text: "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/core"),n=require("primereact/inputtext"),i=require("primereact/virtualscroller"),r=require("primereact/api");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=l(e),s=l(r);function p(){return(p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function u(e){if(Array.isArray(e))return a(e)}function c(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function h(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.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)?a(e,t):void 0}}function d(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(e){return u(e)||c(e)||h(e)||d()}function y(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function v(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function m(e,t,n){return t&&v(e.prototype,t),n&&v(e,n),e}function b(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function O(e,t){return(O=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function k(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&O(e,t)}function g(e){return(g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function C(e,t){return!t||"object"!==g(t)&&"function"!=typeof t?b(e):t}function E(e){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function S(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function L(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?w(Object(n),!0).forEach((function(t){S(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function D(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var x=function(n){k(s,e.Component);var i,r,l=(i=s,r=D(),function(){var e,t=E(i);if(r){var n=E(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return C(this,e)});function s(t){var n;return y(this,s),(n=l.call(this,t)).state={focused:!1},n.onClick=n.onClick.bind(b(n)),n.onFocus=n.onFocus.bind(b(n)),n.onBlur=n.onBlur.bind(b(n)),n.onKeyDown=n.onKeyDown.bind(b(n)),n.inputRef=e.createRef(n.props.inputRef),n}return m(s,[{key:"onClick",value:function(e){this.props.disabled||this.props.readOnly||!this.props.onChange||(this.props.onChange({originalEvent:e,value:this.props.value,checked:!this.props.checked,stopPropagation:function(){},preventDefault:function(){},target:{type:"checkbox",name:this.props.name,id:this.props.id,value:this.props.value,checked:!this.props.checked}}),this.inputRef.current.checked=!this.props.checked,this.inputRef.current.focus(),e.preventDefault())}},{key:"updateInputRef",value:function(){var e=this.props.inputRef;e&&("function"==typeof e?e(this.inputRef.current):e.current=this.inputRef.current)}},{key:"componentDidMount",value:function(){this.updateInputRef(),this.props.tooltip&&this.renderTooltip()}},{key:"componentWillUnmount",value:function(){this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)}},{key:"componentDidUpdate",value:function(e){this.inputRef.current.checked=this.props.checked,e.tooltip===this.props.tooltip&&e.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(L({content:this.props.tooltip},this.props.tooltipOptions||{})):this.renderTooltip())}},{key:"onFocus",value:function(){this.setState({focused:!0})}},{key:"onBlur",value:function(){this.setState({focused:!1})}},{key:"onKeyDown",value:function(e){"Enter"===e.key&&(this.onClick(e),e.preventDefault())}},{key:"renderTooltip",value:function(){this.tooltip=t.tip({target:this.element,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"render",value:function(){var e=this,n=t.classNames("p-checkbox p-component",{"p-checkbox-checked":this.props.checked,"p-checkbox-disabled":this.props.disabled,"p-checkbox-focused":this.state.focused},this.props.className),i=t.classNames("p-checkbox-box",{"p-highlight":this.props.checked,"p-disabled":this.props.disabled,"p-focus":this.state.focused}),r=t.classNames("p-checkbox-icon p-c",S({},this.props.icon,this.props.checked));return o.default.createElement("div",{ref:function(t){return e.element=t},id:this.props.id,className:n,style:this.props.style,onClick:this.onClick,onContextMenu:this.props.onContextMenu,onMouseDown:this.props.onMouseDown},o.default.createElement("div",{className:"p-hidden-accessible"},o.default.createElement("input",{ref:this.inputRef,type:"checkbox","aria-labelledby":this.props.ariaLabelledBy,id:this.props.inputId,name:this.props.name,tabIndex:this.props.tabIndex,defaultChecked:this.props.checked,onKeyDown:this.onKeyDown,onFocus:this.onFocus,onBlur:this.onBlur,disabled:this.props.disabled,readOnly:this.props.readOnly,required:this.props.required})),o.default.createElement("div",{className:i,ref:function(t){return e.box=t},role:"checkbox","aria-checked":this.props.checked},o.default.createElement("span",{className:r})))}}]),s}();function R(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}S(x,"defaultProps",{id:null,inputRef:null,inputId:null,value:null,name:null,checked:!1,style:null,className:null,disabled:!1,required:!1,readOnly:!1,tabIndex:null,icon:"pi pi-check",tooltip:null,tooltipOptions:null,ariaLabelledBy:null,onChange:null,onMouseDown:null,onContextMenu:null});var I=function(i){k(p,e.Component);var r,l,s=(r=p,l=R(),function(){var e,t=E(r);if(l){var n=E(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return C(this,e)});function p(e){var t;return y(this,p),(t=s.call(this,e)).onFilter=t.onFilter.bind(b(t)),t.onSelectAll=t.onSelectAll.bind(b(t)),t}return m(p,[{key:"onFilter",value:function(e){this.props.onFilter&&this.props.onFilter({originalEvent:e,query:e.target.value})}},{key:"onSelectAll",value:function(e){this.props.onSelectAll&&this.props.onSelectAll({originalEvent:e,checked:this.props.selectAll})}},{key:"renderFilterElement",value:function(){return this.props.filter?o.default.createElement("div",{className:"p-multiselect-filter-container"},o.default.createElement(n.InputText,{type:"text",role:"textbox",value:this.props.filterValue,onChange:this.onFilter,className:"p-multiselect-filter",placeholder:this.props.filterPlaceholder}),o.default.createElement("span",{className:"p-multiselect-filter-icon pi pi-search"})):null}},{key:"render",value:function(){var e=this.renderFilterElement(),n=this.props.showSelectAll&&o.default.createElement(x,{checked:this.props.selectAll,onChange:this.onSelectAll,role:"checkbox","aria-checked":this.props.selectAll}),i=o.default.createElement("button",{type:"button",className:"p-multiselect-close p-link",onClick:this.props.onClose},o.default.createElement("span",{className:"p-multiselect-close-icon pi pi-times"}),o.default.createElement(t.Ripple,null)),r=o.default.createElement("div",{className:"p-multiselect-header"},n,e,i);return this.props.template?t.ObjectUtils.getJSXElement(this.props.template,{className:"p-multiselect-header",checkboxElement:n,checked:this.props.selectAll,onChange:this.onSelectAll,filterElement:e,closeElement:i,closeElementClassName:"p-multiselect-close p-link",closeIconClassName:"p-multiselect-close-icon pi pi-times",onCloseClick:this.props.onClose,element:r,props:this.props}):r}}]),p}();function F(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var j=function(n){k(s,e.Component);var i,r,l=(i=s,r=F(),function(){var e,t=E(i);if(r){var n=E(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return C(this,e)});function s(e){var t;return y(this,s),(t=l.call(this,e)).onClick=t.onClick.bind(b(t)),t.onKeyDown=t.onKeyDown.bind(b(t)),t}return m(s,[{key:"onClick",value:function(e){this.props.onClick&&this.props.onClick({originalEvent:e,option:this.props.option}),e.preventDefault()}},{key:"onKeyDown",value:function(e){this.props.onKeyDown&&this.props.onKeyDown({originalEvent:e,option:this.props.option})}},{key:"render",value:function(){var e=t.classNames("p-multiselect-item",{"p-highlight":this.props.selected,"p-disabled":this.props.disabled},this.props.option.className),n=t.classNames("p-checkbox-box",{"p-highlight":this.props.selected}),i=t.classNames("p-checkbox-icon p-c",{"pi pi-check":this.props.selected}),r=this.props.template?t.ObjectUtils.getJSXElement(this.props.template,this.props.option):this.props.label;return o.default.createElement("li",{className:e,onClick:this.onClick,tabIndex:this.props.disabled?null:this.props.tabIndex||0,onKeyDown:this.onKeyDown,role:"option","aria-selected":this.props.selected},o.default.createElement("div",{className:"p-checkbox p-component"},o.default.createElement("div",{className:n},o.default.createElement("span",{className:i}))),o.default.createElement("span",null,r),o.default.createElement(t.Ripple,null))}}]),s}();function N(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function P(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?N(Object(n),!0).forEach((function(t){S(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):N(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function K(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}S(j,"defaultProps",{option:null,label:null,selected:!1,disabled:!1,tabIndex:null,template:null,onClick:null,onKeyDown:null});var V=function(n){k(a,e.Component);var r,l,s=(r=a,l=K(),function(){var e,t=E(r);if(l){var n=E(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return C(this,e)});function a(e){var t;return y(this,a),(t=s.call(this,e)).onEnter=t.onEnter.bind(b(t)),t.onFilterInputChange=t.onFilterInputChange.bind(b(t)),t}return m(a,[{key:"onEnter",value:function(){var e=this;this.props.onEnter((function(){if(e.virtualScrollerRef){var t=e.props.getSelectedOptionIndex();-1!==t&&e.virtualScrollerRef.scrollToIndex(t)}}))}},{key:"onFilterInputChange",value:function(e){this.virtualScrollerRef&&this.virtualScrollerRef.scrollToIndex(0),this.props.onFilterInputChange&&this.props.onFilterInputChange(e)}},{key:"isEmptyFilter",value:function(){return!(this.props.visibleOptions&&this.props.visibleOptions.length)&&this.props.hasFilter()}},{key:"renderHeader",value:function(){return o.default.createElement(I,{filter:this.props.filter,filterValue:this.props.filterValue,onFilter:this.onFilterInputChange,filterPlaceholder:this.props.filterPlaceholder,onClose:this.props.onCloseClick,showSelectAll:this.props.showSelectAll,selectAll:this.props.isAllSelected(),onSelectAll:this.props.onSelectAll,template:this.props.panelHeaderTemplate})}},{key:"renderFooter",value:function(){if(this.props.panelFooterTemplate){var e=t.ObjectUtils.getJSXElement(this.props.panelFooterTemplate,this.props,this.props.onOverlayHide);return o.default.createElement("div",{className:"p-multiselect-footer"},e)}return null}},{key:"renderGroupChildren",value:function(e){var t=this;return this.props.getOptionGroupChildren(e).map((function(e,n){var i=t.props.getOptionLabel(e),r=n+"_"+t.props.getOptionRenderKey(e),l=t.props.isOptionDisabled(e),s=l?null:t.props.tabIndex||0;return o.default.createElement(j,{key:r,label:i,option:e,template:t.props.itemTemplate,selected:t.props.isSelected(e),onClick:t.props.onOptionSelect,onKeyDown:t.props.onOptionKeyDown,tabIndex:s,disabled:l})}))}},{key:"renderEmptyFilter",value:function(){var e=t.ObjectUtils.getJSXElement(this.props.emptyFilterMessage,this.props);return o.default.createElement("li",{className:"p-multiselect-empty-message"},e)}},{key:"renderItem",value:function(e,n){if(this.props.optionGroupLabel){var i=this.props.optionGroupTemplate?t.ObjectUtils.getJSXElement(this.props.optionGroupTemplate,e,n):this.props.getOptionGroupLabel(e),r=this.renderGroupChildren(e),l=n+"_"+this.props.getOptionGroupRenderKey(e);return o.default.createElement(o.default.Fragment,{key:l},o.default.createElement("li",{className:"p-multiselect-item-group"},i),r)}var s=this.props.getOptionLabel(e),p=n+"_"+this.props.getOptionRenderKey(e),a=this.props.isOptionDisabled(e),u=a?null:this.props.tabIndex||0;return o.default.createElement(j,{key:p,label:s,option:e,template:this.props.itemTemplate,selected:this.props.isSelected(e),onClick:this.props.onOptionSelect,onKeyDown:this.props.onOptionKeyDown,tabIndex:u,disabled:a})}},{key:"renderItems",value:function(){var e=this;return this.props.visibleOptions&&this.props.visibleOptions.length?this.props.visibleOptions.map((function(t,n){return e.renderItem(t,n)})):this.props.hasFilter()?this.renderEmptyFilter():null}},{key:"renderContent",value:function(){var e=this;if(this.props.virtualScrollerOptions){var n=P(P({},this.props.virtualScrollerOptions),{style:P(P({},this.props.virtualScrollerOptions.style),{height:this.props.scrollHeight}),className:t.classNames("p-multiselect-items-wrapper",this.props.virtualScrollerOptions.className),items:this.props.visibleOptions,onLazyLoad:function(t){return e.props.virtualScrollerOptions.onLazyLoad(P(P({},t),{filter:e.props.filterValue}))},itemTemplate:function(t,n){return t&&e.renderItem(t,n.index)},contentTemplate:function(n){var i=t.classNames("p-multiselect-items p-component",n.className),r=e.isEmptyFilter()?e.renderEmptyFilter():n.children;return o.default.createElement("ul",{ref:n.ref,className:i,role:"listbox","aria-multiselectable":!0},r)}});return o.default.createElement(i.VirtualScroller,p({ref:function(t){return e.virtualScrollerRef=t}},n))}var r=this.renderItems();return o.default.createElement("div",{className:"p-multiselect-items-wrapper",style:{maxHeight:this.props.scrollHeight}},o.default.createElement("ul",{className:"p-multiselect-items p-component",role:"listbox","aria-multiselectable":!0},r))}},{key:"renderElement",value:function(){var e=t.classNames("p-multiselect-panel p-component",{"p-multiselect-limited":!this.props.allowOptionSelect()},this.props.panelClassName),n=this.renderHeader(),i=this.renderContent(),r=this.renderFooter();return o.default.createElement(t.CSSTransition,{nodeRef:this.props.forwardRef,classNames:"p-connected-overlay",in:this.props.in,timeout:{enter:120,exit:100},options:this.props.transitionOptions,unmountOnExit:!0,onEnter:this.onEnter,onEntered:this.props.onEntered,onExit:this.props.onExit,onExited:this.props.onExited},o.default.createElement("div",{ref:this.props.forwardRef,className:e,style:this.props.panelStyle,onClick:this.props.onClick},n,i,r))}},{key:"render",value:function(){var e=this.renderElement();return o.default.createElement(t.Portal,{element:e,appendTo:this.props.appendTo})}}]),a}(),A=o.default.forwardRef((function(e,t){return o.default.createElement(V,p({forwardRef:t},e))}));function G(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function T(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?G(Object(n),!0).forEach((function(t){S(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):G(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function B(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=H(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},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 l,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,l=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw l}}}}function H(e,t){if(e){if("string"==typeof e)return U(e,t);var n=Object.prototype.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)?U(e,t):void 0}}function U(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function M(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var q=function(n){k(a,e.Component);var i,r,l=(i=a,r=M(),function(){var e,t=E(i);if(r){var n=E(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return C(this,e)});function a(t){var n;return y(this,a),(n=l.call(this,t)).state={filter:"",focused:!1,overlayVisible:!1},n.onClick=n.onClick.bind(b(n)),n.onKeyDown=n.onKeyDown.bind(b(n)),n.onOptionSelect=n.onOptionSelect.bind(b(n)),n.onOptionKeyDown=n.onOptionKeyDown.bind(b(n)),n.onFocus=n.onFocus.bind(b(n)),n.onBlur=n.onBlur.bind(b(n)),n.onFilterInputChange=n.onFilterInputChange.bind(b(n)),n.onCloseClick=n.onCloseClick.bind(b(n)),n.onSelectAll=n.onSelectAll.bind(b(n)),n.onOverlayEnter=n.onOverlayEnter.bind(b(n)),n.onOverlayEntered=n.onOverlayEntered.bind(b(n)),n.onOverlayExit=n.onOverlayExit.bind(b(n)),n.onOverlayExited=n.onOverlayExited.bind(b(n)),n.onPanelClick=n.onPanelClick.bind(b(n)),n.getOptionLabel=n.getOptionLabel.bind(b(n)),n.getOptionRenderKey=n.getOptionRenderKey.bind(b(n)),n.isOptionDisabled=n.isOptionDisabled.bind(b(n)),n.getOptionGroupChildren=n.getOptionGroupChildren.bind(b(n)),n.getOptionGroupLabel=n.getOptionGroupLabel.bind(b(n)),n.getOptionGroupRenderKey=n.getOptionGroupRenderKey.bind(b(n)),n.allowOptionSelect=n.allowOptionSelect.bind(b(n)),n.isSelected=n.isSelected.bind(b(n)),n.isAllSelected=n.isAllSelected.bind(b(n)),n.hasFilter=n.hasFilter.bind(b(n)),n.getSelectedOptionIndex=n.getSelectedOptionIndex.bind(b(n)),n.hide=n.hide.bind(b(n)),n.onOptionKeyDown=n.onOptionKeyDown.bind(b(n)),n.overlayRef=e.createRef(),n.inputRef=e.createRef(n.props.inputRef),n}return m(a,[{key:"onPanelClick",value:function(e){t.OverlayService.emit("overlay-click",{originalEvent:e,target:this.container})}},{key:"allowOptionSelect",value:function(){return!this.props.selectionLimit||!this.props.value||this.props.value&&this.props.value.length<this.props.selectionLimit}},{key:"onOptionSelect",value:function(e){var n=this,i=e.originalEvent,r=e.option;if(!this.props.disabled&&!this.isOptionDisabled(r)){var l=this.getOptionValue(r),o=this.isOptionValueUsed(r),s=this.isSelected(r),p=this.allowOptionSelect();s?this.updateModel(i,this.props.value.filter((function(e){return!t.ObjectUtils.equals(o?e:n.getOptionValue(e),l,n.equalityKey())}))):p&&this.updateModel(i,[].concat(f(this.props.value||[]),[l]))}}},{key:"onOptionKeyDown",value:function(e){var t=e.originalEvent,n=t.currentTarget;switch(t.which){case 40:var i=this.findNextItem(n);i&&i.focus(),t.preventDefault();break;case 38:var r=this.findPrevItem(n);r&&r.focus(),t.preventDefault();break;case 13:case 32:this.onOptionSelect(e),t.preventDefault();break;case 27:this.hide(),this.inputRef.current.focus()}}},{key:"findNextItem",value:function(e){var n=e.nextElementSibling;return n?t.DomHandler.hasClass(n,"p-disabled")||t.DomHandler.hasClass(n,"p-multiselect-item-group")?this.findNextItem(n):n:null}},{key:"findPrevItem",value:function(e){var n=e.previousElementSibling;return n?t.DomHandler.hasClass(n,"p-disabled")||t.DomHandler.hasClass(n,"p-multiselect-item-group")?this.findPrevItem(n):n:null}},{key:"onClick",value:function(e){this.props.disabled||this.isPanelClicked(e)||t.DomHandler.hasClass(e.target,"p-multiselect-token-icon")||this.isClearClicked(e)||(this.state.overlayVisible?this.hide():this.show(),this.inputRef.current.focus())}},{key:"onKeyDown",value:function(e){switch(e.which){case 40:!this.state.overlayVisible&&e.altKey&&(this.show(),e.preventDefault());break;case 32:this.state.overlayVisible?this.hide():this.show(),e.preventDefault();break;case 27:this.hide();break;case 9:if(this.state.overlayVisible){var n=t.DomHandler.getFirstFocusableElement(this.overlayRef.current);n&&(n.focus(),e.preventDefault())}}}},{key:"onSelectAll",value:function(e){var t=this;if(this.props.onSelectAll)this.props.onSelectAll(e);else{var n=null,i=this.getVisibleOptions();if(e.checked){if(n=[],i){var r=i.filter((function(e){return t.isOptionDisabled(e)&&t.isSelected(e)}));n=r.map((function(e){return t.getOptionValue(e)}))}}else i&&(i=i.filter((function(e){return!t.isOptionDisabled(e)})),this.props.optionGroupLabel?(n=[],i.forEach((function(e){return n=[].concat(f(n),f(t.getOptionGroupChildren(e).filter((function(e){return!t.isOptionDisabled(e)})).map((function(e){return t.getOptionValue(e)}))))}))):n=i.map((function(e){return t.getOptionValue(e)})),n=f(new Set([].concat(f(n),f(this.props.value||[])))));this.updateModel(e.originalEvent,n)}}},{key:"updateModel",value:function(e,t){this.props.onChange&&this.props.onChange({originalEvent:e,value:t,stopPropagation:function(){},preventDefault:function(){},target:{name:this.props.name,id:this.props.id,value:t}})}},{key:"onFilterInputChange",value:function(e){var t=this,n=e.query;this.setState({filter:n},(function(){t.props.onFilter&&t.props.onFilter({originalEvent:e,filter:n})}))}},{key:"resetFilter",value:function(){var e=this;this.setState({filter:""},(function(){e.props.onFilter&&e.props.onFilter({filter:""})}))}},{key:"show",value:function(){this.setState({overlayVisible:!0})}},{key:"hide",value:function(){this.setState({overlayVisible:!1})}},{key:"onOverlayEnter",value:function(e){t.ZIndexUtils.set("overlay",this.overlayRef.current),this.alignOverlay(),this.scrollInView(),e&&e()}},{key:"onOverlayEntered",value:function(e){this.bindDocumentClickListener(),this.bindScrollListener(),this.bindResizeListener(),e&&e(),this.props.onShow&&this.props.onShow()}},{key:"onOverlayExit",value:function(){this.unbindDocumentClickListener(),this.unbindScrollListener(),this.unbindResizeListener()}},{key:"onOverlayExited",value:function(){this.props.filter&&this.props.resetFilterOnHide&&this.resetFilter(),t.ZIndexUtils.clear(this.overlayRef.current),this.props.onHide&&this.props.onHide()}},{key:"alignOverlay",value:function(){t.DomHandler.alignOverlay(this.overlayRef.current,this.label.parentElement,this.props.appendTo||s.default.appendTo)}},{key:"scrollInView",value:function(){var e=t.DomHandler.findSingle(this.overlayRef.current,"li.p-highlight");e&&e.scrollIntoView({block:"nearest",inline:"start"})}},{key:"onCloseClick",value:function(e){this.hide(),this.inputRef.current.focus(),e.preventDefault(),e.stopPropagation()}},{key:"getSelectedOptionIndex",value:function(){if(null!=this.props.value&&this.props.options){if(!this.props.optionGroupLabel)return this.findOptionIndexInList(this.props.value,this.props.options);for(var e=0;e<this.props.options.length;e++){var t=this.findOptionIndexInList(this.props.value,this.getOptionGroupChildren(this.props.options[e]));if(-1!==t)return{group:e,option:t}}}return-1}},{key:"findOptionIndexInList",value:function(e,n){var i=this,r=this.equalityKey();return n.findIndex((function(n){return e.some((function(e){return t.ObjectUtils.equals(e,i.getOptionValue(n),r)}))}))}},{key:"isSelected",value:function(e){var n=this,i=!1;if(this.props.value){var r=this.getOptionValue(e),l=this.isOptionValueUsed(e),o=this.equalityKey();i=this.props.value.some((function(e){return t.ObjectUtils.equals(l?e:n.getOptionValue(e),r,o)}))}return i}},{key:"getLabelByValue",value:function(e){var t;if(this.props.options)if(this.props.optionGroupLabel){var n,i=B(this.props.options);try{for(i.s();!(n=i.n()).done;){if(t=this.findOptionByValue(e,this.getOptionGroupChildren(n.value)))break}}catch(e){i.e(e)}finally{i.f()}}else t=this.findOptionByValue(e,this.props.options);return t?this.getOptionLabel(t):null}},{key:"findOptionByValue",value:function(e,n){var i,r=this.equalityKey(),l=B(n);try{for(l.s();!(i=l.n()).done;){var o=i.value,s=this.getOptionValue(o);if(t.ObjectUtils.equals(s,e,r))return o}}catch(e){l.e(e)}finally{l.f()}return null}},{key:"onFocus",value:function(e){var t=this;e.persist(),this.setState({focused:!0},(function(){t.props.onFocus&&t.props.onFocus(e)}))}},{key:"onBlur",value:function(e){var t=this;e.persist(),this.setState({focused:!1},(function(){t.props.onBlur&&t.props.onBlur(e)}))}},{key:"bindDocumentClickListener",value:function(){var e=this;this.documentClickListener||(this.documentClickListener=function(t){e.state.overlayVisible&&e.isOutsideClicked(t)&&e.hide()},document.addEventListener("click",this.documentClickListener))}},{key:"bindScrollListener",value:function(){var e=this;this.scrollHandler||(this.scrollHandler=new t.ConnectedOverlayScrollHandler(this.container,(function(){e.state.overlayVisible&&e.hide()}))),this.scrollHandler.bindScrollListener()}},{key:"unbindScrollListener",value:function(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()}},{key:"bindResizeListener",value:function(){var e=this;this.resizeListener||(this.resizeListener=function(){e.state.overlayVisible&&!t.DomHandler.isAndroid()&&e.hide()},window.addEventListener("resize",this.resizeListener))}},{key:"unbindResizeListener",value:function(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)}},{key:"isOutsideClicked",value:function(e){return this.container&&!(this.container.isSameNode(e.target)||this.isClearClicked(e)||this.container.contains(e.target)||this.isPanelClicked(e))}},{key:"isClearClicked",value:function(e){return t.DomHandler.hasClass(e.target,"p-multiselect-clear-icon")}},{key:"isPanelClicked",value:function(e){return this.overlayRef&&this.overlayRef.current&&this.overlayRef.current.contains(e.target)}},{key:"unbindDocumentClickListener",value:function(){this.documentClickListener&&(document.removeEventListener("click",this.documentClickListener),this.documentClickListener=null)}},{key:"updateInputRef",value:function(){var e=this.props.inputRef;e&&("function"==typeof e?e(this.inputRef.current):e.current=this.inputRef.current)}},{key:"componentDidMount",value:function(){this.updateInputRef(),this.props.tooltip&&this.renderTooltip()}},{key:"componentDidUpdate",value:function(e){e.tooltip===this.props.tooltip&&e.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(T({content:this.props.tooltip},this.props.tooltipOptions||{})):this.renderTooltip()),this.state.overlayVisible&&this.hasFilter()&&this.alignOverlay()}},{key:"componentWillUnmount",value:function(){this.unbindDocumentClickListener(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.tooltip&&(this.tooltip.destroy(),this.tooltip=null),t.ZIndexUtils.clear(this.overlayRef.current)}},{key:"hasFilter",value:function(){return this.state.filter&&this.state.filter.trim().length>0}},{key:"isAllSelected",value:function(){var e=this;if(this.props.onSelectAll)return this.props.selectAll;var t=this.getVisibleOptions();if(0===t.length)return!1;if(t=t.filter((function(t){return!e.isOptionDisabled(t)})),this.props.optionGroupLabel){var n,i=B(t);try{for(i.s();!(n=i.n()).done;){var r,l=B(this.getOptionGroupChildren(n.value).filter((function(t){return!e.isOptionDisabled(t)})));try{for(l.s();!(r=l.n()).done;){if(!this.isSelected(r.value))return!1}}catch(e){l.e(e)}finally{l.f()}}}catch(e){i.e(e)}finally{i.f()}}else{var o,s=B(t);try{for(s.s();!(o=s.n()).done;){if(!this.isSelected(o.value))return!1}}catch(e){s.e(e)}finally{s.f()}}return!0}},{key:"getOptionLabel",value:function(e){return this.props.optionLabel?t.ObjectUtils.resolveFieldData(e,this.props.optionLabel):e&&void 0!==e.label?e.label:e}},{key:"getOptionValue",value:function(e){if(this.props.optionValue){var n=t.ObjectUtils.resolveFieldData(e,this.props.optionValue);return null!==n?n:e}return e&&void 0!==e.value?e.value:e}},{key:"getOptionRenderKey",value:function(e){return this.props.dataKey?t.ObjectUtils.resolveFieldData(e,this.props.dataKey):this.getOptionLabel(e)}},{key:"getOptionGroupRenderKey",value:function(e){return t.ObjectUtils.resolveFieldData(e,this.props.optionGroupLabel)}},{key:"getOptionGroupLabel",value:function(e){return t.ObjectUtils.resolveFieldData(e,this.props.optionGroupLabel)}},{key:"getOptionGroupChildren",value:function(e){return t.ObjectUtils.resolveFieldData(e,this.props.optionGroupChildren)}},{key:"isOptionDisabled",value:function(e){return this.props.optionDisabled?t.ObjectUtils.isFunction(this.props.optionDisabled)?this.props.optionDisabled(e):t.ObjectUtils.resolveFieldData(e,this.props.optionDisabled):!(!e||void 0===e.disabled)&&e.disabled}},{key:"isOptionValueUsed",value:function(e){return this.props.optionValue||e&&void 0!==e.value}},{key:"getVisibleOptions",value:function(){if(this.hasFilter()){var e=this.state.filter.trim().toLocaleLowerCase(this.props.filterLocale),n=this.props.filterBy?this.props.filterBy.split(","):[this.props.optionLabel||"label"];if(this.props.optionGroupLabel){var i,r=[],l=B(this.props.options);try{for(l.s();!(i=l.n()).done;){var o=i.value,s=t.FilterUtils.filter(this.getOptionGroupChildren(o),n,e,this.props.filterMatchMode,this.props.filterLocale);s&&s.length&&r.push(T(T({},o),{items:s}))}}catch(e){l.e(e)}finally{l.f()}return r}return t.FilterUtils.filter(this.props.options,n,e,this.props.filterMatchMode,this.props.filterLocale)}return this.props.options}},{key:"isEmpty",value:function(){return!this.props.value||0===this.props.value.length}},{key:"equalityKey",value:function(){return this.props.optionValue?null:this.props.dataKey}},{key:"checkValidity",value:function(){return this.inputRef.current.checkValidity()}},{key:"removeChip",value:function(e,n){var i=this.equalityKey(),r=this.props.value.filter((function(e){return!t.ObjectUtils.equals(e,n,i)}));this.updateModel(e,r)}},{key:"getSelectedItemsLabel",value:function(){var e=/{(.*?)}/;return e.test(this.props.selectedItemsLabel)?this.props.selectedItemsLabel.replace(this.props.selectedItemsLabel.match(e)[0],this.props.value.length+""):this.props.selectedItemsLabel}},{key:"getLabel",value:function(){var e;if(!this.isEmpty()&&!this.props.fixedPlaceholder){if(this.props.value.length<=this.props.maxSelectedLabels){e="";for(var t=0;t<this.props.value.length;t++)0!==t&&(e+=","),e+=this.getLabelByValue(this.props.value[t]);return e}return this.getSelectedItemsLabel()}return e}},{key:"getLabelContent",value:function(){var e=this;return this.props.selectedItemTemplate?this.isEmpty()?t.ObjectUtils.getJSXElement(this.props.selectedItemTemplate):this.props.value.length<=this.props.maxSelectedLabels?this.props.value.map((function(n,i){var r=t.ObjectUtils.getJSXElement(e.props.selectedItemTemplate,n);return o.default.createElement(o.default.Fragment,{key:i},r)})):this.getSelectedItemsLabel():"chip"!==this.props.display||this.isEmpty()?this.getLabel():this.props.value.map((function(t){var n=e.getLabelByValue(t);return o.default.createElement("div",{className:"p-multiselect-token",key:n},o.default.createElement("span",{className:"p-multiselect-token-label"},n),!e.props.disabled&&o.default.createElement("span",{className:"p-multiselect-token-icon pi pi-times-circle",onClick:function(n){return e.removeChip(n,t)}}))}))}},{key:"renderTooltip",value:function(){this.tooltip=t.tip({target:this.container,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"renderClearIcon",value:function(){var e=this;return this.isEmpty()||!this.props.showClear||this.props.disabled?null:o.default.createElement("i",{className:"p-multiselect-clear-icon pi pi-times",onClick:function(t){return e.updateModel(t,null)}})}},{key:"renderLabel",value:function(){var e=this,n=this.isEmpty(),i=this.getLabelContent(),r=t.classNames("p-multiselect-label",{"p-placeholder":n&&this.props.placeholder,"p-multiselect-label-empty":n&&!this.props.placeholder&&!this.props.selectedItemTemplate,"p-multiselect-items-label":!n&&this.props.value.length>this.props.maxSelectedLabels});return o.default.createElement("div",{ref:function(t){return e.label=t},className:"p-multiselect-label-container"},o.default.createElement("div",{className:r},i||this.props.placeholder||"empty"))}},{key:"render",value:function(){var e=this,n=t.classNames("p-multiselect p-component p-inputwrapper",{"p-multiselect-chip":"chip"===this.props.display,"p-disabled":this.props.disabled,"p-multiselect-clearable":this.props.showClear&&!this.props.disabled,"p-focus":this.state.focused,"p-inputwrapper-filled":this.props.value&&this.props.value.length>0,"p-inputwrapper-focus":this.state.focused||this.state.overlayVisible},this.props.className),i=t.classNames("p-multiselect-trigger-icon p-c",this.props.dropdownIcon),r=this.getVisibleOptions(),l=this.renderLabel(),s=this.renderClearIcon();return o.default.createElement("div",{id:this.props.id,className:n,onClick:this.onClick,ref:function(t){return e.container=t},style:this.props.style},o.default.createElement("div",{className:"p-hidden-accessible"},o.default.createElement("input",{ref:this.inputRef,id:this.props.inputId,name:this.props.name,readOnly:!0,type:"text",onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,role:"listbox","aria-haspopup":"listbox","aria-labelledby":this.props.ariaLabelledBy,"aria-expanded":this.state.overlayVisible,disabled:this.props.disabled,tabIndex:this.props.tabIndex})),l,s,o.default.createElement("div",{className:"p-multiselect-trigger"},o.default.createElement("span",{className:i})),o.default.createElement(A,p({ref:this.overlayRef,visibleOptions:r},this.props,{onClick:this.onPanelClick,onOverlayHide:this.hide,filterValue:this.state.filter,hasFilter:this.hasFilter,onFilterInputChange:this.onFilterInputChange,onCloseClick:this.onCloseClick,onSelectAll:this.onSelectAll,getOptionLabel:this.getOptionLabel,getOptionRenderKey:this.getOptionRenderKey,isOptionDisabled:this.isOptionDisabled,getOptionGroupChildren:this.getOptionGroupChildren,getOptionGroupLabel:this.getOptionGroupLabel,getOptionGroupRenderKey:this.getOptionGroupRenderKey,isSelected:this.isSelected,getSelectedOptionIndex:this.getSelectedOptionIndex,isAllSelected:this.isAllSelected,onOptionSelect:this.onOptionSelect,allowOptionSelect:this.allowOptionSelect,onOptionKeyDown:this.onOptionKeyDown,in:this.state.overlayVisible,onEnter:this.onOverlayEnter,onEntered:this.onOverlayEntered,onExit:this.onOverlayExit,onExited:this.onOverlayExited})))}}]),a}();S(q,"defaultProps",{id:null,inputRef:null,name:null,value:null,options:null,optionLabel:null,optionValue:null,optionDisabled:null,optionGroupLabel:null,optionGroupChildren:null,optionGroupTemplate:null,display:"comma",style:null,className:null,panelClassName:null,panelStyle:null,virtualScrollerOptions:null,scrollHeight:"200px",placeholder:null,fixedPlaceholder:!1,disabled:!1,showClear:!1,filter:!1,filterBy:null,filterMatchMode:"contains",filterPlaceholder:null,filterLocale:void 0,emptyFilterMessage:"No results found",resetFilterOnHide:!1,tabIndex:0,dataKey:null,inputId:null,appendTo:null,tooltip:null,tooltipOptions:null,maxSelectedLabels:3,selectionLimit:null,selectedItemsLabel:"{0} items selected",ariaLabelledBy:null,itemTemplate:null,selectedItemTemplate:null,panelHeaderTemplate:null,panelFooterTemplate:null,transitionOptions:null,dropdownIcon:"pi pi-chevron-down",showSelectAll:!0,selectAll:!1,onChange:null,onFocus:null,onBlur:null,onShow:null,onHide:null,onFilter:null,onSelectAll:null}),exports.MultiSelect=q;
  