@webority/ui-elements 0.198.0 → 0.199.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{WuiCommentThread-BGoAONw2.js → WuiCommentThread-BXd-Z7z1.js} +1 -1
- package/dist/{WuiContextMenu-oKlQvt3V.js → WuiContextMenu-CEJS12YY.js} +1 -1
- package/dist/{WuiDatePicker-B77M2_E7.js → WuiDatePicker-BSAqNqdx.js} +1 -1
- package/dist/{WuiDateRange-BQ1GH9Mu.js → WuiDateRange-ffla_FMG.js} +1 -1
- package/dist/{WuiDrawer-Dj7lXuGm.js → WuiDrawer-RmT2Wp9d.js} +1 -1
- package/dist/{WuiDropdown-6g074v1T.js → WuiDropdown-BRofo083.js} +1 -1
- package/dist/{WuiGantt-wx8VSXiZ.js → WuiGantt-B70jg1w5.js} +1 -1
- package/dist/{WuiHoverCard-DhJcIIM1.js → WuiHoverCard-B_plKt-t.js} +1 -1
- package/dist/{WuiLightbox-DFaHN2Fb.js → WuiLightbox-BSEVtv2x.js} +1 -1
- package/dist/{WuiMentionInput-Dcm3F-e-.js → WuiMentionInput-kUTy26hu.js} +1 -1
- package/dist/WuiModal-LgGTsIpb.js +1 -0
- package/dist/{WuiNavigationMenu-BvYLbEmA.js → WuiNavigationMenu-BebcHPiK.js} +1 -1
- package/dist/{WuiNotificationCenter-DWFg3H-C.js → WuiNotificationCenter-BSXqhz9M.js} +1 -1
- package/dist/{WuiPhone-qw_6W3Q2.js → WuiPhone-D7yYYLYr.js} +1 -1
- package/dist/{WuiPopover-BvWKRNQY.js → WuiPopover-y07DZA1J.js} +1 -1
- package/dist/{WuiSelect-DqHu2OW_.js → WuiSelect-DALTYOKl.js} +1 -1
- package/dist/{WuiShortcuts-CHOfUeFx.js → WuiShortcuts-Z8X5aSTz.js} +1 -1
- package/dist/{WuiTimePicker-Bl3GcIS_.js → WuiTimePicker-D0cM0pPe.js} +1 -1
- package/dist/WuiTour-b7N5FTLM.js +1 -0
- package/dist/{WuiWhatsNew-Dm4Yl68x.js → WuiWhatsNew-naVvdes5.js} +1 -1
- package/dist/WuiWizardStep-D1Ea6_9L.js +1 -0
- package/dist/{chips-DCkeuEvb.js → chips-BzSOOCI-.js} +1 -1
- package/dist/elements/comment-thread.js +1 -1
- package/dist/elements/context-menu.js +1 -1
- package/dist/elements/date-range.js +1 -1
- package/dist/elements/datepicker.js +1 -1
- package/dist/elements/drawer.js +1 -1
- package/dist/elements/dropdown.js +1 -1
- package/dist/elements/filter-popover.js +1 -1
- package/dist/elements/gantt.js +1 -1
- package/dist/elements/hover-card.js +1 -1
- package/dist/elements/lightbox.js +1 -1
- package/dist/elements/mention-input.js +1 -1
- package/dist/elements/modal.js +1 -1
- package/dist/elements/navigation-menu.js +1 -1
- package/dist/elements/notification-center.js +1 -1
- package/dist/elements/phone.js +1 -1
- package/dist/elements/popover.js +1 -1
- package/dist/elements/select.js +1 -1
- package/dist/elements/shortcuts.js +1 -1
- package/dist/elements/timepicker.js +1 -1
- package/dist/elements/tour.js +1 -1
- package/dist/elements/whats-new.js +1 -1
- package/dist/elements/wizard.js +1 -1
- package/dist/{filterPopover-DopUJ22D.js → filterPopover-IndnqT7G.js} +1 -1
- package/dist/helpers.js +1 -1
- package/dist/{nativeOverlay-BHD2QV02.js → nativeOverlay-MOABXAAh.js} +1 -1
- package/dist/{search-OPWGeniZ.js → search-Is-q8GR6.js} +1 -1
- package/dist/server.js +1 -1
- package/dist/ui-chart.global.js +15 -15
- package/dist/ui-chart.js +2 -2
- package/dist/ui-elements/calendar-views.global.js +1 -1
- package/dist/ui-elements/carousel.global.js +1 -1
- package/dist/ui-elements/code-block.global.js +1 -1
- package/dist/ui-elements/command-palette.global.js +1 -1
- package/dist/ui-elements/comment-thread.global.js +1 -1
- package/dist/ui-elements/consent-banner.global.js +1 -1
- package/dist/ui-elements/context-menu.global.js +1 -1
- package/dist/ui-elements/dashboard-grid.global.js +1 -1
- package/dist/ui-elements/data-table.global.js +1 -1
- package/dist/ui-elements/date-range.global.js +1 -1
- package/dist/ui-elements/date-time.global.js +1 -1
- package/dist/ui-elements/datepicker.global.js +1 -1
- package/dist/ui-elements/dock.global.js +1 -1
- package/dist/ui-elements/drawer.global.js +1 -1
- package/dist/ui-elements/dropdown.global.js +1 -1
- package/dist/ui-elements/entry-grid.global.js +1 -1
- package/dist/ui-elements/gantt.global.js +1 -1
- package/dist/ui-elements/glyphs-a.global.js +1 -1
- package/dist/ui-elements/glyphs-b.global.js +1 -1
- package/dist/ui-elements/glyphs-c.global.js +1 -1
- package/dist/ui-elements/glyphs-d.global.js +1 -1
- package/dist/ui-elements/glyphs-e.global.js +1 -1
- package/dist/ui-elements/glyphs-f.global.js +1 -1
- package/dist/ui-elements/glyphs-g.global.js +1 -1
- package/dist/ui-elements/glyphs-h.global.js +1 -1
- package/dist/ui-elements/glyphs-i.global.js +1 -1
- package/dist/ui-elements/glyphs-j.global.js +1 -1
- package/dist/ui-elements/glyphs-k.global.js +1 -1
- package/dist/ui-elements/glyphs-l.global.js +1 -1
- package/dist/ui-elements/glyphs-m.global.js +1 -1
- package/dist/ui-elements/glyphs-n.global.js +1 -1
- package/dist/ui-elements/glyphs-o.global.js +1 -1
- package/dist/ui-elements/glyphs-p.global.js +1 -1
- package/dist/ui-elements/glyphs-q.global.js +1 -1
- package/dist/ui-elements/glyphs-r.global.js +1 -1
- package/dist/ui-elements/glyphs-s.global.js +1 -1
- package/dist/ui-elements/glyphs-t.global.js +1 -1
- package/dist/ui-elements/glyphs-u.global.js +1 -1
- package/dist/ui-elements/glyphs-v.global.js +1 -1
- package/dist/ui-elements/glyphs-w.global.js +1 -1
- package/dist/ui-elements/glyphs-x.global.js +1 -1
- package/dist/ui-elements/glyphs-z.global.js +1 -1
- package/dist/ui-elements/glyphs.global.js +1 -1
- package/dist/ui-elements/hover-card.global.js +1 -1
- package/dist/ui-elements/image-crop.global.js +1 -1
- package/dist/ui-elements/inline-edit.global.js +1 -1
- package/dist/ui-elements/kanban.global.js +1 -1
- package/dist/ui-elements/lead-popup.global.js +1 -1
- package/dist/ui-elements/lightbox.global.js +1 -1
- package/dist/ui-elements/markdown.global.js +1 -1
- package/dist/ui-elements/mini-calendar.global.js +1 -1
- package/dist/ui-elements/navigation-menu.global.js +1 -1
- package/dist/ui-elements/notification-center.global.js +1 -1
- package/dist/ui-elements/offline-banner.global.js +1 -1
- package/dist/ui-elements/onboarding-checklist.global.js +1 -1
- package/dist/ui-elements/org-tree.global.js +1 -1
- package/dist/ui-elements/otp.global.js +1 -1
- package/dist/ui-elements/overflow.global.js +1 -1
- package/dist/ui-elements/phone.global.js +1 -1
- package/dist/ui-elements/popover.global.js +1 -1
- package/dist/ui-elements/rating.global.js +1 -1
- package/dist/ui-elements/record-pager.global.js +1 -1
- package/dist/ui-elements/relative-time.global.js +1 -1
- package/dist/ui-elements/saved-views.global.js +1 -1
- package/dist/ui-elements/select-chips.global.js +1 -1
- package/dist/ui-elements/select-recents.global.js +1 -1
- package/dist/ui-elements/select-search.global.js +1 -1
- package/dist/ui-elements/select-window.global.js +1 -1
- package/dist/ui-elements/server.global.js +1 -1
- package/dist/ui-elements/shell.global.js +1 -1
- package/dist/ui-elements/shortcuts.global.js +1 -1
- package/dist/ui-elements/show-more.global.js +1 -1
- package/dist/ui-elements/slider.global.js +1 -1
- package/dist/ui-elements/sortable.global.js +1 -1
- package/dist/ui-elements/status-icon.global.js +1 -1
- package/dist/ui-elements/table-export.global.js +1 -1
- package/dist/ui-elements/timepicker.global.js +1 -1
- package/dist/ui-elements/tour.global.js +1 -1
- package/dist/ui-elements/tree-picker.global.js +1 -1
- package/dist/ui-elements/tree.global.js +1 -1
- package/dist/ui-elements/truncate.global.js +1 -1
- package/dist/ui-elements/whats-new.global.js +1 -1
- package/dist/ui-elements/wizard.global.js +1 -1
- package/dist/ui-elements.global.js +1 -1
- package/dist/ui-elements.js +1 -1
- package/dist/ui-tour.global.js +1 -1
- package/package.json +5 -5
- package/types/WuiModal.d.ts +1 -0
- package/types/chartSpec.d.ts +6 -1
- package/types/nativeOverlay.d.ts +2 -2
- package/dist/WuiModal-DQbVJGUo.js +0 -1
- package/dist/WuiTour-BS7Jd1Tt.js +0 -1
- package/dist/WuiWizardStep-CSS4B8g4.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-Cxeyx0tU.js";import{n as t,r as n,t as r}from"./fieldState-D-zQcXUS.js";import{f as i}from"./formatters-CXMylefd.js";import{t as a}from"./hasOwn-CJsplJ62.js";import{n as o}from"./imeSafeEnter-DeO_3lXy.js";import{n as s}from"./listboxKeyNav-CNso9shL.js";import{i as c,n as l,r as u,t as d}from"./mentionText-BJsw_opZ.js";import{a as f,l as p,s as m}from"./nativeOverlay-BHD2QV02.js";import{t as h}from"./serverHtml-BC6tAyAl.js";import{m as g}from"./wuiHttp-8CYWEbRz.js";import{n as _,r as v,t as y}from"./textStore-Dh5iyZSR.js";import{t as b}from"./mentionInput.g-DJo6d2Gm.js";var x=8,S=40,C=()=>v(`mentionInput`,b),w=`[data-wui-control]`,T=`[data-wui-field]`,E=`[data-wui-menu]`,D=`[data-wui-live]`,O=0,k=e=>!!(e&&d.test(String(e.value??``))&&l(e.label)!==``);function A(e,t){let n=e.getAttribute(`size`);t.classList.toggle(`wui-input-sm`,n===`sm`),t.classList.toggle(`wui-input-lg`,n===`lg`),t.classList.toggle(`wui-input-xl`,n===`xl`)}function j(e,t){t.classList.toggle(`wui-input-underline`,e.classList.contains(`wui-input-underline`))}function M(e,n){n.readOnly=t(e)||e.hasAttribute(`loading`)}function N(e){let t=e.ownerDocument;e.id||=`wui-mention-${++O}`;let n=t.createElement(`textarea`);n.id=`${e.id}-text`,n.className=`form-control wui-mention-input-text`,n.rows=Number(e.getAttribute(`rows`))>0?Number(e.getAttribute(`rows`)):3,n.setAttribute(`data-wui-control`,``),n.setAttribute(`aria-autocomplete`,`list`),n.setAttribute(`aria-controls`,`${e.id}-people`);let r=e.getAttribute(`label`);r&&n.setAttribute(`aria-label`,r);let i=e.getAttribute(`placeholder`);i&&(n.placeholder=i);for(let t of[`aria-describedby`,`aria-invalid`]){let r=e.getAttribute(t);r&&n.setAttribute(t,r)}n.disabled=e.hasAttribute(`disabled`),M(e,n),A(e,n),j(e,n),e.appendChild(n);let a=e.getAttribute(`name`);if(a){let n=t.createElement(`input`);n.type=`hidden`,n.name=a,n.value=e.getAttribute(`value`)??``,n.setAttribute(`data-wui-field`,``),e.appendChild(n)}let o=t.createElement(`div`);o.className=`wui-mention-menu`,o.id=`${e.id}-people`,o.setAttribute(`role`,`listbox`),o.setAttribute(`aria-label`,e.getAttribute(`people-label`)??C().listNameLabel),o.setAttribute(`data-wui-menu`,``),o.setAttribute(`popover`,`manual`),e.appendChild(o);let s=t.createElement(`span`);s.className=`visually-hidden`,s.setAttribute(`data-wui-live`,``),s.setAttribute(`aria-live`,`polite`),s.setAttribute(`aria-atomic`,`true`),e.appendChild(s)}var P=class extends e{_wired;_pendingValue;_text;_mentions;_peopleProp;_declared;_loading;_searchFailed;_query;_results;_active;_timer;_searchSeq;_lastSearch;_abort;_onMenuDown;static get observedAttributes(){return[`disabled`,`readonly`,`loading`,`size`,`class`,`aria-invalid`,`aria-describedby`]}constructor(){super(),this._wired=!1,this._text=``,this._mentions=[],this._peopleProp=null,this._declared=null,this._loading=!1,this._searchFailed=!1,this._query=null,this._results=[],this._active=-1,this._timer=void 0,this._searchSeq=0,this._abort=null,this._onInput=this._onInput.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onCaret=this._onCaret.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onMenuDown=e=>e.preventDefault(),this._onMenuClick=this._onMenuClick.bind(this)}connectedCallback(){for(let e of[`people`,`loading`,`searchFailed`,`value`])if(a(this,e)){let t=Reflect.get(this,e);Reflect.deleteProperty(this,e),Reflect.set(this,e,t)}if(this._wired)return;this._wired=!0,this.querySelector(w)||N(this);let e=this._requireControl();j(this,e);let t=this.querySelector(T)?.value??this.getAttribute(`value`)??``;this._pendingValue===void 0?this._load(t):this._load(this._pendingValue),this._pendingValue=void 0,this._syncState(),e.addEventListener(`input`,this._onInput),e.addEventListener(`keydown`,this._onKeyDown),e.addEventListener(`click`,this._onCaret),e.addEventListener(`keyup`,this._onCaret),this.addEventListener(`focusout`,this._onFocusOut);let n=this._requireMenu();n.addEventListener(`mousedown`,this._onMenuDown),n.addEventListener(`click`,this._onMenuClick),n.addEventListener(`mousemove`,e=>{let t=e.target instanceof Element?e.target.closest(`.wui-mention-option`):null;t&&Number(t.dataset.index)!==this._active&&this._setActive(Number(t.dataset.index),{reveal:!1})})}disconnectedCallback(){this._close(),clearTimeout(this._timer),this._abort?.abort()}attributeChangedCallback(e,t,n){let r=this._control();r&&(e===`disabled`?(r.disabled=n!==null,n!==null&&this._close()):e===`readonly`?(M(this,r),n!==null&&this._close(),this._syncState()):e===`loading`?(M(this,r),this._syncState(),this._query!==null&&this._renderMenu()):e===`size`?A(this,r):e===`class`?j(this,r):n===null?r.removeAttribute(e):r.setAttribute(e,n))}get value(){return c(this._text,this._mentions)}set value(e){let t=e==null?``:String(e);this._wired?t!==this.value&&this._load(t):this._pendingValue=t}get mentions(){let e=/* @__PURE__ */ new Set,t=[];for(let n of[...this._mentions].sort((e,t)=>e.start-t.start))e.has(n.id)||(e.add(n.id),t.push({id:n.id,label:n.label}));return t}get people(){return this._peopleProp?this._peopleProp:(this._declared||=[...this.querySelectorAll(`[data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})),this._declared)}set people(e){this._peopleProp=Array.isArray(e)?e.filter(k):[],this._searchFailed=!1,(this._isOpen()||this._query!==null)&&this._refresh()}get searchFailed(){return this._searchFailed}set searchFailed(e){this._searchFailed=!!e,this._query!==null&&this._renderMenu()}get loading(){return this._loading||this.hasAttribute(`loading`)}set loading(e){this._loading=!!e,this.toggleAttribute(`loading`,this._loading),this._query!==null&&this._renderMenu()}focus(e){this._control()?.focus(e)}clear(){this._load(``),this._emit()}_control(){return this.querySelector(w)}_menu(){return this.querySelector(E)}_requireControl(){let e=this._control();if(!e)throw Error(`<wui-mention-input> has no text box.`);return e}_requireMenu(){let e=this._menu();if(!e)throw Error(`<wui-mention-input> has no people list.`);return e}_load(e){let{text:t,mentions:n}=u(e);this._text=t,this._mentions=n;let r=this._control();r&&(r.defaultValue=t,r.value=t),this._syncField(),this._close()}_syncField(){let e=this.querySelector(T);e&&(e.value=this.value)}_emit(){this._syncField(),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{value:this.value,mentions:this.mentions}}))}_onInput(){let e=this._requireControl(),t=e.value,n=this._text,r=t.length-n.length,i=Math.min(n.length,t.length),a=Math.max(0,Math.min(i,e.selectionEnd-Math.max(r,0))),o=0;for(;o<a&&n[o]===t[o];)o++;let s=0;for(;s<i-o&&n[n.length-1-s]===t[t.length-1-s];)s++;let c=n.length-s;this._mentions=this._mentions.filter(e=>e.end<=o||e.start>=c).map(e=>e.start>=c?{...e,start:e.start+r,end:e.end+r}:e),this._text=t,this._emit(),this._onCaret()}_onCaret(e){if(e instanceof KeyboardEvent&&e.type===`keyup`&&[`ArrowUp`,`ArrowDown`,`Enter`,`Tab`,`Escape`].includes(e.key))return;let t=this._queryAtCaret();t?this._query&&t.text===this._query.text&&t.start===this._query.start||(this._query=t,this._refresh()):this._close()}_queryAtCaret(){let e=this._control();if(!e||r(this)||e.selectionStart!==e.selectionEnd)return null;let t=e.selectionStart,n=this._text,i=n.lastIndexOf(`@`,t-1);if(i<0||i>0&&!/[\s([{"'“‘]/.test(n.charAt(i-1)))return null;let a=n.slice(i+1,t);return a.length>40||/[\n@]/.test(a)||/^\s/.test(a)||/\s{2}/.test(a)||this._mentions.some(e=>i>=e.start&&i<e.end)?null:{start:i,end:t,text:a}}_refresh(){if(!this._query)return;let e=this.hasAttribute(`remote`)||this.hasAttribute(`source`);if(e&&this._query.text.length<this._minChars()){this._results=[],this._close();return}e&&!this._answered(this._query.text)&&this._search(this._query.text);let t=this._query.text.toLowerCase(),n=e?this.people:this.people.filter(e=>l(e.label).toLowerCase().includes(t));this._results=n.slice(0,8),this._renderMenu()}_answered(e){return this._lastSearch===e}_minChars(){let e=this.getAttribute(`min-chars`),t=e==null||e===``?1:Number(e);return Number.isFinite(t)&&t>=0?t:1}_debounce(){let e=this.getAttribute(`debounce`),t=e==null||e===``?250:Number(e);return Number.isFinite(t)&&t>=0?t:250}_search(e){this._lastSearch=e,clearTimeout(this._timer);let t=++this._searchSeq;this._timer=setTimeout(()=>{let n=this.getAttribute(`source`);n?this._fetchPeople(n,e,t):this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:t}}))},this._debounce())}async _fetchPeople(e,t,n){this._abort?.abort();let r=new AbortController;this._abort=r,this.loading=!0;let i=`${e}${e.includes(`?`)?`&`:`?`}q=${encodeURIComponent(t)}`,a=await g(i,{signal:r.signal});if(n!==this._searchSeq)return;if(this._abort=null,!a.ok){this._peopleProp=[],this._searchFailed=!0,this.loading=!1,this._refresh();return}this._searchFailed=!1;let o=h(a.html);this._peopleProp=[...o.querySelectorAll(`wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})).filter(k),this.loading=!1,this._refresh()}_isOpen(){let e=this._menu();return e!==null&&m(e)}_renderMenu(){let e=this._menu(),t=this._control();if(!e||!t||!this._query)return;this._syncState();let n=this.ownerDocument;if(e.replaceChildren(),this._results.forEach((t,r)=>{let i=n.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${e.id}-${r}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(r),t.src){let e=n.createElement(`img`);e.className=`wui-mention-option-photo`,e.src=t.src,e.alt=``,i.appendChild(e)}let a=n.createElement(`span`);a.className=`wui-mention-option-text`;let o=n.createElement(`span`);if(o.className=`wui-mention-option-label`,o.textContent=l(t.label),a.appendChild(o),t.description){let e=n.createElement(`span`);e.className=`wui-mention-option-description`,e.textContent=String(t.description),a.appendChild(e)}i.appendChild(a),e.appendChild(i)}),!this._results.length){let t=n.createElement(`div`);t.className=`wui-mention-empty`,t.textContent=this.loading?C().searchingLabel:this._searchFailed?C().searchFailedMessage:`${C().noMatchLabel} “${this._query.text}”`,e.appendChild(t)}p(t,e,{mode:`manual`}),this._setActive(this._results.length?0:-1),this.loading||this._announce(this._results.length?_(C(),`foundText`,this._results.length,{count:i(this._results.length,{decimals:0})}):this._searchFailed?C().searchFailedMessage:`${C().noMatchLabel}.`)}_syncState(){let e=this._control();e&&n(this,e)}_close(){this._query=null,this._lastSearch=void 0,clearTimeout(this._timer);let e=this._menu();if(e){let t=m(e);f(e),t&&e.replaceChildren()}this._active=-1,this._control()?.removeAttribute(`aria-activedescendant`)}_setActive(e,{reveal:t=!0}={}){let n=this._requireMenu(),r=[...n.querySelectorAll(`.wui-mention-option`)];this._active=e>=0&&e<r.length?e:-1;let i=this._active>=0?r[this._active]??null:null;for(let e of r)e.setAttribute(`aria-selected`,e===i?`true`:`false`);s(n,i),i?(t&&i.scrollIntoView?.({block:`nearest`}),this._requireControl().setAttribute(`aria-activedescendant`,i.id)):this._requireControl().removeAttribute(`aria-activedescendant`)}_onKeyDown(e){if(this._isOpen()&&this._query){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=this._results.length;if(!t)return;let n=e.key===`ArrowDown`?1:-1;this._setActive((this._active+n+t)%t);return}if((o(e)||e.key===`Tab`)&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._active>=0){e.preventDefault(),this._pick(this._results[this._active]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close();return}}o(e)&&(e.ctrlKey||e.metaKey)?(e.preventDefault(),this.dispatchEvent(new CustomEvent(`wui:mention-input:submit`,{bubbles:!0,detail:{value:this.value}}))):e.key===`Backspace`&&this._removeWholeMention(e)}_removeWholeMention(e){let t=this._requireControl();if(t.selectionStart!==t.selectionEnd)return;let n=t.selectionStart,r=this._mentions.find(e=>e.end===n);r&&(e.preventDefault(),this._replace(r.start,r.end,``))}_onMenuClick(e){let t=e.target instanceof Element?e.target.closest(`.wui-mention-option`):null;t&&this._pick(this._results[Number(t.dataset.index)])}_pick(e){if(!e||!this._query)return;let t=l(e.label),{start:n,end:r}=this._query,i=this._text.slice(r),a=`@${t}${/^\s/.test(i)?``:` `}`;this._replace(n,r,a,{id:String(e.value),label:t}),this._announce(y(C().mentioned,{label:t}))}_replace(e,t,n,r){let i=this._requireControl(),a=n.length-(t-e);this._mentions=this._mentions.filter(n=>n.end<=e||n.start>=t).map(e=>e.start>=t?{...e,start:e.start+a,end:e.end+a}:e),r&&this._mentions.push({start:e,end:e+1+r.label.length,id:r.id,label:r.label}),this._text=this._text.slice(0,e)+n+this._text.slice(t),i.value=this._text;let o=e+n.length;i.setSelectionRange(o,o),this._close(),i.focus(),this._emit()}_onFocusOut(e){e.relatedTarget instanceof Node&&this.contains(e.relatedTarget)||this._close()}_announce(e){let t=this.querySelector(D);t&&(t.textContent=``,t.textContent=e)}};export{x as n,P as r,S as t};
|
|
1
|
+
import{t as e}from"./elementBase-Cxeyx0tU.js";import{n as t,r as n,t as r}from"./fieldState-D-zQcXUS.js";import{f as i}from"./formatters-CXMylefd.js";import{t as a}from"./hasOwn-CJsplJ62.js";import{n as o}from"./imeSafeEnter-DeO_3lXy.js";import{n as s}from"./listboxKeyNav-CNso9shL.js";import{i as c,n as l,r as u,t as d}from"./mentionText-BJsw_opZ.js";import{a as f,l as p,s as m}from"./nativeOverlay-MOABXAAh.js";import{t as h}from"./serverHtml-BC6tAyAl.js";import{m as g}from"./wuiHttp-8CYWEbRz.js";import{n as _,r as v,t as y}from"./textStore-Dh5iyZSR.js";import{t as b}from"./mentionInput.g-DJo6d2Gm.js";var x=8,S=40,C=()=>v(`mentionInput`,b),w=`[data-wui-control]`,T=`[data-wui-field]`,E=`[data-wui-menu]`,D=`[data-wui-live]`,O=0,k=e=>!!(e&&d.test(String(e.value??``))&&l(e.label)!==``);function A(e,t){let n=e.getAttribute(`size`);t.classList.toggle(`wui-input-sm`,n===`sm`),t.classList.toggle(`wui-input-lg`,n===`lg`),t.classList.toggle(`wui-input-xl`,n===`xl`)}function j(e,t){t.classList.toggle(`wui-input-underline`,e.classList.contains(`wui-input-underline`))}function M(e,n){n.readOnly=t(e)||e.hasAttribute(`loading`)}function N(e){let t=e.ownerDocument;e.id||=`wui-mention-${++O}`;let n=t.createElement(`textarea`);n.id=`${e.id}-text`,n.className=`form-control wui-mention-input-text`,n.rows=Number(e.getAttribute(`rows`))>0?Number(e.getAttribute(`rows`)):3,n.setAttribute(`data-wui-control`,``),n.setAttribute(`aria-autocomplete`,`list`),n.setAttribute(`aria-controls`,`${e.id}-people`);let r=e.getAttribute(`label`);r&&n.setAttribute(`aria-label`,r);let i=e.getAttribute(`placeholder`);i&&(n.placeholder=i);for(let t of[`aria-describedby`,`aria-invalid`]){let r=e.getAttribute(t);r&&n.setAttribute(t,r)}n.disabled=e.hasAttribute(`disabled`),M(e,n),A(e,n),j(e,n),e.appendChild(n);let a=e.getAttribute(`name`);if(a){let n=t.createElement(`input`);n.type=`hidden`,n.name=a,n.value=e.getAttribute(`value`)??``,n.setAttribute(`data-wui-field`,``),e.appendChild(n)}let o=t.createElement(`div`);o.className=`wui-mention-menu`,o.id=`${e.id}-people`,o.setAttribute(`role`,`listbox`),o.setAttribute(`aria-label`,e.getAttribute(`people-label`)??C().listNameLabel),o.setAttribute(`data-wui-menu`,``),o.setAttribute(`popover`,`manual`),e.appendChild(o);let s=t.createElement(`span`);s.className=`visually-hidden`,s.setAttribute(`data-wui-live`,``),s.setAttribute(`aria-live`,`polite`),s.setAttribute(`aria-atomic`,`true`),e.appendChild(s)}var P=class extends e{_wired;_pendingValue;_text;_mentions;_peopleProp;_declared;_loading;_searchFailed;_query;_results;_active;_timer;_searchSeq;_lastSearch;_abort;_onMenuDown;static get observedAttributes(){return[`disabled`,`readonly`,`loading`,`size`,`class`,`aria-invalid`,`aria-describedby`]}constructor(){super(),this._wired=!1,this._text=``,this._mentions=[],this._peopleProp=null,this._declared=null,this._loading=!1,this._searchFailed=!1,this._query=null,this._results=[],this._active=-1,this._timer=void 0,this._searchSeq=0,this._abort=null,this._onInput=this._onInput.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onCaret=this._onCaret.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onMenuDown=e=>e.preventDefault(),this._onMenuClick=this._onMenuClick.bind(this)}connectedCallback(){for(let e of[`people`,`loading`,`searchFailed`,`value`])if(a(this,e)){let t=Reflect.get(this,e);Reflect.deleteProperty(this,e),Reflect.set(this,e,t)}if(this._wired)return;this._wired=!0,this.querySelector(w)||N(this);let e=this._requireControl();j(this,e);let t=this.querySelector(T)?.value??this.getAttribute(`value`)??``;this._pendingValue===void 0?this._load(t):this._load(this._pendingValue),this._pendingValue=void 0,this._syncState(),e.addEventListener(`input`,this._onInput),e.addEventListener(`keydown`,this._onKeyDown),e.addEventListener(`click`,this._onCaret),e.addEventListener(`keyup`,this._onCaret),this.addEventListener(`focusout`,this._onFocusOut);let n=this._requireMenu();n.addEventListener(`mousedown`,this._onMenuDown),n.addEventListener(`click`,this._onMenuClick),n.addEventListener(`mousemove`,e=>{let t=e.target instanceof Element?e.target.closest(`.wui-mention-option`):null;t&&Number(t.dataset.index)!==this._active&&this._setActive(Number(t.dataset.index),{reveal:!1})})}disconnectedCallback(){this._close(),clearTimeout(this._timer),this._abort?.abort()}attributeChangedCallback(e,t,n){let r=this._control();r&&(e===`disabled`?(r.disabled=n!==null,n!==null&&this._close()):e===`readonly`?(M(this,r),n!==null&&this._close(),this._syncState()):e===`loading`?(M(this,r),this._syncState(),this._query!==null&&this._renderMenu()):e===`size`?A(this,r):e===`class`?j(this,r):n===null?r.removeAttribute(e):r.setAttribute(e,n))}get value(){return c(this._text,this._mentions)}set value(e){let t=e==null?``:String(e);this._wired?t!==this.value&&this._load(t):this._pendingValue=t}get mentions(){let e=/* @__PURE__ */ new Set,t=[];for(let n of[...this._mentions].sort((e,t)=>e.start-t.start))e.has(n.id)||(e.add(n.id),t.push({id:n.id,label:n.label}));return t}get people(){return this._peopleProp?this._peopleProp:(this._declared||=[...this.querySelectorAll(`[data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})),this._declared)}set people(e){this._peopleProp=Array.isArray(e)?e.filter(k):[],this._searchFailed=!1,(this._isOpen()||this._query!==null)&&this._refresh()}get searchFailed(){return this._searchFailed}set searchFailed(e){this._searchFailed=!!e,this._query!==null&&this._renderMenu()}get loading(){return this._loading||this.hasAttribute(`loading`)}set loading(e){this._loading=!!e,this.toggleAttribute(`loading`,this._loading),this._query!==null&&this._renderMenu()}focus(e){this._control()?.focus(e)}clear(){this._load(``),this._emit()}_control(){return this.querySelector(w)}_menu(){return this.querySelector(E)}_requireControl(){let e=this._control();if(!e)throw Error(`<wui-mention-input> has no text box.`);return e}_requireMenu(){let e=this._menu();if(!e)throw Error(`<wui-mention-input> has no people list.`);return e}_load(e){let{text:t,mentions:n}=u(e);this._text=t,this._mentions=n;let r=this._control();r&&(r.defaultValue=t,r.value=t),this._syncField(),this._close()}_syncField(){let e=this.querySelector(T);e&&(e.value=this.value)}_emit(){this._syncField(),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{value:this.value,mentions:this.mentions}}))}_onInput(){let e=this._requireControl(),t=e.value,n=this._text,r=t.length-n.length,i=Math.min(n.length,t.length),a=Math.max(0,Math.min(i,e.selectionEnd-Math.max(r,0))),o=0;for(;o<a&&n[o]===t[o];)o++;let s=0;for(;s<i-o&&n[n.length-1-s]===t[t.length-1-s];)s++;let c=n.length-s;this._mentions=this._mentions.filter(e=>e.end<=o||e.start>=c).map(e=>e.start>=c?{...e,start:e.start+r,end:e.end+r}:e),this._text=t,this._emit(),this._onCaret()}_onCaret(e){if(e instanceof KeyboardEvent&&e.type===`keyup`&&[`ArrowUp`,`ArrowDown`,`Enter`,`Tab`,`Escape`].includes(e.key))return;let t=this._queryAtCaret();t?this._query&&t.text===this._query.text&&t.start===this._query.start||(this._query=t,this._refresh()):this._close()}_queryAtCaret(){let e=this._control();if(!e||r(this)||e.selectionStart!==e.selectionEnd)return null;let t=e.selectionStart,n=this._text,i=n.lastIndexOf(`@`,t-1);if(i<0||i>0&&!/[\s([{"'“‘]/.test(n.charAt(i-1)))return null;let a=n.slice(i+1,t);return a.length>40||/[\n@]/.test(a)||/^\s/.test(a)||/\s{2}/.test(a)||this._mentions.some(e=>i>=e.start&&i<e.end)?null:{start:i,end:t,text:a}}_refresh(){if(!this._query)return;let e=this.hasAttribute(`remote`)||this.hasAttribute(`source`);if(e&&this._query.text.length<this._minChars()){this._results=[],this._close();return}e&&!this._answered(this._query.text)&&this._search(this._query.text);let t=this._query.text.toLowerCase(),n=e?this.people:this.people.filter(e=>l(e.label).toLowerCase().includes(t));this._results=n.slice(0,8),this._renderMenu()}_answered(e){return this._lastSearch===e}_minChars(){let e=this.getAttribute(`min-chars`),t=e==null||e===``?1:Number(e);return Number.isFinite(t)&&t>=0?t:1}_debounce(){let e=this.getAttribute(`debounce`),t=e==null||e===``?250:Number(e);return Number.isFinite(t)&&t>=0?t:250}_search(e){this._lastSearch=e,clearTimeout(this._timer);let t=++this._searchSeq;this._timer=setTimeout(()=>{let n=this.getAttribute(`source`);n?this._fetchPeople(n,e,t):this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:t}}))},this._debounce())}async _fetchPeople(e,t,n){this._abort?.abort();let r=new AbortController;this._abort=r,this.loading=!0;let i=`${e}${e.includes(`?`)?`&`:`?`}q=${encodeURIComponent(t)}`,a=await g(i,{signal:r.signal});if(n!==this._searchSeq)return;if(this._abort=null,!a.ok){this._peopleProp=[],this._searchFailed=!0,this.loading=!1,this._refresh();return}this._searchFailed=!1;let o=h(a.html);this._peopleProp=[...o.querySelectorAll(`wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})).filter(k),this.loading=!1,this._refresh()}_isOpen(){let e=this._menu();return e!==null&&m(e)}_renderMenu(){let e=this._menu(),t=this._control();if(!e||!t||!this._query)return;this._syncState();let n=this.ownerDocument;if(e.replaceChildren(),this._results.forEach((t,r)=>{let i=n.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${e.id}-${r}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(r),t.src){let e=n.createElement(`img`);e.className=`wui-mention-option-photo`,e.src=t.src,e.alt=``,i.appendChild(e)}let a=n.createElement(`span`);a.className=`wui-mention-option-text`;let o=n.createElement(`span`);if(o.className=`wui-mention-option-label`,o.textContent=l(t.label),a.appendChild(o),t.description){let e=n.createElement(`span`);e.className=`wui-mention-option-description`,e.textContent=String(t.description),a.appendChild(e)}i.appendChild(a),e.appendChild(i)}),!this._results.length){let t=n.createElement(`div`);t.className=`wui-mention-empty`,t.textContent=this.loading?C().searchingLabel:this._searchFailed?C().searchFailedMessage:`${C().noMatchLabel} “${this._query.text}”`,e.appendChild(t)}p(t,e,{mode:`manual`}),this._setActive(this._results.length?0:-1),this.loading||this._announce(this._results.length?_(C(),`foundText`,this._results.length,{count:i(this._results.length,{decimals:0})}):this._searchFailed?C().searchFailedMessage:`${C().noMatchLabel}.`)}_syncState(){let e=this._control();e&&n(this,e)}_close(){this._query=null,this._lastSearch=void 0,clearTimeout(this._timer);let e=this._menu();if(e){let t=m(e);f(e),t&&e.replaceChildren()}this._active=-1,this._control()?.removeAttribute(`aria-activedescendant`)}_setActive(e,{reveal:t=!0}={}){let n=this._requireMenu(),r=[...n.querySelectorAll(`.wui-mention-option`)];this._active=e>=0&&e<r.length?e:-1;let i=this._active>=0?r[this._active]??null:null;for(let e of r)e.setAttribute(`aria-selected`,e===i?`true`:`false`);s(n,i),i?(t&&i.scrollIntoView?.({block:`nearest`}),this._requireControl().setAttribute(`aria-activedescendant`,i.id)):this._requireControl().removeAttribute(`aria-activedescendant`)}_onKeyDown(e){if(this._isOpen()&&this._query){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=this._results.length;if(!t)return;let n=e.key===`ArrowDown`?1:-1;this._setActive((this._active+n+t)%t);return}if((o(e)||e.key===`Tab`)&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._active>=0){e.preventDefault(),this._pick(this._results[this._active]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close();return}}o(e)&&(e.ctrlKey||e.metaKey)?(e.preventDefault(),this.dispatchEvent(new CustomEvent(`wui:mention-input:submit`,{bubbles:!0,detail:{value:this.value}}))):e.key===`Backspace`&&this._removeWholeMention(e)}_removeWholeMention(e){let t=this._requireControl();if(t.selectionStart!==t.selectionEnd)return;let n=t.selectionStart,r=this._mentions.find(e=>e.end===n);r&&(e.preventDefault(),this._replace(r.start,r.end,``))}_onMenuClick(e){let t=e.target instanceof Element?e.target.closest(`.wui-mention-option`):null;t&&this._pick(this._results[Number(t.dataset.index)])}_pick(e){if(!e||!this._query)return;let t=l(e.label),{start:n,end:r}=this._query,i=this._text.slice(r),a=`@${t}${/^\s/.test(i)?``:` `}`;this._replace(n,r,a,{id:String(e.value),label:t}),this._announce(y(C().mentioned,{label:t}))}_replace(e,t,n,r){let i=this._requireControl(),a=n.length-(t-e);this._mentions=this._mentions.filter(n=>n.end<=e||n.start>=t).map(e=>e.start>=t?{...e,start:e.start+a,end:e.end+a}:e),r&&this._mentions.push({start:e,end:e+1+r.label.length,id:r.id,label:r.label}),this._text=this._text.slice(0,e)+n+this._text.slice(t),i.value=this._text;let o=e+n.length;i.setSelectionRange(o,o),this._close(),i.focus(),this._emit()}_onFocusOut(e){e.relatedTarget instanceof Node&&this.contains(e.relatedTarget)||this._close()}_announce(e){let t=this.querySelector(D);t&&(t.textContent=``,t.textContent=e)}};export{x as n,P as r,S as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./elementBase-Cxeyx0tU.js";import{h as t,o as n,p as r,u as i}from"./nativeOverlay-MOABXAAh.js";var a=class extends e{_doc;_release;_opener;_returnTo;_session;_closing;_reopen;static get observedAttributes(){return[`open`,`static`,`no-escape`]}constructor(){super(),this._doc=null,this._release=null,this._opener=null,this._returnTo=null,this._session=0,this._closing=!1,this._reopen=!1}connectedCallback(){this._doc=this.ownerDocument,t(this._doc),this.hasAttribute(`open`)&&this._open()}disconnectedCallback(){this._session++,this._closing=!1,this._reopen=!1;let e=this.querySelector(`dialog`);this._release&&e instanceof HTMLDialogElement&&e.close(),this._releaseDialog(),this._opener=null,this._returnTo=null,this._doc=null}attributeChangedCallback(e){this._doc&&e===`open`&&(this.hasAttribute(`open`)?this._open():this._close())}get isOpen(){return this.hasAttribute(`open`)}show(e){e&&(this._opener=e),this.setAttribute(`open`,``)}hide(){this.removeAttribute(`open`)}_open(){if(this._closing){this._reopen=!0;return}if(this._release)return;let e=++this._session,t=this._opener;if(this._returnTo=t,this._opener=null,this.dispatchEvent(new CustomEvent(`wui-modal-open`,{bubbles:!0,detail:{trigger:t}})),!this.isOpen)return;let n=this._dialog();this._release=i(n,{escape:!this.hasAttribute(`no-escape`),backdrop:this.hasAttribute(`static`)?null:this._card(n),focus:`first-control`,onRequestClose:e=>this._requestClose(e)}),this._settle(e,n)}_close(){if(this._closing){this._reopen=!1;return}if(!this._release)return;this._closing=!0;let e=this._session,t=this._dialog();n(t).then(()=>{e===this._session&&(this._closing=!1,this._releaseDialog(),r(this._returnTo,t),this._returnTo=null,this.dispatchEvent(new CustomEvent(`wui-modal-closed`,{bubbles:!0})),this._reopen&&(this._reopen=!1,this.isOpen&&this._open()))})}_settle(e,t){let n=t.getAnimations?.()??[];n.length?Promise.allSettled(n.map(e=>e.finished)).then(()=>{e===this._session&&this.isOpen&&this._announceOpened()}):this._announceOpened()}_announceOpened(){this.dispatchEvent(new CustomEvent(`wui-modal-opened`,{bubbles:!0}))}_requestClose(e){this.dispatchEvent(new CustomEvent(`wui-modal-close`,{bubbles:!0,cancelable:!0,detail:{reason:e}}))&&this.removeAttribute(`open`)}_releaseDialog(){let e=this._release;this._release=null,e?.()}_card(e){let t=e.querySelector(`.modal-content.wui-modal`);if(!(t instanceof HTMLElement))throw TypeError(`wui-modal has no .modal-content.wui-modal`);return t}_dialog(){let e=this.querySelector(`dialog`);if(!(e instanceof HTMLDialogElement))throw TypeError(`wui-modal has no <dialog>`);return e}};export{a as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{a as n,l as r,s as i}from"./nativeOverlay-
|
|
1
|
+
import{i as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{a as n,l as r,s as i}from"./nativeOverlay-MOABXAAh.js";import{n as a,t as o}from"./rtl-g7G8Bsib.js";var s=`.wui-nav-menu-link`,c=`(max-width: 767.98px)`,l=`data-open`,u=e=>e instanceof Element?e:e instanceof Node?e.parentElement:null,d=e=>[...e].filter(e=>e instanceof HTMLElement),f=e=>{let t=e.children[0];if(!(t instanceof HTMLElement))throw Error(`Navigation entry has no control.`);return t},p=e=>{let t=e.children[1];return t instanceof HTMLElement?t:null},m=(e,t,n)=>{let r=e[t];if(r===void 0)throw Error(n);return r},h=class extends t{constructor(){super(),this._onClick=e=>this._handleClick(e),this._onKeyDown=e=>this._handleKeyDown(e),this._onFocusOut=e=>{if(this._vertical())return;let t=this._openItem(),n=e.relatedTarget;t&&n instanceof Node&&!t.contains(n)&&this._set(t,!1)},this._onPointerDown=()=>{this._pressedOpen=this._openItem()},this._onModeChange=()=>{if(this._vertical())return;let e=this._openItem();e&&this._set(e,!1)},this._onOutsidePress=e=>{let t=this._openItem();t&&!e.composedPath().includes(t)&&this._set(t,!1)},this._pressedOpen=null,this._media=null}connectedCallback(){this._teardown(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this._media=window.matchMedia(c),this._media.addEventListener(`change`,this._onModeChange)}disconnectedCallback(){this._teardown()}open(e){let t=this._items().find(t=>{let n=t.children[0];return n instanceof HTMLElement&&this._isTrigger(n)&&n.dataset.key===e});t&&this._set(t,!0)}close(e=!1){let t=this._openItem();t&&(this._set(t,!1),e&&f(t).focus({preventScroll:!0}))}_items(){return d(this.querySelectorAll(`.wui-nav-menu-item`))}_openItem(){return this._items().find(e=>{let t=p(e);return t!==null&&this._isOpen(t)})??null}_vertical(){return this.getAttribute(`orientation`)===`vertical`}_isOpen(e){return e.hasAttribute(l)||i(e)}_isTrigger(e){return!!e?.classList.contains(`wui-nav-menu-trigger`)}_entries(){return this._items().map(f)}_links(e){let t=p(e);return t?d(t.querySelectorAll(s)):[]}_set(e,t){let a=p(e);if(!a)return;let o=f(e);if(t){let t=this._openItem();if(t&&t!==e&&this._set(t,!1),this._isOpen(a))return;o.setAttribute(`aria-expanded`,`true`),this._vertical()?a.setAttribute(l,``):window.matchMedia(c).matches?(a.setAttribute(l,``),document.addEventListener(`pointerdown`,this._onOutsidePress,!0)):r(o,a,{mode:`auto`,below:!0,flipAlign:!0,onClosed:()=>this._settle(e)}),this._emit(o,!0)}else a.removeAttribute(l),document.removeEventListener(`pointerdown`,this._onOutsidePress,!0),i(a)&&n(a),this._settle(e)}_settle(e){let t=f(e);t.getAttribute(`aria-expanded`)!==`false`&&(t.setAttribute(`aria-expanded`,`false`),this._emit(t,!1))}_emit(e,t){this.dispatchEvent(new CustomEvent(`wui-navigation-menu:toggle`,{bubbles:!0,detail:{key:e.dataset.key??null,open:t}}))}_handleClick(t){let n=this._pressedOpen;this._pressedOpen=null;let r=u(t.target),i=r?.closest(`.wui-nav-menu-trigger`);if(i&&this.contains(i)){let t=e(i.parentElement,`Navigation trigger has no entry.`),r=e(p(t),`Navigation entry has no panel.`),a=n===t||this._isOpen(r);this._set(t,!a);return}let a=r?.closest(s);a&&this.contains(a)&&this.close()}_handleKeyDown(t){if(this._pressedOpen=null,t.altKey||t.ctrlKey||t.metaKey)return;let n=u(t.target)?.closest(`.wui-nav-menu-trigger, .wui-nav-menu-toplink, .wui-nav-menu-link`);if(!(n instanceof HTMLElement)||!this.contains(n))return;let r=this._openItem();if(t.key===`Escape`){if(!r||!p(r)?.hasAttribute(l))return;t.preventDefault(),t.stopPropagation();let e=r.contains(n);this._set(r,!1),e&&f(r).focus({preventScroll:!0});return}if(this._vertical()){this._verticalKey(t,n);return}if(n.matches(s)){this._linkKey(t,n);return}let i=this._entries(),c=i.indexOf(n),d=a(t.key,o(this));if(d===`ArrowRight`||d===`ArrowLeft`||d===`Home`||d===`End`){t.preventDefault();let e=d===`Home`?0:d===`End`?i.length-1:(c+(d===`ArrowRight`?1:-1)+i.length)%i.length;r&&this._set(r,!1),m(i,e,`Navigation has no entry to focus.`).focus({preventScroll:!0})}else if(t.key===`ArrowDown`&&this._isTrigger(n)){t.preventDefault();let r=e(n.parentElement,`Navigation trigger has no entry.`);this._set(r,!0),m(this._links(r),0,`Navigation panel has no link to focus.`).focus({preventScroll:!0})}}_verticalKey(e,t){if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`&&e.key!==`Home`&&e.key!==`End`)return;e.preventDefault();let n=d(this.querySelectorAll(`.wui-nav-menu-trigger, .wui-nav-menu-toplink, .wui-nav-menu-panel[data-open] .wui-nav-menu-link`)),r=n.indexOf(t);m(n,e.key===`Home`?0:e.key===`End`?n.length-1:(r+(e.key===`ArrowDown`?1:-1)+n.length)%n.length,`Navigation has no control to focus.`).focus({preventScroll:!0})}_linkKey(t,n){let r=e(n.closest(`.wui-nav-menu-item`),`Navigation link has no entry.`),i=this._links(r),a=i.indexOf(n);t.key===`ArrowDown`||t.key===`ArrowUp`?(t.preventDefault(),m(i,(a+(t.key===`ArrowDown`?1:-1)+i.length)%i.length,`Navigation panel has no link to focus.`).focus({preventScroll:!0})):t.key===`Home`?(t.preventDefault(),m(i,0,`Navigation panel has no link to focus.`).focus({preventScroll:!0})):t.key===`End`&&(t.preventDefault(),m(i,i.length-1,`Navigation panel has no link to focus.`).focus({preventScroll:!0}))}_teardown(){for(let e of this._items()){let t=p(e);if(!t)continue;let r=t.hasAttribute(l);t.removeAttribute(l),n(t),r&&this._settle(e)}this._media?.removeEventListener(`change`,this._onModeChange),this._media=null,document.removeEventListener(`pointerdown`,this._onOutsidePress,!0),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusout`,this._onFocusOut),this.removeEventListener(`pointerdown`,this._onPointerDown,!0)}};export{h as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{t as n}from"./isDrawn-BbF4phmB.js";import{a as r,l as i,m as a,s as o}from"./nativeOverlay-
|
|
1
|
+
import{i as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{t as n}from"./isDrawn-BbF4phmB.js";import{a as r,l as i,m as a,s as o}from"./nativeOverlay-MOABXAAh.js";import{o as s,r as c,s as l}from"./notificationDays-CZxUShyr.js";import{m as u}from"./wuiHttp-8CYWEbRz.js";import{r as d}from"./textStore-Dh5iyZSR.js";import{t as f}from"./httpFailure.g-DjZzGxPj.js";import{t as p}from"./notificationCentre.g-Cees-vKg.js";var m=()=>d(`notificationCentre`,p),h=`.wui-notification-center-trigger`,g=`.wui-notification-center-panel`,_=`.wui-notification-center-count`,v=`.wui-notification-center-live`,y=`.wui-notification-center-markall`,b=`.wui-notification-center-item`,x=`wui-notification-center-item-read`,S=`.wui-notification-center-unread-label`,C=`.app-tabs`,w=`.wui-notification-center-tabs [role='tablist']`,T=`.wui-notification-center-tabs [role='tab']`,E=`.wui-notification-center-empty`,D=`.wui-notification-center-retry`,O=`.wui-notification-center-earlier`,k=`(max-width: 767.98px)`,A={ArrowDown:1,ArrowUp:-1,Home:`first`,End:`last`},j=e=>!!e,M=()=>({forbidden:m().forbiddenMessage,networkCheck:d(`httpFailure`,f).networkCheckText,client:m().clientMessage,validation:m().clientMessage,server:m().serverMessage,network:m().networkMessage}),N=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},P=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),F=class extends t{constructor(){super(),this._unread=0,this._busy=!1,this._sheet=!1,this._awaitChildren=null,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onToggle=e=>{e.type===`toggle`&&`newState`in e&&e.newState===`closed`&&this._closedByBrowser()},this._onFocusOut=e=>{let t=e.relatedTarget;t instanceof Node&&!this.contains(t)&&this.close()}}static get observedAttributes(){return[`open`]}connectedCallback(){this._unread=this._initialUnread(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`toggle`,this._onToggle,!0),this.isOpen&&(N(this,g)===null||N(this,h)===null)?(this._awaitChildren=new MutationObserver(()=>this._finishAwaitedOpen()),this._awaitChildren.observe(this,{childList:!0})):(this._syncOpen(),this.isOpen&&this._showPanel())}disconnectedCallback(){this._disarmAwait(),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusout`,this._onFocusOut),this.removeEventListener(`toggle`,this._onToggle,!0);let e=N(this,g);e&&r(e)}attributeChangedCallback(e,t,n){e===`open`&&t!==n&&(this._awaitChildren?n===null&&this._disarmAwait():this.isConnected&&(n===null?this._hidePanel():this._showPanel()))}_finishAwaitedOpen(){N(this,g)!==null&&N(this,h)!==null&&(this._disarmAwait(),this._syncOpen(),this._showPanel())}_disarmAwait(){this._awaitChildren?.disconnect(),this._awaitChildren=null}_showPanel(){let t=e(N(this,g),`<wui-notification-center> needs its panel to open.`),n=e(N(this,h),`<wui-notification-center> needs its trigger to open.`);o(t)||(this._sheet=window.matchMedia(k).matches,this._sheet?a(t,!0):i(n,t,{mode:`auto`,onClosed:()=>this._closedByBrowser()}),o(t)&&this._layoutTabs())}_hidePanel(){let e=N(this,g);e&&o(e)&&(this._sheet?a(e,!1):r(e))}_closedByBrowser(){if(!this.isConnected||!this.hasAttribute(`open`))return;let e=N(this,g);this.close({restoreFocus:e?.contains(this.ownerDocument.activeElement)??!1})}get isOpen(){return this.hasAttribute(`open`)}open(){this.isOpen||(e(N(this,g),`<wui-notification-center> needs its panel to open.`),e(N(this,h),`<wui-notification-center> needs its trigger to open.`),this.setAttribute(`open`,``),this._syncOpen(),N(this,g)?.focus(),this._announceToggle())}close({restoreFocus:e=!1}={}){this.isOpen&&(this.removeAttribute(`open`),this._syncOpen(),e&&N(this,h)?.focus(),this._announceToggle())}toggle(){this.isOpen?this.close():this.open()}_announceToggle(){this.dispatchEvent(new CustomEvent(`wui:notification-center:toggle`,{bubbles:!0,detail:{open:this.isOpen}}))}_syncOpen(){this.querySelector(h)?.setAttribute(`aria-expanded`,this.isOpen?`true`:`false`)}_initialUnread(){let e=Number.parseInt(this.getAttribute(`unread`)??``,10);return Number.isInteger(e)&&e>=0?e:this.querySelectorAll(`${b}:not(.${x}):not([data-archived="true"])`).length}_click(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(T);if(n instanceof HTMLElement&&this.contains(n)){if(this.hasAttribute(`controlled`))return;this._pickTab(n);return}let r=t.closest(D);if(r instanceof HTMLElement&&this.contains(r)){if(this.hasAttribute(`controlled`))return;this._emitRetry();return}let i=t.closest(`${h}, ${y}, ${b}`);i instanceof HTMLElement&&this.contains(i)&&(i.matches(h)?this.toggle():this.hasAttribute(`controlled`)||(i.matches(y)?this._markAll():this._markItem(i)))}_key(e){if(!this.isOpen)return;let t=e.target;if(!(t instanceof Element))throw Error(`Keyboard event target is not an element.`);if(!this.querySelector(g)?.contains(t)||t.closest(C))return;let r=A[e.key];if(r===void 0)return;let i=P(this,b).filter(n);if(i.length===0)return;let a=t.closest(b),o=a instanceof HTMLElement?i.indexOf(a):-1,s;s=r===`first`?0:r===`last`?i.length-1:o===-1?r===1?0:i.length-1:Math.min(i.length-1,Math.max(0,o+r)),e.preventDefault(),i[s]?.focus()}_markItem(e){e.classList.contains(x)||(this._applyRead(e),e.dataset.archived!==`true`&&(this._unread=Math.max(0,this._unread-1)),this._render(),this._say(l(this._unread)),this._emitRead([e.dataset.id].filter(j),!1))}async _markAll(){if(this._busy)return;let e=P(this,`${b}:not(.${x})`);if(e.length===0&&this._unread===0)return;let t=e.map(e=>e.dataset.id).filter(j),n=this.getAttribute(`read-action`);if(n){this._setBusy(!0);let e=new URLSearchParams;for(let n of t)e.append(`ids`,n);let r=await u(n,{method:`POST`,body:e});if(this._setBusy(!1),!r.ok){if(r.kind===`session`||r.kind===`aborted`)return;let e=r.kind,t=r.message||M()[e]||m().serverMessage;this._say(t),this.dispatchEvent(new CustomEvent(`wui:notification-center:failed`,{bubbles:!0,detail:{kind:e,message:t}}));return}}for(let t of e)this._applyRead(t);this._unread=0,this._render(),this._say(m().allReadText),this._emitRead(t,!0)}_pickTab(e){let t=e.closest(w);if(t instanceof HTMLElement){for(let n of P(t,T)){let t=n===e;n.classList.toggle(`active`,t),n.setAttribute(`aria-selected`,t?`true`:`false`),n.setAttribute(`tabindex`,t?`0`:`-1`)}this._layoutTabs(),this._filterItems(e.dataset.key)}}_layoutTabs(){for(let e of P(this,w)){let t=N(e,`.app-tab.active`);t&&(e.style.setProperty(`--wui-tab-x`,`${t.offsetLeft}px`),e.style.setProperty(`--wui-tab-w`,`${t.offsetWidth}px`)),e.setAttribute(`data-wui-tabs`,``)}}_filterItems(e){let t=!1;for(let n of P(this,b)){let r=n.dataset.archived===`true`,i=n.classList.contains(x),a=e===`archived`?r:!r&&(e!==`unread`||!i);a&&(t=!0);let o=n.closest(`li`);o&&(o.hidden=!a)}for(let e of P(this,`.wui-notification-center-list section`))e.hidden=[...e.querySelectorAll(`li`)].every(e=>e.hidden);let n=N(this,E);n&&(n.hidden=t);for(let t of P(this,O))t.hidden=e!==`unread`}_applyRead(e){e.classList.add(x),e.querySelector(S)?.remove()}_setBusy(e){this._busy=e;let t=this.querySelector(y);t instanceof HTMLButtonElement&&(t.disabled=e||this._unread===0,e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`))}_render(){let e=N(this,_);e&&(e.textContent=c(this._unread),e.hidden=this._unread===0),this.querySelector(h)?.setAttribute(`aria-label`,s(this.getAttribute(`label`)||m().label,this._unread));let t=this.querySelector(y);t instanceof HTMLButtonElement&&(t.disabled=this._unread===0)}_say(e){let t=this.querySelector(v);t&&(t.textContent=e)}_emitRetry(){this.dispatchEvent(new CustomEvent(`wui:notification-center:retry`,{bubbles:!0}))}_emitRead(e,t){this.dispatchEvent(new CustomEvent(`wui:notification-center:read`,{bubbles:!0,detail:{ids:e,all:t}}))}};export{F as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./countries-DQL9nAUt.js";import{t as n}from"./devWarn-DXdRWZs3.js";import{r}from"./dom-DMQu--xV.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{r as a,t as o}from"./fieldState-D-zQcXUS.js";import{t as s}from"./formMirror-9IpSgeZb.js";import{t as c}from"./iconGlyphs.g-DRNDTVOs.js";import{n as l}from"./imeSafeEnter-DeO_3lXy.js";import{n as u}from"./listboxKeyNav-CNso9shL.js";import{a as d,l as f,s as p}from"./nativeOverlay-BHD2QV02.js";import{r as m,t as h}from"./textStore-Dh5iyZSR.js";import{t as g}from"./phone.g-P66U-SK5.js";var _={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:/* @__PURE__ */ `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:/* @__PURE__ */ `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:/* @__PURE__ */ `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`]},v=new Set(t.map(([e])=>e)),y=/* @__PURE__ */ new Map;for(let[e,t]of Object.entries(_))for(let n of t)y.set(n,e);function b(e){let t=e===void 0?void 0:y.get(e);return t&&v.has(t)?t:null}function x(e){if(!e)return null;let t;try{t=new Intl.Locale(e).region}catch{return null}return t&&v.has(t)?t:null}function S(){let e;try{e=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{e=void 0}let t=typeof navigator>`u`?void 0:navigator.language;return b(e)||x(t)||null}function C(){return Promise.all([import(`./max-ByBKGsXq.js`),import(`./examples.mobile.json-GS1_MGh9.js`)]).then(([e,t])=>w(e,t.default||t))}function w(e,t){return{AsYouType:e.AsYouType,getExampleNumber:e.getExampleNumber,isSupportedCountry:e.isSupportedCountry,isValidPhoneNumber:e.isValidPhoneNumber,parsePhoneNumber:e.parsePhoneNumber,examples:t}}var T=()=>m(`phone`,g);function E(e,t){return e.isSupportedCountry(t)}var D=e=>e?`wui-flag wui-flag-${String(e).toLowerCase()}`:`wui-flag`,O=t=>t?`+${e(t)}`:``,k=null,A=null;function j(){return k?Promise.resolve(k):(A||=C().then(e=>(k=e,k)).catch(e=>(n(`[@webority/ui-elements] <wui-phone> could not load its phone number metadata.`,e),null)),A)}function M(t,n){let r=`+${e(t)}`;return n?.startsWith(r)?n.slice(r.length).trimStart():null}function N(t,n){if(!k||!n||!t||!E(k,t))return n;try{return M(t,new k.AsYouType(t).input(`+${e(t)}${n}`))||n}catch{return n}}function P(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 F(e){if(!k||!e||!E(k,e))return null;try{return M(e,k.getExampleNumber(e,k.examples)?.formatInternational())||null}catch{return null}}function I(e){let t=F(e);return t?h(T().examplePlaceholder,{example:t}):null}function L(e){if(!k||!e)return null;try{if(!k.isValidPhoneNumber(e))return!1;let t=k.parsePhoneNumber(e)?.getType?.();return t===void 0||t===`MOBILE`||t===`FIXED_LINE_OR_MOBILE`}catch{return null}}function R(e){if(!k||!e||!E(k,e))return null;try{let t=k.getExampleNumber(e,k.examples);return t?.nationalNumber?t.nationalNumber.length:null}catch{return null}}function z(e,t,n){if(!k||!E(k,e))return null;try{let r=k.parsePhoneNumber(t,e),i=r?.nationalNumber;return!i||r.country!==e||i.length>n||!t.endsWith(i)?null:i}catch{return null}}function B(e){if(!k||!e?.trim().startsWith(`+`))return null;try{let t=new k.AsYouType;t.input(e.trim());let n=t.getCountry();return!n||!J(t)?null:{country:n,national:t.getNationalNumber()||``}}catch{return null}}function V(t,n){let r=String(n??``).trim();if(!r.startsWith(`+`))return null;let i=r.replace(/[^0-9]/g,``),a=String(e(t));return{country:t,national:i.startsWith(a)?i.slice(a.length):i}}var H=0;function U(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():(H+=1,String(H))}var W=class extends i{static formAssociated=!0;static whenFormatted(){return j().then(()=>void 0)}static get observedAttributes(){return[`value`,`country`,`locked-country`,`placeholder`,`disabled`,`readonly`,`loading`,`required`,`aria-label`,`aria-describedby`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._defaultCountry=S()||``,this._country=this._defaultCountry,this._national=``,this._active=-1,this._committedValue=``,this._validateOnInput=!1}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){let e=K(this.querySelector(`.country-dropdown-menu`),HTMLElement);e&&d(e)}attributeChangedCallback(e,t,n){if(e===`value`)this.value=n;else if(this._rendered){if(e===`aria-label`){let t=this.querySelector(`input[type=tel]`);t&&(n==null?t.removeAttribute(e):t.setAttribute(e,n))}else if(e===`aria-describedby`)this._syncDescribedBy();else if(e===`country`){if(this._locked)return;let e=this.value;if(this._country=n||this._defaultCountry,this._suppressCountryRender)return;this.render(),this.value!==e&&(this._emitInput(),this._emitChange())}else this.render()}}formResetCallback(){this._validateOnInput=!1,this.value=this._defaultValue||``}get _locked(){return(this.getAttribute(`locked-country`)||``).toUpperCase()||null}get value(){return this._national&&this._country?`+${e(this._country)}${this._national}`:``}set value(t){let n=String(t??``).trim();this._locked&&(this._country=this._locked);let r=this._locked?null:B(n);if(r)this._country=r.country,this._national=r.national.replace(/[^0-9]/g,``);else if(n.startsWith(`+`)){let t=n.replace(/[^0-9]/g,``),r=String(e(this._locked||this.getAttribute(`country`)||this._country));r&&t.startsWith(r)&&(t=t.slice(r.length)),this._national=t}else this._national=n.replace(/[^0-9]/g,``);r&&this.getAttribute(`country`)!==this._country?this.setAttribute(`country`,this._country):this._rendered&&this.render(),this._committedValue=this.value,this._syncMirror()}_syncMirror(){s(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._locked||this.getAttribute(`country`)||this._country;let e=this.getAttribute(`placeholder`)||I(this._country)||T().placeholder;this.id||=`wui-phone-${U()}`;let t=`${this.id}-listbox`;this._listboxId=t;let n=this._locked?r(`div`,{class:`phone-country-adornment`},r(`span`,{class:`wui-phone-prefix`},r(`span`,{class:D(this._country),"data-flag":!0,"aria-hidden":`true`}),r(`span`,{class:`phone-dial`,"data-dial":!0},O(this._country)))):r(`div`,{class:`phone-country-adornment`},r(`button`,{type:`button`,class:`country-toggle`,"aria-label":T().chooseCountryLabel,"aria-haspopup":`listbox`,"aria-expanded":`false`,"aria-controls":t,disabled:this.hasAttribute(`disabled`)||void 0},r(`span`,{class:D(this._country),"data-flag":!0,"aria-hidden":`true`}),c(`chevron-down`,{className:`phone-chevron`}),r(`span`,{class:`phone-dial`,"data-dial":!0},O(this._country))),r(`div`,{class:`country-dropdown-menu`,popover:`auto`},r(`div`,{class:`dropdown-search-wrapper`},r(`span`,{class:`dropdown-search-icon`},c(`search`)),r(`input`,{type:`text`,class:`dropdown-search-input`,placeholder:T().searchCountryPlaceholder,"aria-label":T().searchCountriesLabel,"aria-controls":t,"aria-autocomplete":`list`})),r(`div`,{class:`country-list-scroll`,role:`listbox`,id:t,tabindex:`-1`}),r(`div`,{class:`country-empty`,hidden:!0},T().noCountriesFoundLabel))),i=this.getAttribute(`aria-label`),l=this.getAttribute(`aria-describedby`),u=r(`input`,{type:`tel`,class:`form-control`,placeholder:e,value:N(this._country,this._national),"aria-label":i||void 0,"aria-describedby":l||void 0,required:this.hasAttribute(`required`)||void 0,"aria-required":this.hasAttribute(`required`)?`true`:void 0,disabled:this.hasAttribute(`disabled`)||void 0,readonly:o(this)||void 0}),d=this.classList.contains(`wui-input-underline`);this.replaceChildren(r(`div`,{class:d?`phone-input-wrap wui-input-underline`:`phone-input-wrap`},n,u)),this._rendered=!0,a(this,this.querySelector(`input.form-control`)),s(this,this.value),this._wire()}_ensureItems(){let e=K(this.querySelector(`.country-list-scroll`),HTMLElement);if(!e||e.querySelector(`.country-dropdown-item`))return;let n=this._listboxId,i=t.map(([e,t,i],a)=>r(`button`,{type:`button`,role:`option`,id:`${n}-opt-${a}`,class:`country-dropdown-item${e===this._country?` selected`:``}`,"data-iso":e,"aria-selected":String(e===this._country)},r(`span`,{class:D(e),"aria-hidden":`true`}),r(`span`,{class:`country-name-text`},t,r(`span`,{class:`country-code-text`},`+${i}`))));e.prepend(...i)}_itemEls(){return[...this.querySelectorAll(`.country-dropdown-item`)].filter(e=>e instanceof HTMLElement)}_visibleItems(){return this._itemEls().filter(e=>!e.hidden)}_wire(){let t=K(this.querySelector(`.country-toggle`),HTMLButtonElement),n=G(K(this.querySelector(`.phone-input-wrap`),HTMLElement),`phone input wrapper`),r=K(this.querySelector(`.country-dropdown-menu`),HTMLElement),i=K(this.querySelector(`.dropdown-search-input`),HTMLInputElement),a=K(this.querySelector(`.country-list-scroll`),HTMLElement),s=K(this.querySelector(`.country-empty`),HTMLElement),c=G(K(this.querySelector(`input[type=tel]`),HTMLInputElement),`phone input`),m=K(this.querySelector(`[data-flag]`),HTMLElement),g=K(this.querySelector(`[data-dial]`),HTMLElement),_=()=>r!==null&&p(r),v=(e,{reveal:t=!0}={})=>{let n=this._visibleItems();this._active=e,u(G(a,`country list`),e>=0&&n[e]||null);let r=e>=0?n[e]:void 0;r?(t&&r.scrollIntoView({block:`nearest`}),i?.setAttribute(`aria-activedescendant`,r.id)):i?.removeAttribute(`aria-activedescendant`)},y=()=>{_()||(G(t,`country toggle`).setAttribute(`aria-expanded`,`false`),v(-1))},b=()=>{if(o(this)||(this._ensureItems(),f(n,G(r,`country menu`),{mode:`auto`,onClosed:y}),!_()))return;G(t,`country toggle`).setAttribute(`aria-expanded`,`true`);let e=G(i,`country search`);e.value=``,S(``),e.focus(),v(this._visibleItems().findIndex(e=>e.classList.contains(`selected`)))},x=()=>{d(G(r,`country menu`))},S=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)}s&&(s.hidden=n>0)},C=t=>{this._country=t,this.getAttribute(`country`)!==t&&(this._suppressCountryRender=!0,this.setAttribute(`country`,t),this._suppressCountryRender=!1),m&&(m.className=D(t)),g&&(g.textContent=`+${e(t)}`);for(let e of this._itemEls()){let n=e.dataset.iso===t;e.classList.toggle(`selected`,n),e.setAttribute(`aria-selected`,String(n))}this.getAttribute(`placeholder`)||(c.placeholder=I(t)||T().placeholder),this._national&&(c.value=N(t,this._national)),x(),this._syncMirror(),this._emitChange(),this._validateOnInput&&E(O()),c.focus()},w=e=>{let n=this._visibleItems();if(e.key===`ArrowDown`){if(e.preventDefault(),!_()){b();return}v(Math.min(this._active+1,n.length-1))}else if(e.key===`ArrowUp`){if(e.preventDefault(),!_())return;v(Math.max(this._active-1,0))}else if(l(e)){e.preventDefault();let t=n[this._active];_()&&t?.dataset.iso&&C(t.dataset.iso)}else e.key===`Escape`&&_()&&(e.preventDefault(),e.stopPropagation(),x(),G(t,`country toggle`).focus())};t?.addEventListener(`click`,()=>_()?x():b()),t?.addEventListener(`keydown`,e=>{_()?w(e):(e.key===`ArrowDown`||l(e)||e.key===` `)&&(e.preventDefault(),b())}),i&&i.addEventListener(`input`,()=>{S(i.value);let e=this._visibleItems();v(e.length?0:-1)}),a?.addEventListener(`click`,e=>{let t=K(q(e).closest(`.country-dropdown-item`),HTMLElement);t?.dataset.iso&&C(t.dataset.iso)}),a?.addEventListener(`mousemove`,e=>{let t=K(q(e).closest(`.country-dropdown-item`),HTMLElement);t&&!t.classList.contains(`is-active`)&&v(this._visibleItems().indexOf(t),{reveal:!1})}),a?.addEventListener(`mouseleave`,()=>v(-1)),r?.addEventListener(`keydown`,w);let E=e=>{c.classList.toggle(`is-invalid`,e),e?c.setAttribute(`aria-invalid`,`true`):c.removeAttribute(`aria-invalid`);let t=K(this.querySelector(`[data-phone-error]`),HTMLElement);if(e&&!this.hasAttribute(`external-error`)){t||(t=document.createElement(`div`),t.className=`field-error`,t.id=`${this.id}-phone-error`,t.setAttribute(`data-phone-error`,``),n.after(t));let e=F(this._country);t.textContent=this._country?e?h(T().invalidNumberExampleMessage,{example:e}):T().invalidNumberMessage:T().chooseCountryMessage}else t?.remove();this._syncDescribedBy()},O=()=>this._national.length>0&&(!this._country||L(this.value)===!1);c.addEventListener(`input`,e=>{e.stopPropagation();let t=c.selectionStart??c.value.length,n=c.value.slice(0,t).replace(/[^0-9]/g,``).length,r=c.value.replace(/[^0-9]/g,``),i=R(this._country);if(i&&r.length>i){let e=z(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=N(this._country,this._national);if(c.value!==a){c.value=a;let e=P(a,Math.min(n,r.length));c.setSelectionRange(e,e)}this._syncMirror(),this._emitInput(),this._validateOnInput&&E(O())}),c.addEventListener(`change`,e=>e.stopPropagation()),c.addEventListener(`blur`,()=>{let e=O();E(e),e&&(this._validateOnInput=!0),this.value!==this._committedValue&&this._emitChange()}),c.addEventListener(`paste`,e=>{let t=e.clipboardData?.getData(`text`),n=this._locked?V(this._locked,t):B(t);n&&(e.preventDefault(),this._national=n.national.replace(/[^0-9]/g,``),n.country===this._country?c.value=N(this._country,this._national):(this._country=n.country,this.setAttribute(`country`,n.country)),this._syncMirror(),this._emitInput(),this._emitChange(),this._validateOnInput&&c.isConnected&&E(O()),K(this.querySelector(`input[type=tel]`),HTMLInputElement)?.focus())}),this._validateOnInput&&E(O()),j().then(e=>{if(e&&c.isConnected){if(this._national){let e=N(this._country,this._national);c.defaultValue=e,c.value=e}if(!this.getAttribute(`placeholder`)){let e=I(this._country);e&&(c.placeholder=e)}}}),this._syncMirror()}};function G(e,t){if(e==null)throw Error(`${t} missing`);return e}function K(e,t){return e instanceof t?e:null}function q(e){if(!(e.target instanceof Element))throw Error(`Event target is not an element`);return e.target}function J(e){return`getNationalNumber`in e&&typeof e.getNationalNumber==`function`}export{W as t};
|
|
1
|
+
import{n as e,t}from"./countries-DQL9nAUt.js";import{t as n}from"./devWarn-DXdRWZs3.js";import{r}from"./dom-DMQu--xV.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{r as a,t as o}from"./fieldState-D-zQcXUS.js";import{t as s}from"./formMirror-9IpSgeZb.js";import{t as c}from"./iconGlyphs.g-DRNDTVOs.js";import{n as l}from"./imeSafeEnter-DeO_3lXy.js";import{n as u}from"./listboxKeyNav-CNso9shL.js";import{a as d,l as f,s as p}from"./nativeOverlay-MOABXAAh.js";import{r as m,t as h}from"./textStore-Dh5iyZSR.js";import{t as g}from"./phone.g-P66U-SK5.js";var _={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:/* @__PURE__ */ `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:/* @__PURE__ */ `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:/* @__PURE__ */ `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`]},v=new Set(t.map(([e])=>e)),y=/* @__PURE__ */ new Map;for(let[e,t]of Object.entries(_))for(let n of t)y.set(n,e);function b(e){let t=e===void 0?void 0:y.get(e);return t&&v.has(t)?t:null}function x(e){if(!e)return null;let t;try{t=new Intl.Locale(e).region}catch{return null}return t&&v.has(t)?t:null}function S(){let e;try{e=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{e=void 0}let t=typeof navigator>`u`?void 0:navigator.language;return b(e)||x(t)||null}function C(){return Promise.all([import(`./max-ByBKGsXq.js`),import(`./examples.mobile.json-GS1_MGh9.js`)]).then(([e,t])=>w(e,t.default||t))}function w(e,t){return{AsYouType:e.AsYouType,getExampleNumber:e.getExampleNumber,isSupportedCountry:e.isSupportedCountry,isValidPhoneNumber:e.isValidPhoneNumber,parsePhoneNumber:e.parsePhoneNumber,examples:t}}var T=()=>m(`phone`,g);function E(e,t){return e.isSupportedCountry(t)}var D=e=>e?`wui-flag wui-flag-${String(e).toLowerCase()}`:`wui-flag`,O=t=>t?`+${e(t)}`:``,k=null,A=null;function j(){return k?Promise.resolve(k):(A||=C().then(e=>(k=e,k)).catch(e=>(n(`[@webority/ui-elements] <wui-phone> could not load its phone number metadata.`,e),null)),A)}function M(t,n){let r=`+${e(t)}`;return n?.startsWith(r)?n.slice(r.length).trimStart():null}function N(t,n){if(!k||!n||!t||!E(k,t))return n;try{return M(t,new k.AsYouType(t).input(`+${e(t)}${n}`))||n}catch{return n}}function P(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 F(e){if(!k||!e||!E(k,e))return null;try{return M(e,k.getExampleNumber(e,k.examples)?.formatInternational())||null}catch{return null}}function I(e){let t=F(e);return t?h(T().examplePlaceholder,{example:t}):null}function L(e){if(!k||!e)return null;try{if(!k.isValidPhoneNumber(e))return!1;let t=k.parsePhoneNumber(e)?.getType?.();return t===void 0||t===`MOBILE`||t===`FIXED_LINE_OR_MOBILE`}catch{return null}}function R(e){if(!k||!e||!E(k,e))return null;try{let t=k.getExampleNumber(e,k.examples);return t?.nationalNumber?t.nationalNumber.length:null}catch{return null}}function z(e,t,n){if(!k||!E(k,e))return null;try{let r=k.parsePhoneNumber(t,e),i=r?.nationalNumber;return!i||r.country!==e||i.length>n||!t.endsWith(i)?null:i}catch{return null}}function B(e){if(!k||!e?.trim().startsWith(`+`))return null;try{let t=new k.AsYouType;t.input(e.trim());let n=t.getCountry();return!n||!J(t)?null:{country:n,national:t.getNationalNumber()||``}}catch{return null}}function V(t,n){let r=String(n??``).trim();if(!r.startsWith(`+`))return null;let i=r.replace(/[^0-9]/g,``),a=String(e(t));return{country:t,national:i.startsWith(a)?i.slice(a.length):i}}var H=0;function U(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():(H+=1,String(H))}var W=class extends i{static formAssociated=!0;static whenFormatted(){return j().then(()=>void 0)}static get observedAttributes(){return[`value`,`country`,`locked-country`,`placeholder`,`disabled`,`readonly`,`loading`,`required`,`aria-label`,`aria-describedby`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._defaultCountry=S()||``,this._country=this._defaultCountry,this._national=``,this._active=-1,this._committedValue=``,this._validateOnInput=!1}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){let e=K(this.querySelector(`.country-dropdown-menu`),HTMLElement);e&&d(e)}attributeChangedCallback(e,t,n){if(e===`value`)this.value=n;else if(this._rendered){if(e===`aria-label`){let t=this.querySelector(`input[type=tel]`);t&&(n==null?t.removeAttribute(e):t.setAttribute(e,n))}else if(e===`aria-describedby`)this._syncDescribedBy();else if(e===`country`){if(this._locked)return;let e=this.value;if(this._country=n||this._defaultCountry,this._suppressCountryRender)return;this.render(),this.value!==e&&(this._emitInput(),this._emitChange())}else this.render()}}formResetCallback(){this._validateOnInput=!1,this.value=this._defaultValue||``}get _locked(){return(this.getAttribute(`locked-country`)||``).toUpperCase()||null}get value(){return this._national&&this._country?`+${e(this._country)}${this._national}`:``}set value(t){let n=String(t??``).trim();this._locked&&(this._country=this._locked);let r=this._locked?null:B(n);if(r)this._country=r.country,this._national=r.national.replace(/[^0-9]/g,``);else if(n.startsWith(`+`)){let t=n.replace(/[^0-9]/g,``),r=String(e(this._locked||this.getAttribute(`country`)||this._country));r&&t.startsWith(r)&&(t=t.slice(r.length)),this._national=t}else this._national=n.replace(/[^0-9]/g,``);r&&this.getAttribute(`country`)!==this._country?this.setAttribute(`country`,this._country):this._rendered&&this.render(),this._committedValue=this.value,this._syncMirror()}_syncMirror(){s(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._locked||this.getAttribute(`country`)||this._country;let e=this.getAttribute(`placeholder`)||I(this._country)||T().placeholder;this.id||=`wui-phone-${U()}`;let t=`${this.id}-listbox`;this._listboxId=t;let n=this._locked?r(`div`,{class:`phone-country-adornment`},r(`span`,{class:`wui-phone-prefix`},r(`span`,{class:D(this._country),"data-flag":!0,"aria-hidden":`true`}),r(`span`,{class:`phone-dial`,"data-dial":!0},O(this._country)))):r(`div`,{class:`phone-country-adornment`},r(`button`,{type:`button`,class:`country-toggle`,"aria-label":T().chooseCountryLabel,"aria-haspopup":`listbox`,"aria-expanded":`false`,"aria-controls":t,disabled:this.hasAttribute(`disabled`)||void 0},r(`span`,{class:D(this._country),"data-flag":!0,"aria-hidden":`true`}),c(`chevron-down`,{className:`phone-chevron`}),r(`span`,{class:`phone-dial`,"data-dial":!0},O(this._country))),r(`div`,{class:`country-dropdown-menu`,popover:`auto`},r(`div`,{class:`dropdown-search-wrapper`},r(`span`,{class:`dropdown-search-icon`},c(`search`)),r(`input`,{type:`text`,class:`dropdown-search-input`,placeholder:T().searchCountryPlaceholder,"aria-label":T().searchCountriesLabel,"aria-controls":t,"aria-autocomplete":`list`})),r(`div`,{class:`country-list-scroll`,role:`listbox`,id:t,tabindex:`-1`}),r(`div`,{class:`country-empty`,hidden:!0},T().noCountriesFoundLabel))),i=this.getAttribute(`aria-label`),l=this.getAttribute(`aria-describedby`),u=r(`input`,{type:`tel`,class:`form-control`,placeholder:e,value:N(this._country,this._national),"aria-label":i||void 0,"aria-describedby":l||void 0,required:this.hasAttribute(`required`)||void 0,"aria-required":this.hasAttribute(`required`)?`true`:void 0,disabled:this.hasAttribute(`disabled`)||void 0,readonly:o(this)||void 0}),d=this.classList.contains(`wui-input-underline`);this.replaceChildren(r(`div`,{class:d?`phone-input-wrap wui-input-underline`:`phone-input-wrap`},n,u)),this._rendered=!0,a(this,this.querySelector(`input.form-control`)),s(this,this.value),this._wire()}_ensureItems(){let e=K(this.querySelector(`.country-list-scroll`),HTMLElement);if(!e||e.querySelector(`.country-dropdown-item`))return;let n=this._listboxId,i=t.map(([e,t,i],a)=>r(`button`,{type:`button`,role:`option`,id:`${n}-opt-${a}`,class:`country-dropdown-item${e===this._country?` selected`:``}`,"data-iso":e,"aria-selected":String(e===this._country)},r(`span`,{class:D(e),"aria-hidden":`true`}),r(`span`,{class:`country-name-text`},t,r(`span`,{class:`country-code-text`},`+${i}`))));e.prepend(...i)}_itemEls(){return[...this.querySelectorAll(`.country-dropdown-item`)].filter(e=>e instanceof HTMLElement)}_visibleItems(){return this._itemEls().filter(e=>!e.hidden)}_wire(){let t=K(this.querySelector(`.country-toggle`),HTMLButtonElement),n=G(K(this.querySelector(`.phone-input-wrap`),HTMLElement),`phone input wrapper`),r=K(this.querySelector(`.country-dropdown-menu`),HTMLElement),i=K(this.querySelector(`.dropdown-search-input`),HTMLInputElement),a=K(this.querySelector(`.country-list-scroll`),HTMLElement),s=K(this.querySelector(`.country-empty`),HTMLElement),c=G(K(this.querySelector(`input[type=tel]`),HTMLInputElement),`phone input`),m=K(this.querySelector(`[data-flag]`),HTMLElement),g=K(this.querySelector(`[data-dial]`),HTMLElement),_=()=>r!==null&&p(r),v=(e,{reveal:t=!0}={})=>{let n=this._visibleItems();this._active=e,u(G(a,`country list`),e>=0&&n[e]||null);let r=e>=0?n[e]:void 0;r?(t&&r.scrollIntoView({block:`nearest`}),i?.setAttribute(`aria-activedescendant`,r.id)):i?.removeAttribute(`aria-activedescendant`)},y=()=>{_()||(G(t,`country toggle`).setAttribute(`aria-expanded`,`false`),v(-1))},b=()=>{if(o(this)||(this._ensureItems(),f(n,G(r,`country menu`),{mode:`auto`,onClosed:y}),!_()))return;G(t,`country toggle`).setAttribute(`aria-expanded`,`true`);let e=G(i,`country search`);e.value=``,S(``),e.focus(),v(this._visibleItems().findIndex(e=>e.classList.contains(`selected`)))},x=()=>{d(G(r,`country menu`))},S=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)}s&&(s.hidden=n>0)},C=t=>{this._country=t,this.getAttribute(`country`)!==t&&(this._suppressCountryRender=!0,this.setAttribute(`country`,t),this._suppressCountryRender=!1),m&&(m.className=D(t)),g&&(g.textContent=`+${e(t)}`);for(let e of this._itemEls()){let n=e.dataset.iso===t;e.classList.toggle(`selected`,n),e.setAttribute(`aria-selected`,String(n))}this.getAttribute(`placeholder`)||(c.placeholder=I(t)||T().placeholder),this._national&&(c.value=N(t,this._national)),x(),this._syncMirror(),this._emitChange(),this._validateOnInput&&E(O()),c.focus()},w=e=>{let n=this._visibleItems();if(e.key===`ArrowDown`){if(e.preventDefault(),!_()){b();return}v(Math.min(this._active+1,n.length-1))}else if(e.key===`ArrowUp`){if(e.preventDefault(),!_())return;v(Math.max(this._active-1,0))}else if(l(e)){e.preventDefault();let t=n[this._active];_()&&t?.dataset.iso&&C(t.dataset.iso)}else e.key===`Escape`&&_()&&(e.preventDefault(),e.stopPropagation(),x(),G(t,`country toggle`).focus())};t?.addEventListener(`click`,()=>_()?x():b()),t?.addEventListener(`keydown`,e=>{_()?w(e):(e.key===`ArrowDown`||l(e)||e.key===` `)&&(e.preventDefault(),b())}),i&&i.addEventListener(`input`,()=>{S(i.value);let e=this._visibleItems();v(e.length?0:-1)}),a?.addEventListener(`click`,e=>{let t=K(q(e).closest(`.country-dropdown-item`),HTMLElement);t?.dataset.iso&&C(t.dataset.iso)}),a?.addEventListener(`mousemove`,e=>{let t=K(q(e).closest(`.country-dropdown-item`),HTMLElement);t&&!t.classList.contains(`is-active`)&&v(this._visibleItems().indexOf(t),{reveal:!1})}),a?.addEventListener(`mouseleave`,()=>v(-1)),r?.addEventListener(`keydown`,w);let E=e=>{c.classList.toggle(`is-invalid`,e),e?c.setAttribute(`aria-invalid`,`true`):c.removeAttribute(`aria-invalid`);let t=K(this.querySelector(`[data-phone-error]`),HTMLElement);if(e&&!this.hasAttribute(`external-error`)){t||(t=document.createElement(`div`),t.className=`field-error`,t.id=`${this.id}-phone-error`,t.setAttribute(`data-phone-error`,``),n.after(t));let e=F(this._country);t.textContent=this._country?e?h(T().invalidNumberExampleMessage,{example:e}):T().invalidNumberMessage:T().chooseCountryMessage}else t?.remove();this._syncDescribedBy()},O=()=>this._national.length>0&&(!this._country||L(this.value)===!1);c.addEventListener(`input`,e=>{e.stopPropagation();let t=c.selectionStart??c.value.length,n=c.value.slice(0,t).replace(/[^0-9]/g,``).length,r=c.value.replace(/[^0-9]/g,``),i=R(this._country);if(i&&r.length>i){let e=z(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=N(this._country,this._national);if(c.value!==a){c.value=a;let e=P(a,Math.min(n,r.length));c.setSelectionRange(e,e)}this._syncMirror(),this._emitInput(),this._validateOnInput&&E(O())}),c.addEventListener(`change`,e=>e.stopPropagation()),c.addEventListener(`blur`,()=>{let e=O();E(e),e&&(this._validateOnInput=!0),this.value!==this._committedValue&&this._emitChange()}),c.addEventListener(`paste`,e=>{let t=e.clipboardData?.getData(`text`),n=this._locked?V(this._locked,t):B(t);n&&(e.preventDefault(),this._national=n.national.replace(/[^0-9]/g,``),n.country===this._country?c.value=N(this._country,this._national):(this._country=n.country,this.setAttribute(`country`,n.country)),this._syncMirror(),this._emitInput(),this._emitChange(),this._validateOnInput&&c.isConnected&&E(O()),K(this.querySelector(`input[type=tel]`),HTMLInputElement)?.focus())}),this._validateOnInput&&E(O()),j().then(e=>{if(e&&c.isConnected){if(this._national){let e=N(this._country,this._national);c.defaultValue=e,c.value=e}if(!this.getAttribute(`placeholder`)){let e=I(this._country);e&&(c.placeholder=e)}}}),this._syncMirror()}};function G(e,t){if(e==null)throw Error(`${t} missing`);return e}function K(e,t){return e instanceof t?e:null}function q(e){if(!(e.target instanceof Element))throw Error(`Event target is not an element`);return e.target}function J(e){return`getNationalNumber`in e&&typeof e.getNationalNumber==`function`}export{W as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-Cxeyx0tU.js";import{a as t,l as n,s as r}from"./nativeOverlay-
|
|
1
|
+
import{t as e}from"./elementBase-Cxeyx0tU.js";import{a as t,l as n,s as r}from"./nativeOverlay-MOABXAAh.js";var i=80,a=220,o=`:scope > [data-wui-popover-trigger]`,s=`:scope > [data-wui-popover-panel]`,c=`.popover-arrow`,l=`.popover-header`,u=`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,d=[`click`,`hover`,`focus`],f=[`top`,`bottom`,`start`,`end`,`auto`],p=0;function m(e,t){let n=e.querySelector(t);return n instanceof HTMLElement?n:null}function h(e){return e.pointerType===`touch`||e.pointerType===`pen`}var g=class extends e{_open;_timer;_pressOpen;_refocusing;_awaitChildren;_onPress;_onClick;_onOver;_onOut;_onFocusIn;_onFocusOut;_onKeyDown;static get observedAttributes(){return[`open`,`trigger`,`placement`,`open-delay`,`close-delay`,`role-dialog`,`auto-focus`,`labelled-by`]}constructor(){super(),this._open=!1,this._timer=null,this._pressOpen=null,this._refocusing=!1,this._awaitChildren=null,this._onPress=e=>{this._pressOpen=this._zone(e.target)===`trigger`?this._open:null},this._onClick=e=>{if(this._zone(e.target)!==`trigger`||!this._kinds().includes(`click`))return;let t=this._pressOpen??this._open;this._pressOpen=null,this._requestOpen(!t)},this._onOver=e=>{if(h(e))return;let t=this._zone(e.target);t===`panel`?this._clear():t===`trigger`&&this._kinds().includes(`hover`)&&this._schedule(!0)},this._onOut=e=>{!h(e)&&this._kinds().includes(`hover`)&&this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._schedule(!1)},this._onFocusIn=e=>{if(this._refocusing)return;let t=this._zone(e.target);t===`trigger`&&this._kinds().includes(`focus`)?this._requestOpen(!0):t===`panel`&&this._clear()},this._onFocusOut=e=>{this._kinds().includes(`focus`)&&this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._requestOpen(!1)},this._onKeyDown=e=>{if(e.key!==`Escape`||!this._open)return;e.preventDefault();let t=this._zone(this.ownerDocument.activeElement)===`panel`;this._clear(),this._requestOpen(!1),t&&!this._open&&this._trigger?.focus()}}get isOpen(){return this._open}show(){this._open||(this._applyOpen(!0),this._notify(!0,!1))}hide(){this._open&&(this._applyOpen(!1),this._notify(!1,!1))}connectedCallback(){this.addEventListener(`pointerdown`,this._onPress),this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerover`,this._onOver),this.addEventListener(`pointerout`,this._onOut),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut),this._stampTrigger(),this._openOrAwaitChildren()}attributeChangedCallback(e){e===`open`&&this._awaitChildren?this.hasAttribute(`open`)||this._disarmAwait():e===`open`&&this.isConnected&&this._openOrAwaitChildren()}disconnectedCallback(){this._disarmAwait(),this._clear(),this.removeEventListener(`pointerdown`,this._onPress),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerover`,this._onOver),this.removeEventListener(`pointerout`,this._onOut),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),this.ownerDocument.removeEventListener(`keydown`,this._onKeyDown),this._open=!1;let e=this._panel;e&&t(e)}get _panel(){return m(this,s)}get _trigger(){let e=m(this,o);if(e)return e;for(let e of this.children)if(e instanceof HTMLElement&&!e.hasAttribute(`data-wui-popover-panel`))return e;return null}_stampTrigger(){let e=this._trigger;e&&(e.setAttribute(`data-wui-popover-trigger`,``),(this.getAttribute(`trigger`)??`click`).split(/\s+/).includes(`click`)&&!e.hasAttribute(`aria-expanded`)&&e.setAttribute(`aria-expanded`,`false`))}_zone(e){if(!(e instanceof Node)||!this.contains(e))return null;let t=e instanceof Element?e:e.parentElement;return this._panel?.contains(t)?`panel`:this._trigger?.contains(t)?`trigger`:null}_kinds(){let e=(this.getAttribute(`trigger`)??`click`).split(/\s+/).filter(Boolean),t=[];for(let n of e){let e=d.find(e=>e===n);if(!e)throw RangeError(`<wui-popover>: trigger="${n}" is not click, hover or focus.`);t.push(e)}if(t.length===0)throw RangeError(`<wui-popover>: trigger is empty; name click, hover or focus.`);return t}_side(){let e=this.getAttribute(`placement`)??`bottom`,t=f.find(t=>t===e);if(!t)throw RangeError(`<wui-popover>: placement="${e}" is not top, bottom, start, end or auto.`);return t}_delay(e,t){if(!this.hasAttribute(e))return t;let n=this.getAttribute(e)??``,r=Number(n);if(n.trim()===``||!Number.isFinite(r)||r<0)throw RangeError(`<wui-popover>: ${e}="${n}" is not zero or more milliseconds.`);return r}_clear(){this._timer!==null&&clearTimeout(this._timer),this._timer=null}_schedule(e){if(this._clear(),this._open===e)return;let t=e?this._delay(`open-delay`,i):this._delay(`close-delay`,a);this._timer=setTimeout(()=>{this._timer=null,this._requestOpen(e)},t)}_requestOpen(e){e!==this._open&&(e&&this._ready(),this._notify(e,!0)&&this._applyOpen(e))}_notify(e,t){return this.dispatchEvent(new CustomEvent(`wui-popover-toggle`,{bubbles:!0,cancelable:t,detail:{open:e}}))}_mode(){return this._kinds().includes(`click`)?`auto`:`manual`}_ready(){let e=this._panel;if(!e)throw Error(`<wui-popover> has no panel: a child with data-wui-popover-panel is required to open.`);let t=this._trigger;if(!t)throw Error(`<wui-popover> has no trigger: a child element is required to open.`);return{panel:e,trigger:t,side:this._side(),mode:this._mode()}}_applyOpen(e){if(this._stampTrigger(),e===this._open)return;if(e){let{panel:e,trigger:i,side:a,mode:o}=this._ready();this._open=!0,this._name(e);try{n(i,e,{mode:o,side:a,align:`center`,clampHeight:!0,arrow:m(e,c),onClosed:()=>this._onNativeClose()})}catch(n){throw this._open=!1,t(e),n}this.setAttribute(`open`,``),o===`manual`&&this.ownerDocument.addEventListener(`keydown`,this._onKeyDown),this.hasAttribute(`auto-focus`)&&queueMicrotask(()=>{this._open&&r(e)&&m(e,u)?.focus()}),i.hasAttribute(`aria-expanded`)&&i.setAttribute(`aria-expanded`,`true`);return}let i=this._panel;if(!i)throw Error(`<wui-popover> has no panel: a child with data-wui-popover-panel is required to close.`);let a=this._trigger;if(!a)throw Error(`<wui-popover> has no trigger: a child element is required to close.`);this._open=!1,this.ownerDocument.removeEventListener(`keydown`,this._onKeyDown),this.hasAttribute(`auto-focus`)&&this._mode()===`manual`&&i.contains(this.ownerDocument.activeElement)&&this._refocus(),t(i),this.removeAttribute(`open`),a.hasAttribute(`aria-expanded`)&&a.setAttribute(`aria-expanded`,`false`)}_openOrAwaitChildren(){if(this.hasAttribute(`open`)&&(this._panel===null||this._trigger===null)){if(this._awaitChildren)return;this._awaitChildren=new MutationObserver(()=>this._finishAwaitedOpen()),this._awaitChildren.observe(this,{childList:!0})}else this._applyOpen(this.hasAttribute(`open`))}_finishAwaitedOpen(){this._panel!==null&&this._trigger!==null&&(this._disarmAwait(),this._applyOpen(this.hasAttribute(`open`)))}_disarmAwait(){this._awaitChildren?.disconnect(),this._awaitChildren=null}_onNativeClose(){let e=this._panel;if(!this._open||!e||r(e))return;let t=e.contains(this.ownerDocument.activeElement);this._applyOpen(!1),t&&this._refocus(),this._notify(!1,!1)}_refocus(){let e=this._trigger;e&&(this._refocusing=!0,e.focus(),this._refocusing=!1)}_name(e){if(!this.hasAttribute(`role-dialog`))return;e.setAttribute(`role`,`dialog`);let t=this.getAttribute(`labelled-by`);if(t){e.setAttribute(`aria-labelledby`,t);return}let n=m(e,l);n&&(n.id||=`wui-popover-title-${++p}`,e.setAttribute(`aria-labelledby`,n.id))}};export{g as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./anchorOverlay-daGdh_91.js";import{t}from"./avatarNode-BaEvz5Xr.js";import{n}from"./devWarn-DXdRWZs3.js";import{i as r,r as i}from"./dom-DMQu--xV.js";import{t as a}from"./elementBase-Cxeyx0tU.js";import{r as o,t as s}from"./fieldState-D-zQcXUS.js";import{n as c,t as l}from"./formMirror-9IpSgeZb.js";import{n as u}from"./loader-sSdQNOg6.js";import{t as d}from"./iconGlyphs.g-DRNDTVOs.js";import{n as f}from"./imeSafeEnter-DeO_3lXy.js";import{n as p,t as m}from"./listboxKeyNav-CNso9shL.js";import{a as h,l as g,s as _}from"./nativeOverlay-BHD2QV02.js";import{i as v,n as y,t as b}from"./optionLabel-CuShfg_A.js";import{r as x}from"./textStore-Dh5iyZSR.js";import{n as S,r as C,t as w}from"./search.g-chn0itlW.js";import{t as T}from"./hasOwn-CJsplJ62.js";import{n as E,r as D,t as O}from"./window-BZWK3rQk.js";var k=()=>x(`select`,C);function A(e,t){let n=String(t??``).trim().toLowerCase();return n?e.filter(e=>[y(e),e.description,e.meta].some(e=>String(e??``).toLowerCase().includes(n))):e}var j=/* @__PURE__ */ new WeakMap,M=e=>e?{"data-index":String(e.index),"aria-setsize":String(e.size),"aria-posinset":String(e.index+1)}:{},N=e=>e.map(e=>e instanceof Element?e.outerHTML:e.textContent??``).join(``),P;function F(e){P=e}function I(e){P?.clear(e),j.delete(e),e.replaceChildren()}function L(e,t,n={}){let{selected:r=[],query:a=``,status:o=`idle`,emptyText:s=k().emptyText,searchingText:c=k().searchingText,loadingMoreText:l=k().loadingMoreText,hintText:u=k().hintText,actionRow:d=[],recents:f=null}=n,p=new Set(r.map(String)),m=A(t,a),h=e.id,g=d.filter(e=>e.position===`top`),_=d.filter(e=>e.position===`bottom`),v=f?.options.length?f.options:[],y=g.length+v.length+m.length+_.length,b=m.length>300,x=P,S=b&&x!==void 0,C=e=>S?{index:e,size:y}:void 0,w=0,T=e=>{let t=w++;return i(`button`,{type:`button`,role:`option`,id:R(h,t),class:`wui-select-option wui-select-add`,"data-value":String(e.value??``),"data-custom":`true`,"aria-selected":`false`,...M(C(t))},e.label)},E=e=>{let t=w++;return ne(e,R(h,t),p.has(String(e.value)),C(t))},D=g.map(T),O=v.length&&f?[i(`div`,{class:`wui-select-group`},f.label),...v.map(E),i(`div`,{class:`wui-select-sep`,"aria-hidden":`true`})]:[],F=w,I=[];if(S)w+=m.length;else{let e=``;for(let t of m)t.group&&t.group!==e&&I.push(i(`div`,{class:`wui-select-group`},t.group)),e=t.group??``,I.push(E(t))}let L=_.map(T),z=[];if(o===`loading`||o===`more`?z=[i(`div`,{class:`wui-select-loading`},i(`span`,{class:`wui-select-spinner spinner-border spinner-border-sm`,role:`status`,"aria-hidden":`true`}),o===`more`?l:c)]:o===`hint`?z=[i(`div`,{class:`wui-select-hint`},u)]:(o===`empty`||m.length===0&&d.length===0)&&(z=[i(`div`,{class:`wui-select-empty`},s)]),S&&x){let n=[...D,...O],r=[...L,...z];return x.render(e,{options:t,query:a,rows:m,pre:n,post:r,preSig:N(n),postSig:N(r),picked:p,top:g,recent:v,bottom:_,bodyBase:F,total:y}),{rows:y,windowed:!0,long:b}}x?.clear(e);let B=[...D,...O,...I,...L,...z],V=N(B);return j.get(e)===V||(j.set(e,V),e.replaceChildren(...B)),{rows:w,windowed:!1,long:b}}var R=(e,t)=>`${e}-opt-${t}`,z=e=>[...e.querySelectorAll(`.wui-select-option`)];function B(e){return P?P.refresh(e):!1}function V(e,t){return P?P.reveal(e,t):z(e)[t]??null}function ee(e,t){if(P)return P.indexOfValue(e,t);let n=new Set(t.map(String));return z(e).findIndex(e=>n.has(e.dataset.value??``))}function te(e,t){return P?P.indexByPrefix(e,t):z(e).findIndex(e=>(e.textContent??``).trim().toLowerCase().startsWith(t))}function ne(e,n,r,a){let o=!!e.disabled,s={id:n,role:`option`,"data-value":String(e.value??``),"aria-selected":String(r),"aria-disabled":o?`true`:void 0,title:o&&e.disabledHint?e.disabledHint:void 0,...M(a)},c=i(`span`,{class:`wui-select-check`,"aria-hidden":`true`},d(`check`));if(!e.description&&!e.meta)return i(`button`,{type:`button`,class:`wui-select-option${r?` selected`:``}`,...s},t(e),i(`span`,{class:`wui-select-opt-name`},...b(e)),c);let l=e.description?i(`span`,{class:`wui-select-opt-desc`},e.description):null,u=e.meta?i(`span`,{class:`wui-select-opt-meta`},e.meta):null;return i(`div`,{class:`wui-select-option wui-select-option-rich${r?` selected`:``}`,...s},t(e),i(`span`,{class:`wui-select-option-text`},i(`span`,{class:`wui-opt-label`},...b(e)),l),u,c)}var re=Object.freeze([`single`,`multiple`,`search`,`tag`,`country`]),H=e=>e===`multiple`||e===`tag`,U={recents:()=>import(`./recents-DTddcnaM.js`),chips:()=>import(`./chips-DCkeuEvb.js`),search:()=>import(`./search-OPWGeniZ.js`),country:()=>import(`./country-CX7Ok3Md.js`)};function ie(e){let t=T(U,e)?U[e]:void 0;return t?t():Promise.reject(/* @__PURE__ */ Error(`Unknown <wui-select> part: ${e}.`))}var W=e=>typeof e.loadOptions==`function`||!!e.getAttribute(`source`)||e.hasAttribute(`remote`),ae=300,G=`<div class="wui-select-spacer" aria-hidden="true"></div>`,K=()=>i(`div`,{class:`wui-select-spacer`,"aria-hidden":`true`}),q=/* @__PURE__ */ new WeakMap,J=(e,t)=>{let n=e.entries[e.optionEntry[t]??-1];return n?.kind===`option`?n.option:void 0},oe=(e,t,n)=>e.query===t&&e.count>0&&n.length>e.count&&n[0]===J(e,0)&&n[e.count-1]===J(e,e.count-1);function se(e,t,n,r){let i=q.get(e);if(i&&i.options===t&&i.query===n&&i.count===r.length)return i;let a=i!==void 0&&oe(i,n,r),o=[],s=new Int32Array(r.length),c=``;r.forEach((e,t)=>{e.group&&e.group!==c&&o.push({kind:`group`,label:e.group}),c=e.group??``,s[t]=o.length,o.push({kind:`option`,option:e,ord:t})});let l={options:t,query:n,count:r.length,entries:o,optionEntry:s,heights:O(o.length),estimated:!1,bodyTop:0,start:0,end:0,pre:[],post:[],preSig:``,postSig:``,picked:/* @__PURE__ */ new Set,top:[],recent:[],bottom:[],bodyBase:0,total:0};if(q.set(e,l),i&&a){l.heights.setEstimate(i.heights.estimate),l.estimated=i.estimated,l.bodyTop=i.bodyTop;for(let e=0;e<i.entries.length;e++)l.heights.set(e,i.heights.heightOf(e))}else i&&(e.scrollTop=0);return l}var Y=e=>e.clientHeight||ae,ce=(e,t)=>D(t.heights,{scrollTop:Math.max(0,e.scrollTop-t.bodyTop),viewport:Y(e)});function le(e,t,n,r){let a=[];for(let o=n;o<r;o++){let n=e.entries[o];if(n){if(n.kind===`group`)a.push(i(`div`,{class:`wui-select-group`,"data-entry":o},n.label));else{let r=e.bodyBase+n.ord;a.push(ne(n.option,R(t,r),e.picked.has(String(n.option.value)),{index:r,size:e.total}))}}}return a}function ue(e,t){let[n,r]=e.querySelectorAll(`.wui-select-spacer`);n&&r&&(n.style.flex=r.style.flex=`none`,n.style.height=`${t.heights.offsetOf(t.start)}px`,r.style.height=`${t.heights.total()-t.heights.offsetOf(t.end)}px`)}function de(e,t){let{start:n,end:r}=ce(e,t);t.start=n,t.end=r;let i=le(t,e.id,n,r),a=t.preSig+G+N(i)+G+t.postSig,o=e.scrollTop;j.get(e)!==a&&(j.set(e,a),e.replaceChildren(...t.pre,K(),...i,K(),...t.post)),ue(e,t),e.scrollTop!==o&&(e.scrollTop=o)}function fe(e,t){let n={changed:!1,delta:0};if(!e.clientHeight)return n;let{heights:r}=t,i=e.querySelector(`.wui-select-spacer`),a=[],o=!0,s=!1;if(i){let n=i.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;Math.abs(n-t.bodyTop)>.5&&(t.bodyTop=n,s=!0)}let c=r.indexAt(Math.max(0,e.scrollTop-t.bodyTop)),l=r.offsetOf(c),u=0;for(let n of e.querySelectorAll(`.wui-select-option[data-index], .wui-select-group[data-entry]`)){let e=n.getBoundingClientRect().height;if(n.dataset.entry!==void 0)a.push([Number(n.dataset.entry),e]);else{let r=Number(n.dataset.index)-t.bodyBase,i=r>=0?t.optionEntry[r]:void 0;if(i===void 0)continue;o&&(u=e),o=!1,a.push([i,e])}}if(!t.estimated&&u>0){let e=r.estimate;r.setEstimate(u),t.estimated=!0,r.estimate!==e&&(s=!0)}for(let[e,t]of a)r.set(e,t)&&(s=!0);return s?{changed:s,delta:r.offsetOf(c)-l}:n}function X(e,t){de(e,t);for(let n=0;n<2;n++){let{changed:n,delta:r}=fe(e,t);if(!n)return;ue(e,t),r&&(e.scrollTop+=r),de(e,t)}}function pe(e,t){let n=se(e,t.options,t.query,t.rows);Object.assign(n,{pre:t.pre,post:t.post,preSig:t.preSig,postSig:t.postSig,picked:t.picked,top:t.top,recent:t.recent,bottom:t.bottom,bodyBase:t.bodyBase,total:t.total}),X(e,n)}function me(e){let t=q.get(e);if(!t)return!1;let{start:n,end:r}=ce(e,t);return n===t.start&&r===t.end?!1:(X(e,t),!0)}function he(e,t){let n=q.get(e);if(!n||t<0||t>=n.total)return null;let r=t-n.bodyBase,i=r>=0?n.optionEntry[r]:void 0,a=()=>e.querySelector(`[data-index="${t}"]`);if(i===void 0)return a();for(let t=0;t<2;t++){let t={scrollTop:e.scrollTop-n.bodyTop,viewport:Y(e)},r=n.bodyTop+E(n.heights,i,t);if(Math.abs(r-e.scrollTop)>.5)e.scrollTop=r;else if(a())break;X(e,n)}return a()}function ge(e,t){if(t<0||t>=e.total)return;if(t<e.top.length)return e.top[t];let n=t-e.top.length;if(n<e.recent.length)return e.recent[n];let r=t-e.bodyBase;if(r<e.count){let t=e.entries[e.optionEntry[r]??-1];return t?.kind===`option`?t.option:void 0}return e.bottom[r-e.count]}var _e=e=>e&&!(`position`in e)?e:void 0;function ve(e,t){let n=q.get(e);if(!n||t.length===0)return-1;let r=new Set(t.map(String));for(let e=0;e<n.total;e++){let t=_e(ge(n,e));if(t&&r.has(String(t.value)))return e}return-1}var ye=e=>`position`in e?e.label:`${e.initials??``}${y(e)}${e.description??``}${e.meta??``}`;function be(e,t){let n=q.get(e);if(!n)return-1;for(let e=0;e<n.total;e++){let r=ge(n,e);if(r&&ye(r).trim().toLowerCase().startsWith(t))return e}return-1}F({render:pe,refresh:me,reveal:he,indexOfValue:ve,indexByPrefix:be,clear(e){q.delete(e)}});function xe(){return Promise.resolve()}var Z=()=>x(`select`,C),Se=()=>x(`search`,w),Ce=()=>x(`field`,S),we=160,Te=class extends a{static formAssociated=!0;_internals;_value;_optionsProp;_partOptions;_known;_loadOptionsFn;_validateFn;_declared;_query;_ownsFilter;_active;_rows;_windowed;_windowLoad;_windowFailed;_scrollFrame;_endFrame;_status;_error;_nav;_parts;_partSig;_partsMounted;_partToken;_rendered;_searchShown;_defaultValue;_warnedMode;_warnedDensity;_hoverTimer;_hoverOpened;_onHoverOver;_onHoverOut;_panelShown;_pressOpen;static get observedAttributes(){return/* @__PURE__ */ `class.mode.value.placeholder.search-placeholder.empty-text.searchable.clearable.disabled.readonly.loading.required.size.density.icon.prefix.open.open-on-hover.lazy-options.aria-label.aria-describedby.aria-invalid.min-chars.debounce.source.remote.allow-custom.add-label.searching-text.hint-text.value-label.value-avatar.value-initials.max-tags.allow-duplicates.separators.pattern.invalid-message.create-label.collapse-chips.selected-text.clear-all-label.countries.suggested.suggested-label.all-countries-label.recents-key.recents-limit.recents-label`.split(`.`)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``,this._optionsProp=null,this._partOptions=null,this._known=/* @__PURE__ */ new Map,this._loadOptionsFn=null,this._validateFn=null,this._declared=void 0,this._query=``,this._ownsFilter=!1,this._active=-1,this._rows=0,this._windowed=!1,this._windowLoad=null,this._windowFailed=!1,this._scrollFrame=null,this._endFrame=null,this._status=`idle`,this._error=``,this._nav=null,this._parts=null,this._partSig=``,this._partsMounted=!1,this._partToken=0,this._rendered=!1,this._searchShown=!1,this._defaultValue=void 0,this._warnedMode=null,this._hoverTimer=null,this._hoverOpened=!1,this._panelShown=!1,this._pressOpen=null,this._onHoverOver=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&(this._clearHover(),!this._menuOpen()&&this._hoverEligible()&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,!this._menuOpen()&&this._hoverEligible()&&(this._open({focus:!1}),this._hoverOpened=!0)},ke)))},this._onHoverOut=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&!this._hoverZone(e.relatedTarget)&&(this._clearHover(),this._menuOpen()&&this.hasAttribute(`open-on-hover`)&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,this._close()},Ae)))}}connectedCallback(){this.addEventListener(`pointerover`,this._onHoverOver),this.addEventListener(`pointerout`,this._onHoverOut),this._rendered||this.render(),this._ensureParts(),this._mountParts()}disconnectedCallback(){this.removeEventListener(`pointerover`,this._onHoverOver),this.removeEventListener(`pointerout`,this._onHoverOut),this._clearHover(),this._dropMenu(),this._teardown(),this._teardownParts()}attributeChangedCallback(e,t,n){e===`class`?this._syncUnderline():e===`value`?(this._value=Q(n,H(this.mode)),this._applyValue()):e===`aria-invalid`?this._syncInvalid():e===`open`?this._rendered&&(this.hasAttribute(`open`)?this._open({focus:!1}):this._close({force:!0})):e===`open-on-hover`?this.hasAttribute(`open-on-hover`)||this._clearHover():e!==`lazy-options`&&(e===`mode`&&(this._value=Q(this._value,H(this.mode)),this._partOptions=null,this._known.clear(),this._ensureParts()),(e===`source`||e===`remote`||e===`recents-key`)&&this._ensureParts(),Pe.has(e)?this._rendered&&(this._drawValue(),this.renderList()):Ne.has(e)?this._remountParts():this._rendered&&this.render())}formResetCallback(){if(this.value=this._defaultValue??``,!this._rendered)return;let e=this._refs();e.input&&(e.input.value=``,e.input.removeAttribute(`aria-invalid`)),e.search&&(e.search.value=``),this.setError(``),this._query!==``&&this._onQueryChange(``)}get mode(){let e=this.getAttribute(`mode`);return e===null?`single`:De(e)?e:(e!==this._warnedMode&&(this._warnedMode=e,n(`<wui-select> mode "${e}" is not one of ${re.join(`, `)}; it is treated as "single".`)),`single`)}_checkDensity(){let e=this.getAttribute(`density`);e===null||Oe.includes(e)||e===this._warnedDensity||(this._warnedDensity=e,n(`<wui-select> density "${e}" is not one of ${Oe.join(`, `)}; it is treated as "comfortable".`))}set mode(e){this.setAttribute(`mode`,String(e))}get value(){return Array.isArray(this._value)?this._value.slice():this._value}set value(e){this._value=Q(e,H(this.mode)),this._applyValue()}get options(){return this._readOptions()}set options(e){this._optionsProp=Array.isArray(e)?e:null,this.mode!==`country`&&(this._partOptions=null);for(let e of this._activePartsList())e.onOptions?.();if(this._rendered){if(this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._autoSearch()!==this._searchShown){this.render();return}this._drawValue(),this.renderList()}}get loadOptions(){return this._loadOptionsFn}set loadOptions(e){this._loadOptionsFn=typeof e==`function`?e:null,this._ensureParts()}get validate(){return this._validateFn}set validate(e){this._validateFn=typeof e==`function`?e:null}commit(e,t={}){this.value=e,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:!!t.isCustom}}))}setPartOptions(e){this._partOptions=Array.isArray(e)?e:null,this._drawValue(),this.renderList()}setStatus(e){this._status=e,this.renderList()}setError(e){this._error=e?String(e):``,this._syncError()}openMenu(){s(this)||this._open({focus:!1})}closeMenu({focusControl:e=!1}={}){this._close(),e&&this._refs().control?.focus()}renderList(){let e=this._refs();if(!e.list)return;let t=this._ownsFilter?``:this._query,n=this._actionRows(),r=this._recents();if(this.hasAttribute(`lazy-options`)&&!this._menuOpen()){this._rows=A(this._listOptions(),t).length+n.length+(r?.options.length??0),this._windowed=!1,I(e.list),this._anchorMenu();return}let i=L(e.list,this._listOptions(),{selected:this._selectedValues(),query:t,status:this._status,emptyText:this.getAttribute(`empty-text`)||Z().emptyText,searchingText:this.getAttribute(`searching-text`)||Z().searchingText,loadingMoreText:Z().loadingMoreText,hintText:this.getAttribute(`hint-text`)||void 0,actionRow:n,recents:r});this._rows=i.rows,this._windowed=i.windowed,i.long&&!i.windowed&&!this._windowFailed&&this._loadWindow(),this._active>=this._rowCount()&&(this._active=-1),this._active>=0&&this._setActive(this._active,{reveal:!1}),this._anchorMenu(),this._watchListEnd()}_watchListEnd(){this._endFrame===null&&this._activePartsList().some(e=>e.onListEnd)&&(this._endFrame=requestAnimationFrame(()=>{this._endFrame=null,this._checkListEnd()}))}_checkListEnd(){let e=this._refs().list;if(e?.clientHeight&&this._menuOpen()&&!(e.scrollTop+e.clientHeight<e.scrollHeight-we))for(let e of this._activePartsList())e.onListEnd?.()}render(){this._dropMenu();let e=this._carry();this._teardownParts(),this._snapshotDeclared();let t=this.mode;this._checkDensity();let n=H(t),r=t===`tag`,a=n&&(r||this.hasAttribute(`allow-custom`));this._value=Q(this._value,n),this._defaultValue===void 0&&n&&this._value.length===0&&(this._value=this._declaredSelected()),n||this._preselect(),this._defaultValue===void 0&&(this._defaultValue=Q(this._value,n));let s=this.getAttribute(`size`),c=s===`sm`?` wui-select-sm`:s===`lg`?` wui-select-lg`:s===`xl`?` wui-select-xl`:``,l=this.getAttribute(`icon`),u=this.getAttribute(`prefix`),f=this.hasAttribute(`clearable`),p=this.hasAttribute(`disabled`);if(!this.id){let e=crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(8));this.id=`wui-select-${Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}`}let m=`${this.id}-listbox`,h=`${this.id}-entry-error`,g=this.getAttribute(`aria-describedby`)?.trim(),_=g?`${g} ${h}`:h,v=this.hasAttribute(`aria-invalid`)||!!this._error,y=this.hasAttribute(`required`)&&!a,b=this._accessibleName(),x=a?{}:{role:`combobox`,"aria-haspopup":`listbox`,"aria-expanded":`false`,"aria-controls":m},S={"aria-label":b,"aria-describedby":_,"aria-invalid":v?`true`:void 0,"aria-required":y?`true`:void 0},C=n?i(`div`,{class:`form-control wui-select-control wui-select-multi`,...x,...S,"aria-disabled":p?`true`:void 0,tabindex:!p&&!r?`0`:void 0}):i(`button`,{type:`button`,class:`form-control wui-select-control`,...x,...S,disabled:p||void 0}),w=[l?d(l,{className:`wui-select-icon`}):null,u?i(`span`,{class:`wui-select-prefix`},u):null,i(`span`,{class:`wui-select-value`,"data-label":!0}),f?i(`span`,{class:`wui-select-reset`,role:`button`,"aria-label":Z().clearSelectionLabel,hidden:!0},d(`x`)):null,d(`chevron-down`,{className:`wui-select-caret`})];C.append(...w.filter(e=>e!==null));let T=this.getAttribute(`searchable`),E=T===null?t===`multiple`||t===`country`||this._autoSearch():T!==`false`,D=t===`search`||E&&!a;this._searchShown=D;let O=this.getAttribute(`search-placeholder`)||(t===`country`?Z().countrySearchPlaceholder:Se().placeholder),k=D?i(`div`,{class:`wui-select-search`},d(`search`),i(`input`,{class:`wui-select-input`,placeholder:O,"aria-label":O,"aria-autocomplete":`list`}),i(`button`,{type:`button`,class:`wui-select-clear`,"aria-label":Se().clearLabel,hidden:!0},d(`x`))):null,A=i(`div`,{class:`wui-select-options`,role:`listbox`,id:m,tabindex:`-1`,"aria-multiselectable":n?`true`:void 0}),j=i(`div`,{class:`wui-select-menu wui-select-menu-fixed`,popover:`auto`},k,A),M=i(`div`,{class:`field-error wui-select-error`,id:h,"aria-live":`polite`,hidden:!this._error||void 0},this._error||null);this.replaceChildren(i(`div`,{class:`wui-select${c}`},C,j),M),this._rendered=!0,this._syncMirror(),this._syncValidity(),this._drawValue(),this._syncReset(),this.renderList(),this._wire(),o(this,this.querySelector(`.wui-select-control`)),this._syncUnderline(),this._mountParts(e)}_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||Z().fallbackName}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>{let t=document.createDocumentFragment();for(let n of e.childNodes)t.append(n.cloneNode(!0));let n={value:e.getAttribute(`value`)??Ve(e).trim(),label:t.textContent??``,selected:e.hasAttribute(`selected`)};for(let[t,r]of Fe){let i=e.getAttribute(t);i&&(n[r]=i)}return e.hasAttribute(`disabled`)&&(n.disabled=!0),v(n,t)}))}_readOptions(){return this.mode===`country`?this._partOptions||[]:this._partOptions?this._partOptions:this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}_listOptions(){let e=this._readOptions(),t=this.getAttribute(`value-label`);if(this.mode!==`search`||!t||this._value===``)return e;let n=String(this._value);return e.some(e=>String(e.value)===n)?e:[...e,{value:n,label:t}]}_declaredSelected(){return this._optionsProp?[]:(this._declared??[]).filter(e=>e.selected).map(e=>String(e.value))}_preselect(){let e=this._readOptions(),t=this._value!==``&&e.find(e=>String(e.value)===this._value)||e.find(e=>`selected`in e&&!!e.selected);t&&(this._value=String(t.value))}_optionFor(e){let t=String(e),n=this._readOptions().find(e=>String(e.value)===t);return n?(this._known.set(t,n),n):this._known.get(t)}_placeholder(){return this.getAttribute(`placeholder`)||Me()[this.mode]}_hasValue(){return Array.isArray(this._value)?this._value.length>0:this._value!==``}_selectedValues(){return Array.isArray(this._value)?this._value:this._value===``?this._listOptions().some(e=>String(e.value)===``)?[``]:[]:[this._value]}_applyValue(){this._syncMirror(),this._syncValidity(),this._rendered&&(this._drawValue(),this._syncReset(),this.renderList())}_syncMirror(){H(this.mode)?c(this,this._selectedValues()):l(this,this._value)}_drawValue(){let e=this._refs();if(!e.value)return;let t=H(this.mode),n=t?void 0:this._optionFor(this._value);if(this._syncTitle(n),this._syncValueAvatar(),this._activePartsList().some(e=>e.renderValue?.()===!0))return;if(t){e.value.classList.remove(`wui-select-placeholder`),e.value.textContent=``;return}e.value.classList.toggle(`wui-select-placeholder`,!n);let r=this._placeholder();e.value.replaceChildren(...n?b(n):r?[r]:[])}_syncTitle(e){let t=this.querySelector(`.wui-select-control`);if(!t)return;let n=e&&!this.hasAttribute(`title`)?y(e).trim():``;n?t.setAttribute(`title`,n):t.removeAttribute(`title`)}_syncValueAvatar(){let e=this.querySelector(`.wui-select-control`);if(!e)return;e.querySelector(`:scope > .wui-select-value-avatar`)?.remove();let n=!H(this.mode)&&this._hasValue()?t({avatar:this.getAttribute(`value-avatar`),initials:this.getAttribute(`value-initials`)},`avatar-xs`):null;e.classList.toggle(`wui-has-value-avatar`,!!n),n&&e.prepend(i(`span`,{class:`wui-select-value-avatar`,"aria-hidden":`true`},n))}_syncValidity(){let e=this._internals;if(typeof e?.setValidity==`function`){if(this.hasAttribute(`required`)&&!this._hasValue()){let t=this.querySelector(`.wui-select-control`);e.setValidity({valueMissing:!0},Ce().requiredFieldMessage,t instanceof HTMLElement?t:void 0)}else e.setValidity({})}}_syncReset(){let e=$(this,`.wui-select-reset`,HTMLElement);e&&(e.hidden=!(this.hasAttribute(`clearable`)&&this._hasValue()&&!s(this)))}_syncUnderline(){this.querySelector(`.wui-select-control`)?.classList.toggle(`wui-input-underline`,this.classList.contains(`wui-input-underline`))}_syncInvalid(){let e=this.querySelector(`.wui-select-control`);e&&(this.hasAttribute(`aria-invalid`)||this._error?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}_syncError(){let e=$(this,`.wui-select-error`,HTMLElement);e&&(e.textContent=this._error,e.hidden=!this._error),this._syncInvalid()}_refs(){return{control:$(this,`.wui-select-control`,HTMLElement),value:$(this,`.wui-select-value`,HTMLElement),menu:$(this,`.wui-select-menu`,HTMLElement),list:$(this,`.wui-select-options`,HTMLElement),search:$(this,`.wui-select-search input`,HTMLInputElement),input:$(this,`.wui-select-draft`,HTMLInputElement)}}_menuOpen(){let e=$(this,`.wui-select-menu`,HTMLElement);return e!==null&&_(e)}_hoverZone(e){if(!(e instanceof Element))return!1;let t=e.closest(`.wui-select-control, .wui-select-menu`);return t!==null&&this.contains(t)}_hoverEligible(){if(!this.hasAttribute(`open-on-hover`)||s(this)||this.mode===`tag`)return!1;let e=this._refs();return e.search===null&&e.input===null}_clearHover(){this._hoverTimer!==null&&clearTimeout(this._hoverTimer),this._hoverTimer=null}_autoSearch(){return this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._readOptions().length>je}_visible(){let e=this._refs();return e.list?Be(e.list,`.wui-select-option`):[]}_rowCount(){return this._windowed?this._rows:this._visible().length}_rowEl(e){if(!this._windowed)return this._visible()[e];let t=this._refs().list?.querySelector(`[data-index="${e}"]`);return t instanceof HTMLElement?t:void 0}_setActive(e,{reveal:t=!0}={}){let n=this._refs();if(!n.list||!n.control)return;this._active=e;let r=null;e>=0&&e<this._rowCount()&&(r=this._rowEl(e)??(this._windowed&&t?V(n.list,e):null)),p(n.list,r),r?(t&&r.scrollIntoView({block:`nearest`}),n.control.setAttribute(`aria-activedescendant`,r.id)):n.control.removeAttribute(`aria-activedescendant`)}_onListScroll(){this._scrollFrame=null;let e=this._refs().list;e&&(this._windowed&&B(e)&&this._active>=0&&this._setActive(this._active,{reveal:!1}),this._checkListEnd())}_actionRows(){let e=[];for(let t of this._activePartsList()){let n=t.actionRow?.(this._query);n&&e.push(n)}return e}_recents(){if(this._query.trim()!==``)return null;for(let e of this._activePartsList()){let t=e.recents?.(this._listOptions());if(t)return t}return null}_menuPlacement(e,t){let n=this.hasAttribute(`open`)?{below:!0}:{};if(this.getAttribute(`density`)!==`compact`)return{matchWidth:!0,...n};let r=e.getBoundingClientRect();return t.style.width=`max-content`,t.style.minWidth=`${r.width}px`,t.style.maxWidth=`280px`,n}_anchorMenu(){let t=this._refs();t.control&&t.menu&&this._menuOpen()&&e(t.control,t.menu,this._menuPlacement(t.control,t.menu))}_showMenu(e,t){g(e,t,{...this._menuPlacement(e,t),mode:`auto`,keepOffscreen:this.hasAttribute(`open`),onClosed:()=>this._onPanelClosed()}),this._panelShown=!0}_onPanelClosed(){if(!this._panelShown)return;this._panelShown=!1;let e=this._refs();e.control&&(e.control.setAttribute(`aria-expanded`,`false`),this._setActive(-1),this._nav?.clearTypeahead(),this.dispatchEvent(new CustomEvent(`wui-select:close`,{bubbles:!0})))}_open({focus:e=!0}={}){let t=this._refs();if(!t.menu||!t.control)return;let n=this._menuOpen();this._hoverOpened=!1,t.control.setAttribute(`aria-expanded`,`true`),this._query=t.input?t.input.value:``,this._ownsFilter=this._ownsFilter&&this._query!==``;let r=$(this,`.wui-select-search .wui-select-clear`,HTMLElement);if(r&&(r.hidden=!0),t.search&&(t.search.value=``),n||this._showMenu(t.control,t.menu),this.renderList(),e&&(t.search?.focus(),this._setActive(this._windowed&&t.list?ee(t.list,this._selectedValues()):this._visible().findIndex(e=>e.classList.contains(`selected`)))),!n){this.dispatchEvent(new CustomEvent(`wui-select:open`,{bubbles:!0}));for(let e of this._activePartsList())e.onOpen?.()}}_close({force:e=!1}={}){if(!e&&this.hasAttribute(`open`))return;let t=this._refs();if(!t.menu||!t.control)return;this._hoverOpened=!1;let n=t.menu.contains(document.activeElement);_(t.menu)&&h(t.menu),this._onPanelClosed(),n&&t.control.focus()}_onQueryChange(e){this._query=e,this._setActive(-1);let t=$(this,`.wui-select-search .wui-select-clear`,HTMLElement);t&&(t.hidden=!e);let n=!1;for(let t of this._activePartsList())t.onQuery?.(e)===!0&&(n=!0);this._ownsFilter=n,this.renderList()}_pick(e){if(e.getAttribute(`aria-disabled`)===`true`)return;let t=e.dataset.custom===`true`,n=e.dataset.value??``,r=t?{value:n,label:Ve(e).trim()}:this._listOptions().find(e=>String(e.value)===n)??{value:n,label:n},i=this._activePartsList().some(e=>e.onPick?.(r,{isCustom:t})===!0);H(this.mode)||(i||this.commit(n,{isCustom:t}),this._close(),this._refs().control?.focus())}_draftOpens(){return this.mode===`multiple`?this.hasAttribute(`allow-custom`):this.mode===`tag`&&W(this)}_onKeyDown(e){if(!s(this)){for(let t of this._activePartsList())if(t.onKey?.(e)===!0)return;if(!this._menuOpen()){if(e.target instanceof HTMLInputElement){if(e.key!==`ArrowDown`||!this._draftOpens())return;this._open({focus:!1})}else{(e.key===`ArrowDown`||f(e)||e.key===` `)&&(e.preventDefault(),this._open({focus:!0}));return}}r(this._nav,`Listbox keys are not wired.`).handler(e)}}_wire(){this._teardown();let e=this._refs(),t=e.control,n=e.list;if(!t||!e.menu||!n)return;let i=r($(this,`.wui-select`,HTMLElement),`The select wrapper is missing.`),a=$(this,`.wui-select-search .wui-select-clear`,HTMLElement),o=$(this,`.wui-select-reset`,HTMLElement);this._nav=m({getVisibleOptions:()=>this._visible(),getActive:()=>this._active,setActive:e=>this._setActive(e),getCount:()=>this._rowCount(),getOptionAt:e=>this._rowEl(e),findByPrefix:e=>this._windowed?te(n,e):this._visible().findIndex(t=>t.textContent.trim().toLowerCase().startsWith(e)),onEnter:(e,t)=>{if(e)this._pick(e);else if(this._query.trim()!==``){let e=t.find(e=>e.dataset.custom===`true`);if(e)this._pick(e);else if(t.length===1){let e=t[0];e&&this._pick(e)}}},onEscape:e=>{e.preventDefault(),this._nav?.clearTypeahead(),this._close(),t.focus()}}),i.addEventListener(`keydown`,e=>this._onKeyDown(e)),i.addEventListener(`input`,e=>{let t=e.target;if(!(t instanceof HTMLInputElement)||!t.matches(`.wui-select-input, .wui-select-draft`))return;this._onQueryChange(t.value);let n=t.matches(`.wui-select-draft`),r=this._rows>0||this._actionRows().length>0;n&&r&&!this._menuOpen()&&!s(this)&&this._draftOpens()&&this._open({focus:!1})}),i.addEventListener(`focusout`,e=>{let t=e.relatedTarget;t instanceof Node&&this.contains(t)||!this._activePartsList().some(e=>e.onBlur?.()===!0)&&t&&this._close()}),a?.addEventListener(`click`,()=>{let t=r(e.search,`The search input is missing.`);t.value=``,this._onQueryChange(``),t.focus()}),t.addEventListener(`pointerdown`,()=>{this._pressOpen=this._menuOpen()}),t.addEventListener(`click`,e=>{if(e.target instanceof Element&&e.target.closest(`[data-remove]`))return;if(this.mode===`tag`){if(s(this))return;this._refs().input?.focus(),!this._menuOpen()&&this._draftOpens()&&this._open({focus:!1});return}if(e.target instanceof HTMLInputElement){!this._menuOpen()&&!s(this)&&this._open({focus:!1});return}let t=e.detail>0&&this._pressOpen!==null?this._pressOpen:this._menuOpen();this._pressOpen=null,this._clearHover(),this._hoverOpened&&t?(this._hoverOpened=!1,this._open({focus:!0})):t?this._close():s(this)||this._open({focus:!0})}),o?.addEventListener(`click`,e=>{e.stopPropagation(),this.commit(H(this.mode)?[]:``),this._close(),t.focus()}),n.addEventListener(`click`,n=>{let r=ze(n).closest(`.wui-select-option`);if(r instanceof HTMLElement&&(this._pick(r),H(this.mode))){let n=this.querySelector(`.wui-select-draft`);(e.search??(n instanceof HTMLElement?n:t)).focus()}}),n.addEventListener(`mousedown`,e=>{H(this.mode)&&e.target instanceof Element&&e.target.closest(`.wui-select-option`)&&e.preventDefault()}),n.addEventListener(`mousemove`,e=>{let t=ze(e).closest(`.wui-select-option`);t instanceof HTMLElement&&!t.classList.contains(`is-active`)&&this._setActive(this._windowed?Number(t.dataset.index):this._visible().indexOf(t),{reveal:!1})}),n.addEventListener(`scroll`,()=>{this._scrollFrame===null&&(this._scrollFrame=requestAnimationFrame(()=>this._onListScroll()))},{passive:!0}),n.addEventListener(`mouseleave`,()=>this._setActive(-1)),n.addEventListener(`error`,e=>{let t=e.target;t instanceof Element&&t.classList.contains(`avatar-img`)&&t.remove()},!0),this.hasAttribute(`open`)&&this._open({focus:!1})}_teardown(){this._nav?.clearTypeahead(),this._scrollFrame!==null&&cancelAnimationFrame(this._scrollFrame),this._scrollFrame=null,this._endFrame!==null&&cancelAnimationFrame(this._endFrame),this._endFrame=null}_dropMenu(){let e=$(this,`.wui-select-menu`,HTMLElement);e&&h(e)}_activePartsList(){return this._partsMounted?r(this._parts,`The mounted parts are missing.`):[]}_ensureParts(){if(!this.isConnected)return;(this.hasAttribute(`source`)||this.hasAttribute(`remote`)||this.hasAttribute(`recents-key`)||this._loadOptionsFn!==null)&&this._loadWindow();let e=Le(this,this.mode),t=e.join(`,`);if(t===this._partSig)return;this._teardownParts(),this._parts=null,this._partSig=t;let n=++this._partToken;Promise.all(e.map(e=>He(this,e))).then(e=>{n===this._partToken&&(this._parts=e.filter(e=>e!==null),this._mountParts())})}_loadWindow(){this._windowLoad===null&&(this._windowLoad=xe().then(()=>this.renderList(),()=>{this._windowFailed=!0,document.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{chunk:`select-window`}})),this.setError(Z().partLoadMessage)}))}_mountParts(e={draft:``,query:``}){if(!this._parts||this._partsMounted||!this._rendered||!this.isConnected)return;this._partsMounted=!0;let t=Ee(this._refs());for(let n of this._parts)n.mount(this,t,{carry:e});this._drawValue(),this.renderList()}_teardownParts(){let e=this._activePartsList();this._partsMounted=!1;for(let t of e)t.teardown()}_remountParts(){if(!this._partsMounted)return;let e=this._carry();this._teardownParts(),this._mountParts(e)}_carry(){let e=this._refs();return{draft:e.input?.value??``,query:e.search?.value??``}}},Ee=e=>{let{control:t,value:n,menu:i,list:a}=e;return{control:r(t,`control missing`),value:r(n,`value missing`),menu:r(i,`menu missing`),list:r(a,`list missing`),search:e.search,input:e.input}},De=e=>re.includes(e),Oe=[`comfortable`,`compact`],ke=150,Ae=250,je=10,Me=()=>{let e=Z();return{single:e.placeholder,search:e.placeholder,multiple:e.placeholder,tag:e.tagPlaceholder,country:e.countryPlaceholder}},Ne=/* @__PURE__ */ new Set([`countries`,`suggested`,`suggested-label`,`all-countries-label`,`max-tags`,`pattern`,`collapse-chips`,`source`,`remote`,`min-chars`]),Pe=/* @__PURE__ */ new Set([`separators`,`allow-duplicates`,`invalid-message`,`create-label`,`add-label`,`selected-text`,`clear-all-label`,`value-label`,`value-avatar`,`value-initials`,`hint-text`,`recents-key`,`recents-limit`,`recents-label`]),Fe=[[`icon`,`icon`],[`description`,`description`],[`meta`,`meta`],[`group`,`group`],[`avatar`,`avatar`],[`initials`,`initials`],[`disabled-hint`,`disabledHint`]],Q=(e,t)=>t?Array.isArray(e)?e.map(String):e==null||e===``?[]:String(e).split(`,`).map(e=>e.trim()).filter(Boolean):Array.isArray(e)?e.length?String(e[0]):``:e==null?``:String(e),Ie=(e,t)=>t===`multiple`?W(e)?[`chips`,`search`]:[`chips`]:t===`search`?[`search`]:t===`country`?[`country`]:t===`tag`?W(e)?[`chips`,`search`]:[`chips`]:[],Le=(e,t)=>e.hasAttribute(`recents-key`)?[`recents`,...Ie(e,t)]:Ie(e,t),Re=e=>typeof e==`object`&&!!e&&`default`in e&&typeof e.default==`function`,ze=e=>{if(e.target instanceof Element)return e.target;throw Error(`The event target is not an element.`)},$=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},Be=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),Ve=e=>{let t=e.textContent;if(t===null)throw Error(`The element has no text.`);return t},He=(e,t)=>ie(t).then(e=>{if(!Re(e))throw Error(`The part ${t} has no default export.`);return e.default()}).catch(()=>(document.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{chunk:t}})),e.setError(Z().partLoadMessage),null));export{W as n,A as r,Te as t};
|
|
1
|
+
import{t as e}from"./anchorOverlay-daGdh_91.js";import{t}from"./avatarNode-BaEvz5Xr.js";import{n}from"./devWarn-DXdRWZs3.js";import{i as r,r as i}from"./dom-DMQu--xV.js";import{t as a}from"./elementBase-Cxeyx0tU.js";import{r as o,t as s}from"./fieldState-D-zQcXUS.js";import{n as c,t as l}from"./formMirror-9IpSgeZb.js";import{n as u}from"./loader-sSdQNOg6.js";import{t as d}from"./iconGlyphs.g-DRNDTVOs.js";import{n as f}from"./imeSafeEnter-DeO_3lXy.js";import{n as p,t as m}from"./listboxKeyNav-CNso9shL.js";import{a as h,l as g,s as _}from"./nativeOverlay-MOABXAAh.js";import{i as v,n as y,t as b}from"./optionLabel-CuShfg_A.js";import{r as x}from"./textStore-Dh5iyZSR.js";import{n as S,r as C,t as w}from"./search.g-chn0itlW.js";import{t as T}from"./hasOwn-CJsplJ62.js";import{n as E,r as D,t as O}from"./window-BZWK3rQk.js";var k=()=>x(`select`,C);function A(e,t){let n=String(t??``).trim().toLowerCase();return n?e.filter(e=>[y(e),e.description,e.meta].some(e=>String(e??``).toLowerCase().includes(n))):e}var j=/* @__PURE__ */ new WeakMap,M=e=>e?{"data-index":String(e.index),"aria-setsize":String(e.size),"aria-posinset":String(e.index+1)}:{},N=e=>e.map(e=>e instanceof Element?e.outerHTML:e.textContent??``).join(``),P;function F(e){P=e}function I(e){P?.clear(e),j.delete(e),e.replaceChildren()}function L(e,t,n={}){let{selected:r=[],query:a=``,status:o=`idle`,emptyText:s=k().emptyText,searchingText:c=k().searchingText,loadingMoreText:l=k().loadingMoreText,hintText:u=k().hintText,actionRow:d=[],recents:f=null}=n,p=new Set(r.map(String)),m=A(t,a),h=e.id,g=d.filter(e=>e.position===`top`),_=d.filter(e=>e.position===`bottom`),v=f?.options.length?f.options:[],y=g.length+v.length+m.length+_.length,b=m.length>300,x=P,S=b&&x!==void 0,C=e=>S?{index:e,size:y}:void 0,w=0,T=e=>{let t=w++;return i(`button`,{type:`button`,role:`option`,id:R(h,t),class:`wui-select-option wui-select-add`,"data-value":String(e.value??``),"data-custom":`true`,"aria-selected":`false`,...M(C(t))},e.label)},E=e=>{let t=w++;return ne(e,R(h,t),p.has(String(e.value)),C(t))},D=g.map(T),O=v.length&&f?[i(`div`,{class:`wui-select-group`},f.label),...v.map(E),i(`div`,{class:`wui-select-sep`,"aria-hidden":`true`})]:[],F=w,I=[];if(S)w+=m.length;else{let e=``;for(let t of m)t.group&&t.group!==e&&I.push(i(`div`,{class:`wui-select-group`},t.group)),e=t.group??``,I.push(E(t))}let L=_.map(T),z=[];if(o===`loading`||o===`more`?z=[i(`div`,{class:`wui-select-loading`},i(`span`,{class:`wui-select-spinner spinner-border spinner-border-sm`,role:`status`,"aria-hidden":`true`}),o===`more`?l:c)]:o===`hint`?z=[i(`div`,{class:`wui-select-hint`},u)]:(o===`empty`||m.length===0&&d.length===0)&&(z=[i(`div`,{class:`wui-select-empty`},s)]),S&&x){let n=[...D,...O],r=[...L,...z];return x.render(e,{options:t,query:a,rows:m,pre:n,post:r,preSig:N(n),postSig:N(r),picked:p,top:g,recent:v,bottom:_,bodyBase:F,total:y}),{rows:y,windowed:!0,long:b}}x?.clear(e);let B=[...D,...O,...I,...L,...z],V=N(B);return j.get(e)===V||(j.set(e,V),e.replaceChildren(...B)),{rows:w,windowed:!1,long:b}}var R=(e,t)=>`${e}-opt-${t}`,z=e=>[...e.querySelectorAll(`.wui-select-option`)];function B(e){return P?P.refresh(e):!1}function V(e,t){return P?P.reveal(e,t):z(e)[t]??null}function ee(e,t){if(P)return P.indexOfValue(e,t);let n=new Set(t.map(String));return z(e).findIndex(e=>n.has(e.dataset.value??``))}function te(e,t){return P?P.indexByPrefix(e,t):z(e).findIndex(e=>(e.textContent??``).trim().toLowerCase().startsWith(t))}function ne(e,n,r,a){let o=!!e.disabled,s={id:n,role:`option`,"data-value":String(e.value??``),"aria-selected":String(r),"aria-disabled":o?`true`:void 0,title:o&&e.disabledHint?e.disabledHint:void 0,...M(a)},c=i(`span`,{class:`wui-select-check`,"aria-hidden":`true`},d(`check`));if(!e.description&&!e.meta)return i(`button`,{type:`button`,class:`wui-select-option${r?` selected`:``}`,...s},t(e),i(`span`,{class:`wui-select-opt-name`},...b(e)),c);let l=e.description?i(`span`,{class:`wui-select-opt-desc`},e.description):null,u=e.meta?i(`span`,{class:`wui-select-opt-meta`},e.meta):null;return i(`div`,{class:`wui-select-option wui-select-option-rich${r?` selected`:``}`,...s},t(e),i(`span`,{class:`wui-select-option-text`},i(`span`,{class:`wui-opt-label`},...b(e)),l),u,c)}var re=Object.freeze([`single`,`multiple`,`search`,`tag`,`country`]),H=e=>e===`multiple`||e===`tag`,U={recents:()=>import(`./recents-DTddcnaM.js`),chips:()=>import(`./chips-BzSOOCI-.js`),search:()=>import(`./search-Is-q8GR6.js`),country:()=>import(`./country-CX7Ok3Md.js`)};function ie(e){let t=T(U,e)?U[e]:void 0;return t?t():Promise.reject(/* @__PURE__ */ Error(`Unknown <wui-select> part: ${e}.`))}var W=e=>typeof e.loadOptions==`function`||!!e.getAttribute(`source`)||e.hasAttribute(`remote`),ae=300,G=`<div class="wui-select-spacer" aria-hidden="true"></div>`,K=()=>i(`div`,{class:`wui-select-spacer`,"aria-hidden":`true`}),q=/* @__PURE__ */ new WeakMap,J=(e,t)=>{let n=e.entries[e.optionEntry[t]??-1];return n?.kind===`option`?n.option:void 0},oe=(e,t,n)=>e.query===t&&e.count>0&&n.length>e.count&&n[0]===J(e,0)&&n[e.count-1]===J(e,e.count-1);function se(e,t,n,r){let i=q.get(e);if(i&&i.options===t&&i.query===n&&i.count===r.length)return i;let a=i!==void 0&&oe(i,n,r),o=[],s=new Int32Array(r.length),c=``;r.forEach((e,t)=>{e.group&&e.group!==c&&o.push({kind:`group`,label:e.group}),c=e.group??``,s[t]=o.length,o.push({kind:`option`,option:e,ord:t})});let l={options:t,query:n,count:r.length,entries:o,optionEntry:s,heights:O(o.length),estimated:!1,bodyTop:0,start:0,end:0,pre:[],post:[],preSig:``,postSig:``,picked:/* @__PURE__ */ new Set,top:[],recent:[],bottom:[],bodyBase:0,total:0};if(q.set(e,l),i&&a){l.heights.setEstimate(i.heights.estimate),l.estimated=i.estimated,l.bodyTop=i.bodyTop;for(let e=0;e<i.entries.length;e++)l.heights.set(e,i.heights.heightOf(e))}else i&&(e.scrollTop=0);return l}var Y=e=>e.clientHeight||ae,ce=(e,t)=>D(t.heights,{scrollTop:Math.max(0,e.scrollTop-t.bodyTop),viewport:Y(e)});function le(e,t,n,r){let a=[];for(let o=n;o<r;o++){let n=e.entries[o];if(n){if(n.kind===`group`)a.push(i(`div`,{class:`wui-select-group`,"data-entry":o},n.label));else{let r=e.bodyBase+n.ord;a.push(ne(n.option,R(t,r),e.picked.has(String(n.option.value)),{index:r,size:e.total}))}}}return a}function ue(e,t){let[n,r]=e.querySelectorAll(`.wui-select-spacer`);n&&r&&(n.style.flex=r.style.flex=`none`,n.style.height=`${t.heights.offsetOf(t.start)}px`,r.style.height=`${t.heights.total()-t.heights.offsetOf(t.end)}px`)}function de(e,t){let{start:n,end:r}=ce(e,t);t.start=n,t.end=r;let i=le(t,e.id,n,r),a=t.preSig+G+N(i)+G+t.postSig,o=e.scrollTop;j.get(e)!==a&&(j.set(e,a),e.replaceChildren(...t.pre,K(),...i,K(),...t.post)),ue(e,t),e.scrollTop!==o&&(e.scrollTop=o)}function fe(e,t){let n={changed:!1,delta:0};if(!e.clientHeight)return n;let{heights:r}=t,i=e.querySelector(`.wui-select-spacer`),a=[],o=!0,s=!1;if(i){let n=i.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;Math.abs(n-t.bodyTop)>.5&&(t.bodyTop=n,s=!0)}let c=r.indexAt(Math.max(0,e.scrollTop-t.bodyTop)),l=r.offsetOf(c),u=0;for(let n of e.querySelectorAll(`.wui-select-option[data-index], .wui-select-group[data-entry]`)){let e=n.getBoundingClientRect().height;if(n.dataset.entry!==void 0)a.push([Number(n.dataset.entry),e]);else{let r=Number(n.dataset.index)-t.bodyBase,i=r>=0?t.optionEntry[r]:void 0;if(i===void 0)continue;o&&(u=e),o=!1,a.push([i,e])}}if(!t.estimated&&u>0){let e=r.estimate;r.setEstimate(u),t.estimated=!0,r.estimate!==e&&(s=!0)}for(let[e,t]of a)r.set(e,t)&&(s=!0);return s?{changed:s,delta:r.offsetOf(c)-l}:n}function X(e,t){de(e,t);for(let n=0;n<2;n++){let{changed:n,delta:r}=fe(e,t);if(!n)return;ue(e,t),r&&(e.scrollTop+=r),de(e,t)}}function pe(e,t){let n=se(e,t.options,t.query,t.rows);Object.assign(n,{pre:t.pre,post:t.post,preSig:t.preSig,postSig:t.postSig,picked:t.picked,top:t.top,recent:t.recent,bottom:t.bottom,bodyBase:t.bodyBase,total:t.total}),X(e,n)}function me(e){let t=q.get(e);if(!t)return!1;let{start:n,end:r}=ce(e,t);return n===t.start&&r===t.end?!1:(X(e,t),!0)}function he(e,t){let n=q.get(e);if(!n||t<0||t>=n.total)return null;let r=t-n.bodyBase,i=r>=0?n.optionEntry[r]:void 0,a=()=>e.querySelector(`[data-index="${t}"]`);if(i===void 0)return a();for(let t=0;t<2;t++){let t={scrollTop:e.scrollTop-n.bodyTop,viewport:Y(e)},r=n.bodyTop+E(n.heights,i,t);if(Math.abs(r-e.scrollTop)>.5)e.scrollTop=r;else if(a())break;X(e,n)}return a()}function ge(e,t){if(t<0||t>=e.total)return;if(t<e.top.length)return e.top[t];let n=t-e.top.length;if(n<e.recent.length)return e.recent[n];let r=t-e.bodyBase;if(r<e.count){let t=e.entries[e.optionEntry[r]??-1];return t?.kind===`option`?t.option:void 0}return e.bottom[r-e.count]}var _e=e=>e&&!(`position`in e)?e:void 0;function ve(e,t){let n=q.get(e);if(!n||t.length===0)return-1;let r=new Set(t.map(String));for(let e=0;e<n.total;e++){let t=_e(ge(n,e));if(t&&r.has(String(t.value)))return e}return-1}var ye=e=>`position`in e?e.label:`${e.initials??``}${y(e)}${e.description??``}${e.meta??``}`;function be(e,t){let n=q.get(e);if(!n)return-1;for(let e=0;e<n.total;e++){let r=ge(n,e);if(r&&ye(r).trim().toLowerCase().startsWith(t))return e}return-1}F({render:pe,refresh:me,reveal:he,indexOfValue:ve,indexByPrefix:be,clear(e){q.delete(e)}});function xe(){return Promise.resolve()}var Z=()=>x(`select`,C),Se=()=>x(`search`,w),Ce=()=>x(`field`,S),we=160,Te=class extends a{static formAssociated=!0;_internals;_value;_optionsProp;_partOptions;_known;_loadOptionsFn;_validateFn;_declared;_query;_ownsFilter;_active;_rows;_windowed;_windowLoad;_windowFailed;_scrollFrame;_endFrame;_status;_error;_nav;_parts;_partSig;_partsMounted;_partToken;_rendered;_searchShown;_defaultValue;_warnedMode;_warnedDensity;_hoverTimer;_hoverOpened;_onHoverOver;_onHoverOut;_panelShown;_pressOpen;static get observedAttributes(){return/* @__PURE__ */ `class.mode.value.placeholder.search-placeholder.empty-text.searchable.clearable.disabled.readonly.loading.required.size.density.icon.prefix.open.open-on-hover.lazy-options.aria-label.aria-describedby.aria-invalid.min-chars.debounce.source.remote.allow-custom.add-label.searching-text.hint-text.value-label.value-avatar.value-initials.max-tags.allow-duplicates.separators.pattern.invalid-message.create-label.collapse-chips.selected-text.clear-all-label.countries.suggested.suggested-label.all-countries-label.recents-key.recents-limit.recents-label`.split(`.`)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``,this._optionsProp=null,this._partOptions=null,this._known=/* @__PURE__ */ new Map,this._loadOptionsFn=null,this._validateFn=null,this._declared=void 0,this._query=``,this._ownsFilter=!1,this._active=-1,this._rows=0,this._windowed=!1,this._windowLoad=null,this._windowFailed=!1,this._scrollFrame=null,this._endFrame=null,this._status=`idle`,this._error=``,this._nav=null,this._parts=null,this._partSig=``,this._partsMounted=!1,this._partToken=0,this._rendered=!1,this._searchShown=!1,this._defaultValue=void 0,this._warnedMode=null,this._hoverTimer=null,this._hoverOpened=!1,this._panelShown=!1,this._pressOpen=null,this._onHoverOver=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&(this._clearHover(),!this._menuOpen()&&this._hoverEligible()&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,!this._menuOpen()&&this._hoverEligible()&&(this._open({focus:!1}),this._hoverOpened=!0)},ke)))},this._onHoverOut=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&!this._hoverZone(e.relatedTarget)&&(this._clearHover(),this._menuOpen()&&this.hasAttribute(`open-on-hover`)&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,this._close()},Ae)))}}connectedCallback(){this.addEventListener(`pointerover`,this._onHoverOver),this.addEventListener(`pointerout`,this._onHoverOut),this._rendered||this.render(),this._ensureParts(),this._mountParts()}disconnectedCallback(){this.removeEventListener(`pointerover`,this._onHoverOver),this.removeEventListener(`pointerout`,this._onHoverOut),this._clearHover(),this._dropMenu(),this._teardown(),this._teardownParts()}attributeChangedCallback(e,t,n){e===`class`?this._syncUnderline():e===`value`?(this._value=Q(n,H(this.mode)),this._applyValue()):e===`aria-invalid`?this._syncInvalid():e===`open`?this._rendered&&(this.hasAttribute(`open`)?this._open({focus:!1}):this._close({force:!0})):e===`open-on-hover`?this.hasAttribute(`open-on-hover`)||this._clearHover():e!==`lazy-options`&&(e===`mode`&&(this._value=Q(this._value,H(this.mode)),this._partOptions=null,this._known.clear(),this._ensureParts()),(e===`source`||e===`remote`||e===`recents-key`)&&this._ensureParts(),Pe.has(e)?this._rendered&&(this._drawValue(),this.renderList()):Ne.has(e)?this._remountParts():this._rendered&&this.render())}formResetCallback(){if(this.value=this._defaultValue??``,!this._rendered)return;let e=this._refs();e.input&&(e.input.value=``,e.input.removeAttribute(`aria-invalid`)),e.search&&(e.search.value=``),this.setError(``),this._query!==``&&this._onQueryChange(``)}get mode(){let e=this.getAttribute(`mode`);return e===null?`single`:De(e)?e:(e!==this._warnedMode&&(this._warnedMode=e,n(`<wui-select> mode "${e}" is not one of ${re.join(`, `)}; it is treated as "single".`)),`single`)}_checkDensity(){let e=this.getAttribute(`density`);e===null||Oe.includes(e)||e===this._warnedDensity||(this._warnedDensity=e,n(`<wui-select> density "${e}" is not one of ${Oe.join(`, `)}; it is treated as "comfortable".`))}set mode(e){this.setAttribute(`mode`,String(e))}get value(){return Array.isArray(this._value)?this._value.slice():this._value}set value(e){this._value=Q(e,H(this.mode)),this._applyValue()}get options(){return this._readOptions()}set options(e){this._optionsProp=Array.isArray(e)?e:null,this.mode!==`country`&&(this._partOptions=null);for(let e of this._activePartsList())e.onOptions?.();if(this._rendered){if(this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._autoSearch()!==this._searchShown){this.render();return}this._drawValue(),this.renderList()}}get loadOptions(){return this._loadOptionsFn}set loadOptions(e){this._loadOptionsFn=typeof e==`function`?e:null,this._ensureParts()}get validate(){return this._validateFn}set validate(e){this._validateFn=typeof e==`function`?e:null}commit(e,t={}){this.value=e,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:!!t.isCustom}}))}setPartOptions(e){this._partOptions=Array.isArray(e)?e:null,this._drawValue(),this.renderList()}setStatus(e){this._status=e,this.renderList()}setError(e){this._error=e?String(e):``,this._syncError()}openMenu(){s(this)||this._open({focus:!1})}closeMenu({focusControl:e=!1}={}){this._close(),e&&this._refs().control?.focus()}renderList(){let e=this._refs();if(!e.list)return;let t=this._ownsFilter?``:this._query,n=this._actionRows(),r=this._recents();if(this.hasAttribute(`lazy-options`)&&!this._menuOpen()){this._rows=A(this._listOptions(),t).length+n.length+(r?.options.length??0),this._windowed=!1,I(e.list),this._anchorMenu();return}let i=L(e.list,this._listOptions(),{selected:this._selectedValues(),query:t,status:this._status,emptyText:this.getAttribute(`empty-text`)||Z().emptyText,searchingText:this.getAttribute(`searching-text`)||Z().searchingText,loadingMoreText:Z().loadingMoreText,hintText:this.getAttribute(`hint-text`)||void 0,actionRow:n,recents:r});this._rows=i.rows,this._windowed=i.windowed,i.long&&!i.windowed&&!this._windowFailed&&this._loadWindow(),this._active>=this._rowCount()&&(this._active=-1),this._active>=0&&this._setActive(this._active,{reveal:!1}),this._anchorMenu(),this._watchListEnd()}_watchListEnd(){this._endFrame===null&&this._activePartsList().some(e=>e.onListEnd)&&(this._endFrame=requestAnimationFrame(()=>{this._endFrame=null,this._checkListEnd()}))}_checkListEnd(){let e=this._refs().list;if(e?.clientHeight&&this._menuOpen()&&!(e.scrollTop+e.clientHeight<e.scrollHeight-we))for(let e of this._activePartsList())e.onListEnd?.()}render(){this._dropMenu();let e=this._carry();this._teardownParts(),this._snapshotDeclared();let t=this.mode;this._checkDensity();let n=H(t),r=t===`tag`,a=n&&(r||this.hasAttribute(`allow-custom`));this._value=Q(this._value,n),this._defaultValue===void 0&&n&&this._value.length===0&&(this._value=this._declaredSelected()),n||this._preselect(),this._defaultValue===void 0&&(this._defaultValue=Q(this._value,n));let s=this.getAttribute(`size`),c=s===`sm`?` wui-select-sm`:s===`lg`?` wui-select-lg`:s===`xl`?` wui-select-xl`:``,l=this.getAttribute(`icon`),u=this.getAttribute(`prefix`),f=this.hasAttribute(`clearable`),p=this.hasAttribute(`disabled`);if(!this.id){let e=crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(8));this.id=`wui-select-${Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}`}let m=`${this.id}-listbox`,h=`${this.id}-entry-error`,g=this.getAttribute(`aria-describedby`)?.trim(),_=g?`${g} ${h}`:h,v=this.hasAttribute(`aria-invalid`)||!!this._error,y=this.hasAttribute(`required`)&&!a,b=this._accessibleName(),x=a?{}:{role:`combobox`,"aria-haspopup":`listbox`,"aria-expanded":`false`,"aria-controls":m},S={"aria-label":b,"aria-describedby":_,"aria-invalid":v?`true`:void 0,"aria-required":y?`true`:void 0},C=n?i(`div`,{class:`form-control wui-select-control wui-select-multi`,...x,...S,"aria-disabled":p?`true`:void 0,tabindex:!p&&!r?`0`:void 0}):i(`button`,{type:`button`,class:`form-control wui-select-control`,...x,...S,disabled:p||void 0}),w=[l?d(l,{className:`wui-select-icon`}):null,u?i(`span`,{class:`wui-select-prefix`},u):null,i(`span`,{class:`wui-select-value`,"data-label":!0}),f?i(`span`,{class:`wui-select-reset`,role:`button`,"aria-label":Z().clearSelectionLabel,hidden:!0},d(`x`)):null,d(`chevron-down`,{className:`wui-select-caret`})];C.append(...w.filter(e=>e!==null));let T=this.getAttribute(`searchable`),E=T===null?t===`multiple`||t===`country`||this._autoSearch():T!==`false`,D=t===`search`||E&&!a;this._searchShown=D;let O=this.getAttribute(`search-placeholder`)||(t===`country`?Z().countrySearchPlaceholder:Se().placeholder),k=D?i(`div`,{class:`wui-select-search`},d(`search`),i(`input`,{class:`wui-select-input`,placeholder:O,"aria-label":O,"aria-autocomplete":`list`}),i(`button`,{type:`button`,class:`wui-select-clear`,"aria-label":Se().clearLabel,hidden:!0},d(`x`))):null,A=i(`div`,{class:`wui-select-options`,role:`listbox`,id:m,tabindex:`-1`,"aria-multiselectable":n?`true`:void 0}),j=i(`div`,{class:`wui-select-menu wui-select-menu-fixed`,popover:`auto`},k,A),M=i(`div`,{class:`field-error wui-select-error`,id:h,"aria-live":`polite`,hidden:!this._error||void 0},this._error||null);this.replaceChildren(i(`div`,{class:`wui-select${c}`},C,j),M),this._rendered=!0,this._syncMirror(),this._syncValidity(),this._drawValue(),this._syncReset(),this.renderList(),this._wire(),o(this,this.querySelector(`.wui-select-control`)),this._syncUnderline(),this._mountParts(e)}_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||Z().fallbackName}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>{let t=document.createDocumentFragment();for(let n of e.childNodes)t.append(n.cloneNode(!0));let n={value:e.getAttribute(`value`)??Ve(e).trim(),label:t.textContent??``,selected:e.hasAttribute(`selected`)};for(let[t,r]of Fe){let i=e.getAttribute(t);i&&(n[r]=i)}return e.hasAttribute(`disabled`)&&(n.disabled=!0),v(n,t)}))}_readOptions(){return this.mode===`country`?this._partOptions||[]:this._partOptions?this._partOptions:this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}_listOptions(){let e=this._readOptions(),t=this.getAttribute(`value-label`);if(this.mode!==`search`||!t||this._value===``)return e;let n=String(this._value);return e.some(e=>String(e.value)===n)?e:[...e,{value:n,label:t}]}_declaredSelected(){return this._optionsProp?[]:(this._declared??[]).filter(e=>e.selected).map(e=>String(e.value))}_preselect(){let e=this._readOptions(),t=this._value!==``&&e.find(e=>String(e.value)===this._value)||e.find(e=>`selected`in e&&!!e.selected);t&&(this._value=String(t.value))}_optionFor(e){let t=String(e),n=this._readOptions().find(e=>String(e.value)===t);return n?(this._known.set(t,n),n):this._known.get(t)}_placeholder(){return this.getAttribute(`placeholder`)||Me()[this.mode]}_hasValue(){return Array.isArray(this._value)?this._value.length>0:this._value!==``}_selectedValues(){return Array.isArray(this._value)?this._value:this._value===``?this._listOptions().some(e=>String(e.value)===``)?[``]:[]:[this._value]}_applyValue(){this._syncMirror(),this._syncValidity(),this._rendered&&(this._drawValue(),this._syncReset(),this.renderList())}_syncMirror(){H(this.mode)?c(this,this._selectedValues()):l(this,this._value)}_drawValue(){let e=this._refs();if(!e.value)return;let t=H(this.mode),n=t?void 0:this._optionFor(this._value);if(this._syncTitle(n),this._syncValueAvatar(),this._activePartsList().some(e=>e.renderValue?.()===!0))return;if(t){e.value.classList.remove(`wui-select-placeholder`),e.value.textContent=``;return}e.value.classList.toggle(`wui-select-placeholder`,!n);let r=this._placeholder();e.value.replaceChildren(...n?b(n):r?[r]:[])}_syncTitle(e){let t=this.querySelector(`.wui-select-control`);if(!t)return;let n=e&&!this.hasAttribute(`title`)?y(e).trim():``;n?t.setAttribute(`title`,n):t.removeAttribute(`title`)}_syncValueAvatar(){let e=this.querySelector(`.wui-select-control`);if(!e)return;e.querySelector(`:scope > .wui-select-value-avatar`)?.remove();let n=!H(this.mode)&&this._hasValue()?t({avatar:this.getAttribute(`value-avatar`),initials:this.getAttribute(`value-initials`)},`avatar-xs`):null;e.classList.toggle(`wui-has-value-avatar`,!!n),n&&e.prepend(i(`span`,{class:`wui-select-value-avatar`,"aria-hidden":`true`},n))}_syncValidity(){let e=this._internals;if(typeof e?.setValidity==`function`){if(this.hasAttribute(`required`)&&!this._hasValue()){let t=this.querySelector(`.wui-select-control`);e.setValidity({valueMissing:!0},Ce().requiredFieldMessage,t instanceof HTMLElement?t:void 0)}else e.setValidity({})}}_syncReset(){let e=$(this,`.wui-select-reset`,HTMLElement);e&&(e.hidden=!(this.hasAttribute(`clearable`)&&this._hasValue()&&!s(this)))}_syncUnderline(){this.querySelector(`.wui-select-control`)?.classList.toggle(`wui-input-underline`,this.classList.contains(`wui-input-underline`))}_syncInvalid(){let e=this.querySelector(`.wui-select-control`);e&&(this.hasAttribute(`aria-invalid`)||this._error?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}_syncError(){let e=$(this,`.wui-select-error`,HTMLElement);e&&(e.textContent=this._error,e.hidden=!this._error),this._syncInvalid()}_refs(){return{control:$(this,`.wui-select-control`,HTMLElement),value:$(this,`.wui-select-value`,HTMLElement),menu:$(this,`.wui-select-menu`,HTMLElement),list:$(this,`.wui-select-options`,HTMLElement),search:$(this,`.wui-select-search input`,HTMLInputElement),input:$(this,`.wui-select-draft`,HTMLInputElement)}}_menuOpen(){let e=$(this,`.wui-select-menu`,HTMLElement);return e!==null&&_(e)}_hoverZone(e){if(!(e instanceof Element))return!1;let t=e.closest(`.wui-select-control, .wui-select-menu`);return t!==null&&this.contains(t)}_hoverEligible(){if(!this.hasAttribute(`open-on-hover`)||s(this)||this.mode===`tag`)return!1;let e=this._refs();return e.search===null&&e.input===null}_clearHover(){this._hoverTimer!==null&&clearTimeout(this._hoverTimer),this._hoverTimer=null}_autoSearch(){return this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._readOptions().length>je}_visible(){let e=this._refs();return e.list?Be(e.list,`.wui-select-option`):[]}_rowCount(){return this._windowed?this._rows:this._visible().length}_rowEl(e){if(!this._windowed)return this._visible()[e];let t=this._refs().list?.querySelector(`[data-index="${e}"]`);return t instanceof HTMLElement?t:void 0}_setActive(e,{reveal:t=!0}={}){let n=this._refs();if(!n.list||!n.control)return;this._active=e;let r=null;e>=0&&e<this._rowCount()&&(r=this._rowEl(e)??(this._windowed&&t?V(n.list,e):null)),p(n.list,r),r?(t&&r.scrollIntoView({block:`nearest`}),n.control.setAttribute(`aria-activedescendant`,r.id)):n.control.removeAttribute(`aria-activedescendant`)}_onListScroll(){this._scrollFrame=null;let e=this._refs().list;e&&(this._windowed&&B(e)&&this._active>=0&&this._setActive(this._active,{reveal:!1}),this._checkListEnd())}_actionRows(){let e=[];for(let t of this._activePartsList()){let n=t.actionRow?.(this._query);n&&e.push(n)}return e}_recents(){if(this._query.trim()!==``)return null;for(let e of this._activePartsList()){let t=e.recents?.(this._listOptions());if(t)return t}return null}_menuPlacement(e,t){let n=this.hasAttribute(`open`)?{below:!0}:{};if(this.getAttribute(`density`)!==`compact`)return{matchWidth:!0,...n};let r=e.getBoundingClientRect();return t.style.width=`max-content`,t.style.minWidth=`${r.width}px`,t.style.maxWidth=`280px`,n}_anchorMenu(){let t=this._refs();t.control&&t.menu&&this._menuOpen()&&e(t.control,t.menu,this._menuPlacement(t.control,t.menu))}_showMenu(e,t){g(e,t,{...this._menuPlacement(e,t),mode:`auto`,keepOffscreen:this.hasAttribute(`open`),onClosed:()=>this._onPanelClosed()}),this._panelShown=!0}_onPanelClosed(){if(!this._panelShown)return;this._panelShown=!1;let e=this._refs();e.control&&(e.control.setAttribute(`aria-expanded`,`false`),this._setActive(-1),this._nav?.clearTypeahead(),this.dispatchEvent(new CustomEvent(`wui-select:close`,{bubbles:!0})))}_open({focus:e=!0}={}){let t=this._refs();if(!t.menu||!t.control)return;let n=this._menuOpen();this._hoverOpened=!1,t.control.setAttribute(`aria-expanded`,`true`),this._query=t.input?t.input.value:``,this._ownsFilter=this._ownsFilter&&this._query!==``;let r=$(this,`.wui-select-search .wui-select-clear`,HTMLElement);if(r&&(r.hidden=!0),t.search&&(t.search.value=``),n||this._showMenu(t.control,t.menu),this.renderList(),e&&(t.search?.focus(),this._setActive(this._windowed&&t.list?ee(t.list,this._selectedValues()):this._visible().findIndex(e=>e.classList.contains(`selected`)))),!n){this.dispatchEvent(new CustomEvent(`wui-select:open`,{bubbles:!0}));for(let e of this._activePartsList())e.onOpen?.()}}_close({force:e=!1}={}){if(!e&&this.hasAttribute(`open`))return;let t=this._refs();if(!t.menu||!t.control)return;this._hoverOpened=!1;let n=t.menu.contains(document.activeElement);_(t.menu)&&h(t.menu),this._onPanelClosed(),n&&t.control.focus()}_onQueryChange(e){this._query=e,this._setActive(-1);let t=$(this,`.wui-select-search .wui-select-clear`,HTMLElement);t&&(t.hidden=!e);let n=!1;for(let t of this._activePartsList())t.onQuery?.(e)===!0&&(n=!0);this._ownsFilter=n,this.renderList()}_pick(e){if(e.getAttribute(`aria-disabled`)===`true`)return;let t=e.dataset.custom===`true`,n=e.dataset.value??``,r=t?{value:n,label:Ve(e).trim()}:this._listOptions().find(e=>String(e.value)===n)??{value:n,label:n},i=this._activePartsList().some(e=>e.onPick?.(r,{isCustom:t})===!0);H(this.mode)||(i||this.commit(n,{isCustom:t}),this._close(),this._refs().control?.focus())}_draftOpens(){return this.mode===`multiple`?this.hasAttribute(`allow-custom`):this.mode===`tag`&&W(this)}_onKeyDown(e){if(!s(this)){for(let t of this._activePartsList())if(t.onKey?.(e)===!0)return;if(!this._menuOpen()){if(e.target instanceof HTMLInputElement){if(e.key!==`ArrowDown`||!this._draftOpens())return;this._open({focus:!1})}else{(e.key===`ArrowDown`||f(e)||e.key===` `)&&(e.preventDefault(),this._open({focus:!0}));return}}r(this._nav,`Listbox keys are not wired.`).handler(e)}}_wire(){this._teardown();let e=this._refs(),t=e.control,n=e.list;if(!t||!e.menu||!n)return;let i=r($(this,`.wui-select`,HTMLElement),`The select wrapper is missing.`),a=$(this,`.wui-select-search .wui-select-clear`,HTMLElement),o=$(this,`.wui-select-reset`,HTMLElement);this._nav=m({getVisibleOptions:()=>this._visible(),getActive:()=>this._active,setActive:e=>this._setActive(e),getCount:()=>this._rowCount(),getOptionAt:e=>this._rowEl(e),findByPrefix:e=>this._windowed?te(n,e):this._visible().findIndex(t=>t.textContent.trim().toLowerCase().startsWith(e)),onEnter:(e,t)=>{if(e)this._pick(e);else if(this._query.trim()!==``){let e=t.find(e=>e.dataset.custom===`true`);if(e)this._pick(e);else if(t.length===1){let e=t[0];e&&this._pick(e)}}},onEscape:e=>{e.preventDefault(),this._nav?.clearTypeahead(),this._close(),t.focus()}}),i.addEventListener(`keydown`,e=>this._onKeyDown(e)),i.addEventListener(`input`,e=>{let t=e.target;if(!(t instanceof HTMLInputElement)||!t.matches(`.wui-select-input, .wui-select-draft`))return;this._onQueryChange(t.value);let n=t.matches(`.wui-select-draft`),r=this._rows>0||this._actionRows().length>0;n&&r&&!this._menuOpen()&&!s(this)&&this._draftOpens()&&this._open({focus:!1})}),i.addEventListener(`focusout`,e=>{let t=e.relatedTarget;t instanceof Node&&this.contains(t)||!this._activePartsList().some(e=>e.onBlur?.()===!0)&&t&&this._close()}),a?.addEventListener(`click`,()=>{let t=r(e.search,`The search input is missing.`);t.value=``,this._onQueryChange(``),t.focus()}),t.addEventListener(`pointerdown`,()=>{this._pressOpen=this._menuOpen()}),t.addEventListener(`click`,e=>{if(e.target instanceof Element&&e.target.closest(`[data-remove]`))return;if(this.mode===`tag`){if(s(this))return;this._refs().input?.focus(),!this._menuOpen()&&this._draftOpens()&&this._open({focus:!1});return}if(e.target instanceof HTMLInputElement){!this._menuOpen()&&!s(this)&&this._open({focus:!1});return}let t=e.detail>0&&this._pressOpen!==null?this._pressOpen:this._menuOpen();this._pressOpen=null,this._clearHover(),this._hoverOpened&&t?(this._hoverOpened=!1,this._open({focus:!0})):t?this._close():s(this)||this._open({focus:!0})}),o?.addEventListener(`click`,e=>{e.stopPropagation(),this.commit(H(this.mode)?[]:``),this._close(),t.focus()}),n.addEventListener(`click`,n=>{let r=ze(n).closest(`.wui-select-option`);if(r instanceof HTMLElement&&(this._pick(r),H(this.mode))){let n=this.querySelector(`.wui-select-draft`);(e.search??(n instanceof HTMLElement?n:t)).focus()}}),n.addEventListener(`mousedown`,e=>{H(this.mode)&&e.target instanceof Element&&e.target.closest(`.wui-select-option`)&&e.preventDefault()}),n.addEventListener(`mousemove`,e=>{let t=ze(e).closest(`.wui-select-option`);t instanceof HTMLElement&&!t.classList.contains(`is-active`)&&this._setActive(this._windowed?Number(t.dataset.index):this._visible().indexOf(t),{reveal:!1})}),n.addEventListener(`scroll`,()=>{this._scrollFrame===null&&(this._scrollFrame=requestAnimationFrame(()=>this._onListScroll()))},{passive:!0}),n.addEventListener(`mouseleave`,()=>this._setActive(-1)),n.addEventListener(`error`,e=>{let t=e.target;t instanceof Element&&t.classList.contains(`avatar-img`)&&t.remove()},!0),this.hasAttribute(`open`)&&this._open({focus:!1})}_teardown(){this._nav?.clearTypeahead(),this._scrollFrame!==null&&cancelAnimationFrame(this._scrollFrame),this._scrollFrame=null,this._endFrame!==null&&cancelAnimationFrame(this._endFrame),this._endFrame=null}_dropMenu(){let e=$(this,`.wui-select-menu`,HTMLElement);e&&h(e)}_activePartsList(){return this._partsMounted?r(this._parts,`The mounted parts are missing.`):[]}_ensureParts(){if(!this.isConnected)return;(this.hasAttribute(`source`)||this.hasAttribute(`remote`)||this.hasAttribute(`recents-key`)||this._loadOptionsFn!==null)&&this._loadWindow();let e=Le(this,this.mode),t=e.join(`,`);if(t===this._partSig)return;this._teardownParts(),this._parts=null,this._partSig=t;let n=++this._partToken;Promise.all(e.map(e=>He(this,e))).then(e=>{n===this._partToken&&(this._parts=e.filter(e=>e!==null),this._mountParts())})}_loadWindow(){this._windowLoad===null&&(this._windowLoad=xe().then(()=>this.renderList(),()=>{this._windowFailed=!0,document.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{chunk:`select-window`}})),this.setError(Z().partLoadMessage)}))}_mountParts(e={draft:``,query:``}){if(!this._parts||this._partsMounted||!this._rendered||!this.isConnected)return;this._partsMounted=!0;let t=Ee(this._refs());for(let n of this._parts)n.mount(this,t,{carry:e});this._drawValue(),this.renderList()}_teardownParts(){let e=this._activePartsList();this._partsMounted=!1;for(let t of e)t.teardown()}_remountParts(){if(!this._partsMounted)return;let e=this._carry();this._teardownParts(),this._mountParts(e)}_carry(){let e=this._refs();return{draft:e.input?.value??``,query:e.search?.value??``}}},Ee=e=>{let{control:t,value:n,menu:i,list:a}=e;return{control:r(t,`control missing`),value:r(n,`value missing`),menu:r(i,`menu missing`),list:r(a,`list missing`),search:e.search,input:e.input}},De=e=>re.includes(e),Oe=[`comfortable`,`compact`],ke=150,Ae=250,je=10,Me=()=>{let e=Z();return{single:e.placeholder,search:e.placeholder,multiple:e.placeholder,tag:e.tagPlaceholder,country:e.countryPlaceholder}},Ne=/* @__PURE__ */ new Set([`countries`,`suggested`,`suggested-label`,`all-countries-label`,`max-tags`,`pattern`,`collapse-chips`,`source`,`remote`,`min-chars`]),Pe=/* @__PURE__ */ new Set([`separators`,`allow-duplicates`,`invalid-message`,`create-label`,`add-label`,`selected-text`,`clear-all-label`,`value-label`,`value-avatar`,`value-initials`,`hint-text`,`recents-key`,`recents-limit`,`recents-label`]),Fe=[[`icon`,`icon`],[`description`,`description`],[`meta`,`meta`],[`group`,`group`],[`avatar`,`avatar`],[`initials`,`initials`],[`disabled-hint`,`disabledHint`]],Q=(e,t)=>t?Array.isArray(e)?e.map(String):e==null||e===``?[]:String(e).split(`,`).map(e=>e.trim()).filter(Boolean):Array.isArray(e)?e.length?String(e[0]):``:e==null?``:String(e),Ie=(e,t)=>t===`multiple`?W(e)?[`chips`,`search`]:[`chips`]:t===`search`?[`search`]:t===`country`?[`country`]:t===`tag`?W(e)?[`chips`,`search`]:[`chips`]:[],Le=(e,t)=>e.hasAttribute(`recents-key`)?[`recents`,...Ie(e,t)]:Ie(e,t),Re=e=>typeof e==`object`&&!!e&&`default`in e&&typeof e.default==`function`,ze=e=>{if(e.target instanceof Element)return e.target;throw Error(`The event target is not an element.`)},$=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},Be=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),Ve=e=>{let t=e.textContent;if(t===null)throw Error(`The element has no text.`);return t},He=(e,t)=>ie(t).then(e=>{if(!Re(e))throw Error(`The part ${t} has no default export.`);return e.default()}).catch(()=>(document.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{chunk:t}})),e.setError(Z().partLoadMessage),null));export{W as n,A as r,Te as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./dom-DMQu--xV.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{a as r,l as i,s as a}from"./nativeOverlay-
|
|
1
|
+
import{i as e,t}from"./dom-DMQu--xV.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{a as r,l as i,s as a}from"./nativeOverlay-MOABXAAh.js";import{a as o,c as s,d as c,f as l,l as u,o as d,p as f,r as p}from"./shortcutKeys-CoZBxKsS.js";var m=`wui-shortcuts-open-change`;function h(e,t){let n=e.querySelector(t);return n instanceof HTMLElement?n:null}function g(e,t){return[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement)}var _=class extends n{_doc;_onKeyDown;_onClick;_onDocClick;_onPointerDown;_onPressEnd;_pressedOpen;_pinned;_mirroring;static get observedAttributes(){return[`open`,`no-trigger`]}constructor(){super(),this._doc=null,this._pressedOpen=!1,this._pinned=!1,this._mirroring=!1,this._onKeyDown=e=>this._keydown(e),this._onClick=e=>this._click(e),this._onDocClick=e=>{let n=t(e.target,`[data-wui-shortcuts-open]`)?.getAttribute(`data-wui-shortcuts-open`);n&&this.matches(n)&&this.setOpen(!0)},this._onPointerDown=e=>{t(e.target,`.wui-shortcut-toggle`)&&(this._pressedOpen=this.open)},this._onPressEnd=e=>{e.type===`pointerup`&&t(e.target,`.wui-shortcut-toggle`)||(this._pressedOpen=!1)}}connectedCallback(){this._doc=this.ownerDocument,this._doc.addEventListener(`keydown`,this._onKeyDown),this._doc.addEventListener(`click`,this._onDocClick),this._doc.addEventListener(`pointerup`,this._onPressEnd,!0),this._doc.addEventListener(`pointercancel`,this._onPressEnd,!0),this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this.hasAttribute(`open`)&&!this.open&&(this._pinned=!0,this.setOpen(!0,{focus:!1})),this._syncTrigger()}attributeChangedCallback(e,t,n){e===`no-trigger`?this._syncTrigger():(this._mirroring||(this._pinned=n!==null),this._sheet()&&n!==null!==this.open&&this.setOpen(n!==null))}disconnectedCallback(){let e=this._sheet();e&&r(e),this._doc?.removeEventListener(`keydown`,this._onKeyDown),this._doc?.removeEventListener(`click`,this._onDocClick),this._doc?.removeEventListener(`pointerup`,this._onPressEnd,!0),this._doc?.removeEventListener(`pointercancel`,this._onPressEnd,!0),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerdown`,this._onPointerDown,!0),this._doc=null}get open(){let e=this._sheet();return!!(e&&a(e))}set open(e){let t=e===!0||e===``||e===`true`;this._pinned=t,this._sheet()?t!==this.open&&this.setOpen(t):this.toggleAttribute(`open`,t)}setOpen(t,{focus:n=!0}={}){let o=this._sheet();if(!o)return;let s=h(this,`.wui-shortcut-toggle`);if(t||(this._pinned=!1),t){o.removeAttribute(`hidden`);let t=this.hasAttribute(`no-trigger`)?s??this:e(s,`<wui-shortcuts> needs its toggle to anchor the sheet.`);i(t,o,{mode:`auto`,side:`top`,align:`end`,flipAlign:!0,gap:8,keepOffscreen:this._pinned,onClosed:()=>{this._pinned=!1,this._mirror(!1)}})}else r(o);this._mirror(t),n&&(t?queueMicrotask(()=>{a(o)&&h(o,`.wui-shortcut-close`)?.focus()}):s?.focus())}_mirror(e){let t=this._sheet();t&&(t.hidden=!e),h(this,`.wui-shortcut-toggle`)?.setAttribute(`aria-expanded`,String(e)),this.hasAttribute(`open`)!==e&&(this._mirroring=!0,this.toggleAttribute(`open`,e),this._mirroring=!1,this.dispatchEvent(new CustomEvent(m,{bubbles:!0,detail:{open:e}})))}_sheet(){return h(this,`.wui-shortcut-sheet`)}_syncTrigger(){let e=h(this,`.wui-shortcut-toggle`);e&&(e.hidden=this.hasAttribute(`no-trigger`))}_scope(){let e=this.closest(`[${p}]`);return e instanceof HTMLElement?e:null}_items(){let t=this.getAttribute(`items`);return t?g(e(this._scope()??this._doc,`WuiShortcuts used before it was connected`),t):[]}_click(e){let t=e.target;if(t instanceof Element){if(t.closest(`.wui-shortcut-toggle`)){let e=this._pressedOpen;this._pressedOpen=!1,this.setOpen(!e&&!this.open)}else t.closest(`.wui-shortcut-close`)&&this.setOpen(!1)}}_tickFocused(){let t=this._items(),n=e(this._doc,`WuiShortcuts used before it was connected`).activeElement,r=n?.closest?.(`li, tr`),i=t.find(e=>e===n||e.contains(n)||r?.contains(e)),a=(i?.closest(`li, tr`)??i)?.querySelector(`input[type="checkbox"]`);a instanceof HTMLInputElement&&a.click()}_focusSearch(){let t=this.getAttribute(`search`);if(!t)return;let n=e(this._doc,`WuiShortcuts used before it was connected`);(h(this._scope()??n,t)??h(n,t))?.focus()}_keydown(t){if(t.defaultPrevented)return;let n=l(t);if(!n)return;if(n===`esc`&&this.open){t.preventDefault(),this.setOpen(!1);return}let r=this._scope(),i={help:()=>this.setOpen(!this.open)};if(this.getAttribute(`items`)&&(i.j=()=>s(this._items(),1),i.k=()=>s(this._items(),-1),i.x=()=>this._tickFocused()),this.getAttribute(`search`)&&(i.slash=()=>this._focusSearch()),i[n]){u(t,i,r);return}if(n===`enter`)return;let a=e(this._doc,`WuiShortcuts used before it was connected`),p=t.target instanceof Node?t.target:null;if(f(a)||!o(p,r)||d(p))return;let m=c(n),_=g(this,`.wui-shortcut-keys [data-shortcut]`).find(e=>e.dataset.shortcut===m);if(!_)return;let v=(r??a).querySelector(`[aria-current="true"]`)?.closest(`[data-key]`),y=v instanceof HTMLElement?v.dataset.key??null:null;if(!this.dispatchEvent(new CustomEvent(`wui:shortcut`,{bubbles:!0,cancelable:!0,detail:{key:m,itemKey:y}}))){t.preventDefault();return}let b=_.dataset.target,x=b?h(a,b):null;x&&(t.preventDefault(),x.click())}};export{_ as t};
|