(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const n of l)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function a(l){const n={};return l.integrity&&(n.integrity=l.integrity),l.referrerPolicy&&(n.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?n.credentials="include":l.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function r(l){if(l.ep)return;l.ep=!0;const n=a(l);fetch(l.href,n)}})();function pf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var su={exports:{}},un={};/**
 * @license React
 * react-jsx-runtime.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var bf=Symbol.for("react.transitional.element"),yf=Symbol.for("react.fragment");function ru(e,t,a){var r=null;if(a!==void 0&&(r=""+a),t.key!==void 0&&(r=""+t.key),"key"in t){a={};for(var l in t)l!=="key"&&(a[l]=t[l])}else a=t;return t=a.ref,{$$typeof:bf,type:e,key:r,ref:t!==void 0?t:null,props:a}}un.Fragment=yf;un.jsx=ru;un.jsxs=ru;su.exports=un;var s=su.exports,lu={exports:{}},J={};/**
 * @license React
 * react.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var hi=Symbol.for("react.transitional.element"),vf=Symbol.for("react.portal"),jf=Symbol.for("react.fragment"),Nf=Symbol.for("react.strict_mode"),wf=Symbol.for("react.profiler"),Sf=Symbol.for("react.consumer"),Ef=Symbol.for("react.context"),_f=Symbol.for("react.forward_ref"),kf=Symbol.for("react.suspense"),Cf=Symbol.for("react.memo"),nu=Symbol.for("react.lazy"),Nc=Symbol.iterator;function Mf(e){return e===null||typeof e!="object"?null:(e=Nc&&e[Nc]||e["@@iterator"],typeof e=="function"?e:null)}var ou={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},iu=Object.assign,cu={};function Os(e,t,a){this.props=e,this.context=t,this.refs=cu,this.updater=a||ou}Os.prototype.isReactComponent={};Os.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("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")};Os.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function du(){}du.prototype=Os.prototype;function xi(e,t,a){this.props=e,this.context=t,this.refs=cu,this.updater=a||ou}var gi=xi.prototype=new du;gi.constructor=xi;iu(gi,Os.prototype);gi.isPureReactComponent=!0;var wc=Array.isArray,fe={H:null,A:null,T:null,S:null,V:null},uu=Object.prototype.hasOwnProperty;function pi(e,t,a,r,l,n){return a=n.ref,{$$typeof:hi,type:e,key:t,ref:a!==void 0?a:null,props:n}}function Rf(e,t){return pi(e.type,t,void 0,void 0,void 0,e.props)}function bi(e){return typeof e=="object"&&e!==null&&e.$$typeof===hi}function Tf(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(a){return t[a]})}var Sc=/\/+/g;function Tn(e,t){return typeof e=="object"&&e!==null&&e.key!=null?Tf(""+e.key):t.toString(36)}function Ec(){}function zf(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch(typeof e.status=="string"?e.then(Ec,Ec):(e.status="pending",e.then(function(t){e.status==="pending"&&(e.status="fulfilled",e.value=t)},function(t){e.status==="pending"&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}function Fa(e,t,a,r,l){var n=typeof e;(n==="undefined"||n==="boolean")&&(e=null);var o=!1;if(e===null)o=!0;else switch(n){case"bigint":case"string":case"number":o=!0;break;case"object":switch(e.$$typeof){case hi:case vf:o=!0;break;case nu:return o=e._init,Fa(o(e._payload),t,a,r,l)}}if(o)return l=l(e),o=r===""?"."+Tn(e,0):r,wc(l)?(a="",o!=null&&(a=o.replace(Sc,"$&/")+"/"),Fa(l,t,a,"",function(m){return m})):l!=null&&(bi(l)&&(l=Rf(l,a+(l.key==null||e&&e.key===l.key?"":(""+l.key).replace(Sc,"$&/")+"/")+o)),t.push(l)),1;o=0;var i=r===""?".":r+":";if(wc(e))for(var c=0;c<e.length;c++)r=e[c],n=i+Tn(r,c),o+=Fa(r,t,a,n,l);else if(c=Mf(e),typeof c=="function")for(e=c.call(e),c=0;!(r=e.next()).done;)r=r.value,n=i+Tn(r,c++),o+=Fa(r,t,a,n,l);else if(n==="object"){if(typeof e.then=="function")return Fa(zf(e),t,a,r,l);throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.")}return o}function al(e,t,a){if(e==null)return e;var r=[],l=0;return Fa(e,r,"","",function(n){return t.call(a,n,l++)}),r}function Lf(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(a){(e._status===0||e._status===-1)&&(e._status=1,e._result=a)},function(a){(e._status===0||e._status===-1)&&(e._status=2,e._result=a)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var _c=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)};function Af(){}J.Children={map:al,forEach:function(e,t,a){al(e,function(){t.apply(this,arguments)},a)},count:function(e){var t=0;return al(e,function(){t++}),t},toArray:function(e){return al(e,function(t){return t})||[]},only:function(e){if(!bi(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};J.Component=Os;J.Fragment=jf;J.Profiler=wf;J.PureComponent=xi;J.StrictMode=Nf;J.Suspense=kf;J.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=fe;J.__COMPILER_RUNTIME={__proto__:null,c:function(e){return fe.H.useMemoCache(e)}};J.cache=function(e){return function(){return e.apply(null,arguments)}};J.cloneElement=function(e,t,a){if(e==null)throw Error("The argument must be a React element, but you passed "+e+".");var r=iu({},e.props),l=e.key,n=void 0;if(t!=null)for(o in t.ref!==void 0&&(n=void 0),t.key!==void 0&&(l=""+t.key),t)!uu.call(t,o)||o==="key"||o==="__self"||o==="__source"||o==="ref"&&t.ref===void 0||(r[o]=t[o]);var o=arguments.length-2;if(o===1)r.children=a;else if(1<o){for(var i=Array(o),c=0;c<o;c++)i[c]=arguments[c+2];r.children=i}return pi(e.type,l,void 0,void 0,n,r)};J.createContext=function(e){return e={$$typeof:Ef,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:Sf,_context:e},e};J.createElement=function(e,t,a){var r,l={},n=null;if(t!=null)for(r in t.key!==void 0&&(n=""+t.key),t)uu.call(t,r)&&r!=="key"&&r!=="__self"&&r!=="__source"&&(l[r]=t[r]);var o=arguments.length-2;if(o===1)l.children=a;else if(1<o){for(var i=Array(o),c=0;c<o;c++)i[c]=arguments[c+2];l.children=i}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)l[r]===void 0&&(l[r]=o[r]);return pi(e,n,void 0,void 0,null,l)};J.createRef=function(){return{current:null}};J.forwardRef=function(e){return{$$typeof:_f,render:e}};J.isValidElement=bi;J.lazy=function(e){return{$$typeof:nu,_payload:{_status:-1,_result:e},_init:Lf}};J.memo=function(e,t){return{$$typeof:Cf,type:e,compare:t===void 0?null:t}};J.startTransition=function(e){var t=fe.T,a={};fe.T=a;try{var r=e(),l=fe.S;l!==null&&l(a,r),typeof r=="object"&&r!==null&&typeof r.then=="function"&&r.then(Af,_c)}catch(n){_c(n)}finally{fe.T=t}};J.unstable_useCacheRefresh=function(){return fe.H.useCacheRefresh()};J.use=function(e){return fe.H.use(e)};J.useActionState=function(e,t,a){return fe.H.useActionState(e,t,a)};J.useCallback=function(e,t){return fe.H.useCallback(e,t)};J.useContext=function(e){return fe.H.useContext(e)};J.useDebugValue=function(){};J.useDeferredValue=function(e,t){return fe.H.useDeferredValue(e,t)};J.useEffect=function(e,t,a){var r=fe.H;if(typeof a=="function")throw Error("useEffect CRUD overload is not enabled in this build of React.");return r.useEffect(e,t)};J.useId=function(){return fe.H.useId()};J.useImperativeHandle=function(e,t,a){return fe.H.useImperativeHandle(e,t,a)};J.useInsertionEffect=function(e,t){return fe.H.useInsertionEffect(e,t)};J.useLayoutEffect=function(e,t){return fe.H.useLayoutEffect(e,t)};J.useMemo=function(e,t){return fe.H.useMemo(e,t)};J.useOptimistic=function(e,t){return fe.H.useOptimistic(e,t)};J.useReducer=function(e,t,a){return fe.H.useReducer(e,t,a)};J.useRef=function(e){return fe.H.useRef(e)};J.useState=function(e){return fe.H.useState(e)};J.useSyncExternalStore=function(e,t,a){return fe.H.useSyncExternalStore(e,t,a)};J.useTransition=function(){return fe.H.useTransition()};J.version="19.1.1";lu.exports=J;var g=lu.exports;const Of=pf(g);var mu={exports:{}},mn={},fu={exports:{}},hu={};/**
 * @license React
 * scheduler.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */(function(e){function t(O,B){var T=O.length;O.push(B);e:for(;0<T;){var $=T-1>>>1,I=O[$];if(0<l(I,B))O[$]=B,O[T]=I,T=$;else break e}}function a(O){return O.length===0?null:O[0]}function r(O){if(O.length===0)return null;var B=O[0],T=O.pop();if(T!==B){O[0]=T;e:for(var $=0,I=O.length,Ge=I>>>1;$<Ge;){var V=2*($+1)-1,ge=O[V],Ee=V+1,_e=O[Ee];if(0>l(ge,T))Ee<I&&0>l(_e,ge)?(O[$]=_e,O[Ee]=T,$=Ee):(O[$]=ge,O[V]=T,$=V);else if(Ee<I&&0>l(_e,T))O[$]=_e,O[Ee]=T,$=Ee;else break e}}return B}function l(O,B){var T=O.sortIndex-B.sortIndex;return T!==0?T:O.id-B.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var n=performance;e.unstable_now=function(){return n.now()}}else{var o=Date,i=o.now();e.unstable_now=function(){return o.now()-i}}var c=[],m=[],u=1,x=null,f=3,b=!1,j=!1,v=!1,S=!1,h=typeof setTimeout=="function"?setTimeout:null,d=typeof clearTimeout=="function"?clearTimeout:null,p=typeof setImmediate<"u"?setImmediate:null;function y(O){for(var B=a(m);B!==null;){if(B.callback===null)r(m);else if(B.startTime<=O)r(m),B.sortIndex=B.expirationTime,t(c,B);else break;B=a(m)}}function E(O){if(v=!1,y(O),!j)if(a(c)!==null)j=!0,w||(w=!0,_());else{var B=a(m);B!==null&&A(E,B.startTime-O)}}var w=!1,N=-1,R=5,z=-1;function C(){return S?!0:!(e.unstable_now()-z<R)}function k(){if(S=!1,w){var O=e.unstable_now();z=O;var B=!0;try{e:{j=!1,v&&(v=!1,d(N),N=-1),b=!0;var T=f;try{t:{for(y(O),x=a(c);x!==null&&!(x.expirationTime>O&&C());){var $=x.callback;if(typeof $=="function"){x.callback=null,f=x.priorityLevel;var I=$(x.expirationTime<=O);if(O=e.unstable_now(),typeof I=="function"){x.callback=I,y(O),B=!0;break t}x===a(c)&&r(c),y(O)}else r(c);x=a(c)}if(x!==null)B=!0;else{var Ge=a(m);Ge!==null&&A(E,Ge.startTime-O),B=!1}}break e}finally{x=null,f=T,b=!1}B=void 0}}finally{B?_():w=!1}}}var _;if(typeof p=="function")_=function(){p(k)};else if(typeof MessageChannel<"u"){var H=new MessageChannel,Q=H.port2;H.port1.onmessage=k,_=function(){Q.postMessage(null)}}else _=function(){h(k,0)};function A(O,B){N=h(function(){O(e.unstable_now())},B)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(O){O.callback=null},e.unstable_forceFrameRate=function(O){0>O||125<O?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<O?Math.floor(1e3/O):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(O){switch(f){case 1:case 2:case 3:var B=3;break;default:B=f}var T=f;f=B;try{return O()}finally{f=T}},e.unstable_requestPaint=function(){S=!0},e.unstable_runWithPriority=function(O,B){switch(O){case 1:case 2:case 3:case 4:case 5:break;default:O=3}var T=f;f=O;try{return B()}finally{f=T}},e.unstable_scheduleCallback=function(O,B,T){var $=e.unstable_now();switch(typeof T=="object"&&T!==null?(T=T.delay,T=typeof T=="number"&&0<T?$+T:$):T=$,O){case 1:var I=-1;break;case 2:I=250;break;case 5:I=1073741823;break;case 4:I=1e4;break;default:I=5e3}return I=T+I,O={id:u++,callback:B,priorityLevel:O,startTime:T,expirationTime:I,sortIndex:-1},T>$?(O.sortIndex=T,t(m,O),a(c)===null&&O===a(m)&&(v?(d(N),N=-1):v=!0,A(E,T-$))):(O.sortIndex=I,t(c,O),j||b||(j=!0,w||(w=!0,_()))),O},e.unstable_shouldYield=C,e.unstable_wrapCallback=function(O){var B=f;return function(){var T=f;f=B;try{return O.apply(this,arguments)}finally{f=T}}}})(hu);fu.exports=hu;var Df=fu.exports,xu={exports:{}},Xe={};/**
 * @license React
 * react-dom.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Uf=g;function gu(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)t+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function ra(){}var $e={d:{f:ra,r:function(){throw Error(gu(522))},D:ra,C:ra,L:ra,m:ra,X:ra,S:ra,M:ra},p:0,findDOMNode:null},Hf=Symbol.for("react.portal");function Bf(e,t,a){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Hf,key:r==null?null:""+r,children:e,containerInfo:t,implementation:a}}var nr=Uf.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function fn(e,t){if(e==="font")return"";if(typeof t=="string")return t==="use-credentials"?t:""}Xe.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=$e;Xe.createPortal=function(e,t){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(gu(299));return Bf(e,t,null,a)};Xe.flushSync=function(e){var t=nr.T,a=$e.p;try{if(nr.T=null,$e.p=2,e)return e()}finally{nr.T=t,$e.p=a,$e.d.f()}};Xe.preconnect=function(e,t){typeof e=="string"&&(t?(t=t.crossOrigin,t=typeof t=="string"?t==="use-credentials"?t:"":void 0):t=null,$e.d.C(e,t))};Xe.prefetchDNS=function(e){typeof e=="string"&&$e.d.D(e)};Xe.preinit=function(e,t){if(typeof e=="string"&&t&&typeof t.as=="string"){var a=t.as,r=fn(a,t.crossOrigin),l=typeof t.integrity=="string"?t.integrity:void 0,n=typeof t.fetchPriority=="string"?t.fetchPriority:void 0;a==="style"?$e.d.S(e,typeof t.precedence=="string"?t.precedence:void 0,{crossOrigin:r,integrity:l,fetchPriority:n}):a==="script"&&$e.d.X(e,{crossOrigin:r,integrity:l,fetchPriority:n,nonce:typeof t.nonce=="string"?t.nonce:void 0})}};Xe.preinitModule=function(e,t){if(typeof e=="string")if(typeof t=="object"&&t!==null){if(t.as==null||t.as==="script"){var a=fn(t.as,t.crossOrigin);$e.d.M(e,{crossOrigin:a,integrity:typeof t.integrity=="string"?t.integrity:void 0,nonce:typeof t.nonce=="string"?t.nonce:void 0})}}else t==null&&$e.d.M(e)};Xe.preload=function(e,t){if(typeof e=="string"&&typeof t=="object"&&t!==null&&typeof t.as=="string"){var a=t.as,r=fn(a,t.crossOrigin);$e.d.L(e,a,{crossOrigin:r,integrity:typeof t.integrity=="string"?t.integrity:void 0,nonce:typeof t.nonce=="string"?t.nonce:void 0,type:typeof t.type=="string"?t.type:void 0,fetchPriority:typeof t.fetchPriority=="string"?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy=="string"?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet=="string"?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes=="string"?t.imageSizes:void 0,media:typeof t.media=="string"?t.media:void 0})}};Xe.preloadModule=function(e,t){if(typeof e=="string")if(t){var a=fn(t.as,t.crossOrigin);$e.d.m(e,{as:typeof t.as=="string"&&t.as!=="script"?t.as:void 0,crossOrigin:a,integrity:typeof t.integrity=="string"?t.integrity:void 0})}else $e.d.m(e)};Xe.requestFormReset=function(e){$e.d.r(e)};Xe.unstable_batchedUpdates=function(e,t){return e(t)};Xe.useFormState=function(e,t,a){return nr.H.useFormState(e,t,a)};Xe.useFormStatus=function(){return nr.H.useHostTransitionStatus()};Xe.version="19.1.1";function pu(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(pu)}catch(e){console.error(e)}}pu(),xu.exports=Xe;var qf=xu.exports;/**
 * @license React
 * react-dom-client.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Re=Df,bu=g,Vf=qf;function L(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)t+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function yu(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Dr(e){var t=e,a=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(a=t.return),e=t.return;while(e)}return t.tag===3?a:null}function vu(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function kc(e){if(Dr(e)!==e)throw Error(L(188))}function Gf(e){var t=e.alternate;if(!t){if(t=Dr(e),t===null)throw Error(L(188));return t!==e?null:e}for(var a=e,r=t;;){var l=a.return;if(l===null)break;var n=l.alternate;if(n===null){if(r=l.return,r!==null){a=r;continue}break}if(l.child===n.child){for(n=l.child;n;){if(n===a)return kc(l),e;if(n===r)return kc(l),t;n=n.sibling}throw Error(L(188))}if(a.return!==r.return)a=l,r=n;else{for(var o=!1,i=l.child;i;){if(i===a){o=!0,a=l,r=n;break}if(i===r){o=!0,r=l,a=n;break}i=i.sibling}if(!o){for(i=n.child;i;){if(i===a){o=!0,a=n,r=l;break}if(i===r){o=!0,r=n,a=l;break}i=i.sibling}if(!o)throw Error(L(189))}}if(a.alternate!==r)throw Error(L(190))}if(a.tag!==3)throw Error(L(188));return a.stateNode.current===a?e:t}function ju(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=ju(e),t!==null)return t;e=e.sibling}return null}var de=Object.assign,Qf=Symbol.for("react.element"),sl=Symbol.for("react.transitional.element"),ar=Symbol.for("react.portal"),ss=Symbol.for("react.fragment"),Nu=Symbol.for("react.strict_mode"),go=Symbol.for("react.profiler"),Yf=Symbol.for("react.provider"),wu=Symbol.for("react.consumer"),Qt=Symbol.for("react.context"),yi=Symbol.for("react.forward_ref"),po=Symbol.for("react.suspense"),bo=Symbol.for("react.suspense_list"),vi=Symbol.for("react.memo"),oa=Symbol.for("react.lazy"),yo=Symbol.for("react.activity"),$f=Symbol.for("react.memo_cache_sentinel"),Cc=Symbol.iterator;function Xs(e){return e===null||typeof e!="object"?null:(e=Cc&&e[Cc]||e["@@iterator"],typeof e=="function"?e:null)}var Xf=Symbol.for("react.client.reference");function vo(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Xf?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case ss:return"Fragment";case go:return"Profiler";case Nu:return"StrictMode";case po:return"Suspense";case bo:return"SuspenseList";case yo:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case ar:return"Portal";case Qt:return(e.displayName||"Context")+".Provider";case wu:return(e._context.displayName||"Context")+".Consumer";case yi:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case vi:return t=e.displayName||null,t!==null?t:vo(e.type)||"Memo";case oa:t=e._payload,e=e._init;try{return vo(e(t))}catch{}}return null}var sr=Array.isArray,Y=bu.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ae=Vf.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Oa={pending:!1,data:null,method:null,action:null},jo=[],rs=-1;function Ot(e){return{current:e}}function Ae(e){0>rs||(e.current=jo[rs],jo[rs]=null,rs--)}function he(e,t){rs++,jo[rs]=e.current,e.current=t}var zt=Ot(null),jr=Ot(null),pa=Ot(null),Ll=Ot(null);function Al(e,t){switch(he(pa,t),he(jr,e),he(zt,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Ld(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Ld(t),e=q0(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}Ae(zt),he(zt,e)}function Ss(){Ae(zt),Ae(jr),Ae(pa)}function No(e){e.memoizedState!==null&&he(Ll,e);var t=zt.current,a=q0(t,e.type);t!==a&&(he(jr,e),he(zt,a))}function Ol(e){jr.current===e&&(Ae(zt),Ae(jr)),Ll.current===e&&(Ae(Ll),Tr._currentValue=Oa)}var wo=Object.prototype.hasOwnProperty,ji=Re.unstable_scheduleCallback,zn=Re.unstable_cancelCallback,Zf=Re.unstable_shouldYield,Jf=Re.unstable_requestPaint,Lt=Re.unstable_now,Kf=Re.unstable_getCurrentPriorityLevel,Su=Re.unstable_ImmediatePriority,Eu=Re.unstable_UserBlockingPriority,Dl=Re.unstable_NormalPriority,Wf=Re.unstable_LowPriority,_u=Re.unstable_IdlePriority,Pf=Re.log,Ff=Re.unstable_setDisableYieldValue,Ur=null,rt=null;function fa(e){if(typeof Pf=="function"&&Ff(e),rt&&typeof rt.setStrictMode=="function")try{rt.setStrictMode(Ur,e)}catch{}}var lt=Math.clz32?Math.clz32:th,If=Math.log,eh=Math.LN2;function th(e){return e>>>=0,e===0?32:31-(If(e)/eh|0)|0}var rl=256,ll=4194304;function za(e){var t=e&42;if(t!==0)return t;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:return 64;case 128:return 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&4194048;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function hn(e,t,a){var r=e.pendingLanes;if(r===0)return 0;var l=0,n=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var i=r&134217727;return i!==0?(r=i&~n,r!==0?l=za(r):(o&=i,o!==0?l=za(o):a||(a=i&~e,a!==0&&(l=za(a))))):(i=r&~n,i!==0?l=za(i):o!==0?l=za(o):a||(a=r&~e,a!==0&&(l=za(a)))),l===0?0:t!==0&&t!==l&&!(t&n)&&(n=l&-l,a=t&-t,n>=a||n===32&&(a&4194048)!==0)?t:l}function Hr(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ah(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32: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 t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ku(){var e=rl;return rl<<=1,!(rl&4194048)&&(rl=256),e}function Cu(){var e=ll;return ll<<=1,!(ll&62914560)&&(ll=4194304),e}function Ln(e){for(var t=[],a=0;31>a;a++)t.push(e);return t}function Br(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function sh(e,t,a,r,l,n){var o=e.pendingLanes;e.pendingLanes=a,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=a,e.entangledLanes&=a,e.errorRecoveryDisabledLanes&=a,e.shellSuspendCounter=0;var i=e.entanglements,c=e.expirationTimes,m=e.hiddenUpdates;for(a=o&~a;0<a;){var u=31-lt(a),x=1<<u;i[u]=0,c[u]=-1;var f=m[u];if(f!==null)for(m[u]=null,u=0;u<f.length;u++){var b=f[u];b!==null&&(b.lane&=-536870913)}a&=~x}r!==0&&Mu(e,r,0),n!==0&&l===0&&e.tag!==0&&(e.suspendedLanes|=n&~(o&~t))}function Mu(e,t,a){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-lt(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|a&4194090}function Ru(e,t){var a=e.entangledLanes|=t;for(e=e.entanglements;a;){var r=31-lt(a),l=1<<r;l&t|e[r]&t&&(e[r]|=t),a&=~l}}function Ni(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;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:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function wi(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function Tu(){var e=ae.p;return e!==0?e:(e=window.event,e===void 0?32:W0(e.type))}function rh(e,t){var a=ae.p;try{return ae.p=e,t()}finally{ae.p=a}}var Ca=Math.random().toString(36).slice(2),qe="__reactFiber$"+Ca,Pe="__reactProps$"+Ca,Ds="__reactContainer$"+Ca,So="__reactEvents$"+Ca,lh="__reactListeners$"+Ca,nh="__reactHandles$"+Ca,Mc="__reactResources$"+Ca,qr="__reactMarker$"+Ca;function Si(e){delete e[qe],delete e[Pe],delete e[So],delete e[lh],delete e[nh]}function ls(e){var t=e[qe];if(t)return t;for(var a=e.parentNode;a;){if(t=a[Ds]||a[qe]){if(a=t.alternate,t.child!==null||a!==null&&a.child!==null)for(e=Dd(e);e!==null;){if(a=e[qe])return a;e=Dd(e)}return t}e=a,a=e.parentNode}return null}function Us(e){if(e=e[qe]||e[Ds]){var t=e.tag;if(t===5||t===6||t===13||t===26||t===27||t===3)return e}return null}function rr(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(L(33))}function xs(e){var t=e[Mc];return t||(t=e[Mc]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function ze(e){e[qr]=!0}var zu=new Set,Lu={};function Xa(e,t){Es(e,t),Es(e+"Capture",t)}function Es(e,t){for(Lu[e]=t,e=0;e<t.length;e++)zu.add(t[e])}var oh=RegExp("^[: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]*$"),Rc={},Tc={};function ih(e){return wo.call(Tc,e)?!0:wo.call(Rc,e)?!1:oh.test(e)?Tc[e]=!0:(Rc[e]=!0,!1)}function bl(e,t,a){if(ih(t))if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var r=t.toLowerCase().slice(0,5);if(r!=="data-"&&r!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+a)}}function nl(e,t,a){if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+a)}}function Ht(e,t,a,r){if(r===null)e.removeAttribute(a);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(a);return}e.setAttributeNS(t,a,""+r)}}var An,zc;function Ia(e){if(An===void 0)try{throw Error()}catch(a){var t=a.stack.trim().match(/\n( *(at )?)/);An=t&&t[1]||"",zc=-1<a.stack.indexOf(`
    at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
`+An+e+zc}var On=!1;function Dn(e,t){if(!e||On)return"";On=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var x=function(){throw Error()};if(Object.defineProperty(x.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(x,[])}catch(b){var f=b}Reflect.construct(e,[],x)}else{try{x.call()}catch(b){f=b}e.call(x.prototype)}}else{try{throw Error()}catch(b){f=b}(x=e())&&typeof x.catch=="function"&&x.catch(function(){})}}catch(b){if(b&&f&&typeof b.stack=="string")return[b.stack,f.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var l=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,"name");l&&l.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var n=r.DetermineComponentFrameRoot(),o=n[0],i=n[1];if(o&&i){var c=o.split(`
`),m=i.split(`
`);for(l=r=0;r<c.length&&!c[r].includes("DetermineComponentFrameRoot");)r++;for(;l<m.length&&!m[l].includes("DetermineComponentFrameRoot");)l++;if(r===c.length||l===m.length)for(r=c.length-1,l=m.length-1;1<=r&&0<=l&&c[r]!==m[l];)l--;for(;1<=r&&0<=l;r--,l--)if(c[r]!==m[l]){if(r!==1||l!==1)do if(r--,l--,0>l||c[r]!==m[l]){var u=`
`+c[r].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}while(1<=r&&0<=l);break}}}finally{On=!1,Error.prepareStackTrace=a}return(a=e?e.displayName||e.name:"")?Ia(a):""}function ch(e){switch(e.tag){case 26:case 27:case 5:return Ia(e.type);case 16:return Ia("Lazy");case 13:return Ia("Suspense");case 19:return Ia("SuspenseList");case 0:case 15:return Dn(e.type,!1);case 11:return Dn(e.type.render,!1);case 1:return Dn(e.type,!0);case 31:return Ia("Activity");default:return""}}function Lc(e){try{var t="";do t+=ch(e),e=e.return;while(e);return t}catch(a){return`
Error generating stack: `+a.message+`
`+a.stack}}function ut(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Au(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function dh(e){var t=Au(e)?"checked":"value",a=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var l=a.get,n=a.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(o){r=""+o,n.call(this,o)}}),Object.defineProperty(e,t,{enumerable:a.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ul(e){e._valueTracker||(e._valueTracker=dh(e))}function Ou(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var a=t.getValue(),r="";return e&&(r=Au(e)?e.checked?"true":"false":e.value),e=r,e!==a?(t.setValue(e),!0):!1}function Hl(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}}var uh=/[\n"\\]/g;function ht(e){return e.replace(uh,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Eo(e,t,a,r,l,n,o,i){e.name="",o!=null&&typeof o!="function"&&typeof o!="symbol"&&typeof o!="boolean"?e.type=o:e.removeAttribute("type"),t!=null?o==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+ut(t)):e.value!==""+ut(t)&&(e.value=""+ut(t)):o!=="submit"&&o!=="reset"||e.removeAttribute("value"),t!=null?_o(e,o,ut(t)):a!=null?_o(e,o,ut(a)):r!=null&&e.removeAttribute("value"),l==null&&n!=null&&(e.defaultChecked=!!n),l!=null&&(e.checked=l&&typeof l!="function"&&typeof l!="symbol"),i!=null&&typeof i!="function"&&typeof i!="symbol"&&typeof i!="boolean"?e.name=""+ut(i):e.removeAttribute("name")}function Du(e,t,a,r,l,n,o,i){if(n!=null&&typeof n!="function"&&typeof n!="symbol"&&typeof n!="boolean"&&(e.type=n),t!=null||a!=null){if(!(n!=="submit"&&n!=="reset"||t!=null))return;a=a!=null?""+ut(a):"",t=t!=null?""+ut(t):a,i||t===e.value||(e.value=t),e.defaultValue=t}r=r??l,r=typeof r!="function"&&typeof r!="symbol"&&!!r,e.checked=i?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!="function"&&typeof o!="symbol"&&typeof o!="boolean"&&(e.name=o)}function _o(e,t,a){t==="number"&&Hl(e.ownerDocument)===e||e.defaultValue===""+a||(e.defaultValue=""+a)}function gs(e,t,a,r){if(e=e.options,t){t={};for(var l=0;l<a.length;l++)t["$"+a[l]]=!0;for(a=0;a<e.length;a++)l=t.hasOwnProperty("$"+e[a].value),e[a].selected!==l&&(e[a].selected=l),l&&r&&(e[a].defaultSelected=!0)}else{for(a=""+ut(a),t=null,l=0;l<e.length;l++){if(e[l].value===a){e[l].selected=!0,r&&(e[l].defaultSelected=!0);return}t!==null||e[l].disabled||(t=e[l])}t!==null&&(t.selected=!0)}}function Uu(e,t,a){if(t!=null&&(t=""+ut(t),t!==e.value&&(e.value=t),a==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=a!=null?""+ut(a):""}function Hu(e,t,a,r){if(t==null){if(r!=null){if(a!=null)throw Error(L(92));if(sr(r)){if(1<r.length)throw Error(L(93));r=r[0]}a=r}a==null&&(a=""),t=a}a=ut(t),e.defaultValue=a,r=e.textContent,r===a&&r!==""&&r!==null&&(e.value=r)}function _s(e,t){if(t){var a=e.firstChild;if(a&&a===e.lastChild&&a.nodeType===3){a.nodeValue=t;return}}e.textContent=t}var mh=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Ac(e,t,a){var r=t.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?r?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":r?e.setProperty(t,a):typeof a!="number"||a===0||mh.has(t)?t==="float"?e.cssFloat=a:e[t]=(""+a).trim():e[t]=a+"px"}function Bu(e,t,a){if(t!=null&&typeof t!="object")throw Error(L(62));if(e=e.style,a!=null){for(var r in a)!a.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf("--")===0?e.setProperty(r,""):r==="float"?e.cssFloat="":e[r]="");for(var l in t)r=t[l],t.hasOwnProperty(l)&&a[l]!==r&&Ac(e,l,r)}else for(var n in t)t.hasOwnProperty(n)&&Ac(e,n,t[n])}function Ei(e){if(e.indexOf("-")===-1)return!1;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 fh=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),hh=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function yl(e){return hh.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}var ko=null;function _i(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ns=null,ps=null;function Oc(e){var t=Us(e);if(t&&(e=t.stateNode)){var a=e[Pe]||null;e:switch(e=t.stateNode,t.type){case"input":if(Eo(e,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),t=a.name,a.type==="radio"&&t!=null){for(a=e;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+ht(""+t)+'"][type="radio"]'),t=0;t<a.length;t++){var r=a[t];if(r!==e&&r.form===e.form){var l=r[Pe]||null;if(!l)throw Error(L(90));Eo(r,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name)}}for(t=0;t<a.length;t++)r=a[t],r.form===e.form&&Ou(r)}break e;case"textarea":Uu(e,a.value,a.defaultValue);break e;case"select":t=a.value,t!=null&&gs(e,!!a.multiple,t,!1)}}}var Un=!1;function qu(e,t,a){if(Un)return e(t,a);Un=!0;try{var r=e(t);return r}finally{if(Un=!1,(ns!==null||ps!==null)&&(Sn(),ns&&(t=ns,e=ps,ps=ns=null,Oc(t),e)))for(t=0;t<e.length;t++)Oc(e[t])}}function Nr(e,t){var a=e.stateNode;if(a===null)return null;var r=a[Pe]||null;if(r===null)return null;a=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(a&&typeof a!="function")throw Error(L(231,t,typeof a));return a}var Pt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Co=!1;if(Pt)try{var Zs={};Object.defineProperty(Zs,"passive",{get:function(){Co=!0}}),window.addEventListener("test",Zs,Zs),window.removeEventListener("test",Zs,Zs)}catch{Co=!1}var ha=null,ki=null,vl=null;function Vu(){if(vl)return vl;var e,t=ki,a=t.length,r,l="value"in ha?ha.value:ha.textContent,n=l.length;for(e=0;e<a&&t[e]===l[e];e++);var o=a-e;for(r=1;r<=o&&t[a-r]===l[n-r];r++);return vl=l.slice(e,1<r?1-r:void 0)}function jl(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function ol(){return!0}function Dc(){return!1}function Fe(e){function t(a,r,l,n,o){this._reactName=a,this._targetInst=l,this.type=r,this.nativeEvent=n,this.target=o,this.currentTarget=null;for(var i in e)e.hasOwnProperty(i)&&(a=e[i],this[i]=a?a(n):n[i]);return this.isDefaultPrevented=(n.defaultPrevented!=null?n.defaultPrevented:n.returnValue===!1)?ol:Dc,this.isPropagationStopped=Dc,this}return de(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=ol)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=ol)},persist:function(){},isPersistent:ol}),t}var Za={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},xn=Fe(Za),Vr=de({},Za,{view:0,detail:0}),xh=Fe(Vr),Hn,Bn,Js,gn=de({},Vr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ci,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Js&&(Js&&e.type==="mousemove"?(Hn=e.screenX-Js.screenX,Bn=e.screenY-Js.screenY):Bn=Hn=0,Js=e),Hn)},movementY:function(e){return"movementY"in e?e.movementY:Bn}}),Uc=Fe(gn),gh=de({},gn,{dataTransfer:0}),ph=Fe(gh),bh=de({},Vr,{relatedTarget:0}),qn=Fe(bh),yh=de({},Za,{animationName:0,elapsedTime:0,pseudoElement:0}),vh=Fe(yh),jh=de({},Za,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Nh=Fe(jh),wh=de({},Za,{data:0}),Hc=Fe(wh),Sh={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Eh={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},_h={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function kh(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=_h[e])?!!t[e]:!1}function Ci(){return kh}var Ch=de({},Vr,{key:function(e){if(e.key){var t=Sh[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=jl(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Eh[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ci,charCode:function(e){return e.type==="keypress"?jl(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?jl(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Mh=Fe(Ch),Rh=de({},gn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Bc=Fe(Rh),Th=de({},Vr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ci}),zh=Fe(Th),Lh=de({},Za,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ah=Fe(Lh),Oh=de({},gn,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Dh=Fe(Oh),Uh=de({},Za,{newState:0,oldState:0}),Hh=Fe(Uh),Bh=[9,13,27,32],Mi=Pt&&"CompositionEvent"in window,or=null;Pt&&"documentMode"in document&&(or=document.documentMode);var qh=Pt&&"TextEvent"in window&&!or,Gu=Pt&&(!Mi||or&&8<or&&11>=or),qc=" ",Vc=!1;function Qu(e,t){switch(e){case"keyup":return Bh.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Yu(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var os=!1;function Vh(e,t){switch(e){case"compositionend":return Yu(t);case"keypress":return t.which!==32?null:(Vc=!0,qc);case"textInput":return e=t.data,e===qc&&Vc?null:e;default:return null}}function Gh(e,t){if(os)return e==="compositionend"||!Mi&&Qu(e,t)?(e=Vu(),vl=ki=ha=null,os=!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.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Gu&&t.locale!=="ko"?null:t.data;default:return null}}var Qh={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Gc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Qh[e.type]:t==="textarea"}function $u(e,t,a,r){ns?ps?ps.push(r):ps=[r]:ns=r,t=an(t,"onChange"),0<t.length&&(a=new xn("onChange","change",null,a,r),e.push({event:a,listeners:t}))}var ir=null,wr=null;function Yh(e){U0(e,0)}function pn(e){var t=rr(e);if(Ou(t))return e}function Qc(e,t){if(e==="change")return t}var Xu=!1;if(Pt){var Vn;if(Pt){var Gn="oninput"in document;if(!Gn){var Yc=document.createElement("div");Yc.setAttribute("oninput","return;"),Gn=typeof Yc.oninput=="function"}Vn=Gn}else Vn=!1;Xu=Vn&&(!document.documentMode||9<document.documentMode)}function $c(){ir&&(ir.detachEvent("onpropertychange",Zu),wr=ir=null)}function Zu(e){if(e.propertyName==="value"&&pn(wr)){var t=[];$u(t,wr,e,_i(e)),qu(Yh,t)}}function $h(e,t,a){e==="focusin"?($c(),ir=t,wr=a,ir.attachEvent("onpropertychange",Zu)):e==="focusout"&&$c()}function Xh(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return pn(wr)}function Zh(e,t){if(e==="click")return pn(t)}function Jh(e,t){if(e==="input"||e==="change")return pn(t)}function Kh(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var it=typeof Object.is=="function"?Object.is:Kh;function Sr(e,t){if(it(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var a=Object.keys(e),r=Object.keys(t);if(a.length!==r.length)return!1;for(r=0;r<a.length;r++){var l=a[r];if(!wo.call(t,l)||!it(e[l],t[l]))return!1}return!0}function Xc(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Zc(e,t){var a=Xc(e);e=0;for(var r;a;){if(a.nodeType===3){if(r=e+a.textContent.length,e<=t&&r>=t)return{node:a,offset:t-e};e=r}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Xc(a)}}function Ju(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ju(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Ku(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Hl(e.document);t instanceof e.HTMLIFrameElement;){try{var a=typeof t.contentWindow.location.href=="string"}catch{a=!1}if(a)e=t.contentWindow;else break;t=Hl(e.document)}return t}function Ri(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")}var Wh=Pt&&"documentMode"in document&&11>=document.documentMode,is=null,Mo=null,cr=null,Ro=!1;function Jc(e,t,a){var r=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Ro||is==null||is!==Hl(r)||(r=is,"selectionStart"in r&&Ri(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),cr&&Sr(cr,r)||(cr=r,r=an(Mo,"onSelect"),0<r.length&&(t=new xn("onSelect","select",null,t,a),e.push({event:t,listeners:r}),t.target=is)))}function Ta(e,t){var a={};return a[e.toLowerCase()]=t.toLowerCase(),a["Webkit"+e]="webkit"+t,a["Moz"+e]="moz"+t,a}var cs={animationend:Ta("Animation","AnimationEnd"),animationiteration:Ta("Animation","AnimationIteration"),animationstart:Ta("Animation","AnimationStart"),transitionrun:Ta("Transition","TransitionRun"),transitionstart:Ta("Transition","TransitionStart"),transitioncancel:Ta("Transition","TransitionCancel"),transitionend:Ta("Transition","TransitionEnd")},Qn={},Wu={};Pt&&(Wu=document.createElement("div").style,"AnimationEvent"in window||(delete cs.animationend.animation,delete cs.animationiteration.animation,delete cs.animationstart.animation),"TransitionEvent"in window||delete cs.transitionend.transition);function Ja(e){if(Qn[e])return Qn[e];if(!cs[e])return e;var t=cs[e],a;for(a in t)if(t.hasOwnProperty(a)&&a in Wu)return Qn[e]=t[a];return e}var Pu=Ja("animationend"),Fu=Ja("animationiteration"),Iu=Ja("animationstart"),Ph=Ja("transitionrun"),Fh=Ja("transitionstart"),Ih=Ja("transitioncancel"),em=Ja("transitionend"),tm=new Map,To="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");To.push("scrollEnd");function wt(e,t){tm.set(e,t),Xa(t,[e])}var Kc=new WeakMap;function xt(e,t){if(typeof e=="object"&&e!==null){var a=Kc.get(e);return a!==void 0?a:(t={value:e,source:t,stack:Lc(t)},Kc.set(e,t),t)}return{value:e,source:t,stack:Lc(t)}}var dt=[],ds=0,Ti=0;function bn(){for(var e=ds,t=Ti=ds=0;t<e;){var a=dt[t];dt[t++]=null;var r=dt[t];dt[t++]=null;var l=dt[t];dt[t++]=null;var n=dt[t];if(dt[t++]=null,r!==null&&l!==null){var o=r.pending;o===null?l.next=l:(l.next=o.next,o.next=l),r.pending=l}n!==0&&am(a,l,n)}}function yn(e,t,a,r){dt[ds++]=e,dt[ds++]=t,dt[ds++]=a,dt[ds++]=r,Ti|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function zi(e,t,a,r){return yn(e,t,a,r),Bl(e)}function Hs(e,t){return yn(e,null,null,t),Bl(e)}function am(e,t,a){e.lanes|=a;var r=e.alternate;r!==null&&(r.lanes|=a);for(var l=!1,n=e.return;n!==null;)n.childLanes|=a,r=n.alternate,r!==null&&(r.childLanes|=a),n.tag===22&&(e=n.stateNode,e===null||e._visibility&1||(l=!0)),e=n,n=n.return;return e.tag===3?(n=e.stateNode,l&&t!==null&&(l=31-lt(a),e=n.hiddenUpdates,r=e[l],r===null?e[l]=[t]:r.push(t),t.lane=a|536870912),n):null}function Bl(e){if(50<yr)throw yr=0,Fo=null,Error(L(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var us={};function ex(e,t,a,r){this.tag=e,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function st(e,t,a,r){return new ex(e,t,a,r)}function Li(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Jt(e,t){var a=e.alternate;return a===null?(a=st(e.tag,t,e.key,e.mode),a.elementType=e.elementType,a.type=e.type,a.stateNode=e.stateNode,a.alternate=e,e.alternate=a):(a.pendingProps=t,a.type=e.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=e.flags&65011712,a.childLanes=e.childLanes,a.lanes=e.lanes,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,t=e.dependencies,a.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},a.sibling=e.sibling,a.index=e.index,a.ref=e.ref,a.refCleanup=e.refCleanup,a}function sm(e,t){e.flags&=65011714;var a=e.alternate;return a===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=a.childLanes,e.lanes=a.lanes,e.child=a.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=a.memoizedProps,e.memoizedState=a.memoizedState,e.updateQueue=a.updateQueue,e.type=a.type,t=a.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Nl(e,t,a,r,l,n){var o=0;if(r=e,typeof e=="function")Li(e)&&(o=1);else if(typeof e=="string")o=ag(e,a,zt.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case yo:return e=st(31,a,t,l),e.elementType=yo,e.lanes=n,e;case ss:return Da(a.children,l,n,t);case Nu:o=8,l|=24;break;case go:return e=st(12,a,t,l|2),e.elementType=go,e.lanes=n,e;case po:return e=st(13,a,t,l),e.elementType=po,e.lanes=n,e;case bo:return e=st(19,a,t,l),e.elementType=bo,e.lanes=n,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Yf:case Qt:o=10;break e;case wu:o=9;break e;case yi:o=11;break e;case vi:o=14;break e;case oa:o=16,r=null;break e}o=29,a=Error(L(130,e===null?"null":typeof e,"")),r=null}return t=st(o,a,t,l),t.elementType=e,t.type=r,t.lanes=n,t}function Da(e,t,a,r){return e=st(7,e,r,t),e.lanes=a,e}function Yn(e,t,a){return e=st(6,e,null,t),e.lanes=a,e}function $n(e,t,a){return t=st(4,e.children!==null?e.children:[],e.key,t),t.lanes=a,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var ms=[],fs=0,ql=null,Vl=0,mt=[],ft=0,Ua=null,Yt=1,$t="";function La(e,t){ms[fs++]=Vl,ms[fs++]=ql,ql=e,Vl=t}function rm(e,t,a){mt[ft++]=Yt,mt[ft++]=$t,mt[ft++]=Ua,Ua=e;var r=Yt;e=$t;var l=32-lt(r)-1;r&=~(1<<l),a+=1;var n=32-lt(t)+l;if(30<n){var o=l-l%5;n=(r&(1<<o)-1).toString(32),r>>=o,l-=o,Yt=1<<32-lt(t)+l|a<<l|r,$t=n+e}else Yt=1<<n|a<<l|r,$t=e}function Ai(e){e.return!==null&&(La(e,1),rm(e,1,0))}function Oi(e){for(;e===ql;)ql=ms[--fs],ms[fs]=null,Vl=ms[--fs],ms[fs]=null;for(;e===Ua;)Ua=mt[--ft],mt[ft]=null,$t=mt[--ft],mt[ft]=null,Yt=mt[--ft],mt[ft]=null}var Ye=null,be=null,te=!1,Ha=null,Rt=!1,zo=Error(L(519));function Ga(e){var t=Error(L(418,""));throw Er(xt(t,e)),zo}function Wc(e){var t=e.stateNode,a=e.type,r=e.memoizedProps;switch(t[qe]=e,t[Pe]=r,a){case"dialog":P("cancel",t),P("close",t);break;case"iframe":case"object":case"embed":P("load",t);break;case"video":case"audio":for(a=0;a<Cr.length;a++)P(Cr[a],t);break;case"source":P("error",t);break;case"img":case"image":case"link":P("error",t),P("load",t);break;case"details":P("toggle",t);break;case"input":P("invalid",t),Du(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0),Ul(t);break;case"select":P("invalid",t);break;case"textarea":P("invalid",t),Hu(t,r.value,r.defaultValue,r.children),Ul(t)}a=r.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||t.textContent===""+a||r.suppressHydrationWarning===!0||B0(t.textContent,a)?(r.popover!=null&&(P("beforetoggle",t),P("toggle",t)),r.onScroll!=null&&P("scroll",t),r.onScrollEnd!=null&&P("scrollend",t),r.onClick!=null&&(t.onclick=kn),t=!0):t=!1,t||Ga(e)}function Pc(e){for(Ye=e.return;Ye;)switch(Ye.tag){case 5:case 13:Rt=!1;return;case 27:case 3:Rt=!0;return;default:Ye=Ye.return}}function Ks(e){if(e!==Ye)return!1;if(!te)return Pc(e),te=!0,!1;var t=e.tag,a;if((a=t!==3&&t!==27)&&((a=t===5)&&(a=e.type,a=!(a!=="form"&&a!=="button")||ri(e.type,e.memoizedProps)),a=!a),a&&be&&Ga(e),Pc(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(L(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8)if(a=e.data,a==="/$"){if(t===0){be=vt(e.nextSibling);break e}t--}else a!=="$"&&a!=="$!"&&a!=="$?"||t++;e=e.nextSibling}be=null}}else t===27?(t=be,Ma(e.type)?(e=oi,oi=null,be=e):be=t):be=Ye?vt(e.stateNode.nextSibling):null;return!0}function Gr(){be=Ye=null,te=!1}function Fc(){var e=Ha;return e!==null&&(Ke===null?Ke=e:Ke.push.apply(Ke,e),Ha=null),e}function Er(e){Ha===null?Ha=[e]:Ha.push(e)}var Lo=Ot(null),Ka=null,Xt=null;function ca(e,t,a){he(Lo,t._currentValue),t._currentValue=a}function Kt(e){e._currentValue=Lo.current,Ae(Lo)}function Ao(e,t,a){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===a)break;e=e.return}}function Oo(e,t,a,r){var l=e.child;for(l!==null&&(l.return=e);l!==null;){var n=l.dependencies;if(n!==null){var o=l.child;n=n.firstContext;e:for(;n!==null;){var i=n;n=l;for(var c=0;c<t.length;c++)if(i.context===t[c]){n.lanes|=a,i=n.alternate,i!==null&&(i.lanes|=a),Ao(n.return,a,e),r||(o=null);break e}n=i.next}}else if(l.tag===18){if(o=l.return,o===null)throw Error(L(341));o.lanes|=a,n=o.alternate,n!==null&&(n.lanes|=a),Ao(o,a,e),o=null}else o=l.child;if(o!==null)o.return=l;else for(o=l;o!==null;){if(o===e){o=null;break}if(l=o.sibling,l!==null){l.return=o.return,o=l;break}o=o.return}l=o}}function Qr(e,t,a,r){e=null;for(var l=t,n=!1;l!==null;){if(!n){if(l.flags&524288)n=!0;else if(l.flags&262144)break}if(l.tag===10){var o=l.alternate;if(o===null)throw Error(L(387));if(o=o.memoizedProps,o!==null){var i=l.type;it(l.pendingProps.value,o.value)||(e!==null?e.push(i):e=[i])}}else if(l===Ll.current){if(o=l.alternate,o===null)throw Error(L(387));o.memoizedState.memoizedState!==l.memoizedState.memoizedState&&(e!==null?e.push(Tr):e=[Tr])}l=l.return}e!==null&&Oo(t,e,a,r),t.flags|=262144}function Gl(e){for(e=e.firstContext;e!==null;){if(!it(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Qa(e){Ka=e,Xt=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Ve(e){return lm(Ka,e)}function il(e,t){return Ka===null&&Qa(e),lm(e,t)}function lm(e,t){var a=t._currentValue;if(t={context:t,memoizedValue:a,next:null},Xt===null){if(e===null)throw Error(L(308));Xt=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Xt=Xt.next=t;return a}var tx=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(a,r){e.push(r)}};this.abort=function(){t.aborted=!0,e.forEach(function(a){return a()})}},ax=Re.unstable_scheduleCallback,sx=Re.unstable_NormalPriority,ke={$$typeof:Qt,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Di(){return{controller:new tx,data:new Map,refCount:0}}function Yr(e){e.refCount--,e.refCount===0&&ax(sx,function(){e.controller.abort()})}var dr=null,Do=0,ks=0,bs=null;function rx(e,t){if(dr===null){var a=dr=[];Do=0,ks=lc(),bs={status:"pending",value:void 0,then:function(r){a.push(r)}}}return Do++,t.then(Ic,Ic),t}function Ic(){if(--Do===0&&dr!==null){bs!==null&&(bs.status="fulfilled");var e=dr;dr=null,ks=0,bs=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function lx(e,t){var a=[],r={status:"pending",value:null,reason:null,then:function(l){a.push(l)}};return e.then(function(){r.status="fulfilled",r.value=t;for(var l=0;l<a.length;l++)(0,a[l])(t)},function(l){for(r.status="rejected",r.reason=l,l=0;l<a.length;l++)(0,a[l])(void 0)}),r}var ed=Y.S;Y.S=function(e,t){typeof t=="object"&&t!==null&&typeof t.then=="function"&&rx(e,t),ed!==null&&ed(e,t)};var Ba=Ot(null);function Ui(){var e=Ba.current;return e!==null?e:ce.pooledCache}function wl(e,t){t===null?he(Ba,Ba.current):he(Ba,t.pool)}function nm(){var e=Ui();return e===null?null:{parent:ke._currentValue,pool:e}}var $r=Error(L(460)),om=Error(L(474)),vn=Error(L(542)),Uo={then:function(){}};function td(e){return e=e.status,e==="fulfilled"||e==="rejected"}function cl(){}function im(e,t,a){switch(a=e[a],a===void 0?e.push(t):a!==t&&(t.then(cl,cl),t=a),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,sd(e),e;default:if(typeof t.status=="string")t.then(cl,cl);else{if(e=ce,e!==null&&100<e.shellSuspendCounter)throw Error(L(482));e=t,e.status="pending",e.then(function(r){if(t.status==="pending"){var l=t;l.status="fulfilled",l.value=r}},function(r){if(t.status==="pending"){var l=t;l.status="rejected",l.reason=r}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,sd(e),e}throw ur=t,$r}}var ur=null;function ad(){if(ur===null)throw Error(L(459));var e=ur;return ur=null,e}function sd(e){if(e===$r||e===vn)throw Error(L(483))}var ia=!1;function Hi(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ho(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function ba(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ya(e,t,a){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,re&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,t=Bl(e),am(e,null,a),t}return yn(e,r,t,a),Bl(e)}function mr(e,t,a){if(t=t.updateQueue,t!==null&&(t=t.shared,(a&4194048)!==0)){var r=t.lanes;r&=e.pendingLanes,a|=r,t.lanes=a,Ru(e,a)}}function Xn(e,t){var a=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,a===r)){var l=null,n=null;if(a=a.firstBaseUpdate,a!==null){do{var o={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};n===null?l=n=o:n=n.next=o,a=a.next}while(a!==null);n===null?l=n=t:n=n.next=t}else l=n=t;a={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:n,shared:r.shared,callbacks:r.callbacks},e.updateQueue=a;return}e=a.lastBaseUpdate,e===null?a.firstBaseUpdate=t:e.next=t,a.lastBaseUpdate=t}var Bo=!1;function fr(){if(Bo){var e=bs;if(e!==null)throw e}}function hr(e,t,a,r){Bo=!1;var l=e.updateQueue;ia=!1;var n=l.firstBaseUpdate,o=l.lastBaseUpdate,i=l.shared.pending;if(i!==null){l.shared.pending=null;var c=i,m=c.next;c.next=null,o===null?n=m:o.next=m,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,i=u.lastBaseUpdate,i!==o&&(i===null?u.firstBaseUpdate=m:i.next=m,u.lastBaseUpdate=c))}if(n!==null){var x=l.baseState;o=0,u=m=c=null,i=n;do{var f=i.lane&-536870913,b=f!==i.lane;if(b?(ee&f)===f:(r&f)===f){f!==0&&f===ks&&(Bo=!0),u!==null&&(u=u.next={lane:0,tag:i.tag,payload:i.payload,callback:null,next:null});e:{var j=e,v=i;f=t;var S=a;switch(v.tag){case 1:if(j=v.payload,typeof j=="function"){x=j.call(S,x,f);break e}x=j;break e;case 3:j.flags=j.flags&-65537|128;case 0:if(j=v.payload,f=typeof j=="function"?j.call(S,x,f):j,f==null)break e;x=de({},x,f);break e;case 2:ia=!0}}f=i.callback,f!==null&&(e.flags|=64,b&&(e.flags|=8192),b=l.callbacks,b===null?l.callbacks=[f]:b.push(f))}else b={lane:f,tag:i.tag,payload:i.payload,callback:i.callback,next:null},u===null?(m=u=b,c=x):u=u.next=b,o|=f;if(i=i.next,i===null){if(i=l.shared.pending,i===null)break;b=i,i=b.next,b.next=null,l.lastBaseUpdate=b,l.shared.pending=null}}while(!0);u===null&&(c=x),l.baseState=c,l.firstBaseUpdate=m,l.lastBaseUpdate=u,n===null&&(l.shared.lanes=0),ka|=o,e.lanes=o,e.memoizedState=x}}function cm(e,t){if(typeof e!="function")throw Error(L(191,e));e.call(t)}function dm(e,t){var a=e.callbacks;if(a!==null)for(e.callbacks=null,e=0;e<a.length;e++)cm(a[e],t)}var Cs=Ot(null),Ql=Ot(0);function rd(e,t){e=ea,he(Ql,e),he(Cs,t),ea=e|t.baseLanes}function qo(){he(Ql,ea),he(Cs,Cs.current)}function Bi(){ea=Ql.current,Ae(Cs),Ae(Ql)}var Ea=0,W=null,ne=null,Ne=null,Yl=!1,ys=!1,Ya=!1,$l=0,_r=0,vs=null,nx=0;function ve(){throw Error(L(321))}function qi(e,t){if(t===null)return!1;for(var a=0;a<t.length&&a<e.length;a++)if(!it(e[a],t[a]))return!1;return!0}function Vi(e,t,a,r,l,n){return Ea=n,W=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Y.H=e===null||e.memoizedState===null?Vm:Gm,Ya=!1,n=a(r,l),Ya=!1,ys&&(n=mm(t,a,r,l)),um(e),n}function um(e){Y.H=Xl;var t=ne!==null&&ne.next!==null;if(Ea=0,Ne=ne=W=null,Yl=!1,_r=0,vs=null,t)throw Error(L(300));e===null||Le||(e=e.dependencies,e!==null&&Gl(e)&&(Le=!0))}function mm(e,t,a,r){W=e;var l=0;do{if(ys&&(vs=null),_r=0,ys=!1,25<=l)throw Error(L(301));if(l+=1,Ne=ne=null,e.updateQueue!=null){var n=e.updateQueue;n.lastEffect=null,n.events=null,n.stores=null,n.memoCache!=null&&(n.memoCache.index=0)}Y.H=fx,n=t(a,r)}while(ys);return n}function ox(){var e=Y.H,t=e.useState()[0];return t=typeof t.then=="function"?Xr(t):t,e=e.useState()[0],(ne!==null?ne.memoizedState:null)!==e&&(W.flags|=1024),t}function Gi(){var e=$l!==0;return $l=0,e}function Qi(e,t,a){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a}function Yi(e){if(Yl){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Yl=!1}Ea=0,Ne=ne=W=null,ys=!1,_r=$l=0,vs=null}function Ze(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ne===null?W.memoizedState=Ne=e:Ne=Ne.next=e,Ne}function Se(){if(ne===null){var e=W.alternate;e=e!==null?e.memoizedState:null}else e=ne.next;var t=Ne===null?W.memoizedState:Ne.next;if(t!==null)Ne=t,ne=e;else{if(e===null)throw W.alternate===null?Error(L(467)):Error(L(310));ne=e,e={memoizedState:ne.memoizedState,baseState:ne.baseState,baseQueue:ne.baseQueue,queue:ne.queue,next:null},Ne===null?W.memoizedState=Ne=e:Ne=Ne.next=e}return Ne}function $i(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Xr(e){var t=_r;return _r+=1,vs===null&&(vs=[]),e=im(vs,e,t),t=W,(Ne===null?t.memoizedState:Ne.next)===null&&(t=t.alternate,Y.H=t===null||t.memoizedState===null?Vm:Gm),e}function jn(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Xr(e);if(e.$$typeof===Qt)return Ve(e)}throw Error(L(438,String(e)))}function Xi(e){var t=null,a=W.updateQueue;if(a!==null&&(t=a.memoCache),t==null){var r=W.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(l){return l.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),a===null&&(a=$i(),W.updateQueue=a),a.memoCache=t,a=t.data[t.index],a===void 0)for(a=t.data[t.index]=Array(e),r=0;r<e;r++)a[r]=$f;return t.index++,a}function Ft(e,t){return typeof t=="function"?t(e):t}function Sl(e){var t=Se();return Zi(t,ne,e)}function Zi(e,t,a){var r=e.queue;if(r===null)throw Error(L(311));r.lastRenderedReducer=a;var l=e.baseQueue,n=r.pending;if(n!==null){if(l!==null){var o=l.next;l.next=n.next,n.next=o}t.baseQueue=l=n,r.pending=null}if(n=e.baseState,l===null)e.memoizedState=n;else{t=l.next;var i=o=null,c=null,m=t,u=!1;do{var x=m.lane&-536870913;if(x!==m.lane?(ee&x)===x:(Ea&x)===x){var f=m.revertLane;if(f===0)c!==null&&(c=c.next={lane:0,revertLane:0,action:m.action,hasEagerState:m.hasEagerState,eagerState:m.eagerState,next:null}),x===ks&&(u=!0);else if((Ea&f)===f){m=m.next,f===ks&&(u=!0);continue}else x={lane:0,revertLane:m.revertLane,action:m.action,hasEagerState:m.hasEagerState,eagerState:m.eagerState,next:null},c===null?(i=c=x,o=n):c=c.next=x,W.lanes|=f,ka|=f;x=m.action,Ya&&a(n,x),n=m.hasEagerState?m.eagerState:a(n,x)}else f={lane:x,revertLane:m.revertLane,action:m.action,hasEagerState:m.hasEagerState,eagerState:m.eagerState,next:null},c===null?(i=c=f,o=n):c=c.next=f,W.lanes|=x,ka|=x;m=m.next}while(m!==null&&m!==t);if(c===null?o=n:c.next=i,!it(n,e.memoizedState)&&(Le=!0,u&&(a=bs,a!==null)))throw a;e.memoizedState=n,e.baseState=o,e.baseQueue=c,r.lastRenderedState=n}return l===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Zn(e){var t=Se(),a=t.queue;if(a===null)throw Error(L(311));a.lastRenderedReducer=e;var r=a.dispatch,l=a.pending,n=t.memoizedState;if(l!==null){a.pending=null;var o=l=l.next;do n=e(n,o.action),o=o.next;while(o!==l);it(n,t.memoizedState)||(Le=!0),t.memoizedState=n,t.baseQueue===null&&(t.baseState=n),a.lastRenderedState=n}return[n,r]}function fm(e,t,a){var r=W,l=Se(),n=te;if(n){if(a===void 0)throw Error(L(407));a=a()}else a=t();var o=!it((ne||l).memoizedState,a);o&&(l.memoizedState=a,Le=!0),l=l.queue;var i=gm.bind(null,r,l,e);if(Zr(2048,8,i,[e]),l.getSnapshot!==t||o||Ne!==null&&Ne.memoizedState.tag&1){if(r.flags|=2048,Ms(9,Nn(),xm.bind(null,r,l,a,t),null),ce===null)throw Error(L(349));n||Ea&124||hm(r,t,a)}return a}function hm(e,t,a){e.flags|=16384,e={getSnapshot:t,value:a},t=W.updateQueue,t===null?(t=$i(),W.updateQueue=t,t.stores=[e]):(a=t.stores,a===null?t.stores=[e]:a.push(e))}function xm(e,t,a,r){t.value=a,t.getSnapshot=r,pm(t)&&bm(e)}function gm(e,t,a){return a(function(){pm(t)&&bm(e)})}function pm(e){var t=e.getSnapshot;e=e.value;try{var a=t();return!it(e,a)}catch{return!0}}function bm(e){var t=Hs(e,2);t!==null&&ot(t,e,2)}function Vo(e){var t=Ze();if(typeof e=="function"){var a=e;if(e=a(),Ya){fa(!0);try{a()}finally{fa(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ft,lastRenderedState:e},t}function ym(e,t,a,r){return e.baseState=a,Zi(e,ne,typeof r=="function"?r:Ft)}function ix(e,t,a,r,l){if(wn(e))throw Error(L(485));if(e=t.action,e!==null){var n={payload:l,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(o){n.listeners.push(o)}};Y.T!==null?a(!0):n.isTransition=!1,r(n),a=t.pending,a===null?(n.next=t.pending=n,vm(t,n)):(n.next=a.next,t.pending=a.next=n)}}function vm(e,t){var a=t.action,r=t.payload,l=e.state;if(t.isTransition){var n=Y.T,o={};Y.T=o;try{var i=a(l,r),c=Y.S;c!==null&&c(o,i),ld(e,t,i)}catch(m){Go(e,t,m)}finally{Y.T=n}}else try{n=a(l,r),ld(e,t,n)}catch(m){Go(e,t,m)}}function ld(e,t,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(r){nd(e,t,r)},function(r){return Go(e,t,r)}):nd(e,t,a)}function nd(e,t,a){t.status="fulfilled",t.value=a,jm(t),e.state=a,t=e.pending,t!==null&&(a=t.next,a===t?e.pending=null:(a=a.next,t.next=a,vm(e,a)))}function Go(e,t,a){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status="rejected",t.reason=a,jm(t),t=t.next;while(t!==r)}e.action=null}function jm(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Nm(e,t){return t}function od(e,t){if(te){var a=ce.formState;if(a!==null){e:{var r=W;if(te){if(be){t:{for(var l=be,n=Rt;l.nodeType!==8;){if(!n){l=null;break t}if(l=vt(l.nextSibling),l===null){l=null;break t}}n=l.data,l=n==="F!"||n==="F"?l:null}if(l){be=vt(l.nextSibling),r=l.data==="F!";break e}}Ga(r)}r=!1}r&&(t=a[0])}}return a=Ze(),a.memoizedState=a.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Nm,lastRenderedState:t},a.queue=r,a=Hm.bind(null,W,r),r.dispatch=a,r=Vo(!1),n=Pi.bind(null,W,!1,r.queue),r=Ze(),l={state:t,dispatch:null,action:e,pending:null},r.queue=l,a=ix.bind(null,W,l,n,a),l.dispatch=a,r.memoizedState=e,[t,a,!1]}function id(e){var t=Se();return wm(t,ne,e)}function wm(e,t,a){if(t=Zi(e,t,Nm)[0],e=Sl(Ft)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var r=Xr(t)}catch(o){throw o===$r?vn:o}else r=t;t=Se();var l=t.queue,n=l.dispatch;return a!==t.memoizedState&&(W.flags|=2048,Ms(9,Nn(),cx.bind(null,l,a),null)),[r,n,e]}function cx(e,t){e.action=t}function cd(e){var t=Se(),a=ne;if(a!==null)return wm(t,a,e);Se(),t=t.memoizedState,a=Se();var r=a.queue.dispatch;return a.memoizedState=e,[t,r,!1]}function Ms(e,t,a,r){return e={tag:e,create:a,deps:r,inst:t,next:null},t=W.updateQueue,t===null&&(t=$i(),W.updateQueue=t),a=t.lastEffect,a===null?t.lastEffect=e.next=e:(r=a.next,a.next=e,e.next=r,t.lastEffect=e),e}function Nn(){return{destroy:void 0,resource:void 0}}function Sm(){return Se().memoizedState}function El(e,t,a,r){var l=Ze();r=r===void 0?null:r,W.flags|=e,l.memoizedState=Ms(1|t,Nn(),a,r)}function Zr(e,t,a,r){var l=Se();r=r===void 0?null:r;var n=l.memoizedState.inst;ne!==null&&r!==null&&qi(r,ne.memoizedState.deps)?l.memoizedState=Ms(t,n,a,r):(W.flags|=e,l.memoizedState=Ms(1|t,n,a,r))}function dd(e,t){El(8390656,8,e,t)}function Em(e,t){Zr(2048,8,e,t)}function _m(e,t){return Zr(4,2,e,t)}function km(e,t){return Zr(4,4,e,t)}function Cm(e,t){if(typeof t=="function"){e=e();var a=t(e);return function(){typeof a=="function"?a():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Mm(e,t,a){a=a!=null?a.concat([e]):null,Zr(4,4,Cm.bind(null,t,e),a)}function Ji(){}function Rm(e,t){var a=Se();t=t===void 0?null:t;var r=a.memoizedState;return t!==null&&qi(t,r[1])?r[0]:(a.memoizedState=[e,t],e)}function Tm(e,t){var a=Se();t=t===void 0?null:t;var r=a.memoizedState;if(t!==null&&qi(t,r[1]))return r[0];if(r=e(),Ya){fa(!0);try{e()}finally{fa(!1)}}return a.memoizedState=[r,t],r}function Ki(e,t,a){return a===void 0||Ea&1073741824?e.memoizedState=t:(e.memoizedState=a,e=j0(),W.lanes|=e,ka|=e,a)}function zm(e,t,a,r){return it(a,t)?a:Cs.current!==null?(e=Ki(e,a,r),it(e,t)||(Le=!0),e):Ea&42?(e=j0(),W.lanes|=e,ka|=e,t):(Le=!0,e.memoizedState=a)}function Lm(e,t,a,r,l){var n=ae.p;ae.p=n!==0&&8>n?n:8;var o=Y.T,i={};Y.T=i,Pi(e,!1,t,a);try{var c=l(),m=Y.S;if(m!==null&&m(i,c),c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=lx(c,r);xr(e,t,u,nt(e))}else xr(e,t,r,nt(e))}catch(x){xr(e,t,{then:function(){},status:"rejected",reason:x},nt())}finally{ae.p=n,Y.T=o}}function dx(){}function Qo(e,t,a,r){if(e.tag!==5)throw Error(L(476));var l=Am(e).queue;Lm(e,l,t,Oa,a===null?dx:function(){return Om(e),a(r)})}function Am(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Oa,baseState:Oa,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ft,lastRenderedState:Oa},next:null};var a={};return t.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ft,lastRenderedState:a},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Om(e){var t=Am(e).next.queue;xr(e,t,{},nt())}function Wi(){return Ve(Tr)}function Dm(){return Se().memoizedState}function Um(){return Se().memoizedState}function ux(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var a=nt();e=ba(a);var r=ya(t,e,a);r!==null&&(ot(r,t,a),mr(r,t,a)),t={cache:Di()},e.payload=t;return}t=t.return}}function mx(e,t,a){var r=nt();a={lane:r,revertLane:0,action:a,hasEagerState:!1,eagerState:null,next:null},wn(e)?Bm(t,a):(a=zi(e,t,a,r),a!==null&&(ot(a,e,r),qm(a,t,r)))}function Hm(e,t,a){var r=nt();xr(e,t,a,r)}function xr(e,t,a,r){var l={lane:r,revertLane:0,action:a,hasEagerState:!1,eagerState:null,next:null};if(wn(e))Bm(t,l);else{var n=e.alternate;if(e.lanes===0&&(n===null||n.lanes===0)&&(n=t.lastRenderedReducer,n!==null))try{var o=t.lastRenderedState,i=n(o,a);if(l.hasEagerState=!0,l.eagerState=i,it(i,o))return yn(e,t,l,0),ce===null&&bn(),!1}catch{}finally{}if(a=zi(e,t,l,r),a!==null)return ot(a,e,r),qm(a,t,r),!0}return!1}function Pi(e,t,a,r){if(r={lane:2,revertLane:lc(),action:r,hasEagerState:!1,eagerState:null,next:null},wn(e)){if(t)throw Error(L(479))}else t=zi(e,a,r,2),t!==null&&ot(t,e,2)}function wn(e){var t=e.alternate;return e===W||t!==null&&t===W}function Bm(e,t){ys=Yl=!0;var a=e.pending;a===null?t.next=t:(t.next=a.next,a.next=t),e.pending=t}function qm(e,t,a){if(a&4194048){var r=t.lanes;r&=e.pendingLanes,a|=r,t.lanes=a,Ru(e,a)}}var Xl={readContext:Ve,use:jn,useCallback:ve,useContext:ve,useEffect:ve,useImperativeHandle:ve,useLayoutEffect:ve,useInsertionEffect:ve,useMemo:ve,useReducer:ve,useRef:ve,useState:ve,useDebugValue:ve,useDeferredValue:ve,useTransition:ve,useSyncExternalStore:ve,useId:ve,useHostTransitionStatus:ve,useFormState:ve,useActionState:ve,useOptimistic:ve,useMemoCache:ve,useCacheRefresh:ve},Vm={readContext:Ve,use:jn,useCallback:function(e,t){return Ze().memoizedState=[e,t===void 0?null:t],e},useContext:Ve,useEffect:dd,useImperativeHandle:function(e,t,a){a=a!=null?a.concat([e]):null,El(4194308,4,Cm.bind(null,t,e),a)},useLayoutEffect:function(e,t){return El(4194308,4,e,t)},useInsertionEffect:function(e,t){El(4,2,e,t)},useMemo:function(e,t){var a=Ze();t=t===void 0?null:t;var r=e();if(Ya){fa(!0);try{e()}finally{fa(!1)}}return a.memoizedState=[r,t],r},useReducer:function(e,t,a){var r=Ze();if(a!==void 0){var l=a(t);if(Ya){fa(!0);try{a(t)}finally{fa(!1)}}}else l=t;return r.memoizedState=r.baseState=l,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:l},r.queue=e,e=e.dispatch=mx.bind(null,W,e),[r.memoizedState,e]},useRef:function(e){var t=Ze();return e={current:e},t.memoizedState=e},useState:function(e){e=Vo(e);var t=e.queue,a=Hm.bind(null,W,t);return t.dispatch=a,[e.memoizedState,a]},useDebugValue:Ji,useDeferredValue:function(e,t){var a=Ze();return Ki(a,e,t)},useTransition:function(){var e=Vo(!1);return e=Lm.bind(null,W,e.queue,!0,!1),Ze().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,a){var r=W,l=Ze();if(te){if(a===void 0)throw Error(L(407));a=a()}else{if(a=t(),ce===null)throw Error(L(349));ee&124||hm(r,t,a)}l.memoizedState=a;var n={value:a,getSnapshot:t};return l.queue=n,dd(gm.bind(null,r,n,e),[e]),r.flags|=2048,Ms(9,Nn(),xm.bind(null,r,n,a,t),null),a},useId:function(){var e=Ze(),t=ce.identifierPrefix;if(te){var a=$t,r=Yt;a=(r&~(1<<32-lt(r)-1)).toString(32)+a,t="«"+t+"R"+a,a=$l++,0<a&&(t+="H"+a.toString(32)),t+="»"}else a=nx++,t="«"+t+"r"+a.toString(32)+"»";return e.memoizedState=t},useHostTransitionStatus:Wi,useFormState:od,useActionState:od,useOptimistic:function(e){var t=Ze();t.memoizedState=t.baseState=e;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=a,t=Pi.bind(null,W,!0,a),a.dispatch=t,[e,t]},useMemoCache:Xi,useCacheRefresh:function(){return Ze().memoizedState=ux.bind(null,W)}},Gm={readContext:Ve,use:jn,useCallback:Rm,useContext:Ve,useEffect:Em,useImperativeHandle:Mm,useInsertionEffect:_m,useLayoutEffect:km,useMemo:Tm,useReducer:Sl,useRef:Sm,useState:function(){return Sl(Ft)},useDebugValue:Ji,useDeferredValue:function(e,t){var a=Se();return zm(a,ne.memoizedState,e,t)},useTransition:function(){var e=Sl(Ft)[0],t=Se().memoizedState;return[typeof e=="boolean"?e:Xr(e),t]},useSyncExternalStore:fm,useId:Dm,useHostTransitionStatus:Wi,useFormState:id,useActionState:id,useOptimistic:function(e,t){var a=Se();return ym(a,ne,e,t)},useMemoCache:Xi,useCacheRefresh:Um},fx={readContext:Ve,use:jn,useCallback:Rm,useContext:Ve,useEffect:Em,useImperativeHandle:Mm,useInsertionEffect:_m,useLayoutEffect:km,useMemo:Tm,useReducer:Zn,useRef:Sm,useState:function(){return Zn(Ft)},useDebugValue:Ji,useDeferredValue:function(e,t){var a=Se();return ne===null?Ki(a,e,t):zm(a,ne.memoizedState,e,t)},useTransition:function(){var e=Zn(Ft)[0],t=Se().memoizedState;return[typeof e=="boolean"?e:Xr(e),t]},useSyncExternalStore:fm,useId:Dm,useHostTransitionStatus:Wi,useFormState:cd,useActionState:cd,useOptimistic:function(e,t){var a=Se();return ne!==null?ym(a,ne,e,t):(a.baseState=e,[e,a.queue.dispatch])},useMemoCache:Xi,useCacheRefresh:Um},js=null,kr=0;function dl(e){var t=kr;return kr+=1,js===null&&(js=[]),im(js,e,t)}function Ws(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function ul(e,t){throw t.$$typeof===Qf?Error(L(525)):(e=Object.prototype.toString.call(t),Error(L(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function ud(e){var t=e._init;return t(e._payload)}function Qm(e){function t(h,d){if(e){var p=h.deletions;p===null?(h.deletions=[d],h.flags|=16):p.push(d)}}function a(h,d){if(!e)return null;for(;d!==null;)t(h,d),d=d.sibling;return null}function r(h){for(var d=new Map;h!==null;)h.key!==null?d.set(h.key,h):d.set(h.index,h),h=h.sibling;return d}function l(h,d){return h=Jt(h,d),h.index=0,h.sibling=null,h}function n(h,d,p){return h.index=p,e?(p=h.alternate,p!==null?(p=p.index,p<d?(h.flags|=67108866,d):p):(h.flags|=67108866,d)):(h.flags|=1048576,d)}function o(h){return e&&h.alternate===null&&(h.flags|=67108866),h}function i(h,d,p,y){return d===null||d.tag!==6?(d=Yn(p,h.mode,y),d.return=h,d):(d=l(d,p),d.return=h,d)}function c(h,d,p,y){var E=p.type;return E===ss?u(h,d,p.props.children,y,p.key):d!==null&&(d.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===oa&&ud(E)===d.type)?(d=l(d,p.props),Ws(d,p),d.return=h,d):(d=Nl(p.type,p.key,p.props,null,h.mode,y),Ws(d,p),d.return=h,d)}function m(h,d,p,y){return d===null||d.tag!==4||d.stateNode.containerInfo!==p.containerInfo||d.stateNode.implementation!==p.implementation?(d=$n(p,h.mode,y),d.return=h,d):(d=l(d,p.children||[]),d.return=h,d)}function u(h,d,p,y,E){return d===null||d.tag!==7?(d=Da(p,h.mode,y,E),d.return=h,d):(d=l(d,p),d.return=h,d)}function x(h,d,p){if(typeof d=="string"&&d!==""||typeof d=="number"||typeof d=="bigint")return d=Yn(""+d,h.mode,p),d.return=h,d;if(typeof d=="object"&&d!==null){switch(d.$$typeof){case sl:return p=Nl(d.type,d.key,d.props,null,h.mode,p),Ws(p,d),p.return=h,p;case ar:return d=$n(d,h.mode,p),d.return=h,d;case oa:var y=d._init;return d=y(d._payload),x(h,d,p)}if(sr(d)||Xs(d))return d=Da(d,h.mode,p,null),d.return=h,d;if(typeof d.then=="function")return x(h,dl(d),p);if(d.$$typeof===Qt)return x(h,il(h,d),p);ul(h,d)}return null}function f(h,d,p,y){var E=d!==null?d.key:null;if(typeof p=="string"&&p!==""||typeof p=="number"||typeof p=="bigint")return E!==null?null:i(h,d,""+p,y);if(typeof p=="object"&&p!==null){switch(p.$$typeof){case sl:return p.key===E?c(h,d,p,y):null;case ar:return p.key===E?m(h,d,p,y):null;case oa:return E=p._init,p=E(p._payload),f(h,d,p,y)}if(sr(p)||Xs(p))return E!==null?null:u(h,d,p,y,null);if(typeof p.then=="function")return f(h,d,dl(p),y);if(p.$$typeof===Qt)return f(h,d,il(h,p),y);ul(h,p)}return null}function b(h,d,p,y,E){if(typeof y=="string"&&y!==""||typeof y=="number"||typeof y=="bigint")return h=h.get(p)||null,i(d,h,""+y,E);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case sl:return h=h.get(y.key===null?p:y.key)||null,c(d,h,y,E);case ar:return h=h.get(y.key===null?p:y.key)||null,m(d,h,y,E);case oa:var w=y._init;return y=w(y._payload),b(h,d,p,y,E)}if(sr(y)||Xs(y))return h=h.get(p)||null,u(d,h,y,E,null);if(typeof y.then=="function")return b(h,d,p,dl(y),E);if(y.$$typeof===Qt)return b(h,d,p,il(d,y),E);ul(d,y)}return null}function j(h,d,p,y){for(var E=null,w=null,N=d,R=d=0,z=null;N!==null&&R<p.length;R++){N.index>R?(z=N,N=null):z=N.sibling;var C=f(h,N,p[R],y);if(C===null){N===null&&(N=z);break}e&&N&&C.alternate===null&&t(h,N),d=n(C,d,R),w===null?E=C:w.sibling=C,w=C,N=z}if(R===p.length)return a(h,N),te&&La(h,R),E;if(N===null){for(;R<p.length;R++)N=x(h,p[R],y),N!==null&&(d=n(N,d,R),w===null?E=N:w.sibling=N,w=N);return te&&La(h,R),E}for(N=r(N);R<p.length;R++)z=b(N,h,R,p[R],y),z!==null&&(e&&z.alternate!==null&&N.delete(z.key===null?R:z.key),d=n(z,d,R),w===null?E=z:w.sibling=z,w=z);return e&&N.forEach(function(k){return t(h,k)}),te&&La(h,R),E}function v(h,d,p,y){if(p==null)throw Error(L(151));for(var E=null,w=null,N=d,R=d=0,z=null,C=p.next();N!==null&&!C.done;R++,C=p.next()){N.index>R?(z=N,N=null):z=N.sibling;var k=f(h,N,C.value,y);if(k===null){N===null&&(N=z);break}e&&N&&k.alternate===null&&t(h,N),d=n(k,d,R),w===null?E=k:w.sibling=k,w=k,N=z}if(C.done)return a(h,N),te&&La(h,R),E;if(N===null){for(;!C.done;R++,C=p.next())C=x(h,C.value,y),C!==null&&(d=n(C,d,R),w===null?E=C:w.sibling=C,w=C);return te&&La(h,R),E}for(N=r(N);!C.done;R++,C=p.next())C=b(N,h,R,C.value,y),C!==null&&(e&&C.alternate!==null&&N.delete(C.key===null?R:C.key),d=n(C,d,R),w===null?E=C:w.sibling=C,w=C);return e&&N.forEach(function(_){return t(h,_)}),te&&La(h,R),E}function S(h,d,p,y){if(typeof p=="object"&&p!==null&&p.type===ss&&p.key===null&&(p=p.props.children),typeof p=="object"&&p!==null){switch(p.$$typeof){case sl:e:{for(var E=p.key;d!==null;){if(d.key===E){if(E=p.type,E===ss){if(d.tag===7){a(h,d.sibling),y=l(d,p.props.children),y.return=h,h=y;break e}}else if(d.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===oa&&ud(E)===d.type){a(h,d.sibling),y=l(d,p.props),Ws(y,p),y.return=h,h=y;break e}a(h,d);break}else t(h,d);d=d.sibling}p.type===ss?(y=Da(p.props.children,h.mode,y,p.key),y.return=h,h=y):(y=Nl(p.type,p.key,p.props,null,h.mode,y),Ws(y,p),y.return=h,h=y)}return o(h);case ar:e:{for(E=p.key;d!==null;){if(d.key===E)if(d.tag===4&&d.stateNode.containerInfo===p.containerInfo&&d.stateNode.implementation===p.implementation){a(h,d.sibling),y=l(d,p.children||[]),y.return=h,h=y;break e}else{a(h,d);break}else t(h,d);d=d.sibling}y=$n(p,h.mode,y),y.return=h,h=y}return o(h);case oa:return E=p._init,p=E(p._payload),S(h,d,p,y)}if(sr(p))return j(h,d,p,y);if(Xs(p)){if(E=Xs(p),typeof E!="function")throw Error(L(150));return p=E.call(p),v(h,d,p,y)}if(typeof p.then=="function")return S(h,d,dl(p),y);if(p.$$typeof===Qt)return S(h,d,il(h,p),y);ul(h,p)}return typeof p=="string"&&p!==""||typeof p=="number"||typeof p=="bigint"?(p=""+p,d!==null&&d.tag===6?(a(h,d.sibling),y=l(d,p),y.return=h,h=y):(a(h,d),y=Yn(p,h.mode,y),y.return=h,h=y),o(h)):a(h,d)}return function(h,d,p,y){try{kr=0;var E=S(h,d,p,y);return js=null,E}catch(N){if(N===$r||N===vn)throw N;var w=st(29,N,null,h.mode);return w.lanes=y,w.return=h,w}finally{}}}var Rs=Qm(!0),Ym=Qm(!1),pt=Ot(null),At=null;function da(e){var t=e.alternate;he(Ce,Ce.current&1),he(pt,e),At===null&&(t===null||Cs.current!==null||t.memoizedState!==null)&&(At=e)}function $m(e){if(e.tag===22){if(he(Ce,Ce.current),he(pt,e),At===null){var t=e.alternate;t!==null&&t.memoizedState!==null&&(At=e)}}else ua()}function ua(){he(Ce,Ce.current),he(pt,pt.current)}function Zt(e){Ae(pt),At===e&&(At=null),Ae(Ce)}var Ce=Ot(0);function Zl(e){for(var t=e;t!==null;){if(t.tag===13){var a=t.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||a.data==="$?"||ni(a)))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}function Jn(e,t,a,r){t=e.memoizedState,a=a(r,t),a=a==null?t:de({},t,a),e.memoizedState=a,e.lanes===0&&(e.updateQueue.baseState=a)}var Yo={enqueueSetState:function(e,t,a){e=e._reactInternals;var r=nt(),l=ba(r);l.payload=t,a!=null&&(l.callback=a),t=ya(e,l,r),t!==null&&(ot(t,e,r),mr(t,e,r))},enqueueReplaceState:function(e,t,a){e=e._reactInternals;var r=nt(),l=ba(r);l.tag=1,l.payload=t,a!=null&&(l.callback=a),t=ya(e,l,r),t!==null&&(ot(t,e,r),mr(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var a=nt(),r=ba(a);r.tag=2,t!=null&&(r.callback=t),t=ya(e,r,a),t!==null&&(ot(t,e,a),mr(t,e,a))}};function md(e,t,a,r,l,n,o){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,n,o):t.prototype&&t.prototype.isPureReactComponent?!Sr(a,r)||!Sr(l,n):!0}function fd(e,t,a,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(a,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(a,r),t.state!==e&&Yo.enqueueReplaceState(t,t.state,null)}function $a(e,t){var a=t;if("ref"in t){a={};for(var r in t)r!=="ref"&&(a[r]=t[r])}if(e=e.defaultProps){a===t&&(a=de({},a));for(var l in e)a[l]===void 0&&(a[l]=e[l])}return a}var Jl=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)};function Xm(e){Jl(e)}function Zm(e){console.error(e)}function Jm(e){Jl(e)}function Kl(e,t){try{var a=e.onUncaughtError;a(t.value,{componentStack:t.stack})}catch(r){setTimeout(function(){throw r})}}function hd(e,t,a){try{var r=e.onCaughtError;r(a.value,{componentStack:a.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(l){setTimeout(function(){throw l})}}function $o(e,t,a){return a=ba(a),a.tag=3,a.payload={element:null},a.callback=function(){Kl(e,t)},a}function Km(e){return e=ba(e),e.tag=3,e}function Wm(e,t,a,r){var l=a.type.getDerivedStateFromError;if(typeof l=="function"){var n=r.value;e.payload=function(){return l(n)},e.callback=function(){hd(t,a,r)}}var o=a.stateNode;o!==null&&typeof o.componentDidCatch=="function"&&(e.callback=function(){hd(t,a,r),typeof l!="function"&&(va===null?va=new Set([this]):va.add(this));var i=r.stack;this.componentDidCatch(r.value,{componentStack:i!==null?i:""})})}function hx(e,t,a,r,l){if(a.flags|=32768,r!==null&&typeof r=="object"&&typeof r.then=="function"){if(t=a.alternate,t!==null&&Qr(t,a,l,!0),a=pt.current,a!==null){switch(a.tag){case 13:return At===null?Io():a.alternate===null&&ye===0&&(ye=3),a.flags&=-257,a.flags|=65536,a.lanes=l,r===Uo?a.flags|=16384:(t=a.updateQueue,t===null?a.updateQueue=new Set([r]):t.add(r),lo(e,r,l)),!1;case 22:return a.flags|=65536,r===Uo?a.flags|=16384:(t=a.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},a.updateQueue=t):(a=t.retryQueue,a===null?t.retryQueue=new Set([r]):a.add(r)),lo(e,r,l)),!1}throw Error(L(435,a.tag))}return lo(e,r,l),Io(),!1}if(te)return t=pt.current,t!==null?(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=l,r!==zo&&(e=Error(L(422),{cause:r}),Er(xt(e,a)))):(r!==zo&&(t=Error(L(423),{cause:r}),Er(xt(t,a))),e=e.current.alternate,e.flags|=65536,l&=-l,e.lanes|=l,r=xt(r,a),l=$o(e.stateNode,r,l),Xn(e,l),ye!==4&&(ye=2)),!1;var n=Error(L(520),{cause:r});if(n=xt(n,a),br===null?br=[n]:br.push(n),ye!==4&&(ye=2),t===null)return!0;r=xt(r,a),a=t;do{switch(a.tag){case 3:return a.flags|=65536,e=l&-l,a.lanes|=e,e=$o(a.stateNode,r,e),Xn(a,e),!1;case 1:if(t=a.type,n=a.stateNode,(a.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||n!==null&&typeof n.componentDidCatch=="function"&&(va===null||!va.has(n))))return a.flags|=65536,l&=-l,a.lanes|=l,l=Km(l),Wm(l,e,a,r),Xn(a,l),!1}a=a.return}while(a!==null);return!1}var Pm=Error(L(461)),Le=!1;function Oe(e,t,a,r){t.child=e===null?Ym(t,null,a,r):Rs(t,e.child,a,r)}function xd(e,t,a,r,l){a=a.render;var n=t.ref;if("ref"in r){var o={};for(var i in r)i!=="ref"&&(o[i]=r[i])}else o=r;return Qa(t),r=Vi(e,t,a,o,n,l),i=Gi(),e!==null&&!Le?(Qi(e,t,l),It(e,t,l)):(te&&i&&Ai(t),t.flags|=1,Oe(e,t,r,l),t.child)}function gd(e,t,a,r,l){if(e===null){var n=a.type;return typeof n=="function"&&!Li(n)&&n.defaultProps===void 0&&a.compare===null?(t.tag=15,t.type=n,Fm(e,t,n,r,l)):(e=Nl(a.type,null,r,t,t.mode,l),e.ref=t.ref,e.return=t,t.child=e)}if(n=e.child,!Fi(e,l)){var o=n.memoizedProps;if(a=a.compare,a=a!==null?a:Sr,a(o,r)&&e.ref===t.ref)return It(e,t,l)}return t.flags|=1,e=Jt(n,r),e.ref=t.ref,e.return=t,t.child=e}function Fm(e,t,a,r,l){if(e!==null){var n=e.memoizedProps;if(Sr(n,r)&&e.ref===t.ref)if(Le=!1,t.pendingProps=r=n,Fi(e,l))e.flags&131072&&(Le=!0);else return t.lanes=e.lanes,It(e,t,l)}return Xo(e,t,a,r,l)}function Im(e,t,a){var r=t.pendingProps,l=r.children,n=e!==null?e.memoizedState:null;if(r.mode==="hidden"){if(t.flags&128){if(r=n!==null?n.baseLanes|a:a,e!==null){for(l=t.child=e.child,n=0;l!==null;)n=n|l.lanes|l.childLanes,l=l.sibling;t.childLanes=n&~r}else t.childLanes=0,t.child=null;return pd(e,t,r,a)}if(a&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&wl(t,n!==null?n.cachePool:null),n!==null?rd(t,n):qo(),$m(t);else return t.lanes=t.childLanes=536870912,pd(e,t,n!==null?n.baseLanes|a:a,a)}else n!==null?(wl(t,n.cachePool),rd(t,n),ua(),t.memoizedState=null):(e!==null&&wl(t,null),qo(),ua());return Oe(e,t,l,a),t.child}function pd(e,t,a,r){var l=Ui();return l=l===null?null:{parent:ke._currentValue,pool:l},t.memoizedState={baseLanes:a,cachePool:l},e!==null&&wl(t,null),qo(),$m(t),e!==null&&Qr(e,t,r,!0),null}function _l(e,t){var a=t.ref;if(a===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(L(284));(e===null||e.ref!==a)&&(t.flags|=4194816)}}function Xo(e,t,a,r,l){return Qa(t),a=Vi(e,t,a,r,void 0,l),r=Gi(),e!==null&&!Le?(Qi(e,t,l),It(e,t,l)):(te&&r&&Ai(t),t.flags|=1,Oe(e,t,a,l),t.child)}function bd(e,t,a,r,l,n){return Qa(t),t.updateQueue=null,a=mm(t,r,a,l),um(e),r=Gi(),e!==null&&!Le?(Qi(e,t,n),It(e,t,n)):(te&&r&&Ai(t),t.flags|=1,Oe(e,t,a,n),t.child)}function yd(e,t,a,r,l){if(Qa(t),t.stateNode===null){var n=us,o=a.contextType;typeof o=="object"&&o!==null&&(n=Ve(o)),n=new a(r,n),t.memoizedState=n.state!==null&&n.state!==void 0?n.state:null,n.updater=Yo,t.stateNode=n,n._reactInternals=t,n=t.stateNode,n.props=r,n.state=t.memoizedState,n.refs={},Hi(t),o=a.contextType,n.context=typeof o=="object"&&o!==null?Ve(o):us,n.state=t.memoizedState,o=a.getDerivedStateFromProps,typeof o=="function"&&(Jn(t,a,o,r),n.state=t.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof n.getSnapshotBeforeUpdate=="function"||typeof n.UNSAFE_componentWillMount!="function"&&typeof n.componentWillMount!="function"||(o=n.state,typeof n.componentWillMount=="function"&&n.componentWillMount(),typeof n.UNSAFE_componentWillMount=="function"&&n.UNSAFE_componentWillMount(),o!==n.state&&Yo.enqueueReplaceState(n,n.state,null),hr(t,r,n,l),fr(),n.state=t.memoizedState),typeof n.componentDidMount=="function"&&(t.flags|=4194308),r=!0}else if(e===null){n=t.stateNode;var i=t.memoizedProps,c=$a(a,i);n.props=c;var m=n.context,u=a.contextType;o=us,typeof u=="object"&&u!==null&&(o=Ve(u));var x=a.getDerivedStateFromProps;u=typeof x=="function"||typeof n.getSnapshotBeforeUpdate=="function",i=t.pendingProps!==i,u||typeof n.UNSAFE_componentWillReceiveProps!="function"&&typeof n.componentWillReceiveProps!="function"||(i||m!==o)&&fd(t,n,r,o),ia=!1;var f=t.memoizedState;n.state=f,hr(t,r,n,l),fr(),m=t.memoizedState,i||f!==m||ia?(typeof x=="function"&&(Jn(t,a,x,r),m=t.memoizedState),(c=ia||md(t,a,c,r,f,m,o))?(u||typeof n.UNSAFE_componentWillMount!="function"&&typeof n.componentWillMount!="function"||(typeof n.componentWillMount=="function"&&n.componentWillMount(),typeof n.UNSAFE_componentWillMount=="function"&&n.UNSAFE_componentWillMount()),typeof n.componentDidMount=="function"&&(t.flags|=4194308)):(typeof n.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=m),n.props=r,n.state=m,n.context=o,r=c):(typeof n.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{n=t.stateNode,Ho(e,t),o=t.memoizedProps,u=$a(a,o),n.props=u,x=t.pendingProps,f=n.context,m=a.contextType,c=us,typeof m=="object"&&m!==null&&(c=Ve(m)),i=a.getDerivedStateFromProps,(m=typeof i=="function"||typeof n.getSnapshotBeforeUpdate=="function")||typeof n.UNSAFE_componentWillReceiveProps!="function"&&typeof n.componentWillReceiveProps!="function"||(o!==x||f!==c)&&fd(t,n,r,c),ia=!1,f=t.memoizedState,n.state=f,hr(t,r,n,l),fr();var b=t.memoizedState;o!==x||f!==b||ia||e!==null&&e.dependencies!==null&&Gl(e.dependencies)?(typeof i=="function"&&(Jn(t,a,i,r),b=t.memoizedState),(u=ia||md(t,a,u,r,f,b,c)||e!==null&&e.dependencies!==null&&Gl(e.dependencies))?(m||typeof n.UNSAFE_componentWillUpdate!="function"&&typeof n.componentWillUpdate!="function"||(typeof n.componentWillUpdate=="function"&&n.componentWillUpdate(r,b,c),typeof n.UNSAFE_componentWillUpdate=="function"&&n.UNSAFE_componentWillUpdate(r,b,c)),typeof n.componentDidUpdate=="function"&&(t.flags|=4),typeof n.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof n.componentDidUpdate!="function"||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof n.getSnapshotBeforeUpdate!="function"||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=b),n.props=r,n.state=b,n.context=c,r=u):(typeof n.componentDidUpdate!="function"||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof n.getSnapshotBeforeUpdate!="function"||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return n=r,_l(e,t),r=(t.flags&128)!==0,n||r?(n=t.stateNode,a=r&&typeof a.getDerivedStateFromError!="function"?null:n.render(),t.flags|=1,e!==null&&r?(t.child=Rs(t,e.child,null,l),t.child=Rs(t,null,a,l)):Oe(e,t,a,l),t.memoizedState=n.state,e=t.child):e=It(e,t,l),e}function vd(e,t,a,r){return Gr(),t.flags|=256,Oe(e,t,a,r),t.child}var Kn={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Wn(e){return{baseLanes:e,cachePool:nm()}}function Pn(e,t,a){return e=e!==null?e.childLanes&~a:0,t&&(e|=gt),e}function e0(e,t,a){var r=t.pendingProps,l=!1,n=(t.flags&128)!==0,o;if((o=n)||(o=e!==null&&e.memoizedState===null?!1:(Ce.current&2)!==0),o&&(l=!0,t.flags&=-129),o=(t.flags&32)!==0,t.flags&=-33,e===null){if(te){if(l?da(t):ua(),te){var i=be,c;if(c=i){e:{for(c=i,i=Rt;c.nodeType!==8;){if(!i){i=null;break e}if(c=vt(c.nextSibling),c===null){i=null;break e}}i=c}i!==null?(t.memoizedState={dehydrated:i,treeContext:Ua!==null?{id:Yt,overflow:$t}:null,retryLane:536870912,hydrationErrors:null},c=st(18,null,null,0),c.stateNode=i,c.return=t,t.child=c,Ye=t,be=null,c=!0):c=!1}c||Ga(t)}if(i=t.memoizedState,i!==null&&(i=i.dehydrated,i!==null))return ni(i)?t.lanes=32:t.lanes=536870912,null;Zt(t)}return i=r.children,r=r.fallback,l?(ua(),l=t.mode,i=Wl({mode:"hidden",children:i},l),r=Da(r,l,a,null),i.return=t,r.return=t,i.sibling=r,t.child=i,l=t.child,l.memoizedState=Wn(a),l.childLanes=Pn(e,o,a),t.memoizedState=Kn,r):(da(t),Zo(t,i))}if(c=e.memoizedState,c!==null&&(i=c.dehydrated,i!==null)){if(n)t.flags&256?(da(t),t.flags&=-257,t=Fn(e,t,a)):t.memoizedState!==null?(ua(),t.child=e.child,t.flags|=128,t=null):(ua(),l=r.fallback,i=t.mode,r=Wl({mode:"visible",children:r.children},i),l=Da(l,i,a,null),l.flags|=2,r.return=t,l.return=t,r.sibling=l,t.child=r,Rs(t,e.child,null,a),r=t.child,r.memoizedState=Wn(a),r.childLanes=Pn(e,o,a),t.memoizedState=Kn,t=l);else if(da(t),ni(i)){if(o=i.nextSibling&&i.nextSibling.dataset,o)var m=o.dgst;o=m,r=Error(L(419)),r.stack="",r.digest=o,Er({value:r,source:null,stack:null}),t=Fn(e,t,a)}else if(Le||Qr(e,t,a,!1),o=(a&e.childLanes)!==0,Le||o){if(o=ce,o!==null&&(r=a&-a,r=r&42?1:Ni(r),r=r&(o.suspendedLanes|a)?0:r,r!==0&&r!==c.retryLane))throw c.retryLane=r,Hs(e,r),ot(o,e,r),Pm;i.data==="$?"||Io(),t=Fn(e,t,a)}else i.data==="$?"?(t.flags|=192,t.child=e.child,t=null):(e=c.treeContext,be=vt(i.nextSibling),Ye=t,te=!0,Ha=null,Rt=!1,e!==null&&(mt[ft++]=Yt,mt[ft++]=$t,mt[ft++]=Ua,Yt=e.id,$t=e.overflow,Ua=t),t=Zo(t,r.children),t.flags|=4096);return t}return l?(ua(),l=r.fallback,i=t.mode,c=e.child,m=c.sibling,r=Jt(c,{mode:"hidden",children:r.children}),r.subtreeFlags=c.subtreeFlags&65011712,m!==null?l=Jt(m,l):(l=Da(l,i,a,null),l.flags|=2),l.return=t,r.return=t,r.sibling=l,t.child=r,r=l,l=t.child,i=e.child.memoizedState,i===null?i=Wn(a):(c=i.cachePool,c!==null?(m=ke._currentValue,c=c.parent!==m?{parent:m,pool:m}:c):c=nm(),i={baseLanes:i.baseLanes|a,cachePool:c}),l.memoizedState=i,l.childLanes=Pn(e,o,a),t.memoizedState=Kn,r):(da(t),a=e.child,e=a.sibling,a=Jt(a,{mode:"visible",children:r.children}),a.return=t,a.sibling=null,e!==null&&(o=t.deletions,o===null?(t.deletions=[e],t.flags|=16):o.push(e)),t.child=a,t.memoizedState=null,a)}function Zo(e,t){return t=Wl({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function Wl(e,t){return e=st(22,e,null,t),e.lanes=0,e.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null},e}function Fn(e,t,a){return Rs(t,e.child,null,a),e=Zo(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function jd(e,t,a){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ao(e.return,t,a)}function In(e,t,a,r,l){var n=e.memoizedState;n===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:a,tailMode:l}:(n.isBackwards=t,n.rendering=null,n.renderingStartTime=0,n.last=r,n.tail=a,n.tailMode=l)}function t0(e,t,a){var r=t.pendingProps,l=r.revealOrder,n=r.tail;if(Oe(e,t,r.children,a),r=Ce.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&jd(e,a,t);else if(e.tag===19)jd(e,a,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}switch(he(Ce,r),l){case"forwards":for(a=t.child,l=null;a!==null;)e=a.alternate,e!==null&&Zl(e)===null&&(l=a),a=a.sibling;a=l,a===null?(l=t.child,t.child=null):(l=a.sibling,a.sibling=null),In(t,!1,l,a,n);break;case"backwards":for(a=null,l=t.child,t.child=null;l!==null;){if(e=l.alternate,e!==null&&Zl(e)===null){t.child=l;break}e=l.sibling,l.sibling=a,a=l,l=e}In(t,!0,a,null,n);break;case"together":In(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function It(e,t,a){if(e!==null&&(t.dependencies=e.dependencies),ka|=t.lanes,!(a&t.childLanes))if(e!==null){if(Qr(e,t,a,!1),(a&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(L(153));if(t.child!==null){for(e=t.child,a=Jt(e,e.pendingProps),t.child=a,a.return=t;e.sibling!==null;)e=e.sibling,a=a.sibling=Jt(e,e.pendingProps),a.return=t;a.sibling=null}return t.child}function Fi(e,t){return e.lanes&t?!0:(e=e.dependencies,!!(e!==null&&Gl(e)))}function xx(e,t,a){switch(t.tag){case 3:Al(t,t.stateNode.containerInfo),ca(t,ke,e.memoizedState.cache),Gr();break;case 27:case 5:No(t);break;case 4:Al(t,t.stateNode.containerInfo);break;case 10:ca(t,t.type,t.memoizedProps.value);break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated!==null?(da(t),t.flags|=128,null):a&t.child.childLanes?e0(e,t,a):(da(t),e=It(e,t,a),e!==null?e.sibling:null);da(t);break;case 19:var l=(e.flags&128)!==0;if(r=(a&t.childLanes)!==0,r||(Qr(e,t,a,!1),r=(a&t.childLanes)!==0),l){if(r)return t0(e,t,a);t.flags|=128}if(l=t.memoizedState,l!==null&&(l.rendering=null,l.tail=null,l.lastEffect=null),he(Ce,Ce.current),r)break;return null;case 22:case 23:return t.lanes=0,Im(e,t,a);case 24:ca(t,ke,e.memoizedState.cache)}return It(e,t,a)}function a0(e,t,a){if(e!==null)if(e.memoizedProps!==t.pendingProps)Le=!0;else{if(!Fi(e,a)&&!(t.flags&128))return Le=!1,xx(e,t,a);Le=!!(e.flags&131072)}else Le=!1,te&&t.flags&1048576&&rm(t,Vl,t.index);switch(t.lanes=0,t.tag){case 16:e:{e=t.pendingProps;var r=t.elementType,l=r._init;if(r=l(r._payload),t.type=r,typeof r=="function")Li(r)?(e=$a(r,e),t.tag=1,t=yd(null,t,r,e,a)):(t.tag=0,t=Xo(null,t,r,e,a));else{if(r!=null){if(l=r.$$typeof,l===yi){t.tag=11,t=xd(null,t,r,e,a);break e}else if(l===vi){t.tag=14,t=gd(null,t,r,e,a);break e}}throw t=vo(r)||r,Error(L(306,t,""))}}return t;case 0:return Xo(e,t,t.type,t.pendingProps,a);case 1:return r=t.type,l=$a(r,t.pendingProps),yd(e,t,r,l,a);case 3:e:{if(Al(t,t.stateNode.containerInfo),e===null)throw Error(L(387));r=t.pendingProps;var n=t.memoizedState;l=n.element,Ho(e,t),hr(t,r,null,a);var o=t.memoizedState;if(r=o.cache,ca(t,ke,r),r!==n.cache&&Oo(t,[ke],a,!0),fr(),r=o.element,n.isDehydrated)if(n={element:r,isDehydrated:!1,cache:o.cache},t.updateQueue.baseState=n,t.memoizedState=n,t.flags&256){t=vd(e,t,r,a);break e}else if(r!==l){l=xt(Error(L(424)),t),Er(l),t=vd(e,t,r,a);break e}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(be=vt(e.firstChild),Ye=t,te=!0,Ha=null,Rt=!0,a=Ym(t,null,r,a),t.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(Gr(),r===l){t=It(e,t,a);break e}Oe(e,t,r,a)}t=t.child}return t;case 26:return _l(e,t),e===null?(a=Hd(t.type,null,t.pendingProps,null))?t.memoizedState=a:te||(a=t.type,e=t.pendingProps,r=sn(pa.current).createElement(a),r[qe]=t,r[Pe]=e,Be(r,a,e),ze(r),t.stateNode=r):t.memoizedState=Hd(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return No(t),e===null&&te&&(r=t.stateNode=G0(t.type,t.pendingProps,pa.current),Ye=t,Rt=!0,l=be,Ma(t.type)?(oi=l,be=vt(r.firstChild)):be=l),Oe(e,t,t.pendingProps.children,a),_l(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&te&&((l=r=be)&&(r=Qx(r,t.type,t.pendingProps,Rt),r!==null?(t.stateNode=r,Ye=t,be=vt(r.firstChild),Rt=!1,l=!0):l=!1),l||Ga(t)),No(t),l=t.type,n=t.pendingProps,o=e!==null?e.memoizedProps:null,r=n.children,ri(l,n)?r=null:o!==null&&ri(l,o)&&(t.flags|=32),t.memoizedState!==null&&(l=Vi(e,t,ox,null,null,a),Tr._currentValue=l),_l(e,t),Oe(e,t,r,a),t.child;case 6:return e===null&&te&&((e=a=be)&&(a=Yx(a,t.pendingProps,Rt),a!==null?(t.stateNode=a,Ye=t,be=null,e=!0):e=!1),e||Ga(t)),null;case 13:return e0(e,t,a);case 4:return Al(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Rs(t,null,r,a):Oe(e,t,r,a),t.child;case 11:return xd(e,t,t.type,t.pendingProps,a);case 7:return Oe(e,t,t.pendingProps,a),t.child;case 8:return Oe(e,t,t.pendingProps.children,a),t.child;case 12:return Oe(e,t,t.pendingProps.children,a),t.child;case 10:return r=t.pendingProps,ca(t,t.type,r.value),Oe(e,t,r.children,a),t.child;case 9:return l=t.type._context,r=t.pendingProps.children,Qa(t),l=Ve(l),r=r(l),t.flags|=1,Oe(e,t,r,a),t.child;case 14:return gd(e,t,t.type,t.pendingProps,a);case 15:return Fm(e,t,t.type,t.pendingProps,a);case 19:return t0(e,t,a);case 31:return r=t.pendingProps,a=t.mode,r={mode:r.mode,children:r.children},e===null?(a=Wl(r,a),a.ref=t.ref,t.child=a,a.return=t,t=a):(a=Jt(e.child,r),a.ref=t.ref,t.child=a,a.return=t,t=a),t;case 22:return Im(e,t,a);case 24:return Qa(t),r=Ve(ke),e===null?(l=Ui(),l===null&&(l=ce,n=Di(),l.pooledCache=n,n.refCount++,n!==null&&(l.pooledCacheLanes|=a),l=n),t.memoizedState={parent:r,cache:l},Hi(t),ca(t,ke,l)):(e.lanes&a&&(Ho(e,t),hr(t,null,null,a),fr()),l=e.memoizedState,n=t.memoizedState,l.parent!==r?(l={parent:r,cache:r},t.memoizedState=l,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=l),ca(t,ke,r)):(r=n.cache,ca(t,ke,r),r!==l.cache&&Oo(t,[ke],a,!0))),Oe(e,t,t.pendingProps.children,a),t.child;case 29:throw t.pendingProps}throw Error(L(156,t.tag))}function Bt(e){e.flags|=4}function Nd(e,t){if(t.type!=="stylesheet"||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!$0(t)){if(t=pt.current,t!==null&&((ee&4194048)===ee?At!==null:(ee&62914560)!==ee&&!(ee&536870912)||t!==At))throw ur=Uo,om;e.flags|=8192}}function ml(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?Cu():536870912,e.lanes|=t,Ts|=t)}function Ps(e,t){if(!te)switch(e.tailMode){case"hidden":t=e.tail;for(var a=null;t!==null;)t.alternate!==null&&(a=t),t=t.sibling;a===null?e.tail=null:a.sibling=null;break;case"collapsed":a=e.tail;for(var r=null;a!==null;)a.alternate!==null&&(r=a),a=a.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function pe(e){var t=e.alternate!==null&&e.alternate.child===e.child,a=0,r=0;if(t)for(var l=e.child;l!==null;)a|=l.lanes|l.childLanes,r|=l.subtreeFlags&65011712,r|=l.flags&65011712,l.return=e,l=l.sibling;else for(l=e.child;l!==null;)a|=l.lanes|l.childLanes,r|=l.subtreeFlags,r|=l.flags,l.return=e,l=l.sibling;return e.subtreeFlags|=r,e.childLanes=a,t}function gx(e,t,a){var r=t.pendingProps;switch(Oi(t),t.tag){case 31:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return pe(t),null;case 1:return pe(t),null;case 3:return a=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Kt(ke),Ss(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(e===null||e.child===null)&&(Ks(t)?Bt(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Fc())),pe(t),null;case 26:return a=t.memoizedState,e===null?(Bt(t),a!==null?(pe(t),Nd(t,a)):(pe(t),t.flags&=-16777217)):a?a!==e.memoizedState?(Bt(t),pe(t),Nd(t,a)):(pe(t),t.flags&=-16777217):(e.memoizedProps!==r&&Bt(t),pe(t),t.flags&=-16777217),null;case 27:Ol(t),a=pa.current;var l=t.type;if(e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Bt(t);else{if(!r){if(t.stateNode===null)throw Error(L(166));return pe(t),null}e=zt.current,Ks(t)?Wc(t):(e=G0(l,r,a),t.stateNode=e,Bt(t))}return pe(t),null;case 5:if(Ol(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Bt(t);else{if(!r){if(t.stateNode===null)throw Error(L(166));return pe(t),null}if(e=zt.current,Ks(t))Wc(t);else{switch(l=sn(pa.current),e){case 1:e=l.createElementNS("http://www.w3.org/2000/svg",a);break;case 2:e=l.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;default:switch(a){case"svg":e=l.createElementNS("http://www.w3.org/2000/svg",a);break;case"math":e=l.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;case"script":e=l.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild);break;case"select":e=typeof r.is=="string"?l.createElement("select",{is:r.is}):l.createElement("select"),r.multiple?e.multiple=!0:r.size&&(e.size=r.size);break;default:e=typeof r.is=="string"?l.createElement(a,{is:r.is}):l.createElement(a)}}e[qe]=t,e[Pe]=r;e:for(l=t.child;l!==null;){if(l.tag===5||l.tag===6)e.appendChild(l.stateNode);else if(l.tag!==4&&l.tag!==27&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===t)break e;for(;l.sibling===null;){if(l.return===null||l.return===t)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}t.stateNode=e;e:switch(Be(e,a,r),a){case"button":case"input":case"select":case"textarea":e=!!r.autoFocus;break e;case"img":e=!0;break e;default:e=!1}e&&Bt(t)}}return pe(t),t.flags&=-16777217,null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Bt(t);else{if(typeof r!="string"&&t.stateNode===null)throw Error(L(166));if(e=pa.current,Ks(t)){if(e=t.stateNode,a=t.memoizedProps,r=null,l=Ye,l!==null)switch(l.tag){case 27:case 5:r=l.memoizedProps}e[qe]=t,e=!!(e.nodeValue===a||r!==null&&r.suppressHydrationWarning===!0||B0(e.nodeValue,a)),e||Ga(t)}else e=sn(e).createTextNode(r),e[qe]=t,t.stateNode=e}return pe(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(l=Ks(t),r!==null&&r.dehydrated!==null){if(e===null){if(!l)throw Error(L(318));if(l=t.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(L(317));l[qe]=t}else Gr(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;pe(t),l=!1}else l=Fc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),l=!0;if(!l)return t.flags&256?(Zt(t),t):(Zt(t),null)}if(Zt(t),t.flags&128)return t.lanes=a,t;if(a=r!==null,e=e!==null&&e.memoizedState!==null,a){r=t.child,l=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(l=r.alternate.memoizedState.cachePool.pool);var n=null;r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(n=r.memoizedState.cachePool.pool),n!==l&&(r.flags|=2048)}return a!==e&&a&&(t.child.flags|=8192),ml(t,t.updateQueue),pe(t),null;case 4:return Ss(),e===null&&nc(t.stateNode.containerInfo),pe(t),null;case 10:return Kt(t.type),pe(t),null;case 19:if(Ae(Ce),l=t.memoizedState,l===null)return pe(t),null;if(r=(t.flags&128)!==0,n=l.rendering,n===null)if(r)Ps(l,!1);else{if(ye!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(n=Zl(e),n!==null){for(t.flags|=128,Ps(l,!1),e=n.updateQueue,t.updateQueue=e,ml(t,e),t.subtreeFlags=0,e=a,a=t.child;a!==null;)sm(a,e),a=a.sibling;return he(Ce,Ce.current&1|2),t.child}e=e.sibling}l.tail!==null&&Lt()>Fl&&(t.flags|=128,r=!0,Ps(l,!1),t.lanes=4194304)}else{if(!r)if(e=Zl(n),e!==null){if(t.flags|=128,r=!0,e=e.updateQueue,t.updateQueue=e,ml(t,e),Ps(l,!0),l.tail===null&&l.tailMode==="hidden"&&!n.alternate&&!te)return pe(t),null}else 2*Lt()-l.renderingStartTime>Fl&&a!==536870912&&(t.flags|=128,r=!0,Ps(l,!1),t.lanes=4194304);l.isBackwards?(n.sibling=t.child,t.child=n):(e=l.last,e!==null?e.sibling=n:t.child=n,l.last=n)}return l.tail!==null?(t=l.tail,l.rendering=t,l.tail=t.sibling,l.renderingStartTime=Lt(),t.sibling=null,e=Ce.current,he(Ce,r?e&1|2:e&1),t):(pe(t),null);case 22:case 23:return Zt(t),Bi(),r=t.memoizedState!==null,e!==null?e.memoizedState!==null!==r&&(t.flags|=8192):r&&(t.flags|=8192),r?a&536870912&&!(t.flags&128)&&(pe(t),t.subtreeFlags&6&&(t.flags|=8192)):pe(t),a=t.updateQueue,a!==null&&ml(t,a.retryQueue),a=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==a&&(t.flags|=2048),e!==null&&Ae(Ba),null;case 24:return a=null,e!==null&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Kt(ke),pe(t),null;case 25:return null;case 30:return null}throw Error(L(156,t.tag))}function px(e,t){switch(Oi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Kt(ke),Ss(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ol(t),null;case 13:if(Zt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(L(340));Gr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ae(Ce),null;case 4:return Ss(),null;case 10:return Kt(t.type),null;case 22:case 23:return Zt(t),Bi(),e!==null&&Ae(Ba),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Kt(ke),null;case 25:return null;default:return null}}function s0(e,t){switch(Oi(t),t.tag){case 3:Kt(ke),Ss();break;case 26:case 27:case 5:Ol(t);break;case 4:Ss();break;case 13:Zt(t);break;case 19:Ae(Ce);break;case 10:Kt(t.type);break;case 22:case 23:Zt(t),Bi(),e!==null&&Ae(Ba);break;case 24:Kt(ke)}}function Jr(e,t){try{var a=t.updateQueue,r=a!==null?a.lastEffect:null;if(r!==null){var l=r.next;a=l;do{if((a.tag&e)===e){r=void 0;var n=a.create,o=a.inst;r=n(),o.destroy=r}a=a.next}while(a!==l)}}catch(i){oe(t,t.return,i)}}function _a(e,t,a){try{var r=t.updateQueue,l=r!==null?r.lastEffect:null;if(l!==null){var n=l.next;r=n;do{if((r.tag&e)===e){var o=r.inst,i=o.destroy;if(i!==void 0){o.destroy=void 0,l=t;var c=a,m=i;try{m()}catch(u){oe(l,c,u)}}}r=r.next}while(r!==n)}}catch(u){oe(t,t.return,u)}}function r0(e){var t=e.updateQueue;if(t!==null){var a=e.stateNode;try{dm(t,a)}catch(r){oe(e,e.return,r)}}}function l0(e,t,a){a.props=$a(e.type,e.memoizedProps),a.state=e.memoizedState;try{a.componentWillUnmount()}catch(r){oe(e,t,r)}}function gr(e,t){try{var a=e.ref;if(a!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof a=="function"?e.refCleanup=a(r):a.current=r}}catch(l){oe(e,t,l)}}function Tt(e,t){var a=e.ref,r=e.refCleanup;if(a!==null)if(typeof r=="function")try{r()}catch(l){oe(e,t,l)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(l){oe(e,t,l)}else a.current=null}function n0(e){var t=e.type,a=e.memoizedProps,r=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":a.autoFocus&&r.focus();break e;case"img":a.src?r.src=a.src:a.srcSet&&(r.srcset=a.srcSet)}}catch(l){oe(e,e.return,l)}}function eo(e,t,a){try{var r=e.stateNode;Hx(r,e.type,a,t),r[Pe]=t}catch(l){oe(e,e.return,l)}}function o0(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Ma(e.type)||e.tag===4}function to(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||o0(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.tag===27&&Ma(e.type)||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 Jo(e,t,a){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(e,t):(t=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,t.appendChild(e),a=a._reactRootContainer,a!=null||t.onclick!==null||(t.onclick=kn));else if(r!==4&&(r===27&&Ma(e.type)&&(a=e.stateNode,t=null),e=e.child,e!==null))for(Jo(e,t,a),e=e.sibling;e!==null;)Jo(e,t,a),e=e.sibling}function Pl(e,t,a){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?a.insertBefore(e,t):a.appendChild(e);else if(r!==4&&(r===27&&Ma(e.type)&&(a=e.stateNode),e=e.child,e!==null))for(Pl(e,t,a),e=e.sibling;e!==null;)Pl(e,t,a),e=e.sibling}function i0(e){var t=e.stateNode,a=e.memoizedProps;try{for(var r=e.type,l=t.attributes;l.length;)t.removeAttributeNode(l[0]);Be(t,r,a),t[qe]=e,t[Pe]=a}catch(n){oe(e,e.return,n)}}var Vt=!1,je=!1,ao=!1,wd=typeof WeakSet=="function"?WeakSet:Set,Te=null;function bx(e,t){if(e=e.containerInfo,ai=on,e=Ku(e),Ri(e)){if("selectionStart"in e)var a={start:e.selectionStart,end:e.selectionEnd};else e:{a=(a=e.ownerDocument)&&a.defaultView||window;var r=a.getSelection&&a.getSelection();if(r&&r.rangeCount!==0){a=r.anchorNode;var l=r.anchorOffset,n=r.focusNode;r=r.focusOffset;try{a.nodeType,n.nodeType}catch{a=null;break e}var o=0,i=-1,c=-1,m=0,u=0,x=e,f=null;t:for(;;){for(var b;x!==a||l!==0&&x.nodeType!==3||(i=o+l),x!==n||r!==0&&x.nodeType!==3||(c=o+r),x.nodeType===3&&(o+=x.nodeValue.length),(b=x.firstChild)!==null;)f=x,x=b;for(;;){if(x===e)break t;if(f===a&&++m===l&&(i=o),f===n&&++u===r&&(c=o),(b=x.nextSibling)!==null)break;x=f,f=x.parentNode}x=b}a=i===-1||c===-1?null:{start:i,end:c}}else a=null}a=a||{start:0,end:0}}else a=null;for(si={focusedElem:e,selectionRange:a},on=!1,Te=t;Te!==null;)if(t=Te,e=t.child,(t.subtreeFlags&1024)!==0&&e!==null)e.return=t,Te=e;else for(;Te!==null;){switch(t=Te,n=t.alternate,e=t.flags,t.tag){case 0:break;case 11:case 15:break;case 1:if(e&1024&&n!==null){e=void 0,a=t,l=n.memoizedProps,n=n.memoizedState,r=a.stateNode;try{var j=$a(a.type,l,a.elementType===a.type);e=r.getSnapshotBeforeUpdate(j,n),r.__reactInternalSnapshotBeforeUpdate=e}catch(v){oe(a,a.return,v)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,a=e.nodeType,a===9)li(e);else if(a===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":li(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(L(163))}if(e=t.sibling,e!==null){e.return=t.return,Te=e;break}Te=t.return}}function c0(e,t,a){var r=a.flags;switch(a.tag){case 0:case 11:case 15:la(e,a),r&4&&Jr(5,a);break;case 1:if(la(e,a),r&4)if(e=a.stateNode,t===null)try{e.componentDidMount()}catch(o){oe(a,a.return,o)}else{var l=$a(a.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(l,t,e.__reactInternalSnapshotBeforeUpdate)}catch(o){oe(a,a.return,o)}}r&64&&r0(a),r&512&&gr(a,a.return);break;case 3:if(la(e,a),r&64&&(e=a.updateQueue,e!==null)){if(t=null,a.child!==null)switch(a.child.tag){case 27:case 5:t=a.child.stateNode;break;case 1:t=a.child.stateNode}try{dm(e,t)}catch(o){oe(a,a.return,o)}}break;case 27:t===null&&r&4&&i0(a);case 26:case 5:la(e,a),t===null&&r&4&&n0(a),r&512&&gr(a,a.return);break;case 12:la(e,a);break;case 13:la(e,a),r&4&&m0(e,a),r&64&&(e=a.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(a=kx.bind(null,a),$x(e,a))));break;case 22:if(r=a.memoizedState!==null||Vt,!r){t=t!==null&&t.memoizedState!==null||je,l=Vt;var n=je;Vt=r,(je=t)&&!n?na(e,a,(a.subtreeFlags&8772)!==0):la(e,a),Vt=l,je=n}break;case 30:break;default:la(e,a)}}function d0(e){var t=e.alternate;t!==null&&(e.alternate=null,d0(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Si(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var me=null,Je=!1;function qt(e,t,a){for(a=a.child;a!==null;)u0(e,t,a),a=a.sibling}function u0(e,t,a){if(rt&&typeof rt.onCommitFiberUnmount=="function")try{rt.onCommitFiberUnmount(Ur,a)}catch{}switch(a.tag){case 26:je||Tt(a,t),qt(e,t,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:je||Tt(a,t);var r=me,l=Je;Ma(a.type)&&(me=a.stateNode,Je=!1),qt(e,t,a),vr(a.stateNode),me=r,Je=l;break;case 5:je||Tt(a,t);case 6:if(r=me,l=Je,me=null,qt(e,t,a),me=r,Je=l,me!==null)if(Je)try{(me.nodeType===9?me.body:me.nodeName==="HTML"?me.ownerDocument.body:me).removeChild(a.stateNode)}catch(n){oe(a,t,n)}else try{me.removeChild(a.stateNode)}catch(n){oe(a,t,n)}break;case 18:me!==null&&(Je?(e=me,Od(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,a.stateNode),Ar(e)):Od(me,a.stateNode));break;case 4:r=me,l=Je,me=a.stateNode.containerInfo,Je=!0,qt(e,t,a),me=r,Je=l;break;case 0:case 11:case 14:case 15:je||_a(2,a,t),je||_a(4,a,t),qt(e,t,a);break;case 1:je||(Tt(a,t),r=a.stateNode,typeof r.componentWillUnmount=="function"&&l0(a,t,r)),qt(e,t,a);break;case 21:qt(e,t,a);break;case 22:je=(r=je)||a.memoizedState!==null,qt(e,t,a),je=r;break;default:qt(e,t,a)}}function m0(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Ar(e)}catch(a){oe(t,t.return,a)}}function yx(e){switch(e.tag){case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new wd),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new wd),t;default:throw Error(L(435,e.tag))}}function so(e,t){var a=yx(e);t.forEach(function(r){var l=Cx.bind(null,e,r);a.has(r)||(a.add(r),r.then(l,l))})}function et(e,t){var a=t.deletions;if(a!==null)for(var r=0;r<a.length;r++){var l=a[r],n=e,o=t,i=o;e:for(;i!==null;){switch(i.tag){case 27:if(Ma(i.type)){me=i.stateNode,Je=!1;break e}break;case 5:me=i.stateNode,Je=!1;break e;case 3:case 4:me=i.stateNode.containerInfo,Je=!0;break e}i=i.return}if(me===null)throw Error(L(160));u0(n,o,l),me=null,Je=!1,n=l.alternate,n!==null&&(n.return=null),l.return=null}if(t.subtreeFlags&13878)for(t=t.child;t!==null;)f0(t,e),t=t.sibling}var yt=null;function f0(e,t){var a=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:et(t,e),tt(e),r&4&&(_a(3,e,e.return),Jr(3,e),_a(5,e,e.return));break;case 1:et(t,e),tt(e),r&512&&(je||a===null||Tt(a,a.return)),r&64&&Vt&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(a=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=a===null?r:a.concat(r))));break;case 26:var l=yt;if(et(t,e),tt(e),r&512&&(je||a===null||Tt(a,a.return)),r&4){var n=a!==null?a.memoizedState:null;if(r=e.memoizedState,a===null)if(r===null)if(e.stateNode===null){e:{r=e.type,a=e.memoizedProps,l=l.ownerDocument||l;t:switch(r){case"title":n=l.getElementsByTagName("title")[0],(!n||n[qr]||n[qe]||n.namespaceURI==="http://www.w3.org/2000/svg"||n.hasAttribute("itemprop"))&&(n=l.createElement(r),l.head.insertBefore(n,l.querySelector("head > title"))),Be(n,r,a),n[qe]=e,ze(n),r=n;break e;case"link":var o=qd("link","href",l).get(r+(a.href||""));if(o){for(var i=0;i<o.length;i++)if(n=o[i],n.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&n.getAttribute("rel")===(a.rel==null?null:a.rel)&&n.getAttribute("title")===(a.title==null?null:a.title)&&n.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){o.splice(i,1);break t}}n=l.createElement(r),Be(n,r,a),l.head.appendChild(n);break;case"meta":if(o=qd("meta","content",l).get(r+(a.content||""))){for(i=0;i<o.length;i++)if(n=o[i],n.getAttribute("content")===(a.content==null?null:""+a.content)&&n.getAttribute("name")===(a.name==null?null:a.name)&&n.getAttribute("property")===(a.property==null?null:a.property)&&n.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&n.getAttribute("charset")===(a.charSet==null?null:a.charSet)){o.splice(i,1);break t}}n=l.createElement(r),Be(n,r,a),l.head.appendChild(n);break;default:throw Error(L(468,r))}n[qe]=e,ze(n),r=n}e.stateNode=r}else Vd(l,e.type,e.stateNode);else e.stateNode=Bd(l,r,e.memoizedProps);else n!==r?(n===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):n.count--,r===null?Vd(l,e.type,e.stateNode):Bd(l,r,e.memoizedProps)):r===null&&e.stateNode!==null&&eo(e,e.memoizedProps,a.memoizedProps)}break;case 27:et(t,e),tt(e),r&512&&(je||a===null||Tt(a,a.return)),a!==null&&r&4&&eo(e,e.memoizedProps,a.memoizedProps);break;case 5:if(et(t,e),tt(e),r&512&&(je||a===null||Tt(a,a.return)),e.flags&32){l=e.stateNode;try{_s(l,"")}catch(b){oe(e,e.return,b)}}r&4&&e.stateNode!=null&&(l=e.memoizedProps,eo(e,l,a!==null?a.memoizedProps:l)),r&1024&&(ao=!0);break;case 6:if(et(t,e),tt(e),r&4){if(e.stateNode===null)throw Error(L(162));r=e.memoizedProps,a=e.stateNode;try{a.nodeValue=r}catch(b){oe(e,e.return,b)}}break;case 3:if(Ml=null,l=yt,yt=rn(t.containerInfo),et(t,e),yt=l,tt(e),r&4&&a!==null&&a.memoizedState.isDehydrated)try{Ar(t.containerInfo)}catch(b){oe(e,e.return,b)}ao&&(ao=!1,h0(e));break;case 4:r=yt,yt=rn(e.stateNode.containerInfo),et(t,e),tt(e),yt=r;break;case 12:et(t,e),tt(e);break;case 13:et(t,e),tt(e),e.child.flags&8192&&e.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(sc=Lt()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,so(e,r)));break;case 22:l=e.memoizedState!==null;var c=a!==null&&a.memoizedState!==null,m=Vt,u=je;if(Vt=m||l,je=u||c,et(t,e),je=u,Vt=m,tt(e),r&8192)e:for(t=e.stateNode,t._visibility=l?t._visibility&-2:t._visibility|1,l&&(a===null||c||Vt||je||Aa(e)),a=null,t=e;;){if(t.tag===5||t.tag===26){if(a===null){c=a=t;try{if(n=c.stateNode,l)o=n.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none";else{i=c.stateNode;var x=c.memoizedProps.style,f=x!=null&&x.hasOwnProperty("display")?x.display:null;i.style.display=f==null||typeof f=="boolean"?"":(""+f).trim()}}catch(b){oe(c,c.return,b)}}}else if(t.tag===6){if(a===null){c=t;try{c.stateNode.nodeValue=l?"":c.memoizedProps}catch(b){oe(c,c.return,b)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;a===t&&(a=null),t=t.return}a===t&&(a=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(a=r.retryQueue,a!==null&&(r.retryQueue=null,so(e,a))));break;case 19:et(t,e),tt(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,so(e,r)));break;case 30:break;case 21:break;default:et(t,e),tt(e)}}function tt(e){var t=e.flags;if(t&2){try{for(var a,r=e.return;r!==null;){if(o0(r)){a=r;break}r=r.return}if(a==null)throw Error(L(160));switch(a.tag){case 27:var l=a.stateNode,n=to(e);Pl(e,n,l);break;case 5:var o=a.stateNode;a.flags&32&&(_s(o,""),a.flags&=-33);var i=to(e);Pl(e,i,o);break;case 3:case 4:var c=a.stateNode.containerInfo,m=to(e);Jo(e,m,c);break;default:throw Error(L(161))}}catch(u){oe(e,e.return,u)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function h0(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;h0(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function la(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)c0(e,t.alternate,t),t=t.sibling}function Aa(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:_a(4,t,t.return),Aa(t);break;case 1:Tt(t,t.return);var a=t.stateNode;typeof a.componentWillUnmount=="function"&&l0(t,t.return,a),Aa(t);break;case 27:vr(t.stateNode);case 26:case 5:Tt(t,t.return),Aa(t);break;case 22:t.memoizedState===null&&Aa(t);break;case 30:Aa(t);break;default:Aa(t)}e=e.sibling}}function na(e,t,a){for(a=a&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var r=t.alternate,l=e,n=t,o=n.flags;switch(n.tag){case 0:case 11:case 15:na(l,n,a),Jr(4,n);break;case 1:if(na(l,n,a),r=n,l=r.stateNode,typeof l.componentDidMount=="function")try{l.componentDidMount()}catch(m){oe(r,r.return,m)}if(r=n,l=r.updateQueue,l!==null){var i=r.stateNode;try{var c=l.shared.hiddenCallbacks;if(c!==null)for(l.shared.hiddenCallbacks=null,l=0;l<c.length;l++)cm(c[l],i)}catch(m){oe(r,r.return,m)}}a&&o&64&&r0(n),gr(n,n.return);break;case 27:i0(n);case 26:case 5:na(l,n,a),a&&r===null&&o&4&&n0(n),gr(n,n.return);break;case 12:na(l,n,a);break;case 13:na(l,n,a),a&&o&4&&m0(l,n);break;case 22:n.memoizedState===null&&na(l,n,a),gr(n,n.return);break;case 30:break;default:na(l,n,a)}t=t.sibling}}function Ii(e,t){var a=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==a&&(e!=null&&e.refCount++,a!=null&&Yr(a))}function ec(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Yr(e))}function kt(e,t,a,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)x0(e,t,a,r),t=t.sibling}function x0(e,t,a,r){var l=t.flags;switch(t.tag){case 0:case 11:case 15:kt(e,t,a,r),l&2048&&Jr(9,t);break;case 1:kt(e,t,a,r);break;case 3:kt(e,t,a,r),l&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Yr(e)));break;case 12:if(l&2048){kt(e,t,a,r),e=t.stateNode;try{var n=t.memoizedProps,o=n.id,i=n.onPostCommit;typeof i=="function"&&i(o,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(c){oe(t,t.return,c)}}else kt(e,t,a,r);break;case 13:kt(e,t,a,r);break;case 23:break;case 22:n=t.stateNode,o=t.alternate,t.memoizedState!==null?n._visibility&2?kt(e,t,a,r):pr(e,t):n._visibility&2?kt(e,t,a,r):(n._visibility|=2,es(e,t,a,r,(t.subtreeFlags&10256)!==0)),l&2048&&Ii(o,t);break;case 24:kt(e,t,a,r),l&2048&&ec(t.alternate,t);break;default:kt(e,t,a,r)}}function es(e,t,a,r,l){for(l=l&&(t.subtreeFlags&10256)!==0,t=t.child;t!==null;){var n=e,o=t,i=a,c=r,m=o.flags;switch(o.tag){case 0:case 11:case 15:es(n,o,i,c,l),Jr(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState!==null?u._visibility&2?es(n,o,i,c,l):pr(n,o):(u._visibility|=2,es(n,o,i,c,l)),l&&m&2048&&Ii(o.alternate,o);break;case 24:es(n,o,i,c,l),l&&m&2048&&ec(o.alternate,o);break;default:es(n,o,i,c,l)}t=t.sibling}}function pr(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var a=e,r=t,l=r.flags;switch(r.tag){case 22:pr(a,r),l&2048&&Ii(r.alternate,r);break;case 24:pr(a,r),l&2048&&ec(r.alternate,r);break;default:pr(a,r)}t=t.sibling}}var lr=8192;function Wa(e){if(e.subtreeFlags&lr)for(e=e.child;e!==null;)g0(e),e=e.sibling}function g0(e){switch(e.tag){case 26:Wa(e),e.flags&lr&&e.memoizedState!==null&&rg(yt,e.memoizedState,e.memoizedProps);break;case 5:Wa(e);break;case 3:case 4:var t=yt;yt=rn(e.stateNode.containerInfo),Wa(e),yt=t;break;case 22:e.memoizedState===null&&(t=e.alternate,t!==null&&t.memoizedState!==null?(t=lr,lr=16777216,Wa(e),lr=t):Wa(e));break;default:Wa(e)}}function p0(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Fs(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var a=0;a<t.length;a++){var r=t[a];Te=r,y0(r,e)}p0(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)b0(e),e=e.sibling}function b0(e){switch(e.tag){case 0:case 11:case 15:Fs(e),e.flags&2048&&_a(9,e,e.return);break;case 3:Fs(e);break;case 12:Fs(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,kl(e)):Fs(e);break;default:Fs(e)}}function kl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var a=0;a<t.length;a++){var r=t[a];Te=r,y0(r,e)}p0(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:_a(8,t,t.return),kl(t);break;case 22:a=t.stateNode,a._visibility&2&&(a._visibility&=-3,kl(t));break;default:kl(t)}e=e.sibling}}function y0(e,t){for(;Te!==null;){var a=Te;switch(a.tag){case 0:case 11:case 15:_a(8,a,t);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var r=a.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Yr(a.memoizedState.cache)}if(r=a.child,r!==null)r.return=a,Te=r;else e:for(a=e;Te!==null;){r=Te;var l=r.sibling,n=r.return;if(d0(r),r===a){Te=null;break e}if(l!==null){l.return=n,Te=l;break e}Te=n}}}var vx={getCacheForType:function(e){var t=Ve(ke),a=t.data.get(e);return a===void 0&&(a=e(),t.data.set(e,a)),a}},jx=typeof WeakMap=="function"?WeakMap:Map,re=0,ce=null,F=null,ee=0,se=0,at=null,xa=!1,Bs=!1,tc=!1,ea=0,ye=0,ka=0,qa=0,ac=0,gt=0,Ts=0,br=null,Ke=null,Ko=!1,sc=0,Fl=1/0,Il=null,va=null,He=0,ja=null,zs=null,Ns=0,Wo=0,Po=null,v0=null,yr=0,Fo=null;function nt(){if(re&2&&ee!==0)return ee&-ee;if(Y.T!==null){var e=ks;return e!==0?e:lc()}return Tu()}function j0(){gt===0&&(gt=!(ee&536870912)||te?ku():536870912);var e=pt.current;return e!==null&&(e.flags|=32),gt}function ot(e,t,a){(e===ce&&(se===2||se===9)||e.cancelPendingCommit!==null)&&(Ls(e,0),ga(e,ee,gt,!1)),Br(e,a),(!(re&2)||e!==ce)&&(e===ce&&(!(re&2)&&(qa|=a),ye===4&&ga(e,ee,gt,!1)),Dt(e))}function N0(e,t,a){if(re&6)throw Error(L(327));var r=!a&&(t&124)===0&&(t&e.expiredLanes)===0||Hr(e,t),l=r?Sx(e,t):ro(e,t,!0),n=r;do{if(l===0){Bs&&!r&&ga(e,t,0,!1);break}else{if(a=e.current.alternate,n&&!Nx(a)){l=ro(e,t,!1),n=!1;continue}if(l===2){if(n=t,e.errorRecoveryDisabledLanes&n)var o=0;else o=e.pendingLanes&-536870913,o=o!==0?o:o&536870912?536870912:0;if(o!==0){t=o;e:{var i=e;l=br;var c=i.current.memoizedState.isDehydrated;if(c&&(Ls(i,o).flags|=256),o=ro(i,o,!1),o!==2){if(tc&&!c){i.errorRecoveryDisabledLanes|=n,qa|=n,l=4;break e}n=Ke,Ke=l,n!==null&&(Ke===null?Ke=n:Ke.push.apply(Ke,n))}l=o}if(n=!1,l!==2)continue}}if(l===1){Ls(e,0),ga(e,t,0,!0);break}e:{switch(r=e,n=l,n){case 0:case 1:throw Error(L(345));case 4:if((t&4194048)!==t)break;case 6:ga(r,t,gt,!xa);break e;case 2:Ke=null;break;case 3:case 5:break;default:throw Error(L(329))}if((t&62914560)===t&&(l=sc+300-Lt(),10<l)){if(ga(r,t,gt,!xa),hn(r,0,!0)!==0)break e;r.timeoutHandle=V0(Sd.bind(null,r,a,Ke,Il,Ko,t,gt,qa,Ts,xa,n,2,-0,0),l);break e}Sd(r,a,Ke,Il,Ko,t,gt,qa,Ts,xa,n,0,-0,0)}}break}while(!0);Dt(e)}function Sd(e,t,a,r,l,n,o,i,c,m,u,x,f,b){if(e.timeoutHandle=-1,x=t.subtreeFlags,(x&8192||(x&16785408)===16785408)&&(Rr={stylesheets:null,count:0,unsuspend:sg},g0(t),x=lg(),x!==null)){e.cancelPendingCommit=x(_d.bind(null,e,t,n,a,r,l,o,i,c,u,1,f,b)),ga(e,n,o,!m);return}_d(e,t,n,a,r,l,o,i,c)}function Nx(e){for(var t=e;;){var a=t.tag;if((a===0||a===11||a===15)&&t.flags&16384&&(a=t.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var r=0;r<a.length;r++){var l=a[r],n=l.getSnapshot;l=l.value;try{if(!it(n(),l))return!1}catch{return!1}}if(a=t.child,t.subtreeFlags&16384&&a!==null)a.return=t,t=a;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function ga(e,t,a,r){t&=~ac,t&=~qa,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var l=t;0<l;){var n=31-lt(l),o=1<<n;r[n]=-1,l&=~o}a!==0&&Mu(e,a,t)}function Sn(){return re&6?!0:(Kr(0),!1)}function rc(){if(F!==null){if(se===0)var e=F.return;else e=F,Xt=Ka=null,Yi(e),js=null,kr=0,e=F;for(;e!==null;)s0(e.alternate,e),e=e.return;F=null}}function Ls(e,t){var a=e.timeoutHandle;a!==-1&&(e.timeoutHandle=-1,qx(a)),a=e.cancelPendingCommit,a!==null&&(e.cancelPendingCommit=null,a()),rc(),ce=e,F=a=Jt(e.current,null),ee=t,se=0,at=null,xa=!1,Bs=Hr(e,t),tc=!1,Ts=gt=ac=qa=ka=ye=0,Ke=br=null,Ko=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var l=31-lt(r),n=1<<l;t|=e[l],r&=~n}return ea=t,bn(),a}function w0(e,t){W=null,Y.H=Xl,t===$r||t===vn?(t=ad(),se=3):t===om?(t=ad(),se=4):se=t===Pm?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,at=t,F===null&&(ye=1,Kl(e,xt(t,e.current)))}function S0(){var e=Y.H;return Y.H=Xl,e===null?Xl:e}function E0(){var e=Y.A;return Y.A=vx,e}function Io(){ye=4,xa||(ee&4194048)!==ee&&pt.current!==null||(Bs=!0),!(ka&134217727)&&!(qa&134217727)||ce===null||ga(ce,ee,gt,!1)}function ro(e,t,a){var r=re;re|=2;var l=S0(),n=E0();(ce!==e||ee!==t)&&(Il=null,Ls(e,t)),t=!1;var o=ye;e:do try{if(se!==0&&F!==null){var i=F,c=at;switch(se){case 8:rc(),o=6;break e;case 3:case 2:case 9:case 6:pt.current===null&&(t=!0);var m=se;if(se=0,at=null,hs(e,i,c,m),a&&Bs){o=0;break e}break;default:m=se,se=0,at=null,hs(e,i,c,m)}}wx(),o=ye;break}catch(u){w0(e,u)}while(!0);return t&&e.shellSuspendCounter++,Xt=Ka=null,re=r,Y.H=l,Y.A=n,F===null&&(ce=null,ee=0,bn()),o}function wx(){for(;F!==null;)_0(F)}function Sx(e,t){var a=re;re|=2;var r=S0(),l=E0();ce!==e||ee!==t?(Il=null,Fl=Lt()+500,Ls(e,t)):Bs=Hr(e,t);e:do try{if(se!==0&&F!==null){t=F;var n=at;t:switch(se){case 1:se=0,at=null,hs(e,t,n,1);break;case 2:case 9:if(td(n)){se=0,at=null,Ed(t);break}t=function(){se!==2&&se!==9||ce!==e||(se=7),Dt(e)},n.then(t,t);break e;case 3:se=7;break e;case 4:se=5;break e;case 7:td(n)?(se=0,at=null,Ed(t)):(se=0,at=null,hs(e,t,n,7));break;case 5:var o=null;switch(F.tag){case 26:o=F.memoizedState;case 5:case 27:var i=F;if(!o||$0(o)){se=0,at=null;var c=i.sibling;if(c!==null)F=c;else{var m=i.return;m!==null?(F=m,En(m)):F=null}break t}}se=0,at=null,hs(e,t,n,5);break;case 6:se=0,at=null,hs(e,t,n,6);break;case 8:rc(),ye=6;break e;default:throw Error(L(462))}}Ex();break}catch(u){w0(e,u)}while(!0);return Xt=Ka=null,Y.H=r,Y.A=l,re=a,F!==null?0:(ce=null,ee=0,bn(),ye)}function Ex(){for(;F!==null&&!Zf();)_0(F)}function _0(e){var t=a0(e.alternate,e,ea);e.memoizedProps=e.pendingProps,t===null?En(e):F=t}function Ed(e){var t=e,a=t.alternate;switch(t.tag){case 15:case 0:t=bd(a,t,t.pendingProps,t.type,void 0,ee);break;case 11:t=bd(a,t,t.pendingProps,t.type.render,t.ref,ee);break;case 5:Yi(t);default:s0(a,t),t=F=sm(t,ea),t=a0(a,t,ea)}e.memoizedProps=e.pendingProps,t===null?En(e):F=t}function hs(e,t,a,r){Xt=Ka=null,Yi(t),js=null,kr=0;var l=t.return;try{if(hx(e,l,t,a,ee)){ye=1,Kl(e,xt(a,e.current)),F=null;return}}catch(n){if(l!==null)throw F=l,n;ye=1,Kl(e,xt(a,e.current)),F=null;return}t.flags&32768?(te||r===1?e=!0:Bs||ee&536870912?e=!1:(xa=e=!0,(r===2||r===9||r===3||r===6)&&(r=pt.current,r!==null&&r.tag===13&&(r.flags|=16384))),k0(t,e)):En(t)}function En(e){var t=e;do{if(t.flags&32768){k0(t,xa);return}e=t.return;var a=gx(t.alternate,t,ea);if(a!==null){F=a;return}if(t=t.sibling,t!==null){F=t;return}F=t=e}while(t!==null);ye===0&&(ye=5)}function k0(e,t){do{var a=px(e.alternate,e);if(a!==null){a.flags&=32767,F=a;return}if(a=e.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!t&&(e=e.sibling,e!==null)){F=e;return}F=e=a}while(e!==null);ye=6,F=null}function _d(e,t,a,r,l,n,o,i,c){e.cancelPendingCommit=null;do _n();while(He!==0);if(re&6)throw Error(L(327));if(t!==null){if(t===e.current)throw Error(L(177));if(n=t.lanes|t.childLanes,n|=Ti,sh(e,a,n,o,i,c),e===ce&&(F=ce=null,ee=0),zs=t,ja=e,Ns=a,Wo=n,Po=l,v0=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,Mx(Dl,function(){return z0(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!==0,t.subtreeFlags&13878||r){r=Y.T,Y.T=null,l=ae.p,ae.p=2,o=re,re|=4;try{bx(e,t,a)}finally{re=o,ae.p=l,Y.T=r}}He=1,C0(),M0(),R0()}}function C0(){if(He===1){He=0;var e=ja,t=zs,a=(t.flags&13878)!==0;if(t.subtreeFlags&13878||a){a=Y.T,Y.T=null;var r=ae.p;ae.p=2;var l=re;re|=4;try{f0(t,e);var n=si,o=Ku(e.containerInfo),i=n.focusedElem,c=n.selectionRange;if(o!==i&&i&&i.ownerDocument&&Ju(i.ownerDocument.documentElement,i)){if(c!==null&&Ri(i)){var m=c.start,u=c.end;if(u===void 0&&(u=m),"selectionStart"in i)i.selectionStart=m,i.selectionEnd=Math.min(u,i.value.length);else{var x=i.ownerDocument||document,f=x&&x.defaultView||window;if(f.getSelection){var b=f.getSelection(),j=i.textContent.length,v=Math.min(c.start,j),S=c.end===void 0?v:Math.min(c.end,j);!b.extend&&v>S&&(o=S,S=v,v=o);var h=Zc(i,v),d=Zc(i,S);if(h&&d&&(b.rangeCount!==1||b.anchorNode!==h.node||b.anchorOffset!==h.offset||b.focusNode!==d.node||b.focusOffset!==d.offset)){var p=x.createRange();p.setStart(h.node,h.offset),b.removeAllRanges(),v>S?(b.addRange(p),b.extend(d.node,d.offset)):(p.setEnd(d.node,d.offset),b.addRange(p))}}}}for(x=[],b=i;b=b.parentNode;)b.nodeType===1&&x.push({element:b,left:b.scrollLeft,top:b.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i<x.length;i++){var y=x[i];y.element.scrollLeft=y.left,y.element.scrollTop=y.top}}on=!!ai,si=ai=null}finally{re=l,ae.p=r,Y.T=a}}e.current=t,He=2}}function M0(){if(He===2){He=0;var e=ja,t=zs,a=(t.flags&8772)!==0;if(t.subtreeFlags&8772||a){a=Y.T,Y.T=null;var r=ae.p;ae.p=2;var l=re;re|=4;try{c0(e,t.alternate,t)}finally{re=l,ae.p=r,Y.T=a}}He=3}}function R0(){if(He===4||He===3){He=0,Jf();var e=ja,t=zs,a=Ns,r=v0;t.subtreeFlags&10256||t.flags&10256?He=5:(He=0,zs=ja=null,T0(e,e.pendingLanes));var l=e.pendingLanes;if(l===0&&(va=null),wi(a),t=t.stateNode,rt&&typeof rt.onCommitFiberRoot=="function")try{rt.onCommitFiberRoot(Ur,t,void 0,(t.current.flags&128)===128)}catch{}if(r!==null){t=Y.T,l=ae.p,ae.p=2,Y.T=null;try{for(var n=e.onRecoverableError,o=0;o<r.length;o++){var i=r[o];n(i.value,{componentStack:i.stack})}}finally{Y.T=t,ae.p=l}}Ns&3&&_n(),Dt(e),l=e.pendingLanes,a&4194090&&l&42?e===Fo?yr++:(yr=0,Fo=e):yr=0,Kr(0)}}function T0(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Yr(t)))}function _n(e){return C0(),M0(),R0(),z0()}function z0(){if(He!==5)return!1;var e=ja,t=Wo;Wo=0;var a=wi(Ns),r=Y.T,l=ae.p;try{ae.p=32>a?32:a,Y.T=null,a=Po,Po=null;var n=ja,o=Ns;if(He=0,zs=ja=null,Ns=0,re&6)throw Error(L(331));var i=re;if(re|=4,b0(n.current),x0(n,n.current,o,a),re=i,Kr(0,!1),rt&&typeof rt.onPostCommitFiberRoot=="function")try{rt.onPostCommitFiberRoot(Ur,n)}catch{}return!0}finally{ae.p=l,Y.T=r,T0(e,t)}}function kd(e,t,a){t=xt(a,t),t=$o(e.stateNode,t,2),e=ya(e,t,2),e!==null&&(Br(e,2),Dt(e))}function oe(e,t,a){if(e.tag===3)kd(e,e,a);else for(;t!==null;){if(t.tag===3){kd(t,e,a);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(va===null||!va.has(r))){e=xt(a,e),a=Km(2),r=ya(t,a,2),r!==null&&(Wm(a,r,t,e),Br(r,2),Dt(r));break}}t=t.return}}function lo(e,t,a){var r=e.pingCache;if(r===null){r=e.pingCache=new jx;var l=new Set;r.set(t,l)}else l=r.get(t),l===void 0&&(l=new Set,r.set(t,l));l.has(a)||(tc=!0,l.add(a),e=_x.bind(null,e,t,a),t.then(e,e))}function _x(e,t,a){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&a,e.warmLanes&=~a,ce===e&&(ee&a)===a&&(ye===4||ye===3&&(ee&62914560)===ee&&300>Lt()-sc?!(re&2)&&Ls(e,0):ac|=a,Ts===ee&&(Ts=0)),Dt(e)}function L0(e,t){t===0&&(t=Cu()),e=Hs(e,t),e!==null&&(Br(e,t),Dt(e))}function kx(e){var t=e.memoizedState,a=0;t!==null&&(a=t.retryLane),L0(e,a)}function Cx(e,t){var a=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(a=l.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(L(314))}r!==null&&r.delete(t),L0(e,a)}function Mx(e,t){return ji(e,t)}var en=null,ts=null,ei=!1,tn=!1,no=!1,Va=0;function Dt(e){e!==ts&&e.next===null&&(ts===null?en=ts=e:ts=ts.next=e),tn=!0,ei||(ei=!0,Tx())}function Kr(e,t){if(!no&&tn){no=!0;do for(var a=!1,r=en;r!==null;){if(e!==0){var l=r.pendingLanes;if(l===0)var n=0;else{var o=r.suspendedLanes,i=r.pingedLanes;n=(1<<31-lt(42|e)+1)-1,n&=l&~(o&~i),n=n&201326741?n&201326741|1:n?n|2:0}n!==0&&(a=!0,Cd(r,n))}else n=ee,n=hn(r,r===ce?n:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(n&3)||Hr(r,n)||(a=!0,Cd(r,n));r=r.next}while(a);no=!1}}function Rx(){A0()}function A0(){tn=ei=!1;var e=0;Va!==0&&(Bx()&&(e=Va),Va=0);for(var t=Lt(),a=null,r=en;r!==null;){var l=r.next,n=O0(r,t);n===0?(r.next=null,a===null?en=l:a.next=l,l===null&&(ts=a)):(a=r,(e!==0||n&3)&&(tn=!0)),r=l}Kr(e)}function O0(e,t){for(var a=e.suspendedLanes,r=e.pingedLanes,l=e.expirationTimes,n=e.pendingLanes&-62914561;0<n;){var o=31-lt(n),i=1<<o,c=l[o];c===-1?(!(i&a)||i&r)&&(l[o]=ah(i,t)):c<=t&&(e.expiredLanes|=i),n&=~i}if(t=ce,a=ee,a=hn(e,e===t?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,a===0||e===t&&(se===2||se===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&zn(r),e.callbackNode=null,e.callbackPriority=0;if(!(a&3)||Hr(e,a)){if(t=a&-a,t===e.callbackPriority)return t;switch(r!==null&&zn(r),wi(a)){case 2:case 8:a=Eu;break;case 32:a=Dl;break;case 268435456:a=_u;break;default:a=Dl}return r=D0.bind(null,e),a=ji(a,r),e.callbackPriority=t,e.callbackNode=a,t}return r!==null&&r!==null&&zn(r),e.callbackPriority=2,e.callbackNode=null,2}function D0(e,t){if(He!==0&&He!==5)return e.callbackNode=null,e.callbackPriority=0,null;var a=e.callbackNode;if(_n()&&e.callbackNode!==a)return null;var r=ee;return r=hn(e,e===ce?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(N0(e,r,t),O0(e,Lt()),e.callbackNode!=null&&e.callbackNode===a?D0.bind(null,e):null)}function Cd(e,t){if(_n())return null;N0(e,t,!0)}function Tx(){Vx(function(){re&6?ji(Su,Rx):A0()})}function lc(){return Va===0&&(Va=ku()),Va}function Md(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:yl(""+e)}function Rd(e,t){var a=t.ownerDocument.createElement("input");return a.name=t.name,a.value=t.value,e.id&&a.setAttribute("form",e.id),t.parentNode.insertBefore(a,t),e=new FormData(e),a.parentNode.removeChild(a),e}function zx(e,t,a,r,l){if(t==="submit"&&a&&a.stateNode===l){var n=Md((l[Pe]||null).action),o=r.submitter;o&&(t=(t=o[Pe]||null)?Md(t.formAction):o.getAttribute("formAction"),t!==null&&(n=t,o=null));var i=new xn("action","action",null,r,l);e.push({event:i,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(Va!==0){var c=o?Rd(l,o):new FormData(l);Qo(a,{pending:!0,data:c,method:l.method,action:n},null,c)}}else typeof n=="function"&&(i.preventDefault(),c=o?Rd(l,o):new FormData(l),Qo(a,{pending:!0,data:c,method:l.method,action:n},n,c))},currentTarget:l}]})}}for(var oo=0;oo<To.length;oo++){var io=To[oo],Lx=io.toLowerCase(),Ax=io[0].toUpperCase()+io.slice(1);wt(Lx,"on"+Ax)}wt(Pu,"onAnimationEnd");wt(Fu,"onAnimationIteration");wt(Iu,"onAnimationStart");wt("dblclick","onDoubleClick");wt("focusin","onFocus");wt("focusout","onBlur");wt(Ph,"onTransitionRun");wt(Fh,"onTransitionStart");wt(Ih,"onTransitionCancel");wt(em,"onTransitionEnd");Es("onMouseEnter",["mouseout","mouseover"]);Es("onMouseLeave",["mouseout","mouseover"]);Es("onPointerEnter",["pointerout","pointerover"]);Es("onPointerLeave",["pointerout","pointerover"]);Xa("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Xa("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Xa("onBeforeInput",["compositionend","keypress","textInput","paste"]);Xa("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Xa("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Xa("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Cr="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Ox=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Cr));function U0(e,t){t=(t&4)!==0;for(var a=0;a<e.length;a++){var r=e[a],l=r.event;r=r.listeners;e:{var n=void 0;if(t)for(var o=r.length-1;0<=o;o--){var i=r[o],c=i.instance,m=i.currentTarget;if(i=i.listener,c!==n&&l.isPropagationStopped())break e;n=i,l.currentTarget=m;try{n(l)}catch(u){Jl(u)}l.currentTarget=null,n=c}else for(o=0;o<r.length;o++){if(i=r[o],c=i.instance,m=i.currentTarget,i=i.listener,c!==n&&l.isPropagationStopped())break e;n=i,l.currentTarget=m;try{n(l)}catch(u){Jl(u)}l.currentTarget=null,n=c}}}}function P(e,t){var a=t[So];a===void 0&&(a=t[So]=new Set);var r=e+"__bubble";a.has(r)||(H0(t,e,2,!1),a.add(r))}function co(e,t,a){var r=0;t&&(r|=4),H0(a,e,r,t)}var fl="_reactListening"+Math.random().toString(36).slice(2);function nc(e){if(!e[fl]){e[fl]=!0,zu.forEach(function(a){a!=="selectionchange"&&(Ox.has(a)||co(a,!1,e),co(a,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[fl]||(t[fl]=!0,co("selectionchange",!1,t))}}function H0(e,t,a,r){switch(W0(t)){case 2:var l=ig;break;case 8:l=cg;break;default:l=dc}a=l.bind(null,t,a,e),l=void 0,!Co||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(l=!0),r?l!==void 0?e.addEventListener(t,a,{capture:!0,passive:l}):e.addEventListener(t,a,!0):l!==void 0?e.addEventListener(t,a,{passive:l}):e.addEventListener(t,a,!1)}function uo(e,t,a,r,l){var n=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var i=r.stateNode.containerInfo;if(i===l)break;if(o===4)for(o=r.return;o!==null;){var c=o.tag;if((c===3||c===4)&&o.stateNode.containerInfo===l)return;o=o.return}for(;i!==null;){if(o=ls(i),o===null)return;if(c=o.tag,c===5||c===6||c===26||c===27){r=n=o;continue e}i=i.parentNode}}r=r.return}qu(function(){var m=n,u=_i(a),x=[];e:{var f=tm.get(e);if(f!==void 0){var b=xn,j=e;switch(e){case"keypress":if(jl(a)===0)break e;case"keydown":case"keyup":b=Mh;break;case"focusin":j="focus",b=qn;break;case"focusout":j="blur",b=qn;break;case"beforeblur":case"afterblur":b=qn;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":b=Uc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":b=ph;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":b=zh;break;case Pu:case Fu:case Iu:b=vh;break;case em:b=Ah;break;case"scroll":case"scrollend":b=xh;break;case"wheel":b=Dh;break;case"copy":case"cut":case"paste":b=Nh;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":b=Bc;break;case"toggle":case"beforetoggle":b=Hh}var v=(t&4)!==0,S=!v&&(e==="scroll"||e==="scrollend"),h=v?f!==null?f+"Capture":null:f;v=[];for(var d=m,p;d!==null;){var y=d;if(p=y.stateNode,y=y.tag,y!==5&&y!==26&&y!==27||p===null||h===null||(y=Nr(d,h),y!=null&&v.push(Mr(d,y,p))),S)break;d=d.return}0<v.length&&(f=new b(f,j,null,a,u),x.push({event:f,listeners:v}))}}if(!(t&7)){e:{if(f=e==="mouseover"||e==="pointerover",b=e==="mouseout"||e==="pointerout",f&&a!==ko&&(j=a.relatedTarget||a.fromElement)&&(ls(j)||j[Ds]))break e;if((b||f)&&(f=u.window===u?u:(f=u.ownerDocument)?f.defaultView||f.parentWindow:window,b?(j=a.relatedTarget||a.toElement,b=m,j=j?ls(j):null,j!==null&&(S=Dr(j),v=j.tag,j!==S||v!==5&&v!==27&&v!==6)&&(j=null)):(b=null,j=m),b!==j)){if(v=Uc,y="onMouseLeave",h="onMouseEnter",d="mouse",(e==="pointerout"||e==="pointerover")&&(v=Bc,y="onPointerLeave",h="onPointerEnter",d="pointer"),S=b==null?f:rr(b),p=j==null?f:rr(j),f=new v(y,d+"leave",b,a,u),f.target=S,f.relatedTarget=p,y=null,ls(u)===m&&(v=new v(h,d+"enter",j,a,u),v.target=p,v.relatedTarget=S,y=v),S=y,b&&j)t:{for(v=b,h=j,d=0,p=v;p;p=Pa(p))d++;for(p=0,y=h;y;y=Pa(y))p++;for(;0<d-p;)v=Pa(v),d--;for(;0<p-d;)h=Pa(h),p--;for(;d--;){if(v===h||h!==null&&v===h.alternate)break t;v=Pa(v),h=Pa(h)}v=null}else v=null;b!==null&&Td(x,f,b,v,!1),j!==null&&S!==null&&Td(x,S,j,v,!0)}}e:{if(f=m?rr(m):window,b=f.nodeName&&f.nodeName.toLowerCase(),b==="select"||b==="input"&&f.type==="file")var E=Qc;else if(Gc(f))if(Xu)E=Jh;else{E=Xh;var w=$h}else b=f.nodeName,!b||b.toLowerCase()!=="input"||f.type!=="checkbox"&&f.type!=="radio"?m&&Ei(m.elementType)&&(E=Qc):E=Zh;if(E&&(E=E(e,m))){$u(x,E,a,u);break e}w&&w(e,f,m),e==="focusout"&&m&&f.type==="number"&&m.memoizedProps.value!=null&&_o(f,"number",f.value)}switch(w=m?rr(m):window,e){case"focusin":(Gc(w)||w.contentEditable==="true")&&(is=w,Mo=m,cr=null);break;case"focusout":cr=Mo=is=null;break;case"mousedown":Ro=!0;break;case"contextmenu":case"mouseup":case"dragend":Ro=!1,Jc(x,a,u);break;case"selectionchange":if(Wh)break;case"keydown":case"keyup":Jc(x,a,u)}var N;if(Mi)e:{switch(e){case"compositionstart":var R="onCompositionStart";break e;case"compositionend":R="onCompositionEnd";break e;case"compositionupdate":R="onCompositionUpdate";break e}R=void 0}else os?Qu(e,a)&&(R="onCompositionEnd"):e==="keydown"&&a.keyCode===229&&(R="onCompositionStart");R&&(Gu&&a.locale!=="ko"&&(os||R!=="onCompositionStart"?R==="onCompositionEnd"&&os&&(N=Vu()):(ha=u,ki="value"in ha?ha.value:ha.textContent,os=!0)),w=an(m,R),0<w.length&&(R=new Hc(R,e,null,a,u),x.push({event:R,listeners:w}),N?R.data=N:(N=Yu(a),N!==null&&(R.data=N)))),(N=qh?Vh(e,a):Gh(e,a))&&(R=an(m,"onBeforeInput"),0<R.length&&(w=new Hc("onBeforeInput","beforeinput",null,a,u),x.push({event:w,listeners:R}),w.data=N)),zx(x,e,m,a,u)}U0(x,t)})}function Mr(e,t,a){return{instance:e,listener:t,currentTarget:a}}function an(e,t){for(var a=t+"Capture",r=[];e!==null;){var l=e,n=l.stateNode;if(l=l.tag,l!==5&&l!==26&&l!==27||n===null||(l=Nr(e,a),l!=null&&r.unshift(Mr(e,l,n)),l=Nr(e,t),l!=null&&r.push(Mr(e,l,n))),e.tag===3)return r;e=e.return}return[]}function Pa(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Td(e,t,a,r,l){for(var n=t._reactName,o=[];a!==null&&a!==r;){var i=a,c=i.alternate,m=i.stateNode;if(i=i.tag,c!==null&&c===r)break;i!==5&&i!==26&&i!==27||m===null||(c=m,l?(m=Nr(a,n),m!=null&&o.unshift(Mr(a,m,c))):l||(m=Nr(a,n),m!=null&&o.push(Mr(a,m,c)))),a=a.return}o.length!==0&&e.push({event:t,listeners:o})}var Dx=/\r\n?/g,Ux=/\u0000|\uFFFD/g;function zd(e){return(typeof e=="string"?e:""+e).replace(Dx,`
`).replace(Ux,"")}function B0(e,t){return t=zd(t),zd(e)===t}function kn(){}function le(e,t,a,r,l,n){switch(a){case"children":typeof r=="string"?t==="body"||t==="textarea"&&r===""||_s(e,r):(typeof r=="number"||typeof r=="bigint")&&t!=="body"&&_s(e,""+r);break;case"className":nl(e,"class",r);break;case"tabIndex":nl(e,"tabindex",r);break;case"dir":case"role":case"viewBox":case"width":case"height":nl(e,a,r);break;case"style":Bu(e,r,n);break;case"data":if(t!=="object"){nl(e,"data",r);break}case"src":case"href":if(r===""&&(t!=="a"||a!=="href")){e.removeAttribute(a);break}if(r==null||typeof r=="function"||typeof r=="symbol"||typeof r=="boolean"){e.removeAttribute(a);break}r=yl(""+r),e.setAttribute(a,r);break;case"action":case"formAction":if(typeof r=="function"){e.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof n=="function"&&(a==="formAction"?(t!=="input"&&le(e,t,"name",l.name,l,null),le(e,t,"formEncType",l.formEncType,l,null),le(e,t,"formMethod",l.formMethod,l,null),le(e,t,"formTarget",l.formTarget,l,null)):(le(e,t,"encType",l.encType,l,null),le(e,t,"method",l.method,l,null),le(e,t,"target",l.target,l,null)));if(r==null||typeof r=="symbol"||typeof r=="boolean"){e.removeAttribute(a);break}r=yl(""+r),e.setAttribute(a,r);break;case"onClick":r!=null&&(e.onclick=kn);break;case"onScroll":r!=null&&P("scroll",e);break;case"onScrollEnd":r!=null&&P("scrollend",e);break;case"dangerouslySetInnerHTML":if(r!=null){if(typeof r!="object"||!("__html"in r))throw Error(L(61));if(a=r.__html,a!=null){if(l.children!=null)throw Error(L(60));e.innerHTML=a}}break;case"multiple":e.multiple=r&&typeof r!="function"&&typeof r!="symbol";break;case"muted":e.muted=r&&typeof r!="function"&&typeof r!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(r==null||typeof r=="function"||typeof r=="boolean"||typeof r=="symbol"){e.removeAttribute("xlink:href");break}a=yl(""+r),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":r!=null&&typeof r!="function"&&typeof r!="symbol"?e.setAttribute(a,""+r):e.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":r&&typeof r!="function"&&typeof r!="symbol"?e.setAttribute(a,""):e.removeAttribute(a);break;case"capture":case"download":r===!0?e.setAttribute(a,""):r!==!1&&r!=null&&typeof r!="function"&&typeof r!="symbol"?e.setAttribute(a,r):e.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":r!=null&&typeof r!="function"&&typeof r!="symbol"&&!isNaN(r)&&1<=r?e.setAttribute(a,r):e.removeAttribute(a);break;case"rowSpan":case"start":r==null||typeof r=="function"||typeof r=="symbol"||isNaN(r)?e.removeAttribute(a):e.setAttribute(a,r);break;case"popover":P("beforetoggle",e),P("toggle",e),bl(e,"popover",r);break;case"xlinkActuate":Ht(e,"http://www.w3.org/1999/xlink","xlink:actuate",r);break;case"xlinkArcrole":Ht(e,"http://www.w3.org/1999/xlink","xlink:arcrole",r);break;case"xlinkRole":Ht(e,"http://www.w3.org/1999/xlink","xlink:role",r);break;case"xlinkShow":Ht(e,"http://www.w3.org/1999/xlink","xlink:show",r);break;case"xlinkTitle":Ht(e,"http://www.w3.org/1999/xlink","xlink:title",r);break;case"xlinkType":Ht(e,"http://www.w3.org/1999/xlink","xlink:type",r);break;case"xmlBase":Ht(e,"http://www.w3.org/XML/1998/namespace","xml:base",r);break;case"xmlLang":Ht(e,"http://www.w3.org/XML/1998/namespace","xml:lang",r);break;case"xmlSpace":Ht(e,"http://www.w3.org/XML/1998/namespace","xml:space",r);break;case"is":bl(e,"is",r);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=fh.get(a)||a,bl(e,a,r))}}function ti(e,t,a,r,l,n){switch(a){case"style":Bu(e,r,n);break;case"dangerouslySetInnerHTML":if(r!=null){if(typeof r!="object"||!("__html"in r))throw Error(L(61));if(a=r.__html,a!=null){if(l.children!=null)throw Error(L(60));e.innerHTML=a}}break;case"children":typeof r=="string"?_s(e,r):(typeof r=="number"||typeof r=="bigint")&&_s(e,""+r);break;case"onScroll":r!=null&&P("scroll",e);break;case"onScrollEnd":r!=null&&P("scrollend",e);break;case"onClick":r!=null&&(e.onclick=kn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Lu.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(l=a.endsWith("Capture"),t=a.slice(2,l?a.length-7:void 0),n=e[Pe]||null,n=n!=null?n[a]:null,typeof n=="function"&&e.removeEventListener(t,n,l),typeof r=="function")){typeof n!="function"&&n!==null&&(a in e?e[a]=null:e.hasAttribute(a)&&e.removeAttribute(a)),e.addEventListener(t,r,l);break e}a in e?e[a]=r:r===!0?e.setAttribute(a,""):bl(e,a,r)}}}function Be(e,t,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":P("error",e),P("load",e);var r=!1,l=!1,n;for(n in a)if(a.hasOwnProperty(n)){var o=a[n];if(o!=null)switch(n){case"src":r=!0;break;case"srcSet":l=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(L(137,t));default:le(e,t,n,o,a,null)}}l&&le(e,t,"srcSet",a.srcSet,a,null),r&&le(e,t,"src",a.src,a,null);return;case"input":P("invalid",e);var i=n=o=l=null,c=null,m=null;for(r in a)if(a.hasOwnProperty(r)){var u=a[r];if(u!=null)switch(r){case"name":l=u;break;case"type":o=u;break;case"checked":c=u;break;case"defaultChecked":m=u;break;case"value":n=u;break;case"defaultValue":i=u;break;case"children":case"dangerouslySetInnerHTML":if(u!=null)throw Error(L(137,t));break;default:le(e,t,r,u,a,null)}}Du(e,n,i,c,m,o,l,!1),Ul(e);return;case"select":P("invalid",e),r=o=n=null;for(l in a)if(a.hasOwnProperty(l)&&(i=a[l],i!=null))switch(l){case"value":n=i;break;case"defaultValue":o=i;break;case"multiple":r=i;default:le(e,t,l,i,a,null)}t=n,a=o,e.multiple=!!r,t!=null?gs(e,!!r,t,!1):a!=null&&gs(e,!!r,a,!0);return;case"textarea":P("invalid",e),n=l=r=null;for(o in a)if(a.hasOwnProperty(o)&&(i=a[o],i!=null))switch(o){case"value":r=i;break;case"defaultValue":l=i;break;case"children":n=i;break;case"dangerouslySetInnerHTML":if(i!=null)throw Error(L(91));break;default:le(e,t,o,i,a,null)}Hu(e,r,l,n),Ul(e);return;case"option":for(c in a)if(a.hasOwnProperty(c)&&(r=a[c],r!=null))switch(c){case"selected":e.selected=r&&typeof r!="function"&&typeof r!="symbol";break;default:le(e,t,c,r,a,null)}return;case"dialog":P("beforetoggle",e),P("toggle",e),P("cancel",e),P("close",e);break;case"iframe":case"object":P("load",e);break;case"video":case"audio":for(r=0;r<Cr.length;r++)P(Cr[r],e);break;case"image":P("error",e),P("load",e);break;case"details":P("toggle",e);break;case"embed":case"source":case"link":P("error",e),P("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(m in a)if(a.hasOwnProperty(m)&&(r=a[m],r!=null))switch(m){case"children":case"dangerouslySetInnerHTML":throw Error(L(137,t));default:le(e,t,m,r,a,null)}return;default:if(Ei(t)){for(u in a)a.hasOwnProperty(u)&&(r=a[u],r!==void 0&&ti(e,t,u,r,a,void 0));return}}for(i in a)a.hasOwnProperty(i)&&(r=a[i],r!=null&&le(e,t,i,r,a,null))}function Hx(e,t,a,r){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var l=null,n=null,o=null,i=null,c=null,m=null,u=null;for(b in a){var x=a[b];if(a.hasOwnProperty(b)&&x!=null)switch(b){case"checked":break;case"value":break;case"defaultValue":c=x;default:r.hasOwnProperty(b)||le(e,t,b,null,r,x)}}for(var f in r){var b=r[f];if(x=a[f],r.hasOwnProperty(f)&&(b!=null||x!=null))switch(f){case"type":n=b;break;case"name":l=b;break;case"checked":m=b;break;case"defaultChecked":u=b;break;case"value":o=b;break;case"defaultValue":i=b;break;case"children":case"dangerouslySetInnerHTML":if(b!=null)throw Error(L(137,t));break;default:b!==x&&le(e,t,f,b,r,x)}}Eo(e,o,i,c,m,u,n,l);return;case"select":b=o=i=f=null;for(n in a)if(c=a[n],a.hasOwnProperty(n)&&c!=null)switch(n){case"value":break;case"multiple":b=c;default:r.hasOwnProperty(n)||le(e,t,n,null,r,c)}for(l in r)if(n=r[l],c=a[l],r.hasOwnProperty(l)&&(n!=null||c!=null))switch(l){case"value":f=n;break;case"defaultValue":i=n;break;case"multiple":o=n;default:n!==c&&le(e,t,l,n,r,c)}t=i,a=o,r=b,f!=null?gs(e,!!a,f,!1):!!r!=!!a&&(t!=null?gs(e,!!a,t,!0):gs(e,!!a,a?[]:"",!1));return;case"textarea":b=f=null;for(i in a)if(l=a[i],a.hasOwnProperty(i)&&l!=null&&!r.hasOwnProperty(i))switch(i){case"value":break;case"children":break;default:le(e,t,i,null,r,l)}for(o in r)if(l=r[o],n=a[o],r.hasOwnProperty(o)&&(l!=null||n!=null))switch(o){case"value":f=l;break;case"defaultValue":b=l;break;case"children":break;case"dangerouslySetInnerHTML":if(l!=null)throw Error(L(91));break;default:l!==n&&le(e,t,o,l,r,n)}Uu(e,f,b);return;case"option":for(var j in a)if(f=a[j],a.hasOwnProperty(j)&&f!=null&&!r.hasOwnProperty(j))switch(j){case"selected":e.selected=!1;break;default:le(e,t,j,null,r,f)}for(c in r)if(f=r[c],b=a[c],r.hasOwnProperty(c)&&f!==b&&(f!=null||b!=null))switch(c){case"selected":e.selected=f&&typeof f!="function"&&typeof f!="symbol";break;default:le(e,t,c,f,r,b)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var v in a)f=a[v],a.hasOwnProperty(v)&&f!=null&&!r.hasOwnProperty(v)&&le(e,t,v,null,r,f);for(m in r)if(f=r[m],b=a[m],r.hasOwnProperty(m)&&f!==b&&(f!=null||b!=null))switch(m){case"children":case"dangerouslySetInnerHTML":if(f!=null)throw Error(L(137,t));break;default:le(e,t,m,f,r,b)}return;default:if(Ei(t)){for(var S in a)f=a[S],a.hasOwnProperty(S)&&f!==void 0&&!r.hasOwnProperty(S)&&ti(e,t,S,void 0,r,f);for(u in r)f=r[u],b=a[u],!r.hasOwnProperty(u)||f===b||f===void 0&&b===void 0||ti(e,t,u,f,r,b);return}}for(var h in a)f=a[h],a.hasOwnProperty(h)&&f!=null&&!r.hasOwnProperty(h)&&le(e,t,h,null,r,f);for(x in r)f=r[x],b=a[x],!r.hasOwnProperty(x)||f===b||f==null&&b==null||le(e,t,x,f,r,b)}var ai=null,si=null;function sn(e){return e.nodeType===9?e:e.ownerDocument}function Ld(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function q0(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function ri(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var mo=null;function Bx(){var e=window.event;return e&&e.type==="popstate"?e===mo?!1:(mo=e,!0):(mo=null,!1)}var V0=typeof setTimeout=="function"?setTimeout:void 0,qx=typeof clearTimeout=="function"?clearTimeout:void 0,Ad=typeof Promise=="function"?Promise:void 0,Vx=typeof queueMicrotask=="function"?queueMicrotask:typeof Ad<"u"?function(e){return Ad.resolve(null).then(e).catch(Gx)}:V0;function Gx(e){setTimeout(function(){throw e})}function Ma(e){return e==="head"}function Od(e,t){var a=t,r=0,l=0;do{var n=a.nextSibling;if(e.removeChild(a),n&&n.nodeType===8)if(a=n.data,a==="/$"){if(0<r&&8>r){a=r;var o=e.ownerDocument;if(a&1&&vr(o.documentElement),a&2&&vr(o.body),a&4)for(a=o.head,vr(a),o=a.firstChild;o;){var i=o.nextSibling,c=o.nodeName;o[qr]||c==="SCRIPT"||c==="STYLE"||c==="LINK"&&o.rel.toLowerCase()==="stylesheet"||a.removeChild(o),o=i}}if(l===0){e.removeChild(n),Ar(t);return}l--}else a==="$"||a==="$?"||a==="$!"?l++:r=a.charCodeAt(0)-48;else r=0;a=n}while(a);Ar(t)}function li(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var a=t;switch(t=t.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":li(a),Si(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}e.removeChild(a)}}function Qx(e,t,a,r){for(;e.nodeType===1;){var l=a;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(r){if(!e[qr])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(n=e.getAttribute("rel"),n==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(n!==l.rel||e.getAttribute("href")!==(l.href==null||l.href===""?null:l.href)||e.getAttribute("crossorigin")!==(l.crossOrigin==null?null:l.crossOrigin)||e.getAttribute("title")!==(l.title==null?null:l.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(n=e.getAttribute("src"),(n!==(l.src==null?null:l.src)||e.getAttribute("type")!==(l.type==null?null:l.type)||e.getAttribute("crossorigin")!==(l.crossOrigin==null?null:l.crossOrigin))&&n&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var n=l.name==null?null:""+l.name;if(l.type==="hidden"&&e.getAttribute("name")===n)return e}else return e;if(e=vt(e.nextSibling),e===null)break}return null}function Yx(e,t,a){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!a||(e=vt(e.nextSibling),e===null))return null;return e}function ni(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState==="complete"}function $x(e,t){var a=e.ownerDocument;if(e.data!=="$?"||a.readyState==="complete")t();else{var r=function(){t(),a.removeEventListener("DOMContentLoaded",r)};a.addEventListener("DOMContentLoaded",r),e._reactRetry=r}}function vt(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="F!"||t==="F")break;if(t==="/$")return null}}return e}var oi=null;function Dd(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="$"||a==="$!"||a==="$?"){if(t===0)return e;t--}else a==="/$"&&t++}e=e.previousSibling}return null}function G0(e,t,a){switch(t=sn(a),e){case"html":if(e=t.documentElement,!e)throw Error(L(452));return e;case"head":if(e=t.head,!e)throw Error(L(453));return e;case"body":if(e=t.body,!e)throw Error(L(454));return e;default:throw Error(L(451))}}function vr(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Si(e)}var bt=new Map,Ud=new Set;function rn(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var aa=ae.d;ae.d={f:Xx,r:Zx,D:Jx,C:Kx,L:Wx,m:Px,X:Ix,S:Fx,M:eg};function Xx(){var e=aa.f(),t=Sn();return e||t}function Zx(e){var t=Us(e);t!==null&&t.tag===5&&t.type==="form"?Om(t):aa.r(e)}var qs=typeof document>"u"?null:document;function Q0(e,t,a){var r=qs;if(r&&typeof t=="string"&&t){var l=ht(t);l='link[rel="'+e+'"][href="'+l+'"]',typeof a=="string"&&(l+='[crossorigin="'+a+'"]'),Ud.has(l)||(Ud.add(l),e={rel:e,crossOrigin:a,href:t},r.querySelector(l)===null&&(t=r.createElement("link"),Be(t,"link",e),ze(t),r.head.appendChild(t)))}}function Jx(e){aa.D(e),Q0("dns-prefetch",e,null)}function Kx(e,t){aa.C(e,t),Q0("preconnect",e,t)}function Wx(e,t,a){aa.L(e,t,a);var r=qs;if(r&&e&&t){var l='link[rel="preload"][as="'+ht(t)+'"]';t==="image"&&a&&a.imageSrcSet?(l+='[imagesrcset="'+ht(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(l+='[imagesizes="'+ht(a.imageSizes)+'"]')):l+='[href="'+ht(e)+'"]';var n=l;switch(t){case"style":n=As(e);break;case"script":n=Vs(e)}bt.has(n)||(e=de({rel:"preload",href:t==="image"&&a&&a.imageSrcSet?void 0:e,as:t},a),bt.set(n,e),r.querySelector(l)!==null||t==="style"&&r.querySelector(Wr(n))||t==="script"&&r.querySelector(Pr(n))||(t=r.createElement("link"),Be(t,"link",e),ze(t),r.head.appendChild(t)))}}function Px(e,t){aa.m(e,t);var a=qs;if(a&&e){var r=t&&typeof t.as=="string"?t.as:"script",l='link[rel="modulepreload"][as="'+ht(r)+'"][href="'+ht(e)+'"]',n=l;switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":n=Vs(e)}if(!bt.has(n)&&(e=de({rel:"modulepreload",href:e},t),bt.set(n,e),a.querySelector(l)===null)){switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Pr(n)))return}r=a.createElement("link"),Be(r,"link",e),ze(r),a.head.appendChild(r)}}}function Fx(e,t,a){aa.S(e,t,a);var r=qs;if(r&&e){var l=xs(r).hoistableStyles,n=As(e);t=t||"default";var o=l.get(n);if(!o){var i={loading:0,preload:null};if(o=r.querySelector(Wr(n)))i.loading=5;else{e=de({rel:"stylesheet",href:e,"data-precedence":t},a),(a=bt.get(n))&&oc(e,a);var c=o=r.createElement("link");ze(c),Be(c,"link",e),c._p=new Promise(function(m,u){c.onload=m,c.onerror=u}),c.addEventListener("load",function(){i.loading|=1}),c.addEventListener("error",function(){i.loading|=2}),i.loading|=4,Cl(o,t,r)}o={type:"stylesheet",instance:o,count:1,state:i},l.set(n,o)}}}function Ix(e,t){aa.X(e,t);var a=qs;if(a&&e){var r=xs(a).hoistableScripts,l=Vs(e),n=r.get(l);n||(n=a.querySelector(Pr(l)),n||(e=de({src:e,async:!0},t),(t=bt.get(l))&&ic(e,t),n=a.createElement("script"),ze(n),Be(n,"link",e),a.head.appendChild(n)),n={type:"script",instance:n,count:1,state:null},r.set(l,n))}}function eg(e,t){aa.M(e,t);var a=qs;if(a&&e){var r=xs(a).hoistableScripts,l=Vs(e),n=r.get(l);n||(n=a.querySelector(Pr(l)),n||(e=de({src:e,async:!0,type:"module"},t),(t=bt.get(l))&&ic(e,t),n=a.createElement("script"),ze(n),Be(n,"link",e),a.head.appendChild(n)),n={type:"script",instance:n,count:1,state:null},r.set(l,n))}}function Hd(e,t,a,r){var l=(l=pa.current)?rn(l):null;if(!l)throw Error(L(446));switch(e){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(t=As(a.href),a=xs(l).hoistableStyles,r=a.get(t),r||(r={type:"style",instance:null,count:0,state:null},a.set(t,r)),r):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){e=As(a.href);var n=xs(l).hoistableStyles,o=n.get(e);if(o||(l=l.ownerDocument||l,o={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},n.set(e,o),(n=l.querySelector(Wr(e)))&&!n._p&&(o.instance=n,o.state.loading=5),bt.has(e)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},bt.set(e,a),n||tg(l,e,a,o.state))),t&&r===null)throw Error(L(528,""));return o}if(t&&r!==null)throw Error(L(529,""));return null;case"script":return t=a.async,a=a.src,typeof a=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Vs(a),a=xs(l).hoistableScripts,r=a.get(t),r||(r={type:"script",instance:null,count:0,state:null},a.set(t,r)),r):{type:"void",instance:null,count:0,state:null};default:throw Error(L(444,e))}}function As(e){return'href="'+ht(e)+'"'}function Wr(e){return'link[rel="stylesheet"]['+e+"]"}function Y0(e){return de({},e,{"data-precedence":e.precedence,precedence:null})}function tg(e,t,a,r){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?r.loading=1:(t=e.createElement("link"),r.preload=t,t.addEventListener("load",function(){return r.loading|=1}),t.addEventListener("error",function(){return r.loading|=2}),Be(t,"link",a),ze(t),e.head.appendChild(t))}function Vs(e){return'[src="'+ht(e)+'"]'}function Pr(e){return"script[async]"+e}function Bd(e,t,a){if(t.count++,t.instance===null)switch(t.type){case"style":var r=e.querySelector('style[data-href~="'+ht(a.href)+'"]');if(r)return t.instance=r,ze(r),r;var l=de({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement("style"),ze(r),Be(r,"style",l),Cl(r,a.precedence,e),t.instance=r;case"stylesheet":l=As(a.href);var n=e.querySelector(Wr(l));if(n)return t.state.loading|=4,t.instance=n,ze(n),n;r=Y0(a),(l=bt.get(l))&&oc(r,l),n=(e.ownerDocument||e).createElement("link"),ze(n);var o=n;return o._p=new Promise(function(i,c){o.onload=i,o.onerror=c}),Be(n,"link",r),t.state.loading|=4,Cl(n,a.precedence,e),t.instance=n;case"script":return n=Vs(a.src),(l=e.querySelector(Pr(n)))?(t.instance=l,ze(l),l):(r=a,(l=bt.get(n))&&(r=de({},a),ic(r,l)),e=e.ownerDocument||e,l=e.createElement("script"),ze(l),Be(l,"link",r),e.head.appendChild(l),t.instance=l);case"void":return null;default:throw Error(L(443,t.type))}else t.type==="stylesheet"&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Cl(r,a.precedence,e));return t.instance}function Cl(e,t,a){for(var r=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),l=r.length?r[r.length-1]:null,n=l,o=0;o<r.length;o++){var i=r[o];if(i.dataset.precedence===t)n=i;else if(n!==l)break}n?n.parentNode.insertBefore(e,n.nextSibling):(t=a.nodeType===9?a.head:a,t.insertBefore(e,t.firstChild))}function oc(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function ic(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Ml=null;function qd(e,t,a){if(Ml===null){var r=new Map,l=Ml=new Map;l.set(a,r)}else l=Ml,r=l.get(a),r||(r=new Map,l.set(a,r));if(r.has(e))return r;for(r.set(e,null),a=a.getElementsByTagName(e),l=0;l<a.length;l++){var n=a[l];if(!(n[qr]||n[qe]||e==="link"&&n.getAttribute("rel")==="stylesheet")&&n.namespaceURI!=="http://www.w3.org/2000/svg"){var o=n.getAttribute(t)||"";o=e+o;var i=r.get(o);i?i.push(n):r.set(o,[n])}}return r}function Vd(e,t,a){e=e.ownerDocument||e,e.head.insertBefore(a,t==="title"?e.querySelector("head > title"):null)}function ag(e,t,a){if(a===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function $0(e){return!(e.type==="stylesheet"&&!(e.state.loading&3))}var Rr=null;function sg(){}function rg(e,t,a){if(Rr===null)throw Error(L(475));var r=Rr;if(t.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&!(t.state.loading&4)){if(t.instance===null){var l=As(a.href),n=e.querySelector(Wr(l));if(n){e=n._p,e!==null&&typeof e=="object"&&typeof e.then=="function"&&(r.count++,r=ln.bind(r),e.then(r,r)),t.state.loading|=4,t.instance=n,ze(n);return}n=e.ownerDocument||e,a=Y0(a),(l=bt.get(l))&&oc(a,l),n=n.createElement("link"),ze(n);var o=n;o._p=new Promise(function(i,c){o.onload=i,o.onerror=c}),Be(n,"link",a),t.instance=n}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(t,e),(e=t.state.preload)&&!(t.state.loading&3)&&(r.count++,t=ln.bind(r),e.addEventListener("load",t),e.addEventListener("error",t))}}function lg(){if(Rr===null)throw Error(L(475));var e=Rr;return e.stylesheets&&e.count===0&&ii(e,e.stylesheets),0<e.count?function(t){var a=setTimeout(function(){if(e.stylesheets&&ii(e,e.stylesheets),e.unsuspend){var r=e.unsuspend;e.unsuspend=null,r()}},6e4);return e.unsuspend=t,function(){e.unsuspend=null,clearTimeout(a)}}:null}function ln(){if(this.count--,this.count===0){if(this.stylesheets)ii(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var nn=null;function ii(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,nn=new Map,t.forEach(ng,e),nn=null,ln.call(e))}function ng(e,t){if(!(t.state.loading&4)){var a=nn.get(e);if(a)var r=a.get(null);else{a=new Map,nn.set(e,a);for(var l=e.querySelectorAll("link[data-precedence],style[data-precedence]"),n=0;n<l.length;n++){var o=l[n];(o.nodeName==="LINK"||o.getAttribute("media")!=="not all")&&(a.set(o.dataset.precedence,o),r=o)}r&&a.set(null,r)}l=t.instance,o=l.getAttribute("data-precedence"),n=a.get(o)||r,n===r&&a.set(null,l),a.set(o,l),this.count++,r=ln.bind(this),l.addEventListener("load",r),l.addEventListener("error",r),n?n.parentNode.insertBefore(l,n.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(l,e.firstChild)),t.state.loading|=4}}var Tr={$$typeof:Qt,Provider:null,Consumer:null,_currentValue:Oa,_currentValue2:Oa,_threadCount:0};function og(e,t,a,r,l,n,o,i){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ln(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ln(0),this.hiddenUpdates=Ln(null),this.identifierPrefix=r,this.onUncaughtError=l,this.onCaughtError=n,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=i,this.incompleteTransitions=new Map}function X0(e,t,a,r,l,n,o,i,c,m,u,x){return e=new og(e,t,a,o,i,c,m,x),t=1,n===!0&&(t|=24),n=st(3,null,null,t),e.current=n,n.stateNode=e,t=Di(),t.refCount++,e.pooledCache=t,t.refCount++,n.memoizedState={element:r,isDehydrated:a,cache:t},Hi(n),e}function Z0(e){return e?(e=us,e):us}function J0(e,t,a,r,l,n){l=Z0(l),r.context===null?r.context=l:r.pendingContext=l,r=ba(t),r.payload={element:a},n=n===void 0?null:n,n!==null&&(r.callback=n),a=ya(e,r,t),a!==null&&(ot(a,e,t),mr(a,e,t))}function Gd(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var a=e.retryLane;e.retryLane=a!==0&&a<t?a:t}}function cc(e,t){Gd(e,t),(e=e.alternate)&&Gd(e,t)}function K0(e){if(e.tag===13){var t=Hs(e,67108864);t!==null&&ot(t,e,67108864),cc(e,67108864)}}var on=!0;function ig(e,t,a,r){var l=Y.T;Y.T=null;var n=ae.p;try{ae.p=2,dc(e,t,a,r)}finally{ae.p=n,Y.T=l}}function cg(e,t,a,r){var l=Y.T;Y.T=null;var n=ae.p;try{ae.p=8,dc(e,t,a,r)}finally{ae.p=n,Y.T=l}}function dc(e,t,a,r){if(on){var l=ci(r);if(l===null)uo(e,t,r,cn,a),Qd(e,r);else if(ug(l,e,t,a,r))r.stopPropagation();else if(Qd(e,r),t&4&&-1<dg.indexOf(e)){for(;l!==null;){var n=Us(l);if(n!==null)switch(n.tag){case 3:if(n=n.stateNode,n.current.memoizedState.isDehydrated){var o=za(n.pendingLanes);if(o!==0){var i=n;for(i.pendingLanes|=2,i.entangledLanes|=2;o;){var c=1<<31-lt(o);i.entanglements[1]|=c,o&=~c}Dt(n),!(re&6)&&(Fl=Lt()+500,Kr(0))}}break;case 13:i=Hs(n,2),i!==null&&ot(i,n,2),Sn(),cc(n,2)}if(n=ci(r),n===null&&uo(e,t,r,cn,a),n===l)break;l=n}l!==null&&r.stopPropagation()}else uo(e,t,r,null,a)}}function ci(e){return e=_i(e),uc(e)}var cn=null;function uc(e){if(cn=null,e=ls(e),e!==null){var t=Dr(e);if(t===null)e=null;else{var a=t.tag;if(a===13){if(e=vu(t),e!==null)return e;e=null}else if(a===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return cn=e,null}function W0(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Kf()){case Su:return 2;case Eu:return 8;case Dl:case Wf:return 32;case _u:return 268435456;default:return 32}default:return 32}}var di=!1,Na=null,wa=null,Sa=null,zr=new Map,Lr=new Map,ma=[],dg="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Qd(e,t){switch(e){case"focusin":case"focusout":Na=null;break;case"dragenter":case"dragleave":wa=null;break;case"mouseover":case"mouseout":Sa=null;break;case"pointerover":case"pointerout":zr.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Lr.delete(t.pointerId)}}function Is(e,t,a,r,l,n){return e===null||e.nativeEvent!==n?(e={blockedOn:t,domEventName:a,eventSystemFlags:r,nativeEvent:n,targetContainers:[l]},t!==null&&(t=Us(t),t!==null&&K0(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,l!==null&&t.indexOf(l)===-1&&t.push(l),e)}function ug(e,t,a,r,l){switch(t){case"focusin":return Na=Is(Na,e,t,a,r,l),!0;case"dragenter":return wa=Is(wa,e,t,a,r,l),!0;case"mouseover":return Sa=Is(Sa,e,t,a,r,l),!0;case"pointerover":var n=l.pointerId;return zr.set(n,Is(zr.get(n)||null,e,t,a,r,l)),!0;case"gotpointercapture":return n=l.pointerId,Lr.set(n,Is(Lr.get(n)||null,e,t,a,r,l)),!0}return!1}function P0(e){var t=ls(e.target);if(t!==null){var a=Dr(t);if(a!==null){if(t=a.tag,t===13){if(t=vu(a),t!==null){e.blockedOn=t,rh(e.priority,function(){if(a.tag===13){var r=nt();r=Ni(r);var l=Hs(a,r);l!==null&&ot(l,a,r),cc(a,r)}});return}}else if(t===3&&a.stateNode.current.memoizedState.isDehydrated){e.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Rl(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var a=ci(e.nativeEvent);if(a===null){a=e.nativeEvent;var r=new a.constructor(a.type,a);ko=r,a.target.dispatchEvent(r),ko=null}else return t=Us(a),t!==null&&K0(t),e.blockedOn=a,!1;t.shift()}return!0}function Yd(e,t,a){Rl(e)&&a.delete(t)}function mg(){di=!1,Na!==null&&Rl(Na)&&(Na=null),wa!==null&&Rl(wa)&&(wa=null),Sa!==null&&Rl(Sa)&&(Sa=null),zr.forEach(Yd),Lr.forEach(Yd)}function hl(e,t){e.blockedOn===t&&(e.blockedOn=null,di||(di=!0,Re.unstable_scheduleCallback(Re.unstable_NormalPriority,mg)))}var xl=null;function $d(e){xl!==e&&(xl=e,Re.unstable_scheduleCallback(Re.unstable_NormalPriority,function(){xl===e&&(xl=null);for(var t=0;t<e.length;t+=3){var a=e[t],r=e[t+1],l=e[t+2];if(typeof r!="function"){if(uc(r||a)===null)continue;break}var n=Us(a);n!==null&&(e.splice(t,3),t-=3,Qo(n,{pending:!0,data:l,method:a.method,action:r},r,l))}}))}function Ar(e){function t(c){return hl(c,e)}Na!==null&&hl(Na,e),wa!==null&&hl(wa,e),Sa!==null&&hl(Sa,e),zr.forEach(t),Lr.forEach(t);for(var a=0;a<ma.length;a++){var r=ma[a];r.blockedOn===e&&(r.blockedOn=null)}for(;0<ma.length&&(a=ma[0],a.blockedOn===null);)P0(a),a.blockedOn===null&&ma.shift();if(a=(e.ownerDocument||e).$$reactFormReplay,a!=null)for(r=0;r<a.length;r+=3){var l=a[r],n=a[r+1],o=l[Pe]||null;if(typeof n=="function")o||$d(a);else if(o){var i=null;if(n&&n.hasAttribute("formAction")){if(l=n,o=n[Pe]||null)i=o.formAction;else if(uc(l)!==null)continue}else i=o.action;typeof i=="function"?a[r+1]=i:(a.splice(r,3),r-=3),$d(a)}}}function mc(e){this._internalRoot=e}Cn.prototype.render=mc.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(L(409));var a=t.current,r=nt();J0(a,r,e,t,null,null)};Cn.prototype.unmount=mc.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;J0(e.current,2,null,e,null,null),Sn(),t[Ds]=null}};function Cn(e){this._internalRoot=e}Cn.prototype.unstable_scheduleHydration=function(e){if(e){var t=Tu();e={blockedOn:null,target:e,priority:t};for(var a=0;a<ma.length&&t!==0&&t<ma[a].priority;a++);ma.splice(a,0,e),a===0&&P0(e)}};var Xd=bu.version;if(Xd!=="19.1.1")throw Error(L(527,Xd,"19.1.1"));ae.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(L(188)):(e=Object.keys(e).join(","),Error(L(268,e)));return e=Gf(t),e=e!==null?ju(e):null,e=e===null?null:e.stateNode,e};var fg={bundleType:0,version:"19.1.1",rendererPackageName:"react-dom",currentDispatcherRef:Y,reconcilerVersion:"19.1.1"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var gl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!gl.isDisabled&&gl.supportsFiber)try{Ur=gl.inject(fg),rt=gl}catch{}}mn.createRoot=function(e,t){if(!yu(e))throw Error(L(299));var a=!1,r="",l=Xm,n=Zm,o=Jm,i=null;return t!=null&&(t.unstable_strictMode===!0&&(a=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(l=t.onUncaughtError),t.onCaughtError!==void 0&&(n=t.onCaughtError),t.onRecoverableError!==void 0&&(o=t.onRecoverableError),t.unstable_transitionCallbacks!==void 0&&(i=t.unstable_transitionCallbacks)),t=X0(e,1,!1,null,null,a,r,l,n,o,i,null),e[Ds]=t.current,nc(e),new mc(t)};mn.hydrateRoot=function(e,t,a){if(!yu(e))throw Error(L(299));var r=!1,l="",n=Xm,o=Zm,i=Jm,c=null,m=null;return a!=null&&(a.unstable_strictMode===!0&&(r=!0),a.identifierPrefix!==void 0&&(l=a.identifierPrefix),a.onUncaughtError!==void 0&&(n=a.onUncaughtError),a.onCaughtError!==void 0&&(o=a.onCaughtError),a.onRecoverableError!==void 0&&(i=a.onRecoverableError),a.unstable_transitionCallbacks!==void 0&&(c=a.unstable_transitionCallbacks),a.formState!==void 0&&(m=a.formState)),t=X0(e,1,!0,t,a??null,r,l,n,o,i,c,m),t.context=Z0(null),a=t.current,r=nt(),r=Ni(r),l=ba(r),l.callback=null,ya(a,l,r),a=r,t.current.lanes=a,Br(t,a),Dt(t),e[Ds]=t.current,nc(e),new Cn(t)};mn.version="19.1.1";function F0(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(F0)}catch(e){console.error(e)}}F0(),mu.exports=mn;var hg=mu.exports;/**
 * react-router v7.8.2
 *
 * Copyright (c) Remix Software Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */var Zd="popstate";function xg(e={}){function t(r,l){let{pathname:n,search:o,hash:i}=r.location;return ui("",{pathname:n,search:o,hash:i},l.state&&l.state.usr||null,l.state&&l.state.key||"default")}function a(r,l){return typeof l=="string"?l:Or(l)}return pg(t,a,null,e)}function xe(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function jt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function gg(){return Math.random().toString(36).substring(2,10)}function Jd(e,t){return{usr:e.state,key:e.key,idx:t}}function ui(e,t,a=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Gs(t):t,state:a,key:t&&t.key||r||gg()}}function Or({pathname:e="/",search:t="",hash:a=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),a&&a!=="#"&&(e+=a.charAt(0)==="#"?a:"#"+a),e}function Gs(e){let t={};if(e){let a=e.indexOf("#");a>=0&&(t.hash=e.substring(a),e=e.substring(0,a));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function pg(e,t,a,r={}){let{window:l=document.defaultView,v5Compat:n=!1}=r,o=l.history,i="POP",c=null,m=u();m==null&&(m=0,o.replaceState({...o.state,idx:m},""));function u(){return(o.state||{idx:null}).idx}function x(){i="POP";let S=u(),h=S==null?null:S-m;m=S,c&&c({action:i,location:v.location,delta:h})}function f(S,h){i="PUSH";let d=ui(v.location,S,h);m=u()+1;let p=Jd(d,m),y=v.createHref(d);try{o.pushState(p,"",y)}catch(E){if(E instanceof DOMException&&E.name==="DataCloneError")throw E;l.location.assign(y)}n&&c&&c({action:i,location:v.location,delta:1})}function b(S,h){i="REPLACE";let d=ui(v.location,S,h);m=u();let p=Jd(d,m),y=v.createHref(d);o.replaceState(p,"",y),n&&c&&c({action:i,location:v.location,delta:0})}function j(S){return bg(S)}let v={get action(){return i},get location(){return e(l,o)},listen(S){if(c)throw new Error("A history only accepts one active listener");return l.addEventListener(Zd,x),c=S,()=>{l.removeEventListener(Zd,x),c=null}},createHref(S){return t(l,S)},createURL:j,encodeLocation(S){let h=j(S);return{pathname:h.pathname,search:h.search,hash:h.hash}},push:f,replace:b,go(S){return o.go(S)}};return v}function bg(e,t=!1){let a="http://localhost";typeof window<"u"&&(a=window.location.origin!=="null"?window.location.origin:window.location.href),xe(a,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:Or(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=a+r),new URL(r,a)}function I0(e,t,a="/"){return yg(e,t,a,!1)}function yg(e,t,a,r){let l=typeof t=="string"?Gs(t):t,n=ta(l.pathname||"/",a);if(n==null)return null;let o=ef(e);vg(o);let i=null;for(let c=0;i==null&&c<o.length;++c){let m=Tg(n);i=Mg(o[c],m,r)}return i}function ef(e,t=[],a=[],r="",l=!1){let n=(o,i,c=l,m)=>{let u={relativePath:m===void 0?o.path||"":m,caseSensitive:o.caseSensitive===!0,childrenIndex:i,route:o};if(u.relativePath.startsWith("/")){if(!u.relativePath.startsWith(r)&&c)return;xe(u.relativePath.startsWith(r),`Absolute route path "${u.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),u.relativePath=u.relativePath.slice(r.length)}let x=Wt([r,u.relativePath]),f=a.concat(u);o.children&&o.children.length>0&&(xe(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${x}".`),ef(o.children,t,f,x,c)),!(o.path==null&&!o.index)&&t.push({path:x,score:kg(x,o.index),routesMeta:f})};return e.forEach((o,i)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))n(o,i);else for(let m of tf(o.path))n(o,i,!0,m)}),t}function tf(e){let t=e.split("/");if(t.length===0)return[];let[a,...r]=t,l=a.endsWith("?"),n=a.replace(/\?$/,"");if(r.length===0)return l?[n,""]:[n];let o=tf(r.join("/")),i=[];return i.push(...o.map(c=>c===""?n:[n,c].join("/"))),l&&i.push(...o),i.map(c=>e.startsWith("/")&&c===""?"/":c)}function vg(e){e.sort((t,a)=>t.score!==a.score?a.score-t.score:Cg(t.routesMeta.map(r=>r.childrenIndex),a.routesMeta.map(r=>r.childrenIndex)))}var jg=/^:[\w-]+$/,Ng=3,wg=2,Sg=1,Eg=10,_g=-2,Kd=e=>e==="*";function kg(e,t){let a=e.split("/"),r=a.length;return a.some(Kd)&&(r+=_g),t&&(r+=wg),a.filter(l=>!Kd(l)).reduce((l,n)=>l+(jg.test(n)?Ng:n===""?Sg:Eg),r)}function Cg(e,t){return e.length===t.length&&e.slice(0,-1).every((r,l)=>r===t[l])?e[e.length-1]-t[t.length-1]:0}function Mg(e,t,a=!1){let{routesMeta:r}=e,l={},n="/",o=[];for(let i=0;i<r.length;++i){let c=r[i],m=i===r.length-1,u=n==="/"?t:t.slice(n.length)||"/",x=dn({path:c.relativePath,caseSensitive:c.caseSensitive,end:m},u),f=c.route;if(!x&&m&&a&&!r[r.length-1].route.index&&(x=dn({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},u)),!x)return null;Object.assign(l,x.params),o.push({params:l,pathname:Wt([n,x.pathname]),pathnameBase:Og(Wt([n,x.pathnameBase])),route:f}),x.pathnameBase!=="/"&&(n=Wt([n,x.pathnameBase]))}return o}function dn(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[a,r]=Rg(e.path,e.caseSensitive,e.end),l=t.match(a);if(!l)return null;let n=l[0],o=n.replace(/(.)\/+$/,"$1"),i=l.slice(1);return{params:r.reduce((m,{paramName:u,isOptional:x},f)=>{if(u==="*"){let j=i[f]||"";o=n.slice(0,n.length-j.length).replace(/(.)\/+$/,"$1")}const b=i[f];return x&&!b?m[u]=void 0:m[u]=(b||"").replace(/%2F/g,"/"),m},{}),pathname:n,pathnameBase:o,pattern:e}}function Rg(e,t=!1,a=!0){jt(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],l="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,i,c)=>(r.push({paramName:i,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),l+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?l+="\\/*$":e!==""&&e!=="/"&&(l+="(?:(?=\\/|$))"),[new RegExp(l,t?void 0:"i"),r]}function Tg(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return jt(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function ta(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let a=t.endsWith("/")?t.length-1:t.length,r=e.charAt(a);return r&&r!=="/"?null:e.slice(a)||"/"}function zg(e,t="/"){let{pathname:a,search:r="",hash:l=""}=typeof e=="string"?Gs(e):e;return{pathname:a?a.startsWith("/")?a:Lg(a,t):t,search:Dg(r),hash:Ug(l)}}function Lg(e,t){let a=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(l=>{l===".."?a.length>1&&a.pop():l!=="."&&a.push(l)}),a.length>1?a.join("/"):"/"}function fo(e,t,a,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}].  Please separate it out to the \`to.${a}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Ag(e){return e.filter((t,a)=>a===0||t.route.path&&t.route.path.length>0)}function fc(e){let t=Ag(e);return t.map((a,r)=>r===t.length-1?a.pathname:a.pathnameBase)}function hc(e,t,a,r=!1){let l;typeof e=="string"?l=Gs(e):(l={...e},xe(!l.pathname||!l.pathname.includes("?"),fo("?","pathname","search",l)),xe(!l.pathname||!l.pathname.includes("#"),fo("#","pathname","hash",l)),xe(!l.search||!l.search.includes("#"),fo("#","search","hash",l)));let n=e===""||l.pathname==="",o=n?"/":l.pathname,i;if(o==null)i=a;else{let x=t.length-1;if(!r&&o.startsWith("..")){let f=o.split("/");for(;f[0]==="..";)f.shift(),x-=1;l.pathname=f.join("/")}i=x>=0?t[x]:"/"}let c=zg(l,i),m=o&&o!=="/"&&o.endsWith("/"),u=(n||o===".")&&a.endsWith("/");return!c.pathname.endsWith("/")&&(m||u)&&(c.pathname+="/"),c}var Wt=e=>e.join("/").replace(/\/\/+/g,"/"),Og=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Dg=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Ug=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Hg(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}var af=["POST","PUT","PATCH","DELETE"];new Set(af);var Bg=["GET",...af];new Set(Bg);var Qs=g.createContext(null);Qs.displayName="DataRouter";var Mn=g.createContext(null);Mn.displayName="DataRouterState";g.createContext(!1);var sf=g.createContext({isTransitioning:!1});sf.displayName="ViewTransition";var qg=g.createContext(new Map);qg.displayName="Fetchers";var Vg=g.createContext(null);Vg.displayName="Await";var St=g.createContext(null);St.displayName="Navigation";var Fr=g.createContext(null);Fr.displayName="Location";var Ut=g.createContext({outlet:null,matches:[],isDataRoute:!1});Ut.displayName="Route";var xc=g.createContext(null);xc.displayName="RouteError";function Gg(e,{relative:t}={}){xe(Ys(),"useHref() may be used only in the context of a <Router> component.");let{basename:a,navigator:r}=g.useContext(St),{hash:l,pathname:n,search:o}=Ir(e,{relative:t}),i=n;return a!=="/"&&(i=n==="/"?a:Wt([a,n])),r.createHref({pathname:i,search:o,hash:l})}function Ys(){return g.useContext(Fr)!=null}function Et(){return xe(Ys(),"useLocation() may be used only in the context of a <Router> component."),g.useContext(Fr).location}var rf="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function lf(e){g.useContext(St).static||g.useLayoutEffect(e)}function gc(){let{isDataRoute:e}=g.useContext(Ut);return e?tp():Qg()}function Qg(){xe(Ys(),"useNavigate() may be used only in the context of a <Router> component.");let e=g.useContext(Qs),{basename:t,navigator:a}=g.useContext(St),{matches:r}=g.useContext(Ut),{pathname:l}=Et(),n=JSON.stringify(fc(r)),o=g.useRef(!1);return lf(()=>{o.current=!0}),g.useCallback((c,m={})=>{if(jt(o.current,rf),!o.current)return;if(typeof c=="number"){a.go(c);return}let u=hc(c,JSON.parse(n),l,m.relative==="path");e==null&&t!=="/"&&(u.pathname=u.pathname==="/"?t:Wt([t,u.pathname])),(m.replace?a.replace:a.push)(u,m.state,m)},[t,a,n,l,e])}g.createContext(null);function Ir(e,{relative:t}={}){let{matches:a}=g.useContext(Ut),{pathname:r}=Et(),l=JSON.stringify(fc(a));return g.useMemo(()=>hc(e,JSON.parse(l),r,t==="path"),[e,l,r,t])}function Yg(e,t){return nf(e,t)}function nf(e,t,a,r,l){var d;xe(Ys(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:n}=g.useContext(St),{matches:o}=g.useContext(Ut),i=o[o.length-1],c=i?i.params:{},m=i?i.pathname:"/",u=i?i.pathnameBase:"/",x=i&&i.route;{let p=x&&x.path||"";of(m,!x||p.endsWith("*")||p.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${m}" (under <Route path="${p}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.

Please change the parent <Route path="${p}"> to <Route path="${p==="/"?"*":`${p}/*`}">.`)}let f=Et(),b;if(t){let p=typeof t=="string"?Gs(t):t;xe(u==="/"||((d=p.pathname)==null?void 0:d.startsWith(u)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${u}" but pathname "${p.pathname}" was given in the \`location\` prop.`),b=p}else b=f;let j=b.pathname||"/",v=j;if(u!=="/"){let p=u.replace(/^\//,"").split("/");v="/"+j.replace(/^\//,"").split("/").slice(p.length).join("/")}let S=I0(e,{pathname:v});jt(x||S!=null,`No routes matched location "${b.pathname}${b.search}${b.hash}" `),jt(S==null||S[S.length-1].route.element!==void 0||S[S.length-1].route.Component!==void 0||S[S.length-1].route.lazy!==void 0,`Matched leaf route at location "${b.pathname}${b.search}${b.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let h=Kg(S&&S.map(p=>Object.assign({},p,{params:Object.assign({},c,p.params),pathname:Wt([u,n.encodeLocation?n.encodeLocation(p.pathname).pathname:p.pathname]),pathnameBase:p.pathnameBase==="/"?u:Wt([u,n.encodeLocation?n.encodeLocation(p.pathnameBase).pathname:p.pathnameBase])})),o,a,r,l);return t&&h?g.createElement(Fr.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...b},navigationType:"POP"}},h):h}function $g(){let e=ep(),t=Hg(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),a=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",l={padding:"0.5rem",backgroundColor:r},n={padding:"2px 4px",backgroundColor:r},o=null;return console.error("Error handled by React Router default ErrorBoundary:",e),o=g.createElement(g.Fragment,null,g.createElement("p",null,"💿 Hey developer 👋"),g.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",g.createElement("code",{style:n},"ErrorBoundary")," or"," ",g.createElement("code",{style:n},"errorElement")," prop on your route.")),g.createElement(g.Fragment,null,g.createElement("h2",null,"Unexpected Application Error!"),g.createElement("h3",{style:{fontStyle:"italic"}},t),a?g.createElement("pre",{style:l},a):null,o)}var Xg=g.createElement($g,null),Zg=class extends g.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.unstable_onError?this.props.unstable_onError(e,t):console.error("React Router caught the following error during render",e)}render(){return this.state.error!==void 0?g.createElement(Ut.Provider,{value:this.props.routeContext},g.createElement(xc.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Jg({routeContext:e,match:t,children:a}){let r=g.useContext(Qs);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),g.createElement(Ut.Provider,{value:e},a)}function Kg(e,t=[],a=null,r=null,l=null){if(e==null){if(!a)return null;if(a.errors)e=a.matches;else if(t.length===0&&!a.initialized&&a.matches.length>0)e=a.matches;else return null}let n=e,o=a==null?void 0:a.errors;if(o!=null){let m=n.findIndex(u=>u.route.id&&(o==null?void 0:o[u.route.id])!==void 0);xe(m>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),n=n.slice(0,Math.min(n.length,m+1))}let i=!1,c=-1;if(a)for(let m=0;m<n.length;m++){let u=n[m];if((u.route.HydrateFallback||u.route.hydrateFallbackElement)&&(c=m),u.route.id){let{loaderData:x,errors:f}=a,b=u.route.loader&&!x.hasOwnProperty(u.route.id)&&(!f||f[u.route.id]===void 0);if(u.route.lazy||b){i=!0,c>=0?n=n.slice(0,c+1):n=[n[0]];break}}}return n.reduceRight((m,u,x)=>{let f,b=!1,j=null,v=null;a&&(f=o&&u.route.id?o[u.route.id]:void 0,j=u.route.errorElement||Xg,i&&(c<0&&x===0?(of("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,v=null):c===x&&(b=!0,v=u.route.hydrateFallbackElement||null)));let S=t.concat(n.slice(0,x+1)),h=()=>{let d;return f?d=j:b?d=v:u.route.Component?d=g.createElement(u.route.Component,null):u.route.element?d=u.route.element:d=m,g.createElement(Jg,{match:u,routeContext:{outlet:m,matches:S,isDataRoute:a!=null},children:d})};return a&&(u.route.ErrorBoundary||u.route.errorElement||x===0)?g.createElement(Zg,{location:a.location,revalidation:a.revalidation,component:j,error:f,children:h(),routeContext:{outlet:null,matches:S,isDataRoute:!0},unstable_onError:r}):h()},null)}function pc(e){return`${e} must be used within a data router.  See https://reactrouter.com/en/main/routers/picking-a-router.`}function Wg(e){let t=g.useContext(Qs);return xe(t,pc(e)),t}function Pg(e){let t=g.useContext(Mn);return xe(t,pc(e)),t}function Fg(e){let t=g.useContext(Ut);return xe(t,pc(e)),t}function bc(e){let t=Fg(e),a=t.matches[t.matches.length-1];return xe(a.route.id,`${e} can only be used on routes that contain a unique "id"`),a.route.id}function Ig(){return bc("useRouteId")}function ep(){var r;let e=g.useContext(xc),t=Pg("useRouteError"),a=bc("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[a]}function tp(){let{router:e}=Wg("useNavigate"),t=bc("useNavigate"),a=g.useRef(!1);return lf(()=>{a.current=!0}),g.useCallback(async(l,n={})=>{jt(a.current,rf),a.current&&(typeof l=="number"?e.navigate(l):await e.navigate(l,{fromRouteId:t,...n}))},[e,t])}var Wd={};function of(e,t,a){!t&&!Wd[e]&&(Wd[e]=!0,jt(!1,a))}g.memo(ap);function ap({routes:e,future:t,state:a,unstable_onError:r}){return nf(e,void 0,a,r,t)}function mi({to:e,replace:t,state:a,relative:r}){xe(Ys(),"<Navigate> may be used only in the context of a <Router> component.");let{static:l}=g.useContext(St);jt(!l,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:n}=g.useContext(Ut),{pathname:o}=Et(),i=gc(),c=hc(e,fc(n),o,r==="path"),m=JSON.stringify(c);return g.useEffect(()=>{i(JSON.parse(m),{replace:t,state:a,relative:r})},[i,m,r,t,a]),null}function Qe(e){xe(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function sp({basename:e="/",children:t=null,location:a,navigationType:r="POP",navigator:l,static:n=!1}){xe(!Ys(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let o=e.replace(/^\/*/,"/"),i=g.useMemo(()=>({basename:o,navigator:l,static:n,future:{}}),[o,l,n]);typeof a=="string"&&(a=Gs(a));let{pathname:c="/",search:m="",hash:u="",state:x=null,key:f="default"}=a,b=g.useMemo(()=>{let j=ta(c,o);return j==null?null:{location:{pathname:j,search:m,hash:u,state:x,key:f},navigationType:r}},[o,c,m,u,x,f,r]);return jt(b!=null,`<Router basename="${o}"> is not able to match the URL "${c}${m}${u}" because it does not start with the basename, so the <Router> won't render anything.`),b==null?null:g.createElement(St.Provider,{value:i},g.createElement(Fr.Provider,{children:t,value:b}))}function rp({children:e,location:t}){return Yg(fi(e),t)}function fi(e,t=[]){let a=[];return g.Children.forEach(e,(r,l)=>{if(!g.isValidElement(r))return;let n=[...t,l];if(r.type===g.Fragment){a.push.apply(a,fi(r.props.children,n));return}xe(r.type===Qe,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),xe(!r.props.index||!r.props.children,"An index route cannot have child routes.");let o={id:r.props.id||n.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=fi(r.props.children,n)),a.push(o)}),a}var Tl="get",zl="application/x-www-form-urlencoded";function Rn(e){return e!=null&&typeof e.tagName=="string"}function lp(e){return Rn(e)&&e.tagName.toLowerCase()==="button"}function np(e){return Rn(e)&&e.tagName.toLowerCase()==="form"}function op(e){return Rn(e)&&e.tagName.toLowerCase()==="input"}function ip(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function cp(e,t){return e.button===0&&(!t||t==="_self")&&!ip(e)}var pl=null;function dp(){if(pl===null)try{new FormData(document.createElement("form"),0),pl=!1}catch{pl=!0}return pl}var up=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ho(e){return e!=null&&!up.has(e)?(jt(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${zl}"`),null):e}function mp(e,t){let a,r,l,n,o;if(np(e)){let i=e.getAttribute("action");r=i?ta(i,t):null,a=e.getAttribute("method")||Tl,l=ho(e.getAttribute("enctype"))||zl,n=new FormData(e)}else if(lp(e)||op(e)&&(e.type==="submit"||e.type==="image")){let i=e.form;if(i==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=e.getAttribute("formaction")||i.getAttribute("action");if(r=c?ta(c,t):null,a=e.getAttribute("formmethod")||i.getAttribute("method")||Tl,l=ho(e.getAttribute("formenctype"))||ho(i.getAttribute("enctype"))||zl,n=new FormData(i,e),!dp()){let{name:m,type:u,value:x}=e;if(u==="image"){let f=m?`${m}.`:"";n.append(`${f}x`,"0"),n.append(`${f}y`,"0")}else m&&n.append(m,x)}}else{if(Rn(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');a=Tl,r=null,l=zl,o=e}return n&&l==="text/plain"&&(o=n,n=void 0),{action:r,method:a.toLowerCase(),encType:l,formData:n,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function yc(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function fp(e,t,a){let r=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return r.pathname==="/"?r.pathname=`_root.${a}`:t&&ta(r.pathname,t)==="/"?r.pathname=`${t.replace(/\/$/,"")}/_root.${a}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${a}`,r}async function hp(e,t){if(e.id in t)return t[e.id];try{let a=await import(e.module);return t[e.id]=a,a}catch(a){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(a),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function xp(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function gp(e,t,a){let r=await Promise.all(e.map(async l=>{let n=t.routes[l.route.id];if(n){let o=await hp(n,a);return o.links?o.links():[]}return[]}));return vp(r.flat(1).filter(xp).filter(l=>l.rel==="stylesheet"||l.rel==="preload").map(l=>l.rel==="stylesheet"?{...l,rel:"prefetch",as:"style"}:{...l,rel:"prefetch"}))}function Pd(e,t,a,r,l,n){let o=(c,m)=>a[m]?c.route.id!==a[m].route.id:!0,i=(c,m)=>{var u;return a[m].pathname!==c.pathname||((u=a[m].route.path)==null?void 0:u.endsWith("*"))&&a[m].params["*"]!==c.params["*"]};return n==="assets"?t.filter((c,m)=>o(c,m)||i(c,m)):n==="data"?t.filter((c,m)=>{var x;let u=r.routes[c.route.id];if(!u||!u.hasLoader)return!1;if(o(c,m)||i(c,m))return!0;if(c.route.shouldRevalidate){let f=c.route.shouldRevalidate({currentUrl:new URL(l.pathname+l.search+l.hash,window.origin),currentParams:((x=a[0])==null?void 0:x.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function pp(e,t,{includeHydrateFallback:a}={}){return bp(e.map(r=>{let l=t.routes[r.route.id];if(!l)return[];let n=[l.module];return l.clientActionModule&&(n=n.concat(l.clientActionModule)),l.clientLoaderModule&&(n=n.concat(l.clientLoaderModule)),a&&l.hydrateFallbackModule&&(n=n.concat(l.hydrateFallbackModule)),l.imports&&(n=n.concat(l.imports)),n}).flat(1))}function bp(e){return[...new Set(e)]}function yp(e){let t={},a=Object.keys(e).sort();for(let r of a)t[r]=e[r];return t}function vp(e,t){let a=new Set;return new Set(t),e.reduce((r,l)=>{let n=JSON.stringify(yp(l));return a.has(n)||(a.add(n),r.push({key:n,link:l})),r},[])}function cf(){let e=g.useContext(Qs);return yc(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function jp(){let e=g.useContext(Mn);return yc(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var vc=g.createContext(void 0);vc.displayName="FrameworkContext";function df(){let e=g.useContext(vc);return yc(e,"You must render this element inside a <HydratedRouter> element"),e}function Np(e,t){let a=g.useContext(vc),[r,l]=g.useState(!1),[n,o]=g.useState(!1),{onFocus:i,onBlur:c,onMouseEnter:m,onMouseLeave:u,onTouchStart:x}=t,f=g.useRef(null);g.useEffect(()=>{if(e==="render"&&o(!0),e==="viewport"){let v=h=>{h.forEach(d=>{o(d.isIntersecting)})},S=new IntersectionObserver(v,{threshold:.5});return f.current&&S.observe(f.current),()=>{S.disconnect()}}},[e]),g.useEffect(()=>{if(r){let v=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(v)}}},[r]);let b=()=>{l(!0)},j=()=>{l(!1),o(!1)};return a?e!=="intent"?[n,f,{}]:[n,f,{onFocus:er(i,b),onBlur:er(c,j),onMouseEnter:er(m,b),onMouseLeave:er(u,j),onTouchStart:er(x,b)}]:[!1,f,{}]}function er(e,t){return a=>{e&&e(a),a.defaultPrevented||t(a)}}function wp({page:e,...t}){let{router:a}=cf(),r=g.useMemo(()=>I0(a.routes,e,a.basename),[a.routes,e,a.basename]);return r?g.createElement(Ep,{page:e,matches:r,...t}):null}function Sp(e){let{manifest:t,routeModules:a}=df(),[r,l]=g.useState([]);return g.useEffect(()=>{let n=!1;return gp(e,t,a).then(o=>{n||l(o)}),()=>{n=!0}},[e,t,a]),r}function Ep({page:e,matches:t,...a}){let r=Et(),{manifest:l,routeModules:n}=df(),{basename:o}=cf(),{loaderData:i,matches:c}=jp(),m=g.useMemo(()=>Pd(e,t,c,l,r,"data"),[e,t,c,l,r]),u=g.useMemo(()=>Pd(e,t,c,l,r,"assets"),[e,t,c,l,r]),x=g.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let j=new Set,v=!1;if(t.forEach(h=>{var p;let d=l.routes[h.route.id];!d||!d.hasLoader||(!m.some(y=>y.route.id===h.route.id)&&h.route.id in i&&((p=n[h.route.id])!=null&&p.shouldRevalidate)||d.hasClientLoader?v=!0:j.add(h.route.id))}),j.size===0)return[];let S=fp(e,o,"data");return v&&j.size>0&&S.searchParams.set("_routes",t.filter(h=>j.has(h.route.id)).map(h=>h.route.id).join(",")),[S.pathname+S.search]},[o,i,r,l,m,t,e,n]),f=g.useMemo(()=>pp(u,l),[u,l]),b=Sp(u);return g.createElement(g.Fragment,null,x.map(j=>g.createElement("link",{key:j,rel:"prefetch",as:"fetch",href:j,...a})),f.map(j=>g.createElement("link",{key:j,rel:"modulepreload",href:j,...a})),b.map(({key:j,link:v})=>g.createElement("link",{key:j,nonce:a.nonce,...v})))}function _p(...e){return t=>{e.forEach(a=>{typeof a=="function"?a(t):a!=null&&(a.current=t)})}}var uf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{uf&&(window.__reactRouterVersion="7.8.2")}catch{}function kp({basename:e,children:t,window:a}){let r=g.useRef();r.current==null&&(r.current=xg({window:a,v5Compat:!0}));let l=r.current,[n,o]=g.useState({action:l.action,location:l.location}),i=g.useCallback(c=>{g.startTransition(()=>o(c))},[o]);return g.useLayoutEffect(()=>l.listen(i),[l,i]),g.createElement(sp,{basename:e,children:t,location:n.location,navigationType:n.action,navigator:l})}var mf=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,jc=g.forwardRef(function({onClick:t,discover:a="render",prefetch:r="none",relative:l,reloadDocument:n,replace:o,state:i,target:c,to:m,preventScrollReset:u,viewTransition:x,...f},b){let{basename:j}=g.useContext(St),v=typeof m=="string"&&mf.test(m),S,h=!1;if(typeof m=="string"&&v&&(S=m,uf))try{let z=new URL(window.location.href),C=m.startsWith("//")?new URL(z.protocol+m):new URL(m),k=ta(C.pathname,j);C.origin===z.origin&&k!=null?m=k+C.search+C.hash:h=!0}catch{jt(!1,`<Link to="${m}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let d=Gg(m,{relative:l}),[p,y,E]=Np(r,f),w=Tp(m,{replace:o,state:i,target:c,preventScrollReset:u,relative:l,viewTransition:x});function N(z){t&&t(z),z.defaultPrevented||w(z)}let R=g.createElement("a",{...f,...E,href:S||d,onClick:h||n?t:N,ref:_p(b,y),target:c,"data-discover":!v&&a==="render"?"true":void 0});return p&&!v?g.createElement(g.Fragment,null,R,g.createElement(wp,{page:d})):R});jc.displayName="Link";var Cp=g.forwardRef(function({"aria-current":t="page",caseSensitive:a=!1,className:r="",end:l=!1,style:n,to:o,viewTransition:i,children:c,...m},u){let x=Ir(o,{relative:m.relative}),f=Et(),b=g.useContext(Mn),{navigator:j,basename:v}=g.useContext(St),S=b!=null&&Dp(x)&&i===!0,h=j.encodeLocation?j.encodeLocation(x).pathname:x.pathname,d=f.pathname,p=b&&b.navigation&&b.navigation.location?b.navigation.location.pathname:null;a||(d=d.toLowerCase(),p=p?p.toLowerCase():null,h=h.toLowerCase()),p&&v&&(p=ta(p,v)||p);const y=h!=="/"&&h.endsWith("/")?h.length-1:h.length;let E=d===h||!l&&d.startsWith(h)&&d.charAt(y)==="/",w=p!=null&&(p===h||!l&&p.startsWith(h)&&p.charAt(h.length)==="/"),N={isActive:E,isPending:w,isTransitioning:S},R=E?t:void 0,z;typeof r=="function"?z=r(N):z=[r,E?"active":null,w?"pending":null,S?"transitioning":null].filter(Boolean).join(" ");let C=typeof n=="function"?n(N):n;return g.createElement(jc,{...m,"aria-current":R,className:z,ref:u,style:C,to:o,viewTransition:i},typeof c=="function"?c(N):c)});Cp.displayName="NavLink";var Mp=g.forwardRef(({discover:e="render",fetcherKey:t,navigate:a,reloadDocument:r,replace:l,state:n,method:o=Tl,action:i,onSubmit:c,relative:m,preventScrollReset:u,viewTransition:x,...f},b)=>{let j=Ap(),v=Op(i,{relative:m}),S=o.toLowerCase()==="get"?"get":"post",h=typeof i=="string"&&mf.test(i),d=p=>{if(c&&c(p),p.defaultPrevented)return;p.preventDefault();let y=p.nativeEvent.submitter,E=(y==null?void 0:y.getAttribute("formmethod"))||o;j(y||p.currentTarget,{fetcherKey:t,method:E,navigate:a,replace:l,state:n,relative:m,preventScrollReset:u,viewTransition:x})};return g.createElement("form",{ref:b,method:S,action:v,onSubmit:r?c:d,...f,"data-discover":!h&&e==="render"?"true":void 0})});Mp.displayName="Form";function Rp(e){return`${e} must be used within a data router.  See https://reactrouter.com/en/main/routers/picking-a-router.`}function ff(e){let t=g.useContext(Qs);return xe(t,Rp(e)),t}function Tp(e,{target:t,replace:a,state:r,preventScrollReset:l,relative:n,viewTransition:o}={}){let i=gc(),c=Et(),m=Ir(e,{relative:n});return g.useCallback(u=>{if(cp(u,t)){u.preventDefault();let x=a!==void 0?a:Or(c)===Or(m);i(e,{replace:x,state:r,preventScrollReset:l,relative:n,viewTransition:o})}},[c,i,m,a,r,t,e,l,n,o])}var zp=0,Lp=()=>`__${String(++zp)}__`;function Ap(){let{router:e}=ff("useSubmit"),{basename:t}=g.useContext(St),a=Ig();return g.useCallback(async(r,l={})=>{let{action:n,method:o,encType:i,formData:c,body:m}=mp(r,t);if(l.navigate===!1){let u=l.fetcherKey||Lp();await e.fetch(u,a,l.action||n,{preventScrollReset:l.preventScrollReset,formData:c,body:m,formMethod:l.method||o,formEncType:l.encType||i,flushSync:l.flushSync})}else await e.navigate(l.action||n,{preventScrollReset:l.preventScrollReset,formData:c,body:m,formMethod:l.method||o,formEncType:l.encType||i,replace:l.replace,state:l.state,fromRouteId:a,flushSync:l.flushSync,viewTransition:l.viewTransition})},[e,t,a])}function Op(e,{relative:t}={}){let{basename:a}=g.useContext(St),r=g.useContext(Ut);xe(r,"useFormAction must be used inside a RouteContext");let[l]=r.matches.slice(-1),n={...Ir(e||".",{relative:t})},o=Et();if(e==null){n.search=o.search;let i=new URLSearchParams(n.search),c=i.getAll("index");if(c.some(u=>u==="")){i.delete("index"),c.filter(x=>x).forEach(x=>i.append("index",x));let u=i.toString();n.search=u?`?${u}`:""}}return(!e||e===".")&&l.route.index&&(n.search=n.search?n.search.replace(/^\?/,"?index&"):"?index"),a!=="/"&&(n.pathname=n.pathname==="/"?a:Wt([a,n.pathname])),Or(n)}function Dp(e,{relative:t}={}){let a=g.useContext(sf);xe(a!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`.  Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=ff("useViewTransitionState"),l=Ir(e,{relative:t});if(!a.isTransitioning)return!1;let n=ta(a.currentLocation.pathname,r)||a.currentLocation.pathname,o=ta(a.nextLocation.pathname,r)||a.nextLocation.pathname;return dn(l.pathname,o)!=null||dn(l.pathname,n)!=null}const Up="http://localhost/api_rutas";class Hp{constructor(){this.baseURL=Up}getAuthHeader(){const t=localStorage.getItem("token");return t?{Authorization:`Bearer ${t}`}:{}}async request(t,a={}){const r=`${this.baseURL}/${t}`,l={headers:{"Content-Type":"application/json",...this.getAuthHeader(),...a.headers},...a};try{const n=await fetch(r,l),o=await n.json();if(!n.ok)throw new Error(o.error||`HTTP error! status: ${n.status}`);return o}catch(n){throw console.error("API request failed:",n),n}}async login(t,a){const l=await(await fetch(`${this.baseURL}/reportes/funciones_php/api.php`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tipo:"login",username:t,password:a})})).json();if(!l.success)throw new Error(l.message||"Error en login");return l.data}async verifyToken(){const t=localStorage.getItem("token"),r=await(await fetch(`${this.baseURL}/reportes/funciones_php/api.php`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({tipo:"verify"})})).json();if(!r.success)throw new Error(r.message||"Token inválido");return r.data}async logout(){const t=localStorage.getItem("token");return await(await fetch(`${this.baseURL}/reportes/funciones_php/api.php`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({tipo:"logout"})})).json()}async getUsers(){return this.request("usuarios")}async getUserById(t){return this.request(`usuarios/${t}`)}async createUser(t){return this.request("usuarios",{method:"POST",body:JSON.stringify(t)})}async healthCheck(){return this.request("health")}}const U=new Hp;class Bp{constructor(){this.token=localStorage.getItem("token"),this.user=this.getStoredUser()}getStoredUser(){try{const t=localStorage.getItem("user");return t?JSON.parse(t):null}catch(t){return console.error("Error parsing stored user data:",t),null}}async login(t,a){try{const r=await U.login(t,a);if(r.token&&r.usuario)return this.token=r.token,this.user=r.usuario,localStorage.setItem("token",this.token),localStorage.setItem("user",JSON.stringify(this.user)),{success:!0,data:{usuario:this.user},user:this.user};throw new Error("Respuesta inválida del servidor")}catch(r){return console.error("Login error:",r),{success:!1,error:r.message}}}async logout(){try{this.token&&await U.logout()}catch(t){console.error("Logout error:",t)}finally{this.token=null,this.user=null,localStorage.removeItem("token"),localStorage.removeItem("user")}}async verifyAuth(){var t;if(!this.token)return!1;try{const a=await U.verifyToken(),r=((t=a.data)==null?void 0:t.usuario)||a.usuario;return r?(this.user=r,localStorage.setItem("user",JSON.stringify(this.user)),!0):!1}catch(a){return console.error("Auth verification failed:",a),this.logout(),!1}}isAuthenticated(){return!!this.token&&!!this.user}getUser(){return this.user}getToken(){return this.token}hasPermission(t,a){if(!this.user||!this.user.permisos)return!1;const r=this.user.permisos[t];return r&&r.permisos.includes(a)}hasModuleAccess(t){return!this.user||!this.user.permisos?!1:!!this.user.permisos[t]}getUserModules(){return!this.user||!this.user.permisos?[]:Object.entries(this.user.permisos).map(([t,a])=>({name:t,...a})).sort((t,a)=>(t.orden||0)-(a.orden||0))}getRoles(){return!this.user||!this.user.roles?[]:this.user.roles.split(",").filter(t=>t.trim())}hasRole(t){return this.getRoles().includes(t)}isAdmin(){return this.hasRole("super_admin")||this.hasRole("admin")}}const Ct=new Bp,hf=g.createContext(),qp=(e,t)=>{switch(t.type){case"LOGIN_START":return{...e,loading:!0,error:null};case"LOGIN_SUCCESS":return{...e,loading:!1,isAuthenticated:!0,user:t.payload,error:null};case"LOGIN_ERROR":return{...e,loading:!1,isAuthenticated:!1,user:null,error:t.payload};case"LOGOUT":return{...e,isAuthenticated:!1,user:null,loading:!1,error:null};case"VERIFY_AUTH":return{...e,isAuthenticated:t.payload.isAuthenticated,user:t.payload.user,loading:!1};case"SET_LOADING":return{...e,loading:t.payload};case"CLEAR_ERROR":return{...e,error:null};default:return e}},Vp={isAuthenticated:!1,user:null,loading:!0,error:null},Gp=({children:e})=>{var f;const[t,a]=g.useReducer(qp,Vp);g.useEffect(()=>{(async()=>{a({type:"SET_LOADING",payload:!0});try{if(Ct.isAuthenticated()){const j=await Ct.verifyAuth();a(j?{type:"VERIFY_AUTH",payload:{isAuthenticated:!0,user:Ct.getUser()}}:{type:"VERIFY_AUTH",payload:{isAuthenticated:!1,user:null}})}else a({type:"VERIFY_AUTH",payload:{isAuthenticated:!1,user:null}})}catch(j){console.error("Error verifying auth:",j),a({type:"VERIFY_AUTH",payload:{isAuthenticated:!1,user:null}})}})()},[]);const r=async(b,j)=>{var v;a({type:"LOGIN_START"});try{const S=await Ct.login(b,j);if(S.success){const h=((v=S.data)==null?void 0:v.usuario)||S.user;return a({type:"LOGIN_SUCCESS",payload:h}),{success:!0}}else return a({type:"LOGIN_ERROR",payload:S.error}),{success:!1,error:S.error}}catch(S){return a({type:"LOGIN_ERROR",payload:S.message}),{success:!1,error:S.message}}},l=async()=>{try{await Ct.logout()}catch(b){console.error("Error during logout:",b)}finally{a({type:"LOGOUT"})}},n=g.useCallback(()=>{a({type:"CLEAR_ERROR"})},[]),o=g.useCallback((b,j)=>Ct.hasPermission(b,j),[]),i=g.useCallback(b=>Ct.hasModuleAccess(b),[]),c=g.useCallback(()=>Ct.getUserModules(),[]),m=g.useCallback(b=>Ct.hasRole(b),[]),u=g.useCallback(()=>Ct.isAdmin(),[]),x={...t,login:r,logout:l,clearError:n,hasPermission:o,hasModuleAccess:i,getUserModules:c,hasRole:m,isAdmin:u,permisos:((f=t.user)==null?void 0:f.permisos)||{}};return s.jsx(hf.Provider,{value:x,children:e})},sa=()=>{const e=g.useContext(hf);if(!e)throw new Error("useAuth debe ser usado dentro de un AuthProvider");return e},Qp=()=>{const[e,t]=g.useState({username:"",password:""}),[a,r]=g.useState(!1),[l,n]=g.useState({}),[o,i]=g.useState(!1),{login:c,loading:m,error:u,clearError:x,isAuthenticated:f}=sa(),b=gc(),j=Et();g.useEffect(()=>{x()},[]),g.useEffect(()=>{var p,y;if(f&&!m){const E=((y=(p=j.state)==null?void 0:p.from)==null?void 0:y.pathname)||"/dashboard";b(E,{replace:!0})}},[f,m,b,j]);const v=()=>{const p={};return e.username.trim()?e.username.trim().length<3&&(p.username="El usuario debe tener al menos 3 caracteres"):p.username="El usuario es requerido",e.password.trim()?e.password.length<4&&(p.password="La contraseña debe tener al menos 4 caracteres"):p.password="La contraseña es requerida",p},S=p=>typeof p=="string"?p.toLowerCase().includes("credenciales inválidas")||p.toLowerCase().includes("usuario o contraseña incorrectos")?"Usuario o contraseña incorrectos. Por favor verifica tus credenciales.":p.toLowerCase().includes("usuario no encontrado")?"El usuario ingresado no existe en el sistema.":p.toLowerCase().includes("conexión")?"Error de conexión. Por favor intenta de nuevo más tarde.":p.toLowerCase().includes("token")?"Error de autenticación. Por favor intenta nuevamente.":p.toLowerCase().includes("servidor")?"Error del servidor. Por favor contacta al administrador.":p:"Error desconocido. Por favor intenta de nuevo.",h=p=>{const{name:y,value:E}=p.target;t(w=>({...w,[y]:E})),l[y]&&n(w=>({...w,[y]:""})),u&&x()},d=async p=>{var E,w;p.preventDefault(),n({}),x();const y=v();if(Object.keys(y).length>0){n(y);return}i(!0);try{const N=await c(e.username.trim(),e.password);if(N.success){const R=((w=(E=j.state)==null?void 0:E.from)==null?void 0:w.pathname)||"/dashboard";b(R,{replace:!0})}else console.error("Login failed:",N.error)}catch(N){console.error("Login error:",N)}finally{i(!1)}};return s.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-blue-50 to-indigo-100",children:[s.jsx("div",{className:"max-w-md w-full mx-4",children:s.jsxs("div",{className:"bg-white rounded-xl shadow-lg p-8",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("div",{className:"w-16 h-16 bg-blue-600 rounded-full flex items-center justify-center mx-auto mb-4",children:s.jsx("svg",{className:"w-8 h-8 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.031 9-11.622 0-1.042-.133-2.052-.382-3.016z"})})}),s.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:"Sistema de Rutas"}),s.jsx("p",{className:"text-gray-600 mt-2",children:"Ingresa tus credenciales para continuar"})]}),u&&s.jsx("div",{className:"mb-6 bg-red-50 border border-red-200 rounded-lg p-4 animate-shake",children:s.jsxs("div",{className:"flex",children:[s.jsx("div",{className:"flex-shrink-0",children:s.jsx("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),s.jsxs("div",{className:"ml-3",children:[s.jsx("h3",{className:"text-sm font-medium text-red-800 mb-1",children:"Error de autenticación"}),s.jsx("p",{className:"text-sm text-red-700",children:S(u)})]}),s.jsx("div",{className:"ml-auto",children:s.jsx("button",{type:"button",className:"text-red-400 hover:text-red-600 transition-colors",onClick:x,children:s.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})})]})}),s.jsxs("form",{onSubmit:d,className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-gray-700 mb-2",children:"Usuario o Email *"}),s.jsx("input",{id:"username",name:"username",type:"text",value:e.username,onChange:h,className:`w-full px-3 py-3 border rounded-lg shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 transition-colors ${l.username?"border-red-300 focus:ring-red-500 focus:border-red-500":"border-gray-300 focus:ring-blue-500 focus:border-blue-500"}`,placeholder:"Ingresa tu usuario o email",disabled:m||o,autoComplete:"username"}),l.username&&s.jsxs("p",{className:"mt-1 text-sm text-red-600 flex items-center",children:[s.jsx("svg",{className:"h-4 w-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),l.username]})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-gray-700 mb-2",children:"Contraseña *"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{id:"password",name:"password",type:a?"text":"password",value:e.password,onChange:h,className:`w-full px-3 py-3 border rounded-lg shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 pr-10 transition-colors ${l.password?"border-red-300 focus:ring-red-500 focus:border-red-500":"border-gray-300 focus:ring-blue-500 focus:border-blue-500"}`,placeholder:"Ingresa tu contraseña",disabled:m||o,autoComplete:"current-password"}),s.jsx("button",{type:"button",className:"absolute inset-y-0 right-0 pr-3 flex items-center",onClick:()=>r(!a),disabled:m||o,children:s.jsx("svg",{className:"h-5 w-5 text-gray-400 hover:text-gray-600 transition-colors",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a?s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.878 9.878L3 3m6.878 6.878L21 21"}):s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})})})]}),l.password&&s.jsxs("p",{className:"mt-1 text-sm text-red-600 flex items-center",children:[s.jsx("svg",{className:"h-4 w-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),l.password]})]}),s.jsx("div",{children:s.jsx("button",{type:"submit",disabled:m||o||!e.username.trim()||!e.password.trim(),className:"w-full flex justify-center py-3 px-4 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 transform hover:scale-[1.02] active:scale-[0.98]",children:m||o?s.jsxs(s.Fragment,{children:[s.jsxs("svg",{className:"animate-spin -ml-1 mr-3 h-5 w-5 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),o?"Verificando credenciales...":"Iniciando sesión..."]}):s.jsxs(s.Fragment,{children:[s.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 16l-4-4m0 0l4-4m-4 4h14m-5 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h7a3 3 0 013 3v1"})}),"Iniciar Sesión"]})})}),e.password&&s.jsx("div",{className:"text-xs text-gray-600",children:s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx("span",{children:"Seguridad:"}),s.jsxs("div",{className:"flex space-x-1",children:[s.jsx("div",{className:`h-2 w-4 rounded ${e.password.length>=4?"bg-yellow-400":"bg-gray-200"}`}),s.jsx("div",{className:`h-2 w-4 rounded ${e.password.length>=8?"bg-orange-400":"bg-gray-200"}`}),s.jsx("div",{className:`h-2 w-4 rounded ${e.password.length>=12?"bg-green-400":"bg-gray-200"}`})]})]})})]}),s.jsx("div",{className:"mt-8 pt-6 border-t border-gray-200",children:s.jsxs("div",{className:"text-center",children:[s.jsx("p",{className:"text-sm text-gray-600 mb-2",children:"Credenciales de prueba:"}),s.jsxs("div",{className:"text-xs text-gray-500 bg-gray-50 rounded p-2 hover:bg-gray-100 transition-colors",children:[s.jsxs("div",{className:"flex justify-between items-center mb-1",children:[s.jsx("span",{children:"Usuario:"}),s.jsx("span",{className:"font-mono bg-white px-2 py-1 rounded text-blue-600",children:"admin"})]}),s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("span",{children:"Contraseña:"}),s.jsx("span",{className:"font-mono bg-white px-2 py-1 rounded text-blue-600",children:"password"})]})]}),s.jsx("button",{type:"button",onClick:()=>{t({username:"admin",password:"password"}),n({}),x()},className:"mt-2 text-xs text-blue-600 hover:text-blue-700 underline transition-colors",disabled:m||o,children:"Usar credenciales de prueba"})]})})]})}),s.jsx("style",{jsx:!0,children:`
        @keyframes shake {
          0%, 100% { transform: translateX(0); }
          10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
          20%, 40%, 60%, 80% { transform: translateX(2px); }
        }
        .animate-shake {
          animation: shake 0.5s ease-in-out;
        }
      `})]})},ct=({children:e,module:t=null,permission:a=null,fallback:r=null,showLogin:l=!0})=>{const{isAuthenticated:n,loading:o,hasPermission:i,hasModuleAccess:c}=sa(),m=Et();return o?s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto"}),s.jsx("p",{className:"mt-4 text-gray-600",children:"Verificando autenticación..."})]})}):n?t&&!c(t)?r||s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mx-auto mb-4",children:s.jsx("svg",{className:"w-8 h-8 text-red-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),s.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-2",children:"Sin Acceso al Módulo"}),s.jsxs("p",{className:"text-gray-600",children:["No tienes permisos para acceder al módulo ",s.jsx("span",{className:"font-medium",children:t}),"."]})]})}):t&&a&&!i(t,a)?r||s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"w-16 h-16 bg-yellow-100 rounded-full flex items-center justify-center mx-auto mb-4",children:s.jsx("svg",{className:"w-8 h-8 text-yellow-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.031 9-11.622 0-1.042-.133-2.052-.382-3.016z"})})}),s.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-2",children:"Permisos Insuficientes"}),s.jsxs("p",{className:"text-gray-600",children:["No tienes el permiso ",s.jsx("span",{className:"font-medium",children:a})," para el módulo ",s.jsx("span",{className:"font-medium",children:t}),"."]})]})}):e:s.jsx(mi,{to:"/login",state:{from:m},replace:!0})},we=({module:e,permission:t,children:a,fallback:r=null,hideIfNoAccess:l=!0})=>{const{hasPermission:n,hasModuleAccess:o}=sa();return e&&!o(e)||e&&t&&!n(e,t)?l?null:r:a},Yp=({title:e="Sistema de Rutas",showUserInfo:t=!0,onMenuClick:a,className:r=""})=>{const{user:l}=sa();return s.jsx("header",{className:`bg-white shadow-sm border-b border-gray-200 ${r}`,children:s.jsx("div",{className:"px-4 sm:px-6 lg:px-8",children:s.jsxs("div",{className:"flex justify-between items-center h-16",children:[s.jsxs("div",{className:"flex items-center",children:[a&&s.jsx("button",{onClick:a,className:"lg:hidden p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-blue-500","aria-label":"Abrir menú",children:s.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),s.jsx("div",{className:"flex items-center ml-4 lg:ml-0",children:s.jsx("h1",{className:"text-xl font-semibold text-gray-900 truncate",children:e})})]}),s.jsxs("div",{className:"flex items-center space-x-4",children:[s.jsxs("button",{className:"p-2 text-gray-400 hover:text-gray-500 hover:bg-gray-100 rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500","aria-label":"Notificaciones",children:[s.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 17h5l-5-5V9a4 4 0 10-8 0v3l-5 5h5a2 2 0 104 0z"})}),s.jsx("span",{className:"absolute -top-1 -right-1 block h-2 w-2 rounded-full bg-red-400 ring-2 ring-white"})]}),t&&l&&s.jsxs("div",{className:"hidden lg:flex items-center space-x-3",children:[s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-sm font-medium text-gray-900 truncate max-w-32",children:l.nombre||l.username}),s.jsx("p",{className:"text-xs text-gray-500 truncate max-w-32",children:l.roles||"Usuario"})]}),s.jsxs("div",{className:"relative",children:[s.jsx("div",{className:"w-8 h-8 bg-gradient-to-br from-blue-400 to-blue-600 rounded-full flex items-center justify-center text-white font-medium text-sm",children:(l.nombre||l.username||"U").charAt(0).toUpperCase()}),s.jsx("div",{className:"absolute bottom-0 right-0 block h-2 w-2 rounded-full bg-green-400 ring-2 ring-white"})]})]}),t&&l&&s.jsx("div",{className:"lg:hidden",children:s.jsx("button",{className:"p-2 text-gray-400 hover:text-gray-500 hover:bg-gray-100 rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500",children:s.jsx("div",{className:"w-6 h-6 bg-gradient-to-br from-blue-400 to-blue-600 rounded-full flex items-center justify-center text-white font-medium text-xs",children:(l.nombre||l.username||"U").charAt(0).toUpperCase()})})})]})]})})})},$p="/assets/IMAGOTIPO%20ELOTESA-DUudVBJt.png",Nt=({children:e})=>{const[t,a]=g.useState(!1),[r,l]=g.useState({}),{user:n,logout:o,permisos:i}=sa(),c=Et(),m=async()=>{await o()},u=h=>!i||!i[h]?!1:i[h].permisos&&i[h].permisos.length>0,x=(h,d)=>!i||!i[h]?!1:i[h].permisos.includes(d),f=h=>{l(d=>({...d,[h]:!d[h]}))},b=[{type:"item",name:"dashboard",label:"Dashboard",icon:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2H5a2 2 0 00-2-2V7",path:"/dashboard",always:!0},{type:"section",name:"accesos",label:"Accesos y Permisos",icon:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.031 9-11.622 0-1.042-.133-2.052-.382-3.016z",children:[{name:"usuarios",label:"Usuarios",icon:"M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197m13.5-9a2.5 2.5 0 11-5 0 2.5 2.5 0 015 0z",path:"/usuarios"},{name:"configuracion",label:"Roles y Permisos",icon:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z M15 12a3 3 0 11-6 0 3 3 0 016 0z",path:"/configuracion"}]},{type:"section",name:"operaciones",label:"Operaciones",icon:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10",children:[{name:"rutas",label:"Rutas",icon:"M9 20l-5.447-2.724A1 1 0 013 16.382V5.618a1 1 0 011.447-.894L9 7m0 13l6-3m-6 3V7m6 10l4.553 2.276A1 1 0 0021 18.382V7.618a1 1 0 00-.553-.894L15 4m0 13V4m0 0L9 7",path:"/rutas"},{name:"repartidores",label:"Repartidores",icon:"M13 6a3 3 0 11-6 0 3 3 0 016 0zM18 8a2 2 0 11-4 0 2 2 0 014 0zM14 15a4 4 0 00-8 0v3h8v-3z",path:"/repartidores"},{name:"productos",label:"Productos",icon:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4",path:"/productos",children:[{name:"productos",label:"Productos",icon:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4",path:"/productos"},{name:"productos",label:"Gestión de Stocks",icon:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z",path:"/stocks"},{name:"productos",label:"Motivos de Stock",icon:"M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01",path:"/motivos-stock"}]}]},{type:"section",name:"clientes",label:"Clientes",icon:"M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z",children:[{name:"clientes",label:"Gestión de Clientes",icon:"M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z",path:"/clientes"},{name:"clientes",label:"Códigos QR",icon:"M12 4v1m6 11h2m-6 0h-2v4m0-11v3m0 0h.01M12 12h4.01M16 20h4M4 12h4m12 0h.01M5 8h2a1 1 0 001-1V5a1 1 0 00-1-1H5a1 1 0 00-1 1v2a1 1 0 001 1zm12 0h2a1 1 0 001-1V5a1 1 0 00-1-1h-2a1 1 0 00-1 1v2a1 1 0 001 1zM5 20h2a1 1 0 001-1v-2a1 1 0 00-1-1H5a1 1 0 00-1 1v2a1 1 0 001 1z",path:"/codigos-qr"}]},{type:"item",name:"reportes",label:"Reportes",icon:"M9 17v-2m3 2v-4m3 4v-6m2 10H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z",path:"/reportes"}],j=h=>h.children.some(d=>d.always||u(d.name)),v=(h,d=!1)=>{const p=c.pathname===h.path,y=h.children&&h.children.length>0,E=!r[h.name+"_submenu"];if(y)return s.jsxs("div",{className:"space-y-1",children:[s.jsxs("button",{onClick:()=>f(h.name+"_submenu"),className:`w-full group flex items-center px-3 py-2 text-sm font-medium rounded-lg transition-colors duration-200 ${p?"text-blue-600 bg-blue-50":"text-gray-700 hover:text-blue-600 hover:bg-blue-50"}`,children:[s.jsx("svg",{className:"mr-3 h-4 w-4 text-gray-400 group-hover:text-blue-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:h.icon})}),s.jsx("span",{className:"flex-1 text-left",children:h.label}),s.jsx("svg",{className:`ml-auto h-4 w-4 text-gray-400 transition-transform duration-200 ${E?"rotate-90":"rotate-0"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]}),E&&s.jsx("div",{className:"space-y-1 pl-2",children:h.children.map(z=>v(z,!0))})]},h.name);const w="group flex items-center px-3 py-2 text-sm font-medium rounded-lg transition-colors duration-200",N=d?"ml-6 pl-4 border-l border-gray-200":"",R=p?"text-blue-600 bg-blue-50 border-r-2 border-blue-600":"text-gray-700 hover:text-blue-600 hover:bg-blue-50";return s.jsxs(jc,{to:h.path,className:`${w} ${N} ${R}`,children:[s.jsx("svg",{className:`mr-3 h-4 w-4 ${d?"text-gray-300":"text-gray-400"} group-hover:text-blue-500`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:h.icon})}),s.jsx("span",{className:d?"text-sm":"",children:h.label}),h.name!=="dashboard"&&u(h.name)&&s.jsxs("div",{className:"ml-auto flex space-x-1",children:[x(h.name,"leer")&&s.jsx("div",{className:"w-1.5 h-1.5 bg-green-400 rounded-full",title:"Lectura"}),x(h.name,"actualizar")&&s.jsx("div",{className:"w-1.5 h-1.5 bg-blue-400 rounded-full",title:"Actualizar"}),x(h.name,"eliminar")&&s.jsx("div",{className:"w-1.5 h-1.5 bg-red-400 rounded-full",title:"Eliminar"})]})]},h.name+"_"+h.path)},S=h=>{const d=!r[h.name];return j(h)?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("button",{onClick:()=>f(h.name),className:"w-full group flex items-center px-3 py-2 text-sm font-medium text-gray-600 hover:text-gray-900 hover:bg-gray-50 rounded-lg transition-colors duration-200",children:[s.jsx("svg",{className:"mr-3 h-4 w-4 text-gray-400 group-hover:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:h.icon})}),s.jsx("span",{className:"flex-1 text-left",children:h.label}),s.jsx("svg",{className:`ml-auto h-4 w-4 text-gray-400 transition-transform duration-200 ${d?"rotate-90":"rotate-0"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]}),d&&s.jsx("div",{className:"space-y-1 pl-2",children:h.children.map(y=>y.always||u(y.name)?v(y,!0):null)})]},h.name):null};return s.jsxs("div",{className:"min-h-screen bg-gray-50",children:[s.jsxs("div",{className:`fixed inset-y-0 left-0 z-50 w-64 bg-white shadow-lg transform ${t?"translate-x-0":"-translate-x-full"} transition-transform duration-300 ease-in-out lg:translate-x-0`,children:[s.jsxs("div",{className:"flex items-center justify-between h-16 px-6 border-b border-gray-200",children:[s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"w-20 h-20 flex items-center justify-center",children:s.jsx("img",{src:$p,alt:"ELOTESA Logo",className:"w-30 h-15 object-contain"})}),s.jsx("span",{className:"ml-3 text-xl font-semibold text-gray-900",children:"ELOTESA"})]}),s.jsx("button",{onClick:()=>a(!1),className:"lg:hidden p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100",children:s.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsx("nav",{className:"mt-6 px-3",children:s.jsx("div",{className:"space-y-2",children:b.map(h=>h.type==="item"?h.always||u(h.name)?v(h):null:h.type==="section"?S(h):null)})}),s.jsx("div",{className:"absolute bottom-0 left-0 right-0 p-4 border-t border-gray-200 bg-gray-50",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"flex-shrink-0",children:s.jsx("div",{className:"w-8 h-8 bg-gray-300 rounded-full flex items-center justify-center",children:s.jsx("svg",{className:"w-5 h-5 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})})}),s.jsxs("div",{className:"ml-3 flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium text-gray-900 truncate",children:(n==null?void 0:n.nombre)||(n==null?void 0:n.username)}),s.jsx("p",{className:"text-xs text-gray-500 truncate",children:n==null?void 0:n.email})]}),s.jsx("button",{onClick:m,className:"ml-2 p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-lg transition-colors",title:"Cerrar Sesión",children:s.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})})})]})})]}),t&&s.jsx("div",{className:"fixed inset-0 z-40 bg-black bg-opacity-25 lg:hidden",onClick:()=>a(!1)}),s.jsxs("div",{className:"lg:pl-64",children:[s.jsx(Yp,{title:"Sistema de Rutas",onMenuClick:()=>a(!0),showUserInfo:!0}),s.jsx("main",{className:"p-6",children:e})]})]})},Xp=()=>{const{user:e,getUserModules:t}=sa(),a=t(),r=new Date,l=r.toLocaleDateString("es-ES",{weekday:"long",year:"numeric",month:"long",day:"numeric"}),n=r.toLocaleTimeString("es-ES",{hour:"2-digit",minute:"2-digit"}),o=[{name:"Rutas Activas",value:"24",change:"+12%",changeType:"positive",icon:"M9 20l-5.447-2.724A1 1 0 013 16.382V5.618a1 1 0 011.447-.894L9 7m0 13l6-3m-6 3V7m6 10l4.553 2.276A1 1 0 0021 18.382V7.618a1 1 0 00-1.447-.894L15 4m0 13V4m0 0L9 7"},{name:"Vehículos",value:"18",change:"+2",changeType:"positive",icon:"M8 17l4 4 4-4m-4-5v9m-8-4h16a2 2 0 002-2V6a2 2 0 00-2-2H4a2 2 0 00-2 2v9a2 2 0 002 2z"},{name:"Conductores",value:"32",change:"+5%",changeType:"positive",icon:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"},{name:"Reportes Pendientes",value:"7",change:"-3",changeType:"negative",icon:"M9 17v-2m3 2v-4m3 4v-6m2 10H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"}];return s.jsx(Nt,{children:s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"bg-gradient-to-r from-blue-500 to-blue-600 rounded-lg shadow-lg text-white p-6",children:s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold mb-2",children:["¡Bienvenido, ",(e==null?void 0:e.nombre)||(e==null?void 0:e.username),"!"]}),s.jsxs("p",{className:"text-blue-100",children:[l," - ",n]})]}),s.jsx("div",{className:"mt-4 sm:mt-0",children:(e==null?void 0:e.roles)&&s.jsx("div",{className:"flex flex-wrap gap-2",children:e.roles.split(",").map(i=>s.jsx("span",{className:"inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-white bg-opacity-20 text-white border border-white border-opacity-30",children:i.trim()},i.trim()))})})]})}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:o.map(i=>s.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"flex-shrink-0",children:s.jsx("div",{className:"w-8 h-8 bg-blue-100 rounded-lg flex items-center justify-center",children:s.jsx("svg",{className:"w-5 h-5 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:i.icon})})})}),s.jsxs("div",{className:"ml-4 w-0 flex-1",children:[s.jsx("dt",{className:"text-sm font-medium text-gray-500 truncate",children:i.name}),s.jsxs("dd",{className:"flex items-baseline",children:[s.jsx("div",{className:"text-2xl font-semibold text-gray-900",children:i.value}),s.jsxs("div",{className:`ml-2 flex items-baseline text-sm font-semibold ${i.changeType==="positive"?"text-green-600":"text-red-600"}`,children:[i.changeType==="positive"?s.jsx("svg",{className:"w-3 h-3 flex-shrink-0 self-center",fill:"currentColor",viewBox:"0 0 20 20",children:s.jsx("path",{fillRule:"evenodd",d:"M5.293 9.707a1 1 0 010-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 01-1.414 1.414L11 7.414V15a1 1 0 11-2 0V7.414L6.707 9.707a1 1 0 01-1.414 0z",clipRule:"evenodd"})}):s.jsx("svg",{className:"w-3 h-3 flex-shrink-0 self-center",fill:"currentColor",viewBox:"0 0 20 20",children:s.jsx("path",{fillRule:"evenodd",d:"M14.707 10.293a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 111.414-1.414L9 12.586V5a1 1 0 012 0v7.586l2.293-2.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),s.jsx("span",{className:"ml-1",children:i.change})]})]})]})]})},i.name))}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[s.jsx("div",{className:"lg:col-span-2",children:s.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[s.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-6",children:"Acceso Rápido a Módulos"}),a.length>0?s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:a.slice(0,6).map(i=>s.jsx("div",{className:"relative group",children:s.jsxs("div",{className:"flex items-center p-4 border border-gray-200 rounded-lg hover:border-blue-300 hover:shadow-md transition-all duration-200 cursor-pointer",children:[s.jsx("div",{className:"flex-shrink-0",children:s.jsx("div",{className:"w-10 h-10 bg-blue-100 rounded-lg flex items-center justify-center group-hover:bg-blue-200 transition-colors",children:s.jsx(Zp,{icon:i.icono})})}),s.jsxs("div",{className:"ml-4 flex-1",children:[s.jsx("h4",{className:"text-sm font-medium text-gray-900 capitalize",children:i.name.replace("_"," ")}),s.jsxs("p",{className:"text-xs text-gray-500",children:[i.permisos.length," permiso",i.permisos.length!==1?"s":""]})]}),s.jsx("div",{className:"flex space-x-1",children:i.permisos.slice(0,3).map((c,m)=>s.jsx("div",{className:`w-2 h-2 rounded-full ${c==="leer"?"bg-green-400":c==="escribir"||c==="crear"||c==="actualizar"?"bg-blue-400":c==="eliminar"?"bg-red-400":"bg-gray-400"}`,title:c},m))})]})},i.name))}):s.jsxs("div",{className:"text-center py-8",children:[s.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),s.jsx("h3",{className:"mt-2 text-sm font-medium text-gray-900",children:"Sin módulos disponibles"}),s.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"No tienes permisos para acceder a ningún módulo."})]})]})}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[s.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Estado del Sistema"}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-gray-600",children:"Conectividad"}),s.jsxs("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800",children:[s.jsx("div",{className:"w-1.5 h-1.5 bg-green-400 rounded-full mr-1"}),"Online"]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-gray-600",children:"Base de Datos"}),s.jsxs("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800",children:[s.jsx("div",{className:"w-1.5 h-1.5 bg-green-400 rounded-full mr-1"}),"Activa"]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-gray-600",children:"Última Actualización"}),s.jsx("span",{className:"text-sm text-gray-500",children:"Hace 2 min"})]})]})]}),s.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[s.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Enlaces Rápidos"}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(we,{module:"reportes",permission:"leer",children:s.jsx("a",{href:"#",className:"block text-sm text-blue-600 hover:text-blue-700 hover:underline",children:"Ver reportes del día"})}),s.jsx(we,{module:"rutas",permission:"crear",children:s.jsx("a",{href:"#",className:"block text-sm text-blue-600 hover:text-blue-700 hover:underline",children:"Crear nueva ruta"})}),s.jsx(we,{module:"vehiculos",permission:"leer",children:s.jsx("a",{href:"#",className:"block text-sm text-blue-600 hover:text-blue-700 hover:underline",children:"Estado de vehículos"})}),s.jsx(we,{module:"usuarios",permission:"leer",children:s.jsx("a",{href:"#",className:"block text-sm text-blue-600 hover:text-blue-700 hover:underline",children:"Gestionar usuarios"})})]})]})]})]})]})})},Zp=({icon:e})=>{const t="w-6 h-6 text-blue-600";switch(e){case"dashboard":return s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})});case"users":return s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197m13.5-9a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0z"})});case"map":return s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 20l-5.447-2.724A1 1 0 013 16.382V5.618a1 1 0 011.447-.894L9 7m0 13l6-3m-6 3V7m6 10l4.553 2.276A1 1 0 0021 18.382V7.618a1 1 0 00-1.447-.894L15 4m0 13V4m-6 3l6-3"})});case"truck":return s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})});case"bar-chart":return s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})});case"settings":return s.jsxs("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]});default:return s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}};class Jp{async getUsuarios(){try{const t=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getUsuarios"})});if(t.success)return t.data||[];throw new Error(t.message||"Error obteniendo usuarios")}catch(t){throw console.error("Error fetching usuarios:",t),t}}async getUsuario(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getUsuario",id:t})});if(a.success)return a.data;throw new Error(a.message||"Error obteniendo usuario")}catch(a){throw console.error("Error fetching usuario:",a),a}}async createUsuario(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"createUsuario",...t})});if(a.success)return a.data;throw new Error(a.message||"Error creando usuario")}catch(a){throw console.error("Error creating usuario:",a),a}}async updateUsuario(t,a){try{const r=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"updateUsuario",id:t,...a})});if(r.success)return r.data;throw new Error(r.message||"Error actualizando usuario")}catch(r){throw console.error("Error updating usuario:",r),r}}async deleteUsuario(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"deleteUsuario",id:t})});if(a.success)return!0;throw new Error(a.message||"Error eliminando usuario")}catch(a){throw console.error("Error deleting usuario:",a),a}}async toggleUsuarioStatus(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"toggleUsuarioStatus",id:t})});if(a.success)return a.data;throw new Error(a.message||"Error cambiando estado")}catch(a){throw console.error("Error toggling status:",a),a}}async asignarRol(t,a){try{const r=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"asignarRol",usuario_id:t,rol_id:a})});if(r.success)return!0;throw new Error(r.message||"Error asignando rol")}catch(r){throw console.error("Error assigning role:",r),r}}async getRoles(){try{const t=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getRoles"})});if(t.success)return t.data||[];throw new Error(t.message||"Error obteniendo roles")}catch(t){throw console.error("Error fetching roles:",t),t}}}const ws=new Jp,Ie=({isOpen:e,onClose:t,title:a,children:r,size:l="md",closeOnEscape:n=!0,closeOnBackdrop:o=!0})=>{if(g.useEffect(()=>{const c=m=>{n&&m.key==="Escape"&&t()};return e&&(document.addEventListener("keydown",c),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",c),document.body.style.overflow="unset"}},[e,t,n]),!e)return null;const i={sm:"max-w-md",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-7xl"};return s.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:s.jsxs("div",{className:"flex min-h-full items-center justify-center p-4 text-center sm:items-center sm:p-0",children:[s.jsx("div",{className:"fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity",onClick:o?t:void 0}),s.jsxs("div",{className:`relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all sm:my-8 w-full ${i[l]}`,children:[s.jsx("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsx("h3",{className:"text-lg font-semibold leading-6 text-gray-900",children:a}),s.jsxs("button",{type:"button",className:"rounded-md bg-white text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500",onClick:t,children:[s.jsx("span",{className:"sr-only",children:"Cerrar"}),s.jsx("svg",{className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})]})]})}),s.jsx("div",{className:"px-4 pb-4 sm:px-6 sm:pb-4",children:r})]})]})})},Fd=({isOpen:e,onClose:t,user:a=null,onSuccess:r})=>{const[l,n]=g.useState({username:"",email:"",password:"",confirmPassword:"",nombre:"",apellido:"",telefono:"",rol_id:"",activo:1}),[o,i]=g.useState([]),[c,m]=g.useState({}),[u,x]=g.useState(!1),[f,b]=g.useState(!1),j=!!a;g.useEffect(()=>{e&&(v(),a?n({username:a.username||"",email:a.email||"",password:"",confirmPassword:"",nombre:a.nombre||"",apellido:a.apellido||"",telefono:a.telefono||"",rol_id:a.rol_id||"",activo:a.activo!==void 0?a.activo:1}):S())},[e,a]);const v=async()=>{try{const y=await ws.getRoles();i(y)}catch(y){console.error("Error cargando roles:",y)}},S=()=>{n({username:"",email:"",password:"",confirmPassword:"",nombre:"",apellido:"",telefono:"",rol_id:"",activo:1}),m({})},h=()=>{const y={};return l.username.trim()?l.username.trim().length<3&&(y.username="El nombre de usuario debe tener al menos 3 caracteres"):y.username="El nombre de usuario es requerido",l.email.trim()?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(l.email)||(y.email="Email inválido"):y.email="El email es requerido",(!j||l.password)&&(!j&&!l.password?y.password="La contraseña es requerida":l.password&&l.password.length<6&&(y.password="La contraseña debe tener al menos 6 caracteres"),l.password!==l.confirmPassword&&(y.confirmPassword="Las contraseñas no coinciden")),l.nombre.trim()||(y.nombre="El nombre es requerido"),l.apellido.trim()||(y.apellido="El apellido es requerido"),l.telefono&&!/^[\d\s\-\+\(\)]+$/.test(l.telefono)&&(y.telefono="Formato de teléfono inválido"),m(y),Object.keys(y).length===0},d=y=>{const{name:E,value:w,type:N,checked:R}=y.target;n(z=>({...z,[E]:N==="checkbox"?R?1:0:w})),c[E]&&m(z=>({...z,[E]:""}))},p=async y=>{if(y.preventDefault(),!!h()){x(!0);try{const E={...l};j&&!E.password&&delete E.password,delete E.confirmPassword,j?await ws.updateUsuario(a.id,E):await ws.createUsuario(E),r&&r(),t(),S()}catch(E){console.error("Error guardando usuario:",E),m({general:E.message||`Error al ${j?"actualizar":"crear"} usuario`})}finally{x(!1)}}};return s.jsx(Ie,{isOpen:e,onClose:t,title:j?"Editar Usuario":"Crear Nuevo Usuario",size:"lg",children:s.jsxs("form",{onSubmit:p,className:"space-y-4",children:[c.general&&s.jsx("div",{className:"bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg",children:c.general}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-gray-700 mb-1",children:"Nombre de Usuario *"}),s.jsx("input",{type:"text",id:"username",name:"username",value:l.username,onChange:d,className:`w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${c.username?"border-red-300":"border-gray-300"}`,disabled:u}),c.username&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:c.username})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"email",className:"block text-sm font-medium text-gray-700 mb-1",children:"Email *"}),s.jsx("input",{type:"email",id:"email",name:"email",value:l.email,onChange:d,className:`w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${c.email?"border-red-300":"border-gray-300"}`,disabled:u}),c.email&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:c.email})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"nombre",className:"block text-sm font-medium text-gray-700 mb-1",children:"Nombre *"}),s.jsx("input",{type:"text",id:"nombre",name:"nombre",value:l.nombre,onChange:d,className:`w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${c.nombre?"border-red-300":"border-gray-300"}`,disabled:u}),c.nombre&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:c.nombre})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"apellido",className:"block text-sm font-medium text-gray-700 mb-1",children:"Apellido *"}),s.jsx("input",{type:"text",id:"apellido",name:"apellido",value:l.apellido,onChange:d,className:`w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${c.apellido?"border-red-300":"border-gray-300"}`,disabled:u}),c.apellido&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:c.apellido})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"telefono",className:"block text-sm font-medium text-gray-700 mb-1",children:"Teléfono"}),s.jsx("input",{type:"text",id:"telefono",name:"telefono",value:l.telefono,onChange:d,placeholder:"555-0000",className:`w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${c.telefono?"border-red-300":"border-gray-300"}`,disabled:u}),c.telefono&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:c.telefono})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"rol_id",className:"block text-sm font-medium text-gray-700 mb-1",children:"Rol"}),s.jsxs("select",{id:"rol_id",name:"rol_id",value:l.rol_id,onChange:d,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",disabled:u,children:[s.jsx("option",{value:"",children:"Seleccionar rol"}),o.map(y=>s.jsx("option",{value:y.id,children:y.nombre},y.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"password",className:"block text-sm font-medium text-gray-700 mb-1",children:["Contraseña ",!j&&"*"]}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:f?"text":"password",id:"password",name:"password",value:l.password,onChange:d,placeholder:j?"Dejar vacío para mantener la actual":"",className:`w-full px-3 py-2 pr-10 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${c.password?"border-red-300":"border-gray-300"}`,disabled:u}),s.jsx("button",{type:"button",className:"absolute inset-y-0 right-0 pr-3 flex items-center",onClick:()=>b(!f),children:s.jsx("svg",{className:"h-5 w-5 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f?s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.878 9.878L3 3m6.878 6.878L21 21"}):s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})})})]}),c.password&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:c.password})]}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"confirmPassword",className:"block text-sm font-medium text-gray-700 mb-1",children:["Confirmar Contraseña ",!j&&"*"]}),s.jsx("input",{type:f?"text":"password",id:"confirmPassword",name:"confirmPassword",value:l.confirmPassword,onChange:d,placeholder:j?"Confirmar nueva contraseña":"",className:`w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${c.confirmPassword?"border-red-300":"border-gray-300"}`,disabled:u}),c.confirmPassword&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:c.confirmPassword})]})]}),s.jsxs("div",{className:"flex items-center",children:[s.jsx("input",{type:"checkbox",id:"activo",name:"activo",checked:l.activo===1,onChange:d,className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded",disabled:u}),s.jsx("label",{htmlFor:"activo",className:"ml-2 block text-sm text-gray-900",children:"Usuario activo"})]}),s.jsxs("div",{className:"flex justify-end space-x-3 pt-4 border-t",children:[s.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500",disabled:u,children:"Cancelar"}),s.jsx("button",{type:"submit",className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed",disabled:u,children:u?s.jsxs("span",{className:"flex items-center",children:[s.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Guardando..."]}):j?"Actualizar":"Crear Usuario"})]})]})})},Kp=()=>{const{hasPermission:e}=sa(),[t,a]=g.useState([]),[r,l]=g.useState(!0),[n,o]=g.useState(""),[i,c]=g.useState([]),[m,u]=g.useState(!1),[x,f]=g.useState(!1),[b,j]=g.useState(null);g.useEffect(()=>{v()},[]);const v=async()=>{l(!0);try{const k=await ws.getUsuarios();a(k)}catch(k){console.error("Error cargando usuarios:",k)}finally{l(!1)}},S=t.filter(k=>k.nombre.toLowerCase().includes(n.toLowerCase())||k.apellido.toLowerCase().includes(n.toLowerCase())||k.email.toLowerCase().includes(n.toLowerCase())||k.username.toLowerCase().includes(n.toLowerCase())),h=k=>{c(_=>_.includes(k)?_.filter(H=>H!==k):[..._,k])},d=()=>{c(i.length===S.length?[]:S.map(k=>k.id))},p=()=>{j(null),u(!0)},y=k=>{j(k),f(!0)},E=()=>{v(),u(!1),f(!1),j(null)},w=async k=>{try{const _=await ws.toggleUsuarioStatus(k.id);_&&a(H=>H.map(Q=>Q.id===k.id?{...Q,activo:_.activo}:Q))}catch(_){console.error("Error cambiando estado:",_),alert("Error al cambiar el estado del usuario")}},N=async()=>{if(window.confirm(`¿Estás seguro de eliminar ${i.length} usuario(s)?`))try{await Promise.all(i.map(k=>ws.deleteUsuario(k))),await v(),c([]),alert("Usuarios eliminados exitosamente")}catch(k){console.error("Error eliminando usuarios:",k),alert("Error al eliminar usuarios")}},R=k=>new Date(k).toLocaleString("es-ES"),z=k=>{const _={super_admin:"bg-purple-100 text-purple-800",admin:"bg-red-100 text-red-800",supervisor:"bg-blue-100 text-blue-800",operador:"bg-green-100 text-green-800",conductor:"bg-yellow-100 text-yellow-800",usuario:"bg-gray-100 text-gray-800"};return _[k]||_.usuario},C=k=>({super_admin:"Super Admin",admin:"Administrador",supervisor:"Supervisor",operador:"Operador",conductor:"Conductor",usuario:"Usuario"})[k]||k;return s.jsxs(Nt,{children:[s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Gestión de Usuarios"}),s.jsx("p",{className:"text-gray-600 mt-1",children:"Administra usuarios, roles y permisos del sistema"})]}),s.jsx("div",{className:"mt-4 sm:mt-0 flex space-x-3",children:s.jsx(we,{module:"usuarios",permission:"crear",children:s.jsxs("button",{onClick:p,className:"inline-flex items-center px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("svg",{className:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),"Nuevo Usuario"]})})})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-6",children:[s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"w-8 h-8 bg-blue-100 rounded-lg flex items-center justify-center",children:s.jsx("svg",{className:"w-5 h-5 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Total Usuarios"}),s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:t.length})]})]})}),s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"w-8 h-8 bg-green-100 rounded-lg flex items-center justify-center",children:s.jsx("svg",{className:"w-5 h-5 text-green-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Activos"}),s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:t.filter(k=>k.activo).length})]})]})}),s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"w-8 h-8 bg-red-100 rounded-lg flex items-center justify-center",children:s.jsx("svg",{className:"w-5 h-5 text-red-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Inactivos"}),s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:t.filter(k=>!k.activo).length})]})]})}),s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"w-8 h-8 bg-yellow-100 rounded-lg flex items-center justify-center",children:s.jsx("svg",{className:"w-5 h-5 text-yellow-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Conectados Hoy"}),s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:t.filter(k=>{const _=new Date(k.ultimo_acceso),H=new Date;return _.toDateString()===H.toDateString()}).length})]})]})})]}),s.jsxs("div",{className:"bg-white rounded-lg shadow",children:[s.jsx("div",{className:"p-6 border-b border-gray-200",children:s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"text",placeholder:"Buscar usuarios...",value:n,onChange:k=>o(k.target.value),className:"w-full sm:w-80 pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),s.jsx("svg",{className:"absolute left-3 top-2.5 h-5 w-5 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})]}),s.jsxs("div",{className:"mt-4 sm:mt-0 flex items-center space-x-3",children:[i.length>0&&s.jsx(we,{module:"usuarios",permission:"eliminar",children:s.jsxs("button",{onClick:N,className:"inline-flex items-center px-3 py-2 text-sm font-medium text-red-600 hover:text-red-800",children:[s.jsx("svg",{className:"w-4 h-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})}),"Eliminar (",i.length,")"]})}),s.jsxs("span",{className:"text-sm text-gray-500",children:[S.length," de ",t.length," usuarios"]})]})]})}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[s.jsx("thead",{className:"bg-gray-50",children:s.jsxs("tr",{children:[s.jsx("th",{className:"w-4 px-6 py-3",children:s.jsx("input",{type:"checkbox",checked:i.length===S.length&&S.length>0,onChange:d,className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"})}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Usuario"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Contacto"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Rol"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Estado"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Último Acceso"}),s.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Acciones"})]})}),s.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:r?s.jsx("tr",{children:s.jsx("td",{colSpan:"7",className:"px-6 py-12 text-center",children:s.jsxs("div",{className:"flex items-center justify-center",children:[s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"}),s.jsx("span",{className:"ml-2 text-gray-500",children:"Cargando usuarios..."})]})})}):S.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:"7",className:"px-6 py-12 text-center text-gray-500",children:"No se encontraron usuarios"})}):S.map(k=>s.jsxs("tr",{className:"hover:bg-gray-50",children:[s.jsx("td",{className:"px-6 py-4",children:s.jsx("input",{type:"checkbox",checked:i.includes(k.id),onChange:()=>h(k.id),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"w-10 h-10 bg-gradient-to-br from-blue-400 to-blue-600 rounded-full flex items-center justify-center text-white font-medium",children:k.nombre.charAt(0)}),s.jsxs("div",{className:"ml-4",children:[s.jsxs("div",{className:"text-sm font-medium text-gray-900",children:[k.nombre," ",k.apellido]}),s.jsxs("div",{className:"text-sm text-gray-500",children:["@",k.username]})]})]})}),s.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[s.jsx("div",{className:"text-sm text-gray-900",children:k.email}),s.jsx("div",{className:"text-sm text-gray-500",children:k.telefono})]}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:k.roles?s.jsx("div",{className:"flex flex-wrap gap-1",children:k.roles.split(",").map((_,H)=>s.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${z(_.trim())}`,children:C(_.trim())},H))}):s.jsx("span",{className:"text-gray-400 text-xs",children:"Sin rol"})}),s.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[s.jsx(we,{module:"usuarios",permission:"actualizar",children:s.jsx("button",{onClick:()=>w(k),className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${k.activo==1?"bg-green-100 text-green-800 hover:bg-green-200":"bg-red-100 text-red-800 hover:bg-red-200"} transition-colors cursor-pointer`,children:k.activo==1?"Activo":"Inactivo"})}),s.jsx(we,{module:"usuarios",permission:"actualizar",fallback:s.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${k.activo==1?"bg-green-100 text-green-800":"bg-red-100 text-red-800"}`,children:k.activo==1?"Activo":"Inactivo"}),hideIfNoAccess:!1})]}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:R(k.ultimo_acceso)}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:s.jsx("div",{className:"flex items-center justify-end space-x-2",children:s.jsx(we,{module:"usuarios",permission:"actualizar",children:s.jsx("button",{onClick:()=>y(k),className:"text-blue-600 hover:text-blue-700 p-1 rounded",title:"Editar usuario",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})})})})})]},k.id))})]})})]})]}),s.jsx(Fd,{isOpen:m,onClose:()=>u(!1),onSuccess:E}),s.jsx(Fd,{isOpen:x,onClose:()=>f(!1),user:b,onSuccess:E})]})};class Wp{async getRoles(){try{const t=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getRoles"})});if(t.success)return t.data||[];throw new Error(t.message||"Error obteniendo roles")}catch(t){throw console.error("Error fetching roles:",t),t}}async getRole(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getRole",id:t})});if(a.success)return a.data;throw new Error(a.message||"Error obteniendo rol")}catch(a){throw console.error("Error fetching role:",a),a}}async createRole(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"createRol",...t})});if(a.success)return a.data;throw new Error(a.message||"Error creando rol")}catch(a){throw console.error("Error creating role:",a),a}}async updateRole(t,a){try{const r=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"updateRol",id:t,...a})});if(r.success)return r.data;throw new Error(r.message||"Error actualizando rol")}catch(r){throw console.error("Error updating role:",r),r}}async deleteRole(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"deleteRol",id:t})});if(a.success)return!0;throw new Error(a.message||"Error eliminando rol")}catch(a){throw console.error("Error deleting role:",a),a}}async getModulos(){try{const t=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getModulos"})});if(t.success)return t.data||[];throw new Error(t.message||"Error obteniendo módulos")}catch(t){throw console.error("Error fetching modulos:",t),t}}async getPermisos(){try{const t=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getPermisos"})});if(t.success)return t.data||[];throw new Error(t.message||"Error obteniendo permisos")}catch(t){throw console.error("Error fetching permisos:",t),t}}async getRolePermissions(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getRolePermissions",role_id:t})});if(a.success)return a.data||{};throw new Error(a.message||"Error obteniendo permisos del rol")}catch(a){throw console.error("Error fetching role permissions:",a),a}}async assignPermissions(t,a,r){try{const l=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"asignarPermisos",rol_id:t,modulo_id:a,permisos:r})});if(l.success)return!0;throw new Error(l.message||"Error asignando permisos")}catch(l){throw console.error("Error assigning permissions:",l),l}}async getPermissionsMatrix(){try{const t=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getPermissionsMatrix"})});if(t.success)return t.data||{};throw new Error(t.message||"Error obteniendo matriz de permisos")}catch(t){throw console.error("Error fetching permissions matrix:",t),t}}async savePermissionsMatrix(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"savePermissionsMatrix",permissions:t})});if(a.success)return!0;throw new Error(a.message||"Error guardando permisos")}catch(a){throw console.error("Error saving permissions matrix:",a),a}}}const Gt=new Wp,Id=({isOpen:e,onClose:t,role:a=null,onSuccess:r})=>{const[l,n]=g.useState({nombre:"",descripcion:"",activo:1}),[o,i]=g.useState({}),[c,m]=g.useState(!1),u=!!a;g.useEffect(()=>{e&&(a?n({nombre:a.nombre||"",descripcion:a.descripcion||"",activo:a.activo!==void 0?a.activo:1}):x())},[e,a]);const x=()=>{n({nombre:"",descripcion:"",activo:1}),i({})},f=()=>{const h={};return l.nombre.trim()?l.nombre.trim().length<3?h.nombre="El nombre debe tener al menos 3 caracteres":/^[a-zA-Z0-9_]+$/.test(l.nombre.trim())||(h.nombre="El nombre solo puede contener letras, números y guiones bajos"):h.nombre="El nombre del rol es requerido",l.descripcion&&l.descripcion.trim().length<5&&(h.descripcion="La descripción debe tener al menos 5 caracteres"),i(h),Object.keys(h).length===0},b=h=>{const{name:d,value:p,type:y,checked:E}=h.target;n(w=>({...w,[d]:y==="checkbox"?E?1:0:p})),o[d]&&i(w=>({...w,[d]:""}))},j=async h=>{if(h.preventDefault(),!!f()){m(!0);try{const d={...l,nombre:l.nombre.trim().toLowerCase()};u?await Gt.updateRole(a.id,d):await Gt.createRole(d),r&&r(),t(),x()}catch(d){console.error("Error guardando rol:",d),i({general:d.message||`Error al ${u?"actualizar":"crear"} el rol`})}finally{m(!1)}}},v=[{value:"admin",label:"Administrador",description:"Acceso completo al sistema"},{value:"supervisor",label:"Supervisor",description:"Supervisa operaciones y usuarios"},{value:"operador",label:"Operador",description:"Gestiona rutas y vehículos"},{value:"conductor",label:"Conductor",description:"Acceso limitado para conductores"},{value:"usuario",label:"Usuario",description:"Acceso básico al sistema"}],S=h=>{n(d=>({...d,nombre:h.value,descripcion:h.description}))};return s.jsx(Ie,{isOpen:e,onClose:t,title:u?"Editar Rol":"Crear Nuevo Rol",size:"md",children:s.jsxs("form",{onSubmit:j,className:"space-y-4",children:[o.general&&s.jsx("div",{className:"bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg",children:o.general}),!u&&s.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:[s.jsx("label",{className:"block text-sm font-medium text-blue-800 mb-2",children:"Roles Predefinidos (Opcional)"}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:v.map(h=>s.jsxs("button",{type:"button",onClick:()=>S(h),className:"text-left p-2 text-xs bg-white border border-blue-200 rounded hover:bg-blue-50 hover:border-blue-300 transition-colors",children:[s.jsx("div",{className:"font-medium text-blue-900",children:h.label}),s.jsx("div",{className:"text-blue-600 text-xs",children:h.description})]},h.value))}),s.jsx("p",{className:"text-xs text-blue-600 mt-2",children:"Haz clic en un rol predefinido para autocompletar los campos"})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"nombre",className:"block text-sm font-medium text-gray-700 mb-1",children:"Nombre del Rol *"}),s.jsx("input",{type:"text",id:"nombre",name:"nombre",value:l.nombre,onChange:b,placeholder:"ej: supervisor, operador, conductor",className:`w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${o.nombre?"border-red-300":"border-gray-300"}`,disabled:c}),o.nombre&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:o.nombre}),s.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Use solo letras, números y guiones bajos. Se convertirá automáticamente a minúsculas."})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"descripcion",className:"block text-sm font-medium text-gray-700 mb-1",children:"Descripción"}),s.jsx("textarea",{id:"descripcion",name:"descripcion",value:l.descripcion,onChange:b,rows:3,placeholder:"Describe las responsabilidades y alcance de este rol...",className:`w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none ${o.descripcion?"border-red-300":"border-gray-300"}`,disabled:c}),o.descripcion&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:o.descripcion})]}),s.jsxs("div",{className:"flex items-center",children:[s.jsx("input",{type:"checkbox",id:"activo",name:"activo",checked:l.activo===1,onChange:b,className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded",disabled:c}),s.jsx("label",{htmlFor:"activo",className:"ml-2 block text-sm text-gray-900",children:"Rol activo"})]}),s.jsx("div",{className:"bg-gray-50 border border-gray-200 rounded-lg p-4",children:s.jsxs("div",{className:"flex items-start",children:[s.jsx("svg",{className:"w-5 h-5 text-gray-400 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),s.jsxs("div",{className:"ml-3",children:[s.jsx("h4",{className:"text-sm font-medium text-gray-800",children:"Información"}),s.jsx("p",{className:"text-sm text-gray-600 mt-1",children:"Después de crear el rol, podrás asignar permisos específicos usando la Matriz de Permisos. Los roles inactivos no aparecerán como opciones al crear usuarios."})]})]})}),s.jsxs("div",{className:"flex justify-end space-x-3 pt-4 border-t",children:[s.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500",disabled:c,children:"Cancelar"}),s.jsx("button",{type:"submit",className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed",disabled:c,children:c?s.jsxs("span",{className:"flex items-center",children:[s.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Guardando..."]}):u?"Actualizar Rol":"Crear Rol"})]})]})})},Pp=({isOpen:e,onClose:t,roles:a=[],modulos:r=[],permisos:l=[],onSuccess:n})=>{const[o,i]=g.useState({}),[c,m]=g.useState(!1),[u,x]=g.useState(!1),[f,b]=g.useState({});g.useEffect(()=>{e&&j()},[e]);const j=async()=>{m(!0);try{const N=await Gt.getPermissionsMatrix();i(N),b({})}catch(N){console.error("Error cargando matriz de permisos:",N)}finally{m(!1)}},v=(N,R,z)=>{var Q,A;const C=`role_${N}`,k=`module_${R}`,_=`permission_${z}`,H=`${N}_${R}_${z}`;return f.hasOwnProperty(H)?f[H]:((A=(Q=o[C])==null?void 0:Q[k])==null?void 0:A[_])||!1},S=(N,R,z)=>{const C=`${N}_${R}_${z}`,k=v(N,R,z);b(_=>({..._,[C]:!k}))},h=(N,R)=>{const z=l.every(C=>v(N,R,C.id));l.forEach(C=>{const k=`${N}_${R}_${C.id}`;b(_=>({..._,[k]:!z}))})},d=N=>{const R=r.every(z=>l.every(C=>v(N,z.id,C.id)));r.forEach(z=>{l.forEach(C=>{const k=`${N}_${z.id}_${C.id}`;b(_=>({..._,[k]:!R}))})})},p=async()=>{x(!0);try{const N={};Object.entries(f).forEach(([R,z])=>{const[C,k,_]=R.split("_");N[C]||(N[C]={}),N[C][k]||(N[C][k]=[]),z&&N[C][k].push(_)});for(const[R,z]of Object.entries(N))for(const[C,k]of Object.entries(z))await Gt.assignPermissions(R,C,k);n&&n(),t()}catch(N){console.error("Error guardando permisos:",N),alert("Error al guardar los permisos")}finally{x(!1)}},y=Object.keys(f).length>0,E=N=>N?"bg-green-100 text-green-800 border-green-200":"bg-gray-100 text-gray-500 border-gray-200",w=N=>({super_admin:"bg-purple-600 text-white",admin:"bg-red-600 text-white",supervisor:"bg-blue-600 text-white",operador:"bg-green-600 text-white",conductor:"bg-yellow-600 text-white"})[N]||"bg-gray-600 text-white";return s.jsx(Ie,{isOpen:e,onClose:t,title:"Matriz de Permisos",size:"full",children:s.jsxs("div",{className:"space-y-4",children:[c?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"}),s.jsx("span",{className:"ml-2 text-gray-500",children:"Cargando matriz de permisos..."})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4 mb-4",children:s.jsxs("div",{className:"flex items-start",children:[s.jsx("svg",{className:"w-5 h-5 text-blue-600 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),s.jsxs("div",{className:"ml-3",children:[s.jsx("h4",{className:"text-sm font-medium text-blue-800",children:"Instrucciones"}),s.jsxs("p",{className:"text-sm text-blue-700 mt-1",children:["• Haz clic en las celdas para otorgar/revocar permisos individuales",s.jsx("br",{}),"• Haz clic en el nombre del módulo para alternar todos los permisos del módulo",s.jsx("br",{}),"• Haz clic en el nombre del rol para alternar todos los permisos del rol"]})]})]})}),s.jsx("div",{className:"overflow-x-auto border border-gray-200 rounded-lg",children:s.jsxs("table",{className:"min-w-full",children:[s.jsx("thead",{className:"bg-gray-50",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider sticky left-0 bg-gray-50 z-10",children:"Módulo / Rol"}),a.map(N=>s.jsx("th",{className:`px-3 py-3 text-center text-xs font-medium uppercase tracking-wider min-w-32 cursor-pointer hover:opacity-80 ${w(N.nombre)}`,onClick:()=>d(N.id),title:`Alternar todos los permisos para ${N.nombre}`,children:s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("span",{children:N.nombre}),s.jsxs("span",{className:"text-xs opacity-75 mt-1",children:["(",N.descripcion||"Sin descripción",")"]})]})},N.id))]})}),s.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:r.map((N,R)=>s.jsxs(Of.Fragment,{children:[s.jsxs("tr",{className:"bg-gray-25",children:[s.jsxs("td",{className:"px-4 py-3 font-medium text-gray-900 bg-gray-50 sticky left-0 z-10 border-r border-gray-200 cursor-pointer hover:bg-gray-100",onClick:()=>a.forEach(z=>h(z.id,N.id)),title:`Alternar todos los permisos para el módulo ${N.nombre}`,children:[s.jsxs("div",{className:"flex items-center",children:[s.jsx("svg",{className:"w-4 h-4 text-gray-400 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),s.jsx("span",{className:"font-semibold capitalize",children:N.nombre})]}),s.jsx("div",{className:"text-xs text-gray-500 mt-1",children:N.descripcion||"Sin descripción"})]}),a.map(z=>s.jsx("td",{className:"px-3 py-3 text-center bg-gray-25",children:s.jsxs("div",{className:"text-xs text-gray-500",children:[l.filter(C=>v(z.id,N.id,C.id)).length," / ",l.length]})},`${N.id}-${z.id}-header`))]}),l.map((z,C)=>s.jsxs("tr",{className:"hover:bg-gray-50",children:[s.jsx("td",{className:"px-4 py-2 text-sm text-gray-700 bg-white sticky left-0 z-10 border-r border-gray-200",children:s.jsxs("div",{className:"flex items-center pl-6",children:[s.jsx("svg",{className:"w-3 h-3 text-gray-300 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),s.jsx("span",{className:"capitalize",children:z.nombre})]})}),a.map(k=>{const _=v(k.id,N.id,z.id),H=`${k.id}_${N.id}_${z.id}`,Q=f.hasOwnProperty(H);return s.jsx("td",{className:"px-3 py-2 text-center",children:s.jsx("button",{onClick:()=>S(k.id,N.id,z.id),className:`w-full px-2 py-1 rounded text-xs font-medium border transition-colors ${E(_)} ${Q?"ring-2 ring-blue-500 ring-opacity-50":""} hover:opacity-80`,title:`${_?"Revocar":"Otorgar"} permiso ${z.nombre} para ${k.nombre} en ${N.nombre}`,children:_?"✓":"✗"})},`${k.id}-${N.id}-${z.id}`)})]},`${N.id}-${z.id}`))]},N.id))})]})}),y&&s.jsx("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-4",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("svg",{className:"w-5 h-5 text-yellow-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"})}),s.jsxs("span",{className:"ml-2 text-sm text-yellow-800",children:["Tienes ",Object.keys(f).length," cambio(s) pendiente(s). No olvides guardar."]})]})})]}),s.jsxs("div",{className:"flex justify-between items-center pt-4 border-t",children:[s.jsx("button",{type:"button",onClick:()=>{b({}),j()},className:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500",disabled:c||u||!y,children:"Revertir Cambios"}),s.jsxs("div",{className:"flex space-x-3",children:[s.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500",disabled:u,children:"Cerrar"}),s.jsx("button",{onClick:p,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed",disabled:c||u||!y,children:u?s.jsxs("span",{className:"flex items-center",children:[s.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Guardando..."]}):"Guardar Cambios"})]})]})]})})},eu=()=>{const{hasPermission:e}=sa(),[t,a]=g.useState([]),[r,l]=g.useState([]),[n,o]=g.useState([]),[i,c]=g.useState(!0),[m,u]=g.useState(!1),[x,f]=g.useState(!1),[b,j]=g.useState(null),[v,S]=g.useState(!1),[h,d]=g.useState(""),[p,y]=g.useState([]);g.useEffect(()=>{E()},[]);const E=async()=>{c(!0);try{await Promise.all([w(),N(),R()])}finally{c(!1)}},w=async()=>{try{const T=await Gt.getRoles();a(T)}catch(T){console.error("Error cargando roles:",T)}},N=async()=>{try{const T=await Gt.getModulos();l(T)}catch(T){console.error("Error cargando módulos:",T)}},R=async()=>{try{const T=await Gt.getPermisos();o(T)}catch(T){console.error("Error cargando permisos:",T)}},z=t.filter(T=>T.nombre.toLowerCase().includes(h.toLowerCase())||T.descripcion&&T.descripcion.toLowerCase().includes(h.toLowerCase())),C=()=>{j(null),u(!0)},k=T=>{j(T),f(!0)},_=async()=>{if(window.confirm(`¿Estás seguro de eliminar ${p.length} rol(es)?`))try{await Promise.all(p.map(T=>Gt.deleteRole(T))),await w(),y([]),alert("Roles eliminados exitosamente")}catch(T){console.error("Error eliminando roles:",T),alert("Error al eliminar roles")}},H=async T=>{try{await Gt.updateRole(T.id,{activo:T.activo?0:1}),await w()}catch($){console.error("Error cambiando estado:",$),alert("Error al cambiar el estado del rol")}},Q=()=>{w(),u(!1),f(!1),j(null)},A=T=>{y($=>$.includes(T)?$.filter(I=>I!==T):[...$,T])},O=()=>{y(p.length===z.length?[]:z.map(T=>T.id))},B=T=>({super_admin:"bg-purple-100 text-purple-800",admin:"bg-red-100 text-red-800",supervisor:"bg-blue-100 text-blue-800",operador:"bg-green-100 text-green-800",conductor:"bg-yellow-100 text-yellow-800"})[T]||"bg-gray-100 text-gray-800";return s.jsxs(Nt,{children:[s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Configuración - Roles y Permisos"}),s.jsx("p",{className:"text-gray-600 mt-1",children:"Administra roles del sistema y asigna permisos granulares"})]}),s.jsxs("div",{className:"mt-4 sm:mt-0 flex space-x-3",children:[s.jsx(we,{module:"configuracion",permission:"actualizar",children:s.jsxs("button",{onClick:()=>S(!0),className:"inline-flex items-center px-4 py-2 bg-green-600 text-white text-sm font-medium rounded-lg hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500",children:[s.jsx("svg",{className:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.031 9-11.622 0-1.042-.133-2.052-.382-3.016z"})}),"Matriz de Permisos"]})}),s.jsx(we,{module:"configuracion",permission:"crear",children:s.jsxs("button",{onClick:C,className:"inline-flex items-center px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("svg",{className:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),"Nuevo Rol"]})})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-6",children:[s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"w-8 h-8 bg-blue-100 rounded-lg flex items-center justify-center",children:s.jsx("svg",{className:"w-5 h-5 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Total Roles"}),s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:t.length})]})]})}),s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"w-8 h-8 bg-green-100 rounded-lg flex items-center justify-center",children:s.jsx("svg",{className:"w-5 h-5 text-green-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Activos"}),s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:t.filter(T=>T.activo).length})]})]})}),s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"w-8 h-8 bg-yellow-100 rounded-lg flex items-center justify-center",children:s.jsx("svg",{className:"w-5 h-5 text-yellow-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Módulos"}),s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:r.length})]})]})}),s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"w-8 h-8 bg-purple-100 rounded-lg flex items-center justify-center",children:s.jsx("svg",{className:"w-5 h-5 text-purple-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.031 9-11.622 0-1.042-.133-2.052-.382-3.016z"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Permisos"}),s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:n.length})]})]})})]}),s.jsxs("div",{className:"bg-white rounded-lg shadow",children:[s.jsx("div",{className:"p-6 border-b border-gray-200",children:s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"text",placeholder:"Buscar roles...",value:h,onChange:T=>d(T.target.value),className:"w-full sm:w-80 pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),s.jsx("svg",{className:"absolute left-3 top-2.5 h-5 w-5 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})]}),s.jsxs("div",{className:"mt-4 sm:mt-0 flex items-center space-x-3",children:[p.length>0&&s.jsx(we,{module:"configuracion",permission:"eliminar",children:s.jsxs("button",{onClick:_,className:"inline-flex items-center px-3 py-2 text-sm font-medium text-red-600 hover:text-red-800",children:[s.jsx("svg",{className:"w-4 h-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})}),"Eliminar (",p.length,")"]})}),s.jsxs("span",{className:"text-sm text-gray-500",children:[z.length," de ",t.length," roles"]})]})]})}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[s.jsx("thead",{className:"bg-gray-50",children:s.jsxs("tr",{children:[s.jsx("th",{className:"w-4 px-6 py-3",children:s.jsx("input",{type:"checkbox",checked:p.length===z.length&&z.length>0,onChange:O,className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"})}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Rol"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Descripción"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Estado"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Usuarios"}),s.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Acciones"})]})}),s.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:i?s.jsx("tr",{children:s.jsx("td",{colSpan:"6",className:"px-6 py-12 text-center",children:s.jsxs("div",{className:"flex items-center justify-center",children:[s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"}),s.jsx("span",{className:"ml-2 text-gray-500",children:"Cargando roles..."})]})})}):z.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:"6",className:"px-6 py-12 text-center text-gray-500",children:"No se encontraron roles"})}):z.map(T=>s.jsxs("tr",{className:"hover:bg-gray-50",children:[s.jsx("td",{className:"px-6 py-4",children:s.jsx("input",{type:"checkbox",checked:p.includes(T.id),onChange:()=>A(T.id),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"w-10 h-10 bg-gradient-to-br from-blue-400 to-blue-600 rounded-full flex items-center justify-center text-white font-medium",children:T.nombre.charAt(0).toUpperCase()}),s.jsx("div",{className:"ml-4",children:s.jsx("div",{className:"flex items-center",children:s.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${B(T.nombre)} mr-2`,children:T.nombre})})})]})}),s.jsx("td",{className:"px-6 py-4",children:s.jsx("div",{className:"text-sm text-gray-900",children:T.descripcion||"Sin descripción"})}),s.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[s.jsx(we,{module:"configuracion",permission:"actualizar",children:s.jsx("button",{onClick:()=>H(T),className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${T.activo==1?"bg-green-100 text-green-800 hover:bg-green-200":"bg-red-100 text-red-800 hover:bg-red-200"} transition-colors cursor-pointer`,children:T.activo==1?"Activo":"Inactivo"})}),s.jsx(we,{module:"configuracion",permission:"actualizar",fallback:s.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${T.activo==1?"bg-green-100 text-green-800":"bg-red-100 text-red-800"}`,children:T.activo==1?"Activo":"Inactivo"}),hideIfNoAccess:!1})]}),s.jsxs("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:[T.usuarios_count||0," usuarios"]}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:s.jsx("div",{className:"flex items-center justify-end space-x-2",children:s.jsx(we,{module:"configuracion",permission:"actualizar",children:s.jsx("button",{onClick:()=>k(T),className:"text-blue-600 hover:text-blue-700 p-1 rounded",title:"Editar rol",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})})})})})]},T.id))})]})})]})]}),s.jsx(Id,{isOpen:m,onClose:()=>u(!1),onSuccess:Q}),s.jsx(Id,{isOpen:x,onClose:()=>f(!1),role:b,onSuccess:Q}),s.jsx(Pp,{isOpen:v,onClose:()=>S(!1),roles:t,modulos:r,permisos:n,onSuccess:E})]})};class Fp{async obtenerTodos(t={}){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getProductos",...t})});if(a.success)return a.data||[];throw new Error(a.message||"Error obteniendo productos")}catch(a){throw console.error("Error fetching productos:",a),a}}async obtenerPorId(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getProducto",id:t})});if(a.success)return a.data;throw new Error(a.message||"Error obteniendo producto")}catch(a){throw console.error("Error fetching producto:",a),a}}async crear(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"createProducto",...t})});if(a.success)return a.data;throw new Error(a.message||"Error creando producto")}catch(a){throw console.error("Error creating producto:",a),a}}async actualizar(t,a){try{const r=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"updateProducto",id:t,...a})});if(r.success)return r.data;throw new Error(r.message||"Error actualizando producto")}catch(r){throw console.error("Error updating producto:",r),r}}async eliminar(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"deleteProducto",id:t})});if(a.success)return!0;throw new Error(a.message||"Error eliminando producto")}catch(a){throw console.error("Error deleting producto:",a),a}}async obtenerCategorias(){try{const t=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getCategorias"})});if(t.success)return t.data||[];throw new Error(t.message||"Error obteniendo categorías")}catch(t){throw console.error("Error fetching categorias:",t),t}}async crearCategoria(t,a){try{const r=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"createCategoria",nombre:t,descripcion:a})});if(r.success)return r.data;throw new Error(r.message||"Error creando categoría")}catch(r){throw console.error("Error creating categoria:",r),r}}async actualizarStock(t,a,r=null,l=null){try{const n=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"updateStock",id:t,stock:a,motivo_id:r,motivo_texto:l})});if(n.success)return n.data;throw new Error(n.message||"Error actualizando stock")}catch(n){throw console.error("Error updating stock:",n),n}}async obtenerMovimientos(t=null,a=50){try{const r=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getMovimientos",producto_id:t,limit:a})});if(r.success)return r.data||[];throw new Error(r.message||"Error obteniendo movimientos")}catch(r){throw console.error("Error fetching movimientos:",r),r}}async obtenerEstadisticas(){try{const t=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getEstadisticasProductos"})});if(t.success)return t.data||{};throw new Error(t.message||"Error obteniendo estadísticas")}catch(t){throw console.error("Error fetching estadisticas:",t),t}}}const Me=new Fp;class Ip{async uploadImage(t){try{const a=new FormData;a.append("image",t),a.append("tipo","uploadImage");const r=localStorage.getItem("token"),l=await fetch(`${U.baseURL}/reportes/funciones_php/api.php`,{method:"POST",headers:{Authorization:`Bearer ${r}`},body:a}),n=await l.json();if(!l.ok||!n.success)throw new Error(n.message||"Error subiendo imagen");return n.data}catch(a){throw console.error("Error uploading image:",a),a}}async deleteImage(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"deleteImage",image_url:t})});if(a.success)return!0;throw new Error(a.message||"Error eliminando imagen")}catch(a){throw console.error("Error deleting image:",a),a}}validateImage(t){if(!["image/jpeg","image/jpg","image/png","image/gif","image/webp"].includes(t.type))throw new Error("Tipo de archivo no permitido. Solo se permiten: JPG, PNG, GIF, WEBP");if(t.size>5242880)throw new Error("El archivo es demasiado grande. Máximo 5MB");return!0}getImageUrl(t){return t?t.startsWith("http://")||t.startsWith("https://")?t:`${U.baseURL}/${t}`:null}}const as=new Ip,e2=({onImageUploaded:e,currentImageUrl:t,onImageDeleted:a,className:r=""})=>{const[l,n]=g.useState(!1),[o,i]=g.useState(t),c=g.useRef(null),m=async f=>{const b=f.target.files[0];if(b)try{as.validateImage(b);const j=new FileReader;j.onload=S=>{i(S.target.result)},j.readAsDataURL(b),n(!0);const v=await as.uploadImage(b);e&&e(v.url),i(as.getImageUrl(v.url))}catch(j){console.error("Error uploading image:",j),alert(j.message||"Error al subir imagen"),i(t)}finally{n(!1),c.current&&(c.current.value="")}},u=async()=>{if(t&&confirm("¿Estás seguro de eliminar esta imagen?"))try{n(!0),await as.deleteImage(t),i(null),a&&a()}catch(f){console.error("Error deleting image:",f),alert(f.message||"Error al eliminar imagen")}finally{n(!1)}},x=()=>{c.current&&c.current.click()};return s.jsxs("div",{className:`space-y-4 ${r}`,children:[s.jsx("div",{className:"flex justify-center",children:o?s.jsxs("div",{className:"relative",children:[s.jsx("img",{src:o.startsWith("data:")?o:as.getImageUrl(o),alt:"Preview",className:"w-32 h-32 object-cover rounded-lg border border-gray-300",onError:f=>{f.target.src="/placeholder-image.png",f.target.onerror=null}}),!l&&s.jsx("button",{type:"button",onClick:u,className:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full w-6 h-6 flex items-center justify-center hover:bg-red-600 transition-colors",title:"Eliminar imagen",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}):s.jsx("div",{className:"w-32 h-32 border-2 border-dashed border-gray-300 rounded-lg flex items-center justify-center bg-gray-50",children:s.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})})}),s.jsx("input",{ref:c,type:"file",accept:"image/*",onChange:m,className:"hidden"}),s.jsx("div",{className:"flex justify-center space-x-2",children:s.jsx("button",{type:"button",onClick:x,disabled:l,className:"px-4 py-2 bg-blue-600 text-white text-sm rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed",children:l?s.jsxs(s.Fragment,{children:[s.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white inline",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Subiendo..."]}):s.jsxs(s.Fragment,{children:[s.jsx("svg",{className:"w-4 h-4 mr-2 inline",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),o?"Cambiar imagen":"Subir imagen"]})})}),s.jsx("p",{className:"text-xs text-gray-500 text-center",children:"JPG, PNG, GIF, WEBP hasta 5MB"})]})},t2=({isOpen:e,onClose:t,onSave:a,product:r,categories:l})=>{const[n,o]=g.useState({codigo:"",nombre:"",categoria_id:"",precio:"",costo:"",stock_actual:"",stock_minimo:"",stock_maximo:"",unidad_medida:"unidad",codigo_barras:"",imagen_url:"",activo:!0}),[i,c]=g.useState({}),[m,u]=g.useState(!1),x=[{value:"unidad",label:"Unidad"},{value:"kg",label:"Kilogramo"},{value:"g",label:"Gramo"},{value:"l",label:"Litro"},{value:"ml",label:"Mililitro"},{value:"caja",label:"Caja"},{value:"paquete",label:"Paquete"},{value:"m",label:"Metro"},{value:"cm",label:"Centímetro"}];g.useEffect(()=>{o(r?{codigo:r.codigo||"",nombre:r.nombre||"",categoria_id:r.categoria_id||"",precio:r.precio||"",costo:r.costo||"",stock_actual:r.stock_actual||"",stock_minimo:r.stock_minimo||"",stock_maximo:r.stock_maximo||"",unidad_medida:r.unidad_medida||"unidad",codigo_barras:r.codigo_barras||"",imagen_url:r.imagen_url||"",activo:r.activo==1}:{codigo:"",nombre:"",categoria_id:"",precio:"",costo:"",stock_actual:"0",stock_minimo:"0",stock_maximo:"100",unidad_medida:"unidad",codigo_barras:"",imagen_url:"",activo:!0}),c({})},[r,e]);const f=v=>{const{name:S,value:h,type:d,checked:p}=v.target;o(y=>({...y,[S]:d==="checkbox"?p:h})),i[S]&&c(y=>({...y,[S]:""}))},b=()=>{const v={};if(n.codigo.trim()||(v.codigo="El código es requerido"),n.nombre.trim()||(v.nombre="El nombre es requerido"),(!n.precio||parseFloat(n.precio)<0)&&(v.precio="El precio debe ser mayor o igual a 0"),n.costo&&parseFloat(n.costo)<0&&(v.costo="El costo debe ser mayor o igual a 0"),n.stock_actual&&parseInt(n.stock_actual)<0&&(v.stock_actual="El stock actual debe ser mayor o igual a 0"),n.stock_minimo&&parseInt(n.stock_minimo)<0&&(v.stock_minimo="El stock mínimo debe ser mayor o igual a 0"),n.stock_maximo&&parseInt(n.stock_maximo)<0&&(v.stock_maximo="El stock máximo debe ser mayor o igual a 0"),n.stock_minimo&&n.stock_maximo&&parseInt(n.stock_minimo)>parseInt(n.stock_maximo)&&(v.stock_maximo="El stock máximo debe ser mayor al mínimo"),n.imagen_url&&n.imagen_url.startsWith("http"))try{new URL(n.imagen_url)}catch{v.imagen_url="La URL de imagen no es válida"}return v},j=async v=>{v.preventDefault();const S=b();if(Object.keys(S).length>0){c(S);return}u(!0);try{const h={...n,precio:parseFloat(n.precio)||0,costo:parseFloat(n.costo)||0,stock_actual:parseInt(n.stock_actual)||0,stock_minimo:parseInt(n.stock_minimo)||0,stock_maximo:parseInt(n.stock_maximo)||100,activo:n.activo?1:0,categoria_id:n.categoria_id||null};let d;r?d=await Me.actualizar(r.id,h):d=await Me.crear(h),a()}catch(h){console.error("Error guardando producto:",h),c({general:h.message||"Error al guardar producto"})}finally{u(!1)}};return s.jsx(Ie,{isOpen:e,onClose:t,title:r?"Editar Producto":"Nuevo Producto",children:s.jsxs("form",{onSubmit:j,className:"space-y-4",children:[i.general&&s.jsx("div",{className:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded",children:i.general}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Código *"}),s.jsx("input",{type:"text",name:"codigo",value:n.codigo,onChange:f,className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${i.codigo?"border-red-500":"border-gray-300"}`,placeholder:"Código del producto"}),i.codigo&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:i.codigo})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Nombre *"}),s.jsx("input",{type:"text",name:"nombre",value:n.nombre,onChange:f,className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${i.nombre?"border-red-500":"border-gray-300"}`,placeholder:"Nombre del producto"}),i.nombre&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:i.nombre})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Categoría"}),s.jsxs("select",{name:"categoria_id",value:n.categoria_id,onChange:f,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("option",{value:"",children:"Seleccionar categoría"}),l.map(v=>s.jsx("option",{value:v.id,children:v.nombre},v.id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Unidad de Medida"}),s.jsx("select",{name:"unidad_medida",value:n.unidad_medida,onChange:f,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",children:x.map(v=>s.jsx("option",{value:v.value,children:v.label},v.value))})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Precio *"}),s.jsx("input",{type:"number",name:"precio",value:n.precio,onChange:f,step:"0.01",min:"0",className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${i.precio?"border-red-500":"border-gray-300"}`,placeholder:"0.00"}),i.precio&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:i.precio})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Costo"}),s.jsx("input",{type:"number",name:"costo",value:n.costo,onChange:f,step:"0.01",min:"0",className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${i.costo?"border-red-500":"border-gray-300"}`,placeholder:"0.00"}),i.costo&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:i.costo})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Stock Actual"}),s.jsx("input",{type:"number",name:"stock_actual",value:n.stock_actual,onChange:f,min:"0",className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${i.stock_actual?"border-red-500":"border-gray-300"}`,placeholder:"0"}),i.stock_actual&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:i.stock_actual})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Stock Mínimo"}),s.jsx("input",{type:"number",name:"stock_minimo",value:n.stock_minimo,onChange:f,min:"0",className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${i.stock_minimo?"border-red-500":"border-gray-300"}`,placeholder:"0"}),i.stock_minimo&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:i.stock_minimo})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Stock Máximo"}),s.jsx("input",{type:"number",name:"stock_maximo",value:n.stock_maximo,onChange:f,min:"0",className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${i.stock_maximo?"border-red-500":"border-gray-300"}`,placeholder:"100"}),i.stock_maximo&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:i.stock_maximo})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Código de Barras"}),s.jsx("input",{type:"text",name:"codigo_barras",value:n.codigo_barras,onChange:f,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Código de barras"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Imagen del Producto"}),s.jsx(e2,{currentImageUrl:n.imagen_url,onImageUploaded:v=>o(S=>({...S,imagen_url:v})),onImageDeleted:()=>o(v=>({...v,imagen_url:""}))}),s.jsx("div",{className:"mt-3",children:s.jsxs("details",{className:"group",children:[s.jsx("summary",{className:"text-sm text-blue-600 cursor-pointer hover:text-blue-800",children:"O usar URL externa"}),s.jsx("div",{className:"mt-2",children:s.jsx("input",{type:n.imagen_url&&!n.imagen_url.startsWith("http")?"text":"url",name:"imagen_url",value:n.imagen_url,onChange:f,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm",placeholder:"https://ejemplo.com/imagen.jpg"})})]})})]})]}),s.jsx("div",{children:s.jsxs("label",{className:"flex items-center",children:[s.jsx("input",{type:"checkbox",name:"activo",checked:n.activo,onChange:f,className:"mr-2"}),s.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Producto activo"})]})}),s.jsxs("div",{className:"flex justify-end space-x-3 pt-4",children:[s.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-md hover:bg-gray-300",children:"Cancelar"}),s.jsx("button",{type:"submit",disabled:m,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:opacity-50",children:m?"Guardando...":r?"Actualizar":"Crear"})]})]})})};class a2{async obtenerTodos(t={}){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getMotivosStock",...t})});if(a.success)return a.data||[];throw new Error(a.message||"Error obteniendo motivos")}catch(a){throw console.error("Error fetching motivos:",a),a}}async obtenerPorId(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getMotivoStock",id:t})});if(a.success)return a.data;throw new Error(a.message||"Error obteniendo motivo")}catch(a){throw console.error("Error fetching motivo:",a),a}}async crear(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"createMotivoStock",...t})});if(a.success)return a.data;throw new Error(a.message||"Error creando motivo")}catch(a){throw console.error("Error creating motivo:",a),a}}async actualizar(t,a){try{const r=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"updateMotivoStock",id:t,...a})});if(r.success)return r.data;throw new Error(r.message||"Error actualizando motivo")}catch(r){throw console.error("Error updating motivo:",r),r}}async eliminar(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"deleteMotivoStock",id:t})});if(a.success)return!0;throw new Error(a.message||"Error eliminando motivo")}catch(a){throw console.error("Error deleting motivo:",a),a}}async obtenerPorTipo(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getMotivosPorTipo",tipo_movimiento:t})});if(a.success)return a.data||[];throw new Error(a.message||"Error obteniendo motivos por tipo")}catch(a){throw console.error("Error fetching motivos por tipo:",a),a}}async establecerPredeterminado(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"setDefaultMotivoStock",id:t})});if(a.success)return!0;throw new Error(a.message||"Error estableciendo predeterminado")}catch(a){throw console.error("Error setting default motivo:",a),a}}async obtenerEstadisticas(){try{const t=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getEstadisticasMotivos"})});if(t.success)return t.data||{};throw new Error(t.message||"Error obteniendo estadísticas")}catch(t){throw console.error("Error fetching estadisticas:",t),t}}}const Mt=new a2,xf=({isOpen:e,onClose:t,onSave:a,product:r})=>{const[l,n]=g.useState({stock_nuevo:"",motivo_id:"",motivo_personalizado:""}),[o,i]=g.useState({}),[c,m]=g.useState(!1),[u,x]=g.useState([]),[f,b]=g.useState(!1);g.useEffect(()=>{e&&(r&&n({stock_nuevo:r.stock_actual||"",motivo_id:"",motivo_personalizado:""}),i({}),j())},[r,e]);const j=async()=>{if(!f){b(!0);try{const w=await Mt.obtenerTodos({activo:1});x(w);const N=w.find(R=>R.predeterminado==1);N&&!l.motivo_id&&n(R=>({...R,motivo_id:N.id.toString()}))}catch(w){console.error("Error cargando motivos:",w)}finally{b(!1)}}},v=w=>{const{name:N,value:R}=w.target;n(z=>({...z,[N]:R})),o[N]&&i(z=>({...z,[N]:""}))},S=()=>{const w={};!l.stock_nuevo&&l.stock_nuevo!=="0"&&(w.stock_nuevo="El stock nuevo es requerido"),l.stock_nuevo&&parseInt(l.stock_nuevo)<0&&(w.stock_nuevo="El stock debe ser mayor o igual a 0"),l.motivo_id||(w.motivo_id="Debe seleccionar un motivo");const N=u.find(R=>R.id.toString()===l.motivo_id);return N&&N.nombre==="Otro"&&!l.motivo_personalizado.trim()&&(w.motivo_personalizado="Debe especificar el motivo"),w},h=async w=>{w.preventDefault();const N=S();if(Object.keys(N).length>0){i(N);return}m(!0);try{const R=await Me.actualizarStock(r.id,parseInt(l.stock_nuevo),l.motivo_id||null,l.motivo_personalizado||null);a()}catch(R){console.error("Error actualizando stock:",R),i({general:"Error al actualizar stock"})}finally{m(!1)}},d=()=>!r||!l.stock_nuevo?0:parseInt(l.stock_nuevo)-parseInt(r.stock_actual),p=()=>{const w=d();return w>0?{tipo:"entrada",clase:"text-green-600"}:w<0?{tipo:"salida",clase:"text-red-600"}:{tipo:"ajuste",clase:"text-gray-600"}};if(!r)return null;const y=d(),E=p();return s.jsx(Ie,{isOpen:e,onClose:t,title:"Actualizar Stock",children:s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[o.general&&s.jsx("div",{className:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded",children:o.general}),s.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg",children:[s.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:"Información del Producto"}),s.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-600",children:"Código:"}),s.jsx("span",{className:"ml-2 font-medium",children:r.codigo})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-600",children:"Nombre:"}),s.jsx("span",{className:"ml-2 font-medium",children:r.nombre})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-600",children:"Stock Actual:"}),s.jsxs("span",{className:"ml-2 font-medium text-blue-600",children:[r.stock_actual," ",r.unidad_medida]})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-600",children:"Stock Mínimo:"}),s.jsxs("span",{className:"ml-2 font-medium",children:[r.stock_minimo," ",r.unidad_medida]})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Stock Nuevo *"}),s.jsx("input",{type:"number",name:"stock_nuevo",value:l.stock_nuevo,onChange:v,min:"0",className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${o.stock_nuevo?"border-red-500":"border-gray-300"}`,placeholder:"Nuevo stock"}),o.stock_nuevo&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:o.stock_nuevo})]}),l.stock_nuevo&&s.jsx("div",{className:"bg-blue-50 p-3 rounded-lg",children:s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("span",{className:"text-sm text-gray-600",children:"Diferencia:"}),s.jsxs("span",{className:`font-medium ${E.clase}`,children:[y>0?"+":"",y," ",r.unidad_medida,y!==0&&s.jsxs("span",{className:"ml-2 text-xs",children:["(",E.tipo,")"]})]})]})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Motivo *"}),s.jsxs("select",{name:"motivo_id",value:l.motivo_id,onChange:v,disabled:f,className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${o.motivo_id?"border-red-500":"border-gray-300"}`,children:[s.jsx("option",{value:"",children:f?"Cargando motivos...":"Seleccionar motivo"}),u.map(w=>s.jsx("option",{value:w.id.toString(),children:w.nombre},w.id))]}),o.motivo_id&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:o.motivo_id})]}),(()=>{const w=u.find(N=>N.id.toString()===l.motivo_id);return w&&w.nombre==="Otro"})()&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Especificar motivo *"}),s.jsx("input",{type:"text",name:"motivo_personalizado",value:l.motivo_personalizado,onChange:v,className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${o.motivo_personalizado?"border-red-500":"border-gray-300"}`,placeholder:"Especificar el motivo"}),o.motivo_personalizado&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:o.motivo_personalizado})]}),l.stock_nuevo&&parseInt(l.stock_nuevo)<=parseInt(r.stock_minimo)&&s.jsx("div",{className:"bg-yellow-50 border border-yellow-200 text-yellow-800 px-4 py-3 rounded",children:s.jsxs("div",{className:"flex",children:[s.jsx("svg",{className:"w-5 h-5 mr-2",fill:"currentColor",viewBox:"0 0 20 20",children:s.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),s.jsxs("div",{children:[s.jsx("strong",{children:"Atención:"})," El stock quedará por debajo del mínimo recomendado (",r.stock_minimo," ",r.unidad_medida,")."]})]})}),s.jsxs("div",{className:"flex justify-end space-x-3 pt-4",children:[s.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-md hover:bg-gray-300",children:"Cancelar"}),s.jsx("button",{type:"submit",disabled:c||y===0,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:opacity-50",children:c?"Actualizando...":"Actualizar Stock"})]})]})})},s2=({isOpen:e,onClose:t,onSave:a})=>{const[r,l]=g.useState({nombre:"",descripcion:""}),[n,o]=g.useState({}),[i,c]=g.useState(!1);g.useEffect(()=>{e&&(l({nombre:"",descripcion:""}),o({}))},[e]);const m=f=>{const{name:b,value:j}=f.target;l(v=>({...v,[b]:j})),n[b]&&o(v=>({...v,[b]:""}))},u=()=>{const f={};return r.nombre.trim()||(f.nombre="El nombre de la categoría es requerido"),f},x=async f=>{f.preventDefault();const b=u();if(Object.keys(b).length>0){o(b);return}c(!0);try{const j=await Me.crearCategoria(r.nombre.trim(),r.descripcion.trim());a()}catch(j){console.error("Error creando categoría:",j),o({general:"Error al crear categoría"})}finally{c(!1)}};return s.jsx(Ie,{isOpen:e,onClose:t,title:"Nueva Categoría",children:s.jsxs("form",{onSubmit:x,className:"space-y-4",children:[n.general&&s.jsx("div",{className:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded",children:n.general}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Nombre de la Categoría *"}),s.jsx("input",{type:"text",name:"nombre",value:r.nombre,onChange:m,className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${n.nombre?"border-red-500":"border-gray-300"}`,placeholder:"Ej: Alimentos, Bebidas, Limpieza...",maxLength:100}),n.nombre&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:n.nombre})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Descripción"}),s.jsx("textarea",{name:"descripcion",value:r.descripcion,onChange:m,rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Descripción opcional de la categoría"})]}),s.jsxs("div",{className:"flex justify-end space-x-3 pt-4",children:[s.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-md hover:bg-gray-300",children:"Cancelar"}),s.jsx("button",{type:"submit",disabled:i,className:"px-4 py-2 text-sm font-medium text-white bg-green-600 rounded-md hover:bg-green-700 disabled:opacity-50",children:i?"Creando...":"Crear Categoría"})]})]})})},r2=()=>{const{hasPermission:e}=sa(),[t,a]=g.useState([]),[r,l]=g.useState([]),[n,o]=g.useState(!0),[i,c]=g.useState(null),[m,u]=g.useState({search:"",categoria_id:"",activo:"1",stock_bajo:!1}),[x,f]=g.useState(!1),[b,j]=g.useState(!1),[v,S]=g.useState(!1),[h,d]=g.useState(null);g.useEffect(()=>{p()},[]),g.useEffect(()=>{y()},[m]);const p=async()=>{try{o(!0),await Promise.all([y(),E()])}catch(A){console.error("Error cargando datos:",A),c("Error al cargar los datos")}finally{o(!1)}},y=async()=>{try{const A=Object.fromEntries(Object.entries(m).filter(([B,T])=>T!==""&&T!==!1)),O=await Me.obtenerTodos(A);a(O)}catch(A){console.error("Error cargando productos:",A),c("Error al cargar productos")}},E=async()=>{try{const A=await Me.obtenerCategorias();l(A)}catch(A){console.error("Error cargando categorías:",A)}},w=(A,O)=>{u(B=>({...B,[A]:O}))},N=()=>{u({search:"",categoria_id:"",activo:"1",stock_bajo:!1})},R=async()=>{await y(),f(!1),d(null)},z=async()=>{await y(),j(!1),d(null)},C=async()=>{await E(),S(!1)},k=A=>{d(A),f(!0)},_=A=>{d(A),j(!0)},H=async A=>{if(window.confirm("¿Está seguro de eliminar este producto?"))try{await Me.eliminar(A),await y()}catch(O){console.error("Error eliminando producto:",O),c("Error al eliminar producto")}},Q=A=>{switch(A){case"bajo":return"text-red-600 bg-red-100";case"alto":return"text-blue-600 bg-blue-100";default:return"text-green-600 bg-green-100"}};return n?s.jsx(Nt,{children:s.jsx("div",{className:"flex justify-center items-center h-64",children:s.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"})})}):s.jsxs(Nt,{children:[s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Gestión de Productos"}),s.jsx("p",{className:"text-gray-600 mt-1",children:"Administra productos, categorías e inventario"})]}),s.jsxs("div",{className:"mt-4 sm:mt-0 flex space-x-3",children:[s.jsx(we,{module:"productos",permission:"crear",children:s.jsxs("button",{onClick:()=>S(!0),className:"inline-flex items-center px-4 py-2 bg-green-600 text-white text-sm font-medium rounded-lg hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500",children:[s.jsx("svg",{className:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),"Nueva Categoría"]})}),s.jsx(we,{module:"productos",permission:"crear",children:s.jsxs("button",{onClick:()=>f(!0),className:"inline-flex items-center px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("svg",{className:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),"Nuevo Producto"]})})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-6",children:[s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"w-8 h-8 bg-blue-100 rounded-lg flex items-center justify-center",children:s.jsx("svg",{className:"w-5 h-5 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Productos Mostrados"}),s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:t.length})]})]})}),s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"w-8 h-8 bg-green-100 rounded-lg flex items-center justify-center",children:s.jsx("svg",{className:"w-5 h-5 text-green-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Activos"}),s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:t.filter(A=>A.activo==1).length})]})]})}),s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"w-8 h-8 bg-red-100 rounded-lg flex items-center justify-center",children:s.jsx("svg",{className:"w-5 h-5 text-red-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Stock Bajo"}),s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:t.filter(A=>A.stock_actual<=A.stock_minimo).length})]})]})}),s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"w-8 h-8 bg-purple-100 rounded-lg flex items-center justify-center",children:s.jsx("svg",{className:"w-5 h-5 text-purple-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Categorías"}),s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:r.length})]})]})})]}),s.jsx("div",{className:"bg-white p-4 rounded-lg shadow",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:[s.jsx("div",{children:s.jsx("input",{type:"text",placeholder:"Buscar productos...",value:m.search,onChange:A=>w("search",A.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})}),s.jsx("div",{children:s.jsxs("select",{value:m.categoria_id,onChange:A=>w("categoria_id",A.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("option",{value:"",children:"Todas las categorías"}),r.map(A=>s.jsx("option",{value:A.id,children:A.nombre},A.id))]})}),s.jsx("div",{children:s.jsxs("select",{value:m.activo,onChange:A=>w("activo",A.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("option",{value:"",children:"Todos los estados"}),s.jsx("option",{value:"1",children:"Activos"}),s.jsx("option",{value:"0",children:"Inactivos"})]})}),s.jsx("div",{className:"flex items-center",children:s.jsxs("label",{className:"flex items-center",children:[s.jsx("input",{type:"checkbox",checked:m.stock_bajo,onChange:A=>w("stock_bajo",A.target.checked),className:"mr-2"}),"Stock bajo"]})}),s.jsx("div",{children:s.jsx("button",{onClick:N,className:"w-full px-3 py-2 bg-gray-500 text-white rounded-md hover:bg-gray-600",children:"Limpiar"})})]})}),i&&s.jsx("div",{className:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4",children:i}),s.jsxs("div",{className:"bg-white shadow rounded-lg overflow-hidden",children:[s.jsxs("table",{className:"min-w-full",children:[s.jsx("thead",{className:"bg-gray-50",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Código"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Nombre"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Categoría"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Precio"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Stock"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Estado Stock"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Estado"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Acciones"})]})}),s.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:t.map(A=>s.jsxs("tr",{children:[s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900",children:A.codigo}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsxs("div",{className:"flex items-center",children:[A.imagen_url?s.jsx("img",{src:as.getImageUrl(A.imagen_url),alt:A.nombre,className:"w-10 h-10 rounded-md object-cover mr-3",onError:O=>{O.target.style.display="none"}}):s.jsx("div",{className:"w-10 h-10 bg-gray-200 rounded-md flex items-center justify-center mr-3",children:s.jsx("svg",{className:"w-5 h-5 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),s.jsx("div",{className:"text-sm font-medium text-gray-900",children:A.nombre})]})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900",children:A.categoria_nombre||"Sin categoría"}),s.jsxs("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900",children:["$",parseFloat(A.precio).toFixed(2)]}),s.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[s.jsxs("div",{className:"text-sm text-gray-900",children:[A.stock_actual," ",A.unidad_medida]}),s.jsxs("div",{className:"text-xs text-gray-500",children:["Min: ",A.stock_minimo," / Max: ",A.stock_maximo]})]}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsx("span",{className:`px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${Q(A.estado_stock)}`,children:A.estado_stock})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsx("span",{className:`px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${A.activo==1?"bg-green-100 text-green-800":"bg-red-100 text-red-800"}`,children:A.activo==1?"Activo":"Inactivo"})}),s.jsxs("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium space-x-2",children:[s.jsx(we,{module:"productos",permission:"actualizar",children:s.jsx("button",{onClick:()=>k(A),className:"text-blue-600 hover:text-blue-900",children:"Editar"})}),s.jsx(we,{module:"productos",permission:"actualizar",children:s.jsx("button",{onClick:()=>_(A),className:"text-green-600 hover:text-green-900",children:"Stock"})}),s.jsx(we,{module:"productos",permission:"eliminar",children:s.jsx("button",{onClick:()=>H(A.id),className:"text-red-600 hover:text-red-900",children:"Eliminar"})})]})]},A.id))})]}),t.length===0&&s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-gray-500",children:"No se encontraron productos"})})]})]}),s.jsx(t2,{isOpen:x,onClose:()=>{f(!1),d(null)},onSave:R,product:h,categories:r}),s.jsx(xf,{isOpen:b,onClose:()=>{j(!1),d(null)},onSave:z,product:h}),s.jsx(s2,{isOpen:v,onClose:()=>S(!1),onSave:C})]})},l2=()=>{const[e,t]=g.useState([]),[a,r]=g.useState(!1),[l,n]=g.useState(!1),[o,i]=g.useState(null),[c,m]=g.useState({search:"",tipo_movimiento:"",activo:"1"}),[u,x]=g.useState({nombre:"",descripcion:"",tipo_movimiento:"todos",activo:1}),[f,b]=g.useState({}),[j,v]=g.useState(null),S=[{value:"todos",label:"Todos los tipos"},{value:"entrada",label:"Entrada"},{value:"salida",label:"Salida"},{value:"ajuste",label:"Ajuste"}];g.useEffect(()=>{h(),d()},[c]);const h=async()=>{r(!0);try{const _=await Mt.obtenerTodos(c);t(_)}catch(_){console.error("Error cargando motivos:",_)}finally{r(!1)}},d=async()=>{try{const _=await Mt.obtenerEstadisticas();v(_)}catch(_){console.error("Error cargando estadísticas:",_)}},p=_=>{const{name:H,value:Q}=_.target;m(A=>({...A,[H]:Q}))},y=(_=null)=>{i(_),x(_?{nombre:_.nombre,descripcion:_.descripcion||"",tipo_movimiento:_.tipo_movimiento,activo:_.activo}:{nombre:"",descripcion:"",tipo_movimiento:"todos",activo:1}),b({}),n(!0)},E=()=>{n(!1),i(null),b({})},w=_=>{const{name:H,value:Q,type:A,checked:O}=_.target;x(B=>({...B,[H]:A==="checkbox"?O?1:0:Q})),f[H]&&b(B=>({...B,[H]:""}))},N=()=>{const _={};return u.nombre.trim()||(_.nombre="El nombre es requerido"),u.tipo_movimiento||(_.tipo_movimiento="El tipo de movimiento es requerido"),_},R=async _=>{_.preventDefault();const H=N();if(Object.keys(H).length>0){b(H);return}try{o?await Mt.actualizar(o.id,u):await Mt.crear(u),await h(),await d(),E()}catch(Q){console.error("Error guardando motivo:",Q),b({general:Q.message||"Error al guardar motivo"})}},z=async _=>{if(window.confirm("¿Está seguro de eliminar este motivo?"))try{await Mt.eliminar(_),await h(),await d()}catch(H){console.error("Error eliminando motivo:",H),alert("Error al eliminar motivo: "+H.message)}},C=async _=>{try{await Mt.establecerPredeterminado(_),await h()}catch(H){console.error("Error estableciendo predeterminado:",H),alert("Error al establecer predeterminado: "+H.message)}},k=()=>{m({search:"",tipo_movimiento:"",activo:"1"})};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"Motivos de Stock"}),s.jsx("p",{className:"text-gray-600",children:"Gestiona los motivos para cambios de inventario"})]}),s.jsxs("button",{onClick:()=>y(),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center",children:[s.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Nuevo Motivo"]})]}),j&&s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-3 rounded-full bg-blue-100 text-blue-600",children:s.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Total Motivos"}),s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:j.total_motivos})]})]})}),s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-3 rounded-full bg-green-100 text-green-600",children:s.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Por Tipo"}),s.jsx("div",{className:"text-sm text-gray-600",children:j.por_tipo.map(_=>s.jsxs("span",{className:"block",children:[_.tipo_movimiento,": ",_.cantidad]},_.tipo_movimiento))})]})]})}),s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-3 rounded-full bg-yellow-100 text-yellow-600",children:s.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Más Utilizados"}),s.jsx("div",{className:"text-sm text-gray-600",children:j.mas_utilizados.slice(0,3).map(_=>s.jsxs("span",{className:"block",children:[_.nombre,": ",_.usos]},_.nombre))})]})]})})]}),s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Buscar"}),s.jsx("input",{type:"text",name:"search",value:c.search,onChange:p,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Nombre o descripción..."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Tipo de Movimiento"}),s.jsxs("select",{name:"tipo_movimiento",value:c.tipo_movimiento,onChange:p,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("option",{value:"",children:"Todos"}),S.slice(1).map(_=>s.jsx("option",{value:_.value,children:_.label},_.value))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Estado"}),s.jsxs("select",{name:"activo",value:c.activo,onChange:p,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("option",{value:"",children:"Todos"}),s.jsx("option",{value:"1",children:"Activo"}),s.jsx("option",{value:"0",children:"Inactivo"})]})]}),s.jsx("div",{className:"flex items-end",children:s.jsx("button",{onClick:k,className:"w-full px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-md hover:bg-gray-300",children:"Limpiar Filtros"})})]})}),s.jsx("div",{className:"bg-white rounded-lg shadow overflow-hidden",children:a?s.jsxs("div",{className:"p-8 text-center",children:[s.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto"}),s.jsx("p",{className:"mt-4 text-gray-500",children:"Cargando motivos..."})]}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[s.jsx("thead",{className:"bg-gray-50",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Nombre"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Descripción"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Tipo"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Estado"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Predeterminado"}),s.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Acciones"})]})}),s.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:e.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:"6",className:"px-6 py-4 text-center text-gray-500",children:"No se encontraron motivos"})}):e.map(_=>s.jsxs("tr",{className:"hover:bg-gray-50",children:[s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsx("div",{className:"text-sm font-medium text-gray-900",children:_.nombre})}),s.jsx("td",{className:"px-6 py-4",children:s.jsx("div",{className:"text-sm text-gray-600",children:_.descripcion||"-"})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${_.tipo_movimiento==="entrada"?"bg-green-100 text-green-800":_.tipo_movimiento==="salida"?"bg-red-100 text-red-800":_.tipo_movimiento==="ajuste"?"bg-blue-100 text-blue-800":"bg-gray-100 text-gray-800"}`,children:_.tipo_movimiento_texto||_.tipo_movimiento})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${_.activo?"bg-green-100 text-green-800":"bg-red-100 text-red-800"}`,children:_.activo?"Activo":"Inactivo"})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:_.predeterminado?s.jsx("span",{className:"inline-flex px-2 py-1 text-xs font-semibold rounded-full bg-yellow-100 text-yellow-800",children:"Predeterminado"}):s.jsx("button",{onClick:()=>C(_.id),className:"text-xs text-blue-600 hover:text-blue-800",children:"Establecer"})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:s.jsxs("div",{className:"flex justify-end space-x-2",children:[s.jsx("button",{onClick:()=>y(_),className:"text-blue-600 hover:text-blue-900",title:"Editar",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),s.jsx("button",{onClick:()=>z(_.id),className:"text-red-600 hover:text-red-900",title:"Eliminar",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})})]},_.id))})]})})}),s.jsx(Ie,{isOpen:l,onClose:E,title:o?"Editar Motivo":"Nuevo Motivo",children:s.jsxs("form",{onSubmit:R,className:"space-y-4",children:[f.general&&s.jsx("div",{className:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded",children:f.general}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Nombre *"}),s.jsx("input",{type:"text",name:"nombre",value:u.nombre,onChange:w,className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${f.nombre?"border-red-500":"border-gray-300"}`,placeholder:"Nombre del motivo"}),f.nombre&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:f.nombre})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Descripción"}),s.jsx("textarea",{name:"descripcion",value:u.descripcion,onChange:w,rows:"3",className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Descripción del motivo (opcional)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Tipo de Movimiento *"}),s.jsx("select",{name:"tipo_movimiento",value:u.tipo_movimiento,onChange:w,className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${f.tipo_movimiento?"border-red-500":"border-gray-300"}`,children:S.map(_=>s.jsx("option",{value:_.value,children:_.label},_.value))}),f.tipo_movimiento&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:f.tipo_movimiento})]}),s.jsxs("div",{className:"flex items-center",children:[s.jsx("input",{type:"checkbox",name:"activo",checked:u.activo===1,onChange:w,className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),s.jsx("label",{className:"ml-2 block text-sm text-gray-700",children:"Motivo activo"})]}),s.jsxs("div",{className:"flex justify-end space-x-3 pt-4",children:[s.jsx("button",{type:"button",onClick:E,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-md hover:bg-gray-300",children:"Cancelar"}),s.jsxs("button",{type:"submit",className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700",children:[o?"Actualizar":"Crear"," Motivo"]})]})]})})]})},n2=()=>s.jsx(Nt,{children:s.jsx(l2,{})}),o2=({productos:e=[],tipo:t="estado"})=>{var n;const[a,r]=g.useState([]);g.useEffect(()=>{if(e.length!==0&&t==="estado"){const o=e.filter(u=>u.stock_actual===0).length,i=e.filter(u=>u.stock_actual>0&&u.stock_actual<=u.stock_minimo).length,c=e.filter(u=>u.stock_actual>u.stock_minimo&&u.stock_actual<u.stock_maximo).length,m=e.filter(u=>u.stock_actual>=u.stock_maximo).length;r([{label:"Sin Stock",value:o,color:"bg-red-500",percentage:0},{label:"Stock Bajo",value:i,color:"bg-yellow-500",percentage:0},{label:"Normal",value:c,color:"bg-green-500",percentage:0},{label:"Exceso",value:m,color:"bg-purple-500",percentage:0}].map(u=>({...u,percentage:e.length>0?u.value/e.length*100:0})))}},[e,t]);const l=a.reduce((o,i)=>o+i.value,0);return a.length===0?s.jsxs("div",{className:"bg-white p-6 rounded-lg shadow",children:[s.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Distribución de Stock"}),s.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500",children:"No hay datos para mostrar"})]}):s.jsxs("div",{className:"bg-white p-6 rounded-lg shadow",children:[s.jsxs("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:["Distribución de Stock (",l," productos)"]}),s.jsx("div",{className:"space-y-4",children:a.map((o,i)=>s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-center mb-1",children:[s.jsx("span",{className:"text-sm font-medium text-gray-700",children:o.label}),s.jsxs("span",{className:"text-sm text-gray-500",children:[o.value," (",o.percentage.toFixed(1),"%)"]})]}),s.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2",children:s.jsx("div",{className:`h-2 rounded-full ${o.color}`,style:{width:`${o.percentage}%`}})})]},i))}),s.jsx("div",{className:"mt-6 pt-4 border-t border-gray-200",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"text-2xl font-bold text-red-600",children:a.filter(o=>o.label==="Sin Stock"||o.label==="Stock Bajo").reduce((o,i)=>o+i.value,0)}),s.jsx("div",{className:"text-sm text-gray-500",children:"Necesitan atención"})]}),s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"text-2xl font-bold text-green-600",children:((n=a.find(o=>o.label==="Normal"))==null?void 0:n.value)||0}),s.jsx("div",{className:"text-sm text-gray-500",children:"Stock adecuado"})]})]})})]})},i2=()=>{const[e,t]=g.useState({valorInventario:0,movimientosRecientes:[],productosRotacion:[],alertasCriticas:[]}),[a,r]=g.useState(!1),[l,n]=g.useState(new Date().toISOString().split("T")[0]);g.useEffect(()=>{o()},[l]);const o=async()=>{r(!0);try{const[u,x,f]=await Promise.all([Me.obtenerTodos({}),Me.obtenerMovimientos(null,50),Me.obtenerEstadisticas()]),b=u.reduce((h,d)=>{const p=d.categoria_nombre||"Sin categoría",y=d.precio*d.stock_actual;return h[p]=(h[p]||0)+y,h},{}),j=x.reduce((h,d)=>(h[d.producto_id]||(h[d.producto_id]={producto_nombre:d.producto_nombre,producto_codigo:d.producto_codigo,movimientos:0,entradas:0,salidas:0}),h[d.producto_id].movimientos++,d.tipo_movimiento==="entrada"?h[d.producto_id].entradas+=d.cantidad:d.tipo_movimiento==="salida"&&(h[d.producto_id].salidas+=d.cantidad),h),{}),v=Object.values(j).sort((h,d)=>d.movimientos-h.movimientos).slice(0,10),S=u.filter(h=>h.stock_actual===0||h.stock_actual<h.stock_minimo*.5).map(h=>({...h,prioridad:h.stock_actual===0?"crítica":"alta"}));t({valorInventario:b,movimientosRecientes:x.slice(0,10),productosRotacion:v,alertasCriticas:S,estadisticas:f})}catch(u){console.error("Error generando reporte:",u)}finally{r(!1)}},i=()=>{var b,j,v;e.estadisticas,e.valorInventario,e.alertasCriticas.length,e.productosRotacion.length;const u=[["Reporte de Stock",l],[""],["Estadísticas Generales"],["Total Productos",((b=e.estadisticas)==null?void 0:b.total_productos)||0],["Productos Stock Bajo",((j=e.estadisticas)==null?void 0:j.productos_stock_bajo)||0],["Valor Inventario",`$${parseFloat(((v=e.estadisticas)==null?void 0:v.valor_inventario)||0).toLocaleString()}`],[""],["Valor por Categoría"],...Object.entries(e.valorInventario).map(([S,h])=>[S,`$${h.toLocaleString()}`]),[""],["Alertas Críticas"],...e.alertasCriticas.map(S=>[S.codigo,S.nombre,S.stock_actual,S.prioridad])].map(S=>S.join(",")).join(`
`),x=new Blob([u],{type:"text/csv;charset=utf-8;"}),f=document.createElement("a");f.href=URL.createObjectURL(x),f.download=`reporte_stock_${l}.csv`,f.click()},c=u=>new Intl.NumberFormat("es-ES",{style:"currency",currency:"USD"}).format(u),m=u=>new Date(u).toLocaleDateString("es-ES",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"});return a?s.jsx("div",{className:"space-y-6",children:s.jsxs("div",{className:"text-center py-8",children:[s.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto"}),s.jsx("p",{className:"mt-4 text-gray-500",children:"Generando reporte..."})]})}):s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:"Reporte de Stock"}),s.jsx("p",{className:"text-gray-600",children:"Análisis detallado del inventario"})]}),s.jsxs("div",{className:"flex items-center space-x-4",children:[s.jsx("input",{type:"date",value:l,onChange:u=>n(u.target.value),className:"px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"}),s.jsxs("button",{onClick:i,className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center",children:[s.jsx("svg",{className:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),"Exportar CSV"]})]})]})}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"bg-white p-6 rounded-lg shadow",children:[s.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Valor por Categoría"}),s.jsx("div",{className:"space-y-3",children:Object.entries(e.valorInventario).sort(([,u],[,x])=>x-u).map(([u,x])=>s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("span",{className:"text-sm font-medium text-gray-700",children:u}),s.jsx("span",{className:"text-sm font-bold text-gray-900",children:c(x)})]},u))}),s.jsx("div",{className:"mt-4 pt-4 border-t border-gray-200",children:s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("span",{className:"text-sm font-bold text-gray-900",children:"Total"}),s.jsx("span",{className:"text-lg font-bold text-blue-600",children:c(Object.values(e.valorInventario).reduce((u,x)=>u+x,0))})]})})]}),s.jsxs("div",{className:"bg-white p-6 rounded-lg shadow",children:[s.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Productos con Mayor Rotación"}),s.jsx("div",{className:"space-y-3",children:e.productosRotacion.map((u,x)=>s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-gray-900",children:u.producto_nombre}),s.jsx("div",{className:"text-xs text-gray-500",children:u.producto_codigo})]}),s.jsxs("div",{className:"text-right",children:[s.jsxs("div",{className:"text-sm font-bold text-gray-900",children:[u.movimientos," mov."]}),s.jsxs("div",{className:"text-xs text-gray-500",children:["+",u.entradas," / -",u.salidas]})]})]},x))})]})]}),s.jsxs("div",{className:"bg-white rounded-lg shadow",children:[s.jsx("div",{className:"px-6 py-4 border-b border-gray-200",children:s.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Movimientos Recientes"})}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[s.jsx("thead",{className:"bg-gray-50",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Fecha"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Producto"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Tipo"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Cantidad"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Motivo"})]})}),s.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:e.movimientosRecientes.map((u,x)=>s.jsxs("tr",{children:[s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900",children:m(u.created_at)}),s.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[s.jsx("div",{className:"text-sm font-medium text-gray-900",children:u.producto_nombre}),s.jsx("div",{className:"text-sm text-gray-500",children:u.producto_codigo})]}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${u.tipo_movimiento==="entrada"?"bg-green-100 text-green-800":u.tipo_movimiento==="salida"?"bg-red-100 text-red-800":"bg-blue-100 text-blue-800"}`,children:u.tipo_movimiento})}),s.jsxs("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-bold text-gray-900",children:[u.tipo_movimiento==="entrada"&&"+",u.tipo_movimiento==="salida"&&"-",u.cantidad]}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900",children:u.motivo})]},x))})]})})]}),e.alertasCriticas.length>0&&s.jsxs("div",{className:"bg-white rounded-lg shadow",children:[s.jsx("div",{className:"px-6 py-4 border-b border-gray-200",children:s.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Alertas Críticas"})}),s.jsx("div",{className:"p-6",children:s.jsx("div",{className:"grid gap-4",children:e.alertasCriticas.map((u,x)=>s.jsx("div",{className:`p-4 rounded-lg border ${u.prioridad==="crítica"?"border-red-200 bg-red-50":"border-yellow-200 bg-yellow-50"}`,children:s.jsxs("div",{className:"flex justify-between items-start",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"font-medium text-gray-900",children:u.nombre}),s.jsxs("p",{className:"text-sm text-gray-600",children:["Código: ",u.codigo]}),s.jsx("div",{className:"flex items-center mt-2",children:s.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${u.prioridad==="crítica"?"bg-red-100 text-red-800":"bg-yellow-100 text-yellow-800"}`,children:u.prioridad==="crítica"?"SIN STOCK":"STOCK MUY BAJO"})})]}),s.jsxs("div",{className:"text-right",children:[s.jsxs("div",{className:"text-lg font-bold text-red-600",children:[u.stock_actual," / ",u.stock_minimo]}),s.jsx("div",{className:"text-sm text-gray-500",children:"Actual / Mínimo"})]})]})},x))})})]})]})},c2=({productos:e,onUpdate:t})=>{const[a,r]=g.useState(!1),l=[{id:"establecer_minimos_auto",nombre:"Establecer Mínimos Automáticamente",descripcion:"Calcular stocks mínimos basado en rotación promedio",icono:"📊",accion:()=>n()},{id:"reabastecer_urgente",nombre:"Reabastecer Productos Críticos",descripcion:"Llevar productos sin stock al stock mínimo",icono:"🚨",accion:()=>o()},{id:"optimizar_maximos",nombre:"Optimizar Stocks Máximos",descripcion:"Ajustar stocks máximos basado en capacidad",icono:"⚡",accion:()=>i()},{id:"balancear_inventario",nombre:"Balancear Inventario",descripcion:"Redistribuir excesos a productos con stock bajo",icono:"⚖️",accion:()=>c()}],n=async()=>{if(window.confirm("¿Establecer mínimos automáticamente basado en rotación? Esta acción afectará todos los productos.")){r(!0);try{const m=await Me.obtenerMovimientos(null,1e3),u={},x=new Date;x.setDate(x.getDate()-30),m.forEach(v=>{new Date(v.created_at)>=x&&v.tipo_movimiento==="salida"&&(u[v.producto_id]||(u[v.producto_id]={salidas_total:0,nombre:v.producto_nombre}),u[v.producto_id].salidas_total+=v.cantidad)});const f=await Mt.obtenerTodos({activo:1}),b=f.find(v=>v.nombre.includes("Optimización"))||f[0];let j=0;for(const v of e){const S=u[v.id];if(S&&S.salidas_total>0){const h=Math.ceil(S.salidas_total*.5);h!==v.stock_minimo&&(await Me.actualizar(v.id,{stock_minimo:h}),j++)}}alert(`Mínimos automáticos establecidos para ${j} productos`),t()}catch(m){console.error("Error estableciendo mínimos:",m),alert("Error al establecer mínimos automáticamente")}finally{r(!1)}}},o=async()=>{const m=e.filter(u=>u.stock_actual===0);if(m.length===0){alert("No hay productos sin stock que reabastecer");return}if(window.confirm(`¿Reabastecer ${m.length} productos críticos al stock mínimo?`)){r(!0);try{const u=await Mt.obtenerTodos({activo:1}),x=u.find(f=>f.nombre.toLowerCase().includes("reabastecimiento")||f.nombre.toLowerCase().includes("compra")||f.nombre.toLowerCase().includes("entrada"))||u.find(f=>f.tipo_movimiento==="entrada")||u[0];for(const f of m){const b=Math.max(f.stock_minimo,10);await Me.actualizarStock(f.id,b,x.id,"Reabastecimiento automático - producto crítico")}alert(`${m.length} productos críticos reabastecidos`),t()}catch(u){console.error("Error reabasteciendo:",u),alert("Error al reabastecer productos críticos")}finally{r(!1)}}},i=async()=>{if(window.confirm("¿Optimizar stocks máximos basado en rotación y capacidad?")){r(!0);try{let m=0;for(const u of e){const x=Math.max(u.stock_minimo*3,100);x!==u.stock_maximo&&(await Me.actualizar(u.id,{stock_maximo:x}),m++)}alert(`Stocks máximos optimizados para ${m} productos`),t()}catch(m){console.error("Error optimizando máximos:",m),alert("Error al optimizar stocks máximos")}finally{r(!1)}}},c=async()=>{const m=e.filter(x=>x.stock_actual>x.stock_maximo),u=e.filter(x=>x.stock_actual<x.stock_minimo);if(m.length===0||u.length===0){alert("No hay productos con exceso y déficit para balancear");return}alert(`Detectados ${m.length} productos con exceso y ${u.length} con déficit. Esta función requiere implementación de lógica de transferencia entre productos similares.`)};return s.jsxs("div",{className:"bg-white p-6 rounded-lg shadow",children:[s.jsxs("div",{className:"mb-6",children:[s.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Configuraciones Rápidas"}),s.jsx("p",{className:"text-sm text-gray-600",children:"Herramientas de optimización automática del inventario"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:l.map(m=>s.jsx("div",{className:"border border-gray-200 rounded-lg p-4 hover:border-blue-300 transition-colors",children:s.jsxs("div",{className:"flex items-start",children:[s.jsx("div",{className:"text-2xl mr-3",children:m.icono}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h4",{className:"font-medium text-gray-900 mb-1",children:m.nombre}),s.jsx("p",{className:"text-sm text-gray-600 mb-3",children:m.descripcion}),s.jsx("button",{onClick:m.accion,disabled:a,className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-gray-400 text-white px-4 py-2 rounded text-sm font-medium transition-colors",children:a?"Procesando...":"Ejecutar"})]})]})},m.id))}),s.jsx("div",{className:"mt-6 p-4 bg-blue-50 rounded-lg",children:s.jsxs("div",{className:"flex",children:[s.jsx("svg",{className:"h-5 w-5 text-blue-400 mt-0.5",fill:"currentColor",viewBox:"0 0 20 20",children:s.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})}),s.jsx("div",{className:"ml-3 text-sm",children:s.jsxs("p",{className:"text-blue-800",children:[s.jsx("strong",{children:"Importante:"})," Las configuraciones automáticas realizan cambios masivos en el inventario. Revisa siempre los resultados después de ejecutar estas acciones."]})})]})})]})},d2=()=>{var X;const[e,t]=g.useState([]),[a,r]=g.useState([]),[l,n]=g.useState(null),[o,i]=g.useState(!1),[c,m]=g.useState("productos"),[u,x]=g.useState({search:"",categoria_id:"",stock_bajo:!1,solo_criticos:!1}),[f,b]=g.useState({search:"",tipo_movimiento:"",fecha_desde:"",fecha_hasta:""}),[j,v]=g.useState(!1),[S,h]=g.useState(null),[d,p]=g.useState(!1),[y,E]=g.useState([]),[w,N]=g.useState({tipo_ajuste:"porcentaje",valor:"",motivo_id:"",motivo_personalizado:"",aplicar_a:"seleccionados"}),[R,z]=g.useState([]),[C,k]=g.useState([]);g.useEffect(()=>{_(),A(),O()},[]),g.useEffect(()=>{c==="productos"?H():c==="movimientos"&&Q()},[u,f,c]);const _=async()=>{try{const M=await Me.obtenerEstadisticas();n(M)}catch(M){console.error("Error cargando estadísticas:",M)}},H=async()=>{i(!0);try{const M=await Me.obtenerTodos(u);t(M)}catch(M){console.error("Error cargando productos:",M)}finally{i(!1)}},Q=async()=>{i(!0);try{let K=await Me.obtenerMovimientos(null,100);f.search&&(K=K.filter(ue=>{var _t,el,tl;return((_t=ue.producto_nombre)==null?void 0:_t.toLowerCase().includes(f.search.toLowerCase()))||((el=ue.producto_codigo)==null?void 0:el.toLowerCase().includes(f.search.toLowerCase()))||((tl=ue.motivo)==null?void 0:tl.toLowerCase().includes(f.search.toLowerCase()))})),f.tipo_movimiento&&(K=K.filter(ue=>ue.tipo_movimiento===f.tipo_movimiento)),f.fecha_desde&&(K=K.filter(ue=>new Date(ue.created_at)>=new Date(f.fecha_desde))),f.fecha_hasta&&(K=K.filter(ue=>new Date(ue.created_at)<=new Date(f.fecha_hasta+"T23:59:59"))),r(K)}catch(M){console.error("Error cargando movimientos:",M)}finally{i(!1)}},A=async()=>{try{const M=await Mt.obtenerTodos({activo:1});z(M)}catch(M){console.error("Error cargando motivos:",M)}},O=async()=>{try{const M=await Me.obtenerCategorias();k(M)}catch(M){console.error("Error cargando categorías:",M)}},B=M=>{const{name:K,value:ue,type:_t,checked:el}=M.target;x(tl=>({...tl,[K]:_t==="checkbox"?el:ue}))},T=M=>{const{name:K,value:ue}=M.target;b(_t=>({..._t,[K]:ue}))},$=()=>{c==="productos"?x({search:"",categoria_id:"",stock_bajo:!1,solo_criticos:!1}):c==="movimientos"&&b({search:"",tipo_movimiento:"",fecha_desde:"",fecha_hasta:""})},I=M=>{h(M),v(!0)},Ge=()=>{v(!1),h(null),H(),_()},V=M=>{E(K=>K.includes(M)?K.filter(ue=>ue!==M):[...K,M])},ge=()=>{const M=e.map(K=>K.id);E(M)},Ee=()=>{E([])},_e=()=>{p(!0)},$s=()=>{p(!1),N({tipo_ajuste:"porcentaje",valor:"",motivo_id:"",motivo_personalizado:"",aplicar_a:"seleccionados"}),Ee()},Ra=M=>{const{name:K,value:ue}=M.target;N(_t=>({..._t,[K]:ue}))},D=async()=>{try{let M=[];if(w.aplicar_a==="seleccionados"?M=e.filter(K=>y.includes(K.id)):w.aplicar_a==="stock_bajo"?M=e.filter(K=>K.stock_actual<=K.stock_minimo):w.aplicar_a==="todos"&&(M=e),M.length===0){alert("No hay productos para ajustar");return}if(!window.confirm(`¿Está seguro de ajustar el stock de ${M.length} productos?`))return;i(!0);for(const K of M){let ue=K.stock_actual;if(w.tipo_ajuste==="porcentaje"){const _t=parseFloat(w.valor)/100;ue=Math.round(K.stock_actual*(1+_t))}else w.tipo_ajuste==="cantidad"?ue=K.stock_actual+parseInt(w.valor):w.tipo_ajuste==="establecer"&&(ue=parseInt(w.valor));ue=Math.max(0,ue),await Me.actualizarStock(K.id,ue,w.motivo_id||null,w.motivo_personalizado||null)}alert(`Stock ajustado exitosamente para ${M.length} productos`),$s(),H(),_()}catch(M){console.error("Error en ajuste masivo:",M),alert("Error al ejecutar el ajuste masivo: "+M.message)}finally{i(!1)}},q=M=>M.stock_actual===0?{text:"Sin Stock",class:"bg-red-100 text-red-800"}:M.stock_actual<=M.stock_minimo?{text:"Stock Bajo",class:"bg-yellow-100 text-yellow-800"}:M.stock_actual>=M.stock_maximo?{text:"Exceso",class:"bg-purple-100 text-purple-800"}:{text:"Normal",class:"bg-green-100 text-green-800"},Z=M=>{switch(M){case"entrada":return"bg-green-100 text-green-800";case"salida":return"bg-red-100 text-red-800";case"ajuste":return"bg-blue-100 text-blue-800";default:return"bg-gray-100 text-gray-800"}},G=M=>new Date(M).toLocaleDateString("es-ES",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"});return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"Gestión de Stocks"}),s.jsx("p",{className:"text-gray-600",children:"Control completo del inventario y movimientos"})]}),s.jsxs("div",{className:"flex space-x-3",children:[c==="productos"&&s.jsx(s.Fragment,{children:s.jsxs("button",{onClick:_e,className:"bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg flex items-center",children:[s.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})}),"Ajuste Masivo"]})}),s.jsxs("button",{onClick:()=>{_(),H(),Q()},className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg flex items-center",children:[s.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Actualizar"]})]})]}),l&&s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-6",children:[s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-3 rounded-full bg-blue-100 text-blue-600",children:s.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Total Productos"}),s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:l.total_productos})]})]})}),s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-3 rounded-full bg-red-100 text-red-600",children:s.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.732-.833-2.464 0L4.35 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Stock Bajo"}),s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:l.productos_stock_bajo})]})]})}),s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-3 rounded-full bg-green-100 text-green-600",children:s.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Valor Inventario"}),s.jsxs("p",{className:"text-2xl font-semibold text-gray-900",children:["$",parseFloat(l.valor_inventario||0).toLocaleString()]})]})]})}),s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-3 rounded-full bg-purple-100 text-purple-600",children:s.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Categorías"}),s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:l.total_categorias})]})]})})]}),s.jsxs("div",{className:"bg-white rounded-lg shadow",children:[s.jsx("div",{className:"border-b border-gray-200",children:s.jsxs("nav",{className:"flex space-x-8 px-6",children:[s.jsx("button",{onClick:()=>m("productos"),className:`py-4 px-1 border-b-2 font-medium text-sm ${c==="productos"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:"Productos"}),s.jsx("button",{onClick:()=>m("movimientos"),className:`py-4 px-1 border-b-2 font-medium text-sm ${c==="movimientos"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:"Movimientos"}),s.jsx("button",{onClick:()=>m("alertas"),className:`py-4 px-1 border-b-2 font-medium text-sm ${c==="alertas"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:"Alertas"}),s.jsx("button",{onClick:()=>m("reportes"),className:`py-4 px-1 border-b-2 font-medium text-sm ${c==="reportes"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:"Reportes"})]})}),s.jsxs("div",{className:"p-6",children:[c==="productos"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-6 grid grid-cols-1 md:grid-cols-5 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Buscar"}),s.jsx("input",{type:"text",name:"search",value:u.search,onChange:B,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Código o nombre..."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Categoría"}),s.jsxs("select",{name:"categoria_id",value:u.categoria_id,onChange:B,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("option",{value:"",children:"Todas"}),C.map(M=>s.jsx("option",{value:M.id,children:M.nombre},M.id))]})]}),s.jsx("div",{className:"flex items-center space-x-4 mt-6",children:s.jsxs("label",{className:"flex items-center",children:[s.jsx("input",{type:"checkbox",name:"stock_bajo",checked:u.stock_bajo,onChange:B,className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),s.jsx("span",{className:"ml-2 text-sm text-gray-700",children:"Stock Bajo"})]})}),s.jsx("div",{className:"flex items-end",children:s.jsx("button",{onClick:$,className:"w-full px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-md hover:bg-gray-300",children:"Limpiar"})}),s.jsx("div",{className:"flex items-end",children:y.length>0?s.jsxs("div",{className:"flex space-x-2 w-full",children:[s.jsxs("span",{className:"text-sm text-gray-600 py-2",children:[y.length," seleccionados"]}),s.jsx("button",{onClick:Ee,className:"text-xs text-gray-500 hover:text-gray-700",children:"Limpiar"})]}):s.jsx("button",{onClick:ge,className:"w-full px-4 py-2 text-sm font-medium text-blue-600 bg-blue-50 rounded-md hover:bg-blue-100",children:"Seleccionar Todo"})})]}),o?s.jsxs("div",{className:"text-center py-8",children:[s.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto"}),s.jsx("p",{className:"mt-4 text-gray-500",children:"Cargando productos..."})]}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[s.jsx("thead",{className:"bg-gray-50",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:s.jsx("input",{type:"checkbox",checked:y.length===e.length&&e.length>0,onChange:()=>y.length===e.length?Ee():ge(),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"})}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Producto"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Stock Actual"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Min/Max"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Estado"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Valor"}),s.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Acciones"})]})}),s.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:e.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:"7",className:"px-6 py-4 text-center text-gray-500",children:"No se encontraron productos"})}):e.map(M=>{const K=q(M);return s.jsxs("tr",{className:"hover:bg-gray-50",children:[s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsx("input",{type:"checkbox",checked:y.includes(M.id),onChange:()=>V(M.id),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsxs("div",{className:"flex items-center",children:[M.imagen_url&&s.jsx("div",{className:"flex-shrink-0 h-10 w-10",children:s.jsx("img",{className:"h-10 w-10 rounded-full object-cover",src:M.imagen_url.startsWith("http")?M.imagen_url:`http://localhost/api_rutas/${M.imagen_url}`,alt:M.nombre})}),s.jsxs("div",{className:M.imagen_url?"ml-4":"",children:[s.jsx("div",{className:"text-sm font-medium text-gray-900",children:M.nombre}),s.jsx("div",{className:"text-sm text-gray-500",children:M.codigo})]})]})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsxs("div",{className:"text-sm font-bold text-gray-900",children:[M.stock_actual," ",M.unidad_medida]})}),s.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[s.jsxs("div",{className:"text-sm text-gray-900",children:["Min: ",M.stock_minimo]}),s.jsxs("div",{className:"text-sm text-gray-500",children:["Max: ",M.stock_maximo]})]}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${K.class}`,children:K.text})}),s.jsxs("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900",children:["$",(M.precio*M.stock_actual).toLocaleString()]}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:s.jsx("button",{onClick:()=>I(M),className:"text-blue-600 hover:text-blue-900",title:"Actualizar Stock",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})})})]},M.id)})})]})})]}),c==="movimientos"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-6 grid grid-cols-1 md:grid-cols-5 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Buscar"}),s.jsx("input",{type:"text",name:"search",value:f.search,onChange:T,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Producto, código o motivo..."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Tipo"}),s.jsxs("select",{name:"tipo_movimiento",value:f.tipo_movimiento,onChange:T,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("option",{value:"",children:"Todos"}),s.jsx("option",{value:"entrada",children:"Entrada"}),s.jsx("option",{value:"salida",children:"Salida"}),s.jsx("option",{value:"ajuste",children:"Ajuste"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Desde"}),s.jsx("input",{type:"date",name:"fecha_desde",value:f.fecha_desde,onChange:T,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Hasta"}),s.jsx("input",{type:"date",name:"fecha_hasta",value:f.fecha_hasta,onChange:T,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),s.jsx("div",{className:"flex items-end",children:s.jsx("button",{onClick:$,className:"w-full px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-md hover:bg-gray-300",children:"Limpiar"})})]}),o?s.jsxs("div",{className:"text-center py-8",children:[s.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto"}),s.jsx("p",{className:"mt-4 text-gray-500",children:"Cargando movimientos..."})]}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[s.jsx("thead",{className:"bg-gray-50",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Fecha"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Producto"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Tipo"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Cantidad"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Stock Anterior"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Stock Nuevo"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Motivo"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Usuario"})]})}),s.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:a.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:"8",className:"px-6 py-4 text-center text-gray-500",children:"No se encontraron movimientos"})}):a.map(M=>s.jsxs("tr",{className:"hover:bg-gray-50",children:[s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900",children:G(M.created_at)}),s.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[s.jsx("div",{className:"text-sm font-medium text-gray-900",children:M.producto_nombre}),s.jsx("div",{className:"text-sm text-gray-500",children:M.producto_codigo})]}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${Z(M.tipo_movimiento)}`,children:M.tipo_movimiento})}),s.jsxs("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-bold text-gray-900",children:[M.tipo_movimiento==="entrada"&&"+",M.tipo_movimiento==="salida"&&"-",M.cantidad]}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900",children:M.stock_anterior}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-bold text-gray-900",children:M.stock_nuevo}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900",children:M.motivo}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:M.usuario_nombre||"-"})]},M.id))})]})})]}),c==="alertas"&&s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-6",children:s.jsxs("div",{className:"flex",children:[s.jsx("div",{className:"flex-shrink-0",children:s.jsx("svg",{className:"h-5 w-5 text-yellow-400",fill:"currentColor",viewBox:"0 0 20 20",children:s.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})}),s.jsxs("div",{className:"ml-3",children:[s.jsx("h3",{className:"text-sm font-medium text-yellow-800",children:"Productos con Stock Bajo"}),s.jsx("div",{className:"mt-2 text-sm text-yellow-700",children:s.jsx("p",{children:"Los siguientes productos están por debajo del stock mínimo recomendado:"})})]})]})}),s.jsxs("div",{className:"grid gap-4",children:[e.filter(M=>M.stock_actual<=M.stock_minimo).map(M=>s.jsxs("div",{className:"bg-white border border-red-200 rounded-lg p-4",children:[s.jsxs("div",{className:"flex justify-between items-start",children:[s.jsxs("div",{className:"flex items-center space-x-4",children:[M.imagen_url&&s.jsx("img",{className:"h-12 w-12 rounded-lg object-cover",src:M.imagen_url.startsWith("http")?M.imagen_url:`http://localhost/api_rutas/${M.imagen_url}`,alt:M.nombre}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-lg font-medium text-gray-900",children:M.nombre}),s.jsxs("p",{className:"text-sm text-gray-500",children:["Código: ",M.codigo]}),s.jsxs("div",{className:"flex items-center mt-2 space-x-4",children:[s.jsx("span",{className:"text-sm",children:s.jsxs("span",{className:"font-medium text-red-600",children:["Stock: ",M.stock_actual]})}),s.jsxs("span",{className:"text-sm text-gray-500",children:["Mínimo: ",M.stock_minimo]})]})]})]}),s.jsx("button",{onClick:()=>I(M),className:"bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg text-sm",children:"Reabastecer"})]}),s.jsxs("div",{className:"mt-3",children:[s.jsxs("div",{className:"flex justify-between text-sm text-gray-600 mb-1",children:[s.jsx("span",{children:"Stock actual"}),s.jsxs("span",{children:[M.stock_actual,"/",M.stock_minimo]})]}),s.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2",children:s.jsx("div",{className:"bg-red-500 h-2 rounded-full",style:{width:`${Math.min(M.stock_actual/M.stock_minimo*100,100)}%`}})})]})]},M.id)),e.filter(M=>M.stock_actual<=M.stock_minimo).length===0&&s.jsxs("div",{className:"text-center py-8",children:[s.jsx("svg",{className:"mx-auto h-12 w-12 text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),s.jsx("h3",{className:"mt-2 text-sm font-medium text-gray-900",children:"No hay alertas"}),s.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Todos los productos tienen stock adecuado."})]})]})]}),c==="reportes"&&s.jsxs("div",{className:"space-y-6",children:[s.jsx(c2,{productos:e,onUpdate:()=>{H(),_()}}),s.jsx(o2,{productos:e,tipo:"estado"}),s.jsx(i2,{})]})]})]}),s.jsx(xf,{isOpen:j,onClose:Ge,onSave:Ge,product:S}),s.jsx(Ie,{isOpen:d,onClose:$s,title:"Ajuste Masivo de Stock",children:s.jsxs("form",{onSubmit:M=>{M.preventDefault(),D()},className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Aplicar a"}),s.jsxs("select",{name:"aplicar_a",value:w.aplicar_a,onChange:Ra,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsxs("option",{value:"seleccionados",children:["Productos Seleccionados (",y.length,")"]}),s.jsx("option",{value:"stock_bajo",children:"Productos con Stock Bajo"}),s.jsx("option",{value:"todos",children:"Todos los Productos"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Tipo de Ajuste"}),s.jsxs("select",{name:"tipo_ajuste",value:w.tipo_ajuste,onChange:Ra,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("option",{value:"porcentaje",children:"Ajuste por Porcentaje"}),s.jsx("option",{value:"cantidad",children:"Sumar/Restar Cantidad"}),s.jsx("option",{value:"establecer",children:"Establecer Valor Fijo"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Valor"}),s.jsx("input",{type:"number",name:"valor",value:w.valor,onChange:Ra,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:w.tipo_ajuste==="porcentaje"?"Ej: 10 (para +10%)":w.tipo_ajuste==="cantidad"?"Ej: 5 (para +5), -3 (para -3)":"Ej: 100 (stock = 100)",required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Motivo"}),s.jsxs("select",{name:"motivo_id",value:w.motivo_id,onChange:Ra,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("option",{value:"",children:"Seleccionar motivo"}),R.map(M=>s.jsx("option",{value:M.id,children:M.nombre},M.id))]})]}),w.motivo_id&&((X=R.find(M=>M.id==w.motivo_id))==null?void 0:X.nombre)==="Otro"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Especificar Motivo"}),s.jsx("input",{type:"text",name:"motivo_personalizado",value:w.motivo_personalizado,onChange:Ra,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Especificar el motivo",required:!0})]}),s.jsxs("div",{className:"flex justify-end space-x-3 pt-4",children:[s.jsx("button",{type:"button",onClick:$s,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-md hover:bg-gray-300",children:"Cancelar"}),s.jsx("button",{type:"submit",disabled:o,className:"px-4 py-2 text-sm font-medium text-white bg-purple-600 rounded-md hover:bg-purple-700 disabled:opacity-50",children:o?"Procesando...":"Ejecutar Ajuste"})]})]})})]})},u2=()=>s.jsx(Nt,{children:s.jsx(d2,{})});var tu={};class m2{async obtenerTodos(t={}){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getClientes",...t})});if(a.success)return a.data||[];throw new Error(a.message||"Error obteniendo clientes")}catch(a){throw console.error("Error fetching clientes:",a),a}}async obtenerPorId(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getCliente",id:t})});if(a.success)return a.data;throw new Error(a.message||"Error obteniendo cliente")}catch(a){throw console.error("Error fetching cliente:",a),a}}async crear(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"createCliente",...t})});if(a.success)return a.data;throw new Error(a.message||"Error creando cliente")}catch(a){throw console.error("Error creating cliente:",a),a}}async actualizar(t,a){try{const r=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"updateCliente",id:t,...a})});if(r.success)return r.data;throw new Error(r.message||"Error actualizando cliente")}catch(r){throw console.error("Error updating cliente:",r),r}}async eliminar(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"deleteCliente",id:t})});if(a.success)return!0;throw new Error(a.message||"Error eliminando cliente")}catch(a){throw console.error("Error deleting cliente:",a),a}}async obtenerEstadisticas(){try{const t=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getEstadisticasClientes"})});if(t.success)return t.data||{};throw new Error(t.message||"Error obteniendo estadísticas")}catch(t){throw console.error("Error fetching estadisticas:",t),t}}async obtenerHistorial(t,a=50){try{const r=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getHistorialCliente",cliente_id:t,limit:a})});if(r.success)return r.data||[];throw new Error(r.message||"Error obteniendo historial")}catch(r){throw console.error("Error fetching historial:",r),r}}async obtenerVentasHistorial(t,a=50){try{const r=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getVentasCliente",cliente_id:t,limit:a})});if(r.success)return r.data||[];throw new Error(r.message||"Error obteniendo historial de ventas")}catch(r){return console.error("Error fetching ventas historial:",r),[]}}async generarCodigo(){try{const t=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"generarCodigoCliente"})});if(t.success)return t.data.codigo;throw new Error(t.message||"Error generando código")}catch(t){throw console.error("Error generating codigo:",t),t}}async agregarNota(t,a){try{const r=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"addNotaCliente",cliente_id:t,nota:a})});if(r.success)return!0;throw new Error(r.message||"Error agregando nota")}catch(r){throw console.error("Error adding nota:",r),r}}async obtenerDireccionesCliente(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getDireccionesCliente",cliente_id:t})});if(a.success)return a.data||[];throw new Error(a.message||"Error obteniendo direcciones")}catch(a){throw console.error("Error fetching direcciones:",a),a}}async agregarDireccion(t,a){try{const r=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"addDireccionCliente",cliente_id:t,...a})});if(r.success)return r.data;throw new Error(r.message||"Error agregando dirección")}catch(r){throw console.error("Error adding direccion:",r),r}}async desasignarQR(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"desasignarQRCliente",cliente_id:t})});if(a.success)return!0;throw new Error(a.message||"Error desasignando código QR")}catch(a){throw console.error("Error desasignando QR:",a),a}}getEstadoActividad(t){if(!t.ultima_compra)return{text:"Nunca",class:"bg-gray-100 text-gray-800"};const a=t.dias_ultima_compra;return a>180?{text:"Inactivo",class:"bg-red-100 text-red-800"}:a>90?{text:"Bajo",class:"bg-yellow-100 text-yellow-800"}:{text:"Activo",class:"bg-green-100 text-green-800"}}formatFecha(t){return t?new Date(t).toLocaleDateString("es-ES",{year:"numeric",month:"2-digit",day:"2-digit"}):"N/A"}formatFechaHora(t){return t?new Date(t).toLocaleDateString("es-ES",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"N/A"}formatMoneda(t){return new Intl.NumberFormat("es-EC",{style:"currency",currency:"USD"}).format(t||0)}formatTelefono(t){return t?t.length===10&&t.startsWith("0")?t.replace(/(\d{2})(\d{3})(\d{4})/,"$1 $2 $3"):t:""}formatDireccionCompleta(t){if(!t)return"Sin dirección";const a=[];return t.direccion&&a.push(t.direccion),t.ciudad&&a.push(t.ciudad),t.provincia&&a.push(t.provincia),a.join(", ")||"Dirección incompleta"}async buscarDireccion(t){try{const r=await(await fetch(`https://maps.googleapis.com/maps/api/geocode/json?address=${encodeURIComponent(t)}&key=${tu.REACT_APP_GOOGLE_MAPS_API_KEY}`)).json();return r.status==="OK"&&r.results.length>0?r.results.map(l=>({direccion_formateada:l.formatted_address,latitud:l.geometry.location.lat,longitud:l.geometry.location.lng,lugar_id:l.place_id})):[]}catch(a){return console.error("Error buscando dirección:",a),[]}}async obtenerDetallesDireccion(t){try{const r=await(await fetch(`https://maps.googleapis.com/maps/api/place/details/json?place_id=${t}&key=${tu.REACT_APP_GOOGLE_MAPS_API_KEY}`)).json();return r.status==="OK"&&r.result?{direccion_formateada:r.result.formatted_address,latitud:r.result.geometry.location.lat,longitud:r.result.geometry.location.lng,lugar_id:r.result.place_id,componentes:r.result.address_components}:null}catch(a){return console.error("Error obteniendo detalles de dirección:",a),null}}parsearComponentesDireccion(t){const a={calle:"",ciudad:"",provincia:"",codigo_postal:"",pais:""};return t.forEach(r=>{const l=r.types;l.includes("street_number")||l.includes("route")?a.calle+=r.long_name+" ":l.includes("locality")?a.ciudad=r.long_name:l.includes("administrative_area_level_1")?a.provincia=r.long_name:l.includes("postal_code")?a.codigo_postal=r.long_name:l.includes("country")&&(a.pais=r.long_name)}),a.calle=a.calle.trim(),a}}const Ue=new m2,f2=Object.freeze(Object.defineProperty({__proto__:null,default:Ue},Symbol.toStringTag,{value:"Module"}));class h2{async generarLote(t=48,a=null){try{const r=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"generarLoteQR",cantidad:t,nombre_lote:a})});if(r.success)return r.data;throw new Error(r.message||"Error generando lote de códigos QR")}catch(r){throw console.error("Error generating QR lote:",r),r}}async obtenerLotes(t={}){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getLotesQR",...t})});if(a.success)return a.data||[];throw new Error(a.message||"Error obteniendo lotes")}catch(a){throw console.error("Error fetching lotes:",a),a}}async obtenerCodigosLote(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getCodigosLote",lote_id:t})});if(a.success)return a.data||[];throw new Error(a.message||"Error obteniendo códigos del lote")}catch(a){throw console.error("Error fetching codigos lote:",a),a}}async asignarCodigoACliente(t,a){try{const r=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"asignarQRCliente",codigo_qr_id:t,cliente_id:a})});if(r.success)return!0;throw new Error(r.message||"Error asignando código QR")}catch(r){throw console.error("Error assigning QR code:",r),r}}async obtenerDisponibles(t=100){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getQRDisponibles",limite:t})});if(a.success)return a.data||[];throw new Error(a.message||"Error obteniendo códigos disponibles")}catch(a){throw console.error("Error fetching available QR codes:",a),a}}async obtenerQRAsignado(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getQRAsignado",codigo_qr_id:t})});if(a.success)return a.data;throw new Error(a.message||"Error obteniendo información del código QR")}catch(a){throw console.error("Error fetching assigned QR code:",a),a}}async obtenerEstadisticas(){try{const t=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getEstadisticasQR"})});if(t.success)return t.data||{};throw new Error(t.message||"Error obteniendo estadísticas")}catch(t){throw console.error("Error fetching QR statistics:",t),t}}async marcarLoteImpreso(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"marcarLoteImpreso",lote_id:t})});if(a.success)return!0;throw new Error(a.message||"Error marcando lote como impreso")}catch(a){throw console.error("Error marking lote as printed:",a),a}}async marcarLoteComoUsado(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"marcarLoteComoUsado",lote_id:t})});if(a.success)return!0;throw new Error(a.message||"Error marcando lote como usado")}catch(a){throw console.error("Error marking lote as used:",a),a}}async marcarCodigoComoUsado(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"marcarCodigoComoUsado",codigo_id:t})});if(a.success)return!0;throw new Error(a.message||"Error marcando código como usado")}catch(a){throw console.error("Error marking code as used:",a),a}}generarQRCode(t,a=100){return`https://api.qrserver.com/v1/create-qr-code/?size=${a}x${a}&data=${encodeURIComponent(t)}`}formatFecha(t){return t?new Date(t).toLocaleDateString("es-ES",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"N/A"}getEstadoColor(t){return{generado:"bg-blue-100 text-blue-800",asignado:"bg-yellow-100 text-yellow-800",usado:"bg-green-100 text-green-800",pendiente:"bg-gray-100 text-gray-800",impreso:"bg-purple-100 text-purple-800",entregado:"bg-green-100 text-green-800"}[t]||"bg-gray-100 text-gray-800"}getEstadoTexto(t){return{generado:"Generado",asignado:"Asignado",usado:"Usado",pendiente:"Pendiente",impreso:"Impreso",entregado:"Entregado"}[t]||t}}const ie=new h2;let tr=!1,xo=!1;const gf=()=>new Promise((e,t)=>{if(xo){e(window.google);return}if(tr){const l=()=>{xo?e(window.google):setTimeout(l,100)};l();return}tr=!0;const a="AIzaSyBvmuYqMsKtkZ3K3q_WYvry1aE-R_pqD_Q";console.log("Cargando Google Maps con API key:","API key presente");const r=document.createElement("script");r.src=`https://maps.googleapis.com/maps/api/js?key=${a}&libraries=places,geometry`,r.async=!0,r.defer=!0,r.onload=()=>{tr=!1,xo=!0,console.log("Google Maps API cargada exitosamente"),e(window.google)},r.onerror=l=>{tr=!1,console.error("Error cargando Google Maps API:",l),t(new Error("Error cargando Google Maps API - Verifica la API key y las restricciones"))},window.gm_authFailure=()=>{tr=!1,console.error("Error de autenticación de Google Maps API"),t(new Error("API key de Google Maps inválida o tiene restricciones"))},document.head.appendChild(r)}),x2=({isOpen:e,onClose:t,onSave:a,cliente:r})=>{const[l,n]=g.useState({codigo:"",nombre:"",apellidos:"",nombre_comercial:"",telefono:"",telefono_secundario:"",direccion:"",codigo_postal:"",pais:"México",activo:1}),[o,i]=g.useState({}),[c,m]=g.useState(!1),[u,x]=g.useState(!1),[f,b]=g.useState(null),j=g.useRef(null),v=g.useRef(null),S=g.useRef(null),h=g.useRef(null),d=g.useRef(null);g.useEffect(()=>{var k,_,H;if(e){if(S.current&&(S.current.setMap(null),S.current=null),v.current&&(v.current=null),d.current&&((H=(_=(k=window.google)==null?void 0:k.maps)==null?void 0:_.event)==null||H.clearInstanceListeners(d.current),d.current=null),r)if(n({codigo:r.codigo||"",nombre:r.nombre||"",apellidos:r.apellidos||"",nombre_comercial:r.nombre_comercial||"",telefono:r.telefono||"",telefono_secundario:r.telefono_secundario||"",direccion:r.direccion||"",codigo_postal:r.codigo_postal||"",pais:r.pais||"México",activo:r.activo!==void 0?r.activo:1}),r.latitud&&r.longitud){const Q={lat:parseFloat(r.latitud),lng:parseFloat(r.longitud)};console.log("Estableciendo coordenadas del cliente:",Q),b(Q)}else console.log("Cliente sin coordenadas"),b(null);else n({codigo:"",nombre:"",apellidos:"",nombre_comercial:"",telefono:"",telefono_secundario:"",direccion:"",codigo_postal:"",pais:"México",activo:1}),b(null);i({})}else p(),b(null)},[e,r]),g.useEffect(()=>{if(e){const k=setTimeout(()=>{y()},300);return()=>clearTimeout(k)}},[e,f]);const p=()=>{var k,_,H;S.current&&(S.current.setMap(null),S.current=null),v.current&&(v.current=null),d.current&&((H=(_=(k=window.google)==null?void 0:k.maps)==null?void 0:_.event)==null||H.clearInstanceListeners(d.current),d.current=null)},y=async()=>{if(j.current){console.log("Inicializando mapa con coordenadas:",f);try{await gf();const _=f||{lat:21.8853,lng:-102.2916};console.log("Centro del mapa será:",_),j.current.innerHTML="";const H=new window.google.maps.Map(j.current,{zoom:f?15:12,center:_,mapTypeId:"roadmap"});if(v.current=H,f){console.log("Creando marcador en:",f);const Q=new window.google.maps.Marker({position:f,map:H,draggable:!0,title:"Ubicación del cliente"});S.current=Q,Q.addListener("dragend",()=>{const A=Q.getPosition();b({lat:A.lat(),lng:A.lng()}),new window.google.maps.Geocoder().geocode({location:A},(B,T)=>{T==="OK"&&B[0]&&n($=>({...$,direccion:B[0].formatted_address}))})})}else console.log("No se creará marcador (sin coordenadas)");H.addListener("click",Q=>{const A=Q.latLng;b({lat:A.lat(),lng:A.lng()}),S.current&&S.current.setMap(null);const O=new window.google.maps.Marker({position:A,map:H,draggable:!0,title:"Ubicación del cliente"});S.current=O,O.addListener("dragend",()=>{const T=O.getPosition();b({lat:T.lat(),lng:T.lng()}),new window.google.maps.Geocoder().geocode({location:T},(I,Ge)=>{Ge==="OK"&&I[0]&&n(V=>({...V,direccion:I[0].formatted_address}))})}),new window.google.maps.Geocoder().geocode({location:A},(T,$)=>{$==="OK"&&T[0]&&n(I=>({...I,direccion:T[0].formatted_address}))})}),E()}catch(k){console.error("Error cargando Google Maps:",k),j.current&&(j.current.innerHTML=`
          <div class="w-full h-full flex items-center justify-center bg-gray-200">
            <div class="text-center">
              <div class="w-16 h-16 bg-red-400 rounded-full flex items-center justify-center mx-auto mb-4">
                <svg class="w-8 h-8 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
                </svg>
              </div>
              <p class="text-red-500 text-sm">Error cargando Google Maps</p>
              <p class="text-gray-400 text-xs mt-2">${k.message}</p>
            </div>
          </div>
        `)}}},E=()=>{if(!h.current||!window.google)return;d.current&&window.google.maps.event.clearInstanceListeners(d.current);const k=new window.google.maps.places.Autocomplete(h.current,{types:["address"],componentRestrictions:{country:"mx"},fields:["formatted_address","geometry","name"]});d.current=k,k.addListener("place_changed",()=>{const _=k.getPlace();if(_.geometry){const H=_.geometry.location,Q={lat:H.lat(),lng:H.lng()};if(b(Q),n(A=>({...A,direccion:_.formatted_address})),v.current){v.current.setCenter(Q),v.current.setZoom(15),S.current&&S.current.setMap(null);const A=new window.google.maps.Marker({position:Q,map:v.current,draggable:!0,title:"Ubicación del cliente"});S.current=A,A.addListener("dragend",()=>{const O=A.getPosition(),B={lat:O.lat(),lng:O.lng()};b(B),new window.google.maps.Geocoder().geocode({location:O},($,I)=>{I==="OK"&&$[0]&&n(Ge=>({...Ge,direccion:$[0].formatted_address}))})})}}})},w=k=>{const{name:_,value:H,type:Q,checked:A}=k.target,O=Q==="checkbox"?A:H;n(B=>({...B,[_]:O})),o[_]&&i(B=>({...B,[_]:""}))},N=async()=>{x(!0);try{const k=await Ue.generarCodigo();n(_=>({..._,codigo:k}))}catch(k){console.error("Error generando código:",k)}x(!1)},R=()=>{const k={};return l.codigo.trim()||(k.codigo="El código es requerido"),l.nombre_comercial.trim()||(k.nombre_comercial="El nombre comercial es requerido"),l.nombre.trim()||(k.nombre="El nombre del contacto es requerido"),l.telefono.trim()?/^[0-9]{10}$/.test(l.telefono.replace(/\s+/g,""))||(k.telefono="El teléfono debe tener 10 dígitos"):k.telefono="El teléfono es requerido",i(k),Object.keys(k).length===0},z=async k=>{if(k.preventDefault(),!!R()){m(!0);try{let _;const H={...l,telefono:l.telefono.replace(/\s+/g,""),latitud:(f==null?void 0:f.lat)||null,longitud:(f==null?void 0:f.lng)||null};r?_=await Ue.actualizar(r.id,H):_=await Ue.crear(H),a(_),C()}catch(_){console.error("Error guardando cliente:",_),i({general:_.message||"Error al guardar el cliente"})}m(!1)}},C=()=>{p(),b(null),i({}),t()};return s.jsx(Ie,{isOpen:e,onClose:C,title:r?"Editar Cliente":"Nuevo Cliente",size:"full",children:s.jsxs("form",{onSubmit:z,className:"h-full flex flex-col",children:[o.general&&s.jsx("div",{className:"bg-red-50 border border-red-300 text-red-700 px-4 py-3 rounded mb-4",children:o.general}),s.jsxs("div",{className:"flex-1 grid grid-cols-1 lg:grid-cols-2 gap-6 min-h-0",children:[s.jsxs("div",{className:"space-y-6 overflow-y-auto pr-4",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsx("h3",{className:"text-lg font-medium text-gray-900 border-b border-gray-200 pb-2",children:"Información Básica"}),s.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Código *"}),s.jsxs("div",{className:"flex rounded-md shadow-sm",children:[s.jsx("input",{type:"text",name:"codigo",value:l.codigo,onChange:w,className:`flex-1 min-w-0 block w-full px-3 py-2 border rounded-l-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 sm:text-sm ${o.codigo?"border-red-300":"border-gray-300"}`,placeholder:"CLI-001"}),s.jsx("button",{type:"button",onClick:N,disabled:u,className:"inline-flex items-center px-3 py-2 border border-l-0 border-gray-300 rounded-r-md bg-gray-50 text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 sm:text-sm",children:u?"...":"↻"})]}),o.codigo&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:o.codigo})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Nombre Comercial *"}),s.jsx("input",{type:"text",name:"nombre_comercial",value:l.nombre_comercial,onChange:w,className:`block w-full px-3 py-2 border rounded-md shadow-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 sm:text-sm ${o.nombre_comercial?"border-red-300":"border-gray-300"}`,placeholder:"Nombre comercial o empresa"}),o.nombre_comercial&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:o.nombre_comercial})]})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("h3",{className:"text-lg font-medium text-gray-900 border-b border-gray-200 pb-2",children:"Información de Contacto"}),s.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Nombre del Contacto *"}),s.jsx("input",{type:"text",name:"nombre",value:l.nombre,onChange:w,className:`block w-full px-3 py-2 border rounded-md shadow-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 sm:text-sm ${o.nombre?"border-red-300":"border-gray-300"}`,placeholder:"Nombre del contacto principal"}),o.nombre&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:o.nombre})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Teléfono Principal *"}),s.jsx("input",{type:"tel",name:"telefono",value:l.telefono,onChange:w,className:`block w-full px-3 py-2 border rounded-md shadow-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 sm:text-sm ${o.telefono?"border-red-300":"border-gray-300"}`,placeholder:"0999999999"}),o.telefono&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:o.telefono})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Teléfono Secundario"}),s.jsx("input",{type:"tel",name:"telefono_secundario",value:l.telefono_secundario,onChange:w,className:"block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 sm:text-sm",placeholder:"0999999999"})]})]})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("h3",{className:"text-lg font-medium text-gray-900 border-b border-gray-200 pb-2",children:"Dirección"}),s.jsxs("div",{className:"relative",children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Dirección"}),s.jsx("input",{ref:h,type:"text",name:"direccion",value:l.direccion,onChange:w,className:"block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 sm:text-sm",placeholder:"Empieza escribiendo una dirección..."})]}),f&&s.jsxs("div",{className:"bg-green-50 border border-green-200 p-3 rounded-md",children:[s.jsxs("p",{className:"text-sm text-green-800",children:[s.jsx("span",{className:"font-medium",children:"Ubicación seleccionada:"})," ",f.lat.toFixed(6),", ",f.lng.toFixed(6)]}),s.jsx("p",{className:"text-xs text-green-600 mt-1",children:"Puedes hacer clic en el mapa para cambiar la ubicación o arrastrar el marcador."})]})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("h3",{className:"text-lg font-medium text-gray-900 border-b border-gray-200 pb-2",children:"Ubicación en el Mapa"}),s.jsx("div",{className:"bg-gray-100 border border-gray-300 rounded-lg overflow-hidden",style:{height:"500px"},children:s.jsx("div",{ref:j,className:"w-full h-full",children:s.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-200",children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto mb-4"}),s.jsx("p",{className:"text-gray-500 text-sm",children:"Cargando mapa de Google..."})]})})})}),s.jsxs("div",{className:"text-xs text-gray-500 bg-gray-50 p-3 rounded-md",children:[s.jsx("p",{className:"font-medium mb-1",children:"💡 Cómo usar el mapa:"}),s.jsxs("ul",{className:"space-y-1",children:[s.jsx("li",{children:"• Busca una dirección en el campo de texto"}),s.jsx("li",{children:"• Haz clic en el mapa para colocar un marcador"}),s.jsx("li",{children:"• Arrastra el marcador para ajustar la ubicación"}),s.jsx("li",{children:"• Las coordenadas se guardarán automáticamente"})]})]})]})]}),s.jsxs("div",{className:"flex justify-end space-x-3 pt-6 border-t border-gray-200 mt-6",children:[s.jsx("button",{type:"button",onClick:C,className:"px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:"Cancelar"}),s.jsx("button",{type:"submit",disabled:c,className:"px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed",children:c?"Guardando...":r?"Actualizar":"Crear"})]})]})})},g2=({isOpen:e,onClose:t,cliente:a})=>{const[r,l]=g.useState([]),[n,o]=g.useState(!1),[i,c]=g.useState("informacion");g.useEffect(()=>{e&&a&&m()},[e,a]);const m=async()=>{if(a){o(!0);try{const x=await Ue.obtenerVentasHistorial(a.id);l(x)}catch(x){console.error("Error cargando historial de ventas:",x),l([])}finally{o(!1)}}},u=x=>({completada:"bg-green-100 text-green-800",pendiente:"bg-yellow-100 text-yellow-800",cancelada:"bg-red-100 text-red-800",en_proceso:"bg-blue-100 text-blue-800"})[x]||"bg-gray-100 text-gray-800";return a?s.jsx(Ie,{isOpen:e,onClose:t,title:"Detalles del Cliente",size:"xl",children:s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"bg-gradient-to-r from-blue-600 to-blue-700 rounded-lg p-6 text-white",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center space-x-4",children:[s.jsx("div",{className:"w-16 h-16 bg-white bg-opacity-20 rounded-full flex items-center justify-center",children:s.jsx("span",{className:"text-2xl font-bold text-white",children:a.nombre_completo.charAt(0).toUpperCase()})}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold",children:a.nombre_completo}),s.jsxs("p",{className:"text-blue-100",children:[s.jsx("span",{className:"font-medium",children:"Código:"})," ",a.codigo]})]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("div",{className:"text-sm text-blue-100",children:"Estado de Actividad"}),s.jsx("div",{className:`inline-flex px-3 py-1 rounded-full text-sm font-semibold ${a.estado_actividad==="Activo"?"bg-green-500 text-white":a.estado_actividad==="Bajo"?"bg-yellow-500 text-white":"bg-red-500 text-white"}`,children:a.estado_actividad}),a.ultima_compra&&s.jsxs("div",{className:"text-xs text-blue-100 mt-1",children:["Última compra: ",Ue.formatFecha(a.ultima_compra)]})]})]})}),s.jsx("div",{className:"border-b border-gray-200",children:s.jsxs("nav",{className:"flex space-x-8",children:[s.jsx("button",{onClick:()=>c("informacion"),className:`py-2 px-1 border-b-2 font-medium text-sm ${i==="informacion"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:"Información"}),s.jsxs("button",{onClick:()=>c("ventas"),className:`py-2 px-1 border-b-2 font-medium text-sm ${i==="ventas"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:["Historial de Ventas (",r.length,")"]})]})}),i==="informacion"&&s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg",children:[s.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Información Básica"}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-sm font-medium text-gray-500",children:"Nombre Comercial:"}),s.jsx("span",{className:"text-sm text-gray-900 font-medium",children:a.nombre_comercial||"-"})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-sm font-medium text-gray-500",children:"Código:"}),s.jsx("span",{className:"text-sm text-gray-900",children:a.codigo||"-"})]})]})]}),s.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg",children:[s.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Contacto"}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-sm font-medium text-gray-500",children:"Nombre Completo:"}),s.jsx("span",{className:"text-sm text-gray-900",children:a.nombre_completo||"-"})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-sm font-medium text-gray-500",children:"Teléfono Principal:"}),s.jsx("span",{className:"text-sm text-gray-900",children:a.telefono?Ue.formatTelefono(a.telefono):"-"})]}),a.telefono_secundario&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-sm font-medium text-gray-500",children:"Teléfono Secundario:"}),s.jsx("span",{className:"text-sm text-gray-900",children:Ue.formatTelefono(a.telefono_secundario)})]})]})]})]}),s.jsx("div",{className:"space-y-6",children:s.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg",children:[s.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Ubicación"}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-sm font-medium text-gray-500",children:"Dirección:"}),s.jsx("p",{className:"text-sm text-gray-900 mt-1",children:a.direccion||"Sin dirección registrada"})]}),a.codigo_postal&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-sm font-medium text-gray-500",children:"Código Postal:"}),s.jsx("span",{className:"text-sm text-gray-900",children:a.codigo_postal})]}),a.pais&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-sm font-medium text-gray-500",children:"País:"}),s.jsx("span",{className:"text-sm text-gray-900",children:a.pais})]}),a.latitud&&a.longitud&&s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("span",{className:"text-sm font-medium text-gray-500",children:"Coordenadas:"}),s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx("span",{className:"text-xs text-blue-600 bg-blue-100 px-2 py-1 rounded",children:"Geolocalizado"}),s.jsx("button",{onClick:()=>window.open(`https://maps.google.com/?q=${a.latitud},${a.longitud}`,"_blank"),className:"text-xs text-blue-600 hover:text-blue-800 underline",children:"Ver en Maps"})]})]})]})]})})]}),i==="ventas"&&s.jsx("div",{className:"space-y-6",children:s.jsxs("div",{className:"bg-white",children:[s.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Historial de Ventas"}),n?s.jsxs("div",{className:"text-center py-8",children:[s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto"}),s.jsx("p",{className:"mt-2 text-gray-500",children:"Cargando historial de ventas..."})]}):r.length===0?s.jsxs("div",{className:"text-center py-8",children:[s.jsx("svg",{className:"w-12 h-12 text-gray-400 mx-auto mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})}),s.jsx("p",{className:"text-gray-500",children:"No se han registrado ventas para este cliente"})]}):s.jsx("div",{className:"space-y-4",children:r.map((x,f)=>{var b;return s.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center space-x-3",children:[s.jsx("div",{className:"flex-shrink-0",children:s.jsx("svg",{className:"w-8 h-8 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),s.jsxs("div",{children:[s.jsxs("h4",{className:"text-sm font-medium text-gray-900",children:["Venta #",x.numero_venta||x.id]}),s.jsx("p",{className:"text-xs text-gray-500",children:Ue.formatFecha(x.fecha_venta)})]})]}),s.jsxs("div",{className:"text-right",children:[s.jsxs("p",{className:"text-lg font-bold text-gray-900",children:["$",((b=x.total)==null?void 0:b.toLocaleString())||"0.00"]}),s.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${u(x.estado)}`,children:x.estado==="completada"?"Completada":x.estado==="pendiente"?"Pendiente":x.estado==="cancelada"?"Cancelada":x.estado==="en_proceso"?"En Proceso":x.estado})]})]}),x.productos&&x.productos.length>0&&s.jsxs("div",{className:"mt-3 border-t border-gray-200 pt-3",children:[s.jsxs("p",{className:"text-xs font-medium text-gray-500 mb-2",children:["Productos (",x.productos.length,"):"]}),s.jsxs("div",{className:"space-y-1",children:[x.productos.slice(0,3).map((j,v)=>{var S;return s.jsxs("div",{className:"flex justify-between text-xs",children:[s.jsxs("span",{className:"text-gray-700",children:[j.cantidad,"x ",j.nombre]}),s.jsxs("span",{className:"text-gray-900 font-medium",children:["$",((S=j.subtotal)==null?void 0:S.toLocaleString())||"0.00"]})]},v)}),x.productos.length>3&&s.jsxs("p",{className:"text-xs text-gray-500 italic",children:["+",x.productos.length-3," productos más..."]})]})]}),x.vendedor&&s.jsx("div",{className:"mt-2 pt-2 border-t border-gray-200",children:s.jsxs("p",{className:"text-xs text-gray-500",children:["Vendedor: ",s.jsx("span",{className:"text-gray-700",children:x.vendedor})]})})]},f)})})]})}),s.jsx("div",{className:"flex justify-end",children:s.jsx("button",{onClick:t,className:"px-6 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:"Cerrar"})})]})}):null},p2=({isOpen:e,onClose:t,cliente:a,onAsignado:r})=>{const[l,n]=g.useState([]),[o,i]=g.useState(""),[c,m]=g.useState(!1),[u,x]=g.useState(!1),[f,b]=g.useState(""),[j,v]=g.useState(!1);g.useEffect(()=>{e&&S()},[e]),g.useEffect(()=>{const N=R=>{j&&!R.target.closest(".relative")&&v(!1)};return document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[j]);const S=async()=>{m(!0);try{const N=await ie.obtenerDisponibles(50);n(N)}catch(N){console.error("Error cargando códigos disponibles:",N),n([])}finally{m(!1)}},h=async()=>{if(!(!o||!a)){x(!0);try{await ie.asignarCodigoACliente(o,a.id),r(),d()}catch(N){console.error("Error asignando código QR:",N),alert("Error asignando código QR: "+N.message)}finally{x(!1)}}},d=()=>{i(""),b(""),v(!1),t()},p=l.filter(N=>N.codigo.toLowerCase().includes(f.toLowerCase())),y=l.find(N=>N.id==o),E=N=>{i(N.id),b(N.codigo),v(!1)},w=N=>{b(N.target.value),v(!0),N.target.value||i("")};return a?s.jsx(Ie,{isOpen:e,onClose:d,title:`Asignar Código QR - ${a.nombre_comercial}`,size:"md",children:s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"w-10 h-10 bg-blue-600 rounded-full flex items-center justify-center text-white font-bold",children:a.nombre_comercial.charAt(0).toUpperCase()}),s.jsxs("div",{className:"ml-4",children:[s.jsx("h3",{className:"text-lg font-medium text-blue-900",children:a.nombre_comercial}),s.jsxs("p",{className:"text-sm text-blue-700",children:["Código: ",a.codigo," | ",a.nombre_completo]}),a.codigo_qr_id&&s.jsx("p",{className:"text-sm text-orange-600 font-medium",children:"⚠️ Este cliente ya tiene un código QR asignado"})]})]})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-3",children:"Seleccionar Código QR Disponible"}),c?s.jsxs("div",{className:"text-center py-8",children:[s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto"}),s.jsx("p",{className:"mt-2 text-gray-500",children:"Cargando códigos disponibles..."})]}):l.length===0?s.jsxs("div",{className:"text-center py-8 bg-yellow-50 border border-yellow-200 rounded-lg",children:[s.jsx("svg",{className:"w-12 h-12 text-yellow-400 mx-auto mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),s.jsx("p",{className:"text-yellow-800 font-medium",children:"No hay códigos QR disponibles"}),s.jsx("p",{className:"text-yellow-600 text-sm mt-1",children:'Genera un nuevo lote de códigos QR desde la sección "Códigos QR"'})]}):s.jsxs("div",{className:"relative",children:[s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"text",value:f,onChange:w,onFocus:()=>v(!0),placeholder:"Buscar código QR...",className:"w-full px-3 py-2 pr-10 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),s.jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3",children:s.jsx("svg",{className:`w-5 h-5 text-gray-400 cursor-pointer transition-transform ${j?"transform rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",onClick:()=>v(!j),children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}),j&&s.jsx("div",{className:"absolute z-10 w-full mt-1 bg-white border border-gray-300 rounded-md shadow-lg max-h-60 overflow-auto",children:p.length===0?s.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 text-center",children:f?"No se encontraron códigos que coincidan":"No hay códigos disponibles"}):p.map(N=>s.jsx("div",{onClick:()=>E(N),className:`px-3 py-2 cursor-pointer hover:bg-blue-50 ${o==N.id?"bg-blue-100 text-blue-900":"text-gray-900"}`,children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-sm",children:N.codigo}),s.jsxs("div",{className:"text-xs text-gray-500",children:["Generado: ",ie.formatFecha(N.fecha_generacion)]})]}),s.jsx("div",{className:"w-8 h-8 bg-gray-100 border rounded flex items-center justify-center",children:s.jsx("svg",{className:"w-4 h-4 text-gray-600",fill:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M3 3h6v6H3V3zm2 2v2h2V5H5zM3 15h6v6H3v-6zm2 2v2h2v-2H5zM15 3h6v6h-6V3zm2 2v2h2V5h-2z"})})})]})},N.id))}),y&&s.jsx("div",{className:"mt-4 p-4 bg-gray-50 border border-gray-200 rounded-lg",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("p",{className:"text-sm font-medium text-gray-900",children:["Código seleccionado: ",y.codigo]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["Este código será asignado exclusivamente a ",a.nombre_comercial]}),s.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:["Generado: ",ie.formatFecha(y.fecha_generacion)]})]}),s.jsx("div",{className:"ml-4",children:s.jsx("img",{src:ie.generarQRCode(y.codigo,60),alt:"QR Preview",className:"w-15 h-15 border border-gray-300"})})]})})]})]}),s.jsx("div",{className:"bg-gray-50 border border-gray-200 rounded-lg p-4",children:s.jsxs("div",{className:"flex",children:[s.jsx("svg",{className:"w-5 h-5 text-gray-400 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),s.jsxs("div",{className:"ml-3",children:[s.jsx("h3",{className:"text-sm font-medium text-gray-800",children:"Importante sobre la asignación"}),s.jsx("div",{className:"mt-2 text-sm text-gray-600",children:s.jsxs("ul",{className:"list-disc list-inside space-y-1",children:[s.jsx("li",{children:"Una vez asignado, el código QR no podrá ser reasignado"}),s.jsx("li",{children:"El código aparecerá en el perfil del cliente"}),s.jsx("li",{children:"Se registrará en el historial del cliente"}),s.jsx("li",{children:"El código podrá ser usado para identificación"})]})})]})]})}),s.jsxs("div",{className:"flex justify-end space-x-3 pt-6 border-t border-gray-200",children:[s.jsx("button",{onClick:d,className:"px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:"Cancelar"}),s.jsx("button",{onClick:h,disabled:!o||u||l.length===0,className:"px-6 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed",children:u?s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"}),"Asignando..."]}):"Asignar Código QR"})]})]})}):null},b2=()=>{const[e,t]=g.useState([]),[a,r]=g.useState(!1),[l,n]=g.useState({search:"",activo:"1"}),[o,i]=g.useState(!1),[c,m]=g.useState(!1),[u,x]=g.useState(!1),[f,b]=g.useState(!1),[j,v]=g.useState(null),[S,h]=g.useState(null),[d,p]=g.useState(null),[y,E]=g.useState(null);g.useEffect(()=>{w()},[l]);const w=async()=>{r(!0);try{const V=await Ue.obtenerTodos(l);t(V)}catch(V){console.error("Error cargando clientes:",V)}finally{r(!1)}},N=V=>{const{name:ge,value:Ee}=V.target;n(_e=>({..._e,[ge]:Ee}))},R=()=>{n({search:"",activo:"1"})},z=(V=null)=>{v(V),i(!0)},C=()=>{i(!1),v(null)},k=V=>{h(V),m(!0)},_=()=>{m(!1),h(null)},H=()=>{w(),C()},Q=async V=>{if(window.confirm("¿Está seguro de eliminar este cliente?"))try{await Ue.eliminar(V),await w(),await cargarEstadisticas()}catch(ge){console.error("Error eliminando cliente:",ge),alert("Error al eliminar cliente: "+ge.message)}},A=V=>{p(V),x(!0)},O=async V=>{try{p(V);const ge=await ie.obtenerQRAsignado(V.codigo_qr_id);E(ge),b(!0)}catch(ge){console.error("Error obteniendo información del QR:",ge),alert("Error obteniendo información del QR: "+ge.message)}},B=async V=>{if(window.confirm(`¿Está seguro de eliminar la asignación del código QR para ${V.nombre_comercial}?`))try{await Ue.desasignarQR(V.id),await w()}catch(ge){console.error("Error eliminando asignación de QR:",ge),alert("Error eliminando asignación de QR: "+ge.message)}},T=()=>{x(!1),p(null)},$=()=>{b(!1),p(null),E(null)},I=()=>{w(),T()},Ge=()=>{const V=[["Código","Nombre","Teléfono","Ciudad","Dirección","Última Compra"],...e.map(_e=>[_e.codigo,_e.nombre_completo,_e.telefono||"",_e.ciudad||"",Ue.formatDireccionCompleta(_e)||"",Ue.formatFecha(_e.ultima_compra)])].map(_e=>_e.join(",")).join(`
`),ge=new Blob([V],{type:"text/csv;charset=utf-8;"}),Ee=document.createElement("a");Ee.href=URL.createObjectURL(ge),Ee.download=`clientes_${new Date().toISOString().split("T")[0]}.csv`,Ee.click()};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"Gestión de Clientes"}),s.jsx("p",{className:"text-gray-600",children:"Administra tu base de clientes"})]}),s.jsxs("div",{className:"flex space-x-3",children:[s.jsxs("button",{onClick:Ge,className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center",children:[s.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),"Exportar"]}),s.jsxs("button",{onClick:()=>z(),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center",children:[s.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Nuevo Cliente"]})]})]}),s.jsx("div",{className:"bg-white rounded-lg shadow",children:s.jsxs("div",{className:"p-6",children:[s.jsxs("div",{className:"mb-6 grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Buscar"}),s.jsx("input",{type:"text",name:"search",value:l.search,onChange:N,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Nombre, código, teléfono..."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Estado"}),s.jsxs("select",{name:"activo",value:l.activo,onChange:N,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("option",{value:"",children:"Todos"}),s.jsx("option",{value:"1",children:"Activos"}),s.jsx("option",{value:"0",children:"Inactivos"})]})]}),s.jsx("div",{className:"flex items-end",children:s.jsx("button",{onClick:R,className:"w-full px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-md hover:bg-gray-300",children:"Limpiar Filtros"})})]}),a?s.jsxs("div",{className:"text-center py-8",children:[s.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto"}),s.jsx("p",{className:"mt-4 text-gray-500",children:"Cargando clientes..."})]}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[s.jsx("thead",{className:"bg-gray-50",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Cliente"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Contacto"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Dirección"}),s.jsx("th",{className:"px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Código QR"}),s.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Acciones"})]})}),s.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:e.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:"5",className:"px-6 py-4 text-center text-gray-500",children:"No se encontraron clientes"})}):e.map(V=>s.jsxs("tr",{className:"hover:bg-gray-50",children:[s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"flex-shrink-0 h-10 w-10",children:s.jsx("div",{className:"h-10 w-10 rounded-full bg-gradient-to-br from-blue-400 to-blue-600 flex items-center justify-center text-white font-medium",children:V.nombre_completo.charAt(0).toUpperCase()})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("div",{className:"text-sm font-medium text-gray-900",children:V.nombre_completo}),s.jsx("div",{className:"text-sm text-gray-500",children:V.codigo}),s.jsx("div",{className:"text-sm text-gray-500",children:V.nombre_comercial})]})]})}),s.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[s.jsx("div",{className:"text-sm text-gray-900",children:Ue.formatTelefono(V.telefono)||"-"}),s.jsx("div",{className:"text-sm text-gray-500",children:V.telefono_secundario?Ue.formatTelefono(V.telefono_secundario):""})]}),s.jsx("td",{className:"px-6 py-4",children:s.jsxs("div",{className:"flex items-start space-x-2",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("div",{className:"text-sm text-gray-900 line-clamp-2",children:V.direccion||"Sin dirección registrada"}),V.latitud&&V.longitud&&s.jsxs("div",{className:"text-xs text-blue-600 mt-1 flex items-center",children:[s.jsxs("svg",{className:"w-3 h-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]}),"Geolocalizado"]})]}),V.latitud&&V.longitud&&s.jsx("button",{onClick:()=>window.open(`https://maps.google.com/?q=${V.latitud},${V.longitud}`,"_blank"),className:"text-blue-600 hover:text-blue-800",title:"Ver en Google Maps",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})})]})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-center",children:V.codigo_qr_id?s.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[s.jsx("div",{className:"w-12 h-12 bg-gray-100 border border-gray-300 rounded-lg flex items-center justify-center",children:s.jsx("svg",{className:"w-6 h-6 text-green-600",fill:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M3 3h6v6H3V3zm2 2v2h2V5H5zM3 15h6v6H3v-6zm2 2v2h2v-2H5zM15 3h6v6h-6V3zm2 2v2h2V5h-2zM13 7h2v2h-2V7zM15 9h2v2h-2V9zM13 11h2v2h-2v-2zM15 13h2v2h-2v-2zM13 15h2v2h-2v-2zM15 17h2v2h-2v-2zM17 11h2v2h-2v-2zM19 13h2v2h-2v-2zM17 15h2v2h-2v-2zM19 17h2v2h-2v-2z"})})}),s.jsxs("div",{className:"flex space-x-1",children:[s.jsx("button",{onClick:()=>O(V),className:"text-xs text-blue-600 hover:text-blue-800 px-2 py-1 rounded bg-blue-50 hover:bg-blue-100",title:"Ver QR",children:"Ver"}),s.jsx("button",{onClick:()=>B(V),className:"text-xs text-red-600 hover:text-red-800 px-2 py-1 rounded bg-red-50 hover:bg-red-100",title:"Eliminar QR",children:"Eliminar"})]})]}):s.jsxs("button",{onClick:()=>A(V),className:"inline-flex items-center px-3 py-2 border border-gray-300 shadow-sm text-xs font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[s.jsx("svg",{className:"w-4 h-4 mr-1 text-gray-400",fill:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M3 3h6v6H3V3zm2 2v2h2V5H5zM3 15h6v6H3v-6zm2 2v2h2v-2H5zM15 3h6v6h-6V3zm2 2v2h2V5h-2z"})}),"Asignar QR"]})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:s.jsxs("div",{className:"flex justify-end space-x-2",children:[s.jsx("button",{onClick:()=>k(V),className:"text-blue-600 hover:text-blue-900",title:"Ver Detalles",children:s.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})}),s.jsx("button",{onClick:()=>z(V),className:"text-indigo-600 hover:text-indigo-900",title:"Editar",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),s.jsx("button",{onClick:()=>Q(V.id),className:"text-red-600 hover:text-red-900",title:"Eliminar",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})})]},V.id))})]})})]})}),s.jsx(x2,{isOpen:o,onClose:C,onSave:H,cliente:j}),s.jsx(g2,{isOpen:c,onClose:_,cliente:S}),s.jsx(p2,{isOpen:u,onClose:T,cliente:d,onAsignado:I}),y&&s.jsx(Ie,{isOpen:f,onClose:$,title:`Código QR - ${d==null?void 0:d.nombre_comercial}`,size:"md",children:s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"w-10 h-10 bg-blue-600 rounded-full flex items-center justify-center text-white font-bold",children:d==null?void 0:d.nombre_comercial.charAt(0).toUpperCase()}),s.jsxs("div",{className:"ml-4",children:[s.jsx("h3",{className:"text-lg font-medium text-blue-900",children:d==null?void 0:d.nombre_comercial}),s.jsxs("p",{className:"text-sm text-blue-700",children:[d==null?void 0:d.codigo," | ",d==null?void 0:d.nombre_completo]})]})]})}),s.jsx("div",{className:"text-center",children:s.jsxs("div",{className:"inline-block p-6 bg-white border-2 border-gray-300 rounded-lg",children:[s.jsx("img",{src:ie.generarQRCode(y.codigo,200),alt:`QR ${y.codigo}`,className:"mx-auto"}),s.jsx("div",{className:"mt-4 text-lg font-mono text-gray-900",children:y.codigo}),s.jsx("div",{className:"mt-2",children:s.jsx("span",{className:`inline-flex px-3 py-1 text-sm font-semibold rounded-full ${ie.getEstadoColor(y.estado)}`,children:ie.getEstadoTexto(y.estado)})})]})}),s.jsx("div",{className:"bg-gray-50 border border-gray-200 rounded-lg p-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-gray-700",children:"Fecha generación:"}),s.jsx("div",{className:"text-gray-900",children:ie.formatFecha(y.fecha_generacion)})]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-gray-700",children:"Fecha asignación:"}),s.jsx("div",{className:"text-gray-900",children:ie.formatFecha(y.fecha_asignacion)})]})]})}),s.jsxs("div",{className:"flex justify-between pt-6 border-t border-gray-200",children:[s.jsx("button",{onClick:()=>B(d),className:"px-4 py-2 border border-red-300 rounded-md text-sm font-medium text-red-700 bg-white hover:bg-red-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500",children:"Eliminar Asignación"}),s.jsx("button",{onClick:$,className:"px-6 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:"Cerrar"})]})]})})]})},y2=()=>s.jsx(Nt,{children:s.jsx(b2,{})}),v2=({isOpen:e,onClose:t,onLoteGenerado:a})=>{const[r,l]=g.useState({cantidad:48,nombre_lote:""}),[n,o]=g.useState(!1),[i,c]=g.useState({}),m=j=>{const{name:v,value:S,type:h}=j.target,d=h==="number"?parseInt(S)||0:S;l(p=>({...p,[v]:d})),i[v]&&c(p=>({...p,[v]:""}))},u=()=>{const j={};return(!r.cantidad||r.cantidad<1)&&(j.cantidad="La cantidad debe ser mayor a 0"),r.cantidad>100&&(j.cantidad="La cantidad máxima es 100 códigos por lote"),r.nombre_lote.trim()||(j.nombre_lote="El nombre del lote es requerido"),c(j),Object.keys(j).length===0},x=async j=>{if(j.preventDefault(),!!u()){o(!0);try{const v=await ie.generarLote(r.cantidad,r.nombre_lote.trim());l({cantidad:48,nombre_lote:""}),c({}),a(v)}catch(v){console.error("Error generando lote:",v),c({general:v.message||"Error al generar lote de códigos QR"})}o(!1)}},f=()=>{l({cantidad:48,nombre_lote:""}),c({}),t()},b=[24,48,60,72,96];return s.jsx(Ie,{isOpen:e,onClose:f,title:"Generar Lote de Códigos QR",size:"md",children:s.jsxs("form",{onSubmit:x,className:"space-y-6",children:[i.general&&s.jsx("div",{className:"bg-red-50 border border-red-300 text-red-700 px-4 py-3 rounded",children:i.general}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Nombre del Lote *"}),s.jsx("input",{type:"text",name:"nombre_lote",value:r.nombre_lote,onChange:m,className:`block w-full px-3 py-2 border rounded-md shadow-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 sm:text-sm ${i.nombre_lote?"border-red-300":"border-gray-300"}`,placeholder:"Ej: Lote Enero 2024"}),i.nombre_lote&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:i.nombre_lote})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Cantidad de Códigos QR *"}),s.jsx("div",{className:"grid grid-cols-5 gap-2 mb-3",children:b.map(j=>s.jsx("button",{type:"button",onClick:()=>l(v=>({...v,cantidad:j})),className:`px-3 py-2 text-sm font-medium rounded-md border ${r.cantidad===j?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"}`,children:j},j))}),s.jsx("input",{type:"number",name:"cantidad",value:r.cantidad,onChange:m,min:"1",max:"100",className:`block w-full px-3 py-2 border rounded-md shadow-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 sm:text-sm ${i.cantidad?"border-red-300":"border-gray-300"}`,placeholder:"48"}),i.cantidad&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:i.cantidad}),s.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"💡 Se recomienda 48 códigos para una hoja carta estándar (8x6 grid)"})]})]}),s.jsx("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:s.jsxs("div",{className:"flex",children:[s.jsx("svg",{className:"w-5 h-5 text-blue-400 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),s.jsxs("div",{className:"ml-3",children:[s.jsx("h3",{className:"text-sm font-medium text-blue-800",children:"¿Qué sucederá al generar el lote?"}),s.jsx("div",{className:"mt-2 text-sm text-blue-700",children:s.jsxs("ul",{className:"list-disc list-inside space-y-1",children:[s.jsxs("li",{children:["Se crearán ",r.cantidad," códigos QR únicos"]}),s.jsx("li",{children:"Cada código tendrá un identificador único"}),s.jsx("li",{children:"Los códigos estarán listos para imprimir en formato carta"}),s.jsx("li",{children:"Se podrán asignar posteriormente a clientes"})]})})]})]})}),s.jsxs("div",{className:"border border-gray-200 rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-gray-900 mb-3",children:"Vista previa del formato"}),s.jsx("div",{className:"bg-gray-100 border-2 border-dashed border-gray-300 rounded-lg p-4",children:s.jsxs("div",{className:"text-center text-gray-500",children:[s.jsx("svg",{className:"w-12 h-12 mx-auto mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),s.jsx("p",{className:"text-sm font-medium",children:'Hoja Carta (8.5" x 11")'}),s.jsx("p",{className:"text-xs",children:r.cantidad<=48?"8 columnas × 6 filas":r.cantidad<=72?"9 columnas × 8 filas":"10 columnas × 10 filas"}),s.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:[r.cantidad," códigos QR"]})]})})]}),s.jsxs("div",{className:"flex justify-end space-x-3 pt-6 border-t border-gray-200",children:[s.jsx("button",{type:"button",onClick:f,className:"px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:"Cancelar"}),s.jsx("button",{type:"submit",disabled:n,className:"px-6 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed",children:n?s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"}),"Generando..."]}):"Generar Lote"})]})]})})},j2=({isOpen:e,onClose:t,lote:a})=>{const[r,l]=g.useState([]),[n,o]=g.useState(!1);g.useEffect(()=>{e&&a&&i()},[e,a]);const i=async()=>{if(a){o(!0);try{const x=await ie.obtenerCodigosLote(a.id);l(x)}catch(x){console.error("Error cargando códigos:",x),l([])}finally{o(!1)}}},c=async(x,f)=>{if(window.confirm(`¿Marcar el código ${f} como usado? Esta acción no se puede deshacer.`))try{await ie.marcarCodigoComoUsado(x),await i()}catch(b){console.error("Error marcando código como usado:",b),alert("Error al marcar código como usado: "+b.message)}},m=async()=>{if(r.length)try{console.log("Iniciando impresión de",r.length,"códigos");const x=u(),f=window.open("","_blank","width=800,height=600");if(!f){alert("Por favor, permite las ventanas emergentes para imprimir los códigos QR");return}f.document.write(x),f.document.close(),f.onload=()=>{setTimeout(()=>{f.focus(),f.print(),f.onafterprint=()=>{f.close()}},500)};try{await ie.marcarLoteImpreso(a.id),console.log("Lote marcado como impreso")}catch(b){console.error("Error marcando lote como impreso:",b)}}catch(x){console.error("Error en impresión:",x),alert("Error al abrir ventana de impresión: "+x.message)}},u=()=>{let j=`
    <html>
      <head>
   
        <style>
          @page { 
            margin: 10mm; 
            size: letter; 
          }
          body { 
            margin: 0; 
            font-family: Arial, sans-serif; 
            font-size: 8pt;
          }
          .page { 
            page-break-after: always; 
            width: 100%; 
            height: 100vh;
          }
          .page:last-child { 
            page-break-after: avoid; 
          }
          .grid { 
            display: grid; 
            grid-template-columns: repeat(8, 1fr); 
            grid-template-rows: repeat(6, 1fr); 
            gap: 2px; 
            height: 100%; 
          }
          .qr-cell { 
            border: 1px solid #ddd; 
            display: flex; 
            flex-direction: column; 
            align-items: center; 
            justify-content: center; 
            text-align: center; 
            padding: 2px;
          }
          .qr-code { 
            width: 60px; 
            height: 60px; 
            background: #f0f0f0; 
            border: 1px solid #ccc; 
            display: flex; 
            align-items: center; 
            justify-content: center; 
            margin-bottom: 4px;
          }
          .qr-text { 
            font-size: 6pt; 
            word-break: break-all; 
            line-height: 1.1;
          }
          h1 { 
            text-align: center; 
            font-size: 12pt; 
            margin: 0 0 10px 0; 
          }
        </style>
      </head>
      <body>
    `,v=0,S=1;for(;v<r.length;){j+='<div class="page">',j+='<div class="grid">';for(let h=0;h<48&&v<r.length;h++){const d=r[v],p=ie.generarQRCode(d.codigo,60);j+=`
          <div class="qr-cell">
            <img src="${p}" alt="QR" class="qr-code" />
            <div class="qr-text">${d.codigo}</div>
          </div>
        `,v++}for(;(v-(S-1)*48)%48!==0&&(j+='<div class="qr-cell"></div>',(v-(S-1)*48)%48!==47););j+="</div></div>",S++}return j+="</body></html>",j};return a?s.jsx(Ie,{isOpen:e,onClose:t,title:`Códigos QR - ${a.nombre}`,size:"xl",children:s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"bg-gray-50 rounded-lg p-4",children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-gray-500",children:"Total Códigos:"}),s.jsx("div",{className:"text-lg font-semibold text-gray-900",children:a.codigos_en_lote})]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-gray-500",children:"Disponibles:"}),s.jsx("div",{className:"text-lg font-semibold text-blue-600",children:a.codigos_disponibles})]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-gray-500",children:"Asignados:"}),s.jsx("div",{className:"text-lg font-semibold text-yellow-600",children:a.codigos_asignados})]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-gray-500",children:"Usados:"}),s.jsx("div",{className:"text-lg font-semibold text-green-600",children:a.codigos_usados})]})]})}),s.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[s.jsxs("button",{onClick:m,disabled:!r.length,className:"flex items-center px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 font-medium",children:[s.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"})}),"Imprimir Códigos QR"]}),s.jsx("div",{className:"bg-blue-50 border border-blue-200 rounded-lg px-4 py-2",children:s.jsxs("div",{className:"flex items-center text-sm text-blue-700",children:[s.jsx("svg",{className:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium",children:"48 códigos por hoja carta"}),s.jsx("div",{className:"text-xs text-blue-600",children:"Formato optimizado para impresión (8x6 grid)"})]})]})}),a.estado==="pendiente"&&s.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-lg px-3 py-2",children:s.jsxs("div",{className:"flex items-center text-xs text-amber-700",children:[s.jsx("svg",{className:"w-4 h-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),"Se marcará como impreso automáticamente"]})})]}),s.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg",children:[s.jsx("div",{className:"px-4 py-3 border-b border-gray-200",children:s.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Códigos en este lote"})}),n?s.jsxs("div",{className:"text-center py-8",children:[s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto"}),s.jsx("p",{className:"mt-2 text-gray-500",children:"Cargando códigos..."})]}):s.jsx("div",{className:"max-h-96 overflow-y-auto",children:s.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4 p-4",children:r.map(x=>s.jsxs("div",{className:"border border-gray-200 rounded-lg p-3 text-center",children:[s.jsx("div",{className:"mb-2",children:s.jsx("img",{src:ie.generarQRCode(x.codigo,80),alt:`QR ${x.codigo}`,className:"w-20 h-20 mx-auto border border-gray-300",loading:"lazy"})}),s.jsx("div",{className:"text-xs font-mono text-gray-900 mb-2",children:x.codigo}),s.jsx("div",{className:"flex justify-center",children:s.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${ie.getEstadoColor(x.estado)}`,children:ie.getEstadoTexto(x.estado)})}),x.cliente_nombre&&s.jsx("div",{className:"text-xs text-gray-500 mt-1",children:x.cliente_nombre}),s.jsx("div",{className:"mt-3 flex justify-center",children:x.estado==="generado"||x.estado==="asignado"?s.jsx("button",{onClick:()=>c(x.id,x.codigo),className:"px-2 py-1 text-xs bg-red-100 text-red-700 rounded hover:bg-red-200 transition-colors",title:"Marcar como usado",children:s.jsxs("div",{className:"flex items-center space-x-1",children:[s.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})}),s.jsx("span",{children:"Usar"})]})}):s.jsx("div",{className:"px-2 py-1 text-xs text-gray-400 rounded border border-gray-200",children:x.estado==="usado"?"Ya usado":x.estado})})]},x.id))})})]}),s.jsx("div",{className:"flex justify-end pt-6 border-t border-gray-200",children:s.jsx("button",{onClick:t,className:"px-6 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:"Cerrar"})})]})}):null},N2=()=>{var R,z;const[e,t]=g.useState([]),[a,r]=g.useState({}),[l,n]=g.useState(!1),[o,i]=g.useState({estado:"",fecha_desde:"",fecha_hasta:""}),[c,m]=g.useState(!1),[u,x]=g.useState(!1),[f,b]=g.useState(null);g.useEffect(()=>{j()},[o]);const j=async()=>{n(!0);try{const[C,k]=await Promise.all([ie.obtenerLotes(o),ie.obtenerEstadisticas()]);t(C),r(k)}catch(C){console.error("Error cargando datos:",C)}finally{n(!1)}},v=C=>{const{name:k,value:_}=C.target;i(H=>({...H,[k]:_}))},S=()=>{i({estado:"",fecha_desde:"",fecha_hasta:""})},h=()=>{m(!0)},d=()=>{m(!1)},p=C=>{b(C),x(!0)},y=()=>{x(!1),b(null)},E=()=>{j(),d()},w=async C=>{if(window.confirm("¿Marcar este lote como impreso?"))try{await ie.marcarLoteImpreso(C),j()}catch(k){console.error("Error marcando lote como impreso:",k),alert("Error al marcar lote como impreso: "+k.message)}},N=async C=>{if(window.confirm("¿Marcar todos los códigos de este lote como usados? Esta acción no se puede deshacer."))try{await ie.marcarLoteComoUsado(C),j(),alert("Lote marcado como usado exitosamente")}catch(k){console.error("Error marcando lote como usado:",k),alert("Error al marcar lote como usado: "+k.message)}};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"Códigos QR"}),s.jsx("p",{className:"text-gray-600",children:"Genera y administra códigos QR para impresión"})]}),s.jsxs("button",{onClick:h,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center",children:[s.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Generar Lote"]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-6",children:[s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-2 bg-blue-100 rounded-lg",children:s.jsx("svg",{className:"w-6 h-6 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:a.generado||0}),s.jsx("p",{className:"text-sm text-gray-600",children:"Códigos Generados"})]})]})}),s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-2 bg-yellow-100 rounded-lg",children:s.jsx("svg",{className:"w-6 h-6 text-yellow-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:a.asignado||0}),s.jsx("p",{className:"text-sm text-gray-600",children:"Códigos Asignados"})]})]})}),s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-2 bg-green-100 rounded-lg",children:s.jsx("svg",{className:"w-6 h-6 text-green-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:a.usado||0}),s.jsx("p",{className:"text-sm text-gray-600",children:"Códigos Usados"})]})]})}),s.jsx("div",{className:"bg-white p-6 rounded-lg shadow",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-2 bg-purple-100 rounded-lg",children:s.jsx("svg",{className:"w-6 h-6 text-purple-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:(((R=a.lotes)==null?void 0:R.pendiente)||0)+(((z=a.lotes)==null?void 0:z.impreso)||0)}),s.jsx("p",{className:"text-sm text-gray-600",children:"Lotes Total"})]})]})})]}),s.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[s.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Filtros"}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Estado"}),s.jsxs("select",{name:"estado",value:o.estado,onChange:v,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("option",{value:"",children:"Todos los estados"}),s.jsx("option",{value:"pendiente",children:"Pendiente"}),s.jsx("option",{value:"impreso",children:"Impreso"}),s.jsx("option",{value:"entregado",children:"Entregado"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Fecha Desde"}),s.jsx("input",{type:"date",name:"fecha_desde",value:o.fecha_desde,onChange:v,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Fecha Hasta"}),s.jsx("input",{type:"date",name:"fecha_hasta",value:o.fecha_hasta,onChange:v,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),s.jsx("div",{className:"flex items-end",children:s.jsx("button",{onClick:S,className:"w-full px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-md hover:bg-gray-300",children:"Limpiar Filtros"})})]})]}),s.jsx("div",{className:"bg-white rounded-lg shadow",children:s.jsxs("div",{className:"p-6",children:[s.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Lotes de Códigos QR"}),l?s.jsxs("div",{className:"text-center py-8",children:[s.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto"}),s.jsx("p",{className:"mt-4 text-gray-500",children:"Cargando lotes..."})]}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[s.jsx("thead",{className:"bg-gray-50",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Lote"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Estado"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Códigos"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Fecha"}),s.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Acciones"})]})}),s.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:e.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:"5",className:"px-6 py-4 text-center text-gray-500",children:"No se encontraron lotes"})}):e.map(C=>s.jsxs("tr",{className:"hover:bg-gray-50",children:[s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-gray-900",children:C.nombre}),s.jsxs("div",{className:"text-sm text-gray-500",children:["ID: ",C.id]})]})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${ie.getEstadoColor(C.estado)}`,children:ie.getEstadoTexto(C.estado)})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900",children:s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{children:["Total: ",C.codigos_en_lote]}),s.jsxs("div",{className:"flex space-x-4 text-xs text-gray-500",children:[s.jsxs("span",{className:"text-blue-600",children:["Disponibles: ",C.codigos_disponibles]}),s.jsxs("span",{className:"text-yellow-600",children:["Asignados: ",C.codigos_asignados]}),s.jsxs("span",{className:"text-green-600",children:["Usados: ",C.codigos_usados]})]})]})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:ie.formatFecha(C.fecha_creacion)}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:s.jsxs("div",{className:"flex justify-end space-x-2",children:[s.jsx("button",{onClick:()=>p(C),className:"text-blue-600 hover:text-blue-900",title:"Ver Códigos",children:s.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})}),C.estado==="pendiente"&&s.jsx("button",{onClick:()=>w(C.id),className:"text-green-600 hover:text-green-900",title:"Marcar como Impreso",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"})})}),(C.estado==="pendiente"||C.estado==="impreso")&&s.jsx("button",{onClick:()=>N(C.id),className:"text-red-600 hover:text-red-900",title:"Marcar Lote como Usado",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})})]},C.id))})]})})]})}),s.jsx(v2,{isOpen:c,onClose:d,onLoteGenerado:E}),s.jsx(j2,{isOpen:u,onClose:y,lote:f})]})},w2=()=>s.jsx(Nt,{children:s.jsx(N2,{})});class S2{async obtenerTodos(t={}){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getRepartidores",...t})});if(a.success)return a.data||[];throw new Error(a.message||"Error obteniendo repartidores")}catch(a){throw console.error("Error fetching repartidores:",a),a}}async obtenerPorId(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getRepartidor",id:t})});if(a.success)return a.data;throw new Error(a.message||"Error obteniendo repartidor")}catch(a){throw console.error("Error fetching repartidor:",a),a}}async crear(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"createRepartidor",...t})});if(a.success)return a.data;throw new Error(a.message||"Error creando repartidor")}catch(a){throw console.error("Error creating repartidor:",a),a}}async actualizar(t,a){try{const r=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"updateRepartidor",id:t,...a})});if(r.success)return r.data;throw new Error(r.message||"Error actualizando repartidor")}catch(r){throw console.error("Error updating repartidor:",r),r}}async eliminar(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"deleteRepartidor",id:t})});if(a.success)return!0;throw new Error(a.message||"Error eliminando repartidor")}catch(a){throw console.error("Error deleting repartidor:",a),a}}async cambiarEstado(t,a){try{const r=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"cambiarEstadoRepartidor",id:t,estado:a})});if(r.success)return!0;throw new Error(r.message||"Error cambiando estado del repartidor")}catch(r){throw console.error("Error changing repartidor status:",r),r}}async obtenerEstadisticas(){try{const t=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getEstadisticasRepartidores"})});if(t.success)return t.data||{};throw new Error(t.message||"Error obteniendo estadísticas")}catch(t){throw console.error("Error fetching estadisticas:",t),t}}async generarCodigo(){try{const t=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"generarCodigoRepartidor"})});if(t.success)return t.data.codigo;throw new Error(t.message||"Error generando código")}catch(t){throw console.error("Error generating codigo:",t),t}}getEstadoColor(t){return{activo:"bg-green-100 text-green-800",inactivo:"bg-gray-100 text-gray-800",suspendido:"bg-red-100 text-red-800",vacaciones:"bg-blue-100 text-blue-800"}[t]||"bg-gray-100 text-gray-800"}getEstadoTexto(t){return{activo:"Activo",inactivo:"Inactivo",suspendido:"Suspendido",vacaciones:"De Vacaciones"}[t]||t}getVehiculoTexto(t){return{bicicleta:"Bicicleta",motocicleta:"Motocicleta",vehiculo:"Vehículo",a_pie:"A pie"}[t]||t}formatFecha(t){return t?new Date(t).toLocaleDateString("es-ES",{year:"numeric",month:"2-digit",day:"2-digit"}):"N/A"}formatFechaHora(t){return t?new Date(t).toLocaleDateString("es-ES",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"N/A"}formatMoneda(t){return new Intl.NumberFormat("es-EC",{style:"currency",currency:"USD"}).format(t||0)}formatTelefono(t){return t?t.length===10&&t.startsWith("0")?t.replace(/(\d{2})(\d{3})(\d{4})/,"$1 $2 $3"):t:""}formatPorcentaje(t){return`${parseFloat(t||0).toFixed(2)}%`}calcularEdad(t){if(!t)return null;const a=new Date,r=new Date(t);let l=a.getFullYear()-r.getFullYear();const n=a.getMonth()-r.getMonth();return(n<0||n===0&&a.getDate()<r.getDate())&&l--,l}calcularAntiguedad(t){if(!t)return"";const a=new Date,r=new Date(t),l=Math.abs(a-r),n=Math.ceil(l/(1e3*60*60*24));if(n<30)return`${n} días`;if(n<365){const o=Math.floor(n/30);return`${o} ${o===1?"mes":"meses"}`}else{const o=Math.floor(n/365),i=Math.floor(n%365/30);let c=`${o} ${o===1?"año":"años"}`;return i>0&&(c+=` y ${i} ${i===1?"mes":"meses"}`),c}}validarEmail(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}validarTelefono(t){return/^0[2-9]\d{7,8}$/.test(t)}validarCedula(t){if(!/^\d{10}$/.test(t))return!1;const a=t.split("").map(Number),r=a.pop();let l=0;for(let o=0;o<a.length;o++){let i=a[o];o%2===0&&(i*=2,i>9&&(i-=9)),l+=i}return(10-l%10)%10===r}}const We=new S2,E2=({isOpen:e,onClose:t,repartidor:a=null,onSuccess:r})=>{const[l,n]=g.useState({codigo:"",nombre:"",apellidos:"",telefono:"",telefono_secundario:"",email:"",cedula:"",direccion:"",fecha_nacimiento:"",fecha_ingreso:"",salario_base:"",comision_porcentaje:"",zona_asignada:"",vehiculo_tipo:"a_pie",vehiculo_placa:"",licencia_conducir:"",estado:"activo",password:"",password_confirm:"",notas:""}),[o,i]=g.useState({}),[c,m]=g.useState(!1),[u,x]=g.useState(!1),[f,b]=g.useState(!1),[j,v]=g.useState(!1);g.useEffect(()=>{a?(b(!0),n({...a,password:"",password_confirm:"",fecha_nacimiento:a.fecha_nacimiento?a.fecha_nacimiento.split(" ")[0]:"",fecha_ingreso:a.fecha_ingreso?a.fecha_ingreso.split(" ")[0]:""})):(b(!1),S(),e&&!j&&h())},[a,e]);const S=()=>{n({codigo:"",nombre:"",apellidos:"",telefono:"",telefono_secundario:"",email:"",cedula:"",direccion:"",fecha_nacimiento:"",fecha_ingreso:new Date().toISOString().split("T")[0],salario_base:"",comision_porcentaje:"5",zona_asignada:"",vehiculo_tipo:"a_pie",vehiculo_placa:"",licencia_conducir:"",estado:"activo",password:"",password_confirm:"",notas:""}),i({}),v(!1)},h=async()=>{try{const w=await We.generarCodigo();n(N=>({...N,codigo:w})),v(!0)}catch(w){console.error("Error generando código:",w)}},d=w=>{const{name:N,value:R}=w.target;n(z=>({...z,[N]:R})),o[N]&&i(z=>({...z,[N]:""}))},p=()=>{const w={};return l.nombre.trim()||(w.nombre="Nombre es requerido"),l.apellidos.trim()||(w.apellidos="Apellidos son requeridos"),l.telefono.trim()||(w.telefono="Teléfono es requerido"),l.email.trim()||(w.email="Email es requerido"),l.email&&!We.validarEmail(l.email)&&(w.email="Email no válido"),l.telefono&&!We.validarTelefono(l.telefono)&&(w.telefono="Formato de teléfono no válido (ej: 0987654321)"),f?l.password&&(l.password.length<6&&(w.password="Contraseña debe tener al menos 6 caracteres"),l.password!==l.password_confirm&&(w.password_confirm="Las contraseñas no coinciden")):(l.password?l.password.length<6&&(w.password="Contraseña debe tener al menos 6 caracteres"):w.password="Contraseña es requerida",l.password!==l.password_confirm&&(w.password_confirm="Las contraseñas no coinciden")),i(w),Object.keys(w).length===0},y=async w=>{if(w.preventDefault(),!!p()){m(!0);try{const N={...l};N.telefono_secundario||delete N.telefono_secundario,N.notas||delete N.notas,f&&!N.password&&(delete N.password,delete N.password_confirm);let R;f?R=await We.actualizar(a.id,N):R=await We.crear(N);const z=f?"El repartidor se ha actualizado correctamente":`Repartidor creado con código: ${R.codigo||l.codigo}`;alert(z),r(),t(),S()}catch(N){console.error("Error:",N),alert("Error: "+(N.message||"Error al procesar la solicitud"))}finally{m(!1)}}},E=()=>{c||(t(),setTimeout(S,300))};return e?s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl w-full max-w-4xl max-h-[90vh] overflow-hidden",children:[s.jsxs("div",{className:"bg-blue-600 text-white p-4 flex justify-between items-center",children:[s.jsx("h2",{className:"text-xl font-semibold",children:f?"Editar Repartidor":"Nuevo Repartidor"}),s.jsx("button",{onClick:E,disabled:c,className:"text-white hover:text-gray-200 text-2xl disabled:opacity-50",children:"×"})]}),s.jsxs("form",{onSubmit:y,className:"p-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[s.jsx("div",{className:"lg:col-span-3",children:s.jsx("h3",{className:"text-lg font-semibold text-gray-800 mb-4 border-b pb-2",children:"Información Personal"})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Código"}),s.jsx("input",{type:"text",name:"codigo",value:l.codigo,readOnly:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-md bg-gray-50 text-gray-600"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Nombre *"}),s.jsx("input",{type:"text",name:"nombre",value:l.nombre,onChange:d,className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${o.nombre?"border-red-500":"border-gray-300"}`,disabled:c}),o.nombre&&s.jsx("p",{className:"text-red-500 text-sm mt-1",children:o.nombre})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Apellidos *"}),s.jsx("input",{type:"text",name:"apellidos",value:l.apellidos,onChange:d,className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${o.apellidos?"border-red-500":"border-gray-300"}`,disabled:c}),o.apellidos&&s.jsx("p",{className:"text-red-500 text-sm mt-1",children:o.apellidos})]}),s.jsx("div",{className:"lg:col-span-3",children:s.jsx("h3",{className:"text-lg font-semibold text-gray-800 mb-4 border-b pb-2 mt-6",children:"Información de Contacto"})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Teléfono *"}),s.jsx("input",{type:"tel",name:"telefono",value:l.telefono,onChange:d,placeholder:"0987654321",className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${o.telefono?"border-red-500":"border-gray-300"}`,disabled:c}),o.telefono&&s.jsx("p",{className:"text-red-500 text-sm mt-1",children:o.telefono})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Teléfono Secundario"}),s.jsx("input",{type:"tel",name:"telefono_secundario",value:l.telefono_secundario,onChange:d,placeholder:"0987654321",className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",disabled:c})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Email *"}),s.jsx("input",{type:"email",name:"email",value:l.email,onChange:d,className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${o.email?"border-red-500":"border-gray-300"}`,disabled:c}),o.email&&s.jsx("p",{className:"text-red-500 text-sm mt-1",children:o.email})]}),s.jsx("div",{className:"lg:col-span-3",children:s.jsx("h3",{className:"text-lg font-semibold text-gray-800 mb-4 border-b pb-2 mt-6",children:"Credenciales para App Móvil"})}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:["Contraseña ",!f&&"*"]}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:u?"text":"password",name:"password",value:l.password,onChange:d,className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 pr-10 ${o.password?"border-red-500":"border-gray-300"}`,disabled:c,placeholder:f?"Dejar vacío para no cambiar":""}),s.jsx("button",{type:"button",onClick:()=>x(!u),className:"absolute right-2 top-2 text-gray-500 hover:text-gray-700",disabled:c,children:u?"👁️":"👁️‍🗨️"})]}),o.password&&s.jsx("p",{className:"text-red-500 text-sm mt-1",children:o.password})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:["Confirmar Contraseña ",!f&&"*"]}),s.jsx("input",{type:u?"text":"password",name:"password_confirm",value:l.password_confirm,onChange:d,className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${o.password_confirm?"border-red-500":"border-gray-300"}`,disabled:c,placeholder:f?"Dejar vacío para no cambiar":""}),o.password_confirm&&s.jsx("p",{className:"text-red-500 text-sm mt-1",children:o.password_confirm})]}),s.jsxs("div",{className:"lg:col-span-3",children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Notas"}),s.jsx("textarea",{name:"notas",value:l.notas,onChange:d,rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",disabled:c,placeholder:"Observaciones adicionales..."})]})]}),s.jsxs("div",{className:"flex justify-end space-x-4 mt-8 pt-6 border-t",children:[s.jsx("button",{type:"button",onClick:E,disabled:c,className:"px-6 py-2 border border-gray-300 text-gray-700 rounded-md hover:bg-gray-50 disabled:opacity-50",children:"Cancelar"}),s.jsxs("button",{type:"submit",disabled:c,className:"px-6 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:opacity-50 flex items-center",children:[c&&s.jsxs("svg",{className:"animate-spin -ml-1 mr-3 h-5 w-5 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),c?"Procesando...":f?"Actualizar":"Crear Repartidor"]})]})]})]})}):null},_2=({isOpen:e,onClose:t,repartidor:a})=>!e||!a?null:s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl w-full max-w-4xl max-h-[90vh] overflow-hidden",children:[s.jsxs("div",{className:"bg-blue-600 text-white p-4 flex justify-between items-center",children:[s.jsx("h2",{className:"text-xl font-semibold",children:"Detalles del Repartidor"}),s.jsx("button",{onClick:t,className:"text-white hover:text-gray-200 text-2xl",children:"×"})]}),s.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"bg-gray-50 rounded-lg p-6",children:[s.jsxs("h3",{className:"text-lg font-semibold text-gray-800 mb-4 flex items-center",children:[s.jsx("svg",{className:"w-5 h-5 mr-2 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})}),"Información Personal"]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-sm font-medium text-gray-600",children:"Código"}),s.jsx("p",{className:"text-gray-900 font-mono text-lg",children:a.codigo})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm font-medium text-gray-600",children:"Nombre Completo"}),s.jsxs("p",{className:"text-gray-900",children:[a.nombre," ",a.apellidos]})]}),a.direccion&&s.jsxs("div",{children:[s.jsx("label",{className:"text-sm font-medium text-gray-600",children:"Dirección"}),s.jsx("p",{className:"text-gray-900",children:a.direccion})]})]})]}),s.jsxs("div",{className:"bg-gray-50 rounded-lg p-6",children:[s.jsxs("h3",{className:"text-lg font-semibold text-gray-800 mb-4 flex items-center",children:[s.jsx("svg",{className:"w-5 h-5 mr-2 text-green-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"})}),"Información de Contacto"]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-sm font-medium text-gray-600",children:"Teléfono Principal"}),s.jsx("p",{className:"text-gray-900",children:We.formatTelefono(a.telefono)})]}),a.telefono_secundario&&s.jsxs("div",{children:[s.jsx("label",{className:"text-sm font-medium text-gray-600",children:"Teléfono Secundario"}),s.jsx("p",{className:"text-gray-900",children:We.formatTelefono(a.telefono_secundario)})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm font-medium text-gray-600",children:"Email"}),s.jsx("p",{className:"text-gray-900",children:a.email})]})]})]}),s.jsxs("div",{className:"lg:col-span-2 bg-gray-50 rounded-lg p-6",children:[s.jsxs("h3",{className:"text-lg font-semibold text-gray-800 mb-4 flex items-center",children:[s.jsx("svg",{className:"w-5 h-5 mr-2 text-indigo-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Actividad Reciente"]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"text-center p-4 bg-white rounded-lg border",children:[s.jsx("div",{className:"text-2xl font-bold text-gray-900",children:a.ultimo_acceso_texto||"Nunca"}),s.jsx("div",{className:"text-sm text-gray-500",children:"Último Acceso"})]}),s.jsxs("div",{className:"text-center p-4 bg-white rounded-lg border",children:[s.jsx("div",{className:"text-2xl font-bold text-green-600",children:a.ultimo_login?We.formatFechaHora(a.ultimo_login):"N/A"}),s.jsx("div",{className:"text-sm text-gray-500",children:"Último Login"})]})]})]}),a.notas&&s.jsxs("div",{className:"lg:col-span-2 bg-yellow-50 rounded-lg p-6 border border-yellow-200",children:[s.jsxs("h3",{className:"text-lg font-semibold text-gray-800 mb-4 flex items-center",children:[s.jsx("svg",{className:"w-5 h-5 mr-2 text-yellow-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})}),"Notas"]}),s.jsx("p",{className:"text-gray-700 whitespace-pre-wrap",children:a.notas})]})]}),s.jsx("div",{className:"flex justify-end mt-8 pt-6 border-t",children:s.jsx("button",{onClick:t,className:"px-6 py-2 bg-gray-600 text-white rounded-md hover:bg-gray-700 transition-colors",children:"Cerrar"})})]})]})}),k2=()=>{const[e,t]=g.useState([]),[a,r]=g.useState({}),[l,n]=g.useState(!1),[o,i]=g.useState({search:""}),[c,m]=g.useState(!1),[u,x]=g.useState(!1),[f,b]=g.useState(null),[j,v]=g.useState(null);g.useEffect(()=>{S()},[o]);const S=async()=>{n(!0);try{const[C,k]=await Promise.all([We.obtenerTodos(o),We.obtenerEstadisticas()]);t(C),r(k)}catch(C){console.error("Error cargando datos:",C)}finally{n(!1)}},h=C=>{const{name:k,value:_}=C.target;i(H=>({...H,[k]:_}))},d=()=>{i({search:""})},p=(C=null)=>{b(C),m(!0)},y=()=>{m(!1),b(null)},E=C=>{v(C),x(!0)},w=()=>{x(!1),v(null)},N=()=>{S(),y()},R=async C=>{const k=e.find(_=>_.id===C);if(window.confirm(`¿Está seguro de eliminar a ${k==null?void 0:k.nombre_completo}?`))try{await We.eliminar(C),await S()}catch(_){console.error("Error eliminando repartidor:",_),alert("Error al eliminar repartidor: "+_.message)}},z=()=>{const C=[["Código","Nombre Completo","Email","Teléfono","Teléfono Secundario","Último Acceso"],...e.map(H=>[H.codigo,H.nombre_completo,H.email,H.telefono,H.telefono_secundario||"",H.ultimo_acceso_texto||"Nunca"])].map(H=>H.join(",")).join(`
`),k=new Blob([C],{type:"text/csv;charset=utf-8;"}),_=document.createElement("a");_.href=URL.createObjectURL(k),_.download=`repartidores_${new Date().toISOString().split("T")[0]}.csv`,_.click()};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex justify-between items-start",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"Gestión de Repartidores"}),s.jsx("p",{className:"text-gray-600",children:"Administra tu equipo de repartidores/vendedores"})]}),s.jsxs("div",{className:"flex space-x-3",children:[s.jsxs("button",{onClick:z,className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center",children:[s.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),"Exportar"]}),s.jsxs("button",{onClick:()=>p(),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center",children:[s.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Nuevo Repartidor"]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[s.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-2 bg-blue-100 rounded-lg",children:s.jsx("svg",{className:"w-8 h-8 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Total Repartidores"}),s.jsx("p",{className:"text-2xl font-semibold text-gray-900",children:a.total||0})]})]})}),s.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-2 bg-green-100 rounded-lg",children:s.jsx("svg",{className:"w-8 h-8 text-green-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Activos"}),s.jsx("p",{className:"text-2xl font-semibold text-green-600",children:a.activos||0})]})]})}),s.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-2 bg-yellow-100 rounded-lg",children:s.jsx("svg",{className:"w-8 h-8 text-yellow-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Activos Hoy"}),s.jsx("p",{className:"text-2xl font-semibold text-yellow-600",children:a.activos_hoy||0})]})]})})]}),s.jsx("div",{className:"bg-white rounded-lg shadow",children:s.jsxs("div",{className:"p-6",children:[s.jsxs("div",{className:"mb-6 flex gap-4 items-end",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Buscar"}),s.jsx("input",{type:"text",name:"search",value:o.search,onChange:h,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Nombre, código, email, teléfono..."})]}),s.jsx("div",{children:s.jsx("button",{onClick:d,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-md hover:bg-gray-300",children:"Limpiar"})})]}),l?s.jsxs("div",{className:"text-center py-8",children:[s.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto"}),s.jsx("p",{className:"mt-4 text-gray-500",children:"Cargando repartidores..."})]}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[s.jsx("thead",{className:"bg-gray-50",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Repartidor"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Contacto"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Último Acceso"}),s.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Acciones"})]})}),s.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:e.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:"4",className:"px-6 py-4 text-center text-gray-500",children:"No se encontraron repartidores"})}):e.map(C=>s.jsxs("tr",{className:"hover:bg-gray-50",children:[s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"flex-shrink-0 h-10 w-10",children:s.jsxs("div",{className:"h-10 w-10 rounded-full bg-gradient-to-br from-indigo-400 to-indigo-600 flex items-center justify-center text-white font-medium",children:[C.nombre.charAt(0),C.apellidos.charAt(0)]})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("div",{className:"text-sm font-medium text-gray-900",children:C.nombre_completo}),s.jsx("div",{className:"text-sm text-gray-500",children:C.codigo})]})]})}),s.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[s.jsx("div",{className:"text-sm text-gray-900",children:C.email}),s.jsx("div",{className:"text-sm text-gray-500",children:We.formatTelefono(C.telefono)}),C.telefono_secundario&&s.jsx("div",{className:"text-sm text-gray-400",children:We.formatTelefono(C.telefono_secundario)})]}),s.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[s.jsx("div",{className:"text-sm text-gray-900",children:C.ultimo_acceso_texto||"Nunca"}),C.ultimo_login&&s.jsx("div",{className:"text-xs text-gray-500",children:We.formatFechaHora(C.ultimo_login)})]}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:s.jsxs("div",{className:"flex justify-end space-x-2",children:[s.jsx("button",{onClick:()=>E(C),className:"text-blue-600 hover:text-blue-900",title:"Ver Detalles",children:s.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})}),s.jsx("button",{onClick:()=>p(C),className:"text-indigo-600 hover:text-indigo-900",title:"Editar",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),s.jsx("button",{onClick:()=>R(C.id),className:"text-red-600 hover:text-red-900",title:"Eliminar",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})})]},C.id))})]})})]})}),s.jsx(E2,{isOpen:c,onClose:y,onSave:N,repartidor:f}),s.jsx(_2,{isOpen:u,onClose:w,repartidor:j})]})},C2=()=>s.jsx(Nt,{children:s.jsx(k2,{})}),M2="modulepreload",R2=function(e){return"/"+e},au={},T2=function(t,a,r){let l=Promise.resolve();if(a&&a.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),i=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));l=Promise.allSettled(a.map(c=>{if(c=R2(c),c in au)return;au[c]=!0;const m=c.endsWith(".css"),u=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${u}`))return;const x=document.createElement("link");if(x.rel=m?"stylesheet":M2,m||(x.as="script"),x.crossOrigin="",x.href=c,i&&x.setAttribute("nonce",i),document.head.appendChild(x),m)return new Promise((f,b)=>{x.addEventListener("load",f),x.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${c}`)))})}))}function n(o){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=o,window.dispatchEvent(i),!i.defaultPrevented)throw o}return l.then(o=>{for(const i of o||[])i.status==="rejected"&&n(i.reason);return t().catch(n)})};class z2{async obtenerTodos(t={}){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getRutas",...t})});if(a.success)return a.data||[];throw new Error(a.message||"Error obteniendo rutas")}catch(a){throw console.error("Error fetching rutas:",a),a}}async obtenerPorId(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getRuta",id:t})});if(a.success)return a.data;throw new Error(a.message||"Error obteniendo ruta")}catch(a){throw console.error("Error fetching ruta:",a),a}}async crear(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"createRuta",...t})});if(a.success)return a.data;throw new Error(a.message||"Error creando ruta")}catch(a){throw console.error("Error creating ruta:",a),a}}async actualizar(t,a){try{const r=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"updateRuta",id:t,...a})});if(r.success)return r.data;throw new Error(r.message||"Error actualizando ruta")}catch(r){throw console.error("Error updating ruta:",r),r}}async eliminar(t){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"deleteRuta",id:t})});if(a.success)return a.data;throw new Error(a.message||"Error eliminando ruta")}catch(a){throw console.error("Error deleting ruta:",a),a}}async asignarVehiculo(t,a){try{const r=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"asignarVehiculo",ruta_id:t,vehiculo_id:a})});if(r.success)return r.data;throw new Error(r.message||"Error asignando vehículo")}catch(r){throw console.error("Error assigning vehiculo:",r),r}}async asignarConductor(t,a){try{const r=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"asignarConductor",ruta_id:t,repartidor_id:a})});if(r.success)return r.data;throw new Error(r.message||"Error asignando conductor")}catch(r){throw console.error("Error assigning conductor:",r),r}}async obtenerRepartidoresDisponibles(t=null){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getRepartidoresDisponibles",fecha:t||new Date().toISOString().split("T")[0]})});if(a.success)return a.data||[];throw new Error(a.message||"Error obteniendo repartidores disponibles")}catch(a){throw console.error("Error fetching repartidores disponibles:",a),a}}async obtenerVehiculosDisponibles(t=null){try{const a=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getVehiculosDisponibles",fecha:t||new Date().toISOString().split("T")[0]})});if(a.success)return a.data||[];throw new Error(a.message||"Error obteniendo vehículos disponibles")}catch(a){throw console.error("Error fetching vehiculos disponibles:",a),a}}async cambiarEstado(t,a){try{const r=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"cambiarEstadoRuta",ruta_id:t,estado:a})});if(r.success)return r.data;throw new Error(r.message||"Error cambiando estado")}catch(r){throw console.error("Error changing estado:",r),r}}async generarCodigo(){try{const t=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"generarCodigoRuta"})});if(t.success)return t.data;throw new Error(t.message||"Error generando código")}catch(t){throw console.error("Error generating codigo:",t),t}}async obtenerEstadisticas(){try{const t=await U.request("reportes/funciones_php/api.php",{method:"POST",body:JSON.stringify({tipo:"getEstadisticasRutas"})});if(t.success)return t.data||{};throw new Error(t.message||"Error obteniendo estadísticas")}catch(t){throw console.error("Error fetching estadisticas:",t),t}}formatFecha(t){return t?new Date(t).toLocaleDateString("es-ES",{day:"2-digit",month:"2-digit",year:"numeric"}):""}formatHora(t){return t?t.substring(0,5):""}formatFechaHora(t){return t?new Date(t).toLocaleString("es-ES",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):""}getEstadoTexto(t){return{planificada:"Planificada",en_progreso:"En Progreso",completada:"Completada",cancelada:"Cancelada"}[t]||t}getEstadoColor(t){return{planificada:"bg-blue-100 text-blue-800",en_progreso:"bg-yellow-100 text-yellow-800",completada:"bg-green-100 text-green-800",cancelada:"bg-red-100 text-red-800"}[t]||"bg-gray-100 text-gray-800"}calcularProgreso(t,a){return!a||a===0?0:Math.round(t/a*100)}validarDatosRuta(t){const a=[];return(!t.nombre||t.nombre.trim()==="")&&a.push("El nombre de la ruta es obligatorio"),t.fecha_ruta?new Date(t.fecha_ruta)<new Date().setHours(0,0,0,0)&&a.push("La fecha de la ruta no puede ser anterior a hoy"):a.push("La fecha de la ruta es obligatoria"),t.hora_inicio&&t.hora_fin&&t.hora_inicio>=t.hora_fin&&a.push("La hora de inicio debe ser anterior a la hora de fin"),t.paradas&&t.paradas.length===0&&a.push("La ruta debe tener al menos una parada"),a}async obtenerClientesParaRuta(){try{const{default:t}=await T2(async()=>{const{default:a}=await Promise.resolve().then(()=>f2);return{default:a}},[]);return await t.obtenerTodos({activo:"1"})}catch(t){throw console.error("Error obteniendo clientes para ruta:",t),t}}calcularDistancia(t,a,r,l){const o=(r-t)*Math.PI/180,i=(l-a)*Math.PI/180,c=Math.sin(o/2)*Math.sin(o/2)+Math.cos(t*Math.PI/180)*Math.cos(r*Math.PI/180)*Math.sin(i/2)*Math.sin(i/2);return 6371*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))}optimizarParadas(t,a={latitud:0,longitud:0}){if(t.length<=1)return t;const r=[...t],l=new Set,n=[];let o=a;for(;n.length<t.length;){let i=1/0,c=-1;for(let m=0;m<r.length;m++){if(l.has(m))continue;const u=r[m];if(u.latitud&&u.longitud){const x=this.calcularDistancia(o.latitud,o.longitud,u.latitud,u.longitud);x<i&&(i=x,c=m)}}if(c!==-1)l.add(c),n.push(r[c]),o=r[c];else for(let m=0;m<r.length;m++)if(!l.has(m)){l.add(m),n.push(r[m]);break}}return n}}const De=new z2,L2=({paradas:e=[],onRouteCalculated:t,rutaExistente:a=null})=>{const r=g.useRef(null),l=g.useRef([]),[n,o]=g.useState(null),[i,c]=g.useState(!1),[m,u]=g.useState(!1),x=g.useRef(null),f=g.useRef(null),b=g.useRef(!1),j=g.useRef(null);g.useEffect(()=>{if(!r.current)return;(async()=>{try{await gf();const d={lat:21.8853,lng:-102.2916},p=new window.google.maps.Map(r.current,{center:d,zoom:12,mapTypeId:"roadmap"});o(p),x.current=new window.google.maps.DirectionsService,f.current=new window.google.maps.DirectionsRenderer({suppressMarkers:!0,preserveViewport:!1}),f.current.setMap(p)}catch(d){console.error("Error cargando Google Maps:",d),r.current&&(r.current.innerHTML=`
            <div class="flex items-center justify-center h-full">
              <div class="text-center">
                <svg class="mx-auto h-12 w-12 text-red-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.728-.833-2.498 0L4.316 15.5c-.77.833.192 2.5 1.732 2.5z" />
                </svg>
                <h3 class="mt-2 text-sm font-medium text-gray-900">Error cargando el mapa</h3>
                <p class="mt-1 text-sm text-gray-500">${d.message}</p>
              </div>
            </div>
          `)}})()},[]),g.useEffect(()=>{const h=a==null?void 0:a.id;if(h&&h!==j.current&&(console.log("MapaRuta - Nueva ruta detectada, reseteando flag:",h),j.current=h,b.current=!1),b.current){console.log("MapaRuta - Ya se calculó automáticamente para esta ruta, saltando...");return}n&&a&&e&&e.length>=2&&x.current&&(console.log("MapaRuta - Auto-recalculando ruta existente para ID:",h),b.current=!0,setTimeout(()=>{v()},500))},[n,a==null?void 0:a.id,e==null?void 0:e.length]),g.useEffect(()=>{if(!n||!e.length){l.current.forEach(d=>d.setMap(null)),l.current=[];return}l.current.forEach(d=>d.setMap(null)),l.current=[];const h=new window.google.maps.LatLngBounds;if(e.forEach((d,p)=>{const y=new window.google.maps.Marker({position:{lat:d.lat,lng:d.lng},map:n,title:`${d.orden}. ${d.nombre}`,label:{text:d.orden.toString(),color:"white",fontSize:"12px",fontWeight:"bold"},icon:{path:window.google.maps.SymbolPath.CIRCLE,scale:20,fillColor:p===0?"#22c55e":p===e.length-1?"#ef4444":"#3b82f6",fillOpacity:1,strokeColor:"white",strokeWeight:2}}),E=new window.google.maps.InfoWindow({content:`
          <div style="padding: 8px;">
            <h3 style="margin: 0 0 4px 0; color: #1f2937; font-size: 14px; font-weight: 600;">
              Parada #${d.orden}
            </h3>
            <p style="margin: 0; color: #4b5563; font-size: 13px;">
              ${d.nombre}
            </p>
            <div style="margin-top: 6px; font-size: 11px; color: #6b7280;">
              Lat: ${d.lat.toFixed(6)}<br>
              Lng: ${d.lng.toFixed(6)}
            </div>
          </div>
        `});y.addListener("click",()=>{l.current.forEach(w=>{var N;return(N=w.infoWindow)==null?void 0:N.close()}),E.open(n,y),y.infoWindow=E}),l.current.push(y),h.extend({lat:d.lat,lng:d.lng})}),e.length>1&&!i){const d=e.map(y=>({lat:y.lat,lng:y.lng})),p=new window.google.maps.Polyline({path:d,geodesic:!0,strokeColor:"#3b82f6",strokeOpacity:1,strokeWeight:3});p.setMap(n),l.current.push(p)}e.length===1?(n.setCenter({lat:e[0].lat,lng:e[0].lng}),n.setZoom(15)):e.length>1&&(n.fitBounds(h),window.google.maps.event.addListenerOnce(n,"bounds_changed",()=>{n.getZoom()>16&&n.setZoom(16)}))},[n,e,i]);const v=async()=>{if(!(!x.current||!f.current||e.length<2)){u(!0);try{const h={lat:e[0].lat,lng:e[0].lng},d={lat:e[e.length-1].lat,lng:e[e.length-1].lng},p=e.slice(1,-1).map(E=>({location:{lat:E.lat,lng:E.lng},stopover:!0})),y={origin:h,destination:d,waypoints:p,optimizeWaypoints:!0,travelMode:window.google.maps.TravelMode.DRIVING,unitSystem:window.google.maps.UnitSystem.METRIC};x.current.route(y,(E,w)=>{if(u(!1),w==="OK"){l.current.forEach(A=>{A.setMap&&(typeof A.setPath=="function"||A.strokeColor)&&A.setMap(null)}),f.current.setDirections(E),c(!0);const N=E.routes[0],R=N.legs.reduce((A,O)=>A+O.distance.value,0)/1e3,z=Math.round(N.legs.reduce((A,O)=>A+O.duration.value,0)/60),C=E.routes[0].waypoint_order||[];console.log("Waypoints optimizados:",C);const k=N.bounds,_=N.overview_polyline;console.log("Polyline objeto completo:",_),console.log("Polyline.points:",_==null?void 0:_.points);const H=[];N.legs.forEach((A,O)=>{A.steps.forEach((B,T)=>{H.push({legIndex:O,stepIndex:T,instruccion:B.instructions,distancia:B.distance.text,duracion:B.duration.text,maniobra:B.maneuver||null})})});const Q={distanciaTotal:R.toFixed(2),tiempoEstimado:z,rutaPolyline:(_==null?void 0:_.points)||_,waypointsOptimizados:C,boundsNeLat:k.getNorthEast().lat(),boundsNeLng:k.getNorthEast().lng(),boundsSwLat:k.getSouthWest().lat(),boundsSwLng:k.getSouthWest().lng(),instruccionesJson:H};console.log("RouteData final enviado:",Q),console.log("Ruta calculada:",{distancia:R.toFixed(2)+" km",tiempo:z+" minutos",waypoints:C}),t&&t(Q)}else console.error("Error calculando ruta:",w),alert("No se pudo calcular la ruta. Verifica que todas las ubicaciones sean accesibles por carretera.")})}catch(h){u(!1),console.error("Error:",h)}}},S=()=>{f.current&&f.current.setDirections({routes:[]}),c(!1)};return s.jsxs("div",{className:"relative w-full h-full",children:[a&&a.ruta_polyline&&i&&s.jsx("div",{className:"absolute top-2 left-2 z-10",children:s.jsxs("div",{className:"bg-green-600 text-white px-3 py-2 rounded-md text-sm font-medium shadow-lg flex items-center gap-2",children:[s.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Ruta Guardada (",a.distancia_total," km - ",a.tiempo_estimado," min)"]})}),e.length>=2&&s.jsx("div",{className:"absolute top-2 right-2 z-10 flex gap-2",children:i?s.jsxs("button",{type:"button",onClick:S,className:"bg-gray-600 text-white px-3 py-2 rounded-md text-sm font-medium hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 flex items-center gap-2 shadow-lg",children:[s.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"})}),"Línea Directa"]}):s.jsx("button",{type:"button",onClick:v,disabled:m,className:"bg-blue-600 text-white px-3 py-2 rounded-md text-sm font-medium hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2 shadow-lg",children:m?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"animate-spin h-4 w-4 border-2 border-white border-t-transparent rounded-full"}),"Calculando..."]}):s.jsxs(s.Fragment,{children:[s.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 20l-5.447-2.724A1 1 0 013 16.382V5.618a1 1 0 011.447-.894L9 7m0 13l6-3m-6 3V7m6 10l4.553 2.276A1 1 0 0021 18.382V7.618a1 1 0 00-1.447-.894L15 4m0 13V4m-6 3l6-3"})}),a&&a.ruta_polyline?"Recalcular Ruta":"Ruta por Calles"]})})}),s.jsx("div",{ref:r,className:"w-full h-full rounded-lg",style:{minHeight:"400px"}})]})},A2=({paradas:e=[],onRouteCalculated:t,rutaExistente:a=null})=>s.jsx(L2,{paradas:e,onRouteCalculated:t,rutaExistente:a}),O2=({options:e=[],value:t="",onChange:a,placeholder:r="Seleccionar...",className:l="",required:n=!1,disabled:o=!1})=>{const[i,c]=g.useState(!1),[m,u]=g.useState(""),[x,f]=g.useState(-1),b=g.useRef(null),j=g.useRef(null),v=e.filter(E=>E.label.toLowerCase().includes(m.toLowerCase())),S=e.find(E=>E.value===t);g.useEffect(()=>{const E=w=>{b.current&&!b.current.contains(w.target)&&(c(!1),u(""),f(-1))};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);const h=E=>{if(!o)switch(E.key){case"Enter":E.preventDefault(),x>=0&&v[x]&&d(v[x]);break;case"ArrowDown":E.preventDefault(),f(w=>w<v.length-1?w+1:0);break;case"ArrowUp":E.preventDefault(),f(w=>w>0?w-1:v.length-1);break;case"Escape":c(!1),u(""),f(-1);break}},d=E=>{a(E.value),c(!1),u(""),f(-1)},p=()=>{o||(c(!i),i||setTimeout(()=>{var E;return(E=j.current)==null?void 0:E.focus()},0))},y=E=>{u(E.target.value),f(-1),i||c(!0)};return s.jsxs("div",{className:`relative ${l}`,ref:b,children:[s.jsxs("div",{className:`w-full px-2 py-1.5 text-sm border border-gray-300 rounded cursor-pointer bg-white flex items-center justify-between ${o?"bg-gray-100 cursor-not-allowed":"focus-within:ring-1 focus-within:ring-blue-500"}`,onClick:p,children:[s.jsx("div",{className:"flex-1 min-w-0",children:i?s.jsx("input",{ref:j,type:"text",value:m,onChange:y,onKeyDown:h,placeholder:"Buscar...",className:"w-full bg-transparent outline-none",disabled:o}):s.jsx("span",{className:`truncate ${S?"":"text-gray-400"}`,children:S?S.label:r})}),s.jsx("svg",{className:`w-4 h-4 text-gray-400 transition-transform ${i?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),i&&!o&&s.jsx("div",{className:"absolute z-10 w-full mt-1 bg-white border border-gray-300 rounded-md shadow-lg max-h-60 overflow-auto",children:v.length===0?s.jsx("div",{className:"px-3 py-2 text-sm text-gray-500",children:"No se encontraron resultados"}):v.map((E,w)=>s.jsx("div",{className:`px-3 py-2 text-sm cursor-pointer ${x===w?"bg-blue-100 text-blue-900":t===E.value?"bg-blue-50 text-blue-700":"hover:bg-gray-100"}`,onClick:()=>d(E),onMouseEnter:()=>f(w),children:s.jsx("div",{className:"truncate",children:E.label})},E.value))}),s.jsx("input",{type:"hidden",name:"searchable-select",value:t,required:n})]})},D2=({isOpen:e,onClose:t,onSave:a,ruta:r=null})=>{const[l,n]=g.useState(!1),[o,i]=g.useState({}),[c,m]=g.useState({codigo:"",nombre:"",descripcion:"",fecha_ruta:new Date().toISOString().split("T")[0],repartidor_id:"",notas:""}),[u,x]=g.useState([]),[f,b]=g.useState([]),[j,v]=g.useState([]),[S,h]=g.useState("general"),[d,p]=g.useState(!1),[y,E]=g.useState(null),[w,N]=g.useState(null);g.useEffect(()=>{e&&(R(),z().then(()=>{r?C(r):k()}))},[e,r]);const R=()=>{m({codigo:"",nombre:"",descripcion:"",fecha_ruta:new Date().toISOString().split("T")[0],repartidor_id:"",notas:""}),x([]),i({}),h("general"),N(null)},z=async()=>{try{n(!0);const[D,q]=await Promise.all([Ue.obtenerTodos({activo:"1"}),De.obtenerRepartidoresDisponibles(c.fecha_ruta)]);b(D),v(q)}catch(D){console.error("Error cargando datos:",D),alert("Error cargando datos necesarios")}finally{n(!1)}},C=D=>{if(console.log("CrearRuta - llenarFormulario - rutaData completa:",D),console.log("CrearRuta - ruta_polyline:",D.ruta_polyline),console.log("CrearRuta - tipo de ruta_polyline:",typeof D.ruta_polyline),m({codigo:D.codigo||"",nombre:D.nombre||"",descripcion:D.descripcion||"",fecha_ruta:D.fecha_ruta||new Date().toISOString().split("T")[0],repartidor_id:D.repartidor_id?String(D.repartidor_id):"",notas:D.notas||""}),console.log("CrearRuta - repartidor_id recibido:",D.repartidor_id),console.log("CrearRuta - tipo de repartidor_id:",typeof D.repartidor_id),console.log("CrearRuta - repartidoresDisponibles:",j),D.repartidor_id&&!j.find(Z=>Z.id==D.repartidor_id)){console.log("Repartidor asignado no encontrado en lista, agregándolo...");const Z={id:D.repartidor_id,codigo:D.repartidor_codigo||"N/A",nombre_completo:D.repartidor_nombre||"Repartidor Asignado",telefono:D.repartidor_telefono||""};v(G=>[...G,Z])}if(D.paradas){const q=D.paradas.map(Z=>({...Z,id:Z.id||Date.now()+Math.random(),proximas_visitas:Z.frecuencia_dias&&Z.fecha_inicio_frecuencia?B(Z.fecha_inicio_frecuencia,Z.frecuencia_dias,6):[]}));x(q)}},k=async()=>{try{const D=await De.generarCodigo();m(q=>({...q,codigo:D.codigo}))}catch(D){console.error("Error generando código:",D)}},_=D=>{const{name:q,value:Z}=D.target;m(G=>({...G,[q]:Z})),o[q]&&i(G=>({...G,[q]:""})),q==="fecha_ruta"&&H(Z)},H=async D=>{try{const[q]=await Promise.all([De.obtenerRepartidoresDisponibles(D)]);v(q)}catch(q){console.error("Error recargando disponibilidad:",q)}},Q=()=>{const D={id:Date.now(),cliente_id:"",orden:u.length+1,frecuencia_dias:null,fecha_inicio_frecuencia:c.fecha_ruta,dias_semana:[],proximas_visitas:[]};x([...u,D])},A=D=>{const Z=u.filter((G,X)=>X!==D).map((G,X)=>({...G,orden:X+1}));x(Z)},O=(D,q,Z)=>{const G=[...u];if(G[D]={...G[D],[q]:Z},q==="frecuencia_dias"||q==="fecha_inicio_frecuencia"){const X=G[D];X.frecuencia_dias&&X.fecha_inicio_frecuencia&&(X.proximas_visitas=B(X.fecha_inicio_frecuencia,X.frecuencia_dias,6))}x(G)},B=(D,q,Z=6)=>{const G=[],X=new Date(D);for(let M=0;M<Z;M++){const K=new Date(X);K.setDate(X.getDate()+q*M),G.push(K.toISOString().split("T")[0])}return G},T=(D,q)=>{E(q),D.dataTransfer.effectAllowed="move",D.target.style.opacity="0.5"},$=D=>{D.target.style.opacity="",E(null)},I=D=>{D.preventDefault(),D.dataTransfer.dropEffect="move"},Ge=(D,q)=>{if(D.preventDefault(),y===null||y===q)return;const Z=[...u],G=Z[y];Z.splice(y,1),Z.splice(q,0,G);const X=Z.map((M,K)=>({...M,orden:K+1}));x(X)},V=(D,q)=>D?!u.some((G,X)=>X!==q&&G.cliente_id===D):!0,ge=D=>{var G;const q=u.filter((X,M)=>M!==D&&X.cliente_id).map(X=>String(X.cliente_id)),Z=String(((G=u[D])==null?void 0:G.cliente_id)||"");return f.filter(X=>{const M=String(X.id);return!q.includes(M)||M===Z}).map(X=>({value:String(X.id),label:`${X.codigo} - ${X.nombre_comercial}`}))},Ee=()=>{if(u.length<=1)return;const D=u.map(G=>{const X=f.find(M=>M.id===parseInt(G.cliente_id));return{...G,latitud:X==null?void 0:X.latitud,longitud:X==null?void 0:X.longitud,cliente:X}}),Z=De.optimizarParadas(D).map((G,X)=>({...G,orden:X+1}));x(Z),p(!1)},_e=()=>{const D=De.validarDatosRuta({...c,paradas:u}),q={};return D.forEach((Z,G)=>{q[`general_${G}`]=Z}),u.forEach((Z,G)=>{Z.cliente_id?V(Z.cliente_id,G)||(q[`parada_${G}_cliente`]="Este cliente ya está asignado a otra parada"):q[`parada_${G}_cliente`]="Debe seleccionar un cliente"}),i(q),Object.keys(q).length===0},$s=async D=>{if(D.preventDefault(),!!_e()){n(!0);try{const q={...c,paradas:u.map(({id:Z,cliente:G,...X})=>X),...w?{distancia_total:w.distanciaTotal,tiempo_estimado:w.tiempoEstimado,ruta_polyline:w.rutaPolyline,waypoints_optimizados:JSON.stringify(w.waypointsOptimizados),bounds_ne_lat:w.boundsNeLat,bounds_ne_lng:w.boundsNeLng,bounds_sw_lat:w.boundsSwLat,bounds_sw_lng:w.boundsSwLng,instrucciones_json:JSON.stringify(w.instruccionesJson)}:{}};console.log("Datos enviados al servidor:",q),console.log("RouteData recibido en CrearRuta:",w),r!=null&&r.id?await De.actualizar(r.id,q):await De.crear(q),a()}catch(q){console.error("Error guardando ruta:",q),alert("Error: "+q.message)}finally{n(!1)}}},Ra=()=>u.map(D=>{const q=f.find(Z=>Z.id===parseInt(D.cliente_id));return q&&q.latitud&&q.longitud?{id:D.id,orden:D.orden,nombre:q.nombre_comercial,lat:parseFloat(q.latitud),lng:parseFloat(q.longitud)}:null}).filter(Boolean);return e?s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl w-full max-w-[95vw] max-h-[95vh] overflow-hidden",children:[s.jsxs("div",{className:"bg-blue-600 text-white p-4 flex justify-between items-center",children:[s.jsx("h2",{className:"text-xl font-semibold",children:r?"Editar Ruta":"Nueva Ruta"}),s.jsx("button",{onClick:t,className:"text-white hover:text-gray-200 text-2xl",children:"×"})]}),s.jsxs("form",{onSubmit:$s,className:"overflow-hidden flex flex-col h-[calc(95vh-80px)]",children:[s.jsxs("div",{className:"flex-1 flex min-h-0",children:[s.jsxs("div",{className:"flex-1 flex flex-col border-r min-h-0",children:[s.jsxs("div",{className:"flex border-b bg-gray-50 flex-shrink-0",children:[s.jsx("button",{type:"button",onClick:()=>h("general"),className:`px-6 py-3 text-sm font-medium ${S==="general"?"border-b-2 border-blue-500 text-blue-600 bg-white":"text-gray-500 hover:text-gray-700"}`,children:"Información General"}),s.jsxs("button",{type:"button",onClick:()=>h("paradas"),className:`px-6 py-3 text-sm font-medium ${S==="paradas"?"border-b-2 border-blue-500 text-blue-600 bg-white":"text-gray-500 hover:text-gray-700"}`,children:["Paradas (",u.length,")"]}),s.jsx("button",{type:"button",onClick:()=>h("asignaciones"),className:`px-6 py-3 text-sm font-medium ${S==="asignaciones"?"border-b-2 border-blue-500 text-blue-600 bg-white":"text-gray-500 hover:text-gray-700"}`,children:"Asignaciones"})]}),s.jsxs("div",{className:"flex-1 min-h-0 p-6 overflow-y-auto",children:[S==="general"&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["Código ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsxs("div",{className:"flex",children:[s.jsx("input",{type:"text",name:"codigo",value:c.codigo,onChange:_,className:"flex-1 px-3 py-2 border border-gray-300 rounded-l-md focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0}),s.jsx("button",{type:"button",onClick:k,className:"px-3 py-2 bg-gray-100 border border-l-0 border-gray-300 rounded-r-md hover:bg-gray-200 text-sm",children:"Generar"})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["Fecha de Ruta ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"date",name:"fecha_ruta",value:c.fecha_ruta,onChange:_,min:new Date().toISOString().split("T")[0],className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0})]}),s.jsxs("div",{className:"md:col-span-2",children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["Nombre de la Ruta ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",name:"nombre",value:c.nombre,onChange:_,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Ej: Ruta Norte - Zona Industrial",required:!0})]}),s.jsxs("div",{className:"md:col-span-2",children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Descripción"}),s.jsx("textarea",{name:"descripcion",value:c.descripcion,onChange:_,rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Descripción opcional de la ruta..."})]}),s.jsxs("div",{className:"md:col-span-2",children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Notas"}),s.jsx("textarea",{name:"notas",value:c.notas,onChange:_,rows:2,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Notas adicionales sobre la ruta..."})]})]}),Object.keys(o).filter(D=>D.startsWith("general")).length>0&&s.jsx("div",{className:"bg-red-50 border border-red-200 rounded-md p-4",children:s.jsx("ul",{className:"text-red-700 text-sm space-y-1",children:Object.keys(o).filter(D=>D.startsWith("general")).map(D=>s.jsx("li",{children:o[D]},D))})})]}),S==="paradas"&&s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-4 flex-shrink-0",children:[s.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Paradas de la Ruta"}),s.jsxs("div",{className:"flex space-x-2",children:[u.length>1&&s.jsx("button",{type:"button",onClick:()=>p(!0),className:"px-3 py-2 text-sm bg-green-600 text-white rounded-md hover:bg-green-700",children:"Optimizar Ruta"}),s.jsx("button",{type:"button",onClick:Q,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700",children:"Agregar Parada"})]})]}),u.length===0?s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"text-center py-8 bg-gray-50 rounded-lg",children:[s.jsx("p",{className:"text-gray-500 mb-4",children:"No hay paradas agregadas"}),s.jsx("button",{type:"button",onClick:Q,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700",children:"Agregar Primera Parada"})]})}):s.jsx("div",{className:"flex-1 overflow-y-auto pr-2",children:s.jsx("div",{className:"space-y-2",children:u.map((D,q)=>{var Z;return s.jsx("div",{className:`bg-white border border-gray-200 rounded-md p-3 cursor-move transition-all ${y===q?"opacity-50 transform scale-105":"hover:shadow-md"}`,draggable:!0,onDragStart:G=>T(G,q),onDragEnd:$,onDragOver:I,onDrop:G=>Ge(G,q),children:s.jsxs("div",{className:"flex items-start space-x-3",children:[s.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[s.jsxs("span",{className:"bg-blue-100 text-blue-800 text-xs font-medium px-2 py-1 rounded-full whitespace-nowrap",children:["#",D.orden]}),s.jsx("div",{className:"text-gray-400",children:s.jsx("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:s.jsx("path",{d:"M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z"})})})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-5 gap-2",children:[s.jsxs("div",{className:"lg:col-span-3",children:[s.jsxs("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:["Cliente ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx(O2,{options:ge(q),value:String(D.cliente_id||""),onChange:G=>O(q,"cliente_id",G),placeholder:"Seleccionar cliente...",required:!0}),o[`parada_${q}_cliente`]&&s.jsx("p",{className:"text-red-500 text-xs mt-1",children:o[`parada_${q}_cliente`]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Frecuencia"}),s.jsxs("select",{value:D.frecuencia_dias||"",onChange:G=>O(q,"frecuencia_dias",G.target.value?parseInt(G.target.value):null),className:"w-full px-2 py-1.5 text-sm border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",children:[s.jsx("option",{value:"",children:"Única"}),s.jsx("option",{value:"1",children:"Diario"}),s.jsx("option",{value:"7",children:"Semanal"}),s.jsx("option",{value:"15",children:"Quincenal"}),s.jsx("option",{value:"30",children:"Mensual"}),s.jsx("option",{value:"60",children:"Bimestral"}),s.jsx("option",{value:"90",children:"Trimestral"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Inicio"}),s.jsx("input",{type:"date",value:D.fecha_inicio_frecuencia||"",onChange:G=>O(q,"fecha_inicio_frecuencia",G.target.value),className:"w-full px-2 py-1.5 text-sm border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",disabled:!D.frecuencia_dias})]})]}),D.frecuencia_dias&&D.fecha_inicio_frecuencia&&((Z=D.proximas_visitas)==null?void 0:Z.length)>0&&s.jsx("div",{className:"mt-2 p-2 bg-blue-50 border border-blue-200 rounded text-xs",children:s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx("span",{className:"font-medium text-blue-900",children:"Próximas:"}),D.proximas_visitas.slice(0,4).map((G,X)=>s.jsx("span",{className:"text-blue-800 bg-blue-100 px-1 rounded",children:G.split("-").slice(1).join("/")},X)),D.proximas_visitas.length>4&&s.jsxs("span",{className:"text-blue-700",children:["+",D.proximas_visitas.length-4]})]})})]}),s.jsx("button",{type:"button",onClick:()=>A(q),className:"text-red-500 hover:text-red-700 p-1",children:s.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:s.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})},D.id)})})}),d&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-10",children:s.jsxs("div",{className:"bg-white rounded-lg p-6 max-w-md w-full mx-4",children:[s.jsx("h3",{className:"text-lg font-medium mb-4",children:"Optimizar Ruta"}),s.jsx("p",{className:"text-gray-600 mb-6",children:"Esto reorganizará las paradas para minimizar la distancia total recorrida basándose en las coordenadas de los clientes."}),s.jsxs("div",{className:"flex justify-end space-x-3",children:[s.jsx("button",{type:"button",onClick:()=>p(!1),className:"px-4 py-2 text-gray-700 bg-gray-200 rounded-md hover:bg-gray-300",children:"Cancelar"}),s.jsx("button",{type:"button",onClick:Ee,className:"px-4 py-2 bg-green-600 text-white rounded-md hover:bg-green-700",children:"Optimizar"})]})]})})]}),S==="asignaciones"&&s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"grid grid-cols-1 gap-6",children:s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Repartidor"}),s.jsxs("select",{name:"repartidor_id",value:c.repartidor_id,onChange:_,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("option",{value:"",children:"Sin asignar"}),j.map(D=>s.jsxs("option",{value:D.id,children:[D.codigo," - ",D.nombre_completo]},D.id))]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Solo se muestran repartidores disponibles para la fecha seleccionada"})]})}),s.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:[s.jsx("h4",{className:"font-medium text-blue-900 mb-3",children:"Resumen de la Ruta"}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-blue-700 font-medium",children:"Total Paradas:"}),s.jsx("div",{className:"text-blue-900",children:u.length})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-blue-700 font-medium",children:"Tiempo Total:"}),s.jsx("div",{className:"text-blue-900",children:w?`${w.tiempoEstimado} min`:`${u.length*15} min (estimado)`})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-blue-700 font-medium",children:"Distancia:"}),s.jsx("div",{className:"text-blue-900",children:w?`${w.distanciaTotal} km`:"No calculada"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-blue-700 font-medium",children:"Fecha:"}),s.jsx("div",{className:"text-blue-900",children:c.fecha_ruta})]})]})]})]})]})]}),s.jsxs("div",{className:"w-1/2 bg-gray-50 flex flex-col min-h-0",children:[s.jsxs("div",{className:"bg-gray-100 px-4 py-3 border-b flex-shrink-0",children:[s.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Mapa de Ruta"}),s.jsx("p",{className:"text-sm text-gray-600",children:"Las paradas se mostrarán aquí dinámicamente"})]}),s.jsx("div",{className:"flex-1 min-h-0",children:s.jsx(A2,{paradas:Ra(),onRouteCalculated:D=>N(D),rutaExistente:r})})]})]}),s.jsxs("div",{className:"flex justify-between items-center p-6 bg-gray-50 border-t",children:[s.jsxs("div",{className:"text-sm text-gray-500",children:["Los campos marcados con ",s.jsx("span",{className:"text-red-500",children:"*"})," son obligatorios"]}),s.jsxs("div",{className:"flex space-x-3",children:[s.jsx("button",{type:"button",onClick:t,className:"px-6 py-2 border border-gray-300 text-gray-700 rounded-md hover:bg-gray-50",disabled:l,children:"Cancelar"}),s.jsx("button",{type:"submit",className:"px-6 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:opacity-50",disabled:l,children:l?"Guardando...":r?"Actualizar":"Crear Ruta"})]})]})]})]})}):null},U2=()=>{const[e,t]=g.useState([]),[a,r]=g.useState(!1),[l,n]=g.useState({search:"",fecha_inicio:"",fecha_fin:""}),[o,i]=g.useState(!1),[c,m]=g.useState(null);g.useEffect(()=>{u()},[l]);const u=async()=>{r(!0);try{const d=await De.obtenerTodos(l);t(d)}catch(d){console.error("Error cargando rutas:",d),alert("Error cargando rutas: "+d.message)}finally{r(!1)}},x=d=>{const{name:p,value:y}=d.target;n(E=>({...E,[p]:y}))},f=()=>{n({search:"",fecha_inicio:"",fecha_fin:""})},b=async(d=null)=>{if(d)try{r(!0);const p=await De.obtenerPorId(d.id);m(p),i(!0)}catch(p){console.error("Error cargando datos de la ruta:",p),alert("Error cargando datos de la ruta: "+p.message)}finally{r(!1)}else m(null),i(!0)},j=()=>{i(!1),m(null)},v=()=>{u(),j()},S=async d=>{if(window.confirm("¿Está seguro de eliminar esta ruta?"))try{await De.eliminar(d),await u()}catch(p){console.error("Error eliminando ruta:",p),alert("Error eliminando ruta: "+p.message)}},h=()=>{const d=[["Código","Nombre","Fecha","Estado","Repartidor","Paradas"],...e.map(E=>[E.codigo,E.nombre,De.formatFecha(E.fecha_ruta),De.getEstadoTexto(E.estado),E.repartidor_nombre||"Sin asignar",E.total_paradas||0])].map(E=>E.join(",")).join(`
`),p=new Blob([d],{type:"text/csv;charset=utf-8;"}),y=document.createElement("a");y.href=URL.createObjectURL(p),y.download=`rutas_${new Date().toISOString().split("T")[0]}.csv`,y.click()};return s.jsx(Nt,{children:s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"Configurador de Rutas"}),s.jsx("p",{className:"text-gray-600",children:"Crea, edita y planifica las rutas de reparto"})]}),s.jsxs("div",{className:"flex space-x-3",children:[s.jsxs("button",{onClick:h,className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center",children:[s.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),"Exportar"]}),s.jsxs("button",{onClick:()=>b(),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center",children:[s.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Nueva Ruta"]})]})]}),s.jsx("div",{className:"bg-white rounded-lg shadow",children:s.jsxs("div",{className:"p-6",children:[s.jsxs("div",{className:"mb-6 grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Buscar"}),s.jsx("input",{type:"text",name:"search",value:l.search,onChange:x,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Nombre, código..."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Fecha Desde"}),s.jsx("input",{type:"date",name:"fecha_inicio",value:l.fecha_inicio,onChange:x,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Fecha Hasta"}),s.jsx("input",{type:"date",name:"fecha_fin",value:l.fecha_fin,onChange:x,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]})]}),s.jsx("div",{className:"flex justify-end mb-4",children:s.jsx("button",{onClick:f,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-md hover:bg-gray-300",children:"Limpiar Filtros"})}),a?s.jsxs("div",{className:"text-center py-8",children:[s.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto"}),s.jsx("p",{className:"mt-4 text-gray-500",children:"Cargando rutas..."})]}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[s.jsx("thead",{className:"bg-gray-50",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Ruta"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Fecha"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Estado"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Asignaciones"}),s.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Acciones"})]})}),s.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:e.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:"5",className:"px-6 py-4 text-center text-gray-500",children:"No se encontraron rutas"})}):e.map(d=>s.jsxs("tr",{className:"hover:bg-gray-50",children:[s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-gray-900",children:d.nombre}),s.jsx("div",{className:"text-sm text-gray-500",children:d.codigo}),d.descripcion&&s.jsx("div",{className:"text-xs text-gray-400 truncate max-w-xs",children:d.descripcion})]})}),s.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[s.jsx("div",{className:"text-sm text-gray-900",children:De.formatFecha(d.fecha_ruta)}),(d.hora_inicio||d.hora_fin)&&s.jsxs("div",{className:"text-xs text-gray-500",children:[d.hora_inicio&&De.formatHora(d.hora_inicio),d.hora_inicio&&d.hora_fin&&" - ",d.hora_fin&&De.formatHora(d.hora_fin)]})]}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${De.getEstadoColor(d.estado)}`,children:De.getEstadoTexto(d.estado)})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsx("div",{className:"text-sm text-gray-900",children:d.repartidor_nombre?s.jsxs("div",{className:"flex items-center",children:[s.jsx("svg",{className:"w-4 h-4 text-blue-500 mr-1",fill:"currentColor",viewBox:"0 0 20 20",children:s.jsx("path",{fillRule:"evenodd",d:"M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z",clipRule:"evenodd"})}),s.jsx("span",{className:"truncate max-w-xs",children:d.repartidor_nombre})]}):s.jsx("span",{className:"text-gray-400 text-sm",children:"Sin repartidor"})})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:s.jsxs("div",{className:"flex justify-end space-x-2",children:[s.jsx("button",{onClick:()=>b(d),className:"text-indigo-600 hover:text-indigo-900",title:"Editar",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),d.estado!=="completada"&&s.jsx("button",{onClick:()=>S(d.id),className:"text-red-600 hover:text-red-900",title:"Eliminar",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})})]},d.id))})]})})]})}),s.jsx(D2,{isOpen:o,onClose:j,onSave:v,ruta:c})]})})};function H2(){return s.jsx(Gp,{children:s.jsx(kp,{children:s.jsx("div",{className:"App",children:s.jsxs(rp,{children:[s.jsx(Qe,{path:"/login",element:s.jsx(Qp,{})}),s.jsx(Qe,{path:"/",element:s.jsx(ct,{children:s.jsx(mi,{to:"/dashboard",replace:!0})})}),s.jsx(Qe,{path:"/dashboard",element:s.jsx(ct,{children:s.jsx(Xp,{})})}),s.jsx(Qe,{path:"/usuarios",element:s.jsx(ct,{module:"usuarios",permission:"leer",children:s.jsx(Kp,{})})}),s.jsx(Qe,{path:"/configuracion",element:s.jsx(ct,{module:"configuracion",permission:"leer",children:s.jsx(eu,{})})}),s.jsx(Qe,{path:"/roles",element:s.jsx(ct,{module:"configuracion",permission:"leer",children:s.jsx(eu,{})})}),s.jsx(Qe,{path:"/productos",element:s.jsx(ct,{module:"productos",permission:"leer",children:s.jsx(r2,{})})}),s.jsx(Qe,{path:"/motivos-stock",element:s.jsx(ct,{module:"productos",permission:"leer",children:s.jsx(n2,{})})}),s.jsx(Qe,{path:"/stocks",element:s.jsx(ct,{module:"productos",permission:"leer",children:s.jsx(u2,{})})}),s.jsx(Qe,{path:"/clientes",element:s.jsx(ct,{module:"clientes",permission:"leer",children:s.jsx(y2,{})})}),s.jsx(Qe,{path:"/codigos-qr",element:s.jsx(ct,{module:"clientes",permission:"leer",children:s.jsx(w2,{})})}),s.jsx(Qe,{path:"/repartidores",element:s.jsx(ct,{module:"repartidores",permission:"leer",children:s.jsx(C2,{})})}),s.jsx(Qe,{path:"/rutas",element:s.jsx(ct,{module:"rutas",permission:"leer",children:s.jsx(U2,{})})}),s.jsx(Qe,{path:"*",element:s.jsx(mi,{to:"/dashboard",replace:!0})})]})})})})}hg.createRoot(document.getElementById("root")).render(s.jsx(g.StrictMode,{children:s.jsx(H2,{})}));
