import*as e from"react";import t,{PrimeReactContext as n,ariaLabel as l,localeOption as r,FilterService as o}from"primereact/api";import{ComponentBase as i,useHandleStyle as a}from"primereact/componentbase";import{useMergeProps as c,useUpdateEffect as u,useMountEffect as s,useDebounce as p,useOverlayListener as f,useUnmountEffect as d}from"primereact/hooks";import{ChevronDownIcon as m}from"primereact/icons/chevrondown";import{SpinnerIcon as v}from"primereact/icons/spinner";import{TimesIcon as b}from"primereact/icons/times";import{TimesCircleIcon as h}from"primereact/icons/timescircle";import{OverlayService as y}from"primereact/overlayservice";import{Tooltip as g}from"primereact/tooltip";import{classNames as O,ObjectUtils as x,DomHandler as E,IconUtils as k,UniqueComponentId as S,ZIndexUtils as I}from"primereact/utils";import{CSSTransition as w}from"primereact/csstransition";import{Portal as C}from"primereact/portal";import{VirtualScroller as F}from"primereact/virtualscroller";import{CheckIcon as N}from"primereact/icons/check";import{SearchIcon as D}from"primereact/icons/search";import{InputText as P}from"primereact/inputtext";import{Ripple as j}from"primereact/ripple";function L(){return L=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,l=Array(t);nn.maxSelectedLabels})},panel:function(e){var n=e.panelProps,l=e.context;return O("p-multiselect-panel p-component",{"p-multiselect-inline":n.inline,"p-multiselect-flex":n.flex,"p-multiselect-limited":!e.allowOptionSelect,"p-input-filled":l&&"filled"===l.inputStyle||"filled"===t.inputStyle,"p-ripple-disabled":l&&!1===l.ripple||!1===t.ripple})},list:function(e){return"p-multiselect-items p-component"},labelContainer:"p-multiselect-label-container",triggerIcon:"p-multiselect-trigger-icon p-c",trigger:"p-multiselect-trigger",clearIcon:"p-multiselect-clear-icon",tokenLabel:"p-multiselect-token-label",token:"p-multiselect-token",removeTokenIcon:"p-multiselect-token-icon",wrapper:"p-multiselect-items-wrapper",emptyMessage:"p-multiselect-empty-message",itemGroup:"p-multiselect-item-group",closeButton:"p-multiselect-close p-link",header:"p-multiselect-header",closeIcon:"p-multiselect-close-icon",headerCheckboxContainer:"p-multiselect-select-all",headerCheckboxIcon:"p-multiselect-select-all p-checkbox-icon p-c",headerSelectAllLabel:"p-multiselect-select-all-label",filterContainer:"p-multiselect-filter-container",filterIcon:"p-multiselect-filter-icon",item:function(e){var t=e.itemProps;return O("p-multiselect-item",{"p-highlight":t.selected,"p-disabled":t.disabled,"p-focus":t.focusedOptionIndex===t.index})},checkboxContainer:"p-multiselect-checkbox",checkboxIcon:"p-checkbox-icon p-c",transition:"p-connected-overlay"},styles:"\n@layer primereact {\n .p-multiselect {\n display: inline-flex;\n user-select: none;\n cursor: pointer;\n }\n \n .p-multiselect-trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n cursor: pointer;\n }\n \n .p-multiselect-label-container {\n overflow: hidden;\n flex: 1 1 auto;\n cursor: pointer;\n }\n \n .p-multiselect-label {\n display: block;\n white-space: nowrap;\n cursor: pointer;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n \n .p-multiselect-label-empty {\n overflow: hidden;\n visibility: hidden;\n }\n \n .p-multiselect-token {\n cursor: default;\n display: inline-flex;\n align-items: center;\n flex: 0 0 auto;\n }\n \n .p-multiselect-token-icon {\n cursor: pointer;\n }\n \n .p-multiselect .p-multiselect-panel {\n min-width: 100%;\n }\n \n .p-multiselect-inline.p-multiselect-panel {\n border: none;\n position: initial;\n background: none;\n box-shadow: none;\n }\n \n .p-multiselect-inline.p-multiselect-panel .p-multiselect-items {\n padding: 0;\n }\n \n .p-multiselect-flex.p-multiselect-panel .p-multiselect-items {\n display: flex;\n flex-wrap: wrap;\n }\n \n .p-multiselect-items-wrapper {\n overflow: auto;\n }\n \n .p-multiselect-items {\n margin: 0;\n padding: 0;\n list-style-type: none;\n }\n \n .p-multiselect-item {\n cursor: pointer;\n display: flex;\n align-items: center;\n font-weight: normal;\n white-space: nowrap;\n position: relative;\n overflow: hidden;\n outline: none;\n }\n \n .p-multiselect-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n }\n \n .p-multiselect-select-all-label {\n margin-left: 0.5rem;\n }\n \n .p-multiselect-filter-container {\n position: relative;\n flex: 1 1 auto;\n }\n \n .p-multiselect-filter-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n }\n \n .p-multiselect-filter-container .p-inputtext {\n width: 100%;\n }\n \n .p-multiselect-close {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n overflow: hidden;\n position: relative;\n margin-left: auto;\n }\n \n .p-multiselect-clear-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n right: 3rem;\n }\n \n .p-fluid .p-multiselect {\n display: flex;\n }\n}\n",inlineStyles:{root:function(e){var t=e.props;return t.showClear&&!t.disabled&&{position:"relative"}},itemGroup:function(e){var t=e.scrollerOptions;return{height:t.props?t.props.itemSize:void 0}}}}}),W=i.extend({defaultProps:{__TYPE:"Checkbox",autoFocus:!1,checked:!1,className:null,disabled:!1,falseValue:!1,icon:null,id:null,inputId:null,inputRef:null,invalid:!1,variant:null,name:null,onChange:null,onContextMenu:null,onMouseDown:null,readOnly:!1,required:!1,style:null,tabIndex:null,tooltip:null,tooltipOptions:null,trueValue:!0,value:null,children:void 0},css:{classes:{box:"p-checkbox-box",input:"p-checkbox-input",icon:"p-checkbox-icon",root:function(e){var t=e.props,n=e.context;return O("p-checkbox p-component",{"p-highlight":e.checked,"p-disabled":t.disabled,"p-invalid":t.invalid,"p-variant-filled":t.variant?"filled"===t.variant:n&&"filled"===n.inputStyle})}}}});function Y(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,l)}return n}function Z(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:{},o={height:r.props?r.props.itemSize:void 0};if(!0===n.group&&t.optionGroupLabel){var i=t.optionGroupTemplate?x.getJSXElement(t.optionGroupTemplate,n,l):t.getOptionGroupLabel(n),c=l+"_"+t.getOptionGroupRenderKey(n),u=a({className:p("itemGroup"),style:f("itemGroup",{scrollerOptions:r})},m("itemGroup"));return e.createElement("li",L({key:c},u),i)}var v=t.getOptionLabel(n),b=l+"_"+t.getOptionRenderKey(n),h=t.isOptionDisabled(n),y=t.isSelected(n);return e.createElement(re,{hostName:t.hostName,key:b,focusedOptionIndex:t.focusedOptionIndex,label:v,option:n,style:o,index:l,template:t.itemTemplate,selected:y,onClick:t.onOptionSelect,onMouseMove:g,disabled:h,className:t.itemClassName,checkboxIcon:t.checkboxIcon,isUnstyled:d,ptm:s,cx:p})},I=function(){if(t.virtualScrollerOptions){var n=ie(ie({},t.virtualScrollerOptions),{style:ie(ie({},t.virtualScrollerOptions.style),{height:t.scrollHeight}),className:O("p-multiselect-items-wrapper",t.virtualScrollerOptions.className),items:t.visibleOptions,autoSize:!0,onLazyLoad:function(e){return t.virtualScrollerOptions.onLazyLoad(ie(ie({},e),{filter:t.filterValue}))},itemTemplate:function(e,t){return e&&S(e,t.index,t)},contentTemplate:function(n){var l=t.visibleOptions&&t.visibleOptions.length||!t.hasFilter?n.children:k(),r=a({ref:n.contentRef,style:n.style,className:O(n.className,p("list",{virtualScrollerProps:t.virtualScrollerOptions})),role:"listbox","aria-multiselectable":!0},m("list"));return e.createElement("ul",r,l)}});return e.createElement(F,L({ref:o},n,{pt:s("virtualScroller"),__parentMetadata:{parent:t.metaData}}))}var l,i,c=x.isNotEmpty(t.visibleOptions)?t.visibleOptions.map(S):t.hasFilter?k():(l=x.getJSXElement(t.emptyMessage,t)||r("emptyMessage"),i=a({className:p("emptyMessage")},m("emptyMessage")),e.createElement("li",L({},i,{key:"emptyMessage"}),l)),u=a({className:p("wrapper"),style:{maxHeight:t.scrollHeight}},m("wrapper")),f=a({className:p("list"),role:"listbox","aria-multiselectable":!0},m("list"));return e.createElement("div",u,e.createElement("ul",f,c))},N=function(){var n=t.allowOptionSelect(),r=e.createElement(te,{hostName:t.hostName,id:t.id,filter:t.filter,filterRef:i,filterValue:t.filterValue,filterTemplate:t.filterTemplate,visibleOptions:t.visibleOptions,isValidOption:t.isValidOption,getOptionValue:t.getOptionValue,updateModel:t.updateModel,onFilter:h,onFilterKeyDown:t.onFilterKeyDown,filterPlaceholder:t.filterPlaceholder,onClose:t.onCloseClick,showSelectAll:t.showSelectAll,selectAll:t.isAllSelected(),selectAllLabel:t.selectAllLabel,onSelectAll:t.onSelectAll,template:t.panelHeaderTemplate,resetFilter:t.resetFilter,closeIcon:t.closeIcon,filterIcon:t.filterIcon,itemCheckboxIcon:t.itemCheckboxIcon,ptm:s,cx:p,isUnstyled:d,metaData:t.metaData}),o=I(),c=y(),f=a({className:O(t.panelClassName,p("panel",{panelProps:t,context:u,allowOptionSelect:n})),style:t.panelStyle,onClick:t.onClick,"data-pr-is-overlay":!0},m("panel"));if(t.inline)return e.createElement("div",L({ref:l},f),o,c);var g=a({classNames:p("transition"),in:t.in,timeout:{enter:120,exit:100},options:t.transitionOptions,appear:!0,unmountOnExit:!0,onEnter:v,onEntered:b,onExit:t.onExit,onExited:t.onExited},m("transition")),x=a({ref:t.firstHiddenFocusableElementOnOverlay,role:"presentation",className:"p-hidden-accessible p-hidden-focusable",tabIndex:"0",onFocus:t.onFirstHiddenFocus,"data-p-hidden-accessible":!0,"data-p-hidden-focusable":!0},s("hiddenFirstFocusableEl")),E=a({ref:t.lastHiddenFocusableElementOnOverlay,role:"presentation",className:"p-hidden-accessible p-hidden-focusable",tabIndex:"0",onFocus:t.onLastHiddenFocus,"data-p-hidden-accessible":!0,"data-p-hidden-focusable":!0},s("hiddenLastFocusableEl"));return e.createElement(w,L({nodeRef:l},g),e.createElement("div",L({ref:l},f),e.createElement("span",x),r,o,c,e.createElement("span",E)))}();return t.inline?N:e.createElement(C,{element:N,appendTo:t.appendTo})})));function ce(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,l)}return n}function ue(e){for(var t=1;t=e.length?{done:!0}:{done:!1,value:e[l++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==n.return||n.return()}finally{if(a)throw o}}}}function pe(e,t){if(e){if("string"==typeof e)return fe(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?fe(e,t):void 0}}function fe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,l=Array(t);n0,ve=x.isEmpty(C.value),be=C.optionValue?null:C.dataKey,he={props:C,state:{filterState:V,focused:Z,overlayVisible:ee}},ye=z.setMetaData(he),ge=ye.ptm,Oe=ye.cx,xe=ye.sx,Ee=ye.isUnstyled;a(z.css.styles,Ee,{name:"multiselect"});var ke=q(f({target:ne,overlay:fe,listener:function(e,t){t.valid&&("outside"===t.type?Ue(e)||qe(e)||Be():w.hideOverlaysOnDocumentScrolling?Be():E.isDocument(e.target)||_e())},when:ee}),2),Se=ke[0],Ie=ke[1],we=function(){return!C.selectionLimit||!C.value||C.value&&C.value.length-1?t+e+1:-1},Fe=function(e){var t=ot()&&e>0?x.findLastIndex(Dt.slice(0,e),(function(e){return ut(e)})):-1;return t>-1?t:-1},Ne=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=-1;return ot()&&(n=t?-1===(n=Fe(e))?Ce(e):n:-1===(n=Ce(e))?Fe(e):n),n>-1?n:e},De=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1;if(-1===t&&(t=Ne(n,!0)),-1===n&&(n=Ne(t)),-1!==t&&-1!==n){var l=Math.min(t,n),r=Math.max(t,n),o=Dt.slice(l,r+1).filter((function(e){return ct(e)})).map((function(e){return et(e)}));He(e,o,o)}},Pe=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1;if(!C.disabled&&!nt(t)){var l,r=null;r=Ye(t)?C.value.filter((function(e){return!x.equals(e,et(t),be)})):[].concat(K(l=C.value||[])||H(l)||G(l)||J(),[et(t)]),He(e,r,t),-1!==n&&D(n)}},je=function(e){if(ee){var t=-1!==N?vt(N):j?dt():pt();e.shiftKey&&De(e,U,t),yt(e,t)}else Xe(),C.editable&&yt(e,st());e.preventDefault()},Le=function(e){if(e.altKey&&!(arguments.length>1&&void 0!==arguments[1]&&arguments[1]))-1!==N&&Pe(e,Dt[N]),ee&&Be(),e.preventDefault();else{var t=-1!==N?bt(N):j?mt():ft();yt(e,t),!ee&&Xe(),e.preventDefault()}},Ae=function(e){ee?-1!==N&&(e.shiftKey?De(e,N):Pe(e,Dt[N])):(D(-1),je(e)),e.preventDefault()},Te=function(e){var t=e.currentTarget;if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]){t.setSelectionRange(0,e.shiftKey?t.value.length:0),D(-1)}else{var n=e.metaKey||e.ctrlKey,l=dt();e.shiftKey&&n&&De(e,l,U),yt(e,l),!ee&&Xe()}e.preventDefault()},Me=function(e){var t=e.currentTarget;if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]){var n=t.value.length;t.setSelectionRange(e.shiftKey?0:n,n),X("focusedOptionIndex")}else{var l=e.metaKey||e.ctrlKey,r=mt();e.shiftKey&&l&&De(e,U,r),yt(e,r),!ee&&Xe()}e.preventDefault()},Re=function(e){e.preventDefault()},Ve=function(e){e.preventDefault()},Ke=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]||(ee&&it()?(E.focus(e.shiftKey?ie.current:oe.current),e.preventDefault()):(-1!==N&&Pe(e,Dt[N]),ee&&Be(filter)))},He=function(e,t,n){C.onChange&&(C.onChange({originalEvent:e,value:t,selectedOption:n,stopPropagation:function(){null==e||e.stopPropagation()},preventDefault:function(){null==e||e.preventDefault()},target:{name:C.name,id:C.id,value:t}}),E.focus(ce.current))},Ge=function(){B(""),C.onFilter&&C.onFilter({filter:""})},Je=function(e){var t;ee&&((t=e?e.currentTarget:E.findSingle(fe.current,'li[data-p-highlight="true"]'))&&t.scrollIntoView&&t.scrollIntoView({block:"nearest",inline:"nearest"}))},Xe=function(){te(!0),D(-1!==N?N:C.autoOptionFocus?pt():st()),E.focus(ce.current)},Be=function(){D(-1),te(!1),A(!1)},_e=function(){!C.inline&&E.alignOverlay(fe.current,pe.current.parentElement,C.appendTo||w&&w.appendTo||t.appendTo)},Ue=function(e){return"clearicon"===E.getAttribute(e.target,"data-pc-section")},qe=function(e){return"headercheckboxcontainer"===E.getAttribute(e.target,"data-pc-section")},ze=function(e){return fe.current&&fe.current.contains(e.target)},We=function(e,t){return t.findIndex((function(t){return e.some((function(e){return x.equals(e,et(t),be)}))}))},Ye=function(e){if(C.value){var t=et(e),n=lt(e);return C.value.some((function(e){return x.equals(n?e:et(e),t,be)}))}return!1},Ze=function(e){var t;if(C.options)if(C.optionGroupLabel){var n,l=se(C.options);try{for(l.s();!(n=l.n()).done;){if(t=$e(e,tt(n.value)))break}}catch(e){l.e(e)}finally{l.f()}}else t=$e(e,C.options),x.isEmpty(t)&&(t=$e(e,C.value));return t?Qe(t):null},$e=function(e,t){return t.find((function(t){return x.equals(et(t),e,be)}))},Qe=function(e){return C.optionLabel?x.resolveFieldData(e,C.optionLabel):e&&void 0!==e.label?e.label:e},et=function(e){return C.useOptionAsValue?e:C.optionValue?x.resolveFieldData(e,C.optionValue):e&&void 0!==e.value?e.value:e},tt=function(e){return x.resolveFieldData(e,C.optionGroupChildren)},nt=function(e){var t;if(!we()&&!Ye(e))return!0;var n=C.optionDisabled;return n?x.isFunction(n)?n(e):x.resolveFieldData(e,n):e&&null!==(t=e.disabled)&&void 0!==t&&t},lt=function(e){return!C.useOptionAsValue&&C.optionValue||e&&void 0!==e.value},rt=function(e){return C.optionGroupLabel&&e.group},ot=function(){return x.isNotEmpty(C.value)},it=function(){return E.getFocusableElements(fe.current,':not([data-p-hidden-focusable="true"])').length>0},at=function(e){var t;return ct(e)&&(null===(t=Qe(e))||void 0===t?void 0:t.toLocaleLowerCase(C.filterLocale).startsWith(le.current.toLocaleLowerCase(C.filterLocale)))},ct=function(e){return x.isNotEmpty(e)&&!(nt(e)||rt(e))},ut=function(e){return ct(e)&&Ye(e)},st=function(){if(ot())for(var e,t=function(){var e=C.value[n],t=Dt.findIndex((function(t){return ut(t)&&(n=e,l=et(t),x.equals(n,l,be));var n,l}));if(t>-1)return{v:t}},n=C.value.length-1;n>=0;n--)if(e=t())return e.v;return-1},pt=function(){var e=st();return e<0?dt():e},ft=function(){var e=st();return e<0?mt():e},dt=function(){return Dt.findIndex((function(e){return ct(e)}))},mt=function(){return x.findLastIndex(Dt,(function(e){return ct(e)}))},vt=function(e){var t=e-1?t+e+1:e},bt=function(e){var t=e>0?x.findLastIndex(Dt.slice(0,e),(function(e){return ct(e)})):-1;return t>-1?t:e},ht=function(e){le.current=(le.current||"")+e.key;var t=-1;x.isNotEmpty(le.current)&&(-1===(t=-1!==N?-1===(t=Dt.slice(N).findIndex((function(e){return at(e)})))?Dt.slice(0,N).findIndex((function(e){return at(e)})):t+N:Dt.findIndex((function(e){return at(e)})))&&-1===N&&(t=pt()),-1!==t&&yt(e,t)),re.current&&clearTimeout(re.current),re.current=setTimeout((function(){le.current="",re.current=null}),500)},yt=function(e,t){N!==t&&(D(t),Je(e),C.selectOnFocus&&Pe(e,Dt[t],!1))},gt=function(e,t){if(e.stopPropagation(),Ot(e.currentTarget)){var n=C.value.filter((function(e){return!x.equals(e,t,be)}));C.onRemove&&C.onRemove({originalEvent:e,value:n}),He(e,n,t)}},Ot=function(e){var t=de.current;if(!(t.clientWidthC.maxSelectedLabels?xt():x.isArray(C.value)?C.value.reduce((function(e,t,n){return e+(0!==n?", ":"")+Ze(t)}),""):""},kt=function(e){return(e||[]).reduce((function(e,t,n){e.push(ue(ue({},t),{},{group:!0,index:n}));var l=tt(t);return l&&l.forEach((function(t){return e.push(t)})),e}),[])},St=function(e){switch(e.code){case"Space":case"NumpadEnter":case"Enter":if(C.inline)break;He(e,[],[]),e.preventDefault(),e.stopPropagation()}},It=function(e,t){switch(e.code){case"Space":case"NumpadEnter":case"Enter":if(C.inline)break;gt(e,t),e.preventDefault(),e.stopPropagation()}};e.useImperativeHandle(i,(function(){return{props:C,show:Xe,hide:Be,focus:function(){return E.focus(ce.current)},getElement:function(){return ne.current},getOverlay:function(){return fe.current},getInput:function(){return ce.current}}})),s((function(){_e()})),e.useEffect((function(){x.combinedRefs(ce,C.inputRef)}),[ce,C.inputRef]),e.useEffect((function(){!0===C.overlayVisible?Xe():!1===C.overlayVisible&&Be()}),[C.overlayVisible]),u((function(){ee&&V&&me&&_e()}),[ee,V,me]),d((function(){I.clear(fe.current)}));var wt,Ct,Ft,Nt,Dt=function(){var e=C.optionGroupLabel?kt(C.options):C.options;if(me){var t=V.trim().toLocaleLowerCase(C.filterLocale),n=C.filterBy?C.filterBy.split(","):[C.optionLabel||"label"];if(C.optionGroupLabel){var l,r=[],i=se(C.options);try{for(i.s();!(l=i.n()).done;){var a=l.value,c=o.filter(tt(a),n,t,C.filterMatchMode,C.filterLocale);c&&c.length&&r.push(ue(ue({},a),R({},C.optionGroupChildren,c)))}}catch(e){i.e(e)}finally{i.f()}return kt(r)}return o.filter(e,n,t,C.filterMatchMode,C.filterLocale)}return e}(),Pt=x.isNotEmpty(C.tooltip),jt=z.getOtherProps(C),Lt=x.reduceKeys(jt,E.ARIA_PROPS),At=S({className:Oe("triggerIcon")},ge("triggerIcon")),Tt=S({className:Oe("trigger")},ge("trigger")),Mt=C.loadingIcon?k.getJSXIcon(C.loadingIcon,ue({},At),{props:C}):e.createElement(v,L({spin:!0},At)),Rt=C.dropdownIcon?k.getJSXIcon(C.dropdownIcon,ue({},At),{props:C}):e.createElement(m,At),Vt=e.createElement("div",Tt,C.loading?Mt:Rt),Kt=!C.inline&&(wt=C.value?C.value.length:0,Ct=x.isNotEmpty(C.maxSelectedLabels)&&wt>C.maxSelectedLabels?xt():C.selectedItemTemplate?ve?x.getJSXElement(C.selectedItemTemplate):C.value.map((function(t,n){var l=x.getJSXElement(C.selectedItemTemplate,t);return e.createElement(e.Fragment,{key:n},l)})):"chip"!==C.display||ve?Et():C.value.slice(0,C.maxSelectedLabels||wt).map((function(t,n){var l={context:{value:t,index:n}},o=Ze(t),i=o+"_"+n,a=S({"aria-label":r("removeTokenIcon"),className:Oe("removeTokenIcon"),onClick:function(e){return gt(e,t)},onKeyDown:function(e){return It(e,t)},tabIndex:C.tabIndex||"0"},ge("removeTokenIcon",l)),c=!C.disabled&&(C.removeIcon?k.getJSXIcon(C.removeIcon,ue({},a),{props:C}):e.createElement(h,a)),u=S({className:Oe("token")},ge("token",l)),s=S({className:Oe("tokenLabel")},ge("tokenLabel",l));return e.createElement("div",L({},u,{key:i}),e.createElement("span",s,o),c)})),Ft=S({ref:pe,className:Oe("labelContainer")},ge("labelContainer")),Nt=S({ref:de,className:Oe("label",{empty:ve})},ge("label")),e.createElement("div",Ft,e.createElement("div",Nt,Ct||C.placeholder||C.emptyMessage||"empty"))),Ht=!C.inline&&function(){var t=S({className:Oe("clearIcon"),"aria-label":r("clear"),onClick:function(e){return He(e,[],[])},onKeyDown:function(e){return St(e)},tabIndex:C.tabIndex||"0"},ge("clearIcon")),n=k.getJSXIcon(C.clearIcon||e.createElement(b,t),ue({},t),{props:C});return ve||!C.showClear||C.disabled?null:n}(),Gt=S(ue(ue({ref:ne,id:C.id,style:ue(ue({},C.style),xe("root")),className:O(C.className,Oe("root",{focusedState:Z,context:w,overlayVisibleState:ee}))},jt),{},{onClick:function(e){C.inline||C.disabled||C.loading||ze(e)||Ue(e)||(ee?Be():Xe(),E.focus(ce.current),e.preventDefault()),A(!0)}}),z.getOtherProps(C),ge("root")),Jt=S({className:"p-hidden-accessible","data-p-hidden-accessible":!0},ge("hiddenInputWrapper")),Xt=S(ue({ref:ce,id:C.inputId,name:C.name,type:"text",onFocus:function(e){$(!0),C.onFocus&&C.onFocus(e)},onBlur:function(e){$(!1),C.onBlur&&C.onBlur(e)},onKeyDown:function(e){var t=e.metaKey||e.ctrlKey;switch(e.code){case"ArrowUp":if(C.inline)break;Le(e);break;case"ArrowDown":if(C.inline)break;je(e);break;case"Space":case"NumpadEnter":case"Enter":if(C.inline)break;Ae(e);break;case"Home":if(C.inline)break;Te(e),e.preventDefault();break;case"End":if(C.inline)break;Me(e),e.preventDefault();break;case"PageDown":Ve(e);break;case"PageUp":Re(e);break;case"Escape":if(C.inline)break;Be();break;case"Tab":Ke(e);break;case"ShiftLeft":case"ShiftRight":W(N);break;default:if("a"===e.key&&t){var n=Dt.filter((function(e){return ct(e)})).map((function(e){return et(e)}));He(e,n,n),e.preventDefault();break}!t&&x.isPrintableCharacter(e.key)&&(!ee&&Xe(),ht(e),e.preventDefault())}A(!1)},role:"combobox","aria-expanded":ee,disabled:C.disabled,tabIndex:C.disabled?-1:C.tabIndex,value:Et()},Lt),ge("input"));return e.createElement(e.Fragment,null,e.createElement("div",Gt,e.createElement("div",Jt,e.createElement("input",L({},Xt,{readOnly:!0}))),!C.inline&&e.createElement(e.Fragment,null,Kt,Ht,Vt),e.createElement(ae,L({hostName:"MultiSelect",ref:fe,visibleOptions:Dt},C,{onClick:function(e){y.emit("overlay-click",{originalEvent:e,target:ne.current})},onOverlayHide:Be,filterValue:M,focusedOptionIndex:N,onFirstHiddenFocus:function(e){var t=e.relatedTarget===ce.current?E.getFirstFocusableElement(fe.current,':not([data-p-hidden-focusable="true"])'):ce.current;E.focus(t)},onLastHiddenFocus:function(e){var t=e.relatedTarget===ce.current?E.getLastFocusableElement(fe.current,':not([data-p-hidden-focusable="true"])'):ce.current;E.focus(t)},firstHiddenFocusableElementOnOverlay:oe,lastHiddenFocusableElementOnOverlay:ie,setFocusedOptionIndex:D,hasFilter:me,isValidOption:ct,getOptionValue:et,updateModel:He,onFilterInputChange:function(e){var t=e.query;B(t),C.onFilter&&C.onFilter({originalEvent:e,filter:t})},onFilterKeyDown:function(e){switch(e.code){case"ArrowUp":if(C.inline)break;Le(e);break;case"ArrowDown":if(C.inline)break;je(e);break;case"NumpadEnter":case"Enter":if(C.inline)break;Ae(e);break;case"Home":if(C.inline)break;Te(e),e.preventDefault();break;case"End":if(C.inline)break;Me(e),e.preventDefault();break;case"Escape":if(C.inline)break;Be();break;case"Tab":Ke(e)}},resetFilter:Ge,onCloseClick:function(e){Be(),E.focus(ce.current),e.preventDefault(),e.stopPropagation()},onSelectAll:function(e){if(C.onSelectAll)C.onSelectAll(e);else{var t=null;if(e.checked)t=[];else{var n=Dt.filter((function(e){return ct(e)&&!nt(e)}));n&&(t=n.map((function(e){return et(e)})))}C.selectionLimit&&t&&t.length&&(t=t.slice(0,C.selectionLimit)),He(e.originalEvent,t,t)}},getOptionLabel:Qe,getOptionRenderKey:function(e){return C.dataKey?x.resolveFieldData(e,C.dataKey):Qe(e)},isOptionDisabled:nt,getOptionGroupChildren:tt,getOptionGroupLabel:function(e){return x.resolveFieldData(e,C.optionGroupLabel)},getOptionGroupRenderKey:function(e){return x.resolveFieldData(e,C.optionGroupLabel)},isSelected:Ye,getSelectedOptionIndex:function(){if(null!=C.value&&C.options){if(C.optionGroupLabel){var e=0,t=C.options.findIndex((function(t,n){return(e=n)&&-1!==We(C.value,tt(t))}));return-1!==t?{group:e,option:t}:-1}return We(C.value,C.options)}return-1},isAllSelected:function(){return C.onSelectAll?C.selectAll:!x.isEmpty(Dt)&&!Dt.filter((function(e){return!nt(e)&&ct(e)})).some((function(e){return!Ye(e)}))},onOptionSelect:Pe,allowOptionSelect:we,in:ee,onEnter:function(e){I.set("overlay",fe.current,w&&w.autoZIndex||t.autoZIndex,w&&w.zIndex.overlay||t.zIndex.overlay),E.addStyles(fe.current,{position:"absolute",top:"0",left:"0"}),_e(),Je(),e&&e()},onEntered:function(e){e&&e(),Se(),C.onShow&&C.onShow()},onExit:function(){Ie()},onExited:function(){C.filter&&C.resetFilterOnHide&&Ge(),I.clear(fe.current),C.onHide&&C.onHide()},ptm:ge,cx:Oe,sx:xe,isUnstyled:Ee,metaData:he,changeFocusedOptionIndex:yt}))),Pt&&e.createElement(g,L({target:ne,content:C.tooltip,pt:ge("tooltip")},C.tooltipOptions)))})));de.displayName="MultiSelect";export{de as MultiSelect};