"use strict";var stringUtil=require("./stringUtil-623229ca.js"),React=require("react"),classNames=require("classnames");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function _interopNamespace(r){if(r&&r.__esModule)return r;var a=Object.create(null);return r&&Object.keys(r).forEach(function(e){var t;"default"!==e&&(t=Object.getOwnPropertyDescriptor(r,e),Object.defineProperty(a,e,t.get?t:{enumerable:!0,get:function(){return r[e]}}))}),a.default=r,Object.freeze(a)}var React__namespace=_interopNamespace(React),classNames__default=_interopDefaultLegacy(classNames),__assign=function(){return(__assign=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)},__rest=function(e,t){var r={};for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,s=Object.getOwnPropertySymbols(e);a<s.length;a++)t.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(e,s[a])&&(r[s[a]]=e[s[a]]);return r},prefixCls="dmc-adaptive-more",prefixClsItem=prefixCls+"-item",getAttrNum=function(e,t){e=""+e.getPropertyValue(t).replace("px","");return e?parseFloat(e):0},AdaptiveMore=function(e){var u=e.className,t=e.children,r=e.renderMore,p=e.moreLabel,a=e.getProcess,e=__rest(e,["className","children","renderMore","moreLabel","getProcess"]),s=stringUtil._default(),d=s[0],i=s[1].width,s=stringUtil._default(),f=s[0],n=s[1].width,c=React__namespace.useRef(null),m=React__namespace.useRef({}),l=React__namespace.useMemo(function(){return React__namespace.Children.toArray(t).map(function(e){return stringUtil.cloneElement(e,{className:classNames__default.default(prefixClsItem,e.props.className)})})},[t]),s=React__namespace.useState({viewList:l,hiddenList:[]}),o=s[0],_=s[1],s=(React__namespace.useEffect(function(){var r={},a=c.current.querySelectorAll("."+prefixClsItem);l.forEach(function(e,t){t=window.getComputedStyle(a[t]);r[e.key]=getAttrNum(t,"width")+getAttrNum(t,"margin-left")+getAttrNum(t,"margin-right")}),m.current=r},[l]),React__namespace.useEffect(function(){var r=0,a=[],s=[];l.forEach(function(e){var t=m.current[e.key]||0;((r+=t)<=i-(n||0)?a:s).push(e)}),_({viewList:a,hiddenList:s})},[l,i,n,a]),classNames__default.default(prefixCls,u)),a=r?r(o.hiddenList):!!o.hiddenList.length&&stringUtil.jsxRuntime.exports.jsx(stringUtil.Dropmenu,__assign({onlyText:!0,renderOverlay:function(){return stringUtil.jsxRuntime.exports.jsx(React__namespace.Fragment,{children:o.hiddenList},void 0)}},{children:p}),void 0);return stringUtil.jsxRuntime.exports.jsxs("div",__assign({},e,{ref:d,className:s},{children:[stringUtil.jsxRuntime.exports.jsx("div",__assign({className:prefixCls+"-hidden",ref:c},{children:l}),void 0),stringUtil.jsxRuntime.exports.jsx("div",__assign({className:prefixCls+"-inner"},{children:o.viewList}),void 0),stringUtil.jsxRuntime.exports.jsx("div",__assign({className:prefixCls+"-more",ref:f},{children:a}),void 0)]}),void 0)},AdaptiveMoreMemo=(AdaptiveMore.displayName="AdaptiveMore",React__namespace.memo(AdaptiveMore));AdaptiveMoreMemo.displayName="AdaptiveMoreMemo",exports.AdaptiveMore=AdaptiveMore;
