diff --git a/frontend/src/components/RestoreModal.tsx b/frontend/src/components/RestoreModal.tsx index 860882ccb..a462d195e 100644 --- a/frontend/src/components/RestoreModal.tsx +++ b/frontend/src/components/RestoreModal.tsx @@ -210,12 +210,12 @@ export function RestoreModal({ onClose, onRestore, onSuccess }: RestoreModalProp ) : ( )} - {overwrite ? 'Update existing items' : 'Add new items only'} + {overwrite ? 'Replace existing data' : 'Keep existing data'}

{overwrite - ? 'Replace data for items that already exist on this system' - : 'Items that already exist on this system will not be changed'} + ? 'Overwrite items that already exist with backup data' + : 'Only restore items that don\'t already exist'}

diff --git a/static/assets/index-C9aeLRXp.js b/static/assets/index-CycmYzoY.js similarity index 97% rename from static/assets/index-C9aeLRXp.js rename to static/assets/index-CycmYzoY.js index 0f9be0bba..e8d2551e0 100644 --- a/static/assets/index-C9aeLRXp.js +++ b/static/assets/index-CycmYzoY.js @@ -8596,7 +8596,7 @@ Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${ax(t. A`).concat(r,",").concat(r,",0,").concat(+(N>180),",").concat(+(d>0),",").concat(w.x,",").concat(w.y,` A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(A.x,",").concat(A.y,"Z")}else M+="L".concat(e,",").concat(n,"Z");return M},nLe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},rZ=t=>{var e=ei(t,nLe),{cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:d,className:h}=e;if(s0&&Math.abs(c-d)<360?y=tLe({cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:Math.min(v,m/2),forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:d}):y=nZ({cx:n,cy:r,innerRadius:i,outerRadius:s,startAngle:c,endAngle:d}),E.createElement("path",pR({},Cs(e),{className:g,d:y}))};function rLe(t,e,n){if(t==="horizontal")return[{x:e.x,y:n.top},{x:e.x,y:n.top+n.height}];if(t==="vertical")return[{x:n.left,y:e.y},{x:n.left+n.width,y:e.y}];if(OK(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:s,outerRadius:a,angle:o}=e,l=Xr(r,i,s,o),c=Xr(r,i,a,o);return[{x:l.x,y:l.y},{x:c.x,y:c.y}]}return tZ(e)}}var nN={},rN={},iN={},d$;function iLe(){return d$||(d$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=WK();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(iN)),iN}var f$;function sLe(){return f$||(f$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=iLe();function n(r){return r?(r=e.toNumber(r),r===1/0||r===-1/0?(r<0?-1:1)*Number.MAX_VALUE:r===r?r:0):r===0?r:0}t.toFinite=n})(rN)),rN}var h$;function aLe(){return h$||(h$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=qK(),n=sLe();function r(i,s,a){a&&typeof a!="number"&&e.isIterateeCall(i,s,a)&&(s=a=void 0),i=n.toFinite(i),s===void 0?(s=i,i=0):s=n.toFinite(s),a=a===void 0?ie?1:t>=e?0:NaN}function cLe(t,e){return t==null||e==null?NaN:et?1:e>=t?0:NaN}function aO(t){let e,n,r;t.length!==2?(e=Yu,n=(o,l)=>Yu(t(o),l),r=(o,l)=>t(o)-l):(e=t===Yu||t===cLe?t:uLe,n=t,r=t);function i(o,l,c=0,d=o.length){if(c>>1;n(o[h],l)<0?c=h+1:d=h}while(c>>1;n(o[h],l)<=0?c=h+1:d=h}while(cc&&r(o[h-1],l)>-r(o[h],l)?h-1:h}return{left:i,center:a,right:s}}function uLe(){return 0}function sZ(t){return t===null?NaN:+t}function*dLe(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const fLe=aO(Yu),gb=fLe.right;aO(sZ).center;class m$ extends Map{constructor(e,n=mLe){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),e!=null)for(const[r,i]of e)this.set(r,i)}get(e){return super.get(g$(this,e))}has(e){return super.has(g$(this,e))}set(e,n){return super.set(hLe(this,e),n)}delete(e){return super.delete(pLe(this,e))}}function g$({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function hLe({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function pLe({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function mLe(t){return t!==null&&typeof t=="object"?t.valueOf():t}function gLe(t=Yu){if(t===Yu)return aZ;if(typeof t!="function")throw new TypeError("compare is not a function");return(e,n)=>{const r=t(e,n);return r||r===0?r:(t(n,n)===0)-(t(e,e)===0)}}function aZ(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(te?1:0)}const xLe=Math.sqrt(50),bLe=Math.sqrt(10),vLe=Math.sqrt(2);function OS(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),s=r/Math.pow(10,i),a=s>=xLe?10:s>=bLe?5:s>=vLe?2:1;let o,l,c;return i<0?(c=Math.pow(10,-i)/a,o=Math.round(t*c),l=Math.round(e*c),o/ce&&--l,c=-c):(c=Math.pow(10,i)*a,o=Math.round(t/c),l=Math.round(e/c),o*ce&&--l),l0))return[];if(t===e)return[t];const r=e=i))return[];const o=s-i+1,l=new Array(o);if(r)if(a<0)for(let c=0;c=r)&&(n=r);return n}function b$(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function oZ(t,e,n=0,r=1/0,i){if(e=Math.floor(e),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(t.length-1,r)),!(n<=e&&e<=r))return t;for(i=i===void 0?aZ:gLe(i);r>n;){if(r-n>600){const l=r-n+1,c=e-n+1,d=Math.log(l),h=.5*Math.exp(2*d/3),g=.5*Math.sqrt(d*h*(l-h)/l)*(c-l/2<0?-1:1),m=Math.max(n,Math.floor(e-c*h/l+g)),v=Math.min(r,Math.floor(e+(l-c)*h/l+g));oZ(t,e,m,v,i)}const s=t[e];let a=n,o=r;for(ux(t,n,e),i(t[r],s)>0&&ux(t,n,r);a0;)--o}i(t[n],s)===0?ux(t,n,o):(++o,ux(t,o,r)),o<=e&&(n=o+1),e<=o&&(r=o-1)}return t}function ux(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function yLe(t,e,n){if(t=Float64Array.from(dLe(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return b$(t);if(e>=1)return x$(t);var r,i=(r-1)*e,s=Math.floor(i),a=x$(oZ(t,s).subarray(0,s+1)),o=b$(t.subarray(s+1));return a+(o-a)*(i-s)}}function _Le(t,e,n=sZ){if(!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return+n(t[0],0,t);if(e>=1)return+n(t[r-1],r-1,t);var r,i=(r-1)*e,s=Math.floor(i),a=+n(t[s],s,t),o=+n(t[s+1],s+1,t);return a+(o-a)*(i-s)}}function SLe(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((e-t)/n))|0,s=new Array(i);++r>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?p_(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?p_(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=ELe.exec(t))?new Hs(e[1],e[2],e[3],1):(e=ALe.exec(t))?new Hs(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=TLe.exec(t))?p_(e[1],e[2],e[3],e[4]):(e=CLe.exec(t))?p_(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=NLe.exec(t))?E$(e[1],e[2]/100,e[3]/100,1):(e=kLe.exec(t))?E$(e[1],e[2]/100,e[3]/100,e[4]):v$.hasOwnProperty(t)?S$(v$[t]):t==="transparent"?new Hs(NaN,NaN,NaN,0):null}function S$(t){return new Hs(t>>16&255,t>>8&255,t&255,1)}function p_(t,e,n,r){return r<=0&&(t=e=n=NaN),new Hs(t,e,n,r)}function DLe(t){return t instanceof xb||(t=F0(t)),t?(t=t.rgb(),new Hs(t.r,t.g,t.b,t.opacity)):new Hs}function vR(t,e,n,r){return arguments.length===1?DLe(t):new Hs(t,e,n,r??1)}function Hs(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}cO(Hs,vR,cZ(xb,{brighter(t){return t=t==null?LS:Math.pow(LS,t),new Hs(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?I0:Math.pow(I0,t),new Hs(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Hs(wf(this.r),wf(this.g),wf(this.b),jS(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:w$,formatHex:w$,formatHex8:OLe,formatRgb:M$,toString:M$}));function w$(){return`#${cf(this.r)}${cf(this.g)}${cf(this.b)}`}function OLe(){return`#${cf(this.r)}${cf(this.g)}${cf(this.b)}${cf((isNaN(this.opacity)?1:this.opacity)*255)}`}function M$(){const t=jS(this.opacity);return`${t===1?"rgb(":"rgba("}${wf(this.r)}, ${wf(this.g)}, ${wf(this.b)}${t===1?")":`, ${t})`}`}function jS(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function wf(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function cf(t){return t=wf(t),(t<16?"0":"")+t.toString(16)}function E$(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new So(t,e,n,r)}function uZ(t){if(t instanceof So)return new So(t.h,t.s,t.l,t.opacity);if(t instanceof xb||(t=F0(t)),!t)return new So;if(t instanceof So)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),s=Math.max(e,n,r),a=NaN,o=s-i,l=(s+i)/2;return o?(e===s?a=(n-r)/o+(n0&&l<1?0:a,new So(a,o,l,t.opacity)}function LLe(t,e,n,r){return arguments.length===1?uZ(t):new So(t,e,n,r??1)}function So(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}cO(So,LLe,cZ(xb,{brighter(t){return t=t==null?LS:Math.pow(LS,t),new So(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?I0:Math.pow(I0,t),new So(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new Hs(aN(t>=240?t-240:t+120,i,r),aN(t,i,r),aN(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new So(A$(this.h),m_(this.s),m_(this.l),jS(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=jS(this.opacity);return`${t===1?"hsl(":"hsla("}${A$(this.h)}, ${m_(this.s)*100}%, ${m_(this.l)*100}%${t===1?")":`, ${t})`}`}}));function A$(t){return t=(t||0)%360,t<0?t+360:t}function m_(t){return Math.max(0,Math.min(1,t||0))}function aN(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const uO=t=>()=>t;function jLe(t,e){return function(n){return t+n*e}}function ILe(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function ULe(t){return(t=+t)==1?dZ:function(e,n){return n-e?ILe(e,n,t):uO(isNaN(e)?n:e)}}function dZ(t,e){var n=e-t;return n?jLe(t,n):uO(isNaN(t)?e:t)}const T$=(function t(e){var n=ULe(e);function r(i,s){var a=n((i=vR(i)).r,(s=vR(s)).r),o=n(i.g,s.g),l=n(i.b,s.b),c=dZ(i.opacity,s.opacity);return function(d){return i.r=a(d),i.g=o(d),i.b=l(d),i.opacity=c(d),i+""}}return r.gamma=t,r})(1);function FLe(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(s){for(i=0;in&&(s=e.slice(n,s),o[a]?o[a]+=s:o[++a]=s),(r=r[0])===(i=i[0])?o[a]?o[a]+=i:o[++a]=i:(o[++a]=null,l.push({i:a,x:IS(r,i)})),n=oN.lastIndex;return ne&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function YLe(t,e,n){var r=t[0],i=t[1],s=e[0],a=e[1];return i2?ZLe:YLe,l=c=null,h}function h(g){return g==null||isNaN(g=+g)?s:(l||(l=o(t.map(r),e,n)))(r(a(g)))}return h.invert=function(g){return a(i((c||(c=o(e,t.map(r),IS)))(g)))},h.domain=function(g){return arguments.length?(t=Array.from(g,US),d()):t.slice()},h.range=function(g){return arguments.length?(e=Array.from(g),d()):e.slice()},h.rangeRound=function(g){return e=Array.from(g),n=dO,d()},h.clamp=function(g){return arguments.length?(a=g?!0:_s,d()):a!==_s},h.interpolate=function(g){return arguments.length?(n=g,d()):n},h.unknown=function(g){return arguments.length?(s=g,h):s},function(g,m){return r=g,i=m,d()}}function fO(){return fM()(_s,_s)}function QLe(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function FS(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function Mm(t){return t=FS(Math.abs(t)),t?t[1]:NaN}function JLe(t,e){return function(n,r){for(var i=n.length,s=[],a=0,o=t[0],l=0;i>0&&o>0&&(l+o+1>r&&(o=Math.max(1,r-l)),s.push(n.substring(i-=o,i+o)),!((l+=o+1)>r));)o=t[a=(a+1)%t.length];return s.reverse().join(e)}}function eje(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var tje=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function z0(t){if(!(e=tje.exec(t)))throw new Error("invalid format: "+t);var e;return new hO({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}z0.prototype=hO.prototype;function hO(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}hO.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function nje(t){e:for(var e=t.length,n=1,r=-1,i;n0&&(r=0);break}return r>0?t.slice(0,r)+t.slice(i+1):t}var fZ;function rje(t,e){var n=FS(t,e);if(!n)return t+"";var r=n[0],i=n[1],s=i-(fZ=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,a=r.length;return s===a?r:s>a?r+new Array(s-a+1).join("0"):s>0?r.slice(0,s)+"."+r.slice(s):"0."+new Array(1-s).join("0")+FS(t,Math.max(0,e+s-1))[0]}function N$(t,e){var n=FS(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const k$={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:QLe,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>N$(t*100,e),r:N$,s:rje,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function R$(t){return t}var P$=Array.prototype.map,D$=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function ije(t){var e=t.grouping===void 0||t.thousands===void 0?R$:JLe(P$.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",s=t.numerals===void 0?R$:eje(P$.call(t.numerals,String)),a=t.percent===void 0?"%":t.percent+"",o=t.minus===void 0?"−":t.minus+"",l=t.nan===void 0?"NaN":t.nan+"";function c(h){h=z0(h);var g=h.fill,m=h.align,v=h.sign,y=h.symbol,b=h.zero,x=h.width,M=h.comma,w=h.precision,A=h.trim,T=h.type;T==="n"?(M=!0,T="g"):k$[T]||(w===void 0&&(w=12),A=!0,T="g"),(b||g==="0"&&m==="=")&&(b=!0,g="0",m="=");var R=y==="$"?n:y==="#"&&/[boxX]/.test(T)?"0"+T.toLowerCase():"",C=y==="$"?r:/[%p]/.test(T)?a:"",I=k$[T],N=/[defgprs%]/.test(T);w=w===void 0?6:/[gprs]/.test(T)?Math.max(1,Math.min(21,w)):Math.max(0,Math.min(20,w));function D(z){var j=R,W=C,P,$,K;if(T==="c")W=I(z)+W,z="";else{z=+z;var G=z<0||1/z<0;if(z=isNaN(z)?l:I(Math.abs(z),w),A&&(z=nje(z)),G&&+z==0&&v!=="+"&&(G=!1),j=(G?v==="("?v:o:v==="-"||v==="("?"":v)+j,W=(T==="s"?D$[8+fZ/3]:"")+W+(G&&v==="("?")":""),N){for(P=-1,$=z.length;++P<$;)if(K=z.charCodeAt(P),48>K||K>57){W=(K===46?i+z.slice(P+1):z.slice(P))+W,z=z.slice(0,P);break}}}M&&!b&&(z=e(z,1/0));var Z=j.length+z.length+W.length,Q=Z>1)+j+z+W+Q.slice(Z);break;default:z=Q+j+z+W;break}return s(z)}return D.toString=function(){return h+""},D}function d(h,g){var m=c((h=z0(h),h.type="f",h)),v=Math.max(-8,Math.min(8,Math.floor(Mm(g)/3)))*3,y=Math.pow(10,-v),b=D$[8+v/3];return function(x){return m(y*x)+b}}return{format:c,formatPrefix:d}}var g_,pO,hZ;sje({thousands:",",grouping:[3],currency:["$",""]});function sje(t){return g_=ije(t),pO=g_.format,hZ=g_.formatPrefix,g_}function aje(t){return Math.max(0,-Mm(Math.abs(t)))}function oje(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Mm(e)/3)))*3-Mm(Math.abs(t)))}function lje(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Mm(e)-Mm(t))+1}function pZ(t,e,n,r){var i=xR(t,e,n),s;switch(r=z0(r??",f"),r.type){case"s":{var a=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(s=oje(i,a))&&(r.precision=s),hZ(r,a)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(s=lje(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=s-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(s=aje(i))&&(r.precision=s-(r.type==="%")*2);break}}return pO(r)}function md(t){var e=t.domain;return t.ticks=function(n){var r=e();return mR(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return pZ(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,s=r.length-1,a=r[i],o=r[s],l,c,d=10;for(o0;){if(c=gR(a,o,n),c===l)return r[i]=a,r[s]=o,e(r);if(c>0)a=Math.floor(a/c)*c,o=Math.ceil(o/c)*c;else if(c<0)a=Math.ceil(a*c)/c,o=Math.floor(o*c)/c;else break;l=c}return t},t}function mZ(){var t=fO();return t.copy=function(){return bb(t,mZ())},io.apply(t,arguments),md(t)}function gZ(t){var e;function n(r){return r==null||isNaN(r=+r)?e:r}return n.invert=n,n.domain=n.range=function(r){return arguments.length?(t=Array.from(r,US),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return gZ(t).unknown(e)},t=arguments.length?Array.from(t,US):[0,1],md(n)}function xZ(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],s=t[r],a;return sMath.pow(t,e)}function hje(t){return t===Math.E?Math.log:t===10&&Math.log10||t===2&&Math.log2||(t=Math.log(t),e=>Math.log(e)/t)}function j$(t){return(e,n)=>-t(-e,n)}function mO(t){const e=t(O$,L$),n=e.domain;let r=10,i,s;function a(){return i=hje(r),s=fje(r),n()[0]<0?(i=j$(i),s=j$(s),t(cje,uje)):t(O$,L$),e}return e.base=function(o){return arguments.length?(r=+o,a()):r},e.domain=function(o){return arguments.length?(n(o),a()):n()},e.ticks=o=>{const l=n();let c=l[0],d=l[l.length-1];const h=d0){for(;g<=m;++g)for(v=1;vd)break;x.push(y)}}else for(;g<=m;++g)for(v=r-1;v>=1;--v)if(y=g>0?v/s(-g):v*s(g),!(yd)break;x.push(y)}x.length*2{if(o==null&&(o=10),l==null&&(l=r===10?"s":","),typeof l!="function"&&(!(r%1)&&(l=z0(l)).precision==null&&(l.trim=!0),l=pO(l)),o===1/0)return l;const c=Math.max(1,r*o/e.ticks().length);return d=>{let h=d/s(Math.round(i(d)));return h*rn(xZ(n(),{floor:o=>s(Math.floor(i(o))),ceil:o=>s(Math.ceil(i(o)))})),e}function bZ(){const t=mO(fM()).domain([1,10]);return t.copy=()=>bb(t,bZ()).base(t.base()),io.apply(t,arguments),t}function I$(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function U$(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function gO(t){var e=1,n=t(I$(e),U$(e));return n.constant=function(r){return arguments.length?t(I$(e=+r),U$(e)):e},md(n)}function vZ(){var t=gO(fM());return t.copy=function(){return bb(t,vZ()).constant(t.constant())},io.apply(t,arguments)}function F$(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function pje(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function mje(t){return t<0?-t*t:t*t}function xO(t){var e=t(_s,_s),n=1;function r(){return n===1?t(_s,_s):n===.5?t(pje,mje):t(F$(n),F$(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},md(e)}function bO(){var t=xO(fM());return t.copy=function(){return bb(t,bO()).exponent(t.exponent())},io.apply(t,arguments),t}function gje(){return bO.apply(null,arguments).exponent(.5)}function z$(t){return Math.sign(t)*t*t}function xje(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function yZ(){var t=fO(),e=[0,1],n=!1,r;function i(s){var a=xje(t(s));return isNaN(a)?r:n?Math.round(a):a}return i.invert=function(s){return t.invert(z$(s))},i.domain=function(s){return arguments.length?(t.domain(s),i):t.domain()},i.range=function(s){return arguments.length?(t.range((e=Array.from(s,US)).map(z$)),i):e.slice()},i.rangeRound=function(s){return i.range(s).round(!0)},i.round=function(s){return arguments.length?(n=!!s,i):n},i.clamp=function(s){return arguments.length?(t.clamp(s),i):t.clamp()},i.unknown=function(s){return arguments.length?(r=s,i):r},i.copy=function(){return yZ(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},io.apply(i,arguments),md(i)}function _Z(){var t=[],e=[],n=[],r;function i(){var a=0,o=Math.max(1,e.length);for(n=new Array(o-1);++a0?n[o-1]:t[0],o=n?[r[n-1],e]:[r[c-1],r[c]]},a.unknown=function(l){return arguments.length&&(s=l),a},a.thresholds=function(){return r.slice()},a.copy=function(){return SZ().domain([t,e]).range(i).unknown(s)},io.apply(md(a),arguments)}function wZ(){var t=[.5],e=[0,1],n,r=1;function i(s){return s!=null&&s<=s?e[gb(t,s,0,r)]:n}return i.domain=function(s){return arguments.length?(t=Array.from(s),r=Math.min(t.length,e.length-1),i):t.slice()},i.range=function(s){return arguments.length?(e=Array.from(s),r=Math.min(t.length,e.length-1),i):e.slice()},i.invertExtent=function(s){var a=e.indexOf(s);return[t[a-1],t[a]]},i.unknown=function(s){return arguments.length?(n=s,i):n},i.copy=function(){return wZ().domain(t).range(e).unknown(n)},io.apply(i,arguments)}const lN=new Date,cN=new Date;function mi(t,e,n,r){function i(s){return t(s=arguments.length===0?new Date:new Date(+s)),s}return i.floor=s=>(t(s=new Date(+s)),s),i.ceil=s=>(t(s=new Date(s-1)),e(s,1),t(s),s),i.round=s=>{const a=i(s),o=i.ceil(s);return s-a(e(s=new Date(+s),a==null?1:Math.floor(a)),s),i.range=(s,a,o)=>{const l=[];if(s=i.ceil(s),o=o==null?1:Math.floor(o),!(s0))return l;let c;do l.push(c=new Date(+s)),e(s,o),t(s);while(cmi(a=>{if(a>=a)for(;t(a),!s(a);)a.setTime(a-1)},(a,o)=>{if(a>=a)if(o<0)for(;++o<=0;)for(;e(a,-1),!s(a););else for(;--o>=0;)for(;e(a,1),!s(a););}),n&&(i.count=(s,a)=>(lN.setTime(+s),cN.setTime(+a),t(lN),t(cN),Math.floor(n(lN,cN))),i.every=s=>(s=Math.floor(s),!isFinite(s)||!(s>0)?null:s>1?i.filter(r?a=>r(a)%s===0:a=>i.count(0,a)%s===0):i)),i}const zS=mi(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);zS.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?mi(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):zS);zS.range;const lc=1e3,Xa=lc*60,cc=Xa*60,Mc=cc*24,vO=Mc*7,B$=Mc*30,uN=Mc*365,uf=mi(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*lc)},(t,e)=>(e-t)/lc,t=>t.getUTCSeconds());uf.range;const yO=mi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*lc)},(t,e)=>{t.setTime(+t+e*Xa)},(t,e)=>(e-t)/Xa,t=>t.getMinutes());yO.range;const _O=mi(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Xa)},(t,e)=>(e-t)/Xa,t=>t.getUTCMinutes());_O.range;const SO=mi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*lc-t.getMinutes()*Xa)},(t,e)=>{t.setTime(+t+e*cc)},(t,e)=>(e-t)/cc,t=>t.getHours());SO.range;const wO=mi(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*cc)},(t,e)=>(e-t)/cc,t=>t.getUTCHours());wO.range;const vb=mi(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Xa)/Mc,t=>t.getDate()-1);vb.range;const hM=mi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Mc,t=>t.getUTCDate()-1);hM.range;const MZ=mi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Mc,t=>Math.floor(t/Mc));MZ.range;function nh(t){return mi(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(e,n)=>{e.setDate(e.getDate()+n*7)},(e,n)=>(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*Xa)/vO)}const pM=nh(0),BS=nh(1),bje=nh(2),vje=nh(3),Em=nh(4),yje=nh(5),_je=nh(6);pM.range;BS.range;bje.range;vje.range;Em.range;yje.range;_je.range;function rh(t){return mi(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCDate(e.getUTCDate()+n*7)},(e,n)=>(n-e)/vO)}const mM=rh(0),HS=rh(1),Sje=rh(2),wje=rh(3),Am=rh(4),Mje=rh(5),Eje=rh(6);mM.range;HS.range;Sje.range;wje.range;Am.range;Mje.range;Eje.range;const MO=mi(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth());MO.range;const EO=mi(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+(e.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth());EO.range;const Ec=mi(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());Ec.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:mi(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)});Ec.range;const Ac=mi(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());Ac.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:mi(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)});Ac.range;function EZ(t,e,n,r,i,s){const a=[[uf,1,lc],[uf,5,5*lc],[uf,15,15*lc],[uf,30,30*lc],[s,1,Xa],[s,5,5*Xa],[s,15,15*Xa],[s,30,30*Xa],[i,1,cc],[i,3,3*cc],[i,6,6*cc],[i,12,12*cc],[r,1,Mc],[r,2,2*Mc],[n,1,vO],[e,1,B$],[e,3,3*B$],[t,1,uN]];function o(c,d,h){const g=db).right(a,g);if(m===a.length)return t.every(xR(c/uN,d/uN,h));if(m===0)return zS.every(Math.max(xR(c,d,h),1));const[v,y]=a[g/a[m-1][2]53)return null;"w"in ue||(ue.w=1),"Z"in ue?(B=fN(dx(ue.y,0,1)),F=B.getUTCDay(),B=F>4||F===0?HS.ceil(B):HS(B),B=hM.offset(B,(ue.V-1)*7),ue.y=B.getUTCFullYear(),ue.m=B.getUTCMonth(),ue.d=B.getUTCDate()+(ue.w+6)%7):(B=dN(dx(ue.y,0,1)),F=B.getDay(),B=F>4||F===0?BS.ceil(B):BS(B),B=vb.offset(B,(ue.V-1)*7),ue.y=B.getFullYear(),ue.m=B.getMonth(),ue.d=B.getDate()+(ue.w+6)%7)}else("W"in ue||"U"in ue)&&("w"in ue||(ue.w="u"in ue?ue.u%7:"W"in ue?1:0),F="Z"in ue?fN(dx(ue.y,0,1)).getUTCDay():dN(dx(ue.y,0,1)).getDay(),ue.m=0,ue.d="W"in ue?(ue.w+6)%7+ue.W*7-(F+5)%7:ue.w+ue.U*7-(F+6)%7);return"Z"in ue?(ue.H+=ue.Z/100|0,ue.M+=ue.Z%100,fN(ue)):dN(ue)}}function I(fe,Se,Re,ue){for(var ct=0,B=Se.length,F=Re.length,ie,V;ct=F)return-1;if(ie=Se.charCodeAt(ct++),ie===37){if(ie=Se.charAt(ct++),V=T[ie in H$?Se.charAt(ct++):ie],!V||(ue=V(fe,Re,ue))<0)return-1}else if(ie!=Re.charCodeAt(ue++))return-1}return ue}function N(fe,Se,Re){var ue=c.exec(Se.slice(Re));return ue?(fe.p=d.get(ue[0].toLowerCase()),Re+ue[0].length):-1}function D(fe,Se,Re){var ue=m.exec(Se.slice(Re));return ue?(fe.w=v.get(ue[0].toLowerCase()),Re+ue[0].length):-1}function z(fe,Se,Re){var ue=h.exec(Se.slice(Re));return ue?(fe.w=g.get(ue[0].toLowerCase()),Re+ue[0].length):-1}function j(fe,Se,Re){var ue=x.exec(Se.slice(Re));return ue?(fe.m=M.get(ue[0].toLowerCase()),Re+ue[0].length):-1}function W(fe,Se,Re){var ue=y.exec(Se.slice(Re));return ue?(fe.m=b.get(ue[0].toLowerCase()),Re+ue[0].length):-1}function P(fe,Se,Re){return I(fe,e,Se,Re)}function $(fe,Se,Re){return I(fe,n,Se,Re)}function K(fe,Se,Re){return I(fe,r,Se,Re)}function G(fe){return a[fe.getDay()]}function Z(fe){return s[fe.getDay()]}function Q(fe){return l[fe.getMonth()]}function ee(fe){return o[fe.getMonth()]}function H(fe){return i[+(fe.getHours()>=12)]}function q(fe){return 1+~~(fe.getMonth()/3)}function te(fe){return a[fe.getUTCDay()]}function ae(fe){return s[fe.getUTCDay()]}function xe(fe){return l[fe.getUTCMonth()]}function re(fe){return o[fe.getUTCMonth()]}function pe(fe){return i[+(fe.getUTCHours()>=12)]}function Ce(fe){return 1+~~(fe.getUTCMonth()/3)}return{format:function(fe){var Se=R(fe+="",w);return Se.toString=function(){return fe},Se},parse:function(fe){var Se=C(fe+="",!1);return Se.toString=function(){return fe},Se},utcFormat:function(fe){var Se=R(fe+="",A);return Se.toString=function(){return fe},Se},utcParse:function(fe){var Se=C(fe+="",!0);return Se.toString=function(){return fe},Se}}}var H$={"-":"",_:" ",0:"0"},Oi=/^\s*\d+/,Rje=/^%/,Pje=/[\\^$*+?|[\]().{}]/g;function Tn(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",s=i.length;return r+(s[e.toLowerCase(),n]))}function Oje(t,e,n){var r=Oi.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Lje(t,e,n){var r=Oi.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function jje(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Ije(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Uje(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function $$(t,e,n){var r=Oi.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function V$(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Fje(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function zje(t,e,n){var r=Oi.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function Bje(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function G$(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Hje(t,e,n){var r=Oi.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function W$(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function $je(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Vje(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Gje(t,e,n){var r=Oi.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Wje(t,e,n){var r=Oi.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function qje(t,e,n){var r=Rje.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Xje(t,e,n){var r=Oi.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Kje(t,e,n){var r=Oi.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function q$(t,e){return Tn(t.getDate(),e,2)}function Yje(t,e){return Tn(t.getHours(),e,2)}function Zje(t,e){return Tn(t.getHours()%12||12,e,2)}function Qje(t,e){return Tn(1+vb.count(Ec(t),t),e,3)}function AZ(t,e){return Tn(t.getMilliseconds(),e,3)}function Jje(t,e){return AZ(t,e)+"000"}function eIe(t,e){return Tn(t.getMonth()+1,e,2)}function tIe(t,e){return Tn(t.getMinutes(),e,2)}function nIe(t,e){return Tn(t.getSeconds(),e,2)}function rIe(t){var e=t.getDay();return e===0?7:e}function iIe(t,e){return Tn(pM.count(Ec(t)-1,t),e,2)}function TZ(t){var e=t.getDay();return e>=4||e===0?Em(t):Em.ceil(t)}function sIe(t,e){return t=TZ(t),Tn(Em.count(Ec(t),t)+(Ec(t).getDay()===4),e,2)}function aIe(t){return t.getDay()}function oIe(t,e){return Tn(BS.count(Ec(t)-1,t),e,2)}function lIe(t,e){return Tn(t.getFullYear()%100,e,2)}function cIe(t,e){return t=TZ(t),Tn(t.getFullYear()%100,e,2)}function uIe(t,e){return Tn(t.getFullYear()%1e4,e,4)}function dIe(t,e){var n=t.getDay();return t=n>=4||n===0?Em(t):Em.ceil(t),Tn(t.getFullYear()%1e4,e,4)}function fIe(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Tn(e/60|0,"0",2)+Tn(e%60,"0",2)}function X$(t,e){return Tn(t.getUTCDate(),e,2)}function hIe(t,e){return Tn(t.getUTCHours(),e,2)}function pIe(t,e){return Tn(t.getUTCHours()%12||12,e,2)}function mIe(t,e){return Tn(1+hM.count(Ac(t),t),e,3)}function CZ(t,e){return Tn(t.getUTCMilliseconds(),e,3)}function gIe(t,e){return CZ(t,e)+"000"}function xIe(t,e){return Tn(t.getUTCMonth()+1,e,2)}function bIe(t,e){return Tn(t.getUTCMinutes(),e,2)}function vIe(t,e){return Tn(t.getUTCSeconds(),e,2)}function yIe(t){var e=t.getUTCDay();return e===0?7:e}function _Ie(t,e){return Tn(mM.count(Ac(t)-1,t),e,2)}function NZ(t){var e=t.getUTCDay();return e>=4||e===0?Am(t):Am.ceil(t)}function SIe(t,e){return t=NZ(t),Tn(Am.count(Ac(t),t)+(Ac(t).getUTCDay()===4),e,2)}function wIe(t){return t.getUTCDay()}function MIe(t,e){return Tn(HS.count(Ac(t)-1,t),e,2)}function EIe(t,e){return Tn(t.getUTCFullYear()%100,e,2)}function AIe(t,e){return t=NZ(t),Tn(t.getUTCFullYear()%100,e,2)}function TIe(t,e){return Tn(t.getUTCFullYear()%1e4,e,4)}function CIe(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Am(t):Am.ceil(t),Tn(t.getUTCFullYear()%1e4,e,4)}function NIe(){return"+0000"}function K$(){return"%"}function Y$(t){return+t}function Z$(t){return Math.floor(+t/1e3)}var vp,kZ,RZ;kIe({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function kIe(t){return vp=kje(t),kZ=vp.format,vp.parse,RZ=vp.utcFormat,vp.utcParse,vp}function RIe(t){return new Date(t)}function PIe(t){return t instanceof Date?+t:+new Date(+t)}function AO(t,e,n,r,i,s,a,o,l,c){var d=fO(),h=d.invert,g=d.domain,m=c(".%L"),v=c(":%S"),y=c("%I:%M"),b=c("%I %p"),x=c("%a %d"),M=c("%b %d"),w=c("%B"),A=c("%Y");function T(R){return(l(R)e(i/(t.length-1)))},n.quantiles=function(r){return Array.from({length:r+1},(i,s)=>yLe(t,s/r))},n.copy=function(){return LZ(e).domain(t)},Dc.apply(n,arguments)}function xM(){var t=0,e=.5,n=1,r=1,i,s,a,o,l,c=_s,d,h=!1,g;function m(y){return isNaN(y=+y)?g:(y=.5+((y=+d(y))-s)*(r*yt.chartData,NO=We([xd],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),bM=(t,e,n,r)=>r?NO(t):xd(t);function id(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(cr(e)&&cr(n))return!0}return!1}function Q$(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function FZ(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,s;if(cr(n))i=n;else if(typeof n=="function")return;if(cr(r))s=r;else if(typeof r=="function")return;var a=[i,s];if(id(a))return a}}function IIe(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(id(r))return Q$(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,s]=t,a,o;if(i==="auto")e!=null&&(a=Math.min(...e));else if(Tt(i))a=i;else if(typeof i=="function")try{e!=null&&(a=i(e?.[0]))}catch{}else if(typeof i=="string"&&AH.test(i)){var l=AH.exec(i);if(l==null||e==null)a=void 0;else{var c=+l[1];a=e[0]-c}}else a=e?.[0];if(s==="auto")e!=null&&(o=Math.max(...e));else if(Tt(s))o=s;else if(typeof s=="function")try{e!=null&&(o=s(e?.[1]))}catch{}else if(typeof s=="string"&&TH.test(s)){var d=TH.exec(s);if(d==null||e==null)o=void 0;else{var h=+d[1];o=e[1]+h}}else o=e?.[1];var g=[a,o];if(id(g))return e==null?g:Q$(g,e,n)}}}var Gm=1e9,UIe={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},RO,hr=!0,no="[DecimalError] ",Mf=no+"Invalid argument: ",kO=no+"Exponent out of range: ",Wm=Math.floor,Kd=Math.pow,FIe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,ha,Ti=1e7,or=7,zZ=9007199254740991,$S=Wm(zZ/or),Nt={};Nt.absoluteValue=Nt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Nt.comparedTo=Nt.cmp=function(t){var e,n,r,i,s=this;if(t=new s.constructor(t),s.s!==t.s)return s.s||-t.s;if(s.e!==t.e)return s.e>t.e^s.s<0?1:-1;for(r=s.d.length,i=t.d.length,e=0,n=rt.d[e]^s.s<0?1:-1;return r===i?0:r>i^s.s<0?1:-1};Nt.decimalPlaces=Nt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*or;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Nt.dividedBy=Nt.div=function(t){return gc(this,new this.constructor(t))};Nt.dividedToIntegerBy=Nt.idiv=function(t){var e=this,n=e.constructor;return Zn(gc(e,new n(t),0,1),n.precision)};Nt.equals=Nt.eq=function(t){return!this.cmp(t)};Nt.exponent=function(){return Zr(this)};Nt.greaterThan=Nt.gt=function(t){return this.cmp(t)>0};Nt.greaterThanOrEqualTo=Nt.gte=function(t){return this.cmp(t)>=0};Nt.isInteger=Nt.isint=function(){return this.e>this.d.length-2};Nt.isNegative=Nt.isneg=function(){return this.s<0};Nt.isPositive=Nt.ispos=function(){return this.s>0};Nt.isZero=function(){return this.s===0};Nt.lessThan=Nt.lt=function(t){return this.cmp(t)<0};Nt.lessThanOrEqualTo=Nt.lte=function(t){return this.cmp(t)<1};Nt.logarithm=Nt.log=function(t){var e,n=this,r=n.constructor,i=r.precision,s=i+5;if(t===void 0)t=new r(10);else if(t=new r(t),t.s<1||t.eq(ha))throw Error(no+"NaN");if(n.s<1)throw Error(no+(n.s?"NaN":"-Infinity"));return n.eq(ha)?new r(0):(hr=!1,e=gc(B0(n,s),B0(t,s),s),hr=!0,Zn(e,i))};Nt.minus=Nt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?$Z(e,t):BZ(e,(t.s=-t.s,t))};Nt.modulo=Nt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(no+"NaN");return n.s?(hr=!1,e=gc(n,t,0,1).times(t),hr=!0,n.minus(e)):Zn(new r(n),i)};Nt.naturalExponential=Nt.exp=function(){return HZ(this)};Nt.naturalLogarithm=Nt.ln=function(){return B0(this)};Nt.negated=Nt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Nt.plus=Nt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?BZ(e,t):$Z(e,(t.s=-t.s,t))};Nt.precision=Nt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Mf+t);if(e=Zr(i)+1,r=i.d.length-1,n=r*or+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return t&&e>n?e:n};Nt.squareRoot=Nt.sqrt=function(){var t,e,n,r,i,s,a,o=this,l=o.constructor;if(o.s<1){if(!o.s)return new l(0);throw Error(no+"NaN")}for(t=Zr(o),hr=!1,i=Math.sqrt(+o),i==0||i==1/0?(e=tl(o.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=Wm((t+1)/2)-(t<0||t%2),i==1/0?e="5e"+t:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+t),r=new l(e)):r=new l(i.toString()),n=l.precision,i=a=n+3;;)if(s=r,r=s.plus(gc(o,s,a+2)).times(.5),tl(s.d).slice(0,a)===(e=tl(r.d)).slice(0,a)){if(e=e.slice(a-3,a+1),i==a&&e=="4999"){if(Zn(s,n+1,0),s.times(s).eq(o)){r=s;break}}else if(e!="9999")break;a+=4}return hr=!0,Zn(r,n)};Nt.times=Nt.mul=function(t){var e,n,r,i,s,a,o,l,c,d=this,h=d.constructor,g=d.d,m=(t=new h(t)).d;if(!d.s||!t.s)return new h(0);for(t.s*=d.s,n=d.e+t.e,l=g.length,c=m.length,l=0;){for(e=0,i=l+r;i>r;)o=s[i]+m[r]*g[i-r-1]+e,s[i--]=o%Ti|0,e=o/Ti|0;s[i]=(s[i]+e)%Ti|0}for(;!s[--a];)s.pop();return e?++n:s.shift(),t.d=s,t.e=n,hr?Zn(t,h.precision):t};Nt.toDecimalPlaces=Nt.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(fl(t,0,Gm),e===void 0?e=r.rounding:fl(e,0,8),Zn(n,t+Zr(n)+1,e))};Nt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Kf(r,!0):(fl(t,0,Gm),e===void 0?e=i.rounding:fl(e,0,8),r=Zn(new i(r),t+1,e),n=Kf(r,!0,t+1)),n};Nt.toFixed=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?Kf(i):(fl(t,0,Gm),e===void 0?e=s.rounding:fl(e,0,8),r=Zn(new s(i),t+Zr(i)+1,e),n=Kf(r.abs(),!1,t+Zr(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Nt.toInteger=Nt.toint=function(){var t=this,e=t.constructor;return Zn(new e(t),Zr(t)+1,e.rounding)};Nt.toNumber=function(){return+this};Nt.toPower=Nt.pow=function(t){var e,n,r,i,s,a,o=this,l=o.constructor,c=12,d=+(t=new l(t));if(!t.s)return new l(ha);if(o=new l(o),!o.s){if(t.s<1)throw Error(no+"Infinity");return o}if(o.eq(ha))return o;if(r=l.precision,t.eq(ha))return Zn(o,r);if(e=t.e,n=t.d.length-1,a=e>=n,s=o.s,a){if((n=d<0?-d:d)<=zZ){for(i=new l(ha),e=Math.ceil(r/or+4),hr=!1;n%2&&(i=i.times(o),eV(i.d,e)),n=Wm(n/2),n!==0;)o=o.times(o),eV(o.d,e);return hr=!0,t.s<0?new l(ha).div(i):Zn(i,r)}}else if(s<0)throw Error(no+"NaN");return s=s<0&&t.d[Math.max(e,n)]&1?-1:1,o.s=1,hr=!1,i=t.times(B0(o,r+c)),hr=!0,i=HZ(i),i.s=s,i};Nt.toPrecision=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?(n=Zr(i),r=Kf(i,n<=s.toExpNeg||n>=s.toExpPos)):(fl(t,1,Gm),e===void 0?e=s.rounding:fl(e,0,8),i=Zn(new s(i),t,e),n=Zr(i),r=Kf(i,t<=n||n<=s.toExpNeg,t)),r};Nt.toSignificantDigits=Nt.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(fl(t,1,Gm),e===void 0?e=r.rounding:fl(e,0,8)),Zn(new r(n),t,e)};Nt.toString=Nt.valueOf=Nt.val=Nt.toJSON=Nt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=Zr(t),n=t.constructor;return Kf(t,e<=n.toExpNeg||e>=n.toExpPos)};function BZ(t,e){var n,r,i,s,a,o,l,c,d=t.constructor,h=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),hr?Zn(e,h):e;if(l=t.d,c=e.d,a=t.e,i=e.e,l=l.slice(),s=a-i,s){for(s<0?(r=l,s=-s,o=c.length):(r=c,i=a,o=l.length),a=Math.ceil(h/or),o=a>o?a+1:o+1,s>o&&(s=o,r.length=1),r.reverse();s--;)r.push(0);r.reverse()}for(o=l.length,s=c.length,o-s<0&&(s=o,r=c,c=l,l=r),n=0;s;)n=(l[--s]=l[s]+c[s]+n)/Ti|0,l[s]%=Ti;for(n&&(l.unshift(n),++i),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=i,hr?Zn(e,h):e}function fl(t,e,n){if(t!==~~t||tn)throw Error(Mf+t)}function tl(t){var e,n,r,i=t.length-1,s="",a=t[0];if(i>0){for(s+=a,e=1;ea?1:-1;else for(o=l=0;oi[o]?1:-1;break}return l}function n(r,i,s){for(var a=0;s--;)r[s]-=a,a=r[s]1;)r.shift()}return function(r,i,s,a){var o,l,c,d,h,g,m,v,y,b,x,M,w,A,T,R,C,I,N=r.constructor,D=r.s==i.s?1:-1,z=r.d,j=i.d;if(!r.s)return new N(r);if(!i.s)throw Error(no+"Division by zero");for(l=r.e-i.e,C=j.length,T=z.length,m=new N(D),v=m.d=[],c=0;j[c]==(z[c]||0);)++c;if(j[c]>(z[c]||0)&&--l,s==null?M=s=N.precision:a?M=s+(Zr(r)-Zr(i))+1:M=s,M<0)return new N(0);if(M=M/or+2|0,c=0,C==1)for(d=0,j=j[0],M++;(c1&&(j=t(j,d),z=t(z,d),C=j.length,T=z.length),A=C,y=z.slice(0,C),b=y.length;b=Ti/2&&++R;do d=0,o=e(j,y,C,b),o<0?(x=y[0],C!=b&&(x=x*Ti+(y[1]||0)),d=x/R|0,d>1?(d>=Ti&&(d=Ti-1),h=t(j,d),g=h.length,b=y.length,o=e(h,y,g,b),o==1&&(d--,n(h,C16)throw Error(kO+Zr(t));if(!t.s)return new d(ha);for(hr=!1,o=h,a=new d(.03125);t.abs().gte(.1);)t=t.times(a),c+=5;for(r=Math.log(Kd(2,c))/Math.LN10*2+5|0,o+=r,n=i=s=new d(ha),d.precision=o;;){if(i=Zn(i.times(t),o),n=n.times(++l),a=s.plus(gc(i,n,o)),tl(a.d).slice(0,o)===tl(s.d).slice(0,o)){for(;c--;)s=Zn(s.times(s),o);return d.precision=h,e==null?(hr=!0,Zn(s,h)):s}s=a}}function Zr(t){for(var e=t.e*or,n=t.d[0];n>=10;n/=10)e++;return e}function hN(t,e,n){if(e>t.LN10.sd())throw hr=!0,n&&(t.precision=n),Error(no+"LN10 precision limit exceeded");return Zn(new t(t.LN10),e)}function Cu(t){for(var e="";t--;)e+="0";return e}function B0(t,e){var n,r,i,s,a,o,l,c,d,h=1,g=10,m=t,v=m.d,y=m.constructor,b=y.precision;if(m.s<1)throw Error(no+(m.s?"NaN":"-Infinity"));if(m.eq(ha))return new y(0);if(e==null?(hr=!1,c=b):c=e,m.eq(10))return e==null&&(hr=!0),hN(y,c);if(c+=g,y.precision=c,n=tl(v),r=n.charAt(0),s=Zr(m),Math.abs(s)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)m=m.times(t),n=tl(m.d),r=n.charAt(0),h++;s=Zr(m),r>1?(m=new y("0."+n),s++):m=new y(r+"."+n.slice(1))}else return l=hN(y,c+2,b).times(s+""),m=B0(new y(r+"."+n.slice(1)),c-g).plus(l),y.precision=b,e==null?(hr=!0,Zn(m,b)):m;for(o=a=m=gc(m.minus(ha),m.plus(ha),c),d=Zn(m.times(m),c),i=3;;){if(a=Zn(a.times(d),c),l=o.plus(gc(a,new y(i),c)),tl(l.d).slice(0,c)===tl(o.d).slice(0,c))return o=o.times(2),s!==0&&(o=o.plus(hN(y,c+2,b).times(s+""))),o=gc(o,new y(h),c),y.precision=b,e==null?(hr=!0,Zn(o,b)):o;o=l,i+=2}}function J$(t,e){var n,r,i;for((n=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(n<0&&(n=r),n+=+e.slice(r+1),e=e.substring(0,r)):n<0&&(n=e.length),r=0;e.charCodeAt(r)===48;)++r;for(i=e.length;e.charCodeAt(i-1)===48;)--i;if(e=e.slice(r,i),e){if(i-=r,n=n-r-1,t.e=Wm(n/or),t.d=[],r=(n+1)%or,n<0&&(r+=or),r$S||t.e<-$S))throw Error(kO+n)}else t.s=0,t.e=0,t.d=[0];return t}function Zn(t,e,n){var r,i,s,a,o,l,c,d,h=t.d;for(a=1,s=h[0];s>=10;s/=10)a++;if(r=e-a,r<0)r+=or,i=e,c=h[d=0];else{if(d=Math.ceil((r+1)/or),s=h.length,d>=s)return t;for(c=s=h[d],a=1;s>=10;s/=10)a++;r%=or,i=r-or+a}if(n!==void 0&&(s=Kd(10,a-i-1),o=c/s%10|0,l=e<0||h[d+1]!==void 0||c%s,l=n<4?(o||l)&&(n==0||n==(t.s<0?3:2)):o>5||o==5&&(n==4||l||n==6&&(r>0?i>0?c/Kd(10,a-i):0:h[d-1])%10&1||n==(t.s<0?8:7))),e<1||!h[0])return l?(s=Zr(t),h.length=1,e=e-s-1,h[0]=Kd(10,(or-e%or)%or),t.e=Wm(-e/or)||0):(h.length=1,h[0]=t.e=t.s=0),t;if(r==0?(h.length=d,s=1,d--):(h.length=d+1,s=Kd(10,or-r),h[d]=i>0?(c/Kd(10,a-i)%Kd(10,i)|0)*s:0),l)for(;;)if(d==0){(h[0]+=s)==Ti&&(h[0]=1,++t.e);break}else{if(h[d]+=s,h[d]!=Ti)break;h[d--]=0,s=1}for(r=h.length;h[--r]===0;)h.pop();if(hr&&(t.e>$S||t.e<-$S))throw Error(kO+Zr(t));return t}function $Z(t,e){var n,r,i,s,a,o,l,c,d,h,g=t.constructor,m=g.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new g(t),hr?Zn(e,m):e;if(l=t.d,h=e.d,r=e.e,c=t.e,l=l.slice(),a=c-r,a){for(d=a<0,d?(n=l,a=-a,o=h.length):(n=h,r=c,o=l.length),i=Math.max(Math.ceil(m/or),o)+2,a>i&&(a=i,n.length=1),n.reverse(),i=a;i--;)n.push(0);n.reverse()}else{for(i=l.length,o=h.length,d=i0;--i)l[o++]=0;for(i=h.length;i>a;){if(l[--i]0?s=s.charAt(0)+"."+s.slice(1)+Cu(r):a>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i<0?"e":"e+")+i):i<0?(s="0."+Cu(-i-1)+s,n&&(r=n-a)>0&&(s+=Cu(r))):i>=a?(s+=Cu(i+1-a),n&&(r=n-i-1)>0&&(s=s+"."+Cu(r))):((r=i+1)0&&(i+1===a&&(s+="."),s+=Cu(r))),t.s<0?"-"+s:s}function eV(t,e){if(t.length>e)return t.length=e,!0}function VZ(t){var e,n,r;function i(s){var a=this;if(!(a instanceof i))return new i(s);if(a.constructor=i,s instanceof i){a.s=s.s,a.e=s.e,a.d=(s=s.d)?s.slice():s;return}if(typeof s=="number"){if(s*0!==0)throw Error(Mf+s);if(s>0)a.s=1;else if(s<0)s=-s,a.s=-1;else{a.s=0,a.e=0,a.d=[0];return}if(s===~~s&&s<1e7){a.e=0,a.d=[s];return}return J$(a,s.toString())}else if(typeof s!="string")throw Error(Mf+s);if(s.charCodeAt(0)===45?(s=s.slice(1),a.s=-1):a.s=1,FIe.test(s))J$(a,s);else throw Error(Mf+s)}if(i.prototype=Nt,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=VZ,i.config=i.set=zIe,t===void 0&&(t={}),t)for(r=["precision","rounding","toExpNeg","toExpPos","LN10"],e=0;e=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Mf+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Mf+n+": "+r);return this}var RO=VZ(UIe);ha=new RO(1);const jn=RO;var BIe=t=>t,GZ={},WZ=t=>t===GZ,tV=t=>function e(){return arguments.length===0||arguments.length===1&&WZ(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},qZ=(t,e)=>t===1?e:tV(function(){for(var n=arguments.length,r=new Array(n),i=0;ia!==GZ).length;return s>=t?e(...r):qZ(t-s,tV(function(){for(var a=arguments.length,o=new Array(a),l=0;lWZ(d)?o.shift():d);return e(...c,...o)}))}),HIe=t=>qZ(t.length,t),SR=(t,e)=>{for(var n=[],r=t;rArray.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),VIe=function(){for(var e=arguments.length,n=new Array(e),r=0;rl(o),s(...arguments))}},wR=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function XZ(t){var e;return t===0?e=1:e=Math.floor(new jn(t).abs().log(10).toNumber())+1,e}function KZ(t,e,n){for(var r=new jn(t),i=0,s=[];r.lt(e)&&i<1e5;)s.push(r.toNumber()),r=r.add(n),i++;return s}var YZ=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},ZZ=(t,e,n)=>{if(t.lte(0))return new jn(0);var r=XZ(t.toNumber()),i=new jn(10).pow(r),s=t.div(i),a=r!==1?.05:.1,o=new jn(Math.ceil(s.div(a).toNumber())).add(n).mul(a),l=o.mul(i);return e?new jn(l.toNumber()):new jn(Math.ceil(l.toNumber()))},GIe=(t,e,n)=>{var r=new jn(1),i=new jn(t);if(!i.isint()&&n){var s=Math.abs(t);s<1?(r=new jn(10).pow(XZ(t)-1),i=new jn(Math.floor(i.div(r).toNumber())).mul(r)):s>1&&(i=new jn(Math.floor(t)))}else t===0?i=new jn(Math.floor((e-1)/2)):n||(i=new jn(Math.floor(t)));var a=Math.floor((e-1)/2),o=VIe($Ie(l=>i.add(new jn(l-a).mul(r)).toNumber()),SR);return o(0,e)},QZ=function(e,n,r,i){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-e)/(r-1)))return{step:new jn(0),tickMin:new jn(0),tickMax:new jn(0)};var a=ZZ(new jn(n).sub(e).div(r-1),i,s),o;e<=0&&n>=0?o=new jn(0):(o=new jn(e).add(n).div(2),o=o.sub(new jn(o).mod(a)));var l=Math.ceil(o.sub(e).div(a).toNumber()),c=Math.ceil(new jn(n).sub(o).div(a).toNumber()),d=l+c+1;return d>r?QZ(e,n,r,i,s+1):(d0?c+(r-d):c,l=n>0?l:l+(r-d)),{step:a,tickMin:o.sub(new jn(l).mul(a)),tickMax:o.add(new jn(c).mul(a))})},WIe=function(e){var[n,r]=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,a=Math.max(i,2),[o,l]=YZ([n,r]);if(o===-1/0||l===1/0){var c=l===1/0?[o,...SR(0,i-1).map(()=>1/0)]:[...SR(0,i-1).map(()=>-1/0),l];return n>r?wR(c):c}if(o===l)return GIe(o,i,s);var{step:d,tickMin:h,tickMax:g}=QZ(o,l,a,s,0),m=KZ(h,g.add(new jn(.1).mul(d)),d);return n>r?wR(m):m},qIe=function(e,n){var[r,i]=e,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[a,o]=YZ([r,i]);if(a===-1/0||o===1/0)return[r,i];if(a===o)return[a];var l=Math.max(n,2),c=ZZ(new jn(o).sub(a).div(l-1),s,0),d=[...KZ(new jn(a),new jn(o),c),o];return s===!1&&(d=d.map(h=>Math.round(h))),r>i?wR(d):d},JZ=t=>t.rootProps.maxBarSize,XIe=t=>t.rootProps.barGap,eQ=t=>t.rootProps.barCategoryGap,KIe=t=>t.rootProps.barSize,yb=t=>t.rootProps.stackOffset,tQ=t=>t.rootProps.reverseStackOrder,PO=t=>t.options.chartName,DO=t=>t.rootProps.syncId,nQ=t=>t.rootProps.syncMethod,OO=t=>t.options.eventEmitter,YIe=t=>t.rootProps.baseValue,Kr={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},ec={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},ua={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},vM=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},ZIe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:ec.angleAxisId,includeHidden:!1,name:void 0,reversed:ec.reversed,scale:ec.scale,tick:ec.tick,tickCount:void 0,ticks:void 0,type:ec.type,unit:void 0},QIe={allowDataOverflow:ua.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:ua.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:ua.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:ua.scale,tick:ua.tick,tickCount:ua.tickCount,ticks:void 0,type:ua.type,unit:void 0},JIe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:ec.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:ec.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:ec.scale,tick:ec.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},e4e={allowDataOverflow:ua.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:ua.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:ua.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:ua.scale,tick:ua.tick,tickCount:ua.tickCount,ticks:void 0,type:"category",unit:void 0},LO=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?JIe:ZIe,jO=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?e4e:QIe,yM=t=>t.polarOptions,IO=We([Rc,Pc,pi],eZ),rQ=We([yM,IO],(t,e)=>{if(t!=null)return us(t.innerRadius,e,0)}),iQ=We([yM,IO],(t,e)=>{if(t!=null)return us(t.outerRadius,e,e*.8)}),t4e=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},sQ=We([yM],t4e);We([LO,sQ],vM);var aQ=We([IO,rQ,iQ],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});We([jO,aQ],vM);var oQ=We([Sn,yM,rQ,iQ,Rc,Pc],(t,e,n,r,i,s)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:a,cy:o,startAngle:l,endAngle:c}=e;return{cx:us(a,i,i/2),cy:us(o,s,s/2),innerRadius:n,outerRadius:r,startAngle:l,endAngle:c,clockWise:!1}}}),pr=(t,e)=>e,_b=(t,e,n)=>n;function _M(t){return t?.id}function lQ(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:s}=n,a=new Map;return t.forEach(o=>{var l,c=(l=o.data)!==null&&l!==void 0?l:r;if(!(c==null||c.length===0)){var d=_M(o);c.forEach((h,g)=>{var m=s==null||i?g:String(Yn(h,s,null)),v=Yn(h,o.dataKey,0),y;a.has(m)?y=a.get(m):y={},Object.assign(y,{[d]:v}),a.set(m,y)})}}),Array.from(a.values())}function SM(t){return t.stackId!=null&&t.dataKey!=null}var wM=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function MM(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function n4e(t,e){if(t.length===e.length){for(var n=0;n{var e=Sn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},qm=t=>t.tooltip.settings.axisId;function nV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function VS(t){for(var e=1;et.cartesianAxis.xAxis[e],Oc=(t,e)=>{var n=cQ(t,e);return n??Ei},Ai={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:MR,hide:!0,id:0,includeHidden:!1,interval:"preserveEnd",minTickGap:5,mirror:!1,name:void 0,orientation:"left",padding:{top:0,bottom:0},reversed:!1,scale:"auto",tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:"number",unit:void 0,width:fb},uQ=(t,e)=>t.cartesianAxis.yAxis[e],Lc=(t,e)=>{var n=uQ(t,e);return n??Ai},a4e={domain:[0,"auto"],includeHidden:!1,reversed:!1,allowDataOverflow:!1,allowDuplicatedCategory:!1,dataKey:void 0,id:0,name:"",range:[64,64],scale:"auto",type:"number",unit:""},UO=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??a4e},_r=(t,e,n)=>{switch(e){case"xAxis":return Oc(t,n);case"yAxis":return Lc(t,n);case"zAxis":return UO(t,n);case"angleAxis":return LO(t,n);case"radiusAxis":return jO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},o4e=(t,e,n)=>{switch(e){case"xAxis":return Oc(t,n);case"yAxis":return Lc(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},Sb=(t,e,n)=>{switch(e){case"xAxis":return Oc(t,n);case"yAxis":return Lc(t,n);case"angleAxis":return LO(t,n);case"radiusAxis":return jO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},dQ=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function FO(t,e){return n=>{switch(t){case"xAxis":return"xAxisId"in n&&n.xAxisId===e;case"yAxis":return"yAxisId"in n&&n.yAxisId===e;case"zAxis":return"zAxisId"in n&&n.zAxisId===e;case"angleAxis":return"angleAxisId"in n&&n.angleAxisId===e;case"radiusAxis":return"radiusAxisId"in n&&n.radiusAxisId===e;default:return!1}}}var EM=t=>t.graphicalItems.cartesianItems,l4e=We([pr,_b],FO),zO=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),wb=We([EM,_r,l4e],zO,{memoizeOptions:{resultEqualityCheck:MM}}),fQ=We([wb],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(SM)),hQ=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),c4e=We([wb],hQ),BO=t=>t.map(e=>e.data).filter(Boolean).flat(1),u4e=We([wb],BO,{memoizeOptions:{resultEqualityCheck:MM}}),HO=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},$O=We([u4e,bM],HO),VO=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:Yn(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:Yn(i,r)}))):t.map(r=>({value:r})),AM=We([$O,_r,wb],VO);function pQ(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function G_(t){if(ul(t)||t instanceof Date){var e=Number(t);if(cr(e))return e}}function rV(t){if(Array.isArray(t)){var e=[G_(t[0]),G_(t[1])];return id(e)?e:void 0}var n=G_(t);if(n!=null)return[n,n]}function Tc(t){return t.map(G_).filter(cke)}function d4e(t,e,n){return!n||typeof e!="number"||eo(e)?[]:n.length?Tc(n.flatMap(r=>{var i=Yn(t,r.dataKey),s,a;if(Array.isArray(i)?[s,a]=i:s=a=i,!(!cr(s)||!cr(a)))return[e-s,e+a]})):[]}var xi=t=>{var e=gi(t),n=qm(t);return Sb(t,e,n)},Mb=We([xi],t=>t?.dataKey),f4e=We([fQ,bM,xi],lQ),mQ=(t,e,n,r)=>{var i={},s=e.reduce((a,o)=>(o.stackId==null||(a[o.stackId]==null&&(a[o.stackId]=[]),a[o.stackId].push(o)),a),i);return Object.fromEntries(Object.entries(s).map(a=>{var[o,l]=a,c=r?[...l].reverse():l,d=c.map(_M);return[o,{stackedData:RPe(t,d,n),graphicalItems:c}]}))},H0=We([f4e,fQ,yb,tQ],mQ),gQ=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:s}=e;if(r==null&&n!=="zAxis"){var a=LPe(t,i,s);if(!(a!=null&&a[0]===0&&a[1]===0))return a}},h4e=We([_r],t=>t.allowDataOverflow),GO=t=>{var e;if(t==null||!("domain"in t))return MR;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=Tc(t.ticks);return[Math.min(...n),Math.max(...n)]}if(t.type==="category")return t.ticks.map(String)}return(e=t?.domain)!==null&&e!==void 0?e:MR},WO=We([_r],GO),qO=We([WO,h4e],FZ),p4e=We([H0,xd,pr,qO],gQ,{memoizeOptions:{resultEqualityCheck:wM}}),TM=t=>t.errorBars,m4e=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>pQ(n,r)),GS=function(){for(var e=arguments.length,n=new Array(e),r=0;r{var s,a;if(n.length>0&&t.forEach(o=>{n.forEach(l=>{var c,d,h=(c=r[l.id])===null||c===void 0?void 0:c.filter(x=>pQ(i,x)),g=Yn(o,(d=e.dataKey)!==null&&d!==void 0?d:l.dataKey),m=d4e(o,g,h);if(m.length>=2){var v=Math.min(...m),y=Math.max(...m);(s==null||va)&&(a=y)}var b=rV(g);b!=null&&(s=s==null?b[0]:Math.min(s,b[0]),a=a==null?b[1]:Math.max(a,b[1]))})}),e?.dataKey!=null&&t.forEach(o=>{var l=rV(Yn(o,e.dataKey));l!=null&&(s=s==null?l[0]:Math.min(s,l[0]),a=a==null?l[1]:Math.max(a,l[1]))}),cr(s)&&cr(a))return[s,a]},g4e=We([$O,_r,c4e,TM,pr],XO,{memoizeOptions:{resultEqualityCheck:wM}});function x4e(t){var{value:e}=t;if(ul(e)||e instanceof Date)return e}var b4e=(t,e,n)=>{var r=t.map(x4e).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&RK(r))?iZ(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},xQ=t=>t.referenceElements.dots,Xm=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),v4e=We([xQ,pr,_b],Xm),bQ=t=>t.referenceElements.areas,y4e=We([bQ,pr,_b],Xm),vQ=t=>t.referenceElements.lines,_4e=We([vQ,pr,_b],Xm),yQ=(t,e)=>{var n=Tc(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},S4e=We(v4e,pr,yQ),_Q=(t,e)=>{var n=Tc(t.flatMap(r=>[e==="xAxis"?r.x1:r.y1,e==="xAxis"?r.x2:r.y2]));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},w4e=We([y4e,pr],_Q);function M4e(t){var e;if(t.x!=null)return Tc([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:Tc(n)}function E4e(t){var e;if(t.y!=null)return Tc([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:Tc(n)}var SQ=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?M4e(r):E4e(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},A4e=We([_4e,pr],SQ),T4e=We(S4e,A4e,w4e,(t,e,n)=>GS(t,n,e)),KO=(t,e,n,r,i,s,a,o)=>{if(n!=null)return n;var l=a==="vertical"&&o==="xAxis"||a==="horizontal"&&o==="yAxis",c=l?GS(r,s,i):GS(s,i);return IIe(e,c,t.allowDataOverflow)},C4e=We([_r,WO,qO,p4e,g4e,T4e,Sn,pr],KO,{memoizeOptions:{resultEqualityCheck:wM}}),N4e=[0,1],YO=(t,e,n,r,i,s,a)=>{if(!((t==null||n==null||n.length===0)&&a===void 0)){var{dataKey:o,type:l}=t,c=kc(e,s);if(c&&o==null){var d;return iZ(0,(d=n?.length)!==null&&d!==void 0?d:0)}return l==="category"?b4e(r,t,c):i==="expand"?N4e:a}},ZO=We([_r,Sn,$O,AM,yb,pr,C4e],YO),wQ=(t,e,n,r,i)=>{if(t!=null){var{scale:s,type:a}=t;if(s==="auto")return e==="radial"&&i==="radiusAxis"?"band":e==="radial"&&i==="angleAxis"?"linear":a==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?"point":a==="category"?"band":"linear";if(typeof s=="string"){var o="scale".concat(ab(s));return o in Mx?o:"point"}}},Km=We([_r,Sn,dQ,PO,pr],wQ);function k4e(t){if(t!=null){if(t in Mx)return Mx[t]();var e="scale".concat(ab(t));if(e in Mx)return Mx[e]()}}function QO(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=k4e(e);if(i!=null){var s=i.domain(n).range(r);return APe(s),s}}}var JO=(t,e,n)=>{var r=GO(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&id(t))return WIe(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&id(t))return qIe(t,e.tickCount,e.allowDecimals)}},eL=We([ZO,Sb,Km],JO),tL=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&id(e)&&Array.isArray(n)&&n.length>0){var i=e[0],s=n[0],a=e[1],o=n[n.length-1];return[Math.min(i,s),Math.max(a,o)]}return e},R4e=We([_r,ZO,eL,pr],tL),P4e=We(AM,_r,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(Tc(t.map(o=>o.value))).sort((o,l)=>o-l);if(r.length<2)return 1/0;var i=r[r.length-1]-r[0];if(i===0)return 1/0;for(var s=0;sr,(t,e,n,r,i)=>{if(!cr(t))return 0;var s=e==="vertical"?r.height:r.width;if(i==="gap")return t*s/2;if(i==="no-gap"){var a=us(n,t*s),o=t*s/2;return o-a-(o-a)/s*a}return 0}),D4e=(t,e)=>{var n=Oc(t,e);return n==null||typeof n.padding!="string"?0:MQ(t,"xAxis",e,n.padding)},O4e=(t,e)=>{var n=Lc(t,e);return n==null||typeof n.padding!="string"?0:MQ(t,"yAxis",e,n.padding)},L4e=We(Oc,D4e,(t,e)=>{var n,r;if(t==null)return{left:0,right:0};var{padding:i}=t;return typeof i=="string"?{left:e,right:e}:{left:((n=i.left)!==null&&n!==void 0?n:0)+e,right:((r=i.right)!==null&&r!==void 0?r:0)+e}}),j4e=We(Lc,O4e,(t,e)=>{var n,r;if(t==null)return{top:0,bottom:0};var{padding:i}=t;return typeof i=="string"?{top:e,bottom:e}:{top:((n=i.top)!==null&&n!==void 0?n:0)+e,bottom:((r=i.bottom)!==null&&r!==void 0?r:0)+e}}),I4e=We([pi,L4e,aM,sM,(t,e,n)=>n],(t,e,n,r,i)=>{var{padding:s}=r;return i?[s.left,n.width-s.right]:[t.left+e.left,t.left+t.width-e.right]}),U4e=We([pi,Sn,j4e,aM,sM,(t,e,n)=>n],(t,e,n,r,i,s)=>{var{padding:a}=i;return s?[r.height-a.bottom,a.top]:e==="horizontal"?[t.top+t.height-n.bottom,t.top+n.top]:[t.top+n.top,t.top+t.height-n.bottom]}),Eb=(t,e,n,r)=>{var i;switch(e){case"xAxis":return I4e(t,n,r);case"yAxis":return U4e(t,n,r);case"zAxis":return(i=UO(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return sQ(t);case"radiusAxis":return aQ(t,n);default:return}},EQ=We([_r,Eb],vM),Ym=We([_r,Km,R4e,EQ],QO);We([wb,TM,pr],m4e);function AQ(t,e){return t.ide.id?1:0}var CM=(t,e)=>e,NM=(t,e,n)=>n,F4e=We(rM,CM,NM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(AQ)),z4e=We(iM,CM,NM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(AQ)),TQ=(t,e)=>({width:t.width,height:e.height}),B4e=(t,e)=>{var n=typeof e.width=="number"?e.width:fb;return{width:n,height:t.height}},CQ=We(pi,Oc,TQ),H4e=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},$4e=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},V4e=We(Pc,pi,F4e,CM,NM,(t,e,n,r,i)=>{var s={},a;return n.forEach(o=>{var l=TQ(e,o);a==null&&(a=H4e(e,r,t));var c=r==="top"&&!i||r==="bottom"&&i;s[o.id]=a-Number(c)*l.height,a+=(c?-1:1)*l.height}),s}),G4e=We(Rc,pi,z4e,CM,NM,(t,e,n,r,i)=>{var s={},a;return n.forEach(o=>{var l=B4e(e,o);a==null&&(a=$4e(e,r,t));var c=r==="left"&&!i||r==="right"&&i;s[o.id]=a-Number(c)*l.width,a+=(c?-1:1)*l.width}),s}),W4e=(t,e)=>{var n=Oc(t,e);if(n!=null)return V4e(t,n.orientation,n.mirror)},q4e=We([pi,Oc,W4e,(t,e)=>e],(t,e,n,r)=>{if(e!=null){var i=n?.[r];return i==null?{x:t.left,y:0}:{x:t.left,y:i}}}),X4e=(t,e)=>{var n=Lc(t,e);if(n!=null)return G4e(t,n.orientation,n.mirror)},K4e=We([pi,Lc,X4e,(t,e)=>e],(t,e,n,r)=>{if(e!=null){var i=n?.[r];return i==null?{x:0,y:t.top}:{x:i,y:t.top}}}),NQ=We(pi,Lc,(t,e)=>{var n=typeof e.width=="number"?e.width:fb;return{width:n,height:t.height}}),iV=(t,e,n)=>{switch(e){case"xAxis":return CQ(t,n).width;case"yAxis":return NQ(t,n).height;default:return}},kQ=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:s,dataKey:a}=n,o=kc(t,r),l=e.map(c=>c.value);if(a&&o&&s==="category"&&i&&RK(l))return l}},nL=We([Sn,AM,_r,pr],kQ),RQ=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:s}=n,a=kc(t,r);if(a&&(i==="number"||s!=="auto"))return e.map(o=>o.value)}},rL=We([Sn,AM,Sb,pr],RQ),sV=We([Sn,o4e,Km,Ym,nL,rL,Eb,eL,pr],(t,e,n,r,i,s,a,o,l)=>{if(e!=null){var c=kc(t,l);return{angle:e.angle,interval:e.interval,minTickGap:e.minTickGap,orientation:e.orientation,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit,axisType:l,categoricalDomain:s,duplicateDomain:i,isCategorical:c,niceTicks:o,range:a,realScaleType:n,scale:r}}}),Y4e=(t,e,n,r,i,s,a,o,l)=>{if(!(e==null||r==null)){var c=kc(t,l),{type:d,ticks:h,tickCount:g}=e,m=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,v=d==="category"&&r.bandwidth?r.bandwidth()/m:0;v=l==="angleAxis"&&s!=null&&s.length>=2?ki(s[0]-s[1])*2*v:v;var y=h||i;if(y){var b=y.map((x,M)=>{var w=a?a.indexOf(x):x;return{index:M,coordinate:r(w)+v,value:x,offset:v}});return b.filter(x=>cr(x.coordinate))}return c&&o?o.map((x,M)=>({coordinate:r(x)+v,value:x,index:M,offset:v})).filter(x=>cr(x.coordinate)):r.ticks?r.ticks(g).map(x=>({coordinate:r(x)+v,value:x,offset:v})):r.domain().map((x,M)=>({coordinate:r(x)+v,value:a?a[x]:x,index:M,offset:v}))}},PQ=We([Sn,Sb,Km,Ym,eL,Eb,nL,rL,pr],Y4e),Z4e=(t,e,n,r,i,s,a)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var o=kc(t,a),{tickCount:l}=e,c=0;return c=a==="angleAxis"&&r?.length>=2?ki(r[0]-r[1])*2*c:c,o&&s?s.map((d,h)=>({coordinate:n(d)+c,value:d,index:h,offset:c})):n.ticks?n.ticks(l).map(d=>({coordinate:n(d)+c,value:d,offset:c})):n.domain().map((d,h)=>({coordinate:n(d)+c,value:i?i[d]:d,index:h,offset:c}))}},sd=We([Sn,Sb,Ym,Eb,nL,rL,pr],Z4e),ad=We(_r,Ym,(t,e)=>{if(!(t==null||e==null))return VS(VS({},t),{},{scale:e})}),Q4e=We([_r,Km,ZO,EQ],QO);We((t,e,n)=>UO(t,n),Q4e,(t,e)=>{if(!(t==null||e==null))return VS(VS({},t),{},{scale:e})});var J4e=We([Sn,rM,iM],(t,e,n)=>{switch(t){case"horizontal":return e.some(r=>r.reversed)?"right-to-left":"left-to-right";case"vertical":return n.some(r=>r.reversed)?"bottom-to-top":"top-to-bottom";case"centric":case"radial":return"left-to-right";default:return}}),DQ=t=>t.options.defaultTooltipEventType,OQ=t=>t.options.validateTooltipEventTypes;function LQ(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function iL(t,e){var n=DQ(t),r=OQ(t);return LQ(e,n,r)}function eUe(t){return Ct(e=>iL(e,t))}var jQ=(t,e)=>{var n,r=Number(e);if(!(eo(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},tUe=t=>t.tooltip.settings,Du={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},nUe={itemInteraction:{click:Du,hover:Du},axisInteraction:{click:Du,hover:Du},keyboardInteraction:Du,syncInteraction:{active:!1,index:null,dataKey:void 0,label:void 0,coordinate:void 0,sourceViewBox:void 0,graphicalItemId:void 0},tooltipItemPayloads:[],settings:{shared:void 0,trigger:"hover",axisId:0,active:!1,defaultIndex:void 0}},IQ=Zs({name:"tooltip",initialState:nUe,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:dr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=To(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:dr()},removeTooltipEntrySettings:{reducer(t,e){var n=To(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:dr()},setTooltipSettingsState(t,e){t.settings=e.payload},setActiveMouseOverItemIndex(t,e){t.syncInteraction.active=!1,t.keyboardInteraction.active=!1,t.itemInteraction.hover.active=!0,t.itemInteraction.hover.index=e.payload.activeIndex,t.itemInteraction.hover.dataKey=e.payload.activeDataKey,t.itemInteraction.hover.graphicalItemId=e.payload.activeGraphicalItemId,t.itemInteraction.hover.coordinate=e.payload.activeCoordinate},mouseLeaveChart(t){t.itemInteraction.hover.active=!1,t.axisInteraction.hover.active=!1},mouseLeaveItem(t){t.itemInteraction.hover.active=!1},setActiveClickItemIndex(t,e){t.syncInteraction.active=!1,t.itemInteraction.click.active=!0,t.keyboardInteraction.active=!1,t.itemInteraction.click.index=e.payload.activeIndex,t.itemInteraction.click.dataKey=e.payload.activeDataKey,t.itemInteraction.click.graphicalItemId=e.payload.activeGraphicalItemId,t.itemInteraction.click.coordinate=e.payload.activeCoordinate},setMouseOverAxisIndex(t,e){t.syncInteraction.active=!1,t.axisInteraction.hover.active=!0,t.keyboardInteraction.active=!1,t.axisInteraction.hover.index=e.payload.activeIndex,t.axisInteraction.hover.dataKey=e.payload.activeDataKey,t.axisInteraction.hover.coordinate=e.payload.activeCoordinate},setMouseClickAxisIndex(t,e){t.syncInteraction.active=!1,t.keyboardInteraction.active=!1,t.axisInteraction.click.active=!0,t.axisInteraction.click.index=e.payload.activeIndex,t.axisInteraction.click.dataKey=e.payload.activeDataKey,t.axisInteraction.click.coordinate=e.payload.activeCoordinate},setSyncInteraction(t,e){t.syncInteraction=e.payload},setKeyboardInteraction(t,e){t.keyboardInteraction.active=e.payload.active,t.keyboardInteraction.index=e.payload.activeIndex,t.keyboardInteraction.coordinate=e.payload.activeCoordinate,t.keyboardInteraction.dataKey=e.payload.activeDataKey}}}),{addTooltipEntrySettings:rUe,replaceTooltipEntrySettings:iUe,removeTooltipEntrySettings:sUe,setTooltipSettingsState:aUe,setActiveMouseOverItemIndex:UQ,mouseLeaveItem:oUe,mouseLeaveChart:FQ,setActiveClickItemIndex:lUe,setMouseOverAxisIndex:zQ,setMouseClickAxisIndex:cUe,setSyncInteraction:ER,setKeyboardInteraction:AR}=IQ.actions,uUe=IQ.reducer;function aV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function x_(t){for(var e=1;e{if(e==null)return Du;var i=pUe(t,e,n);if(i==null)return Du;if(i.active)return i;if(t.keyboardInteraction.active)return t.keyboardInteraction;if(t.syncInteraction.active&&t.syncInteraction.index!=null)return t.syncInteraction;var s=t.settings.active===!0;if(mUe(i)){if(s)return x_(x_({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return x_(x_({},Du),{},{coordinate:i.coordinate})};function gUe(t){if(typeof t=="number")return Number.isFinite(t)?t:void 0;if(t instanceof Date){var e=t.valueOf();return Number.isFinite(e)?e:void 0}var n=Number(t);return Number.isFinite(n)?n:void 0}function xUe(t,e){var n=gUe(t),r=e[0],i=e[1];if(n===void 0)return!1;var s=Math.min(r,i),a=Math.max(r,i);return n>=s&&n<=a}function bUe(t,e,n){if(n==null||e==null)return!0;var r=Yn(t,e);return r==null||!id(n)?!0:xUe(r,n)}var sL=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var s=Number(i);if(!cr(s))return i;var a=0,o=1/0;e.length>0&&(o=e.length-1);var l=Math.max(a,Math.min(s,o)),c=e[l];return c==null||bUe(c,n,r)?String(l):null},HQ=(t,e,n,r,i,s,a,o)=>{if(!(s==null||o==null)){var l=a[0],c=l==null?void 0:o(l.positions,s);if(c!=null)return c;var d=i?.[Number(s)];if(d)switch(n){case"horizontal":return{x:d.coordinate,y:(r.top+e)/2};default:return{x:(r.left+t)/2,y:d.coordinate}}}},$Q=(t,e,n,r)=>{if(e==="axis")return t.tooltipItemPayloads;if(t.tooltipItemPayloads.length===0)return[];var i;return n==="hover"?i=t.itemInteraction.hover.dataKey:i=t.itemInteraction.click.dataKey,i==null&&r!=null?[t.tooltipItemPayloads[0]]:t.tooltipItemPayloads.filter(s=>{var a;return((a=s.settings)===null||a===void 0?void 0:a.dataKey)===i})},Ab=t=>t.options.tooltipPayloadSearcher,Zm=t=>t.tooltip;function oV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function lV(t){for(var e=1;e{if(!(e==null||s==null)){var{chartData:o,computedData:l,dataStartIndex:c,dataEndIndex:d}=n,h=[];return t.reduce((g,m)=>{var v,{dataDefinedOnItem:y,settings:b}=m,x=SUe(y,o),M=Array.isArray(x)?EY(x,c,d):x,w=(v=b?.dataKey)!==null&&v!==void 0?v:r,A=b?.nameKey,T;if(r&&Array.isArray(M)&&!Array.isArray(M[0])&&a==="axis"?T=PK(M,r,i):T=s(M,e,l,A),Array.isArray(T))T.forEach(C=>{var I=lV(lV({},b),{},{name:C.name,unit:C.unit,color:void 0,fill:void 0});g.push(CH({tooltipEntrySettings:I,dataKey:C.dataKey,payload:C.payload,value:Yn(C.payload,C.dataKey),name:C.name}))});else{var R;g.push(CH({tooltipEntrySettings:b,dataKey:w,payload:T,value:Yn(T,w),name:(R=Yn(T,A))!==null&&R!==void 0?R:b?.name}))}return g},h)}},aL=We([xi,Sn,dQ,PO,gi],wQ),wUe=We([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),MUe=We([gi,qm],FO),Tb=We([wUe,xi,MUe],zO,{memoizeOptions:{resultEqualityCheck:MM}}),EUe=We([Tb],t=>t.filter(SM)),AUe=We([Tb],BO,{memoizeOptions:{resultEqualityCheck:MM}}),Qm=We([AUe,xd],HO),TUe=We([EUe,xd,xi],lQ),oL=We([Qm,xi,Tb],VO),GQ=We([xi],GO),CUe=We([xi],t=>t.allowDataOverflow),WQ=We([GQ,CUe],FZ),NUe=We([Tb],t=>t.filter(SM)),kUe=We([TUe,NUe,yb,tQ],mQ),RUe=We([kUe,xd,gi,WQ],gQ),PUe=We([Tb],hQ),DUe=We([Qm,xi,PUe,TM,gi],XO,{memoizeOptions:{resultEqualityCheck:wM}}),OUe=We([xQ,gi,qm],Xm),LUe=We([OUe,gi],yQ),jUe=We([bQ,gi,qm],Xm),IUe=We([jUe,gi],_Q),UUe=We([vQ,gi,qm],Xm),FUe=We([UUe,gi],SQ),zUe=We([LUe,FUe,IUe],GS),BUe=We([xi,GQ,WQ,RUe,DUe,zUe,Sn,gi],KO),Cb=We([xi,Sn,Qm,oL,yb,gi,BUe],YO),HUe=We([Cb,xi,aL],JO),$Ue=We([xi,Cb,HUe,gi],tL),qQ=t=>{var e=gi(t),n=qm(t),r=!1;return Eb(t,e,n,r)},XQ=We([xi,qQ],vM),KQ=We([xi,aL,$Ue,XQ],QO),VUe=We([Sn,oL,xi,gi],kQ),GUe=We([Sn,oL,xi,gi],RQ),WUe=(t,e,n,r,i,s,a,o)=>{if(e){var{type:l}=e,c=kc(t,o);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,h=l==="category"&&r.bandwidth?r.bandwidth()/d:0;return h=o==="angleAxis"&&i!=null&&i?.length>=2?ki(i[0]-i[1])*2*h:h,c&&a?a.map((g,m)=>({coordinate:r(g)+h,value:g,index:m,offset:h})):r.domain().map((g,m)=>({coordinate:r(g)+h,value:s?s[g]:g,index:m,offset:h}))}}},jc=We([Sn,xi,aL,KQ,qQ,VUe,GUe,gi],WUe),lL=We([DQ,OQ,tUe],(t,e,n)=>LQ(n.shared,t,e)),YQ=t=>t.tooltip.settings.trigger,cL=t=>t.tooltip.settings.defaultIndex,Nb=We([Zm,lL,YQ,cL],BQ),od=We([Nb,Qm,Mb,Cb],sL),ZQ=We([jc,od],jQ),uL=We([Nb],t=>{if(t)return t.dataKey}),qUe=We([Nb],t=>{if(t)return t.graphicalItemId}),QQ=We([Zm,lL,YQ,cL],$Q),XUe=We([Rc,Pc,Sn,pi,jc,cL,QQ,Ab],HQ),KUe=We([Nb,XUe],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),YUe=We([Nb],t=>t.active),ZUe=We([QQ,od,xd,Mb,ZQ,Ab,lL],VQ),QUe=We([ZUe],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function cV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function uV(t){for(var e=1;eCt(xi),rFe=()=>{var t=nFe(),e=Ct(jc),n=Ct(KQ);return _m(!t||!n?void 0:uV(uV({},t),{},{scale:n}),e)};function dV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function yp(t){for(var e=1;e{var i=e.find(s=>s&&s.index===n);if(i){if(t==="horizontal")return{x:i.coordinate,y:r.chartY};if(t==="vertical")return{x:r.chartX,y:i.coordinate}}return{x:0,y:0}},lFe=(t,e,n,r)=>{var i=e.find(c=>c&&c.index===n);if(i){if(t==="centric"){var s=i.coordinate,{radius:a}=r;return yp(yp(yp({},r),Xr(r.cx,r.cy,a,s)),{},{angle:s,radius:a})}var o=i.coordinate,{angle:l}=r;return yp(yp(yp({},r),Xr(r.cx,r.cy,o,l)),{},{angle:l,radius:o})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function cFe(t,e){var{chartX:n,chartY:r}=t;return n>=e.left&&n<=e.left+e.width&&r>=e.top&&r<=e.top+e.height}var JQ=(t,e,n,r,i)=>{var s,a=-1,o=(s=e?.length)!==null&&s!==void 0?s:0;if(o<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var l=0;l0?n[l-1].coordinate:n[o-1].coordinate,d=n[l].coordinate,h=l>=o-1?n[0].coordinate:n[l+1].coordinate,g=void 0;if(ki(d-c)!==ki(h-d)){var m=[];if(ki(h-d)===ki(i[1]-i[0])){g=h;var v=d+i[1]-i[0];m[0]=Math.min(v,(v+c)/2),m[1]=Math.max(v,(v+c)/2)}else{g=c;var y=h+i[1]-i[0];m[0]=Math.min(d,(y+d)/2),m[1]=Math.max(d,(y+d)/2)}var b=[Math.min(d,(g+d)/2),Math.max(d,(g+d)/2)];if(t>b[0]&&t<=b[1]||t>=m[0]&&t<=m[1]){({index:a}=n[l]);break}}else{var x=Math.min(c,h),M=Math.max(c,h);if(t>(x+d)/2&&t<=(M+d)/2){({index:a}=n[l]);break}}}else if(e){for(var w=0;w0&&w(e[w].coordinate+e[w-1].coordinate)/2&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w===o-1&&t>(e[w].coordinate+e[w-1].coordinate)/2){({index:a}=e[w]);break}}return a},eJ=()=>Ct(PO),dL=(t,e)=>e,tJ=(t,e,n)=>n,fL=(t,e,n,r)=>r,uFe=We(jc,t=>Xw(t,e=>e.coordinate)),hL=We([Zm,dL,tJ,fL],BQ),pL=We([hL,Qm,Mb,Cb],sL),dFe=(t,e,n)=>{if(e!=null){var r=Zm(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},nJ=We([Zm,dL,tJ,fL],$Q),WS=We([Rc,Pc,Sn,pi,jc,fL,nJ,Ab],HQ),fFe=We([hL,WS],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),rJ=We([jc,pL],jQ),hFe=We([nJ,pL,xd,Mb,rJ,Ab,dL],VQ),pFe=We([hL,pL],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),mFe=(t,e,n,r,i,s,a)=>{if(!(!t||!n||!r||!i)&&cFe(t,a)){var o=jPe(t,e),l=JQ(o,s,i,n,r),c=oFe(e,i,l,t);return{activeIndex:String(l),activeCoordinate:c}}},gFe=(t,e,n,r,i,s,a)=>{if(!(!t||!r||!i||!s||!n)){var o=JOe(t,n);if(o){var l=IPe(o,e),c=JQ(l,a,s,r,i),d=lFe(e,s,c,o);return{activeIndex:String(c),activeCoordinate:d}}}},xFe=(t,e,n,r,i,s,a,o)=>{if(!(!t||!e||!r||!i||!s))return e==="horizontal"||e==="vertical"?mFe(t,e,r,i,s,a,o):gFe(t,e,n,r,i,s,a)},bFe=We(t=>t.zIndex.zIndexMap,(t,e)=>e,(t,e,n)=>n,(t,e,n)=>{if(e!=null){var r=t[e];if(r!=null)return n?r.panoramaElementId:r.elementId}}),vFe=We(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(Kr)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:n4e}});function fV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function hV(t){for(var e=1;ehV(hV({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),wFe)},EFe=new Set(Object.values(Kr));function AFe(t){return EFe.has(t)}var iJ=Zs({name:"zIndex",initialState:MFe,reducers:{registerZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]?t.zIndexMap[n].consumers+=1:t.zIndexMap[n]={consumers:1,elementId:void 0,panoramaElementId:void 0}},prepare:dr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!AFe(n)&&delete t.zIndexMap[n])},prepare:dr()},registerZIndexPortalId:{reducer:(t,e)=>{var{zIndex:n,elementId:r,isPanorama:i}=e.payload;t.zIndexMap[n]?i?t.zIndexMap[n].panoramaElementId=r:t.zIndexMap[n].elementId=r:t.zIndexMap[n]={consumers:0,elementId:i?void 0:r,panoramaElementId:i?r:void 0}},prepare:dr()},unregisterZIndexPortalId:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(e.payload.isPanorama?t.zIndexMap[n].panoramaElementId=void 0:t.zIndexMap[n].elementId=void 0)},prepare:dr()}}}),{registerZIndexPortal:TFe,unregisterZIndexPortal:CFe,registerZIndexPortalId:NFe,unregisterZIndexPortalId:kFe}=iJ.actions,RFe=iJ.reducer;function Qs(t){var{zIndex:e,children:n}=t,r=mDe(),i=r&&e!==void 0&&e!==0,s=hs(),a=nr();E.useLayoutEffect(()=>i?(a(TFe({zIndex:e})),()=>{a(CFe({zIndex:e}))}):ob,[a,e,i]);var o=Ct(c=>bFe(c,e,s));if(!i)return n;if(!o)return null;var l=document.getElementById(o);return l?nc.createPortal(n,l):null}function TR(){return TR=Object.assign?Object.assign.bind():function(t){for(var e=1;eE.useContext(sJ),pN={exports:{}},mV;function FFe(){return mV||(mV=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(l,c,d){this.fn=l,this.context=c,this.once=d||!1}function s(l,c,d,h,g){if(typeof d!="function")throw new TypeError("The listener must be a function");var m=new i(d,h||l,g),v=n?n+c:c;return l._events[v]?l._events[v].fn?l._events[v]=[l._events[v],m]:l._events[v].push(m):(l._events[v]=m,l._eventsCount++),l}function a(l,c){--l._eventsCount===0?l._events=new r:delete l._events[c]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var c=[],d,h;if(this._eventsCount===0)return c;for(h in d=this._events)e.call(d,h)&&c.push(n?h.slice(1):h);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(d)):c},o.prototype.listeners=function(c){var d=n?n+c:c,h=this._events[d];if(!h)return[];if(h.fn)return[h.fn];for(var g=0,m=h.length,v=new Array(m);g{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),$Fe=aJ.reducer,{createEventEmitter:VFe}=aJ.actions;function GFe(t){return t.tooltip.syncInteraction}var WFe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},oJ=Zs({name:"chartData",initialState:WFe,reducers:{setChartData(t,e){if(t.chartData=e.payload,e.payload==null){t.dataStartIndex=0,t.dataEndIndex=0;return}e.payload.length>0&&t.dataEndIndex!==e.payload.length-1&&(t.dataEndIndex=e.payload.length-1)},setComputedData(t,e){t.computedData=e.payload},setDataStartEndIndexes(t,e){var{startIndex:n,endIndex:r}=e.payload;n!=null&&(t.dataStartIndex=n),r!=null&&(t.dataEndIndex=r)}}}),{setChartData:xV,setDataStartEndIndexes:qFe,setComputedData:b9e}=oJ.actions,XFe=oJ.reducer,KFe=["x","y"];function bV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _p(t){for(var e=1;el.rootProps.className);E.useEffect(()=>{if(t==null)return ob;var l=(c,d,h)=>{if(e!==h&&t===c){if(r==="index"){var g;if(a&&d!==null&&d!==void 0&&(g=d.payload)!==null&&g!==void 0&&g.coordinate&&d.payload.sourceViewBox){var m=d.payload.coordinate,{x:v,y}=m,b=JFe(m,KFe),{x,y:M,width:w,height:A}=d.payload.sourceViewBox,T=_p(_p({},b),{},{x:a.x+(w?(v-x)/w:0)*a.width,y:a.y+(A?(y-M)/A:0)*a.height});n(_p(_p({},d),{},{payload:_p(_p({},d.payload),{},{coordinate:T})}))}else n(d);return}if(i!=null){var R;if(typeof r=="function"){var C={activeTooltipIndex:d.payload.index==null?void 0:Number(d.payload.index),isTooltipActive:d.payload.active,activeIndex:d.payload.index==null?void 0:Number(d.payload.index),activeLabel:d.payload.label,activeDataKey:d.payload.dataKey,activeCoordinate:d.payload.coordinate},I=r(i,C);R=i[I]}else r==="value"&&(R=i.find(K=>String(K.value)===d.payload.label));var{coordinate:N}=d.payload;if(R==null||d.payload.active===!1||N==null||a==null){n(ER({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:D,y:z}=N,j=Math.min(D,a.x+a.width),W=Math.min(z,a.y+a.height),P={x:s==="horizontal"?R.coordinate:j,y:s==="horizontal"?W:R.coordinate},$=ER({active:d.payload.active,coordinate:P,dataKey:d.payload.dataKey,index:String(R.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n($)}}};return $0.on(CR,l),()=>{$0.off(CR,l)}},[o,n,e,t,r,i,s,a])}function n5e(){var t=Ct(DO),e=Ct(OO),n=nr();E.useEffect(()=>{if(t==null)return ob;var r=(i,s,a)=>{e!==a&&t===i&&n(qFe(s))};return $0.on(gV,r),()=>{$0.off(gV,r)}},[n,e,t])}function r5e(){var t=nr();E.useEffect(()=>{t(VFe())},[t]),t5e(),n5e()}function i5e(t,e,n,r,i,s){var a=Ct(m=>dFe(m,t,e)),o=Ct(OO),l=Ct(DO),c=Ct(nQ),d=Ct(GFe),h=d?.active,g=oM();E.useEffect(()=>{if(!h&&l!=null&&o!=null){var m=ER({active:s,coordinate:n,dataKey:a,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:g,graphicalItemId:void 0});$0.emit(CR,l,m,o)}},[h,n,a,i,r,o,l,c,s,g])}function vV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function yV(t){for(var e=1;e{C(aUe({shared:M,trigger:w,axisId:R,active:i,defaultIndex:I}))},[C,M,w,R,i,I]);var N=oM(),D=XY(),z=eUe(M),{activeIndex:j,isActive:W}=(e=Ct(pe=>pFe(pe,z,w,I)))!==null&&e!==void 0?e:{},P=Ct(pe=>hFe(pe,z,w,I)),$=Ct(pe=>rJ(pe,z,w,I)),K=Ct(pe=>fFe(pe,z,w,I)),G=P,Z=UFe(),Q=(n=i??W)!==null&&n!==void 0?n:!1,[ee,H]=KK([G,Q]),q=z==="axis"?$:void 0;i5e(z,w,K,q,j,Q);var te=T??Z;if(te==null||N==null||z==null)return null;var ae=G??_V;Q||(ae=_V),c&&ae.length&&(ae=VK(ae.filter(pe=>pe.value!=null&&(pe.hide!==!0||r.includeHidden)),g,l5e));var xe=ae.length>0,re=E.createElement(eOe,{allowEscapeViewBox:s,animationDuration:a,animationEasing:o,isAnimationActive:d,active:Q,coordinate:K,hasPayload:xe,offset:h,position:m,reverseDirection:v,useTranslate3d:y,viewBox:N,wrapperStyle:b,lastBoundingBox:ee,innerRef:H,hasPortalFromProps:!!T},c5e(l,yV(yV({},r),{},{payload:ae,label:q,active:Q,activeIndex:j,coordinate:K,accessibilityLayer:D})));return E.createElement(E.Fragment,null,nc.createPortal(re,te),Q&&E.createElement(IFe,{cursor:x,tooltipEventType:z,coordinate:K,payload:ae,index:j}))}var kb=t=>null;kb.displayName="Cell";function d5e(t,e,n){return(e=f5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function f5e(t){var e=h5e(t,"string");return typeof e=="symbol"?e:e+""}function h5e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class p5e{constructor(e){d5e(this,"cache",new Map),this.maxSize=e}get(e){var n=this.cache.get(e);return n!==void 0&&(this.cache.delete(e),this.cache.set(e,n)),n}set(e,n){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){var r=this.cache.keys().next().value;r!=null&&this.cache.delete(r)}this.cache.set(e,n)}clear(){this.cache.clear()}size(){return this.cache.size}}function SV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function m5e(t){for(var e=1;e{try{var n=document.getElementById(MV);n||(n=document.createElement("span"),n.setAttribute("id",MV),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,y5e,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},Kx=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||$m.isSsr)return{width:0,height:0};if(!lJ.enableCache)return EV(e,n);var r=_5e(e,n),i=wV.get(r);if(i)return i;var s=EV(e,n);return wV.set(r,s),s},AV=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,TV=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,S5e=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,w5e=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,cJ={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},M5e=Object.keys(cJ),Op="NaN";function E5e(t,e){return t*cJ[e]}class Fs{static parse(e){var n,[,r,i]=(n=w5e.exec(e))!==null&&n!==void 0?n:[];return new Fs(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,eo(e)&&(this.unit=""),n!==""&&!S5e.test(n)&&(this.num=NaN,this.unit=""),M5e.includes(n)&&(this.num=E5e(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new Fs(NaN,""):new Fs(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new Fs(NaN,""):new Fs(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Fs(NaN,""):new Fs(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Fs(NaN,""):new Fs(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return eo(this.num)}}function uJ(t){if(t.includes(Op))return Op;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,s]=(n=AV.exec(e))!==null&&n!==void 0?n:[],a=Fs.parse(r??""),o=Fs.parse(s??""),l=i==="*"?a.multiply(o):a.divide(o);if(l.isNaN())return Op;e=e.replace(AV,l.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var c,[,d,h,g]=(c=TV.exec(e))!==null&&c!==void 0?c:[],m=Fs.parse(d??""),v=Fs.parse(g??""),y=h==="+"?m.add(v):m.subtract(v);if(y.isNaN())return Op;e=e.replace(TV,y.toString())}return e}var CV=/\(([^()]*)\)/;function A5e(t){for(var e=t,n;(n=CV.exec(e))!=null;){var[,r]=n;e=e.replace(CV,uJ(r))}return e}function T5e(t){var e=t.replace(/\s+/g,"");return e=A5e(e),e=uJ(e),e}function C5e(t){try{return T5e(t)}catch{return Op}}function gN(t){var e=C5e(t.slice(5,-1));return e===Op?"":e}var N5e=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],k5e=["dx","dy","angle","className","breakAll"];function NR(){return NR=Object.assign?Object.assign.bind():function(t){for(var e=1;e{var{children:e,breakAll:n,style:r}=t;try{var i=[];vr(e)||(n?i=e.toString().split(""):i=e.toString().split(dJ));var s=i.map(o=>({word:o,width:Kx(o,r).width})),a=n?0:Kx(" ",r).width;return{wordsWithComputedWidth:s,spaceWidth:a}}catch{return null}};function P5e(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var hJ=(t,e,n,r)=>t.reduce((i,s)=>{var{word:a,width:o}=s,l=i[i.length-1];if(l&&o!=null&&(e==null||r||l.width+o+nt.reduce((e,n)=>e.width>n.width?e:n),D5e="…",kV=(t,e,n,r,i,s,a,o)=>{var l=t.slice(0,e),c=fJ({breakAll:n,style:r,children:l+D5e});if(!c)return[!1,[]];var d=hJ(c.wordsWithComputedWidth,s,a,o),h=d.length>i||pJ(d).width>Number(s);return[h,d]},O5e=(t,e,n,r,i)=>{var{maxLines:s,children:a,style:o,breakAll:l}=t,c=Tt(s),d=String(a),h=hJ(e,r,n,i);if(!c||i)return h;var g=h.length>s||pJ(h).width>Number(r);if(!g)return h;for(var m=0,v=d.length-1,y=0,b;m<=v&&y<=d.length-1;){var x=Math.floor((m+v)/2),M=x-1,[w,A]=kV(d,M,l,o,s,r,n,i),[T]=kV(d,x,l,o,s,r,n,i);if(!w&&!T&&(m=x+1),w&&T&&(v=x-1),!w&&T){b=A;break}y++}return b||h},RV=t=>{var e=vr(t)?[]:t.toString().split(dJ);return[{words:e,width:void 0}]},L5e=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:s,maxLines:a}=t;if((e||n)&&!$m.isSsr){var o,l,c=fJ({breakAll:s,children:r,style:i});if(c){var{wordsWithComputedWidth:d,spaceWidth:h}=c;o=d,l=h}else return RV(r);return O5e({breakAll:s,children:r,maxLines:a,style:i},o,l,e,!!n)}return RV(r)},mJ="#808080",j5e={angle:0,breakAll:!1,capHeight:"0.71em",fill:mJ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},kM=E.forwardRef((t,e)=>{var n=ei(t,j5e),{x:r,y:i,lineHeight:s,capHeight:a,fill:o,scaleToFit:l,textAnchor:c,verticalAnchor:d}=n,h=NV(n,N5e),g=E.useMemo(()=>L5e({breakAll:h.breakAll,children:h.children,maxLines:h.maxLines,scaleToFit:l,style:h.style,width:h.width}),[h.breakAll,h.children,h.maxLines,l,h.style,h.width]),{dx:m,dy:v,angle:y,className:b,breakAll:x}=h,M=NV(h,k5e);if(!ul(r)||!ul(i)||g.length===0)return null;var w=Number(r)+(Tt(m)?m:0),A=Number(i)+(Tt(v)?v:0);if(!cr(w)||!cr(A))return null;var T;switch(d){case"start":T=gN("calc(".concat(a,")"));break;case"middle":T=gN("calc(".concat((g.length-1)/2," * -").concat(s," + (").concat(a," / 2))"));break;default:T=gN("calc(".concat(g.length-1," * -").concat(s,")"));break}var R=[];if(l){var C=g[0].width,{width:I}=h;R.push("scale(".concat(Tt(I)&&Tt(C)?I/C:1,")"))}return y&&R.push("rotate(".concat(y,", ").concat(w,", ").concat(A,")")),R.length&&(M.transform=R.join(" ")),E.createElement("text",NR({},Cs(M),{ref:e,x:w,y:A,className:An("recharts-text",b),textAnchor:c,fill:o.includes("url")?mJ:o}),g.map((N,D)=>{var z=N.words.join(x?"":" ");return E.createElement("tspan",{x:w,dy:D===0?T:s,key:"".concat(z,"-").concat(D)},z)}))});kM.displayName="Text";var I5e=["labelRef"];function U5e(t,e){if(t==null)return{};var n,r,i=F5e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:a,children:o}=t,l=E.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:a}),[e,n,r,i,s,a]);return E.createElement(gJ.Provider,{value:l},o)},xJ=()=>{var t=E.useContext(gJ),e=oM();return t||LY(e)},V5e=E.createContext(null),G5e=()=>{var t=E.useContext(V5e),e=Ct(oQ);return t||e},W5e=t=>{var{value:e,formatter:n}=t,r=vr(t.children)?e:t.children;return typeof n=="function"?n(r):r},gL=t=>t!=null&&typeof t=="function",q5e=(t,e)=>{var n=ki(e-t),r=Math.min(Math.abs(e-t),360);return n*r},X5e=(t,e,n,r,i)=>{var{offset:s,className:a}=t,{cx:o,cy:l,innerRadius:c,outerRadius:d,startAngle:h,endAngle:g,clockWise:m}=i,v=(c+d)/2,y=q5e(h,g),b=y>=0?1:-1,x,M;switch(e){case"insideStart":x=h+b*s,M=m;break;case"insideEnd":x=g-b*s,M=!m;break;case"end":x=g+b*s,M=m;break;default:throw new Error("Unsupported position ".concat(e))}M=y<=0?M:!M;var w=Xr(o,l,v,x),A=Xr(o,l,v,x+(M?1:-1)*359),T="M".concat(w.x,",").concat(w.y,` A`).concat(v,",").concat(v,",0,1,").concat(M?0:1,`, - `).concat(A.x,",").concat(A.y),R=vr(t.id)?N0("recharts-radial-line-"):t.id;return E.createElement("text",tc({},r,{dominantBaseline:"central",className:An("recharts-radial-bar-label",a)}),E.createElement("defs",null,E.createElement("path",{id:R,d:T})),E.createElement("textPath",{xlinkHref:"#".concat(R)},n))},K5e=(t,e,n)=>{var{cx:r,cy:i,innerRadius:s,outerRadius:a,startAngle:o,endAngle:l}=t,c=(o+l)/2;if(n==="outside"){var{x:d,y:h}=Xr(r,i,a+e,c);return{x:d,y:h,textAnchor:d>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var g=(s+a)/2,{x:m,y:v}=Xr(r,i,g,c);return{x:m,y:v,textAnchor:"middle",verticalAnchor:"middle"}},kR=t=>"cx"in t&&Tt(t.cx),Y5e=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,s;n!=null&&!kR(n)&&(s=n);var{x:a,y:o,upperWidth:l,lowerWidth:c,height:d}=e,h=a,g=a+(l-c)/2,m=(h+g)/2,v=(l+c)/2,y=h+l/2,b=d>=0?1:-1,x=b*r,M=b>0?"end":"start",w=b>0?"start":"end",A=l>=0?1:-1,T=A*r,R=A>0?"end":"start",C=A>0?"start":"end";if(i==="top"){var I={x:h+l/2,y:o-x,textAnchor:"middle",verticalAnchor:M};return Dr(Dr({},I),s?{height:Math.max(o-s.y,0),width:l}:{})}if(i==="bottom"){var N={x:g+c/2,y:o+d+x,textAnchor:"middle",verticalAnchor:w};return Dr(Dr({},N),s?{height:Math.max(s.y+s.height-(o+d),0),width:c}:{})}if(i==="left"){var D={x:m-T,y:o+d/2,textAnchor:R,verticalAnchor:"middle"};return Dr(Dr({},D),s?{width:Math.max(D.x-s.x,0),height:d}:{})}if(i==="right"){var z={x:m+v+T,y:o+d/2,textAnchor:C,verticalAnchor:"middle"};return Dr(Dr({},z),s?{width:Math.max(s.x+s.width-z.x,0),height:d}:{})}var j=s?{width:v,height:d}:{};return i==="insideLeft"?Dr({x:m+T,y:o+d/2,textAnchor:C,verticalAnchor:"middle"},j):i==="insideRight"?Dr({x:m+v-T,y:o+d/2,textAnchor:R,verticalAnchor:"middle"},j):i==="insideTop"?Dr({x:h+l/2,y:o+x,textAnchor:"middle",verticalAnchor:w},j):i==="insideBottom"?Dr({x:g+c/2,y:o+d-x,textAnchor:"middle",verticalAnchor:M},j):i==="insideTopLeft"?Dr({x:h+T,y:o+x,textAnchor:C,verticalAnchor:w},j):i==="insideTopRight"?Dr({x:h+l-T,y:o+x,textAnchor:R,verticalAnchor:w},j):i==="insideBottomLeft"?Dr({x:g+T,y:o+d-x,textAnchor:C,verticalAnchor:M},j):i==="insideBottomRight"?Dr({x:g+c-T,y:o+d-x,textAnchor:R,verticalAnchor:M},j):i&&typeof i=="object"&&(Tt(i.x)||Sc(i.x))&&(Tt(i.y)||Sc(i.y))?Dr({x:a+us(i.x,v),y:o+us(i.y,d),textAnchor:"end",verticalAnchor:"end"},j):Dr({x:y,y:o+d/2,textAnchor:"middle",verticalAnchor:"middle"},j)},Z5e={angle:0,offset:5,zIndex:Kr.label,position:"middle",textBreakAll:!1};function Nu(t){var e=ei(t,Z5e),{viewBox:n,position:r,value:i,children:s,content:a,className:o="",textBreakAll:l,labelRef:c}=e,d=G5e(),h=xJ(),g=r==="center"?h:d??h,m,v,y;if(n==null?m=g:kR(n)?m=n:m=LY(n),!m||vr(i)&&vr(s)&&!E.isValidElement(a)&&typeof a!="function")return null;var b=Dr(Dr({},e),{},{viewBox:m});if(E.isValidElement(a)){var{labelRef:x}=b,M=U5e(b,I5e);return E.cloneElement(a,M)}if(typeof a=="function"){if(v=E.createElement(a,b),E.isValidElement(v))return v}else v=W5e(e);var w=Cs(e);if(kR(m)){if(r==="insideStart"||r==="insideEnd"||r==="end")return X5e(e,r,v,w,m);y=K5e(m,e.offset,e.position)}else y=Y5e(e,m);return E.createElement(Qs,{zIndex:e.zIndex},E.createElement(kM,tc({ref:c,className:An("recharts-label",o)},w,y,{textAnchor:P5e(w.textAnchor)?w.textAnchor:y.textAnchor,breakAll:l}),v))}Nu.displayName="Label";var Q5e=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?E.createElement(Nu,tc({key:"label-implicit"},r)):ul(t)?E.createElement(Nu,tc({key:"label-implicit",value:t},r)):E.isValidElement(t)?t.type===Nu?E.cloneElement(t,Dr({key:"label-implicit"},r)):E.createElement(Nu,tc({key:"label-implicit",content:t},r)):gL(t)?E.createElement(Nu,tc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?E.createElement(Nu,tc({},t,{key:"label-implicit"},r)):null};function J5e(t){var{label:e,labelRef:n}=t,r=xJ();return Q5e(e,r,n)||null}var xN={},bN={},DV;function eze(){return DV||(DV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(bN)),bN}var vN={},OV;function tze(){return OV||(OV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(vN)),vN}var LV;function nze(){return LV||(LV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eze(),n=tze(),r=VD();function i(s){if(r.isArrayLike(s))return e.last(n.toArray(s))}t.last=i})(xN)),xN}var yN,jV;function rze(){return jV||(jV=1,yN=nze().last),yN}var ize=rze();const sze=ro(ize);var aze=["valueAccessor"],oze=["dataKey","clockWise","id","textBreakAll","zIndex"];function qS(){return qS=Object.assign?Object.assign.bind():function(t){for(var e=1;eArray.isArray(t.value)?sze(t.value):t.value,bJ=E.createContext(void 0),vJ=bJ.Provider,yJ=E.createContext(void 0),uze=yJ.Provider;function dze(){return E.useContext(bJ)}function fze(){return E.useContext(yJ)}function W_(t){var{valueAccessor:e=cze}=t,n=IV(t,aze),{dataKey:r,clockWise:i,id:s,textBreakAll:a,zIndex:o}=n,l=IV(n,oze),c=dze(),d=fze(),h=c||d;return!h||!h.length?null:E.createElement(Qs,{zIndex:o??Kr.label},E.createElement(jr,{className:"recharts-label-list"},h.map((g,m)=>{var v,y=vr(r)?e(g,m):Yn(g&&g.payload,r),b=vr(s)?{}:{id:"".concat(s,"-").concat(m)};return E.createElement(Nu,qS({key:"label-".concat(m)},Cs(g),l,b,{fill:(v=n.fill)!==null&&v!==void 0?v:g.fill,parentViewBox:g.parentViewBox,value:y,textBreakAll:a,viewBox:g.viewBox,index:m,zIndex:0}))})))}W_.displayName="LabelList";function xL(t){var{label:e}=t;return e?e===!0?E.createElement(W_,{key:"labelList-implicit"}):E.isValidElement(e)||gL(e)?E.createElement(W_,{key:"labelList-implicit",content:e}):typeof e=="object"?E.createElement(W_,qS({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function RR(){return RR=Object.assign?Object.assign.bind():function(t){for(var e=1;e{var{cx:e,cy:n,r,className:i}=t,s=An("recharts-dot",i);return Tt(e)&&Tt(n)&&Tt(r)?E.createElement("circle",RR({},Xs(t),$D(t),{className:s,cx:e,cy:n,r})):null},SJ=t=>t.graphicalItems.polarItems,hze=We([pr,_b],FO),RM=We([SJ,_r,hze],zO),pze=We([RM],BO),PM=We([pze,NO],HO),mze=We([PM,_r,RM],VO);We([PM,_r,RM],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var s,a=Yn(r,(s=e.dataKey)!==null&&s!==void 0?s:i.dataKey);return{value:a,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:Yn(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var UV=()=>{},gze=We([PM,_r,RM,TM,pr],XO),xze=We([_r,WO,qO,UV,gze,UV,Sn,pr],KO),wJ=We([_r,Sn,PM,mze,yb,pr,xze],YO),bze=We([wJ,_r,Km],JO);We([_r,wJ,bze,pr],tL);var vze={radiusAxis:{},angleAxis:{}},MJ=Zs({name:"polarAxis",initialState:vze,reducers:{addRadiusAxis(t,e){t.radiusAxis[e.payload.id]=e.payload},removeRadiusAxis(t,e){delete t.radiusAxis[e.payload.id]},addAngleAxis(t,e){t.angleAxis[e.payload.id]=e.payload},removeAngleAxis(t,e){delete t.angleAxis[e.payload.id]}}}),{addRadiusAxis:v9e,removeRadiusAxis:y9e,addAngleAxis:_9e,removeAngleAxis:S9e}=MJ.actions,yze=MJ.reducer;function FV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function zV(t){for(var e=1;ee,bL=We([SJ,Mze],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),Eze=[],vL=(t,e,n)=>n?.length===0?Eze:n,EJ=We([NO,bL,vL],(t,e,n)=>{var{chartData:r}=t;if(e!=null){var i;if(e?.data!=null&&e.data.length>0?i=e.data:i=r,(!i||!i.length)&&n!=null&&(i=n.map(s=>zV(zV({},e.presentationProps),s.props))),i!=null)return i}}),Aze=We([EJ,bL,vL],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var s,a=Yn(r,e.nameKey,e.name),o;return n!=null&&(s=n[i])!==null&&s!==void 0&&(s=s.props)!==null&&s!==void 0&&s.fill?o=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?o=r.fill:o=e.fill,{value:Bm(a,e.dataKey),color:o,payload:r,type:e.legendType}})}),Tze=We([EJ,bL,vL,pi],(t,e,n,r)=>{if(!(e==null||t==null))return CBe({offset:r,pieSettings:e,displayedData:t,cells:n})}),_N={exports:{}},zn={};var BV;function Cze(){if(BV)return zn;BV=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),a=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),g=Symbol.for("react.view_transition"),m=Symbol.for("react.client.reference");function v(y){if(typeof y=="object"&&y!==null){var b=y.$$typeof;switch(b){case t:switch(y=y.type,y){case n:case i:case r:case l:case c:case g:return y;default:switch(y=y&&y.$$typeof,y){case a:case o:case h:case d:return y;case s:return y;default:return b}}case e:return b}}}return zn.ContextConsumer=s,zn.ContextProvider=a,zn.Element=t,zn.ForwardRef=o,zn.Fragment=n,zn.Lazy=h,zn.Memo=d,zn.Portal=e,zn.Profiler=i,zn.StrictMode=r,zn.Suspense=l,zn.SuspenseList=c,zn.isContextConsumer=function(y){return v(y)===s},zn.isContextProvider=function(y){return v(y)===a},zn.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},zn.isForwardRef=function(y){return v(y)===o},zn.isFragment=function(y){return v(y)===n},zn.isLazy=function(y){return v(y)===h},zn.isMemo=function(y){return v(y)===d},zn.isPortal=function(y){return v(y)===e},zn.isProfiler=function(y){return v(y)===i},zn.isStrictMode=function(y){return v(y)===r},zn.isSuspense=function(y){return v(y)===l},zn.isSuspenseList=function(y){return v(y)===c},zn.isValidElementType=function(y){return typeof y=="string"||typeof y=="function"||y===n||y===i||y===r||y===l||y===c||typeof y=="object"&&y!==null&&(y.$$typeof===h||y.$$typeof===d||y.$$typeof===a||y.$$typeof===s||y.$$typeof===o||y.$$typeof===m||y.getModuleId!==void 0)},zn.typeOf=v,zn}var HV;function Nze(){return HV||(HV=1,_N.exports=Cze()),_N.exports}var kze=Nze(),$V=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",VV=null,SN=null,AJ=t=>{if(t===VV&&Array.isArray(SN))return SN;var e=[];return E.Children.forEach(t,n=>{vr(n)||(kze.isFragment(n)?e=e.concat(AJ(n.props.children)):e.push(n))}),SN=e,VV=t,e};function yL(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>$V(i)):r=[$V(e)],AJ(t).forEach(i=>{var s=Wf(i,"type.displayName")||Wf(i,"type.name");s&&r.indexOf(s)!==-1&&n.push(i)}),n}var TJ=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,wN={},GV;function Rze(){return GV||(GV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){if(typeof n!="object"||n==null)return!1;if(Object.getPrototypeOf(n)===null)return!0;if(Object.prototype.toString.call(n)!=="[object Object]"){const i=n[Symbol.toStringTag];return i==null||!Object.getOwnPropertyDescriptor(n,Symbol.toStringTag)?.writable?!1:n.toString()===`[object ${i}]`}let r=n;for(;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(n)===r}t.isPlainObject=e})(wN)),wN}var MN,WV;function Pze(){return WV||(WV=1,MN=Rze().isPlainObject),MN}var Dze=Pze();const Oze=ro(Dze);function qV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function XV(t){for(var e=1;e{var s=n-r,a;return a="M ".concat(t,",").concat(e),a+="L ".concat(t+n,",").concat(e),a+="L ".concat(t+n-s/2,",").concat(e+i),a+="L ".concat(t+n-s/2-r,",").concat(e+i),a+="L ".concat(t,",").concat(e," Z"),a},Uze={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Fze=t=>{var e=ei(t,Uze),{x:n,y:r,upperWidth:i,lowerWidth:s,height:a,className:o}=e,{animationEasing:l,animationDuration:c,animationBegin:d,isUpdateAnimationActive:h}=e,g=E.useRef(null),[m,v]=E.useState(-1),y=E.useRef(i),b=E.useRef(s),x=E.useRef(a),M=E.useRef(n),w=E.useRef(r),A=mb(t,"trapezoid-");if(E.useEffect(()=>{if(g.current&&g.current.getTotalLength)try{var P=g.current.getTotalLength();P&&v(P)}catch{}},[]),n!==+n||r!==+r||i!==+i||s!==+s||a!==+a||i===0&&s===0||a===0)return null;var T=An("recharts-trapezoid",o);if(!h)return E.createElement("g",null,E.createElement("path",XS({},Cs(e),{className:T,d:KV(n,r,i,s,a)})));var R=y.current,C=b.current,I=x.current,N=M.current,D=w.current,z="0px ".concat(m===-1?1:m,"px"),j="".concat(m,"px 0px"),W=KY(["strokeDasharray"],c,l);return E.createElement(pb,{animationId:A,key:A,canBegin:m>0,duration:c,easing:l,isActive:h,begin:d},P=>{var $=lr(R,i,P),K=lr(C,s,P),G=lr(I,a,P),Z=lr(N,n,P),Q=lr(D,r,P);g.current&&(y.current=$,b.current=K,x.current=G,M.current=Z,w.current=Q);var ee=P>0?{transition:W,strokeDasharray:j}:{strokeDasharray:z};return E.createElement("path",XS({},Cs(e),{className:T,d:KV(Z,Q,$,K,G),ref:g,style:XV(XV({},ee),e.style)}))})},zze=["option","shapeType","propTransformer","activeClassName"];function Bze(t,e){if(t==null)return{};var n,r,i=Hze(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r{var r=nr();return(i,s)=>a=>{t?.(i,s,a),r(UQ({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},SL=t=>{var e=nr();return(n,r)=>i=>{t?.(n,r,i),e(oUe())}},wL=(t,e,n)=>{var r=nr();return(i,s)=>a=>{t?.(i,s,a),r(lUe({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function ML(t){var{tooltipEntrySettings:e}=t,n=nr(),r=hs(),i=E.useRef(null);return E.useLayoutEffect(()=>{r||(i.current===null?n(rUe(e)):i.current!==e&&n(iUe({prev:i.current,next:e})),i.current=e)},[e,n,r]),E.useLayoutEffect(()=>()=>{i.current&&(n(sUe(i.current)),i.current=null)},[n]),null}function NJ(t){var{legendPayload:e}=t,n=nr(),r=hs(),i=E.useRef(null);return E.useLayoutEffect(()=>{r||(i.current===null?n(VY(e)):i.current!==e&&n(GY({prev:i.current,next:e})),i.current=e)},[n,r,e]),E.useLayoutEffect(()=>()=>{i.current&&(n(WY(i.current)),i.current=null)},[n]),null}function Kze(t){var{legendPayload:e}=t,n=nr(),r=Ct(Sn),i=E.useRef(null);return E.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(VY(e)):i.current!==e&&n(GY({prev:i.current,next:e})),i.current=e)},[n,r,e]),E.useLayoutEffect(()=>()=>{i.current&&(n(WY(i.current)),i.current=null)},[n]),null}var EN,Yze=()=>{var[t]=E.useState(()=>N0("uid-"));return t},Zze=(EN=Cne.useId)!==null&&EN!==void 0?EN:Yze;function kJ(t,e){var n=Zze();return e||(t?"".concat(t,"-").concat(n):n)}var Qze=E.createContext(void 0),EL=t=>{var{id:e,type:n,children:r}=t,i=kJ("recharts-".concat(n),e);return E.createElement(Qze.Provider,{value:i},r(i))},Jze={cartesianItems:[],polarItems:[]},RJ=Zs({name:"graphicalItems",initialState:Jze,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:dr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=To(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:dr()},removeCartesianGraphicalItem:{reducer(t,e){var n=To(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:dr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:dr()},removePolarGraphicalItem:{reducer(t,e){var n=To(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:dr()}}}),{addCartesianGraphicalItem:eBe,replaceCartesianGraphicalItem:tBe,removeCartesianGraphicalItem:nBe,addPolarGraphicalItem:rBe,removePolarGraphicalItem:iBe}=RJ.actions,sBe=RJ.reducer,aBe=t=>{var e=nr(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(eBe(t)):n.current!==t&&e(tBe({prev:n.current,next:t})),n.current=t},[e,t]),E.useLayoutEffect(()=>()=>{n.current&&(e(nBe(n.current)),n.current=null)},[e]),null},PJ=E.memo(aBe);function oBe(t){var e=nr();return E.useLayoutEffect(()=>(e(rBe(t)),()=>{e(iBe(t))}),[e,t]),null}var lBe=["key"],cBe=["onMouseEnter","onClick","onMouseLeave"],uBe=["id"],dBe=["id"];function QV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ar(t){for(var e=1;eyL(t.children,kb),[t.children]),n=Ct(r=>Aze(r,t.id,e));return n==null?null:E.createElement(Kze,{legendPayload:n})}var xBe=E.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:s,fill:a,name:o,hide:l,tooltipType:c}=t,d={dataDefinedOnItem:r.map(h=>h.tooltipPayload),positions:r.map(h=>h.tooltipPosition),settings:{stroke:i,strokeWidth:s,fill:a,dataKey:e,nameKey:n,name:Bm(o,e),hide:l,type:c,color:a,unit:""}};return E.createElement(ML,{tooltipEntrySettings:d})}),bBe=(t,e)=>t>e?"start":tus(typeof e=="function"?e(t):e,n,n*.8),yBe=(t,e,n)=>{var{top:r,left:i,width:s,height:a}=e,o=eZ(s,a),l=i+us(t.cx,s,s/2),c=r+us(t.cy,a,a/2),d=us(t.innerRadius,o,0),h=vBe(n,t.outerRadius,o),g=t.maxRadius||Math.sqrt(s*s+a*a)/2;return{cx:l,cy:c,innerRadius:d,outerRadius:h,maxRadius:g}},_Be=(t,e)=>{var n=ki(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function SBe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var wBe=(t,e)=>{if(E.isValidElement(t))return E.cloneElement(t,e);if(typeof t=="function")return t(e);var n=An("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=DM(e,lBe);return E.createElement(Xp,ld({},i,{type:"linear",className:n}))},MBe=(t,e,n)=>{if(E.isValidElement(t))return E.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),E.isValidElement(r)))return r;var i=An("recharts-pie-label-text",SBe(t));return E.createElement(kM,ld({},e,{alignmentBaseline:"middle",className:i}),r)};function EBe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:s,dataKey:a}=n;if(!r||!i||!e)return null;var o=Xs(n),l=Gf(i),c=Gf(s),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,h=e.map((g,m)=>{var v=(g.startAngle+g.endAngle)/2,y=Xr(g.cx,g.cy,g.outerRadius+d,v),b=Ar(Ar(Ar(Ar({},o),g),{},{stroke:"none"},l),{},{index:m,textAnchor:bBe(y.x,g.cx)},y),x=Ar(Ar(Ar(Ar({},o),g),{},{fill:"none",stroke:g.fill},c),{},{index:m,points:[Xr(g.cx,g.cy,g.outerRadius,v),y],key:"line"});return E.createElement(Qs,{zIndex:Kr.label,key:"label-".concat(g.startAngle,"-").concat(g.endAngle,"-").concat(g.midAngle,"-").concat(m)},E.createElement(jr,null,s&&wBe(s,x),MBe(i,b,Yn(g,a))))});return E.createElement(jr,{className:"recharts-pie-labels"},h)}function ABe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?E.createElement(xL,{label:i}):E.createElement(EBe,{sectors:e,props:n,showLabels:r})}function TBe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:s,id:a}=t,o=Ct(od),l=Ct(uL),c=Ct(qUe),{onMouseEnter:d,onClick:h,onMouseLeave:g}=i,m=DM(i,cBe),v=_L(d,i.dataKey,a),y=SL(g),b=wL(h,i.dataKey,a);return e==null||e.length===0?null:E.createElement(E.Fragment,null,e.map((x,M)=>{if(x?.startAngle===0&&x?.endAngle===0&&e.length!==1)return null;var w=c==null||c===a,A=String(M)===o&&(l==null||i.dataKey===l)&&w,T=o?r:null,R=n&&A?n:T,C=Ar(Ar({},x),{},{stroke:x.stroke,tabIndex:-1,[kY]:M,[RY]:i.dataKey});return E.createElement(jr,ld({key:"sector-".concat(x?.startAngle,"-").concat(x?.endAngle,"-").concat(x.midAngle,"-").concat(M),tabIndex:-1,className:"recharts-pie-sector"},lb(m,x,M),{onMouseEnter:v(x,M),onMouseLeave:y(x,M),onClick:b(x,M)}),E.createElement(CJ,ld({option:s??R,index:M,shapeType:"sector",isActive:A},C)))}))}function CBe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:s}=t,{cornerRadius:a,startAngle:o,endAngle:l,dataKey:c,nameKey:d,tooltipType:h}=n,g=Math.abs(n.minAngle),m=_Be(o,l),v=Math.abs(m),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,b=r.filter(R=>Yn(R,c,0)!==0).length,x=(v>=360?b:b-1)*y,M=v-b*g-x,w=r.reduce((R,C)=>{var I=Yn(C,c,0);return R+(Tt(I)?I:0)},0),A;if(w>0){var T;A=r.map((R,C)=>{var I=Yn(R,c,0),N=Yn(R,d,C),D=yBe(n,s,R),z=(Tt(I)?I:0)/w,j,W=Ar(Ar({},R),i&&i[C]&&i[C].props);C?j=T.endAngle+ki(m)*y*(I!==0?1:0):j=o;var P=j+ki(m)*((I!==0?g:0)+z*M),$=(j+P)/2,K=(D.innerRadius+D.outerRadius)/2,G=[{name:N,value:I,payload:W,dataKey:c,type:h}],Z=Xr(D.cx,D.cy,K,$);return T=Ar(Ar(Ar(Ar({},n.presentationProps),{},{percent:z,cornerRadius:typeof a=="string"?parseFloat(a):a,name:N,tooltipPayload:G,midAngle:$,middleRadius:K,tooltipPosition:Z},W),D),{},{value:I,dataKey:c,startAngle:j,endAngle:P,payload:W,paddingAngle:ki(m)*y}),T})}return A}function NBe(t){var{showLabels:e,sectors:n,children:r}=t,i=E.useMemo(()=>!e||!n?[]:n.map(s=>({value:s.value,payload:s.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:s.cx,cy:s.cy,innerRadius:s.innerRadius,outerRadius:s.outerRadius,startAngle:s.startAngle,endAngle:s.endAngle,clockWise:!1},fill:s.fill})),[n,e]);return E.createElement(uze,{value:e?i:void 0},r)}function kBe(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:s,animationBegin:a,animationDuration:o,animationEasing:l,activeShape:c,inactiveShape:d,onAnimationStart:h,onAnimationEnd:g}=e,m=mb(e,"recharts-pie-"),v=n.current,[y,b]=E.useState(!1),x=E.useCallback(()=>{typeof g=="function"&&g(),b(!1)},[g]),M=E.useCallback(()=>{typeof h=="function"&&h(),b(!0)},[h]);return E.createElement(NBe,{showLabels:!y,sectors:i},E.createElement(pb,{animationId:m,begin:a,duration:o,isActive:s,easing:l,onAnimationStart:M,onAnimationEnd:x,key:m},w=>{var A=[],T=i&&i[0],R=T?.startAngle;return i?.forEach((C,I)=>{var N=v&&v[I],D=I>0?Wf(C,"paddingAngle",0):0;if(N){var z=lr(N.endAngle-N.startAngle,C.endAngle-C.startAngle,w),j=Ar(Ar({},C),{},{startAngle:R+D,endAngle:R+z+D});A.push(j),R=j.endAngle}else{var{endAngle:W,startAngle:P}=C,$=lr(0,W-P,w),K=Ar(Ar({},C),{},{startAngle:R+D,endAngle:R+$+D});A.push(K),R=K.endAngle}}),n.current=A,E.createElement(jr,null,E.createElement(TBe,{sectors:A,activeShape:c,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),E.createElement(ABe,{showLabels:!y,sectors:i,props:e}),e.children)}var RBe={animationBegin:400,animationDuration:1500,animationEasing:"ease",cx:"50%",cy:"50%",dataKey:"value",endAngle:360,fill:"#808080",hide:!1,innerRadius:0,isAnimationActive:"auto",label:!1,labelLine:!0,legendType:"rect",minAngle:0,nameKey:"name",outerRadius:"80%",paddingAngle:0,rootTabIndex:0,startAngle:0,stroke:"#fff",zIndex:Kr.area};function PBe(t){var{id:e}=t,n=DM(t,uBe),{hide:r,className:i,rootTabIndex:s}=t,a=E.useMemo(()=>yL(t.children,kb),[t.children]),o=Ct(d=>Tze(d,e,a)),l=E.useRef(null),c=An("recharts-pie",i);return r||o==null?(l.current=null,E.createElement(jr,{tabIndex:s,className:c})):E.createElement(Qs,{zIndex:t.zIndex},E.createElement(xBe,{dataKey:t.dataKey,nameKey:t.nameKey,sectors:o,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,tooltipType:t.tooltipType}),E.createElement(jr,{tabIndex:s,className:c},E.createElement(kBe,{props:Ar(Ar({},n),{},{sectors:o}),previousSectorsRef:l,id:e})))}function DJ(t){var e=ei(t,RBe),{id:n}=e,r=DM(e,dBe),i=Xs(r);return E.createElement(EL,{id:n,type:"pie"},s=>E.createElement(E.Fragment,null,E.createElement(oBe,{type:"pie",id:s,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:e.maxRadius}),E.createElement(gBe,ld({},r,{id:s})),E.createElement(PBe,ld({},r,{id:s}))))}DJ.displayName="Pie";var DBe=["points"];function JV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function AN(t){for(var e=1;e{var b,x,M=AN(AN(AN({r:3},a),h),{},{index:y,cx:(b=v.x)!==null&&b!==void 0?b:void 0,cy:(x=v.y)!==null&&x!==void 0?x:void 0,dataKey:s,value:v.value,payload:v.payload,points:e});return E.createElement(FBe,{key:"dot-".concat(y),option:n,dotProps:M,className:i})}),m={};return o&&l!=null&&(m.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(l,")")),E.createElement(Qs,{zIndex:c},E.createElement(jr,YS({className:r},m),g))}function eG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function tG(t){for(var e=1;e({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),t6e=We([e6e,Rc,Pc],(t,e,n)=>{if(!(!t||e==null||n==null))return{x:t.left,y:t.top,width:Math.max(0,e-t.left-t.right),height:Math.max(0,n-t.top-t.bottom)}}),AL=()=>Ct(t6e),n6e=()=>Ct(QUe);function nG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function TN(t){for(var e=1;e{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:s,clipPath:a}=t;if(i===!1||e.x==null||e.y==null)return null;var o={index:n,dataKey:s,cx:e.x,cy:e.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:e.payload,value:e.value},l=TN(TN(TN({},o),Gf(i)),$D(i)),c;return E.isValidElement(i)?c=E.cloneElement(i,l):typeof i=="function"?c=i(l):c=E.createElement(_J,l),E.createElement(jr,{className:"recharts-active-dot",clipPath:a},c)};function rG(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:s,zIndex:a=Kr.activeDot}=t,o=Ct(od),l=n6e();if(e==null||l==null)return null;var c=e.find(d=>l.includes(d.payload));return vr(c)?null:E.createElement(Qs,{zIndex:a},E.createElement(a6e,{point:c,childIndex:Number(o),mainColor:n,dataKey:i,activeDot:r,clipPath:s}))}var o6e="Invariant failed";function l6e(t,e){throw new Error(o6e)}var c6e=["x","y"];function PR(){return PR=Object.assign?Object.assign.bind():function(t){for(var e=1;e1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Tt(e))return e;var s=Tt(r)||vr(r);return s?e(r,i):(s||l6e(),n)}},x6e={},LJ=Zs({name:"errorBars",initialState:x6e,reducers:{addErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]||(t[n]=[]),t[n].push(r)},replaceErrorBar:(t,e)=>{var{itemId:n,prev:r,next:i}=e.payload;t[n]&&(t[n]=t[n].map(s=>s.dataKey===r.dataKey&&s.direction===r.direction?i:s))},removeErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]&&(t[n]=t[n].filter(i=>i.dataKey!==r.dataKey||i.direction!==r.direction))}}}),{addErrorBar:A9e,replaceErrorBar:T9e,removeErrorBar:C9e}=LJ.actions,b6e=LJ.reducer,v6e=["children"];function y6e(t,e){if(t==null)return{};var n,r,i=_6e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r({x:0,y:0,value:0}),errorBarOffset:0},w6e=E.createContext(S6e);function M6e(t){var{children:e}=t,n=y6e(t,v6e);return E.createElement(w6e.Provider,{value:n},e)}function TL(t,e){var n,r,i=Ct(c=>Oc(c,t)),s=Ct(c=>Lc(c,e)),a=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Ei.allowDataOverflow,o=(r=s?.allowDataOverflow)!==null&&r!==void 0?r:Ai.allowDataOverflow,l=a||o;return{needClip:l,needClipX:a,needClipY:o}}function jJ(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=AL(),{needClipX:s,needClipY:a,needClip:o}=TL(e,n);if(!o||!i)return null;var{x:l,y:c,width:d,height:h}=i;return E.createElement("clipPath",{id:"clipPath-".concat(r)},E.createElement("rect",{x:s?l:l-d/2,y:a?c:c-h/2,width:s?d:d*2,height:a?h:h*2}))}function E6e(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&cr(t.zIndex)?t.zIndex:e}var CN={exports:{}},NN={};var sG;function A6e(){if(sG)return NN;sG=1;var t=Tm();function e(l,c){return l===c&&(l!==0||1/l===1/c)||l!==l&&c!==c}var n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,s=t.useEffect,a=t.useMemo,o=t.useDebugValue;return NN.useSyncExternalStoreWithSelector=function(l,c,d,h,g){var m=i(null);if(m.current===null){var v={hasValue:!1,value:null};m.current=v}else v=m.current;m=a(function(){function b(T){if(!x){if(x=!0,M=T,T=h(T),g!==void 0&&v.hasValue){var R=v.value;if(g(R,T))return w=R}return w=T}if(R=w,n(M,T))return R;var C=h(T);return g!==void 0&&g(R,C)?(M=T,R):(M=T,w=C)}var x=!1,M,w,A=d===void 0?null:d;return[function(){return b(c())},A===null?void 0:function(){return b(A())}]},[c,d,h,g]);var y=r(l,m[0],m[1]);return s(function(){v.hasValue=!0,v.value=y},[y]),o(y),y},NN}var aG;function T6e(){return aG||(aG=1,CN.exports=A6e()),CN.exports}T6e();function C6e(t){t()}function N6e(){let t=null,e=null;return{clear(){t=null,e=null},notify(){C6e(()=>{let n=t;for(;n;)n.callback(),n=n.next})},get(){const n=[];let r=t;for(;r;)n.push(r),r=r.next;return n},subscribe(n){let r=!0;const i=e={callback:n,next:null,prev:e};return i.prev?i.prev.next=i:t=i,function(){!r||t===null||(r=!1,i.next?i.next.prev=i.prev:e=i.prev,i.prev?i.prev.next=i.next:t=i.next)}}}}var oG={notify(){},get:()=>[]};function k6e(t,e){let n,r=oG,i=0,s=!1;function a(y){d();const b=r.subscribe(y);let x=!1;return()=>{x||(x=!0,b(),h())}}function o(){r.notify()}function l(){v.onStateChange&&v.onStateChange()}function c(){return s}function d(){i++,n||(n=t.subscribe(l),r=N6e())}function h(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=oG)}function g(){s||(s=!0,d())}function m(){s&&(s=!1,h())}const v={addNestedSub:a,notifyNestedSubs:o,handleChangeWrapper:l,isSubscribed:c,trySubscribe:g,tryUnsubscribe:m,getListeners:()=>r};return v}var R6e=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",P6e=R6e(),D6e=()=>typeof navigator<"u"&&navigator.product==="ReactNative",O6e=D6e(),L6e=()=>P6e||O6e?E.useLayoutEffect:E.useEffect,j6e=L6e();function lG(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function I6e(t,e){if(lG(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(let i=0;i{const l=k6e(i);return{store:i,subscription:l,getServerState:r?()=>r:void 0}},[i,r]),a=E.useMemo(()=>i.getState(),[i]);j6e(()=>{const{subscription:l}=s;return l.onStateChange=l.notifyNestedSubs,l.trySubscribe(),a!==i.getState()&&l.notifyNestedSubs(),()=>{l.tryUnsubscribe(),l.onStateChange=void 0}},[s,a]);const o=n||B6e;return E.createElement(o.Provider,{value:s},e)}var $6e=H6e,V6e=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function G6e(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function OM(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(V6e.has(r)){if(t[r]==null&&e[r]==null)continue;if(!I6e(t[r],e[r]))return!1}else if(!G6e(t[r],e[r]))return!1;return!0}var W6e=["onMouseEnter","onMouseLeave","onClick"],q6e=["value","background","tooltipPosition"],X6e=["id"],K6e=["onMouseEnter","onClick","onMouseLeave"];function Cc(){return Cc=Object.assign?Object.assign.bind():function(t){for(var e=1;e{var{dataKey:e,name:n,fill:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:Bm(n,e),payload:t}]},t8e=E.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:s,hide:a,unit:o,tooltipType:l}=t,c={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:Bm(s,e),hide:a,type:l,color:i,unit:o}};return E.createElement(ML,{tooltipEntrySettings:c})});function n8e(t){var e=Ct(od),{data:n,dataKey:r,background:i,allOtherBarProps:s}=t,{onMouseEnter:a,onMouseLeave:o,onClick:l}=s,c=QS(s,W6e),d=_L(a,r),h=SL(o),g=wL(l,r);if(!i||n==null)return null;var m=Gf(i);return E.createElement(Qs,{zIndex:E6e(i,Kr.barBackground)},n.map((v,y)=>{var{value:b,background:x,tooltipPosition:M}=v,w=QS(v,q6e);if(!x)return null;var A=d(v,y),T=h(v,y),R=g(v,y),C=vs(vs(vs(vs(vs({option:i,isActive:String(y)===e},w),{},{fill:"#eee"},x),m),lb(c,v,y)),{},{onMouseEnter:A,onMouseLeave:T,onClick:R,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return E.createElement(ZS,Cc({key:"background-bar-".concat(y)},C))}))}function r8e(t){var{showLabels:e,children:n,rects:r}=t,i=r?.map(s=>{var a={x:s.x,y:s.y,width:s.width,lowerWidth:s.width,upperWidth:s.width,height:s.height};return vs(vs({},a),{},{value:s.value,payload:s.payload,parentViewBox:s.parentViewBox,viewBox:a,fill:s.fill})});return E.createElement(vJ,{value:e?i:void 0},n)}function i8e(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:s,dataKey:a}=t,o=Ct(od),l=Ct(uL),c=n&&String(s)===o&&(l==null||a===l),d=c?n:e;return c?E.createElement(Qs,{zIndex:Kr.activeBar},E.createElement(ZS,Cc({},r,{name:String(r.name)},i,{isActive:c,option:d,index:s,dataKey:a}))):E.createElement(ZS,Cc({},r,{name:String(r.name)},i,{isActive:c,option:d,index:s,dataKey:a}))}function s8e(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:s}=t;return E.createElement(ZS,Cc({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:s}))}function a8e(t){var e,{data:n,props:r}=t,i=(e=Xs(r))!==null&&e!==void 0?e:{},{id:s}=i,a=QS(i,X6e),{shape:o,dataKey:l,activeBar:c}=r,{onMouseEnter:d,onClick:h,onMouseLeave:g}=r,m=QS(r,K6e),v=_L(d,l),y=SL(g),b=wL(h,l);return n?E.createElement(E.Fragment,null,n.map((x,M)=>E.createElement(jr,Cc({key:"rectangle-".concat(x?.x,"-").concat(x?.y,"-").concat(x?.value,"-").concat(M),className:"recharts-bar-rectangle"},lb(m,x,M),{onMouseEnter:v(x,M),onMouseLeave:y(x,M),onClick:b(x,M)}),c?E.createElement(i8e,{shape:o,activeBar:c,baseProps:a,entry:x,index:M,dataKey:l}):E.createElement(s8e,{shape:o,baseProps:a,entry:x,index:M,dataKey:l})))):null}function o8e(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:s,animationBegin:a,animationDuration:o,animationEasing:l,onAnimationEnd:c,onAnimationStart:d}=e,h=n.current,g=mb(e,"recharts-bar-"),[m,v]=E.useState(!1),y=!m,b=E.useCallback(()=>{typeof c=="function"&&c(),v(!1)},[c]),x=E.useCallback(()=>{typeof d=="function"&&d(),v(!0)},[d]);return E.createElement(r8e,{showLabels:y,rects:r},E.createElement(pb,{animationId:g,begin:a,duration:o,isActive:s,easing:l,onAnimationEnd:b,onAnimationStart:x,key:g},M=>{var w=M===1?r:r?.map((A,T)=>{var R=h&&h[T];if(R)return vs(vs({},A),{},{x:lr(R.x,A.x,M),y:lr(R.y,A.y,M),width:lr(R.width,A.width,M),height:lr(R.height,A.height,M)});if(i==="horizontal"){var C=lr(0,A.height,M),I=lr(A.stackedBarStart,A.y,M);return vs(vs({},A),{},{y:I,height:C})}var N=lr(0,A.width,M),D=lr(A.stackedBarStart,A.x,M);return vs(vs({},A),{},{width:N,x:D})});return M>0&&(n.current=w??null),w==null?null:E.createElement(jr,null,E.createElement(a8e,{props:e,data:w}))}),E.createElement(xL,{label:e.label}),e.children)}function l8e(t){var e=E.useRef(null);return E.createElement(o8e,{previousRectanglesRef:e,props:t})}var IJ=0,c8e=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:Yn(t,e)}};class u8e extends E.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:s,yAxisId:a,needClip:o,background:l,id:c}=this.props;if(e||n==null)return null;var d=An("recharts-bar",i),h=c;return E.createElement(jr,{className:d,id:c},o&&E.createElement("defs",null,E.createElement(jJ,{clipPathId:h,xAxisId:s,yAxisId:a})),E.createElement(jr,{className:"recharts-bar-rectangles",clipPath:o?"url(#clipPath-".concat(h,")"):void 0},E.createElement(n8e,{data:n,dataKey:r,background:l,allOtherBarProps:this.props}),E.createElement(l8e,this.props)))}}var d8e={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:IJ,xAxisId:0,yAxisId:0,zIndex:Kr.bar};function f8e(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:a,animationBegin:o,animationDuration:l,animationEasing:c,isAnimationActive:d}=t,{needClip:h}=TL(e,n),g=Hm(),m=hs(),v=yL(t.children,kb),y=Ct(M=>z8e(M,e,n,m,t.id,v));if(g!=="vertical"&&g!=="horizontal")return null;var b,x=y?.[0];return x==null||x.height==null||x.width==null?b=0:b=g==="vertical"?x.height/2:x.width/2,E.createElement(M6e,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:c8e,errorBarOffset:b},E.createElement(u8e,Cc({},t,{layout:g,needClip:h,data:y,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:a,animationBegin:o,animationDuration:l,animationEasing:c,isAnimationActive:d})))}function h8e(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:s,xAxis:a,yAxis:o,xAxisTicks:l,yAxisTicks:c,stackedData:d,displayedData:h,offset:g,cells:m,parentViewBox:v,dataStartIndex:y}=t,b=e==="horizontal"?o:a,x=d?b.scale.domain():null,M=PPe({numericAxis:b}),w=b.scale(M);return h.map((A,T)=>{var R,C,I,N,D,z;d?R=TPe(d[T+y],x):(R=Yn(A,n),Array.isArray(R)||(R=[M,R]));var j=g6e(r,IJ)(R[1],T);if(e==="horizontal"){var W,[P,$]=[o.scale(R[0]),o.scale(R[1])];C=EH({axis:a,ticks:l,bandSize:s,offset:i.offset,entry:A,index:T}),I=(W=$??P)!==null&&W!==void 0?W:void 0,N=i.size;var K=P-$;if(D=eo(K)?0:K,z={x:C,y:g.top,width:N,height:g.height},Math.abs(j)>0&&Math.abs(D)0&&Math.abs(N)E.createElement(E.Fragment,null,E.createElement(NJ,{legendPayload:e8e(e)}),E.createElement(t8e,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),E.createElement(PJ,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:CY(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),E.createElement(Qs,{zIndex:e.zIndex},E.createElement(f8e,Cc({},e,{id:r})))))}var UJ=E.memo(p8e,OM);UJ.displayName="Bar";function uG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function v_(t){for(var e=1;ee,v8e=(t,e,n)=>n,y8e=(t,e,n,r)=>r,_8e=(t,e,n,r,i)=>i,Rb=We([EM,_8e],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),S8e=We([Rb],t=>t?.maxBarSize),w8e=(t,e,n,r,i,s)=>s,dG=(t,e,n)=>{var r=n??t;if(!vr(r))return us(r,e,0)},M8e=We([Sn,EM,b8e,v8e,y8e],(t,e,n,r,i)=>e.filter(s=>t==="horizontal"?s.xAxisId===n:s.yAxisId===r).filter(s=>s.isPanorama===i).filter(s=>s.hide===!1).filter(s=>s.type==="bar")),E8e=(t,e,n,r)=>{var i=Sn(t);return i==="horizontal"?H0(t,"yAxis",n,r):H0(t,"xAxis",e,r)},A8e=(t,e,n)=>{var r=Sn(t);return r==="horizontal"?iV(t,"xAxis",e):iV(t,"yAxis",n)},T8e=(t,e,n)=>{var r={},i=t.filter(SM),s=t.filter(c=>c.stackId==null),a=i.reduce((c,d)=>(c[d.stackId]||(c[d.stackId]=[]),c[d.stackId].push(d),c),r),o=Object.entries(a).map(c=>{var[d,h]=c,g=h.map(v=>v.dataKey),m=dG(e,n,h[0].barSize);return{stackId:d,dataKeys:g,barSize:m}}),l=s.map(c=>{var d=[c.dataKey].filter(g=>g!=null),h=dG(e,n,c.barSize);return{stackId:void 0,dataKeys:d,barSize:h}});return[...o,...l]},C8e=We([M8e,KIe,A8e],T8e),N8e=(t,e,n,r,i)=>{var s,a,o=Rb(t,e,n,r,i);if(o!=null){var l=Sn(t),c=JZ(t),{maxBarSize:d}=o,h=vr(d)?c:d,g,m;return l==="horizontal"?(g=ad(t,"xAxis",e,r),m=sd(t,"xAxis",e,r)):(g=ad(t,"yAxis",n,r),m=sd(t,"yAxis",n,r)),(s=(a=_m(g,m,!0))!==null&&a!==void 0?a:h)!==null&&s!==void 0?s:0}},FJ=(t,e,n,r)=>{var i=Sn(t),s,a;return i==="horizontal"?(s=ad(t,"xAxis",e,r),a=sd(t,"xAxis",e,r)):(s=ad(t,"yAxis",n,r),a=sd(t,"yAxis",n,r)),_m(s,a)};function k8e(t,e,n,r,i){var s=r.length;if(!(s<1)){var a=us(t,n,0,!0),o,l=[];if(cr(r[0].barSize)){var c=!1,d=n/s,h=r.reduce((x,M)=>x+(M.barSize||0),0);h+=(s-1)*a,h>=n&&(h-=(s-1)*a,a=0),h>=n&&d>0&&(c=!0,d*=.9,h=s*d);var g=(n-h)/2>>0,m={offset:g-a,size:0};o=r.reduce((x,M)=>{var w,A={stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:m.offset+m.size+a,size:c?d:(w=M.barSize)!==null&&w!==void 0?w:0}},T=[...x,A];return m=T[T.length-1].position,T},l)}else{var v=us(e,n,0,!0);n-2*v-(s-1)*a<=0&&(a=0);var y=(n-2*v-(s-1)*a)/s;y>1&&(y>>=0);var b=cr(i)?Math.min(y,i):y;o=r.reduce((x,M,w)=>[...x,{stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:v+(y+a)*w+(y-b)/2,size:b}}],l)}return o}}var R8e=(t,e,n,r,i,s,a)=>{var o=vr(a)?e:a,l=k8e(n,r,i!==s?i:s,t,o);return i!==s&&l!=null&&(l=l.map(c=>v_(v_({},c),{},{position:v_(v_({},c.position),{},{offset:c.position.offset-i/2})}))),l},P8e=We([C8e,JZ,XIe,eQ,N8e,FJ,S8e],R8e),D8e=(t,e,n,r)=>ad(t,"xAxis",e,r),O8e=(t,e,n,r)=>ad(t,"yAxis",n,r),L8e=(t,e,n,r)=>sd(t,"xAxis",e,r),j8e=(t,e,n,r)=>sd(t,"yAxis",n,r),I8e=We([P8e,Rb],(t,e)=>{if(!(t==null||e==null)){var n=t.find(r=>r.stackId===e.stackId&&e.dataKey!=null&&r.dataKeys.includes(e.dataKey));if(n!=null)return n.position}}),U8e=(t,e)=>{var n=_M(e);if(!(!t||n==null||e==null)){var{stackId:r}=e;if(r!=null){var i=t[r];if(i){var{stackedData:s}=i;if(s)return s.find(a=>a.key===n)}}}},F8e=We([E8e,Rb],U8e),z8e=We([pi,eO,D8e,O8e,L8e,j8e,I8e,Sn,bM,FJ,F8e,Rb,w8e],(t,e,n,r,i,s,a,o,l,c,d,h,g)=>{var{chartData:m,dataStartIndex:v,dataEndIndex:y}=l;if(!(h==null||a==null||e==null||o!=="horizontal"&&o!=="vertical"||n==null||r==null||i==null||s==null||c==null)){var{data:b}=h,x;if(b!=null&&b.length>0?x=b:x=m?.slice(v,y+1),x!=null)return h8e({layout:o,barSettings:h,pos:a,parentViewBox:e,bandSize:c,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:s,stackedData:d,displayedData:x,offset:t,cells:g,dataStartIndex:v})}}),zJ=t=>{var{chartData:e}=t,n=nr(),r=hs();return E.useEffect(()=>r?()=>{}:(n(xV(e)),()=>{n(xV(void 0))}),[e,n,r]),null},fG={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},BJ=Zs({name:"brush",initialState:fG,reducers:{setBrushSettings(t,e){return e.payload==null?fG:e.payload}}}),{setBrushSettings:N9e}=BJ.actions,B8e=BJ.reducer;function H8e(t,e,n){return(e=$8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $8e(t){var e=V8e(t,"string");return typeof e=="symbol"?e:e+""}function V8e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class CL{static create(e){return new CL(e)}constructor(e){this.scale=e}get domain(){return this.scale.domain}get range(){return this.scale.range}get rangeMin(){return this.range()[0]}get rangeMax(){return this.range()[1]}get bandwidth(){return this.scale.bandwidth}apply(e){var{bandAware:n,position:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e!==void 0){if(r)switch(r){case"start":return this.scale(e);case"middle":{var i=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+i}case"end":{var s=this.bandwidth?this.bandwidth():0;return this.scale(e)+s}default:return this.scale(e)}if(n){var a=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+a}return this.scale(e)}}isInRange(e){var n=this.range(),r=n[0],i=n[n.length-1];return r<=i?e>=r&&e<=i:e>=i&&e<=r}}H8e(CL,"EPS",1e-4);function G8e(t){return(t%180+180)%180}var W8e=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=G8e(i),a=s*Math.PI/180,o=Math.atan(r/n),l=a>o&&a{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=To(t).dots.findIndex(r=>r===e.payload);n!==-1&&t.dots.splice(n,1)},addArea:(t,e)=>{t.areas.push(e.payload)},removeArea:(t,e)=>{var n=To(t).areas.findIndex(r=>r===e.payload);n!==-1&&t.areas.splice(n,1)},addLine:(t,e)=>{t.lines.push(e.payload)},removeLine:(t,e)=>{var n=To(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:k9e,removeDot:R9e,addArea:P9e,removeArea:D9e,addLine:O9e,removeLine:L9e}=HJ.actions,X8e=HJ.reducer,K8e=E.createContext(void 0),Y8e=t=>{var{children:e}=t,[n]=E.useState("".concat(N0("recharts"),"-clip")),r=AL();if(r==null)return null;var{x:i,y:s,width:a,height:o}=r;return E.createElement(K8e.Provider,{value:n},E.createElement("defs",null,E.createElement("clipPath",{id:n},E.createElement("rect",{x:i,y:s,height:o,width:a}))),e)};function $J(t,e){if(e<1)return[];if(e===1)return t;for(var n=[],r=0;rt*i)return!1;var s=n();return t*(e-t*s/2-r)>=0&&t*(e+t*s/2-i)<=0}function J8e(t,e){return $J(t,e+1)}function eHe(t,e,n,r,i){for(var s=(r||[]).slice(),{start:a,end:o}=e,l=0,c=1,d=a,h=function(){var v=r?.[l];if(v===void 0)return{v:$J(r,c)};var y=l,b,x=()=>(b===void 0&&(b=n(v,y)),b),M=v.coordinate,w=l===0||JS(t,M,x,d,o);w||(l=0,d=a,c+=1),w&&(d=M+t*(x()/2+i),l+=c)},g;c<=s.length;)if(g=h(),g)return g.v;return[]}function hG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function as(t){for(var e=1;e(v===void 0&&(v=n(m,g)),v);if(g===a-1){var b=t*(m.coordinate+t*y()/2-l);s[g]=m=as(as({},m),{},{tickCoord:b>0?m.coordinate-b*t:m.coordinate})}else s[g]=m=as(as({},m),{},{tickCoord:m.coordinate});if(m.tickCoord!=null){var x=JS(t,m.tickCoord,y,o,l);x&&(l=m.tickCoord-t*(y()/2+i),s[g]=as(as({},m),{},{isShow:!0}))}},d=a-1;d>=0;d--)c(d);return s}function sHe(t,e,n,r,i,s){var a=(r||[]).slice(),o=a.length,{start:l,end:c}=e;if(s){var d=r[o-1],h=n(d,o-1),g=t*(d.coordinate+t*h/2-c);if(a[o-1]=d=as(as({},d),{},{tickCoord:g>0?d.coordinate-g*t:d.coordinate}),d.tickCoord!=null){var m=JS(t,d.tickCoord,()=>h,l,c);m&&(c=d.tickCoord-t*(h/2+i),a[o-1]=as(as({},d),{},{isShow:!0}))}}for(var v=s?o-1:o,y=function(M){var w=a[M],A,T=()=>(A===void 0&&(A=n(w,M)),A);if(M===0){var R=t*(w.coordinate-t*T()/2-l);a[M]=w=as(as({},w),{},{tickCoord:R<0?w.coordinate-R*t:w.coordinate})}else a[M]=w=as(as({},w),{},{tickCoord:w.coordinate});if(w.tickCoord!=null){var C=JS(t,w.tickCoord,T,l,c);C&&(l=w.tickCoord+t*(T()/2+i),a[M]=as(as({},w),{},{isShow:!0}))}},b=0;b{var T=typeof c=="function"?c(w.value,A):w.value;return v==="width"?Z8e(Kx(T,{fontSize:e,letterSpacing:n}),y,h):Kx(T,{fontSize:e,letterSpacing:n})[v]},x=i.length>=2?ki(i[1].coordinate-i[0].coordinate):1,M=Q8e(s,x,v);return l==="equidistantPreserveStart"?eHe(x,M,b,i,a):(l==="preserveStart"||l==="preserveStartEnd"?m=sHe(x,M,b,i,a,l==="preserveStartEnd"):m=iHe(x,M,b,i,a),m.filter(w=>w.isShow))}var aHe=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:s=0}=t,a=0;if(e){Array.from(e).forEach(d=>{if(d){var h=d.getBoundingClientRect();h.width>a&&(a=h.width)}});var o=n?n.getBoundingClientRect().width:0,l=i+s,c=a+l+o+(n?r:0);return Math.round(c)}return 0},oHe=["axisLine","width","height","className","hide","ticks","axisType"];function lHe(t,e){if(t==null)return{};var n,r,i=cHe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r{var{ticks:n=[],tick:r,tickLine:i,stroke:s,tickFormatter:a,unit:o,padding:l,tickTextProps:c,orientation:d,mirror:h,x:g,y:m,width:v,height:y,tickSize:b,tickMargin:x,fontSize:M,letterSpacing:w,getTicksConfig:A,events:T,axisType:R}=t,C=NL(Vr(Vr({},A),{},{ticks:n}),M,w),I=mHe(d,h),N=gHe(d,h),D=Xs(A),z=Gf(r),j={};typeof i=="object"&&(j=i);var W=Vr(Vr({},D),{},{fill:"none"},j),P=C.map(G=>Vr({entry:G},pHe(G,g,m,v,y,d,b,h,x))),$=P.map(G=>{var{entry:Z,line:Q}=G;return E.createElement(jr,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(Z.value,"-").concat(Z.coordinate,"-").concat(Z.tickCoord)},i&&E.createElement("line",Yf({},W,Q,{className:An("recharts-cartesian-axis-tick-line",Wf(i,"className"))})))}),K=P.map((G,Z)=>{var{entry:Q,tick:ee}=G,H=Vr(Vr(Vr(Vr({textAnchor:I,verticalAnchor:N},D),{},{stroke:"none",fill:s},z),ee),{},{index:Z,payload:Q,visibleTicksCount:C.length,tickFormatter:a,padding:l},c);return E.createElement(jr,Yf({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Q.value,"-").concat(Q.coordinate,"-").concat(Q.tickCoord)},lb(T,Q,Z)),r&&E.createElement(xHe,{option:r,tickProps:H,value:"".concat(typeof a=="function"?a(Q.value,Z):Q.value).concat(o||"")}))});return E.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(R,"-ticks")},K.length>0&&E.createElement(Qs,{zIndex:Kr.label},E.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(R,"-tick-labels"),ref:e},K)),$.length>0&&E.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(R,"-tick-lines")},$))}),vHe=E.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:s,hide:a,ticks:o,axisType:l}=t,c=lHe(t,oHe),[d,h]=E.useState(""),[g,m]=E.useState(""),v=E.useRef(null);E.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var b;return aHe({ticks:v.current,label:(b=t.labelRef)===null||b===void 0?void 0:b.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var y=E.useCallback(b=>{if(b){var x=b.getElementsByClassName("recharts-cartesian-axis-tick-value");v.current=x;var M=x[0];if(M){var w=window.getComputedStyle(M),A=w.fontSize,T=w.letterSpacing;(A!==d||T!==g)&&(h(A),m(T))}}},[d,g]);return a||r!=null&&r<=0||i!=null&&i<=0?null:E.createElement(Qs,{zIndex:t.zIndex},E.createElement(jr,{className:An("recharts-cartesian-axis",s)},E.createElement(hHe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Xs(t)}),E.createElement(bHe,{ref:y,axisType:l,events:c,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:g,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:o,unit:t.unit,width:t.width,x:t.x,y:t.y}),E.createElement($5e,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},E.createElement(J5e,{label:t.label,labelRef:t.labelRef}),t.children)))}),kL=E.forwardRef((t,e)=>{var n=ei(t,xc);return E.createElement(vHe,Yf({},n,{ref:e}))});kL.displayName="CartesianAxis";var yHe=["x1","y1","x2","y2","key"],_He=["offset"],SHe=["xAxisId","yAxisId"],wHe=["xAxisId","yAxisId"];function mG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ls(t){for(var e=1;e{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:s,height:a,ry:o}=t;return E.createElement("rect",{x:r,y:i,ry:o,width:s,height:a,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function VJ(t){var{option:e,lineItemProps:n}=t,r;if(E.isValidElement(e))r=E.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:s,y1:a,x2:o,y2:l,key:c}=n,d=ew(n,yHe),h=(i=Xs(d))!==null&&i!==void 0?i:{},{offset:g}=h,m=ew(h,_He);r=E.createElement("line",df({},m,{x1:s,y1:a,x2:o,y2:l,fill:"none",key:c}))}return r}function NHe(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:s,yAxisId:a}=t,o=ew(t,SHe),l=i.map((c,d)=>{var h=ls(ls({},o),{},{x1:e,y1:c,x2:e+n,y2:c,key:"line-".concat(d),index:d});return E.createElement(VJ,{key:"line-".concat(d),option:r,lineItemProps:h})});return E.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function kHe(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:s,yAxisId:a}=t,o=ew(t,wHe),l=i.map((c,d)=>{var h=ls(ls({},o),{},{x1:c,y1:e,x2:c,y2:e+n,key:"line-".concat(d),index:d});return E.createElement(VJ,{option:r,lineItemProps:h,key:"line-".concat(d)})});return E.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function RHe(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:s,height:a,horizontalPoints:o,horizontal:l=!0}=t;if(!l||!e||!e.length||o==null)return null;var c=o.map(h=>Math.round(h+i-i)).sort((h,g)=>h-g);i!==c[0]&&c.unshift(0);var d=c.map((h,g)=>{var m=!c[g+1],v=m?i+a-h:c[g+1]-h;if(v<=0)return null;var y=g%e.length;return E.createElement("rect",{key:"react-".concat(g),y:h,x:r,height:v,width:s,stroke:"none",fill:e[y],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function PHe(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:s,width:a,height:o,verticalPoints:l}=t;if(!e||!n||!n.length)return null;var c=l.map(h=>Math.round(h+i-i)).sort((h,g)=>h-g);i!==c[0]&&c.unshift(0);var d=c.map((h,g)=>{var m=!c[g+1],v=m?i+a-h:c[g+1]-h;if(v<=0)return null;var y=g%n.length;return E.createElement("rect",{key:"react-".concat(g),x:h,y:s,width:v,height:o,stroke:"none",fill:n[y],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var DHe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:s}=t;return AY(NL(ls(ls(ls({},xc),n),{},{ticks:TY(n),viewBox:{x:0,y:0,width:r,height:i}})),s.left,s.left+s.width,e)},OHe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:s}=t;return AY(NL(ls(ls(ls({},xc),n),{},{ticks:TY(n),viewBox:{x:0,y:0,width:r,height:i}})),s.top,s.top+s.height,e)},LHe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Kr.grid};function DR(t){var e=nO(),n=rO(),r=jY(),i=ls(ls({},ei(t,LHe)),{},{x:Tt(t.x)?t.x:r.left,y:Tt(t.y)?t.y:r.top,width:Tt(t.width)?t.width:r.width,height:Tt(t.height)?t.height:r.height}),{xAxisId:s,yAxisId:a,x:o,y:l,width:c,height:d,syncWithTicks:h,horizontalValues:g,verticalValues:m}=i,v=hs(),y=Ct(N=>sV(N,"xAxis",s,v)),b=Ct(N=>sV(N,"yAxis",a,v));if(!dl(c)||!dl(d)||!Tt(o)||!Tt(l))return null;var x=i.verticalCoordinatesGenerator||DHe,M=i.horizontalCoordinatesGenerator||OHe,{horizontalPoints:w,verticalPoints:A}=i;if((!w||!w.length)&&typeof M=="function"){var T=g&&g.length,R=M({yAxis:b?ls(ls({},b),{},{ticks:T?g:b.ticks}):void 0,width:e??c,height:n??d,offset:r},T?!0:h);ES(Array.isArray(R),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof R,"]")),Array.isArray(R)&&(w=R)}if((!A||!A.length)&&typeof x=="function"){var C=m&&m.length,I=x({xAxis:y?ls(ls({},y),{},{ticks:C?m:y.ticks}):void 0,width:e??c,height:n??d,offset:r},C?!0:h);ES(Array.isArray(I),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof I,"]")),Array.isArray(I)&&(A=I)}return E.createElement(Qs,{zIndex:i.zIndex},E.createElement("g",{className:"recharts-cartesian-grid"},E.createElement(CHe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),E.createElement(RHe,df({},i,{horizontalPoints:w})),E.createElement(PHe,df({},i,{verticalPoints:A})),E.createElement(NHe,df({},i,{offset:r,horizontalPoints:w,xAxis:y,yAxis:b})),E.createElement(kHe,df({},i,{offset:r,verticalPoints:A,xAxis:y,yAxis:b}))))}DR.displayName="CartesianGrid";function jHe(t){var e=Gf(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:s}=e,a=Number(i),o=Number(s);return(Number.isNaN(a)||a<0)&&(a=n),(Number.isNaN(o)||o<0)&&(o=r),{r:a,strokeWidth:o}}return{r:n,strokeWidth:r}}var GJ=(t,e,n,r)=>ad(t,"xAxis",e,r),WJ=(t,e,n,r)=>sd(t,"xAxis",e,r),qJ=(t,e,n,r)=>ad(t,"yAxis",n,r),XJ=(t,e,n,r)=>sd(t,"yAxis",n,r),IHe=We([Sn,GJ,qJ,WJ,XJ],(t,e,n,r,i)=>kc(t,"xAxis")?_m(e,r,!1):_m(n,i,!1)),UHe=(t,e,n,r,i)=>i,KJ=We([EM,UHe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),FHe=(t,e,n,r,i)=>{var s,a=KJ(t,e,n,r,i);if(a!=null){var o=Sn(t),l=kc(o,"xAxis"),c;if(l?c=H0(t,"yAxis",n,r):c=H0(t,"xAxis",e,r),c!=null){var{stackId:d}=a,h=_M(a);if(!(d==null||h==null)){var g=(s=c[d])===null||s===void 0?void 0:s.stackedData;return g?.find(m=>m.key===h)}}}},zHe=We([Sn,GJ,qJ,WJ,XJ,FHe,bM,IHe,KJ,YIe],(t,e,n,r,i,s,a,o,l,c)=>{var{chartData:d,dataStartIndex:h,dataEndIndex:g}=a;if(!(l==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null)){var{data:m}=l,v;if(m&&m.length>0?v=m:v=d?.slice(h,g+1),v!=null)return s$e({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:h,areaSettings:l,stackedData:s,displayedData:v,chartBaseValue:c,bandSize:o})}}),BHe=["id"],HHe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Ef(){return Ef=Object.assign?Object.assign.bind():function(t){for(var e=1;e{var{dataKey:e,name:n,stroke:r,fill:i,legendType:s,hide:a}=t;return[{inactive:a,dataKey:e,type:s,color:tw(r,i),value:Bm(n,e),payload:t}]},XHe=E.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:a,hide:o,unit:l,tooltipType:c}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:Bm(a,e),hide:o,type:c,color:tw(r,s),unit:l}};return E.createElement(ML,{tooltipEntrySettings:d})});function KHe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:s,dataKey:a}=r,o=Xs(r);return E.createElement(BBe,{points:n,dot:s,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:a,baseProps:o,needClip:i,clipPathId:e})}function YHe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(s=>{var a,o,l={x:(a=s.x)!==null&&a!==void 0?a:0,y:(o=s.y)!==null&&o!==void 0?o:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Lp(Lp({},l),{},{value:s.value,payload:s.payload,parentViewBox:void 0,viewBox:l,fill:void 0})});return E.createElement(vJ,{value:e?i:void 0},n)}function xG(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:s}=t,{layout:a,type:o,stroke:l,connectNulls:c,isRange:d}=s,{id:h}=s,g=YJ(s,BHe),m=Xs(g),v=Cs(g);return E.createElement(E.Fragment,null,e?.length>1&&E.createElement(jr,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},E.createElement(Xp,Ef({},v,{id:h,points:e,connectNulls:c,type:o,baseLine:n,layout:a,stroke:"none",className:"recharts-area-area"})),l!=="none"&&E.createElement(Xp,Ef({},m,{className:"recharts-area-curve",layout:a,type:o,connectNulls:c,fill:"none",points:e})),l!=="none"&&d&&E.createElement(Xp,Ef({},m,{className:"recharts-area-curve",layout:a,type:o,connectNulls:c,fill:"none",points:n}))),E.createElement(KHe,{points:e,props:g,clipPathId:i}))}function ZHe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].y,a=r[r.length-1].y;if(!cr(s)||!cr(a))return null;var o=e*Math.abs(s-a),l=Math.max(...r.map(c=>c.x||0));return Tt(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(c=>c.x||0),l)),Tt(l)?E.createElement("rect",{x:0,y:sc.y||0));return Tt(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(c=>c.y||0),l)),Tt(l)?E.createElement("rect",{x:s({points:a,baseLine:o}),[a,o]),y=mb(v,"recharts-area-"),b=pDe(),[x,M]=E.useState(!1),w=!x,A=E.useCallback(()=>{typeof m=="function"&&m(),M(!1)},[m]),T=E.useCallback(()=>{typeof g=="function"&&g(),M(!0)},[g]);if(b==null)return null;var R=i.current,C=s.current;return E.createElement(YHe,{showLabels:w,points:a},r.children,E.createElement(pb,{animationId:y,begin:c,duration:d,isActive:l,easing:h,onAnimationEnd:A,onAnimationStart:T,key:y},I=>{if(R){var N=R.length/a.length,D=I===1?a:a.map((j,W)=>{var P=Math.floor(W*N);if(R[P]){var $=R[P];return Lp(Lp({},j),{},{x:lr($.x,j.x,I),y:lr($.y,j.y,I)})}return j}),z;return Tt(o)?z=lr(C,o,I):vr(o)||eo(o)?z=lr(C,0,I):z=o.map((j,W)=>{var P=Math.floor(W*N);if(Array.isArray(C)&&C[P]){var $=C[P];return Lp(Lp({},j),{},{x:lr($.x,j.x,I),y:lr($.y,j.y,I)})}return j}),I>0&&(i.current=D,s.current=z),E.createElement(xG,{points:D,baseLine:z,needClip:e,clipPathId:n,props:r})}return I>0&&(i.current=a,s.current=o),E.createElement(jr,null,l&&E.createElement("defs",null,E.createElement("clipPath",{id:"animationClipPath-".concat(n)},E.createElement(JHe,{alpha:I,points:a,baseLine:o,layout:b,strokeWidth:r.strokeWidth}))),E.createElement(jr,{clipPath:"url(#animationClipPath-".concat(n,")")},E.createElement(xG,{points:a,baseLine:o,needClip:e,clipPathId:n,props:r})))}),E.createElement(xL,{label:r.label}))}function t$e(t){var{needClip:e,clipPathId:n,props:r}=t,i=E.useRef(null),s=E.useRef();return E.createElement(e$e,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s})}class n$e extends E.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:s,left:a,needClip:o,xAxisId:l,yAxisId:c,width:d,height:h,id:g,baseLine:m,zIndex:v}=this.props;if(e)return null;var y=An("recharts-area",i),b=g,{r:x,strokeWidth:M}=jHe(n),w=TJ(n),A=x*2+M,T=o?"url(#clipPath-".concat(w?"":"dots-").concat(b,")"):void 0;return E.createElement(Qs,{zIndex:v},E.createElement(jr,{className:y},o&&E.createElement("defs",null,E.createElement(jJ,{clipPathId:b,xAxisId:l,yAxisId:c}),!w&&E.createElement("clipPath",{id:"clipPath-dots-".concat(b)},E.createElement("rect",{x:a-A/2,y:s-A/2,width:d+A,height:h+A}))),E.createElement(t$e,{needClip:o,clipPathId:b,props:this.props})),E.createElement(rG,{points:r,mainColor:tw(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}),this.props.isRange&&Array.isArray(m)&&E.createElement(rG,{points:m,mainColor:tw(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}))}}var ZJ={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,xAxisId:0,yAxisId:0,zIndex:Kr.area};function r$e(t){var e,n=ei(t,ZJ),{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:a,connectNulls:o,dot:l,fill:c,fillOpacity:d,hide:h,isAnimationActive:g,legendType:m,stroke:v,xAxisId:y,yAxisId:b}=n,x=YJ(n,HHe),M=Hm(),w=eJ(),{needClip:A}=TL(y,b),T=hs(),{points:R,isRange:C,baseLine:I}=(e=Ct(P=>zHe(P,y,b,T,t.id)))!==null&&e!==void 0?e:{},N=AL();if(M!=="horizontal"&&M!=="vertical"||N==null||w!=="AreaChart"&&w!=="ComposedChart")return null;var{height:D,width:z,x:j,y:W}=N;return!R||!R.length?null:E.createElement(n$e,Ef({},x,{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:a,baseLine:I,connectNulls:o,dot:l,fill:c,fillOpacity:d,height:D,hide:h,layout:M,isAnimationActive:g==="auto"?!$m.isSsr:g,isRange:C,legendType:m,needClip:A,points:R,stroke:v,width:z,left:j,top:W,xAxisId:y,yAxisId:b}))}var i$e=(t,e,n,r,i)=>{var s=n??e;if(Tt(s))return s;var a=t==="horizontal"?i:r,o=a.scale.domain();if(a.type==="number"){var l=Math.max(o[0],o[1]),c=Math.min(o[0],o[1]);return s==="dataMin"?c:s==="dataMax"||l<0?l:Math.max(Math.min(o[0],o[1]),0)}return s==="dataMin"?o[0]:s==="dataMax"?o[1]:o[0]};function s$e(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:s,chartBaseValue:a,xAxis:o,yAxis:l,displayedData:c,dataStartIndex:d,xAxisTicks:h,yAxisTicks:g,bandSize:m}=t,v=i&&i.length,y=i$e(s,a,n,o,l),b=s==="horizontal",x=!1,M=c.map((A,T)=>{var R;v?R=i[d+T]:(R=Yn(A,r),Array.isArray(R)?x=!0:R=[y,R]);var C=R[1]==null||v&&!e&&Yn(A,r)==null;return b?{x:MH({axis:o,ticks:h,bandSize:m,entry:A,index:T}),y:C?null:l.scale(R[1]),value:R,payload:A}:{x:C?null:o.scale(R[1]),y:MH({axis:l,ticks:g,bandSize:m,entry:A,index:T}),value:R,payload:A}}),w;return v||x?w=M.map(A=>{var T=Array.isArray(A.value)?A.value[0]:null;return b?{x:A.x,y:T!=null&&A.y!=null?l.scale(T):null,payload:A.payload}:{x:T!=null?o.scale(T):null,y:A.y,payload:A.payload}}):w=b?l.scale(y):o.scale(y),{points:M,baseLine:w,isRange:x}}function a$e(t){var e=ei(t,ZJ),n=hs();return E.createElement(EL,{id:e.id,type:"area"},r=>E.createElement(E.Fragment,null,E.createElement(NJ,{legendPayload:qHe(e)}),E.createElement(XHe,{dataKey:e.dataKey,data:e.data,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),E.createElement(PJ,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:CY(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),E.createElement(r$e,Ef({},e,{id:r}))))}var QJ=E.memo(a$e,OM);QJ.displayName="Area";var o$e=["domain","range"],l$e=["domain","range"];function bG(t,e){if(t==null)return{};var n,r,i=c$e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r{n.current===null?e(WBe(t)):n.current!==t&&e(qBe({prev:n.current,next:t})),n.current=t},[t,e]),E.useLayoutEffect(()=>()=>{n.current&&(e(XBe(n.current)),n.current=null)},[e]),null}var p$e=t=>{var{xAxisId:e,className:n}=t,r=Ct(eO),i=hs(),s="xAxis",a=Ct(b=>Ym(b,s,e,i)),o=Ct(b=>PQ(b,s,e,i)),l=Ct(b=>CQ(b,e)),c=Ct(b=>q4e(b,e)),d=Ct(b=>cQ(b,e));if(l==null||c==null||d==null)return null;var{dangerouslySetInnerHTML:h,ticks:g}=t,m=yG(t,u$e),{id:v}=d,y=yG(d,d$e);return E.createElement(kL,OR({},m,y,{scale:a,x:c.x,y:c.y,width:l.width,height:l.height,className:An("recharts-".concat(s," ").concat(s),n),viewBox:r,ticks:o,axisType:s}))},m$e={allowDataOverflow:Ei.allowDataOverflow,allowDecimals:Ei.allowDecimals,allowDuplicatedCategory:Ei.allowDuplicatedCategory,angle:Ei.angle,axisLine:xc.axisLine,height:Ei.height,hide:!1,includeHidden:Ei.includeHidden,interval:Ei.interval,minTickGap:Ei.minTickGap,mirror:Ei.mirror,orientation:Ei.orientation,padding:Ei.padding,reversed:Ei.reversed,scale:Ei.scale,tick:Ei.tick,tickCount:Ei.tickCount,tickLine:xc.tickLine,tickSize:xc.tickSize,type:Ei.type,xAxisId:0},g$e=t=>{var e=ei(t,m$e);return E.createElement(E.Fragment,null,E.createElement(h$e,{allowDataOverflow:e.allowDataOverflow,allowDecimals:e.allowDecimals,allowDuplicatedCategory:e.allowDuplicatedCategory,angle:e.angle,dataKey:e.dataKey,domain:e.domain,height:e.height,hide:e.hide,id:e.xAxisId,includeHidden:e.includeHidden,interval:e.interval,minTickGap:e.minTickGap,mirror:e.mirror,name:e.name,orientation:e.orientation,padding:e.padding,reversed:e.reversed,scale:e.scale,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit}),E.createElement(p$e,e))},LR=E.memo(g$e,JJ);LR.displayName="XAxis";var x$e=["dangerouslySetInnerHTML","ticks"],b$e=["id"];function jR(){return jR=Object.assign?Object.assign.bind():function(t){for(var e=1;e{n.current===null?e(KBe(t)):n.current!==t&&e(YBe({prev:n.current,next:t})),n.current=t},[t,e]),E.useLayoutEffect(()=>()=>{n.current&&(e(ZBe(n.current)),n.current=null)},[e]),null}var _$e=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,s=E.useRef(null),a=E.useRef(null),o=Ct(eO),l=hs(),c=nr(),d="yAxis",h=Ct(T=>Ym(T,d,e,l)),g=Ct(T=>NQ(T,e)),m=Ct(T=>K4e(T,e)),v=Ct(T=>PQ(T,d,e,l)),y=Ct(T=>uQ(T,e));if(E.useLayoutEffect(()=>{if(!(r!=="auto"||!g||gL(i)||E.isValidElement(i)||y==null)){var T=s.current;if(T){var R=T.getCalculatedWidth();Math.round(g.width)!==Math.round(R)&&c(QBe({id:e,width:R}))}}},[v,g,c,i,e,r,y]),g==null||m==null||y==null)return null;var{dangerouslySetInnerHTML:b,ticks:x}=t,M=_G(t,x$e),{id:w}=y,A=_G(y,b$e);return E.createElement(kL,jR({},M,A,{ref:s,labelRef:a,scale:h,x:m.x,y:m.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:g.width,height:g.height,className:An("recharts-".concat(d," ").concat(d),n),viewBox:o,ticks:v,axisType:d}))},S$e={allowDataOverflow:Ai.allowDataOverflow,allowDecimals:Ai.allowDecimals,allowDuplicatedCategory:Ai.allowDuplicatedCategory,angle:Ai.angle,axisLine:xc.axisLine,hide:!1,includeHidden:Ai.includeHidden,interval:Ai.interval,minTickGap:Ai.minTickGap,mirror:Ai.mirror,orientation:Ai.orientation,padding:Ai.padding,reversed:Ai.reversed,scale:Ai.scale,tick:Ai.tick,tickCount:Ai.tickCount,tickLine:xc.tickLine,tickSize:xc.tickSize,type:Ai.type,width:Ai.width,yAxisId:0},w$e=t=>{var e=ei(t,S$e);return E.createElement(E.Fragment,null,E.createElement(y$e,{interval:e.interval,id:e.yAxisId,scale:e.scale,type:e.type,domain:e.domain,allowDataOverflow:e.allowDataOverflow,dataKey:e.dataKey,allowDuplicatedCategory:e.allowDuplicatedCategory,allowDecimals:e.allowDecimals,tickCount:e.tickCount,padding:e.padding,includeHidden:e.includeHidden,reversed:e.reversed,ticks:e.ticks,width:e.width,orientation:e.orientation,mirror:e.mirror,hide:e.hide,unit:e.unit,name:e.name,angle:e.angle,minTickGap:e.minTickGap,tick:e.tick,tickFormatter:e.tickFormatter}),E.createElement(_$e,e))},IR=E.memo(w$e,JJ);IR.displayName="YAxis";var M$e=(t,e)=>e,RL=We([M$e,Sn,oQ,gi,XQ,jc,uFe,pi],xFe),PL=t=>{var e=t.currentTarget.getBoundingClientRect(),n=e.width/t.currentTarget.offsetWidth,r=e.height/t.currentTarget.offsetHeight;return{chartX:Math.round((t.clientX-e.left)/n),chartY:Math.round((t.clientY-e.top)/r)}},eee=to("mouseClick"),tee=db();tee.startListening({actionCreator:eee,effect:(t,e)=>{var n=t.payload,r=RL(e.getState(),PL(n));r?.activeIndex!=null&&e.dispatch(cUe({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var UR=to("mouseMove"),nee=db(),y_=null;nee.startListening({actionCreator:UR,effect:(t,e)=>{var n=t.payload;y_!==null&&cancelAnimationFrame(y_);var r=PL(n);y_=requestAnimationFrame(()=>{var i=e.getState(),s=iL(i,i.tooltip.settings.shared);if(s==="axis"){var a=RL(i,r);a?.activeIndex!=null?e.dispatch(zQ({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate})):e.dispatch(FQ())}y_=null})}});var SG={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:"none",syncId:void 0,syncMethod:"index",baseValue:void 0,reverseStackOrder:!1},ree=Zs({name:"rootProps",initialState:SG,reducers:{updateOptions:(t,e)=>{var n;t.accessibilityLayer=e.payload.accessibilityLayer,t.barCategoryGap=e.payload.barCategoryGap,t.barGap=(n=e.payload.barGap)!==null&&n!==void 0?n:SG.barGap,t.barSize=e.payload.barSize,t.maxBarSize=e.payload.maxBarSize,t.stackOffset=e.payload.stackOffset,t.syncId=e.payload.syncId,t.syncMethod=e.payload.syncMethod,t.className=e.payload.className,t.baseValue=e.payload.baseValue,t.reverseStackOrder=e.payload.reverseStackOrder}}}),E$e=ree.reducer,{updateOptions:A$e}=ree.actions,iee=Zs({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:T$e}=iee.actions,C$e=iee.reducer,see=to("keyDown"),aee=to("focus"),DL=db();DL.startListening({actionCreator:see,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip,s=t.payload;if(!(s!=="ArrowRight"&&s!=="ArrowLeft"&&s!=="Enter")){var a=sL(i,Qm(n),Mb(n),Cb(n)),o=a==null?-1:Number(a);if(!(!Number.isFinite(o)||o<0)){var l=jc(n);if(s==="Enter"){var c=WS(n,"axis","hover",String(i.index));e.dispatch(AR({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:c}));return}var d=J4e(n),h=d==="left-to-right"?1:-1,g=s==="ArrowRight"?1:-1,m=o+g*h;if(!(l==null||m>=l.length||m<0)){var v=WS(n,"axis","hover",String(m));e.dispatch(AR({active:!0,activeIndex:m.toString(),activeDataKey:void 0,activeCoordinate:v}))}}}}}});DL.startListening({actionCreator:aee,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip;if(!i.active&&i.index==null){var s="0",a=WS(n,"axis","hover",String(s));e.dispatch(AR({activeDataKey:void 0,active:!0,activeIndex:s,activeCoordinate:a}))}}}});var La=to("externalEvent"),oee=db(),kN=new Map;oee.startListening({actionCreator:La,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,s=kN.get(i);s!==void 0&&cancelAnimationFrame(s);var a=requestAnimationFrame(()=>{try{var o=e.getState(),l={activeCoordinate:KUe(o),activeDataKey:uL(o),activeIndex:od(o),activeLabel:ZQ(o),activeTooltipIndex:od(o),isTooltipActive:YUe(o)};n(l,r)}finally{kN.delete(i)}});kN.set(i,a)}}});var N$e=We([Zm],t=>t.tooltipItemPayloads),k$e=We([N$e,Ab,(t,e,n)=>e,(t,e,n)=>n],(t,e,n,r)=>{var i=t.find(o=>o.settings.dataKey===r);if(i!=null){var{positions:s}=i;if(s!=null){var a=e(s,n);return a}}}),lee=to("touchMove"),cee=db();cee.startListening({actionCreator:lee,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=iL(r,r.tooltip.settings.shared);if(i==="axis"){var s=RL(r,PL({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));s?.activeIndex!=null&&e.dispatch(zQ({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate}))}else if(i==="item"){var a,o=n.touches[0];if(document.elementFromPoint==null)return;var l=document.elementFromPoint(o.clientX,o.clientY);if(!l||!l.getAttribute)return;var c=l.getAttribute(kY),d=(a=l.getAttribute(RY))!==null&&a!==void 0?a:void 0,h=k$e(e.getState(),c,d);e.dispatch(UQ({activeDataKey:d,activeIndex:c,activeCoordinate:h}))}}}});var R$e=ZK({brush:B8e,cartesianAxis:JBe,chartData:XFe,errorBars:b6e,graphicalItems:sBe,layout:_Pe,legend:NDe,options:$Fe,polarAxis:yze,polarOptions:C$e,referenceElements:X8e,rootProps:E$e,tooltip:uUe,zIndex:RFe}),P$e=function(e){return WRe({reducer:R$e,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([tee.middleware,nee.middleware,DL.middleware,oee.middleware,cee.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(fY({type:"raf"}))},devTools:$m.devToolsEnabled})};function uee(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=hs(),s=E.useRef(null);if(i)return n;s.current==null&&(s.current=P$e(e));var a=GD;return E.createElement($6e,{context:a,store:s.current},n)}function D$e(t){var{layout:e,margin:n}=t,r=nr(),i=hs();return E.useEffect(()=>{i||(r(bPe(e)),r(xPe(n)))},[r,i,e,n]),null}var dee=E.memo(D$e,OM);function fee(t){var e=nr();return E.useEffect(()=>{e(A$e(t))},[e,t]),null}function wG(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=kJ("".concat(r).concat(e)),s=nr();return E.useLayoutEffect(()=>(s(NFe({zIndex:e,elementId:i,isPanorama:n})),()=>{s(kFe({zIndex:e,isPanorama:n}))}),[s,e,i,n]),E.createElement("g",{tabIndex:-1,id:i})}function MG(t){var{children:e,isPanorama:n}=t,r=Ct(vFe);if(!r||r.length===0)return e;var i=r.filter(a=>a<0),s=r.filter(a=>a>0);return E.createElement(E.Fragment,null,i.map(a=>E.createElement(wG,{key:a,zIndex:a,isPanorama:n})),e,s.map(a=>E.createElement(wG,{key:a,zIndex:a,isPanorama:n})))}var O$e=["children"];function L$e(t,e){if(t==null)return{};var n,r,i=j$e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r{var n=nO(),r=rO(),i=XY();if(!dl(n)||!dl(r))return null;var{children:s,otherAttributes:a,title:o,desc:l}=t,c,d;return a!=null&&(typeof a.tabIndex=="number"?c=a.tabIndex:c=i?0:void 0,typeof a.role=="string"?d=a.role:d=i?"application":void 0),E.createElement(LD,nw({},a,{title:o,desc:l,role:d,tabIndex:c,width:n,height:r,style:I$e,ref:e}),s)}),F$e=t=>{var{children:e}=t,n=Ct(aM);if(!n)return null;var{width:r,height:i,y:s,x:a}=n;return E.createElement(LD,{width:r,height:i,x:a,y:s},e)},EG=E.forwardRef((t,e)=>{var{children:n}=t,r=L$e(t,O$e),i=hs();return i?E.createElement(F$e,null,E.createElement(MG,{isPanorama:!0},n)):E.createElement(U$e,nw({ref:e},r),E.createElement(MG,{isPanorama:!1},n))});function z$e(){var t=nr(),[e,n]=E.useState(null),r=Ct(UPe);return E.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),s=i.width/e.offsetWidth;cr(s)&&s!==r&&t(yPe(s))}},[e,t,r]),n}function AG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function B$e(t){for(var e=1;e(r5e(),null);function rw(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var W$e=E.forwardRef((t,e)=>{var n,r,i=E.useRef(null),[s,a]=E.useState({containerWidth:rw((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:rw((r=t.style)===null||r===void 0?void 0:r.height)}),o=E.useCallback((c,d)=>{a(h=>{var g=Math.round(c),m=Math.round(d);return h.containerWidth===g&&h.containerHeight===m?h:{containerWidth:g,containerHeight:m}})},[]),l=E.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null&&typeof ResizeObserver<"u"){var{width:d,height:h}=c.getBoundingClientRect();o(d,h);var g=v=>{var{width:y,height:b}=v[0].contentRect;o(y,b)},m=new ResizeObserver(g);m.observe(c),i.current=m}},[e,o]);return E.useEffect(()=>()=>{var c=i.current;c?.disconnect()},[o]),E.createElement(E.Fragment,null,E.createElement(lM,{width:s.containerWidth,height:s.containerHeight}),E.createElement("div",Zf({ref:l},t)))}),q$e=E.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,s]=E.useState({containerWidth:rw(n),containerHeight:rw(r)}),a=E.useCallback((l,c)=>{s(d=>{var h=Math.round(l),g=Math.round(c);return d.containerWidth===h&&d.containerHeight===g?d:{containerWidth:h,containerHeight:g}})},[]),o=E.useCallback(l=>{if(typeof e=="function"&&e(l),l!=null){var{width:c,height:d}=l.getBoundingClientRect();a(c,d)}},[e,a]);return E.createElement(E.Fragment,null,E.createElement(lM,{width:i.containerWidth,height:i.containerHeight}),E.createElement("div",Zf({ref:o},t)))}),X$e=E.forwardRef((t,e)=>{var{width:n,height:r}=t;return E.createElement(E.Fragment,null,E.createElement(lM,{width:n,height:r}),E.createElement("div",Zf({ref:e},t)))}),K$e=E.forwardRef((t,e)=>{var{width:n,height:r}=t;return Sc(n)||Sc(r)?E.createElement(q$e,Zf({},t,{ref:e})):E.createElement(X$e,Zf({},t,{ref:e}))});function Y$e(t){return t===!0?W$e:K$e}var Z$e=E.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:s,onContextMenu:a,onDoubleClick:o,onMouseDown:l,onMouseEnter:c,onMouseLeave:d,onMouseMove:h,onMouseUp:g,onTouchEnd:m,onTouchMove:v,onTouchStart:y,style:b,width:x,responsive:M,dispatchTouchEvents:w=!0}=t,A=E.useRef(null),T=nr(),[R,C]=E.useState(null),[I,N]=E.useState(null),D=z$e(),z=tO(),j=z?.width>0?z.width:x,W=z?.height>0?z.height:i,P=E.useCallback(fe=>{D(fe),typeof e=="function"&&e(fe),C(fe),N(fe),fe!=null&&(A.current=fe)},[D,e,C,N]),$=E.useCallback(fe=>{T(eee(fe)),T(La({handler:s,reactEvent:fe}))},[T,s]),K=E.useCallback(fe=>{T(UR(fe)),T(La({handler:c,reactEvent:fe}))},[T,c]),G=E.useCallback(fe=>{T(FQ()),T(La({handler:d,reactEvent:fe}))},[T,d]),Z=E.useCallback(fe=>{T(UR(fe)),T(La({handler:h,reactEvent:fe}))},[T,h]),Q=E.useCallback(()=>{T(aee())},[T]),ee=E.useCallback(fe=>{T(see(fe.key))},[T]),H=E.useCallback(fe=>{T(La({handler:a,reactEvent:fe}))},[T,a]),q=E.useCallback(fe=>{T(La({handler:o,reactEvent:fe}))},[T,o]),te=E.useCallback(fe=>{T(La({handler:l,reactEvent:fe}))},[T,l]),ae=E.useCallback(fe=>{T(La({handler:g,reactEvent:fe}))},[T,g]),xe=E.useCallback(fe=>{T(La({handler:y,reactEvent:fe}))},[T,y]),re=E.useCallback(fe=>{w&&T(lee(fe)),T(La({handler:v,reactEvent:fe}))},[T,w,v]),pe=E.useCallback(fe=>{T(La({handler:m,reactEvent:fe}))},[T,m]),Ce=Y$e(M);return E.createElement(sJ.Provider,{value:R},E.createElement(hK.Provider,{value:I},E.createElement(Ce,{width:j??b?.width,height:W??b?.height,className:An("recharts-wrapper",r),style:B$e({position:"relative",cursor:"default",width:j,height:W},b),onClick:$,onContextMenu:H,onDoubleClick:q,onFocus:Q,onKeyDown:ee,onMouseDown:te,onMouseEnter:K,onMouseLeave:G,onMouseMove:Z,onMouseUp:ae,onTouchEnd:pe,onTouchMove:re,onTouchStart:xe,ref:P},E.createElement(G$e,null),n)))}),Q$e=["width","height","responsive","children","className","style","compact","title","desc"];function J$e(t,e){if(t==null)return{};var n,r,i=eVe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r{var{width:n,height:r,responsive:i,children:s,className:a,style:o,compact:l,title:c,desc:d}=t,h=J$e(t,Q$e),g=Xs(h);return l?E.createElement(E.Fragment,null,E.createElement(lM,{width:n,height:r}),E.createElement(EG,{otherAttributes:g,title:c,desc:d},s)):E.createElement(Z$e,{className:a,style:o,width:n,height:r,responsive:i??!1,onClick:t.onClick,onMouseLeave:t.onMouseLeave,onMouseEnter:t.onMouseEnter,onMouseMove:t.onMouseMove,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onContextMenu:t.onContextMenu,onDoubleClick:t.onDoubleClick,onTouchStart:t.onTouchStart,onTouchMove:t.onTouchMove,onTouchEnd:t.onTouchEnd},E.createElement(EG,{otherAttributes:g,title:c,desc:d,ref:e},E.createElement(Y8e,null,s)))});function FR(){return FR=Object.assign?Object.assign.bind():function(t){for(var e=1;eE.createElement(pee,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:rVe,tooltipPayloadSearcher:mL,categoricalChartProps:t,ref:e}));function sVe(t){var e=nr();return E.useEffect(()=>{e(T$e(t))},[e,t]),null}var aVe=["layout"];function zR(){return zR=Object.assign?Object.assign.bind():function(t){for(var e=1;e{var n=ei(t,mVe);return E.createElement(uVe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:pVe,tooltipPayloadSearcher:mL,categoricalChartProps:n,ref:e})}),xVe=["axis"],bVe=E.forwardRef((t,e)=>E.createElement(pee,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:xVe,tooltipPayloadSearcher:mL,categoricalChartProps:t,ref:e}));const __=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function vVe(t){const e=new Date;switch(t){case"7d":return new Date(e.getTime()-10080*60*1e3);case"30d":return new Date(e.getTime()-720*60*60*1e3);case"90d":return new Date(e.getTime()-2160*60*60*1e3);case"365d":return new Date(e.getTime()-365*24*60*60*1e3);case"all":return new Date(0)}}function yVe({archives:t,currency:e="$"}){const[n,r]=E.useState("30d"),i=E.useMemo(()=>{const g=vVe(n);return t.filter(m=>new Date(m.completed_at||m.created_at)>=g)},[t,n]),s=E.useMemo(()=>{const g=new Map;return i.forEach(m=>{const y=new Date(m.completed_at||m.created_at).toISOString().split("T")[0],b=g.get(y)||{date:y,filament:0,cost:0,prints:0};b.filament+=m.filament_used_grams||0,b.cost+=m.cost||0,b.prints+=1,g.set(y,b)}),Array.from(g.values()).sort((m,v)=>m.date.localeCompare(v.date)).map(m=>({...m,dateLabel:new Date(m.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),a=E.useMemo(()=>{if(n==="7d"||n==="30d")return s;const g=new Map;return i.forEach(m=>{const v=new Date(m.completed_at||m.created_at),y=new Date(v);y.setDate(v.getDate()-v.getDay());const b=y.toISOString().split("T")[0],x=g.get(b)||{week:b,filament:0,cost:0,prints:0};x.filament+=m.filament_used_grams||0,x.cost+=m.cost||0,x.prints+=1,g.set(b,x)}),Array.from(g.values()).sort((m,v)=>m.week.localeCompare(v.week)).map(m=>({date:m.week,dateLabel:`Week of ${new Date(m.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...m}))},[i,s,n]),o=E.useMemo(()=>{const g=new Map;return i.forEach(m=>{const y=(m.filament_type||"Unknown").split(", ");y.forEach(b=>{const x=(m.filament_used_grams||0)/y.length;g.set(b,(g.get(b)||0)+x)})}),Array.from(g.entries()).map(([m,v])=>({name:m,value:Math.round(v)})).sort((m,v)=>v.value-m.value)},[i]),l=E.useMemo(()=>{const g=new Date,m=[];for(let v=5;v>=0;v--){const y=new Date(g.getFullYear(),g.getMonth()-v,1),b=new Date(g.getFullYear(),g.getMonth()-v+1,0),x=y.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),M=t.filter(w=>{const A=new Date(w.completed_at||w.created_at);return A>=y&&A<=b});m.push({month:x,filament:Math.round(M.reduce((w,A)=>w+(A.filament_used_grams||0),0)),cost:M.reduce((w,A)=>w+(A.cost||0),0),prints:M.length})}return m},[t]),c=n==="7d"||n==="30d"?s:a,d=i.reduce((g,m)=>g+(m.filament_used_grams||0),0),h=i.reduce((g,m)=>g+(m.cost||0),0);return u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),u.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(g=>u.jsx("button",{onClick:()=>r(g),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===g?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:g==="all"?"All":g.replace("d","D")},g))})]}),u.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),u.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),u.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),u.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,h.toFixed(2)]}),u.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),u.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(d/i.length).toFixed(0):0,"g"]}),u.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(h/i.length).toFixed(2):"0.00"," avg"]})]})]}),c.length>0?u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[u.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),u.jsx(ZC,{width:"100%",height:250,children:u.jsxs(bVe,{data:c,children:[u.jsx("defs",{children:u.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[u.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),u.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),u.jsx(DR,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),u.jsx(LR,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),u.jsx(IR,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),u.jsx(mN,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:g=>[`${g.toFixed(0)}g`,"Filament"]}),u.jsx(QJ,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):u.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),u.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[u.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),o.length>0?u.jsxs("div",{className:"flex items-center gap-4",children:[u.jsx(ZC,{width:160,height:160,children:u.jsxs(gVe,{children:[u.jsx(DJ,{data:o,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:o.map((g,m)=>u.jsx(kb,{fill:__[m%__.length]},`cell-${m}`))}),u.jsx(mN,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:g=>[`${g}g`,"Usage"]})]})}),u.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:o.map((g,m)=>{const v=o.reduce((b,x)=>b+x.value,0),y=v>0?(g.value/v*100).toFixed(0):0;return u.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[u.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:__[m%__.length]}}),u.jsx("span",{className:"text-white truncate flex-1",children:g.name}),u.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[y,"%"]})]},g.name)})})]}):u.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[u.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),u.jsx(ZC,{width:"100%",height:200,children:u.jsxs(iVe,{data:l,children:[u.jsx(DR,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),u.jsx(LR,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),u.jsx(IR,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),u.jsx(mN,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(g,m)=>[m==="filament"?`${g}g`:m==="cost"?`${e}${g.toFixed(2)}`:g,m==="filament"?"Filament":m==="cost"?"Cost":"Prints"]}),u.jsx(qY,{}),u.jsx(UJ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function _Ve({id:t,title:e,children:n,isHidden:r,size:i,onToggleVisibility:s,onToggleSize:a}){const{attributes:o,listeners:l,setNodeRef:c,transform:d,transition:h,isDragging:g}=aK({id:t}),m={transform:xm.Transform.toString(d),transition:h,opacity:g?.5:1};return r?null:u.jsxs("div",{ref:c,style:{...m,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${g?"ring-2 ring-bambu-green shadow-lg":""}`,children:[u.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("button",{...o,...l,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:u.jsx(aP,{className:"w-4 h-4 text-bambu-gray"})}),u.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx("button",{onClick:a,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:`Size: ${i===1?"1/4":i===2?"1/2":"Full"} - Click to cycle`,children:i===4?u.jsx(Voe,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):u.jsx(zoe,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),u.jsx("button",{onClick:s,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:u.jsx(rP,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),u.jsx("div",{className:"p-4",children:n})]})}function SVe({widgets:t,storageKey:e,columns:n=4}){const r=()=>{const b={};return t.forEach(x=>{b[x.id]=x.defaultSize||4}),b},[i,s]=E.useState(()=>{const b=localStorage.getItem(e);if(b)try{const x=JSON.parse(b);return x.sizes||(x.sizes=r()),x}catch{}return{order:t.map(x=>x.id),hidden:t.filter(x=>x.defaultVisible===!1).map(x=>x.id),sizes:r()}}),[a,o]=E.useState(!1);E.useEffect(()=>{localStorage.setItem(e,JSON.stringify(i))},[i,e]),E.useEffect(()=>{const x=t.map(M=>M.id).filter(M=>!i.order.includes(M));x.length>0&&s(M=>({...M,order:[...M.order,...x]}))},[t,i.order]);const l=UX(lS(Bw,{activationConstraint:{distance:8}}),lS(zw,{coordinateGetter:oK})),c=b=>{const{active:x,over:M}=b;M&&x.id!==M.id&&s(w=>{const A=w.order.indexOf(x.id),T=w.order.indexOf(M.id);return{...w,order:Vw(w.order,A,T)}})},d=b=>{s(x=>({...x,hidden:x.hidden.includes(b)?x.hidden.filter(M=>M!==b):[...x.hidden,b]}))},h=b=>{s(x=>{const M=x.sizes[b]||4,w=M===1?2:M===2?4:1;return{...x,sizes:{...x.sizes,[b]:w}}})},g=()=>{const b={order:t.map(x=>x.id),hidden:t.filter(x=>x.defaultVisible===!1).map(x=>x.id),sizes:r()};s(b)},m=i.order.map(b=>t.find(x=>x.id===b)).filter(Boolean),v=m.filter(b=>!i.hidden.includes(b.id)),y=m.filter(b=>i.hidden.includes(b.id));return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-end gap-2",children:[y.length>0&&u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>o(!a),children:[u.jsx(t0,{className:"w-4 h-4"}),y.length," Hidden"]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:g,children:[u.jsx(X0,{className:"w-4 h-4"}),"Reset Layout"]})]}),a&&y.length>0&&u.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[u.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),u.jsx("div",{className:"flex flex-wrap gap-2",children:y.map(b=>u.jsxs("button",{onClick:()=>d(b.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[u.jsx(t0,{className:"w-3 h-3"}),b.title]},b.id))})]}),u.jsx(tK,{sensors:l,collisionDetection:HX,onDragEnd:c,children:u.jsx(iK,{items:v.map(b=>b.id),strategy:DD,children:u.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:v.map(b=>u.jsx(_Ve,{id:b.id,title:b.title,isHidden:i.hidden.includes(b.id),size:i.sizes[b.id]||2,onToggleVisibility:()=>d(b.id),onToggleSize:()=>h(b.id),children:b.component},b.id))})})}),v.length===0&&u.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[u.jsx("p",{children:"All widgets are hidden."}),u.jsx(Ue,{className:"mt-4",onClick:g,children:"Reset Layout"})]})]})}function wVe({stats:t,currency:e}){return u.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:u.jsx(n1,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),u.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:u.jsx(Qr,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),u.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:u.jsx(n1,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),u.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:u.jsx(XN,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),u.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:u.jsx(s0,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),u.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:u.jsx(XN,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),u.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function MVe({stats:t}){const e=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0;return u.jsxs("div",{className:"flex items-center gap-6",children:[u.jsxs("div",{className:"relative w-28 h-28",children:[u.jsxs("svg",{className:"w-full h-full -rotate-90",children:[u.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),u.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${e*3.02} 302`})]}),u.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:u.jsxs("span",{className:"text-xl font-bold text-white",children:[e,"%"]})})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Ss,{className:"w-4 h-4 text-bambu-green"}),u.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),u.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ud,{className:"w-4 h-4 text-red-400"}),u.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),u.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]})]})}function EVe({stats:t,printerMap:e}){const n=t?.average_time_accuracy;if(n==null)return u.jsx("div",{className:"flex items-center justify-center h-full",children:u.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No time accuracy data yet"})});const i=(Math.min(150,Math.max(50,n))-50)/100*100,a=(l=>l>=95&&l<=105?"#00ae42":l>105?"#3b82f6":"#f97316")(n),o=n-100;return u.jsxs("div",{className:"flex items-center gap-6",children:[u.jsxs("div",{className:"relative w-28 h-28",children:[u.jsxs("svg",{className:"w-full h-full -rotate-90",children:[u.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),u.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:a,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i*3.02} 302`})]}),u.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[u.jsxs("span",{className:"text-xl font-bold text-white",children:[n.toFixed(0),"%"]}),u.jsxs("span",{className:`text-xs ${o>=0?"text-blue-400":"text-orange-400"}`,children:[o>=0?"+":"",o.toFixed(0),"%"]})]})]}),u.jsxs("div",{className:"space-y-2 flex-1",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[u.jsx(E9,{className:"w-3 h-3"}),u.jsx("span",{children:"100% = perfect estimate"})]}),t?.time_accuracy_by_printer&&Object.keys(t.time_accuracy_by_printer).length>0&&u.jsx("div",{className:"space-y-1 mt-2",children:Object.entries(t.time_accuracy_by_printer).slice(0,3).map(([l,c])=>u.jsxs("div",{className:"flex items-center justify-between text-xs",children:[u.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(l)||`Printer ${l}`}),u.jsxs("span",{className:`font-medium ${c>=95&&c<=105?"text-bambu-green":c>105?"text-blue-400":"text-orange-400"}`,children:[c.toFixed(0),"%"]})]},l))})]})]})}function AVe({stats:t}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return u.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No filament data available"});const e=Object.entries(t.prints_by_filament_type).sort(([,n],[,r])=>r-n);return u.jsx("div",{className:"space-y-3",children:e.map(([n,r])=>{const i=Math.round(r/(t.total_prints||1)*100);return u.jsxs("div",{children:[u.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[u.jsx("span",{className:"text-white",children:n}),u.jsxs("span",{className:"text-bambu-gray",children:[r," prints"]})]}),u.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:u.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${i}%`}})})]},n)})})}function TVe({printDates:t}){return u.jsx(h3e,{printDates:t,months:4})}function CVe({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?u.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):u.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,r])=>u.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[u.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:u.jsx(ko,{className:"w-4 h-4 text-bambu-green"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),u.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function NVe({archives:t,currency:e}){return!t||t.length===0?u.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):u.jsx(yVe,{archives:t,currency:e})}function kVe(){const{data:t,isLoading:e}=Mt({queryKey:["archiveStats"],queryFn:Le.getArchiveStats}),{data:n}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),{data:r}=Mt({queryKey:["archives"],queryFn:()=>Le.getArchives(void 0,1e3,0)}),{data:i}=Mt({queryKey:["settings"],queryFn:Le.getSettings}),s=i?.currency||"$",a=new Map(n?.map(c=>[String(c.id),c.name])||[]),o=r?.map(c=>c.created_at)||[];if(e)return u.jsx("div",{className:"p-8",children:u.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const l=[{id:"quick-stats",title:"Quick Stats",component:u.jsx(wVe,{stats:t,currency:s}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:u.jsx(MVe,{stats:t}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:u.jsx(EVe,{stats:t,printerMap:a}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:u.jsx(AVe,{stats:t}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:u.jsx(TVe,{printDates:o}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:u.jsx(CVe,{stats:t,printerMap:a}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:u.jsx(NVe,{archives:r||[],currency:s}),defaultSize:4}];return u.jsxs("div",{className:"p-8",children:[u.jsxs("div",{className:"mb-6",children:[u.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),u.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),u.jsx(SVe,{widgets:l,storageKey:"bambusy-dashboard-layout"})]})}function RVe({plug:t,onEdit:e}){const n=Nn(),[r,i]=E.useState(!1),[s,a]=E.useState(!1),[o,l]=E.useState(!1),[c,d]=E.useState(!1),{data:h,isLoading:g,refetch:m}=Mt({queryKey:["smart-plug-status",t.id],queryFn:()=>Le.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:v}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),y=v?.find(R=>R.id===t.printer_id),b=At({mutationFn:R=>Le.controlSmartPlug(t.id,R),onSuccess:()=>{m()}}),x=At({mutationFn:R=>Le.updateSmartPlug(t.id,R),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),M=At({mutationFn:()=>Le.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),w=h?.state==="ON",A=h?.reachable??!1,T=b.isPending;return u.jsxs(u.Fragment,{children:[u.jsx(Lt,{className:"relative",children:u.jsxs(Ft,{className:"p-4",children:[u.jsxs("div",{className:"flex items-start justify-between mb-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:`p-2 rounded-lg ${A?w?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:u.jsx(Nx,{className:`w-5 h-5 ${A?w?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),u.jsxs("div",{children:[u.jsx("h3",{className:"font-medium text-white",children:t.name}),u.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),u.jsx("div",{className:"flex items-center gap-2",children:g?u.jsx(Ot,{className:"w-4 h-4 text-bambu-gray animate-spin"}):A?u.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[u.jsx(T9,{className:"w-4 h-4 text-bambu-green"}),u.jsx("span",{className:w?"text-bambu-green":"text-bambu-gray",children:h?.state||"Unknown"})]}):u.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[u.jsx(fP,{className:"w-4 h-4"}),u.jsx("span",{children:"Offline"})]})})]}),y&&u.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[u.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),u.jsx("span",{className:"text-sm text-white",children:y.name})]}),(t.power_alert_enabled||t.schedule_enabled)&&u.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.power_alert_enabled&&u.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full",children:[u.jsx(ff,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&u.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded-full",children:[u.jsx(Wr,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?`On ${t.schedule_on_time}`:`Off ${t.schedule_off_time}`]})]}),u.jsxs("div",{className:"flex gap-2 mb-3",children:[u.jsxs(Ue,{size:"sm",variant:w?"primary":"secondary",disabled:!A||T,onClick:()=>a(!0),className:"flex-1",children:[T?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(dd,{className:"w-4 h-4"}),"On"]}),u.jsxs(Ue,{size:"sm",variant:w?"secondary":"primary",disabled:!A||T,onClick:()=>l(!0),className:"flex-1",children:[T?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(cP,{className:"w-4 h-4"}),"Off"]})]}),u.jsxs("button",{onClick:()=>d(!c),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(fw,{className:"w-4 h-4"}),"Automation Settings"]}),u.jsx("span",{children:c?"-":"+"})]}),c&&u.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Enabled"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:t.enabled,onChange:R=>x.mutate({enabled:R.target.checked}),className:"sr-only peer"}),u.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Auto On"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:R=>x.mutate({auto_on:R.target.checked}),className:"sr-only peer"}),u.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:R=>x.mutate({auto_off:R.target.checked}),className:"sr-only peer"}),u.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.auto_off&&u.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsxs("button",{onClick:()=>x.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[u.jsx(Qr,{className:"w-4 h-4"}),"Time"]}),u.jsxs("button",{onClick:()=>x.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[u.jsx(Ip,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),u.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:R=>x.mutate({off_delay_minutes:parseInt(R.target.value)||5}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}):u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),u.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:R=>x.mutate({off_temp_threshold:parseInt(R.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),u.jsxs("div",{className:"flex gap-2 pt-2",children:[u.jsxs(Ue,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[u.jsx(lP,{className:"w-4 h-4"}),"Edit"]}),u.jsx(Ue,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:u.jsx(Qn,{className:"w-4 h-4"})})]})]})]})}),r&&u.jsx(Zi,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{M.mutate(),i(!1)},onCancel:()=>i(!1)}),s&&u.jsx(Zi,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{b.mutate("on"),a(!1)},onCancel:()=>a(!1)}),o&&u.jsx(Zi,{title:"Turn Off Smart Plug",message:`Are you sure you want to turn off "${t.name}"? This will cut power to the connected device.`,confirmText:"Turn Off",variant:"danger",onConfirm:()=>{b.mutate("off"),l(!1)},onCancel:()=>l(!1)})]})}function PVe({plug:t,onClose:e}){const n=Nn(),r=!!t,[i,s]=E.useState(t?.name||""),[a,o]=E.useState(t?.ip_address||""),[l,c]=E.useState(t?.username||""),[d,h]=E.useState(t?.password||""),[g,m]=E.useState(t?.printer_id||null),[v,y]=E.useState(null),[b,x]=E.useState(null),[M,w]=E.useState(t?.power_alert_enabled||!1),[A,T]=E.useState(t?.power_alert_high?.toString()||""),[R,C]=E.useState(t?.power_alert_low?.toString()||""),[I,N]=E.useState(t?.schedule_enabled||!1),[D,z]=E.useState(t?.schedule_on_time||""),[j,W]=E.useState(t?.schedule_off_time||""),{data:P}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),{data:$}=Mt({queryKey:["smart-plugs"],queryFn:Le.getSmartPlugs});E.useEffect(()=>{const q=te=>{te.key==="Escape"&&e()};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[e]);const K=At({mutationFn:()=>Le.testSmartPlugConnection(a,l||null,d||null),onSuccess:q=>{y(q),x(null),!i&&q.device_name&&s(q.device_name)},onError:q=>{y(null),x(q.message)}}),G=At({mutationFn:q=>Le.createSmartPlug(q),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:q=>{x(q.message)}}),Z=At({mutationFn:q=>Le.updateSmartPlug(t.id,q),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:q=>{x(q.message)}}),Q=P?.filter(q=>!$?.some(ae=>ae.printer_id===q.id&&ae.id!==t?.id)),ee=q=>{if(q.preventDefault(),x(null),!i.trim()){x("Name is required");return}if(!a.trim()){x("IP address is required");return}const te={name:i.trim(),ip_address:a.trim(),username:l.trim()||null,password:d.trim()||null,printer_id:g,power_alert_enabled:M,power_alert_high:A?parseFloat(A):null,power_alert_low:R?parseFloat(R):null,schedule_enabled:I,schedule_on_time:D||null,schedule_off_time:j||null};r?Z.mutate(te):G.mutate(te)},H=G.isPending||Z.isPending;return u.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:u.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:q=>q.stopPropagation(),children:[u.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[u.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),u.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("form",{onSubmit:ee,className:"p-6 space-y-4",children:[b&&u.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:b}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx("input",{type:"text",value:a,onChange:q=>{o(q.target.value),y(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),u.jsxs(Ue,{type:"button",variant:"secondary",onClick:()=>K.mutate(),disabled:!a.trim()||K.isPending,children:[K.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(T9,{className:"w-4 h-4"}),"Test"]})]})]}),v&&u.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${v.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:v.success?u.jsxs(u.Fragment,{children:[u.jsx(Ss,{className:"w-5 h-5"}),u.jsxs("div",{children:[u.jsx("p",{className:"font-medium",children:"Connected!"}),u.jsxs("p",{className:"text-sm opacity-80",children:[v.device_name&&`Device: ${v.device_name} - `,"State: ",v.state]})]})]}):u.jsxs(u.Fragment,{children:[u.jsx(fP,{className:"w-5 h-5"}),u.jsx("span",{children:"Connection failed"})]})}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),u.jsx("input",{type:"text",value:i,onChange:q=>s(q.target.value),placeholder:"Living Room Plug",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),u.jsx("input",{type:"text",value:l,onChange:q=>c(q.target.value),placeholder:"admin",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),u.jsx("input",{type:"password",value:d,onChange:q=>h(q.target.value),placeholder:"********",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),u.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),u.jsxs("select",{value:g??"",onChange:q=>m(q.target.value?Number(q.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"",children:"No printer (manual control only)"}),Q?.map(q=>u.jsx("option",{value:q.id,children:q.name},q.id))]}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),u.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[u.jsxs("div",{className:"flex items-center justify-between mb-3",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ff,{className:"w-4 h-4 text-bambu-green"}),u.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:M,onChange:q=>w(q.target.checked),className:"sr-only peer"}),u.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),M&&u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),u.jsx("input",{type:"number",value:A,onChange:q=>T(q.target.value),placeholder:"e.g. 200",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),u.jsx("input",{type:"number",value:R,onChange:q=>C(q.target.value),placeholder:"e.g. 10",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Get notified when power consumption crosses these thresholds. Leave empty to disable that direction."})]})]}),u.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[u.jsxs("div",{className:"flex items-center justify-between mb-3",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Qr,{className:"w-4 h-4 text-bambu-green"}),u.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:I,onChange:q=>N(q.target.checked),className:"sr-only peer"}),u.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),I&&u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),u.jsx("input",{type:"time",value:D,onChange:q=>z(q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),u.jsx("input",{type:"time",value:j,onChange:q=>W(q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Automatically turn the plug on/off at these times daily. Leave empty to skip that action."})]})]}),u.jsxs("div",{className:"flex gap-3 pt-2",children:[u.jsx(Ue,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),u.jsxs(Ue,{type:"submit",disabled:H,className:"flex-1",children:[H?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Qo,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function er({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return u.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:r,className:`relative inline-flex w-9 h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:u.jsx("span",{className:`pointer-events-none absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const DVe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function OVe({provider:t,onEdit:e}){const n=Nn(),[r,i]=E.useState(!1),[s,a]=E.useState(!1),[o,l]=E.useState(null),{data:c}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),d=c?.find(y=>y.id===t.printer_id),h=At({mutationFn:y=>Le.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=At({mutationFn:()=>Le.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=At({mutationFn:()=>Le.testNotificationProvider(t.id),onSuccess:y=>{l(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{l({success:!1,message:y.message})}}),v=y=>y||"";return u.jsxs(u.Fragment,{children:[u.jsx(Lt,{className:"relative",children:u.jsxs(Ft,{className:"p-4",children:[u.jsxs("div",{className:"flex items-start justify-between mb-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:u.jsx(ff,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),u.jsxs("div",{children:[u.jsx("h3",{className:"font-medium text-white",children:t.name}),u.jsx("p",{className:"text-sm text-bambu-gray",children:DVe[t.provider_type]||t.provider_type})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[t.last_success&&u.jsxs("span",{className:"text-xs text-bambu-green",children:["Last sent: ",new Date(t.last_success).toLocaleDateString()]}),t.last_error&&t.last_error_at&&(!t.last_success||new Date(t.last_error_at)>new Date(t.last_success))&&u.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"})]})]}),d&&u.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[u.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),u.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&u.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:u.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),u.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&u.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&u.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&u.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&u.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&u.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&u.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&u.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&u.jsx("span",{className:"px-2 py-0.5 bg-cyan-500/20 text-cyan-400 text-xs rounded",children:"Low Filament"}),t.on_maintenance_due&&u.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.quiet_hours_enabled&&u.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[u.jsx(t1,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&u.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[u.jsx(Wr,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),u.jsx("div",{className:"mb-3",children:u.jsxs(Ue,{size:"sm",variant:"secondary",disabled:m.isPending,onClick:()=>{l(null),m.mutate()},className:"w-full",children:[m.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(uP,{className:"w-4 h-4"}),"Send Test Notification"]})}),o&&u.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${o.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[o.success?u.jsx(Ss,{className:"w-4 h-4"}):u.jsx(ud,{className:"w-4 h-4"}),u.jsx("span",{children:o.message})]}),u.jsxs("button",{onClick:()=>a(!s),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(fw,{className:"w-4 h-4"}),"Event Settings"]}),s?u.jsx(cw,{className:"w-4 h-4"}):u.jsx(Qf,{className:"w-4 h-4"})]}),s&&u.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Enabled"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),u.jsx(er,{checked:t.enabled,onChange:y=>h.mutate({enabled:y})})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Print Started"}),u.jsx(er,{checked:t.on_print_start,onChange:y=>h.mutate({on_print_start:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),u.jsx(er,{checked:t.on_print_complete,onChange:y=>h.mutate({on_print_complete:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),u.jsx(er,{checked:t.on_print_failed,onChange:y=>h.mutate({on_print_failed:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),u.jsx(er,{checked:t.on_print_stopped,onChange:y=>h.mutate({on_print_stopped:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),u.jsx(er,{checked:t.on_print_progress,onChange:y=>h.mutate({on_print_progress:y})})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),u.jsx(er,{checked:t.on_printer_offline,onChange:y=>h.mutate({on_printer_offline:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),u.jsx(er,{checked:t.on_printer_error,onChange:y=>h.mutate({on_printer_error:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),u.jsx(er,{checked:t.on_filament_low,onChange:y=>h.mutate({on_filament_low:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),u.jsx(er,{checked:t.on_maintenance_due??!1,onChange:y=>h.mutate({on_maintenance_due:y})})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(t1,{className:"w-4 h-4 text-purple-400"}),u.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),u.jsx(er,{checked:t.quiet_hours_enabled,onChange:y=>h.mutate({quiet_hours_enabled:y})})]}),t.quiet_hours_enabled&&u.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Qr,{className:"w-4 h-4 text-bambu-gray"}),u.jsxs("span",{className:"text-sm text-white",children:[v(t.quiet_hours_start)||"22:00"," - ",v(t.quiet_hours_end)||"07:00"]})]}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Wr,{className:"w-4 h-4 text-emerald-400"}),u.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),u.jsx(er,{checked:t.daily_digest_enabled,onChange:y=>h.mutate({daily_digest_enabled:y})})]}),t.daily_digest_enabled&&u.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Qr,{className:"w-4 h-4 text-bambu-gray"}),u.jsxs("span",{className:"text-sm text-white",children:["Send at ",v(t.daily_digest_time)||"08:00"]})]}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),u.jsxs("div",{className:"flex gap-2 pt-2",children:[u.jsxs(Ue,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[u.jsx(lP,{className:"w-4 h-4"}),"Edit"]}),u.jsx(Ue,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:u.jsx(Qn,{className:"w-4 h-4"})})]})]})]})}),r&&u.jsx(Zi,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{g.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const NG=[{value:"discord",label:"Discord",description:"Send to Discord channel via webhook"},{value:"telegram",label:"Telegram",description:"Notifications via Telegram bot"},{value:"ntfy",label:"ntfy",description:"Free, self-hostable push notifications"},{value:"pushover",label:"Pushover",description:"Simple, reliable push notifications"},{value:"email",label:"Email",description:"SMTP email notifications"},{value:"callmebot",label:"CallMeBot/WhatsApp",description:"Free WhatsApp notifications via CallMeBot"},{value:"webhook",label:"Webhook",description:"Generic HTTP POST to any URL"}];function LVe({provider:t,onClose:e}){const n=Nn(),r=!!t,[i,s]=E.useState(t?.name||""),[a,o]=E.useState(t?.provider_type||"discord"),[l,c]=E.useState(t?.printer_id||null),[d,h]=E.useState(t?.quiet_hours_enabled||!1),[g,m]=E.useState(t?.quiet_hours_start||"22:00"),[v,y]=E.useState(t?.quiet_hours_end||"07:00"),[b,x]=E.useState(t?.daily_digest_enabled||!1),[M,w]=E.useState(t?.daily_digest_time||"08:00"),[A,T]=E.useState(t?.on_print_start??!1),[R,C]=E.useState(t?.on_print_complete??!0),[I,N]=E.useState(t?.on_print_failed??!0),[D,z]=E.useState(t?.on_print_stopped??!0),[j,W]=E.useState(t?.on_print_progress??!1),[P,$]=E.useState(t?.on_printer_offline??!1),[K,G]=E.useState(t?.on_printer_error??!1),[Z,Q]=E.useState(t?.on_filament_low??!1),[ee,H]=E.useState(t?.on_maintenance_due??!1),[q,te]=E.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([V,J])=>[V,String(J)])):{}),[ae,xe]=E.useState(null),[re,pe]=E.useState(null),{data:Ce}=Mt({queryKey:["printers"],queryFn:Le.getPrinters});E.useEffect(()=>{const V=J=>{J.key==="Escape"&&e()};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[e]);const fe=At({mutationFn:()=>Le.testNotificationConfig({provider_type:a,config:q}),onSuccess:V=>{xe(V),pe(null)},onError:V=>{xe({success:!1,message:V.message})}}),Se=At({mutationFn:V=>Le.createNotificationProvider(V),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:V=>{pe(V.message)}}),Re=At({mutationFn:V=>Le.updateNotificationProvider(t.id,V),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:V=>{pe(V.message)}}),ue=V=>{if(V.preventDefault(),pe(null),!i.trim()){pe("Name is required");return}const J=F(a);for(const Ae of J)if(!q[Ae.key]?.trim()){pe(`${Ae.label} is required`);return}const le={name:i.trim(),provider_type:a,config:q,printer_id:l,quiet_hours_enabled:d,quiet_hours_start:d?g:null,quiet_hours_end:d?v:null,daily_digest_enabled:b,daily_digest_time:b?M:null,on_print_start:A,on_print_complete:R,on_print_failed:I,on_print_stopped:D,on_print_progress:j,on_printer_offline:P,on_printer_error:K,on_filament_low:Z,on_maintenance_due:ee};r?Re.mutate(le):Se.mutate(le)},ct=Se.isPending||Re.isPending,B=V=>{switch(V){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambuddy",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"auth_header",label:"Authorization",placeholder:"Bearer token (optional)",type:"password",required:!1},{key:"field_title",label:"Title Field Name",placeholder:"title",type:"text",required:!1},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1}];default:return[]}},F=V=>B(V).filter(J=>J.required),ie=B(a);return u.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:u.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8",onClick:V=>V.stopPropagation(),children:[u.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[u.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),u.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("form",{onSubmit:ue,className:"p-6 space-y-4",children:[re&&u.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:re}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),u.jsx("input",{type:"text",value:i,onChange:V=>s(V.target.value),placeholder:"My Notifications",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),u.jsx("select",{value:a,onChange:V=>{o(V.target.value),te({}),xe(null)},disabled:r,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:NG.map(V=>u.jsx("option",{value:V.value,children:V.label},V.value))}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:NG.find(V=>V.value===a)?.description})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),ie.map(V=>u.jsxs("div",{children:[u.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[V.label," ",V.required&&"*"]}),V.type==="select"&&V.options?u.jsx("select",{value:q[V.key]||V.options[0]?.value||"",onChange:J=>{te({...q,[V.key]:J.target.value}),xe(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:V.options.map(J=>u.jsx("option",{value:J.value,children:J.label},J.value))}):u.jsx("input",{type:V.type,value:q[V.key]||"",onChange:J=>{te({...q,[V.key]:J.target.value}),xe(null)},placeholder:V.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},V.key))]}),u.jsx("div",{className:"flex gap-2",children:u.jsxs(Ue,{type:"button",variant:"secondary",onClick:()=>{xe(null),fe.mutate()},disabled:fe.isPending||!q[F(a)[0]?.key],className:"flex-1",children:[fe.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(uP,{className:"w-4 h-4"}),"Test Configuration"]})}),ae&&u.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ae.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:ae.success?u.jsxs(u.Fragment,{children:[u.jsx(Ss,{className:"w-5 h-5"}),u.jsx("span",{children:ae.message})]}):u.jsxs(u.Fragment,{children:[u.jsx(ud,{className:"w-5 h-5"}),u.jsx("span",{children:ae.message})]})}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),u.jsxs("select",{value:l??"",onChange:V=>c(V.target.value?Number(V.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"",children:"All printers"}),Ce?.map(V=>u.jsx("option",{value:V.id,children:V.name},V.id))]}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),u.jsx(er,{checked:d,onChange:h})]}),d&&u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),u.jsx("input",{type:"time",value:g,onChange:V=>m(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),u.jsx("input",{type:"time",value:v,onChange:V=>y(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),u.jsx(er,{checked:b,onChange:x})]}),b&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),u.jsx("input",{type:"time",value:M,onChange:V=>w(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),u.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[u.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),u.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Start"}),u.jsx(er,{checked:A,onChange:T})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Complete"}),u.jsx(er,{checked:R,onChange:C})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Failed"}),u.jsx(er,{checked:I,onChange:N})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Stopped"}),u.jsx(er,{checked:D,onChange:z})]}),u.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[u.jsxs("div",{children:[u.jsx("span",{className:"text-sm text-white",children:"Progress"}),u.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),u.jsx(er,{checked:j,onChange:W})]})]})]}),u.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[u.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),u.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Offline"}),u.jsx(er,{checked:P,onChange:$})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Error"}),u.jsx(er,{checked:K,onChange:G})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),u.jsx(er,{checked:Z,onChange:Q})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),u.jsx(er,{checked:ee,onChange:H})]})]})]})]}),u.jsxs("div",{className:"flex gap-3 pt-2",children:[u.jsx(Ue,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),u.jsxs(Ue,{type:"submit",disabled:ct,className:"flex-1",children:[ct?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Qo,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function jVe({template:t,onClose:e}){const n=Nn(),r=E.useRef(null),[i,s]=E.useState(t.title_template),[a,o]=E.useState(t.body_template),[l,c]=E.useState(null),[d,h]=E.useState(!0),{data:g}=Mt({queryKey:["template-variables"],queryFn:Le.getTemplateVariables}),m=g?.find(T=>T.event_type===t.event_type),{data:v,isLoading:y}=Mt({queryKey:["template-preview",t.event_type,i,a],queryFn:()=>Le.previewTemplate({event_type:t.event_type,title_template:i,body_template:a}),enabled:d&&i.length>0&&a.length>0});E.useEffect(()=>{const T=R=>{R.key==="Escape"&&e()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[e]);const b=At({mutationFn:T=>Le.updateNotificationTemplate(t.id,T),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:T=>{c(T.message)}}),x=At({mutationFn:()=>Le.resetNotificationTemplate(t.id),onSuccess:T=>{s(T.title_template),o(T.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:T=>{c(T.message)}}),M=T=>{if(T.preventDefault(),c(null),!i.trim()){c("Title is required");return}if(!a.trim()){c("Body is required");return}b.mutate({title_template:i,body_template:a})},w=T=>{const R=r.current;if(!R)return;const C=R.selectionStart,I=R.selectionEnd,N=a,D=N.substring(0,C),z=N.substring(I),j=D+`{${T}}`+z;o(j),setTimeout(()=>{R.focus();const W=C+T.length+2;R.setSelectionRange(W,W)},0)},A=i!==t.title_template||a!==t.body_template;return u.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:u.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[u.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),u.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:u.jsx(Qt,{className:"w-5 h-5 text-bambu-gray"})})]}),u.jsxs("form",{onSubmit:M,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[l&&u.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:l}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),u.jsx("input",{type:"text",value:i,onChange:T=>s(T.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green",placeholder:"Notification title..."})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),u.jsx("textarea",{ref:r,value:a,onChange:T=>o(T.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:"Notification body..."})]}),m&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),u.jsx("div",{className:"flex flex-wrap gap-2",children:m.variables.map(T=>u.jsxs("button",{type:"button",onClick:()=>w(T),className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors",children:[u.jsx(li,{className:"w-3 h-3"}),T]},T))}),u.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center justify-between mb-2",children:[u.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[u.jsx(t0,{className:"w-4 h-4"}),"Live Preview"]}),u.jsx("button",{type:"button",onClick:()=>h(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&u.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:y?u.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[u.jsx(Ot,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):v?u.jsxs(u.Fragment,{children:[u.jsxs("div",{children:[u.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),u.jsx("div",{className:"text-white font-medium",children:v.title})]}),u.jsxs("div",{children:[u.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),u.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:v.body})]})]}):u.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),u.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[u.jsxs(Ue,{type:"button",variant:"ghost",onClick:()=>x.mutate(),disabled:x.isPending,className:"text-orange-400 hover:text-orange-300",children:[x.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin mr-2"}):u.jsx(X0,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Ue,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),u.jsxs(Ue,{onClick:M,disabled:b.isPending||!A,children:[b.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin mr-2"}):u.jsx(Qo,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const IVe={print_start:"Print Started",print_complete:"Print Complete",print_failed:"Print Failed",print_stopped:"Print Stopped",print_progress:"Progress",printer_offline:"Printer Offline",printer_error:"Printer Error",filament_low:"Low Filament",maintenance_due:"Maintenance Due",test:"Test"},UVe={print_start:"text-blue-400",print_complete:"text-bambu-green",print_failed:"text-red-400",print_stopped:"text-orange-400",print_progress:"text-yellow-400",printer_offline:"text-gray-400",printer_error:"text-rose-400",filament_low:"text-cyan-400",maintenance_due:"text-purple-400",test:"text-bambu-gray"};function FVe({onClose:t}){const e=Nn(),{showToast:n}=Di(),[r,i]=E.useState(7),[s,a]=E.useState(null),[o,l]=E.useState(!1),{data:c,isLoading:d,refetch:h,isRefetching:g}=Mt({queryKey:["notification-logs",r,o],queryFn:()=>Le.getNotificationLogs({days:r,limit:100,success:o?!1:void 0})}),{data:m}=Mt({queryKey:["notification-log-stats",r],queryFn:()=>Le.getNotificationLogStats(r)}),v=At({mutationFn:()=>Le.clearNotificationLogs(30),onSuccess:b=>{n(b.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:b=>{n(`Failed to clear logs: ${b.message}`,"error")}}),y=b=>{const x=new Date(b),w=new Date().getTime()-x.getTime();return w<6e4?"Just now":w<36e5?`${Math.floor(w/6e4)}m ago`:w<864e5?`${Math.floor(w/36e5)}h ago`:x.toLocaleDateString()+" "+x.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})};return u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:u.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col",children:[u.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx(KN,{className:"w-5 h-5 text-bambu-green"}),u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),u.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),m&&u.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:u.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[u.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",u.jsx("span",{className:"text-white font-medium",children:m.total})," notifications"]}),u.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[u.jsx(Ss,{className:"w-4 h-4"}),m.success_count," sent"]}),m.failure_count>0&&u.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[u.jsx(ud,{className:"w-4 h-4"}),m.failure_count," failed"]})]})}),u.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[u.jsxs("select",{value:r,onChange:b=>i(Number(b.target.value)),className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:[u.jsx("option",{value:1,children:"Last 24 hours"}),u.jsx("option",{value:7,children:"Last 7 days"}),u.jsx("option",{value:30,children:"Last 30 days"}),u.jsx("option",{value:90,children:"Last 90 days"})]}),u.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:o,onChange:b=>l(b.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),u.jsx("div",{className:"flex-1"}),u.jsxs(Ue,{size:"sm",variant:"secondary",onClick:()=>h(),disabled:g,children:[g?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(qs,{className:"w-4 h-4"}),"Refresh"]}),u.jsxs(Ue,{size:"sm",variant:"secondary",onClick:()=>v.mutate(),disabled:v.isPending,className:"text-red-400 hover:text-red-300",children:[v.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Qn,{className:"w-4 h-4"}),"Clear Old"]})]}),u.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:d?u.jsx("div",{className:"flex justify-center py-12",children:u.jsx(Ot,{className:"w-6 h-6 text-bambu-green animate-spin"})}):c&&c.length>0?u.jsx("div",{className:"space-y-2",children:c.map(b=>u.jsx(zVe,{log:b,isExpanded:s===b.id,onToggle:()=>a(s===b.id?null:b.id),formatDate:y},b.id))}):u.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[u.jsx(KN,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),u.jsx("p",{className:"text-sm",children:o?"No failed notifications":"No notifications logged"})]})})]})})}function zVe({log:t,isExpanded:e,onToggle:n,formatDate:r}){return u.jsxs("div",{className:`border rounded-lg overflow-hidden transition-colors ${t.success?"border-bambu-dark-tertiary bg-bambu-dark/30":"border-red-500/30 bg-red-500/5"}`,children:[u.jsxs("button",{className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-bambu-dark/50 transition-colors",onClick:n,children:[t.success?u.jsx(Ss,{className:"w-4 h-4 text-bambu-green shrink-0"}):u.jsx(ud,{className:"w-4 h-4 text-red-400 shrink-0"}),u.jsx("span",{className:`text-xs font-medium ${UVe[t.event_type]||"text-bambu-gray"}`,children:IVe[t.event_type]||t.event_type}),u.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&u.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),u.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?u.jsx(cw,{className:"w-4 h-4 text-bambu-gray shrink-0"}):u.jsx(Qf,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&u.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),u.jsx("p",{className:"text-sm text-white",children:t.title})]}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),u.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),u.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),u.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[u.jsxs("span",{children:["Provider: ",t.provider_type]}),u.jsxs("span",{children:["Time: ",new Date(t.created_at).toLocaleString()]})]})]})]})}const S_=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:u.jsx(dP,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:u.jsx(ff,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:u.jsx(rc,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:u.jsx(Nx,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:u.jsx(ko,{className:"w-4 h-4"}),default:!1,description:"Printer info (access codes excluded)"},{id:"filaments",labelKey:"backup.categories.filaments",defaultLabel:"Filament Inventory",icon:u.jsx(Zoe,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:u.jsx(Df,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:u.jsx(eP,{className:"w-4 h-4"}),default:!1,description:"All print data + files (3MF, thumbnails, photos)"}];function BVe({onClose:t,onExport:e}){const{t:n}=sw(),[r,i]=E.useState(()=>{const v={};return S_.forEach(y=>{v[y.id]=y.default}),v}),[s,a]=E.useState(!1),[o,l]=E.useState(!1);E.useEffect(()=>{const v=y=>{y.key==="Escape"&&t()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[t]);const c=v=>{i(y=>({...y,[v]:!y[v]}))},d=()=>{const v={};S_.forEach(y=>{v[y.id]=!0}),i(v)},h=()=>{const v={};S_.forEach(y=>{v[y.id]=!1}),i(v)},g=Object.values(r).filter(Boolean).length,m=async()=>{l(!0);try{await e({...r,access_codes:s&&r.printers})}finally{l(!1)}};return u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:o?void 0:t,children:u.jsx(Lt,{className:"w-full max-w-lg",onClick:v=>v.stopPropagation(),children:u.jsxs(Ft,{className:"p-0",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:u.jsx(va,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-lg font-semibold text-white",children:n("backup.exportTitle",{defaultValue:"Export Backup"})}),u.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.selectCategories",{defaultValue:"Select data to include"})})]})]}),u.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("div",{className:"flex gap-2 px-4 pt-4",children:[u.jsx("button",{onClick:d,disabled:o,className:"text-sm text-bambu-green hover:text-bambu-green/80 disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectAll",{defaultValue:"Select All"})}),u.jsx("span",{className:"text-bambu-gray",children:"|"}),u.jsx("button",{onClick:h,disabled:o,className:"text-sm text-bambu-gray hover:text-white disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectNone",{defaultValue:"Select None"})})]}),u.jsx("div",{className:`p-4 space-y-2 max-h-[400px] overflow-y-auto ${o?"opacity-50 pointer-events-none":""}`,children:S_.map(v=>u.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-colors ${r[v.id]?"bg-bambu-green/10 border border-bambu-green/30":"bg-bambu-dark hover:bg-bambu-dark-tertiary border border-transparent"}`,children:[u.jsx("input",{type:"checkbox",checked:r[v.id],onChange:()=>c(v.id),disabled:o,className:"w-4 h-4 rounded border-bambu-gray bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),u.jsx("div",{className:`${r[v.id]?"text-bambu-green":"text-bambu-gray"}`,children:v.icon}),u.jsxs("div",{className:"flex-1",children:[u.jsx("div",{className:"text-white text-sm font-medium",children:n(v.labelKey,{defaultValue:v.defaultLabel})}),u.jsx("div",{className:"text-xs text-bambu-gray",children:v.description})]})]},v.id))}),r.archives&&u.jsx("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:u.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[u.jsx(eP,{className:"w-4 h-4 text-yellow-500 mt-0.5 flex-shrink-0"}),u.jsxs("div",{className:"text-yellow-200 dark:text-yellow-200 text-yellow-700",children:[u.jsx("span",{className:"font-medium",children:"ZIP file will be created."}),u.jsx("span",{className:"text-yellow-600 dark:text-yellow-200/70",children:" Includes all 3MF files, thumbnails, timelapses, and photos. This may take a while and result in a large file."})]})]})}),r.printers&&u.jsxs("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-start gap-2",children:[u.jsx(y9,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),u.jsxs("div",{children:[u.jsx("p",{className:"text-sm font-medium text-white",children:"Include Access Codes"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"For transferring to another machine"})]})]}),u.jsx(er,{checked:s,onChange:a})]}),s&&u.jsx("div",{className:"mt-2 p-2 rounded bg-orange-500/10 border border-orange-500/30",children:u.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[u.jsx(ws,{className:"w-3 h-3 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),u.jsx("span",{className:"text-orange-700 dark:text-orange-200",children:"Access codes will be included in plain text. Keep this backup file secure!"})]})})]}),u.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[u.jsx("span",{className:"text-sm text-bambu-gray",children:n("backup.selectedCount",{count:g,defaultValue:`${g} categories selected`})}),u.jsxs("div",{className:"flex gap-3",children:[u.jsx(Ue,{variant:"secondary",onClick:t,disabled:o,children:n("common.cancel",{defaultValue:"Cancel"})}),u.jsx(Ue,{onClick:m,disabled:g===0||o,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50 disabled:cursor-not-allowed min-w-[100px]",children:o?u.jsxs(u.Fragment,{children:[u.jsx(Ot,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):u.jsxs(u.Fragment,{children:[u.jsx(va,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const kG={settings:"Settings",notification_providers:"Notification Providers",notification_templates:"Notification Templates",smart_plugs:"Smart Plugs",printers:"Printers",filaments:"Filaments",maintenance_types:"Maintenance Types",archives:"Archives"};function HVe({onClose:t,onRestore:e,onSuccess:n}){const[r,i]=E.useState("options"),[s,a]=E.useState(!1),[o,l]=E.useState(null),[c,d]=E.useState(null),[h,g]=E.useState(new Set),m=E.useRef(null);E.useEffect(()=>{const w=A=>{A.key==="Escape"&&r!=="restoring"&&t()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[t,r]);const v=w=>{const A=w.target.files?.[0];A&&l(A)},y=async()=>{if(o){i("restoring");try{const w=await e(o,s);d(w),i("result"),w.success&&n()}catch{d({success:!1,message:"Failed to restore backup. Please check the file format."}),i("result")}}},b=w=>{g(A=>{const T=new Set(A);return T.has(w)?T.delete(w):T.add(w),T})},x=c?.restored?Object.values(c.restored).reduce((w,A)=>w+A,0)+(c.files_restored||0):0,M=c?.total_skipped||0;return u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onMouseDown:w=>{w.target===w.currentTarget&&r!=="restoring"&&t()},children:u.jsx(Lt,{className:"w-full max-w-lg",children:u.jsxs(Ft,{className:"p-0",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:`p-2 rounded-full ${r==="result"&&c?.success?"bg-bambu-green/20 text-bambu-green":r==="result"&&!c?.success?"bg-red-500/20 text-red-500":"bg-blue-500/20 text-blue-500"}`,children:r==="result"&&c?.success?u.jsx(Ss,{className:"w-5 h-5"}):r==="result"&&!c?.success?u.jsx(ws,{className:"w-5 h-5"}):u.jsx(Ka,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsxs("h3",{className:"text-lg font-semibold text-white",children:[r==="options"&&"Restore Backup",r==="restoring"&&"Restoring...",r==="result"&&(c?.success?"Restore Complete":"Restore Failed")]}),u.jsxs("p",{className:"text-sm text-bambu-gray",children:[r==="options"&&"Import settings from a backup file",r==="restoring"&&"Please wait while your data is being restored",r==="result"&&c?.message]})]})]}),r!=="restoring"&&u.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),r==="options"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"p-4 space-y-4",children:[u.jsxs("div",{children:[u.jsx("input",{ref:m,type:"file",accept:".json,.zip",className:"hidden",onChange:v}),u.jsx("button",{type:"button",onClick:()=>m.current?.click(),className:`w-full p-4 border-2 border-dashed rounded-lg transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:o?u.jsxs("div",{className:"flex items-center justify-center gap-2 text-bambu-green",children:[u.jsx(Ss,{className:"w-5 h-5"}),u.jsx("span",{className:"font-medium",children:o.name})]}):u.jsxs("div",{className:"flex flex-col items-center gap-2 text-bambu-gray",children:[u.jsx(Ka,{className:"w-8 h-8"}),u.jsx("span",{children:"Click to select backup file (.json or .zip)"})]})})]}),u.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:u.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[u.jsx(ws,{className:"w-4 h-4 text-blue-500 dark:text-blue-400 mt-0.5 flex-shrink-0"}),u.jsxs("div",{className:"text-blue-700 dark:text-blue-200",children:[u.jsx("p",{className:"font-medium mb-1",children:"How duplicate handling works:"}),u.jsxs("ul",{className:"text-blue-600 dark:text-blue-200/80 space-y-1 text-xs",children:[u.jsxs("li",{children:[u.jsx("strong",{children:"Printers"})," - matched by serial number"]}),u.jsxs("li",{children:[u.jsx("strong",{children:"Smart Plugs"})," - matched by IP address"]}),u.jsxs("li",{children:[u.jsx("strong",{children:"Notification Providers"})," - matched by name"]}),u.jsxs("li",{children:[u.jsx("strong",{children:"Filaments"})," - matched by name + type + brand"]}),u.jsxs("li",{children:[u.jsx("strong",{children:"Archives"})," - matched by content hash (always skipped)"]}),u.jsxs("li",{children:[u.jsx("strong",{children:"Settings & Templates"})," - always overwritten"]})]})]})]})}),u.jsx("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsxs("p",{className:"text-white font-medium flex items-center gap-2",children:[s?u.jsx(qs,{className:"w-4 h-4 text-orange-400"}):u.jsx(i1,{className:"w-4 h-4 text-bambu-gray"}),s?"Update existing items":"Add new items only"]}),u.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:s?"Replace data for items that already exist on this system":"Items that already exist on this system will not be changed"})]}),u.jsx(er,{checked:s,onChange:a})]})}),s&&u.jsx("div",{className:"p-3 rounded-lg bg-orange-500/10 border border-orange-500/30",children:u.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[u.jsx(ws,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),u.jsxs("div",{className:"text-orange-700 dark:text-orange-200",children:[u.jsx("span",{className:"font-medium",children:"Caution:"})," Overwriting will replace your current configurations with data from the backup. Printer access codes are never overwritten for security."]})]})})]}),u.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[u.jsx(Ue,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),u.jsxs(Ue,{type:"button",onClick:y,disabled:!o,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[u.jsx(Ka,{className:"w-4 h-4 mr-2"}),"Restore"]})]})]}),r==="restoring"&&u.jsxs("div",{className:"p-8 flex flex-col items-center gap-4",children:[u.jsx(Ot,{className:"w-12 h-12 text-bambu-green animate-spin"}),u.jsx("p",{className:"text-bambu-gray",children:"Processing backup file..."})]}),r==="result"&&c&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"p-4 space-y-4 max-h-[400px] overflow-y-auto",children:[u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{className:"p-3 rounded-lg bg-bambu-green/10 border border-bambu-green/30",children:[u.jsx("div",{className:"text-2xl font-bold text-bambu-green",children:x}),u.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Restored"})]}),u.jsxs("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[u.jsx("div",{className:"text-2xl font-bold text-yellow-500",children:M}),u.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Skipped"})]})]}),c.restored&&Object.entries(c.restored).some(([,w])=>w>0)&&u.jsxs("div",{className:"space-y-2",children:[u.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[u.jsx(Ss,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),u.jsxs("div",{className:"space-y-1",children:[Object.entries(c.restored).filter(([,w])=>w>0).map(([w,A])=>u.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[u.jsx("span",{className:"text-white",children:kG[w]||w}),u.jsx("span",{className:"text-bambu-green font-medium",children:A})]},w)),(c.files_restored||0)>0&&u.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[u.jsx("span",{className:"text-white",children:"Files (3MF, thumbnails, etc.)"}),u.jsx("span",{className:"text-bambu-green font-medium",children:c.files_restored})]})]})]}),c.skipped&&Object.entries(c.skipped).some(([,w])=>w>0)&&u.jsxs("div",{className:"space-y-2",children:[u.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[u.jsx(i1,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),u.jsx("div",{className:"space-y-1",children:Object.entries(c.skipped).filter(([,w])=>w>0).map(([w,A])=>{const T=c.skipped_details?.[w]||[],R=h.has(w);return u.jsxs("div",{children:[u.jsxs("button",{onClick:()=>T.length>0&&b(w),className:`w-full flex items-center justify-between text-sm p-2 rounded bg-bambu-dark ${T.length>0?"hover:bg-bambu-dark-tertiary cursor-pointer":""}`,children:[u.jsxs("span",{className:"text-white flex items-center gap-2",children:[kG[w]||w,T.length>0&&(R?u.jsx(cw,{className:"w-3 h-3"}):u.jsx(Qf,{className:"w-3 h-3"}))]}),u.jsx("span",{className:"text-yellow-500 font-medium",children:A})]}),R&&T.length>0&&u.jsxs("div",{className:"mt-1 ml-4 p-2 rounded bg-bambu-dark-tertiary text-xs text-bambu-gray space-y-1",children:[T.slice(0,10).map((C,I)=>u.jsx("div",{children:C},I)),T.length>10&&u.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",T.length-10," more"]})]})]},w)})})]}),x===0&&M===0&&u.jsx("div",{className:"p-4 text-center text-bambu-gray",children:"No data was found to restore in the backup file."})]}),u.jsx("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:u.jsx(Ue,{onClick:t,children:"Close"})})]})]})})})}async function $Ve(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function VVe(t){const e=await fetch("/api/v1/settings/spoolman",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok)throw new Error("Failed to save Spoolman settings");return e.json()}function GVe(){const t=Nn(),[e,n]=E.useState(!1),[r,i]=E.useState(""),[s,a]=E.useState("auto"),[o,l]=E.useState(!1),[c,d]=E.useState("all"),[h,g]=E.useState(!1),{data:m,isLoading:v}=Mt({queryKey:["spoolman-settings"],queryFn:$Ve}),{data:y,isLoading:b,refetch:x}=Mt({queryKey:["spoolman-status"],queryFn:Le.getSpoolmanStatus,refetchInterval:3e4}),{data:M}=Mt({queryKey:["printers"],queryFn:Le.getPrinters});E.useEffect(()=>{m&&(n(m.spoolman_enabled==="true"),i(m.spoolman_url||""),a(m.spoolman_sync_mode||"auto"),g(!0))},[m]),E.useEffect(()=>{if(!h||!m)return;if(m.spoolman_enabled==="true"!==e||(m.spoolman_url||"")!==r||(m.spoolman_sync_mode||"auto")!==s){const W=setTimeout(()=>{w.mutate()},500);return()=>clearTimeout(W)}},[e,r,s,h]);const w=At({mutationFn:()=>VVe({spoolman_enabled:e?"true":"false",spoolman_url:r,spoolman_sync_mode:s}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),l(!0),setTimeout(()=>l(!1),2e3)}}),A=At({mutationFn:Le.connectSpoolman,onSuccess:()=>{x()}}),T=At({mutationFn:Le.disconnectSpoolman,onSuccess:()=>{x()}}),R=At({mutationFn:Le.syncAllPrintersAms,onSuccess:j=>{j.success}}),C=At({mutationFn:j=>Le.syncPrinterAms(j),onSuccess:j=>{j.success}}),I=()=>{c==="all"?R.mutate():C.mutate(c)},N=R.isPending||C.isPending,D=c==="all"?R.data:C.data,z=c==="all"?R.isSuccess:C.isSuccess;return v?u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(dF,{className:"w-5 h-5 text-bambu-green"}),u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),u.jsx(Ft,{children:u.jsx("div",{className:"flex justify-center py-8",children:u.jsx(Ot,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(dF,{className:"w-5 h-5 text-bambu-green"}),u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),w.isPending&&u.jsx(Ot,{className:"w-4 h-4 text-bambu-green animate-spin"}),o&&u.jsx(Qp,{className:"w-4 h-4 text-bambu-green"})]})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Enable Spoolman"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:e,onChange:j=>n(j.target.checked),className:"sr-only peer"}),u.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),u.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:j=>i(j.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none disabled:opacity-50"}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),u.jsxs("select",{value:s,onChange:j=>a(j.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:[u.jsx("option",{value:"auto",children:"Automatic"}),u.jsx("option",{value:"manual",children:"Manual Only"})]}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:s==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),e&&u.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center justify-between mb-3",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),b?u.jsx(Ot,{className:"w-4 h-4 text-bambu-gray animate-spin"}):y?.connected?u.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[u.jsx(Qp,{className:"w-4 h-4"}),"Connected"]}):u.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[u.jsx(Qt,{className:"w-4 h-4"}),"Disconnected"]})]}),u.jsx("div",{className:"flex gap-2",children:y?.connected?u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>T.mutate(),disabled:T.isPending,children:[T.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Noe,{className:"w-4 h-4"}),"Disconnect"]}):u.jsxs(Ue,{size:"sm",onClick:()=>A.mutate(),disabled:A.isPending||!r,children:[A.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Roe,{className:"w-4 h-4"}),"Connect"]})})]}),A.isError&&u.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:A.error.message}),y?.connected&&u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("div",{className:"relative flex-1",children:[u.jsxs("select",{value:c,onChange:j=>d(j.target.value==="all"?"all":Number(j.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[u.jsx("option",{value:"all",children:"All Printers"}),M?.map(j=>u.jsx("option",{value:j.id,children:j.name},j.id))]}),u.jsx(Qf,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:I,disabled:N,children:[N?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(qs,{className:"w-4 h-4"}),"Sync"]})]})]}),z&&D&&u.jsx("div",{className:`mt-2 p-2 rounded text-sm ${D.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:D.success?`Synced ${D.synced_count} trays successfully`:`Synced ${D.synced_count} trays with ${D.errors.length} errors`})]})]})]})}function WVe(){const t=Nn(),{t:e,i18n:n}=sw(),{showToast:r}=Di(),[i,s]=E.useState(null),[a,o]=E.useState(!1),[l,c]=E.useState(null),[d,h]=E.useState(!1),[g,m]=E.useState(null),[v,y]=E.useState(null),[b,x]=E.useState(!1),[M,w]=E.useState(k9()),[A,T]=E.useState("general"),[R,C]=E.useState(!1),[I,N]=E.useState(!1),[D,z]=E.useState(null),[j,W]=E.useState(!1),[P,$]=E.useState(!1),K=X=>{w(X),vce(X)},G=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:Z,isLoading:Q}=Mt({queryKey:["settings"],queryFn:Le.getSettings}),{data:ee,isLoading:H}=Mt({queryKey:["smart-plugs"],queryFn:Le.getSmartPlugs}),{data:q,isLoading:te}=Mt({queryKey:["smart-plugs-energy",ee?.map(X=>X.id)],queryFn:async()=>{if(!ee||ee.length===0)return null;const X=await Promise.all(ee.filter(ze=>ze.enabled).map(async ze=>{try{const at=await Le.getSmartPlugStatus(ze.id);return{plug:ze,status:at}}catch{return{plug:ze,status:null}}}));let me=0,ve=0,ge=0,Ke=0,Ie=0;for(const{status:ze}of X)ze?.reachable&&ze.energy&&(Ie++,ze.energy.power!=null&&(me+=ze.energy.power),ze.energy.today!=null&&(ve+=ze.energy.today),ze.energy.yesterday!=null&&(ge+=ze.energy.yesterday),ze.energy.total!=null&&(Ke+=ze.energy.total));return{totalPower:me,totalToday:ve,totalYesterday:ge,totalLifetime:Ke,reachableCount:Ie,totalPlugs:ee.filter(ze=>ze.enabled).length}},enabled:A==="plugs"&&!!ee&&ee.length>0,refetchInterval:A==="plugs"?1e4:!1}),{data:ae,isLoading:xe}=Mt({queryKey:["notification-providers"],queryFn:Le.getNotificationProviders}),{data:re}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),{data:pe,isLoading:Ce}=Mt({queryKey:["notification-templates"],queryFn:Le.getNotificationTemplates}),{data:fe}=Mt({queryKey:["ffmpeg-status"],queryFn:Le.checkFfmpeg}),{data:Se}=Mt({queryKey:["version"],queryFn:Le.getVersion}),{data:Re,refetch:ue,isRefetching:ct}=Mt({queryKey:["updateCheck"],queryFn:Le.checkForUpdates,staleTime:300*1e3}),{data:B,refetch:F}=Mt({queryKey:["updateStatus"],queryFn:Le.getUpdateStatus,refetchInterval:X=>{const me=X.state.data;return me?.status==="downloading"||me?.status==="installing"?1e3:!1}}),ie=At({mutationFn:Le.applyUpdate,onSuccess:()=>{F()}}),[V,J]=E.useState(null),le=At({mutationFn:Le.testAllNotificationProviders,onSuccess:X=>{J(X),t.invalidateQueries({queryKey:["notification-providers"]}),X.failed===0?r(`All ${X.tested} providers tested successfully!`,"success"):r(`${X.success}/${X.tested} providers succeeded`,X.failed>0?"error":"success")},onError:X=>{r(`Failed to test providers: ${X.message}`,"error")}}),Ae=At({mutationFn:async X=>{if(!ee)return{success:0,failed:0};const me=ee.filter(ge=>ge.enabled),ve=await Promise.all(me.map(async ge=>{try{return await Le.controlSmartPlug(ge.id,X),{success:!0}}catch{return{success:!1}}}));return{success:ve.filter(ge=>ge.success).length,failed:ve.filter(ge=>!ge.success).length}},onSuccess:(X,me)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),X.failed===0?r(`All ${X.success} plugs turned ${me}`,"success"):r(`${X.success} plugs turned ${me}, ${X.failed} failed`,"error")},onError:X=>{r(`Failed: ${X.message}`,"error")}}),Ee=E.useRef(null),se=E.useRef(!0);E.useEffect(()=>{Z&&!i&&(s(Z),setTimeout(()=>{se.current=!1},100))},[Z,i]);const U=At({mutationFn:Le.updateSettings,onSuccess:X=>{t.setQueryData(["settings"],X),t.invalidateQueries({queryKey:["archiveStats"]}),r("Settings saved","success")},onError:X=>{r(`Failed to save: ${X.message}`,"error")}});E.useEffect(()=>{if(!(se.current||!i||!Z||!(Z.auto_archive!==i.auto_archive||Z.save_thumbnails!==i.save_thumbnails||Z.capture_finish_photo!==i.capture_finish_photo||Z.default_filament_cost!==i.default_filament_cost||Z.currency!==i.currency||Z.energy_cost_per_kwh!==i.energy_cost_per_kwh||Z.energy_tracking_mode!==i.energy_tracking_mode||Z.check_updates!==i.check_updates||Z.notification_language!==i.notification_language||Z.ams_humidity_good!==i.ams_humidity_good||Z.ams_humidity_fair!==i.ams_humidity_fair||Z.ams_temp_good!==i.ams_temp_good||Z.ams_temp_fair!==i.ams_temp_fair||Z.date_format!==i.date_format||Z.time_format!==i.time_format||Z.default_printer_id!==i.default_printer_id)))return Ee.current&&clearTimeout(Ee.current),Ee.current=setTimeout(()=>{U.mutate(i)},500),()=>{Ee.current&&clearTimeout(Ee.current)}},[i,Z,U]);const L=E.useCallback((X,me)=>{s(ve=>ve?{...ve,[X]:me}:null)},[]);return Q||!i?u.jsx("div",{className:"p-8 flex justify-center",children:u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u.jsxs("div",{className:"p-8",children:[u.jsxs("div",{className:"mb-8",children:[u.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),u.jsx("p",{className:"text-bambu-gray",children:"Configure Bambuddy"})]}),u.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[u.jsx("button",{onClick:()=>T("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${A==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:"General"}),u.jsxs("button",{onClick:()=>T("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${A==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[u.jsx(Nx,{className:"w-4 h-4"}),"Smart Plugs",ee&&ee.length>0&&u.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:ee.length})]}),u.jsxs("button",{onClick:()=>T("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${A==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[u.jsx(ff,{className:"w-4 h-4"}),"Notifications",ae&&ae.length>0&&u.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:ae.length})]})]}),A==="general"&&u.jsxs("div",{className:"flex gap-8",children:[u.jsxs("div",{className:"space-y-6 flex-1 max-w-xl",children:[u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsxs("div",{children:[u.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[u.jsx(e1,{className:"w-4 h-4 inline mr-1"}),e("settings.language")]}),u.jsx("select",{value:n.language,onChange:X=>n.changeLanguage(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:WU.map(X=>u.jsxs("option",{value:X.code,children:[X.nativeName," (",X.name,")"]},X.code))}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.languageDescription")})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("settings.defaultView")}),u.jsx("select",{value:M,onChange:X=>K(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:A_.map(X=>u.jsx("option",{value:X.to,children:e(X.labelKey)},X.id))}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.defaultViewDescription")})]}),u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),u.jsxs("select",{value:i.date_format||"system",onChange:X=>L("date_format",X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"system",children:"System Default"}),u.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),u.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),u.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),u.jsxs("select",{value:i.time_format||"system",onChange:X=>L("time_format",X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"system",children:"System Default"}),u.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),u.jsx("option",{value:"24h",children:"24-hour (15:30)"})]})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),u.jsxs("select",{value:i.default_printer_id??"",onChange:X=>L("default_printer_id",X.target.value?Number(X.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"",children:"No default (ask each time)"}),re?.map(X=>u.jsx("option",{value:X.id,children:X.name},X.id))]}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Sidebar order"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:G,children:[u.jsx(X0,{className:"w-4 h-4"}),"Reset"]})]})]})]}),u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Auto-archive prints"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:i.auto_archive,onChange:X=>L("auto_archive",X.target.checked),className:"sr-only peer"}),u.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Save thumbnails"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:i.save_thumbnails,onChange:X=>L("save_thumbnails",X.target.checked),className:"sr-only peer"}),u.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Capture finish photo"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:i.capture_finish_photo,onChange:X=>L("capture_finish_photo",X.target.checked),className:"sr-only peer"}),u.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),i.capture_finish_photo&&fe&&!fe.installed&&u.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[u.jsx(ws,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),u.jsxs("div",{className:"text-sm",children:[u.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),u.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",u.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",u.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]}),u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),u.jsx("input",{type:"number",step:"0.01",min:"0",value:i.default_filament_cost,onChange:X=>L("default_filament_cost",parseFloat(X.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),u.jsxs("select",{value:i.currency,onChange:X=>L("currency",X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"USD",children:"USD ($)"}),u.jsx("option",{value:"EUR",children:"EUR (€)"}),u.jsx("option",{value:"GBP",children:"GBP (£)"}),u.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),u.jsx("option",{value:"JPY",children:"JPY (¥)"}),u.jsx("option",{value:"CNY",children:"CNY (¥)"}),u.jsx("option",{value:"CAD",children:"CAD ($)"}),u.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),u.jsx("input",{type:"number",step:"0.01",min:"0",value:i.energy_cost_per_kwh,onChange:X=>L("energy_cost_per_kwh",parseFloat(X.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),u.jsxs("select",{value:i.energy_tracking_mode||"total",onChange:X=>L("energy_tracking_mode",X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"print",children:"Prints Only"}),u.jsx("option",{value:"total",children:"Total Consumption"})]}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]})]}),u.jsxs("div",{className:"space-y-6 flex-1 max-w-md",children:[u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Configure color thresholds for AMS humidity and temperature indicators."}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-white",children:[u.jsx(Bae,{className:"w-4 h-4 text-blue-400"}),u.jsx("span",{className:"font-medium",children:"Humidity"})]}),u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (green) ≤"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"number",min:"0",max:"100",value:i.ams_humidity_good??40,onChange:X=>L("ams_humidity_good",parseInt(X.target.value)||40),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),u.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"number",min:"0",max:"100",value:i.ams_humidity_fair??60,onChange:X=>L("ams_humidity_fair",parseInt(X.target.value)||60),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),u.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (bad)"})]}),u.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center gap-2 text-white",children:[u.jsx(Ip,{className:"w-4 h-4 text-orange-400"}),u.jsx("span",{className:"font-medium",children:"Temperature"})]}),u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:i.ams_temp_good??28,onChange:X=>L("ams_temp_good",parseFloat(X.target.value)||28),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),u.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:i.ams_temp_fair??35,onChange:X=>L("ams_temp_fair",parseFloat(X.target.value)||35),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),u.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (hot)"})]})]})]}),u.jsx(GVe,{})]}),u.jsxs("div",{className:"space-y-6 flex-1 max-w-sm",children:[u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Check for updates"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:i.check_updates,onChange:X=>L("check_updates",X.target.checked),className:"sr-only peer"}),u.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),u.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[u.jsxs("div",{className:"flex items-center justify-between mb-2",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Current version"}),u.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",Se?.version||"..."]})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>ue(),disabled:ct,children:[ct?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(qs,{className:"w-4 h-4"}),"Check now"]})]}),Re?.update_available?u.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[u.jsxs("div",{className:"flex items-start justify-between",children:[u.jsxs("div",{children:[u.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",Re.latest_version]}),Re.release_name&&Re.release_name!==Re.latest_version&&u.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:Re.release_name}),Re.release_notes&&u.jsx("p",{className:"text-sm text-bambu-gray mt-2 whitespace-pre-line line-clamp-3",children:Re.release_notes})]}),Re.release_url&&u.jsx("a",{href:Re.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:u.jsx(vc,{className:"w-4 h-4"})})]}),B?.status==="downloading"||B?.status==="installing"?u.jsxs("div",{className:"mt-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[u.jsx(Ot,{className:"w-4 h-4 animate-spin"}),u.jsx("span",{children:B.message})]}),u.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:u.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${B.progress}%`}})})]}):B?.status==="complete"?u.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:B.message}):B?.status==="error"?u.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:B.error||B.message}):u.jsxs(Ue,{className:"mt-3",onClick:()=>ie.mutate(),disabled:ie.isPending,children:[ie.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(va,{className:"w-4 h-4"}),"Install Update"]})]}):Re?.error?u.jsxs("div",{className:"mt-2 p-2 bg-red-500/10 border border-red-500/30 rounded text-sm text-red-400",children:["Failed to check for updates: ",Re.error]}):Re&&!Re.update_available?u.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Backup Data"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Export settings, providers, printers, and more"})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>W(!0),children:[u.jsx(va,{className:"w-4 h-4"}),"Export"]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Restore Backup"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Import settings from a backup file with duplicate handling options"})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>$(!0),children:[u.jsx(Ka,{className:"w-4 h-4"}),"Restore"]})]}),u.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Clear Notification Logs"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Delete notification logs older than 30 days"})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>C(!0),children:[u.jsx(Qn,{className:"w-4 h-4"}),"Clear"]})]})}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Reset UI Preferences"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Reset sidebar order, theme, view modes, and layout preferences. Printers, archives, and settings are not affected."})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>N(!0),children:[u.jsx(Qn,{className:"w-4 h-4"}),"Reset"]})]})]})]})]})]}),A==="plugs"&&u.jsxs("div",{className:"max-w-4xl",children:[u.jsxs("div",{className:"flex items-start justify-between mb-6",children:[u.jsxs("div",{children:[u.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[u.jsx(Nx,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),u.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Connect Tasmota-based smart plugs to automate power control and track energy usage for your printers."})]}),u.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[ee&&ee.filter(X=>X.enabled).length>1&&u.jsxs(u.Fragment,{children:[u.jsxs(Ue,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>z("on"),disabled:Ae.isPending,title:"Turn all plugs on",children:[Ae.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(dd,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),u.jsxs(Ue,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>z("off"),disabled:Ae.isPending,title:"Turn all plugs off",children:[Ae.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(cP,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),u.jsxs(Ue,{className:"whitespace-nowrap",onClick:()=>{c(null),o(!0)},children:[u.jsx(li,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),ee&&ee.length>0&&u.jsxs(Lt,{className:"mb-6",children:[u.jsx(Yl,{children:u.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[u.jsx(s0,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",te&&u.jsx(Ot,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),u.jsx(Ft,{children:q?u.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[u.jsx(s0,{className:"w-3 h-3"}),"Current Power"]}),u.jsxs("div",{className:"text-xl font-bold text-white",children:[q.totalPower.toFixed(1),u.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),u.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[q.reachableCount,"/",q.totalPlugs," plugs online"]})]}),u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[u.jsx(Wr,{className:"w-3 h-3"}),"Today"]}),u.jsxs("div",{className:"text-xl font-bold text-white",children:[q.totalToday.toFixed(2),u.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),i&&i.energy_cost_per_kwh>0&&u.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(q.totalToday*i.energy_cost_per_kwh).toFixed(2)," ",i.currency]})]}),u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[u.jsx(Xle,{className:"w-3 h-3"}),"Yesterday"]}),u.jsxs("div",{className:"text-xl font-bold text-white",children:[q.totalYesterday.toFixed(2),u.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),i&&i.energy_cost_per_kwh>0&&u.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(q.totalYesterday*i.energy_cost_per_kwh).toFixed(2)," ",i.currency]})]}),u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[u.jsx(XN,{className:"w-3 h-3"}),"Total"]}),u.jsxs("div",{className:"text-xl font-bold text-white",children:[q.totalLifetime.toFixed(1),u.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),i&&i.energy_cost_per_kwh>0&&u.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(q.totalLifetime*i.energy_cost_per_kwh).toFixed(2)," ",i.currency]})]})]}):te?null:u.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),H?u.jsx("div",{className:"flex justify-center py-12",children:u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin"})}):ee&&ee.length>0?u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ee.map(X=>u.jsx(RVe,{plug:X,onEdit:me=>{c(me),o(!0)}},X.id))}):u.jsx(Lt,{children:u.jsx(Ft,{className:"py-12",children:u.jsxs("div",{className:"text-center text-bambu-gray",children:[u.jsx(Nx,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),u.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No smart plugs configured"}),u.jsx("p",{className:"text-sm mb-4",children:"Add a Tasmota-based smart plug to track energy usage and automate power control."}),u.jsxs(Ue,{onClick:()=>{c(null),o(!0)},children:[u.jsx(li,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),A==="notifications"&&u.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center justify-between mb-4",children:[u.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[u.jsx(ff,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Ue,{size:"sm",variant:"secondary",onClick:()=>x(!0),children:[u.jsx(KN,{className:"w-4 h-4"}),"Log"]}),ae&&ae.length>0&&u.jsxs(Ue,{size:"sm",variant:"secondary",onClick:()=>{J(null),le.mutate()},disabled:le.isPending,children:[le.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(uP,{className:"w-4 h-4"}),"Test All"]}),u.jsxs(Ue,{size:"sm",onClick:()=>{m(null),h(!0)},children:[u.jsx(li,{className:"w-4 h-4"}),"Add"]})]})]}),u.jsx(Lt,{className:"mb-4",children:u.jsx(Ft,{className:"py-3",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white text-sm font-medium",children:e("settings.notificationLanguage")}),u.jsx("p",{className:"text-xs text-bambu-gray",children:e("settings.notificationLanguageDescription")})]}),u.jsx("select",{value:i.notification_language||"en",onChange:X=>L("notification_language",X.target.value),className:"px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:WU.map(X=>u.jsx("option",{value:X.code,children:X.nativeName},X.code))})]})})}),V&&u.jsx(Lt,{className:"mb-4",children:u.jsxs(Ft,{className:"py-3",children:[u.jsxs("div",{className:"flex items-center justify-between mb-2",children:[u.jsx("span",{className:"text-sm font-medium text-white",children:"Test Results"}),u.jsx("button",{onClick:()=>J(null),className:"text-bambu-gray hover:text-white text-xs",children:"Dismiss"})]}),u.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[u.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[u.jsx(Ss,{className:"w-4 h-4"}),V.success," passed"]}),V.failed>0&&u.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[u.jsx(ud,{className:"w-4 h-4"}),V.failed," failed"]})]}),V.results.filter(X=>!X.success).length>0&&u.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:V.results.filter(X=>!X.success).map(X=>u.jsxs("div",{className:"text-xs text-red-400",children:[u.jsxs("span",{className:"font-medium",children:[X.provider_name,":"]})," ",X.message]},X.provider_id))})]})}),xe?u.jsx("div",{className:"flex justify-center py-12",children:u.jsx(Ot,{className:"w-6 h-6 text-bambu-green animate-spin"})}):ae&&ae.length>0?u.jsx("div",{className:"space-y-3",children:ae.map(X=>u.jsx(OVe,{provider:X,onEdit:me=>{m(me),h(!0)}},X.id))}):u.jsx(Lt,{children:u.jsx(Ft,{className:"py-8",children:u.jsxs("div",{className:"text-center text-bambu-gray",children:[u.jsx(ff,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),u.jsx("p",{className:"text-sm font-medium text-white mb-2",children:"No providers configured"}),u.jsx("p",{className:"text-xs mb-3",children:"Add a provider to receive alerts."}),u.jsxs(Ue,{size:"sm",onClick:()=>{m(null),h(!0)},children:[u.jsx(li,{className:"w-4 h-4"}),"Add Provider"]})]})})})]}),u.jsxs("div",{children:[u.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[u.jsx(rc,{className:"w-5 h-5 text-bambu-green"}),"Message Templates"]}),u.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Customize notification messages for each event."}),Ce?u.jsx("div",{className:"flex justify-center py-8",children:u.jsx(Ot,{className:"w-6 h-6 text-bambu-green animate-spin"})}):pe&&pe.length>0?u.jsx("div",{className:"space-y-2",children:pe.map(X=>u.jsx(Lt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>y(X),children:u.jsx(Ft,{className:"py-2.5 px-3",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("p",{className:"text-white font-medium text-sm truncate",children:X.name}),u.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:X.title_template})]}),u.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:me=>{me.stopPropagation(),y(X)},children:u.jsx(lP,{className:"w-4 h-4 text-bambu-gray"})})]})})},X.id))}):u.jsx(Lt,{children:u.jsx(Ft,{className:"py-8",children:u.jsxs("div",{className:"text-center text-bambu-gray",children:[u.jsx(rc,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),u.jsx("p",{className:"text-sm",children:"No templates available. Restart the backend to seed default templates."})]})})})]})]}),a&&u.jsx(PVe,{plug:l,onClose:()=>{o(!1),c(null)}}),d&&u.jsx(LVe,{provider:g,onClose:()=>{h(!1),m(null)}}),v&&u.jsx(jVe,{template:v,onClose:()=>y(null)}),b&&u.jsx(FVe,{onClose:()=>x(!1)}),R&&u.jsx(Zi,{title:"Clear Notification Logs",message:"This will permanently delete all notification logs older than 30 days. This action cannot be undone.",confirmText:"Clear Logs",variant:"warning",onConfirm:async()=>{C(!1);try{const X=await Le.clearNotificationLogs(30);r(X.message,"success")}catch{r("Failed to clear logs","error")}},onCancel:()=>C(!1)}),I&&u.jsx(Zi,{title:"Reset UI Preferences",message:"This will reset all UI preferences to defaults: sidebar order, theme, dashboard layout, view modes, and sorting preferences. Your printers, archives, and server settings will NOT be affected. The page will reload after clearing.",confirmText:"Reset Preferences",variant:"default",onConfirm:()=>{N(!1),localStorage.clear(),r("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>N(!1)}),D&&u.jsx(Zi,{title:`Turn All Plugs ${D==="on"?"On":"Off"}`,message:`This will turn ${D==="on"?"ON":"OFF"} all ${ee?.filter(X=>X.enabled).length||0} enabled smart plugs. ${D==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${D==="on"?"On":"Off"}`,variant:D==="off"?"danger":"warning",onConfirm:()=>{const X=D;z(null),Ae.mutate(X)},onCancel:()=>z(null)}),j&&u.jsx(BVe,{onClose:()=>W(!1),onExport:async X=>{W(!1);try{const{blob:me,filename:ve}=await Le.exportBackup(X),ge=URL.createObjectURL(me),Ke=document.createElement("a");Ke.href=ge,Ke.download=ve,Ke.click(),URL.revokeObjectURL(ge),r("Backup downloaded","success")}catch{r("Failed to create backup","error")}}}),P&&u.jsx(HVe,{onClose:()=>$(!1),onRestore:async(X,me)=>await Le.importBackup(X,me),onSuccess:()=>{t.invalidateQueries()}})]})}const gee=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},qVe=t=>t.startsWith("HH")?"HF":"S",XVe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},BR=t=>{const e=["High Flow_","High Flow ","Standard_","Standard ","HF_","HF ","S_","S "];for(const r of e)if(t.startsWith(r))return t.slice(r.length);const n=t.indexOf("_");return n>0?t.slice(n+1):t};function RN({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:s,note:a}){const o=qVe(t.nozzle_id),l=t.nozzle_diameter,c=()=>{r&&s?s():e()};return u.jsxs("div",{className:"flex items-center gap-2",children:[r&&u.jsx("button",{onClick:s,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?u.jsx(Pf,{className:"w-4 h-4 text-bambu-green"}):u.jsx(em,{className:"w-4 h-4"})}),u.jsxs("button",{onClick:c,className:`flex-1 text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors ${i?"ring-1 ring-bambu-green":""}`,children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:gee(t.k_value)}),u.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),a&&u.jsx("span",{title:"Has note",children:u.jsx(M9,{className:"w-3 h-3 text-yellow-500"})}),u.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[o," ",l]})]}),a&&u.jsxs("div",{className:"text-xs mt-0.5 truncate text-yellow-500/70",title:a,children:["Note: ",a.length>50?a.substring(0,50)+"...":a]})]}),!r&&n&&u.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:u.jsx(Jp,{className:"w-4 h-4"})})]})}function PN({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:s="",initialNoteKey:a=null,onClose:o,onSave:l,onSaveNote:c}){const{showToast:d}=Di(),[h,g]=E.useState(t?.name||""),[m,v]=E.useState(t?.k_value?gee(t.k_value):"0.020"),[y,b]=E.useState(t?.filament_id||""),[x,M]=E.useState(t?.nozzle_id?XVe(t.nozzle_id):"HH00"),[w,A]=E.useState(t?.nozzle_diameter||n),[T,R]=E.useState(t?[t.extruder_id]:i?[0,1]:[0]),[C,I]=E.useState(!1),[N,D]=E.useState({current:0,total:0}),[z,j]=E.useState(s),W=fr.useMemo(()=>{const ee=new Map;for(const H of r)if(H.filament_id&&!ee.has(H.filament_id)){const q=BR(H.name||"");ee.set(H.filament_id,{id:H.filament_id,name:q||H.filament_id})}return Array.from(ee.values()).sort((H,q)=>H.name.localeCompare(q.name))},[r]),P=At({mutationFn:ee=>(console.log("[KProfile] Calling API..."),Le.setKProfile(e,ee)),onSuccess:ee=>{if(console.log("[KProfile] Save success:",ee),d("K-profile saved"),c&&z!==s){let H;z===""&&a?H=a:t&&t.slot_id>0?H=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:H=`name_${h}_${y}`,c(H,z)}I(!0),setTimeout(()=>{I(!1),l()},2500)},onError:ee=>{console.error("[KProfile] Save error:",ee),d(ee.message,"error"),I(!1)}}),$=At({mutationFn:ee=>(console.log("[KProfile] Deleting profile..."),Le.deleteKProfile(e,ee)),onSuccess:ee=>{console.log("[KProfile] Delete success:",ee),d("K-profile deleted"),I(!0),setTimeout(()=>{I(!1),o()},4e3)},onError:ee=>{console.error("[KProfile] Delete error:",ee),d(ee.message,"error"),I(!1)}}),[K,G]=E.useState(!1),Z=()=>{t&&$.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id,setting_id:t.setting_id})},Q=async ee=>{if(ee.preventDefault(),i&&!t&&T.length===0){d("Please select at least one extruder","error");return}const H=parseFloat(m).toFixed(6),q=`${x}-${w}`;if(t||T.length===1){const ae={name:h,k_value:H,filament_id:y,nozzle_id:q,nozzle_diameter:w,extruder_id:t?t.extruder_id:T[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",ae),P.mutate(ae);return}I(!0),D({current:1,total:T.length});const te=T.map(ae=>({name:h,k_value:H,filament_id:y,nozzle_id:q,nozzle_diameter:w,extruder_id:ae,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${te.length} profiles in batch:`,te);try{if(await Le.setKProfilesBatch(e,te),d(`K-profile saved to ${T.length} extruders`),c&&z){const ae=`name_${h}_${y}`;c(ae,z)}}catch(ae){console.error("[KProfile] Failed to save batch:",ae),d("Failed to save K-profiles","error"),I(!1),D({current:0,total:0});return}D({current:T.length,total:T.length}),setTimeout(()=>{I(!1),D({current:0,total:0}),l()},3e3)};return u.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[u.jsxs(Lt,{className:"w-full max-w-md relative",children:[C&&u.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),u.jsx("p",{className:"text-white font-medium",children:N.total>1?`Saving to extruder ${N.current}/${N.total}...`:"Syncing with printer..."}),u.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),u.jsxs(Ft,{className:"p-0",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),u.jsx("button",{onClick:o,className:"text-bambu-gray hover:text-white transition-colors",disabled:C,children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("form",{onSubmit:Q,className:"p-4 space-y-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),u.jsx("input",{type:"text",value:h,onChange:ee=>g(ee.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,placeholder:"My PLA Profile",required:!t})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),u.jsx("input",{type:"text",inputMode:"decimal",value:m,onChange:ee=>{const H=ee.target.value;(H===""||/^\d*\.?\d*$/.test(H))&&v(H)},onBlur:ee=>{const H=parseFloat(ee.target.value);isNaN(H)||v((Math.trunc(H*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:"0.020",required:!0}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Typical range: 0.01 - 0.06 for PLA, 0.02 - 0.10 for PETG"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),u.jsxs("select",{value:y,onChange:ee=>{const H=ee.target.value;if(b(H),!t&&H&&!h){const q=W.find(te=>te.id===H);q&&g(`${x==="HH00"?"HF":"S"} ${q.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!t,children:[u.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&u.jsx("option",{value:t.filament_id,children:W.find(ee=>ee.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&W.map(ee=>u.jsx("option",{value:ee.id,children:ee.name},ee.id))]}),!t&&W.length===0&&u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),u.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),u.jsxs("select",{value:x,onChange:ee=>{const H=ee.target.value;if(M(H),!t&&y&&!h){const q=W.find(te=>te.id===y);q&&g(`${H==="HS00"?"HF":"S"} ${q.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[u.jsx("option",{value:"HH00",children:"High Flow"}),u.jsx("option",{value:"HS00",children:"Standard"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),u.jsxs("select",{value:w,onChange:ee=>A(ee.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[u.jsx("option",{value:"0.2",children:"0.2mm"}),u.jsx("option",{value:"0.4",children:"0.4mm"}),u.jsx("option",{value:"0.6",children:"0.6mm"}),u.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?u.jsx("div",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white opacity-60",children:t.extruder_id===1?"Left":"Right"}):u.jsxs("div",{className:"flex gap-4",children:[u.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:T.includes(1),onChange:ee=>{ee.target.checked?R([...T,1]):R(T.filter(H=>H!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),u.jsx("span",{className:"text-white",children:"Left"})]}),u.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:T.includes(0),onChange:ee=>{ee.target.checked?R([...T,0]):R(T.filter(H=>H!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),u.jsx("span",{className:"text-white",children:"Right"})]})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),u.jsx("textarea",{value:z,onChange:ee=>j(ee.target.value),placeholder:"Add notes about this profile...",rows:2,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none resize-none"}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Notes are saved in Bambuddy, not on the printer"})]}),u.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&u.jsx(Ue,{type:"button",variant:"secondary",onClick:()=>G(!0),disabled:$.isPending||C,className:"text-red-500 hover:bg-red-500/10",children:$.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Qn,{className:"w-4 h-4"})}),u.jsx(Ue,{type:"button",variant:"secondary",onClick:o,disabled:C,className:"flex-1",children:"Cancel"}),u.jsxs(Ue,{type:"submit",disabled:P.isPending||C,className:"flex-1",children:[P.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(sP,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),K&&u.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:u.jsx(Lt,{className:"w-full max-w-sm",children:u.jsxs(Ft,{className:"p-6",children:[u.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[u.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:u.jsx(Qn,{className:"w-5 h-5 text-red-500"})}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),u.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",u.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),u.jsxs("div",{className:"flex gap-3",children:[u.jsx(Ue,{variant:"secondary",onClick:()=>G(!1),className:"flex-1",children:"Cancel"}),u.jsxs(Ue,{onClick:()=>{G(!1),Z()},disabled:$.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[$.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Qn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const w_={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function KVe(){const{showToast:t}=Di(),[e,n]=E.useState(null),[r,i]=E.useState(()=>localStorage.getItem(w_.NOZZLE_DIAMETER)||"0.4"),[s,a]=E.useState(null),[o,l]=E.useState(!1),[c,d]=E.useState(null),[h,g]=E.useState(""),[m,v]=E.useState("all"),[y,b]=E.useState("all"),[x,M]=E.useState(()=>localStorage.getItem(w_.SORT_OPTION)||"name"),[w,A]=E.useState(!1),[T,R]=E.useState(new Set),[C,I]=E.useState(!1),[N,D]=E.useState(!1),z=V=>`${V.slot_id}_${V.extruder_id}`;E.useEffect(()=>{localStorage.setItem(w_.NOZZLE_DIAMETER,r)},[r]),E.useEffect(()=>{localStorage.setItem(w_.SORT_OPTION,x)},[x]);const{data:j,isLoading:W}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),{data:P,isLoading:$,isFetching:K,error:G,refetch:Z}=Mt({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const V=await Le.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",V?.profiles?.length||0,"profiles"),V},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:Q}=Mt({queryKey:["kprofiles",e,"0.4"],queryFn:()=>Le.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:ee,refetch:H}=Mt({queryKey:["kprofile-notes",e],queryFn:()=>Le.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),q=G?.message?.includes("not connected");E.useEffect(()=>{if(!e&&j&&j.length>0){const V=j.find(J=>J.is_active);V&&n(V.id)}},[e,j]),E.useEffect(()=>{if(e){const V=setTimeout(()=>{Z()},150);return()=>clearTimeout(V)}},[e,r]);const te=j?.filter(V=>V.is_active)||[],ae=fr.useMemo(()=>P?.profiles?P.profiles.filter(J=>{const le=h.toLowerCase(),Ae=!le||J.name.toLowerCase().includes(le)||J.filament_id.toLowerCase().includes(le),Ee=m==="all"||m==="left"&&J.extruder_id===1||m==="right"&&J.extruder_id===0,se=y==="all"||y==="hf"&&J.nozzle_id.startsWith("HH")||y==="s"&&J.nozzle_id.startsWith("HS");return Ae&&Ee&&se}).sort((J,le)=>{switch(x){case"k_value":return parseFloat(J.k_value)-parseFloat(le.k_value);case"filament":return BR(J.name).localeCompare(BR(le.name));case"name":default:return J.name.localeCompare(le.name)}}):[],[P?.profiles,h,m,y,x]),xe=j?.find(V=>V.id===e),re=xe?.nozzle_count===2;E.useEffect(()=>{const V=J=>{J.target instanceof HTMLInputElement||J.target instanceof HTMLTextAreaElement||J.target instanceof HTMLSelectElement||s||o||c||(J.key==="r"||J.key==="R"?(J.preventDefault(),Z()):J.key==="n"||J.key==="N"?(J.preventDefault(),l(!0)):J.key==="Escape"&&w&&(J.preventDefault(),A(!1),R(new Set)))};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[s,o,c,w,Z]);const pe=E.useCallback(()=>{if(!P?.profiles||P.profiles.length===0){t("No profiles to export","error");return}const V={version:1,exported_at:new Date().toISOString(),printer:xe?.name||"Unknown",nozzle_diameter:r,profiles:P.profiles.map(Ee=>({name:Ee.name,k_value:Ee.k_value,filament_id:Ee.filament_id,nozzle_id:Ee.nozzle_id,nozzle_diameter:Ee.nozzle_diameter,extruder_id:Ee.extruder_id}))},J=new Blob([JSON.stringify(V,null,2)],{type:"application/json"}),le=URL.createObjectURL(J),Ae=document.createElement("a");Ae.href=le,Ae.download=`kprofiles_${xe?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae),URL.revokeObjectURL(le),t(`Exported ${P.profiles.length} profiles`)},[P?.profiles,xe,r,t]),Ce=E.useCallback(()=>{const V=document.createElement("input");V.type="file",V.accept=".json",V.onchange=async J=>{const le=J.target.files?.[0];if(le)try{const Ae=await le.text(),Ee=JSON.parse(Ae);if(!Ee.profiles||!Array.isArray(Ee.profiles)){t("Invalid file format","error");return}let se=0;for(const U of Ee.profiles)if(!(!U.name||!U.k_value||!U.filament_id))try{await Le.setKProfile(e,{name:U.name,k_value:parseFloat(U.k_value).toFixed(6),filament_id:U.filament_id,nozzle_id:U.nozzle_id||`HH00-${r}`,nozzle_diameter:U.nozzle_diameter||r,extruder_id:U.extruder_id??0,slot_id:0}),se++,await new Promise(L=>setTimeout(L,500))}catch(L){console.error("Failed to import profile:",U.name,L)}t(`Imported ${se} of ${Ee.profiles.length} profiles`),Z()}catch(Ae){console.error("Import error:",Ae),t("Failed to parse import file","error")}},V.click()},[e,r,t,Z]),fe=E.useCallback(V=>{R(J=>{const le=new Set(J);return le.has(V)?le.delete(V):le.add(V),le})},[]),Se=E.useCallback(()=>{R(new Set(ae.map(V=>z(V))))},[ae,z]),Re=E.useCallback(()=>{T.size!==0&&I(!0)},[T.size]),ue=E.useCallback(async()=>{const V=ae.filter(le=>T.has(z(le)));D(!0);let J=0;for(const le of V)try{await Le.deleteKProfile(e,{slot_id:le.slot_id,extruder_id:le.extruder_id,nozzle_id:le.nozzle_id,nozzle_diameter:le.nozzle_diameter,filament_id:le.filament_id,setting_id:le.setting_id}),J++,await new Promise(Ae=>setTimeout(Ae,300))}catch(Ae){console.error("Failed to delete profile:",le.name,Ae)}t(`Deleted ${J} profiles`),D(!1),I(!1),A(!1),R(new Set),Z()},[e,T,ae,t,Z,z]),ct=E.useCallback(V=>{const J=[];return V.setting_id&&J.push(V.setting_id),J.push(`slot_${V.slot_id}_${V.filament_id}_${V.extruder_id}`),J.push(`name_${V.name}_${V.filament_id}`),J},[]),B=E.useCallback(async(V,J)=>{if(e)try{await Le.setKProfileNote(e,V,J),H()}catch(le){console.error("Failed to save note:",le),t("Failed to save note","error")}},[e,H,t]),F=E.useCallback(V=>{if(!ee?.notes)return{note:"",key:null};const J=ct(V);for(const le of J)if(ee.notes[le])return{note:ee.notes[le],key:le};return{note:"",key:null}},[ee,ct]),ie=E.useCallback(V=>F(V).note,[F]);return W?u.jsx("div",{className:"flex justify-center py-12",children:u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!j||j.length===0?u.jsx(Lt,{children:u.jsxs(Ft,{className:"py-12 text-center",children:[u.jsx(No,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),u.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),u.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):te.length===0?u.jsx(Lt,{children:u.jsxs(Ft,{className:"py-12 text-center",children:[u.jsx(ko,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),u.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),u.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):u.jsxs(u.Fragment,{children:[K&&!$&&u.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[u.jsx(Ot,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),u.jsx("p",{className:"text-white font-medium",children:"Loading K-Profiles..."})]}),u.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[u.jsxs("div",{className:"flex-1 min-w-48",children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),u.jsx("select",{value:e||"",onChange:V=>n(parseInt(V.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:te.map(V=>u.jsx("option",{value:V.id,children:V.name},V.id))})]}),u.jsxs("div",{className:"w-32",children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),u.jsxs("select",{value:r,onChange:V=>i(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"0.2",children:"0.2mm"}),u.jsx("option",{value:"0.4",children:"0.4mm"}),u.jsx("option",{value:"0.6",children:"0.6mm"}),u.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs(Ue,{variant:"secondary",onClick:()=>Z(),disabled:K,children:[u.jsx(qs,{className:`w-4 h-4 ${K?"animate-spin":""}`}),"Refresh"]}),u.jsxs(Ue,{onClick:()=>l(!0),children:[u.jsx(li,{className:"w-4 h-4"}),"Add Profile"]})]})]}),u.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[u.jsxs("div",{className:"flex-1 min-w-48 relative",children:[u.jsx(Zu,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),u.jsx("input",{type:"text",value:h,onChange:V=>g(V.target.value),placeholder:"Search by name or filament...",className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),re&&u.jsx("div",{className:"w-36",children:u.jsxs("select",{value:m,onChange:V=>v(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"all",children:"All Extruders"}),u.jsx("option",{value:"left",children:"Left Only"}),u.jsx("option",{value:"right",children:"Right Only"})]})}),u.jsx("div",{className:"w-32",children:u.jsxs("select",{value:y,onChange:V=>b(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"all",children:"All Flow"}),u.jsx("option",{value:"hf",children:"HF Only"}),u.jsx("option",{value:"s",children:"S Only"})]})}),u.jsx("div",{className:"w-32",children:u.jsxs("select",{value:x,onChange:V=>M(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"name",children:"Sort: Name"}),u.jsx("option",{value:"k_value",children:"Sort: K-Value"}),u.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),u.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[u.jsxs(Ue,{variant:"secondary",onClick:pe,disabled:!P?.profiles?.length,title:"Export profiles to JSON",children:[u.jsx(va,{className:"w-4 h-4"}),"Export"]}),u.jsxs(Ue,{variant:"secondary",onClick:Ce,title:"Import profiles from JSON",children:[u.jsx(Ka,{className:"w-4 h-4"}),"Import"]}),u.jsx("div",{className:"flex-1"}),w?u.jsxs(u.Fragment,{children:[u.jsxs(Ue,{variant:"secondary",onClick:Se,title:"Select all visible profiles",children:[u.jsx(Pf,{className:"w-4 h-4"}),"Select All"]}),u.jsxs(Ue,{variant:"secondary",onClick:Re,disabled:T.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${T.size} selected profiles`,children:[u.jsx(Qn,{className:"w-4 h-4"}),"Delete (",T.size,")"]}),u.jsxs(Ue,{variant:"secondary",onClick:()=>{A(!1),R(new Set)},children:[u.jsx(Qt,{className:"w-4 h-4"}),"Cancel"]})]}):u.jsxs(Ue,{variant:"secondary",onClick:()=>A(!0),disabled:!ae.length,title:"Enter selection mode for bulk delete",children:[u.jsx(Pf,{className:"w-4 h-4"}),"Select"]})]}),$?u.jsx("div",{className:"flex justify-center py-12",children:u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin"})}):q?u.jsx(Lt,{children:u.jsxs(Ft,{className:"py-12 text-center",children:[u.jsx(fP,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),u.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),u.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),u.jsxs(Ue,{variant:"secondary",onClick:()=>Z(),children:[u.jsx(qs,{className:"w-4 h-4"}),"Retry"]})]})}):ae.length>0?re?u.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[u.jsxs("div",{children:[u.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),u.jsx("div",{className:"space-y-1",children:ae.filter(V=>V.extruder_id===1).map(V=>u.jsx(RN,{profile:V,onEdit:()=>a(V),onCopy:()=>d(V),selectionMode:w,isSelected:T.has(z(V)),onToggleSelect:()=>fe(z(V)),note:ie(V)},z(V)))})]}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),u.jsx("div",{className:"space-y-1",children:ae.filter(V=>V.extruder_id===0).map(V=>u.jsx(RN,{profile:V,onEdit:()=>a(V),onCopy:()=>d(V),selectionMode:w,isSelected:T.has(z(V)),onToggleSelect:()=>fe(z(V)),note:ie(V)},z(V)))})]})]}):u.jsx("div",{className:"space-y-1",children:ae.map(V=>u.jsx(RN,{profile:V,onEdit:()=>a(V),onCopy:()=>d(V),selectionMode:w,isSelected:T.has(z(V)),onToggleSelect:()=>fe(z(V)),note:ie(V)},z(V)))}):h||m!=="all"||y!=="all"?u.jsx(Lt,{children:u.jsxs(Ft,{className:"py-12 text-center",children:[u.jsx(Zu,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),u.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),u.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):u.jsx(Lt,{children:u.jsxs(Ft,{className:"py-12 text-center",children:[u.jsx(sP,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),u.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),u.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",r,"mm nozzle"]}),u.jsxs(Ue,{onClick:()=>l(!0),children:[u.jsx(li,{className:"w-4 h-4"}),"Create First Profile"]})]})}),s&&e&&(()=>{const{note:V,key:J}=F(s);return u.jsx(PN,{profile:s,printerId:e,nozzleDiameter:r,existingProfiles:Q?.profiles||P?.profiles,isDualNozzle:re,initialNote:V,initialNoteKey:J,onSaveNote:B,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),a(null),Z()},onSave:()=>{a(null),Z()}})})(),o&&e&&u.jsx(PN,{printerId:e,nozzleDiameter:r,existingProfiles:Q?.profiles||P?.profiles,isDualNozzle:re,onSaveNote:B,onClose:()=>{l(!1),Z()},onSave:()=>{l(!1),Z()}}),c&&e&&u.jsx(PN,{printerId:e,nozzleDiameter:r,existingProfiles:Q?.profiles||P?.profiles,isDualNozzle:re,onSaveNote:B,profile:{...c,slot_id:0,name:`${c.name} (Copy)`},onClose:()=>{d(null),Z()},onSave:()=>{d(null),Z()}}),C&&u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:u.jsx(Lt,{className:"w-full max-w-sm",children:u.jsxs(Ft,{className:"p-6",children:[u.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[u.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:u.jsx(Qn,{className:"w-5 h-5 text-red-500"})}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profiles"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),u.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",u.jsx("span",{className:"text-white font-medium",children:T.size})," selected profiles from the printer?"]}),u.jsxs("div",{className:"flex gap-3",children:[u.jsx(Ue,{variant:"secondary",onClick:()=>I(!1),disabled:N,className:"flex-1",children:"Cancel"}),u.jsxs(Ue,{onClick:ue,disabled:N,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[N?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Qn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function OL(t,e){const n=`${t} ${e||""}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,s=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),a=s?(s[1]||s[2])+"mm":null,o=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),l=o?o[1]+"mm":null,c=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),d=c?c[1].toUpperCase():null;return{printer:i,nozzle:a,layerHeight:l,filamentType:d}}function V0(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function YVe(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4),s=Math.floor(r/36e5),a=Math.floor(r/864e5);return i<1?"Just now":i<60?`${i}m ago`:s<24?`${s}h ago`:a<7?`${a}d ago`:e.toLocaleDateString()}function ZVe({onSuccess:t}){const{showToast:e}=Di(),[n,r]=E.useState("email"),[i,s]=E.useState(""),[a,o]=E.useState(""),[l,c]=E.useState(""),[d,h]=E.useState(""),[g,m]=E.useState("global"),v=At({mutationFn:()=>Le.cloudLogin(i,a,g),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):w.needs_verification?(e("Verification code sent to your email"),r("code")):e(w.message,"error")},onError:w=>e(w.message,"error")}),y=At({mutationFn:()=>Le.cloudVerify(i,l),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):e(w.message,"error")},onError:w=>e(w.message,"error")}),b=At({mutationFn:()=>Le.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:w=>e(w.message,"error")}),x=w=>{w.preventDefault(),n==="email"?v.mutate():n==="code"?y.mutate():n==="token"&&b.mutate()},M=v.isPending||y.isPending||b.isPending;return u.jsx(Lt,{className:"max-w-md mx-auto",children:u.jsxs(Ft,{children:[u.jsxs("div",{className:"text-center mb-6",children:[u.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:u.jsx(tP,{className:"w-6 h-6 text-bambu-green"})}),u.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),u.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),u.jsxs("form",{onSubmit:x,className:"space-y-4",children:[n==="email"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),u.jsx("input",{type:"email",value:i,onChange:w=>s(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),u.jsx("input",{type:"password",value:a,onChange:w=>o(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),u.jsxs("select",{value:g,onChange:w=>m(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"global",children:"Global"}),u.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),u.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),u.jsx("input",{type:"text",value:l,onChange:w=>c(w.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest font-mono focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),n==="token"&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),u.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),u.jsx("textarea",{value:d,onChange:w=>h(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:4,required:!0})]}),u.jsxs("div",{className:"flex gap-2",children:[n==="code"&&u.jsx(Ue,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),u.jsxs(Ue,{type:"submit",disabled:M,className:"flex-1",children:[M?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(pF,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&u.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:u.jsxs("button",{type:"button",onClick:()=>r("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[u.jsx(y9,{className:"w-4 h-4"}),"Use access token instead"]})}),n==="token"&&u.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:u.jsxs("button",{type:"button",onClick:()=>r("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[u.jsx(pF,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function Sp({label:t,value:e,options:n,onChange:r}){const[i,s]=E.useState(!1),a=n.find(o=>o.value===e);return u.jsxs("div",{className:"relative",children:[u.jsxs("button",{onClick:()=>s(!i),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors",children:[u.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),u.jsx("span",{children:a?.label||"All"}),u.jsx(Qf,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),u.jsx("div",{className:"absolute top-full left-0 mt-1 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 py-1 max-h-60 overflow-y-auto",children:n.map(o=>u.jsxs("button",{onClick:()=>{r(o.value),s(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${e===o.value?"text-bambu-green":"text-white"}`,children:[u.jsx("span",{children:o.label}),o.count!==void 0&&u.jsx("span",{className:"text-bambu-gray text-xs",children:o.count})]},o.value))})]})]})}function QVe(){const[t,e]=E.useState(!1);E.useEffect(()=>{const r=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?u.jsx("button",{onClick:n,className:"fixed bottom-6 right-6 p-3 bg-bambu-green hover:bg-bambu-green-light text-white rounded-full shadow-lg shadow-bambu-green/25 transition-all z-40","aria-label":"Scroll to top",children:u.jsx(Yp,{className:"w-5 h-5"})}):null}function DN({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:s,compareDisabled:a}){const o=OL(t.name),l=V0(t.setting_id);return u.jsxs("div",{className:"flex items-center gap-2 group",children:[u.jsx("button",{onClick:e,disabled:a,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${i?"bg-blue-500/20 border border-blue-500/50":a?"bg-bambu-dark/50 opacity-40 cursor-not-allowed":"bg-bambu-dark hover:bg-bambu-dark-tertiary"} ${r&&!a?"cursor-pointer":""}`,children:u.jsxs("div",{className:"flex items-center gap-2",children:[i&&s!==void 0&&u.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium",children:s+1}),!i&&l&&u.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"My preset (editable)"}),u.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),o.filamentType&&t.type==="filament"&&u.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.filamentType}),o.layerHeight&&t.type==="process"&&u.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.layerHeight}),o.printer&&u.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.printer})]})}),u.jsx("button",{onClick:c=>{c.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:"Duplicate",children:u.jsx(Jp,{className:"w-4 h-4"})})]})}function HR(t,e=0){const n=" ".repeat(e);if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string"){if(t.includes("\\n")||t.includes(` + `).concat(A.x,",").concat(A.y),R=vr(t.id)?N0("recharts-radial-line-"):t.id;return E.createElement("text",tc({},r,{dominantBaseline:"central",className:An("recharts-radial-bar-label",a)}),E.createElement("defs",null,E.createElement("path",{id:R,d:T})),E.createElement("textPath",{xlinkHref:"#".concat(R)},n))},K5e=(t,e,n)=>{var{cx:r,cy:i,innerRadius:s,outerRadius:a,startAngle:o,endAngle:l}=t,c=(o+l)/2;if(n==="outside"){var{x:d,y:h}=Xr(r,i,a+e,c);return{x:d,y:h,textAnchor:d>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var g=(s+a)/2,{x:m,y:v}=Xr(r,i,g,c);return{x:m,y:v,textAnchor:"middle",verticalAnchor:"middle"}},kR=t=>"cx"in t&&Tt(t.cx),Y5e=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,s;n!=null&&!kR(n)&&(s=n);var{x:a,y:o,upperWidth:l,lowerWidth:c,height:d}=e,h=a,g=a+(l-c)/2,m=(h+g)/2,v=(l+c)/2,y=h+l/2,b=d>=0?1:-1,x=b*r,M=b>0?"end":"start",w=b>0?"start":"end",A=l>=0?1:-1,T=A*r,R=A>0?"end":"start",C=A>0?"start":"end";if(i==="top"){var I={x:h+l/2,y:o-x,textAnchor:"middle",verticalAnchor:M};return Dr(Dr({},I),s?{height:Math.max(o-s.y,0),width:l}:{})}if(i==="bottom"){var N={x:g+c/2,y:o+d+x,textAnchor:"middle",verticalAnchor:w};return Dr(Dr({},N),s?{height:Math.max(s.y+s.height-(o+d),0),width:c}:{})}if(i==="left"){var D={x:m-T,y:o+d/2,textAnchor:R,verticalAnchor:"middle"};return Dr(Dr({},D),s?{width:Math.max(D.x-s.x,0),height:d}:{})}if(i==="right"){var z={x:m+v+T,y:o+d/2,textAnchor:C,verticalAnchor:"middle"};return Dr(Dr({},z),s?{width:Math.max(s.x+s.width-z.x,0),height:d}:{})}var j=s?{width:v,height:d}:{};return i==="insideLeft"?Dr({x:m+T,y:o+d/2,textAnchor:C,verticalAnchor:"middle"},j):i==="insideRight"?Dr({x:m+v-T,y:o+d/2,textAnchor:R,verticalAnchor:"middle"},j):i==="insideTop"?Dr({x:h+l/2,y:o+x,textAnchor:"middle",verticalAnchor:w},j):i==="insideBottom"?Dr({x:g+c/2,y:o+d-x,textAnchor:"middle",verticalAnchor:M},j):i==="insideTopLeft"?Dr({x:h+T,y:o+x,textAnchor:C,verticalAnchor:w},j):i==="insideTopRight"?Dr({x:h+l-T,y:o+x,textAnchor:R,verticalAnchor:w},j):i==="insideBottomLeft"?Dr({x:g+T,y:o+d-x,textAnchor:C,verticalAnchor:M},j):i==="insideBottomRight"?Dr({x:g+c-T,y:o+d-x,textAnchor:R,verticalAnchor:M},j):i&&typeof i=="object"&&(Tt(i.x)||Sc(i.x))&&(Tt(i.y)||Sc(i.y))?Dr({x:a+us(i.x,v),y:o+us(i.y,d),textAnchor:"end",verticalAnchor:"end"},j):Dr({x:y,y:o+d/2,textAnchor:"middle",verticalAnchor:"middle"},j)},Z5e={angle:0,offset:5,zIndex:Kr.label,position:"middle",textBreakAll:!1};function Nu(t){var e=ei(t,Z5e),{viewBox:n,position:r,value:i,children:s,content:a,className:o="",textBreakAll:l,labelRef:c}=e,d=G5e(),h=xJ(),g=r==="center"?h:d??h,m,v,y;if(n==null?m=g:kR(n)?m=n:m=LY(n),!m||vr(i)&&vr(s)&&!E.isValidElement(a)&&typeof a!="function")return null;var b=Dr(Dr({},e),{},{viewBox:m});if(E.isValidElement(a)){var{labelRef:x}=b,M=U5e(b,I5e);return E.cloneElement(a,M)}if(typeof a=="function"){if(v=E.createElement(a,b),E.isValidElement(v))return v}else v=W5e(e);var w=Cs(e);if(kR(m)){if(r==="insideStart"||r==="insideEnd"||r==="end")return X5e(e,r,v,w,m);y=K5e(m,e.offset,e.position)}else y=Y5e(e,m);return E.createElement(Qs,{zIndex:e.zIndex},E.createElement(kM,tc({ref:c,className:An("recharts-label",o)},w,y,{textAnchor:P5e(w.textAnchor)?w.textAnchor:y.textAnchor,breakAll:l}),v))}Nu.displayName="Label";var Q5e=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?E.createElement(Nu,tc({key:"label-implicit"},r)):ul(t)?E.createElement(Nu,tc({key:"label-implicit",value:t},r)):E.isValidElement(t)?t.type===Nu?E.cloneElement(t,Dr({key:"label-implicit"},r)):E.createElement(Nu,tc({key:"label-implicit",content:t},r)):gL(t)?E.createElement(Nu,tc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?E.createElement(Nu,tc({},t,{key:"label-implicit"},r)):null};function J5e(t){var{label:e,labelRef:n}=t,r=xJ();return Q5e(e,r,n)||null}var xN={},bN={},DV;function eze(){return DV||(DV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(bN)),bN}var vN={},OV;function tze(){return OV||(OV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(vN)),vN}var LV;function nze(){return LV||(LV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eze(),n=tze(),r=VD();function i(s){if(r.isArrayLike(s))return e.last(n.toArray(s))}t.last=i})(xN)),xN}var yN,jV;function rze(){return jV||(jV=1,yN=nze().last),yN}var ize=rze();const sze=ro(ize);var aze=["valueAccessor"],oze=["dataKey","clockWise","id","textBreakAll","zIndex"];function qS(){return qS=Object.assign?Object.assign.bind():function(t){for(var e=1;eArray.isArray(t.value)?sze(t.value):t.value,bJ=E.createContext(void 0),vJ=bJ.Provider,yJ=E.createContext(void 0),uze=yJ.Provider;function dze(){return E.useContext(bJ)}function fze(){return E.useContext(yJ)}function W_(t){var{valueAccessor:e=cze}=t,n=IV(t,aze),{dataKey:r,clockWise:i,id:s,textBreakAll:a,zIndex:o}=n,l=IV(n,oze),c=dze(),d=fze(),h=c||d;return!h||!h.length?null:E.createElement(Qs,{zIndex:o??Kr.label},E.createElement(jr,{className:"recharts-label-list"},h.map((g,m)=>{var v,y=vr(r)?e(g,m):Yn(g&&g.payload,r),b=vr(s)?{}:{id:"".concat(s,"-").concat(m)};return E.createElement(Nu,qS({key:"label-".concat(m)},Cs(g),l,b,{fill:(v=n.fill)!==null&&v!==void 0?v:g.fill,parentViewBox:g.parentViewBox,value:y,textBreakAll:a,viewBox:g.viewBox,index:m,zIndex:0}))})))}W_.displayName="LabelList";function xL(t){var{label:e}=t;return e?e===!0?E.createElement(W_,{key:"labelList-implicit"}):E.isValidElement(e)||gL(e)?E.createElement(W_,{key:"labelList-implicit",content:e}):typeof e=="object"?E.createElement(W_,qS({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function RR(){return RR=Object.assign?Object.assign.bind():function(t){for(var e=1;e{var{cx:e,cy:n,r,className:i}=t,s=An("recharts-dot",i);return Tt(e)&&Tt(n)&&Tt(r)?E.createElement("circle",RR({},Xs(t),$D(t),{className:s,cx:e,cy:n,r})):null},SJ=t=>t.graphicalItems.polarItems,hze=We([pr,_b],FO),RM=We([SJ,_r,hze],zO),pze=We([RM],BO),PM=We([pze,NO],HO),mze=We([PM,_r,RM],VO);We([PM,_r,RM],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var s,a=Yn(r,(s=e.dataKey)!==null&&s!==void 0?s:i.dataKey);return{value:a,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:Yn(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var UV=()=>{},gze=We([PM,_r,RM,TM,pr],XO),xze=We([_r,WO,qO,UV,gze,UV,Sn,pr],KO),wJ=We([_r,Sn,PM,mze,yb,pr,xze],YO),bze=We([wJ,_r,Km],JO);We([_r,wJ,bze,pr],tL);var vze={radiusAxis:{},angleAxis:{}},MJ=Zs({name:"polarAxis",initialState:vze,reducers:{addRadiusAxis(t,e){t.radiusAxis[e.payload.id]=e.payload},removeRadiusAxis(t,e){delete t.radiusAxis[e.payload.id]},addAngleAxis(t,e){t.angleAxis[e.payload.id]=e.payload},removeAngleAxis(t,e){delete t.angleAxis[e.payload.id]}}}),{addRadiusAxis:v9e,removeRadiusAxis:y9e,addAngleAxis:_9e,removeAngleAxis:S9e}=MJ.actions,yze=MJ.reducer;function FV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function zV(t){for(var e=1;ee,bL=We([SJ,Mze],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),Eze=[],vL=(t,e,n)=>n?.length===0?Eze:n,EJ=We([NO,bL,vL],(t,e,n)=>{var{chartData:r}=t;if(e!=null){var i;if(e?.data!=null&&e.data.length>0?i=e.data:i=r,(!i||!i.length)&&n!=null&&(i=n.map(s=>zV(zV({},e.presentationProps),s.props))),i!=null)return i}}),Aze=We([EJ,bL,vL],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var s,a=Yn(r,e.nameKey,e.name),o;return n!=null&&(s=n[i])!==null&&s!==void 0&&(s=s.props)!==null&&s!==void 0&&s.fill?o=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?o=r.fill:o=e.fill,{value:Bm(a,e.dataKey),color:o,payload:r,type:e.legendType}})}),Tze=We([EJ,bL,vL,pi],(t,e,n,r)=>{if(!(e==null||t==null))return CBe({offset:r,pieSettings:e,displayedData:t,cells:n})}),_N={exports:{}},zn={};var BV;function Cze(){if(BV)return zn;BV=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),a=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),g=Symbol.for("react.view_transition"),m=Symbol.for("react.client.reference");function v(y){if(typeof y=="object"&&y!==null){var b=y.$$typeof;switch(b){case t:switch(y=y.type,y){case n:case i:case r:case l:case c:case g:return y;default:switch(y=y&&y.$$typeof,y){case a:case o:case h:case d:return y;case s:return y;default:return b}}case e:return b}}}return zn.ContextConsumer=s,zn.ContextProvider=a,zn.Element=t,zn.ForwardRef=o,zn.Fragment=n,zn.Lazy=h,zn.Memo=d,zn.Portal=e,zn.Profiler=i,zn.StrictMode=r,zn.Suspense=l,zn.SuspenseList=c,zn.isContextConsumer=function(y){return v(y)===s},zn.isContextProvider=function(y){return v(y)===a},zn.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},zn.isForwardRef=function(y){return v(y)===o},zn.isFragment=function(y){return v(y)===n},zn.isLazy=function(y){return v(y)===h},zn.isMemo=function(y){return v(y)===d},zn.isPortal=function(y){return v(y)===e},zn.isProfiler=function(y){return v(y)===i},zn.isStrictMode=function(y){return v(y)===r},zn.isSuspense=function(y){return v(y)===l},zn.isSuspenseList=function(y){return v(y)===c},zn.isValidElementType=function(y){return typeof y=="string"||typeof y=="function"||y===n||y===i||y===r||y===l||y===c||typeof y=="object"&&y!==null&&(y.$$typeof===h||y.$$typeof===d||y.$$typeof===a||y.$$typeof===s||y.$$typeof===o||y.$$typeof===m||y.getModuleId!==void 0)},zn.typeOf=v,zn}var HV;function Nze(){return HV||(HV=1,_N.exports=Cze()),_N.exports}var kze=Nze(),$V=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",VV=null,SN=null,AJ=t=>{if(t===VV&&Array.isArray(SN))return SN;var e=[];return E.Children.forEach(t,n=>{vr(n)||(kze.isFragment(n)?e=e.concat(AJ(n.props.children)):e.push(n))}),SN=e,VV=t,e};function yL(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>$V(i)):r=[$V(e)],AJ(t).forEach(i=>{var s=Wf(i,"type.displayName")||Wf(i,"type.name");s&&r.indexOf(s)!==-1&&n.push(i)}),n}var TJ=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,wN={},GV;function Rze(){return GV||(GV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){if(typeof n!="object"||n==null)return!1;if(Object.getPrototypeOf(n)===null)return!0;if(Object.prototype.toString.call(n)!=="[object Object]"){const i=n[Symbol.toStringTag];return i==null||!Object.getOwnPropertyDescriptor(n,Symbol.toStringTag)?.writable?!1:n.toString()===`[object ${i}]`}let r=n;for(;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(n)===r}t.isPlainObject=e})(wN)),wN}var MN,WV;function Pze(){return WV||(WV=1,MN=Rze().isPlainObject),MN}var Dze=Pze();const Oze=ro(Dze);function qV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function XV(t){for(var e=1;e{var s=n-r,a;return a="M ".concat(t,",").concat(e),a+="L ".concat(t+n,",").concat(e),a+="L ".concat(t+n-s/2,",").concat(e+i),a+="L ".concat(t+n-s/2-r,",").concat(e+i),a+="L ".concat(t,",").concat(e," Z"),a},Uze={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Fze=t=>{var e=ei(t,Uze),{x:n,y:r,upperWidth:i,lowerWidth:s,height:a,className:o}=e,{animationEasing:l,animationDuration:c,animationBegin:d,isUpdateAnimationActive:h}=e,g=E.useRef(null),[m,v]=E.useState(-1),y=E.useRef(i),b=E.useRef(s),x=E.useRef(a),M=E.useRef(n),w=E.useRef(r),A=mb(t,"trapezoid-");if(E.useEffect(()=>{if(g.current&&g.current.getTotalLength)try{var P=g.current.getTotalLength();P&&v(P)}catch{}},[]),n!==+n||r!==+r||i!==+i||s!==+s||a!==+a||i===0&&s===0||a===0)return null;var T=An("recharts-trapezoid",o);if(!h)return E.createElement("g",null,E.createElement("path",XS({},Cs(e),{className:T,d:KV(n,r,i,s,a)})));var R=y.current,C=b.current,I=x.current,N=M.current,D=w.current,z="0px ".concat(m===-1?1:m,"px"),j="".concat(m,"px 0px"),W=KY(["strokeDasharray"],c,l);return E.createElement(pb,{animationId:A,key:A,canBegin:m>0,duration:c,easing:l,isActive:h,begin:d},P=>{var $=lr(R,i,P),K=lr(C,s,P),G=lr(I,a,P),Z=lr(N,n,P),Q=lr(D,r,P);g.current&&(y.current=$,b.current=K,x.current=G,M.current=Z,w.current=Q);var ee=P>0?{transition:W,strokeDasharray:j}:{strokeDasharray:z};return E.createElement("path",XS({},Cs(e),{className:T,d:KV(Z,Q,$,K,G),ref:g,style:XV(XV({},ee),e.style)}))})},zze=["option","shapeType","propTransformer","activeClassName"];function Bze(t,e){if(t==null)return{};var n,r,i=Hze(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r{var r=nr();return(i,s)=>a=>{t?.(i,s,a),r(UQ({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},SL=t=>{var e=nr();return(n,r)=>i=>{t?.(n,r,i),e(oUe())}},wL=(t,e,n)=>{var r=nr();return(i,s)=>a=>{t?.(i,s,a),r(lUe({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function ML(t){var{tooltipEntrySettings:e}=t,n=nr(),r=hs(),i=E.useRef(null);return E.useLayoutEffect(()=>{r||(i.current===null?n(rUe(e)):i.current!==e&&n(iUe({prev:i.current,next:e})),i.current=e)},[e,n,r]),E.useLayoutEffect(()=>()=>{i.current&&(n(sUe(i.current)),i.current=null)},[n]),null}function NJ(t){var{legendPayload:e}=t,n=nr(),r=hs(),i=E.useRef(null);return E.useLayoutEffect(()=>{r||(i.current===null?n(VY(e)):i.current!==e&&n(GY({prev:i.current,next:e})),i.current=e)},[n,r,e]),E.useLayoutEffect(()=>()=>{i.current&&(n(WY(i.current)),i.current=null)},[n]),null}function Kze(t){var{legendPayload:e}=t,n=nr(),r=Ct(Sn),i=E.useRef(null);return E.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(VY(e)):i.current!==e&&n(GY({prev:i.current,next:e})),i.current=e)},[n,r,e]),E.useLayoutEffect(()=>()=>{i.current&&(n(WY(i.current)),i.current=null)},[n]),null}var EN,Yze=()=>{var[t]=E.useState(()=>N0("uid-"));return t},Zze=(EN=Cne.useId)!==null&&EN!==void 0?EN:Yze;function kJ(t,e){var n=Zze();return e||(t?"".concat(t,"-").concat(n):n)}var Qze=E.createContext(void 0),EL=t=>{var{id:e,type:n,children:r}=t,i=kJ("recharts-".concat(n),e);return E.createElement(Qze.Provider,{value:i},r(i))},Jze={cartesianItems:[],polarItems:[]},RJ=Zs({name:"graphicalItems",initialState:Jze,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:dr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=To(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:dr()},removeCartesianGraphicalItem:{reducer(t,e){var n=To(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:dr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:dr()},removePolarGraphicalItem:{reducer(t,e){var n=To(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:dr()}}}),{addCartesianGraphicalItem:eBe,replaceCartesianGraphicalItem:tBe,removeCartesianGraphicalItem:nBe,addPolarGraphicalItem:rBe,removePolarGraphicalItem:iBe}=RJ.actions,sBe=RJ.reducer,aBe=t=>{var e=nr(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(eBe(t)):n.current!==t&&e(tBe({prev:n.current,next:t})),n.current=t},[e,t]),E.useLayoutEffect(()=>()=>{n.current&&(e(nBe(n.current)),n.current=null)},[e]),null},PJ=E.memo(aBe);function oBe(t){var e=nr();return E.useLayoutEffect(()=>(e(rBe(t)),()=>{e(iBe(t))}),[e,t]),null}var lBe=["key"],cBe=["onMouseEnter","onClick","onMouseLeave"],uBe=["id"],dBe=["id"];function QV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ar(t){for(var e=1;eyL(t.children,kb),[t.children]),n=Ct(r=>Aze(r,t.id,e));return n==null?null:E.createElement(Kze,{legendPayload:n})}var xBe=E.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:s,fill:a,name:o,hide:l,tooltipType:c}=t,d={dataDefinedOnItem:r.map(h=>h.tooltipPayload),positions:r.map(h=>h.tooltipPosition),settings:{stroke:i,strokeWidth:s,fill:a,dataKey:e,nameKey:n,name:Bm(o,e),hide:l,type:c,color:a,unit:""}};return E.createElement(ML,{tooltipEntrySettings:d})}),bBe=(t,e)=>t>e?"start":tus(typeof e=="function"?e(t):e,n,n*.8),yBe=(t,e,n)=>{var{top:r,left:i,width:s,height:a}=e,o=eZ(s,a),l=i+us(t.cx,s,s/2),c=r+us(t.cy,a,a/2),d=us(t.innerRadius,o,0),h=vBe(n,t.outerRadius,o),g=t.maxRadius||Math.sqrt(s*s+a*a)/2;return{cx:l,cy:c,innerRadius:d,outerRadius:h,maxRadius:g}},_Be=(t,e)=>{var n=ki(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function SBe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var wBe=(t,e)=>{if(E.isValidElement(t))return E.cloneElement(t,e);if(typeof t=="function")return t(e);var n=An("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=DM(e,lBe);return E.createElement(Xp,ld({},i,{type:"linear",className:n}))},MBe=(t,e,n)=>{if(E.isValidElement(t))return E.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),E.isValidElement(r)))return r;var i=An("recharts-pie-label-text",SBe(t));return E.createElement(kM,ld({},e,{alignmentBaseline:"middle",className:i}),r)};function EBe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:s,dataKey:a}=n;if(!r||!i||!e)return null;var o=Xs(n),l=Gf(i),c=Gf(s),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,h=e.map((g,m)=>{var v=(g.startAngle+g.endAngle)/2,y=Xr(g.cx,g.cy,g.outerRadius+d,v),b=Ar(Ar(Ar(Ar({},o),g),{},{stroke:"none"},l),{},{index:m,textAnchor:bBe(y.x,g.cx)},y),x=Ar(Ar(Ar(Ar({},o),g),{},{fill:"none",stroke:g.fill},c),{},{index:m,points:[Xr(g.cx,g.cy,g.outerRadius,v),y],key:"line"});return E.createElement(Qs,{zIndex:Kr.label,key:"label-".concat(g.startAngle,"-").concat(g.endAngle,"-").concat(g.midAngle,"-").concat(m)},E.createElement(jr,null,s&&wBe(s,x),MBe(i,b,Yn(g,a))))});return E.createElement(jr,{className:"recharts-pie-labels"},h)}function ABe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?E.createElement(xL,{label:i}):E.createElement(EBe,{sectors:e,props:n,showLabels:r})}function TBe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:s,id:a}=t,o=Ct(od),l=Ct(uL),c=Ct(qUe),{onMouseEnter:d,onClick:h,onMouseLeave:g}=i,m=DM(i,cBe),v=_L(d,i.dataKey,a),y=SL(g),b=wL(h,i.dataKey,a);return e==null||e.length===0?null:E.createElement(E.Fragment,null,e.map((x,M)=>{if(x?.startAngle===0&&x?.endAngle===0&&e.length!==1)return null;var w=c==null||c===a,A=String(M)===o&&(l==null||i.dataKey===l)&&w,T=o?r:null,R=n&&A?n:T,C=Ar(Ar({},x),{},{stroke:x.stroke,tabIndex:-1,[kY]:M,[RY]:i.dataKey});return E.createElement(jr,ld({key:"sector-".concat(x?.startAngle,"-").concat(x?.endAngle,"-").concat(x.midAngle,"-").concat(M),tabIndex:-1,className:"recharts-pie-sector"},lb(m,x,M),{onMouseEnter:v(x,M),onMouseLeave:y(x,M),onClick:b(x,M)}),E.createElement(CJ,ld({option:s??R,index:M,shapeType:"sector",isActive:A},C)))}))}function CBe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:s}=t,{cornerRadius:a,startAngle:o,endAngle:l,dataKey:c,nameKey:d,tooltipType:h}=n,g=Math.abs(n.minAngle),m=_Be(o,l),v=Math.abs(m),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,b=r.filter(R=>Yn(R,c,0)!==0).length,x=(v>=360?b:b-1)*y,M=v-b*g-x,w=r.reduce((R,C)=>{var I=Yn(C,c,0);return R+(Tt(I)?I:0)},0),A;if(w>0){var T;A=r.map((R,C)=>{var I=Yn(R,c,0),N=Yn(R,d,C),D=yBe(n,s,R),z=(Tt(I)?I:0)/w,j,W=Ar(Ar({},R),i&&i[C]&&i[C].props);C?j=T.endAngle+ki(m)*y*(I!==0?1:0):j=o;var P=j+ki(m)*((I!==0?g:0)+z*M),$=(j+P)/2,K=(D.innerRadius+D.outerRadius)/2,G=[{name:N,value:I,payload:W,dataKey:c,type:h}],Z=Xr(D.cx,D.cy,K,$);return T=Ar(Ar(Ar(Ar({},n.presentationProps),{},{percent:z,cornerRadius:typeof a=="string"?parseFloat(a):a,name:N,tooltipPayload:G,midAngle:$,middleRadius:K,tooltipPosition:Z},W),D),{},{value:I,dataKey:c,startAngle:j,endAngle:P,payload:W,paddingAngle:ki(m)*y}),T})}return A}function NBe(t){var{showLabels:e,sectors:n,children:r}=t,i=E.useMemo(()=>!e||!n?[]:n.map(s=>({value:s.value,payload:s.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:s.cx,cy:s.cy,innerRadius:s.innerRadius,outerRadius:s.outerRadius,startAngle:s.startAngle,endAngle:s.endAngle,clockWise:!1},fill:s.fill})),[n,e]);return E.createElement(uze,{value:e?i:void 0},r)}function kBe(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:s,animationBegin:a,animationDuration:o,animationEasing:l,activeShape:c,inactiveShape:d,onAnimationStart:h,onAnimationEnd:g}=e,m=mb(e,"recharts-pie-"),v=n.current,[y,b]=E.useState(!1),x=E.useCallback(()=>{typeof g=="function"&&g(),b(!1)},[g]),M=E.useCallback(()=>{typeof h=="function"&&h(),b(!0)},[h]);return E.createElement(NBe,{showLabels:!y,sectors:i},E.createElement(pb,{animationId:m,begin:a,duration:o,isActive:s,easing:l,onAnimationStart:M,onAnimationEnd:x,key:m},w=>{var A=[],T=i&&i[0],R=T?.startAngle;return i?.forEach((C,I)=>{var N=v&&v[I],D=I>0?Wf(C,"paddingAngle",0):0;if(N){var z=lr(N.endAngle-N.startAngle,C.endAngle-C.startAngle,w),j=Ar(Ar({},C),{},{startAngle:R+D,endAngle:R+z+D});A.push(j),R=j.endAngle}else{var{endAngle:W,startAngle:P}=C,$=lr(0,W-P,w),K=Ar(Ar({},C),{},{startAngle:R+D,endAngle:R+$+D});A.push(K),R=K.endAngle}}),n.current=A,E.createElement(jr,null,E.createElement(TBe,{sectors:A,activeShape:c,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),E.createElement(ABe,{showLabels:!y,sectors:i,props:e}),e.children)}var RBe={animationBegin:400,animationDuration:1500,animationEasing:"ease",cx:"50%",cy:"50%",dataKey:"value",endAngle:360,fill:"#808080",hide:!1,innerRadius:0,isAnimationActive:"auto",label:!1,labelLine:!0,legendType:"rect",minAngle:0,nameKey:"name",outerRadius:"80%",paddingAngle:0,rootTabIndex:0,startAngle:0,stroke:"#fff",zIndex:Kr.area};function PBe(t){var{id:e}=t,n=DM(t,uBe),{hide:r,className:i,rootTabIndex:s}=t,a=E.useMemo(()=>yL(t.children,kb),[t.children]),o=Ct(d=>Tze(d,e,a)),l=E.useRef(null),c=An("recharts-pie",i);return r||o==null?(l.current=null,E.createElement(jr,{tabIndex:s,className:c})):E.createElement(Qs,{zIndex:t.zIndex},E.createElement(xBe,{dataKey:t.dataKey,nameKey:t.nameKey,sectors:o,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,tooltipType:t.tooltipType}),E.createElement(jr,{tabIndex:s,className:c},E.createElement(kBe,{props:Ar(Ar({},n),{},{sectors:o}),previousSectorsRef:l,id:e})))}function DJ(t){var e=ei(t,RBe),{id:n}=e,r=DM(e,dBe),i=Xs(r);return E.createElement(EL,{id:n,type:"pie"},s=>E.createElement(E.Fragment,null,E.createElement(oBe,{type:"pie",id:s,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:e.maxRadius}),E.createElement(gBe,ld({},r,{id:s})),E.createElement(PBe,ld({},r,{id:s}))))}DJ.displayName="Pie";var DBe=["points"];function JV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function AN(t){for(var e=1;e{var b,x,M=AN(AN(AN({r:3},a),h),{},{index:y,cx:(b=v.x)!==null&&b!==void 0?b:void 0,cy:(x=v.y)!==null&&x!==void 0?x:void 0,dataKey:s,value:v.value,payload:v.payload,points:e});return E.createElement(FBe,{key:"dot-".concat(y),option:n,dotProps:M,className:i})}),m={};return o&&l!=null&&(m.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(l,")")),E.createElement(Qs,{zIndex:c},E.createElement(jr,YS({className:r},m),g))}function eG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function tG(t){for(var e=1;e({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),t6e=We([e6e,Rc,Pc],(t,e,n)=>{if(!(!t||e==null||n==null))return{x:t.left,y:t.top,width:Math.max(0,e-t.left-t.right),height:Math.max(0,n-t.top-t.bottom)}}),AL=()=>Ct(t6e),n6e=()=>Ct(QUe);function nG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function TN(t){for(var e=1;e{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:s,clipPath:a}=t;if(i===!1||e.x==null||e.y==null)return null;var o={index:n,dataKey:s,cx:e.x,cy:e.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:e.payload,value:e.value},l=TN(TN(TN({},o),Gf(i)),$D(i)),c;return E.isValidElement(i)?c=E.cloneElement(i,l):typeof i=="function"?c=i(l):c=E.createElement(_J,l),E.createElement(jr,{className:"recharts-active-dot",clipPath:a},c)};function rG(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:s,zIndex:a=Kr.activeDot}=t,o=Ct(od),l=n6e();if(e==null||l==null)return null;var c=e.find(d=>l.includes(d.payload));return vr(c)?null:E.createElement(Qs,{zIndex:a},E.createElement(a6e,{point:c,childIndex:Number(o),mainColor:n,dataKey:i,activeDot:r,clipPath:s}))}var o6e="Invariant failed";function l6e(t,e){throw new Error(o6e)}var c6e=["x","y"];function PR(){return PR=Object.assign?Object.assign.bind():function(t){for(var e=1;e1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Tt(e))return e;var s=Tt(r)||vr(r);return s?e(r,i):(s||l6e(),n)}},x6e={},LJ=Zs({name:"errorBars",initialState:x6e,reducers:{addErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]||(t[n]=[]),t[n].push(r)},replaceErrorBar:(t,e)=>{var{itemId:n,prev:r,next:i}=e.payload;t[n]&&(t[n]=t[n].map(s=>s.dataKey===r.dataKey&&s.direction===r.direction?i:s))},removeErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]&&(t[n]=t[n].filter(i=>i.dataKey!==r.dataKey||i.direction!==r.direction))}}}),{addErrorBar:A9e,replaceErrorBar:T9e,removeErrorBar:C9e}=LJ.actions,b6e=LJ.reducer,v6e=["children"];function y6e(t,e){if(t==null)return{};var n,r,i=_6e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r({x:0,y:0,value:0}),errorBarOffset:0},w6e=E.createContext(S6e);function M6e(t){var{children:e}=t,n=y6e(t,v6e);return E.createElement(w6e.Provider,{value:n},e)}function TL(t,e){var n,r,i=Ct(c=>Oc(c,t)),s=Ct(c=>Lc(c,e)),a=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Ei.allowDataOverflow,o=(r=s?.allowDataOverflow)!==null&&r!==void 0?r:Ai.allowDataOverflow,l=a||o;return{needClip:l,needClipX:a,needClipY:o}}function jJ(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=AL(),{needClipX:s,needClipY:a,needClip:o}=TL(e,n);if(!o||!i)return null;var{x:l,y:c,width:d,height:h}=i;return E.createElement("clipPath",{id:"clipPath-".concat(r)},E.createElement("rect",{x:s?l:l-d/2,y:a?c:c-h/2,width:s?d:d*2,height:a?h:h*2}))}function E6e(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&cr(t.zIndex)?t.zIndex:e}var CN={exports:{}},NN={};var sG;function A6e(){if(sG)return NN;sG=1;var t=Tm();function e(l,c){return l===c&&(l!==0||1/l===1/c)||l!==l&&c!==c}var n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,s=t.useEffect,a=t.useMemo,o=t.useDebugValue;return NN.useSyncExternalStoreWithSelector=function(l,c,d,h,g){var m=i(null);if(m.current===null){var v={hasValue:!1,value:null};m.current=v}else v=m.current;m=a(function(){function b(T){if(!x){if(x=!0,M=T,T=h(T),g!==void 0&&v.hasValue){var R=v.value;if(g(R,T))return w=R}return w=T}if(R=w,n(M,T))return R;var C=h(T);return g!==void 0&&g(R,C)?(M=T,R):(M=T,w=C)}var x=!1,M,w,A=d===void 0?null:d;return[function(){return b(c())},A===null?void 0:function(){return b(A())}]},[c,d,h,g]);var y=r(l,m[0],m[1]);return s(function(){v.hasValue=!0,v.value=y},[y]),o(y),y},NN}var aG;function T6e(){return aG||(aG=1,CN.exports=A6e()),CN.exports}T6e();function C6e(t){t()}function N6e(){let t=null,e=null;return{clear(){t=null,e=null},notify(){C6e(()=>{let n=t;for(;n;)n.callback(),n=n.next})},get(){const n=[];let r=t;for(;r;)n.push(r),r=r.next;return n},subscribe(n){let r=!0;const i=e={callback:n,next:null,prev:e};return i.prev?i.prev.next=i:t=i,function(){!r||t===null||(r=!1,i.next?i.next.prev=i.prev:e=i.prev,i.prev?i.prev.next=i.next:t=i.next)}}}}var oG={notify(){},get:()=>[]};function k6e(t,e){let n,r=oG,i=0,s=!1;function a(y){d();const b=r.subscribe(y);let x=!1;return()=>{x||(x=!0,b(),h())}}function o(){r.notify()}function l(){v.onStateChange&&v.onStateChange()}function c(){return s}function d(){i++,n||(n=t.subscribe(l),r=N6e())}function h(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=oG)}function g(){s||(s=!0,d())}function m(){s&&(s=!1,h())}const v={addNestedSub:a,notifyNestedSubs:o,handleChangeWrapper:l,isSubscribed:c,trySubscribe:g,tryUnsubscribe:m,getListeners:()=>r};return v}var R6e=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",P6e=R6e(),D6e=()=>typeof navigator<"u"&&navigator.product==="ReactNative",O6e=D6e(),L6e=()=>P6e||O6e?E.useLayoutEffect:E.useEffect,j6e=L6e();function lG(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function I6e(t,e){if(lG(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(let i=0;i{const l=k6e(i);return{store:i,subscription:l,getServerState:r?()=>r:void 0}},[i,r]),a=E.useMemo(()=>i.getState(),[i]);j6e(()=>{const{subscription:l}=s;return l.onStateChange=l.notifyNestedSubs,l.trySubscribe(),a!==i.getState()&&l.notifyNestedSubs(),()=>{l.tryUnsubscribe(),l.onStateChange=void 0}},[s,a]);const o=n||B6e;return E.createElement(o.Provider,{value:s},e)}var $6e=H6e,V6e=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function G6e(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function OM(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(V6e.has(r)){if(t[r]==null&&e[r]==null)continue;if(!I6e(t[r],e[r]))return!1}else if(!G6e(t[r],e[r]))return!1;return!0}var W6e=["onMouseEnter","onMouseLeave","onClick"],q6e=["value","background","tooltipPosition"],X6e=["id"],K6e=["onMouseEnter","onClick","onMouseLeave"];function Cc(){return Cc=Object.assign?Object.assign.bind():function(t){for(var e=1;e{var{dataKey:e,name:n,fill:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:Bm(n,e),payload:t}]},t8e=E.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:s,hide:a,unit:o,tooltipType:l}=t,c={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:Bm(s,e),hide:a,type:l,color:i,unit:o}};return E.createElement(ML,{tooltipEntrySettings:c})});function n8e(t){var e=Ct(od),{data:n,dataKey:r,background:i,allOtherBarProps:s}=t,{onMouseEnter:a,onMouseLeave:o,onClick:l}=s,c=QS(s,W6e),d=_L(a,r),h=SL(o),g=wL(l,r);if(!i||n==null)return null;var m=Gf(i);return E.createElement(Qs,{zIndex:E6e(i,Kr.barBackground)},n.map((v,y)=>{var{value:b,background:x,tooltipPosition:M}=v,w=QS(v,q6e);if(!x)return null;var A=d(v,y),T=h(v,y),R=g(v,y),C=vs(vs(vs(vs(vs({option:i,isActive:String(y)===e},w),{},{fill:"#eee"},x),m),lb(c,v,y)),{},{onMouseEnter:A,onMouseLeave:T,onClick:R,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return E.createElement(ZS,Cc({key:"background-bar-".concat(y)},C))}))}function r8e(t){var{showLabels:e,children:n,rects:r}=t,i=r?.map(s=>{var a={x:s.x,y:s.y,width:s.width,lowerWidth:s.width,upperWidth:s.width,height:s.height};return vs(vs({},a),{},{value:s.value,payload:s.payload,parentViewBox:s.parentViewBox,viewBox:a,fill:s.fill})});return E.createElement(vJ,{value:e?i:void 0},n)}function i8e(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:s,dataKey:a}=t,o=Ct(od),l=Ct(uL),c=n&&String(s)===o&&(l==null||a===l),d=c?n:e;return c?E.createElement(Qs,{zIndex:Kr.activeBar},E.createElement(ZS,Cc({},r,{name:String(r.name)},i,{isActive:c,option:d,index:s,dataKey:a}))):E.createElement(ZS,Cc({},r,{name:String(r.name)},i,{isActive:c,option:d,index:s,dataKey:a}))}function s8e(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:s}=t;return E.createElement(ZS,Cc({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:s}))}function a8e(t){var e,{data:n,props:r}=t,i=(e=Xs(r))!==null&&e!==void 0?e:{},{id:s}=i,a=QS(i,X6e),{shape:o,dataKey:l,activeBar:c}=r,{onMouseEnter:d,onClick:h,onMouseLeave:g}=r,m=QS(r,K6e),v=_L(d,l),y=SL(g),b=wL(h,l);return n?E.createElement(E.Fragment,null,n.map((x,M)=>E.createElement(jr,Cc({key:"rectangle-".concat(x?.x,"-").concat(x?.y,"-").concat(x?.value,"-").concat(M),className:"recharts-bar-rectangle"},lb(m,x,M),{onMouseEnter:v(x,M),onMouseLeave:y(x,M),onClick:b(x,M)}),c?E.createElement(i8e,{shape:o,activeBar:c,baseProps:a,entry:x,index:M,dataKey:l}):E.createElement(s8e,{shape:o,baseProps:a,entry:x,index:M,dataKey:l})))):null}function o8e(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:s,animationBegin:a,animationDuration:o,animationEasing:l,onAnimationEnd:c,onAnimationStart:d}=e,h=n.current,g=mb(e,"recharts-bar-"),[m,v]=E.useState(!1),y=!m,b=E.useCallback(()=>{typeof c=="function"&&c(),v(!1)},[c]),x=E.useCallback(()=>{typeof d=="function"&&d(),v(!0)},[d]);return E.createElement(r8e,{showLabels:y,rects:r},E.createElement(pb,{animationId:g,begin:a,duration:o,isActive:s,easing:l,onAnimationEnd:b,onAnimationStart:x,key:g},M=>{var w=M===1?r:r?.map((A,T)=>{var R=h&&h[T];if(R)return vs(vs({},A),{},{x:lr(R.x,A.x,M),y:lr(R.y,A.y,M),width:lr(R.width,A.width,M),height:lr(R.height,A.height,M)});if(i==="horizontal"){var C=lr(0,A.height,M),I=lr(A.stackedBarStart,A.y,M);return vs(vs({},A),{},{y:I,height:C})}var N=lr(0,A.width,M),D=lr(A.stackedBarStart,A.x,M);return vs(vs({},A),{},{width:N,x:D})});return M>0&&(n.current=w??null),w==null?null:E.createElement(jr,null,E.createElement(a8e,{props:e,data:w}))}),E.createElement(xL,{label:e.label}),e.children)}function l8e(t){var e=E.useRef(null);return E.createElement(o8e,{previousRectanglesRef:e,props:t})}var IJ=0,c8e=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:Yn(t,e)}};class u8e extends E.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:s,yAxisId:a,needClip:o,background:l,id:c}=this.props;if(e||n==null)return null;var d=An("recharts-bar",i),h=c;return E.createElement(jr,{className:d,id:c},o&&E.createElement("defs",null,E.createElement(jJ,{clipPathId:h,xAxisId:s,yAxisId:a})),E.createElement(jr,{className:"recharts-bar-rectangles",clipPath:o?"url(#clipPath-".concat(h,")"):void 0},E.createElement(n8e,{data:n,dataKey:r,background:l,allOtherBarProps:this.props}),E.createElement(l8e,this.props)))}}var d8e={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:IJ,xAxisId:0,yAxisId:0,zIndex:Kr.bar};function f8e(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:a,animationBegin:o,animationDuration:l,animationEasing:c,isAnimationActive:d}=t,{needClip:h}=TL(e,n),g=Hm(),m=hs(),v=yL(t.children,kb),y=Ct(M=>z8e(M,e,n,m,t.id,v));if(g!=="vertical"&&g!=="horizontal")return null;var b,x=y?.[0];return x==null||x.height==null||x.width==null?b=0:b=g==="vertical"?x.height/2:x.width/2,E.createElement(M6e,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:c8e,errorBarOffset:b},E.createElement(u8e,Cc({},t,{layout:g,needClip:h,data:y,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:a,animationBegin:o,animationDuration:l,animationEasing:c,isAnimationActive:d})))}function h8e(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:s,xAxis:a,yAxis:o,xAxisTicks:l,yAxisTicks:c,stackedData:d,displayedData:h,offset:g,cells:m,parentViewBox:v,dataStartIndex:y}=t,b=e==="horizontal"?o:a,x=d?b.scale.domain():null,M=PPe({numericAxis:b}),w=b.scale(M);return h.map((A,T)=>{var R,C,I,N,D,z;d?R=TPe(d[T+y],x):(R=Yn(A,n),Array.isArray(R)||(R=[M,R]));var j=g6e(r,IJ)(R[1],T);if(e==="horizontal"){var W,[P,$]=[o.scale(R[0]),o.scale(R[1])];C=EH({axis:a,ticks:l,bandSize:s,offset:i.offset,entry:A,index:T}),I=(W=$??P)!==null&&W!==void 0?W:void 0,N=i.size;var K=P-$;if(D=eo(K)?0:K,z={x:C,y:g.top,width:N,height:g.height},Math.abs(j)>0&&Math.abs(D)0&&Math.abs(N)E.createElement(E.Fragment,null,E.createElement(NJ,{legendPayload:e8e(e)}),E.createElement(t8e,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),E.createElement(PJ,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:CY(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),E.createElement(Qs,{zIndex:e.zIndex},E.createElement(f8e,Cc({},e,{id:r})))))}var UJ=E.memo(p8e,OM);UJ.displayName="Bar";function uG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function v_(t){for(var e=1;ee,v8e=(t,e,n)=>n,y8e=(t,e,n,r)=>r,_8e=(t,e,n,r,i)=>i,Rb=We([EM,_8e],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),S8e=We([Rb],t=>t?.maxBarSize),w8e=(t,e,n,r,i,s)=>s,dG=(t,e,n)=>{var r=n??t;if(!vr(r))return us(r,e,0)},M8e=We([Sn,EM,b8e,v8e,y8e],(t,e,n,r,i)=>e.filter(s=>t==="horizontal"?s.xAxisId===n:s.yAxisId===r).filter(s=>s.isPanorama===i).filter(s=>s.hide===!1).filter(s=>s.type==="bar")),E8e=(t,e,n,r)=>{var i=Sn(t);return i==="horizontal"?H0(t,"yAxis",n,r):H0(t,"xAxis",e,r)},A8e=(t,e,n)=>{var r=Sn(t);return r==="horizontal"?iV(t,"xAxis",e):iV(t,"yAxis",n)},T8e=(t,e,n)=>{var r={},i=t.filter(SM),s=t.filter(c=>c.stackId==null),a=i.reduce((c,d)=>(c[d.stackId]||(c[d.stackId]=[]),c[d.stackId].push(d),c),r),o=Object.entries(a).map(c=>{var[d,h]=c,g=h.map(v=>v.dataKey),m=dG(e,n,h[0].barSize);return{stackId:d,dataKeys:g,barSize:m}}),l=s.map(c=>{var d=[c.dataKey].filter(g=>g!=null),h=dG(e,n,c.barSize);return{stackId:void 0,dataKeys:d,barSize:h}});return[...o,...l]},C8e=We([M8e,KIe,A8e],T8e),N8e=(t,e,n,r,i)=>{var s,a,o=Rb(t,e,n,r,i);if(o!=null){var l=Sn(t),c=JZ(t),{maxBarSize:d}=o,h=vr(d)?c:d,g,m;return l==="horizontal"?(g=ad(t,"xAxis",e,r),m=sd(t,"xAxis",e,r)):(g=ad(t,"yAxis",n,r),m=sd(t,"yAxis",n,r)),(s=(a=_m(g,m,!0))!==null&&a!==void 0?a:h)!==null&&s!==void 0?s:0}},FJ=(t,e,n,r)=>{var i=Sn(t),s,a;return i==="horizontal"?(s=ad(t,"xAxis",e,r),a=sd(t,"xAxis",e,r)):(s=ad(t,"yAxis",n,r),a=sd(t,"yAxis",n,r)),_m(s,a)};function k8e(t,e,n,r,i){var s=r.length;if(!(s<1)){var a=us(t,n,0,!0),o,l=[];if(cr(r[0].barSize)){var c=!1,d=n/s,h=r.reduce((x,M)=>x+(M.barSize||0),0);h+=(s-1)*a,h>=n&&(h-=(s-1)*a,a=0),h>=n&&d>0&&(c=!0,d*=.9,h=s*d);var g=(n-h)/2>>0,m={offset:g-a,size:0};o=r.reduce((x,M)=>{var w,A={stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:m.offset+m.size+a,size:c?d:(w=M.barSize)!==null&&w!==void 0?w:0}},T=[...x,A];return m=T[T.length-1].position,T},l)}else{var v=us(e,n,0,!0);n-2*v-(s-1)*a<=0&&(a=0);var y=(n-2*v-(s-1)*a)/s;y>1&&(y>>=0);var b=cr(i)?Math.min(y,i):y;o=r.reduce((x,M,w)=>[...x,{stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:v+(y+a)*w+(y-b)/2,size:b}}],l)}return o}}var R8e=(t,e,n,r,i,s,a)=>{var o=vr(a)?e:a,l=k8e(n,r,i!==s?i:s,t,o);return i!==s&&l!=null&&(l=l.map(c=>v_(v_({},c),{},{position:v_(v_({},c.position),{},{offset:c.position.offset-i/2})}))),l},P8e=We([C8e,JZ,XIe,eQ,N8e,FJ,S8e],R8e),D8e=(t,e,n,r)=>ad(t,"xAxis",e,r),O8e=(t,e,n,r)=>ad(t,"yAxis",n,r),L8e=(t,e,n,r)=>sd(t,"xAxis",e,r),j8e=(t,e,n,r)=>sd(t,"yAxis",n,r),I8e=We([P8e,Rb],(t,e)=>{if(!(t==null||e==null)){var n=t.find(r=>r.stackId===e.stackId&&e.dataKey!=null&&r.dataKeys.includes(e.dataKey));if(n!=null)return n.position}}),U8e=(t,e)=>{var n=_M(e);if(!(!t||n==null||e==null)){var{stackId:r}=e;if(r!=null){var i=t[r];if(i){var{stackedData:s}=i;if(s)return s.find(a=>a.key===n)}}}},F8e=We([E8e,Rb],U8e),z8e=We([pi,eO,D8e,O8e,L8e,j8e,I8e,Sn,bM,FJ,F8e,Rb,w8e],(t,e,n,r,i,s,a,o,l,c,d,h,g)=>{var{chartData:m,dataStartIndex:v,dataEndIndex:y}=l;if(!(h==null||a==null||e==null||o!=="horizontal"&&o!=="vertical"||n==null||r==null||i==null||s==null||c==null)){var{data:b}=h,x;if(b!=null&&b.length>0?x=b:x=m?.slice(v,y+1),x!=null)return h8e({layout:o,barSettings:h,pos:a,parentViewBox:e,bandSize:c,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:s,stackedData:d,displayedData:x,offset:t,cells:g,dataStartIndex:v})}}),zJ=t=>{var{chartData:e}=t,n=nr(),r=hs();return E.useEffect(()=>r?()=>{}:(n(xV(e)),()=>{n(xV(void 0))}),[e,n,r]),null},fG={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},BJ=Zs({name:"brush",initialState:fG,reducers:{setBrushSettings(t,e){return e.payload==null?fG:e.payload}}}),{setBrushSettings:N9e}=BJ.actions,B8e=BJ.reducer;function H8e(t,e,n){return(e=$8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $8e(t){var e=V8e(t,"string");return typeof e=="symbol"?e:e+""}function V8e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class CL{static create(e){return new CL(e)}constructor(e){this.scale=e}get domain(){return this.scale.domain}get range(){return this.scale.range}get rangeMin(){return this.range()[0]}get rangeMax(){return this.range()[1]}get bandwidth(){return this.scale.bandwidth}apply(e){var{bandAware:n,position:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e!==void 0){if(r)switch(r){case"start":return this.scale(e);case"middle":{var i=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+i}case"end":{var s=this.bandwidth?this.bandwidth():0;return this.scale(e)+s}default:return this.scale(e)}if(n){var a=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+a}return this.scale(e)}}isInRange(e){var n=this.range(),r=n[0],i=n[n.length-1];return r<=i?e>=r&&e<=i:e>=i&&e<=r}}H8e(CL,"EPS",1e-4);function G8e(t){return(t%180+180)%180}var W8e=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=G8e(i),a=s*Math.PI/180,o=Math.atan(r/n),l=a>o&&a{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=To(t).dots.findIndex(r=>r===e.payload);n!==-1&&t.dots.splice(n,1)},addArea:(t,e)=>{t.areas.push(e.payload)},removeArea:(t,e)=>{var n=To(t).areas.findIndex(r=>r===e.payload);n!==-1&&t.areas.splice(n,1)},addLine:(t,e)=>{t.lines.push(e.payload)},removeLine:(t,e)=>{var n=To(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:k9e,removeDot:R9e,addArea:P9e,removeArea:D9e,addLine:O9e,removeLine:L9e}=HJ.actions,X8e=HJ.reducer,K8e=E.createContext(void 0),Y8e=t=>{var{children:e}=t,[n]=E.useState("".concat(N0("recharts"),"-clip")),r=AL();if(r==null)return null;var{x:i,y:s,width:a,height:o}=r;return E.createElement(K8e.Provider,{value:n},E.createElement("defs",null,E.createElement("clipPath",{id:n},E.createElement("rect",{x:i,y:s,height:o,width:a}))),e)};function $J(t,e){if(e<1)return[];if(e===1)return t;for(var n=[],r=0;rt*i)return!1;var s=n();return t*(e-t*s/2-r)>=0&&t*(e+t*s/2-i)<=0}function J8e(t,e){return $J(t,e+1)}function eHe(t,e,n,r,i){for(var s=(r||[]).slice(),{start:a,end:o}=e,l=0,c=1,d=a,h=function(){var v=r?.[l];if(v===void 0)return{v:$J(r,c)};var y=l,b,x=()=>(b===void 0&&(b=n(v,y)),b),M=v.coordinate,w=l===0||JS(t,M,x,d,o);w||(l=0,d=a,c+=1),w&&(d=M+t*(x()/2+i),l+=c)},g;c<=s.length;)if(g=h(),g)return g.v;return[]}function hG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function as(t){for(var e=1;e(v===void 0&&(v=n(m,g)),v);if(g===a-1){var b=t*(m.coordinate+t*y()/2-l);s[g]=m=as(as({},m),{},{tickCoord:b>0?m.coordinate-b*t:m.coordinate})}else s[g]=m=as(as({},m),{},{tickCoord:m.coordinate});if(m.tickCoord!=null){var x=JS(t,m.tickCoord,y,o,l);x&&(l=m.tickCoord-t*(y()/2+i),s[g]=as(as({},m),{},{isShow:!0}))}},d=a-1;d>=0;d--)c(d);return s}function sHe(t,e,n,r,i,s){var a=(r||[]).slice(),o=a.length,{start:l,end:c}=e;if(s){var d=r[o-1],h=n(d,o-1),g=t*(d.coordinate+t*h/2-c);if(a[o-1]=d=as(as({},d),{},{tickCoord:g>0?d.coordinate-g*t:d.coordinate}),d.tickCoord!=null){var m=JS(t,d.tickCoord,()=>h,l,c);m&&(c=d.tickCoord-t*(h/2+i),a[o-1]=as(as({},d),{},{isShow:!0}))}}for(var v=s?o-1:o,y=function(M){var w=a[M],A,T=()=>(A===void 0&&(A=n(w,M)),A);if(M===0){var R=t*(w.coordinate-t*T()/2-l);a[M]=w=as(as({},w),{},{tickCoord:R<0?w.coordinate-R*t:w.coordinate})}else a[M]=w=as(as({},w),{},{tickCoord:w.coordinate});if(w.tickCoord!=null){var C=JS(t,w.tickCoord,T,l,c);C&&(l=w.tickCoord+t*(T()/2+i),a[M]=as(as({},w),{},{isShow:!0}))}},b=0;b{var T=typeof c=="function"?c(w.value,A):w.value;return v==="width"?Z8e(Kx(T,{fontSize:e,letterSpacing:n}),y,h):Kx(T,{fontSize:e,letterSpacing:n})[v]},x=i.length>=2?ki(i[1].coordinate-i[0].coordinate):1,M=Q8e(s,x,v);return l==="equidistantPreserveStart"?eHe(x,M,b,i,a):(l==="preserveStart"||l==="preserveStartEnd"?m=sHe(x,M,b,i,a,l==="preserveStartEnd"):m=iHe(x,M,b,i,a),m.filter(w=>w.isShow))}var aHe=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:s=0}=t,a=0;if(e){Array.from(e).forEach(d=>{if(d){var h=d.getBoundingClientRect();h.width>a&&(a=h.width)}});var o=n?n.getBoundingClientRect().width:0,l=i+s,c=a+l+o+(n?r:0);return Math.round(c)}return 0},oHe=["axisLine","width","height","className","hide","ticks","axisType"];function lHe(t,e){if(t==null)return{};var n,r,i=cHe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r{var{ticks:n=[],tick:r,tickLine:i,stroke:s,tickFormatter:a,unit:o,padding:l,tickTextProps:c,orientation:d,mirror:h,x:g,y:m,width:v,height:y,tickSize:b,tickMargin:x,fontSize:M,letterSpacing:w,getTicksConfig:A,events:T,axisType:R}=t,C=NL(Vr(Vr({},A),{},{ticks:n}),M,w),I=mHe(d,h),N=gHe(d,h),D=Xs(A),z=Gf(r),j={};typeof i=="object"&&(j=i);var W=Vr(Vr({},D),{},{fill:"none"},j),P=C.map(G=>Vr({entry:G},pHe(G,g,m,v,y,d,b,h,x))),$=P.map(G=>{var{entry:Z,line:Q}=G;return E.createElement(jr,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(Z.value,"-").concat(Z.coordinate,"-").concat(Z.tickCoord)},i&&E.createElement("line",Yf({},W,Q,{className:An("recharts-cartesian-axis-tick-line",Wf(i,"className"))})))}),K=P.map((G,Z)=>{var{entry:Q,tick:ee}=G,H=Vr(Vr(Vr(Vr({textAnchor:I,verticalAnchor:N},D),{},{stroke:"none",fill:s},z),ee),{},{index:Z,payload:Q,visibleTicksCount:C.length,tickFormatter:a,padding:l},c);return E.createElement(jr,Yf({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Q.value,"-").concat(Q.coordinate,"-").concat(Q.tickCoord)},lb(T,Q,Z)),r&&E.createElement(xHe,{option:r,tickProps:H,value:"".concat(typeof a=="function"?a(Q.value,Z):Q.value).concat(o||"")}))});return E.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(R,"-ticks")},K.length>0&&E.createElement(Qs,{zIndex:Kr.label},E.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(R,"-tick-labels"),ref:e},K)),$.length>0&&E.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(R,"-tick-lines")},$))}),vHe=E.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:s,hide:a,ticks:o,axisType:l}=t,c=lHe(t,oHe),[d,h]=E.useState(""),[g,m]=E.useState(""),v=E.useRef(null);E.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var b;return aHe({ticks:v.current,label:(b=t.labelRef)===null||b===void 0?void 0:b.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var y=E.useCallback(b=>{if(b){var x=b.getElementsByClassName("recharts-cartesian-axis-tick-value");v.current=x;var M=x[0];if(M){var w=window.getComputedStyle(M),A=w.fontSize,T=w.letterSpacing;(A!==d||T!==g)&&(h(A),m(T))}}},[d,g]);return a||r!=null&&r<=0||i!=null&&i<=0?null:E.createElement(Qs,{zIndex:t.zIndex},E.createElement(jr,{className:An("recharts-cartesian-axis",s)},E.createElement(hHe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Xs(t)}),E.createElement(bHe,{ref:y,axisType:l,events:c,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:g,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:o,unit:t.unit,width:t.width,x:t.x,y:t.y}),E.createElement($5e,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},E.createElement(J5e,{label:t.label,labelRef:t.labelRef}),t.children)))}),kL=E.forwardRef((t,e)=>{var n=ei(t,xc);return E.createElement(vHe,Yf({},n,{ref:e}))});kL.displayName="CartesianAxis";var yHe=["x1","y1","x2","y2","key"],_He=["offset"],SHe=["xAxisId","yAxisId"],wHe=["xAxisId","yAxisId"];function mG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ls(t){for(var e=1;e{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:s,height:a,ry:o}=t;return E.createElement("rect",{x:r,y:i,ry:o,width:s,height:a,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function VJ(t){var{option:e,lineItemProps:n}=t,r;if(E.isValidElement(e))r=E.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:s,y1:a,x2:o,y2:l,key:c}=n,d=ew(n,yHe),h=(i=Xs(d))!==null&&i!==void 0?i:{},{offset:g}=h,m=ew(h,_He);r=E.createElement("line",df({},m,{x1:s,y1:a,x2:o,y2:l,fill:"none",key:c}))}return r}function NHe(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:s,yAxisId:a}=t,o=ew(t,SHe),l=i.map((c,d)=>{var h=ls(ls({},o),{},{x1:e,y1:c,x2:e+n,y2:c,key:"line-".concat(d),index:d});return E.createElement(VJ,{key:"line-".concat(d),option:r,lineItemProps:h})});return E.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function kHe(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:s,yAxisId:a}=t,o=ew(t,wHe),l=i.map((c,d)=>{var h=ls(ls({},o),{},{x1:c,y1:e,x2:c,y2:e+n,key:"line-".concat(d),index:d});return E.createElement(VJ,{option:r,lineItemProps:h,key:"line-".concat(d)})});return E.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function RHe(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:s,height:a,horizontalPoints:o,horizontal:l=!0}=t;if(!l||!e||!e.length||o==null)return null;var c=o.map(h=>Math.round(h+i-i)).sort((h,g)=>h-g);i!==c[0]&&c.unshift(0);var d=c.map((h,g)=>{var m=!c[g+1],v=m?i+a-h:c[g+1]-h;if(v<=0)return null;var y=g%e.length;return E.createElement("rect",{key:"react-".concat(g),y:h,x:r,height:v,width:s,stroke:"none",fill:e[y],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function PHe(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:s,width:a,height:o,verticalPoints:l}=t;if(!e||!n||!n.length)return null;var c=l.map(h=>Math.round(h+i-i)).sort((h,g)=>h-g);i!==c[0]&&c.unshift(0);var d=c.map((h,g)=>{var m=!c[g+1],v=m?i+a-h:c[g+1]-h;if(v<=0)return null;var y=g%n.length;return E.createElement("rect",{key:"react-".concat(g),x:h,y:s,width:v,height:o,stroke:"none",fill:n[y],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var DHe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:s}=t;return AY(NL(ls(ls(ls({},xc),n),{},{ticks:TY(n),viewBox:{x:0,y:0,width:r,height:i}})),s.left,s.left+s.width,e)},OHe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:s}=t;return AY(NL(ls(ls(ls({},xc),n),{},{ticks:TY(n),viewBox:{x:0,y:0,width:r,height:i}})),s.top,s.top+s.height,e)},LHe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Kr.grid};function DR(t){var e=nO(),n=rO(),r=jY(),i=ls(ls({},ei(t,LHe)),{},{x:Tt(t.x)?t.x:r.left,y:Tt(t.y)?t.y:r.top,width:Tt(t.width)?t.width:r.width,height:Tt(t.height)?t.height:r.height}),{xAxisId:s,yAxisId:a,x:o,y:l,width:c,height:d,syncWithTicks:h,horizontalValues:g,verticalValues:m}=i,v=hs(),y=Ct(N=>sV(N,"xAxis",s,v)),b=Ct(N=>sV(N,"yAxis",a,v));if(!dl(c)||!dl(d)||!Tt(o)||!Tt(l))return null;var x=i.verticalCoordinatesGenerator||DHe,M=i.horizontalCoordinatesGenerator||OHe,{horizontalPoints:w,verticalPoints:A}=i;if((!w||!w.length)&&typeof M=="function"){var T=g&&g.length,R=M({yAxis:b?ls(ls({},b),{},{ticks:T?g:b.ticks}):void 0,width:e??c,height:n??d,offset:r},T?!0:h);ES(Array.isArray(R),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof R,"]")),Array.isArray(R)&&(w=R)}if((!A||!A.length)&&typeof x=="function"){var C=m&&m.length,I=x({xAxis:y?ls(ls({},y),{},{ticks:C?m:y.ticks}):void 0,width:e??c,height:n??d,offset:r},C?!0:h);ES(Array.isArray(I),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof I,"]")),Array.isArray(I)&&(A=I)}return E.createElement(Qs,{zIndex:i.zIndex},E.createElement("g",{className:"recharts-cartesian-grid"},E.createElement(CHe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),E.createElement(RHe,df({},i,{horizontalPoints:w})),E.createElement(PHe,df({},i,{verticalPoints:A})),E.createElement(NHe,df({},i,{offset:r,horizontalPoints:w,xAxis:y,yAxis:b})),E.createElement(kHe,df({},i,{offset:r,verticalPoints:A,xAxis:y,yAxis:b}))))}DR.displayName="CartesianGrid";function jHe(t){var e=Gf(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:s}=e,a=Number(i),o=Number(s);return(Number.isNaN(a)||a<0)&&(a=n),(Number.isNaN(o)||o<0)&&(o=r),{r:a,strokeWidth:o}}return{r:n,strokeWidth:r}}var GJ=(t,e,n,r)=>ad(t,"xAxis",e,r),WJ=(t,e,n,r)=>sd(t,"xAxis",e,r),qJ=(t,e,n,r)=>ad(t,"yAxis",n,r),XJ=(t,e,n,r)=>sd(t,"yAxis",n,r),IHe=We([Sn,GJ,qJ,WJ,XJ],(t,e,n,r,i)=>kc(t,"xAxis")?_m(e,r,!1):_m(n,i,!1)),UHe=(t,e,n,r,i)=>i,KJ=We([EM,UHe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),FHe=(t,e,n,r,i)=>{var s,a=KJ(t,e,n,r,i);if(a!=null){var o=Sn(t),l=kc(o,"xAxis"),c;if(l?c=H0(t,"yAxis",n,r):c=H0(t,"xAxis",e,r),c!=null){var{stackId:d}=a,h=_M(a);if(!(d==null||h==null)){var g=(s=c[d])===null||s===void 0?void 0:s.stackedData;return g?.find(m=>m.key===h)}}}},zHe=We([Sn,GJ,qJ,WJ,XJ,FHe,bM,IHe,KJ,YIe],(t,e,n,r,i,s,a,o,l,c)=>{var{chartData:d,dataStartIndex:h,dataEndIndex:g}=a;if(!(l==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null)){var{data:m}=l,v;if(m&&m.length>0?v=m:v=d?.slice(h,g+1),v!=null)return s$e({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:h,areaSettings:l,stackedData:s,displayedData:v,chartBaseValue:c,bandSize:o})}}),BHe=["id"],HHe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Ef(){return Ef=Object.assign?Object.assign.bind():function(t){for(var e=1;e{var{dataKey:e,name:n,stroke:r,fill:i,legendType:s,hide:a}=t;return[{inactive:a,dataKey:e,type:s,color:tw(r,i),value:Bm(n,e),payload:t}]},XHe=E.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:a,hide:o,unit:l,tooltipType:c}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:Bm(a,e),hide:o,type:c,color:tw(r,s),unit:l}};return E.createElement(ML,{tooltipEntrySettings:d})});function KHe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:s,dataKey:a}=r,o=Xs(r);return E.createElement(BBe,{points:n,dot:s,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:a,baseProps:o,needClip:i,clipPathId:e})}function YHe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(s=>{var a,o,l={x:(a=s.x)!==null&&a!==void 0?a:0,y:(o=s.y)!==null&&o!==void 0?o:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Lp(Lp({},l),{},{value:s.value,payload:s.payload,parentViewBox:void 0,viewBox:l,fill:void 0})});return E.createElement(vJ,{value:e?i:void 0},n)}function xG(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:s}=t,{layout:a,type:o,stroke:l,connectNulls:c,isRange:d}=s,{id:h}=s,g=YJ(s,BHe),m=Xs(g),v=Cs(g);return E.createElement(E.Fragment,null,e?.length>1&&E.createElement(jr,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},E.createElement(Xp,Ef({},v,{id:h,points:e,connectNulls:c,type:o,baseLine:n,layout:a,stroke:"none",className:"recharts-area-area"})),l!=="none"&&E.createElement(Xp,Ef({},m,{className:"recharts-area-curve",layout:a,type:o,connectNulls:c,fill:"none",points:e})),l!=="none"&&d&&E.createElement(Xp,Ef({},m,{className:"recharts-area-curve",layout:a,type:o,connectNulls:c,fill:"none",points:n}))),E.createElement(KHe,{points:e,props:g,clipPathId:i}))}function ZHe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].y,a=r[r.length-1].y;if(!cr(s)||!cr(a))return null;var o=e*Math.abs(s-a),l=Math.max(...r.map(c=>c.x||0));return Tt(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(c=>c.x||0),l)),Tt(l)?E.createElement("rect",{x:0,y:sc.y||0));return Tt(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(c=>c.y||0),l)),Tt(l)?E.createElement("rect",{x:s({points:a,baseLine:o}),[a,o]),y=mb(v,"recharts-area-"),b=pDe(),[x,M]=E.useState(!1),w=!x,A=E.useCallback(()=>{typeof m=="function"&&m(),M(!1)},[m]),T=E.useCallback(()=>{typeof g=="function"&&g(),M(!0)},[g]);if(b==null)return null;var R=i.current,C=s.current;return E.createElement(YHe,{showLabels:w,points:a},r.children,E.createElement(pb,{animationId:y,begin:c,duration:d,isActive:l,easing:h,onAnimationEnd:A,onAnimationStart:T,key:y},I=>{if(R){var N=R.length/a.length,D=I===1?a:a.map((j,W)=>{var P=Math.floor(W*N);if(R[P]){var $=R[P];return Lp(Lp({},j),{},{x:lr($.x,j.x,I),y:lr($.y,j.y,I)})}return j}),z;return Tt(o)?z=lr(C,o,I):vr(o)||eo(o)?z=lr(C,0,I):z=o.map((j,W)=>{var P=Math.floor(W*N);if(Array.isArray(C)&&C[P]){var $=C[P];return Lp(Lp({},j),{},{x:lr($.x,j.x,I),y:lr($.y,j.y,I)})}return j}),I>0&&(i.current=D,s.current=z),E.createElement(xG,{points:D,baseLine:z,needClip:e,clipPathId:n,props:r})}return I>0&&(i.current=a,s.current=o),E.createElement(jr,null,l&&E.createElement("defs",null,E.createElement("clipPath",{id:"animationClipPath-".concat(n)},E.createElement(JHe,{alpha:I,points:a,baseLine:o,layout:b,strokeWidth:r.strokeWidth}))),E.createElement(jr,{clipPath:"url(#animationClipPath-".concat(n,")")},E.createElement(xG,{points:a,baseLine:o,needClip:e,clipPathId:n,props:r})))}),E.createElement(xL,{label:r.label}))}function t$e(t){var{needClip:e,clipPathId:n,props:r}=t,i=E.useRef(null),s=E.useRef();return E.createElement(e$e,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s})}class n$e extends E.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:s,left:a,needClip:o,xAxisId:l,yAxisId:c,width:d,height:h,id:g,baseLine:m,zIndex:v}=this.props;if(e)return null;var y=An("recharts-area",i),b=g,{r:x,strokeWidth:M}=jHe(n),w=TJ(n),A=x*2+M,T=o?"url(#clipPath-".concat(w?"":"dots-").concat(b,")"):void 0;return E.createElement(Qs,{zIndex:v},E.createElement(jr,{className:y},o&&E.createElement("defs",null,E.createElement(jJ,{clipPathId:b,xAxisId:l,yAxisId:c}),!w&&E.createElement("clipPath",{id:"clipPath-dots-".concat(b)},E.createElement("rect",{x:a-A/2,y:s-A/2,width:d+A,height:h+A}))),E.createElement(t$e,{needClip:o,clipPathId:b,props:this.props})),E.createElement(rG,{points:r,mainColor:tw(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}),this.props.isRange&&Array.isArray(m)&&E.createElement(rG,{points:m,mainColor:tw(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}))}}var ZJ={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,xAxisId:0,yAxisId:0,zIndex:Kr.area};function r$e(t){var e,n=ei(t,ZJ),{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:a,connectNulls:o,dot:l,fill:c,fillOpacity:d,hide:h,isAnimationActive:g,legendType:m,stroke:v,xAxisId:y,yAxisId:b}=n,x=YJ(n,HHe),M=Hm(),w=eJ(),{needClip:A}=TL(y,b),T=hs(),{points:R,isRange:C,baseLine:I}=(e=Ct(P=>zHe(P,y,b,T,t.id)))!==null&&e!==void 0?e:{},N=AL();if(M!=="horizontal"&&M!=="vertical"||N==null||w!=="AreaChart"&&w!=="ComposedChart")return null;var{height:D,width:z,x:j,y:W}=N;return!R||!R.length?null:E.createElement(n$e,Ef({},x,{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:a,baseLine:I,connectNulls:o,dot:l,fill:c,fillOpacity:d,height:D,hide:h,layout:M,isAnimationActive:g==="auto"?!$m.isSsr:g,isRange:C,legendType:m,needClip:A,points:R,stroke:v,width:z,left:j,top:W,xAxisId:y,yAxisId:b}))}var i$e=(t,e,n,r,i)=>{var s=n??e;if(Tt(s))return s;var a=t==="horizontal"?i:r,o=a.scale.domain();if(a.type==="number"){var l=Math.max(o[0],o[1]),c=Math.min(o[0],o[1]);return s==="dataMin"?c:s==="dataMax"||l<0?l:Math.max(Math.min(o[0],o[1]),0)}return s==="dataMin"?o[0]:s==="dataMax"?o[1]:o[0]};function s$e(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:s,chartBaseValue:a,xAxis:o,yAxis:l,displayedData:c,dataStartIndex:d,xAxisTicks:h,yAxisTicks:g,bandSize:m}=t,v=i&&i.length,y=i$e(s,a,n,o,l),b=s==="horizontal",x=!1,M=c.map((A,T)=>{var R;v?R=i[d+T]:(R=Yn(A,r),Array.isArray(R)?x=!0:R=[y,R]);var C=R[1]==null||v&&!e&&Yn(A,r)==null;return b?{x:MH({axis:o,ticks:h,bandSize:m,entry:A,index:T}),y:C?null:l.scale(R[1]),value:R,payload:A}:{x:C?null:o.scale(R[1]),y:MH({axis:l,ticks:g,bandSize:m,entry:A,index:T}),value:R,payload:A}}),w;return v||x?w=M.map(A=>{var T=Array.isArray(A.value)?A.value[0]:null;return b?{x:A.x,y:T!=null&&A.y!=null?l.scale(T):null,payload:A.payload}:{x:T!=null?o.scale(T):null,y:A.y,payload:A.payload}}):w=b?l.scale(y):o.scale(y),{points:M,baseLine:w,isRange:x}}function a$e(t){var e=ei(t,ZJ),n=hs();return E.createElement(EL,{id:e.id,type:"area"},r=>E.createElement(E.Fragment,null,E.createElement(NJ,{legendPayload:qHe(e)}),E.createElement(XHe,{dataKey:e.dataKey,data:e.data,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),E.createElement(PJ,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:CY(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),E.createElement(r$e,Ef({},e,{id:r}))))}var QJ=E.memo(a$e,OM);QJ.displayName="Area";var o$e=["domain","range"],l$e=["domain","range"];function bG(t,e){if(t==null)return{};var n,r,i=c$e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r{n.current===null?e(WBe(t)):n.current!==t&&e(qBe({prev:n.current,next:t})),n.current=t},[t,e]),E.useLayoutEffect(()=>()=>{n.current&&(e(XBe(n.current)),n.current=null)},[e]),null}var p$e=t=>{var{xAxisId:e,className:n}=t,r=Ct(eO),i=hs(),s="xAxis",a=Ct(b=>Ym(b,s,e,i)),o=Ct(b=>PQ(b,s,e,i)),l=Ct(b=>CQ(b,e)),c=Ct(b=>q4e(b,e)),d=Ct(b=>cQ(b,e));if(l==null||c==null||d==null)return null;var{dangerouslySetInnerHTML:h,ticks:g}=t,m=yG(t,u$e),{id:v}=d,y=yG(d,d$e);return E.createElement(kL,OR({},m,y,{scale:a,x:c.x,y:c.y,width:l.width,height:l.height,className:An("recharts-".concat(s," ").concat(s),n),viewBox:r,ticks:o,axisType:s}))},m$e={allowDataOverflow:Ei.allowDataOverflow,allowDecimals:Ei.allowDecimals,allowDuplicatedCategory:Ei.allowDuplicatedCategory,angle:Ei.angle,axisLine:xc.axisLine,height:Ei.height,hide:!1,includeHidden:Ei.includeHidden,interval:Ei.interval,minTickGap:Ei.minTickGap,mirror:Ei.mirror,orientation:Ei.orientation,padding:Ei.padding,reversed:Ei.reversed,scale:Ei.scale,tick:Ei.tick,tickCount:Ei.tickCount,tickLine:xc.tickLine,tickSize:xc.tickSize,type:Ei.type,xAxisId:0},g$e=t=>{var e=ei(t,m$e);return E.createElement(E.Fragment,null,E.createElement(h$e,{allowDataOverflow:e.allowDataOverflow,allowDecimals:e.allowDecimals,allowDuplicatedCategory:e.allowDuplicatedCategory,angle:e.angle,dataKey:e.dataKey,domain:e.domain,height:e.height,hide:e.hide,id:e.xAxisId,includeHidden:e.includeHidden,interval:e.interval,minTickGap:e.minTickGap,mirror:e.mirror,name:e.name,orientation:e.orientation,padding:e.padding,reversed:e.reversed,scale:e.scale,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit}),E.createElement(p$e,e))},LR=E.memo(g$e,JJ);LR.displayName="XAxis";var x$e=["dangerouslySetInnerHTML","ticks"],b$e=["id"];function jR(){return jR=Object.assign?Object.assign.bind():function(t){for(var e=1;e{n.current===null?e(KBe(t)):n.current!==t&&e(YBe({prev:n.current,next:t})),n.current=t},[t,e]),E.useLayoutEffect(()=>()=>{n.current&&(e(ZBe(n.current)),n.current=null)},[e]),null}var _$e=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,s=E.useRef(null),a=E.useRef(null),o=Ct(eO),l=hs(),c=nr(),d="yAxis",h=Ct(T=>Ym(T,d,e,l)),g=Ct(T=>NQ(T,e)),m=Ct(T=>K4e(T,e)),v=Ct(T=>PQ(T,d,e,l)),y=Ct(T=>uQ(T,e));if(E.useLayoutEffect(()=>{if(!(r!=="auto"||!g||gL(i)||E.isValidElement(i)||y==null)){var T=s.current;if(T){var R=T.getCalculatedWidth();Math.round(g.width)!==Math.round(R)&&c(QBe({id:e,width:R}))}}},[v,g,c,i,e,r,y]),g==null||m==null||y==null)return null;var{dangerouslySetInnerHTML:b,ticks:x}=t,M=_G(t,x$e),{id:w}=y,A=_G(y,b$e);return E.createElement(kL,jR({},M,A,{ref:s,labelRef:a,scale:h,x:m.x,y:m.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:g.width,height:g.height,className:An("recharts-".concat(d," ").concat(d),n),viewBox:o,ticks:v,axisType:d}))},S$e={allowDataOverflow:Ai.allowDataOverflow,allowDecimals:Ai.allowDecimals,allowDuplicatedCategory:Ai.allowDuplicatedCategory,angle:Ai.angle,axisLine:xc.axisLine,hide:!1,includeHidden:Ai.includeHidden,interval:Ai.interval,minTickGap:Ai.minTickGap,mirror:Ai.mirror,orientation:Ai.orientation,padding:Ai.padding,reversed:Ai.reversed,scale:Ai.scale,tick:Ai.tick,tickCount:Ai.tickCount,tickLine:xc.tickLine,tickSize:xc.tickSize,type:Ai.type,width:Ai.width,yAxisId:0},w$e=t=>{var e=ei(t,S$e);return E.createElement(E.Fragment,null,E.createElement(y$e,{interval:e.interval,id:e.yAxisId,scale:e.scale,type:e.type,domain:e.domain,allowDataOverflow:e.allowDataOverflow,dataKey:e.dataKey,allowDuplicatedCategory:e.allowDuplicatedCategory,allowDecimals:e.allowDecimals,tickCount:e.tickCount,padding:e.padding,includeHidden:e.includeHidden,reversed:e.reversed,ticks:e.ticks,width:e.width,orientation:e.orientation,mirror:e.mirror,hide:e.hide,unit:e.unit,name:e.name,angle:e.angle,minTickGap:e.minTickGap,tick:e.tick,tickFormatter:e.tickFormatter}),E.createElement(_$e,e))},IR=E.memo(w$e,JJ);IR.displayName="YAxis";var M$e=(t,e)=>e,RL=We([M$e,Sn,oQ,gi,XQ,jc,uFe,pi],xFe),PL=t=>{var e=t.currentTarget.getBoundingClientRect(),n=e.width/t.currentTarget.offsetWidth,r=e.height/t.currentTarget.offsetHeight;return{chartX:Math.round((t.clientX-e.left)/n),chartY:Math.round((t.clientY-e.top)/r)}},eee=to("mouseClick"),tee=db();tee.startListening({actionCreator:eee,effect:(t,e)=>{var n=t.payload,r=RL(e.getState(),PL(n));r?.activeIndex!=null&&e.dispatch(cUe({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var UR=to("mouseMove"),nee=db(),y_=null;nee.startListening({actionCreator:UR,effect:(t,e)=>{var n=t.payload;y_!==null&&cancelAnimationFrame(y_);var r=PL(n);y_=requestAnimationFrame(()=>{var i=e.getState(),s=iL(i,i.tooltip.settings.shared);if(s==="axis"){var a=RL(i,r);a?.activeIndex!=null?e.dispatch(zQ({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate})):e.dispatch(FQ())}y_=null})}});var SG={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:"none",syncId:void 0,syncMethod:"index",baseValue:void 0,reverseStackOrder:!1},ree=Zs({name:"rootProps",initialState:SG,reducers:{updateOptions:(t,e)=>{var n;t.accessibilityLayer=e.payload.accessibilityLayer,t.barCategoryGap=e.payload.barCategoryGap,t.barGap=(n=e.payload.barGap)!==null&&n!==void 0?n:SG.barGap,t.barSize=e.payload.barSize,t.maxBarSize=e.payload.maxBarSize,t.stackOffset=e.payload.stackOffset,t.syncId=e.payload.syncId,t.syncMethod=e.payload.syncMethod,t.className=e.payload.className,t.baseValue=e.payload.baseValue,t.reverseStackOrder=e.payload.reverseStackOrder}}}),E$e=ree.reducer,{updateOptions:A$e}=ree.actions,iee=Zs({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:T$e}=iee.actions,C$e=iee.reducer,see=to("keyDown"),aee=to("focus"),DL=db();DL.startListening({actionCreator:see,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip,s=t.payload;if(!(s!=="ArrowRight"&&s!=="ArrowLeft"&&s!=="Enter")){var a=sL(i,Qm(n),Mb(n),Cb(n)),o=a==null?-1:Number(a);if(!(!Number.isFinite(o)||o<0)){var l=jc(n);if(s==="Enter"){var c=WS(n,"axis","hover",String(i.index));e.dispatch(AR({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:c}));return}var d=J4e(n),h=d==="left-to-right"?1:-1,g=s==="ArrowRight"?1:-1,m=o+g*h;if(!(l==null||m>=l.length||m<0)){var v=WS(n,"axis","hover",String(m));e.dispatch(AR({active:!0,activeIndex:m.toString(),activeDataKey:void 0,activeCoordinate:v}))}}}}}});DL.startListening({actionCreator:aee,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip;if(!i.active&&i.index==null){var s="0",a=WS(n,"axis","hover",String(s));e.dispatch(AR({activeDataKey:void 0,active:!0,activeIndex:s,activeCoordinate:a}))}}}});var La=to("externalEvent"),oee=db(),kN=new Map;oee.startListening({actionCreator:La,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,s=kN.get(i);s!==void 0&&cancelAnimationFrame(s);var a=requestAnimationFrame(()=>{try{var o=e.getState(),l={activeCoordinate:KUe(o),activeDataKey:uL(o),activeIndex:od(o),activeLabel:ZQ(o),activeTooltipIndex:od(o),isTooltipActive:YUe(o)};n(l,r)}finally{kN.delete(i)}});kN.set(i,a)}}});var N$e=We([Zm],t=>t.tooltipItemPayloads),k$e=We([N$e,Ab,(t,e,n)=>e,(t,e,n)=>n],(t,e,n,r)=>{var i=t.find(o=>o.settings.dataKey===r);if(i!=null){var{positions:s}=i;if(s!=null){var a=e(s,n);return a}}}),lee=to("touchMove"),cee=db();cee.startListening({actionCreator:lee,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=iL(r,r.tooltip.settings.shared);if(i==="axis"){var s=RL(r,PL({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));s?.activeIndex!=null&&e.dispatch(zQ({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate}))}else if(i==="item"){var a,o=n.touches[0];if(document.elementFromPoint==null)return;var l=document.elementFromPoint(o.clientX,o.clientY);if(!l||!l.getAttribute)return;var c=l.getAttribute(kY),d=(a=l.getAttribute(RY))!==null&&a!==void 0?a:void 0,h=k$e(e.getState(),c,d);e.dispatch(UQ({activeDataKey:d,activeIndex:c,activeCoordinate:h}))}}}});var R$e=ZK({brush:B8e,cartesianAxis:JBe,chartData:XFe,errorBars:b6e,graphicalItems:sBe,layout:_Pe,legend:NDe,options:$Fe,polarAxis:yze,polarOptions:C$e,referenceElements:X8e,rootProps:E$e,tooltip:uUe,zIndex:RFe}),P$e=function(e){return WRe({reducer:R$e,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([tee.middleware,nee.middleware,DL.middleware,oee.middleware,cee.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(fY({type:"raf"}))},devTools:$m.devToolsEnabled})};function uee(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=hs(),s=E.useRef(null);if(i)return n;s.current==null&&(s.current=P$e(e));var a=GD;return E.createElement($6e,{context:a,store:s.current},n)}function D$e(t){var{layout:e,margin:n}=t,r=nr(),i=hs();return E.useEffect(()=>{i||(r(bPe(e)),r(xPe(n)))},[r,i,e,n]),null}var dee=E.memo(D$e,OM);function fee(t){var e=nr();return E.useEffect(()=>{e(A$e(t))},[e,t]),null}function wG(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=kJ("".concat(r).concat(e)),s=nr();return E.useLayoutEffect(()=>(s(NFe({zIndex:e,elementId:i,isPanorama:n})),()=>{s(kFe({zIndex:e,isPanorama:n}))}),[s,e,i,n]),E.createElement("g",{tabIndex:-1,id:i})}function MG(t){var{children:e,isPanorama:n}=t,r=Ct(vFe);if(!r||r.length===0)return e;var i=r.filter(a=>a<0),s=r.filter(a=>a>0);return E.createElement(E.Fragment,null,i.map(a=>E.createElement(wG,{key:a,zIndex:a,isPanorama:n})),e,s.map(a=>E.createElement(wG,{key:a,zIndex:a,isPanorama:n})))}var O$e=["children"];function L$e(t,e){if(t==null)return{};var n,r,i=j$e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r{var n=nO(),r=rO(),i=XY();if(!dl(n)||!dl(r))return null;var{children:s,otherAttributes:a,title:o,desc:l}=t,c,d;return a!=null&&(typeof a.tabIndex=="number"?c=a.tabIndex:c=i?0:void 0,typeof a.role=="string"?d=a.role:d=i?"application":void 0),E.createElement(LD,nw({},a,{title:o,desc:l,role:d,tabIndex:c,width:n,height:r,style:I$e,ref:e}),s)}),F$e=t=>{var{children:e}=t,n=Ct(aM);if(!n)return null;var{width:r,height:i,y:s,x:a}=n;return E.createElement(LD,{width:r,height:i,x:a,y:s},e)},EG=E.forwardRef((t,e)=>{var{children:n}=t,r=L$e(t,O$e),i=hs();return i?E.createElement(F$e,null,E.createElement(MG,{isPanorama:!0},n)):E.createElement(U$e,nw({ref:e},r),E.createElement(MG,{isPanorama:!1},n))});function z$e(){var t=nr(),[e,n]=E.useState(null),r=Ct(UPe);return E.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),s=i.width/e.offsetWidth;cr(s)&&s!==r&&t(yPe(s))}},[e,t,r]),n}function AG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function B$e(t){for(var e=1;e(r5e(),null);function rw(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var W$e=E.forwardRef((t,e)=>{var n,r,i=E.useRef(null),[s,a]=E.useState({containerWidth:rw((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:rw((r=t.style)===null||r===void 0?void 0:r.height)}),o=E.useCallback((c,d)=>{a(h=>{var g=Math.round(c),m=Math.round(d);return h.containerWidth===g&&h.containerHeight===m?h:{containerWidth:g,containerHeight:m}})},[]),l=E.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null&&typeof ResizeObserver<"u"){var{width:d,height:h}=c.getBoundingClientRect();o(d,h);var g=v=>{var{width:y,height:b}=v[0].contentRect;o(y,b)},m=new ResizeObserver(g);m.observe(c),i.current=m}},[e,o]);return E.useEffect(()=>()=>{var c=i.current;c?.disconnect()},[o]),E.createElement(E.Fragment,null,E.createElement(lM,{width:s.containerWidth,height:s.containerHeight}),E.createElement("div",Zf({ref:l},t)))}),q$e=E.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,s]=E.useState({containerWidth:rw(n),containerHeight:rw(r)}),a=E.useCallback((l,c)=>{s(d=>{var h=Math.round(l),g=Math.round(c);return d.containerWidth===h&&d.containerHeight===g?d:{containerWidth:h,containerHeight:g}})},[]),o=E.useCallback(l=>{if(typeof e=="function"&&e(l),l!=null){var{width:c,height:d}=l.getBoundingClientRect();a(c,d)}},[e,a]);return E.createElement(E.Fragment,null,E.createElement(lM,{width:i.containerWidth,height:i.containerHeight}),E.createElement("div",Zf({ref:o},t)))}),X$e=E.forwardRef((t,e)=>{var{width:n,height:r}=t;return E.createElement(E.Fragment,null,E.createElement(lM,{width:n,height:r}),E.createElement("div",Zf({ref:e},t)))}),K$e=E.forwardRef((t,e)=>{var{width:n,height:r}=t;return Sc(n)||Sc(r)?E.createElement(q$e,Zf({},t,{ref:e})):E.createElement(X$e,Zf({},t,{ref:e}))});function Y$e(t){return t===!0?W$e:K$e}var Z$e=E.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:s,onContextMenu:a,onDoubleClick:o,onMouseDown:l,onMouseEnter:c,onMouseLeave:d,onMouseMove:h,onMouseUp:g,onTouchEnd:m,onTouchMove:v,onTouchStart:y,style:b,width:x,responsive:M,dispatchTouchEvents:w=!0}=t,A=E.useRef(null),T=nr(),[R,C]=E.useState(null),[I,N]=E.useState(null),D=z$e(),z=tO(),j=z?.width>0?z.width:x,W=z?.height>0?z.height:i,P=E.useCallback(fe=>{D(fe),typeof e=="function"&&e(fe),C(fe),N(fe),fe!=null&&(A.current=fe)},[D,e,C,N]),$=E.useCallback(fe=>{T(eee(fe)),T(La({handler:s,reactEvent:fe}))},[T,s]),K=E.useCallback(fe=>{T(UR(fe)),T(La({handler:c,reactEvent:fe}))},[T,c]),G=E.useCallback(fe=>{T(FQ()),T(La({handler:d,reactEvent:fe}))},[T,d]),Z=E.useCallback(fe=>{T(UR(fe)),T(La({handler:h,reactEvent:fe}))},[T,h]),Q=E.useCallback(()=>{T(aee())},[T]),ee=E.useCallback(fe=>{T(see(fe.key))},[T]),H=E.useCallback(fe=>{T(La({handler:a,reactEvent:fe}))},[T,a]),q=E.useCallback(fe=>{T(La({handler:o,reactEvent:fe}))},[T,o]),te=E.useCallback(fe=>{T(La({handler:l,reactEvent:fe}))},[T,l]),ae=E.useCallback(fe=>{T(La({handler:g,reactEvent:fe}))},[T,g]),xe=E.useCallback(fe=>{T(La({handler:y,reactEvent:fe}))},[T,y]),re=E.useCallback(fe=>{w&&T(lee(fe)),T(La({handler:v,reactEvent:fe}))},[T,w,v]),pe=E.useCallback(fe=>{T(La({handler:m,reactEvent:fe}))},[T,m]),Ce=Y$e(M);return E.createElement(sJ.Provider,{value:R},E.createElement(hK.Provider,{value:I},E.createElement(Ce,{width:j??b?.width,height:W??b?.height,className:An("recharts-wrapper",r),style:B$e({position:"relative",cursor:"default",width:j,height:W},b),onClick:$,onContextMenu:H,onDoubleClick:q,onFocus:Q,onKeyDown:ee,onMouseDown:te,onMouseEnter:K,onMouseLeave:G,onMouseMove:Z,onMouseUp:ae,onTouchEnd:pe,onTouchMove:re,onTouchStart:xe,ref:P},E.createElement(G$e,null),n)))}),Q$e=["width","height","responsive","children","className","style","compact","title","desc"];function J$e(t,e){if(t==null)return{};var n,r,i=eVe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r{var{width:n,height:r,responsive:i,children:s,className:a,style:o,compact:l,title:c,desc:d}=t,h=J$e(t,Q$e),g=Xs(h);return l?E.createElement(E.Fragment,null,E.createElement(lM,{width:n,height:r}),E.createElement(EG,{otherAttributes:g,title:c,desc:d},s)):E.createElement(Z$e,{className:a,style:o,width:n,height:r,responsive:i??!1,onClick:t.onClick,onMouseLeave:t.onMouseLeave,onMouseEnter:t.onMouseEnter,onMouseMove:t.onMouseMove,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onContextMenu:t.onContextMenu,onDoubleClick:t.onDoubleClick,onTouchStart:t.onTouchStart,onTouchMove:t.onTouchMove,onTouchEnd:t.onTouchEnd},E.createElement(EG,{otherAttributes:g,title:c,desc:d,ref:e},E.createElement(Y8e,null,s)))});function FR(){return FR=Object.assign?Object.assign.bind():function(t){for(var e=1;eE.createElement(pee,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:rVe,tooltipPayloadSearcher:mL,categoricalChartProps:t,ref:e}));function sVe(t){var e=nr();return E.useEffect(()=>{e(T$e(t))},[e,t]),null}var aVe=["layout"];function zR(){return zR=Object.assign?Object.assign.bind():function(t){for(var e=1;e{var n=ei(t,mVe);return E.createElement(uVe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:pVe,tooltipPayloadSearcher:mL,categoricalChartProps:n,ref:e})}),xVe=["axis"],bVe=E.forwardRef((t,e)=>E.createElement(pee,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:xVe,tooltipPayloadSearcher:mL,categoricalChartProps:t,ref:e}));const __=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function vVe(t){const e=new Date;switch(t){case"7d":return new Date(e.getTime()-10080*60*1e3);case"30d":return new Date(e.getTime()-720*60*60*1e3);case"90d":return new Date(e.getTime()-2160*60*60*1e3);case"365d":return new Date(e.getTime()-365*24*60*60*1e3);case"all":return new Date(0)}}function yVe({archives:t,currency:e="$"}){const[n,r]=E.useState("30d"),i=E.useMemo(()=>{const g=vVe(n);return t.filter(m=>new Date(m.completed_at||m.created_at)>=g)},[t,n]),s=E.useMemo(()=>{const g=new Map;return i.forEach(m=>{const y=new Date(m.completed_at||m.created_at).toISOString().split("T")[0],b=g.get(y)||{date:y,filament:0,cost:0,prints:0};b.filament+=m.filament_used_grams||0,b.cost+=m.cost||0,b.prints+=1,g.set(y,b)}),Array.from(g.values()).sort((m,v)=>m.date.localeCompare(v.date)).map(m=>({...m,dateLabel:new Date(m.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),a=E.useMemo(()=>{if(n==="7d"||n==="30d")return s;const g=new Map;return i.forEach(m=>{const v=new Date(m.completed_at||m.created_at),y=new Date(v);y.setDate(v.getDate()-v.getDay());const b=y.toISOString().split("T")[0],x=g.get(b)||{week:b,filament:0,cost:0,prints:0};x.filament+=m.filament_used_grams||0,x.cost+=m.cost||0,x.prints+=1,g.set(b,x)}),Array.from(g.values()).sort((m,v)=>m.week.localeCompare(v.week)).map(m=>({date:m.week,dateLabel:`Week of ${new Date(m.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...m}))},[i,s,n]),o=E.useMemo(()=>{const g=new Map;return i.forEach(m=>{const y=(m.filament_type||"Unknown").split(", ");y.forEach(b=>{const x=(m.filament_used_grams||0)/y.length;g.set(b,(g.get(b)||0)+x)})}),Array.from(g.entries()).map(([m,v])=>({name:m,value:Math.round(v)})).sort((m,v)=>v.value-m.value)},[i]),l=E.useMemo(()=>{const g=new Date,m=[];for(let v=5;v>=0;v--){const y=new Date(g.getFullYear(),g.getMonth()-v,1),b=new Date(g.getFullYear(),g.getMonth()-v+1,0),x=y.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),M=t.filter(w=>{const A=new Date(w.completed_at||w.created_at);return A>=y&&A<=b});m.push({month:x,filament:Math.round(M.reduce((w,A)=>w+(A.filament_used_grams||0),0)),cost:M.reduce((w,A)=>w+(A.cost||0),0),prints:M.length})}return m},[t]),c=n==="7d"||n==="30d"?s:a,d=i.reduce((g,m)=>g+(m.filament_used_grams||0),0),h=i.reduce((g,m)=>g+(m.cost||0),0);return u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),u.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(g=>u.jsx("button",{onClick:()=>r(g),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===g?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:g==="all"?"All":g.replace("d","D")},g))})]}),u.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),u.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),u.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),u.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,h.toFixed(2)]}),u.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),u.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(d/i.length).toFixed(0):0,"g"]}),u.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(h/i.length).toFixed(2):"0.00"," avg"]})]})]}),c.length>0?u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[u.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),u.jsx(ZC,{width:"100%",height:250,children:u.jsxs(bVe,{data:c,children:[u.jsx("defs",{children:u.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[u.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),u.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),u.jsx(DR,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),u.jsx(LR,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),u.jsx(IR,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),u.jsx(mN,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:g=>[`${g.toFixed(0)}g`,"Filament"]}),u.jsx(QJ,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):u.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),u.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[u.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),o.length>0?u.jsxs("div",{className:"flex items-center gap-4",children:[u.jsx(ZC,{width:160,height:160,children:u.jsxs(gVe,{children:[u.jsx(DJ,{data:o,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:o.map((g,m)=>u.jsx(kb,{fill:__[m%__.length]},`cell-${m}`))}),u.jsx(mN,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:g=>[`${g}g`,"Usage"]})]})}),u.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:o.map((g,m)=>{const v=o.reduce((b,x)=>b+x.value,0),y=v>0?(g.value/v*100).toFixed(0):0;return u.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[u.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:__[m%__.length]}}),u.jsx("span",{className:"text-white truncate flex-1",children:g.name}),u.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[y,"%"]})]},g.name)})})]}):u.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[u.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),u.jsx(ZC,{width:"100%",height:200,children:u.jsxs(iVe,{data:l,children:[u.jsx(DR,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),u.jsx(LR,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),u.jsx(IR,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),u.jsx(mN,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(g,m)=>[m==="filament"?`${g}g`:m==="cost"?`${e}${g.toFixed(2)}`:g,m==="filament"?"Filament":m==="cost"?"Cost":"Prints"]}),u.jsx(qY,{}),u.jsx(UJ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function _Ve({id:t,title:e,children:n,isHidden:r,size:i,onToggleVisibility:s,onToggleSize:a}){const{attributes:o,listeners:l,setNodeRef:c,transform:d,transition:h,isDragging:g}=aK({id:t}),m={transform:xm.Transform.toString(d),transition:h,opacity:g?.5:1};return r?null:u.jsxs("div",{ref:c,style:{...m,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${g?"ring-2 ring-bambu-green shadow-lg":""}`,children:[u.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("button",{...o,...l,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:u.jsx(aP,{className:"w-4 h-4 text-bambu-gray"})}),u.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx("button",{onClick:a,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:`Size: ${i===1?"1/4":i===2?"1/2":"Full"} - Click to cycle`,children:i===4?u.jsx(Voe,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):u.jsx(zoe,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),u.jsx("button",{onClick:s,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:u.jsx(rP,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),u.jsx("div",{className:"p-4",children:n})]})}function SVe({widgets:t,storageKey:e,columns:n=4}){const r=()=>{const b={};return t.forEach(x=>{b[x.id]=x.defaultSize||4}),b},[i,s]=E.useState(()=>{const b=localStorage.getItem(e);if(b)try{const x=JSON.parse(b);return x.sizes||(x.sizes=r()),x}catch{}return{order:t.map(x=>x.id),hidden:t.filter(x=>x.defaultVisible===!1).map(x=>x.id),sizes:r()}}),[a,o]=E.useState(!1);E.useEffect(()=>{localStorage.setItem(e,JSON.stringify(i))},[i,e]),E.useEffect(()=>{const x=t.map(M=>M.id).filter(M=>!i.order.includes(M));x.length>0&&s(M=>({...M,order:[...M.order,...x]}))},[t,i.order]);const l=UX(lS(Bw,{activationConstraint:{distance:8}}),lS(zw,{coordinateGetter:oK})),c=b=>{const{active:x,over:M}=b;M&&x.id!==M.id&&s(w=>{const A=w.order.indexOf(x.id),T=w.order.indexOf(M.id);return{...w,order:Vw(w.order,A,T)}})},d=b=>{s(x=>({...x,hidden:x.hidden.includes(b)?x.hidden.filter(M=>M!==b):[...x.hidden,b]}))},h=b=>{s(x=>{const M=x.sizes[b]||4,w=M===1?2:M===2?4:1;return{...x,sizes:{...x.sizes,[b]:w}}})},g=()=>{const b={order:t.map(x=>x.id),hidden:t.filter(x=>x.defaultVisible===!1).map(x=>x.id),sizes:r()};s(b)},m=i.order.map(b=>t.find(x=>x.id===b)).filter(Boolean),v=m.filter(b=>!i.hidden.includes(b.id)),y=m.filter(b=>i.hidden.includes(b.id));return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-end gap-2",children:[y.length>0&&u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>o(!a),children:[u.jsx(t0,{className:"w-4 h-4"}),y.length," Hidden"]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:g,children:[u.jsx(X0,{className:"w-4 h-4"}),"Reset Layout"]})]}),a&&y.length>0&&u.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[u.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),u.jsx("div",{className:"flex flex-wrap gap-2",children:y.map(b=>u.jsxs("button",{onClick:()=>d(b.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[u.jsx(t0,{className:"w-3 h-3"}),b.title]},b.id))})]}),u.jsx(tK,{sensors:l,collisionDetection:HX,onDragEnd:c,children:u.jsx(iK,{items:v.map(b=>b.id),strategy:DD,children:u.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:v.map(b=>u.jsx(_Ve,{id:b.id,title:b.title,isHidden:i.hidden.includes(b.id),size:i.sizes[b.id]||2,onToggleVisibility:()=>d(b.id),onToggleSize:()=>h(b.id),children:b.component},b.id))})})}),v.length===0&&u.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[u.jsx("p",{children:"All widgets are hidden."}),u.jsx(Ue,{className:"mt-4",onClick:g,children:"Reset Layout"})]})]})}function wVe({stats:t,currency:e}){return u.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:u.jsx(n1,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),u.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:u.jsx(Qr,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),u.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:u.jsx(n1,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),u.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:u.jsx(XN,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),u.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:u.jsx(s0,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),u.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:u.jsx(XN,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),u.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function MVe({stats:t}){const e=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0;return u.jsxs("div",{className:"flex items-center gap-6",children:[u.jsxs("div",{className:"relative w-28 h-28",children:[u.jsxs("svg",{className:"w-full h-full -rotate-90",children:[u.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),u.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${e*3.02} 302`})]}),u.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:u.jsxs("span",{className:"text-xl font-bold text-white",children:[e,"%"]})})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Ss,{className:"w-4 h-4 text-bambu-green"}),u.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),u.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ud,{className:"w-4 h-4 text-red-400"}),u.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),u.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]})]})}function EVe({stats:t,printerMap:e}){const n=t?.average_time_accuracy;if(n==null)return u.jsx("div",{className:"flex items-center justify-center h-full",children:u.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No time accuracy data yet"})});const i=(Math.min(150,Math.max(50,n))-50)/100*100,a=(l=>l>=95&&l<=105?"#00ae42":l>105?"#3b82f6":"#f97316")(n),o=n-100;return u.jsxs("div",{className:"flex items-center gap-6",children:[u.jsxs("div",{className:"relative w-28 h-28",children:[u.jsxs("svg",{className:"w-full h-full -rotate-90",children:[u.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),u.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:a,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i*3.02} 302`})]}),u.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[u.jsxs("span",{className:"text-xl font-bold text-white",children:[n.toFixed(0),"%"]}),u.jsxs("span",{className:`text-xs ${o>=0?"text-blue-400":"text-orange-400"}`,children:[o>=0?"+":"",o.toFixed(0),"%"]})]})]}),u.jsxs("div",{className:"space-y-2 flex-1",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[u.jsx(E9,{className:"w-3 h-3"}),u.jsx("span",{children:"100% = perfect estimate"})]}),t?.time_accuracy_by_printer&&Object.keys(t.time_accuracy_by_printer).length>0&&u.jsx("div",{className:"space-y-1 mt-2",children:Object.entries(t.time_accuracy_by_printer).slice(0,3).map(([l,c])=>u.jsxs("div",{className:"flex items-center justify-between text-xs",children:[u.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(l)||`Printer ${l}`}),u.jsxs("span",{className:`font-medium ${c>=95&&c<=105?"text-bambu-green":c>105?"text-blue-400":"text-orange-400"}`,children:[c.toFixed(0),"%"]})]},l))})]})]})}function AVe({stats:t}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return u.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No filament data available"});const e=Object.entries(t.prints_by_filament_type).sort(([,n],[,r])=>r-n);return u.jsx("div",{className:"space-y-3",children:e.map(([n,r])=>{const i=Math.round(r/(t.total_prints||1)*100);return u.jsxs("div",{children:[u.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[u.jsx("span",{className:"text-white",children:n}),u.jsxs("span",{className:"text-bambu-gray",children:[r," prints"]})]}),u.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:u.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${i}%`}})})]},n)})})}function TVe({printDates:t}){return u.jsx(h3e,{printDates:t,months:4})}function CVe({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?u.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):u.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,r])=>u.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[u.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:u.jsx(ko,{className:"w-4 h-4 text-bambu-green"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),u.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function NVe({archives:t,currency:e}){return!t||t.length===0?u.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):u.jsx(yVe,{archives:t,currency:e})}function kVe(){const{data:t,isLoading:e}=Mt({queryKey:["archiveStats"],queryFn:Le.getArchiveStats}),{data:n}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),{data:r}=Mt({queryKey:["archives"],queryFn:()=>Le.getArchives(void 0,1e3,0)}),{data:i}=Mt({queryKey:["settings"],queryFn:Le.getSettings}),s=i?.currency||"$",a=new Map(n?.map(c=>[String(c.id),c.name])||[]),o=r?.map(c=>c.created_at)||[];if(e)return u.jsx("div",{className:"p-8",children:u.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const l=[{id:"quick-stats",title:"Quick Stats",component:u.jsx(wVe,{stats:t,currency:s}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:u.jsx(MVe,{stats:t}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:u.jsx(EVe,{stats:t,printerMap:a}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:u.jsx(AVe,{stats:t}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:u.jsx(TVe,{printDates:o}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:u.jsx(CVe,{stats:t,printerMap:a}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:u.jsx(NVe,{archives:r||[],currency:s}),defaultSize:4}];return u.jsxs("div",{className:"p-8",children:[u.jsxs("div",{className:"mb-6",children:[u.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),u.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),u.jsx(SVe,{widgets:l,storageKey:"bambusy-dashboard-layout"})]})}function RVe({plug:t,onEdit:e}){const n=Nn(),[r,i]=E.useState(!1),[s,a]=E.useState(!1),[o,l]=E.useState(!1),[c,d]=E.useState(!1),{data:h,isLoading:g,refetch:m}=Mt({queryKey:["smart-plug-status",t.id],queryFn:()=>Le.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:v}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),y=v?.find(R=>R.id===t.printer_id),b=At({mutationFn:R=>Le.controlSmartPlug(t.id,R),onSuccess:()=>{m()}}),x=At({mutationFn:R=>Le.updateSmartPlug(t.id,R),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),M=At({mutationFn:()=>Le.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),w=h?.state==="ON",A=h?.reachable??!1,T=b.isPending;return u.jsxs(u.Fragment,{children:[u.jsx(Lt,{className:"relative",children:u.jsxs(Ft,{className:"p-4",children:[u.jsxs("div",{className:"flex items-start justify-between mb-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:`p-2 rounded-lg ${A?w?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:u.jsx(Nx,{className:`w-5 h-5 ${A?w?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),u.jsxs("div",{children:[u.jsx("h3",{className:"font-medium text-white",children:t.name}),u.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),u.jsx("div",{className:"flex items-center gap-2",children:g?u.jsx(Ot,{className:"w-4 h-4 text-bambu-gray animate-spin"}):A?u.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[u.jsx(T9,{className:"w-4 h-4 text-bambu-green"}),u.jsx("span",{className:w?"text-bambu-green":"text-bambu-gray",children:h?.state||"Unknown"})]}):u.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[u.jsx(fP,{className:"w-4 h-4"}),u.jsx("span",{children:"Offline"})]})})]}),y&&u.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[u.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),u.jsx("span",{className:"text-sm text-white",children:y.name})]}),(t.power_alert_enabled||t.schedule_enabled)&&u.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.power_alert_enabled&&u.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full",children:[u.jsx(ff,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&u.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded-full",children:[u.jsx(Wr,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?`On ${t.schedule_on_time}`:`Off ${t.schedule_off_time}`]})]}),u.jsxs("div",{className:"flex gap-2 mb-3",children:[u.jsxs(Ue,{size:"sm",variant:w?"primary":"secondary",disabled:!A||T,onClick:()=>a(!0),className:"flex-1",children:[T?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(dd,{className:"w-4 h-4"}),"On"]}),u.jsxs(Ue,{size:"sm",variant:w?"secondary":"primary",disabled:!A||T,onClick:()=>l(!0),className:"flex-1",children:[T?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(cP,{className:"w-4 h-4"}),"Off"]})]}),u.jsxs("button",{onClick:()=>d(!c),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(fw,{className:"w-4 h-4"}),"Automation Settings"]}),u.jsx("span",{children:c?"-":"+"})]}),c&&u.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Enabled"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:t.enabled,onChange:R=>x.mutate({enabled:R.target.checked}),className:"sr-only peer"}),u.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Auto On"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:R=>x.mutate({auto_on:R.target.checked}),className:"sr-only peer"}),u.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:R=>x.mutate({auto_off:R.target.checked}),className:"sr-only peer"}),u.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.auto_off&&u.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsxs("button",{onClick:()=>x.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[u.jsx(Qr,{className:"w-4 h-4"}),"Time"]}),u.jsxs("button",{onClick:()=>x.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[u.jsx(Ip,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),u.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:R=>x.mutate({off_delay_minutes:parseInt(R.target.value)||5}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}):u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),u.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:R=>x.mutate({off_temp_threshold:parseInt(R.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),u.jsxs("div",{className:"flex gap-2 pt-2",children:[u.jsxs(Ue,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[u.jsx(lP,{className:"w-4 h-4"}),"Edit"]}),u.jsx(Ue,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:u.jsx(Qn,{className:"w-4 h-4"})})]})]})]})}),r&&u.jsx(Zi,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{M.mutate(),i(!1)},onCancel:()=>i(!1)}),s&&u.jsx(Zi,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{b.mutate("on"),a(!1)},onCancel:()=>a(!1)}),o&&u.jsx(Zi,{title:"Turn Off Smart Plug",message:`Are you sure you want to turn off "${t.name}"? This will cut power to the connected device.`,confirmText:"Turn Off",variant:"danger",onConfirm:()=>{b.mutate("off"),l(!1)},onCancel:()=>l(!1)})]})}function PVe({plug:t,onClose:e}){const n=Nn(),r=!!t,[i,s]=E.useState(t?.name||""),[a,o]=E.useState(t?.ip_address||""),[l,c]=E.useState(t?.username||""),[d,h]=E.useState(t?.password||""),[g,m]=E.useState(t?.printer_id||null),[v,y]=E.useState(null),[b,x]=E.useState(null),[M,w]=E.useState(t?.power_alert_enabled||!1),[A,T]=E.useState(t?.power_alert_high?.toString()||""),[R,C]=E.useState(t?.power_alert_low?.toString()||""),[I,N]=E.useState(t?.schedule_enabled||!1),[D,z]=E.useState(t?.schedule_on_time||""),[j,W]=E.useState(t?.schedule_off_time||""),{data:P}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),{data:$}=Mt({queryKey:["smart-plugs"],queryFn:Le.getSmartPlugs});E.useEffect(()=>{const q=te=>{te.key==="Escape"&&e()};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[e]);const K=At({mutationFn:()=>Le.testSmartPlugConnection(a,l||null,d||null),onSuccess:q=>{y(q),x(null),!i&&q.device_name&&s(q.device_name)},onError:q=>{y(null),x(q.message)}}),G=At({mutationFn:q=>Le.createSmartPlug(q),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:q=>{x(q.message)}}),Z=At({mutationFn:q=>Le.updateSmartPlug(t.id,q),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:q=>{x(q.message)}}),Q=P?.filter(q=>!$?.some(ae=>ae.printer_id===q.id&&ae.id!==t?.id)),ee=q=>{if(q.preventDefault(),x(null),!i.trim()){x("Name is required");return}if(!a.trim()){x("IP address is required");return}const te={name:i.trim(),ip_address:a.trim(),username:l.trim()||null,password:d.trim()||null,printer_id:g,power_alert_enabled:M,power_alert_high:A?parseFloat(A):null,power_alert_low:R?parseFloat(R):null,schedule_enabled:I,schedule_on_time:D||null,schedule_off_time:j||null};r?Z.mutate(te):G.mutate(te)},H=G.isPending||Z.isPending;return u.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:u.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:q=>q.stopPropagation(),children:[u.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[u.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),u.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("form",{onSubmit:ee,className:"p-6 space-y-4",children:[b&&u.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:b}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx("input",{type:"text",value:a,onChange:q=>{o(q.target.value),y(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),u.jsxs(Ue,{type:"button",variant:"secondary",onClick:()=>K.mutate(),disabled:!a.trim()||K.isPending,children:[K.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(T9,{className:"w-4 h-4"}),"Test"]})]})]}),v&&u.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${v.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:v.success?u.jsxs(u.Fragment,{children:[u.jsx(Ss,{className:"w-5 h-5"}),u.jsxs("div",{children:[u.jsx("p",{className:"font-medium",children:"Connected!"}),u.jsxs("p",{className:"text-sm opacity-80",children:[v.device_name&&`Device: ${v.device_name} - `,"State: ",v.state]})]})]}):u.jsxs(u.Fragment,{children:[u.jsx(fP,{className:"w-5 h-5"}),u.jsx("span",{children:"Connection failed"})]})}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),u.jsx("input",{type:"text",value:i,onChange:q=>s(q.target.value),placeholder:"Living Room Plug",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),u.jsx("input",{type:"text",value:l,onChange:q=>c(q.target.value),placeholder:"admin",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),u.jsx("input",{type:"password",value:d,onChange:q=>h(q.target.value),placeholder:"********",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),u.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),u.jsxs("select",{value:g??"",onChange:q=>m(q.target.value?Number(q.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"",children:"No printer (manual control only)"}),Q?.map(q=>u.jsx("option",{value:q.id,children:q.name},q.id))]}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),u.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[u.jsxs("div",{className:"flex items-center justify-between mb-3",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ff,{className:"w-4 h-4 text-bambu-green"}),u.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:M,onChange:q=>w(q.target.checked),className:"sr-only peer"}),u.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),M&&u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),u.jsx("input",{type:"number",value:A,onChange:q=>T(q.target.value),placeholder:"e.g. 200",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),u.jsx("input",{type:"number",value:R,onChange:q=>C(q.target.value),placeholder:"e.g. 10",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Get notified when power consumption crosses these thresholds. Leave empty to disable that direction."})]})]}),u.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[u.jsxs("div",{className:"flex items-center justify-between mb-3",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Qr,{className:"w-4 h-4 text-bambu-green"}),u.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:I,onChange:q=>N(q.target.checked),className:"sr-only peer"}),u.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),I&&u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),u.jsx("input",{type:"time",value:D,onChange:q=>z(q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),u.jsx("input",{type:"time",value:j,onChange:q=>W(q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Automatically turn the plug on/off at these times daily. Leave empty to skip that action."})]})]}),u.jsxs("div",{className:"flex gap-3 pt-2",children:[u.jsx(Ue,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),u.jsxs(Ue,{type:"submit",disabled:H,className:"flex-1",children:[H?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Qo,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function er({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return u.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:r,className:`relative inline-flex w-9 h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:u.jsx("span",{className:`pointer-events-none absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const DVe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function OVe({provider:t,onEdit:e}){const n=Nn(),[r,i]=E.useState(!1),[s,a]=E.useState(!1),[o,l]=E.useState(null),{data:c}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),d=c?.find(y=>y.id===t.printer_id),h=At({mutationFn:y=>Le.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=At({mutationFn:()=>Le.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=At({mutationFn:()=>Le.testNotificationProvider(t.id),onSuccess:y=>{l(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{l({success:!1,message:y.message})}}),v=y=>y||"";return u.jsxs(u.Fragment,{children:[u.jsx(Lt,{className:"relative",children:u.jsxs(Ft,{className:"p-4",children:[u.jsxs("div",{className:"flex items-start justify-between mb-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:u.jsx(ff,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),u.jsxs("div",{children:[u.jsx("h3",{className:"font-medium text-white",children:t.name}),u.jsx("p",{className:"text-sm text-bambu-gray",children:DVe[t.provider_type]||t.provider_type})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[t.last_success&&u.jsxs("span",{className:"text-xs text-bambu-green",children:["Last sent: ",new Date(t.last_success).toLocaleDateString()]}),t.last_error&&t.last_error_at&&(!t.last_success||new Date(t.last_error_at)>new Date(t.last_success))&&u.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"})]})]}),d&&u.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[u.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),u.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&u.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:u.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),u.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&u.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&u.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&u.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&u.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&u.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&u.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&u.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&u.jsx("span",{className:"px-2 py-0.5 bg-cyan-500/20 text-cyan-400 text-xs rounded",children:"Low Filament"}),t.on_maintenance_due&&u.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.quiet_hours_enabled&&u.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[u.jsx(t1,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&u.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[u.jsx(Wr,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),u.jsx("div",{className:"mb-3",children:u.jsxs(Ue,{size:"sm",variant:"secondary",disabled:m.isPending,onClick:()=>{l(null),m.mutate()},className:"w-full",children:[m.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(uP,{className:"w-4 h-4"}),"Send Test Notification"]})}),o&&u.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${o.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[o.success?u.jsx(Ss,{className:"w-4 h-4"}):u.jsx(ud,{className:"w-4 h-4"}),u.jsx("span",{children:o.message})]}),u.jsxs("button",{onClick:()=>a(!s),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(fw,{className:"w-4 h-4"}),"Event Settings"]}),s?u.jsx(cw,{className:"w-4 h-4"}):u.jsx(Qf,{className:"w-4 h-4"})]}),s&&u.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Enabled"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),u.jsx(er,{checked:t.enabled,onChange:y=>h.mutate({enabled:y})})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Print Started"}),u.jsx(er,{checked:t.on_print_start,onChange:y=>h.mutate({on_print_start:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),u.jsx(er,{checked:t.on_print_complete,onChange:y=>h.mutate({on_print_complete:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),u.jsx(er,{checked:t.on_print_failed,onChange:y=>h.mutate({on_print_failed:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),u.jsx(er,{checked:t.on_print_stopped,onChange:y=>h.mutate({on_print_stopped:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),u.jsx(er,{checked:t.on_print_progress,onChange:y=>h.mutate({on_print_progress:y})})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),u.jsx(er,{checked:t.on_printer_offline,onChange:y=>h.mutate({on_printer_offline:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),u.jsx(er,{checked:t.on_printer_error,onChange:y=>h.mutate({on_printer_error:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),u.jsx(er,{checked:t.on_filament_low,onChange:y=>h.mutate({on_filament_low:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),u.jsx(er,{checked:t.on_maintenance_due??!1,onChange:y=>h.mutate({on_maintenance_due:y})})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(t1,{className:"w-4 h-4 text-purple-400"}),u.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),u.jsx(er,{checked:t.quiet_hours_enabled,onChange:y=>h.mutate({quiet_hours_enabled:y})})]}),t.quiet_hours_enabled&&u.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Qr,{className:"w-4 h-4 text-bambu-gray"}),u.jsxs("span",{className:"text-sm text-white",children:[v(t.quiet_hours_start)||"22:00"," - ",v(t.quiet_hours_end)||"07:00"]})]}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Wr,{className:"w-4 h-4 text-emerald-400"}),u.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),u.jsx(er,{checked:t.daily_digest_enabled,onChange:y=>h.mutate({daily_digest_enabled:y})})]}),t.daily_digest_enabled&&u.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Qr,{className:"w-4 h-4 text-bambu-gray"}),u.jsxs("span",{className:"text-sm text-white",children:["Send at ",v(t.daily_digest_time)||"08:00"]})]}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),u.jsxs("div",{className:"flex gap-2 pt-2",children:[u.jsxs(Ue,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[u.jsx(lP,{className:"w-4 h-4"}),"Edit"]}),u.jsx(Ue,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:u.jsx(Qn,{className:"w-4 h-4"})})]})]})]})}),r&&u.jsx(Zi,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{g.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const NG=[{value:"discord",label:"Discord",description:"Send to Discord channel via webhook"},{value:"telegram",label:"Telegram",description:"Notifications via Telegram bot"},{value:"ntfy",label:"ntfy",description:"Free, self-hostable push notifications"},{value:"pushover",label:"Pushover",description:"Simple, reliable push notifications"},{value:"email",label:"Email",description:"SMTP email notifications"},{value:"callmebot",label:"CallMeBot/WhatsApp",description:"Free WhatsApp notifications via CallMeBot"},{value:"webhook",label:"Webhook",description:"Generic HTTP POST to any URL"}];function LVe({provider:t,onClose:e}){const n=Nn(),r=!!t,[i,s]=E.useState(t?.name||""),[a,o]=E.useState(t?.provider_type||"discord"),[l,c]=E.useState(t?.printer_id||null),[d,h]=E.useState(t?.quiet_hours_enabled||!1),[g,m]=E.useState(t?.quiet_hours_start||"22:00"),[v,y]=E.useState(t?.quiet_hours_end||"07:00"),[b,x]=E.useState(t?.daily_digest_enabled||!1),[M,w]=E.useState(t?.daily_digest_time||"08:00"),[A,T]=E.useState(t?.on_print_start??!1),[R,C]=E.useState(t?.on_print_complete??!0),[I,N]=E.useState(t?.on_print_failed??!0),[D,z]=E.useState(t?.on_print_stopped??!0),[j,W]=E.useState(t?.on_print_progress??!1),[P,$]=E.useState(t?.on_printer_offline??!1),[K,G]=E.useState(t?.on_printer_error??!1),[Z,Q]=E.useState(t?.on_filament_low??!1),[ee,H]=E.useState(t?.on_maintenance_due??!1),[q,te]=E.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([V,J])=>[V,String(J)])):{}),[ae,xe]=E.useState(null),[re,pe]=E.useState(null),{data:Ce}=Mt({queryKey:["printers"],queryFn:Le.getPrinters});E.useEffect(()=>{const V=J=>{J.key==="Escape"&&e()};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[e]);const fe=At({mutationFn:()=>Le.testNotificationConfig({provider_type:a,config:q}),onSuccess:V=>{xe(V),pe(null)},onError:V=>{xe({success:!1,message:V.message})}}),Se=At({mutationFn:V=>Le.createNotificationProvider(V),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:V=>{pe(V.message)}}),Re=At({mutationFn:V=>Le.updateNotificationProvider(t.id,V),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:V=>{pe(V.message)}}),ue=V=>{if(V.preventDefault(),pe(null),!i.trim()){pe("Name is required");return}const J=F(a);for(const Ae of J)if(!q[Ae.key]?.trim()){pe(`${Ae.label} is required`);return}const le={name:i.trim(),provider_type:a,config:q,printer_id:l,quiet_hours_enabled:d,quiet_hours_start:d?g:null,quiet_hours_end:d?v:null,daily_digest_enabled:b,daily_digest_time:b?M:null,on_print_start:A,on_print_complete:R,on_print_failed:I,on_print_stopped:D,on_print_progress:j,on_printer_offline:P,on_printer_error:K,on_filament_low:Z,on_maintenance_due:ee};r?Re.mutate(le):Se.mutate(le)},ct=Se.isPending||Re.isPending,B=V=>{switch(V){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambuddy",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"auth_header",label:"Authorization",placeholder:"Bearer token (optional)",type:"password",required:!1},{key:"field_title",label:"Title Field Name",placeholder:"title",type:"text",required:!1},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1}];default:return[]}},F=V=>B(V).filter(J=>J.required),ie=B(a);return u.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:u.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8",onClick:V=>V.stopPropagation(),children:[u.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[u.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),u.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("form",{onSubmit:ue,className:"p-6 space-y-4",children:[re&&u.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:re}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),u.jsx("input",{type:"text",value:i,onChange:V=>s(V.target.value),placeholder:"My Notifications",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),u.jsx("select",{value:a,onChange:V=>{o(V.target.value),te({}),xe(null)},disabled:r,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:NG.map(V=>u.jsx("option",{value:V.value,children:V.label},V.value))}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:NG.find(V=>V.value===a)?.description})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),ie.map(V=>u.jsxs("div",{children:[u.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[V.label," ",V.required&&"*"]}),V.type==="select"&&V.options?u.jsx("select",{value:q[V.key]||V.options[0]?.value||"",onChange:J=>{te({...q,[V.key]:J.target.value}),xe(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:V.options.map(J=>u.jsx("option",{value:J.value,children:J.label},J.value))}):u.jsx("input",{type:V.type,value:q[V.key]||"",onChange:J=>{te({...q,[V.key]:J.target.value}),xe(null)},placeholder:V.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},V.key))]}),u.jsx("div",{className:"flex gap-2",children:u.jsxs(Ue,{type:"button",variant:"secondary",onClick:()=>{xe(null),fe.mutate()},disabled:fe.isPending||!q[F(a)[0]?.key],className:"flex-1",children:[fe.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(uP,{className:"w-4 h-4"}),"Test Configuration"]})}),ae&&u.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ae.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:ae.success?u.jsxs(u.Fragment,{children:[u.jsx(Ss,{className:"w-5 h-5"}),u.jsx("span",{children:ae.message})]}):u.jsxs(u.Fragment,{children:[u.jsx(ud,{className:"w-5 h-5"}),u.jsx("span",{children:ae.message})]})}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),u.jsxs("select",{value:l??"",onChange:V=>c(V.target.value?Number(V.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"",children:"All printers"}),Ce?.map(V=>u.jsx("option",{value:V.id,children:V.name},V.id))]}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),u.jsx(er,{checked:d,onChange:h})]}),d&&u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),u.jsx("input",{type:"time",value:g,onChange:V=>m(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),u.jsx("input",{type:"time",value:v,onChange:V=>y(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),u.jsx(er,{checked:b,onChange:x})]}),b&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),u.jsx("input",{type:"time",value:M,onChange:V=>w(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),u.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[u.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),u.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Start"}),u.jsx(er,{checked:A,onChange:T})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Complete"}),u.jsx(er,{checked:R,onChange:C})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Failed"}),u.jsx(er,{checked:I,onChange:N})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Stopped"}),u.jsx(er,{checked:D,onChange:z})]}),u.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[u.jsxs("div",{children:[u.jsx("span",{className:"text-sm text-white",children:"Progress"}),u.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),u.jsx(er,{checked:j,onChange:W})]})]})]}),u.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[u.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),u.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Offline"}),u.jsx(er,{checked:P,onChange:$})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Error"}),u.jsx(er,{checked:K,onChange:G})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),u.jsx(er,{checked:Z,onChange:Q})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),u.jsx(er,{checked:ee,onChange:H})]})]})]})]}),u.jsxs("div",{className:"flex gap-3 pt-2",children:[u.jsx(Ue,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),u.jsxs(Ue,{type:"submit",disabled:ct,className:"flex-1",children:[ct?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Qo,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function jVe({template:t,onClose:e}){const n=Nn(),r=E.useRef(null),[i,s]=E.useState(t.title_template),[a,o]=E.useState(t.body_template),[l,c]=E.useState(null),[d,h]=E.useState(!0),{data:g}=Mt({queryKey:["template-variables"],queryFn:Le.getTemplateVariables}),m=g?.find(T=>T.event_type===t.event_type),{data:v,isLoading:y}=Mt({queryKey:["template-preview",t.event_type,i,a],queryFn:()=>Le.previewTemplate({event_type:t.event_type,title_template:i,body_template:a}),enabled:d&&i.length>0&&a.length>0});E.useEffect(()=>{const T=R=>{R.key==="Escape"&&e()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[e]);const b=At({mutationFn:T=>Le.updateNotificationTemplate(t.id,T),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:T=>{c(T.message)}}),x=At({mutationFn:()=>Le.resetNotificationTemplate(t.id),onSuccess:T=>{s(T.title_template),o(T.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:T=>{c(T.message)}}),M=T=>{if(T.preventDefault(),c(null),!i.trim()){c("Title is required");return}if(!a.trim()){c("Body is required");return}b.mutate({title_template:i,body_template:a})},w=T=>{const R=r.current;if(!R)return;const C=R.selectionStart,I=R.selectionEnd,N=a,D=N.substring(0,C),z=N.substring(I),j=D+`{${T}}`+z;o(j),setTimeout(()=>{R.focus();const W=C+T.length+2;R.setSelectionRange(W,W)},0)},A=i!==t.title_template||a!==t.body_template;return u.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:u.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[u.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),u.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:u.jsx(Qt,{className:"w-5 h-5 text-bambu-gray"})})]}),u.jsxs("form",{onSubmit:M,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[l&&u.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:l}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),u.jsx("input",{type:"text",value:i,onChange:T=>s(T.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green",placeholder:"Notification title..."})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),u.jsx("textarea",{ref:r,value:a,onChange:T=>o(T.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:"Notification body..."})]}),m&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),u.jsx("div",{className:"flex flex-wrap gap-2",children:m.variables.map(T=>u.jsxs("button",{type:"button",onClick:()=>w(T),className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors",children:[u.jsx(li,{className:"w-3 h-3"}),T]},T))}),u.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center justify-between mb-2",children:[u.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[u.jsx(t0,{className:"w-4 h-4"}),"Live Preview"]}),u.jsx("button",{type:"button",onClick:()=>h(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&u.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:y?u.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[u.jsx(Ot,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):v?u.jsxs(u.Fragment,{children:[u.jsxs("div",{children:[u.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),u.jsx("div",{className:"text-white font-medium",children:v.title})]}),u.jsxs("div",{children:[u.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),u.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:v.body})]})]}):u.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),u.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[u.jsxs(Ue,{type:"button",variant:"ghost",onClick:()=>x.mutate(),disabled:x.isPending,className:"text-orange-400 hover:text-orange-300",children:[x.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin mr-2"}):u.jsx(X0,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Ue,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),u.jsxs(Ue,{onClick:M,disabled:b.isPending||!A,children:[b.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin mr-2"}):u.jsx(Qo,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const IVe={print_start:"Print Started",print_complete:"Print Complete",print_failed:"Print Failed",print_stopped:"Print Stopped",print_progress:"Progress",printer_offline:"Printer Offline",printer_error:"Printer Error",filament_low:"Low Filament",maintenance_due:"Maintenance Due",test:"Test"},UVe={print_start:"text-blue-400",print_complete:"text-bambu-green",print_failed:"text-red-400",print_stopped:"text-orange-400",print_progress:"text-yellow-400",printer_offline:"text-gray-400",printer_error:"text-rose-400",filament_low:"text-cyan-400",maintenance_due:"text-purple-400",test:"text-bambu-gray"};function FVe({onClose:t}){const e=Nn(),{showToast:n}=Di(),[r,i]=E.useState(7),[s,a]=E.useState(null),[o,l]=E.useState(!1),{data:c,isLoading:d,refetch:h,isRefetching:g}=Mt({queryKey:["notification-logs",r,o],queryFn:()=>Le.getNotificationLogs({days:r,limit:100,success:o?!1:void 0})}),{data:m}=Mt({queryKey:["notification-log-stats",r],queryFn:()=>Le.getNotificationLogStats(r)}),v=At({mutationFn:()=>Le.clearNotificationLogs(30),onSuccess:b=>{n(b.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:b=>{n(`Failed to clear logs: ${b.message}`,"error")}}),y=b=>{const x=new Date(b),w=new Date().getTime()-x.getTime();return w<6e4?"Just now":w<36e5?`${Math.floor(w/6e4)}m ago`:w<864e5?`${Math.floor(w/36e5)}h ago`:x.toLocaleDateString()+" "+x.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})};return u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:u.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col",children:[u.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx(KN,{className:"w-5 h-5 text-bambu-green"}),u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),u.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),m&&u.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:u.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[u.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",u.jsx("span",{className:"text-white font-medium",children:m.total})," notifications"]}),u.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[u.jsx(Ss,{className:"w-4 h-4"}),m.success_count," sent"]}),m.failure_count>0&&u.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[u.jsx(ud,{className:"w-4 h-4"}),m.failure_count," failed"]})]})}),u.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[u.jsxs("select",{value:r,onChange:b=>i(Number(b.target.value)),className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:[u.jsx("option",{value:1,children:"Last 24 hours"}),u.jsx("option",{value:7,children:"Last 7 days"}),u.jsx("option",{value:30,children:"Last 30 days"}),u.jsx("option",{value:90,children:"Last 90 days"})]}),u.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:o,onChange:b=>l(b.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),u.jsx("div",{className:"flex-1"}),u.jsxs(Ue,{size:"sm",variant:"secondary",onClick:()=>h(),disabled:g,children:[g?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(qs,{className:"w-4 h-4"}),"Refresh"]}),u.jsxs(Ue,{size:"sm",variant:"secondary",onClick:()=>v.mutate(),disabled:v.isPending,className:"text-red-400 hover:text-red-300",children:[v.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Qn,{className:"w-4 h-4"}),"Clear Old"]})]}),u.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:d?u.jsx("div",{className:"flex justify-center py-12",children:u.jsx(Ot,{className:"w-6 h-6 text-bambu-green animate-spin"})}):c&&c.length>0?u.jsx("div",{className:"space-y-2",children:c.map(b=>u.jsx(zVe,{log:b,isExpanded:s===b.id,onToggle:()=>a(s===b.id?null:b.id),formatDate:y},b.id))}):u.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[u.jsx(KN,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),u.jsx("p",{className:"text-sm",children:o?"No failed notifications":"No notifications logged"})]})})]})})}function zVe({log:t,isExpanded:e,onToggle:n,formatDate:r}){return u.jsxs("div",{className:`border rounded-lg overflow-hidden transition-colors ${t.success?"border-bambu-dark-tertiary bg-bambu-dark/30":"border-red-500/30 bg-red-500/5"}`,children:[u.jsxs("button",{className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-bambu-dark/50 transition-colors",onClick:n,children:[t.success?u.jsx(Ss,{className:"w-4 h-4 text-bambu-green shrink-0"}):u.jsx(ud,{className:"w-4 h-4 text-red-400 shrink-0"}),u.jsx("span",{className:`text-xs font-medium ${UVe[t.event_type]||"text-bambu-gray"}`,children:IVe[t.event_type]||t.event_type}),u.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&u.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),u.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?u.jsx(cw,{className:"w-4 h-4 text-bambu-gray shrink-0"}):u.jsx(Qf,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&u.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),u.jsx("p",{className:"text-sm text-white",children:t.title})]}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),u.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),u.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),u.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[u.jsxs("span",{children:["Provider: ",t.provider_type]}),u.jsxs("span",{children:["Time: ",new Date(t.created_at).toLocaleString()]})]})]})]})}const S_=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:u.jsx(dP,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:u.jsx(ff,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:u.jsx(rc,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:u.jsx(Nx,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:u.jsx(ko,{className:"w-4 h-4"}),default:!1,description:"Printer info (access codes excluded)"},{id:"filaments",labelKey:"backup.categories.filaments",defaultLabel:"Filament Inventory",icon:u.jsx(Zoe,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:u.jsx(Df,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:u.jsx(eP,{className:"w-4 h-4"}),default:!1,description:"All print data + files (3MF, thumbnails, photos)"}];function BVe({onClose:t,onExport:e}){const{t:n}=sw(),[r,i]=E.useState(()=>{const v={};return S_.forEach(y=>{v[y.id]=y.default}),v}),[s,a]=E.useState(!1),[o,l]=E.useState(!1);E.useEffect(()=>{const v=y=>{y.key==="Escape"&&t()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[t]);const c=v=>{i(y=>({...y,[v]:!y[v]}))},d=()=>{const v={};S_.forEach(y=>{v[y.id]=!0}),i(v)},h=()=>{const v={};S_.forEach(y=>{v[y.id]=!1}),i(v)},g=Object.values(r).filter(Boolean).length,m=async()=>{l(!0);try{await e({...r,access_codes:s&&r.printers})}finally{l(!1)}};return u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:o?void 0:t,children:u.jsx(Lt,{className:"w-full max-w-lg",onClick:v=>v.stopPropagation(),children:u.jsxs(Ft,{className:"p-0",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:u.jsx(va,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-lg font-semibold text-white",children:n("backup.exportTitle",{defaultValue:"Export Backup"})}),u.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.selectCategories",{defaultValue:"Select data to include"})})]})]}),u.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("div",{className:"flex gap-2 px-4 pt-4",children:[u.jsx("button",{onClick:d,disabled:o,className:"text-sm text-bambu-green hover:text-bambu-green/80 disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectAll",{defaultValue:"Select All"})}),u.jsx("span",{className:"text-bambu-gray",children:"|"}),u.jsx("button",{onClick:h,disabled:o,className:"text-sm text-bambu-gray hover:text-white disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectNone",{defaultValue:"Select None"})})]}),u.jsx("div",{className:`p-4 space-y-2 max-h-[400px] overflow-y-auto ${o?"opacity-50 pointer-events-none":""}`,children:S_.map(v=>u.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-colors ${r[v.id]?"bg-bambu-green/10 border border-bambu-green/30":"bg-bambu-dark hover:bg-bambu-dark-tertiary border border-transparent"}`,children:[u.jsx("input",{type:"checkbox",checked:r[v.id],onChange:()=>c(v.id),disabled:o,className:"w-4 h-4 rounded border-bambu-gray bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),u.jsx("div",{className:`${r[v.id]?"text-bambu-green":"text-bambu-gray"}`,children:v.icon}),u.jsxs("div",{className:"flex-1",children:[u.jsx("div",{className:"text-white text-sm font-medium",children:n(v.labelKey,{defaultValue:v.defaultLabel})}),u.jsx("div",{className:"text-xs text-bambu-gray",children:v.description})]})]},v.id))}),r.archives&&u.jsx("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:u.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[u.jsx(eP,{className:"w-4 h-4 text-yellow-500 mt-0.5 flex-shrink-0"}),u.jsxs("div",{className:"text-yellow-200 dark:text-yellow-200 text-yellow-700",children:[u.jsx("span",{className:"font-medium",children:"ZIP file will be created."}),u.jsx("span",{className:"text-yellow-600 dark:text-yellow-200/70",children:" Includes all 3MF files, thumbnails, timelapses, and photos. This may take a while and result in a large file."})]})]})}),r.printers&&u.jsxs("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-start gap-2",children:[u.jsx(y9,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),u.jsxs("div",{children:[u.jsx("p",{className:"text-sm font-medium text-white",children:"Include Access Codes"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"For transferring to another machine"})]})]}),u.jsx(er,{checked:s,onChange:a})]}),s&&u.jsx("div",{className:"mt-2 p-2 rounded bg-orange-500/10 border border-orange-500/30",children:u.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[u.jsx(ws,{className:"w-3 h-3 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),u.jsx("span",{className:"text-orange-700 dark:text-orange-200",children:"Access codes will be included in plain text. Keep this backup file secure!"})]})})]}),u.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[u.jsx("span",{className:"text-sm text-bambu-gray",children:n("backup.selectedCount",{count:g,defaultValue:`${g} categories selected`})}),u.jsxs("div",{className:"flex gap-3",children:[u.jsx(Ue,{variant:"secondary",onClick:t,disabled:o,children:n("common.cancel",{defaultValue:"Cancel"})}),u.jsx(Ue,{onClick:m,disabled:g===0||o,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50 disabled:cursor-not-allowed min-w-[100px]",children:o?u.jsxs(u.Fragment,{children:[u.jsx(Ot,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):u.jsxs(u.Fragment,{children:[u.jsx(va,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const kG={settings:"Settings",notification_providers:"Notification Providers",notification_templates:"Notification Templates",smart_plugs:"Smart Plugs",printers:"Printers",filaments:"Filaments",maintenance_types:"Maintenance Types",archives:"Archives"};function HVe({onClose:t,onRestore:e,onSuccess:n}){const[r,i]=E.useState("options"),[s,a]=E.useState(!1),[o,l]=E.useState(null),[c,d]=E.useState(null),[h,g]=E.useState(new Set),m=E.useRef(null);E.useEffect(()=>{const w=A=>{A.key==="Escape"&&r!=="restoring"&&t()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[t,r]);const v=w=>{const A=w.target.files?.[0];A&&l(A)},y=async()=>{if(o){i("restoring");try{const w=await e(o,s);d(w),i("result"),w.success&&n()}catch{d({success:!1,message:"Failed to restore backup. Please check the file format."}),i("result")}}},b=w=>{g(A=>{const T=new Set(A);return T.has(w)?T.delete(w):T.add(w),T})},x=c?.restored?Object.values(c.restored).reduce((w,A)=>w+A,0)+(c.files_restored||0):0,M=c?.total_skipped||0;return u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onMouseDown:w=>{w.target===w.currentTarget&&r!=="restoring"&&t()},children:u.jsx(Lt,{className:"w-full max-w-lg",children:u.jsxs(Ft,{className:"p-0",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:`p-2 rounded-full ${r==="result"&&c?.success?"bg-bambu-green/20 text-bambu-green":r==="result"&&!c?.success?"bg-red-500/20 text-red-500":"bg-blue-500/20 text-blue-500"}`,children:r==="result"&&c?.success?u.jsx(Ss,{className:"w-5 h-5"}):r==="result"&&!c?.success?u.jsx(ws,{className:"w-5 h-5"}):u.jsx(Ka,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsxs("h3",{className:"text-lg font-semibold text-white",children:[r==="options"&&"Restore Backup",r==="restoring"&&"Restoring...",r==="result"&&(c?.success?"Restore Complete":"Restore Failed")]}),u.jsxs("p",{className:"text-sm text-bambu-gray",children:[r==="options"&&"Import settings from a backup file",r==="restoring"&&"Please wait while your data is being restored",r==="result"&&c?.message]})]})]}),r!=="restoring"&&u.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),r==="options"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"p-4 space-y-4",children:[u.jsxs("div",{children:[u.jsx("input",{ref:m,type:"file",accept:".json,.zip",className:"hidden",onChange:v}),u.jsx("button",{type:"button",onClick:()=>m.current?.click(),className:`w-full p-4 border-2 border-dashed rounded-lg transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:o?u.jsxs("div",{className:"flex items-center justify-center gap-2 text-bambu-green",children:[u.jsx(Ss,{className:"w-5 h-5"}),u.jsx("span",{className:"font-medium",children:o.name})]}):u.jsxs("div",{className:"flex flex-col items-center gap-2 text-bambu-gray",children:[u.jsx(Ka,{className:"w-8 h-8"}),u.jsx("span",{children:"Click to select backup file (.json or .zip)"})]})})]}),u.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:u.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[u.jsx(ws,{className:"w-4 h-4 text-blue-500 dark:text-blue-400 mt-0.5 flex-shrink-0"}),u.jsxs("div",{className:"text-blue-700 dark:text-blue-200",children:[u.jsx("p",{className:"font-medium mb-1",children:"How duplicate handling works:"}),u.jsxs("ul",{className:"text-blue-600 dark:text-blue-200/80 space-y-1 text-xs",children:[u.jsxs("li",{children:[u.jsx("strong",{children:"Printers"})," - matched by serial number"]}),u.jsxs("li",{children:[u.jsx("strong",{children:"Smart Plugs"})," - matched by IP address"]}),u.jsxs("li",{children:[u.jsx("strong",{children:"Notification Providers"})," - matched by name"]}),u.jsxs("li",{children:[u.jsx("strong",{children:"Filaments"})," - matched by name + type + brand"]}),u.jsxs("li",{children:[u.jsx("strong",{children:"Archives"})," - matched by content hash (always skipped)"]}),u.jsxs("li",{children:[u.jsx("strong",{children:"Settings & Templates"})," - always overwritten"]})]})]})]})}),u.jsx("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsxs("p",{className:"text-white font-medium flex items-center gap-2",children:[s?u.jsx(qs,{className:"w-4 h-4 text-orange-400"}):u.jsx(i1,{className:"w-4 h-4 text-bambu-gray"}),s?"Replace existing data":"Keep existing data"]}),u.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:s?"Overwrite items that already exist with backup data":"Only restore items that don't already exist"})]}),u.jsx(er,{checked:s,onChange:a})]})}),s&&u.jsx("div",{className:"p-3 rounded-lg bg-orange-500/10 border border-orange-500/30",children:u.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[u.jsx(ws,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),u.jsxs("div",{className:"text-orange-700 dark:text-orange-200",children:[u.jsx("span",{className:"font-medium",children:"Caution:"})," Overwriting will replace your current configurations with data from the backup. Printer access codes are never overwritten for security."]})]})})]}),u.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[u.jsx(Ue,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),u.jsxs(Ue,{type:"button",onClick:y,disabled:!o,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[u.jsx(Ka,{className:"w-4 h-4 mr-2"}),"Restore"]})]})]}),r==="restoring"&&u.jsxs("div",{className:"p-8 flex flex-col items-center gap-4",children:[u.jsx(Ot,{className:"w-12 h-12 text-bambu-green animate-spin"}),u.jsx("p",{className:"text-bambu-gray",children:"Processing backup file..."})]}),r==="result"&&c&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"p-4 space-y-4 max-h-[400px] overflow-y-auto",children:[u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{className:"p-3 rounded-lg bg-bambu-green/10 border border-bambu-green/30",children:[u.jsx("div",{className:"text-2xl font-bold text-bambu-green",children:x}),u.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Restored"})]}),u.jsxs("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[u.jsx("div",{className:"text-2xl font-bold text-yellow-500",children:M}),u.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Skipped"})]})]}),c.restored&&Object.entries(c.restored).some(([,w])=>w>0)&&u.jsxs("div",{className:"space-y-2",children:[u.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[u.jsx(Ss,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),u.jsxs("div",{className:"space-y-1",children:[Object.entries(c.restored).filter(([,w])=>w>0).map(([w,A])=>u.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[u.jsx("span",{className:"text-white",children:kG[w]||w}),u.jsx("span",{className:"text-bambu-green font-medium",children:A})]},w)),(c.files_restored||0)>0&&u.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[u.jsx("span",{className:"text-white",children:"Files (3MF, thumbnails, etc.)"}),u.jsx("span",{className:"text-bambu-green font-medium",children:c.files_restored})]})]})]}),c.skipped&&Object.entries(c.skipped).some(([,w])=>w>0)&&u.jsxs("div",{className:"space-y-2",children:[u.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[u.jsx(i1,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),u.jsx("div",{className:"space-y-1",children:Object.entries(c.skipped).filter(([,w])=>w>0).map(([w,A])=>{const T=c.skipped_details?.[w]||[],R=h.has(w);return u.jsxs("div",{children:[u.jsxs("button",{onClick:()=>T.length>0&&b(w),className:`w-full flex items-center justify-between text-sm p-2 rounded bg-bambu-dark ${T.length>0?"hover:bg-bambu-dark-tertiary cursor-pointer":""}`,children:[u.jsxs("span",{className:"text-white flex items-center gap-2",children:[kG[w]||w,T.length>0&&(R?u.jsx(cw,{className:"w-3 h-3"}):u.jsx(Qf,{className:"w-3 h-3"}))]}),u.jsx("span",{className:"text-yellow-500 font-medium",children:A})]}),R&&T.length>0&&u.jsxs("div",{className:"mt-1 ml-4 p-2 rounded bg-bambu-dark-tertiary text-xs text-bambu-gray space-y-1",children:[T.slice(0,10).map((C,I)=>u.jsx("div",{children:C},I)),T.length>10&&u.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",T.length-10," more"]})]})]},w)})})]}),x===0&&M===0&&u.jsx("div",{className:"p-4 text-center text-bambu-gray",children:"No data was found to restore in the backup file."})]}),u.jsx("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:u.jsx(Ue,{onClick:t,children:"Close"})})]})]})})})}async function $Ve(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function VVe(t){const e=await fetch("/api/v1/settings/spoolman",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok)throw new Error("Failed to save Spoolman settings");return e.json()}function GVe(){const t=Nn(),[e,n]=E.useState(!1),[r,i]=E.useState(""),[s,a]=E.useState("auto"),[o,l]=E.useState(!1),[c,d]=E.useState("all"),[h,g]=E.useState(!1),{data:m,isLoading:v}=Mt({queryKey:["spoolman-settings"],queryFn:$Ve}),{data:y,isLoading:b,refetch:x}=Mt({queryKey:["spoolman-status"],queryFn:Le.getSpoolmanStatus,refetchInterval:3e4}),{data:M}=Mt({queryKey:["printers"],queryFn:Le.getPrinters});E.useEffect(()=>{m&&(n(m.spoolman_enabled==="true"),i(m.spoolman_url||""),a(m.spoolman_sync_mode||"auto"),g(!0))},[m]),E.useEffect(()=>{if(!h||!m)return;if(m.spoolman_enabled==="true"!==e||(m.spoolman_url||"")!==r||(m.spoolman_sync_mode||"auto")!==s){const W=setTimeout(()=>{w.mutate()},500);return()=>clearTimeout(W)}},[e,r,s,h]);const w=At({mutationFn:()=>VVe({spoolman_enabled:e?"true":"false",spoolman_url:r,spoolman_sync_mode:s}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),l(!0),setTimeout(()=>l(!1),2e3)}}),A=At({mutationFn:Le.connectSpoolman,onSuccess:()=>{x()}}),T=At({mutationFn:Le.disconnectSpoolman,onSuccess:()=>{x()}}),R=At({mutationFn:Le.syncAllPrintersAms,onSuccess:j=>{j.success}}),C=At({mutationFn:j=>Le.syncPrinterAms(j),onSuccess:j=>{j.success}}),I=()=>{c==="all"?R.mutate():C.mutate(c)},N=R.isPending||C.isPending,D=c==="all"?R.data:C.data,z=c==="all"?R.isSuccess:C.isSuccess;return v?u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(dF,{className:"w-5 h-5 text-bambu-green"}),u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),u.jsx(Ft,{children:u.jsx("div",{className:"flex justify-center py-8",children:u.jsx(Ot,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(dF,{className:"w-5 h-5 text-bambu-green"}),u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),w.isPending&&u.jsx(Ot,{className:"w-4 h-4 text-bambu-green animate-spin"}),o&&u.jsx(Qp,{className:"w-4 h-4 text-bambu-green"})]})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Enable Spoolman"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:e,onChange:j=>n(j.target.checked),className:"sr-only peer"}),u.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),u.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:j=>i(j.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none disabled:opacity-50"}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),u.jsxs("select",{value:s,onChange:j=>a(j.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:[u.jsx("option",{value:"auto",children:"Automatic"}),u.jsx("option",{value:"manual",children:"Manual Only"})]}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:s==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),e&&u.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center justify-between mb-3",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),b?u.jsx(Ot,{className:"w-4 h-4 text-bambu-gray animate-spin"}):y?.connected?u.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[u.jsx(Qp,{className:"w-4 h-4"}),"Connected"]}):u.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[u.jsx(Qt,{className:"w-4 h-4"}),"Disconnected"]})]}),u.jsx("div",{className:"flex gap-2",children:y?.connected?u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>T.mutate(),disabled:T.isPending,children:[T.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Noe,{className:"w-4 h-4"}),"Disconnect"]}):u.jsxs(Ue,{size:"sm",onClick:()=>A.mutate(),disabled:A.isPending||!r,children:[A.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Roe,{className:"w-4 h-4"}),"Connect"]})})]}),A.isError&&u.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:A.error.message}),y?.connected&&u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("div",{className:"relative flex-1",children:[u.jsxs("select",{value:c,onChange:j=>d(j.target.value==="all"?"all":Number(j.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[u.jsx("option",{value:"all",children:"All Printers"}),M?.map(j=>u.jsx("option",{value:j.id,children:j.name},j.id))]}),u.jsx(Qf,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:I,disabled:N,children:[N?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(qs,{className:"w-4 h-4"}),"Sync"]})]})]}),z&&D&&u.jsx("div",{className:`mt-2 p-2 rounded text-sm ${D.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:D.success?`Synced ${D.synced_count} trays successfully`:`Synced ${D.synced_count} trays with ${D.errors.length} errors`})]})]})]})}function WVe(){const t=Nn(),{t:e,i18n:n}=sw(),{showToast:r}=Di(),[i,s]=E.useState(null),[a,o]=E.useState(!1),[l,c]=E.useState(null),[d,h]=E.useState(!1),[g,m]=E.useState(null),[v,y]=E.useState(null),[b,x]=E.useState(!1),[M,w]=E.useState(k9()),[A,T]=E.useState("general"),[R,C]=E.useState(!1),[I,N]=E.useState(!1),[D,z]=E.useState(null),[j,W]=E.useState(!1),[P,$]=E.useState(!1),K=X=>{w(X),vce(X)},G=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:Z,isLoading:Q}=Mt({queryKey:["settings"],queryFn:Le.getSettings}),{data:ee,isLoading:H}=Mt({queryKey:["smart-plugs"],queryFn:Le.getSmartPlugs}),{data:q,isLoading:te}=Mt({queryKey:["smart-plugs-energy",ee?.map(X=>X.id)],queryFn:async()=>{if(!ee||ee.length===0)return null;const X=await Promise.all(ee.filter(ze=>ze.enabled).map(async ze=>{try{const at=await Le.getSmartPlugStatus(ze.id);return{plug:ze,status:at}}catch{return{plug:ze,status:null}}}));let me=0,ve=0,ge=0,Ke=0,Ie=0;for(const{status:ze}of X)ze?.reachable&&ze.energy&&(Ie++,ze.energy.power!=null&&(me+=ze.energy.power),ze.energy.today!=null&&(ve+=ze.energy.today),ze.energy.yesterday!=null&&(ge+=ze.energy.yesterday),ze.energy.total!=null&&(Ke+=ze.energy.total));return{totalPower:me,totalToday:ve,totalYesterday:ge,totalLifetime:Ke,reachableCount:Ie,totalPlugs:ee.filter(ze=>ze.enabled).length}},enabled:A==="plugs"&&!!ee&&ee.length>0,refetchInterval:A==="plugs"?1e4:!1}),{data:ae,isLoading:xe}=Mt({queryKey:["notification-providers"],queryFn:Le.getNotificationProviders}),{data:re}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),{data:pe,isLoading:Ce}=Mt({queryKey:["notification-templates"],queryFn:Le.getNotificationTemplates}),{data:fe}=Mt({queryKey:["ffmpeg-status"],queryFn:Le.checkFfmpeg}),{data:Se}=Mt({queryKey:["version"],queryFn:Le.getVersion}),{data:Re,refetch:ue,isRefetching:ct}=Mt({queryKey:["updateCheck"],queryFn:Le.checkForUpdates,staleTime:300*1e3}),{data:B,refetch:F}=Mt({queryKey:["updateStatus"],queryFn:Le.getUpdateStatus,refetchInterval:X=>{const me=X.state.data;return me?.status==="downloading"||me?.status==="installing"?1e3:!1}}),ie=At({mutationFn:Le.applyUpdate,onSuccess:()=>{F()}}),[V,J]=E.useState(null),le=At({mutationFn:Le.testAllNotificationProviders,onSuccess:X=>{J(X),t.invalidateQueries({queryKey:["notification-providers"]}),X.failed===0?r(`All ${X.tested} providers tested successfully!`,"success"):r(`${X.success}/${X.tested} providers succeeded`,X.failed>0?"error":"success")},onError:X=>{r(`Failed to test providers: ${X.message}`,"error")}}),Ae=At({mutationFn:async X=>{if(!ee)return{success:0,failed:0};const me=ee.filter(ge=>ge.enabled),ve=await Promise.all(me.map(async ge=>{try{return await Le.controlSmartPlug(ge.id,X),{success:!0}}catch{return{success:!1}}}));return{success:ve.filter(ge=>ge.success).length,failed:ve.filter(ge=>!ge.success).length}},onSuccess:(X,me)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),X.failed===0?r(`All ${X.success} plugs turned ${me}`,"success"):r(`${X.success} plugs turned ${me}, ${X.failed} failed`,"error")},onError:X=>{r(`Failed: ${X.message}`,"error")}}),Ee=E.useRef(null),se=E.useRef(!0);E.useEffect(()=>{Z&&!i&&(s(Z),setTimeout(()=>{se.current=!1},100))},[Z,i]);const U=At({mutationFn:Le.updateSettings,onSuccess:X=>{t.setQueryData(["settings"],X),t.invalidateQueries({queryKey:["archiveStats"]}),r("Settings saved","success")},onError:X=>{r(`Failed to save: ${X.message}`,"error")}});E.useEffect(()=>{if(!(se.current||!i||!Z||!(Z.auto_archive!==i.auto_archive||Z.save_thumbnails!==i.save_thumbnails||Z.capture_finish_photo!==i.capture_finish_photo||Z.default_filament_cost!==i.default_filament_cost||Z.currency!==i.currency||Z.energy_cost_per_kwh!==i.energy_cost_per_kwh||Z.energy_tracking_mode!==i.energy_tracking_mode||Z.check_updates!==i.check_updates||Z.notification_language!==i.notification_language||Z.ams_humidity_good!==i.ams_humidity_good||Z.ams_humidity_fair!==i.ams_humidity_fair||Z.ams_temp_good!==i.ams_temp_good||Z.ams_temp_fair!==i.ams_temp_fair||Z.date_format!==i.date_format||Z.time_format!==i.time_format||Z.default_printer_id!==i.default_printer_id)))return Ee.current&&clearTimeout(Ee.current),Ee.current=setTimeout(()=>{U.mutate(i)},500),()=>{Ee.current&&clearTimeout(Ee.current)}},[i,Z,U]);const L=E.useCallback((X,me)=>{s(ve=>ve?{...ve,[X]:me}:null)},[]);return Q||!i?u.jsx("div",{className:"p-8 flex justify-center",children:u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u.jsxs("div",{className:"p-8",children:[u.jsxs("div",{className:"mb-8",children:[u.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),u.jsx("p",{className:"text-bambu-gray",children:"Configure Bambuddy"})]}),u.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[u.jsx("button",{onClick:()=>T("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${A==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:"General"}),u.jsxs("button",{onClick:()=>T("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${A==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[u.jsx(Nx,{className:"w-4 h-4"}),"Smart Plugs",ee&&ee.length>0&&u.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:ee.length})]}),u.jsxs("button",{onClick:()=>T("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${A==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[u.jsx(ff,{className:"w-4 h-4"}),"Notifications",ae&&ae.length>0&&u.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:ae.length})]})]}),A==="general"&&u.jsxs("div",{className:"flex gap-8",children:[u.jsxs("div",{className:"space-y-6 flex-1 max-w-xl",children:[u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsxs("div",{children:[u.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[u.jsx(e1,{className:"w-4 h-4 inline mr-1"}),e("settings.language")]}),u.jsx("select",{value:n.language,onChange:X=>n.changeLanguage(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:WU.map(X=>u.jsxs("option",{value:X.code,children:[X.nativeName," (",X.name,")"]},X.code))}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.languageDescription")})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("settings.defaultView")}),u.jsx("select",{value:M,onChange:X=>K(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:A_.map(X=>u.jsx("option",{value:X.to,children:e(X.labelKey)},X.id))}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.defaultViewDescription")})]}),u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),u.jsxs("select",{value:i.date_format||"system",onChange:X=>L("date_format",X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"system",children:"System Default"}),u.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),u.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),u.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),u.jsxs("select",{value:i.time_format||"system",onChange:X=>L("time_format",X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"system",children:"System Default"}),u.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),u.jsx("option",{value:"24h",children:"24-hour (15:30)"})]})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),u.jsxs("select",{value:i.default_printer_id??"",onChange:X=>L("default_printer_id",X.target.value?Number(X.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"",children:"No default (ask each time)"}),re?.map(X=>u.jsx("option",{value:X.id,children:X.name},X.id))]}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Sidebar order"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:G,children:[u.jsx(X0,{className:"w-4 h-4"}),"Reset"]})]})]})]}),u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Auto-archive prints"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:i.auto_archive,onChange:X=>L("auto_archive",X.target.checked),className:"sr-only peer"}),u.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Save thumbnails"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:i.save_thumbnails,onChange:X=>L("save_thumbnails",X.target.checked),className:"sr-only peer"}),u.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Capture finish photo"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:i.capture_finish_photo,onChange:X=>L("capture_finish_photo",X.target.checked),className:"sr-only peer"}),u.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),i.capture_finish_photo&&fe&&!fe.installed&&u.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[u.jsx(ws,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),u.jsxs("div",{className:"text-sm",children:[u.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),u.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",u.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",u.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]}),u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),u.jsx("input",{type:"number",step:"0.01",min:"0",value:i.default_filament_cost,onChange:X=>L("default_filament_cost",parseFloat(X.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),u.jsxs("select",{value:i.currency,onChange:X=>L("currency",X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"USD",children:"USD ($)"}),u.jsx("option",{value:"EUR",children:"EUR (€)"}),u.jsx("option",{value:"GBP",children:"GBP (£)"}),u.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),u.jsx("option",{value:"JPY",children:"JPY (¥)"}),u.jsx("option",{value:"CNY",children:"CNY (¥)"}),u.jsx("option",{value:"CAD",children:"CAD ($)"}),u.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),u.jsx("input",{type:"number",step:"0.01",min:"0",value:i.energy_cost_per_kwh,onChange:X=>L("energy_cost_per_kwh",parseFloat(X.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),u.jsxs("select",{value:i.energy_tracking_mode||"total",onChange:X=>L("energy_tracking_mode",X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"print",children:"Prints Only"}),u.jsx("option",{value:"total",children:"Total Consumption"})]}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]})]}),u.jsxs("div",{className:"space-y-6 flex-1 max-w-md",children:[u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Configure color thresholds for AMS humidity and temperature indicators."}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-white",children:[u.jsx(Bae,{className:"w-4 h-4 text-blue-400"}),u.jsx("span",{className:"font-medium",children:"Humidity"})]}),u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (green) ≤"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"number",min:"0",max:"100",value:i.ams_humidity_good??40,onChange:X=>L("ams_humidity_good",parseInt(X.target.value)||40),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),u.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"number",min:"0",max:"100",value:i.ams_humidity_fair??60,onChange:X=>L("ams_humidity_fair",parseInt(X.target.value)||60),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),u.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (bad)"})]}),u.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center gap-2 text-white",children:[u.jsx(Ip,{className:"w-4 h-4 text-orange-400"}),u.jsx("span",{className:"font-medium",children:"Temperature"})]}),u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:i.ams_temp_good??28,onChange:X=>L("ams_temp_good",parseFloat(X.target.value)||28),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),u.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:i.ams_temp_fair??35,onChange:X=>L("ams_temp_fair",parseFloat(X.target.value)||35),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),u.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (hot)"})]})]})]}),u.jsx(GVe,{})]}),u.jsxs("div",{className:"space-y-6 flex-1 max-w-sm",children:[u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Check for updates"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:i.check_updates,onChange:X=>L("check_updates",X.target.checked),className:"sr-only peer"}),u.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),u.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[u.jsxs("div",{className:"flex items-center justify-between mb-2",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Current version"}),u.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",Se?.version||"..."]})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>ue(),disabled:ct,children:[ct?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(qs,{className:"w-4 h-4"}),"Check now"]})]}),Re?.update_available?u.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[u.jsxs("div",{className:"flex items-start justify-between",children:[u.jsxs("div",{children:[u.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",Re.latest_version]}),Re.release_name&&Re.release_name!==Re.latest_version&&u.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:Re.release_name}),Re.release_notes&&u.jsx("p",{className:"text-sm text-bambu-gray mt-2 whitespace-pre-line line-clamp-3",children:Re.release_notes})]}),Re.release_url&&u.jsx("a",{href:Re.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:u.jsx(vc,{className:"w-4 h-4"})})]}),B?.status==="downloading"||B?.status==="installing"?u.jsxs("div",{className:"mt-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[u.jsx(Ot,{className:"w-4 h-4 animate-spin"}),u.jsx("span",{children:B.message})]}),u.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:u.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${B.progress}%`}})})]}):B?.status==="complete"?u.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:B.message}):B?.status==="error"?u.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:B.error||B.message}):u.jsxs(Ue,{className:"mt-3",onClick:()=>ie.mutate(),disabled:ie.isPending,children:[ie.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(va,{className:"w-4 h-4"}),"Install Update"]})]}):Re?.error?u.jsxs("div",{className:"mt-2 p-2 bg-red-500/10 border border-red-500/30 rounded text-sm text-red-400",children:["Failed to check for updates: ",Re.error]}):Re&&!Re.update_available?u.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Backup Data"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Export settings, providers, printers, and more"})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>W(!0),children:[u.jsx(va,{className:"w-4 h-4"}),"Export"]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Restore Backup"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Import settings from a backup file with duplicate handling options"})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>$(!0),children:[u.jsx(Ka,{className:"w-4 h-4"}),"Restore"]})]}),u.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Clear Notification Logs"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Delete notification logs older than 30 days"})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>C(!0),children:[u.jsx(Qn,{className:"w-4 h-4"}),"Clear"]})]})}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Reset UI Preferences"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Reset sidebar order, theme, view modes, and layout preferences. Printers, archives, and settings are not affected."})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>N(!0),children:[u.jsx(Qn,{className:"w-4 h-4"}),"Reset"]})]})]})]})]})]}),A==="plugs"&&u.jsxs("div",{className:"max-w-4xl",children:[u.jsxs("div",{className:"flex items-start justify-between mb-6",children:[u.jsxs("div",{children:[u.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[u.jsx(Nx,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),u.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Connect Tasmota-based smart plugs to automate power control and track energy usage for your printers."})]}),u.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[ee&&ee.filter(X=>X.enabled).length>1&&u.jsxs(u.Fragment,{children:[u.jsxs(Ue,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>z("on"),disabled:Ae.isPending,title:"Turn all plugs on",children:[Ae.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(dd,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),u.jsxs(Ue,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>z("off"),disabled:Ae.isPending,title:"Turn all plugs off",children:[Ae.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(cP,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),u.jsxs(Ue,{className:"whitespace-nowrap",onClick:()=>{c(null),o(!0)},children:[u.jsx(li,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),ee&&ee.length>0&&u.jsxs(Lt,{className:"mb-6",children:[u.jsx(Yl,{children:u.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[u.jsx(s0,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",te&&u.jsx(Ot,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),u.jsx(Ft,{children:q?u.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[u.jsx(s0,{className:"w-3 h-3"}),"Current Power"]}),u.jsxs("div",{className:"text-xl font-bold text-white",children:[q.totalPower.toFixed(1),u.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),u.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[q.reachableCount,"/",q.totalPlugs," plugs online"]})]}),u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[u.jsx(Wr,{className:"w-3 h-3"}),"Today"]}),u.jsxs("div",{className:"text-xl font-bold text-white",children:[q.totalToday.toFixed(2),u.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),i&&i.energy_cost_per_kwh>0&&u.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(q.totalToday*i.energy_cost_per_kwh).toFixed(2)," ",i.currency]})]}),u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[u.jsx(Xle,{className:"w-3 h-3"}),"Yesterday"]}),u.jsxs("div",{className:"text-xl font-bold text-white",children:[q.totalYesterday.toFixed(2),u.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),i&&i.energy_cost_per_kwh>0&&u.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(q.totalYesterday*i.energy_cost_per_kwh).toFixed(2)," ",i.currency]})]}),u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[u.jsx(XN,{className:"w-3 h-3"}),"Total"]}),u.jsxs("div",{className:"text-xl font-bold text-white",children:[q.totalLifetime.toFixed(1),u.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),i&&i.energy_cost_per_kwh>0&&u.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(q.totalLifetime*i.energy_cost_per_kwh).toFixed(2)," ",i.currency]})]})]}):te?null:u.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),H?u.jsx("div",{className:"flex justify-center py-12",children:u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin"})}):ee&&ee.length>0?u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ee.map(X=>u.jsx(RVe,{plug:X,onEdit:me=>{c(me),o(!0)}},X.id))}):u.jsx(Lt,{children:u.jsx(Ft,{className:"py-12",children:u.jsxs("div",{className:"text-center text-bambu-gray",children:[u.jsx(Nx,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),u.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No smart plugs configured"}),u.jsx("p",{className:"text-sm mb-4",children:"Add a Tasmota-based smart plug to track energy usage and automate power control."}),u.jsxs(Ue,{onClick:()=>{c(null),o(!0)},children:[u.jsx(li,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),A==="notifications"&&u.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center justify-between mb-4",children:[u.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[u.jsx(ff,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Ue,{size:"sm",variant:"secondary",onClick:()=>x(!0),children:[u.jsx(KN,{className:"w-4 h-4"}),"Log"]}),ae&&ae.length>0&&u.jsxs(Ue,{size:"sm",variant:"secondary",onClick:()=>{J(null),le.mutate()},disabled:le.isPending,children:[le.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(uP,{className:"w-4 h-4"}),"Test All"]}),u.jsxs(Ue,{size:"sm",onClick:()=>{m(null),h(!0)},children:[u.jsx(li,{className:"w-4 h-4"}),"Add"]})]})]}),u.jsx(Lt,{className:"mb-4",children:u.jsx(Ft,{className:"py-3",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white text-sm font-medium",children:e("settings.notificationLanguage")}),u.jsx("p",{className:"text-xs text-bambu-gray",children:e("settings.notificationLanguageDescription")})]}),u.jsx("select",{value:i.notification_language||"en",onChange:X=>L("notification_language",X.target.value),className:"px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:WU.map(X=>u.jsx("option",{value:X.code,children:X.nativeName},X.code))})]})})}),V&&u.jsx(Lt,{className:"mb-4",children:u.jsxs(Ft,{className:"py-3",children:[u.jsxs("div",{className:"flex items-center justify-between mb-2",children:[u.jsx("span",{className:"text-sm font-medium text-white",children:"Test Results"}),u.jsx("button",{onClick:()=>J(null),className:"text-bambu-gray hover:text-white text-xs",children:"Dismiss"})]}),u.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[u.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[u.jsx(Ss,{className:"w-4 h-4"}),V.success," passed"]}),V.failed>0&&u.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[u.jsx(ud,{className:"w-4 h-4"}),V.failed," failed"]})]}),V.results.filter(X=>!X.success).length>0&&u.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:V.results.filter(X=>!X.success).map(X=>u.jsxs("div",{className:"text-xs text-red-400",children:[u.jsxs("span",{className:"font-medium",children:[X.provider_name,":"]})," ",X.message]},X.provider_id))})]})}),xe?u.jsx("div",{className:"flex justify-center py-12",children:u.jsx(Ot,{className:"w-6 h-6 text-bambu-green animate-spin"})}):ae&&ae.length>0?u.jsx("div",{className:"space-y-3",children:ae.map(X=>u.jsx(OVe,{provider:X,onEdit:me=>{m(me),h(!0)}},X.id))}):u.jsx(Lt,{children:u.jsx(Ft,{className:"py-8",children:u.jsxs("div",{className:"text-center text-bambu-gray",children:[u.jsx(ff,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),u.jsx("p",{className:"text-sm font-medium text-white mb-2",children:"No providers configured"}),u.jsx("p",{className:"text-xs mb-3",children:"Add a provider to receive alerts."}),u.jsxs(Ue,{size:"sm",onClick:()=>{m(null),h(!0)},children:[u.jsx(li,{className:"w-4 h-4"}),"Add Provider"]})]})})})]}),u.jsxs("div",{children:[u.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[u.jsx(rc,{className:"w-5 h-5 text-bambu-green"}),"Message Templates"]}),u.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Customize notification messages for each event."}),Ce?u.jsx("div",{className:"flex justify-center py-8",children:u.jsx(Ot,{className:"w-6 h-6 text-bambu-green animate-spin"})}):pe&&pe.length>0?u.jsx("div",{className:"space-y-2",children:pe.map(X=>u.jsx(Lt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>y(X),children:u.jsx(Ft,{className:"py-2.5 px-3",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("p",{className:"text-white font-medium text-sm truncate",children:X.name}),u.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:X.title_template})]}),u.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:me=>{me.stopPropagation(),y(X)},children:u.jsx(lP,{className:"w-4 h-4 text-bambu-gray"})})]})})},X.id))}):u.jsx(Lt,{children:u.jsx(Ft,{className:"py-8",children:u.jsxs("div",{className:"text-center text-bambu-gray",children:[u.jsx(rc,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),u.jsx("p",{className:"text-sm",children:"No templates available. Restart the backend to seed default templates."})]})})})]})]}),a&&u.jsx(PVe,{plug:l,onClose:()=>{o(!1),c(null)}}),d&&u.jsx(LVe,{provider:g,onClose:()=>{h(!1),m(null)}}),v&&u.jsx(jVe,{template:v,onClose:()=>y(null)}),b&&u.jsx(FVe,{onClose:()=>x(!1)}),R&&u.jsx(Zi,{title:"Clear Notification Logs",message:"This will permanently delete all notification logs older than 30 days. This action cannot be undone.",confirmText:"Clear Logs",variant:"warning",onConfirm:async()=>{C(!1);try{const X=await Le.clearNotificationLogs(30);r(X.message,"success")}catch{r("Failed to clear logs","error")}},onCancel:()=>C(!1)}),I&&u.jsx(Zi,{title:"Reset UI Preferences",message:"This will reset all UI preferences to defaults: sidebar order, theme, dashboard layout, view modes, and sorting preferences. Your printers, archives, and server settings will NOT be affected. The page will reload after clearing.",confirmText:"Reset Preferences",variant:"default",onConfirm:()=>{N(!1),localStorage.clear(),r("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>N(!1)}),D&&u.jsx(Zi,{title:`Turn All Plugs ${D==="on"?"On":"Off"}`,message:`This will turn ${D==="on"?"ON":"OFF"} all ${ee?.filter(X=>X.enabled).length||0} enabled smart plugs. ${D==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${D==="on"?"On":"Off"}`,variant:D==="off"?"danger":"warning",onConfirm:()=>{const X=D;z(null),Ae.mutate(X)},onCancel:()=>z(null)}),j&&u.jsx(BVe,{onClose:()=>W(!1),onExport:async X=>{W(!1);try{const{blob:me,filename:ve}=await Le.exportBackup(X),ge=URL.createObjectURL(me),Ke=document.createElement("a");Ke.href=ge,Ke.download=ve,Ke.click(),URL.revokeObjectURL(ge),r("Backup downloaded","success")}catch{r("Failed to create backup","error")}}}),P&&u.jsx(HVe,{onClose:()=>$(!1),onRestore:async(X,me)=>await Le.importBackup(X,me),onSuccess:()=>{t.invalidateQueries()}})]})}const gee=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},qVe=t=>t.startsWith("HH")?"HF":"S",XVe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},BR=t=>{const e=["High Flow_","High Flow ","Standard_","Standard ","HF_","HF ","S_","S "];for(const r of e)if(t.startsWith(r))return t.slice(r.length);const n=t.indexOf("_");return n>0?t.slice(n+1):t};function RN({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:s,note:a}){const o=qVe(t.nozzle_id),l=t.nozzle_diameter,c=()=>{r&&s?s():e()};return u.jsxs("div",{className:"flex items-center gap-2",children:[r&&u.jsx("button",{onClick:s,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?u.jsx(Pf,{className:"w-4 h-4 text-bambu-green"}):u.jsx(em,{className:"w-4 h-4"})}),u.jsxs("button",{onClick:c,className:`flex-1 text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors ${i?"ring-1 ring-bambu-green":""}`,children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:gee(t.k_value)}),u.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),a&&u.jsx("span",{title:"Has note",children:u.jsx(M9,{className:"w-3 h-3 text-yellow-500"})}),u.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[o," ",l]})]}),a&&u.jsxs("div",{className:"text-xs mt-0.5 truncate text-yellow-500/70",title:a,children:["Note: ",a.length>50?a.substring(0,50)+"...":a]})]}),!r&&n&&u.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:u.jsx(Jp,{className:"w-4 h-4"})})]})}function PN({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:s="",initialNoteKey:a=null,onClose:o,onSave:l,onSaveNote:c}){const{showToast:d}=Di(),[h,g]=E.useState(t?.name||""),[m,v]=E.useState(t?.k_value?gee(t.k_value):"0.020"),[y,b]=E.useState(t?.filament_id||""),[x,M]=E.useState(t?.nozzle_id?XVe(t.nozzle_id):"HH00"),[w,A]=E.useState(t?.nozzle_diameter||n),[T,R]=E.useState(t?[t.extruder_id]:i?[0,1]:[0]),[C,I]=E.useState(!1),[N,D]=E.useState({current:0,total:0}),[z,j]=E.useState(s),W=fr.useMemo(()=>{const ee=new Map;for(const H of r)if(H.filament_id&&!ee.has(H.filament_id)){const q=BR(H.name||"");ee.set(H.filament_id,{id:H.filament_id,name:q||H.filament_id})}return Array.from(ee.values()).sort((H,q)=>H.name.localeCompare(q.name))},[r]),P=At({mutationFn:ee=>(console.log("[KProfile] Calling API..."),Le.setKProfile(e,ee)),onSuccess:ee=>{if(console.log("[KProfile] Save success:",ee),d("K-profile saved"),c&&z!==s){let H;z===""&&a?H=a:t&&t.slot_id>0?H=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:H=`name_${h}_${y}`,c(H,z)}I(!0),setTimeout(()=>{I(!1),l()},2500)},onError:ee=>{console.error("[KProfile] Save error:",ee),d(ee.message,"error"),I(!1)}}),$=At({mutationFn:ee=>(console.log("[KProfile] Deleting profile..."),Le.deleteKProfile(e,ee)),onSuccess:ee=>{console.log("[KProfile] Delete success:",ee),d("K-profile deleted"),I(!0),setTimeout(()=>{I(!1),o()},4e3)},onError:ee=>{console.error("[KProfile] Delete error:",ee),d(ee.message,"error"),I(!1)}}),[K,G]=E.useState(!1),Z=()=>{t&&$.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id,setting_id:t.setting_id})},Q=async ee=>{if(ee.preventDefault(),i&&!t&&T.length===0){d("Please select at least one extruder","error");return}const H=parseFloat(m).toFixed(6),q=`${x}-${w}`;if(t||T.length===1){const ae={name:h,k_value:H,filament_id:y,nozzle_id:q,nozzle_diameter:w,extruder_id:t?t.extruder_id:T[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",ae),P.mutate(ae);return}I(!0),D({current:1,total:T.length});const te=T.map(ae=>({name:h,k_value:H,filament_id:y,nozzle_id:q,nozzle_diameter:w,extruder_id:ae,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${te.length} profiles in batch:`,te);try{if(await Le.setKProfilesBatch(e,te),d(`K-profile saved to ${T.length} extruders`),c&&z){const ae=`name_${h}_${y}`;c(ae,z)}}catch(ae){console.error("[KProfile] Failed to save batch:",ae),d("Failed to save K-profiles","error"),I(!1),D({current:0,total:0});return}D({current:T.length,total:T.length}),setTimeout(()=>{I(!1),D({current:0,total:0}),l()},3e3)};return u.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[u.jsxs(Lt,{className:"w-full max-w-md relative",children:[C&&u.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),u.jsx("p",{className:"text-white font-medium",children:N.total>1?`Saving to extruder ${N.current}/${N.total}...`:"Syncing with printer..."}),u.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),u.jsxs(Ft,{className:"p-0",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),u.jsx("button",{onClick:o,className:"text-bambu-gray hover:text-white transition-colors",disabled:C,children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("form",{onSubmit:Q,className:"p-4 space-y-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),u.jsx("input",{type:"text",value:h,onChange:ee=>g(ee.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,placeholder:"My PLA Profile",required:!t})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),u.jsx("input",{type:"text",inputMode:"decimal",value:m,onChange:ee=>{const H=ee.target.value;(H===""||/^\d*\.?\d*$/.test(H))&&v(H)},onBlur:ee=>{const H=parseFloat(ee.target.value);isNaN(H)||v((Math.trunc(H*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:"0.020",required:!0}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Typical range: 0.01 - 0.06 for PLA, 0.02 - 0.10 for PETG"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),u.jsxs("select",{value:y,onChange:ee=>{const H=ee.target.value;if(b(H),!t&&H&&!h){const q=W.find(te=>te.id===H);q&&g(`${x==="HH00"?"HF":"S"} ${q.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!t,children:[u.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&u.jsx("option",{value:t.filament_id,children:W.find(ee=>ee.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&W.map(ee=>u.jsx("option",{value:ee.id,children:ee.name},ee.id))]}),!t&&W.length===0&&u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),u.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),u.jsxs("select",{value:x,onChange:ee=>{const H=ee.target.value;if(M(H),!t&&y&&!h){const q=W.find(te=>te.id===y);q&&g(`${H==="HS00"?"HF":"S"} ${q.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[u.jsx("option",{value:"HH00",children:"High Flow"}),u.jsx("option",{value:"HS00",children:"Standard"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),u.jsxs("select",{value:w,onChange:ee=>A(ee.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[u.jsx("option",{value:"0.2",children:"0.2mm"}),u.jsx("option",{value:"0.4",children:"0.4mm"}),u.jsx("option",{value:"0.6",children:"0.6mm"}),u.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?u.jsx("div",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white opacity-60",children:t.extruder_id===1?"Left":"Right"}):u.jsxs("div",{className:"flex gap-4",children:[u.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:T.includes(1),onChange:ee=>{ee.target.checked?R([...T,1]):R(T.filter(H=>H!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),u.jsx("span",{className:"text-white",children:"Left"})]}),u.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:T.includes(0),onChange:ee=>{ee.target.checked?R([...T,0]):R(T.filter(H=>H!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),u.jsx("span",{className:"text-white",children:"Right"})]})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),u.jsx("textarea",{value:z,onChange:ee=>j(ee.target.value),placeholder:"Add notes about this profile...",rows:2,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none resize-none"}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Notes are saved in Bambuddy, not on the printer"})]}),u.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&u.jsx(Ue,{type:"button",variant:"secondary",onClick:()=>G(!0),disabled:$.isPending||C,className:"text-red-500 hover:bg-red-500/10",children:$.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Qn,{className:"w-4 h-4"})}),u.jsx(Ue,{type:"button",variant:"secondary",onClick:o,disabled:C,className:"flex-1",children:"Cancel"}),u.jsxs(Ue,{type:"submit",disabled:P.isPending||C,className:"flex-1",children:[P.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(sP,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),K&&u.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:u.jsx(Lt,{className:"w-full max-w-sm",children:u.jsxs(Ft,{className:"p-6",children:[u.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[u.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:u.jsx(Qn,{className:"w-5 h-5 text-red-500"})}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),u.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",u.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),u.jsxs("div",{className:"flex gap-3",children:[u.jsx(Ue,{variant:"secondary",onClick:()=>G(!1),className:"flex-1",children:"Cancel"}),u.jsxs(Ue,{onClick:()=>{G(!1),Z()},disabled:$.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[$.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Qn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const w_={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function KVe(){const{showToast:t}=Di(),[e,n]=E.useState(null),[r,i]=E.useState(()=>localStorage.getItem(w_.NOZZLE_DIAMETER)||"0.4"),[s,a]=E.useState(null),[o,l]=E.useState(!1),[c,d]=E.useState(null),[h,g]=E.useState(""),[m,v]=E.useState("all"),[y,b]=E.useState("all"),[x,M]=E.useState(()=>localStorage.getItem(w_.SORT_OPTION)||"name"),[w,A]=E.useState(!1),[T,R]=E.useState(new Set),[C,I]=E.useState(!1),[N,D]=E.useState(!1),z=V=>`${V.slot_id}_${V.extruder_id}`;E.useEffect(()=>{localStorage.setItem(w_.NOZZLE_DIAMETER,r)},[r]),E.useEffect(()=>{localStorage.setItem(w_.SORT_OPTION,x)},[x]);const{data:j,isLoading:W}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),{data:P,isLoading:$,isFetching:K,error:G,refetch:Z}=Mt({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const V=await Le.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",V?.profiles?.length||0,"profiles"),V},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:Q}=Mt({queryKey:["kprofiles",e,"0.4"],queryFn:()=>Le.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:ee,refetch:H}=Mt({queryKey:["kprofile-notes",e],queryFn:()=>Le.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),q=G?.message?.includes("not connected");E.useEffect(()=>{if(!e&&j&&j.length>0){const V=j.find(J=>J.is_active);V&&n(V.id)}},[e,j]),E.useEffect(()=>{if(e){const V=setTimeout(()=>{Z()},150);return()=>clearTimeout(V)}},[e,r]);const te=j?.filter(V=>V.is_active)||[],ae=fr.useMemo(()=>P?.profiles?P.profiles.filter(J=>{const le=h.toLowerCase(),Ae=!le||J.name.toLowerCase().includes(le)||J.filament_id.toLowerCase().includes(le),Ee=m==="all"||m==="left"&&J.extruder_id===1||m==="right"&&J.extruder_id===0,se=y==="all"||y==="hf"&&J.nozzle_id.startsWith("HH")||y==="s"&&J.nozzle_id.startsWith("HS");return Ae&&Ee&&se}).sort((J,le)=>{switch(x){case"k_value":return parseFloat(J.k_value)-parseFloat(le.k_value);case"filament":return BR(J.name).localeCompare(BR(le.name));case"name":default:return J.name.localeCompare(le.name)}}):[],[P?.profiles,h,m,y,x]),xe=j?.find(V=>V.id===e),re=xe?.nozzle_count===2;E.useEffect(()=>{const V=J=>{J.target instanceof HTMLInputElement||J.target instanceof HTMLTextAreaElement||J.target instanceof HTMLSelectElement||s||o||c||(J.key==="r"||J.key==="R"?(J.preventDefault(),Z()):J.key==="n"||J.key==="N"?(J.preventDefault(),l(!0)):J.key==="Escape"&&w&&(J.preventDefault(),A(!1),R(new Set)))};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[s,o,c,w,Z]);const pe=E.useCallback(()=>{if(!P?.profiles||P.profiles.length===0){t("No profiles to export","error");return}const V={version:1,exported_at:new Date().toISOString(),printer:xe?.name||"Unknown",nozzle_diameter:r,profiles:P.profiles.map(Ee=>({name:Ee.name,k_value:Ee.k_value,filament_id:Ee.filament_id,nozzle_id:Ee.nozzle_id,nozzle_diameter:Ee.nozzle_diameter,extruder_id:Ee.extruder_id}))},J=new Blob([JSON.stringify(V,null,2)],{type:"application/json"}),le=URL.createObjectURL(J),Ae=document.createElement("a");Ae.href=le,Ae.download=`kprofiles_${xe?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae),URL.revokeObjectURL(le),t(`Exported ${P.profiles.length} profiles`)},[P?.profiles,xe,r,t]),Ce=E.useCallback(()=>{const V=document.createElement("input");V.type="file",V.accept=".json",V.onchange=async J=>{const le=J.target.files?.[0];if(le)try{const Ae=await le.text(),Ee=JSON.parse(Ae);if(!Ee.profiles||!Array.isArray(Ee.profiles)){t("Invalid file format","error");return}let se=0;for(const U of Ee.profiles)if(!(!U.name||!U.k_value||!U.filament_id))try{await Le.setKProfile(e,{name:U.name,k_value:parseFloat(U.k_value).toFixed(6),filament_id:U.filament_id,nozzle_id:U.nozzle_id||`HH00-${r}`,nozzle_diameter:U.nozzle_diameter||r,extruder_id:U.extruder_id??0,slot_id:0}),se++,await new Promise(L=>setTimeout(L,500))}catch(L){console.error("Failed to import profile:",U.name,L)}t(`Imported ${se} of ${Ee.profiles.length} profiles`),Z()}catch(Ae){console.error("Import error:",Ae),t("Failed to parse import file","error")}},V.click()},[e,r,t,Z]),fe=E.useCallback(V=>{R(J=>{const le=new Set(J);return le.has(V)?le.delete(V):le.add(V),le})},[]),Se=E.useCallback(()=>{R(new Set(ae.map(V=>z(V))))},[ae,z]),Re=E.useCallback(()=>{T.size!==0&&I(!0)},[T.size]),ue=E.useCallback(async()=>{const V=ae.filter(le=>T.has(z(le)));D(!0);let J=0;for(const le of V)try{await Le.deleteKProfile(e,{slot_id:le.slot_id,extruder_id:le.extruder_id,nozzle_id:le.nozzle_id,nozzle_diameter:le.nozzle_diameter,filament_id:le.filament_id,setting_id:le.setting_id}),J++,await new Promise(Ae=>setTimeout(Ae,300))}catch(Ae){console.error("Failed to delete profile:",le.name,Ae)}t(`Deleted ${J} profiles`),D(!1),I(!1),A(!1),R(new Set),Z()},[e,T,ae,t,Z,z]),ct=E.useCallback(V=>{const J=[];return V.setting_id&&J.push(V.setting_id),J.push(`slot_${V.slot_id}_${V.filament_id}_${V.extruder_id}`),J.push(`name_${V.name}_${V.filament_id}`),J},[]),B=E.useCallback(async(V,J)=>{if(e)try{await Le.setKProfileNote(e,V,J),H()}catch(le){console.error("Failed to save note:",le),t("Failed to save note","error")}},[e,H,t]),F=E.useCallback(V=>{if(!ee?.notes)return{note:"",key:null};const J=ct(V);for(const le of J)if(ee.notes[le])return{note:ee.notes[le],key:le};return{note:"",key:null}},[ee,ct]),ie=E.useCallback(V=>F(V).note,[F]);return W?u.jsx("div",{className:"flex justify-center py-12",children:u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!j||j.length===0?u.jsx(Lt,{children:u.jsxs(Ft,{className:"py-12 text-center",children:[u.jsx(No,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),u.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),u.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):te.length===0?u.jsx(Lt,{children:u.jsxs(Ft,{className:"py-12 text-center",children:[u.jsx(ko,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),u.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),u.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):u.jsxs(u.Fragment,{children:[K&&!$&&u.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[u.jsx(Ot,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),u.jsx("p",{className:"text-white font-medium",children:"Loading K-Profiles..."})]}),u.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[u.jsxs("div",{className:"flex-1 min-w-48",children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),u.jsx("select",{value:e||"",onChange:V=>n(parseInt(V.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:te.map(V=>u.jsx("option",{value:V.id,children:V.name},V.id))})]}),u.jsxs("div",{className:"w-32",children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),u.jsxs("select",{value:r,onChange:V=>i(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"0.2",children:"0.2mm"}),u.jsx("option",{value:"0.4",children:"0.4mm"}),u.jsx("option",{value:"0.6",children:"0.6mm"}),u.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs(Ue,{variant:"secondary",onClick:()=>Z(),disabled:K,children:[u.jsx(qs,{className:`w-4 h-4 ${K?"animate-spin":""}`}),"Refresh"]}),u.jsxs(Ue,{onClick:()=>l(!0),children:[u.jsx(li,{className:"w-4 h-4"}),"Add Profile"]})]})]}),u.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[u.jsxs("div",{className:"flex-1 min-w-48 relative",children:[u.jsx(Zu,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),u.jsx("input",{type:"text",value:h,onChange:V=>g(V.target.value),placeholder:"Search by name or filament...",className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),re&&u.jsx("div",{className:"w-36",children:u.jsxs("select",{value:m,onChange:V=>v(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"all",children:"All Extruders"}),u.jsx("option",{value:"left",children:"Left Only"}),u.jsx("option",{value:"right",children:"Right Only"})]})}),u.jsx("div",{className:"w-32",children:u.jsxs("select",{value:y,onChange:V=>b(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"all",children:"All Flow"}),u.jsx("option",{value:"hf",children:"HF Only"}),u.jsx("option",{value:"s",children:"S Only"})]})}),u.jsx("div",{className:"w-32",children:u.jsxs("select",{value:x,onChange:V=>M(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"name",children:"Sort: Name"}),u.jsx("option",{value:"k_value",children:"Sort: K-Value"}),u.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),u.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[u.jsxs(Ue,{variant:"secondary",onClick:pe,disabled:!P?.profiles?.length,title:"Export profiles to JSON",children:[u.jsx(va,{className:"w-4 h-4"}),"Export"]}),u.jsxs(Ue,{variant:"secondary",onClick:Ce,title:"Import profiles from JSON",children:[u.jsx(Ka,{className:"w-4 h-4"}),"Import"]}),u.jsx("div",{className:"flex-1"}),w?u.jsxs(u.Fragment,{children:[u.jsxs(Ue,{variant:"secondary",onClick:Se,title:"Select all visible profiles",children:[u.jsx(Pf,{className:"w-4 h-4"}),"Select All"]}),u.jsxs(Ue,{variant:"secondary",onClick:Re,disabled:T.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${T.size} selected profiles`,children:[u.jsx(Qn,{className:"w-4 h-4"}),"Delete (",T.size,")"]}),u.jsxs(Ue,{variant:"secondary",onClick:()=>{A(!1),R(new Set)},children:[u.jsx(Qt,{className:"w-4 h-4"}),"Cancel"]})]}):u.jsxs(Ue,{variant:"secondary",onClick:()=>A(!0),disabled:!ae.length,title:"Enter selection mode for bulk delete",children:[u.jsx(Pf,{className:"w-4 h-4"}),"Select"]})]}),$?u.jsx("div",{className:"flex justify-center py-12",children:u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin"})}):q?u.jsx(Lt,{children:u.jsxs(Ft,{className:"py-12 text-center",children:[u.jsx(fP,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),u.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),u.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),u.jsxs(Ue,{variant:"secondary",onClick:()=>Z(),children:[u.jsx(qs,{className:"w-4 h-4"}),"Retry"]})]})}):ae.length>0?re?u.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[u.jsxs("div",{children:[u.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),u.jsx("div",{className:"space-y-1",children:ae.filter(V=>V.extruder_id===1).map(V=>u.jsx(RN,{profile:V,onEdit:()=>a(V),onCopy:()=>d(V),selectionMode:w,isSelected:T.has(z(V)),onToggleSelect:()=>fe(z(V)),note:ie(V)},z(V)))})]}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),u.jsx("div",{className:"space-y-1",children:ae.filter(V=>V.extruder_id===0).map(V=>u.jsx(RN,{profile:V,onEdit:()=>a(V),onCopy:()=>d(V),selectionMode:w,isSelected:T.has(z(V)),onToggleSelect:()=>fe(z(V)),note:ie(V)},z(V)))})]})]}):u.jsx("div",{className:"space-y-1",children:ae.map(V=>u.jsx(RN,{profile:V,onEdit:()=>a(V),onCopy:()=>d(V),selectionMode:w,isSelected:T.has(z(V)),onToggleSelect:()=>fe(z(V)),note:ie(V)},z(V)))}):h||m!=="all"||y!=="all"?u.jsx(Lt,{children:u.jsxs(Ft,{className:"py-12 text-center",children:[u.jsx(Zu,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),u.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),u.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):u.jsx(Lt,{children:u.jsxs(Ft,{className:"py-12 text-center",children:[u.jsx(sP,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),u.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),u.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",r,"mm nozzle"]}),u.jsxs(Ue,{onClick:()=>l(!0),children:[u.jsx(li,{className:"w-4 h-4"}),"Create First Profile"]})]})}),s&&e&&(()=>{const{note:V,key:J}=F(s);return u.jsx(PN,{profile:s,printerId:e,nozzleDiameter:r,existingProfiles:Q?.profiles||P?.profiles,isDualNozzle:re,initialNote:V,initialNoteKey:J,onSaveNote:B,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),a(null),Z()},onSave:()=>{a(null),Z()}})})(),o&&e&&u.jsx(PN,{printerId:e,nozzleDiameter:r,existingProfiles:Q?.profiles||P?.profiles,isDualNozzle:re,onSaveNote:B,onClose:()=>{l(!1),Z()},onSave:()=>{l(!1),Z()}}),c&&e&&u.jsx(PN,{printerId:e,nozzleDiameter:r,existingProfiles:Q?.profiles||P?.profiles,isDualNozzle:re,onSaveNote:B,profile:{...c,slot_id:0,name:`${c.name} (Copy)`},onClose:()=>{d(null),Z()},onSave:()=>{d(null),Z()}}),C&&u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:u.jsx(Lt,{className:"w-full max-w-sm",children:u.jsxs(Ft,{className:"p-6",children:[u.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[u.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:u.jsx(Qn,{className:"w-5 h-5 text-red-500"})}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profiles"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),u.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",u.jsx("span",{className:"text-white font-medium",children:T.size})," selected profiles from the printer?"]}),u.jsxs("div",{className:"flex gap-3",children:[u.jsx(Ue,{variant:"secondary",onClick:()=>I(!1),disabled:N,className:"flex-1",children:"Cancel"}),u.jsxs(Ue,{onClick:ue,disabled:N,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[N?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Qn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function OL(t,e){const n=`${t} ${e||""}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,s=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),a=s?(s[1]||s[2])+"mm":null,o=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),l=o?o[1]+"mm":null,c=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),d=c?c[1].toUpperCase():null;return{printer:i,nozzle:a,layerHeight:l,filamentType:d}}function V0(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function YVe(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4),s=Math.floor(r/36e5),a=Math.floor(r/864e5);return i<1?"Just now":i<60?`${i}m ago`:s<24?`${s}h ago`:a<7?`${a}d ago`:e.toLocaleDateString()}function ZVe({onSuccess:t}){const{showToast:e}=Di(),[n,r]=E.useState("email"),[i,s]=E.useState(""),[a,o]=E.useState(""),[l,c]=E.useState(""),[d,h]=E.useState(""),[g,m]=E.useState("global"),v=At({mutationFn:()=>Le.cloudLogin(i,a,g),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):w.needs_verification?(e("Verification code sent to your email"),r("code")):e(w.message,"error")},onError:w=>e(w.message,"error")}),y=At({mutationFn:()=>Le.cloudVerify(i,l),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):e(w.message,"error")},onError:w=>e(w.message,"error")}),b=At({mutationFn:()=>Le.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:w=>e(w.message,"error")}),x=w=>{w.preventDefault(),n==="email"?v.mutate():n==="code"?y.mutate():n==="token"&&b.mutate()},M=v.isPending||y.isPending||b.isPending;return u.jsx(Lt,{className:"max-w-md mx-auto",children:u.jsxs(Ft,{children:[u.jsxs("div",{className:"text-center mb-6",children:[u.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:u.jsx(tP,{className:"w-6 h-6 text-bambu-green"})}),u.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),u.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),u.jsxs("form",{onSubmit:x,className:"space-y-4",children:[n==="email"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),u.jsx("input",{type:"email",value:i,onChange:w=>s(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),u.jsx("input",{type:"password",value:a,onChange:w=>o(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),u.jsxs("select",{value:g,onChange:w=>m(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"global",children:"Global"}),u.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),u.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),u.jsx("input",{type:"text",value:l,onChange:w=>c(w.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest font-mono focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),n==="token"&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),u.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),u.jsx("textarea",{value:d,onChange:w=>h(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:4,required:!0})]}),u.jsxs("div",{className:"flex gap-2",children:[n==="code"&&u.jsx(Ue,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),u.jsxs(Ue,{type:"submit",disabled:M,className:"flex-1",children:[M?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(pF,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&u.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:u.jsxs("button",{type:"button",onClick:()=>r("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[u.jsx(y9,{className:"w-4 h-4"}),"Use access token instead"]})}),n==="token"&&u.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:u.jsxs("button",{type:"button",onClick:()=>r("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[u.jsx(pF,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function Sp({label:t,value:e,options:n,onChange:r}){const[i,s]=E.useState(!1),a=n.find(o=>o.value===e);return u.jsxs("div",{className:"relative",children:[u.jsxs("button",{onClick:()=>s(!i),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors",children:[u.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),u.jsx("span",{children:a?.label||"All"}),u.jsx(Qf,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),u.jsx("div",{className:"absolute top-full left-0 mt-1 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 py-1 max-h-60 overflow-y-auto",children:n.map(o=>u.jsxs("button",{onClick:()=>{r(o.value),s(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${e===o.value?"text-bambu-green":"text-white"}`,children:[u.jsx("span",{children:o.label}),o.count!==void 0&&u.jsx("span",{className:"text-bambu-gray text-xs",children:o.count})]},o.value))})]})]})}function QVe(){const[t,e]=E.useState(!1);E.useEffect(()=>{const r=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?u.jsx("button",{onClick:n,className:"fixed bottom-6 right-6 p-3 bg-bambu-green hover:bg-bambu-green-light text-white rounded-full shadow-lg shadow-bambu-green/25 transition-all z-40","aria-label":"Scroll to top",children:u.jsx(Yp,{className:"w-5 h-5"})}):null}function DN({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:s,compareDisabled:a}){const o=OL(t.name),l=V0(t.setting_id);return u.jsxs("div",{className:"flex items-center gap-2 group",children:[u.jsx("button",{onClick:e,disabled:a,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${i?"bg-blue-500/20 border border-blue-500/50":a?"bg-bambu-dark/50 opacity-40 cursor-not-allowed":"bg-bambu-dark hover:bg-bambu-dark-tertiary"} ${r&&!a?"cursor-pointer":""}`,children:u.jsxs("div",{className:"flex items-center gap-2",children:[i&&s!==void 0&&u.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium",children:s+1}),!i&&l&&u.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"My preset (editable)"}),u.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),o.filamentType&&t.type==="filament"&&u.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.filamentType}),o.layerHeight&&t.type==="process"&&u.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.layerHeight}),o.printer&&u.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.printer})]})}),u.jsx("button",{onClick:c=>{c.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:"Duplicate",children:u.jsx(Jp,{className:"w-4 h-4"})})]})}function HR(t,e=0){const n=" ".repeat(e);if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string"){if(t.includes("\\n")||t.includes(` `)){const i=t.replace(/\\n/g,` `).replace(/\\"/g,'"').replace(/\\t/g," ").split(` `);if(i.length>1)return`""" diff --git a/static/index.html b/static/index.html index 5728e4425..8ba885bae 100644 --- a/static/index.html +++ b/static/index.html @@ -7,7 +7,7 @@ - +