var Dk=Object.defineProperty;var Tk=(e,t,r)=>t in e?Dk(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var go=(e,t,r)=>Tk(e,typeof t!="symbol"?t+"":t,r);function Mk(e,t){for(var r=0;rn[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function r(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(i){if(i.ep)return;i.ep=!0;const s=r(i);fetch(i.href,s)}})();function Tr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Cv={exports:{}},Oc={},Av={exports:{}},ie={};/** * @license React * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Ys=Symbol.for("react.element"),Ik=Symbol.for("react.portal"),$k=Symbol.for("react.fragment"),Lk=Symbol.for("react.strict_mode"),zk=Symbol.for("react.profiler"),Rk=Symbol.for("react.provider"),Bk=Symbol.for("react.context"),Fk=Symbol.for("react.forward_ref"),Wk=Symbol.for("react.suspense"),Uk=Symbol.for("react.memo"),qk=Symbol.for("react.lazy"),gg=Symbol.iterator;function Hk(e){return e===null||typeof e!="object"?null:(e=gg&&e[gg]||e["@@iterator"],typeof e=="function"?e:null)}var Ov={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Ev=Object.assign,Dv={};function ja(e,t,r){this.props=e,this.context=t,this.refs=Dv,this.updater=r||Ov}ja.prototype.isReactComponent={};ja.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};ja.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Tv(){}Tv.prototype=ja.prototype;function Ep(e,t,r){this.props=e,this.context=t,this.refs=Dv,this.updater=r||Ov}var Dp=Ep.prototype=new Tv;Dp.constructor=Ep;Ev(Dp,ja.prototype);Dp.isPureReactComponent=!0;var xg=Array.isArray,Mv=Object.prototype.hasOwnProperty,Tp={current:null},Iv={key:!0,ref:!0,__self:!0,__source:!0};function $v(e,t,r){var n,i={},s=null,o=null;if(t!=null)for(n in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(s=""+t.key),t)Mv.call(t,n)&&!Iv.hasOwnProperty(n)&&(i[n]=t[n]);var l=arguments.length-2;if(l===1)i.children=r;else if(1>>1,K=O[W];if(0>>1;Wi(Me,z))Ei(Q,Me)?(O[W]=Q,O[E]=z,W=E):(O[W]=Me,O[re]=z,W=re);else if(Ei(Q,z))O[W]=Q,O[E]=z,W=E;else break e}}return k}function i(O,k){var z=O.sortIndex-k.sortIndex;return z!==0?z:O.id-k.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var o=Date,l=o.now();e.unstable_now=function(){return o.now()-l}}var c=[],d=[],u=1,f=null,p=3,m=!1,x=!1,g=!1,v=typeof setTimeout=="function"?setTimeout:null,b=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(O){for(var k=r(d);k!==null;){if(k.callback===null)n(d);else if(k.startTime<=O)n(d),k.sortIndex=k.expirationTime,t(c,k);else break;k=r(d)}}function w(O){if(g=!1,y(O),!x)if(r(c)!==null)x=!0,_(S);else{var k=r(d);k!==null&&D(w,k.startTime-O)}}function S(O,k){x=!1,g&&(g=!1,b(C),C=-1),m=!0;var z=p;try{for(y(k),f=r(c);f!==null&&(!(f.expirationTime>k)||O&&!I());){var W=f.callback;if(typeof W=="function"){f.callback=null,p=f.priorityLevel;var K=W(f.expirationTime<=k);k=e.unstable_now(),typeof K=="function"?f.callback=K:f===r(c)&&n(c),y(k)}else n(c);f=r(c)}if(f!==null)var ee=!0;else{var re=r(d);re!==null&&D(w,re.startTime-k),ee=!1}return ee}finally{f=null,p=z,m=!1}}var N=!1,P=null,C=-1,T=5,$=-1;function I(){return!(e.unstable_now()-$O||125W?(O.sortIndex=z,t(d,O),r(c)===null&&O===r(d)&&(g?(b(C),C=-1):g=!0,D(w,z-W))):(O.sortIndex=K,t(c,O),x||m||(x=!0,_(S))),O},e.unstable_shouldYield=I,e.unstable_wrapCallback=function(O){var k=p;return function(){var z=p;p=k;try{return O.apply(this,arguments)}finally{p=z}}}})(Wv);Fv.exports=Wv;var r_=Fv.exports;/** * @license React * react-dom.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var n_=h,Ft=r_;function U(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,r=1;r"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ld=Object.prototype.hasOwnProperty,i_=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,vg={},bg={};function a_(e){return Ld.call(bg,e)?!0:Ld.call(vg,e)?!1:i_.test(e)?bg[e]=!0:(vg[e]=!0,!1)}function s_(e,t,r,n){if(r!==null&&r.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return n?!1:r!==null?!r.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function o_(e,t,r,n){if(t===null||typeof t>"u"||s_(e,t,r,n))return!0;if(n)return!1;if(r!==null)switch(r.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function yt(e,t,r,n,i,s,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=n,this.attributeNamespace=i,this.mustUseProperty=r,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=o}var tt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){tt[e]=new yt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];tt[t]=new yt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){tt[e]=new yt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){tt[e]=new yt(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){tt[e]=new yt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){tt[e]=new yt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){tt[e]=new yt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){tt[e]=new yt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){tt[e]=new yt(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ip=/[\-:]([a-z])/g;function $p(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Ip,$p);tt[t]=new yt(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Ip,$p);tt[t]=new yt(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Ip,$p);tt[t]=new yt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){tt[e]=new yt(e,1,!1,e.toLowerCase(),null,!1,!1)});tt.xlinkHref=new yt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){tt[e]=new yt(e,1,!1,e.toLowerCase(),null,!0,!0)});function Lp(e,t,r,n){var i=tt.hasOwnProperty(t)?tt[t]:null;(i!==null?i.type!==0:n||!(2l||i[o]!==s[l]){var c=` `+i[o].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=o&&0<=l);break}}}finally{Wu=!1,Error.prepareStackTrace=r}return(e=e?e.displayName||e.name:"")?Xa(e):""}function l_(e){switch(e.tag){case 5:return Xa(e.type);case 16:return Xa("Lazy");case 13:return Xa("Suspense");case 19:return Xa("SuspenseList");case 0:case 2:case 15:return e=Uu(e.type,!1),e;case 11:return e=Uu(e.type.render,!1),e;case 1:return e=Uu(e.type,!0),e;default:return""}}function Fd(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Li:return"Fragment";case $i:return"Portal";case zd:return"Profiler";case zp:return"StrictMode";case Rd:return"Suspense";case Bd:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Hv:return(e.displayName||"Context")+".Consumer";case qv:return(e._context.displayName||"Context")+".Provider";case Rp:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Bp:return t=e.displayName||null,t!==null?t:Fd(e.type)||"Memo";case mn:t=e._payload,e=e._init;try{return Fd(e(t))}catch{}}return null}function c_(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Fd(t);case 8:return t===zp?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function In(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Vv(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function u_(e){var t=Vv(e)?"checked":"value",r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),n=""+e[t];if(!e.hasOwnProperty(t)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var i=r.get,s=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(o){n=""+o,s.call(this,o)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(o){n=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function vo(e){e._valueTracker||(e._valueTracker=u_(e))}function Yv(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var r=t.getValue(),n="";return e&&(n=Vv(e)?e.checked?"true":"false":e.value),e=n,e!==r?(t.setValue(e),!0):!1}function pl(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Wd(e,t){var r=t.checked;return Ne({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??e._wrapperState.initialChecked})}function wg(e,t){var r=t.defaultValue==null?"":t.defaultValue,n=t.checked!=null?t.checked:t.defaultChecked;r=In(t.value!=null?t.value:r),e._wrapperState={initialChecked:n,initialValue:r,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Gv(e,t){t=t.checked,t!=null&&Lp(e,"checked",t,!1)}function Ud(e,t){Gv(e,t);var r=In(t.value),n=t.type;if(r!=null)n==="number"?(r===0&&e.value===""||e.value!=r)&&(e.value=""+r):e.value!==""+r&&(e.value=""+r);else if(n==="submit"||n==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?qd(e,t.type,r):t.hasOwnProperty("defaultValue")&&qd(e,t.type,In(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Sg(e,t,r){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var n=t.type;if(!(n!=="submit"&&n!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,r||t===e.value||(e.value=t),e.defaultValue=t}r=e.name,r!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,r!==""&&(e.name=r)}function qd(e,t,r){(t!=="number"||pl(e.ownerDocument)!==e)&&(r==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+r&&(e.defaultValue=""+r))}var Ja=Array.isArray;function Xi(e,t,r,n){if(e=e.options,t){t={};for(var i=0;i"+t.valueOf().toString()+"",t=bo.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function gs(e,t){if(t){var r=e.firstChild;if(r&&r===e.lastChild&&r.nodeType===3){r.nodeValue=t;return}}e.textContent=t}var ns={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},d_=["Webkit","ms","Moz","O"];Object.keys(ns).forEach(function(e){d_.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ns[t]=ns[e]})});function Qv(e,t,r){return t==null||typeof t=="boolean"||t===""?"":r||typeof t!="number"||t===0||ns.hasOwnProperty(e)&&ns[e]?(""+t).trim():t+"px"}function eb(e,t){e=e.style;for(var r in t)if(t.hasOwnProperty(r)){var n=r.indexOf("--")===0,i=Qv(r,t[r],n);r==="float"&&(r="cssFloat"),n?e.setProperty(r,i):e[r]=i}}var f_=Ne({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Vd(e,t){if(t){if(f_[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(U(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(U(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(U(61))}if(t.style!=null&&typeof t.style!="object")throw Error(U(62))}}function Yd(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Gd=null;function Fp(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Zd=null,Ji=null,Qi=null;function _g(e){if(e=Xs(e)){if(typeof Zd!="function")throw Error(U(280));var t=e.stateNode;t&&(t=Ic(t),Zd(e.stateNode,e.type,t))}}function tb(e){Ji?Qi?Qi.push(e):Qi=[e]:Ji=e}function rb(){if(Ji){var e=Ji,t=Qi;if(Qi=Ji=null,_g(e),t)for(e=0;e>>=0,e===0?32:31-(S_(e)/N_|0)|0}var jo=64,wo=4194304;function Qa(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function xl(e,t){var r=e.pendingLanes;if(r===0)return 0;var n=0,i=e.suspendedLanes,s=e.pingedLanes,o=r&268435455;if(o!==0){var l=o&~i;l!==0?n=Qa(l):(s&=o,s!==0&&(n=Qa(s)))}else o=r&~i,o!==0?n=Qa(o):s!==0&&(n=Qa(s));if(n===0)return 0;if(t!==0&&t!==n&&!(t&i)&&(i=n&-n,s=t&-t,i>=s||i===16&&(s&4194240)!==0))return t;if(n&4&&(n|=r&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=n;0r;r++)t.push(e);return t}function Gs(e,t,r){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-hr(t),e[t]=r}function C_(e,t){var r=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var n=e.eventTimes;for(e=e.expirationTimes;0=as),Ig=" ",$g=!1;function wb(e,t){switch(e){case"keyup":return rP.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Sb(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var zi=!1;function iP(e,t){switch(e){case"compositionend":return Sb(t);case"keypress":return t.which!==32?null:($g=!0,Ig);case"textInput":return e=t.data,e===Ig&&$g?null:e;default:return null}}function aP(e,t){if(zi)return e==="compositionend"||!Gp&&wb(e,t)?(e=bb(),el=Kp=wn=null,zi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:r,offset:t-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=Bg(r)}}function Pb(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Pb(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Cb(){for(var e=window,t=pl();t instanceof e.HTMLIFrameElement;){try{var r=typeof t.contentWindow.location.href=="string"}catch{r=!1}if(r)e=t.contentWindow;else break;t=pl(e.document)}return t}function Zp(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function hP(e){var t=Cb(),r=e.focusedElem,n=e.selectionRange;if(t!==r&&r&&r.ownerDocument&&Pb(r.ownerDocument.documentElement,r)){if(n!==null&&Zp(r)){if(t=n.start,e=n.end,e===void 0&&(e=t),"selectionStart"in r)r.selectionStart=t,r.selectionEnd=Math.min(e,r.value.length);else if(e=(t=r.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=r.textContent.length,s=Math.min(n.start,i);n=n.end===void 0?s:Math.min(n.end,i),!e.extend&&s>n&&(i=n,n=s,s=i),i=Fg(r,s);var o=Fg(r,n);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),s>n?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=r;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;r=document.documentMode,Ri=null,rf=null,os=null,nf=!1;function Wg(e,t,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;nf||Ri==null||Ri!==pl(n)||(n=Ri,"selectionStart"in n&&Zp(n)?n={start:n.selectionStart,end:n.selectionEnd}:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection(),n={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}),os&&ws(os,n)||(os=n,n=bl(rf,"onSelect"),0Wi||(e.current=uf[Wi],uf[Wi]=null,Wi--)}function me(e,t){Wi++,uf[Wi]=e.current,e.current=t}var $n={},ct=Fn($n),kt=Fn(!1),pi=$n;function oa(e,t){var r=e.type.contextTypes;if(!r)return $n;var n=e.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===t)return n.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in r)i[s]=t[s];return n&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function _t(e){return e=e.childContextTypes,e!=null}function wl(){ve(kt),ve(ct)}function Gg(e,t,r){if(ct.current!==$n)throw Error(U(168));me(ct,t),me(kt,r)}function Lb(e,t,r){var n=e.stateNode;if(t=t.childContextTypes,typeof n.getChildContext!="function")return r;n=n.getChildContext();for(var i in n)if(!(i in t))throw Error(U(108,c_(e)||"Unknown",i));return Ne({},r,n)}function Sl(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||$n,pi=ct.current,me(ct,e),me(kt,kt.current),!0}function Zg(e,t,r){var n=e.stateNode;if(!n)throw Error(U(169));r?(e=Lb(e,t,pi),n.__reactInternalMemoizedMergedChildContext=e,ve(kt),ve(ct),me(ct,e)):ve(kt),me(kt,r)}var Lr=null,$c=!1,nd=!1;function zb(e){Lr===null?Lr=[e]:Lr.push(e)}function _P(e){$c=!0,zb(e)}function Wn(){if(!nd&&Lr!==null){nd=!0;var e=0,t=ce;try{var r=Lr;for(ce=1;e>=o,i-=o,Br=1<<32-hr(t)+i|r<C?(T=P,P=null):T=P.sibling;var $=p(b,P,y[C],w);if($===null){P===null&&(P=T);break}e&&P&&$.alternate===null&&t(b,P),j=s($,j,C),N===null?S=$:N.sibling=$,N=$,P=T}if(C===y.length)return r(b,P),be&&Gn(b,C),S;if(P===null){for(;CC?(T=P,P=null):T=P.sibling;var I=p(b,P,$.value,w);if(I===null){P===null&&(P=T);break}e&&P&&I.alternate===null&&t(b,P),j=s(I,j,C),N===null?S=I:N.sibling=I,N=I,P=T}if($.done)return r(b,P),be&&Gn(b,C),S;if(P===null){for(;!$.done;C++,$=y.next())$=f(b,$.value,w),$!==null&&(j=s($,j,C),N===null?S=$:N.sibling=$,N=$);return be&&Gn(b,C),S}for(P=n(b,P);!$.done;C++,$=y.next())$=m(P,b,C,$.value,w),$!==null&&(e&&$.alternate!==null&&P.delete($.key===null?C:$.key),j=s($,j,C),N===null?S=$:N.sibling=$,N=$);return e&&P.forEach(function(A){return t(b,A)}),be&&Gn(b,C),S}function v(b,j,y,w){if(typeof y=="object"&&y!==null&&y.type===Li&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case yo:e:{for(var S=y.key,N=j;N!==null;){if(N.key===S){if(S=y.type,S===Li){if(N.tag===7){r(b,N.sibling),j=i(N,y.props.children),j.return=b,b=j;break e}}else if(N.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===mn&&Qg(S)===N.type){r(b,N.sibling),j=i(N,y.props),j.ref=Fa(b,N,y),j.return=b,b=j;break e}r(b,N);break}else t(b,N);N=N.sibling}y.type===Li?(j=oi(y.props.children,b.mode,w,y.key),j.return=b,b=j):(w=ll(y.type,y.key,y.props,null,b.mode,w),w.ref=Fa(b,j,y),w.return=b,b=w)}return o(b);case $i:e:{for(N=y.key;j!==null;){if(j.key===N)if(j.tag===4&&j.stateNode.containerInfo===y.containerInfo&&j.stateNode.implementation===y.implementation){r(b,j.sibling),j=i(j,y.children||[]),j.return=b,b=j;break e}else{r(b,j);break}else t(b,j);j=j.sibling}j=dd(y,b.mode,w),j.return=b,b=j}return o(b);case mn:return N=y._init,v(b,j,N(y._payload),w)}if(Ja(y))return x(b,j,y,w);if($a(y))return g(b,j,y,w);Ao(b,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,j!==null&&j.tag===6?(r(b,j.sibling),j=i(j,y),j.return=b,b=j):(r(b,j),j=ud(y,b.mode,w),j.return=b,b=j),o(b)):r(b,j)}return v}var ca=Wb(!0),Ub=Wb(!1),_l=Fn(null),Pl=null,Hi=null,eh=null;function th(){eh=Hi=Pl=null}function rh(e){var t=_l.current;ve(_l),e._currentValue=t}function pf(e,t,r){for(;e!==null;){var n=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,n!==null&&(n.childLanes|=t)):n!==null&&(n.childLanes&t)!==t&&(n.childLanes|=t),e===r)break;e=e.return}}function ta(e,t){Pl=e,eh=Hi=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(St=!0),e.firstContext=null)}function tr(e){var t=e._currentValue;if(eh!==e)if(e={context:e,memoizedValue:t,next:null},Hi===null){if(Pl===null)throw Error(U(308));Hi=e,Pl.dependencies={lanes:0,firstContext:e}}else Hi=Hi.next=e;return t}var ti=null;function nh(e){ti===null?ti=[e]:ti.push(e)}function qb(e,t,r,n){var i=t.interleaved;return i===null?(r.next=r,nh(t)):(r.next=i.next,i.next=r),t.interleaved=r,Zr(e,n)}function Zr(e,t){e.lanes|=t;var r=e.alternate;for(r!==null&&(r.lanes|=t),r=e,e=e.return;e!==null;)e.childLanes|=t,r=e.alternate,r!==null&&(r.childLanes|=t),r=e,e=e.return;return r.tag===3?r.stateNode:null}var gn=!1;function ih(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Hb(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function qr(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function An(e,t,r){var n=e.updateQueue;if(n===null)return null;if(n=n.shared,ae&2){var i=n.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),n.pending=t,Zr(e,r)}return i=n.interleaved,i===null?(t.next=t,nh(n)):(t.next=i.next,i.next=t),n.interleaved=t,Zr(e,r)}function rl(e,t,r){if(t=t.updateQueue,t!==null&&(t=t.shared,(r&4194240)!==0)){var n=t.lanes;n&=e.pendingLanes,r|=n,t.lanes=r,Up(e,r)}}function ex(e,t){var r=e.updateQueue,n=e.alternate;if(n!==null&&(n=n.updateQueue,r===n)){var i=null,s=null;if(r=r.firstBaseUpdate,r!==null){do{var o={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};s===null?i=s=o:s=s.next=o,r=r.next}while(r!==null);s===null?i=s=t:s=s.next=t}else i=s=t;r={baseState:n.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:n.shared,effects:n.effects},e.updateQueue=r;return}e=r.lastBaseUpdate,e===null?r.firstBaseUpdate=t:e.next=t,r.lastBaseUpdate=t}function Cl(e,t,r,n){var i=e.updateQueue;gn=!1;var s=i.firstBaseUpdate,o=i.lastBaseUpdate,l=i.shared.pending;if(l!==null){i.shared.pending=null;var c=l,d=c.next;c.next=null,o===null?s=d:o.next=d,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,l=u.lastBaseUpdate,l!==o&&(l===null?u.firstBaseUpdate=d:l.next=d,u.lastBaseUpdate=c))}if(s!==null){var f=i.baseState;o=0,u=d=c=null,l=s;do{var p=l.lane,m=l.eventTime;if((n&p)===p){u!==null&&(u=u.next={eventTime:m,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var x=e,g=l;switch(p=t,m=r,g.tag){case 1:if(x=g.payload,typeof x=="function"){f=x.call(m,f,p);break e}f=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=g.payload,p=typeof x=="function"?x.call(m,f,p):x,p==null)break e;f=Ne({},f,p);break e;case 2:gn=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=i.effects,p===null?i.effects=[l]:p.push(l))}else m={eventTime:m,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},u===null?(d=u=m,c=f):u=u.next=m,o|=p;if(l=l.next,l===null){if(l=i.shared.pending,l===null)break;p=l,l=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(!0);if(u===null&&(c=f),i.baseState=c,i.firstBaseUpdate=d,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else s===null&&(i.shared.lanes=0);gi|=o,e.lanes=o,e.memoizedState=f}}function tx(e,t,r){if(e=t.effects,t.effects=null,e!==null)for(t=0;tr?r:4,e(!0);var n=ad.transition;ad.transition={};try{e(!1),t()}finally{ce=r,ad.transition=n}}function l1(){return rr().memoizedState}function OP(e,t,r){var n=En(e);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},c1(e))u1(t,r);else if(r=qb(e,t,r,n),r!==null){var i=gt();mr(r,e,n,i),d1(r,t,n)}}function EP(e,t,r){var n=En(e),i={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(c1(e))u1(t,i);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var o=t.lastRenderedState,l=s(o,r);if(i.hasEagerState=!0,i.eagerState=l,gr(l,o)){var c=t.interleaved;c===null?(i.next=i,nh(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}finally{}r=qb(e,t,i,n),r!==null&&(i=gt(),mr(r,e,n,i),d1(r,t,n))}}function c1(e){var t=e.alternate;return e===Se||t!==null&&t===Se}function u1(e,t){ls=Ol=!0;var r=e.pending;r===null?t.next=t:(t.next=r.next,r.next=t),e.pending=t}function d1(e,t,r){if(r&4194240){var n=t.lanes;n&=e.pendingLanes,r|=n,t.lanes=r,Up(e,r)}}var El={readContext:tr,useCallback:nt,useContext:nt,useEffect:nt,useImperativeHandle:nt,useInsertionEffect:nt,useLayoutEffect:nt,useMemo:nt,useReducer:nt,useRef:nt,useState:nt,useDebugValue:nt,useDeferredValue:nt,useTransition:nt,useMutableSource:nt,useSyncExternalStore:nt,useId:nt,unstable_isNewReconciler:!1},DP={readContext:tr,useCallback:function(e,t){return jr().memoizedState=[e,t===void 0?null:t],e},useContext:tr,useEffect:nx,useImperativeHandle:function(e,t,r){return r=r!=null?r.concat([e]):null,il(4194308,4,n1.bind(null,t,e),r)},useLayoutEffect:function(e,t){return il(4194308,4,e,t)},useInsertionEffect:function(e,t){return il(4,2,e,t)},useMemo:function(e,t){var r=jr();return t=t===void 0?null:t,e=e(),r.memoizedState=[e,t],e},useReducer:function(e,t,r){var n=jr();return t=r!==void 0?r(t):t,n.memoizedState=n.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},n.queue=e,e=e.dispatch=OP.bind(null,Se,e),[n.memoizedState,e]},useRef:function(e){var t=jr();return e={current:e},t.memoizedState=e},useState:rx,useDebugValue:fh,useDeferredValue:function(e){return jr().memoizedState=e},useTransition:function(){var e=rx(!1),t=e[0];return e=AP.bind(null,e[1]),jr().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,r){var n=Se,i=jr();if(be){if(r===void 0)throw Error(U(407));r=r()}else{if(r=t(),Ve===null)throw Error(U(349));mi&30||Gb(n,t,r)}i.memoizedState=r;var s={value:r,getSnapshot:t};return i.queue=s,nx(Xb.bind(null,n,s,e),[e]),n.flags|=2048,Os(9,Zb.bind(null,n,s,r,t),void 0,null),r},useId:function(){var e=jr(),t=Ve.identifierPrefix;if(be){var r=Fr,n=Br;r=(n&~(1<<32-hr(n)-1)).toString(32)+r,t=":"+t+"R"+r,r=Cs++,0<\/script>",e=e.removeChild(e.firstChild)):typeof n.is=="string"?e=o.createElement(r,{is:n.is}):(e=o.createElement(r),r==="select"&&(o=e,n.multiple?o.multiple=!0:n.size&&(o.size=n.size))):e=o.createElementNS(e,r),e[Sr]=t,e[ks]=n,j1(e,t,!1,!1),t.stateNode=e;e:{switch(o=Yd(r,n),r){case"dialog":xe("cancel",e),xe("close",e),i=n;break;case"iframe":case"object":case"embed":xe("load",e),i=n;break;case"video":case"audio":for(i=0;ifa&&(t.flags|=128,n=!0,Wa(s,!1),t.lanes=4194304)}else{if(!n)if(e=Al(o),e!==null){if(t.flags|=128,n=!0,r=e.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),Wa(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!be)return it(t),null}else 2*Ce()-s.renderingStartTime>fa&&r!==1073741824&&(t.flags|=128,n=!0,Wa(s,!1),t.lanes=4194304);s.isBackwards?(o.sibling=t.child,t.child=o):(r=s.last,r!==null?r.sibling=o:t.child=o,s.last=o)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=Ce(),t.sibling=null,r=we.current,me(we,n?r&1|2:r&1),t):(it(t),null);case 22:case 23:return yh(),n=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==n&&(t.flags|=8192),n&&t.mode&1?It&1073741824&&(it(t),t.subtreeFlags&6&&(t.flags|=8192)):it(t),null;case 24:return null;case 25:return null}throw Error(U(156,t.tag))}function BP(e,t){switch(Jp(t),t.tag){case 1:return _t(t.type)&&wl(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ua(),ve(kt),ve(ct),oh(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return sh(t),null;case 13:if(ve(we),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(U(340));la()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ve(we),null;case 4:return ua(),null;case 10:return rh(t.type._context),null;case 22:case 23:return yh(),null;case 24:return null;default:return null}}var Eo=!1,st=!1,FP=typeof WeakSet=="function"?WeakSet:Set,V=null;function Ki(e,t){var r=e.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){ke(e,t,n)}else r.current=null}function wf(e,t,r){try{r()}catch(n){ke(e,t,n)}}var hx=!1;function WP(e,t){if(af=yl,e=Cb(),Zp(e)){if("selectionStart"in e)var r={start:e.selectionStart,end:e.selectionEnd};else e:{r=(r=e.ownerDocument)&&r.defaultView||window;var n=r.getSelection&&r.getSelection();if(n&&n.rangeCount!==0){r=n.anchorNode;var i=n.anchorOffset,s=n.focusNode;n=n.focusOffset;try{r.nodeType,s.nodeType}catch{r=null;break e}var o=0,l=-1,c=-1,d=0,u=0,f=e,p=null;t:for(;;){for(var m;f!==r||i!==0&&f.nodeType!==3||(l=o+i),f!==s||n!==0&&f.nodeType!==3||(c=o+n),f.nodeType===3&&(o+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break t;if(p===r&&++d===i&&(l=o),p===s&&++u===n&&(c=o),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}r=l===-1||c===-1?null:{start:l,end:c}}else r=null}r=r||{start:0,end:0}}else r=null;for(sf={focusedElem:e,selectionRange:r},yl=!1,V=t;V!==null;)if(t=V,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,V=e;else for(;V!==null;){t=V;try{var x=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(x!==null){var g=x.memoizedProps,v=x.memoizedState,b=t.stateNode,j=b.getSnapshotBeforeUpdate(t.elementType===t.type?g:cr(t.type,g),v);b.__reactInternalSnapshotBeforeUpdate=j}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(U(163))}}catch(w){ke(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,V=e;break}V=t.return}return x=hx,hx=!1,x}function cs(e,t,r){var n=t.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var s=i.destroy;i.destroy=void 0,s!==void 0&&wf(t,r,s)}i=i.next}while(i!==n)}}function Rc(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var r=t=t.next;do{if((r.tag&e)===e){var n=r.create;r.destroy=n()}r=r.next}while(r!==t)}}function Sf(e){var t=e.ref;if(t!==null){var r=e.stateNode;switch(e.tag){case 5:e=r;break;default:e=r}typeof t=="function"?t(e):t.current=e}}function N1(e){var t=e.alternate;t!==null&&(e.alternate=null,N1(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Sr],delete t[ks],delete t[cf],delete t[NP],delete t[kP])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function k1(e){return e.tag===5||e.tag===3||e.tag===4}function mx(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||k1(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Nf(e,t,r){var n=e.tag;if(n===5||n===6)e=e.stateNode,t?r.nodeType===8?r.parentNode.insertBefore(e,t):r.insertBefore(e,t):(r.nodeType===8?(t=r.parentNode,t.insertBefore(e,r)):(t=r,t.appendChild(e)),r=r._reactRootContainer,r!=null||t.onclick!==null||(t.onclick=jl));else if(n!==4&&(e=e.child,e!==null))for(Nf(e,t,r),e=e.sibling;e!==null;)Nf(e,t,r),e=e.sibling}function kf(e,t,r){var n=e.tag;if(n===5||n===6)e=e.stateNode,t?r.insertBefore(e,t):r.appendChild(e);else if(n!==4&&(e=e.child,e!==null))for(kf(e,t,r),e=e.sibling;e!==null;)kf(e,t,r),e=e.sibling}var Xe=null,ur=!1;function hn(e,t,r){for(r=r.child;r!==null;)_1(e,t,r),r=r.sibling}function _1(e,t,r){if(kr&&typeof kr.onCommitFiberUnmount=="function")try{kr.onCommitFiberUnmount(Ec,r)}catch{}switch(r.tag){case 5:st||Ki(r,t);case 6:var n=Xe,i=ur;Xe=null,hn(e,t,r),Xe=n,ur=i,Xe!==null&&(ur?(e=Xe,r=r.stateNode,e.nodeType===8?e.parentNode.removeChild(r):e.removeChild(r)):Xe.removeChild(r.stateNode));break;case 18:Xe!==null&&(ur?(e=Xe,r=r.stateNode,e.nodeType===8?rd(e.parentNode,r):e.nodeType===1&&rd(e,r),bs(e)):rd(Xe,r.stateNode));break;case 4:n=Xe,i=ur,Xe=r.stateNode.containerInfo,ur=!0,hn(e,t,r),Xe=n,ur=i;break;case 0:case 11:case 14:case 15:if(!st&&(n=r.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){i=n=n.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&wf(r,t,o),i=i.next}while(i!==n)}hn(e,t,r);break;case 1:if(!st&&(Ki(r,t),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(l){ke(r,t,l)}hn(e,t,r);break;case 21:hn(e,t,r);break;case 22:r.mode&1?(st=(n=st)||r.memoizedState!==null,hn(e,t,r),st=n):hn(e,t,r);break;default:hn(e,t,r)}}function gx(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var r=e.stateNode;r===null&&(r=e.stateNode=new FP),t.forEach(function(n){var i=XP.bind(null,e,n);r.has(n)||(r.add(n),n.then(i,i))})}}function lr(e,t){var r=t.deletions;if(r!==null)for(var n=0;ni&&(i=o),n&=~s}if(n=i,n=Ce()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*qP(n/1960))-n,10e?16:e,Sn===null)var n=!1;else{if(e=Sn,Sn=null,Ml=0,ae&6)throw Error(U(331));var i=ae;for(ae|=4,V=e.current;V!==null;){var s=V,o=s.child;if(V.flags&16){var l=s.deletions;if(l!==null){for(var c=0;cCe()-gh?si(e,0):mh|=r),Pt(e,t)}function M1(e,t){t===0&&(e.mode&1?(t=wo,wo<<=1,!(wo&130023424)&&(wo=4194304)):t=1);var r=gt();e=Zr(e,t),e!==null&&(Gs(e,t,r),Pt(e,r))}function ZP(e){var t=e.memoizedState,r=0;t!==null&&(r=t.retryLane),M1(e,r)}function XP(e,t){var r=0;switch(e.tag){case 13:var n=e.stateNode,i=e.memoizedState;i!==null&&(r=i.retryLane);break;case 19:n=e.stateNode;break;default:throw Error(U(314))}n!==null&&n.delete(t),M1(e,r)}var I1;I1=function(e,t,r){if(e!==null)if(e.memoizedProps!==t.pendingProps||kt.current)St=!0;else{if(!(e.lanes&r)&&!(t.flags&128))return St=!1,zP(e,t,r);St=!!(e.flags&131072)}else St=!1,be&&t.flags&1048576&&Rb(t,kl,t.index);switch(t.lanes=0,t.tag){case 2:var n=t.type;al(e,t),e=t.pendingProps;var i=oa(t,ct.current);ta(t,r),i=ch(null,t,n,e,i,r);var s=uh();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,_t(n)?(s=!0,Sl(t)):s=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,ih(t),i.updater=zc,t.stateNode=i,i._reactInternals=t,mf(t,n,e,r),t=yf(null,t,n,!0,s,r)):(t.tag=0,be&&s&&Xp(t),ht(null,t,i,r),t=t.child),t;case 16:n=t.elementType;e:{switch(al(e,t),e=t.pendingProps,i=n._init,n=i(n._payload),t.type=n,i=t.tag=QP(n),e=cr(n,e),i){case 0:t=xf(null,t,n,e,r);break e;case 1:t=dx(null,t,n,e,r);break e;case 11:t=cx(null,t,n,e,r);break e;case 14:t=ux(null,t,n,cr(n.type,e),r);break e}throw Error(U(306,n,""))}return t;case 0:return n=t.type,i=t.pendingProps,i=t.elementType===n?i:cr(n,i),xf(e,t,n,i,r);case 1:return n=t.type,i=t.pendingProps,i=t.elementType===n?i:cr(n,i),dx(e,t,n,i,r);case 3:e:{if(y1(t),e===null)throw Error(U(387));n=t.pendingProps,s=t.memoizedState,i=s.element,Hb(e,t),Cl(t,n,null,r);var o=t.memoizedState;if(n=o.element,s.isDehydrated)if(s={element:n,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){i=da(Error(U(423)),t),t=fx(e,t,n,r,i);break e}else if(n!==i){i=da(Error(U(424)),t),t=fx(e,t,n,r,i);break e}else for(zt=Cn(t.stateNode.containerInfo.firstChild),Rt=t,be=!0,dr=null,r=Ub(t,null,n,r),t.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(la(),n===i){t=Xr(e,t,r);break e}ht(e,t,n,r)}t=t.child}return t;case 5:return Kb(t),e===null&&ff(t),n=t.type,i=t.pendingProps,s=e!==null?e.memoizedProps:null,o=i.children,of(n,i)?o=null:s!==null&&of(n,s)&&(t.flags|=32),x1(e,t),ht(e,t,o,r),t.child;case 6:return e===null&&ff(t),null;case 13:return v1(e,t,r);case 4:return ah(t,t.stateNode.containerInfo),n=t.pendingProps,e===null?t.child=ca(t,null,n,r):ht(e,t,n,r),t.child;case 11:return n=t.type,i=t.pendingProps,i=t.elementType===n?i:cr(n,i),cx(e,t,n,i,r);case 7:return ht(e,t,t.pendingProps,r),t.child;case 8:return ht(e,t,t.pendingProps.children,r),t.child;case 12:return ht(e,t,t.pendingProps.children,r),t.child;case 10:e:{if(n=t.type._context,i=t.pendingProps,s=t.memoizedProps,o=i.value,me(_l,n._currentValue),n._currentValue=o,s!==null)if(gr(s.value,o)){if(s.children===i.children&&!kt.current){t=Xr(e,t,r);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var l=s.dependencies;if(l!==null){o=s.child;for(var c=l.firstContext;c!==null;){if(c.context===n){if(s.tag===1){c=qr(-1,r&-r),c.tag=2;var d=s.updateQueue;if(d!==null){d=d.shared;var u=d.pending;u===null?c.next=c:(c.next=u.next,u.next=c),d.pending=c}}s.lanes|=r,c=s.alternate,c!==null&&(c.lanes|=r),pf(s.return,r,t),l.lanes|=r;break}c=c.next}}else if(s.tag===10)o=s.type===t.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(U(341));o.lanes|=r,l=o.alternate,l!==null&&(l.lanes|=r),pf(o,r,t),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===t){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}ht(e,t,i.children,r),t=t.child}return t;case 9:return i=t.type,n=t.pendingProps.children,ta(t,r),i=tr(i),n=n(i),t.flags|=1,ht(e,t,n,r),t.child;case 14:return n=t.type,i=cr(n,t.pendingProps),i=cr(n.type,i),ux(e,t,n,i,r);case 15:return m1(e,t,t.type,t.pendingProps,r);case 17:return n=t.type,i=t.pendingProps,i=t.elementType===n?i:cr(n,i),al(e,t),t.tag=1,_t(n)?(e=!0,Sl(t)):e=!1,ta(t,r),f1(t,n,i),mf(t,n,i,r),yf(null,t,n,!0,e,r);case 19:return b1(e,t,r);case 22:return g1(e,t,r)}throw Error(U(156,t.tag))};function $1(e,t){return cb(e,t)}function JP(e,t,r,n){this.tag=e,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Zt(e,t,r,n){return new JP(e,t,r,n)}function bh(e){return e=e.prototype,!(!e||!e.isReactComponent)}function QP(e){if(typeof e=="function")return bh(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Rp)return 11;if(e===Bp)return 14}return 2}function Dn(e,t){var r=e.alternate;return r===null?(r=Zt(e.tag,t,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=t,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&14680064,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,t=e.dependencies,r.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r}function ll(e,t,r,n,i,s){var o=2;if(n=e,typeof e=="function")bh(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case Li:return oi(r.children,i,s,t);case zp:o=8,i|=8;break;case zd:return e=Zt(12,r,t,i|2),e.elementType=zd,e.lanes=s,e;case Rd:return e=Zt(13,r,t,i),e.elementType=Rd,e.lanes=s,e;case Bd:return e=Zt(19,r,t,i),e.elementType=Bd,e.lanes=s,e;case Kv:return Fc(r,i,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case qv:o=10;break e;case Hv:o=9;break e;case Rp:o=11;break e;case Bp:o=14;break e;case mn:o=16,n=null;break e}throw Error(U(130,e==null?e:typeof e,""))}return t=Zt(o,r,t,i),t.elementType=e,t.type=n,t.lanes=s,t}function oi(e,t,r,n){return e=Zt(7,e,n,t),e.lanes=r,e}function Fc(e,t,r,n){return e=Zt(22,e,n,t),e.elementType=Kv,e.lanes=r,e.stateNode={isHidden:!1},e}function ud(e,t,r){return e=Zt(6,e,null,t),e.lanes=r,e}function dd(e,t,r){return t=Zt(4,e.children!==null?e.children:[],e.key,t),t.lanes=r,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function eC(e,t,r,n,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Hu(0),this.expirationTimes=Hu(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Hu(0),this.identifierPrefix=n,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function jh(e,t,r,n,i,s,o,l,c){return e=new eC(e,t,r,l,c),t===1?(t=1,s===!0&&(t|=8)):t=0,s=Zt(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},ih(s),e}function tC(e,t,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(B1)}catch(e){console.error(e)}}B1(),Bv.exports=Ut;var kh=Bv.exports,Nx=kh;$d.createRoot=Nx.createRoot,$d.hydrateRoot=Nx.hydrateRoot;/** * @remix-run/router v1.23.1 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function Ds(){return Ds=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function _h(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function oC(){return Math.random().toString(36).substr(2,8)}function _x(e,t){return{usr:e.state,key:e.key,idx:t}}function Of(e,t,r,n){return r===void 0&&(r=null),Ds({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?Na(t):t,{state:r,key:t&&t.key||n||oC()})}function Ll(e){let{pathname:t="/",search:r="",hash:n=""}=e;return r&&r!=="?"&&(t+=r.charAt(0)==="?"?r:"?"+r),n&&n!=="#"&&(t+=n.charAt(0)==="#"?n:"#"+n),t}function Na(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substr(r),e=e.substr(0,r));let n=e.indexOf("?");n>=0&&(t.search=e.substr(n),e=e.substr(0,n)),e&&(t.pathname=e)}return t}function lC(e,t,r,n){n===void 0&&(n={});let{window:i=document.defaultView,v5Compat:s=!1}=n,o=i.history,l=Nn.Pop,c=null,d=u();d==null&&(d=0,o.replaceState(Ds({},o.state,{idx:d}),""));function u(){return(o.state||{idx:null}).idx}function f(){l=Nn.Pop;let v=u(),b=v==null?null:v-d;d=v,c&&c({action:l,location:g.location,delta:b})}function p(v,b){l=Nn.Push;let j=Of(g.location,v,b);d=u()+1;let y=_x(j,d),w=g.createHref(j);try{o.pushState(y,"",w)}catch(S){if(S instanceof DOMException&&S.name==="DataCloneError")throw S;i.location.assign(w)}s&&c&&c({action:l,location:g.location,delta:1})}function m(v,b){l=Nn.Replace;let j=Of(g.location,v,b);d=u();let y=_x(j,d),w=g.createHref(j);o.replaceState(y,"",w),s&&c&&c({action:l,location:g.location,delta:0})}function x(v){let b=i.location.origin!=="null"?i.location.origin:i.location.href,j=typeof v=="string"?v:Ll(v);return j=j.replace(/ $/,"%20"),Ae(b,"No window.location.(origin|href) available to create URL for href: "+j),new URL(j,b)}let g={get action(){return l},get location(){return e(i,o)},listen(v){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(kx,f),c=v,()=>{i.removeEventListener(kx,f),c=null}},createHref(v){return t(i,v)},createURL:x,encodeLocation(v){let b=x(v);return{pathname:b.pathname,search:b.search,hash:b.hash}},push:p,replace:m,go(v){return o.go(v)}};return g}var Px;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(Px||(Px={}));function cC(e,t,r){return r===void 0&&(r="/"),uC(e,t,r)}function uC(e,t,r,n){let i=typeof t=="string"?Na(t):t,s=Ph(i.pathname||"/",r);if(s==null)return null;let o=F1(e);dC(o);let l=null;for(let c=0;l==null&&c{let c={relativePath:l===void 0?s.path||"":l,caseSensitive:s.caseSensitive===!0,childrenIndex:o,route:s};c.relativePath.startsWith("/")&&(Ae(c.relativePath.startsWith(n),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+n+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(n.length));let d=Tn([n,c.relativePath]),u=r.concat(c);s.children&&s.children.length>0&&(Ae(s.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+d+'".')),F1(s.children,t,u,d)),!(s.path==null&&!s.index)&&t.push({path:d,score:yC(d,s.index),routesMeta:u})};return e.forEach((s,o)=>{var l;if(s.path===""||!((l=s.path)!=null&&l.includes("?")))i(s,o);else for(let c of W1(s.path))i(s,o,c)}),t}function W1(e){let t=e.split("/");if(t.length===0)return[];let[r,...n]=t,i=r.endsWith("?"),s=r.replace(/\?$/,"");if(n.length===0)return i?[s,""]:[s];let o=W1(n.join("/")),l=[];return l.push(...o.map(c=>c===""?s:[s,c].join("/"))),i&&l.push(...o),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function dC(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:vC(t.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const fC=/^:[\w-]+$/,pC=3,hC=2,mC=1,gC=10,xC=-2,Cx=e=>e==="*";function yC(e,t){let r=e.split("/"),n=r.length;return r.some(Cx)&&(n+=xC),t&&(n+=hC),r.filter(i=>!Cx(i)).reduce((i,s)=>i+(fC.test(s)?pC:s===""?mC:gC),n)}function vC(e,t){return e.length===t.length&&e.slice(0,-1).every((n,i)=>n===t[i])?e[e.length-1]-t[t.length-1]:0}function bC(e,t,r){let{routesMeta:n}=e,i={},s="/",o=[];for(let l=0;l{let{paramName:p,isOptional:m}=u;if(p==="*"){let g=l[f]||"";o=s.slice(0,s.length-g.length).replace(/(.)\/+$/,"$1")}const x=l[f];return m&&!x?d[p]=void 0:d[p]=(x||"").replace(/%2F/g,"/"),d},{}),pathname:s,pathnameBase:o,pattern:e}}function wC(e,t,r){t===void 0&&(t=!1),r===void 0&&(r=!0),_h(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let n=[],i="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c)=>(n.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(n.push({paramName:"*"}),i+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?i+="\\/*$":e!==""&&e!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,t?void 0:"i"),n]}function SC(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return _h(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Ph(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,n=e.charAt(r);return n&&n!=="/"?null:e.slice(r)||"/"}const NC=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,kC=e=>NC.test(e);function _C(e,t){t===void 0&&(t="/");let{pathname:r,search:n="",hash:i=""}=typeof e=="string"?Na(e):e,s;if(r)if(kC(r))s=r;else{if(r.includes("//")){let o=r;r=r.replace(/\/\/+/g,"/"),_h(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+r))}r.startsWith("/")?s=Ax(r.substring(1),"/"):s=Ax(r,t)}else s=t;return{pathname:s,search:AC(n),hash:OC(i)}}function Ax(e,t){let r=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(i=>{i===".."?r.length>1&&r.pop():i!=="."&&r.push(i)}),r.length>1?r.join("/"):"/"}function fd(e,t,r,n){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(n)+"]. Please separate it out to the ")+("`to."+r+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function PC(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function Ch(e,t){let r=PC(e);return t?r.map((n,i)=>i===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function Ah(e,t,r,n){n===void 0&&(n=!1);let i;typeof e=="string"?i=Na(e):(i=Ds({},e),Ae(!i.pathname||!i.pathname.includes("?"),fd("?","pathname","search",i)),Ae(!i.pathname||!i.pathname.includes("#"),fd("#","pathname","hash",i)),Ae(!i.search||!i.search.includes("#"),fd("#","search","hash",i)));let s=e===""||i.pathname==="",o=s?"/":i.pathname,l;if(o==null)l=r;else{let f=t.length-1;if(!n&&o.startsWith("..")){let p=o.split("/");for(;p[0]==="..";)p.shift(),f-=1;i.pathname=p.join("/")}l=f>=0?t[f]:"/"}let c=_C(i,l),d=o&&o!=="/"&&o.endsWith("/"),u=(s||o===".")&&r.endsWith("/");return!c.pathname.endsWith("/")&&(d||u)&&(c.pathname+="/"),c}const Tn=e=>e.join("/").replace(/\/\/+/g,"/"),CC=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),AC=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,OC=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function EC(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const U1=["post","put","patch","delete"];new Set(U1);const DC=["get",...U1];new Set(DC);/** * React Router v6.30.2 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function Ts(){return Ts=Object.assign?Object.assign.bind():function(e){for(var t=1;t{l.current=!0}),h.useCallback(function(d,u){if(u===void 0&&(u={}),!l.current)return;if(typeof d=="number"){n.go(d);return}let f=Ah(d,JSON.parse(o),s,u.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Tn([t,f.pathname])),(u.replace?n.replace:n.push)(f,u.state,u)},[t,n,o,s,e])}function _a(){let{matches:e}=h.useContext(on),t=e[e.length-1];return t?t.params:{}}function K1(e,t){let{relative:r}=t===void 0?{}:t,{future:n}=h.useContext(Un),{matches:i}=h.useContext(on),{pathname:s}=Pi(),o=JSON.stringify(Ch(i,n.v7_relativeSplatPath));return h.useMemo(()=>Ah(e,JSON.parse(o),s,r==="path"),[e,o,s,r])}function $C(e,t){return LC(e,t)}function LC(e,t,r,n){ka()||Ae(!1);let{navigator:i}=h.useContext(Un),{matches:s}=h.useContext(on),o=s[s.length-1],l=o?o.params:{};o&&o.pathname;let c=o?o.pathnameBase:"/";o&&o.route;let d=Pi(),u;if(t){var f;let v=typeof t=="string"?Na(t):t;c==="/"||(f=v.pathname)!=null&&f.startsWith(c)||Ae(!1),u=v}else u=d;let p=u.pathname||"/",m=p;if(c!=="/"){let v=c.replace(/^\//,"").split("/");m="/"+p.replace(/^\//,"").split("/").slice(v.length).join("/")}let x=cC(e,{pathname:m}),g=WC(x&&x.map(v=>Object.assign({},v,{params:Object.assign({},l,v.params),pathname:Tn([c,i.encodeLocation?i.encodeLocation(v.pathname).pathname:v.pathname]),pathnameBase:v.pathnameBase==="/"?c:Tn([c,i.encodeLocation?i.encodeLocation(v.pathnameBase).pathname:v.pathnameBase])})),s,r,n);return t&&g?h.createElement(Kc.Provider,{value:{location:Ts({pathname:"/",search:"",hash:"",state:null,key:"default"},u),navigationType:Nn.Pop}},g):g}function zC(){let e=KC(),t=EC(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,i={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return h.createElement(h.Fragment,null,h.createElement("h2",null,"Unexpected Application Error!"),h.createElement("h3",{style:{fontStyle:"italic"}},t),r?h.createElement("pre",{style:i},r):null,null)}const RC=h.createElement(zC,null);class BC extends h.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,r){return r.location!==t.location||r.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:r.error,location:r.location,revalidation:t.revalidation||r.revalidation}}componentDidCatch(t,r){console.error("React Router caught the following error during render",t,r)}render(){return this.state.error!==void 0?h.createElement(on.Provider,{value:this.props.routeContext},h.createElement(q1.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function FC(e){let{routeContext:t,match:r,children:n}=e,i=h.useContext(Oh);return i&&i.static&&i.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=r.route.id),h.createElement(on.Provider,{value:t},n)}function WC(e,t,r,n){var i;if(t===void 0&&(t=[]),r===void 0&&(r=null),n===void 0&&(n=null),e==null){var s;if(!r)return null;if(r.errors)e=r.matches;else if((s=n)!=null&&s.v7_partialHydration&&t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let o=e,l=(i=r)==null?void 0:i.errors;if(l!=null){let u=o.findIndex(f=>f.route.id&&(l==null?void 0:l[f.route.id])!==void 0);u>=0||Ae(!1),o=o.slice(0,Math.min(o.length,u+1))}let c=!1,d=-1;if(r&&n&&n.v7_partialHydration)for(let u=0;u=0?o=o.slice(0,d+1):o=[o[0]];break}}}return o.reduceRight((u,f,p)=>{let m,x=!1,g=null,v=null;r&&(m=l&&f.route.id?l[f.route.id]:void 0,g=f.route.errorElement||RC,c&&(d<0&&p===0?(YC("route-fallback"),x=!0,v=null):d===p&&(x=!0,v=f.route.hydrateFallbackElement||null)));let b=t.concat(o.slice(0,p+1)),j=()=>{let y;return m?y=g:x?y=v:f.route.Component?y=h.createElement(f.route.Component,null):f.route.element?y=f.route.element:y=u,h.createElement(FC,{match:f,routeContext:{outlet:u,matches:b,isDataRoute:r!=null},children:y})};return r&&(f.route.ErrorBoundary||f.route.errorElement||p===0)?h.createElement(BC,{location:r.location,revalidation:r.revalidation,component:g,error:m,children:j(),routeContext:{outlet:null,matches:b,isDataRoute:!0}}):j()},null)}var V1=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(V1||{}),Y1=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(Y1||{});function UC(e){let t=h.useContext(Oh);return t||Ae(!1),t}function qC(e){let t=h.useContext(TC);return t||Ae(!1),t}function HC(e){let t=h.useContext(on);return t||Ae(!1),t}function G1(e){let t=HC(),r=t.matches[t.matches.length-1];return r.route.id||Ae(!1),r.route.id}function KC(){var e;let t=h.useContext(q1),r=qC(),n=G1();return t!==void 0?t:(e=r.errors)==null?void 0:e[n]}function VC(){let{router:e}=UC(V1.UseNavigateStable),t=G1(Y1.UseNavigateStable),r=h.useRef(!1);return H1(()=>{r.current=!0}),h.useCallback(function(i,s){s===void 0&&(s={}),r.current&&(typeof i=="number"?e.navigate(i):e.navigate(i,Ts({fromRouteId:t},s)))},[e,t])}const Ox={};function YC(e,t,r){Ox[e]||(Ox[e]=!0)}function GC(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function Z1(e){let{to:t,replace:r,state:n,relative:i}=e;ka()||Ae(!1);let{future:s,static:o}=h.useContext(Un),{matches:l}=h.useContext(on),{pathname:c}=Pi(),d=dt(),u=Ah(t,Ch(l,s.v7_relativeSplatPath),c,i==="path"),f=JSON.stringify(u);return h.useEffect(()=>d(JSON.parse(f),{replace:r,state:n,relative:i}),[d,f,i,r,n]),null}function oe(e){Ae(!1)}function ZC(e){let{basename:t="/",children:r=null,location:n,navigationType:i=Nn.Pop,navigator:s,static:o=!1,future:l}=e;ka()&&Ae(!1);let c=t.replace(/^\/*/,"/"),d=h.useMemo(()=>({basename:c,navigator:s,static:o,future:Ts({v7_relativeSplatPath:!1},l)}),[c,l,s,o]);typeof n=="string"&&(n=Na(n));let{pathname:u="/",search:f="",hash:p="",state:m=null,key:x="default"}=n,g=h.useMemo(()=>{let v=Ph(u,c);return v==null?null:{location:{pathname:v,search:f,hash:p,state:m,key:x},navigationType:i}},[c,u,f,p,m,x,i]);return g==null?null:h.createElement(Un.Provider,{value:d},h.createElement(Kc.Provider,{children:r,value:g}))}function XC(e){let{children:t,location:r}=e;return $C(Ef(t),r)}new Promise(()=>{});function Ef(e,t){t===void 0&&(t=[]);let r=[];return h.Children.forEach(e,(n,i)=>{if(!h.isValidElement(n))return;let s=[...t,i];if(n.type===h.Fragment){r.push.apply(r,Ef(n.props.children,s));return}n.type!==oe&&Ae(!1),!n.props.index||!n.props.children||Ae(!1);let o={id:n.props.id||s.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,loader:n.props.loader,action:n.props.action,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(o.children=Ef(n.props.children,s)),r.push(o)}),r}/** * React Router DOM v6.30.2 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function Df(){return Df=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(r[i]=e[i]);return r}function QC(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function eA(e,t){return e.button===0&&(!t||t==="_self")&&!QC(e)}function Tf(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,r)=>{let n=e[r];return t.concat(Array.isArray(n)?n.map(i=>[r,i]):[[r,n]])},[]))}function tA(e,t){let r=Tf(e);return t&&t.forEach((n,i)=>{r.has(i)||t.getAll(i).forEach(s=>{r.append(i,s)})}),r}const rA=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],nA="6";try{window.__reactRouterVersion=nA}catch{}const iA="startTransition",Ex=zv[iA];function aA(e){let{basename:t,children:r,future:n,window:i}=e,s=h.useRef();s.current==null&&(s.current=sC({window:i,v5Compat:!0}));let o=s.current,[l,c]=h.useState({action:o.action,location:o.location}),{v7_startTransition:d}=n||{},u=h.useCallback(f=>{d&&Ex?Ex(()=>c(f)):c(f)},[c,d]);return h.useLayoutEffect(()=>o.listen(u),[o,u]),h.useEffect(()=>GC(n),[n]),h.createElement(ZC,{basename:t,children:r,location:l.location,navigationType:l.action,navigator:o,future:n})}const sA=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",oA=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,zl=h.forwardRef(function(t,r){let{onClick:n,relative:i,reloadDocument:s,replace:o,state:l,target:c,to:d,preventScrollReset:u,viewTransition:f}=t,p=JC(t,rA),{basename:m}=h.useContext(Un),x,g=!1;if(typeof d=="string"&&oA.test(d)&&(x=d,sA))try{let y=new URL(window.location.href),w=d.startsWith("//")?new URL(y.protocol+d):new URL(d),S=Ph(w.pathname,m);w.origin===y.origin&&S!=null?d=S+w.search+w.hash:g=!0}catch{}let v=MC(d,{relative:i}),b=lA(d,{replace:o,state:l,target:c,preventScrollReset:u,relative:i,viewTransition:f});function j(y){n&&n(y),y.defaultPrevented||b(y)}return h.createElement("a",Df({},p,{href:x||v,onClick:g||s?n:j,ref:r,target:c}))});var Dx;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Dx||(Dx={}));var Tx;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Tx||(Tx={}));function lA(e,t){let{target:r,replace:n,state:i,preventScrollReset:s,relative:o,viewTransition:l}=t===void 0?{}:t,c=dt(),d=Pi(),u=K1(e,{relative:o});return h.useCallback(f=>{if(eA(f,r)){f.preventDefault();let p=n!==void 0?n:Ll(d)===Ll(u);c(e,{replace:p,state:i,preventScrollReset:s,relative:o,viewTransition:l})}},[d,c,u,n,i,r,e,s,o,l])}function cA(e){let t=h.useRef(Tf(e)),r=h.useRef(!1),n=Pi(),i=h.useMemo(()=>tA(n.search,r.current?null:t.current),[n.search]),s=dt(),o=h.useCallback((l,c)=>{const d=Tf(typeof l=="function"?l(i):l);r.current=!0,s("?"+d,c)},[s,i]);return[i,o]}const uA={},Mx=e=>{let t;const r=new Set,n=(u,f)=>{const p=typeof u=="function"?u(t):u;if(!Object.is(p,t)){const m=t;t=f??(typeof p!="object"||p===null)?p:Object.assign({},t,p),r.forEach(x=>x(t,m))}},i=()=>t,c={setState:n,getState:i,getInitialState:()=>d,subscribe:u=>(r.add(u),()=>r.delete(u)),destroy:()=>{(uA?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}},d=t=e(n,i,c);return c},dA=e=>e?Mx(e):Mx;var X1={exports:{}},J1={},Q1={exports:{}},ej={};/** * @license React * use-sync-external-store-shim.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var pa=h;function fA(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var pA=typeof Object.is=="function"?Object.is:fA,hA=pa.useState,mA=pa.useEffect,gA=pa.useLayoutEffect,xA=pa.useDebugValue;function yA(e,t){var r=t(),n=hA({inst:{value:r,getSnapshot:t}}),i=n[0].inst,s=n[1];return gA(function(){i.value=r,i.getSnapshot=t,pd(i)&&s({inst:i})},[e,r,t]),mA(function(){return pd(i)&&s({inst:i}),e(function(){pd(i)&&s({inst:i})})},[e]),xA(r),r}function pd(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!pA(e,r)}catch{return!0}}function vA(e,t){return t()}var bA=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?vA:yA;ej.useSyncExternalStore=pa.useSyncExternalStore!==void 0?pa.useSyncExternalStore:bA;Q1.exports=ej;var jA=Q1.exports;/** * @license React * use-sync-external-store-shim/with-selector.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Vc=h,wA=jA;function SA(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var NA=typeof Object.is=="function"?Object.is:SA,kA=wA.useSyncExternalStore,_A=Vc.useRef,PA=Vc.useEffect,CA=Vc.useMemo,AA=Vc.useDebugValue;J1.useSyncExternalStoreWithSelector=function(e,t,r,n,i){var s=_A(null);if(s.current===null){var o={hasValue:!1,value:null};s.current=o}else o=s.current;s=CA(function(){function c(m){if(!d){if(d=!0,u=m,m=n(m),i!==void 0&&o.hasValue){var x=o.value;if(i(x,m))return f=x}return f=m}if(x=f,NA(u,m))return x;var g=n(m);return i!==void 0&&i(x,g)?(u=m,x):(u=m,f=g)}var d=!1,u,f,p=r===void 0?null:r;return[function(){return c(t())},p===null?void 0:function(){return c(p())}]},[t,r,n,i]);var l=kA(e,s[0],s[1]);return PA(function(){o.hasValue=!0,o.value=l},[l]),AA(l),l};X1.exports=J1;var tj=X1.exports;const OA=Tr(tj),rj={},{useDebugValue:EA}=hs,{useSyncExternalStoreWithSelector:DA}=OA;let Ix=!1;const TA=e=>e;function MA(e,t=TA,r){(rj?"production":void 0)!=="production"&&r&&!Ix&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),Ix=!0);const n=DA(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,r);return EA(n),n}const $x=e=>{(rj?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?dA(e):e,r=(n,i)=>MA(t,n,i);return Object.assign(r,t),r},IA=e=>e?$x(e):$x,$A="https://dispos.crawlsy.com";class LA{constructor(t){go(this,"baseUrl");this.baseUrl=t}getHeaders(){const t=localStorage.getItem("token");return{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}}}async request(t,r){const n=`${this.baseUrl}${t}`,i=await fetch(n,{...r,headers:{...this.getHeaders(),...r==null?void 0:r.headers}});if(!i.ok){const s=await i.json().catch(()=>({error:"Request failed"}));throw new Error(s.error||`HTTP ${i.status}`)}return i.json()}async login(t,r){return this.request("/api/auth/login",{method:"POST",body:JSON.stringify({email:t,password:r})})}async getMe(){return this.request("/api/auth/me")}async getDashboardStats(){return this.request("/api/dashboard/stats")}async getDashboardActivity(){return this.request("/api/dashboard/activity")}async getStores(){return this.request("/api/stores")}async getStore(t){return this.request(`/api/stores/${t}`)}async createStore(t){return this.request("/api/stores",{method:"POST",body:JSON.stringify(t)})}async updateStore(t,r){return this.request(`/api/stores/${t}`,{method:"PUT",body:JSON.stringify(r)})}async getDispensaries(){return this.request("/api/dispensaries")}async getDispensary(t){return this.request(`/api/dispensaries/${t}`)}async updateDispensary(t,r){return this.request(`/api/dispensaries/${t}`,{method:"PUT",body:JSON.stringify(r)})}async deleteStore(t){return this.request(`/api/stores/${t}`,{method:"DELETE"})}async scrapeStore(t,r,n){return this.request(`/api/stores/${t}/scrape`,{method:"POST",body:JSON.stringify({parallel:r,userAgent:n})})}async downloadStoreImages(t){return this.request(`/api/stores/${t}/download-images`,{method:"POST"})}async discoverStoreCategories(t){return this.request(`/api/stores/${t}/discover-categories`,{method:"POST"})}async debugScrapeStore(t){return this.request(`/api/stores/${t}/debug-scrape`,{method:"POST"})}async getStoreBrands(t){return this.request(`/api/stores/${t}/brands`)}async getStoreSpecials(t,r){const n=r?`?date=${r}`:"";return this.request(`/api/stores/${t}/specials${n}`)}async getCategories(t){const r=t?`?store_id=${t}`:"";return this.request(`/api/categories${r}`)}async getCategoryTree(t){return this.request(`/api/categories/tree?store_id=${t}`)}async getProducts(t){const r=new URLSearchParams(t).toString();return this.request(`/api/products${r?`?${r}`:""}`)}async getProduct(t){return this.request(`/api/products/${t}`)}async getCampaigns(){return this.request("/api/campaigns")}async getCampaign(t){return this.request(`/api/campaigns/${t}`)}async createCampaign(t){return this.request("/api/campaigns",{method:"POST",body:JSON.stringify(t)})}async updateCampaign(t,r){return this.request(`/api/campaigns/${t}`,{method:"PUT",body:JSON.stringify(r)})}async deleteCampaign(t){return this.request(`/api/campaigns/${t}`,{method:"DELETE"})}async addProductToCampaign(t,r,n){return this.request(`/api/campaigns/${t}/products`,{method:"POST",body:JSON.stringify({product_id:r,display_order:n})})}async removeProductFromCampaign(t,r){return this.request(`/api/campaigns/${t}/products/${r}`,{method:"DELETE"})}async getAnalyticsOverview(t){return this.request(`/api/analytics/overview${t?`?days=${t}`:""}`)}async getProductAnalytics(t,r){return this.request(`/api/analytics/products/${t}${r?`?days=${r}`:""}`)}async getCampaignAnalytics(t,r){return this.request(`/api/analytics/campaigns/${t}${r?`?days=${r}`:""}`)}async getSettings(){return this.request("/api/settings")}async updateSetting(t,r){return this.request(`/api/settings/${t}`,{method:"PUT",body:JSON.stringify({value:r})})}async updateSettings(t){return this.request("/api/settings",{method:"PUT",body:JSON.stringify({settings:t})})}async getProxies(){return this.request("/api/proxies")}async getProxy(t){return this.request(`/api/proxies/${t}`)}async addProxy(t){return this.request("/api/proxies",{method:"POST",body:JSON.stringify(t)})}async addProxiesBulk(t){return this.request("/api/proxies/bulk",{method:"POST",body:JSON.stringify({proxies:t})})}async testProxy(t){return this.request(`/api/proxies/${t}/test`,{method:"POST"})}async testAllProxies(){return this.request("/api/proxies/test-all",{method:"POST"})}async getProxyTestJob(t){return this.request(`/api/proxies/test-job/${t}`)}async getActiveProxyTestJob(){return this.request("/api/proxies/test-job")}async cancelProxyTestJob(t){return this.request(`/api/proxies/test-job/${t}/cancel`,{method:"POST"})}async updateProxy(t,r){return this.request(`/api/proxies/${t}`,{method:"PUT",body:JSON.stringify(r)})}async deleteProxy(t){return this.request(`/api/proxies/${t}`,{method:"DELETE"})}async updateProxyLocations(){return this.request("/api/proxies/update-locations",{method:"POST"})}async getLogs(t,r,n){const i=new URLSearchParams;return t&&i.append("limit",t.toString()),r&&i.append("level",r),n&&i.append("category",n),this.request(`/api/logs?${i.toString()}`)}async clearLogs(){return this.request("/api/logs",{method:"DELETE"})}async getActiveScrapers(){return this.request("/api/scraper-monitor/active")}async getScraperHistory(t){const r=t?`?store_id=${t}`:"";return this.request(`/api/scraper-monitor/history${r}`)}async getJobStats(t){const r=t?`?dispensary_id=${t}`:"";return this.request(`/api/scraper-monitor/jobs/stats${r}`)}async getActiveJobs(t){const r=t?`?dispensary_id=${t}`:"";return this.request(`/api/scraper-monitor/jobs/active${r}`)}async getRecentJobs(t){const r=new URLSearchParams;t!=null&&t.limit&&r.append("limit",t.limit.toString()),t!=null&&t.dispensaryId&&r.append("dispensary_id",t.dispensaryId.toString()),t!=null&&t.status&&r.append("status",t.status);const n=r.toString()?`?${r.toString()}`:"";return this.request(`/api/scraper-monitor/jobs/recent${n}`)}async getWorkerStats(t){const r=t?`?dispensary_id=${t}`:"";return this.request(`/api/scraper-monitor/jobs/workers${r}`)}async getAZMonitorActiveJobs(){return this.request("/api/az/monitor/active-jobs")}async getAZMonitorRecentJobs(t){const r=t?`?limit=${t}`:"";return this.request(`/api/az/monitor/recent-jobs${r}`)}async getAZMonitorErrors(t){const r=new URLSearchParams;t!=null&&t.limit&&r.append("limit",t.limit.toString()),t!=null&&t.hours&&r.append("hours",t.hours.toString());const n=r.toString()?`?${r.toString()}`:"";return this.request(`/api/az/monitor/errors${n}`)}async getAZMonitorSummary(){return this.request("/api/az/monitor/summary")}async getChanges(t){const r=t?`?status=${t}`:"";return this.request(`/api/changes${r}`)}async getChangeStats(){return this.request("/api/changes/stats")}async approveChange(t){return this.request(`/api/changes/${t}/approve`,{method:"POST"})}async rejectChange(t,r){return this.request(`/api/changes/${t}/reject`,{method:"POST",body:JSON.stringify({reason:r})})}async getDispensaryProducts(t,r){const n=r?`?category=${r}`:"";return this.request(`/api/dispensaries/${t}/products${n}`)}async getDispensaryBrands(t){return this.request(`/api/dispensaries/${t}/brands`)}async getDispensarySpecials(t){return this.request(`/api/dispensaries/${t}/specials`)}async getApiPermissions(){return this.request("/api/api-permissions")}async getApiPermissionDispensaries(){return this.request("/api/api-permissions/dispensaries")}async createApiPermission(t){return this.request("/api/api-permissions",{method:"POST",body:JSON.stringify(t)})}async updateApiPermission(t,r){return this.request(`/api/api-permissions/${t}`,{method:"PUT",body:JSON.stringify(r)})}async toggleApiPermission(t){return this.request(`/api/api-permissions/${t}/toggle`,{method:"PATCH"})}async deleteApiPermission(t){return this.request(`/api/api-permissions/${t}`,{method:"DELETE"})}async getGlobalSchedule(){return this.request("/api/schedule/global")}async updateGlobalSchedule(t,r){return this.request(`/api/schedule/global/${t}`,{method:"PUT",body:JSON.stringify(r)})}async getStoreSchedules(){return this.request("/api/schedule/stores")}async getStoreSchedule(t){return this.request(`/api/schedule/stores/${t}`)}async updateStoreSchedule(t,r){return this.request(`/api/schedule/stores/${t}`,{method:"PUT",body:JSON.stringify(r)})}async getDispensarySchedules(t){const r=new URLSearchParams;t!=null&&t.state&&r.append("state",t.state),t!=null&&t.search&&r.append("search",t.search);const n=r.toString();return this.request(`/api/schedule/dispensaries${n?`?${n}`:""}`)}async getDispensarySchedule(t){return this.request(`/api/schedule/dispensaries/${t}`)}async updateDispensarySchedule(t,r){return this.request(`/api/schedule/dispensaries/${t}`,{method:"PUT",body:JSON.stringify(r)})}async getDispensaryCrawlJobs(t){const r=t?`?limit=${t}`:"";return this.request(`/api/schedule/dispensary-jobs${r}`)}async triggerDispensaryCrawl(t){return this.request(`/api/schedule/trigger/dispensary/${t}`,{method:"POST"})}async resolvePlatformId(t){return this.request(`/api/schedule/dispensaries/${t}/resolve-platform-id`,{method:"POST"})}async detectMenuType(t){return this.request(`/api/schedule/dispensaries/${t}/detect-menu-type`,{method:"POST"})}async refreshDetection(t){return this.request(`/api/schedule/dispensaries/${t}/refresh-detection`,{method:"POST"})}async toggleDispensarySchedule(t,r){return this.request(`/api/schedule/dispensaries/${t}/toggle-active`,{method:"PUT",body:JSON.stringify({is_active:r})})}async deleteDispensarySchedule(t){return this.request(`/api/schedule/dispensaries/${t}/schedule`,{method:"DELETE"})}async getCrawlJobs(t){const r=t?`?limit=${t}`:"";return this.request(`/api/schedule/jobs${r}`)}async getStoreCrawlJobs(t,r){const n=r?`?limit=${r}`:"";return this.request(`/api/schedule/jobs/store/${t}${n}`)}async cancelCrawlJob(t){return this.request(`/api/schedule/jobs/${t}/cancel`,{method:"POST"})}async triggerStoreCrawl(t){return this.request(`/api/schedule/trigger/store/${t}`,{method:"POST"})}async triggerAllCrawls(){return this.request("/api/schedule/trigger/all",{method:"POST"})}async restartScheduler(){return this.request("/api/schedule/restart",{method:"POST"})}async getVersion(){return this.request("/api/version")}async getDutchieAZDashboard(){return this.request("/api/az/dashboard")}async getDutchieAZSchedules(){return this.request("/api/az/admin/schedules")}async getDutchieAZSchedule(t){return this.request(`/api/az/admin/schedules/${t}`)}async createDutchieAZSchedule(t){return this.request("/api/az/admin/schedules",{method:"POST",body:JSON.stringify(t)})}async updateDutchieAZSchedule(t,r){return this.request(`/api/az/admin/schedules/${t}`,{method:"PUT",body:JSON.stringify(r)})}async deleteDutchieAZSchedule(t){return this.request(`/api/az/admin/schedules/${t}`,{method:"DELETE"})}async triggerDutchieAZSchedule(t){return this.request(`/api/az/admin/schedules/${t}/trigger`,{method:"POST"})}async initDutchieAZSchedules(){return this.request("/api/az/admin/schedules/init",{method:"POST"})}async getDutchieAZScheduleLogs(t,r,n){const i=new URLSearchParams;r&&i.append("limit",r.toString()),n&&i.append("offset",n.toString());const s=i.toString()?`?${i.toString()}`:"";return this.request(`/api/az/admin/schedules/${t}/logs${s}`)}async getDutchieAZRunLogs(t){const r=new URLSearchParams;t!=null&&t.scheduleId&&r.append("scheduleId",t.scheduleId.toString()),t!=null&&t.jobName&&r.append("jobName",t.jobName),t!=null&&t.limit&&r.append("limit",t.limit.toString()),t!=null&&t.offset&&r.append("offset",t.offset.toString());const n=r.toString()?`?${r.toString()}`:"";return this.request(`/api/az/admin/run-logs${n}`)}async getDutchieAZSchedulerStatus(){return this.request("/api/az/admin/scheduler/status")}async startDutchieAZScheduler(){return this.request("/api/az/admin/scheduler/start",{method:"POST"})}async stopDutchieAZScheduler(){return this.request("/api/az/admin/scheduler/stop",{method:"POST"})}async triggerDutchieAZImmediateCrawl(){return this.request("/api/az/admin/scheduler/trigger",{method:"POST"})}async getDutchieAZStores(t){const r=new URLSearchParams;t!=null&&t.city&&r.append("city",t.city),(t==null?void 0:t.hasPlatformId)!==void 0&&r.append("hasPlatformId",String(t.hasPlatformId)),t!=null&&t.limit&&r.append("limit",t.limit.toString()),t!=null&&t.offset&&r.append("offset",t.offset.toString());const n=r.toString()?`?${r.toString()}`:"";return this.request(`/api/az/stores${n}`)}async getDutchieAZStore(t){return this.request(`/api/az/stores/${t}`)}async getDutchieAZStoreSummary(t){return this.request(`/api/az/stores/${t}/summary`)}async getDutchieAZStoreProducts(t,r){const n=new URLSearchParams;r!=null&&r.stockStatus&&n.append("stockStatus",r.stockStatus),r!=null&&r.type&&n.append("type",r.type),r!=null&&r.subcategory&&n.append("subcategory",r.subcategory),r!=null&&r.brandName&&n.append("brandName",r.brandName),r!=null&&r.search&&n.append("search",r.search),r!=null&&r.limit&&n.append("limit",r.limit.toString()),r!=null&&r.offset&&n.append("offset",r.offset.toString());const i=n.toString()?`?${n.toString()}`:"";return this.request(`/api/az/stores/${t}/products${i}`)}async getDutchieAZStoreBrands(t){return this.request(`/api/az/stores/${t}/brands`)}async getDutchieAZStoreCategories(t){return this.request(`/api/az/stores/${t}/categories`)}async getDutchieAZBrands(t){const r=new URLSearchParams;t!=null&&t.limit&&r.append("limit",t.limit.toString()),t!=null&&t.offset&&r.append("offset",t.offset.toString());const n=r.toString()?`?${r.toString()}`:"";return this.request(`/api/az/brands${n}`)}async getDutchieAZCategories(){return this.request("/api/az/categories")}async getDutchieAZDebugSummary(){return this.request("/api/az/debug/summary")}async getDutchieAZDebugStore(t){return this.request(`/api/az/debug/store/${t}`)}async triggerDutchieAZCrawl(t,r){return this.request(`/api/az/admin/crawl/${t}`,{method:"POST",body:JSON.stringify(r||{})})}async getDetectionStats(){return this.request("/api/az/admin/detection/stats")}async getDispensariesNeedingDetection(t){const r=new URLSearchParams;t!=null&&t.state&&r.append("state",t.state),t!=null&&t.limit&&r.append("limit",t.limit.toString());const n=r.toString()?`?${r.toString()}`:"";return this.request(`/api/az/admin/detection/pending${n}`)}async detectDispensary(t){return this.request(`/api/az/admin/detection/detect/${t}`,{method:"POST"})}async detectAllDispensaries(t){return this.request("/api/az/admin/detection/detect-all",{method:"POST",body:JSON.stringify(t||{})})}async triggerMenuDetectionJob(){return this.request("/api/az/admin/detection/trigger",{method:"POST"})}async getUsers(t){const r=t?`/api/users?${t}`:"/api/users";return this.request(r)}async getUser(t){return this.request(`/api/users/${t}`)}async createUser(t){return this.request("/api/users",{method:"POST",body:JSON.stringify(t)})}async updateUser(t,r){return this.request(`/api/users/${t}`,{method:"PUT",body:JSON.stringify(r)})}async deleteUser(t){return this.request(`/api/users/${t}`,{method:"DELETE"})}}const B=new LA($A),Yc=IA(e=>({user:null,token:localStorage.getItem("token"),isAuthenticated:!!localStorage.getItem("token"),login:async(t,r)=>{const n=await B.login(t,r);localStorage.setItem("token",n.token),e({user:n.user,token:n.token,isAuthenticated:!0})},logout:()=>{localStorage.removeItem("token"),e({user:null,token:null,isAuthenticated:!1})},checkAuth:async()=>{try{const t=await B.getMe();e({user:t.user,isAuthenticated:!0})}catch{localStorage.removeItem("token"),e({user:null,token:null,isAuthenticated:!1})}}}));function zA(){const[e,t]=h.useState("admin@example.com"),[r,n]=h.useState("password"),[i,s]=h.useState(""),[o,l]=h.useState(!1),c=dt(),d=Yc(f=>f.login),u=async f=>{f.preventDefault(),s(""),l(!0);try{await d(e,r),c("/dashboard")}catch(p){s(p.message||"Login failed")}finally{l(!1)}};return a.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100vh",background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)"},children:a.jsxs("div",{style:{background:"white",padding:"40px",borderRadius:"12px",boxShadow:"0 10px 40px rgba(0,0,0,0.2)",width:"100%",maxWidth:"400px"},children:[a.jsx("h1",{style:{marginBottom:"10px",fontSize:"28px"},children:"Cannabrands Menus"}),a.jsx("p",{style:{color:"#666",marginBottom:"30px"},children:"Admin Dashboard"}),i&&a.jsx("div",{style:{background:"#fee",color:"#c33",padding:"12px",borderRadius:"6px",marginBottom:"20px",fontSize:"14px"},children:i}),a.jsxs("form",{onSubmit:u,children:[a.jsxs("div",{style:{marginBottom:"20px"},children:[a.jsx("label",{style:{display:"block",marginBottom:"8px",fontWeight:"500"},children:"Email"}),a.jsx("input",{type:"email",value:e,onChange:f=>t(f.target.value),required:!0,style:{width:"100%",padding:"12px",border:"1px solid #ddd",borderRadius:"6px",fontSize:"14px"}})]}),a.jsxs("div",{style:{marginBottom:"25px"},children:[a.jsx("label",{style:{display:"block",marginBottom:"8px",fontWeight:"500"},children:"Password"}),a.jsx("input",{type:"password",value:r,onChange:f=>n(f.target.value),required:!0,style:{width:"100%",padding:"12px",border:"1px solid #ddd",borderRadius:"6px",fontSize:"14px"}})]}),a.jsx("button",{type:"submit",disabled:o,style:{width:"100%",padding:"14px",background:o?"#999":"#667eea",color:"white",border:"none",borderRadius:"6px",cursor:o?"not-allowed":"pointer",fontSize:"16px",fontWeight:"500",transition:"background 0.2s"},children:o?"Logging in...":"Login"})]})]})})}/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RA=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),BA=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),Lx=e=>{const t=BA(e);return t.charAt(0).toUpperCase()+t.slice(1)},nj=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),FA=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */var WA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UA=h.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:i="",children:s,iconNode:o,...l},c)=>h.createElement("svg",{ref:c,...WA,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:nj("lucide",i),...!s&&!FA(l)&&{"aria-hidden":"true"},...l},[...o.map(([d,u])=>h.createElement(d,u)),...Array.isArray(s)?s:[s]]));/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J=(e,t)=>{const r=h.forwardRef(({className:n,...i},s)=>h.createElement(UA,{ref:s,iconNode:t,className:nj(`lucide-${RA(Lx(e))}`,`lucide-${e}`,n),...i}));return r.displayName=Lx(e),r};/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qA=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],na=J("activity",qA);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HA=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Eh=J("arrow-left",HA);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KA=[["path",{d:"M10 12h4",key:"a56b0p"}],["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M14 21v-3a2 2 0 0 0-4 0v3",key:"1rgiei"}],["path",{d:"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",key:"secmi2"}],["path",{d:"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16",key:"16ra0t"}]],Ln=J("building-2",KA);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VA=[["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M9 22v-3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3",key:"cabbwy"}],["rect",{x:"4",y:"2",width:"16",height:"20",rx:"2",key:"1uxh74"}]],YA=J("building",VA);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GA=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Dh=J("calendar",GA);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZA=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],XA=J("chart-column",ZA);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JA=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],QA=J("check",JA);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e6=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],ij=J("chevron-down",e6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t6=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Mf=J("chevron-right",t6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r6=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],ha=J("circle-alert",r6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n6=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Pr=J("circle-check-big",n6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i6=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Hr=J("circle-x",i6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a6=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],xr=J("clock",a6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s6=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],o6=J("dollar-sign",s6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l6=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Jr=J("external-link",l6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c6=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],u6=J("eye",c6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d6=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],f6=J("file-text",d6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p6=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],h6=J("folder-open",p6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m6=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],hd=J("globe",m6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g6=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],x6=J("image",g6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y6=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],v6=J("key",y6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b6=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],zx=J("layers",b6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j6=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],w6=J("layout-dashboard",j6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const S6=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],N6=J("log-out",S6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k6=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],Th=J("mail",k6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _6=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],yi=J("map-pin",_6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P6=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],Ct=J("package",P6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C6=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],aj=J("pencil",C6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A6=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]],Ms=J("phone",A6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O6=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Rl=J("plus",O6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E6=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Xt=J("refresh-cw",E6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D6=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],T6=J("save",D6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M6=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],sj=J("search",M6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I6=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],$6=J("settings",I6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const L6=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],cl=J("shield",L6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const z6=[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]],Bl=J("store",z6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R6=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],Cr=J("tag",R6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B6=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],oj=J("target",B6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F6=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],Rx=J("toggle-left",F6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W6=[["circle",{cx:"15",cy:"12",r:"3",key:"1afu0r"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],Bx=J("toggle-right",W6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U6=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],lj=J("trash-2",U6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q6=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],H6=J("trending-down",q6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K6=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],zn=J("trending-up",K6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V6=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],cj=J("triangle-alert",V6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y6=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],G6=J("upload",Y6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z6=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],uj=J("users",Z6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X6=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],J6=J("wrench",X6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q6=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Mh=J("x",Q6);/** * @license lucide-react v0.553.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e4=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Fx=J("zap",e4);function qe({to:e,icon:t,label:r,isActive:n}){return a.jsxs("a",{href:e,className:`flex items-center gap-3 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${n?"bg-blue-50 text-blue-600":"text-gray-700 hover:bg-gray-50"}`,children:[a.jsx("span",{className:"flex-shrink-0",children:t}),a.jsx("span",{children:r})]})}function Mo({title:e,children:t}){return a.jsxs("div",{className:"space-y-1",children:[a.jsx("div",{className:"px-3 mb-2",children:a.jsx("h3",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider",children:e})}),t]})}function X({children:e}){const t=dt(),r=Pi(),{user:n,logout:i}=Yc(),[s,o]=h.useState(null);h.useEffect(()=>{(async()=>{try{const u=await B.getVersion();o(u)}catch(u){console.error("Failed to fetch version info:",u)}})()},[]);const l=()=>{i(),t("/login")},c=(d,u=!0)=>u?r.pathname===d:r.pathname.startsWith(d);return a.jsxs("div",{className:"flex min-h-screen bg-gray-50",children:[a.jsxs("div",{className:"w-64 bg-white border-r border-gray-200 flex flex-col",style:{position:"sticky",top:0,height:"100vh",overflowY:"auto"},children:[a.jsxs("div",{className:"px-6 py-5 border-b border-gray-200",children:[a.jsx("h1",{className:"text-lg font-semibold text-gray-900",children:"CannaIQ"}),a.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:n==null?void 0:n.email}),s&&a.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:[s.build_version," (",s.git_sha.slice(0,7),")"]})]}),a.jsxs("nav",{className:"flex-1 px-3 py-4 space-y-6",children:[a.jsxs(Mo,{title:"Main",children:[a.jsx(qe,{to:"/dashboard",icon:a.jsx(w6,{className:"w-4 h-4"}),label:"Dashboard",isActive:c("/dashboard",!0)}),a.jsx(qe,{to:"/dispensaries",icon:a.jsx(Ln,{className:"w-4 h-4"}),label:"Dispensaries",isActive:c("/dispensaries")}),a.jsx(qe,{to:"/categories",icon:a.jsx(h6,{className:"w-4 h-4"}),label:"Categories",isActive:c("/categories")}),a.jsx(qe,{to:"/products",icon:a.jsx(Ct,{className:"w-4 h-4"}),label:"Products",isActive:c("/products")}),a.jsx(qe,{to:"/campaigns",icon:a.jsx(oj,{className:"w-4 h-4"}),label:"Campaigns",isActive:c("/campaigns")}),a.jsx(qe,{to:"/analytics",icon:a.jsx(zn,{className:"w-4 h-4"}),label:"Analytics",isActive:c("/analytics")})]}),a.jsxs(Mo,{title:"AZ Data",children:[a.jsx(qe,{to:"/wholesale-analytics",icon:a.jsx(zn,{className:"w-4 h-4"}),label:"Wholesale Analytics",isActive:c("/wholesale-analytics")}),a.jsx(qe,{to:"/az",icon:a.jsx(Bl,{className:"w-4 h-4"}),label:"AZ Stores",isActive:c("/az",!1)}),a.jsx(qe,{to:"/az-schedule",icon:a.jsx(Dh,{className:"w-4 h-4"}),label:"AZ Schedule",isActive:c("/az-schedule")})]}),a.jsxs(Mo,{title:"Scraper",children:[a.jsx(qe,{to:"/scraper-tools",icon:a.jsx(J6,{className:"w-4 h-4"}),label:"Tools",isActive:c("/scraper-tools")}),a.jsx(qe,{to:"/scraper-schedule",icon:a.jsx(xr,{className:"w-4 h-4"}),label:"Schedule",isActive:c("/scraper-schedule")}),a.jsx(qe,{to:"/scraper-monitor",icon:a.jsx(na,{className:"w-4 h-4"}),label:"Monitor",isActive:c("/scraper-monitor")})]}),a.jsxs(Mo,{title:"System",children:[a.jsx(qe,{to:"/changes",icon:a.jsx(Pr,{className:"w-4 h-4"}),label:"Change Approval",isActive:c("/changes")}),a.jsx(qe,{to:"/api-permissions",icon:a.jsx(v6,{className:"w-4 h-4"}),label:"API Permissions",isActive:c("/api-permissions")}),a.jsx(qe,{to:"/proxies",icon:a.jsx(cl,{className:"w-4 h-4"}),label:"Proxies",isActive:c("/proxies")}),a.jsx(qe,{to:"/logs",icon:a.jsx(f6,{className:"w-4 h-4"}),label:"Logs",isActive:c("/logs")}),a.jsx(qe,{to:"/settings",icon:a.jsx($6,{className:"w-4 h-4"}),label:"Settings",isActive:c("/settings")}),a.jsx(qe,{to:"/users",icon:a.jsx(uj,{className:"w-4 h-4"}),label:"Users",isActive:c("/users")})]})]}),a.jsx("div",{className:"px-3 py-4 border-t border-gray-200",children:a.jsxs("button",{onClick:l,className:"w-full flex items-center gap-3 px-3 py-2 rounded-lg text-sm font-medium text-red-600 hover:bg-red-50 transition-colors",children:[a.jsx(N6,{className:"w-4 h-4"}),a.jsx("span",{children:"Logout"})]})}),s&&a.jsxs("div",{className:"px-3 py-2 border-t border-gray-200 bg-gray-50",children:[a.jsxs("p",{className:"text-xs text-gray-500 text-center",children:[s.build_version," (",s.git_sha.slice(0,7),")"]}),a.jsx("p",{className:"text-xs text-gray-400 text-center mt-0.5",children:s.image_tag})]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto",children:a.jsx("div",{className:"max-w-7xl mx-auto px-8 py-8",children:e})})]})}function dj(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t{var[n]=r;return fj(n)||pj(n)});return Object.fromEntries(t)}function Gc(e){if(e==null)return null;if(h.isValidElement(e)&&typeof e.props=="object"&&e.props!==null){var t=e.props;return nr(t)}return typeof e=="object"&&!Array.isArray(e)?nr(e):null}function ut(e){var t=Object.entries(e).filter(r=>{var[n]=r;return fj(n)||pj(n)||Ih(n)});return Object.fromEntries(t)}function n4(e){return e==null?null:h.isValidElement(e)?ut(e.props):typeof e=="object"&&!Array.isArray(e)?ut(e):null}var i4=["children","width","height","viewBox","className","style","title","desc"];function If(){return If=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{children:r,width:n,height:i,viewBox:s,className:o,style:l,title:c,desc:d}=e,u=a4(e,i4),f=s||{width:n,height:i,x:0,y:0},p=ue("recharts-surface",o);return h.createElement("svg",If({},ut(u),{className:p,width:n,height:i,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:t}),h.createElement("title",null,c),h.createElement("desc",null,d),r)}),o4=["children","className"];function $f(){return $f=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{children:r,className:n}=e,i=l4(e,o4),s=ue("recharts-layer",n);return h.createElement("g",$f({className:s},ut(i),{ref:t}),r)}),u4=h.createContext(null);function he(e){return function(){return e}}const mj=Math.cos,Fl=Math.sin,vr=Math.sqrt,Wl=Math.PI,Zc=2*Wl,Lf=Math.PI,zf=2*Lf,Xn=1e-6,d4=zf-Xn;function gj(e){this._+=e[0];for(let t=1,r=e.length;t=0))throw new Error(`invalid digits: ${e}`);if(t>15)return gj;const r=10**t;return function(n){this._+=n[0];for(let i=1,s=n.length;iXn)if(!(Math.abs(f*c-d*u)>Xn)||!s)this._append`L${this._x1=t},${this._y1=r}`;else{let m=n-o,x=i-l,g=c*c+d*d,v=m*m+x*x,b=Math.sqrt(g),j=Math.sqrt(p),y=s*Math.tan((Lf-Math.acos((g+p-v)/(2*b*j)))/2),w=y/j,S=y/b;Math.abs(w-1)>Xn&&this._append`L${t+w*u},${r+w*f}`,this._append`A${s},${s},0,0,${+(f*m>u*x)},${this._x1=t+S*c},${this._y1=r+S*d}`}}arc(t,r,n,i,s,o){if(t=+t,r=+r,n=+n,o=!!o,n<0)throw new Error(`negative radius: ${n}`);let l=n*Math.cos(i),c=n*Math.sin(i),d=t+l,u=r+c,f=1^o,p=o?i-s:s-i;this._x1===null?this._append`M${d},${u}`:(Math.abs(this._x1-d)>Xn||Math.abs(this._y1-u)>Xn)&&this._append`L${d},${u}`,n&&(p<0&&(p=p%zf+zf),p>d4?this._append`A${n},${n},0,1,${f},${t-l},${r-c}A${n},${n},0,1,${f},${this._x1=d},${this._y1=u}`:p>Xn&&this._append`A${n},${n},0,${+(p>=Lf)},${f},${this._x1=t+n*Math.cos(s)},${this._y1=r+n*Math.sin(s)}`)}rect(t,r,n,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+r}h${n=+n}v${+i}h${-n}Z`}toString(){return this._}}function $h(e){let t=3;return e.digits=function(r){if(!arguments.length)return t;if(r==null)t=null;else{const n=Math.floor(r);if(!(n>=0))throw new RangeError(`invalid digits: ${r}`);t=n}return e},()=>new p4(t)}function Lh(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function xj(e){this._context=e}xj.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function Xc(e){return new xj(e)}function yj(e){return e[0]}function vj(e){return e[1]}function bj(e,t){var r=he(!0),n=null,i=Xc,s=null,o=$h(l);e=typeof e=="function"?e:e===void 0?yj:he(e),t=typeof t=="function"?t:t===void 0?vj:he(t);function l(c){var d,u=(c=Lh(c)).length,f,p=!1,m;for(n==null&&(s=i(m=o())),d=0;d<=u;++d)!(d=m;--x)l.point(y[x],w[x]);l.lineEnd(),l.areaEnd()}b&&(y[p]=+e(v,p,f),w[p]=+t(v,p,f),l.point(n?+n(v,p,f):y[p],r?+r(v,p,f):w[p]))}if(j)return l=null,j+""||null}function u(){return bj().defined(i).curve(o).context(s)}return d.x=function(f){return arguments.length?(e=typeof f=="function"?f:he(+f),n=null,d):e},d.x0=function(f){return arguments.length?(e=typeof f=="function"?f:he(+f),d):e},d.x1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:he(+f),d):n},d.y=function(f){return arguments.length?(t=typeof f=="function"?f:he(+f),r=null,d):t},d.y0=function(f){return arguments.length?(t=typeof f=="function"?f:he(+f),d):t},d.y1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:he(+f),d):r},d.lineX0=d.lineY0=function(){return u().x(e).y(t)},d.lineY1=function(){return u().x(e).y(r)},d.lineX1=function(){return u().x(n).y(t)},d.defined=function(f){return arguments.length?(i=typeof f=="function"?f:he(!!f),d):i},d.curve=function(f){return arguments.length?(o=f,s!=null&&(l=o(s)),d):o},d.context=function(f){return arguments.length?(f==null?s=l=null:l=o(s=f),d):s},d}class jj{constructor(t,r){this._context=t,this._x=r}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,r){switch(t=+t,r=+r,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,r):this._context.moveTo(t,r);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,r,t,r):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+r)/2,t,this._y0,t,r);break}}this._x0=t,this._y0=r}}function h4(e){return new jj(e,!0)}function m4(e){return new jj(e,!1)}const zh={draw(e,t){const r=vr(t/Wl);e.moveTo(r,0),e.arc(0,0,r,0,Zc)}},g4={draw(e,t){const r=vr(t/5)/2;e.moveTo(-3*r,-r),e.lineTo(-r,-r),e.lineTo(-r,-3*r),e.lineTo(r,-3*r),e.lineTo(r,-r),e.lineTo(3*r,-r),e.lineTo(3*r,r),e.lineTo(r,r),e.lineTo(r,3*r),e.lineTo(-r,3*r),e.lineTo(-r,r),e.lineTo(-3*r,r),e.closePath()}},wj=vr(1/3),x4=wj*2,y4={draw(e,t){const r=vr(t/x4),n=r*wj;e.moveTo(0,-r),e.lineTo(n,0),e.lineTo(0,r),e.lineTo(-n,0),e.closePath()}},v4={draw(e,t){const r=vr(t),n=-r/2;e.rect(n,n,r,r)}},b4=.8908130915292852,Sj=Fl(Wl/10)/Fl(7*Wl/10),j4=Fl(Zc/10)*Sj,w4=-mj(Zc/10)*Sj,S4={draw(e,t){const r=vr(t*b4),n=j4*r,i=w4*r;e.moveTo(0,-r),e.lineTo(n,i);for(let s=1;s<5;++s){const o=Zc*s/5,l=mj(o),c=Fl(o);e.lineTo(c*r,-l*r),e.lineTo(l*n-c*i,c*n+l*i)}e.closePath()}},md=vr(3),N4={draw(e,t){const r=-vr(t/(md*3));e.moveTo(0,r*2),e.lineTo(-md*r,-r),e.lineTo(md*r,-r),e.closePath()}},Ht=-.5,Kt=vr(3)/2,Rf=1/vr(12),k4=(Rf/2+1)*3,_4={draw(e,t){const r=vr(t/k4),n=r/2,i=r*Rf,s=n,o=r*Rf+r,l=-s,c=o;e.moveTo(n,i),e.lineTo(s,o),e.lineTo(l,c),e.lineTo(Ht*n-Kt*i,Kt*n+Ht*i),e.lineTo(Ht*s-Kt*o,Kt*s+Ht*o),e.lineTo(Ht*l-Kt*c,Kt*l+Ht*c),e.lineTo(Ht*n+Kt*i,Ht*i-Kt*n),e.lineTo(Ht*s+Kt*o,Ht*o-Kt*s),e.lineTo(Ht*l+Kt*c,Ht*c-Kt*l),e.closePath()}};function P4(e,t){let r=null,n=$h(i);e=typeof e=="function"?e:he(e||zh),t=typeof t=="function"?t:he(t===void 0?64:+t);function i(){let s;if(r||(r=s=n()),e.apply(this,arguments).draw(r,+t.apply(this,arguments)),s)return r=null,s+""||null}return i.type=function(s){return arguments.length?(e=typeof s=="function"?s:he(s),i):e},i.size=function(s){return arguments.length?(t=typeof s=="function"?s:he(+s),i):t},i.context=function(s){return arguments.length?(r=s??null,i):r},i}function Ul(){}function ql(e,t,r){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+r)/6)}function Nj(e){this._context=e}Nj.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:ql(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:ql(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function C4(e){return new Nj(e)}function kj(e){this._context=e}kj.prototype={areaStart:Ul,areaEnd:Ul,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:ql(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function A4(e){return new kj(e)}function _j(e){this._context=e}_j.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var r=(this._x0+4*this._x1+e)/6,n=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(r,n):this._context.moveTo(r,n);break;case 3:this._point=4;default:ql(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function O4(e){return new _j(e)}function Pj(e){this._context=e}Pj.prototype={areaStart:Ul,areaEnd:Ul,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function E4(e){return new Pj(e)}function Wx(e){return e<0?-1:1}function Ux(e,t,r){var n=e._x1-e._x0,i=t-e._x1,s=(e._y1-e._y0)/(n||i<0&&-0),o=(r-e._y1)/(i||n<0&&-0),l=(s*i+o*n)/(n+i);return(Wx(s)+Wx(o))*Math.min(Math.abs(s),Math.abs(o),.5*Math.abs(l))||0}function qx(e,t){var r=e._x1-e._x0;return r?(3*(e._y1-e._y0)/r-t)/2:t}function gd(e,t,r){var n=e._x0,i=e._y0,s=e._x1,o=e._y1,l=(s-n)/3;e._context.bezierCurveTo(n+l,i+l*t,s-l,o-l*r,s,o)}function Hl(e){this._context=e}Hl.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:gd(this,this._t0,qx(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var r=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,gd(this,qx(this,r=Ux(this,e,t)),r);break;default:gd(this,this._t0,r=Ux(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=r}}};function Cj(e){this._context=new Aj(e)}(Cj.prototype=Object.create(Hl.prototype)).point=function(e,t){Hl.prototype.point.call(this,t,e)};function Aj(e){this._context=e}Aj.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,r,n,i,s){this._context.bezierCurveTo(t,e,n,r,s,i)}};function D4(e){return new Hl(e)}function T4(e){return new Cj(e)}function Oj(e){this._context=e}Oj.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,r=e.length;if(r)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),r===2)this._context.lineTo(e[1],t[1]);else for(var n=Hx(e),i=Hx(t),s=0,o=1;o=0;--t)i[t]=(o[t]-i[t+1])/s[t];for(s[r-1]=(e[r]+i[r-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var r=this._x*(1-this._t)+e*this._t;this._context.lineTo(r,this._y),this._context.lineTo(r,t)}break}}this._x=e,this._y=t}};function I4(e){return new Jc(e,.5)}function $4(e){return new Jc(e,0)}function L4(e){return new Jc(e,1)}function ma(e,t){if((o=e.length)>1)for(var r=1,n,i,s=e[t[0]],o,l=s.length;r=0;)r[t]=t;return r}function z4(e,t){return e[t]}function R4(e){const t=[];return t.key=e,t}function B4(){var e=he([]),t=Bf,r=ma,n=z4;function i(s){var o=Array.from(e.apply(this,arguments),R4),l,c=o.length,d=-1,u;for(const f of s)for(l=0,++d;l0){for(var r,n,i=0,s=e[0].length,o;i0){for(var r=0,n=e[t[0]],i,s=n.length;r0)||!((s=(i=e[t[0]]).length)>0))){for(var r=0,n=1,i,s,o;ne===0?0:e>0?1:-1,yr=e=>typeof e=="number"&&e!=+e,Qr=e=>typeof e=="string"&&e.indexOf("%")===e.length-1,G=e=>(typeof e=="number"||e instanceof Number)&&!yr(e),Or=e=>G(e)||typeof e=="string",H4=0,Is=e=>{var t=++H4;return"".concat(e||"").concat(t)},Rn=function(t,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!G(t)&&typeof t!="string")return n;var s;if(Qr(t)){if(r==null)return n;var o=t.indexOf("%");s=r*parseFloat(t.slice(0,o))/100}else s=+t;return yr(s)&&(s=n),i&&r!=null&&s>r&&(s=r),s},Tj=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,r={},n=0;nn&&(typeof t=="function"?t(n):ru(n,t))===r)}var Re=e=>e===null||typeof e>"u",Qs=e=>Re(e)?e:"".concat(e.charAt(0).toUpperCase()).concat(e.slice(1));function K4(e){return e!=null}function Pa(){}var V4=["type","size","sizeType"];function Ff(){return Ff=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t="symbol".concat(Qs(e));return Ij[t]||zh},tO=(e,t,r)=>{if(t==="area")return e;switch(r){case"cross":return 5*e*e/9;case"diamond":return .5*e*e/Math.sqrt(3);case"square":return e*e;case"star":{var n=18*Q4;return 1.25*e*e*(Math.tan(n)-Math.tan(n*2)*Math.tan(n)**2)}case"triangle":return Math.sqrt(3)*e*e/4;case"wye":return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},rO=(e,t)=>{Ij["symbol".concat(Qs(e))]=t},$j=e=>{var{type:t="circle",size:r=64,sizeType:n="area"}=e,i=X4(e,V4),s=Vx(Vx({},i),{},{type:t,size:r,sizeType:n}),o="circle";typeof t=="string"&&(o=t);var l=()=>{var p=eO(o),m=P4().type(p).size(tO(r,n,o)),x=m();if(x!==null)return x},{className:c,cx:d,cy:u}=s,f=ut(s);return G(d)&&G(u)&&G(r)?h.createElement("path",Ff({},f,{className:ue("recharts-symbols",c),transform:"translate(".concat(d,", ").concat(u,")"),d:l()})):null};$j.registerSymbol=rO;var Lj=e=>"radius"in e&&"startAngle"in e&&"endAngle"in e,Bh=(e,t)=>{if(!e||typeof e=="function"||typeof e=="boolean")return null;var r=e;if(h.isValidElement(e)&&(r=e.props),typeof r!="object"&&typeof r!="function")return null;var n={};return Object.keys(r).forEach(i=>{Ih(i)&&(n[i]=s=>r[i](r,s))}),n},nO=(e,t,r)=>n=>(e(t,r,n),null),iO=(e,t,r)=>{if(e===null||typeof e!="object"&&typeof e!="function")return null;var n=null;return Object.keys(e).forEach(i=>{var s=e[i];Ih(i)&&typeof s=="function"&&(n||(n={}),n[i]=nO(s,t,r))}),n};function Yx(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function aO(e){for(var t=1;t(o[l]===void 0&&n[l]!==void 0&&(o[l]=n[l]),o),r);return s}var zj={},Rj={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r,n){const i=new Map;for(let s=0;s=0}e.isLength=t})(Fj);(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=Fj;function r(n){return n!=null&&typeof n!="function"&&t.isLength(n.length)}e.isArrayLike=r})(nu);var Wj={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r){return typeof r=="object"&&r!==null}e.isObjectLike=t})(Wj);(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=nu,r=Wj;function n(i){return r.isObjectLike(i)&&t.isArrayLike(i)}e.isArrayLikeObject=n})(Bj);var Uj={},qj={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=Qc;function r(n){return function(i){return t.get(i,n)}}e.property=r})(qj);var Hj={},Wh={},Kj={},Uh={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r){return r!==null&&(typeof r=="object"||typeof r=="function")}e.isObject=t})(Uh);var qh={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r){return r==null||typeof r!="object"&&typeof r!="function"}e.isPrimitive=t})(qh);var Hh={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r,n){return r===n||Number.isNaN(r)&&Number.isNaN(n)}e.eq=t})(Hh);(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=Uh,r=qh,n=Hh;function i(u,f,p){return typeof p!="function"?i(u,f,()=>{}):s(u,f,function m(x,g,v,b,j,y){const w=p(x,g,v,b,j,y);return w!==void 0?!!w:s(x,g,m,y)},new Map)}function s(u,f,p,m){if(f===u)return!0;switch(typeof f){case"object":return o(u,f,p,m);case"function":return Object.keys(f).length>0?s(u,{...f},p,m):n.eq(u,f);default:return t.isObject(u)?typeof f=="string"?f==="":!0:n.eq(u,f)}}function o(u,f,p,m){if(f==null)return!0;if(Array.isArray(f))return c(u,f,p,m);if(f instanceof Map)return l(u,f,p,m);if(f instanceof Set)return d(u,f,p,m);const x=Object.keys(f);if(u==null)return x.length===0;if(x.length===0)return!0;if(m!=null&&m.has(f))return m.get(f)===u;m==null||m.set(f,u);try{for(let g=0;g{})}e.isMatch=r})(Wh);var Vj={},Kh={},Yj={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r){return Object.getOwnPropertySymbols(r).filter(n=>Object.prototype.propertyIsEnumerable.call(r,n))}e.getSymbols=t})(Yj);var Vh={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r){return r==null?r===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(r)}e.getTag=t})(Vh);var Yh={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t="[object RegExp]",r="[object String]",n="[object Number]",i="[object Boolean]",s="[object Arguments]",o="[object Symbol]",l="[object Date]",c="[object Map]",d="[object Set]",u="[object Array]",f="[object Function]",p="[object ArrayBuffer]",m="[object Object]",x="[object Error]",g="[object DataView]",v="[object Uint8Array]",b="[object Uint8ClampedArray]",j="[object Uint16Array]",y="[object Uint32Array]",w="[object BigUint64Array]",S="[object Int8Array]",N="[object Int16Array]",P="[object Int32Array]",C="[object BigInt64Array]",T="[object Float32Array]",$="[object Float64Array]";e.argumentsTag=s,e.arrayBufferTag=p,e.arrayTag=u,e.bigInt64ArrayTag=C,e.bigUint64ArrayTag=w,e.booleanTag=i,e.dataViewTag=g,e.dateTag=l,e.errorTag=x,e.float32ArrayTag=T,e.float64ArrayTag=$,e.functionTag=f,e.int16ArrayTag=N,e.int32ArrayTag=P,e.int8ArrayTag=S,e.mapTag=c,e.numberTag=n,e.objectTag=m,e.regexpTag=t,e.setTag=d,e.stringTag=r,e.symbolTag=o,e.uint16ArrayTag=j,e.uint32ArrayTag=y,e.uint8ArrayTag=v,e.uint8ClampedArrayTag=b})(Yh);var Gj={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}e.isTypedArray=t})(Gj);(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=Yj,r=Vh,n=Yh,i=qh,s=Gj;function o(u,f){return l(u,void 0,u,new Map,f)}function l(u,f,p,m=new Map,x=void 0){const g=x==null?void 0:x(u,f,p,m);if(g!==void 0)return g;if(i.isPrimitive(u))return u;if(m.has(u))return m.get(u);if(Array.isArray(u)){const v=new Array(u.length);m.set(u,v);for(let b=0;bt.isMatch(s,i)}e.matches=n})(Hj);var Zj={},Xj={},Jj={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=Kh,r=Yh;function n(i,s){return t.cloneDeepWith(i,(o,l,c,d)=>{const u=s==null?void 0:s(o,l,c,d);if(u!==void 0)return u;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case r.numberTag:case r.stringTag:case r.booleanTag:{const f=new i.constructor(i==null?void 0:i.valueOf());return t.copyProperties(f,i),f}case r.argumentsTag:{const f={};return t.copyProperties(f,i),f.length=i.length,f[Symbol.iterator]=i[Symbol.iterator],f}default:return}})}e.cloneDeepWith=n})(Jj);(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=Jj;function r(n){return t.cloneDeepWith(n)}e.cloneDeep=r})(Xj);var Qj={},Gh={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=/^(?:0|[1-9]\d*)$/;function r(n,i=Number.MAX_SAFE_INTEGER){switch(typeof n){case"number":return Number.isInteger(n)&&n>=0&&ne,Ye=()=>{var e=h.useContext(Zh);return e?e.store.dispatch:dO},ul=()=>{},fO=()=>ul,pO=(e,t)=>e===t;function Z(e){var t=h.useContext(Zh);return tj.useSyncExternalStoreWithSelector(t?t.subscription.addNestedSub:fO,t?t.store.getState:ul,t?t.store.getState:ul,t?e:ul,pO)}function hO(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function mO(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function gO(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(r=>typeof r=="function")){const r=e.map(n=>typeof n=="function"?`function ${n.name||"unnamed"}()`:typeof n).join(", ");throw new TypeError(`${t}[${r}]`)}}var Zx=e=>Array.isArray(e)?e:[e];function xO(e){const t=Array.isArray(e[0])?e[0]:e;return gO(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function yO(e,t){const r=[],{length:n}=e;for(let i=0;i{r=$o(),o.resetResultsCount()},o.resultsCount=()=>s,o.resetResultsCount=()=>{s=0},o}function wO(e,...t){const r=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,n=(...i)=>{let s=0,o=0,l,c={},d=i.pop();typeof d=="object"&&(c=d,d=i.pop()),hO(d,`createSelector expects an output function after the inputs, but received: [${typeof d}]`);const u={...r,...c},{memoize:f,memoizeOptions:p=[],argsMemoize:m=tw,argsMemoizeOptions:x=[]}=u,g=Zx(p),v=Zx(x),b=xO(i),j=f(function(){return s++,d.apply(null,arguments)},...g),y=m(function(){o++;const S=yO(b,arguments);return l=j.apply(null,S),l},...v);return Object.assign(y,{resultFunc:d,memoizedResultFunc:j,dependencies:b,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:f,argsMemoize:m})};return Object.assign(n,{withTypes:()=>n}),n}var L=wO(tw),SO=Object.assign((e,t=L)=>{mO(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const r=Object.keys(e),n=r.map(s=>e[s]);return t(n,(...s)=>s.reduce((o,l,c)=>(o[r[c]]=l,o),{}))},{withTypes:()=>SO}),rw={},nw={},iw={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return typeof n=="symbol"?1:n===null?2:n===void 0?3:n!==n?4:0}const r=(n,i,s)=>{if(n!==i){const o=t(n),l=t(i);if(o===l&&o===0){if(ni)return s==="desc"?-1:1}return s==="desc"?l-o:o-l}return 0};e.compareValues=r})(iw);var aw={},Xh={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r){return typeof r=="symbol"||r instanceof Symbol}e.isSymbol=t})(Xh);(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=Xh,r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function i(s,o){return Array.isArray(s)?!1:typeof s=="number"||typeof s=="boolean"||s==null||t.isSymbol(s)?!0:typeof s=="string"&&(n.test(s)||!r.test(s))||o!=null&&Object.hasOwn(o,s)}e.isKey=i})(aw);(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=iw,r=aw,n=tu;function i(s,o,l,c){if(s==null)return[];l=c?void 0:l,Array.isArray(s)||(s=Object.values(s)),Array.isArray(o)||(o=o==null?[null]:[o]),o.length===0&&(o=[null]),Array.isArray(l)||(l=l==null?[]:[l]),l=l.map(m=>String(m));const d=(m,x)=>{let g=m;for(let v=0;vx==null||m==null?x:typeof m=="object"&&"key"in m?Object.hasOwn(x,m.key)?x[m.key]:d(x,m.path):typeof m=="function"?m(x):Array.isArray(m)?d(x,m):typeof x=="object"?x[m]:x,f=o.map(m=>(Array.isArray(m)&&m.length===1&&(m=m[0]),m==null||typeof m=="function"||Array.isArray(m)||r.isKey(m)?m:{key:m,path:n.toPath(m)}));return s.map(m=>({original:m,criteria:f.map(x=>u(x,m))})).slice().sort((m,x)=>{for(let g=0;gm.original)}e.orderBy=i})(nw);var sw={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r,n=1){const i=[],s=Math.floor(n),o=(l,c)=>{for(let d=0;d1&&n.isIterateeCall(s,o[0],o[1])?o=[]:l>2&&n.isIterateeCall(o[0],o[1],o[2])&&(o=[o[0]]),t.orderBy(s,r.flatten(o),["asc"])}e.sortBy=i})(rw);var NO=rw.sortBy;const iu=Tr(NO);var ow=e=>e.legend.settings,kO=e=>e.legend.size,_O=e=>e.legend.payload;L([_O,ow],(e,t)=>{var{itemSorter:r}=t,n=e.flat(1);return r?iu(n,r):n});var Lo=1;function PO(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[t,r]=h.useState({height:0,left:0,top:0,width:0}),n=h.useCallback(i=>{if(i!=null){var s=i.getBoundingClientRect(),o={height:s.height,left:s.left,top:s.top,width:s.width};(Math.abs(o.height-t.height)>Lo||Math.abs(o.left-t.left)>Lo||Math.abs(o.top-t.top)>Lo||Math.abs(o.width-t.width)>Lo)&&r({height:o.height,left:o.left,top:o.top,width:o.width})}},[t.width,t.height,t.top,t.left,...e]);return[t,n]}function Ze(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var CO=typeof Symbol=="function"&&Symbol.observable||"@@observable",Jx=CO,xd=()=>Math.random().toString(36).substring(7).split("").join("."),AO={INIT:`@@redux/INIT${xd()}`,REPLACE:`@@redux/REPLACE${xd()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${xd()}`},Kl=AO;function Qh(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function lw(e,t,r){if(typeof e!="function")throw new Error(Ze(2));if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(Ze(0));if(typeof t=="function"&&typeof r>"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(Ze(1));return r(lw)(e,t)}let n=e,i=t,s=new Map,o=s,l=0,c=!1;function d(){o===s&&(o=new Map,s.forEach((v,b)=>{o.set(b,v)}))}function u(){if(c)throw new Error(Ze(3));return i}function f(v){if(typeof v!="function")throw new Error(Ze(4));if(c)throw new Error(Ze(5));let b=!0;d();const j=l++;return o.set(j,v),function(){if(b){if(c)throw new Error(Ze(6));b=!1,d(),o.delete(j),s=null}}}function p(v){if(!Qh(v))throw new Error(Ze(7));if(typeof v.type>"u")throw new Error(Ze(8));if(typeof v.type!="string")throw new Error(Ze(17));if(c)throw new Error(Ze(9));try{c=!0,i=n(i,v)}finally{c=!1}return(s=o).forEach(j=>{j()}),v}function m(v){if(typeof v!="function")throw new Error(Ze(10));n=v,p({type:Kl.REPLACE})}function x(){const v=f;return{subscribe(b){if(typeof b!="object"||b===null)throw new Error(Ze(11));function j(){const w=b;w.next&&w.next(u())}return j(),{unsubscribe:v(j)}},[Jx](){return this}}}return p({type:Kl.INIT}),{dispatch:p,subscribe:f,getState:u,replaceReducer:m,[Jx]:x}}function OO(e){Object.keys(e).forEach(t=>{const r=e[t];if(typeof r(void 0,{type:Kl.INIT})>"u")throw new Error(Ze(12));if(typeof r(void 0,{type:Kl.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Ze(13))})}function cw(e){const t=Object.keys(e),r={};for(let s=0;s"u")throw l&&l.type,new Error(Ze(14));d[f]=x,c=c||x!==m}return c=c||n.length!==Object.keys(o).length,c?d:o}}function Vl(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,r)=>(...n)=>t(r(...n)))}function EO(...e){return t=>(r,n)=>{const i=t(r,n);let s=()=>{throw new Error(Ze(15))};const o={getState:i.getState,dispatch:(c,...d)=>s(c,...d)},l=e.map(c=>c(o));return s=Vl(...l)(i.dispatch),{...i,dispatch:s}}}function uw(e){return Qh(e)&&"type"in e&&typeof e.type=="string"}var dw=Symbol.for("immer-nothing"),Qx=Symbol.for("immer-draftable"),Wt=Symbol.for("immer-state");function fr(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var $s=Object.getPrototypeOf;function vi(e){return!!e&&!!e[Wt]}function en(e){var t;return e?fw(e)||Array.isArray(e)||!!e[Qx]||!!((t=e.constructor)!=null&&t[Qx])||eo(e)||su(e):!1}var DO=Object.prototype.constructor.toString(),e0=new WeakMap;function fw(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;const r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(r===Object)return!0;if(typeof r!="function")return!1;let n=e0.get(r);return n===void 0&&(n=Function.toString.call(r),e0.set(r,n)),n===DO}function Yl(e,t,r=!0){au(e)===0?(r?Reflect.ownKeys(e):Object.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((n,i)=>t(i,n,e))}function au(e){const t=e[Wt];return t?t.type_:Array.isArray(e)?1:eo(e)?2:su(e)?3:0}function Wf(e,t){return au(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function pw(e,t,r){const n=au(e);n===2?e.set(t,r):n===3?e.add(r):e[t]=r}function TO(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function eo(e){return e instanceof Map}function su(e){return e instanceof Set}function Jn(e){return e.copy_||e.base_}function Uf(e,t){if(eo(e))return new Map(e);if(su(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const r=fw(e);if(t===!0||t==="class_only"&&!r){const n=Object.getOwnPropertyDescriptors(e);delete n[Wt];let i=Reflect.ownKeys(n);for(let s=0;s1&&Object.defineProperties(e,{set:zo,add:zo,clear:zo,delete:zo}),Object.freeze(e),t&&Object.values(e).forEach(r=>em(r,!0))),e}function MO(){fr(2)}var zo={value:MO};function ou(e){return e===null||typeof e!="object"?!0:Object.isFrozen(e)}var IO={};function bi(e){const t=IO[e];return t||fr(0,e),t}var Ls;function hw(){return Ls}function $O(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function t0(e,t){t&&(bi("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function qf(e){Hf(e),e.drafts_.forEach(LO),e.drafts_=null}function Hf(e){e===Ls&&(Ls=e.parent_)}function r0(e){return Ls=$O(Ls,e)}function LO(e){const t=e[Wt];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function n0(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];return e!==void 0&&e!==r?(r[Wt].modified_&&(qf(t),fr(4)),en(e)&&(e=Gl(t,e),t.parent_||Zl(t,e)),t.patches_&&bi("Patches").generateReplacementPatches_(r[Wt].base_,e,t.patches_,t.inversePatches_)):e=Gl(t,r,[]),qf(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==dw?e:void 0}function Gl(e,t,r){if(ou(t))return t;const n=e.immer_.shouldUseStrictIteration(),i=t[Wt];if(!i)return Yl(t,(s,o)=>i0(e,i,t,s,o,r),n),t;if(i.scope_!==e)return t;if(!i.modified_)return Zl(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const s=i.copy_;let o=s,l=!1;i.type_===3&&(o=new Set(s),s.clear(),l=!0),Yl(o,(c,d)=>i0(e,i,s,c,d,r,l),n),Zl(e,s,!1),r&&e.patches_&&bi("Patches").generatePatches_(i,r,e.patches_,e.inversePatches_)}return i.copy_}function i0(e,t,r,n,i,s,o){if(i==null||typeof i!="object"&&!o)return;const l=ou(i);if(!(l&&!o)){if(vi(i)){const c=s&&t&&t.type_!==3&&!Wf(t.assigned_,n)?s.concat(n):void 0,d=Gl(e,i,c);if(pw(r,n,d),vi(d))e.canAutoFreeze_=!1;else return}else o&&r.add(i);if(en(i)&&!l){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[n]===i&&l)return;Gl(e,i),(!t||!t.scope_.parent_)&&typeof n!="symbol"&&(eo(r)?r.has(n):Object.prototype.propertyIsEnumerable.call(r,n))&&Zl(e,i)}}}function Zl(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&em(t,r)}function zO(e,t){const r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:hw(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=n,s=tm;r&&(i=[n],s=zs);const{revoke:o,proxy:l}=Proxy.revocable(i,s);return n.draft_=l,n.revoke_=o,l}var tm={get(e,t){if(t===Wt)return e;const r=Jn(e);if(!Wf(r,t))return RO(e,r,t);const n=r[t];return e.finalized_||!en(n)?n:n===yd(e.base_,t)?(vd(e),e.copy_[t]=Vf(n,e)):n},has(e,t){return t in Jn(e)},ownKeys(e){return Reflect.ownKeys(Jn(e))},set(e,t,r){const n=mw(Jn(e),t);if(n!=null&&n.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){const i=yd(Jn(e),t),s=i==null?void 0:i[Wt];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(TO(r,i)&&(r!==void 0||Wf(e.base_,t)))return!0;vd(e),Kf(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty(e,t){return yd(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,vd(e),Kf(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=Jn(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty(){fr(11)},getPrototypeOf(e){return $s(e.base_)},setPrototypeOf(){fr(12)}},zs={};Yl(tm,(e,t)=>{zs[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});zs.deleteProperty=function(e,t){return zs.set.call(this,e,t,void 0)};zs.set=function(e,t,r){return tm.set.call(this,e[0],t,r,e[0])};function yd(e,t){const r=e[Wt];return(r?Jn(r):e)[t]}function RO(e,t,r){var i;const n=mw(t,r);return n?"value"in n?n.value:(i=n.get)==null?void 0:i.call(e.draft_):void 0}function mw(e,t){if(!(t in e))return;let r=$s(e);for(;r;){const n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=$s(r)}}function Kf(e){e.modified_||(e.modified_=!0,e.parent_&&Kf(e.parent_))}function vd(e){e.copy_||(e.copy_=Uf(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var BO=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(t,r,n)=>{if(typeof t=="function"&&typeof r!="function"){const s=r;r=t;const o=this;return function(c=s,...d){return o.produce(c,u=>r.call(this,u,...d))}}typeof r!="function"&&fr(6),n!==void 0&&typeof n!="function"&&fr(7);let i;if(en(t)){const s=r0(this),o=Vf(t,void 0);let l=!0;try{i=r(o),l=!1}finally{l?qf(s):Hf(s)}return t0(s,n),n0(i,s)}else if(!t||typeof t!="object"){if(i=r(t),i===void 0&&(i=t),i===dw&&(i=void 0),this.autoFreeze_&&em(i,!0),n){const s=[],o=[];bi("Patches").generateReplacementPatches_(t,i,s,o),n(s,o)}return i}else fr(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(o,...l)=>this.produceWithPatches(o,c=>t(c,...l));let n,i;return[this.produce(t,r,(o,l)=>{n=o,i=l}),n,i]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof(e==null?void 0:e.useStrictIteration)=="boolean"&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){en(e)||fr(8),vi(e)&&(e=Kr(e));const t=r0(this),r=Vf(e,void 0);return r[Wt].isManual_=!0,Hf(t),r}finishDraft(e,t){const r=e&&e[Wt];(!r||!r.isManual_)&&fr(9);const{scope_:n}=r;return t0(n,t),n0(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){const i=t[r];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}r>-1&&(t=t.slice(r+1));const n=bi("Patches").applyPatches_;return vi(e)?n(e,t):this.produce(e,i=>n(i,t))}};function Vf(e,t){const r=eo(e)?bi("MapSet").proxyMap_(e,t):su(e)?bi("MapSet").proxySet_(e,t):zO(e,t);return(t?t.scope_:hw()).drafts_.push(r),r}function Kr(e){return vi(e)||fr(10,e),gw(e)}function gw(e){if(!en(e)||ou(e))return e;const t=e[Wt];let r,n=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Uf(e,t.scope_.immer_.useStrictShallowCopy_),n=t.scope_.immer_.shouldUseStrictIteration()}else r=Uf(e,!0);return Yl(r,(i,s)=>{pw(r,i,gw(s))},n),t&&(t.finalized_=!1),r}var Yf=new BO,xw=Yf.produce,FO=Yf.setUseStrictIteration.bind(Yf);function yw(e){return({dispatch:r,getState:n})=>i=>s=>typeof s=="function"?s(r,n,e):i(s)}var WO=yw(),UO=yw,qO=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Vl:Vl.apply(null,arguments)};function ar(e,t){function r(...n){if(t){let i=t(...n);if(!i)throw new Error(Bt(0));return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:n[0]}}return r.toString=()=>`${e}`,r.type=e,r.match=n=>uw(n)&&n.type===e,r}var vw=class ts extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,ts.prototype)}static get[Symbol.species](){return ts}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new ts(...t[0].concat(this)):new ts(...t.concat(this))}};function a0(e){return en(e)?xw(e,()=>{}):e}function Ro(e,t,r){return e.has(t)?e.get(t):e.set(t,r(t)).get(t)}function HO(e){return typeof e=="boolean"}var KO=()=>function(t){const{thunk:r=!0,immutableCheck:n=!0,serializableCheck:i=!0,actionCreatorCheck:s=!0}=t??{};let o=new vw;return r&&(HO(r)?o.push(WO):o.push(UO(r.extraArgument))),o},bw="RTK_autoBatch",Le=()=>e=>({payload:e,meta:{[bw]:!0}}),s0=e=>t=>{setTimeout(t,e)},jw=(e={type:"raf"})=>t=>(...r)=>{const n=t(...r);let i=!0,s=!1,o=!1;const l=new Set,c=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:s0(10):e.type==="callback"?e.queueNotification:s0(e.timeout),d=()=>{o=!1,s&&(s=!1,l.forEach(u=>u()))};return Object.assign({},n,{subscribe(u){const f=()=>i&&u(),p=n.subscribe(f);return l.add(u),()=>{p(),l.delete(u)}},dispatch(u){var f;try{return i=!((f=u==null?void 0:u.meta)!=null&&f[bw]),s=!i,s&&(o||(o=!0,c(d))),n.dispatch(u)}finally{i=!0}}})},VO=e=>function(r){const{autoBatch:n=!0}=r??{};let i=new vw(e);return n&&i.push(jw(typeof n=="object"?n:void 0)),i};function YO(e){const t=KO(),{reducer:r=void 0,middleware:n,devTools:i=!0,preloadedState:s=void 0,enhancers:o=void 0}=e||{};let l;if(typeof r=="function")l=r;else if(Qh(r))l=cw(r);else throw new Error(Bt(1));let c;typeof n=="function"?c=n(t):c=t();let d=Vl;i&&(d=qO({trace:!1,...typeof i=="object"&&i}));const u=EO(...c),f=VO(u);let p=typeof o=="function"?o(f):f();const m=d(...p);return lw(l,s,m)}function ww(e){const t={},r=[];let n;const i={addCase(s,o){const l=typeof s=="string"?s:s.type;if(!l)throw new Error(Bt(28));if(l in t)throw new Error(Bt(29));return t[l]=o,i},addAsyncThunk(s,o){return o.pending&&(t[s.pending.type]=o.pending),o.rejected&&(t[s.rejected.type]=o.rejected),o.fulfilled&&(t[s.fulfilled.type]=o.fulfilled),o.settled&&r.push({matcher:s.settled,reducer:o.settled}),i},addMatcher(s,o){return r.push({matcher:s,reducer:o}),i},addDefaultCase(s){return n=s,i}};return e(i),[t,r,n]}FO(!1);function GO(e){return typeof e=="function"}function ZO(e,t){let[r,n,i]=ww(t),s;if(GO(e))s=()=>a0(e());else{const l=a0(e);s=()=>l}function o(l=s(),c){let d=[r[c.type],...n.filter(({matcher:u})=>u(c)).map(({reducer:u})=>u)];return d.filter(u=>!!u).length===0&&(d=[i]),d.reduce((u,f)=>{if(f)if(vi(u)){const m=f(u,c);return m===void 0?u:m}else{if(en(u))return xw(u,p=>f(p,c));{const p=f(u,c);if(p===void 0){if(u===null)return u;throw Error("A case reducer on a non-draftable value must not return undefined")}return p}}return u},l)}return o.getInitialState=s,o}var XO="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",JO=(e=21)=>{let t="",r=e;for(;r--;)t+=XO[Math.random()*64|0];return t},QO=Symbol.for("rtk-slice-createasyncthunk");function eE(e,t){return`${e}/${t}`}function tE({creators:e}={}){var r;const t=(r=e==null?void 0:e.asyncThunk)==null?void 0:r[QO];return function(i){const{name:s,reducerPath:o=s}=i;if(!s)throw new Error(Bt(11));const l=(typeof i.reducers=="function"?i.reducers(nE()):i.reducers)||{},c=Object.keys(l),d={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(w,S){const N=typeof w=="string"?w:w.type;if(!N)throw new Error(Bt(12));if(N in d.sliceCaseReducersByType)throw new Error(Bt(13));return d.sliceCaseReducersByType[N]=S,u},addMatcher(w,S){return d.sliceMatchers.push({matcher:w,reducer:S}),u},exposeAction(w,S){return d.actionCreators[w]=S,u},exposeCaseReducer(w,S){return d.sliceCaseReducersByName[w]=S,u}};c.forEach(w=>{const S=l[w],N={reducerName:w,type:eE(s,w),createNotation:typeof i.reducers=="function"};aE(S)?oE(N,S,u,t):iE(N,S,u)});function f(){const[w={},S=[],N=void 0]=typeof i.extraReducers=="function"?ww(i.extraReducers):[i.extraReducers],P={...w,...d.sliceCaseReducersByType};return ZO(i.initialState,C=>{for(let T in P)C.addCase(T,P[T]);for(let T of d.sliceMatchers)C.addMatcher(T.matcher,T.reducer);for(let T of S)C.addMatcher(T.matcher,T.reducer);N&&C.addDefaultCase(N)})}const p=w=>w,m=new Map,x=new WeakMap;let g;function v(w,S){return g||(g=f()),g(w,S)}function b(){return g||(g=f()),g.getInitialState()}function j(w,S=!1){function N(C){let T=C[w];return typeof T>"u"&&S&&(T=Ro(x,N,b)),T}function P(C=p){const T=Ro(m,S,()=>new WeakMap);return Ro(T,C,()=>{const $={};for(const[I,A]of Object.entries(i.selectors??{}))$[I]=rE(A,C,()=>Ro(x,C,b),S);return $})}return{reducerPath:w,getSelectors:P,get selectors(){return P(N)},selectSlice:N}}const y={name:s,reducer:v,actions:d.actionCreators,caseReducers:d.sliceCaseReducersByName,getInitialState:b,...j(o),injectInto(w,{reducerPath:S,...N}={}){const P=S??o;return w.inject({reducerPath:P,reducer:v},N),{...y,...j(P,!0)}}};return y}}function rE(e,t,r,n){function i(s,...o){let l=t(s);return typeof l>"u"&&n&&(l=r()),e(l,...o)}return i.unwrapped=e,i}var At=tE();function nE(){function e(t,r){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...r}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...r){return t(...r)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,r){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:r}},asyncThunk:e}}function iE({type:e,reducerName:t,createNotation:r},n,i){let s,o;if("reducer"in n){if(r&&!sE(n))throw new Error(Bt(17));s=n.reducer,o=n.prepare}else s=n;i.addCase(e,s).exposeCaseReducer(t,s).exposeAction(t,o?ar(e,o):ar(e))}function aE(e){return e._reducerDefinitionType==="asyncThunk"}function sE(e){return e._reducerDefinitionType==="reducerWithPrepare"}function oE({type:e,reducerName:t},r,n,i){if(!i)throw new Error(Bt(18));const{payloadCreator:s,fulfilled:o,pending:l,rejected:c,settled:d,options:u}=r,f=i(e,s,u);n.exposeAction(t,f),o&&n.addCase(f.fulfilled,o),l&&n.addCase(f.pending,l),c&&n.addCase(f.rejected,c),d&&n.addMatcher(f.settled,d),n.exposeCaseReducer(t,{fulfilled:o||Bo,pending:l||Bo,rejected:c||Bo,settled:d||Bo})}function Bo(){}var lE="task",Sw="listener",Nw="completed",rm="cancelled",cE=`task-${rm}`,uE=`task-${Nw}`,Gf=`${Sw}-${rm}`,dE=`${Sw}-${Nw}`,lu=class{constructor(e){go(this,"name","TaskAbortError");go(this,"message");this.code=e,this.message=`${lE} ${rm} (reason: ${e})`}},nm=(e,t)=>{if(typeof e!="function")throw new TypeError(Bt(32))},Xl=()=>{},kw=(e,t=Xl)=>(e.catch(t),e),_w=(e,t)=>(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)),li=(e,t)=>{const r=e.signal;r.aborted||("reason"in r||Object.defineProperty(r,"reason",{enumerable:!0,value:t,configurable:!0,writable:!0}),e.abort(t))},ci=e=>{if(e.aborted){const{reason:t}=e;throw new lu(t)}};function Pw(e,t){let r=Xl;return new Promise((n,i)=>{const s=()=>i(new lu(e.reason));if(e.aborted){s();return}r=_w(e,s),t.finally(()=>r()).then(n,i)}).finally(()=>{r=Xl})}var fE=async(e,t)=>{try{return await Promise.resolve(),{status:"ok",value:await e()}}catch(r){return{status:r instanceof lu?"cancelled":"rejected",error:r}}finally{t==null||t()}},Jl=e=>t=>kw(Pw(e,t).then(r=>(ci(e),r))),Cw=e=>{const t=Jl(e);return r=>t(new Promise(n=>setTimeout(n,r)))},{assign:ia}=Object,o0={},cu="listenerMiddleware",pE=(e,t)=>{const r=n=>_w(e,()=>li(n,e.reason));return(n,i)=>{nm(n);const s=new AbortController;r(s);const o=fE(async()=>{ci(e),ci(s.signal);const l=await n({pause:Jl(s.signal),delay:Cw(s.signal),signal:s.signal});return ci(s.signal),l},()=>li(s,uE));return i!=null&&i.autoJoin&&t.push(o.catch(Xl)),{result:Jl(e)(o),cancel(){li(s,cE)}}}},hE=(e,t)=>{const r=async(n,i)=>{ci(t);let s=()=>{};const l=[new Promise((c,d)=>{let u=e({predicate:n,effect:(f,p)=>{p.unsubscribe(),c([f,p.getState(),p.getOriginalState()])}});s=()=>{u(),d()}})];i!=null&&l.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await Pw(t,Promise.race(l));return ci(t),c}finally{s()}};return(n,i)=>kw(r(n,i))},Aw=e=>{let{type:t,actionCreator:r,matcher:n,predicate:i,effect:s}=e;if(t)i=ar(t).match;else if(r)t=r.type,i=r.match;else if(n)i=n;else if(!i)throw new Error(Bt(21));return nm(s),{predicate:i,type:t,effect:s}},Ow=ia(e=>{const{type:t,predicate:r,effect:n}=Aw(e);return{id:JO(),effect:n,type:t,predicate:r,pending:new Set,unsubscribe:()=>{throw new Error(Bt(22))}}},{withTypes:()=>Ow}),l0=(e,t)=>{const{type:r,effect:n,predicate:i}=Aw(t);return Array.from(e.values()).find(s=>(typeof r=="string"?s.type===r:s.predicate===i)&&s.effect===n)},Zf=e=>{e.pending.forEach(t=>{li(t,Gf)})},mE=(e,t)=>()=>{for(const r of t.keys())Zf(r);e.clear()},c0=(e,t,r)=>{try{e(t,r)}catch(n){setTimeout(()=>{throw n},0)}},Ew=ia(ar(`${cu}/add`),{withTypes:()=>Ew}),gE=ar(`${cu}/removeAll`),Dw=ia(ar(`${cu}/remove`),{withTypes:()=>Dw}),xE=(...e)=>{console.error(`${cu}/error`,...e)},to=(e={})=>{const t=new Map,r=new Map,n=m=>{const x=r.get(m)??0;r.set(m,x+1)},i=m=>{const x=r.get(m)??1;x===1?r.delete(m):r.set(m,x-1)},{extra:s,onError:o=xE}=e;nm(o);const l=m=>(m.unsubscribe=()=>t.delete(m.id),t.set(m.id,m),x=>{m.unsubscribe(),x!=null&&x.cancelActive&&Zf(m)}),c=m=>{const x=l0(t,m)??Ow(m);return l(x)};ia(c,{withTypes:()=>c});const d=m=>{const x=l0(t,m);return x&&(x.unsubscribe(),m.cancelActive&&Zf(x)),!!x};ia(d,{withTypes:()=>d});const u=async(m,x,g,v)=>{const b=new AbortController,j=hE(c,b.signal),y=[];try{m.pending.add(b),n(m),await Promise.resolve(m.effect(x,ia({},g,{getOriginalState:v,condition:(w,S)=>j(w,S).then(Boolean),take:j,delay:Cw(b.signal),pause:Jl(b.signal),extra:s,signal:b.signal,fork:pE(b.signal,y),unsubscribe:m.unsubscribe,subscribe:()=>{t.set(m.id,m)},cancelActiveListeners:()=>{m.pending.forEach((w,S,N)=>{w!==b&&(li(w,Gf),N.delete(w))})},cancel:()=>{li(b,Gf),m.pending.delete(b)},throwIfCancelled:()=>{ci(b.signal)}})))}catch(w){w instanceof lu||c0(o,w,{raisedBy:"effect"})}finally{await Promise.all(y),li(b,dE),i(m),m.pending.delete(b)}},f=mE(t,r);return{middleware:m=>x=>g=>{if(!uw(g))return x(g);if(Ew.match(g))return c(g.payload);if(gE.match(g)){f();return}if(Dw.match(g))return d(g.payload);let v=m.getState();const b=()=>{if(v===o0)throw new Error(Bt(23));return v};let j;try{if(j=x(g),t.size>0){const y=m.getState(),w=Array.from(t.values());for(const S of w){let N=!1;try{N=S.predicate(g,y,v)}catch(P){N=!1,c0(o,P,{raisedBy:"predicate"})}N&&u(S,g,m,b)}}}finally{v=o0}return j},startListening:c,stopListening:d,clearListeners:f}};function Bt(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var yE={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},Tw=At({name:"chartLayout",initialState:yE,reducers:{setLayout(e,t){e.layoutType=t.payload},setChartSize(e,t){e.width=t.payload.width,e.height=t.payload.height},setMargin(e,t){var r,n,i,s;e.margin.top=(r=t.payload.top)!==null&&r!==void 0?r:0,e.margin.right=(n=t.payload.right)!==null&&n!==void 0?n:0,e.margin.bottom=(i=t.payload.bottom)!==null&&i!==void 0?i:0,e.margin.left=(s=t.payload.left)!==null&&s!==void 0?s:0},setScale(e,t){e.scale=t.payload}}}),{setMargin:vE,setLayout:bE,setChartSize:jE,setScale:wE}=Tw.actions,SE=Tw.reducer;function Mw(e,t,r){return Array.isArray(e)&&e&&t+r!==0?e.slice(t,r+1):e}function u0(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Yi(e){for(var t=1;t{if(t&&r){var{width:n,height:i}=r,{align:s,verticalAlign:o,layout:l}=t;if((l==="vertical"||l==="horizontal"&&o==="middle")&&s!=="center"&&G(e[s]))return Yi(Yi({},e),{},{[s]:e[s]+(n||0)});if((l==="horizontal"||l==="vertical"&&s==="center")&&o!=="middle"&&G(e[o]))return Yi(Yi({},e),{},{[o]:e[o]+(i||0)})}return e},Mr=(e,t)=>e==="horizontal"&&t==="xAxis"||e==="vertical"&&t==="yAxis"||e==="centric"&&t==="angleAxis"||e==="radial"&&t==="radiusAxis",Iw=(e,t,r,n)=>{if(n)return e.map(l=>l.coordinate);var i,s,o=e.map(l=>(l.coordinate===t&&(i=!0),l.coordinate===r&&(s=!0),l.coordinate));return i||o.push(t),s||o.push(r),o},$w=(e,t,r)=>{if(!e)return null;var{duplicateDomain:n,type:i,range:s,scale:o,realScaleType:l,isCategorical:c,categoricalDomain:d,tickCount:u,ticks:f,niceTicks:p,axisType:m}=e;if(!o)return null;var x=l==="scaleBand"&&o.bandwidth?o.bandwidth()/2:2,g=i==="category"&&o.bandwidth?o.bandwidth()/x:0;if(g=m==="angleAxis"&&s&&s.length>=2?Jt(s[0]-s[1])*2*g:g,f||p){var v=(f||p||[]).map((b,j)=>{var y=n?n.indexOf(b):b;return{coordinate:o(y)+g,value:b,offset:g,index:j}});return v.filter(b=>!yr(b.coordinate))}return c&&d?d.map((b,j)=>({coordinate:o(b)+g,value:b,index:j,offset:g})):o.ticks&&u!=null?o.ticks(u).map((b,j)=>({coordinate:o(b)+g,value:b,offset:g,index:j})):o.domain().map((b,j)=>({coordinate:o(b)+g,value:n?n[b]:b,index:j,offset:g}))},d0=1e-4,CE=e=>{var t=e.domain();if(!(!t||t.length<=2)){var r=t.length,n=e.range(),i=Math.min(n[0],n[1])-d0,s=Math.max(n[0],n[1])+d0,o=e(t[0]),l=e(t[r-1]);(os||ls)&&e.domain([t[0],t[r-1]])}},AE=e=>{var t=e.length;if(!(t<=0))for(var r=0,n=e[0].length;r=0?(e[o][r][0]=i,e[o][r][1]=i+l,i=e[o][r][1]):(e[o][r][0]=s,e[o][r][1]=s+l,s=e[o][r][1])}},OE=e=>{var t=e.length;if(!(t<=0))for(var r=0,n=e[0].length;r=0?(e[s][r][0]=i,e[s][r][1]=i+o,i=e[s][r][1]):(e[s][r][0]=0,e[s][r][1]=0)}},EE={sign:AE,expand:F4,none:ma,silhouette:W4,wiggle:U4,positive:OE},DE=(e,t,r)=>{var n=EE[r],i=B4().keys(t).value((s,o)=>Number(et(s,o,0))).order(Bf).offset(n);return i(e)};function TE(e){return e==null?void 0:String(e)}function Ql(e){var{axis:t,ticks:r,bandSize:n,entry:i,index:s,dataKey:o}=e;if(t.type==="category"){if(!t.allowDuplicatedCategory&&t.dataKey&&!Re(i[t.dataKey])){var l=Mj(r,"value",i[t.dataKey]);if(l)return l.coordinate+n/2}return r[s]?r[s].coordinate+n/2:null}var c=et(i,Re(o)?t.dataKey:o);return Re(c)?null:t.scale(c)}var ME=e=>{var t=e.flat(2).filter(G);return[Math.min(...t),Math.max(...t)]},IE=e=>[e[0]===1/0?0:e[0],e[1]===-1/0?0:e[1]],$E=(e,t,r)=>{if(e!=null)return IE(Object.keys(e).reduce((n,i)=>{var s=e[i],{stackedData:o}=s,l=o.reduce((c,d)=>{var u=Mw(d,t,r),f=ME(u);return[Math.min(c[0],f[0]),Math.max(c[1],f[1])]},[1/0,-1/0]);return[Math.min(l[0],n[0]),Math.max(l[1],n[1])]},[1/0,-1/0]))},f0=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,p0=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,ga=(e,t,r)=>{if(e&&e.scale&&e.scale.bandwidth){var n=e.scale.bandwidth();if(!r||n>0)return n}if(e&&t&&t.length>=2){for(var i=iu(t,u=>u.coordinate),s=1/0,o=1,l=i.length;o{if(t==="horizontal")return e.chartX;if(t==="vertical")return e.chartY},zE=(e,t)=>t==="centric"?e.angle:e.radius,ln=e=>e.layout.width,cn=e=>e.layout.height,RE=e=>e.layout.scale,Lw=e=>e.layout.margin,du=L(e=>e.cartesianAxis.xAxis,e=>Object.values(e)),fu=L(e=>e.cartesianAxis.yAxis,e=>Object.values(e)),BE="data-recharts-item-index",FE="data-recharts-item-data-key",ro=60;function m0(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Fo(e){for(var t=1;te.brush.height;function KE(e){var t=fu(e);return t.reduce((r,n)=>{if(n.orientation==="left"&&!n.mirror&&!n.hide){var i=typeof n.width=="number"?n.width:ro;return r+i}return r},0)}function VE(e){var t=fu(e);return t.reduce((r,n)=>{if(n.orientation==="right"&&!n.mirror&&!n.hide){var i=typeof n.width=="number"?n.width:ro;return r+i}return r},0)}function YE(e){var t=du(e);return t.reduce((r,n)=>n.orientation==="top"&&!n.mirror&&!n.hide?r+n.height:r,0)}function GE(e){var t=du(e);return t.reduce((r,n)=>n.orientation==="bottom"&&!n.mirror&&!n.hide?r+n.height:r,0)}var rt=L([ln,cn,Lw,HE,KE,VE,YE,GE,ow,kO],(e,t,r,n,i,s,o,l,c,d)=>{var u={left:(r.left||0)+i,right:(r.right||0)+s},f={top:(r.top||0)+o,bottom:(r.bottom||0)+l},p=Fo(Fo({},f),u),m=p.bottom;p.bottom+=n,p=PE(p,c,d);var x=e-p.left-p.right,g=t-p.top-p.bottom;return Fo(Fo({brushBottom:m},p),{},{width:Math.max(x,0),height:Math.max(g,0)})}),ZE=L(rt,e=>({x:e.left,y:e.top,width:e.width,height:e.height})),zw=L(ln,cn,(e,t)=>({x:0,y:0,width:e,height:t})),XE=h.createContext(null),pt=()=>h.useContext(XE)!=null,pu=e=>e.brush,hu=L([pu,rt,Lw],(e,t,r)=>({height:e.height,x:G(e.x)?e.x:t.left,y:G(e.y)?e.y:t.top+t.height+t.brushBottom-((r==null?void 0:r.bottom)||0),width:G(e.width)?e.width:t.width})),Rw={},Bw={},Fw={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r,n,{signal:i,edges:s}={}){let o,l=null;const c=s!=null&&s.includes("leading"),d=s==null||s.includes("trailing"),u=()=>{l!==null&&(r.apply(o,l),o=void 0,l=null)},f=()=>{d&&u(),g()};let p=null;const m=()=>{p!=null&&clearTimeout(p),p=setTimeout(()=>{p=null,f()},n)},x=()=>{p!==null&&(clearTimeout(p),p=null)},g=()=>{x(),o=void 0,l=null},v=()=>{u()},b=function(...j){if(i!=null&&i.aborted)return;o=this,l=j;const y=p==null;m(),c&&y&&u()};return b.schedule=m,b.cancel=g,b.flush=v,i==null||i.addEventListener("abort",g,{once:!0}),b}e.debounce=t})(Fw);(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=Fw;function r(n,i=0,s={}){typeof s!="object"&&(s={});const{leading:o=!1,trailing:l=!0,maxWait:c}=s,d=Array(2);o&&(d[0]="leading"),l&&(d[1]="trailing");let u,f=null;const p=t.debounce(function(...g){u=n.apply(this,g),f=null},i,{edges:d}),m=function(...g){return c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(u=n.apply(this,g),f=Date.now(),p.cancel(),p.schedule(),u):(p.apply(this,g),u)},x=()=>(p.flush(),u);return m.cancel=p.cancel,m.flush=x,m}e.debounce=r})(Bw);(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=Bw;function r(n,i=0,s={}){const{leading:o=!0,trailing:l=!0}=s;return t.debounce(n,i,{leading:o,maxWait:i,trailing:l})}e.throttle=r})(Rw);var JE=Rw.throttle;const QE=Tr(JE);var ec=function(t,r){for(var n=arguments.length,i=new Array(n>2?n-2:0),s=2;s{var{width:n="100%",height:i="100%",aspect:s,maxHeight:o}=r,l=Qr(n)?e:Number(n),c=Qr(i)?t:Number(i);return s&&s>0&&(l?c=l/s:c&&(l=c*s),o&&c!=null&&c>o&&(c=o)),{calculatedWidth:l,calculatedHeight:c}},e3={width:0,height:0,overflow:"visible"},t3={width:0,overflowX:"visible"},r3={height:0,overflowY:"visible"},n3={},i3=e=>{var{width:t,height:r}=e,n=Qr(t),i=Qr(r);return n&&i?e3:n?t3:i?r3:n3};function a3(e){var{width:t,height:r,aspect:n}=e,i=t,s=r;return i===void 0&&s===void 0?(i="100%",s="100%"):i===void 0?i=n&&n>0?void 0:"100%":s===void 0&&(s=n&&n>0?void 0:"100%"),{width:i,height:s}}function _e(e){return Number.isFinite(e)}function Er(e){return typeof e=="number"&&e>0&&Number.isFinite(e)}function Xf(){return Xf=Object.assign?Object.assign.bind():function(e){for(var t=1;t({width:r,height:n}),[r,n]);return c3(i)?h.createElement(Uw.Provider,{value:i},t):null}var im=()=>h.useContext(Uw),u3=h.forwardRef((e,t)=>{var{aspect:r,initialDimension:n={width:-1,height:-1},width:i,height:s,minWidth:o=0,minHeight:l,maxHeight:c,children:d,debounce:u=0,id:f,className:p,onResize:m,style:x={}}=e,g=h.useRef(null),v=h.useRef();v.current=m,h.useImperativeHandle(t,()=>g.current);var[b,j]=h.useState({containerWidth:n.width,containerHeight:n.height}),y=h.useCallback((C,T)=>{j($=>{var I=Math.round(C),A=Math.round(T);return $.containerWidth===I&&$.containerHeight===A?$:{containerWidth:I,containerHeight:A}})},[]);h.useEffect(()=>{if(g.current==null||typeof ResizeObserver>"u")return Pa;var C=A=>{var R,{width:H,height:M}=A[0].contentRect;y(H,M),(R=v.current)===null||R===void 0||R.call(v,H,M)};u>0&&(C=QE(C,u,{trailing:!0,leading:!1}));var T=new ResizeObserver(C),{width:$,height:I}=g.current.getBoundingClientRect();return y($,I),T.observe(g.current),()=>{T.disconnect()}},[y,u]);var{containerWidth:w,containerHeight:S}=b;ec(!r||r>0,"The aspect(%s) must be greater than zero.",r);var{calculatedWidth:N,calculatedHeight:P}=Ww(w,S,{width:i,height:s,aspect:r,maxHeight:c});return ec(N!=null&&N>0||P!=null&&P>0,`The width(%s) and height(%s) of chart should be greater than 0, please check the style of container, or the props width(%s) and height(%s), or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the height and width.`,N,P,i,s,o,l,r),h.createElement("div",{id:f?"".concat(f):void 0,className:ue("recharts-responsive-container",p),style:x0(x0({},x),{},{width:i,height:s,minWidth:o,minHeight:l,maxHeight:c}),ref:g},h.createElement("div",{style:i3({width:i,height:s})},h.createElement(qw,{width:N,height:P},d)))}),y0=h.forwardRef((e,t)=>{var r=im();if(Er(r.width)&&Er(r.height))return e.children;var{width:n,height:i}=a3({width:e.width,height:e.height,aspect:e.aspect}),{calculatedWidth:s,calculatedHeight:o}=Ww(void 0,void 0,{width:n,height:i,aspect:e.aspect,maxHeight:e.maxHeight});return G(s)&&G(o)?h.createElement(qw,{width:s,height:o},e.children):h.createElement(u3,Xf({},e,{width:n,height:i,ref:t}))});function Hw(e){if(e)return{x:e.x,y:e.y,upperWidth:"upperWidth"in e?e.upperWidth:e.width,lowerWidth:"lowerWidth"in e?e.lowerWidth:e.width,width:e.width,height:e.height}}var mu=()=>{var e,t=pt(),r=Z(ZE),n=Z(hu),i=(e=Z(pu))===null||e===void 0?void 0:e.padding;return!t||!n||!i?r:{width:n.width-i.left-i.right,height:n.height-i.top-i.bottom,x:i.left,y:i.top}},d3={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},Kw=()=>{var e;return(e=Z(rt))!==null&&e!==void 0?e:d3},Vw=()=>Z(ln),Yw=()=>Z(cn),de=e=>e.layout.layoutType,no=()=>Z(de),f3=()=>{var e=no();return e!==void 0},gu=e=>{var t=Ye(),r=pt(),{width:n,height:i}=e,s=im(),o=n,l=i;return s&&(o=s.width>0?s.width:n,l=s.height>0?s.height:i),h.useEffect(()=>{!r&&Er(o)&&Er(l)&&t(jE({width:o,height:l}))},[t,r,o,l]),null},p3={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},Gw=At({name:"legend",initialState:p3,reducers:{setLegendSize(e,t){e.size.width=t.payload.width,e.size.height=t.payload.height},setLegendSettings(e,t){e.settings.align=t.payload.align,e.settings.layout=t.payload.layout,e.settings.verticalAlign=t.payload.verticalAlign,e.settings.itemSorter=t.payload.itemSorter},addLegendPayload:{reducer(e,t){e.payload.push(t.payload)},prepare:Le()},removeLegendPayload:{reducer(e,t){var r=Kr(e).payload.indexOf(t.payload);r>-1&&e.payload.splice(r,1)},prepare:Le()}}}),{setLegendSize:MF,setLegendSettings:IF,addLegendPayload:h3,removeLegendPayload:m3}=Gw.actions,g3=Gw.reducer;function Jf(){return Jf=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{separator:t=" : ",contentStyle:r={},itemStyle:n={},labelStyle:i={},payload:s,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:d,label:u,labelFormatter:f,accessibilityLayer:p=!1}=e,m=()=>{if(s&&s.length){var S={padding:0,margin:0},N=(l?iu(s,l):s).map((P,C)=>{if(P.type==="none")return null;var T=P.formatter||o||b3,{value:$,name:I}=P,A=$,R=I;if(T){var H=T($,I,P,C,s);if(Array.isArray(H))[A,R]=H;else if(H!=null)A=H;else return null}var M=bd({display:"block",paddingTop:4,paddingBottom:4,color:P.color||"#000"},n);return h.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(C),style:M},Or(R)?h.createElement("span",{className:"recharts-tooltip-item-name"},R):null,Or(R)?h.createElement("span",{className:"recharts-tooltip-item-separator"},t):null,h.createElement("span",{className:"recharts-tooltip-item-value"},A),h.createElement("span",{className:"recharts-tooltip-item-unit"},P.unit||""))});return h.createElement("ul",{className:"recharts-tooltip-item-list",style:S},N)}return null},x=bd({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},r),g=bd({margin:0},i),v=!Re(u),b=v?u:"",j=ue("recharts-default-tooltip",c),y=ue("recharts-tooltip-label",d);v&&f&&s!==void 0&&s!==null&&(b=f(u,s));var w=p?{role:"status","aria-live":"assertive"}:{};return h.createElement("div",Jf({className:j,style:x},w),h.createElement("p",{className:y,style:g},h.isValidElement(b)?b:"".concat(b)),m())},qa="recharts-tooltip-wrapper",w3={visibility:"hidden"};function S3(e){var{coordinate:t,translateX:r,translateY:n}=e;return ue(qa,{["".concat(qa,"-right")]:G(r)&&t&&G(t.x)&&r>=t.x,["".concat(qa,"-left")]:G(r)&&t&&G(t.x)&&r=t.y,["".concat(qa,"-top")]:G(n)&&t&&G(t.y)&&n0?i:0),f=r[n]+i;if(t[n])return o[n]?u:f;var p=c[n];if(p==null)return 0;if(o[n]){var m=u,x=p;return mv?Math.max(u,p):Math.max(f,p)}function N3(e){var{translateX:t,translateY:r,useTranslate3d:n}=e;return{transform:n?"translate3d(".concat(t,"px, ").concat(r,"px, 0)"):"translate(".concat(t,"px, ").concat(r,"px)")}}function k3(e){var{allowEscapeViewBox:t,coordinate:r,offsetTopLeft:n,position:i,reverseDirection:s,tooltipBox:o,useTranslate3d:l,viewBox:c}=e,d,u,f;return o.height>0&&o.width>0&&r?(u=b0({allowEscapeViewBox:t,coordinate:r,key:"x",offsetTopLeft:n,position:i,reverseDirection:s,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),f=b0({allowEscapeViewBox:t,coordinate:r,key:"y",offsetTopLeft:n,position:i,reverseDirection:s,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),d=N3({translateX:u,translateY:f,useTranslate3d:l})):d=w3,{cssProperties:d,cssClasses:S3({translateX:u,translateY:f,coordinate:r})}}function j0(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Wo(e){for(var t=1;t{if(t.key==="Escape"){var r,n,i,s;this.setState({dismissed:!0,dismissedAtCoordinate:{x:(r=(n=this.props.coordinate)===null||n===void 0?void 0:n.x)!==null&&r!==void 0?r:0,y:(i=(s=this.props.coordinate)===null||s===void 0?void 0:s.y)!==null&&i!==void 0?i:0}})}})}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}componentDidUpdate(){var t,r;this.state.dismissed&&(((t=this.props.coordinate)===null||t===void 0?void 0:t.x)!==this.state.dismissedAtCoordinate.x||((r=this.props.coordinate)===null||r===void 0?void 0:r.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}render(){var{active:t,allowEscapeViewBox:r,animationDuration:n,animationEasing:i,children:s,coordinate:o,hasPayload:l,isAnimationActive:c,offset:d,position:u,reverseDirection:f,useTranslate3d:p,viewBox:m,wrapperStyle:x,lastBoundingBox:g,innerRef:v,hasPortalFromProps:b}=this.props,{cssClasses:j,cssProperties:y}=k3({allowEscapeViewBox:r,coordinate:o,offsetTopLeft:d,position:u,reverseDirection:f,tooltipBox:{height:g.height,width:g.width},useTranslate3d:p,viewBox:m}),w=b?{}:Wo(Wo({transition:c&&t?"transform ".concat(n,"ms ").concat(i):void 0},y),{},{pointerEvents:"none",visibility:!this.state.dismissed&&t&&l?"visible":"hidden",position:"absolute",top:0,left:0}),S=Wo(Wo({},w),{},{visibility:!this.state.dismissed&&t&&l?"visible":"hidden"},x);return h.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:j,style:S,ref:v},s)}}var A3=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Ci={devToolsEnabled:!1,isSsr:A3()},Zw=()=>{var e;return(e=Z(t=>t.rootProps.accessibilityLayer))!==null&&e!==void 0?e:!0};function ep(){return ep=Object.assign?Object.assign.bind():function(e){for(var t=1;t_e(e.x)&&_e(e.y),k0=e=>e.base!=null&&tc(e.base)&&tc(e),Ha=e=>e.x,Ka=e=>e.y,T3=(e,t)=>{if(typeof e=="function")return e;var r="curve".concat(Qs(e));return(r==="curveMonotone"||r==="curveBump")&&t?N0["".concat(r).concat(t==="vertical"?"Y":"X")]:N0[r]||Xc},M3=e=>{var{type:t="linear",points:r=[],baseLine:n,layout:i,connectNulls:s=!1}=e,o=T3(t,i),l=s?r.filter(tc):r,c;if(Array.isArray(n)){var d=r.map((m,x)=>S0(S0({},m),{},{base:n[x]}));i==="vertical"?c=Io().y(Ka).x1(Ha).x0(m=>m.base.x):c=Io().x(Ha).y1(Ka).y0(m=>m.base.y);var u=c.defined(k0).curve(o),f=s?d.filter(k0):d;return u(f)}i==="vertical"&&G(n)?c=Io().y(Ka).x1(Ha).x0(n):G(n)?c=Io().x(Ha).y1(Ka).y0(n):c=bj().x(Ha).y(Ka);var p=c.defined(tc).curve(o);return p(l)},fs=e=>{var{className:t,points:r,path:n,pathRef:i}=e;if((!r||!r.length)&&!n)return null;var s=r&&r.length?M3(e):n;return h.createElement("path",ep({},nr(e),Bh(e),{className:ue("recharts-curve",t),d:s===null?void 0:s,ref:i}))},I3=["x","y","top","left","width","height","className"];function tp(){return tp=Object.assign?Object.assign.bind():function(e){for(var t=1;t"M".concat(e,",").concat(i,"v").concat(n,"M").concat(s,",").concat(t,"h").concat(r),U3=e=>{var{x:t=0,y:r=0,top:n=0,left:i=0,width:s=0,height:o=0,className:l}=e,c=B3(e,I3),d=$3({x:t,y:r,top:n,left:i,width:s,height:o},c);return!G(t)||!G(r)||!G(s)||!G(o)||!G(n)||!G(i)?null:h.createElement("path",tp({},ut(d),{className:ue("recharts-cross",l),d:W3(t,r,s,o,n,i)}))};function q3(e,t,r,n){var i=n/2;return{stroke:"none",fill:"#ccc",x:e==="horizontal"?t.x-i:r.left+.5,y:e==="horizontal"?r.top+.5:t.y-i,width:e==="horizontal"?n:r.width-1,height:e==="horizontal"?r.height-1:n}}function P0(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function C0(e){for(var t=1;te.replace(/([A-Z])/g,t=>"-".concat(t.toLowerCase())),Xw=(e,t,r)=>e.map(n=>"".concat(Y3(n)," ").concat(t,"ms ").concat(r)).join(","),G3=(e,t)=>[Object.keys(e),Object.keys(t)].reduce((r,n)=>r.filter(i=>n.includes(i))),Rs=(e,t)=>Object.keys(t).reduce((r,n)=>C0(C0({},r),{},{[n]:e(n,t[n])}),{});function A0(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function $e(e){for(var t=1;te+(t-e)*r,rp=e=>{var{from:t,to:r}=e;return t!==r},Jw=(e,t,r)=>{var n=Rs((i,s)=>{if(rp(s)){var[o,l]=e(s.from,s.to,s.velocity);return $e($e({},s),{},{from:o,velocity:l})}return s},t);return r<1?Rs((i,s)=>rp(s)?$e($e({},s),{},{velocity:rc(s.velocity,n[i].velocity,r),from:rc(s.from,n[i].from,r)}):s,t):Jw(e,n,r-1)};function Q3(e,t,r,n,i,s){var o,l=n.reduce((p,m)=>$e($e({},p),{},{[m]:{from:e[m],velocity:0,to:t[m]}}),{}),c=()=>Rs((p,m)=>m.from,l),d=()=>!Object.values(l).filter(rp).length,u=null,f=p=>{o||(o=p);var m=p-o,x=m/r.dt;l=Jw(r,l,x),i($e($e($e({},e),t),c())),o=p,d()||(u=s.setTimeout(f))};return()=>(u=s.setTimeout(f),()=>{var p;(p=u)===null||p===void 0||p()})}function e5(e,t,r,n,i,s,o){var l=null,c=i.reduce((f,p)=>$e($e({},f),{},{[p]:[e[p],t[p]]}),{}),d,u=f=>{d||(d=f);var p=(f-d)/n,m=Rs((g,v)=>rc(...v,r(p)),c);if(s($e($e($e({},e),t),m)),p<1)l=o.setTimeout(u);else{var x=Rs((g,v)=>rc(...v,r(1)),c);s($e($e($e({},e),t),x))}};return()=>(l=o.setTimeout(u),()=>{var f;(f=l)===null||f===void 0||f()})}const t5=(e,t,r,n,i,s)=>{var o=G3(e,t);return r==null?()=>(i($e($e({},e),t)),()=>{}):r.isStepper===!0?Q3(e,t,r,o,i,s):e5(e,t,r,n,o,i,s)};var nc=1e-4,Qw=(e,t)=>[0,3*e,3*t-6*e,3*e-3*t+1],eS=(e,t)=>e.map((r,n)=>r*t**n).reduce((r,n)=>r+n),O0=(e,t)=>r=>{var n=Qw(e,t);return eS(n,r)},r5=(e,t)=>r=>{var n=Qw(e,t),i=[...n.map((s,o)=>s*o).slice(1),0];return eS(i,r)},n5=function(){for(var t=arguments.length,r=new Array(t),n=0;nparseFloat(l));return[o[0],o[1],o[2],o[3]]}}}return r.length===4?r:[0,0,1,1]},i5=(e,t,r,n)=>{var i=O0(e,r),s=O0(t,n),o=r5(e,r),l=d=>d>1?1:d<0?0:d,c=d=>{for(var u=d>1?1:d,f=u,p=0;p<8;++p){var m=i(f)-u,x=o(f);if(Math.abs(m-u)0&&arguments[0]!==void 0?arguments[0]:{},{stiff:r=100,damping:n=8,dt:i=17}=t,s=(o,l,c)=>{var d=-(o-l)*r,u=c*n,f=c+(d-u)*i/1e3,p=c*i/1e3+o;return Math.abs(p-l){if(typeof e=="string")switch(e){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return E0(e);case"spring":return a5();default:if(e.split("(")[0]==="cubic-bezier")return E0(e)}return typeof e=="function"?e:null};function o5(e){var t,r=()=>null,n=!1,i=null,s=o=>{if(!n){if(Array.isArray(o)){if(!o.length)return;var l=o,[c,...d]=l;if(typeof c=="number"){i=e.setTimeout(s.bind(null,d),c);return}s(c),i=e.setTimeout(s.bind(null,d));return}typeof o=="string"&&(t=o,r(t)),typeof o=="object"&&(t=o,r(t)),typeof o=="function"&&o()}};return{stop:()=>{n=!0},start:o=>{n=!1,i&&(i(),i=null),s(o)},subscribe:o=>(r=o,()=>{r=()=>null}),getTimeoutController:()=>e}}class l5{setTimeout(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=performance.now(),i=null,s=o=>{o-n>=r?t(o):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(s))};return i=requestAnimationFrame(s),()=>{i!=null&&cancelAnimationFrame(i)}}}function c5(){return o5(new l5)}var u5=h.createContext(c5);function d5(e,t){var r=h.useContext(u5);return h.useMemo(()=>t??r(e),[e,t,r])}var f5={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},D0={t:0},jd={t:1};function xu(e){var t=ft(e,f5),{isActive:r,canBegin:n,duration:i,easing:s,begin:o,onAnimationEnd:l,onAnimationStart:c,children:d}=t,u=d5(t.animationId,t.animationManager),[f,p]=h.useState(r?D0:jd),m=h.useRef(null);return h.useEffect(()=>{r||p(jd)},[r]),h.useEffect(()=>{if(!r||!n)return Pa;var x=t5(D0,jd,s5(s),i,p,u.getTimeoutController()),g=()=>{m.current=x()};return u.start([c,o,g,i,l]),()=>{u.stop(),m.current&&m.current(),l()}},[r,n,i,s,o,c,l,u]),d(f.t)}function yu(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",r=h.useRef(Is(t)),n=h.useRef(e);return n.current!==e&&(r.current=Is(t),n.current=e),r.current}var p5=["radius"],h5=["radius"];function T0(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function M0(e){for(var t=1;t{var s=Math.min(Math.abs(r)/2,Math.abs(n)/2),o=n>=0?1:-1,l=r>=0?1:-1,c=n>=0&&r>=0||n<0&&r<0?1:0,d;if(s>0&&i instanceof Array){for(var u=[0,0,0,0],f=0,p=4;fs?s:i[f];d="M".concat(e,",").concat(t+o*u[0]),u[0]>0&&(d+="A ".concat(u[0],",").concat(u[0],",0,0,").concat(c,",").concat(e+l*u[0],",").concat(t)),d+="L ".concat(e+r-l*u[1],",").concat(t),u[1]>0&&(d+="A ".concat(u[1],",").concat(u[1],",0,0,").concat(c,`, `).concat(e+r,",").concat(t+o*u[1])),d+="L ".concat(e+r,",").concat(t+n-o*u[2]),u[2]>0&&(d+="A ".concat(u[2],",").concat(u[2],",0,0,").concat(c,`, `).concat(e+r-l*u[2],",").concat(t+n)),d+="L ".concat(e+l*u[3],",").concat(t+n),u[3]>0&&(d+="A ".concat(u[3],",").concat(u[3],",0,0,").concat(c,`, `).concat(e,",").concat(t+n-o*u[3])),d+="Z"}else if(s>0&&i===+i&&i>0){var m=Math.min(s,i);d="M ".concat(e,",").concat(t+o*m,` A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(e+l*m,",").concat(t,` L `).concat(e+r-l*m,",").concat(t,` A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(e+r,",").concat(t+o*m,` L `).concat(e+r,",").concat(t+n-o*m,` A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(e+r-l*m,",").concat(t+n,` L `).concat(e+l*m,",").concat(t+n,` A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(e,",").concat(t+n-o*m," Z")}else d="M ".concat(e,",").concat(t," h ").concat(r," v ").concat(n," h ").concat(-r," Z");return d},L0={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},tS=e=>{var t=ft(e,L0),r=h.useRef(null),[n,i]=h.useState(-1);h.useEffect(()=>{if(r.current&&r.current.getTotalLength)try{var D=r.current.getTotalLength();D&&i(D)}catch{}},[]);var{x:s,y:o,width:l,height:c,radius:d,className:u}=t,{animationEasing:f,animationDuration:p,animationBegin:m,isAnimationActive:x,isUpdateAnimationActive:g}=t,v=h.useRef(l),b=h.useRef(c),j=h.useRef(s),y=h.useRef(o),w=h.useMemo(()=>({x:s,y:o,width:l,height:c,radius:d}),[s,o,l,c,d]),S=yu(w,"rectangle-");if(s!==+s||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var N=ue("recharts-rectangle",u);if(!g){var P=ut(t),{radius:C}=P,T=I0(P,p5);return h.createElement("path",ic({},T,{radius:typeof d=="number"?d:void 0,className:N,d:$0(s,o,l,c,d)}))}var $=v.current,I=b.current,A=j.current,R=y.current,H="0px ".concat(n===-1?1:n,"px"),M="".concat(n,"px 0px"),_=Xw(["strokeDasharray"],p,typeof f=="string"?f:L0.animationEasing);return h.createElement(xu,{animationId:S,key:S,canBegin:n>0,duration:p,easing:f,isActive:g,begin:m},D=>{var O=Ee($,l,D),k=Ee(I,c,D),z=Ee(A,s,D),W=Ee(R,o,D);r.current&&(v.current=O,b.current=k,j.current=z,y.current=W);var K;x?D>0?K={transition:_,strokeDasharray:M}:K={strokeDasharray:H}:K={strokeDasharray:M};var ee=ut(t),{radius:re}=ee,Me=I0(ee,h5);return h.createElement("path",ic({},Me,{radius:typeof d=="number"?d:void 0,className:N,d:$0(z,W,O,k,d),ref:r,style:M0(M0({},K),t.style)}))})};function z0(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function R0(e){for(var t=1;te*180/Math.PI,Je=(e,t,r,n)=>({x:e+Math.cos(-ac*n)*r,y:t+Math.sin(-ac*n)*r}),S5=function(t,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(t-(n.left||0)-(n.right||0)),Math.abs(r-(n.top||0)-(n.bottom||0)))/2},N5=(e,t)=>{var{x:r,y:n}=e,{x:i,y:s}=t;return Math.sqrt((r-i)**2+(n-s)**2)},k5=(e,t)=>{var{x:r,y:n}=e,{cx:i,cy:s}=t,o=N5({x:r,y:n},{x:i,y:s});if(o<=0)return{radius:o,angle:0};var l=(r-i)/o,c=Math.acos(l);return n>s&&(c=2*Math.PI-c),{radius:o,angle:w5(c),angleInRadian:c}},_5=e=>{var{startAngle:t,endAngle:r}=e,n=Math.floor(t/360),i=Math.floor(r/360),s=Math.min(n,i);return{startAngle:t-s*360,endAngle:r-s*360}},P5=(e,t)=>{var{startAngle:r,endAngle:n}=t,i=Math.floor(r/360),s=Math.floor(n/360),o=Math.min(i,s);return e+o*360},C5=(e,t)=>{var{chartX:r,chartY:n}=e,{radius:i,angle:s}=k5({x:r,y:n},t),{innerRadius:o,outerRadius:l}=t;if(il||i===0)return null;var{startAngle:c,endAngle:d}=_5(t),u=s,f;if(c<=d){for(;u>d;)u-=360;for(;u=c&&u<=d}else{for(;u>c;)u-=360;for(;u=d&&u<=c}return f?R0(R0({},t),{},{radius:i,angle:P5(u,t)}):null};function rS(e){var{cx:t,cy:r,radius:n,startAngle:i,endAngle:s}=e,o=Je(t,r,n,i),l=Je(t,r,n,s);return{points:[o,l],cx:t,cy:r,radius:n,startAngle:i,endAngle:s}}function np(){return np=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var r=Jt(t-e),n=Math.min(Math.abs(t-e),359.999);return r*n},Uo=e=>{var{cx:t,cy:r,radius:n,angle:i,sign:s,isExternal:o,cornerRadius:l,cornerIsExternal:c}=e,d=l*(o?1:-1)+n,u=Math.asin(l/d)/ac,f=c?i:i+s*u,p=Je(t,r,d,f),m=Je(t,r,n,f),x=c?i-s*u:i,g=Je(t,r,d*Math.cos(u*ac),x);return{center:p,circleTangency:m,lineTangency:g,theta:u}},nS=e=>{var{cx:t,cy:r,innerRadius:n,outerRadius:i,startAngle:s,endAngle:o}=e,l=A5(s,o),c=s+l,d=Je(t,r,i,s),u=Je(t,r,i,c),f="M ".concat(d.x,",").concat(d.y,` A `).concat(i,",").concat(i,`,0, `).concat(+(Math.abs(l)>180),",").concat(+(s>c),`, `).concat(u.x,",").concat(u.y,` `);if(n>0){var p=Je(t,r,n,s),m=Je(t,r,n,c);f+="L ".concat(m.x,",").concat(m.y,` A `).concat(n,",").concat(n,`,0, `).concat(+(Math.abs(l)>180),",").concat(+(s<=c),`, `).concat(p.x,",").concat(p.y," Z")}else f+="L ".concat(t,",").concat(r," Z");return f},O5=e=>{var{cx:t,cy:r,innerRadius:n,outerRadius:i,cornerRadius:s,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:d}=e,u=Jt(d-c),{circleTangency:f,lineTangency:p,theta:m}=Uo({cx:t,cy:r,radius:i,angle:c,sign:u,cornerRadius:s,cornerIsExternal:l}),{circleTangency:x,lineTangency:g,theta:v}=Uo({cx:t,cy:r,radius:i,angle:d,sign:-u,cornerRadius:s,cornerIsExternal:l}),b=l?Math.abs(c-d):Math.abs(c-d)-m-v;if(b<0)return o?"M ".concat(p.x,",").concat(p.y,` a`).concat(s,",").concat(s,",0,0,1,").concat(s*2,`,0 a`).concat(s,",").concat(s,",0,0,1,").concat(-s*2,`,0 `):nS({cx:t,cy:r,innerRadius:n,outerRadius:i,startAngle:c,endAngle:d});var j="M ".concat(p.x,",").concat(p.y,` A`).concat(s,",").concat(s,",0,0,").concat(+(u<0),",").concat(f.x,",").concat(f.y,` A`).concat(i,",").concat(i,",0,").concat(+(b>180),",").concat(+(u<0),",").concat(x.x,",").concat(x.y,` A`).concat(s,",").concat(s,",0,0,").concat(+(u<0),",").concat(g.x,",").concat(g.y,` `);if(n>0){var{circleTangency:y,lineTangency:w,theta:S}=Uo({cx:t,cy:r,radius:n,angle:c,sign:u,isExternal:!0,cornerRadius:s,cornerIsExternal:l}),{circleTangency:N,lineTangency:P,theta:C}=Uo({cx:t,cy:r,radius:n,angle:d,sign:-u,isExternal:!0,cornerRadius:s,cornerIsExternal:l}),T=l?Math.abs(c-d):Math.abs(c-d)-S-C;if(T<0&&s===0)return"".concat(j,"L").concat(t,",").concat(r,"Z");j+="L".concat(P.x,",").concat(P.y,` A`).concat(s,",").concat(s,",0,0,").concat(+(u<0),",").concat(N.x,",").concat(N.y,` A`).concat(n,",").concat(n,",0,").concat(+(T>180),",").concat(+(u>0),",").concat(y.x,",").concat(y.y,` A`).concat(s,",").concat(s,",0,0,").concat(+(u<0),",").concat(w.x,",").concat(w.y,"Z")}else j+="L".concat(t,",").concat(r,"Z");return j},E5={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},iS=e=>{var t=ft(e,E5),{cx:r,cy:n,innerRadius:i,outerRadius:s,cornerRadius:o,forceCornerRadius:l,cornerIsExternal:c,startAngle:d,endAngle:u,className:f}=t;if(s0&&Math.abs(d-u)<360?g=O5({cx:r,cy:n,innerRadius:i,outerRadius:s,cornerRadius:Math.min(x,m/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:d,endAngle:u}):g=nS({cx:r,cy:n,innerRadius:i,outerRadius:s,startAngle:d,endAngle:u}),h.createElement("path",np({},ut(t),{className:p,d:g}))};function D5(e,t,r){if(e==="horizontal")return[{x:t.x,y:r.top},{x:t.x,y:r.top+r.height}];if(e==="vertical")return[{x:r.left,y:t.y},{x:r.left+r.width,y:t.y}];if(Lj(t)){if(e==="centric"){var{cx:n,cy:i,innerRadius:s,outerRadius:o,angle:l}=t,c=Je(n,i,s,l),d=Je(n,i,o,l);return[{x:c.x,y:c.y},{x:d.x,y:d.y}]}return rS(t)}}var aS={},sS={},oS={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=Xh;function r(n){return t.isSymbol(n)?NaN:Number(n)}e.toNumber=r})(oS);(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=oS;function r(n){return n?(n=t.toNumber(n),n===1/0||n===-1/0?(n<0?-1:1)*Number.MAX_VALUE:n===n?n:0):n===0?n:0}e.toFinite=r})(sS);(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=Jh,r=sS;function n(i,s,o){o&&typeof o!="number"&&t.isIterateeCall(i,s,o)&&(s=o=void 0),i=r.toFinite(i),s===void 0?(s=i,i=0):s=r.toFinite(s),o=o===void 0?it?1:e>=t?0:NaN}function M5(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}function am(e){let t,r,n;e.length!==2?(t=Mn,r=(l,c)=>Mn(e(l),c),n=(l,c)=>e(l)-c):(t=e===Mn||e===M5?e:I5,r=e,n=e);function i(l,c,d=0,u=l.length){if(d>>1;r(l[f],c)<0?d=f+1:u=f}while(d>>1;r(l[f],c)<=0?d=f+1:u=f}while(dd&&n(l[f-1],c)>-n(l[f],c)?f-1:f}return{left:i,center:o,right:s}}function I5(){return 0}function cS(e){return e===null?NaN:+e}function*$5(e,t){for(let r of e)r!=null&&(r=+r)>=r&&(yield r)}const L5=am(Mn),io=L5.right;am(cS).center;class B0 extends Map{constructor(t,r=B5){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:r}}),t!=null)for(const[n,i]of t)this.set(n,i)}get(t){return super.get(F0(this,t))}has(t){return super.has(F0(this,t))}set(t,r){return super.set(z5(this,t),r)}delete(t){return super.delete(R5(this,t))}}function F0({_intern:e,_key:t},r){const n=t(r);return e.has(n)?e.get(n):r}function z5({_intern:e,_key:t},r){const n=t(r);return e.has(n)?e.get(n):(e.set(n,r),r)}function R5({_intern:e,_key:t},r){const n=t(r);return e.has(n)&&(r=e.get(n),e.delete(n)),r}function B5(e){return e!==null&&typeof e=="object"?e.valueOf():e}function F5(e=Mn){if(e===Mn)return uS;if(typeof e!="function")throw new TypeError("compare is not a function");return(t,r)=>{const n=e(t,r);return n||n===0?n:(e(r,r)===0)-(e(t,t)===0)}}function uS(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(et?1:0)}const W5=Math.sqrt(50),U5=Math.sqrt(10),q5=Math.sqrt(2);function sc(e,t,r){const n=(t-e)/Math.max(0,r),i=Math.floor(Math.log10(n)),s=n/Math.pow(10,i),o=s>=W5?10:s>=U5?5:s>=q5?2:1;let l,c,d;return i<0?(d=Math.pow(10,-i)/o,l=Math.round(e*d),c=Math.round(t*d),l/dt&&--c,d=-d):(d=Math.pow(10,i)*o,l=Math.round(e/d),c=Math.round(t/d),l*dt&&--c),c0))return[];if(e===t)return[e];const n=t=i))return[];const l=s-i+1,c=new Array(l);if(n)if(o<0)for(let d=0;d=n)&&(r=n);return r}function U0(e,t){let r;for(const n of e)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function dS(e,t,r=0,n=1/0,i){if(t=Math.floor(t),r=Math.floor(Math.max(0,r)),n=Math.floor(Math.min(e.length-1,n)),!(r<=t&&t<=n))return e;for(i=i===void 0?uS:F5(i);n>r;){if(n-r>600){const c=n-r+1,d=t-r+1,u=Math.log(c),f=.5*Math.exp(2*u/3),p=.5*Math.sqrt(u*f*(c-f)/c)*(d-c/2<0?-1:1),m=Math.max(r,Math.floor(t-d*f/c+p)),x=Math.min(n,Math.floor(t+(c-d)*f/c+p));dS(e,t,m,x,i)}const s=e[t];let o=r,l=n;for(Va(e,r,t),i(e[n],s)>0&&Va(e,r,n);o0;)--l}i(e[r],s)===0?Va(e,r,l):(++l,Va(e,l,n)),l<=t&&(r=l+1),t<=l&&(n=l-1)}return e}function Va(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function H5(e,t,r){if(e=Float64Array.from($5(e)),!(!(n=e.length)||isNaN(t=+t))){if(t<=0||n<2)return U0(e);if(t>=1)return W0(e);var n,i=(n-1)*t,s=Math.floor(i),o=W0(dS(e,s).subarray(0,s+1)),l=U0(e.subarray(s+1));return o+(l-o)*(i-s)}}function K5(e,t,r=cS){if(!(!(n=e.length)||isNaN(t=+t))){if(t<=0||n<2)return+r(e[0],0,e);if(t>=1)return+r(e[n-1],n-1,e);var n,i=(n-1)*t,s=Math.floor(i),o=+r(e[s],s,e),l=+r(e[s+1],s+1,e);return o+(l-o)*(i-s)}}function V5(e,t,r){e=+e,t=+t,r=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+r;for(var n=-1,i=Math.max(0,Math.ceil((t-e)/r))|0,s=new Array(i);++n>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?qo(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===4?qo(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Z5.exec(e))?new Nt(t[1],t[2],t[3],1):(t=X5.exec(e))?new Nt(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=J5.exec(e))?qo(t[1],t[2],t[3],t[4]):(t=Q5.exec(e))?qo(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=eD.exec(e))?Z0(t[1],t[2]/100,t[3]/100,1):(t=tD.exec(e))?Z0(t[1],t[2]/100,t[3]/100,t[4]):q0.hasOwnProperty(e)?V0(q0[e]):e==="transparent"?new Nt(NaN,NaN,NaN,0):null}function V0(e){return new Nt(e>>16&255,e>>8&255,e&255,1)}function qo(e,t,r,n){return n<=0&&(e=t=r=NaN),new Nt(e,t,r,n)}function iD(e){return e instanceof ao||(e=Ws(e)),e?(e=e.rgb(),new Nt(e.r,e.g,e.b,e.opacity)):new Nt}function lp(e,t,r,n){return arguments.length===1?iD(e):new Nt(e,t,r,n??1)}function Nt(e,t,r,n){this.r=+e,this.g=+t,this.b=+r,this.opacity=+n}lm(Nt,lp,pS(ao,{brighter(e){return e=e==null?oc:Math.pow(oc,e),new Nt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Bs:Math.pow(Bs,e),new Nt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Nt(ui(this.r),ui(this.g),ui(this.b),lc(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:Y0,formatHex:Y0,formatHex8:aD,formatRgb:G0,toString:G0}));function Y0(){return`#${ni(this.r)}${ni(this.g)}${ni(this.b)}`}function aD(){return`#${ni(this.r)}${ni(this.g)}${ni(this.b)}${ni((isNaN(this.opacity)?1:this.opacity)*255)}`}function G0(){const e=lc(this.opacity);return`${e===1?"rgb(":"rgba("}${ui(this.r)}, ${ui(this.g)}, ${ui(this.b)}${e===1?")":`, ${e})`}`}function lc(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ui(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ni(e){return e=ui(e),(e<16?"0":"")+e.toString(16)}function Z0(e,t,r,n){return n<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new pr(e,t,r,n)}function hS(e){if(e instanceof pr)return new pr(e.h,e.s,e.l,e.opacity);if(e instanceof ao||(e=Ws(e)),!e)return new pr;if(e instanceof pr)return e;e=e.rgb();var t=e.r/255,r=e.g/255,n=e.b/255,i=Math.min(t,r,n),s=Math.max(t,r,n),o=NaN,l=s-i,c=(s+i)/2;return l?(t===s?o=(r-n)/l+(r0&&c<1?0:o,new pr(o,l,c,e.opacity)}function sD(e,t,r,n){return arguments.length===1?hS(e):new pr(e,t,r,n??1)}function pr(e,t,r,n){this.h=+e,this.s=+t,this.l=+r,this.opacity=+n}lm(pr,sD,pS(ao,{brighter(e){return e=e==null?oc:Math.pow(oc,e),new pr(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Bs:Math.pow(Bs,e),new pr(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*t,i=2*r-n;return new Nt(wd(e>=240?e-240:e+120,i,n),wd(e,i,n),wd(e<120?e+240:e-120,i,n),this.opacity)},clamp(){return new pr(X0(this.h),Ho(this.s),Ho(this.l),lc(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 e=lc(this.opacity);return`${e===1?"hsl(":"hsla("}${X0(this.h)}, ${Ho(this.s)*100}%, ${Ho(this.l)*100}%${e===1?")":`, ${e})`}`}}));function X0(e){return e=(e||0)%360,e<0?e+360:e}function Ho(e){return Math.max(0,Math.min(1,e||0))}function wd(e,t,r){return(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)*255}const cm=e=>()=>e;function oD(e,t){return function(r){return e+r*t}}function lD(e,t,r){return e=Math.pow(e,r),t=Math.pow(t,r)-e,r=1/r,function(n){return Math.pow(e+n*t,r)}}function cD(e){return(e=+e)==1?mS:function(t,r){return r-t?lD(t,r,e):cm(isNaN(t)?r:t)}}function mS(e,t){var r=t-e;return r?oD(e,r):cm(isNaN(e)?t:e)}const J0=function e(t){var r=cD(t);function n(i,s){var o=r((i=lp(i)).r,(s=lp(s)).r),l=r(i.g,s.g),c=r(i.b,s.b),d=mS(i.opacity,s.opacity);return function(u){return i.r=o(u),i.g=l(u),i.b=c(u),i.opacity=d(u),i+""}}return n.gamma=e,n}(1);function uD(e,t){t||(t=[]);var r=e?Math.min(t.length,e.length):0,n=t.slice(),i;return function(s){for(i=0;ir&&(s=t.slice(r,s),l[o]?l[o]+=s:l[++o]=s),(n=n[0])===(i=i[0])?l[o]?l[o]+=i:l[++o]=i:(l[++o]=null,c.push({i:o,x:cc(n,i)})),r=Sd.lastIndex;return rt&&(r=e,e=t,t=r),function(n){return Math.max(e,Math.min(t,n))}}function jD(e,t,r){var n=e[0],i=e[1],s=t[0],o=t[1];return i2?wD:jD,c=d=null,f}function f(p){return p==null||isNaN(p=+p)?s:(c||(c=l(e.map(n),t,r)))(n(o(p)))}return f.invert=function(p){return o(i((d||(d=l(t,e.map(n),cc)))(p)))},f.domain=function(p){return arguments.length?(e=Array.from(p,uc),u()):e.slice()},f.range=function(p){return arguments.length?(t=Array.from(p),u()):t.slice()},f.rangeRound=function(p){return t=Array.from(p),r=um,u()},f.clamp=function(p){return arguments.length?(o=p?!0:mt,u()):o!==mt},f.interpolate=function(p){return arguments.length?(r=p,u()):r},f.unknown=function(p){return arguments.length?(s=p,f):s},function(p,m){return n=p,i=m,u()}}function dm(){return vu()(mt,mt)}function SD(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function dc(e,t){if((r=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var r,n=e.slice(0,r);return[n.length>1?n[0]+n.slice(2):n,+e.slice(r+1)]}function xa(e){return e=dc(Math.abs(e)),e?e[1]:NaN}function ND(e,t){return function(r,n){for(var i=r.length,s=[],o=0,l=e[0],c=0;i>0&&l>0&&(c+l+1>n&&(l=Math.max(1,n-c)),s.push(r.substring(i-=l,i+l)),!((c+=l+1)>n));)l=e[o=(o+1)%e.length];return s.reverse().join(t)}}function kD(e){return function(t){return t.replace(/[0-9]/g,function(r){return e[+r]})}}var _D=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Us(e){if(!(t=_D.exec(e)))throw new Error("invalid format: "+e);var t;return new fm({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}Us.prototype=fm.prototype;function fm(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}fm.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 PD(e){e:for(var t=e.length,r=1,n=-1,i;r0&&(n=0);break}return n>0?e.slice(0,n)+e.slice(i+1):e}var gS;function CD(e,t){var r=dc(e,t);if(!r)return e+"";var n=r[0],i=r[1],s=i-(gS=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=n.length;return s===o?n:s>o?n+new Array(s-o+1).join("0"):s>0?n.slice(0,s)+"."+n.slice(s):"0."+new Array(1-s).join("0")+dc(e,Math.max(0,t+s-1))[0]}function ey(e,t){var r=dc(e,t);if(!r)return e+"";var n=r[0],i=r[1];return i<0?"0."+new Array(-i).join("0")+n:n.length>i+1?n.slice(0,i+1)+"."+n.slice(i+1):n+new Array(i-n.length+2).join("0")}const ty={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:SD,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>ey(e*100,t),r:ey,s:CD,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function ry(e){return e}var ny=Array.prototype.map,iy=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function AD(e){var t=e.grouping===void 0||e.thousands===void 0?ry:ND(ny.call(e.grouping,Number),e.thousands+""),r=e.currency===void 0?"":e.currency[0]+"",n=e.currency===void 0?"":e.currency[1]+"",i=e.decimal===void 0?".":e.decimal+"",s=e.numerals===void 0?ry:kD(ny.call(e.numerals,String)),o=e.percent===void 0?"%":e.percent+"",l=e.minus===void 0?"−":e.minus+"",c=e.nan===void 0?"NaN":e.nan+"";function d(f){f=Us(f);var p=f.fill,m=f.align,x=f.sign,g=f.symbol,v=f.zero,b=f.width,j=f.comma,y=f.precision,w=f.trim,S=f.type;S==="n"?(j=!0,S="g"):ty[S]||(y===void 0&&(y=12),w=!0,S="g"),(v||p==="0"&&m==="=")&&(v=!0,p="0",m="=");var N=g==="$"?r:g==="#"&&/[boxX]/.test(S)?"0"+S.toLowerCase():"",P=g==="$"?n:/[%p]/.test(S)?o:"",C=ty[S],T=/[defgprs%]/.test(S);y=y===void 0?6:/[gprs]/.test(S)?Math.max(1,Math.min(21,y)):Math.max(0,Math.min(20,y));function $(I){var A=N,R=P,H,M,_;if(S==="c")R=C(I)+R,I="";else{I=+I;var D=I<0||1/I<0;if(I=isNaN(I)?c:C(Math.abs(I),y),w&&(I=PD(I)),D&&+I==0&&x!=="+"&&(D=!1),A=(D?x==="("?x:l:x==="-"||x==="("?"":x)+A,R=(S==="s"?iy[8+gS/3]:"")+R+(D&&x==="("?")":""),T){for(H=-1,M=I.length;++H_||_>57){R=(_===46?i+I.slice(H+1):I.slice(H))+R,I=I.slice(0,H);break}}}j&&!v&&(I=t(I,1/0));var O=A.length+I.length+R.length,k=O>1)+A+I+R+k.slice(O);break;default:I=k+A+I+R;break}return s(I)}return $.toString=function(){return f+""},$}function u(f,p){var m=d((f=Us(f),f.type="f",f)),x=Math.max(-8,Math.min(8,Math.floor(xa(p)/3)))*3,g=Math.pow(10,-x),v=iy[8+x/3];return function(b){return m(g*b)+v}}return{format:d,formatPrefix:u}}var Ko,pm,xS;OD({thousands:",",grouping:[3],currency:["$",""]});function OD(e){return Ko=AD(e),pm=Ko.format,xS=Ko.formatPrefix,Ko}function ED(e){return Math.max(0,-xa(Math.abs(e)))}function DD(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(xa(t)/3)))*3-xa(Math.abs(e)))}function TD(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,xa(t)-xa(e))+1}function yS(e,t,r,n){var i=sp(e,t,r),s;switch(n=Us(n??",f"),n.type){case"s":{var o=Math.max(Math.abs(e),Math.abs(t));return n.precision==null&&!isNaN(s=DD(i,o))&&(n.precision=s),xS(n,o)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(s=TD(i,Math.max(Math.abs(e),Math.abs(t))))&&(n.precision=s-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(s=ED(i))&&(n.precision=s-(n.type==="%")*2);break}}return pm(n)}function qn(e){var t=e.domain;return e.ticks=function(r){var n=t();return ip(n[0],n[n.length-1],r??10)},e.tickFormat=function(r,n){var i=t();return yS(i[0],i[i.length-1],r??10,n)},e.nice=function(r){r==null&&(r=10);var n=t(),i=0,s=n.length-1,o=n[i],l=n[s],c,d,u=10;for(l0;){if(d=ap(o,l,r),d===c)return n[i]=o,n[s]=l,t(n);if(d>0)o=Math.floor(o/d)*d,l=Math.ceil(l/d)*d;else if(d<0)o=Math.ceil(o*d)/d,l=Math.floor(l*d)/d;else break;c=d}return e},e}function vS(){var e=dm();return e.copy=function(){return so(e,vS())},or.apply(e,arguments),qn(e)}function bS(e){var t;function r(n){return n==null||isNaN(n=+n)?t:n}return r.invert=r,r.domain=r.range=function(n){return arguments.length?(e=Array.from(n,uc),r):e.slice()},r.unknown=function(n){return arguments.length?(t=n,r):t},r.copy=function(){return bS(e).unknown(t)},e=arguments.length?Array.from(e,uc):[0,1],qn(r)}function jS(e,t){e=e.slice();var r=0,n=e.length-1,i=e[r],s=e[n],o;return sMath.pow(e,t)}function zD(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function oy(e){return(t,r)=>-e(-t,r)}function hm(e){const t=e(ay,sy),r=t.domain;let n=10,i,s;function o(){return i=zD(n),s=LD(n),r()[0]<0?(i=oy(i),s=oy(s),e(MD,ID)):e(ay,sy),t}return t.base=function(l){return arguments.length?(n=+l,o()):n},t.domain=function(l){return arguments.length?(r(l),o()):r()},t.ticks=l=>{const c=r();let d=c[0],u=c[c.length-1];const f=u0){for(;p<=m;++p)for(x=1;xu)break;b.push(g)}}else for(;p<=m;++p)for(x=n-1;x>=1;--x)if(g=p>0?x/s(-p):x*s(p),!(gu)break;b.push(g)}b.length*2{if(l==null&&(l=10),c==null&&(c=n===10?"s":","),typeof c!="function"&&(!(n%1)&&(c=Us(c)).precision==null&&(c.trim=!0),c=pm(c)),l===1/0)return c;const d=Math.max(1,n*l/t.ticks().length);return u=>{let f=u/s(Math.round(i(u)));return f*nr(jS(r(),{floor:l=>s(Math.floor(i(l))),ceil:l=>s(Math.ceil(i(l)))})),t}function wS(){const e=hm(vu()).domain([1,10]);return e.copy=()=>so(e,wS()).base(e.base()),or.apply(e,arguments),e}function ly(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function cy(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function mm(e){var t=1,r=e(ly(t),cy(t));return r.constant=function(n){return arguments.length?e(ly(t=+n),cy(t)):t},qn(r)}function SS(){var e=mm(vu());return e.copy=function(){return so(e,SS()).constant(e.constant())},or.apply(e,arguments)}function uy(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function RD(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function BD(e){return e<0?-e*e:e*e}function gm(e){var t=e(mt,mt),r=1;function n(){return r===1?e(mt,mt):r===.5?e(RD,BD):e(uy(r),uy(1/r))}return t.exponent=function(i){return arguments.length?(r=+i,n()):r},qn(t)}function xm(){var e=gm(vu());return e.copy=function(){return so(e,xm()).exponent(e.exponent())},or.apply(e,arguments),e}function FD(){return xm.apply(null,arguments).exponent(.5)}function dy(e){return Math.sign(e)*e*e}function WD(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function NS(){var e=dm(),t=[0,1],r=!1,n;function i(s){var o=WD(e(s));return isNaN(o)?n:r?Math.round(o):o}return i.invert=function(s){return e.invert(dy(s))},i.domain=function(s){return arguments.length?(e.domain(s),i):e.domain()},i.range=function(s){return arguments.length?(e.range((t=Array.from(s,uc)).map(dy)),i):t.slice()},i.rangeRound=function(s){return i.range(s).round(!0)},i.round=function(s){return arguments.length?(r=!!s,i):r},i.clamp=function(s){return arguments.length?(e.clamp(s),i):e.clamp()},i.unknown=function(s){return arguments.length?(n=s,i):n},i.copy=function(){return NS(e.domain(),t).round(r).clamp(e.clamp()).unknown(n)},or.apply(i,arguments),qn(i)}function kS(){var e=[],t=[],r=[],n;function i(){var o=0,l=Math.max(1,t.length);for(r=new Array(l-1);++o0?r[l-1]:e[0],l=r?[n[r-1],t]:[n[d-1],n[d]]},o.unknown=function(c){return arguments.length&&(s=c),o},o.thresholds=function(){return n.slice()},o.copy=function(){return _S().domain([e,t]).range(i).unknown(s)},or.apply(qn(o),arguments)}function PS(){var e=[.5],t=[0,1],r,n=1;function i(s){return s!=null&&s<=s?t[io(e,s,0,n)]:r}return i.domain=function(s){return arguments.length?(e=Array.from(s),n=Math.min(e.length,t.length-1),i):e.slice()},i.range=function(s){return arguments.length?(t=Array.from(s),n=Math.min(e.length,t.length-1),i):t.slice()},i.invertExtent=function(s){var o=t.indexOf(s);return[e[o-1],e[o]]},i.unknown=function(s){return arguments.length?(r=s,i):r},i.copy=function(){return PS().domain(e).range(t).unknown(r)},or.apply(i,arguments)}const Nd=new Date,kd=new Date;function Be(e,t,r,n){function i(s){return e(s=arguments.length===0?new Date:new Date(+s)),s}return i.floor=s=>(e(s=new Date(+s)),s),i.ceil=s=>(e(s=new Date(s-1)),t(s,1),e(s),s),i.round=s=>{const o=i(s),l=i.ceil(s);return s-o(t(s=new Date(+s),o==null?1:Math.floor(o)),s),i.range=(s,o,l)=>{const c=[];if(s=i.ceil(s),l=l==null?1:Math.floor(l),!(s0))return c;let d;do c.push(d=new Date(+s)),t(s,l),e(s);while(dBe(o=>{if(o>=o)for(;e(o),!s(o);)o.setTime(o-1)},(o,l)=>{if(o>=o)if(l<0)for(;++l<=0;)for(;t(o,-1),!s(o););else for(;--l>=0;)for(;t(o,1),!s(o););}),r&&(i.count=(s,o)=>(Nd.setTime(+s),kd.setTime(+o),e(Nd),e(kd),Math.floor(r(Nd,kd))),i.every=s=>(s=Math.floor(s),!isFinite(s)||!(s>0)?null:s>1?i.filter(n?o=>n(o)%s===0:o=>i.count(0,o)%s===0):i)),i}const fc=Be(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);fc.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?Be(t=>{t.setTime(Math.floor(t/e)*e)},(t,r)=>{t.setTime(+t+r*e)},(t,r)=>(r-t)/e):fc);fc.range;const Wr=1e3,Qt=Wr*60,Ur=Qt*60,tn=Ur*24,ym=tn*7,fy=tn*30,_d=tn*365,ii=Be(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*Wr)},(e,t)=>(t-e)/Wr,e=>e.getUTCSeconds());ii.range;const vm=Be(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Wr)},(e,t)=>{e.setTime(+e+t*Qt)},(e,t)=>(t-e)/Qt,e=>e.getMinutes());vm.range;const bm=Be(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*Qt)},(e,t)=>(t-e)/Qt,e=>e.getUTCMinutes());bm.range;const jm=Be(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Wr-e.getMinutes()*Qt)},(e,t)=>{e.setTime(+e+t*Ur)},(e,t)=>(t-e)/Ur,e=>e.getHours());jm.range;const wm=Be(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*Ur)},(e,t)=>(t-e)/Ur,e=>e.getUTCHours());wm.range;const oo=Be(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Qt)/tn,e=>e.getDate()-1);oo.range;const bu=Be(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/tn,e=>e.getUTCDate()-1);bu.range;const CS=Be(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/tn,e=>Math.floor(e/tn));CS.range;function Ai(e){return Be(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(t,r)=>{t.setDate(t.getDate()+r*7)},(t,r)=>(r-t-(r.getTimezoneOffset()-t.getTimezoneOffset())*Qt)/ym)}const ju=Ai(0),pc=Ai(1),UD=Ai(2),qD=Ai(3),ya=Ai(4),HD=Ai(5),KD=Ai(6);ju.range;pc.range;UD.range;qD.range;ya.range;HD.range;KD.range;function Oi(e){return Be(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(t,r)=>{t.setUTCDate(t.getUTCDate()+r*7)},(t,r)=>(r-t)/ym)}const wu=Oi(0),hc=Oi(1),VD=Oi(2),YD=Oi(3),va=Oi(4),GD=Oi(5),ZD=Oi(6);wu.range;hc.range;VD.range;YD.range;va.range;GD.range;ZD.range;const Sm=Be(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());Sm.range;const Nm=Be(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());Nm.range;const rn=Be(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());rn.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Be(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,r)=>{t.setFullYear(t.getFullYear()+r*e)});rn.range;const nn=Be(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());nn.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Be(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,r)=>{t.setUTCFullYear(t.getUTCFullYear()+r*e)});nn.range;function AS(e,t,r,n,i,s){const o=[[ii,1,Wr],[ii,5,5*Wr],[ii,15,15*Wr],[ii,30,30*Wr],[s,1,Qt],[s,5,5*Qt],[s,15,15*Qt],[s,30,30*Qt],[i,1,Ur],[i,3,3*Ur],[i,6,6*Ur],[i,12,12*Ur],[n,1,tn],[n,2,2*tn],[r,1,ym],[t,1,fy],[t,3,3*fy],[e,1,_d]];function l(d,u,f){const p=uv).right(o,p);if(m===o.length)return e.every(sp(d/_d,u/_d,f));if(m===0)return fc.every(Math.max(sp(d,u,f),1));const[x,g]=o[p/o[m-1][2]53)return null;"w"in q||(q.w=1),"Z"in q?(pe=Cd(Ya(q.y,0,1)),Et=pe.getUTCDay(),pe=Et>4||Et===0?hc.ceil(pe):hc(pe),pe=bu.offset(pe,(q.V-1)*7),q.y=pe.getUTCFullYear(),q.m=pe.getUTCMonth(),q.d=pe.getUTCDate()+(q.w+6)%7):(pe=Pd(Ya(q.y,0,1)),Et=pe.getDay(),pe=Et>4||Et===0?pc.ceil(pe):pc(pe),pe=oo.offset(pe,(q.V-1)*7),q.y=pe.getFullYear(),q.m=pe.getMonth(),q.d=pe.getDate()+(q.w+6)%7)}else("W"in q||"U"in q)&&("w"in q||(q.w="u"in q?q.u%7:"W"in q?1:0),Et="Z"in q?Cd(Ya(q.y,0,1)).getUTCDay():Pd(Ya(q.y,0,1)).getDay(),q.m=0,q.d="W"in q?(q.w+6)%7+q.W*7-(Et+5)%7:q.w+q.U*7-(Et+6)%7);return"Z"in q?(q.H+=q.Z/100|0,q.M+=q.Z%100,Cd(q)):Pd(q)}}function C(F,te,ne,q){for(var bt=0,pe=te.length,Et=ne.length,Dt,Yn;bt=Et)return-1;if(Dt=te.charCodeAt(bt++),Dt===37){if(Dt=te.charAt(bt++),Yn=S[Dt in py?te.charAt(bt++):Dt],!Yn||(q=Yn(F,ne,q))<0)return-1}else if(Dt!=ne.charCodeAt(q++))return-1}return q}function T(F,te,ne){var q=d.exec(te.slice(ne));return q?(F.p=u.get(q[0].toLowerCase()),ne+q[0].length):-1}function $(F,te,ne){var q=m.exec(te.slice(ne));return q?(F.w=x.get(q[0].toLowerCase()),ne+q[0].length):-1}function I(F,te,ne){var q=f.exec(te.slice(ne));return q?(F.w=p.get(q[0].toLowerCase()),ne+q[0].length):-1}function A(F,te,ne){var q=b.exec(te.slice(ne));return q?(F.m=j.get(q[0].toLowerCase()),ne+q[0].length):-1}function R(F,te,ne){var q=g.exec(te.slice(ne));return q?(F.m=v.get(q[0].toLowerCase()),ne+q[0].length):-1}function H(F,te,ne){return C(F,t,te,ne)}function M(F,te,ne){return C(F,r,te,ne)}function _(F,te,ne){return C(F,n,te,ne)}function D(F){return o[F.getDay()]}function O(F){return s[F.getDay()]}function k(F){return c[F.getMonth()]}function z(F){return l[F.getMonth()]}function W(F){return i[+(F.getHours()>=12)]}function K(F){return 1+~~(F.getMonth()/3)}function ee(F){return o[F.getUTCDay()]}function re(F){return s[F.getUTCDay()]}function Me(F){return c[F.getUTCMonth()]}function E(F){return l[F.getUTCMonth()]}function Q(F){return i[+(F.getUTCHours()>=12)]}function Ot(F){return 1+~~(F.getUTCMonth()/3)}return{format:function(F){var te=N(F+="",y);return te.toString=function(){return F},te},parse:function(F){var te=P(F+="",!1);return te.toString=function(){return F},te},utcFormat:function(F){var te=N(F+="",w);return te.toString=function(){return F},te},utcParse:function(F){var te=P(F+="",!0);return te.toString=function(){return F},te}}}var py={"-":"",_:" ",0:"0"},Ge=/^\s*\d+/,rT=/^%/,nT=/[\\^$*+?|[\]().{}]/g;function se(e,t,r){var n=e<0?"-":"",i=(n?-e:e)+"",s=i.length;return n+(s[t.toLowerCase(),r]))}function aT(e,t,r){var n=Ge.exec(t.slice(r,r+1));return n?(e.w=+n[0],r+n[0].length):-1}function sT(e,t,r){var n=Ge.exec(t.slice(r,r+1));return n?(e.u=+n[0],r+n[0].length):-1}function oT(e,t,r){var n=Ge.exec(t.slice(r,r+2));return n?(e.U=+n[0],r+n[0].length):-1}function lT(e,t,r){var n=Ge.exec(t.slice(r,r+2));return n?(e.V=+n[0],r+n[0].length):-1}function cT(e,t,r){var n=Ge.exec(t.slice(r,r+2));return n?(e.W=+n[0],r+n[0].length):-1}function hy(e,t,r){var n=Ge.exec(t.slice(r,r+4));return n?(e.y=+n[0],r+n[0].length):-1}function my(e,t,r){var n=Ge.exec(t.slice(r,r+2));return n?(e.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function uT(e,t,r){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(r,r+6));return n?(e.Z=n[1]?0:-(n[2]+(n[3]||"00")),r+n[0].length):-1}function dT(e,t,r){var n=Ge.exec(t.slice(r,r+1));return n?(e.q=n[0]*3-3,r+n[0].length):-1}function fT(e,t,r){var n=Ge.exec(t.slice(r,r+2));return n?(e.m=n[0]-1,r+n[0].length):-1}function gy(e,t,r){var n=Ge.exec(t.slice(r,r+2));return n?(e.d=+n[0],r+n[0].length):-1}function pT(e,t,r){var n=Ge.exec(t.slice(r,r+3));return n?(e.m=0,e.d=+n[0],r+n[0].length):-1}function xy(e,t,r){var n=Ge.exec(t.slice(r,r+2));return n?(e.H=+n[0],r+n[0].length):-1}function hT(e,t,r){var n=Ge.exec(t.slice(r,r+2));return n?(e.M=+n[0],r+n[0].length):-1}function mT(e,t,r){var n=Ge.exec(t.slice(r,r+2));return n?(e.S=+n[0],r+n[0].length):-1}function gT(e,t,r){var n=Ge.exec(t.slice(r,r+3));return n?(e.L=+n[0],r+n[0].length):-1}function xT(e,t,r){var n=Ge.exec(t.slice(r,r+6));return n?(e.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function yT(e,t,r){var n=rT.exec(t.slice(r,r+1));return n?r+n[0].length:-1}function vT(e,t,r){var n=Ge.exec(t.slice(r));return n?(e.Q=+n[0],r+n[0].length):-1}function bT(e,t,r){var n=Ge.exec(t.slice(r));return n?(e.s=+n[0],r+n[0].length):-1}function yy(e,t){return se(e.getDate(),t,2)}function jT(e,t){return se(e.getHours(),t,2)}function wT(e,t){return se(e.getHours()%12||12,t,2)}function ST(e,t){return se(1+oo.count(rn(e),e),t,3)}function OS(e,t){return se(e.getMilliseconds(),t,3)}function NT(e,t){return OS(e,t)+"000"}function kT(e,t){return se(e.getMonth()+1,t,2)}function _T(e,t){return se(e.getMinutes(),t,2)}function PT(e,t){return se(e.getSeconds(),t,2)}function CT(e){var t=e.getDay();return t===0?7:t}function AT(e,t){return se(ju.count(rn(e)-1,e),t,2)}function ES(e){var t=e.getDay();return t>=4||t===0?ya(e):ya.ceil(e)}function OT(e,t){return e=ES(e),se(ya.count(rn(e),e)+(rn(e).getDay()===4),t,2)}function ET(e){return e.getDay()}function DT(e,t){return se(pc.count(rn(e)-1,e),t,2)}function TT(e,t){return se(e.getFullYear()%100,t,2)}function MT(e,t){return e=ES(e),se(e.getFullYear()%100,t,2)}function IT(e,t){return se(e.getFullYear()%1e4,t,4)}function $T(e,t){var r=e.getDay();return e=r>=4||r===0?ya(e):ya.ceil(e),se(e.getFullYear()%1e4,t,4)}function LT(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+se(t/60|0,"0",2)+se(t%60,"0",2)}function vy(e,t){return se(e.getUTCDate(),t,2)}function zT(e,t){return se(e.getUTCHours(),t,2)}function RT(e,t){return se(e.getUTCHours()%12||12,t,2)}function BT(e,t){return se(1+bu.count(nn(e),e),t,3)}function DS(e,t){return se(e.getUTCMilliseconds(),t,3)}function FT(e,t){return DS(e,t)+"000"}function WT(e,t){return se(e.getUTCMonth()+1,t,2)}function UT(e,t){return se(e.getUTCMinutes(),t,2)}function qT(e,t){return se(e.getUTCSeconds(),t,2)}function HT(e){var t=e.getUTCDay();return t===0?7:t}function KT(e,t){return se(wu.count(nn(e)-1,e),t,2)}function TS(e){var t=e.getUTCDay();return t>=4||t===0?va(e):va.ceil(e)}function VT(e,t){return e=TS(e),se(va.count(nn(e),e)+(nn(e).getUTCDay()===4),t,2)}function YT(e){return e.getUTCDay()}function GT(e,t){return se(hc.count(nn(e)-1,e),t,2)}function ZT(e,t){return se(e.getUTCFullYear()%100,t,2)}function XT(e,t){return e=TS(e),se(e.getUTCFullYear()%100,t,2)}function JT(e,t){return se(e.getUTCFullYear()%1e4,t,4)}function QT(e,t){var r=e.getUTCDay();return e=r>=4||r===0?va(e):va.ceil(e),se(e.getUTCFullYear()%1e4,t,4)}function eM(){return"+0000"}function by(){return"%"}function jy(e){return+e}function wy(e){return Math.floor(+e/1e3)}var Di,MS,IS;tM({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 tM(e){return Di=tT(e),MS=Di.format,Di.parse,IS=Di.utcFormat,Di.utcParse,Di}function rM(e){return new Date(e)}function nM(e){return e instanceof Date?+e:+new Date(+e)}function km(e,t,r,n,i,s,o,l,c,d){var u=dm(),f=u.invert,p=u.domain,m=d(".%L"),x=d(":%S"),g=d("%I:%M"),v=d("%I %p"),b=d("%a %d"),j=d("%b %d"),y=d("%B"),w=d("%Y");function S(N){return(c(N)t(i/(e.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(i,s)=>H5(e,s/n))},r.copy=function(){return RS(t).domain(e)},un.apply(r,arguments)}function Nu(){var e=0,t=.5,r=1,n=1,i,s,o,l,c,d=mt,u,f=!1,p;function m(g){return isNaN(g=+g)?p:(g=.5+((g=+u(g))-s)*(n*ge.chartData,lM=L([Kn],e=>{var t=e.chartData!=null?e.chartData.length-1:0;return{chartData:e.chartData,computedData:e.computedData,dataEndIndex:t,dataStartIndex:0}}),ku=(e,t,r,n)=>n?lM(e):Kn(e);function ji(e){if(Array.isArray(e)&&e.length===2){var[t,r]=e;if(_e(t)&&_e(r))return!0}return!1}function Sy(e,t,r){return r?e:[Math.min(e[0],t[0]),Math.max(e[1],t[1])]}function US(e,t){if(t&&typeof e!="function"&&Array.isArray(e)&&e.length===2){var[r,n]=e,i,s;if(_e(r))i=r;else if(typeof r=="function")return;if(_e(n))s=n;else if(typeof n=="function")return;var o=[i,s];if(ji(o))return o}}function cM(e,t,r){if(!(!r&&t==null)){if(typeof e=="function"&&t!=null)try{var n=e(t,r);if(ji(n))return Sy(n,t,r)}catch{}if(Array.isArray(e)&&e.length===2){var[i,s]=e,o,l;if(i==="auto")t!=null&&(o=Math.min(...t));else if(G(i))o=i;else if(typeof i=="function")try{t!=null&&(o=i(t==null?void 0:t[0]))}catch{}else if(typeof i=="string"&&f0.test(i)){var c=f0.exec(i);if(c==null||t==null)o=void 0;else{var d=+c[1];o=t[0]-d}}else o=t==null?void 0:t[0];if(s==="auto")t!=null&&(l=Math.max(...t));else if(G(s))l=s;else if(typeof s=="function")try{t!=null&&(l=s(t==null?void 0:t[1]))}catch{}else if(typeof s=="string"&&p0.test(s)){var u=p0.exec(s);if(u==null||t==null)l=void 0;else{var f=+u[1];l=t[1]+f}}else l=t==null?void 0:t[1];var p=[o,l];if(ji(p))return t==null?p:Sy(p,t,r)}}}var Aa=1e9,uM={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},Am,je=!0,sr="[DecimalError] ",di=sr+"Invalid argument: ",Cm=sr+"Exponent out of range: ",Oa=Math.floor,Qn=Math.pow,dM=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Lt,He=1e7,ye=7,qS=9007199254740991,mc=Oa(qS/ye),Y={};Y.absoluteValue=Y.abs=function(){var e=new this.constructor(this);return e.s&&(e.s=1),e};Y.comparedTo=Y.cmp=function(e){var t,r,n,i,s=this;if(e=new s.constructor(e),s.s!==e.s)return s.s||-e.s;if(s.e!==e.e)return s.e>e.e^s.s<0?1:-1;for(n=s.d.length,i=e.d.length,t=0,r=ne.d[t]^s.s<0?1:-1;return n===i?0:n>i^s.s<0?1:-1};Y.decimalPlaces=Y.dp=function(){var e=this,t=e.d.length-1,r=(t-e.e)*ye;if(t=e.d[t],t)for(;t%10==0;t/=10)r--;return r<0?0:r};Y.dividedBy=Y.div=function(e){return Vr(this,new this.constructor(e))};Y.dividedToIntegerBy=Y.idiv=function(e){var t=this,r=t.constructor;return fe(Vr(t,new r(e),0,1),r.precision)};Y.equals=Y.eq=function(e){return!this.cmp(e)};Y.exponent=function(){return Te(this)};Y.greaterThan=Y.gt=function(e){return this.cmp(e)>0};Y.greaterThanOrEqualTo=Y.gte=function(e){return this.cmp(e)>=0};Y.isInteger=Y.isint=function(){return this.e>this.d.length-2};Y.isNegative=Y.isneg=function(){return this.s<0};Y.isPositive=Y.ispos=function(){return this.s>0};Y.isZero=function(){return this.s===0};Y.lessThan=Y.lt=function(e){return this.cmp(e)<0};Y.lessThanOrEqualTo=Y.lte=function(e){return this.cmp(e)<1};Y.logarithm=Y.log=function(e){var t,r=this,n=r.constructor,i=n.precision,s=i+5;if(e===void 0)e=new n(10);else if(e=new n(e),e.s<1||e.eq(Lt))throw Error(sr+"NaN");if(r.s<1)throw Error(sr+(r.s?"NaN":"-Infinity"));return r.eq(Lt)?new n(0):(je=!1,t=Vr(qs(r,s),qs(e,s),s),je=!0,fe(t,i))};Y.minus=Y.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?VS(t,e):HS(t,(e.s=-e.s,e))};Y.modulo=Y.mod=function(e){var t,r=this,n=r.constructor,i=n.precision;if(e=new n(e),!e.s)throw Error(sr+"NaN");return r.s?(je=!1,t=Vr(r,e,0,1).times(e),je=!0,r.minus(t)):fe(new n(r),i)};Y.naturalExponential=Y.exp=function(){return KS(this)};Y.naturalLogarithm=Y.ln=function(){return qs(this)};Y.negated=Y.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e};Y.plus=Y.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?HS(t,e):VS(t,(e.s=-e.s,e))};Y.precision=Y.sd=function(e){var t,r,n,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(di+e);if(t=Te(i)+1,n=i.d.length-1,r=n*ye+1,n=i.d[n],n){for(;n%10==0;n/=10)r--;for(n=i.d[0];n>=10;n/=10)r++}return e&&t>r?t:r};Y.squareRoot=Y.sqrt=function(){var e,t,r,n,i,s,o,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(sr+"NaN")}for(e=Te(l),je=!1,i=Math.sqrt(+l),i==0||i==1/0?(t=Nr(l.d),(t.length+e)%2==0&&(t+="0"),i=Math.sqrt(t),e=Oa((e+1)/2)-(e<0||e%2),i==1/0?t="5e"+e:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),n=new c(t)):n=new c(i.toString()),r=c.precision,i=o=r+3;;)if(s=n,n=s.plus(Vr(l,s,o+2)).times(.5),Nr(s.d).slice(0,o)===(t=Nr(n.d)).slice(0,o)){if(t=t.slice(o-3,o+1),i==o&&t=="4999"){if(fe(s,r+1,0),s.times(s).eq(l)){n=s;break}}else if(t!="9999")break;o+=4}return je=!0,fe(n,r)};Y.times=Y.mul=function(e){var t,r,n,i,s,o,l,c,d,u=this,f=u.constructor,p=u.d,m=(e=new f(e)).d;if(!u.s||!e.s)return new f(0);for(e.s*=u.s,r=u.e+e.e,c=p.length,d=m.length,c=0;){for(t=0,i=c+n;i>n;)l=s[i]+m[n]*p[i-n-1]+t,s[i--]=l%He|0,t=l/He|0;s[i]=(s[i]+t)%He|0}for(;!s[--o];)s.pop();return t?++r:s.shift(),e.d=s,e.e=r,je?fe(e,f.precision):e};Y.toDecimalPlaces=Y.todp=function(e,t){var r=this,n=r.constructor;return r=new n(r),e===void 0?r:(Dr(e,0,Aa),t===void 0?t=n.rounding:Dr(t,0,8),fe(r,e+Te(r)+1,t))};Y.toExponential=function(e,t){var r,n=this,i=n.constructor;return e===void 0?r=wi(n,!0):(Dr(e,0,Aa),t===void 0?t=i.rounding:Dr(t,0,8),n=fe(new i(n),e+1,t),r=wi(n,!0,e+1)),r};Y.toFixed=function(e,t){var r,n,i=this,s=i.constructor;return e===void 0?wi(i):(Dr(e,0,Aa),t===void 0?t=s.rounding:Dr(t,0,8),n=fe(new s(i),e+Te(i)+1,t),r=wi(n.abs(),!1,e+Te(n)+1),i.isneg()&&!i.isZero()?"-"+r:r)};Y.toInteger=Y.toint=function(){var e=this,t=e.constructor;return fe(new t(e),Te(e)+1,t.rounding)};Y.toNumber=function(){return+this};Y.toPower=Y.pow=function(e){var t,r,n,i,s,o,l=this,c=l.constructor,d=12,u=+(e=new c(e));if(!e.s)return new c(Lt);if(l=new c(l),!l.s){if(e.s<1)throw Error(sr+"Infinity");return l}if(l.eq(Lt))return l;if(n=c.precision,e.eq(Lt))return fe(l,n);if(t=e.e,r=e.d.length-1,o=t>=r,s=l.s,o){if((r=u<0?-u:u)<=qS){for(i=new c(Lt),t=Math.ceil(n/ye+4),je=!1;r%2&&(i=i.times(l),ky(i.d,t)),r=Oa(r/2),r!==0;)l=l.times(l),ky(l.d,t);return je=!0,e.s<0?new c(Lt).div(i):fe(i,n)}}else if(s<0)throw Error(sr+"NaN");return s=s<0&&e.d[Math.max(t,r)]&1?-1:1,l.s=1,je=!1,i=e.times(qs(l,n+d)),je=!0,i=KS(i),i.s=s,i};Y.toPrecision=function(e,t){var r,n,i=this,s=i.constructor;return e===void 0?(r=Te(i),n=wi(i,r<=s.toExpNeg||r>=s.toExpPos)):(Dr(e,1,Aa),t===void 0?t=s.rounding:Dr(t,0,8),i=fe(new s(i),e,t),r=Te(i),n=wi(i,e<=r||r<=s.toExpNeg,e)),n};Y.toSignificantDigits=Y.tosd=function(e,t){var r=this,n=r.constructor;return e===void 0?(e=n.precision,t=n.rounding):(Dr(e,1,Aa),t===void 0?t=n.rounding:Dr(t,0,8)),fe(new n(r),e,t)};Y.toString=Y.valueOf=Y.val=Y.toJSON=Y[Symbol.for("nodejs.util.inspect.custom")]=function(){var e=this,t=Te(e),r=e.constructor;return wi(e,t<=r.toExpNeg||t>=r.toExpPos)};function HS(e,t){var r,n,i,s,o,l,c,d,u=e.constructor,f=u.precision;if(!e.s||!t.s)return t.s||(t=new u(e)),je?fe(t,f):t;if(c=e.d,d=t.d,o=e.e,i=t.e,c=c.slice(),s=o-i,s){for(s<0?(n=c,s=-s,l=d.length):(n=d,i=o,l=c.length),o=Math.ceil(f/ye),l=o>l?o+1:l+1,s>l&&(s=l,n.length=1),n.reverse();s--;)n.push(0);n.reverse()}for(l=c.length,s=d.length,l-s<0&&(s=l,n=d,d=c,c=n),r=0;s;)r=(c[--s]=c[s]+d[s]+r)/He|0,c[s]%=He;for(r&&(c.unshift(r),++i),l=c.length;c[--l]==0;)c.pop();return t.d=c,t.e=i,je?fe(t,f):t}function Dr(e,t,r){if(e!==~~e||er)throw Error(di+e)}function Nr(e){var t,r,n,i=e.length-1,s="",o=e[0];if(i>0){for(s+=o,t=1;to?1:-1;else for(l=c=0;li[l]?1:-1;break}return c}function r(n,i,s){for(var o=0;s--;)n[s]-=o,o=n[s]1;)n.shift()}return function(n,i,s,o){var l,c,d,u,f,p,m,x,g,v,b,j,y,w,S,N,P,C,T=n.constructor,$=n.s==i.s?1:-1,I=n.d,A=i.d;if(!n.s)return new T(n);if(!i.s)throw Error(sr+"Division by zero");for(c=n.e-i.e,P=A.length,S=I.length,m=new T($),x=m.d=[],d=0;A[d]==(I[d]||0);)++d;if(A[d]>(I[d]||0)&&--c,s==null?j=s=T.precision:o?j=s+(Te(n)-Te(i))+1:j=s,j<0)return new T(0);if(j=j/ye+2|0,d=0,P==1)for(u=0,A=A[0],j++;(d1&&(A=e(A,u),I=e(I,u),P=A.length,S=I.length),w=P,g=I.slice(0,P),v=g.length;v=He/2&&++N;do u=0,l=t(A,g,P,v),l<0?(b=g[0],P!=v&&(b=b*He+(g[1]||0)),u=b/N|0,u>1?(u>=He&&(u=He-1),f=e(A,u),p=f.length,v=g.length,l=t(f,g,p,v),l==1&&(u--,r(f,P16)throw Error(Cm+Te(e));if(!e.s)return new u(Lt);for(je=!1,l=f,o=new u(.03125);e.abs().gte(.1);)e=e.times(o),d+=5;for(n=Math.log(Qn(2,d))/Math.LN10*2+5|0,l+=n,r=i=s=new u(Lt),u.precision=l;;){if(i=fe(i.times(e),l),r=r.times(++c),o=s.plus(Vr(i,r,l)),Nr(o.d).slice(0,l)===Nr(s.d).slice(0,l)){for(;d--;)s=fe(s.times(s),l);return u.precision=f,t==null?(je=!0,fe(s,f)):s}s=o}}function Te(e){for(var t=e.e*ye,r=e.d[0];r>=10;r/=10)t++;return t}function Ad(e,t,r){if(t>e.LN10.sd())throw je=!0,r&&(e.precision=r),Error(sr+"LN10 precision limit exceeded");return fe(new e(e.LN10),t)}function xn(e){for(var t="";e--;)t+="0";return t}function qs(e,t){var r,n,i,s,o,l,c,d,u,f=1,p=10,m=e,x=m.d,g=m.constructor,v=g.precision;if(m.s<1)throw Error(sr+(m.s?"NaN":"-Infinity"));if(m.eq(Lt))return new g(0);if(t==null?(je=!1,d=v):d=t,m.eq(10))return t==null&&(je=!0),Ad(g,d);if(d+=p,g.precision=d,r=Nr(x),n=r.charAt(0),s=Te(m),Math.abs(s)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)m=m.times(e),r=Nr(m.d),n=r.charAt(0),f++;s=Te(m),n>1?(m=new g("0."+r),s++):m=new g(n+"."+r.slice(1))}else return c=Ad(g,d+2,v).times(s+""),m=qs(new g(n+"."+r.slice(1)),d-p).plus(c),g.precision=v,t==null?(je=!0,fe(m,v)):m;for(l=o=m=Vr(m.minus(Lt),m.plus(Lt),d),u=fe(m.times(m),d),i=3;;){if(o=fe(o.times(u),d),c=l.plus(Vr(o,new g(i),d)),Nr(c.d).slice(0,d)===Nr(l.d).slice(0,d))return l=l.times(2),s!==0&&(l=l.plus(Ad(g,d+2,v).times(s+""))),l=Vr(l,new g(f),d),g.precision=v,t==null?(je=!0,fe(l,v)):l;l=c,i+=2}}function Ny(e,t){var r,n,i;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;t.charCodeAt(n)===48;)++n;for(i=t.length;t.charCodeAt(i-1)===48;)--i;if(t=t.slice(n,i),t){if(i-=n,r=r-n-1,e.e=Oa(r/ye),e.d=[],n=(r+1)%ye,r<0&&(n+=ye),nmc||e.e<-mc))throw Error(Cm+r)}else e.s=0,e.e=0,e.d=[0];return e}function fe(e,t,r){var n,i,s,o,l,c,d,u,f=e.d;for(o=1,s=f[0];s>=10;s/=10)o++;if(n=t-o,n<0)n+=ye,i=t,d=f[u=0];else{if(u=Math.ceil((n+1)/ye),s=f.length,u>=s)return e;for(d=s=f[u],o=1;s>=10;s/=10)o++;n%=ye,i=n-ye+o}if(r!==void 0&&(s=Qn(10,o-i-1),l=d/s%10|0,c=t<0||f[u+1]!==void 0||d%s,c=r<4?(l||c)&&(r==0||r==(e.s<0?3:2)):l>5||l==5&&(r==4||c||r==6&&(n>0?i>0?d/Qn(10,o-i):0:f[u-1])%10&1||r==(e.s<0?8:7))),t<1||!f[0])return c?(s=Te(e),f.length=1,t=t-s-1,f[0]=Qn(10,(ye-t%ye)%ye),e.e=Oa(-t/ye)||0):(f.length=1,f[0]=e.e=e.s=0),e;if(n==0?(f.length=u,s=1,u--):(f.length=u+1,s=Qn(10,ye-n),f[u]=i>0?(d/Qn(10,o-i)%Qn(10,i)|0)*s:0),c)for(;;)if(u==0){(f[0]+=s)==He&&(f[0]=1,++e.e);break}else{if(f[u]+=s,f[u]!=He)break;f[u--]=0,s=1}for(n=f.length;f[--n]===0;)f.pop();if(je&&(e.e>mc||e.e<-mc))throw Error(Cm+Te(e));return e}function VS(e,t){var r,n,i,s,o,l,c,d,u,f,p=e.constructor,m=p.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new p(e),je?fe(t,m):t;if(c=e.d,f=t.d,n=t.e,d=e.e,c=c.slice(),o=d-n,o){for(u=o<0,u?(r=c,o=-o,l=f.length):(r=f,n=d,l=c.length),i=Math.max(Math.ceil(m/ye),l)+2,o>i&&(o=i,r.length=1),r.reverse(),i=o;i--;)r.push(0);r.reverse()}else{for(i=c.length,l=f.length,u=i0;--i)c[l++]=0;for(i=f.length;i>o;){if(c[--i]0?s=s.charAt(0)+"."+s.slice(1)+xn(n):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i<0?"e":"e+")+i):i<0?(s="0."+xn(-i-1)+s,r&&(n=r-o)>0&&(s+=xn(n))):i>=o?(s+=xn(i+1-o),r&&(n=r-i-1)>0&&(s=s+"."+xn(n))):((n=i+1)0&&(i+1===o&&(s+="."),s+=xn(n))),e.s<0?"-"+s:s}function ky(e,t){if(e.length>t)return e.length=t,!0}function YS(e){var t,r,n;function i(s){var o=this;if(!(o instanceof i))return new i(s);if(o.constructor=i,s instanceof i){o.s=s.s,o.e=s.e,o.d=(s=s.d)?s.slice():s;return}if(typeof s=="number"){if(s*0!==0)throw Error(di+s);if(s>0)o.s=1;else if(s<0)s=-s,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(s===~~s&&s<1e7){o.e=0,o.d=[s];return}return Ny(o,s.toString())}else if(typeof s!="string")throw Error(di+s);if(s.charCodeAt(0)===45?(s=s.slice(1),o.s=-1):o.s=1,dM.test(s))Ny(o,s);else throw Error(di+s)}if(i.prototype=Y,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=YS,i.config=i.set=fM,e===void 0&&(e={}),e)for(n=["precision","rounding","toExpNeg","toExpPos","LN10"],t=0;t=i[t+1]&&n<=i[t+2])this[r]=n;else throw Error(di+r+": "+n);if((n=e[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(di+r+": "+n);return this}var Am=YS(uM);Lt=new Am(1);const le=Am;var pM=e=>e,GS={},ZS=e=>e===GS,_y=e=>function t(){return arguments.length===0||arguments.length===1&&ZS(arguments.length<=0?void 0:arguments[0])?t:e(...arguments)},XS=(e,t)=>e===1?t:_y(function(){for(var r=arguments.length,n=new Array(r),i=0;io!==GS).length;return s>=e?t(...n):XS(e-s,_y(function(){for(var o=arguments.length,l=new Array(o),c=0;cZS(u)?l.shift():u);return t(...d,...l)}))}),_u=e=>XS(e.length,e),dp=(e,t)=>{for(var r=[],n=e;nArray.isArray(t)?t.map(e):Object.keys(t).map(r=>t[r]).map(e)),mM=function(){for(var t=arguments.length,r=new Array(t),n=0;nc(l),s(...arguments))}},fp=e=>Array.isArray(e)?e.reverse():e.split("").reverse().join(""),JS=e=>{var t=null,r=null;return function(){for(var n=arguments.length,i=new Array(n),s=0;s{var c;return o===((c=t)===null||c===void 0?void 0:c[l])})||(t=i,r=e(...i)),r}};function QS(e){var t;return e===0?t=1:t=Math.floor(new le(e).abs().log(10).toNumber())+1,t}function e2(e,t,r){for(var n=new le(e),i=0,s=[];n.lt(t)&&i<1e5;)s.push(n.toNumber()),n=n.add(r),i++;return s}_u((e,t,r)=>{var n=+e,i=+t;return n+r*(i-n)});_u((e,t,r)=>{var n=t-+e;return n=n||1/0,(r-e)/n});_u((e,t,r)=>{var n=t-+e;return n=n||1/0,Math.max(0,Math.min(1,(r-e)/n))});var t2=e=>{var[t,r]=e,[n,i]=[t,r];return t>r&&([n,i]=[r,t]),[n,i]},r2=(e,t,r)=>{if(e.lte(0))return new le(0);var n=QS(e.toNumber()),i=new le(10).pow(n),s=e.div(i),o=n!==1?.05:.1,l=new le(Math.ceil(s.div(o).toNumber())).add(r).mul(o),c=l.mul(i);return t?new le(c.toNumber()):new le(Math.ceil(c.toNumber()))},gM=(e,t,r)=>{var n=new le(1),i=new le(e);if(!i.isint()&&r){var s=Math.abs(e);s<1?(n=new le(10).pow(QS(e)-1),i=new le(Math.floor(i.div(n).toNumber())).mul(n)):s>1&&(i=new le(Math.floor(e)))}else e===0?i=new le(Math.floor((t-1)/2)):r||(i=new le(Math.floor(e)));var o=Math.floor((t-1)/2),l=mM(hM(c=>i.add(new le(c-o).mul(n)).toNumber()),dp);return l(0,t)},n2=function(t,r,n,i){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((r-t)/(n-1)))return{step:new le(0),tickMin:new le(0),tickMax:new le(0)};var o=r2(new le(r).sub(t).div(n-1),i,s),l;t<=0&&r>=0?l=new le(0):(l=new le(t).add(r).div(2),l=l.sub(new le(l).mod(o)));var c=Math.ceil(l.sub(t).div(o).toNumber()),d=Math.ceil(new le(r).sub(l).div(o).toNumber()),u=c+d+1;return u>n?n2(t,r,n,i,s+1):(u0?d+(n-u):d,c=r>0?c:c+(n-u)),{step:o,tickMin:l.sub(new le(c).mul(o)),tickMax:l.add(new le(d).mul(o))})};function xM(e){var[t,r]=e,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=Math.max(n,2),[o,l]=t2([t,r]);if(o===-1/0||l===1/0){var c=l===1/0?[o,...dp(0,n-1).map(()=>1/0)]:[...dp(0,n-1).map(()=>-1/0),l];return t>r?fp(c):c}if(o===l)return gM(o,n,i);var{step:d,tickMin:u,tickMax:f}=n2(o,l,s,i,0),p=e2(u,f.add(new le(.1).mul(d)),d);return t>r?fp(p):p}function yM(e,t){var[r,n]=e,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[s,o]=t2([r,n]);if(s===-1/0||o===1/0)return[r,n];if(s===o)return[s];var l=Math.max(t,2),c=r2(new le(o).sub(s).div(l-1),i,0),d=[...e2(new le(s),new le(o),c),o];return i===!1&&(d=d.map(u=>Math.round(u))),r>n?fp(d):d}var vM=JS(xM),bM=JS(yM),jM=e=>e.rootProps.barCategoryGap,Pu=e=>e.rootProps.stackOffset,Om=e=>e.options.chartName,Em=e=>e.rootProps.syncId,i2=e=>e.rootProps.syncMethod,Dm=e=>e.options.eventEmitter,wM=e=>e.rootProps.baseValue,lt={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},zr={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},$t={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},Cu=(e,t)=>{if(!(!e||!t))return e!=null&&e.reversed?[t[1],t[0]]:t},SM={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:zr.angleAxisId,includeHidden:!1,name:void 0,reversed:zr.reversed,scale:zr.scale,tick:zr.tick,tickCount:void 0,ticks:void 0,type:zr.type,unit:void 0},NM={allowDataOverflow:$t.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:$t.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:$t.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:$t.scale,tick:$t.tick,tickCount:$t.tickCount,ticks:void 0,type:$t.type,unit:void 0},kM={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:zr.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:zr.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:zr.scale,tick:zr.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},_M={allowDataOverflow:$t.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:$t.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:$t.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:$t.scale,tick:$t.tick,tickCount:$t.tickCount,ticks:void 0,type:"category",unit:void 0},Tm=(e,t)=>e.polarAxis.angleAxis[t]!=null?e.polarAxis.angleAxis[t]:e.layout.layoutType==="radial"?kM:SM,Mm=(e,t)=>e.polarAxis.radiusAxis[t]!=null?e.polarAxis.radiusAxis[t]:e.layout.layoutType==="radial"?_M:NM,Au=e=>e.polarOptions,Im=L([ln,cn,rt],S5),a2=L([Au,Im],(e,t)=>{if(e!=null)return Rn(e.innerRadius,t,0)}),s2=L([Au,Im],(e,t)=>{if(e!=null)return Rn(e.outerRadius,t,t*.8)}),PM=e=>{if(e==null)return[0,0];var{startAngle:t,endAngle:r}=e;return[t,r]},o2=L([Au],PM);L([Tm,o2],Cu);var l2=L([Im,a2,s2],(e,t,r)=>{if(!(e==null||t==null||r==null))return[t,r]});L([Mm,l2],Cu);var c2=L([de,Au,a2,s2,ln,cn],(e,t,r,n,i,s)=>{if(!(e!=="centric"&&e!=="radial"||t==null||r==null||n==null)){var{cx:o,cy:l,startAngle:c,endAngle:d}=t;return{cx:Rn(o,i,i/2),cy:Rn(l,s,s/2),innerRadius:r,outerRadius:n,startAngle:c,endAngle:d,clockWise:!1}}}),Fe=(e,t)=>t,Ou=(e,t,r)=>r;function $m(e){return e==null?void 0:e.id}function u2(e,t,r){var{chartData:n=[]}=t,{allowDuplicatedCategory:i,dataKey:s}=r,o=new Map;return e.forEach(l=>{var c,d=(c=l.data)!==null&&c!==void 0?c:n;if(!(d==null||d.length===0)){var u=$m(l);d.forEach((f,p)=>{var m=s==null||i?p:String(et(f,s,null)),x=et(f,l.dataKey,0),g;o.has(m)?g=o.get(m):g={},Object.assign(g,{[u]:x}),o.set(m,g)})}}),Array.from(o.values())}function Lm(e){return e.stackId!=null&&e.dataKey!=null}var Eu=(e,t)=>e===t?!0:e==null||t==null?!1:e[0]===t[0]&&e[1]===t[1];function Du(e,t){return Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t}function CM(e,t){if(e.length===t.length){for(var r=0;r{var t=de(e);return t==="horizontal"?"xAxis":t==="vertical"?"yAxis":t==="centric"?"angleAxis":"radiusAxis"},Ea=e=>e.tooltip.settings.axisId;function Py(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function gc(e){for(var t=1;te.cartesianAxis.xAxis[t],dn=(e,t)=>{var r=d2(e,t);return r??Tt},Mt={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:pp,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:ro},f2=(e,t)=>e.cartesianAxis.yAxis[t],fn=(e,t)=>{var r=f2(e,t);return r??Mt},DM={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:""},zm=(e,t)=>{var r=e.cartesianAxis.zAxis[t];return r??DM},vt=(e,t,r)=>{switch(t){case"xAxis":return dn(e,r);case"yAxis":return fn(e,r);case"zAxis":return zm(e,r);case"angleAxis":return Tm(e,r);case"radiusAxis":return Mm(e,r);default:throw new Error("Unexpected axis type: ".concat(t))}},TM=(e,t,r)=>{switch(t){case"xAxis":return dn(e,r);case"yAxis":return fn(e,r);default:throw new Error("Unexpected axis type: ".concat(t))}},lo=(e,t,r)=>{switch(t){case"xAxis":return dn(e,r);case"yAxis":return fn(e,r);case"angleAxis":return Tm(e,r);case"radiusAxis":return Mm(e,r);default:throw new Error("Unexpected axis type: ".concat(t))}},p2=e=>e.graphicalItems.cartesianItems.some(t=>t.type==="bar")||e.graphicalItems.polarItems.some(t=>t.type==="radialBar");function h2(e,t){return r=>{switch(e){case"xAxis":return"xAxisId"in r&&r.xAxisId===t;case"yAxis":return"yAxisId"in r&&r.yAxisId===t;case"zAxis":return"zAxisId"in r&&r.zAxisId===t;case"angleAxis":return"angleAxisId"in r&&r.angleAxisId===t;case"radiusAxis":return"radiusAxisId"in r&&r.radiusAxisId===t;default:return!1}}}var Rm=e=>e.graphicalItems.cartesianItems,MM=L([Fe,Ou],h2),m2=(e,t,r)=>e.filter(r).filter(n=>(t==null?void 0:t.includeHidden)===!0?!0:!n.hide),co=L([Rm,vt,MM],m2,{memoizeOptions:{resultEqualityCheck:Du}}),g2=L([co],e=>e.filter(t=>t.type==="area"||t.type==="bar").filter(Lm)),x2=e=>e.filter(t=>!("stackId"in t)||t.stackId===void 0),IM=L([co],x2),y2=e=>e.map(t=>t.data).filter(Boolean).flat(1),$M=L([co],y2,{memoizeOptions:{resultEqualityCheck:Du}}),v2=(e,t)=>{var{chartData:r=[],dataStartIndex:n,dataEndIndex:i}=t;return e.length>0?e:r.slice(n,i+1)},Bm=L([$M,ku],v2),b2=(e,t,r)=>(t==null?void 0:t.dataKey)!=null?e.map(n=>({value:et(n,t.dataKey)})):r.length>0?r.map(n=>n.dataKey).flatMap(n=>e.map(i=>({value:et(i,n)}))):e.map(n=>({value:n})),Tu=L([Bm,vt,co],b2);function j2(e,t){switch(e){case"xAxis":return t.direction==="x";case"yAxis":return t.direction==="y";default:return!1}}function dl(e){if(Or(e)||e instanceof Date){var t=Number(e);if(_e(t))return t}}function Cy(e){if(Array.isArray(e)){var t=[dl(e[0]),dl(e[1])];return ji(t)?t:void 0}var r=dl(e);if(r!=null)return[r,r]}function an(e){return e.map(dl).filter(K4)}function LM(e,t,r){return!r||typeof t!="number"||yr(t)?[]:r.length?an(r.flatMap(n=>{var i=et(e,n.dataKey),s,o;if(Array.isArray(i)?[s,o]=i:s=o=i,!(!_e(s)||!_e(o)))return[t-s,t+o]})):[]}var Ue=e=>{var t=We(e),r=Ea(e);return lo(e,t,r)},w2=L([Ue],e=>e==null?void 0:e.dataKey),zM=L([g2,ku,Ue],u2),S2=(e,t,r)=>{var n={},i=t.reduce((s,o)=>(o.stackId==null||(s[o.stackId]==null&&(s[o.stackId]=[]),s[o.stackId].push(o)),s),n);return Object.fromEntries(Object.entries(i).map(s=>{var[o,l]=s,c=l.map($m);return[o,{stackedData:DE(e,c,r),graphicalItems:l}]}))},hp=L([zM,g2,Pu],S2),N2=(e,t,r,n)=>{var{dataStartIndex:i,dataEndIndex:s}=t;if(n==null&&r!=="zAxis"){var o=$E(e,i,s);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},RM=L([vt],e=>e.allowDataOverflow),Fm=e=>{var t;if(e==null||!("domain"in e))return pp;if(e.domain!=null)return e.domain;if(e.ticks!=null){if(e.type==="number"){var r=an(e.ticks);return[Math.min(...r),Math.max(...r)]}if(e.type==="category")return e.ticks.map(String)}return(t=e==null?void 0:e.domain)!==null&&t!==void 0?t:pp},k2=L([vt],Fm),_2=L([k2,RM],US),BM=L([hp,Kn,Fe,_2],N2,{memoizeOptions:{resultEqualityCheck:Eu}}),Wm=e=>e.errorBars,FM=(e,t,r)=>e.flatMap(n=>t[n.id]).filter(Boolean).filter(n=>j2(r,n)),xc=function(){for(var t=arguments.length,r=new Array(t),n=0;n{var s,o;if(r.length>0&&e.forEach(l=>{r.forEach(c=>{var d,u,f=(d=n[c.id])===null||d===void 0?void 0:d.filter(b=>j2(i,b)),p=et(l,(u=t.dataKey)!==null&&u!==void 0?u:c.dataKey),m=LM(l,p,f);if(m.length>=2){var x=Math.min(...m),g=Math.max(...m);(s==null||xo)&&(o=g)}var v=Cy(p);v!=null&&(s=s==null?v[0]:Math.min(s,v[0]),o=o==null?v[1]:Math.max(o,v[1]))})}),(t==null?void 0:t.dataKey)!=null&&e.forEach(l=>{var c=Cy(et(l,t.dataKey));c!=null&&(s=s==null?c[0]:Math.min(s,c[0]),o=o==null?c[1]:Math.max(o,c[1]))}),_e(s)&&_e(o))return[s,o]},WM=L([Bm,vt,IM,Wm,Fe],P2,{memoizeOptions:{resultEqualityCheck:Eu}});function UM(e){var{value:t}=e;if(Or(t)||t instanceof Date)return t}var qM=(e,t,r)=>{var n=e.map(UM).filter(i=>i!=null);return r&&(t.dataKey==null||t.allowDuplicatedCategory&&Tj(n))?lS(0,e.length):t.allowDuplicatedCategory?n:Array.from(new Set(n))},C2=e=>e.referenceElements.dots,Da=(e,t,r)=>e.filter(n=>n.ifOverflow==="extendDomain").filter(n=>t==="xAxis"?n.xAxisId===r:n.yAxisId===r),HM=L([C2,Fe,Ou],Da),A2=e=>e.referenceElements.areas,KM=L([A2,Fe,Ou],Da),O2=e=>e.referenceElements.lines,VM=L([O2,Fe,Ou],Da),E2=(e,t)=>{var r=an(e.map(n=>t==="xAxis"?n.x:n.y));if(r.length!==0)return[Math.min(...r),Math.max(...r)]},YM=L(HM,Fe,E2),D2=(e,t)=>{var r=an(e.flatMap(n=>[t==="xAxis"?n.x1:n.y1,t==="xAxis"?n.x2:n.y2]));if(r.length!==0)return[Math.min(...r),Math.max(...r)]},GM=L([KM,Fe],D2);function ZM(e){var t;if(e.x!=null)return an([e.x]);var r=(t=e.segment)===null||t===void 0?void 0:t.map(n=>n.x);return r==null||r.length===0?[]:an(r)}function XM(e){var t;if(e.y!=null)return an([e.y]);var r=(t=e.segment)===null||t===void 0?void 0:t.map(n=>n.y);return r==null||r.length===0?[]:an(r)}var T2=(e,t)=>{var r=e.flatMap(n=>t==="xAxis"?ZM(n):XM(n));if(r.length!==0)return[Math.min(...r),Math.max(...r)]},JM=L([VM,Fe],T2),QM=L(YM,JM,GM,(e,t,r)=>xc(e,r,t)),M2=(e,t,r,n,i,s,o,l)=>{if(r!=null)return r;var c=o==="vertical"&&l==="xAxis"||o==="horizontal"&&l==="yAxis",d=c?xc(n,s,i):xc(s,i);return cM(t,d,e.allowDataOverflow)},eI=L([vt,k2,_2,BM,WM,QM,de,Fe],M2,{memoizeOptions:{resultEqualityCheck:Eu}}),tI=[0,1],I2=(e,t,r,n,i,s,o)=>{if(!((e==null||r==null||r.length===0)&&o===void 0)){var{dataKey:l,type:c}=e,d=Mr(t,s);if(d&&l==null){var u;return lS(0,(u=r==null?void 0:r.length)!==null&&u!==void 0?u:0)}return c==="category"?qM(n,e,d):i==="expand"?tI:o}},Um=L([vt,de,Bm,Tu,Pu,Fe,eI],I2),$2=(e,t,r,n,i)=>{if(e!=null){var{scale:s,type:o}=e;if(s==="auto")return t==="radial"&&i==="radiusAxis"?"band":t==="radial"&&i==="angleAxis"?"linear":o==="category"&&n&&(n.indexOf("LineChart")>=0||n.indexOf("AreaChart")>=0||n.indexOf("ComposedChart")>=0&&!r)?"point":o==="category"?"band":"linear";if(typeof s=="string"){var l="scale".concat(Qs(s));return l in rs?l:"point"}}},uo=L([vt,de,p2,Om,Fe],$2);function rI(e){if(e!=null){if(e in rs)return rs[e]();var t="scale".concat(Qs(e));if(t in rs)return rs[t]()}}function qm(e,t,r,n){if(!(r==null||n==null)){if(typeof e.scale=="function")return e.scale.copy().domain(r).range(n);var i=rI(t);if(i!=null){var s=i.domain(r).range(n);return CE(s),s}}}var L2=(e,t,r)=>{var n=Fm(t);if(!(r!=="auto"&&r!=="linear")){if(t!=null&&t.tickCount&&Array.isArray(n)&&(n[0]==="auto"||n[1]==="auto")&&ji(e))return vM(e,t.tickCount,t.allowDecimals);if(t!=null&&t.tickCount&&t.type==="number"&&ji(e))return bM(e,t.tickCount,t.allowDecimals)}},Hm=L([Um,lo,uo],L2),z2=(e,t,r,n)=>{if(n!=="angleAxis"&&(e==null?void 0:e.type)==="number"&&ji(t)&&Array.isArray(r)&&r.length>0){var i=t[0],s=r[0],o=t[1],l=r[r.length-1];return[Math.min(i,s),Math.max(o,l)]}return t},nI=L([vt,Um,Hm,Fe],z2),iI=L(Tu,vt,(e,t)=>{if(!(!t||t.type!=="number")){var r=1/0,n=Array.from(an(e.map(l=>l.value))).sort((l,c)=>l-c);if(n.length<2)return 1/0;var i=n[n.length-1]-n[0];if(i===0)return 1/0;for(var s=0;sn,(e,t,r,n,i)=>{if(!_e(e))return 0;var s=t==="vertical"?n.height:n.width;if(i==="gap")return e*s/2;if(i==="no-gap"){var o=Rn(r,e*s),l=e*s/2;return l-o-(l-o)/s*o}return 0}),aI=(e,t)=>{var r=dn(e,t);return r==null||typeof r.padding!="string"?0:R2(e,"xAxis",t,r.padding)},sI=(e,t)=>{var r=fn(e,t);return r==null||typeof r.padding!="string"?0:R2(e,"yAxis",t,r.padding)},oI=L(dn,aI,(e,t)=>{var r,n;if(e==null)return{left:0,right:0};var{padding:i}=e;return typeof i=="string"?{left:t,right:t}:{left:((r=i.left)!==null&&r!==void 0?r:0)+t,right:((n=i.right)!==null&&n!==void 0?n:0)+t}}),lI=L(fn,sI,(e,t)=>{var r,n;if(e==null)return{top:0,bottom:0};var{padding:i}=e;return typeof i=="string"?{top:t,bottom:t}:{top:((r=i.top)!==null&&r!==void 0?r:0)+t,bottom:((n=i.bottom)!==null&&n!==void 0?n:0)+t}}),cI=L([rt,oI,hu,pu,(e,t,r)=>r],(e,t,r,n,i)=>{var{padding:s}=n;return i?[s.left,r.width-s.right]:[e.left+t.left,e.left+e.width-t.right]}),uI=L([rt,de,lI,hu,pu,(e,t,r)=>r],(e,t,r,n,i,s)=>{var{padding:o}=i;return s?[n.height-o.bottom,o.top]:t==="horizontal"?[e.top+e.height-r.bottom,e.top+r.top]:[e.top+r.top,e.top+e.height-r.bottom]}),fo=(e,t,r,n)=>{var i;switch(t){case"xAxis":return cI(e,r,n);case"yAxis":return uI(e,r,n);case"zAxis":return(i=zm(e,r))===null||i===void 0?void 0:i.range;case"angleAxis":return o2(e);case"radiusAxis":return l2(e,r);default:return}},B2=L([vt,fo],Cu),Ta=L([vt,uo,nI,B2],qm);L([co,Wm,Fe],FM);function F2(e,t){return e.idt.id?1:0}var Mu=(e,t)=>t,Iu=(e,t,r)=>r,dI=L(du,Mu,Iu,(e,t,r)=>e.filter(n=>n.orientation===t).filter(n=>n.mirror===r).sort(F2)),fI=L(fu,Mu,Iu,(e,t,r)=>e.filter(n=>n.orientation===t).filter(n=>n.mirror===r).sort(F2)),W2=(e,t)=>({width:e.width,height:t.height}),pI=(e,t)=>{var r=typeof t.width=="number"?t.width:ro;return{width:r,height:e.height}},hI=L(rt,dn,W2),mI=(e,t,r)=>{switch(t){case"top":return e.top;case"bottom":return r-e.bottom;default:return 0}},gI=(e,t,r)=>{switch(t){case"left":return e.left;case"right":return r-e.right;default:return 0}},xI=L(cn,rt,dI,Mu,Iu,(e,t,r,n,i)=>{var s={},o;return r.forEach(l=>{var c=W2(t,l);o==null&&(o=mI(t,n,e));var d=n==="top"&&!i||n==="bottom"&&i;s[l.id]=o-Number(d)*c.height,o+=(d?-1:1)*c.height}),s}),yI=L(ln,rt,fI,Mu,Iu,(e,t,r,n,i)=>{var s={},o;return r.forEach(l=>{var c=pI(t,l);o==null&&(o=gI(t,n,e));var d=n==="left"&&!i||n==="right"&&i;s[l.id]=o-Number(d)*c.width,o+=(d?-1:1)*c.width}),s}),vI=(e,t)=>{var r=dn(e,t);if(r!=null)return xI(e,r.orientation,r.mirror)},bI=L([rt,dn,vI,(e,t)=>t],(e,t,r,n)=>{if(t!=null){var i=r==null?void 0:r[n];return i==null?{x:e.left,y:0}:{x:e.left,y:i}}}),jI=(e,t)=>{var r=fn(e,t);if(r!=null)return yI(e,r.orientation,r.mirror)},wI=L([rt,fn,jI,(e,t)=>t],(e,t,r,n)=>{if(t!=null){var i=r==null?void 0:r[n];return i==null?{x:0,y:e.top}:{x:i,y:e.top}}}),SI=L(rt,fn,(e,t)=>{var r=typeof t.width=="number"?t.width:ro;return{width:r,height:e.height}}),U2=(e,t,r,n)=>{if(r!=null){var{allowDuplicatedCategory:i,type:s,dataKey:o}=r,l=Mr(e,n),c=t.map(d=>d.value);if(o&&l&&s==="category"&&i&&Tj(c))return c}},Km=L([de,Tu,vt,Fe],U2),q2=(e,t,r,n)=>{if(!(r==null||r.dataKey==null)){var{type:i,scale:s}=r,o=Mr(e,n);if(o&&(i==="number"||s!=="auto"))return t.map(l=>l.value)}},Vm=L([de,Tu,lo,Fe],q2),Ay=L([de,TM,uo,Ta,Km,Vm,fo,Hm,Fe],(e,t,r,n,i,s,o,l,c)=>{if(t!=null){var d=Mr(e,c);return{angle:t.angle,interval:t.interval,minTickGap:t.minTickGap,orientation:t.orientation,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,axisType:c,categoricalDomain:s,duplicateDomain:i,isCategorical:d,niceTicks:l,range:o,realScaleType:r,scale:n}}}),NI=(e,t,r,n,i,s,o,l,c)=>{if(!(t==null||n==null)){var d=Mr(e,c),{type:u,ticks:f,tickCount:p}=t,m=r==="scaleBand"&&typeof n.bandwidth=="function"?n.bandwidth()/2:2,x=u==="category"&&n.bandwidth?n.bandwidth()/m:0;x=c==="angleAxis"&&s!=null&&s.length>=2?Jt(s[0]-s[1])*2*x:x;var g=f||i;if(g){var v=g.map((b,j)=>{var y=o?o.indexOf(b):b;return{index:j,coordinate:n(y)+x,value:b,offset:x}});return v.filter(b=>_e(b.coordinate))}return d&&l?l.map((b,j)=>({coordinate:n(b)+x,value:b,index:j,offset:x})).filter(b=>_e(b.coordinate)):n.ticks?n.ticks(p).map(b=>({coordinate:n(b)+x,value:b,offset:x})):n.domain().map((b,j)=>({coordinate:n(b)+x,value:o?o[b]:b,index:j,offset:x}))}},H2=L([de,lo,uo,Ta,Hm,fo,Km,Vm,Fe],NI),kI=(e,t,r,n,i,s,o)=>{if(!(t==null||r==null||n==null||n[0]===n[1])){var l=Mr(e,o),{tickCount:c}=t,d=0;return d=o==="angleAxis"&&(n==null?void 0:n.length)>=2?Jt(n[0]-n[1])*2*d:d,l&&s?s.map((u,f)=>({coordinate:r(u)+d,value:u,index:f,offset:d})):r.ticks?r.ticks(c).map(u=>({coordinate:r(u)+d,value:u,offset:d})):r.domain().map((u,f)=>({coordinate:r(u)+d,value:i?i[u]:u,index:f,offset:d}))}},$u=L([de,lo,Ta,fo,Km,Vm,Fe],kI),Lu=L(vt,Ta,(e,t)=>{if(!(e==null||t==null))return gc(gc({},e),{},{scale:t})}),_I=L([vt,uo,Um,B2],qm);L((e,t,r)=>zm(e,r),_I,(e,t)=>{if(!(e==null||t==null))return gc(gc({},e),{},{scale:t})});var PI=L([de,du,fu],(e,t,r)=>{switch(e){case"horizontal":return t.some(n=>n.reversed)?"right-to-left":"left-to-right";case"vertical":return r.some(n=>n.reversed)?"bottom-to-top":"top-to-bottom";case"centric":case"radial":return"left-to-right";default:return}}),K2=e=>e.options.defaultTooltipEventType,V2=e=>e.options.validateTooltipEventTypes;function Y2(e,t,r){if(e==null)return t;var n=e?"axis":"item";return r==null?t:r.includes(n)?n:t}function Ym(e,t){var r=K2(e),n=V2(e);return Y2(t,r,n)}function CI(e){return Z(t=>Ym(t,e))}var G2=(e,t)=>{var r,n=Number(t);if(!(yr(n)||t==null))return n>=0?e==null||(r=e[n])===null||r===void 0?void 0:r.value:void 0},AI=e=>e.tooltip.settings,jn={active:!1,index:null,dataKey:void 0,coordinate:void 0},OI={itemInteraction:{click:jn,hover:jn},axisInteraction:{click:jn,hover:jn},keyboardInteraction:jn,syncInteraction:{active:!1,index:null,dataKey:void 0,label:void 0,coordinate:void 0,sourceViewBox:void 0},tooltipItemPayloads:[],settings:{shared:void 0,trigger:"hover",axisId:0,active:!1,defaultIndex:void 0}},Z2=At({name:"tooltip",initialState:OI,reducers:{addTooltipEntrySettings:{reducer(e,t){e.tooltipItemPayloads.push(t.payload)},prepare:Le()},removeTooltipEntrySettings:{reducer(e,t){var r=Kr(e).tooltipItemPayloads.indexOf(t.payload);r>-1&&e.tooltipItemPayloads.splice(r,1)},prepare:Le()},setTooltipSettingsState(e,t){e.settings=t.payload},setActiveMouseOverItemIndex(e,t){e.syncInteraction.active=!1,e.keyboardInteraction.active=!1,e.itemInteraction.hover.active=!0,e.itemInteraction.hover.index=t.payload.activeIndex,e.itemInteraction.hover.dataKey=t.payload.activeDataKey,e.itemInteraction.hover.coordinate=t.payload.activeCoordinate},mouseLeaveChart(e){e.itemInteraction.hover.active=!1,e.axisInteraction.hover.active=!1},mouseLeaveItem(e){e.itemInteraction.hover.active=!1},setActiveClickItemIndex(e,t){e.syncInteraction.active=!1,e.itemInteraction.click.active=!0,e.keyboardInteraction.active=!1,e.itemInteraction.click.index=t.payload.activeIndex,e.itemInteraction.click.dataKey=t.payload.activeDataKey,e.itemInteraction.click.coordinate=t.payload.activeCoordinate},setMouseOverAxisIndex(e,t){e.syncInteraction.active=!1,e.axisInteraction.hover.active=!0,e.keyboardInteraction.active=!1,e.axisInteraction.hover.index=t.payload.activeIndex,e.axisInteraction.hover.dataKey=t.payload.activeDataKey,e.axisInteraction.hover.coordinate=t.payload.activeCoordinate},setMouseClickAxisIndex(e,t){e.syncInteraction.active=!1,e.keyboardInteraction.active=!1,e.axisInteraction.click.active=!0,e.axisInteraction.click.index=t.payload.activeIndex,e.axisInteraction.click.dataKey=t.payload.activeDataKey,e.axisInteraction.click.coordinate=t.payload.activeCoordinate},setSyncInteraction(e,t){e.syncInteraction=t.payload},setKeyboardInteraction(e,t){e.keyboardInteraction.active=t.payload.active,e.keyboardInteraction.index=t.payload.activeIndex,e.keyboardInteraction.coordinate=t.payload.activeCoordinate,e.keyboardInteraction.dataKey=t.payload.activeDataKey}}}),{addTooltipEntrySettings:EI,removeTooltipEntrySettings:DI,setTooltipSettingsState:TI,setActiveMouseOverItemIndex:MI,mouseLeaveItem:$F,mouseLeaveChart:X2,setActiveClickItemIndex:LF,setMouseOverAxisIndex:J2,setMouseClickAxisIndex:II,setSyncInteraction:mp,setKeyboardInteraction:gp}=Z2.actions,$I=Z2.reducer;function Oy(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Vo(e){for(var t=1;t{if(t==null)return jn;var i=BI(e,t,r);if(i==null)return jn;if(i.active)return i;if(e.keyboardInteraction.active)return e.keyboardInteraction;if(e.syncInteraction.active&&e.syncInteraction.index!=null)return e.syncInteraction;var s=e.settings.active===!0;if(FI(i)){if(s)return Vo(Vo({},i),{},{active:!0})}else if(n!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:n};return Vo(Vo({},jn),{},{coordinate:i.coordinate})},Gm=(e,t)=>{var r=e==null?void 0:e.index;if(r==null)return null;var n=Number(r);if(!_e(n))return r;var i=0,s=1/0;return t.length>0&&(s=t.length-1),String(Math.max(i,Math.min(n,s)))},eN=(e,t,r,n,i,s,o,l)=>{if(!(s==null||l==null)){var c=o[0],d=c==null?void 0:l(c.positions,s);if(d!=null)return d;var u=i==null?void 0:i[Number(s)];if(u)switch(r){case"horizontal":return{x:u.coordinate,y:(n.top+t)/2};default:return{x:(n.left+e)/2,y:u.coordinate}}}},tN=(e,t,r,n)=>{if(t==="axis")return e.tooltipItemPayloads;if(e.tooltipItemPayloads.length===0)return[];var i;return r==="hover"?i=e.itemInteraction.hover.dataKey:i=e.itemInteraction.click.dataKey,i==null&&n!=null?[e.tooltipItemPayloads[0]]:e.tooltipItemPayloads.filter(s=>{var o;return((o=s.settings)===null||o===void 0?void 0:o.dataKey)===i})},po=e=>e.options.tooltipPayloadSearcher,Ma=e=>e.tooltip;function Ey(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Dy(e){for(var t=1;t{if(!(t==null||s==null)){var{chartData:l,computedData:c,dataStartIndex:d,dataEndIndex:u}=r,f=[];return e.reduce((p,m)=>{var x,{dataDefinedOnItem:g,settings:v}=m,b=HI(g,l),j=Array.isArray(b)?Mw(b,d,u):b,y=(x=v==null?void 0:v.dataKey)!==null&&x!==void 0?x:n,w=v==null?void 0:v.nameKey,S;if(n&&Array.isArray(j)&&!Array.isArray(j[0])&&o==="axis"?S=Mj(j,n,i):S=s(j,t,c,w),Array.isArray(S))S.forEach(P=>{var C=Dy(Dy({},v),{},{name:P.name,unit:P.unit,color:void 0,fill:void 0});p.push(h0({tooltipEntrySettings:C,dataKey:P.dataKey,payload:P.payload,value:et(P.payload,P.dataKey),name:P.name}))});else{var N;p.push(h0({tooltipEntrySettings:v,dataKey:y,payload:S,value:et(S,y),name:(N=et(S,w))!==null&&N!==void 0?N:v==null?void 0:v.name}))}return p},f)}},Zm=L([Ue,de,p2,Om,We],$2),KI=L([e=>e.graphicalItems.cartesianItems,e=>e.graphicalItems.polarItems],(e,t)=>[...e,...t]),VI=L([We,Ea],h2),ho=L([KI,Ue,VI],m2,{memoizeOptions:{resultEqualityCheck:Du}}),YI=L([ho],e=>e.filter(Lm)),GI=L([ho],y2,{memoizeOptions:{resultEqualityCheck:Du}}),Ia=L([GI,Kn],v2),ZI=L([YI,Kn,Ue],u2),Xm=L([Ia,Ue,ho],b2),nN=L([Ue],Fm),XI=L([Ue],e=>e.allowDataOverflow),iN=L([nN,XI],US),JI=L([ho],e=>e.filter(Lm)),QI=L([ZI,JI,Pu],S2),e$=L([QI,Kn,We,iN],N2),t$=L([ho],x2),r$=L([Ia,Ue,t$,Wm,We],P2,{memoizeOptions:{resultEqualityCheck:Eu}}),n$=L([C2,We,Ea],Da),i$=L([n$,We],E2),a$=L([A2,We,Ea],Da),s$=L([a$,We],D2),o$=L([O2,We,Ea],Da),l$=L([o$,We],T2),c$=L([i$,l$,s$],xc),u$=L([Ue,nN,iN,e$,r$,c$,de,We],M2),aN=L([Ue,de,Ia,Xm,Pu,We,u$],I2),d$=L([aN,Ue,Zm],L2),f$=L([Ue,aN,d$,We],z2),sN=e=>{var t=We(e),r=Ea(e),n=!1;return fo(e,t,r,n)},oN=L([Ue,sN],Cu),lN=L([Ue,Zm,f$,oN],qm),p$=L([de,Xm,Ue,We],U2),h$=L([de,Xm,Ue,We],q2),m$=(e,t,r,n,i,s,o,l)=>{if(t){var{type:c}=t,d=Mr(e,l);if(n){var u=r==="scaleBand"&&n.bandwidth?n.bandwidth()/2:2,f=c==="category"&&n.bandwidth?n.bandwidth()/u:0;return f=l==="angleAxis"&&i!=null&&(i==null?void 0:i.length)>=2?Jt(i[0]-i[1])*2*f:f,d&&o?o.map((p,m)=>({coordinate:n(p)+f,value:p,index:m,offset:f})):n.domain().map((p,m)=>({coordinate:n(p)+f,value:s?s[p]:p,index:m,offset:f}))}}},pn=L([de,Ue,Zm,lN,sN,p$,h$,We],m$),Jm=L([K2,V2,AI],(e,t,r)=>Y2(r.shared,e,t)),cN=e=>e.tooltip.settings.trigger,Qm=e=>e.tooltip.settings.defaultIndex,zu=L([Ma,Jm,cN,Qm],Q2),Hs=L([zu,Ia],Gm),uN=L([pn,Hs],G2),g$=L([zu],e=>{if(e)return e.dataKey}),dN=L([Ma,Jm,cN,Qm],tN),x$=L([ln,cn,de,rt,pn,Qm,dN,po],eN),y$=L([zu,x$],(e,t)=>e!=null&&e.coordinate?e.coordinate:t),v$=L([zu],e=>e.active),b$=L([dN,Hs,Kn,w2,uN,po,Jm],rN),j$=L([b$],e=>{if(e!=null){var t=e.map(r=>r.payload).filter(r=>r!=null);return Array.from(new Set(t))}});function Ty(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function My(e){for(var t=1;tZ(Ue),_$=()=>{var e=k$(),t=Z(pn),r=Z(lN);return ga(!e||!r?void 0:My(My({},e),{},{scale:r}),t)};function Iy(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Ti(e){for(var t=1;t{var i=t.find(s=>s&&s.index===r);if(i){if(e==="horizontal")return{x:i.coordinate,y:n.chartY};if(e==="vertical")return{x:n.chartX,y:i.coordinate}}return{x:0,y:0}},E$=(e,t,r,n)=>{var i=t.find(d=>d&&d.index===r);if(i){if(e==="centric"){var s=i.coordinate,{radius:o}=n;return Ti(Ti(Ti({},n),Je(n.cx,n.cy,o,s)),{},{angle:s,radius:o})}var l=i.coordinate,{angle:c}=n;return Ti(Ti(Ti({},n),Je(n.cx,n.cy,l,c)),{},{angle:c,radius:l})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function D$(e,t){var{chartX:r,chartY:n}=e;return r>=t.left&&r<=t.left+t.width&&n>=t.top&&n<=t.top+t.height}var fN=(e,t,r,n,i)=>{var s,o=-1,l=(s=t==null?void 0:t.length)!==null&&s!==void 0?s:0;if(l<=1||e==null)return 0;if(n==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var c=0;c0?r[c-1].coordinate:r[l-1].coordinate,u=r[c].coordinate,f=c>=l-1?r[0].coordinate:r[c+1].coordinate,p=void 0;if(Jt(u-d)!==Jt(f-u)){var m=[];if(Jt(f-u)===Jt(i[1]-i[0])){p=f;var x=u+i[1]-i[0];m[0]=Math.min(x,(x+d)/2),m[1]=Math.max(x,(x+d)/2)}else{p=d;var g=f+i[1]-i[0];m[0]=Math.min(u,(g+u)/2),m[1]=Math.max(u,(g+u)/2)}var v=[Math.min(u,(p+u)/2),Math.max(u,(p+u)/2)];if(e>v[0]&&e<=v[1]||e>=m[0]&&e<=m[1]){({index:o}=r[c]);break}}else{var b=Math.min(d,f),j=Math.max(d,f);if(e>(b+u)/2&&e<=(j+u)/2){({index:o}=r[c]);break}}}else if(t){for(var y=0;y0&&y(t[y].coordinate+t[y-1].coordinate)/2&&e<=(t[y].coordinate+t[y+1].coordinate)/2||y===l-1&&e>(t[y].coordinate+t[y-1].coordinate)/2){({index:o}=t[y]);break}}return o},pN=()=>Z(Om),eg=(e,t)=>t,hN=(e,t,r)=>r,tg=(e,t,r,n)=>n,T$=L(pn,e=>iu(e,t=>t.coordinate)),rg=L([Ma,eg,hN,tg],Q2),mN=L([rg,Ia],Gm),M$=(e,t,r)=>{if(t!=null){var n=Ma(e);return t==="axis"?r==="hover"?n.axisInteraction.hover.dataKey:n.axisInteraction.click.dataKey:r==="hover"?n.itemInteraction.hover.dataKey:n.itemInteraction.click.dataKey}},gN=L([Ma,eg,hN,tg],tN),yc=L([ln,cn,de,rt,pn,tg,gN,po],eN),I$=L([rg,yc],(e,t)=>{var r;return(r=e.coordinate)!==null&&r!==void 0?r:t}),xN=L([pn,mN],G2),$$=L([gN,mN,Kn,w2,xN,po,eg],rN),L$=L([rg],e=>({isActive:e.active,activeIndex:e.index})),z$=(e,t,r,n,i,s,o)=>{if(!(!e||!r||!n||!i)&&D$(e,o)){var l=LE(e,t),c=fN(l,s,i,r,n),d=O$(t,i,c,e);return{activeIndex:String(c),activeCoordinate:d}}},R$=(e,t,r,n,i,s,o)=>{if(!(!e||!n||!i||!s||!r)){var l=C5(e,r);if(l){var c=zE(l,t),d=fN(c,o,s,n,i),u=E$(t,s,d,l);return{activeIndex:String(d),activeCoordinate:u}}}},B$=(e,t,r,n,i,s,o,l)=>{if(!(!e||!t||!n||!i||!s))return t==="horizontal"||t==="vertical"?z$(e,t,n,i,s,o,l):R$(e,t,r,n,i,s,o)},F$=L(e=>e.zIndex.zIndexMap,(e,t)=>t,(e,t,r)=>r,(e,t,r)=>{if(t!=null){var n=e[t];if(n!=null)return r?n.panoramaElementId:n.elementId}}),W$=L(e=>e.zIndex.zIndexMap,e=>{var t=Object.keys(e).map(n=>parseInt(n,10)).concat(Object.values(lt)),r=Array.from(new Set(t));return r.sort((n,i)=>n-i)},{memoizeOptions:{resultEqualityCheck:CM}});function $y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Ly(e){for(var t=1;tLy(Ly({},e),{},{[t]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),K$)},Y$=new Set(Object.values(lt));function G$(e){return Y$.has(e)}var yN=At({name:"zIndex",initialState:V$,reducers:{registerZIndexPortal:{reducer:(e,t)=>{var{zIndex:r}=t.payload;e.zIndexMap[r]?e.zIndexMap[r].consumers+=1:e.zIndexMap[r]={consumers:1,elementId:void 0,panoramaElementId:void 0}},prepare:Le()},unregisterZIndexPortal:{reducer:(e,t)=>{var{zIndex:r}=t.payload;e.zIndexMap[r]&&(e.zIndexMap[r].consumers-=1,e.zIndexMap[r].consumers<=0&&!G$(r)&&delete e.zIndexMap[r])},prepare:Le()},registerZIndexPortalId:{reducer:(e,t)=>{var{zIndex:r,elementId:n,isPanorama:i}=t.payload;e.zIndexMap[r]?i?e.zIndexMap[r].panoramaElementId=n:e.zIndexMap[r].elementId=n:e.zIndexMap[r]={consumers:0,elementId:i?void 0:n,panoramaElementId:i?n:void 0}},prepare:Le()},unregisterZIndexPortalId:{reducer:(e,t)=>{var{zIndex:r}=t.payload;e.zIndexMap[r]&&(t.payload.isPanorama?e.zIndexMap[r].panoramaElementId=void 0:e.zIndexMap[r].elementId=void 0)},prepare:Le()}}}),{registerZIndexPortal:Z$,unregisterZIndexPortal:X$,registerZIndexPortalId:J$,unregisterZIndexPortalId:Q$}=yN.actions,e8=yN.reducer;function Ir(e){var{zIndex:t,children:r}=e,n=f3(),i=n&&t!==void 0&&t!==0,s=pt(),o=Ye();h.useLayoutEffect(()=>i?(o(Z$({zIndex:t})),()=>{o(X$({zIndex:t}))}):Pa,[o,t,i]);var l=Z(d=>F$(d,t,s));if(!i)return r;if(!l)return null;var c=document.getElementById(l);return c?kh.createPortal(r,c):null}function xp(){return xp=Object.assign?Object.assign.bind():function(e){for(var t=1;th.useContext(vN),bN={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(r=!1));function i(c,d,u){this.fn=c,this.context=d,this.once=u||!1}function s(c,d,u,f,p){if(typeof u!="function")throw new TypeError("The listener must be a function");var m=new i(u,f||c,p),x=r?r+d:d;return c._events[x]?c._events[x].fn?c._events[x]=[c._events[x],m]:c._events[x].push(m):(c._events[x]=m,c._eventsCount++),c}function o(c,d){--c._eventsCount===0?c._events=new n:delete c._events[d]}function l(){this._events=new n,this._eventsCount=0}l.prototype.eventNames=function(){var d=[],u,f;if(this._eventsCount===0)return d;for(f in u=this._events)t.call(u,f)&&d.push(r?f.slice(1):f);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(u)):d},l.prototype.listeners=function(d){var u=r?r+d:d,f=this._events[u];if(!f)return[];if(f.fn)return[f.fn];for(var p=0,m=f.length,x=new Array(m);p{e.eventEmitter==null&&(e.eventEmitter=Symbol("rechartsEventEmitter"))}}}),d8=wN.reducer,{createEventEmitter:f8}=wN.actions;function p8(e){return e.tooltip.syncInteraction}var h8={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},SN=At({name:"chartData",initialState:h8,reducers:{setChartData(e,t){if(e.chartData=t.payload,t.payload==null){e.dataStartIndex=0,e.dataEndIndex=0;return}t.payload.length>0&&e.dataEndIndex!==t.payload.length-1&&(e.dataEndIndex=t.payload.length-1)},setComputedData(e,t){e.computedData=t.payload},setDataStartEndIndexes(e,t){var{startIndex:r,endIndex:n}=t.payload;r!=null&&(e.dataStartIndex=r),n!=null&&(e.dataEndIndex=n)}}}),{setChartData:By,setDataStartEndIndexes:m8,setComputedData:zF}=SN.actions,g8=SN.reducer,x8=["x","y"];function Fy(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Mi(e){for(var t=1;tc.rootProps.className);h.useEffect(()=>{if(e==null)return Pa;var c=(d,u,f)=>{if(t!==f&&e===d){if(n==="index"){var p;if(o&&u!==null&&u!==void 0&&(p=u.payload)!==null&&p!==void 0&&p.coordinate&&u.payload.sourceViewBox){var m=u.payload.coordinate,{x,y:g}=m,v=j8(m,x8),{x:b,y:j,width:y,height:w}=u.payload.sourceViewBox,S=Mi(Mi({},v),{},{x:o.x+(y?(x-b)/y:0)*o.width,y:o.y+(w?(g-j)/w:0)*o.height});r(Mi(Mi({},u),{},{payload:Mi(Mi({},u.payload),{},{coordinate:S})}))}else r(u);return}if(i!=null){var N;if(typeof n=="function"){var P={activeTooltipIndex:u.payload.index==null?void 0:Number(u.payload.index),isTooltipActive:u.payload.active,activeIndex:u.payload.index==null?void 0:Number(u.payload.index),activeLabel:u.payload.label,activeDataKey:u.payload.dataKey,activeCoordinate:u.payload.coordinate},C=n(i,P);N=i[C]}else n==="value"&&(N=i.find(_=>String(_.value)===u.payload.label));var{coordinate:T}=u.payload;if(N==null||u.payload.active===!1||T==null||o==null){r(mp({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0}));return}var{x:$,y:I}=T,A=Math.min($,o.x+o.width),R=Math.min(I,o.y+o.height),H={x:s==="horizontal"?N.coordinate:A,y:s==="horizontal"?R:N.coordinate},M=mp({active:u.payload.active,coordinate:H,dataKey:u.payload.dataKey,index:String(N.index),label:u.payload.label,sourceViewBox:u.payload.sourceViewBox});r(M)}}};return Ks.on(yp,c),()=>{Ks.off(yp,c)}},[l,r,t,e,n,i,s,o])}function N8(){var e=Z(Em),t=Z(Dm),r=Ye();h.useEffect(()=>{if(e==null)return Pa;var n=(i,s,o)=>{t!==o&&e===i&&r(m8(s))};return Ks.on(Ry,n),()=>{Ks.off(Ry,n)}},[r,t,e])}function k8(){var e=Ye();h.useEffect(()=>{e(f8())},[e]),S8(),N8()}function _8(e,t,r,n,i,s){var o=Z(m=>M$(m,e,t)),l=Z(Dm),c=Z(Em),d=Z(i2),u=Z(p8),f=u==null?void 0:u.active,p=mu();h.useEffect(()=>{if(!f&&c!=null&&l!=null){var m=mp({active:s,coordinate:r,dataKey:o,index:i,label:typeof n=="number"?String(n):n,sourceViewBox:p});Ks.emit(yp,c,m,l)}},[f,r,o,i,n,l,c,d,s,p])}function Wy(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Uy(e){for(var t=1;t{P(TI({shared:j,trigger:y,axisId:N,active:i,defaultIndex:C}))},[P,j,y,N,i,C]);var T=mu(),$=Zw(),I=CI(j),{activeIndex:A,isActive:R}=(t=Z(Q=>L$(Q,I,y,C)))!==null&&t!==void 0?t:{},H=Z(Q=>$$(Q,I,y,C)),M=Z(Q=>xN(Q,I,y,C)),_=Z(Q=>I$(Q,I,y,C)),D=H,O=o8(),k=(r=i??R)!==null&&r!==void 0?r:!1,[z,W]=PO([D,k]),K=I==="axis"?M:void 0;_8(I,y,_,K,A,k);var ee=S??O;if(ee==null||T==null||I==null)return null;var re=D??qy;k||(re=qy),d&&re.length&&(re=uO(re.filter(Q=>Q.value!=null&&(Q.hide!==!0||n.includeHidden)),p,O8));var Me=re.length>0,E=h.createElement(C3,{allowEscapeViewBox:s,animationDuration:o,animationEasing:l,isAnimationActive:u,active:k,coordinate:_,hasPayload:Me,offset:f,position:m,reverseDirection:x,useTranslate3d:g,viewBox:T,wrapperStyle:v,lastBoundingBox:z,innerRef:W,hasPortalFromProps:!!S},E8(c,Uy(Uy({},n),{},{payload:re,label:K,active:k,activeIndex:A,coordinate:_,accessibilityLayer:$})));return h.createElement(h.Fragment,null,kh.createPortal(E,ee),k&&h.createElement(s8,{cursor:b,tooltipEventType:I,coordinate:_,payload:re,index:A}))}function T8(e,t,r){return(t=M8(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function M8(e){var t=I8(e,"string");return typeof t=="symbol"?t:t+""}function I8(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}class $8{constructor(t){T8(this,"cache",new Map),this.maxSize=t}get(t){var r=this.cache.get(t);return r!==void 0&&(this.cache.delete(t),this.cache.set(t,r)),r}set(t,r){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.maxSize){var n=this.cache.keys().next().value;this.cache.delete(n)}this.cache.set(t,r)}clear(){this.cache.clear()}size(){return this.cache.size}}function Ky(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function L8(e){for(var t=1;t{try{var r=document.getElementById(Yy);r||(r=document.createElement("span"),r.setAttribute("id",Yy),r.setAttribute("aria-hidden","true"),document.body.appendChild(r)),Object.assign(r.style,W8,t),r.textContent="".concat(e);var n=r.getBoundingClientRect();return{width:n.width,height:n.height}}catch{return{width:0,height:0}}},ps=function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(t==null||Ci.isSsr)return{width:0,height:0};if(!NN.enableCache)return Gy(t,r);var n=U8(t,r),i=Vy.get(n);if(i)return i;var s=Gy(t,r);return Vy.set(n,s),s},Zy=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,Xy=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,q8=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,H8=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,kN={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},K8=Object.keys(kN),Gi="NaN";function V8(e,t){return e*kN[t]}class jt{static parse(t){var r,[,n,i]=(r=H8.exec(t))!==null&&r!==void 0?r:[];return new jt(parseFloat(n),i??"")}constructor(t,r){this.num=t,this.unit=r,this.num=t,this.unit=r,yr(t)&&(this.unit=""),r!==""&&!q8.test(r)&&(this.num=NaN,this.unit=""),K8.includes(r)&&(this.num=V8(t,r),this.unit="px")}add(t){return this.unit!==t.unit?new jt(NaN,""):new jt(this.num+t.num,this.unit)}subtract(t){return this.unit!==t.unit?new jt(NaN,""):new jt(this.num-t.num,this.unit)}multiply(t){return this.unit!==""&&t.unit!==""&&this.unit!==t.unit?new jt(NaN,""):new jt(this.num*t.num,this.unit||t.unit)}divide(t){return this.unit!==""&&t.unit!==""&&this.unit!==t.unit?new jt(NaN,""):new jt(this.num/t.num,this.unit||t.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return yr(this.num)}}function _N(e){if(e.includes(Gi))return Gi;for(var t=e;t.includes("*")||t.includes("/");){var r,[,n,i,s]=(r=Zy.exec(t))!==null&&r!==void 0?r:[],o=jt.parse(n??""),l=jt.parse(s??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return Gi;t=t.replace(Zy,c.toString())}for(;t.includes("+")||/.-\d+(?:\.\d+)?/.test(t);){var d,[,u,f,p]=(d=Xy.exec(t))!==null&&d!==void 0?d:[],m=jt.parse(u??""),x=jt.parse(p??""),g=f==="+"?m.add(x):m.subtract(x);if(g.isNaN())return Gi;t=t.replace(Xy,g.toString())}return t}var Jy=/\(([^()]*)\)/;function Y8(e){for(var t=e,r;(r=Jy.exec(t))!=null;){var[,n]=r;t=t.replace(Jy,_N(n))}return t}function G8(e){var t=e.replace(/\s+/g,"");return t=Y8(t),t=_N(t),t}function Z8(e){try{return G8(e)}catch{return Gi}}function Od(e){var t=Z8(e.slice(5,-1));return t===Gi?"":t}var X8=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],J8=["dx","dy","angle","className","breakAll"];function vp(){return vp=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{children:t,breakAll:r,style:n}=e;try{var i=[];Re(t)||(r?i=t.toString().split(""):i=t.toString().split(PN));var s=i.map(l=>({word:l,width:ps(l,n).width})),o=r?0:ps(" ",n).width;return{wordsWithComputedWidth:s,spaceWidth:o}}catch{return null}};function eL(e){return e==="start"||e==="middle"||e==="end"||e==="inherit"}var AN=(e,t,r,n)=>e.reduce((i,s)=>{var{word:o,width:l}=s,c=i[i.length-1];if(c&&l!=null&&(t==null||n||c.width+l+re.reduce((t,r)=>t.width>r.width?t:r),tL="…",ev=(e,t,r,n,i,s,o,l)=>{var c=e.slice(0,t),d=CN({breakAll:r,style:n,children:c+tL});if(!d)return[!1,[]];var u=AN(d.wordsWithComputedWidth,s,o,l),f=u.length>i||ON(u).width>Number(s);return[f,u]},rL=(e,t,r,n,i)=>{var{maxLines:s,children:o,style:l,breakAll:c}=e,d=G(s),u=String(o),f=AN(t,n,r,i);if(!d||i)return f;var p=f.length>s||ON(f).width>Number(n);if(!p)return f;for(var m=0,x=u.length-1,g=0,v;m<=x&&g<=u.length-1;){var b=Math.floor((m+x)/2),j=b-1,[y,w]=ev(u,j,c,l,s,n,r,i),[S]=ev(u,b,c,l,s,n,r,i);if(!y&&!S&&(m=b+1),y&&S&&(x=b-1),!y&&S){v=w;break}g++}return v||f},tv=e=>{var t=Re(e)?[]:e.toString().split(PN);return[{words:t,width:void 0}]},nL=e=>{var{width:t,scaleToFit:r,children:n,style:i,breakAll:s,maxLines:o}=e;if((t||r)&&!Ci.isSsr){var l,c,d=CN({breakAll:s,children:n,style:i});if(d){var{wordsWithComputedWidth:u,spaceWidth:f}=d;l=u,c=f}else return tv(n);return rL({breakAll:s,children:n,maxLines:o,style:i},l,c,t,!!r)}return tv(n)},EN="#808080",iL={breakAll:!1,capHeight:"0.71em",fill:EN,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},ng=h.forwardRef((e,t)=>{var r=ft(e,iL),{x:n,y:i,lineHeight:s,capHeight:o,fill:l,scaleToFit:c,textAnchor:d,verticalAnchor:u}=r,f=Qy(r,X8),p=h.useMemo(()=>nL({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:c,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,c,f.style,f.width]),{dx:m,dy:x,angle:g,className:v,breakAll:b}=f,j=Qy(f,J8);if(!Or(n)||!Or(i)||p.length===0)return null;var y=Number(n)+(G(m)?m:0),w=Number(i)+(G(x)?x:0);if(!_e(y)||!_e(w))return null;var S;switch(u){case"start":S=Od("calc(".concat(o,")"));break;case"middle":S=Od("calc(".concat((p.length-1)/2," * -").concat(s," + (").concat(o," / 2))"));break;default:S=Od("calc(".concat(p.length-1," * -").concat(s,")"));break}var N=[];if(c){var P=p[0].width,{width:C}=f;N.push("scale(".concat(G(C)&&G(P)?C/P:1,")"))}return g&&N.push("rotate(".concat(g,", ").concat(y,", ").concat(w,")")),N.length&&(j.transform=N.join(" ")),h.createElement("text",vp({},ut(j),{ref:t,x:y,y:w,className:ue("recharts-text",v),textAnchor:d,fill:l.includes("url")?EN:l}),p.map((T,$)=>{var I=T.words.join(b?"":" ");return h.createElement("tspan",{x:y,dy:$===0?S:s,key:"".concat(I,"-").concat($)},I)}))});ng.displayName="Text";var aL=["labelRef"];function sL(e,t){if(e==null)return{};var r,n,i=oL(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n{var{x:t,y:r,upperWidth:n,lowerWidth:i,width:s,height:o,children:l}=e,c=h.useMemo(()=>({x:t,y:r,upperWidth:n,lowerWidth:i,width:s,height:o}),[t,r,n,i,s,o]);return h.createElement(DN.Provider,{value:c},l)},TN=()=>{var e=h.useContext(DN),t=mu();return e||Hw(t)},fL=h.createContext(null),pL=()=>{var e=h.useContext(fL),t=Z(c2);return e||t},hL=e=>{var{value:t,formatter:r}=e,n=Re(e.children)?t:e.children;return typeof r=="function"?r(n):n},ig=e=>e!=null&&typeof e=="function",mL=(e,t)=>{var r=Jt(t-e),n=Math.min(Math.abs(t-e),360);return r*n},gL=(e,t,r,n,i)=>{var{offset:s,className:o}=e,{cx:l,cy:c,innerRadius:d,outerRadius:u,startAngle:f,endAngle:p,clockWise:m}=i,x=(d+u)/2,g=mL(f,p),v=g>=0?1:-1,b,j;switch(t){case"insideStart":b=f+v*s,j=m;break;case"insideEnd":b=p-v*s,j=!m;break;case"end":b=p+v*s,j=m;break;default:throw new Error("Unsupported position ".concat(t))}j=g<=0?j:!j;var y=Je(l,c,x,b),w=Je(l,c,x,b+(j?1:-1)*359),S="M".concat(y.x,",").concat(y.y,` A`).concat(x,",").concat(x,",0,1,").concat(j?0:1,`, `).concat(w.x,",").concat(w.y),N=Re(e.id)?Is("recharts-radial-line-"):e.id;return h.createElement("text",Rr({},n,{dominantBaseline:"central",className:ue("recharts-radial-bar-label",o)}),h.createElement("defs",null,h.createElement("path",{id:N,d:S})),h.createElement("textPath",{xlinkHref:"#".concat(N)},r))},xL=(e,t,r)=>{var{cx:n,cy:i,innerRadius:s,outerRadius:o,startAngle:l,endAngle:c}=e,d=(l+c)/2;if(r==="outside"){var{x:u,y:f}=Je(n,i,o+t,d);return{x:u,y:f,textAnchor:u>=n?"start":"end",verticalAnchor:"middle"}}if(r==="center")return{x:n,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(r==="centerTop")return{x:n,y:i,textAnchor:"middle",verticalAnchor:"start"};if(r==="centerBottom")return{x:n,y:i,textAnchor:"middle",verticalAnchor:"end"};var p=(s+o)/2,{x:m,y:x}=Je(n,i,p,d);return{x:m,y:x,textAnchor:"middle",verticalAnchor:"middle"}},bp=e=>"cx"in e&&G(e.cx),yL=(e,t)=>{var{parentViewBox:r,offset:n,position:i}=e,s;r!=null&&!bp(r)&&(s=r);var{x:o,y:l,upperWidth:c,lowerWidth:d,height:u}=t,f=o,p=o+(c-d)/2,m=(f+p)/2,x=(c+d)/2,g=f+c/2,v=u>=0?1:-1,b=v*n,j=v>0?"end":"start",y=v>0?"start":"end",w=c>=0?1:-1,S=w*n,N=w>0?"end":"start",P=w>0?"start":"end";if(i==="top"){var C={x:f+c/2,y:l-b,textAnchor:"middle",verticalAnchor:j};return Pe(Pe({},C),s?{height:Math.max(l-s.y,0),width:c}:{})}if(i==="bottom"){var T={x:p+d/2,y:l+u+b,textAnchor:"middle",verticalAnchor:y};return Pe(Pe({},T),s?{height:Math.max(s.y+s.height-(l+u),0),width:d}:{})}if(i==="left"){var $={x:m-S,y:l+u/2,textAnchor:N,verticalAnchor:"middle"};return Pe(Pe({},$),s?{width:Math.max($.x-s.x,0),height:u}:{})}if(i==="right"){var I={x:m+x+S,y:l+u/2,textAnchor:P,verticalAnchor:"middle"};return Pe(Pe({},I),s?{width:Math.max(s.x+s.width-I.x,0),height:u}:{})}var A=s?{width:x,height:u}:{};return i==="insideLeft"?Pe({x:m+S,y:l+u/2,textAnchor:P,verticalAnchor:"middle"},A):i==="insideRight"?Pe({x:m+x-S,y:l+u/2,textAnchor:N,verticalAnchor:"middle"},A):i==="insideTop"?Pe({x:f+c/2,y:l+b,textAnchor:"middle",verticalAnchor:y},A):i==="insideBottom"?Pe({x:p+d/2,y:l+u-b,textAnchor:"middle",verticalAnchor:j},A):i==="insideTopLeft"?Pe({x:f+S,y:l+b,textAnchor:P,verticalAnchor:y},A):i==="insideTopRight"?Pe({x:f+c-S,y:l+b,textAnchor:N,verticalAnchor:y},A):i==="insideBottomLeft"?Pe({x:p+S,y:l+u-b,textAnchor:P,verticalAnchor:j},A):i==="insideBottomRight"?Pe({x:p+d-S,y:l+u-b,textAnchor:N,verticalAnchor:j},A):i&&typeof i=="object"&&(G(i.x)||Qr(i.x))&&(G(i.y)||Qr(i.y))?Pe({x:o+Rn(i.x,x),y:l+Rn(i.y,u),textAnchor:"end",verticalAnchor:"end"},A):Pe({x:g,y:l+u/2,textAnchor:"middle",verticalAnchor:"middle"},A)},vL={offset:5,zIndex:lt.label};function yn(e){var t=ft(e,vL),{viewBox:r,position:n,value:i,children:s,content:o,className:l="",textBreakAll:c,labelRef:d}=t,u=pL(),f=TN(),p=n==="center"?f:u??f,m,x,g;if(r==null?m=p:bp(r)?m=r:m=Hw(r),!m||Re(i)&&Re(s)&&!h.isValidElement(o)&&typeof o!="function")return null;var v=Pe(Pe({},t),{},{viewBox:m});if(h.isValidElement(o)){var{labelRef:b}=v,j=sL(v,aL);return h.cloneElement(o,j)}if(typeof o=="function"){if(x=h.createElement(o,v),h.isValidElement(x))return x}else x=hL(t);var y=ut(t);if(bp(m)){if(n==="insideStart"||n==="insideEnd"||n==="end")return gL(t,n,x,y,m);g=xL(m,t.offset,t.position)}else g=yL(t,m);return h.createElement(Ir,{zIndex:t.zIndex},h.createElement(ng,Rr({ref:d,className:ue("recharts-label",l)},y,g,{textAnchor:eL(y.textAnchor)?y.textAnchor:g.textAnchor,breakAll:c}),x))}yn.displayName="Label";var bL=(e,t,r)=>{if(!e)return null;var n={viewBox:t,labelRef:r};return e===!0?h.createElement(yn,Rr({key:"label-implicit"},n)):Or(e)?h.createElement(yn,Rr({key:"label-implicit",value:e},n)):h.isValidElement(e)?e.type===yn?h.cloneElement(e,Pe({key:"label-implicit"},n)):h.createElement(yn,Rr({key:"label-implicit",content:e},n)):ig(e)?h.createElement(yn,Rr({key:"label-implicit",content:e},n)):e&&typeof e=="object"?h.createElement(yn,Rr({},e,{key:"label-implicit"},n)):null};function jL(e){var{label:t,labelRef:r}=e,n=TN();return bL(t,n,r)||null}var MN={},IN={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r){return r[r.length-1]}e.last=t})(IN);var $N={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r){return Array.isArray(r)?r:Array.from(r)}e.toArray=t})($N);(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=IN,r=$N,n=nu;function i(s){if(n.isArrayLike(s))return t.last(r.toArray(s))}e.last=i})(MN);var wL=MN.last;const SL=Tr(wL);var NL=["valueAccessor"],kL=["dataKey","clockWise","id","textBreakAll","zIndex"];function vc(){return vc=Object.assign?Object.assign.bind():function(e){for(var t=1;tArray.isArray(e.value)?SL(e.value):e.value,LN=h.createContext(void 0),zN=LN.Provider,RN=h.createContext(void 0);RN.Provider;function CL(){return h.useContext(LN)}function AL(){return h.useContext(RN)}function fl(e){var{valueAccessor:t=PL}=e,r=nv(e,NL),{dataKey:n,clockWise:i,id:s,textBreakAll:o,zIndex:l}=r,c=nv(r,kL),d=CL(),u=AL(),f=d||u;return!f||!f.length?null:h.createElement(Ir,{zIndex:l??lt.label},h.createElement(ir,{className:"recharts-label-list"},f.map((p,m)=>{var x,g=Re(n)?t(p,m):et(p&&p.payload,n),v=Re(s)?{}:{id:"".concat(s,"-").concat(m)};return h.createElement(yn,vc({key:"label-".concat(m)},ut(p),c,v,{fill:(x=r.fill)!==null&&x!==void 0?x:p.fill,parentViewBox:p.parentViewBox,value:g,textBreakAll:o,viewBox:p.viewBox,index:m,zIndex:0}))})))}fl.displayName="LabelList";function BN(e){var{label:t}=e;return t?t===!0?h.createElement(fl,{key:"labelList-implicit"}):h.isValidElement(t)||ig(t)?h.createElement(fl,{key:"labelList-implicit",content:t}):typeof t=="object"?h.createElement(fl,vc({key:"labelList-implicit"},t,{type:String(t.type)})):null:null}function jp(){return jp=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{cx:t,cy:r,r:n,className:i}=e,s=ue("recharts-dot",i);return G(t)&&G(r)&&G(n)?h.createElement("circle",jp({},nr(e),Bh(e),{className:s,cx:t,cy:r,r:n})):null},OL={radiusAxis:{},angleAxis:{}},WN=At({name:"polarAxis",initialState:OL,reducers:{addRadiusAxis(e,t){e.radiusAxis[t.payload.id]=t.payload},removeRadiusAxis(e,t){delete e.radiusAxis[t.payload.id]},addAngleAxis(e,t){e.angleAxis[t.payload.id]=t.payload},removeAngleAxis(e,t){delete e.angleAxis[t.payload.id]}}}),{addRadiusAxis:RF,removeRadiusAxis:BF,addAngleAxis:FF,removeAngleAxis:WF}=WN.actions,EL=WN.reducer,ag=e=>e&&typeof e=="object"&&"clipDot"in e?!!e.clipDot:!0,UN={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r){var i;if(typeof r!="object"||r==null)return!1;if(Object.getPrototypeOf(r)===null)return!0;if(Object.prototype.toString.call(r)!=="[object Object]"){const s=r[Symbol.toStringTag];return s==null||!((i=Object.getOwnPropertyDescriptor(r,Symbol.toStringTag))!=null&&i.writable)?!1:r.toString()===`[object ${s}]`}let n=r;for(;Object.getPrototypeOf(n)!==null;)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(r)===n}e.isPlainObject=t})(UN);var DL=UN.isPlainObject;const TL=Tr(DL);function iv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function av(e){for(var t=1;t{var s=r-n,o;return o="M ".concat(e,",").concat(t),o+="L ".concat(e+r,",").concat(t),o+="L ".concat(e+r-s/2,",").concat(t+i),o+="L ".concat(e+r-s/2-n,",").concat(t+i),o+="L ".concat(e,",").concat(t," Z"),o},LL={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},zL=e=>{var t=ft(e,LL),{x:r,y:n,upperWidth:i,lowerWidth:s,height:o,className:l}=t,{animationEasing:c,animationDuration:d,animationBegin:u,isUpdateAnimationActive:f}=t,p=h.useRef(null),[m,x]=h.useState(-1),g=h.useRef(i),v=h.useRef(s),b=h.useRef(o),j=h.useRef(r),y=h.useRef(n),w=yu(e,"trapezoid-");if(h.useEffect(()=>{if(p.current&&p.current.getTotalLength)try{var H=p.current.getTotalLength();H&&x(H)}catch{}},[]),r!==+r||n!==+n||i!==+i||s!==+s||o!==+o||i===0&&s===0||o===0)return null;var S=ue("recharts-trapezoid",l);if(!f)return h.createElement("g",null,h.createElement("path",bc({},ut(t),{className:S,d:sv(r,n,i,s,o)})));var N=g.current,P=v.current,C=b.current,T=j.current,$=y.current,I="0px ".concat(m===-1?1:m,"px"),A="".concat(m,"px 0px"),R=Xw(["strokeDasharray"],d,c);return h.createElement(xu,{animationId:w,key:w,canBegin:m>0,duration:d,easing:c,isActive:f,begin:u},H=>{var M=Ee(N,i,H),_=Ee(P,s,H),D=Ee(C,o,H),O=Ee(T,r,H),k=Ee($,n,H);p.current&&(g.current=M,v.current=_,b.current=D,j.current=O,y.current=k);var z=H>0?{transition:R,strokeDasharray:A}:{strokeDasharray:I};return h.createElement("path",bc({},ut(t),{className:S,d:sv(O,k,M,_,D),ref:p,style:av(av({},z),t.style)}))})},RL=["option","shapeType","propTransformer","activeClassName","isActive"];function BL(e,t){if(e==null)return{};var r,n,i=FL(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n{if(!i){var s=t(r);return n(EI(s)),()=>{n(DI(s))}}},[t,r,n,i]),null}function HN(e){var{legendPayload:t}=e,r=Ye(),n=pt();return h.useLayoutEffect(()=>n?Pa:(r(h3(t)),()=>{r(m3(t))}),[r,n,t]),null}var Ed,GL=()=>{var[e]=h.useState(()=>Is("uid-"));return e},ZL=(Ed=zv.useId)!==null&&Ed!==void 0?Ed:GL;function KN(e,t){var r=ZL();return t||(e?"".concat(e,"-").concat(r):r)}var XL=h.createContext(void 0),VN=e=>{var{id:t,type:r,children:n}=e,i=KN("recharts-".concat(r),t);return h.createElement(XL.Provider,{value:i},n(i))},JL={cartesianItems:[],polarItems:[]},YN=At({name:"graphicalItems",initialState:JL,reducers:{addCartesianGraphicalItem:{reducer(e,t){e.cartesianItems.push(t.payload)},prepare:Le()},replaceCartesianGraphicalItem:{reducer(e,t){var{prev:r,next:n}=t.payload,i=Kr(e).cartesianItems.indexOf(r);i>-1&&(e.cartesianItems[i]=n)},prepare:Le()},removeCartesianGraphicalItem:{reducer(e,t){var r=Kr(e).cartesianItems.indexOf(t.payload);r>-1&&e.cartesianItems.splice(r,1)},prepare:Le()},addPolarGraphicalItem:{reducer(e,t){e.polarItems.push(t.payload)},prepare:Le()},removePolarGraphicalItem:{reducer(e,t){var r=Kr(e).polarItems.indexOf(t.payload);r>-1&&e.polarItems.splice(r,1)},prepare:Le()}}}),{addCartesianGraphicalItem:QL,replaceCartesianGraphicalItem:ez,removeCartesianGraphicalItem:tz,addPolarGraphicalItem:UF,removePolarGraphicalItem:qF}=YN.actions,rz=YN.reducer;function GN(e){var t=Ye(),r=h.useRef(null);return h.useLayoutEffect(()=>{r.current===null?t(QL(e)):r.current!==e&&t(ez({prev:r.current,next:e})),r.current=e},[t,e]),h.useLayoutEffect(()=>()=>{r.current&&(t(tz(r.current)),r.current=null)},[t]),null}var nz=["points"];function cv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Dd(e){for(var t=1;t{var v,b,j=Dd(Dd(Dd({r:3},o),f),{},{index:g,cx:(v=x.x)!==null&&v!==void 0?v:void 0,cy:(b=x.y)!==null&&b!==void 0?b:void 0,dataKey:s,value:x.value,payload:x.payload,points:t});return h.createElement(cz,{key:"dot-".concat(g),option:r,dotProps:j,className:i})}),m={};return l&&c!=null&&(m.clipPath="url(#clipPath-".concat(u?"":"dots-").concat(c,")")),h.createElement(Ir,{zIndex:d},h.createElement(ir,wc({className:n},m),p))}function uv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function dv(e){for(var t=1;t({top:e.top,bottom:e.bottom,left:e.left,right:e.right})),wz=L([jz,ln,cn],(e,t,r)=>{if(!(!e||t==null||r==null))return{x:e.left,y:e.top,width:Math.max(0,t-e.left-e.right),height:Math.max(0,r-e.top-e.bottom)}}),Ru=()=>Z(wz),Sz=()=>Z(j$);function fv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Td(e){for(var t=1;t{var{point:t,childIndex:r,mainColor:n,activeDot:i,dataKey:s}=e;if(i===!1||t.x==null||t.y==null)return null;var o={index:r,dataKey:s,cx:t.x,cy:t.y,r:4,fill:n??"none",strokeWidth:2,stroke:"#fff",payload:t.payload,value:t.value},l=Td(Td(Td({},o),Gc(i)),Bh(i)),c;return h.isValidElement(i)?c=h.cloneElement(i,l):typeof i=="function"?c=i(l):c=h.createElement(FN,l),h.createElement(ir,{className:"recharts-active-dot"},c)};function wp(e){var{points:t,mainColor:r,activeDot:n,itemDataKey:i,zIndex:s=lt.activeDot}=e,o=Z(Hs),l=Sz();if(t==null||l==null)return null;var c=t.find(d=>l.includes(d.payload));return Re(c)?null:h.createElement(Ir,{zIndex:s},h.createElement(Pz,{point:c,childIndex:Number(o),mainColor:r,dataKey:i,activeDot:n}))}var Cz={},JN=At({name:"errorBars",initialState:Cz,reducers:{addErrorBar:(e,t)=>{var{itemId:r,errorBar:n}=t.payload;e[r]||(e[r]=[]),e[r].push(n)},replaceErrorBar:(e,t)=>{var{itemId:r,prev:n,next:i}=t.payload;e[r]&&(e[r]=e[r].map(s=>s.dataKey===n.dataKey&&s.direction===n.direction?i:s))},removeErrorBar:(e,t)=>{var{itemId:r,errorBar:n}=t.payload;e[r]&&(e[r]=e[r].filter(i=>i.dataKey!==n.dataKey||i.direction!==n.direction))}}}),{addErrorBar:VF,replaceErrorBar:YF,removeErrorBar:GF}=JN.actions,Az=JN.reducer,Oz=["children"];function Ez(e,t){if(e==null)return{};var r,n,i=Dz(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n({x:0,y:0,value:0}),errorBarOffset:0},Mz=h.createContext(Tz);function Iz(e){var{children:t}=e,r=Ez(e,Oz);return h.createElement(Mz.Provider,{value:r},t)}function sg(e,t){var r,n,i=Z(d=>dn(d,e)),s=Z(d=>fn(d,t)),o=(r=i==null?void 0:i.allowDataOverflow)!==null&&r!==void 0?r:Tt.allowDataOverflow,l=(n=s==null?void 0:s.allowDataOverflow)!==null&&n!==void 0?n:Mt.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function QN(e){var{xAxisId:t,yAxisId:r,clipPathId:n}=e,i=Ru(),{needClipX:s,needClipY:o,needClip:l}=sg(t,r);if(!l||!i)return null;var{x:c,y:d,width:u,height:f}=i;return h.createElement("clipPath",{id:"clipPath-".concat(n)},h.createElement("rect",{x:s?c:c-u/2,y:o?d:d-f/2,width:s?u:u*2,height:o?f:f*2}))}var $z=e=>{var{chartData:t}=e,r=Ye(),n=pt();return h.useEffect(()=>n?()=>{}:(r(By(t)),()=>{r(By(void 0))}),[t,r,n]),null},pv={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},ek=At({name:"brush",initialState:pv,reducers:{setBrushSettings(e,t){return t.payload==null?pv:t.payload}}}),{setBrushSettings:ZF}=ek.actions,Lz=ek.reducer;function zz(e,t,r){return(t=Rz(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Rz(e){var t=Bz(e,"string");return typeof t=="symbol"?t:t+""}function Bz(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}class og{static create(t){return new og(t)}constructor(t){this.scale=t}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(t){var{bandAware:r,position:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(t!==void 0){if(n)switch(n){case"start":return this.scale(t);case"middle":{var i=this.bandwidth?this.bandwidth()/2:0;return this.scale(t)+i}case"end":{var s=this.bandwidth?this.bandwidth():0;return this.scale(t)+s}default:return this.scale(t)}if(r){var o=this.bandwidth?this.bandwidth()/2:0;return this.scale(t)+o}return this.scale(t)}}isInRange(t){var r=this.range(),n=r[0],i=r[r.length-1];return n<=i?t>=n&&t<=i:t>=i&&t<=n}}zz(og,"EPS",1e-4);function Fz(e){return(e%180+180)%180}var Wz=function(t){var{width:r,height:n}=t,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=Fz(i),o=s*Math.PI/180,l=Math.atan(n/r),c=o>l&&o{e.dots.push(t.payload)},removeDot:(e,t)=>{var r=Kr(e).dots.findIndex(n=>n===t.payload);r!==-1&&e.dots.splice(r,1)},addArea:(e,t)=>{e.areas.push(t.payload)},removeArea:(e,t)=>{var r=Kr(e).areas.findIndex(n=>n===t.payload);r!==-1&&e.areas.splice(r,1)},addLine:(e,t)=>{e.lines.push(t.payload)},removeLine:(e,t)=>{var r=Kr(e).lines.findIndex(n=>n===t.payload);r!==-1&&e.lines.splice(r,1)}}}),{addDot:XF,removeDot:JF,addArea:QF,removeArea:e7,addLine:t7,removeLine:r7}=tk.actions,qz=tk.reducer,Hz=h.createContext(void 0),Kz=e=>{var{children:t}=e,[r]=h.useState("".concat(Is("recharts"),"-clip")),n=Ru();if(n==null)return null;var{x:i,y:s,width:o,height:l}=n;return h.createElement(Hz.Provider,{value:r},h.createElement("defs",null,h.createElement("clipPath",{id:r},h.createElement("rect",{x:i,y:s,height:l,width:o}))),t)};function ba(e,t){for(var r in e)if({}.hasOwnProperty.call(e,r)&&(!{}.hasOwnProperty.call(t,r)||e[r]!==t[r]))return!1;for(var n in t)if({}.hasOwnProperty.call(t,n)&&!{}.hasOwnProperty.call(e,n))return!1;return!0}function rk(e,t){if(t<1)return[];if(t===1)return e;for(var r=[],n=0;ne*i)return!1;var s=r();return e*(t-e*s/2-n)>=0&&e*(t+e*s/2-i)<=0}function Gz(e,t){return rk(e,t+1)}function Zz(e,t,r,n,i){for(var s=(n||[]).slice(),{start:o,end:l}=t,c=0,d=1,u=o,f=function(){var x=n==null?void 0:n[c];if(x===void 0)return{v:rk(n,d)};var g=c,v,b=()=>(v===void 0&&(v=r(x,g)),v),j=x.coordinate,y=c===0||Sc(e,j,b,u,l);y||(c=0,u=o,d+=1),y&&(u=j+e*(b()/2+i),c+=d)},p;d<=s.length;)if(p=f(),p)return p.v;return[]}function hv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function at(e){for(var t=1;t(x===void 0&&(x=r(m,p)),x);if(p===o-1){var v=e*(m.coordinate+e*g()/2-c);s[p]=m=at(at({},m),{},{tickCoord:v>0?m.coordinate-v*e:m.coordinate})}else s[p]=m=at(at({},m),{},{tickCoord:m.coordinate});if(m.tickCoord!=null){var b=Sc(e,m.tickCoord,g,l,c);b&&(c=m.tickCoord-e*(g()/2+i),s[p]=at(at({},m),{},{isShow:!0}))}},u=o-1;u>=0;u--)d(u);return s}function tR(e,t,r,n,i,s){var o=(n||[]).slice(),l=o.length,{start:c,end:d}=t;if(s){var u=n[l-1],f=r(u,l-1),p=e*(u.coordinate+e*f/2-d);if(o[l-1]=u=at(at({},u),{},{tickCoord:p>0?u.coordinate-p*e:u.coordinate}),u.tickCoord!=null){var m=Sc(e,u.tickCoord,()=>f,c,d);m&&(d=u.tickCoord-e*(f/2+i),o[l-1]=at(at({},u),{},{isShow:!0}))}}for(var x=s?l-1:l,g=function(j){var y=o[j],w,S=()=>(w===void 0&&(w=r(y,j)),w);if(j===0){var N=e*(y.coordinate-e*S()/2-c);o[j]=y=at(at({},y),{},{tickCoord:N<0?y.coordinate-N*e:y.coordinate})}else o[j]=y=at(at({},y),{},{tickCoord:y.coordinate});if(y.tickCoord!=null){var P=Sc(e,y.tickCoord,S,c,d);P&&(c=y.tickCoord+e*(S()/2+i),o[j]=at(at({},y),{},{isShow:!0}))}},v=0;v{var S=typeof d=="function"?d(y.value,w):y.value;return x==="width"?Vz(ps(S,{fontSize:t,letterSpacing:r}),g,f):ps(S,{fontSize:t,letterSpacing:r})[x]},b=i.length>=2?Jt(i[1].coordinate-i[0].coordinate):1,j=Yz(s,b,x);return c==="equidistantPreserveStart"?Zz(b,j,v,i,o):(c==="preserveStart"||c==="preserveStartEnd"?m=tR(b,j,v,i,o,c==="preserveStartEnd"):m=eR(b,j,v,i,o),m.filter(y=>y.isShow))}var rR=e=>{var{ticks:t,label:r,labelGapWithTick:n=5,tickSize:i=0,tickMargin:s=0}=e,o=0;if(t){Array.from(t).forEach(u=>{if(u){var f=u.getBoundingClientRect();f.width>o&&(o=f.width)}});var l=r?r.getBoundingClientRect().width:0,c=i+s,d=o+c+l+(r?n:0);return Math.round(d)}return 0},nR=["axisLine","width","height","className","hide","ticks","axisType"],iR=["viewBox"],aR=["viewBox"];function Sp(e,t){if(e==null)return{};var r,n,i=sR(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n{var{ticks:r=[],tick:n,tickLine:i,stroke:s,tickFormatter:o,unit:l,padding:c,tickTextProps:d,orientation:u,mirror:f,x:p,y:m,width:x,height:g,tickSize:v,tickMargin:b,fontSize:j,letterSpacing:y,getTicksConfig:w,events:S,axisType:N}=e,P=lg(Oe(Oe({},w),{},{ticks:r}),j,y),C=fR(u,f),T=pR(u,f),$=nr(w),I=Gc(n),A={};typeof i=="object"&&(A=i);var R=Oe(Oe({},$),{},{fill:"none"},A),H=P.map(D=>Oe({entry:D},dR(D,p,m,x,g,u,v,f,b))),M=H.map(D=>{var{entry:O,line:k}=D;return h.createElement(ir,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(O.value,"-").concat(O.coordinate,"-").concat(O.tickCoord)},i&&h.createElement("line",Si({},R,k,{className:ue("recharts-cartesian-axis-tick-line",ru(i,"className"))})))}),_=H.map((D,O)=>{var{entry:k,tick:z}=D,W=Oe(Oe(Oe(Oe({textAnchor:C,verticalAnchor:T},$),{},{stroke:"none",fill:s},I),z),{},{index:O,payload:k,visibleTicksCount:P.length,tickFormatter:o,padding:c},d);return h.createElement(ir,Si({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(k.value,"-").concat(k.coordinate,"-").concat(k.tickCoord)},iO(S,k,O)),n&&h.createElement(hR,{option:n,tickProps:W,value:"".concat(typeof o=="function"?o(k.value,O):k.value).concat(l||"")}))});return h.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(N,"-ticks")},_.length>0&&h.createElement(Ir,{zIndex:lt.label},h.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(N,"-tick-labels"),ref:t},_)),M.length>0&&h.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(N,"-tick-lines")},M))}),gR=h.forwardRef((e,t)=>{var{axisLine:r,width:n,height:i,className:s,hide:o,ticks:l,axisType:c}=e,d=Sp(e,nR),[u,f]=h.useState(""),[p,m]=h.useState(""),x=h.useRef(null);h.useImperativeHandle(t,()=>({getCalculatedWidth:()=>{var v;return rR({ticks:x.current,label:(v=e.labelRef)===null||v===void 0?void 0:v.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}}));var g=h.useCallback(v=>{if(v){var b=v.getElementsByClassName("recharts-cartesian-axis-tick-value");x.current=b;var j=b[0];if(j){var y=window.getComputedStyle(j),w=y.fontSize,S=y.letterSpacing;(w!==u||S!==p)&&(f(w),m(S))}}},[u,p]);return o||n!=null&&n<=0||i!=null&&i<=0?null:h.createElement(Ir,{zIndex:e.zIndex},h.createElement(ir,{className:ue("recharts-cartesian-axis",s)},h.createElement(uR,{x:e.x,y:e.y,width:n,height:i,orientation:e.orientation,mirror:e.mirror,axisLine:r,otherSvgProps:nr(e)}),h.createElement(mR,{ref:g,axisType:c,events:d,fontSize:u,getTicksConfig:e,height:e.height,letterSpacing:p,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:l,unit:e.unit,width:e.width,x:e.x,y:e.y}),h.createElement(dL,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},h.createElement(jL,{label:e.label,labelRef:e.labelRef}),e.children)))}),xR=h.memo(gR,(e,t)=>{var{viewBox:r}=e,n=Sp(e,iR),{viewBox:i}=t,s=Sp(t,aR);return ba(r,i)&&ba(n,s)}),ug=h.forwardRef((e,t)=>{var r=ft(e,cg);return h.createElement(xR,Si({},r,{ref:t}))});ug.displayName="CartesianAxis";var yR=["x1","y1","x2","y2","key"],vR=["offset"],bR=["xAxisId","yAxisId"],jR=["xAxisId","yAxisId"];function gv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function ot(e){for(var t=1;t{var{fill:t}=e;if(!t||t==="none")return null;var{fillOpacity:r,x:n,y:i,width:s,height:o,ry:l}=e;return h.createElement("rect",{x:n,y:i,ry:l,width:s,height:o,stroke:"none",fill:t,fillOpacity:r,className:"recharts-cartesian-grid-bg"})};function nk(e){var{option:t,lineItemProps:r}=e,n;if(h.isValidElement(t))n=h.cloneElement(t,r);else if(typeof t=="function")n=t(r);else{var i,{x1:s,y1:o,x2:l,y2:c,key:d}=r,u=Nc(r,yR),f=(i=nr(u))!==null&&i!==void 0?i:{},{offset:p}=f,m=Nc(f,vR);n=h.createElement("line",ai({},m,{x1:s,y1:o,x2:l,y2:c,fill:"none",key:d}))}return n}function PR(e){var{x:t,width:r,horizontal:n=!0,horizontalPoints:i}=e;if(!n||!i||!i.length)return null;var{xAxisId:s,yAxisId:o}=e,l=Nc(e,bR),c=i.map((d,u)=>{var f=ot(ot({},l),{},{x1:t,y1:d,x2:t+r,y2:d,key:"line-".concat(u),index:u});return h.createElement(nk,{key:"line-".concat(u),option:n,lineItemProps:f})});return h.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function CR(e){var{y:t,height:r,vertical:n=!0,verticalPoints:i}=e;if(!n||!i||!i.length)return null;var{xAxisId:s,yAxisId:o}=e,l=Nc(e,jR),c=i.map((d,u)=>{var f=ot(ot({},l),{},{x1:d,y1:t,x2:d,y2:t+r,key:"line-".concat(u),index:u});return h.createElement(nk,{option:n,lineItemProps:f,key:"line-".concat(u)})});return h.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function AR(e){var{horizontalFill:t,fillOpacity:r,x:n,y:i,width:s,height:o,horizontalPoints:l,horizontal:c=!0}=e;if(!c||!t||!t.length||l==null)return null;var d=l.map(f=>Math.round(f+i-i)).sort((f,p)=>f-p);i!==d[0]&&d.unshift(0);var u=d.map((f,p)=>{var m=!d[p+1],x=m?i+o-f:d[p+1]-f;if(x<=0)return null;var g=p%t.length;return h.createElement("rect",{key:"react-".concat(p),y:f,x:n,height:x,width:s,stroke:"none",fill:t[g],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return h.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},u)}function OR(e){var{vertical:t=!0,verticalFill:r,fillOpacity:n,x:i,y:s,width:o,height:l,verticalPoints:c}=e;if(!t||!r||!r.length)return null;var d=c.map(f=>Math.round(f+i-i)).sort((f,p)=>f-p);i!==d[0]&&d.unshift(0);var u=d.map((f,p)=>{var m=!d[p+1],x=m?i+o-f:d[p+1]-f;if(x<=0)return null;var g=p%r.length;return h.createElement("rect",{key:"react-".concat(p),x:f,y:s,width:x,height:l,stroke:"none",fill:r[g],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return h.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},u)}var ER=(e,t)=>{var{xAxis:r,width:n,height:i,offset:s}=e;return Iw(lg(ot(ot(ot({},cg),r),{},{ticks:$w(r),viewBox:{x:0,y:0,width:n,height:i}})),s.left,s.left+s.width,t)},DR=(e,t)=>{var{yAxis:r,width:n,height:i,offset:s}=e;return Iw(lg(ot(ot(ot({},cg),r),{},{ticks:$w(r),viewBox:{x:0,y:0,width:n,height:i}})),s.top,s.top+s.height,t)},TR={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:lt.grid};function Np(e){var t=Vw(),r=Yw(),n=Kw(),i=ot(ot({},ft(e,TR)),{},{x:G(e.x)?e.x:n.left,y:G(e.y)?e.y:n.top,width:G(e.width)?e.width:n.width,height:G(e.height)?e.height:n.height}),{xAxisId:s,yAxisId:o,x:l,y:c,width:d,height:u,syncWithTicks:f,horizontalValues:p,verticalValues:m}=i,x=pt(),g=Z(T=>Ay(T,"xAxis",s,x)),v=Z(T=>Ay(T,"yAxis",o,x));if(!Er(d)||!Er(u)||!G(l)||!G(c))return null;var b=i.verticalCoordinatesGenerator||ER,j=i.horizontalCoordinatesGenerator||DR,{horizontalPoints:y,verticalPoints:w}=i;if((!y||!y.length)&&typeof j=="function"){var S=p&&p.length,N=j({yAxis:v?ot(ot({},v),{},{ticks:S?p:v.ticks}):void 0,width:t??d,height:r??u,offset:n},S?!0:f);ec(Array.isArray(N),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof N,"]")),Array.isArray(N)&&(y=N)}if((!w||!w.length)&&typeof b=="function"){var P=m&&m.length,C=b({xAxis:g?ot(ot({},g),{},{ticks:P?m:g.ticks}):void 0,width:t??d,height:r??u,offset:n},P?!0:f);ec(Array.isArray(C),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof C,"]")),Array.isArray(C)&&(w=C)}return h.createElement(Ir,{zIndex:i.zIndex},h.createElement("g",{className:"recharts-cartesian-grid"},h.createElement(_R,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),h.createElement(AR,ai({},i,{horizontalPoints:y})),h.createElement(OR,ai({},i,{verticalPoints:w})),h.createElement(PR,ai({},i,{offset:n,horizontalPoints:y,xAxis:g,yAxis:v})),h.createElement(CR,ai({},i,{offset:n,verticalPoints:w,xAxis:g,yAxis:v}))))}Np.displayName="CartesianGrid";var ik=(e,t,r,n)=>Lu(e,"xAxis",t,n),ak=(e,t,r,n)=>$u(e,"xAxis",t,n),sk=(e,t,r,n)=>Lu(e,"yAxis",r,n),ok=(e,t,r,n)=>$u(e,"yAxis",r,n),MR=L([de,ik,sk,ak,ok],(e,t,r,n,i)=>Mr(e,"xAxis")?ga(t,n,!1):ga(r,i,!1)),IR=(e,t,r,n,i)=>i;function $R(e){return e.type==="line"}var LR=L([Rm,IR],(e,t)=>e.filter($R).find(r=>r.id===t)),zR=L([de,ik,sk,ak,ok,LR,MR,ku],(e,t,r,n,i,s,o,l)=>{var{chartData:c,dataStartIndex:d,dataEndIndex:u}=l;if(!(s==null||t==null||r==null||n==null||i==null||n.length===0||i.length===0||o==null)){var{dataKey:f,data:p}=s,m;if(p!=null&&p.length>0?m=p:m=c==null?void 0:c.slice(d,u+1),m!=null)return i9({layout:e,xAxis:t,yAxis:r,xAxisTicks:n,yAxisTicks:i,dataKey:f,bandSize:o,displayedData:m})}});function lk(e){var t=Gc(e),r=3,n=2;if(t!=null){var{r:i,strokeWidth:s}=t,o=Number(i),l=Number(s);return(Number.isNaN(o)||o<0)&&(o=r),(Number.isNaN(l)||l<0)&&(l=n),{r:o,strokeWidth:l}}return{r,strokeWidth:n}}var RR=["id"],BR=["type","layout","connectNulls","needClip","shape"],FR=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function Vs(){return Vs=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{dataKey:t,name:r,stroke:n,legendType:i,hide:s}=e;return[{inactive:s,dataKey:t,type:i,color:n,value:uu(r,t),payload:e}]};function VR(e){var{dataKey:t,data:r,stroke:n,strokeWidth:i,fill:s,name:o,hide:l,unit:c}=e;return{dataDefinedOnItem:r,positions:void 0,settings:{stroke:n,strokeWidth:i,fill:s,dataKey:t,nameKey:void 0,name:uu(o,t),hide:l,type:e.tooltipType,color:e.stroke,unit:c}}}var ck=(e,t)=>"".concat(t,"px ").concat(e-t,"px");function YR(e,t){for(var r=e.length%2!==0?[...e,0]:e,n=[],i=0;i{var n=r.reduce((f,p)=>f+p);if(!n)return ck(t,e);for(var i=Math.floor(e/n),s=e%n,o=t-e,l=[],c=0,d=0;cs){l=[...r.slice(0,c),s-d];break}var u=l.length%2===0?[0,o]:[o];return[...YR(r,i),...l,...u].map(f=>"".concat(f,"px")).join(", ")};function ZR(e){var{clipPathId:t,points:r,props:n}=e,{dot:i,dataKey:s,needClip:o}=n,{id:l}=n,c=dg(n,RR),d=nr(c);return h.createElement(ZN,{points:r,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:s,baseProps:d,needClip:o,clipPathId:t})}function XR(e){var{showLabels:t,children:r,points:n}=e,i=h.useMemo(()=>n==null?void 0:n.map(s=>{var o,l,c={x:(o=s.x)!==null&&o!==void 0?o:0,y:(l=s.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return wr(wr({},c),{},{value:s.value,payload:s.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[n]);return h.createElement(zN,{value:t?i:void 0},r)}function yv(e){var{clipPathId:t,pathRef:r,points:n,strokeDasharray:i,props:s}=e,{type:o,layout:l,connectNulls:c,needClip:d,shape:u}=s,f=dg(s,BR),p=wr(wr({},ut(f)),{},{fill:"none",className:"recharts-line-curve",clipPath:d?"url(#clipPath-".concat(t,")"):void 0,points:n,type:o,layout:l,connectNulls:c,strokeDasharray:i??s.strokeDasharray});return h.createElement(h.Fragment,null,(n==null?void 0:n.length)>1&&h.createElement(YL,Vs({shapeType:"curve",option:u},p,{pathRef:r})),h.createElement(ZR,{points:n,clipPathId:t,props:s}))}function JR(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function QR(e){var{clipPathId:t,props:r,pathRef:n,previousPointsRef:i,longestAnimatedLengthRef:s}=e,{points:o,strokeDasharray:l,isAnimationActive:c,animationBegin:d,animationDuration:u,animationEasing:f,animateNewValues:p,width:m,height:x,onAnimationEnd:g,onAnimationStart:v}=r,b=i.current,j=yu(r,"recharts-line-"),[y,w]=h.useState(!1),S=!y,N=h.useCallback(()=>{typeof g=="function"&&g(),w(!1)},[g]),P=h.useCallback(()=>{typeof v=="function"&&v(),w(!0)},[v]),C=JR(n.current),T=s.current;return h.createElement(XR,{points:o,showLabels:S},r.children,h.createElement(xu,{animationId:j,begin:d,duration:u,isActive:c,easing:f,onAnimationEnd:N,onAnimationStart:P,key:j},$=>{var I=Ee(T,C+T,$),A=Math.min(I,C),R;if(c)if(l){var H="".concat(l).split(/[,\s]+/gim).map(D=>parseFloat(D));R=GR(A,C,H)}else R=ck(C,A);else R=l==null?void 0:String(l);if(b){var M=b.length/o.length,_=$===1?o:o.map((D,O)=>{var k=Math.floor(O*M);if(b[k]){var z=b[k];return wr(wr({},D),{},{x:Ee(z.x,D.x,$),y:Ee(z.y,D.y,$)})}return p?wr(wr({},D),{},{x:Ee(m*2,D.x,$),y:Ee(x/2,D.y,$)}):wr(wr({},D),{},{x:D.x,y:D.y})});return i.current=_,h.createElement(yv,{props:r,points:_,clipPathId:t,pathRef:n,strokeDasharray:R})}return $>0&&C>0&&(i.current=o,s.current=A),h.createElement(yv,{props:r,points:o,clipPathId:t,pathRef:n,strokeDasharray:R})}),h.createElement(BN,{label:r.label}))}function e9(e){var{clipPathId:t,props:r}=e,n=h.useRef(null),i=h.useRef(0),s=h.useRef(null);return h.createElement(QR,{props:r,clipPathId:t,previousPointsRef:n,longestAnimatedLengthRef:i,pathRef:s})}var t9=(e,t)=>{var r,n;return{x:(r=e.x)!==null&&r!==void 0?r:void 0,y:(n=e.y)!==null&&n!==void 0?n:void 0,value:e.value,errorVal:et(e.payload,t)}};class r9 extends h.Component{render(){var{hide:t,dot:r,points:n,className:i,xAxisId:s,yAxisId:o,top:l,left:c,width:d,height:u,id:f,needClip:p,zIndex:m}=this.props;if(t)return null;var x=ue("recharts-line",i),g=f,{r:v,strokeWidth:b}=lk(r),j=ag(r),y=v*2+b;return h.createElement(Ir,{zIndex:m},h.createElement(ir,{className:x},p&&h.createElement("defs",null,h.createElement(QN,{clipPathId:g,xAxisId:s,yAxisId:o}),!j&&h.createElement("clipPath",{id:"clipPath-dots-".concat(g)},h.createElement("rect",{x:c-y/2,y:l-y/2,width:d+y,height:u+y}))),h.createElement(Iz,{xAxisId:s,yAxisId:o,data:n,dataPointFormatter:t9,errorBarOffset:0},h.createElement(e9,{props:this.props,clipPathId:g}))),h.createElement(wp,{activeDot:this.props.activeDot,points:n,mainColor:this.props.stroke,itemDataKey:this.props.dataKey}))}}var uk={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:!Ci.isSsr,label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:lt.line};function n9(e){var t=ft(e,uk),{activeDot:r,animateNewValues:n,animationBegin:i,animationDuration:s,animationEasing:o,connectNulls:l,dot:c,hide:d,isAnimationActive:u,label:f,legendType:p,xAxisId:m,yAxisId:x,id:g}=t,v=dg(t,FR),{needClip:b}=sg(m,x),j=Ru(),y=no(),w=pt(),S=Z($=>zR($,m,x,w,g));if(y!=="horizontal"&&y!=="vertical"||S==null||j==null)return null;var{height:N,width:P,x:C,y:T}=j;return h.createElement(r9,Vs({},v,{id:g,connectNulls:l,dot:c,activeDot:r,animateNewValues:n,animationBegin:i,animationDuration:s,animationEasing:o,isAnimationActive:u,hide:d,label:f,legendType:p,xAxisId:m,yAxisId:x,points:S,layout:y,height:N,width:P,left:C,top:T,needClip:b}))}function i9(e){var{layout:t,xAxis:r,yAxis:n,xAxisTicks:i,yAxisTicks:s,dataKey:o,bandSize:l,displayedData:c}=e;return c.map((d,u)=>{var f=et(d,o);if(t==="horizontal"){var p=Ql({axis:r,ticks:i,bandSize:l,entry:d,index:u}),m=Re(f)?null:n.scale(f);return{x:p,y:m,value:f,payload:d}}var x=Re(f)?null:r.scale(f),g=Ql({axis:n,ticks:s,bandSize:l,entry:d,index:u});return x==null||g==null?null:{x,y:g,value:f,payload:d}}).filter(Boolean)}function a9(e){var t=ft(e,uk),r=pt();return h.createElement(VN,{id:t.id,type:"line"},n=>h.createElement(h.Fragment,null,h.createElement(HN,{legendPayload:KR(t)}),h.createElement(qN,{fn:VR,args:t}),h.createElement(GN,{type:"line",id:n,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:r}),h.createElement(n9,Vs({},t,{id:n}))))}var dk=h.memo(a9);dk.displayName="Line";var fk=(e,t,r,n)=>Lu(e,"xAxis",t,n),pk=(e,t,r,n)=>$u(e,"xAxis",t,n),hk=(e,t,r,n)=>Lu(e,"yAxis",r,n),mk=(e,t,r,n)=>$u(e,"yAxis",r,n),s9=L([de,fk,hk,pk,mk],(e,t,r,n,i)=>Mr(e,"xAxis")?ga(t,n,!1):ga(r,i,!1)),o9=(e,t,r,n,i)=>i,gk=L([Rm,o9],(e,t)=>e.filter(r=>r.type==="area").find(r=>r.id===t)),l9=(e,t,r,n,i)=>{var s,o=gk(e,t,r,n,i);if(o!=null){var l=de(e),c=Mr(l,"xAxis"),d;if(c?d=hp(e,"yAxis",r,n):d=hp(e,"xAxis",t,n),d!=null){var{stackId:u}=o,f=$m(o);if(!(u==null||f==null)){var p=(s=d[u])===null||s===void 0?void 0:s.stackedData;return p==null?void 0:p.find(m=>m.key===f)}}}},c9=L([de,fk,hk,pk,mk,l9,ku,s9,gk,wM],(e,t,r,n,i,s,o,l,c,d)=>{var{chartData:u,dataStartIndex:f,dataEndIndex:p}=o;if(!(c==null||e!=="horizontal"&&e!=="vertical"||t==null||r==null||n==null||i==null||n.length===0||i.length===0||l==null)){var{data:m}=c,x;if(m&&m.length>0?x=m:x=u==null?void 0:u.slice(f,p+1),x!=null)return C9({layout:e,xAxis:t,yAxis:r,xAxisTicks:n,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:s,displayedData:x,chartBaseValue:d,bandSize:l})}}),u9=["id"],d9=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function fi(){return fi=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{dataKey:t,name:r,stroke:n,fill:i,legendType:s,hide:o}=e;return[{inactive:o,dataKey:t,type:s,color:kc(n,i),value:uu(r,t),payload:e}]};function x9(e){var{dataKey:t,data:r,stroke:n,strokeWidth:i,fill:s,name:o,hide:l,unit:c}=e;return{dataDefinedOnItem:r,positions:void 0,settings:{stroke:n,strokeWidth:i,fill:s,dataKey:t,nameKey:void 0,name:uu(o,t),hide:l,type:e.tooltipType,color:kc(n,s),unit:c}}}function y9(e){var{clipPathId:t,points:r,props:n}=e,{needClip:i,dot:s,dataKey:o}=n,l=nr(n);return h.createElement(ZN,{points:r,dot:s,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:t})}function v9(e){var{showLabels:t,children:r,points:n}=e,i=n.map(s=>{var o,l,c={x:(o=s.x)!==null&&o!==void 0?o:0,y:(l=s.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Zi(Zi({},c),{},{value:s.value,payload:s.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return h.createElement(zN,{value:t?i:void 0},r)}function bv(e){var{points:t,baseLine:r,needClip:n,clipPathId:i,props:s}=e,{layout:o,type:l,stroke:c,connectNulls:d,isRange:u}=s,{id:f}=s,p=xk(s,u9),m=nr(p),x=ut(p);return h.createElement(h.Fragment,null,(t==null?void 0:t.length)>1&&h.createElement(ir,{clipPath:n?"url(#clipPath-".concat(i,")"):void 0},h.createElement(fs,fi({},x,{id:f,points:t,connectNulls:d,type:l,baseLine:r,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&h.createElement(fs,fi({},m,{className:"recharts-area-curve",layout:o,type:l,connectNulls:d,fill:"none",points:t})),c!=="none"&&u&&h.createElement(fs,fi({},m,{className:"recharts-area-curve",layout:o,type:l,connectNulls:d,fill:"none",points:r}))),h.createElement(y9,{points:t,props:p,clipPathId:i}))}function b9(e){var{alpha:t,baseLine:r,points:n,strokeWidth:i}=e,s=n[0].y,o=n[n.length-1].y;if(!_e(s)||!_e(o))return null;var l=t*Math.abs(s-o),c=Math.max(...n.map(d=>d.x||0));return G(r)?c=Math.max(r,c):r&&Array.isArray(r)&&r.length&&(c=Math.max(...r.map(d=>d.x||0),c)),G(c)?h.createElement("rect",{x:0,y:sd.y||0));return G(r)?c=Math.max(r,c):r&&Array.isArray(r)&&r.length&&(c=Math.max(...r.map(d=>d.y||0),c)),G(c)?h.createElement("rect",{x:s{typeof m=="function"&&m(),v(!1)},[m]),y=h.useCallback(()=>{typeof p=="function"&&p(),v(!0)},[p]),w=i.current,S=s.current;return h.createElement(v9,{showLabels:b,points:o},n.children,h.createElement(xu,{animationId:x,begin:d,duration:u,isActive:c,easing:f,onAnimationEnd:j,onAnimationStart:y,key:x},N=>{if(w){var P=w.length/o.length,C=N===1?o:o.map(($,I)=>{var A=Math.floor(I*P);if(w[A]){var R=w[A];return Zi(Zi({},$),{},{x:Ee(R.x,$.x,N),y:Ee(R.y,$.y,N)})}return $}),T;return G(l)?T=Ee(S,l,N):Re(l)||yr(l)?T=Ee(S,0,N):T=l.map(($,I)=>{var A=Math.floor(I*P);if(Array.isArray(S)&&S[A]){var R=S[A];return Zi(Zi({},$),{},{x:Ee(R.x,$.x,N),y:Ee(R.y,$.y,N)})}return $}),N>0&&(i.current=C,s.current=T),h.createElement(bv,{points:C,baseLine:T,needClip:t,clipPathId:r,props:n})}return N>0&&(i.current=o,s.current=l),h.createElement(ir,null,c&&h.createElement("defs",null,h.createElement("clipPath",{id:"animationClipPath-".concat(r)},h.createElement(w9,{alpha:N,points:o,baseLine:l,layout:n.layout,strokeWidth:n.strokeWidth}))),h.createElement(ir,{clipPath:"url(#animationClipPath-".concat(r,")")},h.createElement(bv,{points:o,baseLine:l,needClip:t,clipPathId:r,props:n})))}),h.createElement(BN,{label:n.label}))}function N9(e){var{needClip:t,clipPathId:r,props:n}=e,i=h.useRef(null),s=h.useRef();return h.createElement(S9,{needClip:t,clipPathId:r,props:n,previousPointsRef:i,previousBaselineRef:s})}class k9 extends h.PureComponent{render(){var{hide:t,dot:r,points:n,className:i,top:s,left:o,needClip:l,xAxisId:c,yAxisId:d,width:u,height:f,id:p,baseLine:m,zIndex:x}=this.props;if(t)return null;var g=ue("recharts-area",i),v=p,{r:b,strokeWidth:j}=lk(r),y=ag(r),w=b*2+j;return h.createElement(Ir,{zIndex:x},h.createElement(ir,{className:g},l&&h.createElement("defs",null,h.createElement(QN,{clipPathId:v,xAxisId:c,yAxisId:d}),!y&&h.createElement("clipPath",{id:"clipPath-dots-".concat(v)},h.createElement("rect",{x:o-w/2,y:s-w/2,width:u+w,height:f+w}))),h.createElement(N9,{needClip:l,clipPathId:v,props:this.props})),h.createElement(wp,{points:n,mainColor:kc(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot}),this.props.isRange&&Array.isArray(m)&&h.createElement(wp,{points:m,mainColor:kc(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot}))}}var yk={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:!Ci.isSsr,legendType:"line",stroke:"#3182bd",xAxisId:0,yAxisId:0,zIndex:lt.area};function _9(e){var t,r=ft(e,yk),{activeDot:n,animationBegin:i,animationDuration:s,animationEasing:o,connectNulls:l,dot:c,fill:d,fillOpacity:u,hide:f,isAnimationActive:p,legendType:m,stroke:x,xAxisId:g,yAxisId:v}=r,b=xk(r,d9),j=no(),y=pN(),{needClip:w}=sg(g,v),S=pt(),{points:N,isRange:P,baseLine:C}=(t=Z(H=>c9(H,g,v,S,e.id)))!==null&&t!==void 0?t:{},T=Ru();if(j!=="horizontal"&&j!=="vertical"||T==null||y!=="AreaChart"&&y!=="ComposedChart")return null;var{height:$,width:I,x:A,y:R}=T;return!N||!N.length?null:h.createElement(k9,fi({},b,{activeDot:n,animationBegin:i,animationDuration:s,animationEasing:o,baseLine:C,connectNulls:l,dot:c,fill:d,fillOpacity:u,height:$,hide:f,layout:j,isAnimationActive:p,isRange:P,legendType:m,needClip:w,points:N,stroke:x,width:I,left:A,top:R,xAxisId:g,yAxisId:v}))}var P9=(e,t,r,n,i)=>{var s=r??t;if(G(s))return s;var o=e==="horizontal"?i:n,l=o.scale.domain();if(o.type==="number"){var c=Math.max(l[0],l[1]),d=Math.min(l[0],l[1]);return s==="dataMin"?d:s==="dataMax"||c<0?c:Math.max(Math.min(l[0],l[1]),0)}return s==="dataMin"?l[0]:s==="dataMax"?l[1]:l[0]};function C9(e){var{areaSettings:{connectNulls:t,baseValue:r,dataKey:n},stackedData:i,layout:s,chartBaseValue:o,xAxis:l,yAxis:c,displayedData:d,dataStartIndex:u,xAxisTicks:f,yAxisTicks:p,bandSize:m}=e,x=i&&i.length,g=P9(s,o,r,l,c),v=s==="horizontal",b=!1,j=d.map((w,S)=>{var N;x?N=i[u+S]:(N=et(w,n),Array.isArray(N)?b=!0:N=[g,N]);var P=N[1]==null||x&&!t&&et(w,n)==null;return v?{x:Ql({axis:l,ticks:f,bandSize:m,entry:w,index:S}),y:P?null:c.scale(N[1]),value:N,payload:w}:{x:P?null:l.scale(N[1]),y:Ql({axis:c,ticks:p,bandSize:m,entry:w,index:S}),value:N,payload:w}}),y;return x||b?y=j.map(w=>{var S=Array.isArray(w.value)?w.value[0]:null;return v?{x:w.x,y:S!=null&&w.y!=null?c.scale(S):null,payload:w.payload}:{x:S!=null?l.scale(S):null,y:w.y,payload:w.payload}}):y=v?c.scale(g):l.scale(g),{points:j,baseLine:y,isRange:b}}function A9(e){var t=ft(e,yk),r=pt();return h.createElement(VN,{id:t.id,type:"area"},n=>h.createElement(h.Fragment,null,h.createElement(HN,{legendPayload:g9(t)}),h.createElement(qN,{fn:x9,args:t}),h.createElement(GN,{type:"area",id:n,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:TE(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:r,connectNulls:t.connectNulls}),h.createElement(_9,fi({},t,{id:n}))))}var vk=h.memo(A9);vk.displayName="Area";var O9=["dangerouslySetInnerHTML","ticks"],E9=["id"],D9=["domain"],T9=["domain"];function kp(){return kp=Object.assign?Object.assign.bind():function(e){for(var t=1;t(t(mz(e)),()=>{t(gz(e))}),[e,t]),null}var $9=e=>{var{xAxisId:t,className:r}=e,n=Z(zw),i=pt(),s="xAxis",o=Z(v=>Ta(v,s,t,i)),l=Z(v=>H2(v,s,t,i)),c=Z(v=>hI(v,t)),d=Z(v=>bI(v,t)),u=Z(v=>d2(v,t));if(c==null||d==null||u==null)return null;var{dangerouslySetInnerHTML:f,ticks:p}=e,m=_c(e,O9),{id:x}=u,g=_c(u,E9);return h.createElement(ug,kp({},m,g,{scale:o,x:d.x,y:d.y,width:c.width,height:c.height,className:ue("recharts-".concat(s," ").concat(s),r),viewBox:n,ticks:l,axisType:s}))},L9={allowDataOverflow:Tt.allowDataOverflow,allowDecimals:Tt.allowDecimals,allowDuplicatedCategory:Tt.allowDuplicatedCategory,height:Tt.height,hide:!1,mirror:Tt.mirror,orientation:Tt.orientation,padding:Tt.padding,reversed:Tt.reversed,scale:Tt.scale,tickCount:Tt.tickCount,type:Tt.type,xAxisId:0},z9=e=>{var t,r,n,i,s,o=ft(e,L9);return h.createElement(h.Fragment,null,h.createElement(I9,{interval:(t=o.interval)!==null&&t!==void 0?t:"preserveEnd",id:o.xAxisId,scale:o.scale,type:o.type,padding:o.padding,allowDataOverflow:o.allowDataOverflow,domain:o.domain,dataKey:o.dataKey,allowDuplicatedCategory:o.allowDuplicatedCategory,allowDecimals:o.allowDecimals,tickCount:o.tickCount,includeHidden:(r=o.includeHidden)!==null&&r!==void 0?r:!1,reversed:o.reversed,ticks:o.ticks,height:o.height,orientation:o.orientation,mirror:o.mirror,hide:o.hide,unit:o.unit,name:o.name,angle:(n=o.angle)!==null&&n!==void 0?n:0,minTickGap:(i=o.minTickGap)!==null&&i!==void 0?i:5,tick:(s=o.tick)!==null&&s!==void 0?s:!0,tickFormatter:o.tickFormatter}),h.createElement($9,o))},R9=(e,t)=>{var{domain:r}=e,n=_c(e,D9),{domain:i}=t,s=_c(t,T9);return ba(n,s)?Array.isArray(r)&&r.length===2&&Array.isArray(i)&&i.length===2?r[0]===i[0]&&r[1]===i[1]:ba({domain:r},{domain:i}):!1},_p=h.memo(z9,R9);_p.displayName="XAxis";var B9=["dangerouslySetInnerHTML","ticks"],F9=["id"],W9=["domain"],U9=["domain"];function Pp(){return Pp=Object.assign?Object.assign.bind():function(e){for(var t=1;t(t(xz(e)),()=>{t(yz(e))}),[e,t]),null}var K9=e=>{var{yAxisId:t,className:r,width:n,label:i}=e,s=h.useRef(null),o=h.useRef(null),l=Z(zw),c=pt(),d=Ye(),u="yAxis",f=Z(S=>Ta(S,u,t,c)),p=Z(S=>SI(S,t)),m=Z(S=>wI(S,t)),x=Z(S=>H2(S,u,t,c)),g=Z(S=>f2(S,t));if(h.useLayoutEffect(()=>{if(!(n!=="auto"||!p||ig(i)||h.isValidElement(i)||g==null)){var S=s.current;if(S){var N=S.getCalculatedWidth();Math.round(p.width)!==Math.round(N)&&d(vz({id:t,width:N}))}}},[x,p,d,i,t,n,g]),p==null||m==null||g==null)return null;var{dangerouslySetInnerHTML:v,ticks:b}=e,j=Pc(e,B9),{id:y}=g,w=Pc(g,F9);return h.createElement(ug,Pp({},j,w,{ref:s,labelRef:o,scale:f,x:m.x,y:m.y,tickTextProps:n==="auto"?{width:void 0}:{width:n},width:p.width,height:p.height,className:ue("recharts-".concat(u," ").concat(u),r),viewBox:l,ticks:x,axisType:u}))},V9={allowDataOverflow:Mt.allowDataOverflow,allowDecimals:Mt.allowDecimals,allowDuplicatedCategory:Mt.allowDuplicatedCategory,hide:!1,mirror:Mt.mirror,orientation:Mt.orientation,padding:Mt.padding,reversed:Mt.reversed,scale:Mt.scale,tickCount:Mt.tickCount,type:Mt.type,width:Mt.width,yAxisId:0},Y9=e=>{var t,r,n,i,s,o=ft(e,V9);return h.createElement(h.Fragment,null,h.createElement(H9,{interval:(t=o.interval)!==null&&t!==void 0?t:"preserveEnd",id:o.yAxisId,scale:o.scale,type:o.type,domain:o.domain,allowDataOverflow:o.allowDataOverflow,dataKey:o.dataKey,allowDuplicatedCategory:o.allowDuplicatedCategory,allowDecimals:o.allowDecimals,tickCount:o.tickCount,padding:o.padding,includeHidden:(r=o.includeHidden)!==null&&r!==void 0?r:!1,reversed:o.reversed,ticks:o.ticks,width:o.width,orientation:o.orientation,mirror:o.mirror,hide:o.hide,unit:o.unit,name:o.name,angle:(n=o.angle)!==null&&n!==void 0?n:0,minTickGap:(i=o.minTickGap)!==null&&i!==void 0?i:5,tick:(s=o.tick)!==null&&s!==void 0?s:!0,tickFormatter:o.tickFormatter}),h.createElement(K9,o))},G9=(e,t)=>{var{domain:r}=e,n=Pc(e,W9),{domain:i}=t,s=Pc(t,U9);return ba(n,s)?Array.isArray(r)&&r.length===2&&Array.isArray(i)&&i.length===2?r[0]===i[0]&&r[1]===i[1]:ba({domain:r},{domain:i}):!1},Cp=h.memo(Y9,G9);Cp.displayName="YAxis";var Z9={};/** * @license React * use-sync-external-store-with-selector.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var mo=h;function X9(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var J9=typeof Object.is=="function"?Object.is:X9,Q9=mo.useSyncExternalStore,eB=mo.useRef,tB=mo.useEffect,rB=mo.useMemo,nB=mo.useDebugValue;Z9.useSyncExternalStoreWithSelector=function(e,t,r,n,i){var s=eB(null);if(s.current===null){var o={hasValue:!1,value:null};s.current=o}else o=s.current;s=rB(function(){function c(m){if(!d){if(d=!0,u=m,m=n(m),i!==void 0&&o.hasValue){var x=o.value;if(i(x,m))return f=x}return f=m}if(x=f,J9(u,m))return x;var g=n(m);return i!==void 0&&i(x,g)?(u=m,x):(u=m,f=g)}var d=!1,u,f,p=r===void 0?null:r;return[function(){return c(t())},p===null?void 0:function(){return c(p())}]},[t,r,n,i]);var l=Q9(e,s[0],s[1]);return tB(function(){o.hasValue=!0,o.value=l},[l]),nB(l),l};function iB(e){e()}function aB(){let e=null,t=null;return{clear(){e=null,t=null},notify(){iB(()=>{let r=e;for(;r;)r.callback(),r=r.next})},get(){const r=[];let n=e;for(;n;)r.push(n),n=n.next;return r},subscribe(r){let n=!0;const i=t={callback:r,next:null,prev:t};return i.prev?i.prev.next=i:e=i,function(){!n||e===null||(n=!1,i.next?i.next.prev=i.prev:t=i.prev,i.prev?i.prev.next=i.next:e=i.next)}}}}var jv={notify(){},get:()=>[]};function sB(e,t){let r,n=jv,i=0,s=!1;function o(g){u();const v=n.subscribe(g);let b=!1;return()=>{b||(b=!0,v(),f())}}function l(){n.notify()}function c(){x.onStateChange&&x.onStateChange()}function d(){return s}function u(){i++,r||(r=e.subscribe(c),n=aB())}function f(){i--,r&&i===0&&(r(),r=void 0,n.clear(),n=jv)}function p(){s||(s=!0,u())}function m(){s&&(s=!1,f())}const x={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:d,trySubscribe:p,tryUnsubscribe:m,getListeners:()=>n};return x}var oB=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",lB=oB(),cB=()=>typeof navigator<"u"&&navigator.product==="ReactNative",uB=cB(),dB=()=>lB||uB?h.useLayoutEffect:h.useEffect,fB=dB(),Md=Symbol.for("react-redux-context"),Id=typeof globalThis<"u"?globalThis:{};function pB(){if(!h.createContext)return{};const e=Id[Md]??(Id[Md]=new Map);let t=e.get(h.createContext);return t||(t=h.createContext(null),e.set(h.createContext,t)),t}var hB=pB();function mB(e){const{children:t,context:r,serverState:n,store:i}=e,s=h.useMemo(()=>{const c=sB(i);return{store:i,subscription:c,getServerState:n?()=>n:void 0}},[i,n]),o=h.useMemo(()=>i.getState(),[i]);fB(()=>{const{subscription:c}=s;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),o!==i.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[s,o]);const l=r||hB;return h.createElement(l.Provider,{value:s},t)}var gB=mB,xB=(e,t)=>t,fg=L([xB,de,c2,We,oN,pn,T$,rt],B$),pg=e=>{var t=e.currentTarget.getBoundingClientRect(),r=t.width/e.currentTarget.offsetWidth,n=t.height/e.currentTarget.offsetHeight;return{chartX:Math.round((e.clientX-t.left)/r),chartY:Math.round((e.clientY-t.top)/n)}},bk=ar("mouseClick"),jk=to();jk.startListening({actionCreator:bk,effect:(e,t)=>{var r=e.payload,n=fg(t.getState(),pg(r));(n==null?void 0:n.activeIndex)!=null&&t.dispatch(II({activeIndex:n.activeIndex,activeDataKey:void 0,activeCoordinate:n.activeCoordinate}))}});var Ap=ar("mouseMove"),wk=to();wk.startListening({actionCreator:Ap,effect:(e,t)=>{var r=e.payload,n=t.getState(),i=Ym(n,n.tooltip.settings.shared),s=fg(n,pg(r));i==="axis"&&((s==null?void 0:s.activeIndex)!=null?t.dispatch(J2({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate})):t.dispatch(X2()))}});var wv={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},Sk=At({name:"rootProps",initialState:wv,reducers:{updateOptions:(e,t)=>{var r;e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=(r=t.payload.barGap)!==null&&r!==void 0?r:wv.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue}}}),yB=Sk.reducer,{updateOptions:vB}=Sk.actions,Nk=At({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(e,t)=>t.payload}}),{updatePolarOptions:n7}=Nk.actions,bB=Nk.reducer,kk=ar("keyDown"),_k=ar("focus"),hg=to();hg.startListening({actionCreator:kk,effect:(e,t)=>{var r=t.getState(),n=r.rootProps.accessibilityLayer!==!1;if(n){var{keyboardInteraction:i}=r.tooltip,s=e.payload;if(!(s!=="ArrowRight"&&s!=="ArrowLeft"&&s!=="Enter")){var o=Number(Gm(i,Ia(r))),l=pn(r);if(s==="Enter"){var c=yc(r,"axis","hover",String(i.index));t.dispatch(gp({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:c}));return}var d=PI(r),u=d==="left-to-right"?1:-1,f=s==="ArrowRight"?1:-1,p=o+f*u;if(!(l==null||p>=l.length||p<0)){var m=yc(r,"axis","hover",String(p));t.dispatch(gp({active:!0,activeIndex:p.toString(),activeDataKey:void 0,activeCoordinate:m}))}}}}});hg.startListening({actionCreator:_k,effect:(e,t)=>{var r=t.getState(),n=r.rootProps.accessibilityLayer!==!1;if(n){var{keyboardInteraction:i}=r.tooltip;if(!i.active&&i.index==null){var s="0",o=yc(r,"axis","hover",String(s));t.dispatch(gp({activeDataKey:void 0,active:!0,activeIndex:s,activeCoordinate:o}))}}}});var Vt=ar("externalEvent"),Pk=to();Pk.startListening({actionCreator:Vt,effect:(e,t)=>{if(e.payload.handler!=null){var r=t.getState(),n={activeCoordinate:y$(r),activeDataKey:g$(r),activeIndex:Hs(r),activeLabel:uN(r),activeTooltipIndex:Hs(r),isTooltipActive:v$(r)};e.payload.handler(n,e.payload.reactEvent)}}});var jB=L([Ma],e=>e.tooltipItemPayloads),wB=L([jB,po,(e,t,r)=>t,(e,t,r)=>r],(e,t,r,n)=>{var i=e.find(l=>l.settings.dataKey===n);if(i!=null){var{positions:s}=i;if(s!=null){var o=t(s,r);return o}}}),Ck=ar("touchMove"),Ak=to();Ak.startListening({actionCreator:Ck,effect:(e,t)=>{var r=e.payload;if(!(r.touches==null||r.touches.length===0)){var n=t.getState(),i=Ym(n,n.tooltip.settings.shared);if(i==="axis"){var s=fg(n,pg({clientX:r.touches[0].clientX,clientY:r.touches[0].clientY,currentTarget:r.currentTarget}));(s==null?void 0:s.activeIndex)!=null&&t.dispatch(J2({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate}))}else if(i==="item"){var o,l=r.touches[0];if(document.elementFromPoint==null)return;var c=document.elementFromPoint(l.clientX,l.clientY);if(!c||!c.getAttribute)return;var d=c.getAttribute(BE),u=(o=c.getAttribute(FE))!==null&&o!==void 0?o:void 0,f=wB(t.getState(),d,u);t.dispatch(MI({activeDataKey:u,activeIndex:d,activeCoordinate:f}))}}}});var SB=cw({brush:Lz,cartesianAxis:bz,chartData:g8,errorBars:Az,graphicalItems:rz,layout:SE,legend:g3,options:d8,polarAxis:EL,polarOptions:bB,referenceElements:qz,rootProps:yB,tooltip:$I,zIndex:e8}),NB=function(t){return YO({reducer:SB,preloadedState:t,middleware:r=>r({serializableCheck:!1}).concat([jk.middleware,wk.middleware,hg.middleware,Pk.middleware,Ak.middleware]),enhancers:r=>{var n=r;return typeof r=="function"&&(n=r()),n.concat(jw({type:"raf"}))},devTools:Ci.devToolsEnabled})};function kB(e){var{preloadedState:t,children:r,reduxStoreName:n}=e,i=pt(),s=h.useRef(null);if(i)return r;s.current==null&&(s.current=NB(t));var o=Zh;return h.createElement(gB,{context:o,store:s.current},r)}function _B(e){var{layout:t,margin:r}=e,n=Ye(),i=pt();return h.useEffect(()=>{i||(n(bE(t)),n(vE(r)))},[n,i,t,r]),null}function PB(e){var t=Ye();return h.useEffect(()=>{t(vB(e))},[t,e]),null}function Sv(e){var{zIndex:t,isPanorama:r}=e,n=r?"recharts-zindex-panorama-":"recharts-zindex-",i=KN("".concat(n).concat(t)),s=Ye();return h.useLayoutEffect(()=>(s(J$({zIndex:t,elementId:i,isPanorama:r})),()=>{s(Q$({zIndex:t,isPanorama:r}))}),[s,t,i,r]),h.createElement("g",{id:i})}function Nv(e){var{children:t,isPanorama:r}=e,n=Z(W$);if(!n||n.length===0)return t;var i=n.filter(o=>o<0),s=n.filter(o=>o>0);return h.createElement(h.Fragment,null,i.map(o=>h.createElement(Sv,{key:o,zIndex:o,isPanorama:r})),t,s.map(o=>h.createElement(Sv,{key:o,zIndex:o,isPanorama:r})))}var CB=["children"];function AB(e,t){if(e==null)return{};var r,n,i=OB(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n{var r=Vw(),n=Yw(),i=Zw();if(!Er(r)||!Er(n))return null;var{children:s,otherAttributes:o,title:l,desc:c}=e,d,u;return o!=null&&(typeof o.tabIndex=="number"?d=o.tabIndex:d=i?0:void 0,typeof o.role=="string"?u=o.role:u=i?"application":void 0),h.createElement(hj,Cc({},o,{title:l,desc:c,role:u,tabIndex:d,width:r,height:n,style:EB,ref:t}),s)}),TB=e=>{var{children:t}=e,r=Z(hu);if(!r)return null;var{width:n,height:i,y:s,x:o}=r;return h.createElement(hj,{width:n,height:i,x:o,y:s},t)},kv=h.forwardRef((e,t)=>{var{children:r}=e,n=AB(e,CB),i=pt();return i?h.createElement(TB,null,h.createElement(Nv,{isPanorama:!0},r)):h.createElement(DB,Cc({ref:t},n),h.createElement(Nv,{isPanorama:!1},r))});function MB(){var e=Ye(),[t,r]=h.useState(null),n=Z(RE);return h.useEffect(()=>{if(t!=null){var i=t.getBoundingClientRect(),s=i.width/t.offsetWidth;_e(s)&&s!==n&&e(wE(s))}},[t,e,n]),r}function _v(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function IB(e){for(var t=1;t(k8(),null);function Ac(e){if(typeof e=="number")return e;if(typeof e=="string"){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var BB=h.forwardRef((e,t)=>{var r,n,i=h.useRef(null),[s,o]=h.useState({containerWidth:Ac((r=e.style)===null||r===void 0?void 0:r.width),containerHeight:Ac((n=e.style)===null||n===void 0?void 0:n.height)}),l=h.useCallback((d,u)=>{o(f=>{var p=Math.round(d),m=Math.round(u);return f.containerWidth===p&&f.containerHeight===m?f:{containerWidth:p,containerHeight:m}})},[]),c=h.useCallback(d=>{if(typeof t=="function"&&t(d),d!=null&&typeof ResizeObserver<"u"){var{width:u,height:f}=d.getBoundingClientRect();l(u,f);var p=x=>{var{width:g,height:v}=x[0].contentRect;l(g,v)},m=new ResizeObserver(p);m.observe(d),i.current=m}},[t,l]);return h.useEffect(()=>()=>{var d=i.current;d!=null&&d.disconnect()},[l]),h.createElement(h.Fragment,null,h.createElement(gu,{width:s.containerWidth,height:s.containerHeight}),h.createElement("div",Ni({ref:c},e)))}),FB=h.forwardRef((e,t)=>{var{width:r,height:n}=e,[i,s]=h.useState({containerWidth:Ac(r),containerHeight:Ac(n)}),o=h.useCallback((c,d)=>{s(u=>{var f=Math.round(c),p=Math.round(d);return u.containerWidth===f&&u.containerHeight===p?u:{containerWidth:f,containerHeight:p}})},[]),l=h.useCallback(c=>{if(typeof t=="function"&&t(c),c!=null){var{width:d,height:u}=c.getBoundingClientRect();o(d,u)}},[t,o]);return h.createElement(h.Fragment,null,h.createElement(gu,{width:i.containerWidth,height:i.containerHeight}),h.createElement("div",Ni({ref:l},e)))}),WB=h.forwardRef((e,t)=>{var{width:r,height:n}=e;return h.createElement(h.Fragment,null,h.createElement(gu,{width:r,height:n}),h.createElement("div",Ni({ref:t},e)))}),UB=h.forwardRef((e,t)=>{var{width:r,height:n}=e;return Qr(r)||Qr(n)?h.createElement(FB,Ni({},e,{ref:t})):h.createElement(WB,Ni({},e,{ref:t}))});function qB(e){return e===!0?BB:UB}var HB=h.forwardRef((e,t)=>{var{children:r,className:n,height:i,onClick:s,onContextMenu:o,onDoubleClick:l,onMouseDown:c,onMouseEnter:d,onMouseLeave:u,onMouseMove:f,onMouseUp:p,onTouchEnd:m,onTouchMove:x,onTouchStart:g,style:v,width:b,responsive:j,dispatchTouchEvents:y=!0}=e,w=h.useRef(null),S=Ye(),[N,P]=h.useState(null),[C,T]=h.useState(null),$=MB(),I=im(),A=(I==null?void 0:I.width)>0?I.width:b,R=(I==null?void 0:I.height)>0?I.height:i,H=h.useCallback(F=>{$(F),typeof t=="function"&&t(F),P(F),T(F),F!=null&&(w.current=F)},[$,t,P,T]),M=h.useCallback(F=>{S(bk(F)),S(Vt({handler:s,reactEvent:F}))},[S,s]),_=h.useCallback(F=>{S(Ap(F)),S(Vt({handler:d,reactEvent:F}))},[S,d]),D=h.useCallback(F=>{S(X2()),S(Vt({handler:u,reactEvent:F}))},[S,u]),O=h.useCallback(F=>{S(Ap(F)),S(Vt({handler:f,reactEvent:F}))},[S,f]),k=h.useCallback(()=>{S(_k())},[S]),z=h.useCallback(F=>{S(kk(F.key))},[S]),W=h.useCallback(F=>{S(Vt({handler:o,reactEvent:F}))},[S,o]),K=h.useCallback(F=>{S(Vt({handler:l,reactEvent:F}))},[S,l]),ee=h.useCallback(F=>{S(Vt({handler:c,reactEvent:F}))},[S,c]),re=h.useCallback(F=>{S(Vt({handler:p,reactEvent:F}))},[S,p]),Me=h.useCallback(F=>{S(Vt({handler:g,reactEvent:F}))},[S,g]),E=h.useCallback(F=>{y&&S(Ck(F)),S(Vt({handler:x,reactEvent:F}))},[S,y,x]),Q=h.useCallback(F=>{S(Vt({handler:m,reactEvent:F}))},[S,m]),Ot=qB(j);return h.createElement(vN.Provider,{value:N},h.createElement(u4.Provider,{value:C},h.createElement(Ot,{width:A??(v==null?void 0:v.width),height:R??(v==null?void 0:v.height),className:ue("recharts-wrapper",n),style:IB({position:"relative",cursor:"default",width:A,height:R},v),onClick:M,onContextMenu:W,onDoubleClick:K,onFocus:k,onKeyDown:z,onMouseDown:ee,onMouseEnter:_,onMouseLeave:D,onMouseMove:O,onMouseUp:re,onTouchEnd:Q,onTouchMove:E,onTouchStart:Me,ref:H},h.createElement(RB,null),r)))}),KB=["width","height","responsive","children","className","style","compact","title","desc"];function VB(e,t){if(e==null)return{};var r,n,i=YB(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n{var{width:r,height:n,responsive:i,children:s,className:o,style:l,compact:c,title:d,desc:u}=e,f=VB(e,KB),p=nr(f);return c?h.createElement(h.Fragment,null,h.createElement(gu,{width:r,height:n}),h.createElement(kv,{otherAttributes:p,title:d,desc:u},s)):h.createElement(HB,{className:o,style:l,width:r,height:n,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},h.createElement(kv,{otherAttributes:p,title:d,desc:u,ref:t},h.createElement(Kz,null,s)))});function Op(){return Op=Object.assign?Object.assign.bind():function(e){for(var t=1;th.createElement(Ok,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:JB,tooltipPayloadSearcher:jN,categoricalChartProps:e,ref:t})),eF=["axis"],tF=h.forwardRef((e,t)=>h.createElement(Ok,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:eF,tooltipPayloadSearcher:jN,categoricalChartProps:e,ref:t}));function rF(){var v,b,j,y,w,S,N,P,C,T,$,I,A,R,H,M,_,D,O,k,z;const[e,t]=h.useState(null),[r,n]=h.useState(null),[i,s]=h.useState(!0),[o,l]=h.useState(0),[c,d]=h.useState(!1);h.useEffect(()=>{f(),u()},[]);const u=async()=>{try{const K=(await B.getChangeStats()).pending_count;l(K);const ee=localStorage.getItem("dismissedPendingChangesCount"),re=ee&&parseInt(ee)>=K;d(K>0&&!re)}catch(W){console.error("Failed to load change stats:",W),d(!1)}},f=async()=>{try{const W=await B.getDutchieAZDashboard();t({products:{total:W.productCount,in_stock:W.productCount,with_images:0},stores:{total:W.dispensaryCount,active:W.dispensaryCount},brands:{total:W.brandCount},campaigns:{active:0,total:0},clicks:{clicks_24h:W.snapshotCount24h},failedJobs:W.failedJobCount,lastCrawlTime:W.lastCrawlTime});try{const K=await B.getDashboardActivity();n(K)}catch{n(null)}}catch(W){console.error("Failed to load dashboard:",W)}finally{s(!1)}},p=()=>{localStorage.setItem("dismissedPendingChangesCount",o.toString()),d(!1)};if(i)return a.jsx(X,{children:a.jsx("div",{className:"flex items-center justify-center h-64",children:a.jsx(Xt,{className:"w-8 h-8 animate-spin text-gray-400"})})});const m=Math.round(((v=e==null?void 0:e.products)==null?void 0:v.with_images)/((b=e==null?void 0:e.products)==null?void 0:b.total)*100)||0;Math.round(((j=e==null?void 0:e.stores)==null?void 0:j.active)/((y=e==null?void 0:e.stores)==null?void 0:y.total)*100);const x=[{date:"Mon",products:120},{date:"Tue",products:145},{date:"Wed",products:132},{date:"Thu",products:178},{date:"Fri",products:195},{date:"Sat",products:210},{date:"Sun",products:((w=e==null?void 0:e.products)==null?void 0:w.total)||225}],g=[{time:"00:00",scrapes:5},{time:"04:00",scrapes:12},{time:"08:00",scrapes:18},{time:"12:00",scrapes:25},{time:"16:00",scrapes:30},{time:"20:00",scrapes:22},{time:"24:00",scrapes:((S=r==null?void 0:r.recent_scrapes)==null?void 0:S.length)||15}];return a.jsxs(X,{children:[c&&a.jsx("div",{className:"mb-6 bg-amber-50 border-l-4 border-amber-500 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[a.jsx(cj,{className:"w-5 h-5 text-amber-600 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("h3",{className:"text-sm font-semibold text-amber-900",children:[o," pending change",o!==1?"s":""," require review"]}),a.jsx("p",{className:"text-sm text-amber-700 mt-0.5",children:"Proposed changes to dispensary data are waiting for approval"})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{className:"btn btn-sm bg-amber-600 hover:bg-amber-700 text-white border-none",children:"Review Changes"}),a.jsx("button",{onClick:p,className:"btn btn-sm btn-ghost text-amber-900 hover:bg-amber-100","aria-label":"Dismiss notification",children:a.jsx(Mh,{className:"w-4 h-4"})})]})]})}),a.jsxs("div",{className:"space-y-8",children:[a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-semibold text-gray-900",children:"Dashboard"}),a.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Monitor your dispensary data aggregation"})]}),a.jsxs("button",{onClick:f,className:"inline-flex items-center gap-2 px-4 py-2 bg-white border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors text-sm font-medium text-gray-700",children:[a.jsx(Xt,{className:"w-4 h-4"}),"Refresh"]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("div",{className:"p-2 bg-blue-50 rounded-lg",children:a.jsx(Ct,{className:"w-5 h-5 text-blue-600"})}),a.jsxs("div",{className:"flex items-center gap-1 text-xs text-green-600",children:[a.jsx(zn,{className:"w-3 h-3"}),a.jsx("span",{children:"12.5%"})]})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium text-gray-600",children:"Total Products"}),a.jsx("p",{className:"text-3xl font-semibold text-gray-900",children:((P=(N=e==null?void 0:e.products)==null?void 0:N.total)==null?void 0:P.toLocaleString())||0}),a.jsxs("p",{className:"text-xs text-gray-500",children:[((C=e==null?void 0:e.products)==null?void 0:C.in_stock)||0," in stock"]})]})]}),a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("div",{className:"p-2 bg-emerald-50 rounded-lg",children:a.jsx(Bl,{className:"w-5 h-5 text-emerald-600"})}),a.jsxs("div",{className:"flex items-center gap-1 text-xs text-green-600",children:[a.jsx(zn,{className:"w-3 h-3"}),a.jsx("span",{children:"8.2%"})]})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium text-gray-600",children:"Total Dispensaries"}),a.jsx("p",{className:"text-3xl font-semibold text-gray-900",children:((T=e==null?void 0:e.stores)==null?void 0:T.total)||0}),a.jsxs("p",{className:"text-xs text-gray-500",children:[(($=e==null?void 0:e.stores)==null?void 0:$.active)||0," active (crawlable)"]})]})]}),a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("div",{className:"p-2 bg-purple-50 rounded-lg",children:a.jsx(oj,{className:"w-5 h-5 text-purple-600"})}),a.jsxs("div",{className:"flex items-center gap-1 text-xs text-red-600",children:[a.jsx(H6,{className:"w-3 h-3"}),a.jsx("span",{children:"3.1%"})]})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium text-gray-600",children:"Active Campaigns"}),a.jsx("p",{className:"text-3xl font-semibold text-gray-900",children:((I=e==null?void 0:e.campaigns)==null?void 0:I.active)||0}),a.jsxs("p",{className:"text-xs text-gray-500",children:[((A=e==null?void 0:e.campaigns)==null?void 0:A.total)||0," total campaigns"]})]})]}),a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("div",{className:"p-2 bg-amber-50 rounded-lg",children:a.jsx(x6,{className:"w-5 h-5 text-amber-600"})}),a.jsxs("span",{className:"text-xs font-medium text-gray-600",children:[m,"%"]})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium text-gray-600",children:"Images Downloaded"}),a.jsx("p",{className:"text-3xl font-semibold text-gray-900",children:((H=(R=e==null?void 0:e.products)==null?void 0:R.with_images)==null?void 0:H.toLocaleString())||0}),a.jsx("div",{className:"mt-3",children:a.jsx("div",{className:"w-full bg-gray-100 rounded-full h-1.5",children:a.jsx("div",{className:"bg-amber-500 h-1.5 rounded-full transition-all",style:{width:`${m}%`}})})})]})]}),a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("div",{className:"p-2 bg-cyan-50 rounded-lg",children:a.jsx(na,{className:"w-5 h-5 text-cyan-600"})}),a.jsx(xr,{className:"w-4 h-4 text-gray-400"})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium text-gray-600",children:"Snapshots (24h)"}),a.jsx("p",{className:"text-3xl font-semibold text-gray-900",children:((_=(M=e==null?void 0:e.clicks)==null?void 0:M.clicks_24h)==null?void 0:_.toLocaleString())||0}),a.jsx("p",{className:"text-xs text-gray-500",children:"Product snapshots created"})]})]}),a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("div",{className:"p-2 bg-indigo-50 rounded-lg",children:a.jsx(Cr,{className:"w-5 h-5 text-indigo-600"})}),a.jsx(na,{className:"w-4 h-4 text-gray-400"})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium text-gray-600",children:"Brands"}),a.jsx("p",{className:"text-3xl font-semibold text-gray-900",children:((D=e==null?void 0:e.brands)==null?void 0:D.total)||((O=e==null?void 0:e.products)==null?void 0:O.unique_brands)||0}),a.jsx("p",{className:"text-xs text-gray-500",children:"Unique brands tracked"})]})]})]}),a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Product Growth"}),a.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Weekly product count trend"})]}),a.jsx(y0,{width:"100%",height:200,children:a.jsxs(tF,{data:x,children:[a.jsx("defs",{children:a.jsxs("linearGradient",{id:"productGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[a.jsx("stop",{offset:"5%",stopColor:"#3b82f6",stopOpacity:.1}),a.jsx("stop",{offset:"95%",stopColor:"#3b82f6",stopOpacity:0})]})}),a.jsx(Np,{strokeDasharray:"3 3",stroke:"#f1f5f9"}),a.jsx(_p,{dataKey:"date",tick:{fill:"#94a3b8",fontSize:12},axisLine:{stroke:"#e2e8f0"}}),a.jsx(Cp,{tick:{fill:"#94a3b8",fontSize:12},axisLine:{stroke:"#e2e8f0"}}),a.jsx(Hy,{contentStyle:{backgroundColor:"#ffffff",border:"1px solid #e2e8f0",borderRadius:"8px",fontSize:"12px"}}),a.jsx(vk,{type:"monotone",dataKey:"products",stroke:"#3b82f6",strokeWidth:2,fill:"url(#productGradient)"})]})})]}),a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Scrape Activity"}),a.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Scrapes over the last 24 hours"})]}),a.jsx(y0,{width:"100%",height:200,children:a.jsxs(QB,{data:g,children:[a.jsx(Np,{strokeDasharray:"3 3",stroke:"#f1f5f9"}),a.jsx(_p,{dataKey:"time",tick:{fill:"#94a3b8",fontSize:12},axisLine:{stroke:"#e2e8f0"}}),a.jsx(Cp,{tick:{fill:"#94a3b8",fontSize:12},axisLine:{stroke:"#e2e8f0"}}),a.jsx(Hy,{contentStyle:{backgroundColor:"#ffffff",border:"1px solid #e2e8f0",borderRadius:"8px",fontSize:"12px"}}),a.jsx(dk,{type:"monotone",dataKey:"scrapes",stroke:"#10b981",strokeWidth:2,dot:{fill:"#10b981",r:4}})]})})]})]}),a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200",children:[a.jsxs("div",{className:"px-6 py-4 border-b border-gray-200",children:[a.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Recent Scrapes"}),a.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Latest data collection activities"})]}),a.jsx("div",{className:"divide-y divide-gray-100",children:((k=r==null?void 0:r.recent_scrapes)==null?void 0:k.length)>0?r.recent_scrapes.slice(0,5).map((W,K)=>a.jsx("div",{className:"px-6 py-4 hover:bg-gray-50 transition-colors",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium text-gray-900 truncate",children:W.name}),a.jsx("p",{className:"text-xs text-gray-500 mt-1",children:new Date(W.last_scraped_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})})]}),a.jsx("div",{className:"ml-4 flex-shrink-0",children:a.jsxs("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-50 text-blue-700",children:[W.product_count," products"]})})]})},K)):a.jsxs("div",{className:"px-6 py-12 text-center",children:[a.jsx(na,{className:"w-8 h-8 text-gray-300 mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-gray-500",children:"No recent scrapes"})]})})]}),a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200",children:[a.jsxs("div",{className:"px-6 py-4 border-b border-gray-200",children:[a.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Recent Products"}),a.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Newly added to inventory"})]}),a.jsx("div",{className:"divide-y divide-gray-100",children:((z=r==null?void 0:r.recent_products)==null?void 0:z.length)>0?r.recent_products.slice(0,5).map((W,K)=>a.jsx("div",{className:"px-6 py-4 hover:bg-gray-50 transition-colors",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium text-gray-900 truncate",children:W.name}),a.jsx("p",{className:"text-xs text-gray-500 mt-1",children:W.store_name})]}),W.price&&a.jsx("div",{className:"ml-4 flex-shrink-0",children:a.jsxs("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-emerald-50 text-emerald-700",children:["$",W.price]})})]})},K)):a.jsxs("div",{className:"px-6 py-12 text-center",children:[a.jsx(Ct,{className:"w-8 h-8 text-gray-300 mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-gray-500",children:"No recent products"})]})})]})]})]})]})}function nF(){const[e,t]=cA(),r=dt(),[n,i]=h.useState([]),[s,o]=h.useState([]),[l,c]=h.useState([]),[d,u]=h.useState(!1),[f,p]=h.useState(""),[m,x]=h.useState(""),[g,v]=h.useState(""),[b,j]=h.useState(""),[y,w]=h.useState(0),[S,N]=h.useState(0),P=50;h.useEffect(()=>{const k=e.get("store");k&&x(k),T()},[]),h.useEffect(()=>{m&&($(),C())},[f,m,g,b,S]);const C=async()=>{try{const k=await B.getCategoryTree(parseInt(m));c(k.categories||[])}catch(k){console.error("Failed to load categories:",k)}},T=async()=>{try{const k=await B.getStores();o(k.stores)}catch(k){console.error("Failed to load stores:",k)}},$=async()=>{u(!0);try{const k={limit:P,offset:S,store_id:m};f&&(k.search=f),g&&(k.category_id=g),b&&(k.in_stock=b);const z=await B.getProducts(k);i(z.products),w(z.total)}catch(k){console.error("Failed to load products:",k)}finally{u(!1)}},I=k=>{p(k),N(0)},A=k=>{x(k),v(""),N(0),p(""),t(k?{store:k}:{})},R=k=>{v(k),N(0)},H=(k,z=0)=>k.map(W=>a.jsxs("div",{style:{marginLeft:`${z*20}px`},children:[a.jsxs("button",{onClick:()=>R(W.id.toString()),style:{width:"100%",textAlign:"left",padding:"10px 15px",background:g===W.id.toString()?"#667eea":"transparent",color:g===W.id.toString()?"white":"#333",border:"none",borderRadius:"6px",cursor:"pointer",fontWeight:z===0?"600":"400",fontSize:z===0?"15px":"14px",marginBottom:"4px",transition:"all 0.2s"},onMouseEnter:K=>{g!==W.id.toString()&&(K.currentTarget.style.background="#f5f5f5")},onMouseLeave:K=>{g!==W.id.toString()&&(K.currentTarget.style.background="transparent")},children:[W.name," (",W.product_count||0,")"]}),W.children&&W.children.length>0&&H(W.children,z+1)]},W.id)),M=l.find(k=>k.id.toString()===g),_=()=>{S+P{S>0&&N(Math.max(0,S-P))},O=s.find(k=>k.id.toString()===m);return a.jsx(X,{children:a.jsxs("div",{children:[a.jsx("h1",{style:{fontSize:"32px",marginBottom:"30px"},children:"Products"}),a.jsxs("div",{style:{background:"white",padding:"30px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",marginBottom:"30px"},children:[a.jsx("label",{style:{display:"block",marginBottom:"15px",fontSize:"18px",fontWeight:"600",color:"#333"},children:"Select a Store to View Products:"}),a.jsxs("select",{value:m,onChange:k=>A(k.target.value),style:{width:"100%",padding:"15px",border:"2px solid #667eea",borderRadius:"8px",fontSize:"16px",fontWeight:"500",cursor:"pointer",background:"white"},children:[a.jsx("option",{value:"",children:"-- Select a Store --"}),s.map(k=>a.jsx("option",{value:k.id,children:k.name},k.id))]})]}),m?a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{background:"#667eea",color:"white",padding:"20px",borderRadius:"8px",marginBottom:"20px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[a.jsxs("div",{children:[a.jsx("h2",{style:{margin:0,fontSize:"24px"},children:O==null?void 0:O.name}),M&&a.jsx("div",{style:{marginTop:"8px",fontSize:"14px",opacity:.9},children:M.name})]}),a.jsxs("div",{style:{fontSize:"18px",fontWeight:"bold"},children:[y," Products"]})]}),a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"280px 1fr",gap:"20px"},children:[a.jsx("div",{children:a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",position:"sticky",top:"20px"},children:[a.jsx("h3",{style:{margin:"0 0 16px 0",fontSize:"18px",fontWeight:"600",color:"#333"},children:"Categories"}),a.jsxs("button",{onClick:()=>R(""),style:{width:"100%",textAlign:"left",padding:"10px 15px",background:g===""?"#667eea":"transparent",color:g===""?"white":"#333",border:"none",borderRadius:"6px",cursor:"pointer",fontWeight:"600",fontSize:"15px",marginBottom:"12px"},children:["All Products (",y,")"]}),a.jsx("div",{style:{borderTop:"1px solid #eee",marginBottom:"12px"}}),H(l)]})}),a.jsxs("div",{children:[a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",marginBottom:"20px",display:"flex",gap:"15px",flexWrap:"wrap"},children:[a.jsx("input",{type:"text",placeholder:"Search products...",value:f,onChange:k=>I(k.target.value),style:{flex:"1",minWidth:"200px",padding:"10px",border:"1px solid #ddd",borderRadius:"6px"}}),a.jsxs("select",{value:b,onChange:k=>{j(k.target.value),N(0)},style:{padding:"10px",border:"1px solid #ddd",borderRadius:"6px"},children:[a.jsx("option",{value:"",children:"All Products"}),a.jsx("option",{value:"true",children:"In Stock"}),a.jsx("option",{value:"false",children:"Out of Stock"})]})]}),d?a.jsx("div",{style:{textAlign:"center",padding:"40px"},children:"Loading..."}):a.jsxs(a.Fragment,{children:[a.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(250px, 1fr))",gap:"20px",marginBottom:"20px"},children:n.map(k=>a.jsx(iF,{product:k,onViewDetails:()=>r(`/products/${k.id}`)},k.id))}),n.length===0&&a.jsx("div",{style:{background:"white",padding:"40px",borderRadius:"8px",textAlign:"center",color:"#999"},children:"No products found"}),y>P&&a.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"15px",marginTop:"30px"},children:[a.jsx("button",{onClick:D,disabled:S===0,style:{padding:"10px 20px",background:S===0?"#ddd":"#667eea",color:S===0?"#999":"white",border:"none",borderRadius:"6px",cursor:S===0?"not-allowed":"pointer"},children:"Previous"}),a.jsxs("span",{children:["Showing ",S+1," - ",Math.min(S+P,y)," of ",y]}),a.jsx("button",{onClick:_,disabled:S+P>=y,style:{padding:"10px 20px",background:S+P>=y?"#ddd":"#667eea",color:S+P>=y?"#999":"white",border:"none",borderRadius:"6px",cursor:S+P>=y?"not-allowed":"pointer"},children:"Next"})]})]})]})]})]}):a.jsxs("div",{style:{background:"white",padding:"60px 40px",borderRadius:"8px",textAlign:"center",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsx("div",{style:{fontSize:"48px",marginBottom:"20px"},children:"🏪"}),a.jsx("div",{style:{fontSize:"18px",color:"#666"},children:"Please select a store from the dropdown above to view products"})]})]})})}function iF({product:e,onViewDetails:t}){const r=n=>{if(!n)return"Never";const i=new Date(n),o=new Date().getTime()-i.getTime(),l=Math.floor(o/(1e3*60*60*24));return l===0?"Today":l===1?"Yesterday":l<7?`${l} days ago`:i.toLocaleDateString()};return a.jsxs("div",{style:{background:"white",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",overflow:"hidden",transition:"transform 0.2s"},onMouseEnter:n=>n.currentTarget.style.transform="translateY(-4px)",onMouseLeave:n=>n.currentTarget.style.transform="translateY(0)",children:[e.image_url_full?a.jsx("img",{src:e.image_url_full,alt:e.name,style:{width:"100%",height:"200px",objectFit:"cover",background:"#f5f5f5"},onError:n=>{n.currentTarget.src='data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="200" height="200"%3E%3Crect fill="%23ddd" width="200" height="200"/%3E%3Ctext x="50%25" y="50%25" text-anchor="middle" dy=".3em" fill="%23999"%3ENo Image%3C/text%3E%3C/svg%3E'}}):a.jsx("div",{style:{width:"100%",height:"200px",background:"#f5f5f5",display:"flex",alignItems:"center",justifyContent:"center",color:"#999"},children:"No Image"}),a.jsxs("div",{style:{padding:"15px"},children:[a.jsx("div",{style:{fontWeight:"500",marginBottom:"8px",fontSize:"14px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"},children:[a.jsx("div",{style:{fontWeight:"bold",color:"#667eea"},children:e.price?`$${e.price}`:"N/A"}),a.jsx("div",{style:{padding:"4px 8px",borderRadius:"4px",fontSize:"12px",background:e.in_stock?"#d4edda":"#f8d7da",color:e.in_stock?"#155724":"#721c24"},children:e.in_stock?"In Stock":"Out of Stock"})]}),a.jsxs("div",{style:{fontSize:"11px",color:"#888",marginBottom:"12px",borderTop:"1px solid #eee",paddingTop:"8px"},children:["Last Updated: ",r(e.last_seen_at)]}),a.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.dutchie_url&&a.jsx("a",{href:e.dutchie_url,target:"_blank",rel:"noopener noreferrer",style:{flex:1,padding:"8px 12px",background:"#f0f0f0",color:"#333",textDecoration:"none",borderRadius:"6px",fontSize:"12px",fontWeight:"500",textAlign:"center",border:"1px solid #ddd"},onClick:n=>n.stopPropagation(),children:"Source"}),a.jsx("button",{onClick:n=>{n.stopPropagation(),t()},style:{flex:1,padding:"8px 12px",background:"#667eea",color:"white",border:"none",borderRadius:"6px",fontSize:"12px",fontWeight:"500",cursor:"pointer"},children:"Details"})]})]})]})}function aF(){const{id:e}=_a(),t=dt(),[r,n]=h.useState(null),[i,s]=h.useState(!0),[o,l]=h.useState(null);h.useEffect(()=>{c()},[e]);const c=async()=>{if(e){s(!0),l(null);try{const p=await B.getProduct(parseInt(e));n(p.product)}catch(p){l(p.message||"Failed to load product")}finally{s(!1)}}};if(i)return a.jsx(X,{children:a.jsx("div",{className:"flex items-center justify-center h-64",children:a.jsx("div",{className:"w-8 h-8 border-4 border-gray-200 border-t-blue-600 rounded-full animate-spin"})})});if(o||!r)return a.jsx(X,{children:a.jsxs("div",{className:"text-center py-12",children:[a.jsx(Ct,{className:"w-16 h-16 text-gray-300 mx-auto mb-4"}),a.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-2",children:"Product not found"}),a.jsx("p",{className:"text-gray-500 mb-4",children:o}),a.jsx("button",{onClick:()=>t(-1),className:"text-blue-600 hover:text-blue-700",children:"← Go back"})]})});const d=r.metadata||{},f=r.image_url_full?r.image_url_full:r.medium_path?`http://localhost:9020/dutchie/${r.medium_path}`:r.thumbnail_path?`http://localhost:9020/dutchie/${r.thumbnail_path}`:null;return a.jsx(X,{children:a.jsxs("div",{className:"max-w-6xl mx-auto",children:[a.jsxs("button",{onClick:()=>t(-1),className:"flex items-center gap-2 text-gray-600 hover:text-gray-900 mb-6",children:[a.jsx(Eh,{className:"w-4 h-4"}),"Back"]}),a.jsx("div",{className:"bg-white rounded-xl border border-gray-200 overflow-hidden",children:a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8 p-6",children:[a.jsx("div",{className:"aspect-square bg-gray-50 rounded-lg overflow-hidden",children:f?a.jsx("img",{src:f,alt:r.name,className:"w-full h-full object-contain"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-400",children:a.jsx(Ct,{className:"w-24 h-24"})})}),a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.in_stock?a.jsx("span",{className:"px-2 py-1 bg-green-100 text-green-700 text-xs font-medium rounded",children:"In Stock"}):a.jsx("span",{className:"px-2 py-1 bg-red-100 text-red-700 text-xs font-medium rounded",children:"Out of Stock"}),r.strain_type&&a.jsx("span",{className:"px-2 py-1 bg-purple-100 text-purple-700 text-xs font-medium rounded capitalize",children:r.strain_type})]}),a.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-2",children:r.name}),r.brand&&a.jsx("p",{className:"text-lg text-gray-600 font-medium",children:r.brand}),a.jsxs("div",{className:"flex items-center gap-4 mt-2 text-sm text-gray-500",children:[r.store_name&&a.jsx("span",{children:r.store_name}),r.category_name&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"•"}),a.jsx("span",{children:r.category_name})]})]})]}),r.price!==null&&a.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[a.jsxs("div",{className:"text-3xl font-bold text-blue-600",children:["$",parseFloat(r.price).toFixed(2)]}),r.weight&&a.jsx("div",{className:"text-sm text-gray-500 mt-1",children:r.weight})]}),(r.thc_percentage||r.cbd_percentage)&&a.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-gray-700 mb-3",children:"Cannabinoid Content"}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.thc_percentage!==null&&a.jsxs("div",{className:"bg-green-50 rounded-lg p-3",children:[a.jsx("div",{className:"text-xs text-gray-500 uppercase",children:"THC"}),a.jsxs("div",{className:"text-xl font-bold text-green-600",children:[r.thc_percentage,"%"]})]}),r.cbd_percentage!==null&&a.jsxs("div",{className:"bg-blue-50 rounded-lg p-3",children:[a.jsx("div",{className:"text-xs text-gray-500 uppercase",children:"CBD"}),a.jsxs("div",{className:"text-xl font-bold text-blue-600",children:[r.cbd_percentage,"%"]})]})]})]}),r.description&&a.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:"Description"}),a.jsx("p",{className:"text-gray-600 text-sm leading-relaxed",children:r.description})]}),d.terpenes&&d.terpenes.length>0&&a.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:"Terpenes"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:d.terpenes.map(p=>a.jsx("span",{className:"px-2 py-1 bg-amber-100 text-amber-700 text-xs font-medium rounded",children:p},p))})]}),d.effects&&d.effects.length>0&&a.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:"Effects"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:d.effects.map(p=>a.jsx("span",{className:"px-2 py-1 bg-indigo-100 text-indigo-700 text-xs font-medium rounded",children:p},p))})]}),d.flavors&&d.flavors.length>0&&a.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:"Flavors"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:d.flavors.map(p=>a.jsx("span",{className:"px-2 py-1 bg-pink-100 text-pink-700 text-xs font-medium rounded",children:p},p))})]}),d.lineage&&a.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:"Lineage"}),a.jsx("p",{className:"text-gray-600 text-sm",children:d.lineage})]}),r.dutchie_url&&a.jsx("div",{className:"border-t border-gray-100 pt-4",children:a.jsxs("a",{href:r.dutchie_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-blue-600 hover:text-blue-700",children:["View Source",a.jsx(Jr,{className:"w-4 h-4"})]})}),r.last_seen_at&&a.jsxs("div",{className:"text-xs text-gray-400 pt-4 border-t border-gray-100",children:["Last updated: ",new Date(r.last_seen_at).toLocaleString()]})]})]})})]})})}function sF(){const[e,t]=h.useState([]),[r,n]=h.useState(!0),[i,s]=h.useState(new Set),[o,l]=h.useState(new Set),c=dt();h.useEffect(()=>{d()},[]);const d=async()=>{n(!0);try{const b=await B.getStores();t(b.stores)}catch(b){console.error("Failed to load stores:",b)}finally{n(!1)}},u=b=>{const j=b.match(/(?:^|-)(al|ak|az|ar|ca|co|ct|de|fl|ga|hi|id|il|in|ia|ks|ky|la|me|md|ma|mi|mn|ms|mo|mt|ne|nv|nh|nj|nm|ny|nc|nd|oh|ok|or|pa|ri|sc|sd|tn|tx|ut|vt|va|wa|wv|wi|wy)-/i),y={peoria:"AZ"};let w=j?j[1].toUpperCase():null;if(!w){for(const[S,N]of Object.entries(y))if(b.toLowerCase().includes(S)){w=N;break}}return w||"UNKNOWN"},f=b=>{const j=u(b.slug).toLowerCase(),y=b.name.match(/^([^-]+)/),w=y?y[1].trim().toLowerCase().replace(/\s+/g,"-"):"other";return`/stores/${j}/${w}/${b.slug}`},p=e.reduce((b,j)=>{const y=j.name.match(/^([^-]+)/),w=y?y[1].trim():"Other",S=u(j.slug),P={AZ:"Arizona",FL:"Florida",PA:"Pennsylvania",NJ:"New Jersey",MA:"Massachusetts",IL:"Illinois",NY:"New York",MD:"Maryland",MI:"Michigan",OH:"Ohio",CT:"Connecticut",ME:"Maine",MO:"Missouri",NV:"Nevada",OR:"Oregon",UT:"Utah"}[S]||S;return b[w]||(b[w]={}),b[w][P]||(b[w][P]=[]),b[w][P].push(j),b},{}),m=async(b,j,y)=>{y.stopPropagation();try{await B.updateStore(b,{scrape_enabled:!j}),t(e.map(w=>w.id===b?{...w,scrape_enabled:!j}:w))}catch(w){console.error("Failed to update scraping status:",w)}},x=b=>b?new Date(b).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}):"Never",g=b=>{const j=new Set(i);j.has(b)?j.delete(b):j.add(b),s(j)},v=(b,j)=>{const y=`${b}-${j}`,w=new Set(o);w.has(y)?w.delete(y):w.add(y),l(w)};return r?a.jsx(X,{children:a.jsx("div",{className:"flex items-center justify-center h-64",children:a.jsx("div",{className:"w-8 h-8 border-4 border-gray-200 border-t-blue-600 rounded-full animate-spin"})})}):a.jsx(X,{children:a.jsxs("div",{className:"space-y-6",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-blue-50 rounded-lg",children:a.jsx(Bl,{className:"w-6 h-6 text-blue-600"})}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-semibold text-gray-900",children:"Stores"}),a.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:[e.length," total stores"]})]})]})}),a.jsx("div",{className:"bg-white rounded-xl border border-gray-200 overflow-hidden",children:a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{className:"bg-gray-50 border-b border-gray-200",children:a.jsxs("tr",{children:[a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Store Name"}),a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Type"}),a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"View Online"}),a.jsx("th",{className:"px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Categories"}),a.jsx("th",{className:"px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Products"}),a.jsx("th",{className:"px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Scraping"}),a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Last Scraped"})]})}),a.jsx("tbody",{children:Object.entries(p).map(([b,j])=>{const y=Object.values(j).flat().length,w=y===1,S=i.has(b);if(w){const C=Object.values(j).flat()[0];return a.jsxs("tr",{className:"border-b border-gray-100 hover:bg-gray-50 cursor-pointer transition-colors",onClick:()=>c(f(C)),title:"Click to view store",children:[a.jsx("td",{className:"px-6 py-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[C.logo_url?a.jsx("img",{src:C.logo_url,alt:`${C.name} logo`,className:"w-8 h-8 object-contain flex-shrink-0",onError:T=>{T.target.style.display="none"}}):null,a.jsxs("div",{children:[a.jsx("div",{className:"font-semibold text-gray-900",children:C.name}),a.jsx("div",{className:"text-xs text-gray-500",children:C.slug})]})]})}),a.jsx("td",{className:"px-6 py-4",children:a.jsx("span",{className:"px-2 py-1 text-xs font-medium bg-blue-50 text-blue-700 rounded",children:"CannaIQ"})}),a.jsx("td",{className:"px-6 py-4",children:a.jsxs("a",{href:C.dutchie_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-sm text-blue-600 hover:text-blue-700",onClick:T=>T.stopPropagation(),children:[a.jsx("span",{children:"View Online"}),a.jsx(Jr,{className:"w-3 h-3"})]})}),a.jsx("td",{className:"px-6 py-4 text-center",children:a.jsxs("div",{className:"flex items-center justify-center gap-1",children:[a.jsx(Cr,{className:"w-4 h-4 text-gray-400"}),a.jsx("span",{className:"text-sm font-medium text-gray-900",children:C.category_count||0})]})}),a.jsx("td",{className:"px-6 py-4 text-center",children:a.jsxs("div",{className:"flex items-center justify-center gap-1",children:[a.jsx(Ct,{className:"w-4 h-4 text-gray-400"}),a.jsx("span",{className:"text-sm font-medium text-gray-900",children:C.product_count||0})]})}),a.jsx("td",{className:"px-6 py-4 text-center",onClick:T=>T.stopPropagation(),children:a.jsx("button",{onClick:T=>m(C.id,C.scrape_enabled,T),className:"inline-flex items-center gap-1 text-sm font-medium transition-colors",children:C.scrape_enabled?a.jsxs(a.Fragment,{children:[a.jsx(Bx,{className:"w-5 h-5 text-green-600"}),a.jsx("span",{className:"text-green-600",children:"On"})]}):a.jsxs(a.Fragment,{children:[a.jsx(Rx,{className:"w-5 h-5 text-gray-400"}),a.jsx("span",{className:"text-gray-500",children:"Off"})]})})}),a.jsx("td",{className:"px-6 py-4",children:a.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[a.jsx(xr,{className:"w-4 h-4 text-gray-400"}),x(C.last_scraped_at)]})})]},C.id)}const N=Object.values(j).flat()[0],P=N==null?void 0:N.logo_url;return a.jsxs(hs.Fragment,{children:[a.jsx("tr",{className:"bg-gray-100 border-b border-gray-200 cursor-pointer hover:bg-gray-150 transition-colors",onClick:()=>g(b),children:a.jsx("td",{colSpan:7,className:"px-6 py-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Mf,{className:`w-5 h-5 text-gray-600 transition-transform ${S?"rotate-90":""}`}),P&&a.jsx("img",{src:P,alt:`${b} logo`,className:"w-8 h-8 object-contain flex-shrink-0",onError:C=>{C.target.style.display="none"}}),a.jsx("span",{className:"text-base font-semibold text-gray-900",children:b}),a.jsxs("span",{className:"text-sm text-gray-500",children:["(",y," stores)"]})]})})}),S&&Object.entries(j).map(([C,T])=>{const $=`${b}-${C}`,I=o.has($);return a.jsxs(hs.Fragment,{children:[a.jsx("tr",{className:"bg-gray-50 border-b border-gray-100 cursor-pointer hover:bg-gray-100 transition-colors",onClick:()=>v(b,C),children:a.jsx("td",{colSpan:7,className:"px-6 py-3 pl-12",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Mf,{className:`w-4 h-4 text-gray-500 transition-transform ${I?"rotate-90":""}`}),a.jsx("span",{className:"text-sm font-medium text-gray-700",children:C}),a.jsxs("span",{className:"text-xs text-gray-500",children:["(",T.length," locations)"]})]})})}),I&&T.map(A=>a.jsxs("tr",{className:"border-b border-gray-100 hover:bg-gray-50 cursor-pointer transition-colors",onClick:()=>c(f(A)),title:"Click to view store",children:[a.jsx("td",{className:"px-6 py-4 pl-16",children:a.jsxs("div",{children:[a.jsx("div",{className:"font-semibold text-gray-900",children:A.name}),a.jsx("div",{className:"text-xs text-gray-500",children:A.slug})]})}),a.jsx("td",{className:"px-6 py-4",children:a.jsx("span",{className:"px-2 py-1 text-xs font-medium bg-blue-50 text-blue-700 rounded",children:"CannaIQ"})}),a.jsx("td",{className:"px-6 py-4",children:a.jsxs("a",{href:A.dutchie_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-sm text-blue-600 hover:text-blue-700",onClick:R=>R.stopPropagation(),children:[a.jsx("span",{children:"View Online"}),a.jsx(Jr,{className:"w-3 h-3"})]})}),a.jsx("td",{className:"px-6 py-4 text-center",children:a.jsxs("div",{className:"flex items-center justify-center gap-1",children:[a.jsx(Cr,{className:"w-4 h-4 text-gray-400"}),a.jsx("span",{className:"text-sm font-medium text-gray-900",children:A.category_count||0})]})}),a.jsx("td",{className:"px-6 py-4 text-center",children:a.jsxs("div",{className:"flex items-center justify-center gap-1",children:[a.jsx(Ct,{className:"w-4 h-4 text-gray-400"}),a.jsx("span",{className:"text-sm font-medium text-gray-900",children:A.product_count||0})]})}),a.jsx("td",{className:"px-6 py-4 text-center",onClick:R=>R.stopPropagation(),children:a.jsx("button",{onClick:R=>m(A.id,A.scrape_enabled,R),className:"inline-flex items-center gap-1 text-sm font-medium transition-colors",children:A.scrape_enabled?a.jsxs(a.Fragment,{children:[a.jsx(Bx,{className:"w-5 h-5 text-green-600"}),a.jsx("span",{className:"text-green-600",children:"On"})]}):a.jsxs(a.Fragment,{children:[a.jsx(Rx,{className:"w-5 h-5 text-gray-400"}),a.jsx("span",{className:"text-gray-500",children:"Off"})]})})}),a.jsx("td",{className:"px-6 py-4",children:a.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[a.jsx(xr,{className:"w-4 h-4 text-gray-400"}),x(A.last_scraped_at)]})})]},A.id))]},`state-${$}`)})]},`chain-${b}`)})})]})})}),e.length===0&&a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-12 text-center",children:[a.jsx(Bl,{className:"w-16 h-16 text-gray-300 mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"No stores found"}),a.jsx("p",{className:"text-gray-500",children:"Start by adding stores to your database"})]})]})})}function oF(){const e=dt(),[t,r]=h.useState([]),[n,i]=h.useState(!0),[s,o]=h.useState(""),[l,c]=h.useState(""),[d,u]=h.useState(null),[f,p]=h.useState({});h.useEffect(()=>{m()},[]);const m=async()=>{i(!0);try{const y=await B.getDispensaries();r(y.dispensaries)}catch(y){console.error("Failed to load dispensaries:",y)}finally{i(!1)}},x=y=>{u(y),p({dba_name:y.dba_name||"",website:y.website||"",phone:y.phone||"",google_rating:y.google_rating||"",google_review_count:y.google_review_count||""})},g=async()=>{if(d)try{await B.updateDispensary(d.id,f),await m(),u(null),p({})}catch(y){console.error("Failed to update dispensary:",y),alert("Failed to update dispensary")}},v=()=>{u(null),p({})},b=t.filter(y=>{const w=s.toLowerCase(),S=!s||y.name.toLowerCase().includes(w)||y.company_name&&y.company_name.toLowerCase().includes(w)||y.dba_name&&y.dba_name.toLowerCase().includes(w),N=!l||y.city===l;return S&&N}),j=Array.from(new Set(t.map(y=>y.city).filter(Boolean))).sort();return a.jsxs(X,{children:[a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Dispensaries"}),a.jsxs("p",{className:"text-sm text-gray-600 mt-1",children:["AZDHS official dispensary directory (",t.length," total)"]})]}),a.jsx("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Search"}),a.jsxs("div",{className:"relative",children:[a.jsx(sj,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),a.jsx("input",{type:"text",value:s,onChange:y=>o(y.target.value),placeholder:"Search by name or company...",className:"w-full pl-10 pr-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Filter by City"}),a.jsxs("select",{value:l,onChange:y=>c(y.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",children:[a.jsx("option",{value:"",children:"All Cities"}),j.map(y=>a.jsx("option",{value:y,children:y},y))]})]})]})}),n?a.jsxs("div",{className:"text-center py-12",children:[a.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-blue-500 border-t-transparent"}),a.jsx("p",{className:"mt-2 text-sm text-gray-600",children:"Loading dispensaries..."})]}):a.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 overflow-hidden",children:[a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{className:"bg-gray-50 border-b border-gray-200",children:a.jsxs("tr",{children:[a.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:"Name"}),a.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:"Company"}),a.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:"Address"}),a.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:"City"}),a.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:"Phone"}),a.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:"Email"}),a.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:"Website"}),a.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:"Actions"})]})}),a.jsx("tbody",{className:"divide-y divide-gray-200",children:b.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:8,className:"px-4 py-8 text-center text-sm text-gray-500",children:"No dispensaries found"})}):b.map(y=>a.jsxs("tr",{className:"hover:bg-gray-50",children:[a.jsx("td",{className:"px-4 py-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ln,{className:"w-4 h-4 text-gray-400 flex-shrink-0"}),a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"text-sm font-medium text-gray-900",children:y.dba_name||y.name}),y.dba_name&&y.google_rating&&a.jsxs("span",{className:"text-xs text-gray-500",children:["⭐ ",y.google_rating," (",y.google_review_count," reviews)"]})]})]})}),a.jsx("td",{className:"px-4 py-3",children:a.jsx("span",{className:"text-sm text-gray-600",children:y.company_name||"-"})}),a.jsx("td",{className:"px-4 py-3",children:a.jsxs("div",{className:"flex items-start gap-1",children:[a.jsx(yi,{className:"w-3 h-3 text-gray-400 flex-shrink-0 mt-0.5"}),a.jsx("span",{className:"text-sm text-gray-600",children:y.address||"-"})]})}),a.jsxs("td",{className:"px-4 py-3",children:[a.jsx("span",{className:"text-sm text-gray-600",children:y.city||"-"}),y.zip&&a.jsxs("span",{className:"text-xs text-gray-400 ml-1",children:["(",y.zip,")"]})]}),a.jsx("td",{className:"px-4 py-3",children:y.phone?a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Ms,{className:"w-3 h-3 text-gray-400"}),a.jsx("span",{className:"text-sm text-gray-600",children:y.phone.replace(/(\d{3})(\d{3})(\d{4})/,"($1) $2-$3")})]}):a.jsx("span",{className:"text-sm text-gray-400",children:"-"})}),a.jsx("td",{className:"px-4 py-3",children:y.email?a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Th,{className:"w-3 h-3 text-gray-400"}),a.jsx("a",{href:`mailto:${y.email}`,className:"text-sm text-blue-600 hover:text-blue-800",children:y.email})]}):a.jsx("span",{className:"text-sm text-gray-400",children:"-"})}),a.jsx("td",{className:"px-4 py-3",children:y.website?a.jsxs("a",{href:y.website,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-blue-600 hover:text-blue-800",children:[a.jsx(Jr,{className:"w-3 h-3"}),a.jsx("span",{children:"Visit Site"})]}):a.jsx("span",{className:"text-sm text-gray-400",children:"-"})}),a.jsx("td",{className:"px-4 py-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:()=>x(y),className:"inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium text-gray-600 hover:text-gray-800 hover:bg-gray-50 rounded-lg transition-colors",title:"Edit",children:a.jsx(aj,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>{const w=y.city.toLowerCase().replace(/\s+/g,"-");e(`/dispensaries/${y.state}/${w}/${y.slug}`)},className:"inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium text-blue-600 hover:text-blue-800 hover:bg-blue-50 rounded-lg transition-colors",title:"View",children:a.jsx(u6,{className:"w-4 h-4"})})]})})]},y.id))})]})}),a.jsx("div",{className:"bg-gray-50 px-4 py-3 border-t border-gray-200",children:a.jsxs("div",{className:"text-sm text-gray-600",children:["Showing ",b.length," of ",t.length," dispensaries"]})})]})]}),d&&a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-2xl w-full mx-4 max-h-[90vh] overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200",children:[a.jsxs("h2",{className:"text-xl font-bold text-gray-900",children:["Edit Dispensary: ",d.name]}),a.jsx("button",{onClick:v,className:"text-gray-400 hover:text-gray-600",children:a.jsx(Mh,{className:"w-6 h-6"})})]}),a.jsxs("div",{className:"p-6 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"DBA Name (Display Name)"}),a.jsx("input",{type:"text",value:f.dba_name,onChange:y=>p({...f,dba_name:y.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"e.g., Green Med Wellness"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Website"}),a.jsx("input",{type:"url",value:f.website,onChange:y=>p({...f,website:y.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"https://example.com"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Phone Number"}),a.jsx("input",{type:"tel",value:f.phone,onChange:y=>p({...f,phone:y.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"5551234567"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Google Rating"}),a.jsx("input",{type:"number",step:"0.1",min:"0",max:"5",value:f.google_rating,onChange:y=>p({...f,google_rating:y.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"4.5"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Review Count"}),a.jsx("input",{type:"number",min:"0",value:f.google_review_count,onChange:y=>p({...f,google_review_count:y.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"123"})]})]}),a.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg space-y-2",children:[a.jsxs("div",{className:"text-sm",children:[a.jsx("span",{className:"font-medium text-gray-700",children:"AZDHS Name:"})," ",a.jsx("span",{className:"text-gray-600",children:d.name})]}),a.jsxs("div",{className:"text-sm",children:[a.jsx("span",{className:"font-medium text-gray-700",children:"Address:"})," ",a.jsxs("span",{className:"text-gray-600",children:[d.address,", ",d.city,", ",d.state," ",d.zip]})]})]})]}),a.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-gray-200",children:[a.jsx("button",{onClick:v,className:"px-4 py-2 text-sm font-medium text-gray-700 hover:text-gray-900 hover:bg-gray-100 rounded-lg transition-colors",children:"Cancel"}),a.jsxs("button",{onClick:g,className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-lg transition-colors",children:[a.jsx(T6,{className:"w-4 h-4"}),"Save Changes"]})]})]})})]})}function lF(){const{state:e,city:t,slug:r}=_a(),n=dt(),[i,s]=h.useState(null),[o,l]=h.useState([]),[c,d]=h.useState([]),[u,f]=h.useState([]),[p,m]=h.useState(!0),[x,g]=h.useState("products"),[v,b]=h.useState(!1),[j,y]=h.useState(!1),[w,S]=h.useState(""),[N,P]=h.useState(1),[C]=h.useState(25),T=D=>{if(!D)return"Never";const O=new Date(D),z=new Date().getTime()-O.getTime(),W=Math.floor(z/(1e3*60)),K=Math.floor(z/(1e3*60*60)),ee=Math.floor(z/(1e3*60*60*24));return W<1?"Just now":W<60?`${W}m ago`:K<24?`${K}h ago`:ee===1?"Yesterday":ee<7?`${ee} days ago`:O.toLocaleDateString()};h.useEffect(()=>{$()},[r]);const $=async()=>{m(!0);try{const[D,O,k,z]=await Promise.all([B.getDispensary(r),B.getDispensaryProducts(r).catch(()=>({products:[]})),B.getDispensaryBrands(r).catch(()=>({brands:[]})),B.getDispensarySpecials(r).catch(()=>({specials:[]}))]);s(D),l(O.products),d(k.brands),f(z.specials)}catch(D){console.error("Failed to load dispensary:",D)}finally{m(!1)}},I=async D=>{b(!1),y(!0);try{const O=await fetch(`https://dispos.crawlsy.com/api/dispensaries/${r}/scrape`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("token")}`},body:JSON.stringify({type:D})});if(!O.ok)throw new Error("Failed to trigger scraping");const k=await O.json();alert(`${D.charAt(0).toUpperCase()+D.slice(1)} update started! ${k.message||""}`)}catch(O){console.error("Failed to trigger scraping:",O),alert("Failed to start update. Please try again.")}finally{y(!1)}},A=o.filter(D=>{var k,z,W,K,ee;if(!w)return!0;const O=w.toLowerCase();return((k=D.name)==null?void 0:k.toLowerCase().includes(O))||((z=D.brand)==null?void 0:z.toLowerCase().includes(O))||((W=D.variant)==null?void 0:W.toLowerCase().includes(O))||((K=D.description)==null?void 0:K.toLowerCase().includes(O))||((ee=D.strain_type)==null?void 0:ee.toLowerCase().includes(O))}),R=Math.ceil(A.length/C),H=(N-1)*C,M=H+C,_=A.slice(H,M);return h.useEffect(()=>{P(1)},[w]),p?a.jsx(X,{children:a.jsxs("div",{className:"text-center py-12",children:[a.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-blue-500 border-t-transparent"}),a.jsx("p",{className:"mt-2 text-sm text-gray-600",children:"Loading dispensary..."})]})}):i?a.jsx(X,{children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsxs("button",{onClick:()=>n("/dispensaries"),className:"flex items-center gap-2 text-sm text-gray-600 hover:text-gray-900",children:[a.jsx(Eh,{className:"w-4 h-4"}),"Back to Dispensaries"]}),a.jsxs("div",{className:"relative",children:[a.jsxs("button",{onClick:()=>b(!v),disabled:j,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-lg disabled:opacity-50 disabled:cursor-not-allowed",children:[a.jsx(Xt,{className:`w-4 h-4 ${j?"animate-spin":""}`}),j?"Updating...":"Update",!j&&a.jsx(ij,{className:"w-4 h-4"})]}),v&&!j&&a.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-white rounded-lg shadow-lg border border-gray-200 z-10",children:[a.jsx("button",{onClick:()=>I("products"),className:"w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 rounded-t-lg",children:"Products"}),a.jsx("button",{onClick:()=>I("brands"),className:"w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-100",children:"Brands"}),a.jsx("button",{onClick:()=>I("specials"),className:"w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-100",children:"Specials"}),a.jsx("button",{onClick:()=>I("all"),className:"w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 rounded-b-lg border-t border-gray-200",children:"All"})]})]})]}),a.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 p-6",children:[a.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[a.jsxs("div",{className:"flex items-start gap-4",children:[a.jsx("div",{className:"p-3 bg-blue-50 rounded-lg",children:a.jsx(Ln,{className:"w-8 h-8 text-blue-600"})}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:i.dba_name||i.name}),i.company_name&&a.jsx("p",{className:"text-sm text-gray-600 mt-1",children:i.company_name})]})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600 bg-gray-50 px-4 py-2 rounded-lg",children:[a.jsx(Dh,{className:"w-4 h-4"}),a.jsxs("div",{children:[a.jsx("span",{className:"font-medium",children:"Last Crawl Date:"}),a.jsx("span",{className:"ml-2",children:i.last_menu_scrape?new Date(i.last_menu_scrape).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"Never"})]})]})]}),a.jsxs("div",{className:"flex flex-wrap gap-4",children:[i.address&&a.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[a.jsx(yi,{className:"w-4 h-4"}),a.jsxs("span",{children:[i.address,", ",i.city,", ",i.state," ",i.zip]})]}),i.phone&&a.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[a.jsx(Ms,{className:"w-4 h-4"}),a.jsx("span",{children:i.phone.replace(/(\d{3})(\d{3})(\d{4})/,"($1) $2-$3")})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[a.jsx(Jr,{className:"w-4 h-4"}),i.website?a.jsx("a",{href:i.website,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:text-blue-800",children:"Website"}):a.jsx("span",{children:"Website N/A"})]}),i.email&&a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Th,{className:"w-4 h-4 text-gray-400"}),a.jsx("a",{href:`mailto:${i.email}`,className:"text-blue-600 hover:text-blue-800",children:i.email})]}),i.azdhs_url&&a.jsxs("a",{href:i.azdhs_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-sm text-blue-600 hover:text-blue-800",children:[a.jsx(Jr,{className:"w-4 h-4"}),a.jsx("span",{children:"AZDHS Profile"})]}),a.jsxs(zl,{to:"/schedule",className:"flex items-center gap-2 text-sm text-blue-600 hover:text-blue-800",children:[a.jsx(xr,{className:"w-4 h-4"}),a.jsx("span",{children:"View Schedule"})]})]})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-6",children:[a.jsx("button",{onClick:()=>{g("products"),S("")},className:"bg-white rounded-lg border border-gray-200 p-6 hover:border-blue-300 hover:shadow-md transition-all cursor-pointer text-left",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-green-50 rounded-lg",children:a.jsx(Ct,{className:"w-5 h-5 text-green-600"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-gray-600",children:"Total Products"}),a.jsx("p",{className:"text-2xl font-bold text-gray-900",children:o.length})]})]})}),a.jsx("button",{onClick:()=>g("brands"),className:"bg-white rounded-lg border border-gray-200 p-6 hover:border-blue-300 hover:shadow-md transition-all cursor-pointer text-left",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-purple-50 rounded-lg",children:a.jsx(Cr,{className:"w-5 h-5 text-purple-600"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-gray-600",children:"Brands"}),a.jsx("p",{className:"text-2xl font-bold text-gray-900",children:c.length})]})]})}),a.jsx("button",{onClick:()=>g("specials"),className:"bg-white rounded-lg border border-gray-200 p-6 hover:border-blue-300 hover:shadow-md transition-all cursor-pointer text-left",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-blue-50 rounded-lg",children:a.jsx(zn,{className:"w-5 h-5 text-blue-600"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-gray-600",children:"Active Specials"}),a.jsx("p",{className:"text-2xl font-bold text-gray-900",children:u.length})]})]})}),a.jsx("div",{className:"bg-white rounded-lg border border-gray-200 p-6",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-orange-50 rounded-lg",children:a.jsx(o6,{className:"w-5 h-5 text-orange-600"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-gray-600",children:"Avg Price"}),a.jsx("p",{className:"text-2xl font-bold text-gray-900",children:o.length>0?`$${(o.reduce((D,O)=>D+(O.sale_price||O.regular_price||0),0)/o.length).toFixed(2)}`:"-"})]})]})})]}),a.jsxs("div",{className:"bg-white rounded-lg border border-gray-200",children:[a.jsx("div",{className:"border-b border-gray-200",children:a.jsxs("div",{className:"flex gap-4 px-6",children:[a.jsxs("button",{onClick:()=>g("products"),className:`py-4 px-2 text-sm font-medium border-b-2 ${x==="products"?"border-blue-600 text-blue-600":"border-transparent text-gray-600 hover:text-gray-900"}`,children:["Products (",o.length,")"]}),a.jsxs("button",{onClick:()=>g("brands"),className:`py-4 px-2 text-sm font-medium border-b-2 ${x==="brands"?"border-blue-600 text-blue-600":"border-transparent text-gray-600 hover:text-gray-900"}`,children:["Brands (",c.length,")"]}),a.jsxs("button",{onClick:()=>g("specials"),className:`py-4 px-2 text-sm font-medium border-b-2 ${x==="specials"?"border-blue-600 text-blue-600":"border-transparent text-gray-600 hover:text-gray-900"}`,children:["Specials (",u.length,")"]})]})}),a.jsxs("div",{className:"p-6",children:[x==="products"&&a.jsx("div",{className:"space-y-4",children:o.length===0?a.jsx("p",{className:"text-center py-8 text-gray-500",children:"No products available"}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[a.jsx("input",{type:"text",placeholder:"Search products by name, brand, variant, description, or strain type...",value:w,onChange:D=>S(D.target.value),className:"input input-bordered input-sm flex-1"}),w&&a.jsx("button",{onClick:()=>S(""),className:"btn btn-sm btn-ghost",children:"Clear"}),a.jsxs("div",{className:"text-sm text-gray-600",children:["Showing ",H+1,"-",Math.min(M,A.length)," of ",A.length," products"]})]}),a.jsx("div",{className:"overflow-x-auto -mx-6 px-6",children:a.jsxs("table",{className:"table table-xs table-zebra table-pin-rows w-full",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Image"}),a.jsx("th",{children:"Product Name"}),a.jsx("th",{children:"Brand"}),a.jsx("th",{children:"Variant"}),a.jsx("th",{children:"Description"}),a.jsx("th",{className:"text-right",children:"Price"}),a.jsx("th",{className:"text-center",children:"THC %"}),a.jsx("th",{className:"text-center",children:"CBD %"}),a.jsx("th",{className:"text-center",children:"Strain Type"}),a.jsx("th",{className:"text-center",children:"In Stock"}),a.jsx("th",{children:"Last Updated"}),a.jsx("th",{children:"Actions"})]})}),a.jsx("tbody",{children:_.map(D=>a.jsxs("tr",{children:[a.jsx("td",{className:"whitespace-nowrap",children:D.image_url?a.jsx("img",{src:D.image_url,alt:D.name,className:"w-12 h-12 object-cover rounded",onError:O=>O.currentTarget.style.display="none"}):"-"}),a.jsx("td",{className:"font-medium max-w-[150px]",children:a.jsx("div",{className:"line-clamp-2",title:D.name,children:D.name})}),a.jsx("td",{className:"max-w-[120px]",children:a.jsx("div",{className:"line-clamp-2",title:D.brand||"-",children:D.brand||"-"})}),a.jsx("td",{className:"max-w-[100px]",children:a.jsx("div",{className:"line-clamp-2",title:D.variant||"-",children:D.variant||"-"})}),a.jsx("td",{className:"w-[120px]",children:a.jsx("span",{title:D.description,children:D.description?D.description.length>15?D.description.substring(0,15)+"...":D.description:"-"})}),a.jsx("td",{className:"text-right font-semibold whitespace-nowrap",children:D.sale_price?a.jsxs("div",{className:"flex flex-col items-end",children:[a.jsxs("span",{className:"text-error",children:["$",D.sale_price]}),a.jsxs("span",{className:"text-gray-400 line-through text-xs",children:["$",D.regular_price]})]}):D.regular_price?`$${D.regular_price}`:"-"}),a.jsx("td",{className:"text-center whitespace-nowrap",children:D.thc_percentage?a.jsxs("span",{className:"badge badge-success badge-sm",children:[D.thc_percentage,"%"]}):"-"}),a.jsx("td",{className:"text-center whitespace-nowrap",children:D.cbd_percentage?a.jsxs("span",{className:"badge badge-info badge-sm",children:[D.cbd_percentage,"%"]}):"-"}),a.jsx("td",{className:"text-center whitespace-nowrap",children:D.strain_type?a.jsx("span",{className:"badge badge-ghost badge-sm",children:D.strain_type}):"-"}),a.jsx("td",{className:"text-center whitespace-nowrap",children:D.in_stock?a.jsx("span",{className:"badge badge-success badge-sm",children:"Yes"}):D.in_stock===!1?a.jsx("span",{className:"badge badge-error badge-sm",children:"No"}):"-"}),a.jsx("td",{className:"whitespace-nowrap text-xs text-gray-500",children:D.updated_at?T(D.updated_at):"-"}),a.jsx("td",{children:a.jsxs("div",{className:"flex gap-1",children:[D.dutchie_url&&a.jsx("a",{href:D.dutchie_url,target:"_blank",rel:"noopener noreferrer",className:"btn btn-xs btn-outline",children:"Source"}),a.jsx("button",{onClick:()=>n(`/products/${D.id}`),className:"btn btn-xs btn-primary",children:"Details"})]})})]},D.id))})]})}),R>1&&a.jsxs("div",{className:"flex justify-center items-center gap-2 mt-4",children:[a.jsx("button",{onClick:()=>P(D=>Math.max(1,D-1)),disabled:N===1,className:"btn btn-sm btn-outline",children:"Previous"}),a.jsx("div",{className:"flex gap-1",children:Array.from({length:R},(D,O)=>O+1).map(D=>{const O=D===1||D===R||D>=N-1&&D<=N+1;return D===2&&N>3||D===R-1&&NP(D),className:`btn btn-sm ${N===D?"btn-primary":"btn-outline"}`,children:D},D):null})}),a.jsx("button",{onClick:()=>P(D=>Math.min(R,D+1)),disabled:N===R,className:"btn btn-sm btn-outline",children:"Next"})]})]})}),x==="brands"&&a.jsx("div",{className:"space-y-4",children:c.length===0?a.jsx("p",{className:"text-center py-8 text-gray-500",children:"No brands available"}):a.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:c.map(D=>a.jsxs("button",{onClick:()=>{g("products"),S(D.brand)},className:"border border-gray-200 rounded-lg p-4 text-center hover:border-blue-300 hover:shadow-md transition-all cursor-pointer",children:[a.jsx("p",{className:"font-medium text-gray-900 line-clamp-2",children:D.brand}),a.jsxs("p",{className:"text-sm text-gray-600 mt-1",children:[D.product_count," product",D.product_count!==1?"s":""]})]},D.brand))})}),x==="specials"&&a.jsx("div",{className:"space-y-4",children:u.length===0?a.jsx("p",{className:"text-center py-8 text-gray-500",children:"No active specials"}):a.jsx("div",{className:"space-y-3",children:u.map(D=>a.jsxs("div",{className:"border border-gray-200 rounded-lg p-4",children:[a.jsx("h4",{className:"font-medium text-gray-900",children:D.name}),D.description&&a.jsx("p",{className:"text-sm text-gray-600 mt-1",children:D.description}),a.jsxs("div",{className:"flex items-center gap-4 mt-2 text-sm text-gray-500",children:[a.jsxs("span",{children:[new Date(D.start_date).toLocaleDateString()," -"," ",D.end_date?new Date(D.end_date).toLocaleDateString():"Ongoing"]}),a.jsxs("span",{children:[D.product_count," products"]})]})]},D.id))})})]})]})]})}):a.jsx(X,{children:a.jsx("div",{className:"text-center py-12",children:a.jsx("p",{className:"text-gray-600",children:"Dispensary not found"})})})}function cF(){var $,I;const{slug:e}=_a(),t=dt(),[r,n]=h.useState(null),[i,s]=h.useState([]),[o,l]=h.useState([]),[c,d]=h.useState([]),[u,f]=h.useState(!0),[p,m]=h.useState(null),[x,g]=h.useState(""),[v,b]=h.useState("products"),[j,y]=h.useState("name");h.useEffect(()=>{w()},[e]),h.useEffect(()=>{r&&S()},[p,x,j,r]);const w=async()=>{f(!0);try{const R=(await B.getStores()).stores.find(D=>D.slug===e);if(!R)throw new Error("Store not found");const[H,M,_]=await Promise.all([B.getStore(R.id),B.getCategories(R.id),B.getStoreBrands(R.id)]);n(H),l(M.categories||[]),d(_.brands||[])}catch(A){console.error("Failed to load store data:",A)}finally{f(!1)}},S=async()=>{if(r)try{const A={store_id:r.id,limit:1e3};p&&(A.category_id=p),x&&(A.brand=x);let H=(await B.getProducts(A)).products||[];H.sort((M,_)=>{switch(j){case"name":return(M.name||"").localeCompare(_.name||"");case"price_asc":return(M.price||0)-(_.price||0);case"price_desc":return(_.price||0)-(M.price||0);case"thc":return(_.thc_percentage||0)-(M.thc_percentage||0);default:return 0}}),s(H)}catch(A){console.error("Failed to load products:",A)}},N=A=>A.image_url_full?A.image_url_full:A.medium_path?`http://localhost:9020/dutchie/${A.medium_path}`:A.thumbnail_path?`http://localhost:9020/dutchie/${A.thumbnail_path}`:"https://via.placeholder.com/300x300?text=No+Image",P=A=>A?new Date(A).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}):"Never",C=A=>{switch(A==null?void 0:A.toLowerCase()){case"dutchie":return"bg-green-100 text-green-700";case"jane":return"bg-purple-100 text-purple-700";case"treez":return"bg-blue-100 text-blue-700";case"weedmaps":return"bg-orange-100 text-orange-700";case"leafly":return"bg-emerald-100 text-emerald-700";default:return"bg-gray-100 text-gray-700"}},T=A=>{switch(A){case"completed":return a.jsxs("span",{className:"px-2 py-1 text-xs font-medium bg-green-100 text-green-700 rounded-full flex items-center gap-1",children:[a.jsx(Pr,{className:"w-3 h-3"})," Completed"]});case"running":return a.jsxs("span",{className:"px-2 py-1 text-xs font-medium bg-blue-100 text-blue-700 rounded-full flex items-center gap-1",children:[a.jsx(Xt,{className:"w-3 h-3 animate-spin"})," Running"]});case"failed":return a.jsxs("span",{className:"px-2 py-1 text-xs font-medium bg-red-100 text-red-700 rounded-full flex items-center gap-1",children:[a.jsx(Hr,{className:"w-3 h-3"})," Failed"]});case"pending":return a.jsxs("span",{className:"px-2 py-1 text-xs font-medium bg-yellow-100 text-yellow-700 rounded-full flex items-center gap-1",children:[a.jsx(xr,{className:"w-3 h-3"})," Pending"]});default:return a.jsx("span",{className:"px-2 py-1 text-xs font-medium bg-gray-100 text-gray-700 rounded-full",children:A})}};return u?a.jsx(X,{children:a.jsx("div",{className:"flex items-center justify-center h-64",children:a.jsx("div",{className:"w-8 h-8 border-4 border-gray-200 border-t-blue-600 rounded-full animate-spin"})})}):r?a.jsx(X,{children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[a.jsxs("div",{className:"flex items-start justify-between mb-6",children:[a.jsxs("div",{className:"flex items-start gap-4",children:[a.jsx("button",{onClick:()=>t("/stores"),className:"text-gray-600 hover:text-gray-900 mt-1",children:"← Back"}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h1",{className:"text-2xl font-semibold text-gray-900",children:r.name}),a.jsx("span",{className:`px-2 py-1 text-xs font-medium rounded ${C(r.provider)}`,children:r.provider||"Unknown"})]}),a.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:["Store ID: ",r.id]})]})]}),a.jsxs("a",{href:r.dutchie_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-sm text-blue-600 hover:text-blue-700",children:["View Menu ",a.jsx(Jr,{className:"w-4 h-4"})]})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4 mb-6",children:[a.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-2 text-gray-500 text-xs mb-1",children:[a.jsx(Ct,{className:"w-4 h-4"}),"Products"]}),a.jsx("p",{className:"text-xl font-semibold text-gray-900",children:r.product_count||0})]}),a.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-2 text-gray-500 text-xs mb-1",children:[a.jsx(Cr,{className:"w-4 h-4"}),"Categories"]}),a.jsx("p",{className:"text-xl font-semibold text-gray-900",children:r.category_count||0})]}),a.jsxs("div",{className:"p-4 bg-green-50 rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-2 text-green-600 text-xs mb-1",children:[a.jsx(Pr,{className:"w-4 h-4"}),"In Stock"]}),a.jsx("p",{className:"text-xl font-semibold text-green-700",children:r.in_stock_count||0})]}),a.jsxs("div",{className:"p-4 bg-red-50 rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-2 text-red-600 text-xs mb-1",children:[a.jsx(Hr,{className:"w-4 h-4"}),"Out of Stock"]}),a.jsx("p",{className:"text-xl font-semibold text-red-700",children:r.out_of_stock_count||0})]}),a.jsxs("div",{className:`p-4 rounded-lg ${r.is_stale?"bg-yellow-50":"bg-blue-50"}`,children:[a.jsxs("div",{className:`flex items-center gap-2 text-xs mb-1 ${r.is_stale?"text-yellow-600":"text-blue-600"}`,children:[a.jsx(xr,{className:"w-4 h-4"}),"Freshness"]}),a.jsx("p",{className:`text-sm font-semibold ${r.is_stale?"text-yellow-700":"text-blue-700"}`,children:r.freshness||"Never scraped"})]}),a.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-2 text-gray-500 text-xs mb-1",children:[a.jsx(Dh,{className:"w-4 h-4"}),"Next Crawl"]}),a.jsx("p",{className:"text-sm font-semibold text-gray-700",children:($=r.schedule)!=null&&$.next_run_at?P(r.schedule.next_run_at):"Not scheduled"})]})]}),r.linked_dispensary&&a.jsxs("div",{className:"p-4 bg-indigo-50 rounded-lg mb-6",children:[a.jsxs("div",{className:"flex items-center gap-2 text-indigo-600 text-xs mb-2",children:[a.jsx(YA,{className:"w-4 h-4"}),"Linked Dispensary"]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"font-semibold text-indigo-900",children:r.linked_dispensary.name}),a.jsxs("p",{className:"text-sm text-indigo-700 flex items-center gap-1",children:[a.jsx(yi,{className:"w-3 h-3"}),r.linked_dispensary.city,", ",r.linked_dispensary.state,r.linked_dispensary.address&&` - ${r.linked_dispensary.address}`]})]}),a.jsx("button",{onClick:()=>t(`/dispensaries/${r.linked_dispensary.slug}`),className:"text-sm text-indigo-600 hover:text-indigo-700 font-medium",children:"View Dispensary →"})]})]}),a.jsxs("div",{className:"flex gap-2 border-b border-gray-200",children:[a.jsx("button",{onClick:()=>b("products"),className:`px-4 py-2 border-b-2 transition-colors ${v==="products"?"border-blue-600 text-blue-600 font-medium":"border-transparent text-gray-600 hover:text-gray-900"}`,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ct,{className:"w-4 h-4"}),"Products (",i.length,")"]})}),a.jsx("button",{onClick:()=>b("brands"),className:`px-4 py-2 border-b-2 transition-colors ${v==="brands"?"border-blue-600 text-blue-600 font-medium":"border-transparent text-gray-600 hover:text-gray-900"}`,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Cr,{className:"w-4 h-4"}),"Brands (",c.length,")"]})}),a.jsx("button",{onClick:()=>b("specials"),className:`px-4 py-2 border-b-2 transition-colors ${v==="specials"?"border-blue-600 text-blue-600 font-medium":"border-transparent text-gray-600 hover:text-gray-900"}`,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Fx,{className:"w-4 h-4"}),"Specials"]})}),a.jsx("button",{onClick:()=>b("crawl-history"),className:`px-4 py-2 border-b-2 transition-colors ${v==="crawl-history"?"border-blue-600 text-blue-600 font-medium":"border-transparent text-gray-600 hover:text-gray-900"}`,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(na,{className:"w-4 h-4"}),"Crawl History (",((I=r.recent_jobs)==null?void 0:I.length)||0,")"]})})]})]}),v==="crawl-history"&&a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 overflow-hidden",children:[a.jsxs("div",{className:"p-4 border-b border-gray-200",children:[a.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Recent Crawl Jobs"}),a.jsx("p",{className:"text-sm text-gray-500",children:"Last 10 crawl jobs for this store"})]}),r.recent_jobs&&r.recent_jobs.length>0?a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{className:"bg-gray-50",children:a.jsxs("tr",{children:[a.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Status"}),a.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Type"}),a.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Started"}),a.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Completed"}),a.jsx("th",{className:"px-4 py-3 text-center text-xs font-medium text-gray-500 uppercase",children:"Found"}),a.jsx("th",{className:"px-4 py-3 text-center text-xs font-medium text-gray-500 uppercase",children:"New"}),a.jsx("th",{className:"px-4 py-3 text-center text-xs font-medium text-gray-500 uppercase",children:"Updated"}),a.jsx("th",{className:"px-4 py-3 text-center text-xs font-medium text-gray-500 uppercase",children:"In Stock"}),a.jsx("th",{className:"px-4 py-3 text-center text-xs font-medium text-gray-500 uppercase",children:"Out of Stock"}),a.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Error"})]})}),a.jsx("tbody",{className:"divide-y divide-gray-100",children:r.recent_jobs.map(A=>a.jsxs("tr",{className:"hover:bg-gray-50",children:[a.jsx("td",{className:"px-4 py-3",children:T(A.status)}),a.jsx("td",{className:"px-4 py-3 text-sm text-gray-700",children:A.job_type||"-"}),a.jsx("td",{className:"px-4 py-3 text-sm text-gray-700",children:P(A.started_at)}),a.jsx("td",{className:"px-4 py-3 text-sm text-gray-700",children:P(A.completed_at)}),a.jsx("td",{className:"px-4 py-3 text-center text-sm font-medium text-gray-900",children:A.products_found??"-"}),a.jsx("td",{className:"px-4 py-3 text-center text-sm font-medium text-green-600",children:A.products_new??"-"}),a.jsx("td",{className:"px-4 py-3 text-center text-sm font-medium text-blue-600",children:A.products_updated??"-"}),a.jsx("td",{className:"px-4 py-3 text-center text-sm font-medium text-green-600",children:A.in_stock_count??"-"}),a.jsx("td",{className:"px-4 py-3 text-center text-sm font-medium text-red-600",children:A.out_of_stock_count??"-"}),a.jsx("td",{className:"px-4 py-3 text-sm text-red-600 max-w-xs truncate",title:A.error_message||"",children:A.error_message||"-"})]},A.id))})]})}):a.jsxs("div",{className:"text-center py-12",children:[a.jsx(na,{className:"w-16 h-16 text-gray-300 mx-auto mb-4"}),a.jsx("p",{className:"text-gray-500",children:"No crawl history available"})]})]}),v==="products"&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"bg-white rounded-xl border border-gray-200 p-4",children:a.jsxs("div",{className:"flex flex-wrap gap-4",children:[a.jsxs("div",{className:"flex-1 min-w-[200px]",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Category"}),a.jsxs("select",{value:p||"",onChange:A=>m(A.target.value?parseInt(A.target.value):null),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",children:[a.jsx("option",{value:"",children:"All Categories"}),o.map(A=>a.jsxs("option",{value:A.id,children:[A.name," (",i.filter(R=>R.category_id===A.id).length,")"]},A.id))]})]}),a.jsxs("div",{className:"flex-1 min-w-[200px]",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Brand"}),a.jsxs("select",{value:x,onChange:A=>g(A.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",children:[a.jsx("option",{value:"",children:"All Brands"}),c.map(A=>a.jsx("option",{value:A,children:A},A))]})]}),a.jsxs("div",{className:"flex-1 min-w-[200px]",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Sort By"}),a.jsxs("select",{value:j,onChange:A=>y(A.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",children:[a.jsx("option",{value:"name",children:"Name (A-Z)"}),a.jsx("option",{value:"price_asc",children:"Price (Low to High)"}),a.jsx("option",{value:"price_desc",children:"Price (High to Low)"}),a.jsx("option",{value:"thc",children:"THC % (High to Low)"})]})]})]})}),i.length>0?a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:i.map(A=>a.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 overflow-hidden hover:shadow-lg transition-shadow",children:[a.jsxs("div",{className:"aspect-square bg-gray-50 relative",children:[a.jsx("img",{src:N(A),alt:A.name,className:"w-full h-full object-cover"}),A.in_stock?a.jsx("span",{className:"absolute top-2 right-2 px-2 py-1 bg-green-500 text-white text-xs font-medium rounded",children:"In Stock"}):a.jsx("span",{className:"absolute top-2 right-2 px-2 py-1 bg-red-500 text-white text-xs font-medium rounded",children:"Out of Stock"})]}),a.jsxs("div",{className:"p-3 space-y-2",children:[a.jsx("h3",{className:"font-semibold text-sm text-gray-900 line-clamp-2",children:A.name}),A.brand&&a.jsx("p",{className:"text-xs text-gray-600 font-medium",children:A.brand}),A.category_name&&a.jsx("p",{className:"text-xs text-gray-500",children:A.category_name}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 pt-2 border-t border-gray-100",children:[A.price!==null&&a.jsxs("div",{className:"text-xs",children:[a.jsx("span",{className:"text-gray-500",children:"Price:"}),a.jsxs("span",{className:"ml-1 font-semibold text-blue-600",children:["$",parseFloat(A.price).toFixed(2)]})]}),A.weight&&a.jsxs("div",{className:"text-xs",children:[a.jsx("span",{className:"text-gray-500",children:"Weight:"}),a.jsx("span",{className:"ml-1 font-medium",children:A.weight})]}),A.thc_percentage!==null&&a.jsxs("div",{className:"text-xs",children:[a.jsx("span",{className:"text-gray-500",children:"THC:"}),a.jsxs("span",{className:"ml-1 font-medium text-green-600",children:[A.thc_percentage,"%"]})]}),A.cbd_percentage!==null&&a.jsxs("div",{className:"text-xs",children:[a.jsx("span",{className:"text-gray-500",children:"CBD:"}),a.jsxs("span",{className:"ml-1 font-medium text-blue-600",children:[A.cbd_percentage,"%"]})]}),A.strain_type&&a.jsxs("div",{className:"text-xs col-span-2",children:[a.jsx("span",{className:"text-gray-500",children:"Type:"}),a.jsx("span",{className:"ml-1 font-medium capitalize",children:A.strain_type})]})]}),A.description&&a.jsx("p",{className:"text-xs text-gray-600 line-clamp-2 pt-2 border-t border-gray-100",children:A.description}),A.last_seen_at&&a.jsxs("p",{className:"text-xs text-gray-400 pt-2 border-t border-gray-100",children:["Updated: ",new Date(A.last_seen_at).toLocaleDateString()]}),a.jsxs("div",{className:"flex gap-2 mt-3 pt-3 border-t border-gray-100",children:[A.dutchie_url&&a.jsx("a",{href:A.dutchie_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1 px-3 py-2 bg-gray-100 text-gray-700 text-sm font-medium rounded-lg hover:bg-gray-200 transition-colors text-center border border-gray-200",children:"Source"}),a.jsx("button",{onClick:()=>t(`/products/${A.id}`),className:"flex-1 px-3 py-2 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 transition-colors",children:"Details"})]})]})]},A.id))}):a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-12 text-center",children:[a.jsx(Ct,{className:"w-16 h-16 text-gray-300 mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"No products found"}),a.jsx("p",{className:"text-gray-500",children:"Try adjusting your filters"})]})]}),v==="brands"&&a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[a.jsxs("h2",{className:"text-lg font-semibold text-gray-900 mb-4",children:["All Brands (",c.length,")"]}),c.length>0?a.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-3",children:c.map(A=>{const R=i.filter(H=>H.brand===A);return a.jsxs("div",{className:"p-4 border border-gray-200 rounded-lg hover:border-blue-500 hover:bg-blue-50 transition-all cursor-pointer",onClick:()=>{b("products"),g(A)},children:[a.jsx("p",{className:"font-medium text-gray-900 text-sm",children:A}),a.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[R.length," products"]})]},A)})}):a.jsxs("div",{className:"text-center py-12",children:[a.jsx(Cr,{className:"w-16 h-16 text-gray-300 mx-auto mb-4"}),a.jsx("p",{className:"text-gray-500",children:"No brands found"})]})]}),v==="specials"&&a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[a.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-4",children:"Daily Specials"}),a.jsxs("div",{className:"text-center py-12",children:[a.jsx(Fx,{className:"w-16 h-16 text-gray-300 mx-auto mb-4"}),a.jsx("p",{className:"text-gray-500",children:"No specials available"})]})]})]})}):a.jsx(X,{children:a.jsxs("div",{className:"text-center py-12",children:[a.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-2",children:"Store not found"}),a.jsx("button",{onClick:()=>t("/stores"),className:"text-blue-600 hover:text-blue-700",children:"← Back to stores"})]})})}function uF(){const{state:e,storeName:t,slug:r}=_a(),n=dt(),[i,s]=h.useState(null),[o,l]=h.useState([]),[c,d]=h.useState(!0);h.useEffect(()=>{u()},[r]);const u=async()=>{d(!0);try{const p=(await B.getStores()).stores.find(x=>x.slug===r);if(!p)throw new Error("Store not found");s(p);const m=await B.getStoreBrands(p.id);l(m.brands)}catch(f){console.error("Failed to load brands:",f)}finally{d(!1)}};return c?a.jsx(X,{children:a.jsx("div",{className:"flex items-center justify-center h-64",children:a.jsx("span",{className:"loading loading-spinner loading-lg"})})}):i?a.jsx(X,{children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("button",{onClick:()=>n(`/stores/${e}/${t}/${r}`),className:"btn btn-ghost btn-sm",children:"← Back to Store"}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("h1",{className:"text-3xl font-bold",children:[i.name," - Brands"]}),a.jsxs("div",{className:"flex gap-3 mt-2",children:[a.jsx("a",{href:`${i.dutchie_url}/brands`,target:"_blank",rel:"noopener noreferrer",className:"link link-primary text-sm",children:"View Live Brands Page"}),a.jsx("span",{className:"text-sm text-gray-500",children:"•"}),a.jsxs("span",{className:"text-sm text-gray-500",children:[o.length," ",o.length===1?"Brand":"Brands"]})]})]})]}),o.length>0?a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:o.map((f,p)=>a.jsx("div",{className:"card bg-base-100 shadow-md hover:shadow-lg transition-shadow",children:a.jsx("div",{className:"card-body p-6",children:a.jsx("h3",{className:"text-lg font-semibold text-center",children:f})})},p))}):a.jsx("div",{className:"card bg-base-100 shadow-xl",children:a.jsxs("div",{className:"card-body text-center py-12",children:[a.jsx("p",{className:"text-gray-500",children:"No brands found for this store"}),a.jsx("p",{className:"text-sm text-gray-400 mt-2",children:"Brands are automatically extracted from products"})]})})]})}):a.jsx(X,{children:a.jsx("div",{className:"text-center py-12",children:a.jsx("p",{className:"text-gray-500",children:"Store not found"})})})}function dF(){const{state:e,storeName:t,slug:r}=_a(),n=dt(),[i,s]=h.useState(null),[o,l]=h.useState([]),[c,d]=h.useState(new Date().toISOString().split("T")[0]),[u,f]=h.useState(!0);h.useEffect(()=>{p()},[r,c]);const p=async()=>{f(!0);try{const x=(await B.getStores()).stores.find(v=>v.slug===r);if(!x)throw new Error("Store not found");s(x);const g=await B.getStoreSpecials(x.id,c);l(g.specials)}catch(m){console.error("Failed to load specials:",m)}finally{f(!1)}};return u?a.jsx(X,{children:a.jsx("div",{className:"flex items-center justify-center h-64",children:a.jsx("span",{className:"loading loading-spinner loading-lg"})})}):i?a.jsx(X,{children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("button",{onClick:()=>n(`/stores/${e}/${t}/${r}`),className:"btn btn-ghost btn-sm",children:"← Back to Store"}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("h1",{className:"text-3xl font-bold",children:[i.name," - Specials"]}),a.jsxs("div",{className:"flex gap-3 mt-2",children:[a.jsx("a",{href:`${i.dutchie_url}/specials`,target:"_blank",rel:"noopener noreferrer",className:"link link-primary text-sm",children:"View Live Specials Page"}),a.jsx("span",{className:"text-sm text-gray-500",children:"•"}),a.jsxs("span",{className:"text-sm text-gray-500",children:[o.length," ",o.length===1?"Special":"Specials"]})]})]})]}),a.jsx("div",{className:"card bg-base-100 shadow-md",children:a.jsx("div",{className:"card-body p-4",children:a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("label",{className:"font-semibold",children:"Select Date:"}),a.jsx("input",{type:"date",value:c,onChange:m=>d(m.target.value),className:"input input-bordered input-sm"})]})})}),o.length>0?a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:o.map((m,x)=>a.jsx("div",{className:"card bg-base-100 shadow-xl hover:shadow-2xl transition-shadow",children:a.jsxs("div",{className:"card-body",children:[a.jsx("h3",{className:"card-title text-lg",children:m.name}),m.description&&a.jsx("p",{className:"text-sm text-gray-600",children:m.description}),a.jsxs("div",{className:"space-y-2 mt-2",children:[m.original_price&&a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsx("span",{className:"text-sm opacity-60",children:"Original Price:"}),a.jsxs("span",{className:"line-through text-gray-500",children:["$",parseFloat(m.original_price).toFixed(2)]})]}),m.special_price&&a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsx("span",{className:"text-sm opacity-60",children:"Special Price:"}),a.jsxs("span",{className:"text-lg font-bold text-success",children:["$",parseFloat(m.special_price).toFixed(2)]})]}),m.discount_percentage&&a.jsxs("div",{className:"badge badge-success badge-lg",children:[m.discount_percentage,"% OFF"]}),m.discount_amount&&a.jsxs("div",{className:"badge badge-info badge-lg",children:["Save $",parseFloat(m.discount_amount).toFixed(2)]})]})]})},x))}):a.jsx("div",{className:"card bg-base-100 shadow-xl",children:a.jsxs("div",{className:"card-body text-center py-12",children:[a.jsxs("p",{className:"text-gray-500",children:["No specials found for ",c]}),a.jsx("p",{className:"text-sm text-gray-400 mt-2",children:"Try selecting a different date"})]})})]})}):a.jsx(X,{children:a.jsx("div",{className:"text-center py-12",children:a.jsx("p",{className:"text-gray-500",children:"Store not found"})})})}function fF(){const[e,t]=h.useState([]),[r,n]=h.useState(null),[i,s]=h.useState([]),[o,l]=h.useState(!0);h.useEffect(()=>{c()},[]),h.useEffect(()=>{r&&d()},[r]);const c=async()=>{try{const f=await B.getStores();t(f.stores),f.stores.length>0&&n(f.stores[0].id)}catch(f){console.error("Failed to load stores:",f)}finally{l(!1)}},d=async()=>{if(r)try{const f=await B.getCategoryTree(r);s(f.tree)}catch(f){console.error("Failed to load categories:",f)}};if(o)return a.jsx(X,{children:a.jsx("div",{children:"Loading..."})});const u=e.find(f=>f.id===r);return a.jsx(X,{children:a.jsxs("div",{children:[a.jsx("h1",{style:{fontSize:"32px",marginBottom:"30px"},children:"Categories"}),a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",marginBottom:"30px"},children:[a.jsx("label",{style:{display:"block",marginBottom:"10px",fontWeight:"600"},children:"Select Store:"}),a.jsx("select",{value:r||"",onChange:f=>n(parseInt(f.target.value)),style:{width:"100%",padding:"12px",border:"2px solid #667eea",borderRadius:"6px",fontSize:"16px",cursor:"pointer"},children:e.map(f=>a.jsxs("option",{value:f.id,children:[f.name," (",f.category_count||0," categories)"]},f.id))})]}),u&&a.jsxs("div",{style:{background:"white",padding:"25px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsxs("h2",{style:{marginBottom:"20px",fontSize:"24px"},children:[u.name," - Categories"]}),i.length===0?a.jsx("div",{style:{color:"#999",textAlign:"center",padding:"40px"},children:'No categories found. Run "Discover Categories" from the Stores page.'}):a.jsx("div",{children:i.map(f=>a.jsx(Ek,{category:f},f.id))})]})]})})}function Ek({category:e,level:t=0}){return a.jsxs("div",{style:{marginLeft:t*30+"px",marginBottom:"10px"},children:[a.jsxs("div",{style:{padding:"12px 15px",background:t===0?"#f0f0ff":"#f8f9fa",borderRadius:"6px",borderLeft:`4px solid ${t===0?"#667eea":"#999"}`,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[a.jsxs("div",{children:[a.jsxs("strong",{style:{fontSize:t===0?"16px":"14px"},children:[t>0&&"└── ",e.name]}),a.jsxs("span",{style:{marginLeft:"10px",color:"#666",fontSize:"12px"},children:["(",e.product_count||0," products)"]})]}),a.jsx("div",{style:{fontSize:"12px",color:"#999"},children:a.jsx("code",{children:e.path})})]}),e.children&&e.children.length>0&&a.jsx("div",{style:{marginTop:"5px"},children:e.children.map(r=>a.jsx(Ek,{category:r,level:t+1},r.id))})]})}function Vn({message:e,type:t,onClose:r,duration:n=4e3}){h.useEffect(()=>{const s=setTimeout(r,n);return()=>clearTimeout(s)},[n,r]);const i={success:"#10b981",error:"#ef4444",info:"#3b82f6"};return a.jsxs("div",{style:{position:"fixed",top:"20px",right:"20px",background:i[t],color:"white",padding:"16px 24px",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",zIndex:9999,maxWidth:"400px",animation:"slideIn 0.3s ease-out",fontSize:"14px",fontWeight:"500"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[a.jsx("div",{style:{flex:1,whiteSpace:"pre-wrap"},children:e}),a.jsx("button",{onClick:r,style:{background:"transparent",border:"none",color:"white",cursor:"pointer",fontSize:"18px",padding:"0 4px",opacity:.8},children:"×"})]}),a.jsx("style",{children:` @keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } } `})]})}function pF(){const[e,t]=h.useState([]),[r,n]=h.useState(!0),[i,s]=h.useState(!1),[o,l]=h.useState(null);h.useEffect(()=>{c()},[]);const c=async()=>{n(!0);try{const u=await B.getCampaigns();t(u.campaigns)}catch(u){console.error("Failed to load campaigns:",u)}finally{n(!1)}},d=async(u,f)=>{if(confirm(`Are you sure you want to delete campaign "${f}"?`))try{await B.deleteCampaign(u),c()}catch(p){l({message:"Failed to delete campaign: "+p.message,type:"error"})}};return r?a.jsx(X,{children:a.jsx("div",{children:"Loading..."})}):a.jsxs(X,{children:[o&&a.jsx(Vn,{message:o.message,type:o.type,onClose:()=>l(null)}),a.jsxs("div",{children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"30px"},children:[a.jsx("h1",{style:{fontSize:"32px",margin:0},children:"Campaigns"}),a.jsx("button",{onClick:()=>s(!0),style:{padding:"12px 24px",background:"#667eea",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"14px",fontWeight:"500"},children:"+ Create Campaign"})]}),i&&a.jsx(hF,{onClose:()=>s(!1),onSuccess:()=>{s(!1),c()}}),a.jsx("div",{style:{display:"grid",gap:"20px"},children:e.map(u=>a.jsx("div",{style:{background:"white",padding:"25px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"start"},children:[a.jsxs("div",{style:{flex:1},children:[a.jsxs("h3",{style:{marginBottom:"10px",fontSize:"20px"},children:[u.name,a.jsx("span",{style:{marginLeft:"10px",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",background:u.active?"#d4edda":"#f8d7da",color:u.active?"#155724":"#721c24"},children:u.active?"Active":"Inactive"})]}),a.jsxs("div",{style:{fontSize:"14px",color:"#666",marginBottom:"5px"},children:[a.jsx("strong",{children:"Slug:"})," ",u.slug]}),u.description&&a.jsxs("div",{style:{fontSize:"14px",color:"#666",marginBottom:"5px"},children:[a.jsx("strong",{children:"Description:"})," ",u.description]}),a.jsxs("div",{style:{fontSize:"14px",color:"#666",marginBottom:"5px"},children:[a.jsx("strong",{children:"Display Style:"})," ",u.display_style]}),a.jsxs("div",{style:{fontSize:"14px",color:"#666"},children:[a.jsx("strong",{children:"Products:"})," ",u.product_count||0]})]}),a.jsx("div",{style:{display:"flex",gap:"10px"},children:a.jsx("button",{onClick:()=>d(u.id,u.name),style:{padding:"8px 16px",background:"#e74c3c",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"14px"},children:"Delete"})})]})},u.id))}),e.length===0&&!i&&a.jsx("div",{style:{background:"white",padding:"40px",borderRadius:"8px",textAlign:"center",color:"#999"},children:"No campaigns found"})]})]})}function hF({onClose:e,onSuccess:t}){const[r,n]=h.useState(""),[i,s]=h.useState(""),[o,l]=h.useState(""),[c,d]=h.useState("grid"),[u,f]=h.useState(!0),[p,m]=h.useState(!1),[x,g]=h.useState(null),v=async b=>{b.preventDefault(),m(!0);try{await B.createCampaign({name:r,slug:i,description:o,display_style:c,active:u}),t()}catch(j){g({message:"Failed to create campaign: "+j.message,type:"error"})}finally{m(!1)}};return a.jsxs("div",{style:{background:"white",padding:"25px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",marginBottom:"20px"},children:[x&&a.jsx(Vn,{message:x.message,type:x.type,onClose:()=>g(null)}),a.jsx("h3",{style:{marginBottom:"20px"},children:"Create New Campaign"}),a.jsxs("form",{onSubmit:v,children:[a.jsxs("div",{style:{display:"grid",gap:"15px"},children:[a.jsxs("div",{children:[a.jsx("label",{style:{display:"block",marginBottom:"5px",fontWeight:"500"},children:"Name *"}),a.jsx("input",{type:"text",value:r,onChange:b=>n(b.target.value),required:!0,style:{width:"100%",padding:"10px",border:"1px solid #ddd",borderRadius:"6px"}})]}),a.jsxs("div",{children:[a.jsx("label",{style:{display:"block",marginBottom:"5px",fontWeight:"500"},children:"Slug *"}),a.jsx("input",{type:"text",value:i,onChange:b=>s(b.target.value),required:!0,placeholder:"e.g., summer-sale",style:{width:"100%",padding:"10px",border:"1px solid #ddd",borderRadius:"6px"}})]}),a.jsxs("div",{children:[a.jsx("label",{style:{display:"block",marginBottom:"5px",fontWeight:"500"},children:"Description"}),a.jsx("textarea",{value:o,onChange:b=>l(b.target.value),rows:3,style:{width:"100%",padding:"10px",border:"1px solid #ddd",borderRadius:"6px"}})]}),a.jsxs("div",{children:[a.jsx("label",{style:{display:"block",marginBottom:"5px",fontWeight:"500"},children:"Display Style"}),a.jsxs("select",{value:c,onChange:b=>d(b.target.value),style:{width:"100%",padding:"10px",border:"1px solid #ddd",borderRadius:"6px"},children:[a.jsx("option",{value:"grid",children:"Grid"}),a.jsx("option",{value:"list",children:"List"}),a.jsx("option",{value:"carousel",children:"Carousel"})]})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[a.jsx("input",{type:"checkbox",id:"active",checked:u,onChange:b=>f(b.target.checked)}),a.jsx("label",{htmlFor:"active",children:"Active"})]})]}),a.jsxs("div",{style:{display:"flex",gap:"10px",marginTop:"20px"},children:[a.jsx("button",{type:"submit",disabled:p,style:{padding:"10px 20px",background:p?"#999":"#667eea",color:"white",border:"none",borderRadius:"6px",cursor:p?"not-allowed":"pointer",fontSize:"14px"},children:p?"Creating...":"Create Campaign"}),a.jsx("button",{type:"button",onClick:e,style:{padding:"10px 20px",background:"#ddd",color:"#333",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"14px"},children:"Cancel"})]})]})]})}function mF(){var l,c,d,u;const[e,t]=h.useState(null),[r,n]=h.useState(!0),[i,s]=h.useState(30);h.useEffect(()=>{o()},[i]);const o=async()=>{n(!0);try{const f=await B.getAnalyticsOverview(i);t(f)}catch(f){console.error("Failed to load analytics:",f)}finally{n(!1)}};return r?a.jsx(X,{children:a.jsx("div",{children:"Loading..."})}):a.jsx(X,{children:a.jsxs("div",{children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"30px"},children:[a.jsx("h1",{style:{fontSize:"32px",margin:0},children:"Analytics"}),a.jsxs("select",{value:i,onChange:f=>s(parseInt(f.target.value)),style:{padding:"10px 15px",border:"1px solid #ddd",borderRadius:"6px",fontSize:"14px"},children:[a.jsx("option",{value:7,children:"Last 7 days"}),a.jsx("option",{value:30,children:"Last 30 days"}),a.jsx("option",{value:90,children:"Last 90 days"}),a.jsx("option",{value:365,children:"Last year"})]})]}),a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(250px, 1fr))",gap:"20px",marginBottom:"30px"},children:[a.jsx(Pv,{title:"Total Clicks",value:((l=e==null?void 0:e.overview)==null?void 0:l.total_clicks)||0,icon:"👆",color:"#3498db"}),a.jsx(Pv,{title:"Unique Products Clicked",value:((c=e==null?void 0:e.overview)==null?void 0:c.unique_products)||0,icon:"📦",color:"#2ecc71"})]}),a.jsxs("div",{style:{background:"white",padding:"25px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",marginBottom:"30px"},children:[a.jsx("h3",{style:{marginBottom:"20px"},children:"Clicks Over Time"}),((d=e==null?void 0:e.clicks_by_day)==null?void 0:d.length)>0?a.jsx("div",{style:{overflowX:"auto"},children:a.jsx("div",{style:{display:"flex",alignItems:"flex-end",gap:"8px",minWidth:"600px",height:"200px"},children:e.clicks_by_day.slice().reverse().map((f,p)=>{const m=Math.max(...e.clicks_by_day.map(g=>g.clicks)),x=f.clicks/m*180;return a.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center"},children:[a.jsx("div",{style:{width:"100%",height:`${x}px`,background:"#667eea",borderRadius:"4px 4px 0 0",position:"relative",minHeight:"2px"},title:`${f.clicks} clicks`,children:a.jsx("div",{style:{position:"absolute",top:"-25px",left:"50%",transform:"translateX(-50%)",fontSize:"12px",fontWeight:"bold"},children:f.clicks})}),a.jsx("div",{style:{fontSize:"10px",marginTop:"5px",color:"#666",transform:"rotate(-45deg)",transformOrigin:"left",whiteSpace:"nowrap"},children:new Date(f.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})})]},p)})})}):a.jsx("div",{style:{color:"#999",textAlign:"center",padding:"40px"},children:"No click data for this period"})]}),a.jsxs("div",{style:{background:"white",padding:"25px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsx("h3",{style:{marginBottom:"20px"},children:"Top Products"}),((u=e==null?void 0:e.top_products)==null?void 0:u.length)>0?a.jsx("div",{children:e.top_products.map((f,p)=>a.jsxs("div",{style:{padding:"15px 0",borderBottom:p{u()},[]);const u=async()=>{n(!0);try{const x=await B.getSettings();t(x.settings)}catch(x){console.error("Failed to load settings:",x)}finally{n(!1)}},f=(x,g)=>{l(v=>({...v,[x]:g}))},p=async()=>{s(!0);try{const x=Object.entries(o).map(([g,v])=>({key:g,value:v}));await B.updateSettings(x),l({}),u(),d({message:"Settings saved successfully!",type:"success"})}catch(x){d({message:"Failed to save settings: "+x.message,type:"error"})}finally{s(!1)}},m=Object.keys(o).length>0;return r?a.jsx(X,{children:a.jsx("div",{children:"Loading..."})}):a.jsxs(X,{children:[c&&a.jsx(Vn,{message:c.message,type:c.type,onClose:()=>d(null)}),a.jsxs("div",{children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"30px"},children:[a.jsx("h1",{style:{fontSize:"32px",margin:0},children:"Settings"}),m&&a.jsx("button",{onClick:p,disabled:i,style:{padding:"12px 24px",background:i?"#999":"#2ecc71",color:"white",border:"none",borderRadius:"6px",cursor:i?"not-allowed":"pointer",fontSize:"14px",fontWeight:"500"},children:i?"Saving...":"Save Changes"})]}),a.jsx("div",{style:{background:"white",padding:"25px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:a.jsx("div",{style:{display:"grid",gap:"25px"},children:e.map(x=>{const g=o[x.key]!==void 0?o[x.key]:x.value;return a.jsxs("div",{children:[a.jsx("label",{style:{display:"block",marginBottom:"8px",fontWeight:"500",fontSize:"16px"},children:xF(x.key)}),x.description&&a.jsx("div",{style:{fontSize:"13px",color:"#666",marginBottom:"8px"},children:x.description}),a.jsx("input",{type:"text",value:g,onChange:v=>f(x.key,v.target.value),style:{width:"100%",maxWidth:"500px",padding:"10px",border:o[x.key]!==void 0?"2px solid #667eea":"1px solid #ddd",borderRadius:"6px",fontSize:"14px"}}),a.jsxs("div",{style:{fontSize:"12px",color:"#999",marginTop:"5px"},children:["Last updated: ",new Date(x.updated_at).toLocaleString()]})]},x.key)})})}),m&&a.jsx("div",{style:{marginTop:"20px",padding:"15px",background:"#fff3cd",border:"1px solid #ffc107",borderRadius:"6px",color:"#856404"},children:'⚠️ You have unsaved changes. Click "Save Changes" to apply them.'})]})]})}function xF(e){return e.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function yF(){const[e,t]=h.useState([]),[r,n]=h.useState(!0),[i,s]=h.useState(!1),[o,l]=h.useState({}),[c,d]=h.useState(null),[u,f]=h.useState(null);h.useEffect(()=>{p(),m()},[]),h.useEffect(()=>{if(!(c!=null&&c.id))return;if(c.status==="completed"||c.status==="cancelled"||c.status==="failed"){p();return}const P=setInterval(async()=>{try{const C=await B.getProxyTestJob(c.id);d(C.job),(C.job.status==="completed"||C.job.status==="cancelled"||C.job.status==="failed")&&(clearInterval(P),p())}catch(C){console.error("Failed to poll job status:",C)}},2e3);return()=>clearInterval(P)},[c==null?void 0:c.id]);const p=async()=>{n(!0);try{const N=await B.getProxies();t(N.proxies)}catch(N){console.error("Failed to load proxies:",N)}finally{n(!1)}},m=async()=>{try{const N=await B.getActiveProxyTestJob();N.job&&d(N.job)}catch{console.log("No active job found")}},x=async N=>{l(P=>({...P,[N]:!0}));try{await B.testProxy(N),p()}catch(P){f({message:"Test failed: "+P.message,type:"error"})}finally{l(P=>({...P,[N]:!1}))}},g=async N=>{l(P=>({...P,[N]:!0})),B.testProxy(N).then(()=>{p(),l(P=>({...P,[N]:!1}))}).catch(()=>{l(P=>({...P,[N]:!1}))})},v=async()=>{try{const N=await B.testAllProxies();f({message:"Proxy testing job started",type:"success"}),d({id:N.jobId,status:"pending",tested_proxies:0,total_proxies:e.length,passed_proxies:0,failed_proxies:0})}catch(N){f({message:"Failed to start testing: "+N.message,type:"error"})}},b=async()=>{if(c!=null&&c.id)try{await B.cancelProxyTestJob(c.id),f({message:"Job cancelled",type:"info"})}catch(N){f({message:"Failed to cancel job: "+N.message,type:"error"})}},j=async()=>{try{await B.updateProxyLocations(),f({message:"Location update job started",type:"success"})}catch(N){f({message:"Failed to start location update: "+N.message,type:"error"})}},y=async N=>{if(confirm("Delete this proxy?"))try{await B.deleteProxy(N),p()}catch(P){f({message:"Failed to delete proxy: "+P.message,type:"error"})}};if(r)return a.jsx(X,{children:a.jsx("div",{className:"flex items-center justify-center h-64",children:a.jsx("div",{className:"w-8 h-8 border-4 border-gray-200 border-t-blue-600 rounded-full animate-spin"})})});const w={total:e.length,passed:e.filter(N=>N.active).length,failed:e.filter(N=>!N.active).length},S=w.total>0?Math.round(w.passed/w.total*100):0;return a.jsxs(X,{children:[u&&a.jsx(Vn,{message:u.message,type:u.type,onClose:()=>f(null)}),a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-blue-50 rounded-lg",children:a.jsx(cl,{className:"w-6 h-6 text-blue-600"})}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-semibold text-gray-900",children:"Proxies"}),a.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:[w.total," total • ",w.passed," active • ",w.failed," inactive"]})]})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:v,disabled:!!c&&c.status!=="completed"&&c.status!=="cancelled"&&c.status!=="failed",className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-50 text-blue-700 rounded-lg hover:bg-blue-100 transition-colors text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:[a.jsx(Xt,{className:"w-4 h-4"}),"Test All"]}),a.jsxs("button",{onClick:j,className:"inline-flex items-center gap-2 px-4 py-2 bg-purple-50 text-purple-700 rounded-lg hover:bg-purple-100 transition-colors text-sm font-medium",children:[a.jsx(yi,{className:"w-4 h-4"}),"Update Locations"]}),a.jsxs("button",{onClick:()=>s(!0),className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors text-sm font-medium",children:[a.jsx(Rl,{className:"w-4 h-4"}),"Add Proxy"]})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("div",{className:"p-2 bg-blue-50 rounded-lg",children:a.jsx(cl,{className:"w-5 h-5 text-blue-600"})}),a.jsx("div",{className:"flex items-center gap-1 text-xs text-gray-500",children:a.jsxs("span",{children:[S,"% pass rate"]})})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium text-gray-600",children:"Total Proxies"}),a.jsx("p",{className:"text-3xl font-semibold text-gray-900",children:w.total})]})]}),a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("div",{className:"p-2 bg-green-50 rounded-lg",children:a.jsx(Pr,{className:"w-5 h-5 text-green-600"})}),a.jsxs("div",{className:"flex items-center gap-1 text-xs text-green-600",children:[a.jsx(zn,{className:"w-3 h-3"}),a.jsxs("span",{children:[Math.round(w.passed/w.total*100)||0,"%"]})]})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium text-gray-600",children:"Active"}),a.jsx("p",{className:"text-3xl font-semibold text-green-600",children:w.passed}),a.jsx("p",{className:"text-xs text-gray-500",children:"Passing health checks"})]})]}),a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("div",{className:"p-2 bg-red-50 rounded-lg",children:a.jsx(Hr,{className:"w-5 h-5 text-red-600"})}),a.jsx("div",{className:"flex items-center gap-1 text-xs text-red-600",children:a.jsxs("span",{children:[Math.round(w.failed/w.total*100)||0,"%"]})})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium text-gray-600",children:"Inactive"}),a.jsx("p",{className:"text-3xl font-semibold text-red-600",children:w.failed}),a.jsx("p",{className:"text-xs text-gray-500",children:"Failed health checks"})]})]}),a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[a.jsx("div",{className:"flex items-center justify-between mb-4",children:a.jsx("div",{className:"p-2 bg-purple-50 rounded-lg",children:a.jsx(zn,{className:"w-5 h-5 text-purple-600"})})}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm font-medium text-gray-600",children:"Success Rate"}),a.jsxs("p",{className:"text-3xl font-semibold text-gray-900",children:[S,"%"]}),a.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2 mt-3",children:a.jsx("div",{className:"bg-green-600 h-2 rounded-full transition-all",style:{width:`${S}%`}})})]})]})]}),c&&a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[a.jsxs("div",{className:"flex justify-between items-center mb-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-blue-50 rounded-lg",children:a.jsx(Xt,{className:`w-5 h-5 text-blue-600 ${c.status==="running"?"animate-spin":""}`})}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-semibold text-gray-900",children:"Proxy Testing Job"}),a.jsx("p",{className:"text-sm text-gray-500",children:c.status.charAt(0).toUpperCase()+c.status.slice(1)})]})]}),a.jsxs("div",{className:"flex gap-2",children:[c.status==="running"&&a.jsx("button",{onClick:b,className:"px-3 py-1.5 bg-red-50 text-red-700 rounded-lg hover:bg-red-100 transition-colors text-sm font-medium",children:"Cancel"}),(c.status==="completed"||c.status==="cancelled"||c.status==="failed")&&a.jsx("button",{onClick:()=>d(null),className:"px-3 py-1.5 text-gray-600 hover:bg-gray-50 rounded-lg transition-colors text-sm font-medium",children:"Dismiss"})]})]}),a.jsxs("div",{className:"mb-4",children:[a.jsxs("div",{className:"text-sm text-gray-600 mb-2",children:["Progress: ",c.tested_proxies||0," / ",c.total_proxies||0," proxies tested"]}),a.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2",children:a.jsx("div",{className:`h-2 rounded-full transition-all ${c.status==="completed"?"bg-green-600":c.status==="cancelled"||c.status==="failed"?"bg-red-600":"bg-blue-600"}`,style:{width:`${(c.tested_proxies||0)/(c.total_proxies||100)*100}%`}})})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-gray-600",children:"Passed:"}),a.jsx("span",{className:"px-2 py-1 text-xs font-medium bg-green-50 text-green-700 rounded",children:c.passed_proxies||0})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-gray-600",children:"Failed:"}),a.jsx("span",{className:"px-2 py-1 text-xs font-medium bg-red-50 text-red-700 rounded",children:c.failed_proxies||0})]})]}),c.error&&a.jsxs("div",{className:"mt-4 p-3 bg-red-50 border border-red-200 rounded-lg flex items-start gap-2",children:[a.jsx(ha,{className:"w-5 h-5 text-red-600 flex-shrink-0 mt-0.5"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-red-900",children:"Error"}),a.jsx("p",{className:"text-sm text-red-700",children:c.error})]})]})]}),i&&a.jsx(vF,{onClose:()=>s(!1),onSuccess:()=>{s(!1),p()}}),a.jsx("div",{className:"space-y-3",children:e.map(N=>a.jsx("div",{className:"bg-white rounded-xl border border-gray-200 p-4 hover:shadow-lg transition-shadow",children:a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsxs("h3",{className:"font-semibold text-gray-900",children:[N.protocol,"://",N.host,":",N.port]}),a.jsx("span",{className:`px-2 py-1 text-xs font-medium rounded ${N.active?"bg-green-50 text-green-700":"bg-red-50 text-red-700"}`,children:N.active?"Active":"Inactive"}),N.is_anonymous&&a.jsx("span",{className:"px-2 py-1 text-xs font-medium bg-blue-50 text-blue-700 rounded",children:"Anonymous"}),(N.city||N.state||N.country)&&a.jsxs("span",{className:"px-2 py-1 text-xs font-medium bg-purple-50 text-purple-700 rounded flex items-center gap-1",children:[a.jsx(yi,{className:"w-3 h-3"}),N.city&&`${N.city}/`,N.state&&`${N.state.substring(0,2).toUpperCase()} `,N.country]})]}),a.jsx("div",{className:"text-sm text-gray-600",children:N.last_tested_at?a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(xr,{className:"w-4 h-4 text-gray-400"}),a.jsxs("span",{children:["Last tested: ",new Date(N.last_tested_at).toLocaleString()]})]}),N.test_result==="success"?a.jsxs("span",{className:"flex items-center gap-1 text-green-600",children:[a.jsx(Pr,{className:"w-4 h-4"}),"Success (",N.response_time_ms,"ms)"]}):a.jsxs("span",{className:"flex items-center gap-1 text-red-600",children:[a.jsx(Hr,{className:"w-4 h-4"}),"Failed"]})]}):"Not tested yet"})]}),a.jsxs("div",{className:"flex gap-2",children:[N.active?a.jsx("button",{onClick:()=>x(N.id),disabled:o[N.id],className:"inline-flex items-center gap-1 px-3 py-1.5 bg-blue-50 text-blue-700 rounded-lg hover:bg-blue-100 transition-colors text-sm font-medium disabled:opacity-50",children:o[N.id]?a.jsx("div",{className:"w-4 h-4 border-2 border-blue-700 border-t-transparent rounded-full animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(Xt,{className:"w-4 h-4"}),"Test"]})}):a.jsx("button",{onClick:()=>g(N.id),disabled:o[N.id],className:"inline-flex items-center gap-1 px-3 py-1.5 bg-yellow-50 text-yellow-700 rounded-lg hover:bg-yellow-100 transition-colors text-sm font-medium disabled:opacity-50",children:o[N.id]?a.jsx("div",{className:"w-4 h-4 border-2 border-yellow-700 border-t-transparent rounded-full animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(Xt,{className:"w-4 h-4"}),"Retest"]})}),a.jsxs("button",{onClick:()=>y(N.id),className:"inline-flex items-center gap-1 px-3 py-1.5 bg-red-50 text-red-700 rounded-lg hover:bg-red-100 transition-colors text-sm font-medium",children:[a.jsx(lj,{className:"w-4 h-4"}),"Delete"]})]})]})},N.id))}),e.length===0&&!i&&a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-12 text-center",children:[a.jsx(cl,{className:"w-16 h-16 text-gray-300 mx-auto mb-4"}),a.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"No proxies configured"}),a.jsx("p",{className:"text-gray-500 mb-6",children:"Add your first proxy to get started with scraping"}),a.jsxs("button",{onClick:()=>s(!0),className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors font-medium",children:[a.jsx(Rl,{className:"w-4 h-4"}),"Add Proxy"]})]})]})]})}function vF({onClose:e,onSuccess:t}){const[r,n]=h.useState("single"),[i,s]=h.useState(""),[o,l]=h.useState(""),[c,d]=h.useState("http"),[u,f]=h.useState(""),[p,m]=h.useState(""),[x,g]=h.useState(""),[v,b]=h.useState(!1),[j,y]=h.useState(null),w=C=>{if(C=C.trim(),!C||C.startsWith("#"))return null;let T;return T=C.match(/^(https?|socks5):\/\/([^:]+):([^@]+)@([^:]+):(\d+)$/),T?{protocol:T[1],username:T[2],password:T[3],host:T[4],port:parseInt(T[5])}:(T=C.match(/^(https?|socks5):\/\/([^:]+):(\d+)$/),T?{protocol:T[1],host:T[2],port:parseInt(T[3])}:(T=C.match(/^([^:]+):(\d+):([^:]+):(.+)$/),T?{protocol:"http",host:T[1],port:parseInt(T[2]),username:T[3],password:T[4]}:(T=C.match(/^([^:]+):(\d+)$/),T?{protocol:"http",host:T[1],port:parseInt(T[2])}:null)))},S=async()=>{const T=x.split(` `).map($=>w($)).filter($=>$!==null);if(T.length===0){y({message:"No valid proxies found. Please check the format.",type:"error"});return}b(!0);try{const $=await B.addProxiesBulk(T),I=`Import complete! Added: ${$.added} Duplicates: ${$.duplicates||0} Failed: ${$.failed} Proxies are inactive by default. Use "Test All Proxies" to verify and activate them.`;y({message:I,type:"success"}),t()}catch($){y({message:"Failed to import proxies: "+$.message,type:"error"})}finally{b(!1)}},N=async C=>{var I;const T=(I=C.target.files)==null?void 0:I[0];if(!T)return;const $=await T.text();g($)},P=async C=>{if(C.preventDefault(),r==="bulk"){await S();return}b(!0);try{await B.addProxy({host:i,port:parseInt(o),protocol:c,username:u||void 0,password:p||void 0}),t()}catch(T){y({message:"Failed to add proxy: "+T.message,type:"error"})}finally{b(!1)}};return a.jsxs("div",{className:"bg-white rounded-xl border border-gray-200",children:[j&&a.jsx(Vn,{message:j.message,type:j.type,onClose:()=>y(null)}),a.jsxs("div",{className:"p-6",children:[a.jsxs("div",{className:"flex justify-between items-center mb-6",children:[a.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:"Add Proxies"}),a.jsxs("div",{className:"flex bg-gray-100 rounded-lg p-1",children:[a.jsx("button",{type:"button",onClick:()=>n("single"),className:`px-4 py-2 rounded-md text-sm font-medium transition-colors ${r==="single"?"bg-white text-gray-900 shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:"Single"}),a.jsx("button",{type:"button",onClick:()=>n("bulk"),className:`px-4 py-2 rounded-md text-sm font-medium transition-colors ${r==="bulk"?"bg-white text-gray-900 shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:"Bulk Import"})]})]}),a.jsxs("form",{onSubmit:P,children:[r==="single"?a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Host *"}),a.jsx("input",{type:"text",value:i,onChange:C=>s(C.target.value),required:!0,placeholder:"proxy.example.com",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Port *"}),a.jsx("input",{type:"number",value:o,onChange:C=>l(C.target.value),required:!0,placeholder:"8080",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Protocol *"}),a.jsxs("select",{value:c,onChange:C=>d(C.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",children:[a.jsx("option",{value:"http",children:"HTTP"}),a.jsx("option",{value:"https",children:"HTTPS"}),a.jsx("option",{value:"socks5",children:"SOCKS5"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Username"}),a.jsx("input",{type:"text",value:u,onChange:C=>f(C.target.value),placeholder:"Optional",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]}),a.jsxs("div",{className:"md:col-span-2",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Password"}),a.jsx("input",{type:"password",value:p,onChange:C=>m(C.target.value),placeholder:"Optional",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]})]}):a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Upload File"}),a.jsxs("label",{className:"flex items-center justify-center w-full px-4 py-6 border-2 border-gray-300 border-dashed rounded-lg cursor-pointer hover:border-blue-500 hover:bg-blue-50 transition-colors",children:[a.jsxs("div",{className:"flex flex-col items-center",children:[a.jsx(G6,{className:"w-8 h-8 text-gray-400 mb-2"}),a.jsx("span",{className:"text-sm text-gray-600",children:"Click to upload or drag and drop"}),a.jsx("span",{className:"text-xs text-gray-500 mt-1",children:".txt or .list files"})]}),a.jsx("input",{type:"file",accept:".txt,.list",onChange:N,className:"hidden"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Or Paste Proxies (one per line)"}),a.jsx("textarea",{value:x,onChange:C=>g(C.target.value),placeholder:`Supported formats: host:port protocol://host:port host:port:username:password protocol://username:password@host:port Example: 192.168.1.1:8080 http://proxy.example.com:3128 10.0.0.1:8080:user:pass socks5://user:pass@proxy.example.com:1080`,rows:12,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 font-mono text-sm"})]}),a.jsxs("div",{className:"p-3 bg-blue-50 border border-blue-200 rounded-lg flex items-start gap-2",children:[a.jsx(ha,{className:"w-5 h-5 text-blue-600 flex-shrink-0 mt-0.5"}),a.jsx("span",{className:"text-sm text-blue-900",children:"Lines starting with # are treated as comments and ignored."})]})]}),a.jsxs("div",{className:"flex justify-end gap-3 mt-6 pt-6 border-t border-gray-200",children:[a.jsx("button",{type:"button",onClick:e,className:"px-4 py-2 text-gray-700 hover:bg-gray-50 rounded-lg transition-colors font-medium",children:"Cancel"}),a.jsx("button",{type:"submit",disabled:v,className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:v?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),a.jsx("span",{children:"Processing..."})]}):a.jsxs(a.Fragment,{children:[a.jsx(Rl,{className:"w-4 h-4"}),r==="bulk"?"Import Proxies":"Add Proxy"]})})]})]})]})]})}function bF(){const[e,t]=h.useState([]),[r,n]=h.useState(!0),[i,s]=h.useState(!0),[o,l]=h.useState(""),[c,d]=h.useState(""),[u,f]=h.useState(200),[p,m]=h.useState(null),x=h.useRef(null);h.useEffect(()=>{g()},[o,c,u]),h.useEffect(()=>{if(!i)return;const S=setInterval(()=>{g()},2e3);return()=>clearInterval(S)},[i,o,c,u]);const g=async()=>{try{const S=await B.getLogs(u,o,c);t(S.logs)}catch(S){console.error("Failed to load logs:",S)}finally{n(!1)}},v=async()=>{if(confirm("Are you sure you want to clear all logs?"))try{await B.clearLogs(),t([]),m({message:"Logs cleared successfully",type:"success"})}catch(S){m({message:"Failed to clear logs: "+S.message,type:"error"})}},b=()=>{var S;(S=x.current)==null||S.scrollIntoView({behavior:"smooth"})},j=S=>{switch(S){case"error":return"#dc3545";case"warn":return"#ffc107";case"info":return"#17a2b8";case"debug":return"#6c757d";default:return"#333"}},y=S=>{switch(S){case"error":return"#f8d7da";case"warn":return"#fff3cd";case"info":return"#d1ecf1";case"debug":return"#e2e3e5";default:return"#f8f9fa"}},w=S=>{switch(S){case"scraper":return"🔍";case"images":return"📸";case"categories":return"📂";case"system":return"⚙️";case"api":return"🌐";default:return"📝"}};return r?a.jsx(X,{children:a.jsx("div",{children:"Loading logs..."})}):a.jsxs(X,{children:[p&&a.jsx(Vn,{message:p.message,type:p.type,onClose:()=>m(null)}),a.jsxs("div",{children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[a.jsx("h1",{style:{fontSize:"32px",margin:0},children:"System Logs"}),a.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center"},children:[a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"5px"},children:[a.jsx("input",{type:"checkbox",checked:i,onChange:S=>s(S.target.checked)}),"Auto-refresh (2s)"]}),a.jsx("button",{onClick:b,style:{padding:"8px 16px",background:"#6c757d",color:"white",border:"none",borderRadius:"6px",cursor:"pointer"},children:"⬇️ Scroll to Bottom"}),a.jsx("button",{onClick:v,style:{padding:"8px 16px",background:"#dc3545",color:"white",border:"none",borderRadius:"6px",cursor:"pointer"},children:"🗑️ Clear Logs"})]})]}),a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",marginBottom:"20px",display:"flex",gap:"15px",flexWrap:"wrap"},children:[a.jsxs("select",{value:o,onChange:S=>l(S.target.value),style:{padding:"10px",border:"1px solid #ddd",borderRadius:"6px"},children:[a.jsx("option",{value:"",children:"All Levels"}),a.jsx("option",{value:"info",children:"Info"}),a.jsx("option",{value:"warn",children:"Warning"}),a.jsx("option",{value:"error",children:"Error"}),a.jsx("option",{value:"debug",children:"Debug"})]}),a.jsxs("select",{value:c,onChange:S=>d(S.target.value),style:{padding:"10px",border:"1px solid #ddd",borderRadius:"6px"},children:[a.jsx("option",{value:"",children:"All Categories"}),a.jsx("option",{value:"scraper",children:"🔍 Scraper"}),a.jsx("option",{value:"images",children:"📸 Images"}),a.jsx("option",{value:"categories",children:"📂 Categories"}),a.jsx("option",{value:"system",children:"⚙️ System"}),a.jsx("option",{value:"api",children:"🌐 API"})]}),a.jsxs("select",{value:u,onChange:S=>f(parseInt(S.target.value)),style:{padding:"10px",border:"1px solid #ddd",borderRadius:"6px"},children:[a.jsx("option",{value:"50",children:"Last 50"}),a.jsx("option",{value:"100",children:"Last 100"}),a.jsx("option",{value:"200",children:"Last 200"}),a.jsx("option",{value:"500",children:"Last 500"}),a.jsx("option",{value:"1000",children:"Last 1000"})]}),a.jsx("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"10px"},children:a.jsxs("span",{style:{fontSize:"14px",color:"#666"},children:["Showing ",e.length," logs"]})})]}),a.jsxs("div",{style:{background:"#1e1e1e",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",maxHeight:"70vh",overflowY:"auto",fontFamily:"monospace",fontSize:"13px"},children:[e.length===0?a.jsx("div",{style:{color:"#999",textAlign:"center",padding:"40px"},children:"No logs to display"}):e.map((S,N)=>a.jsxs("div",{style:{padding:"8px 12px",marginBottom:"4px",borderRadius:"4px",background:y(S.level),borderLeft:`4px solid ${j(S.level)}`,display:"flex",gap:"10px",alignItems:"flex-start"},children:[a.jsx("span",{style:{color:"#666",fontSize:"11px",whiteSpace:"nowrap"},children:new Date(S.timestamp).toLocaleTimeString()}),a.jsx("span",{style:{fontSize:"14px"},children:w(S.category)}),a.jsx("span",{style:{padding:"2px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:"bold",background:j(S.level),color:"white",textTransform:"uppercase"},children:S.level}),a.jsx("span",{style:{padding:"2px 6px",borderRadius:"3px",fontSize:"10px",background:"#e2e3e5",color:"#333"},children:S.category}),a.jsx("span",{style:{flex:1,color:"#333",wordBreak:"break-word"},children:S.message})]},N)),a.jsx("div",{ref:x})]})]})]})}function jF(){const[e,t]=h.useState([]),[r,n]=h.useState([]),[i,s]=h.useState(null),[o,l]=h.useState([]),[c,d]=h.useState([]),[u,f]=h.useState([]),[p,m]=h.useState(!0),[x,g]=h.useState(!0),[v,b]=h.useState("az-live"),[j,y]=h.useState(null),[w,S]=h.useState(""),[N,P]=h.useState(null),[C,T]=h.useState({scheduledJobs:[],crawlJobs:[],inMemoryScrapers:[],totalActive:0}),[$,I]=h.useState({jobLogs:[],crawlJobs:[]}),[A,R]=h.useState([]),H=async _=>{try{if(_==="az-live"){const[D,O,k,z]=await Promise.all([B.getAZMonitorSummary().catch(()=>null),B.getAZMonitorActiveJobs().catch(()=>({scheduledJobs:[],crawlJobs:[],inMemoryScrapers:[],totalActive:0})),B.getAZMonitorRecentJobs(30).catch(()=>({jobLogs:[],crawlJobs:[]})),B.getAZMonitorErrors({limit:10,hours:24}).catch(()=>({errors:[]}))]);P(D),T(O),I(k),R((z==null?void 0:z.errors)||[])}else if(_==="jobs"){const[D,O,k,z]=await Promise.all([B.getJobStats(),B.getActiveJobs(),B.getWorkerStats(),B.getRecentJobs({limit:50})]);s(D),l(O.jobs||[]),d(k.workers||[]),f(z.jobs||[])}else if(_==="scrapers"){const[D,O]=await Promise.all([B.getActiveScrapers(),B.getScraperHistory()]);t(D.scrapers||[]),n(O.history||[])}}catch(D){console.error("Failed to load scraper data:",D)}finally{m(!1)}};h.useEffect(()=>{H(v)},[v]),h.useEffect(()=>{if(x){const _=setInterval(()=>H(v),3e3);return()=>clearInterval(_)}},[x,v]);const M=_=>{const D=Math.floor(_/1e3),O=Math.floor(D/60),k=Math.floor(O/60);return k>0?`${k}h ${O%60}m ${D%60}s`:O>0?`${O}m ${D%60}s`:`${D}s`};return a.jsx(X,{children:a.jsxs("div",{children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"30px"},children:[a.jsx("h1",{style:{fontSize:"32px",margin:0},children:"Scraper Monitor"}),a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:x,onChange:_=>g(_.target.checked),style:{width:"18px",height:"18px",cursor:"pointer"}}),a.jsx("span",{children:"Auto-refresh (3s)"})]})]}),a.jsxs("div",{style:{marginBottom:"30px",display:"flex",gap:"10px",borderBottom:"2px solid #eee"},children:[a.jsxs("button",{onClick:()=>b("az-live"),style:{padding:"12px 24px",background:v==="az-live"?"white":"transparent",border:"none",borderBottom:v==="az-live"?"3px solid #10b981":"3px solid transparent",cursor:"pointer",fontSize:"16px",fontWeight:v==="az-live"?"600":"400",color:v==="az-live"?"#10b981":"#666",marginBottom:"-2px"},children:["AZ Live ",C.totalActive>0&&a.jsx("span",{style:{marginLeft:"8px",padding:"2px 8px",background:"#10b981",color:"white",borderRadius:"10px",fontSize:"12px"},children:C.totalActive})]}),a.jsx("button",{onClick:()=>b("jobs"),style:{padding:"12px 24px",background:v==="jobs"?"white":"transparent",border:"none",borderBottom:v==="jobs"?"3px solid #2563eb":"3px solid transparent",cursor:"pointer",fontSize:"16px",fontWeight:v==="jobs"?"600":"400",color:v==="jobs"?"#2563eb":"#666",marginBottom:"-2px"},children:"Dispensary Jobs"}),a.jsx("button",{onClick:()=>b("scrapers"),style:{padding:"12px 24px",background:v==="scrapers"?"white":"transparent",border:"none",borderBottom:v==="scrapers"?"3px solid #2563eb":"3px solid transparent",cursor:"pointer",fontSize:"16px",fontWeight:v==="scrapers"?"600":"400",color:v==="scrapers"?"#2563eb":"#666",marginBottom:"-2px"},children:"Crawl History"})]}),v==="az-live"&&a.jsxs(a.Fragment,{children:[N&&a.jsx("div",{style:{marginBottom:"30px"},children:a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"15px"},children:[a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsx("div",{style:{fontSize:"14px",color:"#999",marginBottom:"8px"},children:"Running Jobs"}),a.jsx("div",{style:{fontSize:"32px",fontWeight:"600",color:C.totalActive>0?"#10b981":"#666"},children:C.totalActive})]}),a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsx("div",{style:{fontSize:"14px",color:"#999",marginBottom:"8px"},children:"Successful (24h)"}),a.jsx("div",{style:{fontSize:"32px",fontWeight:"600",color:"#10b981"},children:(N.successful_jobs_24h||0)+(N.successful_crawls_24h||0)})]}),a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsx("div",{style:{fontSize:"14px",color:"#999",marginBottom:"8px"},children:"Failed (24h)"}),a.jsx("div",{style:{fontSize:"32px",fontWeight:"600",color:(N.failed_jobs_24h||0)+(N.failed_crawls_24h||0)>0?"#ef4444":"#666"},children:(N.failed_jobs_24h||0)+(N.failed_crawls_24h||0)})]}),a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsx("div",{style:{fontSize:"14px",color:"#999",marginBottom:"8px"},children:"Products (24h)"}),a.jsx("div",{style:{fontSize:"32px",fontWeight:"600",color:"#8b5cf6"},children:N.products_found_24h||0})]}),a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsx("div",{style:{fontSize:"14px",color:"#999",marginBottom:"8px"},children:"Snapshots (24h)"}),a.jsx("div",{style:{fontSize:"32px",fontWeight:"600",color:"#06b6d4"},children:N.snapshots_created_24h||0})]})]})}),a.jsxs("div",{style:{marginBottom:"30px"},children:[a.jsxs("h2",{style:{fontSize:"24px",marginBottom:"20px",display:"flex",alignItems:"center",gap:"10px"},children:["Active Jobs",C.totalActive>0&&a.jsxs("span",{style:{padding:"4px 12px",background:"#d1fae5",color:"#065f46",borderRadius:"12px",fontSize:"14px",fontWeight:"600"},children:[C.totalActive," running"]})]}),C.totalActive===0?a.jsxs("div",{style:{background:"white",padding:"60px 40px",borderRadius:"8px",textAlign:"center",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsx("div",{style:{fontSize:"48px",marginBottom:"20px"},children:"😴"}),a.jsx("div",{style:{fontSize:"18px",color:"#666"},children:"No jobs currently running"})]}):a.jsxs("div",{style:{display:"grid",gap:"15px"},children:[C.scheduledJobs.map(_=>a.jsx("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",borderLeft:"4px solid #10b981"},children:a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"start"},children:[a.jsxs("div",{style:{flex:1},children:[a.jsx("div",{style:{fontSize:"18px",fontWeight:"600",marginBottom:"8px"},children:_.job_name}),a.jsx("div",{style:{fontSize:"14px",color:"#666",marginBottom:"12px"},children:_.job_description||"Scheduled job"}),a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:"12px"},children:[a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"12px",color:"#999",marginBottom:"4px"},children:"Processed"}),a.jsx("div",{style:{fontSize:"16px",fontWeight:"600"},children:_.items_processed||0})]}),a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"12px",color:"#999",marginBottom:"4px"},children:"Succeeded"}),a.jsx("div",{style:{fontSize:"16px",fontWeight:"600",color:"#10b981"},children:_.items_succeeded||0})]}),a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"12px",color:"#999",marginBottom:"4px"},children:"Failed"}),a.jsx("div",{style:{fontSize:"16px",fontWeight:"600",color:_.items_failed>0?"#ef4444":"#666"},children:_.items_failed||0})]}),a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"12px",color:"#999",marginBottom:"4px"},children:"Duration"}),a.jsxs("div",{style:{fontSize:"16px",fontWeight:"600"},children:[Math.floor((_.duration_seconds||0)/60),"m ",Math.floor((_.duration_seconds||0)%60),"s"]})]})]})]}),a.jsx("div",{style:{padding:"6px 12px",borderRadius:"4px",fontSize:"13px",fontWeight:"600",background:"#d1fae5",color:"#065f46"},children:"RUNNING"})]})},`sched-${_.id}`)),C.crawlJobs.length>0&&a.jsxs("div",{style:{background:"white",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",overflow:"hidden",marginTop:"15px"},children:[a.jsx("div",{style:{padding:"15px 20px",borderBottom:"2px solid #eee",background:"#f8f8f8"},children:a.jsxs("h3",{style:{margin:0,fontSize:"16px",fontWeight:"600"},children:["Active Crawler Sessions (",C.crawlJobs.length,")"]})}),a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[a.jsx("thead",{children:a.jsxs("tr",{style:{borderBottom:"1px solid #eee"},children:[a.jsx("th",{style:{padding:"12px 15px",textAlign:"left",fontWeight:"600",fontSize:"13px",color:"#666"},children:"Store"}),a.jsx("th",{style:{padding:"12px 15px",textAlign:"left",fontWeight:"600",fontSize:"13px",color:"#666"},children:"Worker"}),a.jsx("th",{style:{padding:"12px 15px",textAlign:"center",fontWeight:"600",fontSize:"13px",color:"#666"},children:"Page"}),a.jsx("th",{style:{padding:"12px 15px",textAlign:"right",fontWeight:"600",fontSize:"13px",color:"#666"},children:"Products"}),a.jsx("th",{style:{padding:"12px 15px",textAlign:"right",fontWeight:"600",fontSize:"13px",color:"#666"},children:"Snapshots"}),a.jsx("th",{style:{padding:"12px 15px",textAlign:"right",fontWeight:"600",fontSize:"13px",color:"#666"},children:"Duration"}),a.jsx("th",{style:{padding:"12px 15px",textAlign:"center",fontWeight:"600",fontSize:"13px",color:"#666"},children:"Status"})]})}),a.jsx("tbody",{children:C.crawlJobs.map(_=>a.jsxs("tr",{style:{borderBottom:"1px solid #eee"},children:[a.jsxs("td",{style:{padding:"12px 15px"},children:[a.jsx("div",{style:{fontWeight:"600",marginBottom:"2px"},children:_.dispensary_name||"Unknown"}),a.jsxs("div",{style:{fontSize:"12px",color:"#999"},children:[_.city," | ID: ",_.dispensary_id]})]}),a.jsxs("td",{style:{padding:"12px 15px",fontSize:"13px"},children:[a.jsx("div",{style:{fontFamily:"monospace",fontSize:"11px",color:"#666"},children:_.worker_id?_.worker_id.substring(0,8):"-"}),_.worker_hostname&&a.jsx("div",{style:{fontSize:"11px",color:"#999"},children:_.worker_hostname})]}),a.jsx("td",{style:{padding:"12px 15px",textAlign:"center",fontSize:"13px"},children:_.current_page&&_.total_pages?a.jsxs("span",{children:[_.current_page,"/",_.total_pages]}):"-"}),a.jsx("td",{style:{padding:"12px 15px",textAlign:"right",fontWeight:"600",color:"#8b5cf6"},children:_.products_found||0}),a.jsx("td",{style:{padding:"12px 15px",textAlign:"right",fontWeight:"600",color:"#06b6d4"},children:_.snapshots_created||0}),a.jsxs("td",{style:{padding:"12px 15px",textAlign:"right",fontSize:"13px"},children:[Math.floor((_.duration_seconds||0)/60),"m ",Math.floor((_.duration_seconds||0)%60),"s"]}),a.jsx("td",{style:{padding:"12px 15px",textAlign:"center"},children:a.jsx("span",{style:{padding:"4px 10px",borderRadius:"12px",fontSize:"11px",fontWeight:"600",background:_.last_heartbeat_at&&Date.now()-new Date(_.last_heartbeat_at).getTime()>6e4?"#fef3c7":"#dbeafe",color:_.last_heartbeat_at&&Date.now()-new Date(_.last_heartbeat_at).getTime()>6e4?"#92400e":"#1e40af"},children:_.last_heartbeat_at&&Date.now()-new Date(_.last_heartbeat_at).getTime()>6e4?"STALE":"CRAWLING"})})]},`crawl-${_.id}`))})]})]})]})]}),(N==null?void 0:N.nextRuns)&&N.nextRuns.length>0&&a.jsxs("div",{style:{marginBottom:"30px"},children:[a.jsx("h2",{style:{fontSize:"24px",marginBottom:"20px"},children:"Next Scheduled Runs"}),a.jsx("div",{style:{background:"white",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",overflow:"hidden"},children:a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[a.jsx("thead",{children:a.jsxs("tr",{style:{background:"#f8f8f8",borderBottom:"2px solid #eee"},children:[a.jsx("th",{style:{padding:"15px",textAlign:"left",fontWeight:"600"},children:"Job"}),a.jsx("th",{style:{padding:"15px",textAlign:"left",fontWeight:"600"},children:"Next Run"}),a.jsx("th",{style:{padding:"15px",textAlign:"center",fontWeight:"600"},children:"Last Status"})]})}),a.jsx("tbody",{children:N.nextRuns.map(_=>a.jsxs("tr",{style:{borderBottom:"1px solid #eee"},children:[a.jsxs("td",{style:{padding:"15px"},children:[a.jsx("div",{style:{fontWeight:"600"},children:_.job_name}),a.jsx("div",{style:{fontSize:"13px",color:"#666"},children:_.description})]}),a.jsx("td",{style:{padding:"15px"},children:a.jsx("div",{style:{fontWeight:"600",color:"#2563eb"},children:_.next_run_at?new Date(_.next_run_at).toLocaleString():"-"})}),a.jsx("td",{style:{padding:"15px",textAlign:"center"},children:a.jsx("span",{style:{padding:"4px 10px",borderRadius:"12px",fontSize:"12px",fontWeight:"600",background:_.last_status==="success"?"#d1fae5":_.last_status==="error"?"#fee2e2":"#fef3c7",color:_.last_status==="success"?"#065f46":_.last_status==="error"?"#991b1b":"#92400e"},children:_.last_status||"never"})})]},_.id))})]})})]}),A.length>0&&a.jsxs("div",{style:{marginBottom:"30px"},children:[a.jsx("h2",{style:{fontSize:"24px",marginBottom:"20px",color:"#ef4444"},children:"Recent Errors (24h)"}),a.jsx("div",{style:{background:"white",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",overflow:"hidden"},children:A.map((_,D)=>a.jsxs("div",{style:{padding:"15px",borderBottom:Da.jsxs("tr",{style:{borderBottom:"1px solid #eee"},children:[a.jsxs("td",{style:{padding:"15px"},children:[a.jsx("div",{style:{fontWeight:"600"},children:_.job_name}),a.jsxs("div",{style:{fontSize:"12px",color:"#999"},children:["Log #",_.id]})]}),a.jsx("td",{style:{padding:"15px",textAlign:"center"},children:a.jsx("span",{style:{padding:"4px 10px",borderRadius:"12px",fontSize:"12px",fontWeight:"600",background:_.status==="success"?"#d1fae5":_.status==="running"?"#dbeafe":_.status==="error"?"#fee2e2":"#fef3c7",color:_.status==="success"?"#065f46":_.status==="running"?"#1e40af":_.status==="error"?"#991b1b":"#92400e"},children:_.status})}),a.jsxs("td",{style:{padding:"15px",textAlign:"right"},children:[a.jsx("span",{style:{color:"#10b981"},children:_.items_succeeded||0})," / ",a.jsx("span",{children:_.items_processed||0})]}),a.jsx("td",{style:{padding:"15px",textAlign:"right"},children:_.duration_ms?`${Math.floor(_.duration_ms/6e4)}m ${Math.floor(_.duration_ms%6e4/1e3)}s`:"-"}),a.jsx("td",{style:{padding:"15px",color:"#666"},children:_.completed_at?new Date(_.completed_at).toLocaleString():"-"})]},`log-${_.id}`))})]})})]})]}),v==="jobs"&&a.jsxs(a.Fragment,{children:[i&&a.jsxs("div",{style:{marginBottom:"30px"},children:[a.jsx("h2",{style:{fontSize:"24px",marginBottom:"20px"},children:"Job Statistics"}),a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"15px"},children:[a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsx("div",{style:{fontSize:"14px",color:"#999",marginBottom:"8px"},children:"Pending"}),a.jsx("div",{style:{fontSize:"32px",fontWeight:"600",color:"#f59e0b"},children:i.pending||0})]}),a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsx("div",{style:{fontSize:"14px",color:"#999",marginBottom:"8px"},children:"In Progress"}),a.jsx("div",{style:{fontSize:"32px",fontWeight:"600",color:"#3b82f6"},children:i.in_progress||0})]}),a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsx("div",{style:{fontSize:"14px",color:"#999",marginBottom:"8px"},children:"Completed"}),a.jsx("div",{style:{fontSize:"32px",fontWeight:"600",color:"#10b981"},children:i.completed||0})]}),a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsx("div",{style:{fontSize:"14px",color:"#999",marginBottom:"8px"},children:"Failed"}),a.jsx("div",{style:{fontSize:"32px",fontWeight:"600",color:"#ef4444"},children:i.failed||0})]}),a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsx("div",{style:{fontSize:"14px",color:"#999",marginBottom:"8px"},children:"Products Found"}),a.jsx("div",{style:{fontSize:"32px",fontWeight:"600",color:"#8b5cf6"},children:i.total_products_found||0})]}),a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsx("div",{style:{fontSize:"14px",color:"#999",marginBottom:"8px"},children:"Products Saved"}),a.jsx("div",{style:{fontSize:"32px",fontWeight:"600",color:"#06b6d4"},children:i.total_products_saved||0})]})]})]}),c.length>0&&a.jsxs("div",{style:{marginBottom:"30px"},children:[a.jsxs("h2",{style:{fontSize:"24px",marginBottom:"20px"},children:["Active Workers (",c.length,")"]}),a.jsx("div",{style:{display:"grid",gap:"15px"},children:c.map(_=>a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",borderLeft:"4px solid #10b981"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[a.jsxs("div",{style:{fontSize:"18px",fontWeight:"600",marginBottom:"12px"},children:["Worker: ",_.worker_id]}),a.jsx("div",{style:{padding:"6px 12px",borderRadius:"4px",fontSize:"13px",fontWeight:"600",background:"#d1fae5",color:"#065f46"},children:"ACTIVE"})]}),a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:"12px"},children:[a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"12px",color:"#999",marginBottom:"4px"},children:"Active Jobs"}),a.jsx("div",{style:{fontSize:"16px",fontWeight:"600"},children:_.active_jobs})]}),a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"12px",color:"#999",marginBottom:"4px"},children:"Products Found"}),a.jsx("div",{style:{fontSize:"16px",fontWeight:"600",color:"#8b5cf6"},children:_.total_products_found||0})]}),a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"12px",color:"#999",marginBottom:"4px"},children:"Products Saved"}),a.jsx("div",{style:{fontSize:"16px",fontWeight:"600",color:"#10b981"},children:_.total_products_saved||0})]}),a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"12px",color:"#999",marginBottom:"4px"},children:"Running Since"}),a.jsx("div",{style:{fontSize:"14px"},children:new Date(_.earliest_start).toLocaleTimeString()})]})]})]},_.worker_id))})]}),a.jsxs("div",{style:{marginBottom:"30px"},children:[a.jsxs("h2",{style:{fontSize:"24px",marginBottom:"20px"},children:["Active Jobs (",o.length,")"]}),o.length===0?a.jsxs("div",{style:{background:"white",padding:"60px 40px",borderRadius:"8px",textAlign:"center",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsx("div",{style:{fontSize:"48px",marginBottom:"20px"},children:"😴"}),a.jsx("div",{style:{fontSize:"18px",color:"#666"},children:"No jobs currently running"})]}):a.jsx("div",{style:{display:"grid",gap:"15px"},children:o.map(_=>a.jsx("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",borderLeft:"4px solid #3b82f6"},children:a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"start"},children:[a.jsxs("div",{style:{flex:1},children:[a.jsx("div",{style:{fontSize:"18px",fontWeight:"600",marginBottom:"8px"},children:_.dispensary_name||_.brand_name}),a.jsxs("div",{style:{fontSize:"14px",color:"#666",marginBottom:"12px"},children:[_.job_type||"crawl"," | Job #",_.id]}),a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:"12px"},children:[a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"12px",color:"#999",marginBottom:"4px"},children:"Products Found"}),a.jsx("div",{style:{fontSize:"16px",fontWeight:"600",color:"#8b5cf6"},children:_.products_found||0})]}),a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"12px",color:"#999",marginBottom:"4px"},children:"Products Saved"}),a.jsx("div",{style:{fontSize:"16px",fontWeight:"600",color:"#10b981"},children:_.products_saved||0})]}),a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"12px",color:"#999",marginBottom:"4px"},children:"Duration"}),a.jsxs("div",{style:{fontSize:"16px",fontWeight:"600"},children:[Math.floor(_.duration_seconds/60),"m ",Math.floor(_.duration_seconds%60),"s"]})]})]})]}),a.jsx("div",{style:{padding:"6px 12px",borderRadius:"4px",fontSize:"13px",fontWeight:"600",background:"#dbeafe",color:"#1e40af"},children:"IN PROGRESS"})]})},_.id))})]}),a.jsxs("div",{children:[a.jsxs("h2",{style:{fontSize:"24px",marginBottom:"20px"},children:["Recent Jobs (",u.length,")"]}),a.jsx("div",{style:{background:"white",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",overflow:"hidden"},children:a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[a.jsx("thead",{children:a.jsxs("tr",{style:{background:"#f8f8f8",borderBottom:"2px solid #eee"},children:[a.jsx("th",{style:{padding:"15px",textAlign:"left",fontWeight:"600"},children:"Dispensary"}),a.jsx("th",{style:{padding:"15px",textAlign:"left",fontWeight:"600"},children:"Type"}),a.jsx("th",{style:{padding:"15px",textAlign:"center",fontWeight:"600"},children:"Status"}),a.jsx("th",{style:{padding:"15px",textAlign:"right",fontWeight:"600"},children:"Found"}),a.jsx("th",{style:{padding:"15px",textAlign:"right",fontWeight:"600"},children:"Saved"}),a.jsx("th",{style:{padding:"15px",textAlign:"right",fontWeight:"600"},children:"Duration"}),a.jsx("th",{style:{padding:"15px",textAlign:"left",fontWeight:"600"},children:"Completed"})]})}),a.jsx("tbody",{children:u.map(_=>a.jsxs("tr",{style:{borderBottom:"1px solid #eee"},children:[a.jsx("td",{style:{padding:"15px"},children:_.dispensary_name||_.brand_name}),a.jsx("td",{style:{padding:"15px",fontSize:"14px",color:"#666"},children:_.job_type||"-"}),a.jsx("td",{style:{padding:"15px",textAlign:"center"},children:a.jsx("span",{style:{padding:"4px 10px",borderRadius:"12px",fontSize:"12px",fontWeight:"600",background:_.status==="completed"?"#d1fae5":_.status==="in_progress"?"#dbeafe":_.status==="failed"?"#fee2e2":"#fef3c7",color:_.status==="completed"?"#065f46":_.status==="in_progress"?"#1e40af":_.status==="failed"?"#991b1b":"#92400e"},children:_.status})}),a.jsx("td",{style:{padding:"15px",textAlign:"right",fontWeight:"600"},children:_.products_found||0}),a.jsx("td",{style:{padding:"15px",textAlign:"right",fontWeight:"600",color:"#10b981"},children:_.products_saved||0}),a.jsx("td",{style:{padding:"15px",textAlign:"right"},children:_.duration_seconds?`${Math.floor(_.duration_seconds/60)}m ${Math.floor(_.duration_seconds%60)}s`:"-"}),a.jsx("td",{style:{padding:"15px",color:"#666"},children:_.completed_at?new Date(_.completed_at).toLocaleString():"-"})]},_.id))})]})})]})]}),v==="scrapers"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{marginBottom:"30px"},children:[a.jsxs("h2",{style:{fontSize:"24px",marginBottom:"20px"},children:["Active Scrapers (",e.length,")"]}),e.length===0?a.jsxs("div",{style:{background:"white",padding:"60px 40px",borderRadius:"8px",textAlign:"center",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsx("div",{style:{fontSize:"48px",marginBottom:"20px"},children:"🛌"}),a.jsx("div",{style:{fontSize:"18px",color:"#666"},children:"No scrapers currently running"})]}):a.jsx("div",{style:{display:"grid",gap:"15px"},children:e.map(_=>a.jsx("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",borderLeft:`4px solid ${_.status==="running"?_.isStale?"#ff9800":"#2ecc71":_.status==="error"?"#e74c3c":"#95a5a6"}`},children:a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"start"},children:[a.jsxs("div",{style:{flex:1},children:[a.jsxs("div",{style:{fontSize:"18px",fontWeight:"600",marginBottom:"8px"},children:[_.storeName," - ",_.categoryName]}),a.jsxs("div",{style:{fontSize:"14px",color:"#666",marginBottom:"12px"},children:["ID: ",_.id]}),a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:"12px"},children:[a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"12px",color:"#999",marginBottom:"4px"},children:"Requests"}),a.jsxs("div",{style:{fontSize:"16px",fontWeight:"600"},children:[_.stats.requestsSuccess," / ",_.stats.requestsTotal]})]}),a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"12px",color:"#999",marginBottom:"4px"},children:"Items Saved"}),a.jsx("div",{style:{fontSize:"16px",fontWeight:"600",color:"#2ecc71"},children:_.stats.itemsSaved})]}),a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"12px",color:"#999",marginBottom:"4px"},children:"Items Dropped"}),a.jsx("div",{style:{fontSize:"16px",fontWeight:"600",color:"#e74c3c"},children:_.stats.itemsDropped})]}),a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"12px",color:"#999",marginBottom:"4px"},children:"Errors"}),a.jsx("div",{style:{fontSize:"16px",fontWeight:"600",color:_.stats.errorsCount>0?"#ff9800":"#999"},children:_.stats.errorsCount})]}),a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"12px",color:"#999",marginBottom:"4px"},children:"Duration"}),a.jsx("div",{style:{fontSize:"16px",fontWeight:"600"},children:M(_.duration)})]})]}),_.currentActivity&&a.jsxs("div",{style:{marginTop:"12px",padding:"8px 12px",background:"#f8f8f8",borderRadius:"4px",fontSize:"14px",color:"#666"},children:["📍 ",_.currentActivity]}),_.isStale&&a.jsx("div",{style:{marginTop:"12px",padding:"8px 12px",background:"#fff3cd",borderRadius:"4px",fontSize:"14px",color:"#856404"},children:"⚠️ No update in over 1 minute - scraper may be stuck"})]}),a.jsx("div",{style:{padding:"6px 12px",borderRadius:"4px",fontSize:"13px",fontWeight:"600",background:_.status==="running"?"#d4edda":_.status==="error"?"#f8d7da":"#e7e7e7",color:_.status==="running"?"#155724":_.status==="error"?"#721c24":"#666"},children:_.status.toUpperCase()})]})},_.id))})]}),a.jsxs("div",{children:[a.jsxs("h2",{style:{fontSize:"24px",marginBottom:"20px"},children:["Recent Scrapes (",r.length,")"]}),a.jsx("div",{style:{background:"white",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",overflow:"hidden"},children:a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[a.jsx("thead",{children:a.jsxs("tr",{style:{background:"#f8f8f8",borderBottom:"2px solid #eee"},children:[a.jsx("th",{style:{padding:"15px",textAlign:"left",fontWeight:"600"},children:"Dispensary"}),a.jsx("th",{style:{padding:"15px",textAlign:"left",fontWeight:"600"},children:"Status"}),a.jsx("th",{style:{padding:"15px",textAlign:"right",fontWeight:"600"},children:"Found"}),a.jsx("th",{style:{padding:"15px",textAlign:"right",fontWeight:"600"},children:"New"}),a.jsx("th",{style:{padding:"15px",textAlign:"right",fontWeight:"600"},children:"Updated"}),a.jsx("th",{style:{padding:"15px",textAlign:"right",fontWeight:"600"},children:"Products"}),a.jsx("th",{style:{padding:"15px",textAlign:"left",fontWeight:"600"},children:"Last Crawled"})]})}),a.jsx("tbody",{children:r.map((_,D)=>a.jsxs("tr",{style:{borderBottom:"1px solid #eee"},children:[a.jsx("td",{style:{padding:"15px"},children:_.dispensary_name||_.store_name}),a.jsx("td",{style:{padding:"15px"},children:a.jsx("span",{style:{padding:"4px 10px",borderRadius:"12px",fontSize:"12px",fontWeight:"600",background:_.status==="completed"?"#d1fae5":_.status==="failed"?"#fee2e2":"#fef3c7",color:_.status==="completed"?"#065f46":_.status==="failed"?"#991b1b":"#92400e"},children:_.status||"-"})}),a.jsx("td",{style:{padding:"15px",textAlign:"right",fontWeight:"600"},children:_.products_found||"-"}),a.jsx("td",{style:{padding:"15px",textAlign:"right",fontWeight:"600",color:"#059669"},children:_.products_new||0}),a.jsx("td",{style:{padding:"15px",textAlign:"right",fontWeight:"600",color:"#2563eb"},children:_.products_updated||0}),a.jsx("td",{style:{padding:"15px",textAlign:"right",fontWeight:"600"},children:_.product_count}),a.jsx("td",{style:{padding:"15px",color:"#666"},children:_.last_scraped_at?new Date(_.last_scraped_at).toLocaleString():"-"})]},D))})]})})]})]})]})})}function wF(){var Me;const[e,t]=h.useState([]),[r,n]=h.useState([]),[i,s]=h.useState([]),[o,l]=h.useState(!0),[c,d]=h.useState(!0),[u,f]=h.useState("dispensaries"),[p,m]=h.useState(null),[x,g]=h.useState(null),[v,b]=h.useState(null),[j,y]=h.useState(null),[w,S]=h.useState(!1),[N,P]=h.useState("all"),[C,T]=h.useState(""),[$,I]=h.useState("");h.useEffect(()=>{const E=setTimeout(()=>{T($)},300);return()=>clearTimeout(E)},[$]),h.useEffect(()=>{if(A(),c){const E=setInterval(A,5e3);return()=>clearInterval(E)}},[c,N,C]);const A=async()=>{try{const E={};N==="AZ"&&(E.state="AZ"),C.trim()&&(E.search=C.trim());const[Q,Ot,F]=await Promise.all([B.getGlobalSchedule(),B.getDispensarySchedules(Object.keys(E).length>0?E:void 0),B.getDispensaryCrawlJobs(100)]);t(Q.schedules||[]),n(Ot.dispensaries||[]),s(F.jobs||[])}catch(E){console.error("Failed to load schedule data:",E)}finally{l(!1)}},R=async E=>{m(E);try{await B.triggerDispensaryCrawl(E),await A()}catch(Q){console.error("Failed to trigger crawl:",Q)}finally{m(null)}},H=async()=>{if(confirm("This will create crawl jobs for ALL active stores. Continue?"))try{const E=await B.triggerAllCrawls();alert(`Created ${E.jobs_created} crawl jobs`),await A()}catch(E){console.error("Failed to trigger all crawls:",E)}},M=async E=>{try{await B.cancelCrawlJob(E),await A()}catch(Q){console.error("Failed to cancel job:",Q)}},_=async E=>{g(E);try{const Q=await B.resolvePlatformId(E);Q.success?alert(Q.message):alert(`Failed: ${Q.error||Q.message}`),await A()}catch(Q){console.error("Failed to resolve platform ID:",Q),alert(`Error: ${Q.message}`)}finally{g(null)}},D=async E=>{b(E);try{const Q=await B.refreshDetection(E);alert(`Detected: ${Q.menu_type}${Q.platform_dispensary_id?`, Platform ID: ${Q.platform_dispensary_id}`:""}`),await A()}catch(Q){console.error("Failed to refresh detection:",Q),alert(`Error: ${Q.message}`)}finally{b(null)}},O=async(E,Q)=>{y(E);try{await B.toggleDispensarySchedule(E,!Q),await A()}catch(Ot){console.error("Failed to toggle schedule:",Ot),alert(`Error: ${Ot.message}`)}finally{y(null)}},k=async(E,Q)=>{try{await B.updateGlobalSchedule(E,Q),await A()}catch(Ot){console.error("Failed to update global schedule:",Ot)}},z=E=>{if(!E)return"Never";const Q=new Date(E),F=new Date().getTime()-Q.getTime(),te=Math.floor(F/6e4),ne=Math.floor(te/60),q=Math.floor(ne/24);return te<1?"Just now":te<60?`${te}m ago`:ne<24?`${ne}h ago`:`${q}d ago`},W=E=>{const Q=new Date(E),Ot=new Date,F=Q.getTime()-Ot.getTime();if(F<0)return"Overdue";const te=Math.floor(F/6e4),ne=Math.floor(te/60);return te<60?`${te}m`:`${ne}h ${te%60}m`},K=E=>{switch(E){case"completed":case"success":return{bg:"#d1fae5",color:"#065f46"};case"running":return{bg:"#dbeafe",color:"#1e40af"};case"failed":case"error":return{bg:"#fee2e2",color:"#991b1b"};case"cancelled":return{bg:"#f3f4f6",color:"#374151"};case"pending":return{bg:"#fef3c7",color:"#92400e"};case"sandbox_only":return{bg:"#e0e7ff",color:"#3730a3"};case"detection_only":return{bg:"#fce7f3",color:"#9d174d"};default:return{bg:"#f3f4f6",color:"#374151"}}},ee=e.find(E=>E.schedule_type==="global_interval"),re=e.find(E=>E.schedule_type==="daily_special");return a.jsx(X,{children:a.jsxs("div",{children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"30px"},children:[a.jsx("h1",{style:{fontSize:"32px",margin:0},children:"Crawler Schedule"}),a.jsxs("div",{style:{display:"flex",gap:"15px",alignItems:"center"},children:[a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:c,onChange:E=>d(E.target.checked),style:{width:"18px",height:"18px",cursor:"pointer"}}),a.jsx("span",{children:"Auto-refresh (5s)"})]}),a.jsx("button",{onClick:H,style:{padding:"10px 20px",background:"#2563eb",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontWeight:"600"},children:"Crawl All Stores"})]})]}),a.jsxs("div",{style:{marginBottom:"30px",display:"flex",gap:"10px",borderBottom:"2px solid #eee"},children:[a.jsxs("button",{onClick:()=>f("dispensaries"),style:{padding:"12px 24px",background:u==="dispensaries"?"white":"transparent",border:"none",borderBottom:u==="dispensaries"?"3px solid #2563eb":"3px solid transparent",cursor:"pointer",fontSize:"16px",fontWeight:u==="dispensaries"?"600":"400",color:u==="dispensaries"?"#2563eb":"#666",marginBottom:"-2px"},children:["Dispensary Schedules (",r.length,")"]}),a.jsxs("button",{onClick:()=>f("jobs"),style:{padding:"12px 24px",background:u==="jobs"?"white":"transparent",border:"none",borderBottom:u==="jobs"?"3px solid #2563eb":"3px solid transparent",cursor:"pointer",fontSize:"16px",fontWeight:u==="jobs"?"600":"400",color:u==="jobs"?"#2563eb":"#666",marginBottom:"-2px"},children:["Job Queue (",i.filter(E=>E.status==="pending"||E.status==="running").length,")"]}),a.jsx("button",{onClick:()=>f("global"),style:{padding:"12px 24px",background:u==="global"?"white":"transparent",border:"none",borderBottom:u==="global"?"3px solid #2563eb":"3px solid transparent",cursor:"pointer",fontSize:"16px",fontWeight:u==="global"?"600":"400",color:u==="global"?"#2563eb":"#666",marginBottom:"-2px"},children:"Global Settings"})]}),u==="global"&&a.jsxs("div",{style:{display:"grid",gap:"20px"},children:[a.jsxs("div",{style:{background:"white",padding:"24px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"start",marginBottom:"20px"},children:[a.jsxs("div",{children:[a.jsx("h2",{style:{fontSize:"20px",margin:0,marginBottom:"8px"},children:"Interval Crawl Schedule"}),a.jsx("p",{style:{color:"#666",margin:0},children:"Crawl all stores periodically"})]}),a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[a.jsx("span",{style:{color:"#666"},children:"Enabled"}),a.jsx("input",{type:"checkbox",checked:(ee==null?void 0:ee.enabled)??!0,onChange:E=>k("global_interval",{enabled:E.target.checked}),style:{width:"20px",height:"20px",cursor:"pointer"}})]})]}),a.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[a.jsx("span",{children:"Crawl every"}),a.jsxs("select",{value:(ee==null?void 0:ee.interval_hours)??4,onChange:E=>k("global_interval",{interval_hours:parseInt(E.target.value)}),style:{padding:"8px 12px",borderRadius:"6px",border:"1px solid #ddd",fontSize:"16px"},children:[a.jsx("option",{value:1,children:"1 hour"}),a.jsx("option",{value:2,children:"2 hours"}),a.jsx("option",{value:4,children:"4 hours"}),a.jsx("option",{value:6,children:"6 hours"}),a.jsx("option",{value:8,children:"8 hours"}),a.jsx("option",{value:12,children:"12 hours"}),a.jsx("option",{value:24,children:"24 hours"})]})]})})]}),a.jsxs("div",{style:{background:"white",padding:"24px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"start",marginBottom:"20px"},children:[a.jsxs("div",{children:[a.jsx("h2",{style:{fontSize:"20px",margin:0,marginBottom:"8px"},children:"Daily Special Crawl"}),a.jsx("p",{style:{color:"#666",margin:0},children:"Crawl stores at local midnight to capture daily specials"})]}),a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[a.jsx("span",{style:{color:"#666"},children:"Enabled"}),a.jsx("input",{type:"checkbox",checked:(re==null?void 0:re.enabled)??!0,onChange:E=>k("daily_special",{enabled:E.target.checked}),style:{width:"20px",height:"20px",cursor:"pointer"}})]})]}),a.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[a.jsx("span",{children:"Run at"}),a.jsx("input",{type:"time",value:((Me=re==null?void 0:re.run_time)==null?void 0:Me.slice(0,5))??"00:01",onChange:E=>k("daily_special",{run_time:E.target.value}),style:{padding:"8px 12px",borderRadius:"6px",border:"1px solid #ddd",fontSize:"16px"}}),a.jsx("span",{style:{color:"#666"},children:"(store local time)"})]})})]})]}),u==="dispensaries"&&a.jsxs("div",{children:[a.jsxs("div",{style:{marginBottom:"15px",display:"flex",gap:"20px",alignItems:"center",flexWrap:"wrap"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[a.jsx("span",{style:{fontWeight:"500",color:"#374151"},children:"State:"}),a.jsxs("div",{style:{display:"flex",borderRadius:"6px",overflow:"hidden",border:"1px solid #d1d5db"},children:[a.jsx("button",{onClick:()=>P("all"),style:{padding:"6px 14px",background:N==="all"?"#2563eb":"white",color:N==="all"?"white":"#374151",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:"500"},children:"All"}),a.jsx("button",{onClick:()=>P("AZ"),style:{padding:"6px 14px",background:N==="AZ"?"#2563eb":"white",color:N==="AZ"?"white":"#374151",border:"none",borderLeft:"1px solid #d1d5db",cursor:"pointer",fontSize:"14px",fontWeight:"500"},children:"AZ Only"})]})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[a.jsx("span",{style:{fontWeight:"500",color:"#374151"},children:"Search:"}),a.jsx("input",{type:"text",placeholder:"Store name or slug...",value:$,onChange:E=>I(E.target.value),style:{padding:"6px 12px",borderRadius:"6px",border:"1px solid #d1d5db",fontSize:"14px",width:"200px"}}),$&&a.jsx("button",{onClick:()=>{I(""),T("")},style:{padding:"4px 8px",background:"#f3f4f6",border:"1px solid #d1d5db",borderRadius:"4px",cursor:"pointer",fontSize:"12px"},children:"Clear"})]}),a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:w,onChange:E=>S(E.target.checked),style:{width:"16px",height:"16px",cursor:"pointer"}}),a.jsx("span",{children:"CannaIQ only"})]}),a.jsxs("span",{style:{color:"#666",fontSize:"14px",marginLeft:"auto"},children:["Showing ",(w?r.filter(E=>E.menu_type==="dutchie"):r).length," dispensaries"]})]}),a.jsx("div",{style:{background:"white",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",overflow:"auto"},children:a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",minWidth:"1200px"},children:[a.jsx("thead",{children:a.jsxs("tr",{style:{background:"#f8f8f8",borderBottom:"2px solid #eee"},children:[a.jsx("th",{style:{padding:"12px",textAlign:"left",fontWeight:"600"},children:"Dispensary"}),a.jsx("th",{style:{padding:"12px",textAlign:"center",fontWeight:"600"},children:"Menu Type"}),a.jsx("th",{style:{padding:"12px",textAlign:"center",fontWeight:"600"},children:"Platform ID"}),a.jsx("th",{style:{padding:"12px",textAlign:"center",fontWeight:"600"},children:"Status"}),a.jsx("th",{style:{padding:"12px",textAlign:"left",fontWeight:"600"},children:"Last Run"}),a.jsx("th",{style:{padding:"12px",textAlign:"left",fontWeight:"600"},children:"Next Run"}),a.jsx("th",{style:{padding:"12px",textAlign:"left",fontWeight:"600"},children:"Last Result"}),a.jsx("th",{style:{padding:"12px",textAlign:"center",fontWeight:"600",minWidth:"220px"},children:"Actions"})]})}),a.jsx("tbody",{children:(w?r.filter(E=>E.menu_type==="dutchie"):r).map(E=>a.jsxs("tr",{style:{borderBottom:"1px solid #eee"},children:[a.jsxs("td",{style:{padding:"12px"},children:[a.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:E.state&&E.city&&(E.dispensary_slug||E.slug)?a.jsx(zl,{to:`/dispensaries/${E.state}/${E.city.toLowerCase().replace(/\s+/g,"-")}/${E.dispensary_slug||E.slug}`,style:{fontWeight:"600",color:"#2563eb",textDecoration:"none"},children:E.dispensary_name}):a.jsx("span",{style:{fontWeight:"600"},children:E.dispensary_name})}),a.jsx("div",{style:{fontSize:"12px",color:"#666"},children:E.city?`${E.city}, ${E.state}`:E.state})]}),a.jsx("td",{style:{padding:"12px",textAlign:"center"},children:E.menu_type?a.jsx("span",{style:{padding:"4px 10px",borderRadius:"12px",fontSize:"11px",fontWeight:"600",background:E.menu_type==="dutchie"?"#d1fae5":"#e0e7ff",color:E.menu_type==="dutchie"?"#065f46":"#3730a3"},children:E.menu_type}):a.jsx("span",{style:{padding:"4px 10px",borderRadius:"12px",fontSize:"11px",fontWeight:"600",background:"#f3f4f6",color:"#666"},children:"unknown"})}),a.jsx("td",{style:{padding:"12px",textAlign:"center"},children:E.platform_dispensary_id?a.jsx("span",{style:{padding:"4px 8px",borderRadius:"4px",fontSize:"10px",fontFamily:"monospace",background:"#d1fae5",color:"#065f46"},title:E.platform_dispensary_id,children:E.platform_dispensary_id.length>12?`${E.platform_dispensary_id.slice(0,6)}...${E.platform_dispensary_id.slice(-4)}`:E.platform_dispensary_id}):a.jsx("span",{style:{padding:"4px 8px",borderRadius:"4px",fontSize:"10px",background:"#fee2e2",color:"#991b1b"},children:"missing"})}),a.jsx("td",{style:{padding:"12px",textAlign:"center"},children:a.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px"},children:[a.jsx("span",{style:{padding:"4px 10px",borderRadius:"12px",fontSize:"11px",fontWeight:"600",background:E.can_crawl?"#d1fae5":E.is_active!==!1?"#fef3c7":"#fee2e2",color:E.can_crawl?"#065f46":E.is_active!==!1?"#92400e":"#991b1b"},children:E.can_crawl?"Ready":E.is_active!==!1?"Not Ready":"Disabled"}),E.schedule_status_reason&&E.schedule_status_reason!=="ready"&&a.jsx("span",{style:{fontSize:"10px",color:"#666",maxWidth:"100px",textAlign:"center"},children:E.schedule_status_reason}),E.interval_minutes&&a.jsxs("span",{style:{fontSize:"10px",color:"#999"},children:["Every ",Math.round(E.interval_minutes/60),"h"]})]})}),a.jsxs("td",{style:{padding:"15px"},children:[a.jsx("div",{children:z(E.last_run_at)}),E.last_run_at&&a.jsx("div",{style:{fontSize:"12px",color:"#999"},children:new Date(E.last_run_at).toLocaleString()})]}),a.jsx("td",{style:{padding:"15px"},children:a.jsx("div",{style:{fontWeight:"600",color:"#2563eb"},children:E.next_run_at?W(E.next_run_at):"Not scheduled"})}),a.jsx("td",{style:{padding:"15px"},children:E.last_status||E.latest_job_status?a.jsxs("div",{children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[a.jsx("span",{style:{padding:"4px 10px",borderRadius:"12px",fontSize:"12px",fontWeight:"600",...K(E.last_status||E.latest_job_status||"pending")},children:E.last_status||E.latest_job_status}),E.last_error&&a.jsx("button",{onClick:()=>alert(E.last_error),style:{padding:"2px 6px",background:"#fee2e2",color:"#991b1b",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"10px"},children:"Error"})]}),E.last_summary?a.jsx("div",{style:{fontSize:"12px",color:"#666",maxWidth:"250px"},children:E.last_summary}):E.latest_products_found!==null?a.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:[E.latest_products_found," products"]}):null]}):a.jsx("span",{style:{color:"#999",fontSize:"13px"},children:"No runs yet"})}),a.jsx("td",{style:{padding:"12px",textAlign:"center"},children:a.jsxs("div",{style:{display:"flex",gap:"6px",justifyContent:"center",flexWrap:"wrap"},children:[a.jsx("button",{onClick:()=>D(E.dispensary_id),disabled:v===E.dispensary_id,style:{padding:"4px 8px",background:v===E.dispensary_id?"#94a3b8":"#f3f4f6",color:"#374151",border:"1px solid #d1d5db",borderRadius:"4px",cursor:v===E.dispensary_id?"wait":"pointer",fontSize:"11px"},title:"Re-detect menu type and resolve platform ID",children:v===E.dispensary_id?"...":"Refresh"}),E.menu_type==="dutchie"&&!E.platform_dispensary_id&&a.jsx("button",{onClick:()=>_(E.dispensary_id),disabled:x===E.dispensary_id,style:{padding:"4px 8px",background:x===E.dispensary_id?"#94a3b8":"#fef3c7",color:"#92400e",border:"1px solid #fcd34d",borderRadius:"4px",cursor:x===E.dispensary_id?"wait":"pointer",fontSize:"11px"},title:"Resolve platform dispensary ID via GraphQL",children:x===E.dispensary_id?"...":"Resolve ID"}),a.jsx("button",{onClick:()=>R(E.dispensary_id),disabled:p===E.dispensary_id||!E.can_crawl,style:{padding:"4px 8px",background:p===E.dispensary_id?"#94a3b8":E.can_crawl?"#2563eb":"#e5e7eb",color:E.can_crawl?"white":"#9ca3af",border:"none",borderRadius:"4px",cursor:p===E.dispensary_id||!E.can_crawl?"not-allowed":"pointer",fontSize:"11px"},title:E.can_crawl?"Trigger immediate crawl":`Cannot crawl: ${E.schedule_status_reason}`,children:p===E.dispensary_id?"...":"Run"}),a.jsx("button",{onClick:()=>O(E.dispensary_id,E.is_active),disabled:j===E.dispensary_id,style:{padding:"4px 8px",background:j===E.dispensary_id?"#94a3b8":E.is_active?"#fee2e2":"#d1fae5",color:E.is_active?"#991b1b":"#065f46",border:"none",borderRadius:"4px",cursor:j===E.dispensary_id?"wait":"pointer",fontSize:"11px"},title:E.is_active?"Disable scheduled crawling":"Enable scheduled crawling",children:j===E.dispensary_id?"...":E.is_active?"Disable":"Enable"})]})})]},E.dispensary_id))})]})})]}),u==="jobs"&&a.jsxs(a.Fragment,{children:[a.jsx("div",{style:{marginBottom:"30px"},children:a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:"15px"},children:[a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsx("div",{style:{fontSize:"14px",color:"#999",marginBottom:"8px"},children:"Pending"}),a.jsx("div",{style:{fontSize:"32px",fontWeight:"600",color:"#f59e0b"},children:i.filter(E=>E.status==="pending").length})]}),a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsx("div",{style:{fontSize:"14px",color:"#999",marginBottom:"8px"},children:"Running"}),a.jsx("div",{style:{fontSize:"32px",fontWeight:"600",color:"#3b82f6"},children:i.filter(E=>E.status==="running").length})]}),a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsx("div",{style:{fontSize:"14px",color:"#999",marginBottom:"8px"},children:"Completed"}),a.jsx("div",{style:{fontSize:"32px",fontWeight:"600",color:"#10b981"},children:i.filter(E=>E.status==="completed").length})]}),a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[a.jsx("div",{style:{fontSize:"14px",color:"#999",marginBottom:"8px"},children:"Failed"}),a.jsx("div",{style:{fontSize:"32px",fontWeight:"600",color:"#ef4444"},children:i.filter(E=>E.status==="failed").length})]})]})}),a.jsx("div",{style:{background:"white",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",overflow:"hidden"},children:a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[a.jsx("thead",{children:a.jsxs("tr",{style:{background:"#f8f8f8",borderBottom:"2px solid #eee"},children:[a.jsx("th",{style:{padding:"15px",textAlign:"left",fontWeight:"600"},children:"Dispensary"}),a.jsx("th",{style:{padding:"15px",textAlign:"center",fontWeight:"600"},children:"Type"}),a.jsx("th",{style:{padding:"15px",textAlign:"center",fontWeight:"600"},children:"Trigger"}),a.jsx("th",{style:{padding:"15px",textAlign:"center",fontWeight:"600"},children:"Status"}),a.jsx("th",{style:{padding:"15px",textAlign:"right",fontWeight:"600"},children:"Products"}),a.jsx("th",{style:{padding:"15px",textAlign:"left",fontWeight:"600"},children:"Started"}),a.jsx("th",{style:{padding:"15px",textAlign:"left",fontWeight:"600"},children:"Completed"}),a.jsx("th",{style:{padding:"15px",textAlign:"center",fontWeight:"600"},children:"Actions"})]})}),a.jsx("tbody",{children:i.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:8,style:{padding:"40px",textAlign:"center",color:"#666"},children:"No crawl jobs found"})}):i.map(E=>a.jsxs("tr",{style:{borderBottom:"1px solid #eee"},children:[a.jsxs("td",{style:{padding:"15px"},children:[a.jsx("div",{style:{fontWeight:"600"},children:E.dispensary_name}),a.jsxs("div",{style:{fontSize:"12px",color:"#999"},children:["Job #",E.id]})]}),a.jsx("td",{style:{padding:"15px",textAlign:"center",fontSize:"13px"},children:E.job_type}),a.jsx("td",{style:{padding:"15px",textAlign:"center"},children:a.jsx("span",{style:{padding:"3px 8px",borderRadius:"4px",fontSize:"12px",background:E.trigger_type==="manual"?"#e0e7ff":E.trigger_type==="daily_special"?"#fce7f3":"#f3f4f6",color:E.trigger_type==="manual"?"#3730a3":E.trigger_type==="daily_special"?"#9d174d":"#374151"},children:E.trigger_type})}),a.jsx("td",{style:{padding:"15px",textAlign:"center"},children:a.jsx("span",{style:{padding:"4px 10px",borderRadius:"12px",fontSize:"12px",fontWeight:"600",...K(E.status)},children:E.status})}),a.jsx("td",{style:{padding:"15px",textAlign:"right"},children:E.products_found!==null?a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:"600"},children:E.products_found}),E.products_new!==null&&E.products_updated!==null&&a.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:["+",E.products_new," / ~",E.products_updated]})]}):"-"}),a.jsx("td",{style:{padding:"15px",fontSize:"13px"},children:E.started_at?new Date(E.started_at).toLocaleString():"-"}),a.jsx("td",{style:{padding:"15px",fontSize:"13px"},children:E.completed_at?new Date(E.completed_at).toLocaleString():"-"}),a.jsxs("td",{style:{padding:"15px",textAlign:"center"},children:[E.status==="pending"&&a.jsx("button",{onClick:()=>M(E.id),style:{padding:"4px 10px",background:"#fee2e2",color:"#991b1b",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"12px"},children:"Cancel"}),E.error_message&&a.jsx("button",{onClick:()=>alert(E.error_message),style:{padding:"4px 10px",background:"#fee2e2",color:"#991b1b",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"12px"},children:"View Error"})]})]},E.id))})]})})]})]})})}function SF(){const[e,t]=h.useState([]),[r,n]=h.useState(null),[i,s]=h.useState(3),[o,l]=h.useState("rotate-desktop"),[c,d]=h.useState(!1),[u,f]=h.useState(!1),[p,m]=h.useState(null),[x,g]=h.useState(!0),[v,b]=h.useState(null),[j,y]=h.useState(!1),[w,S]=h.useState(null),[N,P]=h.useState(!1);h.useEffect(()=>{A(),C()},[]);const C=h.useCallback(async()=>{y(!0);try{const _=await fetch("/api/stale-processes/status");if(_.ok){const D=await _.json();b(D)}}catch(_){console.error("Failed to load stale processes:",_)}finally{y(!1)}},[]),T=async _=>{S(_);try{const O=await(await fetch(`/api/stale-processes/kill/${_}`,{method:"POST"})).json();O.success?(m({message:`Process ${_} killed`,type:"success"}),C()):m({message:O.error||"Failed to kill process",type:"error"})}catch(D){m({message:"Failed to kill process: "+D.message,type:"error"})}finally{S(null)}},$=async _=>{try{const O=await(await fetch("/api/stale-processes/kill-pattern",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pattern:_})})).json();O.success?(m({message:`Killed ${O.killed.length} processes matching "${_}"`,type:"success"}),C()):m({message:O.error||"Failed to kill processes",type:"error"})}catch(D){m({message:"Failed to kill processes: "+D.message,type:"error"})}},I=async(_=!1)=>{P(!0);try{const O=await(await fetch("/api/stale-processes/clean-all",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dryRun:_})})).json();if(O.success){const k=_?`Would kill ${O.totalKilled} processes`:`Killed ${O.totalKilled} processes`;m({message:k,type:"success"}),_||C()}else m({message:O.error||"Failed to clean processes",type:"error"})}catch(D){m({message:"Failed to clean processes: "+D.message,type:"error"})}finally{P(!1)}},A=async()=>{g(!0);try{const D=(await B.getDispensaries()).dispensaries.filter(O=>O.menu_url&&O.scrape_enabled);t(D),D.length>0&&n(D[0].id)}catch(_){console.error("Failed to load dispensaries:",_)}finally{g(!1)}},R=async()=>{if(!(!r||c)){d(!0);try{await B.triggerDispensaryCrawl(r),m({message:"Crawl started for dispensary! Check the Scraper Monitor for progress.",type:"success"})}catch(_){m({message:"Failed to start crawl: "+_.message,type:"error"})}finally{d(!1)}}},H=async()=>{if(!(!r||u)){f(!0);try{m({message:"Image download feature coming soon!",type:"info"})}catch(_){m({message:"Failed to start image download: "+_.message,type:"error"})}finally{f(!1)}}},M=e.find(_=>_.id===r);return x?a.jsx(X,{children:a.jsx("div",{className:"flex items-center justify-center h-64",children:a.jsx("span",{className:"loading loading-spinner loading-lg"})})}):a.jsxs(X,{children:[p&&a.jsx(Vn,{message:p.message,type:p.type,onClose:()=>m(null)}),a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-3xl font-bold",children:"Scraper Tools"}),a.jsx("p",{className:"text-gray-500 mt-2",children:"Manage crawling operations for dispensaries"})]}),a.jsx("div",{className:"card bg-base-100 shadow-xl",children:a.jsxs("div",{className:"card-body",children:[a.jsx("h2",{className:"card-title",children:"Select Dispensary"}),a.jsx("select",{className:"select select-bordered w-full max-w-md",value:r||"",onChange:_=>n(parseInt(_.target.value)),children:e.map(_=>a.jsxs("option",{value:_.id,children:[_.dba_name||_.name," - ",_.city,", ",_.state]},_.id))}),M&&a.jsx("div",{className:"mt-4 p-4 bg-base-200 rounded-lg",children:a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-gray-500",children:"Status"}),a.jsx("div",{className:"font-semibold",children:M.scrape_enabled?a.jsx("span",{className:"badge badge-success",children:"Enabled"}):a.jsx("span",{className:"badge badge-error",children:"Disabled"})})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-gray-500",children:"Provider"}),a.jsx("div",{className:"font-semibold",children:M.provider_type||"Unknown"})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-gray-500",children:"Products"}),a.jsx("div",{className:"font-semibold",children:M.product_count||0})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-gray-500",children:"Last Crawled"}),a.jsx("div",{className:"font-semibold",children:M.last_crawl_at?new Date(M.last_crawl_at).toLocaleDateString():"Never"})]})]})})]})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[a.jsx("div",{className:"card bg-base-100 shadow-xl",children:a.jsxs("div",{className:"card-body",children:[a.jsx("h2",{className:"card-title",children:"Crawl Dispensary"}),a.jsx("p",{className:"text-sm text-gray-500",children:"Start crawling products from the selected dispensary menu"}),a.jsx("div",{className:"card-actions justify-end mt-4",children:a.jsx("button",{onClick:R,disabled:!r||c,className:`btn btn-primary ${c?"loading":""}`,children:c?"Starting...":"Start Crawl"})})]})}),a.jsx("div",{className:"card bg-base-100 shadow-xl",children:a.jsxs("div",{className:"card-body",children:[a.jsx("h2",{className:"card-title",children:"Download Images"}),a.jsx("p",{className:"text-sm text-gray-500",children:"Download missing product images for the selected dispensary"}),a.jsx("div",{className:"card-actions justify-end mt-auto",children:a.jsx("button",{onClick:H,disabled:!r||u,className:`btn btn-secondary ${u?"loading":""}`,children:u?"Downloading...":"Download Missing Images"})})]})})]}),a.jsx("div",{className:"card bg-base-100 shadow-xl",children:a.jsxs("div",{className:"card-body",children:[a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsx("h2",{className:"card-title",children:"Stale Process Monitor"}),a.jsx("div",{className:"flex gap-2",children:a.jsx("button",{onClick:()=>C(),disabled:j,className:"btn btn-sm btn-ghost",children:j?a.jsx("span",{className:"loading loading-spinner loading-xs"}):a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})})]}),a.jsx("p",{className:"text-sm text-gray-500",children:"Monitor and clean up stale background processes from Claude Code sessions"}),j&&!v?a.jsx("div",{className:"flex items-center justify-center h-32",children:a.jsx("span",{className:"loading loading-spinner loading-lg"})}):v?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"stats shadow mt-4",children:a.jsxs("div",{className:"stat",children:[a.jsx("div",{className:"stat-title",children:"Total Processes"}),a.jsx("div",{className:`stat-value ${v.total>0?"text-warning":"text-success"}`,children:v.total}),a.jsxs("div",{className:"stat-desc",children:[v.patterns.length," patterns monitored"]})]})}),Object.entries(v.summary).length>0&&a.jsxs("div",{className:"mt-4",children:[a.jsx("h3",{className:"font-semibold text-sm mb-2",children:"Processes by Pattern"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(v.summary).map(([_,D])=>a.jsxs("div",{className:"badge badge-lg badge-warning gap-2",children:[a.jsx("span",{children:_}),a.jsx("span",{className:"badge badge-sm",children:D}),a.jsx("button",{onClick:()=>$(_),className:"btn btn-xs btn-ghost btn-circle",title:`Kill all "${_}" processes`,children:a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},_))})]}),v.processes.length>0&&a.jsx("div",{className:"mt-4 overflow-x-auto",children:a.jsxs("table",{className:"table table-xs",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"PID"}),a.jsx("th",{children:"User"}),a.jsx("th",{children:"CPU"}),a.jsx("th",{children:"Mem"}),a.jsx("th",{children:"Elapsed"}),a.jsx("th",{children:"Command"}),a.jsx("th",{})]})}),a.jsx("tbody",{children:v.processes.map(_=>a.jsxs("tr",{className:"hover",children:[a.jsx("td",{className:"font-mono",children:_.pid}),a.jsx("td",{children:_.user}),a.jsxs("td",{children:[_.cpu,"%"]}),a.jsxs("td",{children:[_.mem,"%"]}),a.jsx("td",{className:"font-mono",children:_.elapsed}),a.jsx("td",{className:"max-w-xs truncate",title:_.command,children:_.command}),a.jsx("td",{children:a.jsx("button",{onClick:()=>T(_.pid),disabled:w===_.pid,className:"btn btn-xs btn-error",children:w===_.pid?a.jsx("span",{className:"loading loading-spinner loading-xs"}):"Kill"})})]},_.pid))})]})}),a.jsxs("div",{className:"card-actions justify-end mt-4",children:[a.jsx("button",{onClick:()=>I(!0),disabled:N||v.total===0,className:"btn btn-sm btn-outline",children:"Dry Run"}),a.jsx("button",{onClick:()=>I(!1),disabled:N||v.total===0,className:`btn btn-sm btn-error ${N?"loading":""}`,children:N?"Cleaning...":"Clean All"})]})]}):a.jsx("div",{className:"alert alert-error mt-4",children:a.jsx("span",{children:"Failed to load stale processes"})})]})}),a.jsxs("div",{className:"alert alert-info",children:[a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",className:"stroke-current shrink-0 w-6 h-6",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),a.jsxs("span",{children:["After starting scraper operations, check the"," ",a.jsx("a",{href:"/scraper-monitor",className:"link",children:"Scraper Monitor"})," for real-time progress and ",a.jsx("a",{href:"/logs",className:"link",children:"Logs"})," for detailed output."]})]})]})]})}function NF(){const[e,t]=h.useState([]),[r,n]=h.useState(null),[i,s]=h.useState(!0),[o,l]=h.useState("pending"),[c,d]=h.useState(null);h.useEffect(()=>{u()},[o]);const u=async()=>{s(!0);try{const[g,v]=await Promise.all([B.getChanges(o==="all"?void 0:o),B.getChangeStats()]);t(g.changes),n(v)}catch(g){console.error("Failed to load changes:",g)}finally{s(!1)}},f=async g=>{d(g);try{(await B.approveChange(g)).requires_recrawl&&alert("Change approved! This dispensary requires a menu recrawl."),await u()}catch(v){console.error("Failed to approve change:",v),alert("Failed to approve change. Please try again.")}finally{d(null)}},p=async g=>{const v=prompt("Enter rejection reason (optional):");d(g);try{await B.rejectChange(g,v||void 0),await u()}catch(b){console.error("Failed to reject change:",b),alert("Failed to reject change. Please try again.")}finally{d(null)}},m=g=>({dba_name:"DBA Name",website:"Website",phone:"Phone",email:"Email",google_rating:"Google Rating",google_review_count:"Google Review Count",menu_url:"Menu URL"})[g]||g,x=g=>({high:"bg-green-100 text-green-800",medium:"bg-yellow-100 text-yellow-800",low:"bg-red-100 text-red-800"})[g]||"bg-gray-100 text-gray-800";return i?a.jsx(X,{children:a.jsxs("div",{className:"text-center py-12",children:[a.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-blue-500 border-t-transparent"}),a.jsx("p",{className:"mt-2 text-sm text-gray-600",children:"Loading changes..."})]})}):a.jsx(X,{children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Change Approval"}),a.jsx("p",{className:"text-sm text-gray-600 mt-1",children:"Review and approve proposed changes to dispensary data"})]}),a.jsxs("button",{onClick:u,className:"flex items-center gap-2 px-4 py-2 text-sm border border-gray-300 rounded-lg hover:bg-gray-50",children:[a.jsx(Xt,{className:"w-4 h-4"}),"Refresh"]})]}),r&&a.jsxs("div",{className:"grid grid-cols-4 gap-6",children:[a.jsx("div",{className:"bg-white rounded-lg border border-gray-200 p-6",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-yellow-50 rounded-lg",children:a.jsx(xr,{className:"w-5 h-5 text-yellow-600"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-gray-600",children:"Pending"}),a.jsx("p",{className:"text-2xl font-bold text-gray-900",children:r.pending_count})]})]})}),a.jsx("div",{className:"bg-white rounded-lg border border-gray-200 p-6",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-orange-50 rounded-lg",children:a.jsx(cj,{className:"w-5 h-5 text-orange-600"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-gray-600",children:"Needs Recrawl"}),a.jsx("p",{className:"text-2xl font-bold text-gray-900",children:r.pending_recrawl_count})]})]})}),a.jsx("div",{className:"bg-white rounded-lg border border-gray-200 p-6",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-green-50 rounded-lg",children:a.jsx(Pr,{className:"w-5 h-5 text-green-600"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-gray-600",children:"Approved"}),a.jsx("p",{className:"text-2xl font-bold text-gray-900",children:r.approved_count})]})]})}),a.jsx("div",{className:"bg-white rounded-lg border border-gray-200 p-6",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-red-50 rounded-lg",children:a.jsx(Hr,{className:"w-5 h-5 text-red-600"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-gray-600",children:"Rejected"}),a.jsx("p",{className:"text-2xl font-bold text-gray-900",children:r.rejected_count})]})]})})]}),a.jsx("div",{className:"flex gap-2",children:["all","pending","approved","rejected"].map(g=>a.jsx("button",{onClick:()=>l(g),className:`px-4 py-2 text-sm font-medium rounded-lg ${o===g?"bg-blue-600 text-white":"bg-white text-gray-700 border border-gray-300 hover:bg-gray-50"}`,children:g.charAt(0).toUpperCase()+g.slice(1)},g))}),a.jsx("div",{className:"bg-white rounded-lg border border-gray-200",children:e.length===0?a.jsx("div",{className:"text-center py-12",children:a.jsx("p",{className:"text-gray-600",children:"No changes found"})}):a.jsx("div",{className:"divide-y divide-gray-200",children:e.map(g=>a.jsx("div",{className:"p-6",children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:g.dispensary_name}),a.jsx("span",{className:`px-2 py-1 text-xs font-medium rounded ${x(g.confidence_score)}`,children:g.confidence_score||"N/A"}),g.requires_recrawl&&a.jsx("span",{className:"px-2 py-1 text-xs font-medium rounded bg-orange-100 text-orange-800",children:"Requires Recrawl"})]}),a.jsxs("p",{className:"text-sm text-gray-600 mb-3",children:[g.city,", ",g.state," • Source: ",g.source]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4 mb-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-xs font-medium text-gray-500",children:"Field"}),a.jsx("p",{className:"text-sm text-gray-900",children:m(g.field_name)})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs font-medium text-gray-500",children:"Old Value"}),a.jsx("p",{className:"text-sm text-gray-900",children:g.old_value||a.jsx("em",{className:"text-gray-400",children:"None"})})]}),a.jsxs("div",{className:"col-span-2",children:[a.jsx("label",{className:"text-xs font-medium text-gray-500",children:"New Value"}),a.jsx("p",{className:"text-sm font-medium text-blue-600",children:g.new_value})]}),g.change_notes&&a.jsxs("div",{className:"col-span-2",children:[a.jsx("label",{className:"text-xs font-medium text-gray-500",children:"Notes"}),a.jsx("p",{className:"text-sm text-gray-700",children:g.change_notes})]})]}),a.jsxs("p",{className:"text-xs text-gray-500",children:["Created ",new Date(g.created_at).toLocaleString()]}),g.status==="rejected"&&g.rejection_reason&&a.jsxs("div",{className:"mt-2 p-3 bg-red-50 rounded border border-red-200",children:[a.jsx("p",{className:"text-xs font-medium text-red-800",children:"Rejection Reason:"}),a.jsx("p",{className:"text-sm text-red-700",children:g.rejection_reason})]})]}),a.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[g.status==="pending"&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{onClick:()=>f(g.id),disabled:c===g.id,className:"flex items-center gap-2 px-4 py-2 bg-green-600 text-white text-sm font-medium rounded-lg hover:bg-green-700 disabled:opacity-50",children:[a.jsx(Pr,{className:"w-4 h-4"}),"Approve"]}),a.jsxs("button",{onClick:()=>p(g.id),disabled:c===g.id,className:"flex items-center gap-2 px-4 py-2 bg-red-600 text-white text-sm font-medium rounded-lg hover:bg-red-700 disabled:opacity-50",children:[a.jsx(Hr,{className:"w-4 h-4"}),"Reject"]})]}),g.status==="approved"&&a.jsxs("span",{className:"flex items-center gap-2 px-4 py-2 bg-green-100 text-green-800 text-sm font-medium rounded-lg",children:[a.jsx(Pr,{className:"w-4 h-4"}),"Approved"]}),g.status==="rejected"&&a.jsxs("span",{className:"flex items-center gap-2 px-4 py-2 bg-red-100 text-red-800 text-sm font-medium rounded-lg",children:[a.jsx(Hr,{className:"w-4 h-4"}),"Rejected"]}),a.jsx("a",{href:`/dispensaries/${g.dispensary_slug}`,target:"_blank",rel:"noopener noreferrer",className:"p-2 text-gray-400 hover:text-gray-600",children:a.jsx(Jr,{className:"w-4 h-4"})})]})]})},g.id))})})]})})}function kF(){const[e,t]=h.useState([]),[r,n]=h.useState([]),[i,s]=h.useState(!0),[o,l]=h.useState(!1),[c,d]=h.useState({user_name:"",store_id:"",allowed_ips:"",allowed_domains:""}),[u,f]=h.useState(null);h.useEffect(()=>{m(),p()},[]);const p=async()=>{try{const y=await B.getApiPermissionDispensaries();n(y.dispensaries)}catch(y){console.error("Failed to load dispensaries:",y)}},m=async()=>{s(!0);try{const y=await B.getApiPermissions();t(y.permissions)}catch(y){f({message:"Failed to load API permissions: "+y.message,type:"error"})}finally{s(!1)}},x=async y=>{if(y.preventDefault(),!c.user_name.trim()){f({message:"User name is required",type:"error"});return}if(!c.store_id){f({message:"Store is required",type:"error"});return}try{const w=await B.createApiPermission({...c,store_id:parseInt(c.store_id)});f({message:w.message,type:"success"}),d({user_name:"",store_id:"",allowed_ips:"",allowed_domains:""}),l(!1),m()}catch(w){f({message:"Failed to create permission: "+w.message,type:"error"})}},g=async y=>{try{await B.toggleApiPermission(y),f({message:"Permission status updated",type:"success"}),m()}catch(w){f({message:"Failed to toggle permission: "+w.message,type:"error"})}},v=async y=>{if(confirm("Are you sure you want to delete this API permission?"))try{await B.deleteApiPermission(y),f({message:"Permission deleted successfully",type:"success"}),m()}catch(w){f({message:"Failed to delete permission: "+w.message,type:"error"})}},b=y=>{navigator.clipboard.writeText(y),f({message:"API key copied to clipboard!",type:"success"})},j=y=>{if(!y)return"Never";const w=new Date(y);return w.toLocaleDateString()+" "+w.toLocaleTimeString()};return i?a.jsx(X,{children:a.jsx("div",{className:"p-6",children:a.jsx("div",{className:"text-center text-gray-600",children:"Loading API permissions..."})})}):a.jsx(X,{children:a.jsxs("div",{className:"p-6",children:[u&&a.jsx(Vn,{message:u.message,type:u.type,onClose:()=>f(null)}),a.jsxs("div",{className:"flex justify-between items-center mb-6",children:[a.jsx("h1",{className:"text-2xl font-bold",children:"API Permissions"}),a.jsx("button",{onClick:()=>l(!o),className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700",children:o?"Cancel":"Add New Permission"})]}),a.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4 mb-6",children:[a.jsx("h3",{className:"font-semibold text-blue-900 mb-2",children:"How it works:"}),a.jsx("p",{className:"text-blue-800 text-sm",children:"Users with valid permissions can access your API without entering tokens. Access is automatically validated based on their IP address and/or domain name."})]}),o&&a.jsxs("div",{className:"bg-white rounded-lg shadow-md p-6 mb-6",children:[a.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add New API User"}),a.jsxs("form",{onSubmit:x,children:[a.jsxs("div",{className:"mb-4",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"User/Client Name *"}),a.jsx("input",{type:"text",value:c.user_name,onChange:y=>d({...c,user_name:y.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"e.g., My Website",required:!0}),a.jsx("p",{className:"text-sm text-gray-600 mt-1",children:"A friendly name to identify this API user"})]}),a.jsxs("div",{className:"mb-4",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Store *"}),a.jsxs("select",{value:c.store_id,onChange:y=>d({...c,store_id:y.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0,children:[a.jsx("option",{value:"",children:"Select a store..."}),r.map(y=>a.jsx("option",{value:y.id,children:y.name},y.id))]}),a.jsx("p",{className:"text-sm text-gray-600 mt-1",children:"The store this API token can access"})]}),a.jsxs("div",{className:"mb-4",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Allowed IP Addresses"}),a.jsx("textarea",{value:c.allowed_ips,onChange:y=>d({...c,allowed_ips:y.target.value}),rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-sm",placeholder:`192.168.1.1 10.0.0.0/8 2001:db8::/32`}),a.jsxs("p",{className:"text-sm text-gray-600 mt-1",children:["One IP address or CIDR range per line. Leave empty to allow any IP.",a.jsx("br",{}),"Supports IPv4, IPv6, and CIDR notation (e.g., 192.168.0.0/24)"]})]}),a.jsxs("div",{className:"mb-4",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Allowed Domains"}),a.jsx("textarea",{value:c.allowed_domains,onChange:y=>d({...c,allowed_domains:y.target.value}),rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-sm",placeholder:`example.com *.example.com subdomain.example.com`}),a.jsx("p",{className:"text-sm text-gray-600 mt-1",children:"One domain per line. Wildcards supported (e.g., *.example.com). Leave empty to allow any domain."})]}),a.jsx("button",{type:"submit",className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700",children:"Create API Permission"})]})]}),a.jsxs("div",{className:"bg-white rounded-lg shadow-md overflow-hidden",children:[a.jsx("div",{className:"px-6 py-4 border-b border-gray-200",children:a.jsx("h2",{className:"text-xl font-semibold",children:"Active API Users"})}),e.length===0?a.jsx("div",{className:"p-6 text-center text-gray-600",children:"No API permissions configured yet. Add your first user above."}):a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{className:"bg-gray-50",children:a.jsxs("tr",{children:[a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"User Name"}),a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Store"}),a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"API Key"}),a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Allowed IPs"}),a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Allowed Domains"}),a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Status"}),a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Last Used"}),a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Actions"})]})}),a.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:e.map(y=>a.jsxs("tr",{children:[a.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:a.jsx("div",{className:"font-medium text-gray-900",children:y.user_name})}),a.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:a.jsx("div",{className:"text-sm text-gray-900",children:y.store_name||a.jsx("span",{className:"text-gray-400 italic",children:"No store"})})}),a.jsx("td",{className:"px-6 py-4",children:a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsxs("code",{className:"text-xs bg-gray-100 px-2 py-1 rounded",children:[y.api_key.substring(0,16),"..."]}),a.jsx("button",{onClick:()=>b(y.api_key),className:"text-blue-600 hover:text-blue-800 text-sm",children:"Copy"})]})}),a.jsx("td",{className:"px-6 py-4",children:y.allowed_ips?a.jsxs("div",{className:"text-sm text-gray-600",children:[y.allowed_ips.split(` `).slice(0,2).join(", "),y.allowed_ips.split(` `).length>2&&a.jsxs("span",{className:"text-gray-400",children:[" +",y.allowed_ips.split(` `).length-2," more"]})]}):a.jsx("span",{className:"text-gray-400 italic",children:"Any IP"})}),a.jsx("td",{className:"px-6 py-4",children:y.allowed_domains?a.jsxs("div",{className:"text-sm text-gray-600",children:[y.allowed_domains.split(` `).slice(0,2).join(", "),y.allowed_domains.split(` `).length>2&&a.jsxs("span",{className:"text-gray-400",children:[" +",y.allowed_domains.split(` `).length-2," more"]})]}):a.jsx("span",{className:"text-gray-400 italic",children:"Any domain"})}),a.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:y.is_active?a.jsx("span",{className:"px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800",children:"Active"}):a.jsx("span",{className:"px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800",children:"Disabled"})}),a.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-600",children:j(y.last_used_at)}),a.jsxs("td",{className:"px-6 py-4 whitespace-nowrap text-sm space-x-2",children:[a.jsx("button",{onClick:()=>g(y.id),className:"text-blue-600 hover:text-blue-800",children:y.is_active?"Disable":"Enable"}),a.jsx("button",{onClick:()=>v(y.id),className:"text-red-600 hover:text-red-800",children:"Delete"})]})]},y.id))})]})})]})]})})}function _F(){const[e,t]=h.useState([]),[r,n]=h.useState([]),[i,s]=h.useState(null),[o,l]=h.useState(null),[c,d]=h.useState(!0),[u,f]=h.useState(!0),[p,m]=h.useState("schedules"),[x,g]=h.useState(null),[v,b]=h.useState(!1),[j,y]=h.useState(!1),[w,S]=h.useState(null);h.useEffect(()=>{if(N(),u){const k=setInterval(N,1e4);return()=>clearInterval(k)}},[u]);const N=async()=>{try{const[k,z,W,K]=await Promise.all([B.getDutchieAZSchedules(),B.getDutchieAZRunLogs({limit:50}),B.getDutchieAZSchedulerStatus(),B.getDetectionStats().catch(()=>null)]);t(k.schedules||[]),n(z.logs||[]),s(W),l(K)}catch(k){console.error("Failed to load schedule data:",k)}finally{d(!1)}},P=async()=>{try{i!=null&&i.running?await B.stopDutchieAZScheduler():await B.startDutchieAZScheduler(),await N()}catch(k){console.error("Failed to toggle scheduler:",k)}},C=async()=>{try{await B.initDutchieAZSchedules(),await N()}catch(k){console.error("Failed to initialize schedules:",k)}},T=async k=>{try{await B.triggerDutchieAZSchedule(k),await N()}catch(z){console.error("Failed to trigger schedule:",z)}},$=async k=>{try{await B.updateDutchieAZSchedule(k.id,{enabled:!k.enabled}),await N()}catch(z){console.error("Failed to toggle schedule:",z)}},I=async(k,z)=>{try{const W={description:z.description??void 0,enabled:z.enabled,baseIntervalMinutes:z.baseIntervalMinutes,jitterMinutes:z.jitterMinutes,jobConfig:z.jobConfig??void 0};await B.updateDutchieAZSchedule(k,W),g(null),await N()}catch(W){console.error("Failed to update schedule:",W)}},A=async()=>{if(confirm("Run menu detection on all dispensaries with unknown/missing menu_type?")){y(!0),S(null);try{const k=await B.detectAllDispensaries({state:"AZ",onlyUnknown:!0});S(k),await N()}catch(k){console.error("Failed to run bulk detection:",k)}finally{y(!1)}}},R=async()=>{if(confirm("Resolve platform IDs for all dispensaries missing them?")){y(!0),S(null);try{const k=await B.detectAllDispensaries({state:"AZ",onlyMissingPlatformId:!0,onlyUnknown:!1});S(k),await N()}catch(k){console.error("Failed to resolve platform IDs:",k)}finally{y(!1)}}},H=k=>{if(!k)return"Never";const z=new Date(k),K=new Date().getTime()-z.getTime(),ee=Math.floor(K/6e4),re=Math.floor(ee/60),Me=Math.floor(re/24);return ee<1?"Just now":ee<60?`${ee}m ago`:re<24?`${re}h ago`:`${Me}d ago`},M=k=>{if(!k)return"Not scheduled";const z=new Date(k),W=new Date,K=z.getTime()-W.getTime();if(K<0)return"Overdue";const ee=Math.floor(K/6e4),re=Math.floor(ee/60);return ee<60?`${ee}m`:`${re}h ${ee%60}m`},_=k=>{if(!k)return"-";if(k<1e3)return`${k}ms`;const z=Math.floor(k/1e3),W=Math.floor(z/60);return W<1?`${z}s`:`${W}m ${z%60}s`},D=(k,z)=>{const W=Math.floor(k/60),K=k%60,ee=Math.floor(z/60),re=z%60;let Me=W>0?`${W}h`:"";K>0&&(Me+=`${K}m`);let E=ee>0?`${ee}h`:"";return re>0&&(E+=`${re}m`),`${Me} +/- ${E}`},O=k=>{switch(k){case"success":return{bg:"#d1fae5",color:"#065f46"};case"running":return{bg:"#dbeafe",color:"#1e40af"};case"error":return{bg:"#fee2e2",color:"#991b1b"};case"partial":return{bg:"#fef3c7",color:"#92400e"};default:return{bg:"#f3f4f6",color:"#374151"}}};return a.jsx(X,{children:a.jsxs("div",{children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"30px"},children:[a.jsxs("div",{children:[a.jsx("h1",{style:{fontSize:"32px",margin:0},children:"AZ Schedule"}),a.jsx("p",{style:{color:"#666",margin:"8px 0 0 0"},children:"Jittered scheduling for Arizona product crawls"})]}),a.jsx("div",{style:{display:"flex",gap:"15px",alignItems:"center"},children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:u,onChange:k=>f(k.target.checked),style:{width:"18px",height:"18px",cursor:"pointer"}}),a.jsx("span",{children:"Auto-refresh (10s)"})]})})]}),a.jsxs("div",{style:{background:"white",padding:"20px",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",marginBottom:"30px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"20px"},children:[a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"14px",color:"#666",marginBottom:"4px"},children:"Scheduler Status"}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[a.jsx("span",{style:{width:"12px",height:"12px",borderRadius:"50%",background:i!=null&&i.running?"#10b981":"#ef4444",display:"inline-block"}}),a.jsx("span",{style:{fontWeight:"600",fontSize:"18px"},children:i!=null&&i.running?"Running":"Stopped"})]})]}),a.jsxs("div",{style:{borderLeft:"1px solid #eee",paddingLeft:"20px"},children:[a.jsx("div",{style:{fontSize:"14px",color:"#666",marginBottom:"4px"},children:"Poll Interval"}),a.jsx("div",{style:{fontWeight:"600"},children:i?`${i.pollIntervalMs/1e3}s`:"-"})]}),a.jsxs("div",{style:{borderLeft:"1px solid #eee",paddingLeft:"20px"},children:[a.jsx("div",{style:{fontSize:"14px",color:"#666",marginBottom:"4px"},children:"Active Schedules"}),a.jsxs("div",{style:{fontWeight:"600"},children:[e.filter(k=>k.enabled).length," / ",e.length]})]})]}),a.jsxs("div",{style:{display:"flex",gap:"10px"},children:[a.jsx("button",{onClick:P,style:{padding:"10px 20px",background:i!=null&&i.running?"#ef4444":"#10b981",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontWeight:"600"},children:i!=null&&i.running?"Stop Scheduler":"Start Scheduler"}),e.length===0&&a.jsx("button",{onClick:C,style:{padding:"10px 20px",background:"#2563eb",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontWeight:"600"},children:"Initialize Default Schedules"})]})]}),a.jsxs("div",{style:{marginBottom:"30px",display:"flex",gap:"10px",borderBottom:"2px solid #eee"},children:[a.jsxs("button",{onClick:()=>m("schedules"),style:{padding:"12px 24px",background:p==="schedules"?"white":"transparent",border:"none",borderBottom:p==="schedules"?"3px solid #2563eb":"3px solid transparent",cursor:"pointer",fontSize:"16px",fontWeight:p==="schedules"?"600":"400",color:p==="schedules"?"#2563eb":"#666",marginBottom:"-2px"},children:["Schedule Configs (",e.length,")"]}),a.jsxs("button",{onClick:()=>m("logs"),style:{padding:"12px 24px",background:p==="logs"?"white":"transparent",border:"none",borderBottom:p==="logs"?"3px solid #2563eb":"3px solid transparent",cursor:"pointer",fontSize:"16px",fontWeight:p==="logs"?"600":"400",color:p==="logs"?"#2563eb":"#666",marginBottom:"-2px"},children:["Run Logs (",r.length,")"]}),a.jsxs("button",{onClick:()=>m("detection"),style:{padding:"12px 24px",background:p==="detection"?"white":"transparent",border:"none",borderBottom:p==="detection"?"3px solid #2563eb":"3px solid transparent",cursor:"pointer",fontSize:"16px",fontWeight:p==="detection"?"600":"400",color:p==="detection"?"#2563eb":"#666",marginBottom:"-2px"},children:["Menu Detection ",o!=null&&o.needsDetection?`(${o.needsDetection} pending)`:""]})]}),p==="schedules"&&a.jsx("div",{style:{background:"white",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",overflow:"hidden"},children:e.length===0?a.jsx("div",{style:{padding:"40px",textAlign:"center",color:"#666"},children:'No schedules configured. Click "Initialize Default Schedules" to create the default crawl schedule.'}):a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[a.jsx("thead",{children:a.jsxs("tr",{style:{background:"#f8f8f8",borderBottom:"2px solid #eee"},children:[a.jsx("th",{style:{padding:"15px",textAlign:"left",fontWeight:"600"},children:"Job Name"}),a.jsx("th",{style:{padding:"15px",textAlign:"center",fontWeight:"600"},children:"Enabled"}),a.jsx("th",{style:{padding:"15px",textAlign:"center",fontWeight:"600"},children:"Interval (Jitter)"}),a.jsx("th",{style:{padding:"15px",textAlign:"left",fontWeight:"600"},children:"Last Run"}),a.jsx("th",{style:{padding:"15px",textAlign:"left",fontWeight:"600"},children:"Next Run"}),a.jsx("th",{style:{padding:"15px",textAlign:"left",fontWeight:"600"},children:"Last Status"}),a.jsx("th",{style:{padding:"15px",textAlign:"center",fontWeight:"600"},children:"Actions"})]})}),a.jsx("tbody",{children:e.map(k=>a.jsxs("tr",{style:{borderBottom:"1px solid #eee"},children:[a.jsxs("td",{style:{padding:"15px"},children:[a.jsx("div",{style:{fontWeight:"600"},children:k.jobName}),k.description&&a.jsx("div",{style:{fontSize:"13px",color:"#666",marginTop:"4px"},children:k.description}),k.jobConfig&&a.jsxs("div",{style:{fontSize:"11px",color:"#999",marginTop:"4px"},children:["Config: ",JSON.stringify(k.jobConfig)]})]}),a.jsx("td",{style:{padding:"15px",textAlign:"center"},children:a.jsx("button",{onClick:()=>$(k),style:{padding:"4px 12px",borderRadius:"12px",border:"none",cursor:"pointer",fontWeight:"600",fontSize:"12px",background:k.enabled?"#d1fae5":"#fee2e2",color:k.enabled?"#065f46":"#991b1b"},children:k.enabled?"ON":"OFF"})}),a.jsx("td",{style:{padding:"15px",textAlign:"center"},children:a.jsx("div",{style:{fontWeight:"600"},children:D(k.baseIntervalMinutes,k.jitterMinutes)})}),a.jsxs("td",{style:{padding:"15px"},children:[a.jsx("div",{children:H(k.lastRunAt)}),k.lastDurationMs&&a.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:["Duration: ",_(k.lastDurationMs)]})]}),a.jsxs("td",{style:{padding:"15px"},children:[a.jsx("div",{style:{fontWeight:"600",color:"#2563eb"},children:M(k.nextRunAt)}),k.nextRunAt&&a.jsx("div",{style:{fontSize:"12px",color:"#999"},children:new Date(k.nextRunAt).toLocaleString()})]}),a.jsx("td",{style:{padding:"15px"},children:k.lastStatus?a.jsxs("div",{children:[a.jsx("span",{style:{padding:"4px 10px",borderRadius:"12px",fontSize:"12px",fontWeight:"600",...O(k.lastStatus)},children:k.lastStatus}),k.lastErrorMessage&&a.jsx("button",{onClick:()=>alert(k.lastErrorMessage),style:{marginLeft:"8px",padding:"2px 6px",background:"#fee2e2",color:"#991b1b",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"10px"},children:"Error"})]}):a.jsx("span",{style:{color:"#999"},children:"Never run"})}),a.jsx("td",{style:{padding:"15px",textAlign:"center"},children:a.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"center"},children:[a.jsx("button",{onClick:()=>T(k.id),disabled:k.lastStatus==="running",style:{padding:"6px 12px",background:k.lastStatus==="running"?"#94a3b8":"#2563eb",color:"white",border:"none",borderRadius:"4px",cursor:k.lastStatus==="running"?"not-allowed":"pointer",fontSize:"13px"},children:"Run Now"}),a.jsx("button",{onClick:()=>g(k),style:{padding:"6px 12px",background:"#f3f4f6",color:"#374151",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:"Edit"})]})})]},k.id))})]})}),p==="logs"&&a.jsx("div",{style:{background:"white",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",overflow:"hidden"},children:r.length===0?a.jsx("div",{style:{padding:"40px",textAlign:"center",color:"#666"},children:"No run logs yet. Logs will appear here after jobs execute."}):a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[a.jsx("thead",{children:a.jsxs("tr",{style:{background:"#f8f8f8",borderBottom:"2px solid #eee"},children:[a.jsx("th",{style:{padding:"15px",textAlign:"left",fontWeight:"600"},children:"Job"}),a.jsx("th",{style:{padding:"15px",textAlign:"center",fontWeight:"600"},children:"Status"}),a.jsx("th",{style:{padding:"15px",textAlign:"left",fontWeight:"600"},children:"Started"}),a.jsx("th",{style:{padding:"15px",textAlign:"right",fontWeight:"600"},children:"Duration"}),a.jsx("th",{style:{padding:"15px",textAlign:"right",fontWeight:"600"},children:"Processed"}),a.jsx("th",{style:{padding:"15px",textAlign:"right",fontWeight:"600"},children:"Succeeded"}),a.jsx("th",{style:{padding:"15px",textAlign:"right",fontWeight:"600"},children:"Failed"})]})}),a.jsx("tbody",{children:r.map(k=>a.jsxs("tr",{style:{borderBottom:"1px solid #eee"},children:[a.jsxs("td",{style:{padding:"15px"},children:[a.jsx("div",{style:{fontWeight:"600"},children:k.job_name}),a.jsxs("div",{style:{fontSize:"12px",color:"#999"},children:["Run #",k.id]})]}),a.jsxs("td",{style:{padding:"15px",textAlign:"center"},children:[a.jsx("span",{style:{padding:"4px 10px",borderRadius:"12px",fontSize:"12px",fontWeight:"600",...O(k.status)},children:k.status}),k.error_message&&a.jsx("button",{onClick:()=>alert(k.error_message),style:{marginLeft:"8px",padding:"2px 6px",background:"#fee2e2",color:"#991b1b",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"10px"},children:"Error"})]}),a.jsxs("td",{style:{padding:"15px"},children:[a.jsx("div",{children:k.started_at?new Date(k.started_at).toLocaleString():"-"}),a.jsx("div",{style:{fontSize:"12px",color:"#999"},children:H(k.started_at)})]}),a.jsx("td",{style:{padding:"15px",textAlign:"right",fontWeight:"600"},children:_(k.duration_ms)}),a.jsx("td",{style:{padding:"15px",textAlign:"right"},children:k.items_processed??"-"}),a.jsx("td",{style:{padding:"15px",textAlign:"right",color:"#10b981"},children:k.items_succeeded??"-"}),a.jsx("td",{style:{padding:"15px",textAlign:"right",color:k.items_failed?"#ef4444":"inherit"},children:k.items_failed??"-"})]},k.id))})]})}),p==="detection"&&a.jsxs("div",{style:{background:"white",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",padding:"30px"},children:[o&&a.jsxs("div",{style:{marginBottom:"30px"},children:[a.jsx("h3",{style:{margin:"0 0 20px 0"},children:"Detection Statistics"}),a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:"20px"},children:[a.jsxs("div",{style:{padding:"20px",background:"#f8f8f8",borderRadius:"8px",textAlign:"center"},children:[a.jsx("div",{style:{fontSize:"32px",fontWeight:"700",color:"#2563eb"},children:o.totalDispensaries}),a.jsx("div",{style:{color:"#666",marginTop:"4px"},children:"Total Dispensaries"})]}),a.jsxs("div",{style:{padding:"20px",background:"#f8f8f8",borderRadius:"8px",textAlign:"center"},children:[a.jsx("div",{style:{fontSize:"32px",fontWeight:"700",color:"#10b981"},children:o.withMenuType}),a.jsx("div",{style:{color:"#666",marginTop:"4px"},children:"With Menu Type"})]}),a.jsxs("div",{style:{padding:"20px",background:"#f8f8f8",borderRadius:"8px",textAlign:"center"},children:[a.jsx("div",{style:{fontSize:"32px",fontWeight:"700",color:"#10b981"},children:o.withPlatformId}),a.jsx("div",{style:{color:"#666",marginTop:"4px"},children:"With Platform ID"})]}),a.jsxs("div",{style:{padding:"20px",background:"#fef3c7",borderRadius:"8px",textAlign:"center"},children:[a.jsx("div",{style:{fontSize:"32px",fontWeight:"700",color:"#92400e"},children:o.needsDetection}),a.jsx("div",{style:{color:"#666",marginTop:"4px"},children:"Needs Detection"})]})]}),Object.keys(o.byProvider).length>0&&a.jsxs("div",{style:{marginTop:"20px"},children:[a.jsx("h4",{style:{margin:"0 0 10px 0"},children:"By Provider"}),a.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"10px"},children:Object.entries(o.byProvider).map(([k,z])=>a.jsxs("span",{style:{padding:"6px 14px",background:k==="dutchie"?"#dbeafe":"#f3f4f6",borderRadius:"16px",fontSize:"14px",fontWeight:"600"},children:[k,": ",z]},k))})]})]}),a.jsxs("div",{style:{marginBottom:"30px",display:"flex",gap:"15px",flexWrap:"wrap"},children:[a.jsx("button",{onClick:A,disabled:j||!(o!=null&&o.needsDetection),style:{padding:"12px 24px",background:j?"#94a3b8":"#2563eb",color:"white",border:"none",borderRadius:"6px",cursor:j?"not-allowed":"pointer",fontWeight:"600",fontSize:"14px"},children:j?"Detecting...":"Detect All Unknown"}),a.jsx("button",{onClick:R,disabled:j,style:{padding:"12px 24px",background:j?"#94a3b8":"#10b981",color:"white",border:"none",borderRadius:"6px",cursor:j?"not-allowed":"pointer",fontWeight:"600",fontSize:"14px"},children:j?"Resolving...":"Resolve Missing Platform IDs"})]}),w&&a.jsxs("div",{style:{marginBottom:"30px",padding:"20px",background:"#f8f8f8",borderRadius:"8px"},children:[a.jsx("h4",{style:{margin:"0 0 15px 0"},children:"Detection Results"}),a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"15px",marginBottom:"15px"},children:[a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:"600",fontSize:"24px"},children:w.totalProcessed}),a.jsx("div",{style:{color:"#666",fontSize:"13px"},children:"Processed"})]}),a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:"600",fontSize:"24px",color:"#10b981"},children:w.totalSucceeded}),a.jsx("div",{style:{color:"#666",fontSize:"13px"},children:"Succeeded"})]}),a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:"600",fontSize:"24px",color:"#ef4444"},children:w.totalFailed}),a.jsx("div",{style:{color:"#666",fontSize:"13px"},children:"Failed"})]}),a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:"600",fontSize:"24px",color:"#666"},children:w.totalSkipped}),a.jsx("div",{style:{color:"#666",fontSize:"13px"},children:"Skipped"})]})]}),w.errors&&w.errors.length>0&&a.jsxs("div",{style:{marginTop:"15px"},children:[a.jsx("div",{style:{fontWeight:"600",marginBottom:"8px",color:"#991b1b"},children:"Errors:"}),a.jsxs("div",{style:{maxHeight:"150px",overflow:"auto",background:"#fee2e2",padding:"10px",borderRadius:"4px",fontSize:"12px"},children:[w.errors.slice(0,10).map((k,z)=>a.jsx("div",{style:{marginBottom:"4px"},children:k},z)),w.errors.length>10&&a.jsxs("div",{style:{fontStyle:"italic",marginTop:"8px"},children:["...and ",w.errors.length-10," more"]})]})]})]}),a.jsxs("div",{style:{padding:"20px",background:"#f0f9ff",borderRadius:"8px",fontSize:"14px"},children:[a.jsx("h4",{style:{margin:"0 0 10px 0",color:"#1e40af"},children:"About Menu Detection"}),a.jsxs("ul",{style:{margin:0,paddingLeft:"20px",color:"#1e40af"},children:[a.jsxs("li",{style:{marginBottom:"8px"},children:[a.jsx("strong",{children:"Detect All Unknown:"})," Scans dispensaries with no menu_type set and detects the provider (dutchie, treez, jane, etc.) from their menu_url."]}),a.jsxs("li",{style:{marginBottom:"8px"},children:[a.jsx("strong",{children:"Resolve Missing Platform IDs:"}),' For dispensaries already detected as "dutchie", extracts the cName from menu_url and resolves the platform_dispensary_id via GraphQL.']}),a.jsxs("li",{children:[a.jsx("strong",{children:"Automatic scheduling:"}),' A "Menu Detection" job runs daily (24h +/- 1h jitter) to detect new dispensaries.']})]})]})]}),x&&a.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},children:a.jsxs("div",{style:{background:"white",padding:"30px",borderRadius:"12px",width:"500px",maxWidth:"90vw"},children:[a.jsxs("h2",{style:{margin:"0 0 20px 0"},children:["Edit Schedule: ",x.jobName]}),a.jsxs("div",{style:{marginBottom:"20px"},children:[a.jsx("label",{style:{display:"block",marginBottom:"8px",fontWeight:"600"},children:"Description"}),a.jsx("input",{type:"text",value:x.description||"",onChange:k=>g({...x,description:k.target.value}),style:{width:"100%",padding:"10px",borderRadius:"6px",border:"1px solid #ddd",fontSize:"14px"}})]}),a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"20px",marginBottom:"20px"},children:[a.jsxs("div",{children:[a.jsx("label",{style:{display:"block",marginBottom:"8px",fontWeight:"600"},children:"Base Interval (minutes)"}),a.jsx("input",{type:"number",value:x.baseIntervalMinutes,onChange:k=>g({...x,baseIntervalMinutes:parseInt(k.target.value)||240}),style:{width:"100%",padding:"10px",borderRadius:"6px",border:"1px solid #ddd",fontSize:"14px"}}),a.jsxs("div",{style:{fontSize:"12px",color:"#666",marginTop:"4px"},children:["= ",Math.floor(x.baseIntervalMinutes/60),"h ",x.baseIntervalMinutes%60,"m"]})]}),a.jsxs("div",{children:[a.jsx("label",{style:{display:"block",marginBottom:"8px",fontWeight:"600"},children:"Jitter (minutes)"}),a.jsx("input",{type:"number",value:x.jitterMinutes,onChange:k=>g({...x,jitterMinutes:parseInt(k.target.value)||30}),style:{width:"100%",padding:"10px",borderRadius:"6px",border:"1px solid #ddd",fontSize:"14px"}}),a.jsxs("div",{style:{fontSize:"12px",color:"#666",marginTop:"4px"},children:["+/- ",x.jitterMinutes,"m random offset"]})]})]}),a.jsxs("div",{style:{fontSize:"13px",color:"#666",marginBottom:"20px",padding:"15px",background:"#f8f8f8",borderRadius:"6px"},children:[a.jsx("strong",{children:"Effective range:"})," ",Math.floor((x.baseIntervalMinutes-x.jitterMinutes)/60),"h ",(x.baseIntervalMinutes-x.jitterMinutes)%60,"m"," to ",Math.floor((x.baseIntervalMinutes+x.jitterMinutes)/60),"h ",(x.baseIntervalMinutes+x.jitterMinutes)%60,"m"]}),a.jsxs("div",{style:{display:"flex",gap:"10px",justifyContent:"flex-end"},children:[a.jsx("button",{onClick:()=>g(null),style:{padding:"10px 20px",background:"#f3f4f6",color:"#374151",border:"none",borderRadius:"6px",cursor:"pointer"},children:"Cancel"}),a.jsx("button",{onClick:()=>I(x.id,{description:x.description,baseIntervalMinutes:x.baseIntervalMinutes,jitterMinutes:x.jitterMinutes}),style:{padding:"10px 20px",background:"#2563eb",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontWeight:"600"},children:"Save Changes"})]})]})})]})})}function PF(){const e=dt(),[t,r]=h.useState([]),[n,i]=h.useState(0),[s,o]=h.useState(!0),[l,c]=h.useState(null);h.useEffect(()=>{d()},[]);const d=async()=>{o(!0);try{const[u,f]=await Promise.all([B.getDutchieAZStores({limit:200}),B.getDutchieAZDashboard()]);r(u.stores),i(u.total),c(f)}catch(u){console.error("Failed to load data:",u)}finally{o(!1)}};return s?a.jsx(X,{children:a.jsxs("div",{className:"text-center py-12",children:[a.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-blue-500 border-t-transparent"}),a.jsx("p",{className:"mt-2 text-sm text-gray-600",children:"Loading stores..."})]})}):a.jsx(X,{children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"AZ Stores"}),a.jsx("p",{className:"text-sm text-gray-600 mt-1",children:"Arizona dispensaries - data from the CannaIQ pipeline"})]}),a.jsxs("button",{onClick:d,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50",children:[a.jsx(Xt,{className:"w-4 h-4"}),"Refresh"]})]}),l&&a.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[a.jsx("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-blue-50 rounded-lg",children:a.jsx(Ln,{className:"w-5 h-5 text-blue-600"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-gray-600",children:"Dispensaries"}),a.jsx("p",{className:"text-xl font-bold text-gray-900",children:l.dispensaryCount})]})]})}),a.jsx("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-green-50 rounded-lg",children:a.jsx(Ct,{className:"w-5 h-5 text-green-600"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-gray-600",children:"Total Products"}),a.jsx("p",{className:"text-xl font-bold text-gray-900",children:l.productCount.toLocaleString()})]})]})}),a.jsx("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-purple-50 rounded-lg",children:a.jsx(Pr,{className:"w-5 h-5 text-purple-600"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-gray-600",children:"Brands"}),a.jsx("p",{className:"text-xl font-bold text-gray-900",children:l.brandCount})]})]})}),a.jsx("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-orange-50 rounded-lg",children:a.jsx(Hr,{className:"w-5 h-5 text-orange-600"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-gray-600",children:"Failed Jobs (24h)"}),a.jsx("p",{className:"text-xl font-bold text-gray-900",children:l.failedJobCount})]})]})})]}),a.jsxs("div",{className:"bg-white rounded-lg border border-gray-200",children:[a.jsx("div",{className:"p-4 border-b border-gray-200",children:a.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:["All Stores (",n,")"]})}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"table table-zebra w-full",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Name"}),a.jsx("th",{children:"City"}),a.jsx("th",{children:"Menu Type"}),a.jsx("th",{children:"Platform ID"}),a.jsx("th",{children:"Status"}),a.jsx("th",{children:"Actions"})]})}),a.jsx("tbody",{children:t.map(u=>a.jsxs("tr",{children:[a.jsx("td",{children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-blue-50 rounded-lg",children:a.jsx(Ln,{className:"w-4 h-4 text-blue-600"})}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-gray-900",children:u.dba_name||u.name}),u.company_name&&u.company_name!==u.name&&a.jsx("p",{className:"text-xs text-gray-500",children:u.company_name})]})]})}),a.jsx("td",{children:a.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[a.jsx(yi,{className:"w-4 h-4"}),u.city,", ",u.state]})}),a.jsx("td",{children:u.menu_type?a.jsx("span",{className:`badge badge-sm ${u.menu_type==="dutchie"?"badge-success":u.menu_type==="jane"?"badge-info":u.menu_type==="joint"?"badge-primary":u.menu_type==="treez"?"badge-secondary":u.menu_type==="leafly"?"badge-accent":"badge-ghost"}`,children:u.menu_type}):a.jsx("span",{className:"badge badge-ghost badge-sm",children:"unknown"})}),a.jsx("td",{children:u.platform_dispensary_id?a.jsx("span",{className:"text-xs font-mono text-gray-600",children:u.platform_dispensary_id}):a.jsx("span",{className:"badge badge-warning badge-sm",children:"Not Resolved"})}),a.jsx("td",{children:u.platform_dispensary_id?a.jsx("span",{className:"badge badge-success badge-sm",children:"Ready"}):a.jsx("span",{className:"badge badge-warning badge-sm",children:"Pending"})}),a.jsx("td",{children:a.jsx("button",{onClick:()=>e(`/az/stores/${u.id}`),className:"btn btn-sm btn-primary",disabled:!u.platform_dispensary_id,children:"View Products"})})]},u.id))})]})})]})]})})}function CF(){const{id:e}=_a(),t=dt(),[r,n]=h.useState(null),[i,s]=h.useState([]),[o,l]=h.useState(!0),[c,d]=h.useState(!1),[u,f]=h.useState("products"),[p,m]=h.useState(!1),[x,g]=h.useState(!1),[v,b]=h.useState(""),[j,y]=h.useState(1),[w,S]=h.useState(0),[N]=h.useState(25),[P,C]=h.useState(""),T=O=>{if(!O)return"Never";const k=new Date(O),W=new Date().getTime()-k.getTime(),K=Math.floor(W/(1e3*60)),ee=Math.floor(W/(1e3*60*60)),re=Math.floor(W/(1e3*60*60*24));return K<1?"Just now":K<60?`${K}m ago`:ee<24?`${ee}h ago`:re===1?"Yesterday":re<7?`${re} days ago`:k.toLocaleDateString()};h.useEffect(()=>{e&&$()},[e]),h.useEffect(()=>{e&&u==="products"&&I()},[e,j,v,P,u]),h.useEffect(()=>{y(1)},[v,P]);const $=async()=>{l(!0);try{const O=await B.getDutchieAZStoreSummary(parseInt(e,10));n(O)}catch(O){console.error("Failed to load store summary:",O)}finally{l(!1)}},I=async()=>{if(e){d(!0);try{const O=await B.getDutchieAZStoreProducts(parseInt(e,10),{search:v||void 0,stockStatus:P||void 0,limit:N,offset:(j-1)*N});s(O.products),S(O.total)}catch(O){console.error("Failed to load products:",O)}finally{d(!1)}}},A=async()=>{m(!1),g(!0);try{await B.triggerDutchieAZCrawl(parseInt(e,10)),alert("Crawl started! Refresh the page in a few minutes to see updated data.")}catch(O){console.error("Failed to trigger crawl:",O),alert("Failed to start crawl. Please try again.")}finally{g(!1)}},R=Math.ceil(w/N);if(o)return a.jsx(X,{children:a.jsxs("div",{className:"text-center py-12",children:[a.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-blue-500 border-t-transparent"}),a.jsx("p",{className:"mt-2 text-sm text-gray-600",children:"Loading store..."})]})});if(!r)return a.jsx(X,{children:a.jsx("div",{className:"text-center py-12",children:a.jsx("p",{className:"text-gray-600",children:"Store not found"})})});const{dispensary:H,brands:M,categories:_,lastCrawl:D}=r;return a.jsx(X,{children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsxs("button",{onClick:()=>t("/az"),className:"flex items-center gap-2 text-sm text-gray-600 hover:text-gray-900",children:[a.jsx(Eh,{className:"w-4 h-4"}),"Back to AZ Stores"]}),a.jsxs("div",{className:"relative",children:[a.jsxs("button",{onClick:()=>m(!p),disabled:x,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-lg disabled:opacity-50 disabled:cursor-not-allowed",children:[a.jsx(Xt,{className:`w-4 h-4 ${x?"animate-spin":""}`}),x?"Crawling...":"Crawl Now",!x&&a.jsx(ij,{className:"w-4 h-4"})]}),p&&!x&&a.jsx("div",{className:"absolute right-0 mt-2 w-48 bg-white rounded-lg shadow-lg border border-gray-200 z-10",children:a.jsx("button",{onClick:A,className:"w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 rounded-lg",children:"Start Full Crawl"})})]})]}),a.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 p-6",children:[a.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[a.jsxs("div",{className:"flex items-start gap-4",children:[a.jsx("div",{className:"p-3 bg-blue-50 rounded-lg",children:a.jsx(Ln,{className:"w-8 h-8 text-blue-600"})}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:H.dba_name||H.name}),H.company_name&&a.jsx("p",{className:"text-sm text-gray-600 mt-1",children:H.company_name}),a.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Platform ID: ",H.platform_dispensary_id||"Not resolved"]})]})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600 bg-gray-50 px-4 py-2 rounded-lg",children:[a.jsx(xr,{className:"w-4 h-4"}),a.jsxs("div",{children:[a.jsx("span",{className:"font-medium",children:"Last Crawl:"}),a.jsx("span",{className:"ml-2",children:D!=null&&D.completed_at?new Date(D.completed_at).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"Never"}),(D==null?void 0:D.status)&&a.jsx("span",{className:`ml-2 px-2 py-0.5 rounded text-xs ${D.status==="completed"?"bg-green-100 text-green-800":D.status==="failed"?"bg-red-100 text-red-800":"bg-yellow-100 text-yellow-800"}`,children:D.status})]})]})]}),a.jsxs("div",{className:"flex flex-wrap gap-4",children:[H.address&&a.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[a.jsx(yi,{className:"w-4 h-4"}),a.jsxs("span",{children:[H.address,", ",H.city,", ",H.state," ",H.zip]})]}),H.phone&&a.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[a.jsx(Ms,{className:"w-4 h-4"}),a.jsx("span",{children:H.phone})]}),H.website&&a.jsxs("a",{href:H.website,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-sm text-blue-600 hover:text-blue-800",children:[a.jsx(Jr,{className:"w-4 h-4"}),"Website"]})]})]}),a.jsxs("div",{className:"grid grid-cols-5 gap-4",children:[a.jsx("button",{onClick:()=>{f("products"),C(""),b("")},className:`bg-white rounded-lg border p-4 hover:border-blue-300 hover:shadow-md transition-all cursor-pointer text-left ${u==="products"&&!P?"border-blue-500":"border-gray-200"}`,children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-green-50 rounded-lg",children:a.jsx(Ct,{className:"w-5 h-5 text-green-600"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-gray-600",children:"Total Products"}),a.jsx("p",{className:"text-xl font-bold text-gray-900",children:r.totalProducts})]})]})}),a.jsx("button",{onClick:()=>{f("products"),C("in_stock"),b("")},className:`bg-white rounded-lg border p-4 hover:border-blue-300 hover:shadow-md transition-all cursor-pointer text-left ${P==="in_stock"?"border-blue-500":"border-gray-200"}`,children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-emerald-50 rounded-lg",children:a.jsx(Pr,{className:"w-5 h-5 text-emerald-600"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-gray-600",children:"In Stock"}),a.jsx("p",{className:"text-xl font-bold text-gray-900",children:r.inStockCount})]})]})}),a.jsx("button",{onClick:()=>{f("products"),C("out_of_stock"),b("")},className:`bg-white rounded-lg border p-4 hover:border-blue-300 hover:shadow-md transition-all cursor-pointer text-left ${P==="out_of_stock"?"border-blue-500":"border-gray-200"}`,children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-red-50 rounded-lg",children:a.jsx(Hr,{className:"w-5 h-5 text-red-600"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-gray-600",children:"Out of Stock"}),a.jsx("p",{className:"text-xl font-bold text-gray-900",children:r.outOfStockCount})]})]})}),a.jsx("button",{onClick:()=>f("brands"),className:`bg-white rounded-lg border p-4 hover:border-blue-300 hover:shadow-md transition-all cursor-pointer text-left ${u==="brands"?"border-blue-500":"border-gray-200"}`,children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-purple-50 rounded-lg",children:a.jsx(Cr,{className:"w-5 h-5 text-purple-600"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-gray-600",children:"Brands"}),a.jsx("p",{className:"text-xl font-bold text-gray-900",children:r.brandCount})]})]})}),a.jsx("button",{onClick:()=>f("categories"),className:`bg-white rounded-lg border p-4 hover:border-blue-300 hover:shadow-md transition-all cursor-pointer text-left ${u==="categories"?"border-blue-500":"border-gray-200"}`,children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-orange-50 rounded-lg",children:a.jsx(ha,{className:"w-5 h-5 text-orange-600"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-gray-600",children:"Categories"}),a.jsx("p",{className:"text-xl font-bold text-gray-900",children:r.categoryCount})]})]})})]}),a.jsxs("div",{className:"bg-white rounded-lg border border-gray-200",children:[a.jsx("div",{className:"border-b border-gray-200",children:a.jsxs("div",{className:"flex gap-4 px-6",children:[a.jsxs("button",{onClick:()=>{f("products"),C("")},className:`py-4 px-2 text-sm font-medium border-b-2 ${u==="products"?"border-blue-600 text-blue-600":"border-transparent text-gray-600 hover:text-gray-900"}`,children:["Products (",r.totalProducts,")"]}),a.jsxs("button",{onClick:()=>f("brands"),className:`py-4 px-2 text-sm font-medium border-b-2 ${u==="brands"?"border-blue-600 text-blue-600":"border-transparent text-gray-600 hover:text-gray-900"}`,children:["Brands (",r.brandCount,")"]}),a.jsxs("button",{onClick:()=>f("categories"),className:`py-4 px-2 text-sm font-medium border-b-2 ${u==="categories"?"border-blue-600 text-blue-600":"border-transparent text-gray-600 hover:text-gray-900"}`,children:["Categories (",r.categoryCount,")"]})]})}),a.jsxs("div",{className:"p-6",children:[u==="products"&&a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[a.jsx("input",{type:"text",placeholder:"Search products by name or brand...",value:v,onChange:O=>b(O.target.value),className:"input input-bordered input-sm flex-1"}),a.jsxs("select",{value:P,onChange:O=>C(O.target.value),className:"select select-bordered select-sm",children:[a.jsx("option",{value:"",children:"All Stock"}),a.jsx("option",{value:"in_stock",children:"In Stock"}),a.jsx("option",{value:"out_of_stock",children:"Out of Stock"}),a.jsx("option",{value:"unknown",children:"Unknown"})]}),(v||P)&&a.jsx("button",{onClick:()=>{b(""),C("")},className:"btn btn-sm btn-ghost",children:"Clear"}),a.jsxs("div",{className:"text-sm text-gray-600",children:[w," products"]})]}),c?a.jsxs("div",{className:"text-center py-8",children:[a.jsx("div",{className:"inline-block animate-spin rounded-full h-6 w-6 border-4 border-blue-500 border-t-transparent"}),a.jsx("p",{className:"mt-2 text-sm text-gray-600",children:"Loading products..."})]}):i.length===0?a.jsx("p",{className:"text-center py-8 text-gray-500",children:"No products found"}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"overflow-x-auto -mx-6 px-6",children:a.jsxs("table",{className:"table table-xs table-zebra table-pin-rows w-full",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Image"}),a.jsx("th",{children:"Product Name"}),a.jsx("th",{children:"Brand"}),a.jsx("th",{children:"Type"}),a.jsx("th",{className:"text-right",children:"Price"}),a.jsx("th",{className:"text-center",children:"THC %"}),a.jsx("th",{className:"text-center",children:"Stock"}),a.jsx("th",{className:"text-center",children:"Qty"}),a.jsx("th",{children:"Last Updated"})]})}),a.jsx("tbody",{children:i.map(O=>a.jsxs("tr",{children:[a.jsx("td",{className:"whitespace-nowrap",children:O.image_url?a.jsx("img",{src:O.image_url,alt:O.name,className:"w-12 h-12 object-cover rounded",onError:k=>k.currentTarget.style.display="none"}):"-"}),a.jsx("td",{className:"font-medium max-w-[200px]",children:a.jsx("div",{className:"line-clamp-2",title:O.name,children:O.name})}),a.jsx("td",{className:"max-w-[120px]",children:a.jsx("div",{className:"line-clamp-2",title:O.brand||"-",children:O.brand||"-"})}),a.jsxs("td",{className:"whitespace-nowrap",children:[a.jsx("span",{className:"badge badge-ghost badge-sm",children:O.type||"-"}),O.subcategory&&a.jsx("span",{className:"badge badge-ghost badge-sm ml-1",children:O.subcategory})]}),a.jsx("td",{className:"text-right font-semibold whitespace-nowrap",children:O.sale_price?a.jsxs("div",{className:"flex flex-col items-end",children:[a.jsxs("span",{className:"text-error",children:["$",O.sale_price]}),a.jsxs("span",{className:"text-gray-400 line-through text-xs",children:["$",O.regular_price]})]}):O.regular_price?`$${O.regular_price}`:"-"}),a.jsx("td",{className:"text-center whitespace-nowrap",children:O.thc_percentage?a.jsxs("span",{className:"badge badge-success badge-sm",children:[O.thc_percentage,"%"]}):"-"}),a.jsx("td",{className:"text-center whitespace-nowrap",children:O.stock_status==="in_stock"?a.jsx("span",{className:"badge badge-success badge-sm",children:"In Stock"}):O.stock_status==="out_of_stock"?a.jsx("span",{className:"badge badge-error badge-sm",children:"Out"}):a.jsx("span",{className:"badge badge-warning badge-sm",children:"Unknown"})}),a.jsx("td",{className:"text-center whitespace-nowrap",children:O.total_quantity!=null?O.total_quantity:"-"}),a.jsx("td",{className:"whitespace-nowrap text-xs text-gray-500",children:O.updated_at?T(O.updated_at):"-"})]},O.id))})]})}),R>1&&a.jsxs("div",{className:"flex justify-center items-center gap-2 mt-4",children:[a.jsx("button",{onClick:()=>y(O=>Math.max(1,O-1)),disabled:j===1,className:"btn btn-sm btn-outline",children:"Previous"}),a.jsx("div",{className:"flex gap-1",children:Array.from({length:Math.min(5,R)},(O,k)=>{let z;return R<=5||j<=3?z=k+1:j>=R-2?z=R-4+k:z=j-2+k,a.jsx("button",{onClick:()=>y(z),className:`btn btn-sm ${j===z?"btn-primary":"btn-outline"}`,children:z},z)})}),a.jsx("button",{onClick:()=>y(O=>Math.min(R,O+1)),disabled:j===R,className:"btn btn-sm btn-outline",children:"Next"})]})]})]}),u==="brands"&&a.jsx("div",{className:"space-y-4",children:M.length===0?a.jsx("p",{className:"text-center py-8 text-gray-500",children:"No brands found"}):a.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:M.map(O=>a.jsxs("button",{onClick:()=>{f("products"),b(O.brand_name),C("")},className:"border border-gray-200 rounded-lg p-4 text-center hover:border-blue-300 hover:shadow-md transition-all cursor-pointer",children:[a.jsx("p",{className:"font-medium text-gray-900 line-clamp-2",children:O.brand_name}),a.jsxs("p",{className:"text-sm text-gray-600 mt-1",children:[O.product_count," product",O.product_count!==1?"s":""]})]},O.brand_name))})}),u==="categories"&&a.jsx("div",{className:"space-y-4",children:_.length===0?a.jsx("p",{className:"text-center py-8 text-gray-500",children:"No categories found"}):a.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:_.map((O,k)=>a.jsxs("div",{className:"border border-gray-200 rounded-lg p-4 text-center",children:[a.jsx("p",{className:"font-medium text-gray-900",children:O.type}),O.subcategory&&a.jsx("p",{className:"text-sm text-gray-600",children:O.subcategory}),a.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:[O.product_count," product",O.product_count!==1?"s":""]})]},k))})})]})]})]})})}function AF(){const e=dt(),[t,r]=h.useState(null),[n,i]=h.useState([]),[s,o]=h.useState([]),[l,c]=h.useState([]),[d,u]=h.useState(!0),[f,p]=h.useState("overview");h.useEffect(()=>{m()},[]);const m=async()=>{u(!0);try{const[g,v,b,j]=await Promise.all([B.getDutchieAZDashboard(),B.getDutchieAZStores({limit:200}),B.getDutchieAZBrands?B.getDutchieAZBrands({limit:100}):Promise.resolve({brands:[]}),B.getDutchieAZCategories?B.getDutchieAZCategories():Promise.resolve({categories:[]})]);r(g),i(v.stores||[]),o(b.brands||[]),c(j.categories||[])}catch(g){console.error("Failed to load analytics data:",g)}finally{u(!1)}},x=g=>{if(!g)return"Never";const v=new Date(g),j=new Date().getTime()-v.getTime(),y=Math.floor(j/(1e3*60*60)),w=Math.floor(j/(1e3*60*60*24));return y<1?"Just now":y<24?`${y}h ago`:w===1?"Yesterday":w<7?`${w} days ago`:v.toLocaleDateString()};return d?a.jsx(X,{children:a.jsxs("div",{className:"text-center py-12",children:[a.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-blue-500 border-t-transparent"}),a.jsx("p",{className:"mt-2 text-sm text-gray-600",children:"Loading analytics..."})]})}):a.jsx(X,{children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Wholesale & Inventory Analytics"}),a.jsx("p",{className:"text-sm text-gray-600 mt-1",children:"Arizona dispensaries data overview"})]}),a.jsxs("button",{onClick:m,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50",children:[a.jsx(Xt,{className:"w-4 h-4"}),"Refresh"]})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-7 gap-4",children:[a.jsx(Ii,{title:"Dispensaries",value:(t==null?void 0:t.dispensaryCount)||0,icon:a.jsx(Ln,{className:"w-5 h-5 text-blue-600"}),color:"blue"}),a.jsx(Ii,{title:"Total Products",value:(t==null?void 0:t.productCount)||0,icon:a.jsx(Ct,{className:"w-5 h-5 text-green-600"}),color:"green"}),a.jsx(Ii,{title:"Brands",value:(t==null?void 0:t.brandCount)||0,icon:a.jsx(Cr,{className:"w-5 h-5 text-purple-600"}),color:"purple"}),a.jsx(Ii,{title:"Categories",value:(t==null?void 0:t.categoryCount)||0,icon:a.jsx(zx,{className:"w-5 h-5 text-orange-600"}),color:"orange"}),a.jsx(Ii,{title:"Snapshots (24h)",value:(t==null?void 0:t.snapshotCount24h)||0,icon:a.jsx(zn,{className:"w-5 h-5 text-cyan-600"}),color:"cyan"}),a.jsx(Ii,{title:"Failed Jobs (24h)",value:(t==null?void 0:t.failedJobCount)||0,icon:a.jsx(ha,{className:"w-5 h-5 text-red-600"}),color:"red"}),a.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 text-gray-600 mb-1",children:[a.jsx(xr,{className:"w-4 h-4"}),a.jsx("span",{className:"text-xs",children:"Last Crawl"})]}),a.jsx("p",{className:"text-sm font-semibold text-gray-900",children:x((t==null?void 0:t.lastCrawlTime)||null)})]})]}),a.jsxs("div",{className:"bg-white rounded-lg border border-gray-200",children:[a.jsx("div",{className:"border-b border-gray-200",children:a.jsxs("div",{className:"flex gap-4 px-6",children:[a.jsx(Go,{active:f==="overview",onClick:()=>p("overview"),icon:a.jsx(XA,{className:"w-4 h-4"}),label:"Overview"}),a.jsx(Go,{active:f==="stores",onClick:()=>p("stores"),icon:a.jsx(Ln,{className:"w-4 h-4"}),label:`Stores (${n.length})`}),a.jsx(Go,{active:f==="brands",onClick:()=>p("brands"),icon:a.jsx(Cr,{className:"w-4 h-4"}),label:`Brands (${s.length})`}),a.jsx(Go,{active:f==="categories",onClick:()=>p("categories"),icon:a.jsx(zx,{className:"w-4 h-4"}),label:`Categories (${l.length})`})]})}),a.jsxs("div",{className:"p-6",children:[f==="overview"&&a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:"Top Stores by Products"}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:n.slice(0,6).map(g=>a.jsxs("button",{onClick:()=>e(`/az/stores/${g.id}`),className:"flex items-center justify-between p-4 bg-gray-50 rounded-lg hover:bg-gray-100 transition-colors text-left",children:[a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-gray-900",children:g.dba_name||g.name}),a.jsxs("p",{className:"text-sm text-gray-600",children:[g.city,", ",g.state]}),a.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Last crawl: ",x(g.last_crawl_at||null)]})]}),a.jsx(Mf,{className:"w-5 h-5 text-gray-400"})]},g.id))})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:"Top Brands"}),a.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4",children:s.slice(0,12).map(g=>a.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg text-center",children:[a.jsx("p",{className:"font-medium text-gray-900 text-sm line-clamp-2",children:g.brand_name}),a.jsx("p",{className:"text-lg font-bold text-purple-600 mt-1",children:g.product_count}),a.jsx("p",{className:"text-xs text-gray-500",children:"products"})]},g.brand_name))})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:"Product Categories"}),a.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:l.slice(0,12).map((g,v)=>a.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg text-center",children:[a.jsx("p",{className:"font-medium text-gray-900",children:g.type}),g.subcategory&&a.jsx("p",{className:"text-xs text-gray-600",children:g.subcategory}),a.jsx("p",{className:"text-lg font-bold text-orange-600 mt-1",children:g.product_count}),a.jsx("p",{className:"text-xs text-gray-500",children:"products"})]},v))})]})]}),f==="stores"&&a.jsx("div",{className:"space-y-4",children:a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"table table-sm w-full",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Store Name"}),a.jsx("th",{children:"City"}),a.jsx("th",{className:"text-center",children:"Platform ID"}),a.jsx("th",{className:"text-center",children:"Last Crawl"}),a.jsx("th",{})]})}),a.jsx("tbody",{children:n.map(g=>a.jsxs("tr",{className:"hover",children:[a.jsx("td",{className:"font-medium",children:g.dba_name||g.name}),a.jsxs("td",{children:[g.city,", ",g.state]}),a.jsx("td",{className:"text-center",children:g.platform_dispensary_id?a.jsx("span",{className:"badge badge-success badge-sm",children:"Resolved"}):a.jsx("span",{className:"badge badge-warning badge-sm",children:"Pending"})}),a.jsx("td",{className:"text-center text-sm text-gray-600",children:x(g.last_crawl_at||null)}),a.jsx("td",{children:a.jsx("button",{onClick:()=>e(`/az/stores/${g.id}`),className:"btn btn-xs btn-ghost",children:"View"})})]},g.id))})]})})}),f==="brands"&&a.jsx("div",{className:"space-y-4",children:s.length===0?a.jsx("p",{className:"text-center py-8 text-gray-500",children:"No brands found. Run a crawl to populate brand data."}):a.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:s.map(g=>a.jsxs("div",{className:"border border-gray-200 rounded-lg p-4 text-center hover:border-purple-300 hover:shadow-md transition-all",children:[a.jsx("p",{className:"font-medium text-gray-900 text-sm line-clamp-2 h-10",children:g.brand_name}),a.jsxs("div",{className:"mt-2 space-y-1",children:[a.jsxs("div",{className:"flex justify-between text-xs",children:[a.jsx("span",{className:"text-gray-500",children:"Products:"}),a.jsx("span",{className:"font-semibold",children:g.product_count})]}),a.jsxs("div",{className:"flex justify-between text-xs",children:[a.jsx("span",{className:"text-gray-500",children:"Stores:"}),a.jsx("span",{className:"font-semibold",children:g.dispensary_count})]})]})]},g.brand_name))})}),f==="categories"&&a.jsx("div",{className:"space-y-4",children:l.length===0?a.jsx("p",{className:"text-center py-8 text-gray-500",children:"No categories found. Run a crawl to populate category data."}):a.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:l.map((g,v)=>a.jsxs("div",{className:"border border-gray-200 rounded-lg p-4 hover:border-orange-300 hover:shadow-md transition-all",children:[a.jsx("p",{className:"font-medium text-gray-900",children:g.type}),g.subcategory&&a.jsx("p",{className:"text-sm text-gray-600",children:g.subcategory}),a.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[a.jsxs("div",{className:"bg-gray-50 rounded p-2 text-center",children:[a.jsx("p",{className:"font-bold text-lg text-orange-600",children:g.product_count}),a.jsx("p",{className:"text-gray-500",children:"products"})]}),a.jsxs("div",{className:"bg-gray-50 rounded p-2 text-center",children:[a.jsx("p",{className:"font-bold text-lg text-blue-600",children:g.brand_count}),a.jsx("p",{className:"text-gray-500",children:"brands"})]})]}),g.avg_thc!=null&&a.jsxs("p",{className:"text-xs text-gray-500 mt-2 text-center",children:["Avg THC: ",g.avg_thc.toFixed(1),"%"]})]},v))})})]})]})]})})}function Ii({title:e,value:t,icon:r,color:n}){const i={blue:"bg-blue-50",green:"bg-green-50",purple:"bg-purple-50",orange:"bg-orange-50",cyan:"bg-cyan-50",red:"bg-red-50"};return a.jsx("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 ${i[n]||"bg-gray-50"} rounded-lg`,children:r}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-gray-600",children:e}),a.jsx("p",{className:"text-xl font-bold text-gray-900",children:t.toLocaleString()})]})]})})}function Go({active:e,onClick:t,icon:r,label:n}){return a.jsxs("button",{onClick:t,className:`flex items-center gap-2 py-4 px-2 text-sm font-medium border-b-2 transition-colors ${e?"border-blue-600 text-blue-600":"border-transparent text-gray-600 hover:text-gray-900"}`,children:[r,n]})}const Zo=[{value:"cannaiq.co",label:"CannaIQ"},{value:"findagram.co",label:"Find a Gram"},{value:"findadispo.com",label:"Find a Dispo"}];function OF(){const{user:e}=Yc(),[t,r]=h.useState([]),[n,i]=h.useState(!0),[s,o]=h.useState(null),[l,c]=h.useState(!1),[d,u]=h.useState(null),[f,p]=h.useState({email:"",password:"",role:"viewer",first_name:"",last_name:"",phone:"",domain:"cannaiq.co"}),[m,x]=h.useState(null),[g,v]=h.useState(!1),[b,j]=h.useState(""),[y,w]=h.useState(""),S=async()=>{try{i(!0);const M=new URLSearchParams;b&&M.set("search",b),y&&M.set("domain",y);const _=await B.getUsers(M.toString());r(_.users),o(null)}catch(M){o(M.message||"Failed to fetch users")}finally{i(!1)}};h.useEffect(()=>{S()},[b,y]);const N=async()=>{if(!f.email||!f.password){x("Email and password are required");return}try{v(!0),x(null),await B.createUser({email:f.email,password:f.password,role:f.role,first_name:f.first_name||void 0,last_name:f.last_name||void 0,phone:f.phone||void 0,domain:f.domain}),c(!1),$(),S()}catch(M){x(M.message||"Failed to create user")}finally{v(!1)}},P=async()=>{if(!d)return;const M={};if(f.email&&f.email!==d.email&&(M.email=f.email),f.password&&(M.password=f.password),f.role&&f.role!==d.role&&(M.role=f.role),f.first_name!==(d.first_name||"")&&(M.first_name=f.first_name||null),f.last_name!==(d.last_name||"")&&(M.last_name=f.last_name||null),f.phone!==(d.phone||"")&&(M.phone=f.phone||null),f.domain!==d.domain&&(M.domain=f.domain),Object.keys(M).length===0){u(null);return}try{v(!0),x(null),await B.updateUser(d.id,M),u(null),$(),S()}catch(_){x(_.message||"Failed to update user")}finally{v(!1)}},C=async M=>{if(confirm(`Are you sure you want to delete ${M.email}?`))try{await B.deleteUser(M.id),S()}catch(_){alert(_.message||"Failed to delete user")}},T=M=>{u(M),p({email:M.email,password:"",role:M.role,first_name:M.first_name||"",last_name:M.last_name||"",phone:M.phone||"",domain:M.domain}),x(null)},$=()=>{p({email:"",password:"",role:"viewer",first_name:"",last_name:"",phone:"",domain:"cannaiq.co"})},I=()=>{c(!1),u(null),$(),x(null)},A=M=>{switch(M){case"superadmin":return"bg-purple-100 text-purple-800";case"admin":return"bg-blue-100 text-blue-800";case"analyst":return"bg-green-100 text-green-800";case"viewer":return"bg-gray-100 text-gray-700";default:return"bg-gray-100 text-gray-700"}},R=M=>{switch(M){case"cannaiq.co":return"bg-indigo-100 text-indigo-800";case"findagram.co":return"bg-emerald-100 text-emerald-800";case"findadispo.com":return"bg-amber-100 text-amber-800";default:return"bg-gray-100 text-gray-700"}},H=M=>!((e==null?void 0:e.id)===M.id||M.role==="superadmin"&&(e==null?void 0:e.role)!=="superadmin");return a.jsxs(X,{children:[a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(uj,{className:"w-8 h-8 text-blue-600"}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"User Management"}),a.jsx("p",{className:"text-sm text-gray-500",children:"Manage system users across all domains"})]})]}),a.jsxs("button",{onClick:()=>{c(!0),x(null)},className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:[a.jsx(Rl,{className:"w-4 h-4"}),"Add User"]})]}),a.jsx("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:a.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[a.jsxs("div",{className:"flex-1 relative",children:[a.jsx(sj,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),a.jsx("input",{type:"text",placeholder:"Search by email or name...",value:b,onChange:M=>j(M.target.value),className:"w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]}),a.jsx("div",{className:"sm:w-48",children:a.jsxs("select",{value:y,onChange:M=>w(M.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",children:[a.jsx("option",{value:"",children:"All Domains"}),Zo.map(M=>a.jsx("option",{value:M.value,children:M.label},M.value))]})})]})}),s&&a.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 flex items-center gap-3",children:[a.jsx(ha,{className:"w-5 h-5 text-red-500"}),a.jsx("p",{className:"text-red-700",children:s})]}),a.jsx("div",{className:"bg-white rounded-lg border border-gray-200 overflow-hidden",children:n?a.jsxs("div",{className:"p-8 text-center",children:[a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto"}),a.jsx("p",{className:"mt-2 text-gray-500",children:"Loading users..."})]}):t.length===0?a.jsx("div",{className:"p-8 text-center text-gray-500",children:"No users found"}):a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[a.jsx("thead",{className:"bg-gray-50",children:a.jsxs("tr",{children:[a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"User"}),a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Domain"}),a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Role"}),a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Contact"}),a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Created"}),a.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Actions"})]})}),a.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:t.map(M=>{var _,D;return a.jsxs("tr",{className:"hover:bg-gray-50",children:[a.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:a.jsxs("div",{className:"flex items-center",children:[a.jsx("div",{className:"flex-shrink-0 h-10 w-10 rounded-full bg-gradient-to-br from-blue-500 to-purple-600 flex items-center justify-center",children:a.jsx("span",{className:"text-sm font-bold text-white",children:(((_=M.first_name)==null?void 0:_[0])||M.email[0]).toUpperCase()})}),a.jsxs("div",{className:"ml-3",children:[a.jsx("p",{className:"text-sm font-medium text-gray-900",children:M.first_name||M.last_name?`${M.first_name||""} ${M.last_name||""}`.trim():M.email.split("@")[0]}),a.jsx("p",{className:"text-xs text-gray-500",children:M.email}),(e==null?void 0:e.id)===M.id&&a.jsx("span",{className:"text-xs text-blue-500",children:"(you)"})]})]})}),a.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:a.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-1 text-xs font-semibold rounded-full ${R(M.domain)}`,children:[a.jsx(hd,{className:"w-3 h-3"}),((D=Zo.find(O=>O.value===M.domain))==null?void 0:D.label)||M.domain]})}),a.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:a.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${A(M.role)}`,children:M.role})}),a.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:a.jsxs("div",{className:"text-sm",children:[M.phone&&a.jsxs("div",{className:"flex items-center gap-1 text-gray-500",children:[a.jsx(Ms,{className:"w-3 h-3"}),a.jsx("span",{children:M.phone})]}),!M.phone&&a.jsx("span",{className:"text-gray-400",children:"-"})]})}),a.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:new Date(M.created_at).toLocaleDateString()}),a.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:H(M)?a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[a.jsx("button",{onClick:()=>T(M),className:"p-1.5 text-gray-400 hover:text-blue-600 hover:bg-blue-50 rounded transition-colors",title:"Edit user",children:a.jsx(aj,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>C(M),className:"p-1.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded transition-colors",title:"Delete user",children:a.jsx(lj,{className:"w-4 h-4"})})]}):a.jsx("span",{className:"text-xs text-gray-400",children:"-"})})]},M.id)})})]})})}),a.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:[a.jsx("h3",{className:"text-sm font-medium text-gray-700 mb-3",children:"Domains"}),a.jsx("div",{className:"flex flex-wrap gap-4",children:Zo.map(M=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-1 text-xs font-semibold rounded-full ${R(M.value)}`,children:[a.jsx(hd,{className:"w-3 h-3"}),M.label]}),a.jsx("span",{className:"text-xs text-gray-500",children:M.value})]},M.value))})]})]}),(l||d)&&a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-white rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200",children:[a.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:d?"Edit User":"Create New User"}),a.jsx("button",{onClick:I,className:"p-1 text-gray-400 hover:text-gray-600 rounded",children:a.jsx(Mh,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"px-6 py-4 space-y-4",children:[m&&a.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-3 flex items-center gap-2",children:[a.jsx(ha,{className:"w-4 h-4 text-red-500"}),a.jsx("p",{className:"text-sm text-red-700",children:m})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"First Name"}),a.jsx("input",{type:"text",value:f.first_name,onChange:M=>p({...f,first_name:M.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"John"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Last Name"}),a.jsx("input",{type:"text",value:f.last_name,onChange:M=>p({...f,last_name:M.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"Doe"})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[a.jsx(Th,{className:"w-4 h-4 inline mr-1"}),"Email"]}),a.jsx("input",{type:"email",value:f.email,onChange:M=>p({...f,email:M.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"user@example.com"})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["Password ",d&&a.jsx("span",{className:"text-gray-400 font-normal",children:"(leave blank to keep current)"})]}),a.jsx("input",{type:"password",value:f.password,onChange:M=>p({...f,password:M.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:d?"********":"Enter password"})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[a.jsx(Ms,{className:"w-4 h-4 inline mr-1"}),"Phone"]}),a.jsx("input",{type:"tel",value:f.phone,onChange:M=>p({...f,phone:M.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"+1 555 123 4567"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[a.jsx(hd,{className:"w-4 h-4 inline mr-1"}),"Domain"]}),a.jsx("select",{value:f.domain,onChange:M=>p({...f,domain:M.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",children:Zo.map(M=>a.jsx("option",{value:M.value,children:M.label},M.value))})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Role"}),a.jsxs("select",{value:f.role,onChange:M=>p({...f,role:M.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",children:[a.jsx("option",{value:"viewer",children:"Viewer"}),a.jsx("option",{value:"analyst",children:"Analyst"}),a.jsx("option",{value:"admin",children:"Admin"}),(e==null?void 0:e.role)==="superadmin"&&a.jsx("option",{value:"superadmin",children:"Superadmin"})]})]})]})]}),a.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-gray-200 bg-gray-50",children:[a.jsx("button",{onClick:I,className:"px-4 py-2 text-gray-700 hover:bg-gray-100 rounded-lg transition-colors",disabled:g,children:"Cancel"}),a.jsx("button",{onClick:d?P:N,disabled:g,className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50",children:g?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Saving..."]}):a.jsxs(a.Fragment,{children:[a.jsx(QA,{className:"w-4 h-4"}),d?"Update":"Create"]})})]})]})})]})}function EF(){return a.jsxs("div",{className:"min-h-screen bg-base-200",children:[a.jsx("div",{className:"hero min-h-[70vh] bg-gradient-to-br from-primary to-secondary",children:a.jsx("div",{className:"hero-content text-center text-neutral-content",children:a.jsxs("div",{className:"max-w-2xl",children:[a.jsx("h1",{className:"mb-5 text-5xl font-bold text-white",children:"Cannabrands Intelligence"}),a.jsx("p",{className:"mb-8 text-xl text-white/90",children:"Real-time cannabis menu data for dispensaries. Track products, prices, and availability across your favorite stores with our powerful API."}),a.jsxs("div",{className:"flex gap-4 justify-center flex-wrap",children:[a.jsx(zl,{to:"/login",className:"btn btn-lg bg-white text-primary hover:bg-gray-100",children:"Sign In"}),a.jsx("a",{href:"/downloads/cb-wpmenu-1.5.1.zip",className:"btn btn-lg btn-outline text-white border-white hover:bg-white hover:text-primary",children:"Download WordPress Plugin"})]})]})})}),a.jsx("div",{className:"py-20 px-4",children:a.jsxs("div",{className:"max-w-6xl mx-auto",children:[a.jsx("h2",{className:"text-3xl font-bold text-center mb-12",children:"Why Choose Cannabrands Intelligence?"}),a.jsxs("div",{className:"grid md:grid-cols-3 gap-8",children:[a.jsx("div",{className:"card bg-base-100 shadow-xl",children:a.jsxs("div",{className:"card-body items-center text-center",children:[a.jsx("div",{className:"text-4xl mb-4",children:"📊"}),a.jsx("h3",{className:"card-title",children:"Real-Time Data"}),a.jsx("p",{children:"Get up-to-date product information, prices, and stock levels directly from dispensary menus."})]})}),a.jsx("div",{className:"card bg-base-100 shadow-xl",children:a.jsxs("div",{className:"card-body items-center text-center",children:[a.jsx("div",{className:"text-4xl mb-4",children:"🔌"}),a.jsx("h3",{className:"card-title",children:"Easy Integration"}),a.jsx("p",{children:"Simple REST API and WordPress plugin make it easy to display menus on your website."})]})}),a.jsx("div",{className:"card bg-base-100 shadow-xl",children:a.jsxs("div",{className:"card-body items-center text-center",children:[a.jsx("div",{className:"text-4xl mb-4",children:"📈"}),a.jsx("h3",{className:"card-title",children:"Analytics Ready"}),a.jsx("p",{children:"Track price changes, brand performance, and market trends with historical data."})]})})]})]})}),a.jsx("div",{className:"py-20 px-4 bg-base-100",children:a.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[a.jsx("h2",{className:"text-3xl font-bold mb-6",children:"WordPress Integration"}),a.jsx("p",{className:"text-lg mb-8",children:"Display your dispensary menu directly on your WordPress site with our free plugin. Features Elementor widgets and shortcode support for maximum flexibility."}),a.jsxs("div",{className:"mockup-code text-left mb-8",children:[a.jsx("pre",{"data-prefix":"1",children:a.jsx("code",{children:'[cb_products limit="12" columns="3"]'})}),a.jsx("pre",{"data-prefix":"2",children:a.jsx("code",{children:'[cb_product id="123"]'})})]}),a.jsx("a",{href:"/downloads/cb-wpmenu-1.5.1.zip",className:"btn btn-primary btn-lg",children:"Download Plugin v1.5.1"})]})}),a.jsx("div",{className:"py-20 px-4 bg-gradient-to-r from-primary to-secondary",children:a.jsxs("div",{className:"max-w-2xl mx-auto text-center text-white",children:[a.jsx("h2",{className:"text-3xl font-bold mb-6",children:"Ready to Get Started?"}),a.jsx("p",{className:"text-lg mb-8",children:"Contact us to get your API key and start integrating cannabis menu data into your applications."}),a.jsx(zl,{to:"/login",className:"btn btn-lg bg-white text-primary hover:bg-gray-100",children:"Access Dashboard"})]})}),a.jsx("footer",{className:"footer footer-center p-10 bg-base-300 text-base-content",children:a.jsxs("div",{children:[a.jsx("p",{className:"font-bold",children:"Cannabrands Intelligence"}),a.jsxs("p",{children:["Powered by ",a.jsx("a",{href:"https://creationshop.io",target:"_blank",rel:"noopener noreferrer",className:"link link-primary",children:"Creationshop"})]})]})})]})}function ge({children:e}){const{isAuthenticated:t,checkAuth:r}=Yc();return h.useEffect(()=>{r()},[]),t?a.jsx(a.Fragment,{children:e}):a.jsx(Z1,{to:"/login",replace:!0})}function DF(){return a.jsx(aA,{children:a.jsxs(XC,{children:[a.jsx(oe,{path:"/login",element:a.jsx(zA,{})}),a.jsx(oe,{path:"/",element:a.jsx(EF,{})}),a.jsx(oe,{path:"/dashboard",element:a.jsx(ge,{children:a.jsx(rF,{})})}),a.jsx(oe,{path:"/products",element:a.jsx(ge,{children:a.jsx(nF,{})})}),a.jsx(oe,{path:"/products/:id",element:a.jsx(ge,{children:a.jsx(aF,{})})}),a.jsx(oe,{path:"/stores",element:a.jsx(ge,{children:a.jsx(sF,{})})}),a.jsx(oe,{path:"/dispensaries",element:a.jsx(ge,{children:a.jsx(oF,{})})}),a.jsx(oe,{path:"/dispensaries/:state/:city/:slug",element:a.jsx(ge,{children:a.jsx(lF,{})})}),a.jsx(oe,{path:"/stores/:state/:storeName/:slug/brands",element:a.jsx(ge,{children:a.jsx(uF,{})})}),a.jsx(oe,{path:"/stores/:state/:storeName/:slug/specials",element:a.jsx(ge,{children:a.jsx(dF,{})})}),a.jsx(oe,{path:"/stores/:state/:storeName/:slug",element:a.jsx(ge,{children:a.jsx(cF,{})})}),a.jsx(oe,{path:"/categories",element:a.jsx(ge,{children:a.jsx(fF,{})})}),a.jsx(oe,{path:"/campaigns",element:a.jsx(ge,{children:a.jsx(pF,{})})}),a.jsx(oe,{path:"/analytics",element:a.jsx(ge,{children:a.jsx(mF,{})})}),a.jsx(oe,{path:"/settings",element:a.jsx(ge,{children:a.jsx(gF,{})})}),a.jsx(oe,{path:"/changes",element:a.jsx(ge,{children:a.jsx(NF,{})})}),a.jsx(oe,{path:"/proxies",element:a.jsx(ge,{children:a.jsx(yF,{})})}),a.jsx(oe,{path:"/logs",element:a.jsx(ge,{children:a.jsx(bF,{})})}),a.jsx(oe,{path:"/scraper-tools",element:a.jsx(ge,{children:a.jsx(SF,{})})}),a.jsx(oe,{path:"/scraper-monitor",element:a.jsx(ge,{children:a.jsx(jF,{})})}),a.jsx(oe,{path:"/scraper-schedule",element:a.jsx(ge,{children:a.jsx(wF,{})})}),a.jsx(oe,{path:"/az-schedule",element:a.jsx(ge,{children:a.jsx(_F,{})})}),a.jsx(oe,{path:"/az",element:a.jsx(ge,{children:a.jsx(PF,{})})}),a.jsx(oe,{path:"/az/stores/:id",element:a.jsx(ge,{children:a.jsx(CF,{})})}),a.jsx(oe,{path:"/api-permissions",element:a.jsx(ge,{children:a.jsx(kF,{})})}),a.jsx(oe,{path:"/wholesale-analytics",element:a.jsx(ge,{children:a.jsx(AF,{})})}),a.jsx(oe,{path:"/users",element:a.jsx(ge,{children:a.jsx(OF,{})})}),a.jsx(oe,{path:"*",element:a.jsx(Z1,{to:"/dashboard",replace:!0})})]})})}$d.createRoot(document.getElementById("root")).render(a.jsx(hs.StrictMode,{children:a.jsx(DF,{})}));