import{defineProperty as e}from"../../../../../../_virtual/_rollupPluginBabelHelpers.js";import n,{useRef as t,useMemo as o,createRef as r}from"react";import i from"../../../../Chips/Chips.js";import a from"../../../../Flex/Flex.js";import l from"../../../../DialogContentContainer/DialogContentContainer.js";import c from"../../../../Dialog/Dialog.js";import s from"../../../../../hooks/useItemsOverflow/useItemsOverflow.js";import d from"./MultiSelectedValues.module.scss.js";import u from"classnames";import m from"../Trigger/DropdownChip.js";function p(p){var f=p.selectedItems,g=p.onRemove,h=p.renderInput,v=p.disabled,w=p.readOnly,C=t(null),D=t(null),y=o((function(){return f.map((function(){return r()}))}),[f]),E=s({containerRef:C,itemRefs:y,gap:4,deductedSpaceRef:D}),b=o((function(){var e=f.length>E?f.slice(E):[];return{hiddenItems:e,hiddenCount:e.length}}),[f,E]),j=b.hiddenItems,k=b.hiddenCount,x=o((function(){return function(){return n.createElement(l,null,n.createElement(a,{direction:"column",gap:"xs",align:"start",className:d.hiddenChipsDialog},j.map((function(e){return n.createElement(m,{key:"dropdown-chip-dialog-".concat(e.value),item:e,onDelete:function(){return g(e)},className:d.dialogChip,disabled:v,readOnly:w})}))))}}),[j,g,v,w]),I=o((function(){return f.map((function(t,o){var r=E>o;return n.createElement("div",{key:"dropdown-chip-visible-".concat(t.value),ref:y[o],className:u(e({},d.hiddenChip,!r)),"aria-hidden":!r,"data-testid":"dropdown-chip-".concat(t.value)},n.createElement(m,{item:t,onDelete:function(){return g(t)},disabled:v,readOnly:w}))}))}),[f,E,g,y,v,w]);return(null==f?void 0:f.length)?n.createElement(a,{align:"center",wrap:!1,gap:"xs",ref:C,className:d.containerWrapper},I,n.createElement(a,{ref:D,gap:"xs"},k>0&&n.createElement("div",{onClick:function(e){e.stopPropagation()},onKeyDown:function(e){e.stopPropagation()},onMouseDown:function(e){e.stopPropagation()}},n.createElement(c,{content:x,showTrigger:["click","enter"],hideTrigger:["clickoutside","enter"],position:"bottom",moveBy:{main:4},hideWhenReferenceHidden:!0,addKeyboardHideShowTriggersByDefault:!0},n.createElement(i,{label:"+ ".concat(k),readOnly:!0,noMargin:!0,ariaLabel:"+".concat(k,". ").concat(f.length-k," items are visible out of ").concat(f.length),"data-testid":"dropdown-overflow-counter",className:d.overflowCounter,onClick:function(){},onMouseDown:function(e){e.preventDefault()}}))),h&&n.createElement("div",{className:d.inputWrapper},h()))):null}export{p as default};
//# sourceMappingURL=MultiSelectedValues.js.map
