@webority/ui-elements 0.176.0 → 0.177.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/WuiCommentThread-e5t7HceL.js +1 -0
- package/dist/WuiDateRange-BnEJ2WpL.js +1 -0
- package/dist/{WuiInlineEdit-B7VCQXeG.js → WuiInlineEdit-p0cm_i90.js} +1 -1
- package/dist/{WuiMarkdown-DsN4YbiZ.js → WuiMarkdown-DRtGPxQX.js} +1 -1
- package/dist/WuiMentionInput-DPpEVL2s.js +1 -0
- package/dist/{WuiNotificationCenter-BIxUJ0tJ.js → WuiNotificationCenter-DuvGrqwr.js} +1 -1
- package/dist/{WuiPhone-CBge7oVA.js → WuiPhone--w-taM5Q.js} +1 -1
- package/dist/{WuiSavedViews-BmJmnkHu.js → WuiSavedViews-BKpnSd-Y.js} +1 -1
- package/dist/{WuiSelect-CBcfLzOF.js → WuiSelect-iUXaHKw5.js} +1 -1
- package/dist/{WuiSlider-R_mTula0.js → WuiSlider-CK7_l_R5.js} +1 -1
- package/dist/WuiTour-BgpMa8J5.js +1 -0
- package/dist/WuiTree-BjtuCasB.js +1 -0
- package/dist/{chips-DpD0EbS0.js → chips-xXgAvIFy.js} +1 -1
- package/dist/drawerDiscard-z1PsI4cx.js +1 -0
- package/dist/elements/comment-thread.js +1 -1
- package/dist/elements/date-range.js +1 -1
- package/dist/elements/inline-edit.js +1 -1
- package/dist/elements/kanban.js +1 -1
- package/dist/elements/markdown.js +1 -1
- package/dist/elements/mention-input.js +1 -1
- package/dist/elements/notification-center.js +1 -1
- package/dist/elements/phone.js +1 -1
- package/dist/elements/saved-views.js +1 -1
- package/dist/elements/select.js +1 -1
- package/dist/elements/slider.js +1 -1
- package/dist/elements/tour.js +1 -1
- package/dist/elements/tree.js +1 -1
- package/dist/helpers.js +1 -1
- package/dist/httpFailure.g-DjZzGxPj.js +1 -0
- package/dist/{kanban-BCOQDfvj.js → kanban-jQCTLG3Q.js} +1 -1
- package/dist/{listboxKeyNav-DNtuh6Ob.js → listboxKeyNav-CNso9shL.js} +1 -1
- package/dist/{search-BTNIAZY3.js → search-Bhn-bjLL.js} +1 -1
- package/dist/server.js +1 -1
- package/dist/text/en.json +1 -1
- package/dist/text.js +1 -1
- package/dist/themeTransition-TF0BqM20.js +1 -0
- package/dist/ui-calendar.global.js +1 -1
- package/dist/ui-calendar.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/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/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.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 +2 -2
- package/dist/ui-elements/org-tree.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/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/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/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/dist/{wuiHttp-BiwgFpmq.js → wuiHttp-Cw7V8u2w.js} +1 -1
- package/package.json +6 -6
- package/types/calendarAdapter.d.ts +8 -21
- package/types/calendarEngine.d.ts +22 -0
- package/types/commandShortcut.d.ts +12 -0
- package/types/globals.d.ts +0 -4
- package/types/helpers.d.ts +1 -1
- package/types/listboxKeyNav.d.ts +2 -3
- package/types/razor-js/modules/api.d.ts +0 -5
- package/types/server/index.d.ts +1 -0
- package/types/server/shellParts.d.ts +6 -0
- package/types/server/wuiHttp.d.ts +2 -0
- package/types/server/wuiUpload.d.ts +15 -0
- package/dist/WuiCommentThread-D8Cv8y8v.js +0 -1
- package/dist/WuiDateRange-qTncGobM.js +0 -1
- package/dist/WuiMentionInput-DAPLGewp.js +0 -1
- package/dist/WuiTour-BU00-6Lf.js +0 -1
- package/dist/WuiTree-C3yMSmC2.js +0 -1
- package/dist/drawerDiscard-Dl33Ytd2.js +0 -1
- package/dist/httpFailure.g-SkEFc60Y.js +0 -1
- package/dist/themeTransition-DBv2olsl.js +0 -1
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ element classes. Any other helper is imported from the module that owns it.
|
|
|
29
29
|
|
|
30
30
|
## Server entry
|
|
31
31
|
|
|
32
|
-
`@webority/ui-elements/server` carries the server-driven layer for an ASP.NET host: `wuiFetch` and `createRequestQueue` (HTML fragments fetched with the antiforgery token and classified results), server-paged tables, server-loaded modals and drawers, confirm/post/flash actions, the shell parts and the unsaved-changes guard. The Razor script reaches all of it through `window.WeborityUiElements`. The token is read from the meta tag named `wui-csrf` (rendered by the app-csrf-meta tag helper) and sent in the header named by the tag attribute `data-header`; a host that uses another meta name or default header calls `configureCsrf({ metaName, header })` once before the first request.
|
|
32
|
+
`@webority/ui-elements/server` carries the server-driven layer for an ASP.NET host: `wuiFetch` and `createRequestQueue` (HTML fragments fetched with the antiforgery token and classified results), server-paged tables, server-loaded modals and drawers, confirm/post/flash actions, the shell parts and the unsaved-changes guard. The Razor script reaches all of it through `window.WeborityUiElements`. The token is read from the meta tag named `wui-csrf` (rendered by the app-csrf-meta tag helper) and sent in the header named by the tag attribute `data-header`; a host that uses another meta name or default header calls `configureCsrf({ metaName, header })` once before the first request. Use `wuiUpload` for a file upload that needs progress: it sends a POST with XMLHttpRequest, the one request the library makes that way, because fetch cannot report upload progress.
|
|
33
33
|
|
|
34
34
|
Component catalogue: <https://ui-react.webority.dev>
|
|
35
35
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./buttonClass-C8BRtTk8.js";import{n}from"./commentText-NWsssKvj.js";import{t as r}from"./elementBase-Cxeyx0tU.js";import{t as i}from"./hasOwn-CJsplJ62.js";import{a,l as o,s}from"./nativeOverlay-BHD2QV02.js";import{n as c,t as l}from"./rtl-g7G8Bsib.js";import{t as u}from"./serverHtml-BC6tAyAl.js";import{m as d}from"./wuiHttp-Cw7V8u2w.js";import{r as f,t as p}from"./textStore-DBplASiZ.js";import{t as m}from"./commentThread.g-C7L18Tvy.js";import{t as h}from"./httpFailure.g-DjZzGxPj.js";import{r as g}from"./WuiMentionInput-DPpEVL2s.js";var _=`[data-wui-items]`,v=`[data-wui-picker]`,y=`[data-wui-composer]`,b=`[data-wui-comment]`,x=`[data-wui-live]`,S=()=>f(`commentThread`,m),C=e=>({forbidden:S().forbiddenMessage,networkCheck:f(`httpFailure`,h).networkCheckText,client:S().failedClientMessage,validation:S().validationMessage,server:S().failedServerMessage,network:f(`httpFailure`,h).networkText})[e],w=e=>({post:S().donePostText,reply:S().doneReplyText,edit:S().doneEditText,delete:S().doneDeleteText,react:``})[e],T=e=>{let t=typeof e==`object`&&e&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:S().failedServerMessage},E=e=>e instanceof Element?e:null,D=e=>`disabled`in e&&e.disabled===!0,O=(e,t)=>{if(e==null)throw Error(`${t} missing`);return e},k=(e,t,n)=>{let r=e?.querySelector(t);return r instanceof n?r:null},A=(e,t,n)=>{let r=e?.closest(t);return r instanceof n?r:null},j=(e,t,n)=>e?[...e.querySelectorAll(t)].filter(e=>e instanceof n):[],M=class extends r{_wired;_busy;_peopleProp;_pickerFor;_openers;constructor(){super(),this._wired=!1,this._busy=!1,this._peopleProp=null,this._pickerFor=null,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onSubmitKey=this._onSubmitKey.bind(this)}connectedCallback(){if(i(this,`people`)){let e=this.people;Reflect.deleteProperty(this,`people`),this.people=e}if(this._wired)return;this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`wui:mention-input:submit`,this._onSubmitKey),customElements.upgrade(this);let e=k(this,`${y} wui-mention-input`,g);this._handPeople(e),this._applyComposerPlaceholder(e)}disconnectedCallback(){this._closePicker(!1)}get people(){return this._peopleProp?this._peopleProp:j(this,`:scope > [data-wui-people] > wui-option`,HTMLElement).map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0}))}set people(e){this._peopleProp=Array.isArray(e)?e:[];for(let e of this.querySelectorAll(`wui-mention-input`))e.people=this._peopleProp}_handPeople(e){!e||this.hasAttribute(`remote`)||this.hasAttribute(`source`)||(e.people=this.people)}_applyComposerPlaceholder(e){let t=this.getAttribute(`composer-placeholder`);e&&t!=null&&e.setAttribute(`placeholder`,t)}_reactionChoices(){let e=this.getAttribute(`reaction-choices`),t=e?e.split(/\s+/).filter(Boolean):[];return t.length?t:n}_onClick(e){let t=A(E(e.target),`[data-wui-emoji]`,HTMLElement);if(t&&this.contains(t)&&!D(t)){let e=t.closest(v),n=e?this._pickerFor?.comment:t.closest(b);e&&this._closePicker(!0),n&&this._react(n,t.getAttribute(`data-wui-emoji`));return}let n=A(E(e.target),`[data-wui-action]`,HTMLElement);if(!n||!this.contains(n)||D(n))return;let r=n.closest(b);switch(n.getAttribute(`data-wui-action`)){case`reply`:this._openReply(r,n);break;case`edit`:this._openEditor(r,n);break;case`delete`:this._askDelete(r);break;case`cancel-delete`:this._closeConfirm(r,!0);break;case`confirm-delete`:{let e=O(r,`comment`);this._send(`delete`,{commentId:e.getAttribute(`data-wui-comment`)},{comment:e,scope:e});break}case`react-menu`:this._pickerFor?.button===n?this._closePicker(!0):this._openPicker(r,n);break;case`cancel`:this._closeSlot(A(n,`[data-wui-reply], [data-wui-editor]`,HTMLElement),!0);break;case`post`:case`send`:this._sendFrom(n)}}_onKeyDown(e){let t=k(this,v,HTMLElement),n=E(e.target),r=c(e.key,l(this));if(this._pickerFor&&t?.contains(n)){let i=j(t,`[data-wui-emoji]`,HTMLElement),a=n instanceof HTMLElement?i.indexOf(n):-1;e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closePicker(!0)):r===`ArrowRight`||r===`ArrowLeft`?(e.preventDefault(),i[(a+(r===`ArrowRight`?1:-1)+i.length)%i.length]?.focus()):e.key===`Tab`&&this._closePicker(!1);return}if(e.key!==`Escape`)return;let i=A(n,`[data-wui-reply], [data-wui-editor]`,HTMLElement);if(i&&this.contains(i)){e.preventDefault(),e.stopPropagation(),this._closeSlot(i,!0);return}let a=A(n,`[data-wui-comment-confirm]`,HTMLElement);a&&(e.preventDefault(),e.stopPropagation(),this._closeConfirm(a.closest(b),!0))}_onSubmitKey(e){let t=k(A(E(e.target),`[data-wui-reply], [data-wui-editor], [data-wui-composer]`,HTMLElement),`[data-wui-action="send"], [data-wui-action="post"]`,HTMLElement);t&&!D(t)&&this._sendFrom(t)}_openReply(e,t){if(this.hasAttribute(`no-replies`))return;let n=k(e,`:scope > [data-wui-reply]`,HTMLElement);if(!n)return;if(!n.hidden){n.querySelector(`wui-mention-input`)?.focus();return}let r=e?.querySelector(`.wui-comment-author`)?.textContent?.trim()||``;this._fillSlot(n,{label:p(S().replyToText,{author:r}),placeholder:S().replyPlaceholder,value:``,send:S().replyLabel,opener:t})}_openEditor(e,t){let n=k(e,`:scope > .wui-comment-row [data-wui-editor]`,HTMLElement);if(!n?.hidden)return;let r=k(O(n.parentElement,`comment row`),`:scope > [data-wui-text]`,HTMLElement);r&&(r.hidden=!0),this._fillSlot(n,{label:S().editCommentLabel,placeholder:``,value:e?.getAttribute(`data-value`)??``,send:S().saveLabel,opener:t})}_fillSlot(e,{label:t,placeholder:n,value:r,send:i,opener:a}){let o=this.ownerDocument,s=o.createElement(`wui-mention-input`);s.className=`wui-mention-input`,s.setAttribute(`label`,t),n&&s.setAttribute(`placeholder`,n),s.setAttribute(`rows`,`2`),s.setAttribute(`value`,r);for(let e of[`remote`,`source`,`min-chars`,`debounce`]){let t=this.getAttribute(e);t!=null&&s.setAttribute(e,t)}let c=o.createElement(`div`);c.className=`wui-comment-form-actions`,c.append(this._button(`primary`,`solid`,`sm`,`send`,i),this._button(`primary`,`ghost`,`sm`,`cancel`,S().cancelLabel));let l=o.createElement(`div`);l.className=`wui-comment-error`,l.setAttribute(`data-wui-error`,``),l.hidden=!0,e.replaceChildren(s,c,l),this._handPeople(s),e.hidden=!1,this._openers??=/* @__PURE__ */ new WeakMap,this._openers.set(e,a),s.focus();let u=s.querySelector(`textarea`);u?.setSelectionRange(u.value.length,u.value.length)}_button(n,r,i,a,o){let s=this.ownerDocument.createElement(`button`);return s.type=`button`,s.className=e(n,r,i),s.dataset.wui=t,s.setAttribute(`data-wui-action`,a),s.textContent=o,s}_closeSlot(e,t){if(!e||e.hidden)return;if(e.hidden=!0,e.replaceChildren(),e.hasAttribute(`data-wui-editor`)){let t=k(e.parentElement,`:scope > [data-wui-text]`,HTMLElement);t&&(t.hidden=!1)}let n=this._openers?.get(e);t&&n?.isConnected&&n.focus()}_askDelete(e){let t=k(e,`:scope > .wui-comment-row`,HTMLElement),n=k(t,`[data-wui-comment-confirm]`,HTMLElement),r=k(t,`[data-wui-actions]`,HTMLElement);n&&(n.hidden=!1,r&&(r.hidden=!0),k(n,`[data-wui-action="cancel-delete"]`,HTMLElement)?.focus())}_closeConfirm(e,t){let n=k(e,`:scope > .wui-comment-row`,HTMLElement),r=k(n,`[data-wui-comment-confirm]`,HTMLElement),i=k(n,`[data-wui-actions]`,HTMLElement);r&&(r.hidden=!0),i&&(i.hidden=!1),t&&k(i,`[data-wui-action="delete"]`,HTMLElement)?.focus()}_openPicker(e,t){let n=k(this,v,HTMLElement);n&&e&&!this.hasAttribute(`no-reactions`)&&(this._closePicker(!1),this._pickerFor={comment:e,button:t},t.setAttribute(`aria-expanded`,`true`),o(t,n,{mode:`auto`,onClosed:()=>this._pickerClosed()}),k(n,`[data-wui-emoji]`,HTMLElement)?.focus())}_closePicker(e){let t=this._pickerFor;if(!t)return;let n=k(this,v,HTMLElement);n&&a(n),this._pickerClosed(),e&&t.button.isConnected&&t.button.focus()}_pickerClosed(){let e=k(this,v,HTMLElement),t=this._pickerFor;!t||e&&s(e)||(this._pickerFor=null,t.button.setAttribute(`aria-expanded`,`false`))}_react(e,t){t&&!this.hasAttribute(`no-reactions`)&&this._send(`react`,{commentId:e.getAttribute(`data-wui-comment`),emoji:t},{comment:e,scope:e})}_sendFrom(e){let t=A(e,`[data-wui-reply], [data-wui-editor], [data-wui-composer]`,HTMLElement);if(!t)return;let n=t.querySelector(`wui-mention-input`),r=n?.value??``;if(!r.trim()){this._showError(t,S().emptyBodyMessage),n?.focus();return}let i=t.closest(b);t.hasAttribute(`data-wui-composer`)?this._send(`post`,{body:r},{scope:t,form:t}):t.hasAttribute(`data-wui-reply`)?this._send(`reply`,{parentId:O(i,`comment`).getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t}):this._send(`edit`,{commentId:O(i,`comment`).getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t})}async _send(e,t,{comment:n,scope:r,form:i}){if(this._busy)return;this._busy=!0,this.setAttribute(`aria-busy`,`true`);let a=i??k(n,`:scope > .wui-comment-row`,HTMLElement)??this;this._showError(a,null);let o=[...r.querySelectorAll(`button, textarea`)].filter(e=>e instanceof HTMLButtonElement||e instanceof HTMLTextAreaElement).filter(e=>!e.disabled);for(let e of o)e.disabled=!0;let s=await this._persist({intent:e,...t});for(let e of o)e.isConnected&&(e.disabled=!1);this._busy=!1,this.removeAttribute(`aria-busy`);let c=t.commentId??null,l=t.parentId??null;s.ok?(s.html!=null&&this._swapItems(s.html),e===`post`?i?.querySelector(`wui-mention-input`)?.clear():i?.isConnected&&this._closeSlot(i,!1),e===`delete`&&n?.isConnected&&this._closeConfirm(n,!1),this._restoreFocus(e,t,i),w(e)&&this._announce(w(e)),this.dispatchEvent(new CustomEvent(`wui:comment-thread:done`,{bubbles:!0,detail:{intent:e,commentId:c,parentId:l}}))):s.kind!==`session`&&s.kind!==`aborted`&&(this._showError(a.isConnected?a:this,s.message),this._announce(s.message),this.dispatchEvent(new CustomEvent(`wui:comment-thread:failed`,{bubbles:!0,detail:{intent:e,kind:s.kind,message:s.message}})))}async _persist(e){if(this.hasAttribute(`controlled`)){if(typeof this.submit!=`function`)return{ok:!0,html:null};try{return await this.submit(e),{ok:!0,html:null}}catch(e){return{ok:!1,kind:`server`,message:T(e)}}}let t=this.getAttribute(`action`);if(!t)return{ok:!1,kind:`client`,message:S().failedClientMessage};let n=new URLSearchParams;for(let[t,r]of Object.entries(e))r!=null&&n.set(t,r);let r=await d(t,{method:`POST`,body:n});return r.ok?{ok:!0,html:r.html}:{ok:!1,kind:r.kind,message:r.message||C(r.kind)||S().failedServerMessage}}_swapItems(e){let t=k(this,_,HTMLElement);if(!t||!e.trim())return;let n=u(e),r=k(n,_,HTMLElement);t.replaceChildren(...r?r.childNodes:n.childNodes)}_restoreFocus(e,t,n){let r=this.ownerDocument,i=r.activeElement;if(i&&i!==r.body&&i.isConnected&&this.contains(i)&&!D(i))return;let a=e=>e?j(this,b,HTMLElement).find(t=>t.getAttribute(`data-wui-comment`)===e):null,o=e=>k(a(e),`:scope > .wui-comment-row`,HTMLElement),s=null;if(e===`post`)s=n?.querySelector(`textarea`);else if(e===`reply`)s=k(o(t.parentId),`[data-wui-action="reply"]`,HTMLElement);else if(e===`edit`)s=k(o(t.commentId),`[data-wui-action="edit"]`,HTMLElement);else if(e===`react`){let e=o(t.commentId);s=j(e,`button[data-wui-emoji]`,HTMLButtonElement).find(e=>e.getAttribute(`data-wui-emoji`)===t.emoji)??k(e,`[data-wui-action="react-menu"]`,HTMLElement)}s??=k(this,`${y} textarea`,HTMLTextAreaElement),s?.focus()}_showError(e,t){let n=k(e,`:scope > [data-wui-error], :scope > .wui-comment-main > [data-wui-error]`,HTMLElement);n&&(n.textContent=t||``,n.hidden=!t)}_announce(e){let t=k(this,`:scope > ${x}`,HTMLElement);t&&e&&(t.textContent=``,t.textContent=e)}};export{M as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e,n as t,r as n,s as r,t as i,u as a}from"./calendarMath-CT99RyhR.js";import{n as o}from"./devWarn-DXdRWZs3.js";import{r as s,t as c}from"./textStore-DBplASiZ.js";import{t as l}from"./dateRangePicker.g-Pnc37vgX.js";import{n as u,r as d,t as f}from"./zone-BR02ZkHF.js";import{r as p}from"./dom-DMQu--xV.js";import{t as m}from"./elementBase-Cxeyx0tU.js";import{r as h,t as g}from"./fieldState-D-zQcXUS.js";import{_,b as v}from"./formatters-DTW53DjY.js";import{t as y}from"./iconGlyphs.g-a9FtjPXh.js";import{a as b,l as x,s as S}from"./nativeOverlay-BHD2QV02.js";var C=4,w=[`today`,`yesterday`,`last7Days`,`last30Days`,`thisMonth`,`lastMonth`,`thisFinancialYear`],T={today:`todayLabel`,yesterday:`yesterdayLabel`,last7Days:`last7DaysLabel`,last30Days:`last30DaysLabel`,thisMonth:`thisMonthLabel`,lastMonth:`lastMonthLabel`,thisFinancialYear:`thisFinancialYearLabel`},E=e=>String(e).padStart(2,`0`),D=e=>`${e.getUTCFullYear()}-${E(e.getUTCMonth()+1)}-${E(e.getUTCDate())}`;function O(e){return w.includes(e)}function k(e,t=/* @__PURE__ */ new Date,{timeZone:n=f,financialYearStart:i=C}={}){if(!O(e))return null;let a=r(d(n,t));if(!a)throw Error(`today missing`);let{y:o,m:c,d:u}=a,p=(e,t,n)=>D(new Date(Date.UTC(e,t,n))),m=s(`dateRangePicker`,l)[T[e]];switch(e){case`today`:return{label:m,start:p(o,c,u),end:p(o,c,u)};case`yesterday`:return{label:m,start:p(o,c,u-1),end:p(o,c,u-1)};case`last7Days`:return{label:m,start:p(o,c,u-6),end:p(o,c,u)};case`last30Days`:return{label:m,start:p(o,c,u-29),end:p(o,c,u)};case`thisMonth`:return{label:m,start:p(o,c,1),end:p(o,c+1,0)};case`lastMonth`:return{label:m,start:p(o,c-1,1),end:p(o,c,0)};case`thisFinancialYear`:{let e=i-1,t=c>=e?o:o-1;return{label:m,start:p(t,e,1),end:p(t+1,e,0)}}default:return null}}function A(e){o(`[@webority/ui-elements] <wui-date-range> presets: ${e}`)}function j(e){return typeof e==`object`&&!!e}function M(e,t=/* @__PURE__ */ new Date,n={}){let i=String(e??``).trim();if(!i)return[];let a;if(i.startsWith(`[`))try{a=JSON.parse(i)}catch{return A(`the attribute is not valid JSON`),[]}else a=i.split(`,`).map(e=>e.trim());let o=[];for(let e of a)if(typeof e==`string`){let r=k(e,t,n);r?o.push(r):A(`"${e}" is not one of ${w.join(`, `)}`)}else j(e)&&typeof e.label==`string`&&e.label&&typeof e.start==`string`&&typeof e.end==`string`&&r(e.start)&&r(e.end)?o.push({label:e.label,start:e.start,end:e.end}):A(`an item needs a label and ISO start and end dates, or a preset name`);return o}var N=()=>s(`dateRangePicker`,l);function P(e){if(!(e.target instanceof Element))throw Error(`Expected the event target to be an element.`);return e.target}function F(e,t){return[...e.querySelectorAll(t)].map(e=>{if(!(e instanceof HTMLElement))throw Error(`Expected every "${t}" to be an HTML element.`);return e})}var I=class extends m{static formAssociated=!0;_internals;_start;_end;_hover;_viewY;_viewM;get open(){return this.querySelector(`.daterange`)?.classList.contains(`open`)??!1}set open(e){e?!g(this)&&!this.open&&this._open?.():this.open&&this._close?.()}static get observedAttributes(){return[`start`,`end`,`min`,`max`,`placeholder`,`disabled`,`readonly`,`loading`,`first-day`,`size`,`aria-label`,`aria-describedby`,`name`,`start-name`,`end-name`,`presets`,`time-zone`,`financial-year-start`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._start=``,this._end=``,this._hover=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth()}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){this._dropPanel()}attributeChangedCallback(e,t,n){e===`aria-invalid`?this._syncInvalid():this._rendered&&(e===`start`||e===`end`?(this._start=this.getAttribute(`start`)||``,this._end=this.getAttribute(`end`)||``,this._syncTrigger(),this._syncMirrors()):this.render())}_syncInvalid(){let e=this.querySelector(`.daterange-trigger`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get value(){return{start:this._start,end:this._end}}set value(e){this._start=e?.start||``,this._end=e?.end||``,this._syncTrigger(),this._syncMirrors()}_firstDay(){return n(this)}_label(){let t=this.getAttribute(`placeholder`)||N().placeholder;return!this._start&&!this._end?{text:t,empty:!0}:{text:c(N().rangeText,{start:e(this._start)||N().startLabel,end:e(this._end)||N().endLabel}),empty:!1}}render(){this._dropPanel(),this._defaultStart===void 0&&(this._defaultStart=this.getAttribute(`start`)||``,this._defaultEnd=this.getAttribute(`end`)||``,this._start=this._defaultStart||this._start,this._end=this._defaultEnd||this._end);let e=r(this._start);e&&(this._viewY=e.y,this._viewM=e.m);let t=this.getAttribute(`size`),n=t===`sm`?` wui-input-sm`:t===`lg`?` wui-input-lg`:t===`xl`?` wui-input-xl`:``,{text:i,empty:a}=this._label(),o=this.getAttribute(`aria-label`),s=this.getAttribute(`aria-describedby`),c=p(`button`,{type:`button`,class:`input daterange-trigger${n}${a?``:` has-value`}`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-invalid":this.hasAttribute(`aria-invalid`)?`true`:null,disabled:this.hasAttribute(`disabled`),"aria-label":o||null,"aria-describedby":s||null},p(`span`,{"data-range-label":!0,class:a?`wui-select-placeholder`:``},i),y(`calendar`));this.replaceChildren(p(`div`,{class:`daterange`},c,p(`div`,{class:`daterange-pop`,role:`dialog`,popover:`auto`}))),h(this,this.querySelector(`.daterange-trigger`)),this._rendered=!0,this._syncMirrors(),this._wire()}formResetCallback(){this.value={start:this._defaultStart||``,end:this._defaultEnd||``}}_syncTrigger(){let e=this.querySelector(`.daterange-trigger`),t=this.querySelector(`[data-range-label]`);if(!t)return;let{text:n,empty:r}=this._label();t.textContent=n,t.classList.toggle(`wui-select-placeholder`,r),e?.classList.toggle(`has-value`,!r)}_syncMirrors(){let e=this.getAttribute(`start-name`),t=this.getAttribute(`end-name`);this._mirror(`start`,e,this._start),this._mirror(`end`,t,this._end)}_mirror(e,t,n){if(!t)return;let r=this.querySelector(`input[type="hidden"][data-range-mirror="${e}"]`),i;r instanceof HTMLInputElement?i=r:(i=document.createElement(`input`),i.type=`hidden`,i.setAttribute(`data-range-mirror`,e),this.appendChild(i)),i.name=t,i.value=n||``,i.disabled=this.hasAttribute(`disabled`)}_limits(){let e=r(this.getAttribute(`min`)),t=r(this.getAttribute(`max`)),n=e?new Date(e.y,e.m,e.d).getTime():-1/0,i=t?new Date(t.y,t.m,t.d).getTime():1/0;return(e,t,r)=>{let a=new Date(e,t,r).getTime();return a<n||a>i}}_monthHtml(e,n){let r=this._firstDay(),o=(new Date(e,n,1).getDay()-r+7)%7,s=t(e,n),c=this._limits(),l=Array.from({length:7},(e,t)=>p(`span`,null,v((t+r)%7,`min`))),u=(e,t,n,r)=>{let i=a(e,t,n),o=c(e,t,n),s=[`datepicker-day`,r?`is-outside`:``].filter(Boolean).join(` `);return p(`button`,{type:`button`,class:s,"data-iso":i,disabled:o},n)},d=[],f=i(e,n-1),m=t(f.y,f.m);for(let e=o-1;e>=0;e--)d.push(u(f.y,f.m,m-e,!0));for(let t=1;t<=s;t++)d.push(u(e,n,t,!1));let h=i(e,n+1),g=(7-(o+s)%7)%7;for(let e=1;e<=g;e++)d.push(u(h.y,h.m,e,!0));return p(`div`,{class:`daterange-cal`},p(`div`,{class:`datepicker-month-label`},`${_(n)} ${e}`),p(`div`,{class:`datepicker-weekdays`},...l),p(`div`,{class:`datepicker-grid`,role:`grid`},...d))}_presetOptions(){let e=this.getAttribute(`time-zone`),t=f;e!==null&&(u(e)?t=e:o(`[@webority/ui-elements] <wui-date-range> time-zone="${e}" is not a time zone this browser knows; India Standard Time is used.`));let n=this.getAttribute(`financial-year-start`),r=4;if(n!==null){let e=Number(n);Number.isInteger(e)&&e>=1&&e<=12?r=e:o(`[@webority/ui-elements] <wui-date-range> financial-year-start="${n}" must be a month number from 1 to 12; April (4) is used.`)}return{timeZone:t,financialYearStart:r}}_presetsHtml(){if(!this._presetList?.length)return null;let e=this._limits(),t=t=>{let n=r(t);if(!n)throw Error(`Expected a preset date, found "${t}".`);return e(n.y,n.m,n.d)},n=this._presetList.map((e,n)=>p(`button`,{type:`button`,class:`wui-daterange-preset`,"data-preset":n,disabled:t(e.start)||t(e.end)},e.label));return p(`div`,{class:`wui-daterange-presets`,role:`group`,"aria-label":N().quickRangesLabel},...n)}_renderView(){let e=this.querySelector(`.daterange-pop`);if(!e)return;let t=i(this._viewY,this._viewM+1),n=this._presetsHtml(),r=[p(`div`,{class:`daterange-head`},p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":-1,"aria-label":N().previousMonthLabel},y(`chevron-left`)),p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":1,"aria-label":N().nextMonthLabel},y(`chevron-right`))),p(`div`,{class:`daterange-cals`},this._monthHtml(this._viewY,this._viewM),this._monthHtml(t.y,t.m)),p(`div`,{class:`datepicker-foot`},p(`span`,{class:`daterange-hint`,"data-range-hint":!0}),p(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},N().clearLabel))];e.classList.toggle(`wui-daterange-pop--presets`,n!==null),e.replaceChildren(...n?[n,p(`div`,{class:`wui-daterange-main`},...r)]:r),this._paint()}_paint(){let t=this.querySelector(`.daterange-pop`);if(!t)return;let n=this._start?new Date(this._start).getTime():null,r=this._end;n&&!this._end&&this._hover&&new Date(this._hover).getTime()>=n&&(r=this._hover);let i=r?new Date(r).getTime():null;for(let e of F(t,`.datepicker-day[data-iso]`)){let t=new Date(e.dataset.iso??``).getTime(),r=n!=null&&t===n,a=i!=null&&t===i,o=n!=null&&i!=null&&t>n&&t<i;e.classList.toggle(`is-range-start`,r),e.classList.toggle(`is-range-end`,a),e.classList.toggle(`in-range`,o)}F(t,`[data-preset]`).forEach(e=>{let t=this._presetList?.[Number(e.dataset.preset)],n=!!t&&t.start===this._start&&t.end===this._end;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-pressed`,String(n))});let a=t.querySelector(`[data-range-hint]`);a&&(a.textContent=this._start?this._end?c(N().rangeText,{start:e(this._start),end:e(this._end)}):N().pickEndDateLabel:N().pickStartDateLabel)}_pick(e){!this._start||this._start&&this._end?(this._start=e,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._paint()):new Date(e).getTime()<new Date(this._start).getTime()?(this._start=e,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))):(this._end=e,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}_applyPreset({start:e,end:t}){this._start=e,this._end=t,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close()}_dropPanel(){let e=this.querySelector(`.daterange-pop`);e instanceof HTMLDivElement&&b(e)}_wire(){let e=this.querySelector(`.daterange-trigger`),t=this.querySelector(`.daterange-pop`),n=this.querySelector(`.daterange`);if(!(e instanceof HTMLButtonElement)||!(t instanceof HTMLDivElement))return;let a=()=>S(t),o=()=>{this._hover=``,n?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),this.dispatchEvent(new CustomEvent(`wui-date-range:openchange`,{bubbles:!0,detail:{open:!1}}))};this._open=()=>{let i=r(this._start);if(i)this._viewY=i.y,this._viewM=i.m;else{let e=/* @__PURE__ */ new Date;this._viewY=e.getFullYear(),this._viewM=e.getMonth()}this._presetList=M(this.getAttribute(`presets`),/* @__PURE__ */ new Date,this._presetOptions()),this._renderView(),x(e,t,{mode:`auto`,clampHeight:!0,onClosed:o}),a()&&(n?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`),this.dispatchEvent(new CustomEvent(`wui-date-range:openchange`,{bubbles:!0,detail:{open:!0}})))},this._close=()=>{b(t)},e.addEventListener(`click`,()=>{a()?this._close():g(this)||this._open()}),t.addEventListener(`click`,e=>{let t=P(e),n=t.closest(`[data-nav]`);if(n instanceof HTMLElement){let e=i(this._viewY,this._viewM+Number(n.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._renderView();return}if(t.closest(`[data-clear]`)){this._start=``,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._renderView(),this.dispatchEvent(new Event(`change`,{bubbles:!0}));return}let r=t.closest(`[data-preset]`);if(r instanceof HTMLButtonElement&&!r.disabled){let e=this._presetList?.[Number(r.dataset.preset)];e&&this._applyPreset(e);return}let a=t.closest(`.datepicker-day[data-iso]`);if(a instanceof HTMLButtonElement&&!a.disabled){let e=a.dataset.iso;e!==void 0&&this._pick(e)}}),t.addEventListener(`mouseover`,e=>{let t=P(e).closest(`.datepicker-day[data-iso]`),n=t instanceof HTMLButtonElement?t.dataset.iso:void 0;n!==void 0&&this._start&&!this._end&&(this._hover=n,this._paint())}),this._syncMirrors()}};export{I as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./calendarMath-CT99RyhR.js";import{n as t,r as n,t as r}from"./digitGrouping-CCPI3HK3.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{o as a}from"./formatters-DTW53DjY.js";import{n as o}from"./imeSafeEnter-DeO_3lXy.js";import{n as s,t as c}from"./inlineEditText-DRBhMnam.js";import{
|
|
1
|
+
import{i as e}from"./calendarMath-CT99RyhR.js";import{n as t,r as n,t as r}from"./digitGrouping-CCPI3HK3.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{o as a}from"./formatters-DTW53DjY.js";import{n as o}from"./imeSafeEnter-DeO_3lXy.js";import{n as s,t as c}from"./inlineEditText-DRBhMnam.js";import{m as l}from"./wuiHttp-Cw7V8u2w.js";import{r as u,t as d}from"./textStore-DBplASiZ.js";import{t as f}from"./httpFailure.g-DjZzGxPj.js";import{t as p}from"./inlineEdit.g-ZxRNYq0t.js";var m=()=>u(`inlineEdit`,p),h=e=>s.some(t=>t===e),g=`[data-wui-display]`,_=`[data-wui-value]`,v=`[data-wui-editor]`,y=`[data-wui-control]`,b=`[data-wui-error]`,x=`[data-wui-live]`,S=`[aria-expanded="true"]`,C=/* @__PURE__ */ new Set([`select`,`date`]),w=e=>{let t=(typeof e==`object`||typeof e==`function`)&&e!==null&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:m().serverMessage},T=e=>e instanceof HTMLElement&&typeof(`value`in e?e.value:void 0)==`string`,E=(e,t)=>{let n=e?.querySelector(t)??null;return n instanceof HTMLElement?n:null},D=class extends i{_wired;_editing;_busy;_draft;_pressed;_popupOpen;_savedTimer;static get observedAttributes(){return[`disabled`]}constructor(){super(),this._wired=!1,this._editing=!1,this._busy=!1,this._draft=null,this._pressed=!1,this._popupOpen=!1,this._savedTimer=null,this._onClick=this._onClick.bind(this),this._onKeyCapture=this._onKeyCapture.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onChange=this._onChange.bind(this)}connectedCallback(){this._wired||(this._wired=!0,this._grouping(),this.addEventListener(`click`,this._onClick),this.addEventListener(`auxclick`,this._onClick),this.addEventListener(`keydown`,this._onKeyCapture,!0),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`change`,this._onChange))}disconnectedCallback(){clearTimeout(this._savedTimer??void 0),this._savedTimer=null,this._releasePress()}attributeChangedCallback(e){e===`disabled`&&this.hasAttribute(`disabled`)&&this.cancel()}edit(){if(this._editing||this._busy||this.hasAttribute(`disabled`))return;let e=E(this,g),t=E(this,v),n=this._control();e&&t&&n&&(this._editing=!0,this._setState(null),n.value=this._draft??this._value(),t.hidden=!1,this.setAttribute(`data-wui-editing`,``),this._focusControl(n),e.hidden=!0)}cancel(){this._editing&&(this._draft=null,this._setError(null),this.getAttribute(`data-wui-state`)===`error`&&this._setState(null),this._close())}_onClick(e){e.stopPropagation();let t=e.target instanceof Node?e.target:null;e.type===`click`&&!this._editing&&this.querySelector(g)?.contains(t)&&this.edit()}_onKeyCapture(){this._popupOpen=!!(this._editing&&this.querySelector(v)?.querySelector(S))}_onKeyDown(e){if(!this._editing){(o(e)||e.key===` `)&&e.stopPropagation();return}if(e.stopPropagation(),this._popupOpen)return;if(e.key===`Escape`){e.preventDefault(),this.cancel();return}let t=this._type();e.key!==`Enter`||C.has(t)||(t!==`textarea`||e.ctrlKey||e.metaKey)&&(e.preventDefault(),this._commit(this._control()?.value??``))}_onFocusOut(e){if(!this._editing||this._pressed)return;let t=e.relatedTarget instanceof Node?e.relatedTarget:null;t&&this.contains(t)||document.hasFocus()&&this._commit(this._control()?.value??``)}_onPointerDown(){this._editing&&(this._pressed=!0,document.addEventListener(`pointerup`,this._onPointerUp,!0),document.addEventListener(`pointercancel`,this._onPointerUp,!0))}_onPointerUp(){this._releasePress(),setTimeout(()=>{this._pressed=!1,this._editing&&!this.contains(document.activeElement)&&document.hasFocus()&&this._commit(this._control()?.value??``)},0)}_releasePress(){document.removeEventListener(`pointerup`,this._onPointerUp,!0),document.removeEventListener(`pointercancel`,this._onPointerUp,!0)}_onChange(e){if(!this._editing||!C.has(this._type()))return;let t=this._control();t&&e.target===t&&queueMicrotask(()=>this._commit(t.value))}async _commit(e){if(!this._editing||this._busy)return;let t=this._value();if(e===t){this.cancel();return}let n=typeof this.validate==`function`?this.validate(e):null;if(n){this._setError(n),this._announce(n);return}let r=this.hasAttribute(`controlled`);this._draft=null,this._setError(null),this._busy=!0,this._setState(`saving`),this.setAttribute(`aria-busy`,`true`);let i=r?null:this._readShown();r||this._showValue(e),this._close();let a=await this._persist(e,r);this._busy=!1,this.removeAttribute(`aria-busy`);let o=this.getAttribute(`label`)||``;a.ok?(this.setAttribute(`value`,e),!r&&a.text&&this._showText(a.text,!1),this._setState(`saved`),this._savedTimer=setTimeout(()=>this._setState(null),c),this._announce(d(m().savedText,{label:o})),this._fire(`wui:inline-edit:saved`,{value:e,previous:t})):(i&&this._restoreShown(i),a.kind===`session`||a.kind===`aborted`?this._setState(null):(this._draft=e,this._setState(`error`),this._setError(a.message),this._announce(d(m().notSavedText,{label:o,reason:a.message})),this._fire(`wui:inline-edit:failed`,{value:e,previous:t,kind:a.kind,message:a.message})))}async _persist(e,t){if(t){if(typeof this.save!=`function`)return{ok:!0};try{return await this.save(e),{ok:!0}}catch(e){return{ok:!1,kind:`server`,message:w(e)}}}let n=this.getAttribute(`action`);if(!n)return{ok:!0};let r=new URLSearchParams({[this.getAttribute(`name`)||`value`]:e}),i=await l(n,{method:`POST`,body:r});if(i.ok)return{ok:!0,text:i.html.trim()};let a={forbidden:m().forbiddenMessage,networkCheck:u(`httpFailure`,f).networkCheckText,client:m().clientMessage,validation:m().validationMessage,server:m().serverMessage,network:m().networkMessage};return{ok:!1,kind:i.kind,message:i.message||a[i.kind]||m().serverMessage}}_close(){let e=E(this,g),t=E(this,v),n=this.contains(document.activeElement);this._editing=!1,this.removeAttribute(`data-wui-editing`),t&&(t.hidden=!0),e&&(e.hidden=!1),E(t,S)?.click(),n&&e?.focus()}_focusControl(e){if(!C.has(this._type())){e.focus(),e.select?.();return}let t=E(e,`button`);t&&(t.focus(),t.getAttribute(`aria-expanded`)!==`true`&&t.click())}_showValue(t){if(t===``){this._showText(this.getAttribute(`placeholder`)||a(),!0);return}let n=this._type(),i=t;if(n===`date`)i=e(t)||t;else if(n===`select`){let e=[...this._control()?.querySelectorAll(`[data-value]`)??[]].find(e=>e.getAttribute(`data-value`)===t);e&&(i=(e.textContent??``).trim())}else n===`number`&&this._grouping()===`indian`&&(i=r(t));this._showText(i,!1)}_readShown(){let e=this.querySelector(_);return e?{nodes:[...e.childNodes].map(e=>e.cloneNode(!0)),empty:e.hasAttribute(`data-wui-empty`)}:null}_restoreShown(e){let t=this.querySelector(_);t&&(t.replaceChildren(...e.nodes),t.toggleAttribute(`data-wui-empty`,e.empty))}_showText(e,t){let n=this.querySelector(_);n&&(n.textContent=e,n.toggleAttribute(`data-wui-empty`,t))}_setError(e){let t=E(this,b),n=this._control();t&&(t.textContent=e||``,t.hidden=!e),e?n?.setAttribute(`aria-invalid`,`true`):n?.removeAttribute(`aria-invalid`)}_setState(e){clearTimeout(this._savedTimer??void 0),this._savedTimer=null,e?this.setAttribute(`data-wui-state`,e):this.removeAttribute(`data-wui-state`)}_announce(e){let t=this.querySelector(x);t&&e&&(t.textContent=``,t.textContent=e)}_fire(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))}_control(){let e=this.querySelector(y);return T(e)?e:null}_value(){return this.getAttribute(`value`)??``}_type(){let e=this.getAttribute(`type`);return h(e)?e:`text`}_grouping(){let e=this.getAttribute(`grouping`)??`none`;if(!n(e))throw Error(t(e));return e}};export{D as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{r as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";var n=/\[([^[\]\n]+)\](?!\()/g,r=/* @__PURE__ */ new Set(`!"#$%&'()*+,-./:;<=>?@[\\]^_\`{|}~`),i=/\[([^\]\n]+)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/y,a=/!\[([^\]\n]*)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/y,o=new RegExp(n.source,`y`),s=e=>/[\p{L}\p{N}]/u.test(e);function c(e,t){let n=0;for(let r=t-1;r>=0&&e.charAt(r)===`\\`;--r)n+=1;return n%2==1}function l(e,t,n){let r=n.length===1;for(let i=e.indexOf(n,t);i!==-1;i=e.indexOf(n,i+1)){let a=i>t&&!/\s/.test(e.charAt(t))&&!/\s/.test(e.charAt(i-1)),o=r&&(e.charAt(i+1)===n||e.charAt(i-1)===n),l=n===`_`&&s(e.charAt(i+n.length));if(a&&!o&&!l&&!c(e,i))return i}return-1}function u(e,t){let n=t?.isCitation,c=[],d=``,f=()=>{d&&=(c.push({type:`text`,text:d}),``)},p=0;for(;p<e.length;){let m=e.charAt(p),h=e.charAt(p+1);if(m===`\\`&&r.has(h)){d+=h,p+=2;continue}if(m==="`"){let t=e.indexOf("`",p+1);if(t>p+1){f(),c.push({type:`code`,text:e.slice(p+1,t)}),p=t+1;continue}}let g=m+h;if(g===`**`||g===`__`||g===`~~`){let n=l(e,p+2,g);if(n!==-1&&!(g===`__`&&s(e.charAt(p-1)))){f();let r=u(e.slice(p+2,n),t);g===`~~`?c.push({type:`strike`,children:r}):c.push({type:`strong`,children:r}),p=n+2;continue}d+=g,p+=2}else{if(m===`*`||m===`_`){let n=l(e,p+1,m);if(n!==-1&&!(m===`_`&&s(e.charAt(p-1)))){f(),c.push({type:`em`,children:u(e.slice(p+1,n),t)}),p=n+1;continue}}if(m===`[`){i.lastIndex=p;let t=i.exec(e);if(t){let e=t[1],n=t[2];if(e===void 0||n===void 0)throw Error(`The link pattern always captures its label and href`);f(),c.push({type:`link`,href:n,children:u(e)}),p+=t[0].length;continue}if(n){o.lastIndex=p;let t=o.exec(e);if(t){let e=t[1];if(e===void 0)throw Error(`The citation pattern always captures its inner text`);if(n(e)){f(),c.push({type:`citation`,text:e}),p+=t[0].length;continue}}}}if(m===`!`){a.lastIndex=p;let t=a.exec(e);if(t){let e=t[1];if(e===void 0)throw Error(`The image pattern always captures its alt text`);f(),c.push({type:`image`,children:u(e)}),p+=t[0].length;continue}}d+=m,p+=1}}return f(),c.map((e,t)=>({...e,key:t}))}var d=/^[a-z][a-z0-9+.-]*:[a-z0-9_-]+\/[a-z0-9_.~-]+$/i,f=/^https?:/i,p=/^(mailto|tel):/i,m=/^(?:\/(?![/\\])|#|\?|\.{1,2}\/)/,h=/^https:\/\/[^/?#@\\\s]+$/i,g=/^[a-z][a-z0-9+.-]*:/i;function _(e){if(typeof e!=`string`)return null;let t=e.endsWith(`/`)?e.slice(0,-1):e;return h.test(t)?t:null}function v(e,t,n,r,i){if(n&&(t===`page`||d.test(e))){let t=n(e);if(t!=null)return{kind:`app`,target:t}}if(t===`app`)return null;let a=i==null?null:_(i),o=a===null?e:y(e,a);return o===null?null:m.test(o)?{kind:`page`,href:o}:t===`page`&&!(f.test(o)&&r&&b(o,r))?null:f.test(o)?{kind:r&&b(o,r)?`page`:`web`,href:o}:p.test(o)?{kind:`contact`,href:o}:null}function y(e,t){if(g.test(e))return e;if(e.startsWith(`//`))return`https:${e}`;if(e===``)return null;let n=e.indexOf(`#`),r=n<0?``:e.slice(n),i=n<0?e:e.slice(0,n),a=i.indexOf(`?`),o=a<0?i:i.slice(0,a),s=a<0?``:i.slice(a);return o===``?`${t}${s}${r}`:`${t}${ee(o.startsWith(`/`)?o:`/${o}`)}${s}${r}`}function ee(e){let t=e.split(`/`),n=[];return t.forEach((e,r)=>{let i=r===t.length-1;e===`.`?i&&n.push(``):e===`..`?(n.length>1&&n.pop(),i&&n.push(``)):n.push(e)}),n.join(`/`)}function b(e,t){if(e.slice(0,t.length).toLowerCase()!==t.toLowerCase())return!1;let n=e[t.length];return n===void 0||n===`/`||n===`?`||n===`#`}function x(e){return typeof e!=`string`||!e.startsWith(`/`)||e[1]===`/`||e[1]===`\\`?null:e}var S=/^\s*```/,C=/^\s*```\s*(\S*)/,w=/^\s{0,3}(#{1,6})\s+(.*?)(?:\s+#+)?\s*$/,T=/^\s*([-*_])(\s*\1){2,}\s*$/,E=/^(\s*)[-*+]\s+(.*)$/,D=/^(\s*)(\d{1,9})[.)]\s+(.*)$/,O=/^\s*>\s?(.*)$/,te=/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)*\|?\s*$/,ne=[1,2,3,4,5,6],k=e=>e.includes(`|`);function A(e){let t=e.trim();return t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&(t=t.slice(0,-1)),t.split(`|`).map(e=>e.trim())}function j(e,t){let n=e[t];if(n===void 0)throw Error(`startsTable was called past the last source line`);let r=e[t+1];return r!==void 0&&k(n)&&r.includes(`|`)&&te.test(r)}function M(e,t){let n=e[t];if(n===void 0)throw Error(`startsBlock was called past the last source line`);return S.test(n)||O.test(n)||E.test(n)||D.test(n)||w.test(n)||T.test(n)||j(e,t)}function N(e){let t=e.replace(/\t/g,` `).length;return Math.min(Math.floor(t/2),4)}function P(e){let t=D.exec(e);if(t){let e=t[1],n=t[2],r=t[3];if(e===void 0||n===void 0||r===void 0)throw Error(`The ordered list pattern always captures its indent, number and text`);return{text:r,depth:N(e),ordered:!0,number:Number(n)}}let n=E.exec(e);if(n){let e=n[1],t=n[2];if(e===void 0||t===void 0)throw Error(`The bullet list pattern always captures its indent and text`);return{text:t,depth:N(e),ordered:!1,number:0}}return null}function F(e){let t=(e??``).replace(/\r\n?/g,`
|
|
2
2
|
`).split(`
|
|
3
3
|
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()){r+=1;continue}if(S.test(e)){let i=C.exec(e)?.[1]||null,a=[];for(r+=1;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(S.test(e))break;a.push(e),r+=1}r+=1,n.push({type:`code`,text:a.join(`
|
|
4
|
-
`),language:i});continue}if(j(t,r)){let i=A(e),a=[];for(r+=2;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()||!k(e))break;a.push(A(e)),r+=1}n.push({type:`table`,header:i,rows:a});continue}if(T.test(e)){n.push({type:`rule`}),r+=1;continue}let i=w.exec(e);if(i){let e=i[1],t=i[2];if(e===void 0||t===void 0)throw Error(`The heading pattern always captures its hashes and text`);let a=ne[e.length-1];if(a===void 0)throw Error(`The heading pattern always captures one to six hashes`);n.push({type:`heading`,level:a,text:t}),r+=1;continue}if(O.test(e)){let e=[];for(;r<t.length;){let n=t[r];if(n===void 0)throw Error(`parseMarkdown read past the last source line`);let i=O.exec(n);if(!i)break;let a=i[1];if(a===void 0)throw Error(`The quote pattern always captures its text`);e.push(a),r+=1}n.push({type:`quote`,lines:e});continue}let a=P(e);if(a){let e=[];for(;r<t.length;){let n=t[r];if(n===void 0)throw Error(`parseMarkdown read past the last source line`);if(!n.trim())break;let i=P(n);if(i){if(i.depth===0&&i.ordered!==a.ordered)break;e.push(i)}else if(M(t,r))break;else{let t=e[e.length-1];if(t===void 0)throw Error(`A list continuation line follows a list with no item`);t.text+=` ${n.trim()}`}r+=1}n.push({type:`list`,ordered:a.ordered,start:a.ordered?a.number:1,items:e});continue}let o=[e];for(r+=1;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()||M(t,r))break;o.push(e),r+=1}n.push({type:`paragraph`,lines:o})}return n.map((e,t)=>({...e,key:t}))}var I=[`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`razor`,`css`],L=[`razor`,`cshtml`],R=[`app`,`web`,`page`],z=e=>e!==void 0&&R.includes(e);function B(e,t,n,r,i=null){let a=V(n,r).map((e,n)=>{let r=t[n],i=r?.sig===e.sig?r.nodes:null;return{sig:e.sig,nodes:i??e.build()}}),o=new Set(a.flatMap(e=>e.nodes));for(let e of t)for(let t of e.nodes)o.has(t)||t.parentNode?.removeChild(t);let s=i;for(let t of a.flatMap(e=>e.nodes))(t.parentNode!==e||t.previousSibling!==s)&&e.insertBefore(t,s?s.nextSibling:e.firstChild),s=t;return a}function V(e,t){let n={links:z(t.links)?t.links:`web`,headings:t.headings===`text`?`text`:`outline`,resolveLink:t.resolveLink,isCitation:t.isCitation,figureText:typeof t.figureText==`function`?t.figureText:void 0,base:typeof t.base==`string`?t.base:void 0},r=t.resolverGeneration??0;return F(e).map(e=>({sig:`${JSON.stringify(e)}|${n.links}|${n.headings}|${n.base??``}|${r}`,build:()=>U(n,e)}))}var H=class extends t{_drawn;_blocks;_observer;_connected;_resolveLink;_isCitation;_resolverGeneration;_figureText;static get observedAttributes(){return[`links`,`headings`,`base`]}constructor(){super(),this._drawn=[],this._blocks=[],this._observer=null,this._connected=!1,this._resolveLink=void 0,this._isCitation=void 0,this._resolverGeneration=0,this._figureText=void 0}connectedCallback(){this._connected=!0,this._render(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._drawn.some(t=>t.contains(e.target)))&&this._render()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._connected=!1,this._observer?.disconnect(),this._observer=null}get resolveLink(){return this._resolveLink}set resolveLink(e){this._resolveLink=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}get base(){return this.getAttribute(`base`)??void 0}set base(e){e==null?this.removeAttribute(`base`):this.setAttribute(`base`,String(e))}get isCitation(){return this._isCitation}set isCitation(e){this._isCitation=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}get figureText(){return this._figureText}set figureText(e){this._figureText=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}attributeChangedCallback(e,t,n){t!==n&&this._connected&&this._render()}_source(){return Array.from(this.children).find(e=>e
|
|
4
|
+
`),language:i});continue}if(j(t,r)){let i=A(e),a=[];for(r+=2;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()||!k(e))break;a.push(A(e)),r+=1}n.push({type:`table`,header:i,rows:a});continue}if(T.test(e)){n.push({type:`rule`}),r+=1;continue}let i=w.exec(e);if(i){let e=i[1],t=i[2];if(e===void 0||t===void 0)throw Error(`The heading pattern always captures its hashes and text`);let a=ne[e.length-1];if(a===void 0)throw Error(`The heading pattern always captures one to six hashes`);n.push({type:`heading`,level:a,text:t}),r+=1;continue}if(O.test(e)){let e=[];for(;r<t.length;){let n=t[r];if(n===void 0)throw Error(`parseMarkdown read past the last source line`);let i=O.exec(n);if(!i)break;let a=i[1];if(a===void 0)throw Error(`The quote pattern always captures its text`);e.push(a),r+=1}n.push({type:`quote`,lines:e});continue}let a=P(e);if(a){let e=[];for(;r<t.length;){let n=t[r];if(n===void 0)throw Error(`parseMarkdown read past the last source line`);if(!n.trim())break;let i=P(n);if(i){if(i.depth===0&&i.ordered!==a.ordered)break;e.push(i)}else if(M(t,r))break;else{let t=e[e.length-1];if(t===void 0)throw Error(`A list continuation line follows a list with no item`);t.text+=` ${n.trim()}`}r+=1}n.push({type:`list`,ordered:a.ordered,start:a.ordered?a.number:1,items:e});continue}let o=[e];for(r+=1;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()||M(t,r))break;o.push(e),r+=1}n.push({type:`paragraph`,lines:o})}return n.map((e,t)=>({...e,key:t}))}var I=[`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`razor`,`css`],L=[`razor`,`cshtml`],R=[`app`,`web`,`page`],z=e=>e!==void 0&&R.includes(e);function B(e,t,n,r,i=null){let a=V(n,r).map((e,n)=>{let r=t[n],i=r?.sig===e.sig?r.nodes:null;return{sig:e.sig,nodes:i??e.build()}}),o=new Set(a.flatMap(e=>e.nodes));for(let e of t)for(let t of e.nodes)o.has(t)||t.parentNode?.removeChild(t);let s=i;for(let t of a.flatMap(e=>e.nodes))(t.parentNode!==e||t.previousSibling!==s)&&e.insertBefore(t,s?s.nextSibling:e.firstChild),s=t;return a}function V(e,t){let n={links:z(t.links)?t.links:`web`,headings:t.headings===`text`?`text`:`outline`,resolveLink:t.resolveLink,isCitation:t.isCitation,figureText:typeof t.figureText==`function`?t.figureText:void 0,base:typeof t.base==`string`?t.base:void 0},r=t.resolverGeneration??0;return F(e).map(e=>({sig:`${JSON.stringify(e)}|${n.links}|${n.headings}|${n.base??``}|${r}`,build:()=>U(n,e)}))}var H=class extends t{_drawn;_blocks;_observer;_connected;_resolveLink;_isCitation;_resolverGeneration;_figureText;static get observedAttributes(){return[`links`,`headings`,`base`]}constructor(){super(),this._drawn=[],this._blocks=[],this._observer=null,this._connected=!1,this._resolveLink=void 0,this._isCitation=void 0,this._resolverGeneration=0,this._figureText=void 0}connectedCallback(){this._connected=!0,this._render(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._drawn.some(t=>t.contains(e.target)))&&this._render()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._connected=!1,this._observer?.disconnect(),this._observer=null}get resolveLink(){return this._resolveLink}set resolveLink(e){this._resolveLink=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}get base(){return this.getAttribute(`base`)??void 0}set base(e){e==null?this.removeAttribute(`base`):this.setAttribute(`base`,String(e))}get isCitation(){return this._isCitation}set isCitation(e){this._isCitation=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}get figureText(){return this._figureText}set figureText(e){this._figureText=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}attributeChangedCallback(e,t,n){t!==n&&this._connected&&this._render()}_source(){return Array.from(this.children).find(e=>e.tagName===`PRE`&&e.classList.contains(`wui-markdown-source`))}_render(){let e=this._source();e&&(this._blocks=B(this,this._blocks,e.textContent??``,{links:this.getAttribute(`links`)??void 0,headings:this.getAttribute(`headings`)??void 0,base:this.getAttribute(`base`)??void 0,resolveLink:this._resolveLink,isCitation:this._isCitation,figureText:this._figureText,resolverGeneration:this._resolverGeneration},e),this._drawn=this._blocks.flatMap(e=>e.nodes),e.hidden=!0,this._observer?.takeRecords())}};function U(t,n){switch(n.type){case`paragraph`:return[e(`p`,null,...W(t,n.lines))];case`heading`:return[G(t,n)];case`list`:return K(t,n.items);case`table`:return[J(t,n)];case`code`:return[X(n)];case`quote`:return[e(`blockquote`,null,...W(t,n.lines))];case`rule`:return[e(`hr`)];default:return[]}}function W(t,n){let r=[];return n.forEach((n,i)=>{i>0&&r.push(e(`br`)),r.push(...Z(t,n))}),r}function G(t,n){let r=Z(t,n.text);return t.headings===`text`?e(`p`,{class:`fw-semibold`},...r):e(`h2`,null,...r)}function K(e,t){let n=[];for(let r=0;r<t.length;){let i=q(e,t,r);n.push(i.list),r=i.next}return n}function q(t,n,r){let i=n[r];if(!i)throw Error(`List run starts past its items.`);let{depth:a,ordered:o,number:s}=i,c=e(o?`ol`:`ul`,o&&s!==1?{start:s}:null),l=null,u=r,d=n[u];for(;d&&d.depth>=a;){if(d.depth===a)l=e(`li`,null,...Z(t,d.text)),c.append(l),u+=1;else{let e=q(t,n,u);if(!l)throw Error(`Nested list has no item before it.`);l.append(e.list),u=e.next}d=n[u]}return{list:c,next:u}}function J(t,n){let r=n.header.map(n=>e(`th`,{scope:`col`},...Z(t,n))),i=n.rows.map(r=>e(`tr`,null,...n.header.map((n,i)=>e(`td`,null,...Z(t,r[i]??``))))),a=e(`table`,{class:`table`},e(`thead`,null,e(`tr`,null,...r)),e(`tbody`,null,...i));return e(`div`,{class:`table-responsive`},a)}function Y(e){return e===null?`text`:L.includes(e.toLowerCase())?`razor`:I.includes(e)?e:`text`}function X(t){let n=e(`code`,null,t.text),r=e(`pre`,{class:`wui-code-source`},n);return e(`wui-code-block`,{class:`wui-code-block`,language:Y(t.language)},r)}function Z(e,t){return Q(e,u(t,{isCitation:e.isCitation}))}function Q(e,t){return t.flatMap(t=>re(e,t))}function re(t,n){switch(n.type){case`code`:return[e(`code`,null,n.text)];case`strong`:return[e(`strong`,null,...Q(t,n.children))];case`em`:return[e(`em`,null,...Q(t,n.children))];case`strike`:return[e(`del`,null,...Q(t,n.children))];case`image`:return[document.createTextNode(`[`),...Q(t,n.children),document.createTextNode(`]`)];case`link`:return ae(t,n);case`citation`:return[se(n.text)];case`text`:return t.figureText?oe(t.figureText,n.text):[document.createTextNode(n.text)];default:return[document.createTextNode(ie(n))]}}function ie(e){let t=e;return typeof t==`object`&&t&&`text`in t?String(t.text):`undefined`}function ae(e,t){let n=Q(e,t.children),r=v(t.href,e.links,e.resolveLink,globalThis.location?.origin,e.base);if(!r)return n;if(r.kind===`app`){let e=x(r.target);return e?[$(e,n,!1)]:n}return[$(r.href,n,r.kind===`web`)]}function oe(t,n){return t(n).map(t=>t.kind===`sub`||t.kind===`sup`?e(t.kind,null,t.text):document.createTextNode(t.text))}function se(t){let n=e(`span`,{class:`chip-label`},t),r=e(`button`,{type:`button`,class:`chip-body`,"aria-label":t},n);return r.addEventListener(`click`,()=>{r.dispatchEvent(new CustomEvent(`wui-markdown-citation`,{bubbles:!0,detail:{citation:t}}))}),e(`span`,{class:`chip primary chip-outline chip-sm chip-clickable wui-markdown-citation`,"data-wui":`AppChip`},r)}function $(t,n,r){let i=e(`span`,{class:`wui-link__label`},...n);return e(`a`,{class:`wui-link wui-link--static`,"data-wui":`AppLink`,href:t,target:r?`_blank`:void 0,rel:r?`noopener noreferrer`:void 0},i)}export{H as t};
|
|
@@ -0,0 +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-DTW53DjY.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-Cw7V8u2w.js";import{n as _,r as v,t as y}from"./textStore-DBplASiZ.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,n){n.readOnly=t(e)||e.hasAttribute(`loading`)}function M(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`),j(e,n),A(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 N=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`,`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)||M(this);let e=this._requireControl(),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`?(j(this,r),n!==null&&this._close(),this._syncState()):e===`loading`?(j(this,r),this._syncState(),this._query!==null&&this._renderMenu()):e===`size`?A(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,N as r,S 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-BHD2QV02.js";import{o as s,r as c,s as l}from"./notificationDays-wMr8rZko.js";import{
|
|
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-BHD2QV02.js";import{o as s,r as c,s as l}from"./notificationDays-wMr8rZko.js";import{m as u}from"./wuiHttp-Cw7V8u2w.js";import{r as d}from"./textStore-DBplASiZ.js";import{t as f}from"./httpFailure.g-DjZzGxPj.js";import{t as p}from"./notificationCentre.g-UsAurkUz.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=`(max-width: 767.98px)`,O={ArrowDown:1,ArrowUp:-1,Home:`first`,End:`last`},k=e=>!!e,A=()=>({forbidden:m().forbiddenMessage,networkCheck:d(`httpFailure`,f).networkCheckText,client:m().clientMessage,validation:m().clientMessage,server:m().serverMessage,network:m().networkMessage}),j=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},M=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),N=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&&(j(this,g)===null||j(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=j(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(){j(this,g)!==null&&j(this,h)!==null&&(this._disarmAwait(),this._syncOpen(),this._showPanel())}_disarmAwait(){this._awaitChildren?.disconnect(),this._awaitChildren=null}_showPanel(){let t=e(j(this,g),`<wui-notification-center> needs its panel to open.`),n=e(j(this,h),`<wui-notification-center> needs its trigger to open.`);o(t)||(this._sheet=window.matchMedia(D).matches,this._sheet?a(t,!0):i(n,t,{mode:`auto`,onClosed:()=>this._closedByBrowser()}),o(t)&&this._layoutTabs())}_hidePanel(){let e=j(this,g);e&&o(e)&&(this._sheet?a(e,!1):r(e))}_closedByBrowser(){if(!this.isConnected||!this.hasAttribute(`open`))return;let e=j(this,g);this.close({restoreFocus:e?.contains(this.ownerDocument.activeElement)??!1})}get isOpen(){return this.hasAttribute(`open`)}open(){this.isOpen||(e(j(this,g),`<wui-notification-center> needs its panel to open.`),e(j(this,h),`<wui-notification-center> needs its trigger to open.`),this.setAttribute(`open`,``),this._syncOpen(),j(this,g)?.focus(),this._announceToggle())}close({restoreFocus:e=!1}={}){this.isOpen&&(this.removeAttribute(`open`),this._syncOpen(),e&&j(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(`${h}, ${y}, ${b}`);r instanceof HTMLElement&&this.contains(r)&&(r.matches(h)?this.toggle():this.hasAttribute(`controlled`)||(r.matches(y)?this._markAll():this._markItem(r)))}_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=O[e.key];if(r===void 0)return;let i=M(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(k),!1))}async _markAll(){if(this._busy)return;let e=M(this,`${b}:not(.${x})`);if(e.length===0&&this._unread===0)return;let t=e.map(e=>e.dataset.id).filter(k),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||A()[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 M(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 M(this,w)){let t=j(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 M(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 M(this,`.wui-notification-center-list section`))e.hidden=[...e.querySelectorAll(`li`)].every(e=>e.hidden);let n=j(this,E);n&&(n.hidden=t)}_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=j(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)}_emitRead(e,t){this.dispatchEvent(new CustomEvent(`wui:notification-center:read`,{bubbles:!0,detail:{ids:e,all:t}}))}};export{N 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-a9FtjPXh.js";import{n as l}from"./imeSafeEnter-DeO_3lXy.js";import{n as u}from"./listboxKeyNav-DNtuh6Ob.js";import{a as d,l as f,s as p}from"./nativeOverlay-BHD2QV02.js";import{r as m,t as h}from"./textStore-DBplASiZ.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:`input`,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});this.replaceChildren(r(`div`,{class:`phone-input-wrap`},n,u)),this._rendered=!0,a(this,this.querySelector(`input.input`)),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-a9FtjPXh.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-DBplASiZ.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:`input`,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});this.replaceChildren(r(`div`,{class:`phone-input-wrap`},n,u)),this._rendered=!0,a(this,this.querySelector(`input.input`)),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{n as e,t}from"./buttonClass-C8BRtTk8.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{t as r}from"./serverHtml-BC6tAyAl.js";import{
|
|
1
|
+
import{n as e,t}from"./buttonClass-C8BRtTk8.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{t as r}from"./serverHtml-BC6tAyAl.js";import{m as i}from"./wuiHttp-Cw7V8u2w.js";import{r as a,t as o}from"./textStore-DBplASiZ.js";import{t as s}from"./savedViews.g-CzzEliTR.js";var c=`wui-saved-views:`,l=20,u=0,d=()=>a(`savedViews`,s),f=e=>typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`query`in e&&typeof e.query==`string`,p=class extends n{static get observedAttributes(){return[`key`,`mode`,`action`,`can-share`]}_doc=null;_dom=null;_views;_open;_busy;_error;_trigger;_onTriggerClick;_onKeyDown;_onPointerDown;_onSubmit;constructor(){super(),this._views=[],this._open=!1,this._busy=!1,this._error=null,this._onTriggerClick=()=>this._setOpen(!this._open),this._onKeyDown=e=>{this._open&&e.target instanceof Node&&this.contains(e.target)&&(e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._setOpen(!1),this._trigger?.focus()):(e.key===`ArrowDown`||e.key===`ArrowUp`)&&this._ui.menu.contains(e.target)&&!(e.target instanceof Element&&/input|textarea/i.test(e.target.tagName))&&(e.preventDefault(),e.stopPropagation()))},this._onPointerDown=e=>{this._open&&!e.composedPath().includes(this)&&this._setOpen(!1)},this._onSubmit=async e=>{e.preventDefault();let t=this._ui.input.value.trim();if(!t)return;if(this._server()){if(this._busy)return;let e={name:t,query:this._ownerDoc.location.search};this._canShare()&&(e.shared=String(this._ui.share.checked)),await this._request(`save`,e)&&(this._ui.input.value=``,this._ui.share.checked=!1);return}let n=this._ownerDoc.location.search;this._commit([{name:t,query:n},...this._views.filter(e=>e.name!==t)].slice(0,l)),this._ui.input.value=``}}get _ownerDoc(){if(!this._doc)throw Error(`wui-saved-views is not connected`);return this._doc}get _ui(){if(!this._dom)throw Error(`wui-saved-views is not built`);return this._dom}connectedCallback(){this._doc=this.ownerDocument,this._trigger||this._build(),window.addEventListener(`keydown`,this._onKeyDown,!0),this._reload()}disconnectedCallback(){this._setOpen(!1),window.removeEventListener(`keydown`,this._onKeyDown,!0),this._doc=null}attributeChangedCallback(){this._doc&&this._trigger&&this._reload()}_reload(){this._server()?(this._views=[],this._render(),this._request(`list`)):(this._views=this._load(),this._render())}_server(){return this.getAttribute(`mode`)===`server`&&!!this.getAttribute(`action`)&&!!this.getAttribute(`key`)}_canShare(){return this._server()&&this.getAttribute(`can-share`)===`true`}async _request(e,t={}){let n=this.getAttribute(`action`)??``,a=this.getAttribute(`key`)??``,o=n,s;e===`list`?o+=(n.includes(`?`)?`&`:`?`)+new URLSearchParams({intent:`list`,key:a}):s={method:`POST`,body:new URLSearchParams({intent:e,key:a,...t})},this._busy=!0,this._render();let c=await i(o,s);if(this._busy=!1,this._doc===null)return!1;if(c.ok){let e=r(c.html);return this._views=[...e.querySelectorAll(`[data-wui-saved-views-items] > li`)].filter(e=>e instanceof HTMLLIElement).map(e=>({name:e.dataset.name,query:e.dataset.query,shared:e.dataset.shared===`true`})).filter(f),this._error=null,this._render(),!0}return this._error=c.message||d().viewsNotUpdatedMessage,this._render(),!1}_build(){let n=this._ownerDoc;this.classList.add(`dropdown`),this._trigger=n.createElement(`button`),this._trigger.type=`button`,this._trigger.className=e(`neutral`,`outline`,`sm`),this._trigger.dataset.wui=t,this._trigger.textContent=d().viewsLabel,this._trigger.setAttribute(`aria-haspopup`,`true`),this._trigger.setAttribute(`aria-expanded`,`false`),this._trigger.addEventListener(`click`,this._onTriggerClick);let r=n.createElement(`div`);r.className=`dropdown-menu`;let i=n.createElement(`div`);i.className=`dropdown-divider`;let a=n.createElement(`input`);a.type=`text`,a.className=`form-control form-control-sm`,a.setAttribute(`aria-label`,d().viewNameLabel),a.placeholder=d().nameViewPlaceholder;let o=n.createElement(`button`);o.type=`submit`,o.className=e(`primary`,`solid`,`sm`),o.dataset.wui=t,o.textContent=d().saveViewLabel;let s=n.createElement(`form`);s.className=`d-flex gap-2 px-3 py-2`,s.append(a,o),s.addEventListener(`submit`,this._onSubmit);let c=n.createElement(`input`);c.type=`checkbox`,c.className=`form-check-input`,c.setAttribute(`role`,`switch`),c.id=`wui-saved-views-share-${u++}`;let l=n.createElement(`label`);l.className=`form-check-label`,l.htmlFor=c.id,l.textContent=d().shareTeamLabel;let f=n.createElement(`div`);f.className=`form-check form-switch mb-0`,f.append(c,l);let p=n.createElement(`div`);p.className=`px-3 pb-2`,p.hidden=!0,p.append(f),this._dom={menu:r,divider:i,form:s,input:a,save:o,shareRow:p,share:c},this.append(this._trigger,r)}_render(){let e=this._ownerDoc,t=this._ui,n=[];for(let t of this._views){let r=e.createElement(`a`);if(r.className=`dropdown-item`,r.setAttribute(`href`,e.location.pathname+t.query),r.textContent=t.name,t.shared){let t=e.createElement(`span`);t.className=`badge text-bg-secondary ms-2`,t.textContent=d().sharedLabel,r.append(t)}let i=e.createElement(`button`);i.type=`button`,i.className=`btn btn-link btn-sm`,i.textContent=d().deleteLabel,i.setAttribute(`aria-label`,o(d().deleteText,{name:t.name})),i.disabled=this._busy,i.addEventListener(`click`,()=>this._server()?this._request(`delete`,{name:t.name}):this._commit(this._views.filter(e=>e.name!==t.name))),n.push(r,i)}if(this._error){let t=e.createElement(`div`);t.className=`dropdown-item-text text-danger small`,t.setAttribute(`role`,`alert`),t.textContent=this._error,n.push(t)}t.save.disabled=this._busy,t.share.disabled=this._busy,t.shareRow.hidden=!this._canShare(),t.menu.replaceChildren(...n,t.divider,t.form,t.shareRow)}_commit(e){this._views=e,this._write(e),this._render()}_setOpen(e){e!==this._open&&(this._open=e,this._ui.menu.classList.toggle(`show`,e),this._trigger?.setAttribute(`aria-expanded`,String(e)),e?this._ownerDoc.addEventListener(`pointerdown`,this._onPointerDown,!0):this._ownerDoc.removeEventListener(`pointerdown`,this._onPointerDown,!0))}_storage(){let e=this.getAttribute(`key`);if(!e)return null;try{let t=this._ownerDoc.defaultView;return t?{store:t.localStorage,key:c+e}:null}catch{return null}}_load(){let e=this._storage();if(!e)return[];try{let t=JSON.parse(e.store.getItem(e.key)??`[]`);return Array.isArray(t)?t.filter(f).slice(0,l):[]}catch{return[]}}_write(e){let t=this._storage();if(t)try{t.store.setItem(t.key,JSON.stringify(e))}catch(e){if(!(e instanceof DOMException))throw e}}};export{p 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-DvNLnnaO.js";import{t as d}from"./iconGlyphs.g-a9FtjPXh.js";import{n as f}from"./imeSafeEnter-DeO_3lXy.js";import{n as p,t as m}from"./listboxKeyNav-DNtuh6Ob.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-wbpl8OTJ.js";import{r as x}from"./textStore-DBplASiZ.js";import{n as S,r as C,t as w}from"./search.g-B5d1s59A.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,hintText:l=k().hintText,actionRow:u=[],recents:d=null}=n,f=new Set(r.map(String)),p=A(t,a),m=e.id,h=u.filter(e=>e.position===`top`),g=u.filter(e=>e.position===`bottom`),_=d?.options.length?d.options:[],v=h.length+_.length+p.length+g.length,y=p.length>300,b=P,x=y&&b!==void 0,S=e=>x?{index:e,size:v}:void 0,C=0,w=e=>{let t=C++;return i(`button`,{type:`button`,role:`option`,id:R(m,t),class:`wui-select-option wui-select-add`,"data-value":String(e.value??``),"data-custom":`true`,"aria-selected":`false`,...M(S(t))},e.label)},T=e=>{let t=C++;return V(e,R(m,t),f.has(String(e.value)),S(t))},E=h.map(w),D=_.length&&d?[i(`div`,{class:`wui-select-group`},d.label),..._.map(T),i(`div`,{class:`wui-select-sep`,"aria-hidden":`true`})]:[],O=C,F=[];if(x)C+=p.length;else{let e=``;for(let t of p)t.group&&t.group!==e&&F.push(i(`div`,{class:`wui-select-group`},t.group)),e=t.group??``,F.push(T(t))}let I=g.map(w),L=[];if(o===`loading`?L=[i(`div`,{class:`wui-select-loading`},i(`span`,{class:`wui-select-spinner spinner-border spinner-border-sm`,role:`status`,"aria-hidden":`true`}),c)]:o===`hint`?L=[i(`div`,{class:`wui-select-hint`},l)]:(o===`empty`||p.length===0&&u.length===0)&&(L=[i(`div`,{class:`wui-select-empty`},s)]),x&&b){let n=[...E,...D],r=[...I,...L];return b.render(e,{options:t,query:a,rows:p,pre:n,post:r,preSig:N(n),postSig:N(r),picked:f,top:h,recent:_,bottom:g,bodyBase:O,total:v}),{rows:v,windowed:!0,long:y}}b?.clear(e);let z=[...E,...D,...F,...I,...L],B=N(z);return j.get(e)===B||(j.set(e,B),e.replaceChildren(...z)),{rows:C,windowed:!1,long:y}}var R=(e,t)=>`${e}-opt-${t}`,z=e=>[...e.querySelectorAll(`.wui-select-option`)];function B(e){return P?P.refresh(e):!1}function ee(e,t){return P?P.reveal(e,t):z(e)[t]??null}function te(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 ne(e,t){return P?P.indexByPrefix(e,t):z(e).findIndex(e=>(e.textContent??``).trim().toLowerCase().startsWith(t))}function V(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`,ie={recents:()=>import(`./recents-B9efQ1Au.js`),chips:()=>import(`./chips-DpD0EbS0.js`),search:()=>import(`./search-BTNIAZY3.js`),country:()=>import(`./country-T7AfpJpN.js`)};function ae(e){let t=T(ie,e)?ie[e]:void 0;return t?t():Promise.reject(/* @__PURE__ */ Error(`Unknown <wui-select> part: ${e}.`))}var U=e=>typeof e.loadOptions==`function`||!!e.getAttribute(`source`)||e.hasAttribute(`remote`),oe=300,W=`<div class="wui-select-spacer" aria-hidden="true"></div>`,G=()=>i(`div`,{class:`wui-select-spacer`,"aria-hidden":`true`}),K=/* @__PURE__ */ new WeakMap;function se(e,t,n,r){let i=K.get(e);if(i&&i.options===t&&i.query===n&&i.count===r.length)return i;let a=[],o=new Int32Array(r.length),s=``;r.forEach((e,t)=>{e.group&&e.group!==s&&a.push({kind:`group`,label:e.group}),s=e.group??``,o[t]=a.length,a.push({kind:`option`,option:e,ord:t})});let c={options:t,query:n,count:r.length,entries:a,optionEntry:o,heights:O(a.length),estimated:!1,bodyTop:0,start:0,end:0,pre:[],post:[],preSig:``,postSig:``,picked:/* @__PURE__ */ new Set,top:[],recent:[],bottom:[],bodyBase:0,total:0};return K.set(e,c),e.scrollTop=0,c}var q=e=>e.clientHeight||oe,J=(e,t)=>D(t.heights,{scrollTop:Math.max(0,e.scrollTop-t.bodyTop),viewport:q(e)});function ce(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(V(n.option,R(t,r),e.picked.has(String(n.option.value)),{index:r,size:e.total}))}}}return a}function le(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 ue(e,t){let{start:n,end:r}=J(e,t);t.start=n,t.end=r;let i=ce(t,e.id,n,r),a=t.preSig+W+N(i)+W+t.postSig,o=e.scrollTop;j.get(e)!==a&&(j.set(e,a),e.replaceChildren(...t.pre,G(),...i,G(),...t.post)),le(e,t),e.scrollTop!==o&&(e.scrollTop=o)}function de(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 Y(e,t){ue(e,t);for(let n=0;n<2;n++){let{changed:n,delta:r}=de(e,t);if(!n)return;le(e,t),r&&(e.scrollTop+=r),ue(e,t)}}function fe(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}),Y(e,n)}function pe(e){let t=K.get(e);if(!t)return!1;let{start:n,end:r}=J(e,t);return n===t.start&&r===t.end?!1:(Y(e,t),!0)}function me(e,t){let n=K.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:q(e)},r=n.bodyTop+E(n.heights,i,t);if(Math.abs(r-e.scrollTop)>.5)e.scrollTop=r;else if(a())break;Y(e,n)}return a()}function he(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 ge=e=>e&&!(`position`in e)?e:void 0;function _e(e,t){let n=K.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=ge(he(n,e));if(t&&r.has(String(t.value)))return e}return-1}var ve=e=>`position`in e?e.label:`${e.initials??``}${y(e)}${e.description??``}${e.meta??``}`;function ye(e,t){let n=K.get(e);if(!n)return-1;for(let e=0;e<n.total;e++){let r=he(n,e);if(r&&ve(r).trim().toLowerCase().startsWith(t))return e}return-1}F({render:fe,refresh:pe,reveal:me,indexOfValue:_e,indexByPrefix:ye,clear(e){K.delete(e)}});function be(){return Promise.resolve()}var X=()=>x(`select`,C),xe=()=>x(`search`,w),Se=()=>x(`field`,S),Ce=class extends a{static formAssociated=!0;_internals;_value;_optionsProp;_partOptions;_known;_loadOptionsFn;_validateFn;_declared;_query;_ownsFilter;_active;_rows;_windowed;_windowLoad;_windowFailed;_scrollFrame;_status;_error;_nav;_parts;_partSig;_partsMounted;_partToken;_rendered;_searchShown;_defaultValue;_warnedMode;_warnedDensity;_hoverTimer;_hoverOpened;_onHoverOver;_onHoverOut;_panelShown;_pressOpen;static get observedAttributes(){return/* @__PURE__ */ `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._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)},De)))},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()},Oe)))}}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===`value`?(this._value=Z(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=Z(this._value,H(this.mode)),this._partOptions=null,this._known.clear(),this._ensureParts()),(e===`source`||e===`remote`||e===`recents-key`)&&this._ensureParts(),Me.has(e)?this._rendered&&(this._drawValue(),this.renderList()):je.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`:Te(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||Ee.includes(e)||e===this._warnedDensity||(this._warnedDensity=e,n(`<wui-select> density "${e}" is not one of ${Ee.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=Z(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`)||X().emptyText,searchingText:this.getAttribute(`searching-text`)||X().searchingText,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()}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=Z(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=Z(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:`input 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:`input 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":X().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`?X().countrySearchPlaceholder:xe().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":xe().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._mountParts(e)}_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||X().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`)??$(e).trim(),label:t.textContent??``,selected:e.hasAttribute(`selected`)};for(let[t,r]of Ne){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`)||Ae()[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},Se().requiredFieldMessage,t instanceof HTMLElement?t:void 0)}else e.setValidity({})}}_syncReset(){let e=Q(this,`.wui-select-reset`,HTMLElement);e&&(e.hidden=!(this.hasAttribute(`clearable`)&&this._hasValue()&&!s(this)))}_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=Q(this,`.wui-select-error`,HTMLElement);e&&(e.textContent=this._error,e.hidden=!this._error),this._syncInvalid()}_refs(){return{control:Q(this,`.wui-select-control`,HTMLElement),value:Q(this,`.wui-select-value`,HTMLElement),menu:Q(this,`.wui-select-menu`,HTMLElement),list:Q(this,`.wui-select-options`,HTMLElement),search:Q(this,`.wui-select-search input`,HTMLInputElement),input:Q(this,`.wui-select-draft`,HTMLInputElement)}}_menuOpen(){let e=Q(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>ke}_visible(){let e=this._refs();return e.list?Re(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?ee(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&&B(e)&&this._active>=0&&this._setActive(this._active,{reveal:!1})}_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=Q(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?te(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=Q(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:$(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`&&U(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(Q(this,`.wui-select`,HTMLElement),`The select wrapper is missing.`),a=Q(this,`.wui-select-search .wui-select-clear`,HTMLElement),o=Q(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?ne(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=Le(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=Le(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._windowed&&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?.teardown(),this._scrollFrame!==null&&cancelAnimationFrame(this._scrollFrame),this._scrollFrame=null}_dropMenu(){let e=Q(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=Fe(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=>ze(this,e))).then(e=>{n===this._partToken&&(this._parts=e.filter(e=>e!==null),this._mountParts())})}_loadWindow(){this._windowLoad===null&&(this._windowLoad=be().then(()=>this.renderList(),()=>{this._windowFailed=!0,document.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{chunk:`select-window`}})),this.setError(X().partLoadMessage)}))}_mountParts(e={draft:``,query:``}){if(!this._parts||this._partsMounted||!this._rendered||!this.isConnected)return;this._partsMounted=!0;let t=we(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??``}}},we=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}},Te=e=>re.includes(e),Ee=[`comfortable`,`compact`],De=150,Oe=250,ke=10,Ae=()=>{let e=X();return{single:e.placeholder,search:e.placeholder,multiple:e.placeholder,tag:e.tagPlaceholder,country:e.countryPlaceholder}},je=/* @__PURE__ */ new Set([`countries`,`suggested`,`suggested-label`,`all-countries-label`,`max-tags`,`pattern`,`collapse-chips`,`source`,`remote`,`min-chars`]),Me=/* @__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`]),Ne=[[`icon`,`icon`],[`description`,`description`],[`meta`,`meta`],[`group`,`group`],[`avatar`,`avatar`],[`initials`,`initials`],[`disabled-hint`,`disabledHint`]],Z=(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),Pe=(e,t)=>t===`multiple`?U(e)?[`chips`,`search`]:[`chips`]:t===`search`?[`search`]:t===`country`?[`country`]:t===`tag`?U(e)?[`chips`,`search`]:[`chips`]:[],Fe=(e,t)=>e.hasAttribute(`recents-key`)?[`recents`,...Pe(e,t)]:Pe(e,t),Ie=e=>typeof e==`object`&&!!e&&`default`in e&&typeof e.default==`function`,Le=e=>{if(e.target instanceof Element)return e.target;throw Error(`The event target is not an element.`)},Q=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},Re=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),$=e=>{let t=e.textContent;if(t===null)throw Error(`The element has no text.`);return t},ze=(e,t)=>ae(t).then(e=>{if(!Ie(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(X().partLoadMessage),null));export{U as n,A as r,Ce 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-DvNLnnaO.js";import{t as d}from"./iconGlyphs.g-a9FtjPXh.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-wbpl8OTJ.js";import{r as x}from"./textStore-DBplASiZ.js";import{n as S,r as C,t as w}from"./search.g-B5d1s59A.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,hintText:l=k().hintText,actionRow:u=[],recents:d=null}=n,f=new Set(r.map(String)),p=A(t,a),m=e.id,h=u.filter(e=>e.position===`top`),g=u.filter(e=>e.position===`bottom`),_=d?.options.length?d.options:[],v=h.length+_.length+p.length+g.length,y=p.length>300,b=P,x=y&&b!==void 0,S=e=>x?{index:e,size:v}:void 0,C=0,w=e=>{let t=C++;return i(`button`,{type:`button`,role:`option`,id:R(m,t),class:`wui-select-option wui-select-add`,"data-value":String(e.value??``),"data-custom":`true`,"aria-selected":`false`,...M(S(t))},e.label)},T=e=>{let t=C++;return V(e,R(m,t),f.has(String(e.value)),S(t))},E=h.map(w),D=_.length&&d?[i(`div`,{class:`wui-select-group`},d.label),..._.map(T),i(`div`,{class:`wui-select-sep`,"aria-hidden":`true`})]:[],O=C,F=[];if(x)C+=p.length;else{let e=``;for(let t of p)t.group&&t.group!==e&&F.push(i(`div`,{class:`wui-select-group`},t.group)),e=t.group??``,F.push(T(t))}let I=g.map(w),L=[];if(o===`loading`?L=[i(`div`,{class:`wui-select-loading`},i(`span`,{class:`wui-select-spinner spinner-border spinner-border-sm`,role:`status`,"aria-hidden":`true`}),c)]:o===`hint`?L=[i(`div`,{class:`wui-select-hint`},l)]:(o===`empty`||p.length===0&&u.length===0)&&(L=[i(`div`,{class:`wui-select-empty`},s)]),x&&b){let n=[...E,...D],r=[...I,...L];return b.render(e,{options:t,query:a,rows:p,pre:n,post:r,preSig:N(n),postSig:N(r),picked:f,top:h,recent:_,bottom:g,bodyBase:O,total:v}),{rows:v,windowed:!0,long:y}}b?.clear(e);let z=[...E,...D,...F,...I,...L],B=N(z);return j.get(e)===B||(j.set(e,B),e.replaceChildren(...z)),{rows:C,windowed:!1,long:y}}var R=(e,t)=>`${e}-opt-${t}`,z=e=>[...e.querySelectorAll(`.wui-select-option`)];function B(e){return P?P.refresh(e):!1}function ee(e,t){return P?P.reveal(e,t):z(e)[t]??null}function te(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 ne(e,t){return P?P.indexByPrefix(e,t):z(e).findIndex(e=>(e.textContent??``).trim().toLowerCase().startsWith(t))}function V(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`,ie={recents:()=>import(`./recents-B9efQ1Au.js`),chips:()=>import(`./chips-xXgAvIFy.js`),search:()=>import(`./search-Bhn-bjLL.js`),country:()=>import(`./country-T7AfpJpN.js`)};function ae(e){let t=T(ie,e)?ie[e]:void 0;return t?t():Promise.reject(/* @__PURE__ */ Error(`Unknown <wui-select> part: ${e}.`))}var U=e=>typeof e.loadOptions==`function`||!!e.getAttribute(`source`)||e.hasAttribute(`remote`),oe=300,W=`<div class="wui-select-spacer" aria-hidden="true"></div>`,G=()=>i(`div`,{class:`wui-select-spacer`,"aria-hidden":`true`}),K=/* @__PURE__ */ new WeakMap;function se(e,t,n,r){let i=K.get(e);if(i&&i.options===t&&i.query===n&&i.count===r.length)return i;let a=[],o=new Int32Array(r.length),s=``;r.forEach((e,t)=>{e.group&&e.group!==s&&a.push({kind:`group`,label:e.group}),s=e.group??``,o[t]=a.length,a.push({kind:`option`,option:e,ord:t})});let c={options:t,query:n,count:r.length,entries:a,optionEntry:o,heights:O(a.length),estimated:!1,bodyTop:0,start:0,end:0,pre:[],post:[],preSig:``,postSig:``,picked:/* @__PURE__ */ new Set,top:[],recent:[],bottom:[],bodyBase:0,total:0};return K.set(e,c),e.scrollTop=0,c}var q=e=>e.clientHeight||oe,J=(e,t)=>D(t.heights,{scrollTop:Math.max(0,e.scrollTop-t.bodyTop),viewport:q(e)});function ce(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(V(n.option,R(t,r),e.picked.has(String(n.option.value)),{index:r,size:e.total}))}}}return a}function le(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 ue(e,t){let{start:n,end:r}=J(e,t);t.start=n,t.end=r;let i=ce(t,e.id,n,r),a=t.preSig+W+N(i)+W+t.postSig,o=e.scrollTop;j.get(e)!==a&&(j.set(e,a),e.replaceChildren(...t.pre,G(),...i,G(),...t.post)),le(e,t),e.scrollTop!==o&&(e.scrollTop=o)}function de(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 Y(e,t){ue(e,t);for(let n=0;n<2;n++){let{changed:n,delta:r}=de(e,t);if(!n)return;le(e,t),r&&(e.scrollTop+=r),ue(e,t)}}function fe(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}),Y(e,n)}function pe(e){let t=K.get(e);if(!t)return!1;let{start:n,end:r}=J(e,t);return n===t.start&&r===t.end?!1:(Y(e,t),!0)}function me(e,t){let n=K.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:q(e)},r=n.bodyTop+E(n.heights,i,t);if(Math.abs(r-e.scrollTop)>.5)e.scrollTop=r;else if(a())break;Y(e,n)}return a()}function he(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 ge=e=>e&&!(`position`in e)?e:void 0;function _e(e,t){let n=K.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=ge(he(n,e));if(t&&r.has(String(t.value)))return e}return-1}var ve=e=>`position`in e?e.label:`${e.initials??``}${y(e)}${e.description??``}${e.meta??``}`;function ye(e,t){let n=K.get(e);if(!n)return-1;for(let e=0;e<n.total;e++){let r=he(n,e);if(r&&ve(r).trim().toLowerCase().startsWith(t))return e}return-1}F({render:fe,refresh:pe,reveal:me,indexOfValue:_e,indexByPrefix:ye,clear(e){K.delete(e)}});function be(){return Promise.resolve()}var X=()=>x(`select`,C),xe=()=>x(`search`,w),Se=()=>x(`field`,S),Ce=class extends a{static formAssociated=!0;_internals;_value;_optionsProp;_partOptions;_known;_loadOptionsFn;_validateFn;_declared;_query;_ownsFilter;_active;_rows;_windowed;_windowLoad;_windowFailed;_scrollFrame;_status;_error;_nav;_parts;_partSig;_partsMounted;_partToken;_rendered;_searchShown;_defaultValue;_warnedMode;_warnedDensity;_hoverTimer;_hoverOpened;_onHoverOver;_onHoverOut;_panelShown;_pressOpen;static get observedAttributes(){return/* @__PURE__ */ `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._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)},De)))},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()},Oe)))}}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===`value`?(this._value=Z(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=Z(this._value,H(this.mode)),this._partOptions=null,this._known.clear(),this._ensureParts()),(e===`source`||e===`remote`||e===`recents-key`)&&this._ensureParts(),Me.has(e)?this._rendered&&(this._drawValue(),this.renderList()):je.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`:Te(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||Ee.includes(e)||e===this._warnedDensity||(this._warnedDensity=e,n(`<wui-select> density "${e}" is not one of ${Ee.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=Z(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`)||X().emptyText,searchingText:this.getAttribute(`searching-text`)||X().searchingText,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()}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=Z(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=Z(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:`input 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:`input 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":X().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`?X().countrySearchPlaceholder:xe().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":xe().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._mountParts(e)}_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||X().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`)??$(e).trim(),label:t.textContent??``,selected:e.hasAttribute(`selected`)};for(let[t,r]of Ne){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`)||Ae()[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},Se().requiredFieldMessage,t instanceof HTMLElement?t:void 0)}else e.setValidity({})}}_syncReset(){let e=Q(this,`.wui-select-reset`,HTMLElement);e&&(e.hidden=!(this.hasAttribute(`clearable`)&&this._hasValue()&&!s(this)))}_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=Q(this,`.wui-select-error`,HTMLElement);e&&(e.textContent=this._error,e.hidden=!this._error),this._syncInvalid()}_refs(){return{control:Q(this,`.wui-select-control`,HTMLElement),value:Q(this,`.wui-select-value`,HTMLElement),menu:Q(this,`.wui-select-menu`,HTMLElement),list:Q(this,`.wui-select-options`,HTMLElement),search:Q(this,`.wui-select-search input`,HTMLInputElement),input:Q(this,`.wui-select-draft`,HTMLInputElement)}}_menuOpen(){let e=Q(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>ke}_visible(){let e=this._refs();return e.list?Re(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?ee(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&&B(e)&&this._active>=0&&this._setActive(this._active,{reveal:!1})}_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=Q(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?te(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=Q(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:$(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`&&U(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(Q(this,`.wui-select`,HTMLElement),`The select wrapper is missing.`),a=Q(this,`.wui-select-search .wui-select-clear`,HTMLElement),o=Q(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?ne(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=Le(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=Le(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._windowed&&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}_dropMenu(){let e=Q(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=Fe(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=>ze(this,e))).then(e=>{n===this._partToken&&(this._parts=e.filter(e=>e!==null),this._mountParts())})}_loadWindow(){this._windowLoad===null&&(this._windowLoad=be().then(()=>this.renderList(),()=>{this._windowFailed=!0,document.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{chunk:`select-window`}})),this.setError(X().partLoadMessage)}))}_mountParts(e={draft:``,query:``}){if(!this._parts||this._partsMounted||!this._rendered||!this.isConnected)return;this._partsMounted=!0;let t=we(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??``}}},we=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}},Te=e=>re.includes(e),Ee=[`comfortable`,`compact`],De=150,Oe=250,ke=10,Ae=()=>{let e=X();return{single:e.placeholder,search:e.placeholder,multiple:e.placeholder,tag:e.tagPlaceholder,country:e.countryPlaceholder}},je=/* @__PURE__ */ new Set([`countries`,`suggested`,`suggested-label`,`all-countries-label`,`max-tags`,`pattern`,`collapse-chips`,`source`,`remote`,`min-chars`]),Me=/* @__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`]),Ne=[[`icon`,`icon`],[`description`,`description`],[`meta`,`meta`],[`group`,`group`],[`avatar`,`avatar`],[`initials`,`initials`],[`disabled-hint`,`disabledHint`]],Z=(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),Pe=(e,t)=>t===`multiple`?U(e)?[`chips`,`search`]:[`chips`]:t===`search`?[`search`]:t===`country`?[`country`]:t===`tag`?U(e)?[`chips`,`search`]:[`chips`]:[],Fe=(e,t)=>e.hasAttribute(`recents-key`)?[`recents`,...Pe(e,t)]:Pe(e,t),Ie=e=>typeof e==`object`&&!!e&&`default`in e&&typeof e.default==`function`,Le=e=>{if(e.target instanceof Element)return e.target;throw Error(`The event target is not an element.`)},Q=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},Re=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),$=e=>{let t=e.textContent;if(t===null)throw Error(`The element has no text.`);return t},ze=(e,t)=>ae(t).then(e=>{if(!Ie(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(X().partLoadMessage),null));export{U as n,A as r,Ce as t};
|