import{objectWithoutProperties as e,slicedToArray as t,defineProperty as n,extends as o}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import a,{useState as l,useCallback as r}from"react";import{components as i}from"react-select";import s from"classnames";import{useHiddenOptionsData as c}from"../../hooks/useHiddenOptionsData.js";import u from"../../../Counter/Counter.js";import m from"../../../Dialog/Dialog.js";import d from"../../../DialogContentContainer/DialogContentContainer.js";import p from"../../../Tags/Tags.js";import{DROPDOWN_TAG_COLORS as g}from"../../dropdown-constants.js";import f from"./MultiValueContainer.module.scss.js";var h=["children","selectProps"];function v(v){var C=v.children,E=v.selectProps,w=e(v,h),D=E.isDisabled,j=E.placeholder,N=E.inputValue,P=E.selectProps,b=void 0===P?{}:P,I=E.withMandatoryDefaultOptions,O=b.selectedOptions,T=b.onSelectedDelete,k=b.setIsDialogShown,y=b.isDialogShown,M=b.isMultiline,S=C[1],A=l(),x=t(A,2),L=x[0],V=x[1],_=0===O.length&&!N,F=f["tag-with-input-wrapper"],H=s(M?f["multiselect-tag-multi-line"]:f["multiselect-tag-single-line"],n({},f["multiselect-tag-disabled"],D)),K=c({isMultiline:M,ref:L,tagClassName:H,tagWrapperClassName:F,selectedOptionsCount:O.length}),W=K.overflowIndex,B=K.hiddenOptionsCount,U=B>0,q=r((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:O.length;return O.map((function(n,o){var l=Object.keys(g).includes(n.tagColor)?n.tagColor:g.white;return o>=e&&t>o?a.createElement(p,{dataTestId:"value-container-tag",key:n.value,className:H,isClickable:!0,noAnimation:!0,disabled:D,outlined:n.outlined,id:n.value,label:n.label,onDelete:T,onMouseDown:function(e){e.stopPropagation()},readOnly:I&&n.isMandatory,leftAvatar:n.leftAvatar,leftIcon:n.leftIcon,color:l}):null}))}),[O,H,D,T,I]);return a.createElement(i.ValueContainer,o({selectProps:E},w),a.createElement("div",{className:f["value-container"]},_&&a.createElement("div",{className:f["placeholder-container"]},a.createElement(i.Placeholder,w,j)),a.createElement("div",{className:s(f["value-container-tags"],n({},f["without-placeholder"],!_)),ref:function(e){return V(e)},"data-testid":"value-container-tags"},U?a.createElement(a.Fragment,null,q(0,W-1),a.createElement("div",{className:F},q(W-1,W),S),q(W)):a.createElement(a.Fragment,null,q(0,O.length-1),a.createElement("div",{className:F},q(O.length-1),S))),a.createElement("div",null,U&&a.createElement(m,{content:function(){return a.createElement(d,{className:f["value-container-dialog-content"]},q(W))},tooltip:!0,showTrigger:m.hideShowTriggers.CLICK,hideTrigger:m.hideShowTriggers.CLICK_OUTSIDE,open:y,onClick:function(){return k(!0)},onClickOutside:function(){return k(!1)}},a.createElement(u,{kind:u.kinds.LINE,prefix:"+",count:B,onMouseDown:function(e){e.stopPropagation()},noAnimation:!0})))))}export{v as default};
