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,D=e(v,h),w=E.isDisabled,P=E.placeholder,j=E.inputValue,I=E.selectProps,N=void 0===I?{}:I,O=E.withMandatoryDefaultOptions,T=N.selectedOptions,b=N.onSelectedDelete,M=N.setIsDialogShown,k=N.isDialogShown,y=N.isMultiline,A=C[1],S=l(),x=t(S,2),L=x[0],V=x[1],_=0===T.length&&!j,F=f["tag-with-input-wrapper"],H=s(y?f["multiselect-tag-multi-line"]:f["multiselect-tag-single-line"],n({},f["multiselect-tag-disabled"],w)),K=c({isMultiline:y,ref:L,tagClassName:H,tagWrapperClassName:F,selectedOptionsCount:T.length}),R=K.overflowIndex,W=K.hiddenOptionsCount,B=W>0,U=r((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:T.length;return T.map((function(n,o){var l=Object.keys(g).includes(n.tagColor)?n.tagColor:g.PRIMARY;return o>=e&&t>o?a.createElement(p,{dataTestId:"value-container-tag",key:n.value,className:H,noAnimation:!0,disabled:w,id:n.value,label:n.label,onDelete:b,onMouseDown:function(e){e.stopPropagation()},readOnly:O&&n.isMandatory,leftAvatar:n.leftAvatar,leftIcon:n.leftIcon,color:l}):null}))}),[T,H,w,b,O]);return a.createElement(i.ValueContainer,o({selectProps:E},D),a.createElement("div",{className:f["value-container"]},_&&a.createElement("div",{className:f["placeholder-container"]},a.createElement(i.Placeholder,D,P)),a.createElement("div",{className:s(f["value-container-tags"],n({},f["without-placeholder"],!_)),ref:function(e){return V(e)},"data-testid":"value-container-tags"},B?a.createElement(a.Fragment,null,U(0,R-1),a.createElement("div",{className:F},U(R-1,R),A),U(R)):a.createElement(a.Fragment,null,U(0,T.length-1),a.createElement("div",{className:F},U(T.length-1),A))),a.createElement("div",null,B&&a.createElement(m,{content:function(){return a.createElement(d,{className:f["value-container-dialog-content"]},U(R))},tooltip:!0,showTrigger:m.hideShowTriggers.CLICK,hideTrigger:m.hideShowTriggers.CLICK_OUTSIDE,open:k,onClick:function(){return M(!0)},onClickOutside:function(){return M(!1)}},a.createElement(u,{kind:u.kinds.LINE,prefix:"+",count:W,onMouseDown:function(e){e.stopPropagation()},noAnimation:!0})))))}export{v as default};
