var wO=e=>{throw TypeError(e)};var Ly=(e,t,r)=>t.has(e)||wO("Cannot "+r);var B=(e,t,r)=>(Ly(e,t,"read from private field"),r?r.call(e):t.get(e)),we=(e,t,r)=>t.has(e)?wO("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),fe=(e,t,r,n)=>(Ly(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),$e=(e,t,r)=>(Ly(e,t,"access private method"),r);var Rh=(e,t,r,n)=>({set _(a){fe(e,t,a,r)},get _(){return B(e,t,n)}});function oB(e,t){for(var r=0;rn[a]})}}}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 a of document.querySelectorAll('link[rel="modulepreload"]'))n(a);new MutationObserver(a=>{for(const s of a)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(a){const s={};return a.integrity&&(s.integrity=a.integrity),a.referrerPolicy&&(s.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?s.credentials="include":a.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(a){if(a.ep)return;a.ep=!0;const s=r(a);fetch(a.href,s)}})();var $h=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function et(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Gk={exports:{}},Gv={},Kk={exports:{}},ze={};/** * @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 Hf=Symbol.for("react.element"),lB=Symbol.for("react.portal"),cB=Symbol.for("react.fragment"),uB=Symbol.for("react.strict_mode"),dB=Symbol.for("react.profiler"),fB=Symbol.for("react.provider"),hB=Symbol.for("react.context"),pB=Symbol.for("react.forward_ref"),mB=Symbol.for("react.suspense"),vB=Symbol.for("react.memo"),gB=Symbol.for("react.lazy"),NO=Symbol.iterator;function yB(e){return e===null||typeof e!="object"?null:(e=NO&&e[NO]||e["@@iterator"],typeof e=="function"?e:null)}var Yk={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Qk=Object.assign,Xk={};function eu(e,t,r){this.props=e,this.context=t,this.refs=Xk,this.updater=r||Yk}eu.prototype.isReactComponent={};eu.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")};eu.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Zk(){}Zk.prototype=eu.prototype;function Bw(e,t,r){this.props=e,this.context=t,this.refs=Xk,this.updater=r||Yk}var Uw=Bw.prototype=new Zk;Uw.constructor=Bw;Qk(Uw,eu.prototype);Uw.isPureReactComponent=!0;var SO=Array.isArray,Jk=Object.prototype.hasOwnProperty,zw={current:null},e_={key:!0,ref:!0,__self:!0,__source:!0};function t_(e,t,r){var n,a={},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)Jk.call(t,n)&&!e_.hasOwnProperty(n)&&(a[n]=t[n]);var l=arguments.length-2;if(l===1)a.children=r;else if(1>>1,K=E[G];if(0>>1;Ga(le,V))dea(ie,le)?(E[G]=ie,E[de]=V,G=de):(E[G]=le,E[ne]=V,G=ne);else if(dea(ie,V))E[G]=ie,E[de]=V,G=de;else break e}}return F}function a(E,F){var V=E.sortIndex-F.sortIndex;return V!==0?V:E.id-F.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=[],u=[],f=1,d=null,h=3,p=!1,y=!1,v=!1,m=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function b(E){for(var F=r(u);F!==null;){if(F.callback===null)n(u);else if(F.startTime<=E)n(u),F.sortIndex=F.expirationTime,t(c,F);else break;F=r(u)}}function N(E){if(v=!1,b(E),!y)if(r(c)!==null)y=!0,$(w);else{var F=r(u);F!==null&&I(N,F.startTime-E)}}function w(E,F){y=!1,v&&(v=!1,x(P),P=-1),p=!0;var V=h;try{for(b(F),d=r(c);d!==null&&(!(d.expirationTime>F)||E&&!T());){var G=d.callback;if(typeof G=="function"){d.callback=null,h=d.priorityLevel;var K=G(d.expirationTime<=F);F=e.unstable_now(),typeof K=="function"?d.callback=K:d===r(c)&&n(c),b(F)}else n(c);d=r(c)}if(d!==null)var q=!0;else{var ne=r(u);ne!==null&&I(N,ne.startTime-F),q=!1}return q}finally{d=null,h=V,p=!1}}var S=!1,O=null,P=-1,A=5,C=-1;function T(){return!(e.unstable_now()-CE||125G?(E.sortIndex=V,t(u,E),r(c)===null&&E===r(u)&&(v?(x(P),P=-1):v=!0,I(N,V-G))):(E.sortIndex=K,t(c,E),y||p||(y=!0,$(w))),E},e.unstable_shouldYield=T,e.unstable_wrapCallback=function(E){var F=h;return function(){var V=h;h=F;try{return E.apply(this,arguments)}finally{h=V}}}})(s_);i_.exports=s_;var EB=i_.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 TB=j,yn=EB;function ae(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"),k0=Object.prototype.hasOwnProperty,kB=/^[: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]*$/,PO={},AO={};function _B(e){return k0.call(AO,e)?!0:k0.call(PO,e)?!1:kB.test(e)?AO[e]=!0:(PO[e]=!0,!1)}function DB(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 MB(e,t,r,n){if(t===null||typeof t>"u"||DB(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 Rr(e,t,r,n,a,s,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=n,this.attributeNamespace=a,this.mustUseProperty=r,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=o}var mr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){mr[e]=new Rr(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];mr[t]=new Rr(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){mr[e]=new Rr(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){mr[e]=new Rr(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){mr[e]=new Rr(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){mr[e]=new Rr(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){mr[e]=new Rr(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){mr[e]=new Rr(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){mr[e]=new Rr(e,5,!1,e.toLowerCase(),null,!1,!1)});var Vw=/[\-:]([a-z])/g;function qw(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(Vw,qw);mr[t]=new Rr(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(Vw,qw);mr[t]=new Rr(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(Vw,qw);mr[t]=new Rr(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){mr[e]=new Rr(e,1,!1,e.toLowerCase(),null,!1,!1)});mr.xlinkHref=new Rr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){mr[e]=new Rr(e,1,!1,e.toLowerCase(),null,!0,!0)});function Gw(e,t,r,n){var a=mr.hasOwnProperty(t)?mr[t]:null;(a!==null?a.type!==0:n||!(2l||a[o]!==s[l]){var c=` `+a[o].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=o&&0<=l);break}}}finally{Uy=!1,Error.prepareStackTrace=r}return(e=e?e.displayName||e.name:"")?rd(e):""}function IB(e){switch(e.tag){case 5:return rd(e.type);case 16:return rd("Lazy");case 13:return rd("Suspense");case 19:return rd("SuspenseList");case 0:case 2:case 15:return e=zy(e.type,!1),e;case 11:return e=zy(e.type.render,!1),e;case 1:return e=zy(e.type,!0),e;default:return""}}function I0(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 ml:return"Fragment";case pl:return"Portal";case _0:return"Profiler";case Kw:return"StrictMode";case D0:return"Suspense";case M0:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case c_:return(e.displayName||"Context")+".Consumer";case l_:return(e._context.displayName||"Context")+".Provider";case Yw:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Qw:return t=e.displayName||null,t!==null?t:I0(e.type)||"Memo";case Hi:t=e._payload,e=e._init;try{return I0(e(t))}catch{}}return null}function RB(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 I0(t);case 8:return t===Kw?"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 ws(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function d_(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function $B(e){var t=d_(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 a=r.get,s=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.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 Bh(e){e._valueTracker||(e._valueTracker=$B(e))}function f_(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var r=t.getValue(),n="";return e&&(n=d_(e)?e.checked?"true":"false":e.value),e=n,e!==r?(t.setValue(e),!0):!1}function Zp(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 R0(e,t){var r=t.checked;return Tt({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??e._wrapperState.initialChecked})}function EO(e,t){var r=t.defaultValue==null?"":t.defaultValue,n=t.checked!=null?t.checked:t.defaultChecked;r=ws(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 h_(e,t){t=t.checked,t!=null&&Gw(e,"checked",t,!1)}function $0(e,t){h_(e,t);var r=ws(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")?L0(e,t.type,r):t.hasOwnProperty("defaultValue")&&L0(e,t.type,ws(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function TO(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 L0(e,t,r){(t!=="number"||Zp(e.ownerDocument)!==e)&&(r==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+r&&(e.defaultValue=""+r))}var nd=Array.isArray;function Dl(e,t,r,n){if(e=e.options,t){t={};for(var a=0;a"+t.valueOf().toString()+"",t=Uh.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function kd(e,t){if(t){var r=e.firstChild;if(r&&r===e.lastChild&&r.nodeType===3){r.nodeValue=t;return}}e.textContent=t}var dd={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},LB=["Webkit","ms","Moz","O"];Object.keys(dd).forEach(function(e){LB.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),dd[t]=dd[e]})});function g_(e,t,r){return t==null||typeof t=="boolean"||t===""?"":r||typeof t!="number"||t===0||dd.hasOwnProperty(e)&&dd[e]?(""+t).trim():t+"px"}function y_(e,t){e=e.style;for(var r in t)if(t.hasOwnProperty(r)){var n=r.indexOf("--")===0,a=g_(r,t[r],n);r==="float"&&(r="cssFloat"),n?e.setProperty(r,a):e[r]=a}}var FB=Tt({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 U0(e,t){if(t){if(FB[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(ae(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(ae(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(ae(61))}if(t.style!=null&&typeof t.style!="object")throw Error(ae(62))}}function z0(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 W0=null;function Xw(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var H0=null,Ml=null,Il=null;function DO(e){if(e=Gf(e)){if(typeof H0!="function")throw Error(ae(280));var t=e.stateNode;t&&(t=Zv(t),H0(e.stateNode,e.type,t))}}function x_(e){Ml?Il?Il.push(e):Il=[e]:Ml=e}function b_(){if(Ml){var e=Ml,t=Il;if(Il=Ml=null,DO(e),t)for(e=0;e>>=0,e===0?32:31-(QB(e)/XB|0)|0}var zh=64,Wh=4194304;function ad(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 rm(e,t){var r=e.pendingLanes;if(r===0)return 0;var n=0,a=e.suspendedLanes,s=e.pingedLanes,o=r&268435455;if(o!==0){var l=o&~a;l!==0?n=ad(l):(s&=o,s!==0&&(n=ad(s)))}else o=r&~a,o!==0?n=ad(o):s!==0&&(n=ad(s));if(n===0)return 0;if(t!==0&&t!==n&&!(t&a)&&(a=n&-n,s=t&-t,a>=s||a===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 Vf(e,t,r){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-da(t),e[t]=r}function t8(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=hd),zO=" ",WO=!1;function B_(e,t){switch(e){case"keyup":return E8.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function U_(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var vl=!1;function k8(e,t){switch(e){case"compositionend":return U_(t);case"keypress":return t.which!==32?null:(WO=!0,zO);case"textInput":return e=t.data,e===zO&&WO?null:e;default:return null}}function _8(e,t){if(vl)return e==="compositionend"||!i1&&B_(e,t)?(e=L_(),Dp=r1=is=null,vl=!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=GO(r)}}function V_(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?V_(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function q_(){for(var e=window,t=Zp();t instanceof e.HTMLIFrameElement;){try{var r=typeof t.contentWindow.location.href=="string"}catch{r=!1}if(r)e=t.contentWindow;else break;t=Zp(e.document)}return t}function s1(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 U8(e){var t=q_(),r=e.focusedElem,n=e.selectionRange;if(t!==r&&r&&r.ownerDocument&&V_(r.ownerDocument.documentElement,r)){if(n!==null&&s1(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 a=r.textContent.length,s=Math.min(n.start,a);n=n.end===void 0?s:Math.min(n.end,a),!e.extend&&s>n&&(a=n,n=s,s=a),a=KO(r,s);var o=KO(r,n);a&&o&&(e.rangeCount!==1||e.anchorNode!==a.node||e.anchorOffset!==a.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(a.node,a.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,gl=null,Q0=null,md=null,X0=!1;function YO(e,t,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;X0||gl==null||gl!==Zp(n)||(n=gl,"selectionStart"in n&&s1(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}),md&&$d(md,n)||(md=n,n=im(Q0,"onSelect"),0bl||(e.current=nb[bl],nb[bl]=null,bl--)}function vt(e,t){bl++,nb[bl]=e.current,e.current=t}var Ns={},Nr=Ms(Ns),Kr=Ms(!1),Co=Ns;function hc(e,t){var r=e.type.contextTypes;if(!r)return Ns;var n=e.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===t)return n.__reactInternalMemoizedMaskedChildContext;var a={},s;for(s in r)a[s]=t[s];return n&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=a),a}function Yr(e){return e=e.childContextTypes,e!=null}function om(){Nt(Kr),Nt(Nr)}function rP(e,t,r){if(Nr.current!==Ns)throw Error(ae(168));vt(Nr,t),vt(Kr,r)}function tD(e,t,r){var n=e.stateNode;if(t=t.childContextTypes,typeof n.getChildContext!="function")return r;n=n.getChildContext();for(var a in n)if(!(a in t))throw Error(ae(108,RB(e)||"Unknown",a));return Tt({},r,n)}function lm(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ns,Co=Nr.current,vt(Nr,e),vt(Kr,Kr.current),!0}function nP(e,t,r){var n=e.stateNode;if(!n)throw Error(ae(169));r?(e=tD(e,t,Co),n.__reactInternalMemoizedMergedChildContext=e,Nt(Kr),Nt(Nr),vt(Nr,e)):Nt(Kr),vt(Kr,r)}var li=null,Jv=!1,rx=!1;function rD(e){li===null?li=[e]:li.push(e)}function J8(e){Jv=!0,rD(e)}function Is(){if(!rx&&li!==null){rx=!0;var e=0,t=it;try{var r=li;for(it=1;e>=o,a-=o,ui=1<<32-da(t)+a|r<P?(A=O,O=null):A=O.sibling;var C=h(x,O,b[P],N);if(C===null){O===null&&(O=A);break}e&&O&&C.alternate===null&&t(x,O),g=s(C,g,P),S===null?w=C:S.sibling=C,S=C,O=A}if(P===b.length)return r(x,O),St&&Xs(x,P),w;if(O===null){for(;PP?(A=O,O=null):A=O.sibling;var T=h(x,O,C.value,N);if(T===null){O===null&&(O=A);break}e&&O&&T.alternate===null&&t(x,O),g=s(T,g,P),S===null?w=T:S.sibling=T,S=T,O=A}if(C.done)return r(x,O),St&&Xs(x,P),w;if(O===null){for(;!C.done;P++,C=b.next())C=d(x,C.value,N),C!==null&&(g=s(C,g,P),S===null?w=C:S.sibling=C,S=C);return St&&Xs(x,P),w}for(O=n(x,O);!C.done;P++,C=b.next())C=p(O,x,P,C.value,N),C!==null&&(e&&C.alternate!==null&&O.delete(C.key===null?P:C.key),g=s(C,g,P),S===null?w=C:S.sibling=C,S=C);return e&&O.forEach(function(D){return t(x,D)}),St&&Xs(x,P),w}function m(x,g,b,N){if(typeof b=="object"&&b!==null&&b.type===ml&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case Fh:e:{for(var w=b.key,S=g;S!==null;){if(S.key===w){if(w=b.type,w===ml){if(S.tag===7){r(x,S.sibling),g=a(S,b.props.children),g.return=x,x=g;break e}}else if(S.elementType===w||typeof w=="object"&&w!==null&&w.$$typeof===Hi&&sP(w)===S.type){r(x,S.sibling),g=a(S,b.props),g.ref=Mu(x,S,b),g.return=x,x=g;break e}r(x,S);break}else t(x,S);S=S.sibling}b.type===ml?(g=wo(b.props.children,x.mode,N,b.key),g.return=x,x=g):(N=Up(b.type,b.key,b.props,null,x.mode,N),N.ref=Mu(x,g,b),N.return=x,x=N)}return o(x);case pl:e:{for(S=b.key;g!==null;){if(g.key===S)if(g.tag===4&&g.stateNode.containerInfo===b.containerInfo&&g.stateNode.implementation===b.implementation){r(x,g.sibling),g=a(g,b.children||[]),g.return=x,x=g;break e}else{r(x,g);break}else t(x,g);g=g.sibling}g=ux(b,x.mode,N),g.return=x,x=g}return o(x);case Hi:return S=b._init,m(x,g,S(b._payload),N)}if(nd(b))return y(x,g,b,N);if(Eu(b))return v(x,g,b,N);Qh(x,b)}return typeof b=="string"&&b!==""||typeof b=="number"?(b=""+b,g!==null&&g.tag===6?(r(x,g.sibling),g=a(g,b),g.return=x,x=g):(r(x,g),g=cx(b,x.mode,N),g.return=x,x=g),o(x)):r(x,g)}return m}var mc=sD(!0),oD=sD(!1),dm=Ms(null),fm=null,Nl=null,u1=null;function d1(){u1=Nl=fm=null}function f1(e){var t=dm.current;Nt(dm),e._currentValue=t}function sb(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 $l(e,t){fm=e,u1=Nl=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Vr=!0),e.firstContext=null)}function Un(e){var t=e._currentValue;if(u1!==e)if(e={context:e,memoizedValue:t,next:null},Nl===null){if(fm===null)throw Error(ae(308));Nl=e,fm.dependencies={lanes:0,firstContext:e}}else Nl=Nl.next=e;return t}var so=null;function h1(e){so===null?so=[e]:so.push(e)}function lD(e,t,r,n){var a=t.interleaved;return a===null?(r.next=r,h1(t)):(r.next=a.next,a.next=r),t.interleaved=r,Ni(e,n)}function Ni(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 Vi=!1;function p1(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function cD(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 vi(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function hs(e,t,r){var n=e.updateQueue;if(n===null)return null;if(n=n.shared,Ke&2){var a=n.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),n.pending=t,Ni(e,r)}return a=n.interleaved,a===null?(t.next=t,h1(n)):(t.next=a.next,a.next=t),n.interleaved=t,Ni(e,r)}function Ip(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,Jw(e,r)}}function oP(e,t){var r=e.updateQueue,n=e.alternate;if(n!==null&&(n=n.updateQueue,r===n)){var a=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?a=s=o:s=s.next=o,r=r.next}while(r!==null);s===null?a=s=t:s=s.next=t}else a=s=t;r={baseState:n.baseState,firstBaseUpdate:a,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 hm(e,t,r,n){var a=e.updateQueue;Vi=!1;var s=a.firstBaseUpdate,o=a.lastBaseUpdate,l=a.shared.pending;if(l!==null){a.shared.pending=null;var c=l,u=c.next;c.next=null,o===null?s=u:o.next=u,o=c;var f=e.alternate;f!==null&&(f=f.updateQueue,l=f.lastBaseUpdate,l!==o&&(l===null?f.firstBaseUpdate=u:l.next=u,f.lastBaseUpdate=c))}if(s!==null){var d=a.baseState;o=0,f=u=c=null,l=s;do{var h=l.lane,p=l.eventTime;if((n&h)===h){f!==null&&(f=f.next={eventTime:p,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var y=e,v=l;switch(h=t,p=r,v.tag){case 1:if(y=v.payload,typeof y=="function"){d=y.call(p,d,h);break e}d=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=v.payload,h=typeof y=="function"?y.call(p,d,h):y,h==null)break e;d=Tt({},d,h);break e;case 2:Vi=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,h=a.effects,h===null?a.effects=[l]:h.push(l))}else p={eventTime:p,lane:h,tag:l.tag,payload:l.payload,callback:l.callback,next:null},f===null?(u=f=p,c=d):f=f.next=p,o|=h;if(l=l.next,l===null){if(l=a.shared.pending,l===null)break;h=l,l=h.next,h.next=null,a.lastBaseUpdate=h,a.shared.pending=null}}while(!0);if(f===null&&(c=d),a.baseState=c,a.firstBaseUpdate=u,a.lastBaseUpdate=f,t=a.shared.interleaved,t!==null){a=t;do o|=a.lane,a=a.next;while(a!==t)}else s===null&&(a.shared.lanes=0);ko|=o,e.lanes=o,e.memoizedState=d}}function lP(e,t,r){if(e=t.effects,t.effects=null,e!==null)for(t=0;tr?r:4,e(!0);var n=ax.transition;ax.transition={};try{e(!1),t()}finally{it=r,ax.transition=n}}function PD(){return zn().memoizedState}function nU(e,t,r){var n=ms(e);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},AD(e))CD(t,r);else if(r=lD(e,t,r,n),r!==null){var a=_r();fa(r,e,n,a),ED(r,t,n)}}function aU(e,t,r){var n=ms(e),a={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(AD(e))CD(t,a);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(a.hasEagerState=!0,a.eagerState=l,va(l,o)){var c=t.interleaved;c===null?(a.next=a,h1(t)):(a.next=c.next,c.next=a),t.interleaved=a;return}}catch{}finally{}r=lD(e,t,a,n),r!==null&&(a=_r(),fa(r,e,n,a),ED(r,t,n))}}function AD(e){var t=e.alternate;return e===Ct||t!==null&&t===Ct}function CD(e,t){vd=mm=!0;var r=e.pending;r===null?t.next=t:(t.next=r.next,r.next=t),e.pending=t}function ED(e,t,r){if(r&4194240){var n=t.lanes;n&=e.pendingLanes,r|=n,t.lanes=r,Jw(e,r)}}var vm={readContext:Un,useCallback:vr,useContext:vr,useEffect:vr,useImperativeHandle:vr,useInsertionEffect:vr,useLayoutEffect:vr,useMemo:vr,useReducer:vr,useRef:vr,useState:vr,useDebugValue:vr,useDeferredValue:vr,useTransition:vr,useMutableSource:vr,useSyncExternalStore:vr,useId:vr,unstable_isNewReconciler:!1},iU={readContext:Un,useCallback:function(e,t){return Ea().memoizedState=[e,t===void 0?null:t],e},useContext:Un,useEffect:uP,useImperativeHandle:function(e,t,r){return r=r!=null?r.concat([e]):null,$p(4194308,4,jD.bind(null,t,e),r)},useLayoutEffect:function(e,t){return $p(4194308,4,e,t)},useInsertionEffect:function(e,t){return $p(4,2,e,t)},useMemo:function(e,t){var r=Ea();return t=t===void 0?null:t,e=e(),r.memoizedState=[e,t],e},useReducer:function(e,t,r){var n=Ea();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=nU.bind(null,Ct,e),[n.memoizedState,e]},useRef:function(e){var t=Ea();return e={current:e},t.memoizedState=e},useState:cP,useDebugValue:w1,useDeferredValue:function(e){return Ea().memoizedState=e},useTransition:function(){var e=cP(!1),t=e[0];return e=rU.bind(null,e[1]),Ea().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,r){var n=Ct,a=Ea();if(St){if(r===void 0)throw Error(ae(407));r=r()}else{if(r=t(),ir===null)throw Error(ae(349));To&30||hD(n,t,r)}a.memoizedState=r;var s={value:r,getSnapshot:t};return a.queue=s,uP(mD.bind(null,n,s,e),[e]),n.flags|=2048,Vd(9,pD.bind(null,n,s,r,t),void 0,null),r},useId:function(){var e=Ea(),t=ir.identifierPrefix;if(St){var r=di,n=ui;r=(n&~(1<<32-da(n)-1)).toString(32)+r,t=":"+t+"R"+r,r=Wd++,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[Ma]=t,e[Bd]=n,FD(e,t,!1,!1),t.stateNode=e;e:{switch(o=z0(r,n),r){case"dialog":bt("cancel",e),bt("close",e),a=n;break;case"iframe":case"object":case"embed":bt("load",e),a=n;break;case"video":case"audio":for(a=0;ayc&&(t.flags|=128,n=!0,Iu(s,!1),t.lanes=4194304)}else{if(!n)if(e=pm(o),e!==null){if(t.flags|=128,n=!0,r=e.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),Iu(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!St)return gr(t),null}else 2*Mt()-s.renderingStartTime>yc&&r!==1073741824&&(t.flags|=128,n=!0,Iu(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=Mt(),t.sibling=null,r=At.current,vt(At,n?r&1|2:r&1),t):(gr(t),null);case 22:case 23:return C1(),n=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==n&&(t.flags|=8192),n&&t.mode&1?an&1073741824&&(gr(t),t.subtreeFlags&6&&(t.flags|=8192)):gr(t),null;case 24:return null;case 25:return null}throw Error(ae(156,t.tag))}function hU(e,t){switch(l1(t),t.tag){case 1:return Yr(t.type)&&om(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return vc(),Nt(Kr),Nt(Nr),g1(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return v1(t),null;case 13:if(Nt(At),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(ae(340));pc()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Nt(At),null;case 4:return vc(),null;case 10:return f1(t.type._context),null;case 22:case 23:return C1(),null;case 24:return null;default:return null}}var Zh=!1,br=!1,pU=typeof WeakSet=="function"?WeakSet:Set,pe=null;function Sl(e,t){var r=e.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){_t(e,t,n)}else r.current=null}function mb(e,t,r){try{r()}catch(n){_t(e,t,n)}}var jP=!1;function mU(e,t){if(Z0=nm,e=q_(),s1(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 a=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,u=0,f=0,d=e,h=null;t:for(;;){for(var p;d!==r||a!==0&&d.nodeType!==3||(l=o+a),d!==s||n!==0&&d.nodeType!==3||(c=o+n),d.nodeType===3&&(o+=d.nodeValue.length),(p=d.firstChild)!==null;)h=d,d=p;for(;;){if(d===e)break t;if(h===r&&++u===a&&(l=o),h===s&&++f===n&&(c=o),(p=d.nextSibling)!==null)break;d=h,h=d.parentNode}d=p}r=l===-1||c===-1?null:{start:l,end:c}}else r=null}r=r||{start:0,end:0}}else r=null;for(J0={focusedElem:e,selectionRange:r},nm=!1,pe=t;pe!==null;)if(t=pe,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,pe=e;else for(;pe!==null;){t=pe;try{var y=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var v=y.memoizedProps,m=y.memoizedState,x=t.stateNode,g=x.getSnapshotBeforeUpdate(t.elementType===t.type?v:Jn(t.type,v),m);x.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var b=t.stateNode.containerInfo;b.nodeType===1?b.textContent="":b.nodeType===9&&b.documentElement&&b.removeChild(b.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(ae(163))}}catch(N){_t(t,t.return,N)}if(e=t.sibling,e!==null){e.return=t.return,pe=e;break}pe=t.return}return y=jP,jP=!1,y}function gd(e,t,r){var n=t.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var a=n=n.next;do{if((a.tag&e)===e){var s=a.destroy;a.destroy=void 0,s!==void 0&&mb(t,r,s)}a=a.next}while(a!==n)}}function rg(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 vb(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 zD(e){var t=e.alternate;t!==null&&(e.alternate=null,zD(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ma],delete t[Bd],delete t[rb],delete t[X8],delete t[Z8])),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 WD(e){return e.tag===5||e.tag===3||e.tag===4}function wP(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||WD(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 gb(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=sm));else if(n!==4&&(e=e.child,e!==null))for(gb(e,t,r),e=e.sibling;e!==null;)gb(e,t,r),e=e.sibling}function yb(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(yb(e,t,r),e=e.sibling;e!==null;)yb(e,t,r),e=e.sibling}var fr=null,ta=!1;function $i(e,t,r){for(r=r.child;r!==null;)HD(e,t,r),r=r.sibling}function HD(e,t,r){if(Ba&&typeof Ba.onCommitFiberUnmount=="function")try{Ba.onCommitFiberUnmount(Kv,r)}catch{}switch(r.tag){case 5:br||Sl(r,t);case 6:var n=fr,a=ta;fr=null,$i(e,t,r),fr=n,ta=a,fr!==null&&(ta?(e=fr,r=r.stateNode,e.nodeType===8?e.parentNode.removeChild(r):e.removeChild(r)):fr.removeChild(r.stateNode));break;case 18:fr!==null&&(ta?(e=fr,r=r.stateNode,e.nodeType===8?tx(e.parentNode,r):e.nodeType===1&&tx(e,r),Id(e)):tx(fr,r.stateNode));break;case 4:n=fr,a=ta,fr=r.stateNode.containerInfo,ta=!0,$i(e,t,r),fr=n,ta=a;break;case 0:case 11:case 14:case 15:if(!br&&(n=r.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){a=n=n.next;do{var s=a,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&mb(r,t,o),a=a.next}while(a!==n)}$i(e,t,r);break;case 1:if(!br&&(Sl(r,t),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(l){_t(r,t,l)}$i(e,t,r);break;case 21:$i(e,t,r);break;case 22:r.mode&1?(br=(n=br)||r.memoizedState!==null,$i(e,t,r),br=n):$i(e,t,r);break;default:$i(e,t,r)}}function NP(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var r=e.stateNode;r===null&&(r=e.stateNode=new pU),t.forEach(function(n){var a=SU.bind(null,e,n);r.has(n)||(r.add(n),n.then(a,a))})}}function Qn(e,t){var r=t.deletions;if(r!==null)for(var n=0;na&&(a=o),n&=~s}if(n=a,n=Mt()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*gU(n/1960))-n,10e?16:e,ss===null)var n=!1;else{if(e=ss,ss=null,xm=0,Ke&6)throw Error(ae(331));var a=Ke;for(Ke|=4,pe=e.current;pe!==null;){var s=pe,o=s.child;if(pe.flags&16){var l=s.deletions;if(l!==null){for(var c=0;cMt()-P1?jo(e,0):O1|=r),Qr(e,t)}function ZD(e,t){t===0&&(e.mode&1?(t=Wh,Wh<<=1,!(Wh&130023424)&&(Wh=4194304)):t=1);var r=_r();e=Ni(e,t),e!==null&&(Vf(e,t,r),Qr(e,r))}function NU(e){var t=e.memoizedState,r=0;t!==null&&(r=t.retryLane),ZD(e,r)}function SU(e,t){var r=0;switch(e.tag){case 13:var n=e.stateNode,a=e.memoizedState;a!==null&&(r=a.retryLane);break;case 19:n=e.stateNode;break;default:throw Error(ae(314))}n!==null&&n.delete(t),ZD(e,r)}var JD;JD=function(e,t,r){if(e!==null)if(e.memoizedProps!==t.pendingProps||Kr.current)Vr=!0;else{if(!(e.lanes&r)&&!(t.flags&128))return Vr=!1,dU(e,t,r);Vr=!!(e.flags&131072)}else Vr=!1,St&&t.flags&1048576&&nD(t,um,t.index);switch(t.lanes=0,t.tag){case 2:var n=t.type;Lp(e,t),e=t.pendingProps;var a=hc(t,Nr.current);$l(t,r),a=x1(null,t,n,e,a,r);var s=b1();return t.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Yr(n)?(s=!0,lm(t)):s=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,p1(t),a.updater=tg,t.stateNode=a,a._reactInternals=t,lb(t,n,e,r),t=db(null,t,n,!0,s,r)):(t.tag=0,St&&s&&o1(t),Cr(null,t,a,r),t=t.child),t;case 16:n=t.elementType;e:{switch(Lp(e,t),e=t.pendingProps,a=n._init,n=a(n._payload),t.type=n,a=t.tag=PU(n),e=Jn(n,e),a){case 0:t=ub(null,t,n,e,r);break e;case 1:t=yP(null,t,n,e,r);break e;case 11:t=vP(null,t,n,e,r);break e;case 14:t=gP(null,t,n,Jn(n.type,e),r);break e}throw Error(ae(306,n,""))}return t;case 0:return n=t.type,a=t.pendingProps,a=t.elementType===n?a:Jn(n,a),ub(e,t,n,a,r);case 1:return n=t.type,a=t.pendingProps,a=t.elementType===n?a:Jn(n,a),yP(e,t,n,a,r);case 3:e:{if(RD(t),e===null)throw Error(ae(387));n=t.pendingProps,s=t.memoizedState,a=s.element,cD(e,t),hm(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){a=gc(Error(ae(423)),t),t=xP(e,t,n,r,a);break e}else if(n!==a){a=gc(Error(ae(424)),t),t=xP(e,t,n,r,a);break e}else for(cn=fs(t.stateNode.containerInfo.firstChild),dn=t,St=!0,aa=null,r=oD(t,null,n,r),t.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(pc(),n===a){t=Si(e,t,r);break e}Cr(e,t,n,r)}t=t.child}return t;case 5:return uD(t),e===null&&ib(t),n=t.type,a=t.pendingProps,s=e!==null?e.memoizedProps:null,o=a.children,eb(n,a)?o=null:s!==null&&eb(n,s)&&(t.flags|=32),ID(e,t),Cr(e,t,o,r),t.child;case 6:return e===null&&ib(t),null;case 13:return $D(e,t,r);case 4:return m1(t,t.stateNode.containerInfo),n=t.pendingProps,e===null?t.child=mc(t,null,n,r):Cr(e,t,n,r),t.child;case 11:return n=t.type,a=t.pendingProps,a=t.elementType===n?a:Jn(n,a),vP(e,t,n,a,r);case 7:return Cr(e,t,t.pendingProps,r),t.child;case 8:return Cr(e,t,t.pendingProps.children,r),t.child;case 12:return Cr(e,t,t.pendingProps.children,r),t.child;case 10:e:{if(n=t.type._context,a=t.pendingProps,s=t.memoizedProps,o=a.value,vt(dm,n._currentValue),n._currentValue=o,s!==null)if(va(s.value,o)){if(s.children===a.children&&!Kr.current){t=Si(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=vi(-1,r&-r),c.tag=2;var u=s.updateQueue;if(u!==null){u=u.shared;var f=u.pending;f===null?c.next=c:(c.next=f.next,f.next=c),u.pending=c}}s.lanes|=r,c=s.alternate,c!==null&&(c.lanes|=r),sb(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(ae(341));o.lanes|=r,l=o.alternate,l!==null&&(l.lanes|=r),sb(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}Cr(e,t,a.children,r),t=t.child}return t;case 9:return a=t.type,n=t.pendingProps.children,$l(t,r),a=Un(a),n=n(a),t.flags|=1,Cr(e,t,n,r),t.child;case 14:return n=t.type,a=Jn(n,t.pendingProps),a=Jn(n.type,a),gP(e,t,n,a,r);case 15:return DD(e,t,t.type,t.pendingProps,r);case 17:return n=t.type,a=t.pendingProps,a=t.elementType===n?a:Jn(n,a),Lp(e,t),t.tag=1,Yr(n)?(e=!0,lm(t)):e=!1,$l(t,r),TD(t,n,a),lb(t,n,a,r),db(null,t,n,!0,e,r);case 19:return LD(e,t,r);case 22:return MD(e,t,r)}throw Error(ae(156,t.tag))};function eM(e,t){return A_(e,t)}function OU(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 Mn(e,t,r,n){return new OU(e,t,r,n)}function T1(e){return e=e.prototype,!(!e||!e.isReactComponent)}function PU(e){if(typeof e=="function")return T1(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Yw)return 11;if(e===Qw)return 14}return 2}function vs(e,t){var r=e.alternate;return r===null?(r=Mn(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 Up(e,t,r,n,a,s){var o=2;if(n=e,typeof e=="function")T1(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case ml:return wo(r.children,a,s,t);case Kw:o=8,a|=8;break;case _0:return e=Mn(12,r,t,a|2),e.elementType=_0,e.lanes=s,e;case D0:return e=Mn(13,r,t,a),e.elementType=D0,e.lanes=s,e;case M0:return e=Mn(19,r,t,a),e.elementType=M0,e.lanes=s,e;case u_:return ag(r,a,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case l_:o=10;break e;case c_:o=9;break e;case Yw:o=11;break e;case Qw:o=14;break e;case Hi:o=16,n=null;break e}throw Error(ae(130,e==null?e:typeof e,""))}return t=Mn(o,r,t,a),t.elementType=e,t.type=n,t.lanes=s,t}function wo(e,t,r,n){return e=Mn(7,e,n,t),e.lanes=r,e}function ag(e,t,r,n){return e=Mn(22,e,n,t),e.elementType=u_,e.lanes=r,e.stateNode={isHidden:!1},e}function cx(e,t,r){return e=Mn(6,e,null,t),e.lanes=r,e}function ux(e,t,r){return t=Mn(4,e.children!==null?e.children:[],e.key,t),t.lanes=r,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function AU(e,t,r,n,a){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=Hy(0),this.expirationTimes=Hy(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Hy(0),this.identifierPrefix=n,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function k1(e,t,r,n,a,s,o,l,c){return e=new AU(e,t,r,l,c),t===1?(t=1,s===!0&&(t|=8)):t=0,s=Mn(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},p1(s),e}function CU(e,t,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(aM)}catch(e){console.error(e)}}aM(),a_.exports=bn;var Rs=a_.exports;const iM=et(Rs);var sM,kP=Rs;sM=kP.createRoot,kP.hydrateRoot;function DU(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var r,n,a,s,o=[],l="",c=e.split("/");for(c[0]||c.shift();a=c.shift();)r=a[0],r==="*"?(o.push(r),l+=a[1]==="?"?"(?:/(.*))?":"/(.*)"):r===":"?(n=a.indexOf("?",1),s=a.indexOf(".",1),o.push(a.substring(1,~n?n:~s?s:a.length)),l+=~n&&!~s?"(?:/([^/]+?))?":"/([^/]+?)",~s&&(l+=(~n?"?":"")+"\\"+a.substring(s))):l+="/"+a;return{keys:o,pattern:new RegExp("^"+l+(t?"(?=$|/)":"/?$"),"i")}}var oM={exports:{}},lM={};/** * @license React * use-sync-external-store-shim.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 xc=j;function MU(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var IU=typeof Object.is=="function"?Object.is:MU,RU=xc.useState,$U=xc.useEffect,LU=xc.useLayoutEffect,FU=xc.useDebugValue;function BU(e,t){var r=t(),n=RU({inst:{value:r,getSnapshot:t}}),a=n[0].inst,s=n[1];return LU(function(){a.value=r,a.getSnapshot=t,dx(a)&&s({inst:a})},[e,r,t]),$U(function(){return dx(a)&&s({inst:a}),e(function(){dx(a)&&s({inst:a})})},[e]),FU(r),r}function dx(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!IU(e,r)}catch{return!0}}function UU(e,t){return t()}var zU=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?UU:BU;lM.useSyncExternalStore=xc.useSyncExternalStore!==void 0?xc.useSyncExternalStore:zU;oM.exports=lM;var WU=oM.exports;const HU=Hw.useInsertionEffect,VU=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",qU=VU?j.useLayoutEffect:j.useEffect,GU=HU||qU,cM=e=>{const t=j.useRef([e,(...r)=>t[0](...r)]).current;return GU(()=>{t[0]=e}),t[1]},KU="popstate",I1="pushState",R1="replaceState",YU="hashchange",_P=[KU,I1,R1,YU],QU=e=>{for(const t of _P)addEventListener(t,e);return()=>{for(const t of _P)removeEventListener(t,e)}},uM=(e,t)=>WU.useSyncExternalStore(QU,e,t),XU=()=>location.search,ZU=({ssrSearch:e=""}={})=>uM(XU,()=>e),DP=()=>location.pathname,JU=({ssrPath:e}={})=>uM(DP,e?()=>e:DP),ez=(e,{replace:t=!1,state:r=null}={})=>history[t?R1:I1](r,"",e),tz=(e={})=>[JU(e),ez],MP=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[MP]>"u"){for(const e of[I1,R1]){const t=history[e];history[e]=function(){const r=t.apply(this,arguments),n=new Event(e);return n.arguments=arguments,dispatchEvent(n),r}}Object.defineProperty(window,MP,{value:!0})}const rz=(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())?"~"+t:t.slice(e.length)||"/",dM=(e="")=>e==="/"?"":e,nz=(e,t)=>e[0]==="~"?e.slice(1):dM(t)+e,az=(e="",t)=>rz(IP(dM(e)),IP(t)),IP=e=>{try{return decodeURI(e)}catch{return e}},fM={hook:tz,searchHook:ZU,parser:DU,base:"",ssrPath:void 0,ssrSearch:void 0,hrefs:e=>e},hM=j.createContext(fM),Yf=()=>j.useContext(hM),pM={},mM=j.createContext(pM),iz=()=>j.useContext(mM),cg=e=>{const[t,r]=e.hook(e);return[az(e.base,t),cM((n,a)=>r(nz(n,e.base),a))]},Qf=()=>cg(Yf()),vM=(e,t,r,n)=>{const{pattern:a,keys:s}=t instanceof RegExp?{keys:!1,pattern:t}:e(t||"*",n),o=a.exec(r)||[],[l,...c]=o;return l!==void 0?[!0,(()=>{const u=s!==!1?Object.fromEntries(s.map((d,h)=>[d,c[h]])):o.groups;let f={...c};return u&&Object.assign(f,u),f})(),...n?[l]:[]]:[!1,null]},sz=({children:e,...t})=>{var f,d;const r=Yf(),n=t.hook?fM:r;let a=n;const[s,o]=((f=t.ssrPath)==null?void 0:f.split("?"))??[];o&&(t.ssrSearch=o,t.ssrPath=s),t.hrefs=t.hrefs??((d=t.hook)==null?void 0:d.hrefs);let l=j.useRef({}),c=l.current,u=c;for(let h in n){const p=h==="base"?n[h]+(t[h]||""):t[h]||n[h];c===u&&p!==u[h]&&(l.current=u={...u}),u[h]=p,p!==n[h]&&(a=u)}return j.createElement(hM.Provider,{value:a,children:e})},RP=({children:e,component:t},r)=>t?j.createElement(t,{params:r}):typeof e=="function"?e(r):e,oz=e=>{let t=j.useRef(pM),r=t.current;for(const n in e)e[n]!==r[n]&&(r=e);return Object.keys(e).length===0&&(r=e),t.current=r},Te=({path:e,nest:t,match:r,...n})=>{const a=Yf(),[s]=cg(a),[o,l,c]=r??vM(a.parser,e,s,t),u=oz({...iz(),...l});if(!o)return null;const f=c?j.createElement(sz,{base:c},RP(n,u)):RP(n,u);return j.createElement(mM.Provider,{value:u,children:f})},gM=j.forwardRef((e,t)=>{const r=Yf(),[n,a]=cg(r),{to:s="",href:o=s,onClick:l,asChild:c,children:u,className:f,replace:d,state:h,...p}=e,y=cM(m=>{m.ctrlKey||m.metaKey||m.altKey||m.shiftKey||m.button!==0||(l==null||l(m),m.defaultPrevented||(m.preventDefault(),a(o,e)))}),v=r.hrefs(o[0]==="~"?o.slice(1):r.base+o,r);return c&&j.isValidElement(u)?j.cloneElement(u,{onClick:y,href:v}):j.createElement("a",{...p,onClick:y,href:v,className:f!=null&&f.call?f(n===o):f,children:u,ref:t})}),yM=e=>Array.isArray(e)?e.flatMap(t=>yM(t&&t.type===j.Fragment?t.props.children:t)):[e],sd=({children:e,location:t})=>{const r=Yf(),[n]=cg(r);for(const a of yM(e)){let s=0;if(j.isValidElement(a)&&(s=vM(r.parser,a.props.path,t||n,a.props.nest))[0])return j.cloneElement(a,{match:s})}return null};var nu=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Do=typeof window>"u"||"Deno"in globalThis;function En(){}function lz(e,t){return typeof e=="function"?e(t):e}function Nb(e){return typeof e=="number"&&e>=0&&e!==1/0}function xM(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Fl(e,t){return typeof e=="function"?e(t):e}function ia(e,t){return typeof e=="function"?e(t):e}function $P(e,t){const{type:r="all",exact:n,fetchStatus:a,predicate:s,queryKey:o,stale:l}=e;if(o){if(n){if(t.queryHash!==$1(o,t.options))return!1}else if(!Gd(t.queryKey,o))return!1}if(r!=="all"){const c=t.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||a&&a!==t.state.fetchStatus||s&&!s(t))}function LP(e,t){const{exact:r,status:n,predicate:a,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(r){if(Mo(t.options.mutationKey)!==Mo(s))return!1}else if(!Gd(t.options.mutationKey,s))return!1}return!(n&&t.state.status!==n||a&&!a(t))}function $1(e,t){return((t==null?void 0:t.queryKeyHashFn)||Mo)(e)}function Mo(e){return JSON.stringify(e,(t,r)=>Sb(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function Gd(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(r=>!Gd(e[r],t[r])):!1}function bM(e,t){if(e===t)return e;const r=FP(e)&&FP(t);if(r||Sb(e)&&Sb(t)){const n=r?e:Object.keys(e),a=n.length,s=r?t:Object.keys(t),o=s.length,l=r?[]:{};let c=0;for(let u=0;u{setTimeout(t,e)})}function Ob(e,t,r){return typeof r.structuralSharing=="function"?r.structuralSharing(e,t):r.structuralSharing!==!1?bM(e,t):t}function uz(e,t,r=0){const n=[...e,t];return r&&n.length>r?n.slice(1):n}function dz(e,t,r=0){const n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var L1=Symbol();function jM(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===L1?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var po,Qi,Jl,$k,fz=($k=class extends nu{constructor(){super();we(this,po);we(this,Qi);we(this,Jl);fe(this,Jl,t=>{if(!Do&&window.addEventListener){const r=()=>t();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){B(this,Qi)||this.setEventListener(B(this,Jl))}onUnsubscribe(){var t;this.hasListeners()||((t=B(this,Qi))==null||t.call(this),fe(this,Qi,void 0))}setEventListener(t){var r;fe(this,Jl,t),(r=B(this,Qi))==null||r.call(this),fe(this,Qi,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){B(this,po)!==t&&(fe(this,po,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(r=>{r(t)})}isFocused(){var t;return typeof B(this,po)=="boolean"?B(this,po):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},po=new WeakMap,Qi=new WeakMap,Jl=new WeakMap,$k),F1=new fz,ec,Xi,tc,Lk,hz=(Lk=class extends nu{constructor(){super();we(this,ec,!0);we(this,Xi);we(this,tc);fe(this,tc,t=>{if(!Do&&window.addEventListener){const r=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){B(this,Xi)||this.setEventListener(B(this,tc))}onUnsubscribe(){var t;this.hasListeners()||((t=B(this,Xi))==null||t.call(this),fe(this,Xi,void 0))}setEventListener(t){var r;fe(this,tc,t),(r=B(this,Xi))==null||r.call(this),fe(this,Xi,t(this.setOnline.bind(this)))}setOnline(t){B(this,ec)!==t&&(fe(this,ec,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return B(this,ec)}},ec=new WeakMap,Xi=new WeakMap,tc=new WeakMap,Lk),Nm=new hz;function Pb(){let e,t;const r=new Promise((a,s)=>{e=a,t=s});r.status="pending",r.catch(()=>{});function n(a){Object.assign(r,a),delete r.resolve,delete r.reject}return r.resolve=a=>{n({status:"fulfilled",value:a}),e(a)},r.reject=a=>{n({status:"rejected",reason:a}),t(a)},r}function pz(e){return Math.min(1e3*2**e,3e4)}function wM(e){return(e??"online")==="online"?Nm.isOnline():!0}var NM=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function fx(e){return e instanceof NM}function SM(e){let t=!1,r=0,n=!1,a;const s=Pb(),o=v=>{var m;n||(h(new NM(v)),(m=e.abort)==null||m.call(e))},l=()=>{t=!0},c=()=>{t=!1},u=()=>F1.isFocused()&&(e.networkMode==="always"||Nm.isOnline())&&e.canRun(),f=()=>wM(e.networkMode)&&e.canRun(),d=v=>{var m;n||(n=!0,(m=e.onSuccess)==null||m.call(e,v),a==null||a(),s.resolve(v))},h=v=>{var m;n||(n=!0,(m=e.onError)==null||m.call(e,v),a==null||a(),s.reject(v))},p=()=>new Promise(v=>{var m;a=x=>{(n||u())&&v(x)},(m=e.onPause)==null||m.call(e)}).then(()=>{var v;a=void 0,n||(v=e.onContinue)==null||v.call(e)}),y=()=>{if(n)return;let v;const m=r===0?e.initialPromise:void 0;try{v=m??e.fn()}catch(x){v=Promise.reject(x)}Promise.resolve(v).then(d).catch(x=>{var S;if(n)return;const g=e.retry??(Do?0:3),b=e.retryDelay??pz,N=typeof b=="function"?b(r,x):b,w=g===!0||typeof g=="number"&&ru()?void 0:p()).then(()=>{t?h(x):y()})})};return{promise:s,cancel:o,continue:()=>(a==null||a(),s),cancelRetry:l,continueRetry:c,canStart:f,start:()=>(f()?y():p().then(y),s)}}function mz(){let e=[],t=0,r=l=>{l()},n=l=>{l()},a=l=>setTimeout(l,0);const s=l=>{t?e.push(l):a(()=>{r(l)})},o=()=>{const l=e;e=[],l.length&&a(()=>{n(()=>{l.forEach(c=>{r(c)})})})};return{batch:l=>{let c;t++;try{c=l()}finally{t--,t||o()}return c},batchCalls:l=>(...c)=>{s(()=>{l(...c)})},schedule:s,setNotifyFunction:l=>{r=l},setBatchNotifyFunction:l=>{n=l},setScheduler:l=>{a=l}}}var Yt=mz(),mo,Fk,OM=(Fk=class{constructor(){we(this,mo)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Nb(this.gcTime)&&fe(this,mo,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Do?1/0:5*60*1e3))}clearGcTimeout(){B(this,mo)&&(clearTimeout(B(this,mo)),fe(this,mo,void 0))}},mo=new WeakMap,Fk),rc,nc,Cn,yr,Bf,vo,ea,ii,Bk,vz=(Bk=class extends OM{constructor(t){super();we(this,ea);we(this,rc);we(this,nc);we(this,Cn);we(this,yr);we(this,Bf);we(this,vo);fe(this,vo,!1),fe(this,Bf,t.defaultOptions),this.setOptions(t.options),this.observers=[],fe(this,Cn,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,fe(this,rc,gz(this.options)),this.state=t.state??B(this,rc),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=B(this,yr))==null?void 0:t.promise}setOptions(t){this.options={...B(this,Bf),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&B(this,Cn).remove(this)}setData(t,r){const n=Ob(this.state.data,t,this.options);return $e(this,ea,ii).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(t,r){$e(this,ea,ii).call(this,{type:"setState",state:t,setStateOptions:r})}cancel(t){var n,a;const r=(n=B(this,yr))==null?void 0:n.promise;return(a=B(this,yr))==null||a.cancel(t),r?r.then(En).catch(En):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(B(this,rc))}isActive(){return this.observers.some(t=>ia(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===L1||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(t=0){return this.state.isInvalidated||this.state.data===void 0||!xM(this.state.dataUpdatedAt,t)}onFocus(){var r;const t=this.observers.find(n=>n.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(r=B(this,yr))==null||r.continue()}onOnline(){var r;const t=this.observers.find(n=>n.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(r=B(this,yr))==null||r.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),B(this,Cn).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(B(this,yr)&&(B(this,vo)?B(this,yr).cancel({revert:!0}):B(this,yr).cancelRetry()),this.scheduleGc()),B(this,Cn).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||$e(this,ea,ii).call(this,{type:"invalidate"})}fetch(t,r){var c,u,f;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(B(this,yr))return B(this,yr).continueRetry(),B(this,yr).promise}if(t&&this.setOptions(t),!this.options.queryFn){const d=this.observers.find(h=>h.options.queryFn);d&&this.setOptions(d.options)}const n=new AbortController,a=d=>{Object.defineProperty(d,"signal",{enumerable:!0,get:()=>(fe(this,vo,!0),n.signal)})},s=()=>{const d=jM(this.options,r),h={queryKey:this.queryKey,meta:this.meta};return a(h),fe(this,vo,!1),this.options.persister?this.options.persister(d,h,this):d(h)},o={fetchOptions:r,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:s};a(o),(c=this.options.behavior)==null||c.onFetch(o,this),fe(this,nc,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=o.fetchOptions)==null?void 0:u.meta))&&$e(this,ea,ii).call(this,{type:"fetch",meta:(f=o.fetchOptions)==null?void 0:f.meta});const l=d=>{var h,p,y,v;fx(d)&&d.silent||$e(this,ea,ii).call(this,{type:"error",error:d}),fx(d)||((p=(h=B(this,Cn).config).onError)==null||p.call(h,d,this),(v=(y=B(this,Cn).config).onSettled)==null||v.call(y,this.state.data,d,this)),this.scheduleGc()};return fe(this,yr,SM({initialPromise:r==null?void 0:r.initialPromise,fn:o.fetchFn,abort:n.abort.bind(n),onSuccess:d=>{var h,p,y,v;if(d===void 0){l(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(d)}catch(m){l(m);return}(p=(h=B(this,Cn).config).onSuccess)==null||p.call(h,d,this),(v=(y=B(this,Cn).config).onSettled)==null||v.call(y,d,this.state.error,this),this.scheduleGc()},onError:l,onFail:(d,h)=>{$e(this,ea,ii).call(this,{type:"failed",failureCount:d,error:h})},onPause:()=>{$e(this,ea,ii).call(this,{type:"pause"})},onContinue:()=>{$e(this,ea,ii).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0})),B(this,yr).start()}},rc=new WeakMap,nc=new WeakMap,Cn=new WeakMap,yr=new WeakMap,Bf=new WeakMap,vo=new WeakMap,ea=new WeakSet,ii=function(t){const r=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...PM(n.data,this.options),fetchMeta:t.meta??null};case"success":return{...n,data:t.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const a=t.error;return fx(a)&&a.revert&&B(this,nc)?{...B(this,nc),fetchStatus:"idle"}:{...n,error:a,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=r(this.state),Yt.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),B(this,Cn).notify({query:this,type:"updated",action:t})})},Bk);function PM(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:wM(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function gz(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Ta,Uk,yz=(Uk=class extends nu{constructor(t={}){super();we(this,Ta);this.config=t,fe(this,Ta,new Map)}build(t,r,n){const a=r.queryKey,s=r.queryHash??$1(a,r);let o=this.get(s);return o||(o=new vz({cache:this,queryKey:a,queryHash:s,options:t.defaultQueryOptions(r),state:n,defaultOptions:t.getQueryDefaults(a)}),this.add(o)),o}add(t){B(this,Ta).has(t.queryHash)||(B(this,Ta).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const r=B(this,Ta).get(t.queryHash);r&&(t.destroy(),r===t&&B(this,Ta).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Yt.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return B(this,Ta).get(t)}getAll(){return[...B(this,Ta).values()]}find(t){const r={exact:!0,...t};return this.getAll().find(n=>$P(r,n))}findAll(t={}){const r=this.getAll();return Object.keys(t).length>0?r.filter(n=>$P(t,n)):r}notify(t){Yt.batch(()=>{this.listeners.forEach(r=>{r(t)})})}onFocus(){Yt.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Yt.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Ta=new WeakMap,Uk),ka,Pr,go,_a,Ui,zk,xz=(zk=class extends OM{constructor(t){super();we(this,_a);we(this,ka);we(this,Pr);we(this,go);this.mutationId=t.mutationId,fe(this,Pr,t.mutationCache),fe(this,ka,[]),this.state=t.state||AM(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){B(this,ka).includes(t)||(B(this,ka).push(t),this.clearGcTimeout(),B(this,Pr).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){fe(this,ka,B(this,ka).filter(r=>r!==t)),this.scheduleGc(),B(this,Pr).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){B(this,ka).length||(this.state.status==="pending"?this.scheduleGc():B(this,Pr).remove(this))}continue(){var t;return((t=B(this,go))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var a,s,o,l,c,u,f,d,h,p,y,v,m,x,g,b,N,w,S,O;fe(this,go,SM({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(P,A)=>{$e(this,_a,Ui).call(this,{type:"failed",failureCount:P,error:A})},onPause:()=>{$e(this,_a,Ui).call(this,{type:"pause"})},onContinue:()=>{$e(this,_a,Ui).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>B(this,Pr).canRun(this)}));const r=this.state.status==="pending",n=!B(this,go).canStart();try{if(!r){$e(this,_a,Ui).call(this,{type:"pending",variables:t,isPaused:n}),await((s=(a=B(this,Pr).config).onMutate)==null?void 0:s.call(a,t,this));const A=await((l=(o=this.options).onMutate)==null?void 0:l.call(o,t));A!==this.state.context&&$e(this,_a,Ui).call(this,{type:"pending",context:A,variables:t,isPaused:n})}const P=await B(this,go).start();return await((u=(c=B(this,Pr).config).onSuccess)==null?void 0:u.call(c,P,t,this.state.context,this)),await((d=(f=this.options).onSuccess)==null?void 0:d.call(f,P,t,this.state.context)),await((p=(h=B(this,Pr).config).onSettled)==null?void 0:p.call(h,P,null,this.state.variables,this.state.context,this)),await((v=(y=this.options).onSettled)==null?void 0:v.call(y,P,null,t,this.state.context)),$e(this,_a,Ui).call(this,{type:"success",data:P}),P}catch(P){try{throw await((x=(m=B(this,Pr).config).onError)==null?void 0:x.call(m,P,t,this.state.context,this)),await((b=(g=this.options).onError)==null?void 0:b.call(g,P,t,this.state.context)),await((w=(N=B(this,Pr).config).onSettled)==null?void 0:w.call(N,void 0,P,this.state.variables,this.state.context,this)),await((O=(S=this.options).onSettled)==null?void 0:O.call(S,void 0,P,t,this.state.context)),P}finally{$e(this,_a,Ui).call(this,{type:"error",error:P})}}finally{B(this,Pr).runNext(this)}}},ka=new WeakMap,Pr=new WeakMap,go=new WeakMap,_a=new WeakSet,Ui=function(t){const r=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=r(this.state),Yt.batch(()=>{B(this,ka).forEach(n=>{n.onMutationUpdate(t)}),B(this,Pr).notify({mutation:this,type:"updated",action:t})})},zk);function AM(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var nn,Uf,Wk,bz=(Wk=class extends nu{constructor(t={}){super();we(this,nn);we(this,Uf);this.config=t,fe(this,nn,new Map),fe(this,Uf,Date.now())}build(t,r,n){const a=new xz({mutationCache:this,mutationId:++Rh(this,Uf)._,options:t.defaultMutationOptions(r),state:n});return this.add(a),a}add(t){const r=tp(t),n=B(this,nn).get(r)??[];n.push(t),B(this,nn).set(r,n),this.notify({type:"added",mutation:t})}remove(t){var n;const r=tp(t);if(B(this,nn).has(r)){const a=(n=B(this,nn).get(r))==null?void 0:n.filter(s=>s!==t);a&&(a.length===0?B(this,nn).delete(r):B(this,nn).set(r,a))}this.notify({type:"removed",mutation:t})}canRun(t){var n;const r=(n=B(this,nn).get(tp(t)))==null?void 0:n.find(a=>a.state.status==="pending");return!r||r===t}runNext(t){var n;const r=(n=B(this,nn).get(tp(t)))==null?void 0:n.find(a=>a!==t&&a.state.isPaused);return(r==null?void 0:r.continue())??Promise.resolve()}clear(){Yt.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}getAll(){return[...B(this,nn).values()].flat()}find(t){const r={exact:!0,...t};return this.getAll().find(n=>LP(r,n))}findAll(t={}){return this.getAll().filter(r=>LP(t,r))}notify(t){Yt.batch(()=>{this.listeners.forEach(r=>{r(t)})})}resumePausedMutations(){const t=this.getAll().filter(r=>r.state.isPaused);return Yt.batch(()=>Promise.all(t.map(r=>r.continue().catch(En))))}},nn=new WeakMap,Uf=new WeakMap,Wk);function tp(e){var t;return((t=e.options.scope)==null?void 0:t.id)??String(e.mutationId)}function UP(e){return{onFetch:(t,r)=>{var f,d,h,p,y;const n=t.options,a=(h=(d=(f=t.fetchOptions)==null?void 0:f.meta)==null?void 0:d.fetchMore)==null?void 0:h.direction,s=((p=t.state.data)==null?void 0:p.pages)||[],o=((y=t.state.data)==null?void 0:y.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let v=!1;const m=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(t.signal.aborted?v=!0:t.signal.addEventListener("abort",()=>{v=!0}),t.signal)})},x=jM(t.options,t.fetchOptions),g=async(b,N,w)=>{if(v)return Promise.reject();if(N==null&&b.pages.length)return Promise.resolve(b);const S={queryKey:t.queryKey,pageParam:N,direction:w?"backward":"forward",meta:t.options.meta};m(S);const O=await x(S),{maxPages:P}=t.options,A=w?dz:uz;return{pages:A(b.pages,O,P),pageParams:A(b.pageParams,N,P)}};if(a&&s.length){const b=a==="backward",N=b?jz:zP,w={pages:s,pageParams:o},S=N(n,w);l=await g(w,S,b)}else{const b=e??s.length;do{const N=c===0?o[0]??n.initialPageParam:zP(n,l);if(c>0&&N==null)break;l=await g(l,N),c++}while(c{var v,m;return(m=(v=t.options).persister)==null?void 0:m.call(v,u,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r)}:t.fetchFn=u}}}function zP(e,{pages:t,pageParams:r}){const n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function jz(e,{pages:t,pageParams:r}){var n;return t.length>0?(n=e.getPreviousPageParam)==null?void 0:n.call(e,t[0],t,r[0],r):void 0}var kt,Zi,Ji,ac,ic,es,sc,oc,Hk,wz=(Hk=class{constructor(e={}){we(this,kt);we(this,Zi);we(this,Ji);we(this,ac);we(this,ic);we(this,es);we(this,sc);we(this,oc);fe(this,kt,e.queryCache||new yz),fe(this,Zi,e.mutationCache||new bz),fe(this,Ji,e.defaultOptions||{}),fe(this,ac,new Map),fe(this,ic,new Map),fe(this,es,0)}mount(){Rh(this,es)._++,B(this,es)===1&&(fe(this,sc,F1.subscribe(async e=>{e&&(await this.resumePausedMutations(),B(this,kt).onFocus())})),fe(this,oc,Nm.subscribe(async e=>{e&&(await this.resumePausedMutations(),B(this,kt).onOnline())})))}unmount(){var e,t;Rh(this,es)._--,B(this,es)===0&&((e=B(this,sc))==null||e.call(this),fe(this,sc,void 0),(t=B(this,oc))==null||t.call(this),fe(this,oc,void 0))}isFetching(e){return B(this,kt).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return B(this,Zi).findAll({...e,status:"pending"}).length}getQueryData(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=B(this,kt).get(t.queryHash))==null?void 0:r.state.data}ensureQueryData(e){const t=this.getQueryData(e.queryKey);if(t===void 0)return this.fetchQuery(e);{const r=this.defaultQueryOptions(e),n=B(this,kt).build(this,r);return e.revalidateIfStale&&n.isStaleByTime(Fl(r.staleTime,n))&&this.prefetchQuery(r),Promise.resolve(t)}}getQueriesData(e){return B(this,kt).findAll(e).map(({queryKey:t,state:r})=>{const n=r.data;return[t,n]})}setQueryData(e,t,r){const n=this.defaultQueryOptions({queryKey:e}),a=B(this,kt).get(n.queryHash),s=a==null?void 0:a.state.data,o=lz(t,s);if(o!==void 0)return B(this,kt).build(this,n).setData(o,{...r,manual:!0})}setQueriesData(e,t,r){return Yt.batch(()=>B(this,kt).findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=B(this,kt).get(t.queryHash))==null?void 0:r.state}removeQueries(e){const t=B(this,kt);Yt.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=B(this,kt),n={type:"active",...e};return Yt.batch(()=>(r.findAll(e).forEach(a=>{a.reset()}),this.refetchQueries(n,t)))}cancelQueries(e={},t={}){const r={revert:!0,...t},n=Yt.batch(()=>B(this,kt).findAll(e).map(a=>a.cancel(r)));return Promise.all(n).then(En).catch(En)}invalidateQueries(e={},t={}){return Yt.batch(()=>{if(B(this,kt).findAll(e).forEach(n=>{n.invalidate()}),e.refetchType==="none")return Promise.resolve();const r={...e,type:e.refetchType??e.type??"active"};return this.refetchQueries(r,t)})}refetchQueries(e={},t){const r={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},n=Yt.batch(()=>B(this,kt).findAll(e).filter(a=>!a.isDisabled()).map(a=>{let s=a.fetch(void 0,r);return r.throwOnError||(s=s.catch(En)),a.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(n).then(En)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=B(this,kt).build(this,t);return r.isStaleByTime(Fl(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(En).catch(En)}fetchInfiniteQuery(e){return e.behavior=UP(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(En).catch(En)}ensureInfiniteQueryData(e){return e.behavior=UP(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Nm.isOnline()?B(this,Zi).resumePausedMutations():Promise.resolve()}getQueryCache(){return B(this,kt)}getMutationCache(){return B(this,Zi)}getDefaultOptions(){return B(this,Ji)}setDefaultOptions(e){fe(this,Ji,e)}setQueryDefaults(e,t){B(this,ac).set(Mo(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...B(this,ac).values()];let r={};return t.forEach(n=>{Gd(e,n.queryKey)&&(r={...r,...n.defaultOptions})}),r}setMutationDefaults(e,t){B(this,ic).set(Mo(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...B(this,ic).values()];let r={};return t.forEach(n=>{Gd(e,n.mutationKey)&&(r={...r,...n.defaultOptions})}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...B(this,Ji).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=$1(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.enabled!==!0&&t.queryFn===L1&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...B(this,Ji).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){B(this,kt).clear(),B(this,Zi).clear()}},kt=new WeakMap,Zi=new WeakMap,Ji=new WeakMap,ac=new WeakMap,ic=new WeakMap,es=new WeakMap,sc=new WeakMap,oc=new WeakMap,Hk),Br,He,zf,Ar,yo,lc,ts,Da,Wf,cc,uc,xo,bo,rs,dc,nt,od,Ab,Cb,Eb,Tb,kb,_b,Db,CM,Vk,Nz=(Vk=class extends nu{constructor(t,r){super();we(this,nt);we(this,Br);we(this,He);we(this,zf);we(this,Ar);we(this,yo);we(this,lc);we(this,ts);we(this,Da);we(this,Wf);we(this,cc);we(this,uc);we(this,xo);we(this,bo);we(this,rs);we(this,dc,new Set);this.options=r,fe(this,Br,t),fe(this,Da,null),fe(this,ts,Pb()),this.options.experimental_prefetchInRender||B(this,ts).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(B(this,He).addObserver(this),WP(B(this,He),this.options)?$e(this,nt,od).call(this):this.updateResult(),$e(this,nt,Tb).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Mb(B(this,He),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Mb(B(this,He),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,$e(this,nt,kb).call(this),$e(this,nt,_b).call(this),B(this,He).removeObserver(this)}setOptions(t,r){const n=this.options,a=B(this,He);if(this.options=B(this,Br).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ia(this.options.enabled,B(this,He))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");$e(this,nt,Db).call(this),B(this,He).setOptions(this.options),n._defaulted&&!wm(this.options,n)&&B(this,Br).getQueryCache().notify({type:"observerOptionsUpdated",query:B(this,He),observer:this});const s=this.hasListeners();s&&HP(B(this,He),a,this.options,n)&&$e(this,nt,od).call(this),this.updateResult(r),s&&(B(this,He)!==a||ia(this.options.enabled,B(this,He))!==ia(n.enabled,B(this,He))||Fl(this.options.staleTime,B(this,He))!==Fl(n.staleTime,B(this,He)))&&$e(this,nt,Ab).call(this);const o=$e(this,nt,Cb).call(this);s&&(B(this,He)!==a||ia(this.options.enabled,B(this,He))!==ia(n.enabled,B(this,He))||o!==B(this,rs))&&$e(this,nt,Eb).call(this,o)}getOptimisticResult(t){const r=B(this,Br).getQueryCache().build(B(this,Br),t),n=this.createResult(r,t);return Oz(this,n)&&(fe(this,Ar,n),fe(this,lc,this.options),fe(this,yo,B(this,He).state)),n}getCurrentResult(){return B(this,Ar)}trackResult(t,r){const n={};return Object.keys(t).forEach(a=>{Object.defineProperty(n,a,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(a),r==null||r(a),t[a])})}),n}trackProp(t){B(this,dc).add(t)}getCurrentQuery(){return B(this,He)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const r=B(this,Br).defaultQueryOptions(t),n=B(this,Br).getQueryCache().build(B(this,Br),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(t){return $e(this,nt,od).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),B(this,Ar)))}createResult(t,r){var P;const n=B(this,He),a=this.options,s=B(this,Ar),o=B(this,yo),l=B(this,lc),u=t!==n?t.state:B(this,zf),{state:f}=t;let d={...f},h=!1,p;if(r._optimisticResults){const A=this.hasListeners(),C=!A&&WP(t,r),T=A&&HP(t,n,r,a);(C||T)&&(d={...d,...PM(f.data,t.options)}),r._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:y,errorUpdatedAt:v,status:m}=d;if(r.select&&d.data!==void 0)if(s&&d.data===(o==null?void 0:o.data)&&r.select===B(this,Wf))p=B(this,cc);else try{fe(this,Wf,r.select),p=r.select(d.data),p=Ob(s==null?void 0:s.data,p,r),fe(this,cc,p),fe(this,Da,null)}catch(A){fe(this,Da,A)}else p=d.data;if(r.placeholderData!==void 0&&p===void 0&&m==="pending"){let A;if(s!=null&&s.isPlaceholderData&&r.placeholderData===(l==null?void 0:l.placeholderData))A=s.data;else if(A=typeof r.placeholderData=="function"?r.placeholderData((P=B(this,uc))==null?void 0:P.state.data,B(this,uc)):r.placeholderData,r.select&&A!==void 0)try{A=r.select(A),fe(this,Da,null)}catch(C){fe(this,Da,C)}A!==void 0&&(m="success",p=Ob(s==null?void 0:s.data,A,r),h=!0)}B(this,Da)&&(y=B(this,Da),p=B(this,cc),v=Date.now(),m="error");const x=d.fetchStatus==="fetching",g=m==="pending",b=m==="error",N=g&&x,w=p!==void 0,O={status:m,fetchStatus:d.fetchStatus,isPending:g,isSuccess:m==="success",isError:b,isInitialLoading:N,isLoading:N,data:p,dataUpdatedAt:d.dataUpdatedAt,error:y,errorUpdatedAt:v,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>u.dataUpdateCount||d.errorUpdateCount>u.errorUpdateCount,isFetching:x,isRefetching:x&&!g,isLoadingError:b&&!w,isPaused:d.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:b&&w,isStale:B1(t,r),refetch:this.refetch,promise:B(this,ts)};if(this.options.experimental_prefetchInRender){const A=D=>{O.status==="error"?D.reject(O.error):O.data!==void 0&&D.resolve(O.data)},C=()=>{const D=fe(this,ts,O.promise=Pb());A(D)},T=B(this,ts);switch(T.status){case"pending":t.queryHash===n.queryHash&&A(T);break;case"fulfilled":(O.status==="error"||O.data!==T.value)&&C();break;case"rejected":(O.status!=="error"||O.error!==T.reason)&&C();break}}return O}updateResult(t){const r=B(this,Ar),n=this.createResult(B(this,He),this.options);if(fe(this,yo,B(this,He).state),fe(this,lc,this.options),B(this,yo).data!==void 0&&fe(this,uc,B(this,He)),wm(n,r))return;fe(this,Ar,n);const a={},s=()=>{if(!r)return!0;const{notifyOnChangeProps:o}=this.options,l=typeof o=="function"?o():o;if(l==="all"||!l&&!B(this,dc).size)return!0;const c=new Set(l??B(this,dc));return this.options.throwOnError&&c.add("error"),Object.keys(B(this,Ar)).some(u=>{const f=u;return B(this,Ar)[f]!==r[f]&&c.has(f)})};(t==null?void 0:t.listeners)!==!1&&s()&&(a.listeners=!0),$e(this,nt,CM).call(this,{...a,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&$e(this,nt,Tb).call(this)}},Br=new WeakMap,He=new WeakMap,zf=new WeakMap,Ar=new WeakMap,yo=new WeakMap,lc=new WeakMap,ts=new WeakMap,Da=new WeakMap,Wf=new WeakMap,cc=new WeakMap,uc=new WeakMap,xo=new WeakMap,bo=new WeakMap,rs=new WeakMap,dc=new WeakMap,nt=new WeakSet,od=function(t){$e(this,nt,Db).call(this);let r=B(this,He).fetch(this.options,t);return t!=null&&t.throwOnError||(r=r.catch(En)),r},Ab=function(){$e(this,nt,kb).call(this);const t=Fl(this.options.staleTime,B(this,He));if(Do||B(this,Ar).isStale||!Nb(t))return;const n=xM(B(this,Ar).dataUpdatedAt,t)+1;fe(this,xo,setTimeout(()=>{B(this,Ar).isStale||this.updateResult()},n))},Cb=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(B(this,He)):this.options.refetchInterval)??!1},Eb=function(t){$e(this,nt,_b).call(this),fe(this,rs,t),!(Do||ia(this.options.enabled,B(this,He))===!1||!Nb(B(this,rs))||B(this,rs)===0)&&fe(this,bo,setInterval(()=>{(this.options.refetchIntervalInBackground||F1.isFocused())&&$e(this,nt,od).call(this)},B(this,rs)))},Tb=function(){$e(this,nt,Ab).call(this),$e(this,nt,Eb).call(this,$e(this,nt,Cb).call(this))},kb=function(){B(this,xo)&&(clearTimeout(B(this,xo)),fe(this,xo,void 0))},_b=function(){B(this,bo)&&(clearInterval(B(this,bo)),fe(this,bo,void 0))},Db=function(){const t=B(this,Br).getQueryCache().build(B(this,Br),this.options);if(t===B(this,He))return;const r=B(this,He);fe(this,He,t),fe(this,zf,t.state),this.hasListeners()&&(r==null||r.removeObserver(this),t.addObserver(this))},CM=function(t){Yt.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(B(this,Ar))}),B(this,Br).getQueryCache().notify({query:B(this,He),type:"observerResultsUpdated"})})},Vk);function Sz(e,t){return ia(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function WP(e,t){return Sz(e,t)||e.state.data!==void 0&&Mb(e,t,t.refetchOnMount)}function Mb(e,t,r){if(ia(t.enabled,e)!==!1){const n=typeof r=="function"?r(e):r;return n==="always"||n!==!1&&B1(e,t)}return!1}function HP(e,t,r,n){return(e!==t||ia(n.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&B1(e,r)}function B1(e,t){return ia(t.enabled,e)!==!1&&e.isStaleByTime(Fl(t.staleTime,e))}function Oz(e,t){return!wm(e.getCurrentResult(),t)}var ns,as,Ur,ci,bi,zp,Ib,qk,Pz=(qk=class extends nu{constructor(r,n){super();we(this,bi);we(this,ns);we(this,as);we(this,Ur);we(this,ci);fe(this,ns,r),this.setOptions(n),this.bindMethods(),$e(this,bi,zp).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(r){var a;const n=this.options;this.options=B(this,ns).defaultMutationOptions(r),wm(this.options,n)||B(this,ns).getMutationCache().notify({type:"observerOptionsUpdated",mutation:B(this,Ur),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&Mo(n.mutationKey)!==Mo(this.options.mutationKey)?this.reset():((a=B(this,Ur))==null?void 0:a.state.status)==="pending"&&B(this,Ur).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=B(this,Ur))==null||r.removeObserver(this)}onMutationUpdate(r){$e(this,bi,zp).call(this),$e(this,bi,Ib).call(this,r)}getCurrentResult(){return B(this,as)}reset(){var r;(r=B(this,Ur))==null||r.removeObserver(this),fe(this,Ur,void 0),$e(this,bi,zp).call(this),$e(this,bi,Ib).call(this)}mutate(r,n){var a;return fe(this,ci,n),(a=B(this,Ur))==null||a.removeObserver(this),fe(this,Ur,B(this,ns).getMutationCache().build(B(this,ns),this.options)),B(this,Ur).addObserver(this),B(this,Ur).execute(r)}},ns=new WeakMap,as=new WeakMap,Ur=new WeakMap,ci=new WeakMap,bi=new WeakSet,zp=function(){var n;const r=((n=B(this,Ur))==null?void 0:n.state)??AM();fe(this,as,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},Ib=function(r){Yt.batch(()=>{var n,a,s,o,l,c,u,f;if(B(this,ci)&&this.hasListeners()){const d=B(this,as).variables,h=B(this,as).context;(r==null?void 0:r.type)==="success"?((a=(n=B(this,ci)).onSuccess)==null||a.call(n,r.data,d,h),(o=(s=B(this,ci)).onSettled)==null||o.call(s,r.data,null,d,h)):(r==null?void 0:r.type)==="error"&&((c=(l=B(this,ci)).onError)==null||c.call(l,r.error,d,h),(f=(u=B(this,ci)).onSettled)==null||f.call(u,void 0,r.error,d,h))}this.listeners.forEach(d=>{d(B(this,as))})})},qk),EM=j.createContext(void 0),$r=e=>{const t=j.useContext(EM);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Az=({client:e,children:t})=>(j.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),i.jsx(EM.Provider,{value:e,children:t})),TM=j.createContext(!1),Cz=()=>j.useContext(TM);TM.Provider;function Ez(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Tz=j.createContext(Ez()),kz=()=>j.useContext(Tz);function kM(e,t){return typeof e=="function"?e(...t):!!e}function Rb(){}var _z=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Dz=e=>{j.useEffect(()=>{e.clearReset()},[e])},Mz=({result:e,errorResetBoundary:t,throwOnError:r,query:n})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&kM(r,[e.error,n]),Iz=e=>{e.suspense&&(e.staleTime===void 0&&(e.staleTime=1e3),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3)))},Rz=(e,t)=>e.isLoading&&e.isFetching&&!t,$z=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,VP=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function Lz(e,t,r){var f,d,h,p,y;const n=$r(),a=Cz(),s=kz(),o=n.defaultQueryOptions(e);(d=(f=n.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||d.call(f,o),o._optimisticResults=a?"isRestoring":"optimistic",Iz(o),_z(o,s),Dz(s);const l=!n.getQueryCache().get(o.queryHash),[c]=j.useState(()=>new t(n,o)),u=c.getOptimisticResult(o);if(j.useSyncExternalStore(j.useCallback(v=>{const m=a?Rb:c.subscribe(Yt.batchCalls(v));return c.updateResult(),m},[c,a]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),j.useEffect(()=>{c.setOptions(o,{listeners:!1})},[o,c]),$z(o,u))throw VP(o,c,s);if(Mz({result:u,errorResetBoundary:s,throwOnError:o.throwOnError,query:n.getQueryCache().get(o.queryHash)}))throw u.error;if((p=(h=n.getDefaultOptions().queries)==null?void 0:h._experimental_afterQuery)==null||p.call(h,o,u),o.experimental_prefetchInRender&&!Do&&Rz(u,a)){const v=l?VP(o,c,s):(y=n.getQueryCache().get(o.queryHash))==null?void 0:y.promise;v==null||v.catch(Rb).finally(()=>{c.updateResult()})}return o.notifyOnChangeProps?u:c.trackResult(u)}function Fe(e,t){return Lz(e,Nz)}function rt(e,t){const r=$r(),[n]=j.useState(()=>new Pz(r,e));j.useEffect(()=>{n.setOptions(e)},[n,e]);const a=j.useSyncExternalStore(j.useCallback(o=>n.subscribe(Yt.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),s=j.useCallback((o,l)=>{n.mutate(o,l).catch(Rb)},[n]);if(a.error&&kM(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:s,mutateAsync:a.mutate}}const Fz=["Control plane request failed","endpoint is disabled","database connection","connection timeout","SSL connection","authentication failed","ECONNREFUSED","ETIMEDOUT"];function _M(e){if(!e)return"An unexpected error occurred";const t=typeof e=="string"?e:e.message||"Unknown error",r=t.toLowerCase();return Fz.some(a=>r.includes(a.toLowerCase()))||t.includes("401")||t.includes("Unauthorized")?"Please log in to continue":t.includes("403")||t.includes("Forbidden")?"You do not have permission to perform this action":t.includes("404")||t.includes("Not Found")?"The requested resource was not found":t.includes("500")||t.includes("Internal Server Error")?"A server error occurred. Please try again later":r.includes("validation")||r.includes("required")||r.includes("invalid")||r.includes("missing")||r.includes("already exists")?t:r.includes("error")&&(r.includes("network")||r.includes("timeout")||r.includes("connection"))?"Connection issue. Please check your internet connection and try again.":t.length<100&&!t.includes("at ")&&!t.includes("Error:")?t:"An unexpected error occurred. Please try again or contact support if the issue persists."}function hx(e,t,r="Error"){const n=_M(t);e({title:r,description:n,variant:"destructive"})}async function DM(e){if(!e.ok){const t=await e.text()||e.statusText,r=`${e.status}: ${t}`,n=_M(r);throw new Error(n)}}async function MM(e){const t=await e.text();if(t.includes("Control plane request failed")||t.includes("endpoint is disabled")||t.includes("database_unavailable"))throw console.log("Database connectivity issue detected, redirecting to login"),window.location.pathname!=="/"&&(window.location.href="/"),new Error("Please log in to continue");try{const r=JSON.parse(t);if(r.status==="database_unavailable")throw console.log("Database unavailable status detected, redirecting to login"),window.location.pathname!=="/"&&(window.location.href="/"),new Error("Please log in to continue");return r}catch{if(t.includes("Control plane request failed"))throw new Error("Please log in to continue");return t}}async function ut(e,t,r){const n=await fetch(t,{method:e,headers:r?{"Content-Type":"application/json"}:{},body:r?JSON.stringify(r):void 0,credentials:"include"});await DM(n);const a=await MM(n.clone());return new Response(JSON.stringify(a),{status:n.status,statusText:n.statusText,headers:n.headers})}const Bz=({on401:e})=>async({queryKey:t})=>{const r=await fetch(t[0],{credentials:"include"});return e==="returnNull"&&r.status===401?null:(await DM(r),await MM(r))},sa=new wz({defaultOptions:{queries:{queryFn:Bz({on401:"throw"}),refetchInterval:!1,refetchOnWindowFocus:!1,staleTime:1/0,retry:!1},mutations:{retry:!1}}}),Uz=1,zz=1e6;let px=0;function Wz(){return px=(px+1)%Number.MAX_SAFE_INTEGER,px.toString()}const mx=new Map,qP=e=>{if(mx.has(e))return;const t=setTimeout(()=>{mx.delete(e),bd({type:"REMOVE_TOAST",toastId:e})},zz);mx.set(e,t)},Hz=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Uz)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(r=>r.id===t.toast.id?{...r,...t.toast}:r)};case"DISMISS_TOAST":{const{toastId:r}=t;return r?qP(r):e.toasts.forEach(n=>{qP(n.id)}),{...e,toasts:e.toasts.map(n=>n.id===r||r===void 0?{...n,open:!1}:n)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(r=>r.id!==t.toastId)}}},Wp=[];let Hp={toasts:[]};function bd(e){Hp=Hz(Hp,e),Wp.forEach(t=>{t(Hp)})}function Vz({...e}){const t=Wz(),r=a=>bd({type:"UPDATE_TOAST",toast:{...a,id:t}}),n=()=>bd({type:"DISMISS_TOAST",toastId:t});return bd({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:a=>{a||n()}}}),{id:t,dismiss:n,update:r}}function Ht(){const[e,t]=j.useState(Hp);return j.useEffect(()=>(Wp.push(t),()=>{const r=Wp.indexOf(t);r>-1&&Wp.splice(r,1)}),[e]),{...e,toast:Vz,dismiss:r=>bd({type:"DISMISS_TOAST",toastId:r})}}function je(e,t,{checkForDefaultPrevented:r=!0}={}){return function(a){if(e==null||e(a),r===!1||!a.defaultPrevented)return t==null?void 0:t(a)}}function GP(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function U1(...e){return t=>{let r=!1;const n=e.map(a=>{const s=GP(a,t);return!r&&typeof s=="function"&&(r=!0),s});if(r)return()=>{for(let a=0;a{const{children:o,...l}=s,c=j.useMemo(()=>l,Object.values(l));return i.jsx(r.Provider,{value:c,children:o})};n.displayName=e+"Provider";function a(s){const o=j.useContext(r);if(o)return o;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[n,a]}function wn(e,t=[]){let r=[];function n(s,o){const l=j.createContext(o),c=r.length;r=[...r,o];const u=d=>{var x;const{scope:h,children:p,...y}=d,v=((x=h==null?void 0:h[e])==null?void 0:x[c])||l,m=j.useMemo(()=>y,Object.values(y));return i.jsx(v.Provider,{value:m,children:p})};u.displayName=s+"Provider";function f(d,h){var v;const p=((v=h==null?void 0:h[e])==null?void 0:v[c])||l,y=j.useContext(p);if(y)return y;if(o!==void 0)return o;throw new Error(`\`${d}\` must be used within \`${s}\``)}return[u,f]}const a=()=>{const s=r.map(o=>j.createContext(o));return function(l){const c=(l==null?void 0:l[e])||s;return j.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return a.scopeName=e,[n,Gz(a,...t)]}function Gz(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const n=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(s){const o=n.reduce((l,{useScope:c,scopeName:u})=>{const d=c(s)[`__scope${u}`];return{...l,...d}},{});return j.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return r.scopeName=t.scopeName,r}function Io(e){const t=Yz(e),r=j.forwardRef((n,a)=>{const{children:s,...o}=n,l=j.Children.toArray(s),c=l.find(Xz);if(c){const u=c.props.children,f=l.map(d=>d===c?j.Children.count(u)>1?j.Children.only(null):j.isValidElement(u)?u.props.children:null:d);return i.jsx(t,{...o,ref:a,children:j.isValidElement(u)?j.cloneElement(u,void 0,f):null})}return i.jsx(t,{...o,ref:a,children:s})});return r.displayName=`${e}.Slot`,r}var Kz=Io("Slot");function Yz(e){const t=j.forwardRef((r,n)=>{const{children:a,...s}=r;if(j.isValidElement(a)){const o=Jz(a),l=Zz(s,a.props);return a.type!==j.Fragment&&(l.ref=n?U1(n,o):o),j.cloneElement(a,l)}return j.Children.count(a)>1?j.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var IM=Symbol("radix.slottable");function Qz(e){const t=({children:r})=>i.jsx(i.Fragment,{children:r});return t.displayName=`${e}.Slottable`,t.__radixId=IM,t}function Xz(e){return j.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===IM}function Zz(e,t){const r={...t};for(const n in t){const a=e[n],s=t[n];/^on[A-Z]/.test(n)?a&&s?r[n]=(...l)=>{s(...l),a(...l)}:a&&(r[n]=a):n==="style"?r[n]={...a,...s}:n==="className"&&(r[n]=[a,s].filter(Boolean).join(" "))}return{...e,...r}}function Jz(e){var n,a;let t=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function RM(e){const t=e+"CollectionProvider",[r,n]=wn(t),[a,s]=r(t,{collectionRef:{current:null},itemMap:new Map}),o=v=>{const{scope:m,children:x}=v,g=M.useRef(null),b=M.useRef(new Map).current;return i.jsx(a,{scope:m,itemMap:b,collectionRef:g,children:x})};o.displayName=t;const l=e+"CollectionSlot",c=Io(l),u=M.forwardRef((v,m)=>{const{scope:x,children:g}=v,b=s(l,x),N=Ye(m,b.collectionRef);return i.jsx(c,{ref:N,children:g})});u.displayName=l;const f=e+"CollectionItemSlot",d="data-radix-collection-item",h=Io(f),p=M.forwardRef((v,m)=>{const{scope:x,children:g,...b}=v,N=M.useRef(null),w=Ye(m,N),S=s(f,x);return M.useEffect(()=>(S.itemMap.set(N,{ref:N,...b}),()=>void S.itemMap.delete(N))),i.jsx(h,{[d]:"",ref:w,children:g})});p.displayName=f;function y(v){const m=s(e+"CollectionConsumer",v);return M.useCallback(()=>{const g=m.collectionRef.current;if(!g)return[];const b=Array.from(g.querySelectorAll(`[${d}]`));return Array.from(m.itemMap.values()).sort((S,O)=>b.indexOf(S.ref.current)-b.indexOf(O.ref.current))},[m.collectionRef,m.itemMap])}return[{Provider:o,Slot:u,ItemSlot:p},y,n]}var eW=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Re=eW.reduce((e,t)=>{const r=Io(`Primitive.${t}`),n=j.forwardRef((a,s)=>{const{asChild:o,...l}=a,c=o?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),i.jsx(c,{...l,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function $M(e,t){e&&Rs.flushSync(()=>e.dispatchEvent(t))}function Jr(e){const t=j.useRef(e);return j.useEffect(()=>{t.current=e}),j.useMemo(()=>(...r)=>{var n;return(n=t.current)==null?void 0:n.call(t,...r)},[])}function tW(e,t=globalThis==null?void 0:globalThis.document){const r=Jr(e);j.useEffect(()=>{const n=a=>{a.key==="Escape"&&r(a)};return t.addEventListener("keydown",n,{capture:!0}),()=>t.removeEventListener("keydown",n,{capture:!0})},[r,t])}var rW="DismissableLayer",$b="dismissableLayer.update",nW="dismissableLayer.pointerDownOutside",aW="dismissableLayer.focusOutside",KP,LM=j.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Xf=j.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:s,onInteractOutside:o,onDismiss:l,...c}=e,u=j.useContext(LM),[f,d]=j.useState(null),h=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=j.useState({}),y=Ye(t,O=>d(O)),v=Array.from(u.layers),[m]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=v.indexOf(m),g=f?v.indexOf(f):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,N=g>=x,w=sW(O=>{const P=O.target,A=[...u.branches].some(C=>C.contains(P));!N||A||(a==null||a(O),o==null||o(O),O.defaultPrevented||l==null||l())},h),S=oW(O=>{const P=O.target;[...u.branches].some(C=>C.contains(P))||(s==null||s(O),o==null||o(O),O.defaultPrevented||l==null||l())},h);return tW(O=>{g===u.layers.size-1&&(n==null||n(O),!O.defaultPrevented&&l&&(O.preventDefault(),l()))},h),j.useEffect(()=>{if(f)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(KP=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),YP(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=KP)}},[f,h,r,u]),j.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),YP())},[f,u]),j.useEffect(()=>{const O=()=>p({});return document.addEventListener($b,O),()=>document.removeEventListener($b,O)},[]),i.jsx(Re.div,{...c,ref:y,style:{pointerEvents:b?N?"auto":"none":void 0,...e.style},onFocusCapture:je(e.onFocusCapture,S.onFocusCapture),onBlurCapture:je(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:je(e.onPointerDownCapture,w.onPointerDownCapture)})});Xf.displayName=rW;var iW="DismissableLayerBranch",FM=j.forwardRef((e,t)=>{const r=j.useContext(LM),n=j.useRef(null),a=Ye(t,n);return j.useEffect(()=>{const s=n.current;if(s)return r.branches.add(s),()=>{r.branches.delete(s)}},[r.branches]),i.jsx(Re.div,{...e,ref:a})});FM.displayName=iW;function sW(e,t=globalThis==null?void 0:globalThis.document){const r=Jr(e),n=j.useRef(!1),a=j.useRef(()=>{});return j.useEffect(()=>{const s=l=>{if(l.target&&!n.current){let c=function(){BM(nW,r,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",a.current),a.current=c,t.addEventListener("click",a.current,{once:!0})):c()}else t.removeEventListener("click",a.current);n.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",s),t.removeEventListener("click",a.current)}},[t,r]),{onPointerDownCapture:()=>n.current=!0}}function oW(e,t=globalThis==null?void 0:globalThis.document){const r=Jr(e),n=j.useRef(!1);return j.useEffect(()=>{const a=s=>{s.target&&!n.current&&BM(aW,r,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",a),()=>t.removeEventListener("focusin",a)},[t,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function YP(){const e=new CustomEvent($b);document.dispatchEvent(e)}function BM(e,t,r,{discrete:n}){const a=r.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&a.addEventListener(e,t,{once:!0}),n?$M(a,s):a.dispatchEvent(s)}var lW=Xf,cW=FM,Jt=globalThis!=null&&globalThis.document?j.useLayoutEffect:()=>{},uW="Portal",Zf=j.forwardRef((e,t)=>{var l;const{container:r,...n}=e,[a,s]=j.useState(!1);Jt(()=>s(!0),[]);const o=r||a&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return o?iM.createPortal(i.jsx(Re.div,{...n,ref:t}),o):null});Zf.displayName=uW;function dW(e,t){return j.useReducer((r,n)=>t[r][n]??r,e)}var $s=e=>{const{present:t,children:r}=e,n=fW(t),a=typeof r=="function"?r({present:n.isPresent}):j.Children.only(r),s=Ye(n.ref,hW(a));return typeof r=="function"||n.isPresent?j.cloneElement(a,{ref:s}):null};$s.displayName="Presence";function fW(e){const[t,r]=j.useState(),n=j.useRef({}),a=j.useRef(e),s=j.useRef("none"),o=e?"mounted":"unmounted",[l,c]=dW(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return j.useEffect(()=>{const u=rp(n.current);s.current=l==="mounted"?u:"none"},[l]),Jt(()=>{const u=n.current,f=a.current;if(f!==e){const h=s.current,p=rp(u);e?c("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(f&&h!==p?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,c]),Jt(()=>{if(t){let u;const f=t.ownerDocument.defaultView??window,d=p=>{const v=rp(n.current).includes(p.animationName);if(p.target===t&&v&&(c("ANIMATION_END"),!a.current)){const m=t.style.animationFillMode;t.style.animationFillMode="forwards",u=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=m)})}},h=p=>{p.target===t&&(s.current=rp(n.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{f.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:j.useCallback(u=>{u&&(n.current=getComputedStyle(u)),r(u)},[])}}function rp(e){return(e==null?void 0:e.animationName)||"none"}function hW(e){var n,a;let t=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function Ro({prop:e,defaultProp:t,onChange:r=()=>{}}){const[n,a]=pW({defaultProp:t,onChange:r}),s=e!==void 0,o=s?e:n,l=Jr(r),c=j.useCallback(u=>{if(s){const d=typeof u=="function"?u(e):u;d!==e&&l(d)}else a(u)},[s,e,a,l]);return[o,c]}function pW({defaultProp:e,onChange:t}){const r=j.useState(e),[n]=r,a=j.useRef(n),s=Jr(t);return j.useEffect(()=>{a.current!==n&&(s(n),a.current=n)},[n,a,s]),r}var mW="VisuallyHidden",ug=j.forwardRef((e,t)=>i.jsx(Re.span,{...e,ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));ug.displayName=mW;var z1="ToastProvider",[W1,vW,gW]=RM("Toast"),[UM,$Ce]=wn("Toast",[gW]),[yW,dg]=UM(z1),zM=e=>{const{__scopeToast:t,label:r="Notification",duration:n=5e3,swipeDirection:a="right",swipeThreshold:s=50,children:o}=e,[l,c]=j.useState(null),[u,f]=j.useState(0),d=j.useRef(!1),h=j.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${z1}\`. Expected non-empty \`string\`.`),i.jsx(W1.Provider,{scope:t,children:i.jsx(yW,{scope:t,label:r,duration:n,swipeDirection:a,swipeThreshold:s,toastCount:u,viewport:l,onViewportChange:c,onToastAdd:j.useCallback(()=>f(p=>p+1),[]),onToastRemove:j.useCallback(()=>f(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:d,isClosePausedRef:h,children:o})})};zM.displayName=z1;var WM="ToastViewport",xW=["F8"],Lb="toast.viewportPause",Fb="toast.viewportResume",HM=j.forwardRef((e,t)=>{const{__scopeToast:r,hotkey:n=xW,label:a="Notifications ({hotkey})",...s}=e,o=dg(WM,r),l=vW(r),c=j.useRef(null),u=j.useRef(null),f=j.useRef(null),d=j.useRef(null),h=Ye(t,d,o.onViewportChange),p=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),y=o.toastCount>0;j.useEffect(()=>{const m=x=>{var b;n.length!==0&&n.every(N=>x[N]||x.code===N)&&((b=d.current)==null||b.focus())};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[n]),j.useEffect(()=>{const m=c.current,x=d.current;if(y&&m&&x){const g=()=>{if(!o.isClosePausedRef.current){const S=new CustomEvent(Lb);x.dispatchEvent(S),o.isClosePausedRef.current=!0}},b=()=>{if(o.isClosePausedRef.current){const S=new CustomEvent(Fb);x.dispatchEvent(S),o.isClosePausedRef.current=!1}},N=S=>{!m.contains(S.relatedTarget)&&b()},w=()=>{m.contains(document.activeElement)||b()};return m.addEventListener("focusin",g),m.addEventListener("focusout",N),m.addEventListener("pointermove",g),m.addEventListener("pointerleave",w),window.addEventListener("blur",g),window.addEventListener("focus",b),()=>{m.removeEventListener("focusin",g),m.removeEventListener("focusout",N),m.removeEventListener("pointermove",g),m.removeEventListener("pointerleave",w),window.removeEventListener("blur",g),window.removeEventListener("focus",b)}}},[y,o.isClosePausedRef]);const v=j.useCallback(({tabbingDirection:m})=>{const g=l().map(b=>{const N=b.ref.current,w=[N,..._W(N)];return m==="forwards"?w:w.reverse()});return(m==="forwards"?g.reverse():g).flat()},[l]);return j.useEffect(()=>{const m=d.current;if(m){const x=g=>{var w,S,O;const b=g.altKey||g.ctrlKey||g.metaKey;if(g.key==="Tab"&&!b){const P=document.activeElement,A=g.shiftKey;if(g.target===m&&A){(w=u.current)==null||w.focus();return}const D=v({tabbingDirection:A?"backwards":"forwards"}),_=D.findIndex(k=>k===P);vx(D.slice(_+1))?g.preventDefault():A?(S=u.current)==null||S.focus():(O=f.current)==null||O.focus()}};return m.addEventListener("keydown",x),()=>m.removeEventListener("keydown",x)}},[l,v]),i.jsxs(cW,{ref:c,role:"region","aria-label":a.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:y?void 0:"none"},children:[y&&i.jsx(Bb,{ref:u,onFocusFromOutsideViewport:()=>{const m=v({tabbingDirection:"forwards"});vx(m)}}),i.jsx(W1.Slot,{scope:r,children:i.jsx(Re.ol,{tabIndex:-1,...s,ref:h})}),y&&i.jsx(Bb,{ref:f,onFocusFromOutsideViewport:()=>{const m=v({tabbingDirection:"backwards"});vx(m)}})]})});HM.displayName=WM;var VM="ToastFocusProxy",Bb=j.forwardRef((e,t)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...a}=e,s=dg(VM,r);return i.jsx(ug,{"aria-hidden":!0,tabIndex:0,...a,ref:t,style:{position:"fixed"},onFocus:o=>{var u;const l=o.relatedTarget;!((u=s.viewport)!=null&&u.contains(l))&&n()}})});Bb.displayName=VM;var fg="Toast",bW="toast.swipeStart",jW="toast.swipeMove",wW="toast.swipeCancel",NW="toast.swipeEnd",qM=j.forwardRef((e,t)=>{const{forceMount:r,open:n,defaultOpen:a,onOpenChange:s,...o}=e,[l=!0,c]=Ro({prop:n,defaultProp:a,onChange:s});return i.jsx($s,{present:r||l,children:i.jsx(PW,{open:l,...o,ref:t,onClose:()=>c(!1),onPause:Jr(e.onPause),onResume:Jr(e.onResume),onSwipeStart:je(e.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:je(e.onSwipeMove,u=>{const{x:f,y:d}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","move"),u.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${f}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${d}px`)}),onSwipeCancel:je(e.onSwipeCancel,u=>{u.currentTarget.setAttribute("data-swipe","cancel"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:je(e.onSwipeEnd,u=>{const{x:f,y:d}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","end"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${f}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${d}px`),c(!1)})})})});qM.displayName=fg;var[SW,OW]=UM(fg,{onClose(){}}),PW=j.forwardRef((e,t)=>{const{__scopeToast:r,type:n="foreground",duration:a,open:s,onClose:o,onEscapeKeyDown:l,onPause:c,onResume:u,onSwipeStart:f,onSwipeMove:d,onSwipeCancel:h,onSwipeEnd:p,...y}=e,v=dg(fg,r),[m,x]=j.useState(null),g=Ye(t,k=>x(k)),b=j.useRef(null),N=j.useRef(null),w=a||v.duration,S=j.useRef(0),O=j.useRef(w),P=j.useRef(0),{onToastAdd:A,onToastRemove:C}=v,T=Jr(()=>{var R;(m==null?void 0:m.contains(document.activeElement))&&((R=v.viewport)==null||R.focus()),o()}),D=j.useCallback(k=>{!k||k===1/0||(window.clearTimeout(P.current),S.current=new Date().getTime(),P.current=window.setTimeout(T,k))},[T]);j.useEffect(()=>{const k=v.viewport;if(k){const R=()=>{D(O.current),u==null||u()},$=()=>{const I=new Date().getTime()-S.current;O.current=O.current-I,window.clearTimeout(P.current),c==null||c()};return k.addEventListener(Lb,$),k.addEventListener(Fb,R),()=>{k.removeEventListener(Lb,$),k.removeEventListener(Fb,R)}}},[v.viewport,w,c,u,D]),j.useEffect(()=>{s&&!v.isClosePausedRef.current&&D(w)},[s,w,v.isClosePausedRef,D]),j.useEffect(()=>(A(),()=>C()),[A,C]);const _=j.useMemo(()=>m?JM(m):null,[m]);return v.viewport?i.jsxs(i.Fragment,{children:[_&&i.jsx(AW,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:_}),i.jsx(SW,{scope:r,onClose:T,children:Rs.createPortal(i.jsx(W1.ItemSlot,{scope:r,children:i.jsx(lW,{asChild:!0,onEscapeKeyDown:je(l,()=>{v.isFocusedToastEscapeKeyDownRef.current||T(),v.isFocusedToastEscapeKeyDownRef.current=!1}),children:i.jsx(Re.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":v.swipeDirection,...y,ref:g,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:je(e.onKeyDown,k=>{k.key==="Escape"&&(l==null||l(k.nativeEvent),k.nativeEvent.defaultPrevented||(v.isFocusedToastEscapeKeyDownRef.current=!0,T()))}),onPointerDown:je(e.onPointerDown,k=>{k.button===0&&(b.current={x:k.clientX,y:k.clientY})}),onPointerMove:je(e.onPointerMove,k=>{if(!b.current)return;const R=k.clientX-b.current.x,$=k.clientY-b.current.y,I=!!N.current,E=["left","right"].includes(v.swipeDirection),F=["left","up"].includes(v.swipeDirection)?Math.min:Math.max,V=E?F(0,R):0,G=E?0:F(0,$),K=k.pointerType==="touch"?10:2,q={x:V,y:G},ne={originalEvent:k,delta:q};I?(N.current=q,np(jW,d,ne,{discrete:!1})):QP(q,v.swipeDirection,K)?(N.current=q,np(bW,f,ne,{discrete:!1}),k.target.setPointerCapture(k.pointerId)):(Math.abs(R)>K||Math.abs($)>K)&&(b.current=null)}),onPointerUp:je(e.onPointerUp,k=>{const R=N.current,$=k.target;if($.hasPointerCapture(k.pointerId)&&$.releasePointerCapture(k.pointerId),N.current=null,b.current=null,R){const I=k.currentTarget,E={originalEvent:k,delta:R};QP(R,v.swipeDirection,v.swipeThreshold)?np(NW,p,E,{discrete:!0}):np(wW,h,E,{discrete:!0}),I.addEventListener("click",F=>F.preventDefault(),{once:!0})}})})})}),v.viewport)})]}):null}),AW=e=>{const{__scopeToast:t,children:r,...n}=e,a=dg(fg,t),[s,o]=j.useState(!1),[l,c]=j.useState(!1);return TW(()=>o(!0)),j.useEffect(()=>{const u=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(u)},[]),l?null:i.jsx(Zf,{asChild:!0,children:i.jsx(ug,{...n,children:s&&i.jsxs(i.Fragment,{children:[a.label," ",r]})})})},CW="ToastTitle",GM=j.forwardRef((e,t)=>{const{__scopeToast:r,...n}=e;return i.jsx(Re.div,{...n,ref:t})});GM.displayName=CW;var EW="ToastDescription",KM=j.forwardRef((e,t)=>{const{__scopeToast:r,...n}=e;return i.jsx(Re.div,{...n,ref:t})});KM.displayName=EW;var YM="ToastAction",QM=j.forwardRef((e,t)=>{const{altText:r,...n}=e;return r.trim()?i.jsx(ZM,{altText:r,asChild:!0,children:i.jsx(H1,{...n,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${YM}\`. Expected non-empty \`string\`.`),null)});QM.displayName=YM;var XM="ToastClose",H1=j.forwardRef((e,t)=>{const{__scopeToast:r,...n}=e,a=OW(XM,r);return i.jsx(ZM,{asChild:!0,children:i.jsx(Re.button,{type:"button",...n,ref:t,onClick:je(e.onClick,a.onClose)})})});H1.displayName=XM;var ZM=j.forwardRef((e,t)=>{const{__scopeToast:r,altText:n,...a}=e;return i.jsx(Re.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...a,ref:t})});function JM(e){const t=[];return Array.from(e.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&t.push(n.textContent),kW(n)){const a=n.ariaHidden||n.hidden||n.style.display==="none",s=n.dataset.radixToastAnnounceExclude==="";if(!a)if(s){const o=n.dataset.radixToastAnnounceAlt;o&&t.push(o)}else t.push(...JM(n))}}),t}function np(e,t,r,{discrete:n}){const a=r.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:r});t&&a.addEventListener(e,t,{once:!0}),n?$M(a,s):a.dispatchEvent(s)}var QP=(e,t,r=0)=>{const n=Math.abs(e.x),a=Math.abs(e.y),s=n>a;return t==="left"||t==="right"?s&&n>r:!s&&a>r};function TW(e=()=>{}){const t=Jr(e);Jt(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[t])}function kW(e){return e.nodeType===e.ELEMENT_NODE}function _W(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function vx(e){const t=document.activeElement;return e.some(r=>r===t?!0:(r.focus(),document.activeElement!==t))}var DW=zM,eI=HM,tI=qM,rI=GM,nI=KM,aI=QM,iI=H1;function sI(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;ttypeof e=="boolean"?`${e}`:e===0?"0":e,ZP=Me,Jf=(e,t)=>r=>{var n;if((t==null?void 0:t.variants)==null)return ZP(e,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:a,defaultVariants:s}=t,o=Object.keys(a).map(u=>{const f=r==null?void 0:r[u],d=s==null?void 0:s[u];if(f===null)return null;const h=XP(f)||XP(d);return a[u][h]}),l=r&&Object.entries(r).reduce((u,f)=>{let[d,h]=f;return h===void 0||(u[d]=h),u},{}),c=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((u,f)=>{let{class:d,className:h,...p}=f;return Object.entries(p).every(y=>{let[v,m]=y;return Array.isArray(m)?m.includes({...s,...l}[v]):{...s,...l}[v]===m})?[...u,d,h]:u},[]);return ZP(e,o,c,r==null?void 0:r.class,r==null?void 0:r.className)};/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MW=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),oI=(...e)=>e.filter((t,r,n)=>!!t&&n.indexOf(t)===r).join(" ");/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */var IW={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.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RW=j.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:s,iconNode:o,...l},c)=>j.createElement("svg",{ref:c,...IW,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:oI("lucide",a),...l},[...o.map(([u,f])=>j.createElement(u,f)),...Array.isArray(s)?s:[s]]));/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ge=(e,t)=>{const r=j.forwardRef(({className:n,...a},s)=>j.createElement(RW,{ref:s,iconNode:t,className:oI(`lucide-${MW(e)}`,n),...a}));return r.displayName=`${e}`,r};/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pl=ge("Activity",[["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"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $W=ge("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LW=ge("Banknote",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M6 12h.01M18 12h.01",key:"113zkx"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bl=ge("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bc=ge("Building",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dr=ge("Calendar",[["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"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xr=ge("ChartColumn",[["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"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V1=ge("ChartPie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lI=ge("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cI=ge("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FW=ge("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BW=ge("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UW=ge("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eh=ge("CircleAlert",[["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"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ct=ge("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ar=ge("CircleX",[["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"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wr=ge("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sm=ge("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/** * @license lucide-react v0.453.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=ge("DollarSign",[["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"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ln=ge("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zW=ge("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const au=ge("Eye",[["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"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Et=ge("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $o=ge("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gx=ge("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q1=ge("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ub=ge("Key",[["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"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WW=ge("LayoutDashboard",[["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"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uI=ge("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dI=ge("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fI=ge("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/** * @license lucide-react v0.453.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=ge("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HW=ge("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VW=ge("Move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ot=ge("Package",[["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"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JP=ge("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qW=ge("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GW=ge("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fn=ge("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $u=ge("Printer",[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]]);/** * @license lucide-react v0.453.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=ge("RefreshCw",[["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"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iu=ge("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vp=ge("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zb=ge("Shield",[["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"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KW=ge("ShoppingCart",[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YW=ge("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hI=ge("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hg=ge("Target",[["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"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jc=ge("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ul=ge("TrendingDown",[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mr=ge("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const No=ge("TriangleAlert",[["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"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G1=ge("Truck",[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wb=ge("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QW=ge("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XW=ge("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fn=ge("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ss=ge("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eA=ge("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const su=ge("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** * @license lucide-react v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pI=ge("Zap",[["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"}]]),K1="-",ZW=e=>{const t=e7(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{const l=o.split(K1);return l[0]===""&&l.length!==1&&l.shift(),mI(l,t)||JW(o)},getConflictingClassGroupIds:(o,l)=>{const c=r[o]||[];return l&&n[o]?[...c,...n[o]]:c}}},mI=(e,t)=>{var o;if(e.length===0)return t.classGroupId;const r=e[0],n=t.nextPart.get(r),a=n?mI(e.slice(1),n):void 0;if(a)return a;if(t.validators.length===0)return;const s=e.join(K1);return(o=t.validators.find(({validator:l})=>l(s)))==null?void 0:o.classGroupId},tA=/^\[(.+)\]$/,JW=e=>{if(tA.test(e)){const t=tA.exec(e)[1],r=t==null?void 0:t.substring(0,t.indexOf(":"));if(r)return"arbitrary.."+r}},e7=e=>{const{theme:t,prefix:r}=e,n={nextPart:new Map,validators:[]};return r7(Object.entries(e.classGroups),r).forEach(([s,o])=>{Hb(o,n,s,t)}),n},Hb=(e,t,r,n)=>{e.forEach(a=>{if(typeof a=="string"){const s=a===""?t:rA(t,a);s.classGroupId=r;return}if(typeof a=="function"){if(t7(a)){Hb(a(n),t,r,n);return}t.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([s,o])=>{Hb(o,rA(t,s),r,n)})})},rA=(e,t)=>{let r=e;return t.split(K1).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},t7=e=>e.isThemeGetter,r7=(e,t)=>t?e.map(([r,n])=>{const a=n.map(s=>typeof s=="string"?t+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,l])=>[t+o,l])):s);return[r,a]}):e,n7=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=new Map,n=new Map;const a=(s,o)=>{r.set(s,o),t++,t>e&&(t=0,n=r,r=new Map)};return{get(s){let o=r.get(s);if(o!==void 0)return o;if((o=n.get(s))!==void 0)return a(s,o),o},set(s,o){r.has(s)?r.set(s,o):a(s,o)}}},vI="!",a7=e=>{const{separator:t,experimentalParseClassName:r}=e,n=t.length===1,a=t[0],s=t.length,o=l=>{const c=[];let u=0,f=0,d;for(let m=0;mf?d-f:void 0;return{modifiers:c,hasImportantModifier:p,baseClassName:y,maybePostfixModifierPosition:v}};return r?l=>r({className:l,parseClassName:o}):o},i7=e=>{if(e.length<=1)return e;const t=[];let r=[];return e.forEach(n=>{n[0]==="["?(t.push(...r.sort(),n),r=[]):r.push(n)}),t.push(...r.sort()),t},s7=e=>({cache:n7(e.cacheSize),parseClassName:a7(e),...ZW(e)}),o7=/\s+/,l7=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a}=t,s=[],o=e.trim().split(o7);let l="";for(let c=o.length-1;c>=0;c-=1){const u=o[c],{modifiers:f,hasImportantModifier:d,baseClassName:h,maybePostfixModifierPosition:p}=r(u);let y=!!p,v=n(y?h.substring(0,p):h);if(!v){if(!y){l=u+(l.length>0?" "+l:l);continue}if(v=n(h),!v){l=u+(l.length>0?" "+l:l);continue}y=!1}const m=i7(f).join(":"),x=d?m+vI:m,g=x+v;if(s.includes(g))continue;s.push(g);const b=a(v,y);for(let N=0;N0?" "+l:l)}return l};function c7(){let e=0,t,r,n="";for(;e{if(typeof e=="string")return e;let t,r="";for(let n=0;nd(f),e());return r=s7(u),n=r.cache.get,a=r.cache.set,s=l,l(c)}function l(c){const u=n(c);if(u)return u;const f=l7(c,r);return a(c,f),f}return function(){return s(c7.apply(null,arguments))}}const xt=e=>{const t=r=>r[e]||[];return t.isThemeGetter=!0,t},yI=/^\[(?:([a-z-]+):)?(.+)\]$/i,d7=/^\d+\/\d+$/,f7=new Set(["px","full","screen"]),h7=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,p7=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,m7=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,v7=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,g7=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ri=e=>zl(e)||f7.has(e)||d7.test(e),Li=e=>ou(e,"length",O7),zl=e=>!!e&&!Number.isNaN(Number(e)),yx=e=>ou(e,"number",zl),Lu=e=>!!e&&Number.isInteger(Number(e)),y7=e=>e.endsWith("%")&&zl(e.slice(0,-1)),Ie=e=>yI.test(e),Fi=e=>h7.test(e),x7=new Set(["length","size","percentage"]),b7=e=>ou(e,x7,xI),j7=e=>ou(e,"position",xI),w7=new Set(["image","url"]),N7=e=>ou(e,w7,A7),S7=e=>ou(e,"",P7),Fu=()=>!0,ou=(e,t,r)=>{const n=yI.exec(e);return n?n[1]?typeof t=="string"?n[1]===t:t.has(n[1]):r(n[2]):!1},O7=e=>p7.test(e)&&!m7.test(e),xI=()=>!1,P7=e=>v7.test(e),A7=e=>g7.test(e),C7=()=>{const e=xt("colors"),t=xt("spacing"),r=xt("blur"),n=xt("brightness"),a=xt("borderColor"),s=xt("borderRadius"),o=xt("borderSpacing"),l=xt("borderWidth"),c=xt("contrast"),u=xt("grayscale"),f=xt("hueRotate"),d=xt("invert"),h=xt("gap"),p=xt("gradientColorStops"),y=xt("gradientColorStopPositions"),v=xt("inset"),m=xt("margin"),x=xt("opacity"),g=xt("padding"),b=xt("saturate"),N=xt("scale"),w=xt("sepia"),S=xt("skew"),O=xt("space"),P=xt("translate"),A=()=>["auto","contain","none"],C=()=>["auto","hidden","clip","visible","scroll"],T=()=>["auto",Ie,t],D=()=>[Ie,t],_=()=>["",ri,Li],k=()=>["auto",zl,Ie],R=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],$=()=>["solid","dashed","dotted","double","none"],I=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],E=()=>["start","end","center","between","around","evenly","stretch"],F=()=>["","0",Ie],V=()=>["auto","avoid","all","avoid-page","page","left","right","column"],G=()=>[zl,Ie];return{cacheSize:500,separator:":",theme:{colors:[Fu],spacing:[ri,Li],blur:["none","",Fi,Ie],brightness:G(),borderColor:[e],borderRadius:["none","","full",Fi,Ie],borderSpacing:D(),borderWidth:_(),contrast:G(),grayscale:F(),hueRotate:G(),invert:F(),gap:D(),gradientColorStops:[e],gradientColorStopPositions:[y7,Li],inset:T(),margin:T(),opacity:G(),padding:D(),saturate:G(),scale:G(),sepia:F(),skew:G(),space:D(),translate:D()},classGroups:{aspect:[{aspect:["auto","square","video",Ie]}],container:["container"],columns:[{columns:[Fi]}],"break-after":[{"break-after":V()}],"break-before":[{"break-before":V()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...R(),Ie]}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:A()}],"overscroll-x":[{"overscroll-x":A()}],"overscroll-y":[{"overscroll-y":A()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[v]}],"inset-x":[{"inset-x":[v]}],"inset-y":[{"inset-y":[v]}],start:[{start:[v]}],end:[{end:[v]}],top:[{top:[v]}],right:[{right:[v]}],bottom:[{bottom:[v]}],left:[{left:[v]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Lu,Ie]}],basis:[{basis:T()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Ie]}],grow:[{grow:F()}],shrink:[{shrink:F()}],order:[{order:["first","last","none",Lu,Ie]}],"grid-cols":[{"grid-cols":[Fu]}],"col-start-end":[{col:["auto",{span:["full",Lu,Ie]},Ie]}],"col-start":[{"col-start":k()}],"col-end":[{"col-end":k()}],"grid-rows":[{"grid-rows":[Fu]}],"row-start-end":[{row:["auto",{span:[Lu,Ie]},Ie]}],"row-start":[{"row-start":k()}],"row-end":[{"row-end":k()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Ie]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Ie]}],gap:[{gap:[h]}],"gap-x":[{"gap-x":[h]}],"gap-y":[{"gap-y":[h]}],"justify-content":[{justify:["normal",...E()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...E(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...E(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[g]}],px:[{px:[g]}],py:[{py:[g]}],ps:[{ps:[g]}],pe:[{pe:[g]}],pt:[{pt:[g]}],pr:[{pr:[g]}],pb:[{pb:[g]}],pl:[{pl:[g]}],m:[{m:[m]}],mx:[{mx:[m]}],my:[{my:[m]}],ms:[{ms:[m]}],me:[{me:[m]}],mt:[{mt:[m]}],mr:[{mr:[m]}],mb:[{mb:[m]}],ml:[{ml:[m]}],"space-x":[{"space-x":[O]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[O]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Ie,t]}],"min-w":[{"min-w":[Ie,t,"min","max","fit"]}],"max-w":[{"max-w":[Ie,t,"none","full","min","max","fit","prose",{screen:[Fi]},Fi]}],h:[{h:[Ie,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Ie,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Ie,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Ie,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Fi,Li]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",yx]}],"font-family":[{font:[Fu]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Ie]}],"line-clamp":[{"line-clamp":["none",zl,yx]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",ri,Ie]}],"list-image":[{"list-image":["none",Ie]}],"list-style-type":[{list:["none","disc","decimal",Ie]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[x]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[x]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...$(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",ri,Li]}],"underline-offset":[{"underline-offset":["auto",ri,Ie]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:D()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ie]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ie]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[x]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...R(),j7]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",b7]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},N7]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[y]}],"gradient-via-pos":[{via:[y]}],"gradient-to-pos":[{to:[y]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[x]}],"border-style":[{border:[...$(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[x]}],"divide-style":[{divide:$()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-l":[{"border-l":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...$()]}],"outline-offset":[{"outline-offset":[ri,Ie]}],"outline-w":[{outline:[ri,Li]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:_()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[x]}],"ring-offset-w":[{"ring-offset":[ri,Li]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Fi,S7]}],"shadow-color":[{shadow:[Fu]}],opacity:[{opacity:[x]}],"mix-blend":[{"mix-blend":[...I(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":I()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",Fi,Ie]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[f]}],invert:[{invert:[d]}],saturate:[{saturate:[b]}],sepia:[{sepia:[w]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[f]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[x]}],"backdrop-saturate":[{"backdrop-saturate":[b]}],"backdrop-sepia":[{"backdrop-sepia":[w]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Ie]}],duration:[{duration:G()}],ease:[{ease:["linear","in","out","in-out",Ie]}],delay:[{delay:G()}],animate:[{animate:["none","spin","ping","pulse","bounce",Ie]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[N]}],"scale-x":[{"scale-x":[N]}],"scale-y":[{"scale-y":[N]}],rotate:[{rotate:[Lu,Ie]}],"translate-x":[{"translate-x":[P]}],"translate-y":[{"translate-y":[P]}],"skew-x":[{"skew-x":[S]}],"skew-y":[{"skew-y":[S]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Ie]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ie]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":D()}],"scroll-mx":[{"scroll-mx":D()}],"scroll-my":[{"scroll-my":D()}],"scroll-ms":[{"scroll-ms":D()}],"scroll-me":[{"scroll-me":D()}],"scroll-mt":[{"scroll-mt":D()}],"scroll-mr":[{"scroll-mr":D()}],"scroll-mb":[{"scroll-mb":D()}],"scroll-ml":[{"scroll-ml":D()}],"scroll-p":[{"scroll-p":D()}],"scroll-px":[{"scroll-px":D()}],"scroll-py":[{"scroll-py":D()}],"scroll-ps":[{"scroll-ps":D()}],"scroll-pe":[{"scroll-pe":D()}],"scroll-pt":[{"scroll-pt":D()}],"scroll-pr":[{"scroll-pr":D()}],"scroll-pb":[{"scroll-pb":D()}],"scroll-pl":[{"scroll-pl":D()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ie]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[ri,Li,yx]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},E7=u7(C7);function ue(...e){return E7(Me(e))}const T7=DW,bI=j.forwardRef(({className:e,...t},r)=>i.jsx(eI,{ref:r,className:ue("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",e),...t}));bI.displayName=eI.displayName;const k7=Jf("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),jI=j.forwardRef(({className:e,variant:t,...r},n)=>i.jsx(tI,{ref:n,className:ue(k7({variant:t}),e),...r}));jI.displayName=tI.displayName;const _7=j.forwardRef(({className:e,...t},r)=>i.jsx(aI,{ref:r,className:ue("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));_7.displayName=aI.displayName;const wI=j.forwardRef(({className:e,...t},r)=>i.jsx(iI,{ref:r,className:ue("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:i.jsx(su,{className:"h-4 w-4"})}));wI.displayName=iI.displayName;const NI=j.forwardRef(({className:e,...t},r)=>i.jsx(rI,{ref:r,className:ue("text-sm font-semibold",e),...t}));NI.displayName=rI.displayName;const SI=j.forwardRef(({className:e,...t},r)=>i.jsx(nI,{ref:r,className:ue("text-sm opacity-90",e),...t}));SI.displayName=nI.displayName;function D7(){const{toasts:e}=Ht();return i.jsxs(T7,{children:[e.map(function({id:t,title:r,description:n,action:a,...s}){return i.jsxs(jI,{...s,children:[i.jsxs("div",{className:"grid gap-1",children:[r&&i.jsx(NI,{children:r}),n&&i.jsx(SI,{children:n})]}),a,i.jsx(wI,{})]},t)}),i.jsx(bI,{})]})}const OI=j.createContext(void 0);function M7({children:e}){const[t,r]=j.useState(!1),[n,a]=j.useState(null),s=()=>{r(!t),t&&a(null)};return i.jsx(OI.Provider,{value:{isEditMode:t,toggleEditMode:s,editingComponent:n,setEditingComponent:a},children:e})}function I7(){const e=j.useContext(OI);if(e===void 0)throw new Error("useAdminEdit must be used within an AdminEditProvider");return e}function Za(){const[e,t]=j.useState(null),[r,n]=j.useState(!0),[a,s]=j.useState(!1),o=async()=>{if(a)return;const c=setTimeout(()=>{n(!1),s(!0),t(null)},1500);try{const u=await fetch("/api/auth/me",{method:"GET",credentials:"include",headers:{"Content-Type":"application/json"}});if(clearTimeout(c),u.ok){const f=await u.json();f&&f.id&&f.role?t(f):t(null)}else console.log("Auth check returned:",u.status),t(null)}catch{clearTimeout(c),console.log("Auth check failed (normal in production with database issues)"),t(null)}finally{n(!1),s(!0)}},l=async()=>{n(!0),s(!1),await o()};return j.useEffect(()=>{o()},[]),{user:e,isLoading:r,isAuthenticated:!!e,refreshAuth:l}}const Kd=Jf("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),z=j.forwardRef(({className:e,variant:t,size:r,asChild:n=!1,...a},s)=>{const o=n?Kz:"button";return i.jsx(o,{className:ue(Kd({variant:t,size:r,className:e})),ref:s,...a})});z.displayName="Button";const W=j.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:ue("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));W.displayName="Card";const J=j.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:ue("flex flex-col space-y-1.5 p-6",e),...t}));J.displayName="CardHeader";const ee=j.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:ue("text-2xl font-semibold leading-none tracking-tight",e),...t}));ee.displayName="CardTitle";const Rt=j.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:ue("text-sm text-muted-foreground",e),...t}));Rt.displayName="CardDescription";const H=j.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:ue("p-6 pt-0",e),...t}));H.displayName="CardContent";const R7=j.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:ue("flex items-center p-6 pt-0",e),...t}));R7.displayName="CardFooter";function nA(){return i.jsx("div",{className:"min-h-screen bg-gradient-to-br from-primary-50 via-white to-primary-50",children:i.jsxs("div",{className:"container mx-auto px-4 py-16",children:[i.jsxs("div",{className:"text-center mb-16",children:[i.jsxs("div",{className:"flex items-center justify-center mb-6",children:[i.jsx("div",{className:"w-12 h-12 bg-primary-600 rounded-lg flex items-center justify-center",children:i.jsx(ha,{className:"w-7 h-7 text-white"})}),i.jsx("span",{className:"ml-3 text-3xl font-bold text-slate-800",children:"DOK TOK SALES ORDER"})]}),i.jsxs("h1",{className:"text-4xl md:text-6xl font-bold text-slate-900 mb-6",children:["Multi-Role Sales Order",i.jsx("span",{className:"text-primary-600",children:" Management System"})]}),i.jsx("p",{className:"text-xl text-slate-600 max-w-3xl mx-auto mb-8",children:"Streamline your sales operations with Telegram bot integration, role-based access control, and comprehensive reporting capabilities."}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"space-x-4",children:[i.jsx(z,{size:"lg",className:"text-lg px-8 py-3",onClick:()=>{try{window.location.href="/quick-login"}catch{window.location.replace(window.location.origin+"/quick-login")}},children:"Quick Login"}),i.jsx(z,{size:"lg",variant:"outline",className:"text-lg px-8 py-3",onClick:()=>{try{window.location.href="/login"}catch{window.location.replace(window.location.origin+"/login")}},children:"Manual Login"})]}),i.jsxs("div",{className:"mt-6 p-4 bg-blue-50 rounded-lg border border-blue-200",children:[i.jsx("h3",{className:"font-semibold text-blue-900 mb-2",children:"Test Credentials"}),i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2 text-sm",children:[i.jsxs("div",{className:"text-blue-800",children:[i.jsx("strong",{children:"Admin:"}),i.jsx("br",{}),"admin / password123"]}),i.jsxs("div",{className:"text-blue-800",children:[i.jsx("strong",{children:"Sales Officer:"}),i.jsx("br",{}),"sales_officer / password123"]}),i.jsxs("div",{className:"text-blue-800",children:[i.jsx("strong",{children:"Approver:"}),i.jsx("br",{}),"approver / password123"]}),i.jsxs("div",{className:"text-blue-800",children:[i.jsx("strong",{children:"Sales Clerk:"}),i.jsx("br",{}),"sales_clerk / password123"]})]})]})]})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-16",children:[i.jsxs(W,{className:"border-primary-200 hover:border-primary-300 transition-colors",children:[i.jsxs(J,{className:"text-center",children:[i.jsx(ha,{className:"w-8 h-8 text-primary-600 mx-auto mb-2"}),i.jsx(ee,{className:"text-lg",children:"Telegram Integration"})]}),i.jsx(H,{children:i.jsx("p",{className:"text-sm text-slate-600 text-center",children:"Sales officers can submit orders directly through our Telegram bot"})})]}),i.jsxs(W,{className:"border-primary-200 hover:border-primary-300 transition-colors",children:[i.jsxs(J,{className:"text-center",children:[i.jsx(Ss,{className:"w-8 h-8 text-primary-600 mx-auto mb-2"}),i.jsx(ee,{className:"text-lg",children:"Role-Based Access"})]}),i.jsx(H,{children:i.jsx("p",{className:"text-sm text-slate-600 text-center",children:"5 distinct user roles with customized dashboards and permissions"})})]}),i.jsxs(W,{className:"border-primary-200 hover:border-primary-300 transition-colors",children:[i.jsxs(J,{className:"text-center",children:[i.jsx(Xr,{className:"w-8 h-8 text-primary-600 mx-auto mb-2"}),i.jsx(ee,{className:"text-lg",children:"Analytics & Reports"})]}),i.jsx(H,{children:i.jsx("p",{className:"text-sm text-slate-600 text-center",children:"Comprehensive reporting with Excel export and real-time analytics"})})]}),i.jsxs(W,{className:"border-primary-200 hover:border-primary-300 transition-colors",children:[i.jsxs(J,{className:"text-center",children:[i.jsx(zb,{className:"w-8 h-8 text-primary-600 mx-auto mb-2"}),i.jsx(ee,{className:"text-lg",children:"Secure Workflows"})]}),i.jsx(H,{children:i.jsx("p",{className:"text-sm text-slate-600 text-center",children:"Approval workflows with audit trails and session management"})})]})]}),i.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-slate-200 p-8 mb-16",children:[i.jsx("h2",{className:"text-3xl font-bold text-slate-900 text-center mb-8",children:"User Roles & Capabilities"}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"w-16 h-16 bg-purple-100 rounded-full flex items-center justify-center mx-auto mb-4",children:i.jsx(zb,{className:"w-8 h-8 text-purple-600"})}),i.jsx("h3",{className:"text-lg font-semibold text-slate-900 mb-2",children:"Super Admin"}),i.jsx("p",{className:"text-sm text-slate-600",children:"Full system control, user management, and content administration"})]}),i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-4",children:i.jsx(Ss,{className:"w-8 h-8 text-blue-600"})}),i.jsx("h3",{className:"text-lg font-semibold text-slate-900 mb-2",children:"Approvers"}),i.jsx("p",{className:"text-sm text-slate-600",children:"Order approval, editing capabilities, and report creation for management"})]}),i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-4",children:i.jsx(Xr,{className:"w-8 h-8 text-green-600"})}),i.jsx("h3",{className:"text-lg font-semibold text-slate-900 mb-2",children:"Data Recorders"}),i.jsx("p",{className:"text-sm text-slate-600",children:"View orders and export comprehensive data to Excel formats"})]}),i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"w-16 h-16 bg-orange-100 rounded-full flex items-center justify-center mx-auto mb-4",children:i.jsx(Xr,{className:"w-8 h-8 text-orange-600"})}),i.jsx("h3",{className:"text-lg font-semibold text-slate-900 mb-2",children:"Management"}),i.jsx("p",{className:"text-sm text-slate-600",children:"Access to reports, analytics, and insights from approvers"})]}),i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"w-16 h-16 bg-cyan-100 rounded-full flex items-center justify-center mx-auto mb-4",children:i.jsx(ha,{className:"w-8 h-8 text-cyan-600"})}),i.jsx("h3",{className:"text-lg font-semibold text-slate-900 mb-2",children:"Sales Officers"}),i.jsx("p",{className:"text-sm text-slate-600",children:"Submit orders via Telegram bot and track order status"})]})]})]}),i.jsxs("div",{className:"text-center",children:[i.jsx("h2",{className:"text-3xl font-bold text-slate-900 mb-4",children:"Ready to Get Started?"}),i.jsx("p",{className:"text-lg text-slate-600 mb-8",children:"Join the platform and request access to start managing your sales orders efficiently."}),i.jsx(z,{size:"lg",className:"text-lg px-8 py-3",onClick:()=>window.location.href="/login",children:"Go to Home"})]})]})})}const $7=Jf("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function te({className:e,variant:t,...r}){return i.jsx("div",{className:ue($7({variant:t}),e),...r})}var L7=Hw[" useId ".trim().toString()]||(()=>{}),F7=0;function gi(e){const[t,r]=j.useState(L7());return Jt(()=>{r(n=>n??String(F7++))},[e]),t?`radix-${t}`:""}var xx="focusScope.autoFocusOnMount",bx="focusScope.autoFocusOnUnmount",aA={bubbles:!1,cancelable:!0},B7="FocusScope",pg=j.forwardRef((e,t)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:s,...o}=e,[l,c]=j.useState(null),u=Jr(a),f=Jr(s),d=j.useRef(null),h=Ye(t,v=>c(v)),p=j.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;j.useEffect(()=>{if(n){let v=function(b){if(p.paused||!l)return;const N=b.target;l.contains(N)?d.current=N:zi(d.current,{select:!0})},m=function(b){if(p.paused||!l)return;const N=b.relatedTarget;N!==null&&(l.contains(N)||zi(d.current,{select:!0}))},x=function(b){if(document.activeElement===document.body)for(const w of b)w.removedNodes.length>0&&zi(l)};document.addEventListener("focusin",v),document.addEventListener("focusout",m);const g=new MutationObserver(x);return l&&g.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",m),g.disconnect()}}},[n,l,p.paused]),j.useEffect(()=>{if(l){sA.add(p);const v=document.activeElement;if(!l.contains(v)){const x=new CustomEvent(xx,aA);l.addEventListener(xx,u),l.dispatchEvent(x),x.defaultPrevented||(U7(q7(PI(l)),{select:!0}),document.activeElement===v&&zi(l))}return()=>{l.removeEventListener(xx,u),setTimeout(()=>{const x=new CustomEvent(bx,aA);l.addEventListener(bx,f),l.dispatchEvent(x),x.defaultPrevented||zi(v??document.body,{select:!0}),l.removeEventListener(bx,f),sA.remove(p)},0)}}},[l,u,f,p]);const y=j.useCallback(v=>{if(!r&&!n||p.paused)return;const m=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,x=document.activeElement;if(m&&x){const g=v.currentTarget,[b,N]=z7(g);b&&N?!v.shiftKey&&x===N?(v.preventDefault(),r&&zi(b,{select:!0})):v.shiftKey&&x===b&&(v.preventDefault(),r&&zi(N,{select:!0})):x===g&&v.preventDefault()}},[r,n,p.paused]);return i.jsx(Re.div,{tabIndex:-1,...o,ref:h,onKeyDown:y})});pg.displayName=B7;function U7(e,{select:t=!1}={}){const r=document.activeElement;for(const n of e)if(zi(n,{select:t}),document.activeElement!==r)return}function z7(e){const t=PI(e),r=iA(t,e),n=iA(t.reverse(),e);return[r,n]}function PI(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function iA(e,t){for(const r of e)if(!W7(r,{upTo:t}))return r}function W7(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function H7(e){return e instanceof HTMLInputElement&&"select"in e}function zi(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&H7(e)&&t&&e.select()}}var sA=V7();function V7(){let e=[];return{add(t){const r=e[0];t!==r&&(r==null||r.pause()),e=oA(e,t),e.unshift(t)},remove(t){var r;e=oA(e,t),(r=e[0])==null||r.resume()}}}function oA(e,t){const r=[...e],n=r.indexOf(t);return n!==-1&&r.splice(n,1),r}function q7(e){return e.filter(t=>t.tagName!=="A")}var jx=0;function Y1(){j.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??lA()),document.body.insertAdjacentElement("beforeend",e[1]??lA()),jx++,()=>{jx===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),jx--}},[])}function lA(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Ia=function(){return Ia=Object.assign||function(t){for(var r,n=1,a=arguments.length;n"u")return c9;var t=u9(e),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,n-r+t[2]-t[0])}},f9=TI(),Wl="data-scroll-locked",h9=function(e,t,r,n){var a=e.left,s=e.top,o=e.right,l=e.gap;return r===void 0&&(r="margin"),` .`.concat(K7,` { overflow: hidden `).concat(n,`; padding-right: `).concat(l,"px ").concat(n,`; } body[`).concat(Wl,`] { overflow: hidden `).concat(n,`; overscroll-behavior: contain; `).concat([t&&"position: relative ".concat(n,";"),r==="margin"&&` padding-left: `.concat(a,`px; padding-top: `).concat(s,`px; padding-right: `).concat(o,`px; margin-left:0; margin-top:0; margin-right: `).concat(l,"px ").concat(n,`; `),r==="padding"&&"padding-right: ".concat(l,"px ").concat(n,";")].filter(Boolean).join(""),` } .`).concat(qp,` { right: `).concat(l,"px ").concat(n,`; } .`).concat(Gp,` { margin-right: `).concat(l,"px ").concat(n,`; } .`).concat(qp," .").concat(qp,` { right: 0 `).concat(n,`; } .`).concat(Gp," .").concat(Gp,` { margin-right: 0 `).concat(n,`; } body[`).concat(Wl,`] { `).concat(Y7,": ").concat(l,`px; } `)},uA=function(){var e=parseInt(document.body.getAttribute(Wl)||"0",10);return isFinite(e)?e:0},p9=function(){j.useEffect(function(){return document.body.setAttribute(Wl,(uA()+1).toString()),function(){var e=uA()-1;e<=0?document.body.removeAttribute(Wl):document.body.setAttribute(Wl,e.toString())}},[])},m9=function(e){var t=e.noRelative,r=e.noImportant,n=e.gapMode,a=n===void 0?"margin":n;p9();var s=j.useMemo(function(){return d9(a)},[a]);return j.createElement(f9,{styles:h9(s,!t,a,r?"":"!important")})},Vb=!1;if(typeof window<"u")try{var ap=Object.defineProperty({},"passive",{get:function(){return Vb=!0,!0}});window.addEventListener("test",ap,ap),window.removeEventListener("test",ap,ap)}catch{Vb=!1}var il=Vb?{passive:!1}:!1,v9=function(e){return e.tagName==="TEXTAREA"},kI=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!v9(e)&&r[t]==="visible")},g9=function(e){return kI(e,"overflowY")},y9=function(e){return kI(e,"overflowX")},dA=function(e,t){var r=t.ownerDocument,n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=_I(e,n);if(a){var s=DI(e,n),o=s[1],l=s[2];if(o>l)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},x9=function(e){var t=e.scrollTop,r=e.scrollHeight,n=e.clientHeight;return[t,r,n]},b9=function(e){var t=e.scrollLeft,r=e.scrollWidth,n=e.clientWidth;return[t,r,n]},_I=function(e,t){return e==="v"?g9(t):y9(t)},DI=function(e,t){return e==="v"?x9(t):b9(t)},j9=function(e,t){return e==="h"&&t==="rtl"?-1:1},w9=function(e,t,r,n,a){var s=j9(e,window.getComputedStyle(t).direction),o=s*n,l=r.target,c=t.contains(l),u=!1,f=o>0,d=0,h=0;do{var p=DI(e,l),y=p[0],v=p[1],m=p[2],x=v-m-s*y;(y||x)&&_I(e,l)&&(d+=x,h+=y),l instanceof ShadowRoot?l=l.host:l=l.parentNode}while(!c&&l!==document.body||c&&(t.contains(l)||t===l));return(f&&(Math.abs(d)<1||!a)||!f&&(Math.abs(h)<1||!a))&&(u=!0),u},ip=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},fA=function(e){return[e.deltaX,e.deltaY]},hA=function(e){return e&&"current"in e?e.current:e},N9=function(e,t){return e[0]===t[0]&&e[1]===t[1]},S9=function(e){return` .block-interactivity-`.concat(e,` {pointer-events: none;} .allow-interactivity-`).concat(e,` {pointer-events: all;} `)},O9=0,sl=[];function P9(e){var t=j.useRef([]),r=j.useRef([0,0]),n=j.useRef(),a=j.useState(O9++)[0],s=j.useState(TI)[0],o=j.useRef(e);j.useEffect(function(){o.current=e},[e]),j.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var v=G7([e.lockRef.current],(e.shards||[]).map(hA),!0).filter(Boolean);return v.forEach(function(m){return m.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),v.forEach(function(m){return m.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var l=j.useCallback(function(v,m){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var x=ip(v),g=r.current,b="deltaX"in v?v.deltaX:g[0]-x[0],N="deltaY"in v?v.deltaY:g[1]-x[1],w,S=v.target,O=Math.abs(b)>Math.abs(N)?"h":"v";if("touches"in v&&O==="h"&&S.type==="range")return!1;var P=dA(O,S);if(!P)return!0;if(P?w=O:(w=O==="v"?"h":"v",P=dA(O,S)),!P)return!1;if(!n.current&&"changedTouches"in v&&(b||N)&&(n.current=w),!w)return!0;var A=n.current||w;return w9(A,m,v,A==="h"?b:N,!0)},[]),c=j.useCallback(function(v){var m=v;if(!(!sl.length||sl[sl.length-1]!==s)){var x="deltaY"in m?fA(m):ip(m),g=t.current.filter(function(w){return w.name===m.type&&(w.target===m.target||m.target===w.shadowParent)&&N9(w.delta,x)})[0];if(g&&g.should){m.cancelable&&m.preventDefault();return}if(!g){var b=(o.current.shards||[]).map(hA).filter(Boolean).filter(function(w){return w.contains(m.target)}),N=b.length>0?l(m,b[0]):!o.current.noIsolation;N&&m.cancelable&&m.preventDefault()}}},[]),u=j.useCallback(function(v,m,x,g){var b={name:v,delta:m,target:x,should:g,shadowParent:A9(x)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(N){return N!==b})},1)},[]),f=j.useCallback(function(v){r.current=ip(v),n.current=void 0},[]),d=j.useCallback(function(v){u(v.type,fA(v),v.target,l(v,e.lockRef.current))},[]),h=j.useCallback(function(v){u(v.type,ip(v),v.target,l(v,e.lockRef.current))},[]);j.useEffect(function(){return sl.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:h}),document.addEventListener("wheel",c,il),document.addEventListener("touchmove",c,il),document.addEventListener("touchstart",f,il),function(){sl=sl.filter(function(v){return v!==s}),document.removeEventListener("wheel",c,il),document.removeEventListener("touchmove",c,il),document.removeEventListener("touchstart",f,il)}},[]);var p=e.removeScrollBar,y=e.inert;return j.createElement(j.Fragment,null,y?j.createElement(s,{styles:S9(a)}):null,p?j.createElement(m9,{gapMode:e.gapMode}):null)}function A9(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const C9=r9(EI,P9);var vg=j.forwardRef(function(e,t){return j.createElement(mg,Ia({},e,{ref:t,sideCar:C9}))});vg.classNames=mg.classNames;var E9=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ol=new WeakMap,sp=new WeakMap,op={},Ox=0,MI=function(e){return e&&(e.host||MI(e.parentNode))},T9=function(e,t){return t.map(function(r){if(e.contains(r))return r;var n=MI(r);return n&&e.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},k9=function(e,t,r,n){var a=T9(t,Array.isArray(e)?e:[e]);op[r]||(op[r]=new WeakMap);var s=op[r],o=[],l=new Set,c=new Set(a),u=function(d){!d||l.has(d)||(l.add(d),u(d.parentNode))};a.forEach(u);var f=function(d){!d||c.has(d)||Array.prototype.forEach.call(d.children,function(h){if(l.has(h))f(h);else try{var p=h.getAttribute(n),y=p!==null&&p!=="false",v=(ol.get(h)||0)+1,m=(s.get(h)||0)+1;ol.set(h,v),s.set(h,m),o.push(h),v===1&&y&&sp.set(h,!0),m===1&&h.setAttribute(r,"true"),y||h.setAttribute(n,"true")}catch(x){console.error("aria-hidden: cannot operate on ",h,x)}})};return f(t),l.clear(),Ox++,function(){o.forEach(function(d){var h=ol.get(d)-1,p=s.get(d)-1;ol.set(d,h),s.set(d,p),h||(sp.has(d)||d.removeAttribute(n),sp.delete(d)),p||d.removeAttribute(r)}),Ox--,Ox||(ol=new WeakMap,ol=new WeakMap,sp=new WeakMap,op={})}},Q1=function(e,t,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),a=E9(e);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live]"))),k9(n,a,r,"aria-hidden")):function(){return null}},X1="Dialog",[II,RI]=wn(X1),[_9,Na]=II(X1),$I=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:a,onOpenChange:s,modal:o=!0}=e,l=j.useRef(null),c=j.useRef(null),[u=!1,f]=Ro({prop:n,defaultProp:a,onChange:s});return i.jsx(_9,{scope:t,triggerRef:l,contentRef:c,contentId:gi(),titleId:gi(),descriptionId:gi(),open:u,onOpenChange:f,onOpenToggle:j.useCallback(()=>f(d=>!d),[f]),modal:o,children:r})};$I.displayName=X1;var LI="DialogTrigger",FI=j.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,a=Na(LI,r),s=Ye(t,a.triggerRef);return i.jsx(Re.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":eN(a.open),...n,ref:s,onClick:je(e.onClick,a.onOpenToggle)})});FI.displayName=LI;var Z1="DialogPortal",[D9,BI]=II(Z1,{forceMount:void 0}),UI=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:a}=e,s=Na(Z1,t);return i.jsx(D9,{scope:t,forceMount:r,children:j.Children.map(n,o=>i.jsx($s,{present:r||s.open,children:i.jsx(Zf,{asChild:!0,container:a,children:o})}))})};UI.displayName=Z1;var Om="DialogOverlay",zI=j.forwardRef((e,t)=>{const r=BI(Om,e.__scopeDialog),{forceMount:n=r.forceMount,...a}=e,s=Na(Om,e.__scopeDialog);return s.modal?i.jsx($s,{present:n||s.open,children:i.jsx(I9,{...a,ref:t})}):null});zI.displayName=Om;var M9=Io("DialogOverlay.RemoveScroll"),I9=j.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,a=Na(Om,r);return i.jsx(vg,{as:M9,allowPinchZoom:!0,shards:[a.contentRef],children:i.jsx(Re.div,{"data-state":eN(a.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),Lo="DialogContent",WI=j.forwardRef((e,t)=>{const r=BI(Lo,e.__scopeDialog),{forceMount:n=r.forceMount,...a}=e,s=Na(Lo,e.__scopeDialog);return i.jsx($s,{present:n||s.open,children:s.modal?i.jsx(R9,{...a,ref:t}):i.jsx($9,{...a,ref:t})})});WI.displayName=Lo;var R9=j.forwardRef((e,t)=>{const r=Na(Lo,e.__scopeDialog),n=j.useRef(null),a=Ye(t,r.contentRef,n);return j.useEffect(()=>{const s=n.current;if(s)return Q1(s)},[]),i.jsx(HI,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:je(e.onCloseAutoFocus,s=>{var o;s.preventDefault(),(o=r.triggerRef.current)==null||o.focus()}),onPointerDownOutside:je(e.onPointerDownOutside,s=>{const o=s.detail.originalEvent,l=o.button===0&&o.ctrlKey===!0;(o.button===2||l)&&s.preventDefault()}),onFocusOutside:je(e.onFocusOutside,s=>s.preventDefault())})}),$9=j.forwardRef((e,t)=>{const r=Na(Lo,e.__scopeDialog),n=j.useRef(!1),a=j.useRef(!1);return i.jsx(HI,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,l;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(n.current||(l=r.triggerRef.current)==null||l.focus(),s.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:s=>{var c,u;(c=e.onInteractOutside)==null||c.call(e,s),s.defaultPrevented||(n.current=!0,s.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=s.target;((u=r.triggerRef.current)==null?void 0:u.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&a.current&&s.preventDefault()}})}),HI=j.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:s,...o}=e,l=Na(Lo,r),c=j.useRef(null),u=Ye(t,c);return Y1(),i.jsxs(i.Fragment,{children:[i.jsx(pg,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:s,children:i.jsx(Xf,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":eN(l.open),...o,ref:u,onDismiss:()=>l.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(F9,{titleId:l.titleId}),i.jsx(U9,{contentRef:c,descriptionId:l.descriptionId})]})]})}),J1="DialogTitle",VI=j.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,a=Na(J1,r);return i.jsx(Re.h2,{id:a.titleId,...n,ref:t})});VI.displayName=J1;var qI="DialogDescription",GI=j.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,a=Na(qI,r);return i.jsx(Re.p,{id:a.descriptionId,...n,ref:t})});GI.displayName=qI;var KI="DialogClose",YI=j.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,a=Na(KI,r);return i.jsx(Re.button,{type:"button",...n,ref:t,onClick:je(e.onClick,()=>a.onOpenChange(!1))})});YI.displayName=KI;function eN(e){return e?"open":"closed"}var QI="DialogTitleWarning",[L9,XI]=qz(QI,{contentName:Lo,titleName:J1,docsSlug:"dialog"}),F9=({titleId:e})=>{const t=XI(QI),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users. If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component. For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return j.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},B9="DialogDescriptionWarning",U9=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${XI(B9).contentName}}.`;return j.useEffect(()=>{var s;const a=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},tN=$I,rN=FI,nN=UI,th=zI,rh=WI,nh=VI,ah=GI,gg=YI;const zt=tN,Pm=rN,z9=nN,ZI=j.forwardRef(({className:e,...t},r)=>i.jsx(th,{ref:r,className:ue("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));ZI.displayName=th.displayName;const $t=j.forwardRef(({className:e,children:t,...r},n)=>i.jsxs(z9,{children:[i.jsx(ZI,{}),i.jsxs(rh,{ref:n,className:ue("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...r,children:[t,i.jsxs(gg,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[i.jsx(su,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));$t.displayName=rh.displayName;const Lt=({className:e,...t})=>i.jsx("div",{className:ue("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Lt.displayName="DialogHeader";const Oi=({className:e,...t})=>i.jsx("div",{className:ue("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Oi.displayName="DialogFooter";const Ft=j.forwardRef(({className:e,...t},r)=>i.jsx(nh,{ref:r,className:ue("text-lg font-semibold leading-none tracking-tight",e),...t}));Ft.displayName=nh.displayName;const Wa=j.forwardRef(({className:e,...t},r)=>i.jsx(ah,{ref:r,className:ue("text-sm text-muted-foreground",e),...t}));Wa.displayName=ah.displayName;function qn(){const[e,t]=j.useState(null),[r,n]=j.useState(!0),[a,s]=j.useState(!1),o=j.useRef(!1),l=async()=>{if(!o.current){o.current=!0;try{const u=await fetch("/api/auth/me");if(u.ok){const f=await u.json();t(f),s(!0)}else t(null),s(!1)}catch(u){console.log("Auth check failed (this is normal in production):",u),t(null),s(!1)}finally{n(!1)}}},c=async()=>{o.current=!1,n(!0),await l()};return j.useEffect(()=>{l()},[]),{user:e,isLoading:r,isAuthenticated:a,refreshAuth:c}}function ih({children:e,title:t="Dashboard",subtitle:r,showBackButton:n=!1,headerActions:a}){const{user:s}=qn(),[o]=Qf(),[l,c]=j.useState(!1),[u,f]=j.useState(3);if(j.useEffect(()=>{c(!1)},[o]),!s)return null;const h=[{label:"Dashboard",href:"/",icon:q1,roles:["super_admin","approver","sales_clerk","management","sales_officer"]},{label:"Order Tracking",href:"/tracking",icon:Xr,roles:["sales_officer"]},{label:"Orders",href:"/orders",icon:Et,roles:["super_admin","approver","sales_clerk","management"]},{label:"Users",href:"/users",icon:Ss,roles:["super_admin"]},{label:"Approvals",href:"/approvals",icon:ct,roles:["super_admin","approver","management"]},{label:"Sales Clerk",href:"/sales-clerk",icon:Ot,roles:["super_admin","sales_clerk"]},{label:"Reports",href:"/reports",icon:Xr,roles:["super_admin","approver","management"]},{label:"Analytics",href:"/analytics",icon:Xr,roles:["super_admin","approver","sales_clerk","management"]},{label:"Payment Reports",href:"/payment-reports",icon:Ka,roles:["super_admin","approver","management"]},{label:"My Payment Tracking",href:"/my-payment-tracking",icon:Ka,roles:["sales_officer"]},{label:"Bot Management",href:"/bot",icon:ha,roles:["super_admin"]}].filter(m=>m.roles.includes((s==null?void 0:s.role)||"")),p=()=>{const m=s;return m!=null&&m.firstName&&(m!=null&&m.lastName)?`${m.firstName.charAt(0)}${m.lastName.charAt(0)}`.toUpperCase():m!=null&&m.email?m.email.substring(0,2).toUpperCase():"U"},y=()=>{const m=s;return m!=null&&m.firstName&&(m!=null&&m.lastName)?`${m.firstName} ${m.lastName}`:m!=null&&m.email?m.email:"User"},v=()=>({super_admin:"Super Admin",approver:"Approver",sales_clerk:"Sales Clerk",management:"Management",sales_officer:"Sales Officer"})[s==null?void 0:s.role]||(s==null?void 0:s.role);return i.jsxs("div",{className:"min-h-screen bg-gray-50 flex flex-col",children:[i.jsx("header",{className:"bg-white border-b border-gray-200 sticky top-0 z-50 shadow-sm",children:i.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[i.jsxs("div",{className:"flex items-center space-x-3 flex-1 min-w-0",children:[i.jsx(z,{variant:"ghost",size:"sm",className:"p-2 hover:bg-gray-100 rounded-lg",onClick:()=>c(!0),children:i.jsx(fI,{className:"w-5 h-5 text-gray-600"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("h1",{className:"text-lg font-semibold text-gray-900 truncate",children:t}),r&&i.jsx("p",{className:"text-sm text-gray-500 truncate",children:r})]})]}),i.jsxs("div",{className:"flex items-center space-x-2",children:[a,i.jsxs(z,{variant:"ghost",size:"sm",className:"relative p-2 hover:bg-gray-100 rounded-lg",children:[i.jsx(Bl,{className:"w-5 h-5 text-gray-600"}),u>0&&i.jsx(te,{className:"absolute -top-1 -right-1 h-5 w-5 p-0 text-xs bg-red-500 hover:bg-red-500",children:u})]}),i.jsx("div",{className:"w-8 h-8 bg-blue-600 text-white rounded-full flex items-center justify-center text-sm font-medium",children:p()})]})]})}),i.jsx("main",{className:"flex-1 overflow-hidden",children:i.jsx("div",{className:"h-full p-4 overflow-y-auto",children:e})}),l&&i.jsx("div",{className:"fixed inset-0 z-50 bg-black bg-opacity-50",onClick:()=>c(!1),children:i.jsxs("div",{className:"fixed left-0 top-0 h-full w-80 bg-white shadow-2xl transform transition-transform duration-300 ease-in-out",onClick:m=>m.stopPropagation(),children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200",children:[i.jsxs("div",{className:"flex items-center space-x-3",children:[i.jsx("div",{className:"w-8 h-8 bg-gradient-to-r from-blue-600 to-purple-600 rounded-lg flex items-center justify-center",children:i.jsx(ha,{className:"w-5 h-5 text-white"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"text-lg font-bold text-gray-900",children:"DOK TOK"}),i.jsx("p",{className:"text-sm text-gray-500",children:"Sales Management"})]})]}),i.jsx(z,{variant:"ghost",size:"sm",className:"p-2 hover:bg-gray-100 rounded-lg",onClick:()=>c(!1),children:i.jsx(su,{className:"w-5 h-5 text-gray-600"})})]}),i.jsx("div",{className:"p-4 bg-gray-50 border-b border-gray-200",children:i.jsxs("div",{className:"flex items-center space-x-3",children:[i.jsx("div",{className:"w-12 h-12 bg-gradient-to-r from-blue-600 to-purple-600 text-white rounded-full flex items-center justify-center",children:i.jsx("span",{className:"text-sm font-bold",children:p()})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"text-sm font-semibold text-gray-900 truncate",children:y()}),i.jsx("p",{className:"text-xs text-gray-500 truncate",children:v()})]})]})}),i.jsx("nav",{className:"flex-1 p-4 space-y-2 overflow-y-auto",children:h.map(m=>{const x=m.icon,g=o===m.href;return i.jsx(gM,{href:m.href,children:i.jsxs(z,{variant:"ghost",className:ue("w-full justify-start h-12 px-3 text-left transition-all duration-200 rounded-lg",g?"bg-blue-50 text-blue-700 border border-blue-200":"hover:bg-gray-50 text-gray-700"),children:[i.jsx(x,{className:ue("w-5 h-5 mr-3",g?"text-blue-600":"text-gray-500")}),i.jsx("span",{className:"font-medium",children:m.label})]})},m.href)})}),i.jsx("div",{className:"border-t border-gray-200 p-4",children:i.jsxs(z,{variant:"ghost",className:"w-full justify-start h-12 text-gray-600 hover:text-red-600 hover:bg-red-50 transition-colors duration-200 rounded-lg",onClick:async()=>{try{await fetch("/api/auth/logout"),window.location.href="/login"}catch{window.location.href="/login"}},children:[i.jsx(uI,{className:"w-5 h-5 mr-3"}),i.jsx("span",{className:"font-medium",children:"Sign Out"})]})})]})})]})}const he=j.forwardRef(({className:e,type:t,...r},n)=>i.jsx("input",{type:t,className:ue("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...r}));he.displayName="Input";var W9="Label",JI=j.forwardRef((e,t)=>i.jsx(Re.label,{...e,ref:t,onMouseDown:r=>{var a;r.target.closest("button, input, select, textarea")||((a=e.onMouseDown)==null||a.call(e,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));JI.displayName=W9;var eR=JI;const H9=Jf("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),X=j.forwardRef(({className:e,...t},r)=>i.jsx(eR,{ref:r,className:ue(H9(),e),...t}));X.displayName=eR.displayName;const Wn=j.forwardRef(({className:e,...t},r)=>i.jsx("textarea",{className:ue("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...t}));Wn.displayName="Textarea";function pA(e,[t,r]){return Math.min(r,Math.max(t,e))}var V9=j.createContext(void 0);function aN(e){const t=j.useContext(V9);return e||t||"ltr"}const q9=["top","right","bottom","left"],Os=Math.min,on=Math.max,Am=Math.round,lp=Math.floor,Ha=e=>({x:e,y:e}),G9={left:"right",right:"left",bottom:"top",top:"bottom"},K9={start:"end",end:"start"};function qb(e,t,r){return on(e,Os(t,r))}function Pi(e,t){return typeof e=="function"?e(t):e}function Ai(e){return e.split("-")[0]}function lu(e){return e.split("-")[1]}function iN(e){return e==="x"?"y":"x"}function sN(e){return e==="y"?"height":"width"}function Ps(e){return["top","bottom"].includes(Ai(e))?"y":"x"}function oN(e){return iN(Ps(e))}function Y9(e,t,r){r===void 0&&(r=!1);const n=lu(e),a=oN(e),s=sN(a);let o=a==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=Cm(o)),[o,Cm(o)]}function Q9(e){const t=Cm(e);return[Gb(e),t,Gb(t)]}function Gb(e){return e.replace(/start|end/g,t=>K9[t])}function X9(e,t,r){const n=["left","right"],a=["right","left"],s=["top","bottom"],o=["bottom","top"];switch(e){case"top":case"bottom":return r?t?a:n:t?n:a;case"left":case"right":return t?s:o;default:return[]}}function Z9(e,t,r,n){const a=lu(e);let s=X9(Ai(e),r==="start",n);return a&&(s=s.map(o=>o+"-"+a),t&&(s=s.concat(s.map(Gb)))),s}function Cm(e){return e.replace(/left|right|bottom|top/g,t=>G9[t])}function J9(e){return{top:0,right:0,bottom:0,left:0,...e}}function tR(e){return typeof e!="number"?J9(e):{top:e,right:e,bottom:e,left:e}}function Em(e){const{x:t,y:r,width:n,height:a}=e;return{width:n,height:a,top:r,left:t,right:t+n,bottom:r+a,x:t,y:r}}function mA(e,t,r){let{reference:n,floating:a}=e;const s=Ps(t),o=oN(t),l=sN(o),c=Ai(t),u=s==="y",f=n.x+n.width/2-a.width/2,d=n.y+n.height/2-a.height/2,h=n[l]/2-a[l]/2;let p;switch(c){case"top":p={x:f,y:n.y-a.height};break;case"bottom":p={x:f,y:n.y+n.height};break;case"right":p={x:n.x+n.width,y:d};break;case"left":p={x:n.x-a.width,y:d};break;default:p={x:n.x,y:n.y}}switch(lu(t)){case"start":p[o]-=h*(r&&u?-1:1);break;case"end":p[o]+=h*(r&&u?-1:1);break}return p}const eH=async(e,t,r)=>{const{placement:n="bottom",strategy:a="absolute",middleware:s=[],platform:o}=r,l=s.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(t));let u=await o.getElementRects({reference:e,floating:t,strategy:a}),{x:f,y:d}=mA(u,n,c),h=n,p={},y=0;for(let v=0;v({name:"arrow",options:e,async fn(t){const{x:r,y:n,placement:a,rects:s,platform:o,elements:l,middlewareData:c}=t,{element:u,padding:f=0}=Pi(e,t)||{};if(u==null)return{};const d=tR(f),h={x:r,y:n},p=oN(a),y=sN(p),v=await o.getDimensions(u),m=p==="y",x=m?"top":"left",g=m?"bottom":"right",b=m?"clientHeight":"clientWidth",N=s.reference[y]+s.reference[p]-h[p]-s.floating[y],w=h[p]-s.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(u));let O=S?S[b]:0;(!O||!await(o.isElement==null?void 0:o.isElement(S)))&&(O=l.floating[b]||s.floating[y]);const P=N/2-w/2,A=O/2-v[y]/2-1,C=Os(d[x],A),T=Os(d[g],A),D=C,_=O-v[y]-T,k=O/2-v[y]/2+P,R=qb(D,k,_),$=!c.arrow&&lu(a)!=null&&k!==R&&s.reference[y]/2-(kk<=0)){var T,D;const k=(((T=s.flip)==null?void 0:T.index)||0)+1,R=O[k];if(R)return{data:{index:k,overflows:C},reset:{placement:R}};let $=(D=C.filter(I=>I.overflows[0]<=0).sort((I,E)=>I.overflows[1]-E.overflows[1])[0])==null?void 0:D.placement;if(!$)switch(p){case"bestFit":{var _;const I=(_=C.filter(E=>{if(S){const F=Ps(E.placement);return F===g||F==="y"}return!0}).map(E=>[E.placement,E.overflows.filter(F=>F>0).reduce((F,V)=>F+V,0)]).sort((E,F)=>E[1]-F[1])[0])==null?void 0:_[0];I&&($=I);break}case"initialPlacement":$=l;break}if(a!==$)return{reset:{placement:$}}}return{}}}};function vA(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function gA(e){return q9.some(t=>e[t]>=0)}const nH=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r}=t,{strategy:n="referenceHidden",...a}=Pi(e,t);switch(n){case"referenceHidden":{const s=await Yd(t,{...a,elementContext:"reference"}),o=vA(s,r.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:gA(o)}}}case"escaped":{const s=await Yd(t,{...a,altBoundary:!0}),o=vA(s,r.floating);return{data:{escapedOffsets:o,escaped:gA(o)}}}default:return{}}}}};async function aH(e,t){const{placement:r,platform:n,elements:a}=e,s=await(n.isRTL==null?void 0:n.isRTL(a.floating)),o=Ai(r),l=lu(r),c=Ps(r)==="y",u=["left","top"].includes(o)?-1:1,f=s&&c?-1:1,d=Pi(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:y}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return l&&typeof y=="number"&&(p=l==="end"?y*-1:y),c?{x:p*f,y:h*u}:{x:h*u,y:p*f}}const iH=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,n;const{x:a,y:s,placement:o,middlewareData:l}=t,c=await aH(t,e);return o===((r=l.offset)==null?void 0:r.placement)&&(n=l.arrow)!=null&&n.alignmentOffset?{}:{x:a+c.x,y:s+c.y,data:{...c,placement:o}}}}},sH=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:n,placement:a}=t,{mainAxis:s=!0,crossAxis:o=!1,limiter:l={fn:m=>{let{x,y:g}=m;return{x,y:g}}},...c}=Pi(e,t),u={x:r,y:n},f=await Yd(t,c),d=Ps(Ai(a)),h=iN(d);let p=u[h],y=u[d];if(s){const m=h==="y"?"top":"left",x=h==="y"?"bottom":"right",g=p+f[m],b=p-f[x];p=qb(g,p,b)}if(o){const m=d==="y"?"top":"left",x=d==="y"?"bottom":"right",g=y+f[m],b=y-f[x];y=qb(g,y,b)}const v=l.fn({...t,[h]:p,[d]:y});return{...v,data:{x:v.x-r,y:v.y-n,enabled:{[h]:s,[d]:o}}}}}},oH=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:n,placement:a,rects:s,middlewareData:o}=t,{offset:l=0,mainAxis:c=!0,crossAxis:u=!0}=Pi(e,t),f={x:r,y:n},d=Ps(a),h=iN(d);let p=f[h],y=f[d];const v=Pi(l,t),m=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(c){const b=h==="y"?"height":"width",N=s.reference[h]-s.floating[b]+m.mainAxis,w=s.reference[h]+s.reference[b]-m.mainAxis;pw&&(p=w)}if(u){var x,g;const b=h==="y"?"width":"height",N=["top","left"].includes(Ai(a)),w=s.reference[d]-s.floating[b]+(N&&((x=o.offset)==null?void 0:x[d])||0)+(N?0:m.crossAxis),S=s.reference[d]+s.reference[b]+(N?0:((g=o.offset)==null?void 0:g[d])||0)-(N?m.crossAxis:0);yS&&(y=S)}return{[h]:p,[d]:y}}}},lH=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,n;const{placement:a,rects:s,platform:o,elements:l}=t,{apply:c=()=>{},...u}=Pi(e,t),f=await Yd(t,u),d=Ai(a),h=lu(a),p=Ps(a)==="y",{width:y,height:v}=s.floating;let m,x;d==="top"||d==="bottom"?(m=d,x=h===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(x=d,m=h==="end"?"top":"bottom");const g=v-f.top-f.bottom,b=y-f.left-f.right,N=Os(v-f[m],g),w=Os(y-f[x],b),S=!t.middlewareData.shift;let O=N,P=w;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(P=b),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(O=g),S&&!h){const C=on(f.left,0),T=on(f.right,0),D=on(f.top,0),_=on(f.bottom,0);p?P=y-2*(C!==0||T!==0?C+T:on(f.left,f.right)):O=v-2*(D!==0||_!==0?D+_:on(f.top,f.bottom))}await c({...t,availableWidth:P,availableHeight:O});const A=await o.getDimensions(l.floating);return y!==A.width||v!==A.height?{reset:{rects:!0}}:{}}}};function yg(){return typeof window<"u"}function cu(e){return rR(e)?(e.nodeName||"").toLowerCase():"#document"}function hn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ja(e){var t;return(t=(rR(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function rR(e){return yg()?e instanceof Node||e instanceof hn(e).Node:!1}function ga(e){return yg()?e instanceof Element||e instanceof hn(e).Element:!1}function Ya(e){return yg()?e instanceof HTMLElement||e instanceof hn(e).HTMLElement:!1}function yA(e){return!yg()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof hn(e).ShadowRoot}function sh(e){const{overflow:t,overflowX:r,overflowY:n,display:a}=ya(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&!["inline","contents"].includes(a)}function cH(e){return["table","td","th"].includes(cu(e))}function xg(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function lN(e){const t=cN(),r=ga(e)?ya(e):e;return["transform","translate","scale","rotate","perspective"].some(n=>r[n]?r[n]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!t&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!t&&(r.filter?r.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(n=>(r.willChange||"").includes(n))||["paint","layout","strict","content"].some(n=>(r.contain||"").includes(n))}function uH(e){let t=As(e);for(;Ya(t)&&!wc(t);){if(lN(t))return t;if(xg(t))return null;t=As(t)}return null}function cN(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function wc(e){return["html","body","#document"].includes(cu(e))}function ya(e){return hn(e).getComputedStyle(e)}function bg(e){return ga(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function As(e){if(cu(e)==="html")return e;const t=e.assignedSlot||e.parentNode||yA(e)&&e.host||Ja(e);return yA(t)?t.host:t}function nR(e){const t=As(e);return wc(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ya(t)&&sh(t)?t:nR(t)}function Qd(e,t,r){var n;t===void 0&&(t=[]),r===void 0&&(r=!0);const a=nR(e),s=a===((n=e.ownerDocument)==null?void 0:n.body),o=hn(a);if(s){const l=Kb(o);return t.concat(o,o.visualViewport||[],sh(a)?a:[],l&&r?Qd(l):[])}return t.concat(a,Qd(a,[],r))}function Kb(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function aR(e){const t=ya(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const a=Ya(e),s=a?e.offsetWidth:r,o=a?e.offsetHeight:n,l=Am(r)!==s||Am(n)!==o;return l&&(r=s,n=o),{width:r,height:n,$:l}}function uN(e){return ga(e)?e:e.contextElement}function Hl(e){const t=uN(e);if(!Ya(t))return Ha(1);const r=t.getBoundingClientRect(),{width:n,height:a,$:s}=aR(t);let o=(s?Am(r.width):r.width)/n,l=(s?Am(r.height):r.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const dH=Ha(0);function iR(e){const t=hn(e);return!cN()||!t.visualViewport?dH:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function fH(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==hn(e)?!1:t}function Fo(e,t,r,n){t===void 0&&(t=!1),r===void 0&&(r=!1);const a=e.getBoundingClientRect(),s=uN(e);let o=Ha(1);t&&(n?ga(n)&&(o=Hl(n)):o=Hl(e));const l=fH(s,r,n)?iR(s):Ha(0);let c=(a.left+l.x)/o.x,u=(a.top+l.y)/o.y,f=a.width/o.x,d=a.height/o.y;if(s){const h=hn(s),p=n&&ga(n)?hn(n):n;let y=h,v=Kb(y);for(;v&&n&&p!==y;){const m=Hl(v),x=v.getBoundingClientRect(),g=ya(v),b=x.left+(v.clientLeft+parseFloat(g.paddingLeft))*m.x,N=x.top+(v.clientTop+parseFloat(g.paddingTop))*m.y;c*=m.x,u*=m.y,f*=m.x,d*=m.y,c+=b,u+=N,y=hn(v),v=Kb(y)}}return Em({width:f,height:d,x:c,y:u})}function dN(e,t){const r=bg(e).scrollLeft;return t?t.left+r:Fo(Ja(e)).left+r}function sR(e,t,r){r===void 0&&(r=!1);const n=e.getBoundingClientRect(),a=n.left+t.scrollLeft-(r?0:dN(e,n)),s=n.top+t.scrollTop;return{x:a,y:s}}function hH(e){let{elements:t,rect:r,offsetParent:n,strategy:a}=e;const s=a==="fixed",o=Ja(n),l=t?xg(t.floating):!1;if(n===o||l&&s)return r;let c={scrollLeft:0,scrollTop:0},u=Ha(1);const f=Ha(0),d=Ya(n);if((d||!d&&!s)&&((cu(n)!=="body"||sh(o))&&(c=bg(n)),Ya(n))){const p=Fo(n);u=Hl(n),f.x=p.x+n.clientLeft,f.y=p.y+n.clientTop}const h=o&&!d&&!s?sR(o,c,!0):Ha(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-c.scrollLeft*u.x+f.x+h.x,y:r.y*u.y-c.scrollTop*u.y+f.y+h.y}}function pH(e){return Array.from(e.getClientRects())}function mH(e){const t=Ja(e),r=bg(e),n=e.ownerDocument.body,a=on(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),s=on(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let o=-r.scrollLeft+dN(e);const l=-r.scrollTop;return ya(n).direction==="rtl"&&(o+=on(t.clientWidth,n.clientWidth)-a),{width:a,height:s,x:o,y:l}}function vH(e,t){const r=hn(e),n=Ja(e),a=r.visualViewport;let s=n.clientWidth,o=n.clientHeight,l=0,c=0;if(a){s=a.width,o=a.height;const u=cN();(!u||u&&t==="fixed")&&(l=a.offsetLeft,c=a.offsetTop)}return{width:s,height:o,x:l,y:c}}function gH(e,t){const r=Fo(e,!0,t==="fixed"),n=r.top+e.clientTop,a=r.left+e.clientLeft,s=Ya(e)?Hl(e):Ha(1),o=e.clientWidth*s.x,l=e.clientHeight*s.y,c=a*s.x,u=n*s.y;return{width:o,height:l,x:c,y:u}}function xA(e,t,r){let n;if(t==="viewport")n=vH(e,r);else if(t==="document")n=mH(Ja(e));else if(ga(t))n=gH(t,r);else{const a=iR(e);n={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return Em(n)}function oR(e,t){const r=As(e);return r===t||!ga(r)||wc(r)?!1:ya(r).position==="fixed"||oR(r,t)}function yH(e,t){const r=t.get(e);if(r)return r;let n=Qd(e,[],!1).filter(l=>ga(l)&&cu(l)!=="body"),a=null;const s=ya(e).position==="fixed";let o=s?As(e):e;for(;ga(o)&&!wc(o);){const l=ya(o),c=lN(o);!c&&l.position==="fixed"&&(a=null),(s?!c&&!a:!c&&l.position==="static"&&!!a&&["absolute","fixed"].includes(a.position)||sh(o)&&!c&&oR(e,o))?n=n.filter(f=>f!==o):a=l,o=As(o)}return t.set(e,n),n}function xH(e){let{element:t,boundary:r,rootBoundary:n,strategy:a}=e;const o=[...r==="clippingAncestors"?xg(t)?[]:yH(t,this._c):[].concat(r),n],l=o[0],c=o.reduce((u,f)=>{const d=xA(t,f,a);return u.top=on(d.top,u.top),u.right=Os(d.right,u.right),u.bottom=Os(d.bottom,u.bottom),u.left=on(d.left,u.left),u},xA(t,l,a));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function bH(e){const{width:t,height:r}=aR(e);return{width:t,height:r}}function jH(e,t,r){const n=Ya(t),a=Ja(t),s=r==="fixed",o=Fo(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const c=Ha(0);if(n||!n&&!s)if((cu(t)!=="body"||sh(a))&&(l=bg(t)),n){const h=Fo(t,!0,s,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else a&&(c.x=dN(a));const u=a&&!n&&!s?sR(a,l):Ha(0),f=o.left+l.scrollLeft-c.x-u.x,d=o.top+l.scrollTop-c.y-u.y;return{x:f,y:d,width:o.width,height:o.height}}function Px(e){return ya(e).position==="static"}function bA(e,t){if(!Ya(e)||ya(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return Ja(e)===r&&(r=r.ownerDocument.body),r}function lR(e,t){const r=hn(e);if(xg(e))return r;if(!Ya(e)){let a=As(e);for(;a&&!wc(a);){if(ga(a)&&!Px(a))return a;a=As(a)}return r}let n=bA(e,t);for(;n&&cH(n)&&Px(n);)n=bA(n,t);return n&&wc(n)&&Px(n)&&!lN(n)?r:n||uH(e)||r}const wH=async function(e){const t=this.getOffsetParent||lR,r=this.getDimensions,n=await r(e.floating);return{reference:jH(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function NH(e){return ya(e).direction==="rtl"}const SH={convertOffsetParentRelativeRectToViewportRelativeRect:hH,getDocumentElement:Ja,getClippingRect:xH,getOffsetParent:lR,getElementRects:wH,getClientRects:pH,getDimensions:bH,getScale:Hl,isElement:ga,isRTL:NH};function cR(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function OH(e,t){let r=null,n;const a=Ja(e);function s(){var l;clearTimeout(n),(l=r)==null||l.disconnect(),r=null}function o(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),s();const u=e.getBoundingClientRect(),{left:f,top:d,width:h,height:p}=u;if(l||t(),!h||!p)return;const y=lp(d),v=lp(a.clientWidth-(f+h)),m=lp(a.clientHeight-(d+p)),x=lp(f),b={rootMargin:-y+"px "+-v+"px "+-m+"px "+-x+"px",threshold:on(0,Os(1,c))||1};let N=!0;function w(S){const O=S[0].intersectionRatio;if(O!==c){if(!N)return o();O?o(!1,O):n=setTimeout(()=>{o(!1,1e-7)},1e3)}O===1&&!cR(u,e.getBoundingClientRect())&&o(),N=!1}try{r=new IntersectionObserver(w,{...b,root:a.ownerDocument})}catch{r=new IntersectionObserver(w,b)}r.observe(e)}return o(!0),s}function PH(e,t,r,n){n===void 0&&(n={});const{ancestorScroll:a=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=n,u=uN(e),f=a||s?[...u?Qd(u):[],...Qd(t)]:[];f.forEach(x=>{a&&x.addEventListener("scroll",r,{passive:!0}),s&&x.addEventListener("resize",r)});const d=u&&l?OH(u,r):null;let h=-1,p=null;o&&(p=new ResizeObserver(x=>{let[g]=x;g&&g.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var b;(b=p)==null||b.observe(t)})),r()}),u&&!c&&p.observe(u),p.observe(t));let y,v=c?Fo(e):null;c&&m();function m(){const x=Fo(e);v&&!cR(v,x)&&r(),v=x,y=requestAnimationFrame(m)}return r(),()=>{var x;f.forEach(g=>{a&&g.removeEventListener("scroll",r),s&&g.removeEventListener("resize",r)}),d==null||d(),(x=p)==null||x.disconnect(),p=null,c&&cancelAnimationFrame(y)}}const AH=iH,CH=sH,EH=rH,TH=lH,kH=nH,jA=tH,_H=oH,DH=(e,t,r)=>{const n=new Map,a={platform:SH,...r},s={...a.platform,_c:n};return eH(e,t,{...a,platform:s})};var Kp=typeof document<"u"?j.useLayoutEffect:j.useEffect;function Tm(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,n,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(n=r;n--!==0;)if(!Tm(e[n],t[n]))return!1;return!0}if(a=Object.keys(e),r=a.length,r!==Object.keys(t).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(t,a[n]))return!1;for(n=r;n--!==0;){const s=a[n];if(!(s==="_owner"&&e.$$typeof)&&!Tm(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function uR(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function wA(e,t){const r=uR(e);return Math.round(t*r)/r}function Ax(e){const t=j.useRef(e);return Kp(()=>{t.current=e}),t}function MH(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:n=[],platform:a,elements:{reference:s,floating:o}={},transform:l=!0,whileElementsMounted:c,open:u}=e,[f,d]=j.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=j.useState(n);Tm(h,n)||p(n);const[y,v]=j.useState(null),[m,x]=j.useState(null),g=j.useCallback(E=>{E!==S.current&&(S.current=E,v(E))},[]),b=j.useCallback(E=>{E!==O.current&&(O.current=E,x(E))},[]),N=s||y,w=o||m,S=j.useRef(null),O=j.useRef(null),P=j.useRef(f),A=c!=null,C=Ax(c),T=Ax(a),D=Ax(u),_=j.useCallback(()=>{if(!S.current||!O.current)return;const E={placement:t,strategy:r,middleware:h};T.current&&(E.platform=T.current),DH(S.current,O.current,E).then(F=>{const V={...F,isPositioned:D.current!==!1};k.current&&!Tm(P.current,V)&&(P.current=V,Rs.flushSync(()=>{d(V)}))})},[h,t,r,T,D]);Kp(()=>{u===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,d(E=>({...E,isPositioned:!1})))},[u]);const k=j.useRef(!1);Kp(()=>(k.current=!0,()=>{k.current=!1}),[]),Kp(()=>{if(N&&(S.current=N),w&&(O.current=w),N&&w){if(C.current)return C.current(N,w,_);_()}},[N,w,_,C,A]);const R=j.useMemo(()=>({reference:S,floating:O,setReference:g,setFloating:b}),[g,b]),$=j.useMemo(()=>({reference:N,floating:w}),[N,w]),I=j.useMemo(()=>{const E={position:r,left:0,top:0};if(!$.floating)return E;const F=wA($.floating,f.x),V=wA($.floating,f.y);return l?{...E,transform:"translate("+F+"px, "+V+"px)",...uR($.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:F,top:V}},[r,l,$.floating,f.x,f.y]);return j.useMemo(()=>({...f,update:_,refs:R,elements:$,floatingStyles:I}),[f,_,R,$,I])}const IH=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:n,padding:a}=typeof e=="function"?e(r):e;return n&&t(n)?n.current!=null?jA({element:n.current,padding:a}).fn(r):{}:n?jA({element:n,padding:a}).fn(r):{}}}},RH=(e,t)=>({...AH(e),options:[e,t]}),$H=(e,t)=>({...CH(e),options:[e,t]}),LH=(e,t)=>({..._H(e),options:[e,t]}),FH=(e,t)=>({...EH(e),options:[e,t]}),BH=(e,t)=>({...TH(e),options:[e,t]}),UH=(e,t)=>({...kH(e),options:[e,t]}),zH=(e,t)=>({...IH(e),options:[e,t]});var WH="Arrow",dR=j.forwardRef((e,t)=>{const{children:r,width:n=10,height:a=5,...s}=e;return i.jsx(Re.svg,{...s,ref:t,width:n,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:i.jsx("polygon",{points:"0,0 30,0 15,10"})})});dR.displayName=WH;var HH=dR;function fN(e){const[t,r]=j.useState(void 0);return Jt(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const n=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const s=a[0];let o,l;if("borderBoxSize"in s){const c=s.borderBoxSize,u=Array.isArray(c)?c[0]:c;o=u.inlineSize,l=u.blockSize}else o=e.offsetWidth,l=e.offsetHeight;r({width:o,height:l})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}else r(void 0)},[e]),t}var hN="Popper",[fR,jg]=wn(hN),[VH,hR]=fR(hN),pR=e=>{const{__scopePopper:t,children:r}=e,[n,a]=j.useState(null);return i.jsx(VH,{scope:t,anchor:n,onAnchorChange:a,children:r})};pR.displayName=hN;var mR="PopperAnchor",vR=j.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:n,...a}=e,s=hR(mR,r),o=j.useRef(null),l=Ye(t,o);return j.useEffect(()=>{s.onAnchorChange((n==null?void 0:n.current)||o.current)}),n?null:i.jsx(Re.div,{...a,ref:l})});vR.displayName=mR;var pN="PopperContent",[qH,GH]=fR(pN),gR=j.forwardRef((e,t)=>{var ie,ve,re,Y,Z,L;const{__scopePopper:r,side:n="bottom",sideOffset:a=0,align:s="center",alignOffset:o=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:f=0,sticky:d="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:y,...v}=e,m=hR(pN,r),[x,g]=j.useState(null),b=Ye(t,ce=>g(ce)),[N,w]=j.useState(null),S=fN(N),O=(S==null?void 0:S.width)??0,P=(S==null?void 0:S.height)??0,A=n+(s!=="center"?"-"+s:""),C=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},T=Array.isArray(u)?u:[u],D=T.length>0,_={padding:C,boundary:T.filter(YH),altBoundary:D},{refs:k,floatingStyles:R,placement:$,isPositioned:I,middlewareData:E}=MH({strategy:"fixed",placement:A,whileElementsMounted:(...ce)=>PH(...ce,{animationFrame:p==="always"}),elements:{reference:m.anchor},middleware:[RH({mainAxis:a+P,alignmentAxis:o}),c&&$H({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?LH():void 0,..._}),c&&FH({..._}),BH({..._,apply:({elements:ce,rects:ye,availableWidth:We,availableHeight:Je})=>{const{width:ht,height:Lr}=ye.reference,Vt=ce.floating.style;Vt.setProperty("--radix-popper-available-width",`${We}px`),Vt.setProperty("--radix-popper-available-height",`${Je}px`),Vt.setProperty("--radix-popper-anchor-width",`${ht}px`),Vt.setProperty("--radix-popper-anchor-height",`${Lr}px`)}}),N&&zH({element:N,padding:l}),QH({arrowWidth:O,arrowHeight:P}),h&&UH({strategy:"referenceHidden",..._})]}),[F,V]=bR($),G=Jr(y);Jt(()=>{I&&(G==null||G())},[I,G]);const K=(ie=E.arrow)==null?void 0:ie.x,q=(ve=E.arrow)==null?void 0:ve.y,ne=((re=E.arrow)==null?void 0:re.centerOffset)!==0,[le,de]=j.useState();return Jt(()=>{x&&de(window.getComputedStyle(x).zIndex)},[x]),i.jsx("div",{ref:k.setFloating,"data-radix-popper-content-wrapper":"",style:{...R,transform:I?R.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:le,"--radix-popper-transform-origin":[(Y=E.transformOrigin)==null?void 0:Y.x,(Z=E.transformOrigin)==null?void 0:Z.y].join(" "),...((L=E.hide)==null?void 0:L.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:i.jsx(qH,{scope:r,placedSide:F,onArrowChange:w,arrowX:K,arrowY:q,shouldHideArrow:ne,children:i.jsx(Re.div,{"data-side":F,"data-align":V,...v,ref:b,style:{...v.style,animation:I?void 0:"none"}})})})});gR.displayName=pN;var yR="PopperArrow",KH={top:"bottom",right:"left",bottom:"top",left:"right"},xR=j.forwardRef(function(t,r){const{__scopePopper:n,...a}=t,s=GH(yR,n),o=KH[s.placedSide];return i.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:i.jsx(HH,{...a,ref:r,style:{...a.style,display:"block"}})})});xR.displayName=yR;function YH(e){return e!==null}var QH=e=>({name:"transformOrigin",options:e,fn(t){var m,x,g;const{placement:r,rects:n,middlewareData:a}=t,o=((m=a.arrow)==null?void 0:m.centerOffset)!==0,l=o?0:e.arrowWidth,c=o?0:e.arrowHeight,[u,f]=bR(r),d={start:"0%",center:"50%",end:"100%"}[f],h=(((x=a.arrow)==null?void 0:x.x)??0)+l/2,p=(((g=a.arrow)==null?void 0:g.y)??0)+c/2;let y="",v="";return u==="bottom"?(y=o?d:`${h}px`,v=`${-c}px`):u==="top"?(y=o?d:`${h}px`,v=`${n.floating.height+c}px`):u==="right"?(y=`${-c}px`,v=o?d:`${p}px`):u==="left"&&(y=`${n.floating.width+c}px`,v=o?d:`${p}px`),{data:{x:y,y:v}}}});function bR(e){const[t,r="center"]=e.split("-");return[t,r]}var jR=pR,mN=vR,wR=gR,NR=xR;function vN(e){const t=j.useRef({value:e,previous:e});return j.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var XH=[" ","Enter","ArrowUp","ArrowDown"],ZH=[" ","Enter"],oh="Select",[wg,Ng,JH]=RM(oh),[uu,LCe]=wn(oh,[JH,jg]),Sg=jg(),[eV,Ls]=uu(oh),[tV,rV]=uu(oh),SR=e=>{const{__scopeSelect:t,children:r,open:n,defaultOpen:a,onOpenChange:s,value:o,defaultValue:l,onValueChange:c,dir:u,name:f,autoComplete:d,disabled:h,required:p,form:y}=e,v=Sg(t),[m,x]=j.useState(null),[g,b]=j.useState(null),[N,w]=j.useState(!1),S=aN(u),[O=!1,P]=Ro({prop:n,defaultProp:a,onChange:s}),[A,C]=Ro({prop:o,defaultProp:l,onChange:c}),T=j.useRef(null),D=m?y||!!m.closest("form"):!0,[_,k]=j.useState(new Set),R=Array.from(_).map($=>$.props.value).join(";");return i.jsx(jR,{...v,children:i.jsxs(eV,{required:p,scope:t,trigger:m,onTriggerChange:x,valueNode:g,onValueNodeChange:b,valueNodeHasChildren:N,onValueNodeHasChildrenChange:w,contentId:gi(),value:A,onValueChange:C,open:O,onOpenChange:P,dir:S,triggerPointerDownPosRef:T,disabled:h,children:[i.jsx(wg.Provider,{scope:t,children:i.jsx(tV,{scope:e.__scopeSelect,onNativeOptionAdd:j.useCallback($=>{k(I=>new Set(I).add($))},[]),onNativeOptionRemove:j.useCallback($=>{k(I=>{const E=new Set(I);return E.delete($),E})},[]),children:r})}),D?i.jsxs(YR,{"aria-hidden":!0,required:p,tabIndex:-1,name:f,autoComplete:d,value:A,onChange:$=>C($.target.value),disabled:h,form:y,children:[A===void 0?i.jsx("option",{value:""}):null,Array.from(_)]},R):null]})})};SR.displayName=oh;var OR="SelectTrigger",PR=j.forwardRef((e,t)=>{const{__scopeSelect:r,disabled:n=!1,...a}=e,s=Sg(r),o=Ls(OR,r),l=o.disabled||n,c=Ye(t,o.onTriggerChange),u=Ng(r),f=j.useRef("touch"),[d,h,p]=QR(v=>{const m=u().filter(b=>!b.disabled),x=m.find(b=>b.value===o.value),g=XR(m,v,x);g!==void 0&&o.onValueChange(g.value)}),y=v=>{l||(o.onOpenChange(!0),p()),v&&(o.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return i.jsx(mN,{asChild:!0,...s,children:i.jsx(Re.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":KR(o.value)?"":void 0,...a,ref:c,onClick:je(a.onClick,v=>{v.currentTarget.focus(),f.current!=="mouse"&&y(v)}),onPointerDown:je(a.onPointerDown,v=>{f.current=v.pointerType;const m=v.target;m.hasPointerCapture(v.pointerId)&&m.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(y(v),v.preventDefault())}),onKeyDown:je(a.onKeyDown,v=>{const m=d.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&h(v.key),!(m&&v.key===" ")&&XH.includes(v.key)&&(y(),v.preventDefault())})})})});PR.displayName=OR;var AR="SelectValue",CR=j.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:a,children:s,placeholder:o="",...l}=e,c=Ls(AR,r),{onValueNodeHasChildrenChange:u}=c,f=s!==void 0,d=Ye(t,c.onValueNodeChange);return Jt(()=>{u(f)},[u,f]),i.jsx(Re.span,{...l,ref:d,style:{pointerEvents:"none"},children:KR(c.value)?i.jsx(i.Fragment,{children:o}):s})});CR.displayName=AR;var nV="SelectIcon",ER=j.forwardRef((e,t)=>{const{__scopeSelect:r,children:n,...a}=e;return i.jsx(Re.span,{"aria-hidden":!0,...a,ref:t,children:n||"▼"})});ER.displayName=nV;var aV="SelectPortal",TR=e=>i.jsx(Zf,{asChild:!0,...e});TR.displayName=aV;var Bo="SelectContent",kR=j.forwardRef((e,t)=>{const r=Ls(Bo,e.__scopeSelect),[n,a]=j.useState();if(Jt(()=>{a(new DocumentFragment)},[]),!r.open){const s=n;return s?Rs.createPortal(i.jsx(_R,{scope:e.__scopeSelect,children:i.jsx(wg.Slot,{scope:e.__scopeSelect,children:i.jsx("div",{children:e.children})})}),s):null}return i.jsx(DR,{...e,ref:t})});kR.displayName=Bo;var Zn=10,[_R,Fs]=uu(Bo),iV="SelectContentImpl",sV=Io("SelectContent.RemoveScroll"),DR=j.forwardRef((e,t)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:s,onPointerDownOutside:o,side:l,sideOffset:c,align:u,alignOffset:f,arrowPadding:d,collisionBoundary:h,collisionPadding:p,sticky:y,hideWhenDetached:v,avoidCollisions:m,...x}=e,g=Ls(Bo,r),[b,N]=j.useState(null),[w,S]=j.useState(null),O=Ye(t,ie=>N(ie)),[P,A]=j.useState(null),[C,T]=j.useState(null),D=Ng(r),[_,k]=j.useState(!1),R=j.useRef(!1);j.useEffect(()=>{if(b)return Q1(b)},[b]),Y1();const $=j.useCallback(ie=>{const[ve,...re]=D().map(L=>L.ref.current),[Y]=re.slice(-1),Z=document.activeElement;for(const L of ie)if(L===Z||(L==null||L.scrollIntoView({block:"nearest"}),L===ve&&w&&(w.scrollTop=0),L===Y&&w&&(w.scrollTop=w.scrollHeight),L==null||L.focus(),document.activeElement!==Z))return},[D,w]),I=j.useCallback(()=>$([P,b]),[$,P,b]);j.useEffect(()=>{_&&I()},[_,I]);const{onOpenChange:E,triggerPointerDownPosRef:F}=g;j.useEffect(()=>{if(b){let ie={x:0,y:0};const ve=Y=>{var Z,L;ie={x:Math.abs(Math.round(Y.pageX)-(((Z=F.current)==null?void 0:Z.x)??0)),y:Math.abs(Math.round(Y.pageY)-(((L=F.current)==null?void 0:L.y)??0))}},re=Y=>{ie.x<=10&&ie.y<=10?Y.preventDefault():b.contains(Y.target)||E(!1),document.removeEventListener("pointermove",ve),F.current=null};return F.current!==null&&(document.addEventListener("pointermove",ve),document.addEventListener("pointerup",re,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ve),document.removeEventListener("pointerup",re,{capture:!0})}}},[b,E,F]),j.useEffect(()=>{const ie=()=>E(!1);return window.addEventListener("blur",ie),window.addEventListener("resize",ie),()=>{window.removeEventListener("blur",ie),window.removeEventListener("resize",ie)}},[E]);const[V,G]=QR(ie=>{const ve=D().filter(Z=>!Z.disabled),re=ve.find(Z=>Z.ref.current===document.activeElement),Y=XR(ve,ie,re);Y&&setTimeout(()=>Y.ref.current.focus())}),K=j.useCallback((ie,ve,re)=>{const Y=!R.current&&!re;(g.value!==void 0&&g.value===ve||Y)&&(A(ie),Y&&(R.current=!0))},[g.value]),q=j.useCallback(()=>b==null?void 0:b.focus(),[b]),ne=j.useCallback((ie,ve,re)=>{const Y=!R.current&&!re;(g.value!==void 0&&g.value===ve||Y)&&T(ie)},[g.value]),le=n==="popper"?Yb:MR,de=le===Yb?{side:l,sideOffset:c,align:u,alignOffset:f,arrowPadding:d,collisionBoundary:h,collisionPadding:p,sticky:y,hideWhenDetached:v,avoidCollisions:m}:{};return i.jsx(_R,{scope:r,content:b,viewport:w,onViewportChange:S,itemRefCallback:K,selectedItem:P,onItemLeave:q,itemTextRefCallback:ne,focusSelectedItem:I,selectedItemText:C,position:n,isPositioned:_,searchRef:V,children:i.jsx(vg,{as:sV,allowPinchZoom:!0,children:i.jsx(pg,{asChild:!0,trapped:g.open,onMountAutoFocus:ie=>{ie.preventDefault()},onUnmountAutoFocus:je(a,ie=>{var ve;(ve=g.trigger)==null||ve.focus({preventScroll:!0}),ie.preventDefault()}),children:i.jsx(Xf,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:ie=>ie.preventDefault(),onDismiss:()=>g.onOpenChange(!1),children:i.jsx(le,{role:"listbox",id:g.contentId,"data-state":g.open?"open":"closed",dir:g.dir,onContextMenu:ie=>ie.preventDefault(),...x,...de,onPlaced:()=>k(!0),ref:O,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:je(x.onKeyDown,ie=>{const ve=ie.ctrlKey||ie.altKey||ie.metaKey;if(ie.key==="Tab"&&ie.preventDefault(),!ve&&ie.key.length===1&&G(ie.key),["ArrowUp","ArrowDown","Home","End"].includes(ie.key)){let Y=D().filter(Z=>!Z.disabled).map(Z=>Z.ref.current);if(["ArrowUp","End"].includes(ie.key)&&(Y=Y.slice().reverse()),["ArrowUp","ArrowDown"].includes(ie.key)){const Z=ie.target,L=Y.indexOf(Z);Y=Y.slice(L+1)}setTimeout(()=>$(Y)),ie.preventDefault()}})})})})})})});DR.displayName=iV;var oV="SelectItemAlignedPosition",MR=j.forwardRef((e,t)=>{const{__scopeSelect:r,onPlaced:n,...a}=e,s=Ls(Bo,r),o=Fs(Bo,r),[l,c]=j.useState(null),[u,f]=j.useState(null),d=Ye(t,O=>f(O)),h=Ng(r),p=j.useRef(!1),y=j.useRef(!0),{viewport:v,selectedItem:m,selectedItemText:x,focusSelectedItem:g}=o,b=j.useCallback(()=>{if(s.trigger&&s.valueNode&&l&&u&&v&&m&&x){const O=s.trigger.getBoundingClientRect(),P=u.getBoundingClientRect(),A=s.valueNode.getBoundingClientRect(),C=x.getBoundingClientRect();if(s.dir!=="rtl"){const Z=C.left-P.left,L=A.left-Z,ce=O.left-L,ye=O.width+ce,We=Math.max(ye,P.width),Je=window.innerWidth-Zn,ht=pA(L,[Zn,Math.max(Zn,Je-We)]);l.style.minWidth=ye+"px",l.style.left=ht+"px"}else{const Z=P.right-C.right,L=window.innerWidth-A.right-Z,ce=window.innerWidth-O.right-L,ye=O.width+ce,We=Math.max(ye,P.width),Je=window.innerWidth-Zn,ht=pA(L,[Zn,Math.max(Zn,Je-We)]);l.style.minWidth=ye+"px",l.style.right=ht+"px"}const T=h(),D=window.innerHeight-Zn*2,_=v.scrollHeight,k=window.getComputedStyle(u),R=parseInt(k.borderTopWidth,10),$=parseInt(k.paddingTop,10),I=parseInt(k.borderBottomWidth,10),E=parseInt(k.paddingBottom,10),F=R+$+_+E+I,V=Math.min(m.offsetHeight*5,F),G=window.getComputedStyle(v),K=parseInt(G.paddingTop,10),q=parseInt(G.paddingBottom,10),ne=O.top+O.height/2-Zn,le=D-ne,de=m.offsetHeight/2,ie=m.offsetTop+de,ve=R+$+ie,re=F-ve;if(ve<=ne){const Z=T.length>0&&m===T[T.length-1].ref.current;l.style.bottom="0px";const L=u.clientHeight-v.offsetTop-v.offsetHeight,ce=Math.max(le,de+(Z?q:0)+L+I),ye=ve+ce;l.style.height=ye+"px"}else{const Z=T.length>0&&m===T[0].ref.current;l.style.top="0px";const ce=Math.max(ne,R+v.offsetTop+(Z?K:0)+de)+re;l.style.height=ce+"px",v.scrollTop=ve-ne+v.offsetTop}l.style.margin=`${Zn}px 0`,l.style.minHeight=V+"px",l.style.maxHeight=D+"px",n==null||n(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,l,u,v,m,x,s.dir,n]);Jt(()=>b(),[b]);const[N,w]=j.useState();Jt(()=>{u&&w(window.getComputedStyle(u).zIndex)},[u]);const S=j.useCallback(O=>{O&&y.current===!0&&(b(),g==null||g(),y.current=!1)},[b,g]);return i.jsx(cV,{scope:r,contentWrapper:l,shouldExpandOnScrollRef:p,onScrollButtonChange:S,children:i.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:N},children:i.jsx(Re.div,{...a,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});MR.displayName=oV;var lV="SelectPopperPosition",Yb=j.forwardRef((e,t)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=Zn,...s}=e,o=Sg(r);return i.jsx(wR,{...o,...s,ref:t,align:n,collisionPadding:a,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Yb.displayName=lV;var[cV,gN]=uu(Bo,{}),Qb="SelectViewport",IR=j.forwardRef((e,t)=>{const{__scopeSelect:r,nonce:n,...a}=e,s=Fs(Qb,r),o=gN(Qb,r),l=Ye(t,s.onViewportChange),c=j.useRef(0);return i.jsxs(i.Fragment,{children:[i.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),i.jsx(wg.Slot,{scope:r,children:i.jsx(Re.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:je(a.onScroll,u=>{const f=u.currentTarget,{contentWrapper:d,shouldExpandOnScrollRef:h}=o;if(h!=null&&h.current&&d){const p=Math.abs(c.current-f.scrollTop);if(p>0){const y=window.innerHeight-Zn*2,v=parseFloat(d.style.minHeight),m=parseFloat(d.style.height),x=Math.max(v,m);if(x0?N:0,d.style.justifyContent="flex-end")}}}c.current=f.scrollTop})})})]})});IR.displayName=Qb;var RR="SelectGroup",[uV,dV]=uu(RR),fV=j.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,a=gi();return i.jsx(uV,{scope:r,id:a,children:i.jsx(Re.div,{role:"group","aria-labelledby":a,...n,ref:t})})});fV.displayName=RR;var $R="SelectLabel",LR=j.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,a=dV($R,r);return i.jsx(Re.div,{id:a.id,...n,ref:t})});LR.displayName=$R;var km="SelectItem",[hV,FR]=uu(km),BR=j.forwardRef((e,t)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:s,...o}=e,l=Ls(km,r),c=Fs(km,r),u=l.value===n,[f,d]=j.useState(s??""),[h,p]=j.useState(!1),y=Ye(t,g=>{var b;return(b=c.itemRefCallback)==null?void 0:b.call(c,g,n,a)}),v=gi(),m=j.useRef("touch"),x=()=>{a||(l.onValueChange(n),l.onOpenChange(!1))};if(n==="")throw new Error("A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return i.jsx(hV,{scope:r,value:n,disabled:a,textId:v,isSelected:u,onItemTextChange:j.useCallback(g=>{d(b=>b||((g==null?void 0:g.textContent)??"").trim())},[]),children:i.jsx(wg.ItemSlot,{scope:r,value:n,disabled:a,textValue:f,children:i.jsx(Re.div,{role:"option","aria-labelledby":v,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...o,ref:y,onFocus:je(o.onFocus,()=>p(!0)),onBlur:je(o.onBlur,()=>p(!1)),onClick:je(o.onClick,()=>{m.current!=="mouse"&&x()}),onPointerUp:je(o.onPointerUp,()=>{m.current==="mouse"&&x()}),onPointerDown:je(o.onPointerDown,g=>{m.current=g.pointerType}),onPointerMove:je(o.onPointerMove,g=>{var b;m.current=g.pointerType,a?(b=c.onItemLeave)==null||b.call(c):m.current==="mouse"&&g.currentTarget.focus({preventScroll:!0})}),onPointerLeave:je(o.onPointerLeave,g=>{var b;g.currentTarget===document.activeElement&&((b=c.onItemLeave)==null||b.call(c))}),onKeyDown:je(o.onKeyDown,g=>{var N;((N=c.searchRef)==null?void 0:N.current)!==""&&g.key===" "||(ZH.includes(g.key)&&x(),g.key===" "&&g.preventDefault())})})})})});BR.displayName=km;var ld="SelectItemText",UR=j.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:a,...s}=e,o=Ls(ld,r),l=Fs(ld,r),c=FR(ld,r),u=rV(ld,r),[f,d]=j.useState(null),h=Ye(t,x=>d(x),c.onItemTextChange,x=>{var g;return(g=l.itemTextRefCallback)==null?void 0:g.call(l,x,c.value,c.disabled)}),p=f==null?void 0:f.textContent,y=j.useMemo(()=>i.jsx("option",{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:v,onNativeOptionRemove:m}=u;return Jt(()=>(v(y),()=>m(y)),[v,m,y]),i.jsxs(i.Fragment,{children:[i.jsx(Re.span,{id:c.textId,...s,ref:h}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Rs.createPortal(s.children,o.valueNode):null]})});UR.displayName=ld;var zR="SelectItemIndicator",WR=j.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return FR(zR,r).isSelected?i.jsx(Re.span,{"aria-hidden":!0,...n,ref:t}):null});WR.displayName=zR;var Xb="SelectScrollUpButton",HR=j.forwardRef((e,t)=>{const r=Fs(Xb,e.__scopeSelect),n=gN(Xb,e.__scopeSelect),[a,s]=j.useState(!1),o=Ye(t,n.onScrollButtonChange);return Jt(()=>{if(r.viewport&&r.isPositioned){let l=function(){const u=c.scrollTop>0;s(u)};const c=r.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[r.viewport,r.isPositioned]),a?i.jsx(qR,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=r;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});HR.displayName=Xb;var Zb="SelectScrollDownButton",VR=j.forwardRef((e,t)=>{const r=Fs(Zb,e.__scopeSelect),n=gN(Zb,e.__scopeSelect),[a,s]=j.useState(!1),o=Ye(t,n.onScrollButtonChange);return Jt(()=>{if(r.viewport&&r.isPositioned){let l=function(){const u=c.scrollHeight-c.clientHeight,f=Math.ceil(c.scrollTop)c.removeEventListener("scroll",l)}},[r.viewport,r.isPositioned]),a?i.jsx(qR,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=r;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});VR.displayName=Zb;var qR=j.forwardRef((e,t)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=e,s=Fs("SelectScrollButton",r),o=j.useRef(null),l=Ng(r),c=j.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return j.useEffect(()=>()=>c(),[c]),Jt(()=>{var f;const u=l().find(d=>d.ref.current===document.activeElement);(f=u==null?void 0:u.ref.current)==null||f.scrollIntoView({block:"nearest"})},[l]),i.jsx(Re.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:je(a.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(n,50))}),onPointerMove:je(a.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),o.current===null&&(o.current=window.setInterval(n,50))}),onPointerLeave:je(a.onPointerLeave,()=>{c()})})}),pV="SelectSeparator",GR=j.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return i.jsx(Re.div,{"aria-hidden":!0,...n,ref:t})});GR.displayName=pV;var Jb="SelectArrow",mV=j.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,a=Sg(r),s=Ls(Jb,r),o=Fs(Jb,r);return s.open&&o.position==="popper"?i.jsx(NR,{...a,...n,ref:t}):null});mV.displayName=Jb;function KR(e){return e===""||e===void 0}var YR=j.forwardRef((e,t)=>{const{value:r,...n}=e,a=j.useRef(null),s=Ye(t,a),o=vN(r);return j.useEffect(()=>{const l=a.current,c=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(c,"value").set;if(o!==r&&f){const d=new Event("change",{bubbles:!0});f.call(l,r),l.dispatchEvent(d)}},[o,r]),i.jsx(ug,{asChild:!0,children:i.jsx("select",{...n,ref:s,defaultValue:r})})});YR.displayName="BubbleSelect";function QR(e){const t=Jr(e),r=j.useRef(""),n=j.useRef(0),a=j.useCallback(o=>{const l=r.current+o;t(l),function c(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>c(""),1e3))}(l)},[t]),s=j.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return j.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,a,s]}function XR(e,t,r){const a=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=r?e.indexOf(r):-1;let o=vV(e,Math.max(s,0));a.length===1&&(o=o.filter(u=>u!==r));const c=o.find(u=>u.textValue.toLowerCase().startsWith(a.toLowerCase()));return c!==r?c:void 0}function vV(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var gV=SR,ZR=PR,yV=CR,xV=ER,bV=TR,JR=kR,jV=IR,e$=LR,t$=BR,wV=UR,NV=WR,r$=HR,n$=VR,a$=GR;const _e=gV,De=yV,Ae=j.forwardRef(({className:e,children:t,...r},n)=>i.jsxs(ZR,{ref:n,className:ue("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...r,children:[t,i.jsx(xV,{asChild:!0,children:i.jsx(cI,{className:"h-4 w-4 opacity-50"})})]}));Ae.displayName=ZR.displayName;const i$=j.forwardRef(({className:e,...t},r)=>i.jsx(r$,{ref:r,className:ue("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(UW,{className:"h-4 w-4"})}));i$.displayName=r$.displayName;const s$=j.forwardRef(({className:e,...t},r)=>i.jsx(n$,{ref:r,className:ue("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(cI,{className:"h-4 w-4"})}));s$.displayName=n$.displayName;const Ce=j.forwardRef(({className:e,children:t,position:r="popper",...n},a)=>i.jsx(bV,{children:i.jsxs(JR,{ref:a,className:ue("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:r,...n,children:[i.jsx(i$,{}),i.jsx(jV,{className:ue("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),i.jsx(s$,{})]})}));Ce.displayName=JR.displayName;const SV=j.forwardRef(({className:e,...t},r)=>i.jsx(e$,{ref:r,className:ue("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));SV.displayName=e$.displayName;const U=j.forwardRef(({className:e,children:t,...r},n)=>i.jsxs(t$,{ref:n,className:ue("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(NV,{children:i.jsx(lI,{className:"h-4 w-4"})})}),i.jsx(wV,{children:t})]}));U.displayName=t$.displayName;const OV=j.forwardRef(({className:e,...t},r)=>i.jsx(a$,{ref:r,className:ue("-mx-1 my-1 h-px bg-muted",e),...t}));OV.displayName=a$.displayName;var PV="Separator",NA="horizontal",AV=["horizontal","vertical"],o$=j.forwardRef((e,t)=>{const{decorative:r,orientation:n=NA,...a}=e,s=CV(n)?n:NA,l=r?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return i.jsx(Re.div,{"data-orientation":s,...l,...a,ref:t})});o$.displayName=PV;function CV(e){return AV.includes(e)}var l$=o$;const yN=j.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...n},a)=>i.jsx(l$,{ref:a,decorative:r,orientation:t,className:ue("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...n}));yN.displayName=l$.displayName;function qe(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function xn(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function Kt(e,t){const r=qe(e);return isNaN(t)?xn(e,NaN):(t&&r.setDate(r.getDate()+t),r)}function xa(e,t){const r=qe(e);if(isNaN(t))return xn(e,NaN);if(!t)return r;const n=r.getDate(),a=xn(e,r.getTime());a.setMonth(r.getMonth()+t+1,0);const s=a.getDate();return n>=s?a:(r.setFullYear(a.getFullYear(),a.getMonth(),n),r)}const xN=6048e5,EV=864e5;let TV={};function lh(){return TV}function Qa(e,t){var l,c,u,f;const r=lh(),n=(t==null?void 0:t.weekStartsOn)??((c=(l=t==null?void 0:t.locale)==null?void 0:l.options)==null?void 0:c.weekStartsOn)??r.weekStartsOn??((f=(u=r.locale)==null?void 0:u.options)==null?void 0:f.weekStartsOn)??0,a=qe(e),s=a.getDay(),o=(s=a.getTime()?r+1:t.getTime()>=o.getTime()?r:r-1}function Nc(e){const t=qe(e);return t.setHours(0,0,0,0),t}function _m(e){const t=qe(e),r=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return r.setUTCFullYear(t.getFullYear()),+e-+r}function la(e,t){const r=Nc(e),n=Nc(t),a=+r-_m(r),s=+n-_m(n);return Math.round((a-s)/EV)}function kV(e){const t=c$(e),r=xn(e,0);return r.setFullYear(t,0,4),r.setHours(0,0,0,0),Uo(r)}function ej(e,t){const r=t*7;return Kt(e,r)}function _V(e,t){return xa(e,t*12)}function DV(e){let t;return e.forEach(function(r){const n=qe(r);(t===void 0||t{const n=qe(r);(!t||t>n||isNaN(+n))&&(t=n)}),t||new Date(NaN)}function qr(e,t){const r=Nc(e),n=Nc(t);return+r==+n}function bN(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function IV(e){if(!bN(e)&&typeof e!="number")return!1;const t=qe(e);return!isNaN(Number(t))}function Xd(e,t){const r=qe(e),n=qe(t),a=r.getFullYear()-n.getFullYear(),s=r.getMonth()-n.getMonth();return a*12+s}function RV(e,t,r){const n=Qa(e,r),a=Qa(t,r),s=+n-_m(n),o=+a-_m(a);return Math.round((s-o)/xN)}function SA(e,t){const r=qe(e),n=qe(t),a=OA(r,n),s=Math.abs(la(r,n));r.setDate(r.getDate()-a*s);const o=+(OA(r,n)===-a),l=a*(s-o);return l===0?0:l}function OA(e,t){const r=e.getFullYear()-t.getFullYear()||e.getMonth()-t.getMonth()||e.getDate()-t.getDate()||e.getHours()-t.getHours()||e.getMinutes()-t.getMinutes()||e.getSeconds()-t.getSeconds()||e.getMilliseconds()-t.getMilliseconds();return r<0?-1:r>0?1:r}function jN(e){const t=qe(e),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(23,59,59,999),t}function Zr(e){const t=qe(e);return t.setDate(1),t.setHours(0,0,0,0),t}function u$(e){const t=qe(e),r=xn(e,0);return r.setFullYear(t.getFullYear(),0,1),r.setHours(0,0,0,0),r}function wN(e,t){var l,c,u,f;const r=lh(),n=(t==null?void 0:t.weekStartsOn)??((c=(l=t==null?void 0:t.locale)==null?void 0:l.options)==null?void 0:c.weekStartsOn)??r.weekStartsOn??((f=(u=r.locale)==null?void 0:u.options)==null?void 0:f.weekStartsOn)??0,a=qe(e),s=a.getDay(),o=(s{let n;const a=$V[e];return typeof a=="string"?n=a:t===1?n=a.one:n=a.other.replace("{{count}}",t.toString()),r!=null&&r.addSuffix?r.comparison&&r.comparison>0?"in "+n:n+" ago":n};function Cx(e){return(t={})=>{const r=t.width?String(t.width):e.defaultWidth;return e.formats[r]||e.formats[e.defaultWidth]}}const FV={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},BV={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},UV={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},zV={date:Cx({formats:FV,defaultWidth:"full"}),time:Cx({formats:BV,defaultWidth:"full"}),dateTime:Cx({formats:UV,defaultWidth:"full"})},WV={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},HV=(e,t,r,n)=>WV[e];function Bu(e){return(t,r)=>{const n=r!=null&&r.context?String(r.context):"standalone";let a;if(n==="formatting"&&e.formattingValues){const o=e.defaultFormattingWidth||e.defaultWidth,l=r!=null&&r.width?String(r.width):o;a=e.formattingValues[l]||e.formattingValues[o]}else{const o=e.defaultWidth,l=r!=null&&r.width?String(r.width):e.defaultWidth;a=e.values[l]||e.values[o]}const s=e.argumentCallback?e.argumentCallback(t):t;return a[s]}}const VV={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},qV={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},GV={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},KV={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},YV={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},QV={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},XV=(e,t)=>{const r=Number(e),n=r%100;if(n>20||n<10)switch(n%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},ZV={ordinalNumber:XV,era:Bu({values:VV,defaultWidth:"wide"}),quarter:Bu({values:qV,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Bu({values:GV,defaultWidth:"wide"}),day:Bu({values:KV,defaultWidth:"wide"}),dayPeriod:Bu({values:YV,defaultWidth:"wide",formattingValues:QV,defaultFormattingWidth:"wide"})};function Uu(e){return(t,r={})=>{const n=r.width,a=n&&e.matchPatterns[n]||e.matchPatterns[e.defaultMatchWidth],s=t.match(a);if(!s)return null;const o=s[0],l=n&&e.parsePatterns[n]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(l)?eq(l,d=>d.test(o)):JV(l,d=>d.test(o));let u;u=e.valueCallback?e.valueCallback(c):c,u=r.valueCallback?r.valueCallback(u):u;const f=t.slice(o.length);return{value:u,rest:f}}}function JV(e,t){for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t(e[r]))return r}function eq(e,t){for(let r=0;r{const n=t.match(e.matchPattern);if(!n)return null;const a=n[0],s=t.match(e.parsePattern);if(!s)return null;let o=e.valueCallback?e.valueCallback(s[0]):s[0];o=r.valueCallback?r.valueCallback(o):o;const l=t.slice(a.length);return{value:o,rest:l}}}const rq=/^(\d+)(th|st|nd|rd)?/i,nq=/\d+/i,aq={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},iq={any:[/^b/i,/^(a|c)/i]},sq={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},oq={any:[/1/i,/2/i,/3/i,/4/i]},lq={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},cq={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},uq={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},dq={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},fq={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},hq={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},pq={ordinalNumber:tq({matchPattern:rq,parsePattern:nq,valueCallback:e=>parseInt(e,10)}),era:Uu({matchPatterns:aq,defaultMatchWidth:"wide",parsePatterns:iq,defaultParseWidth:"any"}),quarter:Uu({matchPatterns:sq,defaultMatchWidth:"wide",parsePatterns:oq,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Uu({matchPatterns:lq,defaultMatchWidth:"wide",parsePatterns:cq,defaultParseWidth:"any"}),day:Uu({matchPatterns:uq,defaultMatchWidth:"wide",parsePatterns:dq,defaultParseWidth:"any"}),dayPeriod:Uu({matchPatterns:fq,defaultMatchWidth:"any",parsePatterns:hq,defaultParseWidth:"any"})},f$={code:"en-US",formatDistance:LV,formatLong:zV,formatRelative:HV,localize:ZV,match:pq,options:{weekStartsOn:0,firstWeekContainsDate:1}};function mq(e){const t=qe(e);return la(t,u$(t))+1}function h$(e){const t=qe(e),r=+Uo(t)-+kV(t);return Math.round(r/xN)+1}function p$(e,t){var f,d,h,p;const r=qe(e),n=r.getFullYear(),a=lh(),s=(t==null?void 0:t.firstWeekContainsDate)??((d=(f=t==null?void 0:t.locale)==null?void 0:f.options)==null?void 0:d.firstWeekContainsDate)??a.firstWeekContainsDate??((p=(h=a.locale)==null?void 0:h.options)==null?void 0:p.firstWeekContainsDate)??1,o=xn(e,0);o.setFullYear(n+1,0,s),o.setHours(0,0,0,0);const l=Qa(o,t),c=xn(e,0);c.setFullYear(n,0,s),c.setHours(0,0,0,0);const u=Qa(c,t);return r.getTime()>=l.getTime()?n+1:r.getTime()>=u.getTime()?n:n-1}function vq(e,t){var l,c,u,f;const r=lh(),n=(t==null?void 0:t.firstWeekContainsDate)??((c=(l=t==null?void 0:t.locale)==null?void 0:l.options)==null?void 0:c.firstWeekContainsDate)??r.firstWeekContainsDate??((f=(u=r.locale)==null?void 0:u.options)==null?void 0:f.firstWeekContainsDate)??1,a=p$(e,t),s=xn(e,0);return s.setFullYear(a,0,n),s.setHours(0,0,0,0),Qa(s,t)}function m$(e,t){const r=qe(e),n=+Qa(r,t)-+vq(r,t);return Math.round(n/xN)+1}function at(e,t){const r=e<0?"-":"",n=Math.abs(e).toString().padStart(t,"0");return r+n}const Bi={y(e,t){const r=e.getFullYear(),n=r>0?r:1-r;return at(t==="yy"?n%100:n,t.length)},M(e,t){const r=e.getMonth();return t==="M"?String(r+1):at(r+1,2)},d(e,t){return at(e.getDate(),t.length)},a(e,t){const r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(e,t){return at(e.getHours()%12||12,t.length)},H(e,t){return at(e.getHours(),t.length)},m(e,t){return at(e.getMinutes(),t.length)},s(e,t){return at(e.getSeconds(),t.length)},S(e,t){const r=t.length,n=e.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return at(a,t.length)}},ll={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},PA={G:function(e,t,r){const n=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return r.era(n,{width:"abbreviated"});case"GGGGG":return r.era(n,{width:"narrow"});case"GGGG":default:return r.era(n,{width:"wide"})}},y:function(e,t,r){if(t==="yo"){const n=e.getFullYear(),a=n>0?n:1-n;return r.ordinalNumber(a,{unit:"year"})}return Bi.y(e,t)},Y:function(e,t,r,n){const a=p$(e,n),s=a>0?a:1-a;if(t==="YY"){const o=s%100;return at(o,2)}return t==="Yo"?r.ordinalNumber(s,{unit:"year"}):at(s,t.length)},R:function(e,t){const r=c$(e);return at(r,t.length)},u:function(e,t){const r=e.getFullYear();return at(r,t.length)},Q:function(e,t,r){const n=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(n);case"QQ":return at(n,2);case"Qo":return r.ordinalNumber(n,{unit:"quarter"});case"QQQ":return r.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(n,{width:"wide",context:"formatting"})}},q:function(e,t,r){const n=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(n);case"qq":return at(n,2);case"qo":return r.ordinalNumber(n,{unit:"quarter"});case"qqq":return r.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(n,{width:"wide",context:"standalone"})}},M:function(e,t,r){const n=e.getMonth();switch(t){case"M":case"MM":return Bi.M(e,t);case"Mo":return r.ordinalNumber(n+1,{unit:"month"});case"MMM":return r.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(n,{width:"wide",context:"formatting"})}},L:function(e,t,r){const n=e.getMonth();switch(t){case"L":return String(n+1);case"LL":return at(n+1,2);case"Lo":return r.ordinalNumber(n+1,{unit:"month"});case"LLL":return r.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(n,{width:"wide",context:"standalone"})}},w:function(e,t,r,n){const a=m$(e,n);return t==="wo"?r.ordinalNumber(a,{unit:"week"}):at(a,t.length)},I:function(e,t,r){const n=h$(e);return t==="Io"?r.ordinalNumber(n,{unit:"week"}):at(n,t.length)},d:function(e,t,r){return t==="do"?r.ordinalNumber(e.getDate(),{unit:"date"}):Bi.d(e,t)},D:function(e,t,r){const n=mq(e);return t==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):at(n,t.length)},E:function(e,t,r){const n=e.getDay();switch(t){case"E":case"EE":case"EEE":return r.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(n,{width:"short",context:"formatting"});case"EEEE":default:return r.day(n,{width:"wide",context:"formatting"})}},e:function(e,t,r,n){const a=e.getDay(),s=(a-n.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return at(s,2);case"eo":return r.ordinalNumber(s,{unit:"day"});case"eee":return r.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(a,{width:"short",context:"formatting"});case"eeee":default:return r.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,r,n){const a=e.getDay(),s=(a-n.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return at(s,t.length);case"co":return r.ordinalNumber(s,{unit:"day"});case"ccc":return r.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(a,{width:"narrow",context:"standalone"});case"cccccc":return r.day(a,{width:"short",context:"standalone"});case"cccc":default:return r.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,r){const n=e.getDay(),a=n===0?7:n;switch(t){case"i":return String(a);case"ii":return at(a,t.length);case"io":return r.ordinalNumber(a,{unit:"day"});case"iii":return r.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(n,{width:"short",context:"formatting"});case"iiii":default:return r.day(n,{width:"wide",context:"formatting"})}},a:function(e,t,r){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(e,t,r){const n=e.getHours();let a;switch(n===12?a=ll.noon:n===0?a=ll.midnight:a=n/12>=1?"pm":"am",t){case"b":case"bb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,t,r){const n=e.getHours();let a;switch(n>=17?a=ll.evening:n>=12?a=ll.afternoon:n>=4?a=ll.morning:a=ll.night,t){case"B":case"BB":case"BBB":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,t,r){if(t==="ho"){let n=e.getHours()%12;return n===0&&(n=12),r.ordinalNumber(n,{unit:"hour"})}return Bi.h(e,t)},H:function(e,t,r){return t==="Ho"?r.ordinalNumber(e.getHours(),{unit:"hour"}):Bi.H(e,t)},K:function(e,t,r){const n=e.getHours()%12;return t==="Ko"?r.ordinalNumber(n,{unit:"hour"}):at(n,t.length)},k:function(e,t,r){let n=e.getHours();return n===0&&(n=24),t==="ko"?r.ordinalNumber(n,{unit:"hour"}):at(n,t.length)},m:function(e,t,r){return t==="mo"?r.ordinalNumber(e.getMinutes(),{unit:"minute"}):Bi.m(e,t)},s:function(e,t,r){return t==="so"?r.ordinalNumber(e.getSeconds(),{unit:"second"}):Bi.s(e,t)},S:function(e,t){return Bi.S(e,t)},X:function(e,t,r){const n=e.getTimezoneOffset();if(n===0)return"Z";switch(t){case"X":return CA(n);case"XXXX":case"XX":return Js(n);case"XXXXX":case"XXX":default:return Js(n,":")}},x:function(e,t,r){const n=e.getTimezoneOffset();switch(t){case"x":return CA(n);case"xxxx":case"xx":return Js(n);case"xxxxx":case"xxx":default:return Js(n,":")}},O:function(e,t,r){const n=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+AA(n,":");case"OOOO":default:return"GMT"+Js(n,":")}},z:function(e,t,r){const n=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+AA(n,":");case"zzzz":default:return"GMT"+Js(n,":")}},t:function(e,t,r){const n=Math.trunc(e.getTime()/1e3);return at(n,t.length)},T:function(e,t,r){const n=e.getTime();return at(n,t.length)}};function AA(e,t=""){const r=e>0?"-":"+",n=Math.abs(e),a=Math.trunc(n/60),s=n%60;return s===0?r+String(a):r+String(a)+t+at(s,2)}function CA(e,t){return e%60===0?(e>0?"-":"+")+at(Math.abs(e)/60,2):Js(e,t)}function Js(e,t=""){const r=e>0?"-":"+",n=Math.abs(e),a=at(Math.trunc(n/60),2),s=at(n%60,2);return r+a+t+s}const EA=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},v$=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},gq=(e,t)=>{const r=e.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return EA(e,t);let s;switch(n){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;case"PPPP":default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",EA(n,t)).replace("{{time}}",v$(a,t))},yq={p:v$,P:gq},xq=/^D+$/,bq=/^Y+$/,jq=["D","DD","YY","YYYY"];function wq(e){return xq.test(e)}function Nq(e){return bq.test(e)}function Sq(e,t,r){const n=Oq(e,t,r);if(console.warn(n),jq.includes(e))throw new RangeError(n)}function Oq(e,t,r){const n=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${n} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Pq=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Aq=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Cq=/^'([^]*?)'?$/,Eq=/''/g,Tq=/[a-zA-Z]/;function Ve(e,t,r){var f,d,h,p,y,v,m,x;const n=lh(),a=(r==null?void 0:r.locale)??n.locale??f$,s=(r==null?void 0:r.firstWeekContainsDate)??((d=(f=r==null?void 0:r.locale)==null?void 0:f.options)==null?void 0:d.firstWeekContainsDate)??n.firstWeekContainsDate??((p=(h=n.locale)==null?void 0:h.options)==null?void 0:p.firstWeekContainsDate)??1,o=(r==null?void 0:r.weekStartsOn)??((v=(y=r==null?void 0:r.locale)==null?void 0:y.options)==null?void 0:v.weekStartsOn)??n.weekStartsOn??((x=(m=n.locale)==null?void 0:m.options)==null?void 0:x.weekStartsOn)??0,l=qe(e);if(!IV(l))throw new RangeError("Invalid time value");let c=t.match(Aq).map(g=>{const b=g[0];if(b==="p"||b==="P"){const N=yq[b];return N(g,a.formatLong)}return g}).join("").match(Pq).map(g=>{if(g==="''")return{isToken:!1,value:"'"};const b=g[0];if(b==="'")return{isToken:!1,value:kq(g)};if(PA[b])return{isToken:!0,value:g};if(b.match(Tq))throw new RangeError("Format string contains an unescaped latin alphabet character `"+b+"`");return{isToken:!1,value:g}});a.localize.preprocessor&&(c=a.localize.preprocessor(l,c));const u={firstWeekContainsDate:s,weekStartsOn:o,locale:a};return c.map(g=>{if(!g.isToken)return g.value;const b=g.value;(!(r!=null&&r.useAdditionalWeekYearTokens)&&Nq(b)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&wq(b))&&Sq(b,t,String(e));const N=PA[b[0]];return N(l,b,a.localize,u)}).join("")}function kq(e){const t=e.match(Cq);return t?t[1].replace(Eq,"'"):e}function _q(e){const t=qe(e),r=t.getFullYear(),n=t.getMonth(),a=xn(e,0);return a.setFullYear(r,n+1,0),a.setHours(0,0,0,0),a.getDate()}function Dq(e){return Math.trunc(+qe(e)/1e3)}function Mq(e){const t=qe(e),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(0,0,0,0),t}function Iq(e,t){return RV(Mq(e),Zr(e),t)+1}function tj(e,t){const r=qe(e),n=qe(t);return r.getTime()>n.getTime()}function g$(e,t){const r=qe(e),n=qe(t);return+r<+n}function NN(e,t){const r=qe(e),n=qe(t);return r.getFullYear()===n.getFullYear()&&r.getMonth()===n.getMonth()}function Rq(e,t){const r=qe(e),n=qe(t);return r.getFullYear()===n.getFullYear()}function Ex(e,t){return Kt(e,-t)}function Tx(e,t){const r=qe(e),n=r.getFullYear(),a=r.getDate(),s=xn(e,0);s.setFullYear(n,t,15),s.setHours(0,0,0,0);const o=_q(s);return r.setMonth(t,Math.min(a,o)),r}function TA(e,t){const r=qe(e);return isNaN(+r)?xn(e,NaN):(r.setFullYear(t),r)}var Pe=function(){return Pe=Object.assign||function(t){for(var r,n=1,a=arguments.length;n1&&(c||!u),d=t>1&&(u||!c),h=function(){n&&s(n)},p=function(){a&&s(a)};return i.jsx(mG,{displayMonth:e.displayMonth,hideNext:f,hidePrevious:d,nextMonth:a,previousMonth:n,onPreviousClick:h,onNextClick:p})}function vG(e){var t,r=yt(),n=r.classNames,a=r.disableNavigation,s=r.styles,o=r.captionLayout,l=r.components,c=(t=l==null?void 0:l.CaptionLabel)!==null&&t!==void 0?t:b$,u;return a?u=i.jsx(c,{id:e.id,displayMonth:e.displayMonth}):o==="dropdown"?u=i.jsx(kA,{displayMonth:e.displayMonth,id:e.id}):o==="dropdown-buttons"?u=i.jsxs(i.Fragment,{children:[i.jsx(kA,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id}),i.jsx(_A,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id})]}):u=i.jsxs(i.Fragment,{children:[i.jsx(c,{id:e.id,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),i.jsx(_A,{displayMonth:e.displayMonth,id:e.id})]}),i.jsx("div",{className:n.caption,style:s.caption,children:u})}function gG(e){var t=yt(),r=t.footer,n=t.styles,a=t.classNames.tfoot;return r?i.jsx("tfoot",{className:a,style:n.tfoot,children:i.jsx("tr",{children:i.jsx("td",{colSpan:8,children:r})})}):i.jsx(i.Fragment,{})}function yG(e,t,r){for(var n=r?Uo(new Date):Qa(new Date,{locale:e,weekStartsOn:t}),a=[],s=0;s<7;s++){var o=Kt(n,s);a.push(o)}return a}function xG(){var e=yt(),t=e.classNames,r=e.styles,n=e.showWeekNumber,a=e.locale,s=e.weekStartsOn,o=e.ISOWeek,l=e.formatters.formatWeekdayName,c=e.labels.labelWeekday,u=yG(a,s,o);return i.jsxs("tr",{style:r.head_row,className:t.head_row,children:[n&&i.jsx("td",{style:r.head_cell,className:t.head_cell}),u.map(function(f,d){return i.jsx("th",{scope:"col",className:t.head_cell,style:r.head_cell,"aria-label":c(f,{locale:a}),children:l(f,{locale:a})},d)})]})}function bG(){var e,t=yt(),r=t.classNames,n=t.styles,a=t.components,s=(e=a==null?void 0:a.HeadRow)!==null&&e!==void 0?e:xG;return i.jsx("thead",{style:n.head,className:r.head,children:i.jsx(s,{})})}function jG(e){var t=yt(),r=t.locale,n=t.formatters.formatDay;return i.jsx(i.Fragment,{children:n(e.date,{locale:r})})}var SN=j.createContext(void 0);function wG(e){if(!ch(e.initialProps)){var t={selected:void 0,modifiers:{disabled:[]}};return i.jsx(SN.Provider,{value:t,children:e.children})}return i.jsx(NG,{initialProps:e.initialProps,children:e.children})}function NG(e){var t=e.initialProps,r=e.children,n=t.selected,a=t.min,s=t.max,o=function(u,f,d){var h,p;(h=t.onDayClick)===null||h===void 0||h.call(t,u,f,d);var y=!!(f.selected&&a&&(n==null?void 0:n.length)===a);if(!y){var v=!!(!f.selected&&s&&(n==null?void 0:n.length)===s);if(!v){var m=n?y$([],n):[];if(f.selected){var x=m.findIndex(function(g){return qr(u,g)});m.splice(x,1)}else m.push(u);(p=t.onSelect)===null||p===void 0||p.call(t,m,u,f,d)}}},l={disabled:[]};n&&l.disabled.push(function(u){var f=s&&n.length>s-1,d=n.some(function(h){return qr(h,u)});return!!(f&&!d)});var c={selected:n,onDayClick:o,modifiers:l};return i.jsx(SN.Provider,{value:c,children:r})}function ON(){var e=j.useContext(SN);if(!e)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return e}function SG(e,t){var r=t||{},n=r.from,a=r.to;return n&&a?qr(a,e)&&qr(n,e)?void 0:qr(a,e)?{from:a,to:void 0}:qr(n,e)?void 0:tj(n,e)?{from:e,to:a}:{from:n,to:e}:a?tj(e,a)?{from:a,to:e}:{from:e,to:a}:n?g$(e,n)?{from:e,to:n}:{from:n,to:e}:{from:e,to:void 0}}var PN=j.createContext(void 0);function OG(e){if(!uh(e.initialProps)){var t={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return i.jsx(PN.Provider,{value:t,children:e.children})}return i.jsx(PG,{initialProps:e.initialProps,children:e.children})}function PG(e){var t=e.initialProps,r=e.children,n=t.selected,a=n||{},s=a.from,o=a.to,l=t.min,c=t.max,u=function(p,y,v){var m,x;(m=t.onDayClick)===null||m===void 0||m.call(t,p,y,v);var g=SG(p,n);(x=t.onSelect)===null||x===void 0||x.call(t,g,p,y,v)},f={range_start:[],range_end:[],range_middle:[],disabled:[]};if(s?(f.range_start=[s],o?(f.range_end=[o],qr(s,o)||(f.range_middle=[{after:s,before:o}])):f.range_end=[s]):o&&(f.range_start=[o],f.range_end=[o]),l&&(s&&!o&&f.disabled.push({after:Ex(s,l-1),before:Kt(s,l-1)}),s&&o&&f.disabled.push({after:s,before:Kt(s,l-1)}),!s&&o&&f.disabled.push({after:Ex(o,l-1),before:Kt(o,l-1)})),c){if(s&&!o&&(f.disabled.push({before:Kt(s,-c+1)}),f.disabled.push({after:Kt(s,c-1)})),s&&o){var d=la(o,s)+1,h=c-d;f.disabled.push({before:Ex(s,h)}),f.disabled.push({after:Kt(o,h)})}!s&&o&&(f.disabled.push({before:Kt(o,-c+1)}),f.disabled.push({after:Kt(o,c-1)}))}return i.jsx(PN.Provider,{value:{selected:n,onDayClick:u,modifiers:f},children:r})}function AN(){var e=j.useContext(PN);if(!e)throw new Error("useSelectRange must be used within a SelectRangeProvider");return e}function Yp(e){return Array.isArray(e)?y$([],e):e!==void 0?[e]:[]}function AG(e){var t={};return Object.entries(e).forEach(function(r){var n=r[0],a=r[1];t[n]=Yp(a)}),t}var ba;(function(e){e.Outside="outside",e.Disabled="disabled",e.Selected="selected",e.Hidden="hidden",e.Today="today",e.RangeStart="range_start",e.RangeEnd="range_end",e.RangeMiddle="range_middle"})(ba||(ba={}));var CG=ba.Selected,ni=ba.Disabled,EG=ba.Hidden,TG=ba.Today,kx=ba.RangeEnd,_x=ba.RangeMiddle,Dx=ba.RangeStart,kG=ba.Outside;function _G(e,t,r){var n,a=(n={},n[CG]=Yp(e.selected),n[ni]=Yp(e.disabled),n[EG]=Yp(e.hidden),n[TG]=[e.today],n[kx]=[],n[_x]=[],n[Dx]=[],n[kG]=[],n);return e.fromDate&&a[ni].push({before:e.fromDate}),e.toDate&&a[ni].push({after:e.toDate}),ch(e)?a[ni]=a[ni].concat(t.modifiers[ni]):uh(e)&&(a[ni]=a[ni].concat(r.modifiers[ni]),a[Dx]=r.modifiers[Dx],a[_x]=r.modifiers[_x],a[kx]=r.modifiers[kx]),a}var N$=j.createContext(void 0);function DG(e){var t=yt(),r=ON(),n=AN(),a=_G(t,r,n),s=AG(t.modifiers),o=Pe(Pe({},a),s);return i.jsx(N$.Provider,{value:o,children:e.children})}function S$(){var e=j.useContext(N$);if(!e)throw new Error("useModifiers must be used within a ModifiersProvider");return e}function MG(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function IG(e){return!!(e&&typeof e=="object"&&"from"in e)}function RG(e){return!!(e&&typeof e=="object"&&"after"in e)}function $G(e){return!!(e&&typeof e=="object"&&"before"in e)}function LG(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function FG(e,t){var r,n=t.from,a=t.to;if(n&&a){var s=la(a,n)<0;s&&(r=[a,n],n=r[0],a=r[1]);var o=la(e,n)>=0&&la(a,e)>=0;return o}return a?qr(a,e):n?qr(n,e):!1}function BG(e){return bN(e)}function UG(e){return Array.isArray(e)&&e.every(bN)}function zG(e,t){return t.some(function(r){if(typeof r=="boolean")return r;if(BG(r))return qr(e,r);if(UG(r))return r.includes(e);if(IG(r))return FG(e,r);if(LG(r))return r.dayOfWeek.includes(e.getDay());if(MG(r)){var n=la(r.before,e),a=la(r.after,e),s=n>0,o=a<0,l=tj(r.before,r.after);return l?o&&s:s||o}return RG(r)?la(e,r.after)>0:$G(r)?la(r.before,e)>0:typeof r=="function"?r(e):!1})}function CN(e,t,r){var n=Object.keys(t).reduce(function(s,o){var l=t[o];return zG(e,l)&&s.push(o),s},[]),a={};return n.forEach(function(s){return a[s]=!0}),r&&!NN(e,r)&&(a.outside=!0),a}function WG(e,t){for(var r=Zr(e[0]),n=jN(e[e.length-1]),a,s,o=r;o<=n;){var l=CN(o,t),c=!l.disabled&&!l.hidden;if(!c){o=Kt(o,1);continue}if(l.selected)return o;l.today&&!s&&(s=o),a||(a=o),o=Kt(o,1)}return s||a}var HG=365;function O$(e,t){var r=t.moveBy,n=t.direction,a=t.context,s=t.modifiers,o=t.retry,l=o===void 0?{count:0,lastFocused:e}:o,c=a.weekStartsOn,u=a.fromDate,f=a.toDate,d=a.locale,h={day:Kt,week:ej,month:xa,year:_V,startOfWeek:function(m){return a.ISOWeek?Uo(m):Qa(m,{locale:d,weekStartsOn:c})},endOfWeek:function(m){return a.ISOWeek?d$(m):wN(m,{locale:d,weekStartsOn:c})}},p=h[r](e,n==="after"?1:-1);n==="before"&&u?p=DV([u,p]):n==="after"&&f&&(p=MV([f,p]));var y=!0;if(s){var v=CN(p,s);y=!v.disabled&&!v.hidden}return y?p:l.count>HG?l.lastFocused:O$(p,{moveBy:r,direction:n,context:a,modifiers:s,retry:Pe(Pe({},l),{count:l.count+1})})}var P$=j.createContext(void 0);function VG(e){var t=dh(),r=S$(),n=j.useState(),a=n[0],s=n[1],o=j.useState(),l=o[0],c=o[1],u=WG(t.displayMonths,r),f=a??(l&&t.isDateDisplayed(l))?l:u,d=function(){c(a),s(void 0)},h=function(m){s(m)},p=yt(),y=function(m,x){if(a){var g=O$(a,{moveBy:m,direction:x,context:p,modifiers:r});qr(a,g)||(t.goToDate(g,a),h(g))}},v={focusedDay:a,focusTarget:f,blur:d,focus:h,focusDayAfter:function(){return y("day","after")},focusDayBefore:function(){return y("day","before")},focusWeekAfter:function(){return y("week","after")},focusWeekBefore:function(){return y("week","before")},focusMonthBefore:function(){return y("month","before")},focusMonthAfter:function(){return y("month","after")},focusYearBefore:function(){return y("year","before")},focusYearAfter:function(){return y("year","after")},focusStartOfWeek:function(){return y("startOfWeek","before")},focusEndOfWeek:function(){return y("endOfWeek","after")}};return i.jsx(P$.Provider,{value:v,children:e.children})}function EN(){var e=j.useContext(P$);if(!e)throw new Error("useFocusContext must be used within a FocusProvider");return e}function qG(e,t){var r=S$(),n=CN(e,r,t);return n}var TN=j.createContext(void 0);function GG(e){if(!Og(e.initialProps)){var t={selected:void 0};return i.jsx(TN.Provider,{value:t,children:e.children})}return i.jsx(KG,{initialProps:e.initialProps,children:e.children})}function KG(e){var t=e.initialProps,r=e.children,n=function(s,o,l){var c,u,f;if((c=t.onDayClick)===null||c===void 0||c.call(t,s,o,l),o.selected&&!t.required){(u=t.onSelect)===null||u===void 0||u.call(t,void 0,s,o,l);return}(f=t.onSelect)===null||f===void 0||f.call(t,s,s,o,l)},a={selected:t.selected,onDayClick:n};return i.jsx(TN.Provider,{value:a,children:r})}function A$(){var e=j.useContext(TN);if(!e)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return e}function YG(e,t){var r=yt(),n=A$(),a=ON(),s=AN(),o=EN(),l=o.focusDayAfter,c=o.focusDayBefore,u=o.focusWeekAfter,f=o.focusWeekBefore,d=o.blur,h=o.focus,p=o.focusMonthBefore,y=o.focusMonthAfter,v=o.focusYearBefore,m=o.focusYearAfter,x=o.focusStartOfWeek,g=o.focusEndOfWeek,b=function(I){var E,F,V,G;Og(r)?(E=n.onDayClick)===null||E===void 0||E.call(n,e,t,I):ch(r)?(F=a.onDayClick)===null||F===void 0||F.call(a,e,t,I):uh(r)?(V=s.onDayClick)===null||V===void 0||V.call(s,e,t,I):(G=r.onDayClick)===null||G===void 0||G.call(r,e,t,I)},N=function(I){var E;h(e),(E=r.onDayFocus)===null||E===void 0||E.call(r,e,t,I)},w=function(I){var E;d(),(E=r.onDayBlur)===null||E===void 0||E.call(r,e,t,I)},S=function(I){var E;(E=r.onDayMouseEnter)===null||E===void 0||E.call(r,e,t,I)},O=function(I){var E;(E=r.onDayMouseLeave)===null||E===void 0||E.call(r,e,t,I)},P=function(I){var E;(E=r.onDayPointerEnter)===null||E===void 0||E.call(r,e,t,I)},A=function(I){var E;(E=r.onDayPointerLeave)===null||E===void 0||E.call(r,e,t,I)},C=function(I){var E;(E=r.onDayTouchCancel)===null||E===void 0||E.call(r,e,t,I)},T=function(I){var E;(E=r.onDayTouchEnd)===null||E===void 0||E.call(r,e,t,I)},D=function(I){var E;(E=r.onDayTouchMove)===null||E===void 0||E.call(r,e,t,I)},_=function(I){var E;(E=r.onDayTouchStart)===null||E===void 0||E.call(r,e,t,I)},k=function(I){var E;(E=r.onDayKeyUp)===null||E===void 0||E.call(r,e,t,I)},R=function(I){var E;switch(I.key){case"ArrowLeft":I.preventDefault(),I.stopPropagation(),r.dir==="rtl"?l():c();break;case"ArrowRight":I.preventDefault(),I.stopPropagation(),r.dir==="rtl"?c():l();break;case"ArrowDown":I.preventDefault(),I.stopPropagation(),u();break;case"ArrowUp":I.preventDefault(),I.stopPropagation(),f();break;case"PageUp":I.preventDefault(),I.stopPropagation(),I.shiftKey?v():p();break;case"PageDown":I.preventDefault(),I.stopPropagation(),I.shiftKey?m():y();break;case"Home":I.preventDefault(),I.stopPropagation(),x();break;case"End":I.preventDefault(),I.stopPropagation(),g();break}(E=r.onDayKeyDown)===null||E===void 0||E.call(r,e,t,I)},$={onClick:b,onFocus:N,onBlur:w,onKeyDown:R,onKeyUp:k,onMouseEnter:S,onMouseLeave:O,onPointerEnter:P,onPointerLeave:A,onTouchCancel:C,onTouchEnd:T,onTouchMove:D,onTouchStart:_};return $}function QG(){var e=yt(),t=A$(),r=ON(),n=AN(),a=Og(e)?t.selected:ch(e)?r.selected:uh(e)?n.selected:void 0;return a}function XG(e){return Object.values(ba).includes(e)}function ZG(e,t){var r=[e.classNames.day];return Object.keys(t).forEach(function(n){var a=e.modifiersClassNames[n];if(a)r.push(a);else if(XG(n)){var s=e.classNames["day_".concat(n)];s&&r.push(s)}}),r}function JG(e,t){var r=Pe({},e.styles.day);return Object.keys(t).forEach(function(n){var a;r=Pe(Pe({},r),(a=e.modifiersStyles)===null||a===void 0?void 0:a[n])}),r}function eK(e,t,r){var n,a,s,o=yt(),l=EN(),c=qG(e,t),u=YG(e,c),f=QG(),d=!!(o.onDayClick||o.mode!=="default");j.useEffect(function(){var S;c.outside||l.focusedDay&&d&&qr(l.focusedDay,e)&&((S=r.current)===null||S===void 0||S.focus())},[l.focusedDay,e,r,d,c.outside]);var h=ZG(o,c).join(" "),p=JG(o,c),y=!!(c.outside&&!o.showOutsideDays||c.hidden),v=(s=(a=o.components)===null||a===void 0?void 0:a.DayContent)!==null&&s!==void 0?s:jG,m=i.jsx(v,{date:e,displayMonth:t,activeModifiers:c}),x={style:p,className:h,children:m,role:"gridcell"},g=l.focusTarget&&qr(l.focusTarget,e)&&!c.outside,b=l.focusedDay&&qr(l.focusedDay,e),N=Pe(Pe(Pe({},x),(n={disabled:c.disabled,role:"gridcell"},n["aria-selected"]=c.selected,n.tabIndex=b||g?0:-1,n)),u),w={isButton:d,isHidden:y,activeModifiers:c,selectedDays:f,buttonProps:N,divProps:x};return w}function tK(e){var t=j.useRef(null),r=eK(e.date,e.displayMonth,t);return r.isHidden?i.jsx("div",{role:"gridcell"}):r.isButton?i.jsx(Dm,Pe({name:"day",ref:t},r.buttonProps)):i.jsx("div",Pe({},r.divProps))}function rK(e){var t=e.number,r=e.dates,n=yt(),a=n.onWeekNumberClick,s=n.styles,o=n.classNames,l=n.locale,c=n.labels.labelWeekNumber,u=n.formatters.formatWeekNumber,f=u(Number(t),{locale:l});if(!a)return i.jsx("span",{className:o.weeknumber,style:s.weeknumber,children:f});var d=c(Number(t),{locale:l}),h=function(p){a(t,r,p)};return i.jsx(Dm,{name:"week-number","aria-label":d,className:o.weeknumber,style:s.weeknumber,onClick:h,children:f})}function nK(e){var t,r,n=yt(),a=n.styles,s=n.classNames,o=n.showWeekNumber,l=n.components,c=(t=l==null?void 0:l.Day)!==null&&t!==void 0?t:tK,u=(r=l==null?void 0:l.WeekNumber)!==null&&r!==void 0?r:rK,f;return o&&(f=i.jsx("td",{className:s.cell,style:a.cell,children:i.jsx(u,{number:e.weekNumber,dates:e.dates})})),i.jsxs("tr",{className:s.row,style:a.row,children:[f,e.dates.map(function(d){return i.jsx("td",{className:s.cell,style:a.cell,role:"presentation",children:i.jsx(c,{displayMonth:e.displayMonth,date:d})},Dq(d))})]})}function DA(e,t,r){for(var n=r!=null&&r.ISOWeek?d$(t):wN(t,r),a=r!=null&&r.ISOWeek?Uo(e):Qa(e,r),s=la(n,a),o=[],l=0;l<=s;l++)o.push(Kt(a,l));var c=o.reduce(function(u,f){var d=r!=null&&r.ISOWeek?h$(f):m$(f,r),h=u.find(function(p){return p.weekNumber===d});return h?(h.dates.push(f),u):(u.push({weekNumber:d,dates:[f]}),u)},[]);return c}function aK(e,t){var r=DA(Zr(e),jN(e),t);if(t!=null&&t.useFixedWeeks){var n=Iq(e,t);if(n<6){var a=r[r.length-1],s=a.dates[a.dates.length-1],o=ej(s,6-n),l=DA(ej(s,1),o,t);r.push.apply(r,l)}}return r}function iK(e){var t,r,n,a=yt(),s=a.locale,o=a.classNames,l=a.styles,c=a.hideHead,u=a.fixedWeeks,f=a.components,d=a.weekStartsOn,h=a.firstWeekContainsDate,p=a.ISOWeek,y=aK(e.displayMonth,{useFixedWeeks:!!u,ISOWeek:p,locale:s,weekStartsOn:d,firstWeekContainsDate:h}),v=(t=f==null?void 0:f.Head)!==null&&t!==void 0?t:bG,m=(r=f==null?void 0:f.Row)!==null&&r!==void 0?r:nK,x=(n=f==null?void 0:f.Footer)!==null&&n!==void 0?n:gG;return i.jsxs("table",{id:e.id,className:o.table,style:l.table,role:"grid","aria-labelledby":e["aria-labelledby"],children:[!c&&i.jsx(v,{}),i.jsx("tbody",{className:o.tbody,style:l.tbody,children:y.map(function(g){return i.jsx(m,{displayMonth:e.displayMonth,dates:g.dates,weekNumber:g.weekNumber},g.weekNumber)})}),i.jsx(x,{displayMonth:e.displayMonth})]})}function sK(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var oK=sK()?j.useLayoutEffect:j.useEffect,Mx=!1,lK=0;function MA(){return"react-day-picker-".concat(++lK)}function cK(e){var t,r=e??(Mx?MA():null),n=j.useState(r),a=n[0],s=n[1];return oK(function(){a===null&&s(MA())},[]),j.useEffect(function(){Mx===!1&&(Mx=!0)},[]),(t=e??a)!==null&&t!==void 0?t:void 0}function uK(e){var t,r,n=yt(),a=n.dir,s=n.classNames,o=n.styles,l=n.components,c=dh().displayMonths,u=cK(n.id?"".concat(n.id,"-").concat(e.displayIndex):void 0),f=n.id?"".concat(n.id,"-grid-").concat(e.displayIndex):void 0,d=[s.month],h=o.month,p=e.displayIndex===0,y=e.displayIndex===c.length-1,v=!p&&!y;a==="rtl"&&(t=[p,y],y=t[0],p=t[1]),p&&(d.push(s.caption_start),h=Pe(Pe({},h),o.caption_start)),y&&(d.push(s.caption_end),h=Pe(Pe({},h),o.caption_end)),v&&(d.push(s.caption_between),h=Pe(Pe({},h),o.caption_between));var m=(r=l==null?void 0:l.Caption)!==null&&r!==void 0?r:vG;return i.jsxs("div",{className:d.join(" "),style:h,children:[i.jsx(m,{id:u,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),i.jsx(iK,{id:f,"aria-labelledby":u,displayMonth:e.displayMonth})]},e.displayIndex)}function dK(e){var t=yt(),r=t.classNames,n=t.styles;return i.jsx("div",{className:r.months,style:n.months,children:e.children})}function fK(e){var t,r,n=e.initialProps,a=yt(),s=EN(),o=dh(),l=j.useState(!1),c=l[0],u=l[1];j.useEffect(function(){a.initialFocus&&s.focusTarget&&(c||(s.focus(s.focusTarget),u(!0)))},[a.initialFocus,c,s.focus,s.focusTarget,s]);var f=[a.classNames.root,a.className];a.numberOfMonths>1&&f.push(a.classNames.multiple_months),a.showWeekNumber&&f.push(a.classNames.with_weeknumber);var d=Pe(Pe({},a.styles.root),a.style),h=Object.keys(n).filter(function(y){return y.startsWith("data-")}).reduce(function(y,v){var m;return Pe(Pe({},y),(m={},m[v]=n[v],m))},{}),p=(r=(t=n.components)===null||t===void 0?void 0:t.Months)!==null&&r!==void 0?r:dK;return i.jsx("div",Pe({className:f.join(" "),style:d,dir:a.dir,id:a.id,nonce:n.nonce,title:n.title,lang:n.lang},h,{children:i.jsx(p,{children:o.displayMonths.map(function(y,v){return i.jsx(uK,{displayIndex:v,displayMonth:y},v)})})}))}function hK(e){var t=e.children,r=$q(e,["children"]);return i.jsx(rG,{initialProps:r,children:i.jsx(fG,{children:i.jsx(GG,{initialProps:r,children:i.jsx(wG,{initialProps:r,children:i.jsx(OG,{initialProps:r,children:i.jsx(DG,{children:i.jsx(VG,{children:t})})})})})})})}function pK(e){return i.jsx(hK,Pe({},e,{children:i.jsx(fK,{initialProps:e})}))}function Cs({className:e,classNames:t,showOutsideDays:r=!0,...n}){return i.jsx(pK,{showOutsideDays:r,className:ue("p-3",e),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:ue(Kd({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:ue(Kd({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...t},components:{IconLeft:({className:a,...s})=>i.jsx(FW,{className:ue("h-4 w-4",a),...s}),IconRight:({className:a,...s})=>i.jsx(BW,{className:ue("h-4 w-4",a),...s})},...n})}Cs.displayName="Calendar";var kN="Popover",[C$,FCe]=wn(kN,[jg]),fh=jg(),[mK,Bs]=C$(kN),E$=e=>{const{__scopePopover:t,children:r,open:n,defaultOpen:a,onOpenChange:s,modal:o=!1}=e,l=fh(t),c=j.useRef(null),[u,f]=j.useState(!1),[d=!1,h]=Ro({prop:n,defaultProp:a,onChange:s});return i.jsx(jR,{...l,children:i.jsx(mK,{scope:t,contentId:gi(),triggerRef:c,open:d,onOpenChange:h,onOpenToggle:j.useCallback(()=>h(p=>!p),[h]),hasCustomAnchor:u,onCustomAnchorAdd:j.useCallback(()=>f(!0),[]),onCustomAnchorRemove:j.useCallback(()=>f(!1),[]),modal:o,children:r})})};E$.displayName=kN;var T$="PopoverAnchor",vK=j.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,a=Bs(T$,r),s=fh(r),{onCustomAnchorAdd:o,onCustomAnchorRemove:l}=a;return j.useEffect(()=>(o(),()=>l()),[o,l]),i.jsx(mN,{...s,...n,ref:t})});vK.displayName=T$;var k$="PopoverTrigger",_$=j.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,a=Bs(k$,r),s=fh(r),o=Ye(t,a.triggerRef),l=i.jsx(Re.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":$$(a.open),...n,ref:o,onClick:je(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?l:i.jsx(mN,{asChild:!0,...s,children:l})});_$.displayName=k$;var _N="PopoverPortal",[gK,yK]=C$(_N,{forceMount:void 0}),D$=e=>{const{__scopePopover:t,forceMount:r,children:n,container:a}=e,s=Bs(_N,t);return i.jsx(gK,{scope:t,forceMount:r,children:i.jsx($s,{present:r||s.open,children:i.jsx(Zf,{asChild:!0,container:a,children:n})})})};D$.displayName=_N;var Sc="PopoverContent",M$=j.forwardRef((e,t)=>{const r=yK(Sc,e.__scopePopover),{forceMount:n=r.forceMount,...a}=e,s=Bs(Sc,e.__scopePopover);return i.jsx($s,{present:n||s.open,children:s.modal?i.jsx(bK,{...a,ref:t}):i.jsx(jK,{...a,ref:t})})});M$.displayName=Sc;var xK=Io("PopoverContent.RemoveScroll"),bK=j.forwardRef((e,t)=>{const r=Bs(Sc,e.__scopePopover),n=j.useRef(null),a=Ye(t,n),s=j.useRef(!1);return j.useEffect(()=>{const o=n.current;if(o)return Q1(o)},[]),i.jsx(vg,{as:xK,allowPinchZoom:!0,children:i.jsx(I$,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:je(e.onCloseAutoFocus,o=>{var l;o.preventDefault(),s.current||(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:je(e.onPointerDownOutside,o=>{const l=o.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;s.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:je(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),jK=j.forwardRef((e,t)=>{const r=Bs(Sc,e.__scopePopover),n=j.useRef(!1),a=j.useRef(!1);return i.jsx(I$,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,l;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(n.current||(l=r.triggerRef.current)==null||l.focus(),s.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:s=>{var c,u;(c=e.onInteractOutside)==null||c.call(e,s),s.defaultPrevented||(n.current=!0,s.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=s.target;((u=r.triggerRef.current)==null?void 0:u.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&a.current&&s.preventDefault()}})}),I$=j.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:s,disableOutsidePointerEvents:o,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:f,...d}=e,h=Bs(Sc,r),p=fh(r);return Y1(),i.jsx(pg,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:s,children:i.jsx(Xf,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:f,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>h.onOpenChange(!1),children:i.jsx(wR,{"data-state":$$(h.open),role:"dialog",id:h.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),R$="PopoverClose",wK=j.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,a=Bs(R$,r);return i.jsx(Re.button,{type:"button",...n,ref:t,onClick:je(e.onClick,()=>a.onOpenChange(!1))})});wK.displayName=R$;var NK="PopoverArrow",SK=j.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,a=fh(r);return i.jsx(NR,{...a,...n,ref:t})});SK.displayName=NK;function $$(e){return e?"open":"closed"}var OK=E$,PK=_$,AK=D$,L$=M$;const zo=OK,Wo=PK,Es=j.forwardRef(({className:e,align:t="center",sideOffset:r=4,...n},a)=>i.jsx(AK,{children:i.jsx(L$,{ref:a,align:t,sideOffset:r,className:ue("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",e),...n})}));Es.displayName=L$.displayName;function Mm({isOpen:e,onClose:t}){const{toast:r}=Ht(),n=$r(),{user:a}=qn(),[s,o]=j.useState(""),[l,c]=j.useState(""),[u,f]=j.useState(""),[d,h]=j.useState(""),[p,y]=j.useState(""),[v,m]=j.useState(""),[x,g]=j.useState(""),[b,N]=j.useState(""),[w,S]=j.useState(void 0),[O,P]=j.useState([{productType:"",unit:"",quantity:0,price:0,total:0}]),{data:A=[]}=Fe({queryKey:["/api/users"],select:q=>q.filter(ne=>ne.role==="sales_officer"),enabled:(a==null?void 0:a.role)==="approver"||(a==null?void 0:a.role)==="super_admin"}),{data:C=[]}=Fe({queryKey:["/api/products"],staleTime:30*1e3}),T=(q,ne)=>{const le=C.find(de=>de.productType===q&&de.stock===ne);return le?le.currentBalance:0},D=(q,ne,le,de)=>{const ie=T(q,le),ve=de==="carton"?ne*12:ne;return ie>=ve},_=rt({mutationFn:async q=>{console.log("Submitting order data:",q);const ne={...q,customerId:`CUST-${Date.now()}`,session:"session_1",stock:"stock_1",items:q.items||[],totalAmount:q.totalAmount.toString()};return console.log("Formatted order data:",ne),await ut("POST","/api/orders",ne)},onSuccess:()=>{r({title:"Success",description:"Order created successfully!"}),n.invalidateQueries({queryKey:["/api/orders"]}),n.invalidateQueries({queryKey:["/api/orders/my-orders"]}),K()},onError:q=>{console.error("Order creation error:",q),r({title:"Error",description:(q==null?void 0:q.message)||"Failed to create order",variant:"destructive"})}}),k=[{id:"milk_one",name:"Milk One",description:"Standard infant formula"},{id:"milk_two",name:"Milk Two",description:"Follow-up formula"},{id:"milk_three",name:"Milk Three",description:"Growing up milk"},{id:"AR",name:"AR Formula",description:"Anti-reflux formula"},{id:"LF",name:"LF Formula",description:"Lactose-free formula"},{id:"premature",name:"Premature",description:"For premature babies"}],R={milk_one:{tin:1275,carton:7500},milk_two:{tin:1350,carton:8100},milk_three:{tin:1425,carton:8550},AR:{tin:1600,carton:9600},LF:{tin:1500,carton:9e3},premature:{tin:1750,carton:10500}},$=()=>{P([...O,{productType:"",unit:"",quantity:0,price:0,total:0}])},I=q=>{O.length>1&&P(O.filter((ne,le)=>le!==q))},E=(q,ne,le)=>{const de=[...O];if(de[q]={...de[q],[ne]:le},ne==="productType"||ne==="unit"){const ie=ne==="productType"?le:de[q].productType,ve=ne==="unit"?le:de[q].unit;if(ie&&ve&&R[ie]){const re=R[ie][ve];de[q].price===0&&(de[q].price=re||0),de[q].total=de[q].quantity*de[q].price}}(ne==="quantity"||ne==="price")&&(de[q].total=(ne==="quantity"?le:de[q].quantity)*(ne==="price"?le:de[q].price)),P(de)},F=()=>O.reduce((q,ne)=>q+ne.total,0),V=()=>{const q=s&&l&&u&&d&&p&&v,ne=O.some(ie=>ie.productType&&ie.unit&&ie.quantity>0),le=p!=="credit"||w,de=O.every(ie=>!ie.productType||ie.quantity<=0?!0:D(ie.productType,ie.quantity,"stock_1",ie.unit));return q&&ne&&le&&de},G=()=>{if(!V()){r({title:"Validation Error",description:"Please fill in all required fields",variant:"destructive"});return}const q={customerName:s,customerTinNumber:l,customerMobileNumber:u,customerArea:d,paymentTerm:p,businessSector:v,notes:x,items:O.filter(ne=>ne.productType&&ne.quantity>0),totalAmount:F(),salesOfficerId:b||(a==null?void 0:a.id),creditDueDate:p==="credit"?w:null};_.mutate(q)},K=()=>{o(""),c(""),f(""),h(""),y(""),m(""),g(""),N(""),S(void 0),P([{productType:"",unit:"",quantity:0,price:0,total:0}]),t()};return i.jsx(zt,{open:e,onOpenChange:K,children:i.jsxs($t,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[i.jsx(Lt,{children:i.jsxs(Ft,{className:"flex items-center",children:[i.jsx(Ot,{className:"w-5 h-5 mr-2"}),"Create New France Lait Order"]})}),i.jsxs("div",{className:"space-y-6",children:[i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{className:"text-lg",children:"Customer Information"})}),i.jsxs(H,{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"customerName",children:"Customer Name *"}),i.jsx(he,{id:"customerName",value:s,onChange:q=>o(q.target.value),placeholder:"Enter customer name"})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"customerTin",children:"TIN Number *"}),i.jsx(he,{id:"customerTin",value:l,onChange:q=>c(q.target.value),placeholder:"Enter TIN number"})]})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"customerMobile",children:"Mobile Number *"}),i.jsx(he,{id:"customerMobile",value:u,onChange:q=>f(q.target.value),placeholder:"Enter mobile number",type:"tel"})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"customerArea",children:"Customer Area *"}),i.jsx(he,{id:"customerArea",value:d,onChange:q=>h(q.target.value),placeholder:"Enter customer area/location"})]})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"paymentTerm",children:"Payment Term *"}),i.jsxs(_e,{value:p,onValueChange:y,children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"Select payment term"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"cash",children:"Cash"}),i.jsx(U,{value:"credit",children:"Credit"})]})]})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"businessSector",children:"Business Sector *"}),i.jsxs(_e,{value:v,onValueChange:m,children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"Select business sector"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"pharmacy",children:"Pharmacy"}),i.jsx(U,{value:"wholesale",children:"Wholesale"}),i.jsx(U,{value:"supermarket",children:"Supermarket"}),i.jsx(U,{value:"shop",children:"Shop"}),i.jsx(U,{value:"mch",children:"MCH"}),i.jsx(U,{value:"walking",children:"Walking"})]})]})]})]}),p==="credit"&&i.jsxs("div",{children:[i.jsx(X,{children:"Credit Due Date *"}),i.jsxs(zo,{children:[i.jsx(Wo,{asChild:!0,children:i.jsxs(z,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[i.jsx(Dr,{className:"mr-2 h-4 w-4"}),w?Ve(w,"PPP"):"Select due date"]})}),i.jsxs(Es,{className:"w-auto p-0",align:"start",children:[i.jsx("div",{className:"p-3 border-b",children:i.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[i.jsx(z,{variant:"outline",size:"sm",onClick:()=>S(Kt(new Date,30)),children:"30 Days"}),i.jsx(z,{variant:"outline",size:"sm",onClick:()=>S(Kt(new Date,60)),children:"60 Days"}),i.jsx(z,{variant:"outline",size:"sm",onClick:()=>S(Kt(new Date,90)),children:"90 Days"})]})}),i.jsx(Cs,{mode:"single",selected:w,onSelect:S,disabled:q=>qi.jsxs(U,{value:q.id,children:[q.firstName," ",q.lastName]},q.id))})]}),i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Leave empty to assign to yourself"})]})]})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(ee,{className:"text-lg",children:"France Lait Products"}),i.jsxs(z,{onClick:$,size:"sm",children:[i.jsx(fn,{className:"w-4 h-4 mr-2"}),"Add Product"]})]})}),i.jsx(H,{className:"space-y-4",children:O.map((q,ne)=>i.jsx(W,{className:"border border-slate-200",children:i.jsx(H,{className:"p-4",children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-6 gap-4 items-end",children:[i.jsxs("div",{className:"md:col-span-2",children:[i.jsx(X,{children:"Product *"}),i.jsxs(_e,{value:q.productType,onValueChange:le=>E(ne,"productType",le),children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"Select product"})}),i.jsx(Ce,{children:k.map(le=>{const ie=T(le.id,"stock_1");return i.jsx(U,{value:le.id,children:i.jsxs("div",{className:"flex items-center justify-between w-full",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-medium",children:le.name}),i.jsx("div",{className:"text-xs text-muted-foreground",children:le.description})]}),i.jsx("div",{className:"ml-2",children:i.jsxs(te,{variant:ie>0?"default":"destructive",className:"text-xs",children:["Stock: ",ie]})})]})},le.id)})})]})]}),i.jsxs("div",{children:[i.jsx(X,{children:"Unit *"}),i.jsxs(_e,{value:q.unit,onValueChange:le=>E(ne,"unit",le),children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"Unit"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"tin",children:"Tin"}),i.jsx(U,{value:"carton",children:"Carton"})]})]})]}),i.jsxs("div",{children:[i.jsx(X,{children:"Quantity *"}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(he,{type:"number",value:q.quantity||"",onChange:le=>E(ne,"quantity",parseInt(le.target.value)||0),placeholder:"0",min:"0",className:(()=>{const de=D(q.productType,q.quantity,"stock_1",q.unit);return q.productType&&q.quantity>0&&!de?"border-red-500 focus:border-red-500":""})()}),q.productType&&i.jsx("div",{className:"text-xs",children:(()=>{const le="stock_1",de=T(q.productType,le),ie=D(q.productType,q.quantity,le,q.unit),ve=q.unit==="carton"?Math.floor(de/12):de;return q.quantity>0&&!ie?i.jsxs("span",{className:"text-red-600",children:["Insufficient stock! Available: ",ve," ",q.unit||"tins"]}):de>0?i.jsxs("span",{className:"text-green-600",children:["Available: ",ve," ",q.unit||"tins"]}):i.jsx("span",{className:"text-red-600",children:"Out of stock"})})()})]})]}),i.jsxs("div",{children:[i.jsx(X,{children:"Price *"}),i.jsx(he,{type:"number",value:q.price||"",onChange:le=>E(ne,"price",parseFloat(le.target.value)||0),placeholder:"Enter price",step:"0.01",min:"0"})]}),i.jsxs("div",{className:"flex items-end space-x-2",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx(X,{children:"Total"}),i.jsx(he,{type:"number",value:q.total.toFixed(2),readOnly:!0,className:"bg-gray-50"})]}),O.length>1&&i.jsx(z,{variant:"outline",size:"icon",onClick:()=>I(ne),className:"text-red-600 hover:text-red-700",children:i.jsx(jc,{className:"w-4 h-4"})})]})]})})},ne))})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{className:"text-lg",children:"Additional Notes"})}),i.jsx(H,{children:i.jsx(Wn,{value:x,onChange:q=>g(q.target.value),placeholder:"Add any special instructions or notes...",rows:3})})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{className:"text-lg",children:"Order Summary"})}),i.jsx(H,{children:i.jsxs("div",{className:"flex justify-between items-center text-lg font-semibold",children:[i.jsx("span",{children:"Total Amount:"}),i.jsxs(te,{variant:"secondary",className:"text-lg px-3 py-1",children:["ETB ",F().toFixed(2)]})]})})]})]}),i.jsx(yN,{}),i.jsxs("div",{className:"flex justify-end space-x-2",children:[i.jsx(z,{variant:"outline",onClick:K,disabled:_.isPending,children:"Cancel"}),i.jsx(z,{onClick:G,disabled:!V()||_.isPending,className:"bg-blue-600 hover:bg-blue-700",children:_.isPending?"Creating...":"Create Order"})]})]})})}function Ix(){const{user:e}=qn();Ht();const[t,r]=j.useState(!1),[n,a]=j.useState(null),[s,o]=j.useState(!1),{data:l}=Fe({queryKey:["/api/orders/stats"],enabled:!!e}),{data:c=[]}=Fe({queryKey:["/api/orders",{limit:10}],enabled:!!e,select:m=>m.sort((x,g)=>new Date(g.createdAt).getTime()-new Date(x.createdAt).getTime())}),{data:u=[]}=Fe({queryKey:["/api/users"],staleTime:5*60*1e3});if(!e)return null;const f=m=>{const x=u.find(g=>g.id===m);return x?`${x.firstName} ${x.lastName}`:"Unknown"},d=m=>{switch(m){case"approved":return i.jsx(te,{variant:"default",className:"bg-emerald-100 text-emerald-800",children:"Approved"});case"rejected":return i.jsx(te,{variant:"destructive",children:"Rejected"});case"pending":return i.jsx(te,{variant:"secondary",className:"bg-amber-100 text-amber-800",children:"Pending Review"});case"completed":return i.jsx(te,{variant:"default",className:"bg-blue-100 text-blue-800",children:"Completed"});case"processing":return i.jsx(te,{variant:"outline",className:"bg-purple-100 text-purple-800",children:"Processing"});default:return i.jsx(te,{variant:"outline",children:m})}},h=m=>{try{if(!m)return"No date";const x=new Date,g=new Date(m);if(isNaN(g.getTime())||isNaN(x.getTime()))return"Invalid date";const b=Math.floor((x.getTime()-g.getTime())/(1e3*60));if(b<60)return b+" min ago";if(b<1440){const N=Math.floor(b/60);return N+" hour"+(N>1?"s":"")+" ago"}else{const N=Math.floor(b/1440);return N+" day"+(N>1?"s":"")+" ago"}}catch(x){return console.error("Date formatting error:",x),"Date error"}},p=m=>{const x=typeof m=="string"?parseFloat(m):m;return new Intl.NumberFormat("en-US",{style:"currency",currency:"ETB",minimumFractionDigits:0,maximumFractionDigits:0}).format(x).replace("ETB","ETB ")},y=m=>m&&m.trim()?i.jsxs(te,{variant:"outline",className:"bg-blue-50 text-blue-700 font-mono",children:["FS: ",m]}):i.jsx(te,{variant:"outline",className:"bg-gray-100 text-gray-600",children:"FS not set"}),v=m=>{a(m),o(!0)};return i.jsxs(ih,{title:"Dashboard",subtitle:"Order management overview",children:[i.jsxs(W,{className:"mb-6",children:[i.jsx(J,{children:i.jsxs(ee,{className:"flex items-center text-blue-800",children:[i.jsx(Pl,{className:"w-5 h-5 mr-2"}),"Quick Actions"]})}),i.jsxs(H,{className:"grid grid-cols-2 gap-3",children:[i.jsxs(z,{className:"h-16 flex flex-col items-center justify-center bg-green-600 hover:bg-green-700",onClick:()=>r(!0),children:[i.jsx(fn,{className:"w-6 h-6 mb-1"}),i.jsx("span",{className:"text-sm",children:"Create Order"})]}),i.jsxs(z,{variant:"outline",className:"h-16 flex flex-col items-center justify-center border-blue-300 hover:bg-blue-50",onClick:()=>window.location.href="/tracking",children:[i.jsx(Et,{className:"w-6 h-6 mb-1 text-blue-600"}),i.jsx("span",{className:"text-sm text-blue-600",children:"View All Orders"})]})]})]}),i.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4 mb-6",children:[i.jsx(W,{children:i.jsxs(H,{className:"p-4 text-center",children:[i.jsx("div",{className:"flex items-center justify-center mb-2",children:i.jsx(Mr,{className:"w-8 h-8 text-blue-600"})}),i.jsx("p",{className:"text-2xl font-bold text-slate-900",children:(l==null?void 0:l.total)||0}),i.jsx("p",{className:"text-sm text-slate-600",children:"Total Orders"})]})}),i.jsx(W,{children:i.jsxs(H,{className:"p-4 text-center",children:[i.jsx("div",{className:"flex items-center justify-center mb-2",children:i.jsx(wr,{className:"w-8 h-8 text-amber-600"})}),i.jsx("p",{className:"text-2xl font-bold text-slate-900",children:(l==null?void 0:l.pending)||0}),i.jsx("p",{className:"text-sm text-slate-600",children:"Pending"})]})}),i.jsx(W,{children:i.jsxs(H,{className:"p-4 text-center",children:[i.jsx("div",{className:"flex items-center justify-center mb-2",children:i.jsx(ct,{className:"w-8 h-8 text-emerald-600"})}),i.jsx("p",{className:"text-2xl font-bold text-slate-900",children:(l==null?void 0:l.approved)||0}),i.jsx("p",{className:"text-sm text-slate-600",children:"Approved"})]})}),i.jsx(W,{children:i.jsxs(H,{className:"p-4 text-center",children:[i.jsx("div",{className:"flex items-center justify-center mb-2",children:i.jsx(ct,{className:"w-8 h-8 text-blue-600"})}),i.jsx("p",{className:"text-2xl font-bold text-slate-900",children:Array.isArray(c)?c.filter(m=>m.status==="completed").length:0}),i.jsx("p",{className:"text-sm text-slate-600",children:"Completed"})]})})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"flex items-center justify-between",children:[i.jsxs("span",{className:"flex items-center",children:[i.jsx(Et,{className:"w-5 h-5 mr-2"}),"Latest Orders"]}),i.jsx(z,{variant:"ghost",size:"sm",onClick:()=>window.location.href="/tracking",children:i.jsx($W,{className:"w-4 h-4"})})]})}),i.jsx(H,{children:Array.isArray(c)&&c.length>0?i.jsx("div",{className:"space-y-3",children:c.slice(0,8).map(m=>i.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-lg hover:bg-gray-100 transition-colors",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center space-x-2 mb-1",children:[i.jsx("p",{className:"font-medium text-gray-900",children:m.orderNumber||`Order #${m.id}`}),y(m.fsNumber)]}),i.jsx("p",{className:"text-sm text-gray-600 truncate",children:m.customerName}),m.customerTinNumber&&i.jsxs("p",{className:"text-xs text-gray-500 font-mono",children:["TIN: ",m.customerTinNumber]}),i.jsxs("div",{className:"flex items-center space-x-2 mt-1",children:[i.jsx("p",{className:"text-sm font-medium text-green-600",children:p(m.totalAmount)}),m.salesOfficerId&&i.jsxs("div",{className:"flex items-center space-x-1",children:[i.jsx("div",{className:"w-5 h-5 bg-blue-100 rounded-full flex items-center justify-center",children:i.jsx("span",{className:"text-xs font-medium text-blue-800",children:f(m.salesOfficerId).split(" ").map(x=>x.charAt(0)).join("")})}),i.jsx("span",{className:"text-xs text-gray-500",children:f(m.salesOfficerId)})]})]}),i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:h(m.createdAt)})]}),i.jsxs("div",{className:"flex items-center space-x-2",children:[d(m.status),i.jsx(z,{size:"sm",variant:"ghost",onClick:()=>v(m),children:i.jsx(au,{className:"w-4 h-4"})})]})]},m.id))}):i.jsxs("div",{className:"text-center py-12 text-gray-500",children:[i.jsx(Et,{className:"w-16 h-16 mx-auto mb-4 text-gray-300"}),i.jsx("p",{className:"text-lg font-medium mb-2",children:"No orders yet"}),i.jsx("p",{className:"text-sm mb-4",children:"Create your first order to get started"}),i.jsxs(z,{onClick:()=>r(!0),className:"bg-blue-600 hover:bg-blue-700",children:[i.jsx(fn,{className:"w-4 h-4 mr-2"}),"Create Order"]})]})})]}),i.jsx(Mm,{isOpen:t,onClose:()=>r(!1)}),n&&i.jsx(zt,{open:s,onOpenChange:()=>{o(!1),a(null)},children:i.jsxs($t,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[i.jsx(Lt,{children:i.jsxs(Ft,{children:["Order Details - ",n.orderNumber||`#${n.id}`]})}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center space-x-2",children:[d(n.status),n.fsNumber&&i.jsxs(te,{variant:"outline",className:"bg-blue-50 text-blue-700",children:["FS: ",n.fsNumber]})]}),i.jsx("p",{className:"text-2xl font-bold text-green-600",children:p(n.totalAmount)})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{className:"text-lg",children:"Customer Information"})}),i.jsxs(H,{className:"space-y-2",children:[i.jsxs("p",{children:[i.jsx("strong",{children:"Name:"})," ",n.customerName]}),i.jsxs("p",{children:[i.jsx("strong",{children:"TIN:"})," ",i.jsx("span",{className:"font-mono",children:n.customerTinNumber})]}),i.jsxs("p",{children:[i.jsx("strong",{children:"Mobile:"})," ",n.customerMobileNumber]}),i.jsxs("p",{children:[i.jsx("strong",{children:"Area:"})," ",n.customerArea]}),i.jsxs("p",{children:[i.jsx("strong",{children:"Business Sector:"})," ",n.businessSector]})]})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{className:"text-lg",children:"Order Information"})}),i.jsxs(H,{className:"space-y-2",children:[i.jsxs("p",{children:[i.jsx("strong",{children:"Payment Term:"})," ",n.paymentTerm]}),i.jsxs("p",{children:[i.jsx("strong",{children:"Stock:"})," ",n.stock]}),i.jsxs("p",{children:[i.jsx("strong",{children:"Sales Person:"})," ",n.salesOfficerId]}),i.jsxs("p",{children:[i.jsx("strong",{children:"Created:"})," ",h(n.createdAt)]}),n.approvedAt&&i.jsxs("p",{children:[i.jsx("strong",{children:"Approved:"})," ",h(n.approvedAt)]})]})]})]}),n.items&&i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{className:"text-lg",children:"Order Items"})}),i.jsx(H,{children:i.jsx("div",{className:"space-y-2",children:n.items.map((m,x)=>{var g;return i.jsxs("div",{className:"flex justify-between items-center p-2 bg-gray-50 rounded",children:[i.jsxs("div",{children:[i.jsx("p",{className:"font-medium",children:(g=m.productType)==null?void 0:g.replace("_"," ")}),i.jsxs("p",{className:"text-sm text-gray-600",children:[m.quantity," ",m.unit]})]}),i.jsxs("div",{className:"text-right",children:[i.jsx("p",{className:"font-medium",children:p(m.total)}),i.jsxs("p",{className:"text-sm text-gray-600",children:["@ ",p(m.price)]})]})]},x)})})})]})]})]})})]})}const Vl=j.forwardRef(({className:e,...t},r)=>i.jsx("div",{className:"relative w-full overflow-auto",children:i.jsx("table",{ref:r,className:ue("w-full caption-bottom text-sm",e),...t})}));Vl.displayName="Table";const ql=j.forwardRef(({className:e,...t},r)=>i.jsx("thead",{ref:r,className:ue("[&_tr]:border-b",e),...t}));ql.displayName="TableHeader";const Gl=j.forwardRef(({className:e,...t},r)=>i.jsx("tbody",{ref:r,className:ue("[&_tr:last-child]:border-0",e),...t}));Gl.displayName="TableBody";const CK=j.forwardRef(({className:e,...t},r)=>i.jsx("tfoot",{ref:r,className:ue("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));CK.displayName="TableFooter";const zr=j.forwardRef(({className:e,...t},r)=>i.jsx("tr",{ref:r,className:ue("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));zr.displayName="TableRow";const Le=j.forwardRef(({className:e,...t},r)=>i.jsx("th",{ref:r,className:ue("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...t}));Le.displayName="TableHead";const ke=j.forwardRef(({className:e,...t},r)=>i.jsx("td",{ref:r,className:ue("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));ke.displayName="TableCell";const EK=j.forwardRef(({className:e,...t},r)=>i.jsx("caption",{ref:r,className:ue("mt-4 text-sm text-muted-foreground",e),...t}));EK.displayName="TableCaption";const TK=tN,kK=rN,_K=nN,F$=j.forwardRef(({className:e,...t},r)=>i.jsx(th,{className:ue("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:r}));F$.displayName=th.displayName;const DK=Jf("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),B$=j.forwardRef(({side:e="right",className:t,children:r,...n},a)=>i.jsxs(_K,{children:[i.jsx(F$,{}),i.jsxs(rh,{ref:a,className:ue(DK({side:e}),t),...n,children:[r,i.jsxs(gg,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[i.jsx(su,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));B$.displayName=rh.displayName;const MK=j.forwardRef(({className:e,...t},r)=>i.jsx(nh,{ref:r,className:ue("text-lg font-semibold text-foreground",e),...t}));MK.displayName=nh.displayName;const IK=j.forwardRef(({className:e,...t},r)=>i.jsx(ah,{ref:r,className:ue("text-sm text-muted-foreground",e),...t}));IK.displayName=ah.displayName;const Rx=768;function hh(){const[e,t]=j.useState(void 0);return j.useEffect(()=>{const r=window.matchMedia(`(max-width: ${Rx-1}px)`),n=()=>{t(window.innerWidthr.removeEventListener("change",n)},[]),!!e}function ca(){const{user:e}=Za(),[t]=Qf(),r=hh(),[n,a]=j.useState(!1);if(!e)return null;const o=[{label:"Dashboard",href:"/",icon:WW,roles:["super_admin","approver","sales_clerk","management","sales_officer"]},{label:"Order Tracking",href:"/tracking",icon:Xr,roles:["sales_officer"]},{label:"Orders",href:"/orders",icon:Et,roles:["super_admin","approver","sales_clerk","management"]},{label:"Order Approvals",href:"/approvals",icon:ct,roles:["super_admin","approver","management"]},{label:"Stock Inventory",href:"/session-inventory",icon:Ot,roles:["super_admin","approver"]},{label:"Stock Reports",href:"/session-reports",icon:Et,roles:["super_admin","approver","management"]},{label:"User Management",href:"/users",icon:Ss,roles:["super_admin"]},{label:"Management Reports",href:"/reports",icon:V1,roles:["super_admin","management"]},{label:"Payment Approvals",href:"/payment-approvals",icon:ct,roles:["super_admin","approver"]},{label:"Analytics",href:"/analytics",icon:Xr,roles:["super_admin","sales_clerk","management"]},{label:"Payment Reports",href:"/payment-reports",icon:Ka,roles:["super_admin","approver","management"]},{label:"My Payment Tracking",href:"/my-payment-tracking",icon:Ka,roles:["sales_officer"]},{label:"Bot Management",href:"/bot",icon:ha,roles:["super_admin"]},{label:"Logout",href:"#logout",icon:uI,roles:["super_admin","approver","sales_clerk","management","sales_officer"],isLogout:!0}].filter(d=>d.roles.includes((e==null?void 0:e.role)||"")),l=()=>{const d=e;return d!=null&&d.firstName&&(d!=null&&d.lastName)?`${d.firstName.charAt(0)}${d.lastName.charAt(0)}`.toUpperCase():d!=null&&d.email?d.email.substring(0,2).toUpperCase():"U"},c=()=>{const d=e;return d!=null&&d.firstName&&(d!=null&&d.lastName)?`${d.firstName} ${d.lastName}`:d!=null&&d.email?d.email:"User"},u=()=>({super_admin:"Super Admin",approver:"Approver",sales_clerk:"Sales Clerk",management:"Management",sales_officer:"Sales Officer"})[e==null?void 0:e.role]||(e==null?void 0:e.role),f=()=>i.jsxs("div",{className:"h-full flex flex-col bg-white",children:[i.jsx("div",{className:"p-4 sm:p-6 border-b border-slate-200",children:i.jsxs("div",{className:"flex items-center",children:[i.jsx("div",{className:"w-8 h-8 bg-gradient-to-r from-blue-600 to-purple-600 rounded-lg flex items-center justify-center shadow-lg",children:i.jsx(ha,{className:"w-5 h-5 text-white"})}),i.jsxs("div",{className:"ml-3",children:[i.jsx("span",{className:"text-lg sm:text-xl font-bold text-slate-800",children:"DOK TOK"}),i.jsx("p",{className:"text-xs text-slate-500 hidden sm:block",children:"Sales Management"})]})]})}),i.jsx("nav",{className:"flex-1 p-3 sm:p-6 overflow-y-auto max-h-full",children:i.jsx("div",{className:"space-y-1",children:o.map((d,h)=>{const p=d.icon,y=t===d.href;return d.isLogout?i.jsxs(z,{variant:"outline",className:"w-full justify-start h-12 px-3 sm:px-4 text-red-600 border-red-200 hover:text-white hover:bg-red-600 hover:border-red-600 transition-all duration-200 mt-4",onClick:async()=>{try{await fetch("/api/auth/logout",{method:"POST"}),window.location.href="/login"}catch(m){console.error("Logout error:",m),window.location.href="/login"}},children:[i.jsx(p,{className:"w-5 h-5 mr-3"}),i.jsx("span",{className:"font-medium text-sm sm:text-base truncate",children:d.label})]},`logout-${h}`):i.jsx(gM,{href:d.href,children:i.jsxs(z,{variant:y?"default":"ghost",className:ue("w-full justify-start h-12 px-3 sm:px-4 text-left group transition-all duration-200",y?"bg-gradient-to-r from-blue-600 to-purple-600 text-white shadow-lg":"hover:bg-slate-50 hover:shadow-sm text-slate-700"),onClick:()=>a(!1),children:[i.jsx(p,{className:ue("w-5 h-5 mr-3 transition-transform duration-200",y?"scale-110":"group-hover:scale-105")}),i.jsx("span",{className:"font-medium text-sm sm:text-base truncate",children:d.label})]})},`${d.href}-${h}`)})})}),i.jsx("div",{className:"border-t border-slate-200 p-3 sm:p-6 bg-slate-50",children:i.jsxs("div",{className:"flex items-center space-x-3",children:[i.jsx("div",{className:"w-10 h-10 bg-gradient-to-r from-blue-600 to-purple-600 text-white rounded-full flex items-center justify-center shadow-lg",children:i.jsx("span",{className:"text-sm font-bold",children:l()})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"text-sm font-semibold text-slate-900 truncate",children:c()}),i.jsx("p",{className:"text-xs text-slate-500 truncate bg-slate-100 px-2 py-1 rounded-full inline-block",children:u()})]})]})})]});return r?i.jsx(i.Fragment,{children:i.jsxs(TK,{open:n,onOpenChange:a,children:[i.jsx(kK,{asChild:!0,children:i.jsx(z,{variant:"outline",size:"sm",className:"fixed top-4 left-4 z-50 md:hidden bg-white shadow-lg border-slate-200 hover:bg-slate-50 transition-all duration-200",children:i.jsx(fI,{className:"h-5 w-5 text-slate-700"})})}),i.jsx(B$,{side:"left",className:"w-72 sm:w-80 p-0 bg-white",children:i.jsx(f,{})})]})}):i.jsx("aside",{className:"fixed left-0 top-0 h-full w-64 bg-white shadow-sm border-r border-slate-200 z-40 hidden md:block",children:i.jsx(f,{})})}function Ts(){const{user:e}=qn(),{isEditMode:t,toggleEditMode:r}=I7(),[n,a]=j.useState(60);j.useEffect(()=>{const c=setInterval(()=>{a(u=>u<=1?(window.location.href="/api/logout",0):u-1)},6e4);return()=>clearInterval(c)},[]);const s=()=>n>30?"session-indicator":n>10?"session-indicator-warning":"session-indicator-critical",o=()=>n>30?"text-emerald-700":n>10?"text-amber-700":"text-red-700",l=()=>n>30?"bg-emerald-400":n>10?"bg-amber-400":"bg-red-400";return e?i.jsx("header",{className:"bg-white border-b border-slate-200 px-4 sm:px-6 py-3 sm:py-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex-1 min-w-0 ml-16 sm:ml-0",children:[i.jsx("h1",{className:"text-lg sm:text-2xl font-semibold text-slate-800 truncate",id:"pageTitle",children:"Dashboard"}),i.jsx("p",{className:"text-sm text-slate-600",id:"pageSubtitle",children:"Welcome back! Here's what's happening today."})]}),i.jsxs("div",{className:"flex items-center space-x-2 sm:space-x-4",children:[i.jsx("div",{className:`hidden sm:block ${s()}`,children:i.jsxs("div",{className:"flex items-center",children:[i.jsx("div",{className:`w-2 h-2 rounded-full mr-2 ${l()}`}),i.jsxs("span",{className:`text-sm font-medium ${o()}`,children:["Session expires in ",n,"m"]})]})}),i.jsx("div",{className:`sm:hidden ${s()}`,children:i.jsx("div",{className:`w-3 h-3 rounded-full ${l()}`})}),(e==null?void 0:e.role)==="super_admin"&&i.jsxs(z,{variant:t?"default":"ghost",size:"sm",onClick:r,className:"flex items-center gap-2",children:[i.jsx(hI,{className:"h-4 w-4"}),t?"Exit Edit":"Edit Mode"]}),i.jsxs(z,{variant:"ghost",size:"sm",className:"relative p-2 text-slate-400 hover:text-slate-600 hover:bg-slate-100 transition-colors duration-200",children:[i.jsx(Bl,{className:"w-5 h-5"}),i.jsx("span",{className:"absolute top-1 right-1 w-2 h-2 bg-red-500 rounded-full animate-pulse"})]})]})]})}):null}function rj(e){const t=RK(e),r=j.forwardRef((n,a)=>{const{children:s,...o}=n,l=j.Children.toArray(s),c=l.find(LK);if(c){const u=c.props.children,f=l.map(d=>d===c?j.Children.count(u)>1?j.Children.only(null):j.isValidElement(u)?u.props.children:null:d);return i.jsx(t,{...o,ref:a,children:j.isValidElement(u)?j.cloneElement(u,void 0,f):null})}return i.jsx(t,{...o,ref:a,children:s})});return r.displayName=`${e}.Slot`,r}function RK(e){const t=j.forwardRef((r,n)=>{const{children:a,...s}=r;if(j.isValidElement(a)){const o=BK(a),l=FK(s,a.props);return a.type!==j.Fragment&&(l.ref=n?U1(n,o):o),j.cloneElement(a,l)}return j.Children.count(a)>1?j.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var $K=Symbol("radix.slottable");function LK(e){return j.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===$K}function FK(e,t){const r={...t};for(const n in t){const a=e[n],s=t[n];/^on[A-Z]/.test(n)?a&&s?r[n]=(...l)=>{const c=s(...l);return a(...l),c}:a&&(r[n]=a):n==="style"?r[n]={...a,...s}:n==="className"&&(r[n]=[a,s].filter(Boolean).join(" "))}return{...e,...r}}function BK(e){var n,a;let t=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function UK(e){const t=e+"CollectionProvider",[r,n]=wn(t),[a,s]=r(t,{collectionRef:{current:null},itemMap:new Map}),o=v=>{const{scope:m,children:x}=v,g=M.useRef(null),b=M.useRef(new Map).current;return i.jsx(a,{scope:m,itemMap:b,collectionRef:g,children:x})};o.displayName=t;const l=e+"CollectionSlot",c=rj(l),u=M.forwardRef((v,m)=>{const{scope:x,children:g}=v,b=s(l,x),N=Ye(m,b.collectionRef);return i.jsx(c,{ref:N,children:g})});u.displayName=l;const f=e+"CollectionItemSlot",d="data-radix-collection-item",h=rj(f),p=M.forwardRef((v,m)=>{const{scope:x,children:g,...b}=v,N=M.useRef(null),w=Ye(m,N),S=s(f,x);return M.useEffect(()=>(S.itemMap.set(N,{ref:N,...b}),()=>void S.itemMap.delete(N))),i.jsx(h,{[d]:"",ref:w,children:g})});p.displayName=f;function y(v){const m=s(e+"CollectionConsumer",v);return M.useCallback(()=>{const g=m.collectionRef.current;if(!g)return[];const b=Array.from(g.querySelectorAll(`[${d}]`));return Array.from(m.itemMap.values()).sort((S,O)=>b.indexOf(S.ref.current)-b.indexOf(O.ref.current))},[m.collectionRef,m.itemMap])}return[{Provider:o,Slot:u,ItemSlot:p},y,n]}var zK=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],du=zK.reduce((e,t)=>{const r=rj(`Primitive.${t}`),n=j.forwardRef((a,s)=>{const{asChild:o,...l}=a,c=o?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),i.jsx(c,{...l,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),WK=Hw[" useInsertionEffect ".trim().toString()]||Jt;function U$({prop:e,defaultProp:t,onChange:r=()=>{},caller:n}){const[a,s,o]=HK({defaultProp:t,onChange:r}),l=e!==void 0,c=l?e:a;{const f=j.useRef(e!==void 0);j.useEffect(()=>{const d=f.current;d!==l&&console.warn(`${n} is changing from ${d?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=l},[l,n])}const u=j.useCallback(f=>{var d;if(l){const h=VK(f)?f(e):f;h!==e&&((d=o.current)==null||d.call(o,h))}else s(f)},[l,e,s,o]);return[c,u]}function HK({defaultProp:e,onChange:t}){const[r,n]=j.useState(e),a=j.useRef(r),s=j.useRef(t);return WK(()=>{s.current=t},[t]),j.useEffect(()=>{var o;a.current!==r&&((o=s.current)==null||o.call(s,r),a.current=r)},[r,a]),[r,n,s]}function VK(e){return typeof e=="function"}var $x="rovingFocusGroup.onEntryFocus",qK={bubbles:!1,cancelable:!0},ph="RovingFocusGroup",[nj,z$,GK]=UK(ph),[KK,W$]=wn(ph,[GK]),[YK,QK]=KK(ph),H$=j.forwardRef((e,t)=>i.jsx(nj.Provider,{scope:e.__scopeRovingFocusGroup,children:i.jsx(nj.Slot,{scope:e.__scopeRovingFocusGroup,children:i.jsx(XK,{...e,ref:t})})}));H$.displayName=ph;var XK=j.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:a=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:f=!1,...d}=e,h=j.useRef(null),p=Ye(t,h),y=aN(s),[v,m]=U$({prop:o,defaultProp:l??null,onChange:c,caller:ph}),[x,g]=j.useState(!1),b=Jr(u),N=z$(r),w=j.useRef(!1),[S,O]=j.useState(0);return j.useEffect(()=>{const P=h.current;if(P)return P.addEventListener($x,b),()=>P.removeEventListener($x,b)},[b]),i.jsx(YK,{scope:r,orientation:n,dir:y,loop:a,currentTabStopId:v,onItemFocus:j.useCallback(P=>m(P),[m]),onItemShiftTab:j.useCallback(()=>g(!0),[]),onFocusableItemAdd:j.useCallback(()=>O(P=>P+1),[]),onFocusableItemRemove:j.useCallback(()=>O(P=>P-1),[]),children:i.jsx(du.div,{tabIndex:x||S===0?-1:0,"data-orientation":n,...d,ref:p,style:{outline:"none",...e.style},onMouseDown:je(e.onMouseDown,()=>{w.current=!0}),onFocus:je(e.onFocus,P=>{const A=!w.current;if(P.target===P.currentTarget&&A&&!x){const C=new CustomEvent($x,qK);if(P.currentTarget.dispatchEvent(C),!C.defaultPrevented){const T=N().filter($=>$.focusable),D=T.find($=>$.active),_=T.find($=>$.id===v),R=[D,_,...T].filter(Boolean).map($=>$.ref.current);G$(R,f)}}w.current=!1}),onBlur:je(e.onBlur,()=>g(!1))})})}),V$="RovingFocusGroupItem",q$=j.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:s,children:o,...l}=e,c=gi(),u=s||c,f=QK(V$,r),d=f.currentTabStopId===u,h=z$(r),{onFocusableItemAdd:p,onFocusableItemRemove:y,currentTabStopId:v}=f;return j.useEffect(()=>{if(n)return p(),()=>y()},[n,p,y]),i.jsx(nj.ItemSlot,{scope:r,id:u,focusable:n,active:a,children:i.jsx(du.span,{tabIndex:d?0:-1,"data-orientation":f.orientation,...l,ref:t,onMouseDown:je(e.onMouseDown,m=>{n?f.onItemFocus(u):m.preventDefault()}),onFocus:je(e.onFocus,()=>f.onItemFocus(u)),onKeyDown:je(e.onKeyDown,m=>{if(m.key==="Tab"&&m.shiftKey){f.onItemShiftTab();return}if(m.target!==m.currentTarget)return;const x=eY(m,f.orientation,f.dir);if(x!==void 0){if(m.metaKey||m.ctrlKey||m.altKey||m.shiftKey)return;m.preventDefault();let b=h().filter(N=>N.focusable).map(N=>N.ref.current);if(x==="last")b.reverse();else if(x==="prev"||x==="next"){x==="prev"&&b.reverse();const N=b.indexOf(m.currentTarget);b=f.loop?tY(b,N+1):b.slice(N+1)}setTimeout(()=>G$(b))}}),children:typeof o=="function"?o({isCurrentTabStop:d,hasTabStop:v!=null}):o})})});q$.displayName=V$;var ZK={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function JK(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function eY(e,t,r){const n=JK(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return ZK[n]}function G$(e,t=!1){const r=document.activeElement;for(const n of e)if(n===r||(n.focus({preventScroll:t}),document.activeElement!==r))return}function tY(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var rY=H$,nY=q$;function aY(e,t){return j.useReducer((r,n)=>t[r][n]??r,e)}var K$=e=>{const{present:t,children:r}=e,n=iY(t),a=typeof r=="function"?r({present:n.isPresent}):j.Children.only(r),s=Ye(n.ref,sY(a));return typeof r=="function"||n.isPresent?j.cloneElement(a,{ref:s}):null};K$.displayName="Presence";function iY(e){const[t,r]=j.useState(),n=j.useRef(null),a=j.useRef(e),s=j.useRef("none"),o=e?"mounted":"unmounted",[l,c]=aY(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return j.useEffect(()=>{const u=cp(n.current);s.current=l==="mounted"?u:"none"},[l]),Jt(()=>{const u=n.current,f=a.current;if(f!==e){const h=s.current,p=cp(u);e?c("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(f&&h!==p?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,c]),Jt(()=>{if(t){let u;const f=t.ownerDocument.defaultView??window,d=p=>{const v=cp(n.current).includes(p.animationName);if(p.target===t&&v&&(c("ANIMATION_END"),!a.current)){const m=t.style.animationFillMode;t.style.animationFillMode="forwards",u=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=m)})}},h=p=>{p.target===t&&(s.current=cp(n.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{f.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:j.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function cp(e){return(e==null?void 0:e.animationName)||"none"}function sY(e){var n,a;let t=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Pg="Tabs",[oY,BCe]=wn(Pg,[W$]),Y$=W$(),[lY,DN]=oY(Pg),Q$=j.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,onValueChange:a,defaultValue:s,orientation:o="horizontal",dir:l,activationMode:c="automatic",...u}=e,f=aN(l),[d,h]=U$({prop:n,onChange:a,defaultProp:s??"",caller:Pg});return i.jsx(lY,{scope:r,baseId:gi(),value:d,onValueChange:h,orientation:o,dir:f,activationMode:c,children:i.jsx(du.div,{dir:f,"data-orientation":o,...u,ref:t})})});Q$.displayName=Pg;var X$="TabsList",Z$=j.forwardRef((e,t)=>{const{__scopeTabs:r,loop:n=!0,...a}=e,s=DN(X$,r),o=Y$(r);return i.jsx(rY,{asChild:!0,...o,orientation:s.orientation,dir:s.dir,loop:n,children:i.jsx(du.div,{role:"tablist","aria-orientation":s.orientation,...a,ref:t})})});Z$.displayName=X$;var J$="TabsTrigger",e4=j.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,disabled:a=!1,...s}=e,o=DN(J$,r),l=Y$(r),c=n4(o.baseId,n),u=a4(o.baseId,n),f=n===o.value;return i.jsx(nY,{asChild:!0,...l,focusable:!a,active:f,children:i.jsx(du.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":u,"data-state":f?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:c,...s,ref:t,onMouseDown:je(e.onMouseDown,d=>{!a&&d.button===0&&d.ctrlKey===!1?o.onValueChange(n):d.preventDefault()}),onKeyDown:je(e.onKeyDown,d=>{[" ","Enter"].includes(d.key)&&o.onValueChange(n)}),onFocus:je(e.onFocus,()=>{const d=o.activationMode!=="manual";!f&&!a&&d&&o.onValueChange(n)})})})});e4.displayName=J$;var t4="TabsContent",r4=j.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,forceMount:a,children:s,...o}=e,l=DN(t4,r),c=n4(l.baseId,n),u=a4(l.baseId,n),f=n===l.value,d=j.useRef(f);return j.useEffect(()=>{const h=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(h)},[]),i.jsx(K$,{present:a||f,children:({present:h})=>i.jsx(du.div,{"data-state":f?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!h,id:u,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?"0s":void 0},children:h&&s})})});r4.displayName=t4;function n4(e,t){return`${e}-trigger-${t}`}function a4(e,t){return`${e}-content-${t}`}var cY=Q$,i4=Z$,s4=e4,o4=r4;const ja=cY,Hn=j.forwardRef(({className:e,...t},r)=>i.jsx(i4,{ref:r,className:ue("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));Hn.displayName=i4.displayName;const Qe=j.forwardRef(({className:e,...t},r)=>i.jsx(s4,{ref:r,className:ue("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));Qe.displayName=s4.displayName;const Xe=j.forwardRef(({className:e,...t},r)=>i.jsx(o4,{ref:r,className:ue("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Xe.displayName=o4.displayName;function _n(e){try{if(!e)return"No Date";const t=new Date(e);if(isNaN(t.getTime()))return"Invalid Date";const r=t.getFullYear(),n=t.getMonth()+1,a=t.getDate(),s=t.getHours(),o=t.getMinutes(),l=n<10?"0"+n:n.toString(),c=a<10?"0"+a:a.toString(),u=s<10?"0"+s:s.toString(),f=o<10?"0"+o:o.toString();return l+"/"+c+"/"+r+" "+u+":"+f}catch(t){return console.error("Date formatting error:",t),"Date Error"}}function uY(e){try{if(!e)return"No time";const t=new Date(e),r=new Date;if(isNaN(t.getTime())||isNaN(r.getTime()))return _n(e);const n=r.getTime()-t.getTime(),a=Math.floor(n/(1e3*60)),s=Math.floor(n/(1e3*60*60)),o=Math.floor(n/(1e3*60*60*24));return a<1?"Just now":a<60?a+"m ago":s<24?s+"h ago":o<7?o+"d ago":_n(e)}catch(t){return console.error("Time ago formatting error:",t),_n(e)}}function dY(e,t=0){if(typeof e=="number"&&!isNaN(e))return e;if(typeof e=="string"){const r=parseFloat(e);return isNaN(r)?t:r}return t}function Be(e,t="ETB "){const r=dY(e,0);return t+r.toFixed(2)}function fY(e,t){try{for(let r=0;rnew Date(m.timestamp).getTime()-new Date(x.timestamp).getTime());const h=e.status==="rejected"?-1:fY(up,m=>m.key===e.status),p=m=>e.status==="rejected"?m===0?"completed":"rejected":m{if(t)try{await t(e.id,m,o),l(""),u(null)}catch(x){console.error("Failed to update order status:",x)}},v=()=>{if(e.status==="rejected")return 25;const m=up.length;return Math.min((h+1)/m*100,100)};return i.jsxs("div",{className:`space-y-6 ${s}`,children:[i.jsxs(W,{children:[i.jsxs(J,{children:[i.jsxs(ee,{className:"flex items-center gap-2",children:[i.jsx(Ot,{className:"w-5 h-5"}),"Order Timeline - ",e.orderNumber]}),i.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-600",children:[i.jsxs("span",{children:["Customer: ",e.customerName]}),i.jsx("span",{children:"•"}),i.jsxs("span",{children:["Total: $",e.totalAmount]})]})]}),i.jsxs(H,{className:"space-y-6",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex justify-between text-sm",children:[i.jsx("span",{children:"Progress"}),i.jsxs("span",{children:[Math.round(v()),"%"]})]}),i.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2",children:i.jsx("div",{className:`h-2 rounded-full transition-all duration-500 ${e.status==="rejected"?"bg-red-500":"bg-blue-500"}`,style:{width:`${v()}%`}})})]}),i.jsx("div",{className:"relative",children:i.jsx("div",{className:"flex items-center justify-between",children:up.map((m,x)=>{const g=p(x),b=m.icon;return i.jsxs("div",{className:"flex flex-col items-center relative",children:[xl(m.target.value)}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(z,{onClick:()=>y("approved"),className:"bg-green-600 hover:bg-green-700",children:"Approve"}),i.jsx(z,{variant:"outline",onClick:()=>l(""),children:"Cancel"})]})]})]})]}),r&&e.status==="pending"&&i.jsxs(zt,{children:[i.jsx(Pm,{asChild:!0,children:i.jsxs(z,{size:"sm",variant:"destructive",children:[i.jsx(ar,{className:"w-4 h-4 mr-2"}),"Reject Order"]})}),i.jsxs($t,{children:[i.jsx(Lt,{children:i.jsx(Ft,{children:"Reject Order"})}),i.jsxs("div",{className:"space-y-4",children:[i.jsx(Wn,{placeholder:"Reason for rejection (required)",value:o,onChange:m=>l(m.target.value),required:!0}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(z,{variant:"destructive",onClick:()=>y("rejected"),disabled:!o.trim(),children:"Reject"}),i.jsx(z,{variant:"outline",onClick:()=>l(""),children:"Cancel"})]})]})]})]}),n&&e.status==="approved"&&i.jsxs(z,{size:"sm",onClick:()=>y("processing"),className:"bg-orange-600 hover:bg-orange-700",children:[i.jsx(GW,{className:"w-4 h-4 mr-2"}),"Start Processing"]}),a&&e.status==="processing"&&i.jsxs(z,{size:"sm",onClick:()=>y("completed"),className:"bg-purple-600 hover:bg-purple-700",children:[i.jsx(YW,{className:"w-4 h-4 mr-2"}),"Mark Completed"]})]})]})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"flex items-center gap-2",children:[i.jsx(Dr,{className:"w-5 h-5"}),"Timeline Events"]})}),i.jsx(H,{children:i.jsx("div",{className:"space-y-4",children:f.map((m,x)=>i.jsxs("div",{className:"flex items-start gap-4 p-4 rounded-lg border",children:[i.jsxs("div",{className:`w-8 h-8 rounded-full flex items-center justify-center ${m.status==="approved"?"bg-green-100 text-green-600":m.status==="rejected"?"bg-red-100 text-red-600":m.status==="processing"?"bg-orange-100 text-orange-600":m.status==="completed"?"bg-purple-100 text-purple-600":"bg-blue-100 text-blue-600"}`,children:[m.actionType==="created"&&i.jsx(wr,{className:"w-4 h-4"}),m.actionType==="approved"&&i.jsx(ct,{className:"w-4 h-4"}),m.actionType==="rejected"&&i.jsx(ar,{className:"w-4 h-4"}),m.actionType==="processing_started"&&i.jsx(Ot,{className:"w-4 h-4"}),m.actionType==="completed"&&i.jsx(G1,{className:"w-4 h-4"}),m.actionType==="modified"&&i.jsx(ha,{className:"w-4 h-4"})]}),i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(te,{variant:m.status==="approved"?"default":m.status==="rejected"?"destructive":m.status==="processing"?"secondary":m.status==="completed"?"outline":"secondary",children:m.actionType.replace("_"," ").toUpperCase()}),i.jsx("span",{className:"text-sm text-gray-500",children:_n(m.timestamp)})]}),i.jsxs("div",{className:"mt-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Fn,{className:"w-4 h-4 text-gray-400"}),i.jsx("span",{className:"text-sm font-medium",children:m.userName||"Unknown User"})]}),m.notes&&i.jsxs("div",{className:"mt-2 p-2 bg-gray-50 rounded text-sm",children:[i.jsx(ha,{className:"w-4 h-4 inline mr-2 text-gray-400"}),m.notes]})]})]})]},x))})})]})]})}function pY({order:e,onClose:t,canApprove:r,onApprove:n,onReject:a}){const[s,o]=j.useState(""),[l,c]=j.useState(null),{data:u=[]}=Fe({queryKey:["/api/users"],staleTime:5*60*1e3}),f=x=>{if(!x||!u)return"Unknown";const g=u.find(b=>b.id===x);return g?`${g.firstName} ${g.lastName}`.trim():"Unknown"},d=x=>{switch(x){case"approved":return i.jsx(te,{variant:"default",className:"bg-emerald-100 text-emerald-800",children:"Approved"});case"rejected":return i.jsx(te,{variant:"destructive",children:"Rejected"});case"pending":return i.jsx(te,{variant:"secondary",className:"bg-amber-100 text-amber-800",children:"Pending Review"});case"processing":return i.jsx(te,{variant:"default",className:"bg-blue-100 text-blue-800",children:"Processing"});case"completed":return i.jsx(te,{variant:"default",className:"bg-green-100 text-green-800",children:"Completed"});default:return i.jsx(te,{variant:"outline",children:x})}},h=x=>x&&x.trim()?i.jsxs(te,{variant:"outline",className:"bg-blue-50 text-blue-700 font-mono",children:["FS: ",x]}):i.jsx(te,{variant:"outline",className:"bg-gray-100 text-gray-600",children:"FS not set"}),p=()=>{n(s),c(null),o("")},y=()=>{a(s),c(null),o("")},v=x=>new Date(x).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"}),m=Array.isArray(e.items)?e.items:[];return i.jsx(zt,{open:!0,onOpenChange:t,children:i.jsxs($t,{className:"w-[95vw] max-w-4xl max-h-[90vh] overflow-y-auto",children:[i.jsx(Lt,{children:i.jsxs(Ft,{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2",children:[i.jsxs("span",{className:"text-lg sm:text-xl",children:["Order Details - #",e.orderNumber]}),d(e.status)]})}),i.jsxs(ja,{defaultValue:"details",className:"w-full",children:[i.jsxs(Hn,{className:"grid w-full grid-cols-2",children:[i.jsx(Qe,{value:"details",children:"Order Details"}),i.jsx(Qe,{value:"timeline",children:"Progress Timeline"})]}),i.jsxs(Xe,{value:"details",className:"space-y-6 mt-6",children:[i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"text-lg flex items-center",children:[i.jsx(Fn,{className:"w-5 h-5 mr-2"}),"Customer Information"]})}),i.jsxs(H,{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{className:"flex items-center",children:[i.jsx(Fn,{className:"w-4 h-4 text-slate-400 mr-2"}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-slate-500",children:"Customer Name"}),i.jsx("p",{className:"font-medium",children:e.customerName})]})]}),i.jsxs("div",{className:"flex items-center",children:[i.jsx(bc,{className:"w-4 h-4 text-slate-400 mr-2"}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-slate-500",children:"Customer TIN"}),i.jsx("p",{className:"font-medium font-mono",children:e.customerTinNumber||"Not provided"})]})]}),i.jsxs("div",{className:"flex items-center",children:[i.jsx(Fn,{className:"w-4 h-4 text-slate-400 mr-2"}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-slate-500",children:"Sales Officer"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"w-6 h-6 bg-blue-100 rounded-full flex items-center justify-center",children:i.jsx("span",{className:"text-xs font-medium text-blue-700",children:f(e.salesOfficerId).split(" ").map(x=>x.charAt(0)).join("")})}),i.jsx("p",{className:"font-medium",children:f(e.salesOfficerId)})]})]})]}),e.customerCompany&&i.jsxs("div",{className:"flex items-center",children:[i.jsx(bc,{className:"w-4 h-4 text-slate-400 mr-2"}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-slate-500",children:"Company"}),i.jsx("p",{className:"font-medium",children:e.customerCompany})]})]}),e.customerEmail&&i.jsxs("div",{className:"flex items-center",children:[i.jsx(dI,{className:"w-4 h-4 text-slate-400 mr-2"}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-slate-500",children:"Email"}),i.jsx("p",{className:"font-medium",children:e.customerEmail})]})]}),e.customerPhone&&i.jsxs("div",{className:"flex items-center",children:[i.jsx(qW,{className:"w-4 h-4 text-slate-400 mr-2"}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-slate-500",children:"Phone"}),i.jsx("p",{className:"font-medium",children:e.customerPhone})]})]})]})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"text-lg flex items-center",children:[i.jsx(Dr,{className:"w-5 h-5 mr-2"}),"Order Information"]})}),i.jsxs(H,{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-slate-500",children:"Order Date"}),i.jsx("p",{className:"font-medium",children:v(e.createdAt)})]}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-slate-500",children:"Payment Terms"}),i.jsx("p",{className:"font-medium capitalize",children:e.paymentTerm})]}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-slate-500",children:"Business Sector"}),i.jsx("p",{className:"font-medium",children:e.businessSector})]}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-slate-500",children:"Area"}),i.jsx("p",{className:"font-medium",children:e.customerArea})]}),i.jsxs("div",{className:"md:col-span-2",children:[i.jsx("p",{className:"text-sm text-slate-500",children:"FS Number (Sales Invoice)"}),h(e.fsNumber)]})]})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{className:"text-lg",children:"Order Items"})}),i.jsx(H,{children:i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full border-collapse",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b",children:[i.jsx("th",{className:"text-left p-2",children:"Product"}),i.jsx("th",{className:"text-left p-2",children:"Unit"}),i.jsx("th",{className:"text-right p-2",children:"Quantity"}),i.jsx("th",{className:"text-right p-2",children:"Price"}),i.jsx("th",{className:"text-right p-2",children:"Total"})]})}),i.jsx("tbody",{children:m.map((x,g)=>i.jsxs("tr",{className:"border-b",children:[i.jsx("td",{className:"p-2",children:x.productType}),i.jsx("td",{className:"p-2 capitalize",children:x.unit}),i.jsx("td",{className:"p-2 text-right",children:x.quantity}),i.jsxs("td",{className:"p-2 text-right",children:["$",parseFloat(x.price||"0").toFixed(2)]}),i.jsxs("td",{className:"p-2 text-right font-medium",children:["$",parseFloat(x.total||"0").toFixed(2)]})]},g))}),i.jsx("tfoot",{children:i.jsxs("tr",{className:"border-t-2 font-bold",children:[i.jsx("td",{colSpan:4,className:"p-2 text-right",children:"Total Amount:"}),i.jsxs("td",{className:"p-2 text-right",children:["$",parseFloat(e.totalAmount||"0").toFixed(2)]})]})})]})})})]}),e.notes&&i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{className:"text-lg",children:"Notes"})}),i.jsx(H,{children:i.jsx("p",{className:"text-slate-700 whitespace-pre-wrap",children:e.notes})})]}),r&&e.status==="pending"&&i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{className:"text-lg",children:"Review Actions"})}),i.jsx(H,{children:l?i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium mb-2",children:"Add notes (optional):"}),i.jsx(Wn,{value:s,onChange:x=>o(x.target.value),placeholder:"Enter any additional notes...",rows:3})]}),i.jsxs("div",{className:"flex gap-3",children:[i.jsx(z,{onClick:l==="approve"?p:y,variant:l==="approve"?"default":"destructive",className:l==="approve"?"bg-emerald-600 hover:bg-emerald-700":"",children:l==="approve"?"Confirm Approval":"Confirm Rejection"}),i.jsx(z,{onClick:()=>{c(null),o("")},variant:"outline",children:"Cancel"})]})]}):i.jsxs("div",{className:"flex gap-4",children:[i.jsxs(z,{onClick:()=>c("approve"),className:"bg-emerald-600 hover:bg-emerald-700",children:[i.jsx(ct,{className:"w-4 h-4 mr-2"}),"Approve Order"]}),i.jsxs(z,{onClick:()=>c("reject"),variant:"destructive",children:[i.jsx(ar,{className:"w-4 h-4 mr-2"}),"Reject Order"]})]})})]})]}),i.jsx(Xe,{value:"timeline",className:"mt-6",children:i.jsx(hY,{order:e,onStatusUpdate:(x,g,b)=>{g==="approved"?n(b):g==="rejected"&&a(b)},canApprove:r&&e.status==="pending",canProcess:r&&e.status==="approved",canComplete:r&&e.status==="processing"})})]})]})})}function So({trigger:e}){var w,S,O,P,A;const{toast:t}=Ht();$r();const[r,n]=j.useState(!1);j.useState("performance");const[a,s]=j.useState("weekly"),[o,l]=j.useState({}),[c,u]=j.useState(["all"]),[f,d]=j.useState(!1),{data:h=[]}=Fe({queryKey:["/api/orders"],enabled:r}),{data:p=[]}=Fe({queryKey:["/api/users"],enabled:r});Fe({queryKey:["/api/orders/stats"],enabled:r});const y=p.filter(C=>C.role==="sales_officer"),v=[{id:"all",name:"All Categories",icon:Ot},{id:"performance",name:"Sales Performance",icon:Mr},{id:"team",name:"Team Analytics",icon:Ss},{id:"products",name:"Product Analysis",icon:Ot},{id:"customers",name:"Customer Insights",icon:hg},{id:"financial",name:"Financial Summary",icon:Ka}],m=[{id:"today",name:"Today's Report",period:"Real-time daily activity"},{id:"custom",name:"Custom Date Range",period:"Select specific dates"}],x=()=>{var re;const C=new Date,T=new Date(C.getFullYear(),C.getMonth(),C.getDate()),D=new Date(T.getTime()-24*60*60*1e3),_=h.filter(Y=>{const Z=new Date(Y.createdAt),L=new Date(Z.getFullYear(),Z.getMonth(),Z.getDate());switch(a){case"today":return L.getTime()===T.getTime();case"yesterday":return L.getTime()===D.getTime();case"weekly":return Z>=new Date(C.getTime()-7*24*60*60*1e3);case"monthly":return Z>=new Date(C.getTime()-30*24*60*60*1e3);case"quarterly":return Z>=new Date(C.getTime()-90*24*60*60*1e3);case"custom":if(o.from&&o.to){const ce=new Date(o.from.getFullYear(),o.from.getMonth(),o.from.getDate()),ye=new Date(o.to.getFullYear(),o.to.getMonth(),o.to.getDate(),23,59,59);return Z>=ce&&Z<=ye}return!0;default:return!0}}),k=_.length,R=_.filter(Y=>Y.status==="pending").length,$=_.filter(Y=>Y.status==="approved").length,I=_.filter(Y=>Y.status==="rejected").length,E=_.reduce((Y,Z)=>Y+(parseFloat(Z.totalAmount)||0),0),F=k>0?E/k:0,V=y.map(Y=>{const Z=_.filter(ce=>ce.salesOfficerId===Y.id),L=Z.reduce((ce,ye)=>ce+(parseFloat(ye.totalAmount)||0),0);return{id:Y.id,name:`${Y.firstName} ${Y.lastName}`,email:Y.email,totalOrders:Z.length,pendingOrders:Z.filter(ce=>ce.status==="pending").length,approvedOrders:Z.filter(ce=>ce.status==="approved").length,rejectedOrders:Z.filter(ce=>ce.status==="rejected").length,totalRevenue:L,averageOrderValue:Z.length>0?L/Z.length:0,conversionRate:Z.length>0?Z.filter(ce=>ce.status==="approved").length/Z.length*100:0}}),G={};_.forEach(Y=>{Y.items&&Array.isArray(Y.items)&&Y.items.forEach(Z=>{G[Z.productType]||(G[Z.productType]={name:Z.productType,totalQuantity:0,totalRevenue:0,orderCount:0,averagePrice:0}),G[Z.productType].totalQuantity+=Z.quantity||0,G[Z.productType].totalRevenue+=Z.total||0,G[Z.productType].orderCount+=1})}),Object.values(G).forEach(Y=>{Y.averagePrice=Y.totalQuantity>0?Y.totalRevenue/Y.totalQuantity:0});const K={};_.forEach(Y=>{const Z=Y.businessSector||"Unknown";K[Z]||(K[Z]={sector:Z,orderCount:0,totalRevenue:0,customers:new Set}),K[Z].orderCount+=1,K[Z].totalRevenue+=parseFloat(Y.totalAmount)||0,K[Z].customers.add(Y.customerName)}),Object.values(K).forEach(Y=>{Y.uniqueCustomers=Y.customers.size,delete Y.customers});const q=_.filter(Y=>Y.status==="approved").reduce((Y,Z)=>Y+(parseFloat(Z.totalAmount)||0),0),ne=_.filter(Y=>Y.status==="pending").reduce((Y,Z)=>Y+(parseFloat(Z.totalAmount)||0),0),le=k>0?E/_.length*30:0,de=le*3,ie=le*12;_.length;const ve=ne>0?ne/E*100:0;return{summary:{totalOrders:k,pendingOrders:R,approvedOrders:$,rejectedOrders:I,totalRevenue:E,averageOrderValue:F,approvedRevenue:q,pendingRevenue:ne,conversionRate:k>0?$/k*100:0,monthlyProjection:le,quarterlyProjection:de,yearlyProjection:ie,projectedGrowth:ve},teamPerformance:V.sort((Y,Z)=>Z.totalRevenue-Y.totalRevenue),productAnalysis:Object.values(G).sort((Y,Z)=>Z.totalRevenue-Y.totalRevenue),customerAnalysis:Object.values(K).sort((Y,Z)=>Z.totalRevenue-Y.totalRevenue),timeframe:a,dateRange:o.from&&o.to?`${Ve(o.from,"MMM dd, yyyy")} - ${Ve(o.to,"MMM dd, yyyy")}`:((re=m.find(Y=>Y.id===a))==null?void 0:re.period)||"",generatedAt:new Date().toISOString()}},g=async(C="html")=>{d(!0);try{const T=x();if(C==="html"){const D=N(T),_=new Blob([D],{type:"text/html"}),k=URL.createObjectURL(_),R=document.createElement("a");R.href=k,R.download=`DOK-TOK-Sales-Report-${a}-${new Date().toISOString().split("T")[0]}.html`,document.body.appendChild(R),R.click(),document.body.removeChild(R),URL.revokeObjectURL(k)}else{const D=b(T),_=new Blob([D],{type:"text/csv"}),k=URL.createObjectURL(_),R=document.createElement("a");R.href=k,R.download=`DOK-TOK-Sales-Data-${a}-${new Date().toISOString().split("T")[0]}.csv`,document.body.appendChild(R),R.click(),document.body.removeChild(R),URL.revokeObjectURL(k)}t({title:"Report Generated",description:`${C.toUpperCase()} report has been downloaded successfully`}),n(!1)}catch{t({title:"Error",description:"Failed to generate report",variant:"destructive"})}finally{d(!1)}},b=C=>{const T=[];return T.push("DOK TOK Sales Management Report"),T.push(`Period: ${C.dateRange}`),T.push(`Generated: ${_n(C.generatedAt)}`),T.push(""),T.push("EXECUTIVE SUMMARY"),T.push("Metric,Value"),T.push(`Total Orders,${C.summary.totalOrders}`),T.push(`Total Revenue,${C.summary.totalRevenue}`),T.push(`Approved Orders,${C.summary.approvedOrders}`),T.push(`Pending Orders,${C.summary.pendingOrders}`),T.push(`Conversion Rate,${C.summary.conversionRate.toFixed(1)}%`),T.push(`Average Order Value,${C.summary.averageOrderValue}`),T.push(`Monthly Projection,${C.summary.monthlyProjection}`),T.push(`Quarterly Projection,${C.summary.quarterlyProjection}`),T.push(`Yearly Projection,${C.summary.yearlyProjection}`),T.push(""),T.push("TEAM PERFORMANCE"),T.push("Officer Name,Email,Total Orders,Approved Orders,Total Revenue,Conversion Rate"),C.teamPerformance.forEach(D=>{T.push(`${D.name},${D.email},${D.totalOrders},${D.approvedOrders},${D.totalRevenue},${D.conversionRate.toFixed(1)}%`)}),T.push(""),T.push("PRODUCT ANALYSIS"),T.push("Product,Total Quantity,Total Revenue,Order Count,Average Price"),C.productAnalysis.forEach(D=>{T.push(`${D.name},${D.totalQuantity},${D.totalRevenue},${D.orderCount},${D.averagePrice}`)}),T.push(""),T.push("CUSTOMER SECTOR ANALYSIS"),T.push("Business Sector,Order Count,Unique Customers,Total Revenue"),C.customerAnalysis.forEach(D=>{T.push(`${D.sector},${D.orderCount},${D.uniqueCustomers},${D.totalRevenue}`)}),T.join(` `)},N=C=>` Sales Performance Report - ${C.timeframe}

Sales Performance Report

Period: ${C.dateRange}

Generated: ${_n(C.generatedAt)}

Total Orders

${C.summary.totalOrders}

Total Revenue

${Be(C.summary.totalRevenue)}

Conversion Rate

${C.summary.conversionRate.toFixed(1)}%

Avg Order Value

${Be(C.summary.averageOrderValue)}

Order Status Breakdown

Status Count Percentage Revenue
Approved ${C.summary.approvedOrders} ${C.summary.totalOrders>0?(C.summary.approvedOrders/C.summary.totalOrders*100).toFixed(1):0}% ${Be(C.summary.approvedRevenue)}
Pending ${C.summary.pendingOrders} ${C.summary.totalOrders>0?(C.summary.pendingOrders/C.summary.totalOrders*100).toFixed(1):0}% ${Be(C.summary.pendingRevenue)}
Rejected ${C.summary.rejectedOrders} ${C.summary.totalOrders>0?(C.summary.rejectedOrders/C.summary.totalOrders*100).toFixed(1):0}% €0.00

Team Performance Analysis

${C.teamPerformance.map(T=>` `).join("")}
Sales Officer Total Orders Approved Pending Total Revenue Avg Order Value Conversion Rate
${T.name}
${T.email}
${T.totalOrders} ${T.approvedOrders} ${T.pendingOrders} ${Be(T.totalRevenue)} ${Be(T.averageOrderValue)} ${T.conversionRate.toFixed(1)}%

Product Performance Analysis

${C.productAnalysis.map(T=>` `).join("")}
Product Total Quantity Total Revenue Order Count Avg Price
${T.name} ${T.totalQuantity} ${Be(T.totalRevenue)} ${T.orderCount} ${Be(T.averagePrice)}

Customer Sector Analysis

${C.customerAnalysis.map(T=>` `).join("")}
Business Sector Order Count Unique Customers Total Revenue Avg Revenue per Customer
${T.sector} ${T.orderCount} ${T.uniqueCustomers} ${Be(T.totalRevenue)} ${Be(T.uniqueCustomers>0?T.totalRevenue/T.uniqueCustomers:0)}

Sales Projections & Forecasting

Monthly Projection

${Be(C.summary.monthlyProjection)}

Quarterly Projection

${Be(C.summary.quarterlyProjection)}

Yearly Projection

${Be(C.summary.yearlyProjection)}

Projected Growth

${C.summary.projectedGrowth.toFixed(1)}%

Key Performance Insights

  • Revenue Potential: ${Be(C.summary.pendingRevenue)} in pending orders represents ${C.summary.projectedGrowth.toFixed(1)}% potential growth
  • Conversion Efficiency: Current conversion rate of ${C.summary.conversionRate.toFixed(1)}% indicates ${C.summary.conversionRate>70?"excellent":C.summary.conversionRate>50?"good":"needs improvement"} sales performance
  • Market Opportunity: Based on current trends, monthly revenue could reach ${Be(C.summary.monthlyProjection)}
  • Team Performance: ${C.teamPerformance.length} active sales officers generating average ${Be(C.summary.totalRevenue/C.teamPerformance.length)} per officer

Strategic Recommendations

Immediate Actions

  • Focus on converting ${C.summary.pendingOrders} pending orders worth ${Be(C.summary.pendingRevenue)}
  • Optimize sales processes to improve ${C.summary.conversionRate.toFixed(1)}% conversion rate
  • Leverage top-performing products: ${C.productAnalysis.slice(0,3).map(T=>T.name).join(", ")}
  • Expand in highest-revenue sectors: ${C.customerAnalysis.slice(0,2).map(T=>T.sector).join(", ")}

Growth Opportunities

  • Monthly revenue target: ${Be(C.summary.monthlyProjection)} (${((C.summary.monthlyProjection/C.summary.totalRevenue-1)*100).toFixed(1)}% growth)
  • Potential annual revenue: ${Be(C.summary.yearlyProjection)} with current performance
  • Team expansion consideration: Current ${C.teamPerformance.length} officers, consider scaling based on performance
`;return i.jsxs(zt,{open:r,onOpenChange:n,children:[i.jsx(Pm,{asChild:!0,children:e||i.jsxs(z,{className:"bg-purple-600 hover:bg-purple-700",children:[i.jsx(Et,{className:"w-4 h-4 mr-2"}),"Generate Report"]})}),i.jsxs($t,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[i.jsx(Lt,{children:i.jsxs(Ft,{className:"flex items-center",children:[i.jsx(Xr,{className:"w-5 h-5 mr-2"}),"Generate Management Report"]})}),i.jsx("div",{className:"space-y-6",children:i.jsxs(ja,{defaultValue:"setup",className:"w-full",children:[i.jsxs(Hn,{className:"grid w-full grid-cols-3",children:[i.jsx(Qe,{value:"setup",children:"Report Setup"}),i.jsx(Qe,{value:"preview",children:"Preview"}),i.jsx(Qe,{value:"generate",children:"Generate"})]}),i.jsxs(Xe,{value:"setup",className:"space-y-6",children:[i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"flex items-center",children:[i.jsx(wr,{className:"w-5 h-5 mr-2"}),"Time Frame Selection"]})}),i.jsxs(H,{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx(X,{children:"Report Period"}),i.jsxs(_e,{value:a,onValueChange:s,children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"Select time frame"})}),i.jsx(Ce,{children:m.map(C=>i.jsxs(U,{value:C.id,children:[C.name," - ",C.period]},C.id))})]})]}),a==="custom"&&i.jsx("div",{className:"space-y-4",children:i.jsxs("div",{className:"p-4 bg-blue-50 rounded-lg border border-blue-200",children:[i.jsx("h4",{className:"font-semibold text-blue-900 mb-2",children:"Custom Date Range Selection"}),i.jsx("p",{className:"text-sm text-blue-700 mb-3",children:"Select the exact date range for your report analysis"}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx(X,{className:"text-blue-800 font-medium text-base",children:"From Date"}),i.jsxs(zo,{children:[i.jsx(Wo,{asChild:!0,children:i.jsxs(z,{variant:"outline",className:"w-full justify-start mt-2 h-12 border-blue-300 hover:border-blue-400 text-left",children:[i.jsx(Dr,{className:"w-5 h-5 mr-3 text-blue-600"}),i.jsx("span",{className:"text-base",children:o.from?Ve(o.from,"EEEE, MMMM dd, yyyy"):"Click to select start date"})]})}),i.jsx(Es,{className:"w-auto p-0",align:"start",children:i.jsx(Cs,{mode:"single",selected:o.from,onSelect:C=>l(T=>({...T,from:C})),disabled:C=>C>new Date,initialFocus:!0})})]})]}),i.jsxs("div",{children:[i.jsx(X,{className:"text-blue-800 font-medium text-base",children:"To Date"}),i.jsxs(zo,{children:[i.jsx(Wo,{asChild:!0,children:i.jsxs(z,{variant:"outline",className:"w-full justify-start mt-2 h-12 border-blue-300 hover:border-blue-400 text-left",children:[i.jsx(Dr,{className:"w-5 h-5 mr-3 text-blue-600"}),i.jsx("span",{className:"text-base",children:o.to?Ve(o.to,"EEEE, MMMM dd, yyyy"):"Click to select end date"})]})}),i.jsx(Es,{className:"w-auto p-0",align:"start",children:i.jsx(Cs,{mode:"single",selected:o.to,onSelect:C=>l(T=>({...T,to:C})),disabled:C=>C>new Date||(o.from?Ci.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx("input",{type:"checkbox",id:C.id,checked:c.includes(C.id),onChange:T=>{T.target.checked?u(D=>[...D,C.id]):u(D=>D.filter(_=>_!==C.id))},className:"rounded"}),i.jsxs(X,{htmlFor:C.id,className:"flex items-center cursor-pointer",children:[i.jsx(C.icon,{className:"w-4 h-4 mr-2"}),C.name]})]},C.id))})})]})]}),i.jsx(Xe,{value:"preview",className:"space-y-6",children:i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"flex items-center justify-between",children:["Report Preview",i.jsx(te,{variant:"outline",className:"ml-2",children:((w=m.find(C=>C.id===a))==null?void 0:w.name)||"All Time"})]})}),i.jsx(H,{children:i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs(z,{variant:a==="today"?"default":"outline",size:"lg",onClick:()=>s("today"),className:"h-16 flex flex-col items-center justify-center",children:[i.jsx("div",{className:"font-semibold",children:"Today's Report"}),i.jsx("div",{className:"text-xs opacity-80",children:"Real-time activity"})]}),i.jsxs(z,{variant:a==="custom"?"default":"outline",size:"lg",onClick:()=>s("custom"),className:"h-16 flex flex-col items-center justify-center",children:[i.jsx("div",{className:"font-semibold",children:"Custom Date Range"}),i.jsx("div",{className:"text-xs opacity-80",children:"Select specific dates"})]})]}),i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[i.jsxs("div",{className:"p-4 bg-blue-50 rounded-lg text-center",children:[i.jsx("div",{className:"text-2xl font-bold text-blue-600",children:x().summary.totalOrders}),i.jsx("div",{className:"text-sm text-gray-600",children:"Total Orders"}),i.jsx("div",{className:"text-xs text-blue-500 mt-1",children:a==="today"?"Today":(S=m.find(C=>C.id===a))==null?void 0:S.period})]}),i.jsxs("div",{className:"p-4 bg-green-50 rounded-lg text-center",children:[i.jsx("div",{className:"text-2xl font-bold text-green-600",children:x().summary.approvedOrders}),i.jsx("div",{className:"text-sm text-gray-600",children:"Approved"}),i.jsxs("div",{className:"text-xs text-green-500 mt-1",children:[x().summary.conversionRate.toFixed(1),"% rate"]})]}),i.jsxs("div",{className:"p-4 bg-yellow-50 rounded-lg text-center",children:[i.jsx("div",{className:"text-2xl font-bold text-yellow-600",children:x().summary.pendingOrders}),i.jsx("div",{className:"text-sm text-gray-600",children:"Pending"}),i.jsx("div",{className:"text-xs text-yellow-500 mt-1",children:Be(x().summary.pendingRevenue)})]}),i.jsxs("div",{className:"p-4 bg-purple-50 rounded-lg text-center",children:[i.jsx("div",{className:"text-2xl font-bold text-purple-600",children:Be(x().summary.totalRevenue)}),i.jsx("div",{className:"text-sm text-gray-600",children:"Revenue"}),i.jsxs("div",{className:"text-xs text-purple-500 mt-1",children:["Avg: ",Be(x().summary.averageOrderValue)]})]})]}),i.jsxs("div",{className:"p-4 bg-blue-50 rounded-lg border border-blue-200",children:[i.jsx("h4",{className:"font-semibold text-blue-900 mb-2",children:"Report Period"}),i.jsx("p",{className:"text-blue-700 text-sm",children:a==="custom"&&o.from&&o.to?`${Ve(o.from,"MMM dd, yyyy")} - ${Ve(o.to,"MMM dd, yyyy")}`:a==="today"?`Today: ${Ve(new Date,"EEEE, MMMM dd, yyyy")}`:a==="yesterday"?`Yesterday: ${Ve(new Date(Date.now()-864e5),"EEEE, MMMM dd, yyyy")}`:((O=m.find(C=>C.id===a))==null?void 0:O.period)||"All available data"}),a==="today"&&i.jsxs("p",{className:"text-blue-600 text-xs mt-1",children:["Real-time data • Last updated: ",Ve(new Date,"h:mm a")]})]}),i.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg",children:[i.jsx("h4",{className:"font-semibold mb-2",children:"Report Will Include:"}),i.jsxs("ul",{className:"space-y-1 text-sm",children:[i.jsx("li",{children:"• Executive summary with key performance indicators"}),i.jsxs("li",{children:["• ",x().teamPerformance.length," sales officer performance analysis"]}),i.jsxs("li",{children:["• ",x().productAnalysis.length," product sales breakdown and trends"]}),i.jsxs("li",{children:["• ",x().customerAnalysis.length," customer sector insights"]}),i.jsx("li",{children:"• Financial projections and growth forecasting"}),i.jsx("li",{children:"• Strategic recommendations based on current data"})]})]})]})})]})}),i.jsx(Xe,{value:"generate",className:"space-y-6",children:i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"flex items-center",children:[i.jsx(Ln,{className:"w-5 h-5 mr-2"}),"Generate Report"]})}),i.jsxs(H,{className:"space-y-4",children:[i.jsxs("div",{className:"p-4 bg-blue-50 rounded-lg",children:[i.jsx("h4",{className:"font-semibold text-blue-900 mb-2",children:"Report Configuration Summary"}),i.jsxs("div",{className:"space-y-1 text-sm text-blue-800",children:[i.jsxs("p",{children:[i.jsx("strong",{children:"Period:"})," ",((P=m.find(C=>C.id===a))==null?void 0:P.name)||a]}),i.jsxs("p",{children:[i.jsx("strong",{children:"Date Range:"})," ",a==="custom"&&o.from&&o.to?`${Ve(o.from,"MMM dd, yyyy")} - ${Ve(o.to,"MMM dd, yyyy")}`:((A=m.find(C=>C.id===a))==null?void 0:A.period)||""]}),i.jsxs("p",{children:[i.jsx("strong",{children:"Categories:"})," ",c.length," selected"]})]})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsx(z,{onClick:()=>g("html"),disabled:f,className:"w-full bg-green-600 hover:bg-green-700",size:"lg",children:f?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"}),"Generating Report..."]}):i.jsxs(i.Fragment,{children:[i.jsx(Ln,{className:"w-4 h-4 mr-2"}),"Download HTML Report"]})}),i.jsxs(z,{onClick:()=>g("pdf"),disabled:f,variant:"outline",className:"w-full",size:"lg",children:[i.jsx(Ln,{className:"w-4 h-4 mr-2"}),"Download Data (CSV)"]})]}),i.jsx("div",{className:"text-sm text-gray-600 text-center",children:"Report will be downloaded as an HTML file that can be printed or shared with management"})]})]})})]})})]})]})}function Lx(){var Z;const{user:e}=qn(),{toast:t}=Ht(),r=$r(),[n,a]=j.useState(""),[s,o]=j.useState(""),[l,c]=j.useState(""),[u,f]=j.useState(""),[d,h]=j.useState(""),[p,y]=j.useState(),[v,m]=j.useState(),[x,g]=j.useState(!1),[b,N]=j.useState(null),[w,S]=j.useState(!1),[O,P]=j.useState(null),[A,C]=j.useState(""),T=e&&(e==null?void 0:e.role)&&["super_admin","approver"].includes(e.role),D=e&&(e==null?void 0:e.role)&&["super_admin","sales_clerk","approver"].includes(e.role),_=e&&(e==null?void 0:e.role)&&["super_admin","sales_clerk"].includes(e.role),k=e&&(e==null?void 0:e.role)&&["super_admin","approver","sales_clerk"].includes(e.role),{data:R,isLoading:$}=Fe({queryKey:["/api/orders",{status:n&&n!=="all"?n:void 0}]}),{data:I}=Fe({queryKey:["/api/users"],staleTime:5*60*1e3}),E=rt({mutationFn:async({orderId:L,notes:ce})=>{await ut("POST",`/api/orders/${L}/approve`,{notes:ce})},onSuccess:()=>{r.invalidateQueries({queryKey:["/api/orders"]}),r.invalidateQueries({queryKey:["/api/orders/stats"]}),t({title:"Order Approved",description:"The order has been successfully approved."})},onError:L=>{t({title:"Error",description:L.message,variant:"destructive"})}}),F=rt({mutationFn:async({orderId:L,notes:ce})=>{await ut("POST",`/api/orders/${L}/reject`,{notes:ce})},onSuccess:()=>{r.invalidateQueries({queryKey:["/api/orders"]}),r.invalidateQueries({queryKey:["/api/orders/stats"]}),t({title:"Order Rejected",description:"The order has been rejected."})},onError:L=>{t({title:"Error",description:L.message,variant:"destructive"})}}),V=rt({mutationFn:async({orderId:L,fsNumber:ce})=>await ut("PATCH",`/api/payment-reports/${L}/fs-number`,{fsNumber:ce}),onSuccess:()=>{r.invalidateQueries({queryKey:["/api/orders"]}),r.invalidateQueries({queryKey:["/api/payment-reports"]}),S(!1),P(null),C(""),t({title:"FS Number Updated",description:"The FS number has been successfully updated."})},onError:L=>{t({title:"Error",description:L.message,variant:"destructive"})}}),G=rt({mutationFn:async()=>{const L=await fetch("/api/export/orders",{credentials:"include"});if(!L.ok)throw new Error("Export failed");const ce=await L.blob(),ye=window.URL.createObjectURL(ce),We=document.createElement("a");We.href=ye,We.download="orders.xlsx",document.body.appendChild(We),We.click(),window.URL.revokeObjectURL(ye),document.body.removeChild(We)},onSuccess:()=>{t({title:"Export Complete",description:"Orders have been exported to Excel."})},onError:L=>{t({title:"Export Failed",description:L.message,variant:"destructive"})}}),K=L=>{switch(L){case"approved":return i.jsx(te,{variant:"default",className:"bg-emerald-100 text-emerald-800",children:"Approved"});case"rejected":return i.jsx(te,{variant:"destructive",children:"Rejected"});case"pending":return i.jsx(te,{variant:"secondary",className:"bg-amber-100 text-amber-800",children:"Pending Review"});case"completed":return i.jsx(te,{variant:"default",className:"bg-blue-100 text-blue-800",children:"Completed"});case"processing":return i.jsx(te,{variant:"outline",className:"bg-purple-100 text-purple-800",children:"Processing"});default:return i.jsx(te,{variant:"outline",children:L})}},q=L=>L&&L.trim()?i.jsxs(te,{variant:"outline",className:"bg-blue-50 text-blue-700 font-mono",children:["FS: ",L]}):i.jsx(te,{variant:"outline",className:"bg-gray-100 text-gray-600",children:"FS not set"}),ne=L=>L?L.split("_").map(ce=>ce.charAt(0).toUpperCase()).join(""):"N/A",le=L=>{if(!L||!I)return"Unknown";const ce=I.find(ye=>ye.id===L);return ce?`${ce.firstName} ${ce.lastName}`.trim():"Unknown"},de=L=>{P(L),C(L.fsNumber||""),S(!0)},ie=()=>{if(!O||!A.trim()){t({title:"Error",description:"Please enter a valid FS number.",variant:"destructive"});return}V.mutate({orderId:O.id,fsNumber:A.trim()})},ve=()=>{o(""),c(""),f(""),h(""),y(void 0),m(void 0),a("")},re=s||l||u||d||p||v||n&&n!=="all",Y=Array.isArray(R)?R.filter(L=>{var Yn,Pa,Aa,nl,Cu;const ce=!s||L.customerName.toLowerCase().includes(s.toLowerCase())||((Yn=L.customerTinNumber)==null?void 0:Yn.toLowerCase().includes(s.toLowerCase()))||((Pa=L.customerMobileNumber)==null?void 0:Pa.toLowerCase().includes(s.toLowerCase()))||((Aa=L.customerArea)==null?void 0:Aa.toLowerCase().includes(s.toLowerCase()))||L.orderNumber.toLowerCase().includes(s.toLowerCase())||((nl=L.businessSector)==null?void 0:nl.toLowerCase().includes(s.toLowerCase())),ye=!n||n==="all"||L.status===n,We=!l||l==="all"||L.salesOfficerId===l,Je=!u||((Cu=L.customerTinNumber)==null?void 0:Cu.toLowerCase().includes(u.toLowerCase())),ht=!d||L.fsNumber&&L.fsNumber.toLowerCase().includes(d.toLowerCase()),Lr=!p||new Date(L.createdAt)>=p,Vt=!v||new Date(L.createdAt)<=v;return ce&&ye&&We&&Je&&ht&&Lr&&Vt}).sort((L,ce)=>new Date(ce.createdAt).getTime()-new Date(L.createdAt).getTime()):[];return e?i.jsxs("div",{className:"h-screen bg-slate-50",children:[i.jsx(ca,{}),i.jsxs("div",{className:"md:ml-64 flex flex-col h-full overflow-hidden",children:[i.jsx(Ts,{}),i.jsxs("main",{className:"flex-1 overflow-y-auto p-4 lg:p-6",children:[i.jsx("div",{className:"max-w-7xl mx-auto space-y-6",children:i.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center lg:justify-between gap-4",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl lg:text-3xl font-bold text-slate-900",children:"Orders"}),i.jsx("p",{className:"text-slate-600 mt-1",children:"Manage and track all sales orders"})]}),i.jsxs("div",{className:"flex flex-col gap-4",children:[i.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[i.jsxs("div",{className:"relative flex-1 sm:w-64",children:[i.jsx(iu,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),i.jsx(he,{placeholder:"Search orders...",value:s,onChange:L=>o(L.target.value),className:"pl-10 h-10 sm:h-9"})]}),i.jsxs(_e,{value:n,onValueChange:a,children:[i.jsx(Ae,{className:"w-32 h-10 sm:h-9",children:i.jsx(De,{placeholder:"Status"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Status"}),i.jsx(U,{value:"pending",children:"Pending"}),i.jsx(U,{value:"approved",children:"Approved"}),i.jsx(U,{value:"rejected",children:"Rejected"})]})]}),i.jsxs(z,{variant:"outline",onClick:()=>g(!x),className:"h-10 sm:h-9",children:[i.jsx($o,{className:"w-4 h-4 mr-2"}),"Filters"]})]}),i.jsxs("div",{className:"flex gap-2",children:[re&&i.jsxs(z,{variant:"outline",onClick:ve,className:"h-10 sm:h-9 text-red-600 hover:text-red-700",children:[i.jsx(su,{className:"w-4 h-4 mr-2"}),"Clear"]}),i.jsx(So,{}),D&&i.jsxs(z,{variant:"outline",onClick:()=>G.mutate(),disabled:G.isPending,className:"h-10 sm:h-9",children:[i.jsx(Ln,{className:"w-4 h-4 mr-2"}),i.jsx("span",{className:"hidden sm:inline",children:"Export"})]})]})]}),x&&k&&i.jsx(W,{className:"p-4",children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(X,{htmlFor:"tin-filter",className:"text-sm font-medium",children:"Customer TIN"}),i.jsx(he,{id:"tin-filter",placeholder:"Enter TIN number...",value:u,onChange:L=>f(L.target.value),className:"h-9"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(X,{htmlFor:"fs-number-filter",className:"text-sm font-medium",children:"FS Number"}),i.jsx(he,{id:"fs-number-filter",placeholder:"Enter FS number...",value:d,onChange:L=>h(L.target.value),className:"h-9"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(X,{htmlFor:"sales-person-filter",className:"text-sm font-medium",children:"Sales Person"}),i.jsxs(_e,{value:l,onValueChange:c,children:[i.jsx(Ae,{className:"h-9",children:i.jsx(De,{placeholder:"Select sales person"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Sales Officers"}),Array.isArray(I)&&I.filter(L=>{var ce;return((ce=L.roles)==null?void 0:ce.includes("sales_officer"))||L.role==="sales_officer"}).map(L=>i.jsxs(U,{value:L.id,children:[L.firstName," ",L.lastName," (",L.id,")"]},L.id))]})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(X,{className:"text-sm font-medium",children:"Date From"}),i.jsxs(zo,{children:[i.jsx(Wo,{asChild:!0,children:i.jsxs(z,{variant:"outline",className:"h-9 w-full justify-start text-left font-normal",children:[i.jsx(Dr,{className:"mr-2 h-4 w-4"}),p?Ve(p,"PPP"):"Pick a date"]})}),i.jsx(Es,{className:"w-auto p-0",children:i.jsx(Cs,{mode:"single",selected:p,onSelect:y,initialFocus:!0})})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(X,{className:"text-sm font-medium",children:"Date To"}),i.jsxs(zo,{children:[i.jsx(Wo,{asChild:!0,children:i.jsxs(z,{variant:"outline",className:"h-9 w-full justify-start text-left font-normal",children:[i.jsx(Dr,{className:"mr-2 h-4 w-4"}),v?Ve(v,"PPP"):"Pick a date"]})}),i.jsx(Es,{className:"w-auto p-0",children:i.jsx(Cs,{mode:"single",selected:v,onSelect:m,initialFocus:!0})})]})]})]})})]})]})}),i.jsx(W,{className:"hidden lg:block",children:i.jsx(H,{className:"p-0",children:i.jsx("div",{className:"overflow-x-auto",children:i.jsxs(Vl,{children:[i.jsx(ql,{children:i.jsxs(zr,{children:[i.jsx(Le,{children:"Order ID"}),i.jsx(Le,{children:"Customer & TIN"}),i.jsx(Le,{children:"Products"}),i.jsx(Le,{children:"Business Details"}),i.jsx(Le,{children:"FS Number"}),i.jsx(Le,{children:"Sales Officer"}),i.jsx(Le,{children:"Status"}),i.jsx(Le,{children:"Date"}),i.jsx(Le,{children:"Actions"})]})}),i.jsx(Gl,{children:$?i.jsx(zr,{children:i.jsx(ke,{colSpan:9,className:"text-center py-8",children:"Loading orders..."})}):Y.length===0?i.jsx(zr,{children:i.jsx(ke,{colSpan:9,className:"text-center py-8 text-slate-500",children:"No orders found."})}):Y.map(L=>{var ce;return i.jsxs(zr,{children:[i.jsx(ke,{children:i.jsxs("span",{className:"font-medium",children:["#",(ce=L.orderNumber)==null?void 0:ce.slice(-6)]})}),i.jsx(ke,{children:i.jsxs("div",{children:[i.jsx("div",{className:"font-medium",children:L.customerName}),i.jsxs("div",{className:"text-sm text-slate-500 font-mono",children:["TIN: ",L.customerTinNumber]}),i.jsxs("div",{className:"text-xs text-slate-500",children:["📱 ",L.customerMobileNumber," • 📍 ",L.customerArea]})]})}),i.jsx(ke,{children:i.jsxs("div",{children:[i.jsxs("div",{className:"font-medium",children:[Array.isArray(L.items)?L.items.length:0," France Lait products"]}),i.jsxs("div",{className:"text-sm text-slate-500",children:["$",L.totalAmount]})]})}),i.jsx(ke,{children:i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium capitalize",children:L.businessSector}),i.jsx("div",{className:"text-xs text-slate-500 capitalize",children:L.paymentTerm})]})}),i.jsx(ke,{children:q(L.fsNumber)}),i.jsx(ke,{children:i.jsxs("div",{className:"flex items-center",children:[i.jsx("div",{className:"w-8 h-8 bg-blue-100 rounded-full flex items-center justify-center mr-3",children:i.jsx("span",{className:"text-xs font-medium text-blue-700",children:ne(L.salesOfficerId)})}),i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium",children:le(L.salesOfficerId)}),i.jsx("div",{className:"text-xs text-slate-500",children:"Sales Officer"})]})]})}),i.jsx(ke,{children:K(L.status)}),i.jsx(ke,{children:i.jsx("span",{className:"text-sm text-slate-500",children:new Date(L.createdAt).toLocaleDateString()})}),i.jsx(ke,{className:"min-w-[250px]",children:i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsx(z,{variant:"outline",size:"sm",onClick:()=>N(L),children:"View"}),_&&L.status==="approved"&&i.jsxs(z,{variant:"outline",size:"sm",onClick:()=>de(L),className:"bg-blue-50 hover:bg-blue-100 text-blue-700 border-blue-200",children:[i.jsx(JP,{className:"w-3 h-3 mr-1"}),L.fsNumber?"Edit FS":"Add FS"]}),T&&L.status==="pending"&&i.jsxs(i.Fragment,{children:[i.jsx(z,{size:"sm",className:"bg-emerald-600 hover:bg-emerald-700 text-white",onClick:()=>E.mutate({orderId:L.id}),disabled:E.isPending,children:"✓ Approve"}),i.jsx(z,{variant:"destructive",size:"sm",onClick:()=>F.mutate({orderId:L.id}),disabled:F.isPending,children:"✗ Reject"})]})]})})]},L.id)})})]})})})}),i.jsx("div",{className:"lg:hidden space-y-4",children:$?i.jsx(W,{children:i.jsx(H,{className:"p-6",children:i.jsx("div",{className:"text-center text-slate-500",children:"Loading orders..."})})}):Y.length===0?i.jsx(W,{children:i.jsx(H,{className:"p-6",children:i.jsx("div",{className:"text-center text-slate-500",children:"No orders found."})})}):Y.map(L=>{var ce;return i.jsx(W,{className:"p-4",children:i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"font-semibold",children:["#",(ce=L.orderNumber)==null?void 0:ce.slice(-6)]}),K(L.status)]}),i.jsx("span",{className:"text-sm text-slate-500",children:new Date(L.createdAt).toLocaleDateString()})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("div",{className:"font-medium",children:L.customerName}),i.jsxs("div",{className:"text-sm text-slate-500 font-mono",children:["TIN: ",L.customerTinNumber]}),i.jsxs("div",{className:"text-sm text-slate-500",children:["📱 ",L.customerMobileNumber," • 📍 ",L.customerArea]})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"w-6 h-6 bg-blue-100 text-blue-700 rounded-full flex items-center justify-center text-xs font-medium",children:ne(L.salesOfficerId)}),i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium",children:le(L.salesOfficerId)}),i.jsx("div",{className:"text-xs text-slate-500",children:"Sales Officer"})]})]}),q(L.fsNumber)]}),i.jsxs("div",{className:"flex justify-between items-center text-sm",children:[i.jsxs("div",{children:[i.jsxs("span",{className:"font-medium",children:[Array.isArray(L.items)?L.items.length:0," products"]}),i.jsxs("div",{className:"text-slate-500 capitalize",children:[L.businessSector," • ",L.paymentTerm]})]}),i.jsxs("div",{className:"font-medium text-lg",children:["$",L.totalAmount]})]}),i.jsxs("div",{className:"flex gap-2 pt-2 border-t",children:[i.jsx(z,{variant:"outline",size:"sm",onClick:()=>N(L),className:"flex-1",children:"View Details"}),_&&L.status==="approved"&&i.jsxs(z,{variant:"outline",size:"sm",onClick:()=>de(L),className:"bg-blue-50 hover:bg-blue-100 text-blue-700 border-blue-200 flex-1",children:[i.jsx(JP,{className:"w-3 h-3 mr-1"}),L.fsNumber?"Edit FS":"Add FS"]}),T&&L.status==="pending"&&i.jsxs(i.Fragment,{children:[i.jsx(z,{size:"sm",className:"bg-emerald-600 hover:bg-emerald-700 text-white flex-1",onClick:()=>E.mutate({orderId:L.id}),disabled:E.isPending,children:"✓ Approve"}),i.jsx(z,{variant:"destructive",size:"sm",onClick:()=>F.mutate({orderId:L.id}),disabled:F.isPending,className:"flex-1",children:"✗ Reject"})]})]})]})},L.id)})}),b&&i.jsx(pY,{order:b,onClose:()=>N(null),canApprove:!!T,onApprove:L=>{E.mutate({orderId:b.id,notes:L}),N(null)},onReject:L=>{F.mutate({orderId:b.id,notes:L}),N(null)}}),i.jsx(zt,{open:w,onOpenChange:S,children:i.jsxs($t,{className:"sm:max-w-md",children:[i.jsx(Lt,{children:i.jsx(Ft,{children:O!=null&&O.fsNumber?"Edit FS Number":"Add FS Number"})}),i.jsxs("div",{className:"space-y-4 py-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(X,{htmlFor:"order-info",children:"Order Details"}),i.jsxs("div",{className:"bg-slate-50 p-3 rounded-lg text-sm",children:[i.jsxs("div",{children:[i.jsx("strong",{children:"Order:"})," #",(Z=O==null?void 0:O.orderNumber)==null?void 0:Z.slice(-6)]}),i.jsxs("div",{children:[i.jsx("strong",{children:"Customer:"})," ",O==null?void 0:O.customerName]}),i.jsxs("div",{children:[i.jsx("strong",{children:"Amount:"})," $",O==null?void 0:O.totalAmount]})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(X,{htmlFor:"fs-number",children:"FS Number"}),i.jsx(he,{id:"fs-number",value:A,onChange:L=>C(L.target.value),placeholder:"Enter FS number",className:"w-full"})]})]}),i.jsxs(Oi,{children:[i.jsx(z,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),i.jsx(z,{onClick:ie,disabled:V.isPending||!A.trim(),children:V.isPending?"Saving...":"Save FS Number"})]})]})})]})]})]}):null}function mY({user:e,onClose:t,onApprove:r,onReject:n}){const[a,s]=j.useState(e.role||"sales_officer"),o=u=>{const f={super_admin:"bg-purple-100 text-purple-800",approver:"bg-blue-100 text-blue-800",sales_clerk:"bg-green-100 text-green-800",management:"bg-orange-100 text-orange-800",sales_officer:"bg-cyan-100 text-cyan-800"},d={super_admin:"Super Admin",approver:"Approver",sales_clerk:"Sales Clerk",management:"Management",sales_officer:"Sales Officer"};return i.jsx(te,{variant:"secondary",className:f[u],children:d[u]||u})},l=u=>new Date(u).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"}),c=()=>{r(a)};return i.jsx(zt,{open:!0,onOpenChange:t,children:i.jsxs($t,{className:"max-w-2xl",children:[i.jsx(Lt,{children:i.jsx(Ft,{children:"User Registration Details"})}),i.jsxs("div",{className:"space-y-6",children:[i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"text-lg flex items-center",children:[i.jsx(Fn,{className:"w-5 h-5 mr-2"}),"Personal Information"]})}),i.jsx(H,{className:"space-y-4",children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{className:"flex items-center",children:[i.jsx(Fn,{className:"w-4 h-4 text-slate-400 mr-2"}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-slate-500",children:"Full Name"}),i.jsxs("p",{className:"font-medium",children:[e.firstName," ",e.lastName]})]})]}),i.jsxs("div",{className:"flex items-center",children:[i.jsx(dI,{className:"w-4 h-4 text-slate-400 mr-2"}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-slate-500",children:"Email Address"}),i.jsx("p",{className:"font-medium",children:e.email})]})]}),e.department&&i.jsxs("div",{className:"flex items-center",children:[i.jsx(bc,{className:"w-4 h-4 text-slate-400 mr-2"}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-slate-500",children:"Department"}),i.jsx("p",{className:"font-medium",children:e.department})]})]}),i.jsxs("div",{className:"flex items-center",children:[i.jsx(Dr,{className:"w-4 h-4 text-slate-400 mr-2"}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-slate-500",children:"Registration Date"}),i.jsx("p",{className:"font-medium",children:l(e.createdAt)})]})]})]})})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{className:"text-lg",children:"Role Assignment"})}),i.jsxs(H,{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-slate-500 mb-2",children:"Requested Role"}),o(e.role||"sales_officer")]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-slate-700 mb-2",children:"Assign Role"}),i.jsxs(_e,{value:a,onValueChange:s,children:[i.jsx(Ae,{children:i.jsx(De,{})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"sales_officer",children:"Sales Officer"}),i.jsx(U,{value:"sales_clerk",children:"Data Recorder"}),i.jsx(U,{value:"approver",children:"Approver"}),i.jsx(U,{value:"management",children:"Management"})]})]})]})]})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{className:"text-lg",children:"Role Capabilities"})}),i.jsx(H,{children:i.jsxs("div",{className:"space-y-3",children:[a==="sales_officer"&&i.jsxs("div",{className:"p-3 bg-cyan-50 rounded-lg",children:[i.jsx("h4",{className:"font-medium text-cyan-800",children:"Sales Officer"}),i.jsx("p",{className:"text-sm text-cyan-700",children:"Submit orders via Telegram bot and track order status. Cannot approve orders or access administrative functions."})]}),a==="sales_clerk"&&i.jsxs("div",{className:"p-3 bg-green-50 rounded-lg",children:[i.jsx("h4",{className:"font-medium text-green-800",children:"Sales Clerk"}),i.jsx("p",{className:"text-sm text-green-700",children:"View all orders and export comprehensive data to Excel formats. Cannot approve orders but has read access to all order data."})]}),a==="approver"&&i.jsxs("div",{className:"p-3 bg-blue-50 rounded-lg",children:[i.jsx("h4",{className:"font-medium text-blue-800",children:"Approver"}),i.jsx("p",{className:"text-sm text-blue-700",children:"Approve and edit orders from sales officers, create reports, and post insights to management. Full order management capabilities."})]}),a==="management"&&i.jsxs("div",{className:"p-3 bg-orange-50 rounded-lg",children:[i.jsx("h4",{className:"font-medium text-orange-800",children:"Management"}),i.jsx("p",{className:"text-sm text-orange-700",children:"Access to reports, analytics, and insights from approvers. View-only access to orders with comprehensive reporting dashboard."})]})]})})]}),i.jsxs("div",{className:"flex items-center justify-end space-x-3 pt-4 border-t border-slate-200",children:[i.jsx(z,{variant:"outline",onClick:t,children:"Cancel"}),i.jsxs(z,{onClick:n,variant:"destructive",children:[i.jsx(ar,{className:"w-4 h-4 mr-2"}),"Reject Registration"]}),i.jsxs(z,{onClick:c,className:"bg-emerald-600 hover:bg-emerald-700",children:[i.jsx(ct,{className:"w-4 h-4 mr-2"}),"Approve as ",a.replace("_"," ")]})]})]})]})})}var MN="Checkbox",[vY,UCe]=wn(MN),[gY,yY]=vY(MN),l4=j.forwardRef((e,t)=>{const{__scopeCheckbox:r,name:n,checked:a,defaultChecked:s,required:o,disabled:l,value:c="on",onCheckedChange:u,form:f,...d}=e,[h,p]=j.useState(null),y=Ye(t,N=>p(N)),v=j.useRef(!1),m=h?f||!!h.closest("form"):!0,[x=!1,g]=Ro({prop:a,defaultProp:s,onChange:u}),b=j.useRef(x);return j.useEffect(()=>{const N=h==null?void 0:h.form;if(N){const w=()=>g(b.current);return N.addEventListener("reset",w),()=>N.removeEventListener("reset",w)}},[h,g]),i.jsxs(gY,{scope:r,state:x,disabled:l,children:[i.jsx(Re.button,{type:"button",role:"checkbox","aria-checked":gs(x)?"mixed":x,"aria-required":o,"data-state":d4(x),"data-disabled":l?"":void 0,disabled:l,value:c,...d,ref:y,onKeyDown:je(e.onKeyDown,N=>{N.key==="Enter"&&N.preventDefault()}),onClick:je(e.onClick,N=>{g(w=>gs(w)?!0:!w),m&&(v.current=N.isPropagationStopped(),v.current||N.stopPropagation())})}),m&&i.jsx(xY,{control:h,bubbles:!v.current,name:n,value:c,checked:x,required:o,disabled:l,form:f,style:{transform:"translateX(-100%)"},defaultChecked:gs(s)?!1:s})]})});l4.displayName=MN;var c4="CheckboxIndicator",u4=j.forwardRef((e,t)=>{const{__scopeCheckbox:r,forceMount:n,...a}=e,s=yY(c4,r);return i.jsx($s,{present:n||gs(s.state)||s.state===!0,children:i.jsx(Re.span,{"data-state":d4(s.state),"data-disabled":s.disabled?"":void 0,...a,ref:t,style:{pointerEvents:"none",...e.style}})})});u4.displayName=c4;var xY=e=>{const{control:t,checked:r,bubbles:n=!0,defaultChecked:a,...s}=e,o=j.useRef(null),l=vN(r),c=fN(t);j.useEffect(()=>{const f=o.current,d=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(d,"checked").set;if(l!==r&&p){const y=new Event("click",{bubbles:n});f.indeterminate=gs(r),p.call(f,gs(r)?!1:r),f.dispatchEvent(y)}},[l,r,n]);const u=j.useRef(gs(r)?!1:r);return i.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:a??u.current,...s,tabIndex:-1,ref:o,style:{...e.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function gs(e){return e==="indeterminate"}function d4(e){return gs(e)?"indeterminate":e?"checked":"unchecked"}var f4=l4,bY=u4;const h4=j.forwardRef(({className:e,...t},r)=>i.jsx(f4,{ref:r,className:ue("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:i.jsx(bY,{className:ue("flex items-center justify-center text-current"),children:i.jsx(lI,{className:"h-4 w-4"})})}));h4.displayName=f4.displayName;function jY({isOpen:e,onClose:t,onSubmit:r,isLoading:n}){const[a,s]=j.useState({username:"",password:"",firstName:"",lastName:"",email:"",role:"",department:"",telegramUsername:""}),[o,l]=j.useState(!1),[c,u]=j.useState([]),f=[{value:"super_admin",label:"Super Admin"},{value:"approver",label:"Approver"},{value:"management",label:"Management"},{value:"sales_officer",label:"Sales Officer"},{value:"sales_clerk",label:"Data Recorder"}],[d,h]=j.useState({}),p=()=>{const g={};return a.username.trim()?a.username.length<3&&(g.username="Username must be at least 3 characters"):g.username="Username is required",a.password?a.password.length<6&&(g.password="Password must be at least 6 characters"):g.password="Password is required",a.firstName.trim()||(g.firstName="First name is required"),a.lastName.trim()||(g.lastName="Last name is required"),a.role||(g.role="Role selection is required"),a.email&&a.email.trim()&&(/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a.email)||(g.email="Please enter a valid email address")),h(g),Object.keys(g).length===0},y=g=>{if(g.preventDefault(),p()){const b={...a,email:a.email.trim()||void 0,department:a.department.trim()||void 0,telegramUsername:a.telegramUsername.trim()||void 0,roles:c.length>0?c:[a.role]};r(b)}},v=g=>{u(b=>b.includes(g)?b.filter(N=>N!==g):[...b,g])},m=()=>{s({username:"",password:"",firstName:"",lastName:"",email:"",role:"",department:"",telegramUsername:""}),u([]),h({}),t()},x=()=>{const b="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*";let N="";for(let w=0;w<12;w++)N+=b.charAt(Math.floor(Math.random()*b.length));s({...a,password:N})};return i.jsx(zt,{open:e,onOpenChange:m,children:i.jsxs($t,{className:"max-w-md max-h-[90vh] overflow-y-auto",children:[i.jsxs(Lt,{children:[i.jsx(Ft,{children:"Create New User"}),i.jsx(Wa,{children:"Fill in the details below to create a new user account. Required fields are marked with *."})]}),i.jsxs("form",{onSubmit:y,className:"space-y-4 pb-4",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"firstName",children:"First Name *"}),i.jsx(he,{id:"firstName",value:a.firstName,onChange:g=>s({...a,firstName:g.target.value}),className:d.firstName?"border-red-500":"",required:!0}),d.firstName&&i.jsx("p",{className:"text-red-500 text-sm mt-1",children:d.firstName})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"lastName",children:"Last Name *"}),i.jsx(he,{id:"lastName",value:a.lastName,onChange:g=>s({...a,lastName:g.target.value}),className:d.lastName?"border-red-500":"",required:!0}),d.lastName&&i.jsx("p",{className:"text-red-500 text-sm mt-1",children:d.lastName})]})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"username",children:"Username *"}),i.jsx(he,{id:"username",value:a.username,onChange:g=>s({...a,username:g.target.value}),className:d.username?"border-red-500":"",placeholder:"Enter unique username",required:!0}),d.username&&i.jsx("p",{className:"text-red-500 text-sm mt-1",children:d.username})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"password",children:"Password *"}),i.jsxs("div",{className:"relative",children:[i.jsx(he,{id:"password",type:o?"text":"password",value:a.password,onChange:g=>s({...a,password:g.target.value}),required:!0,className:"pr-20"}),i.jsxs("div",{className:"absolute right-2 top-2 flex space-x-1",children:[i.jsx(z,{type:"button",variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>l(!o),children:o?i.jsx(zW,{className:"h-4 w-4"}):i.jsx(au,{className:"h-4 w-4"})}),i.jsx(z,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:x,children:"Gen"})]})]})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"email",children:"Email"}),i.jsx(he,{id:"email",type:"email",value:a.email,onChange:g=>s({...a,email:g.target.value})})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"role",children:"Primary Role *"}),i.jsxs(_e,{value:a.role,onValueChange:g=>s({...a,role:g}),children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"Select primary role"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"super_admin",children:"Super Admin"}),i.jsx(U,{value:"sales_officer",children:"Sales Officer"}),i.jsx(U,{value:"approver",children:"Approver"}),i.jsx(U,{value:"sales_clerk",children:"Sales Clerk"}),i.jsx(U,{value:"management",children:"Management"})]})]})]}),i.jsxs("div",{children:[i.jsx(X,{children:"Additional Roles (Optional)"}),i.jsx("div",{className:"space-y-2 mt-2",children:f.map(g=>i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx(h4,{id:`role-${g.value}`,checked:c.includes(g.value),onCheckedChange:()=>v(g.value)}),i.jsx(X,{htmlFor:`role-${g.value}`,className:"text-sm",children:g.label})]},g.value))}),i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Select additional roles this user should have access to"})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"department",children:"Department"}),i.jsx(he,{id:"department",value:a.department,onChange:g=>s({...a,department:g.target.value})})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"telegramUsername",children:"Telegram Username"}),i.jsx(he,{id:"telegramUsername",value:a.telegramUsername,onChange:g=>s({...a,telegramUsername:g.target.value}),placeholder:"@username"})]}),i.jsxs("div",{className:"flex justify-end space-x-3 pt-4",children:[i.jsx(z,{type:"button",variant:"outline",onClick:m,disabled:n,children:"Cancel"}),i.jsx(z,{type:"submit",disabled:n||!a.username||!a.password||!a.firstName||!a.lastName||!a.role,children:n?"Creating...":"Create User"})]})]})]})})}var p4="AlertDialog",[wY,zCe]=wn(p4,[RI]),_i=RI(),m4=e=>{const{__scopeAlertDialog:t,...r}=e,n=_i(t);return i.jsx(tN,{...n,...r,modal:!0})};m4.displayName=p4;var NY="AlertDialogTrigger",SY=j.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...n}=e,a=_i(r);return i.jsx(rN,{...a,...n,ref:t})});SY.displayName=NY;var OY="AlertDialogPortal",v4=e=>{const{__scopeAlertDialog:t,...r}=e,n=_i(t);return i.jsx(nN,{...n,...r})};v4.displayName=OY;var PY="AlertDialogOverlay",g4=j.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...n}=e,a=_i(r);return i.jsx(th,{...a,...n,ref:t})});g4.displayName=PY;var Kl="AlertDialogContent",[AY,CY]=wY(Kl),EY=Qz("AlertDialogContent"),y4=j.forwardRef((e,t)=>{const{__scopeAlertDialog:r,children:n,...a}=e,s=_i(r),o=j.useRef(null),l=Ye(t,o),c=j.useRef(null);return i.jsx(L9,{contentName:Kl,titleName:x4,docsSlug:"alert-dialog",children:i.jsx(AY,{scope:r,cancelRef:c,children:i.jsxs(rh,{role:"alertdialog",...s,...a,ref:l,onOpenAutoFocus:je(a.onOpenAutoFocus,u=>{var f;u.preventDefault(),(f=c.current)==null||f.focus({preventScroll:!0})}),onPointerDownOutside:u=>u.preventDefault(),onInteractOutside:u=>u.preventDefault(),children:[i.jsx(EY,{children:n}),i.jsx(kY,{contentRef:o})]})})})});y4.displayName=Kl;var x4="AlertDialogTitle",b4=j.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...n}=e,a=_i(r);return i.jsx(nh,{...a,...n,ref:t})});b4.displayName=x4;var j4="AlertDialogDescription",w4=j.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...n}=e,a=_i(r);return i.jsx(ah,{...a,...n,ref:t})});w4.displayName=j4;var TY="AlertDialogAction",N4=j.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...n}=e,a=_i(r);return i.jsx(gg,{...a,...n,ref:t})});N4.displayName=TY;var S4="AlertDialogCancel",O4=j.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...n}=e,{cancelRef:a}=CY(S4,r),s=_i(r),o=Ye(t,a);return i.jsx(gg,{...s,...n,ref:o})});O4.displayName=S4;var kY=({contentRef:e})=>{const t=`\`${Kl}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${Kl}\` by passing a \`${j4}\` component as a child, which also benefits sighted users by adding visible context to the dialog. Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${Kl}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component. For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return j.useEffect(()=>{var n;document.getElementById((n=e.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},_Y=m4,DY=v4,P4=g4,A4=y4,C4=N4,E4=O4,T4=b4,k4=w4;const MY=_Y,IY=DY,_4=j.forwardRef(({className:e,...t},r)=>i.jsx(P4,{className:ue("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:r}));_4.displayName=P4.displayName;const D4=j.forwardRef(({className:e,...t},r)=>i.jsxs(IY,{children:[i.jsx(_4,{}),i.jsx(A4,{ref:r,className:ue("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));D4.displayName=A4.displayName;const M4=({className:e,...t})=>i.jsx("div",{className:ue("flex flex-col space-y-2 text-center sm:text-left",e),...t});M4.displayName="AlertDialogHeader";const I4=({className:e,...t})=>i.jsx("div",{className:ue("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});I4.displayName="AlertDialogFooter";const R4=j.forwardRef(({className:e,...t},r)=>i.jsx(T4,{ref:r,className:ue("text-lg font-semibold",e),...t}));R4.displayName=T4.displayName;const $4=j.forwardRef(({className:e,...t},r)=>i.jsx(k4,{ref:r,className:ue("text-sm text-muted-foreground",e),...t}));$4.displayName=k4.displayName;const L4=j.forwardRef(({className:e,...t},r)=>i.jsx(C4,{ref:r,className:ue(Kd(),e),...t}));L4.displayName=C4.displayName;const F4=j.forwardRef(({className:e,...t},r)=>i.jsx(E4,{ref:r,className:ue(Kd({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));F4.displayName=E4.displayName;function RY(){const{toast:e}=Ht(),[t,r]=j.useState(!1),[n,a]=j.useState(!1),[s,o]=j.useState(!1);j.useState(!1);const[l,c]=j.useState(null),[u,f]=j.useState({firstName:"",lastName:"",email:"",username:"",role:"",registrationStatus:"",isActive:!0}),[d,h]=j.useState({newPassword:"",confirmPassword:""}),{data:p=[],isLoading:y}=Fe({queryKey:["/api/users"],queryFn:async()=>(await ut("GET","/api/users")).json()}),v=rt({mutationFn:async A=>(await ut("PUT",`/api/users/${A.userId}`,A.updates)).json(),onSuccess:()=>{sa.invalidateQueries({queryKey:["/api/users"]}),e({title:"User updated successfully"}),r(!1),c(null)},onError:A=>{e({title:"Failed to update user",description:A.message,variant:"destructive"})}}),m=rt({mutationFn:async A=>(await ut("DELETE",`/api/users/${A}`)).json(),onSuccess:()=>{sa.invalidateQueries({queryKey:["/api/users"]}),e({title:"User deleted successfully"}),a(!1),c(null)},onError:A=>{e({title:"Failed to delete user",description:A.message,variant:"destructive"})}}),x=rt({mutationFn:async A=>(await ut("POST",`/api/users/${A.userId}/change-password`,{newPassword:A.newPassword})).json(),onSuccess:()=>{e({title:"Password changed successfully"}),o(!1),c(null),h({newPassword:"",confirmPassword:""})},onError:A=>{e({title:"Failed to change password",description:A.message,variant:"destructive"})}}),g=A=>{c(A),f({firstName:A.firstName,lastName:A.lastName,email:A.email,username:A.username||"",role:A.role,registrationStatus:A.registrationStatus,isActive:A.isActive}),r(!0)},b=A=>{c(A),a(!0)},N=A=>{c(A),o(!0)},w=()=>{l&&v.mutate({userId:l.id,updates:u})},S=()=>{if(l){if(d.newPassword!==d.confirmPassword){e({title:"Password mismatch",description:"New password and confirmation do not match",variant:"destructive"});return}if(d.newPassword.length<8){e({title:"Password too short",description:"Password must be at least 8 characters long",variant:"destructive"});return}x.mutate({userId:l.id,newPassword:d.newPassword})}},O=A=>{switch(A){case"super_admin":return"bg-red-500 hover:bg-red-600";case"admin":return"bg-orange-500 hover:bg-orange-600";case"approver":return"bg-blue-500 hover:bg-blue-600";case"sales_officer":return"bg-green-500 hover:bg-green-600";case"sales_clerk":return"bg-purple-500 hover:bg-purple-600";default:return"bg-gray-500 hover:bg-gray-600"}},P=A=>{switch(A){case"approved":return"bg-green-500 hover:bg-green-600";case"pending":return"bg-yellow-500 hover:bg-yellow-600";case"rejected":return"bg-red-500 hover:bg-red-600";default:return"bg-gray-500 hover:bg-gray-600"}};return y?i.jsx("div",{className:"flex items-center justify-center p-8",children:i.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900"})}):i.jsxs("div",{className:"space-y-6",children:[i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"flex items-center gap-2",children:[i.jsx(Fn,{className:"h-5 w-5"}),"User Management"]})}),i.jsx(H,{children:i.jsx("div",{className:"rounded-md border",children:i.jsxs(Vl,{children:[i.jsx(ql,{children:i.jsxs(zr,{children:[i.jsx(Le,{children:"Name"}),i.jsx(Le,{children:"Email"}),i.jsx(Le,{children:"Username"}),i.jsx(Le,{children:"Role"}),i.jsx(Le,{children:"Status"}),i.jsx(Le,{children:"Active"}),i.jsx(Le,{children:"Created"}),i.jsx(Le,{children:"Actions"})]})}),i.jsx(Gl,{children:p.map(A=>i.jsxs(zr,{children:[i.jsxs(ke,{className:"font-medium",children:[A.firstName," ",A.lastName]}),i.jsx(ke,{children:A.email}),i.jsx(ke,{children:A.username||"-"}),i.jsx(ke,{children:i.jsx("div",{className:"space-y-1",children:Array.isArray(A.roles)&&A.roles.length>0?A.roles.map(C=>i.jsx(te,{className:`text-white ${O(C)} mr-1`,children:C.replace("_"," ").toUpperCase()},C)):i.jsx(te,{className:`text-white ${O(A.role)}`,children:A.role.replace("_"," ").toUpperCase()})})}),i.jsx(ke,{children:i.jsx(te,{className:`text-white ${P(A.registrationStatus)}`,children:A.registrationStatus.toUpperCase()})}),i.jsx(ke,{children:i.jsx(te,{variant:A.isActive?"default":"destructive",children:A.isActive?"Yes":"No"})}),i.jsx(ke,{children:new Date(A.createdAt).toLocaleDateString()}),i.jsx(ke,{children:i.jsxs("div",{className:"flex gap-2",children:[i.jsx(z,{variant:"outline",size:"sm",onClick:()=>g(A),children:i.jsx(hI,{className:"h-4 w-4"})}),i.jsx(z,{variant:"outline",size:"sm",onClick:()=>N(A),children:i.jsx(Ub,{className:"h-4 w-4"})}),i.jsx(z,{variant:"outline",size:"sm",onClick:()=>b(A),children:i.jsx(jc,{className:"h-4 w-4"})})]})})]},A.id))})]})})})]}),i.jsx(zt,{open:t,onOpenChange:r,children:i.jsxs($t,{className:"sm:max-w-md",children:[i.jsxs(Lt,{children:[i.jsx(Ft,{children:"Edit User"}),i.jsx(Wa,{children:"Update user information and permissions"})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"firstName",children:"First Name"}),i.jsx(he,{id:"firstName",value:u.firstName,onChange:A=>f(C=>({...C,firstName:A.target.value}))})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"lastName",children:"Last Name"}),i.jsx(he,{id:"lastName",value:u.lastName,onChange:A=>f(C=>({...C,lastName:A.target.value}))})]})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"email",children:"Email"}),i.jsx(he,{id:"email",type:"email",value:u.email,onChange:A=>f(C=>({...C,email:A.target.value}))})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"username",children:"Username"}),i.jsx(he,{id:"username",value:u.username,onChange:A=>f(C=>({...C,username:A.target.value}))})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"role",children:"Role"}),i.jsxs(_e,{value:u.role,onValueChange:A=>f(C=>({...C,role:A})),children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"Select role"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"super_admin",children:"Super Admin"}),i.jsx(U,{value:"admin",children:"Admin"}),i.jsx(U,{value:"approver",children:"Approver"}),i.jsx(U,{value:"sales_officer",children:"Sales Officer"}),i.jsx(U,{value:"sales_clerk",children:"Sales Clerk"})]})]})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"status",children:"Status"}),i.jsxs(_e,{value:u.registrationStatus,onValueChange:A=>f(C=>({...C,registrationStatus:A})),children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"Select status"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"approved",children:"Approved"}),i.jsx(U,{value:"pending",children:"Pending"}),i.jsx(U,{value:"rejected",children:"Rejected"})]})]})]}),i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx("input",{type:"checkbox",id:"isActive",checked:u.isActive,onChange:A=>f(C=>({...C,isActive:A.target.checked})),className:"h-4 w-4 rounded border-gray-300"}),i.jsx(X,{htmlFor:"isActive",children:"User is active"})]})]}),i.jsxs(Oi,{children:[i.jsx(z,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),i.jsx(z,{onClick:w,disabled:v.isPending,children:v.isPending?"Saving...":"Save Changes"})]})]})}),i.jsx(zt,{open:s,onOpenChange:o,children:i.jsxs($t,{className:"sm:max-w-md",children:[i.jsxs(Lt,{children:[i.jsx(Ft,{children:"Change Password"}),i.jsxs(Wa,{children:["Set a new password for ",l==null?void 0:l.firstName," ",l==null?void 0:l.lastName]})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"newPassword",children:"New Password"}),i.jsx(he,{id:"newPassword",type:"password",value:d.newPassword,onChange:A=>h(C=>({...C,newPassword:A.target.value})),placeholder:"Enter new password (min 8 characters)"})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"confirmPassword",children:"Confirm Password"}),i.jsx(he,{id:"confirmPassword",type:"password",value:d.confirmPassword,onChange:A=>h(C=>({...C,confirmPassword:A.target.value})),placeholder:"Confirm new password"})]})]}),i.jsxs(Oi,{children:[i.jsx(z,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),i.jsx(z,{onClick:S,disabled:x.isPending,children:x.isPending?"Changing...":"Change Password"})]})]})}),i.jsx(MY,{open:n,onOpenChange:a,children:i.jsxs(D4,{children:[i.jsxs(M4,{children:[i.jsx(R4,{children:"Delete User"}),i.jsxs($4,{children:["Are you sure you want to delete ",l==null?void 0:l.firstName," ",l==null?void 0:l.lastName,"? This action cannot be undone and will permanently remove all user data."]})]}),i.jsxs(I4,{children:[i.jsx(F4,{children:"Cancel"}),i.jsx(L4,{onClick:()=>l&&m.mutate(l.id),className:"bg-red-600 hover:bg-red-700",children:m.isPending?"Deleting...":"Delete User"})]})]})})]})}function $Y(){qn();const{toast:e}=Ht(),t=$r(),[r,n]=j.useState(""),[a,s]=j.useState(""),[o,l]=j.useState(null),[c,u]=j.useState(!1),{data:f=[],isLoading:d}=Fe({queryKey:["/api/users"],queryFn:async()=>(await ut("GET","/api/users")).json()}),{data:h=[],isLoading:p}=Fe({queryKey:["/api/users/pending"],queryFn:async()=>(await ut("GET","/api/users/pending")).json()}),y=rt({mutationFn:async()=>{const b=await(await ut("GET","/api/export/users")).blob(),N=window.URL.createObjectURL(b),w=document.createElement("a");w.style.display="none",w.href=N,w.download=`users-${new Date().toISOString().split("T")[0]}.xlsx`,document.body.appendChild(w),w.click(),window.URL.revokeObjectURL(N)},onError:g=>{e({title:"Export failed",description:g.message,variant:"destructive"})}}),v=rt({mutationFn:async({userId:g,role:b})=>(await ut("POST",`/api/users/${g}/approve`,{role:b})).json(),onSuccess:()=>{t.invalidateQueries({queryKey:["/api/users/pending"]}),t.invalidateQueries({queryKey:["/api/users"]}),e({title:"User approved successfully"}),l(null)},onError:g=>{e({title:"Approval failed",description:g.message,variant:"destructive"})}}),m=rt({mutationFn:async g=>(await ut("POST",`/api/users/${g}/reject`)).json(),onSuccess:()=>{t.invalidateQueries({queryKey:["/api/users/pending"]}),e({title:"User rejected"})},onError:g=>{e({title:"Rejection failed",description:g.message,variant:"destructive"})}}),x=rt({mutationFn:async g=>(await ut("POST","/api/users/create-manual",g)).json(),onSuccess:()=>{t.invalidateQueries({queryKey:["/api/users"]}),e({title:"User created successfully"}),u(!1)},onError:g=>{e({title:"User creation failed",description:g.message,variant:"destructive"})}});return f.filter(g=>{var w,S,O;const b=a===""||((w=g.firstName)==null?void 0:w.toLowerCase().includes(a.toLowerCase()))||((S=g.lastName)==null?void 0:S.toLowerCase().includes(a.toLowerCase()))||((O=g.email)==null?void 0:O.toLowerCase().includes(a.toLowerCase())),N=r===""||r==="all"||g.role===r;return b&&N}),d||p?i.jsxs("div",{className:"min-h-screen bg-slate-50",children:[i.jsx(ca,{}),i.jsxs("div",{className:"md:ml-64",children:[i.jsx(Ts,{}),i.jsx("main",{className:"p-6 pt-16 md:pt-6",children:i.jsx("div",{className:"flex items-center justify-center h-64",children:i.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900"})})})]})]}):i.jsxs("div",{className:"min-h-screen bg-slate-50",children:[i.jsx(ca,{}),i.jsxs("div",{className:"md:ml-64",children:[i.jsx(Ts,{}),i.jsxs("main",{className:"p-3 sm:p-6 pt-16 md:pt-6",children:[i.jsx("div",{className:"mb-4 sm:mb-6",children:i.jsxs("div",{className:"flex flex-col space-y-4 sm:flex-row sm:items-center sm:justify-between sm:space-y-0",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-xl sm:text-2xl font-semibold text-slate-800",children:"User Management"}),i.jsx("p",{className:"text-sm sm:text-base text-slate-600",children:"Manage all users, approvals, and access control"})]}),i.jsxs("div",{className:"flex flex-col space-y-3 sm:flex-row sm:items-center sm:space-y-0 sm:space-x-3",children:[i.jsxs("div",{className:"relative",children:[i.jsx(iu,{className:"w-4 h-4 text-slate-400 absolute left-3 top-3"}),i.jsx(he,{placeholder:"Search users...",className:"pl-10 h-10 sm:h-9",value:a,onChange:g=>s(g.target.value)})]}),i.jsxs("div",{className:"flex space-x-2",children:[i.jsxs(_e,{value:r,onValueChange:n,children:[i.jsx(Ae,{className:"w-full sm:w-40 h-10 sm:h-9",children:i.jsx(De,{placeholder:"All Roles"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Roles"}),i.jsx(U,{value:"super_admin",children:"Super Admin"}),i.jsx(U,{value:"approver",children:"Approver"}),i.jsx(U,{value:"management",children:"Management"}),i.jsx(U,{value:"sales_officer",children:"Sales Officer"}),i.jsx(U,{value:"sales_clerk",children:"Data Recorder"})]})]}),i.jsx(So,{trigger:i.jsxs(z,{variant:"outline",className:"bg-purple-600 hover:bg-purple-700 text-white border-purple-600 h-10 sm:h-9",children:[i.jsx(Et,{className:"w-4 h-4 mr-2"}),i.jsx("span",{className:"hidden sm:inline",children:"Report"})]})}),i.jsxs(z,{variant:"outline",onClick:()=>y.mutate(),disabled:y.isPending,className:"h-10 sm:h-9",children:[i.jsx(Ln,{className:"w-4 h-4 mr-2"}),i.jsx("span",{className:"hidden sm:inline",children:"Export"})]}),i.jsxs(z,{onClick:()=>u(!0),className:"bg-blue-600 hover:bg-blue-700 h-10 sm:h-9",children:[i.jsx(XW,{className:"w-4 h-4 mr-2"}),i.jsx("span",{className:"hidden sm:inline",children:"Create User"})]})]})]})]})}),i.jsxs(ja,{defaultValue:"management",className:"space-y-6",children:[i.jsxs(Hn,{className:"grid w-full grid-cols-2",children:[i.jsxs(Qe,{value:"management",className:"flex items-center gap-2",children:[i.jsx(Ss,{className:"h-4 w-4"}),"All Users Management"]}),i.jsxs(Qe,{value:"approvals",className:"flex items-center gap-2",children:[i.jsx(QW,{className:"h-4 w-4"}),"Pending Approvals (",Array.isArray(h)?h.length:0,")"]})]}),i.jsx(Xe,{value:"management",className:"space-y-6",children:i.jsx(RY,{})}),i.jsx(Xe,{value:"approvals",className:"space-y-6",children:Array.isArray(h)&&h.length>0?i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"flex items-center justify-between",children:[i.jsx("span",{children:"Pending User Registrations"}),i.jsxs(te,{variant:"secondary",className:"bg-amber-100 text-amber-800",children:[h.length," pending"]})]})}),i.jsx(H,{children:i.jsx("div",{className:"space-y-4",children:h.map(g=>{var b;return i.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"font-medium",children:[g.firstName," ",g.lastName]}),i.jsx("div",{className:"text-sm text-gray-600",children:g.email}),i.jsx(te,{variant:"outline",className:"mt-1",children:((b=g.role)==null?void 0:b.replace("_"," ").toUpperCase())||"UNKNOWN"})]}),i.jsxs("div",{className:"flex space-x-2",children:[i.jsx(z,{size:"sm",onClick:()=>l(g),className:"bg-green-600 hover:bg-green-700",children:"Review"}),i.jsx(z,{size:"sm",variant:"destructive",onClick:()=>m.mutate(g.id),children:"Reject"})]})]},g.id)})})})]}):i.jsx(W,{children:i.jsx(H,{className:"p-8 text-center",children:i.jsx("div",{className:"text-gray-500",children:"No pending user registrations"})})})})]}),o&&i.jsx(mY,{user:o,onClose:()=>l(null),onApprove:g=>v.mutate({userId:o.id,role:g}),onReject:()=>m.mutate(o.id)}),i.jsx(jY,{isOpen:c,onClose:()=>u(!1),onSubmit:g=>x.mutate(g),isLoading:x.isPending})]})]})]})}var IN="Progress",RN=100,[LY,WCe]=wn(IN),[FY,BY]=LY(IN),B4=j.forwardRef((e,t)=>{const{__scopeProgress:r,value:n=null,max:a,getValueLabel:s=UY,...o}=e;(a||a===0)&&!IA(a)&&console.error(zY(`${a}`,"Progress"));const l=IA(a)?a:RN;n!==null&&!RA(n,l)&&console.error(WY(`${n}`,"Progress"));const c=RA(n,l)?n:null,u=Im(c)?s(c,l):void 0;return i.jsx(FY,{scope:r,value:c,max:l,children:i.jsx(Re.div,{"aria-valuemax":l,"aria-valuemin":0,"aria-valuenow":Im(c)?c:void 0,"aria-valuetext":u,role:"progressbar","data-state":W4(c,l),"data-value":c??void 0,"data-max":l,...o,ref:t})})});B4.displayName=IN;var U4="ProgressIndicator",z4=j.forwardRef((e,t)=>{const{__scopeProgress:r,...n}=e,a=BY(U4,r);return i.jsx(Re.div,{"data-state":W4(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...n,ref:t})});z4.displayName=U4;function UY(e,t){return`${Math.round(e/t*100)}%`}function W4(e,t){return e==null?"indeterminate":e===t?"complete":"loading"}function Im(e){return typeof e=="number"}function IA(e){return Im(e)&&!isNaN(e)&&e>0}function RA(e,t){return Im(e)&&!isNaN(e)&&e<=t&&e>=0}function zY(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${RN}\`.`}function WY(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be: - a positive number - less than the value passed to \`max\` (or ${RN} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var H4=B4,HY=z4;const $N=j.forwardRef(({className:e,value:t,...r},n)=>i.jsx(H4,{ref:n,className:ue("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...r,children:i.jsx(HY,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));$N.displayName=H4.displayName;var VY=Array.isArray,en=VY,qY=typeof $h=="object"&&$h&&$h.Object===Object&&$h,V4=qY,GY=V4,KY=typeof self=="object"&&self&&self.Object===Object&&self,YY=GY||KY||Function("return this")(),ei=YY,QY=ei,XY=QY.Symbol,mh=XY,$A=mh,q4=Object.prototype,ZY=q4.hasOwnProperty,JY=q4.toString,zu=$A?$A.toStringTag:void 0;function eQ(e){var t=ZY.call(e,zu),r=e[zu];try{e[zu]=void 0;var n=!0}catch{}var a=JY.call(e);return n&&(t?e[zu]=r:delete e[zu]),a}var tQ=eQ,rQ=Object.prototype,nQ=rQ.toString;function aQ(e){return nQ.call(e)}var iQ=aQ,LA=mh,sQ=tQ,oQ=iQ,lQ="[object Null]",cQ="[object Undefined]",FA=LA?LA.toStringTag:void 0;function uQ(e){return e==null?e===void 0?cQ:lQ:FA&&FA in Object(e)?sQ(e):oQ(e)}var Di=uQ;function dQ(e){return e!=null&&typeof e=="object"}var Mi=dQ,fQ=Di,hQ=Mi,pQ="[object Symbol]";function mQ(e){return typeof e=="symbol"||hQ(e)&&fQ(e)==pQ}var fu=mQ,vQ=en,gQ=fu,yQ=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,xQ=/^\w*$/;function bQ(e,t){if(vQ(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||gQ(e)?!0:xQ.test(e)||!yQ.test(e)||t!=null&&e in Object(t)}var LN=bQ;function jQ(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Us=jQ;const hu=et(Us);var wQ=Di,NQ=Us,SQ="[object AsyncFunction]",OQ="[object Function]",PQ="[object GeneratorFunction]",AQ="[object Proxy]";function CQ(e){if(!NQ(e))return!1;var t=wQ(e);return t==OQ||t==PQ||t==SQ||t==AQ}var FN=CQ;const Oe=et(FN);var EQ=ei,TQ=EQ["__core-js_shared__"],kQ=TQ,Fx=kQ,BA=function(){var e=/[^.]+$/.exec(Fx&&Fx.keys&&Fx.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function _Q(e){return!!BA&&BA in e}var DQ=_Q,MQ=Function.prototype,IQ=MQ.toString;function RQ(e){if(e!=null){try{return IQ.call(e)}catch{}try{return e+""}catch{}}return""}var G4=RQ,$Q=FN,LQ=DQ,FQ=Us,BQ=G4,UQ=/[\\^$.*+?()[\]{}|]/g,zQ=/^\[object .+?Constructor\]$/,WQ=Function.prototype,HQ=Object.prototype,VQ=WQ.toString,qQ=HQ.hasOwnProperty,GQ=RegExp("^"+VQ.call(qQ).replace(UQ,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function KQ(e){if(!FQ(e)||LQ(e))return!1;var t=$Q(e)?GQ:zQ;return t.test(BQ(e))}var YQ=KQ;function QQ(e,t){return e==null?void 0:e[t]}var XQ=QQ,ZQ=YQ,JQ=XQ;function eX(e,t){var r=JQ(e,t);return ZQ(r)?r:void 0}var Zo=eX,tX=Zo,rX=tX(Object,"create"),Ag=rX,UA=Ag;function nX(){this.__data__=UA?UA(null):{},this.size=0}var aX=nX;function iX(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var sX=iX,oX=Ag,lX="__lodash_hash_undefined__",cX=Object.prototype,uX=cX.hasOwnProperty;function dX(e){var t=this.__data__;if(oX){var r=t[e];return r===lX?void 0:r}return uX.call(t,e)?t[e]:void 0}var fX=dX,hX=Ag,pX=Object.prototype,mX=pX.hasOwnProperty;function vX(e){var t=this.__data__;return hX?t[e]!==void 0:mX.call(t,e)}var gX=vX,yX=Ag,xX="__lodash_hash_undefined__";function bX(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=yX&&t===void 0?xX:t,this}var jX=bX,wX=aX,NX=sX,SX=fX,OX=gX,PX=jX;function pu(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t-1}var WX=zX,HX=Cg;function VX(e,t){var r=this.__data__,n=HX(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var qX=VX,GX=EX,KX=$X,YX=BX,QX=WX,XX=qX;function mu(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t0?1:-1},lo=function(t){return vh(t)&&t.indexOf("%")===t.length-1},se=function(t){return xJ(t)&&!gu(t)},Zt=function(t){return se(t)||vh(t)},NJ=0,Jo=function(t){var r=++NJ;return"".concat(t||"").concat(r)},Tr=function(t,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!se(t)&&!vh(t))return n;var s;if(lo(t)){var o=t.indexOf("%");s=r*parseFloat(t.slice(0,o))/100}else s=+t;return gu(s)&&(s=n),a&&s>r&&(s=r),s},Yi=function(t){if(!t)return null;var r=Object.keys(t);return r&&r.length?t[r[0]]:null},SJ=function(t){if(!Array.isArray(t))return!1;for(var r=t.length,n={},a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function TJ(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function ij(e){"@babel/helpers - typeof";return ij=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ij(e)}var KA={click:"onClick",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",mouseout:"onMouseOut",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",touchcancel:"onTouchCancel",touchend:"onTouchEnd",touchmove:"onTouchMove",touchstart:"onTouchStart",contextmenu:"onContextMenu",dblclick:"onDoubleClick"},yi=function(t){return typeof t=="string"?t:t?t.displayName||t.name||"Component":""},YA=null,Ux=null,YN=function e(t){if(t===YA&&Array.isArray(Ux))return Ux;var r=[];return j.Children.forEach(t,function(n){Ee(n)||(pJ.isFragment(n)?r=r.concat(e(n.props.children)):r.push(n))}),Ux=r,YA=t,r};function mn(e,t){var r=[],n=[];return Array.isArray(t)?n=t.map(function(a){return yi(a)}):n=[yi(t)],YN(e).forEach(function(a){var s=pn(a,"type.displayName")||pn(a,"type.name");n.indexOf(s)!==-1&&r.push(a)}),r}function sn(e,t){var r=mn(e,t);return r&&r[0]}var QA=function(t){if(!t||!t.props)return!1;var r=t.props,n=r.width,a=r.height;return!(!se(n)||n<=0||!se(a)||a<=0)},kJ=["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColormatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-url","foreignObject","g","glyph","glyphRef","hkern","image","line","lineGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"],_J=function(t){return t&&t.type&&vh(t.type)&&kJ.indexOf(t.type)>=0},nL=function(t){return t&&ij(t)==="object"&&"clipDot"in t},DJ=function(t,r,n,a){var s,o=(s=Bx==null?void 0:Bx[a])!==null&&s!==void 0?s:[];return r.startsWith("data-")||!Oe(t)&&(a&&o.includes(r)||PJ.includes(r))||n&&KN.includes(r)},xe=function(t,r,n){if(!t||typeof t=="function"||typeof t=="boolean")return null;var a=t;if(j.isValidElement(t)&&(a=t.props),!hu(a))return null;var s={};return Object.keys(a).forEach(function(o){var l;DJ((l=a)===null||l===void 0?void 0:l[o],o,r,n)&&(s[o]=a[o])}),s},sj=function e(t,r){if(t===r)return!0;var n=j.Children.count(t);if(n!==j.Children.count(r))return!1;if(n===0)return!0;if(n===1)return XA(Array.isArray(t)?t[0]:t,Array.isArray(r)?r[0]:r);for(var a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function LJ(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function lj(e){var t=e.children,r=e.width,n=e.height,a=e.viewBox,s=e.className,o=e.style,l=e.title,c=e.desc,u=$J(e,RJ),f=a||{width:r,height:n,x:0,y:0},d=Me("recharts-surface",s);return M.createElement("svg",oj({},xe(u,!0,"svg"),{className:d,width:r,height:n,style:o,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height)}),M.createElement("title",null,l),M.createElement("desc",null,c),t)}var FJ=["children","className"];function cj(){return cj=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function UJ(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}var Ue=M.forwardRef(function(e,t){var r=e.children,n=e.className,a=BJ(e,FJ),s=Me("recharts-layer",n);return M.createElement("g",cj({className:s},xe(a,!0),{ref:t}),r)}),pa=function(t,r){for(var n=arguments.length,a=new Array(n>2?n-2:0),s=2;sa?0:a+t),r=r>a?a:r,r<0&&(r+=a),a=t>r?0:r-t>>>0,t>>>=0;for(var s=Array(a);++n=n?e:HJ(e,t,r)}var qJ=VJ,GJ="\\ud800-\\udfff",KJ="\\u0300-\\u036f",YJ="\\ufe20-\\ufe2f",QJ="\\u20d0-\\u20ff",XJ=KJ+YJ+QJ,ZJ="\\ufe0e\\ufe0f",JJ="\\u200d",eee=RegExp("["+JJ+GJ+XJ+ZJ+"]");function tee(e){return eee.test(e)}var aL=tee;function ree(e){return e.split("")}var nee=ree,iL="\\ud800-\\udfff",aee="\\u0300-\\u036f",iee="\\ufe20-\\ufe2f",see="\\u20d0-\\u20ff",oee=aee+iee+see,lee="\\ufe0e\\ufe0f",cee="["+iL+"]",uj="["+oee+"]",dj="\\ud83c[\\udffb-\\udfff]",uee="(?:"+uj+"|"+dj+")",sL="[^"+iL+"]",oL="(?:\\ud83c[\\udde6-\\uddff]){2}",lL="[\\ud800-\\udbff][\\udc00-\\udfff]",dee="\\u200d",cL=uee+"?",uL="["+lee+"]?",fee="(?:"+dee+"(?:"+[sL,oL,lL].join("|")+")"+uL+cL+")*",hee=uL+cL+fee,pee="(?:"+[sL+uj+"?",uj,oL,lL,cee].join("|")+")",mee=RegExp(dj+"(?="+dj+")|"+pee+hee,"g");function vee(e){return e.match(mee)||[]}var gee=vee,yee=nee,xee=aL,bee=gee;function jee(e){return xee(e)?bee(e):yee(e)}var wee=jee,Nee=qJ,See=aL,Oee=wee,Pee=X4;function Aee(e){return function(t){t=Pee(t);var r=See(t)?Oee(t):void 0,n=r?r[0]:t.charAt(0),a=r?Nee(r,1).join(""):t.slice(1);return n[e]()+a}}var Cee=Aee,Eee=Cee,Tee=Eee("toUpperCase"),kee=Tee;const zg=et(kee);function mt(e){return function(){return e}}const dL=Math.cos,Lm=Math.sin,Sa=Math.sqrt,Fm=Math.PI,Wg=2*Fm,fj=Math.PI,hj=2*fj,eo=1e-6,_ee=hj-eo;function fL(e){this._+=e[0];for(let t=1,r=e.length;t=0))throw new Error(`invalid digits: ${e}`);if(t>15)return fL;const r=10**t;return function(n){this._+=n[0];for(let a=1,s=n.length;aeo)if(!(Math.abs(d*c-u*f)>eo)||!s)this._append`L${this._x1=t},${this._y1=r}`;else{let p=n-o,y=a-l,v=c*c+u*u,m=p*p+y*y,x=Math.sqrt(v),g=Math.sqrt(h),b=s*Math.tan((fj-Math.acos((v+h-m)/(2*x*g)))/2),N=b/g,w=b/x;Math.abs(N-1)>eo&&this._append`L${t+N*f},${r+N*d}`,this._append`A${s},${s},0,0,${+(d*p>f*y)},${this._x1=t+w*c},${this._y1=r+w*u}`}}arc(t,r,n,a,s,o){if(t=+t,r=+r,n=+n,o=!!o,n<0)throw new Error(`negative radius: ${n}`);let l=n*Math.cos(a),c=n*Math.sin(a),u=t+l,f=r+c,d=1^o,h=o?a-s:s-a;this._x1===null?this._append`M${u},${f}`:(Math.abs(this._x1-u)>eo||Math.abs(this._y1-f)>eo)&&this._append`L${u},${f}`,n&&(h<0&&(h=h%hj+hj),h>_ee?this._append`A${n},${n},0,1,${d},${t-l},${r-c}A${n},${n},0,1,${d},${this._x1=u},${this._y1=f}`:h>eo&&this._append`A${n},${n},0,${+(h>=fj)},${d},${this._x1=t+n*Math.cos(s)},${this._y1=r+n*Math.sin(s)}`)}rect(t,r,n,a){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+r}h${n=+n}v${+a}h${-n}Z`}toString(){return this._}}function QN(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 Mee(t)}function XN(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function hL(e){this._context=e}hL.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 Hg(e){return new hL(e)}function pL(e){return e[0]}function mL(e){return e[1]}function vL(e,t){var r=mt(!0),n=null,a=Hg,s=null,o=QN(l);e=typeof e=="function"?e:e===void 0?pL:mt(e),t=typeof t=="function"?t:t===void 0?mL:mt(t);function l(c){var u,f=(c=XN(c)).length,d,h=!1,p;for(n==null&&(s=a(p=o())),u=0;u<=f;++u)!(u=p;--y)l.point(b[y],N[y]);l.lineEnd(),l.areaEnd()}x&&(b[h]=+e(m,h,d),N[h]=+t(m,h,d),l.point(n?+n(m,h,d):b[h],r?+r(m,h,d):N[h]))}if(g)return l=null,g+""||null}function f(){return vL().defined(a).curve(o).context(s)}return u.x=function(d){return arguments.length?(e=typeof d=="function"?d:mt(+d),n=null,u):e},u.x0=function(d){return arguments.length?(e=typeof d=="function"?d:mt(+d),u):e},u.x1=function(d){return arguments.length?(n=d==null?null:typeof d=="function"?d:mt(+d),u):n},u.y=function(d){return arguments.length?(t=typeof d=="function"?d:mt(+d),r=null,u):t},u.y0=function(d){return arguments.length?(t=typeof d=="function"?d:mt(+d),u):t},u.y1=function(d){return arguments.length?(r=d==null?null:typeof d=="function"?d:mt(+d),u):r},u.lineX0=u.lineY0=function(){return f().x(e).y(t)},u.lineY1=function(){return f().x(e).y(r)},u.lineX1=function(){return f().x(n).y(t)},u.defined=function(d){return arguments.length?(a=typeof d=="function"?d:mt(!!d),u):a},u.curve=function(d){return arguments.length?(o=d,s!=null&&(l=o(s)),u):o},u.context=function(d){return arguments.length?(d==null?s=l=null:l=o(s=d),u):s},u}class gL{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 Iee(e){return new gL(e,!0)}function Ree(e){return new gL(e,!1)}const ZN={draw(e,t){const r=Sa(t/Fm);e.moveTo(r,0),e.arc(0,0,r,0,Wg)}},$ee={draw(e,t){const r=Sa(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()}},yL=Sa(1/3),Lee=yL*2,Fee={draw(e,t){const r=Sa(t/Lee),n=r*yL;e.moveTo(0,-r),e.lineTo(n,0),e.lineTo(0,r),e.lineTo(-n,0),e.closePath()}},Bee={draw(e,t){const r=Sa(t),n=-r/2;e.rect(n,n,r,r)}},Uee=.8908130915292852,xL=Lm(Fm/10)/Lm(7*Fm/10),zee=Lm(Wg/10)*xL,Wee=-dL(Wg/10)*xL,Hee={draw(e,t){const r=Sa(t*Uee),n=zee*r,a=Wee*r;e.moveTo(0,-r),e.lineTo(n,a);for(let s=1;s<5;++s){const o=Wg*s/5,l=dL(o),c=Lm(o);e.lineTo(c*r,-l*r),e.lineTo(l*n-c*a,c*n+l*a)}e.closePath()}},zx=Sa(3),Vee={draw(e,t){const r=-Sa(t/(zx*3));e.moveTo(0,r*2),e.lineTo(-zx*r,-r),e.lineTo(zx*r,-r),e.closePath()}},Sn=-.5,On=Sa(3)/2,pj=1/Sa(12),qee=(pj/2+1)*3,Gee={draw(e,t){const r=Sa(t/qee),n=r/2,a=r*pj,s=n,o=r*pj+r,l=-s,c=o;e.moveTo(n,a),e.lineTo(s,o),e.lineTo(l,c),e.lineTo(Sn*n-On*a,On*n+Sn*a),e.lineTo(Sn*s-On*o,On*s+Sn*o),e.lineTo(Sn*l-On*c,On*l+Sn*c),e.lineTo(Sn*n+On*a,Sn*a-On*n),e.lineTo(Sn*s+On*o,Sn*o-On*s),e.lineTo(Sn*l+On*c,Sn*c-On*l),e.closePath()}};function Kee(e,t){let r=null,n=QN(a);e=typeof e=="function"?e:mt(e||ZN),t=typeof t=="function"?t:mt(t===void 0?64:+t);function a(){let s;if(r||(r=s=n()),e.apply(this,arguments).draw(r,+t.apply(this,arguments)),s)return r=null,s+""||null}return a.type=function(s){return arguments.length?(e=typeof s=="function"?s:mt(s),a):e},a.size=function(s){return arguments.length?(t=typeof s=="function"?s:mt(+s),a):t},a.context=function(s){return arguments.length?(r=s??null,a):r},a}function Bm(){}function Um(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 bL(e){this._context=e}bL.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:Um(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:Um(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function Yee(e){return new bL(e)}function jL(e){this._context=e}jL.prototype={areaStart:Bm,areaEnd:Bm,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:Um(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function Qee(e){return new jL(e)}function wL(e){this._context=e}wL.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:Um(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function Xee(e){return new wL(e)}function NL(e){this._context=e}NL.prototype={areaStart:Bm,areaEnd:Bm,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 Zee(e){return new NL(e)}function JA(e){return e<0?-1:1}function eC(e,t,r){var n=e._x1-e._x0,a=t-e._x1,s=(e._y1-e._y0)/(n||a<0&&-0),o=(r-e._y1)/(a||n<0&&-0),l=(s*a+o*n)/(n+a);return(JA(s)+JA(o))*Math.min(Math.abs(s),Math.abs(o),.5*Math.abs(l))||0}function tC(e,t){var r=e._x1-e._x0;return r?(3*(e._y1-e._y0)/r-t)/2:t}function Wx(e,t,r){var n=e._x0,a=e._y0,s=e._x1,o=e._y1,l=(s-n)/3;e._context.bezierCurveTo(n+l,a+l*t,s-l,o-l*r,s,o)}function zm(e){this._context=e}zm.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:Wx(this,this._t0,tC(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,Wx(this,tC(this,r=eC(this,e,t)),r);break;default:Wx(this,this._t0,r=eC(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=r}}};function SL(e){this._context=new OL(e)}(SL.prototype=Object.create(zm.prototype)).point=function(e,t){zm.prototype.point.call(this,t,e)};function OL(e){this._context=e}OL.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,a,s){this._context.bezierCurveTo(t,e,n,r,s,a)}};function Jee(e){return new zm(e)}function ete(e){return new SL(e)}function PL(e){this._context=e}PL.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=rC(e),a=rC(t),s=0,o=1;o=0;--t)a[t]=(o[t]-a[t+1])/s[t];for(s[r-1]=(e[r]+a[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 rte(e){return new Vg(e,.5)}function nte(e){return new Vg(e,0)}function ate(e){return new Vg(e,1)}function Oc(e,t){if((o=e.length)>1)for(var r=1,n,a,s=e[t[0]],o,l=s.length;r=0;)r[t]=t;return r}function ite(e,t){return e[t]}function ste(e){const t=[];return t.key=e,t}function ote(){var e=mt([]),t=mj,r=Oc,n=ite;function a(s){var o=Array.from(e.apply(this,arguments),ste),l,c=o.length,u=-1,f;for(const d of s)for(l=0,++u;l0){for(var r,n,a=0,s=e[0].length,o;a0){for(var r=0,n=e[t[0]],a,s=n.length;r0)||!((s=(a=e[t[0]]).length)>0))){for(var r=0,n=1,a,s,o;n=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function vte(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}var AL={symbolCircle:ZN,symbolCross:$ee,symbolDiamond:Fee,symbolSquare:Bee,symbolStar:Hee,symbolTriangle:Vee,symbolWye:Gee},gte=Math.PI/180,yte=function(t){var r="symbol".concat(zg(t));return AL[r]||ZN},xte=function(t,r,n){if(r==="area")return t;switch(n){case"cross":return 5*t*t/9;case"diamond":return .5*t*t/Math.sqrt(3);case"square":return t*t;case"star":{var a=18*gte;return 1.25*t*t*(Math.tan(a)-Math.tan(a*2)*Math.pow(Math.tan(a),2))}case"triangle":return Math.sqrt(3)*t*t/4;case"wye":return(21-10*Math.sqrt(3))*t*t/8;default:return Math.PI*t*t/4}},bte=function(t,r){AL["symbol".concat(zg(t))]=r},JN=function(t){var r=t.type,n=r===void 0?"circle":r,a=t.size,s=a===void 0?64:a,o=t.sizeType,l=o===void 0?"area":o,c=mte(t,dte),u=aC(aC({},c),{},{type:n,size:s,sizeType:l}),f=function(){var m=yte(n),x=Kee().type(m).size(xte(s,l,n));return x()},d=u.className,h=u.cx,p=u.cy,y=xe(u,!0);return h===+h&&p===+p&&s===+s?M.createElement("path",vj({},y,{className:Me("recharts-symbols",d),transform:"translate(".concat(h,", ").concat(p,")"),d:f()})):null};JN.registerSymbol=bte;function Pc(e){"@babel/helpers - typeof";return Pc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Pc(e)}function gj(){return gj=Object.assign?Object.assign.bind():function(e){for(var t=1;t`);var g=p.inactive?u:p.color;return M.createElement("li",gj({className:m,style:d,key:"legend-item-".concat(y)},Ho(n.props,p,y)),M.createElement(lj,{width:o,height:o,viewBox:f,style:h},n.renderIcon(p)),M.createElement("span",{className:"recharts-legend-item-text",style:{color:g}},v?v(x,p,y):x))})}},{key:"render",value:function(){var n=this.props,a=n.payload,s=n.layout,o=n.align;if(!a||!a.length)return null;var l={padding:0,margin:0,textAlign:s==="horizontal"?o:"left"};return M.createElement("ul",{className:"recharts-default-legend",style:l},this.renderItems())}}])}(j.PureComponent);Jd(eS,"displayName","Legend");Jd(eS,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var Tte=Eg;function kte(){this.__data__=new Tte,this.size=0}var _te=kte;function Dte(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var Mte=Dte;function Ite(e){return this.__data__.get(e)}var Rte=Ite;function $te(e){return this.__data__.has(e)}var Lte=$te,Fte=Eg,Bte=UN,Ute=zN,zte=200;function Wte(e,t){var r=this.__data__;if(r instanceof Fte){var n=r.__data__;if(!Bte||n.lengthl))return!1;var u=s.get(e),f=s.get(t);if(u&&f)return u==t&&f==e;var d=-1,h=!0,p=r&dre?new ore:void 0;for(s.set(e,t),s.set(t,e);++d-1&&e%1==0&&e-1&&e%1==0&&e<=mne}var aS=vne,gne=Di,yne=aS,xne=Mi,bne="[object Arguments]",jne="[object Array]",wne="[object Boolean]",Nne="[object Date]",Sne="[object Error]",One="[object Function]",Pne="[object Map]",Ane="[object Number]",Cne="[object Object]",Ene="[object RegExp]",Tne="[object Set]",kne="[object String]",_ne="[object WeakMap]",Dne="[object ArrayBuffer]",Mne="[object DataView]",Ine="[object Float32Array]",Rne="[object Float64Array]",$ne="[object Int8Array]",Lne="[object Int16Array]",Fne="[object Int32Array]",Bne="[object Uint8Array]",Une="[object Uint8ClampedArray]",zne="[object Uint16Array]",Wne="[object Uint32Array]",jt={};jt[Ine]=jt[Rne]=jt[$ne]=jt[Lne]=jt[Fne]=jt[Bne]=jt[Une]=jt[zne]=jt[Wne]=!0;jt[bne]=jt[jne]=jt[Dne]=jt[wne]=jt[Mne]=jt[Nne]=jt[Sne]=jt[One]=jt[Pne]=jt[Ane]=jt[Cne]=jt[Ene]=jt[Tne]=jt[kne]=jt[_ne]=!1;function Hne(e){return xne(e)&&yne(e.length)&&!!jt[gne(e)]}var Vne=Hne;function qne(e){return function(t){return e(t)}}var LL=qne,qm={exports:{}};qm.exports;(function(e,t){var r=V4,n=t&&!t.nodeType&&t,a=n&&!0&&e&&!e.nodeType&&e,s=a&&a.exports===n,o=s&&r.process,l=function(){try{var c=a&&a.require&&a.require("util").types;return c||o&&o.binding&&o.binding("util")}catch{}}();e.exports=l})(qm,qm.exports);var Gne=qm.exports,Kne=Vne,Yne=LL,dC=Gne,fC=dC&&dC.isTypedArray,Qne=fC?Yne(fC):Kne,FL=Qne,Xne=ene,Zne=rS,Jne=en,eae=$L,tae=nS,rae=FL,nae=Object.prototype,aae=nae.hasOwnProperty;function iae(e,t){var r=Jne(e),n=!r&&Zne(e),a=!r&&!n&&eae(e),s=!r&&!n&&!a&&rae(e),o=r||n||a||s,l=o?Xne(e.length,String):[],c=l.length;for(var u in e)(t||aae.call(e,u))&&!(o&&(u=="length"||a&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||tae(u,c)))&&l.push(u);return l}var sae=iae,oae=Object.prototype;function lae(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||oae;return e===r}var cae=lae;function uae(e,t){return function(r){return e(t(r))}}var BL=uae,dae=BL,fae=dae(Object.keys,Object),hae=fae,pae=cae,mae=hae,vae=Object.prototype,gae=vae.hasOwnProperty;function yae(e){if(!pae(e))return mae(e);var t=[];for(var r in Object(e))gae.call(e,r)&&r!="constructor"&&t.push(r);return t}var xae=yae,bae=FN,jae=aS;function wae(e){return e!=null&&jae(e.length)&&!bae(e)}var gh=wae,Nae=sae,Sae=xae,Oae=gh;function Pae(e){return Oae(e)?Nae(e):Sae(e)}var qg=Pae,Aae=zre,Cae=Zre,Eae=qg;function Tae(e){return Aae(e,Eae,Cae)}var kae=Tae,hC=kae,_ae=1,Dae=Object.prototype,Mae=Dae.hasOwnProperty;function Iae(e,t,r,n,a,s){var o=r&_ae,l=hC(e),c=l.length,u=hC(t),f=u.length;if(c!=f&&!o)return!1;for(var d=c;d--;){var h=l[d];if(!(o?h in t:Mae.call(t,h)))return!1}var p=s.get(e),y=s.get(t);if(p&&y)return p==t&&y==e;var v=!0;s.set(e,t),s.set(t,e);for(var m=o;++d-1}var Dse=_se;function Mse(e,t,r){for(var n=-1,a=e==null?0:e.length;++n=Yse){var u=t?null:Gse(e);if(u)return Kse(u);o=!1,a=qse,c=new Wse}else c=t?[]:l;e:for(;++n=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function doe(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function foe(e){return e.value}function hoe(e,t){if(M.isValidElement(e))return M.cloneElement(e,t);if(typeof e=="function")return M.createElement(e,t);t.ref;var r=uoe(t,roe);return M.createElement(eS,r)}var EC=1,Ql=function(e){function t(){var r;noe(this,t);for(var n=arguments.length,a=new Array(n),s=0;sEC||Math.abs(a.height-this.lastBoundingBox.height)>EC)&&(this.lastBoundingBox.width=a.width,this.lastBoundingBox.height=a.height,n&&n(a)):(this.lastBoundingBox.width!==-1||this.lastBoundingBox.height!==-1)&&(this.lastBoundingBox.width=-1,this.lastBoundingBox.height=-1,n&&n(null))}},{key:"getBBoxSnapshot",value:function(){return this.lastBoundingBox.width>=0&&this.lastBoundingBox.height>=0?ai({},this.lastBoundingBox):{width:0,height:0}}},{key:"getDefaultPosition",value:function(n){var a=this.props,s=a.layout,o=a.align,l=a.verticalAlign,c=a.margin,u=a.chartWidth,f=a.chartHeight,d,h;if(!n||(n.left===void 0||n.left===null)&&(n.right===void 0||n.right===null))if(o==="center"&&s==="vertical"){var p=this.getBBoxSnapshot();d={left:((u||0)-p.width)/2}}else d=o==="right"?{right:c&&c.right||0}:{left:c&&c.left||0};if(!n||(n.top===void 0||n.top===null)&&(n.bottom===void 0||n.bottom===null))if(l==="middle"){var y=this.getBBoxSnapshot();h={top:((f||0)-y.height)/2}}else h=l==="bottom"?{bottom:c&&c.bottom||0}:{top:c&&c.top||0};return ai(ai({},d),h)}},{key:"render",value:function(){var n=this,a=this.props,s=a.content,o=a.width,l=a.height,c=a.wrapperStyle,u=a.payloadUniqBy,f=a.payload,d=ai(ai({position:"absolute",width:o||"auto",height:l||"auto"},this.getDefaultPosition(c)),c);return M.createElement("div",{className:"recharts-legend-wrapper",style:d,ref:function(p){n.wrapperNode=p}},hoe(s,ai(ai({},this.props),{},{payload:GL(f,u,foe)})))}}],[{key:"getWithHeight",value:function(n,a){var s=ai(ai({},this.defaultProps),n.props),o=s.layout;return o==="vertical"&&se(n.props.height)?{height:n.props.height}:o==="horizontal"?{width:n.props.width||a}:null}}])}(j.PureComponent);Gg(Ql,"displayName","Legend");Gg(Ql,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var TC=mh,poe=rS,moe=en,kC=TC?TC.isConcatSpreadable:void 0;function voe(e){return moe(e)||poe(e)||!!(kC&&e&&e[kC])}var goe=voe,yoe=IL,xoe=goe;function QL(e,t,r,n,a){var s=-1,o=e.length;for(r||(r=xoe),a||(a=[]);++s0&&r(l)?t>1?QL(l,t-1,r,n,a):yoe(a,l):n||(a[a.length]=l)}return a}var XL=QL;function boe(e){return function(t,r,n){for(var a=-1,s=Object(t),o=n(t),l=o.length;l--;){var c=o[e?l:++a];if(r(s[c],c,s)===!1)break}return t}}var joe=boe,woe=joe,Noe=woe(),Soe=Noe,Ooe=Soe,Poe=qg;function Aoe(e,t){return e&&Ooe(e,t,Poe)}var ZL=Aoe,Coe=gh;function Eoe(e,t){return function(r,n){if(r==null)return r;if(!Coe(r))return e(r,n);for(var a=r.length,s=t?a:-1,o=Object(r);(t?s--:++st||s&&o&&c&&!l&&!u||n&&o&&c||!r&&c||!a)return 1;if(!n&&!s&&!u&&e=l)return c;var u=r[n];return c*(u=="desc"?-1:1)}}return e.index-t.index}var Woe=zoe,Gx=HN,Hoe=VN,Voe=ti,qoe=JL,Goe=Loe,Koe=LL,Yoe=Woe,Qoe=bu,Xoe=en;function Zoe(e,t,r){t.length?t=Gx(t,function(s){return Xoe(s)?function(o){return Hoe(o,s.length===1?s[0]:s)}:s}):t=[Qoe];var n=-1;t=Gx(t,Koe(Voe));var a=qoe(e,function(s,o,l){var c=Gx(t,function(u){return u(s)});return{criteria:c,index:++n,value:s}});return Goe(a,function(s,o){return Yoe(s,o,r)})}var Joe=Zoe;function ele(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var tle=ele,rle=tle,DC=Math.max;function nle(e,t,r){return t=DC(t===void 0?e.length-1:t,0),function(){for(var n=arguments,a=-1,s=DC(n.length-t,0),o=Array(s);++a0){if(++t>=hle)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var gle=vle,yle=fle,xle=gle,ble=xle(yle),jle=ble,wle=bu,Nle=ale,Sle=jle;function Ole(e,t){return Sle(Nle(e,t,wle),e+"")}var Ple=Ole,Ale=BN,Cle=gh,Ele=nS,Tle=Us;function kle(e,t,r){if(!Tle(r))return!1;var n=typeof t;return(n=="number"?Cle(r)&&Ele(t,r.length):n=="string"&&t in r)?Ale(r[t],e):!1}var Kg=kle,_le=XL,Dle=Joe,Mle=Ple,IC=Kg,Ile=Mle(function(e,t){if(e==null)return[];var r=t.length;return r>1&&IC(e,t[0],t[1])?t=[]:r>2&&IC(t[0],t[1],t[2])&&(t=[t[0]]),Dle(e,_le(t,1),[])}),Rle=Ile;const oS=et(Rle);function ef(e){"@babel/helpers - typeof";return ef=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ef(e)}function Oj(){return Oj=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r=t.x),"".concat(Wu,"-left"),se(r)&&t&&se(t.x)&&r=t.y),"".concat(Wu,"-top"),se(n)&&t&&se(t.y)&&nv?Math.max(f,c[n]):Math.max(d,c[n])}function Xle(e){var t=e.translateX,r=e.translateY,n=e.useTranslate3d;return{transform:n?"translate3d(".concat(t,"px, ").concat(r,"px, 0)"):"translate(".concat(t,"px, ").concat(r,"px)")}}function Zle(e){var t=e.allowEscapeViewBox,r=e.coordinate,n=e.offsetTopLeft,a=e.position,s=e.reverseDirection,o=e.tooltipBox,l=e.useTranslate3d,c=e.viewBox,u,f,d;return o.height>0&&o.width>0&&r?(f=LC({allowEscapeViewBox:t,coordinate:r,key:"x",offsetTopLeft:n,position:a,reverseDirection:s,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),d=LC({allowEscapeViewBox:t,coordinate:r,key:"y",offsetTopLeft:n,position:a,reverseDirection:s,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),u=Xle({translateX:f,translateY:d,useTranslate3d:l})):u=Yle,{cssProperties:u,cssClasses:Qle({translateX:f,translateY:d,coordinate:r})}}function Cc(e){"@babel/helpers - typeof";return Cc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Cc(e)}function FC(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function BC(e){for(var t=1;tUC||Math.abs(n.height-this.state.lastBoundingBox.height)>UC)&&this.setState({lastBoundingBox:{width:n.width,height:n.height}})}else(this.state.lastBoundingBox.width!==-1||this.state.lastBoundingBox.height!==-1)&&this.setState({lastBoundingBox:{width:-1,height:-1}})}},{key:"componentDidMount",value:function(){document.addEventListener("keydown",this.handleKeyDown),this.updateBBox()}},{key:"componentWillUnmount",value:function(){document.removeEventListener("keydown",this.handleKeyDown)}},{key:"componentDidUpdate",value:function(){var n,a;this.props.active&&this.updateBBox(),this.state.dismissed&&(((n=this.props.coordinate)===null||n===void 0?void 0:n.x)!==this.state.dismissedAtCoordinate.x||((a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}},{key:"render",value:function(){var n=this,a=this.props,s=a.active,o=a.allowEscapeViewBox,l=a.animationDuration,c=a.animationEasing,u=a.children,f=a.coordinate,d=a.hasPayload,h=a.isAnimationActive,p=a.offset,y=a.position,v=a.reverseDirection,m=a.useTranslate3d,x=a.viewBox,g=a.wrapperStyle,b=Zle({allowEscapeViewBox:o,coordinate:f,offsetTopLeft:p,position:y,reverseDirection:v,tooltipBox:this.state.lastBoundingBox,useTranslate3d:m,viewBox:x}),N=b.cssClasses,w=b.cssProperties,S=BC(BC({transition:h&&s?"transform ".concat(l,"ms ").concat(c):void 0},w),{},{pointerEvents:"none",visibility:!this.state.dismissed&&s&&d?"visible":"hidden",position:"absolute",top:0,left:0},g);return M.createElement("div",{tabIndex:-1,className:N,style:S,ref:function(P){n.wrapperNode=P}},u)}}])}(j.PureComponent),lce=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},ma={isSsr:lce(),get:function(t){return ma[t]},set:function(t,r){if(typeof t=="string")ma[t]=r;else{var n=Object.keys(t);n&&n.length&&n.forEach(function(a){ma[a]=t[a]})}}};function Ec(e){"@babel/helpers - typeof";return Ec=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ec(e)}function zC(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function WC(e){for(var t=1;t0;return M.createElement(oce,{allowEscapeViewBox:o,animationDuration:l,animationEasing:c,isAnimationActive:h,active:s,coordinate:f,hasPayload:S,offset:p,position:m,reverseDirection:x,useTranslate3d:g,viewBox:b,wrapperStyle:N},yce(u,WC(WC({},this.props),{},{payload:w})))}}])}(j.PureComponent);lS(Wr,"displayName","Tooltip");lS(Wr,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!ma.isSsr,itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,viewBox:{x:0,y:0,height:0,width:0},wrapperStyle:{}});var xce=ei,bce=function(){return xce.Date.now()},jce=bce,wce=/\s/;function Nce(e){for(var t=e.length;t--&&wce.test(e.charAt(t)););return t}var Sce=Nce,Oce=Sce,Pce=/^\s+/;function Ace(e){return e&&e.slice(0,Oce(e)+1).replace(Pce,"")}var Cce=Ace,Ece=Cce,HC=Us,Tce=fu,VC=NaN,kce=/^[-+]0x[0-9a-f]+$/i,_ce=/^0b[01]+$/i,Dce=/^0o[0-7]+$/i,Mce=parseInt;function Ice(e){if(typeof e=="number")return e;if(Tce(e))return VC;if(HC(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=HC(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Ece(e);var r=_ce.test(e);return r||Dce.test(e)?Mce(e.slice(2),r?2:8):kce.test(e)?VC:+e}var iF=Ice,Rce=Us,Yx=jce,qC=iF,$ce="Expected a function",Lce=Math.max,Fce=Math.min;function Bce(e,t,r){var n,a,s,o,l,c,u=0,f=!1,d=!1,h=!0;if(typeof e!="function")throw new TypeError($ce);t=qC(t)||0,Rce(r)&&(f=!!r.leading,d="maxWait"in r,s=d?Lce(qC(r.maxWait)||0,t):s,h="trailing"in r?!!r.trailing:h);function p(S){var O=n,P=a;return n=a=void 0,u=S,o=e.apply(P,O),o}function y(S){return u=S,l=setTimeout(x,t),f?p(S):o}function v(S){var O=S-c,P=S-u,A=t-O;return d?Fce(A,s-P):A}function m(S){var O=S-c,P=S-u;return c===void 0||O>=t||O<0||d&&P>=s}function x(){var S=Yx();if(m(S))return g(S);l=setTimeout(x,v(S))}function g(S){return l=void 0,h&&n?p(S):(n=a=void 0,o)}function b(){l!==void 0&&clearTimeout(l),u=0,n=c=a=l=void 0}function N(){return l===void 0?o:g(Yx())}function w(){var S=Yx(),O=m(S);if(n=arguments,a=this,c=S,O){if(l===void 0)return y(c);if(d)return clearTimeout(l),l=setTimeout(x,t),p(c)}return l===void 0&&(l=setTimeout(x,t)),o}return w.cancel=b,w.flush=N,w}var Uce=Bce,zce=Uce,Wce=Us,Hce="Expected a function";function Vce(e,t,r){var n=!0,a=!0;if(typeof e!="function")throw new TypeError(Hce);return Wce(r)&&(n="leading"in r?!!r.leading:n,a="trailing"in r?!!r.trailing:a),zce(e,t,{leading:n,maxWait:t,trailing:a})}var qce=Vce;const sF=et(qce);function rf(e){"@babel/helpers - typeof";return rf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},rf(e)}function GC(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function pp(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&(_=sF(_,v,{trailing:!0,leading:!1}));var k=new ResizeObserver(_),R=w.current.getBoundingClientRect(),$=R.width,I=R.height;return T($,I),k.observe(w.current),function(){k.disconnect()}},[T,v]);var D=j.useMemo(function(){var _=A.containerWidth,k=A.containerHeight;if(_<0||k<0)return null;pa(lo(o)||lo(c),`The width(%s) and height(%s) are both fixed numbers, maybe you don't need to use a ResponsiveContainer.`,o,c),pa(!r||r>0,"The aspect(%s) must be greater than zero.",r);var R=lo(o)?_:o,$=lo(c)?k:c;r&&r>0&&(R?$=R/r:$&&(R=$*r),h&&$>h&&($=h)),pa(R>0||$>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.`,R,$,o,c,f,d,r);var I=!Array.isArray(p)&&yi(p.type).endsWith("Chart");return M.Children.map(p,function(E){return M.isValidElement(E)?j.cloneElement(E,pp({width:R,height:$},I?{style:pp({height:"100%",width:"100%",maxHeight:$,maxWidth:R},E.props.style)}:{})):E})},[r,p,c,h,d,f,A,o]);return M.createElement("div",{id:m?"".concat(m):void 0,className:Me("recharts-responsive-container",x),style:pp(pp({},N),{},{width:o,height:c,minWidth:f,minHeight:d,maxHeight:h}),ref:w},D)}),Yg=function(t){return null};Yg.displayName="Cell";function nf(e){"@babel/helpers - typeof";return nf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},nf(e)}function YC(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Ej(e){for(var t=1;t1&&arguments[1]!==void 0?arguments[1]:{};if(t==null||ma.isSsr)return{width:0,height:0};var n=sue(r),a=JSON.stringify({text:t,copyStyle:n});if(cl.widthCache[a])return cl.widthCache[a];try{var s=document.getElementById(QC);s||(s=document.createElement("span"),s.setAttribute("id",QC),s.setAttribute("aria-hidden","true"),document.body.appendChild(s));var o=Ej(Ej({},iue),n);Object.assign(s.style,o),s.textContent="".concat(t);var l=s.getBoundingClientRect(),c={width:l.width,height:l.height};return cl.widthCache[a]=c,++cl.cacheCount>aue&&(cl.cacheCount=0,cl.widthCache={}),c}catch{return{width:0,height:0}}},oue=function(t){return{top:t.top+window.scrollY-document.documentElement.clientTop,left:t.left+window.scrollX-document.documentElement.clientLeft}};function af(e){"@babel/helpers - typeof";return af=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},af(e)}function Qm(e,t){return due(e)||uue(e,t)||cue(e,t)||lue()}function lue(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function cue(e,t){if(e){if(typeof e=="string")return XC(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return XC(e,t)}}function XC(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Oue(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function n2(e,t){return Eue(e)||Cue(e,t)||Aue(e,t)||Pue()}function Pue(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Aue(e,t){if(e){if(typeof e=="string")return a2(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return a2(e,t)}}function a2(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&arguments[0]!==void 0?arguments[0]:[];return R.reduce(function($,I){var E=I.word,F=I.width,V=$[$.length-1];if(V&&(a==null||s||V.width+F+nI.width?$:I})};if(!f)return p;for(var v="…",m=function(R){var $=d.slice(0,R),I=uF({breakAll:u,style:c,children:$+v}).wordsWithComputedWidth,E=h(I),F=E.length>o||y(E).width>Number(a);return[F,E]},x=0,g=d.length-1,b=0,N;x<=g&&b<=d.length-1;){var w=Math.floor((x+g)/2),S=w-1,O=m(S),P=n2(O,2),A=P[0],C=P[1],T=m(w),D=n2(T,1),_=D[0];if(!A&&!_&&(x=w+1),A&&_&&(g=w-1),!A&&_){N=C;break}b++}return N||p},i2=function(t){var r=Ee(t)?[]:t.toString().split(cF);return[{words:r}]},kue=function(t){var r=t.width,n=t.scaleToFit,a=t.children,s=t.style,o=t.breakAll,l=t.maxLines;if((r||n)&&!ma.isSsr){var c,u,f=uF({breakAll:o,children:a,style:s});if(f){var d=f.wordsWithComputedWidth,h=f.spaceWidth;c=d,u=h}else return i2(a);return Tue({breakAll:o,children:a,maxLines:l,style:s},c,u,r,n)}return i2(a)},s2="#808080",Vo=function(t){var r=t.x,n=r===void 0?0:r,a=t.y,s=a===void 0?0:a,o=t.lineHeight,l=o===void 0?"1em":o,c=t.capHeight,u=c===void 0?"0.71em":c,f=t.scaleToFit,d=f===void 0?!1:f,h=t.textAnchor,p=h===void 0?"start":h,y=t.verticalAnchor,v=y===void 0?"end":y,m=t.fill,x=m===void 0?s2:m,g=r2(t,Nue),b=j.useMemo(function(){return kue({breakAll:g.breakAll,children:g.children,maxLines:g.maxLines,scaleToFit:d,style:g.style,width:g.width})},[g.breakAll,g.children,g.maxLines,d,g.style,g.width]),N=g.dx,w=g.dy,S=g.angle,O=g.className,P=g.breakAll,A=r2(g,Sue);if(!Zt(n)||!Zt(s))return null;var C=n+(se(N)?N:0),T=s+(se(w)?w:0),D;switch(v){case"start":D=Qx("calc(".concat(u,")"));break;case"middle":D=Qx("calc(".concat((b.length-1)/2," * -").concat(l," + (").concat(u," / 2))"));break;default:D=Qx("calc(".concat(b.length-1," * -").concat(l,")"));break}var _=[];if(d){var k=b[0].width,R=g.width;_.push("scale(".concat((se(R)?R/k:1)/k,")"))}return S&&_.push("rotate(".concat(S,", ").concat(C,", ").concat(T,")")),_.length&&(A.transform=_.join(" ")),M.createElement("text",Tj({},xe(A,!0),{x:C,y:T,className:Me("recharts-text",O),textAnchor:p,fill:x.includes("url")?s2:x}),b.map(function($,I){var E=$.words.join(P?"":" ");return M.createElement("tspan",{x:C,dy:I===0?D:l,key:"".concat(E,"-").concat(I)},E)}))};function ys(e,t){return e==null||t==null?NaN:et?1:e>=t?0:NaN}function _ue(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}function cS(e){let t,r,n;e.length!==2?(t=ys,r=(l,c)=>ys(e(l),c),n=(l,c)=>e(l)-c):(t=e===ys||e===_ue?e:Due,r=e,n=e);function a(l,c,u=0,f=l.length){if(u>>1;r(l[d],c)<0?u=d+1:f=d}while(u>>1;r(l[d],c)<=0?u=d+1:f=d}while(uu&&n(l[d-1],c)>-n(l[d],c)?d-1:d}return{left:a,center:o,right:s}}function Due(){return 0}function dF(e){return e===null?NaN:+e}function*Mue(e,t){for(let r of e)r!=null&&(r=+r)>=r&&(yield r)}const Iue=cS(ys),yh=Iue.right;cS(dF).center;class o2 extends Map{constructor(t,r=Lue){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:r}}),t!=null)for(const[n,a]of t)this.set(n,a)}get(t){return super.get(l2(this,t))}has(t){return super.has(l2(this,t))}set(t,r){return super.set(Rue(this,t),r)}delete(t){return super.delete($ue(this,t))}}function l2({_intern:e,_key:t},r){const n=t(r);return e.has(n)?e.get(n):r}function Rue({_intern:e,_key:t},r){const n=t(r);return e.has(n)?e.get(n):(e.set(n,r),r)}function $ue({_intern:e,_key:t},r){const n=t(r);return e.has(n)&&(r=e.get(n),e.delete(n)),r}function Lue(e){return e!==null&&typeof e=="object"?e.valueOf():e}function Fue(e=ys){if(e===ys)return fF;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 fF(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(et?1:0)}const Bue=Math.sqrt(50),Uue=Math.sqrt(10),zue=Math.sqrt(2);function Xm(e,t,r){const n=(t-e)/Math.max(0,r),a=Math.floor(Math.log10(n)),s=n/Math.pow(10,a),o=s>=Bue?10:s>=Uue?5:s>=zue?2:1;let l,c,u;return a<0?(u=Math.pow(10,-a)/o,l=Math.round(e*u),c=Math.round(t*u),l/ut&&--c,u=-u):(u=Math.pow(10,a)*o,l=Math.round(e/u),c=Math.round(t/u),l*ut&&--c),c0))return[];if(e===t)return[e];const n=t=a))return[];const l=s-a+1,c=new Array(l);if(n)if(o<0)for(let u=0;u=n)&&(r=n);return r}function u2(e,t){let r;for(const n of e)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function hF(e,t,r=0,n=1/0,a){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(a=a===void 0?fF:Fue(a);n>r;){if(n-r>600){const c=n-r+1,u=t-r+1,f=Math.log(c),d=.5*Math.exp(2*f/3),h=.5*Math.sqrt(f*d*(c-d)/c)*(u-c/2<0?-1:1),p=Math.max(r,Math.floor(t-u*d/c+h)),y=Math.min(n,Math.floor(t+(c-u)*d/c+h));hF(e,t,p,y,a)}const s=e[t];let o=r,l=n;for(Vu(e,r,t),a(e[n],s)>0&&Vu(e,r,n);o0;)--l}a(e[r],s)===0?Vu(e,r,l):(++l,Vu(e,l,n)),l<=t&&(r=l+1),t<=l&&(n=l-1)}return e}function Vu(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function Wue(e,t,r){if(e=Float64Array.from(Mue(e)),!(!(n=e.length)||isNaN(t=+t))){if(t<=0||n<2)return u2(e);if(t>=1)return c2(e);var n,a=(n-1)*t,s=Math.floor(a),o=c2(hF(e,s).subarray(0,s+1)),l=u2(e.subarray(s+1));return o+(l-o)*(a-s)}}function Hue(e,t,r=dF){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,a=(n-1)*t,s=Math.floor(a),o=+r(e[s],s,e),l=+r(e[s+1],s+1,e);return o+(l-o)*(a-s)}}function Vue(e,t,r){e=+e,t=+t,r=(a=arguments.length)<2?(t=e,e=0,1):a<3?1:+r;for(var n=-1,a=Math.max(0,Math.ceil((t-e)/r))|0,s=new Array(a);++n>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?vp(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===4?vp(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=Gue.exec(e))?new Gr(t[1],t[2],t[3],1):(t=Kue.exec(e))?new Gr(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Yue.exec(e))?vp(t[1],t[2],t[3],t[4]):(t=Que.exec(e))?vp(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Xue.exec(e))?g2(t[1],t[2]/100,t[3]/100,1):(t=Zue.exec(e))?g2(t[1],t[2]/100,t[3]/100,t[4]):d2.hasOwnProperty(e)?p2(d2[e]):e==="transparent"?new Gr(NaN,NaN,NaN,0):null}function p2(e){return new Gr(e>>16&255,e>>8&255,e&255,1)}function vp(e,t,r,n){return n<=0&&(e=t=r=NaN),new Gr(e,t,r,n)}function tde(e){return e instanceof xh||(e=cf(e)),e?(e=e.rgb(),new Gr(e.r,e.g,e.b,e.opacity)):new Gr}function Ij(e,t,r,n){return arguments.length===1?tde(e):new Gr(e,t,r,n??1)}function Gr(e,t,r,n){this.r=+e,this.g=+t,this.b=+r,this.opacity=+n}dS(Gr,Ij,mF(xh,{brighter(e){return e=e==null?Zm:Math.pow(Zm,e),new Gr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?of:Math.pow(of,e),new Gr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Gr(Oo(this.r),Oo(this.g),Oo(this.b),Jm(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:m2,formatHex:m2,formatHex8:rde,formatRgb:v2,toString:v2}));function m2(){return`#${co(this.r)}${co(this.g)}${co(this.b)}`}function rde(){return`#${co(this.r)}${co(this.g)}${co(this.b)}${co((isNaN(this.opacity)?1:this.opacity)*255)}`}function v2(){const e=Jm(this.opacity);return`${e===1?"rgb(":"rgba("}${Oo(this.r)}, ${Oo(this.g)}, ${Oo(this.b)}${e===1?")":`, ${e})`}`}function Jm(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Oo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function co(e){return e=Oo(e),(e<16?"0":"")+e.toString(16)}function g2(e,t,r,n){return n<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new oa(e,t,r,n)}function vF(e){if(e instanceof oa)return new oa(e.h,e.s,e.l,e.opacity);if(e instanceof xh||(e=cf(e)),!e)return new oa;if(e instanceof oa)return e;e=e.rgb();var t=e.r/255,r=e.g/255,n=e.b/255,a=Math.min(t,r,n),s=Math.max(t,r,n),o=NaN,l=s-a,c=(s+a)/2;return l?(t===s?o=(r-n)/l+(r0&&c<1?0:o,new oa(o,l,c,e.opacity)}function nde(e,t,r,n){return arguments.length===1?vF(e):new oa(e,t,r,n??1)}function oa(e,t,r,n){this.h=+e,this.s=+t,this.l=+r,this.opacity=+n}dS(oa,nde,mF(xh,{brighter(e){return e=e==null?Zm:Math.pow(Zm,e),new oa(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?of:Math.pow(of,e),new oa(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,a=2*r-n;return new Gr(Xx(e>=240?e-240:e+120,a,n),Xx(e,a,n),Xx(e<120?e+240:e-120,a,n),this.opacity)},clamp(){return new oa(y2(this.h),gp(this.s),gp(this.l),Jm(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=Jm(this.opacity);return`${e===1?"hsl(":"hsla("}${y2(this.h)}, ${gp(this.s)*100}%, ${gp(this.l)*100}%${e===1?")":`, ${e})`}`}}));function y2(e){return e=(e||0)%360,e<0?e+360:e}function gp(e){return Math.max(0,Math.min(1,e||0))}function Xx(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 fS=e=>()=>e;function ade(e,t){return function(r){return e+r*t}}function ide(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 sde(e){return(e=+e)==1?gF:function(t,r){return r-t?ide(t,r,e):fS(isNaN(t)?r:t)}}function gF(e,t){var r=t-e;return r?ade(e,r):fS(isNaN(e)?t:e)}const x2=function e(t){var r=sde(t);function n(a,s){var o=r((a=Ij(a)).r,(s=Ij(s)).r),l=r(a.g,s.g),c=r(a.b,s.b),u=gF(a.opacity,s.opacity);return function(f){return a.r=o(f),a.g=l(f),a.b=c(f),a.opacity=u(f),a+""}}return n.gamma=e,n}(1);function ode(e,t){t||(t=[]);var r=e?Math.min(t.length,e.length):0,n=t.slice(),a;return function(s){for(a=0;ar&&(s=t.slice(r,s),l[o]?l[o]+=s:l[++o]=s),(n=n[0])===(a=a[0])?l[o]?l[o]+=a:l[++o]=a:(l[++o]=null,c.push({i:o,x:ev(n,a)})),r=Zx.lastIndex;return rt&&(r=e,e=t,t=r),function(n){return Math.max(e,Math.min(t,n))}}function yde(e,t,r){var n=e[0],a=e[1],s=t[0],o=t[1];return a2?xde:yde,c=u=null,d}function d(h){return h==null||isNaN(h=+h)?s:(c||(c=l(e.map(n),t,r)))(n(o(h)))}return d.invert=function(h){return o(a((u||(u=l(t,e.map(n),ev)))(h)))},d.domain=function(h){return arguments.length?(e=Array.from(h,tv),f()):e.slice()},d.range=function(h){return arguments.length?(t=Array.from(h),f()):t.slice()},d.rangeRound=function(h){return t=Array.from(h),r=hS,f()},d.clamp=function(h){return arguments.length?(o=h?!0:kr,f()):o!==kr},d.interpolate=function(h){return arguments.length?(r=h,f()):r},d.unknown=function(h){return arguments.length?(s=h,d):s},function(h,p){return n=h,a=p,f()}}function pS(){return Qg()(kr,kr)}function bde(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function rv(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 Tc(e){return e=rv(Math.abs(e)),e?e[1]:NaN}function jde(e,t){return function(r,n){for(var a=r.length,s=[],o=0,l=e[0],c=0;a>0&&l>0&&(c+l+1>n&&(l=Math.max(1,n-c)),s.push(r.substring(a-=l,a+l)),!((c+=l+1)>n));)l=e[o=(o+1)%e.length];return s.reverse().join(t)}}function wde(e){return function(t){return t.replace(/[0-9]/g,function(r){return e[+r]})}}var Nde=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function uf(e){if(!(t=Nde.exec(e)))throw new Error("invalid format: "+e);var t;return new mS({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]})}uf.prototype=mS.prototype;function mS(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+""}mS.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 Sde(e){e:for(var t=e.length,r=1,n=-1,a;r0&&(n=0);break}return n>0?e.slice(0,n)+e.slice(a+1):e}var yF;function Ode(e,t){var r=rv(e,t);if(!r)return e+"";var n=r[0],a=r[1],s=a-(yF=Math.max(-8,Math.min(8,Math.floor(a/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")+rv(e,Math.max(0,t+s-1))[0]}function j2(e,t){var r=rv(e,t);if(!r)return e+"";var n=r[0],a=r[1];return a<0?"0."+new Array(-a).join("0")+n:n.length>a+1?n.slice(0,a+1)+"."+n.slice(a+1):n+new Array(a-n.length+2).join("0")}const w2={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:bde,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)=>j2(e*100,t),r:j2,s:Ode,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function N2(e){return e}var S2=Array.prototype.map,O2=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Pde(e){var t=e.grouping===void 0||e.thousands===void 0?N2:jde(S2.call(e.grouping,Number),e.thousands+""),r=e.currency===void 0?"":e.currency[0]+"",n=e.currency===void 0?"":e.currency[1]+"",a=e.decimal===void 0?".":e.decimal+"",s=e.numerals===void 0?N2:wde(S2.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 u(d){d=uf(d);var h=d.fill,p=d.align,y=d.sign,v=d.symbol,m=d.zero,x=d.width,g=d.comma,b=d.precision,N=d.trim,w=d.type;w==="n"?(g=!0,w="g"):w2[w]||(b===void 0&&(b=12),N=!0,w="g"),(m||h==="0"&&p==="=")&&(m=!0,h="0",p="=");var S=v==="$"?r:v==="#"&&/[boxX]/.test(w)?"0"+w.toLowerCase():"",O=v==="$"?n:/[%p]/.test(w)?o:"",P=w2[w],A=/[defgprs%]/.test(w);b=b===void 0?6:/[gprs]/.test(w)?Math.max(1,Math.min(21,b)):Math.max(0,Math.min(20,b));function C(T){var D=S,_=O,k,R,$;if(w==="c")_=P(T)+_,T="";else{T=+T;var I=T<0||1/T<0;if(T=isNaN(T)?c:P(Math.abs(T),b),N&&(T=Sde(T)),I&&+T==0&&y!=="+"&&(I=!1),D=(I?y==="("?y:l:y==="-"||y==="("?"":y)+D,_=(w==="s"?O2[8+yF/3]:"")+_+(I&&y==="("?")":""),A){for(k=-1,R=T.length;++k$||$>57){_=($===46?a+T.slice(k+1):T.slice(k))+_,T=T.slice(0,k);break}}}g&&!m&&(T=t(T,1/0));var E=D.length+T.length+_.length,F=E>1)+D+T+_+F.slice(E);break;default:T=F+D+T+_;break}return s(T)}return C.toString=function(){return d+""},C}function f(d,h){var p=u((d=uf(d),d.type="f",d)),y=Math.max(-8,Math.min(8,Math.floor(Tc(h)/3)))*3,v=Math.pow(10,-y),m=O2[8+y/3];return function(x){return p(v*x)+m}}return{format:u,formatPrefix:f}}var yp,vS,xF;Ade({thousands:",",grouping:[3],currency:["$",""]});function Ade(e){return yp=Pde(e),vS=yp.format,xF=yp.formatPrefix,yp}function Cde(e){return Math.max(0,-Tc(Math.abs(e)))}function Ede(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Tc(t)/3)))*3-Tc(Math.abs(e)))}function Tde(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,Tc(t)-Tc(e))+1}function bF(e,t,r,n){var a=Dj(e,t,r),s;switch(n=uf(n??",f"),n.type){case"s":{var o=Math.max(Math.abs(e),Math.abs(t));return n.precision==null&&!isNaN(s=Ede(a,o))&&(n.precision=s),xF(n,o)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(s=Tde(a,Math.max(Math.abs(e),Math.abs(t))))&&(n.precision=s-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(s=Cde(a))&&(n.precision=s-(n.type==="%")*2);break}}return vS(n)}function zs(e){var t=e.domain;return e.ticks=function(r){var n=t();return kj(n[0],n[n.length-1],r??10)},e.tickFormat=function(r,n){var a=t();return bF(a[0],a[a.length-1],r??10,n)},e.nice=function(r){r==null&&(r=10);var n=t(),a=0,s=n.length-1,o=n[a],l=n[s],c,u,f=10;for(l0;){if(u=_j(o,l,r),u===c)return n[a]=o,n[s]=l,t(n);if(u>0)o=Math.floor(o/u)*u,l=Math.ceil(l/u)*u;else if(u<0)o=Math.ceil(o*u)/u,l=Math.floor(l*u)/u;else break;c=u}return e},e}function nv(){var e=pS();return e.copy=function(){return bh(e,nv())},Kn.apply(e,arguments),zs(e)}function jF(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,tv),r):e.slice()},r.unknown=function(n){return arguments.length?(t=n,r):t},r.copy=function(){return jF(e).unknown(t)},e=arguments.length?Array.from(e,tv):[0,1],zs(r)}function wF(e,t){e=e.slice();var r=0,n=e.length-1,a=e[r],s=e[n],o;return sMath.pow(e,t)}function Ide(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 C2(e){return(t,r)=>-e(-t,r)}function gS(e){const t=e(P2,A2),r=t.domain;let n=10,a,s;function o(){return a=Ide(n),s=Mde(n),r()[0]<0?(a=C2(a),s=C2(s),e(kde,_de)):e(P2,A2),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 u=c[0],f=c[c.length-1];const d=f0){for(;h<=p;++h)for(y=1;yf)break;x.push(v)}}else for(;h<=p;++h)for(y=n-1;y>=1;--y)if(v=h>0?y/s(-h):y*s(h),!(vf)break;x.push(v)}x.length*2{if(l==null&&(l=10),c==null&&(c=n===10?"s":","),typeof c!="function"&&(!(n%1)&&(c=uf(c)).precision==null&&(c.trim=!0),c=vS(c)),l===1/0)return c;const u=Math.max(1,n*l/t.ticks().length);return f=>{let d=f/s(Math.round(a(f)));return d*nr(wF(r(),{floor:l=>s(Math.floor(a(l))),ceil:l=>s(Math.ceil(a(l)))})),t}function NF(){const e=gS(Qg()).domain([1,10]);return e.copy=()=>bh(e,NF()).base(e.base()),Kn.apply(e,arguments),e}function E2(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function T2(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function yS(e){var t=1,r=e(E2(t),T2(t));return r.constant=function(n){return arguments.length?e(E2(t=+n),T2(t)):t},zs(r)}function SF(){var e=yS(Qg());return e.copy=function(){return bh(e,SF()).constant(e.constant())},Kn.apply(e,arguments)}function k2(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function Rde(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function $de(e){return e<0?-e*e:e*e}function xS(e){var t=e(kr,kr),r=1;function n(){return r===1?e(kr,kr):r===.5?e(Rde,$de):e(k2(r),k2(1/r))}return t.exponent=function(a){return arguments.length?(r=+a,n()):r},zs(t)}function bS(){var e=xS(Qg());return e.copy=function(){return bh(e,bS()).exponent(e.exponent())},Kn.apply(e,arguments),e}function Lde(){return bS.apply(null,arguments).exponent(.5)}function _2(e){return Math.sign(e)*e*e}function Fde(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function OF(){var e=pS(),t=[0,1],r=!1,n;function a(s){var o=Fde(e(s));return isNaN(o)?n:r?Math.round(o):o}return a.invert=function(s){return e.invert(_2(s))},a.domain=function(s){return arguments.length?(e.domain(s),a):e.domain()},a.range=function(s){return arguments.length?(e.range((t=Array.from(s,tv)).map(_2)),a):t.slice()},a.rangeRound=function(s){return a.range(s).round(!0)},a.round=function(s){return arguments.length?(r=!!s,a):r},a.clamp=function(s){return arguments.length?(e.clamp(s),a):e.clamp()},a.unknown=function(s){return arguments.length?(n=s,a):n},a.copy=function(){return OF(e.domain(),t).round(r).clamp(e.clamp()).unknown(n)},Kn.apply(a,arguments),zs(a)}function PF(){var e=[],t=[],r=[],n;function a(){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[u-1],n[u]]},o.unknown=function(c){return arguments.length&&(s=c),o},o.thresholds=function(){return n.slice()},o.copy=function(){return AF().domain([e,t]).range(a).unknown(s)},Kn.apply(zs(o),arguments)}function CF(){var e=[.5],t=[0,1],r,n=1;function a(s){return s!=null&&s<=s?t[yh(e,s,0,n)]:r}return a.domain=function(s){return arguments.length?(e=Array.from(s),n=Math.min(e.length,t.length-1),a):e.slice()},a.range=function(s){return arguments.length?(t=Array.from(s),n=Math.min(e.length,t.length-1),a):t.slice()},a.invertExtent=function(s){var o=t.indexOf(s);return[e[o-1],e[o]]},a.unknown=function(s){return arguments.length?(r=s,a):r},a.copy=function(){return CF().domain(e).range(t).unknown(r)},Kn.apply(a,arguments)}const Jx=new Date,e0=new Date;function er(e,t,r,n){function a(s){return e(s=arguments.length===0?new Date:new Date(+s)),s}return a.floor=s=>(e(s=new Date(+s)),s),a.ceil=s=>(e(s=new Date(s-1)),t(s,1),e(s),s),a.round=s=>{const o=a(s),l=a.ceil(s);return s-o(t(s=new Date(+s),o==null?1:Math.floor(o)),s),a.range=(s,o,l)=>{const c=[];if(s=a.ceil(s),l=l==null?1:Math.floor(l),!(s0))return c;let u;do c.push(u=new Date(+s)),t(s,l),e(s);while(uer(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&&(a.count=(s,o)=>(Jx.setTime(+s),e0.setTime(+o),e(Jx),e(e0),Math.floor(r(Jx,e0))),a.every=s=>(s=Math.floor(s),!isFinite(s)||!(s>0)?null:s>1?a.filter(n?o=>n(o)%s===0:o=>a.count(0,o)%s===0):a)),a}const av=er(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);av.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?er(t=>{t.setTime(Math.floor(t/e)*e)},(t,r)=>{t.setTime(+t+r*e)},(t,r)=>(r-t)/e):av);av.range;const fi=1e3,In=fi*60,hi=In*60,Ci=hi*24,jS=Ci*7,D2=Ci*30,t0=Ci*365,uo=er(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*fi)},(e,t)=>(t-e)/fi,e=>e.getUTCSeconds());uo.range;const wS=er(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*fi)},(e,t)=>{e.setTime(+e+t*In)},(e,t)=>(t-e)/In,e=>e.getMinutes());wS.range;const NS=er(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*In)},(e,t)=>(t-e)/In,e=>e.getUTCMinutes());NS.range;const SS=er(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*fi-e.getMinutes()*In)},(e,t)=>{e.setTime(+e+t*hi)},(e,t)=>(t-e)/hi,e=>e.getHours());SS.range;const OS=er(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*hi)},(e,t)=>(t-e)/hi,e=>e.getUTCHours());OS.range;const jh=er(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*In)/Ci,e=>e.getDate()-1);jh.range;const Xg=er(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Ci,e=>e.getUTCDate()-1);Xg.range;const EF=er(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Ci,e=>Math.floor(e/Ci));EF.range;function el(e){return er(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())*In)/jS)}const Zg=el(0),iv=el(1),Bde=el(2),Ude=el(3),kc=el(4),zde=el(5),Wde=el(6);Zg.range;iv.range;Bde.range;Ude.range;kc.range;zde.range;Wde.range;function tl(e){return er(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)/jS)}const Jg=tl(0),sv=tl(1),Hde=tl(2),Vde=tl(3),_c=tl(4),qde=tl(5),Gde=tl(6);Jg.range;sv.range;Hde.range;Vde.range;_c.range;qde.range;Gde.range;const PS=er(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());PS.range;const AS=er(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());AS.range;const Ei=er(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());Ei.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:er(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)});Ei.range;const Ti=er(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());Ti.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:er(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)});Ti.range;function TF(e,t,r,n,a,s){const o=[[uo,1,fi],[uo,5,5*fi],[uo,15,15*fi],[uo,30,30*fi],[s,1,In],[s,5,5*In],[s,15,15*In],[s,30,30*In],[a,1,hi],[a,3,3*hi],[a,6,6*hi],[a,12,12*hi],[n,1,Ci],[n,2,2*Ci],[r,1,jS],[t,1,D2],[t,3,3*D2],[e,1,t0]];function l(u,f,d){const h=fm).right(o,h);if(p===o.length)return e.every(Dj(u/t0,f/t0,d));if(p===0)return av.every(Math.max(Dj(u,f,d),1));const[y,v]=o[h/o[p-1][2]53)return null;"w"in L||(L.w=1),"Z"in L?(ye=n0(qu(L.y,0,1)),We=ye.getUTCDay(),ye=We>4||We===0?sv.ceil(ye):sv(ye),ye=Xg.offset(ye,(L.V-1)*7),L.y=ye.getUTCFullYear(),L.m=ye.getUTCMonth(),L.d=ye.getUTCDate()+(L.w+6)%7):(ye=r0(qu(L.y,0,1)),We=ye.getDay(),ye=We>4||We===0?iv.ceil(ye):iv(ye),ye=jh.offset(ye,(L.V-1)*7),L.y=ye.getFullYear(),L.m=ye.getMonth(),L.d=ye.getDate()+(L.w+6)%7)}else("W"in L||"U"in L)&&("w"in L||(L.w="u"in L?L.u%7:"W"in L?1:0),We="Z"in L?n0(qu(L.y,0,1)).getUTCDay():r0(qu(L.y,0,1)).getDay(),L.m=0,L.d="W"in L?(L.w+6)%7+L.W*7-(We+5)%7:L.w+L.U*7-(We+6)%7);return"Z"in L?(L.H+=L.Z/100|0,L.M+=L.Z%100,n0(L)):r0(L)}}function P(re,Y,Z,L){for(var ce=0,ye=Y.length,We=Z.length,Je,ht;ce=We)return-1;if(Je=Y.charCodeAt(ce++),Je===37){if(Je=Y.charAt(ce++),ht=w[Je in M2?Y.charAt(ce++):Je],!ht||(L=ht(re,Z,L))<0)return-1}else if(Je!=Z.charCodeAt(L++))return-1}return L}function A(re,Y,Z){var L=u.exec(Y.slice(Z));return L?(re.p=f.get(L[0].toLowerCase()),Z+L[0].length):-1}function C(re,Y,Z){var L=p.exec(Y.slice(Z));return L?(re.w=y.get(L[0].toLowerCase()),Z+L[0].length):-1}function T(re,Y,Z){var L=d.exec(Y.slice(Z));return L?(re.w=h.get(L[0].toLowerCase()),Z+L[0].length):-1}function D(re,Y,Z){var L=x.exec(Y.slice(Z));return L?(re.m=g.get(L[0].toLowerCase()),Z+L[0].length):-1}function _(re,Y,Z){var L=v.exec(Y.slice(Z));return L?(re.m=m.get(L[0].toLowerCase()),Z+L[0].length):-1}function k(re,Y,Z){return P(re,t,Y,Z)}function R(re,Y,Z){return P(re,r,Y,Z)}function $(re,Y,Z){return P(re,n,Y,Z)}function I(re){return o[re.getDay()]}function E(re){return s[re.getDay()]}function F(re){return c[re.getMonth()]}function V(re){return l[re.getMonth()]}function G(re){return a[+(re.getHours()>=12)]}function K(re){return 1+~~(re.getMonth()/3)}function q(re){return o[re.getUTCDay()]}function ne(re){return s[re.getUTCDay()]}function le(re){return c[re.getUTCMonth()]}function de(re){return l[re.getUTCMonth()]}function ie(re){return a[+(re.getUTCHours()>=12)]}function ve(re){return 1+~~(re.getUTCMonth()/3)}return{format:function(re){var Y=S(re+="",b);return Y.toString=function(){return re},Y},parse:function(re){var Y=O(re+="",!1);return Y.toString=function(){return re},Y},utcFormat:function(re){var Y=S(re+="",N);return Y.toString=function(){return re},Y},utcParse:function(re){var Y=O(re+="",!0);return Y.toString=function(){return re},Y}}}var M2={"-":"",_:" ",0:"0"},lr=/^\s*\d+/,Jde=/^%/,efe=/[\\^$*+?|[\]().{}]/g;function Ze(e,t,r){var n=e<0?"-":"",a=(n?-e:e)+"",s=a.length;return n+(s[t.toLowerCase(),r]))}function rfe(e,t,r){var n=lr.exec(t.slice(r,r+1));return n?(e.w=+n[0],r+n[0].length):-1}function nfe(e,t,r){var n=lr.exec(t.slice(r,r+1));return n?(e.u=+n[0],r+n[0].length):-1}function afe(e,t,r){var n=lr.exec(t.slice(r,r+2));return n?(e.U=+n[0],r+n[0].length):-1}function ife(e,t,r){var n=lr.exec(t.slice(r,r+2));return n?(e.V=+n[0],r+n[0].length):-1}function sfe(e,t,r){var n=lr.exec(t.slice(r,r+2));return n?(e.W=+n[0],r+n[0].length):-1}function I2(e,t,r){var n=lr.exec(t.slice(r,r+4));return n?(e.y=+n[0],r+n[0].length):-1}function R2(e,t,r){var n=lr.exec(t.slice(r,r+2));return n?(e.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function ofe(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 lfe(e,t,r){var n=lr.exec(t.slice(r,r+1));return n?(e.q=n[0]*3-3,r+n[0].length):-1}function cfe(e,t,r){var n=lr.exec(t.slice(r,r+2));return n?(e.m=n[0]-1,r+n[0].length):-1}function $2(e,t,r){var n=lr.exec(t.slice(r,r+2));return n?(e.d=+n[0],r+n[0].length):-1}function ufe(e,t,r){var n=lr.exec(t.slice(r,r+3));return n?(e.m=0,e.d=+n[0],r+n[0].length):-1}function L2(e,t,r){var n=lr.exec(t.slice(r,r+2));return n?(e.H=+n[0],r+n[0].length):-1}function dfe(e,t,r){var n=lr.exec(t.slice(r,r+2));return n?(e.M=+n[0],r+n[0].length):-1}function ffe(e,t,r){var n=lr.exec(t.slice(r,r+2));return n?(e.S=+n[0],r+n[0].length):-1}function hfe(e,t,r){var n=lr.exec(t.slice(r,r+3));return n?(e.L=+n[0],r+n[0].length):-1}function pfe(e,t,r){var n=lr.exec(t.slice(r,r+6));return n?(e.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function mfe(e,t,r){var n=Jde.exec(t.slice(r,r+1));return n?r+n[0].length:-1}function vfe(e,t,r){var n=lr.exec(t.slice(r));return n?(e.Q=+n[0],r+n[0].length):-1}function gfe(e,t,r){var n=lr.exec(t.slice(r));return n?(e.s=+n[0],r+n[0].length):-1}function F2(e,t){return Ze(e.getDate(),t,2)}function yfe(e,t){return Ze(e.getHours(),t,2)}function xfe(e,t){return Ze(e.getHours()%12||12,t,2)}function bfe(e,t){return Ze(1+jh.count(Ei(e),e),t,3)}function kF(e,t){return Ze(e.getMilliseconds(),t,3)}function jfe(e,t){return kF(e,t)+"000"}function wfe(e,t){return Ze(e.getMonth()+1,t,2)}function Nfe(e,t){return Ze(e.getMinutes(),t,2)}function Sfe(e,t){return Ze(e.getSeconds(),t,2)}function Ofe(e){var t=e.getDay();return t===0?7:t}function Pfe(e,t){return Ze(Zg.count(Ei(e)-1,e),t,2)}function _F(e){var t=e.getDay();return t>=4||t===0?kc(e):kc.ceil(e)}function Afe(e,t){return e=_F(e),Ze(kc.count(Ei(e),e)+(Ei(e).getDay()===4),t,2)}function Cfe(e){return e.getDay()}function Efe(e,t){return Ze(iv.count(Ei(e)-1,e),t,2)}function Tfe(e,t){return Ze(e.getFullYear()%100,t,2)}function kfe(e,t){return e=_F(e),Ze(e.getFullYear()%100,t,2)}function _fe(e,t){return Ze(e.getFullYear()%1e4,t,4)}function Dfe(e,t){var r=e.getDay();return e=r>=4||r===0?kc(e):kc.ceil(e),Ze(e.getFullYear()%1e4,t,4)}function Mfe(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+Ze(t/60|0,"0",2)+Ze(t%60,"0",2)}function B2(e,t){return Ze(e.getUTCDate(),t,2)}function Ife(e,t){return Ze(e.getUTCHours(),t,2)}function Rfe(e,t){return Ze(e.getUTCHours()%12||12,t,2)}function $fe(e,t){return Ze(1+Xg.count(Ti(e),e),t,3)}function DF(e,t){return Ze(e.getUTCMilliseconds(),t,3)}function Lfe(e,t){return DF(e,t)+"000"}function Ffe(e,t){return Ze(e.getUTCMonth()+1,t,2)}function Bfe(e,t){return Ze(e.getUTCMinutes(),t,2)}function Ufe(e,t){return Ze(e.getUTCSeconds(),t,2)}function zfe(e){var t=e.getUTCDay();return t===0?7:t}function Wfe(e,t){return Ze(Jg.count(Ti(e)-1,e),t,2)}function MF(e){var t=e.getUTCDay();return t>=4||t===0?_c(e):_c.ceil(e)}function Hfe(e,t){return e=MF(e),Ze(_c.count(Ti(e),e)+(Ti(e).getUTCDay()===4),t,2)}function Vfe(e){return e.getUTCDay()}function qfe(e,t){return Ze(sv.count(Ti(e)-1,e),t,2)}function Gfe(e,t){return Ze(e.getUTCFullYear()%100,t,2)}function Kfe(e,t){return e=MF(e),Ze(e.getUTCFullYear()%100,t,2)}function Yfe(e,t){return Ze(e.getUTCFullYear()%1e4,t,4)}function Qfe(e,t){var r=e.getUTCDay();return e=r>=4||r===0?_c(e):_c.ceil(e),Ze(e.getUTCFullYear()%1e4,t,4)}function Xfe(){return"+0000"}function U2(){return"%"}function z2(e){return+e}function W2(e){return Math.floor(+e/1e3)}var ul,IF,RF;Zfe({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 Zfe(e){return ul=Zde(e),IF=ul.format,ul.parse,RF=ul.utcFormat,ul.utcParse,ul}function Jfe(e){return new Date(e)}function ehe(e){return e instanceof Date?+e:+new Date(+e)}function CS(e,t,r,n,a,s,o,l,c,u){var f=pS(),d=f.invert,h=f.domain,p=u(".%L"),y=u(":%S"),v=u("%I:%M"),m=u("%I %p"),x=u("%a %d"),g=u("%b %d"),b=u("%B"),N=u("%Y");function w(S){return(c(S)t(a/(e.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(a,s)=>Wue(e,s/n))},r.copy=function(){return BF(t).domain(e)},Ii.apply(r,arguments)}function ty(){var e=0,t=.5,r=1,n=1,a,s,o,l,c,u=kr,f,d=!1,h;function p(v){return isNaN(v=+v)?h:(v=.5+((v=+f(v))-s)*(n*vt}var HF=ohe,lhe=ry,che=HF,uhe=bu;function dhe(e){return e&&e.length?lhe(e,uhe,che):void 0}var fhe=dhe;const os=et(fhe);function hhe(e,t){return ee.e^s.s<0?1:-1;for(n=s.d.length,a=e.d.length,t=0,r=ne.d[t]^s.s<0?1:-1;return n===a?0:n>a^s.s<0?1:-1};me.decimalPlaces=me.dp=function(){var e=this,t=e.d.length-1,r=(t-e.e)*wt;if(t=e.d[t],t)for(;t%10==0;t/=10)r--;return r<0?0:r};me.dividedBy=me.div=function(e){return xi(this,new this.constructor(e))};me.dividedToIntegerBy=me.idiv=function(e){var t=this,r=t.constructor;return dt(xi(t,new r(e),0,1),r.precision)};me.equals=me.eq=function(e){return!this.cmp(e)};me.exponent=function(){return Wt(this)};me.greaterThan=me.gt=function(e){return this.cmp(e)>0};me.greaterThanOrEqualTo=me.gte=function(e){return this.cmp(e)>=0};me.isInteger=me.isint=function(){return this.e>this.d.length-2};me.isNegative=me.isneg=function(){return this.s<0};me.isPositive=me.ispos=function(){return this.s>0};me.isZero=function(){return this.s===0};me.lessThan=me.lt=function(e){return this.cmp(e)<0};me.lessThanOrEqualTo=me.lte=function(e){return this.cmp(e)<1};me.logarithm=me.log=function(e){var t,r=this,n=r.constructor,a=n.precision,s=a+5;if(e===void 0)e=new n(10);else if(e=new n(e),e.s<1||e.eq(ln))throw Error(Vn+"NaN");if(r.s<1)throw Error(Vn+(r.s?"NaN":"-Infinity"));return r.eq(ln)?new n(0):(Pt=!1,t=xi(df(r,s),df(e,s),s),Pt=!0,dt(t,a))};me.minus=me.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?YF(t,e):GF(t,(e.s=-e.s,e))};me.modulo=me.mod=function(e){var t,r=this,n=r.constructor,a=n.precision;if(e=new n(e),!e.s)throw Error(Vn+"NaN");return r.s?(Pt=!1,t=xi(r,e,0,1).times(e),Pt=!0,r.minus(t)):dt(new n(r),a)};me.naturalExponential=me.exp=function(){return KF(this)};me.naturalLogarithm=me.ln=function(){return df(this)};me.negated=me.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e};me.plus=me.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?GF(t,e):YF(t,(e.s=-e.s,e))};me.precision=me.sd=function(e){var t,r,n,a=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Po+e);if(t=Wt(a)+1,n=a.d.length-1,r=n*wt+1,n=a.d[n],n){for(;n%10==0;n/=10)r--;for(n=a.d[0];n>=10;n/=10)r++}return e&&t>r?t:r};me.squareRoot=me.sqrt=function(){var e,t,r,n,a,s,o,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(Vn+"NaN")}for(e=Wt(l),Pt=!1,a=Math.sqrt(+l),a==0||a==1/0?(t=$a(l.d),(t.length+e)%2==0&&(t+="0"),a=Math.sqrt(t),e=Nu((e+1)/2)-(e<0||e%2),a==1/0?t="5e"+e:(t=a.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),n=new c(t)):n=new c(a.toString()),r=c.precision,a=o=r+3;;)if(s=n,n=s.plus(xi(l,s,o+2)).times(.5),$a(s.d).slice(0,o)===(t=$a(n.d)).slice(0,o)){if(t=t.slice(o-3,o+1),a==o&&t=="4999"){if(dt(s,r+1,0),s.times(s).eq(l)){n=s;break}}else if(t!="9999")break;o+=4}return Pt=!0,dt(n,r)};me.times=me.mul=function(e){var t,r,n,a,s,o,l,c,u,f=this,d=f.constructor,h=f.d,p=(e=new d(e)).d;if(!f.s||!e.s)return new d(0);for(e.s*=f.s,r=f.e+e.e,c=h.length,u=p.length,c=0;){for(t=0,a=c+n;a>n;)l=s[a]+p[n]*h[a-n-1]+t,s[a--]=l%tr|0,t=l/tr|0;s[a]=(s[a]+t)%tr|0}for(;!s[--o];)s.pop();return t?++r:s.shift(),e.d=s,e.e=r,Pt?dt(e,d.precision):e};me.toDecimalPlaces=me.todp=function(e,t){var r=this,n=r.constructor;return r=new n(r),e===void 0?r:(Xa(e,0,wu),t===void 0?t=n.rounding:Xa(t,0,8),dt(r,e+Wt(r)+1,t))};me.toExponential=function(e,t){var r,n=this,a=n.constructor;return e===void 0?r=Go(n,!0):(Xa(e,0,wu),t===void 0?t=a.rounding:Xa(t,0,8),n=dt(new a(n),e+1,t),r=Go(n,!0,e+1)),r};me.toFixed=function(e,t){var r,n,a=this,s=a.constructor;return e===void 0?Go(a):(Xa(e,0,wu),t===void 0?t=s.rounding:Xa(t,0,8),n=dt(new s(a),e+Wt(a)+1,t),r=Go(n.abs(),!1,e+Wt(n)+1),a.isneg()&&!a.isZero()?"-"+r:r)};me.toInteger=me.toint=function(){var e=this,t=e.constructor;return dt(new t(e),Wt(e)+1,t.rounding)};me.toNumber=function(){return+this};me.toPower=me.pow=function(e){var t,r,n,a,s,o,l=this,c=l.constructor,u=12,f=+(e=new c(e));if(!e.s)return new c(ln);if(l=new c(l),!l.s){if(e.s<1)throw Error(Vn+"Infinity");return l}if(l.eq(ln))return l;if(n=c.precision,e.eq(ln))return dt(l,n);if(t=e.e,r=e.d.length-1,o=t>=r,s=l.s,o){if((r=f<0?-f:f)<=qF){for(a=new c(ln),t=Math.ceil(n/wt+4),Pt=!1;r%2&&(a=a.times(l),q2(a.d,t)),r=Nu(r/2),r!==0;)l=l.times(l),q2(l.d,t);return Pt=!0,e.s<0?new c(ln).div(a):dt(a,n)}}else if(s<0)throw Error(Vn+"NaN");return s=s<0&&e.d[Math.max(t,r)]&1?-1:1,l.s=1,Pt=!1,a=e.times(df(l,n+u)),Pt=!0,a=KF(a),a.s=s,a};me.toPrecision=function(e,t){var r,n,a=this,s=a.constructor;return e===void 0?(r=Wt(a),n=Go(a,r<=s.toExpNeg||r>=s.toExpPos)):(Xa(e,1,wu),t===void 0?t=s.rounding:Xa(t,0,8),a=dt(new s(a),e,t),r=Wt(a),n=Go(a,e<=r||r<=s.toExpNeg,e)),n};me.toSignificantDigits=me.tosd=function(e,t){var r=this,n=r.constructor;return e===void 0?(e=n.precision,t=n.rounding):(Xa(e,1,wu),t===void 0?t=n.rounding:Xa(t,0,8)),dt(new n(r),e,t)};me.toString=me.valueOf=me.val=me.toJSON=me[Symbol.for("nodejs.util.inspect.custom")]=function(){var e=this,t=Wt(e),r=e.constructor;return Go(e,t<=r.toExpNeg||t>=r.toExpPos)};function GF(e,t){var r,n,a,s,o,l,c,u,f=e.constructor,d=f.precision;if(!e.s||!t.s)return t.s||(t=new f(e)),Pt?dt(t,d):t;if(c=e.d,u=t.d,o=e.e,a=t.e,c=c.slice(),s=o-a,s){for(s<0?(n=c,s=-s,l=u.length):(n=u,a=o,l=c.length),o=Math.ceil(d/wt),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=u.length,l-s<0&&(s=l,n=u,u=c,c=n),r=0;s;)r=(c[--s]=c[s]+u[s]+r)/tr|0,c[s]%=tr;for(r&&(c.unshift(r),++a),l=c.length;c[--l]==0;)c.pop();return t.d=c,t.e=a,Pt?dt(t,d):t}function Xa(e,t,r){if(e!==~~e||er)throw Error(Po+e)}function $a(e){var t,r,n,a=e.length-1,s="",o=e[0];if(a>0){for(s+=o,t=1;to?1:-1;else for(l=c=0;la[l]?1:-1;break}return c}function r(n,a,s){for(var o=0;s--;)n[s]-=o,o=n[s]1;)n.shift()}return function(n,a,s,o){var l,c,u,f,d,h,p,y,v,m,x,g,b,N,w,S,O,P,A=n.constructor,C=n.s==a.s?1:-1,T=n.d,D=a.d;if(!n.s)return new A(n);if(!a.s)throw Error(Vn+"Division by zero");for(c=n.e-a.e,O=D.length,w=T.length,p=new A(C),y=p.d=[],u=0;D[u]==(T[u]||0);)++u;if(D[u]>(T[u]||0)&&--c,s==null?g=s=A.precision:o?g=s+(Wt(n)-Wt(a))+1:g=s,g<0)return new A(0);if(g=g/wt+2|0,u=0,O==1)for(f=0,D=D[0],g++;(u1&&(D=e(D,f),T=e(T,f),O=D.length,w=T.length),N=O,v=T.slice(0,O),m=v.length;m=tr/2&&++S;do f=0,l=t(D,v,O,m),l<0?(x=v[0],O!=m&&(x=x*tr+(v[1]||0)),f=x/S|0,f>1?(f>=tr&&(f=tr-1),d=e(D,f),h=d.length,m=v.length,l=t(d,v,h,m),l==1&&(f--,r(d,O16)throw Error(kS+Wt(e));if(!e.s)return new f(ln);for(t==null?(Pt=!1,l=d):l=t,o=new f(.03125);e.abs().gte(.1);)e=e.times(o),u+=5;for(n=Math.log(ro(2,u))/Math.LN10*2+5|0,l+=n,r=a=s=new f(ln),f.precision=l;;){if(a=dt(a.times(e),l),r=r.times(++c),o=s.plus(xi(a,r,l)),$a(o.d).slice(0,l)===$a(s.d).slice(0,l)){for(;u--;)s=dt(s.times(s),l);return f.precision=d,t==null?(Pt=!0,dt(s,d)):s}s=o}}function Wt(e){for(var t=e.e*wt,r=e.d[0];r>=10;r/=10)t++;return t}function a0(e,t,r){if(t>e.LN10.sd())throw Pt=!0,r&&(e.precision=r),Error(Vn+"LN10 precision limit exceeded");return dt(new e(e.LN10),t)}function qi(e){for(var t="";e--;)t+="0";return t}function df(e,t){var r,n,a,s,o,l,c,u,f,d=1,h=10,p=e,y=p.d,v=p.constructor,m=v.precision;if(p.s<1)throw Error(Vn+(p.s?"NaN":"-Infinity"));if(p.eq(ln))return new v(0);if(t==null?(Pt=!1,u=m):u=t,p.eq(10))return t==null&&(Pt=!0),a0(v,u);if(u+=h,v.precision=u,r=$a(y),n=r.charAt(0),s=Wt(p),Math.abs(s)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)p=p.times(e),r=$a(p.d),n=r.charAt(0),d++;s=Wt(p),n>1?(p=new v("0."+r),s++):p=new v(n+"."+r.slice(1))}else return c=a0(v,u+2,m).times(s+""),p=df(new v(n+"."+r.slice(1)),u-h).plus(c),v.precision=m,t==null?(Pt=!0,dt(p,m)):p;for(l=o=p=xi(p.minus(ln),p.plus(ln),u),f=dt(p.times(p),u),a=3;;){if(o=dt(o.times(f),u),c=l.plus(xi(o,new v(a),u)),$a(c.d).slice(0,u)===$a(l.d).slice(0,u))return l=l.times(2),s!==0&&(l=l.plus(a0(v,u+2,m).times(s+""))),l=xi(l,new v(d),u),v.precision=m,t==null?(Pt=!0,dt(l,m)):l;l=c,a+=2}}function V2(e,t){var r,n,a;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(a=t.length;t.charCodeAt(a-1)===48;)--a;if(t=t.slice(n,a),t){if(a-=n,r=r-n-1,e.e=Nu(r/wt),e.d=[],n=(r+1)%wt,r<0&&(n+=wt),nov||e.e<-ov))throw Error(kS+r)}else e.s=0,e.e=0,e.d=[0];return e}function dt(e,t,r){var n,a,s,o,l,c,u,f,d=e.d;for(o=1,s=d[0];s>=10;s/=10)o++;if(n=t-o,n<0)n+=wt,a=t,u=d[f=0];else{if(f=Math.ceil((n+1)/wt),s=d.length,f>=s)return e;for(u=s=d[f],o=1;s>=10;s/=10)o++;n%=wt,a=n-wt+o}if(r!==void 0&&(s=ro(10,o-a-1),l=u/s%10|0,c=t<0||d[f+1]!==void 0||u%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?a>0?u/ro(10,o-a):0:d[f-1])%10&1||r==(e.s<0?8:7))),t<1||!d[0])return c?(s=Wt(e),d.length=1,t=t-s-1,d[0]=ro(10,(wt-t%wt)%wt),e.e=Nu(-t/wt)||0):(d.length=1,d[0]=e.e=e.s=0),e;if(n==0?(d.length=f,s=1,f--):(d.length=f+1,s=ro(10,wt-n),d[f]=a>0?(u/ro(10,o-a)%ro(10,a)|0)*s:0),c)for(;;)if(f==0){(d[0]+=s)==tr&&(d[0]=1,++e.e);break}else{if(d[f]+=s,d[f]!=tr)break;d[f--]=0,s=1}for(n=d.length;d[--n]===0;)d.pop();if(Pt&&(e.e>ov||e.e<-ov))throw Error(kS+Wt(e));return e}function YF(e,t){var r,n,a,s,o,l,c,u,f,d,h=e.constructor,p=h.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new h(e),Pt?dt(t,p):t;if(c=e.d,d=t.d,n=t.e,u=e.e,c=c.slice(),o=u-n,o){for(f=o<0,f?(r=c,o=-o,l=d.length):(r=d,n=u,l=c.length),a=Math.max(Math.ceil(p/wt),l)+2,o>a&&(o=a,r.length=1),r.reverse(),a=o;a--;)r.push(0);r.reverse()}else{for(a=c.length,l=d.length,f=a0;--a)c[l++]=0;for(a=d.length;a>o;){if(c[--a]0?s=s.charAt(0)+"."+s.slice(1)+qi(n):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(a<0?"e":"e+")+a):a<0?(s="0."+qi(-a-1)+s,r&&(n=r-o)>0&&(s+=qi(n))):a>=o?(s+=qi(a+1-o),r&&(n=r-a-1)>0&&(s=s+"."+qi(n))):((n=a+1)0&&(a+1===o&&(s+="."),s+=qi(n))),e.s<0?"-"+s:s}function q2(e,t){if(e.length>t)return e.length=t,!0}function QF(e){var t,r,n;function a(s){var o=this;if(!(o instanceof a))return new a(s);if(o.constructor=a,s instanceof a){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(Po+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 V2(o,s.toString())}else if(typeof s!="string")throw Error(Po+s);if(s.charCodeAt(0)===45?(s=s.slice(1),o.s=-1):o.s=1,Mhe.test(s))V2(o,s);else throw Error(Po+s)}if(a.prototype=me,a.ROUND_UP=0,a.ROUND_DOWN=1,a.ROUND_CEIL=2,a.ROUND_FLOOR=3,a.ROUND_HALF_UP=4,a.ROUND_HALF_DOWN=5,a.ROUND_HALF_EVEN=6,a.ROUND_HALF_CEIL=7,a.ROUND_HALF_FLOOR=8,a.clone=QF,a.config=a.set=Ihe,e===void 0&&(e={}),e)for(n=["precision","rounding","toExpNeg","toExpPos","LN10"],t=0;t=a[t+1]&&n<=a[t+2])this[r]=n;else throw Error(Po+r+": "+n);if((n=e[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(Po+r+": "+n);return this}var _S=QF(Dhe);ln=new _S(1);const lt=_S;function Rhe(e){return Bhe(e)||Fhe(e)||Lhe(e)||$he()}function $he(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Lhe(e,t){if(e){if(typeof e=="string")return Lj(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Lj(e,t)}}function Fhe(e){if(typeof Symbol<"u"&&Symbol.iterator in Object(e))return Array.from(e)}function Bhe(e){if(Array.isArray(e))return Lj(e)}function Lj(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=t?r.apply(void 0,a):e(t-o,G2(function(){for(var l=arguments.length,c=new Array(l),u=0;ue.length)&&(t=e.length);for(var r=0,n=new Array(t);r"u"||!(Symbol.iterator in Object(e)))){var r=[],n=!0,a=!1,s=void 0;try{for(var o=e[Symbol.iterator](),l;!(n=(l=o.next()).done)&&(r.push(l.value),!(t&&r.length===t));n=!0);}catch(c){a=!0,s=c}finally{try{!n&&o.return!=null&&o.return()}finally{if(a)throw s}}return r}}function tpe(e){if(Array.isArray(e))return e}function t3(e){var t=ff(e,2),r=t[0],n=t[1],a=r,s=n;return r>n&&(a=n,s=r),[a,s]}function r3(e,t,r){if(e.lte(0))return new lt(0);var n=iy.getDigitCount(e.toNumber()),a=new lt(10).pow(n),s=e.div(a),o=n!==1?.05:.1,l=new lt(Math.ceil(s.div(o).toNumber())).add(r).mul(o),c=l.mul(a);return t?c:new lt(Math.ceil(c))}function rpe(e,t,r){var n=1,a=new lt(e);if(!a.isint()&&r){var s=Math.abs(e);s<1?(n=new lt(10).pow(iy.getDigitCount(e)-1),a=new lt(Math.floor(a.div(n).toNumber())).mul(n)):s>1&&(a=new lt(Math.floor(e)))}else e===0?a=new lt(Math.floor((t-1)/2)):r||(a=new lt(Math.floor(e)));var o=Math.floor((t-1)/2),l=Hhe(Whe(function(c){return a.add(new lt(c-o).mul(n)).toNumber()}),Fj);return l(0,t)}function n3(e,t,r,n){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((t-e)/(r-1)))return{step:new lt(0),tickMin:new lt(0),tickMax:new lt(0)};var s=r3(new lt(t).sub(e).div(r-1),n,a),o;e<=0&&t>=0?o=new lt(0):(o=new lt(e).add(t).div(2),o=o.sub(new lt(o).mod(s)));var l=Math.ceil(o.sub(e).div(s).toNumber()),c=Math.ceil(new lt(t).sub(o).div(s).toNumber()),u=l+c+1;return u>r?n3(e,t,r,n,a+1):(u0?c+(r-u):c,l=t>0?l:l+(r-u)),{step:s,tickMin:o.sub(new lt(l).mul(s)),tickMax:o.add(new lt(c).mul(s))})}function npe(e){var t=ff(e,2),r=t[0],n=t[1],a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=Math.max(a,2),l=t3([r,n]),c=ff(l,2),u=c[0],f=c[1];if(u===-1/0||f===1/0){var d=f===1/0?[u].concat(Uj(Fj(0,a-1).map(function(){return 1/0}))):[].concat(Uj(Fj(0,a-1).map(function(){return-1/0})),[f]);return r>n?Bj(d):d}if(u===f)return rpe(u,a,s);var h=n3(u,f,o,s),p=h.step,y=h.tickMin,v=h.tickMax,m=iy.rangeStep(y,v.add(new lt(.1).mul(p)),p);return r>n?Bj(m):m}function ape(e,t){var r=ff(e,2),n=r[0],a=r[1],s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=t3([n,a]),l=ff(o,2),c=l[0],u=l[1];if(c===-1/0||u===1/0)return[n,a];if(c===u)return[c];var f=Math.max(t,2),d=r3(new lt(u).sub(c).div(f-1),s,0),h=[].concat(Uj(iy.rangeStep(new lt(c),new lt(u).sub(new lt(.99).mul(d)),d)),[u]);return n>a?Bj(h):h}var ipe=JF(npe),spe=JF(ape),ope="Invariant failed";function ks(e,t){throw new Error(ope)}var lpe=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function Dc(e){"@babel/helpers - typeof";return Dc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Dc(e)}function lv(){return lv=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function mpe(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function vpe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function gpe(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0,o=-1,l=(r=n==null?void 0:n.length)!==null&&r!==void 0?r:0;if(l<=1)return 0;if(s&&s.axisType==="angleAxis"&&Math.abs(Math.abs(s.range[1]-s.range[0])-360)<=1e-6)for(var c=s.range,u=0;u0?a[u-1].coordinate:a[l-1].coordinate,d=a[u].coordinate,h=u>=l-1?a[0].coordinate:a[u+1].coordinate,p=void 0;if(Er(d-f)!==Er(h-d)){var y=[];if(Er(h-d)===Er(c[1]-c[0])){p=h;var v=d+c[1]-c[0];y[0]=Math.min(v,(v+f)/2),y[1]=Math.max(v,(v+f)/2)}else{p=f;var m=h+c[1]-c[0];y[0]=Math.min(d,(m+d)/2),y[1]=Math.max(d,(m+d)/2)}var x=[Math.min(d,(p+d)/2),Math.max(d,(p+d)/2)];if(t>x[0]&&t<=x[1]||t>=y[0]&&t<=y[1]){o=a[u].index;break}}else{var g=Math.min(f,h),b=Math.max(f,h);if(t>(g+d)/2&&t<=(b+d)/2){o=a[u].index;break}}}else for(var N=0;N0&&N(n[N].coordinate+n[N-1].coordinate)/2&&t<=(n[N].coordinate+n[N+1].coordinate)/2||N===l-1&&t>(n[N].coordinate+n[N-1].coordinate)/2){o=n[N].index;break}return o},DS=function(t){var r,n=t,a=n.type.displayName,s=(r=t.type)!==null&&r!==void 0&&r.defaultProps?Dt(Dt({},t.type.defaultProps),t.props):t.props,o=s.stroke,l=s.fill,c;switch(a){case"Line":c=o;break;case"Area":case"Radar":c=o&&o!=="none"?o:l;break;default:c=l;break}return c},Mpe=function(t){var r=t.barSize,n=t.totalSize,a=t.stackGroups,s=a===void 0?{}:a;if(!s)return{};for(var o={},l=Object.keys(s),c=0,u=l.length;c=0});if(x&&x.length){var g=x[0].type.defaultProps,b=g!==void 0?Dt(Dt({},g),x[0].props):x[0].props,N=b.barSize,w=b[m];o[w]||(o[w]=[]);var S=Ee(N)?r:N;o[w].push({item:x[0],stackList:x.slice(1),barSize:Ee(S)?void 0:Tr(S,n,0)})}}return o},Ipe=function(t){var r=t.barGap,n=t.barCategoryGap,a=t.bandSize,s=t.sizeList,o=s===void 0?[]:s,l=t.maxBarSize,c=o.length;if(c<1)return null;var u=Tr(r,a,0,!0),f,d=[];if(o[0].barSize===+o[0].barSize){var h=!1,p=a/c,y=o.reduce(function(N,w){return N+w.barSize||0},0);y+=(c-1)*u,y>=a&&(y-=(c-1)*u,u=0),y>=a&&p>0&&(h=!0,p*=.9,y=c*p);var v=(a-y)/2>>0,m={offset:v-u,size:0};f=o.reduce(function(N,w){var S={item:w.item,position:{offset:m.offset+m.size+u,size:h?p:w.barSize}},O=[].concat(Q2(N),[S]);return m=O[O.length-1].position,w.stackList&&w.stackList.length&&w.stackList.forEach(function(P){O.push({item:P,position:m})}),O},d)}else{var x=Tr(n,a,0,!0);a-2*x-(c-1)*u<=0&&(u=0);var g=(a-2*x-(c-1)*u)/c;g>1&&(g>>=0);var b=l===+l?Math.min(g,l):g;f=o.reduce(function(N,w,S){var O=[].concat(Q2(N),[{item:w.item,position:{offset:x+(g+u)*S+(g-b)/2,size:b}}]);return w.stackList&&w.stackList.length&&w.stackList.forEach(function(P){O.push({item:P,position:O[O.length-1].position})}),O},d)}return f},Rpe=function(t,r,n,a){var s=n.children,o=n.width,l=n.margin,c=o-(l.left||0)-(l.right||0),u=o3({children:s,legendWidth:c});if(u){var f=a||{},d=f.width,h=f.height,p=u.align,y=u.verticalAlign,v=u.layout;if((v==="vertical"||v==="horizontal"&&y==="middle")&&p!=="center"&&se(t[p]))return Dt(Dt({},t),{},Zl({},p,t[p]+(d||0)));if((v==="horizontal"||v==="vertical"&&p==="center")&&y!=="middle"&&se(t[y]))return Dt(Dt({},t),{},Zl({},y,t[y]+(h||0)))}return t},$pe=function(t,r,n){return Ee(r)?!0:t==="horizontal"?r==="yAxis":t==="vertical"||n==="x"?r==="xAxis":n==="y"?r==="yAxis":!0},l3=function(t,r,n,a,s){var o=r.props.children,l=mn(o,wh).filter(function(u){return $pe(a,s,u.props.direction)});if(l&&l.length){var c=l.map(function(u){return u.props.dataKey});return t.reduce(function(u,f){var d=It(f,n);if(Ee(d))return u;var h=Array.isArray(d)?[ny(d),os(d)]:[d,d],p=c.reduce(function(y,v){var m=It(f,v,0),x=h[0]-Math.abs(Array.isArray(m)?m[0]:m),g=h[1]+Math.abs(Array.isArray(m)?m[1]:m);return[Math.min(x,y[0]),Math.max(g,y[1])]},[1/0,-1/0]);return[Math.min(p[0],u[0]),Math.max(p[1],u[1])]},[1/0,-1/0])}return null},Lpe=function(t,r,n,a,s){var o=r.map(function(l){return l3(t,l,n,s,a)}).filter(function(l){return!Ee(l)});return o&&o.length?o.reduce(function(l,c){return[Math.min(l[0],c[0]),Math.max(l[1],c[1])]},[1/0,-1/0]):null},c3=function(t,r,n,a,s){var o=r.map(function(c){var u=c.props.dataKey;return n==="number"&&u&&l3(t,c,u,a)||Nd(t,u,n,s)});if(n==="number")return o.reduce(function(c,u){return[Math.min(c[0],u[0]),Math.max(c[1],u[1])]},[1/0,-1/0]);var l={};return o.reduce(function(c,u){for(var f=0,d=u.length;f=2?Er(l[0]-l[1])*2*u:u,r&&(t.ticks||t.niceTicks)){var f=(t.ticks||t.niceTicks).map(function(d){var h=s?s.indexOf(d):d;return{coordinate:a(h)+u,value:d,offset:u}});return f.filter(function(d){return!gu(d.coordinate)})}return t.isCategorical&&t.categoricalDomain?t.categoricalDomain.map(function(d,h){return{coordinate:a(d)+u,value:d,index:h,offset:u}}):a.ticks&&!n?a.ticks(t.tickCount).map(function(d){return{coordinate:a(d)+u,value:d,offset:u}}):a.domain().map(function(d,h){return{coordinate:a(d)+u,value:s?s[d]:d,index:h,offset:u}})},i0=new WeakMap,xp=function(t,r){if(typeof r!="function")return t;i0.has(t)||i0.set(t,new WeakMap);var n=i0.get(t);if(n.has(r))return n.get(r);var a=function(){t.apply(void 0,arguments),r.apply(void 0,arguments)};return n.set(r,a),a},f3=function(t,r,n){var a=t.scale,s=t.type,o=t.layout,l=t.axisType;if(a==="auto")return o==="radial"&&l==="radiusAxis"?{scale:sf(),realScaleType:"band"}:o==="radial"&&l==="angleAxis"?{scale:nv(),realScaleType:"linear"}:s==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:wd(),realScaleType:"point"}:s==="category"?{scale:sf(),realScaleType:"band"}:{scale:nv(),realScaleType:"linear"};if(vh(a)){var c="scale".concat(zg(a));return{scale:(H2[c]||wd)(),realScaleType:H2[c]?c:"point"}}return Oe(a)?{scale:a}:{scale:wd(),realScaleType:"point"}},Z2=1e-4,h3=function(t){var r=t.domain();if(!(!r||r.length<=2)){var n=r.length,a=t.range(),s=Math.min(a[0],a[1])-Z2,o=Math.max(a[0],a[1])+Z2,l=t(r[0]),c=t(r[n-1]);(lo||co)&&t.domain([r[0],r[n-1]])}},Fpe=function(t,r){if(!t)return null;for(var n=0,a=t.length;na)&&(s[1]=a),s[0]>a&&(s[0]=a),s[1]=0?(t[l][n][0]=s,t[l][n][1]=s+c,s=t[l][n][1]):(t[l][n][0]=o,t[l][n][1]=o+c,o=t[l][n][1])}},zpe=function(t){var r=t.length;if(!(r<=0))for(var n=0,a=t[0].length;n=0?(t[o][n][0]=s,t[o][n][1]=s+l,s=t[o][n][1]):(t[o][n][0]=0,t[o][n][1]=0)}},Wpe={sign:Upe,expand:lte,none:Oc,silhouette:cte,wiggle:ute,positive:zpe},Hpe=function(t,r,n){var a=r.map(function(l){return l.props.dataKey}),s=Wpe[n],o=ote().keys(a).value(function(l,c){return+It(l,c,0)}).order(mj).offset(s);return o(t)},Vpe=function(t,r,n,a,s,o){if(!t)return null;var l=o?r.reverse():r,c={},u=l.reduce(function(d,h){var p,y=(p=h.type)!==null&&p!==void 0&&p.defaultProps?Dt(Dt({},h.type.defaultProps),h.props):h.props,v=y.stackId,m=y.hide;if(m)return d;var x=y[n],g=d[x]||{hasStack:!1,stackGroups:{}};if(Zt(v)){var b=g.stackGroups[v]||{numericAxisId:n,cateAxisId:a,items:[]};b.items.push(h),g.hasStack=!0,g.stackGroups[v]=b}else g.stackGroups[Jo("_stackId_")]={numericAxisId:n,cateAxisId:a,items:[h]};return Dt(Dt({},d),{},Zl({},x,g))},c),f={};return Object.keys(u).reduce(function(d,h){var p=u[h];if(p.hasStack){var y={};p.stackGroups=Object.keys(p.stackGroups).reduce(function(v,m){var x=p.stackGroups[m];return Dt(Dt({},v),{},Zl({},m,{numericAxisId:n,cateAxisId:a,items:x.items,stackedData:Hpe(t,x.items,s)}))},y)}return Dt(Dt({},d),{},Zl({},h,p))},f)},p3=function(t,r){var n=r.realScaleType,a=r.type,s=r.tickCount,o=r.originalDomain,l=r.allowDecimals,c=n||r.scale;if(c!=="auto"&&c!=="linear")return null;if(s&&a==="number"&&o&&(o[0]==="auto"||o[1]==="auto")){var u=t.domain();if(!u.length)return null;var f=ipe(u,s,l);return t.domain([ny(f),os(f)]),{niceTicks:f}}if(s&&a==="number"){var d=t.domain(),h=spe(d,s,l);return{niceTicks:h}}return null};function uv(e){var t=e.axis,r=e.ticks,n=e.bandSize,a=e.entry,s=e.index,o=e.dataKey;if(t.type==="category"){if(!t.allowDuplicatedCategory&&t.dataKey&&!Ee(a[t.dataKey])){var l=Rm(r,"value",a[t.dataKey]);if(l)return l.coordinate+n/2}return r[s]?r[s].coordinate+n/2:null}var c=It(a,Ee(o)?t.dataKey:o);return Ee(c)?null:t.scale(c)}var J2=function(t){var r=t.axis,n=t.ticks,a=t.offset,s=t.bandSize,o=t.entry,l=t.index;if(r.type==="category")return n[l]?n[l].coordinate+a:null;var c=It(o,r.dataKey,r.domain[l]);return Ee(c)?null:r.scale(c)-s/2+a},qpe=function(t){var r=t.numericAxis,n=r.scale.domain();if(r.type==="number"){var a=Math.min(n[0],n[1]),s=Math.max(n[0],n[1]);return a<=0&&s>=0?0:s<0?s:a}return n[0]},Gpe=function(t,r){var n,a=(n=t.type)!==null&&n!==void 0&&n.defaultProps?Dt(Dt({},t.type.defaultProps),t.props):t.props,s=a.stackId;if(Zt(s)){var o=r[s];if(o){var l=o.items.indexOf(t);return l>=0?o.stackedData[l]:null}}return null},Kpe=function(t){return t.reduce(function(r,n){return[ny(n.concat([r[0]]).filter(se)),os(n.concat([r[1]]).filter(se))]},[1/0,-1/0])},m3=function(t,r,n){return Object.keys(t).reduce(function(a,s){var o=t[s],l=o.stackedData,c=l.reduce(function(u,f){var d=Kpe(f.slice(r,n+1));return[Math.min(u[0],d[0]),Math.max(u[1],d[1])]},[1/0,-1/0]);return[Math.min(c[0],a[0]),Math.max(c[1],a[1])]},[1/0,-1/0]).map(function(a){return a===1/0||a===-1/0?0:a})},eE=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,tE=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Vj=function(t,r,n){if(Oe(t))return t(r,n);if(!Array.isArray(t))return r;var a=[];if(se(t[0]))a[0]=n?t[0]:Math.min(t[0],r[0]);else if(eE.test(t[0])){var s=+eE.exec(t[0])[1];a[0]=r[0]-s}else Oe(t[0])?a[0]=t[0](r[0]):a[0]=r[0];if(se(t[1]))a[1]=n?t[1]:Math.max(t[1],r[1]);else if(tE.test(t[1])){var o=+tE.exec(t[1])[1];a[1]=r[1]+o}else Oe(t[1])?a[1]=t[1](r[1]):a[1]=r[1];return a},dv=function(t,r,n){if(t&&t.scale&&t.scale.bandwidth){var a=t.scale.bandwidth();if(!n||a>0)return a}if(t&&r&&r.length>=2){for(var s=oS(r,function(d){return d.coordinate}),o=1/0,l=1,c=s.length;le.length)&&(t=e.length);for(var r=0,n=new Array(t);r2&&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},nme=function(t,r,n,a,s){var o=t.width,l=t.height,c=t.startAngle,u=t.endAngle,f=Tr(t.cx,o,o/2),d=Tr(t.cy,l,l/2),h=y3(o,l,n),p=Tr(t.innerRadius,h,0),y=Tr(t.outerRadius,h,h*.8),v=Object.keys(r);return v.reduce(function(m,x){var g=r[x],b=g.domain,N=g.reversed,w;if(Ee(g.range))a==="angleAxis"?w=[c,u]:a==="radiusAxis"&&(w=[p,y]),N&&(w=[w[1],w[0]]);else{w=g.range;var S=w,O=Xpe(S,2);c=O[0],u=O[1]}var P=f3(g,s),A=P.realScaleType,C=P.scale;C.domain(b).range(w),h3(C);var T=p3(C,oi(oi({},g),{},{realScaleType:A})),D=oi(oi(oi({},g),T),{},{range:w,radius:y,realScaleType:A,scale:C,cx:f,cy:d,innerRadius:p,outerRadius:y,startAngle:c,endAngle:u});return oi(oi({},m),{},g3({},x,D))},{})},ame=function(t,r){var n=t.x,a=t.y,s=r.x,o=r.y;return Math.sqrt(Math.pow(n-s,2)+Math.pow(a-o,2))},ime=function(t,r){var n=t.x,a=t.y,s=r.cx,o=r.cy,l=ame({x:n,y:a},{x:s,y:o});if(l<=0)return{radius:l};var c=(n-s)/l,u=Math.acos(c);return a>o&&(u=2*Math.PI-u),{radius:l,angle:rme(u),angleInRadian:u}},sme=function(t){var r=t.startAngle,n=t.endAngle,a=Math.floor(r/360),s=Math.floor(n/360),o=Math.min(a,s);return{startAngle:r-o*360,endAngle:n-o*360}},ome=function(t,r){var n=r.startAngle,a=r.endAngle,s=Math.floor(n/360),o=Math.floor(a/360),l=Math.min(s,o);return t+l*360},iE=function(t,r){var n=t.x,a=t.y,s=ime({x:n,y:a},r),o=s.radius,l=s.angle,c=r.innerRadius,u=r.outerRadius;if(ou)return!1;if(o===0)return!0;var f=sme(r),d=f.startAngle,h=f.endAngle,p=l,y;if(d<=h){for(;p>h;)p-=360;for(;p=d&&p<=h}else{for(;p>d;)p-=360;for(;p=h&&p<=d}return y?oi(oi({},r),{},{radius:o,angle:ome(p,r)}):null},x3=function(t){return!j.isValidElement(t)&&!Oe(t)&&typeof t!="boolean"?t.className:""};function vf(e){"@babel/helpers - typeof";return vf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vf(e)}var lme=["offset"];function cme(e){return hme(e)||fme(e)||dme(e)||ume()}function ume(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function dme(e,t){if(e){if(typeof e=="string")return qj(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return qj(e,t)}}function fme(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function hme(e){if(Array.isArray(e))return qj(e)}function qj(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function mme(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function sE(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function qt(e){for(var t=1;t=0?1:-1,b,N;a==="insideStart"?(b=p+g*o,N=v):a==="insideEnd"?(b=y-g*o,N=!v):a==="end"&&(b=y+g*o,N=v),N=x<=0?N:!N;var w=gt(u,f,m,b),S=gt(u,f,m,b+(N?1:-1)*359),O="M".concat(w.x,",").concat(w.y,` A`).concat(m,",").concat(m,",0,1,").concat(N?0:1,`, `).concat(S.x,",").concat(S.y),P=Ee(t.id)?Jo("recharts-radial-line-"):t.id;return M.createElement("text",gf({},n,{dominantBaseline:"central",className:Me("recharts-radial-bar-label",l)}),M.createElement("defs",null,M.createElement("path",{id:P,d:O})),M.createElement("textPath",{xlinkHref:"#".concat(P)},r))},wme=function(t){var r=t.viewBox,n=t.offset,a=t.position,s=r,o=s.cx,l=s.cy,c=s.innerRadius,u=s.outerRadius,f=s.startAngle,d=s.endAngle,h=(f+d)/2;if(a==="outside"){var p=gt(o,l,u+n,h),y=p.x,v=p.y;return{x:y,y:v,textAnchor:y>=o?"start":"end",verticalAnchor:"middle"}}if(a==="center")return{x:o,y:l,textAnchor:"middle",verticalAnchor:"middle"};if(a==="centerTop")return{x:o,y:l,textAnchor:"middle",verticalAnchor:"start"};if(a==="centerBottom")return{x:o,y:l,textAnchor:"middle",verticalAnchor:"end"};var m=(c+u)/2,x=gt(o,l,m,h),g=x.x,b=x.y;return{x:g,y:b,textAnchor:"middle",verticalAnchor:"middle"}},Nme=function(t){var r=t.viewBox,n=t.parentViewBox,a=t.offset,s=t.position,o=r,l=o.x,c=o.y,u=o.width,f=o.height,d=f>=0?1:-1,h=d*a,p=d>0?"end":"start",y=d>0?"start":"end",v=u>=0?1:-1,m=v*a,x=v>0?"end":"start",g=v>0?"start":"end";if(s==="top"){var b={x:l+u/2,y:c-d*a,textAnchor:"middle",verticalAnchor:p};return qt(qt({},b),n?{height:Math.max(c-n.y,0),width:u}:{})}if(s==="bottom"){var N={x:l+u/2,y:c+f+h,textAnchor:"middle",verticalAnchor:y};return qt(qt({},N),n?{height:Math.max(n.y+n.height-(c+f),0),width:u}:{})}if(s==="left"){var w={x:l-m,y:c+f/2,textAnchor:x,verticalAnchor:"middle"};return qt(qt({},w),n?{width:Math.max(w.x-n.x,0),height:f}:{})}if(s==="right"){var S={x:l+u+m,y:c+f/2,textAnchor:g,verticalAnchor:"middle"};return qt(qt({},S),n?{width:Math.max(n.x+n.width-S.x,0),height:f}:{})}var O=n?{width:u,height:f}:{};return s==="insideLeft"?qt({x:l+m,y:c+f/2,textAnchor:g,verticalAnchor:"middle"},O):s==="insideRight"?qt({x:l+u-m,y:c+f/2,textAnchor:x,verticalAnchor:"middle"},O):s==="insideTop"?qt({x:l+u/2,y:c+h,textAnchor:"middle",verticalAnchor:y},O):s==="insideBottom"?qt({x:l+u/2,y:c+f-h,textAnchor:"middle",verticalAnchor:p},O):s==="insideTopLeft"?qt({x:l+m,y:c+h,textAnchor:g,verticalAnchor:y},O):s==="insideTopRight"?qt({x:l+u-m,y:c+h,textAnchor:x,verticalAnchor:y},O):s==="insideBottomLeft"?qt({x:l+m,y:c+f-h,textAnchor:g,verticalAnchor:p},O):s==="insideBottomRight"?qt({x:l+u-m,y:c+f-h,textAnchor:x,verticalAnchor:p},O):hu(s)&&(se(s.x)||lo(s.x))&&(se(s.y)||lo(s.y))?qt({x:l+Tr(s.x,u),y:c+Tr(s.y,f),textAnchor:"end",verticalAnchor:"end"},O):qt({x:l+u/2,y:c+f/2,textAnchor:"middle",verticalAnchor:"middle"},O)},Sme=function(t){return"cx"in t&&se(t.cx)};function nr(e){var t=e.offset,r=t===void 0?5:t,n=pme(e,lme),a=qt({offset:r},n),s=a.viewBox,o=a.position,l=a.value,c=a.children,u=a.content,f=a.className,d=f===void 0?"":f,h=a.textBreakAll;if(!s||Ee(l)&&Ee(c)&&!j.isValidElement(u)&&!Oe(u))return null;if(j.isValidElement(u))return j.cloneElement(u,a);var p;if(Oe(u)){if(p=j.createElement(u,a),j.isValidElement(p))return p}else p=xme(a);var y=Sme(s),v=xe(a,!0);if(y&&(o==="insideStart"||o==="insideEnd"||o==="end"))return jme(a,p,v);var m=y?wme(a):Nme(a);return M.createElement(Vo,gf({className:Me("recharts-label",d)},v,m,{breakAll:h}),p)}nr.displayName="Label";var b3=function(t){var r=t.cx,n=t.cy,a=t.angle,s=t.startAngle,o=t.endAngle,l=t.r,c=t.radius,u=t.innerRadius,f=t.outerRadius,d=t.x,h=t.y,p=t.top,y=t.left,v=t.width,m=t.height,x=t.clockWise,g=t.labelViewBox;if(g)return g;if(se(v)&&se(m)){if(se(d)&&se(h))return{x:d,y:h,width:v,height:m};if(se(p)&&se(y))return{x:p,y,width:v,height:m}}return se(d)&&se(h)?{x:d,y:h,width:0,height:0}:se(r)&&se(n)?{cx:r,cy:n,startAngle:s||a||0,endAngle:o||a||0,innerRadius:u||0,outerRadius:f||c||l||0,clockWise:x}:t.viewBox?t.viewBox:{}},Ome=function(t,r){return t?t===!0?M.createElement(nr,{key:"label-implicit",viewBox:r}):Zt(t)?M.createElement(nr,{key:"label-implicit",viewBox:r,value:t}):j.isValidElement(t)?t.type===nr?j.cloneElement(t,{key:"label-implicit",viewBox:r}):M.createElement(nr,{key:"label-implicit",content:t,viewBox:r}):Oe(t)?M.createElement(nr,{key:"label-implicit",content:t,viewBox:r}):hu(t)?M.createElement(nr,gf({viewBox:r},t,{key:"label-implicit"})):null:null},Pme=function(t,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!t||!t.children&&n&&!t.label)return null;var a=t.children,s=b3(t),o=mn(a,nr).map(function(c,u){return j.cloneElement(c,{viewBox:r||s,key:"label-".concat(u)})});if(!n)return o;var l=Ome(t.label,r||s);return[l].concat(cme(o))};nr.parseViewBox=b3;nr.renderCallByParent=Pme;function Ame(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var Cme=Ame;const Eme=et(Cme);function yf(e){"@babel/helpers - typeof";return yf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yf(e)}var Tme=["valueAccessor"],kme=["data","dataKey","clockWise","id","textBreakAll"];function _me(e){return Rme(e)||Ime(e)||Mme(e)||Dme()}function Dme(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Mme(e,t){if(e){if(typeof e=="string")return Gj(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Gj(e,t)}}function Ime(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Rme(e){if(Array.isArray(e))return Gj(e)}function Gj(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Bme(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}var Ume=function(t){return Array.isArray(t.value)?Eme(t.value):t.value};function qa(e){var t=e.valueAccessor,r=t===void 0?Ume:t,n=cE(e,Tme),a=n.data,s=n.dataKey,o=n.clockWise,l=n.id,c=n.textBreakAll,u=cE(n,kme);return!a||!a.length?null:M.createElement(Ue,{className:"recharts-label-list"},a.map(function(f,d){var h=Ee(s)?r(f,d):It(f&&f.payload,s),p=Ee(l)?{}:{id:"".concat(l,"-").concat(d)};return M.createElement(nr,hv({},xe(f,!0),u,p,{parentViewBox:f.parentViewBox,value:h,textBreakAll:c,viewBox:nr.parseViewBox(Ee(o)?f:lE(lE({},f),{},{clockWise:o})),key:"label-".concat(d),index:d}))}))}qa.displayName="LabelList";function zme(e,t){return e?e===!0?M.createElement(qa,{key:"labelList-implicit",data:t}):M.isValidElement(e)||Oe(e)?M.createElement(qa,{key:"labelList-implicit",data:t,content:e}):hu(e)?M.createElement(qa,hv({data:t},e,{key:"labelList-implicit"})):null:null}function Wme(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e||!e.children&&r&&!e.label)return null;var n=e.children,a=mn(n,qa).map(function(o,l){return j.cloneElement(o,{data:t,key:"labelList-".concat(l)})});if(!r)return a;var s=zme(e.label,t);return[s].concat(_me(a))}qa.renderCallByParent=Wme;function xf(e){"@babel/helpers - typeof";return xf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xf(e)}function Kj(){return Kj=Object.assign?Object.assign.bind():function(e){for(var t=1;t180),",").concat(+(o>u),`, `).concat(d.x,",").concat(d.y,` `);if(a>0){var p=gt(r,n,a,o),y=gt(r,n,a,u);h+="L ".concat(y.x,",").concat(y.y,` A `).concat(a,",").concat(a,`,0, `).concat(+(Math.abs(c)>180),",").concat(+(o<=u),`, `).concat(p.x,",").concat(p.y," Z")}else h+="L ".concat(r,",").concat(n," Z");return h},Kme=function(t){var r=t.cx,n=t.cy,a=t.innerRadius,s=t.outerRadius,o=t.cornerRadius,l=t.forceCornerRadius,c=t.cornerIsExternal,u=t.startAngle,f=t.endAngle,d=Er(f-u),h=bp({cx:r,cy:n,radius:s,angle:u,sign:d,cornerRadius:o,cornerIsExternal:c}),p=h.circleTangency,y=h.lineTangency,v=h.theta,m=bp({cx:r,cy:n,radius:s,angle:f,sign:-d,cornerRadius:o,cornerIsExternal:c}),x=m.circleTangency,g=m.lineTangency,b=m.theta,N=c?Math.abs(u-f):Math.abs(u-f)-v-b;if(N<0)return l?"M ".concat(y.x,",").concat(y.y,` a`).concat(o,",").concat(o,",0,0,1,").concat(o*2,`,0 a`).concat(o,",").concat(o,",0,0,1,").concat(-o*2,`,0 `):j3({cx:r,cy:n,innerRadius:a,outerRadius:s,startAngle:u,endAngle:f});var w="M ".concat(y.x,",").concat(y.y,` A`).concat(o,",").concat(o,",0,0,").concat(+(d<0),",").concat(p.x,",").concat(p.y,` A`).concat(s,",").concat(s,",0,").concat(+(N>180),",").concat(+(d<0),",").concat(x.x,",").concat(x.y,` A`).concat(o,",").concat(o,",0,0,").concat(+(d<0),",").concat(g.x,",").concat(g.y,` `);if(a>0){var S=bp({cx:r,cy:n,radius:a,angle:u,sign:d,isExternal:!0,cornerRadius:o,cornerIsExternal:c}),O=S.circleTangency,P=S.lineTangency,A=S.theta,C=bp({cx:r,cy:n,radius:a,angle:f,sign:-d,isExternal:!0,cornerRadius:o,cornerIsExternal:c}),T=C.circleTangency,D=C.lineTangency,_=C.theta,k=c?Math.abs(u-f):Math.abs(u-f)-A-_;if(k<0&&o===0)return"".concat(w,"L").concat(r,",").concat(n,"Z");w+="L".concat(D.x,",").concat(D.y,` A`).concat(o,",").concat(o,",0,0,").concat(+(d<0),",").concat(T.x,",").concat(T.y,` A`).concat(a,",").concat(a,",0,").concat(+(k>180),",").concat(+(d>0),",").concat(O.x,",").concat(O.y,` A`).concat(o,",").concat(o,",0,0,").concat(+(d<0),",").concat(P.x,",").concat(P.y,"Z")}else w+="L".concat(r,",").concat(n,"Z");return w},Yme={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},w3=function(t){var r=dE(dE({},Yme),t),n=r.cx,a=r.cy,s=r.innerRadius,o=r.outerRadius,l=r.cornerRadius,c=r.forceCornerRadius,u=r.cornerIsExternal,f=r.startAngle,d=r.endAngle,h=r.className;if(o0&&Math.abs(f-d)<360?m=Kme({cx:n,cy:a,innerRadius:s,outerRadius:o,cornerRadius:Math.min(v,y/2),forceCornerRadius:c,cornerIsExternal:u,startAngle:f,endAngle:d}):m=j3({cx:n,cy:a,innerRadius:s,outerRadius:o,startAngle:f,endAngle:d}),M.createElement("path",Kj({},xe(r,!0),{className:p,d:m,role:"img"}))};function bf(e){"@babel/helpers - typeof";return bf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bf(e)}function Yj(){return Yj=Object.assign?Object.assign.bind():function(e){for(var t=1;t0;)if(!r.equals(e[n],t[n],n,n,e,t,r))return!1;return!0}function pve(e,t){return rl(e.getTime(),t.getTime())}function mve(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function vve(e,t){return e===t}function xE(e,t,r){var n=e.size;if(n!==t.size)return!1;if(!n)return!0;for(var a=new Array(n),s=e.entries(),o,l,c=0;(o=s.next())&&!o.done;){for(var u=t.entries(),f=!1,d=0;(l=u.next())&&!l.done;){if(a[d]){d++;continue}var h=o.value,p=l.value;if(r.equals(h[0],p[0],c,d,e,t,r)&&r.equals(h[1],p[1],h[0],p[0],e,t,r)){f=a[d]=!0;break}d++}if(!f)return!1;c++}return!0}var gve=rl;function yve(e,t,r){var n=yE(e),a=n.length;if(yE(t).length!==a)return!1;for(;a-- >0;)if(!P3(e,t,r,n[a]))return!1;return!0}function Xu(e,t,r){var n=vE(e),a=n.length;if(vE(t).length!==a)return!1;for(var s,o,l;a-- >0;)if(s=n[a],!P3(e,t,r,s)||(o=gE(e,s),l=gE(t,s),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function xve(e,t){return rl(e.valueOf(),t.valueOf())}function bve(e,t){return e.source===t.source&&e.flags===t.flags}function bE(e,t,r){var n=e.size;if(n!==t.size)return!1;if(!n)return!0;for(var a=new Array(n),s=e.values(),o,l;(o=s.next())&&!o.done;){for(var c=t.values(),u=!1,f=0;(l=c.next())&&!l.done;){if(!a[f]&&r.equals(o.value,l.value,o.value,l.value,e,t,r)){u=a[f]=!0;break}f++}if(!u)return!1}return!0}function jve(e,t){var r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(e[r]!==t[r])return!1;return!0}function wve(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function P3(e,t,r,n){return(n===fve||n===dve||n===uve)&&(e.$$typeof||t.$$typeof)?!0:cve(t,n)&&r.equals(e[n],t[n],n,n,e,t,r)}var Nve="[object Arguments]",Sve="[object Boolean]",Ove="[object Date]",Pve="[object Error]",Ave="[object Map]",Cve="[object Number]",Eve="[object Object]",Tve="[object RegExp]",kve="[object Set]",_ve="[object String]",Dve="[object URL]",Mve=Array.isArray,jE=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,wE=Object.assign,Ive=Object.prototype.toString.call.bind(Object.prototype.toString);function Rve(e){var t=e.areArraysEqual,r=e.areDatesEqual,n=e.areErrorsEqual,a=e.areFunctionsEqual,s=e.areMapsEqual,o=e.areNumbersEqual,l=e.areObjectsEqual,c=e.arePrimitiveWrappersEqual,u=e.areRegExpsEqual,f=e.areSetsEqual,d=e.areTypedArraysEqual,h=e.areUrlsEqual;return function(y,v,m){if(y===v)return!0;if(y==null||v==null)return!1;var x=typeof y;if(x!==typeof v)return!1;if(x!=="object")return x==="number"?o(y,v,m):x==="function"?a(y,v,m):!1;var g=y.constructor;if(g!==v.constructor)return!1;if(g===Object)return l(y,v,m);if(Mve(y))return t(y,v,m);if(jE!=null&&jE(y))return d(y,v,m);if(g===Date)return r(y,v,m);if(g===RegExp)return u(y,v,m);if(g===Map)return s(y,v,m);if(g===Set)return f(y,v,m);var b=Ive(y);return b===Ove?r(y,v,m):b===Tve?u(y,v,m):b===Ave?s(y,v,m):b===kve?f(y,v,m):b===Eve?typeof y.then!="function"&&typeof v.then!="function"&&l(y,v,m):b===Dve?h(y,v,m):b===Pve?n(y,v,m):b===Nve?l(y,v,m):b===Sve||b===Cve||b===_ve?c(y,v,m):!1}}function $ve(e){var t=e.circular,r=e.createCustomConfig,n=e.strict,a={areArraysEqual:n?Xu:hve,areDatesEqual:pve,areErrorsEqual:mve,areFunctionsEqual:vve,areMapsEqual:n?mE(xE,Xu):xE,areNumbersEqual:gve,areObjectsEqual:n?Xu:yve,arePrimitiveWrappersEqual:xve,areRegExpsEqual:bve,areSetsEqual:n?mE(bE,Xu):bE,areTypedArraysEqual:n?Xu:jve,areUrlsEqual:wve};if(r&&(a=wE({},a,r(a))),t){var s=wp(a.areArraysEqual),o=wp(a.areMapsEqual),l=wp(a.areObjectsEqual),c=wp(a.areSetsEqual);a=wE({},a,{areArraysEqual:s,areMapsEqual:o,areObjectsEqual:l,areSetsEqual:c})}return a}function Lve(e){return function(t,r,n,a,s,o,l){return e(t,r,l)}}function Fve(e){var t=e.circular,r=e.comparator,n=e.createState,a=e.equals,s=e.strict;if(n)return function(c,u){var f=n(),d=f.cache,h=d===void 0?t?new WeakMap:void 0:d,p=f.meta;return r(c,u,{cache:h,equals:a,meta:p,strict:s})};if(t)return function(c,u){return r(c,u,{cache:new WeakMap,equals:a,meta:void 0,strict:s})};var o={cache:void 0,equals:a,meta:void 0,strict:s};return function(c,u){return r(c,u,o)}}var Bve=Hs();Hs({strict:!0});Hs({circular:!0});Hs({circular:!0,strict:!0});Hs({createInternalComparator:function(){return rl}});Hs({strict:!0,createInternalComparator:function(){return rl}});Hs({circular:!0,createInternalComparator:function(){return rl}});Hs({circular:!0,createInternalComparator:function(){return rl},strict:!0});function Hs(e){e===void 0&&(e={});var t=e.circular,r=t===void 0?!1:t,n=e.createInternalComparator,a=e.createState,s=e.strict,o=s===void 0?!1:s,l=$ve(e),c=Rve(l),u=n?n(c):Lve(c);return Fve({circular:r,comparator:c,createState:a,equals:u,strict:o})}function Uve(e){typeof requestAnimationFrame<"u"&&requestAnimationFrame(e)}function NE(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=-1,n=function a(s){r<0&&(r=s),s-r>t?(e(s),r=-1):Uve(a)};requestAnimationFrame(n)}function Qj(e){"@babel/helpers - typeof";return Qj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Qj(e)}function zve(e){return qve(e)||Vve(e)||Hve(e)||Wve()}function Wve(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Hve(e,t){if(e){if(typeof e=="string")return SE(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return SE(e,t)}}function SE(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);re.length)&&(t=e.length);for(var r=0,n=new Array(t);r1?1:x<0?0:x},v=function(x){for(var g=x>1?1:x,b=g,N=0;N<8;++N){var w=d(b)-g,S=p(b);if(Math.abs(w-g)0&&arguments[0]!==void 0?arguments[0]:{},r=t.stiff,n=r===void 0?100:r,a=t.damping,s=a===void 0?8:a,o=t.dt,l=o===void 0?17:o,c=function(f,d,h){var p=-(f-d)*n,y=h*s,v=h+(p-y)*l/1e3,m=h*l/1e3+f;return Math.abs(m-d)e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Nge(e,t){if(e==null)return{};var r={},n=Object.keys(e),a,s;for(s=0;s=0)&&(r[a]=e[a]);return r}function s0(e){return Age(e)||Pge(e)||Oge(e)||Sge()}function Sge(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Oge(e,t){if(e){if(typeof e=="string")return tw(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return tw(e,t)}}function Pge(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Age(e){if(Array.isArray(e))return tw(e)}function tw(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function vv(e){return vv=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},vv(e)}var wa=function(e){_ge(r,e);var t=Dge(r);function r(n,a){var s;Cge(this,r),s=t.call(this,n,a);var o=s.props,l=o.isActive,c=o.attributeName,u=o.from,f=o.to,d=o.steps,h=o.children,p=o.duration;if(s.handleStyleChange=s.handleStyleChange.bind(aw(s)),s.changeStyle=s.changeStyle.bind(aw(s)),!l||p<=0)return s.state={style:{}},typeof h=="function"&&(s.state={style:f}),nw(s);if(d&&d.length)s.state={style:d[0].style};else if(u){if(typeof h=="function")return s.state={style:u},nw(s);s.state={style:c?cd({},c,u):u}}else s.state={style:{}};return s}return Tge(r,[{key:"componentDidMount",value:function(){var a=this.props,s=a.isActive,o=a.canBegin;this.mounted=!0,!(!s||!o)&&this.runAnimation(this.props)}},{key:"componentDidUpdate",value:function(a){var s=this.props,o=s.isActive,l=s.canBegin,c=s.attributeName,u=s.shouldReAnimate,f=s.to,d=s.from,h=this.state.style;if(l){if(!o){var p={style:c?cd({},c,f):f};this.state&&h&&(c&&h[c]!==f||!c&&h!==f)&&this.setState(p);return}if(!(Bve(a.to,f)&&a.canBegin&&a.isActive)){var y=!a.canBegin||!a.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var v=y||u?d:a.to;if(this.state&&h){var m={style:c?cd({},c,v):v};(c&&h[c]!==v||!c&&h!==v)&&this.setState(m)}this.runAnimation(Xn(Xn({},this.props),{},{from:v,begin:0}))}}}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var a=this.props.onAnimationEnd;this.unSubscribe&&this.unSubscribe(),this.manager&&(this.manager.stop(),this.manager=null),this.stopJSAnimation&&this.stopJSAnimation(),a&&a()}},{key:"handleStyleChange",value:function(a){this.changeStyle(a)}},{key:"changeStyle",value:function(a){this.mounted&&this.setState({style:a})}},{key:"runJSAnimation",value:function(a){var s=this,o=a.from,l=a.to,c=a.duration,u=a.easing,f=a.begin,d=a.onAnimationEnd,h=a.onAnimationStart,p=bge(o,l,cge(u),c,this.changeStyle),y=function(){s.stopJSAnimation=p()};this.manager.start([h,f,y,c,d])}},{key:"runStepAnimation",value:function(a){var s=this,o=a.steps,l=a.begin,c=a.onAnimationStart,u=o[0],f=u.style,d=u.duration,h=d===void 0?0:d,p=function(v,m,x){if(x===0)return v;var g=m.duration,b=m.easing,N=b===void 0?"ease":b,w=m.style,S=m.properties,O=m.onAnimationEnd,P=x>0?o[x-1]:m,A=S||Object.keys(w);if(typeof N=="function"||N==="spring")return[].concat(s0(v),[s.runJSAnimation.bind(s,{from:P.style,to:w,duration:g,easing:N}),g]);var C=AE(A,g,N),T=Xn(Xn(Xn({},P.style),w),{},{transition:C});return[].concat(s0(v),[T,g,O]).filter(Xve)};return this.manager.start([c].concat(s0(o.reduce(p,[f,Math.max(h,l)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=Gve());var s=a.begin,o=a.duration,l=a.attributeName,c=a.to,u=a.easing,f=a.onAnimationStart,d=a.onAnimationEnd,h=a.steps,p=a.children,y=this.manager;if(this.unSubscribe=y.subscribe(this.handleStyleChange),typeof u=="function"||typeof p=="function"||u==="spring"){this.runJSAnimation(a);return}if(h.length>1){this.runStepAnimation(a);return}var v=l?cd({},l,c):c,m=AE(Object.keys(v),o,u);y.start([f,s,Xn(Xn({},v),{},{transition:m}),o,d])}},{key:"render",value:function(){var a=this.props,s=a.children;a.begin;var o=a.duration;a.attributeName,a.easing;var l=a.isActive;a.steps,a.from,a.to,a.canBegin,a.onAnimationEnd,a.shouldReAnimate,a.onAnimationReStart;var c=wge(a,jge),u=j.Children.count(s),f=this.state.style;if(typeof s=="function")return s(f);if(!l||u===0||o<=0)return s;var d=function(p){var y=p.props,v=y.style,m=v===void 0?{}:v,x=y.className,g=j.cloneElement(p,Xn(Xn({},c),{},{style:Xn(Xn({},m),f),className:x}));return g};return u===1?d(j.Children.only(s)):M.createElement("div",null,j.Children.map(s,function(h){return d(h)}))}}]),r}(j.PureComponent);wa.displayName="Animate";wa.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};wa.propTypes={from:tt.oneOfType([tt.object,tt.string]),to:tt.oneOfType([tt.object,tt.string]),attributeName:tt.string,duration:tt.number,begin:tt.number,easing:tt.oneOfType([tt.string,tt.func]),steps:tt.arrayOf(tt.shape({duration:tt.number.isRequired,style:tt.object.isRequired,easing:tt.oneOfType([tt.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),tt.func]),properties:tt.arrayOf("string"),onAnimationEnd:tt.func})),children:tt.oneOfType([tt.node,tt.func]),isActive:tt.bool,canBegin:tt.bool,onAnimationEnd:tt.func,shouldReAnimate:tt.bool,onAnimationStart:tt.func,onAnimationReStart:tt.func};function Ne(){return Ne=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0?1:-1,c=n>=0?1:-1,u=a>=0&&n>=0||a<0&&n<0?1:0,f;if(o>0&&s instanceof Array){for(var d=[0,0,0,0],h=0,p=4;ho?o:s[h];f="M".concat(t,",").concat(r+l*d[0]),d[0]>0&&(f+="A ".concat(d[0],",").concat(d[0],",0,0,").concat(u,",").concat(t+c*d[0],",").concat(r)),f+="L ".concat(t+n-c*d[1],",").concat(r),d[1]>0&&(f+="A ".concat(d[1],",").concat(d[1],",0,0,").concat(u,`, `).concat(t+n,",").concat(r+l*d[1])),f+="L ".concat(t+n,",").concat(r+a-l*d[2]),d[2]>0&&(f+="A ".concat(d[2],",").concat(d[2],",0,0,").concat(u,`, `).concat(t+n-c*d[2],",").concat(r+a)),f+="L ".concat(t+c*d[3],",").concat(r+a),d[3]>0&&(f+="A ".concat(d[3],",").concat(d[3],",0,0,").concat(u,`, `).concat(t,",").concat(r+a-l*d[3])),f+="Z"}else if(o>0&&s===+s&&s>0){var y=Math.min(o,s);f="M ".concat(t,",").concat(r+l*y,` A `).concat(y,",").concat(y,",0,0,").concat(u,",").concat(t+c*y,",").concat(r,` L `).concat(t+n-c*y,",").concat(r,` A `).concat(y,",").concat(y,",0,0,").concat(u,",").concat(t+n,",").concat(r+l*y,` L `).concat(t+n,",").concat(r+a-l*y,` A `).concat(y,",").concat(y,",0,0,").concat(u,",").concat(t+n-c*y,",").concat(r+a,` L `).concat(t+c*y,",").concat(r+a,` A `).concat(y,",").concat(y,",0,0,").concat(u,",").concat(t,",").concat(r+a-l*y," Z")}else f="M ".concat(t,",").concat(r," h ").concat(n," v ").concat(a," h ").concat(-n," Z");return f},Wge=function(t,r){if(!t||!r)return!1;var n=t.x,a=t.y,s=r.x,o=r.y,l=r.width,c=r.height;if(Math.abs(l)>0&&Math.abs(c)>0){var u=Math.min(s,s+l),f=Math.max(s,s+l),d=Math.min(o,o+c),h=Math.max(o,o+c);return n>=u&&n<=f&&a>=d&&a<=h}return!1},Hge={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},MS=function(t){var r=IE(IE({},Hge),t),n=j.useRef(),a=j.useState(-1),s=Ige(a,2),o=s[0],l=s[1];j.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var N=n.current.getTotalLength();N&&l(N)}catch{}},[]);var c=r.x,u=r.y,f=r.width,d=r.height,h=r.radius,p=r.className,y=r.animationEasing,v=r.animationDuration,m=r.animationBegin,x=r.isAnimationActive,g=r.isUpdateAnimationActive;if(c!==+c||u!==+u||f!==+f||d!==+d||f===0||d===0)return null;var b=Me("recharts-rectangle",p);return g?M.createElement(wa,{canBegin:o>0,from:{width:f,height:d,x:c,y:u},to:{width:f,height:d,x:c,y:u},duration:v,animationEasing:y,isActive:g},function(N){var w=N.width,S=N.height,O=N.x,P=N.y;return M.createElement(wa,{canBegin:o>0,from:"0px ".concat(o===-1?1:o,"px"),to:"".concat(o,"px 0px"),attributeName:"strokeDasharray",begin:m,duration:v,isActive:x,easing:y},M.createElement("path",yv({},xe(r,!0),{className:b,d:RE(O,P,w,S,h),ref:n})))}):M.createElement("path",yv({},xe(r,!0),{className:b,d:RE(c,u,f,d,h)}))},Vge=["points","className","baseLinePoints","connectNulls"];function Cl(){return Cl=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Gge(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function $E(e){return Xge(e)||Qge(e)||Yge(e)||Kge()}function Kge(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Yge(e,t){if(e){if(typeof e=="string")return sw(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return sw(e,t)}}function Qge(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Xge(e){if(Array.isArray(e))return sw(e)}function sw(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&arguments[0]!==void 0?arguments[0]:[],r=[[]];return t.forEach(function(n){LE(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),LE(t[0])&&r[r.length-1].push(t[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},Od=function(t,r){var n=Zge(t);r&&(n=[n.reduce(function(s,o){return[].concat($E(s),$E(o))},[])]);var a=n.map(function(s){return s.reduce(function(o,l,c){return"".concat(o).concat(c===0?"M":"L").concat(l.x,",").concat(l.y)},"")}).join("");return n.length===1?"".concat(a,"Z"):a},Jge=function(t,r,n){var a=Od(t,n);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(Od(r.reverse(),n).slice(1))},eye=function(t){var r=t.points,n=t.className,a=t.baseLinePoints,s=t.connectNulls,o=qge(t,Vge);if(!r||!r.length)return null;var l=Me("recharts-polygon",n);if(a&&a.length){var c=o.stroke&&o.stroke!=="none",u=Jge(r,a,s);return M.createElement("g",{className:l},M.createElement("path",Cl({},xe(o,!0),{fill:u.slice(-1)==="Z"?o.fill:"none",stroke:"none",d:u})),c?M.createElement("path",Cl({},xe(o,!0),{fill:"none",d:Od(r,s)})):null,c?M.createElement("path",Cl({},xe(o,!0),{fill:"none",d:Od(a,s)})):null)}var f=Od(r,s);return M.createElement("path",Cl({},xe(o,!0),{fill:f.slice(-1)==="Z"?o.fill:"none",className:l,d:f}))};function ow(){return ow=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function oye(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}var lye=function(t,r,n,a,s,o){return"M".concat(t,",").concat(s,"v").concat(a,"M").concat(o,",").concat(r,"h").concat(n)},cye=function(t){var r=t.x,n=r===void 0?0:r,a=t.y,s=a===void 0?0:a,o=t.top,l=o===void 0?0:o,c=t.left,u=c===void 0?0:c,f=t.width,d=f===void 0?0:f,h=t.height,p=h===void 0?0:h,y=t.className,v=sye(t,tye),m=rye({x:n,y:s,top:l,left:u,width:d,height:p},v);return!se(n)||!se(s)||!se(d)||!se(p)||!se(l)||!se(u)?null:M.createElement("path",lw({},xe(m,!0),{className:Me("recharts-cross",y),d:lye(n,s,d,p,l,u)}))},uye=ry,dye=HF,fye=ti;function hye(e,t){return e&&e.length?uye(e,fye(t),dye):void 0}var pye=hye;const mye=et(pye);var vye=ry,gye=ti,yye=VF;function xye(e,t){return e&&e.length?vye(e,gye(t),yye):void 0}var bye=xye;const jye=et(bye);var wye=["cx","cy","angle","ticks","axisLine"],Nye=["ticks","tick","angle","tickFormatter","stroke"];function Ic(e){"@babel/helpers - typeof";return Ic=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ic(e)}function Pd(){return Pd=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Sye(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function Oye(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function zE(e,t){for(var r=0;rVE?o=a==="outer"?"start":"end":s<-VE?o=a==="outer"?"end":"start":o="middle",o}},{key:"renderAxisLine",value:function(){var n=this.props,a=n.cx,s=n.cy,o=n.radius,l=n.axisLine,c=n.axisLineType,u=Ys(Ys({},xe(this.props,!1)),{},{fill:"none"},xe(l,!1));if(c==="circle")return M.createElement(Nh,ao({className:"recharts-polar-angle-axis-line"},u,{cx:a,cy:s,r:o}));var f=this.props.ticks,d=f.map(function(h){return gt(a,s,o,h.coordinate)});return M.createElement(eye,ao({className:"recharts-polar-angle-axis-line"},u,{points:d}))}},{key:"renderTicks",value:function(){var n=this,a=this.props,s=a.ticks,o=a.tick,l=a.tickLine,c=a.tickFormatter,u=a.stroke,f=xe(this.props,!1),d=xe(o,!1),h=Ys(Ys({},f),{},{fill:"none"},xe(l,!1)),p=s.map(function(y,v){var m=n.getTickLineCoord(y),x=n.getTickTextAnchor(y),g=Ys(Ys(Ys({textAnchor:x},f),{},{stroke:"none",fill:u},d),{},{index:v,payload:y,x:m.x2,y:m.y2});return M.createElement(Ue,ao({className:Me("recharts-polar-angle-axis-tick",x3(o)),key:"tick-".concat(y.coordinate)},Ho(n.props,y,v)),l&&M.createElement("line",ao({className:"recharts-polar-angle-axis-tick-line"},h,m)),o&&t.renderTickItem(o,g,c?c(y.value,v):y.value))});return M.createElement(Ue,{className:"recharts-polar-angle-axis-ticks"},p)}},{key:"render",value:function(){var n=this.props,a=n.ticks,s=n.radius,o=n.axisLine;return s<=0||!a||!a.length?null:M.createElement(Ue,{className:Me("recharts-polar-angle-axis",this.props.className)},o&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(n,a,s){var o;return M.isValidElement(n)?o=M.cloneElement(n,a):Oe(n)?o=n(a):o=M.createElement(Vo,ao({},a,{className:"recharts-polar-angle-axis-tick-value"}),s),o}}])}(j.PureComponent);ly(cy,"displayName","PolarAngleAxis");ly(cy,"axisType","angleAxis");ly(cy,"defaultProps",{type:"category",angleAxisId:0,scale:"auto",cx:0,cy:0,orientation:"outer",axisLine:!0,tickLine:!0,tickSize:8,tick:!0,hide:!1,allowDuplicatedCategory:!0});var Bye=BL,Uye=Bye(Object.getPrototypeOf,Object),zye=Uye,Wye=Di,Hye=zye,Vye=Mi,qye="[object Object]",Gye=Function.prototype,Kye=Object.prototype,L3=Gye.toString,Yye=Kye.hasOwnProperty,Qye=L3.call(Object);function Xye(e){if(!Vye(e)||Wye(e)!=qye)return!1;var t=Hye(e);if(t===null)return!0;var r=Yye.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&L3.call(r)==Qye}var Zye=Xye;const Jye=et(Zye);var exe=Di,txe=Mi,rxe="[object Boolean]";function nxe(e){return e===!0||e===!1||txe(e)&&exe(e)==rxe}var axe=nxe;const ixe=et(axe);function Of(e){"@babel/helpers - typeof";return Of=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Of(e)}function jv(){return jv=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r0,from:{upperWidth:0,lowerWidth:0,height:h,x:c,y:u},to:{upperWidth:f,lowerWidth:d,height:h,x:c,y:u},duration:v,animationEasing:y,isActive:x},function(b){var N=b.upperWidth,w=b.lowerWidth,S=b.height,O=b.x,P=b.y;return M.createElement(wa,{canBegin:o>0,from:"0px ".concat(o===-1?1:o,"px"),to:"".concat(o,"px 0px"),attributeName:"strokeDasharray",begin:m,duration:v,easing:y},M.createElement("path",jv({},xe(r,!0),{className:g,d:YE(O,P,N,w,S),ref:n})))}):M.createElement("g",null,M.createElement("path",jv({},xe(r,!0),{className:g,d:YE(c,u,f,d,h)})))},vxe=["option","shapeType","propTransformer","activeClassName","isActive"];function Pf(e){"@babel/helpers - typeof";return Pf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Pf(e)}function gxe(e,t){if(e==null)return{};var r=yxe(e,t),n,a;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function yxe(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function QE(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function wv(e){for(var t=1;t0?pn(b,"paddingAngle",0):0;if(w){var O=Qt(w.endAngle-w.startAngle,b.endAngle-b.startAngle),P=pt(pt({},b),{},{startAngle:g+S,endAngle:g+O(v)+S});m.push(P),g=P.endAngle}else{var A=b.endAngle,C=b.startAngle,T=Qt(0,A-C),D=T(v),_=pt(pt({},b),{},{startAngle:g+S,endAngle:g+D+S});m.push(_),g=_.endAngle}}),M.createElement(Ue,null,n.renderSectorsStatically(m))})}},{key:"attachKeyboardHandlers",value:function(n){var a=this;n.onkeydown=function(s){if(!s.altKey)switch(s.key){case"ArrowLeft":{var o=++a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[o].focus(),a.setState({sectorToFocus:o});break}case"ArrowRight":{var l=--a.state.sectorToFocus<0?a.sectorRefs.length-1:a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[l].focus(),a.setState({sectorToFocus:l});break}case"Escape":{a.sectorRefs[a.state.sectorToFocus].blur(),a.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var n=this.props,a=n.sectors,s=n.isAnimationActive,o=this.state.prevSectors;return s&&a&&a.length&&(!o||!qo(o,a))?this.renderSectorsWithAnimation():this.renderSectorsStatically(a)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var n=this,a=this.props,s=a.hide,o=a.sectors,l=a.className,c=a.label,u=a.cx,f=a.cy,d=a.innerRadius,h=a.outerRadius,p=a.isAnimationActive,y=this.state.isAnimationFinished;if(s||!o||!o.length||!se(u)||!se(f)||!se(d)||!se(h))return null;var v=Me("recharts-pie",l);return M.createElement(Ue,{tabIndex:this.props.rootTabIndex,className:v,ref:function(x){n.pieRef=x}},this.renderSectors(),c&&this.renderLabels(o),nr.renderCallByParent(this.props,null,!1),(!p||y)&&qa.renderCallByParent(this.props,o,!1))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return a.prevIsAnimationActive!==n.isAnimationActive?{prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:[],isAnimationFinished:!0}:n.isAnimationActive&&n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:a.curSectors,isAnimationFinished:!0}:n.sectors!==a.curSectors?{curSectors:n.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(n,a){return n>a?"start":n=360?g:g-1)*c,N=m-g*p-b,w=a.reduce(function(P,A){var C=It(A,x,0);return P+(se(C)?C:0)},0),S;if(w>0){var O;S=a.map(function(P,A){var C=It(P,x,0),T=It(P,f,A),D=(se(C)?C:0)/w,_;A?_=O.endAngle+Er(v)*c*(C!==0?1:0):_=o;var k=_+Er(v)*((C!==0?p:0)+D*N),R=(_+k)/2,$=(y.innerRadius+y.outerRadius)/2,I=[{name:T,value:C,payload:P,dataKey:x,type:h}],E=gt(y.cx,y.cy,$,R);return O=pt(pt(pt({percent:D,cornerRadius:s,name:T,tooltipPayload:I,midAngle:R,middleRadius:$,tooltipPosition:E},P),y),{},{value:It(P,x),startAngle:_,endAngle:k,payload:P,paddingAngle:Er(v)*c}),O})}return pt(pt({},y),{},{sectors:S,data:a})});var Fxe=Math.ceil,Bxe=Math.max;function Uxe(e,t,r,n){for(var a=-1,s=Bxe(Fxe((t-e)/(r||1)),0),o=Array(s);s--;)o[n?s:++a]=e,e+=r;return o}var zxe=Uxe,Wxe=iF,eT=1/0,Hxe=17976931348623157e292;function Vxe(e){if(!e)return e===0?e:0;if(e=Wxe(e),e===eT||e===-eT){var t=e<0?-1:1;return t*Hxe}return e===e?e:0}var z3=Vxe,qxe=zxe,Gxe=Kg,o0=z3;function Kxe(e){return function(t,r,n){return n&&typeof n!="number"&&Gxe(t,r,n)&&(r=n=void 0),t=o0(t),r===void 0?(r=t,t=0):r=o0(r),n=n===void 0?t0&&n.handleDrag(a.changedTouches[0])}),rn(n,"handleDragEnd",function(){n.setState({isTravellerMoving:!1,isSlideMoving:!1},function(){var a=n.props,s=a.endIndex,o=a.onDragEnd,l=a.startIndex;o==null||o({endIndex:s,startIndex:l})}),n.detachDragEndListener()}),rn(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),rn(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),rn(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),rn(n,"handleSlideDragStart",function(a){var s=iT(a)?a.changedTouches[0]:a;n.setState({isTravellerMoving:!1,isSlideMoving:!0,slideMoveStartX:s.pageX}),n.attachDragEndListener()}),n.travellerDragStartHandlers={startX:n.handleTravellerDragStart.bind(n,"startX"),endX:n.handleTravellerDragStart.bind(n,"endX")},n.state={},n}return l0e(t,e),a0e(t,[{key:"componentWillUnmount",value:function(){this.leaveTimer&&(clearTimeout(this.leaveTimer),this.leaveTimer=null),this.detachDragEndListener()}},{key:"getIndex",value:function(n){var a=n.startX,s=n.endX,o=this.state.scaleValues,l=this.props,c=l.gap,u=l.data,f=u.length-1,d=Math.min(a,s),h=Math.max(a,s),p=t.getIndexInRange(o,d),y=t.getIndexInRange(o,h);return{startIndex:p-p%c,endIndex:y===f?f:y-y%c}}},{key:"getTextOfTick",value:function(n){var a=this.props,s=a.data,o=a.tickFormatter,l=a.dataKey,c=It(s[n],l,n);return Oe(o)?o(c,n):c}},{key:"attachDragEndListener",value:function(){window.addEventListener("mouseup",this.handleDragEnd,!0),window.addEventListener("touchend",this.handleDragEnd,!0),window.addEventListener("mousemove",this.handleDrag,!0)}},{key:"detachDragEndListener",value:function(){window.removeEventListener("mouseup",this.handleDragEnd,!0),window.removeEventListener("touchend",this.handleDragEnd,!0),window.removeEventListener("mousemove",this.handleDrag,!0)}},{key:"handleSlideDrag",value:function(n){var a=this.state,s=a.slideMoveStartX,o=a.startX,l=a.endX,c=this.props,u=c.x,f=c.width,d=c.travellerWidth,h=c.startIndex,p=c.endIndex,y=c.onChange,v=n.pageX-s;v>0?v=Math.min(v,u+f-d-l,u+f-d-o):v<0&&(v=Math.max(v,u-o,u-l));var m=this.getIndex({startX:o+v,endX:l+v});(m.startIndex!==h||m.endIndex!==p)&&y&&y(m),this.setState({startX:o+v,endX:l+v,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,a){var s=iT(a)?a.changedTouches[0]:a;this.setState({isSlideMoving:!1,isTravellerMoving:!0,movingTravellerId:n,brushMoveStartX:s.pageX}),this.attachDragEndListener()}},{key:"handleTravellerMove",value:function(n){var a=this.state,s=a.brushMoveStartX,o=a.movingTravellerId,l=a.endX,c=a.startX,u=this.state[o],f=this.props,d=f.x,h=f.width,p=f.travellerWidth,y=f.onChange,v=f.gap,m=f.data,x={startX:this.state.startX,endX:this.state.endX},g=n.pageX-s;g>0?g=Math.min(g,d+h-p-u):g<0&&(g=Math.max(g,d-u)),x[o]=u+g;var b=this.getIndex(x),N=b.startIndex,w=b.endIndex,S=function(){var P=m.length-1;return o==="startX"&&(l>c?N%v===0:w%v===0)||lc?w%v===0:N%v===0)||l>c&&w===P};this.setState(rn(rn({},o,u+g),"brushMoveStartX",n.pageX),function(){y&&S()&&y(b)})}},{key:"handleTravellerMoveKeyboard",value:function(n,a){var s=this,o=this.state,l=o.scaleValues,c=o.startX,u=o.endX,f=this.state[a],d=l.indexOf(f);if(d!==-1){var h=d+n;if(!(h===-1||h>=l.length)){var p=l[h];a==="startX"&&p>=u||a==="endX"&&p<=c||this.setState(rn({},a,p),function(){s.props.onChange(s.getIndex({startX:s.state.startX,endX:s.state.endX}))})}}}},{key:"renderBackground",value:function(){var n=this.props,a=n.x,s=n.y,o=n.width,l=n.height,c=n.fill,u=n.stroke;return M.createElement("rect",{stroke:u,fill:c,x:a,y:s,width:o,height:l})}},{key:"renderPanorama",value:function(){var n=this.props,a=n.x,s=n.y,o=n.width,l=n.height,c=n.data,u=n.children,f=n.padding,d=j.Children.only(u);return d?M.cloneElement(d,{x:a,y:s,width:o,height:l,margin:f,compact:!0,data:c}):null}},{key:"renderTravellerLayer",value:function(n,a){var s,o,l=this,c=this.props,u=c.y,f=c.travellerWidth,d=c.height,h=c.traveller,p=c.ariaLabel,y=c.data,v=c.startIndex,m=c.endIndex,x=Math.max(n,this.props.x),g=l0(l0({},xe(this.props,!1)),{},{x,y:u,width:f,height:d}),b=p||"Min value: ".concat((s=y[v])===null||s===void 0?void 0:s.name,", Max value: ").concat((o=y[m])===null||o===void 0?void 0:o.name);return M.createElement(Ue,{tabIndex:0,role:"slider","aria-label":b,"aria-valuenow":n,className:"recharts-brush-traveller",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.travellerDragStartHandlers[a],onTouchStart:this.travellerDragStartHandlers[a],onKeyDown:function(w){["ArrowLeft","ArrowRight"].includes(w.key)&&(w.preventDefault(),w.stopPropagation(),l.handleTravellerMoveKeyboard(w.key==="ArrowRight"?1:-1,a))},onFocus:function(){l.setState({isTravellerFocused:!0})},onBlur:function(){l.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},t.renderTraveller(h,g))}},{key:"renderSlide",value:function(n,a){var s=this.props,o=s.y,l=s.height,c=s.stroke,u=s.travellerWidth,f=Math.min(n,a)+u,d=Math.max(Math.abs(a-n)-u,0);return M.createElement("rect",{className:"recharts-brush-slide",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.handleSlideDragStart,onTouchStart:this.handleSlideDragStart,style:{cursor:"move"},stroke:"none",fill:c,fillOpacity:.2,x:f,y:o,width:d,height:l})}},{key:"renderText",value:function(){var n=this.props,a=n.startIndex,s=n.endIndex,o=n.y,l=n.height,c=n.travellerWidth,u=n.stroke,f=this.state,d=f.startX,h=f.endX,p=5,y={pointerEvents:"none",fill:u};return M.createElement(Ue,{className:"recharts-brush-texts"},M.createElement(Vo,Ov({textAnchor:"end",verticalAnchor:"middle",x:Math.min(d,h)-p,y:o+l/2},y),this.getTextOfTick(a)),M.createElement(Vo,Ov({textAnchor:"start",verticalAnchor:"middle",x:Math.max(d,h)+c+p,y:o+l/2},y),this.getTextOfTick(s)))}},{key:"render",value:function(){var n=this.props,a=n.data,s=n.className,o=n.children,l=n.x,c=n.y,u=n.width,f=n.height,d=n.alwaysShowText,h=this.state,p=h.startX,y=h.endX,v=h.isTextActive,m=h.isSlideMoving,x=h.isTravellerMoving,g=h.isTravellerFocused;if(!a||!a.length||!se(l)||!se(c)||!se(u)||!se(f)||u<=0||f<=0)return null;var b=Me("recharts-brush",s),N=M.Children.count(o)===1,w=r0e("userSelect","none");return M.createElement(Ue,{className:b,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:w},this.renderBackground(),N&&this.renderPanorama(),this.renderSlide(p,y),this.renderTravellerLayer(p,"startX"),this.renderTravellerLayer(y,"endX"),(v||m||x||g||d)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(n){var a=n.x,s=n.y,o=n.width,l=n.height,c=n.stroke,u=Math.floor(s+l/2)-1;return M.createElement(M.Fragment,null,M.createElement("rect",{x:a,y:s,width:o,height:l,fill:c,stroke:"none"}),M.createElement("line",{x1:a+1,y1:u,x2:a+o-1,y2:u,fill:"none",stroke:"#fff"}),M.createElement("line",{x1:a+1,y1:u+2,x2:a+o-1,y2:u+2,fill:"none",stroke:"#fff"}))}},{key:"renderTraveller",value:function(n,a){var s;return M.isValidElement(n)?s=M.cloneElement(n,a):Oe(n)?s=n(a):s=t.renderDefaultTraveller(a),s}},{key:"getDerivedStateFromProps",value:function(n,a){var s=n.data,o=n.width,l=n.x,c=n.travellerWidth,u=n.updateId,f=n.startIndex,d=n.endIndex;if(s!==a.prevData||u!==a.prevUpdateId)return l0({prevData:s,prevTravellerWidth:c,prevUpdateId:u,prevX:l,prevWidth:o},s&&s.length?u0e({data:s,width:o,x:l,travellerWidth:c,startIndex:f,endIndex:d}):{scale:null,scaleValues:null});if(a.scale&&(o!==a.prevWidth||l!==a.prevX||c!==a.prevTravellerWidth)){a.scale.range([l,l+o-c]);var h=a.scale.domain().map(function(p){return a.scale(p)});return{prevData:s,prevTravellerWidth:c,prevUpdateId:u,prevX:l,prevWidth:o,startX:a.scale(n.startIndex),endX:a.scale(n.endIndex),scaleValues:h}}return null}},{key:"getIndexInRange",value:function(n,a){for(var s=n.length,o=0,l=s-1;l-o>1;){var c=Math.floor((o+l)/2);n[c]>a?l=c:o=c}return a>=n[l]?l:o}}])}(j.PureComponent);rn(Fc,"displayName","Brush");rn(Fc,"defaultProps",{height:40,travellerWidth:5,gap:1,fill:"#fff",stroke:"#666",padding:{top:1,right:1,bottom:1,left:1},leaveTimeOut:1e3,alwaysShowText:!1});var d0e=sS;function f0e(e,t){var r;return d0e(e,function(n,a,s){return r=t(n,a,s),!r}),!!r}var h0e=f0e,p0e=_L,m0e=ti,v0e=h0e,g0e=en,y0e=Kg;function x0e(e,t,r){var n=g0e(e)?p0e:v0e;return r&&y0e(e,t,r)&&(t=void 0),n(e,m0e(t))}var b0e=x0e;const j0e=et(b0e);var Ga=function(t,r){var n=t.alwaysShow,a=t.ifOverflow;return n&&(a="extendDomain"),a===r},sT=eF;function w0e(e,t,r){t=="__proto__"&&sT?sT(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var N0e=w0e,S0e=N0e,O0e=ZL,P0e=ti;function A0e(e,t){var r={};return t=P0e(t),O0e(e,function(n,a,s){S0e(r,a,t(n,a,s))}),r}var C0e=A0e;const E0e=et(C0e);function T0e(e,t){for(var r=-1,n=e==null?0:e.length;++r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function G0e(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function K0e(e,t){var r=e.x,n=e.y,a=q0e(e,z0e),s="".concat(r),o=parseInt(s,10),l="".concat(n),c=parseInt(l,10),u="".concat(t.height||a.height),f=parseInt(u,10),d="".concat(t.width||a.width),h=parseInt(d,10);return Zu(Zu(Zu(Zu(Zu({},t),a),o?{x:o}:{}),c?{y:c}:{}),{},{height:f,width:h,name:t.name,radius:t.radius})}function lT(e){return M.createElement(F3,hw({shapeType:"rectangle",propTransformer:K0e,activeClassName:"recharts-active-bar"},e))}var Y0e=function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return function(n,a){if(typeof t=="number")return t;var s=typeof n=="number";return s?t(n,a):(s||ks(),r)}},Q0e=["value","background"],G3;function Bc(e){"@babel/helpers - typeof";return Bc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bc(e)}function X0e(e,t){if(e==null)return{};var r=Z0e(e,t),n,a;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Z0e(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function Av(){return Av=Object.assign?Object.assign.bind():function(e){for(var t=1;t0&&Math.abs(R)0&&Math.abs(k)0&&(_=Math.min((ne||0)-(k[le-1]||0),_))}),Number.isFinite(_)){var R=_/D,$=v.layout==="vertical"?n.height:n.width;if(v.padding==="gap"&&(O=R*$/2),v.padding==="no-gap"){var I=Tr(t.barCategoryGap,R*$),E=R*$/2;O=E-I-(E-I)/$*I}}}a==="xAxis"?P=[n.left+(b.left||0)+(O||0),n.left+n.width-(b.right||0)-(O||0)]:a==="yAxis"?P=c==="horizontal"?[n.top+n.height-(b.bottom||0),n.top+(b.top||0)]:[n.top+(b.top||0)+(O||0),n.top+n.height-(b.bottom||0)-(O||0)]:P=v.range,w&&(P=[P[1],P[0]]);var F=f3(v,s,h),V=F.scale,G=F.realScaleType;V.domain(x).range(P),h3(V);var K=p3(V,ra(ra({},v),{},{realScaleType:G}));a==="xAxis"?(T=m==="top"&&!N||m==="bottom"&&N,A=n.left,C=d[S]-T*v.height):a==="yAxis"&&(T=m==="left"&&!N||m==="right"&&N,A=d[S]-T*v.width,C=n.top);var q=ra(ra(ra({},v),K),{},{realScaleType:G,x:A,y:C,scale:V,width:a==="xAxis"?n.width:v.width,height:a==="yAxis"?n.height:v.height});return q.bandSize=dv(q,K),!v.hide&&a==="xAxis"?d[S]+=(T?-1:1)*q.height:v.hide||(d[S]+=(T?-1:1)*q.width),ra(ra({},p),{},fy({},y,q))},{})},X3=function(t,r){var n=t.x,a=t.y,s=r.x,o=r.y;return{x:Math.min(n,s),y:Math.min(a,o),width:Math.abs(s-n),height:Math.abs(o-a)}},cbe=function(t){var r=t.x1,n=t.y1,a=t.x2,s=t.y2;return X3({x:r,y:n},{x:a,y:s})},Z3=function(){function e(t){sbe(this,e),this.scale=t}return obe(e,[{key:"domain",get:function(){return this.scale.domain}},{key:"range",get:function(){return this.scale.range}},{key:"rangeMin",get:function(){return this.range()[0]}},{key:"rangeMax",get:function(){return this.range()[1]}},{key:"bandwidth",get:function(){return this.scale.bandwidth}},{key:"apply",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=n.bandAware,s=n.position;if(r!==void 0){if(s)switch(s){case"start":return this.scale(r);case"middle":{var o=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+o}case"end":{var l=this.bandwidth?this.bandwidth():0;return this.scale(r)+l}default:return this.scale(r)}if(a){var c=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+c}return this.scale(r)}}},{key:"isInRange",value:function(r){var n=this.range(),a=n[0],s=n[n.length-1];return a<=s?r>=a&&r<=s:r>=s&&r<=a}}],[{key:"create",value:function(r){return new e(r)}}])}();fy(Z3,"EPS",1e-4);var RS=function(t){var r=Object.keys(t).reduce(function(n,a){return ra(ra({},n),{},fy({},a,Z3.create(t[a])))},{});return ra(ra({},r),{},{apply:function(a){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=s.bandAware,l=s.position;return E0e(a,function(c,u){return r[u].apply(c,{bandAware:o,position:l})})},isInRange:function(a){return q3(a,function(s,o){return r[o].isInRange(s)})}})};function ube(e){return(e%180+180)%180}var dbe=function(t){var r=t.width,n=t.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=ube(a),o=s*Math.PI/180,l=Math.atan(n/r),c=o>l&&o-1?a[s?t[o]:o]:void 0}}var vbe=mbe,gbe=z3;function ybe(e){var t=gbe(e),r=t%1;return t===t?r?t-r:t:0}var xbe=ybe,bbe=qL,jbe=ti,wbe=xbe,Nbe=Math.max;function Sbe(e,t,r){var n=e==null?0:e.length;if(!n)return-1;var a=r==null?0:wbe(r);return a<0&&(a=Nbe(n+a,0)),bbe(e,jbe(t),a)}var Obe=Sbe,Pbe=vbe,Abe=Obe,Cbe=Pbe(Abe),Ebe=Cbe;const Tbe=et(Ebe);var kbe=AZ(function(e){return{x:e.left,y:e.top,width:e.width,height:e.height}},function(e){return["l",e.left,"t",e.top,"w",e.width,"h",e.height].join("")}),$S=j.createContext(void 0),LS=j.createContext(void 0),J3=j.createContext(void 0),e6=j.createContext({}),t6=j.createContext(void 0),r6=j.createContext(0),n6=j.createContext(0),hT=function(t){var r=t.state,n=r.xAxisMap,a=r.yAxisMap,s=r.offset,o=t.clipPathId,l=t.children,c=t.width,u=t.height,f=kbe(s);return M.createElement($S.Provider,{value:n},M.createElement(LS.Provider,{value:a},M.createElement(e6.Provider,{value:s},M.createElement(J3.Provider,{value:f},M.createElement(t6.Provider,{value:o},M.createElement(r6.Provider,{value:u},M.createElement(n6.Provider,{value:c},l)))))))},_be=function(){return j.useContext(t6)},a6=function(t){var r=j.useContext($S);r==null&&ks();var n=r[t];return n==null&&ks(),n},Dbe=function(){var t=j.useContext($S);return Yi(t)},Mbe=function(){var t=j.useContext(LS),r=Tbe(t,function(n){return q3(n.domain,Number.isFinite)});return r||Yi(t)},i6=function(t){var r=j.useContext(LS);r==null&&ks();var n=r[t];return n==null&&ks(),n},Ibe=function(){var t=j.useContext(J3);return t},Rbe=function(){return j.useContext(e6)},FS=function(){return j.useContext(n6)},BS=function(){return j.useContext(r6)};function Uc(e){"@babel/helpers - typeof";return Uc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Uc(e)}function $be(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Lbe(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);re*a)return!1;var s=r();return e*(t-e*s/2-n)>=0&&e*(t+e*s/2-a)<=0}function xje(e,t){return f6(e,t+1)}function bje(e,t,r,n,a){for(var s=(n||[]).slice(),o=t.start,l=t.end,c=0,u=1,f=o,d=function(){var y=n==null?void 0:n[c];if(y===void 0)return{v:f6(n,u)};var v=c,m,x=function(){return m===void 0&&(m=r(y,v)),m},g=y.coordinate,b=c===0||_v(e,g,x,f,l);b||(c=0,f=o,u+=1),b&&(f=g+e*(x()/2+a),c+=u)},h;u<=s.length;)if(h=d(),h)return h.v;return[]}function kf(e){"@babel/helpers - typeof";return kf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},kf(e)}function jT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function xr(e){for(var t=1;t0?p.coordinate-m*e:p.coordinate})}else s[h]=p=xr(xr({},p),{},{tickCoord:p.coordinate});var x=_v(e,p.tickCoord,v,l,c);x&&(c=p.tickCoord-e*(v()/2+a),s[h]=xr(xr({},p),{},{isShow:!0}))},f=o-1;f>=0;f--)u(f);return s}function Oje(e,t,r,n,a,s){var o=(n||[]).slice(),l=o.length,c=t.start,u=t.end;if(s){var f=n[l-1],d=r(f,l-1),h=e*(f.coordinate+e*d/2-u);o[l-1]=f=xr(xr({},f),{},{tickCoord:h>0?f.coordinate-h*e:f.coordinate});var p=_v(e,f.tickCoord,function(){return d},c,u);p&&(u=f.tickCoord-e*(d/2+a),o[l-1]=xr(xr({},f),{},{isShow:!0}))}for(var y=s?l-1:l,v=function(g){var b=o[g],N,w=function(){return N===void 0&&(N=r(b,g)),N};if(g===0){var S=e*(b.coordinate-e*w()/2-c);o[g]=b=xr(xr({},b),{},{tickCoord:S<0?b.coordinate-S*e:b.coordinate})}else o[g]=b=xr(xr({},b),{},{tickCoord:b.coordinate});var O=_v(e,b.tickCoord,w,c,u);O&&(c=b.tickCoord+e*(w()/2+a),o[g]=xr(xr({},b),{},{isShow:!0}))},m=0;m=2?Er(a[1].coordinate-a[0].coordinate):1,x=yje(s,m,p);return c==="equidistantPreserveStart"?bje(m,x,v,a,o):(c==="preserveStart"||c==="preserveStartEnd"?h=Oje(m,x,v,a,o,c==="preserveStartEnd"):h=Sje(m,x,v,a,o),h.filter(function(g){return g.isShow}))}var Pje=["viewBox"],Aje=["viewBox"],Cje=["ticks"];function Hc(e){"@babel/helpers - typeof";return Hc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Hc(e)}function Tl(){return Tl=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Eje(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function Tje(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function NT(e,t){for(var r=0;r0?c(this.props):c(p)),o<=0||l<=0||!y||!y.length?null:M.createElement(Ue,{className:Me("recharts-cartesian-axis",u),ref:function(m){n.layerReference=m}},s&&this.renderAxisLine(),this.renderTicks(y,this.state.fontSize,this.state.letterSpacing),nr.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(n,a,s){var o;return M.isValidElement(n)?o=M.cloneElement(n,a):Oe(n)?o=n(a):o=M.createElement(Vo,Tl({},a,{className:"recharts-cartesian-axis-tick-value"}),s),o}}])}(j.Component);HS(Su,"displayName","CartesianAxis");HS(Su,"defaultProps",{x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd"});var $je=["x1","y1","x2","y2","key"],Lje=["offset"];function Ko(e){"@babel/helpers - typeof";return Ko=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ko(e)}function ST(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function jr(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function zje(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}var Wje=function(t){var r=t.fill;if(!r||r==="none")return null;var n=t.fillOpacity,a=t.x,s=t.y,o=t.width,l=t.height,c=t.ry;return M.createElement("rect",{x:a,y:s,ry:c,width:o,height:l,stroke:"none",fill:r,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function m6(e,t){var r;if(M.isValidElement(e))r=M.cloneElement(e,t);else if(Oe(e))r=e(t);else{var n=t.x1,a=t.y1,s=t.x2,o=t.y2,l=t.key,c=OT(t,$je),u=xe(c,!1);u.offset;var f=OT(u,Lje);r=M.createElement("line",fo({},f,{x1:n,y1:a,x2:s,y2:o,fill:"none",key:l}))}return r}function Hje(e){var t=e.x,r=e.width,n=e.horizontal,a=n===void 0?!0:n,s=e.horizontalPoints;if(!a||!s||!s.length)return null;var o=s.map(function(l,c){var u=jr(jr({},e),{},{x1:t,y1:l,x2:t+r,y2:l,key:"line-".concat(c),index:c});return m6(a,u)});return M.createElement("g",{className:"recharts-cartesian-grid-horizontal"},o)}function Vje(e){var t=e.y,r=e.height,n=e.vertical,a=n===void 0?!0:n,s=e.verticalPoints;if(!a||!s||!s.length)return null;var o=s.map(function(l,c){var u=jr(jr({},e),{},{x1:l,y1:t,x2:l,y2:t+r,key:"line-".concat(c),index:c});return m6(a,u)});return M.createElement("g",{className:"recharts-cartesian-grid-vertical"},o)}function qje(e){var t=e.horizontalFill,r=e.fillOpacity,n=e.x,a=e.y,s=e.width,o=e.height,l=e.horizontalPoints,c=e.horizontal,u=c===void 0?!0:c;if(!u||!t||!t.length)return null;var f=l.map(function(h){return Math.round(h+a-a)}).sort(function(h,p){return h-p});a!==f[0]&&f.unshift(0);var d=f.map(function(h,p){var y=!f[p+1],v=y?a+o-h:f[p+1]-h;if(v<=0)return null;var m=p%t.length;return M.createElement("rect",{key:"react-".concat(p),y:h,x:n,height:v,width:s,stroke:"none",fill:t[m],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return M.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function Gje(e){var t=e.vertical,r=t===void 0?!0:t,n=e.verticalFill,a=e.fillOpacity,s=e.x,o=e.y,l=e.width,c=e.height,u=e.verticalPoints;if(!r||!n||!n.length)return null;var f=u.map(function(h){return Math.round(h+s-s)}).sort(function(h,p){return h-p});s!==f[0]&&f.unshift(0);var d=f.map(function(h,p){var y=!f[p+1],v=y?s+l-h:f[p+1]-h;if(v<=0)return null;var m=p%n.length;return M.createElement("rect",{key:"react-".concat(p),x:h,y:o,width:v,height:c,stroke:"none",fill:n[m],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return M.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var Kje=function(t,r){var n=t.xAxis,a=t.width,s=t.height,o=t.offset;return d3(WS(jr(jr(jr({},Su.defaultProps),n),{},{ticks:pi(n,!0),viewBox:{x:0,y:0,width:a,height:s}})),o.left,o.left+o.width,r)},Yje=function(t,r){var n=t.yAxis,a=t.width,s=t.height,o=t.offset;return d3(WS(jr(jr(jr({},Su.defaultProps),n),{},{ticks:pi(n,!0),viewBox:{x:0,y:0,width:a,height:s}})),o.top,o.top+o.height,r)},dl={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function ud(e){var t,r,n,a,s,o,l=FS(),c=BS(),u=Rbe(),f=jr(jr({},e),{},{stroke:(t=e.stroke)!==null&&t!==void 0?t:dl.stroke,fill:(r=e.fill)!==null&&r!==void 0?r:dl.fill,horizontal:(n=e.horizontal)!==null&&n!==void 0?n:dl.horizontal,horizontalFill:(a=e.horizontalFill)!==null&&a!==void 0?a:dl.horizontalFill,vertical:(s=e.vertical)!==null&&s!==void 0?s:dl.vertical,verticalFill:(o=e.verticalFill)!==null&&o!==void 0?o:dl.verticalFill,x:se(e.x)?e.x:u.left,y:se(e.y)?e.y:u.top,width:se(e.width)?e.width:u.width,height:se(e.height)?e.height:u.height}),d=f.x,h=f.y,p=f.width,y=f.height,v=f.syncWithTicks,m=f.horizontalValues,x=f.verticalValues,g=Dbe(),b=Mbe();if(!se(p)||p<=0||!se(y)||y<=0||!se(d)||d!==+d||!se(h)||h!==+h)return null;var N=f.verticalCoordinatesGenerator||Kje,w=f.horizontalCoordinatesGenerator||Yje,S=f.horizontalPoints,O=f.verticalPoints;if((!S||!S.length)&&Oe(w)){var P=m&&m.length,A=w({yAxis:b?jr(jr({},b),{},{ticks:P?m:b.ticks}):void 0,width:l,height:c,offset:u},P?!0:v);pa(Array.isArray(A),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(Ko(A),"]")),Array.isArray(A)&&(S=A)}if((!O||!O.length)&&Oe(N)){var C=x&&x.length,T=N({xAxis:g?jr(jr({},g),{},{ticks:C?x:g.ticks}):void 0,width:l,height:c,offset:u},C?!0:v);pa(Array.isArray(T),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(Ko(T),"]")),Array.isArray(T)&&(O=T)}return M.createElement("g",{className:"recharts-cartesian-grid"},M.createElement(Wje,{fill:f.fill,fillOpacity:f.fillOpacity,x:f.x,y:f.y,width:f.width,height:f.height,ry:f.ry}),M.createElement(Hje,fo({},f,{offset:u,horizontalPoints:S,xAxis:g,yAxis:b})),M.createElement(Vje,fo({},f,{offset:u,verticalPoints:O,xAxis:g,yAxis:b})),M.createElement(qje,fo({},f,{horizontalPoints:S})),M.createElement(Gje,fo({},f,{verticalPoints:O})))}ud.displayName="CartesianGrid";var Qje=["type","layout","connectNulls","ref"],Xje=["key"];function Vc(e){"@babel/helpers - typeof";return Vc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Vc(e)}function PT(e,t){if(e==null)return{};var r=Zje(e,t),n,a;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Zje(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function Ad(){return Ad=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);rd){p=[].concat(fl(c.slice(0,y)),[d-v]);break}var m=p.length%2===0?[0,h]:[h];return[].concat(fl(t.repeat(c,f)),fl(p),m).map(function(x){return"".concat(x,"px")}).join(", ")}),na(r,"id",Jo("recharts-line-")),na(r,"pathRef",function(o){r.mainCurve=o}),na(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0}),r.props.onAnimationEnd&&r.props.onAnimationEnd()}),na(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1}),r.props.onAnimationStart&&r.props.onAnimationStart()}),r}return lwe(t,e),awe(t,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();this.setState({totalLength:n})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();n!==this.state.totalLength&&this.setState({totalLength:n})}}},{key:"getTotalLength",value:function(){var n=this.mainCurve;try{return n&&n.getTotalLength&&n.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(n,a){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var s=this.props,o=s.points,l=s.xAxis,c=s.yAxis,u=s.layout,f=s.children,d=mn(f,wh);if(!d)return null;var h=function(v,m){return{x:v.x,y:v.y,value:v.value,errorVal:It(v.payload,m)}},p={clipPath:n?"url(#clipPath-".concat(a,")"):null};return M.createElement(Ue,p,d.map(function(y){return M.cloneElement(y,{key:"bar-".concat(y.props.dataKey),data:o,xAxis:l,yAxis:c,layout:u,dataPointFormatter:h})}))}},{key:"renderDots",value:function(n,a,s){var o=this.props.isAnimationActive;if(o&&!this.state.isAnimationFinished)return null;var l=this.props,c=l.dot,u=l.points,f=l.dataKey,d=xe(this.props,!1),h=xe(c,!0),p=u.map(function(v,m){var x=tn(tn(tn({key:"dot-".concat(m),r:3},d),h),{},{index:m,cx:v.x,cy:v.y,value:v.value,dataKey:f,payload:v.payload,points:u});return t.renderDotItem(c,x)}),y={clipPath:n?"url(#clipPath-".concat(a?"":"dots-").concat(s,")"):null};return M.createElement(Ue,Ad({className:"recharts-line-dots",key:"dots"},y),p)}},{key:"renderCurveStatically",value:function(n,a,s,o){var l=this.props,c=l.type,u=l.layout,f=l.connectNulls;l.ref;var d=PT(l,Qje),h=tn(tn(tn({},xe(d,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:a?"url(#clipPath-".concat(s,")"):null,points:n},o),{},{type:c,layout:u,connectNulls:f});return M.createElement(Ao,Ad({},h,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(n,a){var s=this,o=this.props,l=o.points,c=o.strokeDasharray,u=o.isAnimationActive,f=o.animationBegin,d=o.animationDuration,h=o.animationEasing,p=o.animationId,y=o.animateNewValues,v=o.width,m=o.height,x=this.state,g=x.prevPoints,b=x.totalLength;return M.createElement(wa,{begin:f,duration:d,isActive:u,easing:h,from:{t:0},to:{t:1},key:"line-".concat(p),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(N){var w=N.t;if(g){var S=g.length/l.length,O=l.map(function(D,_){var k=Math.floor(_*S);if(g[k]){var R=g[k],$=Qt(R.x,D.x),I=Qt(R.y,D.y);return tn(tn({},D),{},{x:$(w),y:I(w)})}if(y){var E=Qt(v*2,D.x),F=Qt(m/2,D.y);return tn(tn({},D),{},{x:E(w),y:F(w)})}return tn(tn({},D),{},{x:D.x,y:D.y})});return s.renderCurveStatically(O,n,a)}var P=Qt(0,b),A=P(w),C;if(c){var T="".concat(c).split(/[,\s]+/gim).map(function(D){return parseFloat(D)});C=s.getStrokeDasharray(A,b,T)}else C=s.generateSimpleStrokeDasharray(b,A);return s.renderCurveStatically(l,n,a,{strokeDasharray:C})})}},{key:"renderCurve",value:function(n,a){var s=this.props,o=s.points,l=s.isAnimationActive,c=this.state,u=c.prevPoints,f=c.totalLength;return l&&o&&o.length&&(!u&&f>0||!qo(u,o))?this.renderCurveWithAnimation(n,a):this.renderCurveStatically(o,n,a)}},{key:"render",value:function(){var n,a=this.props,s=a.hide,o=a.dot,l=a.points,c=a.className,u=a.xAxis,f=a.yAxis,d=a.top,h=a.left,p=a.width,y=a.height,v=a.isAnimationActive,m=a.id;if(s||!l||!l.length)return null;var x=this.state.isAnimationFinished,g=l.length===1,b=Me("recharts-line",c),N=u&&u.allowDataOverflow,w=f&&f.allowDataOverflow,S=N||w,O=Ee(m)?this.id:m,P=(n=xe(o,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},A=P.r,C=A===void 0?3:A,T=P.strokeWidth,D=T===void 0?2:T,_=nL(o)?o:{},k=_.clipDot,R=k===void 0?!0:k,$=C*2+D;return M.createElement(Ue,{className:b},N||w?M.createElement("defs",null,M.createElement("clipPath",{id:"clipPath-".concat(O)},M.createElement("rect",{x:N?h:h-p/2,y:w?d:d-y/2,width:N?p:p*2,height:w?y:y*2})),!R&&M.createElement("clipPath",{id:"clipPath-dots-".concat(O)},M.createElement("rect",{x:h-$/2,y:d-$/2,width:p+$,height:y+$}))):null,!g&&this.renderCurve(S,O),this.renderErrorBar(S,O),(g||o)&&this.renderDots(S,R,O),(!v||x)&&qa.renderCallByParent(this.props,l))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curPoints:n.points,prevPoints:a.curPoints}:n.points!==a.curPoints?{curPoints:n.points}:null}},{key:"repeat",value:function(n,a){for(var s=n.length%2!==0?[].concat(fl(n),[0]):n,o=[],l=0;l=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function fwe(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function ho(){return ho=Object.assign?Object.assign.bind():function(e){for(var t=1;t0||!qo(f,o)||!qo(d,l))?this.renderAreaWithAnimation(n,a):this.renderAreaStatically(o,l,n,a)}},{key:"render",value:function(){var n,a=this.props,s=a.hide,o=a.dot,l=a.points,c=a.className,u=a.top,f=a.left,d=a.xAxis,h=a.yAxis,p=a.width,y=a.height,v=a.isAnimationActive,m=a.id;if(s||!l||!l.length)return null;var x=this.state.isAnimationFinished,g=l.length===1,b=Me("recharts-area",c),N=d&&d.allowDataOverflow,w=h&&h.allowDataOverflow,S=N||w,O=Ee(m)?this.id:m,P=(n=xe(o,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},A=P.r,C=A===void 0?3:A,T=P.strokeWidth,D=T===void 0?2:T,_=nL(o)?o:{},k=_.clipDot,R=k===void 0?!0:k,$=C*2+D;return M.createElement(Ue,{className:b},N||w?M.createElement("defs",null,M.createElement("clipPath",{id:"clipPath-".concat(O)},M.createElement("rect",{x:N?f:f-p/2,y:w?u:u-y/2,width:N?p:p*2,height:w?y:y*2})),!R&&M.createElement("clipPath",{id:"clipPath-dots-".concat(O)},M.createElement("rect",{x:f-$/2,y:u-$/2,width:p+$,height:y+$}))):null,g?null:this.renderArea(S,O),(o||g)&&this.renderDots(S,R,O),(!v||x)&&qa.renderCallByParent(this.props,l))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curPoints:n.points,curBaseLine:n.baseLine,prevPoints:a.curPoints,prevBaseLine:a.curBaseLine}:n.points!==a.curPoints||n.baseLine!==a.curBaseLine?{curPoints:n.points,curBaseLine:n.baseLine}:null}}])}(j.PureComponent);y6=Vs;Fa(Vs,"displayName","Area");Fa(Vs,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!ma.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});Fa(Vs,"getBaseValue",function(e,t,r,n){var a=e.layout,s=e.baseValue,o=t.props.baseValue,l=o??s;if(se(l)&&typeof l=="number")return l;var c=a==="horizontal"?n:r,u=c.scale.domain();if(c.type==="number"){var f=Math.max(u[0],u[1]),d=Math.min(u[0],u[1]);return l==="dataMin"?d:l==="dataMax"||f<0?f:Math.max(Math.min(u[0],u[1]),0)}return l==="dataMin"?u[0]:l==="dataMax"?u[1]:u[0]});Fa(Vs,"getComposedData",function(e){var t=e.props,r=e.item,n=e.xAxis,a=e.yAxis,s=e.xAxisTicks,o=e.yAxisTicks,l=e.bandSize,c=e.dataKey,u=e.stackedData,f=e.dataStartIndex,d=e.displayedData,h=e.offset,p=t.layout,y=u&&u.length,v=y6.getBaseValue(t,r,n,a),m=p==="horizontal",x=!1,g=d.map(function(N,w){var S;y?S=u[f+w]:(S=It(N,c),Array.isArray(S)?x=!0:S=[v,S]);var O=S[1]==null||y&&It(N,c)==null;return m?{x:uv({axis:n,ticks:s,bandSize:l,entry:N,index:w}),y:O?null:a.scale(S[1]),value:S,payload:N}:{x:O?null:n.scale(S[1]),y:uv({axis:a,ticks:o,bandSize:l,entry:N,index:w}),value:S,payload:N}}),b;return y||x?b=g.map(function(N){var w=Array.isArray(N.value)?N.value[0]:null;return m?{x:N.x,y:w!=null&&N.y!=null?a.scale(w):null}:{x:w!=null?n.scale(w):null,y:N.y}}):b=m?a.scale(v):n.scale(v),Wi({points:g,baseLine:b,layout:p,isRange:x},h)});Fa(Vs,"renderDotItem",function(e,t){var r;if(M.isValidElement(e))r=M.cloneElement(e,t);else if(Oe(e))r=e(t);else{var n=Me("recharts-area-dot",typeof e!="boolean"?e.className:""),a=t.key,s=x6(t,dwe);r=M.createElement(Nh,ho({},s,{key:a,className:n}))}return r});function Gc(e){"@babel/helpers - typeof";return Gc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Gc(e)}function bwe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function jwe(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function o1e(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function l1e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c1e(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r0?o:t&&t.length&&se(a)&&se(s)?t.slice(a,s+1):[]};function I6(e){return e==="number"?[0,"auto"]:void 0}var Dw=function(t,r,n,a){var s=t.graphicalItems,o=t.tooltipAxis,l=gy(r,t);return n<0||!s||!s.length||n>=l.length?null:s.reduce(function(c,u){var f,d=(f=u.props.data)!==null&&f!==void 0?f:r;d&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=n&&(d=d.slice(t.dataStartIndex,t.dataEndIndex+1));var h;if(o.dataKey&&!o.allowDuplicatedCategory){var p=d===void 0?l:d;h=Rm(p,o.dataKey,a)}else h=d&&d[n]||l[n];return h?[].concat(Qc(c),[v3(u,h)]):c},[])},RT=function(t,r,n,a){var s=a||{x:t.chartX,y:t.chartY},o=j1e(s,n),l=t.orderedTooltipTicks,c=t.tooltipAxis,u=t.tooltipTicks,f=Dpe(o,l,u,c);if(f>=0&&u){var d=u[f]&&u[f].value,h=Dw(t,r,f,d),p=w1e(n,l,f,s);return{activeTooltipIndex:f,activeLabel:d,activePayload:h,activeCoordinate:p}}return null},N1e=function(t,r){var n=r.axes,a=r.graphicalItems,s=r.axisType,o=r.axisIdKey,l=r.stackGroups,c=r.dataStartIndex,u=r.dataEndIndex,f=t.layout,d=t.children,h=t.stackOffset,p=u3(f,s);return n.reduce(function(y,v){var m,x=v.type.defaultProps!==void 0?Q(Q({},v.type.defaultProps),v.props):v.props,g=x.type,b=x.dataKey,N=x.allowDataOverflow,w=x.allowDuplicatedCategory,S=x.scale,O=x.ticks,P=x.includeHidden,A=x[o];if(y[A])return y;var C=gy(t.data,{graphicalItems:a.filter(function(K){var q,ne=o in K.props?K.props[o]:(q=K.type.defaultProps)===null||q===void 0?void 0:q[o];return ne===A}),dataStartIndex:c,dataEndIndex:u}),T=C.length,D,_,k;Ywe(x.domain,N,g)&&(D=Vj(x.domain,null,N),p&&(g==="number"||S!=="auto")&&(k=Nd(C,b,"category")));var R=I6(g);if(!D||D.length===0){var $,I=($=x.domain)!==null&&$!==void 0?$:R;if(b){if(D=Nd(C,b,g),g==="category"&&p){var E=SJ(D);w&&E?(_=D,D=Sv(0,T)):w||(D=rE(I,D,v).reduce(function(K,q){return K.indexOf(q)>=0?K:[].concat(Qc(K),[q])},[]))}else if(g==="category")w?D=D.filter(function(K){return K!==""&&!Ee(K)}):D=rE(I,D,v).reduce(function(K,q){return K.indexOf(q)>=0||q===""||Ee(q)?K:[].concat(Qc(K),[q])},[]);else if(g==="number"){var F=Lpe(C,a.filter(function(K){var q,ne,le=o in K.props?K.props[o]:(q=K.type.defaultProps)===null||q===void 0?void 0:q[o],de="hide"in K.props?K.props.hide:(ne=K.type.defaultProps)===null||ne===void 0?void 0:ne.hide;return le===A&&(P||!de)}),b,s,f);F&&(D=F)}p&&(g==="number"||S!=="auto")&&(k=Nd(C,b,"category"))}else p?D=Sv(0,T):l&&l[A]&&l[A].hasStack&&g==="number"?D=h==="expand"?[0,1]:m3(l[A].stackGroups,c,u):D=c3(C,a.filter(function(K){var q=o in K.props?K.props[o]:K.type.defaultProps[o],ne="hide"in K.props?K.props.hide:K.type.defaultProps.hide;return q===A&&(P||!ne)}),g,f,!0);if(g==="number")D=Tw(d,D,A,s,O),I&&(D=Vj(I,D,N));else if(g==="category"&&I){var V=I,G=D.every(function(K){return V.indexOf(K)>=0});G&&(D=V)}}return Q(Q({},y),{},Se({},A,Q(Q({},x),{},{axisType:s,domain:D,categoricalDomain:k,duplicateDomain:_,originalDomain:(m=x.domain)!==null&&m!==void 0?m:R,isCategorical:p,layout:f})))},{})},S1e=function(t,r){var n=r.graphicalItems,a=r.Axis,s=r.axisType,o=r.axisIdKey,l=r.stackGroups,c=r.dataStartIndex,u=r.dataEndIndex,f=t.layout,d=t.children,h=gy(t.data,{graphicalItems:n,dataStartIndex:c,dataEndIndex:u}),p=h.length,y=u3(f,s),v=-1;return n.reduce(function(m,x){var g=x.type.defaultProps!==void 0?Q(Q({},x.type.defaultProps),x.props):x.props,b=g[o],N=I6("number");if(!m[b]){v++;var w;return y?w=Sv(0,p):l&&l[b]&&l[b].hasStack?(w=m3(l[b].stackGroups,c,u),w=Tw(d,w,b,s)):(w=Vj(N,c3(h,n.filter(function(S){var O,P,A=o in S.props?S.props[o]:(O=S.type.defaultProps)===null||O===void 0?void 0:O[o],C="hide"in S.props?S.props.hide:(P=S.type.defaultProps)===null||P===void 0?void 0:P.hide;return A===b&&!C}),"number",f),a.defaultProps.allowDataOverflow),w=Tw(d,w,b,s)),Q(Q({},m),{},Se({},b,Q(Q({axisType:s},a.defaultProps),{},{hide:!0,orientation:pn(x1e,"".concat(s,".").concat(v%2),null),domain:w,originalDomain:N,isCategorical:y,layout:f})))}return m},{})},O1e=function(t,r){var n=r.axisType,a=n===void 0?"xAxis":n,s=r.AxisComp,o=r.graphicalItems,l=r.stackGroups,c=r.dataStartIndex,u=r.dataEndIndex,f=t.children,d="".concat(a,"Id"),h=mn(f,s),p={};return h&&h.length?p=N1e(t,{axes:h,graphicalItems:o,axisType:a,axisIdKey:d,stackGroups:l,dataStartIndex:c,dataEndIndex:u}):o&&o.length&&(p=S1e(t,{Axis:s,graphicalItems:o,axisType:a,axisIdKey:d,stackGroups:l,dataStartIndex:c,dataEndIndex:u})),p},P1e=function(t){var r=Yi(t),n=pi(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:oS(n,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:dv(r,n)}},$T=function(t){var r=t.children,n=t.defaultShowTooltip,a=sn(r,Fc),s=0,o=0;return t.data&&t.data.length!==0&&(o=t.data.length-1),a&&a.props&&(a.props.startIndex>=0&&(s=a.props.startIndex),a.props.endIndex>=0&&(o=a.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:s,dataEndIndex:o,activeTooltipIndex:-1,isTooltipActive:!!n}},A1e=function(t){return!t||!t.length?!1:t.some(function(r){var n=yi(r&&r.type);return n&&n.indexOf("Bar")>=0})},LT=function(t){return t==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:t==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:t==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},C1e=function(t,r){var n=t.props,a=t.graphicalItems,s=t.xAxisMap,o=s===void 0?{}:s,l=t.yAxisMap,c=l===void 0?{}:l,u=n.width,f=n.height,d=n.children,h=n.margin||{},p=sn(d,Fc),y=sn(d,Ql),v=Object.keys(c).reduce(function(w,S){var O=c[S],P=O.orientation;return!O.mirror&&!O.hide?Q(Q({},w),{},Se({},P,w[P]+O.width)):w},{left:h.left||0,right:h.right||0}),m=Object.keys(o).reduce(function(w,S){var O=o[S],P=O.orientation;return!O.mirror&&!O.hide?Q(Q({},w),{},Se({},P,pn(w,"".concat(P))+O.height)):w},{top:h.top||0,bottom:h.bottom||0}),x=Q(Q({},m),v),g=x.bottom;p&&(x.bottom+=p.props.height||Fc.defaultProps.height),y&&r&&(x=Rpe(x,a,n,r));var b=u-x.left-x.right,N=f-x.top-x.bottom;return Q(Q({brushBottom:g},x),{},{width:Math.max(b,0),height:Math.max(N,0)})},E1e=function(t,r){if(r==="xAxis")return t[r].width;if(r==="yAxis")return t[r].height},yy=function(t){var r=t.chartName,n=t.GraphicalChild,a=t.defaultTooltipEventType,s=a===void 0?"axis":a,o=t.validateTooltipEventTypes,l=o===void 0?["axis"]:o,c=t.axisComponents,u=t.legendContent,f=t.formatAxisMap,d=t.defaultProps,h=function(x,g){var b=g.graphicalItems,N=g.stackGroups,w=g.offset,S=g.updateId,O=g.dataStartIndex,P=g.dataEndIndex,A=x.barSize,C=x.layout,T=x.barGap,D=x.barCategoryGap,_=x.maxBarSize,k=LT(C),R=k.numericAxisName,$=k.cateAxisName,I=A1e(b),E=[];return b.forEach(function(F,V){var G=gy(x.data,{graphicalItems:[F],dataStartIndex:O,dataEndIndex:P}),K=F.type.defaultProps!==void 0?Q(Q({},F.type.defaultProps),F.props):F.props,q=K.dataKey,ne=K.maxBarSize,le=K["".concat(R,"Id")],de=K["".concat($,"Id")],ie={},ve=c.reduce(function(Pa,Aa){var nl=g["".concat(Aa.axisType,"Map")],Cu=K["".concat(Aa.axisType,"Id")];nl&&nl[Cu]||Aa.axisType==="zAxis"||ks();var jO=nl[Cu];return Q(Q({},Pa),{},Se(Se({},Aa.axisType,jO),"".concat(Aa.axisType,"Ticks"),pi(jO)))},ie),re=ve[$],Y=ve["".concat($,"Ticks")],Z=N&&N[le]&&N[le].hasStack&&Gpe(F,N[le].stackGroups),L=yi(F.type).indexOf("Bar")>=0,ce=dv(re,Y),ye=[],We=I&&Mpe({barSize:A,stackGroups:N,totalSize:E1e(ve,$)});if(L){var Je,ht,Lr=Ee(ne)?_:ne,Vt=(Je=(ht=dv(re,Y,!0))!==null&&ht!==void 0?ht:Lr)!==null&&Je!==void 0?Je:0;ye=Ipe({barGap:T,barCategoryGap:D,bandSize:Vt!==ce?Vt:ce,sizeList:We[de],maxBarSize:Lr}),Vt!==ce&&(ye=ye.map(function(Pa){return Q(Q({},Pa),{},{position:Q(Q({},Pa.position),{},{offset:Pa.position.offset-Vt/2})})}))}var Yn=F&&F.type&&F.type.getComposedData;Yn&&E.push({props:Q(Q({},Yn(Q(Q({},ve),{},{displayedData:G,props:x,dataKey:q,item:F,bandSize:ce,barPosition:ye,offset:w,stackedData:Z,layout:C,dataStartIndex:O,dataEndIndex:P}))),{},Se(Se(Se({key:F.key||"item-".concat(V)},R,ve[R]),$,ve[$]),"animationId",S)),childIndex:IJ(F,x.children),item:F})}),E},p=function(x,g){var b=x.props,N=x.dataStartIndex,w=x.dataEndIndex,S=x.updateId;if(!QA({props:b}))return null;var O=b.children,P=b.layout,A=b.stackOffset,C=b.data,T=b.reverseStackOrder,D=LT(P),_=D.numericAxisName,k=D.cateAxisName,R=mn(O,n),$=Vpe(C,R,"".concat(_,"Id"),"".concat(k,"Id"),A,T),I=c.reduce(function(K,q){var ne="".concat(q.axisType,"Map");return Q(Q({},K),{},Se({},ne,O1e(b,Q(Q({},q),{},{graphicalItems:R,stackGroups:q.axisType===_&&$,dataStartIndex:N,dataEndIndex:w}))))},{}),E=C1e(Q(Q({},I),{},{props:b,graphicalItems:R}),g==null?void 0:g.legendBBox);Object.keys(I).forEach(function(K){I[K]=f(b,I[K],E,K.replace("Map",""),r)});var F=I["".concat(k,"Map")],V=P1e(F),G=h(b,Q(Q({},I),{},{dataStartIndex:N,dataEndIndex:w,updateId:S,graphicalItems:R,stackGroups:$,offset:E}));return Q(Q({formattedGraphicalItems:G,graphicalItems:R,offset:E,stackGroups:$},V),I)},y=function(m){function x(g){var b,N,w;return l1e(this,x),w=d1e(this,x,[g]),Se(w,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),Se(w,"accessibilityManager",new Kwe),Se(w,"handleLegendBBoxUpdate",function(S){if(S){var O=w.state,P=O.dataStartIndex,A=O.dataEndIndex,C=O.updateId;w.setState(Q({legendBBox:S},p({props:w.props,dataStartIndex:P,dataEndIndex:A,updateId:C},Q(Q({},w.state),{},{legendBBox:S}))))}}),Se(w,"handleReceiveSyncEvent",function(S,O,P){if(w.props.syncId===S){if(P===w.eventEmitterSymbol&&typeof w.props.syncMethod!="function")return;w.applySyncEvent(O)}}),Se(w,"handleBrushChange",function(S){var O=S.startIndex,P=S.endIndex;if(O!==w.state.dataStartIndex||P!==w.state.dataEndIndex){var A=w.state.updateId;w.setState(function(){return Q({dataStartIndex:O,dataEndIndex:P},p({props:w.props,dataStartIndex:O,dataEndIndex:P,updateId:A},w.state))}),w.triggerSyncEvent({dataStartIndex:O,dataEndIndex:P})}}),Se(w,"handleMouseEnter",function(S){var O=w.getMouseInfo(S);if(O){var P=Q(Q({},O),{},{isTooltipActive:!0});w.setState(P),w.triggerSyncEvent(P);var A=w.props.onMouseEnter;Oe(A)&&A(P,S)}}),Se(w,"triggeredAfterMouseMove",function(S){var O=w.getMouseInfo(S),P=O?Q(Q({},O),{},{isTooltipActive:!0}):{isTooltipActive:!1};w.setState(P),w.triggerSyncEvent(P);var A=w.props.onMouseMove;Oe(A)&&A(P,S)}),Se(w,"handleItemMouseEnter",function(S){w.setState(function(){return{isTooltipActive:!0,activeItem:S,activePayload:S.tooltipPayload,activeCoordinate:S.tooltipPosition||{x:S.cx,y:S.cy}}})}),Se(w,"handleItemMouseLeave",function(){w.setState(function(){return{isTooltipActive:!1}})}),Se(w,"handleMouseMove",function(S){S.persist(),w.throttleTriggeredAfterMouseMove(S)}),Se(w,"handleMouseLeave",function(S){w.throttleTriggeredAfterMouseMove.cancel();var O={isTooltipActive:!1};w.setState(O),w.triggerSyncEvent(O);var P=w.props.onMouseLeave;Oe(P)&&P(O,S)}),Se(w,"handleOuterEvent",function(S){var O=MJ(S),P=pn(w.props,"".concat(O));if(O&&Oe(P)){var A,C;/.*touch.*/i.test(O)?C=w.getMouseInfo(S.changedTouches[0]):C=w.getMouseInfo(S),P((A=C)!==null&&A!==void 0?A:{},S)}}),Se(w,"handleClick",function(S){var O=w.getMouseInfo(S);if(O){var P=Q(Q({},O),{},{isTooltipActive:!0});w.setState(P),w.triggerSyncEvent(P);var A=w.props.onClick;Oe(A)&&A(P,S)}}),Se(w,"handleMouseDown",function(S){var O=w.props.onMouseDown;if(Oe(O)){var P=w.getMouseInfo(S);O(P,S)}}),Se(w,"handleMouseUp",function(S){var O=w.props.onMouseUp;if(Oe(O)){var P=w.getMouseInfo(S);O(P,S)}}),Se(w,"handleTouchMove",function(S){S.changedTouches!=null&&S.changedTouches.length>0&&w.throttleTriggeredAfterMouseMove(S.changedTouches[0])}),Se(w,"handleTouchStart",function(S){S.changedTouches!=null&&S.changedTouches.length>0&&w.handleMouseDown(S.changedTouches[0])}),Se(w,"handleTouchEnd",function(S){S.changedTouches!=null&&S.changedTouches.length>0&&w.handleMouseUp(S.changedTouches[0])}),Se(w,"handleDoubleClick",function(S){var O=w.props.onDoubleClick;if(Oe(O)){var P=w.getMouseInfo(S);O(P,S)}}),Se(w,"handleContextMenu",function(S){var O=w.props.onContextMenu;if(Oe(O)){var P=w.getMouseInfo(S);O(P,S)}}),Se(w,"triggerSyncEvent",function(S){w.props.syncId!==void 0&&u0.emit(d0,w.props.syncId,S,w.eventEmitterSymbol)}),Se(w,"applySyncEvent",function(S){var O=w.props,P=O.layout,A=O.syncMethod,C=w.state.updateId,T=S.dataStartIndex,D=S.dataEndIndex;if(S.dataStartIndex!==void 0||S.dataEndIndex!==void 0)w.setState(Q({dataStartIndex:T,dataEndIndex:D},p({props:w.props,dataStartIndex:T,dataEndIndex:D,updateId:C},w.state)));else if(S.activeTooltipIndex!==void 0){var _=S.chartX,k=S.chartY,R=S.activeTooltipIndex,$=w.state,I=$.offset,E=$.tooltipTicks;if(!I)return;if(typeof A=="function")R=A(E,S);else if(A==="value"){R=-1;for(var F=0;F=0){var Z,L;if(_.dataKey&&!_.allowDuplicatedCategory){var ce=typeof _.dataKey=="function"?Y:"payload.".concat(_.dataKey.toString());Z=Rm(F,ce,R),L=V&&G&&Rm(G,ce,R)}else Z=F==null?void 0:F[k],L=V&&G&&G[k];if(de||le){var ye=S.props.activeIndex!==void 0?S.props.activeIndex:k;return[j.cloneElement(S,Q(Q(Q({},A.props),ve),{},{activeIndex:ye})),null,null]}if(!Ee(Z))return[re].concat(Qc(w.renderActivePoints({item:A,activePoint:Z,basePoint:L,childIndex:k,isRange:V})))}else{var We,Je=(We=w.getItemByXY(w.state.activeCoordinate))!==null&&We!==void 0?We:{graphicalItem:re},ht=Je.graphicalItem,Lr=ht.item,Vt=Lr===void 0?S:Lr,Yn=ht.childIndex,Pa=Q(Q(Q({},A.props),ve),{},{activeIndex:Yn});return[j.cloneElement(Vt,Pa),null,null]}return V?[re,null,null]:[re,null]}),Se(w,"renderCustomized",function(S,O,P){return j.cloneElement(S,Q(Q({key:"recharts-customized-".concat(P)},w.props),w.state))}),Se(w,"renderMap",{CartesianGrid:{handler:Sp,once:!0},ReferenceArea:{handler:w.renderReferenceElement},ReferenceLine:{handler:Sp},ReferenceDot:{handler:w.renderReferenceElement},XAxis:{handler:Sp},YAxis:{handler:Sp},Brush:{handler:w.renderBrush,once:!0},Bar:{handler:w.renderGraphicChild},Line:{handler:w.renderGraphicChild},Area:{handler:w.renderGraphicChild},Radar:{handler:w.renderGraphicChild},RadialBar:{handler:w.renderGraphicChild},Scatter:{handler:w.renderGraphicChild},Pie:{handler:w.renderGraphicChild},Funnel:{handler:w.renderGraphicChild},Tooltip:{handler:w.renderCursor,once:!0},PolarGrid:{handler:w.renderPolarGrid,once:!0},PolarAngleAxis:{handler:w.renderPolarAxis},PolarRadiusAxis:{handler:w.renderPolarAxis},Customized:{handler:w.renderCustomized}}),w.clipPathId="".concat((b=g.id)!==null&&b!==void 0?b:Jo("recharts"),"-clip"),w.throttleTriggeredAfterMouseMove=sF(w.triggeredAfterMouseMove,(N=g.throttleDelay)!==null&&N!==void 0?N:1e3/60),w.state={},w}return p1e(x,m),u1e(x,[{key:"componentDidMount",value:function(){var b,N;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(b=this.props.margin.left)!==null&&b!==void 0?b:0,top:(N=this.props.margin.top)!==null&&N!==void 0?N:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var b=this.props,N=b.children,w=b.data,S=b.height,O=b.layout,P=sn(N,Wr);if(P){var A=P.props.defaultIndex;if(!(typeof A!="number"||A<0||A>this.state.tooltipTicks.length-1)){var C=this.state.tooltipTicks[A]&&this.state.tooltipTicks[A].value,T=Dw(this.state,w,A,C),D=this.state.tooltipTicks[A].coordinate,_=(this.state.offset.top+S)/2,k=O==="horizontal",R=k?{x:D,y:_}:{y:D,x:_},$=this.state.formattedGraphicalItems.find(function(E){var F=E.item;return F.type.name==="Scatter"});$&&(R=Q(Q({},R),$.props.points[A].tooltipPosition),T=$.props.points[A].tooltipPayload);var I={activeTooltipIndex:A,isTooltipActive:!0,activeLabel:C,activePayload:T,activeCoordinate:R};this.setState(I),this.renderCursor(P),this.accessibilityManager.setIndex(A)}}}},{key:"getSnapshotBeforeUpdate",value:function(b,N){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==N.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==b.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==b.margin){var w,S;this.accessibilityManager.setDetails({offset:{left:(w=this.props.margin.left)!==null&&w!==void 0?w:0,top:(S=this.props.margin.top)!==null&&S!==void 0?S:0}})}return null}},{key:"componentDidUpdate",value:function(b){sj([sn(b.children,Wr)],[sn(this.props.children,Wr)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var b=sn(this.props.children,Wr);if(b&&typeof b.props.shared=="boolean"){var N=b.props.shared?"axis":"item";return l.indexOf(N)>=0?N:s}return s}},{key:"getMouseInfo",value:function(b){if(!this.container)return null;var N=this.container,w=N.getBoundingClientRect(),S=oue(w),O={chartX:Math.round(b.pageX-S.left),chartY:Math.round(b.pageY-S.top)},P=w.width/N.offsetWidth||1,A=this.inRange(O.chartX,O.chartY,P);if(!A)return null;var C=this.state,T=C.xAxisMap,D=C.yAxisMap,_=this.getTooltipEventType(),k=RT(this.state,this.props.data,this.props.layout,A);if(_!=="axis"&&T&&D){var R=Yi(T).scale,$=Yi(D).scale,I=R&&R.invert?R.invert(O.chartX):null,E=$&&$.invert?$.invert(O.chartY):null;return Q(Q({},O),{},{xValue:I,yValue:E},k)}return k?Q(Q({},O),k):null}},{key:"inRange",value:function(b,N){var w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,S=this.props.layout,O=b/w,P=N/w;if(S==="horizontal"||S==="vertical"){var A=this.state.offset,C=O>=A.left&&O<=A.left+A.width&&P>=A.top&&P<=A.top+A.height;return C?{x:O,y:P}:null}var T=this.state,D=T.angleAxisMap,_=T.radiusAxisMap;if(D&&_){var k=Yi(D);return iE({x:O,y:P},k)}return null}},{key:"parseEventsOfWrapper",value:function(){var b=this.props.children,N=this.getTooltipEventType(),w=sn(b,Wr),S={};w&&N==="axis"&&(w.props.trigger==="click"?S={onClick:this.handleClick}:S={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var O=$m(this.props,this.handleOuterEvent);return Q(Q({},O),S)}},{key:"addListener",value:function(){u0.on(d0,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){u0.removeListener(d0,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(b,N,w){for(var S=this.state.formattedGraphicalItems,O=0,P=S.length;O({totalOrders:156,totalRevenue:89750.5,approvalRate:87.5,avgOrderValue:575.32,growthRate:12.3,topProducts:[{name:"Milk One",value:45,revenue:28500},{name:"Milk Two",value:32,revenue:21600},{name:"AR Formula",value:28,revenue:18200},{name:"LF Formula",value:25,revenue:16250},{name:"Milk Three",value:18,revenue:12100},{name:"Premature",value:8,revenue:5100}],salesByRegion:[{region:"Addis Ababa",orders:78,revenue:45600},{region:"Dire Dawa",orders:32,revenue:18400},{region:"Bahir Dar",orders:24,revenue:14200},{region:"Hawassa",orders:18,revenue:9800},{region:"Mekelle",orders:12,revenue:7200}],dailyTrends:[{date:"Jan 1",orders:8,revenue:4800},{date:"Jan 2",orders:12,revenue:7200},{date:"Jan 3",orders:15,revenue:9e3},{date:"Jan 4",orders:22,revenue:13200},{date:"Jan 5",orders:18,revenue:10800},{date:"Jan 6",orders:25,revenue:15e3},{date:"Jan 7",orders:28,revenue:16800}],businessSectors:[{sector:"Pharmacy",count:58,percentage:37.2},{sector:"Wholesale",count:34,percentage:21.8},{sector:"Supermarket",count:28,percentage:17.9},{sector:"Shop",count:22,percentage:14.1},{sector:"MCH",count:10,percentage:6.4},{sector:"Walking",count:4,percentage:2.6}],paymentTerms:[{term:"Credit",count:89,percentage:57.1},{term:"Cash",count:67,percentage:42.9}]})}),{data:a}=Fe({queryKey:["/api/analytics/sales-officers",t],queryFn:async()=>[{name:"Ahmed M.",orders:45,revenue:28750,approvalRate:92.5,avgOrderValue:639,growth:18.2},{name:"Fatima K.",orders:38,revenue:24200,approvalRate:89.5,avgOrderValue:637,growth:15.1},{name:"Mohammed A.",orders:32,revenue:18900,approvalRate:84.4,avgOrderValue:591,growth:8.7},{name:"Marta T.",orders:28,revenue:16100,approvalRate:85.7,avgOrderValue:575,growth:22.3},{name:"Daniel H.",orders:13,revenue:7800,approvalRate:76.9,avgOrderValue:600,growth:-5.2}]});if(!n)return i.jsx(W,{className:e,children:i.jsx(H,{className:"p-6",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"h-4 bg-muted animate-pulse rounded"}),i.jsx("div",{className:"h-4 bg-muted animate-pulse rounded w-3/4"}),i.jsx("div",{className:"h-4 bg-muted animate-pulse rounded w-1/2"})]})})});const s=l=>`ETB ${l.toFixed(2)}`,o=({title:l,value:c,change:u,icon:f,format:d="number"})=>{const h=p=>{switch(d){case"currency":return s(p);case"percentage":return`${p}%`;default:return p.toLocaleString()}};return i.jsx(W,{children:i.jsx(H,{className:"p-6",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:l}),i.jsx("p",{className:"text-2xl font-bold",children:h(c)}),u!==void 0&&i.jsxs("div",{className:ue("flex items-center text-sm",u>=0?"text-green-600":"text-red-600"),children:[u>=0?i.jsx(Mr,{className:"h-3 w-3 mr-1"}):i.jsx(Ul,{className:"h-3 w-3 mr-1"}),Math.abs(u),"% from last period"]})]}),i.jsx(f,{className:"h-8 w-8 text-muted-foreground"})]})})})};return i.jsxs("div",{className:ue("w-full space-y-6",e),children:[i.jsxs("div",{className:"flex items-center justify-between w-full",children:[i.jsx("h2",{className:"text-2xl font-bold",children:"Analytics Dashboard"}),i.jsx("div",{className:"flex gap-2",children:[{label:"7 Days",value:"7d"},{label:"30 Days",value:"30d"},{label:"90 Days",value:"90d"},{label:"1 Year",value:"1y"}].map(l=>i.jsx(z,{variant:t===l.value?"default":"outline",size:"sm",onClick:()=>r(l.value),children:l.label},l.value))})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[i.jsx(o,{title:"Total Orders",value:n.totalOrders,change:n.growthRate,icon:Ot}),i.jsx(o,{title:"Total Revenue",value:n.totalRevenue,change:15.8,icon:Ka,format:"currency"}),i.jsx(o,{title:"Approval Rate",value:n.approvalRate,change:2.1,icon:hg,format:"percentage"}),i.jsx(o,{title:"Avg Order Value",value:n.avgOrderValue,change:8.4,icon:Mr,format:"currency"})]}),i.jsxs(ja,{defaultValue:"overview",className:"space-y-4",children:[i.jsxs(Hn,{children:[i.jsx(Qe,{value:"overview",children:"Overview"}),i.jsx(Qe,{value:"products",children:"Products"}),i.jsx(Qe,{value:"regions",children:"Regions"}),i.jsx(Qe,{value:"performance",children:"Performance"})]}),i.jsx(Xe,{value:"overview",className:"space-y-4",children:i.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{children:"Daily Order Trends"})}),i.jsx(H,{children:i.jsx(Hu,{width:"100%",height:300,children:i.jsxs(_1e,{data:n.dailyTrends,children:[i.jsx(ud,{strokeDasharray:"3 3"}),i.jsx(mi,{dataKey:"date"}),i.jsx(Ra,{}),i.jsx(Wr,{}),i.jsx(Vs,{type:"monotone",dataKey:"orders",stroke:"#8884d8",fill:"#8884d8",fillOpacity:.6})]})})})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{children:"Revenue Trends"})}),i.jsx(H,{children:i.jsx(Hu,{width:"100%",height:300,children:i.jsxs(T1e,{data:n.dailyTrends,children:[i.jsx(ud,{strokeDasharray:"3 3"}),i.jsx(mi,{dataKey:"date"}),i.jsx(Ra,{}),i.jsx(Wr,{formatter:l=>s(Number(l))}),i.jsx(Sh,{type:"monotone",dataKey:"revenue",stroke:"#82ca9d",strokeWidth:2})]})})})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{children:"Orders by Business Sector"})}),i.jsx(H,{children:i.jsx(Hu,{width:"100%",height:300,children:i.jsxs(k1e,{children:[i.jsx(Ri,{data:n.businessSectors,cx:"50%",cy:"50%",labelLine:!1,label:({sector:l,percentage:c})=>`${l}: ${c}%`,outerRadius:80,fill:"#8884d8",dataKey:"count",children:n.businessSectors.map((l,c)=>i.jsx(Yg,{fill:BT[c%BT.length]},`cell-${c}`))}),i.jsx(Wr,{})]})})})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{children:"Payment Terms Distribution"})}),i.jsx(H,{className:"space-y-4",children:n.paymentTerms.map((l,c)=>i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex justify-between text-sm",children:[i.jsx("span",{className:"font-medium",children:l.term}),i.jsxs("span",{children:[l.count," orders (",l.percentage,"%)"]})]}),i.jsx($N,{value:l.percentage,className:"h-2"})]},l.term))})]})]})}),i.jsx(Xe,{value:"products",className:"space-y-4",children:i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{children:"Top Products Performance"})}),i.jsx(H,{children:i.jsx(Hu,{width:"100%",height:400,children:i.jsxs(FT,{data:n.topProducts,children:[i.jsx(ud,{strokeDasharray:"3 3"}),i.jsx(mi,{dataKey:"name"}),i.jsx(Ra,{yAxisId:"left"}),i.jsx(Ra,{yAxisId:"right",orientation:"right"}),i.jsx(Wr,{}),i.jsx(La,{yAxisId:"left",dataKey:"value",fill:"#8884d8",name:"Orders"}),i.jsx(La,{yAxisId:"right",dataKey:"revenue",fill:"#82ca9d",name:"Revenue ($)"})]})})})]})}),i.jsx(Xe,{value:"regions",className:"space-y-4",children:i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{children:"Sales by Region"})}),i.jsx(H,{children:i.jsx(Hu,{width:"100%",height:400,children:i.jsxs(FT,{data:n.salesByRegion,children:[i.jsx(ud,{strokeDasharray:"3 3"}),i.jsx(mi,{dataKey:"region"}),i.jsx(Ra,{}),i.jsx(Wr,{}),i.jsx(La,{dataKey:"orders",fill:"#8884d8",name:"Orders"}),i.jsx(La,{dataKey:"revenue",fill:"#82ca9d",name:"Revenue ($)"})]})})})]})}),i.jsx(Xe,{value:"performance",className:"space-y-4",children:a&&i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{children:"Sales Officer Performance"})}),i.jsx(H,{children:i.jsx("div",{className:"space-y-4",children:a.map((l,c)=>i.jsxs("div",{className:"p-4 border rounded-lg",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("h4",{className:"font-medium",children:l.name}),i.jsxs(te,{variant:l.growth>=0?"default":"destructive",children:[l.growth>=0?"+":"",l.growth,"%"]})]}),i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-muted-foreground",children:"Orders:"}),i.jsx("p",{className:"font-medium",children:l.orders})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-muted-foreground",children:"Revenue:"}),i.jsx("p",{className:"font-medium",children:s(l.revenue)})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-muted-foreground",children:"Approval Rate:"}),i.jsxs("p",{className:"font-medium",children:[l.approvalRate,"%"]})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-muted-foreground",children:"Avg Order:"}),i.jsx("p",{className:"font-medium",children:s(l.avgOrderValue)})]})]})]},l.name))})})]})})]})]})}function UT(){const{user:e}=Za(),[t,r]=j.useState("overview"),{data:n=[]}=Fe({queryKey:["/api/orders"]}),{data:a=[]}=Fe({queryKey:["/api/users"]}),{data:s}=Fe({queryKey:["/api/orders/stats"]});if(!e||!["super_admin","approver","management"].includes(e==null?void 0:e.role))return i.jsx("div",{className:"min-h-screen bg-slate-50 flex items-center justify-center",children:i.jsx(W,{className:"w-full max-w-md",children:i.jsxs(H,{className:"pt-6 text-center",children:[i.jsx("h2",{className:"text-xl font-semibold text-slate-800 mb-2",children:"Access Denied"}),i.jsx("p",{className:"text-slate-600",children:"You don't have permission to access reports."})]})})});const o=n.reduce((v,m)=>v+(parseFloat(m.totalAmount)||0),0),l=n.filter(v=>v.status==="approved").reduce((v,m)=>v+(parseFloat(m.totalAmount)||0),0),c=n.filter(v=>v.status==="pending").reduce((v,m)=>v+(parseFloat(m.totalAmount)||0),0),u=n.length>0?((s==null?void 0:s.approved)||0)/n.length*100:0,f=n.length>0?o/n.length:0,d=a.filter(v=>v.role==="sales_officer"),h=a.filter(v=>v.status==="approved"),p=[{id:"daily",title:"Daily Performance Report",description:"Yesterday's sales activity and performance metrics",icon:Dr,color:"bg-blue-500",timeframe:"daily"},{id:"weekly",title:"Weekly Sales Summary",description:"Past 7 days sales analysis and team performance",icon:Xr,color:"bg-green-500",timeframe:"weekly"},{id:"monthly",title:"Monthly Business Report",description:"Comprehensive monthly analysis and projections",icon:Mr,color:"bg-purple-500",timeframe:"monthly"},{id:"quarterly",title:"Quarterly Executive Summary",description:"Strategic overview and business insights",icon:V1,color:"bg-orange-500",timeframe:"quarterly"}],y=[{title:"Total Orders",value:(s==null?void 0:s.total)||0,icon:Et,color:"text-blue-600",bgColor:"bg-blue-50"},{title:"Total Revenue",value:Be(o),icon:Ka,color:"text-green-600",bgColor:"bg-green-50"},{title:"Conversion Rate",value:`${u.toFixed(1)}%`,icon:hg,color:"text-purple-600",bgColor:"bg-purple-50"},{title:"Active Users",value:h.length,icon:Ss,color:"text-orange-600",bgColor:"bg-orange-50"},{title:"Avg Order Value",value:Be(f),icon:Xr,color:"text-indigo-600",bgColor:"bg-indigo-50"},{title:"Pending Revenue",value:Be(c),icon:Pl,color:"text-yellow-600",bgColor:"bg-yellow-50"}];return i.jsxs("div",{className:"min-h-screen bg-slate-50",children:[i.jsx(ca,{}),i.jsxs("div",{className:"md:ml-64",children:[i.jsx(Ts,{}),i.jsxs("main",{className:"p-3 sm:p-6 pt-16 md:pt-6",children:[i.jsx("div",{className:"mb-6",children:i.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between space-y-4 sm:space-y-0",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-bold text-slate-800",children:"Management Reports"}),i.jsx("p",{className:"text-slate-600 mt-1",children:"Comprehensive sales analytics and business intelligence"})]}),i.jsx(So,{trigger:i.jsxs(z,{className:"bg-purple-600 hover:bg-purple-700",children:[i.jsx(Et,{className:"w-4 h-4 mr-2"}),"Generate Custom Report"]})})]})}),i.jsxs(ja,{value:t,onValueChange:r,children:[i.jsxs(Hn,{className:"grid w-full grid-cols-3",children:[i.jsx(Qe,{value:"overview",children:"Overview"}),i.jsx(Qe,{value:"analytics",children:"Analytics"}),i.jsx(Qe,{value:"templates",children:"Quick Reports"})]}),i.jsxs(Xe,{value:"overview",className:"space-y-6 mt-6",children:[i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:y.map((v,m)=>i.jsx(W,{children:i.jsx(H,{className:"p-6",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm font-medium text-slate-600",children:v.title}),i.jsx("p",{className:"text-2xl font-bold text-slate-900",children:v.value})]}),i.jsx("div",{className:`p-3 rounded-lg ${v.bgColor}`,children:i.jsx(v.icon,{className:`w-6 h-6 ${v.color}`})})]})})},m))}),i.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{className:"text-lg",children:"Order Status Distribution"})}),i.jsxs(H,{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx(te,{className:"bg-green-100 text-green-800",children:"Approved"}),i.jsxs("span",{className:"text-sm text-slate-600",children:[(s==null?void 0:s.approved)||0," orders"]})]}),i.jsx("span",{className:"font-semibold",children:Be(l)})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx(te,{className:"bg-yellow-100 text-yellow-800",children:"Pending"}),i.jsxs("span",{className:"text-sm text-slate-600",children:[(s==null?void 0:s.pending)||0," orders"]})]}),i.jsx("span",{className:"font-semibold",children:Be(c)})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx(te,{className:"bg-red-100 text-red-800",children:"Rejected"}),i.jsxs("span",{className:"text-sm text-slate-600",children:[(s==null?void 0:s.rejected)||0," orders"]})]}),i.jsx("span",{className:"font-semibold",children:"€0.00"})]})]})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{className:"text-lg",children:"Team Overview"})}),i.jsxs(H,{className:"space-y-3",children:[i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"text-3xl font-bold text-blue-600",children:d.length}),i.jsx("div",{className:"text-sm text-slate-600",children:"Active Sales Officers"})]}),i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"text-2xl font-semibold text-green-600",children:h.length}),i.jsx("div",{className:"text-sm text-slate-600",children:"Total Active Users"})]})]})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{className:"text-lg",children:"Revenue Insights"})}),i.jsxs(H,{className:"space-y-3",children:[i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"text-2xl font-bold text-green-600",children:Be(l)}),i.jsx("div",{className:"text-sm text-slate-600",children:"Confirmed Revenue"})]}),i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"text-xl font-semibold text-yellow-600",children:Be(c)}),i.jsx("div",{className:"text-sm text-slate-600",children:"Potential Revenue"})]})]})]})]})]}),i.jsx(Xe,{value:"analytics",className:"mt-6",children:i.jsx(R6,{})}),i.jsxs(Xe,{value:"templates",className:"space-y-6 mt-6",children:[i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:p.map(v=>i.jsxs(W,{className:"hover:shadow-lg transition-shadow cursor-pointer",children:[i.jsx(J,{children:i.jsxs("div",{className:"flex items-center space-x-3",children:[i.jsx("div",{className:`p-3 rounded-lg ${v.color} text-white`,children:i.jsx(v.icon,{className:"w-6 h-6"})}),i.jsxs("div",{children:[i.jsx(ee,{className:"text-lg",children:v.title}),i.jsx("p",{className:"text-sm text-slate-600 mt-1",children:v.description})]})]})}),i.jsx(H,{children:i.jsx(So,{trigger:i.jsxs(z,{variant:"outline",className:"w-full",children:[i.jsx(Ln,{className:"w-4 h-4 mr-2"}),"Generate ",v.title]})})})]},v.id))}),i.jsxs(W,{children:[i.jsxs(J,{children:[i.jsx(ee,{children:"Custom Report Builder"}),i.jsx("p",{className:"text-sm text-slate-600",children:"Create detailed reports with custom date ranges, filters, and categories"})]}),i.jsx(H,{children:i.jsx(So,{trigger:i.jsxs(z,{className:"bg-gradient-to-r from-purple-600 to-blue-600 hover:from-purple-700 hover:to-blue-700 text-white",children:[i.jsx(Xr,{className:"w-4 h-4 mr-2"}),"Launch Report Builder"]})})})]})]})]})]})]})]})}function zT({orderId:e,className:t}){const[r,n]=j.useState(!1),{data:a,isLoading:s}=Fe({queryKey:[`/api/orders/${e}`],enabled:!!e});if(s)return i.jsx(W,{className:t,children:i.jsx(H,{className:"p-6",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"h-4 bg-muted animate-pulse rounded"}),i.jsx("div",{className:"h-4 bg-muted animate-pulse rounded w-3/4"}),i.jsx("div",{className:"h-4 bg-muted animate-pulse rounded w-1/2"})]})})});if(!a)return i.jsx(W,{className:t,children:i.jsx(H,{className:"p-6",children:i.jsx("div",{className:"text-center text-muted-foreground",children:"Order not found"})})});const l=(()=>{const p=[{id:"created",title:"Order Created",description:"Order submitted by sales officer",icon:Ot,status:"completed",timestamp:a.createdAt,notes:`Created by ${a.salesOfficerName||"Sales Officer"}`},{id:"review",title:"Under Review",description:"Order is being reviewed by approver",icon:au,status:a.status==="pending"?"current":a.status==="approved"?"completed":"failed",timestamp:a.status!=="pending"?a.updatedAt:void 0,notes:a.approvalNotes}];return a.status==="approved"?p.push({id:"approved",title:"Order Approved",description:"Order has been approved and is ready for processing",icon:ct,status:"completed",timestamp:a.approvedAt||a.updatedAt,notes:a.approvalNotes||`Approved by ${a.approverName||"Approver"}`},{id:"processing",title:"Processing",description:"Order is being prepared for shipment",icon:wr,status:"current",timestamp:void 0,notes:"France Lait products being prepared"},{id:"shipped",title:"Shipped",description:"Order has been shipped to customer",icon:G1,status:"pending",timestamp:void 0,notes:"Tracking information will be provided"}):a.status==="rejected"&&p.push({id:"rejected",title:"Order Rejected",description:"Order has been rejected",icon:ar,status:"failed",timestamp:a.updatedAt,notes:a.approvalNotes||"Order did not meet approval criteria"}),p})(),c=l.findIndex(p=>p.status==="current"),u=c>=0?(c+1)/l.length*100:l.filter(p=>p.status==="completed").length/l.length*100,f=p=>{switch(p){case"completed":return"text-green-600 dark:text-green-400";case"current":return"text-blue-600 dark:text-blue-400";case"failed":return"text-red-600 dark:text-red-400";default:return"text-muted-foreground"}},d=p=>{const y={pending:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300",approved:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-300",rejected:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-300"};return i.jsx(te,{className:y[p]||"bg-gray-100 text-gray-800",children:p.charAt(0).toUpperCase()+p.slice(1)})},h=p=>{try{const y=new Date(p);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(y)}catch{return p}};return i.jsxs(W,{className:t,children:[i.jsx(J,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsxs(ee,{className:"text-lg",children:["Order #",a.orderNumber]}),i.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.customerName," • $",a.totalAmount]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[d(a.status),i.jsxs(z,{variant:"outline",size:"sm",onClick:()=>n(!r),children:[r?"Hide":"Show"," Details"]})]})]})}),i.jsxs(H,{className:"space-y-6",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex justify-between text-sm",children:[i.jsx("span",{className:"text-muted-foreground",children:"Progress"}),i.jsxs("span",{className:"font-medium",children:[Math.round(u),"%"]})]}),i.jsx($N,{value:u,className:"h-2"})]}),i.jsx("div",{className:"space-y-4",children:l.map((p,y)=>{const v=p.icon,m=y===l.length-1;return i.jsxs("div",{className:"relative",children:[i.jsxs("div",{className:"flex items-start gap-4",children:[i.jsx("div",{className:ue("flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center",p.status==="completed"?"bg-green-100 dark:bg-green-900":p.status==="current"?"bg-blue-100 dark:bg-blue-900":p.status==="failed"?"bg-red-100 dark:bg-red-900":"bg-muted"),children:i.jsx(v,{className:ue("h-4 w-4",f(p.status))})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("h4",{className:ue("font-medium",f(p.status)),children:p.title}),p.timestamp&&i.jsx("span",{className:"text-xs text-muted-foreground",children:h(p.timestamp)})]}),i.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:p.description}),p.notes&&r&&i.jsx("p",{className:"text-xs text-muted-foreground mt-2 p-2 bg-muted/50 rounded",children:p.notes})]})]}),!m&&i.jsx("div",{className:ue("absolute left-4 top-8 w-px h-6 -translate-x-1/2",p.status==="completed"?"bg-green-200 dark:bg-green-800":"bg-muted")})]},p.id)})}),r&&i.jsxs(i.Fragment,{children:[i.jsx(yN,{}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("h4",{className:"font-medium",children:"Order Details"}),i.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-muted-foreground",children:"Customer:"}),i.jsx("p",{className:"font-medium",children:a.customerName})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-muted-foreground",children:"TIN:"}),i.jsx("p",{className:"font-medium",children:a.customerTinNumber})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-muted-foreground",children:"Mobile:"}),i.jsx("p",{className:"font-medium",children:a.customerMobileNumber})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-muted-foreground",children:"Area:"}),i.jsx("p",{className:"font-medium",children:a.customerArea})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-muted-foreground",children:"Payment:"}),i.jsx("p",{className:"font-medium capitalize",children:a.paymentTerm})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-muted-foreground",children:"Sector:"}),i.jsx("p",{className:"font-medium capitalize",children:a.businessSector})]})]}),a.items&&Array.isArray(a.items)&&i.jsxs("div",{children:[i.jsx("span",{className:"text-muted-foreground text-sm",children:"Products:"}),i.jsx("div",{className:"mt-1 space-y-1",children:a.items.map((p,y)=>i.jsxs("div",{className:"text-sm flex justify-between",children:[i.jsxs("span",{children:[p.productType," (",p.unit,")"]}),i.jsxs("span",{children:[p.quantity," × $",p.price," = $",p.total]})]},y))})]})]})]})]})]})}function Op(){const{user:e}=qn(),[t,r]=j.useState("30d"),[n,a]=j.useState("all"),[s,o]=j.useState("overview"),{data:l}=Fe({queryKey:["/api/orders/my-orders",{limit:5}],enabled:!!e&&(e==null?void 0:e.role)==="sales_officer"}),{data:c}=Fe({queryKey:["/api/orders",{limit:10}],enabled:!!e&&["super_admin","approver","sales_clerk","management"].includes((e==null?void 0:e.role)||"")}),u=["super_admin","approver","management"].includes((e==null?void 0:e.role)||""),f=(e==null?void 0:e.role)==="sales_officer",d=y=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(y),h=()=>i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[i.jsx(W,{children:i.jsx(H,{className:"p-6",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"My Orders"}),i.jsx("p",{className:"text-2xl font-bold",children:Array.isArray(l)?l.length:0}),i.jsx("p",{className:"text-xs text-green-600",children:"+2 this week"})]}),i.jsx(Ot,{className:"h-8 w-8 text-muted-foreground"})]})})}),i.jsx(W,{children:i.jsx(H,{className:"p-6",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Approval Rate"}),i.jsx("p",{className:"text-2xl font-bold",children:"87%"}),i.jsx("p",{className:"text-xs text-green-600",children:"+5% from last month"})]}),i.jsx(hg,{className:"h-8 w-8 text-muted-foreground"})]})})}),i.jsx(W,{children:i.jsx(H,{className:"p-6",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Total Value"}),i.jsx("p",{className:"text-2xl font-bold",children:d(24580)}),i.jsx("p",{className:"text-xs text-green-600",children:"+12% growth"})]}),i.jsx(Mr,{className:"h-8 w-8 text-muted-foreground"})]})})})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{children:"My Recent Orders"})}),i.jsx(H,{children:Array.isArray(l)&&l.length>0?i.jsx("div",{className:"space-y-4",children:l.map(y=>i.jsx(zT,{orderId:y.id},y.id))}):i.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[i.jsx(Ot,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),i.jsx("p",{children:"No recent orders found"}),i.jsx("p",{className:"text-sm",children:"Create your first order to see analytics"})]})})]})]}),p=()=>i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("h1",{className:"text-3xl font-bold",children:"France Lait Analytics"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs(_e,{value:t,onValueChange:r,children:[i.jsx(Ae,{className:"w-32",children:i.jsx(De,{})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"7d",children:"7 Days"}),i.jsx(U,{value:"30d",children:"30 Days"}),i.jsx(U,{value:"90d",children:"90 Days"}),i.jsx(U,{value:"1y",children:"1 Year"})]})]}),i.jsxs(_e,{value:n,onValueChange:a,children:[i.jsx(Ae,{className:"w-32",children:i.jsx(De,{})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Regions"}),i.jsx(U,{value:"addis",children:"Addis Ababa"}),i.jsx(U,{value:"dire",children:"Dire Dawa"}),i.jsx(U,{value:"bahir",children:"Bahir Dar"})]})]}),i.jsxs(z,{variant:"outline",size:"sm",children:[i.jsx(Ln,{className:"h-4 w-4 mr-2"}),"Export"]})]})]}),i.jsx(R6,{}),Array.isArray(c)&&c.length>0&&i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{children:"Recent Order Activity"})}),i.jsx(H,{children:i.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:c.slice(0,4).map(y=>i.jsx(zT,{orderId:y.id},y.id))})})]})]});return i.jsxs("div",{className:"min-h-screen bg-slate-50 dark:bg-slate-900",children:[i.jsx(Ts,{}),i.jsxs("div",{className:"flex",children:[i.jsx(ca,{}),i.jsx("main",{className:"flex-1 p-6 pt-16 md:pt-6 w-full md:ml-64",children:i.jsx("div",{className:"w-full space-y-6",children:i.jsxs(ja,{value:s,onValueChange:o,children:[i.jsxs(Hn,{className:"grid w-full grid-cols-3",children:[i.jsxs(Qe,{value:"overview",className:"flex items-center gap-2",children:[i.jsx(Xr,{className:"h-4 w-4"}),"Overview"]}),i.jsxs(Qe,{value:"performance",className:"flex items-center gap-2",children:[i.jsx(Mr,{className:"h-4 w-4"}),"Performance"]}),i.jsxs(Qe,{value:"insights",className:"flex items-center gap-2",children:[i.jsx(V1,{className:"h-4 w-4"}),"Insights"]})]}),i.jsx(Xe,{value:"overview",className:"space-y-6",children:f?i.jsx(h,{}):i.jsx(p,{})}),i.jsxs(Xe,{value:"performance",className:"space-y-6",children:[i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{children:"Performance Metrics"})}),i.jsx(H,{children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[i.jsxs("div",{className:"text-center p-4 border rounded-lg",children:[i.jsx("div",{className:"text-2xl font-bold text-blue-600",children:"92%"}),i.jsx("div",{className:"text-sm text-muted-foreground",children:"Customer Satisfaction"})]}),i.jsxs("div",{className:"text-center p-4 border rounded-lg",children:[i.jsx("div",{className:"text-2xl font-bold text-green-600",children:"24h"}),i.jsx("div",{className:"text-sm text-muted-foreground",children:"Avg Response Time"})]}),i.jsxs("div",{className:"text-center p-4 border rounded-lg",children:[i.jsx("div",{className:"text-2xl font-bold text-purple-600",children:"156"}),i.jsx("div",{className:"text-sm text-muted-foreground",children:"Orders This Month"})]}),i.jsxs("div",{className:"text-center p-4 border rounded-lg",children:[i.jsx("div",{className:"text-2xl font-bold text-orange-600",children:"87%"}),i.jsx("div",{className:"text-sm text-muted-foreground",children:"Approval Rate"})]})]})})]}),u&&i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{children:"Sales Team Performance"})}),i.jsx(H,{children:i.jsx("div",{className:"space-y-4",children:[{name:"Ahmed M.",orders:45,revenue:28750,trend:"+18%"},{name:"Fatima K.",orders:38,revenue:24200,trend:"+15%"},{name:"Mohammed A.",orders:32,revenue:18900,trend:"+9%"},{name:"Marta T.",orders:28,revenue:16100,trend:"+22%"}].map(y=>i.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-10 h-10 bg-blue-100 rounded-full flex items-center justify-center",children:i.jsx(Ss,{className:"h-5 w-5 text-blue-600"})}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium",children:y.name}),i.jsxs("div",{className:"text-sm text-muted-foreground",children:[y.orders," orders"]})]})]}),i.jsxs("div",{className:"text-right",children:[i.jsx("div",{className:"font-medium",children:d(y.revenue)}),i.jsx("div",{className:"text-sm text-green-600",children:y.trend})]})]},y.name))})})]})]}),i.jsxs(Xe,{value:"insights",className:"space-y-6",children:[i.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{children:"Product Insights"})}),i.jsx(H,{children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex justify-between items-center",children:[i.jsx("span",{children:"Milk One"}),i.jsx(te,{children:"Best Seller"})]}),i.jsxs("div",{className:"flex justify-between items-center",children:[i.jsx("span",{children:"AR Formula"}),i.jsx(te,{variant:"secondary",children:"High Margin"})]}),i.jsxs("div",{className:"flex justify-between items-center",children:[i.jsx("span",{children:"LF Formula"}),i.jsx(te,{variant:"outline",children:"Growing Demand"})]})]})})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{children:"Market Trends"})}),i.jsx(H,{children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{children:"Pharmacy Sector"}),i.jsx("span",{className:"text-green-600",children:"+12% growth"})]}),i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{children:"Wholesale Orders"}),i.jsx("span",{className:"text-blue-600",children:"+8% growth"})]}),i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{children:"Regional Expansion"}),i.jsx("span",{className:"text-purple-600",children:"3 new areas"})]})]})})]})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{children:"Recommendations"})}),i.jsx(H,{children:i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"p-4 bg-blue-50 border border-blue-200 rounded-lg",children:[i.jsx("h4",{className:"font-medium text-blue-900",children:"Inventory Optimization"}),i.jsx("p",{className:"text-sm text-blue-700",children:"Consider increasing AR Formula stock by 20% based on growing demand"})]}),i.jsxs("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg",children:[i.jsx("h4",{className:"font-medium text-green-900",children:"Sales Strategy"}),i.jsx("p",{className:"text-sm text-green-700",children:"Focus on pharmacy sector expansion - highest conversion rate"})]}),i.jsxs("div",{className:"p-4 bg-orange-50 border border-orange-200 rounded-lg",children:[i.jsx("h4",{className:"font-medium text-orange-900",children:"Customer Retention"}),i.jsx("p",{className:"text-sm text-orange-700",children:"Implement loyalty program for high-value wholesale customers"})]})]})})]})]})]})})})]})]})}var VS="Switch",[D1e,HCe]=wn(VS),[M1e,I1e]=D1e(VS),$6=j.forwardRef((e,t)=>{const{__scopeSwitch:r,name:n,checked:a,defaultChecked:s,required:o,disabled:l,value:c="on",onCheckedChange:u,form:f,...d}=e,[h,p]=j.useState(null),y=Ye(t,b=>p(b)),v=j.useRef(!1),m=h?f||!!h.closest("form"):!0,[x=!1,g]=Ro({prop:a,defaultProp:s,onChange:u});return i.jsxs(M1e,{scope:r,checked:x,disabled:l,children:[i.jsx(Re.button,{type:"button",role:"switch","aria-checked":x,"aria-required":o,"data-state":B6(x),"data-disabled":l?"":void 0,disabled:l,value:c,...d,ref:y,onClick:je(e.onClick,b=>{g(N=>!N),m&&(v.current=b.isPropagationStopped(),v.current||b.stopPropagation())})}),m&&i.jsx(R1e,{control:h,bubbles:!v.current,name:n,value:c,checked:x,required:o,disabled:l,form:f,style:{transform:"translateX(-100%)"}})]})});$6.displayName=VS;var L6="SwitchThumb",F6=j.forwardRef((e,t)=>{const{__scopeSwitch:r,...n}=e,a=I1e(L6,r);return i.jsx(Re.span,{"data-state":B6(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:t})});F6.displayName=L6;var R1e=e=>{const{control:t,checked:r,bubbles:n=!0,...a}=e,s=j.useRef(null),o=vN(r),l=fN(t);return j.useEffect(()=>{const c=s.current,u=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(u,"checked").set;if(o!==r&&d){const h=new Event("click",{bubbles:n});d.call(c,r),c.dispatchEvent(h)}},[o,r,n]),i.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:s,style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function B6(e){return e?"checked":"unchecked"}var U6=$6,$1e=F6;const _l=j.forwardRef(({className:e,...t},r)=>i.jsx(U6,{className:ue("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:r,children:i.jsx($1e,{className:ue("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));_l.displayName=U6.displayName;function L1e(){const{user:e}=qn(),{toast:t}=Ht(),r=$r(),[n,a]=j.useState(!1),[s,o]=j.useState({botToken:"",webhookUrl:"",welcomeMessage:"",autoApproveLimit:"",isActive:!0}),{data:l,isLoading:c}=Fe({queryKey:["/api/bot/config"]});M.useEffect(()=>{if(l){const m=l;o({botToken:m.hasToken?"••••••••••••••••••••••••••••••••••••••••••••••••":"",webhookUrl:m.webhookUrl||"",welcomeMessage:m.welcomeMessage||"",autoApproveLimit:m.autoApproveLimit||"",isActive:m.isActive||!1})}},[l]);const{data:u}=Fe({queryKey:["/api/bot/status"],refetchInterval:3e4}),f=rt({mutationFn:async m=>{await ut("POST","/api/bot/config",m)},onSuccess:()=>{r.invalidateQueries({queryKey:["/api/bot/config"]}),r.invalidateQueries({queryKey:["/api/bot/status"]}),a(!1),t({title:"Configuration Updated",description:"Bot configuration has been successfully updated."})},onError:m=>{t({title:"Update Failed",description:m.message,variant:"destructive"})}}),d=rt({mutationFn:async()=>{await ut("POST","/api/bot/restart")},onSuccess:()=>{r.invalidateQueries({queryKey:["/api/bot/status"]}),t({title:"Bot Restarted",description:"The Telegram bot has been restarted successfully."})},onError:m=>{t({title:"Restart Failed",description:m.message,variant:"destructive"})}}),h=()=>{const m={...s};m.botToken.includes("••••")&&delete m.botToken,f.mutate(m)},p=(m,x)=>{o(g=>({...g,[m]:x}))},y=()=>u?u.isActive?i.jsx(te,{variant:"default",className:"bg-emerald-100 text-emerald-800",children:"Online"}):i.jsx(te,{variant:"destructive",children:"Offline"}):i.jsx(te,{variant:"secondary",children:"Unknown"}),v=()=>u?u.isActive?i.jsx("div",{className:"w-2 h-2 bg-emerald-400 rounded-full"}):i.jsx("div",{className:"w-2 h-2 bg-red-400 rounded-full"}):i.jsx("div",{className:"w-2 h-2 bg-slate-400 rounded-full"});return!e||e.role!=="super_admin"?i.jsx("div",{className:"min-h-screen bg-slate-50 flex items-center justify-center",children:i.jsx(W,{className:"w-full max-w-md",children:i.jsxs(H,{className:"pt-6 text-center",children:[i.jsx("h2",{className:"text-xl font-semibold text-slate-800 mb-2",children:"Access Denied"}),i.jsx("p",{className:"text-slate-600",children:"You don't have permission to access this page."})]})})}):i.jsxs("div",{className:"min-h-screen bg-slate-50",children:[i.jsx(ca,{}),i.jsxs("div",{className:"ml-64",children:[i.jsx(Ts,{}),i.jsxs("main",{className:"p-6",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx("h1",{className:"text-2xl font-semibold text-slate-800",children:"Bot Management"}),i.jsx("p",{className:"text-slate-600",children:"Configure and monitor your Telegram order bot"})]}),i.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[i.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs(ee,{className:"flex items-center",children:[i.jsx(Pl,{className:"w-5 h-5 mr-2"}),"Bot Status"]}),y()]})}),i.jsx(H,{children:i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"p-4 bg-slate-50 rounded-lg",children:[i.jsx("p",{className:"text-sm text-slate-600",children:"Bot Username"}),i.jsx("p",{className:"text-lg font-medium text-slate-900",children:"@teleorder_bot"})]}),i.jsxs("div",{className:"p-4 bg-slate-50 rounded-lg",children:[i.jsx("p",{className:"text-sm text-slate-600",children:"Last Activity"}),i.jsx("p",{className:"text-lg font-medium text-slate-900",children:"2 minutes ago"})]}),i.jsxs("div",{className:"p-4 bg-slate-50 rounded-lg",children:[i.jsx("p",{className:"text-sm text-slate-600",children:"Orders Today"}),i.jsx("p",{className:"text-lg font-medium text-slate-900",children:"12"})]}),i.jsxs("div",{className:"p-4 bg-slate-50 rounded-lg",children:[i.jsx("p",{className:"text-sm text-slate-600",children:"Active Users"}),i.jsx("p",{className:"text-lg font-medium text-slate-900",children:"8"})]})]})})]}),(!(l!=null&&l.hasToken)||(l==null?void 0:l.hasToken)===!1)&&i.jsxs(W,{className:"border-amber-200 bg-amber-50",children:[i.jsx(J,{children:i.jsxs(ee,{className:"text-amber-800 flex items-center",children:[i.jsx(Ub,{className:"w-5 h-5 mr-2"}),"Bot Setup Required"]})}),i.jsxs(H,{className:"text-amber-700",children:[i.jsx("p",{className:"mb-3",children:"To enable the Telegram bot, you need to:"}),i.jsxs("ol",{className:"list-decimal list-inside space-y-2 mb-4",children:[i.jsxs("li",{children:["Contact ",i.jsx("strong",{children:"@BotFather"})," on Telegram"]}),i.jsxs("li",{children:["Send ",i.jsx("code",{children:"/newbot"})," and follow the instructions"]}),i.jsx("li",{children:"Choose a name and username for your bot"}),i.jsx("li",{children:"Copy the bot token (starts with numbers followed by colon)"}),i.jsx("li",{children:"Paste the token in the configuration below"})]}),i.jsxs("p",{className:"text-sm",children:["Example token format: ",i.jsx("code",{children:"123456789:ABCdefGHIjklMNOpqrsTUVwxyz"})]})]})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs(ee,{className:"flex items-center",children:[i.jsx(Vp,{className:"w-5 h-5 mr-2"}),"Configuration"]}),i.jsx(z,{variant:"outline",size:"sm",onClick:()=>a(!n),children:n?"Cancel":"Edit"})]})}),i.jsxs(H,{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-slate-700 mb-2",children:[i.jsx(Ub,{className:"w-4 h-4 inline mr-1"}),"Bot Token"]}),i.jsx("div",{className:"flex items-center space-x-2",children:i.jsx(he,{type:n?"text":"password",value:s.botToken,onChange:m=>p("botToken",m.target.value),placeholder:"123456789:ABCdefGHIjklMNOpqrsTUVwxyz",disabled:!n,className:"flex-1"})}),i.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Get this from @BotFather on Telegram. Keep it secure and never share it."})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-slate-700 mb-2",children:[i.jsx(eA,{className:"w-4 h-4 inline mr-1"}),"Webhook URL"]}),i.jsx(he,{type:"url",value:s.webhookUrl,onChange:m=>p("webhookUrl",m.target.value),placeholder:"https://your-domain.com/webhook/telegram",disabled:!n})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-slate-700 mb-2",children:"Welcome Message"}),i.jsx(Wn,{rows:3,value:s.welcomeMessage,onChange:m=>p("welcomeMessage",m.target.value),placeholder:"Welcome! Use this bot to submit orders...",disabled:!n})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-slate-700 mb-2",children:"Auto-approve Limit ($)"}),i.jsx(he,{type:"number",value:s.autoApproveLimit,onChange:m=>p("autoApproveLimit",m.target.value),placeholder:"500.00",disabled:!n}),i.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Orders under this amount will be automatically approved"})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("h4",{className:"text-sm font-medium text-slate-900",children:"Bot Active"}),i.jsx("p",{className:"text-sm text-slate-500",children:"Enable or disable the bot"})]}),i.jsx(_l,{checked:s.isActive,onCheckedChange:m=>p("isActive",m),disabled:!n})]}),n&&i.jsx("div",{className:"pt-4",children:i.jsx(z,{onClick:h,disabled:f.isPending,className:"w-full",children:f.isPending?"Saving...":"Save Configuration"})})]})]})]}),i.jsxs("div",{className:"space-y-6",children:[i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"flex items-center",children:[i.jsx(Pl,{className:"w-5 h-5 mr-2"}),"Recent Activity"]})}),i.jsx(H,{children:i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-start",children:[i.jsx("div",{className:"w-8 h-8 bg-blue-50 rounded-lg flex items-center justify-center mr-3",children:i.jsx(ha,{className:"w-4 h-4 text-blue-600"})}),i.jsxs("div",{className:"flex-1",children:[i.jsx("p",{className:"text-sm text-slate-900",children:"New order #1047 from Mike Johnson"}),i.jsx("p",{className:"text-xs text-slate-500",children:"2 minutes ago"})]})]}),i.jsxs("div",{className:"flex items-start",children:[i.jsx("div",{className:"w-8 h-8 bg-emerald-50 rounded-lg flex items-center justify-center mr-3",children:i.jsx(Pl,{className:"w-4 h-4 text-emerald-600"})}),i.jsxs("div",{className:"flex-1",children:[i.jsx("p",{className:"text-sm text-slate-900",children:"User @anna_lee joined the bot"}),i.jsx("p",{className:"text-xs text-slate-500",children:"15 minutes ago"})]})]}),i.jsxs("div",{className:"flex items-start",children:[i.jsx("div",{className:"w-8 h-8 bg-amber-50 rounded-lg flex items-center justify-center mr-3",children:i.jsx(Pl,{className:"w-4 h-4 text-amber-600"})}),i.jsxs("div",{className:"flex-1",children:[i.jsx("p",{className:"text-sm text-slate-900",children:"Order validation failed for user @john_smith"}),i.jsx("p",{className:"text-xs text-slate-500",children:"1 hour ago"})]})]})]})})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{children:"Available Commands"})}),i.jsx(H,{children:i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"p-3 bg-slate-50 rounded-lg",children:[i.jsx("code",{className:"text-sm font-mono text-slate-900",children:"/start"}),i.jsx("p",{className:"text-xs text-slate-600 mt-1",children:"Initialize bot and show welcome message"})]}),i.jsxs("div",{className:"p-3 bg-slate-50 rounded-lg",children:[i.jsx("code",{className:"text-sm font-mono text-slate-900",children:"/neworder"}),i.jsx("p",{className:"text-xs text-slate-600 mt-1",children:"Start creating a new order"})]}),i.jsxs("div",{className:"p-3 bg-slate-50 rounded-lg",children:[i.jsx("code",{className:"text-sm font-mono text-slate-900",children:"/myorders"}),i.jsx("p",{className:"text-xs text-slate-600 mt-1",children:"View user's submitted orders"})]}),i.jsxs("div",{className:"p-3 bg-slate-50 rounded-lg",children:[i.jsx("code",{className:"text-sm font-mono text-slate-900",children:"/help"}),i.jsx("p",{className:"text-xs text-slate-600 mt-1",children:"Show help and command list"})]})]})})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{children:"Bot Controls"})}),i.jsx(H,{children:i.jsxs("div",{className:"space-y-3",children:[i.jsxs(z,{className:"w-full justify-start",variant:"outline",onClick:()=>d.mutate(),disabled:d.isPending,children:[i.jsx(za,{className:"w-4 h-4 mr-2"}),d.isPending?"Restarting...":"Restart Bot"]}),i.jsxs(z,{className:"w-full justify-start",variant:"outline",children:[i.jsx(eA,{className:"w-4 h-4 mr-2"}),"Update Webhook"]}),i.jsxs(z,{className:"w-full justify-start",variant:"outline",children:[i.jsx(Ln,{className:"w-4 h-4 mr-2"}),"Export Logs"]})]})})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{children:"System Health"})}),i.jsx(H,{children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center",children:[v(),i.jsx("span",{className:"text-sm text-slate-700 ml-3",children:"Bot Status"})]}),i.jsx("span",{className:"text-sm font-medium text-emerald-600",children:u!=null&&u.isActive?"Online":"Offline"})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center",children:[i.jsx("div",{className:"w-2 h-2 bg-emerald-400 rounded-full"}),i.jsx("span",{className:"text-sm text-slate-700 ml-3",children:"Database"})]}),i.jsx("span",{className:"text-sm font-medium text-emerald-600",children:"Healthy"})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center",children:[i.jsx("div",{className:"w-2 h-2 bg-amber-400 rounded-full"}),i.jsx("span",{className:"text-sm text-slate-700 ml-3",children:"API Response"})]}),i.jsx("span",{className:"text-sm font-medium text-amber-600",children:"125ms"})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center",children:[i.jsx("div",{className:"w-2 h-2 bg-emerald-400 rounded-full"}),i.jsx("span",{className:"text-sm text-slate-700 ml-3",children:"Storage"})]}),i.jsx("span",{className:"text-sm font-medium text-emerald-600",children:"67% used"})]})]})})]})]})]})]})]})]})}function h0(){var $;const{user:e}=Za(),[t,r]=j.useState(""),[n,a]=j.useState("all"),[s,o]=j.useState(!1),[l,c]=j.useState(null),[u,f]=j.useState(!1),[d,h]=j.useState(""),[p,y]=j.useState(""),[v,m]=j.useState(),[x,g]=j.useState(),b=(e==null?void 0:e.role)==="approver"||(e==null?void 0:e.role)==="super_admin"?"/api/orders":"/api/orders/my-orders",{data:N=[],isLoading:w,refetch:S}=Fe({queryKey:[b],enabled:!!e,refetchInterval:3e4}),O=()=>{S()},P=d||p||v||x,A=()=>{h(""),y(""),m(void 0),g(void 0),r(""),a("all")},C=I=>{switch(I){case"approved":return i.jsx(ct,{className:"w-5 h-5 text-emerald-600"});case"rejected":return i.jsx(ar,{className:"w-5 h-5 text-red-600"});case"pending":return i.jsx(wr,{className:"w-5 h-5 text-amber-600"});case"completed":return i.jsx(ct,{className:"w-5 h-5 text-blue-600"});case"processing":return i.jsx(za,{className:"w-5 h-5 text-purple-600"});default:return i.jsx(eh,{className:"w-5 h-5 text-slate-400"})}},T=I=>{switch(I){case"approved":return i.jsx(te,{className:"bg-emerald-100 text-emerald-800 hover:bg-emerald-100",children:"Approved"});case"rejected":return i.jsx(te,{variant:"destructive",children:"Rejected"});case"pending":return i.jsx(te,{className:"bg-amber-100 text-amber-800 hover:bg-amber-100",children:"Pending Review"});case"completed":return i.jsx(te,{className:"bg-blue-100 text-blue-800 hover:bg-blue-100",children:"Completed"});case"processing":return i.jsx(te,{className:"bg-purple-100 text-purple-800 hover:bg-purple-100",children:"Processing"});default:return i.jsx(te,{variant:"outline",children:I})}},D=I=>I&&I.trim()?i.jsxs(te,{variant:"outline",className:"bg-blue-50 text-blue-700 font-mono",children:["FS: ",I]}):i.jsx(te,{variant:"outline",className:"bg-gray-100 text-gray-600",children:"FS not set"}),_=I=>I?I.split("_").map(E=>E.charAt(0).toUpperCase()).join(""):"N/A",k=Array.isArray(N)?N.filter(I=>{var le,de,ie,ve;const E=!t||((le=I.customerName)==null?void 0:le.toLowerCase().includes(t.toLowerCase()))||((de=I.orderNumber)==null?void 0:de.toLowerCase().includes(t.toLowerCase()))||((ie=I.id)==null?void 0:ie.toString().includes(t)),F=n==="all"||I.status===n,V=!d||((ve=I.customerTinNumber)==null?void 0:ve.toLowerCase().includes(d.toLowerCase())),G=!p||I.fsNumber&&I.fsNumber.toLowerCase().includes(p.toLowerCase()),K=new Date(I.createdAt),q=!v||K>=v,ne=!x||K<=x;return E&&F&&V&&G&&q&&ne}).sort((I,E)=>new Date(E.createdAt).getTime()-new Date(I.createdAt).getTime()):[],R=I=>new Date(I).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return e?i.jsxs("div",{className:"p-6 space-y-6",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-bold text-slate-900",children:"Order Tracking"}),i.jsx("p",{className:"text-slate-600",children:"Real-time order status monitoring and tracking"})]}),i.jsxs(z,{size:"sm",className:"bg-blue-600 hover:bg-blue-700 text-white",onClick:()=>o(!0),children:[i.jsx(fn,{className:"w-4 h-4 mr-1"}),"New Order"]})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx(iu,{className:"w-4 h-4 text-slate-400 absolute left-3 top-3"}),i.jsx(he,{placeholder:"Search orders...",className:"pl-10",value:t,onChange:I=>r(I.target.value)})]}),i.jsxs(_e,{value:n,onValueChange:a,children:[i.jsx(Ae,{className:"w-full sm:w-48",children:i.jsx(De,{placeholder:"Filter by status"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Status"}),i.jsx(U,{value:"pending",children:"Pending"}),i.jsx(U,{value:"approved",children:"Approved"}),i.jsx(U,{value:"processing",children:"Processing"}),i.jsx(U,{value:"completed",children:"Completed"}),i.jsx(U,{value:"rejected",children:"Rejected"})]})]}),i.jsxs(z,{variant:"outline",onClick:()=>f(!u),className:"flex items-center gap-2",children:[i.jsx($o,{className:"w-4 h-4"}),"Filters"]}),i.jsxs(z,{variant:"outline",size:"sm",onClick:O,className:"flex items-center gap-2",children:[i.jsx(za,{className:"w-4 h-4"}),"Refresh"]}),P&&i.jsxs(z,{variant:"outline",onClick:A,className:"flex items-center gap-2 text-red-600 hover:text-red-700",children:[i.jsx(su,{className:"w-4 h-4"}),"Clear"]})]}),u&&i.jsx(W,{className:"p-4",children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(X,{htmlFor:"tin-filter",className:"text-sm font-medium",children:"Customer TIN"}),i.jsx(he,{id:"tin-filter",placeholder:"Enter TIN number...",value:d,onChange:I=>h(I.target.value),className:"h-9"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(X,{htmlFor:"fs-number-filter",className:"text-sm font-medium",children:"FS Number"}),i.jsx(he,{id:"fs-number-filter",placeholder:"Enter FS number...",value:p,onChange:I=>y(I.target.value),className:"h-9"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(X,{className:"text-sm font-medium",children:"Date From"}),i.jsxs(zo,{children:[i.jsx(Wo,{asChild:!0,children:i.jsxs(z,{variant:"outline",className:"h-9 w-full justify-start text-left font-normal",children:[i.jsx(Dr,{className:"mr-2 h-4 w-4"}),v?Ve(v,"PPP"):"Pick a date"]})}),i.jsx(Es,{className:"w-auto p-0",children:i.jsx(Cs,{mode:"single",selected:v,onSelect:m,initialFocus:!0})})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(X,{className:"text-sm font-medium",children:"Date To"}),i.jsxs(zo,{children:[i.jsx(Wo,{asChild:!0,children:i.jsxs(z,{variant:"outline",className:"h-9 w-full justify-start text-left font-normal",children:[i.jsx(Dr,{className:"mr-2 h-4 w-4"}),x?Ve(x,"PPP"):"Pick a date"]})}),i.jsx(Es,{className:"w-auto p-0",children:i.jsx(Cs,{mode:"single",selected:x,onSelect:g,initialFocus:!0})})]})]})]})})]}),i.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-5 gap-4",children:[i.jsx(W,{children:i.jsxs(H,{className:"p-4 text-center",children:[i.jsx("div",{className:"flex items-center justify-center mb-2",children:i.jsx(Mr,{className:"w-8 h-8 text-blue-600"})}),i.jsx("p",{className:"text-2xl font-bold text-slate-900",children:k.length}),i.jsx("p",{className:"text-sm text-slate-600",children:"Total Orders"})]})}),i.jsx(W,{children:i.jsxs(H,{className:"p-4 text-center",children:[i.jsx("div",{className:"flex items-center justify-center mb-2",children:i.jsx(wr,{className:"w-8 h-8 text-amber-600"})}),i.jsx("p",{className:"text-2xl font-bold text-slate-900",children:k.filter(I=>I.status==="pending").length}),i.jsx("p",{className:"text-sm text-slate-600",children:"Pending"})]})}),i.jsx(W,{children:i.jsxs(H,{className:"p-4 text-center",children:[i.jsx("div",{className:"flex items-center justify-center mb-2",children:i.jsx(ct,{className:"w-8 h-8 text-emerald-600"})}),i.jsx("p",{className:"text-2xl font-bold text-slate-900",children:k.filter(I=>I.status==="approved").length}),i.jsx("p",{className:"text-sm text-slate-600",children:"Approved"})]})}),i.jsx(W,{children:i.jsxs(H,{className:"p-4 text-center",children:[i.jsx("div",{className:"flex items-center justify-center mb-2",children:i.jsx(ct,{className:"w-8 h-8 text-blue-600"})}),i.jsx("p",{className:"text-2xl font-bold text-slate-900",children:k.filter(I=>I.status==="completed").length}),i.jsx("p",{className:"text-sm text-slate-600",children:"Completed"})]})}),i.jsx(W,{children:i.jsxs(H,{className:"p-4 text-center",children:[i.jsx("div",{className:"flex items-center justify-center mb-2",children:i.jsx(ar,{className:"w-8 h-8 text-red-600"})}),i.jsx("p",{className:"text-2xl font-bold text-slate-900",children:k.filter(I=>I.status==="rejected").length}),i.jsx("p",{className:"text-sm text-slate-600",children:"Rejected"})]})})]}),i.jsx("div",{className:"space-y-4",children:w?i.jsx(W,{children:i.jsxs(H,{className:"p-6 text-center",children:[i.jsx(za,{className:"w-8 h-8 text-slate-400 animate-spin mx-auto mb-4"}),i.jsx("p",{className:"text-slate-600",children:"Loading orders..."})]})}):k.length===0?i.jsx(W,{children:i.jsxs(H,{className:"p-6 text-center",children:[i.jsx("div",{className:"w-16 h-16 bg-slate-100 rounded-full flex items-center justify-center mx-auto mb-4",children:i.jsx(Dr,{className:"w-8 h-8 text-slate-400"})}),i.jsx("p",{className:"text-slate-600 mb-2",children:"No orders found"}),i.jsxs(z,{onClick:()=>o(!0),children:[i.jsx(fn,{className:"w-4 h-4 mr-2"}),"Create Your First Order"]})]})}):k.map(I=>i.jsx(W,{className:"hover:shadow-md transition-shadow",children:i.jsx(H,{className:"p-6",children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[C(I.status),i.jsxs("h3",{className:"text-lg font-semibold text-slate-900",children:["Order #",I.id]}),T(I.status)]}),i.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-slate-600",children:"Customer:"}),i.jsx("p",{className:"font-medium text-slate-900",children:I.customerName}),i.jsxs("p",{className:"text-xs text-slate-500 font-mono",children:["TIN: ",I.customerTinNumber]})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-slate-600",children:"Sales Person:"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"w-6 h-6 bg-blue-100 text-blue-700 rounded-full flex items-center justify-center",children:i.jsx("span",{className:"text-xs font-medium",children:_(I.salesOfficerId)})}),i.jsx("p",{className:"font-medium text-slate-900",children:I.salesOfficerId})]})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-slate-600",children:"Business Sector:"}),i.jsx("p",{className:"font-medium text-slate-900 capitalize",children:I.businessSector})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-slate-600",children:"FS Number:"}),i.jsx("div",{className:"mt-1",children:D(I.fsNumber)})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-slate-600",children:"Total Amount:"}),i.jsxs("p",{className:"font-medium text-slate-900",children:["€",I.totalAmount]})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-slate-600",children:"Created:"}),i.jsx("p",{className:"font-medium text-slate-900",children:R(I.createdAt)})]})]})]}),i.jsx(z,{variant:"outline",size:"sm",onClick:()=>c(I),className:"ml-4",children:i.jsx(au,{className:"w-4 h-4"})})]})})},I.id))}),i.jsx(Mm,{isOpen:s,onClose:()=>o(!1)}),l&&i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-white rounded-lg max-w-2xl w-full max-h-[90vh] overflow-hidden",children:[i.jsx("div",{className:"border-b border-slate-200 p-4",children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{children:[i.jsxs("h2",{className:"text-xl font-semibold text-slate-900",children:["Order #",l.id]}),i.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[i.jsxs("span",{className:"text-sm text-slate-500",children:["Customer: ",l.customerName]}),T(l.status)]})]}),i.jsx(z,{variant:"ghost",onClick:()=>c(null),children:"✕"})]})}),i.jsx("div",{className:"p-6 overflow-y-auto max-h-[60vh]",children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium text-slate-700",children:"Customer TIN"}),i.jsx("p",{className:"text-slate-900 font-mono",children:l.customerTinNumber||"Not provided"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium text-slate-700",children:"Sales Person"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"w-8 h-8 bg-slate-200 rounded-full flex items-center justify-center",children:i.jsx("span",{className:"text-xs font-medium text-slate-600",children:($=l.salesOfficerId)==null?void 0:$.substring(0,2).toUpperCase()})}),i.jsx("p",{className:"text-slate-900",children:l.salesOfficerId})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium text-slate-700",children:"Business Sector"}),i.jsx("p",{className:"text-slate-900 capitalize",children:l.businessSector})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium text-slate-700",children:"Payment Term"}),i.jsx("p",{className:"text-slate-900 capitalize",children:l.paymentTerm})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium text-slate-700",children:"Estimated Area"}),i.jsx("p",{className:"text-slate-900",children:l.estimatedArea})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium text-slate-700",children:"Total Amount"}),i.jsxs("p",{className:"text-slate-900 font-semibold",children:["€",l.totalAmount]})]}),l.fsNumber&&i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium text-slate-700",children:"FS Number"}),i.jsx("p",{className:"text-slate-900 font-mono bg-blue-50 text-blue-700 px-2 py-1 rounded text-sm inline-block",children:l.fsNumber})]})]}),l.items&&i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium text-slate-700 mb-2 block",children:"Order Items"}),i.jsx("div",{className:"bg-slate-50 rounded-lg p-4",children:i.jsx("pre",{className:"text-sm text-slate-900 whitespace-pre-wrap",children:JSON.stringify(l.items,null,2)})})]}),l.notes&&i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium text-slate-700 mb-2 block",children:"Notes"}),i.jsx("div",{className:"bg-slate-50 rounded-lg p-4",children:i.jsx("p",{className:"text-sm text-slate-900",children:l.notes})})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium text-slate-700",children:"Created At"}),i.jsx("p",{className:"text-slate-900",children:R(l.createdAt)})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium text-slate-700",children:"Last Updated"}),i.jsx("p",{className:"text-slate-900",children:R(l.updatedAt)})]})]})]})})]})})]})]}):null}function Mf(e){"@babel/helpers - typeof";return Mf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Mf(e)}function F1e(e,t){if(Mf(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(Mf(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function B1e(e){var t=F1e(e,"string");return Mf(t)=="symbol"?t:t+""}function U1e(e,t,r){return(t=B1e(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function WT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function HT(e){for(var t=1;t"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(Fr(1));return r(z6)(e,t)}if(typeof e!="function")throw new Error(Fr(2));var a=e,s=t,o=[],l=o,c=!1;function u(){l===o&&(l=o.slice())}function f(){if(c)throw new Error(Fr(3));return s}function d(v){if(typeof v!="function")throw new Error(Fr(4));if(c)throw new Error(Fr(5));var m=!0;return u(),l.push(v),function(){if(m){if(c)throw new Error(Fr(6));m=!1,u();var g=l.indexOf(v);l.splice(g,1),o=null}}}function h(v){if(!z1e(v))throw new Error(Fr(7));if(typeof v.type>"u")throw new Error(Fr(8));if(c)throw new Error(Fr(9));try{c=!0,s=a(s,v)}finally{c=!1}for(var m=o=l,x=0;x=0;n--){var a=t[n](e);if(a)return a}return function(s,o){throw new Error("Invalid value of type "+typeof e+" for "+r+" argument when connecting component "+o.wrappedComponentName+".")}}function GNe(e,t){return e===t}function KNe(e){var t=e===void 0?{}:e,r=t.connectHOC,n=r===void 0?CNe:r,a=t.mapStateToPropsFactories,s=a===void 0?RNe:a,o=t.mapDispatchToPropsFactories,l=o===void 0?DNe:o,c=t.mergePropsFactories,u=c===void 0?UNe:c,f=t.selectorFactory,d=f===void 0?VNe:f;return function(p,y,v,m){m===void 0&&(m={});var x=m,g=x.pure,b=g===void 0?!0:g,N=x.areStatesEqual,w=N===void 0?GNe:N,S=x.areOwnPropsEqual,O=S===void 0?m0:S,P=x.areStatePropsEqual,A=P===void 0?m0:P,C=x.areMergedPropsEqual,T=C===void 0?m0:C,D=gv(x,qNe),_=v0(p,s,"mapStateToProps"),k=v0(y,l,"mapDispatchToProps"),R=v0(v,u,"mergeProps");return n(d,Ne({methodName:"connect",getDisplayName:function(I){return"Connect("+I+")"},shouldHandleStateChanges:!!p,initMapStateToProps:_,initMapDispatchToProps:k,initMergeProps:R,pure:b,areStatesEqual:w,areOwnPropsEqual:O,areStatePropsEqual:A,areMergedPropsEqual:T},D))}}const i5=KNe();V1e(Rs.unstable_batchedUpdates);function YNe(e,t){if(e.length!==t.length)return!1;for(var r=0;r");return n.callbacks},n.setCallbacks=function(l){n.callbacks=l},n}var r=t.prototype;return r.componentDidMount=function(){this.unbind=Rn(window,[{eventName:"error",fn:this.onWindowError}])},r.componentDidCatch=function(a){if(a instanceof Uv){this.setState({});return}throw a},r.componentWillUnmount=function(){this.unbind()},r.render=function(){return this.props.children(this.setCallbacks)},t}(M.Component),aSe=` Press space bar to start a drag. When dragging you can use the arrow keys to move the item around and escape to cancel. Some screen readers may require you to be in focus mode or to use your pass through key `,zv=function(t){return t+1},iSe=function(t){return` You have lifted an item in position `+zv(t.source.index)+` `},u5=function(t,r){var n=t.droppableId===r.droppableId,a=zv(t.index),s=zv(r.index);return n?` You have moved the item from position `+a+` to position `+s+` `:` You have moved the item from position `+a+` in list `+t.droppableId+` to list `+r.droppableId+` in position `+s+` `},d5=function(t,r,n){var a=r.droppableId===n.droppableId;return a?` The item `+t+` has been combined with `+n.draggableId:` The item `+t+` in list `+r.droppableId+` has been combined with `+n.draggableId+` in list `+n.droppableId+` `},sSe=function(t){var r=t.destination;if(r)return u5(t.source,r);var n=t.combine;return n?d5(t.draggableId,t.source,n):"You are over an area that cannot be dropped on"},ik=function(t){return` The item has returned to its starting position of `+zv(t.index)+` `},oSe=function(t){if(t.reason==="CANCEL")return` Movement cancelled. `+ik(t.source)+` `;var r=t.destination,n=t.combine;return r?` You have dropped the item. `+u5(t.source,r)+` `:n?` You have dropped the item. `+d5(t.draggableId,t.source,n)+` `:` The item has been dropped while not over a drop area. `+ik(t.source)+` `},Xp={dragHandleUsageInstructions:aSe,onDragStart:iSe,onDragUpdate:sSe,onDragEnd:oSe},or={x:0,y:0},hr=function(t,r){return{x:t.x+r.x,y:t.y+r.y}},un=function(t,r){return{x:t.x-r.x,y:t.y-r.y}},bs=function(t,r){return t.x===r.x&&t.y===r.y},Ou=function(t){return{x:t.x!==0?-t.x:0,y:t.y!==0?-t.y:0}},Yo=function(t,r,n){var a;return n===void 0&&(n=0),a={},a[t]=r,a[t==="x"?"y":"x"]=n,a},Rf=function(t,r){return Math.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2))},sk=function(t,r){return Math.min.apply(Math,r.map(function(n){return Rf(t,n)}))},f5=function(t){return function(r){return{x:t(r.x),y:t(r.y)}}},lSe=function(e,t){var r=ua({top:Math.max(t.top,e.top),right:Math.min(t.right,e.right),bottom:Math.min(t.bottom,e.bottom),left:Math.max(t.left,e.left)});return r.width<=0||r.height<=0?null:r},Mh=function(t,r){return{top:t.top+r.y,left:t.left+r.x,bottom:t.bottom+r.y,right:t.right+r.x}},ok=function(t){return[{x:t.left,y:t.top},{x:t.right,y:t.top},{x:t.left,y:t.bottom},{x:t.right,y:t.bottom}]},cSe={top:0,right:0,bottom:0,left:0},uSe=function(t,r){return r?Mh(t,r.scroll.diff.displacement):t},dSe=function(t,r,n){if(n&&n.increasedBy){var a;return Ne({},t,(a={},a[r.end]=t[r.end]+n.increasedBy[r.line],a))}return t},fSe=function(t,r){return r&&r.shouldClipSubject?lSe(r.pageMarginBox,t):ua(t)},Xc=function(e){var t=e.page,r=e.withPlaceholder,n=e.axis,a=e.frame,s=uSe(t.marginBox,a),o=dSe(s,n,r),l=fSe(o,a);return{page:t,withPlaceholder:r,active:l}},tO=function(e,t){e.frame||oe();var r=e.frame,n=un(t,r.scroll.initial),a=Ou(n),s=Ne({},r,{scroll:{initial:r.scroll.initial,current:t,diff:{value:n,displacement:a},max:r.scroll.max}}),o=Xc({page:e.subject.page,withPlaceholder:e.subject.withPlaceholder,axis:e.axis,frame:s}),l=Ne({},e,{frame:s,subject:o});return l};function Wv(e){return Object.values?Object.values(e):Object.keys(e).map(function(t){return e[t]})}function rO(e,t){if(e.findIndex)return e.findIndex(t);for(var r=0;re.bottom,u=n.lefte.right,f=c&&u;if(f)return!0;var d=c&&o||u&&s;return d}},vSe=function(e){var t=Bn(e.top,e.bottom),r=Bn(e.left,e.right);return function(n){var a=t(n.top)&&t(n.bottom)&&r(n.left)&&r(n.right);return a}},aO={direction:"vertical",line:"y",crossAxisLine:"x",start:"top",end:"bottom",size:"height",crossAxisStart:"left",crossAxisEnd:"right",crossAxisSize:"width"},y5={direction:"horizontal",line:"x",crossAxisLine:"y",start:"left",end:"right",size:"width",crossAxisStart:"top",crossAxisEnd:"bottom",crossAxisSize:"height"},gSe=function(e){return function(t){var r=Bn(t.top,t.bottom),n=Bn(t.left,t.right);return function(a){return e===aO?r(a.top)&&r(a.bottom):n(a.left)&&n(a.right)}}},ySe=function(t,r){var n=r.frame?r.frame.scroll.diff.displacement:or;return Mh(t,n)},xSe=function(t,r,n){return r.subject.active?n(r.subject.active)(t):!1},bSe=function(t,r,n){return n(r)(t)},iO=function(t){var r=t.target,n=t.destination,a=t.viewport,s=t.withDroppableDisplacement,o=t.isVisibleThroughFrameFn,l=s?ySe(r,n):r;return xSe(l,n,o)&&bSe(l,a,o)},jSe=function(t){return iO(Ne({},t,{isVisibleThroughFrameFn:g5}))},x5=function(t){return iO(Ne({},t,{isVisibleThroughFrameFn:vSe}))},wSe=function(t){return iO(Ne({},t,{isVisibleThroughFrameFn:gSe(t.destination.axis)}))},NSe=function(t,r,n){if(typeof n=="boolean")return n;if(!r)return!0;var a=r.invisible,s=r.visible;if(a[t])return!1;var o=s[t];return o?o.shouldAnimate:!0};function SSe(e,t){var r=e.page.marginBox,n={top:t.point.y,right:0,bottom:0,left:t.point.x};return ua(JS(r,n))}function Lf(e){var t=e.afterDragging,r=e.destination,n=e.displacedBy,a=e.viewport,s=e.forceShouldAnimate,o=e.last;return t.reduce(function(c,u){var f=SSe(u,n),d=u.descriptor.id;c.all.push(d);var h=jSe({target:f,destination:r,viewport:a,withDroppableDisplacement:!0});if(!h)return c.invisible[u.descriptor.id]=!0,c;var p=NSe(d,o,s),y={draggableId:d,shouldAnimate:p};return c.visible[d]=y,c},{all:[],visible:{},invisible:{}})}function OSe(e,t){if(!e.length)return 0;var r=e[e.length-1].descriptor.index;return t.inHomeList?r:r+1}function lk(e){var t=e.insideDestination,r=e.inHomeList,n=e.displacedBy,a=e.destination,s=OSe(t,{inHomeList:r});return{displaced:$f,displacedBy:n,at:{type:"REORDER",destination:{droppableId:a.descriptor.id,index:s}}}}function Hv(e){var t=e.draggable,r=e.insideDestination,n=e.destination,a=e.viewport,s=e.displacedBy,o=e.last,l=e.index,c=e.forceShouldAnimate,u=Au(t,n);if(l==null)return lk({insideDestination:r,inHomeList:u,displacedBy:s,destination:n});var f=qs(r,function(v){return v.descriptor.index===l});if(!f)return lk({insideDestination:r,inHomeList:u,displacedBy:s,destination:n});var d=Dy(t,r),h=r.indexOf(f),p=d.slice(h),y=Lf({afterDragging:p,destination:n,displacedBy:s,last:o,viewport:a.frame,forceShouldAnimate:c});return{displaced:y,displacedBy:s,at:{type:"REORDER",destination:{droppableId:n.descriptor.id,index:l}}}}function _s(e,t){return!!t.effected[e]}var PSe=function(e){var t=e.isMovingForward,r=e.destination,n=e.draggables,a=e.combine,s=e.afterCritical;if(!r.isCombineEnabled)return null;var o=a.draggableId,l=n[o],c=l.descriptor.index,u=_s(o,s);return u?t?c:c-1:t?c+1:c},ASe=function(e){var t=e.isMovingForward,r=e.isInHomeList,n=e.insideDestination,a=e.location;if(!n.length)return null;var s=a.index,o=t?s+1:s-1,l=n[0].descriptor.index,c=n[n.length-1].descriptor.index,u=r?c:c+1;return ou?null:o},CSe=function(e){var t=e.isMovingForward,r=e.isInHomeList,n=e.draggable,a=e.draggables,s=e.destination,o=e.insideDestination,l=e.previousImpact,c=e.viewport,u=e.afterCritical,f=l.at;if(f||oe(),f.type==="REORDER"){var d=ASe({isMovingForward:t,isInHomeList:r,location:f.destination,insideDestination:o});return d==null?null:Hv({draggable:n,insideDestination:o,destination:s,viewport:c,last:l.displaced,displacedBy:l.displacedBy,index:d})}var h=PSe({isMovingForward:t,destination:s,displaced:l.displaced,draggables:a,combine:f.combine,afterCritical:u});return h==null?null:Hv({draggable:n,insideDestination:o,destination:s,viewport:c,last:l.displaced,displacedBy:l.displacedBy,index:h})},ESe=function(e){var t=e.displaced,r=e.afterCritical,n=e.combineWith,a=e.displacedBy,s=!!(t.visible[n]||t.invisible[n]);return _s(n,r)?s?or:Ou(a.point):s?a.point:or},TSe=function(e){var t=e.afterCritical,r=e.impact,n=e.draggables,a=_y(r);a||oe();var s=a.draggableId,o=n[s].page.borderBox.center,l=ESe({displaced:r.displaced,afterCritical:t,combineWith:s,displacedBy:r.displacedBy});return hr(o,l)},b5=function(t,r){return r.margin[t.start]+r.borderBox[t.size]/2},kSe=function(t,r){return r.margin[t.end]+r.borderBox[t.size]/2},sO=function(t,r,n){return r[t.crossAxisStart]+n.margin[t.crossAxisStart]+n.borderBox[t.crossAxisSize]/2},ck=function(t){var r=t.axis,n=t.moveRelativeTo,a=t.isMoving;return Yo(r.line,n.marginBox[r.end]+b5(r,a),sO(r,n.marginBox,a))},uk=function(t){var r=t.axis,n=t.moveRelativeTo,a=t.isMoving;return Yo(r.line,n.marginBox[r.start]-kSe(r,a),sO(r,n.marginBox,a))},_Se=function(t){var r=t.axis,n=t.moveInto,a=t.isMoving;return Yo(r.line,n.contentBox[r.start]+b5(r,a),sO(r,n.contentBox,a))},DSe=function(e){var t=e.impact,r=e.draggable,n=e.draggables,a=e.droppable,s=e.afterCritical,o=Pu(a.descriptor.id,n),l=r.page,c=a.axis;if(!o.length)return _Se({axis:c,moveInto:a.page,isMoving:l});var u=t.displaced,f=t.displacedBy,d=u.all[0];if(d){var h=n[d];if(_s(d,s))return uk({axis:c,moveRelativeTo:h.page,isMoving:l});var p=Fv(h.page,f.point);return uk({axis:c,moveRelativeTo:p,isMoving:l})}var y=o[o.length-1];if(y.descriptor.id===r.descriptor.id)return l.borderBox.center;if(_s(y.descriptor.id,s)){var v=Fv(y.page,Ou(s.displacedBy.point));return ck({axis:c,moveRelativeTo:v,isMoving:l})}return ck({axis:c,moveRelativeTo:y.page,isMoving:l})},Mw=function(e,t){var r=e.frame;return r?hr(t,r.scroll.diff.displacement):t},MSe=function(t){var r=t.impact,n=t.draggable,a=t.droppable,s=t.draggables,o=t.afterCritical,l=n.page.borderBox.center,c=r.at;return!a||!c?l:c.type==="REORDER"?DSe({impact:r,draggable:n,draggables:s,droppable:a,afterCritical:o}):TSe({impact:r,draggables:s,afterCritical:o})},My=function(e){var t=MSe(e),r=e.droppable,n=r?Mw(r,t):t;return n},j5=function(e,t){var r=un(t,e.scroll.initial),n=Ou(r),a=ua({top:t.y,bottom:t.y+e.frame.height,left:t.x,right:t.x+e.frame.width}),s={frame:a,scroll:{initial:e.scroll.initial,max:e.scroll.max,current:t,diff:{value:r,displacement:n}}};return s};function dk(e,t){return e.map(function(r){return t[r]})}function ISe(e,t){for(var r=0;r1?f.sort(function(d,h){return Or(d)[l.start]-Or(h)[l.start]})[0]:u.sort(function(d,h){var p=sk(r,ok(Or(d))),y=sk(r,ok(Or(h)));return p!==y?p-y:Or(d)[l.start]-Or(h)[l.start]})[0]},fk=function(t,r){var n=t.page.borderBox.center;return _s(t.descriptor.id,r)?un(n,r.displacedBy.point):n},BSe=function(t,r){var n=t.page.borderBox;return _s(t.descriptor.id,r)?Mh(n,Ou(r.displacedBy.point)):n},USe=function(e){var t=e.pageBorderBoxCenter,r=e.viewport,n=e.destination,a=e.insideDestination,s=e.afterCritical,o=a.filter(function(l){return x5({target:BSe(l,s),destination:n,viewport:r.frame,withDroppableDisplacement:!0})}).sort(function(l,c){var u=Rf(t,Mw(n,fk(l,s))),f=Rf(t,Mw(n,fk(c,s)));return ut.left&&e.topt.top}function YSe(e){var t=e.pageBorderBox,r=e.draggable,n=e.candidates,a=r.page.borderBox.center,s=n.map(function(o){var l=o.axis,c=Yo(o.axis.line,t.center[l.line],o.page.borderBox.center[l.crossAxisLine]);return{id:o.descriptor.id,distance:Rf(a,c)}}).sort(function(o,l){return l.distance-o.distance});return s[0]?s[0].id:null}function QSe(e){var t=e.pageBorderBox,r=e.draggable,n=e.droppables,a=ky(n).filter(function(s){if(!s.isEnabled)return!1;var o=s.subject.active;if(!o||!KSe(t,o))return!1;if(O5(o)(t.center))return!0;var l=s.axis,c=o.center[l.crossAxisLine],u=t[l.crossAxisStart],f=t[l.crossAxisEnd],d=Bn(o[l.crossAxisStart],o[l.crossAxisEnd]),h=d(u),p=d(f);return!h&&!p?!0:h?uc});return a.length?a.length===1?a[0].descriptor.id:YSe({pageBorderBox:t,draggable:r,candidates:a}):null}var P5=function(t,r){return ua(Mh(t,r))},XSe=function(e,t){var r=e.frame;return r?P5(t,r.scroll.diff.value):t};function A5(e){var t=e.displaced,r=e.id;return!!(t.visible[r]||t.invisible[r])}function ZSe(e){var t=e.draggable,r=e.closest,n=e.inHomeList;return r?n&&r.descriptor.index>t.descriptor.index?r.descriptor.index-1:r.descriptor.index:null}var JSe=function(e){var t=e.pageBorderBoxWithDroppableScroll,r=e.draggable,n=e.destination,a=e.insideDestination,s=e.last,o=e.viewport,l=e.afterCritical,c=n.axis,u=Ih(n.axis,r.displaceBy),f=u.value,d=t[c.start],h=t[c.end],p=Dy(r,a),y=qs(p,function(m){var x=m.descriptor.id,g=m.page.borderBox.center[c.line],b=_s(x,l),N=A5({displaced:s,id:x});return b?N?h<=g:dx[l.start]+b&&dx[l.start]-u+b&&fx[l.start]+u+b&&dx[l.start]+b&&f=mk)return R5;var s=a/mk,o=$w+TOe*s,l=n==="CANCEL"?o*kOe:o;return Number(l.toFixed(2))},DOe=function(e){var t=e.impact,r=e.draggable,n=e.dimensions,a=e.viewport,s=e.afterCritical,o=n.draggables,l=n.droppables,c=vn(t),u=c?l[c]:null,f=l[r.descriptor.droppableId],d=T5({impact:t,draggable:r,draggables:o,afterCritical:s,droppable:u||f,viewport:a}),h=un(d,r.client.borderBox.center);return h},MOe=function(e){var t=e.draggables,r=e.reason,n=e.lastImpact,a=e.home,s=e.viewport,o=e.onLiftImpact;if(!n.at||r!=="DROP"){var l=E5({draggables:t,impact:o,destination:a,viewport:s,forceShouldAnimate:!0});return{impact:l,didDropInsideDroppable:!1}}if(n.at.type==="REORDER")return{impact:n,didDropInsideDroppable:!0};var c=Ne({},n,{displaced:$f});return{impact:c,didDropInsideDroppable:!0}},IOe=function(e){var t=e.getState,r=e.dispatch;return function(n){return function(a){if(a.type!=="DROP"){n(a);return}var s=t(),o=a.payload.reason;if(s.phase==="COLLECTING"){r(AOe({reason:o}));return}if(s.phase!=="IDLE"){var l=s.phase==="DROP_PENDING"&&s.isWaiting;l&&oe(),s.phase==="DRAGGING"||s.phase==="DROP_PENDING"||oe();var c=s.critical,u=s.dimensions,f=u.draggables[s.critical.draggable.id],d=MOe({reason:o,lastImpact:s.impact,afterCritical:s.afterCritical,onLiftImpact:s.onLiftImpact,home:s.dimensions.droppables[s.critical.droppable.id],viewport:s.viewport,draggables:s.dimensions.draggables}),h=d.impact,p=d.didDropInsideDroppable,y=p?nO(h):null,v=p?_y(h):null,m={index:c.draggable.index,droppableId:c.droppable.id},x={draggableId:f.descriptor.id,type:f.descriptor.type,source:m,reason:o,mode:s.movementMode,destination:y,combine:v},g=DOe({impact:h,draggable:f,dimensions:u,viewport:s.viewport,afterCritical:s.afterCritical}),b={critical:s.critical,afterCritical:s.afterCritical,result:x,impact:h},N=!bs(s.current.client.offset,g)||!!x.combine;if(!N){r(uO({completed:b}));return}var w=_Oe({current:s.current.client.offset,destination:g,reason:o}),S={newHomeClientOffset:g,dropDuration:w,completed:b};r(POe(S))}}}},$5=function(){return{x:window.pageXOffset,y:window.pageYOffset}};function ROe(e){return{eventName:"scroll",options:{passive:!0,capture:!1},fn:function(r){r.target!==window&&r.target!==window.document||e()}}}function $Oe(e){var t=e.onWindowScroll;function r(){t($5())}var n=If(r),a=ROe(n),s=xs;function o(){return s!==xs}function l(){o()&&oe(),s=Rn(window,[a])}function c(){o()||oe(),n.cancel(),s(),s=xs}return{start:l,stop:c,isActive:o}}var LOe=function(t){return t.type==="DROP_COMPLETE"||t.type==="DROP_ANIMATE"||t.type==="FLUSH"},FOe=function(e){var t=$Oe({onWindowScroll:function(n){e.dispatch(bOe({newScroll:n}))}});return function(r){return function(n){!t.isActive()&&n.type==="INITIAL_PUBLISH"&&t.start(),t.isActive()&&LOe(n)&&t.stop(),r(n)}}},BOe=function(e){var t=!1,r=!1,n=setTimeout(function(){r=!0}),a=function(o){t||r||(t=!0,e(o),clearTimeout(n))};return a.wasCalled=function(){return t},a},UOe=function(){var e=[],t=function(s){var o=rO(e,function(u){return u.timerId===s});o===-1&&oe();var l=e.splice(o,1),c=l[0];c.callback()},r=function(s){var o=setTimeout(function(){return t(o)}),l={timerId:o,callback:s};e.push(l)},n=function(){if(e.length){var s=[].concat(e);e.length=0,s.forEach(function(o){clearTimeout(o.timerId),o.callback()})}};return{add:r,flush:n}},zOe=function(t,r){return t==null&&r==null?!0:t==null||r==null?!1:t.droppableId===r.droppableId&&t.index===r.index},WOe=function(t,r){return t==null&&r==null?!0:t==null||r==null?!1:t.draggableId===r.draggableId&&t.droppableId===r.droppableId},HOe=function(t,r){if(t===r)return!0;var n=t.draggable.id===r.draggable.id&&t.draggable.droppableId===r.draggable.droppableId&&t.draggable.type===r.draggable.type&&t.draggable.index===r.draggable.index,a=t.droppable.id===r.droppable.id&&t.droppable.type===r.droppable.type;return n&&a},Ju=function(t,r){r()},Pp=function(t,r){return{draggableId:t.draggable.id,type:t.droppable.type,source:{droppableId:t.droppable.id,index:t.draggable.index},mode:r}},b0=function(t,r,n,a){if(!t){n(a(r));return}var s=BOe(n),o={announce:s};t(r,o),s.wasCalled()||n(a(r))},VOe=function(e,t){var r=UOe(),n=null,a=function(h,p){n&&oe(),Ju("onBeforeCapture",function(){var y=e().onBeforeCapture;if(y){var v={draggableId:h,mode:p};y(v)}})},s=function(h,p){n&&oe(),Ju("onBeforeDragStart",function(){var y=e().onBeforeDragStart;y&&y(Pp(h,p))})},o=function(h,p){n&&oe();var y=Pp(h,p);n={mode:p,lastCritical:h,lastLocation:y.source,lastCombine:null},r.add(function(){Ju("onDragStart",function(){return b0(e().onDragStart,y,t,Xp.onDragStart)})})},l=function(h,p){var y=nO(p),v=_y(p);n||oe();var m=!HOe(h,n.lastCritical);m&&(n.lastCritical=h);var x=!zOe(n.lastLocation,y);x&&(n.lastLocation=y);var g=!WOe(n.lastCombine,v);if(g&&(n.lastCombine=v),!(!m&&!x&&!g)){var b=Ne({},Pp(h,n.mode),{combine:v,destination:y});r.add(function(){Ju("onDragUpdate",function(){return b0(e().onDragUpdate,b,t,Xp.onDragUpdate)})})}},c=function(){n||oe(),r.flush()},u=function(h){n||oe(),n=null,Ju("onDragEnd",function(){return b0(e().onDragEnd,h,t,Xp.onDragEnd)})},f=function(){if(n){var h=Ne({},Pp(n.lastCritical,n.mode),{combine:null,destination:null,reason:"CANCEL"});u(h)}};return{beforeCapture:a,beforeStart:s,start:o,update:l,flush:c,drop:u,abort:f}},qOe=function(e,t){var r=VOe(e,t);return function(n){return function(a){return function(s){if(s.type==="BEFORE_INITIAL_CAPTURE"){r.beforeCapture(s.payload.draggableId,s.payload.movementMode);return}if(s.type==="INITIAL_PUBLISH"){var o=s.payload.critical;r.beforeStart(o,s.payload.movementMode),a(s),r.start(o,s.payload.movementMode);return}if(s.type==="DROP_COMPLETE"){var l=s.payload.completed.result;r.flush(),a(s),r.drop(l);return}if(a(s),s.type==="FLUSH"){r.abort();return}var c=n.getState();c.phase==="DRAGGING"&&r.update(c.critical,c.impact)}}}},GOe=function(e){return function(t){return function(r){if(r.type!=="DROP_ANIMATION_FINISHED"){t(r);return}var n=e.getState();n.phase!=="DROP_ANIMATING"&&oe(),e.dispatch(uO({completed:n.completed}))}}},KOe=function(e){var t=null,r=null;function n(){r&&(cancelAnimationFrame(r),r=null),t&&(t(),t=null)}return function(a){return function(s){if((s.type==="FLUSH"||s.type==="DROP_COMPLETE"||s.type==="DROP_ANIMATION_FINISHED")&&n(),a(s),s.type==="DROP_ANIMATE"){var o={eventName:"scroll",options:{capture:!0,passive:!1,once:!0},fn:function(){var c=e.getState();c.phase==="DROP_ANIMATING"&&e.dispatch(I5())}};r=requestAnimationFrame(function(){r=null,t=Rn(window,[o])})}}}},YOe=function(e){return function(){return function(t){return function(r){(r.type==="DROP_COMPLETE"||r.type==="FLUSH"||r.type==="DROP_ANIMATE")&&e.stopPublishing(),t(r)}}}},QOe=function(e){var t=!1;return function(){return function(r){return function(n){if(n.type==="INITIAL_PUBLISH"){t=!0,e.tryRecordFocus(n.payload.critical.draggable.id),r(n),e.tryRestoreFocusRecorded();return}if(r(n),!!t){if(n.type==="FLUSH"){t=!1,e.tryRestoreFocusRecorded();return}if(n.type==="DROP_COMPLETE"){t=!1;var a=n.payload.completed.result;a.combine&&e.tryShiftRecord(a.draggableId,a.combine.draggableId),e.tryRestoreFocusRecorded()}}}}}},XOe=function(t){return t.type==="DROP_COMPLETE"||t.type==="DROP_ANIMATE"||t.type==="FLUSH"},ZOe=function(e){return function(t){return function(r){return function(n){if(XOe(n)){e.stop(),r(n);return}if(n.type==="INITIAL_PUBLISH"){r(n);var a=t.getState();a.phase!=="DRAGGING"&&oe(),e.start(a);return}r(n),e.scroll(t.getState())}}}},JOe=function(e){return function(t){return function(r){if(t(r),r.type==="PUBLISH_WHILE_DRAGGING"){var n=e.getState();n.phase==="DROP_PENDING"&&(n.isWaiting||e.dispatch(M5({reason:n.reason})))}}}},ePe=W6,tPe=function(e){var t=e.dimensionMarshal,r=e.focusMarshal,n=e.styleMarshal,a=e.getResponders,s=e.announce,o=e.autoScroller;return z6(dOe,ePe(W1e(EOe(n),YOe(t),COe(t),IOe,GOe,KOe,JOe,ZOe(o),FOe,QOe(r),qOe(a,s))))},j0=function(){return{additions:{},removals:{},modified:{}}};function rPe(e){var t=e.registry,r=e.callbacks,n=j0(),a=null,s=function(){a||(r.collectionStarting(),a=requestAnimationFrame(function(){a=null;var f=n,d=f.additions,h=f.removals,p=f.modified,y=Object.keys(d).map(function(x){return t.draggable.getById(x).getDimension(or)}).sort(function(x,g){return x.descriptor.index-g.descriptor.index}),v=Object.keys(p).map(function(x){var g=t.droppable.getById(x),b=g.callbacks.getScrollWhileDragging();return{droppableId:x,scroll:b}}),m={additions:y,removals:Object.keys(h),modified:v};n=j0(),r.publish(m)}))},o=function(f){var d=f.descriptor.id;n.additions[d]=f,n.modified[f.descriptor.droppableId]=!0,n.removals[d]&&delete n.removals[d],s()},l=function(f){var d=f.descriptor;n.removals[d.id]=!0,n.modified[d.droppableId]=!0,n.additions[d.id]&&delete n.additions[d.id],s()},c=function(){a&&(cancelAnimationFrame(a),a=null,n=j0())};return{add:o,remove:l,stop:c}}var L5=function(e){var t=e.scrollHeight,r=e.scrollWidth,n=e.height,a=e.width,s=un({x:r,y:t},{x:a,y:n}),o={x:Math.max(0,s.x),y:Math.max(0,s.y)};return o},F5=function(){var e=document.documentElement;return e||oe(),e},B5=function(){var e=F5(),t=L5({scrollHeight:e.scrollHeight,scrollWidth:e.scrollWidth,width:e.clientWidth,height:e.clientHeight});return t},nPe=function(){var e=$5(),t=B5(),r=e.y,n=e.x,a=F5(),s=a.clientWidth,o=a.clientHeight,l=n+s,c=r+o,u=ua({top:r,left:n,right:l,bottom:c}),f={frame:u,scroll:{initial:e,current:e,max:t,diff:{value:or,displacement:or}}};return f},aPe=function(e){var t=e.critical,r=e.scrollOptions,n=e.registry,a=nPe(),s=a.scroll.current,o=t.droppable,l=n.droppable.getAllByType(o.type).map(function(d){return d.callbacks.getDimensionAndWatchScroll(s,r)}),c=n.draggable.getAllByType(t.draggable.type).map(function(d){return d.getDimension(s)}),u={draggables:m5(c),droppables:p5(l)},f={dimensions:u,critical:t,viewport:a};return f};function vk(e,t,r){if(r.descriptor.id===t.id||r.descriptor.type!==t.type)return!1;var n=e.droppable.getById(r.descriptor.droppableId);return n.descriptor.mode==="virtual"}var iPe=function(e,t){var r=null,n=rPe({callbacks:{publish:t.publishWhileDragging,collectionStarting:t.collectionStarting},registry:e}),a=function(p,y){e.droppable.exists(p)||oe(),r&&t.updateDroppableIsEnabled({id:p,isEnabled:y})},s=function(p,y){r&&(e.droppable.exists(p)||oe(),t.updateDroppableIsCombineEnabled({id:p,isCombineEnabled:y}))},o=function(p,y){r&&(e.droppable.exists(p)||oe(),t.updateDroppableScroll({id:p,newScroll:y}))},l=function(p,y){r&&e.droppable.getById(p).callbacks.scroll(y)},c=function(){if(r){n.stop();var p=r.critical.droppable;e.droppable.getAllByType(p.type).forEach(function(y){return y.callbacks.dragStopped()}),r.unsubscribe(),r=null}},u=function(p){r||oe();var y=r.critical.draggable;p.type==="ADDITION"&&vk(e,y,p.value)&&n.add(p.value),p.type==="REMOVAL"&&vk(e,y,p.value)&&n.remove(p.value)},f=function(p){r&&oe();var y=e.draggable.getById(p.draggableId),v=e.droppable.getById(y.descriptor.droppableId),m={draggable:y.descriptor,droppable:v.descriptor},x=e.subscribe(u);return r={critical:m,unsubscribe:x},aPe({critical:m,registry:e,scrollOptions:p.scrollOptions})},d={updateDroppableIsEnabled:a,updateDroppableIsCombineEnabled:s,scrollDroppable:l,updateDroppableScroll:o,startPublishing:f,stopPublishing:c};return d},U5=function(e,t){return e.phase==="IDLE"?!0:e.phase!=="DROP_ANIMATING"||e.completed.result.draggableId===t?!1:e.completed.result.reason==="DROP"},sPe=function(e){window.scrollBy(e.x,e.y)},oPe=sr(function(e){return ky(e).filter(function(t){return!(!t.isEnabled||!t.frame)})}),lPe=function(t,r){var n=qs(oPe(r),function(a){return a.frame||oe(),O5(a.frame.pageMarginBox)(t)});return n},cPe=function(e){var t=e.center,r=e.destination,n=e.droppables;if(r){var a=n[r];return a.frame?a:null}var s=lPe(t,n);return s},js={startFromPercentage:.25,maxScrollAtPercentage:.05,maxPixelScroll:28,ease:function(t){return Math.pow(t,2)},durationDampening:{stopDampeningAt:1200,accelerateAt:360}},uPe=function(e,t){var r=e[t.size]*js.startFromPercentage,n=e[t.size]*js.maxScrollAtPercentage,a={startScrollingFrom:r,maxScrollValueAt:n};return a},z5=function(e){var t=e.startOfRange,r=e.endOfRange,n=e.current,a=r-t;if(a===0)return 0;var s=n-t,o=s/a;return o},hO=1,dPe=function(e,t){if(e>t.startScrollingFrom)return 0;if(e<=t.maxScrollValueAt)return js.maxPixelScroll;if(e===t.startScrollingFrom)return hO;var r=z5({startOfRange:t.maxScrollValueAt,endOfRange:t.startScrollingFrom,current:e}),n=1-r,a=js.maxPixelScroll*js.ease(n);return Math.ceil(a)},gk=js.durationDampening.accelerateAt,yk=js.durationDampening.stopDampeningAt,fPe=function(e,t){var r=t,n=yk,a=Date.now(),s=a-r;if(s>=yk)return e;if(st.height,s=r.width>t.width;return!s&&!a?n:s&&a?null:{x:s?0:n.x,y:a?0:n.y}},pPe=f5(function(e){return e===0?0:e}),W5=function(e){var t=e.dragStartTime,r=e.container,n=e.subject,a=e.center,s=e.shouldUseTimeDampening,o={top:a.y-r.top,right:r.right-a.x,bottom:r.bottom-a.y,left:a.x-r.left},l=bk({container:r,distanceToEdges:o,dragStartTime:t,axis:aO,shouldUseTimeDampening:s}),c=bk({container:r,distanceToEdges:o,dragStartTime:t,axis:y5,shouldUseTimeDampening:s}),u=pPe({x:c,y:l});if(bs(u,or))return null;var f=hPe({container:r,subject:n,proposedScroll:u});return f?bs(f,or)?null:f:null},mPe=f5(function(e){return e===0?0:e>0?1:-1}),pO=function(){var e=function(r,n){return r<0?r:r>n?r-n:0};return function(t){var r=t.current,n=t.max,a=t.change,s=hr(r,a),o={x:e(s.x,n.x),y:e(s.y,n.y)};return bs(o,or)?null:o}}(),H5=function(t){var r=t.max,n=t.current,a=t.change,s={x:Math.max(n.x,r.x),y:Math.max(n.y,r.y)},o=mPe(a),l=pO({max:s,current:n,change:o});return!l||o.x!==0&&l.x===0||o.y!==0&&l.y===0},mO=function(t,r){return H5({current:t.scroll.current,max:t.scroll.max,change:r})},vPe=function(t,r){if(!mO(t,r))return null;var n=t.scroll.max,a=t.scroll.current;return pO({current:a,max:n,change:r})},vO=function(t,r){var n=t.frame;return n?H5({current:n.scroll.current,max:n.scroll.max,change:r}):!1},gPe=function(t,r){var n=t.frame;return!n||!vO(t,r)?null:pO({current:n.scroll.current,max:n.scroll.max,change:r})},yPe=function(e){var t=e.viewport,r=e.subject,n=e.center,a=e.dragStartTime,s=e.shouldUseTimeDampening,o=W5({dragStartTime:a,container:t.frame,subject:r,center:n,shouldUseTimeDampening:s});return o&&mO(t,o)?o:null},xPe=function(e){var t=e.droppable,r=e.subject,n=e.center,a=e.dragStartTime,s=e.shouldUseTimeDampening,o=t.frame;if(!o)return null;var l=W5({dragStartTime:a,container:o.pageMarginBox,subject:r,center:n,shouldUseTimeDampening:s});return l&&vO(t,l)?l:null},jk=function(e){var t=e.state,r=e.dragStartTime,n=e.shouldUseTimeDampening,a=e.scrollWindow,s=e.scrollDroppable,o=t.current.page.borderBoxCenter,l=t.dimensions.draggables[t.critical.draggable.id],c=l.page.marginBox;if(t.isWindowScrollAllowed){var u=t.viewport,f=yPe({dragStartTime:r,viewport:u,subject:c,center:o,shouldUseTimeDampening:n});if(f){a(f);return}}var d=cPe({center:o,destination:vn(t.impact),droppables:t.dimensions.droppables});if(d){var h=xPe({dragStartTime:r,droppable:d,subject:c,center:o,shouldUseTimeDampening:n});h&&s(d.descriptor.id,h)}},bPe=function(e){var t=e.scrollWindow,r=e.scrollDroppable,n=If(t),a=If(r),s=null,o=function(f){s||oe();var d=s,h=d.shouldUseTimeDampening,p=d.dragStartTime;jk({state:f,scrollWindow:n,scrollDroppable:a,dragStartTime:p,shouldUseTimeDampening:h})},l=function(f){s&&oe();var d=Date.now(),h=!1,p=function(){h=!0};jk({state:f,dragStartTime:0,shouldUseTimeDampening:!1,scrollWindow:p,scrollDroppable:p}),s={dragStartTime:d,shouldUseTimeDampening:h},h&&o(f)},c=function(){s&&(n.cancel(),a.cancel(),s=null)};return{start:l,stop:c,scroll:o}},jPe=function(e){var t=e.move,r=e.scrollDroppable,n=e.scrollWindow,a=function(u,f){var d=hr(u.current.client.selection,f);t({client:d})},s=function(u,f){if(!vO(u,f))return f;var d=gPe(u,f);if(!d)return r(u.descriptor.id,f),null;var h=un(f,d);r(u.descriptor.id,h);var p=un(f,h);return p},o=function(u,f,d){if(!u||!mO(f,d))return d;var h=vPe(f,d);if(!h)return n(d),null;var p=un(d,h);n(p);var y=un(d,p);return y},l=function(u){var f=u.scrollJumpRequest;if(f){var d=vn(u.impact);d||oe();var h=s(u.dimensions.droppables[d],f);if(h){var p=u.viewport,y=o(u.isWindowScrollAllowed,p,h);y&&a(u,y)}}};return l},wPe=function(e){var t=e.scrollDroppable,r=e.scrollWindow,n=e.move,a=bPe({scrollWindow:r,scrollDroppable:t}),s=jPe({move:n,scrollWindow:r,scrollDroppable:t}),o=function(u){if(u.phase==="DRAGGING"){if(u.movementMode==="FLUID"){a.scroll(u);return}u.scrollJumpRequest&&s(u)}},l={scroll:o,start:a.start,stop:a.stop};return l},Zc="data-rbd",Jc=function(){var e=Zc+"-drag-handle";return{base:e,draggableId:e+"-draggable-id",contextId:e+"-context-id"}}(),Lw=function(){var e=Zc+"-draggable";return{base:e,contextId:e+"-context-id",id:e+"-id"}}(),NPe=function(){var e=Zc+"-droppable";return{base:e,contextId:e+"-context-id",id:e+"-id"}}(),wk={contextId:Zc+"-scroll-container-context-id"},SPe=function(t){return function(r){return"["+r+'="'+t+'"]'}},ed=function(t,r){return t.map(function(n){var a=n.styles[r];return a?n.selector+" { "+a+" }":""}).join(" ")},OPe="pointer-events: none;",PPe=function(e){var t=SPe(e),r=function(){var l=` cursor: -webkit-grab; cursor: grab; `;return{selector:t(Jc.contextId),styles:{always:` -webkit-touch-callout: none; -webkit-tap-highlight-color: rgba(0,0,0,0); touch-action: manipulation; `,resting:l,dragging:OPe,dropAnimating:l}}}(),n=function(){var l=` transition: `+Ed.outOfTheWay+`; `;return{selector:t(Lw.contextId),styles:{dragging:l,dropAnimating:l,userCancel:l}}}(),a={selector:t(NPe.contextId),styles:{always:"overflow-anchor: none;"}},s={selector:"body",styles:{dragging:` cursor: grabbing; cursor: -webkit-grabbing; user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; overflow-anchor: none; `}},o=[n,r,a,s];return{always:ed(o,"always"),resting:ed(o,"resting"),dragging:ed(o,"dragging"),dropAnimating:ed(o,"dropAnimating"),userCancel:ed(o,"userCancel")}},gn=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?j.useLayoutEffect:j.useEffect,w0=function(){var t=document.querySelector("head");return t||oe(),t},Nk=function(t){var r=document.createElement("style");return t&&r.setAttribute("nonce",t),r.type="text/css",r};function APe(e,t){var r=Ge(function(){return PPe(e)},[e]),n=j.useRef(null),a=j.useRef(null),s=be(sr(function(d){var h=a.current;h||oe(),h.textContent=d}),[]),o=be(function(d){var h=n.current;h||oe(),h.textContent=d},[]);gn(function(){!n.current&&!a.current||oe();var d=Nk(t),h=Nk(t);return n.current=d,a.current=h,d.setAttribute(Zc+"-always",e),h.setAttribute(Zc+"-dynamic",e),w0().appendChild(d),w0().appendChild(h),o(r.always),s(r.resting),function(){var p=function(v){var m=v.current;m||oe(),w0().removeChild(m),v.current=null};p(n),p(a)}},[t,o,s,r.always,r.resting,e]);var l=be(function(){return s(r.dragging)},[s,r.dragging]),c=be(function(d){if(d==="DROP"){s(r.dropAnimating);return}s(r.userCancel)},[s,r.dropAnimating,r.userCancel]),u=be(function(){a.current&&s(r.resting)},[s,r.resting]),f=Ge(function(){return{dragging:l,dropping:c,resting:u}},[l,c,u]);return f}var V5=function(e){return e&&e.ownerDocument?e.ownerDocument.defaultView:window};function Iy(e){return e instanceof V5(e).HTMLElement}function CPe(e,t){var r="["+Jc.contextId+'="'+e+'"]',n=h5(document.querySelectorAll(r));if(!n.length)return null;var a=qs(n,function(s){return s.getAttribute(Jc.draggableId)===t});return!a||!Iy(a)?null:a}function EPe(e){var t=j.useRef({}),r=j.useRef(null),n=j.useRef(null),a=j.useRef(!1),s=be(function(h,p){var y={id:h,focus:p};return t.current[h]=y,function(){var m=t.current,x=m[h];x!==y&&delete m[h]}},[]),o=be(function(h){var p=CPe(e,h);p&&p!==document.activeElement&&p.focus()},[e]),l=be(function(h,p){r.current===h&&(r.current=p)},[]),c=be(function(){n.current||a.current&&(n.current=requestAnimationFrame(function(){n.current=null;var h=r.current;h&&o(h)}))},[o]),u=be(function(h){r.current=null;var p=document.activeElement;p&&p.getAttribute(Jc.draggableId)===h&&(r.current=h)},[]);gn(function(){return a.current=!0,function(){a.current=!1;var h=n.current;h&&cancelAnimationFrame(h)}},[]);var f=Ge(function(){return{register:s,tryRecordFocus:u,tryRestoreFocusRecorded:c,tryShiftRecord:l}},[s,u,c,l]);return f}function TPe(){var e={draggables:{},droppables:{}},t=[];function r(d){return t.push(d),function(){var p=t.indexOf(d);p!==-1&&t.splice(p,1)}}function n(d){t.length&&t.forEach(function(h){return h(d)})}function a(d){return e.draggables[d]||null}function s(d){var h=a(d);return h||oe(),h}var o={register:function(h){e.draggables[h.descriptor.id]=h,n({type:"ADDITION",value:h})},update:function(h,p){var y=e.draggables[p.descriptor.id];y&&y.uniqueId===h.uniqueId&&(delete e.draggables[p.descriptor.id],e.draggables[h.descriptor.id]=h)},unregister:function(h){var p=h.descriptor.id,y=a(p);y&&h.uniqueId===y.uniqueId&&(delete e.draggables[p],n({type:"REMOVAL",value:h}))},getById:s,findById:a,exists:function(h){return!!a(h)},getAllByType:function(h){return Wv(e.draggables).filter(function(p){return p.descriptor.type===h})}};function l(d){return e.droppables[d]||null}function c(d){var h=l(d);return h||oe(),h}var u={register:function(h){e.droppables[h.descriptor.id]=h},unregister:function(h){var p=l(h.descriptor.id);p&&h.uniqueId===p.uniqueId&&delete e.droppables[h.descriptor.id]},getById:c,findById:l,exists:function(h){return!!l(h)},getAllByType:function(h){return Wv(e.droppables).filter(function(p){return p.descriptor.type===h})}};function f(){e.draggables={},e.droppables={},t.length=0}return{draggable:o,droppable:u,subscribe:r,clean:f}}function kPe(){var e=Ge(TPe,[]);return j.useEffect(function(){return function(){requestAnimationFrame(e.clean)}},[e]),e}var gO=M.createContext(null),Vv=function(){var e=document.body;return e||oe(),e},_Pe={position:"absolute",width:"1px",height:"1px",margin:"-1px",border:"0",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)","clip-path":"inset(100%)"},DPe=function(t){return"rbd-announcement-"+t};function MPe(e){var t=Ge(function(){return DPe(e)},[e]),r=j.useRef(null);j.useEffect(function(){var s=document.createElement("div");return r.current=s,s.id=t,s.setAttribute("aria-live","assertive"),s.setAttribute("aria-atomic","true"),Ne(s.style,_Pe),Vv().appendChild(s),function(){setTimeout(function(){var c=Vv();c.contains(s)&&c.removeChild(s),s===r.current&&(r.current=null)})}},[t]);var n=be(function(a){var s=r.current;if(s){s.textContent=a;return}},[]);return n}var IPe=0,RPe={separator:"::"};function yO(e,t){return t===void 0&&(t=RPe),Ge(function(){return""+e+t.separator+IPe++},[t.separator,e])}function $Pe(e){var t=e.contextId,r=e.uniqueId;return"rbd-hidden-text-"+t+"-"+r}function LPe(e){var t=e.contextId,r=e.text,n=yO("hidden-text",{separator:"-"}),a=Ge(function(){return $Pe({contextId:t,uniqueId:n})},[n,t]);return j.useEffect(function(){var o=document.createElement("div");return o.id=a,o.textContent=r,o.style.display="none",Vv().appendChild(o),function(){var c=Vv();c.contains(o)&&c.removeChild(o)}},[a,r]),a}var Ry=M.createContext(null);function q5(e){var t=j.useRef(e);return j.useEffect(function(){t.current=e}),t}function FPe(){var e=null;function t(){return!!e}function r(o){return o===e}function n(o){e&&oe();var l={abandon:o};return e=l,l}function a(){e||oe(),e=null}function s(){e&&(e.abandon(),a())}return{isClaimed:t,isActive:r,claim:n,release:a,tryAbandon:s}}var BPe=9,UPe=13,xO=27,G5=32,zPe=33,WPe=34,HPe=35,VPe=36,qPe=37,GPe=38,KPe=39,YPe=40,Ap,QPe=(Ap={},Ap[UPe]=!0,Ap[BPe]=!0,Ap),K5=function(e){QPe[e.keyCode]&&e.preventDefault()},$y=function(){var e="visibilitychange";if(typeof document>"u")return e;var t=[e,"ms"+e,"webkit"+e,"moz"+e,"o"+e],r=qs(t,function(n){return"on"+n in document});return r||e}(),Y5=0,Sk=5;function XPe(e,t){return Math.abs(t.x-e.x)>=Sk||Math.abs(t.y-e.y)>=Sk}var Ok={type:"IDLE"};function ZPe(e){var t=e.cancel,r=e.completed,n=e.getPhase,a=e.setPhase;return[{eventName:"mousemove",fn:function(o){var l=o.button,c=o.clientX,u=o.clientY;if(l===Y5){var f={x:c,y:u},d=n();if(d.type==="DRAGGING"){o.preventDefault(),d.actions.move(f);return}d.type!=="PENDING"&&oe();var h=d.point;if(XPe(h,f)){o.preventDefault();var p=d.actions.fluidLift(f);a({type:"DRAGGING",actions:p})}}}},{eventName:"mouseup",fn:function(o){var l=n();if(l.type!=="DRAGGING"){t();return}o.preventDefault(),l.actions.drop({shouldBlockNextClick:!0}),r()}},{eventName:"mousedown",fn:function(o){n().type==="DRAGGING"&&o.preventDefault(),t()}},{eventName:"keydown",fn:function(o){var l=n();if(l.type==="PENDING"){t();return}if(o.keyCode===xO){o.preventDefault(),t();return}K5(o)}},{eventName:"resize",fn:t},{eventName:"scroll",options:{passive:!0,capture:!1},fn:function(){n().type==="PENDING"&&t()}},{eventName:"webkitmouseforcedown",fn:function(o){var l=n();if(l.type==="IDLE"&&oe(),l.actions.shouldRespectForcePress()){t();return}o.preventDefault()}},{eventName:$y,fn:t}]}function JPe(e){var t=j.useRef(Ok),r=j.useRef(xs),n=Ge(function(){return{eventName:"mousedown",fn:function(d){if(!d.defaultPrevented&&d.button===Y5&&!(d.ctrlKey||d.metaKey||d.shiftKey||d.altKey)){var h=e.findClosestDraggableId(d);if(h){var p=e.tryGetLock(h,o,{sourceEvent:d});if(p){d.preventDefault();var y={x:d.clientX,y:d.clientY};r.current(),u(p,y)}}}}}},[e]),a=Ge(function(){return{eventName:"webkitmouseforcewillbegin",fn:function(d){if(!d.defaultPrevented){var h=e.findClosestDraggableId(d);if(h){var p=e.findOptionsForDraggable(h);p&&(p.shouldRespectForcePress||e.canGetLock(h)&&d.preventDefault())}}}}},[e]),s=be(function(){var d={passive:!1,capture:!0};r.current=Rn(window,[a,n],d)},[a,n]),o=be(function(){var f=t.current;f.type!=="IDLE"&&(t.current=Ok,r.current(),s())},[s]),l=be(function(){var f=t.current;o(),f.type==="DRAGGING"&&f.actions.cancel({shouldBlockNextClick:!0}),f.type==="PENDING"&&f.actions.abort()},[o]),c=be(function(){var d={capture:!0,passive:!1},h=ZPe({cancel:l,completed:o,getPhase:function(){return t.current},setPhase:function(y){t.current=y}});r.current=Rn(window,h,d)},[l,o]),u=be(function(d,h){t.current.type!=="IDLE"&&oe(),t.current={type:"PENDING",point:h,actions:d},c()},[c]);gn(function(){return s(),function(){r.current()}},[s])}var hl;function eAe(){}var tAe=(hl={},hl[WPe]=!0,hl[zPe]=!0,hl[VPe]=!0,hl[HPe]=!0,hl);function rAe(e,t){function r(){t(),e.cancel()}function n(){t(),e.drop()}return[{eventName:"keydown",fn:function(s){if(s.keyCode===xO){s.preventDefault(),r();return}if(s.keyCode===G5){s.preventDefault(),n();return}if(s.keyCode===YPe){s.preventDefault(),e.moveDown();return}if(s.keyCode===GPe){s.preventDefault(),e.moveUp();return}if(s.keyCode===KPe){s.preventDefault(),e.moveRight();return}if(s.keyCode===qPe){s.preventDefault(),e.moveLeft();return}if(tAe[s.keyCode]){s.preventDefault();return}K5(s)}},{eventName:"mousedown",fn:r},{eventName:"mouseup",fn:r},{eventName:"click",fn:r},{eventName:"touchstart",fn:r},{eventName:"resize",fn:r},{eventName:"wheel",fn:r,options:{passive:!0}},{eventName:$y,fn:r}]}function nAe(e){var t=j.useRef(eAe),r=Ge(function(){return{eventName:"keydown",fn:function(s){if(s.defaultPrevented||s.keyCode!==G5)return;var o=e.findClosestDraggableId(s);if(!o)return;var l=e.tryGetLock(o,f,{sourceEvent:s});if(!l)return;s.preventDefault();var c=!0,u=l.snapLift();t.current();function f(){c||oe(),c=!1,t.current(),n()}t.current=Rn(window,rAe(u,f),{capture:!0,passive:!1})}}},[e]),n=be(function(){var s={passive:!1,capture:!0};t.current=Rn(window,[r],s)},[r]);gn(function(){return n(),function(){t.current()}},[n])}var N0={type:"IDLE"},aAe=120,iAe=.15;function sAe(e){var t=e.cancel,r=e.getPhase;return[{eventName:"orientationchange",fn:t},{eventName:"resize",fn:t},{eventName:"contextmenu",fn:function(a){a.preventDefault()}},{eventName:"keydown",fn:function(a){if(r().type!=="DRAGGING"){t();return}a.keyCode===xO&&a.preventDefault(),t()}},{eventName:$y,fn:t}]}function oAe(e){var t=e.cancel,r=e.completed,n=e.getPhase;return[{eventName:"touchmove",options:{capture:!1},fn:function(s){var o=n();if(o.type!=="DRAGGING"){t();return}o.hasMoved=!0;var l=s.touches[0],c=l.clientX,u=l.clientY,f={x:c,y:u};s.preventDefault(),o.actions.move(f)}},{eventName:"touchend",fn:function(s){var o=n();if(o.type!=="DRAGGING"){t();return}s.preventDefault(),o.actions.drop({shouldBlockNextClick:!0}),r()}},{eventName:"touchcancel",fn:function(s){if(n().type!=="DRAGGING"){t();return}s.preventDefault(),t()}},{eventName:"touchforcechange",fn:function(s){var o=n();o.type==="IDLE"&&oe();var l=s.touches[0];if(l){var c=l.force>=iAe;if(c){var u=o.actions.shouldRespectForcePress();if(o.type==="PENDING"){u&&t();return}if(u){if(o.hasMoved){s.preventDefault();return}t();return}s.preventDefault()}}}},{eventName:$y,fn:t}]}function lAe(e){var t=j.useRef(N0),r=j.useRef(xs),n=be(function(){return t.current},[]),a=be(function(p){t.current=p},[]),s=Ge(function(){return{eventName:"touchstart",fn:function(p){if(!p.defaultPrevented){var y=e.findClosestDraggableId(p);if(y){var v=e.tryGetLock(y,l,{sourceEvent:p});if(v){var m=p.touches[0],x=m.clientX,g=m.clientY,b={x,y:g};r.current(),d(v,b)}}}}}},[e]),o=be(function(){var p={capture:!0,passive:!1};r.current=Rn(window,[s],p)},[s]),l=be(function(){var h=t.current;h.type!=="IDLE"&&(h.type==="PENDING"&&clearTimeout(h.longPressTimerId),a(N0),r.current(),o())},[o,a]),c=be(function(){var h=t.current;l(),h.type==="DRAGGING"&&h.actions.cancel({shouldBlockNextClick:!0}),h.type==="PENDING"&&h.actions.abort()},[l]),u=be(function(){var p={capture:!0,passive:!1},y={cancel:c,completed:l,getPhase:n},v=Rn(window,oAe(y),p),m=Rn(window,sAe(y),p);r.current=function(){v(),m()}},[c,n,l]),f=be(function(){var p=n();p.type!=="PENDING"&&oe();var y=p.actions.fluidLift(p.point);a({type:"DRAGGING",actions:y,hasMoved:!1})},[n,a]),d=be(function(p,y){n().type!=="IDLE"&&oe();var v=setTimeout(f,aAe);a({type:"PENDING",point:y,actions:p,longPressTimerId:v}),u()},[u,n,a,f]);gn(function(){return o(),function(){r.current();var y=n();y.type==="PENDING"&&(clearTimeout(y.longPressTimerId),a(N0))}},[n,o,a]),gn(function(){var p=Rn(window,[{eventName:"touchmove",fn:function(){},options:{capture:!1,passive:!1}}]);return p},[])}var cAe={input:!0,button:!0,textarea:!0,select:!0,option:!0,optgroup:!0,video:!0,audio:!0};function Q5(e,t){if(t==null)return!1;var r=!!cAe[t.tagName.toLowerCase()];if(r)return!0;var n=t.getAttribute("contenteditable");return n==="true"||n===""?!0:t===e?!1:Q5(e,t.parentElement)}function uAe(e,t){var r=t.target;return Iy(r)?Q5(e,r):!1}var dAe=function(e){return ua(e.getBoundingClientRect()).center};function fAe(e){return e instanceof V5(e).Element}var hAe=function(){var e="matches";if(typeof document>"u")return e;var t=[e,"msMatchesSelector","webkitMatchesSelector"],r=qs(t,function(n){return n in Element.prototype});return r||e}();function X5(e,t){return e==null?null:e[hAe](t)?e:X5(e.parentElement,t)}function pAe(e,t){return e.closest?e.closest(t):X5(e,t)}function mAe(e){return"["+Jc.contextId+'="'+e+'"]'}function vAe(e,t){var r=t.target;if(!fAe(r))return null;var n=mAe(e),a=pAe(r,n);return!a||!Iy(a)?null:a}function gAe(e,t){var r=vAe(e,t);return r?r.getAttribute(Jc.draggableId):null}function yAe(e,t){var r="["+Lw.contextId+'="'+e+'"]',n=h5(document.querySelectorAll(r)),a=qs(n,function(s){return s.getAttribute(Lw.id)===t});return!a||!Iy(a)?null:a}function xAe(e){e.preventDefault()}function Cp(e){var t=e.expected,r=e.phase,n=e.isLockActive;return e.shouldWarn,!(!n()||t!==r)}function Z5(e){var t=e.lockAPI,r=e.store,n=e.registry,a=e.draggableId;if(t.isClaimed())return!1;var s=n.draggable.findById(a);return!(!s||!s.options.isEnabled||!U5(r.getState(),a))}function bAe(e){var t=e.lockAPI,r=e.contextId,n=e.store,a=e.registry,s=e.draggableId,o=e.forceSensorStop,l=e.sourceEvent,c=Z5({lockAPI:t,store:n,registry:a,draggableId:s});if(!c)return null;var u=a.draggable.getById(s),f=yAe(r,u.descriptor.id);if(!f||l&&!u.options.canDragInteractiveElements&&uAe(f,l))return null;var d=t.claim(o||xs),h="PRE_DRAG";function p(){return u.options.shouldRespectForcePress}function y(){return t.isActive(d)}function v(S,O){Cp({expected:S,phase:h,isLockActive:y,shouldWarn:!0})&&n.dispatch(O())}var m=v.bind(null,"DRAGGING");function x(S){function O(){t.release(),h="COMPLETED"}h!=="PRE_DRAG"&&(O(),h!=="PRE_DRAG"&&oe()),n.dispatch(hOe(S.liftActionArgs)),h="DRAGGING";function P(A,C){if(C===void 0&&(C={shouldBlockNextClick:!1}),S.cleanup(),C.shouldBlockNextClick){var T=Rn(window,[{eventName:"click",fn:xAe,options:{once:!0,passive:!1,capture:!0}}]);setTimeout(T)}O(),n.dispatch(M5({reason:A}))}return Ne({isActive:function(){return Cp({expected:"DRAGGING",phase:h,isLockActive:y,shouldWarn:!1})},shouldRespectForcePress:p,drop:function(C){return P("DROP",C)},cancel:function(C){return P("CANCEL",C)}},S.actions)}function g(S){var O=If(function(A){m(function(){return D5({client:A})})}),P=x({liftActionArgs:{id:s,clientSelection:S,movementMode:"FLUID"},cleanup:function(){return O.cancel()},actions:{move:O}});return Ne({},P,{move:O})}function b(){var S={moveUp:function(){return m(wOe)},moveRight:function(){return m(SOe)},moveDown:function(){return m(NOe)},moveLeft:function(){return m(OOe)}};return x({liftActionArgs:{id:s,clientSelection:dAe(f),movementMode:"SNAP"},cleanup:xs,actions:S})}function N(){var S=Cp({expected:"PRE_DRAG",phase:h,isLockActive:y,shouldWarn:!0});S&&t.release()}var w={isActive:function(){return Cp({expected:"PRE_DRAG",phase:h,isLockActive:y,shouldWarn:!1})},shouldRespectForcePress:p,fluidLift:g,snapLift:b,abort:N};return w}var jAe=[JPe,nAe,lAe];function wAe(e){var t=e.contextId,r=e.store,n=e.registry,a=e.customSensors,s=e.enableDefaultSensors,o=[].concat(s?jAe:[],a||[]),l=j.useState(function(){return FPe()})[0],c=be(function(g,b){g.isDragging&&!b.isDragging&&l.tryAbandon()},[l]);gn(function(){var g=r.getState(),b=r.subscribe(function(){var N=r.getState();c(g,N),g=N});return b},[l,r,c]),gn(function(){return l.tryAbandon},[l.tryAbandon]);for(var u=be(function(x){return Z5({lockAPI:l,registry:n,store:r,draggableId:x})},[l,n,r]),f=be(function(x,g,b){return bAe({lockAPI:l,registry:n,contextId:t,store:r,draggableId:x,forceSensorStop:g,sourceEvent:b&&b.sourceEvent?b.sourceEvent:null})},[t,l,n,r]),d=be(function(x){return gAe(t,x)},[t]),h=be(function(x){var g=n.draggable.findById(x);return g?g.options:null},[n.draggable]),p=be(function(){l.isClaimed()&&(l.tryAbandon(),r.getState().phase!=="IDLE"&&r.dispatch(cO()))},[l,r]),y=be(l.isClaimed,[l]),v=Ge(function(){return{canGetLock:u,tryGetLock:f,findClosestDraggableId:d,findOptionsForDraggable:h,tryReleaseLock:p,isLockClaimed:y}},[u,f,d,h,p,y]),m=0;m{if(!a.name||!a.label)return;const h={id:Date.now().toString(),name:a.name,label:a.label,type:a.type||"text",required:a.required||!1,visible:a.visible!==!1,order:r.length+1,options:a.options,placeholder:a.placeholder,validation:a.validation};n([...r,h]),s({type:"text",required:!1,visible:!0})},l=h=>{n(r.filter(p=>p.id!==h))},c=(h,p)=>{n(r.map(y=>y.id===h?{...y,...p}:y))},u=h=>{if(!h.destination)return;const p=Array.from(r),[y]=p.splice(h.source.index,1);p.splice(h.destination.index,0,y);const v=p.map((m,x)=>({...m,order:x+1}));n(v)},f=()=>{e(r)};return i.jsxs("div",{className:"space-y-6",children:[i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{children:"Manage Order Form Fields"})}),i.jsx(H,{children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx(X,{children:"Field Name"}),i.jsx(he,{value:a.name||"",onChange:h=>s({...a,name:h.target.value}),placeholder:"fieldName"})]}),i.jsxs("div",{children:[i.jsx(X,{children:"Field Label"}),i.jsx(he,{value:a.label||"",onChange:h=>s({...a,label:h.target.value}),placeholder:"Display Label"})]})]}),i.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[i.jsxs("div",{children:[i.jsx(X,{children:"Field Type"}),i.jsxs(_e,{value:a.type,onValueChange:h=>s({...a,type:h}),children:[i.jsx(Ae,{children:i.jsx(De,{})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"text",children:"Text"}),i.jsx(U,{value:"number",children:"Number"}),i.jsx(U,{value:"select",children:"Select"}),i.jsx(U,{value:"checkbox",children:"Checkbox"}),i.jsx(U,{value:"textarea",children:"Textarea"})]})]})]}),i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx(_l,{checked:a.required,onCheckedChange:h=>s({...a,required:h})}),i.jsx(X,{children:"Required"})]}),i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx(_l,{checked:a.visible!==!1,onCheckedChange:h=>s({...a,visible:h})}),i.jsx(X,{children:"Visible"})]})]}),a.type==="select"&&i.jsxs("div",{children:[i.jsx(X,{children:"Options (comma separated)"}),i.jsx(he,{value:((d=a.options)==null?void 0:d.join(", "))||"",onChange:h=>s({...a,options:h.target.value.split(",").map(p=>p.trim()).filter(Boolean)}),placeholder:"option1, option2, option3"})]}),i.jsxs(z,{onClick:o,className:"w-full",children:[i.jsx(fn,{className:"w-4 h-4 mr-2"}),"Add Field"]})]})})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{children:"Current Fields"})}),i.jsx(H,{children:i.jsx(AAe,{onDragEnd:u,children:i.jsx(aB,{droppableId:"fields",children:h=>i.jsxs("div",{...h.droppableProps,ref:h.innerRef,className:"space-y-2",children:[r.map((p,y)=>i.jsx(uCe,{draggableId:p.id,index:y,children:v=>i.jsx("div",{ref:v.innerRef,...v.draggableProps,className:"border rounded-lg p-4 bg-white",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx("div",{...v.dragHandleProps,children:i.jsx(VW,{className:"w-4 h-4 text-gray-400"})}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium",children:p.label}),i.jsxs("div",{className:"text-sm text-gray-500",children:[p.name," • ",p.type,p.required&&" • Required",!p.visible&&" • Hidden"]})]})]}),i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx(_l,{checked:p.visible,onCheckedChange:m=>c(p.id,{visible:m})}),i.jsx(_l,{checked:p.required,onCheckedChange:m=>c(p.id,{required:m})}),i.jsx(z,{variant:"ghost",size:"sm",onClick:()=>l(p.id),children:i.jsx(jc,{className:"w-4 h-4"})})]})]})})},p.id)),h.placeholder]})})})})]}),i.jsx(z,{onClick:f,className:"w-full",size:"lg",children:"Save Field Configuration"})]})}function _k({order:e,isOpen:t,onClose:r}){const[n,a]=j.useState(""),[s,o]=j.useState(""),{toast:l}=Ht(),c=$r(),u=rt({mutationFn:async({orderId:v,notes:m})=>ut("POST",`/api/orders/${v}/approve`,{notes:m}),onSuccess:()=>{l({title:"Order Approved",description:"The order has been successfully approved"}),c.invalidateQueries({queryKey:["/api/orders"]}),c.invalidateQueries({queryKey:["/api/orders/stats"]}),a(""),r()},onError:v=>{l({title:"Approval Failed",description:v.message||"Failed to approve order",variant:"destructive"})}}),f=rt({mutationFn:async({orderId:v,notes:m})=>ut("POST",`/api/orders/${v}/reject`,{notes:m}),onSuccess:()=>{l({title:"Order Rejected",description:"The order has been successfully rejected"}),c.invalidateQueries({queryKey:["/api/orders"]}),c.invalidateQueries({queryKey:["/api/orders/stats"]}),o(""),r()},onError:v=>{l({title:"Rejection Failed",description:v.message||"Failed to reject order",variant:"destructive"})}}),d=()=>{e&&u.mutate({orderId:e.id,notes:n})},h=()=>{e&&f.mutate({orderId:e.id,notes:s})},p=v=>`ETB ${parseFloat(v).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`,y=v=>new Date(v).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return e?i.jsx(zt,{open:t,onOpenChange:r,children:i.jsxs($t,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[i.jsx(Lt,{children:i.jsxs(Ft,{children:["Order Details - ",e.orderNumber]})}),i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs(W,{children:[i.jsx(J,{className:"pb-3",children:i.jsx(ee,{className:"text-lg",children:"Customer Information"})}),i.jsxs(H,{className:"space-y-2",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-sm text-gray-500",children:"Customer Name:"}),i.jsx("p",{className:"font-medium",children:e.customerName})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-sm text-gray-500",children:"Business Sector:"}),i.jsx("p",{className:"font-medium",children:e.businessSector})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-sm text-gray-500",children:"Area:"}),i.jsx("p",{className:"font-medium",children:e.area})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-sm text-gray-500",children:"Payment Term:"}),i.jsx("p",{className:"font-medium",children:e.paymentTerm})]})]})]}),i.jsxs(W,{children:[i.jsx(J,{className:"pb-3",children:i.jsx(ee,{className:"text-lg",children:"Order Summary"})}),i.jsxs(H,{className:"space-y-2",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-sm text-gray-500",children:"Order Number:"}),i.jsx("p",{className:"font-medium",children:e.orderNumber})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-sm text-gray-500",children:"Total Amount:"}),i.jsx("p",{className:"font-medium text-green-600",children:p(e.totalAmount)})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-sm text-gray-500",children:"Status:"}),i.jsx("div",{className:"mt-1",children:i.jsx(te,{variant:e.status==="pending"?"outline":e.status==="approved"?"default":"destructive",children:e.status})})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-sm text-gray-500",children:"Created:"}),i.jsx("p",{className:"font-medium",children:y(e.createdAt)})]})]})]})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"text-lg flex items-center gap-2",children:[i.jsx(Ot,{className:"w-5 h-5"}),"Order Items"]})}),i.jsx(H,{children:i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b",children:[i.jsx("th",{className:"text-left p-2",children:"Product"}),i.jsx("th",{className:"text-left p-2",children:"Unit"}),i.jsx("th",{className:"text-left p-2",children:"Quantity"}),i.jsx("th",{className:"text-left p-2",children:"Price"}),i.jsx("th",{className:"text-left p-2",children:"Total"})]})}),i.jsx("tbody",{children:e.items.map((v,m)=>i.jsxs("tr",{className:"border-b",children:[i.jsx("td",{className:"p-2 font-medium",children:v.productType}),i.jsx("td",{className:"p-2",children:v.unit}),i.jsx("td",{className:"p-2",children:v.quantity}),i.jsx("td",{className:"p-2",children:p(v.price.toString())}),i.jsx("td",{className:"p-2 font-medium",children:p(v.total.toString())})]},m))})]})})})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"text-lg flex items-center gap-2",children:[i.jsx(Fn,{className:"w-5 h-5"}),"Sales Officer"]})}),i.jsx(H,{children:i.jsx("p",{className:"font-medium",children:e.salesOfficer?`${e.salesOfficer.firstName} ${e.salesOfficer.lastName}`:"Unknown"})})]}),e.notes&&i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{className:"text-lg",children:"Order Notes"})}),i.jsx(H,{children:i.jsx("p",{className:"text-gray-700",children:e.notes})})]}),(e.approvalNotes||e.rejectionNotes)&&i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{className:"text-lg",children:e.status==="approved"?"Approval Notes":e.status==="rejected"?"Rejection Notes":"Review Notes"})}),i.jsx(H,{children:i.jsxs("div",{className:"space-y-2",children:[e.approvalNotes&&i.jsxs("div",{className:"bg-green-50 border border-green-200 rounded-lg p-3",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx(ct,{className:"w-4 h-4 text-green-600"}),i.jsx("span",{className:"font-medium text-green-800",children:"Approval Notes:"})]}),i.jsx("p",{className:"text-green-700",children:e.approvalNotes})]}),e.rejectionNotes&&i.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-3",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx(ar,{className:"w-4 h-4 text-red-600"}),i.jsx("span",{className:"font-medium text-red-800",children:"Rejection Notes:"})]}),i.jsx("p",{className:"text-red-700",children:e.rejectionNotes})]})]})})]}),e.status==="pending"&&i.jsxs(W,{children:[i.jsx(J,{children:i.jsx(ee,{className:"text-lg",children:"Approval Actions"})}),i.jsx(H,{className:"space-y-4",children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"approval-notes",children:"Approval Notes"}),i.jsx(Wn,{id:"approval-notes",placeholder:"Add notes for approval...",value:n,onChange:v=>a(v.target.value),className:"mt-1",rows:3}),i.jsxs(z,{onClick:d,disabled:u.isPending,className:"w-full mt-2 bg-green-600 hover:bg-green-700",children:[i.jsx(ct,{className:"w-4 h-4 mr-2"}),u.isPending?"Approving...":"Approve Order"]})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"rejection-notes",children:"Rejection Notes"}),i.jsx(Wn,{id:"rejection-notes",placeholder:"Add reason for rejection...",value:s,onChange:v=>o(v.target.value),className:"mt-1",rows:3}),i.jsxs(z,{onClick:h,disabled:f.isPending,variant:"destructive",className:"w-full mt-2",children:[i.jsx(ar,{className:"w-4 h-4 mr-2"}),f.isPending?"Rejecting...":"Reject Order"]})]})]})})]})]})]})}):null}function P0(){const e=hh(),{toast:t}=Ht(),r=$r();Za();const[n,a]=j.useState(null),[s,o]=j.useState(!1),[l,c]=j.useState(!1),u=rt({mutationFn:async x=>ut("POST","/api/order-form/config",x),onSuccess:()=>{t({title:"Configuration Saved",description:"Order form fields have been updated successfully"}),r.invalidateQueries({queryKey:["/api/order-form/config"]})},onError:x=>{t({title:"Save Failed",description:x.message||"Failed to save field configuration",variant:"destructive"})}}),{data:f=[],isLoading:d}=Fe({queryKey:["/api/orders"],select:x=>x.filter(g=>g.status==="pending"||g.status==="approved"||g.status==="rejected").sort((g,b)=>new Date(b.createdAt).getTime()-new Date(g.createdAt).getTime())}),{data:h}=Fe({queryKey:["/api/orders/stats"]}),p=x=>{switch(x){case"approved":return i.jsx(te,{className:"bg-green-100 text-green-800 hover:bg-green-100",children:"Approved"});case"rejected":return i.jsx(te,{variant:"destructive",children:"Rejected"});case"pending":return i.jsx(te,{className:"bg-amber-100 text-amber-800 hover:bg-amber-100",children:"Pending Review"});default:return i.jsx(te,{variant:"outline",children:x})}},y=({order:x})=>i.jsx(W,{className:"hover:shadow-md transition-shadow",children:i.jsxs(H,{className:"p-4",children:[i.jsxs("div",{className:"flex justify-between items-start mb-3",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"font-semibold text-lg",children:x.orderNumber}),i.jsx("p",{className:"text-gray-600",children:x.customerName})]}),p(x.status)]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm mb-3",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-gray-500",children:"Business:"}),i.jsx("p",{className:"font-medium",children:x.businessSector})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-gray-500",children:"Area:"}),i.jsx("p",{className:"font-medium",children:x.area})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-gray-500",children:"Payment:"}),i.jsx("p",{className:"font-medium",children:x.paymentTerm})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-gray-500",children:"Total:"}),i.jsx("p",{className:"font-medium text-green-600",children:Be(x.totalAmount)})]})]}),i.jsxs("div",{className:"flex justify-between items-center",children:[i.jsxs("div",{className:"text-xs text-gray-500",children:[i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx(Fn,{className:"w-3 h-3"}),x.salesOfficer?`${x.salesOfficer.firstName} ${x.salesOfficer.lastName}`:"Unknown"]}),i.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[i.jsx(Dr,{className:"w-3 h-3"}),uY(x.createdAt)]})]}),i.jsxs(z,{variant:"outline",size:"sm",onClick:()=>{a(x),o(!0)},children:[i.jsx(au,{className:"w-4 h-4 mr-1"}),"View Details"]})]})]})}),v=f.filter(x=>x.status==="pending"),m=f.filter(x=>x.status!=="pending");return console.log("Orders data:",f),console.log("Pending orders:",v),console.log("Processed orders:",m),e?i.jsxs(ih,{title:"Order Approvals",children:[i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(W,{children:i.jsxs(H,{className:"p-4 text-center",children:[i.jsx("div",{className:"text-2xl font-bold text-amber-600",children:(h==null?void 0:h.pending)||0}),i.jsx("div",{className:"text-sm text-gray-600",children:"Pending"})]})}),i.jsx(W,{children:i.jsxs(H,{className:"p-4 text-center",children:[i.jsx("div",{className:"text-2xl font-bold text-green-600",children:(h==null?void 0:h.approved)||0}),i.jsx("div",{className:"text-sm text-gray-600",children:"Approved"})]})})]}),i.jsxs(ja,{defaultValue:"pending",className:"w-full",children:[i.jsxs(Hn,{className:"grid w-full grid-cols-3",children:[i.jsxs(Qe,{value:"pending",children:[i.jsx(wr,{className:"w-4 h-4 mr-1"}),"Pending (",v.length,")"]}),i.jsxs(Qe,{value:"processed",children:[i.jsx(Ot,{className:"w-4 h-4 mr-1"}),"Processed (",m.length,")"]}),i.jsxs(Qe,{value:"tools",children:[i.jsx(Vp,{className:"w-4 h-4 mr-1"}),"Tools"]})]}),i.jsx(Xe,{value:"pending",className:"space-y-4 mt-4",children:d?i.jsx("div",{className:"text-center py-8",children:"Loading orders..."}):v.length===0?i.jsx(W,{children:i.jsxs(H,{className:"p-8 text-center",children:[i.jsx(wr,{className:"w-12 h-12 mx-auto text-gray-400 mb-4"}),i.jsx("h3",{className:"text-lg font-semibold text-gray-600 mb-2",children:"No Pending Orders"}),i.jsx("p",{className:"text-gray-500",children:"All orders have been processed."})]})}):v.map(x=>i.jsx(y,{order:x},x.id))}),i.jsx(Xe,{value:"processed",className:"space-y-4 mt-4",children:m.length===0?i.jsx(W,{children:i.jsxs(H,{className:"p-8 text-center",children:[i.jsx(Ot,{className:"w-12 h-12 mx-auto text-gray-400 mb-4"}),i.jsx("h3",{className:"text-lg font-semibold text-gray-600 mb-2",children:"No Processed Orders"}),i.jsx("p",{className:"text-gray-500",children:"No orders have been processed yet."})]})}):m.map(x=>i.jsx(y,{order:x},x.id))}),i.jsxs(Xe,{value:"tools",className:"space-y-4 mt-4",children:[i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"flex items-center gap-2",children:[i.jsx(fn,{className:"w-5 h-5"}),"Quick Actions"]})}),i.jsx(H,{className:"space-y-3",children:i.jsxs(z,{onClick:()=>c(!0),className:"w-full",children:[i.jsx(fn,{className:"w-4 h-4 mr-2"}),"Create New Order"]})})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"flex items-center gap-2",children:[i.jsx(Et,{className:"w-5 h-5"}),"Reports & Analytics"]})}),i.jsx(H,{children:i.jsx(So,{})})]}),i.jsxs(W,{children:[i.jsxs(J,{children:[i.jsxs(ee,{className:"flex items-center gap-2",children:[i.jsx(Vp,{className:"w-5 h-5"}),"Order Form Configuration"]}),i.jsx(Rt,{children:"Configure which fields are shown in the order form"})]}),i.jsx(H,{children:i.jsx(kk,{onSave:u.mutate})})]})]})]})]}),i.jsx(Mm,{isOpen:l,onClose:()=>c(!1)}),i.jsx(_k,{order:n,isOpen:s,onClose:()=>{o(!1),a(null)}})]}):i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex justify-between items-center",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-bold",children:"Order Approvals"}),i.jsx("p",{className:"text-gray-600",children:"Review and approve pending orders"})]}),i.jsxs(z,{onClick:()=>c(!0),children:[i.jsx(fn,{className:"w-4 h-4 mr-2"}),"Create Order"]})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-6",children:[i.jsxs(W,{children:[i.jsxs(J,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[i.jsx(ee,{className:"text-sm font-medium",children:"Total Orders"}),i.jsx(Ot,{className:"h-4 w-4 text-muted-foreground"})]}),i.jsx(H,{children:i.jsx("div",{className:"text-2xl font-bold",children:(h==null?void 0:h.total)||0})})]}),i.jsxs(W,{children:[i.jsxs(J,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[i.jsx(ee,{className:"text-sm font-medium",children:"Pending Review"}),i.jsx(wr,{className:"h-4 w-4 text-amber-500"})]}),i.jsx(H,{children:i.jsx("div",{className:"text-2xl font-bold text-amber-600",children:(h==null?void 0:h.pending)||0})})]}),i.jsxs(W,{children:[i.jsxs(J,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[i.jsx(ee,{className:"text-sm font-medium",children:"Approved"}),i.jsx(Mr,{className:"h-4 w-4 text-green-500"})]}),i.jsx(H,{children:i.jsx("div",{className:"text-2xl font-bold text-green-600",children:(h==null?void 0:h.approved)||0})})]}),i.jsxs(W,{children:[i.jsxs(J,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[i.jsx(ee,{className:"text-sm font-medium",children:"Rejected"}),i.jsx(Mr,{className:"h-4 w-4 text-red-500"})]}),i.jsx(H,{children:i.jsx("div",{className:"text-2xl font-bold text-red-600",children:(h==null?void 0:h.rejected)||0})})]})]}),i.jsxs(ja,{defaultValue:"pending",className:"w-full",children:[i.jsxs(Hn,{children:[i.jsxs(Qe,{value:"pending",children:[i.jsx(wr,{className:"w-4 h-4 mr-2"}),"Pending Review (",v.length,")"]}),i.jsxs(Qe,{value:"processed",children:[i.jsx(Ot,{className:"w-4 h-4 mr-2"}),"Processed Orders (",m.length,")"]}),i.jsxs(Qe,{value:"reports",children:[i.jsx(Et,{className:"w-4 h-4 mr-2"}),"Reports & Tools"]})]}),i.jsx(Xe,{value:"pending",className:"space-y-4",children:d?i.jsx("div",{className:"text-center py-8",children:"Loading orders..."}):v.length===0?i.jsx(W,{children:i.jsxs(H,{className:"p-12 text-center",children:[i.jsx(wr,{className:"w-16 h-16 mx-auto text-gray-400 mb-4"}),i.jsx("h3",{className:"text-xl font-semibold text-gray-600 mb-2",children:"No Pending Orders"}),i.jsx("p",{className:"text-gray-500",children:"All orders have been reviewed and processed."})]})}):i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:v.map(x=>i.jsx(y,{order:x},x.id))})}),i.jsx(Xe,{value:"processed",className:"space-y-4",children:m.length===0?i.jsx(W,{children:i.jsxs(H,{className:"p-12 text-center",children:[i.jsx(Ot,{className:"w-16 h-16 mx-auto text-gray-400 mb-4"}),i.jsx("h3",{className:"text-xl font-semibold text-gray-600 mb-2",children:"No Processed Orders"}),i.jsx("p",{className:"text-gray-500",children:"No orders have been processed yet."})]})}):i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:m.map(x=>i.jsx(y,{order:x},x.id))})}),i.jsx(Xe,{value:"reports",className:"space-y-6",children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[i.jsxs(W,{children:[i.jsxs(J,{children:[i.jsxs(ee,{className:"flex items-center gap-2",children:[i.jsx(Et,{className:"w-5 h-5"}),"Reports & Analytics"]}),i.jsx(Rt,{children:"Generate comprehensive reports for orders and sales data"})]}),i.jsx(H,{children:i.jsx(So,{})})]}),i.jsxs(W,{children:[i.jsxs(J,{children:[i.jsxs(ee,{className:"flex items-center gap-2",children:[i.jsx(Vp,{className:"w-5 h-5"}),"Order Form Configuration"]}),i.jsx(Rt,{children:"Configure which fields are shown in the order form"})]}),i.jsx(H,{children:i.jsx(kk,{onSave:u.mutate})})]})]})})]}),i.jsx(Mm,{isOpen:l,onClose:()=>c(!1)}),i.jsx(_k,{order:n,isOpen:s,onClose:()=>{o(!1),a(null)}})]})}function A0(){const e=hh(),{toast:t}=Ht();qn();const r=j.useRef(null),[n,a]=j.useState(null),[s,o]=j.useState(""),[l,c]=j.useState("all"),[u,f]=j.useState("all"),[d,h]=j.useState([]),[p,y]=j.useState(null),[v,m]=j.useState(!1),{data:x=[],isLoading:g}=Fe({queryKey:["/api/orders"],select:_=>!_||!Array.isArray(_)?[]:_.sort((k,R)=>new Date(R.createdAt).getTime()-new Date(k.createdAt).getTime()),retry:!1,refetchOnWindowFocus:!1});Fe({queryKey:["/api/users"],select:_=>!_||!Array.isArray(_)?[]:_.filter(k=>k.role==="sales_officer"),retry:!1,refetchOnWindowFocus:!1});const b=(x||[]).filter(_=>{if(!_)return!1;const k=s===""||(_.customerName||"").toLowerCase().includes(s.toLowerCase())||(_.orderNumber||"").toLowerCase().includes(s.toLowerCase())||(_.customerArea||"").toLowerCase().includes(s.toLowerCase())||(_.customerTinNumber||"").toLowerCase().includes(s.toLowerCase()),R=l==="all"||_.status===l,$=u==="all"||_.businessSector===u;return k&&R&&$}),N=(x||[]).filter(_=>_&&_.status==="approved"),w=_=>{switch(_){case"pending":return i.jsx(te,{variant:"secondary",className:"bg-yellow-100 text-yellow-800",children:"Pending"});case"approved":return i.jsx(te,{variant:"default",className:"bg-green-100 text-green-800",children:"Approved"});case"rejected":return i.jsx(te,{variant:"destructive",children:"Rejected"});case"processing":return i.jsx(te,{variant:"outline",className:"bg-blue-100 text-blue-800",children:"Processing"});case"completed":return i.jsx(te,{variant:"outline",className:"bg-purple-100 text-purple-800",children:"Completed"});default:return i.jsx(te,{variant:"outline",children:_})}},S=async()=>{try{const _=await fetch("/api/export/orders?status=approved",{method:"GET"});if(!_.ok)throw new Error("Export failed");const k=await _.blob(),R=window.URL.createObjectURL(k),$=document.createElement("a");$.style.display="none",$.href=R,$.download=`approved_orders_${new Date().toISOString().split("T")[0]}.xlsx`,document.body.appendChild($),$.click(),window.URL.revokeObjectURL(R),document.body.removeChild($),t({title:"Export completed",description:"Approved orders exported to Excel successfully"})}catch(_){console.error("Export error:",_),t({title:"Export failed",description:"Failed to export approved orders",variant:"destructive"})}},O=_=>{const k={customerName:_.customerName,customerTinNumber:_.customerTinNumber||"",customerMobileNumber:_.customerMobileNumber||"",customerArea:_.customerArea,businessSector:_.businessSector,paymentTerm:_.paymentTerm,items:_.items,totalAmount:_.totalAmount,fsNumber:_.fsNumber||"",notes:_.notes};y(k),m(!0)},P=_=>{const k=_.reduce((R,$)=>{const I=`${$.customerName}_${$.customerTinNumber||"notinumber"}`;return R[I]||(R[I]={customerInfo:{name:$.customerName,tinNumber:$.customerTinNumber,mobileNumber:$.customerMobileNumber,area:$.customerArea,businessSector:$.businessSector},orders:[]}),R[I].orders.push($),R},{});return Object.values(k)},A=()=>{const _=x.filter(R=>d.includes(R.id)),k=P(_);if(k.length>0){const R=k[0],$=R.orders.flatMap(F=>F.items),I=R.orders.reduce((F,V)=>F+V.totalAmount,0),E={customerName:R.customerInfo.name,customerTinNumber:R.customerInfo.tinNumber||"",customerMobileNumber:R.customerInfo.mobileNumber||"",customerArea:R.customerInfo.area,businessSector:R.customerInfo.businessSector,paymentTerm:R.orders[0].paymentTerm,items:$,totalAmount:I,fsNumber:"",notes:R.orders.map(F=>`Order ${F.orderNumber}: ${F.notes||"No notes"}`).join(` `)};y(E),m(!0)}},C=()=>{if(r.current){const _=window.open("","_blank");_&&(_.document.write(` Order Request Form ${r.current.innerHTML} `),_.document.close(),_.print())}},T=({order:_})=>i.jsxs($t,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[i.jsx(Lt,{children:i.jsxs(Ft,{className:"flex items-center gap-2",children:[i.jsx(Et,{className:"w-5 h-5"}),"Order Details - ",_.orderNumber]})}),i.jsxs("div",{className:"space-y-6",children:[i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"text-lg flex items-center gap-2",children:[i.jsx(Fn,{className:"w-4 h-4"}),"Customer Information"]})}),i.jsx(H,{children:i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx(X,{className:"text-gray-600",children:"Customer Name"}),i.jsx("p",{className:"font-medium",children:_.customerName})]}),i.jsxs("div",{children:[i.jsx(X,{className:"text-gray-600",children:"TIN Number"}),i.jsx("p",{className:"font-medium",children:_.customerTinNumber||"N/A"})]}),i.jsxs("div",{children:[i.jsx(X,{className:"text-gray-600",children:"Mobile Number"}),i.jsx("p",{className:"font-medium",children:_.customerMobileNumber||"N/A"})]}),i.jsxs("div",{children:[i.jsx(X,{className:"text-gray-600",children:"Area"}),i.jsx("p",{className:"font-medium",children:_.customerArea})]}),i.jsxs("div",{children:[i.jsx(X,{className:"text-gray-600",children:"Business Sector"}),i.jsx("p",{className:"font-medium capitalize",children:_.businessSector})]}),i.jsxs("div",{children:[i.jsx(X,{className:"text-gray-600",children:"Payment Term"}),i.jsx("p",{className:"font-medium capitalize",children:_.paymentTerm})]})]})})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"text-lg flex items-center gap-2",children:[i.jsx(Fn,{className:"w-4 h-4"}),"Sales Officer"]})}),i.jsx(H,{children:i.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx(X,{className:"text-gray-600",children:"Sales Officer"}),i.jsx("p",{className:"font-medium",children:_.salesOfficer?`${_.salesOfficer.firstName} ${_.salesOfficer.lastName}`:_.salesOfficerId})]}),i.jsxs("div",{children:[i.jsx(X,{className:"text-gray-600",children:"Status"}),i.jsx("div",{className:"mt-1",children:w(_.status)})]})]})})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"text-lg flex items-center gap-2",children:[i.jsx(Ot,{className:"w-4 h-4"}),"Order Items"]})}),i.jsx(H,{children:i.jsx("div",{className:"border rounded-lg",children:i.jsxs(Vl,{children:[i.jsx(ql,{children:i.jsxs(zr,{children:[i.jsx(Le,{children:"Product Type"}),i.jsx(Le,{children:"Unit"}),i.jsx(Le,{className:"text-right",children:"Quantity"}),i.jsx(Le,{className:"text-right",children:"Price"}),i.jsx(Le,{className:"text-right",children:"Total"})]})}),i.jsxs(Gl,{children:[_.items.map((k,R)=>i.jsxs(zr,{children:[i.jsx(ke,{className:"font-medium",children:k.productType}),i.jsx(ke,{className:"capitalize",children:k.unit}),i.jsx(ke,{className:"text-right",children:k.quantity}),i.jsx(ke,{className:"text-right",children:Be(k.price)}),i.jsx(ke,{className:"text-right font-medium",children:Be(k.total)})]},R)),i.jsxs(zr,{className:"bg-gray-50",children:[i.jsx(ke,{colSpan:4,className:"font-bold text-right",children:"Total Amount:"}),i.jsx(ke,{className:"font-bold text-right",children:Be(_.totalAmount)})]})]})]})})})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"text-lg flex items-center gap-2",children:[i.jsx(Dr,{className:"w-4 h-4"}),"Order Timeline"]})}),i.jsxs(H,{children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx(X,{className:"text-gray-600",children:"Created At"}),i.jsx("p",{className:"font-medium",children:_n(_.createdAt)})]}),i.jsxs("div",{children:[i.jsx(X,{className:"text-gray-600",children:"Last Updated"}),i.jsx("p",{className:"font-medium",children:_n(_.updatedAt)})]}),_.approvedAt&&i.jsxs("div",{children:[i.jsx(X,{className:"text-gray-600",children:"Approved At"}),i.jsx("p",{className:"font-medium",children:_n(_.approvedAt)})]}),_.fsNumber&&i.jsxs("div",{children:[i.jsx(X,{className:"text-gray-600",children:"FS Number"}),i.jsx("p",{className:"font-medium",children:_.fsNumber})]})]}),_.notes&&i.jsxs("div",{className:"mt-4",children:[i.jsx(X,{className:"text-gray-600",children:"Notes"}),i.jsx("p",{className:"mt-1 p-3 bg-gray-50 rounded border text-sm",children:_.notes})]})]})]}),i.jsx("div",{className:"flex gap-2 pt-4 border-t",children:i.jsxs(z,{onClick:()=>O(_),className:"flex-1",children:[i.jsx($u,{className:"w-4 h-4 mr-2"}),"Print Order Form"]})})]})]}),D=i.jsxs("div",{className:"space-y-6",children:[i.jsx("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-bold",children:"Sales Clerk Dashboard"}),i.jsx("p",{className:"text-gray-600 mt-1",children:"View all order transactions and export approved orders"})]})}),i.jsxs(ja,{defaultValue:"orders",className:"space-y-6",children:[i.jsxs(Hn,{className:"grid w-full grid-cols-2",children:[i.jsx(Qe,{value:"orders",children:"All Orders"}),i.jsx(Qe,{value:"export",children:"Export & Print"})]}),i.jsxs(Xe,{value:"orders",className:"space-y-6",children:[i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"text-lg flex items-center gap-2",children:[i.jsx($o,{className:"w-4 h-4"}),"Filters & Search"]})}),i.jsx(H,{children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"search",children:"Search"}),i.jsxs("div",{className:"relative",children:[i.jsx(iu,{className:"absolute left-3 top-3 h-4 w-4 text-gray-400"}),i.jsx(he,{id:"search",placeholder:"Customer, order number, area...",value:s,onChange:_=>o(_.target.value),className:"pl-10"})]})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"status",children:"Status"}),i.jsxs(_e,{value:l,onValueChange:c,children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"All statuses"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Statuses"}),i.jsx(U,{value:"pending",children:"Pending"}),i.jsx(U,{value:"approved",children:"Approved"}),i.jsx(U,{value:"rejected",children:"Rejected"}),i.jsx(U,{value:"processing",children:"Processing"}),i.jsx(U,{value:"completed",children:"Completed"})]})]})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"business",children:"Business Sector"}),i.jsxs(_e,{value:u,onValueChange:f,children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"All sectors"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Sectors"}),i.jsx(U,{value:"wholesale",children:"Wholesale"}),i.jsx(U,{value:"pharmacy",children:"Pharmacy"}),i.jsx(U,{value:"shop",children:"Shop"}),i.jsx(U,{value:"supermarket",children:"Supermarket"}),i.jsx(U,{value:"mch",children:"MCH"}),i.jsx(U,{value:"walking",children:"Walking"})]})]})]}),i.jsx("div",{className:"flex items-end",children:i.jsx(z,{variant:"outline",onClick:()=>{o(""),c("all"),f("all")},className:"w-full",children:"Clear Filters"})})]})})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"flex items-center justify-between",children:[i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(Et,{className:"w-4 h-4"}),"Orders (",b.length,")"]}),d.length>0&&i.jsxs(z,{onClick:A,size:"sm",children:[i.jsx($u,{className:"w-4 h-4 mr-2"}),"Print Selected (",d.length,")"]})]})}),i.jsx(H,{children:g?i.jsx("div",{className:"flex justify-center py-8",children:i.jsx("div",{className:"text-gray-500",children:"Loading orders..."})}):b.length===0?i.jsx("div",{className:"text-center py-8 text-gray-500",children:"No orders found matching your criteria"}):i.jsx("div",{className:"overflow-x-auto",children:i.jsxs(Vl,{children:[i.jsx(ql,{children:i.jsxs(zr,{children:[i.jsx(Le,{className:"w-12",children:i.jsx("input",{type:"checkbox",onChange:_=>{_.target.checked?h(b.map(k=>k.id)):h([])},checked:d.length===b.length})}),i.jsx(Le,{children:"Order Number"}),i.jsx(Le,{children:"Customer"}),i.jsx(Le,{children:"Area"}),i.jsx(Le,{children:"Business"}),i.jsx(Le,{children:"Items"}),i.jsx(Le,{className:"text-right",children:"Total"}),i.jsx(Le,{children:"Status"}),i.jsx(Le,{children:"Sales Officer"}),i.jsx(Le,{children:"Date"}),i.jsx(Le,{className:"text-center",children:"Actions"})]})}),i.jsx(Gl,{children:b.map(_=>i.jsxs(zr,{children:[i.jsx(ke,{children:i.jsx("input",{type:"checkbox",checked:d.includes(_.id),onChange:k=>{k.target.checked?h([...d,_.id]):h(d.filter(R=>R!==_.id))}})}),i.jsx(ke,{className:"font-medium",children:_.orderNumber}),i.jsx(ke,{children:i.jsxs("div",{children:[i.jsx("div",{className:"font-medium",children:_.customerName}),_.customerTinNumber&&i.jsxs("div",{className:"text-sm text-gray-500",children:["TIN: ",_.customerTinNumber]})]})}),i.jsx(ke,{children:_.customerArea}),i.jsx(ke,{className:"capitalize",children:_.businessSector}),i.jsxs(ke,{children:[(_.items||[]).length," items"]}),i.jsx(ke,{className:"text-right font-medium",children:Be(_.totalAmount)}),i.jsx(ke,{children:w(_.status)}),i.jsx(ke,{children:_.salesOfficer?`${_.salesOfficer.firstName} ${_.salesOfficer.lastName}`:_.salesOfficerId}),i.jsx(ke,{children:_n(_.createdAt)}),i.jsx(ke,{className:"text-center",children:i.jsxs(zt,{children:[i.jsx(Pm,{asChild:!0,children:i.jsxs(z,{variant:"outline",size:"sm",onClick:()=>a(_),children:[i.jsx(au,{className:"w-3 h-3 mr-1"}),"View"]})}),n&&i.jsx(T,{order:n})]})})]},_.id))})]})})})]})]}),i.jsxs(Xe,{value:"export",className:"space-y-6",children:[i.jsxs(W,{children:[i.jsxs(J,{children:[i.jsxs(ee,{className:"text-lg flex items-center gap-2",children:[i.jsx(Ln,{className:"w-4 h-4"}),"Export Approved Orders"]}),i.jsx(Rt,{children:"Export approved orders to Excel format for record keeping and analysis"})]}),i.jsx(H,{children:i.jsx("div",{className:"space-y-4",children:i.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"font-medium",children:"Approved Orders Excel Export"}),i.jsx("p",{className:"text-sm text-gray-600",children:"Download all approved orders with customer details and product information"}),i.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:["Total approved orders: ",N.length]})]}),i.jsxs(z,{onClick:S,children:[i.jsx(Ln,{className:"w-4 h-4 mr-2"}),"Export to Excel"]})]})})})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs(ee,{className:"text-lg flex items-center gap-2",children:[i.jsx(Et,{className:"w-4 h-4"}),"Recent Approved Orders"]})}),i.jsx(H,{children:N.length===0?i.jsx("div",{className:"text-center py-8 text-gray-500",children:"No approved orders available for export"}):i.jsx("div",{className:"overflow-x-auto",children:i.jsxs(Vl,{children:[i.jsx(ql,{children:i.jsxs(zr,{children:[i.jsx(Le,{children:"Order Number"}),i.jsx(Le,{children:"Customer"}),i.jsx(Le,{children:"Area"}),i.jsx(Le,{className:"text-right",children:"Total"}),i.jsx(Le,{children:"Approved Date"}),i.jsx(Le,{className:"text-center",children:"Actions"})]})}),i.jsx(Gl,{children:N.slice(0,10).map(_=>i.jsxs(zr,{children:[i.jsx(ke,{className:"font-medium",children:_.orderNumber}),i.jsx(ke,{children:_.customerName}),i.jsx(ke,{children:_.customerArea}),i.jsx(ke,{className:"text-right font-medium",children:Be(_.totalAmount)}),i.jsx(ke,{children:_.approvedAt?_n(_.approvedAt):"N/A"}),i.jsx(ke,{className:"text-center",children:i.jsxs(z,{variant:"outline",size:"sm",onClick:()=>O(_),children:[i.jsx($u,{className:"w-3 h-3 mr-1"}),"Print"]})})]},_.id))})]})})})]})]})]}),i.jsx(zt,{open:v,onOpenChange:m,children:i.jsxs($t,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[i.jsx(Lt,{children:i.jsxs(Ft,{className:"flex items-center gap-2",children:[i.jsx($u,{className:"w-5 h-5"}),"Order Request Form"]})}),p&&i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 p-4 border rounded-lg bg-gray-50",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"customerName",children:"Customer Name"}),i.jsx(he,{id:"customerName",value:p.customerName,onChange:_=>y({...p,customerName:_.target.value})})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"customerTinNumber",children:"TIN Number"}),i.jsx(he,{id:"customerTinNumber",value:p.customerTinNumber,onChange:_=>y({...p,customerTinNumber:_.target.value})})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"customerMobileNumber",children:"Mobile Number"}),i.jsx(he,{id:"customerMobileNumber",value:p.customerMobileNumber,onChange:_=>y({...p,customerMobileNumber:_.target.value})})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"fsNumber",children:"FS Number"}),i.jsx(he,{id:"fsNumber",value:p.fsNumber,onChange:_=>y({...p,fsNumber:_.target.value}),placeholder:"Enter FS Number manually"})]})]}),i.jsxs("div",{ref:r,className:"p-6 bg-white border",children:[i.jsxs("div",{className:"header",children:[i.jsx("h1",{style:{fontSize:"24px",fontWeight:"bold",marginBottom:"10px"},children:"ORDER REQUEST FORM"}),i.jsx("p",{style:{fontSize:"14px",color:"#666"},children:"DOK TOK Sales Order Management System"})]}),i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{style:{fontSize:"18px",fontWeight:"bold",marginBottom:"15px",borderBottom:"1px solid #000"},children:"Customer Information"}),i.jsxs("div",{className:"form-row",children:[i.jsxs("div",{className:"form-field",children:[i.jsx("span",{className:"label",children:"Customer Name:"}),i.jsx("div",{className:"value",children:p.customerName})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("span",{className:"label",children:"TIN Number:"}),i.jsx("div",{className:"value",children:p.customerTinNumber})]})]}),i.jsxs("div",{className:"form-row",children:[i.jsxs("div",{className:"form-field",children:[i.jsx("span",{className:"label",children:"Mobile Number:"}),i.jsx("div",{className:"value",children:p.customerMobileNumber})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("span",{className:"label",children:"Area:"}),i.jsx("div",{className:"value",children:p.customerArea})]})]}),i.jsxs("div",{className:"form-row",children:[i.jsxs("div",{className:"form-field",children:[i.jsx("span",{className:"label",children:"Business Sector:"}),i.jsx("div",{className:"value",style:{textTransform:"capitalize"},children:p.businessSector})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("span",{className:"label",children:"Payment Term:"}),i.jsx("div",{className:"value",style:{textTransform:"capitalize"},children:p.paymentTerm})]})]}),i.jsxs("div",{className:"form-row",children:[i.jsxs("div",{className:"form-field",children:[i.jsx("span",{className:"label",children:"FS Number:"}),i.jsx("div",{className:"value",children:p.fsNumber})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("span",{className:"label",children:"Date:"}),i.jsx("div",{className:"value",children:new Date().toLocaleDateString()})]})]})]}),i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{style:{fontSize:"18px",fontWeight:"bold",marginBottom:"15px",borderBottom:"1px solid #000"},children:"Order Details"}),i.jsxs("table",{children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Product Type"}),i.jsx("th",{children:"Unit"}),i.jsx("th",{children:"Quantity"}),i.jsx("th",{children:"Price"}),i.jsx("th",{children:"Total"})]})}),i.jsxs("tbody",{children:[(p.items||[]).map((_,k)=>i.jsxs("tr",{children:[i.jsx("td",{children:_.productType}),i.jsx("td",{style:{textTransform:"capitalize"},children:_.unit}),i.jsx("td",{children:_.quantity}),i.jsx("td",{children:Be(_.price)}),i.jsx("td",{children:Be(_.total)})]},k)),i.jsxs("tr",{style:{backgroundColor:"#f0f0f0",fontWeight:"bold"},children:[i.jsx("td",{colSpan:4,children:"Total Amount:"}),i.jsx("td",{children:Be(p.totalAmount)})]})]})]})]}),p.notes&&i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{style:{fontSize:"18px",fontWeight:"bold",marginBottom:"15px",borderBottom:"1px solid #000"},children:"Notes"}),i.jsx("div",{className:"value",style:{minHeight:"40px"},children:p.notes})]}),i.jsxs("div",{className:"signature-section",children:[i.jsxs("div",{className:"signature-box",children:[i.jsx("div",{className:"signature-line"}),i.jsx("p",{children:"Customer Signature"})]}),i.jsxs("div",{className:"signature-box",children:[i.jsx("div",{className:"signature-line"}),i.jsx("p",{children:"Sales Officer Signature"})]}),i.jsxs("div",{className:"signature-box",children:[i.jsx("div",{className:"signature-line"}),i.jsx("p",{children:"Date"})]})]})]}),i.jsxs("div",{className:"flex gap-2 pt-4 border-t",children:[i.jsxs(z,{onClick:C,className:"flex-1",children:[i.jsx($u,{className:"w-4 h-4 mr-2"}),"Print Form"]}),i.jsx(z,{variant:"outline",onClick:()=>m(!1),children:"Cancel"})]})]})]})})]});return e?i.jsx(ih,{title:"Sales Clerk",subtitle:"Order Management & Export",children:D}):i.jsx("div",{className:"flex h-screen bg-gray-50",children:i.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:i.jsx("main",{className:"flex-1 overflow-y-auto p-6",children:D})})})}const gCe=e=>{if(!e)return"N/A";try{const t=new Date(e);return isNaN(t.getTime())?"Invalid Date":Ve(t,"MMM dd, yyyy")}catch{return"Invalid Date"}};function yCe({userRole:e,userId:t}){Ht(),$r(),j.useState(null),j.useState(""),j.useState("");const[r,n]=j.useState("all"),[a,s]=j.useState("all"),[o,l]=j.useState("all"),[c,u]=j.useState("all"),[f,d]=j.useState(""),[h,p]=j.useState(""),[y,v]=j.useState("");j.useState(!1),j.useState(!1),j.useState(!1),j.useState(null);const{data:m=[],isLoading:x,refetch:g}=Fe({queryKey:["/api/payment-reports"],refetchInterval:3e4,refetchOnWindowFocus:!0,select:O=>O.map(P=>{let A=0,C="active";try{const T=P.dateOfSalesMade?new Date(P.dateOfSalesMade):P.sellingDate?new Date(P.sellingDate):new Date,D=new Date;if(A=SA(D,T),P.paymentTerm==="credit"){const _=P.creditDueDate?new Date(P.creditDueDate):Kt(T,30),k=SA(_,D);k<0?C="overdue":k<=7?C="matured":C="not_matured"}else P.paymentTerm==="cash"&&(C=A>0?"matured":"active")}catch(T){console.warn("Date parsing error for report:",P.id,T),A=0,C="active"}return{...P,daysElapsed:A,maturityStatus:C}})}),{data:b=[]}=Fe({queryKey:["/api/users","sales_officer"],queryFn:async()=>{const O=await fetch("/api/users?role=sales_officer");if(!O.ok)throw new Error("Failed to fetch sales officers");return O.json()}}),N=b.map(O=>({id:O.id,name:`${O.firstName} ${O.lastName}`.trim()||O.username||O.id})),w=m?m.filter(O=>{var k,R;const P=r==="all"||O.paymentStatus===r,A=a==="all"||O.paymentTerm===a,C=o==="all"||O.salesPersonId===o,T=c==="all"||O.businessSector===c,D=!y||O.customerName.toLowerCase().includes(y.toLowerCase())||((k=O.fsNumber)==null?void 0:k.toLowerCase().includes(y.toLowerCase()))||((R=O.salesPersonName)==null?void 0:R.toLowerCase().includes(y.toLowerCase())),_=(()=>{if(!f&&!h)return!0;const $=O.dateOfSalesMade||O.sellingDate;if(!$)return!1;const I=new Date($).getTime(),E=f?new Date(f).getTime():0,F=h?new Date(h+"T23:59:59").getTime():1/0;return I>=E&&I<=F})();return P&&A&&C&&T&&D&&_}).sort((O,P)=>{const A=O.dateOfSalesMade?new Date(O.dateOfSalesMade).getTime():0;return(P.dateOfSalesMade?new Date(P.dateOfSalesMade).getTime():0)-A}):[],S=()=>{v(""),n("all"),s("all"),l("all"),u("all"),d(""),p("")};return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-2xl font-bold",children:"Payment Collection Report"}),i.jsx("p",{className:"text-gray-600",children:"Track collected and uncollected cash & credit sales"})]}),i.jsx("div",{className:"flex gap-2",children:i.jsxs(z,{variant:"outline",children:[i.jsx(Ln,{className:"w-4 h-4 mr-2"}),"Export Report"]})})]}),i.jsxs(W,{children:[i.jsxs(J,{children:[i.jsxs(ee,{className:"flex items-center gap-2",children:[i.jsx($o,{className:"h-5 w-5"}),"Filter Options"]}),i.jsx(Rt,{children:"Use the filters below to narrow down payment reports"})]}),i.jsxs(H,{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx(X,{children:"Search"}),i.jsxs("div",{className:"relative",children:[i.jsx(iu,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),i.jsx(he,{placeholder:"Search customer, FS number...",value:y,onChange:O=>v(O.target.value),className:"pl-10"})]})]}),i.jsxs("div",{children:[i.jsx(X,{children:"Payment Status"}),i.jsxs(_e,{value:r,onValueChange:n,children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"All Status"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Status"}),i.jsx(U,{value:"uncollected",children:"Uncollected"}),i.jsx(U,{value:"collected",children:"Collected"}),i.jsx(U,{value:"overdue",children:"Overdue"})]})]})]})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx(X,{children:"Business Sector"}),i.jsxs(_e,{value:c,onValueChange:u,children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"All Sectors"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Sectors"}),i.jsx(U,{value:"wholesale",children:"Wholesale"}),i.jsx(U,{value:"pharmacy",children:"Pharmacy"}),i.jsx(U,{value:"supermarket",children:"Supermarket"}),i.jsx(U,{value:"shop",children:"Shop"}),i.jsx(U,{value:"mch",children:"MCH"}),i.jsx(U,{value:"walking",children:"Walking"})]})]})]}),i.jsxs("div",{children:[i.jsx(X,{children:"Date From"}),i.jsx(he,{type:"date",value:f,onChange:O=>d(O.target.value)})]})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx(X,{children:"Payment Term"}),i.jsxs(_e,{value:a,onValueChange:s,children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"All Terms"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Terms"}),i.jsx(U,{value:"cash",children:"Cash"}),i.jsx(U,{value:"credit",children:"Credit"})]})]})]}),i.jsxs("div",{children:[i.jsx(X,{children:"Date To"}),i.jsx(he,{type:"date",value:h,onChange:O=>p(O.target.value)})]})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx(X,{children:"Sales Officer"}),i.jsxs(_e,{value:o,onValueChange:l,children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"All Sales Officers"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Sales Officers"}),N.map(O=>i.jsx(U,{value:O.id,children:O.name},O.id))]})]})]}),i.jsxs("div",{className:"flex items-end gap-2",children:[i.jsxs(z,{onClick:()=>g(),variant:"outline",size:"sm",className:"h-10",children:[i.jsx(za,{className:"w-4 h-4 mr-2"}),"Refresh"]}),i.jsxs(z,{onClick:S,variant:"outline",size:"sm",className:"h-10",children:[i.jsx($o,{className:"w-4 h-4 mr-2"}),"Clear Filters"]})]})]})]})]}),i.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:x?i.jsxs("div",{className:"col-span-full text-center py-8",children:[i.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto"}),i.jsx("p",{className:"mt-2 text-gray-600",children:"Loading payment reports..."})]}):w.length===0?i.jsx(W,{className:"col-span-full",children:i.jsxs(H,{className:"py-8 text-center",children:[i.jsx(Et,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),i.jsx("h3",{className:"text-lg font-semibold text-gray-600",children:"No Payment Reports"}),i.jsx("p",{className:"text-gray-500 mt-2",children:"Payment reports will appear here after orders are approved"})]})}):w.map(O=>i.jsxs(W,{className:"hover:shadow-md transition-shadow",children:[i.jsx(J,{className:"pb-3",children:i.jsxs("div",{className:"flex justify-between items-start",children:[i.jsxs("div",{children:[i.jsx(ee,{className:"text-lg",children:O.customerName}),i.jsxs(Rt,{className:"flex items-center gap-2 mt-1",children:[i.jsxs("span",{children:["FS: ",O.fsNumber||"Not Set"]}),i.jsx(te,{variant:"outline",children:O.businessSector})]})]}),i.jsx("div",{className:"text-right",children:i.jsx(te,{className:O.paymentStatus==="collected"?"bg-green-100 text-green-800":O.paymentStatus==="overdue"?"bg-red-100 text-red-800":"bg-yellow-100 text-yellow-800",children:O.paymentStatus==="collected"?"Collected":O.paymentStatus==="overdue"?"Overdue":"Uncollected"})})]})}),i.jsx(H,{children:i.jsxs("div",{className:"space-y-2 text-sm",children:[i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-gray-600",children:"Amount:"}),i.jsx("span",{className:"font-bold text-lg",children:Be(parseFloat(O.amount))})]}),i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-gray-600",children:"Payment Term:"}),i.jsx("span",{className:"capitalize",children:O.paymentTerm})]}),i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-gray-600",children:"Selling Date:"}),i.jsx("span",{children:gCe(O.dateOfSalesMade||O.sellingDate)})]})]})})]},O.id))})]})}function C0(){const{user:e}=qn(),t=hh();if(!e)return null;const r=i.jsx(yCe,{userRole:(e==null?void 0:e.role)||"",userId:(e==null?void 0:e.id)||""});return t?i.jsx(ih,{title:"Payment Reports",subtitle:"Cash & Credit Collection Tracking",headerActions:i.jsxs(z,{size:"sm",variant:"outline",className:"bg-green-600 hover:bg-green-700 text-white border-green-600",children:[i.jsx(Et,{className:"w-3 h-3 mr-1"}),"Export"]}),children:r}):i.jsx("div",{className:"flex-1 space-y-4 p-8 pt-6",children:r})}function xCe(){const[e,t]=j.useState("all"),[r,n]=j.useState(""),[a,s]=j.useState(""),[o,l]=j.useState("all"),[c,u]=j.useState(!1),[f,d]=j.useState(null),[h,p]=j.useState(null),[y,v]=j.useState({bankName:"",transactionNumber:"",attachment:null}),{toast:m}=Ht(),x=$r(),{data:g=[],isLoading:b}=Fe({queryKey:["/api/my-payment-tracking",e,r,a,o],queryFn:async()=>{const k=new URLSearchParams;e&&e!=="all"&&k.append("paymentStatus",e);const R=await fetch(`/api/my-payment-tracking?${k.toString()}`);if(!R.ok)throw new Error("Failed to fetch payment tracking");return R.json()},select:k=>{let R=k;return r&&(R=R.filter($=>$.fsNumber&&$.fsNumber.toLowerCase().includes(r.toLowerCase()))),a&&(R=R.filter($=>$.customerTin&&$.customerTin.toLowerCase().includes(a.toLowerCase()))),o&&o!=="all"&&(R=R.filter($=>$.businessSector===o)),R.sort(($,I)=>new Date(I.dateOfSalesMade).getTime()-new Date($.dateOfSalesMade).getTime())}}),N=rt({mutationFn:async k=>{const R={paymentMethod:k.paymentMethod,bankName:k.bankName||null,transactionNumber:k.transactionNumber||null,attachmentPath:k.attachmentPath||null},$=await fetch(`/api/payment-reports/${k.reportId}/notify-payment`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)});if(!$.ok){const I=await $.json();throw new Error(I.message||"Failed to notify payment")}return $.json()},onSuccess:()=>{x.invalidateQueries({queryKey:["/api/my-payment-tracking"]}),m({title:"Payment Notification Sent",description:"Your payment notification has been sent for approval.",variant:"default"}),O()},onError:k=>{m({title:"Error",description:k.message,variant:"destructive"})}}),w=k=>{d(k),u(!0)},S=k=>{A.mutate(k.id)},O=()=>{u(!1),d(null),p(null),v({bankName:"",transactionNumber:"",attachment:null})},P=async()=>{if(!f||!h)return;if(h==="direct_bank_deposit"&&(!y.bankName||!y.transactionNumber)){m({title:"Missing Information",description:"Please fill in all required bank details.",variant:"destructive"});return}let k=null;if(y.attachment)try{const R=await new Promise((E,F)=>{const V=new FileReader;V.onload=()=>{const K=V.result.split(",")[1];E(K)},V.onerror=F,V.readAsDataURL(y.attachment)}),I=await(await ut("POST","/api/upload/payment-attachment",{fileData:R,fileName:y.attachment.name,fileType:y.attachment.type})).json();I.success&&(k=I.filePath)}catch(R){console.error("File upload error:",R),m({title:"File Upload Failed",description:"File may be too large (max 10MB) or invalid format. Please try with a smaller file.",variant:"destructive"});return}N.mutate({reportId:f.id,paymentMethod:h,bankName:y.bankName,transactionNumber:y.transactionNumber,attachmentPath:k})};rt({mutationFn:async k=>(await ut("POST",`/api/payment-reports/${k}/notify-paid`)).json(),onSuccess:()=>{x.invalidateQueries({queryKey:["/api/my-payment-tracking"]}),m({title:"Payment notification sent",description:"Approvers have been notified about the payment"})},onError:k=>{m({title:"Failed to notify payment",description:k.message,variant:"destructive"})}});const A=rt({mutationFn:async k=>{const R=await fetch(`/api/payment-reports/${k}/reactivate`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!R.ok){const $=await R.json();throw new Error($.message||"Failed to reactivate payment")}return R.json()},onSuccess:()=>{x.invalidateQueries({queryKey:["/api/my-payment-tracking"]}),m({title:"Payment Reactivated",description:"You can now submit a new payment notification for this order.",variant:"default"})},onError:k=>{m({title:"Failed to Reactivate Payment",description:k.message,variant:"destructive"})}}),C=k=>{switch(k){case"pending":return i.jsxs(te,{variant:"outline",className:"text-yellow-600",children:[i.jsx(eh,{className:"w-3 h-3 mr-1"}),"Uncollected"]});case"collected":return i.jsxs(te,{variant:"default",className:"bg-green-600",children:[i.jsx(ct,{className:"w-3 h-3 mr-1"}),"Collected"]});case"overdue":return i.jsxs(te,{variant:"destructive",children:[i.jsx(ar,{className:"w-3 h-3 mr-1"}),"Overdue"]});default:return i.jsx(te,{variant:"outline",children:k})}},T=k=>k==="cash"?i.jsx(te,{variant:"default",className:"bg-blue-600",children:"Cash"}):i.jsx(te,{variant:"outline",className:"text-orange-600",children:"Credit"}),D=(k,R)=>{if(!R)return null;const $=new Date,I=new Date(R),E=$.getTime()-I.getTime();return Math.floor(E/(1e3*3600*24))},_=j.useMemo(()=>{const k=g.length,R=g.filter(G=>G.paymentStatus==="collected").length,$=g.filter(G=>G.paymentStatus==="uncollected").length,I=g.filter(G=>G.paymentStatus==="overdue").length,E=g.reduce((G,K)=>G+parseFloat(K.amount),0),F=g.filter(G=>G.paymentStatus==="collected").reduce((G,K)=>G+parseFloat(K.amount),0),V=g.filter(G=>G.paymentStatus==="uncollected").reduce((G,K)=>G+parseFloat(K.amount),0);return{total:k,collected:R,pending:$,overdue:I,totalAmount:E,collectedAmount:F,pendingAmount:V,collectionRate:k>0?R/k*100:0}},[g]);return i.jsxs("div",{className:"space-y-6",children:[i.jsx("div",{className:"flex justify-between items-center",children:i.jsxs("div",{children:[i.jsx("h1",{className:"text-3xl font-bold",children:"My Payment Tracking"}),i.jsx("p",{className:"text-muted-foreground",children:"Track all your payment transactions and collection status"})]})}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[i.jsxs(W,{children:[i.jsxs(J,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[i.jsx(ee,{className:"text-sm font-medium",children:"Total Orders"}),i.jsx(Et,{className:"h-4 w-4 text-muted-foreground"})]}),i.jsxs(H,{children:[i.jsx("div",{className:"text-2xl font-bold",children:_.total}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"All payment transactions"})]})]}),i.jsxs(W,{children:[i.jsxs(J,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[i.jsx(ee,{className:"text-sm font-medium",children:"Collection Rate"}),i.jsx(Mr,{className:"h-4 w-4 text-green-600"})]}),i.jsxs(H,{children:[i.jsxs("div",{className:"text-2xl font-bold text-green-600",children:[_.collectionRate.toFixed(1),"%"]}),i.jsxs("p",{className:"text-xs text-muted-foreground",children:[_.collected," of ",_.total," collected"]})]})]}),i.jsxs(W,{children:[i.jsxs(J,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[i.jsx(ee,{className:"text-sm font-medium",children:"Collected Amount"}),i.jsx(Ka,{className:"h-4 w-4 text-green-600"})]}),i.jsxs(H,{children:[i.jsxs("div",{className:"text-2xl font-bold text-green-600",children:["ETB ",_.collectedAmount.toFixed(2)]}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"Successfully collected"})]})]}),i.jsxs(W,{children:[i.jsxs(J,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[i.jsx(ee,{className:"text-sm font-medium",children:"Uncollected Amount"}),i.jsx(Ul,{className:"h-4 w-4 text-yellow-600"})]}),i.jsxs(H,{children:[i.jsxs("div",{className:"text-2xl font-bold text-yellow-600",children:["ETB ",_.pendingAmount.toFixed(2)]}),i.jsxs("p",{className:"text-xs text-muted-foreground",children:[_.pending," uncollected + ",_.overdue," overdue"]})]})]})]}),i.jsxs(W,{children:[i.jsxs(J,{children:[i.jsx(ee,{children:"Filter Transactions"}),i.jsx(Rt,{children:"Filter your payment transactions by status, business sector, TIN number, and FS number"})]}),i.jsx(H,{children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"statusFilter",children:"Payment Status"}),i.jsxs(_e,{value:e,onValueChange:t,children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"All statuses"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All statuses"}),i.jsx(U,{value:"uncollected",children:"Uncollected"}),i.jsx(U,{value:"collected",children:"Collected"}),i.jsx(U,{value:"overdue",children:"Overdue"})]})]})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"businessSectorFilter",children:"Business Sector"}),i.jsxs(_e,{value:o,onValueChange:l,children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"All sectors"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All sectors"}),i.jsx(U,{value:"wholesale",children:"Wholesale"}),i.jsx(U,{value:"pharmacy",children:"Pharmacy"}),i.jsx(U,{value:"supermarket",children:"Supermarket"}),i.jsx(U,{value:"shop",children:"Shop"}),i.jsx(U,{value:"mch",children:"MCH"}),i.jsx(U,{value:"walking",children:"Walking"})]})]})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"tinNumberFilter",children:"TIN Number"}),i.jsx(he,{id:"tinNumberFilter",placeholder:"Enter TIN number...",value:a,onChange:k=>s(k.target.value),className:"h-9"})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"fsNumberFilter",children:"FS Number"}),i.jsx(he,{id:"fsNumberFilter",placeholder:"Enter FS number...",value:r,onChange:k=>n(k.target.value),className:"h-9"})]})]}),i.jsx("div",{className:"flex justify-end",children:i.jsxs(z,{variant:"outline",size:"sm",onClick:()=>{t("all"),l("all"),s(""),n("")},className:"text-muted-foreground",children:[i.jsx(ar,{className:"w-4 h-4 mr-2"}),"Clear All Filters"]})})]})})]}),i.jsxs(W,{children:[i.jsxs(J,{children:[i.jsxs(ee,{children:["Payment Transactions (",g.length,")"]}),i.jsx(Rt,{children:"All your payment transactions and their current status"})]}),i.jsx(H,{children:b?i.jsx("div",{className:"flex justify-center py-8",children:i.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):g.length===0?i.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[i.jsx(Et,{className:"mx-auto h-12 w-12 mb-4"}),i.jsx("p",{children:"No payment transactions found"}),i.jsx("p",{className:"text-sm",children:"Your approved orders will appear here for payment tracking"})]}):i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full border-collapse",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b",children:[i.jsx("th",{className:"text-left p-2",children:"Order #"}),i.jsx("th",{className:"text-left p-2",children:"Customer & TIN"}),i.jsx("th",{className:"text-left p-2",children:"Sales Person"}),i.jsx("th",{className:"text-left p-2",children:"FS Number"}),i.jsx("th",{className:"text-left p-2",children:"Sales Date"}),i.jsx("th",{className:"text-left p-2",children:"Amount"}),i.jsx("th",{className:"text-left p-2",children:"Sector"}),i.jsx("th",{className:"text-left p-2",children:"Payment Term"}),i.jsx("th",{className:"text-left p-2",children:"Due Date"}),i.jsx("th",{className:"text-left p-2",children:"Days Elapsed"}),i.jsx("th",{className:"text-left p-2",children:"Status"}),i.jsx("th",{className:"text-left p-2",children:"Payment Notification"}),i.jsx("th",{className:"text-left p-2",children:"Actions"})]})}),i.jsx("tbody",{children:g.map(k=>{var $;const R=k.paymentTerm==="credit"&&k.creditDueDate?D(k.dateOfSalesMade,k.creditDueDate):null;return i.jsxs("tr",{className:"border-b hover:bg-muted/50",children:[i.jsx("td",{className:"p-2 font-medium",children:k.orderNumber}),i.jsx("td",{className:"p-2",children:i.jsxs("div",{children:[i.jsx("div",{className:"font-medium",children:k.customerName}),i.jsxs("div",{className:"text-xs text-slate-500 font-mono",children:["TIN: ",k.customerTinNumber||"Not provided"]})]})}),i.jsx("td",{className:"p-2",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"w-6 h-6 bg-slate-200 rounded-full flex items-center justify-center",children:i.jsx("span",{className:"text-xs font-medium text-slate-600",children:($=k.salesOfficerId)==null?void 0:$.substring(0,2).toUpperCase()})}),i.jsx("span",{className:"text-sm",children:k.salesOfficerId})]})}),i.jsx("td",{className:"p-2",children:k.fsNumber?i.jsx(te,{variant:"outline",className:"bg-blue-50 text-blue-700 font-mono",children:k.fsNumber}):i.jsx("span",{className:"text-muted-foreground",children:"Not set"})}),i.jsx("td",{className:"p-2",children:i.jsxs("div",{className:"flex items-center",children:[i.jsx(Dr,{className:"w-4 h-4 mr-1"}),Ve(new Date(k.dateOfSalesMade),"MMM dd, yyyy")]})}),i.jsx("td",{className:"p-2",children:i.jsxs("div",{className:"flex items-center",children:[i.jsx(Ka,{className:"w-4 h-4 mr-1"}),parseFloat(k.amount).toFixed(2)]})}),i.jsx("td",{className:"p-2",children:i.jsxs("div",{className:"flex items-center",children:[i.jsx(bc,{className:"w-4 h-4 mr-1"}),k.businessSector]})}),i.jsx("td",{className:"p-2",children:T(k.paymentTerm)}),i.jsx("td",{className:"p-2",children:k.creditDueDate?Ve(new Date(k.creditDueDate),"MMM dd, yyyy"):i.jsx("span",{className:"text-muted-foreground",children:"N/A"})}),i.jsx("td",{className:"p-2",children:R!==null?i.jsxs("div",{className:"flex items-center",children:[i.jsx(wr,{className:"w-4 h-4 mr-1"}),i.jsxs("span",{className:R>0?"text-red-600 font-medium":"text-green-600",children:[R>0?`+${R}`:R," days"]})]}):i.jsx("span",{className:"text-muted-foreground",children:"N/A"})}),i.jsx("td",{className:"p-2",children:C(k.paymentStatus)}),i.jsx("td",{className:"p-2",children:k.paymentNotifiedAt?i.jsxs("div",{className:"text-sm",children:[i.jsxs(te,{variant:"outline",className:"text-blue-600",children:[i.jsx(Bl,{className:"w-3 h-3 mr-1"}),"Notified"]}),i.jsx("div",{className:"text-muted-foreground text-xs mt-1",children:Ve(new Date(k.paymentNotifiedAt),"MMM dd, h:mm a")}),k.paymentApprovalStatus==="approved"&&i.jsxs(te,{variant:"default",className:"bg-green-600 mt-1",children:[i.jsx(ct,{className:"w-3 h-3 mr-1"}),"Approved"]}),k.paymentApprovalStatus==="rejected"&&i.jsxs(te,{variant:"destructive",className:"mt-1",children:[i.jsx(ar,{className:"w-3 h-3 mr-1"}),"Rejected"]})]}):i.jsx("span",{className:"text-muted-foreground",children:"Not notified"})}),i.jsx("td",{className:"p-2",children:k.paymentStatus==="uncollected"&&!k.paymentNotifiedAt?i.jsxs(z,{size:"sm",onClick:()=>w(k),className:"bg-blue-600 hover:bg-blue-700",children:[i.jsx(Bl,{className:"w-4 h-4 mr-1"}),"Notify Payment Paid"]}):k.paymentNotifiedAt&&k.paymentApprovalStatus==="pending"?i.jsxs(te,{variant:"outline",className:"text-orange-600",children:[i.jsx(wr,{className:"w-3 h-3 mr-1"}),"Awaiting Approval"]}):k.paymentApprovalStatus==="approved"?i.jsxs(te,{variant:"default",className:"bg-green-600",children:[i.jsx(ct,{className:"w-3 h-3 mr-1"}),"Payment Approved"]}):k.paymentApprovalStatus==="rejected"?i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsxs(te,{variant:"destructive",children:[i.jsx(ar,{className:"w-3 h-3 mr-1"}),"Payment Rejected"]}),i.jsxs(z,{size:"sm",variant:"outline",onClick:()=>S(k),className:"text-blue-600 border-blue-600 hover:bg-blue-50",children:[i.jsx(za,{className:"w-3 h-3 mr-1"}),"Reactivate"]})]}):i.jsx("span",{className:"text-muted-foreground",children:"-"})})]},k.id)})})]})})})]}),i.jsx(zt,{open:c,onOpenChange:u,children:i.jsxs($t,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[i.jsxs(Lt,{children:[i.jsx(Ft,{children:"Notify Payment Paid"}),i.jsxs(Wa,{children:["Select payment method and provide required details for order ",f==null?void 0:f.orderNumber]})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-3",children:[i.jsx(X,{children:"Payment Method"}),i.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[i.jsxs(z,{variant:h==="direct_bank_deposit"?"default":"outline",onClick:()=>p("direct_bank_deposit"),className:"h-auto p-4 justify-start",children:[i.jsx(Sm,{className:"w-5 h-5 mr-3"}),i.jsxs("div",{className:"text-left",children:[i.jsx("div",{className:"font-medium",children:"Direct Bank Deposit"}),i.jsx("div",{className:"text-sm text-muted-foreground",children:"Requires bank details and slip attachment"})]})]}),i.jsxs(z,{variant:h==="check_received"?"default":"outline",onClick:()=>p("check_received"),className:"h-auto p-4 justify-start",children:[i.jsx(LW,{className:"w-5 h-5 mr-3"}),i.jsxs("div",{className:"text-left",children:[i.jsx("div",{className:"font-medium",children:"Check Received"}),i.jsx("div",{className:"text-sm text-muted-foreground",children:"Simple approval workflow"})]})]})]})]}),h==="direct_bank_deposit"&&i.jsxs("div",{className:"space-y-4 border-t pt-4",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"bankName",children:"Bank Name *"}),i.jsx(he,{id:"bankName",value:y.bankName,onChange:k=>v(R=>({...R,bankName:k.target.value})),placeholder:"Enter bank name",required:!0})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"transactionNumber",children:"Transaction Number *"}),i.jsx(he,{id:"transactionNumber",value:y.transactionNumber,onChange:k=>v(R=>({...R,transactionNumber:k.target.value})),placeholder:"Enter transaction/reference number",required:!0})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"attachment",children:"Bank Slip Attachment"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(he,{id:"attachment",type:"file",accept:"image/*,.pdf",onChange:k=>v(R=>{var $;return{...R,attachment:(($=k.target.files)==null?void 0:$[0])||null}}),className:"flex-1"}),i.jsx(Wb,{className:"w-4 h-4 text-muted-foreground"})]}),i.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Upload bank slip or deposit receipt (optional)"})]})]})]}),i.jsxs(Oi,{className:"flex gap-2 pt-4",children:[i.jsx(z,{variant:"outline",onClick:O,children:"Cancel"}),i.jsx(z,{onClick:P,disabled:!h||N.isPending,className:"bg-blue-600 hover:bg-blue-700 text-white",children:N.isPending?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"}),"Sending..."]}):i.jsxs(i.Fragment,{children:[i.jsx(Bl,{className:"w-4 h-4 mr-2"}),"Submit Payment Notification"]})})]})]})})]})}function Dk(){const{user:e}=qn(),t=hh();if(!e)return null;if((e==null?void 0:e.role)!=="sales_officer")return i.jsxs("div",{className:"flex flex-col items-center justify-center min-h-screen",children:[i.jsx("h2",{className:"text-xl font-bold mb-2",children:"Access Restricted"}),i.jsx("p",{className:"text-muted-foreground",children:"This page is only available for sales officers."})]});const r=i.jsx(xCe,{});return t?i.jsx(ih,{title:"My Payment Tracking",subtitle:"Track Your Sales Payment Status",headerActions:i.jsxs(z,{size:"sm",variant:"outline",className:"bg-blue-600 hover:bg-blue-700 text-white border-blue-600",children:[i.jsx(Mr,{className:"w-3 h-3 mr-1"}),"Stats"]}),children:r}):i.jsx("div",{className:"flex-1 space-y-4 p-8 pt-6",children:r})}function bCe({open:e,onOpenChange:t,paymentReport:r}){var v;const[n,a]=j.useState({notes:"",bankTransactionNumber:"",bankAdviceAttachment:"",verifiedFsNumber:"",verifiedAmount:""}),[s,o]=j.useState(!1),{toast:l}=Ht(),c=$r(),u=rt({mutationFn:async m=>{if(!r)throw new Error("No payment report selected");return(await ut("POST",`/api/payment-reports/${r.id}/approve-payment`,m)).json()},onSuccess:()=>{c.invalidateQueries({queryKey:["/api/payment-reports"]}),l({title:"Payment approved successfully"}),t(!1),d()},onError:m=>{l({title:"Failed to approve payment",description:m.message,variant:"destructive"})}}),f=rt({mutationFn:async m=>{if(!r)throw new Error("No payment report selected");return(await ut("POST",`/api/payment-reports/${r.id}/reject-payment`,{notes:m})).json()},onSuccess:()=>{c.invalidateQueries({queryKey:["/api/payment-reports"]}),l({title:"Payment rejected"}),t(!1),d()},onError:m=>{l({title:"Failed to reject payment",description:m.message,variant:"destructive"})}}),d=()=>{a({notes:"",bankTransactionNumber:"",bankAdviceAttachment:"",verifiedFsNumber:"",verifiedAmount:""})},h=async m=>{var g;const x=(g=m.target.files)==null?void 0:g[0];if(x){o(!0);try{const b=await new Promise((S,O)=>{const P=new FileReader;P.onload=()=>{const C=P.result.split(",")[1];S(C)},P.onerror=O,P.readAsDataURL(x)}),w=await(await ut("POST","/api/upload/payment-attachment",{fileData:b,fileName:x.name,fileType:x.type})).json();if(w.success)a(S=>({...S,bankAdviceAttachment:w.filePath})),l({title:"File uploaded successfully"});else throw new Error(w.message||"Upload failed")}catch(b){console.error("File upload error:",b),l({title:"File upload failed",description:"File may be too large (max 10MB) or invalid format. Please try with a smaller file.",variant:"destructive"})}finally{o(!1)}}},p=()=>{u.mutate(n)},y=()=>{if(!n.notes.trim()){l({title:"Rejection reason is required",variant:"destructive"});return}f.mutate(n.notes)};return r?i.jsx(zt,{open:e,onOpenChange:t,children:i.jsxs($t,{className:"max-w-4xl max-h-[95vh] overflow-y-auto w-[95vw] sm:w-full",children:[i.jsxs(Lt,{children:[i.jsxs(Ft,{className:"flex items-center gap-2 text-lg sm:text-xl",children:[i.jsx(Sm,{className:"h-4 w-4 sm:h-5 sm:w-5"}),"Payment Approval - ",r.orderNumber]}),i.jsx(Wa,{className:"text-sm",children:"Review and verify payment details before approving or rejecting this payment notification."})]}),i.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 sm:gap-6",children:[i.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[i.jsx("h3",{className:"font-semibold text-base sm:text-lg border-b pb-2",children:"Order Information"}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Et,{className:"h-4 w-4 text-muted-foreground"}),i.jsx("span",{className:"font-medium",children:"Order Number:"}),i.jsx(te,{variant:"outline",children:r.orderNumber})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Fn,{className:"h-4 w-4 text-muted-foreground"}),i.jsx("span",{className:"font-medium",children:"Customer:"}),i.jsx("span",{children:r.customerName})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(bc,{className:"h-4 w-4 text-muted-foreground"}),i.jsx("span",{className:"font-medium",children:"Business Sector:"}),i.jsx("span",{children:r.businessSector})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Ka,{className:"h-4 w-4 text-muted-foreground"}),i.jsx("span",{className:"font-medium",children:"Original Amount:"}),i.jsxs("span",{className:"font-semibold",children:["ETB ",parseFloat(String(r.amount||r.totalAmount||0)).toFixed(2)]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-medium",children:"Current FS Number:"}),r.fsNumber?i.jsx(te,{variant:"outline",children:r.fsNumber}):i.jsx("span",{className:"text-muted-foreground",children:"Not set"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-medium",children:"Sales Person:"}),i.jsx("span",{children:r.salesPersonName})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-medium",children:"Sales Date:"}),i.jsx("span",{children:Ve(new Date(r.dateOfSalesMade),"MMM dd, yyyy")})]}),r.paymentNotifiedAt&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-medium",children:"Payment Notified:"}),i.jsx("span",{children:Ve(new Date(r.paymentNotifiedAt),"MMM dd, yyyy h:mm a")})]})]})]}),r.paymentNotifiedAt&&i.jsxs("div",{className:"space-y-3 sm:space-y-4 bg-blue-50 dark:bg-blue-900/20 p-3 sm:p-4 rounded-lg border border-blue-200 dark:border-blue-800",children:[i.jsx("h3",{className:"font-semibold text-base sm:text-lg border-b pb-2 text-blue-800 dark:text-blue-200",children:"Payment Details (Entered by Sales Officer)"}),i.jsxs("div",{className:"space-y-2 sm:space-y-3",children:[i.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-1 sm:gap-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Sm,{className:"h-3 w-3 sm:h-4 sm:w-4 text-blue-600 dark:text-blue-400"}),i.jsx("span",{className:"font-medium text-sm sm:text-base",children:"Payment Method:"})]}),i.jsx(te,{variant:"secondary",className:"capitalize text-xs w-fit",children:((v=r.paymentMethod)==null?void 0:v.replace("_"," "))||"Not specified"})]}),r.paymentMethod==="direct_bank_deposit"&&i.jsxs(i.Fragment,{children:[r.bankName&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(bc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"}),i.jsx("span",{className:"font-medium",children:"Bank Name:"}),i.jsx("span",{className:"font-semibold",children:r.bankName})]}),r.bankTransactionNumber&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Et,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"}),i.jsx("span",{className:"font-medium",children:"Transaction Number:"}),i.jsx(te,{variant:"outline",children:r.bankTransactionNumber})]}),r.bankAdviceAttachment&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Wb,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"}),i.jsx("span",{className:"font-medium",children:"Bank Slip:"}),i.jsx("a",{href:`/api/download/${r.bankAdviceAttachment}`,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 dark:text-blue-400 hover:underline",children:"View Attachment"})]})]}),r.paymentMethod==="check_received"&&i.jsx("div",{className:"text-sm text-muted-foreground",children:"Sales officer confirmed that payment was received via check."})]})]}),i.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[i.jsx("h3",{className:"font-semibold text-base sm:text-lg border-b pb-2",children:"Approver Verification (Optional)"}),i.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"You can approve this payment with or without filling additional verification details below."}),i.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"bankTransactionNumber",className:"text-sm",children:"Additional Bank Transaction Number"}),i.jsx(he,{id:"bankTransactionNumber",value:n.bankTransactionNumber,onChange:m=>a(x=>({...x,bankTransactionNumber:m.target.value})),placeholder:"Enter additional transaction reference (optional)",className:"mt-1 text-sm"})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"verifiedFsNumber",className:"text-sm",children:"Verified FS Number"}),i.jsx(he,{id:"verifiedFsNumber",value:n.verifiedFsNumber,onChange:m=>a(x=>({...x,verifiedFsNumber:m.target.value})),placeholder:"Enter or verify FS number",className:"mt-1 text-sm"})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"verifiedAmount",className:"text-sm",children:"Verified Amount (ETB)"}),i.jsx(he,{id:"verifiedAmount",type:"number",step:"0.01",value:n.verifiedAmount,onChange:m=>a(x=>({...x,verifiedAmount:m.target.value})),placeholder:"Enter verified payment amount (optional)",className:"mt-1 text-sm"})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"bankAdvice",className:"text-sm",children:"Additional Bank Advice Attachment"}),i.jsxs("div",{className:"mt-1 space-y-2",children:[i.jsx(he,{id:"bankAdvice",type:"file",accept:".pdf,.jpg,.jpeg,.png,.doc,.docx",onChange:h,disabled:s,className:"text-sm"}),n.bankAdviceAttachment&&i.jsxs("div",{className:"flex items-center gap-2 text-xs sm:text-sm text-green-600",children:[i.jsx(Wb,{className:"h-3 w-3 sm:h-4 sm:w-4"}),"File uploaded: ",n.bankAdviceAttachment]})]})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"notes",className:"text-sm",children:"Approval Notes"}),i.jsx(Wn,{id:"notes",value:n.notes,onChange:m=>a(x=>({...x,notes:m.target.value})),placeholder:"Enter any notes or comments about this payment approval...",className:"mt-1 text-sm resize-none",rows:3})]})]})]})]}),i.jsxs(Oi,{className:"gap-2",children:[i.jsx(z,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),i.jsxs(z,{variant:"destructive",onClick:y,disabled:f.isPending||!n.notes.trim(),children:[i.jsx(ar,{className:"h-4 w-4 mr-2"}),"Reject Payment"]}),i.jsxs(z,{onClick:p,disabled:u.isPending,className:"bg-green-600 hover:bg-green-700",children:[i.jsx(ct,{className:"h-4 w-4 mr-2"}),"Approve Payment"]})]})]})}):null}function jCe(){const[e,t]=j.useState({approvalStatus:"all",paymentStatus:"all",businessSector:"all",paymentTerm:"all",salesOfficer:"all",searchTerm:"",fsNumber:"",tinNumber:"",dateFrom:"",dateTo:""}),[r,n]=j.useState(null),[a,s]=j.useState(!1),{data:o=[],isLoading:l,refetch:c}=Fe({queryKey:["/api/payment-reports"],refetchInterval:3e4,refetchOnWindowFocus:!0}),{data:u=[]}=Fe({queryKey:["/api/users"],staleTime:5*60*1e3}),f=o.filter(g=>{const b=e.approvalStatus==="all"||g.paymentApprovalStatus===e.approvalStatus,N=e.paymentStatus==="all"||g.paymentStatus===e.paymentStatus,w=e.businessSector==="all"||g.businessSector===e.businessSector,S=e.paymentTerm==="all"||g.paymentTerm===e.paymentTerm,O=e.salesOfficer==="all"||g.salesPersonId===e.salesOfficer,P=!e.searchTerm||g.customerName.toLowerCase().includes(e.searchTerm.toLowerCase())||g.orderNumber.toLowerCase().includes(e.searchTerm.toLowerCase())||g.salesPersonName&&g.salesPersonName.toLowerCase().includes(e.searchTerm.toLowerCase()),A=!e.fsNumber||g.fsNumber&&g.fsNumber.toLowerCase().includes(e.fsNumber.toLowerCase()),C=!e.tinNumber||g.customerTin&&g.customerTin.toLowerCase().includes(e.tinNumber.toLowerCase()),T=(()=>{if(!e.dateFrom&&!e.dateTo)return!0;const D=new Date(g.dateOfSalesMade),_=e.dateFrom?new Date(e.dateFrom):null,k=e.dateTo?new Date(e.dateTo+"T23:59:59"):null;return!(_&&D<_||k&&D>k)})();return b&&N&&w&&S&&O&&P&&A&&C&&T}),d=g=>{const b=u.find(N=>N.id===g);return b?`${b.firstName} ${b.lastName}`:"Unknown"},h=g=>{switch(g){case"pending":return i.jsxs(te,{variant:"outline",className:"text-orange-600 border-orange-600",children:[i.jsx(wr,{className:"w-3 h-3 mr-1"}),"Pending Review"]});case"approved":return i.jsxs(te,{variant:"default",className:"bg-green-600",children:[i.jsx(ct,{className:"w-3 h-3 mr-1"}),"Approved"]});case"rejected":return i.jsxs(te,{variant:"destructive",children:[i.jsx(ar,{className:"w-3 h-3 mr-1"}),"Rejected"]});default:return i.jsx(te,{variant:"secondary",children:"Unknown"})}},p=g=>{n(g),s(!0)},y=()=>{t({approvalStatus:"all",paymentStatus:"all",businessSector:"all",paymentTerm:"all",salesOfficer:"all",searchTerm:"",fsNumber:"",tinNumber:"",dateFrom:"",dateTo:""})},v=f.filter(g=>g.paymentApprovalStatus==="pending").length,m=f.filter(g=>g.paymentApprovalStatus==="approved").length,x=f.filter(g=>g.paymentApprovalStatus==="rejected").length;return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-4",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-2xl lg:text-3xl font-bold tracking-tight",children:"Payment Approvals"}),i.jsx("p",{className:"text-muted-foreground mt-1",children:"Review and approve payment notifications from sales officers"})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[v>0&&i.jsxs(te,{variant:"outline",className:"text-orange-600 border-orange-600 whitespace-nowrap",children:[i.jsx(eh,{className:"w-4 h-4 mr-1"}),v," Pending Review"]}),i.jsxs(z,{variant:"outline",onClick:()=>c(),size:"sm",children:[i.jsx(za,{className:"w-4 h-4 mr-2"}),"Refresh"]})]})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 lg:gap-6",children:[i.jsx(W,{children:i.jsx(H,{className:"pt-6",children:i.jsxs("div",{className:"flex items-center",children:[i.jsx(wr,{className:"h-8 w-8 text-orange-600"}),i.jsxs("div",{className:"ml-4",children:[i.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Awaiting Review"}),i.jsx("p",{className:"text-2xl font-bold",children:v})]})]})})}),i.jsx(W,{children:i.jsx(H,{className:"pt-6",children:i.jsxs("div",{className:"flex items-center",children:[i.jsx(ct,{className:"h-8 w-8 text-green-600"}),i.jsxs("div",{className:"ml-4",children:[i.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Approved"}),i.jsx("p",{className:"text-2xl font-bold",children:m})]})]})})}),i.jsx(W,{children:i.jsx(H,{className:"pt-6",children:i.jsxs("div",{className:"flex items-center",children:[i.jsx(ar,{className:"h-8 w-8 text-red-600"}),i.jsxs("div",{className:"ml-4",children:[i.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Rejected"}),i.jsx("p",{className:"text-2xl font-bold",children:x})]})]})})})]}),i.jsxs(W,{children:[i.jsxs(J,{children:[i.jsxs(ee,{className:"flex items-center gap-2",children:[i.jsx($o,{className:"h-5 w-5"}),"Payment Report Filters"]}),i.jsx(Rt,{children:"Use the filters below to narrow down payment reports"})]}),i.jsxs(H,{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"searchTerm",children:"Search"}),i.jsxs("div",{className:"relative",children:[i.jsx(iu,{className:"absolute left-2 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),i.jsx(he,{id:"searchTerm",placeholder:"Customer, order, sales person...",value:e.searchTerm,onChange:g=>t(b=>({...b,searchTerm:g.target.value})),className:"pl-8"})]})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"fsNumber",children:"FS Number"}),i.jsx(he,{id:"fsNumber",placeholder:"Search by FS number...",value:e.fsNumber,onChange:g=>t(b=>({...b,fsNumber:g.target.value}))})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"tinNumber",children:"TIN Number"}),i.jsx(he,{id:"tinNumber",placeholder:"Search by TIN number...",value:e.tinNumber,onChange:g=>t(b=>({...b,tinNumber:g.target.value}))})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"approvalStatus",children:"Approval Status"}),i.jsxs(_e,{value:e.approvalStatus,onValueChange:g=>t(b=>({...b,approvalStatus:g})),children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"All approval statuses"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Approval Status"}),i.jsx(U,{value:"pending",children:"Pending Review"}),i.jsx(U,{value:"approved",children:"Approved"}),i.jsx(U,{value:"rejected",children:"Rejected"})]})]})]})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"paymentStatus",children:"Payment Status"}),i.jsxs(_e,{value:e.paymentStatus,onValueChange:g=>t(b=>({...b,paymentStatus:g})),children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"All statuses"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Statuses"}),i.jsx(U,{value:"uncollected",children:"Uncollected"}),i.jsx(U,{value:"collected",children:"Collected"}),i.jsx(U,{value:"overdue",children:"Overdue"})]})]})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"businessSector",children:"Business Sector"}),i.jsxs(_e,{value:e.businessSector,onValueChange:g=>t(b=>({...b,businessSector:g})),children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"All sectors"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Sectors"}),i.jsx(U,{value:"wholesale",children:"Wholesale"}),i.jsx(U,{value:"pharmacy",children:"Pharmacy"}),i.jsx(U,{value:"supermarket",children:"Supermarket"}),i.jsx(U,{value:"shop",children:"Shop"}),i.jsx(U,{value:"mch",children:"MCH"}),i.jsx(U,{value:"walking",children:"Walking"})]})]})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"dateFrom",children:"Date From"}),i.jsx(he,{id:"dateFrom",type:"date",value:e.dateFrom,onChange:g=>t(b=>({...b,dateFrom:g.target.value}))})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"dateTo",children:"Date To"}),i.jsx(he,{id:"dateTo",type:"date",value:e.dateTo,onChange:g=>t(b=>({...b,dateTo:g.target.value}))})]})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"paymentTerm",children:"Payment Term"}),i.jsxs(_e,{value:e.paymentTerm,onValueChange:g=>t(b=>({...b,paymentTerm:g})),children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"All terms"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Payment Terms"}),i.jsx(U,{value:"cash",children:"Cash"}),i.jsx(U,{value:"credit",children:"Credit"})]})]})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"salesOfficer",children:"Sales Officer"}),i.jsxs(_e,{value:e.salesOfficer,onValueChange:g=>t(b=>({...b,salesOfficer:g})),children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"All officers"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Sales Officers"}),u.filter(g=>g.role==="sales_officer"||g.roles&&g.roles.includes("sales_officer")).map(g=>i.jsxs(U,{value:g.id,children:[g.firstName," ",g.lastName]},g.id))]})]})]}),i.jsx("div",{className:"flex items-end",children:i.jsxs(z,{variant:"outline",size:"sm",onClick:y,className:"h-10 text-muted-foreground",children:[i.jsx(ar,{className:"w-4 h-4 mr-2"}),"Clear All Filters"]})})]})]})]}),i.jsxs(W,{children:[i.jsxs(J,{children:[i.jsxs(ee,{children:["Payment Notifications (",f.length,")"]}),i.jsx(Rt,{children:"Review payment notifications that require approval"})]}),i.jsx(H,{children:l?i.jsx("div",{className:"flex justify-center py-8",children:i.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):f.length===0?i.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[i.jsx(Sm,{className:"mx-auto h-12 w-12 mb-4"}),i.jsx("p",{children:"No payment notifications found"})]}):i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full border-collapse",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b",children:[i.jsx("th",{className:"text-left p-3 font-semibold",children:"Order #"}),i.jsx("th",{className:"text-left p-3 font-semibold",children:"Customer"}),i.jsx("th",{className:"text-left p-3 font-semibold",children:"Amount"}),i.jsx("th",{className:"text-left p-3 font-semibold",children:"FS Number"}),i.jsx("th",{className:"text-left p-3 font-semibold",children:"Sales Person"}),i.jsx("th",{className:"text-left p-3 font-semibold",children:"Notification Date"}),i.jsx("th",{className:"text-left p-3 font-semibold",children:"Status"}),i.jsx("th",{className:"text-left p-3 font-semibold",children:"Bank Details"}),i.jsx("th",{className:"text-left p-3 font-semibold",children:"Actions"})]})}),i.jsx("tbody",{children:f.map(g=>i.jsxs("tr",{className:"border-b hover:bg-muted/50",children:[i.jsx("td",{className:"p-3",children:i.jsx(te,{variant:"outline",children:g.orderNumber})}),i.jsx("td",{className:"p-3",children:i.jsxs("div",{children:[i.jsx("div",{className:"font-medium",children:g.customerName}),g.customerTin&&i.jsxs("div",{className:"text-sm text-muted-foreground",children:["TIN: ",g.customerTin]})]})}),i.jsx("td",{className:"p-3",children:i.jsxs("div",{className:"flex flex-col",children:[i.jsxs("span",{className:"font-semibold",children:["ETB ",parseFloat(String(g.amount||g.totalAmount||"0")).toFixed(2)]}),g.verifiedAmount&&i.jsxs("span",{className:"text-sm text-green-600",children:["Verified: ETB ",parseFloat(g.verifiedAmount).toFixed(2)]})]})}),i.jsx("td",{className:"p-3",children:g.fsNumber?i.jsx(te,{variant:"outline",children:g.fsNumber}):i.jsx("span",{className:"text-muted-foreground",children:"Not set"})}),i.jsx("td",{className:"p-3",children:d(g.salesPersonId)}),i.jsx("td",{className:"p-3",children:g.paymentNotifiedAt?i.jsxs("div",{className:"text-sm",children:[i.jsx("div",{children:Ve(new Date(g.paymentNotifiedAt),"MMM dd, yyyy")}),i.jsx("div",{className:"text-muted-foreground",children:Ve(new Date(g.paymentNotifiedAt),"h:mm a")})]}):i.jsx("span",{className:"text-muted-foreground",children:"Not notified"})}),i.jsx("td",{className:"p-3",children:h(g.paymentApprovalStatus||"pending")}),i.jsx("td",{className:"p-3",children:g.bankTransactionNumber?i.jsx("div",{className:"text-sm",children:i.jsxs("div",{className:"font-medium",children:["TX: ",g.bankTransactionNumber]})}):i.jsx("span",{className:"text-muted-foreground",children:"Not provided"})}),i.jsx("td",{className:"p-3",children:g.paymentApprovalStatus==="pending"&&g.paymentNotifiedAt?i.jsxs(z,{size:"sm",onClick:()=>p(g),className:"bg-blue-600 hover:bg-blue-700",children:[i.jsx(Bl,{className:"w-4 h-4 mr-1"}),"Review Payment"]}):g.paymentApprovalStatus==="approved"?i.jsxs("div",{className:"text-sm text-green-600",children:[i.jsx("div",{children:"Approved"}),g.paymentApprovedAt&&i.jsx("div",{className:"text-xs text-muted-foreground",children:Ve(new Date(g.paymentApprovedAt),"MMM dd, h:mm a")})]}):g.paymentApprovalStatus==="rejected"?i.jsxs("div",{className:"text-sm text-red-600",children:[i.jsx("div",{children:"Rejected"}),g.paymentApprovedAt&&i.jsx("div",{className:"text-xs text-muted-foreground",children:Ve(new Date(g.paymentApprovedAt),"MMM dd, h:mm a")})]}):i.jsx("span",{className:"text-muted-foreground",children:"No action needed"})})]},g.id))})]})})})]}),i.jsx(bCe,{open:a,onOpenChange:s,paymentReport:r})]})}function Mk(){const{user:e}=Za();return!e||!["super_admin","approver","sales_clerk"].includes(e==null?void 0:e.role)?i.jsx("div",{className:"min-h-screen bg-slate-50 flex items-center justify-center",children:i.jsxs("div",{className:"text-center",children:[i.jsx("h2",{className:"text-xl font-semibold text-slate-800 mb-2",children:"Access Denied"}),i.jsx("p",{className:"text-slate-600",children:"You don't have permission to access payment approvals."})]})}):i.jsxs("div",{className:"min-h-screen bg-slate-50",children:[i.jsx(ca,{}),i.jsxs("div",{className:"md:ml-64",children:[i.jsx(Ts,{}),i.jsxs("main",{className:"p-3 sm:p-6 pt-16 md:pt-6",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx("h1",{className:"text-2xl font-bold text-slate-800",children:"Payment Approvals"}),i.jsx("p",{className:"text-slate-600 mt-1",children:"Review and approve payment notifications from sales team"})]}),i.jsx(jCe,{})]})]})]})}const Ik=[{type:"increase",label:"Quick Add +50",icon:i.jsx(fn,{className:"w-4 h-4"}),color:"bg-green-100 text-green-800 border-green-200",description:"Add 50 units to current stock"},{type:"decrease",label:"Quick Remove -20",icon:i.jsx(HW,{className:"w-4 h-4"}),color:"bg-yellow-100 text-yellow-800 border-yellow-200",description:"Remove 20 units from current stock"},{type:"restock",label:"Full Restock",icon:i.jsx(Ot,{className:"w-4 h-4"}),color:"bg-blue-100 text-blue-800 border-blue-200",description:"Set to maximum stock level"},{type:"emergency_zero",label:"Emergency Zero",icon:i.jsx(No,{className:"w-4 h-4"}),color:"bg-red-100 text-red-800 border-red-200",description:"Set stock to zero (emergency use)"}];function wCe(){const{toast:e}=Ht(),[t,r]=j.useState([]),[n,a]=j.useState(!1),[s,o]=j.useState({amount:0,reason:"",operation:"add"}),[l,c]=j.useState({businessSector:"all",productType:"all",status:"all"}),{data:u=[]}=Fe({queryKey:["/api/products",l],queryFn:async()=>{const m=new URLSearchParams;return l.businessSector&&l.businessSector!=="all"&&m.append("businessSector",l.businessSector),l.productType&&l.productType!=="all"&&m.append("productType",l.productType),l.status&&l.status!=="all"&&m.append("status",l.status),(await fetch(`/api/products?${m.toString()}`)).json()}}),f=rt({mutationFn:async({productIds:m,adjustmentType:x,customAmount:g})=>{const b=await fetch("/api/products/bulk-adjust",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({productIds:m,adjustmentType:x,customAmount:g,reason:s.reason})});if(!b.ok)throw new Error("Failed to perform bulk adjustment");return b.json()},onSuccess:m=>{sa.invalidateQueries({queryKey:["/api/products"]}),sa.invalidateQueries({queryKey:["/api/stock/summary"]}),r([]),a(!1),o({amount:0,reason:"",operation:"add"});const x=m.results.filter(b=>b.success).length,g=m.results.filter(b=>!b.success).length;g>0?e({title:"Partial Success",description:`${x} products adjusted successfully, ${g} failed`,variant:"destructive"}):e({title:"Success",description:`Successfully adjusted stock for ${x} product${x>1?"s":""}`})},onError:m=>{e({title:"Error",description:m.message,variant:"destructive"})}}),d=m=>{r(x=>x.includes(m)?x.filter(g=>g!==m):[...x,m])},h=()=>{t.length===u.length?r([]):r(u.map(m=>m.id))},p=m=>{if(t.length===0){e({title:"No Products Selected",description:"Please select at least one product to adjust",variant:"destructive"});return}Ik.find(g=>g.type===m)&&(m==="emergency_zero"&&!confirm(`Are you sure you want to set stock to ZERO for ${t.length} product(s)? This action should only be used in emergencies.`)||f.mutate({productIds:t,adjustmentType:m}))},y=()=>{if(t.length===0){e({title:"No Products Selected",description:"Please select at least one product to adjust",variant:"destructive"});return}if(!s.reason.trim()){e({title:"Reason Required",description:"Please provide a reason for the stock adjustment",variant:"destructive"});return}let m;s.operation,m=s.amount,f.mutate({productIds:t,adjustmentType:"custom",customAmount:m})},v=(m,x)=>{switch(m){case"in_stock":return i.jsxs(te,{className:"bg-green-100 text-green-800",children:[i.jsx(ct,{className:"w-3 h-3 mr-1"}),"In Stock"]});case"low_stock":return i.jsxs(te,{className:"bg-yellow-100 text-yellow-800",children:[i.jsx(No,{className:"w-3 h-3 mr-1"}),"Low Stock"]});case"out_of_stock":return i.jsxs(te,{className:"bg-red-100 text-red-800",children:[i.jsx(Ot,{className:"w-3 h-3 mr-1"}),"Out of Stock"]});default:return i.jsx(te,{variant:"secondary",children:"Unknown"})}};return i.jsxs("div",{className:"space-y-6",children:[i.jsx(W,{className:"bg-gradient-to-r from-blue-50 to-indigo-50 border-blue-200",children:i.jsx(J,{children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(pI,{className:"w-6 h-6 text-blue-600"}),i.jsxs("div",{children:[i.jsx(ee,{className:"text-blue-900",children:"One-Click Product Adjustment"}),i.jsx(Rt,{className:"text-blue-700",children:"Super Admin Module - Quickly adjust stock levels across multiple products"})]})]})})}),i.jsxs(W,{children:[i.jsxs(J,{children:[i.jsx(ee,{children:"Quick Adjustments"}),i.jsx(Rt,{children:t.length>0?`${t.length} product${t.length>1?"s":""} selected`:"Select products below to enable quick adjustments"})]}),i.jsxs(H,{children:[i.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:Ik.map(m=>i.jsxs(z,{variant:"outline",className:`h-20 flex flex-col items-center gap-2 transition-all ${m.color} ${t.length===0?"opacity-50 cursor-not-allowed":"hover:scale-105"}`,onClick:()=>p(m.type),disabled:t.length===0||f.isPending,title:m.description,children:[m.icon,i.jsx("span",{className:"text-xs font-medium text-center",children:m.label})]},m.type))}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs(z,{variant:"outline",onClick:()=>a(!0),disabled:t.length===0,className:"flex items-center gap-2",children:[i.jsx(Mr,{className:"w-4 h-4"}),"Custom Adjustment"]}),i.jsxs(z,{variant:"outline",onClick:h,className:"flex items-center gap-2",children:[i.jsx(Ot,{className:"w-4 h-4"}),t.length===u.length?"Deselect All":"Select All"]})]})]})]}),i.jsx(W,{children:i.jsx(H,{className:"pt-6",children:i.jsxs("div",{className:"flex gap-4 mb-4",children:[i.jsxs(_e,{value:l.businessSector,onValueChange:m=>c(x=>({...x,businessSector:m})),children:[i.jsx(Ae,{className:"w-48",children:i.jsx(De,{placeholder:"Business Sector"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Sectors"}),i.jsx(U,{value:"food",children:"Food"}),i.jsx(U,{value:"beverage",children:"Beverage"}),i.jsx(U,{value:"retail",children:"Retail"}),i.jsx(U,{value:"restaurant",children:"Restaurant"}),i.jsx(U,{value:"hotel",children:"Hotel"}),i.jsx(U,{value:"wholesale",children:"Wholesale"})]})]}),i.jsxs(_e,{value:l.productType,onValueChange:m=>c(x=>({...x,productType:m})),children:[i.jsx(Ae,{className:"w-48",children:i.jsx(De,{placeholder:"Product Type"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Products"}),i.jsx(U,{value:"coconut_milk",children:"Coconut Milk"}),i.jsx(U,{value:"coconut_cream",children:"Coconut Cream"}),i.jsx(U,{value:"coconut_water",children:"Coconut Water"}),i.jsx(U,{value:"desiccated_coconut",children:"Desiccated Coconut"}),i.jsx(U,{value:"coconut_oil",children:"Coconut Oil"})]})]}),i.jsxs(_e,{value:l.status,onValueChange:m=>c(x=>({...x,status:m})),children:[i.jsx(Ae,{className:"w-48",children:i.jsx(De,{placeholder:"Stock Status"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Status"}),i.jsx(U,{value:"in_stock",children:"In Stock"}),i.jsx(U,{value:"low_stock",children:"Low Stock"}),i.jsx(U,{value:"out_of_stock",children:"Out of Stock"})]})]})]})})}),i.jsxs(W,{children:[i.jsxs(J,{children:[i.jsx(ee,{children:"Select Products for Adjustment"}),i.jsx(Rt,{children:"Click on products to select them for bulk adjustments"})]}),i.jsx(H,{children:i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:u.map(m=>i.jsxs("div",{className:`p-4 border rounded-lg cursor-pointer transition-all ${t.includes(m.id)?"border-blue-500 bg-blue-50 shadow-md":"border-gray-200 hover:border-gray-300 hover:shadow-sm"}`,onClick:()=>d(m.id),children:[i.jsxs("div",{className:"flex items-start justify-between mb-2",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("h3",{className:"font-medium text-sm",children:m.name}),i.jsxs("p",{className:"text-xs text-gray-500 capitalize",children:[m.productType.replace("_"," ")," • ",m.businessSector]})]}),i.jsx("input",{type:"checkbox",checked:t.includes(m.id),onChange:()=>d(m.id),className:"w-4 h-4 text-blue-600"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex justify-between items-center",children:[i.jsxs("span",{className:"text-sm font-medium",children:[m.currentStock," ",m.unit]}),v(m.status,m.currentStock)]}),i.jsxs("div",{className:"text-xs text-gray-500",children:["Min: ",m.minimumStock," • Max: ",m.maximumStock]}),m.unitPrice&&i.jsxs("div",{className:"text-xs text-gray-600",children:["Price: ",m.unitPrice]})]})]},m.id))})})]}),i.jsx(zt,{open:n,onOpenChange:a,children:i.jsxs($t,{children:[i.jsxs(Lt,{children:[i.jsx(Ft,{children:"Custom Stock Adjustment"}),i.jsxs(Wa,{children:["Set custom stock levels for ",t.length," selected product",t.length>1?"s":""]})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"operation",children:"Operation"}),i.jsxs(_e,{value:s.operation,onValueChange:m=>o(x=>({...x,operation:m})),children:[i.jsx(Ae,{children:i.jsx(De,{})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"add",children:"Add to current stock"}),i.jsx(U,{value:"subtract",children:"Subtract from current stock"}),i.jsx(U,{value:"set",children:"Set exact stock level"})]})]})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"amount",children:s.operation==="set"?"New Stock Level":"Amount"}),i.jsx(he,{id:"amount",type:"number",value:s.amount,onChange:m=>o(x=>({...x,amount:parseInt(m.target.value)||0})),min:"0"})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"reason",children:"Reason for Adjustment"}),i.jsx(Wn,{id:"reason",value:s.reason,onChange:m=>o(x=>({...x,reason:m.target.value})),placeholder:"Enter reason for this stock adjustment..."})]})]}),i.jsxs(Oi,{children:[i.jsx(z,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),i.jsx(z,{onClick:y,disabled:f.isPending||!s.reason.trim(),children:"Apply Adjustment"})]})]})})]})}const Rk={name:"",productType:"",businessSector:"wholesale",stock:"stock_1",unit:"tin",currentStock:0,minimumStock:10,maximumStock:1e3,unitPrice:"",description:""};function E0(){var I;const{user:e}=qn(),{toast:t}=Ht(),[r,n]=j.useState(!1),[a,s]=j.useState(!1),[o,l]=j.useState(!1),[c,u]=j.useState(null),[f,d]=j.useState(Rk),[h,p]=j.useState({newStock:0,reason:""}),[y,v]=j.useState(""),[m,x]=j.useState({businessSector:"all",productType:"all",status:"all",stock:"all"}),g=e==null?void 0:e.role,b=["super_admin","approver"].includes(g),N=E=>{switch(E){case"milk_one":return"Milk One";case"milk_two":return"Milk Two";case"milk_three":return"Milk Three";case"AR":return"AR";case"LF":return"LF";case"premature":return"Premature";default:return E}},{data:w=[],isLoading:S,error:O,refetch:P}=Fe({queryKey:["/api/products",m],queryFn:async()=>{const E=new URLSearchParams;m.businessSector&&m.businessSector!=="all"&&E.append("businessSector",m.businessSector),m.productType&&m.productType!=="all"&&E.append("productType",m.productType),m.status&&m.status!=="all"&&E.append("status",m.status);const F=await fetch(`/api/products?${E.toString()}`,{credentials:"include",headers:{"Content-Type":"application/json"}});if(!F.ok)throw new Error(`Failed to fetch products: ${F.status}`);return F.json()},enabled:!!e}),{data:A,isLoading:C,error:T}=Fe({queryKey:["/api/stock/summary"],queryFn:async()=>{const E=await fetch("/api/stock/summary",{credentials:"include",headers:{"Content-Type":"application/json"}});if(!E.ok)throw new Error(`Failed to fetch stock summary: ${E.status}`);return E.json()},enabled:!!e}),D=rt({mutationFn:async E=>{const F=await fetch("/api/products",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)});if(!F.ok)throw new Error("Failed to create product");return F.json()},onSuccess:()=>{sa.invalidateQueries({queryKey:["/api/products"]}),sa.invalidateQueries({queryKey:["/api/stock/summary"]}),n(!1),d(Rk),t({title:"Success",description:"Product created successfully"})},onError:E=>{hx(t,E,"Product Creation Failed")}}),_=rt({mutationFn:async({id:E,reason:F})=>{console.log("Deleting product:",E,"with reason:",F);const V=await fetch(`/api/products/${E}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:F}),credentials:"include"});if(!V.ok){const K=await V.text();throw console.error("Delete product error:",K),new Error(`Failed to delete product: ${V.status} - ${K}`)}const G=await V.text();console.log("Delete raw response:",G);try{return G?JSON.parse(G):{success:!0}}catch(K){return console.error("Delete JSON parse error:",K,"Response:",G),{success:!0}}},onSuccess:()=>{sa.invalidateQueries({queryKey:["/api/products"]}),sa.invalidateQueries({queryKey:["/api/stock/summary"]}),l(!1),u(null),v(""),t({title:"Success",description:"Product deleted successfully"})},onError:E=>{hx(t,E,"Product Deletion Failed")}}),k=rt({mutationFn:async({id:E,newStock:F,reason:V})=>{console.log("Adjusting stock:",{id:E,newStock:F,reason:V});const G=await fetch(`/api/products/${E}/adjust-stock`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newStock:F,reason:V}),credentials:"include"});if(!G.ok){const q=await G.text();throw console.error("Adjust stock error:",q),new Error(`Failed to adjust stock: ${G.status} - ${q}`)}const K=await G.text();console.log("Raw response:",K);try{return JSON.parse(K)}catch(q){throw console.error("JSON parse error:",q,"Response:",K),new Error(`Invalid JSON response: ${K}`)}},onSuccess:E=>{console.log("Stock adjustment successful:",E),sa.invalidateQueries({queryKey:["/api/products"]}),sa.invalidateQueries({queryKey:["/api/stock/summary"]}),s(!1),u(null),p({newStock:0,reason:""}),t({title:"Success",description:"Stock adjusted successfully"})},onError:E=>{console.error("Stock adjustment error:",E),hx(t,E,"Stock Adjustment Failed")}}),R=(E,F)=>{switch(E){case"in_stock":return i.jsxs(te,{className:"bg-green-100 text-green-800",children:[i.jsx(ct,{className:"w-3 h-3 mr-1"}),"In Stock"]});case"low_stock":return i.jsxs(te,{className:"bg-yellow-100 text-yellow-800",children:[i.jsx(No,{className:"w-3 h-3 mr-1"}),"Low Stock"]});case"out_of_stock":return i.jsxs(te,{className:"bg-red-100 text-red-800",children:[i.jsx(Ul,{className:"w-3 h-3 mr-1"}),"Out of Stock"]});default:return i.jsx(te,{variant:"secondary",children:"Unknown"})}},$=E=>{u(E),p({newStock:E.currentBalance,reason:""}),s(!0)};return console.log("StockDashboard debug:",{user:e,userRole:g,productsLoading:S,summaryLoading:C,productsError:O,summaryError:T,productsCount:w==null?void 0:w.length,stockSummary:A}),S||C?i.jsx("div",{className:"space-y-6",children:i.jsx(W,{children:i.jsx(H,{className:"p-6",children:i.jsx("div",{className:"text-center",children:"Loading stock data..."})})})}):O||T?i.jsx("div",{className:"space-y-6",children:i.jsx(W,{children:i.jsx(H,{className:"p-6",children:i.jsxs("div",{className:"text-center text-red-600",children:["Error loading stock data: ",(I=O||T)==null?void 0:I.message,i.jsx("br",{}),i.jsx(z,{onClick:()=>{P(),window.location.reload()},className:"mt-2",children:"Retry"})]})})})}):i.jsxs("div",{className:"space-y-6",children:[g==="super_admin"&&i.jsxs(ja,{defaultValue:"overview",className:"space-y-6",children:[i.jsxs(Hn,{className:"grid w-full grid-cols-2",children:[i.jsx(Qe,{value:"overview",children:"Stock Overview"}),i.jsxs(Qe,{value:"adjustment",className:"flex items-center gap-2",children:[i.jsx(pI,{className:"w-4 h-4"}),"One-Click Adjustments"]})]}),i.jsxs(Xe,{value:"overview",className:"space-y-6",children:[A&&i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[i.jsxs(W,{children:[i.jsxs(J,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[i.jsx(ee,{className:"text-sm font-medium",children:"Total Products"}),i.jsx(Ot,{className:"h-4 w-4 text-muted-foreground"})]}),i.jsx(H,{children:i.jsx("div",{className:"text-2xl font-bold",children:A.totalProducts})})]}),i.jsxs(W,{children:[i.jsxs(J,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[i.jsx(ee,{className:"text-sm font-medium",children:"In Stock"}),i.jsx(ct,{className:"h-4 w-4 text-green-600"})]}),i.jsx(H,{children:i.jsx("div",{className:"text-2xl font-bold text-green-600",children:A.inStock})})]}),i.jsxs(W,{children:[i.jsxs(J,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[i.jsx(ee,{className:"text-sm font-medium",children:"Low Stock"}),i.jsx(No,{className:"h-4 w-4 text-yellow-600"})]}),i.jsx(H,{children:i.jsx("div",{className:"text-2xl font-bold text-yellow-600",children:A.lowStock})})]}),i.jsxs(W,{children:[i.jsxs(J,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[i.jsx(ee,{className:"text-sm font-medium",children:"Out of Stock"}),i.jsx(Ul,{className:"h-4 w-4 text-red-600"})]}),i.jsx(H,{children:i.jsx("div",{className:"text-2xl font-bold text-red-600",children:A.outOfStock})})]})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs("div",{className:"flex justify-between items-center",children:[i.jsxs("div",{children:[i.jsx(ee,{children:"Stock Management"}),i.jsx(Rt,{children:"Monitor and manage product inventory levels"})]}),b&&i.jsxs(z,{onClick:()=>n(!0),children:[i.jsx(fn,{className:"w-4 h-4 mr-2"}),"Add Product"]})]})}),i.jsxs(H,{children:[i.jsxs("div",{className:"flex gap-4 mb-6",children:[i.jsxs(_e,{value:m.productType,onValueChange:E=>x(F=>({...F,productType:E})),children:[i.jsx(Ae,{className:"w-48",children:i.jsx(De,{placeholder:"Product Type"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Products"}),i.jsx(U,{value:"milk_one",children:"Milk One"}),i.jsx(U,{value:"milk_two",children:"Milk Two"}),i.jsx(U,{value:"milk_three",children:"Milk Three"}),i.jsx(U,{value:"AR",children:"AR"}),i.jsx(U,{value:"LF",children:"LF"}),i.jsx(U,{value:"premature",children:"Premature"})]})]}),i.jsxs(_e,{value:m.stock,onValueChange:E=>x(F=>({...F,stock:E})),children:[i.jsx(Ae,{className:"w-48",children:i.jsx(De,{placeholder:"Stock Period"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Periods"}),i.jsx(U,{value:"stock_1",children:"Stock 1"}),i.jsx(U,{value:"stock_2",children:"Stock 2"}),i.jsx(U,{value:"stock_3",children:"Stock 3"}),i.jsx(U,{value:"stock_4",children:"Stock 4"}),i.jsx(U,{value:"stock_5",children:"Stock 5"}),i.jsx(U,{value:"stock_6",children:"Stock 6"}),i.jsx(U,{value:"stock_7",children:"Stock 7"}),i.jsx(U,{value:"stock_8",children:"Stock 8"}),i.jsx(U,{value:"stock_9",children:"Stock 9"}),i.jsx(U,{value:"stock_10",children:"Stock 10"})]})]}),i.jsxs(_e,{value:m.status,onValueChange:E=>x(F=>({...F,status:E})),children:[i.jsx(Ae,{className:"w-48",children:i.jsx(De,{placeholder:"Stock Status"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Status"}),i.jsx(U,{value:"in_stock",children:"In Stock"}),i.jsx(U,{value:"low_stock",children:"Low Stock"}),i.jsx(U,{value:"out_of_stock",children:"Out of Stock"})]})]})]}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full border-collapse",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b",children:[i.jsx("th",{className:"text-left p-3 font-medium",children:"Product Type"}),i.jsx("th",{className:"text-left p-3 font-medium",children:"Stock Period"}),i.jsx("th",{className:"text-left p-3 font-medium",children:"Current Stock"}),i.jsx("th",{className:"text-left p-3 font-medium",children:"Status"}),i.jsx("th",{className:"text-left p-3 font-medium",children:"Unit Price"}),b&&i.jsx("th",{className:"text-left p-3 font-medium",children:"Actions"})]})}),i.jsx("tbody",{children:w.filter(E=>["milk_one","milk_two","milk_three","AR","LF","premature"].includes(E.productType)).map(E=>i.jsxs("tr",{className:"border-b hover:bg-slate-50",children:[i.jsx("td",{className:"p-3",children:i.jsx("div",{children:i.jsx("div",{className:"font-medium capitalize",children:E.productType==="milk_one"?"Milk One":E.productType==="milk_two"?"Milk Two":E.productType==="milk_three"?"Milk Three":E.productType})})}),i.jsx("td",{className:"p-3",children:i.jsx("span",{className:"px-2 py-1 bg-blue-100 text-blue-800 rounded-full text-sm font-medium",children:E.stock.replace("stock_","Stock ")})}),i.jsxs("td",{className:"p-3",children:[i.jsx("span",{className:"font-medium",children:E.currentBalance})," ",E.unit]}),i.jsx("td",{className:"p-3",children:R(E.status,E.currentBalance)}),i.jsx("td",{className:"p-3",children:"N/A"}),b&&i.jsx("td",{className:"p-3",children:i.jsxs("div",{className:"flex gap-2",children:[i.jsx(z,{size:"sm",variant:"outline",onClick:()=>$(E),children:i.jsx(Mr,{className:"w-3 h-3"})}),i.jsx(z,{size:"sm",variant:"outline",onClick:()=>{u(E),l(!0)},children:i.jsx(jc,{className:"w-3 h-3"})})]})})]},E.id))})]})})]})]})]}),i.jsx(Xe,{value:"adjustment",children:i.jsx(wCe,{})})]}),g!=="super_admin"&&i.jsxs("div",{className:"space-y-6",children:[A&&i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[i.jsxs(W,{children:[i.jsxs(J,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[i.jsx(ee,{className:"text-sm font-medium",children:"Total Products"}),i.jsx(Ot,{className:"h-4 w-4 text-muted-foreground"})]}),i.jsx(H,{children:i.jsx("div",{className:"text-2xl font-bold",children:A.totalProducts})})]}),i.jsxs(W,{children:[i.jsxs(J,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[i.jsx(ee,{className:"text-sm font-medium",children:"In Stock"}),i.jsx(ct,{className:"h-4 w-4 text-green-600"})]}),i.jsx(H,{children:i.jsx("div",{className:"text-2xl font-bold text-green-600",children:A.inStock})})]}),i.jsxs(W,{children:[i.jsxs(J,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[i.jsx(ee,{className:"text-sm font-medium",children:"Low Stock"}),i.jsx(No,{className:"h-4 w-4 text-yellow-600"})]}),i.jsx(H,{children:i.jsx("div",{className:"text-2xl font-bold text-yellow-600",children:A.lowStock})})]}),i.jsxs(W,{children:[i.jsxs(J,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[i.jsx(ee,{className:"text-sm font-medium",children:"Out of Stock"}),i.jsx(Ul,{className:"h-4 w-4 text-red-600"})]}),i.jsx(H,{children:i.jsx("div",{className:"text-2xl font-bold text-red-600",children:A.outOfStock})})]})]}),i.jsxs(W,{children:[i.jsx(J,{children:i.jsxs("div",{className:"flex justify-between items-center",children:[i.jsxs("div",{children:[i.jsx(ee,{children:"Stock Management"}),i.jsx(Rt,{children:"Monitor and manage product inventory levels"})]}),b&&i.jsxs(z,{onClick:()=>n(!0),children:[i.jsx(fn,{className:"w-4 h-4 mr-2"}),"Add Product"]})]})}),i.jsxs(H,{children:[i.jsxs("div",{className:"flex gap-4 mb-6",children:[i.jsxs(_e,{value:m.productType,onValueChange:E=>x(F=>({...F,productType:E})),children:[i.jsx(Ae,{className:"w-48",children:i.jsx(De,{placeholder:"Product Type"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Products"}),i.jsx(U,{value:"milk_one",children:"Milk One"}),i.jsx(U,{value:"milk_two",children:"Milk Two"}),i.jsx(U,{value:"milk_three",children:"Milk Three"}),i.jsx(U,{value:"AR",children:"AR"}),i.jsx(U,{value:"LF",children:"LF"}),i.jsx(U,{value:"premature",children:"Premature"})]})]}),i.jsxs(_e,{value:m.status,onValueChange:E=>x(F=>({...F,status:E})),children:[i.jsx(Ae,{className:"w-48",children:i.jsx(De,{placeholder:"Stock Status"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Status"}),i.jsx(U,{value:"in_stock",children:"In Stock"}),i.jsx(U,{value:"low_stock",children:"Low Stock"}),i.jsx(U,{value:"out_of_stock",children:"Out of Stock"})]})]})]}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full border-collapse",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b",children:[i.jsx("th",{className:"text-left p-3 font-medium",children:"Product Type"}),i.jsx("th",{className:"text-left p-3 font-medium",children:"Stock Period"}),i.jsx("th",{className:"text-left p-3 font-medium",children:"Current Stock"}),i.jsx("th",{className:"text-left p-3 font-medium",children:"Status"}),i.jsx("th",{className:"text-left p-3 font-medium",children:"Unit Price"}),b&&i.jsx("th",{className:"text-left p-3 font-medium",children:"Actions"})]})}),i.jsx("tbody",{children:w.filter(E=>["milk_one","milk_two","milk_three","AR","LF","premature"].includes(E.productType)).map(E=>i.jsxs("tr",{className:"border-b hover:bg-slate-50",children:[i.jsx("td",{className:"p-3",children:i.jsx("div",{children:i.jsx("div",{className:"font-medium capitalize",children:E.productType==="milk_one"?"Milk One":E.productType==="milk_two"?"Milk Two":E.productType==="milk_three"?"Milk Three":E.productType})})}),i.jsx("td",{className:"p-3",children:i.jsx("span",{className:"px-2 py-1 bg-blue-100 text-blue-800 rounded-full text-sm font-medium",children:E.stock.replace("stock_","Stock ")})}),i.jsxs("td",{className:"p-3",children:[i.jsx("span",{className:"font-medium",children:E.currentBalance})," ",E.unit]}),i.jsx("td",{className:"p-3",children:R(E.status,E.currentBalance)}),i.jsx("td",{className:"p-3",children:"N/A"}),b&&i.jsx("td",{className:"p-3",children:i.jsxs("div",{className:"flex gap-2",children:[i.jsx(z,{size:"sm",variant:"outline",onClick:()=>$(E),children:i.jsx(Mr,{className:"w-3 h-3"})}),i.jsx(z,{size:"sm",variant:"outline",onClick:()=>{u(E),l(!0)},children:i.jsx(jc,{className:"w-3 h-3"})})]})})]},E.id))})]})})]})]})]}),i.jsx(zt,{open:r,onOpenChange:n,children:i.jsxs($t,{className:"max-w-md",children:[i.jsxs(Lt,{children:[i.jsx(Ft,{children:"Add New Product"}),i.jsx(Wa,{children:"Create a new product in the inventory"})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"name",children:"Product Name"}),i.jsx(he,{id:"name",value:f.name,onChange:E=>d(F=>({...F,name:E.target.value}))})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"productType",children:"Product Type"}),i.jsxs(_e,{value:f.productType,onValueChange:E=>d(F=>({...F,productType:E})),children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"Select type"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"milk_one",children:"Milk One"}),i.jsx(U,{value:"milk_two",children:"Milk Two"}),i.jsx(U,{value:"milk_three",children:"Milk Three"}),i.jsx(U,{value:"AR",children:"AR"}),i.jsx(U,{value:"LF",children:"LF"}),i.jsx(U,{value:"premature",children:"Premature"})]})]})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"stock",children:"Stock Period"}),i.jsxs(_e,{value:f.stock,onValueChange:E=>d(F=>({...F,stock:E})),children:[i.jsx(Ae,{children:i.jsx(De,{placeholder:"Select stock period"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"stock_1",children:"Stock 1"}),i.jsx(U,{value:"stock_2",children:"Stock 2"}),i.jsx(U,{value:"stock_3",children:"Stock 3"}),i.jsx(U,{value:"stock_4",children:"Stock 4"}),i.jsx(U,{value:"stock_5",children:"Stock 5"}),i.jsx(U,{value:"stock_6",children:"Stock 6"}),i.jsx(U,{value:"stock_7",children:"Stock 7"}),i.jsx(U,{value:"stock_8",children:"Stock 8"}),i.jsx(U,{value:"stock_9",children:"Stock 9"}),i.jsx(U,{value:"stock_10",children:"Stock 10"})]})]})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"unit",children:"Unit"}),i.jsxs(_e,{value:f.unit,onValueChange:E=>d(F=>({...F,unit:E})),children:[i.jsx(Ae,{children:i.jsx(De,{})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"tin",children:"Tin"}),i.jsx(U,{value:"carton",children:"Carton"})]})]})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"unitPrice",children:"Unit Price"}),i.jsx(he,{id:"unitPrice",value:f.unitPrice,onChange:E=>d(F=>({...F,unitPrice:E.target.value})),placeholder:"0.00"})]})]}),i.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"currentStock",children:"Current Stock"}),i.jsx(he,{id:"currentStock",type:"number",value:f.currentStock,onChange:E=>d(F=>({...F,currentStock:parseInt(E.target.value)||0}))})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"minimumStock",children:"Min Stock"}),i.jsx(he,{id:"minimumStock",type:"number",value:f.minimumStock,onChange:E=>d(F=>({...F,minimumStock:parseInt(E.target.value)||0}))})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"maximumStock",children:"Max Stock"}),i.jsx(he,{id:"maximumStock",type:"number",value:f.maximumStock,onChange:E=>d(F=>({...F,maximumStock:parseInt(E.target.value)||0}))})]})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"description",children:"Description"}),i.jsx(Wn,{id:"description",value:f.description,onChange:E=>d(F=>({...F,description:E.target.value})),placeholder:"Optional product description"})]})]}),i.jsxs(Oi,{children:[i.jsx(z,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),i.jsx(z,{onClick:()=>D.mutate(f),disabled:D.isPending,children:"Create Product"})]})]})}),i.jsx(zt,{open:a,onOpenChange:s,children:i.jsxs($t,{className:"max-w-md",children:[i.jsxs(Lt,{children:[i.jsx(Ft,{children:"Adjust Stock"}),i.jsxs(Wa,{children:["Current stock: ",c==null?void 0:c.currentBalance," ",c==null?void 0:c.unit]})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx(X,{htmlFor:"newStock",children:"New Stock Level"}),i.jsx(he,{id:"newStock",type:"number",value:h.newStock,onChange:E=>p(F=>({...F,newStock:parseInt(E.target.value)||0}))})]}),i.jsxs("div",{children:[i.jsx(X,{htmlFor:"reason",children:"Reason for Adjustment"}),i.jsx(Wn,{id:"reason",value:h.reason,onChange:E=>p(F=>({...F,reason:E.target.value})),placeholder:"Enter reason for stock adjustment"})]})]}),i.jsxs(Oi,{children:[i.jsx(z,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),i.jsx(z,{onClick:()=>{console.log("Adjust stock button clicked",{selectedProduct:c,adjustmentData:h}),c&&k.mutate({id:c.id,newStock:h.newStock,reason:h.reason})},disabled:k.isPending||!c||!h.reason.trim(),children:k.isPending?"Adjusting...":"Adjust Stock"})]})]})}),i.jsx(zt,{open:o,onOpenChange:l,children:i.jsxs($t,{className:"max-w-md",children:[i.jsxs(Lt,{children:[i.jsx(Ft,{children:"Delete Product"}),i.jsxs(Wa,{children:['Are you sure you want to delete "',N((c==null?void 0:c.productType)||""),'"? This action cannot be undone.']})]}),i.jsx("div",{className:"space-y-4",children:i.jsxs("div",{children:[i.jsx(X,{htmlFor:"deleteReason",children:"Reason for deletion"}),i.jsx("textarea",{id:"deleteReason",className:"w-full p-2 border rounded-md",rows:3,placeholder:"Please provide a reason for deleting this product...",value:y,onChange:E=>v(E.target.value)})]})}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(z,{variant:"outline",onClick:()=>{l(!1),u(null),v("")},children:"Cancel"}),i.jsx(z,{variant:"destructive",onClick:()=>{c&&y.trim()&&_.mutate({id:c.id,reason:y.trim()})},disabled:!y.trim()||_.isPending,children:_.isPending?"Deleting...":"Delete Product"})]})]})})]})}function T0(){Za();const[e,t]=j.useState({stock:"all",productType:"all"}),{data:r=[]}=Fe({queryKey:["/api/products",e],queryFn:async()=>{const d=new URLSearchParams;return e.stock&&e.stock!=="all"&&d.append("stock",e.stock),e.productType&&e.productType!=="all"&&d.append("productType",e.productType),(await fetch(`/api/products?${d.toString()}`)).json()}});Fe({queryKey:["/api/stock/summary"],queryFn:async()=>(await fetch("/api/stock/summary")).json()});const{data:n=[]}=Fe({queryKey:["/api/stock/movements"],queryFn:async()=>(await fetch("/api/stock/movements")).json()}),a=(d,h)=>{const p=d/h*100;return d===0?i.jsxs(te,{className:"bg-red-100 text-red-800",children:[i.jsx(Ul,{className:"w-3 h-3 mr-1"}),"Finished"]}):p<=20?i.jsxs(te,{className:"bg-yellow-100 text-yellow-800",children:[i.jsx(No,{className:"w-3 h-3 mr-1"}),"Low Stock"]}):i.jsxs(te,{className:"bg-green-100 text-green-800",children:[i.jsx(ct,{className:"w-3 h-3 mr-1"}),"In Progress"]})},s=()=>{const d=[["Stock","Product Type","Beginning Balance","Current Balance","Unit","Sold","Progress %"].join(","),...r.map(v=>[v.stock,v.productType,v.beginningBalance,v.currentBalance,v.unit,v.beginningBalance-v.currentBalance,((v.beginningBalance-v.currentBalance)/v.beginningBalance*100).toFixed(1)+"%"].join(","))].join(` `),h=new Blob([d],{type:"text/csv"}),p=window.URL.createObjectURL(h),y=document.createElement("a");y.href=p,y.download=`stock_report_${new Date().toISOString().split("T")[0]}.csv`,y.click(),window.URL.revokeObjectURL(p)},o=r.reduce((d,h)=>(d[h.stock]||(d[h.stock]=[]),d[h.stock].push(h),d),{}),l={milk_one:"Milk One",milk_two:"Milk Two",milk_three:"Milk Three",AR:"AR",LF:"LF",premature:"Premature"},c={stock_1:"Stock 1",stock_2:"Stock 2",stock_3:"Stock 3",stock_4:"Stock 4",stock_5:"Stock 5",stock_6:"Stock 6",stock_7:"Stock 7",stock_8:"Stock 8",stock_9:"Stock 9",stock_10:"Stock 10"},u=d=>{switch(d){case"adjustment":return i.jsx(fn,{className:"w-4 h-4 text-blue-600"});case"sale":return i.jsx(KW,{className:"w-4 h-4 text-green-600"});case"deletion":return i.jsx(jc,{className:"w-4 h-4 text-red-600"});default:return i.jsx(gx,{className:"w-4 h-4 text-gray-600"})}},f=d=>{switch(d){case"adjustment":return i.jsx(te,{className:"bg-blue-100 text-blue-800",children:"Adjustment"});case"sale":return i.jsx(te,{className:"bg-green-100 text-green-800",children:"Sale"});case"deletion":return i.jsx(te,{className:"bg-red-100 text-red-800",children:"Deletion"});default:return i.jsx(te,{variant:"secondary",children:d})}};return i.jsxs("div",{className:"flex flex-col min-h-screen bg-slate-50 md:ml-64",children:[i.jsx(Ts,{}),i.jsx("main",{className:"flex-1 p-6",children:i.jsxs("div",{className:"max-w-7xl mx-auto",children:[i.jsx("div",{className:"mb-8",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-10 h-10 bg-gradient-to-r from-green-600 to-blue-600 rounded-lg flex items-center justify-center",children:i.jsx(Et,{className:"w-5 h-5 text-white"})}),i.jsxs("div",{children:[i.jsx("h1",{className:"text-3xl font-bold text-slate-900",children:"Stock Reports"}),i.jsx("p",{className:"text-slate-600",children:"Track progress of milk product stocks until completion"})]})]}),i.jsxs(z,{onClick:s,className:"flex items-center gap-2",children:[i.jsx(Ln,{className:"w-4 h-4"}),"Export Report"]})]})}),i.jsxs(ja,{defaultValue:"summary",className:"space-y-6",children:[i.jsx("div",{className:"overflow-x-auto",children:i.jsxs(Hn,{className:"inline-flex h-auto w-auto min-w-full gap-1 p-1",children:[i.jsx(Qe,{value:"summary",className:"flex-shrink-0 text-xs md:text-sm px-2 py-2",children:"Stock Summary"}),i.jsx(Qe,{value:"detailed",className:"flex-shrink-0 text-xs md:text-sm px-2 py-2",children:"Detailed Report"}),i.jsx(Qe,{value:"progress",className:"flex-shrink-0 text-xs md:text-sm px-2 py-2",children:"Progress Tracking"}),i.jsx(Qe,{value:"movement",className:"flex-shrink-0 text-xs md:text-sm px-2 py-2",children:"Movement History"})]})}),i.jsx(Xe,{value:"summary",className:"space-y-6",children:i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:Object.entries(o).map(([d,h])=>{const p=h.reduce((x,g)=>x+g.beginningBalance,0),y=h.reduce((x,g)=>x+g.currentBalance,0),v=p-y,m=p>0?v/p*100:0;return i.jsxs(W,{children:[i.jsxs(J,{children:[i.jsxs(ee,{className:"flex items-center gap-2",children:[i.jsx(Xr,{className:"w-5 h-5"}),c[d]]}),i.jsxs(Rt,{children:[h.length," product types"]})]}),i.jsx(H,{children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-3 gap-2 text-sm",children:[i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"text-slate-500",children:"Beginning"}),i.jsx("div",{className:"font-bold text-lg",children:p.toLocaleString()})]}),i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"text-slate-500",children:"Sold"}),i.jsx("div",{className:"font-bold text-lg text-blue-600",children:v.toLocaleString()})]}),i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"text-slate-500",children:"Remaining"}),i.jsx("div",{className:"font-bold text-lg text-green-600",children:y.toLocaleString()})]})]}),i.jsxs("div",{className:"flex justify-between text-sm",children:[i.jsx("span",{children:"Progress:"}),i.jsxs("span",{className:"font-medium",children:[m.toFixed(1),"% sold"]})]}),i.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2",children:i.jsx("div",{className:"bg-blue-600 h-2 rounded-full",style:{width:`${m}%`}})}),i.jsx("div",{className:"space-y-2",children:h.map(x=>i.jsxs("div",{className:"flex justify-between items-center p-2 bg-slate-50 rounded text-sm",children:[i.jsx("span",{children:l[x.productType]}),i.jsxs("div",{className:"text-right",children:[i.jsxs("div",{className:"font-medium",children:[x.currentBalance.toLocaleString()," ",x.unit]}),a(x.currentBalance,x.beginningBalance)]})]},x.id))})]})})]},d)})})}),i.jsx(Xe,{value:"detailed",className:"space-y-6",children:i.jsxs(W,{children:[i.jsxs(J,{children:[i.jsx(ee,{children:"Detailed Stock Report"}),i.jsx(Rt,{children:"Complete inventory tracking for all stocks"}),i.jsxs("div",{className:"flex gap-4 pt-4",children:[i.jsxs(_e,{value:e.stock,onValueChange:d=>t(h=>({...h,stock:d})),children:[i.jsx(Ae,{className:"w-48",children:i.jsx(De,{placeholder:"Stock"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Stocks"}),i.jsx(U,{value:"stock_1",children:"Stock 1"}),i.jsx(U,{value:"stock_2",children:"Stock 2"}),i.jsx(U,{value:"stock_3",children:"Stock 3"}),i.jsx(U,{value:"stock_4",children:"Stock 4"}),i.jsx(U,{value:"stock_5",children:"Stock 5"})]})]}),i.jsxs(_e,{value:e.productType,onValueChange:d=>t(h=>({...h,productType:d})),children:[i.jsx(Ae,{className:"w-48",children:i.jsx(De,{placeholder:"Product Type"})}),i.jsxs(Ce,{children:[i.jsx(U,{value:"all",children:"All Products"}),i.jsx(U,{value:"milk_one",children:"Milk One"}),i.jsx(U,{value:"milk_two",children:"Milk Two"}),i.jsx(U,{value:"milk_three",children:"Milk Three"}),i.jsx(U,{value:"AR",children:"AR"}),i.jsx(U,{value:"LF",children:"LF"}),i.jsx(U,{value:"premature",children:"Premature"})]})]})]})]}),i.jsx(H,{children:i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full border-collapse",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b",children:[i.jsx("th",{className:"text-left p-3 font-medium",children:"Stock"}),i.jsx("th",{className:"text-left p-3 font-medium",children:"Product Type"}),i.jsx("th",{className:"text-left p-3 font-medium",children:"Beginning Balance"}),i.jsx("th",{className:"text-left p-3 font-medium",children:"Current Balance"}),i.jsx("th",{className:"text-left p-3 font-medium",children:"Sold"}),i.jsx("th",{className:"text-left p-3 font-medium",children:"Unit"}),i.jsx("th",{className:"text-left p-3 font-medium",children:"Progress"}),i.jsx("th",{className:"text-left p-3 font-medium",children:"Status"})]})}),i.jsx("tbody",{children:r.map(d=>{const h=d.beginningBalance-d.currentBalance,p=d.beginningBalance>0?h/d.beginningBalance*100:0;return i.jsxs("tr",{className:"border-b hover:bg-slate-50",children:[i.jsx("td",{className:"p-3 font-medium",children:c[d.stock]}),i.jsx("td",{className:"p-3",children:l[d.productType]}),i.jsx("td",{className:"p-3",children:i.jsx("span",{className:"font-medium",children:d.beginningBalance.toLocaleString()})}),i.jsx("td",{className:"p-3",children:i.jsx("span",{className:"font-medium text-lg",children:d.currentBalance.toLocaleString()})}),i.jsx("td",{className:"p-3",children:i.jsx("span",{className:"font-medium text-blue-600",children:h.toLocaleString()})}),i.jsx("td",{className:"p-3 capitalize",children:d.unit}),i.jsx("td",{className:"p-3",children:i.jsxs("span",{className:"text-sm",children:[p.toFixed(1),"%"]})}),i.jsx("td",{className:"p-3",children:a(d.currentBalance,d.beginningBalance)})]},d.id)})})]})})})]})}),i.jsx(Xe,{value:"progress",className:"space-y-6",children:i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:Object.entries(o).map(([d,h])=>i.jsxs(W,{children:[i.jsxs(J,{children:[i.jsxs(ee,{children:[c[d]," Progress"]}),i.jsx(Rt,{children:"Track completion progress for this stock"})]}),i.jsx(H,{children:i.jsx("div",{className:"space-y-4",children:h.map(p=>{const y=p.beginningBalance-p.currentBalance,v=p.beginningBalance>0?y/p.beginningBalance*100:0;return i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex justify-between items-center",children:[i.jsx("span",{className:"font-medium",children:l[p.productType]}),i.jsxs("span",{className:"text-sm text-slate-500",children:[v.toFixed(1),"% complete"]})]}),i.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2",children:i.jsx("div",{className:"bg-blue-600 h-2 rounded-full",style:{width:`${v}%`}})}),i.jsxs("div",{className:"flex justify-between text-sm text-slate-600",children:[i.jsxs("span",{children:["Sold: ",y.toLocaleString()," ",p.unit]}),i.jsxs("span",{children:["Remaining: ",p.currentBalance.toLocaleString()," ",p.unit]})]})]},p.id)})})})]},d))})}),i.jsx(Xe,{value:"movement",className:"space-y-6",children:i.jsxs(W,{children:[i.jsxs(J,{children:[i.jsxs(ee,{className:"flex items-center gap-2",children:[i.jsx(gx,{className:"w-5 h-5"}),"Stock Movement History"]}),i.jsx(Rt,{children:"Complete history of all stock movements and changes"})]}),i.jsx(H,{children:n.length>0?i.jsx("div",{className:"space-y-4",children:n.map(d=>{const h=d.newStock-d.previousStock,p=h>0,y=h<0,v=d.movementType==="sale",m=d.movementType==="deletion";return i.jsxs("div",{className:"border rounded-lg p-4 bg-white shadow-sm",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[u(d.movementType),i.jsxs("div",{children:[i.jsx("span",{className:"font-semibold text-lg",children:d.product?l[d.product.productType]||d.product.productType:"Unknown Product"}),i.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[i.jsx(te,{className:"bg-blue-100 text-blue-800 text-xs",children:d.product?c[d.product.stock]||d.product.stock:"Unknown Stock"}),d.movementType==="adjustment"&&i.jsx(te,{className:`text-xs ${p?"bg-green-100 text-green-800":"bg-red-100 text-red-800"}`,children:p?"↗ INCREMENT":"↘ DECREMENT"})]})]})]}),f(d.movementType)]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 text-sm",children:[i.jsxs("div",{className:"bg-slate-50 p-3 rounded",children:[i.jsx("span",{className:"font-medium text-slate-600 block",children:"Quantity Change:"}),i.jsxs("span",{className:`text-lg font-bold ${p?"text-green-600":y||v||m?"text-red-600":"text-slate-800"}`,children:[p?"+":"",h.toLocaleString()]}),i.jsxs("div",{className:"text-xs text-slate-500 mt-1",children:[d.previousStock.toLocaleString()," → ",d.newStock.toLocaleString()]})]}),i.jsxs("div",{className:"bg-slate-50 p-3 rounded",children:[i.jsx("span",{className:"font-medium text-slate-600 block",children:"Adjusted By:"}),i.jsx("span",{className:"text-slate-800 font-medium",children:d.performedBy})]}),i.jsxs("div",{className:"bg-slate-50 p-3 rounded",children:[i.jsx("span",{className:"font-medium text-slate-600 block",children:"Date:"}),i.jsx("span",{className:"text-slate-800",children:new Date(d.performedAt||d.createdAt).toLocaleDateString()})]}),i.jsxs("div",{className:"bg-slate-50 p-3 rounded",children:[i.jsx("span",{className:"font-medium text-slate-600 block",children:"Time:"}),i.jsx("span",{className:"text-slate-800",children:new Date(d.performedAt||d.createdAt).toLocaleTimeString()})]})]}),d.reason&&i.jsxs("div",{className:"mt-4 p-4 bg-blue-50 rounded border-l-4 border-blue-500",children:[i.jsx("span",{className:"font-medium text-blue-900 block mb-1",children:"Adjustment Reason:"}),i.jsx("p",{className:"text-blue-800",children:d.reason})]})]},d.id)})}):i.jsxs("div",{className:"text-center py-12 text-slate-500",children:[i.jsx(gx,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),i.jsx("p",{children:"No stock movements recorded yet"})]})})]})})]})]})})]})}function NCe(){const[e,t]=j.useState("amdom"),[r,n]=j.useState("password123"),{toast:a}=Ht(),s=$r(),o=rt({mutationFn:async c=>await ut("POST","/api/auth/login",c),onSuccess:()=>{a({title:"Login successful",description:"Redirecting to dashboard..."}),s.invalidateQueries({queryKey:["/api/auth/test-user"]}),s.invalidateQueries({queryKey:["/api/auth/user"]}),setTimeout(()=>{window.location.href="/"},1e3)},onError:c=>{a({title:"Login failed",description:c.message||"Invalid credentials",variant:"destructive"})}}),l=c=>{c.preventDefault(),o.mutate({username:e,password:r})};return i.jsx("div",{className:"min-h-screen bg-gradient-to-br from-primary-50 via-white to-primary-50 flex items-center justify-center p-4",children:i.jsxs(W,{className:"w-full max-w-md",children:[i.jsxs(J,{className:"text-center",children:[i.jsx("div",{className:"flex items-center justify-center mb-4",children:i.jsx("div",{className:"w-12 h-12 bg-primary-600 rounded-lg flex items-center justify-center",children:i.jsx(ha,{className:"w-7 h-7 text-white"})})}),i.jsx(ee,{className:"text-2xl font-bold text-slate-800",children:"DOK TOK SALES ORDER"}),i.jsx("p",{className:"text-slate-600",children:"Sales Officer Test Login"})]}),i.jsxs(H,{children:[i.jsxs("form",{onSubmit:l,className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(X,{htmlFor:"username",children:"Username"}),i.jsx(he,{id:"username",type:"text",value:e,onChange:c=>t(c.target.value),placeholder:"Enter username",required:!0})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(X,{htmlFor:"password",children:"Password"}),i.jsx(he,{id:"password",type:"password",value:r,onChange:c=>n(c.target.value),placeholder:"Enter password",required:!0})]}),i.jsx(z,{type:"submit",className:"w-full",disabled:o.isPending,children:o.isPending?"Logging in...":"Login as Approver"})]}),i.jsxs("div",{className:"mt-6 p-4 bg-blue-50 rounded-lg",children:[i.jsx("h3",{className:"font-medium text-blue-800 mb-2",children:"Demo Credentials"}),i.jsxs("p",{className:"text-sm text-blue-700",children:[i.jsx("strong",{children:"Username:"})," amdom",i.jsx("br",{}),i.jsx("strong",{children:"Password:"})," password123"]})]}),i.jsx("div",{className:"mt-4 text-center",children:i.jsx(z,{variant:"ghost",onClick:()=>window.location.href="/api/login",className:"text-sm text-slate-600",children:"Login with Replit Auth instead"})})]})]})})}function SCe(){const[,e]=Qf(),{toast:t}=Ht(),r=$r(),n=rt({mutationFn:async()=>await ut("POST","/api/auth/login",{username:"admin",password:"password123"}),onSuccess:()=>{t({title:"Admin login successful",description:"Welcome, Super Admin!"}),r.invalidateQueries({queryKey:["/api/auth/test-user"]}),r.invalidateQueries({queryKey:["/api/auth/user"]}),e("/")},onError:s=>{t({title:"Admin login failed",description:s.message||"Authentication error",variant:"destructive"})}}),a=()=>{n.mutate()};return i.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center p-4",children:i.jsxs(W,{className:"w-full max-w-md shadow-lg",children:[i.jsxs(J,{className:"text-center pb-6",children:[i.jsx("div",{className:"mx-auto w-16 h-16 bg-blue-600 rounded-full flex items-center justify-center mb-4",children:i.jsx(zb,{className:"w-8 h-8 text-white"})}),i.jsx(ee,{className:"text-2xl font-bold",children:"Super Admin Access"}),i.jsx("p",{className:"text-muted-foreground",children:"DOK TOK Sales Order Management System"})]}),i.jsxs(H,{className:"space-y-6",children:[i.jsx(z,{onClick:a,disabled:n.isPending,className:"w-full",size:"lg",children:n.isPending?"Logging in...":"Login as Super Admin"}),i.jsx("div",{className:"text-center text-sm text-muted-foreground",children:i.jsx("p",{children:"This will log you in with full administrative privileges"})})]})]})})}function iB(){const[e,t]=j.useState(""),[r,n]=j.useState(""),{toast:a}=Ht();Qf();const{refreshAuth:s}=Za(),o=rt({mutationFn:async c=>{const u=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!u.ok){const f=await u.json();throw new Error(f.message||"Login failed")}return u.json()},onSuccess:async c=>{a({title:"Login Successful",description:`Welcome, ${c.user.firstName} ${c.user.lastName}`}),await s(),setTimeout(()=>{window.location.href="/"},100)},onError:c=>{a({title:"Login Failed",description:c.message,variant:"destructive"})}}),l=c=>{if(c.preventDefault(),!e||!r){a({title:"Missing Information",description:"Please enter both username and password",variant:"destructive"});return}o.mutate({username:e,password:r})};return i.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8",children:i.jsxs(W,{className:"w-full max-w-md",children:[i.jsxs(J,{className:"space-y-1",children:[i.jsx(ee,{className:"text-2xl font-bold text-center",children:"DokTok Sales"}),i.jsx(Rt,{className:"text-center",children:"Sign in to your account"})]}),i.jsxs(H,{children:[i.jsxs("form",{onSubmit:l,className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(X,{htmlFor:"username",children:"Username"}),i.jsx(he,{id:"username",type:"text",placeholder:"Enter your username",value:e,onChange:c=>t(c.target.value),disabled:o.isPending})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(X,{htmlFor:"password",children:"Password"}),i.jsx(he,{id:"password",type:"password",placeholder:"Enter your password",value:r,onChange:c=>n(c.target.value),disabled:o.isPending})]}),i.jsx(z,{type:"submit",className:"w-full",disabled:o.isPending,children:o.isPending?"Signing in...":"Sign In"})]}),i.jsxs("div",{className:"mt-6 p-4 bg-gray-50 rounded-lg",children:[i.jsx("div",{className:"text-sm text-gray-600 mb-2 font-medium",children:"Test Users:"}),i.jsxs("div",{className:"space-y-1 text-xs text-gray-500",children:[i.jsxs("div",{children:["Sales Clerk: ",i.jsx("code",{children:"sales_clerk / password123"})]}),i.jsxs("div",{children:["Sales Officer: ",i.jsx("code",{children:"sales_officer / password123"})]}),i.jsxs("div",{children:["Approver: ",i.jsx("code",{children:"approver / password123"})]}),i.jsxs("div",{children:["Super Admin: ",i.jsx("code",{children:"admin / password123"})]})]})]})]})]})})}function OCe(){const{isAuthenticated:e,isLoading:t,user:r}=Za();return i.jsx("div",{className:"min-h-screen bg-gray-100 p-8",children:i.jsxs("div",{className:"max-w-2xl mx-auto bg-white rounded-lg shadow p-6",children:[i.jsx("h1",{className:"text-2xl font-bold mb-6",children:"Debug Information"}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Is Loading:"}),i.jsx("p",{className:"text-lg",children:t?"Yes":"No"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Is Authenticated:"}),i.jsx("p",{className:"text-lg",children:e?"Yes":"No"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"User Data:"}),i.jsx("pre",{className:"bg-gray-100 p-3 rounded text-sm overflow-auto",children:JSON.stringify(r,null,2)})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Current URL:"}),i.jsx("p",{className:"text-lg",children:window.location.href})]}),i.jsxs("div",{className:"pt-4 space-x-4",children:[i.jsx("button",{onClick:()=>window.location.href="/landing",className:"bg-blue-500 text-white px-4 py-2 rounded",children:"Go to Landing"}),i.jsx("button",{onClick:()=>window.location.href="/login",className:"bg-green-500 text-white px-4 py-2 rounded",children:"Go to Login"})]})]})]})})}function PCe(){const e=async(t,r)=>{try{(await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:r})})).ok?window.location.href="/":alert("Login failed. Please try again.")}catch{alert("Login failed. Please try again.")}};return i.jsx("div",{className:"min-h-screen bg-gray-100 flex items-center justify-center p-4",children:i.jsx("div",{className:"max-w-4xl w-full",children:i.jsxs(W,{className:"shadow-lg",children:[i.jsxs(J,{className:"text-center",children:[i.jsx(ee,{className:"text-2xl font-bold",children:"DOK TOK Sales - Quick Login"}),i.jsx("p",{className:"text-gray-600",children:"Choose a role to access the system"})]}),i.jsxs(H,{children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[i.jsxs(W,{className:"border-blue-200 hover:border-blue-400 transition-colors cursor-pointer",onClick:()=>e("admin","password123"),children:[i.jsxs(J,{className:"text-center py-4",children:[i.jsx(ee,{className:"text-lg text-blue-700",children:"Super Admin"}),i.jsx("p",{className:"text-sm text-gray-600",children:"Full system access"})]}),i.jsx(H,{className:"text-center py-2",children:i.jsx(z,{className:"w-full bg-blue-600 hover:bg-blue-700",children:"Login as Admin"})})]}),i.jsxs(W,{className:"border-green-200 hover:border-green-400 transition-colors cursor-pointer",onClick:()=>e("sales_officer","password123"),children:[i.jsxs(J,{className:"text-center py-4",children:[i.jsx(ee,{className:"text-lg text-green-700",children:"Sales Officer"}),i.jsx("p",{className:"text-sm text-gray-600",children:"Create orders, track payments"})]}),i.jsx(H,{className:"text-center py-2",children:i.jsx(z,{className:"w-full bg-green-600 hover:bg-green-700",children:"Login as Sales"})})]}),i.jsxs(W,{className:"border-purple-200 hover:border-purple-400 transition-colors cursor-pointer",onClick:()=>e("approver","password123"),children:[i.jsxs(J,{className:"text-center py-4",children:[i.jsx(ee,{className:"text-lg text-purple-700",children:"Approver"}),i.jsx("p",{className:"text-sm text-gray-600",children:"Approve orders, manage payments"})]}),i.jsx(H,{className:"text-center py-2",children:i.jsx(z,{className:"w-full bg-purple-600 hover:bg-purple-700",children:"Login as Approver"})})]}),i.jsxs(W,{className:"border-orange-200 hover:border-orange-400 transition-colors cursor-pointer",onClick:()=>e("sales_clerk","password123"),children:[i.jsxs(J,{className:"text-center py-4",children:[i.jsx(ee,{className:"text-lg text-orange-700",children:"Sales Clerk"}),i.jsx("p",{className:"text-sm text-gray-600",children:"Data entry, FS numbers"})]}),i.jsx(H,{className:"text-center py-2",children:i.jsx(z,{className:"w-full bg-orange-600 hover:bg-orange-700",children:"Login as Clerk"})})]})]}),i.jsx("div",{className:"mt-6 text-center",children:i.jsx(z,{variant:"outline",onClick:()=>window.location.href="/login",children:"Use Manual Login Instead"})})]})]})})})}function ACe(){const e=()=>{window.location.replace(window.location.origin+"/")},t=()=>{window.location.reload()};return i.jsx("div",{className:"min-h-screen bg-gray-100 flex items-center justify-center p-4",children:i.jsxs(W,{className:"max-w-md w-full shadow-lg",children:[i.jsxs(J,{className:"text-center",children:[i.jsx("div",{className:"mx-auto w-12 h-12 bg-red-100 rounded-full flex items-center justify-center mb-4",children:i.jsx(eh,{className:"w-6 h-6 text-red-600"})}),i.jsx(ee,{className:"text-xl font-bold text-gray-900",children:"Connection Error"}),i.jsx("p",{className:"text-gray-600 mt-2",children:"There seems to be a temporary issue. Please try refreshing the page or return to the home page."})]}),i.jsxs(H,{className:"space-y-4",children:[i.jsxs(z,{onClick:e,className:"w-full bg-blue-600 hover:bg-blue-700",children:[i.jsx(q1,{className:"w-4 h-4 mr-2"}),"Go to Home Page"]}),i.jsxs(z,{onClick:t,variant:"outline",className:"w-full",children:[i.jsx(za,{className:"w-4 h-4 mr-2"}),"Refresh Page"]}),i.jsxs("div",{className:"text-center text-sm text-gray-500 mt-4",children:[i.jsx("p",{children:"If the problem persists, try:"}),i.jsxs("ul",{className:"text-left mt-2 space-y-1",children:[i.jsx("li",{children:"• Clearing your browser cache"}),i.jsx("li",{children:"• Using an incognito/private window"}),i.jsx("li",{children:"• Trying a different browser"})]})]})]})]})})}class CCe extends j.Component{constructor(){super(...arguments),this.state={hasError:!1},this.handleGoHome=()=>{window.location.href="/"},this.handleRefresh=()=>{window.location.reload()},this.handleReset=()=>{this.setState({hasError:!1,error:void 0})}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,r){console.error("Production Error Boundary caught an error:",t,r)}render(){return this.state.hasError?i.jsx("div",{className:"min-h-screen bg-gray-100 flex items-center justify-center p-4",children:i.jsxs(W,{className:"max-w-lg w-full shadow-lg",children:[i.jsxs(J,{className:"text-center",children:[i.jsx("div",{className:"mx-auto w-12 h-12 bg-red-100 rounded-full flex items-center justify-center mb-4",children:i.jsx(No,{className:"w-6 h-6 text-red-600"})}),i.jsx(ee,{className:"text-xl font-bold text-gray-900",children:"Application Error"}),i.jsx("p",{className:"text-gray-600 mt-2",children:"Something went wrong. This is likely a temporary issue."})]}),i.jsxs(H,{className:"space-y-4",children:[i.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[i.jsxs(z,{onClick:this.handleGoHome,className:"flex-1 bg-blue-600 hover:bg-blue-700",children:[i.jsx(q1,{className:"w-4 h-4 mr-2"}),"Go Home"]}),i.jsxs(z,{onClick:this.handleRefresh,variant:"outline",className:"flex-1",children:[i.jsx(za,{className:"w-4 h-4 mr-2"}),"Refresh"]})]}),i.jsx(z,{onClick:this.handleReset,variant:"ghost",className:"w-full text-sm",children:"Try Again"}),i.jsxs("div",{className:"text-center text-xs text-gray-500 mt-4 p-3 bg-gray-50 rounded",children:[i.jsx("p",{children:i.jsx("strong",{children:"Quick Solutions:"})}),i.jsxs("ul",{className:"text-left mt-2 space-y-1",children:[i.jsx("li",{children:"• Clear browser cache and cookies"}),i.jsx("li",{children:"• Try an incognito/private window"}),i.jsx("li",{children:"• Use a different browser"}),i.jsx("li",{children:"• Check your internet connection"})]})]})]})]})}):this.props.children}}function ECe(){const[e,t]=Qf(),{toast:r}=Ht(),n=$r(),[a,s]=j.useState(!1),o=j.useRef(null),l=j.useRef(!1),c=rt({mutationFn:async u=>await ut("POST","/api/auth/telegram-login",{token:u}),onSuccess:u=>{const f=u.user||u;r({title:"Welcome back!",description:`Logged in as ${f.firstName} ${f.lastName}`}),n.invalidateQueries(),s(!0),setTimeout(()=>{f.role==="approver"?t("/approvals"):f.role==="sales_officer"?t("/tracking"):t("/")},500)},onError:u=>{r({title:"Auto-login failed",description:u.message||"Please login manually",variant:"destructive"}),s(!0);const f=e.split("?")[0];window.history.replaceState({},"",f),t("/admin-login")}});return j.useEffect(()=>{if(a||l.current)return;const f=new URLSearchParams(window.location.search).get("token");if(f&&o.current!==f&&!c.isPending){l.current=!0,o.current=f;const d=e.split("?")[0];window.history.replaceState({},"",d),c.mutate(f)}},[]),null}class sB extends j.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,r){console.log("Authentication error caught:",t,r)}render(){return this.state.hasError?i.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8",children:i.jsxs(W,{className:"w-full max-w-md",children:[i.jsxs(J,{className:"text-center",children:[i.jsx(eh,{className:"w-12 h-12 text-amber-500 mx-auto mb-4"}),i.jsx(ee,{className:"text-xl",children:"Authentication Service"})]}),i.jsxs(H,{className:"text-center space-y-4",children:[i.jsx("p",{className:"text-gray-600",children:"The system is experiencing temporary connectivity issues. Authentication is still available."}),i.jsxs(z,{onClick:()=>{this.setState({hasError:!1}),window.location.reload()},className:"w-full",children:[i.jsx(za,{className:"w-4 h-4 mr-2"}),"Continue to Login"]}),i.jsx("p",{className:"text-xs text-gray-500",children:"All user data and functionality remain available through secure fallback systems."})]})]})}):this.props.children}}function TCe(){const{user:e}=Za();if(!e)return i.jsx(sB,{children:i.jsx(iB,{})});switch(e.role){case"super_admin":return i.jsxs("div",{className:"min-h-screen bg-slate-50",children:[i.jsx(ca,{}),i.jsxs("div",{className:"md:ml-64 min-h-screen",children:[i.jsx("div",{className:"bg-white border-b border-slate-200 px-4 py-2 flex justify-end",children:i.jsxs("button",{onClick:async()=>{try{await fetch("/api/auth/logout",{method:"POST"}),window.location.href="/login"}catch(t){console.error("Logout error:",t),window.location.href="/login"}},className:"bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg text-sm font-medium transition-colors duration-200 flex items-center gap-2",children:[i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})}),"Logout"]})}),i.jsxs(sd,{children:[i.jsx(Te,{path:"/orders",component:Lx}),i.jsx(Te,{path:"/users",component:$Y}),i.jsx(Te,{path:"/reports",component:UT}),i.jsx(Te,{path:"/analytics",component:Op}),i.jsx(Te,{path:"/bot",component:L1e}),i.jsx(Te,{path:"/approvals",component:P0}),i.jsx(Te,{path:"/payment-approvals",component:Mk}),i.jsx(Te,{path:"/sales-clerk",component:A0}),i.jsx(Te,{path:"/payment-reports",component:C0}),i.jsx(Te,{path:"/tracking",component:h0}),i.jsx(Te,{path:"/my-payment-tracking",component:Dk}),i.jsx(Te,{path:"/session-inventory",component:E0}),i.jsx(Te,{path:"/session-reports",component:T0}),i.jsx(Te,{path:"/",component:Ix})]})]})]});case"sales_officer":return i.jsxs("div",{className:"min-h-screen bg-slate-50",children:[i.jsx(ca,{}),i.jsxs("div",{className:"md:ml-64 min-h-screen",children:[i.jsx("div",{className:"bg-white border-b border-slate-200 px-4 py-2 flex justify-end",children:i.jsxs("button",{onClick:async()=>{try{await fetch("/api/auth/logout",{method:"POST"}),window.location.href="/login"}catch(t){console.error("Logout error:",t),window.location.href="/login"}},className:"bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg text-sm font-medium transition-colors duration-200 flex items-center gap-2",children:[i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})}),"Logout"]})}),i.jsxs(sd,{children:[i.jsx(Te,{path:"/tracking",component:h0}),i.jsx(Te,{path:"/analytics",component:Op}),i.jsx(Te,{path:"/my-payment-tracking",component:Dk}),i.jsx(Te,{path:"/",component:h0})]})]})]});case"approver":return i.jsxs("div",{className:"min-h-screen bg-slate-50",children:[i.jsx(ca,{}),i.jsxs("div",{className:"md:ml-64 min-h-screen",children:[i.jsx("div",{className:"bg-white border-b border-slate-200 px-4 py-2 flex justify-end",children:i.jsxs("button",{onClick:async()=>{try{await fetch("/api/auth/logout",{method:"POST"}),window.location.href="/login"}catch(t){console.error("Logout error:",t),window.location.href="/login"}},className:"bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg text-sm font-medium transition-colors duration-200 flex items-center gap-2",children:[i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})}),"Logout"]})}),i.jsxs(sd,{children:[i.jsx(Te,{path:"/orders",component:Lx}),i.jsx(Te,{path:"/reports",component:UT}),i.jsx(Te,{path:"/analytics",component:Op}),i.jsx(Te,{path:"/approvals",component:P0}),i.jsx(Te,{path:"/payment-approvals",component:Mk}),i.jsx(Te,{path:"/payment-reports",component:C0}),i.jsx(Te,{path:"/session-inventory",component:E0}),i.jsx(Te,{path:"/session-reports",component:T0}),i.jsx(Te,{path:"/",component:Ix})]})]})]});case"sales_clerk":return i.jsxs("div",{className:"min-h-screen bg-slate-50",children:[i.jsx(ca,{}),i.jsx("div",{className:"md:ml-64 min-h-screen",children:i.jsxs(sd,{children:[i.jsx(Te,{path:"/orders",component:Lx}),i.jsx(Te,{path:"/approvals",component:P0}),i.jsx(Te,{path:"/analytics",component:Op}),i.jsx(Te,{path:"/payment-reports",component:C0}),i.jsx(Te,{path:"/sales-clerk",component:A0}),i.jsx(Te,{path:"/session-inventory",component:E0}),i.jsx(Te,{path:"/session-reports",component:T0}),i.jsx(Te,{path:"/",component:A0})]})})]});default:return i.jsx(Ix,{})}}function kCe(){const{isAuthenticated:e,isLoading:t}=Za();return i.jsxs(i.Fragment,{children:[i.jsxs(sd,{children:[i.jsx(Te,{path:"/test-login",component:NCe}),i.jsx(Te,{path:"/admin-login",component:SCe}),i.jsx(Te,{path:"/login",component:iB}),i.jsx(Te,{path:"/landing",component:nA}),i.jsx(Te,{path:"/quick-login",component:PCe}),i.jsx(Te,{path:"/debug",component:OCe}),i.jsx(Te,{path:"/error",component:ACe}),e?i.jsx(Te,{path:"*",component:TCe}):i.jsx(Te,{path:"*",children:()=>i.jsx(nA,{})})]}),i.jsx(ECe,{})]})}function _Ce(){return i.jsx(CCe,{children:i.jsx(sB,{children:i.jsx(Az,{client:sa,children:i.jsxs(M7,{children:[i.jsx(kCe,{}),i.jsx(D7,{})]})})})})}class DCe extends M.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,r){console.error("Error caught by boundary:",t,r)}render(){return this.state.hasError?this.props.fallback||i.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:i.jsxs("div",{className:"text-center space-y-4",children:[i.jsx("h2",{className:"text-xl font-semibold text-red-600",children:"Something went wrong"}),i.jsx("p",{className:"text-gray-600",children:"Please refresh the page and try again."}),i.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600",children:"Refresh Page"})]})}):this.props.children}}function MCe(){typeof window<"u"&&(Array.prototype.find||(Array.prototype.find=function(e){for(let t=0;t=e)return r;const n=String(t),a=e-r.length;let s="";for(let o=0;o