import{r as e}from"./react-DnjLh4X0.js";import"./use-sync-external-store-BwOntpwp.js";import"./react-dom-AUmP0oVs.js";import{c as t}from"./clsx-BeLtu-UY.js";import{t as r}from"./es-toolkit-D_c8uYHv.js";var n=e=>"string"==typeof e&&e.indexOf("%")===e.length-1,i=function(e,t){for(var r=arguments.length,n=new Array(r>2?r-2:0),i=2;i<r;i++)n[i-2]=arguments[i]};function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var h=e.forwardRef((o,s)=>{var{aspect:h,initialDimension:c={width:-1,height:-1},width:u="100%",height:l="100%",minWidth:d=0,minHeight:f,maxHeight:g,children:m,debounce:p=0,id:v,className:b,onResize:y,style:w={}}=o,j=e.useRef(null),O=e.useRef();O.current=y,e.useImperativeHandle(s,()=>j.current);var[P,H]=e.useState({containerWidth:c.width,containerHeight:c.height}),R=e.useCallback((e,t)=>{H(r=>{var n=Math.round(e),i=Math.round(t);return r.containerWidth===n&&r.containerHeight===i?r:{containerWidth:n,containerHeight:i}})},[]);e.useEffect(()=>{var e=e=>{var t,{width:r,height:n}=e[0].contentRect;R(r,n),null===(t=O.current)||void 0===t||t.call(O,r,n)};p>0&&(e=r(e,p,{trailing:!0,leading:!1}));var t=new ResizeObserver(e),{width:n,height:i}=j.current.getBoundingClientRect();return R(n,i),t.observe(j.current),()=>{t.disconnect()}},[R,p]);var E=e.useMemo(()=>{var{containerWidth:t,containerHeight:r}=P;if(t<0||r<0)return null;i(n(u)||n(l),"The width(%s) and height(%s) are both fixed numbers,\n       maybe you don't need to use a ResponsiveContainer.",u,l),i(!h||h>0,"The aspect(%s) must be greater than zero.",h);var o=n(u)?t:u,s=n(l)?r:l;return h&&h>0&&(o?s=o/h:s&&(o=s*h),g&&s>g&&(s=g)),i(o>0||s>0,"The width(%s) and height(%s) of chart should be greater than 0,\n       please check the style of container, or the props width(%s) and height(%s),\n       or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the\n       height and width.",o,s,u,l,d,f,h),e.Children.map(m,t=>e.cloneElement(t,{width:o,height:s,style:a({width:o,height:s},t.props.style)}))},[h,m,l,g,f,d,P,u]);return e.createElement("div",{id:v?"".concat(v):void 0,className:t("recharts-responsive-container",b),style:a(a({},w),{},{width:u,height:l,minWidth:d,minHeight:f,maxHeight:g}),ref:j},e.createElement("div",{style:{width:0,height:0,overflow:"visible"}},E))});export{h as R};
