"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/utils"),n=require("primereact/csstransition"),i=require("primereact/ripple"),o=require("primereact/overlayservice"),r=require("primereact/portal"),l=require("primereact/api");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=s(e),p=s(l);function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var n=0;n=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:o}}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 r,l=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return l=e.done,e},e:function(e){s=!0,r=e},f:function(){try{l||null==n.return||n.return()}finally{if(s)throw r}}}}function S(e,t){if(e){if("string"==typeof e)return g(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)?g(e,t):void 0}}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);ni.width-t.DomHandler.calculateScrollbarWidth()&&(this.element.style.left="-100%")}},{key:"onOptionSelect",value:function(e){this.props.onOptionSelect&&this.props.onOptionSelect(e)}},{key:"onKeyDown",value:function(e,t){var n=e.currentTarget.parentElement;switch(e.key){case"Down":case"ArrowDown":var i=this.findNextItem(n);i&&i.children[0].focus();break;case"Up":case"ArrowUp":var o=this.findPrevItem(n);o&&o.children[0].focus();break;case"Right":case"ArrowRight":this.isOptionGroup(t)&&(this.state.activeOption===t?n.children[1].children[0].children[0].focus():this.setState({activeOption:t}));break;case"Left":case"ArrowLeft":this.setState({activeOption:null});var r=e.currentTarget.parentElement.parentElement.previousElementSibling;r&&r.focus();break;case"Enter":this.onOptionClick(e,t);break;case"Tab":case"Escape":this.props.onPanelHide&&(this.props.onPanelHide(),e.preventDefault())}e.preventDefault()}},{key:"findNextItem",value:function(e){var n=e.nextElementSibling;return n?t.DomHandler.hasClass(n,"p-disabled")||!t.DomHandler.hasClass(n,"p-cascadeselect-item")?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-cascadeselect-item")?this.findPrevItem(n):n:null}},{key:"onOptionClick",value:function(e,t){this.isOptionGroup(t)?(this.setState({activeOption:this.state.activeOption===t?null:t}),this.props.onOptionGroupSelect&&this.props.onOptionGroupSelect({originalEvent:e,value:t})):this.props.onOptionSelect&&this.props.onOptionSelect({originalEvent:e,value:this.getOptionValue(t)})}},{key:"onOptionGroupSelect",value:function(e){this.props.onOptionGroupSelect&&this.props.onOptionGroupSelect(e)}},{key:"getOptionLabel",value:function(e){return this.props.optionLabel?t.ObjectUtils.resolveFieldData(e,this.props.optionLabel):e}},{key:"getOptionValue",value:function(e){return this.props.optionValue?t.ObjectUtils.resolveFieldData(e,this.props.optionValue):e}},{key:"getOptionGroupLabel",value:function(e){return this.props.optionGroupLabel?t.ObjectUtils.resolveFieldData(e,this.props.optionGroupLabel):null}},{key:"getOptionGroupChildren",value:function(e){return t.ObjectUtils.resolveFieldData(e,this.props.optionGroupChildren[this.props.level])}},{key:"isOptionGroup",value:function(e){return Object.prototype.hasOwnProperty.call(e,this.props.optionGroupChildren[this.props.level])}},{key:"getOptionLabelToRender",value:function(e){return this.isOptionGroup(e)?this.getOptionGroupLabel(e):this.getOptionLabel(e)}},{key:"renderSubmenu",value:function(e){return this.isOptionGroup(e)&&this.state.activeOption===e?a.default.createElement(s,{options:this.getOptionGroupChildren(e),className:"p-cascadeselect-sublist",selectionPath:this.props.selectionPath,optionLabel:this.props.optionLabel,optionValue:this.props.optionValue,level:this.props.level+1,onOptionSelect:this.onOptionSelect,onOptionGroupSelect:this.onOptionGroupSelect,parentActive:this.state.activeOption===e,optionGroupLabel:this.props.optionGroupLabel,optionGroupChildren:this.props.optionGroupChildren,dirty:this.props.dirty,template:this.props.template,onPanelHide:this.props.onPanelHide}):null}},{key:"renderOption",value:function(e,n){var o=this,r=t.classNames("p-cascadeselect-item",{"p-cascadeselect-item-group":this.isOptionGroup(e),"p-cascadeselect-item-active p-highlight":this.state.activeOption===e},e.className),l=this.renderSubmenu(e),s=this.props.template?t.ObjectUtils.getJSXElement(this.props.template,this.getOptionValue(e)):a.default.createElement("span",{className:"p-cascadeselect-item-text"},this.getOptionLabelToRender(e)),p=this.isOptionGroup(e)&&a.default.createElement("span",{className:"p-cascadeselect-group-icon pi pi-angle-right"});return a.default.createElement("li",{key:this.getOptionLabelToRender(e)+"_"+n,className:r,style:e.style,role:"none"},a.default.createElement("div",{className:"p-cascadeselect-item-content",onClick:function(t){return o.onOptionClick(t,e)},tabIndex:0,onKeyDown:function(t){return o.onKeyDown(t,e)}},s,p,a.default.createElement(i.Ripple,null)),l)}},{key:"renderMenu",value:function(){var e=this;return this.props.options?this.props.options.map((function(t,n){return e.renderOption(t,n)})):null}},{key:"render",value:function(){var e=this,n=t.classNames("p-cascadeselect-panel p-cascadeselect-items",this.props.className),i=this.renderMenu();return a.default.createElement("ul",{ref:function(t){return e.element=t},className:n,role:"listbox","aria-orientation":"horizontal"},i)}}]),s}();function L(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=C(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0,o=function(){};return{s:o,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:o}}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 r,l=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return l=e.done,e},e:function(e){s=!0,r=e},f:function(){try{l||null==n.return||n.return()}finally{if(s)throw r}}}}function C(e,t){if(e){if("string"==typeof e)return G(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)?G(e,t):void 0}}function G(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n