import{r as e}from"./react-DAXU6W__.js";import"./use-sync-external-store-1RlyKR5I.js";import{c as t}from"./clsx-BeLtu-UY.js";import{t as r}from"./es-toolkit-wXpXWs0x.js";import"./react-dom-8wXINnbn.js";var i=e=>"string"==typeof e&&e.indexOf("%")===e.length-1,n=e=>("number"==typeof e||e instanceof Number)&&!(e=>"number"==typeof e&&e!=+e)(e),h=function(e,t){for(var r=arguments.length,i=new Array(r>2?r-2:0),n=2;n<r;n++)i[n-2]=arguments[n]},a=(e,t,r)=>{var{width:n="100%",height:h="100%",aspect:a,maxHeight:o}=r,c=i(n)?e:Number(n),s=i(h)?t:Number(h);return a&&a>0&&(c?s=c/a:s&&(c=s*a),o&&s>o&&(s=o)),{calculatedWidth:c,calculatedHeight:s}},o={width:0,height:0,overflow:"visible"},c={width:0,overflowX:"visible"},s={height:0,overflowY:"visible"},d={},u=e=>{var{width:t,height:r}=e,n=i(t),h=i(r);return n&&h?o:n?c:h?s:d};function l(e){return"number"==typeof e&&e>0&&Number.isFinite(e)}function g(){return g=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)({}).hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},g.apply(null,arguments)}function v(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function f(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?v(Object(r),!0).forEach(function(t){m(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):v(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function m(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 i=r.call(e,t);if("object"!=typeof i)return i;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 p=e.createContext({width:-1,height:-1});function w(t){var{children:r,width:i,height:n}=t,h=e.useMemo(()=>({width:i,height:n}),[i,n]);return i<=0||n<=0?null:e.createElement(p.Provider,{value:h},r)}var b=e.forwardRef((i,n)=>{var{aspect:o,initialDimension:c={width:-1,height:-1},width:s,height:d,minWidth:l=0,minHeight:g,maxHeight:v,children:m,debounce:p=0,id:b,className:y,onResize:O,style:j={}}=i,H=e.useRef(null),P=e.useRef();P.current=O,e.useImperativeHandle(n,()=>H.current);var[x,E]=e.useState({containerWidth:c.width,containerHeight:c.height}),W=e.useCallback((e,t)=>{E(r=>{var i=Math.round(e),n=Math.round(t);return r.containerWidth===i&&r.containerHeight===n?r:{containerWidth:i,containerHeight:n}})},[]);e.useEffect(()=>{var e=e=>{var t,{width:r,height:i}=e[0].contentRect;W(r,i),null===(t=P.current)||void 0===t||t.call(P,r,i)};p>0&&(e=r(e,p,{trailing:!0,leading:!1}));var t=new ResizeObserver(e),{width:i,height:n}=H.current.getBoundingClientRect();return W(i,n),t.observe(H.current),()=>{t.disconnect()}},[W,p]);var{containerWidth:R,containerHeight:N}=x;h(!o||o>0,"The aspect(%s) must be greater than zero.",o);var{calculatedWidth:D,calculatedHeight:S}=a(R,N,{width:s,height:d,aspect:o,maxHeight:v});return h(D>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.",D,S,s,d,l,g,o),e.createElement("div",{id:b?"".concat(b):void 0,className:t("recharts-responsive-container",y),style:f(f({},j),{},{width:s,height:d,minWidth:l,minHeight:g,maxHeight:v}),ref:H},e.createElement("div",{style:u({width:s,height:d})},e.createElement(w,{width:D,height:S},m)))}),y=e.forwardRef((t,r)=>{var i=e.useContext(p);if(l(i.width)&&l(i.height))return t.children;var{width:h,height:o}=function(e){var{width:t,height:r,aspect:i}=e,n=t,h=r;return void 0===n&&void 0===h?(n="100%",h="100%"):void 0===n?n=i&&i>0?void 0:"100%":void 0===h&&(h=i&&i>0?void 0:"100%"),{width:n,height:h}}({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:c,calculatedHeight:s}=a(void 0,void 0,{width:h,height:o,aspect:t.aspect,maxHeight:t.maxHeight});return n(c)&&n(s)?e.createElement(w,{width:c,height:s},t.children):e.createElement(b,g({},t,{width:h,height:o,ref:r}))});export{y as R};
