3019 lines
3.4 MiB
3019 lines
3.4 MiB
var bW=Object.defineProperty,vW=Object.defineProperties;var wW=Object.getOwnPropertyDescriptors;var sb=Object.getOwnPropertySymbols;var jT=Object.prototype.hasOwnProperty,_T=Object.prototype.propertyIsEnumerable;var Eh=(e,r)=>(r=Symbol[e])?r:Symbol.for("Symbol."+e),jW=e=>{throw TypeError(e)},O0=Math.pow,z_=(e,r,a)=>r in e?bW(e,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[r]=a,se=(e,r)=>{for(var a in r||(r={}))jT.call(r,a)&&z_(e,a,r[a]);if(sb)for(var a of sb(r))_T.call(r,a)&&z_(e,a,r[a]);return e},je=(e,r)=>vW(e,wW(r));var li=(e,r)=>{var a={};for(var s in e)jT.call(e,s)&&r.indexOf(s)<0&&(a[s]=e[s]);if(e!=null&&sb)for(var s of sb(e))r.indexOf(s)<0&&_T.call(e,s)&&(a[s]=e[s]);return a};var _W=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var $s=(e,r,a)=>z_(e,typeof r!="symbol"?r+"":r,a);var J=(e,r,a)=>new Promise((s,n)=>{var i=c=>{try{l(a.next(c))}catch(u){n(u)}},o=c=>{try{l(a.throw(c))}catch(u){n(u)}},l=c=>c.done?s(c.value):Promise.resolve(c.value).then(i,o);l((a=a.apply(e,r)).next())}),P0=function(e,r){this[0]=e,this[1]=r},$_=(e,r,a)=>{var s=(o,l,c,u)=>{try{var h=a[o](l),f=(l=h.value)instanceof P0,y=h.done;Promise.resolve(f?l[0]:l).then(b=>f?s(o==="return"?o:"next",l[1]?{done:b.done,value:b.value}:b,c,u):c({value:b,done:y})).catch(b=>s("throw",b,c,u))}catch(b){u(b)}},n=o=>i[o]=l=>new Promise((c,u)=>s(o,l,c,u)),i={};return a=a.apply(e,r),i[Eh("asyncIterator")]=()=>i,n("next"),n("throw"),n("return"),i},U_=e=>{var r=e[Eh("asyncIterator")],a=!1,s,n={};return r==null?(r=e[Eh("iterator")](),s=i=>n[i]=o=>r[i](o)):(r=r.call(e),s=i=>n[i]=o=>{if(a){if(a=!1,i==="throw")throw o;return o}return a=!0,{done:!1,value:new P0(new Promise(l=>{var c=r[i](o);c instanceof Object||jW("Object expected"),l(c)}),1)}}),n[Eh("iterator")]=()=>n,s("next"),"throw"in r?s("throw"):n.throw=i=>{throw i},"return"in r&&s("return"),n},kT=(e,r,a)=>(r=e[Eh("asyncIterator")])?r.call(e):(e=e[Eh("iterator")](),r={},a=(s,n)=>(n=e[s])&&(r[s]=i=>new Promise((o,l,c)=>(i=n.call(e,i),c=i.done,Promise.resolve(i.value).then(u=>o({value:u,done:c}),l)))),a("next"),a("return"),r);var KSe=_W(Le=>{function kW(e,r){for(var a=0;a<r.length;a++){const s=r[a];if(typeof s!="string"&&!Array.isArray(s)){for(const n in s)if(n!=="default"&&!(n in e)){const i=Object.getOwnPropertyDescriptor(s,n);i&&Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:()=>s[n]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))s(n);new MutationObserver(n=>{for(const i of n)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function a(n){const i={};return n.integrity&&(i.integrity=n.integrity),n.referrerPolicy&&(i.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?i.credentials="include":n.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(n){if(n.ep)return;n.ep=!0;const i=a(n);fetch(n.href,i)}})();function tu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var B_={exports:{}},Vg={};var NT;function NW(){if(NT)return Vg;NT=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function a(s,n,i){var o=null;if(i!==void 0&&(o=""+i),n.key!==void 0&&(o=""+n.key),"key"in n){i={};for(var l in n)l!=="key"&&(i[l]=n[l])}else i=n;return n=i.ref,{$$typeof:e,type:s,key:o,ref:n!==void 0?n:null,props:i}}return Vg.Fragment=r,Vg.jsx=a,Vg.jsxs=a,Vg}var ST;function SW(){return ST||(ST=1,B_.exports=NW()),B_.exports}var t=SW(),W_={exports:{}},Wr={};var CT;function CW(){if(CT)return Wr;CT=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),n=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),y=Symbol.iterator;function b(V){return V===null||typeof V!="object"?null:(V=y&&V[y]||V["@@iterator"],typeof V=="function"?V:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,k={};function S(V,I,B){this.props=V,this.context=I,this.refs=k,this.updater=B||w}S.prototype.isReactComponent={},S.prototype.setState=function(V,I){if(typeof V!="object"&&typeof V!="function"&&V!=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,V,I,"setState")},S.prototype.forceUpdate=function(V){this.updater.enqueueForceUpdate(this,V,"forceUpdate")};function N(){}N.prototype=S.prototype;function C(V,I,B){this.props=V,this.context=I,this.refs=k,this.updater=B||w}var O=C.prototype=new N;O.constructor=C,v(O,S.prototype),O.isPureReactComponent=!0;var T=Array.isArray;function P(){}var E={H:null,A:null,T:null,S:null},R=Object.prototype.hasOwnProperty;function z(V,I,B){var Q=B.ref;return{$$typeof:e,type:V,key:I,ref:Q!==void 0?Q:null,props:B}}function G(V,I){return z(V.type,I,V.props)}function ae(V){return typeof V=="object"&&V!==null&&V.$$typeof===e}function ee(V){var I={"=":"=0",":":"=2"};return"$"+V.replace(/[=:]/g,function(B){return I[B]})}var ne=/\/+/g;function te(V,I){return typeof V=="object"&&V!==null&&V.key!=null?ee(""+V.key):I.toString(36)}function Y(V){switch(V.status){case"fulfilled":return V.value;case"rejected":throw V.reason;default:switch(typeof V.status=="string"?V.then(P,P):(V.status="pending",V.then(function(I){V.status==="pending"&&(V.status="fulfilled",V.value=I)},function(I){V.status==="pending"&&(V.status="rejected",V.reason=I)})),V.status){case"fulfilled":return V.value;case"rejected":throw V.reason}}throw V}function q(V,I,B,Q,ie){var me=typeof V;(me==="undefined"||me==="boolean")&&(V=null);var he=!1;if(V===null)he=!0;else switch(me){case"bigint":case"string":case"number":he=!0;break;case"object":switch(V.$$typeof){case e:case r:he=!0;break;case h:return he=V._init,q(he(V._payload),I,B,Q,ie)}}if(he)return ie=ie(V),he=Q===""?"."+te(V,0):Q,T(ie)?(B="",he!=null&&(B=he.replace(ne,"$&/")+"/"),q(ie,I,B,"",function(ge){return ge})):ie!=null&&(ae(ie)&&(ie=G(ie,B+(ie.key==null||V&&V.key===ie.key?"":(""+ie.key).replace(ne,"$&/")+"/")+he)),I.push(ie)),1;he=0;var de=Q===""?".":Q+":";if(T(V))for(var xe=0;xe<V.length;xe++)Q=V[xe],me=de+te(Q,xe),he+=q(Q,I,B,me,ie);else if(xe=b(V),typeof xe=="function")for(V=xe.call(V),xe=0;!(Q=V.next()).done;)Q=Q.value,me=de+te(Q,xe++),he+=q(Q,I,B,me,ie);else if(me==="object"){if(typeof V.then=="function")return q(Y(V),I,B,Q,ie);throw I=String(V),Error("Objects are not valid as a React child (found: "+(I==="[object Object]"?"object with keys {"+Object.keys(V).join(", ")+"}":I)+"). If you meant to render a collection of children, use an array instead.")}return he}function H(V,I,B){if(V==null)return V;var Q=[],ie=0;return q(V,Q,"","",function(me){return I.call(B,me,ie++)}),Q}function U(V){if(V._status===-1){var I=V._result;I=I(),I.then(function(B){(V._status===0||V._status===-1)&&(V._status=1,V._result=B)},function(B){(V._status===0||V._status===-1)&&(V._status=2,V._result=B)}),V._status===-1&&(V._status=0,V._result=I)}if(V._status===1)return V._result.default;throw V._result}var re=typeof reportError=="function"?reportError:function(V){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var I=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof V=="object"&&V!==null&&typeof V.message=="string"?String(V.message):String(V),error:V});if(!window.dispatchEvent(I))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",V);return}console.error(V)},X={map:H,forEach:function(V,I,B){H(V,function(){I.apply(this,arguments)},B)},count:function(V){var I=0;return H(V,function(){I++}),I},toArray:function(V){return H(V,function(I){return I})||[]},only:function(V){if(!ae(V))throw Error("React.Children.only expected to receive a single React element child.");return V}};return Wr.Activity=f,Wr.Children=X,Wr.Component=S,Wr.Fragment=a,Wr.Profiler=n,Wr.PureComponent=C,Wr.StrictMode=s,Wr.Suspense=c,Wr.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=E,Wr.__COMPILER_RUNTIME={__proto__:null,c:function(V){return E.H.useMemoCache(V)}},Wr.cache=function(V){return function(){return V.apply(null,arguments)}},Wr.cacheSignal=function(){return null},Wr.cloneElement=function(V,I,B){if(V==null)throw Error("The argument must be a React element, but you passed "+V+".");var Q=v({},V.props),ie=V.key;if(I!=null)for(me in I.key!==void 0&&(ie=""+I.key),I)!R.call(I,me)||me==="key"||me==="__self"||me==="__source"||me==="ref"&&I.ref===void 0||(Q[me]=I[me]);var me=arguments.length-2;if(me===1)Q.children=B;else if(1<me){for(var he=Array(me),de=0;de<me;de++)he[de]=arguments[de+2];Q.children=he}return z(V.type,ie,Q)},Wr.createContext=function(V){return V={$$typeof:o,_currentValue:V,_currentValue2:V,_threadCount:0,Provider:null,Consumer:null},V.Provider=V,V.Consumer={$$typeof:i,_context:V},V},Wr.createElement=function(V,I,B){var Q,ie={},me=null;if(I!=null)for(Q in I.key!==void 0&&(me=""+I.key),I)R.call(I,Q)&&Q!=="key"&&Q!=="__self"&&Q!=="__source"&&(ie[Q]=I[Q]);var he=arguments.length-2;if(he===1)ie.children=B;else if(1<he){for(var de=Array(he),xe=0;xe<he;xe++)de[xe]=arguments[xe+2];ie.children=de}if(V&&V.defaultProps)for(Q in he=V.defaultProps,he)ie[Q]===void 0&&(ie[Q]=he[Q]);return z(V,me,ie)},Wr.createRef=function(){return{current:null}},Wr.forwardRef=function(V){return{$$typeof:l,render:V}},Wr.isValidElement=ae,Wr.lazy=function(V){return{$$typeof:h,_payload:{_status:-1,_result:V},_init:U}},Wr.memo=function(V,I){return{$$typeof:u,type:V,compare:I===void 0?null:I}},Wr.startTransition=function(V){var I=E.T,B={};E.T=B;try{var Q=V(),ie=E.S;ie!==null&&ie(B,Q),typeof Q=="object"&&Q!==null&&typeof Q.then=="function"&&Q.then(P,re)}catch(me){re(me)}finally{I!==null&&B.types!==null&&(I.types=B.types),E.T=I}},Wr.unstable_useCacheRefresh=function(){return E.H.useCacheRefresh()},Wr.use=function(V){return E.H.use(V)},Wr.useActionState=function(V,I,B){return E.H.useActionState(V,I,B)},Wr.useCallback=function(V,I){return E.H.useCallback(V,I)},Wr.useContext=function(V){return E.H.useContext(V)},Wr.useDebugValue=function(){},Wr.useDeferredValue=function(V,I){return E.H.useDeferredValue(V,I)},Wr.useEffect=function(V,I){return E.H.useEffect(V,I)},Wr.useEffectEvent=function(V){return E.H.useEffectEvent(V)},Wr.useId=function(){return E.H.useId()},Wr.useImperativeHandle=function(V,I,B){return E.H.useImperativeHandle(V,I,B)},Wr.useInsertionEffect=function(V,I){return E.H.useInsertionEffect(V,I)},Wr.useLayoutEffect=function(V,I){return E.H.useLayoutEffect(V,I)},Wr.useMemo=function(V,I){return E.H.useMemo(V,I)},Wr.useOptimistic=function(V,I){return E.H.useOptimistic(V,I)},Wr.useReducer=function(V,I,B){return E.H.useReducer(V,I,B)},Wr.useRef=function(V){return E.H.useRef(V)},Wr.useState=function(V){return E.H.useState(V)},Wr.useSyncExternalStore=function(V,I,B){return E.H.useSyncExternalStore(V,I,B)},Wr.useTransition=function(){return E.H.useTransition()},Wr.version="19.2.1",Wr}var TT;function Ip(){return TT||(TT=1,W_.exports=CW()),W_.exports}var p=Ip();const gr=tu(p),TW=kW({__proto__:null,default:gr},[p]);var H_={exports:{}},Gg={},q_={exports:{}},V_={};var ET;function EW(){return ET||(ET=1,(function(e){function r(q,H){var U=q.length;q.push(H);e:for(;0<U;){var re=U-1>>>1,X=q[re];if(0<n(X,H))q[re]=H,q[U]=X,U=re;else break e}}function a(q){return q.length===0?null:q[0]}function s(q){if(q.length===0)return null;var H=q[0],U=q.pop();if(U!==H){q[0]=U;e:for(var re=0,X=q.length,V=X>>>1;re<V;){var I=2*(re+1)-1,B=q[I],Q=I+1,ie=q[Q];if(0>n(B,U))Q<X&&0>n(ie,B)?(q[re]=ie,q[Q]=U,re=Q):(q[re]=B,q[I]=U,re=I);else if(Q<X&&0>n(ie,U))q[re]=ie,q[Q]=U,re=Q;else break e}}return H}function n(q,H){var U=q.sortIndex-H.sortIndex;return U!==0?U:q.id-H.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var o=Date,l=o.now();e.unstable_now=function(){return o.now()-l}}var c=[],u=[],h=1,f=null,y=3,b=!1,w=!1,v=!1,k=!1,S=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate!="undefined"?setImmediate:null;function O(q){for(var H=a(u);H!==null;){if(H.callback===null)s(u);else if(H.startTime<=q)s(u),H.sortIndex=H.expirationTime,r(c,H);else break;H=a(u)}}function T(q){if(v=!1,O(q),!w)if(a(c)!==null)w=!0,P||(P=!0,ee());else{var H=a(u);H!==null&&Y(T,H.startTime-q)}}var P=!1,E=-1,R=5,z=-1;function G(){return k?!0:!(e.unstable_now()-z<R)}function ae(){if(k=!1,P){var q=e.unstable_now();z=q;var H=!0;try{e:{w=!1,v&&(v=!1,N(E),E=-1),b=!0;var U=y;try{t:{for(O(q),f=a(c);f!==null&&!(f.expirationTime>q&&G());){var re=f.callback;if(typeof re=="function"){f.callback=null,y=f.priorityLevel;var X=re(f.expirationTime<=q);if(q=e.unstable_now(),typeof X=="function"){f.callback=X,O(q),H=!0;break t}f===a(c)&&s(c),O(q)}else s(c);f=a(c)}if(f!==null)H=!0;else{var V=a(u);V!==null&&Y(T,V.startTime-q),H=!1}}break e}finally{f=null,y=U,b=!1}H=void 0}}finally{H?ee():P=!1}}}var ee;if(typeof C=="function")ee=function(){C(ae)};else if(typeof MessageChannel!="undefined"){var ne=new MessageChannel,te=ne.port2;ne.port1.onmessage=ae,ee=function(){te.postMessage(null)}}else ee=function(){S(ae,0)};function Y(q,H){E=S(function(){q(e.unstable_now())},H)}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(q){q.callback=null},e.unstable_forceFrameRate=function(q){0>q||125<q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<q?Math.floor(1e3/q):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_next=function(q){switch(y){case 1:case 2:case 3:var H=3;break;default:H=y}var U=y;y=H;try{return q()}finally{y=U}},e.unstable_requestPaint=function(){k=!0},e.unstable_runWithPriority=function(q,H){switch(q){case 1:case 2:case 3:case 4:case 5:break;default:q=3}var U=y;y=q;try{return H()}finally{y=U}},e.unstable_scheduleCallback=function(q,H,U){var re=e.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?re+U:re):U=re,q){case 1:var X=-1;break;case 2:X=250;break;case 5:X=1073741823;break;case 4:X=1e4;break;default:X=5e3}return X=U+X,q={id:h++,callback:H,priorityLevel:q,startTime:U,expirationTime:X,sortIndex:-1},U>re?(q.sortIndex=U,r(u,q),a(c)===null&&q===a(u)&&(v?(N(E),E=-1):v=!0,Y(T,U-re))):(q.sortIndex=X,r(c,q),w||b||(w=!0,P||(P=!0,ee()))),q},e.unstable_shouldYield=G,e.unstable_wrapCallback=function(q){var H=y;return function(){var U=y;y=H;try{return q.apply(this,arguments)}finally{y=U}}}})(V_)),V_}var AT;function AW(){return AT||(AT=1,q_.exports=EW()),q_.exports}var G_={exports:{}},ci={};var OT;function OW(){if(OT)return ci;OT=1;var e=Ip();function r(c){var u="https://react.dev/errors/"+c;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var h=2;h<arguments.length;h++)u+="&args[]="+encodeURIComponent(arguments[h])}return"Minified React error #"+c+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(){}var s={d:{f:a,r:function(){throw Error(r(522))},D:a,C:a,L:a,m:a,X:a,S:a,M:a},p:0,findDOMNode:null},n=Symbol.for("react.portal");function i(c,u,h){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:n,key:f==null?null:""+f,children:c,containerInfo:u,implementation:h}}var o=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(c,u){if(c==="font")return"";if(typeof u=="string")return u==="use-credentials"?u:""}return ci.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,ci.createPortal=function(c,u){var h=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)throw Error(r(299));return i(c,u,null,h)},ci.flushSync=function(c){var u=o.T,h=s.p;try{if(o.T=null,s.p=2,c)return c()}finally{o.T=u,s.p=h,s.d.f()}},ci.preconnect=function(c,u){typeof c=="string"&&(u?(u=u.crossOrigin,u=typeof u=="string"?u==="use-credentials"?u:"":void 0):u=null,s.d.C(c,u))},ci.prefetchDNS=function(c){typeof c=="string"&&s.d.D(c)},ci.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var h=u.as,f=l(h,u.crossOrigin),y=typeof u.integrity=="string"?u.integrity:void 0,b=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;h==="style"?s.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:f,integrity:y,fetchPriority:b}):h==="script"&&s.d.X(c,{crossOrigin:f,integrity:y,fetchPriority:b,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},ci.preinitModule=function(c,u){if(typeof c=="string")if(typeof u=="object"&&u!==null){if(u.as==null||u.as==="script"){var h=l(u.as,u.crossOrigin);s.d.M(c,{crossOrigin:h,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0})}}else u==null&&s.d.M(c)},ci.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var h=u.as,f=l(h,u.crossOrigin);s.d.L(c,h,{crossOrigin:f,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0,type:typeof u.type=="string"?u.type:void 0,fetchPriority:typeof u.fetchPriority=="string"?u.fetchPriority:void 0,referrerPolicy:typeof u.referrerPolicy=="string"?u.referrerPolicy:void 0,imageSrcSet:typeof u.imageSrcSet=="string"?u.imageSrcSet:void 0,imageSizes:typeof u.imageSizes=="string"?u.imageSizes:void 0,media:typeof u.media=="string"?u.media:void 0})}},ci.preloadModule=function(c,u){if(typeof c=="string")if(u){var h=l(u.as,u.crossOrigin);s.d.m(c,{as:typeof u.as=="string"&&u.as!=="script"?u.as:void 0,crossOrigin:h,integrity:typeof u.integrity=="string"?u.integrity:void 0})}else s.d.m(c)},ci.requestFormReset=function(c){s.d.r(c)},ci.unstable_batchedUpdates=function(c,u){return c(u)},ci.useFormState=function(c,u,h){return o.H.useFormState(c,u,h)},ci.useFormStatus=function(){return o.H.useHostTransitionStatus()},ci.version="19.2.1",ci}var PT;function u9(){if(PT)return G_.exports;PT=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__=="undefined"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(r){console.error(r)}}return e(),G_.exports=OW(),G_.exports}var DT;function PW(){if(DT)return Gg;DT=1;var e=AW(),r=Ip(),a=u9();function s(d){var m="https://react.dev/errors/"+d;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var x=2;x<arguments.length;x++)m+="&args[]="+encodeURIComponent(arguments[x])}return"Minified React error #"+d+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(d){return!(!d||d.nodeType!==1&&d.nodeType!==9&&d.nodeType!==11)}function i(d){var m=d,x=d;if(d.alternate)for(;m.return;)m=m.return;else{d=m;do m=d,(m.flags&4098)!==0&&(x=m.return),d=m.return;while(d)}return m.tag===3?x:null}function o(d){if(d.tag===13){var m=d.memoizedState;if(m===null&&(d=d.alternate,d!==null&&(m=d.memoizedState)),m!==null)return m.dehydrated}return null}function l(d){if(d.tag===31){var m=d.memoizedState;if(m===null&&(d=d.alternate,d!==null&&(m=d.memoizedState)),m!==null)return m.dehydrated}return null}function c(d){if(i(d)!==d)throw Error(s(188))}function u(d){var m=d.alternate;if(!m){if(m=i(d),m===null)throw Error(s(188));return m!==d?null:d}for(var x=d,_=m;;){var D=x.return;if(D===null)break;var F=D.alternate;if(F===null){if(_=D.return,_!==null){x=_;continue}break}if(D.child===F.child){for(F=D.child;F;){if(F===x)return c(D),d;if(F===_)return c(D),m;F=F.sibling}throw Error(s(188))}if(x.return!==_.return)x=D,_=F;else{for(var ue=!1,Ee=D.child;Ee;){if(Ee===x){ue=!0,x=D,_=F;break}if(Ee===_){ue=!0,_=D,x=F;break}Ee=Ee.sibling}if(!ue){for(Ee=F.child;Ee;){if(Ee===x){ue=!0,x=F,_=D;break}if(Ee===_){ue=!0,_=F,x=D;break}Ee=Ee.sibling}if(!ue)throw Error(s(189))}}if(x.alternate!==_)throw Error(s(190))}if(x.tag!==3)throw Error(s(188));return x.stateNode.current===x?d:m}function h(d){var m=d.tag;if(m===5||m===26||m===27||m===6)return d;for(d=d.child;d!==null;){if(m=h(d),m!==null)return m;d=d.sibling}return null}var f=Object.assign,y=Symbol.for("react.element"),b=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),C=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),z=Symbol.for("react.activity"),G=Symbol.for("react.memo_cache_sentinel"),ae=Symbol.iterator;function ee(d){return d===null||typeof d!="object"?null:(d=ae&&d[ae]||d["@@iterator"],typeof d=="function"?d:null)}var ne=Symbol.for("react.client.reference");function te(d){if(d==null)return null;if(typeof d=="function")return d.$$typeof===ne?null:d.displayName||d.name||null;if(typeof d=="string")return d;switch(d){case v:return"Fragment";case S:return"Profiler";case k:return"StrictMode";case T:return"Suspense";case P:return"SuspenseList";case z:return"Activity"}if(typeof d=="object")switch(d.$$typeof){case w:return"Portal";case C:return d.displayName||"Context";case N:return(d._context.displayName||"Context")+".Consumer";case O:var m=d.render;return d=d.displayName,d||(d=m.displayName||m.name||"",d=d!==""?"ForwardRef("+d+")":"ForwardRef"),d;case E:return m=d.displayName||null,m!==null?m:te(d.type)||"Memo";case R:m=d._payload,d=d._init;try{return te(d(m))}catch(x){}}return null}var Y=Array.isArray,q=r.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U={pending:!1,data:null,method:null,action:null},re=[],X=-1;function V(d){return{current:d}}function I(d){0>X||(d.current=re[X],re[X]=null,X--)}function B(d,m){X++,re[X]=d.current,d.current=m}var Q=V(null),ie=V(null),me=V(null),he=V(null);function de(d,m){switch(B(me,m),B(ie,d),B(Q,null),m.nodeType){case 9:case 11:d=(d=m.documentElement)&&(d=d.namespaceURI)?q6(d):0;break;default:if(d=m.tagName,m=m.namespaceURI)m=q6(m),d=V6(m,d);else switch(d){case"svg":d=1;break;case"math":d=2;break;default:d=0}}I(Q),B(Q,d)}function xe(){I(Q),I(ie),I(me)}function ge(d){d.memoizedState!==null&&B(he,d);var m=Q.current,x=V6(m,d.type);m!==x&&(B(ie,d),B(Q,x))}function be(d){ie.current===d&&(I(Q),I(ie)),he.current===d&&(I(he),Bg._currentValue=U)}var K,ye;function Z(d){if(K===void 0)try{throw Error()}catch(x){var m=x.stack.trim().match(/\n( *(at )?)/);K=m&&m[1]||"",ye=-1<x.stack.indexOf(`
|
||
at`)?" (<anonymous>)":-1<x.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||
`+K+d+ye}var M=!1;function we(d,m){if(!d||M)return"";M=!0;var x=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var _={DetermineComponentFrameRoot:function(){try{if(m){var Vt=function(){throw Error()};if(Object.defineProperty(Vt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Vt,[])}catch(Rt){var St=Rt}Reflect.construct(d,[],Vt)}else{try{Vt.call()}catch(Rt){St=Rt}d.call(Vt.prototype)}}else{try{throw Error()}catch(Rt){St=Rt}(Vt=d())&&typeof Vt.catch=="function"&&Vt.catch(function(){})}}catch(Rt){if(Rt&&St&&typeof Rt.stack=="string")return[Rt.stack,St.stack]}return[null,null]}};_.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var D=Object.getOwnPropertyDescriptor(_.DetermineComponentFrameRoot,"name");D&&D.configurable&&Object.defineProperty(_.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var F=_.DetermineComponentFrameRoot(),ue=F[0],Ee=F[1];if(ue&&Ee){var Ze=ue.split(`
|
||
`),_t=Ee.split(`
|
||
`);for(D=_=0;_<Ze.length&&!Ze[_].includes("DetermineComponentFrameRoot");)_++;for(;D<_t.length&&!_t[D].includes("DetermineComponentFrameRoot");)D++;if(_===Ze.length||D===_t.length)for(_=Ze.length-1,D=_t.length-1;1<=_&&0<=D&&Ze[_]!==_t[D];)D--;for(;1<=_&&0<=D;_--,D--)if(Ze[_]!==_t[D]){if(_!==1||D!==1)do if(_--,D--,0>D||Ze[_]!==_t[D]){var It=`
|
||
`+Ze[_].replace(" at new "," at ");return d.displayName&&It.includes("<anonymous>")&&(It=It.replace("<anonymous>",d.displayName)),It}while(1<=_&&0<=D);break}}}finally{M=!1,Error.prepareStackTrace=x}return(x=d?d.displayName||d.name:"")?Z(x):""}function pe(d,m){switch(d.tag){case 26:case 27:case 5:return Z(d.type);case 16:return Z("Lazy");case 13:return d.child!==m&&m!==null?Z("Suspense Fallback"):Z("Suspense");case 19:return Z("SuspenseList");case 0:case 15:return we(d.type,!1);case 11:return we(d.type.render,!1);case 1:return we(d.type,!0);case 31:return Z("Activity");default:return""}}function le(d){try{var m="",x=null;do m+=pe(d,x),x=d,d=d.return;while(d);return m}catch(_){return`
|
||
Error generating stack: `+_.message+`
|
||
`+_.stack}}var Fe=Object.prototype.hasOwnProperty,ze=e.unstable_scheduleCallback,Re=e.unstable_cancelCallback,De=e.unstable_shouldYield,Et=e.unstable_requestPaint,jt=e.unstable_now,Ie=e.unstable_getCurrentPriorityLevel,$e=e.unstable_ImmediatePriority,Qe=e.unstable_UserBlockingPriority,at=e.unstable_NormalPriority,Ct=e.unstable_LowPriority,vt=e.unstable_IdlePriority,er=e.log,nr=e.unstable_setDisableYieldValue,dt=null,He=null;function it(d){if(typeof er=="function"&&nr(d),He&&typeof He.setStrictMode=="function")try{He.setStrictMode(dt,d)}catch(m){}}var Ue=Math.clz32?Math.clz32:st,Ve=Math.log,lt=Math.LN2;function st(d){return d>>>=0,d===0?32:31-(Ve(d)/lt|0)|0}var Mt=256,Ot=262144,Pt=4194304;function zt(d){var m=d&42;if(m!==0)return m;switch(d&-d){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:return d&261888;case 262144:case 524288:case 1048576:case 2097152:return d&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return d&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return d}}function Tt(d,m,x){var _=d.pendingLanes;if(_===0)return 0;var D=0,F=d.suspendedLanes,ue=d.pingedLanes;d=d.warmLanes;var Ee=_&134217727;return Ee!==0?(_=Ee&~F,_!==0?D=zt(_):(ue&=Ee,ue!==0?D=zt(ue):x||(x=Ee&~d,x!==0&&(D=zt(x))))):(Ee=_&~F,Ee!==0?D=zt(Ee):ue!==0?D=zt(ue):x||(x=_&~d,x!==0&&(D=zt(x)))),D===0?0:m!==0&&m!==D&&(m&F)===0&&(F=D&-D,x=m&-m,F>=x||F===32&&(x&4194048)!==0)?m:D}function Gt(d,m){return(d.pendingLanes&~(d.suspendedLanes&~d.pingedLanes)&m)===0}function Ye(d,m){switch(d){case 1:case 2:case 4:case 8:case 64:return m+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 m+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 kt(){var d=Pt;return Pt<<=1,(Pt&62914560)===0&&(Pt=4194304),d}function Yt(d){for(var m=[],x=0;31>x;x++)m.push(d);return m}function Ae(d,m){d.pendingLanes|=m,m!==268435456&&(d.suspendedLanes=0,d.pingedLanes=0,d.warmLanes=0)}function ke(d,m,x,_,D,F){var ue=d.pendingLanes;d.pendingLanes=x,d.suspendedLanes=0,d.pingedLanes=0,d.warmLanes=0,d.expiredLanes&=x,d.entangledLanes&=x,d.errorRecoveryDisabledLanes&=x,d.shellSuspendCounter=0;var Ee=d.entanglements,Ze=d.expirationTimes,_t=d.hiddenUpdates;for(x=ue&~x;0<x;){var It=31-Ue(x),Vt=1<<It;Ee[It]=0,Ze[It]=-1;var St=_t[It];if(St!==null)for(_t[It]=null,It=0;It<St.length;It++){var Rt=St[It];Rt!==null&&(Rt.lane&=-536870913)}x&=~Vt}_!==0&&Be(d,_,0),F!==0&&D===0&&d.tag!==0&&(d.suspendedLanes|=F&~(ue&~m))}function Be(d,m,x){d.pendingLanes|=m,d.suspendedLanes&=~m;var _=31-Ue(m);d.entangledLanes|=m,d.entanglements[_]=d.entanglements[_]|1073741824|x&261930}function yt(d,m){var x=d.entangledLanes|=m;for(d=d.entanglements;x;){var _=31-Ue(x),D=1<<_;D&m|d[_]&m&&(d[_]|=m),x&=~D}}function Me(d,m){var x=m&-m;return x=(x&42)!==0?1:Ke(x),(x&(d.suspendedLanes|m))!==0?0:x}function Ke(d){switch(d){case 2:d=1;break;case 8:d=4;break;case 32:d=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:d=128;break;case 268435456:d=134217728;break;default:d=0}return d}function Xe(d){return d&=-d,2<d?8<d?(d&134217727)!==0?32:268435456:8:2}function oe(){var d=H.p;return d!==0?d:(d=window.event,d===void 0?32:gT(d.type))}function _e(d,m){var x=H.p;try{return H.p=d,m()}finally{H.p=x}}var ve=Math.random().toString(36).slice(2),Se="__reactFiber$"+ve,Ce="__reactProps$"+ve,Pe="__reactContainer$"+ve,rt="__reactEvents$"+ve,ut="__reactListeners$"+ve,et="__reactHandles$"+ve,nt="__reactResources$"+ve,ct="__reactMarker$"+ve;function $t(d){delete d[Se],delete d[Ce],delete d[rt],delete d[ut],delete d[et]}function Ut(d){var m=d[Se];if(m)return m;for(var x=d.parentNode;x;){if(m=x[Pe]||x[Se]){if(x=m.alternate,m.child!==null||x!==null&&x.child!==null)for(d=Q6(d);d!==null;){if(x=d[Se])return x;d=Q6(d)}return m}d=x,x=d.parentNode}return null}function Xt(d){if(d=d[Se]||d[Pe]){var m=d.tag;if(m===5||m===6||m===13||m===31||m===26||m===27||m===3)return d}return null}function pt(d){var m=d.tag;if(m===5||m===26||m===27||m===6)return d.stateNode;throw Error(s(33))}function Wt(d){var m=d[nt];return m||(m=d[nt]={hoistableStyles:new Map,hoistableScripts:new Map}),m}function rr(d){d[ct]=!0}var Mr=new Set,Br={};function Yr(d,m){ma(d,m),ma(d+"Capture",m)}function ma(d,m){for(Br[d]=m,d=0;d<m.length;d++)Mr.add(m[d])}var ps=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]*$"),hn={},Rs={};function Un(d){return Fe.call(Rs,d)?!0:Fe.call(hn,d)?!1:ps.test(d)?Rs[d]=!0:(hn[d]=!0,!1)}function Tr(d,m,x){if(Un(m))if(x===null)d.removeAttribute(m);else{switch(typeof x){case"undefined":case"function":case"symbol":d.removeAttribute(m);return;case"boolean":var _=m.toLowerCase().slice(0,5);if(_!=="data-"&&_!=="aria-"){d.removeAttribute(m);return}}d.setAttribute(m,""+x)}}function Ir(d,m,x){if(x===null)d.removeAttribute(m);else{switch(typeof x){case"undefined":case"function":case"symbol":case"boolean":d.removeAttribute(m);return}d.setAttribute(m,""+x)}}function ws(d,m,x,_){if(_===null)d.removeAttribute(x);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":d.removeAttribute(x);return}d.setAttributeNS(m,x,""+_)}}function Ca(d){switch(typeof d){case"bigint":case"boolean":case"number":case"string":case"undefined":return d;case"object":return d;default:return""}}function pn(d){var m=d.type;return(d=d.nodeName)&&d.toLowerCase()==="input"&&(m==="checkbox"||m==="radio")}function mt(d,m,x){var _=Object.getOwnPropertyDescriptor(d.constructor.prototype,m);if(!d.hasOwnProperty(m)&&typeof _!="undefined"&&typeof _.get=="function"&&typeof _.set=="function"){var D=_.get,F=_.set;return Object.defineProperty(d,m,{configurable:!0,get:function(){return D.call(this)},set:function(ue){x=""+ue,F.call(this,ue)}}),Object.defineProperty(d,m,{enumerable:_.enumerable}),{getValue:function(){return x},setValue:function(ue){x=""+ue},stopTracking:function(){d._valueTracker=null,delete d[m]}}}}function ft(d){if(!d._valueTracker){var m=pn(d)?"checked":"value";d._valueTracker=mt(d,m,""+d[m])}}function dr(d){if(!d)return!1;var m=d._valueTracker;if(!m)return!0;var x=m.getValue(),_="";return d&&(_=pn(d)?d.checked?"true":"false":d.value),d=_,d!==x?(m.setValue(d),!0):!1}function vr(d){if(d=d||(typeof document!="undefined"?document:void 0),typeof d=="undefined")return null;try{return d.activeElement||d.body}catch(m){return d.body}}var Oe=/[\n"\\]/g;function ar(d){return d.replace(Oe,function(m){return"\\"+m.charCodeAt(0).toString(16)+" "})}function us(d,m,x,_,D,F,ue,Ee){d.name="",ue!=null&&typeof ue!="function"&&typeof ue!="symbol"&&typeof ue!="boolean"?d.type=ue:d.removeAttribute("type"),m!=null?ue==="number"?(m===0&&d.value===""||d.value!=m)&&(d.value=""+Ca(m)):d.value!==""+Ca(m)&&(d.value=""+Ca(m)):ue!=="submit"&&ue!=="reset"||d.removeAttribute("value"),m!=null?Ba(d,ue,Ca(m)):x!=null?Ba(d,ue,Ca(x)):_!=null&&d.removeAttribute("value"),D==null&&F!=null&&(d.defaultChecked=!!F),D!=null&&(d.checked=D&&typeof D!="function"&&typeof D!="symbol"),Ee!=null&&typeof Ee!="function"&&typeof Ee!="symbol"&&typeof Ee!="boolean"?d.name=""+Ca(Ee):d.removeAttribute("name")}function Bn(d,m,x,_,D,F,ue,Ee){if(F!=null&&typeof F!="function"&&typeof F!="symbol"&&typeof F!="boolean"&&(d.type=F),m!=null||x!=null){if(!(F!=="submit"&&F!=="reset"||m!=null)){ft(d);return}x=x!=null?""+Ca(x):"",m=m!=null?""+Ca(m):x,Ee||m===d.value||(d.value=m),d.defaultValue=m}_=_!=null?_:D,_=typeof _!="function"&&typeof _!="symbol"&&!!_,d.checked=Ee?d.checked:!!_,d.defaultChecked=!!_,ue!=null&&typeof ue!="function"&&typeof ue!="symbol"&&typeof ue!="boolean"&&(d.name=ue),ft(d)}function Ba(d,m,x){m==="number"&&vr(d.ownerDocument)===d||d.defaultValue===""+x||(d.defaultValue=""+x)}function Sr(d,m,x,_){if(d=d.options,m){m={};for(var D=0;D<x.length;D++)m["$"+x[D]]=!0;for(x=0;x<d.length;x++)D=m.hasOwnProperty("$"+d[x].value),d[x].selected!==D&&(d[x].selected=D),D&&_&&(d[x].defaultSelected=!0)}else{for(x=""+Ca(x),m=null,D=0;D<d.length;D++){if(d[D].value===x){d[D].selected=!0,_&&(d[D].defaultSelected=!0);return}m!==null||d[D].disabled||(m=d[D])}m!==null&&(m.selected=!0)}}function ji(d,m,x){if(m!=null&&(m=""+Ca(m),m!==d.value&&(d.value=m),x==null)){d.defaultValue!==m&&(d.defaultValue=m);return}d.defaultValue=x!=null?""+Ca(x):""}function _i(d,m,x,_){if(m==null){if(_!=null){if(x!=null)throw Error(s(92));if(Y(_)){if(1<_.length)throw Error(s(93));_=_[0]}x=_}x==null&&(x=""),m=x}x=Ca(m),d.defaultValue=x,_=d.textContent,_===x&&_!==""&&_!==null&&(d.value=_),ft(d)}function js(d,m){if(m){var x=d.firstChild;if(x&&x===d.lastChild&&x.nodeType===3){x.nodeValue=m;return}}d.textContent=m}var fo=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 xo(d,m,x){var _=m.indexOf("--")===0;x==null||typeof x=="boolean"||x===""?_?d.setProperty(m,""):m==="float"?d.cssFloat="":d[m]="":_?d.setProperty(m,x):typeof x!="number"||x===0||fo.has(m)?m==="float"?d.cssFloat=x:d[m]=(""+x).trim():d[m]=x+"px"}function Go(d,m,x){if(m!=null&&typeof m!="object")throw Error(s(62));if(d=d.style,x!=null){for(var _ in x)!x.hasOwnProperty(_)||m!=null&&m.hasOwnProperty(_)||(_.indexOf("--")===0?d.setProperty(_,""):_==="float"?d.cssFloat="":d[_]="");for(var D in m)_=m[D],m.hasOwnProperty(D)&&x[D]!==_&&xo(d,D,_)}else for(var F in m)m.hasOwnProperty(F)&&xo(d,F,m[F])}function Ko(d){if(d.indexOf("-")===-1)return!1;switch(d){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 Sl=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"]]),Vc=/^[\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 Yo(d){return Vc.test(""+d)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":d}function gs(){}var ot=null;function Lt(d){return d=d.target||d.srcElement||window,d.correspondingUseElement&&(d=d.correspondingUseElement),d.nodeType===3?d.parentNode:d}var oa=null,mr=null;function Wa(d){var m=Xt(d);if(m&&(d=m.stateNode)){var x=d[Ce]||null;e:switch(d=m.stateNode,m.type){case"input":if(us(d,x.value,x.defaultValue,x.defaultValue,x.checked,x.defaultChecked,x.type,x.name),m=x.name,x.type==="radio"&&m!=null){for(x=d;x.parentNode;)x=x.parentNode;for(x=x.querySelectorAll('input[name="'+ar(""+m)+'"][type="radio"]'),m=0;m<x.length;m++){var _=x[m];if(_!==d&&_.form===d.form){var D=_[Ce]||null;if(!D)throw Error(s(90));us(_,D.value,D.defaultValue,D.defaultValue,D.checked,D.defaultChecked,D.type,D.name)}}for(m=0;m<x.length;m++)_=x[m],_.form===d.form&&dr(_)}break e;case"textarea":ji(d,x.value,x.defaultValue);break e;case"select":m=x.value,m!=null&&Sr(d,!!x.multiple,m,!1)}}}var Hr=!1;function Ts(d,m,x){if(Hr)return d(m,x);Hr=!0;try{var _=d(m);return _}finally{if(Hr=!1,(oa!==null||mr!==null)&&(Ly(),oa&&(m=oa,d=mr,mr=oa=null,Wa(m),d)))for(m=0;m<d.length;m++)Wa(d[m])}}function ki(d,m){var x=d.stateNode;if(x===null)return null;var _=x[Ce]||null;if(_===null)return null;x=_[m];e:switch(m){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(_=!_.disabled)||(d=d.type,_=!(d==="button"||d==="input"||d==="select"||d==="textarea")),d=!_;break e;default:d=!1}if(d)return null;if(x&&typeof x!="function")throw Error(s(231,m,typeof x));return x}var gn=!(typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"),Wn=!1;if(gn)try{var Cn={};Object.defineProperty(Cn,"passive",{get:function(){Wn=!0}}),window.addEventListener("test",Cn,Cn),window.removeEventListener("test",Cn,Cn)}catch(d){Wn=!1}var Hn=null,yo=null,Za=null;function ni(){if(Za)return Za;var d,m=yo,x=m.length,_,D="value"in Hn?Hn.value:Hn.textContent,F=D.length;for(d=0;d<x&&m[d]===D[d];d++);var ue=x-d;for(_=1;_<=ue&&m[x-_]===D[F-_];_++);return Za=D.slice(d,1<_?1-_:void 0)}function Jo(d){var m=d.keyCode;return"charCode"in d?(d=d.charCode,d===0&&m===13&&(d=13)):d=m,d===10&&(d=13),32<=d||d===13?d:0}function hc(){return!0}function d0(){return!1}function Ms(d){function m(x,_,D,F,ue){this._reactName=x,this._targetInst=D,this.type=_,this.nativeEvent=F,this.target=ue,this.currentTarget=null;for(var Ee in d)d.hasOwnProperty(Ee)&&(x=d[Ee],this[Ee]=x?x(F):F[Ee]);return this.isDefaultPrevented=(F.defaultPrevented!=null?F.defaultPrevented:F.returnValue===!1)?hc:d0,this.isPropagationStopped=d0,this}return f(m.prototype,{preventDefault:function(){this.defaultPrevented=!0;var x=this.nativeEvent;x&&(x.preventDefault?x.preventDefault():typeof x.returnValue!="unknown"&&(x.returnValue=!1),this.isDefaultPrevented=hc)},stopPropagation:function(){var x=this.nativeEvent;x&&(x.stopPropagation?x.stopPropagation():typeof x.cancelBubble!="unknown"&&(x.cancelBubble=!0),this.isPropagationStopped=hc)},persist:function(){},isPersistent:hc}),m}var bo={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(d){return d.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Gc=Ms(bo),Cl=f({},bo,{view:0,detail:0}),la=Ms(Cl),du,Tn,Ii,Kc=f({},Cl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Zc,button:0,buttons:0,relatedTarget:function(d){return d.relatedTarget===void 0?d.fromElement===d.srcElement?d.toElement:d.fromElement:d.relatedTarget},movementX:function(d){return"movementX"in d?d.movementX:(d!==Ii&&(Ii&&d.type==="mousemove"?(du=d.screenX-Ii.screenX,Tn=d.screenY-Ii.screenY):Tn=du=0,Ii=d),du)},movementY:function(d){return"movementY"in d?d.movementY:Tn}}),Km=Ms(Kc),u0=f({},Kc,{dataTransfer:0}),ng=Ms(u0),vo=f({},Cl,{relatedTarget:0}),wo=Ms(vo),Yc=f({},bo,{animationName:0,elapsedTime:0,pseudoElement:0}),Jc=Ms(Yc),Zo=f({},bo,{clipboardData:function(d){return"clipboardData"in d?d.clipboardData:window.clipboardData}}),zi=Ms(Zo),ig=f({},bo,{data:0}),m0=Ms(ig),Xo={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},jo={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"},Tl={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function pc(d){var m=this.nativeEvent;return m.getModifierState?m.getModifierState(d):(d=Tl[d])?!!m[d]:!1}function Zc(){return pc}var h0=f({},Cl,{key:function(d){if(d.key){var m=Xo[d.key]||d.key;if(m!=="Unidentified")return m}return d.type==="keypress"?(d=Jo(d),d===13?"Enter":String.fromCharCode(d)):d.type==="keydown"||d.type==="keyup"?jo[d.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Zc,charCode:function(d){return d.type==="keypress"?Jo(d):0},keyCode:function(d){return d.type==="keydown"||d.type==="keyup"?d.keyCode:0},which:function(d){return d.type==="keypress"?Jo(d):d.type==="keydown"||d.type==="keyup"?d.keyCode:0}}),Ym=Ms(h0),og=f({},Kc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Jm=Ms(og),p0=f({},Cl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Zc}),lg=Ms(p0),Zm=f({},bo,{propertyName:0,elapsedTime:0,pseudoElement:0}),Xm=Ms(Zm),gc=f({},Kc,{deltaX:function(d){return"deltaX"in d?d.deltaX:"wheelDeltaX"in d?-d.wheelDeltaX:0},deltaY:function(d){return"deltaY"in d?d.deltaY:"wheelDeltaY"in d?-d.wheelDeltaY:"wheelDelta"in d?-d.wheelDelta:0},deltaZ:0,deltaMode:0}),El=Ms(gc),cg=f({},bo,{newState:0,oldState:0}),Xc=Ms(cg),ii=[9,13,27,32],Qc=gn&&"CompositionEvent"in window,$i=null;gn&&"documentMode"in document&&($i=document.documentMode);var g0=gn&&"TextEvent"in window&&!$i,Al=gn&&(!Qc||$i&&8<$i&&11>=$i),uu=" ",Qm=!1;function eh(d,m){switch(d){case"keyup":return ii.indexOf(m.keyCode)!==-1;case"keydown":return m.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function f0(d){return d=d.detail,typeof d=="object"&&"data"in d?d.data:null}var Ol=!1;function ka(d,m){switch(d){case"compositionend":return f0(m);case"keypress":return m.which!==32?null:(Qm=!0,uu);case"textInput":return d=m.data,d===uu&&Qm?null:d;default:return null}}function Pl(d,m){if(Ol)return d==="compositionend"||!Qc&&eh(d,m)?(d=ni(),Za=yo=Hn=null,Ol=!1,d):null;switch(d){case"paste":return null;case"keypress":if(!(m.ctrlKey||m.altKey||m.metaKey)||m.ctrlKey&&m.altKey){if(m.char&&1<m.char.length)return m.char;if(m.which)return String.fromCharCode(m.which)}return null;case"compositionend":return Al&&m.locale!=="ko"?null:m.data;default:return null}}var dg={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 Ui(d){var m=d&&d.nodeName&&d.nodeName.toLowerCase();return m==="input"?!!dg[d.type]:m==="textarea"}function th(d,m,x,_){oa?mr?mr.push(_):mr=[_]:oa=_,m=Wy(m,"onChange"),0<m.length&&(x=new Gc("onChange","change",null,x,_),d.push({event:x,listeners:m}))}var Bi=null,ed=null;function td(d){z6(d,0)}function rd(d){var m=pt(d);if(dr(m))return d}function ad(d,m){if(d==="change")return m}var sd=!1;if(gn){var Wi;if(gn){var fc="oninput"in document;if(!fc){var rh=document.createElement("div");rh.setAttribute("oninput","return;"),fc=typeof rh.oninput=="function"}Wi=fc}else Wi=!1;sd=Wi&&(!document.documentMode||9<document.documentMode)}function nd(){Bi&&(Bi.detachEvent("onpropertychange",ah),ed=Bi=null)}function ah(d){if(d.propertyName==="value"&&rd(ed)){var m=[];th(m,ed,d,Lt(d)),Ts(td,m)}}function Hi(d,m,x){d==="focusin"?(nd(),Bi=m,ed=x,Bi.attachEvent("onpropertychange",ah)):d==="focusout"&&nd()}function mu(d){if(d==="selectionchange"||d==="keyup"||d==="keydown")return rd(ed)}function xc(d,m){if(d==="click")return rd(m)}function qi(d,m){if(d==="input"||d==="change")return rd(m)}function En(d,m){return d===m&&(d!==0||1/d===1/m)||d!==d&&m!==m}var Ls=typeof Object.is=="function"?Object.is:En;function Vi(d,m){if(Ls(d,m))return!0;if(typeof d!="object"||d===null||typeof m!="object"||m===null)return!1;var x=Object.keys(d),_=Object.keys(m);if(x.length!==_.length)return!1;for(_=0;_<x.length;_++){var D=x[_];if(!Fe.call(m,D)||!Ls(d[D],m[D]))return!1}return!0}function hu(d){for(;d&&d.firstChild;)d=d.firstChild;return d}function id(d,m){var x=hu(d);d=0;for(var _;x;){if(x.nodeType===3){if(_=d+x.textContent.length,d<=m&&_>=m)return{node:x,offset:m-d};d=_}e:{for(;x;){if(x.nextSibling){x=x.nextSibling;break e}x=x.parentNode}x=void 0}x=hu(x)}}function x0(d,m){return d&&m?d===m?!0:d&&d.nodeType===3?!1:m&&m.nodeType===3?x0(d,m.parentNode):"contains"in d?d.contains(m):d.compareDocumentPosition?!!(d.compareDocumentPosition(m)&16):!1:!1}function od(d){d=d!=null&&d.ownerDocument!=null&&d.ownerDocument.defaultView!=null?d.ownerDocument.defaultView:window;for(var m=vr(d.document);m instanceof d.HTMLIFrameElement;){try{var x=typeof m.contentWindow.location.href=="string"}catch(_){x=!1}if(x)d=m.contentWindow;else break;m=vr(d.document)}return m}function Qo(d){var m=d&&d.nodeName&&d.nodeName.toLowerCase();return m&&(m==="input"&&(d.type==="text"||d.type==="search"||d.type==="tel"||d.type==="url"||d.type==="password")||m==="textarea"||d.contentEditable==="true")}var pu=gn&&"documentMode"in document&&11>=document.documentMode,el=null,ld=null,Dl=null,tl=!1;function sh(d,m,x){var _=x.window===x?x.document:x.nodeType===9?x:x.ownerDocument;tl||el==null||el!==vr(_)||(_=el,"selectionStart"in _&&Qo(_)?_={start:_.selectionStart,end:_.selectionEnd}:(_=(_.ownerDocument&&_.ownerDocument.defaultView||window).getSelection(),_={anchorNode:_.anchorNode,anchorOffset:_.anchorOffset,focusNode:_.focusNode,focusOffset:_.focusOffset}),Dl&&Vi(Dl,_)||(Dl=_,_=Wy(ld,"onSelect"),0<_.length&&(m=new Gc("onSelect","select",null,m,x),d.push({event:m,listeners:_}),m.target=el)))}function _o(d,m){var x={};return x[d.toLowerCase()]=m.toLowerCase(),x["Webkit"+d]="webkit"+m,x["Moz"+d]="moz"+m,x}var Rl={animationend:_o("Animation","AnimationEnd"),animationiteration:_o("Animation","AnimationIteration"),animationstart:_o("Animation","AnimationStart"),transitionrun:_o("Transition","TransitionRun"),transitionstart:_o("Transition","TransitionStart"),transitioncancel:_o("Transition","TransitionCancel"),transitionend:_o("Transition","TransitionEnd")},cd={},fe={};gn&&(fe=document.createElement("div").style,"AnimationEvent"in window||(delete Rl.animationend.animation,delete Rl.animationiteration.animation,delete Rl.animationstart.animation),"TransitionEvent"in window||delete Rl.transitionend.transition);function Te(d){if(cd[d])return cd[d];if(!Rl[d])return d;var m=Rl[d],x;for(x in m)if(m.hasOwnProperty(x)&&x in fe)return cd[d]=m[x];return d}var qe=Te("animationend"),Kt=Te("animationiteration"),lr=Te("animationstart"),Ht=Te("transitionrun"),jr=Te("transitionstart"),ra=Te("transitioncancel"),ns=Te("transitionend"),ha=new Map,fs="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(" ");fs.push("scrollEnd");function is(d,m){ha.set(d,m),Yr(m,[d])}var Es=typeof reportError=="function"?reportError:function(d){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var m=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof d=="object"&&d!==null&&typeof d.message=="string"?String(d.message):String(d),error:d});if(!window.dispatchEvent(m))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",d);return}console.error(d)},Xa=[],zr=0,Ni=0;function Zs(){for(var d=zr,m=Ni=zr=0;m<d;){var x=Xa[m];Xa[m++]=null;var _=Xa[m];Xa[m++]=null;var D=Xa[m];Xa[m++]=null;var F=Xa[m];if(Xa[m++]=null,_!==null&&D!==null){var ue=_.pending;ue===null?D.next=D:(D.next=ue.next,ue.next=D),_.pending=D}F!==0&&Ml(x,D,F)}}function ko(d,m,x,_){Xa[zr++]=d,Xa[zr++]=m,Xa[zr++]=x,Xa[zr++]=_,Ni|=_,d.lanes|=_,d=d.alternate,d!==null&&(d.lanes|=_)}function Si(d,m,x,_){return ko(d,m,x,_),y0(d)}function _s(d,m){return ko(d,null,null,m),y0(d)}function Ml(d,m,x){d.lanes|=x;var _=d.alternate;_!==null&&(_.lanes|=x);for(var D=!1,F=d.return;F!==null;)F.childLanes|=x,_=F.alternate,_!==null&&(_.childLanes|=x),F.tag===22&&(d=F.stateNode,d===null||d._visibility&1||(D=!0)),d=F,F=F.return;return d.tag===3?(F=d.stateNode,D&&m!==null&&(D=31-Ue(x),d=F.hiddenUpdates,_=d[D],_===null?d[D]=[m]:_.push(m),m.lane=x|536870912),F):null}function y0(d){if(50<Mg)throw Mg=0,c_=null,Error(s(185));for(var m=d.return;m!==null;)d=m,m=d.return;return d.tag===3?d.stateNode:null}var dd={};function lj(d,m,x,_){this.tag=d,this.key=x,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=m,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=_,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function oi(d,m,x,_){return new lj(d,m,x,_)}function nh(d){return d=d.prototype,!(!d||!d.isReactComponent)}function rl(d,m){var x=d.alternate;return x===null?(x=oi(d.tag,m,d.key,d.mode),x.elementType=d.elementType,x.type=d.type,x.stateNode=d.stateNode,x.alternate=d,d.alternate=x):(x.pendingProps=m,x.type=d.type,x.flags=0,x.subtreeFlags=0,x.deletions=null),x.flags=d.flags&65011712,x.childLanes=d.childLanes,x.lanes=d.lanes,x.child=d.child,x.memoizedProps=d.memoizedProps,x.memoizedState=d.memoizedState,x.updateQueue=d.updateQueue,m=d.dependencies,x.dependencies=m===null?null:{lanes:m.lanes,firstContext:m.firstContext},x.sibling=d.sibling,x.index=d.index,x.ref=d.ref,x.refCleanup=d.refCleanup,x}function ug(d,m){d.flags&=65011714;var x=d.alternate;return x===null?(d.childLanes=0,d.lanes=m,d.child=null,d.subtreeFlags=0,d.memoizedProps=null,d.memoizedState=null,d.updateQueue=null,d.dependencies=null,d.stateNode=null):(d.childLanes=x.childLanes,d.lanes=x.lanes,d.child=x.child,d.subtreeFlags=0,d.deletions=null,d.memoizedProps=x.memoizedProps,d.memoizedState=x.memoizedState,d.updateQueue=x.updateQueue,d.type=x.type,m=x.dependencies,d.dependencies=m===null?null:{lanes:m.lanes,firstContext:m.firstContext}),d}function b0(d,m,x,_,D,F){var ue=0;if(_=d,typeof d=="function")nh(d)&&(ue=1);else if(typeof d=="string")ue=oW(d,x,Q.current)?26:d==="html"||d==="head"||d==="body"?27:5;else e:switch(d){case z:return d=oi(31,x,m,D),d.elementType=z,d.lanes=F,d;case v:return ud(x.children,D,F,m);case k:ue=8,D|=24;break;case S:return d=oi(12,x,m,D|2),d.elementType=S,d.lanes=F,d;case T:return d=oi(13,x,m,D),d.elementType=T,d.lanes=F,d;case P:return d=oi(19,x,m,D),d.elementType=P,d.lanes=F,d;default:if(typeof d=="object"&&d!==null)switch(d.$$typeof){case C:ue=10;break e;case N:ue=9;break e;case O:ue=11;break e;case E:ue=14;break e;case R:ue=16,_=null;break e}ue=29,x=Error(s(130,d===null?"null":typeof d,"")),_=null}return m=oi(ue,x,m,D),m.elementType=d,m.type=_,m.lanes=F,m}function ud(d,m,x,_){return d=oi(7,d,_,m),d.lanes=x,d}function ih(d,m,x){return d=oi(6,d,null,m),d.lanes=x,d}function mg(d){var m=oi(18,null,null,0);return m.stateNode=d,m}function hg(d,m,x){return m=oi(4,d.children!==null?d.children:[],d.key,m),m.lanes=x,m.stateNode={containerInfo:d.containerInfo,pendingChildren:null,implementation:d.implementation},m}var g=new WeakMap;function j(d,m){if(typeof d=="object"&&d!==null){var x=g.get(d);return x!==void 0?x:(m={value:d,source:m,stack:le(m)},g.set(d,m),m)}return{value:d,source:m,stack:le(m)}}var A=[],W=0,ce=null,Ne=0,Ge=[],xt=0,Nt=null,qt=1,cr="";function Cr(d,m){A[W++]=Ne,A[W++]=ce,ce=d,Ne=m}function Jr(d,m,x){Ge[xt++]=qt,Ge[xt++]=cr,Ge[xt++]=Nt,Nt=d;var _=qt;d=cr;var D=32-Ue(_)-1;_&=~(1<<D),x+=1;var F=32-Ue(m)+D;if(30<F){var ue=D-D%5;F=(_&(1<<ue)-1).toString(32),_>>=ue,D-=ue,qt=1<<32-Ue(m)+D|x<<D|_,cr=F+d}else qt=1<<F|x<<D|_,cr=d}function fn(d){d.return!==null&&(Cr(d,1),Jr(d,1,0))}function Fs(d){for(;d===ce;)ce=A[--W],A[W]=null,Ne=A[--W],A[W]=null;for(;d===Nt;)Nt=Ge[--xt],Ge[xt]=null,cr=Ge[--xt],Ge[xt]=null,qt=Ge[--xt],Ge[xt]=null}function Ci(d,m){Ge[xt++]=qt,Ge[xt++]=cr,Ge[xt++]=Nt,qt=m.id,cr=m.overflow,Nt=d}var Ta=null,Ea=null,pa=!1,yc=null,Gi=!1,oh=Error(s(519));function bc(d){var m=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw v0(j(m,d)),oh}function pg(d){var m=d.stateNode,x=d.type,_=d.memoizedProps;switch(m[Se]=d,m[Ce]=_,x){case"dialog":fa("cancel",m),fa("close",m);break;case"iframe":case"object":case"embed":fa("load",m);break;case"video":case"audio":for(x=0;x<Fg.length;x++)fa(Fg[x],m);break;case"source":fa("error",m);break;case"img":case"image":case"link":fa("error",m),fa("load",m);break;case"details":fa("toggle",m);break;case"input":fa("invalid",m),Bn(m,_.value,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name,!0);break;case"select":fa("invalid",m);break;case"textarea":fa("invalid",m),_i(m,_.value,_.defaultValue,_.children)}x=_.children,typeof x!="string"&&typeof x!="number"&&typeof x!="bigint"||m.textContent===""+x||_.suppressHydrationWarning===!0||W6(m.textContent,x)?(_.popover!=null&&(fa("beforetoggle",m),fa("toggle",m)),_.onScroll!=null&&fa("scroll",m),_.onScrollEnd!=null&&fa("scrollend",m),_.onClick!=null&&(m.onclick=gs),m=!0):m=!1,m||bc(d,!0)}function As(d){for(Ta=d.return;Ta;)switch(Ta.tag){case 5:case 31:case 13:Gi=!1;return;case 27:case 3:Gi=!0;return;default:Ta=Ta.return}}function Ll(d){if(d!==Ta)return!1;if(!pa)return As(d),pa=!0,!1;var m=d.tag,x;if((x=m!==3&&m!==27)&&((x=m===5)&&(x=d.type,x=!(x!=="form"&&x!=="button")||k_(d.type,d.memoizedProps)),x=!x),x&&Ea&&bc(d),As(d),m===13){if(d=d.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(s(317));Ea=X6(d)}else if(m===31){if(d=d.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(s(317));Ea=X6(d)}else m===27?(m=Ea,Tu(d.type)?(d=E_,E_=null,Ea=d):Ea=m):Ea=Ta?sl(d.stateNode.nextSibling):null;return!0}function md(){Ea=Ta=null,pa=!1}function gg(){var d=yc;return d!==null&&(Zi===null?Zi=d:Zi.push.apply(Zi,d),yc=null),d}function v0(d){yc===null?yc=[d]:yc.push(d)}var w0=V(null),vc=null,Fl=null;function gu(d,m,x){B(w0,m._currentValue),m._currentValue=x}function hd(d){d._currentValue=w0.current,I(w0)}function cj(d,m,x){for(;d!==null;){var _=d.alternate;if((d.childLanes&m)!==m?(d.childLanes|=m,_!==null&&(_.childLanes|=m)):_!==null&&(_.childLanes&m)!==m&&(_.childLanes|=m),d===x)break;d=d.return}}function dj(d,m,x,_){var D=d.child;for(D!==null&&(D.return=d);D!==null;){var F=D.dependencies;if(F!==null){var ue=D.child;F=F.firstContext;e:for(;F!==null;){var Ee=F;F=D;for(var Ze=0;Ze<m.length;Ze++)if(Ee.context===m[Ze]){F.lanes|=x,Ee=F.alternate,Ee!==null&&(Ee.lanes|=x),cj(F.return,x,d),_||(ue=null);break e}F=Ee.next}}else if(D.tag===18){if(ue=D.return,ue===null)throw Error(s(341));ue.lanes|=x,F=ue.alternate,F!==null&&(F.lanes|=x),cj(ue,x,d),ue=null}else ue=D.child;if(ue!==null)ue.return=D;else for(ue=D;ue!==null;){if(ue===d){ue=null;break}if(D=ue.sibling,D!==null){D.return=ue.return,ue=D;break}ue=ue.return}D=ue}}function lh(d,m,x,_){d=null;for(var D=m,F=!1;D!==null;){if(!F){if((D.flags&524288)!==0)F=!0;else if((D.flags&262144)!==0)break}if(D.tag===10){var ue=D.alternate;if(ue===null)throw Error(s(387));if(ue=ue.memoizedProps,ue!==null){var Ee=D.type;Ls(D.pendingProps.value,ue.value)||(d!==null?d.push(Ee):d=[Ee])}}else if(D===he.current){if(ue=D.alternate,ue===null)throw Error(s(387));ue.memoizedState.memoizedState!==D.memoizedState.memoizedState&&(d!==null?d.push(Bg):d=[Bg])}D=D.return}d!==null&&dj(m,d,x,_),m.flags|=262144}function ly(d){for(d=d.firstContext;d!==null;){if(!Ls(d.context._currentValue,d.memoizedValue))return!0;d=d.next}return!1}function j0(d){vc=d,Fl=null,d=d.dependencies,d!==null&&(d.firstContext=null)}function qn(d){return TC(vc,d)}function cy(d,m){return vc===null&&j0(d),TC(d,m)}function TC(d,m){var x=m._currentValue;if(m={context:m,memoizedValue:x,next:null},Fl===null){if(d===null)throw Error(s(308));Fl=m,d.dependencies={lanes:0,firstContext:m},d.flags|=524288}else Fl=Fl.next=m;return x}var aB=typeof AbortController!="undefined"?AbortController:function(){var d=[],m=this.signal={aborted:!1,addEventListener:function(x,_){d.push(_)}};this.abort=function(){m.aborted=!0,d.forEach(function(x){return x()})}},sB=e.unstable_scheduleCallback,nB=e.unstable_NormalPriority,Xs={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function uj(){return{controller:new aB,data:new Map,refCount:0}}function fg(d){d.refCount--,d.refCount===0&&sB(nB,function(){d.controller.abort()})}var xg=null,mj=0,ch=0,dh=null;function iB(d,m){if(xg===null){var x=xg=[];mj=0,ch=g_(),dh={status:"pending",value:void 0,then:function(_){x.push(_)}}}return mj++,m.then(EC,EC),m}function EC(){if(--mj===0&&xg!==null){dh!==null&&(dh.status="fulfilled");var d=xg;xg=null,ch=0,dh=null;for(var m=0;m<d.length;m++)(0,d[m])()}}function oB(d,m){var x=[],_={status:"pending",value:null,reason:null,then:function(D){x.push(D)}};return d.then(function(){_.status="fulfilled",_.value=m;for(var D=0;D<x.length;D++)(0,x[D])(m)},function(D){for(_.status="rejected",_.reason=D,D=0;D<x.length;D++)(0,x[D])(void 0)}),_}var AC=q.S;q.S=function(d,m){h6=jt(),typeof m=="object"&&m!==null&&typeof m.then=="function"&&iB(d,m),AC!==null&&AC(d,m)};var _0=V(null);function hj(){var d=_0.current;return d!==null?d:os.pooledCache}function dy(d,m){m===null?B(_0,_0.current):B(_0,m.pool)}function OC(){var d=hj();return d===null?null:{parent:Xs._currentValue,pool:d}}var uh=Error(s(460)),pj=Error(s(474)),uy=Error(s(542)),my={then:function(){}};function PC(d){return d=d.status,d==="fulfilled"||d==="rejected"}function DC(d,m,x){switch(x=d[x],x===void 0?d.push(m):x!==m&&(m.then(gs,gs),m=x),m.status){case"fulfilled":return m.value;case"rejected":throw d=m.reason,MC(d),d;default:if(typeof m.status=="string")m.then(gs,gs);else{if(d=os,d!==null&&100<d.shellSuspendCounter)throw Error(s(482));d=m,d.status="pending",d.then(function(_){if(m.status==="pending"){var D=m;D.status="fulfilled",D.value=_}},function(_){if(m.status==="pending"){var D=m;D.status="rejected",D.reason=_}})}switch(m.status){case"fulfilled":return m.value;case"rejected":throw d=m.reason,MC(d),d}throw N0=m,uh}}function k0(d){try{var m=d._init;return m(d._payload)}catch(x){throw x!==null&&typeof x=="object"&&typeof x.then=="function"?(N0=x,uh):x}}var N0=null;function RC(){if(N0===null)throw Error(s(459));var d=N0;return N0=null,d}function MC(d){if(d===uh||d===uy)throw Error(s(483))}var mh=null,yg=0;function hy(d){var m=yg;return yg+=1,mh===null&&(mh=[]),DC(mh,d,m)}function bg(d,m){m=m.props.ref,d.ref=m!==void 0?m:null}function py(d,m){throw m.$$typeof===y?Error(s(525)):(d=Object.prototype.toString.call(m),Error(s(31,d==="[object Object]"?"object with keys {"+Object.keys(m).join(", ")+"}":d)))}function LC(d){function m(gt,tt){if(d){var wt=gt.deletions;wt===null?(gt.deletions=[tt],gt.flags|=16):wt.push(tt)}}function x(gt,tt){if(!d)return null;for(;tt!==null;)m(gt,tt),tt=tt.sibling;return null}function _(gt){for(var tt=new Map;gt!==null;)gt.key!==null?tt.set(gt.key,gt):tt.set(gt.index,gt),gt=gt.sibling;return tt}function D(gt,tt){return gt=rl(gt,tt),gt.index=0,gt.sibling=null,gt}function F(gt,tt,wt){return gt.index=wt,d?(wt=gt.alternate,wt!==null?(wt=wt.index,wt<tt?(gt.flags|=67108866,tt):wt):(gt.flags|=67108866,tt)):(gt.flags|=1048576,tt)}function ue(gt){return d&>.alternate===null&&(gt.flags|=67108866),gt}function Ee(gt,tt,wt,Bt){return tt===null||tt.tag!==6?(tt=ih(wt,gt.mode,Bt),tt.return=gt,tt):(tt=D(tt,wt),tt.return=gt,tt)}function Ze(gt,tt,wt,Bt){var Pr=wt.type;return Pr===v?It(gt,tt,wt.props.children,Bt,wt.key):tt!==null&&(tt.elementType===Pr||typeof Pr=="object"&&Pr!==null&&Pr.$$typeof===R&&k0(Pr)===tt.type)?(tt=D(tt,wt.props),bg(tt,wt),tt.return=gt,tt):(tt=b0(wt.type,wt.key,wt.props,null,gt.mode,Bt),bg(tt,wt),tt.return=gt,tt)}function _t(gt,tt,wt,Bt){return tt===null||tt.tag!==4||tt.stateNode.containerInfo!==wt.containerInfo||tt.stateNode.implementation!==wt.implementation?(tt=hg(wt,gt.mode,Bt),tt.return=gt,tt):(tt=D(tt,wt.children||[]),tt.return=gt,tt)}function It(gt,tt,wt,Bt,Pr){return tt===null||tt.tag!==7?(tt=ud(wt,gt.mode,Bt,Pr),tt.return=gt,tt):(tt=D(tt,wt),tt.return=gt,tt)}function Vt(gt,tt,wt){if(typeof tt=="string"&&tt!==""||typeof tt=="number"||typeof tt=="bigint")return tt=ih(""+tt,gt.mode,wt),tt.return=gt,tt;if(typeof tt=="object"&&tt!==null){switch(tt.$$typeof){case b:return wt=b0(tt.type,tt.key,tt.props,null,gt.mode,wt),bg(wt,tt),wt.return=gt,wt;case w:return tt=hg(tt,gt.mode,wt),tt.return=gt,tt;case R:return tt=k0(tt),Vt(gt,tt,wt)}if(Y(tt)||ee(tt))return tt=ud(tt,gt.mode,wt,null),tt.return=gt,tt;if(typeof tt.then=="function")return Vt(gt,hy(tt),wt);if(tt.$$typeof===C)return Vt(gt,cy(gt,tt),wt);py(gt,tt)}return null}function St(gt,tt,wt,Bt){var Pr=tt!==null?tt.key:null;if(typeof wt=="string"&&wt!==""||typeof wt=="number"||typeof wt=="bigint")return Pr!==null?null:Ee(gt,tt,""+wt,Bt);if(typeof wt=="object"&&wt!==null){switch(wt.$$typeof){case b:return wt.key===Pr?Ze(gt,tt,wt,Bt):null;case w:return wt.key===Pr?_t(gt,tt,wt,Bt):null;case R:return wt=k0(wt),St(gt,tt,wt,Bt)}if(Y(wt)||ee(wt))return Pr!==null?null:It(gt,tt,wt,Bt,null);if(typeof wt.then=="function")return St(gt,tt,hy(wt),Bt);if(wt.$$typeof===C)return St(gt,tt,cy(gt,wt),Bt);py(gt,wt)}return null}function Rt(gt,tt,wt,Bt,Pr){if(typeof Bt=="string"&&Bt!==""||typeof Bt=="number"||typeof Bt=="bigint")return gt=gt.get(wt)||null,Ee(tt,gt,""+Bt,Pr);if(typeof Bt=="object"&&Bt!==null){switch(Bt.$$typeof){case b:return gt=gt.get(Bt.key===null?wt:Bt.key)||null,Ze(tt,gt,Bt,Pr);case w:return gt=gt.get(Bt.key===null?wt:Bt.key)||null,_t(tt,gt,Bt,Pr);case R:return Bt=k0(Bt),Rt(gt,tt,wt,Bt,Pr)}if(Y(Bt)||ee(Bt))return gt=gt.get(wt)||null,It(tt,gt,Bt,Pr,null);if(typeof Bt.then=="function")return Rt(gt,tt,wt,hy(Bt),Pr);if(Bt.$$typeof===C)return Rt(gt,tt,wt,cy(tt,Bt),Pr);py(tt,Bt)}return null}function xr(gt,tt,wt,Bt){for(var Pr=null,Aa=null,Nr=tt,Zr=tt=0,ba=null;Nr!==null&&Zr<wt.length;Zr++){Nr.index>Zr?(ba=Nr,Nr=null):ba=Nr.sibling;var Oa=St(gt,Nr,wt[Zr],Bt);if(Oa===null){Nr===null&&(Nr=ba);break}d&&Nr&&Oa.alternate===null&&m(gt,Nr),tt=F(Oa,tt,Zr),Aa===null?Pr=Oa:Aa.sibling=Oa,Aa=Oa,Nr=ba}if(Zr===wt.length)return x(gt,Nr),pa&&Cr(gt,Zr),Pr;if(Nr===null){for(;Zr<wt.length;Zr++)Nr=Vt(gt,wt[Zr],Bt),Nr!==null&&(tt=F(Nr,tt,Zr),Aa===null?Pr=Nr:Aa.sibling=Nr,Aa=Nr);return pa&&Cr(gt,Zr),Pr}for(Nr=_(Nr);Zr<wt.length;Zr++)ba=Rt(Nr,gt,Zr,wt[Zr],Bt),ba!==null&&(d&&ba.alternate!==null&&Nr.delete(ba.key===null?Zr:ba.key),tt=F(ba,tt,Zr),Aa===null?Pr=ba:Aa.sibling=ba,Aa=ba);return d&&Nr.forEach(function(Du){return m(gt,Du)}),pa&&Cr(gt,Zr),Pr}function Lr(gt,tt,wt,Bt){if(wt==null)throw Error(s(151));for(var Pr=null,Aa=null,Nr=tt,Zr=tt=0,ba=null,Oa=wt.next();Nr!==null&&!Oa.done;Zr++,Oa=wt.next()){Nr.index>Zr?(ba=Nr,Nr=null):ba=Nr.sibling;var Du=St(gt,Nr,Oa.value,Bt);if(Du===null){Nr===null&&(Nr=ba);break}d&&Nr&&Du.alternate===null&&m(gt,Nr),tt=F(Du,tt,Zr),Aa===null?Pr=Du:Aa.sibling=Du,Aa=Du,Nr=ba}if(Oa.done)return x(gt,Nr),pa&&Cr(gt,Zr),Pr;if(Nr===null){for(;!Oa.done;Zr++,Oa=wt.next())Oa=Vt(gt,Oa.value,Bt),Oa!==null&&(tt=F(Oa,tt,Zr),Aa===null?Pr=Oa:Aa.sibling=Oa,Aa=Oa);return pa&&Cr(gt,Zr),Pr}for(Nr=_(Nr);!Oa.done;Zr++,Oa=wt.next())Oa=Rt(Nr,gt,Zr,Oa.value,Bt),Oa!==null&&(d&&Oa.alternate!==null&&Nr.delete(Oa.key===null?Zr:Oa.key),tt=F(Oa,tt,Zr),Aa===null?Pr=Oa:Aa.sibling=Oa,Aa=Oa);return d&&Nr.forEach(function(yW){return m(gt,yW)}),pa&&Cr(gt,Zr),Pr}function ts(gt,tt,wt,Bt){if(typeof wt=="object"&&wt!==null&&wt.type===v&&wt.key===null&&(wt=wt.props.children),typeof wt=="object"&&wt!==null){switch(wt.$$typeof){case b:e:{for(var Pr=wt.key;tt!==null;){if(tt.key===Pr){if(Pr=wt.type,Pr===v){if(tt.tag===7){x(gt,tt.sibling),Bt=D(tt,wt.props.children),Bt.return=gt,gt=Bt;break e}}else if(tt.elementType===Pr||typeof Pr=="object"&&Pr!==null&&Pr.$$typeof===R&&k0(Pr)===tt.type){x(gt,tt.sibling),Bt=D(tt,wt.props),bg(Bt,wt),Bt.return=gt,gt=Bt;break e}x(gt,tt);break}else m(gt,tt);tt=tt.sibling}wt.type===v?(Bt=ud(wt.props.children,gt.mode,Bt,wt.key),Bt.return=gt,gt=Bt):(Bt=b0(wt.type,wt.key,wt.props,null,gt.mode,Bt),bg(Bt,wt),Bt.return=gt,gt=Bt)}return ue(gt);case w:e:{for(Pr=wt.key;tt!==null;){if(tt.key===Pr)if(tt.tag===4&&tt.stateNode.containerInfo===wt.containerInfo&&tt.stateNode.implementation===wt.implementation){x(gt,tt.sibling),Bt=D(tt,wt.children||[]),Bt.return=gt,gt=Bt;break e}else{x(gt,tt);break}else m(gt,tt);tt=tt.sibling}Bt=hg(wt,gt.mode,Bt),Bt.return=gt,gt=Bt}return ue(gt);case R:return wt=k0(wt),ts(gt,tt,wt,Bt)}if(Y(wt))return xr(gt,tt,wt,Bt);if(ee(wt)){if(Pr=ee(wt),typeof Pr!="function")throw Error(s(150));return wt=Pr.call(wt),Lr(gt,tt,wt,Bt)}if(typeof wt.then=="function")return ts(gt,tt,hy(wt),Bt);if(wt.$$typeof===C)return ts(gt,tt,cy(gt,wt),Bt);py(gt,wt)}return typeof wt=="string"&&wt!==""||typeof wt=="number"||typeof wt=="bigint"?(wt=""+wt,tt!==null&&tt.tag===6?(x(gt,tt.sibling),Bt=D(tt,wt),Bt.return=gt,gt=Bt):(x(gt,tt),Bt=ih(wt,gt.mode,Bt),Bt.return=gt,gt=Bt),ue(gt)):x(gt,tt)}return function(gt,tt,wt,Bt){try{yg=0;var Pr=ts(gt,tt,wt,Bt);return mh=null,Pr}catch(Nr){if(Nr===uh||Nr===uy)throw Nr;var Aa=oi(29,Nr,null,gt.mode);return Aa.lanes=Bt,Aa.return=gt,Aa}finally{}}}var S0=LC(!0),FC=LC(!1),fu=!1;function gj(d){d.updateQueue={baseState:d.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function fj(d,m){d=d.updateQueue,m.updateQueue===d&&(m.updateQueue={baseState:d.baseState,firstBaseUpdate:d.firstBaseUpdate,lastBaseUpdate:d.lastBaseUpdate,shared:d.shared,callbacks:null})}function xu(d){return{lane:d,tag:0,payload:null,callback:null,next:null}}function yu(d,m,x){var _=d.updateQueue;if(_===null)return null;if(_=_.shared,(Fa&2)!==0){var D=_.pending;return D===null?m.next=m:(m.next=D.next,D.next=m),_.pending=m,m=y0(d),Ml(d,null,x),m}return ko(d,_,m,x),y0(d)}function vg(d,m,x){if(m=m.updateQueue,m!==null&&(m=m.shared,(x&4194048)!==0)){var _=m.lanes;_&=d.pendingLanes,x|=_,m.lanes=x,yt(d,x)}}function xj(d,m){var x=d.updateQueue,_=d.alternate;if(_!==null&&(_=_.updateQueue,x===_)){var D=null,F=null;if(x=x.firstBaseUpdate,x!==null){do{var ue={lane:x.lane,tag:x.tag,payload:x.payload,callback:null,next:null};F===null?D=F=ue:F=F.next=ue,x=x.next}while(x!==null);F===null?D=F=m:F=F.next=m}else D=F=m;x={baseState:_.baseState,firstBaseUpdate:D,lastBaseUpdate:F,shared:_.shared,callbacks:_.callbacks},d.updateQueue=x;return}d=x.lastBaseUpdate,d===null?x.firstBaseUpdate=m:d.next=m,x.lastBaseUpdate=m}var yj=!1;function wg(){if(yj){var d=dh;if(d!==null)throw d}}function jg(d,m,x,_){yj=!1;var D=d.updateQueue;fu=!1;var F=D.firstBaseUpdate,ue=D.lastBaseUpdate,Ee=D.shared.pending;if(Ee!==null){D.shared.pending=null;var Ze=Ee,_t=Ze.next;Ze.next=null,ue===null?F=_t:ue.next=_t,ue=Ze;var It=d.alternate;It!==null&&(It=It.updateQueue,Ee=It.lastBaseUpdate,Ee!==ue&&(Ee===null?It.firstBaseUpdate=_t:Ee.next=_t,It.lastBaseUpdate=Ze))}if(F!==null){var Vt=D.baseState;ue=0,It=_t=Ze=null,Ee=F;do{var St=Ee.lane&-536870913,Rt=St!==Ee.lane;if(Rt?(ya&St)===St:(_&St)===St){St!==0&&St===ch&&(yj=!0),It!==null&&(It=It.next={lane:0,tag:Ee.tag,payload:Ee.payload,callback:null,next:null});e:{var xr=d,Lr=Ee;St=m;var ts=x;switch(Lr.tag){case 1:if(xr=Lr.payload,typeof xr=="function"){Vt=xr.call(ts,Vt,St);break e}Vt=xr;break e;case 3:xr.flags=xr.flags&-65537|128;case 0:if(xr=Lr.payload,St=typeof xr=="function"?xr.call(ts,Vt,St):xr,St==null)break e;Vt=f({},Vt,St);break e;case 2:fu=!0}}St=Ee.callback,St!==null&&(d.flags|=64,Rt&&(d.flags|=8192),Rt=D.callbacks,Rt===null?D.callbacks=[St]:Rt.push(St))}else Rt={lane:St,tag:Ee.tag,payload:Ee.payload,callback:Ee.callback,next:null},It===null?(_t=It=Rt,Ze=Vt):It=It.next=Rt,ue|=St;if(Ee=Ee.next,Ee===null){if(Ee=D.shared.pending,Ee===null)break;Rt=Ee,Ee=Rt.next,Rt.next=null,D.lastBaseUpdate=Rt,D.shared.pending=null}}while(!0);It===null&&(Ze=Vt),D.baseState=Ze,D.firstBaseUpdate=_t,D.lastBaseUpdate=It,F===null&&(D.shared.lanes=0),_u|=ue,d.lanes=ue,d.memoizedState=Vt}}function IC(d,m){if(typeof d!="function")throw Error(s(191,d));d.call(m)}function zC(d,m){var x=d.callbacks;if(x!==null)for(d.callbacks=null,d=0;d<x.length;d++)IC(x[d],m)}var hh=V(null),gy=V(0);function $C(d,m){d=jd,B(gy,d),B(hh,m),jd=d|m.baseLanes}function bj(){B(gy,jd),B(hh,hh.current)}function vj(){jd=gy.current,I(hh),I(gy)}var No=V(null),al=null;function bu(d){var m=d.alternate;B(Gs,Gs.current&1),B(No,d),al===null&&(m===null||hh.current!==null||m.memoizedState!==null)&&(al=d)}function wj(d){B(Gs,Gs.current),B(No,d),al===null&&(al=d)}function UC(d){d.tag===22?(B(Gs,Gs.current),B(No,d),al===null&&(al=d)):vu()}function vu(){B(Gs,Gs.current),B(No,No.current)}function So(d){I(No),al===d&&(al=null),I(Gs)}var Gs=V(0);function fy(d){for(var m=d;m!==null;){if(m.tag===13){var x=m.memoizedState;if(x!==null&&(x=x.dehydrated,x===null||C_(x)||T_(x)))return m}else if(m.tag===19&&(m.memoizedProps.revealOrder==="forwards"||m.memoizedProps.revealOrder==="backwards"||m.memoizedProps.revealOrder==="unstable_legacy-backwards"||m.memoizedProps.revealOrder==="together")){if((m.flags&128)!==0)return m}else if(m.child!==null){m.child.return=m,m=m.child;continue}if(m===d)break;for(;m.sibling===null;){if(m.return===null||m.return===d)return null;m=m.return}m.sibling.return=m.return,m=m.sibling}return null}var pd=0,Vr=null,Qa=null,Qs=null,xy=!1,ph=!1,C0=!1,yy=0,_g=0,gh=null,lB=0;function Is(){throw Error(s(321))}function jj(d,m){if(m===null)return!1;for(var x=0;x<m.length&&x<d.length;x++)if(!Ls(d[x],m[x]))return!1;return!0}function _j(d,m,x,_,D,F){return pd=F,Vr=m,m.memoizedState=null,m.updateQueue=null,m.lanes=0,q.H=d===null||d.memoizedState===null?k5:Ij,C0=!1,F=x(_,D),C0=!1,ph&&(F=WC(m,x,_,D)),BC(d),F}function BC(d){q.H=Sg;var m=Qa!==null&&Qa.next!==null;if(pd=0,Qs=Qa=Vr=null,xy=!1,_g=0,gh=null,m)throw Error(s(300));d===null||en||(d=d.dependencies,d!==null&&ly(d)&&(en=!0))}function WC(d,m,x,_){Vr=d;var D=0;do{if(ph&&(gh=null),_g=0,ph=!1,25<=D)throw Error(s(301));if(D+=1,Qs=Qa=null,d.updateQueue!=null){var F=d.updateQueue;F.lastEffect=null,F.events=null,F.stores=null,F.memoCache!=null&&(F.memoCache.index=0)}q.H=N5,F=m(x,_)}while(ph);return F}function cB(){var d=q.H,m=d.useState()[0];return m=typeof m.then=="function"?kg(m):m,d=d.useState()[0],(Qa!==null?Qa.memoizedState:null)!==d&&(Vr.flags|=1024),m}function kj(){var d=yy!==0;return yy=0,d}function Nj(d,m,x){m.updateQueue=d.updateQueue,m.flags&=-2053,d.lanes&=~x}function Sj(d){if(xy){for(d=d.memoizedState;d!==null;){var m=d.queue;m!==null&&(m.pending=null),d=d.next}xy=!1}pd=0,Qs=Qa=Vr=null,ph=!1,_g=yy=0,gh=null}function Ti(){var d={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Qs===null?Vr.memoizedState=Qs=d:Qs=Qs.next=d,Qs}function Ks(){if(Qa===null){var d=Vr.alternate;d=d!==null?d.memoizedState:null}else d=Qa.next;var m=Qs===null?Vr.memoizedState:Qs.next;if(m!==null)Qs=m,Qa=d;else{if(d===null)throw Vr.alternate===null?Error(s(467)):Error(s(310));Qa=d,d={memoizedState:Qa.memoizedState,baseState:Qa.baseState,baseQueue:Qa.baseQueue,queue:Qa.queue,next:null},Qs===null?Vr.memoizedState=Qs=d:Qs=Qs.next=d}return Qs}function by(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function kg(d){var m=_g;return _g+=1,gh===null&&(gh=[]),d=DC(gh,d,m),m=Vr,(Qs===null?m.memoizedState:Qs.next)===null&&(m=m.alternate,q.H=m===null||m.memoizedState===null?k5:Ij),d}function vy(d){if(d!==null&&typeof d=="object"){if(typeof d.then=="function")return kg(d);if(d.$$typeof===C)return qn(d)}throw Error(s(438,String(d)))}function Cj(d){var m=null,x=Vr.updateQueue;if(x!==null&&(m=x.memoCache),m==null){var _=Vr.alternate;_!==null&&(_=_.updateQueue,_!==null&&(_=_.memoCache,_!=null&&(m={data:_.data.map(function(D){return D.slice()}),index:0})))}if(m==null&&(m={data:[],index:0}),x===null&&(x=by(),Vr.updateQueue=x),x.memoCache=m,x=m.data[m.index],x===void 0)for(x=m.data[m.index]=Array(d),_=0;_<d;_++)x[_]=G;return m.index++,x}function gd(d,m){return typeof m=="function"?m(d):m}function wy(d){var m=Ks();return Tj(m,Qa,d)}function Tj(d,m,x){var _=d.queue;if(_===null)throw Error(s(311));_.lastRenderedReducer=x;var D=d.baseQueue,F=_.pending;if(F!==null){if(D!==null){var ue=D.next;D.next=F.next,F.next=ue}m.baseQueue=D=F,_.pending=null}if(F=d.baseState,D===null)d.memoizedState=F;else{m=D.next;var Ee=ue=null,Ze=null,_t=m,It=!1;do{var Vt=_t.lane&-536870913;if(Vt!==_t.lane?(ya&Vt)===Vt:(pd&Vt)===Vt){var St=_t.revertLane;if(St===0)Ze!==null&&(Ze=Ze.next={lane:0,revertLane:0,gesture:null,action:_t.action,hasEagerState:_t.hasEagerState,eagerState:_t.eagerState,next:null}),Vt===ch&&(It=!0);else if((pd&St)===St){_t=_t.next,St===ch&&(It=!0);continue}else Vt={lane:0,revertLane:_t.revertLane,gesture:null,action:_t.action,hasEagerState:_t.hasEagerState,eagerState:_t.eagerState,next:null},Ze===null?(Ee=Ze=Vt,ue=F):Ze=Ze.next=Vt,Vr.lanes|=St,_u|=St;Vt=_t.action,C0&&x(F,Vt),F=_t.hasEagerState?_t.eagerState:x(F,Vt)}else St={lane:Vt,revertLane:_t.revertLane,gesture:_t.gesture,action:_t.action,hasEagerState:_t.hasEagerState,eagerState:_t.eagerState,next:null},Ze===null?(Ee=Ze=St,ue=F):Ze=Ze.next=St,Vr.lanes|=Vt,_u|=Vt;_t=_t.next}while(_t!==null&&_t!==m);if(Ze===null?ue=F:Ze.next=Ee,!Ls(F,d.memoizedState)&&(en=!0,It&&(x=dh,x!==null)))throw x;d.memoizedState=F,d.baseState=ue,d.baseQueue=Ze,_.lastRenderedState=F}return D===null&&(_.lanes=0),[d.memoizedState,_.dispatch]}function Ej(d){var m=Ks(),x=m.queue;if(x===null)throw Error(s(311));x.lastRenderedReducer=d;var _=x.dispatch,D=x.pending,F=m.memoizedState;if(D!==null){x.pending=null;var ue=D=D.next;do F=d(F,ue.action),ue=ue.next;while(ue!==D);Ls(F,m.memoizedState)||(en=!0),m.memoizedState=F,m.baseQueue===null&&(m.baseState=F),x.lastRenderedState=F}return[F,_]}function HC(d,m,x){var _=Vr,D=Ks(),F=pa;if(F){if(x===void 0)throw Error(s(407));x=x()}else x=m();var ue=!Ls((Qa||D).memoizedState,x);if(ue&&(D.memoizedState=x,en=!0),D=D.queue,Pj(GC.bind(null,_,D,d),[d]),D.getSnapshot!==m||ue||Qs!==null&&Qs.memoizedState.tag&1){if(_.flags|=2048,fh(9,{destroy:void 0},VC.bind(null,_,D,x,m),null),os===null)throw Error(s(349));F||(pd&127)!==0||qC(_,m,x)}return x}function qC(d,m,x){d.flags|=16384,d={getSnapshot:m,value:x},m=Vr.updateQueue,m===null?(m=by(),Vr.updateQueue=m,m.stores=[d]):(x=m.stores,x===null?m.stores=[d]:x.push(d))}function VC(d,m,x,_){m.value=x,m.getSnapshot=_,KC(m)&&YC(d)}function GC(d,m,x){return x(function(){KC(m)&&YC(d)})}function KC(d){var m=d.getSnapshot;d=d.value;try{var x=m();return!Ls(d,x)}catch(_){return!0}}function YC(d){var m=_s(d,2);m!==null&&Xi(m,d,2)}function Aj(d){var m=Ti();if(typeof d=="function"){var x=d;if(d=x(),C0){it(!0);try{x()}finally{it(!1)}}}return m.memoizedState=m.baseState=d,m.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:gd,lastRenderedState:d},m}function JC(d,m,x,_){return d.baseState=x,Tj(d,Qa,typeof _=="function"?_:gd)}function dB(d,m,x,_,D){if(ky(d))throw Error(s(485));if(d=m.action,d!==null){var F={payload:D,action:d,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(ue){F.listeners.push(ue)}};q.T!==null?x(!0):F.isTransition=!1,_(F),x=m.pending,x===null?(F.next=m.pending=F,ZC(m,F)):(F.next=x.next,m.pending=x.next=F)}}function ZC(d,m){var x=m.action,_=m.payload,D=d.state;if(m.isTransition){var F=q.T,ue={};q.T=ue;try{var Ee=x(D,_),Ze=q.S;Ze!==null&&Ze(ue,Ee),XC(d,m,Ee)}catch(_t){Oj(d,m,_t)}finally{F!==null&&ue.types!==null&&(F.types=ue.types),q.T=F}}else try{F=x(D,_),XC(d,m,F)}catch(_t){Oj(d,m,_t)}}function XC(d,m,x){x!==null&&typeof x=="object"&&typeof x.then=="function"?x.then(function(_){QC(d,m,_)},function(_){return Oj(d,m,_)}):QC(d,m,x)}function QC(d,m,x){m.status="fulfilled",m.value=x,e5(m),d.state=x,m=d.pending,m!==null&&(x=m.next,x===m?d.pending=null:(x=x.next,m.next=x,ZC(d,x)))}function Oj(d,m,x){var _=d.pending;if(d.pending=null,_!==null){_=_.next;do m.status="rejected",m.reason=x,e5(m),m=m.next;while(m!==_)}d.action=null}function e5(d){d=d.listeners;for(var m=0;m<d.length;m++)(0,d[m])()}function t5(d,m){return m}function r5(d,m){if(pa){var x=os.formState;if(x!==null){e:{var _=Vr;if(pa){if(Ea){t:{for(var D=Ea,F=Gi;D.nodeType!==8;){if(!F){D=null;break t}if(D=sl(D.nextSibling),D===null){D=null;break t}}F=D.data,D=F==="F!"||F==="F"?D:null}if(D){Ea=sl(D.nextSibling),_=D.data==="F!";break e}}bc(_)}_=!1}_&&(m=x[0])}}return x=Ti(),x.memoizedState=x.baseState=m,_={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t5,lastRenderedState:m},x.queue=_,x=w5.bind(null,Vr,_),_.dispatch=x,_=Aj(!1),F=Fj.bind(null,Vr,!1,_.queue),_=Ti(),D={state:m,dispatch:null,action:d,pending:null},_.queue=D,x=dB.bind(null,Vr,D,F,x),D.dispatch=x,_.memoizedState=d,[m,x,!1]}function a5(d){var m=Ks();return s5(m,Qa,d)}function s5(d,m,x){if(m=Tj(d,m,t5)[0],d=wy(gd)[0],typeof m=="object"&&m!==null&&typeof m.then=="function")try{var _=kg(m)}catch(ue){throw ue===uh?uy:ue}else _=m;m=Ks();var D=m.queue,F=D.dispatch;return x!==m.memoizedState&&(Vr.flags|=2048,fh(9,{destroy:void 0},uB.bind(null,D,x),null)),[_,F,d]}function uB(d,m){d.action=m}function n5(d){var m=Ks(),x=Qa;if(x!==null)return s5(m,x,d);Ks(),m=m.memoizedState,x=Ks();var _=x.queue.dispatch;return x.memoizedState=d,[m,_,!1]}function fh(d,m,x,_){return d={tag:d,create:x,deps:_,inst:m,next:null},m=Vr.updateQueue,m===null&&(m=by(),Vr.updateQueue=m),x=m.lastEffect,x===null?m.lastEffect=d.next=d:(_=x.next,x.next=d,d.next=_,m.lastEffect=d),d}function i5(){return Ks().memoizedState}function jy(d,m,x,_){var D=Ti();Vr.flags|=d,D.memoizedState=fh(1|m,{destroy:void 0},x,_===void 0?null:_)}function _y(d,m,x,_){var D=Ks();_=_===void 0?null:_;var F=D.memoizedState.inst;Qa!==null&&_!==null&&jj(_,Qa.memoizedState.deps)?D.memoizedState=fh(m,F,x,_):(Vr.flags|=d,D.memoizedState=fh(1|m,F,x,_))}function o5(d,m){jy(8390656,8,d,m)}function Pj(d,m){_y(2048,8,d,m)}function mB(d){Vr.flags|=4;var m=Vr.updateQueue;if(m===null)m=by(),Vr.updateQueue=m,m.events=[d];else{var x=m.events;x===null?m.events=[d]:x.push(d)}}function l5(d){var m=Ks().memoizedState;return mB({ref:m,nextImpl:d}),function(){if((Fa&2)!==0)throw Error(s(440));return m.impl.apply(void 0,arguments)}}function c5(d,m){return _y(4,2,d,m)}function d5(d,m){return _y(4,4,d,m)}function u5(d,m){if(typeof m=="function"){d=d();var x=m(d);return function(){typeof x=="function"?x():m(null)}}if(m!=null)return d=d(),m.current=d,function(){m.current=null}}function m5(d,m,x){x=x!=null?x.concat([d]):null,_y(4,4,u5.bind(null,m,d),x)}function Dj(){}function h5(d,m){var x=Ks();m=m===void 0?null:m;var _=x.memoizedState;return m!==null&&jj(m,_[1])?_[0]:(x.memoizedState=[d,m],d)}function p5(d,m){var x=Ks();m=m===void 0?null:m;var _=x.memoizedState;if(m!==null&&jj(m,_[1]))return _[0];if(_=d(),C0){it(!0);try{d()}finally{it(!1)}}return x.memoizedState=[_,m],_}function Rj(d,m,x){return x===void 0||(pd&1073741824)!==0&&(ya&261930)===0?d.memoizedState=m:(d.memoizedState=x,d=g6(),Vr.lanes|=d,_u|=d,x)}function g5(d,m,x,_){return Ls(x,m)?x:hh.current!==null?(d=Rj(d,x,_),Ls(d,m)||(en=!0),d):(pd&42)===0||(pd&1073741824)!==0&&(ya&261930)===0?(en=!0,d.memoizedState=x):(d=g6(),Vr.lanes|=d,_u|=d,m)}function f5(d,m,x,_,D){var F=H.p;H.p=F!==0&&8>F?F:8;var ue=q.T,Ee={};q.T=Ee,Fj(d,!1,m,x);try{var Ze=D(),_t=q.S;if(_t!==null&&_t(Ee,Ze),Ze!==null&&typeof Ze=="object"&&typeof Ze.then=="function"){var It=oB(Ze,_);Ng(d,m,It,Eo(d))}else Ng(d,m,_,Eo(d))}catch(Vt){Ng(d,m,{then:function(){},status:"rejected",reason:Vt},Eo())}finally{H.p=F,ue!==null&&Ee.types!==null&&(ue.types=Ee.types),q.T=ue}}function hB(){}function Mj(d,m,x,_){if(d.tag!==5)throw Error(s(476));var D=x5(d).queue;f5(d,D,m,U,x===null?hB:function(){return y5(d),x(_)})}function x5(d){var m=d.memoizedState;if(m!==null)return m;m={memoizedState:U,baseState:U,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:gd,lastRenderedState:U},next:null};var x={};return m.next={memoizedState:x,baseState:x,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:gd,lastRenderedState:x},next:null},d.memoizedState=m,d=d.alternate,d!==null&&(d.memoizedState=m),m}function y5(d){var m=x5(d);m.next===null&&(m=d.alternate.memoizedState),Ng(d,m.next.queue,{},Eo())}function Lj(){return qn(Bg)}function b5(){return Ks().memoizedState}function v5(){return Ks().memoizedState}function pB(d){for(var m=d.return;m!==null;){switch(m.tag){case 24:case 3:var x=Eo();d=xu(x);var _=yu(m,d,x);_!==null&&(Xi(_,m,x),vg(_,m,x)),m={cache:uj()},d.payload=m;return}m=m.return}}function gB(d,m,x){var _=Eo();x={lane:_,revertLane:0,gesture:null,action:x,hasEagerState:!1,eagerState:null,next:null},ky(d)?j5(m,x):(x=Si(d,m,x,_),x!==null&&(Xi(x,d,_),_5(x,m,_)))}function w5(d,m,x){var _=Eo();Ng(d,m,x,_)}function Ng(d,m,x,_){var D={lane:_,revertLane:0,gesture:null,action:x,hasEagerState:!1,eagerState:null,next:null};if(ky(d))j5(m,D);else{var F=d.alternate;if(d.lanes===0&&(F===null||F.lanes===0)&&(F=m.lastRenderedReducer,F!==null))try{var ue=m.lastRenderedState,Ee=F(ue,x);if(D.hasEagerState=!0,D.eagerState=Ee,Ls(Ee,ue))return ko(d,m,D,0),os===null&&Zs(),!1}catch(Ze){}finally{}if(x=Si(d,m,D,_),x!==null)return Xi(x,d,_),_5(x,m,_),!0}return!1}function Fj(d,m,x,_){if(_={lane:2,revertLane:g_(),gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},ky(d)){if(m)throw Error(s(479))}else m=Si(d,x,_,2),m!==null&&Xi(m,d,2)}function ky(d){var m=d.alternate;return d===Vr||m!==null&&m===Vr}function j5(d,m){ph=xy=!0;var x=d.pending;x===null?m.next=m:(m.next=x.next,x.next=m),d.pending=m}function _5(d,m,x){if((x&4194048)!==0){var _=m.lanes;_&=d.pendingLanes,x|=_,m.lanes=x,yt(d,x)}}var Sg={readContext:qn,use:vy,useCallback:Is,useContext:Is,useEffect:Is,useImperativeHandle:Is,useLayoutEffect:Is,useInsertionEffect:Is,useMemo:Is,useReducer:Is,useRef:Is,useState:Is,useDebugValue:Is,useDeferredValue:Is,useTransition:Is,useSyncExternalStore:Is,useId:Is,useHostTransitionStatus:Is,useFormState:Is,useActionState:Is,useOptimistic:Is,useMemoCache:Is,useCacheRefresh:Is};Sg.useEffectEvent=Is;var k5={readContext:qn,use:vy,useCallback:function(d,m){return Ti().memoizedState=[d,m===void 0?null:m],d},useContext:qn,useEffect:o5,useImperativeHandle:function(d,m,x){x=x!=null?x.concat([d]):null,jy(4194308,4,u5.bind(null,m,d),x)},useLayoutEffect:function(d,m){return jy(4194308,4,d,m)},useInsertionEffect:function(d,m){jy(4,2,d,m)},useMemo:function(d,m){var x=Ti();m=m===void 0?null:m;var _=d();if(C0){it(!0);try{d()}finally{it(!1)}}return x.memoizedState=[_,m],_},useReducer:function(d,m,x){var _=Ti();if(x!==void 0){var D=x(m);if(C0){it(!0);try{x(m)}finally{it(!1)}}}else D=m;return _.memoizedState=_.baseState=D,d={pending:null,lanes:0,dispatch:null,lastRenderedReducer:d,lastRenderedState:D},_.queue=d,d=d.dispatch=gB.bind(null,Vr,d),[_.memoizedState,d]},useRef:function(d){var m=Ti();return d={current:d},m.memoizedState=d},useState:function(d){d=Aj(d);var m=d.queue,x=w5.bind(null,Vr,m);return m.dispatch=x,[d.memoizedState,x]},useDebugValue:Dj,useDeferredValue:function(d,m){var x=Ti();return Rj(x,d,m)},useTransition:function(){var d=Aj(!1);return d=f5.bind(null,Vr,d.queue,!0,!1),Ti().memoizedState=d,[!1,d]},useSyncExternalStore:function(d,m,x){var _=Vr,D=Ti();if(pa){if(x===void 0)throw Error(s(407));x=x()}else{if(x=m(),os===null)throw Error(s(349));(ya&127)!==0||qC(_,m,x)}D.memoizedState=x;var F={value:x,getSnapshot:m};return D.queue=F,o5(GC.bind(null,_,F,d),[d]),_.flags|=2048,fh(9,{destroy:void 0},VC.bind(null,_,F,x,m),null),x},useId:function(){var d=Ti(),m=os.identifierPrefix;if(pa){var x=cr,_=qt;x=(_&~(1<<32-Ue(_)-1)).toString(32)+x,m="_"+m+"R_"+x,x=yy++,0<x&&(m+="H"+x.toString(32)),m+="_"}else x=lB++,m="_"+m+"r_"+x.toString(32)+"_";return d.memoizedState=m},useHostTransitionStatus:Lj,useFormState:r5,useActionState:r5,useOptimistic:function(d){var m=Ti();m.memoizedState=m.baseState=d;var x={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return m.queue=x,m=Fj.bind(null,Vr,!0,x),x.dispatch=m,[d,m]},useMemoCache:Cj,useCacheRefresh:function(){return Ti().memoizedState=pB.bind(null,Vr)},useEffectEvent:function(d){var m=Ti(),x={impl:d};return m.memoizedState=x,function(){if((Fa&2)!==0)throw Error(s(440));return x.impl.apply(void 0,arguments)}}},Ij={readContext:qn,use:vy,useCallback:h5,useContext:qn,useEffect:Pj,useImperativeHandle:m5,useInsertionEffect:c5,useLayoutEffect:d5,useMemo:p5,useReducer:wy,useRef:i5,useState:function(){return wy(gd)},useDebugValue:Dj,useDeferredValue:function(d,m){var x=Ks();return g5(x,Qa.memoizedState,d,m)},useTransition:function(){var d=wy(gd)[0],m=Ks().memoizedState;return[typeof d=="boolean"?d:kg(d),m]},useSyncExternalStore:HC,useId:b5,useHostTransitionStatus:Lj,useFormState:a5,useActionState:a5,useOptimistic:function(d,m){var x=Ks();return JC(x,Qa,d,m)},useMemoCache:Cj,useCacheRefresh:v5};Ij.useEffectEvent=l5;var N5={readContext:qn,use:vy,useCallback:h5,useContext:qn,useEffect:Pj,useImperativeHandle:m5,useInsertionEffect:c5,useLayoutEffect:d5,useMemo:p5,useReducer:Ej,useRef:i5,useState:function(){return Ej(gd)},useDebugValue:Dj,useDeferredValue:function(d,m){var x=Ks();return Qa===null?Rj(x,d,m):g5(x,Qa.memoizedState,d,m)},useTransition:function(){var d=Ej(gd)[0],m=Ks().memoizedState;return[typeof d=="boolean"?d:kg(d),m]},useSyncExternalStore:HC,useId:b5,useHostTransitionStatus:Lj,useFormState:n5,useActionState:n5,useOptimistic:function(d,m){var x=Ks();return Qa!==null?JC(x,Qa,d,m):(x.baseState=d,[d,x.queue.dispatch])},useMemoCache:Cj,useCacheRefresh:v5};N5.useEffectEvent=l5;function zj(d,m,x,_){m=d.memoizedState,x=x(_,m),x=x==null?m:f({},m,x),d.memoizedState=x,d.lanes===0&&(d.updateQueue.baseState=x)}var $j={enqueueSetState:function(d,m,x){d=d._reactInternals;var _=Eo(),D=xu(_);D.payload=m,x!=null&&(D.callback=x),m=yu(d,D,_),m!==null&&(Xi(m,d,_),vg(m,d,_))},enqueueReplaceState:function(d,m,x){d=d._reactInternals;var _=Eo(),D=xu(_);D.tag=1,D.payload=m,x!=null&&(D.callback=x),m=yu(d,D,_),m!==null&&(Xi(m,d,_),vg(m,d,_))},enqueueForceUpdate:function(d,m){d=d._reactInternals;var x=Eo(),_=xu(x);_.tag=2,m!=null&&(_.callback=m),m=yu(d,_,x),m!==null&&(Xi(m,d,x),vg(m,d,x))}};function S5(d,m,x,_,D,F,ue){return d=d.stateNode,typeof d.shouldComponentUpdate=="function"?d.shouldComponentUpdate(_,F,ue):m.prototype&&m.prototype.isPureReactComponent?!Vi(x,_)||!Vi(D,F):!0}function C5(d,m,x,_){d=m.state,typeof m.componentWillReceiveProps=="function"&&m.componentWillReceiveProps(x,_),typeof m.UNSAFE_componentWillReceiveProps=="function"&&m.UNSAFE_componentWillReceiveProps(x,_),m.state!==d&&$j.enqueueReplaceState(m,m.state,null)}function T0(d,m){var x=m;if("ref"in m){x={};for(var _ in m)_!=="ref"&&(x[_]=m[_])}if(d=d.defaultProps){x===m&&(x=f({},x));for(var D in d)x[D]===void 0&&(x[D]=d[D])}return x}function T5(d){Es(d)}function E5(d){console.error(d)}function A5(d){Es(d)}function Ny(d,m){try{var x=d.onUncaughtError;x(m.value,{componentStack:m.stack})}catch(_){setTimeout(function(){throw _})}}function O5(d,m,x){try{var _=d.onCaughtError;_(x.value,{componentStack:x.stack,errorBoundary:m.tag===1?m.stateNode:null})}catch(D){setTimeout(function(){throw D})}}function Uj(d,m,x){return x=xu(x),x.tag=3,x.payload={element:null},x.callback=function(){Ny(d,m)},x}function P5(d){return d=xu(d),d.tag=3,d}function D5(d,m,x,_){var D=x.type.getDerivedStateFromError;if(typeof D=="function"){var F=_.value;d.payload=function(){return D(F)},d.callback=function(){O5(m,x,_)}}var ue=x.stateNode;ue!==null&&typeof ue.componentDidCatch=="function"&&(d.callback=function(){O5(m,x,_),typeof D!="function"&&(ku===null?ku=new Set([this]):ku.add(this));var Ee=_.stack;this.componentDidCatch(_.value,{componentStack:Ee!==null?Ee:""})})}function fB(d,m,x,_,D){if(x.flags|=32768,_!==null&&typeof _=="object"&&typeof _.then=="function"){if(m=x.alternate,m!==null&&lh(m,x,D,!0),x=No.current,x!==null){switch(x.tag){case 31:case 13:return al===null?Fy():x.alternate===null&&zs===0&&(zs=3),x.flags&=-257,x.flags|=65536,x.lanes=D,_===my?x.flags|=16384:(m=x.updateQueue,m===null?x.updateQueue=new Set([_]):m.add(_),m_(d,_,D)),!1;case 22:return x.flags|=65536,_===my?x.flags|=16384:(m=x.updateQueue,m===null?(m={transitions:null,markerInstances:null,retryQueue:new Set([_])},x.updateQueue=m):(x=m.retryQueue,x===null?m.retryQueue=new Set([_]):x.add(_)),m_(d,_,D)),!1}throw Error(s(435,x.tag))}return m_(d,_,D),Fy(),!1}if(pa)return m=No.current,m!==null?((m.flags&65536)===0&&(m.flags|=256),m.flags|=65536,m.lanes=D,_!==oh&&(d=Error(s(422),{cause:_}),v0(j(d,x)))):(_!==oh&&(m=Error(s(423),{cause:_}),v0(j(m,x))),d=d.current.alternate,d.flags|=65536,D&=-D,d.lanes|=D,_=j(_,x),D=Uj(d.stateNode,_,D),xj(d,D),zs!==4&&(zs=2)),!1;var F=Error(s(520),{cause:_});if(F=j(F,x),Rg===null?Rg=[F]:Rg.push(F),zs!==4&&(zs=2),m===null)return!0;_=j(_,x),x=m;do{switch(x.tag){case 3:return x.flags|=65536,d=D&-D,x.lanes|=d,d=Uj(x.stateNode,_,d),xj(x,d),!1;case 1:if(m=x.type,F=x.stateNode,(x.flags&128)===0&&(typeof m.getDerivedStateFromError=="function"||F!==null&&typeof F.componentDidCatch=="function"&&(ku===null||!ku.has(F))))return x.flags|=65536,D&=-D,x.lanes|=D,D=P5(D),D5(D,d,x,_),xj(x,D),!1}x=x.return}while(x!==null);return!1}var Bj=Error(s(461)),en=!1;function Vn(d,m,x,_){m.child=d===null?FC(m,null,x,_):S0(m,d.child,x,_)}function R5(d,m,x,_,D){x=x.render;var F=m.ref;if("ref"in _){var ue={};for(var Ee in _)Ee!=="ref"&&(ue[Ee]=_[Ee])}else ue=_;return j0(m),_=_j(d,m,x,ue,F,D),Ee=kj(),d!==null&&!en?(Nj(d,m,D),fd(d,m,D)):(pa&&Ee&&fn(m),m.flags|=1,Vn(d,m,_,D),m.child)}function M5(d,m,x,_,D){if(d===null){var F=x.type;return typeof F=="function"&&!nh(F)&&F.defaultProps===void 0&&x.compare===null?(m.tag=15,m.type=F,L5(d,m,F,_,D)):(d=b0(x.type,null,_,m,m.mode,D),d.ref=m.ref,d.return=m,m.child=d)}if(F=d.child,!Jj(d,D)){var ue=F.memoizedProps;if(x=x.compare,x=x!==null?x:Vi,x(ue,_)&&d.ref===m.ref)return fd(d,m,D)}return m.flags|=1,d=rl(F,_),d.ref=m.ref,d.return=m,m.child=d}function L5(d,m,x,_,D){if(d!==null){var F=d.memoizedProps;if(Vi(F,_)&&d.ref===m.ref)if(en=!1,m.pendingProps=_=F,Jj(d,D))(d.flags&131072)!==0&&(en=!0);else return m.lanes=d.lanes,fd(d,m,D)}return Wj(d,m,x,_,D)}function F5(d,m,x,_){var D=_.children,F=d!==null?d.memoizedState:null;if(d===null&&m.stateNode===null&&(m.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),_.mode==="hidden"){if((m.flags&128)!==0){if(F=F!==null?F.baseLanes|x:x,d!==null){for(_=m.child=d.child,D=0;_!==null;)D=D|_.lanes|_.childLanes,_=_.sibling;_=D&~F}else _=0,m.child=null;return I5(d,m,F,x,_)}if((x&536870912)!==0)m.memoizedState={baseLanes:0,cachePool:null},d!==null&&dy(m,F!==null?F.cachePool:null),F!==null?$C(m,F):bj(),UC(m);else return _=m.lanes=536870912,I5(d,m,F!==null?F.baseLanes|x:x,x,_)}else F!==null?(dy(m,F.cachePool),$C(m,F),vu(),m.memoizedState=null):(d!==null&&dy(m,null),bj(),vu());return Vn(d,m,D,x),m.child}function Cg(d,m){return d!==null&&d.tag===22||m.stateNode!==null||(m.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),m.sibling}function I5(d,m,x,_,D){var F=hj();return F=F===null?null:{parent:Xs._currentValue,pool:F},m.memoizedState={baseLanes:x,cachePool:F},d!==null&&dy(m,null),bj(),UC(m),d!==null&&lh(d,m,_,!0),m.childLanes=D,null}function Sy(d,m){return m=Ty({mode:m.mode,children:m.children},d.mode),m.ref=d.ref,d.child=m,m.return=d,m}function z5(d,m,x){return S0(m,d.child,null,x),d=Sy(m,m.pendingProps),d.flags|=2,So(m),m.memoizedState=null,d}function xB(d,m,x){var _=m.pendingProps,D=(m.flags&128)!==0;if(m.flags&=-129,d===null){if(pa){if(_.mode==="hidden")return d=Sy(m,_),m.lanes=536870912,Cg(null,d);if(wj(m),(d=Ea)?(d=Z6(d,Gi),d=d!==null&&d.data==="&"?d:null,d!==null&&(m.memoizedState={dehydrated:d,treeContext:Nt!==null?{id:qt,overflow:cr}:null,retryLane:536870912,hydrationErrors:null},x=mg(d),x.return=m,m.child=x,Ta=m,Ea=null)):d=null,d===null)throw bc(m);return m.lanes=536870912,null}return Sy(m,_)}var F=d.memoizedState;if(F!==null){var ue=F.dehydrated;if(wj(m),D)if(m.flags&256)m.flags&=-257,m=z5(d,m,x);else if(m.memoizedState!==null)m.child=d.child,m.flags|=128,m=null;else throw Error(s(558));else if(en||lh(d,m,x,!1),D=(x&d.childLanes)!==0,en||D){if(_=os,_!==null&&(ue=Me(_,x),ue!==0&&ue!==F.retryLane))throw F.retryLane=ue,_s(d,ue),Xi(_,d,ue),Bj;Fy(),m=z5(d,m,x)}else d=F.treeContext,Ea=sl(ue.nextSibling),Ta=m,pa=!0,yc=null,Gi=!1,d!==null&&Ci(m,d),m=Sy(m,_),m.flags|=4096;return m}return d=rl(d.child,{mode:_.mode,children:_.children}),d.ref=m.ref,m.child=d,d.return=m,d}function Cy(d,m){var x=m.ref;if(x===null)d!==null&&d.ref!==null&&(m.flags|=4194816);else{if(typeof x!="function"&&typeof x!="object")throw Error(s(284));(d===null||d.ref!==x)&&(m.flags|=4194816)}}function Wj(d,m,x,_,D){return j0(m),x=_j(d,m,x,_,void 0,D),_=kj(),d!==null&&!en?(Nj(d,m,D),fd(d,m,D)):(pa&&_&&fn(m),m.flags|=1,Vn(d,m,x,D),m.child)}function $5(d,m,x,_,D,F){return j0(m),m.updateQueue=null,x=WC(m,_,x,D),BC(d),_=kj(),d!==null&&!en?(Nj(d,m,F),fd(d,m,F)):(pa&&_&&fn(m),m.flags|=1,Vn(d,m,x,F),m.child)}function U5(d,m,x,_,D){if(j0(m),m.stateNode===null){var F=dd,ue=x.contextType;typeof ue=="object"&&ue!==null&&(F=qn(ue)),F=new x(_,F),m.memoizedState=F.state!==null&&F.state!==void 0?F.state:null,F.updater=$j,m.stateNode=F,F._reactInternals=m,F=m.stateNode,F.props=_,F.state=m.memoizedState,F.refs={},gj(m),ue=x.contextType,F.context=typeof ue=="object"&&ue!==null?qn(ue):dd,F.state=m.memoizedState,ue=x.getDerivedStateFromProps,typeof ue=="function"&&(zj(m,x,ue,_),F.state=m.memoizedState),typeof x.getDerivedStateFromProps=="function"||typeof F.getSnapshotBeforeUpdate=="function"||typeof F.UNSAFE_componentWillMount!="function"&&typeof F.componentWillMount!="function"||(ue=F.state,typeof F.componentWillMount=="function"&&F.componentWillMount(),typeof F.UNSAFE_componentWillMount=="function"&&F.UNSAFE_componentWillMount(),ue!==F.state&&$j.enqueueReplaceState(F,F.state,null),jg(m,_,F,D),wg(),F.state=m.memoizedState),typeof F.componentDidMount=="function"&&(m.flags|=4194308),_=!0}else if(d===null){F=m.stateNode;var Ee=m.memoizedProps,Ze=T0(x,Ee);F.props=Ze;var _t=F.context,It=x.contextType;ue=dd,typeof It=="object"&&It!==null&&(ue=qn(It));var Vt=x.getDerivedStateFromProps;It=typeof Vt=="function"||typeof F.getSnapshotBeforeUpdate=="function",Ee=m.pendingProps!==Ee,It||typeof F.UNSAFE_componentWillReceiveProps!="function"&&typeof F.componentWillReceiveProps!="function"||(Ee||_t!==ue)&&C5(m,F,_,ue),fu=!1;var St=m.memoizedState;F.state=St,jg(m,_,F,D),wg(),_t=m.memoizedState,Ee||St!==_t||fu?(typeof Vt=="function"&&(zj(m,x,Vt,_),_t=m.memoizedState),(Ze=fu||S5(m,x,Ze,_,St,_t,ue))?(It||typeof F.UNSAFE_componentWillMount!="function"&&typeof F.componentWillMount!="function"||(typeof F.componentWillMount=="function"&&F.componentWillMount(),typeof F.UNSAFE_componentWillMount=="function"&&F.UNSAFE_componentWillMount()),typeof F.componentDidMount=="function"&&(m.flags|=4194308)):(typeof F.componentDidMount=="function"&&(m.flags|=4194308),m.memoizedProps=_,m.memoizedState=_t),F.props=_,F.state=_t,F.context=ue,_=Ze):(typeof F.componentDidMount=="function"&&(m.flags|=4194308),_=!1)}else{F=m.stateNode,fj(d,m),ue=m.memoizedProps,It=T0(x,ue),F.props=It,Vt=m.pendingProps,St=F.context,_t=x.contextType,Ze=dd,typeof _t=="object"&&_t!==null&&(Ze=qn(_t)),Ee=x.getDerivedStateFromProps,(_t=typeof Ee=="function"||typeof F.getSnapshotBeforeUpdate=="function")||typeof F.UNSAFE_componentWillReceiveProps!="function"&&typeof F.componentWillReceiveProps!="function"||(ue!==Vt||St!==Ze)&&C5(m,F,_,Ze),fu=!1,St=m.memoizedState,F.state=St,jg(m,_,F,D),wg();var Rt=m.memoizedState;ue!==Vt||St!==Rt||fu||d!==null&&d.dependencies!==null&&ly(d.dependencies)?(typeof Ee=="function"&&(zj(m,x,Ee,_),Rt=m.memoizedState),(It=fu||S5(m,x,It,_,St,Rt,Ze)||d!==null&&d.dependencies!==null&&ly(d.dependencies))?(_t||typeof F.UNSAFE_componentWillUpdate!="function"&&typeof F.componentWillUpdate!="function"||(typeof F.componentWillUpdate=="function"&&F.componentWillUpdate(_,Rt,Ze),typeof F.UNSAFE_componentWillUpdate=="function"&&F.UNSAFE_componentWillUpdate(_,Rt,Ze)),typeof F.componentDidUpdate=="function"&&(m.flags|=4),typeof F.getSnapshotBeforeUpdate=="function"&&(m.flags|=1024)):(typeof F.componentDidUpdate!="function"||ue===d.memoizedProps&&St===d.memoizedState||(m.flags|=4),typeof F.getSnapshotBeforeUpdate!="function"||ue===d.memoizedProps&&St===d.memoizedState||(m.flags|=1024),m.memoizedProps=_,m.memoizedState=Rt),F.props=_,F.state=Rt,F.context=Ze,_=It):(typeof F.componentDidUpdate!="function"||ue===d.memoizedProps&&St===d.memoizedState||(m.flags|=4),typeof F.getSnapshotBeforeUpdate!="function"||ue===d.memoizedProps&&St===d.memoizedState||(m.flags|=1024),_=!1)}return F=_,Cy(d,m),_=(m.flags&128)!==0,F||_?(F=m.stateNode,x=_&&typeof x.getDerivedStateFromError!="function"?null:F.render(),m.flags|=1,d!==null&&_?(m.child=S0(m,d.child,null,D),m.child=S0(m,null,x,D)):Vn(d,m,x,D),m.memoizedState=F.state,d=m.child):d=fd(d,m,D),d}function B5(d,m,x,_){return md(),m.flags|=256,Vn(d,m,x,_),m.child}var Hj={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function qj(d){return{baseLanes:d,cachePool:OC()}}function Vj(d,m,x){return d=d!==null?d.childLanes&~x:0,m&&(d|=To),d}function W5(d,m,x){var _=m.pendingProps,D=!1,F=(m.flags&128)!==0,ue;if((ue=F)||(ue=d!==null&&d.memoizedState===null?!1:(Gs.current&2)!==0),ue&&(D=!0,m.flags&=-129),ue=(m.flags&32)!==0,m.flags&=-33,d===null){if(pa){if(D?bu(m):vu(),(d=Ea)?(d=Z6(d,Gi),d=d!==null&&d.data!=="&"?d:null,d!==null&&(m.memoizedState={dehydrated:d,treeContext:Nt!==null?{id:qt,overflow:cr}:null,retryLane:536870912,hydrationErrors:null},x=mg(d),x.return=m,m.child=x,Ta=m,Ea=null)):d=null,d===null)throw bc(m);return T_(d)?m.lanes=32:m.lanes=536870912,null}var Ee=_.children;return _=_.fallback,D?(vu(),D=m.mode,Ee=Ty({mode:"hidden",children:Ee},D),_=ud(_,D,x,null),Ee.return=m,_.return=m,Ee.sibling=_,m.child=Ee,_=m.child,_.memoizedState=qj(x),_.childLanes=Vj(d,ue,x),m.memoizedState=Hj,Cg(null,_)):(bu(m),Gj(m,Ee))}var Ze=d.memoizedState;if(Ze!==null&&(Ee=Ze.dehydrated,Ee!==null)){if(F)m.flags&256?(bu(m),m.flags&=-257,m=Kj(d,m,x)):m.memoizedState!==null?(vu(),m.child=d.child,m.flags|=128,m=null):(vu(),Ee=_.fallback,D=m.mode,_=Ty({mode:"visible",children:_.children},D),Ee=ud(Ee,D,x,null),Ee.flags|=2,_.return=m,Ee.return=m,_.sibling=Ee,m.child=_,S0(m,d.child,null,x),_=m.child,_.memoizedState=qj(x),_.childLanes=Vj(d,ue,x),m.memoizedState=Hj,m=Cg(null,_));else if(bu(m),T_(Ee)){if(ue=Ee.nextSibling&&Ee.nextSibling.dataset,ue)var _t=ue.dgst;ue=_t,_=Error(s(419)),_.stack="",_.digest=ue,v0({value:_,source:null,stack:null}),m=Kj(d,m,x)}else if(en||lh(d,m,x,!1),ue=(x&d.childLanes)!==0,en||ue){if(ue=os,ue!==null&&(_=Me(ue,x),_!==0&&_!==Ze.retryLane))throw Ze.retryLane=_,_s(d,_),Xi(ue,d,_),Bj;C_(Ee)||Fy(),m=Kj(d,m,x)}else C_(Ee)?(m.flags|=192,m.child=d.child,m=null):(d=Ze.treeContext,Ea=sl(Ee.nextSibling),Ta=m,pa=!0,yc=null,Gi=!1,d!==null&&Ci(m,d),m=Gj(m,_.children),m.flags|=4096);return m}return D?(vu(),Ee=_.fallback,D=m.mode,Ze=d.child,_t=Ze.sibling,_=rl(Ze,{mode:"hidden",children:_.children}),_.subtreeFlags=Ze.subtreeFlags&65011712,_t!==null?Ee=rl(_t,Ee):(Ee=ud(Ee,D,x,null),Ee.flags|=2),Ee.return=m,_.return=m,_.sibling=Ee,m.child=_,Cg(null,_),_=m.child,Ee=d.child.memoizedState,Ee===null?Ee=qj(x):(D=Ee.cachePool,D!==null?(Ze=Xs._currentValue,D=D.parent!==Ze?{parent:Ze,pool:Ze}:D):D=OC(),Ee={baseLanes:Ee.baseLanes|x,cachePool:D}),_.memoizedState=Ee,_.childLanes=Vj(d,ue,x),m.memoizedState=Hj,Cg(d.child,_)):(bu(m),x=d.child,d=x.sibling,x=rl(x,{mode:"visible",children:_.children}),x.return=m,x.sibling=null,d!==null&&(ue=m.deletions,ue===null?(m.deletions=[d],m.flags|=16):ue.push(d)),m.child=x,m.memoizedState=null,x)}function Gj(d,m){return m=Ty({mode:"visible",children:m},d.mode),m.return=d,d.child=m}function Ty(d,m){return d=oi(22,d,null,m),d.lanes=0,d}function Kj(d,m,x){return S0(m,d.child,null,x),d=Gj(m,m.pendingProps.children),d.flags|=2,m.memoizedState=null,d}function H5(d,m,x){d.lanes|=m;var _=d.alternate;_!==null&&(_.lanes|=m),cj(d.return,m,x)}function Yj(d,m,x,_,D,F){var ue=d.memoizedState;ue===null?d.memoizedState={isBackwards:m,rendering:null,renderingStartTime:0,last:_,tail:x,tailMode:D,treeForkCount:F}:(ue.isBackwards=m,ue.rendering=null,ue.renderingStartTime=0,ue.last=_,ue.tail=x,ue.tailMode=D,ue.treeForkCount=F)}function q5(d,m,x){var _=m.pendingProps,D=_.revealOrder,F=_.tail;_=_.children;var ue=Gs.current,Ee=(ue&2)!==0;if(Ee?(ue=ue&1|2,m.flags|=128):ue&=1,B(Gs,ue),Vn(d,m,_,x),_=pa?Ne:0,!Ee&&d!==null&&(d.flags&128)!==0)e:for(d=m.child;d!==null;){if(d.tag===13)d.memoizedState!==null&&H5(d,x,m);else if(d.tag===19)H5(d,x,m);else if(d.child!==null){d.child.return=d,d=d.child;continue}if(d===m)break e;for(;d.sibling===null;){if(d.return===null||d.return===m)break e;d=d.return}d.sibling.return=d.return,d=d.sibling}switch(D){case"forwards":for(x=m.child,D=null;x!==null;)d=x.alternate,d!==null&&fy(d)===null&&(D=x),x=x.sibling;x=D,x===null?(D=m.child,m.child=null):(D=x.sibling,x.sibling=null),Yj(m,!1,D,x,F,_);break;case"backwards":case"unstable_legacy-backwards":for(x=null,D=m.child,m.child=null;D!==null;){if(d=D.alternate,d!==null&&fy(d)===null){m.child=D;break}d=D.sibling,D.sibling=x,x=D,D=d}Yj(m,!0,x,null,F,_);break;case"together":Yj(m,!1,null,null,void 0,_);break;default:m.memoizedState=null}return m.child}function fd(d,m,x){if(d!==null&&(m.dependencies=d.dependencies),_u|=m.lanes,(x&m.childLanes)===0)if(d!==null){if(lh(d,m,x,!1),(x&m.childLanes)===0)return null}else return null;if(d!==null&&m.child!==d.child)throw Error(s(153));if(m.child!==null){for(d=m.child,x=rl(d,d.pendingProps),m.child=x,x.return=m;d.sibling!==null;)d=d.sibling,x=x.sibling=rl(d,d.pendingProps),x.return=m;x.sibling=null}return m.child}function Jj(d,m){return(d.lanes&m)!==0?!0:(d=d.dependencies,!!(d!==null&&ly(d)))}function yB(d,m,x){switch(m.tag){case 3:de(m,m.stateNode.containerInfo),gu(m,Xs,d.memoizedState.cache),md();break;case 27:case 5:ge(m);break;case 4:de(m,m.stateNode.containerInfo);break;case 10:gu(m,m.type,m.memoizedProps.value);break;case 31:if(m.memoizedState!==null)return m.flags|=128,wj(m),null;break;case 13:var _=m.memoizedState;if(_!==null)return _.dehydrated!==null?(bu(m),m.flags|=128,null):(x&m.child.childLanes)!==0?W5(d,m,x):(bu(m),d=fd(d,m,x),d!==null?d.sibling:null);bu(m);break;case 19:var D=(d.flags&128)!==0;if(_=(x&m.childLanes)!==0,_||(lh(d,m,x,!1),_=(x&m.childLanes)!==0),D){if(_)return q5(d,m,x);m.flags|=128}if(D=m.memoizedState,D!==null&&(D.rendering=null,D.tail=null,D.lastEffect=null),B(Gs,Gs.current),_)break;return null;case 22:return m.lanes=0,F5(d,m,x,m.pendingProps);case 24:gu(m,Xs,d.memoizedState.cache)}return fd(d,m,x)}function V5(d,m,x){if(d!==null)if(d.memoizedProps!==m.pendingProps)en=!0;else{if(!Jj(d,x)&&(m.flags&128)===0)return en=!1,yB(d,m,x);en=(d.flags&131072)!==0}else en=!1,pa&&(m.flags&1048576)!==0&&Jr(m,Ne,m.index);switch(m.lanes=0,m.tag){case 16:e:{var _=m.pendingProps;if(d=k0(m.elementType),m.type=d,typeof d=="function")nh(d)?(_=T0(d,_),m.tag=1,m=U5(null,m,d,_,x)):(m.tag=0,m=Wj(null,m,d,_,x));else{if(d!=null){var D=d.$$typeof;if(D===O){m.tag=11,m=R5(null,m,d,_,x);break e}else if(D===E){m.tag=14,m=M5(null,m,d,_,x);break e}}throw m=te(d)||d,Error(s(306,m,""))}}return m;case 0:return Wj(d,m,m.type,m.pendingProps,x);case 1:return _=m.type,D=T0(_,m.pendingProps),U5(d,m,_,D,x);case 3:e:{if(de(m,m.stateNode.containerInfo),d===null)throw Error(s(387));_=m.pendingProps;var F=m.memoizedState;D=F.element,fj(d,m),jg(m,_,null,x);var ue=m.memoizedState;if(_=ue.cache,gu(m,Xs,_),_!==F.cache&&dj(m,[Xs],x,!0),wg(),_=ue.element,F.isDehydrated)if(F={element:_,isDehydrated:!1,cache:ue.cache},m.updateQueue.baseState=F,m.memoizedState=F,m.flags&256){m=B5(d,m,_,x);break e}else if(_!==D){D=j(Error(s(424)),m),v0(D),m=B5(d,m,_,x);break e}else{switch(d=m.stateNode.containerInfo,d.nodeType){case 9:d=d.body;break;default:d=d.nodeName==="HTML"?d.ownerDocument.body:d}for(Ea=sl(d.firstChild),Ta=m,pa=!0,yc=null,Gi=!0,x=FC(m,null,_,x),m.child=x;x;)x.flags=x.flags&-3|4096,x=x.sibling}else{if(md(),_===D){m=fd(d,m,x);break e}Vn(d,m,_,x)}m=m.child}return m;case 26:return Cy(d,m),d===null?(x=aT(m.type,null,m.pendingProps,null))?m.memoizedState=x:pa||(x=m.type,d=m.pendingProps,_=Hy(me.current).createElement(x),_[Se]=m,_[Ce]=d,Gn(_,x,d),rr(_),m.stateNode=_):m.memoizedState=aT(m.type,d.memoizedProps,m.pendingProps,d.memoizedState),null;case 27:return ge(m),d===null&&pa&&(_=m.stateNode=eT(m.type,m.pendingProps,me.current),Ta=m,Gi=!0,D=Ea,Tu(m.type)?(E_=D,Ea=sl(_.firstChild)):Ea=D),Vn(d,m,m.pendingProps.children,x),Cy(d,m),d===null&&(m.flags|=4194304),m.child;case 5:return d===null&&pa&&((D=_=Ea)&&(_=KB(_,m.type,m.pendingProps,Gi),_!==null?(m.stateNode=_,Ta=m,Ea=sl(_.firstChild),Gi=!1,D=!0):D=!1),D||bc(m)),ge(m),D=m.type,F=m.pendingProps,ue=d!==null?d.memoizedProps:null,_=F.children,k_(D,F)?_=null:ue!==null&&k_(D,ue)&&(m.flags|=32),m.memoizedState!==null&&(D=_j(d,m,cB,null,null,x),Bg._currentValue=D),Cy(d,m),Vn(d,m,_,x),m.child;case 6:return d===null&&pa&&((d=x=Ea)&&(x=YB(x,m.pendingProps,Gi),x!==null?(m.stateNode=x,Ta=m,Ea=null,d=!0):d=!1),d||bc(m)),null;case 13:return W5(d,m,x);case 4:return de(m,m.stateNode.containerInfo),_=m.pendingProps,d===null?m.child=S0(m,null,_,x):Vn(d,m,_,x),m.child;case 11:return R5(d,m,m.type,m.pendingProps,x);case 7:return Vn(d,m,m.pendingProps,x),m.child;case 8:return Vn(d,m,m.pendingProps.children,x),m.child;case 12:return Vn(d,m,m.pendingProps.children,x),m.child;case 10:return _=m.pendingProps,gu(m,m.type,_.value),Vn(d,m,_.children,x),m.child;case 9:return D=m.type._context,_=m.pendingProps.children,j0(m),D=qn(D),_=_(D),m.flags|=1,Vn(d,m,_,x),m.child;case 14:return M5(d,m,m.type,m.pendingProps,x);case 15:return L5(d,m,m.type,m.pendingProps,x);case 19:return q5(d,m,x);case 31:return xB(d,m,x);case 22:return F5(d,m,x,m.pendingProps);case 24:return j0(m),_=qn(Xs),d===null?(D=hj(),D===null&&(D=os,F=uj(),D.pooledCache=F,F.refCount++,F!==null&&(D.pooledCacheLanes|=x),D=F),m.memoizedState={parent:_,cache:D},gj(m),gu(m,Xs,D)):((d.lanes&x)!==0&&(fj(d,m),jg(m,null,null,x),wg()),D=d.memoizedState,F=m.memoizedState,D.parent!==_?(D={parent:_,cache:_},m.memoizedState=D,m.lanes===0&&(m.memoizedState=m.updateQueue.baseState=D),gu(m,Xs,_)):(_=F.cache,gu(m,Xs,_),_!==D.cache&&dj(m,[Xs],x,!0))),Vn(d,m,m.pendingProps.children,x),m.child;case 29:throw m.pendingProps}throw Error(s(156,m.tag))}function xd(d){d.flags|=4}function Zj(d,m,x,_,D){if((m=(d.mode&32)!==0)&&(m=!1),m){if(d.flags|=16777216,(D&335544128)===D)if(d.stateNode.complete)d.flags|=8192;else if(b6())d.flags|=8192;else throw N0=my,pj}else d.flags&=-16777217}function G5(d,m){if(m.type!=="stylesheet"||(m.state.loading&4)!==0)d.flags&=-16777217;else if(d.flags|=16777216,!lT(m))if(b6())d.flags|=8192;else throw N0=my,pj}function Ey(d,m){m!==null&&(d.flags|=4),d.flags&16384&&(m=d.tag!==22?kt():536870912,d.lanes|=m,vh|=m)}function Tg(d,m){if(!pa)switch(d.tailMode){case"hidden":m=d.tail;for(var x=null;m!==null;)m.alternate!==null&&(x=m),m=m.sibling;x===null?d.tail=null:x.sibling=null;break;case"collapsed":x=d.tail;for(var _=null;x!==null;)x.alternate!==null&&(_=x),x=x.sibling;_===null?m||d.tail===null?d.tail=null:d.tail.sibling=null:_.sibling=null}}function xs(d){var m=d.alternate!==null&&d.alternate.child===d.child,x=0,_=0;if(m)for(var D=d.child;D!==null;)x|=D.lanes|D.childLanes,_|=D.subtreeFlags&65011712,_|=D.flags&65011712,D.return=d,D=D.sibling;else for(D=d.child;D!==null;)x|=D.lanes|D.childLanes,_|=D.subtreeFlags,_|=D.flags,D.return=d,D=D.sibling;return d.subtreeFlags|=_,d.childLanes=x,m}function bB(d,m,x){var _=m.pendingProps;switch(Fs(m),m.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return xs(m),null;case 1:return xs(m),null;case 3:return x=m.stateNode,_=null,d!==null&&(_=d.memoizedState.cache),m.memoizedState.cache!==_&&(m.flags|=2048),hd(Xs),xe(),x.pendingContext&&(x.context=x.pendingContext,x.pendingContext=null),(d===null||d.child===null)&&(Ll(m)?xd(m):d===null||d.memoizedState.isDehydrated&&(m.flags&256)===0||(m.flags|=1024,gg())),xs(m),null;case 26:var D=m.type,F=m.memoizedState;return d===null?(xd(m),F!==null?(xs(m),G5(m,F)):(xs(m),Zj(m,D,null,_,x))):F?F!==d.memoizedState?(xd(m),xs(m),G5(m,F)):(xs(m),m.flags&=-16777217):(d=d.memoizedProps,d!==_&&xd(m),xs(m),Zj(m,D,d,_,x)),null;case 27:if(be(m),x=me.current,D=m.type,d!==null&&m.stateNode!=null)d.memoizedProps!==_&&xd(m);else{if(!_){if(m.stateNode===null)throw Error(s(166));return xs(m),null}d=Q.current,Ll(m)?pg(m):(d=eT(D,_,x),m.stateNode=d,xd(m))}return xs(m),null;case 5:if(be(m),D=m.type,d!==null&&m.stateNode!=null)d.memoizedProps!==_&&xd(m);else{if(!_){if(m.stateNode===null)throw Error(s(166));return xs(m),null}if(F=Q.current,Ll(m))pg(m);else{var ue=Hy(me.current);switch(F){case 1:F=ue.createElementNS("http://www.w3.org/2000/svg",D);break;case 2:F=ue.createElementNS("http://www.w3.org/1998/Math/MathML",D);break;default:switch(D){case"svg":F=ue.createElementNS("http://www.w3.org/2000/svg",D);break;case"math":F=ue.createElementNS("http://www.w3.org/1998/Math/MathML",D);break;case"script":F=ue.createElement("div"),F.innerHTML="<script><\/script>",F=F.removeChild(F.firstChild);break;case"select":F=typeof _.is=="string"?ue.createElement("select",{is:_.is}):ue.createElement("select"),_.multiple?F.multiple=!0:_.size&&(F.size=_.size);break;default:F=typeof _.is=="string"?ue.createElement(D,{is:_.is}):ue.createElement(D)}}F[Se]=m,F[Ce]=_;e:for(ue=m.child;ue!==null;){if(ue.tag===5||ue.tag===6)F.appendChild(ue.stateNode);else if(ue.tag!==4&&ue.tag!==27&&ue.child!==null){ue.child.return=ue,ue=ue.child;continue}if(ue===m)break e;for(;ue.sibling===null;){if(ue.return===null||ue.return===m)break e;ue=ue.return}ue.sibling.return=ue.return,ue=ue.sibling}m.stateNode=F;e:switch(Gn(F,D,_),D){case"button":case"input":case"select":case"textarea":_=!!_.autoFocus;break e;case"img":_=!0;break e;default:_=!1}_&&xd(m)}}return xs(m),Zj(m,m.type,d===null?null:d.memoizedProps,m.pendingProps,x),null;case 6:if(d&&m.stateNode!=null)d.memoizedProps!==_&&xd(m);else{if(typeof _!="string"&&m.stateNode===null)throw Error(s(166));if(d=me.current,Ll(m)){if(d=m.stateNode,x=m.memoizedProps,_=null,D=Ta,D!==null)switch(D.tag){case 27:case 5:_=D.memoizedProps}d[Se]=m,d=!!(d.nodeValue===x||_!==null&&_.suppressHydrationWarning===!0||W6(d.nodeValue,x)),d||bc(m,!0)}else d=Hy(d).createTextNode(_),d[Se]=m,m.stateNode=d}return xs(m),null;case 31:if(x=m.memoizedState,d===null||d.memoizedState!==null){if(_=Ll(m),x!==null){if(d===null){if(!_)throw Error(s(318));if(d=m.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(s(557));d[Se]=m}else md(),(m.flags&128)===0&&(m.memoizedState=null),m.flags|=4;xs(m),d=!1}else x=gg(),d!==null&&d.memoizedState!==null&&(d.memoizedState.hydrationErrors=x),d=!0;if(!d)return m.flags&256?(So(m),m):(So(m),null);if((m.flags&128)!==0)throw Error(s(558))}return xs(m),null;case 13:if(_=m.memoizedState,d===null||d.memoizedState!==null&&d.memoizedState.dehydrated!==null){if(D=Ll(m),_!==null&&_.dehydrated!==null){if(d===null){if(!D)throw Error(s(318));if(D=m.memoizedState,D=D!==null?D.dehydrated:null,!D)throw Error(s(317));D[Se]=m}else md(),(m.flags&128)===0&&(m.memoizedState=null),m.flags|=4;xs(m),D=!1}else D=gg(),d!==null&&d.memoizedState!==null&&(d.memoizedState.hydrationErrors=D),D=!0;if(!D)return m.flags&256?(So(m),m):(So(m),null)}return So(m),(m.flags&128)!==0?(m.lanes=x,m):(x=_!==null,d=d!==null&&d.memoizedState!==null,x&&(_=m.child,D=null,_.alternate!==null&&_.alternate.memoizedState!==null&&_.alternate.memoizedState.cachePool!==null&&(D=_.alternate.memoizedState.cachePool.pool),F=null,_.memoizedState!==null&&_.memoizedState.cachePool!==null&&(F=_.memoizedState.cachePool.pool),F!==D&&(_.flags|=2048)),x!==d&&x&&(m.child.flags|=8192),Ey(m,m.updateQueue),xs(m),null);case 4:return xe(),d===null&&b_(m.stateNode.containerInfo),xs(m),null;case 10:return hd(m.type),xs(m),null;case 19:if(I(Gs),_=m.memoizedState,_===null)return xs(m),null;if(D=(m.flags&128)!==0,F=_.rendering,F===null)if(D)Tg(_,!1);else{if(zs!==0||d!==null&&(d.flags&128)!==0)for(d=m.child;d!==null;){if(F=fy(d),F!==null){for(m.flags|=128,Tg(_,!1),d=F.updateQueue,m.updateQueue=d,Ey(m,d),m.subtreeFlags=0,d=x,x=m.child;x!==null;)ug(x,d),x=x.sibling;return B(Gs,Gs.current&1|2),pa&&Cr(m,_.treeForkCount),m.child}d=d.sibling}_.tail!==null&&jt()>Ry&&(m.flags|=128,D=!0,Tg(_,!1),m.lanes=4194304)}else{if(!D)if(d=fy(F),d!==null){if(m.flags|=128,D=!0,d=d.updateQueue,m.updateQueue=d,Ey(m,d),Tg(_,!0),_.tail===null&&_.tailMode==="hidden"&&!F.alternate&&!pa)return xs(m),null}else 2*jt()-_.renderingStartTime>Ry&&x!==536870912&&(m.flags|=128,D=!0,Tg(_,!1),m.lanes=4194304);_.isBackwards?(F.sibling=m.child,m.child=F):(d=_.last,d!==null?d.sibling=F:m.child=F,_.last=F)}return _.tail!==null?(d=_.tail,_.rendering=d,_.tail=d.sibling,_.renderingStartTime=jt(),d.sibling=null,x=Gs.current,B(Gs,D?x&1|2:x&1),pa&&Cr(m,_.treeForkCount),d):(xs(m),null);case 22:case 23:return So(m),vj(),_=m.memoizedState!==null,d!==null?d.memoizedState!==null!==_&&(m.flags|=8192):_&&(m.flags|=8192),_?(x&536870912)!==0&&(m.flags&128)===0&&(xs(m),m.subtreeFlags&6&&(m.flags|=8192)):xs(m),x=m.updateQueue,x!==null&&Ey(m,x.retryQueue),x=null,d!==null&&d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(x=d.memoizedState.cachePool.pool),_=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(_=m.memoizedState.cachePool.pool),_!==x&&(m.flags|=2048),d!==null&&I(_0),null;case 24:return x=null,d!==null&&(x=d.memoizedState.cache),m.memoizedState.cache!==x&&(m.flags|=2048),hd(Xs),xs(m),null;case 25:return null;case 30:return null}throw Error(s(156,m.tag))}function vB(d,m){switch(Fs(m),m.tag){case 1:return d=m.flags,d&65536?(m.flags=d&-65537|128,m):null;case 3:return hd(Xs),xe(),d=m.flags,(d&65536)!==0&&(d&128)===0?(m.flags=d&-65537|128,m):null;case 26:case 27:case 5:return be(m),null;case 31:if(m.memoizedState!==null){if(So(m),m.alternate===null)throw Error(s(340));md()}return d=m.flags,d&65536?(m.flags=d&-65537|128,m):null;case 13:if(So(m),d=m.memoizedState,d!==null&&d.dehydrated!==null){if(m.alternate===null)throw Error(s(340));md()}return d=m.flags,d&65536?(m.flags=d&-65537|128,m):null;case 19:return I(Gs),null;case 4:return xe(),null;case 10:return hd(m.type),null;case 22:case 23:return So(m),vj(),d!==null&&I(_0),d=m.flags,d&65536?(m.flags=d&-65537|128,m):null;case 24:return hd(Xs),null;case 25:return null;default:return null}}function K5(d,m){switch(Fs(m),m.tag){case 3:hd(Xs),xe();break;case 26:case 27:case 5:be(m);break;case 4:xe();break;case 31:m.memoizedState!==null&&So(m);break;case 13:So(m);break;case 19:I(Gs);break;case 10:hd(m.type);break;case 22:case 23:So(m),vj(),d!==null&&I(_0);break;case 24:hd(Xs)}}function Eg(d,m){try{var x=m.updateQueue,_=x!==null?x.lastEffect:null;if(_!==null){var D=_.next;x=D;do{if((x.tag&d)===d){_=void 0;var F=x.create,ue=x.inst;_=F(),ue.destroy=_}x=x.next}while(x!==D)}}catch(Ee){qa(m,m.return,Ee)}}function wu(d,m,x){try{var _=m.updateQueue,D=_!==null?_.lastEffect:null;if(D!==null){var F=D.next;_=F;do{if((_.tag&d)===d){var ue=_.inst,Ee=ue.destroy;if(Ee!==void 0){ue.destroy=void 0,D=m;var Ze=x,_t=Ee;try{_t()}catch(It){qa(D,Ze,It)}}}_=_.next}while(_!==F)}}catch(It){qa(m,m.return,It)}}function Y5(d){var m=d.updateQueue;if(m!==null){var x=d.stateNode;try{zC(m,x)}catch(_){qa(d,d.return,_)}}}function J5(d,m,x){x.props=T0(d.type,d.memoizedProps),x.state=d.memoizedState;try{x.componentWillUnmount()}catch(_){qa(d,m,_)}}function Ag(d,m){try{var x=d.ref;if(x!==null){switch(d.tag){case 26:case 27:case 5:var _=d.stateNode;break;case 30:_=d.stateNode;break;default:_=d.stateNode}typeof x=="function"?d.refCleanup=x(_):x.current=_}}catch(D){qa(d,m,D)}}function wc(d,m){var x=d.ref,_=d.refCleanup;if(x!==null)if(typeof _=="function")try{_()}catch(D){qa(d,m,D)}finally{d.refCleanup=null,d=d.alternate,d!=null&&(d.refCleanup=null)}else if(typeof x=="function")try{x(null)}catch(D){qa(d,m,D)}else x.current=null}function Z5(d){var m=d.type,x=d.memoizedProps,_=d.stateNode;try{e:switch(m){case"button":case"input":case"select":case"textarea":x.autoFocus&&_.focus();break e;case"img":x.src?_.src=x.src:x.srcSet&&(_.srcset=x.srcSet)}}catch(D){qa(d,d.return,D)}}function Xj(d,m,x){try{var _=d.stateNode;BB(_,d.type,x,m),_[Ce]=m}catch(D){qa(d,d.return,D)}}function X5(d){return d.tag===5||d.tag===3||d.tag===26||d.tag===27&&Tu(d.type)||d.tag===4}function Qj(d){e:for(;;){for(;d.sibling===null;){if(d.return===null||X5(d.return))return null;d=d.return}for(d.sibling.return=d.return,d=d.sibling;d.tag!==5&&d.tag!==6&&d.tag!==18;){if(d.tag===27&&Tu(d.type)||d.flags&2||d.child===null||d.tag===4)continue e;d.child.return=d,d=d.child}if(!(d.flags&2))return d.stateNode}}function e_(d,m,x){var _=d.tag;if(_===5||_===6)d=d.stateNode,m?(x.nodeType===9?x.body:x.nodeName==="HTML"?x.ownerDocument.body:x).insertBefore(d,m):(m=x.nodeType===9?x.body:x.nodeName==="HTML"?x.ownerDocument.body:x,m.appendChild(d),x=x._reactRootContainer,x!=null||m.onclick!==null||(m.onclick=gs));else if(_!==4&&(_===27&&Tu(d.type)&&(x=d.stateNode,m=null),d=d.child,d!==null))for(e_(d,m,x),d=d.sibling;d!==null;)e_(d,m,x),d=d.sibling}function Ay(d,m,x){var _=d.tag;if(_===5||_===6)d=d.stateNode,m?x.insertBefore(d,m):x.appendChild(d);else if(_!==4&&(_===27&&Tu(d.type)&&(x=d.stateNode),d=d.child,d!==null))for(Ay(d,m,x),d=d.sibling;d!==null;)Ay(d,m,x),d=d.sibling}function Q5(d){var m=d.stateNode,x=d.memoizedProps;try{for(var _=d.type,D=m.attributes;D.length;)m.removeAttributeNode(D[0]);Gn(m,_,x),m[Se]=d,m[Ce]=x}catch(F){qa(d,d.return,F)}}var yd=!1,tn=!1,t_=!1,e6=typeof WeakSet=="function"?WeakSet:Set,An=null;function wB(d,m){if(d=d.containerInfo,j_=Zy,d=od(d),Qo(d)){if("selectionStart"in d)var x={start:d.selectionStart,end:d.selectionEnd};else e:{x=(x=d.ownerDocument)&&x.defaultView||window;var _=x.getSelection&&x.getSelection();if(_&&_.rangeCount!==0){x=_.anchorNode;var D=_.anchorOffset,F=_.focusNode;_=_.focusOffset;try{x.nodeType,F.nodeType}catch(Lr){x=null;break e}var ue=0,Ee=-1,Ze=-1,_t=0,It=0,Vt=d,St=null;t:for(;;){for(var Rt;Vt!==x||D!==0&&Vt.nodeType!==3||(Ee=ue+D),Vt!==F||_!==0&&Vt.nodeType!==3||(Ze=ue+_),Vt.nodeType===3&&(ue+=Vt.nodeValue.length),(Rt=Vt.firstChild)!==null;)St=Vt,Vt=Rt;for(;;){if(Vt===d)break t;if(St===x&&++_t===D&&(Ee=ue),St===F&&++It===_&&(Ze=ue),(Rt=Vt.nextSibling)!==null)break;Vt=St,St=Vt.parentNode}Vt=Rt}x=Ee===-1||Ze===-1?null:{start:Ee,end:Ze}}else x=null}x=x||{start:0,end:0}}else x=null;for(__={focusedElem:d,selectionRange:x},Zy=!1,An=m;An!==null;)if(m=An,d=m.child,(m.subtreeFlags&1028)!==0&&d!==null)d.return=m,An=d;else for(;An!==null;){switch(m=An,F=m.alternate,d=m.flags,m.tag){case 0:if((d&4)!==0&&(d=m.updateQueue,d=d!==null?d.events:null,d!==null))for(x=0;x<d.length;x++)D=d[x],D.ref.impl=D.nextImpl;break;case 11:case 15:break;case 1:if((d&1024)!==0&&F!==null){d=void 0,x=m,D=F.memoizedProps,F=F.memoizedState,_=x.stateNode;try{var xr=T0(x.type,D);d=_.getSnapshotBeforeUpdate(xr,F),_.__reactInternalSnapshotBeforeUpdate=d}catch(Lr){qa(x,x.return,Lr)}}break;case 3:if((d&1024)!==0){if(d=m.stateNode.containerInfo,x=d.nodeType,x===9)S_(d);else if(x===1)switch(d.nodeName){case"HEAD":case"HTML":case"BODY":S_(d);break;default:d.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((d&1024)!==0)throw Error(s(163))}if(d=m.sibling,d!==null){d.return=m.return,An=d;break}An=m.return}}function t6(d,m,x){var _=x.flags;switch(x.tag){case 0:case 11:case 15:vd(d,x),_&4&&Eg(5,x);break;case 1:if(vd(d,x),_&4)if(d=x.stateNode,m===null)try{d.componentDidMount()}catch(ue){qa(x,x.return,ue)}else{var D=T0(x.type,m.memoizedProps);m=m.memoizedState;try{d.componentDidUpdate(D,m,d.__reactInternalSnapshotBeforeUpdate)}catch(ue){qa(x,x.return,ue)}}_&64&&Y5(x),_&512&&Ag(x,x.return);break;case 3:if(vd(d,x),_&64&&(d=x.updateQueue,d!==null)){if(m=null,x.child!==null)switch(x.child.tag){case 27:case 5:m=x.child.stateNode;break;case 1:m=x.child.stateNode}try{zC(d,m)}catch(ue){qa(x,x.return,ue)}}break;case 27:m===null&&_&4&&Q5(x);case 26:case 5:vd(d,x),m===null&&_&4&&Z5(x),_&512&&Ag(x,x.return);break;case 12:vd(d,x);break;case 31:vd(d,x),_&4&&s6(d,x);break;case 13:vd(d,x),_&4&&n6(d,x),_&64&&(d=x.memoizedState,d!==null&&(d=d.dehydrated,d!==null&&(x=AB.bind(null,x),JB(d,x))));break;case 22:if(_=x.memoizedState!==null||yd,!_){m=m!==null&&m.memoizedState!==null||tn,D=yd;var F=tn;yd=_,(tn=m)&&!F?wd(d,x,(x.subtreeFlags&8772)!==0):vd(d,x),yd=D,tn=F}break;case 30:break;default:vd(d,x)}}function r6(d){var m=d.alternate;m!==null&&(d.alternate=null,r6(m)),d.child=null,d.deletions=null,d.sibling=null,d.tag===5&&(m=d.stateNode,m!==null&&$t(m)),d.stateNode=null,d.return=null,d.dependencies=null,d.memoizedProps=null,d.memoizedState=null,d.pendingProps=null,d.stateNode=null,d.updateQueue=null}var ks=null,Ki=!1;function bd(d,m,x){for(x=x.child;x!==null;)a6(d,m,x),x=x.sibling}function a6(d,m,x){if(He&&typeof He.onCommitFiberUnmount=="function")try{He.onCommitFiberUnmount(dt,x)}catch(F){}switch(x.tag){case 26:tn||wc(x,m),bd(d,m,x),x.memoizedState?x.memoizedState.count--:x.stateNode&&(x=x.stateNode,x.parentNode.removeChild(x));break;case 27:tn||wc(x,m);var _=ks,D=Ki;Tu(x.type)&&(ks=x.stateNode,Ki=!1),bd(d,m,x),zg(x.stateNode),ks=_,Ki=D;break;case 5:tn||wc(x,m);case 6:if(_=ks,D=Ki,ks=null,bd(d,m,x),ks=_,Ki=D,ks!==null)if(Ki)try{(ks.nodeType===9?ks.body:ks.nodeName==="HTML"?ks.ownerDocument.body:ks).removeChild(x.stateNode)}catch(F){qa(x,m,F)}else try{ks.removeChild(x.stateNode)}catch(F){qa(x,m,F)}break;case 18:ks!==null&&(Ki?(d=ks,Y6(d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d,x.stateNode),Th(d)):Y6(ks,x.stateNode));break;case 4:_=ks,D=Ki,ks=x.stateNode.containerInfo,Ki=!0,bd(d,m,x),ks=_,Ki=D;break;case 0:case 11:case 14:case 15:wu(2,x,m),tn||wu(4,x,m),bd(d,m,x);break;case 1:tn||(wc(x,m),_=x.stateNode,typeof _.componentWillUnmount=="function"&&J5(x,m,_)),bd(d,m,x);break;case 21:bd(d,m,x);break;case 22:tn=(_=tn)||x.memoizedState!==null,bd(d,m,x),tn=_;break;default:bd(d,m,x)}}function s6(d,m){if(m.memoizedState===null&&(d=m.alternate,d!==null&&(d=d.memoizedState,d!==null))){d=d.dehydrated;try{Th(d)}catch(x){qa(m,m.return,x)}}}function n6(d,m){if(m.memoizedState===null&&(d=m.alternate,d!==null&&(d=d.memoizedState,d!==null&&(d=d.dehydrated,d!==null))))try{Th(d)}catch(x){qa(m,m.return,x)}}function jB(d){switch(d.tag){case 31:case 13:case 19:var m=d.stateNode;return m===null&&(m=d.stateNode=new e6),m;case 22:return d=d.stateNode,m=d._retryCache,m===null&&(m=d._retryCache=new e6),m;default:throw Error(s(435,d.tag))}}function Oy(d,m){var x=jB(d);m.forEach(function(_){if(!x.has(_)){x.add(_);var D=OB.bind(null,d,_);_.then(D,D)}})}function Yi(d,m){var x=m.deletions;if(x!==null)for(var _=0;_<x.length;_++){var D=x[_],F=d,ue=m,Ee=ue;e:for(;Ee!==null;){switch(Ee.tag){case 27:if(Tu(Ee.type)){ks=Ee.stateNode,Ki=!1;break e}break;case 5:ks=Ee.stateNode,Ki=!1;break e;case 3:case 4:ks=Ee.stateNode.containerInfo,Ki=!0;break e}Ee=Ee.return}if(ks===null)throw Error(s(160));a6(F,ue,D),ks=null,Ki=!1,F=D.alternate,F!==null&&(F.return=null),D.return=null}if(m.subtreeFlags&13886)for(m=m.child;m!==null;)i6(m,d),m=m.sibling}var Il=null;function i6(d,m){var x=d.alternate,_=d.flags;switch(d.tag){case 0:case 11:case 14:case 15:Yi(m,d),Ji(d),_&4&&(wu(3,d,d.return),Eg(3,d),wu(5,d,d.return));break;case 1:Yi(m,d),Ji(d),_&512&&(tn||x===null||wc(x,x.return)),_&64&&yd&&(d=d.updateQueue,d!==null&&(_=d.callbacks,_!==null&&(x=d.shared.hiddenCallbacks,d.shared.hiddenCallbacks=x===null?_:x.concat(_))));break;case 26:var D=Il;if(Yi(m,d),Ji(d),_&512&&(tn||x===null||wc(x,x.return)),_&4){var F=x!==null?x.memoizedState:null;if(_=d.memoizedState,x===null)if(_===null)if(d.stateNode===null){e:{_=d.type,x=d.memoizedProps,D=D.ownerDocument||D;t:switch(_){case"title":F=D.getElementsByTagName("title")[0],(!F||F[ct]||F[Se]||F.namespaceURI==="http://www.w3.org/2000/svg"||F.hasAttribute("itemprop"))&&(F=D.createElement(_),D.head.insertBefore(F,D.querySelector("head > title"))),Gn(F,_,x),F[Se]=d,rr(F),_=F;break e;case"link":var ue=iT("link","href",D).get(_+(x.href||""));if(ue){for(var Ee=0;Ee<ue.length;Ee++)if(F=ue[Ee],F.getAttribute("href")===(x.href==null||x.href===""?null:x.href)&&F.getAttribute("rel")===(x.rel==null?null:x.rel)&&F.getAttribute("title")===(x.title==null?null:x.title)&&F.getAttribute("crossorigin")===(x.crossOrigin==null?null:x.crossOrigin)){ue.splice(Ee,1);break t}}F=D.createElement(_),Gn(F,_,x),D.head.appendChild(F);break;case"meta":if(ue=iT("meta","content",D).get(_+(x.content||""))){for(Ee=0;Ee<ue.length;Ee++)if(F=ue[Ee],F.getAttribute("content")===(x.content==null?null:""+x.content)&&F.getAttribute("name")===(x.name==null?null:x.name)&&F.getAttribute("property")===(x.property==null?null:x.property)&&F.getAttribute("http-equiv")===(x.httpEquiv==null?null:x.httpEquiv)&&F.getAttribute("charset")===(x.charSet==null?null:x.charSet)){ue.splice(Ee,1);break t}}F=D.createElement(_),Gn(F,_,x),D.head.appendChild(F);break;default:throw Error(s(468,_))}F[Se]=d,rr(F),_=F}d.stateNode=_}else oT(D,d.type,d.stateNode);else d.stateNode=nT(D,_,d.memoizedProps);else F!==_?(F===null?x.stateNode!==null&&(x=x.stateNode,x.parentNode.removeChild(x)):F.count--,_===null?oT(D,d.type,d.stateNode):nT(D,_,d.memoizedProps)):_===null&&d.stateNode!==null&&Xj(d,d.memoizedProps,x.memoizedProps)}break;case 27:Yi(m,d),Ji(d),_&512&&(tn||x===null||wc(x,x.return)),x!==null&&_&4&&Xj(d,d.memoizedProps,x.memoizedProps);break;case 5:if(Yi(m,d),Ji(d),_&512&&(tn||x===null||wc(x,x.return)),d.flags&32){D=d.stateNode;try{js(D,"")}catch(xr){qa(d,d.return,xr)}}_&4&&d.stateNode!=null&&(D=d.memoizedProps,Xj(d,D,x!==null?x.memoizedProps:D)),_&1024&&(t_=!0);break;case 6:if(Yi(m,d),Ji(d),_&4){if(d.stateNode===null)throw Error(s(162));_=d.memoizedProps,x=d.stateNode;try{x.nodeValue=_}catch(xr){qa(d,d.return,xr)}}break;case 3:if(Gy=null,D=Il,Il=qy(m.containerInfo),Yi(m,d),Il=D,Ji(d),_&4&&x!==null&&x.memoizedState.isDehydrated)try{Th(m.containerInfo)}catch(xr){qa(d,d.return,xr)}t_&&(t_=!1,o6(d));break;case 4:_=Il,Il=qy(d.stateNode.containerInfo),Yi(m,d),Ji(d),Il=_;break;case 12:Yi(m,d),Ji(d);break;case 31:Yi(m,d),Ji(d),_&4&&(_=d.updateQueue,_!==null&&(d.updateQueue=null,Oy(d,_)));break;case 13:Yi(m,d),Ji(d),d.child.flags&8192&&d.memoizedState!==null!=(x!==null&&x.memoizedState!==null)&&(Dy=jt()),_&4&&(_=d.updateQueue,_!==null&&(d.updateQueue=null,Oy(d,_)));break;case 22:D=d.memoizedState!==null;var Ze=x!==null&&x.memoizedState!==null,_t=yd,It=tn;if(yd=_t||D,tn=It||Ze,Yi(m,d),tn=It,yd=_t,Ji(d),_&8192)e:for(m=d.stateNode,m._visibility=D?m._visibility&-2:m._visibility|1,D&&(x===null||Ze||yd||tn||E0(d)),x=null,m=d;;){if(m.tag===5||m.tag===26){if(x===null){Ze=x=m;try{if(F=Ze.stateNode,D)ue=F.style,typeof ue.setProperty=="function"?ue.setProperty("display","none","important"):ue.display="none";else{Ee=Ze.stateNode;var Vt=Ze.memoizedProps.style,St=Vt!=null&&Vt.hasOwnProperty("display")?Vt.display:null;Ee.style.display=St==null||typeof St=="boolean"?"":(""+St).trim()}}catch(xr){qa(Ze,Ze.return,xr)}}}else if(m.tag===6){if(x===null){Ze=m;try{Ze.stateNode.nodeValue=D?"":Ze.memoizedProps}catch(xr){qa(Ze,Ze.return,xr)}}}else if(m.tag===18){if(x===null){Ze=m;try{var Rt=Ze.stateNode;D?J6(Rt,!0):J6(Ze.stateNode,!1)}catch(xr){qa(Ze,Ze.return,xr)}}}else if((m.tag!==22&&m.tag!==23||m.memoizedState===null||m===d)&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===d)break e;for(;m.sibling===null;){if(m.return===null||m.return===d)break e;x===m&&(x=null),m=m.return}x===m&&(x=null),m.sibling.return=m.return,m=m.sibling}_&4&&(_=d.updateQueue,_!==null&&(x=_.retryQueue,x!==null&&(_.retryQueue=null,Oy(d,x))));break;case 19:Yi(m,d),Ji(d),_&4&&(_=d.updateQueue,_!==null&&(d.updateQueue=null,Oy(d,_)));break;case 30:break;case 21:break;default:Yi(m,d),Ji(d)}}function Ji(d){var m=d.flags;if(m&2){try{for(var x,_=d.return;_!==null;){if(X5(_)){x=_;break}_=_.return}if(x==null)throw Error(s(160));switch(x.tag){case 27:var D=x.stateNode,F=Qj(d);Ay(d,F,D);break;case 5:var ue=x.stateNode;x.flags&32&&(js(ue,""),x.flags&=-33);var Ee=Qj(d);Ay(d,Ee,ue);break;case 3:case 4:var Ze=x.stateNode.containerInfo,_t=Qj(d);e_(d,_t,Ze);break;default:throw Error(s(161))}}catch(It){qa(d,d.return,It)}d.flags&=-3}m&4096&&(d.flags&=-4097)}function o6(d){if(d.subtreeFlags&1024)for(d=d.child;d!==null;){var m=d;o6(m),m.tag===5&&m.flags&1024&&m.stateNode.reset(),d=d.sibling}}function vd(d,m){if(m.subtreeFlags&8772)for(m=m.child;m!==null;)t6(d,m.alternate,m),m=m.sibling}function E0(d){for(d=d.child;d!==null;){var m=d;switch(m.tag){case 0:case 11:case 14:case 15:wu(4,m,m.return),E0(m);break;case 1:wc(m,m.return);var x=m.stateNode;typeof x.componentWillUnmount=="function"&&J5(m,m.return,x),E0(m);break;case 27:zg(m.stateNode);case 26:case 5:wc(m,m.return),E0(m);break;case 22:m.memoizedState===null&&E0(m);break;case 30:E0(m);break;default:E0(m)}d=d.sibling}}function wd(d,m,x){for(x=x&&(m.subtreeFlags&8772)!==0,m=m.child;m!==null;){var _=m.alternate,D=d,F=m,ue=F.flags;switch(F.tag){case 0:case 11:case 15:wd(D,F,x),Eg(4,F);break;case 1:if(wd(D,F,x),_=F,D=_.stateNode,typeof D.componentDidMount=="function")try{D.componentDidMount()}catch(_t){qa(_,_.return,_t)}if(_=F,D=_.updateQueue,D!==null){var Ee=_.stateNode;try{var Ze=D.shared.hiddenCallbacks;if(Ze!==null)for(D.shared.hiddenCallbacks=null,D=0;D<Ze.length;D++)IC(Ze[D],Ee)}catch(_t){qa(_,_.return,_t)}}x&&ue&64&&Y5(F),Ag(F,F.return);break;case 27:Q5(F);case 26:case 5:wd(D,F,x),x&&_===null&&ue&4&&Z5(F),Ag(F,F.return);break;case 12:wd(D,F,x);break;case 31:wd(D,F,x),x&&ue&4&&s6(D,F);break;case 13:wd(D,F,x),x&&ue&4&&n6(D,F);break;case 22:F.memoizedState===null&&wd(D,F,x),Ag(F,F.return);break;case 30:break;default:wd(D,F,x)}m=m.sibling}}function r_(d,m){var x=null;d!==null&&d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(x=d.memoizedState.cachePool.pool),d=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(d=m.memoizedState.cachePool.pool),d!==x&&(d!=null&&d.refCount++,x!=null&&fg(x))}function a_(d,m){d=null,m.alternate!==null&&(d=m.alternate.memoizedState.cache),m=m.memoizedState.cache,m!==d&&(m.refCount++,d!=null&&fg(d))}function zl(d,m,x,_){if(m.subtreeFlags&10256)for(m=m.child;m!==null;)l6(d,m,x,_),m=m.sibling}function l6(d,m,x,_){var D=m.flags;switch(m.tag){case 0:case 11:case 15:zl(d,m,x,_),D&2048&&Eg(9,m);break;case 1:zl(d,m,x,_);break;case 3:zl(d,m,x,_),D&2048&&(d=null,m.alternate!==null&&(d=m.alternate.memoizedState.cache),m=m.memoizedState.cache,m!==d&&(m.refCount++,d!=null&&fg(d)));break;case 12:if(D&2048){zl(d,m,x,_),d=m.stateNode;try{var F=m.memoizedProps,ue=F.id,Ee=F.onPostCommit;typeof Ee=="function"&&Ee(ue,m.alternate===null?"mount":"update",d.passiveEffectDuration,-0)}catch(Ze){qa(m,m.return,Ze)}}else zl(d,m,x,_);break;case 31:zl(d,m,x,_);break;case 13:zl(d,m,x,_);break;case 23:break;case 22:F=m.stateNode,ue=m.alternate,m.memoizedState!==null?F._visibility&2?zl(d,m,x,_):Og(d,m):F._visibility&2?zl(d,m,x,_):(F._visibility|=2,xh(d,m,x,_,(m.subtreeFlags&10256)!==0||!1)),D&2048&&r_(ue,m);break;case 24:zl(d,m,x,_),D&2048&&a_(m.alternate,m);break;default:zl(d,m,x,_)}}function xh(d,m,x,_,D){for(D=D&&((m.subtreeFlags&10256)!==0||!1),m=m.child;m!==null;){var F=d,ue=m,Ee=x,Ze=_,_t=ue.flags;switch(ue.tag){case 0:case 11:case 15:xh(F,ue,Ee,Ze,D),Eg(8,ue);break;case 23:break;case 22:var It=ue.stateNode;ue.memoizedState!==null?It._visibility&2?xh(F,ue,Ee,Ze,D):Og(F,ue):(It._visibility|=2,xh(F,ue,Ee,Ze,D)),D&&_t&2048&&r_(ue.alternate,ue);break;case 24:xh(F,ue,Ee,Ze,D),D&&_t&2048&&a_(ue.alternate,ue);break;default:xh(F,ue,Ee,Ze,D)}m=m.sibling}}function Og(d,m){if(m.subtreeFlags&10256)for(m=m.child;m!==null;){var x=d,_=m,D=_.flags;switch(_.tag){case 22:Og(x,_),D&2048&&r_(_.alternate,_);break;case 24:Og(x,_),D&2048&&a_(_.alternate,_);break;default:Og(x,_)}m=m.sibling}}var Pg=8192;function yh(d,m,x){if(d.subtreeFlags&Pg)for(d=d.child;d!==null;)c6(d,m,x),d=d.sibling}function c6(d,m,x){switch(d.tag){case 26:yh(d,m,x),d.flags&Pg&&d.memoizedState!==null&&lW(x,Il,d.memoizedState,d.memoizedProps);break;case 5:yh(d,m,x);break;case 3:case 4:var _=Il;Il=qy(d.stateNode.containerInfo),yh(d,m,x),Il=_;break;case 22:d.memoizedState===null&&(_=d.alternate,_!==null&&_.memoizedState!==null?(_=Pg,Pg=16777216,yh(d,m,x),Pg=_):yh(d,m,x));break;default:yh(d,m,x)}}function d6(d){var m=d.alternate;if(m!==null&&(d=m.child,d!==null)){m.child=null;do m=d.sibling,d.sibling=null,d=m;while(d!==null)}}function Dg(d){var m=d.deletions;if((d.flags&16)!==0){if(m!==null)for(var x=0;x<m.length;x++){var _=m[x];An=_,m6(_,d)}d6(d)}if(d.subtreeFlags&10256)for(d=d.child;d!==null;)u6(d),d=d.sibling}function u6(d){switch(d.tag){case 0:case 11:case 15:Dg(d),d.flags&2048&&wu(9,d,d.return);break;case 3:Dg(d);break;case 12:Dg(d);break;case 22:var m=d.stateNode;d.memoizedState!==null&&m._visibility&2&&(d.return===null||d.return.tag!==13)?(m._visibility&=-3,Py(d)):Dg(d);break;default:Dg(d)}}function Py(d){var m=d.deletions;if((d.flags&16)!==0){if(m!==null)for(var x=0;x<m.length;x++){var _=m[x];An=_,m6(_,d)}d6(d)}for(d=d.child;d!==null;){switch(m=d,m.tag){case 0:case 11:case 15:wu(8,m,m.return),Py(m);break;case 22:x=m.stateNode,x._visibility&2&&(x._visibility&=-3,Py(m));break;default:Py(m)}d=d.sibling}}function m6(d,m){for(;An!==null;){var x=An;switch(x.tag){case 0:case 11:case 15:wu(8,x,m);break;case 23:case 22:if(x.memoizedState!==null&&x.memoizedState.cachePool!==null){var _=x.memoizedState.cachePool.pool;_!=null&&_.refCount++}break;case 24:fg(x.memoizedState.cache)}if(_=x.child,_!==null)_.return=x,An=_;else e:for(x=d;An!==null;){_=An;var D=_.sibling,F=_.return;if(r6(_),_===x){An=null;break e}if(D!==null){D.return=F,An=D;break e}An=F}}}var _B={getCacheForType:function(d){var m=qn(Xs),x=m.data.get(d);return x===void 0&&(x=d(),m.data.set(d,x)),x},cacheSignal:function(){return qn(Xs).controller.signal}},kB=typeof WeakMap=="function"?WeakMap:Map,Fa=0,os=null,ga=null,ya=0,Ha=0,Co=null,ju=!1,bh=!1,s_=!1,jd=0,zs=0,_u=0,A0=0,n_=0,To=0,vh=0,Rg=null,Zi=null,i_=!1,Dy=0,h6=0,Ry=1/0,My=null,ku=null,xn=0,Nu=null,wh=null,_d=0,o_=0,l_=null,p6=null,Mg=0,c_=null;function Eo(){return(Fa&2)!==0&&ya!==0?ya&-ya:q.T!==null?g_():oe()}function g6(){if(To===0)if((ya&536870912)===0||pa){var d=Ot;Ot<<=1,(Ot&3932160)===0&&(Ot=262144),To=d}else To=536870912;return d=No.current,d!==null&&(d.flags|=32),To}function Xi(d,m,x){(d===os&&(Ha===2||Ha===9)||d.cancelPendingCommit!==null)&&(jh(d,0),Su(d,ya,To,!1)),Ae(d,x),((Fa&2)===0||d!==os)&&(d===os&&((Fa&2)===0&&(A0|=x),zs===4&&Su(d,ya,To,!1)),jc(d))}function f6(d,m,x){if((Fa&6)!==0)throw Error(s(327));var _=!x&&(m&127)===0&&(m&d.expiredLanes)===0||Gt(d,m),D=_?CB(d,m):u_(d,m,!0),F=_;do{if(D===0){bh&&!_&&Su(d,m,0,!1);break}else{if(x=d.current.alternate,F&&!NB(x)){D=u_(d,m,!1),F=!1;continue}if(D===2){if(F=m,d.errorRecoveryDisabledLanes&F)var ue=0;else ue=d.pendingLanes&-536870913,ue=ue!==0?ue:ue&536870912?536870912:0;if(ue!==0){m=ue;e:{var Ee=d;D=Rg;var Ze=Ee.current.memoizedState.isDehydrated;if(Ze&&(jh(Ee,ue).flags|=256),ue=u_(Ee,ue,!1),ue!==2){if(s_&&!Ze){Ee.errorRecoveryDisabledLanes|=F,A0|=F,D=4;break e}F=Zi,Zi=D,F!==null&&(Zi===null?Zi=F:Zi.push.apply(Zi,F))}D=ue}if(F=!1,D!==2)continue}}if(D===1){jh(d,0),Su(d,m,0,!0);break}e:{switch(_=d,F=D,F){case 0:case 1:throw Error(s(345));case 4:if((m&4194048)!==m)break;case 6:Su(_,m,To,!ju);break e;case 2:Zi=null;break;case 3:case 5:break;default:throw Error(s(329))}if((m&62914560)===m&&(D=Dy+300-jt(),10<D)){if(Su(_,m,To,!ju),Tt(_,0,!0)!==0)break e;_d=m,_.timeoutHandle=G6(x6.bind(null,_,x,Zi,My,i_,m,To,A0,vh,ju,F,"Throttled",-0,0),D);break e}x6(_,x,Zi,My,i_,m,To,A0,vh,ju,F,null,-0,0)}}break}while(!0);jc(d)}function x6(d,m,x,_,D,F,ue,Ee,Ze,_t,It,Vt,St,Rt){if(d.timeoutHandle=-1,Vt=m.subtreeFlags,Vt&8192||(Vt&16785408)===16785408){Vt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:gs},c6(m,F,Vt);var xr=(F&62914560)===F?Dy-jt():(F&4194048)===F?h6-jt():0;if(xr=cW(Vt,xr),xr!==null){_d=F,d.cancelPendingCommit=xr(N6.bind(null,d,m,F,x,_,D,ue,Ee,Ze,It,Vt,null,St,Rt)),Su(d,F,ue,!_t);return}}N6(d,m,F,x,_,D,ue,Ee,Ze)}function NB(d){for(var m=d;;){var x=m.tag;if((x===0||x===11||x===15)&&m.flags&16384&&(x=m.updateQueue,x!==null&&(x=x.stores,x!==null)))for(var _=0;_<x.length;_++){var D=x[_],F=D.getSnapshot;D=D.value;try{if(!Ls(F(),D))return!1}catch(ue){return!1}}if(x=m.child,m.subtreeFlags&16384&&x!==null)x.return=m,m=x;else{if(m===d)break;for(;m.sibling===null;){if(m.return===null||m.return===d)return!0;m=m.return}m.sibling.return=m.return,m=m.sibling}}return!0}function Su(d,m,x,_){m&=~n_,m&=~A0,d.suspendedLanes|=m,d.pingedLanes&=~m,_&&(d.warmLanes|=m),_=d.expirationTimes;for(var D=m;0<D;){var F=31-Ue(D),ue=1<<F;_[F]=-1,D&=~ue}x!==0&&Be(d,x,m)}function Ly(){return(Fa&6)===0?(Lg(0),!1):!0}function d_(){if(ga!==null){if(Ha===0)var d=ga.return;else d=ga,Fl=vc=null,Sj(d),mh=null,yg=0,d=ga;for(;d!==null;)K5(d.alternate,d),d=d.return;ga=null}}function jh(d,m){var x=d.timeoutHandle;x!==-1&&(d.timeoutHandle=-1,qB(x)),x=d.cancelPendingCommit,x!==null&&(d.cancelPendingCommit=null,x()),_d=0,d_(),os=d,ga=x=rl(d.current,null),ya=m,Ha=0,Co=null,ju=!1,bh=Gt(d,m),s_=!1,vh=To=n_=A0=_u=zs=0,Zi=Rg=null,i_=!1,(m&8)!==0&&(m|=m&32);var _=d.entangledLanes;if(_!==0)for(d=d.entanglements,_&=m;0<_;){var D=31-Ue(_),F=1<<D;m|=d[D],_&=~F}return jd=m,Zs(),x}function y6(d,m){Vr=null,q.H=Sg,m===uh||m===uy?(m=RC(),Ha=3):m===pj?(m=RC(),Ha=4):Ha=m===Bj?8:m!==null&&typeof m=="object"&&typeof m.then=="function"?6:1,Co=m,ga===null&&(zs=1,Ny(d,j(m,d.current)))}function b6(){var d=No.current;return d===null?!0:(ya&4194048)===ya?al===null:(ya&62914560)===ya||(ya&536870912)!==0?d===al:!1}function v6(){var d=q.H;return q.H=Sg,d===null?Sg:d}function w6(){var d=q.A;return q.A=_B,d}function Fy(){zs=4,ju||(ya&4194048)!==ya&&No.current!==null||(bh=!0),(_u&134217727)===0&&(A0&134217727)===0||os===null||Su(os,ya,To,!1)}function u_(d,m,x){var _=Fa;Fa|=2;var D=v6(),F=w6();(os!==d||ya!==m)&&(My=null,jh(d,m)),m=!1;var ue=zs;e:do try{if(Ha!==0&&ga!==null){var Ee=ga,Ze=Co;switch(Ha){case 8:d_(),ue=6;break e;case 3:case 2:case 9:case 6:No.current===null&&(m=!0);var _t=Ha;if(Ha=0,Co=null,_h(d,Ee,Ze,_t),x&&bh){ue=0;break e}break;default:_t=Ha,Ha=0,Co=null,_h(d,Ee,Ze,_t)}}SB(),ue=zs;break}catch(It){y6(d,It)}while(!0);return m&&d.shellSuspendCounter++,Fl=vc=null,Fa=_,q.H=D,q.A=F,ga===null&&(os=null,ya=0,Zs()),ue}function SB(){for(;ga!==null;)j6(ga)}function CB(d,m){var x=Fa;Fa|=2;var _=v6(),D=w6();os!==d||ya!==m?(My=null,Ry=jt()+500,jh(d,m)):bh=Gt(d,m);e:do try{if(Ha!==0&&ga!==null){m=ga;var F=Co;t:switch(Ha){case 1:Ha=0,Co=null,_h(d,m,F,1);break;case 2:case 9:if(PC(F)){Ha=0,Co=null,_6(m);break}m=function(){Ha!==2&&Ha!==9||os!==d||(Ha=7),jc(d)},F.then(m,m);break e;case 3:Ha=7;break e;case 4:Ha=5;break e;case 7:PC(F)?(Ha=0,Co=null,_6(m)):(Ha=0,Co=null,_h(d,m,F,7));break;case 5:var ue=null;switch(ga.tag){case 26:ue=ga.memoizedState;case 5:case 27:var Ee=ga;if(ue?lT(ue):Ee.stateNode.complete){Ha=0,Co=null;var Ze=Ee.sibling;if(Ze!==null)ga=Ze;else{var _t=Ee.return;_t!==null?(ga=_t,Iy(_t)):ga=null}break t}}Ha=0,Co=null,_h(d,m,F,5);break;case 6:Ha=0,Co=null,_h(d,m,F,6);break;case 8:d_(),zs=6;break e;default:throw Error(s(462))}}TB();break}catch(It){y6(d,It)}while(!0);return Fl=vc=null,q.H=_,q.A=D,Fa=x,ga!==null?0:(os=null,ya=0,Zs(),zs)}function TB(){for(;ga!==null&&!De();)j6(ga)}function j6(d){var m=V5(d.alternate,d,jd);d.memoizedProps=d.pendingProps,m===null?Iy(d):ga=m}function _6(d){var m=d,x=m.alternate;switch(m.tag){case 15:case 0:m=$5(x,m,m.pendingProps,m.type,void 0,ya);break;case 11:m=$5(x,m,m.pendingProps,m.type.render,m.ref,ya);break;case 5:Sj(m);default:K5(x,m),m=ga=ug(m,jd),m=V5(x,m,jd)}d.memoizedProps=d.pendingProps,m===null?Iy(d):ga=m}function _h(d,m,x,_){Fl=vc=null,Sj(m),mh=null,yg=0;var D=m.return;try{if(fB(d,D,m,x,ya)){zs=1,Ny(d,j(x,d.current)),ga=null;return}}catch(F){if(D!==null)throw ga=D,F;zs=1,Ny(d,j(x,d.current)),ga=null;return}m.flags&32768?(pa||_===1?d=!0:bh||(ya&536870912)!==0?d=!1:(ju=d=!0,(_===2||_===9||_===3||_===6)&&(_=No.current,_!==null&&_.tag===13&&(_.flags|=16384))),k6(m,d)):Iy(m)}function Iy(d){var m=d;do{if((m.flags&32768)!==0){k6(m,ju);return}d=m.return;var x=bB(m.alternate,m,jd);if(x!==null){ga=x;return}if(m=m.sibling,m!==null){ga=m;return}ga=m=d}while(m!==null);zs===0&&(zs=5)}function k6(d,m){do{var x=vB(d.alternate,d);if(x!==null){x.flags&=32767,ga=x;return}if(x=d.return,x!==null&&(x.flags|=32768,x.subtreeFlags=0,x.deletions=null),!m&&(d=d.sibling,d!==null)){ga=d;return}ga=d=x}while(d!==null);zs=6,ga=null}function N6(d,m,x,_,D,F,ue,Ee,Ze){d.cancelPendingCommit=null;do zy();while(xn!==0);if((Fa&6)!==0)throw Error(s(327));if(m!==null){if(m===d.current)throw Error(s(177));if(F=m.lanes|m.childLanes,F|=Ni,ke(d,x,F,ue,Ee,Ze),d===os&&(ga=os=null,ya=0),wh=m,Nu=d,_d=x,o_=F,l_=D,p6=_,(m.subtreeFlags&10256)!==0||(m.flags&10256)!==0?(d.callbackNode=null,d.callbackPriority=0,PB(at,function(){return A6(),null})):(d.callbackNode=null,d.callbackPriority=0),_=(m.flags&13878)!==0,(m.subtreeFlags&13878)!==0||_){_=q.T,q.T=null,D=H.p,H.p=2,ue=Fa,Fa|=4;try{wB(d,m,x)}finally{Fa=ue,H.p=D,q.T=_}}xn=1,S6(),C6(),T6()}}function S6(){if(xn===1){xn=0;var d=Nu,m=wh,x=(m.flags&13878)!==0;if((m.subtreeFlags&13878)!==0||x){x=q.T,q.T=null;var _=H.p;H.p=2;var D=Fa;Fa|=4;try{i6(m,d);var F=__,ue=od(d.containerInfo),Ee=F.focusedElem,Ze=F.selectionRange;if(ue!==Ee&&Ee&&Ee.ownerDocument&&x0(Ee.ownerDocument.documentElement,Ee)){if(Ze!==null&&Qo(Ee)){var _t=Ze.start,It=Ze.end;if(It===void 0&&(It=_t),"selectionStart"in Ee)Ee.selectionStart=_t,Ee.selectionEnd=Math.min(It,Ee.value.length);else{var Vt=Ee.ownerDocument||document,St=Vt&&Vt.defaultView||window;if(St.getSelection){var Rt=St.getSelection(),xr=Ee.textContent.length,Lr=Math.min(Ze.start,xr),ts=Ze.end===void 0?Lr:Math.min(Ze.end,xr);!Rt.extend&&Lr>ts&&(ue=ts,ts=Lr,Lr=ue);var gt=id(Ee,Lr),tt=id(Ee,ts);if(gt&&tt&&(Rt.rangeCount!==1||Rt.anchorNode!==gt.node||Rt.anchorOffset!==gt.offset||Rt.focusNode!==tt.node||Rt.focusOffset!==tt.offset)){var wt=Vt.createRange();wt.setStart(gt.node,gt.offset),Rt.removeAllRanges(),Lr>ts?(Rt.addRange(wt),Rt.extend(tt.node,tt.offset)):(wt.setEnd(tt.node,tt.offset),Rt.addRange(wt))}}}}for(Vt=[],Rt=Ee;Rt=Rt.parentNode;)Rt.nodeType===1&&Vt.push({element:Rt,left:Rt.scrollLeft,top:Rt.scrollTop});for(typeof Ee.focus=="function"&&Ee.focus(),Ee=0;Ee<Vt.length;Ee++){var Bt=Vt[Ee];Bt.element.scrollLeft=Bt.left,Bt.element.scrollTop=Bt.top}}Zy=!!j_,__=j_=null}finally{Fa=D,H.p=_,q.T=x}}d.current=m,xn=2}}function C6(){if(xn===2){xn=0;var d=Nu,m=wh,x=(m.flags&8772)!==0;if((m.subtreeFlags&8772)!==0||x){x=q.T,q.T=null;var _=H.p;H.p=2;var D=Fa;Fa|=4;try{t6(d,m.alternate,m)}finally{Fa=D,H.p=_,q.T=x}}xn=3}}function T6(){if(xn===4||xn===3){xn=0,Et();var d=Nu,m=wh,x=_d,_=p6;(m.subtreeFlags&10256)!==0||(m.flags&10256)!==0?xn=5:(xn=0,wh=Nu=null,E6(d,d.pendingLanes));var D=d.pendingLanes;if(D===0&&(ku=null),Xe(x),m=m.stateNode,He&&typeof He.onCommitFiberRoot=="function")try{He.onCommitFiberRoot(dt,m,void 0,(m.current.flags&128)===128)}catch(Ze){}if(_!==null){m=q.T,D=H.p,H.p=2,q.T=null;try{for(var F=d.onRecoverableError,ue=0;ue<_.length;ue++){var Ee=_[ue];F(Ee.value,{componentStack:Ee.stack})}}finally{q.T=m,H.p=D}}(_d&3)!==0&&zy(),jc(d),D=d.pendingLanes,(x&261930)!==0&&(D&42)!==0?d===c_?Mg++:(Mg=0,c_=d):Mg=0,Lg(0)}}function E6(d,m){(d.pooledCacheLanes&=m)===0&&(m=d.pooledCache,m!=null&&(d.pooledCache=null,fg(m)))}function zy(){return S6(),C6(),T6(),A6()}function A6(){if(xn!==5)return!1;var d=Nu,m=o_;o_=0;var x=Xe(_d),_=q.T,D=H.p;try{H.p=32>x?32:x,q.T=null,x=l_,l_=null;var F=Nu,ue=_d;if(xn=0,wh=Nu=null,_d=0,(Fa&6)!==0)throw Error(s(331));var Ee=Fa;if(Fa|=4,u6(F.current),l6(F,F.current,ue,x),Fa=Ee,Lg(0,!1),He&&typeof He.onPostCommitFiberRoot=="function")try{He.onPostCommitFiberRoot(dt,F)}catch(Ze){}return!0}finally{H.p=D,q.T=_,E6(d,m)}}function O6(d,m,x){m=j(x,m),m=Uj(d.stateNode,m,2),d=yu(d,m,2),d!==null&&(Ae(d,2),jc(d))}function qa(d,m,x){if(d.tag===3)O6(d,d,x);else for(;m!==null;){if(m.tag===3){O6(m,d,x);break}else if(m.tag===1){var _=m.stateNode;if(typeof m.type.getDerivedStateFromError=="function"||typeof _.componentDidCatch=="function"&&(ku===null||!ku.has(_))){d=j(x,d),x=P5(2),_=yu(m,x,2),_!==null&&(D5(x,_,m,d),Ae(_,2),jc(_));break}}m=m.return}}function m_(d,m,x){var _=d.pingCache;if(_===null){_=d.pingCache=new kB;var D=new Set;_.set(m,D)}else D=_.get(m),D===void 0&&(D=new Set,_.set(m,D));D.has(x)||(s_=!0,D.add(x),d=EB.bind(null,d,m,x),m.then(d,d))}function EB(d,m,x){var _=d.pingCache;_!==null&&_.delete(m),d.pingedLanes|=d.suspendedLanes&x,d.warmLanes&=~x,os===d&&(ya&x)===x&&(zs===4||zs===3&&(ya&62914560)===ya&&300>jt()-Dy?(Fa&2)===0&&jh(d,0):n_|=x,vh===ya&&(vh=0)),jc(d)}function P6(d,m){m===0&&(m=kt()),d=_s(d,m),d!==null&&(Ae(d,m),jc(d))}function AB(d){var m=d.memoizedState,x=0;m!==null&&(x=m.retryLane),P6(d,x)}function OB(d,m){var x=0;switch(d.tag){case 31:case 13:var _=d.stateNode,D=d.memoizedState;D!==null&&(x=D.retryLane);break;case 19:_=d.stateNode;break;case 22:_=d.stateNode._retryCache;break;default:throw Error(s(314))}_!==null&&_.delete(m),P6(d,x)}function PB(d,m){return ze(d,m)}var $y=null,kh=null,h_=!1,Uy=!1,p_=!1,Cu=0;function jc(d){d!==kh&&d.next===null&&(kh===null?$y=kh=d:kh=kh.next=d),Uy=!0,h_||(h_=!0,RB())}function Lg(d,m){if(!p_&&Uy){p_=!0;do for(var x=!1,_=$y;_!==null;){if(d!==0){var D=_.pendingLanes;if(D===0)var F=0;else{var ue=_.suspendedLanes,Ee=_.pingedLanes;F=(1<<31-Ue(42|d)+1)-1,F&=D&~(ue&~Ee),F=F&201326741?F&201326741|1:F?F|2:0}F!==0&&(x=!0,L6(_,F))}else F=ya,F=Tt(_,_===os?F:0,_.cancelPendingCommit!==null||_.timeoutHandle!==-1),(F&3)===0||Gt(_,F)||(x=!0,L6(_,F));_=_.next}while(x);p_=!1}}function DB(){D6()}function D6(){Uy=h_=!1;var d=0;Cu!==0&&HB()&&(d=Cu);for(var m=jt(),x=null,_=$y;_!==null;){var D=_.next,F=R6(_,m);F===0?(_.next=null,x===null?$y=D:x.next=D,D===null&&(kh=x)):(x=_,(d!==0||(F&3)!==0)&&(Uy=!0)),_=D}xn!==0&&xn!==5||Lg(d),Cu!==0&&(Cu=0)}function R6(d,m){for(var x=d.suspendedLanes,_=d.pingedLanes,D=d.expirationTimes,F=d.pendingLanes&-62914561;0<F;){var ue=31-Ue(F),Ee=1<<ue,Ze=D[ue];Ze===-1?((Ee&x)===0||(Ee&_)!==0)&&(D[ue]=Ye(Ee,m)):Ze<=m&&(d.expiredLanes|=Ee),F&=~Ee}if(m=os,x=ya,x=Tt(d,d===m?x:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),_=d.callbackNode,x===0||d===m&&(Ha===2||Ha===9)||d.cancelPendingCommit!==null)return _!==null&&_!==null&&Re(_),d.callbackNode=null,d.callbackPriority=0;if((x&3)===0||Gt(d,x)){if(m=x&-x,m===d.callbackPriority)return m;switch(_!==null&&Re(_),Xe(x)){case 2:case 8:x=Qe;break;case 32:x=at;break;case 268435456:x=vt;break;default:x=at}return _=M6.bind(null,d),x=ze(x,_),d.callbackPriority=m,d.callbackNode=x,m}return _!==null&&_!==null&&Re(_),d.callbackPriority=2,d.callbackNode=null,2}function M6(d,m){if(xn!==0&&xn!==5)return d.callbackNode=null,d.callbackPriority=0,null;var x=d.callbackNode;if(zy()&&d.callbackNode!==x)return null;var _=ya;return _=Tt(d,d===os?_:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),_===0?null:(f6(d,_,m),R6(d,jt()),d.callbackNode!=null&&d.callbackNode===x?M6.bind(null,d):null)}function L6(d,m){if(zy())return null;f6(d,m,!0)}function RB(){VB(function(){(Fa&6)!==0?ze($e,DB):D6()})}function g_(){if(Cu===0){var d=ch;d===0&&(d=Mt,Mt<<=1,(Mt&261888)===0&&(Mt=256)),Cu=d}return Cu}function F6(d){return d==null||typeof d=="symbol"||typeof d=="boolean"?null:typeof d=="function"?d:Yo(""+d)}function I6(d,m){var x=m.ownerDocument.createElement("input");return x.name=m.name,x.value=m.value,d.id&&x.setAttribute("form",d.id),m.parentNode.insertBefore(x,m),d=new FormData(d),x.parentNode.removeChild(x),d}function MB(d,m,x,_,D){if(m==="submit"&&x&&x.stateNode===D){var F=F6((D[Ce]||null).action),ue=_.submitter;ue&&(m=(m=ue[Ce]||null)?F6(m.formAction):ue.getAttribute("formAction"),m!==null&&(F=m,ue=null));var Ee=new Gc("action","action",null,_,D);d.push({event:Ee,listeners:[{instance:null,listener:function(){if(_.defaultPrevented){if(Cu!==0){var Ze=ue?I6(D,ue):new FormData(D);Mj(x,{pending:!0,data:Ze,method:D.method,action:F},null,Ze)}}else typeof F=="function"&&(Ee.preventDefault(),Ze=ue?I6(D,ue):new FormData(D),Mj(x,{pending:!0,data:Ze,method:D.method,action:F},F,Ze))},currentTarget:D}]})}}for(var f_=0;f_<fs.length;f_++){var x_=fs[f_],LB=x_.toLowerCase(),FB=x_[0].toUpperCase()+x_.slice(1);is(LB,"on"+FB)}is(qe,"onAnimationEnd"),is(Kt,"onAnimationIteration"),is(lr,"onAnimationStart"),is("dblclick","onDoubleClick"),is("focusin","onFocus"),is("focusout","onBlur"),is(Ht,"onTransitionRun"),is(jr,"onTransitionStart"),is(ra,"onTransitionCancel"),is(ns,"onTransitionEnd"),ma("onMouseEnter",["mouseout","mouseover"]),ma("onMouseLeave",["mouseout","mouseover"]),ma("onPointerEnter",["pointerout","pointerover"]),ma("onPointerLeave",["pointerout","pointerover"]),Yr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Yr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Yr("onBeforeInput",["compositionend","keypress","textInput","paste"]),Yr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Yr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Yr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Fg="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(" "),IB=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Fg));function z6(d,m){m=(m&4)!==0;for(var x=0;x<d.length;x++){var _=d[x],D=_.event;_=_.listeners;e:{var F=void 0;if(m)for(var ue=_.length-1;0<=ue;ue--){var Ee=_[ue],Ze=Ee.instance,_t=Ee.currentTarget;if(Ee=Ee.listener,Ze!==F&&D.isPropagationStopped())break e;F=Ee,D.currentTarget=_t;try{F(D)}catch(It){Es(It)}D.currentTarget=null,F=Ze}else for(ue=0;ue<_.length;ue++){if(Ee=_[ue],Ze=Ee.instance,_t=Ee.currentTarget,Ee=Ee.listener,Ze!==F&&D.isPropagationStopped())break e;F=Ee,D.currentTarget=_t;try{F(D)}catch(It){Es(It)}D.currentTarget=null,F=Ze}}}}function fa(d,m){var x=m[rt];x===void 0&&(x=m[rt]=new Set);var _=d+"__bubble";x.has(_)||($6(m,d,2,!1),x.add(_))}function y_(d,m,x){var _=0;m&&(_|=4),$6(x,d,_,m)}var By="_reactListening"+Math.random().toString(36).slice(2);function b_(d){if(!d[By]){d[By]=!0,Mr.forEach(function(x){x!=="selectionchange"&&(IB.has(x)||y_(x,!1,d),y_(x,!0,d))});var m=d.nodeType===9?d:d.ownerDocument;m===null||m[By]||(m[By]=!0,y_("selectionchange",!1,m))}}function $6(d,m,x,_){switch(gT(m)){case 2:var D=mW;break;case 8:D=hW;break;default:D=R_}x=D.bind(null,m,x,d),D=void 0,!Wn||m!=="touchstart"&&m!=="touchmove"&&m!=="wheel"||(D=!0),_?D!==void 0?d.addEventListener(m,x,{capture:!0,passive:D}):d.addEventListener(m,x,!0):D!==void 0?d.addEventListener(m,x,{passive:D}):d.addEventListener(m,x,!1)}function v_(d,m,x,_,D){var F=_;if((m&1)===0&&(m&2)===0&&_!==null)e:for(;;){if(_===null)return;var ue=_.tag;if(ue===3||ue===4){var Ee=_.stateNode.containerInfo;if(Ee===D)break;if(ue===4)for(ue=_.return;ue!==null;){var Ze=ue.tag;if((Ze===3||Ze===4)&&ue.stateNode.containerInfo===D)return;ue=ue.return}for(;Ee!==null;){if(ue=Ut(Ee),ue===null)return;if(Ze=ue.tag,Ze===5||Ze===6||Ze===26||Ze===27){_=F=ue;continue e}Ee=Ee.parentNode}}_=_.return}Ts(function(){var _t=F,It=Lt(x),Vt=[];e:{var St=ha.get(d);if(St!==void 0){var Rt=Gc,xr=d;switch(d){case"keypress":if(Jo(x)===0)break e;case"keydown":case"keyup":Rt=Ym;break;case"focusin":xr="focus",Rt=wo;break;case"focusout":xr="blur",Rt=wo;break;case"beforeblur":case"afterblur":Rt=wo;break;case"click":if(x.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Rt=Km;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Rt=ng;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Rt=lg;break;case qe:case Kt:case lr:Rt=Jc;break;case ns:Rt=Xm;break;case"scroll":case"scrollend":Rt=la;break;case"wheel":Rt=El;break;case"copy":case"cut":case"paste":Rt=zi;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Rt=Jm;break;case"toggle":case"beforetoggle":Rt=Xc}var Lr=(m&4)!==0,ts=!Lr&&(d==="scroll"||d==="scrollend"),gt=Lr?St!==null?St+"Capture":null:St;Lr=[];for(var tt=_t,wt;tt!==null;){var Bt=tt;if(wt=Bt.stateNode,Bt=Bt.tag,Bt!==5&&Bt!==26&&Bt!==27||wt===null||gt===null||(Bt=ki(tt,gt),Bt!=null&&Lr.push(Ig(tt,Bt,wt))),ts)break;tt=tt.return}0<Lr.length&&(St=new Rt(St,xr,null,x,It),Vt.push({event:St,listeners:Lr}))}}if((m&7)===0){e:{if(St=d==="mouseover"||d==="pointerover",Rt=d==="mouseout"||d==="pointerout",St&&x!==ot&&(xr=x.relatedTarget||x.fromElement)&&(Ut(xr)||xr[Pe]))break e;if((Rt||St)&&(St=It.window===It?It:(St=It.ownerDocument)?St.defaultView||St.parentWindow:window,Rt?(xr=x.relatedTarget||x.toElement,Rt=_t,xr=xr?Ut(xr):null,xr!==null&&(ts=i(xr),Lr=xr.tag,xr!==ts||Lr!==5&&Lr!==27&&Lr!==6)&&(xr=null)):(Rt=null,xr=_t),Rt!==xr)){if(Lr=Km,Bt="onMouseLeave",gt="onMouseEnter",tt="mouse",(d==="pointerout"||d==="pointerover")&&(Lr=Jm,Bt="onPointerLeave",gt="onPointerEnter",tt="pointer"),ts=Rt==null?St:pt(Rt),wt=xr==null?St:pt(xr),St=new Lr(Bt,tt+"leave",Rt,x,It),St.target=ts,St.relatedTarget=wt,Bt=null,Ut(It)===_t&&(Lr=new Lr(gt,tt+"enter",xr,x,It),Lr.target=wt,Lr.relatedTarget=ts,Bt=Lr),ts=Bt,Rt&&xr)t:{for(Lr=zB,gt=Rt,tt=xr,wt=0,Bt=gt;Bt;Bt=Lr(Bt))wt++;Bt=0;for(var Pr=tt;Pr;Pr=Lr(Pr))Bt++;for(;0<wt-Bt;)gt=Lr(gt),wt--;for(;0<Bt-wt;)tt=Lr(tt),Bt--;for(;wt--;){if(gt===tt||tt!==null&>===tt.alternate){Lr=gt;break t}gt=Lr(gt),tt=Lr(tt)}Lr=null}else Lr=null;Rt!==null&&U6(Vt,St,Rt,Lr,!1),xr!==null&&ts!==null&&U6(Vt,ts,xr,Lr,!0)}}e:{if(St=_t?pt(_t):window,Rt=St.nodeName&&St.nodeName.toLowerCase(),Rt==="select"||Rt==="input"&&St.type==="file")var Aa=ad;else if(Ui(St))if(sd)Aa=qi;else{Aa=mu;var Nr=Hi}else Rt=St.nodeName,!Rt||Rt.toLowerCase()!=="input"||St.type!=="checkbox"&&St.type!=="radio"?_t&&Ko(_t.elementType)&&(Aa=ad):Aa=xc;if(Aa&&(Aa=Aa(d,_t))){th(Vt,Aa,x,It);break e}Nr&&Nr(d,St,_t),d==="focusout"&&_t&&St.type==="number"&&_t.memoizedProps.value!=null&&Ba(St,"number",St.value)}switch(Nr=_t?pt(_t):window,d){case"focusin":(Ui(Nr)||Nr.contentEditable==="true")&&(el=Nr,ld=_t,Dl=null);break;case"focusout":Dl=ld=el=null;break;case"mousedown":tl=!0;break;case"contextmenu":case"mouseup":case"dragend":tl=!1,sh(Vt,x,It);break;case"selectionchange":if(pu)break;case"keydown":case"keyup":sh(Vt,x,It)}var Zr;if(Qc)e:{switch(d){case"compositionstart":var ba="onCompositionStart";break e;case"compositionend":ba="onCompositionEnd";break e;case"compositionupdate":ba="onCompositionUpdate";break e}ba=void 0}else Ol?eh(d,x)&&(ba="onCompositionEnd"):d==="keydown"&&x.keyCode===229&&(ba="onCompositionStart");ba&&(Al&&x.locale!=="ko"&&(Ol||ba!=="onCompositionStart"?ba==="onCompositionEnd"&&Ol&&(Zr=ni()):(Hn=It,yo="value"in Hn?Hn.value:Hn.textContent,Ol=!0)),Nr=Wy(_t,ba),0<Nr.length&&(ba=new m0(ba,d,null,x,It),Vt.push({event:ba,listeners:Nr}),Zr?ba.data=Zr:(Zr=f0(x),Zr!==null&&(ba.data=Zr)))),(Zr=g0?ka(d,x):Pl(d,x))&&(ba=Wy(_t,"onBeforeInput"),0<ba.length&&(Nr=new m0("onBeforeInput","beforeinput",null,x,It),Vt.push({event:Nr,listeners:ba}),Nr.data=Zr)),MB(Vt,d,_t,x,It)}z6(Vt,m)})}function Ig(d,m,x){return{instance:d,listener:m,currentTarget:x}}function Wy(d,m){for(var x=m+"Capture",_=[];d!==null;){var D=d,F=D.stateNode;if(D=D.tag,D!==5&&D!==26&&D!==27||F===null||(D=ki(d,x),D!=null&&_.unshift(Ig(d,D,F)),D=ki(d,m),D!=null&&_.push(Ig(d,D,F))),d.tag===3)return _;d=d.return}return[]}function zB(d){if(d===null)return null;do d=d.return;while(d&&d.tag!==5&&d.tag!==27);return d||null}function U6(d,m,x,_,D){for(var F=m._reactName,ue=[];x!==null&&x!==_;){var Ee=x,Ze=Ee.alternate,_t=Ee.stateNode;if(Ee=Ee.tag,Ze!==null&&Ze===_)break;Ee!==5&&Ee!==26&&Ee!==27||_t===null||(Ze=_t,D?(_t=ki(x,F),_t!=null&&ue.unshift(Ig(x,_t,Ze))):D||(_t=ki(x,F),_t!=null&&ue.push(Ig(x,_t,Ze)))),x=x.return}ue.length!==0&&d.push({event:m,listeners:ue})}var $B=/\r\n?/g,UB=/\u0000|\uFFFD/g;function B6(d){return(typeof d=="string"?d:""+d).replace($B,`
|
||
`).replace(UB,"")}function W6(d,m){return m=B6(m),B6(d)===m}function es(d,m,x,_,D,F){switch(x){case"children":typeof _=="string"?m==="body"||m==="textarea"&&_===""||js(d,_):(typeof _=="number"||typeof _=="bigint")&&m!=="body"&&js(d,""+_);break;case"className":Ir(d,"class",_);break;case"tabIndex":Ir(d,"tabindex",_);break;case"dir":case"role":case"viewBox":case"width":case"height":Ir(d,x,_);break;case"style":Go(d,_,F);break;case"data":if(m!=="object"){Ir(d,"data",_);break}case"src":case"href":if(_===""&&(m!=="a"||x!=="href")){d.removeAttribute(x);break}if(_==null||typeof _=="function"||typeof _=="symbol"||typeof _=="boolean"){d.removeAttribute(x);break}_=Yo(""+_),d.setAttribute(x,_);break;case"action":case"formAction":if(typeof _=="function"){d.setAttribute(x,"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 F=="function"&&(x==="formAction"?(m!=="input"&&es(d,m,"name",D.name,D,null),es(d,m,"formEncType",D.formEncType,D,null),es(d,m,"formMethod",D.formMethod,D,null),es(d,m,"formTarget",D.formTarget,D,null)):(es(d,m,"encType",D.encType,D,null),es(d,m,"method",D.method,D,null),es(d,m,"target",D.target,D,null)));if(_==null||typeof _=="symbol"||typeof _=="boolean"){d.removeAttribute(x);break}_=Yo(""+_),d.setAttribute(x,_);break;case"onClick":_!=null&&(d.onclick=gs);break;case"onScroll":_!=null&&fa("scroll",d);break;case"onScrollEnd":_!=null&&fa("scrollend",d);break;case"dangerouslySetInnerHTML":if(_!=null){if(typeof _!="object"||!("__html"in _))throw Error(s(61));if(x=_.__html,x!=null){if(D.children!=null)throw Error(s(60));d.innerHTML=x}}break;case"multiple":d.multiple=_&&typeof _!="function"&&typeof _!="symbol";break;case"muted":d.muted=_&&typeof _!="function"&&typeof _!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(_==null||typeof _=="function"||typeof _=="boolean"||typeof _=="symbol"){d.removeAttribute("xlink:href");break}x=Yo(""+_),d.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",x);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":_!=null&&typeof _!="function"&&typeof _!="symbol"?d.setAttribute(x,""+_):d.removeAttribute(x);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":_&&typeof _!="function"&&typeof _!="symbol"?d.setAttribute(x,""):d.removeAttribute(x);break;case"capture":case"download":_===!0?d.setAttribute(x,""):_!==!1&&_!=null&&typeof _!="function"&&typeof _!="symbol"?d.setAttribute(x,_):d.removeAttribute(x);break;case"cols":case"rows":case"size":case"span":_!=null&&typeof _!="function"&&typeof _!="symbol"&&!isNaN(_)&&1<=_?d.setAttribute(x,_):d.removeAttribute(x);break;case"rowSpan":case"start":_==null||typeof _=="function"||typeof _=="symbol"||isNaN(_)?d.removeAttribute(x):d.setAttribute(x,_);break;case"popover":fa("beforetoggle",d),fa("toggle",d),Tr(d,"popover",_);break;case"xlinkActuate":ws(d,"http://www.w3.org/1999/xlink","xlink:actuate",_);break;case"xlinkArcrole":ws(d,"http://www.w3.org/1999/xlink","xlink:arcrole",_);break;case"xlinkRole":ws(d,"http://www.w3.org/1999/xlink","xlink:role",_);break;case"xlinkShow":ws(d,"http://www.w3.org/1999/xlink","xlink:show",_);break;case"xlinkTitle":ws(d,"http://www.w3.org/1999/xlink","xlink:title",_);break;case"xlinkType":ws(d,"http://www.w3.org/1999/xlink","xlink:type",_);break;case"xmlBase":ws(d,"http://www.w3.org/XML/1998/namespace","xml:base",_);break;case"xmlLang":ws(d,"http://www.w3.org/XML/1998/namespace","xml:lang",_);break;case"xmlSpace":ws(d,"http://www.w3.org/XML/1998/namespace","xml:space",_);break;case"is":Tr(d,"is",_);break;case"innerText":case"textContent":break;default:(!(2<x.length)||x[0]!=="o"&&x[0]!=="O"||x[1]!=="n"&&x[1]!=="N")&&(x=Sl.get(x)||x,Tr(d,x,_))}}function w_(d,m,x,_,D,F){switch(x){case"style":Go(d,_,F);break;case"dangerouslySetInnerHTML":if(_!=null){if(typeof _!="object"||!("__html"in _))throw Error(s(61));if(x=_.__html,x!=null){if(D.children!=null)throw Error(s(60));d.innerHTML=x}}break;case"children":typeof _=="string"?js(d,_):(typeof _=="number"||typeof _=="bigint")&&js(d,""+_);break;case"onScroll":_!=null&&fa("scroll",d);break;case"onScrollEnd":_!=null&&fa("scrollend",d);break;case"onClick":_!=null&&(d.onclick=gs);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Br.hasOwnProperty(x))e:{if(x[0]==="o"&&x[1]==="n"&&(D=x.endsWith("Capture"),m=x.slice(2,D?x.length-7:void 0),F=d[Ce]||null,F=F!=null?F[x]:null,typeof F=="function"&&d.removeEventListener(m,F,D),typeof _=="function")){typeof F!="function"&&F!==null&&(x in d?d[x]=null:d.hasAttribute(x)&&d.removeAttribute(x)),d.addEventListener(m,_,D);break e}x in d?d[x]=_:_===!0?d.setAttribute(x,""):Tr(d,x,_)}}}function Gn(d,m,x){switch(m){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":fa("error",d),fa("load",d);var _=!1,D=!1,F;for(F in x)if(x.hasOwnProperty(F)){var ue=x[F];if(ue!=null)switch(F){case"src":_=!0;break;case"srcSet":D=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,m));default:es(d,m,F,ue,x,null)}}D&&es(d,m,"srcSet",x.srcSet,x,null),_&&es(d,m,"src",x.src,x,null);return;case"input":fa("invalid",d);var Ee=F=ue=D=null,Ze=null,_t=null;for(_ in x)if(x.hasOwnProperty(_)){var It=x[_];if(It!=null)switch(_){case"name":D=It;break;case"type":ue=It;break;case"checked":Ze=It;break;case"defaultChecked":_t=It;break;case"value":F=It;break;case"defaultValue":Ee=It;break;case"children":case"dangerouslySetInnerHTML":if(It!=null)throw Error(s(137,m));break;default:es(d,m,_,It,x,null)}}Bn(d,F,Ee,Ze,_t,ue,D,!1);return;case"select":fa("invalid",d),_=ue=F=null;for(D in x)if(x.hasOwnProperty(D)&&(Ee=x[D],Ee!=null))switch(D){case"value":F=Ee;break;case"defaultValue":ue=Ee;break;case"multiple":_=Ee;default:es(d,m,D,Ee,x,null)}m=F,x=ue,d.multiple=!!_,m!=null?Sr(d,!!_,m,!1):x!=null&&Sr(d,!!_,x,!0);return;case"textarea":fa("invalid",d),F=D=_=null;for(ue in x)if(x.hasOwnProperty(ue)&&(Ee=x[ue],Ee!=null))switch(ue){case"value":_=Ee;break;case"defaultValue":D=Ee;break;case"children":F=Ee;break;case"dangerouslySetInnerHTML":if(Ee!=null)throw Error(s(91));break;default:es(d,m,ue,Ee,x,null)}_i(d,_,D,F);return;case"option":for(Ze in x)if(x.hasOwnProperty(Ze)&&(_=x[Ze],_!=null))switch(Ze){case"selected":d.selected=_&&typeof _!="function"&&typeof _!="symbol";break;default:es(d,m,Ze,_,x,null)}return;case"dialog":fa("beforetoggle",d),fa("toggle",d),fa("cancel",d),fa("close",d);break;case"iframe":case"object":fa("load",d);break;case"video":case"audio":for(_=0;_<Fg.length;_++)fa(Fg[_],d);break;case"image":fa("error",d),fa("load",d);break;case"details":fa("toggle",d);break;case"embed":case"source":case"link":fa("error",d),fa("load",d);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(_t in x)if(x.hasOwnProperty(_t)&&(_=x[_t],_!=null))switch(_t){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,m));default:es(d,m,_t,_,x,null)}return;default:if(Ko(m)){for(It in x)x.hasOwnProperty(It)&&(_=x[It],_!==void 0&&w_(d,m,It,_,x,void 0));return}}for(Ee in x)x.hasOwnProperty(Ee)&&(_=x[Ee],_!=null&&es(d,m,Ee,_,x,null))}function BB(d,m,x,_){switch(m){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var D=null,F=null,ue=null,Ee=null,Ze=null,_t=null,It=null;for(Rt in x){var Vt=x[Rt];if(x.hasOwnProperty(Rt)&&Vt!=null)switch(Rt){case"checked":break;case"value":break;case"defaultValue":Ze=Vt;default:_.hasOwnProperty(Rt)||es(d,m,Rt,null,_,Vt)}}for(var St in _){var Rt=_[St];if(Vt=x[St],_.hasOwnProperty(St)&&(Rt!=null||Vt!=null))switch(St){case"type":F=Rt;break;case"name":D=Rt;break;case"checked":_t=Rt;break;case"defaultChecked":It=Rt;break;case"value":ue=Rt;break;case"defaultValue":Ee=Rt;break;case"children":case"dangerouslySetInnerHTML":if(Rt!=null)throw Error(s(137,m));break;default:Rt!==Vt&&es(d,m,St,Rt,_,Vt)}}us(d,ue,Ee,Ze,_t,It,F,D);return;case"select":Rt=ue=Ee=St=null;for(F in x)if(Ze=x[F],x.hasOwnProperty(F)&&Ze!=null)switch(F){case"value":break;case"multiple":Rt=Ze;default:_.hasOwnProperty(F)||es(d,m,F,null,_,Ze)}for(D in _)if(F=_[D],Ze=x[D],_.hasOwnProperty(D)&&(F!=null||Ze!=null))switch(D){case"value":St=F;break;case"defaultValue":Ee=F;break;case"multiple":ue=F;default:F!==Ze&&es(d,m,D,F,_,Ze)}m=Ee,x=ue,_=Rt,St!=null?Sr(d,!!x,St,!1):!!_!=!!x&&(m!=null?Sr(d,!!x,m,!0):Sr(d,!!x,x?[]:"",!1));return;case"textarea":Rt=St=null;for(Ee in x)if(D=x[Ee],x.hasOwnProperty(Ee)&&D!=null&&!_.hasOwnProperty(Ee))switch(Ee){case"value":break;case"children":break;default:es(d,m,Ee,null,_,D)}for(ue in _)if(D=_[ue],F=x[ue],_.hasOwnProperty(ue)&&(D!=null||F!=null))switch(ue){case"value":St=D;break;case"defaultValue":Rt=D;break;case"children":break;case"dangerouslySetInnerHTML":if(D!=null)throw Error(s(91));break;default:D!==F&&es(d,m,ue,D,_,F)}ji(d,St,Rt);return;case"option":for(var xr in x)if(St=x[xr],x.hasOwnProperty(xr)&&St!=null&&!_.hasOwnProperty(xr))switch(xr){case"selected":d.selected=!1;break;default:es(d,m,xr,null,_,St)}for(Ze in _)if(St=_[Ze],Rt=x[Ze],_.hasOwnProperty(Ze)&&St!==Rt&&(St!=null||Rt!=null))switch(Ze){case"selected":d.selected=St&&typeof St!="function"&&typeof St!="symbol";break;default:es(d,m,Ze,St,_,Rt)}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 Lr in x)St=x[Lr],x.hasOwnProperty(Lr)&&St!=null&&!_.hasOwnProperty(Lr)&&es(d,m,Lr,null,_,St);for(_t in _)if(St=_[_t],Rt=x[_t],_.hasOwnProperty(_t)&&St!==Rt&&(St!=null||Rt!=null))switch(_t){case"children":case"dangerouslySetInnerHTML":if(St!=null)throw Error(s(137,m));break;default:es(d,m,_t,St,_,Rt)}return;default:if(Ko(m)){for(var ts in x)St=x[ts],x.hasOwnProperty(ts)&&St!==void 0&&!_.hasOwnProperty(ts)&&w_(d,m,ts,void 0,_,St);for(It in _)St=_[It],Rt=x[It],!_.hasOwnProperty(It)||St===Rt||St===void 0&&Rt===void 0||w_(d,m,It,St,_,Rt);return}}for(var gt in x)St=x[gt],x.hasOwnProperty(gt)&&St!=null&&!_.hasOwnProperty(gt)&&es(d,m,gt,null,_,St);for(Vt in _)St=_[Vt],Rt=x[Vt],!_.hasOwnProperty(Vt)||St===Rt||St==null&&Rt==null||es(d,m,Vt,St,_,Rt)}function H6(d){switch(d){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function WB(){if(typeof performance.getEntriesByType=="function"){for(var d=0,m=0,x=performance.getEntriesByType("resource"),_=0;_<x.length;_++){var D=x[_],F=D.transferSize,ue=D.initiatorType,Ee=D.duration;if(F&&Ee&&H6(ue)){for(ue=0,Ee=D.responseEnd,_+=1;_<x.length;_++){var Ze=x[_],_t=Ze.startTime;if(_t>Ee)break;var It=Ze.transferSize,Vt=Ze.initiatorType;It&&H6(Vt)&&(Ze=Ze.responseEnd,ue+=It*(Ze<Ee?1:(Ee-_t)/(Ze-_t)))}if(--_,m+=8*(F+ue)/(D.duration/1e3),d++,10<d)break}}if(0<d)return m/d/1e6}return navigator.connection&&(d=navigator.connection.downlink,typeof d=="number")?d:5}var j_=null,__=null;function Hy(d){return d.nodeType===9?d:d.ownerDocument}function q6(d){switch(d){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function V6(d,m){if(d===0)switch(m){case"svg":return 1;case"math":return 2;default:return 0}return d===1&&m==="foreignObject"?0:d}function k_(d,m){return d==="textarea"||d==="noscript"||typeof m.children=="string"||typeof m.children=="number"||typeof m.children=="bigint"||typeof m.dangerouslySetInnerHTML=="object"&&m.dangerouslySetInnerHTML!==null&&m.dangerouslySetInnerHTML.__html!=null}var N_=null;function HB(){var d=window.event;return d&&d.type==="popstate"?d===N_?!1:(N_=d,!0):(N_=null,!1)}var G6=typeof setTimeout=="function"?setTimeout:void 0,qB=typeof clearTimeout=="function"?clearTimeout:void 0,K6=typeof Promise=="function"?Promise:void 0,VB=typeof queueMicrotask=="function"?queueMicrotask:typeof K6!="undefined"?function(d){return K6.resolve(null).then(d).catch(GB)}:G6;function GB(d){setTimeout(function(){throw d})}function Tu(d){return d==="head"}function Y6(d,m){var x=m,_=0;do{var D=x.nextSibling;if(d.removeChild(x),D&&D.nodeType===8)if(x=D.data,x==="/$"||x==="/&"){if(_===0){d.removeChild(D),Th(m);return}_--}else if(x==="$"||x==="$?"||x==="$~"||x==="$!"||x==="&")_++;else if(x==="html")zg(d.ownerDocument.documentElement);else if(x==="head"){x=d.ownerDocument.head,zg(x);for(var F=x.firstChild;F;){var ue=F.nextSibling,Ee=F.nodeName;F[ct]||Ee==="SCRIPT"||Ee==="STYLE"||Ee==="LINK"&&F.rel.toLowerCase()==="stylesheet"||x.removeChild(F),F=ue}}else x==="body"&&zg(d.ownerDocument.body);x=D}while(x);Th(m)}function J6(d,m){var x=d;d=0;do{var _=x.nextSibling;if(x.nodeType===1?m?(x._stashedDisplay=x.style.display,x.style.display="none"):(x.style.display=x._stashedDisplay||"",x.getAttribute("style")===""&&x.removeAttribute("style")):x.nodeType===3&&(m?(x._stashedText=x.nodeValue,x.nodeValue=""):x.nodeValue=x._stashedText||""),_&&_.nodeType===8)if(x=_.data,x==="/$"){if(d===0)break;d--}else x!=="$"&&x!=="$?"&&x!=="$~"&&x!=="$!"||d++;x=_}while(x)}function S_(d){var m=d.firstChild;for(m&&m.nodeType===10&&(m=m.nextSibling);m;){var x=m;switch(m=m.nextSibling,x.nodeName){case"HTML":case"HEAD":case"BODY":S_(x),$t(x);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(x.rel.toLowerCase()==="stylesheet")continue}d.removeChild(x)}}function KB(d,m,x,_){for(;d.nodeType===1;){var D=x;if(d.nodeName.toLowerCase()!==m.toLowerCase()){if(!_&&(d.nodeName!=="INPUT"||d.type!=="hidden"))break}else if(_){if(!d[ct])switch(m){case"meta":if(!d.hasAttribute("itemprop"))break;return d;case"link":if(F=d.getAttribute("rel"),F==="stylesheet"&&d.hasAttribute("data-precedence"))break;if(F!==D.rel||d.getAttribute("href")!==(D.href==null||D.href===""?null:D.href)||d.getAttribute("crossorigin")!==(D.crossOrigin==null?null:D.crossOrigin)||d.getAttribute("title")!==(D.title==null?null:D.title))break;return d;case"style":if(d.hasAttribute("data-precedence"))break;return d;case"script":if(F=d.getAttribute("src"),(F!==(D.src==null?null:D.src)||d.getAttribute("type")!==(D.type==null?null:D.type)||d.getAttribute("crossorigin")!==(D.crossOrigin==null?null:D.crossOrigin))&&F&&d.hasAttribute("async")&&!d.hasAttribute("itemprop"))break;return d;default:return d}}else if(m==="input"&&d.type==="hidden"){var F=D.name==null?null:""+D.name;if(D.type==="hidden"&&d.getAttribute("name")===F)return d}else return d;if(d=sl(d.nextSibling),d===null)break}return null}function YB(d,m,x){if(m==="")return null;for(;d.nodeType!==3;)if((d.nodeType!==1||d.nodeName!=="INPUT"||d.type!=="hidden")&&!x||(d=sl(d.nextSibling),d===null))return null;return d}function Z6(d,m){for(;d.nodeType!==8;)if((d.nodeType!==1||d.nodeName!=="INPUT"||d.type!=="hidden")&&!m||(d=sl(d.nextSibling),d===null))return null;return d}function C_(d){return d.data==="$?"||d.data==="$~"}function T_(d){return d.data==="$!"||d.data==="$?"&&d.ownerDocument.readyState!=="loading"}function JB(d,m){var x=d.ownerDocument;if(d.data==="$~")d._reactRetry=m;else if(d.data!=="$?"||x.readyState!=="loading")m();else{var _=function(){m(),x.removeEventListener("DOMContentLoaded",_)};x.addEventListener("DOMContentLoaded",_),d._reactRetry=_}}function sl(d){for(;d!=null;d=d.nextSibling){var m=d.nodeType;if(m===1||m===3)break;if(m===8){if(m=d.data,m==="$"||m==="$!"||m==="$?"||m==="$~"||m==="&"||m==="F!"||m==="F")break;if(m==="/$"||m==="/&")return null}}return d}var E_=null;function X6(d){d=d.nextSibling;for(var m=0;d;){if(d.nodeType===8){var x=d.data;if(x==="/$"||x==="/&"){if(m===0)return sl(d.nextSibling);m--}else x!=="$"&&x!=="$!"&&x!=="$?"&&x!=="$~"&&x!=="&"||m++}d=d.nextSibling}return null}function Q6(d){d=d.previousSibling;for(var m=0;d;){if(d.nodeType===8){var x=d.data;if(x==="$"||x==="$!"||x==="$?"||x==="$~"||x==="&"){if(m===0)return d;m--}else x!=="/$"&&x!=="/&"||m++}d=d.previousSibling}return null}function eT(d,m,x){switch(m=Hy(x),d){case"html":if(d=m.documentElement,!d)throw Error(s(452));return d;case"head":if(d=m.head,!d)throw Error(s(453));return d;case"body":if(d=m.body,!d)throw Error(s(454));return d;default:throw Error(s(451))}}function zg(d){for(var m=d.attributes;m.length;)d.removeAttributeNode(m[0]);$t(d)}var nl=new Map,tT=new Set;function qy(d){return typeof d.getRootNode=="function"?d.getRootNode():d.nodeType===9?d:d.ownerDocument}var kd=H.d;H.d={f:ZB,r:XB,D:QB,C:eW,L:tW,m:rW,X:sW,S:aW,M:nW};function ZB(){var d=kd.f(),m=Ly();return d||m}function XB(d){var m=Xt(d);m!==null&&m.tag===5&&m.type==="form"?y5(m):kd.r(d)}var Nh=typeof document=="undefined"?null:document;function rT(d,m,x){var _=Nh;if(_&&typeof m=="string"&&m){var D=ar(m);D='link[rel="'+d+'"][href="'+D+'"]',typeof x=="string"&&(D+='[crossorigin="'+x+'"]'),tT.has(D)||(tT.add(D),d={rel:d,crossOrigin:x,href:m},_.querySelector(D)===null&&(m=_.createElement("link"),Gn(m,"link",d),rr(m),_.head.appendChild(m)))}}function QB(d){kd.D(d),rT("dns-prefetch",d,null)}function eW(d,m){kd.C(d,m),rT("preconnect",d,m)}function tW(d,m,x){kd.L(d,m,x);var _=Nh;if(_&&d&&m){var D='link[rel="preload"][as="'+ar(m)+'"]';m==="image"&&x&&x.imageSrcSet?(D+='[imagesrcset="'+ar(x.imageSrcSet)+'"]',typeof x.imageSizes=="string"&&(D+='[imagesizes="'+ar(x.imageSizes)+'"]')):D+='[href="'+ar(d)+'"]';var F=D;switch(m){case"style":F=Sh(d);break;case"script":F=Ch(d)}nl.has(F)||(d=f({rel:"preload",href:m==="image"&&x&&x.imageSrcSet?void 0:d,as:m},x),nl.set(F,d),_.querySelector(D)!==null||m==="style"&&_.querySelector($g(F))||m==="script"&&_.querySelector(Ug(F))||(m=_.createElement("link"),Gn(m,"link",d),rr(m),_.head.appendChild(m)))}}function rW(d,m){kd.m(d,m);var x=Nh;if(x&&d){var _=m&&typeof m.as=="string"?m.as:"script",D='link[rel="modulepreload"][as="'+ar(_)+'"][href="'+ar(d)+'"]',F=D;switch(_){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":F=Ch(d)}if(!nl.has(F)&&(d=f({rel:"modulepreload",href:d},m),nl.set(F,d),x.querySelector(D)===null)){switch(_){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(x.querySelector(Ug(F)))return}_=x.createElement("link"),Gn(_,"link",d),rr(_),x.head.appendChild(_)}}}function aW(d,m,x){kd.S(d,m,x);var _=Nh;if(_&&d){var D=Wt(_).hoistableStyles,F=Sh(d);m=m||"default";var ue=D.get(F);if(!ue){var Ee={loading:0,preload:null};if(ue=_.querySelector($g(F)))Ee.loading=5;else{d=f({rel:"stylesheet",href:d,"data-precedence":m},x),(x=nl.get(F))&&A_(d,x);var Ze=ue=_.createElement("link");rr(Ze),Gn(Ze,"link",d),Ze._p=new Promise(function(_t,It){Ze.onload=_t,Ze.onerror=It}),Ze.addEventListener("load",function(){Ee.loading|=1}),Ze.addEventListener("error",function(){Ee.loading|=2}),Ee.loading|=4,Vy(ue,m,_)}ue={type:"stylesheet",instance:ue,count:1,state:Ee},D.set(F,ue)}}}function sW(d,m){kd.X(d,m);var x=Nh;if(x&&d){var _=Wt(x).hoistableScripts,D=Ch(d),F=_.get(D);F||(F=x.querySelector(Ug(D)),F||(d=f({src:d,async:!0},m),(m=nl.get(D))&&O_(d,m),F=x.createElement("script"),rr(F),Gn(F,"link",d),x.head.appendChild(F)),F={type:"script",instance:F,count:1,state:null},_.set(D,F))}}function nW(d,m){kd.M(d,m);var x=Nh;if(x&&d){var _=Wt(x).hoistableScripts,D=Ch(d),F=_.get(D);F||(F=x.querySelector(Ug(D)),F||(d=f({src:d,async:!0,type:"module"},m),(m=nl.get(D))&&O_(d,m),F=x.createElement("script"),rr(F),Gn(F,"link",d),x.head.appendChild(F)),F={type:"script",instance:F,count:1,state:null},_.set(D,F))}}function aT(d,m,x,_){var D=(D=me.current)?qy(D):null;if(!D)throw Error(s(446));switch(d){case"meta":case"title":return null;case"style":return typeof x.precedence=="string"&&typeof x.href=="string"?(m=Sh(x.href),x=Wt(D).hoistableStyles,_=x.get(m),_||(_={type:"style",instance:null,count:0,state:null},x.set(m,_)),_):{type:"void",instance:null,count:0,state:null};case"link":if(x.rel==="stylesheet"&&typeof x.href=="string"&&typeof x.precedence=="string"){d=Sh(x.href);var F=Wt(D).hoistableStyles,ue=F.get(d);if(ue||(D=D.ownerDocument||D,ue={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},F.set(d,ue),(F=D.querySelector($g(d)))&&!F._p&&(ue.instance=F,ue.state.loading=5),nl.has(d)||(x={rel:"preload",as:"style",href:x.href,crossOrigin:x.crossOrigin,integrity:x.integrity,media:x.media,hrefLang:x.hrefLang,referrerPolicy:x.referrerPolicy},nl.set(d,x),F||iW(D,d,x,ue.state))),m&&_===null)throw Error(s(528,""));return ue}if(m&&_!==null)throw Error(s(529,""));return null;case"script":return m=x.async,x=x.src,typeof x=="string"&&m&&typeof m!="function"&&typeof m!="symbol"?(m=Ch(x),x=Wt(D).hoistableScripts,_=x.get(m),_||(_={type:"script",instance:null,count:0,state:null},x.set(m,_)),_):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,d))}}function Sh(d){return'href="'+ar(d)+'"'}function $g(d){return'link[rel="stylesheet"]['+d+"]"}function sT(d){return f({},d,{"data-precedence":d.precedence,precedence:null})}function iW(d,m,x,_){d.querySelector('link[rel="preload"][as="style"]['+m+"]")?_.loading=1:(m=d.createElement("link"),_.preload=m,m.addEventListener("load",function(){return _.loading|=1}),m.addEventListener("error",function(){return _.loading|=2}),Gn(m,"link",x),rr(m),d.head.appendChild(m))}function Ch(d){return'[src="'+ar(d)+'"]'}function Ug(d){return"script[async]"+d}function nT(d,m,x){if(m.count++,m.instance===null)switch(m.type){case"style":var _=d.querySelector('style[data-href~="'+ar(x.href)+'"]');if(_)return m.instance=_,rr(_),_;var D=f({},x,{"data-href":x.href,"data-precedence":x.precedence,href:null,precedence:null});return _=(d.ownerDocument||d).createElement("style"),rr(_),Gn(_,"style",D),Vy(_,x.precedence,d),m.instance=_;case"stylesheet":D=Sh(x.href);var F=d.querySelector($g(D));if(F)return m.state.loading|=4,m.instance=F,rr(F),F;_=sT(x),(D=nl.get(D))&&A_(_,D),F=(d.ownerDocument||d).createElement("link"),rr(F);var ue=F;return ue._p=new Promise(function(Ee,Ze){ue.onload=Ee,ue.onerror=Ze}),Gn(F,"link",_),m.state.loading|=4,Vy(F,x.precedence,d),m.instance=F;case"script":return F=Ch(x.src),(D=d.querySelector(Ug(F)))?(m.instance=D,rr(D),D):(_=x,(D=nl.get(F))&&(_=f({},x),O_(_,D)),d=d.ownerDocument||d,D=d.createElement("script"),rr(D),Gn(D,"link",_),d.head.appendChild(D),m.instance=D);case"void":return null;default:throw Error(s(443,m.type))}else m.type==="stylesheet"&&(m.state.loading&4)===0&&(_=m.instance,m.state.loading|=4,Vy(_,x.precedence,d));return m.instance}function Vy(d,m,x){for(var _=x.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),D=_.length?_[_.length-1]:null,F=D,ue=0;ue<_.length;ue++){var Ee=_[ue];if(Ee.dataset.precedence===m)F=Ee;else if(F!==D)break}F?F.parentNode.insertBefore(d,F.nextSibling):(m=x.nodeType===9?x.head:x,m.insertBefore(d,m.firstChild))}function A_(d,m){d.crossOrigin==null&&(d.crossOrigin=m.crossOrigin),d.referrerPolicy==null&&(d.referrerPolicy=m.referrerPolicy),d.title==null&&(d.title=m.title)}function O_(d,m){d.crossOrigin==null&&(d.crossOrigin=m.crossOrigin),d.referrerPolicy==null&&(d.referrerPolicy=m.referrerPolicy),d.integrity==null&&(d.integrity=m.integrity)}var Gy=null;function iT(d,m,x){if(Gy===null){var _=new Map,D=Gy=new Map;D.set(x,_)}else D=Gy,_=D.get(x),_||(_=new Map,D.set(x,_));if(_.has(d))return _;for(_.set(d,null),x=x.getElementsByTagName(d),D=0;D<x.length;D++){var F=x[D];if(!(F[ct]||F[Se]||d==="link"&&F.getAttribute("rel")==="stylesheet")&&F.namespaceURI!=="http://www.w3.org/2000/svg"){var ue=F.getAttribute(m)||"";ue=d+ue;var Ee=_.get(ue);Ee?Ee.push(F):_.set(ue,[F])}}return _}function oT(d,m,x){d=d.ownerDocument||d,d.head.insertBefore(x,m==="title"?d.querySelector("head > title"):null)}function oW(d,m,x){if(x===1||m.itemProp!=null)return!1;switch(d){case"meta":case"title":return!0;case"style":if(typeof m.precedence!="string"||typeof m.href!="string"||m.href==="")break;return!0;case"link":if(typeof m.rel!="string"||typeof m.href!="string"||m.href===""||m.onLoad||m.onError)break;switch(m.rel){case"stylesheet":return d=m.disabled,typeof m.precedence=="string"&&d==null;default:return!0}case"script":if(m.async&&typeof m.async!="function"&&typeof m.async!="symbol"&&!m.onLoad&&!m.onError&&m.src&&typeof m.src=="string")return!0}return!1}function lT(d){return!(d.type==="stylesheet"&&(d.state.loading&3)===0)}function lW(d,m,x,_){if(x.type==="stylesheet"&&(typeof _.media!="string"||matchMedia(_.media).matches!==!1)&&(x.state.loading&4)===0){if(x.instance===null){var D=Sh(_.href),F=m.querySelector($g(D));if(F){m=F._p,m!==null&&typeof m=="object"&&typeof m.then=="function"&&(d.count++,d=Ky.bind(d),m.then(d,d)),x.state.loading|=4,x.instance=F,rr(F);return}F=m.ownerDocument||m,_=sT(_),(D=nl.get(D))&&A_(_,D),F=F.createElement("link"),rr(F);var ue=F;ue._p=new Promise(function(Ee,Ze){ue.onload=Ee,ue.onerror=Ze}),Gn(F,"link",_),x.instance=F}d.stylesheets===null&&(d.stylesheets=new Map),d.stylesheets.set(x,m),(m=x.state.preload)&&(x.state.loading&3)===0&&(d.count++,x=Ky.bind(d),m.addEventListener("load",x),m.addEventListener("error",x))}}var P_=0;function cW(d,m){return d.stylesheets&&d.count===0&&Jy(d,d.stylesheets),0<d.count||0<d.imgCount?function(x){var _=setTimeout(function(){if(d.stylesheets&&Jy(d,d.stylesheets),d.unsuspend){var F=d.unsuspend;d.unsuspend=null,F()}},6e4+m);0<d.imgBytes&&P_===0&&(P_=62500*WB());var D=setTimeout(function(){if(d.waitingForImages=!1,d.count===0&&(d.stylesheets&&Jy(d,d.stylesheets),d.unsuspend)){var F=d.unsuspend;d.unsuspend=null,F()}},(d.imgBytes>P_?50:800)+m);return d.unsuspend=x,function(){d.unsuspend=null,clearTimeout(_),clearTimeout(D)}}:null}function Ky(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Jy(this,this.stylesheets);else if(this.unsuspend){var d=this.unsuspend;this.unsuspend=null,d()}}}var Yy=null;function Jy(d,m){d.stylesheets=null,d.unsuspend!==null&&(d.count++,Yy=new Map,m.forEach(dW,d),Yy=null,Ky.call(d))}function dW(d,m){if(!(m.state.loading&4)){var x=Yy.get(d);if(x)var _=x.get(null);else{x=new Map,Yy.set(d,x);for(var D=d.querySelectorAll("link[data-precedence],style[data-precedence]"),F=0;F<D.length;F++){var ue=D[F];(ue.nodeName==="LINK"||ue.getAttribute("media")!=="not all")&&(x.set(ue.dataset.precedence,ue),_=ue)}_&&x.set(null,_)}D=m.instance,ue=D.getAttribute("data-precedence"),F=x.get(ue)||_,F===_&&x.set(null,D),x.set(ue,D),this.count++,_=Ky.bind(this),D.addEventListener("load",_),D.addEventListener("error",_),F?F.parentNode.insertBefore(D,F.nextSibling):(d=d.nodeType===9?d.head:d,d.insertBefore(D,d.firstChild)),m.state.loading|=4}}var Bg={$$typeof:C,Provider:null,Consumer:null,_currentValue:U,_currentValue2:U,_threadCount:0};function uW(d,m,x,_,D,F,ue,Ee,Ze){this.tag=1,this.containerInfo=d,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=Yt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Yt(0),this.hiddenUpdates=Yt(null),this.identifierPrefix=_,this.onUncaughtError=D,this.onCaughtError=F,this.onRecoverableError=ue,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Ze,this.incompleteTransitions=new Map}function cT(d,m,x,_,D,F,ue,Ee,Ze,_t,It,Vt){return d=new uW(d,m,x,ue,Ze,_t,It,Vt,Ee),m=1,F===!0&&(m|=24),F=oi(3,null,null,m),d.current=F,F.stateNode=d,m=uj(),m.refCount++,d.pooledCache=m,m.refCount++,F.memoizedState={element:_,isDehydrated:x,cache:m},gj(F),d}function dT(d){return d?(d=dd,d):dd}function uT(d,m,x,_,D,F){D=dT(D),_.context===null?_.context=D:_.pendingContext=D,_=xu(m),_.payload={element:x},F=F===void 0?null:F,F!==null&&(_.callback=F),x=yu(d,_,m),x!==null&&(Xi(x,d,m),vg(x,d,m))}function mT(d,m){if(d=d.memoizedState,d!==null&&d.dehydrated!==null){var x=d.retryLane;d.retryLane=x!==0&&x<m?x:m}}function D_(d,m){mT(d,m),(d=d.alternate)&&mT(d,m)}function hT(d){if(d.tag===13||d.tag===31){var m=_s(d,67108864);m!==null&&Xi(m,d,67108864),D_(d,67108864)}}function pT(d){if(d.tag===13||d.tag===31){var m=Eo();m=Ke(m);var x=_s(d,m);x!==null&&Xi(x,d,m),D_(d,m)}}var Zy=!0;function mW(d,m,x,_){var D=q.T;q.T=null;var F=H.p;try{H.p=2,R_(d,m,x,_)}finally{H.p=F,q.T=D}}function hW(d,m,x,_){var D=q.T;q.T=null;var F=H.p;try{H.p=8,R_(d,m,x,_)}finally{H.p=F,q.T=D}}function R_(d,m,x,_){if(Zy){var D=M_(_);if(D===null)v_(d,m,_,Xy,x),fT(d,_);else if(gW(D,d,m,x,_))_.stopPropagation();else if(fT(d,_),m&4&&-1<pW.indexOf(d)){for(;D!==null;){var F=Xt(D);if(F!==null)switch(F.tag){case 3:if(F=F.stateNode,F.current.memoizedState.isDehydrated){var ue=zt(F.pendingLanes);if(ue!==0){var Ee=F;for(Ee.pendingLanes|=2,Ee.entangledLanes|=2;ue;){var Ze=1<<31-Ue(ue);Ee.entanglements[1]|=Ze,ue&=~Ze}jc(F),(Fa&6)===0&&(Ry=jt()+500,Lg(0))}}break;case 31:case 13:Ee=_s(F,2),Ee!==null&&Xi(Ee,F,2),Ly(),D_(F,2)}if(F=M_(_),F===null&&v_(d,m,_,Xy,x),F===D)break;D=F}D!==null&&_.stopPropagation()}else v_(d,m,_,null,x)}}function M_(d){return d=Lt(d),L_(d)}var Xy=null;function L_(d){if(Xy=null,d=Ut(d),d!==null){var m=i(d);if(m===null)d=null;else{var x=m.tag;if(x===13){if(d=o(m),d!==null)return d;d=null}else if(x===31){if(d=l(m),d!==null)return d;d=null}else if(x===3){if(m.stateNode.current.memoizedState.isDehydrated)return m.tag===3?m.stateNode.containerInfo:null;d=null}else m!==d&&(d=null)}}return Xy=d,null}function gT(d){switch(d){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(Ie()){case $e:return 2;case Qe:return 8;case at:case Ct:return 32;case vt:return 268435456;default:return 32}default:return 32}}var F_=!1,Eu=null,Au=null,Ou=null,Wg=new Map,Hg=new Map,Pu=[],pW="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 fT(d,m){switch(d){case"focusin":case"focusout":Eu=null;break;case"dragenter":case"dragleave":Au=null;break;case"mouseover":case"mouseout":Ou=null;break;case"pointerover":case"pointerout":Wg.delete(m.pointerId);break;case"gotpointercapture":case"lostpointercapture":Hg.delete(m.pointerId)}}function qg(d,m,x,_,D,F){return d===null||d.nativeEvent!==F?(d={blockedOn:m,domEventName:x,eventSystemFlags:_,nativeEvent:F,targetContainers:[D]},m!==null&&(m=Xt(m),m!==null&&hT(m)),d):(d.eventSystemFlags|=_,m=d.targetContainers,D!==null&&m.indexOf(D)===-1&&m.push(D),d)}function gW(d,m,x,_,D){switch(m){case"focusin":return Eu=qg(Eu,d,m,x,_,D),!0;case"dragenter":return Au=qg(Au,d,m,x,_,D),!0;case"mouseover":return Ou=qg(Ou,d,m,x,_,D),!0;case"pointerover":var F=D.pointerId;return Wg.set(F,qg(Wg.get(F)||null,d,m,x,_,D)),!0;case"gotpointercapture":return F=D.pointerId,Hg.set(F,qg(Hg.get(F)||null,d,m,x,_,D)),!0}return!1}function xT(d){var m=Ut(d.target);if(m!==null){var x=i(m);if(x!==null){if(m=x.tag,m===13){if(m=o(x),m!==null){d.blockedOn=m,_e(d.priority,function(){pT(x)});return}}else if(m===31){if(m=l(x),m!==null){d.blockedOn=m,_e(d.priority,function(){pT(x)});return}}else if(m===3&&x.stateNode.current.memoizedState.isDehydrated){d.blockedOn=x.tag===3?x.stateNode.containerInfo:null;return}}}d.blockedOn=null}function Qy(d){if(d.blockedOn!==null)return!1;for(var m=d.targetContainers;0<m.length;){var x=M_(d.nativeEvent);if(x===null){x=d.nativeEvent;var _=new x.constructor(x.type,x);ot=_,x.target.dispatchEvent(_),ot=null}else return m=Xt(x),m!==null&&hT(m),d.blockedOn=x,!1;m.shift()}return!0}function yT(d,m,x){Qy(d)&&x.delete(m)}function fW(){F_=!1,Eu!==null&&Qy(Eu)&&(Eu=null),Au!==null&&Qy(Au)&&(Au=null),Ou!==null&&Qy(Ou)&&(Ou=null),Wg.forEach(yT),Hg.forEach(yT)}function eb(d,m){d.blockedOn===m&&(d.blockedOn=null,F_||(F_=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,fW)))}var tb=null;function bT(d){tb!==d&&(tb=d,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){tb===d&&(tb=null);for(var m=0;m<d.length;m+=3){var x=d[m],_=d[m+1],D=d[m+2];if(typeof _!="function"){if(L_(_||x)===null)continue;break}var F=Xt(x);F!==null&&(d.splice(m,3),m-=3,Mj(F,{pending:!0,data:D,method:x.method,action:_},_,D))}}))}function Th(d){function m(Ze){return eb(Ze,d)}Eu!==null&&eb(Eu,d),Au!==null&&eb(Au,d),Ou!==null&&eb(Ou,d),Wg.forEach(m),Hg.forEach(m);for(var x=0;x<Pu.length;x++){var _=Pu[x];_.blockedOn===d&&(_.blockedOn=null)}for(;0<Pu.length&&(x=Pu[0],x.blockedOn===null);)xT(x),x.blockedOn===null&&Pu.shift();if(x=(d.ownerDocument||d).$$reactFormReplay,x!=null)for(_=0;_<x.length;_+=3){var D=x[_],F=x[_+1],ue=D[Ce]||null;if(typeof F=="function")ue||bT(x);else if(ue){var Ee=null;if(F&&F.hasAttribute("formAction")){if(D=F,ue=F[Ce]||null)Ee=ue.formAction;else if(L_(D)!==null)continue}else Ee=ue.action;typeof Ee=="function"?x[_+1]=Ee:(x.splice(_,3),_-=3),bT(x)}}}function vT(){function d(F){F.canIntercept&&F.info==="react-transition"&&F.intercept({handler:function(){return new Promise(function(ue){return D=ue})},focusReset:"manual",scroll:"manual"})}function m(){D!==null&&(D(),D=null),_||setTimeout(x,20)}function x(){if(!_&&!navigation.transition){var F=navigation.currentEntry;F&&F.url!=null&&navigation.navigate(F.url,{state:F.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var _=!1,D=null;return navigation.addEventListener("navigate",d),navigation.addEventListener("navigatesuccess",m),navigation.addEventListener("navigateerror",m),setTimeout(x,100),function(){_=!0,navigation.removeEventListener("navigate",d),navigation.removeEventListener("navigatesuccess",m),navigation.removeEventListener("navigateerror",m),D!==null&&(D(),D=null)}}}function I_(d){this._internalRoot=d}rb.prototype.render=I_.prototype.render=function(d){var m=this._internalRoot;if(m===null)throw Error(s(409));var x=m.current,_=Eo();uT(x,_,d,m,null,null)},rb.prototype.unmount=I_.prototype.unmount=function(){var d=this._internalRoot;if(d!==null){this._internalRoot=null;var m=d.containerInfo;uT(d.current,2,null,d,null,null),Ly(),m[Pe]=null}};function rb(d){this._internalRoot=d}rb.prototype.unstable_scheduleHydration=function(d){if(d){var m=oe();d={blockedOn:null,target:d,priority:m};for(var x=0;x<Pu.length&&m!==0&&m<Pu[x].priority;x++);Pu.splice(x,0,d),x===0&&xT(d)}};var wT=r.version;if(wT!=="19.2.1")throw Error(s(527,wT,"19.2.1"));H.findDOMNode=function(d){var m=d._reactInternals;if(m===void 0)throw typeof d.render=="function"?Error(s(188)):(d=Object.keys(d).join(","),Error(s(268,d)));return d=u(m),d=d!==null?h(d):null,d=d===null?null:d.stateNode,d};var xW={bundleType:0,version:"19.2.1",rendererPackageName:"react-dom",currentDispatcherRef:q,reconcilerVersion:"19.2.1"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__!="undefined"){var ab=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ab.isDisabled&&ab.supportsFiber)try{dt=ab.inject(xW),He=ab}catch(d){}}return Gg.createRoot=function(d,m){if(!n(d))throw Error(s(299));var x=!1,_="",D=T5,F=E5,ue=A5;return m!=null&&(m.unstable_strictMode===!0&&(x=!0),m.identifierPrefix!==void 0&&(_=m.identifierPrefix),m.onUncaughtError!==void 0&&(D=m.onUncaughtError),m.onCaughtError!==void 0&&(F=m.onCaughtError),m.onRecoverableError!==void 0&&(ue=m.onRecoverableError)),m=cT(d,1,!1,null,null,x,_,null,D,F,ue,vT),d[Pe]=m.current,b_(d),new I_(m)},Gg.hydrateRoot=function(d,m,x){if(!n(d))throw Error(s(299));var _=!1,D="",F=T5,ue=E5,Ee=A5,Ze=null;return x!=null&&(x.unstable_strictMode===!0&&(_=!0),x.identifierPrefix!==void 0&&(D=x.identifierPrefix),x.onUncaughtError!==void 0&&(F=x.onUncaughtError),x.onCaughtError!==void 0&&(ue=x.onCaughtError),x.onRecoverableError!==void 0&&(Ee=x.onRecoverableError),x.formState!==void 0&&(Ze=x.formState)),m=cT(d,1,!0,m,x!=null?x:null,_,D,Ze,F,ue,Ee,vT),m.context=dT(null),x=m.current,_=Eo(),_=Ke(_),D=xu(_),D.callback=null,yu(x,D,_),x=_,m.current.lanes=x,Ae(m,x),jc(m),d[Pe]=m.current,b_(d),new rb(m)},Gg.version="19.2.1",Gg}var RT;function DW(){if(RT)return H_.exports;RT=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__=="undefined"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(r){console.error(r)}}return e(),H_.exports=PW(),H_.exports}var RW=DW();const $r=e=>typeof e=="string",Kg=()=>{let e,r;const a=new Promise((s,n)=>{e=s,r=n});return a.resolve=e,a.reject=r,a},MT=e=>e==null?"":""+e,MW=(e,r,a)=>{e.forEach(s=>{r[s]&&(a[s]=r[s])})},LW=/###/g,LT=e=>e&&e.indexOf("###")>-1?e.replace(LW,"."):e,FT=e=>!e||$r(e),Af=(e,r,a)=>{const s=$r(r)?r.split("."):r;let n=0;for(;n<s.length-1;){if(FT(e))return{};const i=LT(s[n]);!e[i]&&a&&(e[i]=new a),Object.prototype.hasOwnProperty.call(e,i)?e=e[i]:e={},++n}return FT(e)?{}:{obj:e,k:LT(s[n])}},IT=(e,r,a)=>{const{obj:s,k:n}=Af(e,r,Object);if(s!==void 0||r.length===1){s[n]=a;return}let i=r[r.length-1],o=r.slice(0,r.length-1),l=Af(e,o,Object);for(;l.obj===void 0&&o.length;)i=`${o[o.length-1]}.${i}`,o=o.slice(0,o.length-1),l=Af(e,o,Object),l!=null&&l.obj&&typeof l.obj[`${l.k}.${i}`]!="undefined"&&(l.obj=void 0);l.obj[`${l.k}.${i}`]=a},FW=(e,r,a,s)=>{const{obj:n,k:i}=Af(e,r,Object);n[i]=n[i]||[],n[i].push(a)},yv=(e,r)=>{const{obj:a,k:s}=Af(e,r);if(a&&Object.prototype.hasOwnProperty.call(a,s))return a[s]},IW=(e,r,a)=>{const s=yv(e,a);return s!==void 0?s:yv(r,a)},m9=(e,r,a)=>{for(const s in r)s!=="__proto__"&&s!=="constructor"&&(s in e?$r(e[s])||e[s]instanceof String||$r(r[s])||r[s]instanceof String?a&&(e[s]=r[s]):m9(e[s],r[s],a):e[s]=r[s]);return e},Ah=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var zW={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const $W=e=>$r(e)?e.replace(/[&<>"'\/]/g,r=>zW[r]):e;class UW{constructor(r){this.capacity=r,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(r){const a=this.regExpMap.get(r);if(a!==void 0)return a;const s=new RegExp(r);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(r,s),this.regExpQueue.push(r),s}}const BW=[" ",",","?","!",";"],WW=new UW(20),HW=(e,r,a)=>{r=r||"",a=a||"";const s=BW.filter(o=>r.indexOf(o)<0&&a.indexOf(o)<0);if(s.length===0)return!0;const n=WW.getRegExp(`(${s.map(o=>o==="?"?"\\?":o).join("|")})`);let i=!n.test(e);if(!i){const o=e.indexOf(a);o>0&&!n.test(e.substring(0,o))&&(i=!0)}return i},pN=(e,r,a=".")=>{if(!e)return;if(e[r])return Object.prototype.hasOwnProperty.call(e,r)?e[r]:void 0;const s=r.split(a);let n=e;for(let i=0;i<s.length;){if(!n||typeof n!="object")return;let o,l="";for(let c=i;c<s.length;++c)if(c!==i&&(l+=a),l+=s[c],o=n[l],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&c<s.length-1)continue;i+=c-i+1;break}n=o}return n},Vf=e=>e==null?void 0:e.replace("_","-"),qW={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,r){var a,s;(s=(a=console==null?void 0:console[e])==null?void 0:a.apply)==null||s.call(a,console,r)}};class bv{constructor(r,a={}){this.init(r,a)}init(r,a={}){this.prefix=a.prefix||"i18next:",this.logger=r||qW,this.options=a,this.debug=a.debug}log(...r){return this.forward(r,"log","",!0)}warn(...r){return this.forward(r,"warn","",!0)}error(...r){return this.forward(r,"error","")}deprecate(...r){return this.forward(r,"warn","WARNING DEPRECATED: ",!0)}forward(r,a,s,n){return n&&!this.debug?null:($r(r[0])&&(r[0]=`${s}${this.prefix} ${r[0]}`),this.logger[a](r))}create(r){return new bv(this.logger,se({prefix:`${this.prefix}:${r}:`},this.options))}clone(r){return r=r||this.options,r.prefix=r.prefix||this.prefix,new bv(this.logger,r)}}var Dc=new bv;let B1=class{constructor(){this.observers={}}on(r,a){return r.split(" ").forEach(s=>{this.observers[s]||(this.observers[s]=new Map);const n=this.observers[s].get(a)||0;this.observers[s].set(a,n+1)}),this}off(r,a){if(this.observers[r]){if(!a){delete this.observers[r];return}this.observers[r].delete(a)}}emit(r,...a){this.observers[r]&&Array.from(this.observers[r].entries()).forEach(([n,i])=>{for(let o=0;o<i;o++)n(...a)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([n,i])=>{for(let o=0;o<i;o++)n.apply(n,[r,...a])})}};class zT extends B1{constructor(r,a={ns:["translation"],defaultNS:"translation"}){super(),this.data=r||{},this.options=a,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(r){this.options.ns.indexOf(r)<0&&this.options.ns.push(r)}removeNamespaces(r){const a=this.options.ns.indexOf(r);a>-1&&this.options.ns.splice(a,1)}getResource(r,a,s,n={}){var u,h;const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,o=n.ignoreJSONStructure!==void 0?n.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;r.indexOf(".")>-1?l=r.split("."):(l=[r,a],s&&(Array.isArray(s)?l.push(...s):$r(s)&&i?l.push(...s.split(i)):l.push(s)));const c=yv(this.data,l);return!c&&!a&&!s&&r.indexOf(".")>-1&&(r=l[0],a=l[1],s=l.slice(2).join(".")),c||!o||!$r(s)?c:pN((h=(u=this.data)==null?void 0:u[r])==null?void 0:h[a],s,i)}addResource(r,a,s,n,i={silent:!1}){const o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator;let l=[r,a];s&&(l=l.concat(o?s.split(o):s)),r.indexOf(".")>-1&&(l=r.split("."),n=a,a=l[1]),this.addNamespaces(a),IT(this.data,l,n),i.silent||this.emit("added",r,a,s,n)}addResources(r,a,s,n={silent:!1}){for(const i in s)($r(s[i])||Array.isArray(s[i]))&&this.addResource(r,a,i,s[i],{silent:!0});n.silent||this.emit("added",r,a,s)}addResourceBundle(r,a,s,n,i,o={silent:!1,skipCopy:!1}){let l=[r,a];r.indexOf(".")>-1&&(l=r.split("."),n=s,s=a,a=l[1]),this.addNamespaces(a);let c=yv(this.data,l)||{};o.skipCopy||(s=JSON.parse(JSON.stringify(s))),n?m9(c,s,i):c=se(se({},c),s),IT(this.data,l,c),o.silent||this.emit("added",r,a,s)}removeResourceBundle(r,a){this.hasResourceBundle(r,a)&&delete this.data[r][a],this.removeNamespaces(a),this.emit("removed",r,a)}hasResourceBundle(r,a){return this.getResource(r,a)!==void 0}getResourceBundle(r,a){return a||(a=this.options.defaultNS),this.getResource(r,a)}getDataByLanguage(r){return this.data[r]}hasLanguageSomeTranslations(r){const a=this.getDataByLanguage(r);return!!(a&&Object.keys(a)||[]).find(n=>a[n]&&Object.keys(a[n]).length>0)}toJSON(){return this.data}}var h9={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,r,a,s,n){return e.forEach(i=>{var o,l;r=(l=(o=this.processors[i])==null?void 0:o.process(r,a,s,n))!=null?l:r}),r}};const p9=Symbol("i18next/PATH_KEY");function VW(){const e=[],r=Object.create(null);let a;return r.get=(s,n)=>{var i;return(i=a==null?void 0:a.revoke)==null||i.call(a),n===p9?e:(e.push(n),a=Proxy.revocable(s,r),a.proxy)},Proxy.revocable(Object.create(null),r).proxy}function gN(e,r){var s;const{[p9]:a}=e(VW());return a.join((s=r==null?void 0:r.keySeparator)!=null?s:".")}const $T={},K_=e=>!$r(e)&&typeof e!="boolean"&&typeof e!="number";class vv extends B1{constructor(r,a={}){super(),MW(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],r,this),this.options=a,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Dc.create("translator")}changeLanguage(r){r&&(this.language=r)}exists(r,a={interpolation:{}}){const s=se({},a);if(r==null)return!1;const n=this.resolve(r,s);if((n==null?void 0:n.res)===void 0)return!1;const i=K_(n.res);return!(s.returnObjects===!1&&i)}extractFromKey(r,a){let s=a.nsSeparator!==void 0?a.nsSeparator:this.options.nsSeparator;s===void 0&&(s=":");const n=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let i=a.ns||this.options.defaultNS||[];const o=s&&r.indexOf(s)>-1,l=!this.options.userDefinedKeySeparator&&!a.keySeparator&&!this.options.userDefinedNsSeparator&&!a.nsSeparator&&!HW(r,s,n);if(o&&!l){const c=r.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:r,namespaces:$r(i)?[i]:i};const u=r.split(s);(s!==n||s===n&&this.options.ns.indexOf(u[0])>-1)&&(i=u.shift()),r=u.join(n)}return{key:r,namespaces:$r(i)?[i]:i}}translate(r,a,s){let n=typeof a=="object"?se({},a):a;if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n=se({},n)),n||(n={}),r==null)return"";typeof r=="function"&&(r=gN(r,se(se({},this.options),n))),Array.isArray(r)||(r=[String(r)]);const i=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,o=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:l,namespaces:c}=this.extractFromKey(r[r.length-1],n),u=c[c.length-1];let h=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;h===void 0&&(h=":");const f=n.lng||this.language,y=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((f==null?void 0:f.toLowerCase())==="cimode")return y?i?{res:`${u}${h}${l}`,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(n)}:`${u}${h}${l}`:i?{res:l,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(n)}:l;const b=this.resolve(r,n);let w=b==null?void 0:b.res;const v=(b==null?void 0:b.usedKey)||l,k=(b==null?void 0:b.exactUsedKey)||l,S=["[object Number]","[object Function]","[object RegExp]"],N=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,C=!this.i18nFormat||this.i18nFormat.handleAsObject,O=n.count!==void 0&&!$r(n.count),T=vv.hasDefaultValue(n),P=O?this.pluralResolver.getSuffix(f,n.count,n):"",E=n.ordinal&&O?this.pluralResolver.getSuffix(f,n.count,{ordinal:!1}):"",R=O&&!n.ordinal&&n.count===0,z=R&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${P}`]||n[`defaultValue${E}`]||n.defaultValue;let G=w;C&&!w&&T&&(G=z);const ae=K_(G),ee=Object.prototype.toString.apply(G);if(C&&G&&ae&&S.indexOf(ee)<0&&!($r(N)&&Array.isArray(G))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const ne=this.options.returnedObjectHandler?this.options.returnedObjectHandler(v,G,je(se({},n),{ns:c})):`key '${l} (${this.language})' returned an object instead of string.`;return i?(b.res=ne,b.usedParams=this.getUsedParamsDetails(n),b):ne}if(o){const ne=Array.isArray(G),te=ne?[]:{},Y=ne?k:v;for(const q in G)if(Object.prototype.hasOwnProperty.call(G,q)){const H=`${Y}${o}${q}`;T&&!w?te[q]=this.translate(H,je(se({},n),{defaultValue:K_(z)?z[q]:void 0,joinArrays:!1,ns:c})):te[q]=this.translate(H,je(se({},n),{joinArrays:!1,ns:c})),te[q]===H&&(te[q]=G[q])}w=te}}else if(C&&$r(N)&&Array.isArray(w))w=w.join(N),w&&(w=this.extendTranslation(w,r,n,s));else{let ne=!1,te=!1;!this.isValidLookup(w)&&T&&(ne=!0,w=z),this.isValidLookup(w)||(te=!0,w=l);const q=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&te?void 0:w,H=T&&z!==w&&this.options.updateMissing;if(te||ne||H){if(this.logger.log(H?"updateKey":"missingKey",f,u,l,H?z:w),o){const V=this.resolve(l,je(se({},n),{keySeparator:!1}));V&&V.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let U=[];const re=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&re&&re[0])for(let V=0;V<re.length;V++)U.push(re[V]);else this.options.saveMissingTo==="all"?U=this.languageUtils.toResolveHierarchy(n.lng||this.language):U.push(n.lng||this.language);const X=(V,I,B)=>{var ie;const Q=T&&B!==w?B:q;this.options.missingKeyHandler?this.options.missingKeyHandler(V,u,I,Q,H,n):(ie=this.backendConnector)!=null&&ie.saveMissing&&this.backendConnector.saveMissing(V,u,I,Q,H,n),this.emit("missingKey",V,u,I,w)};this.options.saveMissing&&(this.options.saveMissingPlurals&&O?U.forEach(V=>{const I=this.pluralResolver.getSuffixes(V,n);R&&n[`defaultValue${this.options.pluralSeparator}zero`]&&I.indexOf(`${this.options.pluralSeparator}zero`)<0&&I.push(`${this.options.pluralSeparator}zero`),I.forEach(B=>{X([V],l+B,n[`defaultValue${B}`]||z)})}):X(U,l,z))}w=this.extendTranslation(w,r,n,b,s),te&&w===l&&this.options.appendNamespaceToMissingKey&&(w=`${u}${h}${l}`),(te||ne)&&this.options.parseMissingKeyHandler&&(w=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${h}${l}`:l,ne?w:void 0,n))}return i?(b.res=w,b.usedParams=this.getUsedParamsDetails(n),b):w}extendTranslation(r,a,s,n,i){var c,u;if((c=this.i18nFormat)!=null&&c.parse)r=this.i18nFormat.parse(r,se(se({},this.options.interpolation.defaultVariables),s),s.lng||this.language||n.usedLng,n.usedNS,n.usedKey,{resolved:n});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init(je(se({},s),{interpolation:se(se({},this.options.interpolation),s.interpolation)}));const h=$r(r)&&(((u=s==null?void 0:s.interpolation)==null?void 0:u.skipOnVariables)!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let f;if(h){const b=r.match(this.interpolator.nestingRegexp);f=b&&b.length}let y=s.replace&&!$r(s.replace)?s.replace:s;if(this.options.interpolation.defaultVariables&&(y=se(se({},this.options.interpolation.defaultVariables),y)),r=this.interpolator.interpolate(r,y,s.lng||this.language||n.usedLng,s),h){const b=r.match(this.interpolator.nestingRegexp),w=b&&b.length;f<w&&(s.nest=!1)}!s.lng&&n&&n.res&&(s.lng=this.language||n.usedLng),s.nest!==!1&&(r=this.interpolator.nest(r,(...b)=>(i==null?void 0:i[0])===b[0]&&!s.context?(this.logger.warn(`It seems you are nesting recursively key: ${b[0]} in key: ${a[0]}`),null):this.translate(...b,a),s)),s.interpolation&&this.interpolator.reset()}const o=s.postProcess||this.options.postProcess,l=$r(o)?[o]:o;return r!=null&&(l!=null&&l.length)&&s.applyPostProcessor!==!1&&(r=h9.handle(l,r,a,this.options&&this.options.postProcessPassResolved?se({i18nResolved:je(se({},n),{usedParams:this.getUsedParamsDetails(s)})},s):s,this)),r}resolve(r,a={}){let s,n,i,o,l;return $r(r)&&(r=[r]),r.forEach(c=>{if(this.isValidLookup(s))return;const u=this.extractFromKey(c,a),h=u.key;n=h;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const y=a.count!==void 0&&!$r(a.count),b=y&&!a.ordinal&&a.count===0,w=a.context!==void 0&&($r(a.context)||typeof a.context=="number")&&a.context!=="",v=a.lngs?a.lngs:this.languageUtils.toResolveHierarchy(a.lng||this.language,a.fallbackLng);f.forEach(k=>{var S,N;this.isValidLookup(s)||(l=k,!$T[`${v[0]}-${k}`]&&((S=this.utils)!=null&&S.hasLoadedNamespace)&&!((N=this.utils)!=null&&N.hasLoadedNamespace(l))&&($T[`${v[0]}-${k}`]=!0,this.logger.warn(`key "${n}" for languages "${v.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),v.forEach(C=>{var P;if(this.isValidLookup(s))return;o=C;const O=[h];if((P=this.i18nFormat)!=null&&P.addLookupKeys)this.i18nFormat.addLookupKeys(O,h,C,k,a);else{let E;y&&(E=this.pluralResolver.getSuffix(C,a.count,a));const R=`${this.options.pluralSeparator}zero`,z=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(y&&(a.ordinal&&E.indexOf(z)===0&&O.push(h+E.replace(z,this.options.pluralSeparator)),O.push(h+E),b&&O.push(h+R)),w){const G=`${h}${this.options.contextSeparator||"_"}${a.context}`;O.push(G),y&&(a.ordinal&&E.indexOf(z)===0&&O.push(G+E.replace(z,this.options.pluralSeparator)),O.push(G+E),b&&O.push(G+R))}}let T;for(;T=O.pop();)this.isValidLookup(s)||(i=T,s=this.getResource(C,k,T,a))}))})}),{res:s,usedKey:n,exactUsedKey:i,usedLng:o,usedNS:l}}isValidLookup(r){return r!==void 0&&!(!this.options.returnNull&&r===null)&&!(!this.options.returnEmptyString&&r==="")}getResource(r,a,s,n={}){var i;return(i=this.i18nFormat)!=null&&i.getResource?this.i18nFormat.getResource(r,a,s,n):this.resourceStore.getResource(r,a,s,n)}getUsedParamsDetails(r={}){const a=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=r.replace&&!$r(r.replace);let n=s?r.replace:r;if(s&&typeof r.count!="undefined"&&(n.count=r.count),this.options.interpolation.defaultVariables&&(n=se(se({},this.options.interpolation.defaultVariables),n)),!s){n=se({},n);for(const i of a)delete n[i]}return n}static hasDefaultValue(r){const a="defaultValue";for(const s in r)if(Object.prototype.hasOwnProperty.call(r,s)&&a===s.substring(0,a.length)&&r[s]!==void 0)return!0;return!1}}class UT{constructor(r){this.options=r,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Dc.create("languageUtils")}getScriptPartFromCode(r){if(r=Vf(r),!r||r.indexOf("-")<0)return null;const a=r.split("-");return a.length===2||(a.pop(),a[a.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(a.join("-"))}getLanguagePartFromCode(r){if(r=Vf(r),!r||r.indexOf("-")<0)return r;const a=r.split("-");return this.formatLanguageCode(a[0])}formatLanguageCode(r){if($r(r)&&r.indexOf("-")>-1){let a;try{a=Intl.getCanonicalLocales(r)[0]}catch(s){}return a&&this.options.lowerCaseLng&&(a=a.toLowerCase()),a||(this.options.lowerCaseLng?r.toLowerCase():r)}return this.options.cleanCode||this.options.lowerCaseLng?r.toLowerCase():r}isSupportedCode(r){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(r=this.getLanguagePartFromCode(r)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(r)>-1}getBestMatchFromCodes(r){if(!r)return null;let a;return r.forEach(s=>{if(a)return;const n=this.formatLanguageCode(s);(!this.options.supportedLngs||this.isSupportedCode(n))&&(a=n)}),!a&&this.options.supportedLngs&&r.forEach(s=>{if(a)return;const n=this.getScriptPartFromCode(s);if(this.isSupportedCode(n))return a=n;const i=this.getLanguagePartFromCode(s);if(this.isSupportedCode(i))return a=i;a=this.options.supportedLngs.find(o=>{if(o===i)return o;if(!(o.indexOf("-")<0&&i.indexOf("-")<0)&&(o.indexOf("-")>0&&i.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===i||o.indexOf(i)===0&&i.length>1))return o})}),a||(a=this.getFallbackCodes(this.options.fallbackLng)[0]),a}getFallbackCodes(r,a){if(!r)return[];if(typeof r=="function"&&(r=r(a)),$r(r)&&(r=[r]),Array.isArray(r))return r;if(!a)return r.default||[];let s=r[a];return s||(s=r[this.getScriptPartFromCode(a)]),s||(s=r[this.formatLanguageCode(a)]),s||(s=r[this.getLanguagePartFromCode(a)]),s||(s=r.default),s||[]}toResolveHierarchy(r,a){const s=this.getFallbackCodes((a===!1?[]:a)||this.options.fallbackLng||[],r),n=[],i=o=>{o&&(this.isSupportedCode(o)?n.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return $r(r)&&(r.indexOf("-")>-1||r.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&i(this.formatLanguageCode(r)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&i(this.getScriptPartFromCode(r)),this.options.load!=="currentOnly"&&i(this.getLanguagePartFromCode(r))):$r(r)&&i(this.formatLanguageCode(r)),s.forEach(o=>{n.indexOf(o)<0&&i(this.formatLanguageCode(o))}),n}}const BT={zero:0,one:1,two:2,few:3,many:4,other:5},WT={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class GW{constructor(r,a={}){this.languageUtils=r,this.options=a,this.logger=Dc.create("pluralResolver"),this.pluralRulesCache={}}addRule(r,a){this.rules[r]=a}clearCache(){this.pluralRulesCache={}}getRule(r,a={}){const s=Vf(r==="dev"?"en":r),n=a.ordinal?"ordinal":"cardinal",i=JSON.stringify({cleanedCode:s,type:n});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let o;try{o=new Intl.PluralRules(s,{type:n})}catch(l){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),WT;if(!r.match(/-|_/))return WT;const c=this.languageUtils.getLanguagePartFromCode(r);o=this.getRule(c,a)}return this.pluralRulesCache[i]=o,o}needsPlural(r,a={}){let s=this.getRule(r,a);return s||(s=this.getRule("dev",a)),(s==null?void 0:s.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(r,a,s={}){return this.getSuffixes(r,s).map(n=>`${a}${n}`)}getSuffixes(r,a={}){let s=this.getRule(r,a);return s||(s=this.getRule("dev",a)),s?s.resolvedOptions().pluralCategories.sort((n,i)=>BT[n]-BT[i]).map(n=>`${this.options.prepend}${a.ordinal?`ordinal${this.options.prepend}`:""}${n}`):[]}getSuffix(r,a,s={}){const n=this.getRule(r,s);return n?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${n.select(a)}`:(this.logger.warn(`no plural rule found for: ${r}`),this.getSuffix("dev",a,s))}}const HT=(e,r,a,s=".",n=!0)=>{let i=IW(e,r,a);return!i&&n&&$r(a)&&(i=pN(e,a,s),i===void 0&&(i=pN(r,a,s))),i},Y_=e=>e.replace(/\$/g,"$$$$");class qT{constructor(r={}){var a;this.logger=Dc.create("interpolator"),this.options=r,this.format=((a=r==null?void 0:r.interpolation)==null?void 0:a.format)||(s=>s),this.init(r)}init(r={}){r.interpolation||(r.interpolation={escapeValue:!0});const{escape:a,escapeValue:s,useRawValueToEscape:n,prefix:i,prefixEscaped:o,suffix:l,suffixEscaped:c,formatSeparator:u,unescapeSuffix:h,unescapePrefix:f,nestingPrefix:y,nestingPrefixEscaped:b,nestingSuffix:w,nestingSuffixEscaped:v,nestingOptionsSeparator:k,maxReplaces:S,alwaysFormat:N}=r.interpolation;this.escape=a!==void 0?a:$W,this.escapeValue=s!==void 0?s:!0,this.useRawValueToEscape=n!==void 0?n:!1,this.prefix=i?Ah(i):o||"{{",this.suffix=l?Ah(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=h?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":h||"",this.nestingPrefix=y?Ah(y):b||Ah("$t("),this.nestingSuffix=w?Ah(w):v||Ah(")"),this.nestingOptionsSeparator=k||",",this.maxReplaces=S||1e3,this.alwaysFormat=N!==void 0?N:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const r=(a,s)=>(a==null?void 0:a.source)===s?(a.lastIndex=0,a):new RegExp(s,"g");this.regexp=r(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=r(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=r(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(r,a,s,n){var b;let i,o,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=w=>{if(w.indexOf(this.formatSeparator)<0){const N=HT(a,c,w,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(N,void 0,s,je(se(se({},n),a),{interpolationkey:w})):N}const v=w.split(this.formatSeparator),k=v.shift().trim(),S=v.join(this.formatSeparator).trim();return this.format(HT(a,c,k,this.options.keySeparator,this.options.ignoreJSONStructure),S,s,je(se(se({},n),a),{interpolationkey:k}))};this.resetRegExp();const h=(n==null?void 0:n.missingInterpolationHandler)||this.options.missingInterpolationHandler,f=((b=n==null?void 0:n.interpolation)==null?void 0:b.skipOnVariables)!==void 0?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:w=>Y_(w)},{regex:this.regexp,safeValue:w=>this.escapeValue?Y_(this.escape(w)):Y_(w)}].forEach(w=>{for(l=0;i=w.regex.exec(r);){const v=i[1].trim();if(o=u(v),o===void 0)if(typeof h=="function"){const S=h(r,i,n);o=$r(S)?S:""}else if(n&&Object.prototype.hasOwnProperty.call(n,v))o="";else if(f){o=i[0];continue}else this.logger.warn(`missed to pass in variable ${v} for interpolating ${r}`),o="";else!$r(o)&&!this.useRawValueToEscape&&(o=MT(o));const k=w.safeValue(o);if(r=r.replace(i[0],k),f?(w.regex.lastIndex+=o.length,w.regex.lastIndex-=i[0].length):w.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),r}nest(r,a,s={}){let n,i,o;const l=(c,u)=>{var v;const h=this.nestingOptionsSeparator;if(c.indexOf(h)<0)return c;const f=c.split(new RegExp(`${h}[ ]*{`));let y=`{${f[1]}`;c=f[0],y=this.interpolate(y,o);const b=y.match(/'/g),w=y.match(/"/g);(((v=b==null?void 0:b.length)!=null?v:0)%2===0&&!w||w.length%2!==0)&&(y=y.replace(/'/g,'"'));try{o=JSON.parse(y),u&&(o=se(se({},u),o))}catch(k){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,k),`${c}${h}${y}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,c};for(;n=this.nestingRegexp.exec(r);){let c=[];o=se({},s),o=o.replace&&!$r(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;const u=/{.*}/.test(n[1])?n[1].lastIndexOf("}")+1:n[1].indexOf(this.formatSeparator);if(u!==-1&&(c=n[1].slice(u).split(this.formatSeparator).map(h=>h.trim()).filter(Boolean),n[1]=n[1].slice(0,u)),i=a(l.call(this,n[1].trim(),o),o),i&&n[0]===r&&!$r(i))return i;$r(i)||(i=MT(i)),i||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${r}`),i=""),c.length&&(i=c.reduce((h,f)=>this.format(h,f,s.lng,je(se({},s),{interpolationkey:n[1].trim()})),i.trim())),r=r.replace(n[0],i),this.regexp.lastIndex=0}return r}}const KW=e=>{let r=e.toLowerCase().trim();const a={};if(e.indexOf("(")>-1){const s=e.split("(");r=s[0].toLowerCase().trim();const n=s[1].substring(0,s[1].length-1);r==="currency"&&n.indexOf(":")<0?a.currency||(a.currency=n.trim()):r==="relativetime"&&n.indexOf(":")<0?a.range||(a.range=n.trim()):n.split(";").forEach(o=>{if(o){const[l,...c]=o.split(":"),u=c.join(":").trim().replace(/^'+|'+$/g,""),h=l.trim();a[h]||(a[h]=u),u==="false"&&(a[h]=!1),u==="true"&&(a[h]=!0),isNaN(u)||(a[h]=parseInt(u,10))}})}return{formatName:r,formatOptions:a}},VT=e=>{const r={};return(a,s,n)=>{let i=n;n&&n.interpolationkey&&n.formatParams&&n.formatParams[n.interpolationkey]&&n[n.interpolationkey]&&(i=je(se({},i),{[n.interpolationkey]:void 0}));const o=s+JSON.stringify(i);let l=r[o];return l||(l=e(Vf(s),n),r[o]=l),l(a)}},YW=e=>(r,a,s)=>e(Vf(a),s)(r);class JW{constructor(r={}){this.logger=Dc.create("formatter"),this.options=r,this.init(r)}init(r,a={interpolation:{}}){this.formatSeparator=a.interpolation.formatSeparator||",";const s=a.cacheInBuiltFormats?VT:YW;this.formats={number:s((n,i)=>{const o=new Intl.NumberFormat(n,se({},i));return l=>o.format(l)}),currency:s((n,i)=>{const o=new Intl.NumberFormat(n,je(se({},i),{style:"currency"}));return l=>o.format(l)}),datetime:s((n,i)=>{const o=new Intl.DateTimeFormat(n,se({},i));return l=>o.format(l)}),relativetime:s((n,i)=>{const o=new Intl.RelativeTimeFormat(n,se({},i));return l=>o.format(l,i.range||"day")}),list:s((n,i)=>{const o=new Intl.ListFormat(n,se({},i));return l=>o.format(l)})}}add(r,a){this.formats[r.toLowerCase().trim()]=a}addCached(r,a){this.formats[r.toLowerCase().trim()]=VT(a)}format(r,a,s,n={}){const i=a.split(this.formatSeparator);if(i.length>1&&i[0].indexOf("(")>1&&i[0].indexOf(")")<0&&i.find(l=>l.indexOf(")")>-1)){const l=i.findIndex(c=>c.indexOf(")")>-1);i[0]=[i[0],...i.splice(1,l)].join(this.formatSeparator)}return i.reduce((l,c)=>{var f;const{formatName:u,formatOptions:h}=KW(c);if(this.formats[u]){let y=l;try{const b=((f=n==null?void 0:n.formatParams)==null?void 0:f[n.interpolationkey])||{},w=b.locale||b.lng||n.locale||n.lng||s;y=this.formats[u](l,w,se(se(se({},h),n),b))}catch(b){this.logger.warn(b)}return y}else this.logger.warn(`there was no format function for ${u}`);return l},r)}}const ZW=(e,r)=>{e.pending[r]!==void 0&&(delete e.pending[r],e.pendingCount--)};class XW extends B1{constructor(r,a,s,n={}){var i,o;super(),this.backend=r,this.store=a,this.services=s,this.languageUtils=s.languageUtils,this.options=n,this.logger=Dc.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=n.maxParallelReads||10,this.readingCalls=0,this.maxRetries=n.maxRetries>=0?n.maxRetries:5,this.retryTimeout=n.retryTimeout>=1?n.retryTimeout:350,this.state={},this.queue=[],(o=(i=this.backend)==null?void 0:i.init)==null||o.call(i,s,n.backend,n)}queueLoad(r,a,s,n){const i={},o={},l={},c={};return r.forEach(u=>{let h=!0;a.forEach(f=>{const y=`${u}|${f}`;!s.reload&&this.store.hasResourceBundle(u,f)?this.state[y]=2:this.state[y]<0||(this.state[y]===1?o[y]===void 0&&(o[y]=!0):(this.state[y]=1,h=!1,o[y]===void 0&&(o[y]=!0),i[y]===void 0&&(i[y]=!0),c[f]===void 0&&(c[f]=!0)))}),h||(l[u]=!0)}),(Object.keys(i).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:n}),{toLoad:Object.keys(i),pending:Object.keys(o),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(r,a,s){const n=r.split("|"),i=n[0],o=n[1];a&&this.emit("failedLoading",i,o,a),!a&&s&&this.store.addResourceBundle(i,o,s,void 0,void 0,{skipCopy:!0}),this.state[r]=a?-1:2,a&&s&&(this.state[r]=0);const l={};this.queue.forEach(c=>{FW(c.loaded,[i],o),ZW(c,r),a&&c.errors.push(a),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{l[u]||(l[u]={});const h=c.loaded[u];h.length&&h.forEach(f=>{l[u][f]===void 0&&(l[u][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(r,a,s,n=0,i=this.retryTimeout,o){if(!r.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:r,ns:a,fcName:s,tried:n,wait:i,callback:o});return}this.readingCalls++;const l=(u,h)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&h&&n<this.maxRetries){setTimeout(()=>{this.read.call(this,r,a,s,n+1,i*2,o)},i);return}o(u,h)},c=this.backend[s].bind(this.backend);if(c.length===2){try{const u=c(r,a);u&&typeof u.then=="function"?u.then(h=>l(null,h)).catch(l):l(null,u)}catch(u){l(u)}return}return c(r,a,l)}prepareLoading(r,a,s={},n){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),n&&n();$r(r)&&(r=this.languageUtils.toResolveHierarchy(r)),$r(a)&&(a=[a]);const i=this.queueLoad(r,a,s,n);if(!i.toLoad.length)return i.pending.length||n(),null;i.toLoad.forEach(o=>{this.loadOne(o)})}load(r,a,s){this.prepareLoading(r,a,{},s)}reload(r,a,s){this.prepareLoading(r,a,{reload:!0},s)}loadOne(r,a=""){const s=r.split("|"),n=s[0],i=s[1];this.read(n,i,"read",void 0,void 0,(o,l)=>{o&&this.logger.warn(`${a}loading namespace ${i} for language ${n} failed`,o),!o&&l&&this.logger.log(`${a}loaded namespace ${i} for language ${n}`,l),this.loaded(r,o,l)})}saveMissing(r,a,s,n,i,o={},l=()=>{}){var c,u,h,f,y;if((u=(c=this.services)==null?void 0:c.utils)!=null&&u.hasLoadedNamespace&&!((f=(h=this.services)==null?void 0:h.utils)!=null&&f.hasLoadedNamespace(a))){this.logger.warn(`did not save key "${s}" as the namespace "${a}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(s==null||s==="")){if((y=this.backend)!=null&&y.create){const b=je(se({},o),{isUpdate:i}),w=this.backend.create.bind(this.backend);if(w.length<6)try{let v;w.length===5?v=w(r,a,s,n,b):v=w(r,a,s,n),v&&typeof v.then=="function"?v.then(k=>l(null,k)).catch(l):l(null,v)}catch(v){l(v)}else w(r,a,s,n,l,b)}!r||!r[0]||this.store.addResource(r[0],a,s,n)}}}const GT=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let r={};if(typeof e[1]=="object"&&(r=e[1]),$r(e[1])&&(r.defaultValue=e[1]),$r(e[2])&&(r.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const a=e[3]||e[2];Object.keys(a).forEach(s=>{r[s]=a[s]})}return r},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),KT=e=>{var r,a;return $r(e.ns)&&(e.ns=[e.ns]),$r(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),$r(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),((a=(r=e.supportedLngs)==null?void 0:r.indexOf)==null?void 0:a.call(r,"cimode"))<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),typeof e.initImmediate=="boolean"&&(e.initAsync=e.initImmediate),e},nb=()=>{},QW=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(a=>{typeof e[a]=="function"&&(e[a]=e[a].bind(e))})};class Of extends B1{constructor(r={},a){if(super(),this.options=KT(r),this.services={},this.logger=Dc,this.modules={external:[]},QW(this),a&&!this.isInitialized&&!r.isClone){if(!this.options.initAsync)return this.init(r,a),this;setTimeout(()=>{this.init(r,a)},0)}}init(r={},a){this.isInitializing=!0,typeof r=="function"&&(a=r,r={}),r.defaultNS==null&&r.ns&&($r(r.ns)?r.defaultNS=r.ns:r.ns.indexOf("translation")<0&&(r.defaultNS=r.ns[0]));const s=GT();this.options=se(se(se({},s),this.options),KT(r)),this.options.interpolation=se(se({},s.interpolation),this.options.interpolation),r.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=r.keySeparator),r.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=r.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=s.overloadTranslationOptionHandler);const n=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?Dc.init(n(this.modules.logger),this.options):Dc.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=JW;const h=new UT(this.options);this.store=new zT(this.options.resources,this.options);const f=this.services;f.logger=Dc,f.resourceStore=this.store,f.languageUtils=h,f.pluralResolver=new GW(h,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==s.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),u&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(f.formatter=n(u),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new qT(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new XW(n(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(b,...w)=>{this.emit(b,...w)}),this.modules.languageDetector&&(f.languageDetector=n(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=n(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new vv(this.services,this.options),this.translator.on("*",(b,...w)=>{this.emit(b,...w)}),this.modules.external.forEach(b=>{b.init&&b.init(this)})}if(this.format=this.options.interpolation.format,a||(a=nb),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(u=>{this[u]=(...h)=>this.store[u](...h)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=(...h)=>(this.store[u](...h),this)});const l=Kg(),c=()=>{const u=(h,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(f),a(h,f)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(r,a=nb){var i,o;let s=a;const n=$r(r)?r:this.language;if(typeof r=="function"&&(s=r),!this.options.resources||this.options.partialBundledLanguages){if((n==null?void 0:n.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return s();const l=[],c=u=>{if(!u||u==="cimode")return;this.services.languageUtils.toResolveHierarchy(u).forEach(f=>{f!=="cimode"&&l.indexOf(f)<0&&l.push(f)})};n?c(n):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(h=>c(h)),(o=(i=this.options.preload)==null?void 0:i.forEach)==null||o.call(i,u=>c(u)),this.services.backendConnector.load(l,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),s(u)})}else s(null)}reloadResources(r,a,s){const n=Kg();return typeof r=="function"&&(s=r,r=void 0),typeof a=="function"&&(s=a,a=void 0),r||(r=this.languages),a||(a=this.options.ns),s||(s=nb),this.services.backendConnector.reload(r,a,i=>{n.resolve(),s(i)}),n}use(r){if(!r)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!r.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return r.type==="backend"&&(this.modules.backend=r),(r.type==="logger"||r.log&&r.warn&&r.error)&&(this.modules.logger=r),r.type==="languageDetector"&&(this.modules.languageDetector=r),r.type==="i18nFormat"&&(this.modules.i18nFormat=r),r.type==="postProcessor"&&h9.addPostProcessor(r),r.type==="formatter"&&(this.modules.formatter=r),r.type==="3rdParty"&&this.modules.external.push(r),this}setResolvedLanguage(r){if(!(!r||!this.languages)&&!(["cimode","dev"].indexOf(r)>-1)){for(let a=0;a<this.languages.length;a++){const s=this.languages[a];if(!(["cimode","dev"].indexOf(s)>-1)&&this.store.hasLanguageSomeTranslations(s)){this.resolvedLanguage=s;break}}!this.resolvedLanguage&&this.languages.indexOf(r)<0&&this.store.hasLanguageSomeTranslations(r)&&(this.resolvedLanguage=r,this.languages.unshift(r))}}changeLanguage(r,a){this.isLanguageChangingTo=r;const s=Kg();this.emit("languageChanging",r);const n=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},i=(l,c)=>{c?this.isLanguageChangingTo===r&&(n(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,s.resolve((...u)=>this.t(...u)),a&&a(l,(...u)=>this.t(...u))},o=l=>{var h,f;!r&&!l&&this.services.languageDetector&&(l=[]);const c=$r(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes($r(l)?[l]:l);u&&(this.language||n(u),this.translator.language||this.translator.changeLanguage(u),(f=(h=this.services.languageDetector)==null?void 0:h.cacheUserLanguage)==null||f.call(h,u)),this.loadResources(u,y=>{i(y,u)})};return!r&&this.services.languageDetector&&!this.services.languageDetector.async?o(this.services.languageDetector.detect()):!r&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(r),s}getFixedT(r,a,s){const n=(i,o,...l)=>{let c;typeof o!="object"?c=this.options.overloadTranslationOptionHandler([i,o].concat(l)):c=se({},o),c.lng=c.lng||n.lng,c.lngs=c.lngs||n.lngs,c.ns=c.ns||n.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||s||n.keyPrefix);const u=this.options.keySeparator||".";let h;return c.keyPrefix&&Array.isArray(i)?h=i.map(f=>(typeof f=="function"&&(f=gN(f,se(se({},this.options),o))),`${c.keyPrefix}${u}${f}`)):(typeof i=="function"&&(i=gN(i,se(se({},this.options),o))),h=c.keyPrefix?`${c.keyPrefix}${u}${i}`:i),this.t(h,c)};return $r(r)?n.lng=r:n.lngs=r,n.ns=a,n.keyPrefix=s,n}t(...r){var a;return(a=this.translator)==null?void 0:a.translate(...r)}exists(...r){var a;return(a=this.translator)==null?void 0:a.exists(...r)}setDefaultNamespace(r){this.options.defaultNS=r}hasLoadedNamespace(r,a={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=a.lng||this.resolvedLanguage||this.languages[0],n=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(s.toLowerCase()==="cimode")return!0;const o=(l,c)=>{const u=this.services.backendConnector.state[`${l}|${c}`];return u===-1||u===0||u===2};if(a.precheck){const l=a.precheck(this,o);if(l!==void 0)return l}return!!(this.hasResourceBundle(s,r)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(s,r)&&(!n||o(i,r)))}loadNamespaces(r,a){const s=Kg();return this.options.ns?($r(r)&&(r=[r]),r.forEach(n=>{this.options.ns.indexOf(n)<0&&this.options.ns.push(n)}),this.loadResources(n=>{s.resolve(),a&&a(n)}),s):(a&&a(),Promise.resolve())}loadLanguages(r,a){const s=Kg();$r(r)&&(r=[r]);const n=this.options.preload||[],i=r.filter(o=>n.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return i.length?(this.options.preload=n.concat(i),this.loadResources(o=>{s.resolve(),a&&a(o)}),s):(a&&a(),Promise.resolve())}dir(r){var n,i;if(r||(r=this.resolvedLanguage||(((n=this.languages)==null?void 0:n.length)>0?this.languages[0]:this.language)),!r)return"rtl";try{const o=new Intl.Locale(r);if(o&&o.getTextInfo){const l=o.getTextInfo();if(l&&l.direction)return l.direction}}catch(o){}const a=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],s=((i=this.services)==null?void 0:i.languageUtils)||new UT(GT());return r.toLowerCase().indexOf("-latn")>1?"ltr":a.indexOf(s.getLanguagePartFromCode(r))>-1||r.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(r={},a){const s=new Of(r,a);return s.createInstance=Of.createInstance,s}cloneInstance(r={},a=nb){const s=r.forkResourceStore;s&&delete r.forkResourceStore;const n=je(se(se({},this.options),r),{isClone:!0}),i=new Of(n);if((r.debug!==void 0||r.prefix!==void 0)&&(i.logger=i.logger.clone(r)),["store","services","language"].forEach(l=>{i[l]=this[l]}),i.services=se({},this.services),i.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},s){const l=Object.keys(this.store.data).reduce((c,u)=>(c[u]=se({},this.store.data[u]),c[u]=Object.keys(c[u]).reduce((h,f)=>(h[f]=se({},c[u][f]),h),c[u]),c),{});i.store=new zT(l,n),i.services.resourceStore=i.store}return r.interpolation&&(i.services.interpolator=new qT(n)),i.translator=new vv(i.services,n),i.translator.on("*",(l,...c)=>{i.emit(l,...c)}),i.init(n,a),i.translator.options=n,i.translator.backendConnector.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Fn=Of.createInstance();Fn.createInstance;Fn.dir;Fn.init;Fn.loadResources;Fn.reloadResources;Fn.use;Fn.changeLanguage;Fn.getFixedT;Fn.t;Fn.exists;Fn.setDefaultNamespace;Fn.hasLoadedNamespace;Fn.loadNamespaces;Fn.loadLanguages;const eH=(e,r,a,s)=>{var i,o,l,c;const n=[a,se({code:r},s||{})];if((o=(i=e==null?void 0:e.services)==null?void 0:i.logger)!=null&&o.forward)return e.services.logger.forward(n,"warn","react-i18next::",!0);fm(n[0])&&(n[0]=`react-i18next:: ${n[0]}`),(c=(l=e==null?void 0:e.services)==null?void 0:l.logger)!=null&&c.warn?e.services.logger.warn(...n):console!=null&&console.warn&&console.warn(...n)},YT={},g9=(e,r,a,s)=>{fm(a)&&YT[a]||(fm(a)&&(YT[a]=new Date),eH(e,r,a,s))},f9=(e,r)=>()=>{if(e.isInitialized)r();else{const a=()=>{setTimeout(()=>{e.off("initialized",a)},0),r()};e.on("initialized",a)}},fN=(e,r,a)=>{e.loadNamespaces(r,f9(e,a))},JT=(e,r,a,s)=>{if(fm(a)&&(a=[a]),e.options.preload&&e.options.preload.indexOf(r)>-1)return fN(e,a,s);a.forEach(n=>{e.options.ns.indexOf(n)<0&&e.options.ns.push(n)}),e.loadLanguages(r,f9(e,s))},tH=(e,r,a={})=>!r.languages||!r.languages.length?(g9(r,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:r.languages}),!0):r.hasLoadedNamespace(e,{lng:a.lng,precheck:(s,n)=>{if(a.bindI18n&&a.bindI18n.indexOf("languageChanging")>-1&&s.services.backendConnector.backend&&s.isLanguageChangingTo&&!n(s.isLanguageChangingTo,e))return!1}}),fm=e=>typeof e=="string",rH=e=>typeof e=="object"&&e!==null,aH=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,sH={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},nH=e=>sH[e],iH=e=>e.replace(aH,nH);let xN={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:iH};const oH=(e={})=>{xN=se(se({},xN),e)},lH=()=>xN;let x9;const cH=e=>{x9=e},dH=()=>x9,uH={type:"3rdParty",init(e){oH(e.options.react),cH(e)}},mH=p.createContext();class hH{constructor(){this.usedNamespaces={}}addUsedNamespaces(r){r.forEach(a=>{this.usedNamespaces[a]||(this.usedNamespaces[a]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var J_={exports:{}},Z_={};var ZT;function pH(){if(ZT)return Z_;ZT=1;var e=Ip();function r(f,y){return f===y&&(f!==0||1/f===1/y)||f!==f&&y!==y}var a=typeof Object.is=="function"?Object.is:r,s=e.useState,n=e.useEffect,i=e.useLayoutEffect,o=e.useDebugValue;function l(f,y){var b=y(),w=s({inst:{value:b,getSnapshot:y}}),v=w[0].inst,k=w[1];return i(function(){v.value=b,v.getSnapshot=y,c(v)&&k({inst:v})},[f,b,y]),n(function(){return c(v)&&k({inst:v}),f(function(){c(v)&&k({inst:v})})},[f]),o(b),b}function c(f){var y=f.getSnapshot;f=f.value;try{var b=y();return!a(f,b)}catch(w){return!0}}function u(f,y){return y()}var h=typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"?u:l;return Z_.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:h,Z_}var XT;function y9(){return XT||(XT=1,J_.exports=pH()),J_.exports}var gH=y9();const fH=(e,r)=>fm(r)?r:rH(r)&&fm(r.defaultValue)?r.defaultValue:Array.isArray(e)?e[e.length-1]:e,xH={t:fH,ready:!1},yH=()=>()=>{},sr=(e,r={})=>{var z,G,ae;const{i18n:a}=r,{i18n:s,defaultNS:n}=p.useContext(mH)||{},i=a||s||dH();i&&!i.reportNamespaces&&(i.reportNamespaces=new hH),i||g9(i,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=p.useMemo(()=>{var ee;return se(se(se({},lH()),(ee=i==null?void 0:i.options)==null?void 0:ee.react),r)},[i,r]),{useSuspense:l,keyPrefix:c}=o,u=n||((z=i==null?void 0:i.options)==null?void 0:z.defaultNS),h=fm(u)?[u]:u||["translation"],f=p.useMemo(()=>h,h);(ae=(G=i==null?void 0:i.reportNamespaces)==null?void 0:G.addUsedNamespaces)==null||ae.call(G,f);const y=p.useRef(0),b=p.useCallback(ee=>{if(!i)return yH;const{bindI18n:ne,bindI18nStore:te}=o,Y=()=>{y.current+=1,ee()};return ne&&i.on(ne,Y),te&&i.store.on(te,Y),()=>{ne&&ne.split(" ").forEach(q=>i.off(q,Y)),te&&te.split(" ").forEach(q=>i.store.off(q,Y))}},[i,o]),w=p.useRef(),v=p.useCallback(()=>{if(!i)return xH;const ee=!!(i.isInitialized||i.initializedStoreOnce)&&f.every(U=>tH(U,i,o)),ne=r.lng||i.language,te=y.current,Y=w.current;if(Y&&Y.ready===ee&&Y.lng===ne&&Y.keyPrefix===c&&Y.revision===te)return Y;const H={t:i.getFixedT(ne,o.nsMode==="fallback"?f:f[0],c),ready:ee,lng:ne,keyPrefix:c,revision:te};return w.current=H,H},[i,f,c,o,r.lng]),[k,S]=p.useState(0),{t:N,ready:C}=gH.useSyncExternalStore(b,v,v);p.useEffect(()=>{if(i&&!C&&!l){const ee=()=>S(ne=>ne+1);r.lng?JT(i,r.lng,f,ee):fN(i,f,ee)}},[i,r.lng,f,C,l,k]);const O=i||{},T=p.useRef(null),P=p.useRef(),E=ee=>{const ne=Object.getOwnPropertyDescriptors(ee);ne.__original&&delete ne.__original;const te=Object.create(Object.getPrototypeOf(ee),ne);if(!Object.prototype.hasOwnProperty.call(te,"__original"))try{Object.defineProperty(te,"__original",{value:ee,writable:!1,enumerable:!1,configurable:!1})}catch(Y){}return te},R=p.useMemo(()=>{const ee=O,ne=ee==null?void 0:ee.language;let te=ee;ee&&(T.current&&T.current.__original===ee?P.current!==ne?(te=E(ee),T.current=te,P.current=ne):te=T.current:(te=E(ee),T.current=te,P.current=ne));const Y=[N,te,C];return Y.t=N,Y.i18n=te,Y.ready=C,Y},[N,O,C,O.resolvedLanguage,O.language,O.languages]);if(i&&l&&!C)throw new Promise(ee=>{const ne=()=>ee();r.lng?JT(i,r.lng,f,ne):fN(i,f,ne)});return R},{slice:bH,forEach:vH}=[];function wH(e){return vH.call(bH.call(arguments,1),r=>{if(r)for(const a in r)e[a]===void 0&&(e[a]=r[a])}),e}function jH(e){return typeof e!="string"?!1:[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(a=>a.test(e))}const QT=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,_H=function(e,r){const s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},n=encodeURIComponent(r);let i=`${e}=${n}`;if(s.maxAge>0){const o=s.maxAge-0;if(Number.isNaN(o))throw new Error("maxAge should be a Number");i+=`; Max-Age=${Math.floor(o)}`}if(s.domain){if(!QT.test(s.domain))throw new TypeError("option domain is invalid");i+=`; Domain=${s.domain}`}if(s.path){if(!QT.test(s.path))throw new TypeError("option path is invalid");i+=`; Path=${s.path}`}if(s.expires){if(typeof s.expires.toUTCString!="function")throw new TypeError("option expires is invalid");i+=`; Expires=${s.expires.toUTCString()}`}if(s.httpOnly&&(i+="; HttpOnly"),s.secure&&(i+="; Secure"),s.sameSite)switch(typeof s.sameSite=="string"?s.sameSite.toLowerCase():s.sameSite){case!0:i+="; SameSite=Strict";break;case"lax":i+="; SameSite=Lax";break;case"strict":i+="; SameSite=Strict";break;case"none":i+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return s.partitioned&&(i+="; Partitioned"),i},eE={create(e,r,a,s){let n=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};a&&(n.expires=new Date,n.expires.setTime(n.expires.getTime()+a*60*1e3)),s&&(n.domain=s),document.cookie=_H(e,r,n)},read(e){const r=`${e}=`,a=document.cookie.split(";");for(let s=0;s<a.length;s++){let n=a[s];for(;n.charAt(0)===" ";)n=n.substring(1,n.length);if(n.indexOf(r)===0)return n.substring(r.length,n.length)}return null},remove(e,r){this.create(e,"",-1,r)}};var kH={name:"cookie",lookup(e){let{lookupCookie:r}=e;if(r&&typeof document!="undefined")return eE.read(r)||void 0},cacheUserLanguage(e,r){let{lookupCookie:a,cookieMinutes:s,cookieDomain:n,cookieOptions:i}=r;a&&typeof document!="undefined"&&eE.create(a,e,s,n,i)}},NH={name:"querystring",lookup(e){var s;let{lookupQuerystring:r}=e,a;if(typeof window!="undefined"){let{search:n}=window.location;!window.location.search&&((s=window.location.hash)==null?void 0:s.indexOf("?"))>-1&&(n=window.location.hash.substring(window.location.hash.indexOf("?")));const o=n.substring(1).split("&");for(let l=0;l<o.length;l++){const c=o[l].indexOf("=");c>0&&o[l].substring(0,c)===r&&(a=o[l].substring(c+1))}}return a}},SH={name:"hash",lookup(e){var n;let{lookupHash:r,lookupFromHashIndex:a}=e,s;if(typeof window!="undefined"){const{hash:i}=window.location;if(i&&i.length>2){const o=i.substring(1);if(r){const l=o.split("&");for(let c=0;c<l.length;c++){const u=l[c].indexOf("=");u>0&&l[c].substring(0,u)===r&&(s=l[c].substring(u+1))}}if(s)return s;if(!s&&a>-1){const l=i.match(/\/([a-zA-Z-]*)/g);return Array.isArray(l)?(n=l[typeof a=="number"?a:0])==null?void 0:n.replace("/",""):void 0}}}return s}};let Oh=null;const tE=()=>{if(Oh!==null)return Oh;try{if(Oh=typeof window!="undefined"&&window.localStorage!==null,!Oh)return!1;const e="i18next.translate.boo";window.localStorage.setItem(e,"foo"),window.localStorage.removeItem(e)}catch(e){Oh=!1}return Oh};var CH={name:"localStorage",lookup(e){let{lookupLocalStorage:r}=e;if(r&&tE())return window.localStorage.getItem(r)||void 0},cacheUserLanguage(e,r){let{lookupLocalStorage:a}=r;a&&tE()&&window.localStorage.setItem(a,e)}};let Ph=null;const rE=()=>{if(Ph!==null)return Ph;try{if(Ph=typeof window!="undefined"&&window.sessionStorage!==null,!Ph)return!1;const e="i18next.translate.boo";window.sessionStorage.setItem(e,"foo"),window.sessionStorage.removeItem(e)}catch(e){Ph=!1}return Ph};var TH={name:"sessionStorage",lookup(e){let{lookupSessionStorage:r}=e;if(r&&rE())return window.sessionStorage.getItem(r)||void 0},cacheUserLanguage(e,r){let{lookupSessionStorage:a}=r;a&&rE()&&window.sessionStorage.setItem(a,e)}},EH={name:"navigator",lookup(e){const r=[];if(typeof navigator!="undefined"){const{languages:a,userLanguage:s,language:n}=navigator;if(a)for(let i=0;i<a.length;i++)r.push(a[i]);s&&r.push(s),n&&r.push(n)}return r.length>0?r:void 0}},AH={name:"htmlTag",lookup(e){let{htmlTag:r}=e,a;const s=r||(typeof document!="undefined"?document.documentElement:null);return s&&typeof s.getAttribute=="function"&&(a=s.getAttribute("lang")),a}},OH={name:"path",lookup(e){var n;let{lookupFromPathIndex:r}=e;if(typeof window=="undefined")return;const a=window.location.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(a)?(n=a[typeof r=="number"?r:0])==null?void 0:n.replace("/",""):void 0}},PH={name:"subdomain",lookup(e){var n,i;let{lookupFromSubdomainIndex:r}=e;const a=typeof r=="number"?r+1:1,s=typeof window!="undefined"&&((i=(n=window.location)==null?void 0:n.hostname)==null?void 0:i.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i));if(s)return s[a]}};let b9=!1;try{document.cookie,b9=!0}catch(e){}const v9=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];b9||v9.splice(1,1);const DH=()=>({order:v9,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:e=>e});class w9{constructor(r){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(r,a)}init(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=r,this.options=wH(a,this.options||{},DH()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=n=>n.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=s,this.addDetector(kH),this.addDetector(NH),this.addDetector(CH),this.addDetector(TH),this.addDetector(EH),this.addDetector(AH),this.addDetector(OH),this.addDetector(PH),this.addDetector(SH)}addDetector(r){return this.detectors[r.name]=r,this}detect(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,a=[];return r.forEach(s=>{if(this.detectors[s]){let n=this.detectors[s].lookup(this.options);n&&typeof n=="string"&&(n=[n]),n&&(a=a.concat(n))}}),a=a.filter(s=>s!=null&&!jH(s)).map(s=>this.options.convertDetectedLanguage(s)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?a:a.length>0?a[0]:null}cacheUserLanguage(r){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.caches;a&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(r)>-1||a.forEach(s=>{this.detectors[s]&&this.detectors[s].cacheUserLanguage(r,this.options)}))}}w9.type="languageDetector";const RH={dashboard:"Dashboard",assets:"Assets",workOrders:"Work Orders",maintenance:"Asset Maintenance",ppm:"PPM",logout:"Logout",login:"Login",email:"Email",password:"Password",submit:"Submit",cancel:"Cancel",save:"Save",saveChanges:"Save Changes",delete:"Delete",deleting:"Deleting...",edit:"Edit",create:"Create",search:"Search",filter:"Filter",export:"Export",import:"Import",loading:"Loading...",noData:"No data available",error:"Error",success:"Success",darkMode:"Dark Mode",lightMode:"Light Mode",language:"Language",english:"English",arabic:"Arabic",backToDashboard:"Back to Dashboard",back:"Back",saving:"Saving...",tryAgain:"Try Again",filters:"Filters",enterFilterName:"Enter filter name",saveFilterPreset:"Save Filter Preset",saveFilter:"Save Filter",filtering:"Filtering...",updating:"Updating...",clearFilters:"Clear filters",total:"Total",selected:"selected",rows:"rows",actions:"Actions",selectAllTitle:"Select all",deselectAllTitle:"Deselect all",typeToSearch:"Type to search...",typing:"typing...",enterFilterNameExample:"Enter filter name (e.g., 'Open High Priority')",yes:"Yes",no:"No"},MH={title:"SEERA-ASM",loggedInAs:"Logged in as:",version:"Seera-ASM v2.26",inventory:"Inventory",ppmPlanner:"PPM Planner",maintenanceCalendar:"Maintenance Calendar",activeMap:"Active Map",maintenanceTeam:"Maintenance Team",procurement:"Procurement",projects:"Project Management",sla:"Service Level Agreement (SLA)",support:"Support",inspection:"Inspection",sfdaEntries:"SFDA Recalls",deleteRequests:"Delete Requests",userProfile:"User Profile"},LH={moduleTitle:"Project Management",title:"Projects",listTotal:"Total: ",listProject:"project",listProjects:"projects",projectsDoctype:"Projects",tasksDoctype:"Tasks",timesheetDoctype:"Timesheets",projectTemplateDoctype:"Project templates",activityTypeDoctype:"Activity types",newProject:"New project",newTask:"New task",newTimesheet:"New timesheet",newProjectTemplate:"New project template",newActivityType:"New activity type",searchPlaceholder:"Search by project name…",noProjects:"No projects found.",noTasks:"No tasks found.",noTimesheets:"No timesheets found.",projectName:"Project name",customer:"Customer",expectedEnd:"Expected end",progress:"Progress",project:"Project",assignedTo:"Assigned to",dueDate:"Due date",timesheetId:"Timesheet",totalHours:"Total hours",taskColumn:"Task",templateCreated:"Template saved.",templateUpdated:"Template updated.",timesheetCreated:"Timesheet saved.",timesheetUpdated:"Timesheet updated.",reportsDashboardTitle:"Project reports",reportsDashboardSubtitle:"Portfolio KPIs and charts from Project, Task, and Timesheet data.",projectOverviewSection:"Project overview",projectOverviewBanner:"Project Overview",reportProjectFilter:"Report project",reportProjectFilterHint:"Selection applies to charts, KPIs, and tasks. Project snapshot and project updates appear only when a project is selected.",selectProjectPlaceholder:"Select project…",searchProjectPlaceholder:"Search by name or ID…",clearProjectSelection:"Clear selection",noMatchingOpenProjects:"No matching open projects.",projectPickerLimitNote:"Showing up to 2,000 most recently modified open projects. Refine search to find one.",snapshotProjectBudget:"Project budget",snapshotOverallShort:"Overall",overviewProjectNameLabel:"Project Name :",overviewDepartmentLabel:"Department:",overviewDateLabel:"DATE:",overviewProgressLabel:"Progress:",overviewCustomerLabel:"Customer:",overviewDatesUpToday:"Dates up today",overviewProjectDuration:"Project Duration",overviewStartDateLabel:"Project start Date :",overviewEndDateLabel:"Project End Date :",projectNotesSection:"Project notes",hubSubtitle:"Projects, tasks, timesheets, and linked other documents.",reportsCardSub:"Charts & portfolio snapshot",chipOpenProjects:"Open projects",sectionCoreTitle:"Project & task management",sectionCoreSubtitle:"Core project tracking and planning.",tasksCardSub:"All tasks",timesheetsCardSub:"Time logs",reportsCardLabel:"Reports"},FH={twoFactorTitle:"Two-factor authentication (OTP App)",twoFactorSidebarTitle:"Two-factor auth",twoFactorOtpAppNoteShort:"Authenticator app required. Reset only if you need a new QR setup.",twoFactorLoading:"Loading security settings…",twoFactorRequired:"Two-factor authentication is required for your account.",twoFactorNotRequired:"Two-factor authentication is not required for your roles.",twoFactorDisabledSite:"Two-factor authentication is not enabled on this site.",twoFactorOtpAppNote:"Use an authenticator app (Google Authenticator, Authy, etc.). On first login after reset, check your email for a QR setup link.",resetOtp:"Reset authenticator",resetOtpConfirm:"Reset your OTP secret? You will need to scan a new QR code on your next login.",resetOtpSuccess:"Authenticator reset. Check your email on next login for setup instructions.",resetOtpFailed:"Could not reset authenticator."},IH={title:"SEERA-ASM",subtitle:"Asset Management System",signIn:"Sign in to continue",emailPlaceholder:"Enter your email",passwordPlaceholder:"Enter your password",loginFailed:"Login failed. Please check your credentials.",demoLogin:"Demo Login",or:"or",forgotPassword:"Forgot password?",forgotPasswordTitle:"Forgot password?",forgotPasswordHint:"Enter the email or username you use to sign in. We will send reset instructions to your registered email address.",forgotPasswordUserRequired:"Please enter your email or username.",forgotPasswordUserPlaceholder:"Email or username",forgotPasswordSubmit:"Send reset link",forgotPasswordClose:"Cancel",forgotPasswordSentSuccess:"Password reset instructions have been sent to your registered email address. Please check your inbox.",forgotPasswordNotFound:"No user account was found with the provided email address.",forgotPasswordTimeout:"The request took too long. Please try again or contact your administrator if outbound email is not configured.",forgotPasswordCannotReset:"Password reset is not available for this account.",forgotPasswordFailed:"Could not send reset email. Please try again later.",finishingSignOut:"Finishing sign-out…",afterPasswordResetSignIn:"Your password was updated. Please sign in with your new password.",twoFactorTitle:"Two-factor verification",twoFactorCodeLabel:"Verification code",twoFactorCodePlaceholder:"000000",twoFactorVerify:"Verify",twoFactorBackToLogin:"Back to sign in",twoFactorOtpAppEnter:"Enter the 6-digit code from your authenticator app.",twoFactorOtpAppSetupIncomplete:"Authenticator setup is not complete. Check your email for the QR setup link or contact your administrator.",twoFactorEmailQrHint:"Open the setup link in your email on this device to scan the QR code, then return here to enter your code.",twoFactorCodeRequired:"Please enter the verification code.",twoFactorInvalid:"Incorrect verification code. Please try again.",twoFactorSessionExpired:"Verification session expired. Please sign in again."},zH={title:"Dashboard",loading:"Loading dashboard...",totalAssets:"TOTAL NO. OF ASSETS",assetsDown:"Assets Down",openWorkOrders:"OPEN WORK ORDERS",workOrdersInProgress:"WORK ORDERS IN PROGRESS",completedWorkOrders:"COMPLETED WORK ORDERS",totalWorkOrders:"TOTAL WORK ORDERS",overdueWorkOrders:"OVERDUE WORK ORDERS",closedWorkOrders:"Closed Work Orders",upTime:"Up Time",downTime:"Down Time",workOrderStatus:"Work Order Status",workOrderByType:"Work Order by Type",maintenanceByAsset:"Maintenance - Asset wise Count",assigneesStatus:"Asset Maintenance Assignees Status Count",assigneesCount:"Assignees",totalTasksAssigned:"Tasks Assigned",maintenanceFrequency:"Asset Maintenance Frequency Chart",maintenanceLogs:"MAINTENANCE LOGS",assetUptime:"Asset Uptime",avgResponseTime:"Avg Response Time",maintenanceEfficiency:"Maintenance Efficiency",overdueMaintenance:"Overdue Maintenance",upDownTimeChart:"Up & Down Time Chart",ppmStatus:"PPM Status",completionRate:"Contractor Completion Rate",completionRateChartHint:"Completion % over last 7 months — hover a point for details",completionRateTooltip:"{{value}}% completion rate",viewFullReport:"View Full Report",noDataAvailable:"No data available",loadingTechnicianHours:"Loading technician hours...",loadingTechnicianWorkData:"Loading technician work data...",welcome:"Welcome,",user:"User",failedToLoad:"Failed to load dashboard data",recentRecords:"Recent Records",latestEntries:"Latest entries from your Frappe backend",quickActions:"Quick Actions",cardTotalAssets:"Total Assets",cardOpenWorkOrders:"Open Work Orders",cardInProgress:"In Progress",cardCompletedWorkOrders:"Completed Work Orders",viewUsers:"View Users",manageUserAccounts:"Manage user accounts",settings:"Settings",configurePreferences:"Configure your preferences",events:"Events",viewCalendarEvents:"View calendar events",reports:"Reports",viewAnalyticsReports:"View analytics and reports",ppmTemplateCounts:"PPM Template Counts",repairCost:"Repair Cost",dashboardFilter:"Dashboard Filter",allDepartments:"All Departments",workOrderStatusDistribution:"Work Order Status Distribution",workOrderInspectionSummary:"Work Order Inspection Summary",woRejectionSummary:"WO Rejection Summary",total:"Total",inProgress:"In Progress",completed:"Completed",totalSales:"Total Sales",average:"Average",noChartDataAvailable:"No chart data available",loadingInspectionData:"Loading inspection data...",noInspectionDataAvailable:"No inspection data available",totalRejections:"Total rejections",loadingRejectionData:"Loading rejection data...",noRejectionDataAvailable:"No rejection data available",department:"Department",allOperational:"All Operational",low:"Low",highPriority:"High Priority",allClear:"All Clear",fastResponse:"Fast Response",monitor:"Monitor",onTrack:"On Track",needsAttention:"Needs Attention",totalHours:"Total: {{value}} hours",technicianWorkingHours:"Technicians Working Hours",techniciansWorked:"Technicians Work Summary",pendingReviewWorkOrders:"Pending Review",clear:"Clear",clearFilter:"Clear Filter",label:"Label",open:"Open"},$H={assetId:"Asset ID",assetName:"Asset Name",serialNumber:"Serial Number",company:"Company/Hospital",building:"Building",roomNumber:"Room Number",location:"Location",department:"Department",deviceStatus:"Device Status",modality:"Modality",manufacturer:"Manufacturer",supplier:"Supplier",assetCategory:"Asset Category",purchaseDate:"Purchase Date",purchaseAmount:"Purchase Amount",availableForUseDate:"Available For Use Date",createdOn:"Created On",modifiedOn:"Modified On",createdBy:"Created By",modifiedBy:"Modified By",workOrderId:"Work Order ID",workOrderType:"Type",status:"Status",priority:"Priority",description:"Description",assignedTo:"Assigned To",scheduledDate:"Scheduled Date",completedDate:"Completed Date",hospital:"Hospital",assetType:"Asset Type",siteName:"Site Name",assignedSupervisor:"Assigned Supervisor",assignedContractor:"Assigned Contractor",serialNumberShort:"Serial",departmentShort:"Dept",manufacturerShort:"Mfr",workOrderIdShort:"WO ID",assetShort:"Asset",typeShort:"Type",nameShort:"Name",pmId:"PM ID",name:"Name"},UH={filterBy:"Filter By",createdDate:"Created Date",latestModifiedDate:"Latest Modified Date",startDate:"Start Date",endDate:"End Date",assetId:"Asset ID",hospital:"Hospital",name:"Name",serial:"Serial",status:"Status",location:"Location",dept:"Dept",modality:"Modality",mfr:"Mfr",supplier:"Supplier",workOrderId:"WO ID",asset:"Asset",type:"Type",priority:"Priority",workflowState:"Workflow State",allStatuses:"All Statuses",allStates:"All States",allTypes:"All Types",allPriorities:"All priorities",allHospitals:"All Hospitals",allModalities:"All Modalities",filterByCompany:"Filter by Company",allManufacturers:"All Manufacturers",sortBy:"Sort by",sortCreationNewest:"Creation (newest first)",sortCreationOldest:"Creation (oldest first)",sortModifiedNewest:"Modified (newest first)",sortModifiedOldest:"Modified (oldest first)",sortNameAsc:"Name (A-Z)",sortNameDesc:"Name (Z-A)",sortAssetNameAsc:"Asset Name (A-Z)",sortAssetNameDesc:"Asset Name (Z-A)",sortItemNameAsc:"Item Name (A-Z)",sortItemNameDesc:"Item Name (Z-A)",sortTeamNameAsc:"Team Name (A-Z)",sortTeamNameDesc:"Team Name (Z-A)"},BH={addNew:"Add New",searchPlaceholder:"Search...",noResults:"No results found",showing:"Showing",of:"of",results:"results",selectAll:"Select All",deselectAll:"Deselect All",selected:"selected",actions:"Actions",view:"View",edit:"Edit",delete:"Delete",duplicate:"Duplicate",export:"Export",print:"Print",filters:"Filters",clearFilters:"Clear Filters",applyFilters:"Apply Filters",columns:"Columns",exportSelected:"Export Selected",exportAllOnPage:"Export All on Page",exportAllWithFilters:"Export All with Filters",exportFormat:"Export Format",csv:"CSV",excel:"Excel",exporting:"Exporting...",exportComplete:"Export Complete",close:"Close",loading:"Loading...",refresh:"Refresh",deselectAllTitle:"Deselect all",selectAllTitle:"Select all",typeToSearch:"Type to search...",enterFilterName:"Enter filter name",enterFilterNameExample:"Enter filter name (e.g., 'Open High Priority')",allStatuses:"All Statuses",noIssuesFound:"No issues found",createFirstIssue:"Create your first issue",saveFilterPreset:"Save Filter Preset",saveFilter:"Save Filter",savedFilters:"Saved Filters",clear:"Clear",typing:"typing...",filtering:"Filtering...",noMaintenanceTeamsFound:"No maintenance teams found",createFirstTeam:"Create your first team",all:"All",tryAdjustingFilters:"Try adjusting your search or filters",getStartedCreateFirst:"Get started by creating your first PPM Planner",noMaintenanceLogsFound:"No maintenance logs found",createFirstMaintenanceLog:"Create your first maintenance log",total:"Total",noPPMSchedulesFound:"No PPM schedules found",createFirstPPMSchedule:"Create your first PPM schedule",deleteConfirmCannotUndo:"This action cannot be undone."},WH={title:"Assets",addAsset:"Add New Asset",assetDetails:"Asset Details",assetInformation:"Asset Information",newAsset:"New Asset",duplicateAsset:"Duplicate Asset",fromAsset:"From Asset",creatingFromAsset:"Creating Work Order from Asset",assetInfoPrefilled:"Asset information prefilled from",pleaseSelectWorkOrderType:"Please select a Work Order type and add any additional details",loadingAssetDetails:"Loading asset details...",pleaseEnterAssetName:"Please enter an Asset Name",pleaseSelectCategory:"Please select a Category",assetDuplicatedSuccessfully:"Asset duplicated successfully!",assetCreatedSuccessfully:"Asset created successfully!",assetUpdatedSuccessfully:"Asset updated successfully!",sourceAssetNotFound:"Source Asset Not Found",assetNotFoundMessage:"The asset you're trying to duplicate could not be found.",backToAssetsList:"Back to Assets List",backToList:"Back to assets list",createNewAsset:"Create New Asset",newAssetDetails:"New Asset Details",noAssetsFound:"No assets found",createFirstAsset:"Create your first asset",deleteConfirmTitle:"Delete Asset",deleteConfirmMessage:"Are you sure you want to delete this asset? This action cannot be undone.",noDataToExport:"No data to export",loadingPermissions:"Loading permissions...",selectAssetId:"Select Asset ID",selectHospital:"Hospital",viewDetails:"View Details",editAsset:"Edit Asset",createWorkOrder:"Create Work Order",viewLinkedWOs:"View Linked Work Orders",moreActions:"More Actions",exportAsJson:"Export as JSON",printAsset:"Print",status:{up:"Up",down:"Down"},deviceStatus:"Device Status",apiNotAvailable:"Asset API Not Available",apiNotDeployed:"The Asset API endpoint is not deployed yet.",tryCreatingNew:"Try Creating a New Asset (Demo)",listTotal:"Total: ",table:{assetName:"Asset Name",serialNo:"Serial No",company:"Company",location:"Location",status:"Status",updatedOn:"Updated on",actions:"Actions"},export:{title:"Export Assets",selectData:"Select Data to Export",selectedRows:"Selected Rows",selectedCount:"Export {{count}} selected asset ",currentPage:"Current Page",currentPageCount:"Export {{count}} asset on current page",allWithFilters:"All Records (with current filters)",allWithFiltersCount:"Export all {{count}} asset matching current filters",csvDesc:"Comma-separated values",excelDesc:"XLSX spreadsheet",columnsToExport:"Columns to Export",selectAll:"Select All",resetToDefault:"Reset to Default",columnsSelected:"{{count}} column selected",exporting:"Exporting...",exportButton:"Export",exportingSelected:"Exporting {{count}} selected row ",exportingPage:"Exporting {{count}} row from current page",exportingAll:"Exporting all {{count}} row "},detail:{assetInformation:"Asset Information",technicalSpecs:"Technical Specs",financialDetails:"Financial Details",assetFinanceBooks:"Asset Finance Books",addRow:"Add Row",duplicatingFrom:"Duplicating from:",noDepartmentsMapped:"No departments mapped to this building",departmentsAvailable:"{{count}} department(s) available (filtered by building)",selectDepartmentForRoom:"Select Department to enable Room Number",depreciationMethodNote:"The depreciation method is an accounting method used to allocate the cost of a tangible asset over its useful life.",calculateDepreciation:"Calculate Depreciation",noFinanceBooksYet:'No finance books added yet. Click "Add Row" to add one.',noSparePartsYet:'No spare parts added yet. Click "Add Row" to add one.',assetName:"Asset Name",category:"Category",type:"Asset Type",modality:"Modality",class:"Class",assetId:"Asset ID",deviceStatus:"Device Status",serialCode:"Serial Code",technicalDepartment:"Technical Department",manufacturer:"Manufacturer",model:"Model",totalHours:"Total Hours",downTimeHours:"Down Time (Hours)",upTimeHours:"Up Time (Hours)",placeholderAssetName:"e.g. Laptop Model X",placeholderSerialCode:"e.g. SN-12345",placeholderModelNumber:"Model number",placeholderZero:"0",placeholderDescription:"Brief description of the asset",placeholderPONumber:"PO number",selectClass:"Select class",classA:"Class A",classB:"Class B",classC:"Class C",autoGenerated:"Auto-generated",calculatedFromAvailableDate:"Calculated from Available For Use Date",calculatedTotalMinusDown:"Calculated: Total Hours - Down Time",hospital:"Hospital",siteName:"Site name",selectSite:"Select Site",building:"Building",department:"Department",roomNumber:"Room Number",location:"Location",recalled:"Recalled",selectStatus:"Select status",operational:"Operational",underMaintenance:"Under Maintenance",decommissioned:"Decommissioned",selectServiceAgreement:"Select Service Agreement",warranty:"Warranty",contract:"Contract",frameWork:"Frame Work",mainContractor:"Main Contractor",outOfWarranty:"Out of warranty",underDismantle:"Under Dismantle",underInstallation:"Under Installation",selectServiceCoverage:"Select Service Coverage",pmOnly:"PM Only",labour:"Labour",labourAndParts:"Labour & Parts",comprehensive:"Comprehensive",supplierVendor:"Supplier/Vendor",selectMethod:"Select Method",straightLine:"Straight Line",doubleDecliningBalance:"Double Declining Balance",writtenDownValue:"Written Down Value",manual:"Manual",recycling:"Recycling",donation:"Donation",sale:"Sale",assetDuplicatedSuccess:"Asset duplicated successfully!",assetCreatedSuccess:"Asset created successfully!",assetUpdatedSuccess:"Asset updated successfully!",failedToSave:"Failed to save asset",cannotSubmitNotSaved:"Cannot submit: Asset not saved yet",confirmSubmit:'Are you sure you want to submit this asset? Once submitted, only fields marked as "Allow on Submit" can be edited.',assetSubmittedSuccess:"Asset submitted successfully!",failedToSubmit:"Failed to submit asset",pleaseSaveFirstForPPM:"Please save the asset first to view PPM Plan",pleaseSaveFirstForHistory:"Please save the asset first to view Asset History",failedToLoadPPMPlan:"Failed to load PPM Plan. Please try again.",noPlannedMaintenance:"No planned maintenance found for this asset",noWorkOrdersFound:"No Work Orders Found",noSparePartsUsed:"No Spare Parts Used",noMaintenanceRecords:"No Maintenance Records Found",noMaintenanceTasks:"No Maintenance Tasks Found",selectBuildingFirst:"Select Building first to enable Department",coverage:"Coverage",siteContractor:"Site Contractor",contractNumber:"Contract Number",serviceAgreement:"Service Agreement",serviceCoverage:"Service Coverage",purchaseOrderNumber:"Purchase Order Number",grossPurchaseAmount:"Gross Purchase Amount",purchaseDate:"Purchase Date",installationDate:"Installation Date",availableForUseDate:"Available For Use Date",financeBook:"Finance Book",depreciationMethod:"Depreciation Method",totalDepreciations:"Total Depreciations",frequencyMonths:"Frequency (Months)",depreciationPostingDate:"Depreciation Posting Date",startDate:"Start Date",endDate:"End Date",totalAmount:"Total Amount",selectRoomFirst:"Select Room Number to enable Location",autoSetFromRoom:"Auto-set from room mapping",moreDetails:"More Details"}},HH=JSON.parse(`{"title":"Work Orders","addWorkOrder":"Add New Work Order","workOrderDetails":"Work Order Details","newWorkOrder":"New Work Order","duplicateWorkOrder":"Duplicate Work Order","createFromAsset":"Create Work Order from Asset","createFromSupportIssue":"Create Work Order from Support Issue","closeWorkOrders":"Close Work Orders","closeConfirmTitle":"Close Work Orders","closeConfirmMessage":"Are you sure you want to close the selected work order(s)?","deleteConfirmMessage":"Are you sure you want to delete this work order? This action cannot be undone.","cancelConfirmMessage":"Are you sure you want to cancel this work order? This will mark the work order as cancelled and you can then delete it if needed.","assignConfirmMessage":"Are you sure you want to assign this work order to the following technician(s)?","deleteWorkOrder":"Delete Work Order","cancelWorkOrder":"Cancel Work Order","loadingWorkOrders":"Loading work orders...","loadingDetails":"Loading work order details...","backToList":"Back to work orders list","status":{"open":"Open","work_in_progress":"Work In Progress","pending_review":"Pending Review","completed":"Completed","cancelled":"Cancelled","closed":"Closed"},"priorityNormal":"Normal","priorityUrgent":"Urgent","workflowState":{"draft":"Draft"},"priority":{"normal":"Normal","urgent":"Urgent"},"table":{"workOrderId":"Work Order ID","asset":"Asset","type":"Type","technicalReport":"Technical Report","department":"Department","workflowState":"Workflow State","priority":"Priority","noWorkOrdersFound":"No work orders found","createFirstWorkOrder":"Create your first work order"},"export":{"title":"Export Work Orders","selectData":"What to Export","selectedRows":"Selected Rows","selectedCount":"Export {{count}} selected work order ","currentPage":"Current Page","currentPageCount":"Export {{count}} work order on current page","allWithFilters":"All Records (with current filters)","allWithFiltersCount":"Export all {{count}} work order matching current filters","csvDesc":"Comma-separated values","excelDesc":"XLSX spreadsheet","columnsToExport":"Columns to Export","selectAll":"Select All","resetToDefault":"Reset to Default","columnsSelected":"{{count}} column selected","exporting":"Exporting...","exportButton":"Export","exportingSelected":"Exporting {{count}} selected row ","exportingPage":"Exporting {{count}} row from current page","exportingAll":"Exporting all {{count}} row "},"closeModal":{"title":"Close Work Orders","confirmBulkClose":"Confirm Bulk Close Operation","aboutToClose":"You are about to close {{count}} work order . This action will change their workflow state to Closed.","alreadyClosedNote":"Note: {{count}} work order{{count !== 1 ? 's are' : ' is'}} already closed and will be skipped.","selectedWorkOrders":"Selected Work Orders ({{count}})","workOrderId":"Work Order ID","currentStatus":"Current Status","workflowState":"Workflow State","alreadyClosed":"(already closed)","willClose":"Will close {{count}} work order ","allAlreadyClosed":"All selected work orders are already closed","cancel":"Cancel","close":"Close","closing":"Closing..."},"detail":{"workOrderInformation":"Work Order Information","assignments":"Assignments","statusSummary":"Status Summary","existingWorkOrders":"Existing Work Order(s):","created":"Created","proceedCreateNew":"Do you still want to proceed with creating a new Work Order?","loadingTechnicians":"Loading technicians...","feedbackBy":"Feedback By","overallSatisfaction":"Overall Satisfaction","overallRatingPreview":"Overall Rating Preview","uploading":"Uploading...","uploadOpeningFile":"Upload Opening File","uploadClosingFile":"Upload Closing File","noAttachment":"No attachment","noClosingAttachment":"No closing attachment","closingAttachment":"Closing Attachment","currentState":"Current State","loadingActions":"Loading actions...","actionResults":"Action Results:","checkingFeedback":"Checking feedback...","yourRating":"Your Rating","repairStatus":"Repair Status","priority":"Priority","lastModified":"Last Modified","documentStatus":"Document Status","loadingActivity":"Loading activity...","added":"Added:","removed":"Removed:","modified":"Modified:","items":"item(s)","rows":"row(s)","pleaseAllowPopupsServiceReport":"Please allow popups for this site to print the Service Report.","pleaseProvideAtLeastOneRating":"Please provide at least one rating","feedbackSubmittedSuccessfully":"Feedback submitted successfully!","failedToSubmitFeedback":"Failed to submit feedback","feedbackUpdatedSuccessfully":"Feedback updated successfully!","failedToUpdateFeedback":"Failed to update feedback","locationAutoSetTo":"Location auto-set to: {{location}}","noTechniciansSelected":"No technicians selected","techniciansAssignedSuccessfully":"{{count}} additional technician(s) assigned successfully","removedTechnician":"Removed {{name}}","itemAlreadyAdded":"Item \\"{{itemCode}}\\" is already added in row {{row}}. Please select a different item.","insufficientStock":"Insufficient stock for {{itemCode}}. Available: {{available}}, Required: {{required}}","pleaseEnterSerialNumberToSearch":"Please enter a serial number to search","assetFound":"Asset found: {{name}}","noAssetFoundWithSerialNumber":"No asset found with this serial number","fileSizeExceeds":"File size exceeds 10MB limit","fileUploadedSuccessfully":"File uploaded successfully","failedToUploadFile":"Failed to upload file","attachmentRemoved":"Attachment removed","failureDateSetToCurrentTime":"Failure Date set to current time","firstRespondedOnSetToCurrentTime":"First Responded On set to current time","completionDateSetToCurrentTime":"Completion Date set to current time","firstRespondedOnSetTo":"First Responded On set to {{datetime}}","completionDateSetTo":"Completion Date set to {{datetime}}","assignedSupervisorMandatory":"Assigned Supervisor is mandatory for Work Control role.","assignedEngineerMandatory":"Assigned Engineer is mandatory for Work Control role.","assignedTechnicianMandatory":"Assigned Technician is mandatory when workflow is \\"Sent to Engineer\\".","workOrderCancelledSuccessfully":"Work Order cancelled successfully!","failedToCancel":"Failed to cancel: {{error}}","workOrderDeletedSuccessfully":"Work Order deleted successfully!","failedToDelete":"Failed to delete: {{error}}","pleaseSelectWorkOrderType":"Please select a Work Order Type","workOrderUpdatedSuccessfully":"Work order updated successfully!","workOrderCreatedSuccessfully":"Work order created successfully!","workOrderCreatedFromAssetSuccessfully":"Work order created from asset successfully!","workOrderCreatedFromIssueSuccessfully":"Work order created and linked. The support ticket stays open until the requester updates it after the work order is closed.","loadingSupportIssue":"Loading support issue...","failedToLoadSupportIssue":"Could not load support issue. You can still fill the work order manually.","supportIssue":"Support Issue","workOrderDuplicatedSuccessfully":"Work order duplicated successfully!","documentModifiedByAnotherUser":"Document was modified by another user. Refreshing...","pleaseReviewLatestChanges":"Please review the latest changes and try saving again.","failedToSaveWorkOrder":"Failed to save work order: {{error}}","technicalReportMandatoryForSupervisor":"Technical Report is mandatory when sending directly to Supervisor. Please fill in the Technical Report field before proceeding.","applyingAction":"Applying action \\"{{action}}\\"...","assignedTo":"Assigned to: {{name}}","actionCompletedSuccessfully":"Action \\"{{action}}\\" completed successfully!","documentModifiedRefreshing":"Document was modified. Refreshing...","tryActionAgainAfterReview":"Please try the action again after reviewing the latest changes.","failedToApplyAction":"Failed to apply action \\"{{action}}\\". {{error}}","editModeEnabled":"Edit mode enabled","editCancelledChangesDiscarded":"Edit cancelled - changes discarded","closingAttachmentRemoved":"Closing attachment removed","closingAttachmentUploadedSuccessfully":"Closing attachment uploaded successfully","failedToUploadClosingAttachment":"Failed to upload closing attachment","newStockItemRowAdded":"New stock item row added","stockItemRemoved":"Stock item {{item}} removed","activityLogRefreshed":"Activity log refreshed","errorLabel":"Error","backToList":"Back to work orders list","duplicateWorkOrder":"Duplicate Work Order","createFromAsset":"Create Work Order from Asset","createFromSupportIssue":"Create Work Order from Support Issue","newWorkOrder":"New Work Order","workOrderDetails":"Work Order Details","existingWorkOrderFound":"Existing Work Order Found","workOrderExistsForAsset":"A Work Order already exists for this Asset with workflow state not yet Approved or Closed.","workOrderExistsForTypeAndRoom":"A Work Order already exists for this Work Order Type and Room No with workflow state not yet Approved or Closed.","proceedWithNewWO":"Do you still want to proceed with creating a new Work Order?","proceedAnyway":"Proceed Anyway","noGoBack":"No, Go Back","yesCancel":"Yes, Cancel","cancelling":"Cancelling...","deleting":"Deleting...","selectAdditionalTechnicians":"Select Additional Technicians","searchTechnicians":"Search technicians...","techniciansSelected":"{{count}} technician(s) selected","clearAll":"Clear all","noTechniciansMatchSearch":"No technicians match your search","noTechniciansFound":"No technicians found","hospital":"Hospital","technicalDepartment":"Technical Department","woType":"WO Type","assetId":"Asset ID","assetName":"Asset Name","extensionNo":"Extension No","building":"Building","departmentName":"Department Name","roomNo":"Room No","location":"Location","manufacturer":"Manufacturer","supplier":"Supplier","assignedSupervisor":"Assigned Supervisor","assignedEngineer":"Assigned Engineer","assignedTechnician":"Assigned Technician","fromAsset":"From Asset","assetDetailsAutoPopulated":"Asset details auto-populated","selectBuildingFirst":"Select Building first to enable Department","printServiceReport":"Print Service Report","removeAttachment":"Remove attachment","removeClosingAttachment":"Remove closing attachment","setToCurrentDateTime":"Set to current date & time","selectItem":"Select Item","selectWarehouse":"Select Warehouse","autoPopulatedFromStock":"Auto-populated from stock","removeItem":"Remove item","noItemsAddedYet":"No items added yet","commentsDiscussion":"Comments & Discussion","refreshActivityLog":"Refresh activity log","supervisorsAvailableForType":"{{count}} Assigned Supervisor(s) available for this type","civilWorkCategory":"Civil Work Category","selectCivilWorkCategory":"Select Civil Work Category","selectPendingReason":"Select Pending Reason","pleaseSpecifyReason":"Please specify the reason...","selectServiceAgreement":"Select Service Agreement","selectServiceCoverage":"Select Service Coverage","describeComplaint":"Describe the nature of complaint...","describeWorkPerformed":"Describe the work performed...","enterSerialNumber":"Enter serial number","searchAssetBySerial":"Search asset by serial number","workOrder":"Work Order:","giveFeedback":"Give Feedback","editFeedback":"Edit Feedback","feedbackDetails":"Feedback Details","confirmAssignment":"Confirm Assignment","notRated":"Not rated","serviceReport":"Service Report","assetInfoPrefilled":"Asset information has been pre-filled from","linkedFromAsset":"Linked from Asset:","loadingAssetDetails":"Loading asset details...","cancelled":"Cancelled","workOrderId":"Work Order ID","pendingReason":"Pending Reason","otherReason":"Other Reason","serviceAgreementDetails":"Service Agreement Details","siteContractor":"Site Contractor","subcontractor":"Subcontractor","model":"Model","description":"Description","natureOfComplaint":"Nature of Complaint","technicalReport":"Technical Report","selectWoTypeFirstForSupervisors":"Select Work Order Type first to filter Assigned Supervisors","noSupervisorsFound":"No Assigned Supervisors found for this Work Order Type","requiredForExistingWO":"* Required for existing Work Orders","selectWoTypeFirstForEngineers":"Select Work Order Type first to filter Engineers","noEngineersFound":"No Engineers (Contractor Engineer role) found for this Work Order Type","engineersAvailable":"{{count}} Engineer(s) available","selectWoTypeFirstForTechnicians":"Select Work Order Type first to filter Technicians","noTechniciansFoundForType":"No Technicians found for this Work Order Type","techniciansAvailable":"{{count}} Technician(s) available","requiredForSentToEngineer":"* Required for \\"Sent to Engineer\\" state","autoCalculated":"(Auto-calculated)","autoSetOnRepairStart":"(Auto-set on repair start)","autoSetOnClose":"(Auto-set on close)","totalItems":"Total Items:","confirmAction":"Confirm Action","confirmActionMessage":"Are you sure you want to {{action}} this work order?","processing":"Processing...","yesAction":"Yes, {{action}}","systemManagerNote":"System Manager: Showing all valid actions for this state (conditions evaluated).","saveToSeeActions":"Save your changes to see all available actions.","availableActions":"Available Actions","allOptionsAvailable":"All Options Available","bothFilledMessage":"Both Technician and Technical Report are filled. You can now use any available workflow action above.","technicianAssigned":"Technician Assigned","assignedTechnicianLabel":"Assigned Technician:","wantToEnableSendToSupervisor":"Want to also enable \\"Send to Supervisor\\"?","fillTechnicalReportToUnlock":"Fill the \\"Technical Report\\" field to unlock this option","technicalReportFilled":"Technical Report Filled","howWasService":"How was the service for this work order?","noFeedbackYet":"No feedback has been given yet","statusInfoAfterCreation":"Status information will appear after creation","activityLog":"Activity Log","refreshActivityLogTitle":"Refresh activity log","noChangesRecorded":"No changes recorded yet","createdThisWorkOrder":"Created this Work Order","showLess":"Show Less","showAll":"Show All","entries":"entries","changedFrom":"changed from","documentUpdated":"Document updated","addItem":"Add Item","addFirstItem":"+ Add first item","item":"Item","valuationRate":"Valuation Rate","warehouse":"Warehouse","consumedQty":"Consumed Qty","availableStock":"Available Stock","totalValue":"Total Value","action":"Action","open":"Open","autoGenerated":"Auto-generated","updating":"Updating...","submitting":"Submitting...","updateFeedback":"Update Feedback","submitFeedback":"Submit Feedback","editRating":"Edit Rating","saveSelection":"Save Selection","troubleshootingTree":"Troubleshooting tree","troubleshootingGuideDone":"Completed","troubleshootingGuideDoneTitle":"Troubleshooting guide completed. Open again anytime to review the steps."},"troubleshootTree":{"pageTitle":"Troubleshooting tree","backToWorkOrder":"Back","workOrderBadge":"Work order: {{id}}","problemTypeTitle":"What type of problem is it?","selfServiceTitle":"Self-service checks","stepOf":"Step {{current}} of {{total}}","introHint":"Read the steps below. When you have actually tried them, use the button to continue.","confirmTried":"Yes, I've tried this","previousStep":"Previous step","guideCompleteBadge":"All steps done","allStepsCompleteTitle":"Troubleshooting steps completed","allStepsCompleteBodyWo":"Continue on the work order to resolve the complaint—technical report, photos, parts, and workflow actions.","allStepsCompleteBodyStandalone":"When you are ready, go back to Support to open or follow up on an issue.","continueToResolveComplaint":"Continue to resolve complaint","backToSupportFromGuide":"Back to support","reviewCategoryAgain":"Review this category again","cantComplete":"I can't complete these checks","cantCompleteHint":"Note what blocked you on the work order or tell your team lead.","cantCompleteStepPrompt":"Why can't you complete this step? (required to continue)","cantCompletePlaceholder":"e.g. No access to the panel, site policy, or missing tools…","saveExplanationContinue":"Save explanation and continue","backToChecks":"Back to checks","reasonRequiredToast":"Please explain why you can't complete this step to continue.","savedToWorkOrder":"Explanation saved on the work order.","explanationSavedStayOnGuide":"Saved to the technical report. You can keep going with the guide.","saveExplanationFailed":"Could not save to the work order. Try again.","workOrderStillLoading":"Work order is still loading. Wait a moment and try again.","notAvailableUntilRepairInProgress":"The troubleshooting guide is available after a technician is assigned (work order in Repair In Progress).","noSteps":"No steps configured for this category.","ultrasoundBadge":"Ultrasound diagnostic","footerTitle":"Still need help?","footerHint":"Continue on the work order to add details, attachments, or escalate through your normal process.","categories":{"air_conditioning":"Air conditioning","power":"Power & electrical","building_systems":"Building systems","applications_account":"Application & account","ultrasound":"GE Voluson 730 (Ultrasound)"},"steps":{"air_conditioning":[{"heroCaption":"Comfort and cooling basics","title":"Thermostat and operating mode","bullets":["Confirm the thermostat or controller is on, set to cool/heat as needed, and not locked or on a conflicting schedule.","If the display is blank, check power or batteries to the thermostat.","After changes, wait a few minutes; note room, setpoint, and what you observed."]},{"heroCaption":"Air movement","title":"Filters, grilles, and airflow","bullets":["Ensure supply/return grilles are open and not blocked.","If policy allows, check whether filters need cleaning or replacement.","Listen for unusual fan noise; note which indoor unit or zone is affected."]},{"heroCaption":"Condensate and drains","title":"Water and drain lines","bullets":["Look for water around the indoor unit; check visible condensate drains only if safe and permitted.","If you see active leaking, stop and report.","Record location and whether the issue is continuous or only when the system runs."]},{"heroCaption":"Before requesting service","title":"If there is still no improvement","bullets":["Capture temperatures, error codes or blinking patterns on the controller (if any).","List what you already tried and approximate times.","Do not open refrigerant circuits or electrical enclosures unless you are authorized."]}],"power":[{"heroCaption":"Panels, breakers, and protection devices","title":"Breakers, RCDs, and panels","bullets":["Identify whether one circuit or a whole area is affected.","Check the correct panel for that space; reset a tripped breaker only once if policy allows, and note which label matches the room or equipment.","If an RCD/GFCI device has tripped, press reset after unplugging new or suspect equipment—if it trips again, leave it off and report."]},{"heroCaption":"Local circuits","title":"Outlets, lighting, and equipment power","bullets":["Test another outlet on a different circuit; try a known-good lamp or charger.","Confirm equipment power switches and any local disconnects are on.","If only one device fails, try another socket before assuming a building fault."]},{"heroCaption":"Backup supply","title":"UPS, generators, and transfer","bullets":["If the site uses UPS or backup, check indicator panels for alarms or battery mode.","Do not reset generator or ATS equipment unless trained and authorized.","Record alarm messages verbatim for the work order."]},{"heroCaption":"Safety","title":"When to stop","bullets":["Smell of burning, arcing sounds, or hot panel surfaces: stay clear and report immediately.","Never defeat interlocks or safety covers.","Document affected areas and any labels on tripped devices."]}],"building_systems":[{"heroCaption":"Water and wet systems","title":"Shutoff and obvious leaks","bullets":["If safe, identify the nearest isolation valve for the affected fixture or zone—turn off only if you are authorized.","Contain small leaks with towels or bins; do not block drains meant for overflow.","Note color, flow rate, and whether hot or cold lines are involved."]},{"heroCaption":"Access and security","title":"Doors, locks, and access control","bullets":["Verify you are at the correct door or gate for the reported location.","For card or code access, confirm your credential is active; try a secondary reader if available.","Do not force doors or bypass locks—report access failures."]},{"heroCaption":"Fixtures","title":"Sanitary and small building items","bullets":["For simple blockages, use only approved tools or procedures; avoid chemical misuse.","Check for obvious obstructions where visible.","If sewage odor or backflow appears, stop and escalate."]},{"heroCaption":"Structure and glazing","title":"Glass, ceilings, and hazards","bullets":["Cordon off falling debris or broken glass; do not stand under damaged ceiling tiles.","Photograph from a safe distance if policy allows.","Record exact room/zone and approximate size of the issue."]}],"applications_account":[{"heroCaption":"Client side","title":"Browser, session, and cache","bullets":["Try a hard refresh or a second browser; close extra tabs if the app is slow.","Sign out and sign back in if the session seems stuck.","Note the exact URL, time, and any on-screen error text."]},{"heroCaption":"Connectivity","title":"Network and VPN","bullets":["Confirm Wi‑Fi or LAN is connected; try another network if permitted.","If VPN is required, reconnect and wait for full tunnel establishment.","Run a quick test to a known internal site only if standard procedure."]},{"heroCaption":"Identity","title":"Passwords, MFA, and lockouts","bullets":["Use the official password reset or unlock path—avoid sharing credentials.","If MFA fails, check device time sync and try one backup code if available.","Record whether the issue is all users or only your account."]},{"heroCaption":"Application errors","title":"Logs and support handoff","bullets":["Copy or screenshot error IDs; avoid pasting sensitive personal data into chat.","Note steps to reproduce in order.","Attach evidence to the work order or ticket per local policy."]}],"ultrasound":[{"heroCaption":"GE Voluson 730 — power and environment check","title":"Step 1 — Power supply and environment (Section 7-7-1)","bullets":["Verify the scanner power cable is firmly plugged into a standard wall outlet. Do NOT use a red emergency power outlet.","Confirm there is AC voltage at the wall outlet and that the room circuit breaker is ON.","Check that the main power switch on the back of the scanner is in the ON position — you should hear fan noise within a few seconds.","Ensure the room is not excessively hot. The GE Voluson 730 is prone to overheating — check that ventilation holes on the unit are clear of dust and obstructions.","If the scanner was recently moved from a cold environment (e.g. storage), allow at least 2 hours for temperature balance before powering on.","Record what you observe: any indicator lights, fan noise, amber/green ON/OFF button state."]},{"heroCaption":"GE Voluson 730 — probe inspection","title":"Step 2 — Probe and transducer check (Section 7-7-2, 7-7-3)","bullets":["Disconnect the probe from the port and reseat it firmly — a loose connection is the most common cause of missing or noisy images.","Visually inspect the probe cable along its full length for cracks, tears, or kinks. Check the connector for bent pins.","Inspect the probe lens for cracks or cuts — gel or disinfectant entering through cracks can permanently damage the transducer.","For 3D/4D mechanical probes (e.g. RAB series): gently press the dome — no error should appear. Wiggle the cable through its full length to check for intermittent faults.","If a second probe is available, swap it in. If the problem resolves, the fault is probe-related. If it persists across probes, the fault is in the machine itself.","Check the trackball: if it moves but is sluggish, remove the ball and clean it with a lint-free cloth. If it does not move at all, the trackball unit needs replacement."]},{"heroCaption":"GE Voluson 730 — image quality","title":"Step 3 — Image quality and noise (Section 7-7-2, 7-7-5)","bullets":["If the image is noisy or unclear, first check whether any nearby electrical devices (other medical equipment, transformers, HF surgery units) are causing electromagnetic interference. Move the scanner away from them if possible.","Try using a different wall socket — electrical noise from a shared circuit can degrade image quality.","Verify ultrasound gel is applied correctly and that gain, depth, and focus settings are appropriate for the examination type.","For monitor issues: if there is no image but power is on, check the video cable connection at the back of the monitor — ensure no pins are bent. Power cycle the monitor.","If the screen shows colour that is not uniform, power the monitor off and back on to activate the Auto-Degauss function.","If the image is fuzzy, adjust contrast and brightness settings. Check that the video cable is connected to both the scanner output and the monitor — a floating cable increases video output level and causes fuzz."]},{"heroCaption":"GE Voluson 730 — system restart procedure","title":"Step 4 — Correct shutdown and restart sequence","bullets":["Many GE Voluson software faults (freezing, boot loops, blank screens) are caused by improper shutdown — cutting main power instead of using the software sequence.","To shut down correctly: press the ON/OFF button on the control panel → wait for the system to complete its shutdown sequence → only then switch off the main power at the back.","To restart: switch main power ON → wait for the amber standby light → press the ON/OFF button → allow the full boot sequence to complete (typically 2–3 minutes).","If the system is frozen and unresponsive: disconnect main power, wait 30 seconds, then follow the correct startup sequence above.","If the system restarts automatically or shuts off within ~3 minutes of booting, the Primary Power Supply (CPY inside) is likely defective — do not continue cycling power; document and escalate.","After restart, check whether the reported problem persists before proceeding to the next step."]},{"heroCaption":"GE Voluson 730 — error codes and diagnostics","title":"Step 5 — Error codes, fan faults, and system diagnostics","bullets":["Note any error codes or messages displayed on screen verbatim — these are essential for GE service engineers.","Fan failure is a common GE Voluson fault: if you see a message like 'FAN1 Defect' or 'PS Code (0x5461)', the scanner is overheating. Shut it down immediately and do not restart until the fan issue is resolved.","Check the rear ventilation area for dust accumulation on the fan grilles — this is the leading cause of overheating on the Voluson series. Clean with a dry brush or low-pressure air if safe and permitted.","Check the keyboard and trackball for physical damage or stuck keys — some boot failures on Voluson E8 are triggered by keyboard faults rather than power supply issues.","If the scanner boots but shows no signal on the monitor, try reseating the video cable at both ends. If the monitor power indicator is flashing alternately green and orange, this indicates a potential monitor hardware failure.","Document: error code, time of occurrence, what the machine was doing when it failed, and any pattern (e.g. only after extended use, only on first boot in the morning)."]},{"heroCaption":"GE Voluson 730 — escalation to GE service","title":"Step 6 — Escalation: when to call GE / SAMAMA","bullets":["Escalate immediately if: the Primary Power Supply is suspected defective, a fan fault code is shown, internal hardware replacement (CKV module, BF board, power supply) is required, or the probe needs professional repair.","Before calling, gather: asset ID and serial number (visible in SEERA-ASM), the exact error code(s) from the screen, your findings from steps 1–5, and the service agreement details (warranty / contract / SAMAMA coverage).","Do NOT open refrigerant circuits, internal power supplies, or electronic enclosures unless you are a GE-authorized service engineer.","For SAMAMA-covered assets: log the findings in the Technical Report field on this work order, then contact SAMAMA with the work order number and your diagnostic notes.","For warranty-covered assets: contact GE Healthcare service directly with the serial number and error details.","After escalation, update this work order with the outcome: parts ordered, GE visit scheduled, or resolution confirmed."]},{"heroCaption":"GE Voluson 730 — printer troubleshooting","title":"Step 7 — Printer not working (Section 7-7-7)","bullets":["Check that the printer is properly connected — verify all signal and power supply cables between the printer and scanner are seated correctly.","Check that paper is loaded in the printer — insert paper if empty.","Verify the correct Print key(s) configuration is set on the scanner — configure if not set.","If still unable to print, check manual print operation — if manual print also fails, check signal cables between GEF and Backpanel.","If there is still no image on printout, check Video Output of system — if video output is OK, replace the printer. If video output is not OK, replace the CKV module.","Document the fault: which printer, what error message if any, and whether manual print also failed."]},{"heroCaption":"GE Voluson 730 — network troubleshooting","title":"Step 8 — Network connectivity issues (Section 7-7-10)","bullets":["Check that the network cable between the scanner and the wall network outlet is connected and firmly seated at both ends.","Try replacing with a known-good network cable to rule out a faulty cable.","Check the cable between the network connector on the Back Panel and the LAN connector on the GEF board inside the scanner.","Connect a network cable directly between the scanner and a PC — try to ping from the scanner to the PC's IP address. If ping succeeds, the internal hardware connection is OK and the issue is with the hospital network.","If ping fails, the fault is internal — escalate to GE service with findings.","Document: IP addresses used, ping result, which cable was tested, and whether the issue affects this scanner only or other network devices too."]}]}}}`),qH={title:"Asset Maintenance",maintenanceLogs:"Maintenance Logs",maintenanceDetails:"Maintenance Details",addMaintenance:"Add New Maintenance",listTotal:"Total: {{count}} maintenance log ",apiNotAvailable:"Maintenance API Not Available",apiNotDeployed:"The Asset Maintenance API endpoint is not deployed yet.",tryCreatingNew:"Try Creating New (Demo)",deletedSuccessfully:"Maintenance log deleted successfully!",status:{planned:"Planned",completed:"Completed",overdue:"Overdue",cancelled:"Cancelled"},maintenanceTeam:"Maintenance Team",newMaintenanceTeam:"New Maintenance Team",teamId:"Team ID",teamName:"Team Name",managerEmail:"Manager Email",managerName:"Supervisor Name",expertise:"Expertise",selectTeam:"Select Team",viewDetails:"View Details",editTeam:"Edit Team",duplicateTeam:"Duplicate Team",deleteTeam:"Delete Team",selectHospital:"Select Hospital",selectExpertise:"Select Expertise",selectManager:"Select Manager",enterTeamName:"Enter Team Name",teamInformation:"Team Information",selectUser:"Select User",selectRole:"Select Role",totalMembers:"Total Members",teamSummary:"Team Summary",addFirstMember:"Add First Member",manager:"Supervisor Email",loadingTeams:"Loading maintenance teams...",errorLoadingTeams:"Error Loading Maintenance Teams",deleteConfirmMessage:"Are you sure you want to delete this maintenance team? This action cannot be undone.",team:"Team",deleteTeamButton:"Delete Team",listTitle:"Maintenance Teams",statsTotalTeams:"Total Teams",statsManagers:"Managers",statsHospitals:"Hospitals",export:{title:"Export Maintenance Teams",selectData:"Select Data to Export",selectedRows:"Selected Rows",selectedCount:"Export {{count}} selected team ",currentPage:"Current Page",currentPageCount:"Export {{count}} team on current page",allWithFilters:"All Records (with current filters)",allWithFiltersCount:"Export all {{count}} team matching current filters",exportFormat:"Export Format",csv:"CSV",csvDesc:"Comma-separated values",excel:"Excel",excelDesc:"XLSX spreadsheet",columnsToExport:"Columns to Export",selectAll:"Select All",resetToDefault:"Reset to Default",columnsSelected:"{{count}} column selected",exporting:"Exporting...",exportButton:"Export",exportingSelected:"Exporting {{count}} selected row ",exportingPage:"Exporting {{count}} row from current page",exportingAll:"Exporting all {{count}} row "}},VH={title:"PPM",ppmDetails:"PPM Details",addPPM:"Add New PPM",periodicity:"Periodicity",dueDate:"Due Date",manageSchedules:"Manage PM Schedules",pmId:"PM ID",name:"Name",manufacturer:"Manufacturer",listTotal:"Total: {{count}} PPM schedule ",searchPlaceholder:"Search by ID, asset, company...",filterByCompany:"Filter by Company",company:"Company",asset:"Asset",assetType:"Asset Type",frequency:"Frequency",noOfPMs:"No. of PMs",totalAmount:"Total Amount",apiNotAvailable:"PPM API Not Available",apiNotDeployed:"The PPM API endpoint is not deployed yet.",tryCreatingNew:"Try Creating New (Demo)",deletedSuccessfully:"PPM schedule deleted successfully!",noSchedulesFound:"No PPM schedules found",createFirstSchedule:"Create your first PPM schedule",confirmDelete:"Confirm Delete",deleteConfirmMessage:"Are you sure you want to delete this PPM schedule? This action cannot be undone.",detail:{duplicateSchedule:"Duplicate PPM Schedule",newSchedule:"New PPM Schedule",scheduleDetails:"PPM Schedule Details",basicInformation:"Basic Information",financialInformation:"Financial Information",scheduleInformation:"Schedule Information",maintenanceTeam:"Maintenance Team",numberOfPMs:"Number of PMs",pricePerPM:"Price per PM",frequencyPlaceholder:"e.g., Monthly, Quarterly, Yearly",scheduleInfoAfterCreation:"Schedule information will appear after creation",assetName:"Asset Name",pleaseEnterAssetName:"Please enter Asset Name",duplicatedSuccessfully:"PPM schedule duplicated successfully!",createdSuccessfully:"PPM schedule created successfully!",updatedSuccessfully:"PPM schedule updated successfully!",failedToSave:"Failed to save",saveChanges:"Save Changes",loadingSchedule:"Loading PPM schedule...",backToSchedules:"Back to PPM schedules",errorLoading:"Error"}},GH={listTitle:"PPM Schedules",export:{title:"Export PPM Schedules",selectData:"Export Scope",selectedRows:"Selected Rows",selectedCount:"Export {{count}} selected schedule ",currentPage:"Current Page",currentPageCount:"Export {{count}} schedule on current page",allWithFilters:"All Records (with current filters)",allWithFiltersCount:"Export all {{count}} schedule matching current filters",csvDesc:"Comma-separated values",excelDesc:"XLSX spreadsheet",columnsToExport:"Columns to Export",selectAll:"Select All",resetToDefault:"Reset to Default",columnsSelected:"{{count}} column selected",exporting:"Exporting...",exportButton:"Export",exportingSelected:"Exporting {{count}} selected row ",exportingPage:"Exporting {{count}} row from current page",exportingAll:"Exporting all {{count}} row "}},KH={title:"Export",whatToExport:"What to Export",selectedRows:"Selected Rows",currentPage:"Current Page",allWithFilters:"All with Filters",exportSelected:"Export {count} selected",exportPage:"Export {count} on current page",exportAll:"Export all {count}",columnsToExport:"Columns to Export",selectAll:"Select All",selectDefault:"Select Default",exporting:"Exporting...",exportingSelected:"Exporting {count} selected row(s)",exportingPage:"Exporting {count} row(s) from current page",exportingAll:"Exporting all {count} row(s)",selected:"selected",rows:"rows"},YH={title:"Items",itemDetails:"Item details",newItem:"New item",addItem:"Add new item",itemId:"Item ID",itemCode:"Item code",itemName:"Item name",itemGroup:"Item group",stockUOM:"Stock UOM",partDescription:"Part description",brand:"Brand",valuationRate:"Valuation rate",openingStock:"Opening stock",lastCalibrationDate:"Last calibration date",nextCalibrationDate:"Next calibration date",selectItem:"Select item",selectItemGroup:"Select item group",selectHospital:"Select hospital",serialNo:"Serial no.",dateIn:"Date in",watts:"Watts",volts:"Volts",type:"Type",code:"Code",viewDetails:"View details",editItem:"Edit item",duplicateItem:"Duplicate item",deleteItem:"Delete item",basicInformation:"Basic information",inventoryDetails:"Inventory details",stockInformation:"Stock information",isStockItem:"Is stock item",isFixedAsset:"Is fixed asset",balanceQty:"Balance qty",calibrationInformation:"Calibration information",additionalInformation:"Additional information",refreshBalanceQty:"Refresh balance qty",warrantyMonths:"Warranty (months)",errorLoadingItems:"Error loading items",loadingItems:"Loading items...",deleteConfirmMessage:"Are you sure you want to delete this item? This cannot be undone.",backToInventory:"Back to inventory",loadingItem:"Loading item...",errorLoadingItem:"Error loading item",createNewItem:"Create new item",itemCodeLabel:"Item code",itemUpdatedSuccessfully:"Item updated successfully!",pleaseSaveFirst:"Please save the item first before submitting.",submittedSuccessfully:"Item submitted successfully!",failedToSave:"Failed to save",failedToSubmit:"Failed to submit",noItemsFound:"No items found",createFirstItem:"Create your first item",listTitle:"Inventory",listTotal:"Total: {{count}} item(s)",failedToLoadItems:"Failed to load items.",listAddItem:"Add item",export:{title:"Export items",selectData:"Select data to export",selectedRows:"Selected rows",selectedCount:"Export {{count}} selected item(s)",currentPage:"Current page",currentPageCount:"Export {{count}} item(s) on current page",allWithFilters:"All records (current filters)",allWithFiltersCount:"Export all {{count}} item(s) matching filters",csvDesc:"Comma-separated values",excelDesc:"XLSX spreadsheet",columnsToExport:"Columns to export",selectAll:"Select all",resetToDefault:"Reset to default",columnsSelected:"{{count}} column(s) selected",exporting:"Exporting...",exportButton:"Export",exportingSelected:"Exporting {{count}} selected row(s)",exportingPage:"Exporting {{count}} row(s) from current page",exportingAll:"Exporting all {{count}} row(s)"}},JH={title:"Issues",issueDetails:"Issue details",newIssue:"New ticket",addIssue:"Add new ticket",issueId:"Ticket ID",subject:"Subject",raisedBy:"Raised by",contact:"Contact",issueType:"Issue type",openingDate:"Opening date",resolutionDate:"Resolution date",resolvedBy:"Resolved by",firstRespondedOn:"First responded on",resolutionDetails:"Resolution details",selectIssue:"Select issue",allPriorities:"All priorities",allCompanies:"All companies",viewDetails:"View details",editIssue:"Edit issue",deleteIssue:"Delete issue",enterSubject:"Enter subject",selectPriority:"Select priority",selectIssueType:"Select issue type",describeIssue:"Describe the issue...",contactInformation:"Contact information",createNewIssue:"Create new support ticket",resolution:"Resolution",describeResolution:"Describe how the issue was resolved...",selectCompany:"Select company",statusInformation:"Status information",currentStatus:"Current status",timeline:"Timeline",loadingIssues:"Loading tickets...",errorLoadingIssues:"Error loading tickets",deleteConfirmMessage:"Are you sure you want to delete this ticket? This cannot be undone.",deletedSuccessfully:"Ticket deleted successfully!",createWorkOrderFromIssue:"Create work order",workflowActions:"Workflow actions",issueSingular:"support ticket",actionResults:"Action results:",listTitle:"Support tickets",listTotal:"Total",listSelected:"selected",statsTotalIssues:"Total tickets",statsOpen:"Open",statsResolved:"Resolved",statsClosed:"Closed",noIssuesFound:"No tickets found",createFirstIssue:"Create your first ticket",export:{title:"Export tickets",selectData:"Select data to export",selectedRows:"Selected rows",selectedCount:"Export {{count}} selected ticket(s)",currentPage:"Current page",currentPageCount:"Export {{count}} ticket(s) on current page",allWithFilters:"All records (current filters)",allWithFiltersCount:"Export all {{count}} ticket(s) matching filters",exportFormat:"Export format",csv:"CSV",csvDesc:"Comma-separated values",excel:"Excel",excelDesc:"XLSX spreadsheet",columnsToExport:"Columns to export",selectAll:"Select all",resetToDefault:"Reset to default",columnsSelected:"{{count}} column(s) selected",exporting:"Exporting...",exportButton:"Export",exportingSelected:"Exporting {{count}} selected row(s)",exportingPage:"Exporting {{count}} row(s) from current page",exportingAll:"Export all {{count}} row(s)"},status:{open:"Open",replied:"Replied",on_hold:"On hold",resolved:"Resolved",closed:"Closed"},priority:{low:"Low",medium:"Medium",high:"High",critical:"Critical"}},ZH={title:"Users",userDetails:"User details",newUser:"New user",addUser:"Add new user",searchUsers:"Search users...",manageUsers:"Manage user accounts and permissions",noUsersFound:"No users found",tryAdjustingSearch:"Try adjusting your search.",noUsersAvailable:"No users available.",backToDashboard:"Back to dashboard",refresh:"Refresh",active:"Active",inactive:"Inactive",noEmail:"No email",created:"Created"},XH={title:"Events",eventDetails:"Event details",newEvent:"New event",addEvent:"Add event",upcomingEvents:"Upcoming events",eventsFromFrappe:"Events from Frappe",noEventsFound:"No events found",noEventsScheduled:"No events scheduled.",refreshEvents:"Refresh events"},QH={previous:"Previous",next:"Next",goTo:"Go to",go:"Go",page:"Page",showingToOf:"Showing {{start}} to {{end}} of {{total}} {{label}}",showingTo:"Showing {{start}} to {{end}} {{label}}",items:"items",assets:"assets",workOrders:"work orders",issues:"tickets",teams:"teams",inspections:"inspections",plans:"plans",sfdaEntries:"SFDA Recalls"},eq={loading:"Loading...",noResultsFound:"No results found",createNewDoctype:"Create new {{doctype}}",selectLabel:"Select {{label}}"},tq={loadingSupportPlans:"Loading support plans...",errorLoadingSupportPlans:"Error loading support plans",deleteConfirmMessage:"Are you sure you want to delete this support plan? This cannot be undone.",planId:"Plan ID",deletedSuccessfully:"Support plan deleted successfully!",deleteSupportPlan:"Delete support plan",noSupportPlansFound:"No support plans found",createFirstSupportPlan:"Create your first support plan",table:{planName:"Plan name",type:"Type",frequency:"Frequency",contractValue:"Contract value",warrantyStatus:"Warranty status",contractStatus:"Contract status"},status:{active:"Active",expired:"Expired",pending:"Pending",terminated:"Terminated early"},statusLabel:{warrantyPrefix:"W:",contractPrefix:"C:"},viewDetails:"View support plan",editSupportPlan:"Edit support plan",listTitle:"Support plans",statsTotalPlans:"Total plans",statsContracts:"Contracts",statsWarranties:"Warranties",statsActive:"Active",export:{title:"Export support plans",selectData:"Select data to export",selectedRows:"Selected rows",selectedCount:"Export {{count}} selected plan(s)",currentPage:"Current page",currentPageCount:"Export {{count}} plan(s) on current page",allWithFilters:"All records (current filters)",allWithFiltersCount:"Export all {{count}} plan(s) matching filters",exportFormat:"Export format",csv:"CSV",csvDesc:"Comma-separated values",excel:"Excel",excelDesc:"XLSX spreadsheet",columnsToExport:"Columns to export",selectAll:"Select all",resetToDefault:"Reset to default",columnsSelected:"{{count}} column(s) selected",exporting:"Exporting...",exportButton:"Export",exportingSelected:"Exporting {{count}} selected row(s)",exportingPage:"Exporting {{count}} row(s) from current page",exportingAll:"Export all {{count}} row(s)"}},rq={title:"Inspections",loadingInspections:"Loading inspections...",errorLoadingInspections:"Error loading inspections",deleteConfirmMessage:"Are you sure you want to delete this inspection? This cannot be undone.",inspectionId:"Inspection ID",deleteInspection:"Delete Inspection",deletedSuccessfully:"Inspection deleted successfully!",noInspectionsFound:"No inspections found",createFirstInspection:"Create your first inspection",type:"Type",workflowStateHeader:"Workflow state",targetDate:"Target Date",requestedBy:"Requested By",linkedWorkOrder:"Linked Work Order",savedFilters:"Saved Filters",newInspection:"New Inspection",inspectionReport:"Inspection Report",technicalDepartment:"Technical Department",filterStatus:"Filter Status",filterWorkflow:"Filter Workflow",filterType:"Filter Type",filterWorkOrder:"Filter Work Order",filterDepartment:"Filter Department",selectWorkOrder:"Select Work Order",selectDepartment:"Select Department",stats:{draft:"Draft",pendingApproval:"Pending Approval",closed:"Closed"},status:{open:"Open",in_progress:"In Progress",pending_review:"Pending Review",closed:"Closed"},workflowState:{draft:"Draft",sent_to_work_control:"Sent to Work Control",sent_to_technician:"Sent to technician",sent_to_supervisor:"Sent to Supervisor",closed:"Closed"},typeMap:{inspection:"Inspection",safety_inspection:"Safety Inspection"},viewDetails:"View Details",editInspection:"Edit Inspection",export:{title:"Export inspections",selectData:"Select data to export",selectedRows:"Selected rows",selectedCount:"Export {{count}} selected inspection(s)",currentPage:"Current page",currentPageCount:"Export {{count}} inspection(s) on current page",allWithFilters:"All records (current filters)",allWithFiltersCount:"Export all {{count}} inspection(s) matching filters",exportFormat:"Export format",csv:"CSV",csvDesc:"Comma-separated values",excel:"Excel",excelDesc:"XLSX spreadsheet",columnsToExport:"Columns to export",selectAll:"Select all",resetToDefault:"Reset to default",columnsSelected:"{{count}} column(s) selected",exporting:"Exporting...",exportButton:"Export",exportingSelected:"Exporting {{count}} selected row(s)",exportingPage:"Exporting {{count}} row(s) from current page",exportingAll:"Export all {{count}} row(s)",inspectionId:"Inspection ID",inspectionType:"Inspection Type",status:"Status",workflowState:"Workflow State",inspectionDate:"Inspection Date",targetClosureDate:"Target Closure Date",requestedBy:"Requested By",technicalDepartment:"Technical Department",linkedWorkOrder:"Linked Work Order",observationNote:"Observation Note",technicalResponse:"Technical Response",createdOn:"Created On",modifiedOn:"Modified On",createdBy:"Created By"},detail:{loadingDetails:"Loading Details...",errorLoading:"Error Loading...",backToList:"Back To List",newInspection:"New Inspection",inspectionDetails:"Inspection Details",createNewRecord:"Create New Record",cancelInspection:"Cancel Inspection",cancelConfirmMessage:"Are you sure you want to cancel this inspection? It will be marked cancelled and you can delete it afterwards if needed.",noGoBack:"No, go back",yesCancel:"Yes, cancel",cancelling:"Cancelling...",selectType:"Select Type",workOrderType:"Work Order Type",selectWorkOrderType:"Select Work Order Type",techniciansAvailable:"{{count}} technician(s) available for this type",selectDepartment:"Select Department",selectLocation:"Select Location",extensionNo:"Extension No",selectExtension:"Select Extension",inspectionDate:"Inspection Date",targetClosureDate:"Target Closure Date",cannotBeInPast:"Cannot be in the past",cannotBeEarlier:"Cannot be earlier than the inspection date or in the past",openingAttachment:"Opening Attachment",closingAttachment:"Closing Attachment",uploading:"Uploading...",uploadFile:"Upload File",uploadClosingFile:"Upload Closing File",noAttachment:"No Attachment",removeAttachment:"Remove Attachment",assignmentInformation:"Assignment Information",requestedBy:"Requested By",selectUser:"Select User",technicalDepartment:"Technical Department",assignedTechnician:"Assigned Technician",selectTechnician:"Select Technician",selectWOTypeFirst:"Select work order type first to filter technicians",noTechniciansForType:"No technicians found for this work order type",notesAndResponse:"Notes And Response",observationNote:"Observation Note",placeholderObservation:"Enter observation notes...",technicalResponse:"Technical Response",placeholderTechnicalResponse:"Enter technical response...",linkedWorkOrder:"Linked Work Order",linkedCorrectiveWO:"Linked Corrective WO",readOnly:"Read Only",viewWorkOrder:"View Work Order",noLinkedWorkOrder:"No Linked Work Order",workflowActions:"Workflow Actions",workflowProgress:"Workflow Progress",workControl:"Work Control",technicianStep:"Technician Step",supervisorStep:"Supervisor Step",draftStep:"Draft Step",closedStep:"Closed Step",statusInfo:"Status Info",documentStatus:"Document Status",woType:"WO Type",assignedTo:"Assigned To",submitted:"Submitted",cancelled:"Cancelled",added:"Added",removed:"Removed",modified:"Modified",items:"Items",rows:"Rows",activityLog:"Activity Log",activityLogRefreshed:"Activity Log Refreshed",refreshActivityLog:"Refresh Activity Log",noChangesRecorded:"No Changes Recorded",createdThisInspection:"Created This Inspection",changedFrom:"Changed From",documentUpdated:"Document Updated",showLess:"Show Less",showAll:"Show All",department:"Department",location:"Location",inspectionType:"Inspection Type",status:"Status",removeClosingAttachment:"Remove Closing Attachment",noClosingAttachment:"No Closing Attachment",cancelledSuccessfully:"Cancelled Successfully",failedToCancel:"Failed to cancel: {{error}}",failedToSave:"Failed to save: {{error}}",failedToDelete:"Failed to delete: {{error}}",targetClosureMandatory:"Target closure date is required to save.",attachmentMandatory:"Attachment is required to save.",extensionMandatory:"Extension number is required to save.",createdSuccessfully:"Created Successfully",updatedSuccessfully:"Updated Successfully",deletedSuccessfully:"Deleted Successfully",inspectionDateInPast:"Inspection date cannot be in the past.",targetClosureEarlier:"Target closure cannot be earlier than the inspection date.",targetClosureInPast:"Target closure date cannot be in the past.",fileSizeExceeds:"File size exceeds 10 MB limit",fileUploadedSuccess:"File uploaded successfully",failedToUpload:"Failed to upload file",closingAttachmentRemoved:"Closing Attachment Removed",closingAttachmentUploadedSuccess:"Closing Attachment Uploaded Success",failedToUploadClosing:"Failed to upload closing attachment",attachmentRemoved:"Attachment Removed",systemManager:"System Manager",workflow:"Workflow"}},aq={title:"Active map",loading:"Loading map data...",hospital:"Hospital",departmentWoType:"Department (work order type)",selectHospital:"Select Hospital",selectDepartment:"Select Department",clearDepartmentHint:"Clear department to filter by hospital only",clearHospitalHint:"Clear hospital to filter by department only",clearFilters:"Clear Filters",legendHospital:"Hospital",legendDepartment:"Department (work order type)",legendHasUrgent:"Has urgent work orders",totalAssets:"Total Assets",workOrderStatus:"Work Order Status",status:"Status",count:"Count",normal:"Normal",urgent:"Urgent",open:"Open",workInProgress:"Work In Progress",pendingReview:"Pending Review",completed:"Completed",closed:"Closed",preventiveMaintenance:"Preventive Maintenance",planned:"Planned",overdue:"Overdue",viewAssets:"View Assets",viewWorkOrders:"View Work Orders",viewAllWorkOrders:"View All Work Orders",showingWorkOrdersByType:"Work orders by type",deptWoType:"Department / WO type",tooltipDept:"Department",tooltipHospital:"Hospital",tooltipUrgent:"Urgent",normalWos:"Normal work orders:",urgentWos:"Urgent work orders:",closedWos:"Closed work orders:",plannedPms:"Planned PM:",completedPms:"Completed PM:",assets:"Assets"},sq={title:"Maintenance calendar",viewType:"View type",maintenanceLog:"Maintenance Log",ppmPlanner:"PPM planner",filters:"Filters",yearlyMap:"Yearly map",yearlyMapTitle:"Yearly PPM planner map view",mapShort:"Map",hospital:"Hospital",selectHospital:"Select Hospital",department:"Department",allDepartments:"All Departments",status:"Status",allStatuses:"All Statuses",planned:"Planned",completed:"Completed",overdue:"Overdue",cancelled:"Cancelled",assignedTo:"Assigned To",allTechnicians:"All Technicians",clearFilters:"Clear Filters",months:{january:"January",february:"February",march:"March",april:"April",may:"May",june:"June",july:"July",august:"August",september:"September",october:"October",november:"November",december:"December"},days:{sun:"Sun",mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat"},previousMonth:"Previous Month",today:"Today",nextMonth:"Next Month",loadingLogs:"Loading maintenance logs...",loadingPpm:"Loading PPM schedules...",overdueInTooltip:"(overdue)",clickToViewDetails:"Click to view details",clickToViewPpmPlanner:"Click to open PPM planner",ppmPlannerDefault:"PPM planner",legendCompleted:"Completed",legendPlanned:"Planned",legendOverdue:"Overdue",legendToday:"Today",summaryPpmPlanners:"PPM planners"},nq={title:"SFDA Recalls",loading:"Loading SFDA Recalls...",errorLoading:"Error Loading SFDA Entries",noEntriesFound:"No SFDA entries found",viewDetails:"View Details",savedFilters:"Saved Filters",paginationLabel:"SFDA Recalls",columns:{title:"Title",date:"Date",ncmdrRef:"NCMDR Ref",manufacturer:"Manufacturer",passed:"Passed"},filters:{title:"Title",titlePlaceholder:"Search by title...",ncmdrRef:"NCMDR Ref",ncmdrRefPlaceholder:"Search by NCMDR ref...",manufacturer:"Manufacturer",manufacturerPlaceholder:"Search by manufacturer...",date:"Date",dateStart:"Date From",dateEnd:"Date To",dateNewest:"Alert Date (newest first)",dateOldest:"Alert Date (oldest first)",passed:"Passed"},stats:{passed:"Passed (this page)",notPassed:"Not Passed (this page)"},deviceFields:{material:"Material",materialDescription:"Material Description",catalogNumber:"Catalog Number",udi:"UDI",serialNo:"Serial No",matching:"Matching",gtin:"GTIN",batch:"Batch"},detail:{loading:"Loading SFDA entry details...",errorLoading:"Error Loading SFDA Entry",notFound:"SFDA entry not found",backToList:"Back to SFDA Recalls",entryInformation:"Weekly Bulletin Information",deviceList:"Alerts & Device List",devices:"device rows",alerts:"alerts",alertCount:"Alert Count",noDevices:"No alerts or devices in this weekly entry",adeDetailPdf:"ADE Detail PDF",openPdfNewTab:"PDF",noPdf:"No PDF attached",passed:"Passed",notPassed:"Not Passed",passedDate:"Passed Date",adeDetailUrl:"ADE",viewAde:"ADE",statusSummary:"Status Summary",passedStatus:"Passed Status",deviceCount:"Device Row Count",pdfAttached:"Rows with PDF",auditInfo:"Audit Information",documentId:"Document ID",openMatchingAsset:"View matching asset",resolvingMatches:"Resolving matches..."}},iq={common:RH,sidebar:MH,projects:LH,profile:FH,login:IH,dashboard:zH,commonFields:$H,filters:UH,listPages:BH,assets:WH,workOrders:HH,maintenance:qH,ppm:VH,ppmPlanner:GH,exportModal:KH,items:YH,issues:JH,users:ZH,events:XH,pagination:QH,linkField:eq,supportPlans:tq,inspections:rq,activeMap:aq,maintenanceCalendarPage:sq,sfdaEntries:nq},oq={dashboard:"لوحة التحكم",assets:"الأصول",workOrders:"أوامر العمل",maintenance:"صيانة الأصول",ppm:"الصيانة الوقائية",logout:"تسجيل الخروج",login:"تسجيل الدخول",email:"البريد الإلكتروني",password:"كلمة المرور",submit:"إرسال",cancel:"إلغاء",save:"حفظ",saveChanges:"حفظ التغييرات",delete:"حذف",deleting:"جاري الحذف...",edit:"تعديل",create:"إنشاء",search:"بحث",filter:"تصفية",export:"تصدير",import:"استيراد",loading:"جاري التحميل...",noData:"لا توجد بيانات",error:"خطأ",success:"نجح",darkMode:"الوضع الداكن",lightMode:"الوضع الفاتح",language:"اللغة",english:"الإنجليزية",arabic:"العربية",backToDashboard:"العودة إلى لوحة التحكم",back:"رجوع",saving:"جاري الحفظ...",tryAgain:"حاول مرة أخرى",filters:"المرشحات",enterFilterName:"أدخل اسم المرشح",saveFilterPreset:"حفظ مجموعة المرشحات",saveFilter:"حفظ المرشح",filtering:"جاري التصفية...",updating:"جاري التحديث...",clearFilters:"مسح المرشحات",total:"الإجمالي",selected:"محدد",rows:"صفوف",actions:"إجراءات",selectAllTitle:"تحديد الكل",deselectAllTitle:"إلغاء تحديد الكل",typeToSearch:"اكتب للبحث...",typing:"جاري الكتابة...",enterFilterNameExample:"أدخل اسم المرشح (مثال: 'مفتوح أولوية عالية')"},lq={title:"أصول سيرا",loggedInAs:"تم تسجيل الدخول كـ:",version:"أصول سيرا نظام إدارة الأصول الإصدار 2.26",inventory:"المخزون",ppmPlanner:"مخطط الصيانة الوقائية",maintenanceCalendar:"تقويم الصيانة",activeMap:"الخريطة النشطة",maintenanceTeam:"فريق الصيانة",procurement:"المشتريات",projects:"إدارة المشاريع",sla:"اتفاقية مستوى الخدمة",support:"الدعم",inspection:"التفتيش",sfdaEntries:"يتذكر SFDA",userProfile:"الملف الشخصي"},cq={moduleTitle:"إدارة المشاريع",hubSubtitle:"المشاريع والمهام وجداول الوقت والمستندات المرتبطة.",reportsCardSub:"مخططات ولقطة محفظة المشاريع.",title:"المشاريع",listTotal:"الإجمالي: ",listProject:"مشروع",listProjects:"مشاريع",projectsDoctype:"المشاريع",tasksDoctype:"المهام",timesheetDoctype:"جداول الوقت",projectTemplateDoctype:"قوالب المشاريع",activityTypeDoctype:"أنواع النشاط",newProject:"مشروع جديد",newTask:"مهمة جديدة",newTimesheet:"جدول وقت جديد",newProjectTemplate:"قالب مشروع جديد",newActivityType:"نوع نشاط جديد",searchPlaceholder:"البحث باسم المشروع…",noProjects:"لا توجد مشاريع.",noTasks:"لا توجد مهام.",noTimesheets:"لا توجد جداول وقت.",projectName:"اسم المشروع",customer:"العميل",expectedEnd:"تاريخ الانتهاء المتوقع",progress:"التقدم",project:"المشروع",assignedTo:"معيّن إلى",dueDate:"تاريخ الاستحقاق",timesheetId:"جدول الوقت",totalHours:"إجمالي الساعات",taskColumn:"المهمة",templateCreated:"تم حفظ القالب.",templateUpdated:"تم تحديث القالب.",timesheetCreated:"تم حفظ جدول الوقت.",timesheetUpdated:"تم تحديث جدول الوقت.",reportsDashboardTitle:"تقارير المشاريع",reportsDashboardSubtitle:"مؤشرات ومخططات من بيانات المشروع والمهمة وجدول الوقت.",projectOverviewSection:"نظرة عامة على المشروع",projectOverviewBanner:"نظرة عامة على المشروع",reportProjectFilter:"مشروع التقرير",reportProjectFilterHint:"يؤثر الاختيار على المخططات والمؤشرات والمهام. تظهر لقطة المشروع وتحديثات المشروع فقط عند اختيار مشروع.",selectProjectPlaceholder:"اختر مشروعًا…",searchProjectPlaceholder:"بحث بالاسم أو الرقم…",clearProjectSelection:"إلغاء الاختيار",noMatchingOpenProjects:"لا توجد مشاريع مفتوحة مطابقة.",projectPickerLimitNote:"عرض حتى 2000 مشروع مفتوح الأحدث تعديلًا. صفِّ البحث للعثور على مشروع.",snapshotProjectBudget:"ميزانية المشروع",snapshotOverallShort:"الإجمالي",overviewProjectNameLabel:"اسم المشروع :",overviewDepartmentLabel:"القسم:",overviewDateLabel:"التاريخ:",overviewProgressLabel:"التقدم:",overviewCustomerLabel:"العميل:",overviewDatesUpToday:"الأيام حتى اليوم",overviewProjectDuration:"مدة المشروع",overviewStartDateLabel:"تاريخ بدء المشروع :",overviewEndDateLabel:"تاريخ انتهاء المشروع :",projectNotesSection:"ملاحظات المشروع",reportsCardLabel:"التقارير"},dq={twoFactorTitle:"المصادقة الثنائية (تطبيق OTP)",twoFactorSidebarTitle:"المصادقة الثنائية",twoFactorOtpAppNoteShort:"تطبيق المصادقة مطلوب. أعد التعيين فقط عند الحاجة لرمز QR جديد.",twoFactorLoading:"جاري تحميل إعدادات الأمان…",twoFactorRequired:"المصادقة الثنائية مطلوبة لحسابك.",twoFactorNotRequired:"المصادقة الثنائية غير مطلوبة لأدوارك.",twoFactorDisabledSite:"المصادقة الثنائية غير مفعّلة على هذا الموقع.",twoFactorOtpAppNote:"استخدم تطبيق مصادقة (Google Authenticator، Authy، إلخ). بعد إعادة التعيين، راجع بريدك عند أول تسجيل دخول لرابط إعداد QR.",resetOtp:"إعادة تعيين المصادقة",resetOtpConfirm:"إعادة تعيين سر OTP؟ ستحتاج لمسح رمز QR جديد عند تسجيل الدخول التالي.",resetOtpSuccess:"تم إعادة تعيين المصادقة. راجع بريدك عند تسجيل الدخول التالي.",resetOtpFailed:"تعذر إعادة تعيين المصادقة."},uq={title:"أصول سيرا",subtitle:"نظام إدارة الأصول",signIn:"قم بتسجيل الدخول للمتابعة",emailPlaceholder:"أدخل بريدك الإلكتروني",passwordPlaceholder:"أدخل كلمة المرور",loginFailed:"فشل تسجيل الدخول. يرجى التحقق من بيانات الاعتماد الخاصة بك.",demoLogin:"تسجيل دخول تجريبي",or:"أو",forgotPassword:"نسيت كلمة المرور؟",forgotPasswordTitle:"نسيت كلمة المرور؟",forgotPasswordHint:"أدخل البريد الإلكتروني أو اسم المستخدم الذي تستخدمه لتسجيل الدخول. سنرسل تعليمات إعادة التعيين إلى بريدك المسجل.",forgotPasswordUserRequired:"يرجى إدخال البريد أو اسم المستخدم.",forgotPasswordUserPlaceholder:"البريد أو اسم المستخدم",forgotPasswordSubmit:"إرسال رابط إعادة التعيين",forgotPasswordClose:"إلغاء",forgotPasswordSentSuccess:"تم إرسال تعليمات إعادة تعيين كلمة المرور إلى بريدك المسجل. يرجى التحقق من صندوق الوارد.",forgotPasswordNotFound:"لم يتم العثور على حساب مستخدم بالبريد أو اسم المستخدم المقدم.",forgotPasswordTimeout:"استغرق الطلب وقتًا طويلاً. حاول مرة أخرى أو تواصل مع المسؤول إذا لم يكن البريد الصادر مُعدًا.",forgotPasswordCannotReset:"إعادة تعيين كلمة المرور غير متاحة لهذا الحساب.",forgotPasswordFailed:"تعذر إرسال بريد إعادة التعيين. حاول مرة أخرى لاحقًا.",finishingSignOut:"جاري إنهاء تسجيل الخروج…",afterPasswordResetSignIn:"تم تحديث كلمة المرور. يرجى تسجيل الدخول بكلمة المرور الجديدة.",twoFactorTitle:"التحقق بخطوتين",twoFactorCodeLabel:"رمز التحقق",twoFactorCodePlaceholder:"000000",twoFactorVerify:"تحقق",twoFactorBackToLogin:"العودة لتسجيل الدخول",twoFactorOtpAppEnter:"أدخل الرمز المكون من 6 أرقام من تطبيق المصادقة.",twoFactorOtpAppSetupIncomplete:"إعداد المصادقة غير مكتمل. راجع بريدك لرابط رمز QR أو تواصل مع المسؤول.",twoFactorEmailQrHint:"افتح رابط الإعداد في بريدك على هذا الجهاز لمسح رمز QR، ثم عد هنا لإدخال الرمز.",twoFactorCodeRequired:"يرجى إدخال رمز التحقق.",twoFactorInvalid:"رمز التحقق غير صحيح. حاول مرة أخرى.",twoFactorSessionExpired:"انتهت جلسة التحقق. يرجى تسجيل الدخول مرة أخرى."},mq={title:"لوحة التحكم",loading:"جاري تحميل لوحة التحكم...",totalAssets:"إجمالي عدد الأصول",assetsDown:"الأصول إلى أسفل",openWorkOrders:"أوامر العمل المفتوحة",workOrdersInProgress:"أوامر العمل قيد التنفيذ",completedWorkOrders:"أوامر العمل المكتملة",totalWorkOrders:"إجمالي أوامر العمل",overdueWorkOrders:"أوامر العمل المتأخرة",closedWorkOrders:"أوامر العمل المغلقة",upTime:"وقت التشغيل",downTime:"وقت التوقف",workOrderStatus:"حالة أمر العمل",workOrderByType:"أمر العمل حسب النوع",maintenanceByAsset:"الصيانة حسب الأصل",assigneesStatus:"حالة المكلفين",assigneesCount:"المكلفون",totalTasksAssigned:"المهام المعينة",maintenanceFrequency:"تكرار الصيانة",maintenanceLogs:"سجلات الصيانة",assetUptime:"وقت تشغيل الأصل",avgResponseTime:"متوسط وقت الاستجابة",maintenanceEfficiency:"كفاءة الصيانة",overdueMaintenance:"صيانة متأخرة",upDownTimeChart:"مخطط وقت التشغيل والتوقف",ppmStatus:"حالة الصيانة الوقائية",completionRate:"معدل الإكمال",completionRateChartHint:"نسبة الإكمال خلال آخر 7 أشهر — مرر المؤشر على النقطة للتفاصيل",completionRateTooltip:"{{value}}% معدل الإكمال",viewFullReport:"عرض التقرير الكامل",noDataAvailable:"لا توجد بيانات",loadingTechnicianHours:"جاري تحميل ساعات الفنيين...",loadingTechnicianWorkData:"جاري تحميل بيانات عمل الفنيين...",welcome:"مرحباً،",user:"المستخدم",failedToLoad:"فشل تحميل بيانات لوحة التحكم",recentRecords:"السجلات الأخيرة",latestEntries:"أحدث الإدخالات من النظام الخلفي",quickActions:"إجراءات سريعة",cardTotalAssets:"إجمالي الأصول",cardOpenWorkOrders:"أوامر العمل المفتوحة",cardInProgress:"قيد التنفيذ",cardCompletedWorkOrders:"أوامر العمل المكتملة",viewUsers:"عرض المستخدمين",manageUserAccounts:"إدارة حسابات المستخدمين",settings:"الإعدادات",configurePreferences:"تكوين التفضيلات",events:"الأحداث",viewCalendarEvents:"عرض أحداث التقويم",reports:"التقارير",viewAnalyticsReports:"عرض التحليلات والتقارير",ppmTemplateCounts:"عدادات قوالب الصيانة الوقائية",repairCost:"تكلفة الإصلاح",dashboardFilter:"فلتر لوحة التحكم",allDepartments:"جميع الأقسام",workOrderStatusDistribution:"توزيع حالة أوامر العمل",workOrderInspectionSummary:"ملخص تفتيش أوامر العمل",woRejectionSummary:"ملخص رفض أوامر العمل",total:"الإجمالي",inProgress:"قيد التنفيذ",completed:"مكتمل",totalSales:"إجمالي المبيعات",average:"متوسط",noChartDataAvailable:"لا توجد بيانات للمخطط",loadingInspectionData:"جاري تحميل بيانات التفتيش...",noInspectionDataAvailable:"لا توجد بيانات تفتيش",totalRejections:"إجمالي الرفض",loadingRejectionData:"جاري تحميل بيانات الرفض...",noRejectionDataAvailable:"لا توجد بيانات رفض",department:"القسم",allOperational:"جميع الأنظمة تعمل",low:"منخفض",highPriority:"أولوية عالية",allClear:"الكل واضح",fastResponse:"استجابة سريعة",monitor:"مراقبة",onTrack:"وفق الخطة",needsAttention:"يحتاج اهتمام",totalHours:"الإجمالي: {{value}} ساعة",technicianWorkingHours:"ساعات عمل الفنيين",techniciansWorked:"ملخص عمل الفنيين",pendingReviewWorkOrders:"قيد المراجعة",clear:"مسح",clearFilter:"مسح الفلتر",label:"التسمية",open:"مفتوح"},hq={assetId:"معرف الأصل",assetName:"اسم الأصل",serialNumber:"الرقم التسلسلي",company:"الشركة/المستشفى",location:"الموقع",department:"القسم",deviceStatus:"حالة الجهاز",modality:"الطريقة",manufacturer:"الشركة المصنعة",supplier:"المورد",assetCategory:"فئة الأصل",purchaseDate:"تاريخ الشراء",purchaseAmount:"مبلغ الشراء",availableForUseDate:"تاريخ التوفر للاستخدام",createdOn:"تم الإنشاء في",modifiedOn:"تم التعديل في",createdBy:"تم الإنشاء بواسطة",modifiedBy:"تم التعديل بواسطة",workOrderId:"معرف أمر العمل",workOrderType:"النوع",status:"الحالة",priority:"الأولوية",description:"الوصف",assignedTo:"مكلف إلى",scheduledDate:"التاريخ المجدول",completedDate:"تاريخ الإكمال",hospital:"المستشفى",assetType:"نوع الأصل",siteName:"اسم الموقع",assignedSupervisor:"المشرف المعين",assignedContractor:"المقاول المعين",serialNumberShort:"الرقم التسلسلي",departmentShort:"القسم",manufacturerShort:"الشركة المصنعة",workOrderIdShort:"معرف أمر العمل",assetShort:"الأصل",typeShort:"النوع",nameShort:"الاسم",pmId:"معرف الصيانة الوقائية",name:"الاسم"},pq={filterBy:"تصفية حسب",createdDate:"تاريخ الإنشاء",latestModifiedDate:"آخر تاريخ تعديل",startDate:"تاريخ البداية",endDate:"تاريخ النهاية",assetId:"معرف الأصل",hospital:"المستشفى",name:"الاسم",serial:"الرقم التسلسلي",status:"الحالة",location:"الموقع",dept:"القسم",modality:"الطريقة",mfr:"الشركة المصنعة",supplier:"المورد",workOrderId:"معرف أمر العمل",asset:"الأصل",type:"النوع",priority:"الأولوية",workflowState:"حالة سير العمل",allStatuses:"أي حالة",allStates:"جميع الحالات",allTypes:"جميع الأنواع",allPriorities:"أي أولوية",allHospitals:"جميع المستشفيات",allModalities:"جميع الطرق",filterByCompany:"تصفية حسب الشركة",allManufacturers:"جميع الشركات المصنعة",sortBy:"ترتيب حسب",sortCreationNewest:"تاريخ الإنشاء (الأحدث أولاً)",sortCreationOldest:"تاريخ الإنشاء (الأقدم أولاً)",sortModifiedNewest:"آخر تعديل (الأحدث أولاً)",sortModifiedOldest:"آخر تعديل (الأقدم أولاً)",sortNameAsc:"الاسم (أ-ي)",sortNameDesc:"الاسم (ي-أ)",sortAssetNameAsc:"اسم الأصل (أ-ي)",sortAssetNameDesc:"اسم الأصل (ي-أ)",sortItemNameAsc:"اسم العنصر (أ-ي)",sortItemNameDesc:"اسم العنصر (ي-أ)",sortTeamNameAsc:"اسم الفريق (أ-ي)",sortTeamNameDesc:"اسم الفريق (ي-أ)"},gq={addNew:"إضافة جديد",searchPlaceholder:"بحث...",noResults:"لم يتم العثور على نتائج",showing:"عرض",of:"من",results:"نتائج",selectAll:"تحديد الكل",deselectAll:"إلغاء تحديد الكل",selected:"محدد",actions:"الإجراءات",view:"عرض",edit:"تعديل",delete:"حذف",duplicate:"نسخ",export:"تصدير",print:"طباعة",filters:"المرشحات",clearFilters:"مسح المرشحات",applyFilters:"تطبيق المرشحات",columns:"الأعمدة",exportSelected:"تصدير المحدد",exportAllOnPage:"تصدير الكل في الصفحة",exportAllWithFilters:"تصدير الكل مع المرشحات",exportFormat:"تنسيق التصدير",csv:"CSV",excel:"Excel",exporting:"جاري التصدير...",exportComplete:"اكتمل التصدير",close:"إغلاق",loading:"جاري التحميل...",refresh:"تحديث",deselectAllTitle:"إلغاء تحديد الكل",selectAllTitle:"تحديد الكل",typeToSearch:"اكتب للبحث...",enterFilterName:"أدخل اسم المرشح",enterFilterNameExample:"أدخل اسم المرشح (مثال: 'مفتوح أولوية عالية')",allStatuses:"أي حالة",savedFilters:"المرشحات المحفوظة",clear:"مسح",noIssuesFound:"لم يتم العثور على تذاكر",createFirstIssue:"أنشئ تذكرتك الأولى",saveFilterPreset:"حفظ مجموعة المرشحات",saveFilter:"حفظ المرشح",filtering:"جاري التصفية...",noMaintenanceTeamsFound:"لم يتم العثور على فرق صيانة",createFirstTeam:"أنشئ فريقك الأول",all:"الكل",tryAdjustingFilters:"حاول تعديل البحث أو المرشحات",getStartedCreateFirst:"ابدأ بإنشاء مخطط الصيانة الوقائية الأول",noMaintenanceLogsFound:"لم يتم العثور على سجلات صيانة",createFirstMaintenanceLog:"أنشئ سجل الصيانة الأول",total:"الإجمالي",noPPMSchedulesFound:"لم يتم العثور على جداول صيانة وقائية",createFirstPPMSchedule:"أنشئ جدول الصيانة الوقائية الأول",deleteConfirmCannotUndo:"لا يمكن التراجع عن هذا الإجراء."},fq={title:"الأصول",addAsset:"إضافة أصل جديد",assetDetails:"تفاصيل الأصل",assetInformation:"معلومات الأصل",newAsset:"أصل جديد",duplicateAsset:"نسخ الأصل",fromAsset:"من الأصل",creatingFromAsset:"جاري إنشاء أمر العمل من الأصل",assetInfoPrefilled:"معلومات الأصل معبأة مسبقاً من",pleaseSelectWorkOrderType:"يرجى اختيار نوع أمر العمل وإضافة أي تفاصيل",loadingAssetDetails:"جاري تحميل تفاصيل الأصل...",pleaseEnterAssetName:"يرجى إدخال اسم الأصل",pleaseSelectCategory:"يرجى اختيار الفئة",assetDuplicatedSuccessfully:"تم نسخ الأصل بنجاح!",assetCreatedSuccessfully:"تم إنشاء الأصل بنجاح!",assetUpdatedSuccessfully:"تم تحديث الأصل بنجاح!",sourceAssetNotFound:"الأصل المصدر غير موجود",assetNotFoundMessage:"لم يتم العثور على الأصل الذي تحاول نسخه.",backToAssetsList:"العودة إلى قائمة الأصول",backToList:"العودة إلى قائمة الأصول",createNewAsset:"إنشاء أصل جديد",newAssetDetails:"تفاصيل أصل جديد",noAssetsFound:"لم يتم العثور على أصول",createFirstAsset:"أنشئ أول أصل",deleteConfirmTitle:"حذف الأصل",deleteConfirmMessage:"هل أنت متأكد من حذف هذا الأصل؟ لا يمكن التراجع عن هذا الإجراء.",noDataToExport:"لا توجد بيانات للتصدير",loadingPermissions:"جاري تحميل الصلاحيات...",selectAssetId:"اختر معرف الأصل",selectHospital:"المستشفى",viewDetails:"عرض التفاصيل",editAsset:"تعديل الأصل",createWorkOrder:"إنشاء أمر عمل",viewLinkedWOs:"عرض أوامر العمل المرتبطة",moreActions:"المزيد من الإجراءات",exportAsJson:"تصدير كـ JSON",printAsset:"طباعة",deviceStatus:"حالة الجهاز",status:{up:"يعمل",down:"متوقف"},apiNotAvailable:"واجهة برمجة الأصول غير متاحة",apiNotDeployed:"نقطة نهاية واجهة برمجة الأصول غير مُنشأة بعد.",tryCreatingNew:"حاول إنشاء أصل جديد (تجريبي)",listTotal:"الإجمالي: ",table:{assetName:"اسم الأصل",serialNo:"الرقم التسلسلي",company:"الشركة",location:"الموقع",status:"الحالة",updatedOn:"آخر تحديث",actions:"إجراءات"},export:{title:"تصدير الأصول",selectData:"اختر البيانات للتصدير",selectedRows:"الصفوف المحددة",selectedCount:"تصدير {{count}} أصل{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}",currentPage:"الصفحة الحالية",currentPageCount:"تصدير {{count}} أصل{{count !== 1 ? 'اً' : ''}} في الصفحة الحالية",allWithFilters:"جميع السجلات (مع الفلاتر الحالية)",allWithFiltersCount:"تصدير جميع {{count}} أصل{{count !== 1 ? 'اً' : ''}} المطابقة للفلاتر الحالية",csvDesc:"قيم مفصولة بفاصلة",excelDesc:"جدول XLSX",columnsToExport:"الأعمدة للتصدير",selectAll:"تحديد الكل",resetToDefault:"إعادة التعيين للافتراضي",columnsSelected:"{{count}} عمود{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}",exporting:"جاري التصدير...",exportButton:"تصدير",exportingSelected:"جاري تصدير {{count}} صف{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}",exportingPage:"جاري تصدير {{count}} صف{{count !== 1 ? 'اً' : ''}} من الصفحة الحالية",exportingAll:"جاري تصدير جميع {{count}} صف{{count !== 1 ? 'اً' : ''}}"},detail:{assetInformation:"معلومات الأصل",technicalSpecs:"المواصفات الفنية",financialDetails:"التفاصيل المالية",assetFinanceBooks:"دفاتر أصول التمويل",addRow:"إضافة صف",duplicatingFrom:"النسخ من:",noDepartmentsMapped:"لا توجد أقسام معينة لهذا المبنى",departmentsAvailable:"{{count}} قسم متاح (مُصفى حسب المبنى)",selectDepartmentForRoom:"اختر القسم لتفعيل رقم الغرفة",depreciationMethodNote:"طريقة الاستهلاك هي طريقة محاسبية لتوزيع تكلفة أصل ملموس على عمره الإنتاجي.",calculateDepreciation:"حساب الاستهلاك",noFinanceBooksYet:'لم تتم إضافة دفاتر مالية بعد. انقر "إضافة صف" للإضافة.',noSparePartsYet:'لم تتم إضافة قطع غيار بعد. انقر "إضافة صف" للإضافة.',assetName:"اسم الأصل",category:"الفئة",modality:"الطريقة",class:"الفئة",assetId:"معرف الأصل",deviceStatus:"حالة الجهاز",serialCode:"الرمز التسلسلي",technicalDepartment:"القسم الفني",manufacturer:"الشركة المصنعة",model:"الموديل",totalHours:"إجمالي الساعات",downTimeHours:"وقت التوقف (بالساعات)",upTimeHours:"وقت التشغيل (بالساعات)",placeholderAssetName:"مثال: كمبيوتر محمول موديل X",placeholderSerialCode:"مثال: SN-12345",placeholderModelNumber:"رقم الموديل",placeholderZero:"0",placeholderDescription:"وصف موجز للأصل",placeholderPONumber:"رقم أمر الشراء",selectClass:"اختر الفئة",classA:"فئة أ",classB:"فئة ب",classC:"فئة ج",autoGenerated:"يُولد تلقائياً",calculatedFromAvailableDate:"محسوب من تاريخ التوفر للاستخدام",calculatedTotalMinusDown:"محسوب: إجمالي الساعات - وقت التوقف",hospital:"المستشفى",siteName:"اسم الموقع",selectSite:"اختر الموقع",building:"المبنى",department:"القسم",roomNumber:"رقم الغرفة",location:"الموقع",recalled:"مسترجع",selectStatus:"اختر الحالة",operational:"يعمل",underMaintenance:"قيد الصيانة",decommissioned:"مُوقف",selectServiceAgreement:"اختر اتفاقية الخدمة",warranty:"ضمان",contract:"عقد",frameWork:"إطار عمل",mainContractor:"المقاول الرئيسي",outOfWarranty:"خارج الضمان",underDismantle:"قيد التفكيك",underInstallation:"قيد التركيب",selectServiceCoverage:"اختر تغطية الخدمة",pmOnly:"صيانة وقائية فقط",labour:"عمالة",labourAndParts:"عمالة وقطع غيار",comprehensive:"شامل",supplierVendor:"المورد/البائع",selectMethod:"اختر الطريقة",straightLine:"الطريقة الخطية",doubleDecliningBalance:"الرصيد المتناقص المزدوج",writtenDownValue:"القيمة المكتوبة",manual:"يدوي",recycling:"إعادة التدوير",donation:"تبرع",sale:"بيع",assetDuplicatedSuccess:"تم نسخ الأصل بنجاح!",assetCreatedSuccess:"تم إنشاء الأصل بنجاح!",assetUpdatedSuccess:"تم تحديث الأصل بنجاح!",failedToSave:"فشل حفظ الأصل",cannotSubmitNotSaved:"لا يمكن الإرسال: الأصل غير محفوظ بعد",confirmSubmit:'هل أنت متأكد من إرسال هذا الأصل؟ بعد الإرسال، يمكن تعديل الحقول المحددة بـ "السماح عند الإرسال" فقط.',assetSubmittedSuccess:"تم إرسال الأصل بنجاح!",failedToSubmit:"فشل إرسال الأصل",pleaseSaveFirstForPPM:"يرجى حفظ الأصل أولاً لعرض خطة الصيانة الوقائية",pleaseSaveFirstForHistory:"يرجى حفظ الأصل أولاً لعرض سجل الأصل",failedToLoadPPMPlan:"فشل تحميل خطة الصيانة الوقائية. يرجى المحاولة مرة أخرى.",noPlannedMaintenance:"لم يتم العثور على صيانة مخطط لها لهذا الأصل",noWorkOrdersFound:"لم يتم العثور على أوامر عمل",noSparePartsUsed:"لم تُستخدم قطع غيار",noMaintenanceRecords:"لم يتم العثور على سجلات صيانة",noMaintenanceTasks:"لم يتم العثور على مهام صيانة",selectBuildingFirst:"اختر المبنى أولاً لتفعيل القسم",coverage:"التغطية",siteContractor:"مقاول الموقع",contractNumber:"رقم العقد",serviceAgreement:"اتفاقية الخدمة",serviceCoverage:"تغطية الخدمة",purchaseOrderNumber:"رقم أمر الشراء",grossPurchaseAmount:"مبلغ الشراء الإجمالي",purchaseDate:"تاريخ الشراء",installationDate:"تاريخ التركيب",availableForUseDate:"تاريخ التوفر للاستخدام",financeBook:"دفتر المالية",depreciationMethod:"طريقة الاستهلاك",totalDepreciations:"إجمالي الاستهلاك",frequencyMonths:"التكرار (بالأشهر)",depreciationPostingDate:"تاريخ ترحيل الاستهلاك",startDate:"تاريخ البداية",endDate:"تاريخ النهاية",totalAmount:"المبلغ الإجمالي",selectRoomFirst:"اختر رقم الغرفة لتفعيل الموقع",autoSetFromRoom:"تم التعيين تلقائياً من خريطة الغرفة",moreDetails:"تفاصيل إضافية"}},xq=JSON.parse(`{"title":"أوامر العمل","addWorkOrder":"إضافة أمر عمل جديد","workOrderDetails":"تفاصيل أمر العمل","newWorkOrder":"أمر عمل جديد","duplicateWorkOrder":"نسخ أمر العمل","createFromAsset":"إنشاء أمر عمل من الأصل","closeWorkOrders":"إغلاق أوامر العمل","closeConfirmTitle":"إغلاق أوامر العمل","closeConfirmMessage":"هل أنت متأكد من إغلاق أمر/أوامر العمل المحددة؟","deleteConfirmMessage":"هل أنت متأكد من حذف أمر العمل هذا؟ لا يمكن التراجع عن هذا الإجراء.","cancelConfirmMessage":"هل أنت متأكد من إلغاء أمر العمل هذا؟ سيتم وضع علامة ملغى ويمكنك حذفه لاحقاً إذا لزم الأمر.","assignConfirmMessage":"هل أنت متأكد من تعيين أمر العمل هذا للفني/الفنيين التاليين؟","deleteWorkOrder":"حذف أمر العمل","cancelWorkOrder":"إلغاء أمر العمل","loadingWorkOrders":"جاري تحميل أوامر العمل...","loadingDetails":"جاري تحميل تفاصيل أمر العمل...","backToList":"العودة إلى قائمة أوامر العمل","status":{"open":"مفتوح","work_in_progress":"جاري العمل","pending_review":"قيد المراجعة","completed":"مكتمل","cancelled":"ملغى","closed":"مغلق"},"priorityNormal":"عادي","priorityUrgent":"عاجل","workflowState":{"draft":"مسودة"},"priority":{"normal":"عادي","urgent":"عاجل"},"table":{"workOrderId":"معرف أمر العمل","asset":"الأصل","type":"النوع","technicalReport":"التقرير الفني","department":"القسم","workflowState":"حالة سير العمل","priority":"الأولوية","noWorkOrdersFound":"لم يتم العثور على أوامر عمل","createFirstWorkOrder":"أنشئ أول أمر عمل"},"export":{"title":"تصدير أوامر العمل","selectData":"ماذا تُصدّر","selectedRows":"الصفوف المحددة","selectedCount":"تصدير {{count}} أمر عمل{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}","currentPage":"الصفحة الحالية","currentPageCount":"تصدير {{count}} أمر عمل{{count !== 1 ? 'اً' : ''}} في الصفحة الحالية","allWithFilters":"جميع السجلات (مع الفلاتر الحالية)","allWithFiltersCount":"تصدير جميع {{count}} أمر عمل{{count !== 1 ? 'اً' : ''}} المطابقة للفلاتر الحالية","csvDesc":"قيم مفصولة بفاصلة","excelDesc":"جدول XLSX","columnsToExport":"الأعمدة للتصدير","selectAll":"تحديد الكل","resetToDefault":"إعادة التعيين للافتراضي","columnsSelected":"{{count}} عمود{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}","exporting":"جاري التصدير...","exportButton":"تصدير","exportingSelected":"جاري تصدير {{count}} صف{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}","exportingPage":"جاري تصدير {{count}} صف{{count !== 1 ? 'اً' : ''}} من الصفحة الحالية","exportingAll":"جاري تصدير جميع {{count}} صف{{count !== 1 ? 'اً' : ''}}"},"closeModal":{"title":"إغلاق أوامر العمل","confirmBulkClose":"تأكيد عملية الإغلاق الجماعي","aboutToClose":"أنت على وشك إغلاق {{count}} أمر عمل{{count !== 1 ? 'اً' : ''}}. سيتم تغيير حالة سير العمل إلى \\"مغلق\\".","alreadyClosedNote":"ملاحظة: {{count}} أمر عمل{{count !== 1 ? ' مغلقة' : ' مغلق'}} بالفعل وسيتم تخطيها.","selectedWorkOrders":"أوامر العمل المحددة ({{count}})","workOrderId":"معرف أمر العمل","currentStatus":"الحالة الحالية","workflowState":"حالة سير العمل","alreadyClosed":"(مغلق بالفعل)","willClose":"سيتم إغلاق {{count}} أمر عمل{{count !== 1 ? 'اً' : ''}}","allAlreadyClosed":"جميع أوامر العمل المحددة مغلقة بالفعل","cancel":"إلغاء","close":"إغلاق","closing":"جاري الإغلاق..."},"detail":{"workOrderInformation":"معلومات أمر العمل","assignments":"التعيينات","statusSummary":"ملخص الحالة","existingWorkOrders":"أمر/أوامر العمل الموجودة:","created":"تاريخ الإنشاء","proceedCreateNew":"هل تريد المتابعة لإنشاء أمر عمل جديد؟","loadingTechnicians":"جاري تحميل الفنيين...","feedbackBy":"التقييم بواسطة","overallSatisfaction":"رضا إجمالي","overallRatingPreview":"معاينة التقييم الإجمالي","uploading":"جاري الرفع...","uploadOpeningFile":"رفع ملف الفتح","uploadClosingFile":"رفع ملف الإغلاق","noAttachment":"لا يوجد مرفق","noClosingAttachment":"لا يوجد مرفق إغلاق","closingAttachment":"مرفق الإغلاق","currentState":"الحالة الحالية","loadingActions":"جاري تحميل الإجراءات...","actionResults":"نتائج الإجراء:","checkingFeedback":"جاري التحقق من التقييم...","yourRating":"تقييمك","repairStatus":"حالة الإصلاح","priority":"الأولوية","lastModified":"آخر تعديل","documentStatus":"حالة المستند","loadingActivity":"جاري تحميل النشاط...","added":"تمت الإضافة:","removed":"تمت الإزالة:","modified":"تم التعديل:","items":"عنصر/عناصر","rows":"صف/صفوف","pleaseAllowPopupsServiceReport":"يرجى السماح بالنوافذ المنبثقة لهذا الموقع لطباعة تقرير الخدمة.","pleaseProvideAtLeastOneRating":"يرجى تقديم تقييم واحد على الأقل","feedbackSubmittedSuccessfully":"تم إرسال التقييم بنجاح!","failedToSubmitFeedback":"فشل إرسال التقييم","feedbackUpdatedSuccessfully":"تم تحديث التقييم بنجاح!","failedToUpdateFeedback":"فشل تحديث التقييم","locationAutoSetTo":"تم تعيين الموقع تلقائياً إلى: {{location}}","noTechniciansSelected":"لم يتم تحديد فنيين","techniciansAssignedSuccessfully":"تم تعيين {{count}} فني/فنيين إضافي بنجاح","removedTechnician":"تمت إزالة {{name}}","itemAlreadyAdded":"الصنف \\"{{itemCode}}\\" مضاف بالفعل في الصف {{row}}. يرجى اختيار صنف مختلف.","insufficientStock":"مخزون غير كافٍ لـ {{itemCode}}. المتوفر: {{available}}، المطلوب: {{required}}","pleaseEnterSerialNumberToSearch":"يرجى إدخال الرقم التسلسلي للبحث","assetFound":"تم العثور على الأصل: {{name}}","noAssetFoundWithSerialNumber":"لم يتم العثور على أصل بهذا الرقم التسلسلي","fileSizeExceeds":"حجم الملف يتجاوز حد 10 ميجابايت","fileUploadedSuccessfully":"تم رفع الملف بنجاح","failedToUploadFile":"فشل رفع الملف","attachmentRemoved":"تم إزالة المرفق","failureDateSetToCurrentTime":"تم تعيين تاريخ العطل على الوقت الحالي","firstRespondedOnSetToCurrentTime":"تم تعيين وقت أول استجابة على الوقت الحالي","completionDateSetToCurrentTime":"تم تعيين تاريخ الإكمال على الوقت الحالي","firstRespondedOnSetTo":"تم تعيين وقت أول استجابة على {{datetime}}","completionDateSetTo":"تم تعيين تاريخ الإكمال على {{datetime}}","assignedSupervisorMandatory":"المشرف المعيّن إلزامي لدور مراقبة العمل.","assignedEngineerMandatory":"المهندس المعيّن إلزامي لدور مراقبة العمل.","assignedTechnicianMandatory":"الفني المعيّن إلزامي عندما تكون الحالة \\"إرسال إلى المهندس\\".","workOrderCancelledSuccessfully":"تم إلغاء أمر العمل بنجاح!","failedToCancel":"فشل الإلغاء: {{error}}","workOrderDeletedSuccessfully":"تم حذف أمر العمل بنجاح!","failedToDelete":"فشل الحذف: {{error}}","pleaseSelectWorkOrderType":"يرجى اختيار نوع أمر العمل","workOrderUpdatedSuccessfully":"تم تحديث أمر العمل بنجاح!","workOrderCreatedSuccessfully":"تم إنشاء أمر العمل بنجاح!","workOrderCreatedFromAssetSuccessfully":"تم إنشاء أمر العمل من الأصل بنجاح!","workOrderDuplicatedSuccessfully":"تم نسخ أمر العمل بنجاح!","documentModifiedByAnotherUser":"تم تعديل المستند من قبل مستخدم آخر. جاري التحديث...","pleaseReviewLatestChanges":"يرجى مراجعة أحدث التغييرات والمحاولة مرة أخرى.","failedToSaveWorkOrder":"فشل حفظ أمر العمل: {{error}}","technicalReportMandatoryForSupervisor":"التقرير الفني إلزامي عند الإرسال مباشرة إلى المشرف. يرجى ملء حقل التقرير الفني قبل المتابعة.","applyingAction":"جاري تطبيق الإجراء \\"{{action}}\\"...","assignedTo":"معيّن إلى: {{name}}","actionCompletedSuccessfully":"تم إكمال الإجراء \\"{{action}}\\" بنجاح!","documentModifiedRefreshing":"تم تعديل المستند. جاري التحديث...","tryActionAgainAfterReview":"يرجى المحاولة مرة أخرى بعد مراجعة أحدث التغييرات.","failedToApplyAction":"فشل تطبيق الإجراء \\"{{action}}\\". {{error}}","editModeEnabled":"تم تفعيل وضع التحرير","editCancelledChangesDiscarded":"تم إلغاء التحرير - تم تجاهل التغييرات","closingAttachmentRemoved":"تم إزالة مرفق الإغلاق","closingAttachmentUploadedSuccessfully":"تم رفع مرفق الإغلاق بنجاح","failedToUploadClosingAttachment":"فشل رفع مرفق الإغلاق","newStockItemRowAdded":"تمت إضافة صف صنف جديد","stockItemRemoved":"تمت إزالة صنف المخزون {{item}}","activityLogRefreshed":"تم تحديث سجل النشاط","errorLabel":"خطأ","backToList":"العودة إلى قائمة أوامر العمل","duplicateWorkOrder":"نسخ أمر العمل","createFromAsset":"إنشاء أمر عمل من الأصل","newWorkOrder":"أمر عمل جديد","workOrderDetails":"تفاصيل أمر العمل","existingWorkOrderFound":"تم العثور على أمر عمل موجود","workOrderExistsForAsset":"يوجد أمر عمل بالفعل لهذا الأصل بحالة سير عمل غير معتمدة أو مغلقة.","workOrderExistsForTypeAndRoom":"يوجد أمر عمل بالفعل لهذا النوع ورقم الغرفة بحالة سير عمل غير معتمدة أو مغلقة.","proceedWithNewWO":"هل ما زلت تريد المتابعة بإنشاء أمر عمل جديد؟","proceedAnyway":"متابعة على أي حال","noGoBack":"لا، تراجع","yesCancel":"نعم، إلغاء","cancelling":"جاري الإلغاء...","deleting":"جاري الحذف...","selectAdditionalTechnicians":"اختر فنيين إضافيين","searchTechnicians":"البحث عن فنيين...","techniciansSelected":"{{count}} فني/فنيين محدد","clearAll":"مسح الكل","noTechniciansMatchSearch":"لا يوجد فنيون يطابقون بحثك","noTechniciansFound":"لم يتم العثور على فنيين","hospital":"المستشفى","technicalDepartment":"القسم الفني","woType":"نوع أمر العمل","assetId":"معرف الأصل","assetName":"اسم الأصل","extensionNo":"رقم الامتداد","building":"المبنى","departmentName":"اسم القسم","roomNo":"رقم الغرفة","location":"الموقع","manufacturer":"الشركة المصنعة","supplier":"المورد","assignedSupervisor":"المشرف المعيّن","assignedEngineer":"المهندس المعيّن","assignedTechnician":"الفني المعيّن","fromAsset":"من الأصل","assetDetailsAutoPopulated":"تم تعبئة تفاصيل الأصل تلقائياً","selectBuildingFirst":"اختر المبنى أولاً لتفعيل القسم","printServiceReport":"طباعة تقرير الخدمة","removeAttachment":"إزالة المرفق","removeClosingAttachment":"إزالة مرفق الإغلاق","setToCurrentDateTime":"تعيين على التاريخ والوقت الحالي","selectItem":"اختر الصنف","selectWarehouse":"اختر المستودع","autoPopulatedFromStock":"تم تعبئته تلقائياً من المخزون","removeItem":"إزالة الصنف","noItemsAddedYet":"لم تتم إضافة أصناف بعد","commentsDiscussion":"التعليقات والنقاش","refreshActivityLog":"تحديث سجل النشاط","supervisorsAvailableForType":"{{count}} مشرف/مشرفين معيّن متاح لهذا النوع","civilWorkCategory":"فئة الأعمال المدنية","selectCivilWorkCategory":"اختر فئة الأعمال المدنية","selectPendingReason":"اختر سبب الانتظار","pleaseSpecifyReason":"يرجى تحديد السبب...","selectServiceAgreement":"اختر اتفاقية الخدمة","selectServiceCoverage":"اختر تغطية الخدمة","describeComplaint":"صف طبيعة الشكوى...","describeWorkPerformed":"صف العمل المنفذ...","enterSerialNumber":"أدخل الرقم التسلسلي","searchAssetBySerial":"البحث عن الأصل بالرقم التسلسلي","workOrder":"أمر العمل:","giveFeedback":"تقديم التقييم","editFeedback":"تعديل التقييم","feedbackDetails":"تفاصيل التقييم","confirmAssignment":"تأكيد التعيين","notRated":"غير مُقيّم","serviceReport":"تقرير الخدمة","assetInfoPrefilled":"تم تعبئة معلومات الأصل تلقائياً من","linkedFromAsset":"مرتبط من الأصل:","loadingAssetDetails":"جاري تحميل تفاصيل الأصل...","cancelled":"ملغى","workOrderId":"معرف أمر العمل","pendingReason":"سبب الانتظار","otherReason":"سبب آخر","serviceAgreementDetails":"تفاصيل اتفاقية الخدمة","siteContractor":"متعاقد الموقع","subcontractor":"المقاول من الباطن","model":"الموديل","description":"الوصف","natureOfComplaint":"طبيعة الشكوى","technicalReport":"التقرير الفني","selectWoTypeFirstForSupervisors":"اختر نوع أمر العمل أولاً لتصفية المشرفين المعيّنين","noSupervisorsFound":"لم يتم العثور على مشرفين معيّنين لهذا النوع من أمر العمل","requiredForExistingWO":"* مطلوب لأوامر العمل الموجودة","selectWoTypeFirstForEngineers":"اختر نوع أمر العمل أولاً لتصفية المهندسين","noEngineersFound":"لم يتم العثور على مهندسين (دور مهندس المقاول) لهذا النوع من أمر العمل","engineersAvailable":"{{count}} مهندس/مهندسين متاح","selectWoTypeFirstForTechnicians":"اختر نوع أمر العمل أولاً لتصفية الفنيين","noTechniciansFoundForType":"لم يتم العثور على فنيين لهذا النوع من أمر العمل","techniciansAvailable":"{{count}} فني/فنيين متاح","requiredForSentToEngineer":"* مطلوب لحالة \\"إرسال إلى المهندس\\"","autoCalculated":"(محسوب تلقائياً)","autoSetOnRepairStart":"(يُعيّن عند بدء الإصلاح)","autoSetOnClose":"(يُعيّن عند الإغلاق)","totalItems":"إجمالي الأصناف:","confirmAction":"تأكيد الإجراء","confirmActionMessage":"هل أنت متأكد أنك تريد {{action}} أمر العمل هذا؟","processing":"جاري المعالجة...","yesAction":"نعم، {{action}}","systemManagerNote":"مدير النظام: عرض جميع الإجراءات الصالحة لهذه الحالة.","saveToSeeActions":"احفظ التغييرات لرؤية جميع الإجراءات المتاحة.","availableActions":"الإجراءات المتاحة","allOptionsAvailable":"جميع الخيارات متاحة","bothFilledMessage":"تم ملء الفني والتقرير الفني. يمكنك الآن استخدام أي إجراء سير عمل متاح أعلاه.","technicianAssigned":"تم تعيين الفني","assignedTechnicianLabel":"الفني المعيّن:","wantToEnableSendToSupervisor":"هل تريد أيضاً تمكين \\"إرسال إلى المشرف\\"؟","fillTechnicalReportToUnlock":"املأ حقل \\"التقرير الفني\\" لفتح هذا الخيار","technicalReportFilled":"تم ملء التقرير الفني","howWasService":"كيف كانت الخدمة لأمر العمل هذا؟","noFeedbackYet":"لم يُقدّم أي تقييم بعد","statusInfoAfterCreation":"ستظهر معلومات الحالة بعد الإنشاء","activityLog":"سجل النشاط","refreshActivityLogTitle":"تحديث سجل النشاط","noChangesRecorded":"لم يُسجّل أي تغيير بعد","createdThisWorkOrder":"أنشأ أمر العمل هذا","showLess":"عرض أقل","showAll":"عرض الكل","entries":"إدخالات","changedFrom":"تغيّر من","documentUpdated":"تم تحديث المستند","addItem":"إضافة صنف","addFirstItem":"+ إضافة الصنف الأول","item":"الصنف","valuationRate":"معدل التقييم","warehouse":"المستودع","consumedQty":"الكمية المستهلكة","availableStock":"المخزون المتاح","totalValue":"إجمالي القيمة","action":"الإجراء","open":"مفتوح","autoGenerated":"يُنشأ تلقائياً","updating":"جاري التحديث...","submitting":"جاري الإرسال...","updateFeedback":"تحديث التقييم","submitFeedback":"إرسال التقييم","editRating":"تعديل التقييم","saveSelection":"حفظ التحديد"}}`),yq={title:"صيانة الأصول",maintenanceLogs:"سجلات الصيانة",maintenanceDetails:"تفاصيل الصيانة",addMaintenance:"إضافة صيانة جديدة",listTotal:"الإجمالي: {{count}} سجل صيانة{{count !== 1 ? '' : ''}}",apiNotAvailable:"واجهة صيانة الأصول غير متاحة",apiNotDeployed:"لم يتم نشر نقطة نهاية واجهة صيانة الأصول بعد.",tryCreatingNew:"جرب الإنشاء (تجريبي)",deletedSuccessfully:"تم حذف فريق الصيانة بنجاح!",status:{planned:"مخطط",completed:"مكتمل",overdue:"متأخر",cancelled:"ملغى"},maintenanceTeam:"فريق الصيانة",newMaintenanceTeam:"فريق صيانة جديد",teamId:"معرف الفريق",teamName:"اسم الفريق",managerEmail:"بريد المشرف",managerName:"اسم المشرف",expertise:"الاختصاص",selectTeam:"اختر الفريق",viewDetails:"عرض التفاصيل",editTeam:"تعديل الفريق",duplicateTeam:"نسخ الفريق",deleteTeam:"حذف الفريق",selectHospital:"اختر المستشفى",selectExpertise:"اختر الاختصاص",selectManager:"اختر المشرف",enterTeamName:"أدخل اسم الفريق",teamInformation:"معلومات الفريق",selectUser:"اختر المستخدم",selectRole:"اختر الدور",totalMembers:"إجمالي الأعضاء",teamSummary:"ملخص الفريق",addFirstMember:"أضف العضو الأول",manager:"بريد المشرف",loadingTeams:"جاري تحميل فرق الصيانة...",errorLoadingTeams:"خطأ في تحميل فرق الصيانة",deleteConfirmMessage:"هل أنت متأكد من حذف فريق الصيانة هذا؟ لا يمكن التراجع عن هذا الإجراء.",team:"الفريق",deleteTeamButton:"حذف الفريق",listTitle:"فرق الصيانة",statsTotalTeams:"إجمالي الفرق",statsManagers:"المديرون",statsHospitals:"المستشفيات",export:{title:"تصدير فرق الصيانة",selectData:"اختر البيانات للتصدير",selectedRows:"الصفوف المحددة",selectedCount:"تصدير {{count}} فريق صيانة محدد",currentPage:"الصفحة الحالية",currentPageCount:"تصدير {{count}} فريق صيانة في الصفحة الحالية",allWithFilters:"جميع السجلات (مع المرشحات الحالية)",allWithFiltersCount:"تصدير كل {{count}} فريق صيانة مطابق للمرشحات",exportFormat:"تنسيق التصدير",csv:"CSV",csvDesc:"قيم مفصولة بفواصل",excel:"Excel",excelDesc:"جدول XLSX",columnsToExport:"الأعمدة للتصدير",selectAll:"تحديد الكل",resetToDefault:"إعادة إلى الافتراضي",columnsSelected:"{{count}} عمود محدد",exporting:"جاري التصدير...",exportButton:"تصدير",exportingSelected:"تصدير {{count}} صف محدد",exportingPage:"تصدير {{count}} صف من الصفحة الحالية",exportingAll:"تصدير كل {{count}} صف"}},bq={title:"الصيانة الوقائية",ppmDetails:"تفاصيل الصيانة الوقائية",addPPM:"إضافة صيانة وقائية جديدة",periodicity:"الدورية",dueDate:"تاريخ الاستحقاق",manageSchedules:"إدارة الجداول",pmId:"معرف الصيانة الوقائية",name:"الاسم",manufacturer:"الشركة المصنعة",listTotal:"الإجمالي: {{count}} جدول صيانة وقائية{{count !== 1 ? '' : ''}}",searchPlaceholder:"ابحث بالمعرف أو الأصل أو الشركة...",filterByCompany:"تصفية حسب الشركة",company:"الشركة",asset:"الأصل",assetType:"نوع الأصل",frequency:"التكرار",noOfPMs:"عدد الصيانات الوقائية",totalAmount:"المبلغ الإجمالي",apiNotAvailable:"واجهة الصيانة الوقائية غير متاحة",apiNotDeployed:"لم يتم نشر نقطة نهاية واجهة الصيانة الوقائية بعد.",tryCreatingNew:"جرب الإنشاء (تجريبي)",deletedSuccessfully:"تم حذف جدول الصيانة الوقائية بنجاح!",noSchedulesFound:"لم يتم العثور على جداول صيانة وقائية",createFirstSchedule:"أنشئ أول جدول صيانة وقائية",confirmDelete:"تأكيد الحذف",deleteConfirmMessage:"هل أنت متأكد من حذف جدول الصيانة الوقائية هذا؟ لا يمكن التراجع عن هذا الإجراء.",detail:{duplicateSchedule:"نسخ جدول الصيانة الوقائية",newSchedule:"جدول صيانة وقائية جديد",scheduleDetails:"تفاصيل جدول الصيانة الوقائية",basicInformation:"المعلومات الأساسية",financialInformation:"المعلومات المالية",scheduleInformation:"معلومات الجدول",maintenanceTeam:"فريق الصيانة",numberOfPMs:"عدد الصيانات الوقائية",pricePerPM:"السعر لكل صيانة وقائية",frequencyPlaceholder:"مثال: شهري، ربع سنوي، سنوي",scheduleInfoAfterCreation:"ستظهر معلومات الجدول بعد الإنشاء",assetName:"اسم الأصل",pleaseEnterAssetName:"يرجى إدخال اسم الأصل",duplicatedSuccessfully:"تم نسخ جدول الصيانة الوقائية بنجاح!",createdSuccessfully:"تم إنشاء جدول الصيانة الوقائية بنجاح!",updatedSuccessfully:"تم تحديث جدول الصيانة الوقائية بنجاح!",failedToSave:"فشل الحفظ",saveChanges:"حفظ التغييرات",loadingSchedule:"جاري تحميل جدول الصيانة الوقائية...",backToSchedules:"العودة إلى جداول الصيانة الوقائية",errorLoading:"خطأ"}},vq={listTitle:"جداول الصيانة الوقائية",export:{title:"تصدير جداول الصيانة الوقائية",selectData:"نطاق التصدير",selectedRows:"الصفوف المحددة",selectedCount:"تصدير {{count}} جدول{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}",currentPage:"الصفحة الحالية",currentPageCount:"تصدير {{count}} جدول{{count !== 1 ? 'اً' : ''}} في الصفحة الحالية",allWithFilters:"جميع السجلات (مع الفلاتر الحالية)",allWithFiltersCount:"تصدير جميع {{count}} جدول{{count !== 1 ? 'اً' : ''}} المطابقة للفلاتر الحالية",csvDesc:"قيم مفصولة بفاصلة",excelDesc:"جدول XLSX",columnsToExport:"الأعمدة للتصدير",selectAll:"تحديد الكل",resetToDefault:"إعادة التعيين للافتراضي",columnsSelected:"{{count}} عمود{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}",exporting:"جاري التصدير...",exportButton:"تصدير",exportingSelected:"جاري تصدير {{count}} صف{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}",exportingPage:"جاري تصدير {{count}} صف{{count !== 1 ? 'اً' : ''}} من الصفحة الحالية",exportingAll:"جاري تصدير جميع {{count}} صف{{count !== 1 ? 'اً' : ''}}"}},wq={title:"تصدير",whatToExport:"ما الذي سيتم تصديره",selectedRows:"الصفوف المحددة",currentPage:"الصفحة الحالية",allWithFilters:"الكل مع المرشحات",exportSelected:"تصدير {count} محدد",exportPage:"تصدير {count} في الصفحة الحالية",exportAll:"تصدير الكل {count}",columnsToExport:"الأعمدة للتصدير",selectAll:"تحديد الكل",selectDefault:"تحديد الافتراضي",exporting:"جاري التصدير...",exportingSelected:"جاري تصدير {count} صف(وف) محدد(ة)",exportingPage:"جاري تصدير {count} صف(وف) من الصفحة الحالية",exportingAll:"جاري تصدير جميع {count} صف(وف)",selected:"محدد",rows:"صفوف"},jq={title:"الأصناف",itemDetails:"تفاصيل الصنف",newItem:"صنف جديد",addItem:"إضافة صنف جديد",itemId:"معرف الصنف",itemCode:"كود الصنف",itemName:"اسم الصنف",itemGroup:"مجموعة الأصناف",stockUOM:"وحدة المخزون",partDescription:"وصف القطعة",brand:"العلامة التجارية",valuationRate:"معدل التقييم",openingStock:"رصيد الافتتاح",lastCalibrationDate:"تاريخ المعايرة الأخير",nextCalibrationDate:"تاريخ المعايرة القادم",selectItem:"اختر الصنف",selectItemGroup:"اختر مجموعة الأصناف",selectHospital:"اختر المستشفى",serialNo:"الرقم التسلسلي",dateIn:"تاريخ الدخول",watts:"واط",volts:"فولت",type:"النوع",code:"الرمز",viewDetails:"عرض التفاصيل",editItem:"تعديل الصنف",duplicateItem:"نسخ الصنف",deleteItem:"حذف الصنف",basicInformation:"المعلومات الأساسية",inventoryDetails:"تفاصيل المخزون",stockInformation:"معلومات المخزون",isStockItem:"صنف مخزني",isFixedAsset:"أصل ثابت",balanceQty:"الرصيد",calibrationInformation:"معلومات المعايرة",additionalInformation:"معلومات إضافية",refreshBalanceQty:"تحديث الرصيد",warrantyMonths:"الضمان (بالأشهر)",errorLoadingItems:"خطأ في تحميل الأصناف",loadingItems:"جاري تحميل الأصناف...",deleteConfirmMessage:"هل أنت متأكد من حذف هذا الصنف؟ لا يمكن التراجع عن هذا الإجراء.",backToInventory:"العودة إلى المخزون",loadingItem:"جاري تحميل الصنف...",errorLoadingItem:"خطأ في تحميل الصنف",createNewItem:"إنشاء صنف جديد",itemCodeLabel:"كود الصنف",itemUpdatedSuccessfully:"تم تحديث الصنف بنجاح!",pleaseSaveFirst:"يرجى حفظ الصنف أولاً قبل الإرسال.",submittedSuccessfully:"تم إرسال الصنف بنجاح!",failedToSave:"فشل الحفظ",failedToSubmit:"فشل الإرسال",noItemsFound:"لم يتم العثور على عناصر",createFirstItem:"أنشئ عنصرك الأول",listTitle:"المخزون",listTotal:"الإجمالي: {{count}} عنصر{{count !== 1 ? 'اً' : ''}}",failedToLoadItems:"فشل تحميل العناصر.",listAddItem:"إضافة عنصر",export:{title:"تصدير العناصر",selectData:"اختر البيانات للتصدير",selectedRows:"الصفوف المحددة",selectedCount:"تصدير {{count}} عنصر{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}",currentPage:"الصفحة الحالية",currentPageCount:"تصدير {{count}} عنصر{{count !== 1 ? 'اً' : ''}} في الصفحة الحالية",allWithFilters:"جميع السجلات (مع الفلاتر الحالية)",allWithFiltersCount:"تصدير جميع {{count}} عنصر{{count !== 1 ? 'اً' : ''}} المطابقة للفلاتر الحالية",csvDesc:"قيم مفصولة بفاصلة",excelDesc:"جدول XLSX",columnsToExport:"الأعمدة للتصدير",selectAll:"تحديد الكل",resetToDefault:"إعادة التعيين للافتراضي",columnsSelected:"{{count}} عمود{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}",exporting:"جاري التصدير...",exportButton:"تصدير",exportingSelected:"جاري تصدير {{count}} صف{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}",exportingPage:"جاري تصدير {{count}} صف{{count !== 1 ? 'اً' : ''}} من الصفحة الحالية",exportingAll:"جاري تصدير جميع {{count}} صف{{count !== 1 ? 'اً' : ''}}"}},_q={title:"التذاكر",issueDetails:"تفاصيل التذكرة",newIssue:"تذكرة جديدة",addIssue:"إضافة تذكرة جديدة",issueId:"معرف التذكرة",subject:"الموضوع",raisedBy:"أُبلغ بها",contact:"جهة الاتصال",issueType:"نوع التذكرة",openingDate:"تاريخ الفتح",resolutionDate:"تاريخ الحل",resolvedBy:"تم الحل بواسطة",firstRespondedOn:"أول رد في",resolutionDetails:"تفاصيل الحل",selectIssue:"اختر التذكرة",allPriorities:"أي أولوية",allCompanies:"جميع الشركات",viewDetails:"عرض التفاصيل",editIssue:"تعديل التذكرة",deleteIssue:"حذف التذكرة",enterSubject:"أدخل موضوع التذكرة",selectPriority:"اختر الأولوية",selectIssueType:"اختر نوع التذكرة",describeIssue:"صف التذكرة بالتفصيل...",contactInformation:"معلومات الاتصال",createNewIssue:"إنشاء تذكرة دعم جديدة",resolution:"الحل",describeResolution:"صف كيف تم حل التذكرة...",selectCompany:"اختر الشركة",statusInformation:"معلومات الحالة",currentStatus:"الحالة الحالية",timeline:"الجدول الزمني",loadingIssues:"جاري تحميل التذاكر...",errorLoadingIssues:"خطأ في تحميل التذاكر",deleteConfirmMessage:"هل أنت متأكد من حذف هذه التذكرة؟ لا يمكن التراجع عن هذا الإجراء.",deletedSuccessfully:"تم حذف التذكرة بنجاح!",listTitle:"تذاكر الدعم",listTotal:"الإجمالي",listSelected:"محدد",statsTotalIssues:"إجمالي التذاكر",statsOpen:"مفتوحة",statsResolved:"محلولة",statsClosed:"مغلقة",export:{title:"تصدير التذاكر",selectData:"اختر البيانات للتصدير",selectedRows:"الصفوف المحددة",selectedCount:"تصدير {{count}} تذكرة محددة",currentPage:"الصفحة الحالية",currentPageCount:"تصدير {{count}} تذكرة في الصفحة الحالية",allWithFilters:"جميع السجلات (مع المرشحات الحالية)",allWithFiltersCount:"تصدير كل {{count}} تذكرة مطابقة للمرشحات",exportFormat:"تنسيق التصدير",csv:"CSV",csvDesc:"قيم مفصولة بفواصل",excel:"Excel",excelDesc:"جدول XLSX",columnsToExport:"الأعمدة للتصدير",selectAll:"تحديد الكل",resetToDefault:"إعادة إلى الافتراضي",columnsSelected:"{{count}} عمود محدد",exporting:"جاري التصدير...",exportButton:"تصدير",exportingSelected:"تصدير {{count}} صف محدد",exportingPage:"تصدير {{count}} صف من الصفحة الحالية",exportingAll:"تصدير كل {{count}} صف"},status:{open:"مفتوحة",replied:"تم الرد",on_hold:"قيد الانتظار",resolved:"محلولة",closed:"مغلقة"},priority:{low:"منخفضة",medium:"متوسطة",high:"عالية",critical:"حرجة"}},kq={title:"المستخدمون",userDetails:"تفاصيل المستخدم",newUser:"مستخدم جديد",addUser:"إضافة مستخدم جديد",searchUsers:"بحث عن مستخدمين...",manageUsers:"إدارة حسابات المستخدمين والصلاحيات",noUsersFound:"لم يتم العثور على مستخدمين",tryAdjustingSearch:"حاول تعديل مصطلحات البحث.",noUsersAvailable:"لا يوجد مستخدمون متاحون.",backToDashboard:"العودة إلى لوحة التحكم",refresh:"تحديث",active:"نشط",inactive:"غير نشط",noEmail:"لا يوجد بريد إلكتروني",created:"تاريخ الإنشاء"},Nq={title:"الفعاليات",eventDetails:"تفاصيل الفعالية",newEvent:"فعالية جديدة",addEvent:"إضافة فعالية",upcomingEvents:"الفعاليات القادمة",eventsFromFrappe:"فعاليات من نظام Frappe",noEventsFound:"لم يتم العثور على فعاليات",noEventsScheduled:"لا توجد فعاليات مجدولة حالياً.",refreshEvents:"تحديث الفعاليات"},Sq={previous:"السابق",next:"التالي",goTo:"انتقل إلى",go:"انتقال",page:"صفحة",showingToOf:"عرض {{start}} إلى {{end}} من {{total}} {{label}}",showingTo:"عرض {{start}} إلى {{end}} {{label}}",items:"أصناف",assets:"أصول",workOrders:"أوامر عمل",issues:"تذاكر",teams:"فرق",inspections:"عمليات تفتيش",plans:"خطط"},Cq={loading:"جاري التحميل...",noResultsFound:"لم يتم العثور على نتائج",createNewDoctype:"إنشاء {{doctype}} جديد",selectLabel:"اختر {{label}}"},Tq={loadingSupportPlans:"جاري تحميل خطط الدعم...",errorLoadingSupportPlans:"خطأ في تحميل خطط الدعم",deleteConfirmMessage:"هل أنت متأكد من حذف خطة الدعم هذه؟ لا يمكن التراجع عن هذا الإجراء.",planId:"معرف الخطة",deletedSuccessfully:"تم حذف خطة الدعم بنجاح!",deleteSupportPlan:"حذف خطة الدعم",noSupportPlansFound:"لم يتم العثور على خطط دعم",createFirstSupportPlan:"أنشئ أول خطة دعم",table:{planName:"اسم الخطة",type:"النوع",frequency:"التكرار",contractValue:"قيمة العقد",warrantyStatus:"حالة الضمان",contractStatus:"حالة العقد"},status:{active:"نشط",expired:"منتهي",pending:"قيد الانتظار",terminated:"منتهي مبكرًا"},statusLabel:{warrantyPrefix:"ض:",contractPrefix:"ع:"},viewDetails:"عرض خطة الدعم",editSupportPlan:"تعديل خطة الدعم",listTitle:"خطط الدعم",statsTotalPlans:"إجمالي الخطط",statsContracts:"العقود",statsWarranties:"الضمانات",statsActive:"نشطة",export:{title:"تصدير خطط الدعم",selectData:"اختر البيانات للتصدير",selectedRows:"الصفوف المحددة",selectedCount:"تصدير {{count}} خطة دعم محددة",currentPage:"الصفحة الحالية",currentPageCount:"تصدير {{count}} خطة دعم في الصفحة الحالية",allWithFilters:"جميع السجلات (مع المرشحات الحالية)",allWithFiltersCount:"تصدير كل {{count}} خطة دعم مطابقة للمرشحات",exportFormat:"تنسيق التصدير",csv:"CSV",csvDesc:"قيم مفصولة بفواصل",excel:"Excel",excelDesc:"جدول XLSX",columnsToExport:"الأعمدة للتصدير",selectAll:"تحديد الكل",resetToDefault:"إعادة إلى الافتراضي",columnsSelected:"{{count}} عمود محدد",exporting:"جاري التصدير...",exportButton:"تصدير",exportingSelected:"تصدير {{count}} صف محدد",exportingPage:"تصدير {{count}} صف من الصفحة الحالية",exportingAll:"تصدير كل {{count}} صف"}},Eq={title:"عمليات التفتيش",loadingInspections:"جاري تحميل عمليات التفتيش...",errorLoadingInspections:"خطأ في تحميل عمليات التفتيش",deleteConfirmMessage:"هل أنت متأكد من حذف عملية التفتيش هذه؟ لا يمكن التراجع عن هذا الإجراء.",inspectionId:"معرف التفتيش",deleteInspection:"حذف التفتيش",deletedSuccessfully:"تم حذف التفتيش بنجاح!",noInspectionsFound:"لم يتم العثور على عمليات تفتيش",createFirstInspection:"أنشئ أول عملية تفتيش",type:"نوع التفتيش",workflowStateHeader:"حالة سير العمل",targetDate:"تاريخ الاستهداف",requestedBy:"طُلِبت بواسطة",linkedWorkOrder:"أمر العمل المرتبط",savedFilters:"المرشحات المحفوظة",newInspection:"تفتيش جديد",inspectionReport:"تقرير التفتيش",technicalDepartment:"القسم الفني",filterStatus:"الحالة",filterWorkflow:"سير العمل",filterType:"النوع",filterWorkOrder:"أمر العمل",filterDepartment:"القسم",selectWorkOrder:"اختر أمر العمل",selectDepartment:"اختر القسم",stats:{draft:"مسودة",pendingApproval:"بانتظار الموافقة",closed:"مغلقة"},status:{open:"مفتوحة",in_progress:"قيد التنفيذ",pending_review:"بانتظار المراجعة",closed:"مغلقة"},workflowState:{draft:"مسودة",sent_to_work_control:"مرسل إلى التحكم بالعمل",sent_to_technician:"مرسل إلى الفني",sent_to_supervisor:"مرسلة إلى المشرف",closed:"مغلقة"},typeMap:{inspection:"تفتيش",safety_inspection:"تفتيش سلامة"},viewDetails:"عرض التفاصيل",editInspection:"تعديل التفتيش",export:{title:"تصدير عمليات التفتيش",selectData:"اختر البيانات للتصدير",selectedRows:"الصفوف المحددة",selectedCount:"تصدير {{count}} عملية تفتيش محددة",currentPage:"الصفحة الحالية",currentPageCount:"تصدير {{count}} عملية تفتيش في الصفحة الحالية",allWithFilters:"جميع السجلات (مع المرشحات الحالية)",allWithFiltersCount:"تصدير كل {{count}} عملية تفتيش مطابقة للمرشحات",exportFormat:"تنسيق التصدير",csv:"CSV",csvDesc:"قيم مفصولة بفواصل",excel:"Excel",excelDesc:"جدول XLSX",columnsToExport:"الأعمدة للتصدير",selectAll:"تحديد الكل",resetToDefault:"إعادة إلى الافتراضي",columnsSelected:"{{count}} عمود محدد",exporting:"جاري التصدير...",exportButton:"تصدير",exportingSelected:"تصدير {{count}} صف محدد",exportingPage:"تصدير {{count}} صف من الصفحة الحالية",exportingAll:"تصدير كل {{count}} صف",inspectionId:"معرف التفتيش",inspectionType:"نوع التفتيش",status:"الحالة",workflowState:"حالة سير العمل",inspectionDate:"تاريخ التفتيش",targetClosureDate:"تاريخ الإغلاق المستهدف",requestedBy:"طُلِبت بواسطة",technicalDepartment:"القسم الفني",linkedWorkOrder:"أمر العمل المرتبط",observationNote:"ملاحظة الملاحظة",technicalResponse:"الرد الفني",createdOn:"تاريخ الإنشاء",modifiedOn:"تاريخ التعديل",createdBy:"أنشئ بواسطة"},detail:{loadingDetails:"جاري تحميل تفاصيل التفتيش...",errorLoading:"خطأ في تحميل التفتيش",backToList:"العودة إلى التفتيشات",newInspection:"تفتيش جديد",inspectionDetails:"تفاصيل التفتيش",createNewRecord:"إنشاء سجل تفتيش جديد",cancelInspection:"إلغاء التفتيش",cancelConfirmMessage:"هل أنت متأكد أنك تريد إلغاء هذا التفتيش؟ سيتم تمييز التفتيش كملغى ويمكنك حذفه بعد ذلك إذا لزم الأمر.",noGoBack:"لا، تراجع",yesCancel:"نعم، إلغاء",cancelling:"جاري الإلغاء...",selectType:"اختر النوع",workOrderType:"نوع أمر العمل",selectWorkOrderType:"اختر نوع أمر العمل",techniciansAvailable:"{{count}} فني/فنيين متاح لهذا النوع",selectDepartment:"اختر القسم",selectLocation:"اختر الموقع",extensionNo:"رقم الامتداد *",selectExtension:"اختر الامتداد",inspectionDate:"تاريخ التفتيش",targetClosureDate:"تاريخ الإغلاق المستهدف",cannotBeInPast:"لا يمكن أن يكون في الماضي",cannotBeEarlier:"لا يمكن أن يكون أقدم من تاريخ التفتيش أو في الماضي",openingAttachment:"مرفق الافتتاح",closingAttachment:"مرفق الإغلاق",uploading:"جاري الرفع...",uploadFile:"رفع ملف",uploadClosingFile:"رفع ملف الإغلاق",noAttachment:"لا يوجد مرفق",removeAttachment:"إزالة المرفق",assignmentInformation:"معلومات التعيين",requestedBy:"طُلِبت بواسطة",selectUser:"اختر المستخدم",technicalDepartment:"القسم الفني",assignedTechnician:"الفني المعيّن",selectTechnician:"اختر الفني",selectWOTypeFirst:"اختر نوع أمر العمل أولاً لتصفية الفنيين",noTechniciansForType:"لم يتم العثور على فنيين لهذا النوع من أمر العمل",notesAndResponse:"الملاحظات والرد",observationNote:"ملاحظة الملاحظة",placeholderObservation:"أدخل ملاحظات الملاحظة...",technicalResponse:"الرد الفني",placeholderTechnicalResponse:"أدخل الرد الفني...",linkedWorkOrder:"أمر العمل المرتبط",linkedCorrectiveWO:"أمر العمل التصحيحي المرتبط",readOnly:"للقراءة فقط",viewWorkOrder:"عرض أمر العمل",noLinkedWorkOrder:"لا يوجد أمر عمل مرتبط",workflowActions:"إجراءات سير العمل",workflowProgress:"تقدم سير العمل",workControl:"مراقبة العمل",technicianStep:"الفني",supervisorStep:"المشرف",draftStep:"مسودة",closedStep:"مغلق",statusInfo:"معلومات الحالة",documentStatus:"حالة المستند",woType:"نوع أمر العمل",assignedTo:"معيّن إلى",submitted:"مُرسل",cancelled:"ملغى",added:"مضاف:",removed:"مُزال:",modified:"مُعدّل:",items:"عنصر/عناصر",rows:"صف/صفوف",activityLog:"سجل النشاط",activityLogRefreshed:"تم تحديث سجل النشاط",refreshActivityLog:"تحديث سجل النشاط",noChangesRecorded:"لم يتم تسجيل أي تغييرات بعد",createdThisInspection:"أنشأ هذا التفتيش",changedFrom:"تم التغيير من",documentUpdated:"تم تحديث المستند",showLess:"عرض أقل",showAll:"عرض الكل",department:"القسم",location:"الموقع",inspectionType:"نوع التفتيش",status:"الحالة",removeClosingAttachment:"إزالة مرفق الإغلاق",noClosingAttachment:"لا يوجد مرفق إغلاق",cancelledSuccessfully:"تم إلغاء التفتيش بنجاح!",failedToCancel:"فشل الإلغاء: {{error}}",failedToSave:"فشل الحفظ: {{error}}",failedToDelete:"فشل الحذف: {{error}}",targetClosureMandatory:"تاريخ الإغلاق المستهدف إلزامي للحفظ.",attachmentMandatory:"المرفق إلزامي للحفظ.",extensionMandatory:"رقم الامتداد إلزامي للحفظ.",createdSuccessfully:"تم إنشاء التفتيش بنجاح!",updatedSuccessfully:"تم تحديث التفتيش بنجاح!",deletedSuccessfully:"تم حذف التفتيش بنجاح!",inspectionDateInPast:"لا يمكن أن يكون تاريخ التفتيش في الماضي.",targetClosureEarlier:"لا يمكن أن يكون تاريخ الإغلاق المستهدف أقدم من تاريخ التفتيش.",targetClosureInPast:"لا يمكن أن يكون تاريخ الإغلاق المستهدف في الماضي.",fileSizeExceeds:"حجم الملف يتجاوز حد 10 ميجابايت",fileUploadedSuccess:"تم رفع الملف بنجاح",failedToUpload:"فشل رفع الملف",closingAttachmentRemoved:"تم إزالة مرفق الإغلاق",closingAttachmentUploadedSuccess:"تم رفع مرفق الإغلاق بنجاح",failedToUploadClosing:"فشل رفع مرفق الإغلاق",attachmentRemoved:"تم إزالة المرفق",systemManager:"مدير النظام",workflow:"سير العمل"}},Aq={title:"الخريطة النشطة",loading:"جاري تحميل بيانات الخريطة...",hospital:"المستشفى",departmentWoType:"القسم (نوع أمر العمل)",selectHospital:"اختر المستشفى",selectDepartment:"اختر القسم",clearDepartmentHint:"مسح القسم للتصفية حسب المستشفى",clearHospitalHint:"مسح المستشفى للتصفية حسب القسم",clearFilters:"مسح المرشحات",legendHospital:"المستشفى",legendDepartment:"القسم (نوع أمر العمل)",legendHasUrgent:"يوجد أوامر عمل عاجلة",totalAssets:"إجمالي الأصول",workOrderStatus:"حالة أمر العمل",status:"الحالة",count:"العدد",normal:"عادي",urgent:"عاجل",open:"مفتوح",workInProgress:"قيد التنفيذ",pendingReview:"بانتظار المراجعة",completed:"مكتمل",closed:"مغلق",preventiveMaintenance:"الصيانة الوقائية",planned:"مخطط",overdue:"متأخر",viewAssets:"عرض الأصول",viewWorkOrders:"عرض أوامر العمل",viewAllWorkOrders:"عرض جميع أوامر العمل",showingWorkOrdersByType:"عرض أوامر العمل حسب النوع",deptWoType:"القسم / نوع أمر العمل",tooltipDept:"قسم",tooltipHospital:"مستشفى",tooltipUrgent:"عاجل! ",normalWos:"أوامر عادية:",urgentWos:"أوامر عاجلة:",closedWos:"أوامر مغلقة:",plannedPms:"صيانة مخطط لها:",completedPms:"صيانة مكتملة:",assets:"الأصول"},Oq={title:"تقويم الصيانة",viewType:"نوع العرض",maintenanceLog:"سجل الصيانة",ppmPlanner:"مخطط الصيانة الوقائية",filters:"المرشحات",yearlyMap:"الخريطة السنوية",yearlyMapTitle:"عرض خريطة مخطط الصيانة الوقائية السنوية",mapShort:"خريطة",hospital:"المستشفى",selectHospital:"اختر المستشفى",department:"القسم",allDepartments:"جميع الأقسام",status:"الحالة",allStatuses:"جميع الحالات",planned:"مخطط",completed:"مكتمل",overdue:"متأخر",cancelled:"ملغى",assignedTo:"مكلف إلى",allTechnicians:"جميع الفنيين",clearFilters:"مسح المرشحات",months:{january:"يناير",february:"فبراير",march:"مارس",april:"أبريل",may:"مايو",june:"يونيو",july:"يوليو",august:"أغسطس",september:"سبتمبر",october:"أكتوبر",november:"نوفمبر",december:"ديسمبر"},days:{sun:"الأحد",mon:"الإثنين",tue:"الثلاثاء",wed:"الأربعاء",thu:"الخميس",fri:"الجمعة",sat:"السبت"},previousMonth:"الشهر السابق",today:"اليوم",nextMonth:"الشهر التالي",loadingLogs:"جاري تحميل سجلات الصيانة...",loadingPpm:"جاري تحميل مخططات الصيانة الوقائية...",overdueInTooltip:"(متأخر)",clickToViewDetails:"انقر لعرض التفاصيل",clickToViewPpmPlanner:"انقر لعرض مخطط الصيانة الوقائية",ppmPlannerDefault:"مخطط الصيانة الوقائية",legendCompleted:"مكتمل",legendPlanned:"مخطط",legendOverdue:"متأخر",legendToday:"اليوم",summaryPpmPlanners:"مخططات الصيانة الوقائية"},Pq={common:oq,sidebar:lq,projects:cq,profile:dq,login:uq,dashboard:mq,commonFields:hq,filters:pq,listPages:gq,assets:fq,workOrders:xq,maintenance:yq,ppm:bq,ppmPlanner:vq,exportModal:wq,items:jq,issues:_q,users:kq,events:Nq,pagination:Sq,linkField:Cq,supportPlans:Tq,inspections:Eq,activeMap:Aq,maintenanceCalendarPage:Oq},Ar={BASE_URL:"",ENDPOINTS:{USER_DETAILS:"/api/method/asset_lite.api.custom_api.get_user_details",DOCTYPE_RECORDS:"/api/method/asset_lite.api.custom_api.get_doctype_records",DASHBOARD_STATS:"/api/method/asset_lite.api.custom_api.get_dashboard_stats",DASHBOARD_NUMBER_CARDS:"/api/method/asset_lite.api.dashboard_api.get_number_cards",DASHBOARD_LIST_CHARTS:"/api/method/asset_lite.api.dashboard_api.list_dashboard_charts",DASHBOARD_CHART_DATA:"/api/method/asset_lite.api.dashboard_api.get_dashboard_chart_data",DASHBOARD_REPAIR_COST:"/api/method/asset_lite.api.dashboard_api.get_repair_cost_by_item",TECHNICIAN_WORKING_HOURS:"/api/method/asset_lite.api.dashboard_api.get_technician_working_hours",TECHNICIAN_WORK_SUMMARY:"/api/method/asset_lite.api.dashboard_api.get_technician_work_summary",KYC_DETAILS:"/api/method/asset_lite.api.custom_api.get_kyc_details",GET_ASSETS:"/api/method/asset_lite.api.asset_api.get_assets",GET_ASSET_DETAILS:"/api/method/asset_lite.api.asset_api.get_asset_details",CREATE_ASSET:"/api/method/asset_lite.api.asset_api.create_asset",UPDATE_ASSET:"/api/method/asset_lite.api.asset_api.update_asset",DELETE_ASSET:"/api/method/asset_lite.api.asset_api.delete_asset",GET_ASSET_FILTERS:"/api/method/asset_lite.api.asset_api.get_asset_filters",GET_ASSET_STATS:"/api/method/asset_lite.api.asset_api.get_asset_stats",SEARCH_ASSETS:"/api/method/asset_lite.api.asset_api.search_assets",SUBMIT_ASSET:"/api/method/asset_lite.api.asset_api.submit_asset",CANCEL_ASSET:"/api/method/asset_lite.api.asset_api.cancel_asset",GET_WORK_ORDERS:"/api/method/asset_lite.api.work_order_api.get_work_orders",GET_WORK_ORDER_DETAILS:"/api/method/asset_lite.api.work_order_api.get_work_order_details",CREATE_WORK_ORDER:"/api/method/asset_lite.api.work_order_api.create_work_order",UPDATE_WORK_ORDER:"/api/method/asset_lite.api.work_order_api.update_work_order",DELETE_WORK_ORDER:"/api/method/asset_lite.api.work_order_api.delete_work_order",UPDATE_WORK_ORDER_STATUS:"/api/method/asset_lite.api.work_order_api.update_work_order_status",GET_ASSET_MAINTENANCE_LOGS:"/api/method/asset_lite.api.asset_maintenance_api.get_asset_maintenance_logs",GET_ASSET_MAINTENANCE_LOG_DETAILS:"/api/method/asset_lite.api.asset_maintenance_api.get_asset_maintenance_log_details",CREATE_ASSET_MAINTENANCE_LOG:"/api/method/asset_lite.api.asset_maintenance_api.create_asset_maintenance_log",UPDATE_ASSET_MAINTENANCE_LOG:"/api/method/asset_lite.api.asset_maintenance_api.update_asset_maintenance_log",DELETE_ASSET_MAINTENANCE_LOG:"/api/method/asset_lite.api.asset_maintenance_api.delete_asset_maintenance_log",UPDATE_MAINTENANCE_STATUS:"/api/method/asset_lite.api.asset_maintenance_api.update_maintenance_status",GET_MAINTENANCE_LOGS_BY_ASSET:"/api/method/asset_lite.api.asset_maintenance_api.get_maintenance_logs_by_asset",GET_OVERDUE_MAINTENANCE_LOGS:"/api/method/asset_lite.api.asset_maintenance_api.get_overdue_maintenance_logs",GET_ASSET_MAINTENANCES:"/api/method/asset_lite.api.ppm_api.get_asset_maintenances",GET_ASSET_MAINTENANCE_DETAILS:"/api/method/asset_lite.api.ppm_api.get_asset_maintenance_details",CREATE_ASSET_MAINTENANCE:"/api/method/asset_lite.api.ppm_api.create_asset_maintenance",UPDATE_ASSET_MAINTENANCE:"/api/method/asset_lite.api.ppm_api.update_asset_maintenance",DELETE_ASSET_MAINTENANCE:"/api/method/asset_lite.api.ppm_api.delete_asset_maintenance",GET_MAINTENANCE_TASKS:"/api/method/asset_lite.api.ppm_api.get_maintenance_tasks",GET_SERVICE_COVERAGE:"/api/method/asset_lite.api.ppm_api.get_service_coverage",GET_MAINTENANCES_BY_ASSET:"/api/method/asset_lite.api.ppm_api.get_maintenances_by_asset",GET_ACTIVE_SERVICE_CONTRACTS:"/api/method/asset_lite.api.ppm_api.get_active_service_contracts",LOGIN:"/api/method/login",RESET_PASSWORD:"/api/method/frappe.core.doctype.user.user.reset_password",LOGOUT:"/api/method/logout",CSRF_TOKEN:"/api/method/frappe.sessions.get_csrf_token",TWO_FACTOR_STATUS:"/api/method/asm_ui_app.api.two_factor.get_two_factor_status",UPLOAD_FILE:"/api/method/upload_file",GET_USER_PERMISSIONS:"/api/method/asset_lite.api.userperm_api.get_user_permissions",GET_PERMISSION_FILTERS:"/api/method/asset_lite.api.userperm_api.get_permission_filters",GET_ALLOWED_VALUES:"/api/method/asset_lite.api.userperm_api.get_allowed_values",CHECK_DOCUMENT_ACCESS:"/api/method/asset_lite.api.userperm_api.check_document_access",GET_CONFIGURED_DOCTYPES:"/api/method/asset_lite.api.userperm_api.get_configured_doctypes",GET_USER_DEFAULTS:"/api/method/asset_lite.api.userperm_api.get_user_defaults"},DEFAULT_HEADERS:{"Content-Type":"application/json",Accept:"application/json"},TIMEOUT:parseInt("60000")};class Dq{constructor(){$s(this,"baseURL");$s(this,"endpoints");$s(this,"defaultHeaders");$s(this,"timeout");this.baseURL=Ar.BASE_URL,this.endpoints=Ar.ENDPOINTS,this.defaultHeaders=Ar.DEFAULT_HEADERS,this.timeout=Ar.TIMEOUT}getCSRFToken(){return J(this,null,function*(){try{if(typeof window!="undefined"&&window.csrf_token)return window.csrf_token;if(!localStorage.getItem("user"))return null;const a=yield fetch(`${this.baseURL}${this.endpoints.CSRF_TOKEN}`,{method:"GET",headers:{Accept:"application/json"},credentials:"include"});return a.ok&&(yield a.json()).message||null}catch(r){return null}})}apiCall(s){return J(this,arguments,function*(r,a={}){const n=`${this.baseURL}${r}`,i=se({method:"GET",headers:se(se({},this.defaultHeaders),a.headers)},a),o=yield this.getCSRFToken();o&&(i.headers["X-Frappe-CSRF-Token"]=o);try{const l=new AbortController,c=setTimeout(()=>l.abort(),this.timeout),u=yield fetch(n,je(se({},i),{signal:l.signal}));if(clearTimeout(c),!u.ok){const f=yield u.json().catch(()=>({}));throw new Po(f.error||`HTTP error! status: ${u.status}`,u.status)}const h=yield u.json();return h.message!==void 0?h.message:h}catch(l){throw l instanceof Error?(console.error("API call failed:",l),new Po(l.message)):l}})}parseFrappeLoginError(r,a){if(typeof r.message=="string"&&r.message)return r.message;if(typeof r.exc=="string"&&r.exc){const s=r.exc.match(/:\s*(.+)$/);return s?s[1].trim():r.exc}if(r._server_messages)try{const i=JSON.parse(String(r._server_messages)).map(o=>JSON.parse(o)).map(o=>o.message).filter(Boolean).join(" ");if(i)return i}catch(s){}return a===401?"Invalid credentials or verification code.":"Login failed. Please try again."}parseLoggedInUser(r,a){return typeof r.message=="string"&&r.message==="Logged In"?{full_name:r.full_name,user_id:r.user||a,home_page:r.home_page,sid:r.sid,email:a}:r.message&&typeof r.message=="object"?r.message:r.full_name||r.user?{full_name:r.full_name,user_id:r.user||a,home_page:r.home_page,sid:r.sid,email:a}:null}postLoginRequest(r){return J(this,null,function*(){const a=`${this.baseURL}${this.endpoints.LOGIN}`,s=new AbortController,n=setTimeout(()=>s.abort(),this.timeout);try{const i=yield fetch(a,{method:"POST",headers:{Accept:"application/json"},body:r,credentials:"include",signal:s.signal}),o=yield i.text();let l={};try{l=o?JSON.parse(o):{}}catch(c){l={}}if(!i.ok){const c=i.status===401?"Invalid credentials or verification code.":"Login failed. Please try again.";throw new Po(c,i.status)}return l}finally{clearTimeout(n)}})}mapLoginResponse(r,a){const s=r.verification,n=r.tmp_id,i=r.message;if(s&&n&&i!=="Logged In")return{status:"two_factor_required",tmp_id:n,verification:s};const o=this.parseLoggedInUser(r,a);if(o&&(i==="Logged In"||o.sid||o.user_id))return{status:"logged_in",user:o};throw new Po("Unexpected login response.",500,"INVALID_RESPONSE")}login(r){return J(this,null,function*(){const a=new FormData;a.append("usr",r.email),a.append("pwd",r.password);const s=yield this.postLoginRequest(a);return this.mapLoginResponse(s,r.email)})}verifyLoginOtp(r,a){return J(this,null,function*(){const s=new FormData;s.append("otp",a.trim()),s.append("tmp_id",r);const n=yield this.postLoginRequest(s),i=this.mapLoginResponse(n);if(i.status!=="logged_in")throw new Po("Verification failed. Please try again.",401,"OTP_FAILED");return i})}requestPasswordReset(r,a){return J(this,null,function*(){const s=r.trim();if(!s)throw new Po("Email is required",400,"EMPTY_EMAIL");const n=yield this.getCSRFTokenForGuest(),i={Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"};n&&(i["X-Frappe-CSRF-Token"]=n);const o=`${this.baseURL}${this.endpoints.RESET_PASSWORD}`,l=new AbortController,c=setTimeout(()=>l.abort(),45e3),u=a?AbortSignal.any([a,l.signal]):l.signal;try{const h=yield fetch(o,{method:"POST",headers:i,body:new URLSearchParams({user:s}).toString(),credentials:"include",signal:u}),f=yield h.text();let y={};try{y=f?JSON.parse(f):{}}catch(w){y={}}const b=typeof y.message=="string"?y.message:typeof y.message=="object"&&y.message!==null&&"message"in y.message?String(y.message.message):"";if(h.status===404||b.toLowerCase().includes("not found"))throw new Po("User not found",404,"USER_NOT_FOUND");if(h.status===403)throw new Po("Could not send reset email",403,"FORBIDDEN");if(!h.ok)throw new Po(b||`HTTP error! status: ${h.status}`,h.status,"REQUEST_FAILED");if(b==="disabled"||b==="not allowed")throw new Po("Reset not allowed",200,"RESET_NOT_ALLOWED")}finally{clearTimeout(c)}})}getCSRFTokenForGuest(){return J(this,null,function*(){const r=typeof window!="undefined"?window:void 0;if(r!=null&&r.csrf_token)return r.csrf_token;try{const a=yield fetch(`${this.baseURL}${this.endpoints.CSRF_TOKEN}`,{method:"GET",headers:{Accept:"application/json"},credentials:"include"});if(a.ok)return(yield a.json()).message||null}catch(a){}return null})}logout(){return J(this,null,function*(){yield this.apiCall(this.endpoints.LOGOUT,{method:"POST"})})}getUserDetails(r){return J(this,null,function*(){const a=r?`?user_id=${r}`:"";return this.apiCall(`${this.endpoints.USER_DETAILS}${a}`)})}getDoctypeRecords(r,a,s,n=20,i=0){return J(this,null,function*(){const o=new URLSearchParams({doctype:r,limit:n.toString(),offset:i.toString()});return a&&o.append("filters",JSON.stringify(a)),s&&o.append("fields",JSON.stringify(s)),this.apiCall(`${this.endpoints.DOCTYPE_RECORDS}?${o}`)})}getDashboardStats(){return J(this,null,function*(){return this.apiCall(this.endpoints.DASHBOARD_STATS)})}getNumberCards(){return J(this,null,function*(){return this.apiCall(this.endpoints.DASHBOARD_NUMBER_CARDS)})}listDashboardCharts(r=!0){return J(this,null,function*(){const a=new URLSearchParams({public_only:r?"1":"0"});return this.apiCall(`${this.endpoints.DASHBOARD_LIST_CHARTS}?${a}`)})}getDashboardChartData(r,a){return J(this,null,function*(){const s=new URLSearchParams({chart_name:r});return a&&s.append("report_filters",JSON.stringify(a)),this.apiCall(`${this.endpoints.DASHBOARD_CHART_DATA}?${s}`)})}getKycDetails(){return J(this,null,function*(){return this.apiCall(this.endpoints.KYC_DETAILS)})}uploadFile(r){return J(this,null,function*(){const a=new FormData;return a.append("file",r.file),a.append("doctype",r.doctype),a.append("docname",r.docname),a.append("fieldname",r.fieldname),this.apiCall(this.endpoints.UPLOAD_FILE,{method:"POST",headers:{},body:a})})}getUserPermissions(r){return J(this,null,function*(){const a=r?`?user=${encodeURIComponent(r)}`:"";return this.apiCall(`${this.endpoints.GET_USER_PERMISSIONS}${a}`)})}getPermissionFilters(r,a){return J(this,null,function*(){const s=new URLSearchParams({target_doctype:r});return a&&s.append("user",a),this.apiCall(`${this.endpoints.GET_PERMISSION_FILTERS}?${s}`)})}getAllowedValues(r,a){return J(this,null,function*(){const s=new URLSearchParams({allow_doctype:r});return a&&s.append("user",a),this.apiCall(`${this.endpoints.GET_ALLOWED_VALUES}?${s}`)})}checkDocumentAccess(r,a,s){return J(this,null,function*(){const n=new URLSearchParams({doctype:r,docname:a});return s&&n.append("user",s),this.apiCall(`${this.endpoints.CHECK_DOCUMENT_ACCESS}?${n}`)})}getConfiguredDoctypes(){return J(this,null,function*(){return this.apiCall(this.endpoints.GET_CONFIGURED_DOCTYPES)})}getUserDefaults(r){return J(this,null,function*(){const a=r?`?user=${encodeURIComponent(r)}`:"";return this.apiCall(`${this.endpoints.GET_USER_DEFAULTS}${a}`)})}isAuthenticated(){return!!localStorage.getItem("frappe_session_id")}getSessionId(){return localStorage.getItem("frappe_session_id")}setSessionId(r){localStorage.setItem("frappe_session_id",r)}}class Po extends Error{constructor(a,s,n){super(a);$s(this,"status");$s(this,"code");this.name="ApiError",this.status=s,this.code=n}}const At=new Dq,ib=Object.freeze(Object.defineProperty({__proto__:null,ApiError:Po,default:At},Symbol.toStringTag,{value:"Module"}));function Rq(e){return J(this,null,function*(){try{const r=yield At.getDoctypeRecords("Translation",{language:e},["source_text","translated_text","context"],1e4,0),a={};return r.records&&r.records.length>0&&r.records.forEach(s=>{const n=s.source_text,i=s.translated_text||n;if(s.context){const o=`${s.context}.${n}`;a[o]=i}else n.includes("."),a[n]=i}),a}catch(r){return console.error("Error fetching translations from Frappe:",r),{}}})}function Mq(e){const r={};return Object.keys(e).forEach(a=>{if(a.includes(".")){const s=a.split(".");let n=r;for(let i=0;i<s.length-1;i++){const o=s[i];n[o]||(n[o]={}),n=n[o]}n[s[s.length-1]]=e[a]}else r[a]=e[a]}),r}function aE(e){return J(this,null,function*(){const r=yield Rq(e);return Mq(r)})}Fn.use(w9).use(uH).init({resources:{en:{translation:iq},ar:{translation:Pq}},fallbackLng:"en",defaultNS:"translation",interpolation:{escapeValue:!1},detection:{order:["localStorage","navigator"],caches:["localStorage"]}});function Pf(){return J(this,null,function*(){try{if(!localStorage.getItem("user"))return;const r=yield aE("en");Object.keys(r).length>0&&Fn.addResourceBundle("en","translation",r,!0,!0);const a=yield aE("ar");Object.keys(a).length>0&&Fn.addResourceBundle("ar","translation",a,!0,!0),console.log("✓ Translations loaded from Frappe")}catch(e){console.warn("⚠ Could not load translations from Frappe, using static translations:",e)}})}Fn.on("initialized",()=>{Pf()});var sE="popstate";function Lq(e={}){function r(s,n){let{pathname:i,search:o,hash:l}=s.location;return yN("",{pathname:i,search:o,hash:l},n.state&&n.state.usr||null,n.state&&n.state.key||"default")}function a(s,n){return typeof n=="string"?n:Gf(n)}return Iq(r,a,null,e)}function Cs(e,r){if(e===!1||e===null||typeof e=="undefined")throw new Error(r)}function Bo(e,r){if(!e){typeof console!="undefined"&&console.warn(r);try{throw new Error(r)}catch(a){}}}function Fq(){return Math.random().toString(36).substring(2,10)}function nE(e,r){return{usr:e.state,key:e.key,idx:r}}function yN(e,r,a=null,s){return je(se({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof r=="string"?zp(r):r),{state:a,key:r&&r.key||s||Fq()})}function Gf({pathname:e="/",search:r="",hash:a=""}){return r&&r!=="?"&&(e+=r.charAt(0)==="?"?r:"?"+r),a&&a!=="#"&&(e+=a.charAt(0)==="#"?a:"#"+a),e}function zp(e){let r={};if(e){let a=e.indexOf("#");a>=0&&(r.hash=e.substring(a),e=e.substring(0,a));let s=e.indexOf("?");s>=0&&(r.search=e.substring(s),e=e.substring(0,s)),e&&(r.pathname=e)}return r}function Iq(e,r,a,s={}){let{window:n=document.defaultView,v5Compat:i=!1}=s,o=n.history,l="POP",c=null,u=h();u==null&&(u=0,o.replaceState(je(se({},o.state),{idx:u}),""));function h(){return(o.state||{idx:null}).idx}function f(){l="POP";let k=h(),S=k==null?null:k-u;u=k,c&&c({action:l,location:v.location,delta:S})}function y(k,S){l="PUSH";let N=yN(v.location,k,S);u=h()+1;let C=nE(N,u),O=v.createHref(N);try{o.pushState(C,"",O)}catch(T){if(T instanceof DOMException&&T.name==="DataCloneError")throw T;n.location.assign(O)}i&&c&&c({action:l,location:v.location,delta:1})}function b(k,S){l="REPLACE";let N=yN(v.location,k,S);u=h();let C=nE(N,u),O=v.createHref(N);o.replaceState(C,"",O),i&&c&&c({action:l,location:v.location,delta:0})}function w(k){return zq(k)}let v={get action(){return l},get location(){return e(n,o)},listen(k){if(c)throw new Error("A history only accepts one active listener");return n.addEventListener(sE,f),c=k,()=>{n.removeEventListener(sE,f),c=null}},createHref(k){return r(n,k)},createURL:w,encodeLocation(k){let S=w(k);return{pathname:S.pathname,search:S.search,hash:S.hash}},push:y,replace:b,go(k){return o.go(k)}};return v}function zq(e,r=!1){let a="http://localhost";typeof window!="undefined"&&(a=window.location.origin!=="null"?window.location.origin:window.location.href),Cs(a,"No window.location.(origin|href) available to create URL");let s=typeof e=="string"?e:Gf(e);return s=s.replace(/ $/,"%20"),!r&&s.startsWith("//")&&(s=a+s),new URL(s,a)}function j9(e,r,a="/"){return $q(e,r,a,!1)}function $q(e,r,a,s){let n=typeof r=="string"?zp(r):r,i=Gd(n.pathname||"/",a);if(i==null)return null;let o=_9(e);Uq(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let u=Xq(i);l=Jq(o[c],u,s)}return l}function _9(e,r=[],a=[],s="",n=!1){let i=(o,l,c=n,u)=>{let h={relativePath:u===void 0?o.path||"":u,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};if(h.relativePath.startsWith("/")){if(!h.relativePath.startsWith(s)&&c)return;Cs(h.relativePath.startsWith(s),`Absolute route path "${h.relativePath}" nested under path "${s}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),h.relativePath=h.relativePath.slice(s.length)}let f=Id([s,h.relativePath]),y=a.concat(h);o.children&&o.children.length>0&&(Cs(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),_9(o.children,r,y,f,c)),!(o.path==null&&!o.index)&&r.push({path:f,score:Kq(f,o.index),routesMeta:y})};return e.forEach((o,l)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))i(o,l);else for(let u of k9(o.path))i(o,l,!0,u)}),r}function k9(e){let r=e.split("/");if(r.length===0)return[];let[a,...s]=r,n=a.endsWith("?"),i=a.replace(/\?$/,"");if(s.length===0)return n?[i,""]:[i];let o=k9(s.join("/")),l=[];return l.push(...o.map(c=>c===""?i:[i,c].join("/"))),n&&l.push(...o),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function Uq(e){e.sort((r,a)=>r.score!==a.score?a.score-r.score:Yq(r.routesMeta.map(s=>s.childrenIndex),a.routesMeta.map(s=>s.childrenIndex)))}var Bq=/^:[\w-]+$/,Wq=3,Hq=2,qq=1,Vq=10,Gq=-2,iE=e=>e==="*";function Kq(e,r){let a=e.split("/"),s=a.length;return a.some(iE)&&(s+=Gq),r&&(s+=Hq),a.filter(n=>!iE(n)).reduce((n,i)=>n+(Bq.test(i)?Wq:i===""?qq:Vq),s)}function Yq(e,r){return e.length===r.length&&e.slice(0,-1).every((s,n)=>s===r[n])?e[e.length-1]-r[r.length-1]:0}function Jq(e,r,a=!1){let{routesMeta:s}=e,n={},i="/",o=[];for(let l=0;l<s.length;++l){let c=s[l],u=l===s.length-1,h=i==="/"?r:r.slice(i.length)||"/",f=wv({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},h),y=c.route;if(!f&&u&&a&&!s[s.length-1].route.index&&(f=wv({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},h)),!f)return null;Object.assign(n,f.params),o.push({params:n,pathname:Id([i,f.pathname]),pathnameBase:aV(Id([i,f.pathnameBase])),route:y}),f.pathnameBase!=="/"&&(i=Id([i,f.pathnameBase]))}return o}function wv(e,r){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[a,s]=Zq(e.path,e.caseSensitive,e.end),n=r.match(a);if(!n)return null;let i=n[0],o=i.replace(/(.)\/+$/,"$1"),l=n.slice(1);return{params:s.reduce((u,{paramName:h,isOptional:f},y)=>{if(h==="*"){let w=l[y]||"";o=i.slice(0,i.length-w.length).replace(/(.)\/+$/,"$1")}const b=l[y];return f&&!b?u[h]=void 0:u[h]=(b||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:o,pattern:e}}function Zq(e,r=!1,a=!0){Bo(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 s=[],n="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c)=>(s.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(s.push({paramName:"*"}),n+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?n+="\\/*$":e!==""&&e!=="/"&&(n+="(?:(?=\\/|$))"),[new RegExp(n,r?void 0:"i"),s]}function Xq(e){try{return e.split("/").map(r=>decodeURIComponent(r).replace(/\//g,"%2F")).join("/")}catch(r){return Bo(!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 (${r}).`),e}}function Gd(e,r){if(r==="/")return e;if(!e.toLowerCase().startsWith(r.toLowerCase()))return null;let a=r.endsWith("/")?r.length-1:r.length,s=e.charAt(a);return s&&s!=="/"?null:e.slice(a)||"/"}var Qq=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,eV=e=>Qq.test(e);function tV(e,r="/"){let{pathname:a,search:s="",hash:n=""}=typeof e=="string"?zp(e):e,i;if(a)if(eV(a))i=a;else{if(a.includes("//")){let o=a;a=a.replace(/\/\/+/g,"/"),Bo(!1,`Pathnames cannot have embedded double slashes - normalizing ${o} -> ${a}`)}a.startsWith("/")?i=oE(a.substring(1),"/"):i=oE(a,r)}else i=r;return{pathname:i,search:sV(s),hash:nV(n)}}function oE(e,r){let a=r.replace(/\/+$/,"").split("/");return e.split("/").forEach(n=>{n===".."?a.length>1&&a.pop():n!=="."&&a.push(n)}),a.length>1?a.join("/"):"/"}function X_(e,r,a,s){return`Cannot include a '${e}' character in a manually specified \`to.${r}\` field [${JSON.stringify(s)}]. 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 rV(e){return e.filter((r,a)=>a===0||r.route.path&&r.route.path.length>0)}function $4(e){let r=rV(e);return r.map((a,s)=>s===r.length-1?a.pathname:a.pathnameBase)}function U4(e,r,a,s=!1){let n;typeof e=="string"?n=zp(e):(n=se({},e),Cs(!n.pathname||!n.pathname.includes("?"),X_("?","pathname","search",n)),Cs(!n.pathname||!n.pathname.includes("#"),X_("#","pathname","hash",n)),Cs(!n.search||!n.search.includes("#"),X_("#","search","hash",n)));let i=e===""||n.pathname==="",o=i?"/":n.pathname,l;if(o==null)l=a;else{let f=r.length-1;if(!s&&o.startsWith("..")){let y=o.split("/");for(;y[0]==="..";)y.shift(),f-=1;n.pathname=y.join("/")}l=f>=0?r[f]:"/"}let c=tV(n,l),u=o&&o!=="/"&&o.endsWith("/"),h=(i||o===".")&&a.endsWith("/");return!c.pathname.endsWith("/")&&(u||h)&&(c.pathname+="/"),c}var Id=e=>e.join("/").replace(/\/\/+/g,"/"),aV=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),sV=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,nV=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function iV(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function oV(e){return e.map(r=>r.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var N9=["POST","PUT","PATCH","DELETE"];new Set(N9);var lV=["GET",...N9];new Set(lV);var $p=p.createContext(null);$p.displayName="DataRouter";var W1=p.createContext(null);W1.displayName="DataRouterState";p.createContext(!1);var S9=p.createContext({isTransitioning:!1});S9.displayName="ViewTransition";var cV=p.createContext(new Map);cV.displayName="Fetchers";var dV=p.createContext(null);dV.displayName="Await";var wl=p.createContext(null);wl.displayName="Navigation";var bx=p.createContext(null);bx.displayName="Location";var nc=p.createContext({outlet:null,matches:[],isDataRoute:!1});nc.displayName="Route";var B4=p.createContext(null);B4.displayName="RouteError";function uV(e,{relative:r}={}){Cs(Up(),"useHref() may be used only in the context of a <Router> component.");let{basename:a,navigator:s}=p.useContext(wl),{hash:n,pathname:i,search:o}=vx(e,{relative:r}),l=i;return a!=="/"&&(l=i==="/"?a:Id([a,i])),s.createHref({pathname:l,search:o,hash:n})}function Up(){return p.useContext(bx)!=null}function mo(){return Cs(Up(),"useLocation() may be used only in the context of a <Router> component."),p.useContext(bx).location}var C9="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function T9(e){p.useContext(wl).static||p.useLayoutEffect(e)}function hr(){let{isDataRoute:e}=p.useContext(nc);return e?kV():mV()}function mV(){Cs(Up(),"useNavigate() may be used only in the context of a <Router> component.");let e=p.useContext($p),{basename:r,navigator:a}=p.useContext(wl),{matches:s}=p.useContext(nc),{pathname:n}=mo(),i=JSON.stringify($4(s)),o=p.useRef(!1);return T9(()=>{o.current=!0}),p.useCallback((c,u={})=>{if(Bo(o.current,C9),!o.current)return;if(typeof c=="number"){a.go(c);return}let h=U4(c,JSON.parse(i),n,u.relative==="path");e==null&&r!=="/"&&(h.pathname=h.pathname==="/"?r:Id([r,h.pathname])),(u.replace?a.replace:a.push)(h,u.state,u)},[r,a,i,n,e])}p.createContext(null);function hs(){let{matches:e}=p.useContext(nc),r=e[e.length-1];return r?r.params:{}}function vx(e,{relative:r}={}){let{matches:a}=p.useContext(nc),{pathname:s}=mo(),n=JSON.stringify($4(a));return p.useMemo(()=>U4(e,JSON.parse(n),s,r==="path"),[e,n,s,r])}function hV(e,r){return E9(e,r)}function E9(e,r,a,s,n){var N;Cs(Up(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i}=p.useContext(wl),{matches:o}=p.useContext(nc),l=o[o.length-1],c=l?l.params:{},u=l?l.pathname:"/",h=l?l.pathnameBase:"/",f=l&&l.route;{let C=f&&f.path||"";A9(u,!f||C.endsWith("*")||C.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${C}">) 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="${C}"> to <Route path="${C==="/"?"*":`${C}/*`}">.`)}let y=mo(),b;if(r){let C=typeof r=="string"?zp(r):r;Cs(h==="/"||((N=C.pathname)==null?void 0:N.startsWith(h)),`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 "${h}" but pathname "${C.pathname}" was given in the \`location\` prop.`),b=C}else b=y;let w=b.pathname||"/",v=w;if(h!=="/"){let C=h.replace(/^\//,"").split("/");v="/"+w.replace(/^\//,"").split("/").slice(C.length).join("/")}let k=j9(e,{pathname:v});Bo(f||k!=null,`No routes matched location "${b.pathname}${b.search}${b.hash}" `),Bo(k==null||k[k.length-1].route.element!==void 0||k[k.length-1].route.Component!==void 0||k[k.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 S=yV(k&&k.map(C=>Object.assign({},C,{params:Object.assign({},c,C.params),pathname:Id([h,i.encodeLocation?i.encodeLocation(C.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathname]),pathnameBase:C.pathnameBase==="/"?h:Id([h,i.encodeLocation?i.encodeLocation(C.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathnameBase])})),o,a,s,n);return r&&S?p.createElement(bx.Provider,{value:{location:se({pathname:"/",search:"",hash:"",state:null,key:"default"},b),navigationType:"POP"}},S):S}function pV(){let e=_V(),r=iV(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),a=e instanceof Error?e.stack:null,s="rgba(200,200,200, 0.5)",n={padding:"0.5rem",backgroundColor:s},i={padding:"2px 4px",backgroundColor:s},o=null;return console.error("Error handled by React Router default ErrorBoundary:",e),o=p.createElement(p.Fragment,null,p.createElement("p",null,"💿 Hey developer 👋"),p.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",p.createElement("code",{style:i},"ErrorBoundary")," or"," ",p.createElement("code",{style:i},"errorElement")," prop on your route.")),p.createElement(p.Fragment,null,p.createElement("h2",null,"Unexpected Application Error!"),p.createElement("h3",{style:{fontStyle:"italic"}},r),a?p.createElement("pre",{style:n},a):null,o)}var gV=p.createElement(pV,null),fV=class extends p.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,r){return r.location!==e.location||r.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:r.error,location:r.location,revalidation:e.revalidation||r.revalidation}}componentDidCatch(e,r){this.props.onError?this.props.onError(e,r):console.error("React Router caught the following error during render",e)}render(){return this.state.error!==void 0?p.createElement(nc.Provider,{value:this.props.routeContext},p.createElement(B4.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function xV({routeContext:e,match:r,children:a}){let s=p.useContext($p);return s&&s.static&&s.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=r.route.id),p.createElement(nc.Provider,{value:e},a)}function yV(e,r=[],a=null,s=null,n=null){if(e==null){if(!a)return null;if(a.errors)e=a.matches;else if(r.length===0&&!a.initialized&&a.matches.length>0)e=a.matches;else return null}let i=e,o=a==null?void 0:a.errors;if(o!=null){let h=i.findIndex(f=>f.route.id&&(o==null?void 0:o[f.route.id])!==void 0);Cs(h>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),i=i.slice(0,Math.min(i.length,h+1))}let l=!1,c=-1;if(a)for(let h=0;h<i.length;h++){let f=i[h];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(c=h),f.route.id){let{loaderData:y,errors:b}=a,w=f.route.loader&&!y.hasOwnProperty(f.route.id)&&(!b||b[f.route.id]===void 0);if(f.route.lazy||w){l=!0,c>=0?i=i.slice(0,c+1):i=[i[0]];break}}}let u=a&&s?(h,f)=>{var y,b,w;s(h,{location:a.location,params:(w=(b=(y=a.matches)==null?void 0:y[0])==null?void 0:b.params)!=null?w:{},unstable_pattern:oV(a.matches),errorInfo:f})}:void 0;return i.reduceRight((h,f,y)=>{let b,w=!1,v=null,k=null;a&&(b=o&&f.route.id?o[f.route.id]:void 0,v=f.route.errorElement||gV,l&&(c<0&&y===0?(A9("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),w=!0,k=null):c===y&&(w=!0,k=f.route.hydrateFallbackElement||null)));let S=r.concat(i.slice(0,y+1)),N=()=>{let C;return b?C=v:w?C=k:f.route.Component?C=p.createElement(f.route.Component,null):f.route.element?C=f.route.element:C=h,p.createElement(xV,{match:f,routeContext:{outlet:h,matches:S,isDataRoute:a!=null},children:C})};return a&&(f.route.ErrorBoundary||f.route.errorElement||y===0)?p.createElement(fV,{location:a.location,revalidation:a.revalidation,component:v,error:b,children:N(),routeContext:{outlet:null,matches:S,isDataRoute:!0},onError:u}):N()},null)}function W4(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function bV(e){let r=p.useContext($p);return Cs(r,W4(e)),r}function vV(e){let r=p.useContext(W1);return Cs(r,W4(e)),r}function wV(e){let r=p.useContext(nc);return Cs(r,W4(e)),r}function H4(e){let r=wV(e),a=r.matches[r.matches.length-1];return Cs(a.route.id,`${e} can only be used on routes that contain a unique "id"`),a.route.id}function jV(){return H4("useRouteId")}function _V(){var s;let e=p.useContext(B4),r=vV("useRouteError"),a=H4("useRouteError");return e!==void 0?e:(s=r.errors)==null?void 0:s[a]}function kV(){let{router:e}=bV("useNavigate"),r=H4("useNavigate"),a=p.useRef(!1);return T9(()=>{a.current=!0}),p.useCallback((o,...l)=>J(null,[o,...l],function*(n,i={}){Bo(a.current,C9),a.current&&(typeof n=="number"?yield e.navigate(n):yield e.navigate(n,se({fromRouteId:r},i)))}),[e,r])}var lE={};function A9(e,r,a){!r&&!lE[e]&&(lE[e]=!0,Bo(!1,a))}p.memo(NV);function NV({routes:e,future:r,state:a,unstable_onError:s}){return E9(e,void 0,a,s,r)}function bf({to:e,replace:r,state:a,relative:s}){Cs(Up(),"<Navigate> may be used only in the context of a <Router> component.");let{static:n}=p.useContext(wl);Bo(!n,"<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:i}=p.useContext(nc),{pathname:o}=mo(),l=hr(),c=U4(e,$4(i),o,s==="path"),u=JSON.stringify(c);return p.useEffect(()=>{l(JSON.parse(u),{replace:r,state:a,relative:s})},[l,u,s,r,a]),null}function ur(e){Cs(!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 SV({basename:e="/",children:r=null,location:a,navigationType:s="POP",navigator:n,static:i=!1,unstable_useTransitions:o}){Cs(!Up(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=p.useMemo(()=>({basename:l,navigator:n,static:i,unstable_useTransitions:o,future:{}}),[l,n,i,o]);typeof a=="string"&&(a=zp(a));let{pathname:u="/",search:h="",hash:f="",state:y=null,key:b="default"}=a,w=p.useMemo(()=>{let v=Gd(u,l);return v==null?null:{location:{pathname:v,search:h,hash:f,state:y,key:b},navigationType:s}},[l,u,h,f,y,b,s]);return Bo(w!=null,`<Router basename="${l}"> is not able to match the URL "${u}${h}${f}" because it does not start with the basename, so the <Router> won't render anything.`),w==null?null:p.createElement(wl.Provider,{value:c},p.createElement(bx.Provider,{children:r,value:w}))}function CV({children:e,location:r}){return hV(bN(e),r)}function bN(e,r=[]){let a=[];return p.Children.forEach(e,(s,n)=>{if(!p.isValidElement(s))return;let i=[...r,n];if(s.type===p.Fragment){a.push.apply(a,bN(s.props.children,i));return}Cs(s.type===ur,`[${typeof s.type=="string"?s.type:s.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Cs(!s.props.index||!s.props.children,"An index route cannot have child routes.");let o={id:s.props.id||i.join("-"),caseSensitive:s.props.caseSensitive,element:s.props.element,Component:s.props.Component,index:s.props.index,path:s.props.path,middleware:s.props.middleware,loader:s.props.loader,action:s.props.action,hydrateFallbackElement:s.props.hydrateFallbackElement,HydrateFallback:s.props.HydrateFallback,errorElement:s.props.errorElement,ErrorBoundary:s.props.ErrorBoundary,hasErrorBoundary:s.props.hasErrorBoundary===!0||s.props.ErrorBoundary!=null||s.props.errorElement!=null,shouldRevalidate:s.props.shouldRevalidate,handle:s.props.handle,lazy:s.props.lazy};s.props.children&&(o.children=bN(s.props.children,i)),a.push(o)}),a}var rv="get",av="application/x-www-form-urlencoded";function H1(e){return typeof HTMLElement!="undefined"&&e instanceof HTMLElement}function TV(e){return H1(e)&&e.tagName.toLowerCase()==="button"}function EV(e){return H1(e)&&e.tagName.toLowerCase()==="form"}function AV(e){return H1(e)&&e.tagName.toLowerCase()==="input"}function OV(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function PV(e,r){return e.button===0&&(!r||r==="_self")&&!OV(e)}function vN(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((r,a)=>{let s=e[a];return r.concat(Array.isArray(s)?s.map(n=>[a,n]):[[a,s]])},[]))}function DV(e,r){let a=vN(e);return r&&r.forEach((s,n)=>{a.has(n)||r.getAll(n).forEach(i=>{a.append(n,i)})}),a}var ob=null;function RV(){if(ob===null)try{new FormData(document.createElement("form"),0),ob=!1}catch(e){ob=!0}return ob}var MV=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Q_(e){return e!=null&&!MV.has(e)?(Bo(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${av}"`),null):e}function LV(e,r){let a,s,n,i,o;if(EV(e)){let l=e.getAttribute("action");s=l?Gd(l,r):null,a=e.getAttribute("method")||rv,n=Q_(e.getAttribute("enctype"))||av,i=new FormData(e)}else if(TV(e)||AV(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=e.getAttribute("formaction")||l.getAttribute("action");if(s=c?Gd(c,r):null,a=e.getAttribute("formmethod")||l.getAttribute("method")||rv,n=Q_(e.getAttribute("formenctype"))||Q_(l.getAttribute("enctype"))||av,i=new FormData(l,e),!RV()){let{name:u,type:h,value:f}=e;if(h==="image"){let y=u?`${u}.`:"";i.append(`${y}x`,"0"),i.append(`${y}y`,"0")}else u&&i.append(u,f)}}else{if(H1(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');a=rv,s=null,n=av,o=e}return i&&n==="text/plain"&&(o=i,i=void 0),{action:s,method:a.toLowerCase(),encType:n,formData:i,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function q4(e,r){if(e===!1||e===null||typeof e=="undefined")throw new Error(r)}function FV(e,r,a){let s=typeof e=="string"?new URL(e,typeof window=="undefined"?"server://singlefetch/":window.location.origin):e;return s.pathname==="/"?s.pathname=`_root.${a}`:r&&Gd(s.pathname,r)==="/"?s.pathname=`${r.replace(/\/$/,"")}/_root.${a}`:s.pathname=`${s.pathname.replace(/\/$/,"")}.${a}`,s}function IV(e,r){return J(this,null,function*(){if(e.id in r)return r[e.id];try{let a=yield import(e.module);return r[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 zV(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"}function $V(e,r,a){return J(this,null,function*(){let s=yield Promise.all(e.map(n=>J(null,null,function*(){let i=r.routes[n.route.id];if(i){let o=yield IV(i,a);return o.links?o.links():[]}return[]})));return HV(s.flat(1).filter(zV).filter(n=>n.rel==="stylesheet"||n.rel==="preload").map(n=>n.rel==="stylesheet"?je(se({},n),{rel:"prefetch",as:"style"}):je(se({},n),{rel:"prefetch"})))})}function cE(e,r,a,s,n,i){let o=(c,u)=>a[u]?c.route.id!==a[u].route.id:!0,l=(c,u)=>{var h;return a[u].pathname!==c.pathname||((h=a[u].route.path)==null?void 0:h.endsWith("*"))&&a[u].params["*"]!==c.params["*"]};return i==="assets"?r.filter((c,u)=>o(c,u)||l(c,u)):i==="data"?r.filter((c,u)=>{var f;let h=s.routes[c.route.id];if(!h||!h.hasLoader)return!1;if(o(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let y=c.route.shouldRevalidate({currentUrl:new URL(n.pathname+n.search+n.hash,window.origin),currentParams:((f=a[0])==null?void 0:f.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof y=="boolean")return y}return!0}):[]}function UV(e,r,{includeHydrateFallback:a}={}){return BV(e.map(s=>{let n=r.routes[s.route.id];if(!n)return[];let i=[n.module];return n.clientActionModule&&(i=i.concat(n.clientActionModule)),n.clientLoaderModule&&(i=i.concat(n.clientLoaderModule)),a&&n.hydrateFallbackModule&&(i=i.concat(n.hydrateFallbackModule)),n.imports&&(i=i.concat(n.imports)),i}).flat(1))}function BV(e){return[...new Set(e)]}function WV(e){let r={},a=Object.keys(e).sort();for(let s of a)r[s]=e[s];return r}function HV(e,r){let a=new Set;return new Set(r),e.reduce((s,n)=>{let i=JSON.stringify(WV(n));return a.has(i)||(a.add(i),s.push({key:i,link:n})),s},[])}function O9(){let e=p.useContext($p);return q4(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function qV(){let e=p.useContext(W1);return q4(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var V4=p.createContext(void 0);V4.displayName="FrameworkContext";function P9(){let e=p.useContext(V4);return q4(e,"You must render this element inside a <HydratedRouter> element"),e}function VV(e,r){let a=p.useContext(V4),[s,n]=p.useState(!1),[i,o]=p.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:h,onTouchStart:f}=r,y=p.useRef(null);p.useEffect(()=>{if(e==="render"&&o(!0),e==="viewport"){let v=S=>{S.forEach(N=>{o(N.isIntersecting)})},k=new IntersectionObserver(v,{threshold:.5});return y.current&&k.observe(y.current),()=>{k.disconnect()}}},[e]),p.useEffect(()=>{if(s){let v=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(v)}}},[s]);let b=()=>{n(!0)},w=()=>{n(!1),o(!1)};return a?e!=="intent"?[i,y,{}]:[i,y,{onFocus:Yg(l,b),onBlur:Yg(c,w),onMouseEnter:Yg(u,b),onMouseLeave:Yg(h,w),onTouchStart:Yg(f,b)}]:[!1,y,{}]}function Yg(e,r){return a=>{e&&e(a),a.defaultPrevented||r(a)}}function GV(a){var s=a,{page:e}=s,r=li(s,["page"]);let{router:n}=O9(),i=p.useMemo(()=>j9(n.routes,e,n.basename),[n.routes,e,n.basename]);return i?p.createElement(YV,se({page:e,matches:i},r)):null}function KV(e){let{manifest:r,routeModules:a}=P9(),[s,n]=p.useState([]);return p.useEffect(()=>{let i=!1;return $V(e,r,a).then(o=>{i||n(o)}),()=>{i=!0}},[e,r,a]),s}function YV(s){var n=s,{page:e,matches:r}=n,a=li(n,["page","matches"]);let i=mo(),{manifest:o,routeModules:l}=P9(),{basename:c}=O9(),{loaderData:u,matches:h}=qV(),f=p.useMemo(()=>cE(e,r,h,o,i,"data"),[e,r,h,o,i]),y=p.useMemo(()=>cE(e,r,h,o,i,"assets"),[e,r,h,o,i]),b=p.useMemo(()=>{if(e===i.pathname+i.search+i.hash)return[];let k=new Set,S=!1;if(r.forEach(C=>{var T;let O=o.routes[C.route.id];!O||!O.hasLoader||(!f.some(P=>P.route.id===C.route.id)&&C.route.id in u&&((T=l[C.route.id])!=null&&T.shouldRevalidate)||O.hasClientLoader?S=!0:k.add(C.route.id))}),k.size===0)return[];let N=FV(e,c,"data");return S&&k.size>0&&N.searchParams.set("_routes",r.filter(C=>k.has(C.route.id)).map(C=>C.route.id).join(",")),[N.pathname+N.search]},[c,u,i,o,f,r,e,l]),w=p.useMemo(()=>UV(y,o),[y,o]),v=KV(y);return p.createElement(p.Fragment,null,b.map(k=>p.createElement("link",se({key:k,rel:"prefetch",as:"fetch",href:k},a))),w.map(k=>p.createElement("link",se({key:k,rel:"modulepreload",href:k},a))),v.map(({key:k,link:S})=>p.createElement("link",se({key:k,nonce:a.nonce},S))))}function JV(...e){return r=>{e.forEach(a=>{typeof a=="function"?a(r):a!=null&&(a.current=r)})}}var D9=typeof window!="undefined"&&typeof window.document!="undefined"&&typeof window.document.createElement!="undefined";try{D9&&(window.__reactRouterVersion="7.10.0")}catch(e){}function ZV({basename:e,children:r,unstable_useTransitions:a,window:s}){let n=p.useRef();n.current==null&&(n.current=Lq({window:s,v5Compat:!0}));let i=n.current,[o,l]=p.useState({action:i.action,location:i.location}),c=p.useCallback(u=>{a===!1?l(u):p.startTransition(()=>l(u))},[a]);return p.useLayoutEffect(()=>i.listen(c),[i,c]),p.createElement(SV,{basename:e,children:r,location:o.location,navigationType:o.action,navigator:i,unstable_useTransitions:a===!0})}var R9=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Df=p.forwardRef(function(w,b){var v=w,{onClick:r,discover:a="render",prefetch:s="none",relative:n,reloadDocument:i,replace:o,state:l,target:c,to:u,preventScrollReset:h,viewTransition:f}=v,y=li(v,["onClick","discover","prefetch","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"]);let{basename:k,unstable_useTransitions:S}=p.useContext(wl),N=typeof u=="string"&&R9.test(u),C,O=!1;if(typeof u=="string"&&N&&(C=u,D9))try{let ee=new URL(window.location.href),ne=u.startsWith("//")?new URL(ee.protocol+u):new URL(u),te=Gd(ne.pathname,k);ne.origin===ee.origin&&te!=null?u=te+ne.search+ne.hash:O=!0}catch(ee){Bo(!1,`<Link to="${u}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let T=uV(u,{relative:n}),[P,E,R]=VV(s,y),z=tG(u,{replace:o,state:l,target:c,preventScrollReset:h,relative:n,viewTransition:f,unstable_useTransitions:S});function G(ee){r&&r(ee),ee.defaultPrevented||z(ee)}let ae=p.createElement("a",je(se(se({},y),R),{href:C||T,onClick:O||i?r:G,ref:JV(b,E),target:c,"data-discover":!N&&a==="render"?"true":void 0}));return P&&!N?p.createElement(p.Fragment,null,ae,p.createElement(GV,{page:T})):ae});Df.displayName="Link";var XV=p.forwardRef(function(f,h){var y=f,{"aria-current":r="page",caseSensitive:a=!1,className:s="",end:n=!1,style:i,to:o,viewTransition:l,children:c}=y,u=li(y,["aria-current","caseSensitive","className","end","style","to","viewTransition","children"]);let b=vx(o,{relative:u.relative}),w=mo(),v=p.useContext(W1),{navigator:k,basename:S}=p.useContext(wl),N=v!=null&&iG(b)&&l===!0,C=k.encodeLocation?k.encodeLocation(b).pathname:b.pathname,O=w.pathname,T=v&&v.navigation&&v.navigation.location?v.navigation.location.pathname:null;a||(O=O.toLowerCase(),T=T?T.toLowerCase():null,C=C.toLowerCase()),T&&S&&(T=Gd(T,S)||T);const P=C!=="/"&&C.endsWith("/")?C.length-1:C.length;let E=O===C||!n&&O.startsWith(C)&&O.charAt(P)==="/",R=T!=null&&(T===C||!n&&T.startsWith(C)&&T.charAt(C.length)==="/"),z={isActive:E,isPending:R,isTransitioning:N},G=E?r:void 0,ae;typeof s=="function"?ae=s(z):ae=[s,E?"active":null,R?"pending":null,N?"transitioning":null].filter(Boolean).join(" ");let ee=typeof i=="function"?i(z):i;return p.createElement(Df,je(se({},u),{"aria-current":G,className:ae,ref:h,style:ee,to:o,viewTransition:l}),typeof c=="function"?c(z):c)});XV.displayName="NavLink";var QV=p.forwardRef((w,b)=>{var v=w,{discover:e="render",fetcherKey:r,navigate:a,reloadDocument:s,replace:n,state:i,method:o=rv,action:l,onSubmit:c,relative:u,preventScrollReset:h,viewTransition:f}=v,y=li(v,["discover","fetcherKey","navigate","reloadDocument","replace","state","method","action","onSubmit","relative","preventScrollReset","viewTransition"]);let{unstable_useTransitions:k}=p.useContext(wl),S=sG(),N=nG(l,{relative:u}),C=o.toLowerCase()==="get"?"get":"post",O=typeof l=="string"&&R9.test(l),T=P=>{if(c&&c(P),P.defaultPrevented)return;P.preventDefault();let E=P.nativeEvent.submitter,R=(E==null?void 0:E.getAttribute("formmethod"))||o,z=()=>S(E||P.currentTarget,{fetcherKey:r,method:R,navigate:a,replace:n,state:i,relative:u,preventScrollReset:h,viewTransition:f});k&&a!==!1?p.startTransition(()=>z()):z()};return p.createElement("form",je(se({ref:b,method:C,action:N,onSubmit:s?c:T},y),{"data-discover":!O&&e==="render"?"true":void 0}))});QV.displayName="Form";function eG(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function M9(e){let r=p.useContext($p);return Cs(r,eG(e)),r}function tG(e,{target:r,replace:a,state:s,preventScrollReset:n,relative:i,viewTransition:o,unstable_useTransitions:l}={}){let c=hr(),u=mo(),h=vx(e,{relative:i});return p.useCallback(f=>{if(PV(f,r)){f.preventDefault();let y=a!==void 0?a:Gf(u)===Gf(h),b=()=>c(e,{replace:y,state:s,preventScrollReset:n,relative:i,viewTransition:o});l?p.startTransition(()=>b()):b()}},[u,c,h,a,s,r,e,n,i,o,l])}function _a(e){Bo(typeof URLSearchParams!="undefined","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let r=p.useRef(vN(e)),a=p.useRef(!1),s=mo(),n=p.useMemo(()=>DV(s.search,a.current?null:r.current),[s.search]),i=hr(),o=p.useCallback((l,c)=>{const u=vN(typeof l=="function"?l(new URLSearchParams(n)):l);a.current=!0,i("?"+u,c)},[i,n]);return[n,o]}var rG=0,aG=()=>`__${String(++rG)}__`;function sG(){let{router:e}=M9("useSubmit"),{basename:r}=p.useContext(wl),a=jV(),s=e.fetch,n=e.navigate;return p.useCallback((l,...c)=>J(null,[l,...c],function*(i,o={}){let{action:u,method:h,encType:f,formData:y,body:b}=LV(i,r);if(o.navigate===!1){let w=o.fetcherKey||aG();yield s(w,a,o.action||u,{preventScrollReset:o.preventScrollReset,formData:y,body:b,formMethod:o.method||h,formEncType:o.encType||f,flushSync:o.flushSync})}else yield n(o.action||u,{preventScrollReset:o.preventScrollReset,formData:y,body:b,formMethod:o.method||h,formEncType:o.encType||f,replace:o.replace,state:o.state,fromRouteId:a,flushSync:o.flushSync,viewTransition:o.viewTransition})}),[s,n,r,a])}function nG(e,{relative:r}={}){let{basename:a}=p.useContext(wl),s=p.useContext(nc);Cs(s,"useFormAction must be used inside a RouteContext");let[n]=s.matches.slice(-1),i=se({},vx(e||".",{relative:r})),o=mo();if(e==null){i.search=o.search;let l=new URLSearchParams(i.search),c=l.getAll("index");if(c.some(h=>h==="")){l.delete("index"),c.filter(f=>f).forEach(f=>l.append("index",f));let h=l.toString();i.search=h?`?${h}`:""}}return(!e||e===".")&&n.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),a!=="/"&&(i.pathname=i.pathname==="/"?a:Id([a,i.pathname])),Gf(i)}function iG(e,{relative:r}={}){let a=p.useContext(S9);Cs(a!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:s}=M9("useViewTransitionState"),n=vx(e,{relative:r});if(!a.isTransitioning)return!1;let i=Gd(a.currentLocation.pathname,s)||a.currentLocation.pathname,o=Gd(a.nextLocation.pathname,s)||a.nextLocation.pathname;return wv(n.pathname,o)!=null||wv(n.pathname,i)!=null}var wx=u9();function L9(){return J(this,null,function*(){var e,r;try{const a=yield fetch("/api/method/frappe.auth.get_logged_user",{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json"},credentials:"include"});if(!a.ok)return{ok:!1};const s=yield a.json(),n=s==null?void 0:s.message;if(!n||n==="Guest")return{ok:!1};let i=n,o="";try{const c=yield fetch(`/api/resource/User/${encodeURIComponent(n)}?fields=["full_name","user_image"]`,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json"},credentials:"include"});if(c.ok){const u=yield c.json();(e=u.data)!=null&&e.full_name&&(i=u.data.full_name),(r=u.data)!=null&&r.user_image&&(o=u.data.user_image)}}catch(c){}const l={email:n,full_name:i,user_image:o,roles:[]};return localStorage.setItem("user",JSON.stringify(l)),{ok:!0}}catch(a){return{ok:!1}}})}const oG="modulepreload",lG=function(e){return"/assets/asm_ui_app/asm_app/"+e},dE={},Wu=function(r,a,s){let n=Promise.resolve();if(a&&a.length>0){let u=function(h){return Promise.all(h.map(f=>Promise.resolve(f).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};var o=u;document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));n=u(a.map(h=>{if(h=lG(h),h in dE)return;dE[h]=!0;const f=h.endsWith(".css"),y=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${y}`))return;const b=document.createElement("link");if(b.rel=f?"stylesheet":oG,f||(b.as="script"),b.crossOrigin="",b.href=h,c&&b.setAttribute("nonce",c),document.head.appendChild(b),f)return new Promise((w,v)=>{b.addEventListener("load",w),b.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${h}`)))})}))}function i(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return n.then(l=>{for(const c of l||[])c.status==="rejected"&&i(c.reason);return r().catch(i)})},ek="asm_show_after_password_reset",lb="asm_login_tmp_id",cG=()=>{const[e,r]=p.useState({email:"",password:""}),[a,s]=p.useState(!1),[n,i]=p.useState(!0),[o,l]=p.useState(null),[c,u]=p.useState(!1),[h,f]=p.useState(""),[y,b]=p.useState(!1),[w,v]=p.useState(null),[k,S]=p.useState(!1),[N,C]=p.useState(!1),[O,T]=p.useState(!1),[P,E]=p.useState("credentials"),[R,z]=p.useState(null),[G,ae]=p.useState(""),[ee,ne]=p.useState(null),te=hr(),Y=mo(),{t:q}=sr(),H=p.useRef(!1),U=p.useRef(null),re=p.useCallback(()=>{var ge;(ge=U.current)==null||ge.abort(),U.current=null,u(!1),b(!1),v(null),S(!1)},[]),X=p.useCallback(()=>{u(!0),f(e.email),v(null),S(!1),b(!1),l(null)},[e.email]);p.useEffect(()=>{if(!c)return;const ge=be=>{be.key==="Escape"&&re()};return document.addEventListener("keydown",ge),()=>document.removeEventListener("keydown",ge)},[c,re]),p.useEffect(()=>{let ge=!1;return J(null,null,function*(){if(typeof sessionStorage!="undefined"&&sessionStorage.getItem(ek)==="1"&&(sessionStorage.removeItem(ek),ge||T(!0)),new URLSearchParams(typeof window!="undefined"?window.location.search:"").get("manual_login")==="1"&&!H.current){H.current=!0,ge||C(!0),localStorage.removeItem("user"),localStorage.removeItem("frappe_session_id");const ye="";let Z=typeof window!="undefined"?window.csrf_token:void 0;if(!Z)try{const we=yield fetch(`${ye}/api/method/frappe.sessions.get_csrf_token`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(we.ok){const pe=yield we.json();typeof pe.message=="string"&&(Z=pe.message)}}catch(we){}const M={Accept:"application/json"};Z&&(M["X-Frappe-CSRF-Token"]=Z);try{yield fetch(`${ye}/api/method/logout`,{method:"POST",credentials:"include",headers:M})}catch(we){}if(typeof sessionStorage!="undefined"&&sessionStorage.setItem(ek,"1"),ge)return;C(!1),te("/login",{replace:!0});return}if(localStorage.getItem("user")){ge||(i(!1),te("/dashboard",{replace:!0}));return}const K=yield L9();if(!ge){if(K.ok){try{yield Pf()}catch(ye){console.warn("Could not load translations after session bootstrap:",ye)}ge||te("/dashboard",{replace:!0})}ge||i(!1)}}),()=>{ge=!0}},[te,Y.pathname,Y.search]);const V="/assets/asm_ui_app/asm_app/",I="?v=1774269853",B=ge=>{const{name:be,value:K}=ge.target;r(ye=>je(se({},ye),{[be]:K})),l(null)},Q=p.useCallback(ge=>J(null,null,function*(){const be=(yield Wu(()=>J(null,null,function*(){const{default:ye}=yield Promise.resolve().then(()=>ib);return{default:ye}}),[])).default,K=je(se({},ge),{email:ge.email||e.email});localStorage.setItem("user",JSON.stringify(K)),ge.sid&&be.setSessionId(ge.sid),sessionStorage.removeItem(lb);try{yield Pf()}catch(ye){console.warn("Could not load translations after login:",ye)}te("/dashboard")}),[e.email,te]),ie=ge=>J(null,null,function*(){ge.preventDefault(),s(!0),l(null);try{const K=yield(yield Wu(()=>J(null,null,function*(){const{default:ye}=yield Promise.resolve().then(()=>ib);return{default:ye}}),void 0)).default.login(e);if(K.status==="two_factor_required"){sessionStorage.setItem(lb,K.tmp_id),z(K.tmp_id),ne(K.verification),E("otp"),ae("");return}yield Q(K.user)}catch(be){console.error("Login error:",be);const K=be instanceof Error?be.message:q("login.loginFailed");l(K)}finally{s(!1)}}),me=ge=>J(null,null,function*(){ge.preventDefault();const be=R||sessionStorage.getItem(lb);if(!be){l(q("login.twoFactorSessionExpired")),E("credentials");return}if(!G.trim()){l(q("login.twoFactorCodeRequired"));return}s(!0),l(null);try{const ye=yield(yield Wu(()=>J(null,null,function*(){const{default:Z}=yield Promise.resolve().then(()=>ib);return{default:Z}}),void 0)).default.verifyLoginOtp(be,G);ye.status==="logged_in"&&(yield Q(ye.user))}catch(K){const ye=K instanceof Error?K.message:q("login.twoFactorInvalid");l(ye)}finally{s(!1)}}),he=()=>{sessionStorage.removeItem(lb),E("credentials"),z(null),ne(null),ae(""),l(null)},de=()=>J(null,null,function*(){const ge={full_name:"Demo User",email:"demo@seeraarabia.com",user_image:"",roles:["System Manager","Administrator"]};localStorage.setItem("user",JSON.stringify(ge));try{yield Pf()}catch(be){console.warn("Could not load translations after demo login:",be)}te("/dashboard")}),xe=ge=>J(null,null,function*(){var Z;ge.preventDefault();const be=h.trim();if(!be){v(q("login.forgotPasswordUserRequired"));return}(Z=U.current)==null||Z.abort();const K=new AbortController;U.current=K,b(!0),v(null),S(!1);const ye=yield Wu(()=>Promise.resolve().then(()=>ib),void 0);try{yield ye.default.requestPasswordReset(be,K.signal),S(!0)}catch(M){M instanceof Error&&M.name==="AbortError"?v(q("login.forgotPasswordTimeout")):M instanceof ye.ApiError?M.code==="USER_NOT_FOUND"?v(q("login.forgotPasswordNotFound")):M.code==="RESET_NOT_ALLOWED"?v(q("login.forgotPasswordCannotReset")):M.code==="FORBIDDEN"?v(q("login.forgotPasswordFailed")):M.code==="EMPTY_EMAIL"?v(q("login.forgotPasswordUserRequired")):v(q("login.forgotPasswordFailed")):v(q("login.forgotPasswordFailed"))}finally{U.current===K&&(U.current=null),b(!1)}});return n||N?t.jsx("div",{className:"flex min-h-screen items-center justify-center bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"flex flex-col items-center gap-3 text-gray-600 dark:text-gray-400",children:[t.jsxs("svg",{className:"h-10 w-10 animate-spin text-indigo-600",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","aria-hidden":!0,children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.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"})]}),t.jsx("span",{className:"text-sm",children:q(N?"login.finishingSignOut":"common.loading")})]})}):t.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900 py-12 px-4 sm:px-6 lg:px-8",children:[t.jsxs("div",{className:"max-w-md w-full space-y-8",children:[t.jsxs("div",{children:[t.jsx("div",{className:"flex justify-center mb-6",children:t.jsxs("div",{className:"w-32 h-32 flex items-center justify-center bg-white dark:bg-gray-800 rounded-2xl shadow-2xl p-4",children:[t.jsx("img",{src:`${V}${V.endsWith("/")?"":"/"}seera-logo.png${I}`,alt:"Seera Arabia",className:"w-full h-full object-contain",onError:ge=>{const be=ge.currentTarget.parentElement;be&&be.classList.add("bg-gradient-to-br","from-indigo-600","to-purple-600"),ge.currentTarget.style.display="none";const K=ge.currentTarget.nextElementSibling;K&&K.classList.remove("hidden")}}),t.jsxs("svg",{className:"w-20 h-20 hidden",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"white",fillOpacity:"0.9"}),t.jsx("path",{d:"M2 17L12 22L22 17V12L12 17L2 12V17Z",fill:"white",fillOpacity:"0.7"}),t.jsx("path",{d:"M12 12V17",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]})]})}),t.jsx("h2",{className:"text-center text-3xl font-semibold text-gray-900 dark:text-white",children:q("login.title")}),t.jsx("p",{className:"mt-2 text-center text-sm font-medium text-indigo-600 dark:text-indigo-400",children:q("login.subtitle")}),t.jsx("p",{className:"mt-1 text-center text-xs text-gray-600 dark:text-gray-400",children:q(P==="otp"?"login.twoFactorTitle":"login.signIn")})]}),t.jsxs("div",{className:"mt-8 space-y-6",children:[O&&P==="credentials"&&t.jsx("div",{className:"rounded-md bg-green-50 p-4 dark:bg-green-900/20",children:t.jsx("p",{className:"text-sm text-green-800 dark:text-green-300",children:q("login.afterPasswordResetSignIn")})}),P==="otp"?t.jsxs("form",{className:"space-y-6",onSubmit:me,children:[t.jsxs("div",{className:"rounded-md bg-indigo-50 p-4 text-sm text-indigo-900 dark:bg-indigo-900/20 dark:text-indigo-200",children:[(ee==null?void 0:ee.method)==="Email"&&ee.prompt?t.jsx("p",{children:ee.prompt}):(ee==null?void 0:ee.method)==="OTP App"&&ee.setup?t.jsx("p",{children:q("login.twoFactorOtpAppEnter")}):(ee==null?void 0:ee.method)==="OTP App"&&!ee.setup?t.jsx("p",{children:q("login.twoFactorOtpAppSetupIncomplete")}):t.jsx("p",{children:q("login.twoFactorOtpAppEnter")}),(ee==null?void 0:ee.method)==="Email"&&t.jsx("p",{className:"mt-2 text-xs text-indigo-800 dark:text-indigo-300",children:q("login.twoFactorEmailQrHint")})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"otp",className:"sr-only",children:q("login.twoFactorCodeLabel")}),t.jsx("input",{id:"otp",name:"otp",type:"text",inputMode:"numeric",autoComplete:"one-time-code",maxLength:6,required:!0,autoFocus:!0,className:"relative block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-center text-lg tracking-widest text-gray-900 placeholder-gray-500 focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 dark:border-gray-600 dark:bg-gray-800 dark:text-white",placeholder:q("login.twoFactorCodePlaceholder"),value:G,onChange:ge=>{ae(ge.target.value.replace(/\D/g,"").slice(0,6)),l(null)}})]}),o&&t.jsx("div",{className:"rounded-md bg-red-50 p-4 dark:bg-red-900/20",children:t.jsx("div",{className:"text-sm text-red-700 dark:text-red-400",children:o})}),t.jsx("button",{type:"submit",disabled:a,className:"group relative flex w-full justify-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",children:q(a?"common.loading":"login.twoFactorVerify")}),t.jsx("button",{type:"button",onClick:he,className:"w-full text-center text-sm font-medium text-indigo-600 hover:text-indigo-500 dark:text-indigo-400",children:q("login.twoFactorBackToLogin")})]}):t.jsxs("form",{className:"space-y-6",onSubmit:ie,children:[t.jsxs("div",{className:"rounded-md shadow-sm -space-y-px",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"email",className:"sr-only",children:q("common.email")}),t.jsx("input",{id:"email",name:"email",type:"email",required:!0,className:"appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 dark:border-gray-600 placeholder-gray-500 dark:placeholder-gray-400 text-gray-900 dark:text-white bg-white dark:bg-gray-800 rounded-t-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm",placeholder:q("login.emailPlaceholder"),value:e.email,onChange:B})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"password",className:"sr-only",children:q("common.password")}),t.jsx("input",{id:"password",name:"password",type:"password",required:!0,className:"appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 dark:border-gray-600 placeholder-gray-500 dark:placeholder-gray-400 text-gray-900 dark:text-white bg-white dark:bg-gray-800 rounded-b-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm",placeholder:q("login.passwordPlaceholder"),value:e.password,onChange:B})]})]}),o&&t.jsx("div",{className:"rounded-md bg-red-50 dark:bg-red-900/20 p-4",children:t.jsx("div",{className:"text-sm text-red-700 dark:text-red-400",children:o})}),t.jsx("button",{type:"submit",disabled:a,className:"group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed",children:a?t.jsxs("div",{className:"flex items-center",children:[t.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:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.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"})]}),q("common.loading")]}):q("common.login")})]}),P==="credentials"&&t.jsx("div",{className:"text-center",children:t.jsx("button",{type:"button",onClick:X,className:"text-sm font-medium text-indigo-600 dark:text-indigo-400 hover:text-indigo-500 dark:hover:text-indigo-300 focus:outline-none focus:underline",children:q("login.forgotPassword")})}),t.jsxs("div",{className:"hidden space-y-3","aria-hidden":"true",children:[t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute inset-0 flex items-center",children:t.jsx("div",{className:"w-full border-t border-gray-300 dark:border-gray-600"})}),t.jsx("div",{className:"relative flex justify-center text-sm",children:t.jsx("span",{className:"px-2 bg-gray-50 dark:bg-gray-900 text-gray-500 dark:text-gray-400",children:q("login.or")})})]}),t.jsxs("button",{type:"button",onClick:de,tabIndex:-1,className:"w-full flex justify-center py-2 px-4 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500",children:["🚀 ",q("login.demoLogin")]})]})]})]}),c&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:re,role:"presentation",children:t.jsxs("div",{className:"relative w-full max-w-md rounded-lg border border-gray-200 bg-white p-5 shadow-xl dark:border-gray-700 dark:bg-gray-800",onClick:ge=>ge.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"forgot-password-title",children:[t.jsx("button",{type:"button",onClick:re,className:"absolute right-3 top-3 rounded p-1 text-gray-500 hover:bg-gray-100 hover:text-gray-800 dark:hover:bg-gray-700 dark:hover:text-gray-200","aria-label":q("login.forgotPasswordClose"),children:"×"}),t.jsx("h3",{id:"forgot-password-title",className:"pr-8 text-lg font-semibold text-gray-900 dark:text-white",children:q("login.forgotPasswordTitle")}),t.jsx("p",{className:"mt-2 text-xs leading-relaxed text-gray-600 dark:text-gray-400",children:q("login.forgotPasswordHint")}),t.jsxs("form",{className:"mt-4 space-y-3",onSubmit:xe,children:[t.jsx("input",{type:"text",name:"reset-user",autoComplete:"username",value:h,onChange:ge=>{f(ge.target.value),v(null),S(!1)},className:"relative block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 placeholder-gray-500 focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 dark:border-gray-600 dark:bg-gray-800 dark:text-white dark:placeholder-gray-400",placeholder:q("login.forgotPasswordUserPlaceholder")}),w&&t.jsx("div",{className:"rounded-md bg-red-50 p-3 text-sm text-red-700 dark:bg-red-900/20 dark:text-red-400",children:w}),k&&t.jsx("div",{className:"rounded-md bg-green-50 p-3 text-sm text-green-800 dark:bg-green-900/20 dark:text-green-300",children:q("login.forgotPasswordSentSuccess")}),t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:justify-end sm:gap-3",children:[t.jsx("button",{type:"button",onClick:re,className:"inline-flex justify-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",children:q("login.forgotPasswordClose")}),t.jsx("button",{type:"submit",disabled:y,className:"inline-flex justify-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",children:q(y?"common.loading":"login.forgotPasswordSubmit")})]})]})]})})]})};function q1(e,r=[]){const[a,s]=p.useState(null),[n,i]=p.useState(!0),[o,l]=p.useState(null),c=p.useCallback(()=>J(null,null,function*(){try{i(!0),l(null);const h=yield e();s(h)}catch(h){h instanceof Po?l(h.message):l(h instanceof Error?h.message:"Unknown error")}finally{i(!1)}}),r);p.useEffect(()=>{c()},[c]);const u=p.useCallback(()=>{c()},[c]);return{data:a,loading:n,error:o,refetch:u}}function dG(e){return q1(()=>At.getUserDetails(e),[e])}function uG(){return q1(()=>At.getDashboardStats())}function F9(){return q1(()=>At.getNumberCards())}function rp(e,r){return q1(()=>At.getDashboardChartData(e,r),[e,JSON.stringify(r||{})])}function mG(){const[e,r]=p.useState(At.isAuthenticated());return{isAuthenticated:e,login:n=>J(null,null,function*(){try{const i=yield At.login(n);if(i&&i.message)return i.message.sid&&At.setSessionId(i.message.sid),r(!0),i;throw new Error("Login failed")}catch(i){throw r(!1),i}}),logout:()=>J(null,null,function*(){try{yield At.logout()}finally{At.setSessionId(""),r(!1)}})}}const hG=()=>{const[e,r]=p.useState({}),[a,s]=p.useState(!1),n=()=>J(null,null,function*(){s(!0);const i={};try{console.log("Testing basic connectivity...");try{const o=yield fetch("/api/method/frappe.desk.doctype.event.event.get_events",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({start:new Date().toISOString().split("T")[0],end:new Date(Date.now()+2592e6).toISOString().split("T")[0]}),signal:AbortSignal.timeout(1e4)});o.ok?i.csrfToken="✅ Basic Connectivity: SUCCESS":i.csrfToken=`❌ Basic Connectivity: HTTP ${o.status}`}catch(o){i.csrfToken=`❌ Basic Connectivity: ${o instanceof Error?o.message:"Unknown error"}`}console.log("Testing Frappe system endpoint...");try{yield At.apiCall("/api/method/frappe.auth.get_logged_user",{method:"GET",headers:{"Content-Type":"application/json"}}),i.dashboardStats="✅ Frappe System API: SUCCESS"}catch(o){const l=o instanceof Error?o.message:"Unknown";l.includes("403")||l.includes("401")?i.dashboardStats="✅ Frappe System API: SUCCESS (auth required)":i.dashboardStats=`❌ Frappe System API: ${l}`}console.log("Testing Custom User Details...");try{const o=yield At.getUserDetails();i.userDetails=o?"✅ Custom API: SUCCESS":"❌ Custom API: Failed"}catch(o){i.userDetails=`❌ Custom API (Expected): ${o instanceof Error?o.message:"Unknown"}`}console.log("Testing Custom Dashboard Stats...");try{const o=yield At.getDashboardStats();i.doctypeRecords=o?"✅ Custom Stats: SUCCESS":"❌ Custom Stats: Failed"}catch(o){i.doctypeRecords=`❌ Custom Stats (Expected): ${o instanceof Error?o.message:"Unknown"}`}}catch(o){console.error("API Test Error:",o),o instanceof Po?i.error=`${o.message} (Status: ${o.status})`:i.error=o instanceof Error?o.message:"Unknown error"}r(i),s(!1)});return t.jsxs("div",{style:{padding:"20px",border:"1px solid #ccc",margin:"20px"},children:[t.jsx("h2",{children:"API Connection Test"}),t.jsx("button",{onClick:n,disabled:a,style:{padding:"10px 20px",marginBottom:"20px",backgroundColor:a?"#ccc":"#007bff",color:"white",border:"none",borderRadius:"4px",cursor:a?"not-allowed":"pointer"},children:a?"Testing...":"Test API Connection"}),t.jsxs("div",{children:[t.jsx("h3",{children:"Test Results:"}),t.jsxs("div",{style:{background:"#f5f5f5",padding:"15px",borderRadius:"5px",fontSize:"14px"},children:[t.jsxs("div",{children:[t.jsx("strong",{children:"1. Basic Connectivity:"})," ",e.csrfToken||"Not tested"]}),t.jsxs("div",{children:[t.jsx("strong",{children:"2. Frappe System API:"})," ",e.dashboardStats||"Not tested"]}),t.jsxs("div",{children:[t.jsx("strong",{children:"3. Custom User API:"})," ",e.userDetails||"Not tested"]}),t.jsxs("div",{children:[t.jsx("strong",{children:"4. Custom Stats API:"})," ",e.doctypeRecords||"Not tested"]}),e.error&&t.jsxs("div",{style:{color:"red"},children:[t.jsx("strong",{children:"Error:"})," ",e.error]})]}),t.jsxs("div",{style:{marginTop:"10px",fontSize:"12px",color:"#666"},children:[t.jsx("p",{children:t.jsx("strong",{children:"Expected Results:"})}),t.jsxs("ul",{children:[t.jsx("li",{children:"✅ Basic Connectivity should succeed (tests proxy connection)"}),t.jsx("li",{children:"✅ Frappe System API should succeed (tests Frappe API)"}),t.jsx("li",{children:"❌ Custom APIs will fail until you deploy the API file to your server"})]}),t.jsxs("p",{children:[t.jsx("strong",{children:"If Basic Connectivity fails:"})," Check your Frappe server is running and accessible"]})]})]})]})},tk=e=>Number.isFinite(e)?Math.max(0,e):0;function pG({type:e,labels:r,datasets:a,height:s=220}){if(!(r!=null&&r.length)||!(a!=null&&a.length))return t.jsx("div",{className:"text-sm text-gray-500",children:"No data"});if(e.toLowerCase()==="pie"){const u=a[0].values.map(tk),h=u.reduce((k,S)=>k+S,0)||1,f=Math.min(100,s/2-10),y=f+10,b=f+10;let w=0;const v=a[0].values.map((k,S)=>a[0].color||uE(S));return t.jsx("svg",{width:y*2,height:b*2,viewBox:`0 0 ${y*2} ${b*2}`,children:u.map((k,S)=>{const N=w/h*2*Math.PI;w+=k;const C=w/h*2*Math.PI,O=C-N>Math.PI?1:0,T=y+f*Math.cos(N),P=b+f*Math.sin(N),E=y+f*Math.cos(C),R=b+f*Math.sin(C),z=`M ${y} ${b} L ${T} ${P} A ${f} ${f} 0 ${O} 1 ${E} ${R} Z`;return t.jsx("path",{d:z,fill:v[S]},S)})})}const n=a,i=Math.max(...n.flatMap(u=>u.values.map(tk)),1),o=Math.max(r.length*60,300),l=s-40,c=Math.max(20,(o-40)/r.length-10);return t.jsxs("svg",{width:o,height:s,viewBox:`0 0 ${o} ${s}`,children:[t.jsx("line",{x1:30,y1:10,x2:30,y2:l,stroke:"#e5e7eb"}),t.jsx("line",{x1:30,y1:l,x2:o-10,y2:l,stroke:"#e5e7eb"}),r.map((u,h)=>{const f=40+h*(c+10);let y=0;return t.jsxs("g",{children:[n.map((b,w)=>{const k=tk(b.values[h]||0)/i*(l-20),S=l-k-y,N=b.color||uE(w);return y+=k,t.jsx("rect",{x:f,y:S,width:c,height:k,fill:N,rx:2},w)}),t.jsx("text",{x:f+c/2,y:s-5,textAnchor:"middle",fontSize:"10",fill:"#6b7280",children:gG(u,8)})]},h)})]})}function uE(e){const r=["#4F46E5","#10B981","#F59E0B","#EF4444","#6366F1","#22C55E","#E11D48"];return r[e%r.length]}function gG(e,r){return e.length>r?e.slice(0,r-1)+"…":e}const fG=({chartName:e,filters:r})=>{const{data:a,loading:s,error:n}=rp(e,r);return t.jsxs("div",{className:"bg-white rounded-lg shadow p-4 overflow-auto",children:[t.jsx("div",{className:"flex items-center justify-between mb-3",children:t.jsx("h4",{className:"text-sm font-semibold text-gray-800",children:e})}),s&&t.jsx("div",{className:"text-sm text-gray-500",children:"Loading…"}),n&&t.jsx("div",{className:"text-sm text-red-600",children:n}),!s&&!n&&a&&t.jsx(pG,{type:a.type,labels:a.labels,datasets:a.datasets})]})},xG=()=>{var b,w,v,k;const[e,r]=p.useState(null),[a,s]=p.useState([]),n=hr(),{logout:i}=mG(),{loading:o,error:l}=uG(),{data:c}=F9(),{data:u,loading:h,error:f}=dG();p.useEffect(()=>{const S=localStorage.getItem("user");S?r(JSON.parse(S)):u&&r(u);const N=[{name:"USER001",full_name:"John Doe",email:"john.doe@seeraarabia.com",creation:new Date().toISOString(),modified:new Date().toISOString(),modified_by:"system",owner:"system",docstatus:0},{name:"USER002",full_name:"Jane Smith",email:"jane.smith@seeraarabia.com",creation:new Date(Date.now()-864e5).toISOString(),modified:new Date().toISOString(),modified_by:"system",owner:"system",docstatus:0},{name:"USER003",full_name:"Ahmed Al-Rashid",email:"ahmed.alrashid@seeraarabia.com",creation:new Date(Date.now()-1728e5).toISOString(),modified:new Date().toISOString(),modified_by:"system",owner:"system",docstatus:0},{name:"USER004",full_name:"Sarah Johnson",email:"sarah.johnson@seeraarabia.com",creation:new Date(Date.now()-2592e5).toISOString(),modified:new Date().toISOString(),modified_by:"system",owner:"system",docstatus:0},{name:"USER005",full_name:"Mohammed Hassan",email:"mohammed.hassan@seeraarabia.com",creation:new Date(Date.now()-3456e5).toISOString(),modified:new Date().toISOString(),modified_by:"system",owner:"system",docstatus:0}];s(N)},[u]);const y=()=>J(null,null,function*(){try{yield i(),localStorage.removeItem("user"),n("/login")}catch(S){console.error("Logout error:",S),localStorage.removeItem("user"),n("/login")}});return o||h?t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900",children:t.jsx("div",{className:"animate-spin rounded-full h-32 w-32 border-b-2 border-indigo-600"})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900",children:[t.jsx("header",{className:"bg-white dark:bg-gray-800 shadow",children:t.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"flex justify-between items-center py-6",children:[t.jsx("div",{className:"flex items-center",children:t.jsx("h1",{className:"text-3xl font-bold text-gray-900 dark:text-white",children:"Dashboard"})}),t.jsxs("div",{className:"flex items-center space-x-4",children:[t.jsxs("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:["Welcome, ",(e==null?void 0:e.full_name)||"User"]}),t.jsx("button",{onClick:y,className:"bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-md text-sm font-medium",children:"Logout"})]})]})})}),t.jsxs("main",{className:"max-w-7xl mx-auto py-6 sm:px-6 lg:px-8",children:[(l||f)&&t.jsx("div",{className:"mb-6 rounded-md bg-red-50 dark:bg-red-900/20 p-4",children:t.jsx("div",{className:"text-sm text-red-700 dark:text-red-400",children:l||f||"Failed to load dashboard data"})}),t.jsxs("div",{className:"grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-4 mb-8",children:[t.jsx("div",{className:"bg-white dark:bg-gray-800 overflow-hidden shadow rounded-lg",children:t.jsx("div",{className:"p-5",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"w-8 h-8 bg-indigo-500 rounded-md flex items-center justify-center",children:t.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})})}),t.jsx("div",{className:"ml-5 w-0 flex-1",children:t.jsxs("dl",{children:[t.jsx("dt",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 truncate",children:"Total Assets"}),t.jsx("dd",{className:"text-lg font-medium text-gray-900 dark:text-white",children:(b=c==null?void 0:c.total_assets)!=null?b:"-"})]})})]})})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 overflow-hidden shadow rounded-lg",children:t.jsx("div",{className:"p-5",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"w-8 h-8 bg-green-500 rounded-md flex items-center justify-center",children:t.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})})}),t.jsx("div",{className:"ml-5 w-0 flex-1",children:t.jsxs("dl",{children:[t.jsx("dt",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 truncate",children:"Open Work Orders"}),t.jsx("dd",{className:"text-lg font-medium text-gray-900 dark:text-white",children:(w=c==null?void 0:c.work_orders_open)!=null?w:"-"})]})})]})})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 overflow-hidden shadow rounded-lg",children:t.jsx("div",{className:"p-5",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"w-8 h-8 bg-yellow-500 rounded-md flex items-center justify-center",children:t.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:t.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"})})})}),t.jsx("div",{className:"ml-5 w-0 flex-1",children:t.jsxs("dl",{children:[t.jsx("dt",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 truncate",children:"In Progress"}),t.jsx("dd",{className:"text-lg font-medium text-gray-900 dark:text-white",children:(v=c==null?void 0:c.work_orders_in_progress)!=null?v:"-"})]})})]})})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 overflow-hidden shadow rounded-lg",children:t.jsx("div",{className:"p-5",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"w-8 h-8 bg-purple-500 rounded-md flex items-center justify-center",children:t.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{fillRule:"evenodd",d:"M3 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z",clipRule:"evenodd"})})})}),t.jsx("div",{className:"ml-5 w-0 flex-1",children:t.jsxs("dl",{children:[t.jsx("dt",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 truncate",children:"Completed Work Orders"}),t.jsx("dd",{className:"text-lg font-medium text-gray-900 dark:text-white",children:(k=c==null?void 0:c.work_orders_completed)!=null?k:"-"})]})})]})})})]}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-6 mb-8",children:["Up & Down Time Chart","Work Order Status Chart","Maintenance - Asset wise Count","Asset Maintenance Assignees Status Count","Asset Maintenance Frequency Chart","PPM Status","PPM Template Counts","Repair Cost"].map(S=>t.jsx(fG,{chartName:S},S))}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow overflow-hidden sm:rounded-md",children:[t.jsxs("div",{className:"px-4 py-5 sm:px-6",children:[t.jsx("h3",{className:"text-lg leading-6 font-medium text-gray-900 dark:text-white",children:"Recent Records"}),t.jsx("p",{className:"mt-1 max-w-2xl text-sm text-gray-500 dark:text-gray-400",children:"Latest entries from your Frappe backend"})]}),t.jsx("ul",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:a.map(S=>{var N;return t.jsx("li",{children:t.jsxs("div",{className:"px-4 py-4 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0 h-10 w-10",children:t.jsx("div",{className:"h-10 w-10 rounded-full bg-indigo-100 flex items-center justify-center",children:t.jsx("span",{className:"text-sm font-medium text-indigo-600",children:((N=S.full_name)==null?void 0:N.charAt(0))||S.name.charAt(0)})})}),t.jsxs("div",{className:"ml-4",children:[t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:S.full_name||S.name}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:S.email||"No email"})]})]}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(S.creation).toLocaleDateString()})]})},S.name)})})]}),t.jsxs("div",{className:"mt-8",children:[t.jsx("h3",{className:"text-lg leading-6 font-medium text-gray-900 dark:text-white mb-4",children:"Quick Actions"}),t.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[t.jsx("button",{onClick:()=>n("/users"),className:"bg-white dark:bg-gray-800 p-6 rounded-lg shadow hover:shadow-md transition-shadow",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"w-8 h-8 bg-blue-500 rounded-md flex items-center justify-center",children:t.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{d:"M9 6a3 3 0 11-6 0 3 3 0 016 0zM17 6a3 3 0 11-6 0 3 3 0 016 0zM12.93 17c.046-.327.07-.66.07-1a6.97 6.97 0 00-1.5-4.33A5 5 0 0119 16v1h-6.07zM6 11a5 5 0 015 5v1H1v-1a5 5 0 015-5z"})})})}),t.jsxs("div",{className:"ml-4",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"View Users"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Manage user accounts"})]})]})}),t.jsx("button",{onClick:()=>n("/settings"),className:"bg-white dark:bg-gray-800 p-6 rounded-lg shadow hover:shadow-md transition-shadow",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"w-8 h-8 bg-gray-500 rounded-md flex items-center justify-center",children:t.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{fillRule:"evenodd",d:"M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z",clipRule:"evenodd"})})})}),t.jsxs("div",{className:"ml-4",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Settings"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Configure your preferences"})]})]})}),t.jsx("button",{onClick:()=>n("/events"),className:"bg-white dark:bg-gray-800 p-6 rounded-lg shadow hover:shadow-md transition-shadow",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"w-8 h-8 bg-purple-500 rounded-md flex items-center justify-center",children:t.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})})}),t.jsxs("div",{className:"ml-4",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Events"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"View calendar events"})]})]})}),t.jsx("button",{onClick:()=>n("/reports"),className:"bg-white dark:bg-gray-800 p-6 rounded-lg shadow hover:shadow-md transition-shadow",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"w-8 h-8 bg-green-500 rounded-md flex items-center justify-center",children:t.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{fillRule:"evenodd",d:"M3 3a1 1 0 000 2v8a2 2 0 002 2h2.586l-1.293 1.293a1 1 0 101.414 1.414L10 15.414l2.293 2.293a1 1 0 001.414-1.414L12.414 15H15a2 2 0 002-2V5a1 1 0 100-2H3zm11.707 4.707a1 1 0 00-1.414-1.414L10 9.586 8.707 8.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})})}),t.jsxs("div",{className:"ml-4",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Reports"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"View analytics and reports"})]})]})})]})]}),t.jsx("div",{className:"mt-8",children:t.jsx(hG,{})})]})]})},yG=["*"];class bG{getWorkOrders(r,a,s=20,n=0,i,o){return J(this,null,function*(){try{const{toFrappeFilterArray:l}=yield Wu(()=>J(null,null,function*(){const{toFrappeFilterArray:k}=yield Promise.resolve().then(()=>CS);return{toFrappeFilterArray:k}}),void 0),c=l(r||{}),u={doctype:"Work_Order",filters:c.length>0?c:{},fields:a||yG,limit_start:n,limit_page_length:s,order_by:i||"creation desc"};o&&o.length>0&&(u.or_filters=o),console.log("[workOrderService] getWorkOrders request:",u);const h=yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);const y=(yield h.json()).message||[];let b=0;const w={doctype:"Work_Order",filters:c.length>0?c:{},fields:["name"],limit_page_length:0};o&&o.length>0&&(w.or_filters=o);const v=yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});return v.ok&&(b=((yield v.json()).message||[]).length),{work_orders:y,total_count:b,limit:s,offset:n,has_more:n+s<b}}catch(l){throw console.error("[workOrderService] getWorkOrders error:",l),l}})}getWorkOrderDetails(r){return J(this,null,function*(){const a=`${Ar.ENDPOINTS.GET_WORK_ORDER_DETAILS}?work_order_name=${encodeURIComponent(r)}`;return At.apiCall(a)})}createWorkOrder(r){return J(this,null,function*(){return At.apiCall(Ar.ENDPOINTS.CREATE_WORK_ORDER,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({work_order_data:r})})})}updateWorkOrder(r,a){return J(this,null,function*(){return At.apiCall(Ar.ENDPOINTS.UPDATE_WORK_ORDER,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({work_order_name:r,work_order_data:a})})})}deleteWorkOrder(r){return J(this,null,function*(){return At.apiCall(Ar.ENDPOINTS.DELETE_WORK_ORDER,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({work_order_name:r})})})}updateWorkOrderStatus(r,a,s){return J(this,null,function*(){return At.apiCall(Ar.ENDPOINTS.UPDATE_WORK_ORDER_STATUS,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({work_order_name:r,repair_status:a,workflow_state:s})})})}getWorkOrderFilters(){return J(this,null,function*(){return At.apiCall(Ar.ENDPOINTS.GET_WORK_ORDER_FILTERS)})}getWorkOrderStats(){return J(this,null,function*(){return At.apiCall(Ar.ENDPOINTS.GET_WORK_ORDER_STATS)})}searchWorkOrders(r,a=10){return J(this,null,function*(){const s=`${Ar.ENDPOINTS.SEARCH_WORK_ORDERS}?search_term=${encodeURIComponent(r)}&limit=${a}`;return At.apiCall(s)})}submitWorkOrder(r){return J(this,null,function*(){return At.apiCall("/api/method/frappe.client.submit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doc:{doctype:"Asset Repair",name:r}})})})}cancelWorkOrder(r){return J(this,null,function*(){return At.apiCall("/api/method/frappe.client.cancel",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doc:{doctype:"Asset Repair",name:r}})})})}getWorkOrdersByAsset(r,a=50){return J(this,null,function*(){const s={asset:r};return(yield this.getWorkOrders(s,void 0,a,0,"creation desc")).work_orders})}getOpenWorkOrders(r=50){return J(this,null,function*(){const a={repair_status:["not in",["Completed","Cancelled"]]};return(yield this.getWorkOrders(a,void 0,r,0,"creation desc")).work_orders})}getWorkOrdersByPriority(r,a=50){return J(this,null,function*(){const s={custom_priority_:r};return(yield this.getWorkOrders(s,void 0,a,0,"creation desc")).work_orders})}}const Uu=new bG,vG=(e,r)=>{const a=se({},e||{});for(const[s,n]of Object.entries(r))if(!a[s])a[s]=n;else if(Array.isArray(n)&&n[0]==="in"){const i=n[1],o=a[s];if(typeof o=="string")i.includes(o)||(a[s]=["in",[]]);else if(Array.isArray(o)&&o[0]==="in"){const c=o[1].filter(u=>i.includes(u));a[s]=["in",c]}else a[s]=n}return a};function I9(e,r=20,a=0,s,n={},i){const[o,l]=p.useState([]),[c,u]=p.useState(0),[h,f]=p.useState(!1),[y,b]=p.useState(!0),[w,v]=p.useState(null),[k,S]=p.useState(0),N=p.useRef(!1),C=JSON.stringify(e),O=JSON.stringify(n),T=JSON.stringify(i);p.useEffect(()=>{if(N.current&&w)return;let E=!1;return N.current=!0,J(null,null,function*(){try{b(!0);const z=vG(e,n);console.log("[useWorkOrders] User filters:",e),console.log("[useWorkOrders] Permission filters:",n),console.log("[useWorkOrders] OR filters:",i),console.log("[useWorkOrders] Merged filters:",z);const G=yield Uu.getWorkOrders(z,void 0,r,a,s,i);E||(l(G.work_orders),u(G.total_count),f(G.has_more),v(null))}catch(z){if(!E){const G=z instanceof Error?z.message:"Failed to fetch work orders";G.includes("417")||G.includes("Expectation Failed")||G.includes("has no attribute")?v("API endpoint not deployed or misconfigured. Please check FIX_417_ERROR.md for solutions."):v(G),l([]),u(0),f(!1)}}finally{E||b(!1)}}),()=>{E=!0}},[C,O,T,r,a,s,k]);const P=p.useCallback(()=>{N.current=!1,S(E=>E+1)},[]);return{workOrders:o,totalCount:c,hasMore:h,loading:y,error:w,refetch:P}}function z9(e){const[r,a]=p.useState(null),[s,n]=p.useState(!0),[i,o]=p.useState(null),l=p.useCallback(()=>J(null,null,function*(){if(!e){a(null),n(!1);return}try{n(!0),o(null);const u=yield Uu.getWorkOrderDetails(e);a(u)}catch(u){o(u instanceof Error?u.message:"Failed to fetch work order details")}finally{n(!1)}}),[e]);p.useEffect(()=>{l()},[l]);const c=p.useCallback(()=>{l()},[l]);return{workOrder:r,loading:s,error:i,refetch:c}}function G4(){const[e,r]=p.useState(!1),[a,s]=p.useState(null);return{createWorkOrder:u=>J(null,null,function*(){try{r(!0),s(null),console.log("[useWorkOrderMutations] Creating work order with data:",u);const h=yield Uu.createWorkOrder(u);if(console.log("[useWorkOrderMutations] Create work order response:",h),h.success)return h.work_order;{const f=h.error||"Failed to create work order";throw new Error(f)}}catch(h){console.error("[useWorkOrderMutations] Create work order error:",h);const f=h instanceof Error?h.message:"Failed to create work order";throw s(f),h}finally{r(!1)}}),updateWorkOrder:(u,h)=>J(null,null,function*(){try{r(!0),s(null),console.log("[useWorkOrderMutations] Updating work order:",u,"with data:",h);const f=yield Uu.updateWorkOrder(u,h);if(console.log("[useWorkOrderMutations] Update work order response:",f),f.success)return f.work_order;{const y=f.error||"Failed to update work order";throw new Error(y)}}catch(f){console.error("[useWorkOrderMutations] Update work order error:",f);const y=f instanceof Error?f.message:"Failed to update work order";throw s(y),f}finally{r(!1)}}),deleteWorkOrder:u=>J(null,null,function*(){try{r(!0),s(null);const h=yield Uu.deleteWorkOrder(u);if(!h.success)throw new Error("Failed to delete work order");return h}catch(h){const f=h instanceof Error?h.message:"Failed to delete work order";throw s(f),h}finally{r(!1)}}),submitWorkOrder:u=>J(null,null,function*(){try{r(!0),s(null),console.log("[useWorkOrderMutations] Submitting work order:",u);const h=yield Uu.submitWorkOrder(u);return console.log("[useWorkOrderMutations] Submit work order response:",h),h}catch(h){console.error("[useWorkOrderMutations] Submit work order error:",h);const f=h instanceof Error?h.message:"Failed to submit work order";throw s(f),h}finally{r(!1)}}),updateStatus:(u,h,f)=>J(null,null,function*(){try{r(!0),s(null);const y=yield Uu.updateWorkOrderStatus(u,h,f);if(y.success)return y.work_order;throw new Error("Failed to update work order status")}catch(y){const b=y instanceof Error?y.message:"Failed to update status";throw s(b),y}finally{r(!1)}}),loading:e,error:a}}const $l=At;class wG{getMaintenanceLogs(r,a,s=20,n=0,i){return J(this,null,function*(){const o=new URLSearchParams;r&&o.append("filters",JSON.stringify(r)),a&&a.length>0&&o.append("fields",JSON.stringify(a)),o.append("limit",s.toString()),o.append("offset",n.toString()),i&&o.append("order_by",i),o.append("include_child_tables","true");const l=`${Ar.ENDPOINTS.GET_ASSET_MAINTENANCE_LOGS}?${o.toString()}`;return $l.apiCall(l)})}getMaintenanceLogDetails(r){return J(this,null,function*(){const a=new URLSearchParams;a.append("log_name",r),a.append("include_child_tables","true");const s=`${Ar.ENDPOINTS.GET_ASSET_MAINTENANCE_LOG_DETAILS}?${a.toString()}`;return $l.apiCall(s)})}createMaintenanceLog(r){return J(this,null,function*(){const a=this.prepareLogData(r);return $l.apiCall(Ar.ENDPOINTS.CREATE_ASSET_MAINTENANCE_LOG,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_data:a})})})}updateMaintenanceLog(r,a){return J(this,null,function*(){const s=this.prepareLogData(a);return $l.apiCall(Ar.ENDPOINTS.UPDATE_ASSET_MAINTENANCE_LOG,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_name:r,log_data:s})})})}deleteMaintenanceLog(r){return J(this,null,function*(){return $l.apiCall(Ar.ENDPOINTS.DELETE_ASSET_MAINTENANCE_LOG,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_name:r})})})}updateMaintenanceStatus(r,a,s){return J(this,null,function*(){return $l.apiCall(Ar.ENDPOINTS.UPDATE_MAINTENANCE_STATUS,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_name:r,maintenance_status:a,workflow_state:s})})})}getMaintenanceLogsByAsset(r,a,s=20,n=0){return J(this,null,function*(){const i=new URLSearchParams;i.append("asset_name",r),a&&i.append("filters",JSON.stringify(a)),i.append("limit",s.toString()),i.append("offset",n.toString()),i.append("include_child_tables","true");const o=`${Ar.ENDPOINTS.GET_MAINTENANCE_LOGS_BY_ASSET}?${i.toString()}`;return $l.apiCall(o)})}getOverdueMaintenanceLogs(r,a=20,s=0){return J(this,null,function*(){const n=new URLSearchParams;r&&n.append("filters",JSON.stringify(r)),n.append("limit",a.toString()),n.append("offset",s.toString()),n.append("include_child_tables","true");const i=`${Ar.ENDPOINTS.GET_OVERDUE_MAINTENANCE_LOGS}?${n.toString()}`;return $l.apiCall(i)})}addPPMTableRow(r,a){return J(this,null,function*(){return $l.apiCall(Ar.ENDPOINTS.ADD_PPM_TABLE_ROW||"/api/method/asset_lite.api.asset_maintenance_api.add_ppm_table_row",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_name:r,row_data:this.cleanPPMRow(a)})})})}removePPMTableRow(r,a){return J(this,null,function*(){return $l.apiCall(Ar.ENDPOINTS.REMOVE_PPM_TABLE_ROW||"/api/method/asset_lite.api.asset_maintenance_api.remove_ppm_table_row",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_name:r,row_name:a})})})}updatePPMTableRow(r,a,s){return J(this,null,function*(){return $l.apiCall(Ar.ENDPOINTS.UPDATE_PPM_TABLE_ROW||"/api/method/asset_lite.api.asset_maintenance_api.update_ppm_table_row",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_name:r,row_name:a,row_data:this.cleanPPMRow(s)})})})}cleanPPMRow(r){return je(se({},r.name&&!r.name.startsWith("new-")?{name:r.name}:{}),{maintenance_name:r.maintenance_name||"",working:typeof r.working=="boolean"?r.working?1:0:r.working||0,defect_found:typeof r.defect_found=="boolean"?r.defect_found?1:0:r.defect_found||0,not_working:typeof r.not_working=="boolean"?r.not_working?1:0:r.not_working||0})}prepareLogData(r){const a={},s=["asset_name","custom_asset_type","item_code","item_name","custom_asset_names","custom_hospital_name","task","task_name","maintenance_type","periodicity","custom_template","maintenance_status","due_date","completion_date","assign_to_name","has_certificate","custom_early_completion","custom_early_completion_reason","custom_accepted_by_moh","custom_accepted_by_moh_","custom_pm_overdue_reason","description","custom_table"];for(const n of s)r[n]!==void 0&&r[n]!==null&&r[n]!==""&&(a[n]=r[n]);return typeof a.has_certificate=="boolean"&&(a.has_certificate=a.has_certificate?1:0),typeof a.custom_accepted_by_moh=="boolean"&&(a.custom_accepted_by_moh=a.custom_accepted_by_moh?1:0),typeof a.custom_accepted_by_moh_=="boolean"&&(a.custom_accepted_by_moh_=a.custom_accepted_by_moh_?1:0),a.custom_table&&Array.isArray(a.custom_table)&&(a.custom_table=a.custom_table.map(n=>this.cleanPPMRow(n))),a}}const op=new wG;function V1(e,r=20,a=0,s){const[n,i]=p.useState([]),[o,l]=p.useState(0),[c,u]=p.useState(!1),[h,f]=p.useState(!0),[y,b]=p.useState(null),[w,v]=p.useState(0),k=p.useRef(!1),S=JSON.stringify(e);p.useEffect(()=>{if(k.current&&y)return;let C=!1;return k.current=!0,J(null,null,function*(){try{f(!0);const T=yield op.getMaintenanceLogs(e,void 0,r,a,s);C||(i(T.asset_maintenance_logs),l(T.total_count),u(T.has_more),b(null))}catch(T){if(!C){const P=T instanceof Error?T.message:"Failed to fetch maintenance logs";P.includes("417")||P.includes("Expectation Failed")||P.includes("has no attribute")?b("API endpoint not deployed. Please deploy asset_maintenance_api.py to your Frappe server."):b(P),i([]),l(0),u(!1)}}finally{C||f(!1)}}),()=>{C=!0}},[S,r,a,s,w]);const N=p.useCallback(()=>{k.current=!1,v(C=>C+1)},[]);return{logs:n,totalCount:o,hasMore:c,loading:h,error:y,refetch:N}}function jG(e){const[r,a]=p.useState(null),[s,n]=p.useState(!0),[i,o]=p.useState(null),l=p.useCallback(()=>J(null,null,function*(){if(!e){a(null),n(!1);return}try{n(!0),o(null);const u=yield op.getMaintenanceLogDetails(e);a(u)}catch(u){o(u instanceof Error?u.message:"Failed to fetch maintenance log details")}finally{n(!1)}}),[e]);p.useEffect(()=>{l()},[l]);const c=p.useCallback(()=>{l()},[l]);return{log:r,loading:s,error:i,refetch:c}}function $9(){const[e,r]=p.useState(!1),[a,s]=p.useState(null);return{createLog:c=>J(null,null,function*(){try{r(!0),s(null),console.log("[useMaintenanceMutations] Creating maintenance log:",c);const u=yield op.createMaintenanceLog(c);if(console.log("[useMaintenanceMutations] Create response:",u),u.success)return u.asset_maintenance_log;{const h=u.error||"Failed to create maintenance log";throw new Error(h)}}catch(u){console.error("[useMaintenanceMutations] Create error:",u);const h=u instanceof Error?u.message:"Failed to create maintenance log";throw s(h),u}finally{r(!1)}}),updateLog:(c,u)=>J(null,null,function*(){try{r(!0),s(null),console.log("[useMaintenanceMutations] Updating maintenance log:",c,u);const h=yield op.updateMaintenanceLog(c,u);if(console.log("[useMaintenanceMutations] Update response:",h),h.success)return h.asset_maintenance_log;{const f=h.error||"Failed to update maintenance log";throw new Error(f)}}catch(h){console.error("[useMaintenanceMutations] Update error:",h);const f=h instanceof Error?h.message:"Failed to update maintenance log";throw s(f),h}finally{r(!1)}}),deleteLog:c=>J(null,null,function*(){try{r(!0),s(null);const u=yield op.deleteMaintenanceLog(c);if(!u.success)throw new Error("Failed to delete maintenance log");return u}catch(u){const h=u instanceof Error?u.message:"Failed to delete maintenance log";throw s(h),u}finally{r(!1)}}),updateStatus:(c,u,h)=>J(null,null,function*(){try{r(!0),s(null);const f=yield op.updateMaintenanceStatus(c,u,h);if(f.success)return f.asset_maintenance_log;throw new Error("Failed to update maintenance status")}catch(f){const y=f instanceof Error?f.message:"Failed to update status";throw s(y),f}finally{r(!1)}}),loading:e,error:a}}class _G{getAssets(r,a,s=20,n=0,i){return J(this,null,function*(){const o=new URLSearchParams;if(r&&Object.keys(r).length>0){const{toFrappeFilterArray:c}=yield Wu(()=>J(null,null,function*(){const{toFrappeFilterArray:h}=yield Promise.resolve().then(()=>CS);return{toFrappeFilterArray:h}}),void 0),u=c(r);u.length>0&&o.append("filters",JSON.stringify(u))}a&&a.length>0&&o.append("fields",JSON.stringify(a)),o.append("limit",s.toString()),o.append("offset",n.toString()),i&&o.append("order_by",i);const l=`${Ar.ENDPOINTS.GET_ASSETS}?${o.toString()}`;return At.apiCall(l)})}getAssetDetails(r){return J(this,null,function*(){const a=`${Ar.ENDPOINTS.GET_ASSET_DETAILS}?asset_name=${encodeURIComponent(r)}`;return At.apiCall(a)})}createAsset(r){return J(this,null,function*(){return At.apiCall(Ar.ENDPOINTS.CREATE_ASSET,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({asset_data:r})})})}updateAsset(r,a){return J(this,null,function*(){return At.apiCall(Ar.ENDPOINTS.UPDATE_ASSET,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({asset_name:r,asset_data:a})})})}deleteAsset(r){return J(this,null,function*(){return At.apiCall(Ar.ENDPOINTS.DELETE_ASSET,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({asset_name:r})})})}getAssetFilters(){return J(this,null,function*(){return At.apiCall(Ar.ENDPOINTS.GET_ASSET_FILTERS)})}getAssetStats(){return J(this,null,function*(){return At.apiCall(Ar.ENDPOINTS.GET_ASSET_STATS)})}searchAssets(r,a=10){return J(this,null,function*(){const s=`${Ar.ENDPOINTS.SEARCH_ASSETS}?search_term=${encodeURIComponent(r)}&limit=${a}`;return At.apiCall(s)})}getExistingSerialNumbers(r){return J(this,null,function*(){const a=Array.from(new Set(r.map(i=>i.trim()).filter(Boolean)));if(a.length===0)return new Set;const s=new Set,n=500;for(let i=0;i<a.length;i+=n){const o=a.slice(i,i+n),l=new URLSearchParams;l.append("fields",JSON.stringify(["custom_serial_number"])),l.append("filters",JSON.stringify([["custom_serial_number","in",o]])),l.append("limit_page_length","0");const c=yield fetch(`${Ar.BASE_URL}/api/resource/Asset?${l.toString()}`,{method:"GET",headers:se({Accept:"application/json","Content-Type":"application/json"},typeof window!="undefined"&&window.csrf_token?{"X-Frappe-CSRF-Token":window.csrf_token}:{}),credentials:"include"});if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);const u=yield c.json();for(const h of u.data||[]){const f=(h.custom_serial_number||"").trim();f&&s.add(f)}}return s})}submitAsset(r){return J(this,null,function*(){return At.apiCall(Ar.ENDPOINTS.SUBMIT_ASSET||"/api/method/asset_lite.api.asset_api.submit_asset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({asset_name:r})})})}}const Q0=new _G,kG=(e,r)=>{const a=se({},e||{});for(const[s,n]of Object.entries(r))if(!a[s])a[s]=n;else if(Array.isArray(n)&&n[0]==="in"){const i=n[1],o=a[s];if(typeof o=="string")i.includes(o)||(a[s]=["in",[]]);else if(Array.isArray(o)&&o[0]==="in"){const c=o[1].filter(u=>i.includes(u));a[s]=["in",c]}else a[s]=n}return a};function U9(e,r=20,a=0,s,n={}){const[i,o]=p.useState([]),[l,c]=p.useState(0),[u,h]=p.useState(!1),[f,y]=p.useState(!0),[b,w]=p.useState(null),[v,k]=p.useState(0),S=p.useRef(!1),N=JSON.stringify(e),C=JSON.stringify(n);p.useEffect(()=>{if(S.current&&b)return;let T=!1;return S.current=!0,J(null,null,function*(){try{y(!0);const E=kG(e,n);console.log("[useAssets] User filters:",e),console.log("[useAssets] Permission filters:",n),console.log("[useAssets] Merged filters:",E);const R=yield Q0.getAssets(E,void 0,r,a,s);T||(o(R.assets),c(R.total_count),h(R.has_more),w(null))}catch(E){if(!T){const R=E instanceof Error?E.message:"Failed to fetch assets";R.includes("417")||R.includes("Expectation Failed")||R.includes("has no attribute")?w("API endpoint not deployed or misconfigured. Please check FIX_417_ERROR.md for solutions."):w(R),o([]),c(0),h(!1)}}finally{T||y(!1)}}),()=>{T=!0}},[N,C,r,a,s,v]);const O=p.useCallback(()=>{S.current=!1,k(T=>T+1)},[]);return{assets:i,totalCount:l,hasMore:u,loading:f,error:b,refetch:O}}function NG(e){const[r,a]=p.useState(null),[s,n]=p.useState(!0),[i,o]=p.useState(null),l=p.useCallback(()=>J(null,null,function*(){if(!e){a(null),n(!1);return}try{n(!0),o(null);const u=yield Q0.getAssetDetails(e);a(u)}catch(u){o(u instanceof Error?u.message:"Failed to fetch asset details")}finally{n(!1)}}),[e]);p.useEffect(()=>{l()},[l]);const c=p.useCallback(()=>{l()},[l]);return{asset:r,loading:s,error:i,refetch:c}}function B9(){const[e,r]=p.useState(!1),[a,s]=p.useState(null);return{createAsset:c=>J(null,null,function*(){try{r(!0),s(null),console.log("[useAssetMutations] Creating asset with data:",c);const u=yield Q0.createAsset(c);if(console.log("[useAssetMutations] Create asset response:",u),u.success)return u.asset;{const h=u.error||"Failed to create asset";throw new Error(h)}}catch(u){console.error("[useAssetMutations] Create asset error:",u);const h=u instanceof Error?u.message:"Failed to create asset";throw s(h),u}finally{r(!1)}}),updateAsset:(c,u)=>J(null,null,function*(){try{r(!0),s(null),console.log("[useAssetMutations] Updating asset:",c,"with data:",u);const h=yield Q0.updateAsset(c,u);if(console.log("[useAssetMutations] Update asset response:",h),h.success)return h.asset;{const f=h.error||"Failed to update asset";throw new Error(f)}}catch(h){console.error("[useAssetMutations] Update asset error:",h);const f=h instanceof Error?h.message:"Failed to update asset";throw s(f),h}finally{r(!1)}}),deleteAsset:c=>J(null,null,function*(){try{r(!0),s(null);const u=yield Q0.deleteAsset(c);if(!u.success)throw new Error("Failed to delete asset");return u}catch(u){const h=u instanceof Error?u.message:"Failed to delete asset";throw s(h),u}finally{r(!1)}}),submitAsset:c=>J(null,null,function*(){try{r(!0),s(null),console.log("[useAssetMutations] Submitting asset:",c);const u=yield Q0.submitAsset(c);return console.log("[useAssetMutations] Submit asset response:",u),u}catch(u){console.error("[useAssetMutations] Submit asset error:",u);const h=u instanceof Error?u.message:"Failed to submit asset";throw s(h),u}finally{r(!1)}}),loading:e,error:a}}var W9={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},mE=gr.createContext&&gr.createContext(W9),SG=["attr","size","title"];function CG(e,r){if(e==null)return{};var a=TG(e,r),s,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)s=i[n],!(r.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(a[s]=e[s])}return a}function TG(e,r){if(e==null)return{};var a={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(r.indexOf(s)>=0)continue;a[s]=e[s]}return a}function jv(){return jv=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)Object.prototype.hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},jv.apply(this,arguments)}function hE(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function _v(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?hE(Object(a),!0).forEach(function(s){EG(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):hE(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function EG(e,r,a){return r=AG(r),r in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function AG(e){var r=OG(e,"string");return typeof r=="symbol"?r:r+""}function OG(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function H9(e){return e&&e.map((r,a)=>gr.createElement(r.tag,_v({key:a},r.attr),H9(r.child)))}function Zt(e){return r=>gr.createElement(PG,jv({attr:_v({},e.attr)},r),H9(e.child))}function PG(e){var r=a=>{var{attr:s,size:n,title:i}=e,o=CG(e,SG),l=n||a.size||"1em",c;return a.className&&(c=a.className),e.className&&(c=(c?c+" ":"")+e.className),gr.createElement("svg",jv({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,s,o,{className:c,style:_v(_v({color:e.color||a.color},a.style),e.style),height:l,width:l,xmlns:"http://www.w3.org/2000/svg"}),i&&gr.createElement("title",null,i),e.children)};return mE!==void 0?gr.createElement(mE.Consumer,null,a=>r(a)):r(W9)}function DG(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z"},child:[]}]})(e)}function ia(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M257.5 445.1l-22.2 22.2c-9.4 9.4-24.6 9.4-33.9 0L7 273c-9.4-9.4-9.4-24.6 0-33.9L201.4 44.7c9.4-9.4 24.6-9.4 33.9 0l22.2 22.2c9.5 9.5 9.3 25-.4 34.3L136.6 216H424c13.3 0 24 10.7 24 24v32c0 13.3-10.7 24-24 24H136.6l120.5 114.8c9.8 9.3 10 24.8.4 34.3z"},child:[]}]})(e)}function RG(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z"},child:[]}]})(e)}function Mo(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 8C119.034 8 8 119.033 8 256s111.034 248 248 248 248-111.034 248-248S392.967 8 256 8zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676zM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676z"},child:[]}]})(e)}function wN(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M224 512c35.32 0 63.97-28.65 63.97-64H160.03c0 35.35 28.65 64 63.97 64zm215.39-149.71c-19.32-20.76-55.47-51.99-55.47-154.29 0-77.7-54.48-139.9-127.94-155.16V32c0-17.67-14.32-32-31.98-32s-31.98 14.33-31.98 32v20.84C118.56 68.1 64.08 130.3 64.08 208c0 102.3-36.15 133.53-55.47 154.29-6 6.45-8.66 14.16-8.61 21.71.11 16.4 12.98 32 32.1 32h383.8c19.12 0 32-15.6 32.1-32 .05-7.55-2.61-15.27-8.61-21.71z"},child:[]}]})(e)}function MG(e){return Zt({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M296 160H180.6l42.6-129.8C227.2 15 215.7 0 200 0H56C44 0 33.8 8.9 32.2 20.8l-32 240C-1.7 275.2 9.5 288 24 288h118.7L96.6 482.5c-3.6 15.2 8 29.5 23.3 29.5 8.4 0 16.4-4.4 20.8-12l176-304c9.3-15.9-2.2-36-20.7-36z"},child:[]}]})(e)}function pE(e){return Zt({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M425.7 256c-16.9 0-32.8-9-41.4-23.4L320 126l-64.2 106.6c-8.7 14.5-24.6 23.5-41.5 23.5-4.5 0-9-.6-13.3-1.9L64 215v178c0 14.7 10 27.5 24.2 31l216.2 54.1c10.2 2.5 20.9 2.5 31 0L551.8 424c14.2-3.6 24.2-16.4 24.2-31V215l-137 39.1c-4.3 1.3-8.8 1.9-13.3 1.9zm212.6-112.2L586.8 41c-3.1-6.2-9.8-9.8-16.7-8.9L320 64l91.7 152.1c3.8 6.3 11.4 9.3 18.5 7.3l197.9-56.5c9.9-2.9 14.7-13.9 10.2-23.1zM53.2 41L1.7 143.8c-4.6 9.2.3 20.2 10.1 23l197.9 56.5c7.1 2 14.7-1 18.5-7.3L320 64 69.8 32.1c-6.9-.8-13.5 2.7-16.6 8.9z"},child:[]}]})(e)}function LG(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M509.5 184.6L458.9 32.8C452.4 13.2 434.1 0 413.4 0H272v192h238.7c-.4-2.5-.4-5-1.2-7.4zM240 0H98.6c-20.7 0-39 13.2-45.5 32.8L2.5 184.6c-.8 2.4-.8 4.9-1.2 7.4H240V0zM0 224v240c0 26.5 21.5 48 48 48h416c26.5 0 48-21.5 48-48V224H0z"},child:[]}]})(e)}function zd(e){return Zt({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M560 288h-80v96l-32-21.3-32 21.3v-96h-80c-8.8 0-16 7.2-16 16v192c0 8.8 7.2 16 16 16h224c8.8 0 16-7.2 16-16V304c0-8.8-7.2-16-16-16zm-384-64h224c8.8 0 16-7.2 16-16V16c0-8.8-7.2-16-16-16h-80v96l-32-21.3L256 96V0h-80c-8.8 0-16 7.2-16 16v192c0 8.8 7.2 16 16 16zm64 64h-80v96l-32-21.3L96 384v-96H16c-8.8 0-16 7.2-16 16v192c0 8.8 7.2 16 16 16h224c8.8 0 16-7.2 16-16V304c0-8.8-7.2-16-16-16z"},child:[]}]})(e)}function K4(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M436 480h-20V24c0-13.255-10.745-24-24-24H56C42.745 0 32 10.745 32 24v456H12c-6.627 0-12 5.373-12 12v20h448v-20c0-6.627-5.373-12-12-12zM128 76c0-6.627 5.373-12 12-12h40c6.627 0 12 5.373 12 12v40c0 6.627-5.373 12-12 12h-40c-6.627 0-12-5.373-12-12V76zm0 96c0-6.627 5.373-12 12-12h40c6.627 0 12 5.373 12 12v40c0 6.627-5.373 12-12 12h-40c-6.627 0-12-5.373-12-12v-40zm52 148h-40c-6.627 0-12-5.373-12-12v-40c0-6.627 5.373-12 12-12h40c6.627 0 12 5.373 12 12v40c0 6.627-5.373 12-12 12zm76 160h-64v-84c0-6.627 5.373-12 12-12h40c6.627 0 12 5.373 12 12v84zm64-172c0 6.627-5.373 12-12 12h-40c-6.627 0-12-5.373-12-12v-40c0-6.627 5.373-12 12-12h40c6.627 0 12 5.373 12 12v40zm0-96c0 6.627-5.373 12-12 12h-40c-6.627 0-12-5.373-12-12v-40c0-6.627 5.373-12 12-12h40c6.627 0 12 5.373 12 12v40zm0-96c0 6.627-5.373 12-12 12h-40c-6.627 0-12-5.373-12-12V76c0-6.627 5.373-12 12-12h40c6.627 0 12 5.373 12 12v40z"},child:[]}]})(e)}function q9(e){return Zt({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M576 240c0-23.63-12.95-44.04-32-55.12V32.01C544 23.26 537.02 0 512 0c-7.12 0-14.19 2.38-19.98 7.02l-85.03 68.03C364.28 109.19 310.66 128 256 128H64c-35.35 0-64 28.65-64 64v96c0 35.35 28.65 64 64 64h33.7c-1.39 10.48-2.18 21.14-2.18 32 0 39.77 9.26 77.35 25.56 110.94 5.19 10.69 16.52 17.06 28.4 17.06h74.28c26.05 0 41.69-29.84 25.9-50.56-16.4-21.52-26.15-48.36-26.15-77.44 0-11.11 1.62-21.79 4.41-32H256c54.66 0 108.28 18.81 150.98 52.95l85.03 68.03a32.023 32.023 0 0 0 19.98 7.02c24.92 0 32-22.78 32-32V295.13C563.05 284.04 576 263.63 576 240zm-96 141.42l-33.05-26.44C392.95 311.78 325.12 288 256 288v-96c69.12 0 136.95-23.78 190.95-66.98L480 98.58v282.84z"},child:[]}]})(e)}function rc(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M0 464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V192H0v272zm320-196c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40zm0 128c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40zM192 268c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40zm0 128c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40zM64 268c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H76c-6.6 0-12-5.4-12-12v-40zm0 128c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H76c-6.6 0-12-5.4-12-12v-40zM400 64h-48V16c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v48H160V16c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v48H48C21.5 64 0 85.5 0 112v48h448v-48c0-26.5-21.5-48-48-48z"},child:[]}]})(e)}function Y4(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M436 160H12c-6.627 0-12-5.373-12-12v-36c0-26.51 21.49-48 48-48h48V12c0-6.627 5.373-12 12-12h40c6.627 0 12 5.373 12 12v52h128V12c0-6.627 5.373-12 12-12h40c6.627 0 12 5.373 12 12v52h48c26.51 0 48 21.49 48 48v36c0 6.627-5.373 12-12 12zM12 192h424c6.627 0 12 5.373 12 12v260c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V204c0-6.627 5.373-12 12-12zm333.296 95.947l-28.169-28.398c-4.667-4.705-12.265-4.736-16.97-.068L194.12 364.665l-45.98-46.352c-4.667-4.705-12.266-4.736-16.971-.068l-28.397 28.17c-4.705 4.667-4.736 12.265-.068 16.97l82.601 83.269c4.667 4.705 12.265 4.736 16.97.068l142.953-141.805c4.705-4.667 4.736-12.265.068-16.97z"},child:[]}]})(e)}function sv(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12 192h424c6.6 0 12 5.4 12 12v260c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V204c0-6.6 5.4-12 12-12zm436-44v-36c0-26.5-21.5-48-48-48h-48V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H160V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H48C21.5 64 0 85.5 0 112v36c0 6.6 5.4 12 12 12h424c6.6 0 12-5.4 12-12z"},child:[]}]})(e)}function gE(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M332.8 320h38.4c6.4 0 12.8-6.4 12.8-12.8V172.8c0-6.4-6.4-12.8-12.8-12.8h-38.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h38.4c6.4 0 12.8-6.4 12.8-12.8V76.8c0-6.4-6.4-12.8-12.8-12.8h-38.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-288 0h38.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-38.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h38.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-38.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zM496 384H64V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-32c0-8.84-7.16-16-16-16z"},child:[]}]})(e)}function J4(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M496 384H64V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-32c0-8.84-7.16-16-16-16zM464 96H345.94c-21.38 0-32.09 25.85-16.97 40.97l32.4 32.4L288 242.75l-73.37-73.37c-12.5-12.5-32.76-12.5-45.25 0l-68.69 68.69c-6.25 6.25-6.25 16.38 0 22.63l22.62 22.62c6.25 6.25 16.38 6.25 22.63 0L192 237.25l73.37 73.37c12.5 12.5 32.76 12.5 45.25 0l96-96 32.4 32.4c15.12 15.12 40.97 4.41 40.97-16.97V112c.01-8.84-7.15-16-15.99-16z"},child:[]}]})(e)}function Qt(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z"},child:[]}]})(e)}function Ra(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M400 480H48c-26.51 0-48-21.49-48-48V80c0-26.51 21.49-48 48-48h352c26.51 0 48 21.49 48 48v352c0 26.51-21.49 48-48 48zm-204.686-98.059l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.248-16.379-6.249-22.628 0L184 302.745l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.25 16.379 6.25 22.628.001z"},child:[]}]})(e)}function Oc(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"},child:[]}]})(e)}function Fr(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.357-9.357 24.522-9.375 33.901-.04L224 284.505l154.745-154.021c9.379-9.335 24.544-9.317 33.901.04l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.372-24.569 9.372-33.942 0z"},child:[]}]})(e)}function Z4(e){return Zt({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z"},child:[]}]})(e)}function Fi(e){return Zt({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"},child:[]}]})(e)}function Ja(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M240.971 130.524l194.343 194.343c9.373 9.373 9.373 24.569 0 33.941l-22.667 22.667c-9.357 9.357-24.522 9.375-33.901.04L224 227.495 69.255 381.516c-9.379 9.335-24.544 9.317-33.901-.04l-22.667-22.667c-9.373-9.373-9.373-24.569 0-33.941L207.03 130.525c9.372-9.373 24.568-9.373 33.941-.001z"},child:[]}]})(e)}function ao(e){return Zt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M336 64h-80c0-35.3-28.7-64-64-64s-64 28.7-64 64H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V112c0-26.5-21.5-48-48-48zM192 40c13.3 0 24 10.7 24 24s-10.7 24-24 24-24-10.7-24-24 10.7-24 24-24zm121.2 231.8l-143 141.8c-4.7 4.7-12.3 4.6-17-.1l-82.6-83.3c-4.7-4.7-4.6-12.3.1-17L99.1 285c4.7-4.7 12.3-4.6 17 .1l46 46.4 106-105.2c4.7-4.7 12.3-4.6 17 .1l28.2 28.4c4.7 4.8 4.6 12.3-.1 17z"},child:[]}]})(e)}function Ju(e){return Zt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M336 64h-80c0-35.3-28.7-64-64-64s-64 28.7-64 64H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V112c0-26.5-21.5-48-48-48zM96 424c-13.3 0-24-10.7-24-24s10.7-24 24-24 24 10.7 24 24-10.7 24-24 24zm0-96c-13.3 0-24-10.7-24-24s10.7-24 24-24 24 10.7 24 24-10.7 24-24 24zm0-96c-13.3 0-24-10.7-24-24s10.7-24 24-24 24 10.7 24 24-10.7 24-24 24zm96-192c13.3 0 24 10.7 24 24s-10.7 24-24 24-24-10.7-24-24 10.7-24 24-24zm128 368c0 4.4-3.6 8-8 8H168c-4.4 0-8-3.6-8-8v-16c0-4.4 3.6-8 8-8h144c4.4 0 8 3.6 8 8v16zm0-96c0 4.4-3.6 8-8 8H168c-4.4 0-8-3.6-8-8v-16c0-4.4 3.6-8 8-8h144c4.4 0 8 3.6 8 8v16zm0-96c0 4.4-3.6 8-8 8H168c-4.4 0-8-3.6-8-8v-16c0-4.4 3.6-8 8-8h144c4.4 0 8 3.6 8 8v16z"},child:[]}]})(e)}function ea(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256,8C119,8,8,119,8,256S119,504,256,504,504,393,504,256,393,8,256,8Zm92.49,313h0l-20,25a16,16,0,0,1-22.49,2.5h0l-67-49.72a40,40,0,0,1-15-31.23V112a16,16,0,0,1,16-16h32a16,16,0,0,1,16,16V256l58,42.5A16,16,0,0,1,348.49,321Z"},child:[]}]})(e)}function V9(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z"},child:[]}]})(e)}function kv(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M487.4 315.7l-42.6-24.6c4.3-23.2 4.3-47 0-70.2l42.6-24.6c4.9-2.8 7.1-8.6 5.5-14-11.1-35.6-30-67.8-54.7-94.6-3.8-4.1-10-5.1-14.8-2.3L380.8 110c-17.9-15.4-38.5-27.3-60.8-35.1V25.8c0-5.6-3.9-10.5-9.4-11.7-36.7-8.2-74.3-7.8-109.2 0-5.5 1.2-9.4 6.1-9.4 11.7V75c-22.2 7.9-42.8 19.8-60.8 35.1L88.7 85.5c-4.9-2.8-11-1.9-14.8 2.3-24.7 26.7-43.6 58.9-54.7 94.6-1.7 5.4.6 11.2 5.5 14L67.3 221c-4.3 23.2-4.3 47 0 70.2l-42.6 24.6c-4.9 2.8-7.1 8.6-5.5 14 11.1 35.6 30 67.8 54.7 94.6 3.8 4.1 10 5.1 14.8 2.3l42.6-24.6c17.9 15.4 38.5 27.3 60.8 35.1v49.2c0 5.6 3.9 10.5 9.4 11.7 36.7 8.2 74.3 7.8 109.2 0 5.5-1.2 9.4-6.1 9.4-11.7v-49.2c22.2-7.9 42.8-19.8 60.8-35.1l42.6 24.6c4.9 2.8 11 1.9 14.8-2.3 24.7-26.7 43.6-58.9 54.7-94.6 1.5-5.5-.7-11.3-5.6-14.1zM256 336c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z"},child:[]}]})(e)}function FG(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 32C114.6 32 0 125.1 0 240c0 49.6 21.4 95 57 130.7C44.5 421.1 2.7 466 2.2 466.5c-2.2 2.3-2.8 5.7-1.5 8.7S4.8 480 8 480c66.3 0 116-31.8 140.6-51.4 32.7 12.3 69 19.4 107.4 19.4 141.4 0 256-93.1 256-208S397.4 32 256 32z"},child:[]}]})(e)}function nv(e){return Zt({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M416 192c0-88.4-93.1-160-208-160S0 103.6 0 192c0 34.3 14.1 65.9 38 92-13.4 30.2-35.5 54.2-35.8 54.5-2.2 2.3-2.8 5.7-1.5 8.7S4.8 352 8 352c36.6 0 66.9-12.3 88.7-25 32.2 15.7 70.3 25 111.3 25 114.9 0 208-71.6 208-160zm122 220c23.9-26 38-57.7 38-92 0-66.9-53.5-124.2-129.3-148.1.9 6.6 1.3 13.3 1.3 20.1 0 105.9-107.7 192-240 192-10.8 0-21.3-.8-31.7-1.9C207.8 439.6 281.8 480 368 480c41 0 79.1-9.2 111.3-25 21.8 12.7 52.1 25 88.7 25 3.2 0 6.1-1.9 7.3-4.8 1.3-2.9.7-6.3-1.5-8.7-.3-.3-22.4-24.2-35.8-54.5z"},child:[]}]})(e)}function Vo(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z"},child:[]}]})(e)}function qc(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"},child:[]}]})(e)}function qr(e){return Zt({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M402.6 83.2l90.2 90.2c3.8 3.8 3.8 10 0 13.8L274.4 405.6l-92.8 10.3c-12.4 1.4-22.9-9.1-21.5-21.5l10.3-92.8L388.8 83.2c3.8-3.8 10-3.8 13.8 0zm162-22.9l-48.8-48.8c-15.2-15.2-39.9-15.2-55.2 0l-35.4 35.4c-3.8 3.8-3.8 10 0 13.8l90.2 90.2c3.8 3.8 10 3.8 13.8 0l35.4-35.4c15.2-15.3 15.2-40 0-55.2zM384 346.2V448H64V128h229.8c3.2 0 6.2-1.3 8.5-3.5l40-40c7.6-7.6 2.2-20.5-8.5-20.5H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V306.2c0-10.7-12.9-16-20.5-8.5l-40 40c-2.2 2.3-3.5 5.3-3.5 8.5z"},child:[]}]})(e)}function jx(e){return Zt({attr:{viewBox:"0 0 192 512"},child:[{tag:"path",attr:{d:"M96 184c39.8 0 72 32.2 72 72s-32.2 72-72 72-72-32.2-72-72 32.2-72 72-72zM24 80c0 39.8 32.2 72 72 72s72-32.2 72-72S135.8 8 96 8 24 40.2 24 80zm0 352c0 39.8 32.2 72 72 72s72-32.2 72-72-32.2-72-72-72-72 32.2-72 72z"},child:[]}]})(e)}function G9(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M502.3 190.8c3.9-3.1 9.7-.2 9.7 4.7V400c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V195.6c0-5 5.7-7.8 9.7-4.7 22.4 17.4 52.1 39.5 154.1 113.6 21.1 15.4 56.7 47.8 92.2 47.6 35.7.3 72-32.8 92.3-47.6 102-74.1 131.6-96.3 154-113.7zM256 320c23.2.4 56.6-29.2 73.4-41.4 132.7-96.3 142.8-104.7 173.4-128.7 5.8-4.5 9.2-11.5 9.2-18.9v-19c0-26.5-21.5-48-48-48H48C21.5 64 0 85.5 0 112v19c0 7.4 3.4 14.3 9.2 18.9 30.6 23.9 40.7 32.4 173.4 128.7 16.8 12.2 50.2 41.8 73.4 41.4z"},child:[]}]})(e)}function IG(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"},child:[]}]})(e)}function Or(e){return Zt({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"},child:[]}]})(e)}function dn(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M432,320H400a16,16,0,0,0-16,16V448H64V128H208a16,16,0,0,0,16-16V80a16,16,0,0,0-16-16H48A48,48,0,0,0,0,112V464a48,48,0,0,0,48,48H400a48,48,0,0,0,48-48V336A16,16,0,0,0,432,320ZM488,0h-128c-21.37,0-32.05,25.91-17,41l35.73,35.73L135,320.37a24,24,0,0,0,0,34L157.67,377a24,24,0,0,0,34,0L435.28,133.32,471,169c15,15,41,4.5,41-17V24A24,24,0,0,0,488,0Z"},child:[]}]})(e)}function rk(e){return Zt({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M320 400c-75.85 0-137.25-58.71-142.9-133.11L72.2 185.82c-13.79 17.3-26.48 35.59-36.72 55.59a32.35 32.35 0 0 0 0 29.19C89.71 376.41 197.07 448 320 448c26.91 0 52.87-4 77.89-10.46L346 397.39a144.13 144.13 0 0 1-26 2.61zm313.82 58.1l-110.55-85.44a331.25 331.25 0 0 0 81.25-102.07 32.35 32.35 0 0 0 0-29.19C550.29 135.59 442.93 64 320 64a308.15 308.15 0 0 0-147.32 37.7L45.46 3.37A16 16 0 0 0 23 6.18L3.37 31.45A16 16 0 0 0 6.18 53.9l588.36 454.73a16 16 0 0 0 22.46-2.81l19.64-25.27a16 16 0 0 0-2.82-22.45zm-183.72-142l-39.3-30.38A94.75 94.75 0 0 0 416 256a94.76 94.76 0 0 0-121.31-92.21A47.65 47.65 0 0 1 304 192a46.64 46.64 0 0 1-1.54 10l-73.61-56.89A142.31 142.31 0 0 1 320 112a143.92 143.92 0 0 1 144 144c0 21.63-5.29 41.79-13.9 60.11z"},child:[]}]})(e)}function Ps(e){return Zt({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M572.52 241.4C518.29 135.59 410.93 64 288 64S57.68 135.64 3.48 241.41a32.35 32.35 0 0 0 0 29.19C57.71 376.41 165.07 448 288 448s230.32-71.64 284.52-177.41a32.35 32.35 0 0 0 0-29.19zM288 400a144 144 0 1 1 144-144 143.93 143.93 0 0 1-144 144zm0-240a95.31 95.31 0 0 0-25.31 3.79 47.85 47.85 0 0 1-66.9 66.9A95.78 95.78 0 1 0 288 160z"},child:[]}]})(e)}function X4(e){return Zt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm64 236c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12v8zm0-64c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12v8zm0-72v8c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12zm96-114.1v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"},child:[]}]})(e)}function pp(e){return Zt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zM64 72c0-4.42 3.58-8 8-8h80c4.42 0 8 3.58 8 8v16c0 4.42-3.58 8-8 8H72c-4.42 0-8-3.58-8-8V72zm0 64c0-4.42 3.58-8 8-8h80c4.42 0 8 3.58 8 8v16c0 4.42-3.58 8-8 8H72c-4.42 0-8-3.58-8-8v-16zm192.81 248H304c8.84 0 16 7.16 16 16s-7.16 16-16 16h-47.19c-16.45 0-31.27-9.14-38.64-23.86-2.95-5.92-8.09-6.52-10.17-6.52s-7.22.59-10.02 6.19l-7.67 15.34a15.986 15.986 0 0 1-14.31 8.84c-.38 0-.75-.02-1.14-.05-6.45-.45-12-4.75-14.03-10.89L144 354.59l-10.61 31.88c-5.89 17.66-22.38 29.53-41 29.53H80c-8.84 0-16-7.16-16-16s7.16-16 16-16h12.39c4.83 0 9.11-3.08 10.64-7.66l18.19-54.64c3.3-9.81 12.44-16.41 22.78-16.41s19.48 6.59 22.77 16.41l13.88 41.64c19.77-16.19 54.05-9.7 66 14.16 2.02 4.06 5.96 6.5 10.16 6.5zM377 105L279.1 7c-4.5-4.5-10.6-7-17-7H256v128h128v-6.1c0-6.3-2.5-12.4-7-16.9z"},child:[]}]})(e)}function ic(e){return Zt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm-96 144c0 4.42-3.58 8-8 8h-8c-8.84 0-16 7.16-16 16v32c0 8.84 7.16 16 16 16h8c4.42 0 8 3.58 8 8v16c0 4.42-3.58 8-8 8h-8c-26.51 0-48-21.49-48-48v-32c0-26.51 21.49-48 48-48h8c4.42 0 8 3.58 8 8v16zm44.27 104H160c-4.42 0-8-3.58-8-8v-16c0-4.42 3.58-8 8-8h12.27c5.95 0 10.41-3.5 10.41-6.62 0-1.3-.75-2.66-2.12-3.84l-21.89-18.77c-8.47-7.22-13.33-17.48-13.33-28.14 0-21.3 19.02-38.62 42.41-38.62H200c4.42 0 8 3.58 8 8v16c0 4.42-3.58 8-8 8h-12.27c-5.95 0-10.41 3.5-10.41 6.62 0 1.3.75 2.66 2.12 3.84l21.89 18.77c8.47 7.22 13.33 17.48 13.33 28.14.01 21.29-19 38.62-42.39 38.62zM256 264v20.8c0 20.27 5.7 40.17 16 56.88 10.3-16.7 16-36.61 16-56.88V264c0-4.42 3.58-8 8-8h16c4.42 0 8 3.58 8 8v20.8c0 35.48-12.88 68.89-36.28 94.09-3.02 3.25-7.27 5.11-11.72 5.11s-8.7-1.86-11.72-5.11c-23.4-25.2-36.28-58.61-36.28-94.09V264c0-4.42 3.58-8 8-8h16c4.42 0 8 3.58 8 8zm121-159L279.1 7c-4.5-4.5-10.6-7-17-7H256v128h128v-6.1c0-6.3-2.5-12.4-7-16.9z"},child:[]}]})(e)}function oc(e){return Zt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm60.1 106.5L224 336l60.1 93.5c5.1 8-.6 18.5-10.1 18.5h-34.9c-4.4 0-8.5-2.4-10.6-6.3C208.9 405.5 192 373 192 373c-6.4 14.8-10 20-36.6 68.8-2.1 3.9-6.1 6.3-10.5 6.3H110c-9.5 0-15.2-10.5-10.1-18.5l60.3-93.5-60.3-93.5c-5.2-8 .6-18.5 10.1-18.5h34.8c4.4 0 8.5 2.4 10.6 6.3 26.1 48.8 20 33.6 36.6 68.5 0 0 6.1-11.7 36.6-68.5 2.1-3.9 6.2-6.3 10.6-6.3H274c9.5-.1 15.2 10.4 10.1 18.4zM384 121.9v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"},child:[]}]})(e)}function Sa(e){return Zt({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M384 121.9c0-6.3-2.5-12.4-7-16.9L279.1 7c-4.5-4.5-10.6-7-17-7H256v128h128zM571 308l-95.7-96.4c-10.1-10.1-27.4-3-27.4 11.3V288h-64v64h64v65.2c0 14.3 17.3 21.4 27.4 11.3L571 332c6.6-6.6 6.6-17.4 0-24zm-379 28v-32c0-8.8 7.2-16 16-16h176V160H248c-13.2 0-24-10.8-24-24V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V352H208c-8.8 0-16-7.2-16-16z"},child:[]}]})(e)}function xm(e){return Zt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M377 105L279.1 7c-4.5-4.5-10.6-7-17-7H256v128h128v-6.1c0-6.3-2.5-12.4-7-16.9zm-153 31V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zM64 72c0-4.42 3.58-8 8-8h80c4.42 0 8 3.58 8 8v16c0 4.42-3.58 8-8 8H72c-4.42 0-8-3.58-8-8V72zm0 80v-16c0-4.42 3.58-8 8-8h80c4.42 0 8 3.58 8 8v16c0 4.42-3.58 8-8 8H72c-4.42 0-8-3.58-8-8zm144 263.88V440c0 4.42-3.58 8-8 8h-16c-4.42 0-8-3.58-8-8v-24.29c-11.29-.58-22.27-4.52-31.37-11.35-3.9-2.93-4.1-8.77-.57-12.14l11.75-11.21c2.77-2.64 6.89-2.76 10.13-.73 3.87 2.42 8.26 3.72 12.82 3.72h28.11c6.5 0 11.8-5.92 11.8-13.19 0-5.95-3.61-11.19-8.77-12.73l-45-13.5c-18.59-5.58-31.58-23.42-31.58-43.39 0-24.52 19.05-44.44 42.67-45.07V232c0-4.42 3.58-8 8-8h16c4.42 0 8 3.58 8 8v24.29c11.29.58 22.27 4.51 31.37 11.35 3.9 2.93 4.1 8.77.57 12.14l-11.75 11.21c-2.77 2.64-6.89 2.76-10.13.73-3.87-2.43-8.26-3.72-12.82-3.72h-28.11c-6.5 0-11.8 5.92-11.8 13.19 0 5.95 3.61 11.19 8.77 12.73l45 13.5c18.59 5.58 31.58 23.42 31.58 43.39 0 24.53-19.05 44.44-42.67 45.07z"},child:[]}]})(e)}function zG(e){return Zt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M288 256H96v64h192v-64zm89-151L279.1 7c-4.5-4.5-10.6-7-17-7H256v128h128v-6.1c0-6.3-2.5-12.4-7-16.9zm-153 31V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zM64 72c0-4.42 3.58-8 8-8h80c4.42 0 8 3.58 8 8v16c0 4.42-3.58 8-8 8H72c-4.42 0-8-3.58-8-8V72zm0 64c0-4.42 3.58-8 8-8h80c4.42 0 8 3.58 8 8v16c0 4.42-3.58 8-8 8H72c-4.42 0-8-3.58-8-8v-16zm256 304c0 4.42-3.58 8-8 8h-80c-4.42 0-8-3.58-8-8v-16c0-4.42 3.58-8 8-8h80c4.42 0 8 3.58 8 8v16zm0-200v96c0 8.84-7.16 16-16 16H80c-8.84 0-16-7.16-16-16v-96c0-8.84 7.16-16 16-16h224c8.84 0 16 7.16 16 16z"},child:[]}]})(e)}function iv(e){return Zt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M377 105L279.1 7c-4.5-4.5-10.6-7-17-7H256v128h128v-6.1c0-6.3-2.5-12.4-7-16.9zm-153 31V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm64 160v48c0 4.4-3.6 8-8 8h-56v56c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8v-56h-56c-4.4 0-8-3.6-8-8v-48c0-4.4 3.6-8 8-8h56v-56c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v56h56c4.4 0 8 3.6 8 8z"},child:[]}]})(e)}function _x(e){return Zt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M181.9 256.1c-5-16-4.9-46.9-2-46.9 8.4 0 7.6 36.9 2 46.9zm-1.7 47.2c-7.7 20.2-17.3 43.3-28.4 62.7 18.3-7 39-17.2 62.9-21.9-12.7-9.6-24.9-23.4-34.5-40.8zM86.1 428.1c0 .8 13.2-5.4 34.9-40.2-6.7 6.3-29.1 24.5-34.9 40.2zM248 160h136v328c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V24C0 10.7 10.7 0 24 0h200v136c0 13.2 10.8 24 24 24zm-8 171.8c-20-12.2-33.3-29-42.7-53.8 4.5-18.5 11.6-46.6 6.2-64.2-4.7-29.4-42.4-26.5-47.8-6.8-5 18.3-.4 44.1 8.1 77-11.6 27.6-28.7 64.6-40.8 85.8-.1 0-.1.1-.2.1-27.1 13.9-73.6 44.5-54.5 68 5.6 6.9 16 10 21.5 10 17.9 0 35.7-18 61.1-61.8 25.8-8.5 54.1-19.1 79-23.2 21.7 11.8 47.1 19.5 64 19.5 29.2 0 31.2-32 19.7-43.4-13.9-13.6-54.3-9.7-73.6-7.2zM377 105L279 7c-4.5-4.5-10.6-7-17-7h-6v128h128v-6.1c0-6.3-2.5-12.4-7-16.9zm-74.1 255.3c4.1-2.7-2.5-11.9-42.8-9 37.1 15.8 42.8 9 42.8 9z"},child:[]}]})(e)}function Nv(e){return Zt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm160-14.1v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"},child:[]}]})(e)}function ds(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M487.976 0H24.028C2.71 0-8.047 25.866 7.058 40.971L192 225.941V432c0 7.831 3.821 15.17 10.237 19.662l80 55.98C298.02 518.69 320 507.493 320 487.98V225.941l184.947-184.97C520.021 25.896 509.338 0 487.976 0z"},child:[]}]})(e)}function gp(e){return Zt({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M572.694 292.093L500.27 416.248A63.997 63.997 0 0 1 444.989 448H45.025c-18.523 0-30.064-20.093-20.731-36.093l72.424-124.155A64 64 0 0 1 152 256h399.964c18.523 0 30.064 20.093 20.73 36.093zM152 224h328v-48c0-26.51-21.49-48-48-48H272l-64-64H48C21.49 64 0 85.49 0 112v278.046l69.077-118.418C86.214 242.25 117.989 224 152 224z"},child:[]}]})(e)}function Sv(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M480 288c0-80.25-49.28-148.92-119.19-177.62L320 192V80a16 16 0 0 0-16-16h-96a16 16 0 0 0-16 16v112l-40.81-81.62C81.28 139.08 32 207.75 32 288v64h448zm16 96H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h480a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(e)}function Cv(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M192 208c0-17.67-14.33-32-32-32h-16c-35.35 0-64 28.65-64 64v48c0 35.35 28.65 64 64 64h16c17.67 0 32-14.33 32-32V208zm176 144c35.35 0 64-28.65 64-64v-48c0-35.35-28.65-64-64-64h-16c-17.67 0-32 14.33-32 32v112c0 17.67 14.33 32 32 32h16zM256 0C113.18 0 4.58 118.83 0 256v16c0 8.84 7.16 16 16 16h16c8.84 0 16-7.16 16-16v-16c0-114.69 93.31-208 208-208s208 93.31 208 208h-.12c.08 2.43.12 165.72.12 165.72 0 23.35-18.93 42.28-42.28 42.28H320c0-26.51-21.49-48-48-48h-32c-26.51 0-48 21.49-48 48s21.49 48 48 48h181.72c49.86 0 90.28-40.42 90.28-90.28V256C507.42 118.83 398.82 0 256 0z"},child:[]}]})(e)}function ym(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M504 255.531c.253 136.64-111.18 248.372-247.82 248.468-59.015.042-113.223-20.53-155.822-54.911-11.077-8.94-11.905-25.541-1.839-35.607l11.267-11.267c8.609-8.609 22.353-9.551 31.891-1.984C173.062 425.135 212.781 440 256 440c101.705 0 184-82.311 184-184 0-101.705-82.311-184-184-184-48.814 0-93.149 18.969-126.068 49.932l50.754 50.754c10.08 10.08 2.941 27.314-11.313 27.314H24c-8.837 0-16-7.163-16-16V38.627c0-14.254 17.234-21.393 27.314-11.314l49.372 49.372C129.209 34.136 189.552 8 256 8c136.81 0 247.747 110.78 248 247.531zm-180.912 78.784l9.823-12.63c8.138-10.463 6.253-25.542-4.21-33.679L288 256.349V152c0-13.255-10.745-24-24-24h-16c-13.255 0-24 10.745-24 24v135.651l65.409 50.874c10.463 8.137 25.541 6.253 33.679-4.21z"},child:[]}]})(e)}function $G(e){return Zt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M336 0H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V48c0-26.5-21.5-48-48-48zM144 32h96c8.8 0 16 7.2 16 16s-7.2 16-16 16h-96c-8.8 0-16-7.2-16-16s7.2-16 16-16zm48 128c35.3 0 64 28.7 64 64s-28.7 64-64 64-64-28.7-64-64 28.7-64 64-64zm112 236.8c0 10.6-10 19.2-22.4 19.2H102.4C90 416 80 407.4 80 396.8v-19.2c0-31.8 30.1-57.6 67.2-57.6h5c12.3 5.1 25.7 8 39.8 8s27.6-2.9 39.8-8h5c37.1 0 67.2 25.8 67.2 57.6v19.2z"},child:[]}]})(e)}function ro(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 8C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm0 110c23.196 0 42 18.804 42 42s-18.804 42-42 42-42-18.804-42-42 18.804-42 42-42zm56 254c0 6.627-5.373 12-12 12h-88c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h12v-64h-12c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h64c6.627 0 12 5.373 12 12v100h12c6.627 0 12 5.373 12 12v24z"},child:[]}]})(e)}function ak(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M512 176.001C512 273.203 433.202 352 336 352c-11.22 0-22.19-1.062-32.827-3.069l-24.012 27.014A23.999 23.999 0 0 1 261.223 384H224v40c0 13.255-10.745 24-24 24h-40v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24v-78.059c0-6.365 2.529-12.47 7.029-16.971l161.802-161.802C163.108 213.814 160 195.271 160 176 160 78.798 238.797.001 335.999 0 433.488-.001 512 78.511 512 176.001zM336 128c0 26.51 21.49 48 48 48s48-21.49 48-48-21.49-48-48-48-48 21.49-48 48z"},child:[]}]})(e)}function ov(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(e)}function K9(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M80 368H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm0-320H16A16 16 0 0 0 0 64v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16zm0 160H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm416 176H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(e)}function jN(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M400 224h-24v-72C376 68.2 307.8 0 224 0S72 68.2 72 152v72H48c-26.5 0-48 21.5-48 48v192c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V272c0-26.5-21.5-48-48-48zm-104 0H152v-72c0-39.7 32.3-72 72-72s72 32.3 72 72v72z"},child:[]}]})(e)}function UG(e){return Zt({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M0 117.66v346.32c0 11.32 11.43 19.06 21.94 14.86L160 416V32L20.12 87.95A32.006 32.006 0 0 0 0 117.66zM192 416l192 64V96L192 32v384zM554.06 33.16L416 96v384l139.88-55.95A31.996 31.996 0 0 0 576 394.34V48.02c0-11.32-11.43-19.06-21.94-14.86z"},child:[]}]})(e)}function Q4(e){return Zt({attr:{viewBox:"0 0 352 512"},child:[{tag:"path",attr:{d:"M176 352c53.02 0 96-42.98 96-96V96c0-53.02-42.98-96-96-96S80 42.98 80 96v160c0 53.02 42.98 96 96 96zm160-160h-16c-8.84 0-16 7.16-16 16v48c0 74.8-64.49 134.82-140.79 127.38C96.71 376.89 48 317.11 48 250.3V208c0-8.84-7.16-16-16-16H16c-8.84 0-16 7.16-16 16v40.16c0 89.64 63.97 169.55 152 181.69V464H96c-8.84 0-16 7.16-16 16v16c0 8.84 7.16 16 16 16h160c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16h-56v-33.77C285.71 418.47 352 344.9 352 256v-48c0-8.84-7.16-16-16-16z"},child:[]}]})(e)}function Zu(e){return Zt({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M621.16 54.46C582.37 38.19 543.55 32 504.75 32c-123.17-.01-246.33 62.34-369.5 62.34-30.89 0-61.76-3.92-92.65-13.72-3.47-1.1-6.95-1.62-10.35-1.62C15.04 79 0 92.32 0 110.81v317.26c0 12.63 7.23 24.6 18.84 29.46C57.63 473.81 96.45 480 135.25 480c123.17 0 246.34-62.35 369.51-62.35 30.89 0 61.76 3.92 92.65 13.72 3.47 1.1 6.95 1.62 10.35 1.62 17.21 0 32.25-13.32 32.25-31.81V83.93c-.01-12.64-7.24-24.6-18.85-29.47zM48 132.22c20.12 5.04 41.12 7.57 62.72 8.93C104.84 170.54 79 192.69 48 192.69v-60.47zm0 285v-47.78c34.37 0 62.18 27.27 63.71 61.4-22.53-1.81-43.59-6.31-63.71-13.62zM320 352c-44.19 0-80-42.99-80-96 0-53.02 35.82-96 80-96s80 42.98 80 96c0 53.03-35.83 96-80 96zm272 27.78c-17.52-4.39-35.71-6.85-54.32-8.44 5.87-26.08 27.5-45.88 54.32-49.28v57.72zm0-236.11c-30.89-3.91-54.86-29.7-55.81-61.55 19.54 2.17 38.09 6.23 55.81 12.66v48.89z"},child:[]}]})(e)}function Lm(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M476 3.2L12.5 270.6c-18.1 10.4-15.8 35.6 2.2 43.2L121 358.4l287.3-253.2c5.5-4.9 13.3 2.6 8.6 8.3L176 407v80.5c0 23.6 28.5 32.9 42.5 15.8L282 426l124.6 52.2c14.2 6 30.4-2.9 33-18.2l72-432C515 7.8 493.3-6.8 476 3.2z"},child:[]}]})(e)}function BG(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M43.246 466.142c-58.43-60.289-57.341-157.511 1.386-217.581L254.392 34c44.316-45.332 116.351-45.336 160.671 0 43.89 44.894 43.943 117.329 0 162.276L232.214 383.128c-29.855 30.537-78.633 30.111-107.982-.998-28.275-29.97-27.368-77.473 1.452-106.953l143.743-146.835c6.182-6.314 16.312-6.422 22.626-.241l22.861 22.379c6.315 6.182 6.422 16.312.241 22.626L171.427 319.927c-4.932 5.045-5.236 13.428-.648 18.292 4.372 4.634 11.245 4.711 15.688.165l182.849-186.851c19.613-20.062 19.613-52.725-.011-72.798-19.189-19.627-49.957-19.637-69.154 0L90.39 293.295c-34.763 35.56-35.299 93.12-1.191 128.313 34.01 35.093 88.985 35.137 123.058.286l172.06-175.999c6.177-6.319 16.307-6.433 22.626-.256l22.877 22.364c6.319 6.177 6.434 16.307.256 22.626l-172.06 175.998c-59.576 60.938-155.943 60.216-214.77-.485z"},child:[]}]})(e)}function xl(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M497.9 142.1l-46.1 46.1c-4.7 4.7-12.3 4.7-17 0l-111-111c-4.7-4.7-4.7-12.3 0-17l46.1-46.1c18.7-18.7 49.1-18.7 67.9 0l60.1 60.1c18.8 18.7 18.8 49.1 0 67.9zM284.2 99.8L21.6 362.4.4 483.9c-2.9 16.4 11.4 30.6 27.8 27.8l121.5-21.3 262.6-262.6c4.7-4.7 4.7-12.3 0-17l-111-111c-4.8-4.7-12.4-4.7-17.1 0zM124.1 339.9c-5.5-5.5-5.5-14.3 0-19.8l154-154c5.5-5.5 14.3-5.5 19.8 0s5.5 14.3 0 19.8l-154 154c-5.5 5.5-14.3 5.5-19.8 0zM88 424h48v36.3l-64.5 11.3-31.1-31.1L51.7 376H88v48z"},child:[]}]})(e)}function WG(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M497.39 361.8l-112-48a24 24 0 0 0-28 6.9l-49.6 60.6A370.66 370.66 0 0 1 130.6 204.11l60.6-49.6a23.94 23.94 0 0 0 6.9-28l-48-112A24.16 24.16 0 0 0 122.6.61l-104 24A24 24 0 0 0 0 48c0 256.5 207.9 464 464 464a24 24 0 0 0 23.4-18.6l24-104a24.29 24.29 0 0 0-14.01-27.6z"},child:[]}]})(e)}function Rr(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"},child:[]}]})(e)}function yl(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M448 192V77.25c0-8.49-3.37-16.62-9.37-22.63L393.37 9.37c-6-6-14.14-9.37-22.63-9.37H96C78.33 0 64 14.33 64 32v160c-35.35 0-64 28.65-64 64v112c0 8.84 7.16 16 16 16h48v96c0 17.67 14.33 32 32 32h320c17.67 0 32-14.33 32-32v-96h48c8.84 0 16-7.16 16-16V256c0-35.35-28.65-64-64-64zm-64 256H128v-96h256v96zm0-224H128V64h192v48c0 8.84 7.16 16 16 16h48v96zm48 72c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24z"},child:[]}]})(e)}function Hu(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M0 224h192V32H0v192zM64 96h64v64H64V96zm192-64v192h192V32H256zm128 128h-64V96h64v64zM0 480h192V288H0v192zm64-128h64v64H64v-64zm352-64h32v128h-96v-32h-32v96h-64V288h96v32h64v-32zm0 160h32v32h-32v-32zm-64 0h32v32h-32v-32z"},child:[]}]})(e)}function fE(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M500.33 0h-47.41a12 12 0 0 0-12 12.57l4 82.76A247.42 247.42 0 0 0 256 8C119.34 8 7.9 119.53 8 256.19 8.1 393.07 119.1 504 256 504a247.1 247.1 0 0 0 166.18-63.91 12 12 0 0 0 .48-17.43l-34-34a12 12 0 0 0-16.38-.55A176 176 0 1 1 402.1 157.8l-101.53-4.87a12 12 0 0 0-12.57 12v47.41a12 12 0 0 0 12 12h200.33a12 12 0 0 0 12-12V12a12 12 0 0 0-12-12z"},child:[]}]})(e)}function ta(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z"},child:[]}]})(e)}function za(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"},child:[]}]})(e)}function Rf(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M466.5 83.7l-192-80a48.15 48.15 0 0 0-36.9 0l-192 80C27.7 91.1 16 108.6 16 128c0 198.5 114.5 335.7 221.5 380.3 11.8 4.9 25.1 4.9 36.9 0C360.1 472.6 496 349.3 496 128c0-19.4-11.7-36.9-29.5-44.3zM256.1 446.3l-.1-381 175.9 73.3c-3.3 151.4-82.1 261.1-175.8 307.7z"},child:[]}]})(e)}function eS(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M352 160v-32C352 57.42 294.579 0 224 0 153.42 0 96 57.42 96 128v32H0v272c0 44.183 35.817 80 80 80h288c44.183 0 80-35.817 80-80V160h-96zm-192-32c0-35.29 28.71-64 64-64s64 28.71 64 64v32H160v-32zm160 120c-13.255 0-24-10.745-24-24s10.745-24 24-24 24 10.745 24 24-10.745 24-24 24zm-192 0c-13.255 0-24-10.745-24-24s10.745-24 24-24 24 10.745 24 24-10.745 24-24 24z"},child:[]}]})(e)}function dm(e){return Zt({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M528.12 301.319l47.273-208C578.806 78.301 567.391 64 551.99 64H159.208l-9.166-44.81C147.758 8.021 137.93 0 126.529 0H24C10.745 0 0 10.745 0 24v16c0 13.255 10.745 24 24 24h69.883l70.248 343.435C147.325 417.1 136 435.222 136 456c0 30.928 25.072 56 56 56s56-25.072 56-56c0-15.674-6.447-29.835-16.824-40h209.647C430.447 426.165 424 440.326 424 456c0 30.928 25.072 56 56 56s56-25.072 56-56c0-22.172-12.888-41.332-31.579-50.405l5.517-24.276c3.413-15.018-8.002-29.319-23.403-29.319H218.117l-6.545-32h293.145c11.206 0 20.92-7.754 23.403-18.681z"},child:[]}]})(e)}function Y9(e){return Zt({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M128 352H32c-17.67 0-32 14.33-32 32v96c0 17.67 14.33 32 32 32h96c17.67 0 32-14.33 32-32v-96c0-17.67-14.33-32-32-32zm-24-80h192v48h48v-48h192v48h48v-57.59c0-21.17-17.23-38.41-38.41-38.41H344v-64h40c17.67 0 32-14.33 32-32V32c0-17.67-14.33-32-32-32H256c-17.67 0-32 14.33-32 32v96c0 17.67 14.33 32 32 32h40v64H94.41C73.23 224 56 241.23 56 262.41V320h48v-48zm264 80h-96c-17.67 0-32 14.33-32 32v96c0 17.67 14.33 32 32 32h96c17.67 0 32-14.33 32-32v-96c0-17.67-14.33-32-32-32zm240 0h-96c-17.67 0-32 14.33-32 32v96c0 17.67 14.33 32 32 32h96c17.67 0 32-14.33 32-32v-96c0-17.67-14.33-32-32-32z"},child:[]}]})(e)}function tr(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z"},child:[]}]})(e)}function Ur(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48z"},child:[]}]})(e)}function a0(e){return Zt({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M259.3 17.8L194 150.2 47.9 171.5c-26.2 3.8-36.7 36.1-17.7 54.6l105.7 103-25 145.5c-4.5 26.3 23.2 46 46.4 33.7L288 439.6l130.7 68.7c23.2 12.2 50.9-7.4 46.4-33.7l-25-145.5 105.7-103c19-18.5 8.5-50.8-17.7-54.6L382 150.2 316.7 17.8c-11.7-23.6-45.6-23.9-57.4 0z"},child:[]}]})(e)}function HG(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M312 320h136V56c0-13.3-10.7-24-24-24H24C10.7 32 0 42.7 0 56v400c0 13.3 10.7 24 24 24h264V344c0-13.2 10.8-24 24-24zm129 55l-98 98c-4.5 4.5-10.6 7-17 7h-6V352h128v6.1c0 6.3-2.5 12.4-7 16.9z"},child:[]}]})(e)}function qG(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48z"},child:[]}]})(e)}function VG(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M432 304c0 114.9-93.1 208-208 208S16 418.9 16 304c0-104 76.3-190.2 176-205.5V64h-28c-6.6 0-12-5.4-12-12V12c0-6.6 5.4-12 12-12h120c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-28v34.5c37.5 5.8 71.7 21.6 99.7 44.6l27.5-27.5c4.7-4.7 12.3-4.7 17 0l28.3 28.3c4.7 4.7 4.7 12.3 0 17l-29.4 29.4-.6.6C419.7 223.3 432 262.2 432 304zm-176 36V188.5c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12V340c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12z"},child:[]}]})(e)}function Ma(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M440.65 12.57l4 82.77A247.16 247.16 0 0 0 255.83 8C134.73 8 33.91 94.92 12.29 209.82A12 12 0 0 0 24.09 224h49.05a12 12 0 0 0 11.67-9.26 175.91 175.91 0 0 1 317-56.94l-101.46-4.86a12 12 0 0 0-12.57 12v47.41a12 12 0 0 0 12 12H500a12 12 0 0 0 12-12V12a12 12 0 0 0-12-12h-47.37a12 12 0 0 0-11.98 12.57zM255.83 432a175.61 175.61 0 0 1-146-77.8l101.8 4.87a12 12 0 0 0 12.57-12v-47.4a12 12 0 0 0-12-12H12a12 12 0 0 0-12 12V500a12 12 0 0 0 12 12h47.35a12 12 0 0 0 12-12.6l-4.15-82.57A247.17 247.17 0 0 0 255.83 504c121.11 0 221.93-86.92 243.55-201.82a12 12 0 0 0-11.8-14.18h-49.05a12 12 0 0 0-11.67 9.26A175.86 175.86 0 0 1 255.83 432z"},child:[]}]})(e)}function J9(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zM224 416H64v-96h160v96zm0-160H64v-96h160v96zm224 160H288v-96h160v96zm0-160H288v-96h160v96z"},child:[]}]})(e)}function GG(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M0 252.118V48C0 21.49 21.49 0 48 0h204.118a48 48 0 0 1 33.941 14.059l211.882 211.882c18.745 18.745 18.745 49.137 0 67.882L293.823 497.941c-18.745 18.745-49.137 18.745-67.882 0L14.059 286.059A48 48 0 0 1 0 252.118zM112 64c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48z"},child:[]}]})(e)}function Z9(e){return Zt({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M497.941 225.941L286.059 14.059A48 48 0 0 0 252.118 0H48C21.49 0 0 21.49 0 48v204.118a48 48 0 0 0 14.059 33.941l211.882 211.882c18.744 18.745 49.136 18.746 67.882 0l204.118-204.118c18.745-18.745 18.745-49.137 0-67.882zM112 160c-26.51 0-48-21.49-48-48s21.49-48 48-48 48 21.49 48 48-21.49 48-48 48zm513.941 133.823L421.823 497.941c-18.745 18.745-49.137 18.745-67.882 0l-.36-.36L527.64 323.522c16.999-16.999 26.36-39.6 26.36-63.64s-9.362-46.641-26.36-63.64L331.397 0h48.721a48 48 0 0 1 33.941 14.059l211.882 211.882c18.745 18.745 18.745 49.137 0 67.882z"},child:[]}]})(e)}function bm(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M139.61 35.5a12 12 0 0 0-17 0L58.93 98.81l-22.7-22.12a12 12 0 0 0-17 0L3.53 92.41a12 12 0 0 0 0 17l47.59 47.4a12.78 12.78 0 0 0 17.61 0l15.59-15.62L156.52 69a12.09 12.09 0 0 0 .09-17zm0 159.19a12 12 0 0 0-17 0l-63.68 63.72-22.7-22.1a12 12 0 0 0-17 0L3.53 252a12 12 0 0 0 0 17L51 316.5a12.77 12.77 0 0 0 17.6 0l15.7-15.69 72.2-72.22a12 12 0 0 0 .09-16.9zM64 368c-26.49 0-48.59 21.5-48.59 48S37.53 464 64 464a48 48 0 0 0 0-96zm432 16H208a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h288a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H208a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h288a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H208a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h288a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(e)}function sk(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M296 32h192c13.255 0 24 10.745 24 24v160c0 13.255-10.745 24-24 24H296c-13.255 0-24-10.745-24-24V56c0-13.255 10.745-24 24-24zm-80 0H24C10.745 32 0 42.745 0 56v160c0 13.255 10.745 24 24 24h192c13.255 0 24-10.745 24-24V56c0-13.255-10.745-24-24-24zM0 296v160c0 13.255 10.745 24 24 24h192c13.255 0 24-10.745 24-24V296c0-13.255-10.745-24-24-24H24c-13.255 0-24 10.745-24 24zm296 184h192c13.255 0 24-10.745 24-24V296c0-13.255-10.745-24-24-24H296c-13.255 0-24 10.745-24 24v160c0 13.255 10.745 24 24 24z"},child:[]}]})(e)}function vf(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M104 224H24c-13.255 0-24 10.745-24 24v240c0 13.255 10.745 24 24 24h80c13.255 0 24-10.745 24-24V248c0-13.255-10.745-24-24-24zM64 472c-13.255 0-24-10.745-24-24s10.745-24 24-24 24 10.745 24 24-10.745 24-24 24zM384 81.452c0 42.416-25.97 66.208-33.277 94.548h101.723c33.397 0 59.397 27.746 59.553 58.098.084 17.938-7.546 37.249-19.439 49.197l-.11.11c9.836 23.337 8.237 56.037-9.308 79.469 8.681 25.895-.069 57.704-16.382 74.757 4.298 17.598 2.244 32.575-6.148 44.632C440.202 511.587 389.616 512 346.839 512l-2.845-.001c-48.287-.017-87.806-17.598-119.56-31.725-15.957-7.099-36.821-15.887-52.651-16.178-6.54-.12-11.783-5.457-11.783-11.998v-213.77c0-3.2 1.282-6.271 3.558-8.521 39.614-39.144 56.648-80.587 89.117-113.111 14.804-14.832 20.188-37.236 25.393-58.902C282.515 39.293 291.817 0 312 0c24 0 72 8 72 81.452z"},child:[]}]})(e)}function pr(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z"},child:[]}]})(e)}function ht(e){return Zt({attr:{viewBox:"0 0 352 512"},child:[{tag:"path",attr:{d:"M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"},child:[]}]})(e)}function X9(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M501.1 395.7L384 278.6c-23.1-23.1-57.6-27.6-85.4-13.9L192 158.1V96L64 0 0 64l96 128h62.1l106.6 106.6c-13.6 27.8-9.2 62.3 13.9 85.4l117.1 117.1c14.6 14.6 38.2 14.6 52.7 0l52.7-52.7c14.5-14.6 14.5-38.2 0-52.7zM331.7 225c28.3 0 54.9 11 74.9 31l19.4 19.4c15.8-6.9 30.8-16.5 43.8-29.5 37.1-37.1 49.7-89.3 37.9-136.7-2.2-9-13.5-12.1-20.1-5.5l-74.4 74.4-67.9-11.3L334 98.9l74.4-74.4c6.6-6.6 3.4-17.9-5.7-20.2-47.4-11.7-99.6.9-136.6 37.9-28.5 28.5-41.9 66.1-41.2 103.6l82.1 82.1c8.1-1.9 16.5-2.9 24.7-2.9zm-103.9 82l-56.7-56.7L18.7 402.8c-25 25-25 65.5 0 90.5s65.5 25 90.5 0l123.6-123.6c-7.6-19.9-9.9-41.6-5-62.7zM64 472c-13.2 0-24-10.8-24-24 0-13.3 10.7-24 24-24s24 10.7 24 24c0 13.2-10.7 24-24 24z"},child:[]}]})(e)}function KG(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M32 464a48 48 0 0 0 48 48h288a48 48 0 0 0 48-48V128H32zm272-256a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zm-96 0a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zm-96 0a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zM432 32H312l-9.4-18.7A24 24 0 0 0 281.1 0H166.8a23.72 23.72 0 0 0-21.4 13.3L136 32H16A16 16 0 0 0 0 48v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16z"},child:[]}]})(e)}function wr(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M432 32H312l-9.4-18.7A24 24 0 0 0 281.1 0H166.8a23.72 23.72 0 0 0-21.4 13.3L136 32H16A16 16 0 0 0 0 48v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16zM53.2 467a48 48 0 0 0 47.9 45h245.8a48 48 0 0 0 47.9-45L416 128H32z"},child:[]}]})(e)}function G1(e){return Zt({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M624 352h-16V243.9c0-12.7-5.1-24.9-14.1-33.9L494 110.1c-9-9-21.2-14.1-33.9-14.1H416V48c0-26.5-21.5-48-48-48H48C21.5 0 0 21.5 0 48v320c0 26.5 21.5 48 48 48h16c0 53 43 96 96 96s96-43 96-96h128c0 53 43 96 96 96s96-43 96-96h48c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zM160 464c-26.5 0-48-21.5-48-48s21.5-48 48-48 48 21.5 48 48-21.5 48-48 48zm320 0c-26.5 0-48-21.5-48-48s21.5-48 48-48 48 21.5 48 48-21.5 48-48 48zm80-208H416V144h44.1l99.9 99.9V256z"},child:[]}]})(e)}function Tv(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M296 384h-80c-13.3 0-24-10.7-24-24V192h-87.7c-17.8 0-26.7-21.5-14.1-34.1L242.3 5.7c7.5-7.5 19.8-7.5 27.3 0l152.2 152.2c12.6 12.6 3.7 34.1-14.1 34.1H320v168c0 13.3-10.7 24-24 24zm216-8v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h136v8c0 30.9 25.1 56 56 56h80c30.9 0 56-25.1 56-56v-8h136c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"},child:[]}]})(e)}function xE(e){return Zt({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M496 224c-79.6 0-144 64.4-144 144s64.4 144 144 144 144-64.4 144-144-64.4-144-144-144zm64 150.3c0 5.3-4.4 9.7-9.7 9.7h-60.6c-5.3 0-9.7-4.4-9.7-9.7v-76.6c0-5.3 4.4-9.7 9.7-9.7h12.6c5.3 0 9.7 4.4 9.7 9.7V352h38.3c5.3 0 9.7 4.4 9.7 9.7v12.6zM320 368c0-27.8 6.7-54.1 18.2-77.5-8-1.5-16.2-2.5-24.6-2.5h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h347.1c-45.3-31.9-75.1-84.5-75.1-144zm-96-112c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128z"},child:[]}]})(e)}function yE(e){return Zt({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M610.5 373.3c2.6-14.1 2.6-28.5 0-42.6l25.8-14.9c3-1.7 4.3-5.2 3.3-8.5-6.7-21.6-18.2-41.2-33.2-57.4-2.3-2.5-6-3.1-9-1.4l-25.8 14.9c-10.9-9.3-23.4-16.5-36.9-21.3v-29.8c0-3.4-2.4-6.4-5.7-7.1-22.3-5-45-4.8-66.2 0-3.3.7-5.7 3.7-5.7 7.1v29.8c-13.5 4.8-26 12-36.9 21.3l-25.8-14.9c-2.9-1.7-6.7-1.1-9 1.4-15 16.2-26.5 35.8-33.2 57.4-1 3.3.4 6.8 3.3 8.5l25.8 14.9c-2.6 14.1-2.6 28.5 0 42.6l-25.8 14.9c-3 1.7-4.3 5.2-3.3 8.5 6.7 21.6 18.2 41.1 33.2 57.4 2.3 2.5 6 3.1 9 1.4l25.8-14.9c10.9 9.3 23.4 16.5 36.9 21.3v29.8c0 3.4 2.4 6.4 5.7 7.1 22.3 5 45 4.8 66.2 0 3.3-.7 5.7-3.7 5.7-7.1v-29.8c13.5-4.8 26-12 36.9-21.3l25.8 14.9c2.9 1.7 6.7 1.1 9-1.4 15-16.2 26.5-35.8 33.2-57.4 1-3.3-.4-6.8-3.3-8.5l-25.8-14.9zM496 400.5c-26.8 0-48.5-21.8-48.5-48.5s21.8-48.5 48.5-48.5 48.5 21.8 48.5 48.5-21.7 48.5-48.5 48.5zM224 256c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm201.2 226.5c-2.3-1.2-4.6-2.6-6.8-3.9l-7.9 4.6c-6 3.4-12.8 5.3-19.6 5.3-10.9 0-21.4-4.6-28.9-12.6-18.3-19.8-32.3-43.9-40.2-69.6-5.5-17.7 1.9-36.4 17.9-45.7l7.9-4.6c-.1-2.6-.1-5.2 0-7.8l-7.9-4.6c-16-9.2-23.4-28-17.9-45.7.9-2.9 2.2-5.8 3.2-8.7-3.8-.3-7.5-1.2-11.4-1.2h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h352c10.1 0 19.5-3.2 27.2-8.5-1.2-3.8-2-7.7-2-11.8v-9.2z"},child:[]}]})(e)}function Ev(e){return Zt({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M192 256c61.9 0 112-50.1 112-112S253.9 32 192 32 80 82.1 80 144s50.1 112 112 112zm76.8 32h-8.3c-20.8 10-43.9 16-68.5 16s-47.6-6-68.5-16h-8.3C51.6 288 0 339.6 0 403.2V432c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48v-28.8c0-63.6-51.6-115.2-115.2-115.2zM480 256c53 0 96-43 96-96s-43-96-96-96-96 43-96 96 43 96 96 96zm48 32h-3.8c-13.9 4.8-28.6 8-44.2 8s-30.3-3.2-44.2-8H432c-20.4 0-39.2 5.9-55.7 15.4 24.4 26.3 39.7 61.2 39.7 99.8v38.4c0 2.2-.5 4.3-.6 6.4H592c26.5 0 48-21.5 48-48 0-61.9-50.1-112-112-112z"},child:[]}]})(e)}function YG(e){return Zt({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M624 208h-64v-64c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v64h-64c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h64v64c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-64h64c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm-400 48c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm89.6 32h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-41.6c0-74.2-60.2-134.4-134.4-134.4z"},child:[]}]})(e)}function JG(e){return Zt({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M630.6 364.9l-90.3-90.2c-12-12-28.3-18.7-45.3-18.7h-79.3c-17.7 0-32 14.3-32 32v79.2c0 17 6.7 33.2 18.7 45.2l90.3 90.2c12.5 12.5 32.8 12.5 45.3 0l92.5-92.5c12.6-12.5 12.6-32.7.1-45.2zm-182.8-21c-13.3 0-24-10.7-24-24s10.7-24 24-24 24 10.7 24 24c0 13.2-10.7 24-24 24zm-223.8-88c70.7 0 128-57.3 128-128C352 57.3 294.7 0 224 0S96 57.3 96 128c0 70.6 57.3 127.9 128 127.9zm127.8 111.2V294c-12.2-3.6-24.9-6.2-38.2-6.2h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 287.9 0 348.1 0 422.3v41.6c0 26.5 21.5 48 48 48h352c15.5 0 29.1-7.5 37.9-18.9l-58-58c-18.1-18.1-28.1-42.2-28.1-67.9z"},child:[]}]})(e)}function Av(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M224 256c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm95.8 32.6L272 480l-32-136 32-56h-96l32 56-32 136-47.8-191.4C56.9 292 0 350.3 0 422.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-41.6c0-72.1-56.9-130.4-128.2-133.8z"},child:[]}]})(e)}function nn(e){return Zt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M224 256c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm89.6 32h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-41.6c0-74.2-60.2-134.4-134.4-134.4z"},child:[]}]})(e)}function $d(e){return Zt({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M96 224c35.3 0 64-28.7 64-64s-28.7-64-64-64-64 28.7-64 64 28.7 64 64 64zm448 0c35.3 0 64-28.7 64-64s-28.7-64-64-64-64 28.7-64 64 28.7 64 64 64zm32 32h-64c-17.6 0-33.5 7.1-45.1 18.6 40.3 22.1 68.9 62 75.1 109.4h66c17.7 0 32-14.3 32-32v-32c0-35.3-28.7-64-64-64zm-256 0c61.9 0 112-50.1 112-112S381.9 32 320 32 208 82.1 208 144s50.1 112 112 112zm76.8 32h-8.3c-20.8 10-43.9 16-68.5 16s-47.6-6-68.5-16h-8.3C179.6 288 128 339.6 128 403.2V432c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48v-28.8c0-63.6-51.6-115.2-115.2-115.2zm-223.7-13.4C161.5 263.1 145.6 256 128 256H64c-35.3 0-64 28.7-64 64v32c0 17.7 14.3 32 32 32h65.9c6.3-47.4 34.9-87.3 75.2-109.4z"},child:[]}]})(e)}function vm(e){return Zt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M507.73 109.1c-2.24-9.03-13.54-12.09-20.12-5.51l-74.36 74.36-67.88-11.31-11.31-67.88 74.36-74.36c6.62-6.62 3.43-17.9-5.66-20.16-47.38-11.74-99.55.91-136.58 37.93-39.64 39.64-50.55 97.1-34.05 147.2L18.74 402.76c-24.99 24.99-24.99 65.51 0 90.5 24.99 24.99 65.51 24.99 90.5 0l213.21-213.21c50.12 16.71 107.47 5.68 147.37-34.22 37.07-37.07 49.7-89.32 37.91-136.73zM64 472c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24z"},child:[]}]})(e)}var Ov={};Ov.version="0.18.5";var Q9=1252,ZG=[874,932,936,949,950,1250,1251,1252,1253,1254,1255,1256,1257,1258,1e4],eR=function(e){ZG.indexOf(e)!=-1&&(Q9=e)};function XG(){eR(1252)}var Kf=function(e){eR(e)};function QG(){Kf(1200),XG()}var cb=function(r){return String.fromCharCode(r)},bE=function(r){return String.fromCharCode(r)},Pv,qu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Yf(e){for(var r="",a=0,s=0,n=0,i=0,o=0,l=0,c=0,u=0;u<e.length;)a=e.charCodeAt(u++),i=a>>2,s=e.charCodeAt(u++),o=(a&3)<<4|s>>4,n=e.charCodeAt(u++),l=(s&15)<<2|n>>6,c=n&63,isNaN(s)?l=c=64:isNaN(n)&&(c=64),r+=qu.charAt(i)+qu.charAt(o)+qu.charAt(l)+qu.charAt(c);return r}function Kd(e){var r="",a=0,s=0,n=0,i=0,o=0,l=0,c=0;e=e.replace(/[^\w\+\/\=]/g,"");for(var u=0;u<e.length;)i=qu.indexOf(e.charAt(u++)),o=qu.indexOf(e.charAt(u++)),a=i<<2|o>>4,r+=String.fromCharCode(a),l=qu.indexOf(e.charAt(u++)),s=(o&15)<<4|l>>2,l!==64&&(r+=String.fromCharCode(s)),c=qu.indexOf(e.charAt(u++)),n=(l&3)<<6|c,c!==64&&(r+=String.fromCharCode(n));return r}var Ia=(function(){return typeof Buffer!="undefined"&&typeof process!="undefined"&&typeof process.versions!="undefined"&&!!process.versions.node})(),ru=(function(){if(typeof Buffer!="undefined"){var e=!Buffer.from;if(!e)try{Buffer.from("foo","utf8")}catch(r){e=!0}return e?function(r,a){return a?new Buffer(r,a):new Buffer(r)}:Buffer.from.bind(Buffer)}return function(){}})();function wm(e){return Ia?Buffer.alloc?Buffer.alloc(e):new Buffer(e):typeof Uint8Array!="undefined"?new Uint8Array(e):new Array(e)}function vE(e){return Ia?Buffer.allocUnsafe?Buffer.allocUnsafe(e):new Buffer(e):typeof Uint8Array!="undefined"?new Uint8Array(e):new Array(e)}var Vl=function(r){return Ia?ru(r,"binary"):r.split("").map(function(a){return a.charCodeAt(0)&255})};function K1(e){if(typeof ArrayBuffer=="undefined")return Vl(e);for(var r=new ArrayBuffer(e.length),a=new Uint8Array(r),s=0;s!=e.length;++s)a[s]=e.charCodeAt(s)&255;return r}function kx(e){if(Array.isArray(e))return e.map(function(s){return String.fromCharCode(s)}).join("");for(var r=[],a=0;a<e.length;++a)r[a]=String.fromCharCode(e[a]);return r.join("")}function eK(e){if(typeof Uint8Array=="undefined")throw new Error("Unsupported");return new Uint8Array(e)}var Qn=Ia?function(e){return Buffer.concat(e.map(function(r){return Buffer.isBuffer(r)?r:ru(r)}))}:function(e){if(typeof Uint8Array!="undefined"){var r=0,a=0;for(r=0;r<e.length;++r)a+=e[r].length;var s=new Uint8Array(a),n=0;for(r=0,a=0;r<e.length;a+=n,++r)if(n=e[r].length,e[r]instanceof Uint8Array)s.set(e[r],a);else{if(typeof e[r]=="string")throw"wtf";s.set(new Uint8Array(e[r]),a)}return s}return[].concat.apply([],e.map(function(i){return Array.isArray(i)?i:[].slice.call(i)}))};function tK(e){for(var r=[],a=0,s=e.length+250,n=wm(e.length+255),i=0;i<e.length;++i){var o=e.charCodeAt(i);if(o<128)n[a++]=o;else if(o<2048)n[a++]=192|o>>6&31,n[a++]=128|o&63;else if(o>=55296&&o<57344){o=(o&1023)+64;var l=e.charCodeAt(++i)&1023;n[a++]=240|o>>8&7,n[a++]=128|o>>2&63,n[a++]=128|l>>6&15|(o&3)<<4,n[a++]=128|l&63}else n[a++]=224|o>>12&15,n[a++]=128|o>>6&63,n[a++]=128|o&63;a>s&&(r.push(n.slice(0,a)),a=0,n=wm(65535),s=65530)}return r.push(n.slice(0,a)),Qn(r)}var Mf=/\u0000/g,db=/[\u0001-\u0006]/g;function fp(e){for(var r="",a=e.length-1;a>=0;)r+=e.charAt(a--);return r}function Xl(e,r){var a=""+e;return a.length>=r?a:Ws("0",r-a.length)+a}function tS(e,r){var a=""+e;return a.length>=r?a:Ws(" ",r-a.length)+a}function Dv(e,r){var a=""+e;return a.length>=r?a:a+Ws(" ",r-a.length)}function rK(e,r){var a=""+Math.round(e);return a.length>=r?a:Ws("0",r-a.length)+a}function aK(e,r){var a=""+e;return a.length>=r?a:Ws("0",r-a.length)+a}var wE=Math.pow(2,32);function Dh(e,r){if(e>wE||e<-wE)return rK(e,r);var a=Math.round(e);return aK(a,r)}function Rv(e,r){return r=r||0,e.length>=7+r&&(e.charCodeAt(r)|32)===103&&(e.charCodeAt(r+1)|32)===101&&(e.charCodeAt(r+2)|32)===110&&(e.charCodeAt(r+3)|32)===101&&(e.charCodeAt(r+4)|32)===114&&(e.charCodeAt(r+5)|32)===97&&(e.charCodeAt(r+6)|32)===108}var jE=[["Sun","Sunday"],["Mon","Monday"],["Tue","Tuesday"],["Wed","Wednesday"],["Thu","Thursday"],["Fri","Friday"],["Sat","Saturday"]],nk=[["J","Jan","January"],["F","Feb","February"],["M","Mar","March"],["A","Apr","April"],["M","May","May"],["J","Jun","June"],["J","Jul","July"],["A","Aug","August"],["S","Sep","September"],["O","Oct","October"],["N","Nov","November"],["D","Dec","December"]];function sK(e){return e||(e={}),e[0]="General",e[1]="0",e[2]="0.00",e[3]="#,##0",e[4]="#,##0.00",e[9]="0%",e[10]="0.00%",e[11]="0.00E+00",e[12]="# ?/?",e[13]="# ??/??",e[14]="m/d/yy",e[15]="d-mmm-yy",e[16]="d-mmm",e[17]="mmm-yy",e[18]="h:mm AM/PM",e[19]="h:mm:ss AM/PM",e[20]="h:mm",e[21]="h:mm:ss",e[22]="m/d/yy h:mm",e[37]="#,##0 ;(#,##0)",e[38]="#,##0 ;[Red](#,##0)",e[39]="#,##0.00;(#,##0.00)",e[40]="#,##0.00;[Red](#,##0.00)",e[45]="mm:ss",e[46]="[h]:mm:ss",e[47]="mmss.0",e[48]="##0.0E+0",e[49]="@",e[56]='"上午/下午 "hh"時"mm"分"ss"秒 "',e}var Hs={0:"General",1:"0",2:"0.00",3:"#,##0",4:"#,##0.00",9:"0%",10:"0.00%",11:"0.00E+00",12:"# ?/?",13:"# ??/??",14:"m/d/yy",15:"d-mmm-yy",16:"d-mmm",17:"mmm-yy",18:"h:mm AM/PM",19:"h:mm:ss AM/PM",20:"h:mm",21:"h:mm:ss",22:"m/d/yy h:mm",37:"#,##0 ;(#,##0)",38:"#,##0 ;[Red](#,##0)",39:"#,##0.00;(#,##0.00)",40:"#,##0.00;[Red](#,##0.00)",45:"mm:ss",46:"[h]:mm:ss",47:"mmss.0",48:"##0.0E+0",49:"@",56:'"上午/下午 "hh"時"mm"分"ss"秒 "'},_E={5:37,6:38,7:39,8:40,23:0,24:0,25:0,26:0,27:14,28:14,29:14,30:14,31:14,50:14,51:14,52:14,53:14,54:14,55:14,56:14,57:14,58:14,59:1,60:2,61:3,62:4,67:9,68:10,69:12,70:13,71:14,72:14,73:15,74:16,75:17,76:20,77:21,78:22,79:45,80:46,81:47,82:0},nK={5:'"$"#,##0_);\\("$"#,##0\\)',63:'"$"#,##0_);\\("$"#,##0\\)',6:'"$"#,##0_);[Red]\\("$"#,##0\\)',64:'"$"#,##0_);[Red]\\("$"#,##0\\)',7:'"$"#,##0.00_);\\("$"#,##0.00\\)',65:'"$"#,##0.00_);\\("$"#,##0.00\\)',8:'"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',66:'"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',41:'_(* #,##0_);_(* \\(#,##0\\);_(* "-"_);_(@_)',42:'_("$"* #,##0_);_("$"* \\(#,##0\\);_("$"* "-"_);_(@_)',43:'_(* #,##0.00_);_(* \\(#,##0.00\\);_(* "-"??_);_(@_)',44:'_("$"* #,##0.00_);_("$"* \\(#,##0.00\\);_("$"* "-"??_);_(@_)'};function Mv(e,r,a){for(var s=e<0?-1:1,n=e*s,i=0,o=1,l=0,c=1,u=0,h=0,f=Math.floor(n);u<r&&(f=Math.floor(n),l=f*o+i,h=f*u+c,!(n-f<5e-8));)n=1/(n-f),i=o,o=l,c=u,u=h;if(h>r&&(u>r?(h=c,l=i):(h=u,l=o)),!a)return[0,s*l,h];var y=Math.floor(s*l/h);return[y,s*l-y*h,h]}function ub(e,r,a){if(e>2958465||e<0)return null;var s=e|0,n=Math.floor(86400*(e-s)),i=0,o=[],l={D:s,T:n,u:86400*(e-s)-n,y:0,m:0,d:0,H:0,M:0,S:0,q:0};if(Math.abs(l.u)<1e-6&&(l.u=0),r&&r.date1904&&(s+=1462),l.u>.9999&&(l.u=0,++n==86400&&(l.T=n=0,++s,++l.D)),s===60)o=a?[1317,10,29]:[1900,2,29],i=3;else if(s===0)o=a?[1317,8,29]:[1900,1,0],i=6;else{s>60&&--s;var c=new Date(1900,0,1);c.setDate(c.getDate()+s-1),o=[c.getFullYear(),c.getMonth()+1,c.getDate()],i=c.getDay(),s<60&&(i=(i+6)%7),a&&(i=mK(c,o))}return l.y=o[0],l.m=o[1],l.d=o[2],l.S=n%60,n=Math.floor(n/60),l.M=n%60,n=Math.floor(n/60),l.H=n,l.q=i,l}var tR=new Date(1899,11,31,0,0,0),iK=tR.getTime(),oK=new Date(1900,2,1,0,0,0);function rR(e,r){var a=e.getTime();return r?a-=1461*24*60*60*1e3:e>=oK&&(a+=1440*60*1e3),(a-(iK+(e.getTimezoneOffset()-tR.getTimezoneOffset())*6e4))/(1440*60*1e3)}function rS(e){return e.indexOf(".")==-1?e:e.replace(/(?:\.0*|(\.\d*[1-9])0+)$/,"$1")}function lK(e){return e.indexOf("E")==-1?e:e.replace(/(?:\.0*|(\.\d*[1-9])0+)[Ee]/,"$1E").replace(/(E[+-])(\d)$/,"$10$2")}function cK(e){var r=e<0?12:11,a=rS(e.toFixed(12));return a.length<=r||(a=e.toPrecision(10),a.length<=r)?a:e.toExponential(5)}function dK(e){var r=rS(e.toFixed(11));return r.length>(e<0?12:11)||r==="0"||r==="-0"?e.toPrecision(6):r}function uK(e){var r=Math.floor(Math.log(Math.abs(e))*Math.LOG10E),a;return r>=-4&&r<=-1?a=e.toPrecision(10+r):Math.abs(r)<=9?a=cK(e):r===10?a=e.toFixed(10).substr(0,12):a=dK(e),rS(lK(a.toUpperCase()))}function _N(e,r){switch(typeof e){case"string":return e;case"boolean":return e?"TRUE":"FALSE";case"number":return(e|0)===e?e.toString(10):uK(e);case"undefined":return"";case"object":if(e==null)return"";if(e instanceof Date)return Xu(14,rR(e,r&&r.date1904),r)}throw new Error("unsupported value in General format: "+e)}function mK(e,r){r[0]-=581;var a=e.getDay();return e<60&&(a=(a+6)%7),a}function hK(e,r,a,s){var n="",i=0,o=0,l=a.y,c,u=0;switch(e){case 98:l=a.y+543;case 121:switch(r.length){case 1:case 2:c=l%100,u=2;break;default:c=l%1e4,u=4;break}break;case 109:switch(r.length){case 1:case 2:c=a.m,u=r.length;break;case 3:return nk[a.m-1][1];case 5:return nk[a.m-1][0];default:return nk[a.m-1][2]}break;case 100:switch(r.length){case 1:case 2:c=a.d,u=r.length;break;case 3:return jE[a.q][0];default:return jE[a.q][1]}break;case 104:switch(r.length){case 1:case 2:c=1+(a.H+11)%12,u=r.length;break;default:throw"bad hour format: "+r}break;case 72:switch(r.length){case 1:case 2:c=a.H,u=r.length;break;default:throw"bad hour format: "+r}break;case 77:switch(r.length){case 1:case 2:c=a.M,u=r.length;break;default:throw"bad minute format: "+r}break;case 115:if(r!="s"&&r!="ss"&&r!=".0"&&r!=".00"&&r!=".000")throw"bad second format: "+r;return a.u===0&&(r=="s"||r=="ss")?Xl(a.S,r.length):(s>=2?o=s===3?1e3:100:o=s===1?10:1,i=Math.round(o*(a.S+a.u)),i>=60*o&&(i=0),r==="s"?i===0?"0":""+i/o:(n=Xl(i,2+s),r==="ss"?n.substr(0,2):"."+n.substr(2,r.length-1)));case 90:switch(r){case"[h]":case"[hh]":c=a.D*24+a.H;break;case"[m]":case"[mm]":c=(a.D*24+a.H)*60+a.M;break;case"[s]":case"[ss]":c=((a.D*24+a.H)*60+a.M)*60+Math.round(a.S+a.u);break;default:throw"bad abstime format: "+r}u=r.length===3?1:2;break;case 101:c=l,u=1;break}var h=u>0?Xl(c,u):"";return h}function Vu(e){var r=3;if(e.length<=r)return e;for(var a=e.length%r,s=e.substr(0,a);a!=e.length;a+=r)s+=(s.length>0?",":"")+e.substr(a,r);return s}var aR=/%/g;function pK(e,r,a){var s=r.replace(aR,""),n=r.length-s.length;return Ud(e,s,a*Math.pow(10,2*n))+Ws("%",n)}function gK(e,r,a){for(var s=r.length-1;r.charCodeAt(s-1)===44;)--s;return Ud(e,r.substr(0,s),a/Math.pow(10,3*(r.length-s)))}function sR(e,r){var a,s=e.indexOf("E")-e.indexOf(".")-1;if(e.match(/^#+0.0E\+0$/)){if(r==0)return"0.0E+0";if(r<0)return"-"+sR(e,-r);var n=e.indexOf(".");n===-1&&(n=e.indexOf("E"));var i=Math.floor(Math.log(r)*Math.LOG10E)%n;if(i<0&&(i+=n),a=(r/Math.pow(10,i)).toPrecision(s+1+(n+i)%n),a.indexOf("e")===-1){var o=Math.floor(Math.log(r)*Math.LOG10E);for(a.indexOf(".")===-1?a=a.charAt(0)+"."+a.substr(1)+"E+"+(o-a.length+i):a+="E+"+(o-i);a.substr(0,2)==="0.";)a=a.charAt(0)+a.substr(2,n)+"."+a.substr(2+n),a=a.replace(/^0+([1-9])/,"$1").replace(/^0+\./,"0.");a=a.replace(/\+-/,"-")}a=a.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/,function(l,c,u,h){return c+u+h.substr(0,(n+i)%n)+"."+h.substr(i)+"E"})}else a=r.toExponential(s);return e.match(/E\+00$/)&&a.match(/e[+-]\d$/)&&(a=a.substr(0,a.length-1)+"0"+a.charAt(a.length-1)),e.match(/E\-/)&&a.match(/e\+/)&&(a=a.replace(/e\+/,"e")),a.replace("e","E")}var nR=/# (\?+)( ?)\/( ?)(\d+)/;function fK(e,r,a){var s=parseInt(e[4],10),n=Math.round(r*s),i=Math.floor(n/s),o=n-i*s,l=s;return a+(i===0?"":""+i)+" "+(o===0?Ws(" ",e[1].length+1+e[4].length):tS(o,e[1].length)+e[2]+"/"+e[3]+Xl(l,e[4].length))}function xK(e,r,a){return a+(r===0?"":""+r)+Ws(" ",e[1].length+2+e[4].length)}var iR=/^#*0*\.([0#]+)/,oR=/\).*[0#]/,lR=/\(###\) ###\\?-####/;function Ai(e){for(var r="",a,s=0;s!=e.length;++s)switch(a=e.charCodeAt(s)){case 35:break;case 63:r+=" ";break;case 48:r+="0";break;default:r+=String.fromCharCode(a)}return r}function kE(e,r){var a=Math.pow(10,r);return""+Math.round(e*a)/a}function NE(e,r){var a=e-Math.floor(e),s=Math.pow(10,r);return r<(""+Math.round(a*s)).length?0:Math.round(a*s)}function yK(e,r){return r<(""+Math.round((e-Math.floor(e))*Math.pow(10,r))).length?1:0}function bK(e){return e<2147483647&&e>-2147483648?""+(e>=0?e|0:e-1|0):""+Math.floor(e)}function dl(e,r,a){if(e.charCodeAt(0)===40&&!r.match(oR)){var s=r.replace(/\( */,"").replace(/ \)/,"").replace(/\)/,"");return a>=0?dl("n",s,a):"("+dl("n",s,-a)+")"}if(r.charCodeAt(r.length-1)===44)return gK(e,r,a);if(r.indexOf("%")!==-1)return pK(e,r,a);if(r.indexOf("E")!==-1)return sR(r,a);if(r.charCodeAt(0)===36)return"$"+dl(e,r.substr(r.charAt(1)==" "?2:1),a);var n,i,o,l,c=Math.abs(a),u=a<0?"-":"";if(r.match(/^00+$/))return u+Dh(c,r.length);if(r.match(/^[#?]+$/))return n=Dh(a,0),n==="0"&&(n=""),n.length>r.length?n:Ai(r.substr(0,r.length-n.length))+n;if(i=r.match(nR))return fK(i,c,u);if(r.match(/^#+0+$/))return u+Dh(c,r.length-r.indexOf("0"));if(i=r.match(iR))return n=kE(a,i[1].length).replace(/^([^\.]+)$/,"$1."+Ai(i[1])).replace(/\.$/,"."+Ai(i[1])).replace(/\.(\d*)$/,function(w,v){return"."+v+Ws("0",Ai(i[1]).length-v.length)}),r.indexOf("0.")!==-1?n:n.replace(/^0\./,".");if(r=r.replace(/^#+([0.])/,"$1"),i=r.match(/^(0*)\.(#*)$/))return u+kE(c,i[2].length).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^(-?\d*)$/,"$1.").replace(/^0\./,i[1].length?"0.":".");if(i=r.match(/^#{1,3},##0(\.?)$/))return u+Vu(Dh(c,0));if(i=r.match(/^#,##0\.([#0]*0)$/))return a<0?"-"+dl(e,r,-a):Vu(""+(Math.floor(a)+yK(a,i[1].length)))+"."+Xl(NE(a,i[1].length),i[1].length);if(i=r.match(/^#,#*,#0/))return dl(e,r.replace(/^#,#*,/,""),a);if(i=r.match(/^([0#]+)(\\?-([0#]+))+$/))return n=fp(dl(e,r.replace(/[\\-]/g,""),a)),o=0,fp(fp(r.replace(/\\/g,"")).replace(/[0#]/g,function(w){return o<n.length?n.charAt(o++):w==="0"?"0":""}));if(r.match(lR))return n=dl(e,"##########",a),"("+n.substr(0,3)+") "+n.substr(3,3)+"-"+n.substr(6);var h="";if(i=r.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/))return o=Math.min(i[4].length,7),l=Mv(c,Math.pow(10,o)-1,!1),n=""+u,h=Ud("n",i[1],l[1]),h.charAt(h.length-1)==" "&&(h=h.substr(0,h.length-1)+"0"),n+=h+i[2]+"/"+i[3],h=Dv(l[2],o),h.length<i[4].length&&(h=Ai(i[4].substr(i[4].length-h.length))+h),n+=h,n;if(i=r.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/))return o=Math.min(Math.max(i[1].length,i[4].length),7),l=Mv(c,Math.pow(10,o)-1,!0),u+(l[0]||(l[1]?"":"0"))+" "+(l[1]?tS(l[1],o)+i[2]+"/"+i[3]+Dv(l[2],o):Ws(" ",2*o+1+i[2].length+i[3].length));if(i=r.match(/^[#0?]+$/))return n=Dh(a,0),r.length<=n.length?n:Ai(r.substr(0,r.length-n.length))+n;if(i=r.match(/^([#0?]+)\.([#0]+)$/)){n=""+a.toFixed(Math.min(i[2].length,10)).replace(/([^0])0+$/,"$1"),o=n.indexOf(".");var f=r.indexOf(".")-o,y=r.length-n.length-f;return Ai(r.substr(0,f)+n+r.substr(r.length-y))}if(i=r.match(/^00,000\.([#0]*0)$/))return o=NE(a,i[1].length),a<0?"-"+dl(e,r,-a):Vu(bK(a)).replace(/^\d,\d{3}$/,"0$&").replace(/^\d*$/,function(w){return"00,"+(w.length<3?Xl(0,3-w.length):"")+w})+"."+Xl(o,i[1].length);switch(r){case"###,##0.00":return dl(e,"#,##0.00",a);case"###,###":case"##,###":case"#,###":var b=Vu(Dh(c,0));return b!=="0"?u+b:"";case"###,###.00":return dl(e,"###,##0.00",a).replace(/^0\./,".");case"#,###.00":return dl(e,"#,##0.00",a).replace(/^0\./,".")}throw new Error("unsupported format |"+r+"|")}function vK(e,r,a){for(var s=r.length-1;r.charCodeAt(s-1)===44;)--s;return Ud(e,r.substr(0,s),a/Math.pow(10,3*(r.length-s)))}function wK(e,r,a){var s=r.replace(aR,""),n=r.length-s.length;return Ud(e,s,a*Math.pow(10,2*n))+Ws("%",n)}function cR(e,r){var a,s=e.indexOf("E")-e.indexOf(".")-1;if(e.match(/^#+0.0E\+0$/)){if(r==0)return"0.0E+0";if(r<0)return"-"+cR(e,-r);var n=e.indexOf(".");n===-1&&(n=e.indexOf("E"));var i=Math.floor(Math.log(r)*Math.LOG10E)%n;if(i<0&&(i+=n),a=(r/Math.pow(10,i)).toPrecision(s+1+(n+i)%n),!a.match(/[Ee]/)){var o=Math.floor(Math.log(r)*Math.LOG10E);a.indexOf(".")===-1?a=a.charAt(0)+"."+a.substr(1)+"E+"+(o-a.length+i):a+="E+"+(o-i),a=a.replace(/\+-/,"-")}a=a.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/,function(l,c,u,h){return c+u+h.substr(0,(n+i)%n)+"."+h.substr(i)+"E"})}else a=r.toExponential(s);return e.match(/E\+00$/)&&a.match(/e[+-]\d$/)&&(a=a.substr(0,a.length-1)+"0"+a.charAt(a.length-1)),e.match(/E\-/)&&a.match(/e\+/)&&(a=a.replace(/e\+/,"e")),a.replace("e","E")}function Tc(e,r,a){if(e.charCodeAt(0)===40&&!r.match(oR)){var s=r.replace(/\( */,"").replace(/ \)/,"").replace(/\)/,"");return a>=0?Tc("n",s,a):"("+Tc("n",s,-a)+")"}if(r.charCodeAt(r.length-1)===44)return vK(e,r,a);if(r.indexOf("%")!==-1)return wK(e,r,a);if(r.indexOf("E")!==-1)return cR(r,a);if(r.charCodeAt(0)===36)return"$"+Tc(e,r.substr(r.charAt(1)==" "?2:1),a);var n,i,o,l,c=Math.abs(a),u=a<0?"-":"";if(r.match(/^00+$/))return u+Xl(c,r.length);if(r.match(/^[#?]+$/))return n=""+a,a===0&&(n=""),n.length>r.length?n:Ai(r.substr(0,r.length-n.length))+n;if(i=r.match(nR))return xK(i,c,u);if(r.match(/^#+0+$/))return u+Xl(c,r.length-r.indexOf("0"));if(i=r.match(iR))return n=(""+a).replace(/^([^\.]+)$/,"$1."+Ai(i[1])).replace(/\.$/,"."+Ai(i[1])),n=n.replace(/\.(\d*)$/,function(w,v){return"."+v+Ws("0",Ai(i[1]).length-v.length)}),r.indexOf("0.")!==-1?n:n.replace(/^0\./,".");if(r=r.replace(/^#+([0.])/,"$1"),i=r.match(/^(0*)\.(#*)$/))return u+(""+c).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^(-?\d*)$/,"$1.").replace(/^0\./,i[1].length?"0.":".");if(i=r.match(/^#{1,3},##0(\.?)$/))return u+Vu(""+c);if(i=r.match(/^#,##0\.([#0]*0)$/))return a<0?"-"+Tc(e,r,-a):Vu(""+a)+"."+Ws("0",i[1].length);if(i=r.match(/^#,#*,#0/))return Tc(e,r.replace(/^#,#*,/,""),a);if(i=r.match(/^([0#]+)(\\?-([0#]+))+$/))return n=fp(Tc(e,r.replace(/[\\-]/g,""),a)),o=0,fp(fp(r.replace(/\\/g,"")).replace(/[0#]/g,function(w){return o<n.length?n.charAt(o++):w==="0"?"0":""}));if(r.match(lR))return n=Tc(e,"##########",a),"("+n.substr(0,3)+") "+n.substr(3,3)+"-"+n.substr(6);var h="";if(i=r.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/))return o=Math.min(i[4].length,7),l=Mv(c,Math.pow(10,o)-1,!1),n=""+u,h=Ud("n",i[1],l[1]),h.charAt(h.length-1)==" "&&(h=h.substr(0,h.length-1)+"0"),n+=h+i[2]+"/"+i[3],h=Dv(l[2],o),h.length<i[4].length&&(h=Ai(i[4].substr(i[4].length-h.length))+h),n+=h,n;if(i=r.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/))return o=Math.min(Math.max(i[1].length,i[4].length),7),l=Mv(c,Math.pow(10,o)-1,!0),u+(l[0]||(l[1]?"":"0"))+" "+(l[1]?tS(l[1],o)+i[2]+"/"+i[3]+Dv(l[2],o):Ws(" ",2*o+1+i[2].length+i[3].length));if(i=r.match(/^[#0?]+$/))return n=""+a,r.length<=n.length?n:Ai(r.substr(0,r.length-n.length))+n;if(i=r.match(/^([#0]+)\.([#0]+)$/)){n=""+a.toFixed(Math.min(i[2].length,10)).replace(/([^0])0+$/,"$1"),o=n.indexOf(".");var f=r.indexOf(".")-o,y=r.length-n.length-f;return Ai(r.substr(0,f)+n+r.substr(r.length-y))}if(i=r.match(/^00,000\.([#0]*0)$/))return a<0?"-"+Tc(e,r,-a):Vu(""+a).replace(/^\d,\d{3}$/,"0$&").replace(/^\d*$/,function(w){return"00,"+(w.length<3?Xl(0,3-w.length):"")+w})+"."+Xl(0,i[1].length);switch(r){case"###,###":case"##,###":case"#,###":var b=Vu(""+c);return b!=="0"?u+b:"";default:if(r.match(/\.[0#?]*$/))return Tc(e,r.slice(0,r.lastIndexOf(".")),a)+Ai(r.slice(r.lastIndexOf(".")))}throw new Error("unsupported format |"+r+"|")}function Ud(e,r,a){return(a|0)===a?Tc(e,r,a):dl(e,r,a)}function jK(e){for(var r=[],a=!1,s=0,n=0;s<e.length;++s)switch(e.charCodeAt(s)){case 34:a=!a;break;case 95:case 42:case 92:++s;break;case 59:r[r.length]=e.substr(n,s-n),n=s+1}if(r[r.length]=e.substr(n),a===!0)throw new Error("Format |"+e+"| unterminated string ");return r}var dR=/\[[HhMmSs\u0E0A\u0E19\u0E17]*\]/;function uR(e){for(var r=0,a="",s="";r<e.length;)switch(a=e.charAt(r)){case"G":Rv(e,r)&&(r+=6),r++;break;case'"':for(;e.charCodeAt(++r)!==34&&r<e.length;);++r;break;case"\\":r+=2;break;case"_":r+=2;break;case"@":++r;break;case"B":case"b":if(e.charAt(r+1)==="1"||e.charAt(r+1)==="2")return!0;case"M":case"D":case"Y":case"H":case"S":case"E":case"m":case"d":case"y":case"h":case"s":case"e":case"g":return!0;case"A":case"a":case"上":if(e.substr(r,3).toUpperCase()==="A/P"||e.substr(r,5).toUpperCase()==="AM/PM"||e.substr(r,5).toUpperCase()==="上午/下午")return!0;++r;break;case"[":for(s=a;e.charAt(r++)!=="]"&&r<e.length;)s+=e.charAt(r);if(s.match(dR))return!0;break;case".":case"0":case"#":for(;r<e.length&&("0#?.,E+-%".indexOf(a=e.charAt(++r))>-1||a=="\\"&&e.charAt(r+1)=="-"&&"0#".indexOf(e.charAt(r+2))>-1););break;case"?":for(;e.charAt(++r)===a;);break;case"*":++r,(e.charAt(r)==" "||e.charAt(r)=="*")&&++r;break;case"(":case")":++r;break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(;r<e.length&&"0123456789".indexOf(e.charAt(++r))>-1;);break;case" ":++r;break;default:++r;break}return!1}function _K(e,r,a,s){for(var n=[],i="",o=0,l="",c="t",u,h,f,y="H";o<e.length;)switch(l=e.charAt(o)){case"G":if(!Rv(e,o))throw new Error("unrecognized character "+l+" in "+e);n[n.length]={t:"G",v:"General"},o+=7;break;case'"':for(i="";(f=e.charCodeAt(++o))!==34&&o<e.length;)i+=String.fromCharCode(f);n[n.length]={t:"t",v:i},++o;break;case"\\":var b=e.charAt(++o),w=b==="("||b===")"?b:"t";n[n.length]={t:w,v:b},++o;break;case"_":n[n.length]={t:"t",v:" "},o+=2;break;case"@":n[n.length]={t:"T",v:r},++o;break;case"B":case"b":if(e.charAt(o+1)==="1"||e.charAt(o+1)==="2"){if(u==null&&(u=ub(r,a,e.charAt(o+1)==="2"),u==null))return"";n[n.length]={t:"X",v:e.substr(o,2)},c=l,o+=2;break}case"M":case"D":case"Y":case"H":case"S":case"E":l=l.toLowerCase();case"m":case"d":case"y":case"h":case"s":case"e":case"g":if(r<0||u==null&&(u=ub(r,a),u==null))return"";for(i=l;++o<e.length&&e.charAt(o).toLowerCase()===l;)i+=l;l==="m"&&c.toLowerCase()==="h"&&(l="M"),l==="h"&&(l=y),n[n.length]={t:l,v:i},c=l;break;case"A":case"a":case"上":var v={t:l,v:l};if(u==null&&(u=ub(r,a)),e.substr(o,3).toUpperCase()==="A/P"?(u!=null&&(v.v=u.H>=12?"P":"A"),v.t="T",y="h",o+=3):e.substr(o,5).toUpperCase()==="AM/PM"?(u!=null&&(v.v=u.H>=12?"PM":"AM"),v.t="T",o+=5,y="h"):e.substr(o,5).toUpperCase()==="上午/下午"?(u!=null&&(v.v=u.H>=12?"下午":"上午"),v.t="T",o+=5,y="h"):(v.t="t",++o),u==null&&v.t==="T")return"";n[n.length]=v,c=l;break;case"[":for(i=l;e.charAt(o++)!=="]"&&o<e.length;)i+=e.charAt(o);if(i.slice(-1)!=="]")throw'unterminated "[" block: |'+i+"|";if(i.match(dR)){if(u==null&&(u=ub(r,a),u==null))return"";n[n.length]={t:"Z",v:i.toLowerCase()},c=i.charAt(1)}else i.indexOf("$")>-1&&(i=(i.match(/\$([^-\[\]]*)/)||[])[1]||"$",uR(e)||(n[n.length]={t:"t",v:i}));break;case".":if(u!=null){for(i=l;++o<e.length&&(l=e.charAt(o))==="0";)i+=l;n[n.length]={t:"s",v:i};break}case"0":case"#":for(i=l;++o<e.length&&"0#?.,E+-%".indexOf(l=e.charAt(o))>-1;)i+=l;n[n.length]={t:"n",v:i};break;case"?":for(i=l;e.charAt(++o)===l;)i+=l;n[n.length]={t:l,v:i},c=l;break;case"*":++o,(e.charAt(o)==" "||e.charAt(o)=="*")&&++o;break;case"(":case")":n[n.length]={t:s===1?"t":l,v:l},++o;break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(i=l;o<e.length&&"0123456789".indexOf(e.charAt(++o))>-1;)i+=e.charAt(o);n[n.length]={t:"D",v:i};break;case" ":n[n.length]={t:l,v:l},++o;break;case"$":n[n.length]={t:"t",v:"$"},++o;break;default:if(",$-+/():!^&'~{}<>=€acfijklopqrtuvwxzP".indexOf(l)===-1)throw new Error("unrecognized character "+l+" in "+e);n[n.length]={t:"t",v:l},++o;break}var k=0,S=0,N;for(o=n.length-1,c="t";o>=0;--o)switch(n[o].t){case"h":case"H":n[o].t=y,c="h",k<1&&(k=1);break;case"s":(N=n[o].v.match(/\.0+$/))&&(S=Math.max(S,N[0].length-1)),k<3&&(k=3);case"d":case"y":case"M":case"e":c=n[o].t;break;case"m":c==="s"&&(n[o].t="M",k<2&&(k=2));break;case"X":break;case"Z":k<1&&n[o].v.match(/[Hh]/)&&(k=1),k<2&&n[o].v.match(/[Mm]/)&&(k=2),k<3&&n[o].v.match(/[Ss]/)&&(k=3)}switch(k){case 0:break;case 1:u.u>=.5&&(u.u=0,++u.S),u.S>=60&&(u.S=0,++u.M),u.M>=60&&(u.M=0,++u.H);break;case 2:u.u>=.5&&(u.u=0,++u.S),u.S>=60&&(u.S=0,++u.M);break}var C="",O;for(o=0;o<n.length;++o)switch(n[o].t){case"t":case"T":case" ":case"D":break;case"X":n[o].v="",n[o].t=";";break;case"d":case"m":case"y":case"h":case"H":case"M":case"s":case"e":case"b":case"Z":n[o].v=hK(n[o].t.charCodeAt(0),n[o].v,u,S),n[o].t="t";break;case"n":case"?":for(O=o+1;n[O]!=null&&((l=n[O].t)==="?"||l==="D"||(l===" "||l==="t")&&n[O+1]!=null&&(n[O+1].t==="?"||n[O+1].t==="t"&&n[O+1].v==="/")||n[o].t==="("&&(l===" "||l==="n"||l===")")||l==="t"&&(n[O].v==="/"||n[O].v===" "&&n[O+1]!=null&&n[O+1].t=="?"));)n[o].v+=n[O].v,n[O]={v:"",t:";"},++O;C+=n[o].v,o=O-1;break;case"G":n[o].t="t",n[o].v=_N(r,a);break}var T="",P,E;if(C.length>0){C.charCodeAt(0)==40?(P=r<0&&C.charCodeAt(0)===45?-r:r,E=Ud("n",C,P)):(P=r<0&&s>1?-r:r,E=Ud("n",C,P),P<0&&n[0]&&n[0].t=="t"&&(E=E.substr(1),n[0].v="-"+n[0].v)),O=E.length-1;var R=n.length;for(o=0;o<n.length;++o)if(n[o]!=null&&n[o].t!="t"&&n[o].v.indexOf(".")>-1){R=o;break}var z=n.length;if(R===n.length&&E.indexOf("E")===-1){for(o=n.length-1;o>=0;--o)n[o]==null||"n?".indexOf(n[o].t)===-1||(O>=n[o].v.length-1?(O-=n[o].v.length,n[o].v=E.substr(O+1,n[o].v.length)):O<0?n[o].v="":(n[o].v=E.substr(0,O+1),O=-1),n[o].t="t",z=o);O>=0&&z<n.length&&(n[z].v=E.substr(0,O+1)+n[z].v)}else if(R!==n.length&&E.indexOf("E")===-1){for(O=E.indexOf(".")-1,o=R;o>=0;--o)if(!(n[o]==null||"n?".indexOf(n[o].t)===-1)){for(h=n[o].v.indexOf(".")>-1&&o===R?n[o].v.indexOf(".")-1:n[o].v.length-1,T=n[o].v.substr(h+1);h>=0;--h)O>=0&&(n[o].v.charAt(h)==="0"||n[o].v.charAt(h)==="#")&&(T=E.charAt(O--)+T);n[o].v=T,n[o].t="t",z=o}for(O>=0&&z<n.length&&(n[z].v=E.substr(0,O+1)+n[z].v),O=E.indexOf(".")+1,o=R;o<n.length;++o)if(!(n[o]==null||"n?(".indexOf(n[o].t)===-1&&o!==R)){for(h=n[o].v.indexOf(".")>-1&&o===R?n[o].v.indexOf(".")+1:0,T=n[o].v.substr(0,h);h<n[o].v.length;++h)O<E.length&&(T+=E.charAt(O++));n[o].v=T,n[o].t="t",z=o}}}for(o=0;o<n.length;++o)n[o]!=null&&"n?".indexOf(n[o].t)>-1&&(P=s>1&&r<0&&o>0&&n[o-1].v==="-"?-r:r,n[o].v=Ud(n[o].t,n[o].v,P),n[o].t="t");var G="";for(o=0;o!==n.length;++o)n[o]!=null&&(G+=n[o].v);return G}var SE=/\[(=|>[=]?|<[>=]?)(-?\d+(?:\.\d*)?)\]/;function CE(e,r){if(r==null)return!1;var a=parseFloat(r[2]);switch(r[1]){case"=":if(e==a)return!0;break;case">":if(e>a)return!0;break;case"<":if(e<a)return!0;break;case"<>":if(e!=a)return!0;break;case">=":if(e>=a)return!0;break;case"<=":if(e<=a)return!0;break}return!1}function kK(e,r){var a=jK(e),s=a.length,n=a[s-1].indexOf("@");if(s<4&&n>-1&&--s,a.length>4)throw new Error("cannot find right format for |"+a.join("|")+"|");if(typeof r!="number")return[4,a.length===4||n>-1?a[a.length-1]:"@"];switch(a.length){case 1:a=n>-1?["General","General","General",a[0]]:[a[0],a[0],a[0],"@"];break;case 2:a=n>-1?[a[0],a[0],a[0],a[1]]:[a[0],a[1],a[0],"@"];break;case 3:a=n>-1?[a[0],a[1],a[0],a[2]]:[a[0],a[1],a[2],"@"];break}var i=r>0?a[0]:r<0?a[1]:a[2];if(a[0].indexOf("[")===-1&&a[1].indexOf("[")===-1)return[s,i];if(a[0].match(/\[[=<>]/)!=null||a[1].match(/\[[=<>]/)!=null){var o=a[0].match(SE),l=a[1].match(SE);return CE(r,o)?[s,a[0]]:CE(r,l)?[s,a[1]]:[s,a[o!=null&&l!=null?2:1]]}return[s,i]}function Xu(e,r,a){a==null&&(a={});var s="";switch(typeof e){case"string":e=="m/d/yy"&&a.dateNF?s=a.dateNF:s=e;break;case"number":e==14&&a.dateNF?s=a.dateNF:s=(a.table!=null?a.table:Hs)[e],s==null&&(s=a.table&&a.table[_E[e]]||Hs[_E[e]]),s==null&&(s=nK[e]||"General");break}if(Rv(s,0))return _N(r,a);r instanceof Date&&(r=rR(r,a.date1904));var n=kK(s,r);if(Rv(n[1]))return _N(r,a);if(r===!0)r="TRUE";else if(r===!1)r="FALSE";else if(r===""||r==null)return"";return _K(n[1],r,a,n[0])}function mR(e,r){if(typeof r!="number"){r=+r||-1;for(var a=0;a<392;++a){if(Hs[a]==null){r<0&&(r=a);continue}if(Hs[a]==e){r=a;break}}r<0&&(r=391)}return Hs[r]=e,r}function Y1(e){for(var r=0;r!=392;++r)e[r]!==void 0&&mR(e[r],r)}function J1(){Hs=sK()}var hR=/[dD]+|[mM]+|[yYeE]+|[Hh]+|[Ss]+/g;function NK(e){var r=typeof e=="number"?Hs[e]:e;return r=r.replace(hR,"(\\d+)"),new RegExp("^"+r+"$")}function SK(e,r,a){var s=-1,n=-1,i=-1,o=-1,l=-1,c=-1;(r.match(hR)||[]).forEach(function(f,y){var b=parseInt(a[y+1],10);switch(f.toLowerCase().charAt(0)){case"y":s=b;break;case"d":i=b;break;case"h":o=b;break;case"s":c=b;break;case"m":o>=0?l=b:n=b;break}}),c>=0&&l==-1&&n>=0&&(l=n,n=-1);var u=(""+(s>=0?s:new Date().getFullYear())).slice(-4)+"-"+("00"+(n>=1?n:1)).slice(-2)+"-"+("00"+(i>=1?i:1)).slice(-2);u.length==7&&(u="0"+u),u.length==8&&(u="20"+u);var h=("00"+(o>=0?o:0)).slice(-2)+":"+("00"+(l>=0?l:0)).slice(-2)+":"+("00"+(c>=0?c:0)).slice(-2);return o==-1&&l==-1&&c==-1?u:s==-1&&n==-1&&i==-1?h:u+"T"+h}var CK=(function(){var e={};e.version="1.2.0";function r(){for(var E=0,R=new Array(256),z=0;z!=256;++z)E=z,E=E&1?-306674912^E>>>1:E>>>1,E=E&1?-306674912^E>>>1:E>>>1,E=E&1?-306674912^E>>>1:E>>>1,E=E&1?-306674912^E>>>1:E>>>1,E=E&1?-306674912^E>>>1:E>>>1,E=E&1?-306674912^E>>>1:E>>>1,E=E&1?-306674912^E>>>1:E>>>1,E=E&1?-306674912^E>>>1:E>>>1,R[z]=E;return typeof Int32Array!="undefined"?new Int32Array(R):R}var a=r();function s(E){var R=0,z=0,G=0,ae=typeof Int32Array!="undefined"?new Int32Array(4096):new Array(4096);for(G=0;G!=256;++G)ae[G]=E[G];for(G=0;G!=256;++G)for(z=E[G],R=256+G;R<4096;R+=256)z=ae[R]=z>>>8^E[z&255];var ee=[];for(G=1;G!=16;++G)ee[G-1]=typeof Int32Array!="undefined"?ae.subarray(G*256,G*256+256):ae.slice(G*256,G*256+256);return ee}var n=s(a),i=n[0],o=n[1],l=n[2],c=n[3],u=n[4],h=n[5],f=n[6],y=n[7],b=n[8],w=n[9],v=n[10],k=n[11],S=n[12],N=n[13],C=n[14];function O(E,R){for(var z=R^-1,G=0,ae=E.length;G<ae;)z=z>>>8^a[(z^E.charCodeAt(G++))&255];return~z}function T(E,R){for(var z=R^-1,G=E.length-15,ae=0;ae<G;)z=C[E[ae++]^z&255]^N[E[ae++]^z>>8&255]^S[E[ae++]^z>>16&255]^k[E[ae++]^z>>>24]^v[E[ae++]]^w[E[ae++]]^b[E[ae++]]^y[E[ae++]]^f[E[ae++]]^h[E[ae++]]^u[E[ae++]]^c[E[ae++]]^l[E[ae++]]^o[E[ae++]]^i[E[ae++]]^a[E[ae++]];for(G+=15;ae<G;)z=z>>>8^a[(z^E[ae++])&255];return~z}function P(E,R){for(var z=R^-1,G=0,ae=E.length,ee=0,ne=0;G<ae;)ee=E.charCodeAt(G++),ee<128?z=z>>>8^a[(z^ee)&255]:ee<2048?(z=z>>>8^a[(z^(192|ee>>6&31))&255],z=z>>>8^a[(z^(128|ee&63))&255]):ee>=55296&&ee<57344?(ee=(ee&1023)+64,ne=E.charCodeAt(G++)&1023,z=z>>>8^a[(z^(240|ee>>8&7))&255],z=z>>>8^a[(z^(128|ee>>2&63))&255],z=z>>>8^a[(z^(128|ne>>6&15|(ee&3)<<4))&255],z=z>>>8^a[(z^(128|ne&63))&255]):(z=z>>>8^a[(z^(224|ee>>12&15))&255],z=z>>>8^a[(z^(128|ee>>6&63))&255],z=z>>>8^a[(z^(128|ee&63))&255]);return~z}return e.table=a,e.bstr=O,e.buf=T,e.str=P,e})(),as=(function(){var r={};r.version="1.2.1";function a(oe,_e){for(var ve=oe.split("/"),Se=_e.split("/"),Ce=0,Pe=0,rt=Math.min(ve.length,Se.length);Ce<rt;++Ce){if(Pe=ve[Ce].length-Se[Ce].length)return Pe;if(ve[Ce]!=Se[Ce])return ve[Ce]<Se[Ce]?-1:1}return ve.length-Se.length}function s(oe){if(oe.charAt(oe.length-1)=="/")return oe.slice(0,-1).indexOf("/")===-1?oe:s(oe.slice(0,-1));var _e=oe.lastIndexOf("/");return _e===-1?oe:oe.slice(0,_e+1)}function n(oe){if(oe.charAt(oe.length-1)=="/")return n(oe.slice(0,-1));var _e=oe.lastIndexOf("/");return _e===-1?oe:oe.slice(_e+1)}function i(oe,_e){typeof _e=="string"&&(_e=new Date(_e));var ve=_e.getHours();ve=ve<<6|_e.getMinutes(),ve=ve<<5|_e.getSeconds()>>>1,oe.write_shift(2,ve);var Se=_e.getFullYear()-1980;Se=Se<<4|_e.getMonth()+1,Se=Se<<5|_e.getDate(),oe.write_shift(2,Se)}function o(oe){var _e=oe.read_shift(2)&65535,ve=oe.read_shift(2)&65535,Se=new Date,Ce=ve&31;ve>>>=5;var Pe=ve&15;ve>>>=4,Se.setMilliseconds(0),Se.setFullYear(ve+1980),Se.setMonth(Pe-1),Se.setDate(Ce);var rt=_e&31;_e>>>=5;var ut=_e&63;return _e>>>=6,Se.setHours(_e),Se.setMinutes(ut),Se.setSeconds(rt<<1),Se}function l(oe){Ro(oe,0);for(var _e={},ve=0;oe.l<=oe.length-4;){var Se=oe.read_shift(2),Ce=oe.read_shift(2),Pe=oe.l+Ce,rt={};switch(Se){case 21589:ve=oe.read_shift(1),ve&1&&(rt.mtime=oe.read_shift(4)),Ce>5&&(ve&2&&(rt.atime=oe.read_shift(4)),ve&4&&(rt.ctime=oe.read_shift(4))),rt.mtime&&(rt.mt=new Date(rt.mtime*1e3));break}oe.l=Pe,_e[Se]=rt}return _e}var c;function u(){return c||(c={})}function h(oe,_e){if(oe[0]==80&&oe[1]==75)return Mt(oe,_e);if((oe[0]|32)==109&&(oe[1]|32)==105)return Ae(oe,_e);if(oe.length<512)throw new Error("CFB file size "+oe.length+" < 512");var ve=3,Se=512,Ce=0,Pe=0,rt=0,ut=0,et=0,nt=[],ct=oe.slice(0,512);Ro(ct,0);var $t=f(ct);switch(ve=$t[0],ve){case 3:Se=512;break;case 4:Se=4096;break;case 0:if($t[1]==0)return Mt(oe,_e);default:throw new Error("Major Version: Expected 3 or 4 saw "+ve)}Se!==512&&(ct=oe.slice(0,Se),Ro(ct,28));var Ut=oe.slice(0,Se);y(ct,ve);var Xt=ct.read_shift(4,"i");if(ve===3&&Xt!==0)throw new Error("# Directory Sectors: Expected 0 saw "+Xt);ct.l+=4,rt=ct.read_shift(4,"i"),ct.l+=4,ct.chk("00100000","Mini Stream Cutoff Size: "),ut=ct.read_shift(4,"i"),Ce=ct.read_shift(4,"i"),et=ct.read_shift(4,"i"),Pe=ct.read_shift(4,"i");for(var pt=-1,Wt=0;Wt<109&&(pt=ct.read_shift(4,"i"),!(pt<0));++Wt)nt[Wt]=pt;var rr=b(oe,Se);k(et,Pe,rr,Se,nt);var Mr=N(rr,rt,nt,Se);Mr[rt].name="!Directory",Ce>0&&ut!==ne&&(Mr[ut].name="!MiniFAT"),Mr[nt[0]].name="!FAT",Mr.fat_addrs=nt,Mr.ssz=Se;var Br={},Yr=[],ma=[],ps=[];C(rt,Mr,rr,Yr,Ce,Br,ma,ut),w(ma,ps,Yr),Yr.shift();var hn={FileIndex:ma,FullPaths:ps};return _e&&_e.raw&&(hn.raw={header:Ut,sectors:rr}),hn}function f(oe){if(oe[oe.l]==80&&oe[oe.l+1]==75)return[0,0];oe.chk(te,"Header Signature: "),oe.l+=16;var _e=oe.read_shift(2,"u");return[oe.read_shift(2,"u"),_e]}function y(oe,_e){var ve=9;switch(oe.l+=2,ve=oe.read_shift(2)){case 9:if(_e!=3)throw new Error("Sector Shift: Expected 9 saw "+ve);break;case 12:if(_e!=4)throw new Error("Sector Shift: Expected 12 saw "+ve);break;default:throw new Error("Sector Shift: Expected 9 or 12 saw "+ve)}oe.chk("0600","Mini Sector Shift: "),oe.chk("000000000000","Reserved: ")}function b(oe,_e){for(var ve=Math.ceil(oe.length/_e)-1,Se=[],Ce=1;Ce<ve;++Ce)Se[Ce-1]=oe.slice(Ce*_e,(Ce+1)*_e);return Se[ve-1]=oe.slice(ve*_e),Se}function w(oe,_e,ve){for(var Se=0,Ce=0,Pe=0,rt=0,ut=0,et=ve.length,nt=[],ct=[];Se<et;++Se)nt[Se]=ct[Se]=Se,_e[Se]=ve[Se];for(;ut<ct.length;++ut)Se=ct[ut],Ce=oe[Se].L,Pe=oe[Se].R,rt=oe[Se].C,nt[Se]===Se&&(Ce!==-1&&nt[Ce]!==Ce&&(nt[Se]=nt[Ce]),Pe!==-1&&nt[Pe]!==Pe&&(nt[Se]=nt[Pe])),rt!==-1&&(nt[rt]=Se),Ce!==-1&&Se!=nt[Se]&&(nt[Ce]=nt[Se],ct.lastIndexOf(Ce)<ut&&ct.push(Ce)),Pe!==-1&&Se!=nt[Se]&&(nt[Pe]=nt[Se],ct.lastIndexOf(Pe)<ut&&ct.push(Pe));for(Se=1;Se<et;++Se)nt[Se]===Se&&(Pe!==-1&&nt[Pe]!==Pe?nt[Se]=nt[Pe]:Ce!==-1&&nt[Ce]!==Ce&&(nt[Se]=nt[Ce]));for(Se=1;Se<et;++Se)if(oe[Se].type!==0){if(ut=Se,ut!=nt[ut])do ut=nt[ut],_e[Se]=_e[ut]+"/"+_e[Se];while(ut!==0&&nt[ut]!==-1&&ut!=nt[ut]);nt[Se]=-1}for(_e[0]+="/",Se=1;Se<et;++Se)oe[Se].type!==2&&(_e[Se]+="/")}function v(oe,_e,ve){for(var Se=oe.start,Ce=oe.size,Pe=[],rt=Se;ve&&Ce>0&&rt>=0;)Pe.push(_e.slice(rt*ee,rt*ee+ee)),Ce-=ee,rt=Z0(ve,rt*4);return Pe.length===0?Ft(0):Qn(Pe).slice(0,oe.size)}function k(oe,_e,ve,Se,Ce){var Pe=ne;if(oe===ne){if(_e!==0)throw new Error("DIFAT chain shorter than expected")}else if(oe!==-1){var rt=ve[oe],ut=(Se>>>2)-1;if(!rt)return;for(var et=0;et<ut&&(Pe=Z0(rt,et*4))!==ne;++et)Ce.push(Pe);k(Z0(rt,Se-4),_e-1,ve,Se,Ce)}}function S(oe,_e,ve,Se,Ce){var Pe=[],rt=[];Ce||(Ce=[]);var ut=Se-1,et=0,nt=0;for(et=_e;et>=0;){Ce[et]=!0,Pe[Pe.length]=et,rt.push(oe[et]);var ct=ve[Math.floor(et*4/Se)];if(nt=et*4&ut,Se<4+nt)throw new Error("FAT boundary crossed: "+et+" 4 "+Se);if(!oe[ct])break;et=Z0(oe[ct],nt)}return{nodes:Pe,data:ME([rt])}}function N(oe,_e,ve,Se){var Ce=oe.length,Pe=[],rt=[],ut=[],et=[],nt=Se-1,ct=0,$t=0,Ut=0,Xt=0;for(ct=0;ct<Ce;++ct)if(ut=[],Ut=ct+_e,Ut>=Ce&&(Ut-=Ce),!rt[Ut]){et=[];var pt=[];for($t=Ut;$t>=0;){pt[$t]=!0,rt[$t]=!0,ut[ut.length]=$t,et.push(oe[$t]);var Wt=ve[Math.floor($t*4/Se)];if(Xt=$t*4&nt,Se<4+Xt)throw new Error("FAT boundary crossed: "+$t+" 4 "+Se);if(!oe[Wt]||($t=Z0(oe[Wt],Xt),pt[$t]))break}Pe[Ut]={nodes:ut,data:ME([et])}}return Pe}function C(oe,_e,ve,Se,Ce,Pe,rt,ut){for(var et=0,nt=Se.length?2:0,ct=_e[oe].data,$t=0,Ut=0,Xt;$t<ct.length;$t+=128){var pt=ct.slice($t,$t+128);Ro(pt,64),Ut=pt.read_shift(2),Xt=oS(pt,0,Ut-nt),Se.push(Xt);var Wt={name:Xt,type:pt.read_shift(1),color:pt.read_shift(1),L:pt.read_shift(4,"i"),R:pt.read_shift(4,"i"),C:pt.read_shift(4,"i"),clsid:pt.read_shift(16),state:pt.read_shift(4,"i"),start:0,size:0},rr=pt.read_shift(2)+pt.read_shift(2)+pt.read_shift(2)+pt.read_shift(2);rr!==0&&(Wt.ct=O(pt,pt.l-8));var Mr=pt.read_shift(2)+pt.read_shift(2)+pt.read_shift(2)+pt.read_shift(2);Mr!==0&&(Wt.mt=O(pt,pt.l-8)),Wt.start=pt.read_shift(4,"i"),Wt.size=pt.read_shift(4,"i"),Wt.size<0&&Wt.start<0&&(Wt.size=Wt.type=0,Wt.start=ne,Wt.name=""),Wt.type===5?(et=Wt.start,Ce>0&&et!==ne&&(_e[et].name="!StreamData")):Wt.size>=4096?(Wt.storage="fat",_e[Wt.start]===void 0&&(_e[Wt.start]=S(ve,Wt.start,_e.fat_addrs,_e.ssz)),_e[Wt.start].name=Wt.name,Wt.content=_e[Wt.start].data.slice(0,Wt.size)):(Wt.storage="minifat",Wt.size<0?Wt.size=0:et!==ne&&Wt.start!==ne&&_e[et]&&(Wt.content=v(Wt,_e[et].data,(_e[ut]||{}).data))),Wt.content&&Ro(Wt.content,0),Pe[Xt]=Wt,rt.push(Wt)}}function O(oe,_e){return new Date((Fo(oe,_e+4)/1e7*Math.pow(2,32)+Fo(oe,_e)/1e7-11644473600)*1e3)}function T(oe,_e){return u(),h(c.readFileSync(oe),_e)}function P(oe,_e){var ve=_e&&_e.type;switch(ve||Ia&&Buffer.isBuffer(oe)&&(ve="buffer"),ve||"base64"){case"file":return T(oe,_e);case"base64":return h(Vl(Kd(oe)),_e);case"binary":return h(Vl(oe),_e)}return h(oe,_e)}function E(oe,_e){var ve=_e||{},Se=ve.root||"Root Entry";if(oe.FullPaths||(oe.FullPaths=[]),oe.FileIndex||(oe.FileIndex=[]),oe.FullPaths.length!==oe.FileIndex.length)throw new Error("inconsistent CFB structure");oe.FullPaths.length===0&&(oe.FullPaths[0]=Se+"/",oe.FileIndex[0]={name:Se,type:5}),ve.CLSID&&(oe.FileIndex[0].clsid=ve.CLSID),R(oe)}function R(oe){var _e="Sh33tJ5";if(!as.find(oe,"/"+_e)){var ve=Ft(4);ve[0]=55,ve[1]=ve[3]=50,ve[2]=54,oe.FileIndex.push({name:_e,type:2,content:ve,size:4,L:69,R:69,C:69}),oe.FullPaths.push(oe.FullPaths[0]+_e),z(oe)}}function z(oe,_e){E(oe);for(var ve=!1,Se=!1,Ce=oe.FullPaths.length-1;Ce>=0;--Ce){var Pe=oe.FileIndex[Ce];switch(Pe.type){case 0:Se?ve=!0:(oe.FileIndex.pop(),oe.FullPaths.pop());break;case 1:case 2:case 5:Se=!0,isNaN(Pe.R*Pe.L*Pe.C)&&(ve=!0),Pe.R>-1&&Pe.L>-1&&Pe.R==Pe.L&&(ve=!0);break;default:ve=!0;break}}if(!(!ve&&!_e)){var rt=new Date(1987,1,19),ut=0,et=Object.create?Object.create(null):{},nt=[];for(Ce=0;Ce<oe.FullPaths.length;++Ce)et[oe.FullPaths[Ce]]=!0,oe.FileIndex[Ce].type!==0&&nt.push([oe.FullPaths[Ce],oe.FileIndex[Ce]]);for(Ce=0;Ce<nt.length;++Ce){var ct=s(nt[Ce][0]);Se=et[ct],Se||(nt.push([ct,{name:n(ct).replace("/",""),type:1,clsid:q,ct:rt,mt:rt,content:null}]),et[ct]=!0)}for(nt.sort(function(Xt,pt){return a(Xt[0],pt[0])}),oe.FullPaths=[],oe.FileIndex=[],Ce=0;Ce<nt.length;++Ce)oe.FullPaths[Ce]=nt[Ce][0],oe.FileIndex[Ce]=nt[Ce][1];for(Ce=0;Ce<nt.length;++Ce){var $t=oe.FileIndex[Ce],Ut=oe.FullPaths[Ce];if($t.name=n(Ut).replace("/",""),$t.L=$t.R=$t.C=-($t.color=1),$t.size=$t.content?$t.content.length:0,$t.start=0,$t.clsid=$t.clsid||q,Ce===0)$t.C=nt.length>1?1:-1,$t.size=0,$t.type=5;else if(Ut.slice(-1)=="/"){for(ut=Ce+1;ut<nt.length&&s(oe.FullPaths[ut])!=Ut;++ut);for($t.C=ut>=nt.length?-1:ut,ut=Ce+1;ut<nt.length&&s(oe.FullPaths[ut])!=s(Ut);++ut);$t.R=ut>=nt.length?-1:ut,$t.type=1}else s(oe.FullPaths[Ce+1]||"")==s(Ut)&&($t.R=Ce+1),$t.type=2}}}function G(oe,_e){var ve=_e||{};if(ve.fileType=="mad")return ke(oe,ve);switch(z(oe),ve.fileType){case"zip":return Pt(oe,ve)}var Se=(function(Xt){for(var pt=0,Wt=0,rr=0;rr<Xt.FileIndex.length;++rr){var Mr=Xt.FileIndex[rr];if(Mr.content){var Br=Mr.content.length;Br>0&&(Br<4096?pt+=Br+63>>6:Wt+=Br+511>>9)}}for(var Yr=Xt.FullPaths.length+3>>2,ma=pt+7>>3,ps=pt+127>>7,hn=ma+Wt+Yr+ps,Rs=hn+127>>7,Un=Rs<=109?0:Math.ceil((Rs-109)/127);hn+Rs+Un+127>>7>Rs;)Un=++Rs<=109?0:Math.ceil((Rs-109)/127);var Tr=[1,Un,Rs,ps,Yr,Wt,pt,0];return Xt.FileIndex[0].size=pt<<6,Tr[7]=(Xt.FileIndex[0].start=Tr[0]+Tr[1]+Tr[2]+Tr[3]+Tr[4]+Tr[5])+(Tr[6]+7>>3),Tr})(oe),Ce=Ft(Se[7]<<9),Pe=0,rt=0;{for(Pe=0;Pe<8;++Pe)Ce.write_shift(1,Y[Pe]);for(Pe=0;Pe<8;++Pe)Ce.write_shift(2,0);for(Ce.write_shift(2,62),Ce.write_shift(2,3),Ce.write_shift(2,65534),Ce.write_shift(2,9),Ce.write_shift(2,6),Pe=0;Pe<3;++Pe)Ce.write_shift(2,0);for(Ce.write_shift(4,0),Ce.write_shift(4,Se[2]),Ce.write_shift(4,Se[0]+Se[1]+Se[2]+Se[3]-1),Ce.write_shift(4,0),Ce.write_shift(4,4096),Ce.write_shift(4,Se[3]?Se[0]+Se[1]+Se[2]-1:ne),Ce.write_shift(4,Se[3]),Ce.write_shift(-4,Se[1]?Se[0]-1:ne),Ce.write_shift(4,Se[1]),Pe=0;Pe<109;++Pe)Ce.write_shift(-4,Pe<Se[2]?Se[1]+Pe:-1)}if(Se[1])for(rt=0;rt<Se[1];++rt){for(;Pe<236+rt*127;++Pe)Ce.write_shift(-4,Pe<Se[2]?Se[1]+Pe:-1);Ce.write_shift(-4,rt===Se[1]-1?ne:rt+1)}var ut=function(Xt){for(rt+=Xt;Pe<rt-1;++Pe)Ce.write_shift(-4,Pe+1);Xt&&(++Pe,Ce.write_shift(-4,ne))};for(rt=Pe=0,rt+=Se[1];Pe<rt;++Pe)Ce.write_shift(-4,H.DIFSECT);for(rt+=Se[2];Pe<rt;++Pe)Ce.write_shift(-4,H.FATSECT);ut(Se[3]),ut(Se[4]);for(var et=0,nt=0,ct=oe.FileIndex[0];et<oe.FileIndex.length;++et)ct=oe.FileIndex[et],ct.content&&(nt=ct.content.length,!(nt<4096)&&(ct.start=rt,ut(nt+511>>9)));for(ut(Se[6]+7>>3);Ce.l&511;)Ce.write_shift(-4,H.ENDOFCHAIN);for(rt=Pe=0,et=0;et<oe.FileIndex.length;++et)ct=oe.FileIndex[et],ct.content&&(nt=ct.content.length,!(!nt||nt>=4096)&&(ct.start=rt,ut(nt+63>>6)));for(;Ce.l&511;)Ce.write_shift(-4,H.ENDOFCHAIN);for(Pe=0;Pe<Se[4]<<2;++Pe){var $t=oe.FullPaths[Pe];if(!$t||$t.length===0){for(et=0;et<17;++et)Ce.write_shift(4,0);for(et=0;et<3;++et)Ce.write_shift(4,-1);for(et=0;et<12;++et)Ce.write_shift(4,0);continue}ct=oe.FileIndex[Pe],Pe===0&&(ct.start=ct.size?ct.start-1:ne);var Ut=Pe===0&&ve.root||ct.name;if(nt=2*(Ut.length+1),Ce.write_shift(64,Ut,"utf16le"),Ce.write_shift(2,nt),Ce.write_shift(1,ct.type),Ce.write_shift(1,ct.color),Ce.write_shift(-4,ct.L),Ce.write_shift(-4,ct.R),Ce.write_shift(-4,ct.C),ct.clsid)Ce.write_shift(16,ct.clsid,"hex");else for(et=0;et<4;++et)Ce.write_shift(4,0);Ce.write_shift(4,ct.state||0),Ce.write_shift(4,0),Ce.write_shift(4,0),Ce.write_shift(4,0),Ce.write_shift(4,0),Ce.write_shift(4,ct.start),Ce.write_shift(4,ct.size),Ce.write_shift(4,0)}for(Pe=1;Pe<oe.FileIndex.length;++Pe)if(ct=oe.FileIndex[Pe],ct.size>=4096)if(Ce.l=ct.start+1<<9,Ia&&Buffer.isBuffer(ct.content))ct.content.copy(Ce,Ce.l,0,ct.size),Ce.l+=ct.size+511&-512;else{for(et=0;et<ct.size;++et)Ce.write_shift(1,ct.content[et]);for(;et&511;++et)Ce.write_shift(1,0)}for(Pe=1;Pe<oe.FileIndex.length;++Pe)if(ct=oe.FileIndex[Pe],ct.size>0&&ct.size<4096)if(Ia&&Buffer.isBuffer(ct.content))ct.content.copy(Ce,Ce.l,0,ct.size),Ce.l+=ct.size+63&-64;else{for(et=0;et<ct.size;++et)Ce.write_shift(1,ct.content[et]);for(;et&63;++et)Ce.write_shift(1,0)}if(Ia)Ce.l=Ce.length;else for(;Ce.l<Ce.length;)Ce.write_shift(1,0);return Ce}function ae(oe,_e){var ve=oe.FullPaths.map(function(et){return et.toUpperCase()}),Se=ve.map(function(et){var nt=et.split("/");return nt[nt.length-(et.slice(-1)=="/"?2:1)]}),Ce=!1;_e.charCodeAt(0)===47?(Ce=!0,_e=ve[0].slice(0,-1)+_e):Ce=_e.indexOf("/")!==-1;var Pe=_e.toUpperCase(),rt=Ce===!0?ve.indexOf(Pe):Se.indexOf(Pe);if(rt!==-1)return oe.FileIndex[rt];var ut=!Pe.match(db);for(Pe=Pe.replace(Mf,""),ut&&(Pe=Pe.replace(db,"!")),rt=0;rt<ve.length;++rt)if((ut?ve[rt].replace(db,"!"):ve[rt]).replace(Mf,"")==Pe||(ut?Se[rt].replace(db,"!"):Se[rt]).replace(Mf,"")==Pe)return oe.FileIndex[rt];return null}var ee=64,ne=-2,te="d0cf11e0a1b11ae1",Y=[208,207,17,224,161,177,26,225],q="00000000000000000000000000000000",H={MAXREGSECT:-6,DIFSECT:-4,FATSECT:-3,ENDOFCHAIN:ne,FREESECT:-1,HEADER_SIGNATURE:te,HEADER_MINOR_VERSION:"3e00",MAXREGSID:-6,NOSTREAM:-1,HEADER_CLSID:q,EntryTypes:["unknown","storage","stream","lockbytes","property","root"]};function U(oe,_e,ve){u();var Se=G(oe,ve);c.writeFileSync(_e,Se)}function re(oe){for(var _e=new Array(oe.length),ve=0;ve<oe.length;++ve)_e[ve]=String.fromCharCode(oe[ve]);return _e.join("")}function X(oe,_e){var ve=G(oe,_e);switch(_e&&_e.type||"buffer"){case"file":return u(),c.writeFileSync(_e.filename,ve),ve;case"binary":return typeof ve=="string"?ve:re(ve);case"base64":return Yf(typeof ve=="string"?ve:re(ve));case"buffer":if(Ia)return Buffer.isBuffer(ve)?ve:ru(ve);case"array":return typeof ve=="string"?Vl(ve):ve}return ve}var V;function I(oe){try{var _e=oe.InflateRaw,ve=new _e;if(ve._processChunk(new Uint8Array([3,0]),ve._finishFlushFlag),ve.bytesRead)V=oe;else throw new Error("zlib does not expose bytesRead")}catch(Se){console.error("cannot use native zlib: "+(Se.message||Se))}}function B(oe,_e){if(!V)return lt(oe,_e);var ve=V.InflateRaw,Se=new ve,Ce=Se._processChunk(oe.slice(oe.l),Se._finishFlushFlag);return oe.l+=Se.bytesRead,Ce}function Q(oe){return V?V.deflateRawSync(oe):vt(oe)}var ie=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],me=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],he=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577];function de(oe){var _e=(oe<<1|oe<<11)&139536|(oe<<5|oe<<15)&558144;return(_e>>16|_e>>8|_e)&255}for(var xe=typeof Uint8Array!="undefined",ge=xe?new Uint8Array(256):[],be=0;be<256;++be)ge[be]=de(be);function K(oe,_e){var ve=ge[oe&255];return _e<=8?ve>>>8-_e:(ve=ve<<8|ge[oe>>8&255],_e<=16?ve>>>16-_e:(ve=ve<<8|ge[oe>>16&255],ve>>>24-_e))}function ye(oe,_e){var ve=_e&7,Se=_e>>>3;return(oe[Se]|(ve<=6?0:oe[Se+1]<<8))>>>ve&3}function Z(oe,_e){var ve=_e&7,Se=_e>>>3;return(oe[Se]|(ve<=5?0:oe[Se+1]<<8))>>>ve&7}function M(oe,_e){var ve=_e&7,Se=_e>>>3;return(oe[Se]|(ve<=4?0:oe[Se+1]<<8))>>>ve&15}function we(oe,_e){var ve=_e&7,Se=_e>>>3;return(oe[Se]|(ve<=3?0:oe[Se+1]<<8))>>>ve&31}function pe(oe,_e){var ve=_e&7,Se=_e>>>3;return(oe[Se]|(ve<=1?0:oe[Se+1]<<8))>>>ve&127}function le(oe,_e,ve){var Se=_e&7,Ce=_e>>>3,Pe=(1<<ve)-1,rt=oe[Ce]>>>Se;return ve<8-Se||(rt|=oe[Ce+1]<<8-Se,ve<16-Se)||(rt|=oe[Ce+2]<<16-Se,ve<24-Se)||(rt|=oe[Ce+3]<<24-Se),rt&Pe}function Fe(oe,_e,ve){var Se=_e&7,Ce=_e>>>3;return Se<=5?oe[Ce]|=(ve&7)<<Se:(oe[Ce]|=ve<<Se&255,oe[Ce+1]=(ve&7)>>8-Se),_e+3}function ze(oe,_e,ve){var Se=_e&7,Ce=_e>>>3;return ve=(ve&1)<<Se,oe[Ce]|=ve,_e+1}function Re(oe,_e,ve){var Se=_e&7,Ce=_e>>>3;return ve<<=Se,oe[Ce]|=ve&255,ve>>>=8,oe[Ce+1]=ve,_e+8}function De(oe,_e,ve){var Se=_e&7,Ce=_e>>>3;return ve<<=Se,oe[Ce]|=ve&255,ve>>>=8,oe[Ce+1]=ve&255,oe[Ce+2]=ve>>>8,_e+16}function Et(oe,_e){var ve=oe.length,Se=2*ve>_e?2*ve:_e+5,Ce=0;if(ve>=_e)return oe;if(Ia){var Pe=vE(Se);if(oe.copy)oe.copy(Pe);else for(;Ce<oe.length;++Ce)Pe[Ce]=oe[Ce];return Pe}else if(xe){var rt=new Uint8Array(Se);if(rt.set)rt.set(oe);else for(;Ce<ve;++Ce)rt[Ce]=oe[Ce];return rt}return oe.length=Se,oe}function jt(oe){for(var _e=new Array(oe),ve=0;ve<oe;++ve)_e[ve]=0;return _e}function Ie(oe,_e,ve){var Se=1,Ce=0,Pe=0,rt=0,ut=0,et=oe.length,nt=xe?new Uint16Array(32):jt(32);for(Pe=0;Pe<32;++Pe)nt[Pe]=0;for(Pe=et;Pe<ve;++Pe)oe[Pe]=0;et=oe.length;var ct=xe?new Uint16Array(et):jt(et);for(Pe=0;Pe<et;++Pe)nt[Ce=oe[Pe]]++,Se<Ce&&(Se=Ce),ct[Pe]=0;for(nt[0]=0,Pe=1;Pe<=Se;++Pe)nt[Pe+16]=ut=ut+nt[Pe-1]<<1;for(Pe=0;Pe<et;++Pe)ut=oe[Pe],ut!=0&&(ct[Pe]=nt[ut+16]++);var $t=0;for(Pe=0;Pe<et;++Pe)if($t=oe[Pe],$t!=0)for(ut=K(ct[Pe],Se)>>Se-$t,rt=(1<<Se+4-$t)-1;rt>=0;--rt)_e[ut|rt<<$t]=$t&15|Pe<<4;return Se}var $e=xe?new Uint16Array(512):jt(512),Qe=xe?new Uint16Array(32):jt(32);if(!xe){for(var at=0;at<512;++at)$e[at]=0;for(at=0;at<32;++at)Qe[at]=0}(function(){for(var oe=[],_e=0;_e<32;_e++)oe.push(5);Ie(oe,Qe,32);var ve=[];for(_e=0;_e<=143;_e++)ve.push(8);for(;_e<=255;_e++)ve.push(9);for(;_e<=279;_e++)ve.push(7);for(;_e<=287;_e++)ve.push(8);Ie(ve,$e,288)})();var Ct=(function(){for(var _e=xe?new Uint8Array(32768):[],ve=0,Se=0;ve<he.length-1;++ve)for(;Se<he[ve+1];++Se)_e[Se]=ve;for(;Se<32768;++Se)_e[Se]=29;var Ce=xe?new Uint8Array(259):[];for(ve=0,Se=0;ve<me.length-1;++ve)for(;Se<me[ve+1];++Se)Ce[Se]=ve;function Pe(ut,et){for(var nt=0;nt<ut.length;){var ct=Math.min(65535,ut.length-nt),$t=nt+ct==ut.length;for(et.write_shift(1,+$t),et.write_shift(2,ct),et.write_shift(2,~ct&65535);ct-- >0;)et[et.l++]=ut[nt++]}return et.l}function rt(ut,et){for(var nt=0,ct=0,$t=xe?new Uint16Array(32768):[];ct<ut.length;){var Ut=Math.min(65535,ut.length-ct);if(Ut<10){for(nt=Fe(et,nt,+(ct+Ut==ut.length)),nt&7&&(nt+=8-(nt&7)),et.l=nt/8|0,et.write_shift(2,Ut),et.write_shift(2,~Ut&65535);Ut-- >0;)et[et.l++]=ut[ct++];nt=et.l*8;continue}nt=Fe(et,nt,+(ct+Ut==ut.length)+2);for(var Xt=0;Ut-- >0;){var pt=ut[ct];Xt=(Xt<<5^pt)&32767;var Wt=-1,rr=0;if((Wt=$t[Xt])&&(Wt|=ct&-32768,Wt>ct&&(Wt-=32768),Wt<ct))for(;ut[Wt+rr]==ut[ct+rr]&&rr<250;)++rr;if(rr>2){pt=Ce[rr],pt<=22?nt=Re(et,nt,ge[pt+1]>>1)-1:(Re(et,nt,3),nt+=5,Re(et,nt,ge[pt-23]>>5),nt+=3);var Mr=pt<8?0:pt-4>>2;Mr>0&&(De(et,nt,rr-me[pt]),nt+=Mr),pt=_e[ct-Wt],nt=Re(et,nt,ge[pt]>>3),nt-=3;var Br=pt<4?0:pt-2>>1;Br>0&&(De(et,nt,ct-Wt-he[pt]),nt+=Br);for(var Yr=0;Yr<rr;++Yr)$t[Xt]=ct&32767,Xt=(Xt<<5^ut[ct])&32767,++ct;Ut-=rr-1}else pt<=143?pt=pt+48:nt=ze(et,nt,1),nt=Re(et,nt,ge[pt]),$t[Xt]=ct&32767,++ct}nt=Re(et,nt,0)-1}return et.l=(nt+7)/8|0,et.l}return function(et,nt){return et.length<8?Pe(et,nt):rt(et,nt)}})();function vt(oe){var _e=Ft(50+Math.floor(oe.length*1.1)),ve=Ct(oe,_e);return _e.slice(0,ve)}var er=xe?new Uint16Array(32768):jt(32768),nr=xe?new Uint16Array(32768):jt(32768),dt=xe?new Uint16Array(128):jt(128),He=1,it=1;function Ue(oe,_e){var ve=we(oe,_e)+257;_e+=5;var Se=we(oe,_e)+1;_e+=5;var Ce=M(oe,_e)+4;_e+=4;for(var Pe=0,rt=xe?new Uint8Array(19):jt(19),ut=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],et=1,nt=xe?new Uint8Array(8):jt(8),ct=xe?new Uint8Array(8):jt(8),$t=rt.length,Ut=0;Ut<Ce;++Ut)rt[ie[Ut]]=Pe=Z(oe,_e),et<Pe&&(et=Pe),nt[Pe]++,_e+=3;var Xt=0;for(nt[0]=0,Ut=1;Ut<=et;++Ut)ct[Ut]=Xt=Xt+nt[Ut-1]<<1;for(Ut=0;Ut<$t;++Ut)(Xt=rt[Ut])!=0&&(ut[Ut]=ct[Xt]++);var pt=0;for(Ut=0;Ut<$t;++Ut)if(pt=rt[Ut],pt!=0){Xt=ge[ut[Ut]]>>8-pt;for(var Wt=(1<<7-pt)-1;Wt>=0;--Wt)dt[Xt|Wt<<pt]=pt&7|Ut<<3}var rr=[];for(et=1;rr.length<ve+Se;)switch(Xt=dt[pe(oe,_e)],_e+=Xt&7,Xt>>>=3){case 16:for(Pe=3+ye(oe,_e),_e+=2,Xt=rr[rr.length-1];Pe-- >0;)rr.push(Xt);break;case 17:for(Pe=3+Z(oe,_e),_e+=3;Pe-- >0;)rr.push(0);break;case 18:for(Pe=11+pe(oe,_e),_e+=7;Pe-- >0;)rr.push(0);break;default:rr.push(Xt),et<Xt&&(et=Xt);break}var Mr=rr.slice(0,ve),Br=rr.slice(ve);for(Ut=ve;Ut<286;++Ut)Mr[Ut]=0;for(Ut=Se;Ut<30;++Ut)Br[Ut]=0;return He=Ie(Mr,er,286),it=Ie(Br,nr,30),_e}function Ve(oe,_e){if(oe[0]==3&&!(oe[1]&3))return[wm(_e),2];for(var ve=0,Se=0,Ce=vE(_e||1<<18),Pe=0,rt=Ce.length>>>0,ut=0,et=0;(Se&1)==0;){if(Se=Z(oe,ve),ve+=3,Se>>>1)Se>>1==1?(ut=9,et=5):(ve=Ue(oe,ve),ut=He,et=it);else{ve&7&&(ve+=8-(ve&7));var nt=oe[ve>>>3]|oe[(ve>>>3)+1]<<8;if(ve+=32,nt>0)for(!_e&&rt<Pe+nt&&(Ce=Et(Ce,Pe+nt),rt=Ce.length);nt-- >0;)Ce[Pe++]=oe[ve>>>3],ve+=8;continue}for(;;){!_e&&rt<Pe+32767&&(Ce=Et(Ce,Pe+32767),rt=Ce.length);var ct=le(oe,ve,ut),$t=Se>>>1==1?$e[ct]:er[ct];if(ve+=$t&15,$t>>>=4,($t>>>8&255)===0)Ce[Pe++]=$t;else{if($t==256)break;$t-=257;var Ut=$t<8?0:$t-4>>2;Ut>5&&(Ut=0);var Xt=Pe+me[$t];Ut>0&&(Xt+=le(oe,ve,Ut),ve+=Ut),ct=le(oe,ve,et),$t=Se>>>1==1?Qe[ct]:nr[ct],ve+=$t&15,$t>>>=4;var pt=$t<4?0:$t-2>>1,Wt=he[$t];for(pt>0&&(Wt+=le(oe,ve,pt),ve+=pt),!_e&&rt<Xt&&(Ce=Et(Ce,Xt+100),rt=Ce.length);Pe<Xt;)Ce[Pe]=Ce[Pe-Wt],++Pe}}}return _e?[Ce,ve+7>>>3]:[Ce.slice(0,Pe),ve+7>>>3]}function lt(oe,_e){var ve=oe.slice(oe.l||0),Se=Ve(ve,_e);return oe.l+=Se[1],Se[0]}function st(oe,_e){if(oe)typeof console!="undefined"&&console.error(_e);else throw new Error(_e)}function Mt(oe,_e){var ve=oe;Ro(ve,0);var Se=[],Ce=[],Pe={FileIndex:Se,FullPaths:Ce};E(Pe,{root:_e.root});for(var rt=ve.length-4;(ve[rt]!=80||ve[rt+1]!=75||ve[rt+2]!=5||ve[rt+3]!=6)&&rt>=0;)--rt;ve.l=rt+4,ve.l+=4;var ut=ve.read_shift(2);ve.l+=6;var et=ve.read_shift(4);for(ve.l=et,rt=0;rt<ut;++rt){ve.l+=20;var nt=ve.read_shift(4),ct=ve.read_shift(4),$t=ve.read_shift(2),Ut=ve.read_shift(2),Xt=ve.read_shift(2);ve.l+=8;var pt=ve.read_shift(4),Wt=l(ve.slice(ve.l+$t,ve.l+$t+Ut));ve.l+=$t+Ut+Xt;var rr=ve.l;ve.l=pt+4,Ot(ve,nt,ct,Pe,Wt),ve.l=rr}return Pe}function Ot(oe,_e,ve,Se,Ce){oe.l+=2;var Pe=oe.read_shift(2),rt=oe.read_shift(2),ut=o(oe);if(Pe&8257)throw new Error("Unsupported ZIP encryption");for(var et=oe.read_shift(4),nt=oe.read_shift(4),ct=oe.read_shift(4),$t=oe.read_shift(2),Ut=oe.read_shift(2),Xt="",pt=0;pt<$t;++pt)Xt+=String.fromCharCode(oe[oe.l++]);if(Ut){var Wt=l(oe.slice(oe.l,oe.l+Ut));(Wt[21589]||{}).mt&&(ut=Wt[21589].mt),((Ce||{})[21589]||{}).mt&&(ut=Ce[21589].mt)}oe.l+=Ut;var rr=oe.slice(oe.l,oe.l+nt);switch(rt){case 8:rr=B(oe,ct);break;case 0:break;default:throw new Error("Unsupported ZIP Compression method "+rt)}var Mr=!1;Pe&8&&(et=oe.read_shift(4),et==134695760&&(et=oe.read_shift(4),Mr=!0),nt=oe.read_shift(4),ct=oe.read_shift(4)),nt!=_e&&st(Mr,"Bad compressed size: "+_e+" != "+nt),ct!=ve&&st(Mr,"Bad uncompressed size: "+ve+" != "+ct),yt(Se,Xt,rr,{unsafe:!0,mt:ut})}function Pt(oe,_e){var ve=_e||{},Se=[],Ce=[],Pe=Ft(1),rt=ve.compression?8:0,ut=0,et=0,nt=0,ct=0,$t=0,Ut=oe.FullPaths[0],Xt=Ut,pt=oe.FileIndex[0],Wt=[],rr=0;for(et=1;et<oe.FullPaths.length;++et)if(Xt=oe.FullPaths[et].slice(Ut.length),pt=oe.FileIndex[et],!(!pt.size||!pt.content||Xt=="Sh33tJ5")){var Mr=ct,Br=Ft(Xt.length);for(nt=0;nt<Xt.length;++nt)Br.write_shift(1,Xt.charCodeAt(nt)&127);Br=Br.slice(0,Br.l),Wt[$t]=CK.buf(pt.content,0);var Yr=pt.content;rt==8&&(Yr=Q(Yr)),Pe=Ft(30),Pe.write_shift(4,67324752),Pe.write_shift(2,20),Pe.write_shift(2,ut),Pe.write_shift(2,rt),pt.mt?i(Pe,pt.mt):Pe.write_shift(4,0),Pe.write_shift(-4,Wt[$t]),Pe.write_shift(4,Yr.length),Pe.write_shift(4,pt.content.length),Pe.write_shift(2,Br.length),Pe.write_shift(2,0),ct+=Pe.length,Se.push(Pe),ct+=Br.length,Se.push(Br),ct+=Yr.length,Se.push(Yr),Pe=Ft(46),Pe.write_shift(4,33639248),Pe.write_shift(2,0),Pe.write_shift(2,20),Pe.write_shift(2,ut),Pe.write_shift(2,rt),Pe.write_shift(4,0),Pe.write_shift(-4,Wt[$t]),Pe.write_shift(4,Yr.length),Pe.write_shift(4,pt.content.length),Pe.write_shift(2,Br.length),Pe.write_shift(2,0),Pe.write_shift(2,0),Pe.write_shift(2,0),Pe.write_shift(2,0),Pe.write_shift(4,0),Pe.write_shift(4,Mr),rr+=Pe.l,Ce.push(Pe),rr+=Br.length,Ce.push(Br),++$t}return Pe=Ft(22),Pe.write_shift(4,101010256),Pe.write_shift(2,0),Pe.write_shift(2,0),Pe.write_shift(2,$t),Pe.write_shift(2,$t),Pe.write_shift(4,rr),Pe.write_shift(4,ct),Pe.write_shift(2,0),Qn([Qn(Se),Qn(Ce),Pe])}var zt={htm:"text/html",xml:"text/xml",gif:"image/gif",jpg:"image/jpeg",png:"image/png",mso:"application/x-mso",thmx:"application/vnd.ms-officetheme",sh33tj5:"application/octet-stream"};function Tt(oe,_e){if(oe.ctype)return oe.ctype;var ve=oe.name||"",Se=ve.match(/\.([^\.]+)$/);return Se&&zt[Se[1]]||_e&&(Se=(ve=_e).match(/[\.\\]([^\.\\])+$/),Se&&zt[Se[1]])?zt[Se[1]]:"application/octet-stream"}function Gt(oe){for(var _e=Yf(oe),ve=[],Se=0;Se<_e.length;Se+=76)ve.push(_e.slice(Se,Se+76));return ve.join(`\r
|
||
`)+`\r
|
||
`}function Ye(oe){var _e=oe.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7E-\xFF=]/g,function(nt){var ct=nt.charCodeAt(0).toString(16).toUpperCase();return"="+(ct.length==1?"0"+ct:ct)});_e=_e.replace(/ $/mg,"=20").replace(/\t$/mg,"=09"),_e.charAt(0)==`
|
||
`&&(_e="=0D"+_e.slice(1)),_e=_e.replace(/\r(?!\n)/mg,"=0D").replace(/\n\n/mg,`
|
||
=0A`).replace(/([^\r\n])\n/mg,"$1=0A");for(var ve=[],Se=_e.split(`\r
|
||
`),Ce=0;Ce<Se.length;++Ce){var Pe=Se[Ce];if(Pe.length==0){ve.push("");continue}for(var rt=0;rt<Pe.length;){var ut=76,et=Pe.slice(rt,rt+ut);et.charAt(ut-1)=="="?ut--:et.charAt(ut-2)=="="?ut-=2:et.charAt(ut-3)=="="&&(ut-=3),et=Pe.slice(rt,rt+ut),rt+=ut,rt<Pe.length&&(et+="="),ve.push(et)}}return ve.join(`\r
|
||
`)}function kt(oe){for(var _e=[],ve=0;ve<oe.length;++ve){for(var Se=oe[ve];ve<=oe.length&&Se.charAt(Se.length-1)=="=";)Se=Se.slice(0,Se.length-1)+oe[++ve];_e.push(Se)}for(var Ce=0;Ce<_e.length;++Ce)_e[Ce]=_e[Ce].replace(/[=][0-9A-Fa-f]{2}/g,function(Pe){return String.fromCharCode(parseInt(Pe.slice(1),16))});return Vl(_e.join(`\r
|
||
`))}function Yt(oe,_e,ve){for(var Se="",Ce="",Pe="",rt,ut=0;ut<10;++ut){var et=_e[ut];if(!et||et.match(/^\s*$/))break;var nt=et.match(/^(.*?):\s*([^\s].*)$/);if(nt)switch(nt[1].toLowerCase()){case"content-location":Se=nt[2].trim();break;case"content-type":Pe=nt[2].trim();break;case"content-transfer-encoding":Ce=nt[2].trim();break}}switch(++ut,Ce.toLowerCase()){case"base64":rt=Vl(Kd(_e.slice(ut).join("")));break;case"quoted-printable":rt=kt(_e.slice(ut));break;default:throw new Error("Unsupported Content-Transfer-Encoding "+Ce)}var ct=yt(oe,Se.slice(ve.length),rt,{unsafe:!0});Pe&&(ct.ctype=Pe)}function Ae(oe,_e){if(re(oe.slice(0,13)).toLowerCase()!="mime-version:")throw new Error("Unsupported MAD header");var ve=_e&&_e.root||"",Se=(Ia&&Buffer.isBuffer(oe)?oe.toString("binary"):re(oe)).split(`\r
|
||
`),Ce=0,Pe="";for(Ce=0;Ce<Se.length;++Ce)if(Pe=Se[Ce],!!/^Content-Location:/i.test(Pe)&&(Pe=Pe.slice(Pe.indexOf("file")),ve||(ve=Pe.slice(0,Pe.lastIndexOf("/")+1)),Pe.slice(0,ve.length)!=ve))for(;ve.length>0&&(ve=ve.slice(0,ve.length-1),ve=ve.slice(0,ve.lastIndexOf("/")+1),Pe.slice(0,ve.length)!=ve););var rt=(Se[1]||"").match(/boundary="(.*?)"/);if(!rt)throw new Error("MAD cannot find boundary");var ut="--"+(rt[1]||""),et=[],nt=[],ct={FileIndex:et,FullPaths:nt};E(ct);var $t,Ut=0;for(Ce=0;Ce<Se.length;++Ce){var Xt=Se[Ce];Xt!==ut&&Xt!==ut+"--"||(Ut++&&Yt(ct,Se.slice($t,Ce),ve),$t=Ce)}return ct}function ke(oe,_e){var ve=_e||{},Se=ve.boundary||"SheetJS";Se="------="+Se;for(var Ce=["MIME-Version: 1.0",'Content-Type: multipart/related; boundary="'+Se.slice(2)+'"',"","",""],Pe=oe.FullPaths[0],rt=Pe,ut=oe.FileIndex[0],et=1;et<oe.FullPaths.length;++et)if(rt=oe.FullPaths[et].slice(Pe.length),ut=oe.FileIndex[et],!(!ut.size||!ut.content||rt=="Sh33tJ5")){rt=rt.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7E-\xFF]/g,function(rr){return"_x"+rr.charCodeAt(0).toString(16)+"_"}).replace(/[\u0080-\uFFFF]/g,function(rr){return"_u"+rr.charCodeAt(0).toString(16)+"_"});for(var nt=ut.content,ct=Ia&&Buffer.isBuffer(nt)?nt.toString("binary"):re(nt),$t=0,Ut=Math.min(1024,ct.length),Xt=0,pt=0;pt<=Ut;++pt)(Xt=ct.charCodeAt(pt))>=32&&Xt<128&&++$t;var Wt=$t>=Ut*4/5;Ce.push(Se),Ce.push("Content-Location: "+(ve.root||"file:///C:/SheetJS/")+rt),Ce.push("Content-Transfer-Encoding: "+(Wt?"quoted-printable":"base64")),Ce.push("Content-Type: "+Tt(ut,rt)),Ce.push(""),Ce.push(Wt?Ye(ct):Gt(ct))}return Ce.push(Se+`--\r
|
||
`),Ce.join(`\r
|
||
`)}function Be(oe){var _e={};return E(_e,oe),_e}function yt(oe,_e,ve,Se){var Ce=Se&&Se.unsafe;Ce||E(oe);var Pe=!Ce&&as.find(oe,_e);if(!Pe){var rt=oe.FullPaths[0];_e.slice(0,rt.length)==rt?rt=_e:(rt.slice(-1)!="/"&&(rt+="/"),rt=(rt+_e).replace("//","/")),Pe={name:n(_e),type:2},oe.FileIndex.push(Pe),oe.FullPaths.push(rt),Ce||as.utils.cfb_gc(oe)}return Pe.content=ve,Pe.size=ve?ve.length:0,Se&&(Se.CLSID&&(Pe.clsid=Se.CLSID),Se.mt&&(Pe.mt=Se.mt),Se.ct&&(Pe.ct=Se.ct)),Pe}function Me(oe,_e){E(oe);var ve=as.find(oe,_e);if(ve){for(var Se=0;Se<oe.FileIndex.length;++Se)if(oe.FileIndex[Se]==ve)return oe.FileIndex.splice(Se,1),oe.FullPaths.splice(Se,1),!0}return!1}function Ke(oe,_e,ve){E(oe);var Se=as.find(oe,_e);if(Se){for(var Ce=0;Ce<oe.FileIndex.length;++Ce)if(oe.FileIndex[Ce]==Se)return oe.FileIndex[Ce].name=n(ve),oe.FullPaths[Ce]=ve,!0}return!1}function Xe(oe){z(oe,!0)}return r.find=ae,r.read=P,r.parse=h,r.write=X,r.writeFile=U,r.utils={cfb_new:Be,cfb_add:yt,cfb_del:Me,cfb_mov:Ke,cfb_gc:Xe,ReadShift:Ff,CheckField:OR,prep_blob:Ro,bconcat:Qn,use_zlib:I,_deflateRaw:vt,_inflateRaw:lt,consts:H},r})();function TK(e){return typeof e=="string"?K1(e):Array.isArray(e)?eK(e):e}function Nx(e,r,a){if(typeof Deno!="undefined"){if(a&&typeof r=="string")switch(a){case"utf8":r=new TextEncoder(a).encode(r);break;case"binary":r=K1(r);break;default:throw new Error("Unsupported encoding "+a)}return Deno.writeFileSync(e,r)}var s=a=="utf8"?Zf(r):r;if(typeof IE_SaveFile!="undefined")return IE_SaveFile(s,e);if(typeof Blob!="undefined"){var n=new Blob([TK(s)],{type:"application/octet-stream"});if(typeof navigator!="undefined"&&navigator.msSaveBlob)return navigator.msSaveBlob(n,e);if(typeof saveAs!="undefined")return saveAs(n,e);if(typeof URL!="undefined"&&typeof document!="undefined"&&document.createElement&&URL.createObjectURL){var i=URL.createObjectURL(n);if(typeof chrome=="object"&&typeof(chrome.downloads||{}).download=="function")return URL.revokeObjectURL&&typeof setTimeout!="undefined"&&setTimeout(function(){URL.revokeObjectURL(i)},6e4),chrome.downloads.download({url:i,filename:e,saveAs:!0});var o=document.createElement("a");if(o.download!=null)return o.download=e,o.href=i,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL&&typeof setTimeout!="undefined"&&setTimeout(function(){URL.revokeObjectURL(i)},6e4),i}}if(typeof $!="undefined"&&typeof File!="undefined"&&typeof Folder!="undefined")try{var l=File(e);return l.open("w"),l.encoding="binary",Array.isArray(r)&&(r=kx(r)),l.write(r),l.close(),r}catch(c){if(!c.message||!c.message.match(/onstruct/))throw c}throw new Error("cannot save file "+e)}function si(e){for(var r=Object.keys(e),a=[],s=0;s<r.length;++s)Object.prototype.hasOwnProperty.call(e,r[s])&&a.push(r[s]);return a}function TE(e,r){for(var a=[],s=si(e),n=0;n!==s.length;++n)a[e[s[n]][r]]==null&&(a[e[s[n]][r]]=s[n]);return a}function aS(e){for(var r=[],a=si(e),s=0;s!==a.length;++s)r[e[a[s]]]=a[s];return r}function Z1(e){for(var r=[],a=si(e),s=0;s!==a.length;++s)r[e[a[s]]]=parseInt(a[s],10);return r}function EK(e){for(var r=[],a=si(e),s=0;s!==a.length;++s)r[e[a[s]]]==null&&(r[e[a[s]]]=[]),r[e[a[s]]].push(a[s]);return r}var Lv=new Date(1899,11,30,0,0,0);function co(e,r){var a=e.getTime(),s=Lv.getTime()+(e.getTimezoneOffset()-Lv.getTimezoneOffset())*6e4;return(a-s)/(1440*60*1e3)}var pR=new Date,AK=Lv.getTime()+(pR.getTimezoneOffset()-Lv.getTimezoneOffset())*6e4,EE=pR.getTimezoneOffset();function gR(e){var r=new Date;return r.setTime(e*24*60*60*1e3+AK),r.getTimezoneOffset()!==EE&&r.setTime(r.getTime()+(r.getTimezoneOffset()-EE)*6e4),r}var AE=new Date("2017-02-19T19:06:09.000Z"),fR=isNaN(AE.getFullYear())?new Date("2/19/17"):AE,OK=fR.getFullYear()==2017;function Mi(e,r){var a=new Date(e);if(OK)return r>0?a.setTime(a.getTime()+a.getTimezoneOffset()*60*1e3):r<0&&a.setTime(a.getTime()-a.getTimezoneOffset()*60*1e3),a;if(e instanceof Date)return e;if(fR.getFullYear()==1917&&!isNaN(a.getFullYear())){var s=a.getFullYear();return e.indexOf(""+s)>-1||a.setFullYear(a.getFullYear()+100),a}var n=e.match(/\d+/g)||["2017","2","19","0","0","0"],i=new Date(+n[0],+n[1]-1,+n[2],+n[3]||0,+n[4]||0,+n[5]||0);return e.indexOf("Z")>-1&&(i=new Date(i.getTime()-i.getTimezoneOffset()*60*1e3)),i}function X1(e,r){if(Ia&&Buffer.isBuffer(e))return e.toString("binary");if(typeof TextDecoder!="undefined")try{var a={"€":"","‚":"",ƒ:"","„":"","…":"
","†":"","‡":"","ˆ":"","‰":"",Š:"","‹":"",Œ:"",Ž:"","‘":"","’":"","“":"","”":"","•":"","–":"","—":"","˜":"","™":"",š:"","›":"",œ:"",ž:"",Ÿ:""};return Array.isArray(e)&&(e=new Uint8Array(e)),new TextDecoder("latin1").decode(e).replace(/[€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ]/g,function(i){return a[i]||i})}catch(i){}for(var s=[],n=0;n!=e.length;++n)s.push(String.fromCharCode(e[n]));return s.join("")}function uo(e){if(typeof JSON!="undefined"&&!Array.isArray(e))return JSON.parse(JSON.stringify(e));if(typeof e!="object"||e==null)return e;if(e instanceof Date)return new Date(e.getTime());var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=uo(e[a]));return r}function Ws(e,r){for(var a="";a.length<r;)a+=e;return a}function Bd(e){var r=Number(e);if(!isNaN(r))return isFinite(r)?r:NaN;if(!/\d/.test(e))return r;var a=1,s=e.replace(/([\d]),([\d])/g,"$1$2").replace(/[$]/g,"").replace(/[%]/g,function(){return a*=100,""});return!isNaN(r=Number(s))||(s=s.replace(/[(](.*)[)]/,function(n,i){return a=-a,i}),!isNaN(r=Number(s)))?r/a:r}var PK=["january","february","march","april","may","june","july","august","september","october","november","december"];function Jf(e){var r=new Date(e),a=new Date(NaN),s=r.getYear(),n=r.getMonth(),i=r.getDate();if(isNaN(i))return a;var o=e.toLowerCase();if(o.match(/jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec/)){if(o=o.replace(/[^a-z]/g,"").replace(/([^a-z]|^)[ap]m?([^a-z]|$)/,""),o.length>3&&PK.indexOf(o)==-1)return a}else if(o.match(/[a-z]/))return a;return s<0||s>8099?a:(n>0||i>1)&&s!=101?r:e.match(/[^-0-9:,\/\\]/)?a:r}function na(e,r,a){if(e.FullPaths){if(typeof a=="string"){var s;return Ia?s=ru(a):s=tK(a),as.utils.cfb_add(e,r,s)}as.utils.cfb_add(e,r,a)}else e.file(r,a)}function sS(){return as.utils.cfb_new()}var mn=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r
|
||
`,DK={""":'"',"'":"'",">":">","<":"<","&":"&"},nS=aS(DK),iS=/[&<>'"]/g,RK=/[\u0000-\u0008\u000b-\u001f]/g;function Ka(e){var r=e+"";return r.replace(iS,function(a){return nS[a]}).replace(RK,function(a){return"_x"+("000"+a.charCodeAt(0).toString(16)).slice(-4)+"_"})}function OE(e){return Ka(e).replace(/ /g,"_x0020_")}var xR=/[\u0000-\u001f]/g;function MK(e){var r=e+"";return r.replace(iS,function(a){return nS[a]}).replace(/\n/g,"<br/>").replace(xR,function(a){return"&#x"+("000"+a.charCodeAt(0).toString(16)).slice(-4)+";"})}function LK(e){var r=e+"";return r.replace(iS,function(a){return nS[a]}).replace(xR,function(a){return"&#x"+a.charCodeAt(0).toString(16).toUpperCase()+";"})}function FK(e){return e.replace(/(\r\n|[\r\n])/g," ")}function IK(e){switch(e){case 1:case!0:case"1":case"true":case"TRUE":return!0;default:return!1}}function ik(e){for(var r="",a=0,s=0,n=0,i=0,o=0,l=0;a<e.length;){if(s=e.charCodeAt(a++),s<128){r+=String.fromCharCode(s);continue}if(n=e.charCodeAt(a++),s>191&&s<224){o=(s&31)<<6,o|=n&63,r+=String.fromCharCode(o);continue}if(i=e.charCodeAt(a++),s<240){r+=String.fromCharCode((s&15)<<12|(n&63)<<6|i&63);continue}o=e.charCodeAt(a++),l=((s&7)<<18|(n&63)<<12|(i&63)<<6|o&63)-65536,r+=String.fromCharCode(55296+(l>>>10&1023)),r+=String.fromCharCode(56320+(l&1023))}return r}function PE(e){var r=wm(2*e.length),a,s,n=1,i=0,o=0,l;for(s=0;s<e.length;s+=n)n=1,(l=e.charCodeAt(s))<128?a=l:l<224?(a=(l&31)*64+(e.charCodeAt(s+1)&63),n=2):l<240?(a=(l&15)*4096+(e.charCodeAt(s+1)&63)*64+(e.charCodeAt(s+2)&63),n=3):(n=4,a=(l&7)*262144+(e.charCodeAt(s+1)&63)*4096+(e.charCodeAt(s+2)&63)*64+(e.charCodeAt(s+3)&63),a-=65536,o=55296+(a>>>10&1023),a=56320+(a&1023)),o!==0&&(r[i++]=o&255,r[i++]=o>>>8,o=0),r[i++]=a%256,r[i++]=a>>>8;return r.slice(0,i).toString("ucs2")}function DE(e){return ru(e,"binary").toString("utf8")}var mb="foo bar bazâð£",Lf=Ia&&(DE(mb)==ik(mb)&&DE||PE(mb)==ik(mb)&&PE)||ik,Zf=Ia?function(e){return ru(e,"utf8").toString("binary")}:function(e){for(var r=[],a=0,s=0,n=0;a<e.length;)switch(s=e.charCodeAt(a++),!0){case s<128:r.push(String.fromCharCode(s));break;case s<2048:r.push(String.fromCharCode(192+(s>>6))),r.push(String.fromCharCode(128+(s&63)));break;case(s>=55296&&s<57344):s-=55296,n=e.charCodeAt(a++)-56320+(s<<10),r.push(String.fromCharCode(240+(n>>18&7))),r.push(String.fromCharCode(144+(n>>12&63))),r.push(String.fromCharCode(128+(n>>6&63))),r.push(String.fromCharCode(128+(n&63)));break;default:r.push(String.fromCharCode(224+(s>>12))),r.push(String.fromCharCode(128+(s>>6&63))),r.push(String.fromCharCode(128+(s&63)))}return r.join("")},zK=(function(){var e=[["nbsp"," "],["middot","·"],["quot",'"'],["apos","'"],["gt",">"],["lt","<"],["amp","&"]].map(function(r){return[new RegExp("&"+r[0]+";","ig"),r[1]]});return function(a){for(var s=a.replace(/^[\t\n\r ]+/,"").replace(/[\t\n\r ]+$/,"").replace(/>\s+/g,">").replace(/\s+</g,"<").replace(/[\t\n\r ]+/g," ").replace(/<\s*[bB][rR]\s*\/?>/g,`
|
||
`).replace(/<[^>]*>/g,""),n=0;n<e.length;++n)s=s.replace(e[n][0],e[n][1]);return s}})(),yR=/(^\s|\s$|\n)/;function ei(e,r){return"<"+e+(r.match(yR)?' xml:space="preserve"':"")+">"+r+"</"+e+">"}function Xf(e){return si(e).map(function(r){return" "+r+'="'+e[r]+'"'}).join("")}function ir(e,r,a){return"<"+e+(a!=null?Xf(a):"")+(r!=null?(r.match(yR)?' xml:space="preserve"':"")+">"+r+"</"+e:"/")+">"}function kN(e,r){try{return e.toISOString().replace(/\.\d*/,"")}catch(a){if(r)throw a}return""}function $K(e,r){switch(typeof e){case"string":var a=ir("vt:lpwstr",Ka(e));return a=a.replace(/"/g,"_x0022_"),a;case"number":return ir((e|0)==e?"vt:i4":"vt:r8",Ka(String(e)));case"boolean":return ir("vt:bool",e?"true":"false")}if(e instanceof Date)return ir("vt:filetime",kN(e));throw new Error("Unable to serialize "+e)}var Dn={CORE_PROPS:"http://schemas.openxmlformats.org/package/2006/metadata/core-properties",CUST_PROPS:"http://schemas.openxmlformats.org/officeDocument/2006/custom-properties",EXT_PROPS:"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties",CT:"http://schemas.openxmlformats.org/package/2006/content-types",RELS:"http://schemas.openxmlformats.org/package/2006/relationships",TCMNT:"http://schemas.microsoft.com/office/spreadsheetml/2018/threadedcomments",dc:"http://purl.org/dc/elements/1.1/",dcterms:"http://purl.org/dc/terms/",dcmitype:"http://purl.org/dc/dcmitype/",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",vt:"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes",xsi:"http://www.w3.org/2001/XMLSchema-instance",xsd:"http://www.w3.org/2001/XMLSchema"},Bp=["http://schemas.openxmlformats.org/spreadsheetml/2006/main","http://purl.oclc.org/ooxml/spreadsheetml/main","http://schemas.microsoft.com/office/excel/2006/main","http://schemas.microsoft.com/office/excel/2006/2"],Lo={o:"urn:schemas-microsoft-com:office:office",x:"urn:schemas-microsoft-com:office:excel",ss:"urn:schemas-microsoft-com:office:spreadsheet",dt:"uuid:C2F41010-65B3-11d1-A29F-00AA00C14882",mv:"http://macVmlSchemaUri",v:"urn:schemas-microsoft-com:vml",html:"http://www.w3.org/TR/REC-html40"};function UK(e,r){for(var a=1-2*(e[r+7]>>>7),s=((e[r+7]&127)<<4)+(e[r+6]>>>4&15),n=e[r+6]&15,i=5;i>=0;--i)n=n*256+e[r+i];return s==2047?n==0?a*(1/0):NaN:(s==0?s=-1022:(s-=1023,n+=Math.pow(2,52)),a*Math.pow(2,s-52)*n)}function BK(e,r,a){var s=(r<0||1/r==-1/0?1:0)<<7,n=0,i=0,o=s?-r:r;isFinite(o)?o==0?n=i=0:(n=Math.floor(Math.log(o)/Math.LN2),i=o*Math.pow(2,52-n),n<=-1023&&(!isFinite(i)||i<Math.pow(2,52))?n=-1022:(i-=Math.pow(2,52),n+=1023)):(n=2047,i=isNaN(r)?26985:0);for(var l=0;l<=5;++l,i/=256)e[a+l]=i&255;e[a+6]=(n&15)<<4|i&15,e[a+7]=n>>4|s}var RE=function(e){for(var r=[],a=10240,s=0;s<e[0].length;++s)if(e[0][s])for(var n=0,i=e[0][s].length;n<i;n+=a)r.push.apply(r,e[0][s].slice(n,n+a));return r},ME=Ia?function(e){return e[0].length>0&&Buffer.isBuffer(e[0][0])?Buffer.concat(e[0].map(function(r){return Buffer.isBuffer(r)?r:ru(r)})):RE(e)}:RE,LE=function(e,r,a){for(var s=[],n=r;n<a;n+=2)s.push(String.fromCharCode(wf(e,n)));return s.join("").replace(Mf,"")},oS=Ia?function(e,r,a){return Buffer.isBuffer(e)?e.toString("utf16le",r,a).replace(Mf,""):LE(e,r,a)}:LE,FE=function(e,r,a){for(var s=[],n=r;n<r+a;++n)s.push(("0"+e[n].toString(16)).slice(-2));return s.join("")},bR=Ia?function(e,r,a){return Buffer.isBuffer(e)?e.toString("hex",r,r+a):FE(e,r,a)}:FE,IE=function(e,r,a){for(var s=[],n=r;n<a;n++)s.push(String.fromCharCode(ap(e,n)));return s.join("")},Sx=Ia?function(r,a,s){return Buffer.isBuffer(r)?r.toString("utf8",a,s):IE(r,a,s)}:IE,vR=function(e,r){var a=Fo(e,r);return a>0?Sx(e,r+4,r+4+a-1):""},wR=vR,jR=function(e,r){var a=Fo(e,r);return a>0?Sx(e,r+4,r+4+a-1):""},_R=jR,kR=function(e,r){var a=2*Fo(e,r);return a>0?Sx(e,r+4,r+4+a-1):""},NR=kR,SR=function(r,a){var s=Fo(r,a);return s>0?oS(r,a+4,a+4+s):""},CR=SR,TR=function(e,r){var a=Fo(e,r);return a>0?Sx(e,r+4,r+4+a):""},ER=TR,AR=function(e,r){return UK(e,r)},Fv=AR,lS=function(r){return Array.isArray(r)||typeof Uint8Array!="undefined"&&r instanceof Uint8Array};Ia&&(wR=function(r,a){if(!Buffer.isBuffer(r))return vR(r,a);var s=r.readUInt32LE(a);return s>0?r.toString("utf8",a+4,a+4+s-1):""},_R=function(r,a){if(!Buffer.isBuffer(r))return jR(r,a);var s=r.readUInt32LE(a);return s>0?r.toString("utf8",a+4,a+4+s-1):""},NR=function(r,a){if(!Buffer.isBuffer(r))return kR(r,a);var s=2*r.readUInt32LE(a);return r.toString("utf16le",a+4,a+4+s-1)},CR=function(r,a){if(!Buffer.isBuffer(r))return SR(r,a);var s=r.readUInt32LE(a);return r.toString("utf16le",a+4,a+4+s)},ER=function(r,a){if(!Buffer.isBuffer(r))return TR(r,a);var s=r.readUInt32LE(a);return r.toString("utf8",a+4,a+4+s)},Fv=function(r,a){return Buffer.isBuffer(r)?r.readDoubleLE(a):AR(r,a)},lS=function(r){return Buffer.isBuffer(r)||Array.isArray(r)||typeof Uint8Array!="undefined"&&r instanceof Uint8Array});var ap=function(e,r){return e[r]},wf=function(e,r){return e[r+1]*256+e[r]},WK=function(e,r){var a=e[r+1]*256+e[r];return a<32768?a:(65535-a+1)*-1},Fo=function(e,r){return e[r+3]*(1<<24)+(e[r+2]<<16)+(e[r+1]<<8)+e[r]},Z0=function(e,r){return e[r+3]<<24|e[r+2]<<16|e[r+1]<<8|e[r]},HK=function(e,r){return e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3]};function Ff(e,r){var a="",s,n,i=[],o,l,c,u;switch(r){case"dbcs":if(u=this.l,Ia&&Buffer.isBuffer(this))a=this.slice(this.l,this.l+2*e).toString("utf16le");else for(c=0;c<e;++c)a+=String.fromCharCode(wf(this,u)),u+=2;e*=2;break;case"utf8":a=Sx(this,this.l,this.l+e);break;case"utf16le":e*=2,a=oS(this,this.l,this.l+e);break;case"wstr":return Ff.call(this,e,"dbcs");case"lpstr-ansi":a=wR(this,this.l),e=4+Fo(this,this.l);break;case"lpstr-cp":a=_R(this,this.l),e=4+Fo(this,this.l);break;case"lpwstr":a=NR(this,this.l),e=4+2*Fo(this,this.l);break;case"lpp4":e=4+Fo(this,this.l),a=CR(this,this.l),e&2&&(e+=2);break;case"8lpp4":e=4+Fo(this,this.l),a=ER(this,this.l),e&3&&(e+=4-(e&3));break;case"cstr":for(e=0,a="";(o=ap(this,this.l+e++))!==0;)i.push(cb(o));a=i.join("");break;case"_wstr":for(e=0,a="";(o=wf(this,this.l+e))!==0;)i.push(cb(o)),e+=2;e+=2,a=i.join("");break;case"dbcs-cont":for(a="",u=this.l,c=0;c<e;++c){if(this.lens&&this.lens.indexOf(u)!==-1)return o=ap(this,u),this.l=u+1,l=Ff.call(this,e-c,o?"dbcs-cont":"sbcs-cont"),i.join("")+l;i.push(cb(wf(this,u))),u+=2}a=i.join(""),e*=2;break;case"cpstr":case"sbcs-cont":for(a="",u=this.l,c=0;c!=e;++c){if(this.lens&&this.lens.indexOf(u)!==-1)return o=ap(this,u),this.l=u+1,l=Ff.call(this,e-c,o?"dbcs-cont":"sbcs-cont"),i.join("")+l;i.push(cb(ap(this,u))),u+=1}a=i.join("");break;default:switch(e){case 1:return s=ap(this,this.l),this.l++,s;case 2:return s=(r==="i"?WK:wf)(this,this.l),this.l+=2,s;case 4:case-4:return r==="i"||(this[this.l+3]&128)===0?(s=(e>0?Z0:HK)(this,this.l),this.l+=4,s):(n=Fo(this,this.l),this.l+=4,n);case 8:case-8:if(r==="f")return e==8?n=Fv(this,this.l):n=Fv([this[this.l+7],this[this.l+6],this[this.l+5],this[this.l+4],this[this.l+3],this[this.l+2],this[this.l+1],this[this.l+0]],0),this.l+=8,n;e=8;case 16:a=bR(this,this.l,e);break}}return this.l+=e,a}var qK=function(e,r,a){e[a]=r&255,e[a+1]=r>>>8&255,e[a+2]=r>>>16&255,e[a+3]=r>>>24&255},VK=function(e,r,a){e[a]=r&255,e[a+1]=r>>8&255,e[a+2]=r>>16&255,e[a+3]=r>>24&255},GK=function(e,r,a){e[a]=r&255,e[a+1]=r>>>8&255};function KK(e,r,a){var s=0,n=0;if(a==="dbcs"){for(n=0;n!=r.length;++n)GK(this,r.charCodeAt(n),this.l+2*n);s=2*r.length}else if(a==="sbcs"){for(r=r.replace(/[^\x00-\x7F]/g,"_"),n=0;n!=r.length;++n)this[this.l+n]=r.charCodeAt(n)&255;s=r.length}else if(a==="hex"){for(;n<e;++n)this[this.l++]=parseInt(r.slice(2*n,2*n+2),16)||0;return this}else if(a==="utf16le"){var i=Math.min(this.l+e,this.length);for(n=0;n<Math.min(r.length,e);++n){var o=r.charCodeAt(n);this[this.l++]=o&255,this[this.l++]=o>>8}for(;this.l<i;)this[this.l++]=0;return this}else switch(e){case 1:s=1,this[this.l]=r&255;break;case 2:s=2,this[this.l]=r&255,r>>>=8,this[this.l+1]=r&255;break;case 3:s=3,this[this.l]=r&255,r>>>=8,this[this.l+1]=r&255,r>>>=8,this[this.l+2]=r&255;break;case 4:s=4,qK(this,r,this.l);break;case 8:if(s=8,a==="f"){BK(this,r,this.l);break}case 16:break;case-4:s=4,VK(this,r,this.l);break}return this.l+=s,this}function OR(e,r){var a=bR(this,this.l,e.length>>1);if(a!==e)throw new Error(r+"Expected "+e+" saw "+a);this.l+=e.length>>1}function Ro(e,r){e.l=r,e.read_shift=Ff,e.chk=OR,e.write_shift=KK}function zc(e,r){e.l+=r}function Ft(e){var r=wm(e);return Ro(r,0),r}function io(){var e=[],r=Ia?256:2048,a=function(u){var h=Ft(u);return Ro(h,0),h},s=a(r),n=function(){s&&(s.length>s.l&&(s=s.slice(0,s.l),s.l=s.length),s.length>0&&e.push(s),s=null)},i=function(u){return s&&u<s.length-s.l?s:(n(),s=a(Math.max(u+1,r)))},o=function(){return n(),Qn(e)},l=function(u){n(),s=u,s.l==null&&(s.l=s.length),i(r)};return{next:i,push:l,end:o,_bufs:e}}function Jt(e,r,a,s){var n=+r,i;if(!isNaN(n)){s||(s=Uee[n].p||(a||[]).length||0),i=1+(n>=128?1:0)+1,s>=128&&++i,s>=16384&&++i,s>=2097152&&++i;var o=e.next(i);n<=127?o.write_shift(1,n):(o.write_shift(1,(n&127)+128),o.write_shift(1,n>>7));for(var l=0;l!=4;++l)if(s>=128)o.write_shift(1,(s&127)+128),s>>=7;else{o.write_shift(1,s);break}s>0&&lS(a)&&e.push(a)}}function If(e,r,a){var s=uo(e);if(r.s?(s.cRel&&(s.c+=r.s.c),s.rRel&&(s.r+=r.s.r)):(s.cRel&&(s.c+=r.c),s.rRel&&(s.r+=r.r)),!a||a.biff<12){for(;s.c>=256;)s.c-=256;for(;s.r>=65536;)s.r-=65536}return s}function zE(e,r,a){var s=uo(e);return s.s=If(s.s,r.s,a),s.e=If(s.e,r.s,a),s}function zf(e,r){if(e.cRel&&e.c<0)for(e=uo(e);e.c<0;)e.c+=r>8?16384:256;if(e.rRel&&e.r<0)for(e=uo(e);e.r<0;)e.r+=r>8?1048576:r>5?65536:16384;var a=Ya(e);return!e.cRel&&e.cRel!=null&&(a=ZK(a)),!e.rRel&&e.rRel!=null&&(a=YK(a)),a}function ok(e,r){return e.s.r==0&&!e.s.rRel&&e.e.r==(r.biff>=12?1048575:r.biff>=8?65536:16384)&&!e.e.rRel?(e.s.cRel?"":"$")+gi(e.s.c)+":"+(e.e.cRel?"":"$")+gi(e.e.c):e.s.c==0&&!e.s.cRel&&e.e.c==(r.biff>=12?16383:255)&&!e.e.cRel?(e.s.rRel?"":"$")+ai(e.s.r)+":"+(e.e.rRel?"":"$")+ai(e.e.r):zf(e.s,r.biff)+":"+zf(e.e,r.biff)}function cS(e){return parseInt(JK(e),10)-1}function ai(e){return""+(e+1)}function YK(e){return e.replace(/([A-Z]|^)(\d+)$/,"$1$$$2")}function JK(e){return e.replace(/\$(\d+)$/,"$1")}function dS(e){for(var r=XK(e),a=0,s=0;s!==r.length;++s)a=26*a+r.charCodeAt(s)-64;return a-1}function gi(e){if(e<0)throw new Error("invalid column "+e);var r="";for(++e;e;e=Math.floor((e-1)/26))r=String.fromCharCode((e-1)%26+65)+r;return r}function ZK(e){return e.replace(/^([A-Z])/,"$$$1")}function XK(e){return e.replace(/^\$([A-Z])/,"$1")}function QK(e){return e.replace(/(\$?[A-Z]*)(\$?\d*)/,"$1,$2").split(",")}function Rn(e){for(var r=0,a=0,s=0;s<e.length;++s){var n=e.charCodeAt(s);n>=48&&n<=57?r=10*r+(n-48):n>=65&&n<=90&&(a=26*a+(n-64))}return{c:a-1,r:r-1}}function Ya(e){for(var r=e.c+1,a="";r;r=(r-1)/26|0)a=String.fromCharCode((r-1)%26+65)+a;return a+(e.r+1)}function Wo(e){var r=e.indexOf(":");return r==-1?{s:Rn(e),e:Rn(e)}:{s:Rn(e.slice(0,r)),e:Rn(e.slice(r+1))}}function ln(e,r){return typeof r=="undefined"||typeof r=="number"?ln(e.s,e.e):(typeof e!="string"&&(e=Ya(e)),typeof r!="string"&&(r=Ya(r)),e==r?e:e+":"+r)}function vs(e){var r={s:{c:0,r:0},e:{c:0,r:0}},a=0,s=0,n=0,i=e.length;for(a=0;s<i&&!((n=e.charCodeAt(s)-64)<1||n>26);++s)a=26*a+n;for(r.s.c=--a,a=0;s<i&&!((n=e.charCodeAt(s)-48)<0||n>9);++s)a=10*a+n;if(r.s.r=--a,s===i||n!=10)return r.e.c=r.s.c,r.e.r=r.s.r,r;for(++s,a=0;s!=i&&!((n=e.charCodeAt(s)-64)<1||n>26);++s)a=26*a+n;for(r.e.c=--a,a=0;s!=i&&!((n=e.charCodeAt(s)-48)<0||n>9);++s)a=10*a+n;return r.e.r=--a,r}function $E(e,r){var a=e.t=="d"&&r instanceof Date;if(e.z!=null)try{return e.w=Xu(e.z,a?co(r):r)}catch(s){}try{return e.w=Xu((e.XF||{}).numFmtId||(a?14:0),a?co(r):r)}catch(s){return""+r}}function Yd(e,r,a){return e==null||e.t==null||e.t=="z"?"":e.w!==void 0?e.w:(e.t=="d"&&!e.z&&a&&a.dateNF&&(e.z=a.dateNF),e.t=="e"?Cx[e.v]||e.v:r==null?$E(e,e.v):$E(e,r))}function Fm(e,r){var a=r&&r.sheet?r.sheet:"Sheet1",s={};return s[a]=e,{SheetNames:[a],Sheets:s}}function PR(e,r,a){var s=a||{},n=e?Array.isArray(e):s.dense,i=e||(n?[]:{}),o=0,l=0;if(i&&s.origin!=null){if(typeof s.origin=="number")o=s.origin;else{var c=typeof s.origin=="string"?Rn(s.origin):s.origin;o=c.r,l=c.c}i["!ref"]||(i["!ref"]="A1:A1")}var u={s:{c:1e7,r:1e7},e:{c:0,r:0}};if(i["!ref"]){var h=vs(i["!ref"]);u.s.c=h.s.c,u.s.r=h.s.r,u.e.c=Math.max(u.e.c,h.e.c),u.e.r=Math.max(u.e.r,h.e.r),o==-1&&(u.e.r=o=h.e.r+1)}for(var f=0;f!=r.length;++f)if(r[f]){if(!Array.isArray(r[f]))throw new Error("aoa_to_sheet expects an array of arrays");for(var y=0;y!=r[f].length;++y)if(typeof r[f][y]!="undefined"){var b={v:r[f][y]},w=o+f,v=l+y;if(u.s.r>w&&(u.s.r=w),u.s.c>v&&(u.s.c=v),u.e.r<w&&(u.e.r=w),u.e.c<v&&(u.e.c=v),r[f][y]&&typeof r[f][y]=="object"&&!Array.isArray(r[f][y])&&!(r[f][y]instanceof Date))b=r[f][y];else if(Array.isArray(b.v)&&(b.f=r[f][y][1],b.v=b.v[0]),b.v===null)if(b.f)b.t="n";else if(s.nullError)b.t="e",b.v=0;else if(s.sheetStubs)b.t="z";else continue;else typeof b.v=="number"?b.t="n":typeof b.v=="boolean"?b.t="b":b.v instanceof Date?(b.z=s.dateNF||Hs[14],s.cellDates?(b.t="d",b.w=Xu(b.z,co(b.v))):(b.t="n",b.v=co(b.v),b.w=Xu(b.z,b.v))):b.t="s";if(n)i[w]||(i[w]=[]),i[w][v]&&i[w][v].z&&(b.z=i[w][v].z),i[w][v]=b;else{var k=Ya({c:v,r:w});i[k]&&i[k].z&&(b.z=i[k].z),i[k]=b}}}return u.s.c<1e7&&(i["!ref"]=ln(u)),i}function Wp(e,r){return PR(null,e,r)}function eY(e){return e.read_shift(4,"i")}function ec(e,r){return r||(r=Ft(4)),r.write_shift(4,e),r}function fi(e){var r=e.read_shift(4);return r===0?"":e.read_shift(r,"dbcs")}function Mn(e,r){var a=!1;return r==null&&(a=!0,r=Ft(4+2*e.length)),r.write_shift(4,e.length),e.length>0&&r.write_shift(0,e,"dbcs"),a?r.slice(0,r.l):r}function tY(e){return{ich:e.read_shift(2),ifnt:e.read_shift(2)}}function rY(e,r){return r||(r=Ft(4)),r.write_shift(2,0),r.write_shift(2,0),r}function uS(e,r){var a=e.l,s=e.read_shift(1),n=fi(e),i=[],o={t:n,h:n};if((s&1)!==0){for(var l=e.read_shift(4),c=0;c!=l;++c)i.push(tY(e));o.r=i}else o.r=[{ich:0,ifnt:0}];return e.l=a+r,o}function aY(e,r){var a=!1;return r==null&&(a=!0,r=Ft(15+4*e.t.length)),r.write_shift(1,0),Mn(e.t,r),a?r.slice(0,r.l):r}var sY=uS;function nY(e,r){var a=!1;return r==null&&(a=!0,r=Ft(23+4*e.t.length)),r.write_shift(1,1),Mn(e.t,r),r.write_shift(4,1),rY({},r),a?r.slice(0,r.l):r}function jl(e){var r=e.read_shift(4),a=e.read_shift(2);return a+=e.read_shift(1)<<16,e.l++,{c:r,iStyleRef:a}}function Im(e,r){return r==null&&(r=Ft(8)),r.write_shift(-4,e.c),r.write_shift(3,e.iStyleRef||e.s),r.write_shift(1,0),r}function zm(e){var r=e.read_shift(2);return r+=e.read_shift(1)<<16,e.l++,{c:-1,iStyleRef:r}}function $m(e,r){return r==null&&(r=Ft(4)),r.write_shift(3,e.iStyleRef||e.s),r.write_shift(1,0),r}var iY=fi,DR=Mn;function mS(e){var r=e.read_shift(4);return r===0||r===4294967295?"":e.read_shift(r,"dbcs")}function Iv(e,r){var a=!1;return r==null&&(a=!0,r=Ft(127)),r.write_shift(4,e.length>0?e.length:4294967295),e.length>0&&r.write_shift(0,e,"dbcs"),a?r.slice(0,r.l):r}var oY=fi,NN=mS,hS=Iv;function RR(e){var r=e.slice(e.l,e.l+4),a=r[0]&1,s=r[0]&2;e.l+=4;var n=s===0?Fv([0,0,0,0,r[0]&252,r[1],r[2],r[3]],0):Z0(r,0)>>2;return a?n/100:n}function MR(e,r){r==null&&(r=Ft(4));var a=0,s=0,n=e*100;if(e==(e|0)&&e>=-536870912&&e<1<<29?s=1:n==(n|0)&&n>=-536870912&&n<1<<29&&(s=1,a=1),s)r.write_shift(-4,((a?n:e)<<2)+(a+2));else throw new Error("unsupported RkNumber "+e)}function LR(e){var r={s:{},e:{}};return r.s.r=e.read_shift(4),r.e.r=e.read_shift(4),r.s.c=e.read_shift(4),r.e.c=e.read_shift(4),r}function lY(e,r){return r||(r=Ft(16)),r.write_shift(4,e.s.r),r.write_shift(4,e.e.r),r.write_shift(4,e.s.c),r.write_shift(4,e.e.c),r}var Um=LR,Hp=lY;function qp(e){if(e.length-e.l<8)throw"XLS Xnum Buffer underflow";return e.read_shift(8,"f")}function jm(e,r){return(r||Ft(8)).write_shift(8,e,"f")}function cY(e){var r={},a=e.read_shift(1),s=a>>>1,n=e.read_shift(1),i=e.read_shift(2,"i"),o=e.read_shift(1),l=e.read_shift(1),c=e.read_shift(1);switch(e.l++,s){case 0:r.auto=1;break;case 1:r.index=n;var u=yY[n];u&&(r.rgb=ZE(u));break;case 2:r.rgb=ZE([o,l,c]);break;case 3:r.theme=n;break}return i!=0&&(r.tint=i>0?i/32767:i/32768),r}function zv(e,r){if(r||(r=Ft(8)),!e||e.auto)return r.write_shift(4,0),r.write_shift(4,0),r;e.index!=null?(r.write_shift(1,2),r.write_shift(1,e.index)):e.theme!=null?(r.write_shift(1,6),r.write_shift(1,e.theme)):(r.write_shift(1,5),r.write_shift(1,0));var a=e.tint||0;if(a>0?a*=32767:a<0&&(a*=32768),r.write_shift(2,a),!e.rgb||e.theme!=null)r.write_shift(2,0),r.write_shift(1,0),r.write_shift(1,0);else{var s=e.rgb||"FFFFFF";typeof s=="number"&&(s=("000000"+s.toString(16)).slice(-6)),r.write_shift(1,parseInt(s.slice(0,2),16)),r.write_shift(1,parseInt(s.slice(2,4),16)),r.write_shift(1,parseInt(s.slice(4,6),16)),r.write_shift(1,255)}return r}function dY(e){var r=e.read_shift(1);e.l++;var a={fBold:r&1,fItalic:r&2,fUnderline:r&4,fStrikeout:r&8,fOutline:r&16,fShadow:r&32,fCondense:r&64,fExtend:r&128};return a}function uY(e,r){r||(r=Ft(2));var a=(e.italic?2:0)|(e.strike?8:0)|(e.outline?16:0)|(e.shadow?32:0)|(e.condense?64:0)|(e.extend?128:0);return r.write_shift(1,a),r.write_shift(1,0),r}var FR=2,Do=3,hb=11,$v=19,pb=64,mY=65,hY=71,pY=4108,gY=4126,Zn=80,UE={1:{n:"CodePage",t:FR},2:{n:"Category",t:Zn},3:{n:"PresentationFormat",t:Zn},4:{n:"ByteCount",t:Do},5:{n:"LineCount",t:Do},6:{n:"ParagraphCount",t:Do},7:{n:"SlideCount",t:Do},8:{n:"NoteCount",t:Do},9:{n:"HiddenCount",t:Do},10:{n:"MultimediaClipCount",t:Do},11:{n:"ScaleCrop",t:hb},12:{n:"HeadingPairs",t:pY},13:{n:"TitlesOfParts",t:gY},14:{n:"Manager",t:Zn},15:{n:"Company",t:Zn},16:{n:"LinksUpToDate",t:hb},17:{n:"CharacterCount",t:Do},19:{n:"SharedDoc",t:hb},22:{n:"HyperlinksChanged",t:hb},23:{n:"AppVersion",t:Do,p:"version"},24:{n:"DigSig",t:mY},26:{n:"ContentType",t:Zn},27:{n:"ContentStatus",t:Zn},28:{n:"Language",t:Zn},29:{n:"Version",t:Zn},255:{},2147483648:{n:"Locale",t:$v},2147483651:{n:"Behavior",t:$v},1919054434:{}},BE={1:{n:"CodePage",t:FR},2:{n:"Title",t:Zn},3:{n:"Subject",t:Zn},4:{n:"Author",t:Zn},5:{n:"Keywords",t:Zn},6:{n:"Comments",t:Zn},7:{n:"Template",t:Zn},8:{n:"LastAuthor",t:Zn},9:{n:"RevNumber",t:Zn},10:{n:"EditTime",t:pb},11:{n:"LastPrinted",t:pb},12:{n:"CreatedDate",t:pb},13:{n:"ModifiedDate",t:pb},14:{n:"PageCount",t:Do},15:{n:"WordCount",t:Do},16:{n:"CharCount",t:Do},17:{n:"Thumbnail",t:hY},18:{n:"Application",t:Zn},19:{n:"DocSecurity",t:Do},255:{},2147483648:{n:"Locale",t:$v},2147483651:{n:"Behavior",t:$v},1919054434:{}};function fY(e){return e.map(function(r){return[r>>16&255,r>>8&255,r&255]})}var xY=fY([0,16777215,16711680,65280,255,16776960,16711935,65535,0,16777215,16711680,65280,255,16776960,16711935,65535,8388608,32768,128,8421376,8388736,32896,12632256,8421504,10066431,10040166,16777164,13434879,6684774,16744576,26316,13421823,128,16711935,16776960,65535,8388736,8388608,32896,255,52479,13434879,13434828,16777113,10079487,16751052,13408767,16764057,3368703,3394764,10079232,16763904,16750848,16737792,6710937,9868950,13158,3381606,13056,3355392,10040064,10040166,3355545,3355443,16777215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),yY=uo(xY),Cx={0:"#NULL!",7:"#DIV/0!",15:"#VALUE!",23:"#REF!",29:"#NAME?",36:"#NUM!",42:"#N/A",43:"#GETTING_DATA",255:"#WTF?"},bY={"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml":"workbooks","application/vnd.ms-excel.sheet.macroEnabled.main+xml":"workbooks","application/vnd.ms-excel.sheet.binary.macroEnabled.main":"workbooks","application/vnd.ms-excel.addin.macroEnabled.main+xml":"workbooks","application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml":"workbooks","application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml":"sheets","application/vnd.ms-excel.worksheet":"sheets","application/vnd.ms-excel.binIndexWs":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml":"charts","application/vnd.ms-excel.chartsheet":"charts","application/vnd.ms-excel.macrosheet+xml":"macros","application/vnd.ms-excel.macrosheet":"macros","application/vnd.ms-excel.intlmacrosheet":"TODO","application/vnd.ms-excel.binIndexMs":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml":"dialogs","application/vnd.ms-excel.dialogsheet":"dialogs","application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml":"strs","application/vnd.ms-excel.sharedStrings":"strs","application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml":"styles","application/vnd.ms-excel.styles":"styles","application/vnd.openxmlformats-package.core-properties+xml":"coreprops","application/vnd.openxmlformats-officedocument.custom-properties+xml":"custprops","application/vnd.openxmlformats-officedocument.extended-properties+xml":"extprops","application/vnd.openxmlformats-officedocument.customXmlProperties+xml":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.customProperty":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml":"comments","application/vnd.ms-excel.comments":"comments","application/vnd.ms-excel.threadedcomments+xml":"threadedcomments","application/vnd.ms-excel.person+xml":"people","application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml":"metadata","application/vnd.ms-excel.sheetMetadata":"metadata","application/vnd.ms-excel.pivotTable":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml":"TODO","application/vnd.openxmlformats-officedocument.drawingml.chart+xml":"TODO","application/vnd.ms-office.chartcolorstyle+xml":"TODO","application/vnd.ms-office.chartstyle+xml":"TODO","application/vnd.ms-office.chartex+xml":"TODO","application/vnd.ms-excel.calcChain":"calcchains","application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml":"calcchains","application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings":"TODO","application/vnd.ms-office.activeX":"TODO","application/vnd.ms-office.activeX+xml":"TODO","application/vnd.ms-excel.attachedToolbars":"TODO","application/vnd.ms-excel.connections":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml":"TODO","application/vnd.ms-excel.externalLink":"links","application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml":"links","application/vnd.ms-excel.pivotCacheDefinition":"TODO","application/vnd.ms-excel.pivotCacheRecords":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml":"TODO","application/vnd.ms-excel.queryTable":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.queryTable+xml":"TODO","application/vnd.ms-excel.userNames":"TODO","application/vnd.ms-excel.revisionHeaders":"TODO","application/vnd.ms-excel.revisionLog":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.revisionHeaders+xml":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.revisionLog+xml":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.userNames+xml":"TODO","application/vnd.ms-excel.tableSingleCells":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.tableSingleCells+xml":"TODO","application/vnd.ms-excel.slicer":"TODO","application/vnd.ms-excel.slicerCache":"TODO","application/vnd.ms-excel.slicer+xml":"TODO","application/vnd.ms-excel.slicerCache+xml":"TODO","application/vnd.ms-excel.wsSortMap":"TODO","application/vnd.ms-excel.table":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml":"TODO","application/vnd.openxmlformats-officedocument.theme+xml":"themes","application/vnd.openxmlformats-officedocument.themeOverride+xml":"TODO","application/vnd.ms-excel.Timeline+xml":"TODO","application/vnd.ms-excel.TimelineCache+xml":"TODO","application/vnd.ms-office.vbaProject":"vba","application/vnd.ms-office.vbaProjectSignature":"TODO","application/vnd.ms-office.volatileDependencies":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.volatileDependencies+xml":"TODO","application/vnd.ms-excel.controlproperties+xml":"TODO","application/vnd.openxmlformats-officedocument.model+data":"TODO","application/vnd.ms-excel.Survey+xml":"TODO","application/vnd.openxmlformats-officedocument.drawing+xml":"drawings","application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml":"TODO","application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml":"TODO","application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml":"TODO","application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml":"TODO","application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml":"TODO","application/vnd.openxmlformats-officedocument.vmlDrawing":"TODO","application/vnd.openxmlformats-package.relationships+xml":"rels","application/vnd.openxmlformats-officedocument.oleObject":"TODO","image/png":"TODO",sheet:"js"},gb={workbooks:{xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",xlsm:"application/vnd.ms-excel.sheet.macroEnabled.main+xml",xlsb:"application/vnd.ms-excel.sheet.binary.macroEnabled.main",xlam:"application/vnd.ms-excel.addin.macroEnabled.main+xml",xltx:"application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml"},strs:{xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",xlsb:"application/vnd.ms-excel.sharedStrings"},comments:{xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml",xlsb:"application/vnd.ms-excel.comments"},sheets:{xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",xlsb:"application/vnd.ms-excel.worksheet"},charts:{xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml",xlsb:"application/vnd.ms-excel.chartsheet"},dialogs:{xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml",xlsb:"application/vnd.ms-excel.dialogsheet"},macros:{xlsx:"application/vnd.ms-excel.macrosheet+xml",xlsb:"application/vnd.ms-excel.macrosheet"},metadata:{xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml",xlsb:"application/vnd.ms-excel.sheetMetadata"},styles:{xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",xlsb:"application/vnd.ms-excel.styles"}};function IR(){return{workbooks:[],sheets:[],charts:[],dialogs:[],macros:[],rels:[],strs:[],comments:[],threadedcomments:[],links:[],coreprops:[],extprops:[],custprops:[],themes:[],styles:[],calcchains:[],vba:[],drawings:[],metadata:[],people:[],TODO:[],xmlns:""}}function zR(e,r){var a=EK(bY),s=[],n;s[s.length]=mn,s[s.length]=ir("Types",null,{xmlns:Dn.CT,"xmlns:xsd":Dn.xsd,"xmlns:xsi":Dn.xsi}),s=s.concat([["xml","application/xml"],["bin","application/vnd.ms-excel.sheet.binary.macroEnabled.main"],["vml","application/vnd.openxmlformats-officedocument.vmlDrawing"],["data","application/vnd.openxmlformats-officedocument.model+data"],["bmp","image/bmp"],["png","image/png"],["gif","image/gif"],["emf","image/x-emf"],["wmf","image/x-wmf"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["tif","image/tiff"],["tiff","image/tiff"],["pdf","application/pdf"],["rels","application/vnd.openxmlformats-package.relationships+xml"]].map(function(c){return ir("Default",null,{Extension:c[0],ContentType:c[1]})}));var i=function(c){e[c]&&e[c].length>0&&(n=e[c][0],s[s.length]=ir("Override",null,{PartName:(n[0]=="/"?"":"/")+n,ContentType:gb[c][r.bookType]||gb[c].xlsx}))},o=function(c){(e[c]||[]).forEach(function(u){s[s.length]=ir("Override",null,{PartName:(u[0]=="/"?"":"/")+u,ContentType:gb[c][r.bookType]||gb[c].xlsx})})},l=function(c){(e[c]||[]).forEach(function(u){s[s.length]=ir("Override",null,{PartName:(u[0]=="/"?"":"/")+u,ContentType:a[c][0]})})};return i("workbooks"),o("sheets"),o("charts"),l("themes"),["strs","styles"].forEach(i),["coreprops","extprops","custprops"].forEach(l),l("vba"),l("comments"),l("threadedcomments"),l("drawings"),o("metadata"),l("people"),s.length>2&&(s[s.length]="</Types>",s[1]=s[1].replace("/>",">")),s.join("")}var Da={WB:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",HLINK:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",VML:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing",XPATH:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath",XMISS:"http://schemas.microsoft.com/office/2006/relationships/xlExternalLinkPath/xlPathMissing",CMNT:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",CORE_PROPS:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",EXT_PROPS:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",CUST_PROPS:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties",SST:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings",STY:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",THEME:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",WS:["http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet","http://purl.oclc.org/ooxml/officeDocument/relationships/worksheet"],DRAW:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",XLMETA:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sheetMetadata",TCMNT:"http://schemas.microsoft.com/office/2017/10/relationships/threadedComment",PEOPLE:"http://schemas.microsoft.com/office/2017/10/relationships/person",VBA:"http://schemas.microsoft.com/office/2006/relationships/vbaProject"};function $R(e){var r=e.lastIndexOf("/");return e.slice(0,r+1)+"_rels/"+e.slice(r+1)+".rels"}function xp(e){var r=[mn,ir("Relationships",null,{xmlns:Dn.RELS})];return si(e["!id"]).forEach(function(a){r[r.length]=ir("Relationship",null,e["!id"][a])}),r.length>2&&(r[r.length]="</Relationships>",r[1]=r[1].replace("/>",">")),r.join("")}function Ga(e,r,a,s,n,i){if(n||(n={}),e["!id"]||(e["!id"]={}),e["!idx"]||(e["!idx"]=1),r<0)for(r=e["!idx"];e["!id"]["rId"+r];++r);if(e["!idx"]=r+1,n.Id="rId"+r,n.Type=s,n.Target=a,[Da.HLINK,Da.XPATH,Da.XMISS].indexOf(n.Type)>-1&&(n.TargetMode="External"),e["!id"][n.Id])throw new Error("Cannot rewrite rId "+r);return e["!id"][n.Id]=n,e[("/"+n.Target).replace("//","/")]=n,r}function vY(e){var r=[mn];r.push(`<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.2">
|
||
`),r.push(` <manifest:file-entry manifest:full-path="/" manifest:version="1.2" manifest:media-type="application/vnd.oasis.opendocument.spreadsheet"/>
|
||
`);for(var a=0;a<e.length;++a)r.push(' <manifest:file-entry manifest:full-path="'+e[a][0]+'" manifest:media-type="'+e[a][1]+`"/>
|
||
`);return r.push("</manifest:manifest>"),r.join("")}function WE(e,r,a){return[' <rdf:Description rdf:about="'+e+`">
|
||
`,' <rdf:type rdf:resource="http://docs.oasis-open.org/ns/office/1.2/meta/'+(a||"odf")+"#"+r+`"/>
|
||
`,` </rdf:Description>
|
||
`].join("")}function wY(e,r){return[' <rdf:Description rdf:about="'+e+`">
|
||
`,' <ns0:hasPart xmlns:ns0="http://docs.oasis-open.org/ns/office/1.2/meta/pkg#" rdf:resource="'+r+`"/>
|
||
`,` </rdf:Description>
|
||
`].join("")}function jY(e){var r=[mn];r.push(`<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||
`);for(var a=0;a!=e.length;++a)r.push(WE(e[a][0],e[a][1])),r.push(wY("",e[a][0]));return r.push(WE("","Document","pkg")),r.push("</rdf:RDF>"),r.join("")}function UR(){return'<office:document-meta xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xlink="http://www.w3.org/1999/xlink" office:version="1.2"><office:meta><meta:generator>SheetJS '+Ov.version+"</meta:generator></office:meta></office:document-meta>"}var um=[["cp:category","Category"],["cp:contentStatus","ContentStatus"],["cp:keywords","Keywords"],["cp:lastModifiedBy","LastAuthor"],["cp:lastPrinted","LastPrinted"],["cp:revision","RevNumber"],["cp:version","Version"],["dc:creator","Author"],["dc:description","Comments"],["dc:identifier","Identifier"],["dc:language","Language"],["dc:subject","Subject"],["dc:title","Title"],["dcterms:created","CreatedDate","date"],["dcterms:modified","ModifiedDate","date"]];function lk(e,r,a,s,n){n[e]!=null||r==null||r===""||(n[e]=r,r=Ka(r),s[s.length]=a?ir(e,r,a):ei(e,r))}function BR(e,r){var a=r||{},s=[mn,ir("cp:coreProperties",null,{"xmlns:cp":Dn.CORE_PROPS,"xmlns:dc":Dn.dc,"xmlns:dcterms":Dn.dcterms,"xmlns:dcmitype":Dn.dcmitype,"xmlns:xsi":Dn.xsi})],n={};if(!e&&!a.Props)return s.join("");e&&(e.CreatedDate!=null&&lk("dcterms:created",typeof e.CreatedDate=="string"?e.CreatedDate:kN(e.CreatedDate,a.WTF),{"xsi:type":"dcterms:W3CDTF"},s,n),e.ModifiedDate!=null&&lk("dcterms:modified",typeof e.ModifiedDate=="string"?e.ModifiedDate:kN(e.ModifiedDate,a.WTF),{"xsi:type":"dcterms:W3CDTF"},s,n));for(var i=0;i!=um.length;++i){var o=um[i],l=a.Props&&a.Props[o[1]]!=null?a.Props[o[1]]:e?e[o[1]]:null;l===!0?l="1":l===!1?l="0":typeof l=="number"&&(l=String(l)),l!=null&&lk(o[0],l,null,s,n)}return s.length>2&&(s[s.length]="</cp:coreProperties>",s[1]=s[1].replace("/>",">")),s.join("")}var yp=[["Application","Application","string"],["AppVersion","AppVersion","string"],["Company","Company","string"],["DocSecurity","DocSecurity","string"],["Manager","Manager","string"],["HyperlinksChanged","HyperlinksChanged","bool"],["SharedDoc","SharedDoc","bool"],["LinksUpToDate","LinksUpToDate","bool"],["ScaleCrop","ScaleCrop","bool"],["HeadingPairs","HeadingPairs","raw"],["TitlesOfParts","TitlesOfParts","raw"]],WR=["Worksheets","SheetNames","NamedRanges","DefinedNames","Chartsheets","ChartNames"];function HR(e){var r=[],a=ir;return e||(e={}),e.Application="SheetJS",r[r.length]=mn,r[r.length]=ir("Properties",null,{xmlns:Dn.EXT_PROPS,"xmlns:vt":Dn.vt}),yp.forEach(function(s){if(e[s[1]]!==void 0){var n;switch(s[2]){case"string":n=Ka(String(e[s[1]]));break;case"bool":n=e[s[1]]?"true":"false";break}n!==void 0&&(r[r.length]=a(s[0],n))}}),r[r.length]=a("HeadingPairs",a("vt:vector",a("vt:variant","<vt:lpstr>Worksheets</vt:lpstr>")+a("vt:variant",a("vt:i4",String(e.Worksheets))),{size:2,baseType:"variant"})),r[r.length]=a("TitlesOfParts",a("vt:vector",e.SheetNames.map(function(s){return"<vt:lpstr>"+Ka(s)+"</vt:lpstr>"}).join(""),{size:e.Worksheets,baseType:"lpstr"})),r.length>2&&(r[r.length]="</Properties>",r[1]=r[1].replace("/>",">")),r.join("")}function qR(e){var r=[mn,ir("Properties",null,{xmlns:Dn.CUST_PROPS,"xmlns:vt":Dn.vt})];if(!e)return r.join("");var a=1;return si(e).forEach(function(n){++a,r[r.length]=ir("property",$K(e[n]),{fmtid:"{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",pid:a,name:Ka(n)})}),r.length>2&&(r[r.length]="</Properties>",r[1]=r[1].replace("/>",">")),r.join("")}var HE={Title:"Title",Subject:"Subject",Author:"Author",Keywords:"Keywords",Comments:"Description",LastAuthor:"LastAuthor",RevNumber:"Revision",Application:"AppName",LastPrinted:"LastPrinted",CreatedDate:"Created",ModifiedDate:"LastSaved",Category:"Category",Manager:"Manager",Company:"Company",AppVersion:"Version",ContentStatus:"ContentStatus",Identifier:"Identifier",Language:"Language"};function _Y(e,r){var a=[];return si(HE).map(function(s){for(var n=0;n<um.length;++n)if(um[n][1]==s)return um[n];for(n=0;n<yp.length;++n)if(yp[n][1]==s)return yp[n];throw s}).forEach(function(s){if(e[s[1]]!=null){var n=r&&r.Props&&r.Props[s[1]]!=null?r.Props[s[1]]:e[s[1]];switch(s[2]){case"date":n=new Date(n).toISOString().replace(/\.\d*Z/,"Z");break}typeof n=="number"?n=String(n):n===!0||n===!1?n=n?"1":"0":n instanceof Date&&(n=new Date(n).toISOString().replace(/\.\d*Z/,"")),a.push(ei(HE[s[1]]||s[1],n))}}),ir("DocumentProperties",a.join(""),{xmlns:Lo.o})}function kY(e,r){var a=["Worksheets","SheetNames"],s="CustomDocumentProperties",n=[];return e&&si(e).forEach(function(i){if(Object.prototype.hasOwnProperty.call(e,i)){for(var o=0;o<um.length;++o)if(i==um[o][1])return;for(o=0;o<yp.length;++o)if(i==yp[o][1])return;for(o=0;o<a.length;++o)if(i==a[o])return;var l=e[i],c="string";typeof l=="number"?(c="float",l=String(l)):l===!0||l===!1?(c="boolean",l=l?"1":"0"):l=String(l),n.push(ir(OE(i),l,{"dt:dt":c}))}}),r&&si(r).forEach(function(i){if(Object.prototype.hasOwnProperty.call(r,i)&&!(e&&Object.prototype.hasOwnProperty.call(e,i))){var o=r[i],l="string";typeof o=="number"?(l="float",o=String(o)):o===!0||o===!1?(l="boolean",o=o?"1":"0"):o instanceof Date?(l="dateTime.tz",o=o.toISOString()):o=String(o),n.push(ir(OE(i),o,{"dt:dt":l}))}}),"<"+s+' xmlns="'+Lo.o+'">'+n.join("")+"</"+s+">"}function NY(e){var r=typeof e=="string"?new Date(Date.parse(e)):e,a=r.getTime()/1e3+11644473600,s=a%Math.pow(2,32),n=(a-s)/Math.pow(2,32);s*=1e7,n*=1e7;var i=s/Math.pow(2,32)|0;i>0&&(s=s%Math.pow(2,32),n+=i);var o=Ft(8);return o.write_shift(4,s),o.write_shift(4,n),o}function qE(e,r){var a=Ft(4),s=Ft(4);switch(a.write_shift(4,e==80?31:e),e){case 3:s.write_shift(-4,r);break;case 5:s=Ft(8),s.write_shift(8,r,"f");break;case 11:s.write_shift(4,r?1:0);break;case 64:s=NY(r);break;case 31:case 80:for(s=Ft(4+2*(r.length+1)+(r.length%2?0:2)),s.write_shift(4,r.length+1),s.write_shift(0,r,"dbcs");s.l!=s.length;)s.write_shift(1,0);break;default:throw new Error("TypedPropertyValue unrecognized type "+e+" "+r)}return Qn([a,s])}var VR=["CodePage","Thumbnail","_PID_LINKBASE","_PID_HLINKS","SystemIdentifier","FMTID"];function SY(e){switch(typeof e){case"boolean":return 11;case"number":return(e|0)==e?3:5;case"string":return 31;case"object":if(e instanceof Date)return 64;break}return-1}function VE(e,r,a){var s=Ft(8),n=[],i=[],o=8,l=0,c=Ft(8),u=Ft(8);if(c.write_shift(4,2),c.write_shift(4,1200),u.write_shift(4,1),i.push(c),n.push(u),o+=8+c.length,!r){u=Ft(8),u.write_shift(4,0),n.unshift(u);var h=[Ft(4)];for(h[0].write_shift(4,e.length),l=0;l<e.length;++l){var f=e[l][0];for(c=Ft(8+2*(f.length+1)+(f.length%2?0:2)),c.write_shift(4,l+2),c.write_shift(4,f.length+1),c.write_shift(0,f,"dbcs");c.l!=c.length;)c.write_shift(1,0);h.push(c)}c=Qn(h),i.unshift(c),o+=8+c.length}for(l=0;l<e.length;++l)if(!(r&&!r[e[l][0]])&&!(VR.indexOf(e[l][0])>-1||WR.indexOf(e[l][0])>-1)&&e[l][1]!=null){var y=e[l][1],b=0;if(r){b=+r[e[l][0]];var w=a[b];if(w.p=="version"&&typeof y=="string"){var v=y.split(".");y=(+v[0]<<16)+(+v[1]||0)}c=qE(w.t,y)}else{var k=SY(y);k==-1&&(k=31,y=String(y)),c=qE(k,y)}i.push(c),u=Ft(8),u.write_shift(4,r?b:2+l),n.push(u),o+=8+c.length}var S=8*(i.length+1);for(l=0;l<i.length;++l)n[l].write_shift(4,S),S+=i[l].length;return s.write_shift(4,o),s.write_shift(4,i.length),Qn([s].concat(n).concat(i))}function GE(e,r,a,s,n,i){var o=Ft(n?68:48),l=[o];o.write_shift(2,65534),o.write_shift(2,0),o.write_shift(4,842412599),o.write_shift(16,as.utils.consts.HEADER_CLSID,"hex"),o.write_shift(4,n?2:1),o.write_shift(16,r,"hex"),o.write_shift(4,n?68:48);var c=VE(e,a,s);if(l.push(c),n){var u=VE(n,null,null);o.write_shift(16,i,"hex"),o.write_shift(4,68+c.length),l.push(u)}return Qn(l)}function CY(e,r){r||(r=Ft(e));for(var a=0;a<e;++a)r.write_shift(1,0);return r}function TY(e,r){return e.read_shift(r)===1}function Oi(e,r){return r||(r=Ft(2)),r.write_shift(2,+!!e),r}function GR(e){return e.read_shift(2,"u")}function hl(e,r){return r||(r=Ft(2)),r.write_shift(2,e),r}function KR(e,r,a){return a||(a=Ft(2)),a.write_shift(1,r=="e"?+e:+!!e),a.write_shift(1,r=="e"?1:0),a}function YR(e,r,a){var s=e.read_shift(a&&a.biff>=12?2:1),n="sbcs-cont";if(a&&a.biff>=8,!a||a.biff==8){var i=e.read_shift(1);i&&(n="dbcs-cont")}else a.biff==12&&(n="wstr");a.biff>=2&&a.biff<=5&&(n="cpstr");var o=s?e.read_shift(s,n):"";return o}function EY(e){var r=e.t||"",a=Ft(3);a.write_shift(2,r.length),a.write_shift(1,1);var s=Ft(2*r.length);s.write_shift(2*r.length,r,"utf16le");var n=[a,s];return Qn(n)}function AY(e,r,a){var s;if(a){if(a.biff>=2&&a.biff<=5)return e.read_shift(r,"cpstr");if(a.biff>=12)return e.read_shift(r,"dbcs-cont")}var n=e.read_shift(1);return n===0?s=e.read_shift(r,"sbcs-cont"):s=e.read_shift(r,"dbcs-cont"),s}function OY(e,r,a){var s=e.read_shift(a&&a.biff==2?1:2);return s===0?(e.l++,""):AY(e,s,a)}function PY(e,r,a){if(a.biff>5)return OY(e,r,a);var s=e.read_shift(1);return s===0?(e.l++,""):e.read_shift(s,a.biff<=4||!e.lens?"cpstr":"sbcs-cont")}function JR(e,r,a){return a||(a=Ft(3+2*e.length)),a.write_shift(2,e.length),a.write_shift(1,1),a.write_shift(31,e,"utf16le"),a}function KE(e,r){r||(r=Ft(6+e.length*2)),r.write_shift(4,1+e.length);for(var a=0;a<e.length;++a)r.write_shift(2,e.charCodeAt(a));return r.write_shift(2,0),r}function DY(e){var r=Ft(512),a=0,s=e.Target;s.slice(0,7)=="file://"&&(s=s.slice(7));var n=s.indexOf("#"),i=n>-1?31:23;switch(s.charAt(0)){case"#":i=28;break;case".":i&=-3;break}r.write_shift(4,2),r.write_shift(4,i);var o=[8,6815827,6619237,4849780,83];for(a=0;a<o.length;++a)r.write_shift(4,o[a]);if(i==28)s=s.slice(1),KE(s,r);else if(i&2){for(o="e0 c9 ea 79 f9 ba ce 11 8c 82 00 aa 00 4b a9 0b".split(" "),a=0;a<o.length;++a)r.write_shift(1,parseInt(o[a],16));var l=n>-1?s.slice(0,n):s;for(r.write_shift(4,2*(l.length+1)),a=0;a<l.length;++a)r.write_shift(2,l.charCodeAt(a));r.write_shift(2,0),i&8&&KE(n>-1?s.slice(n+1):"",r)}else{for(o="03 03 00 00 00 00 00 00 c0 00 00 00 00 00 00 46".split(" "),a=0;a<o.length;++a)r.write_shift(1,parseInt(o[a],16));for(var c=0;s.slice(c*3,c*3+3)=="../"||s.slice(c*3,c*3+3)=="..\\";)++c;for(r.write_shift(2,c),r.write_shift(4,s.length-3*c+1),a=0;a<s.length-3*c;++a)r.write_shift(1,s.charCodeAt(a+3*c)&255);for(r.write_shift(1,0),r.write_shift(2,65535),r.write_shift(2,57005),a=0;a<6;++a)r.write_shift(4,0)}return r.slice(0,r.l)}function _m(e,r,a,s){return s||(s=Ft(6)),s.write_shift(2,e),s.write_shift(2,r),s.write_shift(2,a||0),s}function RY(e,r,a){var s=a.biff>8?4:2,n=e.read_shift(s),i=e.read_shift(s,"i"),o=e.read_shift(s,"i");return[n,i,o]}function MY(e){var r=e.read_shift(2),a=e.read_shift(2),s=e.read_shift(2),n=e.read_shift(2);return{s:{c:s,r},e:{c:n,r:a}}}function ZR(e,r){return r||(r=Ft(8)),r.write_shift(2,e.s.r),r.write_shift(2,e.e.r),r.write_shift(2,e.s.c),r.write_shift(2,e.e.c),r}function pS(e,r,a){var s=1536,n=16;switch(a.bookType){case"biff8":break;case"biff5":s=1280,n=8;break;case"biff4":s=4,n=6;break;case"biff3":s=3,n=6;break;case"biff2":s=2,n=4;break;case"xla":break;default:throw new Error("unsupported BIFF version")}var i=Ft(n);return i.write_shift(2,s),i.write_shift(2,r),n>4&&i.write_shift(2,29282),n>6&&i.write_shift(2,1997),n>8&&(i.write_shift(2,49161),i.write_shift(2,1),i.write_shift(2,1798),i.write_shift(2,0)),i}function LY(e,r){var a=!r||r.biff==8,s=Ft(a?112:54);for(s.write_shift(r.biff==8?2:1,7),a&&s.write_shift(1,0),s.write_shift(4,859007059),s.write_shift(4,5458548|(a?0:536870912));s.l<s.length;)s.write_shift(1,a?0:32);return s}function FY(e,r){var a=!r||r.biff>=8?2:1,s=Ft(8+a*e.name.length);s.write_shift(4,e.pos),s.write_shift(1,e.hs||0),s.write_shift(1,e.dt),s.write_shift(1,e.name.length),r.biff>=8&&s.write_shift(1,1),s.write_shift(a*e.name.length,e.name,r.biff<8?"sbcs":"utf16le");var n=s.slice(0,s.l);return n.l=s.l,n}function IY(e,r){var a=Ft(8);a.write_shift(4,e.Count),a.write_shift(4,e.Unique);for(var s=[],n=0;n<e.length;++n)s[n]=EY(e[n]);var i=Qn([a].concat(s));return i.parts=[a.length].concat(s.map(function(o){return o.length})),i}function zY(){var e=Ft(18);return e.write_shift(2,0),e.write_shift(2,0),e.write_shift(2,29280),e.write_shift(2,17600),e.write_shift(2,56),e.write_shift(2,0),e.write_shift(2,0),e.write_shift(2,1),e.write_shift(2,500),e}function $Y(e){var r=Ft(18),a=1718;return e&&e.RTL&&(a|=64),r.write_shift(2,a),r.write_shift(4,0),r.write_shift(4,64),r.write_shift(4,0),r.write_shift(4,0),r}function UY(e,r){var a=e.name||"Arial",s=r&&r.biff==5,n=s?15+a.length:16+2*a.length,i=Ft(n);return i.write_shift(2,e.sz*20),i.write_shift(4,0),i.write_shift(2,400),i.write_shift(4,0),i.write_shift(2,0),i.write_shift(1,a.length),s||i.write_shift(1,1),i.write_shift((s?1:2)*a.length,a,s?"sbcs":"utf16le"),i}function BY(e,r,a,s){var n=Ft(10);return _m(e,r,s,n),n.write_shift(4,a),n}function WY(e,r,a,s,n){var i=!n||n.biff==8,o=Ft(8+ +i+(1+i)*a.length);return _m(e,r,s,o),o.write_shift(2,a.length),i&&o.write_shift(1,1),o.write_shift((1+i)*a.length,a,i?"utf16le":"sbcs"),o}function HY(e,r,a,s){var n=a&&a.biff==5;s||(s=Ft(n?3+r.length:5+2*r.length)),s.write_shift(2,e),s.write_shift(n?1:2,r.length),n||s.write_shift(1,1),s.write_shift((n?1:2)*r.length,r,n?"sbcs":"utf16le");var i=s.length>s.l?s.slice(0,s.l):s;return i.l==null&&(i.l=i.length),i}function qY(e,r){var a=r.biff==8||!r.biff?4:2,s=Ft(2*a+6);return s.write_shift(a,e.s.r),s.write_shift(a,e.e.r+1),s.write_shift(2,e.s.c),s.write_shift(2,e.e.c+1),s.write_shift(2,0),s}function YE(e,r,a,s){var n=a&&a.biff==5;s||(s=Ft(n?16:20)),s.write_shift(2,0),e.style?(s.write_shift(2,e.numFmtId||0),s.write_shift(2,65524)):(s.write_shift(2,e.numFmtId||0),s.write_shift(2,r<<4));var i=0;return e.numFmtId>0&&n&&(i|=1024),s.write_shift(4,i),s.write_shift(4,0),n||s.write_shift(4,0),s.write_shift(2,0),s}function VY(e){var r=Ft(8);return r.write_shift(4,0),r.write_shift(2,0),r.write_shift(2,0),r}function GY(e,r,a,s,n,i){var o=Ft(8);return _m(e,r,s,o),KR(a,i,o),o}function KY(e,r,a,s){var n=Ft(14);return _m(e,r,s,n),jm(a,n),n}function YY(e,r,a){if(a.biff<8)return JY(e,r,a);for(var s=[],n=e.l+r,i=e.read_shift(a.biff>8?4:2);i--!==0;)s.push(RY(e,a.biff>8?12:6,a));if(e.l!=n)throw new Error("Bad ExternSheet: "+e.l+" != "+n);return s}function JY(e,r,a){e[e.l+1]==3&&e[e.l]++;var s=YR(e,r,a);return s.charCodeAt(0)==3?s.slice(1):s}function ZY(e){var r=Ft(2+e.length*8);r.write_shift(2,e.length);for(var a=0;a<e.length;++a)ZR(e[a],r);return r}function XY(e){var r=Ft(24),a=Rn(e[0]);r.write_shift(2,a.r),r.write_shift(2,a.r),r.write_shift(2,a.c),r.write_shift(2,a.c);for(var s="d0 c9 ea 79 f9 ba ce 11 8c 82 00 aa 00 4b a9 0b".split(" "),n=0;n<16;++n)r.write_shift(1,parseInt(s[n],16));return Qn([r,DY(e[1])])}function QY(e){var r=e[1].Tooltip,a=Ft(10+2*(r.length+1));a.write_shift(2,2048);var s=Rn(e[0]);a.write_shift(2,s.r),a.write_shift(2,s.r),a.write_shift(2,s.c),a.write_shift(2,s.c);for(var n=0;n<r.length;++n)a.write_shift(2,r.charCodeAt(n));return a.write_shift(2,0),a}function eJ(e){return e||(e=Ft(4)),e.write_shift(2,1),e.write_shift(2,1),e}function tJ(e,r,a){if(!a.cellStyles)return zc(e,r);var s=a&&a.biff>=12?4:2,n=e.read_shift(s),i=e.read_shift(s),o=e.read_shift(s),l=e.read_shift(s),c=e.read_shift(2);s==2&&(e.l+=2);var u={s:n,e:i,w:o,ixfe:l,flags:c};return(a.biff>=5||!a.biff)&&(u.level=c>>8&7),u}function rJ(e,r){var a=Ft(12);a.write_shift(2,r),a.write_shift(2,r),a.write_shift(2,e.width*256),a.write_shift(2,0);var s=0;return e.hidden&&(s|=1),a.write_shift(1,s),s=e.level||0,a.write_shift(1,s),a.write_shift(2,0),a}function aJ(e){for(var r=Ft(2*e),a=0;a<e;++a)r.write_shift(2,a+1);return r}function sJ(e,r,a){var s=Ft(15);return Ex(s,e,r),s.write_shift(8,a,"f"),s}function nJ(e,r,a){var s=Ft(9);return Ex(s,e,r),s.write_shift(2,a),s}var iJ=(function(){var e={1:437,2:850,3:1252,4:1e4,100:852,101:866,102:865,103:861,104:895,105:620,106:737,107:857,120:950,121:949,122:936,123:932,124:874,125:1255,126:1256,150:10007,151:10029,152:10006,200:1250,201:1251,202:1254,203:1253,0:20127,8:865,9:437,10:850,11:437,13:437,14:850,15:437,16:850,17:437,18:850,19:932,20:850,21:437,22:850,23:865,24:437,25:437,26:850,27:437,28:863,29:850,31:852,34:852,35:852,36:860,37:850,38:866,55:850,64:852,77:936,78:949,79:950,80:874,87:1252,88:1252,89:1252,108:863,134:737,135:852,136:857,204:1257,255:16969},r=aS({1:437,2:850,3:1252,4:1e4,100:852,101:866,102:865,103:861,104:895,105:620,106:737,107:857,120:950,121:949,122:936,123:932,124:874,125:1255,126:1256,150:10007,151:10029,152:10006,200:1250,201:1251,202:1254,203:1253,0:20127});function a(l,c){var u=[],h=wm(1);switch(c.type){case"base64":h=Vl(Kd(l));break;case"binary":h=Vl(l);break;case"buffer":case"array":h=l;break}Ro(h,0);var f=h.read_shift(1),y=!!(f&136),b=!1,w=!1;switch(f){case 2:break;case 3:break;case 48:b=!0,y=!0;break;case 49:b=!0,y=!0;break;case 131:break;case 139:break;case 140:w=!0;break;case 245:break;default:throw new Error("DBF Unsupported Version: "+f.toString(16))}var v=0,k=521;f==2&&(v=h.read_shift(2)),h.l+=3,f!=2&&(v=h.read_shift(4)),v>1048576&&(v=1e6),f!=2&&(k=h.read_shift(2));var S=h.read_shift(2),N=c.codepage||1252;f!=2&&(h.l+=16,h.read_shift(1),h[h.l]!==0&&(N=e[h[h.l]]),h.l+=1,h.l+=2),w&&(h.l+=36);for(var C=[],O={},T=Math.min(h.length,f==2?521:k-10-(b?264:0)),P=w?32:11;h.l<T&&h[h.l]!=13;)switch(O={},O.name=Pv.utils.decode(N,h.slice(h.l,h.l+P)).replace(/[\u0000\r\n].*$/g,""),h.l+=P,O.type=String.fromCharCode(h.read_shift(1)),f!=2&&!w&&(O.offset=h.read_shift(4)),O.len=h.read_shift(1),f==2&&(O.offset=h.read_shift(2)),O.dec=h.read_shift(1),O.name.length&&C.push(O),f!=2&&(h.l+=w?13:14),O.type){case"B":(!b||O.len!=8)&&c.WTF&&console.log("Skipping "+O.name+":"+O.type);break;case"G":case"P":c.WTF&&console.log("Skipping "+O.name+":"+O.type);break;case"+":case"0":case"@":case"C":case"D":case"F":case"I":case"L":case"M":case"N":case"O":case"T":case"Y":break;default:throw new Error("Unknown Field Type: "+O.type)}if(h[h.l]!==13&&(h.l=k-1),h.read_shift(1)!==13)throw new Error("DBF Terminator not found "+h.l+" "+h[h.l]);h.l=k;var E=0,R=0;for(u[0]=[],R=0;R!=C.length;++R)u[0][R]=C[R].name;for(;v-- >0;){if(h[h.l]===42){h.l+=S;continue}for(++h.l,u[++E]=[],R=0,R=0;R!=C.length;++R){var z=h.slice(h.l,h.l+C[R].len);h.l+=C[R].len,Ro(z,0);var G=Pv.utils.decode(N,z);switch(C[R].type){case"C":G.trim().length&&(u[E][R]=G.replace(/\s+$/,""));break;case"D":G.length===8?u[E][R]=new Date(+G.slice(0,4),+G.slice(4,6)-1,+G.slice(6,8)):u[E][R]=G;break;case"F":u[E][R]=parseFloat(G.trim());break;case"+":case"I":u[E][R]=w?z.read_shift(-4,"i")^2147483648:z.read_shift(4,"i");break;case"L":switch(G.trim().toUpperCase()){case"Y":case"T":u[E][R]=!0;break;case"N":case"F":u[E][R]=!1;break;case"":case"?":break;default:throw new Error("DBF Unrecognized L:|"+G+"|")}break;case"M":if(!y)throw new Error("DBF Unexpected MEMO for type "+f.toString(16));u[E][R]="##MEMO##"+(w?parseInt(G.trim(),10):z.read_shift(4));break;case"N":G=G.replace(/\u0000/g,"").trim(),G&&G!="."&&(u[E][R]=+G||0);break;case"@":u[E][R]=new Date(z.read_shift(-8,"f")-621356832e5);break;case"T":u[E][R]=new Date((z.read_shift(4)-2440588)*864e5+z.read_shift(4));break;case"Y":u[E][R]=z.read_shift(4,"i")/1e4+z.read_shift(4,"i")/1e4*Math.pow(2,32);break;case"O":u[E][R]=-z.read_shift(-8,"f");break;case"B":if(b&&C[R].len==8){u[E][R]=z.read_shift(8,"f");break}case"G":case"P":z.l+=C[R].len;break;case"0":if(C[R].name==="_NullFlags")break;default:throw new Error("DBF Unsupported data type "+C[R].type)}}}if(f!=2&&h.l<h.length&&h[h.l++]!=26)throw new Error("DBF EOF Marker missing "+(h.l-1)+" of "+h.length+" "+h[h.l-1].toString(16));return c&&c.sheetRows&&(u=u.slice(0,c.sheetRows)),c.DBF=C,u}function s(l,c){var u=c||{};u.dateNF||(u.dateNF="yyyymmdd");var h=Wp(a(l,u),u);return h["!cols"]=u.DBF.map(function(f){return{wch:f.len,DBF:f}}),delete u.DBF,h}function n(l,c){try{return Fm(s(l,c),c)}catch(u){if(c&&c.WTF)throw u}return{SheetNames:[],Sheets:{}}}var i={B:8,C:250,L:1,D:8,"?":0,"":0};function o(l,c){var u=c||{};if(+u.codepage>=0&&Kf(+u.codepage),u.type=="string")throw new Error("Cannot write DBF to JS string");var h=io(),f=qv(l,{header:1,raw:!0,cellDates:!0}),y=f[0],b=f.slice(1),w=l["!cols"]||[],v=0,k=0,S=0,N=1;for(v=0;v<y.length;++v){if(((w[v]||{}).DBF||{}).name){y[v]=w[v].DBF.name,++S;continue}if(y[v]!=null){if(++S,typeof y[v]=="number"&&(y[v]=y[v].toString(10)),typeof y[v]!="string")throw new Error("DBF Invalid column name "+y[v]+" |"+typeof y[v]+"|");if(y.indexOf(y[v])!==v){for(k=0;k<1024;++k)if(y.indexOf(y[v]+"_"+k)==-1){y[v]+="_"+k;break}}}}var C=vs(l["!ref"]),O=[],T=[],P=[];for(v=0;v<=C.e.c-C.s.c;++v){var E="",R="",z=0,G=[];for(k=0;k<b.length;++k)b[k][v]!=null&&G.push(b[k][v]);if(G.length==0||y[v]==null){O[v]="?";continue}for(k=0;k<G.length;++k){switch(typeof G[k]){case"number":R="B";break;case"string":R="C";break;case"boolean":R="L";break;case"object":R=G[k]instanceof Date?"D":"C";break;default:R="C"}z=Math.max(z,String(G[k]).length),E=E&&E!=R?"C":R}z>250&&(z=250),R=((w[v]||{}).DBF||{}).type,R=="C"&&w[v].DBF.len>z&&(z=w[v].DBF.len),E=="B"&&R=="N"&&(E="N",P[v]=w[v].DBF.dec,z=w[v].DBF.len),T[v]=E=="C"||R=="N"?z:i[E]||0,N+=T[v],O[v]=E}var ae=h.next(32);for(ae.write_shift(4,318902576),ae.write_shift(4,b.length),ae.write_shift(2,296+32*S),ae.write_shift(2,N),v=0;v<4;++v)ae.write_shift(4,0);for(ae.write_shift(4,0|(+r[Q9]||3)<<8),v=0,k=0;v<y.length;++v)if(y[v]!=null){var ee=h.next(32),ne=(y[v].slice(-10)+"\0\0\0\0\0\0\0\0\0\0\0").slice(0,11);ee.write_shift(1,ne,"sbcs"),ee.write_shift(1,O[v]=="?"?"C":O[v],"sbcs"),ee.write_shift(4,k),ee.write_shift(1,T[v]||i[O[v]]||0),ee.write_shift(1,P[v]||0),ee.write_shift(1,2),ee.write_shift(4,0),ee.write_shift(1,0),ee.write_shift(4,0),ee.write_shift(4,0),k+=T[v]||i[O[v]]||0}var te=h.next(264);for(te.write_shift(4,13),v=0;v<65;++v)te.write_shift(4,0);for(v=0;v<b.length;++v){var Y=h.next(N);for(Y.write_shift(1,0),k=0;k<y.length;++k)if(y[k]!=null)switch(O[k]){case"L":Y.write_shift(1,b[v][k]==null?63:b[v][k]?84:70);break;case"B":Y.write_shift(8,b[v][k]||0,"f");break;case"N":var q="0";for(typeof b[v][k]=="number"&&(q=b[v][k].toFixed(P[k]||0)),S=0;S<T[k]-q.length;++S)Y.write_shift(1,32);Y.write_shift(1,q,"sbcs");break;case"D":b[v][k]?(Y.write_shift(4,("0000"+b[v][k].getFullYear()).slice(-4),"sbcs"),Y.write_shift(2,("00"+(b[v][k].getMonth()+1)).slice(-2),"sbcs"),Y.write_shift(2,("00"+b[v][k].getDate()).slice(-2),"sbcs")):Y.write_shift(8,"00000000","sbcs");break;case"C":var H=String(b[v][k]!=null?b[v][k]:"").slice(0,T[k]);for(Y.write_shift(1,H,"sbcs"),S=0;S<T[k]-H.length;++S)Y.write_shift(1,32);break}}return h.next(1).write_shift(1,26),h.end()}return{to_workbook:n,to_sheet:s,from_sheet:o}})(),oJ=(function(){var e={AA:"À",BA:"Á",CA:"Â",DA:195,HA:"Ä",JA:197,AE:"È",BE:"É",CE:"Ê",HE:"Ë",AI:"Ì",BI:"Í",CI:"Î",HI:"Ï",AO:"Ò",BO:"Ó",CO:"Ô",DO:213,HO:"Ö",AU:"Ù",BU:"Ú",CU:"Û",HU:"Ü",Aa:"à",Ba:"á",Ca:"â",Da:227,Ha:"ä",Ja:229,Ae:"è",Be:"é",Ce:"ê",He:"ë",Ai:"ì",Bi:"í",Ci:"î",Hi:"ï",Ao:"ò",Bo:"ó",Co:"ô",Do:245,Ho:"ö",Au:"ù",Bu:"ú",Cu:"û",Hu:"ü",KC:"Ç",Kc:"ç",q:"æ",z:"œ",a:"Æ",j:"Œ",DN:209,Dn:241,Hy:255,S:169,c:170,R:174,"B ":180,0:176,1:177,2:178,3:179,5:181,6:182,7:183,Q:185,k:186,b:208,i:216,l:222,s:240,y:248,"!":161,'"':162,"#":163,"(":164,"%":165,"'":167,"H ":168,"+":171,";":187,"<":188,"=":189,">":190,"?":191,"{":223},r=new RegExp("\x1BN("+si(e).join("|").replace(/\|\|\|/,"|\\||").replace(/([?()+])/g,"\\$1")+"|\\|)","gm"),a=function(y,b){var w=e[b];return typeof w=="number"?bE(w):w},s=function(y,b,w){var v=b.charCodeAt(0)-32<<4|w.charCodeAt(0)-48;return v==59?y:bE(v)};e["|"]=254;function n(y,b){switch(b.type){case"base64":return i(Kd(y),b);case"binary":return i(y,b);case"buffer":return i(Ia&&Buffer.isBuffer(y)?y.toString("binary"):kx(y),b);case"array":return i(X1(y),b)}throw new Error("Unrecognized type "+b.type)}function i(y,b){var w=y.split(/[\n\r]+/),v=-1,k=-1,S=0,N=0,C=[],O=[],T=null,P={},E=[],R=[],z=[],G=0,ae;for(+b.codepage>=0&&Kf(+b.codepage);S!==w.length;++S){G=0;var ee=w[S].trim().replace(/\x1B([\x20-\x2F])([\x30-\x3F])/g,s).replace(r,a),ne=ee.replace(/;;/g,"\0").split(";").map(function(ie){return ie.replace(/\u0000/g,";")}),te=ne[0],Y;if(ee.length>0)switch(te){case"ID":break;case"E":break;case"B":break;case"O":break;case"W":break;case"P":ne[1].charAt(0)=="P"&&O.push(ee.slice(3).replace(/;;/g,";"));break;case"C":var q=!1,H=!1,U=!1,re=!1,X=-1,V=-1;for(N=1;N<ne.length;++N)switch(ne[N].charAt(0)){case"A":break;case"X":k=parseInt(ne[N].slice(1))-1,H=!0;break;case"Y":for(v=parseInt(ne[N].slice(1))-1,H||(k=0),ae=C.length;ae<=v;++ae)C[ae]=[];break;case"K":Y=ne[N].slice(1),Y.charAt(0)==='"'?Y=Y.slice(1,Y.length-1):Y==="TRUE"?Y=!0:Y==="FALSE"?Y=!1:isNaN(Bd(Y))?isNaN(Jf(Y).getDate())||(Y=Mi(Y)):(Y=Bd(Y),T!==null&&uR(T)&&(Y=gR(Y))),q=!0;break;case"E":re=!0;var I=nZ(ne[N].slice(1),{r:v,c:k});C[v][k]=[C[v][k],I];break;case"S":U=!0,C[v][k]=[C[v][k],"S5S"];break;case"G":break;case"R":X=parseInt(ne[N].slice(1))-1;break;case"C":V=parseInt(ne[N].slice(1))-1;break;default:if(b&&b.WTF)throw new Error("SYLK bad record "+ee)}if(q&&(C[v][k]&&C[v][k].length==2?C[v][k][0]=Y:C[v][k]=Y,T=null),U){if(re)throw new Error("SYLK shared formula cannot have own formula");var B=X>-1&&C[X][V];if(!B||!B[1])throw new Error("SYLK shared formula cannot find base");C[v][k][1]=iZ(B[1],{r:v-X,c:k-V})}break;case"F":var Q=0;for(N=1;N<ne.length;++N)switch(ne[N].charAt(0)){case"X":k=parseInt(ne[N].slice(1))-1,++Q;break;case"Y":for(v=parseInt(ne[N].slice(1))-1,ae=C.length;ae<=v;++ae)C[ae]=[];break;case"M":G=parseInt(ne[N].slice(1))/20;break;case"F":break;case"G":break;case"P":T=O[parseInt(ne[N].slice(1))];break;case"S":break;case"D":break;case"N":break;case"W":for(z=ne[N].slice(1).split(" "),ae=parseInt(z[0],10);ae<=parseInt(z[1],10);++ae)G=parseInt(z[2],10),R[ae-1]=G===0?{hidden:!0}:{wch:G},gS(R[ae-1]);break;case"C":k=parseInt(ne[N].slice(1))-1,R[k]||(R[k]={});break;case"R":v=parseInt(ne[N].slice(1))-1,E[v]||(E[v]={}),G>0?(E[v].hpt=G,E[v].hpx=rM(G)):G===0&&(E[v].hidden=!0);break;default:if(b&&b.WTF)throw new Error("SYLK bad record "+ee)}Q<1&&(T=null);break;default:if(b&&b.WTF)throw new Error("SYLK bad record "+ee)}}return E.length>0&&(P["!rows"]=E),R.length>0&&(P["!cols"]=R),b&&b.sheetRows&&(C=C.slice(0,b.sheetRows)),[C,P]}function o(y,b){var w=n(y,b),v=w[0],k=w[1],S=Wp(v,b);return si(k).forEach(function(N){S[N]=k[N]}),S}function l(y,b){return Fm(o(y,b),b)}function c(y,b,w,v){var k="C;Y"+(w+1)+";X"+(v+1)+";K";switch(y.t){case"n":k+=y.v||0,y.f&&!y.F&&(k+=";E"+xS(y.f,{r:w,c:v}));break;case"b":k+=y.v?"TRUE":"FALSE";break;case"e":k+=y.w||y.v;break;case"d":k+='"'+(y.w||y.v)+'"';break;case"s":k+='"'+y.v.replace(/"/g,"").replace(/;/g,";;")+'"';break}return k}function u(y,b){b.forEach(function(w,v){var k="F;W"+(v+1)+" "+(v+1)+" ";w.hidden?k+="0":(typeof w.width=="number"&&!w.wpx&&(w.wpx=Uv(w.width)),typeof w.wpx=="number"&&!w.wch&&(w.wch=Bv(w.wpx)),typeof w.wch=="number"&&(k+=Math.round(w.wch))),k.charAt(k.length-1)!=" "&&y.push(k)})}function h(y,b){b.forEach(function(w,v){var k="F;";w.hidden?k+="M0;":w.hpt?k+="M"+20*w.hpt+";":w.hpx&&(k+="M"+20*Wv(w.hpx)+";"),k.length>2&&y.push(k+"R"+(v+1))})}function f(y,b){var w=["ID;PWXL;N;E"],v=[],k=vs(y["!ref"]),S,N=Array.isArray(y),C=`\r
|
||
`;w.push("P;PGeneral"),w.push("F;P0;DG0G8;M255"),y["!cols"]&&u(w,y["!cols"]),y["!rows"]&&h(w,y["!rows"]),w.push("B;Y"+(k.e.r-k.s.r+1)+";X"+(k.e.c-k.s.c+1)+";D"+[k.s.c,k.s.r,k.e.c,k.e.r].join(" "));for(var O=k.s.r;O<=k.e.r;++O)for(var T=k.s.c;T<=k.e.c;++T){var P=Ya({r:O,c:T});S=N?(y[O]||[])[T]:y[P],!(!S||S.v==null&&(!S.f||S.F))&&v.push(c(S,y,O,T))}return w.join(C)+C+v.join(C)+C+"E"+C}return{to_workbook:l,to_sheet:o,from_sheet:f}})(),lJ=(function(){function e(i,o){switch(o.type){case"base64":return r(Kd(i),o);case"binary":return r(i,o);case"buffer":return r(Ia&&Buffer.isBuffer(i)?i.toString("binary"):kx(i),o);case"array":return r(X1(i),o)}throw new Error("Unrecognized type "+o.type)}function r(i,o){for(var l=i.split(`
|
||
`),c=-1,u=-1,h=0,f=[];h!==l.length;++h){if(l[h].trim()==="BOT"){f[++c]=[],u=0;continue}if(!(c<0)){var y=l[h].trim().split(","),b=y[0],w=y[1];++h;for(var v=l[h]||"";(v.match(/["]/g)||[]).length&1&&h<l.length-1;)v+=`
|
||
`+l[++h];switch(v=v.trim(),+b){case-1:if(v==="BOT"){f[++c]=[],u=0;continue}else if(v!=="EOD")throw new Error("Unrecognized DIF special command "+v);break;case 0:v==="TRUE"?f[c][u]=!0:v==="FALSE"?f[c][u]=!1:isNaN(Bd(w))?isNaN(Jf(w).getDate())?f[c][u]=w:f[c][u]=Mi(w):f[c][u]=Bd(w),++u;break;case 1:v=v.slice(1,v.length-1),v=v.replace(/""/g,'"'),v&&v.match(/^=".*"$/)&&(v=v.slice(2,-1)),f[c][u++]=v!==""?v:null;break}if(v==="EOD")break}}return o&&o.sheetRows&&(f=f.slice(0,o.sheetRows)),f}function a(i,o){return Wp(e(i,o),o)}function s(i,o){return Fm(a(i,o),o)}var n=(function(){var i=function(c,u,h,f,y){c.push(u),c.push(h+","+f),c.push('"'+y.replace(/"/g,'""')+'"')},o=function(c,u,h,f){c.push(u+","+h),c.push(u==1?'"'+f.replace(/"/g,'""')+'"':f)};return function(c){var u=[],h=vs(c["!ref"]),f,y=Array.isArray(c);i(u,"TABLE",0,1,"sheetjs"),i(u,"VECTORS",0,h.e.r-h.s.r+1,""),i(u,"TUPLES",0,h.e.c-h.s.c+1,""),i(u,"DATA",0,0,"");for(var b=h.s.r;b<=h.e.r;++b){o(u,-1,0,"BOT");for(var w=h.s.c;w<=h.e.c;++w){var v=Ya({r:b,c:w});if(f=y?(c[b]||[])[w]:c[v],!f){o(u,1,0,"");continue}switch(f.t){case"n":var k=f.w;!k&&f.v!=null&&(k=f.v),k==null?f.f&&!f.F?o(u,1,0,"="+f.f):o(u,1,0,""):o(u,0,k,"V");break;case"b":o(u,0,f.v?1:0,f.v?"TRUE":"FALSE");break;case"s":o(u,1,0,isNaN(f.v)?f.v:'="'+f.v+'"');break;case"d":f.w||(f.w=Xu(f.z||Hs[14],co(Mi(f.v)))),o(u,0,f.w,"V");break;default:o(u,1,0,"")}}}o(u,-1,0,"EOD");var S=`\r
|
||
`,N=u.join(S);return N}})();return{to_workbook:s,to_sheet:a,from_sheet:n}})(),XR=(function(){function e(f){return f.replace(/\\b/g,"\\").replace(/\\c/g,":").replace(/\\n/g,`
|
||
`)}function r(f){return f.replace(/\\/g,"\\b").replace(/:/g,"\\c").replace(/\n/g,"\\n")}function a(f,y){for(var b=f.split(`
|
||
`),w=-1,v=-1,k=0,S=[];k!==b.length;++k){var N=b[k].trim().split(":");if(N[0]==="cell"){var C=Rn(N[1]);if(S.length<=C.r)for(w=S.length;w<=C.r;++w)S[w]||(S[w]=[]);switch(w=C.r,v=C.c,N[2]){case"t":S[w][v]=e(N[3]);break;case"v":S[w][v]=+N[3];break;case"vtf":var O=N[N.length-1];case"vtc":switch(N[3]){case"nl":S[w][v]=!!+N[4];break;default:S[w][v]=+N[4];break}N[2]=="vtf"&&(S[w][v]=[S[w][v],O])}}}return y&&y.sheetRows&&(S=S.slice(0,y.sheetRows)),S}function s(f,y){return Wp(a(f,y),y)}function n(f,y){return Fm(s(f,y),y)}var i=["socialcalc:version:1.5","MIME-Version: 1.0","Content-Type: multipart/mixed; boundary=SocialCalcSpreadsheetControlSave"].join(`
|
||
`),o=["--SocialCalcSpreadsheetControlSave","Content-type: text/plain; charset=UTF-8"].join(`
|
||
`)+`
|
||
`,l=["# SocialCalc Spreadsheet Control Save","part:sheet"].join(`
|
||
`),c="--SocialCalcSpreadsheetControlSave--";function u(f){if(!f||!f["!ref"])return"";for(var y=[],b=[],w,v="",k=Wo(f["!ref"]),S=Array.isArray(f),N=k.s.r;N<=k.e.r;++N)for(var C=k.s.c;C<=k.e.c;++C)if(v=Ya({r:N,c:C}),w=S?(f[N]||[])[C]:f[v],!(!w||w.v==null||w.t==="z")){switch(b=["cell",v,"t"],w.t){case"s":case"str":b.push(r(w.v));break;case"n":w.f?(b[2]="vtf",b[3]="n",b[4]=w.v,b[5]=r(w.f)):(b[2]="v",b[3]=w.v);break;case"b":b[2]="vt"+(w.f?"f":"c"),b[3]="nl",b[4]=w.v?"1":"0",b[5]=r(w.f||(w.v?"TRUE":"FALSE"));break;case"d":var O=co(Mi(w.v));b[2]="vtc",b[3]="nd",b[4]=""+O,b[5]=w.w||Xu(w.z||Hs[14],O);break;case"e":continue}y.push(b.join(":"))}return y.push("sheet:c:"+(k.e.c-k.s.c+1)+":r:"+(k.e.r-k.s.r+1)+":tvf:1"),y.push("valueformat:1:text-wiki"),y.join(`
|
||
`)}function h(f){return[i,o,l,o,u(f),c].join(`
|
||
`)}return{to_workbook:n,to_sheet:s,from_sheet:h}})(),cJ=(function(){function e(h,f,y,b,w){w.raw?f[y][b]=h:h===""||(h==="TRUE"?f[y][b]=!0:h==="FALSE"?f[y][b]=!1:isNaN(Bd(h))?isNaN(Jf(h).getDate())?f[y][b]=h:f[y][b]=Mi(h):f[y][b]=Bd(h))}function r(h,f){var y=f||{},b=[];if(!h||h.length===0)return b;for(var w=h.split(/[\r\n]/),v=w.length-1;v>=0&&w[v].length===0;)--v;for(var k=10,S=0,N=0;N<=v;++N)S=w[N].indexOf(" "),S==-1?S=w[N].length:S++,k=Math.max(k,S);for(N=0;N<=v;++N){b[N]=[];var C=0;for(e(w[N].slice(0,k).trim(),b,N,C,y),C=1;C<=(w[N].length-k)/10+1;++C)e(w[N].slice(k+(C-1)*10,k+C*10).trim(),b,N,C,y)}return y.sheetRows&&(b=b.slice(0,y.sheetRows)),b}var a={44:",",9:" ",59:";",124:"|"},s={44:3,9:2,59:1,124:0};function n(h){for(var f={},y=!1,b=0,w=0;b<h.length;++b)(w=h.charCodeAt(b))==34?y=!y:!y&&w in a&&(f[w]=(f[w]||0)+1);w=[];for(b in f)Object.prototype.hasOwnProperty.call(f,b)&&w.push([f[b],b]);if(!w.length){f=s;for(b in f)Object.prototype.hasOwnProperty.call(f,b)&&w.push([f[b],b])}return w.sort(function(v,k){return v[0]-k[0]||s[v[1]]-s[k[1]]}),a[w.pop()[1]]||44}function i(h,f){var y=f||{},b="",w=y.dense?[]:{},v={s:{c:0,r:0},e:{c:0,r:0}};h.slice(0,4)=="sep="?h.charCodeAt(5)==13&&h.charCodeAt(6)==10?(b=h.charAt(4),h=h.slice(7)):h.charCodeAt(5)==13||h.charCodeAt(5)==10?(b=h.charAt(4),h=h.slice(6)):b=n(h.slice(0,1024)):y&&y.FS?b=y.FS:b=n(h.slice(0,1024));var k=0,S=0,N=0,C=0,O=0,T=b.charCodeAt(0),P=!1,E=0,R=h.charCodeAt(0);h=h.replace(/\r\n/mg,`
|
||
`);var z=y.dateNF!=null?NK(y.dateNF):null;function G(){var ae=h.slice(C,O),ee={};if(ae.charAt(0)=='"'&&ae.charAt(ae.length-1)=='"'&&(ae=ae.slice(1,-1).replace(/""/g,'"')),ae.length===0)ee.t="z";else if(y.raw)ee.t="s",ee.v=ae;else if(ae.trim().length===0)ee.t="s",ee.v=ae;else if(ae.charCodeAt(0)==61)ae.charCodeAt(1)==34&&ae.charCodeAt(ae.length-1)==34?(ee.t="s",ee.v=ae.slice(2,-1).replace(/""/g,'"')):oZ(ae)?(ee.t="n",ee.f=ae.slice(1)):(ee.t="s",ee.v=ae);else if(ae=="TRUE")ee.t="b",ee.v=!0;else if(ae=="FALSE")ee.t="b",ee.v=!1;else if(!isNaN(N=Bd(ae)))ee.t="n",y.cellText!==!1&&(ee.w=ae),ee.v=N;else if(!isNaN(Jf(ae).getDate())||z&&ae.match(z)){ee.z=y.dateNF||Hs[14];var ne=0;z&&ae.match(z)&&(ae=SK(ae,y.dateNF,ae.match(z)||[]),ne=1),y.cellDates?(ee.t="d",ee.v=Mi(ae,ne)):(ee.t="n",ee.v=co(Mi(ae,ne))),y.cellText!==!1&&(ee.w=Xu(ee.z,ee.v instanceof Date?co(ee.v):ee.v)),y.cellNF||delete ee.z}else ee.t="s",ee.v=ae;if(ee.t=="z"||(y.dense?(w[k]||(w[k]=[]),w[k][S]=ee):w[Ya({c:S,r:k})]=ee),C=O+1,R=h.charCodeAt(C),v.e.c<S&&(v.e.c=S),v.e.r<k&&(v.e.r=k),E==T)++S;else if(S=0,++k,y.sheetRows&&y.sheetRows<=k)return!0}e:for(;O<h.length;++O)switch(E=h.charCodeAt(O)){case 34:R===34&&(P=!P);break;case T:case 10:case 13:if(!P&&G())break e;break}return O-C>0&&G(),w["!ref"]=ln(v),w}function o(h,f){return!(f&&f.PRN)||f.FS||h.slice(0,4)=="sep="||h.indexOf(" ")>=0||h.indexOf(",")>=0||h.indexOf(";")>=0?i(h,f):Wp(r(h,f),f)}function l(h,f){var y="",b=f.type=="string"?[0,0,0,0]:wte(h,f);switch(f.type){case"base64":y=Kd(h);break;case"binary":y=h;break;case"buffer":f.codepage==65001?y=h.toString("utf8"):f.codepage&&typeof Pv!="undefined"||(y=Ia&&Buffer.isBuffer(h)?h.toString("binary"):kx(h));break;case"array":y=X1(h);break;case"string":y=h;break;default:throw new Error("Unrecognized type "+f.type)}return b[0]==239&&b[1]==187&&b[2]==191?y=Lf(y.slice(3)):f.type!="string"&&f.type!="buffer"&&f.codepage==65001?y=Lf(y):f.type=="binary",y.slice(0,19)=="socialcalc:version:"?XR.to_sheet(f.type=="string"?y:Lf(y),f):o(y,f)}function c(h,f){return Fm(l(h,f),f)}function u(h){for(var f=[],y=vs(h["!ref"]),b,w=Array.isArray(h),v=y.s.r;v<=y.e.r;++v){for(var k=[],S=y.s.c;S<=y.e.c;++S){var N=Ya({r:v,c:S});if(b=w?(h[v]||[])[S]:h[N],!b||b.v==null){k.push(" ");continue}for(var C=(b.w||(Yd(b),b.w)||"").slice(0,10);C.length<10;)C+=" ";k.push(C+(S===0?" ":""))}f.push(k.join(""))}return f.join(`
|
||
`)}return{to_workbook:c,to_sheet:l,from_sheet:u}})(),JE=(function(){function e(I,B,Q){if(I){Ro(I,I.l||0);for(var ie=Q.Enum||X;I.l<I.length;){var me=I.read_shift(2),he=ie[me]||ie[65535],de=I.read_shift(2),xe=I.l+de,ge=he.f&&he.f(I,de,Q);if(I.l=xe,B(ge,he,me))return}}}function r(I,B){switch(B.type){case"base64":return a(Vl(Kd(I)),B);case"binary":return a(Vl(I),B);case"buffer":case"array":return a(I,B)}throw"Unsupported type "+B.type}function a(I,B){if(!I)return I;var Q=B||{},ie=Q.dense?[]:{},me="Sheet1",he="",de=0,xe={},ge=[],be=[],K={s:{r:0,c:0},e:{r:0,c:0}},ye=Q.sheetRows||0;if(I[2]==0&&(I[3]==8||I[3]==9)&&I.length>=16&&I[14]==5&&I[15]===108)throw new Error("Unsupported Works 3 for Mac file");if(I[2]==2)Q.Enum=X,e(I,function(pe,le,Fe){switch(Fe){case 0:Q.vers=pe,pe>=4096&&(Q.qpro=!0);break;case 6:K=pe;break;case 204:pe&&(he=pe);break;case 222:he=pe;break;case 15:case 51:Q.qpro||(pe[1].v=pe[1].v.slice(1));case 13:case 14:case 16:Fe==14&&(pe[2]&112)==112&&(pe[2]&15)>1&&(pe[2]&15)<15&&(pe[1].z=Q.dateNF||Hs[14],Q.cellDates&&(pe[1].t="d",pe[1].v=gR(pe[1].v))),Q.qpro&&pe[3]>de&&(ie["!ref"]=ln(K),xe[me]=ie,ge.push(me),ie=Q.dense?[]:{},K={s:{r:0,c:0},e:{r:0,c:0}},de=pe[3],me=he||"Sheet"+(de+1),he="");var ze=Q.dense?(ie[pe[0].r]||[])[pe[0].c]:ie[Ya(pe[0])];if(ze){ze.t=pe[1].t,ze.v=pe[1].v,pe[1].z!=null&&(ze.z=pe[1].z),pe[1].f!=null&&(ze.f=pe[1].f);break}Q.dense?(ie[pe[0].r]||(ie[pe[0].r]=[]),ie[pe[0].r][pe[0].c]=pe[1]):ie[Ya(pe[0])]=pe[1];break}},Q);else if(I[2]==26||I[2]==14)Q.Enum=V,I[2]==14&&(Q.qpro=!0,I.l=0),e(I,function(pe,le,Fe){switch(Fe){case 204:me=pe;break;case 22:pe[1].v=pe[1].v.slice(1);case 23:case 24:case 25:case 37:case 39:case 40:if(pe[3]>de&&(ie["!ref"]=ln(K),xe[me]=ie,ge.push(me),ie=Q.dense?[]:{},K={s:{r:0,c:0},e:{r:0,c:0}},de=pe[3],me="Sheet"+(de+1)),ye>0&&pe[0].r>=ye)break;Q.dense?(ie[pe[0].r]||(ie[pe[0].r]=[]),ie[pe[0].r][pe[0].c]=pe[1]):ie[Ya(pe[0])]=pe[1],K.e.c<pe[0].c&&(K.e.c=pe[0].c),K.e.r<pe[0].r&&(K.e.r=pe[0].r);break;case 27:pe[14e3]&&(be[pe[14e3][0]]=pe[14e3][1]);break;case 1537:be[pe[0]]=pe[1],pe[0]==de&&(me=pe[1]);break}},Q);else throw new Error("Unrecognized LOTUS BOF "+I[2]);if(ie["!ref"]=ln(K),xe[he||me]=ie,ge.push(he||me),!be.length)return{SheetNames:ge,Sheets:xe};for(var Z={},M=[],we=0;we<be.length;++we)xe[ge[we]]?(M.push(be[we]||ge[we]),Z[be[we]]=xe[be[we]]||xe[ge[we]]):(M.push(be[we]),Z[be[we]]={"!ref":"A1"});return{SheetNames:M,Sheets:Z}}function s(I,B){var Q=B||{};if(+Q.codepage>=0&&Kf(+Q.codepage),Q.type=="string")throw new Error("Cannot write WK1 to JS string");var ie=io(),me=vs(I["!ref"]),he=Array.isArray(I),de=[];or(ie,0,i(1030)),or(ie,6,c(me));for(var xe=Math.min(me.e.r,8191),ge=me.s.r;ge<=xe;++ge)for(var be=ai(ge),K=me.s.c;K<=me.e.c;++K){ge===me.s.r&&(de[K]=gi(K));var ye=de[K]+be,Z=he?(I[ge]||[])[K]:I[ye];if(!(!Z||Z.t=="z"))if(Z.t=="n")(Z.v|0)==Z.v&&Z.v>=-32768&&Z.v<=32767?or(ie,13,b(ge,K,Z.v)):or(ie,14,v(ge,K,Z.v));else{var M=Yd(Z);or(ie,15,f(ge,K,M.slice(0,239)))}}return or(ie,1),ie.end()}function n(I,B){var Q=B||{};if(+Q.codepage>=0&&Kf(+Q.codepage),Q.type=="string")throw new Error("Cannot write WK3 to JS string");var ie=io();or(ie,0,o(I));for(var me=0,he=0;me<I.SheetNames.length;++me)(I.Sheets[I.SheetNames[me]]||{})["!ref"]&&or(ie,27,re(I.SheetNames[me],he++));var de=0;for(me=0;me<I.SheetNames.length;++me){var xe=I.Sheets[I.SheetNames[me]];if(!(!xe||!xe["!ref"])){for(var ge=vs(xe["!ref"]),be=Array.isArray(xe),K=[],ye=Math.min(ge.e.r,8191),Z=ge.s.r;Z<=ye;++Z)for(var M=ai(Z),we=ge.s.c;we<=ge.e.c;++we){Z===ge.s.r&&(K[we]=gi(we));var pe=K[we]+M,le=be?(xe[Z]||[])[we]:xe[pe];if(!(!le||le.t=="z"))if(le.t=="n")or(ie,23,G(Z,we,de,le.v));else{var Fe=Yd(le);or(ie,22,E(Z,we,de,Fe.slice(0,239)))}}++de}}return or(ie,1),ie.end()}function i(I){var B=Ft(2);return B.write_shift(2,I),B}function o(I){var B=Ft(26);B.write_shift(2,4096),B.write_shift(2,4),B.write_shift(4,0);for(var Q=0,ie=0,me=0,he=0;he<I.SheetNames.length;++he){var de=I.SheetNames[he],xe=I.Sheets[de];if(!(!xe||!xe["!ref"])){++me;var ge=Wo(xe["!ref"]);Q<ge.e.r&&(Q=ge.e.r),ie<ge.e.c&&(ie=ge.e.c)}}return Q>8191&&(Q=8191),B.write_shift(2,Q),B.write_shift(1,me),B.write_shift(1,ie),B.write_shift(2,0),B.write_shift(2,0),B.write_shift(1,1),B.write_shift(1,2),B.write_shift(4,0),B.write_shift(4,0),B}function l(I,B,Q){var ie={s:{c:0,r:0},e:{c:0,r:0}};return B==8&&Q.qpro?(ie.s.c=I.read_shift(1),I.l++,ie.s.r=I.read_shift(2),ie.e.c=I.read_shift(1),I.l++,ie.e.r=I.read_shift(2),ie):(ie.s.c=I.read_shift(2),ie.s.r=I.read_shift(2),B==12&&Q.qpro&&(I.l+=2),ie.e.c=I.read_shift(2),ie.e.r=I.read_shift(2),B==12&&Q.qpro&&(I.l+=2),ie.s.c==65535&&(ie.s.c=ie.e.c=ie.s.r=ie.e.r=0),ie)}function c(I){var B=Ft(8);return B.write_shift(2,I.s.c),B.write_shift(2,I.s.r),B.write_shift(2,I.e.c),B.write_shift(2,I.e.r),B}function u(I,B,Q){var ie=[{c:0,r:0},{t:"n",v:0},0,0];return Q.qpro&&Q.vers!=20768?(ie[0].c=I.read_shift(1),ie[3]=I.read_shift(1),ie[0].r=I.read_shift(2),I.l+=2):(ie[2]=I.read_shift(1),ie[0].c=I.read_shift(2),ie[0].r=I.read_shift(2)),ie}function h(I,B,Q){var ie=I.l+B,me=u(I,B,Q);if(me[1].t="s",Q.vers==20768){I.l++;var he=I.read_shift(1);return me[1].v=I.read_shift(he,"utf8"),me}return Q.qpro&&I.l++,me[1].v=I.read_shift(ie-I.l,"cstr"),me}function f(I,B,Q){var ie=Ft(7+Q.length);ie.write_shift(1,255),ie.write_shift(2,B),ie.write_shift(2,I),ie.write_shift(1,39);for(var me=0;me<ie.length;++me){var he=Q.charCodeAt(me);ie.write_shift(1,he>=128?95:he)}return ie.write_shift(1,0),ie}function y(I,B,Q){var ie=u(I,B,Q);return ie[1].v=I.read_shift(2,"i"),ie}function b(I,B,Q){var ie=Ft(7);return ie.write_shift(1,255),ie.write_shift(2,B),ie.write_shift(2,I),ie.write_shift(2,Q,"i"),ie}function w(I,B,Q){var ie=u(I,B,Q);return ie[1].v=I.read_shift(8,"f"),ie}function v(I,B,Q){var ie=Ft(13);return ie.write_shift(1,255),ie.write_shift(2,B),ie.write_shift(2,I),ie.write_shift(8,Q,"f"),ie}function k(I,B,Q){var ie=I.l+B,me=u(I,B,Q);if(me[1].v=I.read_shift(8,"f"),Q.qpro)I.l=ie;else{var he=I.read_shift(2);O(I.slice(I.l,I.l+he),me),I.l+=he}return me}function S(I,B,Q){var ie=B&32768;return B&=-32769,B=(ie?I:0)+(B>=8192?B-16384:B),(ie?"":"$")+(Q?gi(B):ai(B))}var N={51:["FALSE",0],52:["TRUE",0],70:["LEN",1],80:["SUM",69],81:["AVERAGEA",69],82:["COUNTA",69],83:["MINA",69],84:["MAXA",69],111:["T",1]},C=["","","","","","","","","","+","-","*","/","^","=","<>","<=",">=","<",">","","","","","&","","","","","","",""];function O(I,B){Ro(I,0);for(var Q=[],ie=0,me="",he="",de="",xe="";I.l<I.length;){var ge=I[I.l++];switch(ge){case 0:Q.push(I.read_shift(8,"f"));break;case 1:he=S(B[0].c,I.read_shift(2),!0),me=S(B[0].r,I.read_shift(2),!1),Q.push(he+me);break;case 2:{var be=S(B[0].c,I.read_shift(2),!0),K=S(B[0].r,I.read_shift(2),!1);he=S(B[0].c,I.read_shift(2),!0),me=S(B[0].r,I.read_shift(2),!1),Q.push(be+K+":"+he+me)}break;case 3:if(I.l<I.length){console.error("WK1 premature formula end");return}break;case 4:Q.push("("+Q.pop()+")");break;case 5:Q.push(I.read_shift(2));break;case 6:{for(var ye="";ge=I[I.l++];)ye+=String.fromCharCode(ge);Q.push('"'+ye.replace(/"/g,'""')+'"')}break;case 8:Q.push("-"+Q.pop());break;case 23:Q.push("+"+Q.pop());break;case 22:Q.push("NOT("+Q.pop()+")");break;case 20:case 21:xe=Q.pop(),de=Q.pop(),Q.push(["AND","OR"][ge-20]+"("+de+","+xe+")");break;default:if(ge<32&&C[ge])xe=Q.pop(),de=Q.pop(),Q.push(de+C[ge]+xe);else if(N[ge]){if(ie=N[ge][1],ie==69&&(ie=I[I.l++]),ie>Q.length){console.error("WK1 bad formula parse 0x"+ge.toString(16)+":|"+Q.join("|")+"|");return}var Z=Q.slice(-ie);Q.length-=ie,Q.push(N[ge][0]+"("+Z.join(",")+")")}else return ge<=7?console.error("WK1 invalid opcode "+ge.toString(16)):ge<=24?console.error("WK1 unsupported op "+ge.toString(16)):ge<=30?console.error("WK1 invalid opcode "+ge.toString(16)):ge<=115?console.error("WK1 unsupported function opcode "+ge.toString(16)):console.error("WK1 unrecognized opcode "+ge.toString(16))}}Q.length==1?B[1].f=""+Q[0]:console.error("WK1 bad formula parse |"+Q.join("|")+"|")}function T(I){var B=[{c:0,r:0},{t:"n",v:0},0];return B[0].r=I.read_shift(2),B[3]=I[I.l++],B[0].c=I[I.l++],B}function P(I,B){var Q=T(I);return Q[1].t="s",Q[1].v=I.read_shift(B-4,"cstr"),Q}function E(I,B,Q,ie){var me=Ft(6+ie.length);me.write_shift(2,I),me.write_shift(1,Q),me.write_shift(1,B),me.write_shift(1,39);for(var he=0;he<ie.length;++he){var de=ie.charCodeAt(he);me.write_shift(1,de>=128?95:de)}return me.write_shift(1,0),me}function R(I,B){var Q=T(I);Q[1].v=I.read_shift(2);var ie=Q[1].v>>1;if(Q[1].v&1)switch(ie&7){case 0:ie=(ie>>3)*5e3;break;case 1:ie=(ie>>3)*500;break;case 2:ie=(ie>>3)/20;break;case 3:ie=(ie>>3)/200;break;case 4:ie=(ie>>3)/2e3;break;case 5:ie=(ie>>3)/2e4;break;case 6:ie=(ie>>3)/16;break;case 7:ie=(ie>>3)/64;break}return Q[1].v=ie,Q}function z(I,B){var Q=T(I),ie=I.read_shift(4),me=I.read_shift(4),he=I.read_shift(2);if(he==65535)return ie===0&&me===3221225472?(Q[1].t="e",Q[1].v=15):ie===0&&me===3489660928?(Q[1].t="e",Q[1].v=42):Q[1].v=0,Q;var de=he&32768;return he=(he&32767)-16446,Q[1].v=(1-de*2)*(me*Math.pow(2,he+32)+ie*Math.pow(2,he)),Q}function G(I,B,Q,ie){var me=Ft(14);if(me.write_shift(2,I),me.write_shift(1,Q),me.write_shift(1,B),ie==0)return me.write_shift(4,0),me.write_shift(4,0),me.write_shift(2,65535),me;var he=0,de=0,xe=0,ge=0;return ie<0&&(he=1,ie=-ie),de=Math.log2(ie)|0,ie/=Math.pow(2,de-31),ge=ie>>>0,(ge&2147483648)==0&&(ie/=2,++de,ge=ie>>>0),ie-=ge,ge|=2147483648,ge>>>=0,ie*=Math.pow(2,32),xe=ie>>>0,me.write_shift(4,xe),me.write_shift(4,ge),de+=16383+(he?32768:0),me.write_shift(2,de),me}function ae(I,B){var Q=z(I);return I.l+=B-14,Q}function ee(I,B){var Q=T(I),ie=I.read_shift(4);return Q[1].v=ie>>6,Q}function ne(I,B){var Q=T(I),ie=I.read_shift(8,"f");return Q[1].v=ie,Q}function te(I,B){var Q=ne(I);return I.l+=B-10,Q}function Y(I,B){return I[I.l+B-1]==0?I.read_shift(B,"cstr"):""}function q(I,B){var Q=I[I.l++];Q>B-1&&(Q=B-1);for(var ie="";ie.length<Q;)ie+=String.fromCharCode(I[I.l++]);return ie}function H(I,B,Q){if(!(!Q.qpro||B<21)){var ie=I.read_shift(1);I.l+=17,I.l+=1,I.l+=2;var me=I.read_shift(B-21,"cstr");return[ie,me]}}function U(I,B){for(var Q={},ie=I.l+B;I.l<ie;){var me=I.read_shift(2);if(me==14e3){for(Q[me]=[0,""],Q[me][0]=I.read_shift(2);I[I.l];)Q[me][1]+=String.fromCharCode(I[I.l]),I.l++;I.l++}}return Q}function re(I,B){var Q=Ft(5+I.length);Q.write_shift(2,14e3),Q.write_shift(2,B);for(var ie=0;ie<I.length;++ie){var me=I.charCodeAt(ie);Q[Q.l++]=me>127?95:me}return Q[Q.l++]=0,Q}var X={0:{n:"BOF",f:GR},1:{n:"EOF"},2:{n:"CALCMODE"},3:{n:"CALCORDER"},4:{n:"SPLIT"},5:{n:"SYNC"},6:{n:"RANGE",f:l},7:{n:"WINDOW1"},8:{n:"COLW1"},9:{n:"WINTWO"},10:{n:"COLW2"},11:{n:"NAME"},12:{n:"BLANK"},13:{n:"INTEGER",f:y},14:{n:"NUMBER",f:w},15:{n:"LABEL",f:h},16:{n:"FORMULA",f:k},24:{n:"TABLE"},25:{n:"ORANGE"},26:{n:"PRANGE"},27:{n:"SRANGE"},28:{n:"FRANGE"},29:{n:"KRANGE1"},32:{n:"HRANGE"},35:{n:"KRANGE2"},36:{n:"PROTEC"},37:{n:"FOOTER"},38:{n:"HEADER"},39:{n:"SETUP"},40:{n:"MARGINS"},41:{n:"LABELFMT"},42:{n:"TITLES"},43:{n:"SHEETJS"},45:{n:"GRAPH"},46:{n:"NGRAPH"},47:{n:"CALCCOUNT"},48:{n:"UNFORMATTED"},49:{n:"CURSORW12"},50:{n:"WINDOW"},51:{n:"STRING",f:h},55:{n:"PASSWORD"},56:{n:"LOCKED"},60:{n:"QUERY"},61:{n:"QUERYNAME"},62:{n:"PRINT"},63:{n:"PRINTNAME"},64:{n:"GRAPH2"},65:{n:"GRAPHNAME"},66:{n:"ZOOM"},67:{n:"SYMSPLIT"},68:{n:"NSROWS"},69:{n:"NSCOLS"},70:{n:"RULER"},71:{n:"NNAME"},72:{n:"ACOMM"},73:{n:"AMACRO"},74:{n:"PARSE"},102:{n:"PRANGES??"},103:{n:"RRANGES??"},104:{n:"FNAME??"},105:{n:"MRANGES??"},204:{n:"SHEETNAMECS",f:Y},222:{n:"SHEETNAMELP",f:q},65535:{n:""}},V={0:{n:"BOF"},1:{n:"EOF"},2:{n:"PASSWORD"},3:{n:"CALCSET"},4:{n:"WINDOWSET"},5:{n:"SHEETCELLPTR"},6:{n:"SHEETLAYOUT"},7:{n:"COLUMNWIDTH"},8:{n:"HIDDENCOLUMN"},9:{n:"USERRANGE"},10:{n:"SYSTEMRANGE"},11:{n:"ZEROFORCE"},12:{n:"SORTKEYDIR"},13:{n:"FILESEAL"},14:{n:"DATAFILLNUMS"},15:{n:"PRINTMAIN"},16:{n:"PRINTSTRING"},17:{n:"GRAPHMAIN"},18:{n:"GRAPHSTRING"},19:{n:"??"},20:{n:"ERRCELL"},21:{n:"NACELL"},22:{n:"LABEL16",f:P},23:{n:"NUMBER17",f:z},24:{n:"NUMBER18",f:R},25:{n:"FORMULA19",f:ae},26:{n:"FORMULA1A"},27:{n:"XFORMAT",f:U},28:{n:"DTLABELMISC"},29:{n:"DTLABELCELL"},30:{n:"GRAPHWINDOW"},31:{n:"CPA"},32:{n:"LPLAUTO"},33:{n:"QUERY"},34:{n:"HIDDENSHEET"},35:{n:"??"},37:{n:"NUMBER25",f:ee},38:{n:"??"},39:{n:"NUMBER27",f:ne},40:{n:"FORMULA28",f:te},142:{n:"??"},147:{n:"??"},150:{n:"??"},151:{n:"??"},152:{n:"??"},153:{n:"??"},154:{n:"??"},155:{n:"??"},156:{n:"??"},163:{n:"??"},174:{n:"??"},175:{n:"??"},176:{n:"??"},177:{n:"??"},184:{n:"??"},185:{n:"??"},186:{n:"??"},187:{n:"??"},188:{n:"??"},195:{n:"??"},201:{n:"??"},204:{n:"SHEETNAMECS",f:Y},205:{n:"??"},206:{n:"??"},207:{n:"??"},208:{n:"??"},256:{n:"??"},259:{n:"??"},260:{n:"??"},261:{n:"??"},262:{n:"??"},263:{n:"??"},265:{n:"??"},266:{n:"??"},267:{n:"??"},268:{n:"??"},270:{n:"??"},271:{n:"??"},384:{n:"??"},389:{n:"??"},390:{n:"??"},393:{n:"??"},396:{n:"??"},512:{n:"??"},514:{n:"??"},513:{n:"??"},516:{n:"??"},517:{n:"??"},640:{n:"??"},641:{n:"??"},642:{n:"??"},643:{n:"??"},644:{n:"??"},645:{n:"??"},646:{n:"??"},647:{n:"??"},648:{n:"??"},658:{n:"??"},659:{n:"??"},660:{n:"??"},661:{n:"??"},662:{n:"??"},665:{n:"??"},666:{n:"??"},768:{n:"??"},772:{n:"??"},1537:{n:"SHEETINFOQP",f:H},1600:{n:"??"},1602:{n:"??"},1793:{n:"??"},1794:{n:"??"},1795:{n:"??"},1796:{n:"??"},1920:{n:"??"},2048:{n:"??"},2049:{n:"??"},2052:{n:"??"},2688:{n:"??"},10998:{n:"??"},12849:{n:"??"},28233:{n:"??"},28484:{n:"??"},65535:{n:""}};return{sheet_to_wk1:s,book_to_wk3:n,to_workbook:r}})(),dJ=/^\s|\s$|[\t\n\r]/;function QR(e,r){if(!r.bookSST)return"";var a=[mn];a[a.length]=ir("sst",null,{xmlns:Bp[0],count:e.Count,uniqueCount:e.Unique});for(var s=0;s!=e.length;++s)if(e[s]!=null){var n=e[s],i="<si>";n.r?i+=n.r:(i+="<t",n.t||(n.t=""),n.t.match(dJ)&&(i+=' xml:space="preserve"'),i+=">"+Ka(n.t)+"</t>"),i+="</si>",a[a.length]=i}return a.length>2&&(a[a.length]="</sst>",a[1]=a[1].replace("/>",">")),a.join("")}function uJ(e){return[e.read_shift(4),e.read_shift(4)]}function mJ(e,r){return r||(r=Ft(8)),r.write_shift(4,e.Count),r.write_shift(4,e.Unique),r}var hJ=aY;function pJ(e){var r=io();Jt(r,159,mJ(e));for(var a=0;a<e.length;++a)Jt(r,19,hJ(e[a]));return Jt(r,160),r.end()}function gJ(e){for(var r=[],a=e.split(""),s=0;s<a.length;++s)r[s]=a[s].charCodeAt(0);return r}function eM(e){var r=0,a,s=gJ(e),n=s.length+1,i,o,l,c,u;for(a=wm(n),a[0]=s.length,i=1;i!=n;++i)a[i]=s[i-1];for(i=n-1;i>=0;--i)o=a[i],l=(r&16384)===0?0:1,c=r<<1&32767,u=l|c,r=u^o;return r^52811}var fJ=(function(){function e(n,i){switch(i.type){case"base64":return r(Kd(n),i);case"binary":return r(n,i);case"buffer":return r(Ia&&Buffer.isBuffer(n)?n.toString("binary"):kx(n),i);case"array":return r(X1(n),i)}throw new Error("Unrecognized type "+i.type)}function r(n,i){var o=i||{},l=o.dense?[]:{},c=n.match(/\\trowd.*?\\row\b/g);if(!c.length)throw new Error("RTF missing table");var u={s:{c:0,r:0},e:{c:0,r:c.length-1}};return c.forEach(function(h,f){Array.isArray(l)&&(l[f]=[]);for(var y=/\\\w+\b/g,b=0,w,v=-1;w=y.exec(h);){switch(w[0]){case"\\cell":var k=h.slice(b,y.lastIndex-w[0].length);if(k[0]==" "&&(k=k.slice(1)),++v,k.length){var S={v:k,t:"s"};Array.isArray(l)?l[f][v]=S:l[Ya({r:f,c:v})]=S}break}b=y.lastIndex}v>u.e.c&&(u.e.c=v)}),l["!ref"]=ln(u),l}function a(n,i){return Fm(e(n,i),i)}function s(n){for(var i=["{\\rtf1\\ansi"],o=vs(n["!ref"]),l,c=Array.isArray(n),u=o.s.r;u<=o.e.r;++u){i.push("\\trowd\\trautofit1");for(var h=o.s.c;h<=o.e.c;++h)i.push("\\cellx"+(h+1));for(i.push("\\pard\\intbl"),h=o.s.c;h<=o.e.c;++h){var f=Ya({r:u,c:h});l=c?(n[u]||[])[h]:n[f],!(!l||l.v==null&&(!l.f||l.F))&&(i.push(" "+(l.w||(Yd(l),l.w))),i.push("\\cell"))}i.push("\\pard\\intbl\\row")}return i.join("")+"}"}return{to_workbook:a,to_sheet:e,from_sheet:s}})();function ZE(e){for(var r=0,a=1;r!=3;++r)a=a*256+(e[r]>255?255:e[r]<0?0:e[r]);return a.toString(16).toUpperCase().slice(1)}var xJ=6,Wd=xJ;function Uv(e){return Math.floor((e+Math.round(128/Wd)/256)*Wd)}function Bv(e){return Math.floor((e-5)/Wd*100+.5)/100}function SN(e){return Math.round((e*Wd+5)/Wd*256)/256}function gS(e){e.width?(e.wpx=Uv(e.width),e.wch=Bv(e.wpx),e.MDW=Wd):e.wpx?(e.wch=Bv(e.wpx),e.width=SN(e.wch),e.MDW=Wd):typeof e.wch=="number"&&(e.width=SN(e.wch),e.wpx=Uv(e.width),e.MDW=Wd),e.customWidth&&delete e.customWidth}var yJ=96,tM=yJ;function Wv(e){return e*96/tM}function rM(e){return e*tM/96}function bJ(e){var r=["<numFmts>"];return[[5,8],[23,26],[41,44],[50,392]].forEach(function(a){for(var s=a[0];s<=a[1];++s)e[s]!=null&&(r[r.length]=ir("numFmt",null,{numFmtId:s,formatCode:Ka(e[s])}))}),r.length===1?"":(r[r.length]="</numFmts>",r[0]=ir("numFmts",null,{count:r.length-2}).replace("/>",">"),r.join(""))}function vJ(e){var r=[];return r[r.length]=ir("cellXfs",null),e.forEach(function(a){r[r.length]=ir("xf",null,a)}),r[r.length]="</cellXfs>",r.length===2?"":(r[0]=ir("cellXfs",null,{count:r.length-2}).replace("/>",">"),r.join(""))}function aM(e,r){var a=[mn,ir("styleSheet",null,{xmlns:Bp[0],"xmlns:vt":Dn.vt})],s;return e.SSF&&(s=bJ(e.SSF))!=null&&(a[a.length]=s),a[a.length]='<fonts count="1"><font><sz val="12"/><color theme="1"/><name val="Calibri"/><family val="2"/><scheme val="minor"/></font></fonts>',a[a.length]='<fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills>',a[a.length]='<borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders>',a[a.length]='<cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs>',(s=vJ(r.cellXfs))&&(a[a.length]=s),a[a.length]='<cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles>',a[a.length]='<dxfs count="0"/>',a[a.length]='<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleMedium4"/>',a.length>2&&(a[a.length]="</styleSheet>",a[1]=a[1].replace("/>",">")),a.join("")}function wJ(e,r){var a=e.read_shift(2),s=fi(e);return[a,s]}function jJ(e,r,a){a||(a=Ft(6+4*r.length)),a.write_shift(2,e),Mn(r,a);var s=a.length>a.l?a.slice(0,a.l):a;return a.l==null&&(a.l=a.length),s}function _J(e,r,a){var s={};s.sz=e.read_shift(2)/20;var n=dY(e);n.fItalic&&(s.italic=1),n.fCondense&&(s.condense=1),n.fExtend&&(s.extend=1),n.fShadow&&(s.shadow=1),n.fOutline&&(s.outline=1),n.fStrikeout&&(s.strike=1);var i=e.read_shift(2);switch(i===700&&(s.bold=1),e.read_shift(2)){case 1:s.vertAlign="superscript";break;case 2:s.vertAlign="subscript";break}var o=e.read_shift(1);o!=0&&(s.underline=o);var l=e.read_shift(1);l>0&&(s.family=l);var c=e.read_shift(1);switch(c>0&&(s.charset=c),e.l++,s.color=cY(e),e.read_shift(1)){case 1:s.scheme="major";break;case 2:s.scheme="minor";break}return s.name=fi(e),s}function kJ(e,r){r||(r=Ft(153)),r.write_shift(2,e.sz*20),uY(e,r),r.write_shift(2,e.bold?700:400);var a=0;e.vertAlign=="superscript"?a=1:e.vertAlign=="subscript"&&(a=2),r.write_shift(2,a),r.write_shift(1,e.underline||0),r.write_shift(1,e.family||0),r.write_shift(1,e.charset||0),r.write_shift(1,0),zv(e.color,r);var s=0;return s=2,r.write_shift(1,s),Mn(e.name,r),r.length>r.l?r.slice(0,r.l):r}var NJ=["none","solid","mediumGray","darkGray","lightGray","darkHorizontal","darkVertical","darkDown","darkUp","darkGrid","darkTrellis","lightHorizontal","lightVertical","lightDown","lightUp","lightGrid","lightTrellis","gray125","gray0625"],ck,SJ=zc;function XE(e,r){r||(r=Ft(84)),ck||(ck=aS(NJ));var a=ck[e.patternType];a==null&&(a=40),r.write_shift(4,a);var s=0;if(a!=40)for(zv({auto:1},r),zv({auto:1},r);s<12;++s)r.write_shift(4,0);else{for(;s<4;++s)r.write_shift(4,0);for(;s<12;++s)r.write_shift(4,0)}return r.length>r.l?r.slice(0,r.l):r}function CJ(e,r){var a=e.l+r,s=e.read_shift(2),n=e.read_shift(2);return e.l=a,{ixfe:s,numFmtId:n}}function sM(e,r,a){a||(a=Ft(16)),a.write_shift(2,r||0),a.write_shift(2,e.numFmtId||0),a.write_shift(2,0),a.write_shift(2,0),a.write_shift(2,0),a.write_shift(1,0),a.write_shift(1,0);var s=0;return a.write_shift(1,s),a.write_shift(1,0),a.write_shift(1,0),a.write_shift(1,0),a}function Jg(e,r){return r||(r=Ft(10)),r.write_shift(1,0),r.write_shift(1,0),r.write_shift(4,0),r.write_shift(4,0),r}var TJ=zc;function EJ(e,r){return r||(r=Ft(51)),r.write_shift(1,0),Jg(null,r),Jg(null,r),Jg(null,r),Jg(null,r),Jg(null,r),r.length>r.l?r.slice(0,r.l):r}function AJ(e,r){return r||(r=Ft(52)),r.write_shift(4,e.xfId),r.write_shift(2,1),r.write_shift(1,0),r.write_shift(1,0),Iv(e.name||"",r),r.length>r.l?r.slice(0,r.l):r}function OJ(e,r,a){var s=Ft(2052);return s.write_shift(4,e),Iv(r,s),Iv(a,s),s.length>s.l?s.slice(0,s.l):s}function PJ(e,r){if(r){var a=0;[[5,8],[23,26],[41,44],[50,392]].forEach(function(s){for(var n=s[0];n<=s[1];++n)r[n]!=null&&++a}),a!=0&&(Jt(e,615,ec(a)),[[5,8],[23,26],[41,44],[50,392]].forEach(function(s){for(var n=s[0];n<=s[1];++n)r[n]!=null&&Jt(e,44,jJ(n,r[n]))}),Jt(e,616))}}function DJ(e){var r=1;Jt(e,611,ec(r)),Jt(e,43,kJ({sz:12,color:{theme:1},name:"Calibri",family:2})),Jt(e,612)}function RJ(e){var r=2;Jt(e,603,ec(r)),Jt(e,45,XE({patternType:"none"})),Jt(e,45,XE({patternType:"gray125"})),Jt(e,604)}function MJ(e){var r=1;Jt(e,613,ec(r)),Jt(e,46,EJ()),Jt(e,614)}function LJ(e){var r=1;Jt(e,626,ec(r)),Jt(e,47,sM({numFmtId:0},65535)),Jt(e,627)}function FJ(e,r){Jt(e,617,ec(r.length)),r.forEach(function(a){Jt(e,47,sM(a,0))}),Jt(e,618)}function IJ(e){var r=1;Jt(e,619,ec(r)),Jt(e,48,AJ({xfId:0,name:"Normal"})),Jt(e,620)}function zJ(e){var r=0;Jt(e,505,ec(r)),Jt(e,506)}function $J(e){var r=0;Jt(e,508,OJ(r,"TableStyleMedium9","PivotStyleMedium4")),Jt(e,509)}function UJ(e,r){var a=io();return Jt(a,278),PJ(a,e.SSF),DJ(a),RJ(a),MJ(a),LJ(a),FJ(a,r.cellXfs),IJ(a),zJ(a),$J(a),Jt(a,279),a.end()}function nM(e,r){if(r&&r.themeXLSX)return r.themeXLSX;if(e&&typeof e.raw=="string")return e.raw;var a=[mn];return a[a.length]='<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme">',a[a.length]="<a:themeElements>",a[a.length]='<a:clrScheme name="Office">',a[a.length]='<a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1>',a[a.length]='<a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1>',a[a.length]='<a:dk2><a:srgbClr val="1F497D"/></a:dk2>',a[a.length]='<a:lt2><a:srgbClr val="EEECE1"/></a:lt2>',a[a.length]='<a:accent1><a:srgbClr val="4F81BD"/></a:accent1>',a[a.length]='<a:accent2><a:srgbClr val="C0504D"/></a:accent2>',a[a.length]='<a:accent3><a:srgbClr val="9BBB59"/></a:accent3>',a[a.length]='<a:accent4><a:srgbClr val="8064A2"/></a:accent4>',a[a.length]='<a:accent5><a:srgbClr val="4BACC6"/></a:accent5>',a[a.length]='<a:accent6><a:srgbClr val="F79646"/></a:accent6>',a[a.length]='<a:hlink><a:srgbClr val="0000FF"/></a:hlink>',a[a.length]='<a:folHlink><a:srgbClr val="800080"/></a:folHlink>',a[a.length]="</a:clrScheme>",a[a.length]='<a:fontScheme name="Office">',a[a.length]="<a:majorFont>",a[a.length]='<a:latin typeface="Cambria"/>',a[a.length]='<a:ea typeface=""/>',a[a.length]='<a:cs typeface=""/>',a[a.length]='<a:font script="Jpan" typeface="MS Pゴシック"/>',a[a.length]='<a:font script="Hang" typeface="맑은 고딕"/>',a[a.length]='<a:font script="Hans" typeface="宋体"/>',a[a.length]='<a:font script="Hant" typeface="新細明體"/>',a[a.length]='<a:font script="Arab" typeface="Times New Roman"/>',a[a.length]='<a:font script="Hebr" typeface="Times New Roman"/>',a[a.length]='<a:font script="Thai" typeface="Tahoma"/>',a[a.length]='<a:font script="Ethi" typeface="Nyala"/>',a[a.length]='<a:font script="Beng" typeface="Vrinda"/>',a[a.length]='<a:font script="Gujr" typeface="Shruti"/>',a[a.length]='<a:font script="Khmr" typeface="MoolBoran"/>',a[a.length]='<a:font script="Knda" typeface="Tunga"/>',a[a.length]='<a:font script="Guru" typeface="Raavi"/>',a[a.length]='<a:font script="Cans" typeface="Euphemia"/>',a[a.length]='<a:font script="Cher" typeface="Plantagenet Cherokee"/>',a[a.length]='<a:font script="Yiii" typeface="Microsoft Yi Baiti"/>',a[a.length]='<a:font script="Tibt" typeface="Microsoft Himalaya"/>',a[a.length]='<a:font script="Thaa" typeface="MV Boli"/>',a[a.length]='<a:font script="Deva" typeface="Mangal"/>',a[a.length]='<a:font script="Telu" typeface="Gautami"/>',a[a.length]='<a:font script="Taml" typeface="Latha"/>',a[a.length]='<a:font script="Syrc" typeface="Estrangelo Edessa"/>',a[a.length]='<a:font script="Orya" typeface="Kalinga"/>',a[a.length]='<a:font script="Mlym" typeface="Kartika"/>',a[a.length]='<a:font script="Laoo" typeface="DokChampa"/>',a[a.length]='<a:font script="Sinh" typeface="Iskoola Pota"/>',a[a.length]='<a:font script="Mong" typeface="Mongolian Baiti"/>',a[a.length]='<a:font script="Viet" typeface="Times New Roman"/>',a[a.length]='<a:font script="Uigh" typeface="Microsoft Uighur"/>',a[a.length]='<a:font script="Geor" typeface="Sylfaen"/>',a[a.length]="</a:majorFont>",a[a.length]="<a:minorFont>",a[a.length]='<a:latin typeface="Calibri"/>',a[a.length]='<a:ea typeface=""/>',a[a.length]='<a:cs typeface=""/>',a[a.length]='<a:font script="Jpan" typeface="MS Pゴシック"/>',a[a.length]='<a:font script="Hang" typeface="맑은 고딕"/>',a[a.length]='<a:font script="Hans" typeface="宋体"/>',a[a.length]='<a:font script="Hant" typeface="新細明體"/>',a[a.length]='<a:font script="Arab" typeface="Arial"/>',a[a.length]='<a:font script="Hebr" typeface="Arial"/>',a[a.length]='<a:font script="Thai" typeface="Tahoma"/>',a[a.length]='<a:font script="Ethi" typeface="Nyala"/>',a[a.length]='<a:font script="Beng" typeface="Vrinda"/>',a[a.length]='<a:font script="Gujr" typeface="Shruti"/>',a[a.length]='<a:font script="Khmr" typeface="DaunPenh"/>',a[a.length]='<a:font script="Knda" typeface="Tunga"/>',a[a.length]='<a:font script="Guru" typeface="Raavi"/>',a[a.length]='<a:font script="Cans" typeface="Euphemia"/>',a[a.length]='<a:font script="Cher" typeface="Plantagenet Cherokee"/>',a[a.length]='<a:font script="Yiii" typeface="Microsoft Yi Baiti"/>',a[a.length]='<a:font script="Tibt" typeface="Microsoft Himalaya"/>',a[a.length]='<a:font script="Thaa" typeface="MV Boli"/>',a[a.length]='<a:font script="Deva" typeface="Mangal"/>',a[a.length]='<a:font script="Telu" typeface="Gautami"/>',a[a.length]='<a:font script="Taml" typeface="Latha"/>',a[a.length]='<a:font script="Syrc" typeface="Estrangelo Edessa"/>',a[a.length]='<a:font script="Orya" typeface="Kalinga"/>',a[a.length]='<a:font script="Mlym" typeface="Kartika"/>',a[a.length]='<a:font script="Laoo" typeface="DokChampa"/>',a[a.length]='<a:font script="Sinh" typeface="Iskoola Pota"/>',a[a.length]='<a:font script="Mong" typeface="Mongolian Baiti"/>',a[a.length]='<a:font script="Viet" typeface="Arial"/>',a[a.length]='<a:font script="Uigh" typeface="Microsoft Uighur"/>',a[a.length]='<a:font script="Geor" typeface="Sylfaen"/>',a[a.length]="</a:minorFont>",a[a.length]="</a:fontScheme>",a[a.length]='<a:fmtScheme name="Office">',a[a.length]="<a:fillStyleLst>",a[a.length]='<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>',a[a.length]='<a:gradFill rotWithShape="1">',a[a.length]="<a:gsLst>",a[a.length]='<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs>',a[a.length]='<a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod val="300000"/></a:schemeClr></a:gs>',a[a.length]='<a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs>',a[a.length]="</a:gsLst>",a[a.length]='<a:lin ang="16200000" scaled="1"/>',a[a.length]="</a:gradFill>",a[a.length]='<a:gradFill rotWithShape="1">',a[a.length]="<a:gsLst>",a[a.length]='<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="100000"/><a:shade val="100000"/><a:satMod val="130000"/></a:schemeClr></a:gs>',a[a.length]='<a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="50000"/><a:shade val="100000"/><a:satMod val="350000"/></a:schemeClr></a:gs>',a[a.length]="</a:gsLst>",a[a.length]='<a:lin ang="16200000" scaled="0"/>',a[a.length]="</a:gradFill>",a[a.length]="</a:fillStyleLst>",a[a.length]="<a:lnStyleLst>",a[a.length]='<a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000"/><a:satMod val="105000"/></a:schemeClr></a:solidFill><a:prstDash val="solid"/></a:ln>',a[a.length]='<a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln>',a[a.length]='<a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln>',a[a.length]="</a:lnStyleLst>",a[a.length]="<a:effectStyleLst>",a[a.length]="<a:effectStyle>",a[a.length]="<a:effectLst>",a[a.length]='<a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000"/></a:srgbClr></a:outerShdw>',a[a.length]="</a:effectLst>",a[a.length]="</a:effectStyle>",a[a.length]="<a:effectStyle>",a[a.length]="<a:effectLst>",a[a.length]='<a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw>',a[a.length]="</a:effectLst>",a[a.length]="</a:effectStyle>",a[a.length]="<a:effectStyle>",a[a.length]="<a:effectLst>",a[a.length]='<a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw>',a[a.length]="</a:effectLst>",a[a.length]='<a:scene3d><a:camera prst="orthographicFront"><a:rot lat="0" lon="0" rev="0"/></a:camera><a:lightRig rig="threePt" dir="t"><a:rot lat="0" lon="0" rev="1200000"/></a:lightRig></a:scene3d>',a[a.length]='<a:sp3d><a:bevelT w="63500" h="25400"/></a:sp3d>',a[a.length]="</a:effectStyle>",a[a.length]="</a:effectStyleLst>",a[a.length]="<a:bgFillStyleLst>",a[a.length]='<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>',a[a.length]='<a:gradFill rotWithShape="1">',a[a.length]="<a:gsLst>",a[a.length]='<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs>',a[a.length]='<a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000"/><a:shade val="99000"/><a:satMod val="350000"/></a:schemeClr></a:gs>',a[a.length]='<a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs>',a[a.length]="</a:gsLst>",a[a.length]='<a:path path="circle"><a:fillToRect l="50000" t="-80000" r="50000" b="180000"/></a:path>',a[a.length]="</a:gradFill>",a[a.length]='<a:gradFill rotWithShape="1">',a[a.length]="<a:gsLst>",a[a.length]='<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs>',a[a.length]='<a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs>',a[a.length]="</a:gsLst>",a[a.length]='<a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path>',a[a.length]="</a:gradFill>",a[a.length]="</a:bgFillStyleLst>",a[a.length]="</a:fmtScheme>",a[a.length]="</a:themeElements>",a[a.length]="<a:objectDefaults>",a[a.length]="<a:spDef>",a[a.length]='<a:spPr/><a:bodyPr/><a:lstStyle/><a:style><a:lnRef idx="1"><a:schemeClr val="accent1"/></a:lnRef><a:fillRef idx="3"><a:schemeClr val="accent1"/></a:fillRef><a:effectRef idx="2"><a:schemeClr val="accent1"/></a:effectRef><a:fontRef idx="minor"><a:schemeClr val="lt1"/></a:fontRef></a:style>',a[a.length]="</a:spDef>",a[a.length]="<a:lnDef>",a[a.length]='<a:spPr/><a:bodyPr/><a:lstStyle/><a:style><a:lnRef idx="2"><a:schemeClr val="accent1"/></a:lnRef><a:fillRef idx="0"><a:schemeClr val="accent1"/></a:fillRef><a:effectRef idx="1"><a:schemeClr val="accent1"/></a:effectRef><a:fontRef idx="minor"><a:schemeClr val="tx1"/></a:fontRef></a:style>',a[a.length]="</a:lnDef>",a[a.length]="</a:objectDefaults>",a[a.length]="<a:extraClrSchemeLst/>",a[a.length]="</a:theme>",a.join("")}function BJ(e,r){return{flags:e.read_shift(4),version:e.read_shift(4),name:fi(e)}}function WJ(e){var r=Ft(12+2*e.name.length);return r.write_shift(4,e.flags),r.write_shift(4,e.version),Mn(e.name,r),r.slice(0,r.l)}function HJ(e){for(var r=[],a=e.read_shift(4);a-- >0;)r.push([e.read_shift(4),e.read_shift(4)]);return r}function qJ(e){var r=Ft(4+8*e.length);r.write_shift(4,e.length);for(var a=0;a<e.length;++a)r.write_shift(4,e[a][0]),r.write_shift(4,e[a][1]);return r}function VJ(e,r){var a=Ft(8+2*r.length);return a.write_shift(4,e),Mn(r,a),a.slice(0,a.l)}function GJ(e){return e.l+=4,e.read_shift(4)!=0}function KJ(e,r){var a=Ft(8);return a.write_shift(4,e),a.write_shift(4,1),a}function YJ(){var e=io();return Jt(e,332),Jt(e,334,ec(1)),Jt(e,335,WJ({name:"XLDAPR",version:12e4,flags:3496657072})),Jt(e,336),Jt(e,339,VJ(1,"XLDAPR")),Jt(e,52),Jt(e,35,ec(514)),Jt(e,4096,ec(0)),Jt(e,4097,hl(1)),Jt(e,36),Jt(e,53),Jt(e,340),Jt(e,337,KJ(1)),Jt(e,51,qJ([[1,0]])),Jt(e,338),Jt(e,333),e.end()}function iM(){var e=[mn];return e.push(`<metadata xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:xlrd="http://schemas.microsoft.com/office/spreadsheetml/2017/richdata" xmlns:xda="http://schemas.microsoft.com/office/spreadsheetml/2017/dynamicarray">
|
||
<metadataTypes count="1">
|
||
<metadataType name="XLDAPR" minSupportedVersion="120000" copy="1" pasteAll="1" pasteValues="1" merge="1" splitFirst="1" rowColShift="1" clearFormats="1" clearComments="1" assign="1" coerce="1" cellMeta="1"/>
|
||
</metadataTypes>
|
||
<futureMetadata name="XLDAPR" count="1">
|
||
<bk>
|
||
<extLst>
|
||
<ext uri="{bdbb8cdc-fa1e-496e-a857-3c3f30c029c3}">
|
||
<xda:dynamicArrayProperties fDynamic="1" fCollapsed="0"/>
|
||
</ext>
|
||
</extLst>
|
||
</bk>
|
||
</futureMetadata>
|
||
<cellMetadata count="1">
|
||
<bk>
|
||
<rc t="1" v="0"/>
|
||
</bk>
|
||
</cellMetadata>
|
||
</metadata>`),e.join("")}function JJ(e){var r={};r.i=e.read_shift(4);var a={};a.r=e.read_shift(4),a.c=e.read_shift(4),r.r=Ya(a);var s=e.read_shift(1);return s&2&&(r.l="1"),s&8&&(r.a="1"),r}var lp=1024;function oM(e,r){for(var a=[21600,21600],s=["m0,0l0",a[1],a[0],a[1],a[0],"0xe"].join(","),n=[ir("xml",null,{"xmlns:v":Lo.v,"xmlns:o":Lo.o,"xmlns:x":Lo.x,"xmlns:mv":Lo.mv}).replace(/\/>/,">"),ir("o:shapelayout",ir("o:idmap",null,{"v:ext":"edit",data:e}),{"v:ext":"edit"}),ir("v:shapetype",[ir("v:stroke",null,{joinstyle:"miter"}),ir("v:path",null,{gradientshapeok:"t","o:connecttype":"rect"})].join(""),{id:"_x0000_t202","o:spt":202,coordsize:a.join(","),path:s})];lp<e*1e3;)lp+=1e3;return r.forEach(function(i){var o=Rn(i[0]),l={color2:"#BEFF82",type:"gradient"};l.type=="gradient"&&(l.angle="-180");var c=l.type=="gradient"?ir("o:fill",null,{type:"gradientUnscaled","v:ext":"view"}):null,u=ir("v:fill",c,l),h={on:"t",obscured:"t"};++lp,n=n.concat(["<v:shape"+Xf({id:"_x0000_s"+lp,type:"#_x0000_t202",style:"position:absolute; margin-left:80pt;margin-top:5pt;width:104pt;height:64pt;z-index:10"+(i[1].hidden?";visibility:hidden":""),fillcolor:"#ECFAD4",strokecolor:"#edeaa1"})+">",u,ir("v:shadow",null,h),ir("v:path",null,{"o:connecttype":"none"}),'<v:textbox><div style="text-align:left"></div></v:textbox>','<x:ClientData ObjectType="Note">',"<x:MoveWithCells/>","<x:SizeWithCells/>",ei("x:Anchor",[o.c+1,0,o.r+1,0,o.c+3,20,o.r+5,20].join(",")),ei("x:AutoFill","False"),ei("x:Row",String(o.r)),ei("x:Column",String(o.c)),i[1].hidden?"":"<x:Visible/>","</x:ClientData>","</v:shape>"])}),n.push("</xml>"),n.join("")}function lM(e){var r=[mn,ir("comments",null,{xmlns:Bp[0]})],a=[];return r.push("<authors>"),e.forEach(function(s){s[1].forEach(function(n){var i=Ka(n.a);a.indexOf(i)==-1&&(a.push(i),r.push("<author>"+i+"</author>")),n.T&&n.ID&&a.indexOf("tc="+n.ID)==-1&&(a.push("tc="+n.ID),r.push("<author>tc="+n.ID+"</author>"))})}),a.length==0&&(a.push("SheetJ5"),r.push("<author>SheetJ5</author>")),r.push("</authors>"),r.push("<commentList>"),e.forEach(function(s){var n=0,i=[];if(s[1][0]&&s[1][0].T&&s[1][0].ID?n=a.indexOf("tc="+s[1][0].ID):s[1].forEach(function(c){c.a&&(n=a.indexOf(Ka(c.a))),i.push(c.t||"")}),r.push('<comment ref="'+s[0]+'" authorId="'+n+'"><text>'),i.length<=1)r.push(ei("t",Ka(i[0]||"")));else{for(var o=`Comment:
|
||
`+i[0]+`
|
||
`,l=1;l<i.length;++l)o+=`Reply:
|
||
`+i[l]+`
|
||
`;r.push(ei("t",Ka(o)))}r.push("</text></comment>")}),r.push("</commentList>"),r.length>2&&(r[r.length]="</comments>",r[1]=r[1].replace("/>",">")),r.join("")}function ZJ(e,r,a){var s=[mn,ir("ThreadedComments",null,{xmlns:Dn.TCMNT}).replace(/[\/]>/,">")];return e.forEach(function(n){var i="";(n[1]||[]).forEach(function(o,l){if(!o.T){delete o.ID;return}o.a&&r.indexOf(o.a)==-1&&r.push(o.a);var c={ref:n[0],id:"{54EE7951-7262-4200-6969-"+("000000000000"+a.tcid++).slice(-12)+"}"};l==0?i=c.id:c.parentId=i,o.ID=c.id,o.a&&(c.personId="{54EE7950-7262-4200-6969-"+("000000000000"+r.indexOf(o.a)).slice(-12)+"}"),s.push(ir("threadedComment",ei("text",o.t||""),c))})}),s.push("</ThreadedComments>"),s.join("")}function XJ(e){var r=[mn,ir("personList",null,{xmlns:Dn.TCMNT,"xmlns:x":Bp[0]}).replace(/[\/]>/,">")];return e.forEach(function(a,s){r.push(ir("person",null,{displayName:a,id:"{54EE7950-7262-4200-6969-"+("000000000000"+s).slice(-12)+"}",userId:a,providerId:"None"}))}),r.push("</personList>"),r.join("")}function QJ(e){var r={};r.iauthor=e.read_shift(4);var a=Um(e);return r.rfx=a.s,r.ref=Ya(a.s),e.l+=16,r}function eZ(e,r){return r==null&&(r=Ft(36)),r.write_shift(4,e[1].iauthor),Hp(e[0],r),r.write_shift(4,0),r.write_shift(4,0),r.write_shift(4,0),r.write_shift(4,0),r}var tZ=fi;function rZ(e){return Mn(e.slice(0,54))}function aZ(e){var r=io(),a=[];return Jt(r,628),Jt(r,630),e.forEach(function(s){s[1].forEach(function(n){a.indexOf(n.a)>-1||(a.push(n.a.slice(0,54)),Jt(r,632,rZ(n.a)))})}),Jt(r,631),Jt(r,633),e.forEach(function(s){s[1].forEach(function(n){n.iauthor=a.indexOf(n.a);var i={s:Rn(s[0]),e:Rn(s[0])};Jt(r,635,eZ([i,n])),n.t&&n.t.length>0&&Jt(r,637,nY(n)),Jt(r,636),delete n.iauthor})}),Jt(r,634),Jt(r,629),r.end()}function sZ(e,r){r.FullPaths.forEach(function(a,s){if(s!=0){var n=a.replace(/[^\/]*[\/]/,"/_VBA_PROJECT_CUR/");n.slice(-1)!=="/"&&as.utils.cfb_add(e,n,r.FileIndex[s].content)}})}var cM=["xlsb","xlsm","xlam","biff8","xla"],nZ=(function(){var e=/(^|[^A-Za-z_])R(\[?-?\d+\]|[1-9]\d*|)C(\[?-?\d+\]|[1-9]\d*|)(?![A-Za-z0-9_])/g,r={r:0,c:0};function a(s,n,i,o){var l=!1,c=!1;i.length==0?c=!0:i.charAt(0)=="["&&(c=!0,i=i.slice(1,-1)),o.length==0?l=!0:o.charAt(0)=="["&&(l=!0,o=o.slice(1,-1));var u=i.length>0?parseInt(i,10)|0:0,h=o.length>0?parseInt(o,10)|0:0;return l?h+=r.c:--h,c?u+=r.r:--u,n+(l?"":"$")+gi(h)+(c?"":"$")+ai(u)}return function(n,i){return r=i,n.replace(e,a)}})(),fS=/(^|[^._A-Z0-9])([$]?)([A-Z]{1,2}|[A-W][A-Z]{2}|X[A-E][A-Z]|XF[A-D])([$]?)(10[0-3]\d{4}|104[0-7]\d{3}|1048[0-4]\d{2}|10485[0-6]\d|104857[0-6]|[1-9]\d{0,5})(?![_.\(A-Za-z0-9])/g,xS=(function(){return function(r,a){return r.replace(fS,function(s,n,i,o,l,c){var u=dS(o)-(i?0:a.c),h=cS(c)-(l?0:a.r),f=h==0?"":l?h+1:"["+h+"]",y=u==0?"":i?u+1:"["+u+"]";return n+"R"+f+"C"+y})}})();function iZ(e,r){return e.replace(fS,function(a,s,n,i,o,l){return s+(n=="$"?n+i:gi(dS(i)+r.c))+(o=="$"?o+l:ai(cS(l)+r.r))})}function oZ(e){return e.length!=1}function rn(e){e.l+=1}function Qu(e,r){var a=e.read_shift(2);return[a&16383,a>>14&1,a>>15&1]}function dM(e,r,a){var s=2;if(a){if(a.biff>=2&&a.biff<=5)return uM(e);a.biff==12&&(s=4)}var n=e.read_shift(s),i=e.read_shift(s),o=Qu(e),l=Qu(e);return{s:{r:n,c:o[0],cRel:o[1],rRel:o[2]},e:{r:i,c:l[0],cRel:l[1],rRel:l[2]}}}function uM(e){var r=Qu(e),a=Qu(e),s=e.read_shift(1),n=e.read_shift(1);return{s:{r:r[0],c:s,cRel:r[1],rRel:r[2]},e:{r:a[0],c:n,cRel:a[1],rRel:a[2]}}}function lZ(e,r,a){if(a.biff<8)return uM(e);var s=e.read_shift(a.biff==12?4:2),n=e.read_shift(a.biff==12?4:2),i=Qu(e),o=Qu(e);return{s:{r:s,c:i[0],cRel:i[1],rRel:i[2]},e:{r:n,c:o[0],cRel:o[1],rRel:o[2]}}}function mM(e,r,a){if(a&&a.biff>=2&&a.biff<=5)return cZ(e);var s=e.read_shift(a&&a.biff==12?4:2),n=Qu(e);return{r:s,c:n[0],cRel:n[1],rRel:n[2]}}function cZ(e){var r=Qu(e),a=e.read_shift(1);return{r:r[0],c:a,cRel:r[1],rRel:r[2]}}function dZ(e){var r=e.read_shift(2),a=e.read_shift(2);return{r,c:a&255,fQuoted:!!(a&16384),cRel:a>>15,rRel:a>>15}}function uZ(e,r,a){var s=a&&a.biff?a.biff:8;if(s>=2&&s<=5)return mZ(e);var n=e.read_shift(s>=12?4:2),i=e.read_shift(2),o=(i&16384)>>14,l=(i&32768)>>15;if(i&=16383,l==1)for(;n>524287;)n-=1048576;if(o==1)for(;i>8191;)i=i-16384;return{r:n,c:i,cRel:o,rRel:l}}function mZ(e){var r=e.read_shift(2),a=e.read_shift(1),s=(r&32768)>>15,n=(r&16384)>>14;return r&=16383,s==1&&r>=8192&&(r=r-16384),n==1&&a>=128&&(a=a-256),{r,c:a,cRel:n,rRel:s}}function hZ(e,r,a){var s=(e[e.l++]&96)>>5,n=dM(e,a.biff>=2&&a.biff<=5?6:8,a);return[s,n]}function pZ(e,r,a){var s=(e[e.l++]&96)>>5,n=e.read_shift(2,"i"),i=8;if(a)switch(a.biff){case 5:e.l+=12,i=6;break;case 12:i=12;break}var o=dM(e,i,a);return[s,n,o]}function gZ(e,r,a){var s=(e[e.l++]&96)>>5;return e.l+=a&&a.biff>8?12:a.biff<8?6:8,[s]}function fZ(e,r,a){var s=(e[e.l++]&96)>>5,n=e.read_shift(2),i=8;if(a)switch(a.biff){case 5:e.l+=12,i=6;break;case 12:i=12;break}return e.l+=i,[s,n]}function xZ(e,r,a){var s=(e[e.l++]&96)>>5,n=lZ(e,r-1,a);return[s,n]}function yZ(e,r,a){var s=(e[e.l++]&96)>>5;return e.l+=a.biff==2?6:a.biff==12?14:7,[s]}function QE(e){var r=e[e.l+1]&1,a=1;return e.l+=4,[r,a]}function bZ(e,r,a){e.l+=2;for(var s=e.read_shift(a&&a.biff==2?1:2),n=[],i=0;i<=s;++i)n.push(e.read_shift(a&&a.biff==2?1:2));return n}function vZ(e,r,a){var s=e[e.l+1]&255?1:0;return e.l+=2,[s,e.read_shift(a&&a.biff==2?1:2)]}function wZ(e,r,a){var s=e[e.l+1]&255?1:0;return e.l+=2,[s,e.read_shift(a&&a.biff==2?1:2)]}function jZ(e){var r=e[e.l+1]&255?1:0;return e.l+=2,[r,e.read_shift(2)]}function _Z(e,r,a){var s=e[e.l+1]&255?1:0;return e.l+=a&&a.biff==2?3:4,[s]}function hM(e){var r=e.read_shift(1),a=e.read_shift(1);return[r,a]}function kZ(e){return e.read_shift(2),hM(e)}function NZ(e){return e.read_shift(2),hM(e)}function SZ(e,r,a){var s=(e[e.l]&96)>>5;e.l+=1;var n=mM(e,0,a);return[s,n]}function CZ(e,r,a){var s=(e[e.l]&96)>>5;e.l+=1;var n=uZ(e,0,a);return[s,n]}function TZ(e,r,a){var s=(e[e.l]&96)>>5;e.l+=1;var n=e.read_shift(2);a&&a.biff==5&&(e.l+=12);var i=mM(e,0,a);return[s,n,i]}function EZ(e,r,a){var s=(e[e.l]&96)>>5;e.l+=1;var n=e.read_shift(a&&a.biff<=3?1:2);return[EX[n],fM[n],s]}function AZ(e,r,a){var s=e[e.l++],n=e.read_shift(1),i=a&&a.biff<=3?[s==88?-1:0,e.read_shift(1)]:OZ(e);return[n,(i[0]===0?fM:TX)[i[1]]]}function OZ(e){return[e[e.l+1]>>7,e.read_shift(2)&32767]}function PZ(e,r,a){e.l+=a&&a.biff==2?3:4}function DZ(e,r,a){if(e.l++,a&&a.biff==12)return[e.read_shift(4,"i"),0];var s=e.read_shift(2),n=e.read_shift(a&&a.biff==2?1:2);return[s,n]}function RZ(e){return e.l++,Cx[e.read_shift(1)]}function MZ(e){return e.l++,e.read_shift(2)}function LZ(e){return e.l++,e.read_shift(1)!==0}function FZ(e){return e.l++,qp(e)}function IZ(e,r,a){return e.l++,YR(e,r-1,a)}function zZ(e,r){var a=[e.read_shift(1)];if(r==12)switch(a[0]){case 2:a[0]=4;break;case 4:a[0]=16;break;case 0:a[0]=1;break;case 1:a[0]=2;break}switch(a[0]){case 4:a[1]=TY(e,1)?"TRUE":"FALSE",r!=12&&(e.l+=7);break;case 37:case 16:a[1]=Cx[e[e.l]],e.l+=r==12?4:8;break;case 0:e.l+=8;break;case 1:a[1]=qp(e);break;case 2:a[1]=PY(e,0,{biff:r>0&&r<8?2:r});break;default:throw new Error("Bad SerAr: "+a[0])}return a}function $Z(e,r,a){for(var s=e.read_shift(a.biff==12?4:2),n=[],i=0;i!=s;++i)n.push((a.biff==12?Um:MY)(e));return n}function UZ(e,r,a){var s=0,n=0;a.biff==12?(s=e.read_shift(4),n=e.read_shift(4)):(n=1+e.read_shift(1),s=1+e.read_shift(2)),a.biff>=2&&a.biff<8&&(--s,--n==0&&(n=256));for(var i=0,o=[];i!=s&&(o[i]=[]);++i)for(var l=0;l!=n;++l)o[i][l]=zZ(e,a.biff);return o}function BZ(e,r,a){var s=e.read_shift(1)>>>5&3,n=!a||a.biff>=8?4:2,i=e.read_shift(n);switch(a.biff){case 2:e.l+=5;break;case 3:case 4:e.l+=8;break;case 5:e.l+=12;break}return[s,0,i]}function WZ(e,r,a){if(a.biff==5)return HZ(e);var s=e.read_shift(1)>>>5&3,n=e.read_shift(2),i=e.read_shift(4);return[s,n,i]}function HZ(e){var r=e.read_shift(1)>>>5&3,a=e.read_shift(2,"i");e.l+=8;var s=e.read_shift(2);return e.l+=12,[r,a,s]}function qZ(e,r,a){var s=e.read_shift(1)>>>5&3;e.l+=a&&a.biff==2?3:4;var n=e.read_shift(a&&a.biff==2?1:2);return[s,n]}function VZ(e,r,a){var s=e.read_shift(1)>>>5&3,n=e.read_shift(a&&a.biff==2?1:2);return[s,n]}function GZ(e,r,a){var s=e.read_shift(1)>>>5&3;return e.l+=4,a.biff<8&&e.l--,a.biff==12&&(e.l+=2),[s]}function KZ(e,r,a){var s=(e[e.l++]&96)>>5,n=e.read_shift(2),i=4;if(a)switch(a.biff){case 5:i=15;break;case 12:i=6;break}return e.l+=i,[s,n]}var YZ=zc,JZ=zc,ZZ=zc;function Tx(e,r,a){return e.l+=2,[dZ(e)]}function yS(e){return e.l+=6,[]}var XZ=Tx,QZ=yS,eX=yS,tX=Tx;function pM(e){return e.l+=2,[GR(e),e.read_shift(2)&1]}var rX=Tx,aX=pM,sX=yS,nX=Tx,iX=Tx,oX=["Data","All","Headers","??","?Data2","??","?DataHeaders","??","Totals","??","??","??","?DataTotals","??","??","??","?Current"];function lX(e){e.l+=2;var r=e.read_shift(2),a=e.read_shift(2),s=e.read_shift(4),n=e.read_shift(2),i=e.read_shift(2),o=oX[a>>2&31];return{ixti:r,coltype:a&3,rt:o,idx:s,c:n,C:i}}function cX(e){return e.l+=2,[e.read_shift(4)]}function dX(e,r,a){return e.l+=5,e.l+=2,e.l+=a.biff==2?1:4,["PTGSHEET"]}function uX(e,r,a){return e.l+=a.biff==2?4:5,["PTGENDSHEET"]}function mX(e){var r=e.read_shift(1)>>>5&3,a=e.read_shift(2);return[r,a]}function hX(e){var r=e.read_shift(1)>>>5&3,a=e.read_shift(2);return[r,a]}function pX(e){return e.l+=4,[0,0]}var e7={1:{n:"PtgExp",f:DZ},2:{n:"PtgTbl",f:ZZ},3:{n:"PtgAdd",f:rn},4:{n:"PtgSub",f:rn},5:{n:"PtgMul",f:rn},6:{n:"PtgDiv",f:rn},7:{n:"PtgPower",f:rn},8:{n:"PtgConcat",f:rn},9:{n:"PtgLt",f:rn},10:{n:"PtgLe",f:rn},11:{n:"PtgEq",f:rn},12:{n:"PtgGe",f:rn},13:{n:"PtgGt",f:rn},14:{n:"PtgNe",f:rn},15:{n:"PtgIsect",f:rn},16:{n:"PtgUnion",f:rn},17:{n:"PtgRange",f:rn},18:{n:"PtgUplus",f:rn},19:{n:"PtgUminus",f:rn},20:{n:"PtgPercent",f:rn},21:{n:"PtgParen",f:rn},22:{n:"PtgMissArg",f:rn},23:{n:"PtgStr",f:IZ},26:{n:"PtgSheet",f:dX},27:{n:"PtgEndSheet",f:uX},28:{n:"PtgErr",f:RZ},29:{n:"PtgBool",f:LZ},30:{n:"PtgInt",f:MZ},31:{n:"PtgNum",f:FZ},32:{n:"PtgArray",f:yZ},33:{n:"PtgFunc",f:EZ},34:{n:"PtgFuncVar",f:AZ},35:{n:"PtgName",f:BZ},36:{n:"PtgRef",f:SZ},37:{n:"PtgArea",f:hZ},38:{n:"PtgMemArea",f:qZ},39:{n:"PtgMemErr",f:YZ},40:{n:"PtgMemNoMem",f:JZ},41:{n:"PtgMemFunc",f:VZ},42:{n:"PtgRefErr",f:GZ},43:{n:"PtgAreaErr",f:gZ},44:{n:"PtgRefN",f:CZ},45:{n:"PtgAreaN",f:xZ},46:{n:"PtgMemAreaN",f:mX},47:{n:"PtgMemNoMemN",f:hX},57:{n:"PtgNameX",f:WZ},58:{n:"PtgRef3d",f:TZ},59:{n:"PtgArea3d",f:pZ},60:{n:"PtgRefErr3d",f:KZ},61:{n:"PtgAreaErr3d",f:fZ},255:{}},gX={64:32,96:32,65:33,97:33,66:34,98:34,67:35,99:35,68:36,100:36,69:37,101:37,70:38,102:38,71:39,103:39,72:40,104:40,73:41,105:41,74:42,106:42,75:43,107:43,76:44,108:44,77:45,109:45,78:46,110:46,79:47,111:47,88:34,120:34,89:57,121:57,90:58,122:58,91:59,123:59,92:60,124:60,93:61,125:61},fX={1:{n:"PtgElfLel",f:pM},2:{n:"PtgElfRw",f:nX},3:{n:"PtgElfCol",f:XZ},6:{n:"PtgElfRwV",f:iX},7:{n:"PtgElfColV",f:tX},10:{n:"PtgElfRadical",f:rX},11:{n:"PtgElfRadicalS",f:sX},13:{n:"PtgElfColS",f:QZ},15:{n:"PtgElfColSV",f:eX},16:{n:"PtgElfRadicalLel",f:aX},25:{n:"PtgList",f:lX},29:{n:"PtgSxName",f:cX},255:{}},xX={0:{n:"PtgAttrNoop",f:pX},1:{n:"PtgAttrSemi",f:_Z},2:{n:"PtgAttrIf",f:wZ},4:{n:"PtgAttrChoose",f:bZ},8:{n:"PtgAttrGoto",f:vZ},16:{n:"PtgAttrSum",f:PZ},32:{n:"PtgAttrBaxcel",f:QE},33:{n:"PtgAttrBaxcel",f:QE},64:{n:"PtgAttrSpace",f:kZ},65:{n:"PtgAttrSpaceSemi",f:NZ},128:{n:"PtgAttrIfError",f:jZ},255:{}};function yX(e,r,a,s){if(s.biff<8)return zc(e,r);for(var n=e.l+r,i=[],o=0;o!==a.length;++o)switch(a[o][0]){case"PtgArray":a[o][1]=UZ(e,0,s),i.push(a[o][1]);break;case"PtgMemArea":a[o][2]=$Z(e,a[o][1],s),i.push(a[o][2]);break;case"PtgExp":s&&s.biff==12&&(a[o][1][1]=e.read_shift(4),i.push(a[o][1]));break;case"PtgList":case"PtgElfRadicalS":case"PtgElfColS":case"PtgElfColSV":throw"Unsupported "+a[o][0]}return r=n-e.l,r!==0&&i.push(zc(e,r)),i}function bX(e,r,a){for(var s=e.l+r,n,i,o=[];s!=e.l;)r=s-e.l,i=e[e.l],n=e7[i]||e7[gX[i]],(i===24||i===25)&&(n=(i===24?fX:xX)[e[e.l+1]]),!n||!n.f?zc(e,r):o.push([n.n,n.f(e,r,a)]);return o}function vX(e){for(var r=[],a=0;a<e.length;++a){for(var s=e[a],n=[],i=0;i<s.length;++i){var o=s[i];if(o)switch(o[0]){case 2:n.push('"'+o[1].replace(/"/g,'""')+'"');break;default:n.push(o[1])}else n.push("")}r.push(n.join(","))}return r.join(";")}var wX={PtgAdd:"+",PtgConcat:"&",PtgDiv:"/",PtgEq:"=",PtgGe:">=",PtgGt:">",PtgLe:"<=",PtgLt:"<",PtgMul:"*",PtgNe:"<>",PtgPower:"^",PtgSub:"-"};function jX(e,r){if(!e&&!(r&&r.biff<=5&&r.biff>=2))throw new Error("empty sheet name");return/[^\w\u4E00-\u9FFF\u3040-\u30FF]/.test(e)?"'"+e+"'":e}function gM(e,r,a){if(!e)return"SH33TJSERR0";if(a.biff>8&&(!e.XTI||!e.XTI[r]))return e.SheetNames[r];if(!e.XTI)return"SH33TJSERR6";var s=e.XTI[r];if(a.biff<8)return r>1e4&&(r-=65536),r<0&&(r=-r),r==0?"":e.XTI[r-1];if(!s)return"SH33TJSERR1";var n="";if(a.biff>8)switch(e[s[0]][0]){case 357:return n=s[1]==-1?"#REF":e.SheetNames[s[1]],s[1]==s[2]?n:n+":"+e.SheetNames[s[2]];case 358:return a.SID!=null?e.SheetNames[a.SID]:"SH33TJSSAME"+e[s[0]][0];case 355:default:return"SH33TJSSRC"+e[s[0]][0]}switch(e[s[0]][0][0]){case 1025:return n=s[1]==-1?"#REF":e.SheetNames[s[1]]||"SH33TJSERR3",s[1]==s[2]?n:n+":"+e.SheetNames[s[2]];case 14849:return e[s[0]].slice(1).map(function(i){return i.Name}).join(";;");default:return e[s[0]][0][3]?(n=s[1]==-1?"#REF":e[s[0]][0][3][s[1]]||"SH33TJSERR4",s[1]==s[2]?n:n+":"+e[s[0]][0][3][s[2]]):"SH33TJSERR2"}}function t7(e,r,a){var s=gM(e,r,a);return s=="#REF"?s:jX(s,a)}function kp(e,r,a,s,n){var i=n&&n.biff||8,o={s:{c:0,r:0}},l=[],c,u,h,f=0,y=0,b,w="";if(!e[0]||!e[0][0])return"";for(var v=-1,k="",S=0,N=e[0].length;S<N;++S){var C=e[0][S];switch(C[0]){case"PtgUminus":l.push("-"+l.pop());break;case"PtgUplus":l.push("+"+l.pop());break;case"PtgPercent":l.push(l.pop()+"%");break;case"PtgAdd":case"PtgConcat":case"PtgDiv":case"PtgEq":case"PtgGe":case"PtgGt":case"PtgLe":case"PtgLt":case"PtgMul":case"PtgNe":case"PtgPower":case"PtgSub":if(c=l.pop(),u=l.pop(),v>=0){switch(e[0][v][1][0]){case 0:k=Ws(" ",e[0][v][1][1]);break;case 1:k=Ws("\r",e[0][v][1][1]);break;default:if(k="",n.WTF)throw new Error("Unexpected PtgAttrSpaceType "+e[0][v][1][0])}u=u+k,v=-1}l.push(u+wX[C[0]]+c);break;case"PtgIsect":c=l.pop(),u=l.pop(),l.push(u+" "+c);break;case"PtgUnion":c=l.pop(),u=l.pop(),l.push(u+","+c);break;case"PtgRange":c=l.pop(),u=l.pop(),l.push(u+":"+c);break;case"PtgAttrChoose":break;case"PtgAttrGoto":break;case"PtgAttrIf":break;case"PtgAttrIfError":break;case"PtgRef":h=If(C[1][1],o,n),l.push(zf(h,i));break;case"PtgRefN":h=a?If(C[1][1],a,n):C[1][1],l.push(zf(h,i));break;case"PtgRef3d":f=C[1][1],h=If(C[1][2],o,n),w=t7(s,f,n),l.push(w+"!"+zf(h,i));break;case"PtgFunc":case"PtgFuncVar":var O=C[1][0],T=C[1][1];O||(O=0),O&=127;var P=O==0?[]:l.slice(-O);l.length-=O,T==="User"&&(T=P.shift()),l.push(T+"("+P.join(",")+")");break;case"PtgBool":l.push(C[1]?"TRUE":"FALSE");break;case"PtgInt":l.push(C[1]);break;case"PtgNum":l.push(String(C[1]));break;case"PtgStr":l.push('"'+C[1].replace(/"/g,'""')+'"');break;case"PtgErr":l.push(C[1]);break;case"PtgAreaN":b=zE(C[1][1],a?{s:a}:o,n),l.push(ok(b,n));break;case"PtgArea":b=zE(C[1][1],o,n),l.push(ok(b,n));break;case"PtgArea3d":f=C[1][1],b=C[1][2],w=t7(s,f,n),l.push(w+"!"+ok(b,n));break;case"PtgAttrSum":l.push("SUM("+l.pop()+")");break;case"PtgAttrBaxcel":case"PtgAttrSemi":break;case"PtgName":y=C[1][2];var E=(s.names||[])[y-1]||(s[0]||[])[y],R=E?E.Name:"SH33TJSNAME"+String(y);R&&R.slice(0,6)=="_xlfn."&&!n.xlfn&&(R=R.slice(6)),l.push(R);break;case"PtgNameX":var z=C[1][1];y=C[1][2];var G;if(n.biff<=5)z<0&&(z=-z),s[z]&&(G=s[z][y]);else{var ae="";if(((s[z]||[])[0]||[])[0]==14849||(((s[z]||[])[0]||[])[0]==1025?s[z][y]&&s[z][y].itab>0&&(ae=s.SheetNames[s[z][y].itab-1]+"!"):ae=s.SheetNames[y-1]+"!"),s[z]&&s[z][y])ae+=s[z][y].Name;else if(s[0]&&s[0][y])ae+=s[0][y].Name;else{var ee=(gM(s,z,n)||"").split(";;");ee[y-1]?ae=ee[y-1]:ae+="SH33TJSERRX"}l.push(ae);break}G||(G={Name:"SH33TJSERRY"}),l.push(G.Name);break;case"PtgParen":var ne="(",te=")";if(v>=0){switch(k="",e[0][v][1][0]){case 2:ne=Ws(" ",e[0][v][1][1])+ne;break;case 3:ne=Ws("\r",e[0][v][1][1])+ne;break;case 4:te=Ws(" ",e[0][v][1][1])+te;break;case 5:te=Ws("\r",e[0][v][1][1])+te;break;default:if(n.WTF)throw new Error("Unexpected PtgAttrSpaceType "+e[0][v][1][0])}v=-1}l.push(ne+l.pop()+te);break;case"PtgRefErr":l.push("#REF!");break;case"PtgRefErr3d":l.push("#REF!");break;case"PtgExp":h={c:C[1][1],r:C[1][0]};var Y={c:a.c,r:a.r};if(s.sharedf[Ya(h)]){var q=s.sharedf[Ya(h)];l.push(kp(q,o,Y,s,n))}else{var H=!1;for(c=0;c!=s.arrayf.length;++c)if(u=s.arrayf[c],!(h.c<u[0].s.c||h.c>u[0].e.c)&&!(h.r<u[0].s.r||h.r>u[0].e.r)){l.push(kp(u[1],o,Y,s,n)),H=!0;break}H||l.push(C[1])}break;case"PtgArray":l.push("{"+vX(C[1])+"}");break;case"PtgMemArea":break;case"PtgAttrSpace":case"PtgAttrSpaceSemi":v=S;break;case"PtgTbl":break;case"PtgMemErr":break;case"PtgMissArg":l.push("");break;case"PtgAreaErr":l.push("#REF!");break;case"PtgAreaErr3d":l.push("#REF!");break;case"PtgList":l.push("Table"+C[1].idx+"[#"+C[1].rt+"]");break;case"PtgMemAreaN":case"PtgMemNoMemN":case"PtgAttrNoop":case"PtgSheet":case"PtgEndSheet":break;case"PtgMemFunc":break;case"PtgMemNoMem":break;case"PtgElfCol":case"PtgElfColS":case"PtgElfColSV":case"PtgElfColV":case"PtgElfLel":case"PtgElfRadical":case"PtgElfRadicalLel":case"PtgElfRadicalS":case"PtgElfRw":case"PtgElfRwV":throw new Error("Unsupported ELFs");case"PtgSxName":throw new Error("Unrecognized Formula Token: "+String(C));default:throw new Error("Unrecognized Formula Token: "+String(C))}var U=["PtgAttrSpace","PtgAttrSpaceSemi","PtgAttrGoto"];if(n.biff!=3&&v>=0&&U.indexOf(e[0][S][0])==-1){C=e[0][v];var re=!0;switch(C[1][0]){case 4:re=!1;case 0:k=Ws(" ",C[1][1]);break;case 5:re=!1;case 1:k=Ws("\r",C[1][1]);break;default:if(k="",n.WTF)throw new Error("Unexpected PtgAttrSpaceType "+C[1][0])}l.push((re?k:"")+l.pop()+(re?"":k)),v=-1}}if(l.length>1&&n.WTF)throw new Error("bad formula stack");return l[0]}function _X(e){if(e==null){var r=Ft(8);return r.write_shift(1,3),r.write_shift(1,0),r.write_shift(2,0),r.write_shift(2,0),r.write_shift(2,65535),r}else if(typeof e=="number")return jm(e);return jm(0)}function kX(e,r,a,s,n){var i=_m(r,a,n),o=_X(e.v),l=Ft(6),c=33;l.write_shift(2,c),l.write_shift(4,0);for(var u=Ft(e.bf.length),h=0;h<e.bf.length;++h)u[h]=e.bf[h];var f=Qn([i,o,l,u]);return f}function Q1(e,r,a){var s=e.read_shift(4),n=bX(e,s,a),i=e.read_shift(4),o=i>0?yX(e,i,n,a):null;return[n,o]}var NX=Q1,ew=Q1,SX=Q1,CX=Q1,TX={0:"BEEP",1:"OPEN",2:"OPEN.LINKS",3:"CLOSE.ALL",4:"SAVE",5:"SAVE.AS",6:"FILE.DELETE",7:"PAGE.SETUP",8:"PRINT",9:"PRINTER.SETUP",10:"QUIT",11:"NEW.WINDOW",12:"ARRANGE.ALL",13:"WINDOW.SIZE",14:"WINDOW.MOVE",15:"FULL",16:"CLOSE",17:"RUN",22:"SET.PRINT.AREA",23:"SET.PRINT.TITLES",24:"SET.PAGE.BREAK",25:"REMOVE.PAGE.BREAK",26:"FONT",27:"DISPLAY",28:"PROTECT.DOCUMENT",29:"PRECISION",30:"A1.R1C1",31:"CALCULATE.NOW",32:"CALCULATION",34:"DATA.FIND",35:"EXTRACT",36:"DATA.DELETE",37:"SET.DATABASE",38:"SET.CRITERIA",39:"SORT",40:"DATA.SERIES",41:"TABLE",42:"FORMAT.NUMBER",43:"ALIGNMENT",44:"STYLE",45:"BORDER",46:"CELL.PROTECTION",47:"COLUMN.WIDTH",48:"UNDO",49:"CUT",50:"COPY",51:"PASTE",52:"CLEAR",53:"PASTE.SPECIAL",54:"EDIT.DELETE",55:"INSERT",56:"FILL.RIGHT",57:"FILL.DOWN",61:"DEFINE.NAME",62:"CREATE.NAMES",63:"FORMULA.GOTO",64:"FORMULA.FIND",65:"SELECT.LAST.CELL",66:"SHOW.ACTIVE.CELL",67:"GALLERY.AREA",68:"GALLERY.BAR",69:"GALLERY.COLUMN",70:"GALLERY.LINE",71:"GALLERY.PIE",72:"GALLERY.SCATTER",73:"COMBINATION",74:"PREFERRED",75:"ADD.OVERLAY",76:"GRIDLINES",77:"SET.PREFERRED",78:"AXES",79:"LEGEND",80:"ATTACH.TEXT",81:"ADD.ARROW",82:"SELECT.CHART",83:"SELECT.PLOT.AREA",84:"PATTERNS",85:"MAIN.CHART",86:"OVERLAY",87:"SCALE",88:"FORMAT.LEGEND",89:"FORMAT.TEXT",90:"EDIT.REPEAT",91:"PARSE",92:"JUSTIFY",93:"HIDE",94:"UNHIDE",95:"WORKSPACE",96:"FORMULA",97:"FORMULA.FILL",98:"FORMULA.ARRAY",99:"DATA.FIND.NEXT",100:"DATA.FIND.PREV",101:"FORMULA.FIND.NEXT",102:"FORMULA.FIND.PREV",103:"ACTIVATE",104:"ACTIVATE.NEXT",105:"ACTIVATE.PREV",106:"UNLOCKED.NEXT",107:"UNLOCKED.PREV",108:"COPY.PICTURE",109:"SELECT",110:"DELETE.NAME",111:"DELETE.FORMAT",112:"VLINE",113:"HLINE",114:"VPAGE",115:"HPAGE",116:"VSCROLL",117:"HSCROLL",118:"ALERT",119:"NEW",120:"CANCEL.COPY",121:"SHOW.CLIPBOARD",122:"MESSAGE",124:"PASTE.LINK",125:"APP.ACTIVATE",126:"DELETE.ARROW",127:"ROW.HEIGHT",128:"FORMAT.MOVE",129:"FORMAT.SIZE",130:"FORMULA.REPLACE",131:"SEND.KEYS",132:"SELECT.SPECIAL",133:"APPLY.NAMES",134:"REPLACE.FONT",135:"FREEZE.PANES",136:"SHOW.INFO",137:"SPLIT",138:"ON.WINDOW",139:"ON.DATA",140:"DISABLE.INPUT",142:"OUTLINE",143:"LIST.NAMES",144:"FILE.CLOSE",145:"SAVE.WORKBOOK",146:"DATA.FORM",147:"COPY.CHART",148:"ON.TIME",149:"WAIT",150:"FORMAT.FONT",151:"FILL.UP",152:"FILL.LEFT",153:"DELETE.OVERLAY",155:"SHORT.MENUS",159:"SET.UPDATE.STATUS",161:"COLOR.PALETTE",162:"DELETE.STYLE",163:"WINDOW.RESTORE",164:"WINDOW.MAXIMIZE",166:"CHANGE.LINK",167:"CALCULATE.DOCUMENT",168:"ON.KEY",169:"APP.RESTORE",170:"APP.MOVE",171:"APP.SIZE",172:"APP.MINIMIZE",173:"APP.MAXIMIZE",174:"BRING.TO.FRONT",175:"SEND.TO.BACK",185:"MAIN.CHART.TYPE",186:"OVERLAY.CHART.TYPE",187:"SELECT.END",188:"OPEN.MAIL",189:"SEND.MAIL",190:"STANDARD.FONT",191:"CONSOLIDATE",192:"SORT.SPECIAL",193:"GALLERY.3D.AREA",194:"GALLERY.3D.COLUMN",195:"GALLERY.3D.LINE",196:"GALLERY.3D.PIE",197:"VIEW.3D",198:"GOAL.SEEK",199:"WORKGROUP",200:"FILL.GROUP",201:"UPDATE.LINK",202:"PROMOTE",203:"DEMOTE",204:"SHOW.DETAIL",206:"UNGROUP",207:"OBJECT.PROPERTIES",208:"SAVE.NEW.OBJECT",209:"SHARE",210:"SHARE.NAME",211:"DUPLICATE",212:"APPLY.STYLE",213:"ASSIGN.TO.OBJECT",214:"OBJECT.PROTECTION",215:"HIDE.OBJECT",216:"SET.EXTRACT",217:"CREATE.PUBLISHER",218:"SUBSCRIBE.TO",219:"ATTRIBUTES",220:"SHOW.TOOLBAR",222:"PRINT.PREVIEW",223:"EDIT.COLOR",224:"SHOW.LEVELS",225:"FORMAT.MAIN",226:"FORMAT.OVERLAY",227:"ON.RECALC",228:"EDIT.SERIES",229:"DEFINE.STYLE",240:"LINE.PRINT",243:"ENTER.DATA",249:"GALLERY.RADAR",250:"MERGE.STYLES",251:"EDITION.OPTIONS",252:"PASTE.PICTURE",253:"PASTE.PICTURE.LINK",254:"SPELLING",256:"ZOOM",259:"INSERT.OBJECT",260:"WINDOW.MINIMIZE",265:"SOUND.NOTE",266:"SOUND.PLAY",267:"FORMAT.SHAPE",268:"EXTEND.POLYGON",269:"FORMAT.AUTO",272:"GALLERY.3D.BAR",273:"GALLERY.3D.SURFACE",274:"FILL.AUTO",276:"CUSTOMIZE.TOOLBAR",277:"ADD.TOOL",278:"EDIT.OBJECT",279:"ON.DOUBLECLICK",280:"ON.ENTRY",281:"WORKBOOK.ADD",282:"WORKBOOK.MOVE",283:"WORKBOOK.COPY",284:"WORKBOOK.OPTIONS",285:"SAVE.WORKSPACE",288:"CHART.WIZARD",289:"DELETE.TOOL",290:"MOVE.TOOL",291:"WORKBOOK.SELECT",292:"WORKBOOK.ACTIVATE",293:"ASSIGN.TO.TOOL",295:"COPY.TOOL",296:"RESET.TOOL",297:"CONSTRAIN.NUMERIC",298:"PASTE.TOOL",302:"WORKBOOK.NEW",305:"SCENARIO.CELLS",306:"SCENARIO.DELETE",307:"SCENARIO.ADD",308:"SCENARIO.EDIT",309:"SCENARIO.SHOW",310:"SCENARIO.SHOW.NEXT",311:"SCENARIO.SUMMARY",312:"PIVOT.TABLE.WIZARD",313:"PIVOT.FIELD.PROPERTIES",314:"PIVOT.FIELD",315:"PIVOT.ITEM",316:"PIVOT.ADD.FIELDS",318:"OPTIONS.CALCULATION",319:"OPTIONS.EDIT",320:"OPTIONS.VIEW",321:"ADDIN.MANAGER",322:"MENU.EDITOR",323:"ATTACH.TOOLBARS",324:"VBAActivate",325:"OPTIONS.CHART",328:"VBA.INSERT.FILE",330:"VBA.PROCEDURE.DEFINITION",336:"ROUTING.SLIP",338:"ROUTE.DOCUMENT",339:"MAIL.LOGON",342:"INSERT.PICTURE",343:"EDIT.TOOL",344:"GALLERY.DOUGHNUT",350:"CHART.TREND",352:"PIVOT.ITEM.PROPERTIES",354:"WORKBOOK.INSERT",355:"OPTIONS.TRANSITION",356:"OPTIONS.GENERAL",370:"FILTER.ADVANCED",373:"MAIL.ADD.MAILER",374:"MAIL.DELETE.MAILER",375:"MAIL.REPLY",376:"MAIL.REPLY.ALL",377:"MAIL.FORWARD",378:"MAIL.NEXT.LETTER",379:"DATA.LABEL",380:"INSERT.TITLE",381:"FONT.PROPERTIES",382:"MACRO.OPTIONS",383:"WORKBOOK.HIDE",384:"WORKBOOK.UNHIDE",385:"WORKBOOK.DELETE",386:"WORKBOOK.NAME",388:"GALLERY.CUSTOM",390:"ADD.CHART.AUTOFORMAT",391:"DELETE.CHART.AUTOFORMAT",392:"CHART.ADD.DATA",393:"AUTO.OUTLINE",394:"TAB.ORDER",395:"SHOW.DIALOG",396:"SELECT.ALL",397:"UNGROUP.SHEETS",398:"SUBTOTAL.CREATE",399:"SUBTOTAL.REMOVE",400:"RENAME.OBJECT",412:"WORKBOOK.SCROLL",413:"WORKBOOK.NEXT",414:"WORKBOOK.PREV",415:"WORKBOOK.TAB.SPLIT",416:"FULL.SCREEN",417:"WORKBOOK.PROTECT",420:"SCROLLBAR.PROPERTIES",421:"PIVOT.SHOW.PAGES",422:"TEXT.TO.COLUMNS",423:"FORMAT.CHARTTYPE",424:"LINK.FORMAT",425:"TRACER.DISPLAY",430:"TRACER.NAVIGATE",431:"TRACER.CLEAR",432:"TRACER.ERROR",433:"PIVOT.FIELD.GROUP",434:"PIVOT.FIELD.UNGROUP",435:"CHECKBOX.PROPERTIES",436:"LABEL.PROPERTIES",437:"LISTBOX.PROPERTIES",438:"EDITBOX.PROPERTIES",439:"PIVOT.REFRESH",440:"LINK.COMBO",441:"OPEN.TEXT",442:"HIDE.DIALOG",443:"SET.DIALOG.FOCUS",444:"ENABLE.OBJECT",445:"PUSHBUTTON.PROPERTIES",446:"SET.DIALOG.DEFAULT",447:"FILTER",448:"FILTER.SHOW.ALL",449:"CLEAR.OUTLINE",450:"FUNCTION.WIZARD",451:"ADD.LIST.ITEM",452:"SET.LIST.ITEM",453:"REMOVE.LIST.ITEM",454:"SELECT.LIST.ITEM",455:"SET.CONTROL.VALUE",456:"SAVE.COPY.AS",458:"OPTIONS.LISTS.ADD",459:"OPTIONS.LISTS.DELETE",460:"SERIES.AXES",461:"SERIES.X",462:"SERIES.Y",463:"ERRORBAR.X",464:"ERRORBAR.Y",465:"FORMAT.CHART",466:"SERIES.ORDER",467:"MAIL.LOGOFF",468:"CLEAR.ROUTING.SLIP",469:"APP.ACTIVATE.MICROSOFT",470:"MAIL.EDIT.MAILER",471:"ON.SHEET",472:"STANDARD.WIDTH",473:"SCENARIO.MERGE",474:"SUMMARY.INFO",475:"FIND.FILE",476:"ACTIVE.CELL.FONT",477:"ENABLE.TIPWIZARD",478:"VBA.MAKE.ADDIN",480:"INSERTDATATABLE",481:"WORKGROUP.OPTIONS",482:"MAIL.SEND.MAILER",485:"AUTOCORRECT",489:"POST.DOCUMENT",491:"PICKLIST",493:"VIEW.SHOW",494:"VIEW.DEFINE",495:"VIEW.DELETE",509:"SHEET.BACKGROUND",510:"INSERT.MAP.OBJECT",511:"OPTIONS.MENONO",517:"MSOCHECKS",518:"NORMAL",519:"LAYOUT",520:"RM.PRINT.AREA",521:"CLEAR.PRINT.AREA",522:"ADD.PRINT.AREA",523:"MOVE.BRK",545:"HIDECURR.NOTE",546:"HIDEALL.NOTES",547:"DELETE.NOTE",548:"TRAVERSE.NOTES",549:"ACTIVATE.NOTES",620:"PROTECT.REVISIONS",621:"UNPROTECT.REVISIONS",647:"OPTIONS.ME",653:"WEB.PUBLISH",667:"NEWWEBQUERY",673:"PIVOT.TABLE.CHART",753:"OPTIONS.SAVE",755:"OPTIONS.SPELL",808:"HIDEALL.INKANNOTS"},fM={0:"COUNT",1:"IF",2:"ISNA",3:"ISERROR",4:"SUM",5:"AVERAGE",6:"MIN",7:"MAX",8:"ROW",9:"COLUMN",10:"NA",11:"NPV",12:"STDEV",13:"DOLLAR",14:"FIXED",15:"SIN",16:"COS",17:"TAN",18:"ATAN",19:"PI",20:"SQRT",21:"EXP",22:"LN",23:"LOG10",24:"ABS",25:"INT",26:"SIGN",27:"ROUND",28:"LOOKUP",29:"INDEX",30:"REPT",31:"MID",32:"LEN",33:"VALUE",34:"TRUE",35:"FALSE",36:"AND",37:"OR",38:"NOT",39:"MOD",40:"DCOUNT",41:"DSUM",42:"DAVERAGE",43:"DMIN",44:"DMAX",45:"DSTDEV",46:"VAR",47:"DVAR",48:"TEXT",49:"LINEST",50:"TREND",51:"LOGEST",52:"GROWTH",53:"GOTO",54:"HALT",55:"RETURN",56:"PV",57:"FV",58:"NPER",59:"PMT",60:"RATE",61:"MIRR",62:"IRR",63:"RAND",64:"MATCH",65:"DATE",66:"TIME",67:"DAY",68:"MONTH",69:"YEAR",70:"WEEKDAY",71:"HOUR",72:"MINUTE",73:"SECOND",74:"NOW",75:"AREAS",76:"ROWS",77:"COLUMNS",78:"OFFSET",79:"ABSREF",80:"RELREF",81:"ARGUMENT",82:"SEARCH",83:"TRANSPOSE",84:"ERROR",85:"STEP",86:"TYPE",87:"ECHO",88:"SET.NAME",89:"CALLER",90:"DEREF",91:"WINDOWS",92:"SERIES",93:"DOCUMENTS",94:"ACTIVE.CELL",95:"SELECTION",96:"RESULT",97:"ATAN2",98:"ASIN",99:"ACOS",100:"CHOOSE",101:"HLOOKUP",102:"VLOOKUP",103:"LINKS",104:"INPUT",105:"ISREF",106:"GET.FORMULA",107:"GET.NAME",108:"SET.VALUE",109:"LOG",110:"EXEC",111:"CHAR",112:"LOWER",113:"UPPER",114:"PROPER",115:"LEFT",116:"RIGHT",117:"EXACT",118:"TRIM",119:"REPLACE",120:"SUBSTITUTE",121:"CODE",122:"NAMES",123:"DIRECTORY",124:"FIND",125:"CELL",126:"ISERR",127:"ISTEXT",128:"ISNUMBER",129:"ISBLANK",130:"T",131:"N",132:"FOPEN",133:"FCLOSE",134:"FSIZE",135:"FREADLN",136:"FREAD",137:"FWRITELN",138:"FWRITE",139:"FPOS",140:"DATEVALUE",141:"TIMEVALUE",142:"SLN",143:"SYD",144:"DDB",145:"GET.DEF",146:"REFTEXT",147:"TEXTREF",148:"INDIRECT",149:"REGISTER",150:"CALL",151:"ADD.BAR",152:"ADD.MENU",153:"ADD.COMMAND",154:"ENABLE.COMMAND",155:"CHECK.COMMAND",156:"RENAME.COMMAND",157:"SHOW.BAR",158:"DELETE.MENU",159:"DELETE.COMMAND",160:"GET.CHART.ITEM",161:"DIALOG.BOX",162:"CLEAN",163:"MDETERM",164:"MINVERSE",165:"MMULT",166:"FILES",167:"IPMT",168:"PPMT",169:"COUNTA",170:"CANCEL.KEY",171:"FOR",172:"WHILE",173:"BREAK",174:"NEXT",175:"INITIATE",176:"REQUEST",177:"POKE",178:"EXECUTE",179:"TERMINATE",180:"RESTART",181:"HELP",182:"GET.BAR",183:"PRODUCT",184:"FACT",185:"GET.CELL",186:"GET.WORKSPACE",187:"GET.WINDOW",188:"GET.DOCUMENT",189:"DPRODUCT",190:"ISNONTEXT",191:"GET.NOTE",192:"NOTE",193:"STDEVP",194:"VARP",195:"DSTDEVP",196:"DVARP",197:"TRUNC",198:"ISLOGICAL",199:"DCOUNTA",200:"DELETE.BAR",201:"UNREGISTER",204:"USDOLLAR",205:"FINDB",206:"SEARCHB",207:"REPLACEB",208:"LEFTB",209:"RIGHTB",210:"MIDB",211:"LENB",212:"ROUNDUP",213:"ROUNDDOWN",214:"ASC",215:"DBCS",216:"RANK",219:"ADDRESS",220:"DAYS360",221:"TODAY",222:"VDB",223:"ELSE",224:"ELSE.IF",225:"END.IF",226:"FOR.CELL",227:"MEDIAN",228:"SUMPRODUCT",229:"SINH",230:"COSH",231:"TANH",232:"ASINH",233:"ACOSH",234:"ATANH",235:"DGET",236:"CREATE.OBJECT",237:"VOLATILE",238:"LAST.ERROR",239:"CUSTOM.UNDO",240:"CUSTOM.REPEAT",241:"FORMULA.CONVERT",242:"GET.LINK.INFO",243:"TEXT.BOX",244:"INFO",245:"GROUP",246:"GET.OBJECT",247:"DB",248:"PAUSE",251:"RESUME",252:"FREQUENCY",253:"ADD.TOOLBAR",254:"DELETE.TOOLBAR",255:"User",256:"RESET.TOOLBAR",257:"EVALUATE",258:"GET.TOOLBAR",259:"GET.TOOL",260:"SPELLING.CHECK",261:"ERROR.TYPE",262:"APP.TITLE",263:"WINDOW.TITLE",264:"SAVE.TOOLBAR",265:"ENABLE.TOOL",266:"PRESS.TOOL",267:"REGISTER.ID",268:"GET.WORKBOOK",269:"AVEDEV",270:"BETADIST",271:"GAMMALN",272:"BETAINV",273:"BINOMDIST",274:"CHIDIST",275:"CHIINV",276:"COMBIN",277:"CONFIDENCE",278:"CRITBINOM",279:"EVEN",280:"EXPONDIST",281:"FDIST",282:"FINV",283:"FISHER",284:"FISHERINV",285:"FLOOR",286:"GAMMADIST",287:"GAMMAINV",288:"CEILING",289:"HYPGEOMDIST",290:"LOGNORMDIST",291:"LOGINV",292:"NEGBINOMDIST",293:"NORMDIST",294:"NORMSDIST",295:"NORMINV",296:"NORMSINV",297:"STANDARDIZE",298:"ODD",299:"PERMUT",300:"POISSON",301:"TDIST",302:"WEIBULL",303:"SUMXMY2",304:"SUMX2MY2",305:"SUMX2PY2",306:"CHITEST",307:"CORREL",308:"COVAR",309:"FORECAST",310:"FTEST",311:"INTERCEPT",312:"PEARSON",313:"RSQ",314:"STEYX",315:"SLOPE",316:"TTEST",317:"PROB",318:"DEVSQ",319:"GEOMEAN",320:"HARMEAN",321:"SUMSQ",322:"KURT",323:"SKEW",324:"ZTEST",325:"LARGE",326:"SMALL",327:"QUARTILE",328:"PERCENTILE",329:"PERCENTRANK",330:"MODE",331:"TRIMMEAN",332:"TINV",334:"MOVIE.COMMAND",335:"GET.MOVIE",336:"CONCATENATE",337:"POWER",338:"PIVOT.ADD.DATA",339:"GET.PIVOT.TABLE",340:"GET.PIVOT.FIELD",341:"GET.PIVOT.ITEM",342:"RADIANS",343:"DEGREES",344:"SUBTOTAL",345:"SUMIF",346:"COUNTIF",347:"COUNTBLANK",348:"SCENARIO.GET",349:"OPTIONS.LISTS.GET",350:"ISPMT",351:"DATEDIF",352:"DATESTRING",353:"NUMBERSTRING",354:"ROMAN",355:"OPEN.DIALOG",356:"SAVE.DIALOG",357:"VIEW.GET",358:"GETPIVOTDATA",359:"HYPERLINK",360:"PHONETIC",361:"AVERAGEA",362:"MAXA",363:"MINA",364:"STDEVPA",365:"VARPA",366:"STDEVA",367:"VARA",368:"BAHTTEXT",369:"THAIDAYOFWEEK",370:"THAIDIGIT",371:"THAIMONTHOFYEAR",372:"THAINUMSOUND",373:"THAINUMSTRING",374:"THAISTRINGLENGTH",375:"ISTHAIDIGIT",376:"ROUNDBAHTDOWN",377:"ROUNDBAHTUP",378:"THAIYEAR",379:"RTD",380:"CUBEVALUE",381:"CUBEMEMBER",382:"CUBEMEMBERPROPERTY",383:"CUBERANKEDMEMBER",384:"HEX2BIN",385:"HEX2DEC",386:"HEX2OCT",387:"DEC2BIN",388:"DEC2HEX",389:"DEC2OCT",390:"OCT2BIN",391:"OCT2HEX",392:"OCT2DEC",393:"BIN2DEC",394:"BIN2OCT",395:"BIN2HEX",396:"IMSUB",397:"IMDIV",398:"IMPOWER",399:"IMABS",400:"IMSQRT",401:"IMLN",402:"IMLOG2",403:"IMLOG10",404:"IMSIN",405:"IMCOS",406:"IMEXP",407:"IMARGUMENT",408:"IMCONJUGATE",409:"IMAGINARY",410:"IMREAL",411:"COMPLEX",412:"IMSUM",413:"IMPRODUCT",414:"SERIESSUM",415:"FACTDOUBLE",416:"SQRTPI",417:"QUOTIENT",418:"DELTA",419:"GESTEP",420:"ISEVEN",421:"ISODD",422:"MROUND",423:"ERF",424:"ERFC",425:"BESSELJ",426:"BESSELK",427:"BESSELY",428:"BESSELI",429:"XIRR",430:"XNPV",431:"PRICEMAT",432:"YIELDMAT",433:"INTRATE",434:"RECEIVED",435:"DISC",436:"PRICEDISC",437:"YIELDDISC",438:"TBILLEQ",439:"TBILLPRICE",440:"TBILLYIELD",441:"PRICE",442:"YIELD",443:"DOLLARDE",444:"DOLLARFR",445:"NOMINAL",446:"EFFECT",447:"CUMPRINC",448:"CUMIPMT",449:"EDATE",450:"EOMONTH",451:"YEARFRAC",452:"COUPDAYBS",453:"COUPDAYS",454:"COUPDAYSNC",455:"COUPNCD",456:"COUPNUM",457:"COUPPCD",458:"DURATION",459:"MDURATION",460:"ODDLPRICE",461:"ODDLYIELD",462:"ODDFPRICE",463:"ODDFYIELD",464:"RANDBETWEEN",465:"WEEKNUM",466:"AMORDEGRC",467:"AMORLINC",468:"CONVERT",724:"SHEETJS",469:"ACCRINT",470:"ACCRINTM",471:"WORKDAY",472:"NETWORKDAYS",473:"GCD",474:"MULTINOMIAL",475:"LCM",476:"FVSCHEDULE",477:"CUBEKPIMEMBER",478:"CUBESET",479:"CUBESETCOUNT",480:"IFERROR",481:"COUNTIFS",482:"SUMIFS",483:"AVERAGEIF",484:"AVERAGEIFS"},EX={2:1,3:1,10:0,15:1,16:1,17:1,18:1,19:0,20:1,21:1,22:1,23:1,24:1,25:1,26:1,27:2,30:2,31:3,32:1,33:1,34:0,35:0,38:1,39:2,40:3,41:3,42:3,43:3,44:3,45:3,47:3,48:2,53:1,61:3,63:0,65:3,66:3,67:1,68:1,69:1,70:1,71:1,72:1,73:1,74:0,75:1,76:1,77:1,79:2,80:2,83:1,85:0,86:1,89:0,90:1,94:0,95:0,97:2,98:1,99:1,101:3,102:3,105:1,106:1,108:2,111:1,112:1,113:1,114:1,117:2,118:1,119:4,121:1,126:1,127:1,128:1,129:1,130:1,131:1,133:1,134:1,135:1,136:2,137:2,138:2,140:1,141:1,142:3,143:4,144:4,161:1,162:1,163:1,164:1,165:2,172:1,175:2,176:2,177:3,178:2,179:1,184:1,186:1,189:3,190:1,195:3,196:3,197:1,198:1,199:3,201:1,207:4,210:3,211:1,212:2,213:2,214:1,215:1,225:0,229:1,230:1,231:1,232:1,233:1,234:1,235:3,244:1,247:4,252:2,257:1,261:1,271:1,273:4,274:2,275:2,276:2,277:3,278:3,279:1,280:3,281:3,282:3,283:1,284:1,285:2,286:4,287:3,288:2,289:4,290:3,291:3,292:3,293:4,294:1,295:3,296:1,297:3,298:1,299:2,300:3,301:3,302:4,303:2,304:2,305:2,306:2,307:2,308:2,309:3,310:2,311:2,312:2,313:2,314:2,315:2,316:4,325:2,326:2,327:2,328:2,331:2,332:2,337:2,342:1,343:1,346:2,347:1,350:4,351:3,352:1,353:2,360:1,368:1,369:1,370:1,371:1,372:1,373:1,374:1,375:1,376:1,377:1,378:1,382:3,385:1,392:1,393:1,396:2,397:2,398:2,399:1,400:1,401:1,402:1,403:1,404:1,405:1,406:1,407:1,408:1,409:1,410:1,414:4,415:1,416:1,417:2,420:1,421:1,422:2,424:1,425:2,426:2,427:2,428:2,430:3,438:3,439:3,440:3,443:2,444:2,445:2,446:2,447:6,448:6,449:2,450:2,464:2,468:3,476:2,479:1,480:2,65535:0};function AX(e){var r="of:="+e.replace(fS,"$1[.$2$3$4$5]").replace(/\]:\[/g,":");return r.replace(/;/g,"|").replace(/,/g,";")}function OX(e){return e.replace(/\./,"!")}var $f=typeof Map!="undefined";function bS(e,r,a){var s=0,n=e.length;if(a){if($f?a.has(r):Object.prototype.hasOwnProperty.call(a,r)){for(var i=$f?a.get(r):a[r];s<i.length;++s)if(e[i[s]].t===r)return e.Count++,i[s]}}else for(;s<n;++s)if(e[s].t===r)return e.Count++,s;return e[n]={t:r},e.Count++,e.Unique++,a&&($f?(a.has(r)||a.set(r,[]),a.get(r).push(n)):(Object.prototype.hasOwnProperty.call(a,r)||(a[r]=[]),a[r].push(n))),n}function tw(e,r){var a={min:e+1,max:e+1},s=-1;return r.MDW&&(Wd=r.MDW),r.width!=null?a.customWidth=1:r.wpx!=null?s=Bv(r.wpx):r.wch!=null&&(s=r.wch),s>-1?(a.width=SN(s),a.customWidth=1):r.width!=null&&(a.width=r.width),r.hidden&&(a.hidden=!0),r.level!=null&&(a.outlineLevel=a.level=r.level),a}function xM(e,r){if(e){var a=[.7,.7,.75,.75,.3,.3];e.left==null&&(e.left=a[0]),e.right==null&&(e.right=a[1]),e.top==null&&(e.top=a[2]),e.bottom==null&&(e.bottom=a[3]),e.header==null&&(e.header=a[4]),e.footer==null&&(e.footer=a[5])}}function s0(e,r,a){var s=a.revssf[r.z!=null?r.z:"General"],n=60,i=e.length;if(s==null&&a.ssf){for(;n<392;++n)if(a.ssf[n]==null){mR(r.z,n),a.ssf[n]=r.z,a.revssf[r.z]=s=n;break}}for(n=0;n!=i;++n)if(e[n].numFmtId===s)return n;return e[i]={numFmtId:s,fontId:0,fillId:0,borderId:0,xfId:0,applyNumberFormat:1},i}function PX(e,r,a){if(e&&e["!ref"]){var s=vs(e["!ref"]);if(s.e.c<s.s.c||s.e.r<s.s.r)throw new Error("Bad range ("+a+"): "+e["!ref"])}}function DX(e){if(e.length===0)return"";for(var r='<mergeCells count="'+e.length+'">',a=0;a!=e.length;++a)r+='<mergeCell ref="'+ln(e[a])+'"/>';return r+"</mergeCells>"}function RX(e,r,a,s,n){var i=!1,o={},l=null;if(s.bookType!=="xlsx"&&r.vbaraw){var c=r.SheetNames[a];try{r.Workbook&&(c=r.Workbook.Sheets[a].CodeName||c)}catch(h){}i=!0,o.codeName=Zf(Ka(c))}if(e&&e["!outline"]){var u={summaryBelow:1,summaryRight:1};e["!outline"].above&&(u.summaryBelow=0),e["!outline"].left&&(u.summaryRight=0),l=(l||"")+ir("outlinePr",null,u)}!i&&!l||(n[n.length]=ir("sheetPr",l,o))}var MX=["objects","scenarios","selectLockedCells","selectUnlockedCells"],LX=["formatColumns","formatRows","formatCells","insertColumns","insertRows","insertHyperlinks","deleteColumns","deleteRows","sort","autoFilter","pivotTables"];function FX(e){var r={sheet:1};return MX.forEach(function(a){e[a]!=null&&e[a]&&(r[a]="1")}),LX.forEach(function(a){e[a]!=null&&!e[a]&&(r[a]="0")}),e.password&&(r.password=eM(e.password).toString(16).toUpperCase()),ir("sheetProtection",null,r)}function IX(e){return xM(e),ir("pageMargins",null,e)}function zX(e,r){for(var a=["<cols>"],s,n=0;n!=r.length;++n)(s=r[n])&&(a[a.length]=ir("col",null,tw(n,s)));return a[a.length]="</cols>",a.join("")}function $X(e,r,a,s){var n=typeof e.ref=="string"?e.ref:ln(e.ref);a.Workbook||(a.Workbook={Sheets:[]}),a.Workbook.Names||(a.Workbook.Names=[]);var i=a.Workbook.Names,o=Wo(n);o.s.r==o.e.r&&(o.e.r=Wo(r["!ref"]).e.r,n=ln(o));for(var l=0;l<i.length;++l){var c=i[l];if(c.Name=="_xlnm._FilterDatabase"&&c.Sheet==s){c.Ref="'"+a.SheetNames[s]+"'!"+n;break}}return l==i.length&&i.push({Name:"_xlnm._FilterDatabase",Sheet:s,Ref:"'"+a.SheetNames[s]+"'!"+n}),ir("autoFilter",null,{ref:n})}function UX(e,r,a,s){var n={workbookViewId:"0"};return(((s||{}).Workbook||{}).Views||[])[0]&&(n.rightToLeft=s.Workbook.Views[0].RTL?"1":"0"),ir("sheetViews",ir("sheetView",null,n),{})}function BX(e,r,a,s){if(e.c&&a["!comments"].push([r,e.c]),e.v===void 0&&typeof e.f!="string"||e.t==="z"&&!e.f)return"";var n="",i=e.t,o=e.v;if(e.t!=="z")switch(e.t){case"b":n=e.v?"1":"0";break;case"n":n=""+e.v;break;case"e":n=Cx[e.v];break;case"d":s&&s.cellDates?n=Mi(e.v,-1).toISOString():(e=uo(e),e.t="n",n=""+(e.v=co(Mi(e.v)))),typeof e.z=="undefined"&&(e.z=Hs[14]);break;default:n=e.v;break}var l=ei("v",Ka(n)),c={r},u=s0(s.cellXfs,e,s);switch(u!==0&&(c.s=u),e.t){case"n":break;case"d":c.t="d";break;case"b":c.t="b";break;case"e":c.t="e";break;case"z":break;default:if(e.v==null){delete e.t;break}if(e.v.length>32767)throw new Error("Text length must not exceed 32767 characters");if(s&&s.bookSST){l=ei("v",""+bS(s.Strings,e.v,s.revStrings)),c.t="s";break}c.t="str";break}if(e.t!=i&&(e.t=i,e.v=o),typeof e.f=="string"&&e.f){var h=e.F&&e.F.slice(0,r.length)==r?{t:"array",ref:e.F}:null;l=ir("f",Ka(e.f),h)+(e.v!=null?l:"")}return e.l&&a["!links"].push([r,e.l]),e.D&&(c.cm=1),ir("c",l,c)}function WX(e,r,a,s){var n=[],i=[],o=vs(e["!ref"]),l="",c,u="",h=[],f=0,y=0,b=e["!rows"],w=Array.isArray(e),v={r:u},k,S=-1;for(y=o.s.c;y<=o.e.c;++y)h[y]=gi(y);for(f=o.s.r;f<=o.e.r;++f){for(i=[],u=ai(f),y=o.s.c;y<=o.e.c;++y){c=h[y]+u;var N=w?(e[f]||[])[y]:e[c];N!==void 0&&(l=BX(N,c,e,r))!=null&&i.push(l)}(i.length>0||b&&b[f])&&(v={r:u},b&&b[f]&&(k=b[f],k.hidden&&(v.hidden=1),S=-1,k.hpx?S=Wv(k.hpx):k.hpt&&(S=k.hpt),S>-1&&(v.ht=S,v.customHeight=1),k.level&&(v.outlineLevel=k.level)),n[n.length]=ir("row",i.join(""),v))}if(b)for(;f<b.length;++f)b&&b[f]&&(v={r:f+1},k=b[f],k.hidden&&(v.hidden=1),S=-1,k.hpx?S=Wv(k.hpx):k.hpt&&(S=k.hpt),S>-1&&(v.ht=S,v.customHeight=1),k.level&&(v.outlineLevel=k.level),n[n.length]=ir("row","",v));return n.join("")}function yM(e,r,a,s){var n=[mn,ir("worksheet",null,{xmlns:Bp[0],"xmlns:r":Dn.r})],i=a.SheetNames[e],o=0,l="",c=a.Sheets[i];c==null&&(c={});var u=c["!ref"]||"A1",h=vs(u);if(h.e.c>16383||h.e.r>1048575){if(r.WTF)throw new Error("Range "+u+" exceeds format limit A1:XFD1048576");h.e.c=Math.min(h.e.c,16383),h.e.r=Math.min(h.e.c,1048575),u=ln(h)}s||(s={}),c["!comments"]=[];var f=[];RX(c,a,e,r,n),n[n.length]=ir("dimension",null,{ref:u}),n[n.length]=UX(c,r,e,a),r.sheetFormat&&(n[n.length]=ir("sheetFormatPr",null,{defaultRowHeight:r.sheetFormat.defaultRowHeight||"16",baseColWidth:r.sheetFormat.baseColWidth||"10",outlineLevelRow:r.sheetFormat.outlineLevelRow||"7"})),c["!cols"]!=null&&c["!cols"].length>0&&(n[n.length]=zX(c,c["!cols"])),n[o=n.length]="<sheetData/>",c["!links"]=[],c["!ref"]!=null&&(l=WX(c,r),l.length>0&&(n[n.length]=l)),n.length>o+1&&(n[n.length]="</sheetData>",n[o]=n[o].replace("/>",">")),c["!protect"]&&(n[n.length]=FX(c["!protect"])),c["!autofilter"]!=null&&(n[n.length]=$X(c["!autofilter"],c,a,e)),c["!merges"]!=null&&c["!merges"].length>0&&(n[n.length]=DX(c["!merges"]));var y=-1,b,w=-1;return c["!links"].length>0&&(n[n.length]="<hyperlinks>",c["!links"].forEach(function(v){v[1].Target&&(b={ref:v[0]},v[1].Target.charAt(0)!="#"&&(w=Ga(s,-1,Ka(v[1].Target).replace(/#.*$/,""),Da.HLINK),b["r:id"]="rId"+w),(y=v[1].Target.indexOf("#"))>-1&&(b.location=Ka(v[1].Target.slice(y+1))),v[1].Tooltip&&(b.tooltip=Ka(v[1].Tooltip)),n[n.length]=ir("hyperlink",null,b))}),n[n.length]="</hyperlinks>"),delete c["!links"],c["!margins"]!=null&&(n[n.length]=IX(c["!margins"])),(!r||r.ignoreEC||r.ignoreEC==null)&&(n[n.length]=ei("ignoredErrors",ir("ignoredError",null,{numberStoredAsText:1,sqref:u}))),f.length>0&&(w=Ga(s,-1,"../drawings/drawing"+(e+1)+".xml",Da.DRAW),n[n.length]=ir("drawing",null,{"r:id":"rId"+w}),c["!drawing"]=f),c["!comments"].length>0&&(w=Ga(s,-1,"../drawings/vmlDrawing"+(e+1)+".vml",Da.VML),n[n.length]=ir("legacyDrawing",null,{"r:id":"rId"+w}),c["!legacy"]=w),n.length>1&&(n[n.length]="</worksheet>",n[1]=n[1].replace("/>",">")),n.join("")}function HX(e,r){var a={},s=e.l+r;a.r=e.read_shift(4),e.l+=4;var n=e.read_shift(2);e.l+=1;var i=e.read_shift(1);return e.l=s,i&7&&(a.level=i&7),i&16&&(a.hidden=!0),i&32&&(a.hpt=n/20),a}function qX(e,r,a){var s=Ft(145),n=(a["!rows"]||[])[e]||{};s.write_shift(4,e),s.write_shift(4,0);var i=320;n.hpx?i=Wv(n.hpx)*20:n.hpt&&(i=n.hpt*20),s.write_shift(2,i),s.write_shift(1,0);var o=0;n.level&&(o|=n.level),n.hidden&&(o|=16),(n.hpx||n.hpt)&&(o|=32),s.write_shift(1,o),s.write_shift(1,0);var l=0,c=s.l;s.l+=4;for(var u={r:e,c:0},h=0;h<16;++h)if(!(r.s.c>h+1<<10||r.e.c<h<<10)){for(var f=-1,y=-1,b=h<<10;b<h+1<<10;++b){u.c=b;var w=Array.isArray(a)?(a[u.r]||[])[u.c]:a[Ya(u)];w&&(f<0&&(f=b),y=b)}f<0||(++l,s.write_shift(4,f),s.write_shift(4,y))}var v=s.l;return s.l=c,s.write_shift(4,l),s.l=v,s.length>s.l?s.slice(0,s.l):s}function VX(e,r,a,s){var n=qX(s,a,r);(n.length>17||(r["!rows"]||[])[s])&&Jt(e,0,n)}var GX=Um,KX=Hp;function YX(){}function JX(e,r){var a={},s=e[e.l];return++e.l,a.above=!(s&64),a.left=!(s&128),e.l+=18,a.name=iY(e),a}function ZX(e,r,a){a==null&&(a=Ft(84+4*e.length));var s=192;r&&(r.above&&(s&=-65),r.left&&(s&=-129)),a.write_shift(1,s);for(var n=1;n<3;++n)a.write_shift(1,0);return zv({auto:1},a),a.write_shift(-4,-1),a.write_shift(-4,-1),DR(e,a),a.slice(0,a.l)}function XX(e){var r=jl(e);return[r]}function QX(e,r,a){return a==null&&(a=Ft(8)),Im(r,a)}function eQ(e){var r=zm(e);return[r]}function tQ(e,r,a){return a==null&&(a=Ft(4)),$m(r,a)}function rQ(e){var r=jl(e),a=e.read_shift(1);return[r,a,"b"]}function aQ(e,r,a){return a==null&&(a=Ft(9)),Im(r,a),a.write_shift(1,e.v?1:0),a}function sQ(e){var r=zm(e),a=e.read_shift(1);return[r,a,"b"]}function nQ(e,r,a){return a==null&&(a=Ft(5)),$m(r,a),a.write_shift(1,e.v?1:0),a}function iQ(e){var r=jl(e),a=e.read_shift(1);return[r,a,"e"]}function oQ(e,r,a){return a==null&&(a=Ft(9)),Im(r,a),a.write_shift(1,e.v),a}function lQ(e){var r=zm(e),a=e.read_shift(1);return[r,a,"e"]}function cQ(e,r,a){return a==null&&(a=Ft(8)),$m(r,a),a.write_shift(1,e.v),a.write_shift(2,0),a.write_shift(1,0),a}function dQ(e){var r=jl(e),a=e.read_shift(4);return[r,a,"s"]}function uQ(e,r,a){return a==null&&(a=Ft(12)),Im(r,a),a.write_shift(4,r.v),a}function mQ(e){var r=zm(e),a=e.read_shift(4);return[r,a,"s"]}function hQ(e,r,a){return a==null&&(a=Ft(8)),$m(r,a),a.write_shift(4,r.v),a}function pQ(e){var r=jl(e),a=qp(e);return[r,a,"n"]}function gQ(e,r,a){return a==null&&(a=Ft(16)),Im(r,a),jm(e.v,a),a}function fQ(e){var r=zm(e),a=qp(e);return[r,a,"n"]}function xQ(e,r,a){return a==null&&(a=Ft(12)),$m(r,a),jm(e.v,a),a}function yQ(e){var r=jl(e),a=RR(e);return[r,a,"n"]}function bQ(e,r,a){return a==null&&(a=Ft(12)),Im(r,a),MR(e.v,a),a}function vQ(e){var r=zm(e),a=RR(e);return[r,a,"n"]}function wQ(e,r,a){return a==null&&(a=Ft(8)),$m(r,a),MR(e.v,a),a}function jQ(e){var r=jl(e),a=uS(e);return[r,a,"is"]}function _Q(e){var r=jl(e),a=fi(e);return[r,a,"str"]}function kQ(e,r,a){return a==null&&(a=Ft(12+4*e.v.length)),Im(r,a),Mn(e.v,a),a.length>a.l?a.slice(0,a.l):a}function NQ(e){var r=zm(e),a=fi(e);return[r,a,"str"]}function SQ(e,r,a){return a==null&&(a=Ft(8+4*e.v.length)),$m(r,a),Mn(e.v,a),a.length>a.l?a.slice(0,a.l):a}function CQ(e,r,a){var s=e.l+r,n=jl(e);n.r=a["!row"];var i=e.read_shift(1),o=[n,i,"b"];if(a.cellFormula){e.l+=2;var l=ew(e,s-e.l,a);o[3]=kp(l,null,n,a.supbooks,a)}else e.l=s;return o}function TQ(e,r,a){var s=e.l+r,n=jl(e);n.r=a["!row"];var i=e.read_shift(1),o=[n,i,"e"];if(a.cellFormula){e.l+=2;var l=ew(e,s-e.l,a);o[3]=kp(l,null,n,a.supbooks,a)}else e.l=s;return o}function EQ(e,r,a){var s=e.l+r,n=jl(e);n.r=a["!row"];var i=qp(e),o=[n,i,"n"];if(a.cellFormula){e.l+=2;var l=ew(e,s-e.l,a);o[3]=kp(l,null,n,a.supbooks,a)}else e.l=s;return o}function AQ(e,r,a){var s=e.l+r,n=jl(e);n.r=a["!row"];var i=fi(e),o=[n,i,"str"];if(a.cellFormula){e.l+=2;var l=ew(e,s-e.l,a);o[3]=kp(l,null,n,a.supbooks,a)}else e.l=s;return o}var OQ=Um,PQ=Hp;function DQ(e,r){return r==null&&(r=Ft(4)),r.write_shift(4,e),r}function RQ(e,r){var a=e.l+r,s=Um(e),n=mS(e),i=fi(e),o=fi(e),l=fi(e);e.l=a;var c={rfx:s,relId:n,loc:i,display:l};return o&&(c.Tooltip=o),c}function MQ(e,r){var a=Ft(50+4*(e[1].Target.length+(e[1].Tooltip||"").length));Hp({s:Rn(e[0]),e:Rn(e[0])},a),hS("rId"+r,a);var s=e[1].Target.indexOf("#"),n=s==-1?"":e[1].Target.slice(s+1);return Mn(n||"",a),Mn(e[1].Tooltip||"",a),Mn("",a),a.slice(0,a.l)}function LQ(){}function FQ(e,r,a){var s=e.l+r,n=LR(e),i=e.read_shift(1),o=[n];if(o[2]=i,a.cellFormula){var l=NX(e,s-e.l,a);o[1]=l}else e.l=s;return o}function IQ(e,r,a){var s=e.l+r,n=Um(e),i=[n];if(a.cellFormula){var o=CX(e,s-e.l,a);i[1]=o,e.l=s}else e.l=s;return i}function zQ(e,r,a){a==null&&(a=Ft(18));var s=tw(e,r);a.write_shift(-4,e),a.write_shift(-4,e),a.write_shift(4,(s.width||10)*256),a.write_shift(4,0);var n=0;return r.hidden&&(n|=1),typeof s.width=="number"&&(n|=2),r.level&&(n|=r.level<<8),a.write_shift(2,n),a}var bM=["left","right","top","bottom","header","footer"];function $Q(e){var r={};return bM.forEach(function(a){r[a]=qp(e)}),r}function UQ(e,r){return r==null&&(r=Ft(48)),xM(e),bM.forEach(function(a){jm(e[a],r)}),r}function BQ(e){var r=e.read_shift(2);return e.l+=28,{RTL:r&32}}function WQ(e,r,a){a==null&&(a=Ft(30));var s=924;return(((r||{}).Views||[])[0]||{}).RTL&&(s|=32),a.write_shift(2,s),a.write_shift(4,0),a.write_shift(4,0),a.write_shift(4,0),a.write_shift(1,0),a.write_shift(1,0),a.write_shift(2,0),a.write_shift(2,100),a.write_shift(2,0),a.write_shift(2,0),a.write_shift(2,0),a.write_shift(4,0),a}function HQ(e){var r=Ft(24);return r.write_shift(4,4),r.write_shift(4,1),Hp(e,r),r}function qQ(e,r){return r==null&&(r=Ft(66)),r.write_shift(2,e.password?eM(e.password):0),r.write_shift(4,1),[["objects",!1],["scenarios",!1],["formatCells",!0],["formatColumns",!0],["formatRows",!0],["insertColumns",!0],["insertRows",!0],["insertHyperlinks",!0],["deleteColumns",!0],["deleteRows",!0],["selectLockedCells",!1],["sort",!0],["autoFilter",!0],["pivotTables",!0],["selectUnlockedCells",!1]].forEach(function(a){a[1]?r.write_shift(4,e[a[0]]!=null&&!e[a[0]]?1:0):r.write_shift(4,e[a[0]]!=null&&e[a[0]]?0:1)}),r}function VQ(){}function GQ(){}function KQ(e,r,a,s,n,i,o){if(r.v===void 0)return!1;var l="";switch(r.t){case"b":l=r.v?"1":"0";break;case"d":r=uo(r),r.z=r.z||Hs[14],r.v=co(Mi(r.v)),r.t="n";break;case"n":case"e":l=""+r.v;break;default:l=r.v;break}var c={r:a,c:s};switch(c.s=s0(n.cellXfs,r,n),r.l&&i["!links"].push([Ya(c),r.l]),r.c&&i["!comments"].push([Ya(c),r.c]),r.t){case"s":case"str":return n.bookSST?(l=bS(n.Strings,r.v,n.revStrings),c.t="s",c.v=l,o?Jt(e,18,hQ(r,c)):Jt(e,7,uQ(r,c))):(c.t="str",o?Jt(e,17,SQ(r,c)):Jt(e,6,kQ(r,c))),!0;case"n":return r.v==(r.v|0)&&r.v>-1e3&&r.v<1e3?o?Jt(e,13,wQ(r,c)):Jt(e,2,bQ(r,c)):o?Jt(e,16,xQ(r,c)):Jt(e,5,gQ(r,c)),!0;case"b":return c.t="b",o?Jt(e,15,nQ(r,c)):Jt(e,4,aQ(r,c)),!0;case"e":return c.t="e",o?Jt(e,14,cQ(r,c)):Jt(e,3,oQ(r,c)),!0}return o?Jt(e,12,tQ(r,c)):Jt(e,1,QX(r,c)),!0}function YQ(e,r,a,s){var n=vs(r["!ref"]||"A1"),i,o="",l=[];Jt(e,145);var c=Array.isArray(r),u=n.e.r;r["!rows"]&&(u=Math.max(n.e.r,r["!rows"].length-1));for(var h=n.s.r;h<=u;++h){o=ai(h),VX(e,r,n,h);var f=!1;if(h<=n.e.r)for(var y=n.s.c;y<=n.e.c;++y){h===n.s.r&&(l[y]=gi(y)),i=l[y]+o;var b=c?(r[h]||[])[y]:r[i];if(!b){f=!1;continue}f=KQ(e,b,h,y,s,r,f)}}Jt(e,146)}function JQ(e,r){!r||!r["!merges"]||(Jt(e,177,DQ(r["!merges"].length)),r["!merges"].forEach(function(a){Jt(e,176,PQ(a))}),Jt(e,178))}function ZQ(e,r){!r||!r["!cols"]||(Jt(e,390),r["!cols"].forEach(function(a,s){a&&Jt(e,60,zQ(s,a))}),Jt(e,391))}function XQ(e,r){!r||!r["!ref"]||(Jt(e,648),Jt(e,649,HQ(vs(r["!ref"]))),Jt(e,650))}function QQ(e,r,a){r["!links"].forEach(function(s){if(s[1].Target){var n=Ga(a,-1,s[1].Target.replace(/#.*$/,""),Da.HLINK);Jt(e,494,MQ(s,n))}}),delete r["!links"]}function eee(e,r,a,s){if(r["!comments"].length>0){var n=Ga(s,-1,"../drawings/vmlDrawing"+(a+1)+".vml",Da.VML);Jt(e,551,hS("rId"+n)),r["!legacy"]=n}}function tee(e,r,a,s){if(r["!autofilter"]){var n=r["!autofilter"],i=typeof n.ref=="string"?n.ref:ln(n.ref);a.Workbook||(a.Workbook={Sheets:[]}),a.Workbook.Names||(a.Workbook.Names=[]);var o=a.Workbook.Names,l=Wo(i);l.s.r==l.e.r&&(l.e.r=Wo(r["!ref"]).e.r,i=ln(l));for(var c=0;c<o.length;++c){var u=o[c];if(u.Name=="_xlnm._FilterDatabase"&&u.Sheet==s){u.Ref="'"+a.SheetNames[s]+"'!"+i;break}}c==o.length&&o.push({Name:"_xlnm._FilterDatabase",Sheet:s,Ref:"'"+a.SheetNames[s]+"'!"+i}),Jt(e,161,Hp(vs(i))),Jt(e,162)}}function ree(e,r,a){Jt(e,133),Jt(e,137,WQ(r,a)),Jt(e,138),Jt(e,134)}function aee(e,r){r["!protect"]&&Jt(e,535,qQ(r["!protect"]))}function see(e,r,a,s){var n=io(),i=a.SheetNames[e],o=a.Sheets[i]||{},l=i;try{a&&a.Workbook&&(l=a.Workbook.Sheets[e].CodeName||l)}catch(u){}var c=vs(o["!ref"]||"A1");if(c.e.c>16383||c.e.r>1048575){if(r.WTF)throw new Error("Range "+(o["!ref"]||"A1")+" exceeds format limit A1:XFD1048576");c.e.c=Math.min(c.e.c,16383),c.e.r=Math.min(c.e.c,1048575)}return o["!links"]=[],o["!comments"]=[],Jt(n,129),(a.vbaraw||o["!outline"])&&Jt(n,147,ZX(l,o["!outline"])),Jt(n,148,KX(c)),ree(n,o,a.Workbook),ZQ(n,o),YQ(n,o,e,r),aee(n,o),tee(n,o,a,e),JQ(n,o),QQ(n,o,s),o["!margins"]&&Jt(n,476,UQ(o["!margins"])),(!r||r.ignoreEC||r.ignoreEC==null)&&XQ(n,o),eee(n,o,e,s),Jt(n,130),n.end()}function nee(e,r){e.l+=10;var a=fi(e);return{name:a}}var iee=[["allowRefreshQuery",!1,"bool"],["autoCompressPictures",!0,"bool"],["backupFile",!1,"bool"],["checkCompatibility",!1,"bool"],["CodeName",""],["date1904",!1,"bool"],["defaultThemeVersion",0,"int"],["filterPrivacy",!1,"bool"],["hidePivotFieldList",!1,"bool"],["promptedSolutions",!1,"bool"],["publishItems",!1,"bool"],["refreshAllConnections",!1,"bool"],["saveExternalLinkValues",!0,"bool"],["showBorderUnselectedTables",!0,"bool"],["showInkAnnotation",!0,"bool"],["showObjects","all"],["showPivotChartFilter",!1,"bool"],["updateLinks","userSet"]];function oee(e){return!e.Workbook||!e.Workbook.WBProps?"false":IK(e.Workbook.WBProps.date1904)?"true":"false"}var lee="][*?/\\".split("");function vM(e,r){if(e.length>31)throw new Error("Sheet names cannot exceed 31 chars");var a=!0;return lee.forEach(function(s){if(e.indexOf(s)!=-1)throw new Error("Sheet name cannot contain : \\ / ? * [ ]")}),a}function cee(e,r,a){e.forEach(function(s,n){vM(s);for(var i=0;i<n;++i)if(s==e[i])throw new Error("Duplicate Sheet Name: "+s);if(a){var o=r&&r[n]&&r[n].CodeName||s;if(o.charCodeAt(0)==95&&o.length>22)throw new Error("Bad Code Name: Worksheet"+o)}})}function dee(e){if(!e||!e.SheetNames||!e.Sheets)throw new Error("Invalid Workbook");if(!e.SheetNames.length)throw new Error("Workbook is empty");var r=e.Workbook&&e.Workbook.Sheets||[];cee(e.SheetNames,r,!!e.vbaraw);for(var a=0;a<e.SheetNames.length;++a)PX(e.Sheets[e.SheetNames[a]],e.SheetNames[a],a)}function wM(e){var r=[mn];r[r.length]=ir("workbook",null,{xmlns:Bp[0],"xmlns:r":Dn.r});var a=e.Workbook&&(e.Workbook.Names||[]).length>0,s={codeName:"ThisWorkbook"};e.Workbook&&e.Workbook.WBProps&&(iee.forEach(function(l){e.Workbook.WBProps[l[0]]!=null&&e.Workbook.WBProps[l[0]]!=l[1]&&(s[l[0]]=e.Workbook.WBProps[l[0]])}),e.Workbook.WBProps.CodeName&&(s.codeName=e.Workbook.WBProps.CodeName,delete s.CodeName)),r[r.length]=ir("workbookPr",null,s);var n=e.Workbook&&e.Workbook.Sheets||[],i=0;if(n&&n[0]&&n[0].Hidden){for(r[r.length]="<bookViews>",i=0;i!=e.SheetNames.length&&!(!n[i]||!n[i].Hidden);++i);i==e.SheetNames.length&&(i=0),r[r.length]='<workbookView firstSheet="'+i+'" activeTab="'+i+'"/>',r[r.length]="</bookViews>"}for(r[r.length]="<sheets>",i=0;i!=e.SheetNames.length;++i){var o={name:Ka(e.SheetNames[i].slice(0,31))};if(o.sheetId=""+(i+1),o["r:id"]="rId"+(i+1),n[i])switch(n[i].Hidden){case 1:o.state="hidden";break;case 2:o.state="veryHidden";break}r[r.length]=ir("sheet",null,o)}return r[r.length]="</sheets>",a&&(r[r.length]="<definedNames>",e.Workbook&&e.Workbook.Names&&e.Workbook.Names.forEach(function(l){var c={name:l.Name};l.Comment&&(c.comment=l.Comment),l.Sheet!=null&&(c.localSheetId=""+l.Sheet),l.Hidden&&(c.hidden="1"),l.Ref&&(r[r.length]=ir("definedName",Ka(l.Ref),c))}),r[r.length]="</definedNames>"),r.length>2&&(r[r.length]="</workbook>",r[1]=r[1].replace("/>",">")),r.join("")}function uee(e,r){var a={};return a.Hidden=e.read_shift(4),a.iTabID=e.read_shift(4),a.strRelID=NN(e),a.name=fi(e),a}function mee(e,r){return r||(r=Ft(127)),r.write_shift(4,e.Hidden),r.write_shift(4,e.iTabID),hS(e.strRelID,r),Mn(e.name.slice(0,31),r),r.length>r.l?r.slice(0,r.l):r}function hee(e,r){var a={},s=e.read_shift(4);a.defaultThemeVersion=e.read_shift(4);var n=r>8?fi(e):"";return n.length>0&&(a.CodeName=n),a.autoCompressPictures=!!(s&65536),a.backupFile=!!(s&64),a.checkCompatibility=!!(s&4096),a.date1904=!!(s&1),a.filterPrivacy=!!(s&8),a.hidePivotFieldList=!!(s&1024),a.promptedSolutions=!!(s&16),a.publishItems=!!(s&2048),a.refreshAllConnections=!!(s&262144),a.saveExternalLinkValues=!!(s&128),a.showBorderUnselectedTables=!!(s&4),a.showInkAnnotation=!!(s&32),a.showObjects=["all","placeholders","none"][s>>13&3],a.showPivotChartFilter=!!(s&32768),a.updateLinks=["userSet","never","always"][s>>8&3],a}function pee(e,r){r||(r=Ft(72));var a=0;return e&&e.filterPrivacy&&(a|=8),r.write_shift(4,a),r.write_shift(4,0),DR(e&&e.CodeName||"ThisWorkbook",r),r.slice(0,r.l)}function gee(e,r,a){var s=e.l+r;e.l+=4,e.l+=1;var n=e.read_shift(4),i=oY(e),o=SX(e,0,a),l=mS(e);e.l=s;var c={Name:i,Ptg:o};return n<268435455&&(c.Sheet=n),l&&(c.Comment=l),c}function fee(e,r){Jt(e,143);for(var a=0;a!=r.SheetNames.length;++a){var s=r.Workbook&&r.Workbook.Sheets&&r.Workbook.Sheets[a]&&r.Workbook.Sheets[a].Hidden||0,n={Hidden:s,iTabID:a+1,strRelID:"rId"+(a+1),name:r.SheetNames[a]};Jt(e,156,mee(n))}Jt(e,144)}function xee(e,r){r||(r=Ft(127));for(var a=0;a!=4;++a)r.write_shift(4,0);return Mn("SheetJS",r),Mn(Ov.version,r),Mn(Ov.version,r),Mn("7262",r),r.length>r.l?r.slice(0,r.l):r}function yee(e,r){r||(r=Ft(29)),r.write_shift(-4,0),r.write_shift(-4,460),r.write_shift(4,28800),r.write_shift(4,17600),r.write_shift(4,500),r.write_shift(4,e),r.write_shift(4,e);var a=120;return r.write_shift(1,a),r.length>r.l?r.slice(0,r.l):r}function bee(e,r){if(!(!r.Workbook||!r.Workbook.Sheets)){for(var a=r.Workbook.Sheets,s=0,n=-1,i=-1;s<a.length;++s)!a[s]||!a[s].Hidden&&n==-1?n=s:a[s].Hidden==1&&i==-1&&(i=s);i>n||(Jt(e,135),Jt(e,158,yee(n)),Jt(e,136))}}function vee(e,r){var a=io();return Jt(a,131),Jt(a,128,xee()),Jt(a,153,pee(e.Workbook&&e.Workbook.WBProps||null)),bee(a,e),fee(a,e),Jt(a,132),a.end()}function wee(e,r,a){return(r.slice(-4)===".bin"?vee:wM)(e)}function jee(e,r,a,s,n){return(r.slice(-4)===".bin"?see:yM)(e,a,s,n)}function _ee(e,r,a){return(r.slice(-4)===".bin"?UJ:aM)(e,a)}function kee(e,r,a){return(r.slice(-4)===".bin"?pJ:QR)(e,a)}function Nee(e,r,a){return(r.slice(-4)===".bin"?aZ:lM)(e)}function See(e){return(e.slice(-4)===".bin"?YJ:iM)()}function Cee(e,r){var a=[];return e.Props&&a.push(_Y(e.Props,r)),e.Custprops&&a.push(kY(e.Props,e.Custprops)),a.join("")}function Tee(){return""}function Eee(e,r){var a=['<Style ss:ID="Default" ss:Name="Normal"><NumberFormat/></Style>'];return r.cellXfs.forEach(function(s,n){var i=[];i.push(ir("NumberFormat",null,{"ss:Format":Ka(Hs[s.numFmtId])}));var o={"ss:ID":"s"+(21+n)};a.push(ir("Style",i.join(""),o))}),ir("Styles",a.join(""))}function jM(e){return ir("NamedRange",null,{"ss:Name":e.Name,"ss:RefersTo":"="+xS(e.Ref,{r:0,c:0})})}function Aee(e){if(!((e||{}).Workbook||{}).Names)return"";for(var r=e.Workbook.Names,a=[],s=0;s<r.length;++s){var n=r[s];n.Sheet==null&&(n.Name.match(/^_xlfn\./)||a.push(jM(n)))}return ir("Names",a.join(""))}function Oee(e,r,a,s){if(!e||!((s||{}).Workbook||{}).Names)return"";for(var n=s.Workbook.Names,i=[],o=0;o<n.length;++o){var l=n[o];l.Sheet==a&&(l.Name.match(/^_xlfn\./)||i.push(jM(l)))}return i.join("")}function Pee(e,r,a,s){if(!e)return"";var n=[];if(e["!margins"]&&(n.push("<PageSetup>"),e["!margins"].header&&n.push(ir("Header",null,{"x:Margin":e["!margins"].header})),e["!margins"].footer&&n.push(ir("Footer",null,{"x:Margin":e["!margins"].footer})),n.push(ir("PageMargins",null,{"x:Bottom":e["!margins"].bottom||"0.75","x:Left":e["!margins"].left||"0.7","x:Right":e["!margins"].right||"0.7","x:Top":e["!margins"].top||"0.75"})),n.push("</PageSetup>")),s&&s.Workbook&&s.Workbook.Sheets&&s.Workbook.Sheets[a])if(s.Workbook.Sheets[a].Hidden)n.push(ir("Visible",s.Workbook.Sheets[a].Hidden==1?"SheetHidden":"SheetVeryHidden",{}));else{for(var i=0;i<a&&!(s.Workbook.Sheets[i]&&!s.Workbook.Sheets[i].Hidden);++i);i==a&&n.push("<Selected/>")}return((((s||{}).Workbook||{}).Views||[])[0]||{}).RTL&&n.push("<DisplayRightToLeft/>"),e["!protect"]&&(n.push(ei("ProtectContents","True")),e["!protect"].objects&&n.push(ei("ProtectObjects","True")),e["!protect"].scenarios&&n.push(ei("ProtectScenarios","True")),e["!protect"].selectLockedCells!=null&&!e["!protect"].selectLockedCells?n.push(ei("EnableSelection","NoSelection")):e["!protect"].selectUnlockedCells!=null&&!e["!protect"].selectUnlockedCells&&n.push(ei("EnableSelection","UnlockedCells")),[["formatCells","AllowFormatCells"],["formatColumns","AllowSizeCols"],["formatRows","AllowSizeRows"],["insertColumns","AllowInsertCols"],["insertRows","AllowInsertRows"],["insertHyperlinks","AllowInsertHyperlinks"],["deleteColumns","AllowDeleteCols"],["deleteRows","AllowDeleteRows"],["sort","AllowSort"],["autoFilter","AllowFilter"],["pivotTables","AllowUsePivotTables"]].forEach(function(o){e["!protect"][o[0]]&&n.push("<"+o[1]+"/>")})),n.length==0?"":ir("WorksheetOptions",n.join(""),{xmlns:Lo.x})}function Dee(e){return e.map(function(r){var a=FK(r.t||""),s=ir("ss:Data",a,{xmlns:"http://www.w3.org/TR/REC-html40"});return ir("Comment",s,{"ss:Author":r.a})}).join("")}function Ree(e,r,a,s,n,i,o){if(!e||e.v==null&&e.f==null)return"";var l={};if(e.f&&(l["ss:Formula"]="="+Ka(xS(e.f,o))),e.F&&e.F.slice(0,r.length)==r){var c=Rn(e.F.slice(r.length+1));l["ss:ArrayRange"]="RC:R"+(c.r==o.r?"":"["+(c.r-o.r)+"]")+"C"+(c.c==o.c?"":"["+(c.c-o.c)+"]")}if(e.l&&e.l.Target&&(l["ss:HRef"]=Ka(e.l.Target),e.l.Tooltip&&(l["x:HRefScreenTip"]=Ka(e.l.Tooltip))),a["!merges"])for(var u=a["!merges"],h=0;h!=u.length;++h)u[h].s.c!=o.c||u[h].s.r!=o.r||(u[h].e.c>u[h].s.c&&(l["ss:MergeAcross"]=u[h].e.c-u[h].s.c),u[h].e.r>u[h].s.r&&(l["ss:MergeDown"]=u[h].e.r-u[h].s.r));var f="",y="";switch(e.t){case"z":if(!s.sheetStubs)return"";break;case"n":f="Number",y=String(e.v);break;case"b":f="Boolean",y=e.v?"1":"0";break;case"e":f="Error",y=Cx[e.v];break;case"d":f="DateTime",y=new Date(e.v).toISOString(),e.z==null&&(e.z=e.z||Hs[14]);break;case"s":f="String",y=LK(e.v||"");break}var b=s0(s.cellXfs,e,s);l["ss:StyleID"]="s"+(21+b),l["ss:Index"]=o.c+1;var w=e.v!=null?y:"",v=e.t=="z"?"":'<Data ss:Type="'+f+'">'+w+"</Data>";return(e.c||[]).length>0&&(v+=Dee(e.c)),ir("Cell",v,l)}function Mee(e,r){var a='<Row ss:Index="'+(e+1)+'"';return r&&(r.hpt&&!r.hpx&&(r.hpx=rM(r.hpt)),r.hpx&&(a+=' ss:AutoFitHeight="0" ss:Height="'+r.hpx+'"'),r.hidden&&(a+=' ss:Hidden="1"')),a+">"}function Lee(e,r,a,s){if(!e["!ref"])return"";var n=vs(e["!ref"]),i=e["!merges"]||[],o=0,l=[];e["!cols"]&&e["!cols"].forEach(function(k,S){gS(k);var N=!!k.width,C=tw(S,k),O={"ss:Index":S+1};N&&(O["ss:Width"]=Uv(C.width)),k.hidden&&(O["ss:Hidden"]="1"),l.push(ir("Column",null,O))});for(var c=Array.isArray(e),u=n.s.r;u<=n.e.r;++u){for(var h=[Mee(u,(e["!rows"]||[])[u])],f=n.s.c;f<=n.e.c;++f){var y=!1;for(o=0;o!=i.length;++o)if(!(i[o].s.c>f)&&!(i[o].s.r>u)&&!(i[o].e.c<f)&&!(i[o].e.r<u)){(i[o].s.c!=f||i[o].s.r!=u)&&(y=!0);break}if(!y){var b={r:u,c:f},w=Ya(b),v=c?(e[u]||[])[f]:e[w];h.push(Ree(v,w,e,r,a,s,b))}}h.push("</Row>"),h.length>2&&l.push(h.join(""))}return l.join("")}function Fee(e,r,a){var s=[],n=a.SheetNames[e],i=a.Sheets[n],o=i?Oee(i,r,e,a):"";return o.length>0&&s.push("<Names>"+o+"</Names>"),o=i?Lee(i,r,e,a):"",o.length>0&&s.push("<Table>"+o+"</Table>"),s.push(Pee(i,r,e,a)),s.join("")}function Iee(e,r){r||(r={}),e.SSF||(e.SSF=uo(Hs)),e.SSF&&(J1(),Y1(e.SSF),r.revssf=Z1(e.SSF),r.revssf[e.SSF[65535]]=0,r.ssf=e.SSF,r.cellXfs=[],s0(r.cellXfs,{},{revssf:{General:0}}));var a=[];a.push(Cee(e,r)),a.push(Tee()),a.push(""),a.push("");for(var s=0;s<e.SheetNames.length;++s)a.push(ir("Worksheet",Fee(s,r,e),{"ss:Name":Ka(e.SheetNames[s])}));return a[2]=Eee(e,r),a[3]=Aee(e),mn+ir("Workbook",a.join(""),{xmlns:Lo.ss,"xmlns:o":Lo.o,"xmlns:x":Lo.x,"xmlns:ss":Lo.ss,"xmlns:dt":Lo.dt,"xmlns:html":Lo.html})}var dk={SI:"e0859ff2f94f6810ab9108002b27b3d9",DSI:"02d5cdd59c2e1b10939708002b2cf9ae",UDI:"05d5cdd59c2e1b10939708002b2cf9ae"};function zee(e,r){var a=[],s=[],n=[],i=0,o,l=TE(UE,"n"),c=TE(BE,"n");if(e.Props)for(o=si(e.Props),i=0;i<o.length;++i)(Object.prototype.hasOwnProperty.call(l,o[i])?a:Object.prototype.hasOwnProperty.call(c,o[i])?s:n).push([o[i],e.Props[o[i]]]);if(e.Custprops)for(o=si(e.Custprops),i=0;i<o.length;++i)Object.prototype.hasOwnProperty.call(e.Props||{},o[i])||(Object.prototype.hasOwnProperty.call(l,o[i])?a:Object.prototype.hasOwnProperty.call(c,o[i])?s:n).push([o[i],e.Custprops[o[i]]]);var u=[];for(i=0;i<n.length;++i)VR.indexOf(n[i][0])>-1||WR.indexOf(n[i][0])>-1||n[i][1]!=null&&u.push(n[i]);s.length&&as.utils.cfb_add(r,"/SummaryInformation",GE(s,dk.SI,c,BE)),(a.length||u.length)&&as.utils.cfb_add(r,"/DocumentSummaryInformation",GE(a,dk.DSI,l,UE,u.length?u:null,dk.UDI))}function $ee(e,r){var a=r||{},s=as.utils.cfb_new({root:"R"}),n="/Workbook";switch(a.bookType||"xls"){case"xls":a.bookType="biff8";case"xla":a.bookType||(a.bookType="xla");case"biff8":n="/Workbook",a.biff=8;break;case"biff5":n="/Book",a.biff=5;break;default:throw new Error("invalid type "+a.bookType+" for XLS CFB")}return as.utils.cfb_add(s,n,_M(e,a)),a.biff==8&&(e.Props||e.Custprops)&&zee(e,s),a.biff==8&&e.vbaraw&&sZ(s,as.read(e.vbaraw,{type:typeof e.vbaraw=="string"?"binary":"buffer"})),s}var Uee={0:{f:HX},1:{f:XX},2:{f:yQ},3:{f:iQ},4:{f:rQ},5:{f:pQ},6:{f:_Q},7:{f:dQ},8:{f:AQ},9:{f:EQ},10:{f:CQ},11:{f:TQ},12:{f:eQ},13:{f:vQ},14:{f:lQ},15:{f:sQ},16:{f:fQ},17:{f:NQ},18:{f:mQ},19:{f:uS},20:{},21:{},22:{},23:{},24:{},25:{},26:{},27:{},28:{},29:{},30:{},31:{},32:{},33:{},34:{},35:{T:1},36:{T:-1},37:{T:1},38:{T:-1},39:{f:gee},40:{},42:{},43:{f:_J},44:{f:wJ},45:{f:SJ},46:{f:TJ},47:{f:CJ},48:{},49:{f:eY},50:{},51:{f:HJ},52:{T:1},53:{T:-1},54:{T:1},55:{T:-1},56:{T:1},57:{T:-1},58:{},59:{},60:{f:tJ},62:{f:jQ},63:{f:JJ},64:{f:VQ},65:{},66:{},67:{},68:{},69:{},70:{},128:{},129:{T:1},130:{T:-1},131:{T:1,f:zc,p:0},132:{T:-1},133:{T:1},134:{T:-1},135:{T:1},136:{T:-1},137:{T:1,f:BQ},138:{T:-1},139:{T:1},140:{T:-1},141:{T:1},142:{T:-1},143:{T:1},144:{T:-1},145:{T:1},146:{T:-1},147:{f:JX},148:{f:GX,p:16},151:{f:LQ},152:{},153:{f:hee},154:{},155:{},156:{f:uee},157:{},158:{},159:{T:1,f:uJ},160:{T:-1},161:{T:1,f:Um},162:{T:-1},163:{T:1},164:{T:-1},165:{T:1},166:{T:-1},167:{},168:{},169:{},170:{},171:{},172:{T:1},173:{T:-1},174:{},175:{},176:{f:OQ},177:{T:1},178:{T:-1},179:{T:1},180:{T:-1},181:{T:1},182:{T:-1},183:{T:1},184:{T:-1},185:{T:1},186:{T:-1},187:{T:1},188:{T:-1},189:{T:1},190:{T:-1},191:{T:1},192:{T:-1},193:{T:1},194:{T:-1},195:{T:1},196:{T:-1},197:{T:1},198:{T:-1},199:{T:1},200:{T:-1},201:{T:1},202:{T:-1},203:{T:1},204:{T:-1},205:{T:1},206:{T:-1},207:{T:1},208:{T:-1},209:{T:1},210:{T:-1},211:{T:1},212:{T:-1},213:{T:1},214:{T:-1},215:{T:1},216:{T:-1},217:{T:1},218:{T:-1},219:{T:1},220:{T:-1},221:{T:1},222:{T:-1},223:{T:1},224:{T:-1},225:{T:1},226:{T:-1},227:{T:1},228:{T:-1},229:{T:1},230:{T:-1},231:{T:1},232:{T:-1},233:{T:1},234:{T:-1},235:{T:1},236:{T:-1},237:{T:1},238:{T:-1},239:{T:1},240:{T:-1},241:{T:1},242:{T:-1},243:{T:1},244:{T:-1},245:{T:1},246:{T:-1},247:{T:1},248:{T:-1},249:{T:1},250:{T:-1},251:{T:1},252:{T:-1},253:{T:1},254:{T:-1},255:{T:1},256:{T:-1},257:{T:1},258:{T:-1},259:{T:1},260:{T:-1},261:{T:1},262:{T:-1},263:{T:1},264:{T:-1},265:{T:1},266:{T:-1},267:{T:1},268:{T:-1},269:{T:1},270:{T:-1},271:{T:1},272:{T:-1},273:{T:1},274:{T:-1},275:{T:1},276:{T:-1},277:{},278:{T:1},279:{T:-1},280:{T:1},281:{T:-1},282:{T:1},283:{T:1},284:{T:-1},285:{T:1},286:{T:-1},287:{T:1},288:{T:-1},289:{T:1},290:{T:-1},291:{T:1},292:{T:-1},293:{T:1},294:{T:-1},295:{T:1},296:{T:-1},297:{T:1},298:{T:-1},299:{T:1},300:{T:-1},301:{T:1},302:{T:-1},303:{T:1},304:{T:-1},305:{T:1},306:{T:-1},307:{T:1},308:{T:-1},309:{T:1},310:{T:-1},311:{T:1},312:{T:-1},313:{T:-1},314:{T:1},315:{T:-1},316:{T:1},317:{T:-1},318:{T:1},319:{T:-1},320:{T:1},321:{T:-1},322:{T:1},323:{T:-1},324:{T:1},325:{T:-1},326:{T:1},327:{T:-1},328:{T:1},329:{T:-1},330:{T:1},331:{T:-1},332:{T:1},333:{T:-1},334:{T:1},335:{f:BJ},336:{T:-1},337:{f:GJ,T:1},338:{T:-1},339:{T:1},340:{T:-1},341:{T:1},342:{T:-1},343:{T:1},344:{T:-1},345:{T:1},346:{T:-1},347:{T:1},348:{T:-1},349:{T:1},350:{T:-1},351:{},352:{},353:{T:1},354:{T:-1},355:{f:NN},357:{},358:{},359:{},360:{T:1},361:{},362:{f:YY},363:{},364:{},366:{},367:{},368:{},369:{},370:{},371:{},372:{T:1},373:{T:-1},374:{T:1},375:{T:-1},376:{T:1},377:{T:-1},378:{T:1},379:{T:-1},380:{T:1},381:{T:-1},382:{T:1},383:{T:-1},384:{T:1},385:{T:-1},386:{T:1},387:{T:-1},388:{T:1},389:{T:-1},390:{T:1},391:{T:-1},392:{T:1},393:{T:-1},394:{T:1},395:{T:-1},396:{},397:{},398:{},399:{},400:{},401:{T:1},403:{},404:{},405:{},406:{},407:{},408:{},409:{},410:{},411:{},412:{},413:{},414:{},415:{},416:{},417:{},418:{},419:{},420:{},421:{},422:{T:1},423:{T:1},424:{T:-1},425:{T:-1},426:{f:FQ},427:{f:IQ},428:{},429:{T:1},430:{T:-1},431:{T:1},432:{T:-1},433:{T:1},434:{T:-1},435:{T:1},436:{T:-1},437:{T:1},438:{T:-1},439:{T:1},440:{T:-1},441:{T:1},442:{T:-1},443:{T:1},444:{T:-1},445:{T:1},446:{T:-1},447:{T:1},448:{T:-1},449:{T:1},450:{T:-1},451:{T:1},452:{T:-1},453:{T:1},454:{T:-1},455:{T:1},456:{T:-1},457:{T:1},458:{T:-1},459:{T:1},460:{T:-1},461:{T:1},462:{T:-1},463:{T:1},464:{T:-1},465:{T:1},466:{T:-1},467:{T:1},468:{T:-1},469:{T:1},470:{T:-1},471:{},472:{},473:{T:1},474:{T:-1},475:{},476:{f:$Q},477:{},478:{},479:{T:1},480:{T:-1},481:{T:1},482:{T:-1},483:{T:1},484:{T:-1},485:{f:YX},486:{T:1},487:{T:-1},488:{T:1},489:{T:-1},490:{T:1},491:{T:-1},492:{T:1},493:{T:-1},494:{f:RQ},495:{T:1},496:{T:-1},497:{T:1},498:{T:-1},499:{},500:{T:1},501:{T:-1},502:{T:1},503:{T:-1},504:{},505:{T:1},506:{T:-1},507:{},508:{T:1},509:{T:-1},510:{T:1},511:{T:-1},512:{},513:{},514:{T:1},515:{T:-1},516:{T:1},517:{T:-1},518:{T:1},519:{T:-1},520:{T:1},521:{T:-1},522:{},523:{},524:{},525:{},526:{},527:{},528:{T:1},529:{T:-1},530:{T:1},531:{T:-1},532:{T:1},533:{T:-1},534:{},535:{},536:{},537:{},538:{T:1},539:{T:-1},540:{T:1},541:{T:-1},542:{T:1},548:{},549:{},550:{f:NN},551:{},552:{},553:{},554:{T:1},555:{T:-1},556:{T:1},557:{T:-1},558:{T:1},559:{T:-1},560:{T:1},561:{T:-1},562:{},564:{},565:{T:1},566:{T:-1},569:{T:1},570:{T:-1},572:{},573:{T:1},574:{T:-1},577:{},578:{},579:{},580:{},581:{},582:{},583:{},584:{},585:{},586:{},587:{},588:{T:-1},589:{},590:{T:1},591:{T:-1},592:{T:1},593:{T:-1},594:{T:1},595:{T:-1},596:{},597:{T:1},598:{T:-1},599:{T:1},600:{T:-1},601:{T:1},602:{T:-1},603:{T:1},604:{T:-1},605:{T:1},606:{T:-1},607:{},608:{T:1},609:{T:-1},610:{},611:{T:1},612:{T:-1},613:{T:1},614:{T:-1},615:{T:1},616:{T:-1},617:{T:1},618:{T:-1},619:{T:1},620:{T:-1},625:{},626:{T:1},627:{T:-1},628:{T:1},629:{T:-1},630:{T:1},631:{T:-1},632:{f:tZ},633:{T:1},634:{T:-1},635:{T:1,f:QJ},636:{T:-1},637:{f:sY},638:{T:1},639:{},640:{T:-1},641:{T:1},642:{T:-1},643:{T:1},644:{},645:{T:-1},646:{T:1},648:{T:1},649:{},650:{T:-1},651:{f:nee},652:{},653:{T:1},654:{T:-1},655:{T:1},656:{T:-1},657:{T:1},658:{T:-1},659:{},660:{T:1},661:{},662:{T:-1},663:{},664:{T:1},665:{},666:{T:-1},667:{},668:{},669:{},671:{T:1},672:{T:-1},673:{T:1},674:{T:-1},675:{},676:{},677:{},678:{},679:{},680:{},681:{},1024:{},1025:{},1026:{T:1},1027:{T:-1},1028:{T:1},1029:{T:-1},1030:{},1031:{T:1},1032:{T:-1},1033:{T:1},1034:{T:-1},1035:{},1036:{},1037:{},1038:{T:1},1039:{T:-1},1040:{},1041:{T:1},1042:{T:-1},1043:{},1044:{},1045:{},1046:{T:1},1047:{T:-1},1048:{T:1},1049:{T:-1},1050:{},1051:{T:1},1052:{T:1},1053:{f:GQ},1054:{T:1},1055:{},1056:{T:1},1057:{T:-1},1058:{T:1},1059:{T:-1},1061:{},1062:{T:1},1063:{T:-1},1064:{T:1},1065:{T:-1},1066:{T:1},1067:{T:-1},1068:{T:1},1069:{T:-1},1070:{T:1},1071:{T:-1},1072:{T:1},1073:{T:-1},1075:{T:1},1076:{T:-1},1077:{T:1},1078:{T:-1},1079:{T:1},1080:{T:-1},1081:{T:1},1082:{T:-1},1083:{T:1},1084:{T:-1},1085:{},1086:{T:1},1087:{T:-1},1088:{T:1},1089:{T:-1},1090:{T:1},1091:{T:-1},1092:{T:1},1093:{T:-1},1094:{T:1},1095:{T:-1},1096:{},1097:{T:1},1098:{},1099:{T:-1},1100:{T:1},1101:{T:-1},1102:{},1103:{},1104:{},1105:{},1111:{},1112:{},1113:{T:1},1114:{T:-1},1115:{T:1},1116:{T:-1},1117:{},1118:{T:1},1119:{T:-1},1120:{T:1},1121:{T:-1},1122:{T:1},1123:{T:-1},1124:{T:1},1125:{T:-1},1126:{},1128:{T:1},1129:{T:-1},1130:{},1131:{T:1},1132:{T:-1},1133:{T:1},1134:{T:-1},1135:{T:1},1136:{T:-1},1137:{T:1},1138:{T:-1},1139:{T:1},1140:{T:-1},1141:{},1142:{T:1},1143:{T:-1},1144:{T:1},1145:{T:-1},1146:{},1147:{T:1},1148:{T:-1},1149:{T:1},1150:{T:-1},1152:{T:1},1153:{T:-1},1154:{T:-1},1155:{T:-1},1156:{T:-1},1157:{T:1},1158:{T:-1},1159:{T:1},1160:{T:-1},1161:{T:1},1162:{T:-1},1163:{T:1},1164:{T:-1},1165:{T:1},1166:{T:-1},1167:{T:1},1168:{T:-1},1169:{T:1},1170:{T:-1},1171:{},1172:{T:1},1173:{T:-1},1177:{},1178:{T:1},1180:{},1181:{},1182:{},2048:{T:1},2049:{T:-1},2050:{},2051:{T:1},2052:{T:-1},2053:{},2054:{},2055:{T:1},2056:{T:-1},2057:{T:1},2058:{T:-1},2060:{},2067:{},2068:{T:1},2069:{T:-1},2070:{},2071:{},2072:{T:1},2073:{T:-1},2075:{},2076:{},2077:{T:1},2078:{T:-1},2079:{},2080:{T:1},2081:{T:-1},2082:{},2083:{T:1},2084:{T:-1},2085:{T:1},2086:{T:-1},2087:{T:1},2088:{T:-1},2089:{T:1},2090:{T:-1},2091:{},2092:{},2093:{T:1},2094:{T:-1},2095:{},2096:{T:1},2097:{T:-1},2098:{T:1},2099:{T:-1},2100:{T:1},2101:{T:-1},2102:{},2103:{T:1},2104:{T:-1},2105:{},2106:{T:1},2107:{T:-1},2108:{},2109:{T:1},2110:{T:-1},2111:{T:1},2112:{T:-1},2113:{T:1},2114:{T:-1},2115:{},2116:{},2117:{},2118:{T:1},2119:{T:-1},2120:{},2121:{T:1},2122:{T:-1},2123:{T:1},2124:{T:-1},2125:{},2126:{T:1},2127:{T:-1},2128:{},2129:{T:1},2130:{T:-1},2131:{T:1},2132:{T:-1},2133:{T:1},2134:{},2135:{},2136:{},2137:{T:1},2138:{T:-1},2139:{T:1},2140:{T:-1},2141:{},3072:{},3073:{},4096:{T:1},4097:{T:-1},5002:{T:1},5003:{T:-1},5081:{T:1},5082:{T:-1},5083:{},5084:{T:1},5085:{T:-1},5086:{T:1},5087:{T:-1},5088:{},5089:{},5090:{},5092:{T:1},5093:{T:-1},5094:{},5095:{T:1},5096:{T:-1},5097:{},5099:{},65535:{n:""}};function or(e,r,a,s){var n=r;if(!isNaN(n)){var i=s||(a||[]).length||0,o=e.next(4);o.write_shift(2,n),o.write_shift(2,i),i>0&&lS(a)&&e.push(a)}}function Bee(e,r,a,s){var n=(a||[]).length||0;if(n<=8224)return or(e,r,a,n);var i=r;if(!isNaN(i)){for(var o=a.parts||[],l=0,c=0,u=0;u+(o[l]||8224)<=8224;)u+=o[l]||8224,l++;var h=e.next(4);for(h.write_shift(2,i),h.write_shift(2,u),e.push(a.slice(c,c+u)),c+=u;c<n;){for(h=e.next(4),h.write_shift(2,60),u=0;u+(o[l]||8224)<=8224;)u+=o[l]||8224,l++;h.write_shift(2,u),e.push(a.slice(c,c+u)),c+=u}}}function Ex(e,r,a){return e||(e=Ft(7)),e.write_shift(2,r),e.write_shift(2,a),e.write_shift(2,0),e.write_shift(1,0),e}function Wee(e,r,a,s){var n=Ft(9);return Ex(n,e,r),KR(a,s||"b",n),n}function Hee(e,r,a){var s=Ft(8+2*a.length);return Ex(s,e,r),s.write_shift(1,a.length),s.write_shift(a.length,a,"sbcs"),s.l<s.length?s.slice(0,s.l):s}function qee(e,r,a,s){if(r.v!=null)switch(r.t){case"d":case"n":var n=r.t=="d"?co(Mi(r.v)):r.v;n==(n|0)&&n>=0&&n<65536?or(e,2,nJ(a,s,n)):or(e,3,sJ(a,s,n));return;case"b":case"e":or(e,5,Wee(a,s,r.v,r.t));return;case"s":case"str":or(e,4,Hee(a,s,(r.v||"").slice(0,255)));return}or(e,1,Ex(null,a,s))}function Vee(e,r,a,s){var n=Array.isArray(r),i=vs(r["!ref"]||"A1"),o,l="",c=[];if(i.e.c>255||i.e.r>16383){if(s.WTF)throw new Error("Range "+(r["!ref"]||"A1")+" exceeds format limit A1:IV16384");i.e.c=Math.min(i.e.c,255),i.e.r=Math.min(i.e.c,16383),o=ln(i)}for(var u=i.s.r;u<=i.e.r;++u){l=ai(u);for(var h=i.s.c;h<=i.e.c;++h){u===i.s.r&&(c[h]=gi(h)),o=c[h]+l;var f=n?(r[u]||[])[h]:r[o];f&&qee(e,f,u,h)}}}function Gee(e,r){for(var a=r||{},s=io(),n=0,i=0;i<e.SheetNames.length;++i)e.SheetNames[i]==a.sheet&&(n=i);if(n==0&&a.sheet&&e.SheetNames[0]!=a.sheet)throw new Error("Sheet not found: "+a.sheet);return or(s,a.biff==4?1033:a.biff==3?521:9,pS(e,16,a)),Vee(s,e.Sheets[e.SheetNames[n]],n,a),or(s,10),s.end()}function Kee(e,r,a){or(e,49,UY({sz:12,name:"Arial"},a))}function Yee(e,r,a){r&&[[5,8],[23,26],[41,44],[50,392]].forEach(function(s){for(var n=s[0];n<=s[1];++n)r[n]!=null&&or(e,1054,HY(n,r[n],a))})}function Jee(e,r){var a=Ft(19);a.write_shift(4,2151),a.write_shift(4,0),a.write_shift(4,0),a.write_shift(2,3),a.write_shift(1,1),a.write_shift(4,0),or(e,2151,a),a=Ft(39),a.write_shift(4,2152),a.write_shift(4,0),a.write_shift(4,0),a.write_shift(2,3),a.write_shift(1,0),a.write_shift(4,0),a.write_shift(2,1),a.write_shift(4,4),a.write_shift(2,0),ZR(vs(r["!ref"]||"A1"),a),a.write_shift(4,4),or(e,2152,a)}function Zee(e,r){for(var a=0;a<16;++a)or(e,224,YE({numFmtId:0,style:!0},0,r));r.cellXfs.forEach(function(s){or(e,224,YE(s,0,r))})}function Xee(e,r){for(var a=0;a<r["!links"].length;++a){var s=r["!links"][a];or(e,440,XY(s)),s[1].Tooltip&&or(e,2048,QY(s))}delete r["!links"]}function Qee(e,r){if(r){var a=0;r.forEach(function(s,n){++a<=256&&s&&or(e,125,rJ(tw(n,s),n))})}}function ete(e,r,a,s,n){var i=16+s0(n.cellXfs,r,n);if(r.v==null&&!r.bf){or(e,513,_m(a,s,i));return}if(r.bf)or(e,6,kX(r,a,s,n,i));else switch(r.t){case"d":case"n":var o=r.t=="d"?co(Mi(r.v)):r.v;or(e,515,KY(a,s,o,i));break;case"b":case"e":or(e,517,GY(a,s,r.v,i,n,r.t));break;case"s":case"str":if(n.bookSST){var l=bS(n.Strings,r.v,n.revStrings);or(e,253,BY(a,s,l,i))}else or(e,516,WY(a,s,(r.v||"").slice(0,255),i,n));break;default:or(e,513,_m(a,s,i))}}function tte(e,r,a){var s=io(),n=a.SheetNames[e],i=a.Sheets[n]||{},o=(a||{}).Workbook||{},l=(o.Sheets||[])[e]||{},c=Array.isArray(i),u=r.biff==8,h,f="",y=[],b=vs(i["!ref"]||"A1"),w=u?65536:16384;if(b.e.c>255||b.e.r>=w){if(r.WTF)throw new Error("Range "+(i["!ref"]||"A1")+" exceeds format limit A1:IV16384");b.e.c=Math.min(b.e.c,255),b.e.r=Math.min(b.e.c,w-1)}or(s,2057,pS(a,16,r)),or(s,13,hl(1)),or(s,12,hl(100)),or(s,15,Oi(!0)),or(s,17,Oi(!1)),or(s,16,jm(.001)),or(s,95,Oi(!0)),or(s,42,Oi(!1)),or(s,43,Oi(!1)),or(s,130,hl(1)),or(s,128,VY()),or(s,131,Oi(!1)),or(s,132,Oi(!1)),u&&Qee(s,i["!cols"]),or(s,512,qY(b,r)),u&&(i["!links"]=[]);for(var v=b.s.r;v<=b.e.r;++v){f=ai(v);for(var k=b.s.c;k<=b.e.c;++k){v===b.s.r&&(y[k]=gi(k)),h=y[k]+f;var S=c?(i[v]||[])[k]:i[h];S&&(ete(s,S,v,k,r),u&&S.l&&i["!links"].push([h,S.l]))}}var N=l.CodeName||l.name||n;return u&&or(s,574,$Y((o.Views||[])[0])),u&&(i["!merges"]||[]).length&&or(s,229,ZY(i["!merges"])),u&&Xee(s,i),or(s,442,JR(N)),u&&Jee(s,i),or(s,10),s.end()}function rte(e,r,a){var s=io(),n=(e||{}).Workbook||{},i=n.Sheets||[],o=n.WBProps||{},l=a.biff==8,c=a.biff==5;if(or(s,2057,pS(e,5,a)),a.bookType=="xla"&&or(s,135),or(s,225,l?hl(1200):null),or(s,193,CY(2)),c&&or(s,191),c&&or(s,192),or(s,226),or(s,92,LY("SheetJS",a)),or(s,66,hl(l?1200:1252)),l&&or(s,353,hl(0)),l&&or(s,448),or(s,317,aJ(e.SheetNames.length)),l&&e.vbaraw&&or(s,211),l&&e.vbaraw){var u=o.CodeName||"ThisWorkbook";or(s,442,JR(u))}or(s,156,hl(17)),or(s,25,Oi(!1)),or(s,18,Oi(!1)),or(s,19,hl(0)),l&&or(s,431,Oi(!1)),l&&or(s,444,hl(0)),or(s,61,zY()),or(s,64,Oi(!1)),or(s,141,hl(0)),or(s,34,Oi(oee(e)=="true")),or(s,14,Oi(!0)),l&&or(s,439,Oi(!1)),or(s,218,hl(0)),Kee(s,e,a),Yee(s,e.SSF,a),Zee(s,a),l&&or(s,352,Oi(!1));var h=s.end(),f=io();l&&or(f,140,eJ()),l&&a.Strings&&Bee(f,252,IY(a.Strings)),or(f,10);var y=f.end(),b=io(),w=0,v=0;for(v=0;v<e.SheetNames.length;++v)w+=(l?12:11)+(l?2:1)*e.SheetNames[v].length;var k=h.length+w+y.length;for(v=0;v<e.SheetNames.length;++v){var S=i[v]||{};or(b,133,FY({pos:k,hs:S.Hidden||0,dt:0,name:e.SheetNames[v]},a)),k+=r[v].length}var N=b.end();if(w!=N.length)throw new Error("BS8 "+w+" != "+N.length);var C=[];return h.length&&C.push(h),N.length&&C.push(N),y.length&&C.push(y),Qn(C)}function ate(e,r){var a=r||{},s=[];e&&!e.SSF&&(e.SSF=uo(Hs)),e&&e.SSF&&(J1(),Y1(e.SSF),a.revssf=Z1(e.SSF),a.revssf[e.SSF[65535]]=0,a.ssf=e.SSF),a.Strings=[],a.Strings.Count=0,a.Strings.Unique=0,vS(a),a.cellXfs=[],s0(a.cellXfs,{},{revssf:{General:0}}),e.Props||(e.Props={});for(var n=0;n<e.SheetNames.length;++n)s[s.length]=tte(n,a,e);return s.unshift(rte(e,s,a)),Qn(s)}function _M(e,r){for(var a=0;a<=e.SheetNames.length;++a){var s=e.Sheets[e.SheetNames[a]];if(!(!s||!s["!ref"])){var n=Wo(s["!ref"]);n.e.c>255&&typeof console!="undefined"&&console.error&&console.error("Worksheet '"+e.SheetNames[a]+"' extends beyond column IV (255). Data may be lost.")}}var i=r||{};switch(i.biff||2){case 8:case 5:return ate(e,r);case 4:case 3:case 2:return Gee(e,r)}throw new Error("invalid type "+i.bookType+" for BIFF")}function ste(e,r,a,s){for(var n=e["!merges"]||[],i=[],o=r.s.c;o<=r.e.c;++o){for(var l=0,c=0,u=0;u<n.length;++u)if(!(n[u].s.r>a||n[u].s.c>o)&&!(n[u].e.r<a||n[u].e.c<o)){if(n[u].s.r<a||n[u].s.c<o){l=-1;break}l=n[u].e.r-n[u].s.r+1,c=n[u].e.c-n[u].s.c+1;break}if(!(l<0)){var h=Ya({r:a,c:o}),f=s.dense?(e[a]||[])[o]:e[h],y=f&&f.v!=null&&(f.h||MK(f.w||(Yd(f),f.w)||""))||"",b={};l>1&&(b.rowspan=l),c>1&&(b.colspan=c),s.editable?y='<span contenteditable="true">'+y+"</span>":f&&(b["data-t"]=f&&f.t||"z",f.v!=null&&(b["data-v"]=f.v),f.z!=null&&(b["data-z"]=f.z),f.l&&(f.l.Target||"#").charAt(0)!="#"&&(y='<a href="'+f.l.Target+'">'+y+"</a>")),b.id=(s.id||"sjs")+"-"+h,i.push(ir("td",y,b))}}var w="<tr>";return w+i.join("")+"</tr>"}var nte='<html><head><meta charset="utf-8"/><title>SheetJS Table Export</title></head><body>',ite="</body></html>";function ote(e,r,a){var s=[];return s.join("")+"<table"+(a&&a.id?' id="'+a.id+'"':"")+">"}function kM(e,r){var a=r||{},s=a.header!=null?a.header:nte,n=a.footer!=null?a.footer:ite,i=[s],o=Wo(e["!ref"]);a.dense=Array.isArray(e),i.push(ote(e,o,a));for(var l=o.s.r;l<=o.e.r;++l)i.push(ste(e,o,l,a));return i.push("</table>"+n),i.join("")}function NM(e,r,a){var s=a||{},n=0,i=0;if(s.origin!=null)if(typeof s.origin=="number")n=s.origin;else{var o=typeof s.origin=="string"?Rn(s.origin):s.origin;n=o.r,i=o.c}var l=r.getElementsByTagName("tr"),c=Math.min(s.sheetRows||1e7,l.length),u={s:{r:0,c:0},e:{r:n,c:i}};if(e["!ref"]){var h=Wo(e["!ref"]);u.s.r=Math.min(u.s.r,h.s.r),u.s.c=Math.min(u.s.c,h.s.c),u.e.r=Math.max(u.e.r,h.e.r),u.e.c=Math.max(u.e.c,h.e.c),n==-1&&(u.e.r=n=h.e.r+1)}var f=[],y=0,b=e["!rows"]||(e["!rows"]=[]),w=0,v=0,k=0,S=0,N=0,C=0;for(e["!cols"]||(e["!cols"]=[]);w<l.length&&v<c;++w){var O=l[w];if(r7(O)){if(s.display)continue;b[v]={hidden:!0}}var T=O.children;for(k=S=0;k<T.length;++k){var P=T[k];if(!(s.display&&r7(P))){var E=P.hasAttribute("data-v")?P.getAttribute("data-v"):P.hasAttribute("v")?P.getAttribute("v"):zK(P.innerHTML),R=P.getAttribute("data-z")||P.getAttribute("z");for(y=0;y<f.length;++y){var z=f[y];z.s.c==S+i&&z.s.r<v+n&&v+n<=z.e.r&&(S=z.e.c+1-i,y=-1)}C=+P.getAttribute("colspan")||1,((N=+P.getAttribute("rowspan")||1)>1||C>1)&&f.push({s:{r:v+n,c:S+i},e:{r:v+n+(N||1)-1,c:S+i+(C||1)-1}});var G={t:"s",v:E},ae=P.getAttribute("data-t")||P.getAttribute("t")||"";E!=null&&(E.length==0?G.t=ae||"z":s.raw||E.trim().length==0||ae=="s"||(E==="TRUE"?G={t:"b",v:!0}:E==="FALSE"?G={t:"b",v:!1}:isNaN(Bd(E))?isNaN(Jf(E).getDate())||(G={t:"d",v:Mi(E)},s.cellDates||(G={t:"n",v:co(G.v)}),G.z=s.dateNF||Hs[14]):G={t:"n",v:Bd(E)})),G.z===void 0&&R!=null&&(G.z=R);var ee="",ne=P.getElementsByTagName("A");if(ne&&ne.length)for(var te=0;te<ne.length&&!(ne[te].hasAttribute("href")&&(ee=ne[te].getAttribute("href"),ee.charAt(0)!="#"));++te);ee&&ee.charAt(0)!="#"&&(G.l={Target:ee}),s.dense?(e[v+n]||(e[v+n]=[]),e[v+n][S+i]=G):e[Ya({c:S+i,r:v+n})]=G,u.e.c<S+i&&(u.e.c=S+i),S+=C}}++v}return f.length&&(e["!merges"]=(e["!merges"]||[]).concat(f)),u.e.r=Math.max(u.e.r,v-1+n),e["!ref"]=ln(u),v>=c&&(e["!fullref"]=ln((u.e.r=l.length-w+v-1+n,u))),e}function SM(e,r){var a=r||{},s=a.dense?[]:{};return NM(s,e,r)}function lte(e,r){return Fm(SM(e,r),r)}function r7(e){var r="",a=cte(e);return a&&(r=a(e).getPropertyValue("display")),r||(r=e.style&&e.style.display),r==="none"}function cte(e){return e.ownerDocument.defaultView&&typeof e.ownerDocument.defaultView.getComputedStyle=="function"?e.ownerDocument.defaultView.getComputedStyle:typeof getComputedStyle=="function"?getComputedStyle:null}var dte=(function(){var e=["<office:master-styles>",'<style:master-page style:name="mp1" style:page-layout-name="mp1">',"<style:header/>",'<style:header-left style:display="false"/>',"<style:footer/>",'<style:footer-left style:display="false"/>',"</style:master-page>","</office:master-styles>"].join(""),r="<office:document-styles "+Xf({"xmlns:office":"urn:oasis:names:tc:opendocument:xmlns:office:1.0","xmlns:table":"urn:oasis:names:tc:opendocument:xmlns:table:1.0","xmlns:style":"urn:oasis:names:tc:opendocument:xmlns:style:1.0","xmlns:text":"urn:oasis:names:tc:opendocument:xmlns:text:1.0","xmlns:draw":"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0","xmlns:fo":"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0","xmlns:xlink":"http://www.w3.org/1999/xlink","xmlns:dc":"http://purl.org/dc/elements/1.1/","xmlns:number":"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0","xmlns:svg":"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0","xmlns:of":"urn:oasis:names:tc:opendocument:xmlns:of:1.2","office:version":"1.2"})+">"+e+"</office:document-styles>";return function(){return mn+r}})(),a7=(function(){var e=function(i){return Ka(i).replace(/ +/g,function(o){return'<text:s text:c="'+o.length+'"/>'}).replace(/\t/g,"<text:tab/>").replace(/\n/g,"</text:p><text:p>").replace(/^ /,"<text:s/>").replace(/ $/,"<text:s/>")},r=` <table:table-cell />
|
||
`,a=` <table:covered-table-cell/>
|
||
`,s=function(i,o,l){var c=[];c.push(' <table:table table:name="'+Ka(o.SheetNames[l])+`" table:style-name="ta1">
|
||
`);var u=0,h=0,f=Wo(i["!ref"]||"A1"),y=i["!merges"]||[],b=0,w=Array.isArray(i);if(i["!cols"])for(h=0;h<=f.e.c;++h)c.push(" <table:table-column"+(i["!cols"][h]?' table:style-name="co'+i["!cols"][h].ods+'"':"")+`></table:table-column>
|
||
`);var v="",k=i["!rows"]||[];for(u=0;u<f.s.r;++u)v=k[u]?' table:style-name="ro'+k[u].ods+'"':"",c.push(" <table:table-row"+v+`></table:table-row>
|
||
`);for(;u<=f.e.r;++u){for(v=k[u]?' table:style-name="ro'+k[u].ods+'"':"",c.push(" <table:table-row"+v+`>
|
||
`),h=0;h<f.s.c;++h)c.push(r);for(;h<=f.e.c;++h){var S=!1,N={},C="";for(b=0;b!=y.length;++b)if(!(y[b].s.c>h)&&!(y[b].s.r>u)&&!(y[b].e.c<h)&&!(y[b].e.r<u)){(y[b].s.c!=h||y[b].s.r!=u)&&(S=!0),N["table:number-columns-spanned"]=y[b].e.c-y[b].s.c+1,N["table:number-rows-spanned"]=y[b].e.r-y[b].s.r+1;break}if(S){c.push(a);continue}var O=Ya({r:u,c:h}),T=w?(i[u]||[])[h]:i[O];if(T&&T.f&&(N["table:formula"]=Ka(AX(T.f)),T.F&&T.F.slice(0,O.length)==O)){var P=Wo(T.F);N["table:number-matrix-columns-spanned"]=P.e.c-P.s.c+1,N["table:number-matrix-rows-spanned"]=P.e.r-P.s.r+1}if(!T){c.push(r);continue}switch(T.t){case"b":C=T.v?"TRUE":"FALSE",N["office:value-type"]="boolean",N["office:boolean-value"]=T.v?"true":"false";break;case"n":C=T.w||String(T.v||0),N["office:value-type"]="float",N["office:value"]=T.v||0;break;case"s":case"str":C=T.v==null?"":T.v,N["office:value-type"]="string";break;case"d":C=T.w||Mi(T.v).toISOString(),N["office:value-type"]="date",N["office:date-value"]=Mi(T.v).toISOString(),N["table:style-name"]="ce1";break;default:c.push(r);continue}var E=e(C);if(T.l&&T.l.Target){var R=T.l.Target;R=R.charAt(0)=="#"?"#"+OX(R.slice(1)):R,R.charAt(0)!="#"&&!R.match(/^\w+:/)&&(R="../"+R),E=ir("text:a",E,{"xlink:href":R.replace(/&/g,"&")})}c.push(" "+ir("table:table-cell",ir("text:p",E,{}),N)+`
|
||
`)}c.push(` </table:table-row>
|
||
`)}return c.push(` </table:table>
|
||
`),c.join("")},n=function(i,o){i.push(` <office:automatic-styles>
|
||
`),i.push(` <number:date-style style:name="N37" number:automatic-order="true">
|
||
`),i.push(` <number:month number:style="long"/>
|
||
`),i.push(` <number:text>/</number:text>
|
||
`),i.push(` <number:day number:style="long"/>
|
||
`),i.push(` <number:text>/</number:text>
|
||
`),i.push(` <number:year/>
|
||
`),i.push(` </number:date-style>
|
||
`);var l=0;o.SheetNames.map(function(u){return o.Sheets[u]}).forEach(function(u){if(u&&u["!cols"]){for(var h=0;h<u["!cols"].length;++h)if(u["!cols"][h]){var f=u["!cols"][h];if(f.width==null&&f.wpx==null&&f.wch==null)continue;gS(f),f.ods=l;var y=u["!cols"][h].wpx+"px";i.push(' <style:style style:name="co'+l+`" style:family="table-column">
|
||
`),i.push(' <style:table-column-properties fo:break-before="auto" style:column-width="'+y+`"/>
|
||
`),i.push(` </style:style>
|
||
`),++l}}});var c=0;o.SheetNames.map(function(u){return o.Sheets[u]}).forEach(function(u){if(u&&u["!rows"]){for(var h=0;h<u["!rows"].length;++h)if(u["!rows"][h]){u["!rows"][h].ods=c;var f=u["!rows"][h].hpx+"px";i.push(' <style:style style:name="ro'+c+`" style:family="table-row">
|
||
`),i.push(' <style:table-row-properties fo:break-before="auto" style:row-height="'+f+`"/>
|
||
`),i.push(` </style:style>
|
||
`),++c}}}),i.push(` <style:style style:name="ta1" style:family="table" style:master-page-name="mp1">
|
||
`),i.push(` <style:table-properties table:display="true" style:writing-mode="lr-tb"/>
|
||
`),i.push(` </style:style>
|
||
`),i.push(` <style:style style:name="ce1" style:family="table-cell" style:parent-style-name="Default" style:data-style-name="N37"/>
|
||
`),i.push(` </office:automatic-styles>
|
||
`)};return function(o,l){var c=[mn],u=Xf({"xmlns:office":"urn:oasis:names:tc:opendocument:xmlns:office:1.0","xmlns:table":"urn:oasis:names:tc:opendocument:xmlns:table:1.0","xmlns:style":"urn:oasis:names:tc:opendocument:xmlns:style:1.0","xmlns:text":"urn:oasis:names:tc:opendocument:xmlns:text:1.0","xmlns:draw":"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0","xmlns:fo":"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0","xmlns:xlink":"http://www.w3.org/1999/xlink","xmlns:dc":"http://purl.org/dc/elements/1.1/","xmlns:meta":"urn:oasis:names:tc:opendocument:xmlns:meta:1.0","xmlns:number":"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0","xmlns:presentation":"urn:oasis:names:tc:opendocument:xmlns:presentation:1.0","xmlns:svg":"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0","xmlns:chart":"urn:oasis:names:tc:opendocument:xmlns:chart:1.0","xmlns:dr3d":"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0","xmlns:math":"http://www.w3.org/1998/Math/MathML","xmlns:form":"urn:oasis:names:tc:opendocument:xmlns:form:1.0","xmlns:script":"urn:oasis:names:tc:opendocument:xmlns:script:1.0","xmlns:ooo":"http://openoffice.org/2004/office","xmlns:ooow":"http://openoffice.org/2004/writer","xmlns:oooc":"http://openoffice.org/2004/calc","xmlns:dom":"http://www.w3.org/2001/xml-events","xmlns:xforms":"http://www.w3.org/2002/xforms","xmlns:xsd":"http://www.w3.org/2001/XMLSchema","xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","xmlns:sheet":"urn:oasis:names:tc:opendocument:sh33tjs:1.0","xmlns:rpt":"http://openoffice.org/2005/report","xmlns:of":"urn:oasis:names:tc:opendocument:xmlns:of:1.2","xmlns:xhtml":"http://www.w3.org/1999/xhtml","xmlns:grddl":"http://www.w3.org/2003/g/data-view#","xmlns:tableooo":"http://openoffice.org/2009/table","xmlns:drawooo":"http://openoffice.org/2010/draw","xmlns:calcext":"urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0","xmlns:loext":"urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0","xmlns:field":"urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0","xmlns:formx":"urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0","xmlns:css3t":"http://www.w3.org/TR/css3-text/","office:version":"1.2"}),h=Xf({"xmlns:config":"urn:oasis:names:tc:opendocument:xmlns:config:1.0","office:mimetype":"application/vnd.oasis.opendocument.spreadsheet"});l.bookType=="fods"?(c.push("<office:document"+u+h+`>
|
||
`),c.push(UR().replace(/office:document-meta/g,"office:meta"))):c.push("<office:document-content"+u+`>
|
||
`),n(c,o),c.push(` <office:body>
|
||
`),c.push(` <office:spreadsheet>
|
||
`);for(var f=0;f!=o.SheetNames.length;++f)c.push(s(o.Sheets[o.SheetNames[f]],o,f));return c.push(` </office:spreadsheet>
|
||
`),c.push(` </office:body>
|
||
`),l.bookType=="fods"?c.push("</office:document>"):c.push("</office:document-content>"),c.join("")}})();function CM(e,r){if(r.bookType=="fods")return a7(e,r);var a=sS(),s="",n=[],i=[];return s="mimetype",na(a,s,"application/vnd.oasis.opendocument.spreadsheet"),s="content.xml",na(a,s,a7(e,r)),n.push([s,"text/xml"]),i.push([s,"ContentFile"]),s="styles.xml",na(a,s,dte(e,r)),n.push([s,"text/xml"]),i.push([s,"StylesFile"]),s="meta.xml",na(a,s,mn+UR()),n.push([s,"text/xml"]),i.push([s,"MetadataFile"]),s="manifest.rdf",na(a,s,jY(i)),n.push([s,"application/rdf+xml"]),s="META-INF/manifest.xml",na(a,s,vY(n)),a}function Hv(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ute(e){return typeof TextEncoder!="undefined"?new TextEncoder().encode(e):Vl(Zf(e))}function mte(e,r){e:for(var a=0;a<=e.length-r.length;++a){for(var s=0;s<r.length;++s)if(e[a+s]!=r[s])continue e;return!0}return!1}function e0(e){var r=e.reduce(function(n,i){return n+i.length},0),a=new Uint8Array(r),s=0;return e.forEach(function(n){a.set(n,s),s+=n.length}),a}function hte(e,r,a){var s=Math.floor(a==0?0:Math.LOG10E*Math.log(Math.abs(a)))+6176-20,n=a/Math.pow(10,s-6176);e[r+15]|=s>>7,e[r+14]|=(s&127)<<1;for(var i=0;n>=1;++i,n/=256)e[r+i]=n&255;e[r+15]|=a>=0?0:128}function Qf(e,r){var a=r?r[0]:0,s=e[a]&127;e:if(e[a++]>=128&&(s|=(e[a]&127)<<7,e[a++]<128||(s|=(e[a]&127)<<14,e[a++]<128)||(s|=(e[a]&127)<<21,e[a++]<128)||(s+=(e[a]&127)*Math.pow(2,28),++a,e[a++]<128)||(s+=(e[a]&127)*Math.pow(2,35),++a,e[a++]<128)||(s+=(e[a]&127)*Math.pow(2,42),++a,e[a++]<128)))break e;return r&&(r[0]=a),s}function Va(e){var r=new Uint8Array(7);r[0]=e&127;var a=1;e:if(e>127){if(r[a-1]|=128,r[a]=e>>7&127,++a,e<=16383||(r[a-1]|=128,r[a]=e>>14&127,++a,e<=2097151)||(r[a-1]|=128,r[a]=e>>21&127,++a,e<=268435455)||(r[a-1]|=128,r[a]=e/256>>>21&127,++a,e<=34359738367)||(r[a-1]|=128,r[a]=e/65536>>>21&127,++a,e<=4398046511103))break e;r[a-1]|=128,r[a]=e/16777216>>>21&127,++a}return r.slice(0,a)}function bp(e){var r=0,a=e[r]&127;e:if(e[r++]>=128){if(a|=(e[r]&127)<<7,e[r++]<128||(a|=(e[r]&127)<<14,e[r++]<128)||(a|=(e[r]&127)<<21,e[r++]<128))break e;a|=(e[r]&127)<<28}return a}function vn(e){for(var r=[],a=[0];a[0]<e.length;){var s=a[0],n=Qf(e,a),i=n&7;n=Math.floor(n/8);var o=0,l;if(n==0)break;switch(i){case 0:{for(var c=a[0];e[a[0]++]>=128;);l=e.slice(c,a[0])}break;case 5:o=4,l=e.slice(a[0],a[0]+o),a[0]+=o;break;case 1:o=8,l=e.slice(a[0],a[0]+o),a[0]+=o;break;case 2:o=Qf(e,a),l=e.slice(a[0],a[0]+o),a[0]+=o;break;case 3:case 4:default:throw new Error("PB Type ".concat(i," for Field ").concat(n," at offset ").concat(s))}var u={data:l,type:i};r[n]==null?r[n]=[u]:r[n].push(u)}return r}function Kn(e){var r=[];return e.forEach(function(a,s){a.forEach(function(n){n.data&&(r.push(Va(s*8+n.type)),n.type==2&&r.push(Va(n.data.length)),r.push(n.data))})}),e0(r)}function Ul(e){for(var r,a=[],s=[0];s[0]<e.length;){var n=Qf(e,s),i=vn(e.slice(s[0],s[0]+n));s[0]+=n;var o={id:bp(i[1][0].data),messages:[]};i[2].forEach(function(l){var c=vn(l.data),u=bp(c[3][0].data);o.messages.push({meta:c,data:e.slice(s[0],s[0]+u)}),s[0]+=u}),(r=i[3])!=null&&r[0]&&(o.merge=bp(i[3][0].data)>>>0>0),a.push(o)}return a}function Rh(e){var r=[];return e.forEach(function(a){var s=[];s[1]=[{data:Va(a.id),type:0}],s[2]=[],a.merge!=null&&(s[3]=[{data:Va(+!!a.merge),type:0}]);var n=[];a.messages.forEach(function(o){n.push(o.data),o.meta[3]=[{type:0,data:Va(o.data.length)}],s[2].push({data:Kn(o.meta),type:2})});var i=Kn(s);r.push(Va(i.length)),r.push(i),n.forEach(function(o){return r.push(o)})}),e0(r)}function pte(e,r){if(e!=0)throw new Error("Unexpected Snappy chunk type ".concat(e));for(var a=[0],s=Qf(r,a),n=[];a[0]<r.length;){var i=r[a[0]]&3;if(i==0){var o=r[a[0]++]>>2;if(o<60)++o;else{var l=o-59;o=r[a[0]],l>1&&(o|=r[a[0]+1]<<8),l>2&&(o|=r[a[0]+2]<<16),l>3&&(o|=r[a[0]+3]<<24),o>>>=0,o++,a[0]+=l}n.push(r.slice(a[0],a[0]+o)),a[0]+=o;continue}else{var c=0,u=0;if(i==1?(u=(r[a[0]]>>2&7)+4,c=(r[a[0]++]&224)<<3,c|=r[a[0]++]):(u=(r[a[0]++]>>2)+1,i==2?(c=r[a[0]]|r[a[0]+1]<<8,a[0]+=2):(c=(r[a[0]]|r[a[0]+1]<<8|r[a[0]+2]<<16|r[a[0]+3]<<24)>>>0,a[0]+=4)),n=[e0(n)],c==0)throw new Error("Invalid offset 0");if(c>n[0].length)throw new Error("Invalid offset beyond length");if(u>=c)for(n.push(n[0].slice(-c)),u-=c;u>=n[n.length-1].length;)n.push(n[n.length-1]),u-=n[n.length-1].length;n.push(n[0].slice(-c,-c+u))}}var h=e0(n);if(h.length!=s)throw new Error("Unexpected length: ".concat(h.length," != ").concat(s));return h}function Bl(e){for(var r=[],a=0;a<e.length;){var s=e[a++],n=e[a]|e[a+1]<<8|e[a+2]<<16;a+=3,r.push(pte(s,e.slice(a,a+n))),a+=n}if(a!==e.length)throw new Error("data is not a valid framed stream!");return e0(r)}function Mh(e){for(var r=[],a=0;a<e.length;){var s=Math.min(e.length-a,268435455),n=new Uint8Array(4);r.push(n);var i=Va(s),o=i.length;r.push(i),s<=60?(o++,r.push(new Uint8Array([s-1<<2]))):s<=256?(o+=2,r.push(new Uint8Array([240,s-1&255]))):s<=65536?(o+=3,r.push(new Uint8Array([244,s-1&255,s-1>>8&255]))):s<=16777216?(o+=4,r.push(new Uint8Array([248,s-1&255,s-1>>8&255,s-1>>16&255]))):s<=4294967296&&(o+=5,r.push(new Uint8Array([252,s-1&255,s-1>>8&255,s-1>>16&255,s-1>>>24&255]))),r.push(e.slice(a,a+s)),o+=s,n[0]=0,n[1]=o&255,n[2]=o>>8&255,n[3]=o>>16&255,a+=s}return e0(r)}function uk(e,r){var a=new Uint8Array(32),s=Hv(a),n=12,i=0;switch(a[0]=5,e.t){case"n":a[1]=2,hte(a,n,e.v),i|=1,n+=16;break;case"b":a[1]=6,s.setFloat64(n,e.v?1:0,!0),i|=2,n+=8;break;case"s":if(r.indexOf(e.v)==-1)throw new Error("Value ".concat(e.v," missing from SST!"));a[1]=3,s.setUint32(n,r.indexOf(e.v),!0),i|=8,n+=4;break;default:throw"unsupported cell type "+e.t}return s.setUint32(8,i,!0),a.slice(0,n)}function mk(e,r){var a=new Uint8Array(32),s=Hv(a),n=12,i=0;switch(a[0]=3,e.t){case"n":a[2]=2,s.setFloat64(n,e.v,!0),i|=32,n+=8;break;case"b":a[2]=6,s.setFloat64(n,e.v?1:0,!0),i|=32,n+=8;break;case"s":if(r.indexOf(e.v)==-1)throw new Error("Value ".concat(e.v," missing from SST!"));a[2]=3,s.setUint32(n,r.indexOf(e.v),!0),i|=16,n+=4;break;default:throw"unsupported cell type "+e.t}return s.setUint32(4,i,!0),a.slice(0,n)}function Ru(e){var r=vn(e);return Qf(r[1][0].data)}function gte(e,r,a){var s,n,i,o;if(!((s=e[6])!=null&&s[0])||!((n=e[7])!=null&&n[0]))throw"Mutation only works on post-BNC storages!";var l=((o=(i=e[8])==null?void 0:i[0])==null?void 0:o.data)&&bp(e[8][0].data)>0||!1;if(l)throw"Math only works with normal offsets";for(var c=0,u=Hv(e[7][0].data),h=0,f=[],y=Hv(e[4][0].data),b=0,w=[],v=0;v<r.length;++v){if(r[v]==null){u.setUint16(v*2,65535,!0),y.setUint16(v*2,65535);continue}u.setUint16(v*2,h,!0),y.setUint16(v*2,b,!0);var k,S;switch(typeof r[v]){case"string":k=uk({t:"s",v:r[v]},a),S=mk({t:"s",v:r[v]},a);break;case"number":k=uk({t:"n",v:r[v]},a),S=mk({t:"n",v:r[v]},a);break;case"boolean":k=uk({t:"b",v:r[v]},a),S=mk({t:"b",v:r[v]},a);break;default:throw new Error("Unsupported value "+r[v])}f.push(k),h+=k.length,w.push(S),b+=S.length,++c}for(e[2][0].data=Va(c);v<e[7][0].data.length/2;++v)u.setUint16(v*2,65535,!0),y.setUint16(v*2,65535,!0);return e[6][0].data=e0(f),e[3][0].data=e0(w),c}function fte(e,r){if(!r||!r.numbers)throw new Error("Must pass a `numbers` option -- check the README");var a=e.Sheets[e.SheetNames[0]];e.SheetNames.length>1&&console.error("The Numbers writer currently writes only the first table");var s=Wo(a["!ref"]);s.s.r=s.s.c=0;var n=!1;s.e.c>9&&(n=!0,s.e.c=9),s.e.r>49&&(n=!0,s.e.r=49),n&&console.error("The Numbers writer is currently limited to ".concat(ln(s)));var i=qv(a,{range:s,header:1}),o=["~Sh33tJ5~"];i.forEach(function(B){return B.forEach(function(Q){typeof Q=="string"&&o.push(Q)})});var l={},c=[],u=as.read(r.numbers,{type:"base64"});u.FileIndex.map(function(B,Q){return[B,u.FullPaths[Q]]}).forEach(function(B){var Q=B[0],ie=B[1];if(Q.type==2&&Q.name.match(/\.iwa/)){var me=Q.content,he=Bl(me),de=Ul(he);de.forEach(function(xe){c.push(xe.id),l[xe.id]={deps:[],location:ie,type:bp(xe.messages[0].meta[1][0].data)}})}}),c.sort(function(B,Q){return B-Q});var h=c.filter(function(B){return B>1}).map(function(B){return[B,Va(B)]});u.FileIndex.map(function(B,Q){return[B,u.FullPaths[Q]]}).forEach(function(B){var Q=B[0];if(B[1],!!Q.name.match(/\.iwa/)){var ie=Ul(Bl(Q.content));ie.forEach(function(me){me.messages.forEach(function(he){h.forEach(function(de){me.messages.some(function(xe){return bp(xe.meta[1][0].data)!=11006&&mte(xe.data,de[1])})&&l[de[0]].deps.push(me.id)})})})}});for(var f=as.find(u,l[1].location),y=Ul(Bl(f.content)),b,w=0;w<y.length;++w){var v=y[w];v.id==1&&(b=v)}var k=Ru(vn(b.messages[0].data)[1][0].data);for(f=as.find(u,l[k].location),y=Ul(Bl(f.content)),w=0;w<y.length;++w)v=y[w],v.id==k&&(b=v);for(k=Ru(vn(b.messages[0].data)[2][0].data),f=as.find(u,l[k].location),y=Ul(Bl(f.content)),w=0;w<y.length;++w)v=y[w],v.id==k&&(b=v);for(k=Ru(vn(b.messages[0].data)[2][0].data),f=as.find(u,l[k].location),y=Ul(Bl(f.content)),w=0;w<y.length;++w)v=y[w],v.id==k&&(b=v);var S=vn(b.messages[0].data);{S[6][0].data=Va(s.e.r+1),S[7][0].data=Va(s.e.c+1);var N=Ru(S[46][0].data),C=as.find(u,l[N].location),O=Ul(Bl(C.content));{for(var T=0;T<O.length&&O[T].id!=N;++T);if(O[T].id!=N)throw"Bad ColumnRowUIDMapArchive";var P=vn(O[T].messages[0].data);P[1]=[],P[2]=[],P[3]=[];for(var E=0;E<=s.e.c;++E){var R=[];R[1]=R[2]=[{type:0,data:Va(E+420690)}],P[1].push({type:2,data:Kn(R)}),P[2].push({type:0,data:Va(E)}),P[3].push({type:0,data:Va(E)})}P[4]=[],P[5]=[],P[6]=[];for(var z=0;z<=s.e.r;++z)R=[],R[1]=R[2]=[{type:0,data:Va(z+726270)}],P[4].push({type:2,data:Kn(R)}),P[5].push({type:0,data:Va(z)}),P[6].push({type:0,data:Va(z)});O[T].messages[0].data=Kn(P)}C.content=Mh(Rh(O)),C.size=C.content.length,delete S[46];var G=vn(S[4][0].data);{G[7][0].data=Va(s.e.r+1);var ae=vn(G[1][0].data),ee=Ru(ae[2][0].data);C=as.find(u,l[ee].location),O=Ul(Bl(C.content));{if(O[0].id!=ee)throw"Bad HeaderStorageBucket";var ne=vn(O[0].messages[0].data);for(z=0;z<i.length;++z){var te=vn(ne[2][0].data);te[1][0].data=Va(z),te[4][0].data=Va(i[z].length),ne[2][z]={type:ne[2][0].type,data:Kn(te)}}O[0].messages[0].data=Kn(ne)}C.content=Mh(Rh(O)),C.size=C.content.length;var Y=Ru(G[2][0].data);C=as.find(u,l[Y].location),O=Ul(Bl(C.content));{if(O[0].id!=Y)throw"Bad HeaderStorageBucket";for(ne=vn(O[0].messages[0].data),E=0;E<=s.e.c;++E)te=vn(ne[2][0].data),te[1][0].data=Va(E),te[4][0].data=Va(s.e.r+1),ne[2][E]={type:ne[2][0].type,data:Kn(te)};O[0].messages[0].data=Kn(ne)}C.content=Mh(Rh(O)),C.size=C.content.length;var q=Ru(G[4][0].data);(function(){for(var B=as.find(u,l[q].location),Q=Ul(Bl(B.content)),ie,me=0;me<Q.length;++me){var he=Q[me];he.id==q&&(ie=he)}var de=vn(ie.messages[0].data);{de[3]=[];var xe=[];o.forEach(function(K,ye){xe[1]=[{type:0,data:Va(ye)}],xe[2]=[{type:0,data:Va(1)}],xe[3]=[{type:2,data:ute(K)}],de[3].push({type:2,data:Kn(xe)})})}ie.messages[0].data=Kn(de);var ge=Rh(Q),be=Mh(ge);B.content=be,B.size=B.content.length})();var H=vn(G[3][0].data);{var U=H[1][0];delete H[2];var re=vn(U.data);{var X=Ru(re[2][0].data);(function(){for(var B=as.find(u,l[X].location),Q=Ul(Bl(B.content)),ie,me=0;me<Q.length;++me){var he=Q[me];he.id==X&&(ie=he)}var de=vn(ie.messages[0].data);{delete de[6],delete H[7];var xe=new Uint8Array(de[5][0].data);de[5]=[];for(var ge=0,be=0;be<=s.e.r;++be){var K=vn(xe);ge+=gte(K,i[be],o),K[1][0].data=Va(be),de[5].push({data:Kn(K),type:2})}de[1]=[{type:0,data:Va(s.e.c+1)}],de[2]=[{type:0,data:Va(s.e.r+1)}],de[3]=[{type:0,data:Va(ge)}],de[4]=[{type:0,data:Va(s.e.r+1)}]}ie.messages[0].data=Kn(de);var ye=Rh(Q),Z=Mh(ye);B.content=Z,B.size=B.content.length})()}U.data=Kn(re)}G[3][0].data=Kn(H)}S[4][0].data=Kn(G)}b.messages[0].data=Kn(S);var V=Rh(y),I=Mh(V);return f.content=I,f.size=f.content.length,u}function xte(e){return function(a){for(var s=0;s!=e.length;++s){var n=e[s];a[n[0]]===void 0&&(a[n[0]]=n[1]),n[2]==="n"&&(a[n[0]]=Number(a[n[0]]))}}}function vS(e){xte([["cellDates",!1],["bookSST",!1],["bookType","xlsx"],["compression",!1],["WTF",!1]])(e)}function yte(e,r){return r.bookType=="ods"?CM(e,r):r.bookType=="numbers"?fte(e,r):r.bookType=="xlsb"?bte(e,r):vte(e,r)}function bte(e,r){lp=1024,e&&!e.SSF&&(e.SSF=uo(Hs)),e&&e.SSF&&(J1(),Y1(e.SSF),r.revssf=Z1(e.SSF),r.revssf[e.SSF[65535]]=0,r.ssf=e.SSF),r.rels={},r.wbrels={},r.Strings=[],r.Strings.Count=0,r.Strings.Unique=0,$f?r.revStrings=new Map:(r.revStrings={},r.revStrings.foo=[],delete r.revStrings.foo);var a=r.bookType=="xlsb"?"bin":"xml",s=cM.indexOf(r.bookType)>-1,n=IR();vS(r=r||{});var i=sS(),o="",l=0;if(r.cellXfs=[],s0(r.cellXfs,{},{revssf:{General:0}}),e.Props||(e.Props={}),o="docProps/core.xml",na(i,o,BR(e.Props,r)),n.coreprops.push(o),Ga(r.rels,2,o,Da.CORE_PROPS),o="docProps/app.xml",!(e.Props&&e.Props.SheetNames))if(!e.Workbook||!e.Workbook.Sheets)e.Props.SheetNames=e.SheetNames;else{for(var c=[],u=0;u<e.SheetNames.length;++u)(e.Workbook.Sheets[u]||{}).Hidden!=2&&c.push(e.SheetNames[u]);e.Props.SheetNames=c}for(e.Props.Worksheets=e.Props.SheetNames.length,na(i,o,HR(e.Props)),n.extprops.push(o),Ga(r.rels,3,o,Da.EXT_PROPS),e.Custprops!==e.Props&&si(e.Custprops||{}).length>0&&(o="docProps/custom.xml",na(i,o,qR(e.Custprops)),n.custprops.push(o),Ga(r.rels,4,o,Da.CUST_PROPS)),l=1;l<=e.SheetNames.length;++l){var h={"!id":{}},f=e.Sheets[e.SheetNames[l-1]],y=(f||{})["!type"]||"sheet";switch(y){case"chart":default:o="xl/worksheets/sheet"+l+"."+a,na(i,o,jee(l-1,o,r,e,h)),n.sheets.push(o),Ga(r.wbrels,-1,"worksheets/sheet"+l+"."+a,Da.WS[0])}if(f){var b=f["!comments"],w=!1,v="";b&&b.length>0&&(v="xl/comments"+l+"."+a,na(i,v,Nee(b,v)),n.comments.push(v),Ga(h,-1,"../comments"+l+"."+a,Da.CMNT),w=!0),f["!legacy"]&&w&&na(i,"xl/drawings/vmlDrawing"+l+".vml",oM(l,f["!comments"])),delete f["!comments"],delete f["!legacy"]}h["!id"].rId1&&na(i,$R(o),xp(h))}return r.Strings!=null&&r.Strings.length>0&&(o="xl/sharedStrings."+a,na(i,o,kee(r.Strings,o,r)),n.strs.push(o),Ga(r.wbrels,-1,"sharedStrings."+a,Da.SST)),o="xl/workbook."+a,na(i,o,wee(e,o)),n.workbooks.push(o),Ga(r.rels,1,o,Da.WB),o="xl/theme/theme1.xml",na(i,o,nM(e.Themes,r)),n.themes.push(o),Ga(r.wbrels,-1,"theme/theme1.xml",Da.THEME),o="xl/styles."+a,na(i,o,_ee(e,o,r)),n.styles.push(o),Ga(r.wbrels,-1,"styles."+a,Da.STY),e.vbaraw&&s&&(o="xl/vbaProject.bin",na(i,o,e.vbaraw),n.vba.push(o),Ga(r.wbrels,-1,"vbaProject.bin",Da.VBA)),o="xl/metadata."+a,na(i,o,See(o)),n.metadata.push(o),Ga(r.wbrels,-1,"metadata."+a,Da.XLMETA),na(i,"[Content_Types].xml",zR(n,r)),na(i,"_rels/.rels",xp(r.rels)),na(i,"xl/_rels/workbook."+a+".rels",xp(r.wbrels)),delete r.revssf,delete r.ssf,i}function vte(e,r){lp=1024,e&&!e.SSF&&(e.SSF=uo(Hs)),e&&e.SSF&&(J1(),Y1(e.SSF),r.revssf=Z1(e.SSF),r.revssf[e.SSF[65535]]=0,r.ssf=e.SSF),r.rels={},r.wbrels={},r.Strings=[],r.Strings.Count=0,r.Strings.Unique=0,$f?r.revStrings=new Map:(r.revStrings={},r.revStrings.foo=[],delete r.revStrings.foo);var a="xml",s=cM.indexOf(r.bookType)>-1,n=IR();vS(r=r||{});var i=sS(),o="",l=0;if(r.cellXfs=[],s0(r.cellXfs,{},{revssf:{General:0}}),e.Props||(e.Props={}),o="docProps/core.xml",na(i,o,BR(e.Props,r)),n.coreprops.push(o),Ga(r.rels,2,o,Da.CORE_PROPS),o="docProps/app.xml",!(e.Props&&e.Props.SheetNames))if(!e.Workbook||!e.Workbook.Sheets)e.Props.SheetNames=e.SheetNames;else{for(var c=[],u=0;u<e.SheetNames.length;++u)(e.Workbook.Sheets[u]||{}).Hidden!=2&&c.push(e.SheetNames[u]);e.Props.SheetNames=c}e.Props.Worksheets=e.Props.SheetNames.length,na(i,o,HR(e.Props)),n.extprops.push(o),Ga(r.rels,3,o,Da.EXT_PROPS),e.Custprops!==e.Props&&si(e.Custprops||{}).length>0&&(o="docProps/custom.xml",na(i,o,qR(e.Custprops)),n.custprops.push(o),Ga(r.rels,4,o,Da.CUST_PROPS));var h=["SheetJ5"];for(r.tcid=0,l=1;l<=e.SheetNames.length;++l){var f={"!id":{}},y=e.Sheets[e.SheetNames[l-1]],b=(y||{})["!type"]||"sheet";switch(b){case"chart":default:o="xl/worksheets/sheet"+l+"."+a,na(i,o,yM(l-1,r,e,f)),n.sheets.push(o),Ga(r.wbrels,-1,"worksheets/sheet"+l+"."+a,Da.WS[0])}if(y){var w=y["!comments"],v=!1,k="";if(w&&w.length>0){var S=!1;w.forEach(function(N){N[1].forEach(function(C){C.T==!0&&(S=!0)})}),S&&(k="xl/threadedComments/threadedComment"+l+"."+a,na(i,k,ZJ(w,h,r)),n.threadedcomments.push(k),Ga(f,-1,"../threadedComments/threadedComment"+l+"."+a,Da.TCMNT)),k="xl/comments"+l+"."+a,na(i,k,lM(w)),n.comments.push(k),Ga(f,-1,"../comments"+l+"."+a,Da.CMNT),v=!0}y["!legacy"]&&v&&na(i,"xl/drawings/vmlDrawing"+l+".vml",oM(l,y["!comments"])),delete y["!comments"],delete y["!legacy"]}f["!id"].rId1&&na(i,$R(o),xp(f))}return r.Strings!=null&&r.Strings.length>0&&(o="xl/sharedStrings."+a,na(i,o,QR(r.Strings,r)),n.strs.push(o),Ga(r.wbrels,-1,"sharedStrings."+a,Da.SST)),o="xl/workbook."+a,na(i,o,wM(e)),n.workbooks.push(o),Ga(r.rels,1,o,Da.WB),o="xl/theme/theme1.xml",na(i,o,nM(e.Themes,r)),n.themes.push(o),Ga(r.wbrels,-1,"theme/theme1.xml",Da.THEME),o="xl/styles."+a,na(i,o,aM(e,r)),n.styles.push(o),Ga(r.wbrels,-1,"styles."+a,Da.STY),e.vbaraw&&s&&(o="xl/vbaProject.bin",na(i,o,e.vbaraw),n.vba.push(o),Ga(r.wbrels,-1,"vbaProject.bin",Da.VBA)),o="xl/metadata."+a,na(i,o,iM()),n.metadata.push(o),Ga(r.wbrels,-1,"metadata."+a,Da.XLMETA),h.length>1&&(o="xl/persons/person.xml",na(i,o,XJ(h)),n.people.push(o),Ga(r.wbrels,-1,"persons/person.xml",Da.PEOPLE)),na(i,"[Content_Types].xml",zR(n,r)),na(i,"_rels/.rels",xp(r.rels)),na(i,"xl/_rels/workbook."+a+".rels",xp(r.wbrels)),delete r.revssf,delete r.ssf,i}function wte(e,r){var a="";switch((r||{}).type||"base64"){case"buffer":return[e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7]];case"base64":a=Kd(e.slice(0,12));break;case"binary":a=e;break;case"array":return[e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7]];default:throw new Error("Unrecognized type "+(r&&r.type||"undefined"))}return[a.charCodeAt(0),a.charCodeAt(1),a.charCodeAt(2),a.charCodeAt(3),a.charCodeAt(4),a.charCodeAt(5),a.charCodeAt(6),a.charCodeAt(7)]}function TM(e,r){switch(r.type){case"base64":case"binary":break;case"buffer":case"array":r.type="";break;case"file":return Nx(r.file,as.write(e,{type:Ia?"buffer":""}));case"string":throw new Error("'string' output type invalid for '"+r.bookType+"' files");default:throw new Error("Unrecognized type "+r.type)}return as.write(e,r)}function jte(e,r){var a=uo(r||{}),s=yte(e,a);return _te(s,a)}function _te(e,r){var a={},s=Ia?"nodebuffer":typeof Uint8Array!="undefined"?"array":"string";if(r.compression&&(a.compression="DEFLATE"),r.password)a.type=s;else switch(r.type){case"base64":a.type="base64";break;case"binary":a.type="string";break;case"string":throw new Error("'string' output type invalid for '"+r.bookType+"' files");case"buffer":case"file":a.type=s;break;default:throw new Error("Unrecognized type "+r.type)}var n=e.FullPaths?as.write(e,{fileType:"zip",type:{nodebuffer:"buffer",string:"binary"}[a.type]||a.type,compression:!!r.compression}):e.generate(a);if(typeof Deno!="undefined"&&typeof n=="string"){if(r.type=="binary"||r.type=="base64")return n;n=new Uint8Array(K1(n))}return r.password&&typeof encrypt_agile!="undefined"?TM(encrypt_agile(n,r.password),r):r.type==="file"?Nx(r.file,n):r.type=="string"?Lf(n):n}function kte(e,r){var a=r||{},s=$ee(e,a);return TM(s,a)}function Ec(e,r,a){a||(a="");var s=a+e;switch(r.type){case"base64":return Yf(Zf(s));case"binary":return Zf(s);case"string":return e;case"file":return Nx(r.file,s,"utf8");case"buffer":return Ia?ru(s,"utf8"):typeof TextEncoder!="undefined"?new TextEncoder().encode(s):Ec(s,{type:"binary"}).split("").map(function(n){return n.charCodeAt(0)})}throw new Error("Unrecognized type "+r.type)}function Nte(e,r){switch(r.type){case"base64":return Yf(e);case"binary":return e;case"string":return e;case"file":return Nx(r.file,e,"binary");case"buffer":return Ia?ru(e,"binary"):e.split("").map(function(a){return a.charCodeAt(0)})}throw new Error("Unrecognized type "+r.type)}function fb(e,r){switch(r.type){case"string":case"base64":case"binary":for(var a="",s=0;s<e.length;++s)a+=String.fromCharCode(e[s]);return r.type=="base64"?Yf(a):r.type=="string"?Lf(a):a;case"file":return Nx(r.file,e);case"buffer":return e;default:throw new Error("Unrecognized type "+r.type)}}function EM(e,r){QG(),dee(e);var a=uo(r||{});if(a.cellStyles&&(a.cellNF=!0,a.sheetStubs=!0),a.type=="array"){a.type="binary";var s=EM(e,a);return a.type="array",K1(s)}var n=0;if(a.sheet&&(typeof a.sheet=="number"?n=a.sheet:n=e.SheetNames.indexOf(a.sheet),!e.SheetNames[n]))throw new Error("Sheet not found: "+a.sheet+" : "+typeof a.sheet);switch(a.bookType||"xlsb"){case"xml":case"xlml":return Ec(Iee(e,a),a);case"slk":case"sylk":return Ec(oJ.from_sheet(e.Sheets[e.SheetNames[n]],a),a);case"htm":case"html":return Ec(kM(e.Sheets[e.SheetNames[n]],a),a);case"txt":return Nte(AM(e.Sheets[e.SheetNames[n]],a),a);case"csv":return Ec(wS(e.Sheets[e.SheetNames[n]],a),a,"\uFEFF");case"dif":return Ec(lJ.from_sheet(e.Sheets[e.SheetNames[n]],a),a);case"dbf":return fb(iJ.from_sheet(e.Sheets[e.SheetNames[n]],a),a);case"prn":return Ec(cJ.from_sheet(e.Sheets[e.SheetNames[n]],a),a);case"rtf":return Ec(fJ.from_sheet(e.Sheets[e.SheetNames[n]],a),a);case"eth":return Ec(XR.from_sheet(e.Sheets[e.SheetNames[n]],a),a);case"fods":return Ec(CM(e,a),a);case"wk1":return fb(JE.sheet_to_wk1(e.Sheets[e.SheetNames[n]],a),a);case"wk3":return fb(JE.book_to_wk3(e,a),a);case"biff2":a.biff||(a.biff=2);case"biff3":a.biff||(a.biff=3);case"biff4":return a.biff||(a.biff=4),fb(_M(e,a),a);case"biff5":a.biff||(a.biff=5);case"biff8":case"xla":case"xls":return a.biff||(a.biff=8),kte(e,a);case"xlsx":case"xlsm":case"xlam":case"xlsb":case"numbers":case"ods":return jte(e,a);default:throw new Error("Unrecognized bookType |"+a.bookType+"|")}}function Ste(e){if(!e.bookType){var r={xls:"biff8",htm:"html",slk:"sylk",socialcalc:"eth",Sh33tJS:"WTF"},a=e.file.slice(e.file.lastIndexOf(".")).toLowerCase();a.match(/^\.[a-z]+$/)&&(e.bookType=a.slice(1)),e.bookType=r[e.bookType]||e.bookType}}function lc(e,r,a){var s={};return s.type="file",s.file=r,Ste(s),EM(e,s)}function Cte(e,r,a,s,n,i,o,l){var c=ai(a),u=l.defval,h=l.raw||!Object.prototype.hasOwnProperty.call(l,"raw"),f=!0,y=n===1?[]:{};if(n!==1)if(Object.defineProperty)try{Object.defineProperty(y,"__rowNum__",{value:a,enumerable:!1})}catch(k){y.__rowNum__=a}else y.__rowNum__=a;if(!o||e[a])for(var b=r.s.c;b<=r.e.c;++b){var w=o?e[a][b]:e[s[b]+c];if(w===void 0||w.t===void 0){if(u===void 0)continue;i[b]!=null&&(y[i[b]]=u);continue}var v=w.v;switch(w.t){case"z":if(v==null)break;continue;case"e":v=v==0?null:void 0;break;case"s":case"d":case"b":case"n":break;default:throw new Error("unrecognized type "+w.t)}if(i[b]!=null){if(v==null)if(w.t=="e"&&v===null)y[i[b]]=null;else if(u!==void 0)y[i[b]]=u;else if(h&&v===null)y[i[b]]=null;else continue;else y[i[b]]=h&&(w.t!=="n"||w.t==="n"&&l.rawNumbers!==!1)?v:Yd(w,v,l);v!=null&&(f=!1)}}return{row:y,isempty:f}}function qv(e,r){if(e==null||e["!ref"]==null)return[];var a={t:"n",v:0},s=0,n=1,i=[],o=0,l="",c={s:{r:0,c:0},e:{r:0,c:0}},u=r||{},h=u.range!=null?u.range:e["!ref"];switch(u.header===1?s=1:u.header==="A"?s=2:Array.isArray(u.header)?s=3:u.header==null&&(s=0),typeof h){case"string":c=vs(h);break;case"number":c=vs(e["!ref"]),c.s.r=h;break;default:c=h}s>0&&(n=0);var f=ai(c.s.r),y=[],b=[],w=0,v=0,k=Array.isArray(e),S=c.s.r,N=0,C={};k&&!e[S]&&(e[S]=[]);var O=u.skipHidden&&e["!cols"]||[],T=u.skipHidden&&e["!rows"]||[];for(N=c.s.c;N<=c.e.c;++N)if(!(O[N]||{}).hidden)switch(y[N]=gi(N),a=k?e[S][N]:e[y[N]+f],s){case 1:i[N]=N-c.s.c;break;case 2:i[N]=y[N];break;case 3:i[N]=u.header[N-c.s.c];break;default:if(a==null&&(a={w:"__EMPTY",t:"s"}),l=o=Yd(a,null,u),v=C[o]||0,!v)C[o]=1;else{do l=o+"_"+v++;while(C[l]);C[o]=v,C[l]=1}i[N]=l}for(S=c.s.r+n;S<=c.e.r;++S)if(!(T[S]||{}).hidden){var P=Cte(e,c,S,y,s,i,k,u);(P.isempty===!1||(s===1?u.blankrows!==!1:u.blankrows))&&(b[w++]=P.row)}return b.length=w,b}var s7=/"/g;function Tte(e,r,a,s,n,i,o,l){for(var c=!0,u=[],h="",f=ai(a),y=r.s.c;y<=r.e.c;++y)if(s[y]){var b=l.dense?(e[a]||[])[y]:e[s[y]+f];if(b==null)h="";else if(b.v!=null){c=!1,h=""+(l.rawNumbers&&b.t=="n"?b.v:Yd(b,null,l));for(var w=0,v=0;w!==h.length;++w)if((v=h.charCodeAt(w))===n||v===i||v===34||l.forceQuotes){h='"'+h.replace(s7,'""')+'"';break}h=="ID"&&(h='"ID"')}else b.f!=null&&!b.F?(c=!1,h="="+b.f,h.indexOf(",")>=0&&(h='"'+h.replace(s7,'""')+'"')):h="";u.push(h)}return l.blankrows===!1&&c?null:u.join(o)}function wS(e,r){var a=[],s=r==null?{}:r;if(e==null||e["!ref"]==null)return"";var n=vs(e["!ref"]),i=s.FS!==void 0?s.FS:",",o=i.charCodeAt(0),l=s.RS!==void 0?s.RS:`
|
||
`,c=l.charCodeAt(0),u=new RegExp((i=="|"?"\\|":i)+"+$"),h="",f=[];s.dense=Array.isArray(e);for(var y=s.skipHidden&&e["!cols"]||[],b=s.skipHidden&&e["!rows"]||[],w=n.s.c;w<=n.e.c;++w)(y[w]||{}).hidden||(f[w]=gi(w));for(var v=0,k=n.s.r;k<=n.e.r;++k)(b[k]||{}).hidden||(h=Tte(e,n,k,f,o,c,i,s),h!=null&&(s.strip&&(h=h.replace(u,"")),(h||s.blankrows!==!1)&&a.push((v++?l:"")+h)));return delete s.dense,a.join("")}function AM(e,r){r||(r={}),r.FS=" ",r.RS=`
|
||
`;var a=wS(e,r);return a}function Ete(e){var r="",a,s="";if(e==null||e["!ref"]==null)return[];var n=vs(e["!ref"]),i="",o=[],l,c=[],u=Array.isArray(e);for(l=n.s.c;l<=n.e.c;++l)o[l]=gi(l);for(var h=n.s.r;h<=n.e.r;++h)for(i=ai(h),l=n.s.c;l<=n.e.c;++l)if(r=o[l]+i,a=u?(e[h]||[])[l]:e[r],s="",a!==void 0){if(a.F!=null){if(r=a.F,!a.f)continue;s=a.f,r.indexOf(":")==-1&&(r=r+":"+r)}if(a.f!=null)s=a.f;else{if(a.t=="z")continue;if(a.t=="n"&&a.v!=null)s=""+a.v;else if(a.t=="b")s=a.v?"TRUE":"FALSE";else if(a.w!==void 0)s="'"+a.w;else{if(a.v===void 0)continue;a.t=="s"?s="'"+a.v:s=""+a.v}}c[c.length]=r+"="+s}return c}function OM(e,r,a){var s=a||{},n=+!s.skipHeader,i=e||{},o=0,l=0;if(i&&s.origin!=null)if(typeof s.origin=="number")o=s.origin;else{var c=typeof s.origin=="string"?Rn(s.origin):s.origin;o=c.r,l=c.c}var u,h={s:{c:0,r:0},e:{c:l,r:o+r.length-1+n}};if(i["!ref"]){var f=vs(i["!ref"]);h.e.c=Math.max(h.e.c,f.e.c),h.e.r=Math.max(h.e.r,f.e.r),o==-1&&(o=f.e.r+1,h.e.r=o+r.length-1+n)}else o==-1&&(o=0,h.e.r=r.length-1+n);var y=s.header||[],b=0;r.forEach(function(v,k){si(v).forEach(function(S){(b=y.indexOf(S))==-1&&(y[b=y.length]=S);var N=v[S],C="z",O="",T=Ya({c:l+b,r:o+k+n});u=ex(i,T),N&&typeof N=="object"&&!(N instanceof Date)?i[T]=N:(typeof N=="number"?C="n":typeof N=="boolean"?C="b":typeof N=="string"?C="s":N instanceof Date?(C="d",s.cellDates||(C="n",N=co(N)),O=s.dateNF||Hs[14]):N===null&&s.nullError&&(C="e",N=0),u?(u.t=C,u.v=N,delete u.w,delete u.R,O&&(u.z=O)):i[T]=u={t:C,v:N},O&&(u.z=O))})}),h.e.c=Math.max(h.e.c,l+y.length-1);var w=ai(o);if(n)for(b=0;b<y.length;++b)i[gi(b+l)+w]={t:"s",v:y[b]};return i["!ref"]=ln(h),i}function Ate(e,r){return OM(null,e,r)}function ex(e,r,a){if(typeof r=="string"){if(Array.isArray(e)){var s=Rn(r);return e[s.r]||(e[s.r]=[]),e[s.r][s.c]||(e[s.r][s.c]={t:"z"})}return e[r]||(e[r]={t:"z"})}return typeof r!="number"?ex(e,Ya(r)):ex(e,Ya({r,c:a||0}))}function Ote(e,r){if(typeof r=="number"){if(r>=0&&e.SheetNames.length>r)return r;throw new Error("Cannot find sheet # "+r)}else if(typeof r=="string"){var a=e.SheetNames.indexOf(r);if(a>-1)return a;throw new Error("Cannot find sheet name |"+r+"|")}else throw new Error("Cannot find sheet |"+r+"|")}function Pte(){return{SheetNames:[],Sheets:{}}}function Dte(e,r,a,s){var n=1;if(!a)for(;n<=65535&&e.SheetNames.indexOf(a="Sheet"+n)!=-1;++n,a=void 0);if(!a||e.SheetNames.length>=65535)throw new Error("Too many worksheets");if(s&&e.SheetNames.indexOf(a)>=0){var i=a.match(/(^.*?)(\d+)$/);n=i&&+i[2]||0;var o=i&&i[1]||a;for(++n;n<=65535&&e.SheetNames.indexOf(a=o+n)!=-1;++n);}if(vM(a),e.SheetNames.indexOf(a)>=0)throw new Error("Worksheet with name |"+a+"| already exists!");return e.SheetNames.push(a),e.Sheets[a]=r,a}function Rte(e,r,a){e.Workbook||(e.Workbook={}),e.Workbook.Sheets||(e.Workbook.Sheets=[]);var s=Ote(e,r);switch(e.Workbook.Sheets[s]||(e.Workbook.Sheets[s]={}),a){case 0:case 1:case 2:break;default:throw new Error("Bad sheet visibility setting "+a)}e.Workbook.Sheets[s].Hidden=a}function Mte(e,r){return e.z=r,e}function PM(e,r,a){return r?(e.l={Target:r},a&&(e.l.Tooltip=a)):delete e.l,e}function Lte(e,r,a){return PM(e,"#"+r,a)}function Fte(e,r,a){e.c||(e.c=[]),e.c.push({t:r,a:a||"SheetJS"})}function Ite(e,r,a,s){for(var n=typeof r!="string"?r:vs(r),i=typeof r=="string"?r:ln(r),o=n.s.r;o<=n.e.r;++o)for(var l=n.s.c;l<=n.e.c;++l){var c=ex(e,o,l);c.t="n",c.F=i,delete c.v,o==n.s.r&&l==n.s.c&&(c.f=a,s&&(c.D=!0))}return e}var Na={encode_col:gi,encode_row:ai,encode_cell:Ya,encode_range:ln,decode_col:dS,decode_row:cS,split_cell:QK,decode_cell:Rn,decode_range:Wo,format_cell:Yd,sheet_add_aoa:PR,sheet_add_json:OM,sheet_add_dom:NM,aoa_to_sheet:Wp,json_to_sheet:Ate,table_to_sheet:SM,table_to_book:lte,sheet_to_csv:wS,sheet_to_txt:AM,sheet_to_json:qv,sheet_to_html:kM,sheet_to_formulae:Ete,sheet_to_row_object_array:qv,sheet_get_cell:ex,book_new:Pte,book_append_sheet:Dte,book_set_sheet_visibility:Rte,cell_set_number_format:Mte,cell_set_hyperlink:PM,cell_set_internal_link:Lte,cell_add_comment:Fte,sheet_set_array_formula:Ite,consts:{SHEET_VISIBLE:0,SHEET_HIDDEN:1,SHEET_VERY_HIDDEN:2}};const zte=({isOpen:e,onClose:r,permittedIssueTypes:a=[],isAdmin:s=!0,defaultWorkOrderType:n=""})=>{const{t:i}=sr(),[o,l]=p.useState(!1),[c,u]=p.useState(null),[h,f]=p.useState([]),[y,b]=p.useState([]),[w,v]=p.useState(!0),[k,S]=p.useState(""),[N,C]=p.useState(""),[O,T]=p.useState(""),[P,E]=p.useState(!1),[R,z]=p.useState([]);p.useEffect(()=>{if(!s)return;J(null,null,function*(){try{const B=yield(yield fetch('/api/resource/Issue Type?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"})).json();B.data&&z(B.data.map(Q=>Q.name))}catch(I){console.error("Error fetching issue types:",I)}})},[s]),p.useEffect(()=>{!s&&a.length===1?T(a[0]):T(n||"")},[a,s,n]);const G="Technicians working Hours",ae=p.useCallback(()=>J(null,null,function*(){l(!0),u(null);try{const V={};k&&(V.from_date=k),N&&(V.to_date=N),O?V.work_order_type=O:!s&&a.length>0&&a.length===1&&(V.work_order_type=a[0]);const B=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:G,filters:V,ignore_prepared_report:1})})).json();if(B.exc)throw new Error(B.exc);if(B.message)if(B.message.columns&&B.message.columns.length>0&&b(B.message.columns),B.message.result){let Q=B.message.result;!s&&a.length>1&&!O&&(Q=Q.filter(ie=>a.includes(ie.work_order_type))),f(Q)}else f([])}catch(V){console.error("Error fetching report:",V),u(V instanceof Error?V.message:"Failed to fetch report data"),f([])}finally{l(!1)}}),[k,N,O,s,a]);p.useEffect(()=>{e&&ae()},[e,ae]),p.useEffect(()=>{const V=I=>{I.key==="Escape"&&e&&r()};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[e,r]),p.useEffect(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="unset",()=>{document.body.style.overflow="unset"}),[e]);const ee=()=>{S(""),C(""),s&&T("")},ne=()=>{const V=h.length,I=h.reduce((Q,ie)=>Q+(parseFloat(ie.total_hours)||0),0),B=V>0?I/V:0;return{totalTechnicians:V,totalHours:I,avgHours:B}},te=()=>{if(h.length!==0){E(!0);try{const I=[y.map(me=>me.label).join(","),...h.map(me=>y.map(he=>{let de=me[he.fieldname]||"";return typeof de=="string"&&(de.includes(",")||de.includes('"')||de.includes(`
|
||
`))&&(de=`"${de.replace(/"/g,'""')}"`),de}).join(","))].join(`
|
||
`),B=new Blob(["\uFEFF"+I],{type:"text/csv;charset=utf-8;"}),Q=URL.createObjectURL(B),ie=document.createElement("a");ie.href=Q,ie.download=`technician_working_hours_${new Date().toISOString().split("T")[0]}.csv`,ie.click(),URL.revokeObjectURL(Q)}finally{E(!1)}}},Y=()=>{if(h.length!==0){E(!0);try{const I=[y.map(me=>me.label),...h.map(me=>y.map(he=>me[he.fieldname]||""))],B=Na.aoa_to_sheet(I),Q=y.map(me=>({wch:me.width?Math.floor(me.width/7):20}));B["!cols"]=Q;const ie=Na.book_new();Na.book_append_sheet(ie,B,"Technician Hours"),lc(ie,`technician_working_hours_${new Date().toISOString().split("T")[0]}.xlsx`)}finally{E(!1)}}},q=()=>{const V=ne(),I=window.open("","_blank");if(!I){alert("Please allow popups for this site to print the report.");return}const B=`
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<title>Technicians Working Hours Report</title>
|
||
<style>
|
||
body { font-family: Arial, sans-serif; margin: 20px; }
|
||
h1 { text-align: center; color: #333; margin-bottom: 20px; }
|
||
.meta { text-align: center; color: #666; margin-bottom: 20px; font-size: 12px; }
|
||
.summary { display: flex; justify-content: center; gap: 30px; margin-bottom: 20px; padding: 15px; background: #f8f9fa; border-radius: 8px; }
|
||
.summary-item { text-align: center; }
|
||
.summary-label { font-size: 11px; color: #666; }
|
||
.summary-value { font-size: 20px; font-weight: bold; color: #333; }
|
||
.summary-value.hours { color: #0891B2; }
|
||
table { width: 100%; border-collapse: collapse; font-size: 12px; }
|
||
th { background-color: #0891B2; color: white; padding: 10px 8px; text-align: left; font-weight: 600; }
|
||
td { padding: 10px 8px; border-bottom: 1px solid #ddd; }
|
||
tr:nth-child(even) { background-color: #f9f9f9; }
|
||
tr:hover { background-color: #f5f5f5; }
|
||
.hours-cell { font-weight: 600; color: #0891B2; }
|
||
@media print {
|
||
body { margin: 0; }
|
||
table { page-break-inside: auto; }
|
||
tr { page-break-inside: avoid; page-break-after: auto; }
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<h1>Technicians Working Hours Report</h1>
|
||
<div class="meta">
|
||
Generated on: ${new Date().toLocaleString()}
|
||
${k?` | From: ${k}`:""}
|
||
${N?` | To: ${N}`:""}
|
||
</div>
|
||
<div class="summary">
|
||
<div class="summary-item">
|
||
<div class="summary-label">Total Technicians</div>
|
||
<div class="summary-value">${V.totalTechnicians}</div>
|
||
</div>
|
||
<div class="summary-item">
|
||
<div class="summary-label">Total Hours</div>
|
||
<div class="summary-value hours">${V.totalHours.toFixed(2)}</div>
|
||
</div>
|
||
<div class="summary-item">
|
||
<div class="summary-label">Average Hours</div>
|
||
<div class="summary-value hours">${V.avgHours.toFixed(2)}</div>
|
||
</div>
|
||
</div>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>#</th>
|
||
${y.map(Q=>`<th>${Q.label}</th>`).join("")}
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
${h.map((Q,ie)=>`
|
||
<tr>
|
||
<td>${ie+1}</td>
|
||
${y.map(me=>{let he=Q[me.fieldname]||"-",de="";return me.fieldname==="total_hours"&&(de="hours-cell",he=typeof he=="number"?he.toFixed(2):he),`<td class="${de}">${he}</td>`}).join("")}
|
||
</tr>
|
||
`).join("")}
|
||
</tbody>
|
||
</table>
|
||
<script>
|
||
window.onload = function() { window.print(); }
|
||
<\/script>
|
||
</body>
|
||
</html>
|
||
`;I.document.write(B),I.document.close()},H=()=>{q()},U=(V,I)=>{if(V==null||V==="")return"-";switch(I.fieldtype){case"Float":return typeof V=="number"?V.toFixed(2):V;case"Date":return new Date(V).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});case"Datetime":return new Date(V).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});default:return String(V)}};if(!e)return null;const re=ne(),X=k||N||O;return t.jsxs("div",{className:"fixed inset-0 z-[80] bg-gray-50 dark:bg-gray-900 flex flex-col",children:[t.jsx("div",{className:"bg-gradient-to-r from-cyan-600 to-blue-600 px-6 py-4 flex-shrink-0 shadow-lg",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("button",{onClick:r,className:"p-2 text-white/80 hover:text-white hover:bg-white/20 rounded-lg transition-colors",title:"Go Back",children:t.jsx(ia,{size:18})}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ea,{className:"text-white text-xl"}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-bold text-white",children:"Technicians Working Hours"}),t.jsxs("p",{className:"text-white/70 text-sm",children:[h.length," technician",h.length!==1?"s":""," found"]})]})]})]}),t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("button",{onClick:r,className:"p-2 text-white/80 hover:text-white hover:bg-white/20 rounded-lg transition-colors",title:"Close (Esc)",children:t.jsx(ht,{size:20})})})]})}),!o&&h.length>0&&t.jsx("div",{className:"bg-white dark:bg-gray-800 px-6 py-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx($d,{className:"text-blue-500 text-2xl"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 font-medium",children:"Total Technicians"}),t.jsx("p",{className:"text-2xl font-bold text-blue-700 dark:text-blue-300",children:re.totalTechnicians})]})]})}),t.jsx("div",{className:"bg-cyan-50 dark:bg-cyan-900/20 rounded-lg p-4 border border-cyan-200 dark:border-cyan-800",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ea,{className:"text-cyan-500 text-2xl"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-cyan-600 dark:text-cyan-400 font-medium",children:"Total Hours Worked"}),t.jsx("p",{className:"text-2xl font-bold text-cyan-700 dark:text-cyan-300",children:re.totalHours.toFixed(2)})]})]})}),t.jsx("div",{className:"bg-purple-50 dark:bg-purple-900/20 rounded-lg p-4 border border-purple-200 dark:border-purple-800",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(yE,{className:"text-purple-500 text-2xl"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-purple-600 dark:text-purple-400 font-medium",children:"Average Hours/Technician"}),t.jsx("p",{className:"text-2xl font-bold text-purple-700 dark:text-purple-300",children:re.avgHours.toFixed(2)})]})]})})]})}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 px-6 py-3 border-b border-gray-200 dark:border-gray-700 flex-shrink-0 shadow-sm",children:[t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("button",{onClick:()=>v(!w),className:"flex items-center gap-2 px-4 py-2 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:[t.jsx(ds,{size:12}),"Filters",X&&t.jsx("span",{className:"bg-cyan-100 dark:bg-cyan-900/50 text-cyan-600 dark:text-cyan-400 px-2 py-0.5 rounded-full text-xs font-bold",children:[k,N,O].filter(Boolean).length}),w?t.jsx(Ja,{size:10}):t.jsx(Fr,{size:10})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:ae,disabled:o,className:"p-2.5 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors disabled:opacity-50",title:"Refresh",children:t.jsx(Ma,{className:o?"animate-spin":"",size:14})}),t.jsxs("div",{className:"flex items-center gap-1 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg overflow-hidden",children:[t.jsxs("button",{onClick:te,disabled:h.length===0||P,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as CSV",children:[t.jsx(ic,{className:"text-green-600",size:14}),t.jsx("span",{children:"CSV"})]}),t.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),t.jsxs("button",{onClick:Y,disabled:h.length===0||P,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as Excel",children:[t.jsx(oc,{className:"text-green-700",size:14}),t.jsx("span",{children:"Excel"})]}),t.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),t.jsxs("button",{onClick:H,disabled:h.length===0,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as PDF",children:[t.jsx(_x,{className:"text-red-600",size:14}),t.jsx("span",{children:"PDF"})]}),t.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),t.jsxs("button",{onClick:q,disabled:h.length===0,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Print",children:[t.jsx(yl,{className:"text-purple-600",size:14}),t.jsx("span",{children:"Print"})]})]})]})]}),w&&t.jsx("div",{className:"mt-4 p-4 bg-gray-50 dark:bg-gray-900/50 rounded-lg border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"From Date"}),t.jsx("input",{type:"date",value:k,onChange:V=>S(V.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-cyan-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"To Date"}),t.jsx("input",{type:"date",value:N,onChange:V=>C(V.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-cyan-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Technical Department"}),!s&&a.length===1?t.jsxs("div",{className:"w-full px-3 py-2 text-sm border border-gray-200 dark:border-gray-600 rounded-lg bg-gray-50 dark:bg-gray-600 text-gray-700 dark:text-gray-300 flex items-center gap-2",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-indigo-400 flex-shrink-0"}),O,t.jsx("span",{className:"ml-auto text-[10px] text-gray-400 dark:text-gray-500 uppercase",children:"Restricted"})]}):t.jsxs("select",{value:O,onChange:V=>T(V.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-cyan-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:"All Departments"}),(s?R:a).map(V=>t.jsx("option",{value:V,children:V},V))]})]}),t.jsx("div",{className:"flex items-end",children:t.jsxs("button",{onClick:ee,disabled:!X,className:"px-4 py-2 text-sm font-medium text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:[t.jsx(ht,{size:12}),"Clear Filters"]})})]})})]}),t.jsxs("div",{className:"flex-1 overflow-auto p-6",children:[o&&t.jsx("div",{className:"flex items-center justify-center py-20",children:t.jsxs("div",{className:"text-center",children:[t.jsx(tr,{className:"animate-spin text-cyan-500 text-5xl mx-auto mb-4"}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-lg",children:"Loading report data..."})]})}),c&&!o&&t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-8 text-center max-w-lg mx-auto",children:[t.jsx("p",{className:"text-red-600 dark:text-red-400 mb-4 text-lg",children:c}),t.jsx("button",{onClick:ae,className:"px-6 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-sm font-medium transition-colors",children:"Try Again"})]}),!o&&!c&&h.length===0&&t.jsxs("div",{className:"text-center py-20",children:[t.jsx(za,{className:"text-gray-300 dark:text-gray-600 text-6xl mx-auto mb-4"}),t.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-xl",children:"No data found"}),t.jsx("p",{className:"text-gray-400 dark:text-gray-500 text-sm mt-2",children:"Try adjusting your date range filters"})]}),!o&&!c&&h.length>0&&t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden shadow-sm",children:t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 sticky top-0",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-600 dark:text-gray-300 uppercase tracking-wider w-16",children:"#"}),y.map((V,I)=>t.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-600 dark:text-gray-300 uppercase tracking-wider whitespace-nowrap",style:{minWidth:V.width||150},children:V.label},I))]})}),t.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:h.map((V,I)=>t.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[t.jsx("td",{className:"px-4 py-3 text-sm text-gray-500 dark:text-gray-400 font-medium",children:I+1}),y.map((B,Q)=>{const ie=V[B.fieldname],me=U(ie,B);return B.fieldname==="total_hours"?t.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:t.jsxs("span",{className:"inline-flex items-center gap-1 px-3 py-1 rounded-full text-sm font-semibold bg-cyan-100 dark:bg-cyan-900/30 text-cyan-700 dark:text-cyan-300",children:[t.jsx(ea,{size:12}),me," hrs"]})},Q):B.fieldname==="engineer"&&ie?t.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:t.jsx("a",{href:`/app/user/${ie}`,target:"_blank",rel:"noopener noreferrer",className:"text-cyan-600 dark:text-cyan-400 hover:underline font-medium text-sm",children:me})},Q):B.fieldname==="technician_name"?t.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-200 dark:bg-gray-600 flex items-center justify-center",children:t.jsx(yE,{className:"text-gray-500 dark:text-gray-400",size:14})}),t.jsx("span",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:me})]})},Q):t.jsx("td",{className:"px-4 py-3 text-sm text-gray-700 dark:text-gray-300",title:typeof ie=="string"&&ie.length>50?ie:void 0,children:t.jsx("div",{className:"max-w-xs truncate",children:me})},Q)})]},I))})]})})})]}),t.jsx("div",{className:"bg-white dark:bg-gray-800 px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex-shrink-0 shadow-inner",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Showing ",h.length," technician",h.length!==1?"s":"",X&&" (filtered)",re.totalHours>0&&t.jsxs("span",{className:"ml-2 text-cyan-600 dark:text-cyan-400",children:["• Total: ",re.totalHours.toFixed(2)," hours"]})]}),t.jsx("button",{onClick:r,className:"px-6 py-2 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-lg text-sm font-medium transition-colors",children:"Close"})]})})]})},$te=({isOpen:e,onClose:r,permittedIssueTypes:a=[],isAdmin:s=!0,defaultWorkOrderType:n=""})=>{const{t:i}=sr(),[o,l]=p.useState(!1),[c,u]=p.useState(null),[h,f]=p.useState([]),[y,b]=p.useState([]),[w,v]=p.useState(!1),[k,S]=p.useState(!1),[N,C]=p.useState([]);p.useEffect(()=>{if(!s)return;J(null,null,function*(){try{const U=yield(yield fetch('/api/resource/Issue Type?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"})).json();U.data&&C(U.data.map(re=>re.name))}catch(H){console.error("Error fetching issue types:",H)}})},[s]);const[O,T]=p.useState("");p.useEffect(()=>{!s&&a.length===1?T(a[0]):T(n||"")},[a,s,n]);const P="Technician Work Order Summary",E=p.useCallback(()=>J(null,null,function*(){l(!0),u(null);try{const q={};O?q.work_order_type=O:!s&&a.length===1&&(q.work_order_type=a[0]);const U=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:P,filters:q,ignore_prepared_report:1})})).json();if(U.exc)throw new Error(U.exc);if(U.message)if(U.message.columns&&U.message.columns.length>0&&b(U.message.columns),U.message.result){let re=U.message.result;!s&&a.length>1&&!O&&(re=re.filter(X=>a.includes(X.work_order_type))),f(re)}else f([])}catch(q){console.error("Error fetching report:",q),u(q instanceof Error?q.message:"Failed to fetch report data"),f([])}finally{l(!1)}}),[O,s,a]);p.useEffect(()=>{e&&E()},[e,E]),p.useEffect(()=>{const q=H=>{H.key==="Escape"&&e&&r()};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},[e,r]),p.useEffect(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="unset",()=>{document.body.style.overflow="unset"}),[e]);const R=()=>{const q=h.length,H=h.reduce((I,B)=>I+(parseInt(B.total)||0),0),U=h.reduce((I,B)=>I+(parseInt(B.completed)||0),0),re=h.reduce((I,B)=>I+(parseInt(B.in_progress)||0),0),X=h.reduce((I,B)=>I+(parseInt(B.open)||0),0),V=H>0?(U/H*100).toFixed(1):"0";return{totalTechnicians:q,totalWorkOrders:H,totalCompleted:U,totalInProgress:re,totalOpen:X,completionRate:V}},z=()=>{if(h.length!==0){S(!0);try{const H=[y.map(V=>V.label).join(","),...h.map(V=>y.map(I=>{let B=V[I.fieldname]||"";return typeof B=="string"&&(B.includes(",")||B.includes('"')||B.includes(`
|
||
`))&&(B=`"${B.replace(/"/g,'""')}"`),B}).join(","))].join(`
|
||
`),U=new Blob(["\uFEFF"+H],{type:"text/csv;charset=utf-8;"}),re=URL.createObjectURL(U),X=document.createElement("a");X.href=re,X.download=`technician_work_order_summary_${new Date().toISOString().split("T")[0]}.csv`,X.click(),URL.revokeObjectURL(re)}finally{S(!1)}}},G=()=>{if(h.length!==0){S(!0);try{const H=[y.map(V=>V.label),...h.map(V=>y.map(I=>V[I.fieldname]||""))],U=Na.aoa_to_sheet(H),re=y.map(V=>({wch:V.width?Math.floor(V.width/7):20}));U["!cols"]=re;const X=Na.book_new();Na.book_append_sheet(X,U,"Work Order Summary"),lc(X,`technician_work_order_summary_${new Date().toISOString().split("T")[0]}.xlsx`)}finally{S(!1)}}},ae=()=>{const q=R(),H=window.open("","_blank");if(!H){alert("Please allow popups for this site to print the report.");return}const U=`
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<title>Technician Work Order Summary Report</title>
|
||
<style>
|
||
body { font-family: Arial, sans-serif; margin: 20px; }
|
||
h1 { text-align: center; color: #333; margin-bottom: 20px; }
|
||
.meta { text-align: center; color: #666; margin-bottom: 20px; font-size: 12px; }
|
||
.summary { display: flex; justify-content: center; gap: 20px; margin-bottom: 20px; padding: 15px; background: #f8f9fa; border-radius: 8px; flex-wrap: wrap; }
|
||
.summary-item { text-align: center; min-width: 100px; }
|
||
.summary-label { font-size: 11px; color: #666; }
|
||
.summary-value { font-size: 20px; font-weight: bold; color: #333; }
|
||
.summary-value.completed { color: #10B981; }
|
||
.summary-value.in-progress { color: #3B82F6; }
|
||
.summary-value.open { color: #F59E0B; }
|
||
table { width: 100%; border-collapse: collapse; font-size: 12px; }
|
||
th { background-color: #8B5CF6; color: white; padding: 10px 8px; text-align: left; font-weight: 600; }
|
||
td { padding: 10px 8px; border-bottom: 1px solid #ddd; }
|
||
tr:nth-child(even) { background-color: #f9f9f9; }
|
||
tr:hover { background-color: #f5f5f5; }
|
||
.count-cell { font-weight: 600; text-align: center; }
|
||
.completed { color: #10B981; }
|
||
.in-progress { color: #3B82F6; }
|
||
.open { color: #F59E0B; }
|
||
@media print {
|
||
body { margin: 0; }
|
||
table { page-break-inside: auto; }
|
||
tr { page-break-inside: avoid; page-break-after: auto; }
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<h1>Technician Work Order Summary Report</h1>
|
||
<div class="meta">
|
||
Generated on: ${new Date().toLocaleString()}
|
||
${O?` | Department: ${O}`:""}
|
||
</div>
|
||
<div class="summary">
|
||
<div class="summary-item">
|
||
<div class="summary-label">Total Technicians</div>
|
||
<div class="summary-value">${q.totalTechnicians}</div>
|
||
</div>
|
||
<div class="summary-item">
|
||
<div class="summary-label">Total Work Orders</div>
|
||
<div class="summary-value">${q.totalWorkOrders}</div>
|
||
</div>
|
||
<div class="summary-item">
|
||
<div class="summary-label">Completed</div>
|
||
<div class="summary-value completed">${q.totalCompleted}</div>
|
||
</div>
|
||
<div class="summary-item">
|
||
<div class="summary-label">In Progress</div>
|
||
<div class="summary-value in-progress">${q.totalInProgress}</div>
|
||
</div>
|
||
<div class="summary-item">
|
||
<div class="summary-label">Open</div>
|
||
<div class="summary-value open">${q.totalOpen}</div>
|
||
</div>
|
||
<div class="summary-item">
|
||
<div class="summary-label">Completion Rate</div>
|
||
<div class="summary-value completed">${q.completionRate}%</div>
|
||
</div>
|
||
</div>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>#</th>
|
||
${y.map(re=>`<th>${re.label}</th>`).join("")}
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
${h.map((re,X)=>`
|
||
<tr>
|
||
<td>${X+1}</td>
|
||
${y.map(V=>{let I=re[V.fieldname]||"-",B="";return V.fieldname==="completed"?B="count-cell completed":V.fieldname==="in_progress"?B="count-cell in-progress":V.fieldname==="open"?B="count-cell open":V.fieldname==="total"&&(B="count-cell"),`<td class="${B}">${I}</td>`}).join("")}
|
||
</tr>
|
||
`).join("")}
|
||
</tbody>
|
||
</table>
|
||
<script>
|
||
window.onload = function() { window.print(); }
|
||
<\/script>
|
||
</body>
|
||
</html>
|
||
`;H.document.write(U),H.document.close()},ee=()=>{ae()},ne=(q,H)=>{if(q==null||q==="")return"-";switch(H.fieldtype){case"Int":return parseInt(q)||0;case"Float":return typeof q=="number"?q.toFixed(2):q;default:return String(q)}};if(!e)return null;const te=R(),Y=!!O;return t.jsxs("div",{className:"fixed inset-0 z-[80] bg-gray-50 dark:bg-gray-900 flex flex-col",children:[t.jsx("div",{className:"bg-gradient-to-r from-purple-600 to-indigo-600 px-6 py-4 flex-shrink-0 shadow-lg",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("button",{onClick:r,className:"p-2 text-white/80 hover:text-white hover:bg-white/20 rounded-lg transition-colors",title:"Go Back",children:t.jsx(ia,{size:18})}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Sv,{className:"text-white text-xl"}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-bold text-white",children:"Technician Work Order Summary"}),t.jsxs("p",{className:"text-white/70 text-sm",children:[h.length," technician",h.length!==1?"s":""," found",O&&t.jsx("span",{className:"ml-2 bg-white/20 px-2 py-0.5 rounded-full text-xs",children:O})]})]})]})]}),t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("button",{onClick:r,className:"p-2 text-white/80 hover:text-white hover:bg-white/20 rounded-lg transition-colors",title:"Close (Esc)",children:t.jsx(ht,{size:20})})})]})}),!o&&h.length>0&&t.jsx("div",{className:"bg-white dark:bg-gray-800 px-6 py-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:t.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4",children:t.jsx("div",{className:"bg-indigo-50 dark:bg-indigo-900/20 rounded-lg p-4 border border-indigo-200 dark:border-indigo-800",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx($d,{className:"text-indigo-500 text-xl"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-indigo-600 dark:text-indigo-400 font-medium",children:"Technicians"}),t.jsx("p",{className:"text-xl font-bold text-indigo-700 dark:text-indigo-300",children:te.totalTechnicians})]})]})})})}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 px-6 py-3 border-b border-gray-200 dark:border-gray-700 flex-shrink-0 shadow-sm",children:[t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("button",{onClick:()=>v(!w),className:"flex items-center gap-2 px-4 py-2 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:[t.jsx(ds,{size:12}),"Filters",Y&&t.jsx("span",{className:"bg-purple-100 dark:bg-purple-900/50 text-purple-600 dark:text-purple-400 px-2 py-0.5 rounded-full text-xs font-bold",children:"1"}),w?t.jsx(Ja,{size:10}):t.jsx(Fr,{size:10})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:E,disabled:o,className:"p-2.5 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors disabled:opacity-50",title:"Refresh",children:t.jsx(Ma,{className:o?"animate-spin":"",size:14})}),t.jsxs("div",{className:"flex items-center gap-1 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg overflow-hidden",children:[t.jsxs("button",{onClick:z,disabled:h.length===0||k,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as CSV",children:[t.jsx(ic,{className:"text-green-600",size:14}),t.jsx("span",{children:"CSV"})]}),t.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),t.jsxs("button",{onClick:G,disabled:h.length===0||k,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as Excel",children:[t.jsx(oc,{className:"text-green-700",size:14}),t.jsx("span",{children:"Excel"})]}),t.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),t.jsxs("button",{onClick:ee,disabled:h.length===0,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as PDF",children:[t.jsx(_x,{className:"text-red-600",size:14}),t.jsx("span",{children:"PDF"})]}),t.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),t.jsxs("button",{onClick:ae,disabled:h.length===0,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Print",children:[t.jsx(yl,{className:"text-purple-600",size:14}),t.jsx("span",{children:"Print"})]})]})]})]}),w&&t.jsx("div",{className:"mt-4 p-4 bg-gray-50 dark:bg-gray-900/50 rounded-lg border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Technical Department"}),!s&&a.length===1?t.jsxs("div",{className:"w-full px-3 py-2 text-sm border border-gray-200 dark:border-gray-600 rounded-lg bg-gray-50 dark:bg-gray-600 text-gray-700 dark:text-gray-300 flex items-center gap-2",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-purple-400 flex-shrink-0"}),O,t.jsx("span",{className:"ml-auto text-[10px] text-gray-400 dark:text-gray-500 uppercase tracking-wide",children:"Restricted"})]}):t.jsxs("select",{value:O,onChange:q=>T(q.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:s?"All Departments":"Select Department"}),(s?N:a).map(q=>t.jsx("option",{value:q,children:q},q))]})]}),t.jsx("div",{}),t.jsx("div",{}),t.jsx("div",{className:"flex items-end",children:s&&t.jsxs("button",{onClick:()=>T(""),disabled:!Y,className:"px-4 py-2 text-sm font-medium text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:[t.jsx(ht,{size:12}),"Clear Filters"]})})]})})]}),t.jsxs("div",{className:"flex-1 overflow-auto p-6",children:[o&&t.jsx("div",{className:"flex items-center justify-center py-20",children:t.jsxs("div",{className:"text-center",children:[t.jsx(tr,{className:"animate-spin text-purple-500 text-5xl mx-auto mb-4"}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-lg",children:"Loading report data..."})]})}),c&&!o&&t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-8 text-center max-w-lg mx-auto",children:[t.jsx("p",{className:"text-red-600 dark:text-red-400 mb-4 text-lg",children:c}),t.jsx("button",{onClick:E,className:"px-6 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-sm font-medium transition-colors",children:"Try Again"})]}),!o&&!c&&h.length===0&&t.jsxs("div",{className:"text-center py-20",children:[t.jsx(za,{className:"text-gray-300 dark:text-gray-600 text-6xl mx-auto mb-4"}),t.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-xl",children:"No data found"}),t.jsx("p",{className:"text-gray-400 dark:text-gray-500 text-sm mt-2",children:"No technicians have been assigned to work orders yet."})]}),!o&&!c&&h.length>0&&t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden shadow-sm",children:t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 sticky top-0",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-600 dark:text-gray-300 uppercase tracking-wider w-16",children:"#"}),y.map((q,H)=>t.jsx("th",{className:`px-4 py-3 text-xs font-semibold text-gray-600 dark:text-gray-300 uppercase tracking-wider whitespace-nowrap ${q.fieldtype==="Int"?"text-center":"text-left"}`,style:{minWidth:q.width||120},children:q.label},H))]})}),t.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:h.map((q,H)=>t.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[t.jsx("td",{className:"px-4 py-3 text-sm text-gray-500 dark:text-gray-400 font-medium",children:H+1}),y.map((U,re)=>{const X=q[U.fieldname],V=ne(X,U);return U.fieldname==="assigned_technician"?t.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-purple-100 dark:bg-purple-900/30 flex items-center justify-center",children:t.jsx(Sv,{className:"text-purple-500 dark:text-purple-400",size:14})}),t.jsx("span",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:V})]})},re):U.fieldname==="total"?t.jsx("td",{className:"px-4 py-3 text-center whitespace-nowrap",children:t.jsx("span",{className:"inline-flex items-center justify-center min-w-[40px] px-3 py-1 rounded-full text-sm font-bold bg-indigo-100 dark:bg-indigo-900/30 text-indigo-700 dark:text-indigo-300",children:V})},re):U.fieldname==="completed"?t.jsx("td",{className:"px-4 py-3 text-center whitespace-nowrap",children:t.jsx("span",{className:"inline-flex items-center justify-center min-w-[40px] px-3 py-1 rounded-full text-sm font-bold bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300",children:V})},re):U.fieldname==="in_progress"?t.jsx("td",{className:"px-4 py-3 text-center whitespace-nowrap",children:t.jsx("span",{className:"inline-flex items-center justify-center min-w-[40px] px-3 py-1 rounded-full text-sm font-bold bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300",children:V})},re):U.fieldname==="open"?t.jsx("td",{className:"px-4 py-3 text-center whitespace-nowrap",children:t.jsx("span",{className:"inline-flex items-center justify-center min-w-[40px] px-3 py-1 rounded-full text-sm font-bold bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300",children:V})},re):t.jsx("td",{className:"px-4 py-3 text-sm text-gray-700 dark:text-gray-300",children:V},re)})]},H))})]})})})]}),t.jsx("div",{className:"bg-white dark:bg-gray-800 px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex-shrink-0 shadow-inner",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Showing ",h.length," technician",h.length!==1?"s":"",O&&t.jsxs("span",{className:"ml-2 text-purple-600 dark:text-purple-400",children:["· ",O]}),te.totalWorkOrders>0&&t.jsxs("span",{className:"ml-2 text-purple-600 dark:text-purple-400",children:["• Total: ",te.totalWorkOrders," work orders • ",t.jsxs("span",{className:"text-green-600",children:[te.totalCompleted," completed"]}),"• ",t.jsxs("span",{className:"text-blue-600",children:[te.totalInProgress," in progress"]}),"• ",t.jsxs("span",{className:"text-amber-600",children:[te.totalOpen," open"]})]})]}),t.jsx("button",{onClick:r,className:"px-6 py-2 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-lg text-sm font-medium transition-colors",children:"Close"})]})})]})},jS=(e="Asset")=>{const[r,a]=p.useState({isAdmin:!1,restrictions:{},permissionFilters:{},targetDoctype:e,loading:!0,error:null}),s=p.useCallback(u=>J(null,null,function*(){const h=u||e;try{a(y=>je(se({},y),{loading:!0,error:null,targetDoctype:h}));const f=yield At.getPermissionFilters(h);return a({isAdmin:f.is_admin,restrictions:f.restrictions||{},permissionFilters:f.filters||{},targetDoctype:h,loading:!1,error:null}),f}catch(f){return console.error(`Error fetching permissions for ${h}:`,f),a(y=>je(se({},y),{loading:!1,error:f instanceof Error?f.message:"Failed to fetch permissions"})),null}}),[e]);p.useEffect(()=>{s()},[s]);const n=p.useCallback(u=>{var h;return((h=r.restrictions[u])==null?void 0:h.values)||[]},[r.restrictions]),i=p.useCallback(u=>r.isAdmin?!1:!!r.restrictions[u],[r.isAdmin,r.restrictions]),o=p.useMemo(()=>!r.isAdmin&&Object.keys(r.restrictions).length>0,[r.isAdmin,r.restrictions]),l=p.useCallback(u=>{if(r.isAdmin)return u;const h=se({},u);for(const[f,y]of Object.entries(r.permissionFilters))if(!h[f])h[f]=y;else if(Array.isArray(y)&&y[0]==="in"){const b=y[1];typeof h[f]=="string"&&!b.includes(h[f])&&(h[f]=["in",[]])}return h},[r.isAdmin,r.permissionFilters]),c=p.useMemo(()=>Object.entries(r.restrictions).map(([u,h])=>({type:u,field:h.field,values:h.values,count:h.count})),[r.restrictions]);return je(se({},r),{refetch:s,switchDoctype:s,getAllowedValues:n,hasRestriction:i,hasAnyRestrictions:o,mergeFilters:l,restrictionsList:c})},Pd=e=>{if(e==null)return!0;const r=String(e).trim().toLowerCase();return r===""||r==="null"||r==="unknown"||r==="undefined"||r==="none"},Ute=()=>{var er,nr,dt,He,it,Ue,Ve;const{t:e}=sr(),{data:r,loading:a}=F9(),{workOrders:s}=I9({},0,0),n=gr.useMemo(()=>(s||[]).filter(lt=>lt.custom_delete_status!=="Deleted"),[s]),{logs:i}=V1({},0,0),{assets:o}=U9({},0,0),[l,c]=p.useState(null),[u,h]=p.useState(null),[f,y]=p.useState(null),[b,w]=p.useState(null),[v,k]=p.useState(null),[S,N]=p.useState(null),[C,O]=p.useState(null),[T,P]=p.useState(null),[E,R]=p.useState({open:0,inProgress:0,completed:0,pendingReview:0,rejected:0,total:0,wfCompleted:0,wfInProgress:0,wfRejected:0}),[z,G]=p.useState({assetsDown:0,avgResponseTime:0,maintenanceEfficiency:0,overdueTasks:0,plannedMaintenance:0});rp("Up & Down Time Chart");const{data:ae}=rp("Work Order Status Chart");rp("Maintenance - Asset wise Count");const{data:ee}=rp("Asset Maintenance Assignees Status Count");rp("Asset Maintenance Frequency Chart");const{restrictions:ne,isAdmin:te}=jS("Work_Order"),Y=gr.useMemo(()=>{var lt;return((lt=ne["Issue Type"])==null?void 0:lt.values)||[]},[JSON.stringify((er=ne["Issue Type"])==null?void 0:er.values)]),[q,H]=p.useState([]);p.useEffect(()=>{J(null,null,function*(){var st;try{const Mt=yield fetch('/api/method/frappe.client.get_value?doctype=User&fieldname=["roles"]&filters={"name":"__user__"}'.replace("__user__",""),{credentials:"include"}),zt=(yield(yield fetch("/api/method/frappe.auth.get_logged_user",{credentials:"include"})).json()).message;if(zt){const Ye=(((st=(yield(yield fetch(`/api/resource/User/${encodeURIComponent(zt)}?fields=["roles"]`,{headers:{Accept:"application/json"},credentials:"include"})).json()).data)==null?void 0:st.roles)||[]).map(kt=>kt.role);H(Ye)}}catch(Mt){console.error("Error fetching user roles:",Mt)}})},[]);const U=te||q.includes("System Manager")||q.includes("Quality Supervisor"),re=te||q.includes("System Manager")||q.includes("Cluster Manager"),[X,V]=p.useState(null),[I,B]=p.useState(null),[Q,ie]=p.useState(!1),[me,he]=p.useState(!1),[de,xe]=p.useState(null),[ge,be]=p.useState(null),[K,ye]=p.useState(!1),[Z,M]=p.useState(!1),[we,pe]=p.useState(null),[le,Fe]=p.useState(!1),[ze,Re]=p.useState(null),[De,Et]=p.useState(!1),[jt,Ie]=p.useState([]),[$e,Qe]=p.useState("");p.useEffect(()=>{J(null,null,function*(){try{const Mt=yield(yield fetch('/api/resource/Issue Type?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"})).json();Mt.data&&Ie(Mt.data.map(Ot=>Ot.name))}catch(st){console.error("Error fetching issue types:",st)}})},[]);const at=gr.useMemo(()=>n?!te&&Y.length>0||!$e?n:n.filter(lt=>lt.work_order_type===$e):[],[n,te,Y,$e]);p.useEffect(()=>{J(null,null,function*(){var st;try{const Mt={};!te&&Y.length>0?Mt.work_order_type=Y.length===1?Y[0]:["in",Y]:$e&&(Mt.work_order_type=$e);const Pt=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:"Technicians working Hours",filters:Mt,ignore_prepared_report:1})})).json();if((st=Pt.message)!=null&&st.result){const zt=Pt.message.result.filter(Ye=>Ye&&typeof Ye=="object"&&!Ye.is_total_row),Tt=zt.map(Ye=>Ye.technician_name||"Unknown"),Gt=zt.map(Ye=>parseFloat(Ye.total_hours)||0);V({labels:Tt,datasets:[{name:"Total Hours",values:Gt,colors:["#6366F1"]}],type:"Bar"})}}catch(Mt){console.error("Error fetching technician hours:",Mt)}})},[Y,te,$e]),p.useEffect(()=>{J(null,null,function*(){var st;try{const Mt={};!te&&Y.length>0?Mt.work_order_type=Y.length===1?Y[0]:["in",Y]:$e&&(Mt.work_order_type=$e);const Pt=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:"Technician Work Order Summary",filters:Mt,ignore_prepared_report:1})})).json();if((st=Pt.message)!=null&&st.result){const zt=Pt.message.result.filter(Ye=>Ye&&typeof Ye=="object"&&!Ye.is_total_row),Tt=zt.map(Ye=>Ye.assigned_technician||"Unknown"),Gt=[{name:"completed",values:zt.map(Ye=>parseFloat(Ye.completed)||0),color:"#10B981"},{name:"in_progress",values:zt.map(Ye=>parseFloat(Ye.in_progress)||0),color:"#3B82F6"},{name:"open",values:zt.map(Ye=>parseFloat(Ye.open)||0),color:"#F59E0B"}].filter(Ye=>Ye.values.some(kt=>kt>0));B({labels:Tt,datasets:Gt,type:"Bar"})}}catch(Mt){console.error("Error fetching technician worked:",Mt)}})},[Y,te,$e]);const Ct=(lt,st)=>{var Pt,zt;const Mt=lt.find(Tt=>(Tt==null?void 0:Tt.fieldname)&&(Tt.fieldname.toLowerCase().includes("work_order_type")||Tt.fieldname.toLowerCase().includes("wo_type")||Tt.fieldname.toLowerCase()==="type"));if(Mt)return Mt.fieldname;const Ot=lt.find(Tt=>(Tt==null?void 0:Tt.label)&&(Tt.label.toLowerCase().includes("wo type")||Tt.label.toLowerCase().includes("work order type")||Tt.label.toLowerCase()==="type"));return Ot?Ot.fieldname:(Pt=lt[1])!=null&&Pt.fieldname?lt[1].fieldname:((zt=lt[0])==null?void 0:zt.fieldname)||Object.keys(st[0]||{})[0]||"name"},vt=(lt,st,Mt)=>{var Tt;const Ot=Gt=>typeof Gt=="number"&&!isNaN(Gt)||typeof Gt=="string"&&Gt!==""&&!isNaN(parseFloat(Gt)),Pt=lt.filter(Gt=>(Gt==null?void 0:Gt.fieldname)&&Gt.fieldname!==Mt&&st.some(Ye=>Ot(Ye[Gt.fieldname]))),zt=Pt.find(Gt=>{const Ye=((Gt.label||"")+(Gt.fieldname||"")).toLowerCase();return Ye.includes("count")||Ye.includes("linked")||Ye.includes("inspection")||Ye.includes("rejection")||Ye.includes("total")||Ye.includes("wo")});return zt?zt.fieldname:((Tt=Pt[0])==null?void 0:Tt.fieldname)||null};return p.useEffect(()=>{if(!U)return;J(null,null,function*(){var st,Mt;try{const Ot={};!te&&Y.length>0?Ot.work_order_type=Y.length===1?Y[0]:Y:$e&&(Ot.work_order_type=$e);const zt=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:"Inspection Linked Work Orders Summary",filters:Ot,ignore_prepared_report:1})})).json();if((st=zt.message)!=null&&st.result){const Tt=zt.message.result.filter(yt=>yt&&typeof yt=="object"&&!yt.is_total_row),Gt=((Mt=zt.message)==null?void 0:Mt.columns)||[],Ye=Ct(Gt,Tt),kt=vt(Gt,Tt,Ye),Yt={};Tt.forEach(yt=>{const Me=yt[Ye]!==null&&yt[Ye]!==void 0&&yt[Ye]!==""?String(yt[Ye]):"(No Type)",Ke=kt&&parseFloat(yt[kt])||0;Yt[Me]=(Yt[Me]||0)+Ke});const Ae=Object.keys(Yt),ke=Object.values(Yt),Be=Gt.find(yt=>(yt==null?void 0:yt.fieldname)===kt);xe({labels:Ae,datasets:[{name:(Be==null?void 0:Be.label)||"Count",values:ke}],rawRows:Tt,columns:Gt,type:"Bar"})}}catch(Ot){console.error("Error fetching inspection summary:",Ot)}})},[U,Y,te,$e]),p.useEffect(()=>{if(!U)return;J(null,null,function*(){var st,Mt;try{const Ot={};!te&&Y.length>0?Ot.work_order_type=Y.length===1?Y[0]:Y:$e&&(Ot.work_order_type=$e);const zt=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:"WO Rejection Summary",filters:Ot,ignore_prepared_report:1})})).json();if((st=zt.message)!=null&&st.result){const Tt=zt.message.result.filter(oe=>oe&&typeof oe=="object"&&!oe.is_total_row),Gt=((Mt=zt.message)==null?void 0:Mt.columns)||[],Ye=Ct(Gt,Tt),kt=oe=>typeof oe=="number"&&!isNaN(oe)||typeof oe=="string"&&oe!==""&&!isNaN(parseFloat(oe)),Yt=oe=>{if(!(oe!=null&&oe.fieldname)||oe.fieldname===Ye||!Tt.length)return!1;if(oe.fieldtype&&["Int","Float","Currency","Percent"].includes(oe.fieldtype))return!0;const _e=Tt.find(ve=>ve[oe.fieldname]!=null&&ve[oe.fieldname]!=="");return _e?kt(_e[oe.fieldname]):!1},Ae=Gt.filter(Yt),ke=Ae.length>0?Ae:Gt.filter(oe=>{if(!(oe!=null&&oe.fieldname)||oe.fieldname===Ye||!Tt.length)return!1;const _e=Tt.find(ve=>ve[oe.fieldname]!=null&&ve[oe.fieldname]!=="");return _e?!isNaN(parseFloat(String(_e[oe.fieldname]))):!1}),Be={};Tt.forEach(oe=>{const _e=oe[Ye]!==null&&oe[Ye]!==void 0&&oe[Ye]!==""?String(oe[Ye]):"(No Type)";Be[_e]||(Be[_e]={}),ke.forEach(ve=>{Be[_e][ve.fieldname]=(Be[_e][ve.fieldname]||0)+(parseFloat(oe[ve.fieldname])||0)})});const yt=(()=>{var _e;const oe=ke.find(ve=>{const Se=((ve.label||"")+(ve.fieldname||"")).toLowerCase();return Se.includes("total_rejected")||Se.includes("total rejected")||Se.includes("rejected")});return(oe==null?void 0:oe.fieldname)||((_e=ke[ke.length-1])==null?void 0:_e.fieldname)||null})(),Me=Object.keys(Be),Ke=Me.map(oe=>yt&&Be[oe][yt]||0),Xe=Ke.reduce((oe,_e)=>oe+_e,0);be({labels:Me,datasets:[{name:"Total Rejected",values:Ke}],totalRejected:Xe,rawRows:Tt,columns:Gt,type:"Bar"})}}catch(Ot){console.error("Error fetching rejection summary:",Ot)}})},[U,Y,te,$e]),p.useEffect(()=>{if(o&&o.length>0){let lt=0,st=0;o.forEach(Pt=>{const zt=Pt.custom_up_time||0,Tt=Pt.custom_down_time||0;lt+=typeof zt=="number"?zt:0,st+=typeof Tt=="number"?Tt:0});const Mt=[],Ot=[];if(lt>0&&(Mt.push(e("dashboard.upTime")),Ot.push(lt)),st>0&&(Mt.push(e("dashboard.downTime")),Ot.push(st)),Mt.length>0){const Pt=[];lt>0&&Pt.push("#6366F1"),st>0&&Pt.push("#8B5CF6"),w({labels:Mt,datasets:[{name:"Time",values:Ot,colors:Pt}],type:"Pie"})}else w(null)}else w(null)},[o]),p.useEffect(()=>{if(o&&o.length>0){const lt=o.filter(st=>(st.custom_device_status||"").trim().toLowerCase()==="down").length;G(st=>je(se({},st),{assetsDown:lt}))}},[o]),p.useEffect(()=>{if(o&&o.length>0){const lt={};o.forEach(Tt=>{const Gt=(Tt.custom_device_status||"Unknown").trim();lt[Gt]=(lt[Gt]||0)+1});const st=Object.entries(lt).sort(([,Tt],[,Gt])=>Gt-Tt),Mt=st.map(([Tt])=>Tt),Ot=st.map(([,Tt])=>Tt),Pt={Up:"#10B981",up:"#10B981",Down:"#EF4444",down:"#EF4444","Under Maintenance":"#F59E0B","under maintenance":"#F59E0B",Decommissioned:"#6B7280"},zt=Mt.map((Tt,Gt)=>Pt[Tt]||Pt[Tt.toLowerCase()]||tc(Mt.length)[Gt]);k({labels:Mt,datasets:[{name:"Assets",values:Ot,colors:zt}],type:"Pie",total:o.length})}else k(null)},[o]),p.useEffect(()=>{if(at&&at.length>0){const lt={};let st=0,Mt=0,Ot=0,Pt=0,zt=0;at.forEach(ut=>{const et=ut.repair_status||"Unknown";lt[et]=(lt[et]||0)+1;const nt=et.toLowerCase();nt==="open"&&st++,nt==="work in progress"&&Mt++,nt==="closed"&&Ot++,nt==="pending review"&&Pt++,nt==="rejected"&&zt++});let Tt=0,Gt=0,Ye=0;at.forEach(ut=>{const et=(ut.workflow_state||"").toLowerCase();et==="closed"||et==="sent to supervisor"?Tt++:et==="rejected"?Ye++:Gt++});const kt=["Open","Work In Progress","Pending Review","Closed","Rejected","Cancelled","Unknown"],Yt=Object.entries(lt).sort(([ut],[et])=>{const nt=kt.indexOf(ut),ct=kt.indexOf(et);return nt===-1&&ct===-1?ut.localeCompare(et):nt===-1?1:ct===-1?-1:nt-ct}),Ae=Yt.map(([ut])=>ut),ke=Yt.map(([,ut])=>ut),Be={Open:"#F59E0B","Work In Progress":"#3B82F6","Pending Review":"#E11D48",Pending:"#8B5CF6",Completed:"#10B981",Closed:"#10B981",Rejected:"#EF4444",Cancelled:"#EC4899",Unknown:"#6B7280"},yt=Ae.map(ut=>Be[ut]||"#6366F1");c({labels:Ae,datasets:[{name:"Work Orders",values:ke,colors:yt}],type:"bar"}),R({open:st,inProgress:Mt,completed:Ot,pendingReview:Pt,rejected:zt,total:at.length,wfCompleted:Tt,wfInProgress:Gt,wfRejected:Ye});const Me=ut=>{const et=ut.toLowerCase().trim();return et.includes("open")?"Open":et.includes("work in progress")||et.includes("in progress")||et.includes("wip")?"Work In Progress":et.includes("pending review")||et.includes("pending")?"Pending Review":et.includes("completed")||et.includes("complete")?"Completed":et.includes("closed")?"Closed":et.includes("rejected")?"Rejected":ut},Ke={},Xe=new Set;at.forEach(ut=>{const et=ut.work_order_type;if(Pd(et))return;const nt=String(et),ct=Me(ut.repair_status||"Unknown");Xe.add(ct),Ke[nt]||(Ke[nt]={}),Ke[nt][ct]=(Ke[nt][ct]||0)+1});const oe=Object.keys(Ke),_e=["Open","Work In Progress","Pending Review","Completed","Closed","Rejected"],Se=Array.from(Xe).sort((ut,et)=>{const nt=_e.indexOf(ut),ct=_e.indexOf(et);return nt!==-1&&ct!==-1?nt-ct:nt!==-1?-1:ct!==-1?1:ut.localeCompare(et)}).map(ut=>({name:ut,values:oe.map(et=>Ke[et][ut]||0)}));h({labels:oe,datasets:Se,type:"Bar"});const Ce={};at.forEach(ut=>{const et=ut.work_order_type;if(Pd(et))return;const nt=String(et);Ce[nt]||(Ce[nt]={total:0,wfCompleted:0,wfInProgress:0,wfRejected:0,closed:0,pendingReview:0,open:0,inProgress:0,rejected:0}),Ce[nt].total++;const ct=(ut.workflow_state||"").toLowerCase();ct==="closed"||ct==="sent to supervisor"?Ce[nt].wfCompleted++:ct==="rejected"?Ce[nt].wfRejected++:Ce[nt].wfInProgress++;const $t=(ut.repair_status||"").toLowerCase();$t==="closed"&&Ce[nt].closed++,$t==="pending review"&&Ce[nt].pendingReview++,$t==="open"&&Ce[nt].open++,$t==="work in progress"&&Ce[nt].inProgress++,$t==="rejected"&&Ce[nt].rejected++});const Pe=Object.keys(Ce),rt=Pe.map(ut=>{const et=Ce[ut];return je(se({type:ut},et),{rate:et.total>0?et.wfCompleted/et.total*100:0})});P({labels:Pe,rates:rt})}else h(null),P(null)},[at]),p.useEffect(()=>{if(i&&i.length>0){const lt={};let st=0,Mt=0,Ot=0;const Pt=new Date;i.forEach(Ke=>{var oe,_e;const Xe=Ke.asset_name||"Unknown";lt[Xe]=(lt[Xe]||0)+1,((oe=Ke.maintenance_status)==null?void 0:oe.toLowerCase())==="completed"&&st++,((_e=Ke.maintenance_status)==null?void 0:_e.toLowerCase())==="planned"&&Mt++,Ke.due_date&&new Date(Ke.due_date)<Pt&&Ke.maintenance_status!=="Completed"&&Ot++});const zt=Object.entries(lt).sort(([,Ke],[,Xe])=>Xe-Ke).slice(0,10);y({labels:zt.map(([Ke])=>Ke),datasets:[{name:"Maintenance Count",values:zt.map(([,Ke])=>Ke),colors:tc(zt.length)}],type:"bar"});const Tt=i.length>0?st/i.length*100:0;G(Ke=>je(se({},Ke),{maintenanceEfficiency:Tt,overdueTasks:Ot,plannedMaintenance:Mt}));const Gt={},Ye=new Set,kt=(Ke,Xe)=>{const oe=Ke.toLowerCase().trim(),_e=new Date,ve=Xe.due_date?new Date(Xe.due_date):null;return ve&&ve<_e&&oe!=="completed"&&oe!=="cancelled"?"Overdue":oe.includes("completed on time")||oe==="completed on time"?"Completed On Time":oe.includes("completed within")||oe.includes("within sla")||oe==="completed"?"Completed Within SLA":oe.includes("delay")||oe.includes("late")?"Delay In Completion":oe.includes("pending")||oe==="planned"?"Pending":oe.includes("overdue")?"Overdue":oe.includes("cancelled")||oe==="cancelled"?"Cancelled":Ke};i.forEach(Ke=>{const Xe=Ke.assign_to_name||"null",oe=kt(Ke.maintenance_status||"Unknown",Ke);Ye.add(oe),Gt[Xe]||(Gt[Xe]={}),Gt[Xe][oe]=(Gt[Xe][oe]||0)+1});const Yt=Object.keys(Gt),Ae=["Completed On Time","Completed Within SLA","Delay In Completion","Pending","Overdue","Cancelled"],Be=Array.from(Ye).sort((Ke,Xe)=>{const oe=Ae.indexOf(Ke),_e=Ae.indexOf(Xe);return oe!==-1&&_e!==-1?oe-_e:oe!==-1?-1:_e!==-1?1:Ke.localeCompare(Xe)}).map(Ke=>({name:Ke,values:Yt.map(Xe=>Gt[Xe][Ke]||0)}));N({labels:Yt,datasets:Be,type:"Bar"});const yt={};i.forEach(Ke=>{const Xe=Ke.periodicity||Ke.maintenance_type||"Other";yt[Xe]=(yt[Xe]||0)+1});const Me=Object.entries(yt).sort(([,Ke],[,Xe])=>Xe-Ke);O({labels:Me.map(([Ke])=>Ke),datasets:[{name:"Frequency",values:Me.map(([,Ke])=>Ke),colors:tc(Me.length)}],type:"bar"})}else N(null),O(null)},[i]),p.useEffect(()=>{if(n&&n.length>0){let lt=0,st=0;n.forEach(Ot=>{if(Ot.creation&&Ot.first_responded_on){const Pt=new Date(Ot.creation),Tt=(new Date(Ot.first_responded_on).getTime()-Pt.getTime())/(1e3*60*60);Tt>=0&&(lt+=Tt,st++)}});const Mt=st>0?lt/st:0;G(Ot=>je(se({},Ot),{avgResponseTime:Mt}))}},[n]),p.useEffect(()=>{if(!re)return;J(null,null,function*(){var st,Mt,Ot;try{const Pt={};!te&&Y.length>0?Pt.work_order_type=Y.length===1?Y[0]:Y:$e&&(Pt.work_order_type=$e);const Tt=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:"Time to Repair",filters:Pt,ignore_prepared_report:1})})).json();if((st=Tt.message)!=null&&st.result){const Gt=Tt.message.result.filter(oe=>oe&&typeof oe=="object"&&!oe.is_total_row),Ye=((Mt=Tt.message)==null?void 0:Mt.columns)||[],kt=Ye.find(oe=>{const _e=((oe.label||"")+(oe.fieldname||"")).toLowerCase();return _e.includes("wo_type")||_e.includes("wo type")||_e.includes("work_order_type")||_e.includes("work order type")})||Ye[1],Yt=Ye.find(oe=>{const _e=((oe.label||"")+(oe.fieldname||"")).toLowerCase();return _e.includes("time_to_repair")||_e.includes("time to repair")||_e.includes("repair_time")||_e.includes("hours")})||Ye[Ye.length-1],Ae={};Gt.forEach(oe=>{const _e=kt?oe[kt.fieldname]:null;if(Pd(_e))return;const ve=String(_e),Se=Yt&&parseFloat(oe[Yt.fieldname])||0;Ae[ve]||(Ae[ve]={total:0,count:0}),Ae[ve].total+=Se,Ae[ve].count+=1});const ke=Object.keys(Ae),Be=ke.map(oe=>parseFloat((Ae[oe].total/Ae[oe].count).toFixed(3))),yt=Gt.filter(oe=>!Pd(kt?oe[kt.fieldname]:null)),Me=yt.length>0?parseFloat((yt.reduce((oe,_e)=>oe+(Yt&&parseFloat(_e[Yt.fieldname])||0),0)/yt.length).toFixed(3)):0,Ke=((Ot=Tt.message)==null?void 0:Ot.report_summary)||[],Xe=Ke.find(oe=>{var _e,ve;return((_e=oe.label)==null?void 0:_e.toLowerCase().includes("avg"))||((ve=oe.label)==null?void 0:ve.toLowerCase().includes("overall"))});pe({labels:ke,datasets:[{name:"Avg Time to Repair (hrs)",values:Be}],overallAvg:Xe&&parseFloat(Xe.value)||Me,rawRows:Gt,columns:Ye,reportSummary:Ke,type:"Bar"})}}catch(Pt){console.error("Error fetching time to repair:",Pt)}})},[re,Y,te,$e]),a?t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-600 mx-auto mb-4"}),t.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:e("dashboard.loading")})]})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[t.jsxs("div",{className:"max-w-[1600px] mx-auto",children:[(te||Y.length===0)&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 px-5 py-3 mb-5 flex items-center gap-4 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400",children:[t.jsx("div",{className:"w-7 h-7 bg-indigo-50 dark:bg-indigo-900/30 rounded-lg flex items-center justify-center",children:t.jsx(ds,{className:"text-indigo-500 text-xs"})}),t.jsx("span",{className:"font-semibold text-gray-700 dark:text-gray-300",children:e("dashboard.dashboardFilter","Dashboard Filter")})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Technical Department"}),t.jsxs("select",{value:$e,onChange:lt=>Qe(lt.target.value),className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white min-w-[200px]",children:[t.jsx("option",{value:"",children:e("dashboard.allDepartments","All Departments")}),jt.map(lt=>t.jsx("option",{value:lt,children:lt},lt))]})]}),$e&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>Qe(""),className:"text-xs text-red-500 hover:text-red-700 dark:text-red-400 flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:[t.jsx(ht,{size:10})," ",e("dashboard.clearFilter","Clear")]}),t.jsx("span",{className:"text-xs text-indigo-600 dark:text-indigo-400 bg-indigo-50 dark:bg-indigo-900/30 px-3 py-1 rounded-full font-medium",children:$e})]})]}),t.jsxs("div",{className:"grid grid-cols-12 gap-4 mb-5",style:{gridTemplateRows:"auto 1fr 1fr"},children:[t.jsx("div",{className:"col-span-12 lg:col-span-7",children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 px-4 py-2",children:t.jsxs("div",{className:"grid grid-cols-4 lg:grid-cols-7 divide-x divide-gray-200 dark:divide-gray-700",children:[t.jsx(D0,{icon:t.jsx(zd,{className:"text-indigo-600"}),value:(dt=(nr=o==null?void 0:o.length)!=null?nr:r==null?void 0:r.total_assets)!=null?dt:0,label:e("dashboard.totalAssets"),bgColor:"bg-indigo-50 dark:bg-indigo-900/20",iconColor:"text-indigo-600",href:"/asm_app/assets"}),t.jsx(D0,{icon:t.jsx(dm,{className:"text-amber-500"}),value:E.open||((He=r==null?void 0:r.work_orders_open)!=null?He:0),label:e("dashboard.openWorkOrders"),bgColor:"bg-amber-50 dark:bg-amber-900/20",iconColor:"text-amber-500",href:"/asm_app/work-orders?status=Open"}),t.jsx(D0,{icon:t.jsx(ea,{className:"text-blue-600"}),value:E.inProgress||((it=r==null?void 0:r.work_orders_in_progress)!=null?it:0),label:e("dashboard.workOrdersInProgress"),bgColor:"bg-blue-50 dark:bg-blue-900/20",iconColor:"text-blue-600",href:"/asm_app/work-orders?status=In+Progress"}),t.jsx(D0,{icon:t.jsx(Or,{className:"text-orange-500"}),value:E.pendingReview,label:e("dashboard.pendingReviewWorkOrders","Pending Review"),bgColor:"bg-orange-50 dark:bg-orange-900/20",iconColor:"text-orange-500",href:"/asm_app/work-orders?status=Pending+Review"}),t.jsx(D0,{icon:t.jsx(Qt,{className:"text-emerald-600"}),value:E.completed||((Ue=r==null?void 0:r.work_orders_completed)!=null?Ue:0),label:e("dashboard.closedWorkOrders"),bgColor:"bg-emerald-50 dark:bg-emerald-900/20",iconColor:"text-emerald-600",href:"/asm_app/work-orders?status=Closed"}),t.jsx(D0,{icon:t.jsx(Mo,{className:"text-red-500"}),value:E.rejected,label:e("dashboard.rejectedWorkOrders","Rejected WOs"),bgColor:"bg-red-50 dark:bg-red-900/20",iconColor:"text-red-500",href:"/asm_app/work-orders?status=Rejected"}),t.jsx(D0,{icon:t.jsx(J4,{className:"text-purple-600"}),value:E.total,label:e("dashboard.totalWorkOrders"),bgColor:"bg-purple-50 dark:bg-purple-900/20",iconColor:"text-purple-600",href:"/asm_app/work-orders"})]})})}),t.jsx("div",{className:"col-span-12 lg:col-span-5 lg:row-span-2 flex",children:t.jsx(Gte,{className:"flex-1 w-full",data:l||ae,totalWorkOrders:E.total,completedWorkOrders:E.completed,onOpenReport:()=>Re({title:"Work Order Status Distribution",data:l||ae,redirectContext:"wo_status"})})}),t.jsx("div",{className:"col-span-12 lg:col-span-7 flex",children:t.jsx(Bte,{className:"flex-1 w-full",totalWorkOrders:E.total,completedWorkOrders:E.wfCompleted,inProgressWorkOrders:E.wfInProgress,rejectedWorkOrders:E.wfRejected,byTypeChartData:T,onOpenReport:()=>{const lt=(T==null?void 0:T.rates)||[];Re({title:e("dashboard.completionRate","Completion Rate by Department"),data:{labels:lt.map(st=>st.type),datasets:[{name:"Completion Rate (%)",values:lt.map(st=>parseFloat(st.rate.toFixed(2)))},{name:"WF Completed",values:lt.map(st=>st.wfCompleted)},{name:"In Progress",values:lt.map(st=>st.wfInProgress)},{name:"Rejected (WF)",values:lt.map(st=>st.wfRejected)},{name:"Closed WOs",values:lt.map(st=>st.closed)},{name:"Pending Review",values:lt.map(st=>st.pendingReview)},{name:"Open",values:lt.map(st=>st.open)},{name:"Total",values:lt.map(st=>st.total)}],hideFooterTotal:!0}})}})}),t.jsx("div",{className:"col-span-12 lg:col-span-7 flex",children:t.jsx(Hte,{className:"flex-1 w-full",totalWorkOrders:E.total,closedWorkOrders:E.completed,inProgressWorkOrders:E.inProgress,rejectedWorkOrders:E.rejected,byTypeChartData:T,onOpenReport:()=>{const lt=(T==null?void 0:T.rates)||[];Re({title:"Overall Completion Rate by Department",data:{labels:lt.map(st=>st.type),datasets:[{name:"Completion Rate (%)",values:lt.map(st=>parseFloat((st.closed/(st.total||1)*100).toFixed(2)))},{name:"Closed WOs",values:lt.map(st=>st.closed)},{name:"In Progress",values:lt.map(st=>st.inProgress)},{name:"Rejected",values:lt.map(st=>st.rejected)},{name:"Total WOs",values:lt.map(st=>st.total)}],hideFooterTotal:!0}})}})}),t.jsx("div",{className:"col-span-12 lg:col-span-5 flex",children:t.jsx(Kte,{className:"flex-1 w-full",data:v,totalAssets:(Ve=o==null?void 0:o.length)!=null?Ve:0,onOpenReport:()=>Et(!0)})})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-5",children:[t.jsx(xb,{icon:t.jsx(Or,{className:"text-red-500"}),title:e("dashboard.assetsDown","Assets Down"),value:z.assetsDown,trend:z.assetsDown===0?"All Operational":z.assetsDown<=3?"Low":"High Priority",trendUp:z.assetsDown===0,bgColor:"bg-red-50 dark:bg-red-900/20"}),t.jsx(xb,{icon:t.jsx(ea,{className:"text-blue-500"}),title:e("dashboard.avgResponseTime"),value:z.avgResponseTime>0?`${z.avgResponseTime.toFixed(1)} hrs`:"N/A",trend:z.avgResponseTime>0&&z.avgResponseTime<4?"Fast Response":"Monitor",trendUp:z.avgResponseTime>0&&z.avgResponseTime<4,bgColor:"bg-blue-50 dark:bg-blue-900/20"}),t.jsx(xb,{icon:t.jsx(X9,{className:"text-orange-500"}),title:e("dashboard.maintenanceEfficiency"),value:`${z.maintenanceEfficiency.toFixed(1)}%`,trend:z.maintenanceEfficiency>=70?"On Track":"Needs Attention",trendUp:z.maintenanceEfficiency>=70,bgColor:"bg-orange-50 dark:bg-orange-900/20"}),t.jsx(xb,{icon:t.jsx(Or,{className:"text-rose-500"}),title:e("dashboard.overdueMaintenance"),value:z.overdueTasks,trend:z.overdueTasks===0?"All Clear":z.overdueTasks<=3?"Low":"High Priority",trendUp:z.overdueTasks<=3,bgColor:"bg-rose-50 dark:bg-rose-900/20"})]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-5",children:[t.jsx(n7,{title:e("dashboard.workOrderStatus"),data:u||ae,onOpenReport:()=>Re({title:e("dashboard.workOrderStatus"),data:u||ae,redirectContext:"wo_type"})}),t.jsx(n7,{title:e("dashboard.assigneesStatus"),data:S||ee,onOpenReport:()=>Re({title:e("dashboard.assigneesStatus"),data:S||ee}),showSummary:!0})]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-5",children:[t.jsx(Xte,{title:e("dashboard.technicianWorkingHours","Technicians Working Hours"),data:X,onOpenReport:()=>ie(!0)}),t.jsx(Qte,{title:e("dashboard.techniciansWorked","Technicians Work Summary"),data:I,onOpenReport:()=>he(!0)})]}),U&&t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-5",children:[t.jsx(rre,{title:e("dashboard.inspectionLinkedWOSummary","Inspection Linked Work Orders Summary"),data:de,onOpenReport:()=>ye(!0)}),t.jsx(are,{title:e("dashboard.woRejectionSummary","WO Rejection Summary"),data:ge,onOpenReport:()=>M(!0)})]}),re&&t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-5",children:[t.jsx(ire,{data:we,onOpenReport:()=>Fe(!0)}),t.jsx(Vte,{insights:z,maintenanceLogs:i||[]})]})]}),t.jsx(zte,{isOpen:Q,onClose:()=>ie(!1),permittedIssueTypes:Y,isAdmin:te,defaultWorkOrderType:$e}),t.jsx($te,{isOpen:me,onClose:()=>he(!1),permittedIssueTypes:Y,isAdmin:te,defaultWorkOrderType:$e}),U&&t.jsx(sre,{isOpen:K,onClose:()=>ye(!1),permittedIssueTypes:Y,isAdmin:te,defaultWorkOrderType:$e}),U&&t.jsx(nre,{isOpen:Z,onClose:()=>M(!1),permittedIssueTypes:Y,isAdmin:te,defaultWorkOrderType:$e}),re&&t.jsx(ore,{isOpen:le,onClose:()=>Fe(!1),permittedIssueTypes:Y,isAdmin:te,defaultWorkOrderType:$e}),t.jsx(Yte,{isOpen:De,onClose:()=>Et(!1),assets:o||[],chartData:v}),t.jsx(tre,{isOpen:!!ze,onClose:()=>Re(null),title:(ze==null?void 0:ze.title)||"",data:ze==null?void 0:ze.data,redirectContext:ze==null?void 0:ze.redirectContext})]})},D0=({icon:e,value:r,label:a,bgColor:s,href:n})=>{const i=()=>{n&&(window.location.href=n)};return t.jsxs("div",{className:`text-center py-3 px-2 last:border-r-0 ${n?"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors rounded-lg group":""}`,onClick:n?i:void 0,title:n?`View ${a}`:void 0,children:[t.jsx("div",{className:`w-10 h-10 ${s} rounded-xl flex items-center justify-center text-base mx-auto mb-2 ${n?"group-hover:scale-105 transition-transform":""}`,children:e}),t.jsx("div",{className:"text-xl font-bold text-gray-900 dark:text-white leading-none mb-1",children:r}),t.jsx("div",{className:"text-[9px] font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide leading-tight px-1",children:a}),n&&t.jsx("div",{className:"text-[8px] text-indigo-400 dark:text-indigo-500 opacity-0 group-hover:opacity-100 transition-opacity mt-0.5",children:"View →"})]})},xb=({icon:e,title:r,value:a,trend:s,trendUp:n,bgColor:i})=>t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all p-4 border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-start justify-between mb-3",children:[t.jsx("div",{className:`w-10 h-10 ${i} rounded-xl flex items-center justify-center text-lg`,children:e}),t.jsxs("div",{className:`flex items-center gap-1 text-xs font-semibold px-2 py-1 rounded-full ${n?"text-emerald-700 bg-emerald-50 dark:text-emerald-400 dark:bg-emerald-900/20":"text-red-700 bg-red-50 dark:text-red-400 dark:bg-red-900/20"}`,children:[n?t.jsx(RG,{className:"text-[9px]"}):t.jsx(DG,{className:"text-[9px]"}),s]})]}),t.jsx("div",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-1",children:a}),t.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:r})]}),Bte=({totalWorkOrders:e,completedWorkOrders:r,inProgressWorkOrders:a,rejectedWorkOrders:s,byTypeChartData:n,onOpenReport:i,className:o=""})=>{var u;const{t:l}=sr(),c=e>0?(r/e*100).toFixed(2):"0.00";return t.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all px-5 py-4 border border-gray-200 dark:border-gray-700 flex flex-col h-full ${o}`,children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 bg-indigo-50 dark:bg-indigo-900/20 rounded-xl flex items-center justify-center",children:t.jsx(J4,{className:"text-indigo-600 text-base"})}),t.jsxs("div",{children:[t.jsxs("div",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:[c,"%"]}),t.jsx("div",{className:"text-xs font-semibold text-indigo-600 dark:text-indigo-400 uppercase tracking-wide",children:l("dashboard.completionRate","Workflow Completion Rate")})]})]}),i&&t.jsx("button",{onClick:i,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:"View Detail",children:t.jsx(dn,{className:"text-gray-400 text-xs"})})]}),n&&((u=n.rates)==null?void 0:u.length)>0?t.jsx(Wte,{data:n}):t.jsx("div",{className:"h-28 flex items-center justify-center text-gray-400 text-xs",children:l("dashboard.noDataAvailable","No data available")}),t.jsxs("div",{className:"grid grid-cols-4 gap-3 mt-3 pt-3 border-t border-gray-100 dark:border-gray-700",children:[t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-lg font-bold text-indigo-600 dark:text-indigo-400",children:e}),t.jsx("div",{className:"text-[9px] font-semibold text-gray-400 uppercase tracking-wide",children:"Total"})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-lg font-bold text-blue-600 dark:text-blue-400",children:a}),t.jsx("div",{className:"text-[9px] font-semibold text-gray-400 uppercase tracking-wide",children:"In Progress"})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-lg font-bold text-red-600 dark:text-red-400",children:s}),t.jsx("div",{className:"text-[9px] font-semibold text-gray-400 uppercase tracking-wide",children:"Rejected"})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-lg font-bold text-emerald-600 dark:text-emerald-400",children:r}),t.jsx("div",{className:"text-[9px] font-semibold text-gray-400 uppercase tracking-wide",children:"Completed"})]})]})]})},Wte=({data:e})=>{const{t:r}=sr(),[a,s]=gr.useState(null),n=gr.useRef(null),[i,o]=gr.useState(null),l=((e==null?void 0:e.rates)||[]).filter(P=>!Pd(P.type));if(!l.length)return t.jsx("div",{className:"h-28 flex items-center justify-center text-gray-400 text-xs",children:r("dashboard.noDataAvailable","No data available")});const c=tc(l.length),u=110,h=32,f=12,y=10,w=u-y-28,v=l.length,k=Math.max(260,v*72+h+f),N=(k-h-f)/v,C=Math.min(44,N*.55),O=[0,.25,.5,.75,1],T=(P,E)=>{if(s(P),n.current){const R=n.current.getBoundingClientRect(),G=E.currentTarget.ownerSVGElement.getBoundingClientRect(),ae=G.width/k,ee=G.left-R.left+(h+P*N+N/2)*ae;o({x:ee,y:0})}};return t.jsxs("div",{className:"w-full relative",ref:n,children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("svg",{width:"100%",height:u,viewBox:`0 0 ${k} ${u}`,preserveAspectRatio:"xMidYMid meet",className:"w-full",onMouseLeave:()=>{s(null),o(null)},children:[O.map((P,E)=>{const R=y+w-P*w;return t.jsxs("g",{children:[t.jsx("line",{x1:h,y1:R,x2:k-f,y2:R,stroke:"#E5E7EB",strokeWidth:"1"}),t.jsxs("text",{x:h-3,y:R+3,textAnchor:"end",fontSize:"7",fill:"#9CA3AF",children:[Math.round(P*100),"%"]})]},E)}),t.jsx("line",{x1:h,y1:y+w,x2:k-f,y2:y+w,stroke:"#D1D5DB",strokeWidth:"1"}),l.map((P,E)=>{const R=Math.max(0,P.rate/100*w),z=h+E*N+N/2,G=z-C/2,ae=y+w-R,ee=c[E],ne=a===E;return t.jsxs("g",{onMouseEnter:te=>T(E,te),style:{cursor:"pointer"},children:[t.jsx("rect",{x:h+E*N,y,width:N,height:w,fill:"transparent"}),t.jsx("rect",{x:G,y:R>0?ae:y+w-1,width:C,height:R>0?R:1,fill:ee,rx:"4",ry:"4",opacity:ne?1:.8,style:{transition:"opacity 0.15s, filter 0.15s",filter:ne?"brightness(1.15)":"none"}}),R>14&&t.jsxs("text",{x:z,y:ae-3,textAnchor:"middle",fontSize:"7.5",fontWeight:"700",fill:ee,children:[P.rate.toFixed(1),"%"]}),t.jsx("text",{x:z,y:y+w+12,textAnchor:"middle",fontSize:"6.5",fill:ne?ee:"#6B7280",fontWeight:ne?"700":"400",children:(P.type||"").length>11?(P.type||"").substring(0,9)+"…":P.type||""})]},E)})]})}),a!==null&&i&&l[a]&&(()=>{const P=l[a],E=c[a];return t.jsxs("div",{className:"absolute pointer-events-none z-30",style:{left:i.x,top:4,transform:"translateX(-50%)",minWidth:160},children:[t.jsxs("div",{className:"bg-gray-900 dark:bg-gray-700 text-white text-xs rounded-xl shadow-2xl px-3 py-2",children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-1 pb-1 border-b border-white/20",children:[t.jsx("div",{className:"w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{backgroundColor:E}}),t.jsx("span",{className:"font-semibold text-[11px] truncate max-w-[120px]",children:P.type})]}),t.jsxs("div",{className:"text-green-400 font-bold text-sm text-center mb-0.5",children:["WF: ",P.rate.toFixed(2),"%"]}),t.jsxs("div",{className:"text-gray-300 text-[10px] text-center",children:[P.wfCompleted," done · ",P.wfInProgress," prog · ",P.wfRejected," rej"]})]}),t.jsx("div",{className:"w-2.5 h-2.5 bg-gray-900 dark:bg-gray-700 rotate-45 mx-auto -mt-1.5"})]})})(),t.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-2 pt-2 border-t border-gray-100 dark:border-gray-700",children:l.map((P,E)=>t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{backgroundColor:c[E]}}),t.jsx("span",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:(P.type||"").length>22?(P.type||"").substring(0,20)+"…":P.type||""})]},E))})]})},Hte=({totalWorkOrders:e,closedWorkOrders:r,inProgressWorkOrders:a,rejectedWorkOrders:s,byTypeChartData:n,onOpenReport:i,className:o=""})=>{var u;const{t:l}=sr(),c=e>0?(r/e*100).toFixed(2):"0.00";return t.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all px-5 py-4 border border-gray-200 dark:border-gray-700 flex flex-col h-full ${o}`,children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 bg-emerald-50 dark:bg-emerald-900/20 rounded-xl flex items-center justify-center",children:t.jsx(Qt,{className:"text-emerald-600 text-base"})}),t.jsxs("div",{children:[t.jsxs("div",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:[c,"%"]}),t.jsx("div",{className:"text-xs font-semibold text-emerald-600 dark:text-emerald-400 uppercase tracking-wide",children:"Overall Completion Rate"})]})]}),i&&t.jsx("button",{onClick:i,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:"View Detail",children:t.jsx(dn,{className:"text-gray-400 text-xs"})})]}),n&&((u=n.rates)==null?void 0:u.length)>0?t.jsx(qte,{data:n}):t.jsx("div",{className:"h-28 flex items-center justify-center text-gray-400 text-xs",children:l("dashboard.noDataAvailable","No data available")}),t.jsxs("div",{className:"grid grid-cols-4 gap-3 mt-3 pt-3 border-t border-gray-100 dark:border-gray-700",children:[t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-lg font-bold text-indigo-600 dark:text-indigo-400",children:e}),t.jsx("div",{className:"text-[9px] font-semibold text-gray-400 uppercase tracking-wide",children:"Total"})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-lg font-bold text-blue-600 dark:text-blue-400",children:a}),t.jsx("div",{className:"text-[9px] font-semibold text-gray-400 uppercase tracking-wide",children:"In Progress"})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-lg font-bold text-red-600 dark:text-red-400",children:s}),t.jsx("div",{className:"text-[9px] font-semibold text-gray-400 uppercase tracking-wide",children:"Rejected"})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-lg font-bold text-emerald-600 dark:text-emerald-400",children:r}),t.jsx("div",{className:"text-[9px] font-semibold text-gray-400 uppercase tracking-wide",children:"Completed"})]})]})]})},qte=({data:e})=>{const{t:r}=sr(),[a,s]=gr.useState(null),n=gr.useRef(null),[i,o]=gr.useState(null),l=((e==null?void 0:e.rates)||[]).filter(E=>!Pd(E.type));if(!l.length)return t.jsx("div",{className:"h-28 flex items-center justify-center text-gray-400 text-xs",children:r("dashboard.noDataAvailable","No data available")});const c=l.map(E=>({type:E.type,total:E.total,closed:E.closed,inProgress:E.inProgress,rejected:E.rejected,rate:E.total>0?E.closed/E.total*100:0})),u=tc(c.length),h=110,f=32,y=12,b=10,v=h-b-28,k=c.length,S=Math.max(260,k*72+f+y),C=(S-f-y)/k,O=Math.min(44,C*.55),T=[0,.25,.5,.75,1],P=(E,R)=>{if(s(E),n.current){const z=n.current.getBoundingClientRect(),ae=R.currentTarget.ownerSVGElement.getBoundingClientRect(),ee=ae.width/S,ne=ae.left-z.left+(f+E*C+C/2)*ee;o({x:ne,y:0})}};return t.jsxs("div",{className:"w-full relative",ref:n,children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("svg",{width:"100%",height:h,viewBox:`0 0 ${S} ${h}`,preserveAspectRatio:"xMidYMid meet",className:"w-full",onMouseLeave:()=>{s(null),o(null)},children:[T.map((E,R)=>{const z=b+v-E*v;return t.jsxs("g",{children:[t.jsx("line",{x1:f,y1:z,x2:S-y,y2:z,stroke:"#E5E7EB",strokeWidth:"1"}),t.jsxs("text",{x:f-3,y:z+3,textAnchor:"end",fontSize:"7",fill:"#9CA3AF",children:[Math.round(E*100),"%"]})]},R)}),t.jsx("line",{x1:f,y1:b+v,x2:S-y,y2:b+v,stroke:"#D1D5DB",strokeWidth:"1"}),c.map((E,R)=>{const z=Math.max(0,E.rate/100*v),G=f+R*C+C/2,ae=G-O/2,ee=b+v-z,ne=u[R],te=a===R;return t.jsxs("g",{onMouseEnter:Y=>P(R,Y),style:{cursor:"pointer"},children:[t.jsx("rect",{x:f+R*C,y:b,width:C,height:v,fill:"transparent"}),t.jsx("rect",{x:ae,y:z>0?ee:b+v-1,width:O,height:z>0?z:1,fill:ne,rx:"4",ry:"4",opacity:te?1:.8,style:{transition:"opacity 0.15s, filter 0.15s",filter:te?"brightness(1.15)":"none"}}),z>14&&t.jsxs("text",{x:G,y:ee-3,textAnchor:"middle",fontSize:"7.5",fontWeight:"700",fill:ne,children:[E.rate.toFixed(1),"%"]}),t.jsx("text",{x:G,y:b+v+12,textAnchor:"middle",fontSize:"6.5",fill:te?ne:"#6B7280",fontWeight:te?"700":"400",children:(E.type||"").length>11?(E.type||"").substring(0,9)+"…":E.type||""})]},R)})]})}),a!==null&&i&&c[a]&&(()=>{const E=c[a],R=u[a];return t.jsxs("div",{className:"absolute pointer-events-none z-30",style:{left:i.x,top:4,transform:"translateX(-50%)",minWidth:160},children:[t.jsxs("div",{className:"bg-gray-900 dark:bg-gray-700 text-white text-xs rounded-xl shadow-2xl px-3 py-2",children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-1 pb-1 border-b border-white/20",children:[t.jsx("div",{className:"w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{backgroundColor:R}}),t.jsx("span",{className:"font-semibold text-[11px] truncate max-w-[120px]",children:E.type})]}),t.jsxs("div",{className:"text-green-400 font-bold text-sm text-center mb-0.5",children:[E.rate.toFixed(2),"% Closed"]}),t.jsxs("div",{className:"text-gray-300 text-[10px] text-center",children:[E.closed," closed · ",E.inProgress," prog · ",E.rejected," rej"]}),t.jsxs("div",{className:"text-gray-400 text-[10px] text-center",children:[E.total," total"]})]}),t.jsx("div",{className:"w-2.5 h-2.5 bg-gray-900 dark:bg-gray-700 rotate-45 mx-auto -mt-1.5"})]})})(),t.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-2 pt-2 border-t border-gray-100 dark:border-gray-700",children:c.map((E,R)=>t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{backgroundColor:u[R]}}),t.jsx("span",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:(E.type||"").length>22?(E.type||"").substring(0,20)+"…":E.type||""})]},R))})]})},Vte=({insights:e,maintenanceLogs:r})=>{const a=gr.useMemo(()=>r.filter(l=>{var c;return((c=l.maintenance_status)==null?void 0:c.toLowerCase())==="completed"}).length,[r]),s=r.length,n=[{label:"Total Logs",value:s,color:"bg-indigo-50 dark:bg-indigo-900/20",textColor:"text-indigo-600 dark:text-indigo-400"},{label:"Planned",value:e.plannedMaintenance,color:"bg-blue-50 dark:bg-blue-900/20",textColor:"text-blue-600 dark:text-blue-400"},{label:"Completed",value:a,color:"bg-emerald-50 dark:bg-emerald-900/20",textColor:"text-emerald-600 dark:text-emerald-400"},{label:"Overdue",value:e.overdueTasks,color:"bg-red-50 dark:bg-red-900/20",textColor:"text-red-600 dark:text-red-400"}],i=Math.min(e.maintenanceEfficiency,100),o=i>=70?"#10B981":i>=40?"#F59E0B":"#EF4444";return t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all p-5 border border-gray-200 dark:border-gray-700 flex flex-col",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"w-10 h-10 bg-orange-50 dark:bg-orange-900/20 rounded-xl flex items-center justify-center",children:t.jsx(Y4,{className:"text-orange-500 text-base"})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Maintenance Overview"}),t.jsxs("p",{className:"text-xs text-gray-400",children:[s," total maintenance logs"]})]})]}),t.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:n.map((l,c)=>t.jsxs("div",{className:`${l.color} rounded-xl p-3 text-center`,children:[t.jsx("div",{className:`text-2xl font-bold ${l.textColor}`,children:l.value}),t.jsx("div",{className:"text-[10px] font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide mt-0.5",children:l.label})]},c))}),t.jsxs("div",{className:"mt-auto space-y-2",children:[t.jsxs("div",{className:"flex justify-between items-center text-xs mb-1",children:[t.jsx("span",{className:"font-semibold text-gray-600 dark:text-gray-300",children:"Maintenance Efficiency"}),t.jsxs("span",{className:"font-bold",style:{color:o},children:[e.maintenanceEfficiency.toFixed(1),"%"]})]}),t.jsx("div",{className:"h-3 bg-gray-100 dark:bg-gray-700 rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full rounded-full transition-all duration-700",style:{width:`${i}%`,backgroundColor:o}})}),t.jsxs("div",{className:"flex justify-between text-[10px] text-gray-400 mt-1",children:[t.jsx("span",{children:"0%"}),t.jsx("span",{className:i>=70?"text-emerald-500":"text-amber-500",children:i>=70?"✓ On Track":"Needs Attention"}),t.jsx("span",{children:"100%"})]})]}),t.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-100 dark:border-gray-700 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400",children:[t.jsx(ea,{className:"text-blue-400"}),t.jsx("span",{children:"Avg Response Time"})]}),t.jsx("span",{className:"text-sm font-bold text-blue-600 dark:text-blue-400",children:e.avgResponseTime>0?`${e.avgResponseTime.toFixed(1)} hrs`:"N/A"})]})]})},Gte=({data:e,totalWorkOrders:r,completedWorkOrders:a,onOpenReport:s,className:n=""})=>{var o,l,c,u;const{t:i}=sr();return t.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all px-5 py-5 border border-gray-200 dark:border-gray-700 flex flex-col h-full ${n}`,children:[t.jsxs("div",{className:"flex items-center justify-between mb-4 flex-shrink-0",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-white",children:"Work Order Status Distribution"}),t.jsxs("div",{className:"text-2xl font-bold text-gray-900 dark:text-white mt-1",children:[r," ",t.jsx("span",{className:"text-sm font-medium text-gray-500",children:"Total"})]})]}),t.jsx("button",{onClick:s,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:i("dashboard.viewFullReport"),children:t.jsx(dn,{className:"w-4 h-4 text-gray-400"})})]}),t.jsx("div",{className:"flex-1",children:e&&((o=e==null?void 0:e.labels)!=null&&o.length||(u=(c=(l=e==null?void 0:e.datasets)==null?void 0:l[0])==null?void 0:c.values)!=null&&u.length)?t.jsx(RM,{data:e}):t.jsx("div",{className:"h-48 flex items-center justify-center text-gray-400 text-sm",children:i("dashboard.noDataAvailable")})})]})},Kte=({data:e,totalAssets:r,onOpenReport:a,className:s=""})=>{var n;return t.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all px-5 py-5 border border-gray-200 dark:border-gray-700 flex flex-col h-full ${s}`,children:[t.jsxs("div",{className:"flex items-center justify-between mb-4 flex-shrink-0",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-white",children:"Asset UP & Down"}),t.jsxs("div",{className:"text-2xl font-bold text-gray-900 dark:text-white mt-1",children:[r," ",t.jsx("span",{className:"text-sm font-medium text-gray-500",children:"Total"})]})]}),a&&t.jsx("button",{onClick:a,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:"View Asset Status Report",children:t.jsx(dn,{className:"w-4 h-4 text-gray-400"})})]}),t.jsx("div",{className:"flex-1",children:e&&((n=e==null?void 0:e.labels)!=null&&n.length)?t.jsx(RM,{data:e}):t.jsx("div",{className:"h-48 flex items-center justify-center text-gray-400 text-sm",children:"No asset status data"})})]})},Yte=({isOpen:e,onClose:r,assets:a,chartData:s})=>{var f,y,b,w,v,k;if(!e)return null;const n=(s==null?void 0:s.labels)||[],i=((y=(f=s==null?void 0:s.datasets)==null?void 0:f[0])==null?void 0:y.values)||[],o=((w=(b=s==null?void 0:s.datasets)==null?void 0:b[0])==null?void 0:w.colors)||tc(n.length),l=(k=(v=s==null?void 0:s.total)!=null?v:a==null?void 0:a.length)!=null?k:i.reduce((S,N)=>S+N,0),c=S=>{const N=S.toLowerCase();return N==="up"?{border:"border-emerald-200 dark:border-emerald-700",bg:"bg-emerald-50 dark:bg-emerald-900/20",text:"text-emerald-700 dark:text-emerald-300",badge:"bg-emerald-100 dark:bg-emerald-800 text-emerald-700 dark:text-emerald-200"}:N==="down"?{border:"border-red-200 dark:border-red-700",bg:"bg-red-50 dark:bg-red-900/20",text:"text-red-700 dark:text-red-300",badge:"bg-red-100 dark:bg-red-800 text-red-700 dark:text-red-200"}:N.includes("maintenance")?{border:"border-amber-200 dark:border-amber-700",bg:"bg-amber-50 dark:bg-amber-900/20",text:"text-amber-700 dark:text-amber-300",badge:"bg-amber-100 dark:bg-amber-800 text-amber-700 dark:text-amber-200"}:N.includes("decommission")?{border:"border-gray-200 dark:border-gray-600",bg:"bg-gray-50 dark:bg-gray-700/30",text:"text-gray-600 dark:text-gray-400",badge:"bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300"}:{border:"border-indigo-200 dark:border-indigo-700",bg:"bg-indigo-50 dark:bg-indigo-900/20",text:"text-indigo-700 dark:text-indigo-300",badge:"bg-indigo-100 dark:bg-indigo-800 text-indigo-700 dark:text-indigo-200"}},u=S=>{const N=`/asm_app/assets?device_status=${encodeURIComponent(S)}`;window.location.href=N},h=()=>{window.location.href="/asm_app/assets"};return t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-lg overflow-hidden flex flex-col",children:[t.jsxs("div",{className:"bg-gradient-to-r from-teal-500 to-emerald-600 px-6 py-4 flex items-center justify-between flex-shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(zd,{className:"text-white text-xl"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-white leading-tight",children:"Asset Status Overview"}),t.jsx("p",{className:"text-teal-100 text-xs mt-0.5",children:"Click a card to view filtered assets"})]})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white p-1.5 rounded-lg hover:bg-white/20 transition-colors",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsxs("div",{className:"p-6 space-y-4",children:[t.jsxs("button",{onClick:h,className:"w-full flex items-center justify-between bg-indigo-50 dark:bg-indigo-900/20 border border-indigo-200 dark:border-indigo-700 rounded-xl px-5 py-4 hover:bg-indigo-100 dark:hover:bg-indigo-900/40 transition-colors group",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 bg-indigo-100 dark:bg-indigo-800 rounded-xl flex items-center justify-center",children:t.jsx(zd,{className:"text-indigo-600 dark:text-indigo-300 text-base"})}),t.jsxs("div",{className:"text-left",children:[t.jsx("div",{className:"text-xs font-semibold text-indigo-500 dark:text-indigo-400 uppercase tracking-wide",children:"Total Assets"}),t.jsx("div",{className:"text-3xl font-bold text-indigo-700 dark:text-indigo-200 leading-tight",children:l})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-semibold text-indigo-500 dark:text-indigo-400 group-hover:text-indigo-700 dark:group-hover:text-indigo-200 transition-colors",children:["View all ",t.jsx(dn,{size:10})]})]}),n.length===0?t.jsx("div",{className:"text-center text-gray-400 py-8 text-sm",children:"No status data available"}):t.jsx("div",{className:"grid grid-cols-2 gap-3",children:n.map((S,N)=>{var E;const C=(E=i[N])!=null?E:0,O=l>0?(C/l*100).toFixed(1):"0.0",T=c(S),P=o[N]||"#6366F1";return t.jsxs("button",{onClick:()=>u(S),className:`flex flex-col items-start text-left ${T.bg} border ${T.border} rounded-xl px-4 py-4 hover:opacity-80 hover:shadow-md transition-all group`,children:[t.jsxs("div",{className:"flex items-start justify-between w-full mb-2",children:[t.jsx("div",{className:`text-4xl font-bold ${T.text} leading-none`,children:C}),t.jsxs("div",{className:`flex items-center gap-1 text-[10px] font-semibold ${T.text} opacity-60 group-hover:opacity-100 transition-opacity mt-1`,children:["View ",t.jsx(dn,{size:8})]})]}),t.jsx("div",{className:`text-xs font-semibold ${T.text} uppercase tracking-wide mb-3`,children:S}),t.jsx("div",{className:"w-full h-1.5 bg-white/60 dark:bg-black/20 rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full rounded-full transition-all duration-700",style:{width:`${O}%`,backgroundColor:P}})}),t.jsxs("div",{className:`text-[11px] font-semibold ${T.text} mt-1.5 opacity-70`,children:[O,"% of total"]})]},S)})})]})]})})},Jte=({data:e})=>{const{t:r}=sr(),a=(e==null?void 0:e.labels)||[],s=(e==null?void 0:e.datasets)||[];if(!s.length)return t.jsx("div",{className:"text-center text-gray-400 py-4 text-sm",children:r("dashboard.noDataAvailable")});const n=s.flatMap(w=>w.values||[]),i=Math.max(...n,1),o=240,l=Math.max(800,a.length*100),c=Math.min(120,(l-100)/a.length),u=4,h=s.length,f=Math.max(12,(c-u*(h+1))/h),y={"Completed On Time":"#6366F1","Completed Within SLA":"#3B82F6","Delay In Completion":"#8B5CF6",Pending:"#A855F7",Overdue:"#EC4899",Cancelled:"#0EA5E9",Open:"#F59E0B","Work In Progress":"#3B82F6","Pending Review":"#E11D48",Completed:"#10B981",Closed:"#10B981",Rejected:"#EF4444"},b=(w,v)=>{for(const[k,S]of Object.entries(y))if(w.toLowerCase().includes(k.toLowerCase()))return S;return tc(h)[v]};return t.jsxs("div",{className:"relative w-full overflow-x-auto",children:[t.jsxs("svg",{width:"100%",height:o+40,viewBox:`0 0 ${l} ${o+40}`,className:"w-full",preserveAspectRatio:"xMidYMid meet",children:[t.jsx("defs",{children:s.map((w,v)=>{const k=b(w.name||"",v);return t.jsxs("linearGradient",{id:`groupedBarGradient${v}`,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[t.jsx("stop",{offset:"0%",style:{stopColor:k,stopOpacity:.9}}),t.jsx("stop",{offset:"100%",style:{stopColor:k,stopOpacity:.7}})]},v)})}),[0,.25,.5,.75,1].map((w,v)=>t.jsx("line",{x1:"60",y1:o-w*o,x2:l-20,y2:o-w*o,stroke:"#E5E7EB",strokeWidth:"1"},v)),[0,.25,.5,.75,1].map((w,v)=>t.jsx("text",{x:"45",y:o-w*o+4,textAnchor:"end",className:"text-xs fill-gray-400",children:(i*w).toFixed(w===0?0:i<5?1:0)},v)),a.map((w,v)=>{const k=80+v*c;return t.jsxs("g",{children:[s.map((S,N)=>{var R;const C=((R=S.values)==null?void 0:R[v])||0,O=C/i*o,T=k+u+N*(f+u),P=o-O,E=b(S.name||"",N);return t.jsx("g",{children:t.jsx("rect",{x:T,y:P,width:f,height:O,fill:E,rx:"3",ry:"3",className:"hover:opacity-80 cursor-pointer transition-opacity",children:t.jsx("title",{children:`${w||"Unknown"} — ${S.name||"Series"}: ${C}`})})},N)}),t.jsx("text",{x:k+c/2,y:o+15,textAnchor:"middle",className:"text-xs fill-gray-600 dark:fill-gray-400",children:w&&w.length>12?w.substring(0,10)+"...":w||"null"})]},v)})]}),t.jsx("div",{className:"flex flex-wrap items-center justify-center gap-2 mt-2 pt-2 border-t border-gray-200 dark:border-gray-700",children:s.map((w,v)=>{const k=b(w.name||"",v);return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-2.5 h-2.5 rounded",style:{backgroundColor:k}}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:w.name&&w.name.length>20?w.name.substring(0,18)+"...":w.name||`Series ${v+1}`})]},v)})})]})},Zte=({data:e})=>{const{t:r}=sr(),a=(e==null?void 0:e.labels)||[],s=(e==null?void 0:e.datasets)||[];if(!s.length)return t.jsx("div",{className:"text-center text-gray-400 py-4 text-sm",children:r("dashboard.noDataAvailable")});const i=Array.isArray(e==null?void 0:e.totals)&&e.totals.length===a.length?e.totals:a.map((u,h)=>s.reduce((f,y)=>{var b;return f+(((b=y.values)==null?void 0:b[h])||0)},0)),o=Math.max(...i,1),l={total:"#6366F1",completed:"#10B981",in_progress:"#3B82F6",open:"#F59E0B"},c=(u,h)=>{for(const[f,y]of Object.entries(l))if(u.toLowerCase().includes(f))return y;return tc(s.length)[h]};return t.jsxs("div",{className:"space-y-2 max-h-72 overflow-y-auto",children:[a.map((u,h)=>{const f=i[h],y=s.map(b=>{var v;const w=((v=b.values)==null?void 0:v[h])||0;return w>0?`${(b.name||"").replace(/_/g," ")}: ${w}`:null}).filter(Boolean).join(" • ");return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-32 text-xs text-gray-700 dark:text-gray-200 truncate",title:u,children:u}),t.jsx("div",{className:"flex-1 h-4 bg-gray-100 dark:bg-gray-700 rounded-full overflow-hidden flex cursor-default",title:`${y} • Total: ${f}`,children:s.map((b,w)=>{var k;const v=((k=b.values)==null?void 0:k[h])||0;return v?t.jsx("div",{className:"h-full",style:{width:`${v/o*100}%`,backgroundColor:c(b.name||"",w)}},b.name):null})}),t.jsx("div",{className:"w-10 text-xs text-right text-gray-500 dark:text-gray-400",children:f})]},h)}),t.jsx("div",{className:"flex flex-wrap items-center gap-3 pt-2 border-t border-gray-200 dark:border-gray-700 mt-2",children:s.map((u,h)=>t.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-gray-600 dark:text-gray-300",children:[t.jsx("span",{className:"inline-block w-3 h-3 rounded-sm",style:{backgroundColor:c(u.name||"",h)}}),t.jsx("span",{children:(u.name||`Series ${h+1}`).replace(/_/g," ")})]},u.name||h))})]})},Xte=({title:e,data:r,onOpenReport:a})=>{var l;const{t:s}=sr(),[n,i]=p.useState(!1),o=gr.useMemo(()=>{var c,u;return(u=(c=r==null?void 0:r.datasets)==null?void 0:c[0])!=null&&u.values?r.datasets[0].values.reduce((h,f)=>h+f,0):0},[r]);return p.useEffect(()=>{const c=()=>i(!1);if(n)return document.addEventListener("click",c),()=>document.removeEventListener("click",c)},[n]),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all p-5 border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:a,className:"w-10 h-10 bg-indigo-50 dark:bg-indigo-900/20 rounded-xl flex items-center justify-center hover:bg-indigo-100 transition-colors group",children:t.jsx(xE,{className:"text-indigo-600 text-lg group-hover:scale-110 transition-transform"})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:e}),t.jsxs("p",{className:"text-xs text-gray-400",children:["Total: ",t.jsxs("span",{className:"font-semibold text-indigo-600",children:[o.toFixed(1)," hrs"]})]})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("button",{onClick:c=>{c.stopPropagation(),i(!n)},className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg",children:t.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"currentColor",viewBox:"0 0 20 20",children:t.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"})})}),n&&t.jsx("div",{className:"absolute right-0 top-full mt-1 w-48 bg-white dark:bg-gray-800 rounded-xl shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50",children:t.jsxs("button",{onClick:c=>{c.stopPropagation(),i(!1),a==null||a()},className:"w-full px-4 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(dn,{className:"text-gray-400",size:12}),s("dashboard.viewFullReport")]})})]})]}),!r||!((l=r.datasets)!=null&&l.length)?t.jsx("div",{className:"h-64 flex items-center justify-center text-gray-400",children:t.jsxs("div",{className:"text-center",children:[t.jsx(xE,{className:"text-4xl mx-auto mb-2 opacity-30"}),t.jsx("div",{className:"text-sm",children:"Loading..."})]})}):t.jsx(DM,{data:r,valueLabel:"hrs"})]})},Qte=({title:e,data:r,onOpenReport:a})=>{var l;const{t:s}=sr(),[n,i]=p.useState(!1),o=gr.useMemo(()=>{if(!(r!=null&&r.datasets))return{completed:0,inProgress:0,open:0};const c={completed:0,inProgress:0,open:0};return r.datasets.forEach(u=>{var f;const h=((f=u.values)==null?void 0:f.reduce((y,b)=>y+b,0))||0;u.name==="completed"?c.completed=h:u.name==="in_progress"?c.inProgress=h:u.name==="open"&&(c.open=h)}),c},[r]);return p.useEffect(()=>{const c=()=>i(!1);if(n)return document.addEventListener("click",c),()=>document.removeEventListener("click",c)},[n]),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all p-5 border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:a,className:"w-10 h-10 bg-purple-50 dark:bg-purple-900/20 rounded-xl flex items-center justify-center hover:bg-purple-100 transition-colors group",children:t.jsx(Sv,{className:"text-purple-600 text-lg group-hover:scale-110 transition-transform"})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:e}),t.jsxs("div",{className:"flex items-center gap-2 text-xs mt-0.5",children:[t.jsxs("span",{className:"text-emerald-600 font-semibold",children:[o.completed," done"]}),t.jsx("span",{className:"text-gray-300",children:"•"}),t.jsxs("span",{className:"text-blue-600 font-semibold",children:[o.inProgress," wip"]}),t.jsx("span",{className:"text-gray-300",children:"•"}),t.jsxs("span",{className:"text-amber-600 font-semibold",children:[o.open," open"]})]})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("button",{onClick:c=>{c.stopPropagation(),i(!n)},className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg",children:t.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"currentColor",viewBox:"0 0 20 20",children:t.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"})})}),n&&t.jsx("div",{className:"absolute right-0 top-full mt-1 w-48 bg-white dark:bg-gray-800 rounded-xl shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50",children:t.jsxs("button",{onClick:c=>{c.stopPropagation(),i(!1),a==null||a()},className:"w-full px-4 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(dn,{className:"text-gray-400",size:12}),s("dashboard.viewFullReport")]})})]})]}),!r||!((l=r.datasets)!=null&&l.length)?t.jsx("div",{className:"h-64 flex items-center justify-center text-gray-400",children:t.jsxs("div",{className:"text-center",children:[t.jsx(Sv,{className:"text-4xl mx-auto mb-2 opacity-30"}),t.jsx("div",{className:"text-sm",children:"Loading..."})]})}):t.jsx(Zte,{data:r})]})},DM=({data:e,valueLabel:r=""})=>{var o,l;const{t:a}=sr(),s=(e==null?void 0:e.labels)||[],n=((l=(o=e==null?void 0:e.datasets)==null?void 0:o[0])==null?void 0:l.values)||[];if(!n.length)return t.jsx("div",{className:"text-center text-gray-400 py-4 text-sm",children:a("dashboard.noDataAvailable")});const i=Math.max(...n,1);return t.jsx("div",{className:"space-y-3",children:s.map((c,u)=>{const h=n[u]||0,f=h/i*100;return t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-28 text-xs text-gray-600 dark:text-gray-400 truncate text-right",title:c||"(No Type)",children:c||"(No Type)"}),t.jsx("div",{className:"flex-1 h-6 bg-gray-100 dark:bg-gray-700 rounded-lg overflow-hidden",children:t.jsx("div",{className:"h-full bg-gradient-to-r from-indigo-500 to-purple-500 rounded-lg transition-all duration-500",style:{width:`${f}%`}})}),t.jsxs("div",{className:"w-12 text-xs font-semibold text-gray-800 dark:text-gray-200 text-right",children:[typeof h=="number"?Number.isInteger(h)?h:h.toFixed(1):h,r?` ${r}`:""]})]},u)})})},ere=({data:e})=>{var i,o;const{t:r}=sr(),a=(e==null?void 0:e.labels)||[],s=((o=(i=e==null?void 0:e.datasets)==null?void 0:i[0])==null?void 0:o.values)||[];if(!s.length)return t.jsx("div",{className:"text-center text-gray-400 py-4 text-sm",children:r("dashboard.noDataAvailable")});const n=Math.max(...s,1);return t.jsx("div",{className:"space-y-3",children:a.map((l,c)=>{const u=s[c]||0,h=u/n*100;return t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-32 text-xs text-gray-600 dark:text-gray-400 truncate text-right",title:l||"(No Type)",children:l||"(No Type)"}),t.jsx("div",{className:"flex-1 h-6 bg-gray-100 dark:bg-gray-700 rounded-lg overflow-hidden",children:t.jsx("div",{className:"h-full rounded-lg transition-all duration-500",style:{width:`${h}%`,background:"linear-gradient(to right, #EF4444, #F87171)"}})}),t.jsx("div",{className:"w-10 text-xs font-semibold text-red-600 dark:text-red-400 text-right",children:typeof u=="number"?Number.isInteger(u)?u:u.toFixed(1):u})]},c)})})},RM=({data:e})=>{var y,b,w,v;const r=(e==null?void 0:e.labels)||[],a=((b=(y=e==null?void 0:e.datasets)==null?void 0:y[0])==null?void 0:b.values)||[],s=r.some(k=>k.toLowerCase().includes("up time")||k.toLowerCase().includes("down time")||k.toLowerCase().includes("uptime")||k.toLowerCase().includes("downtime"));let n=[];if(s)n=r.map(k=>{const S=k.toLowerCase();return S.includes("up time")||S.includes("uptime")?"#6366F1":"#8B5CF6"});else{const k=(v=(w=e==null?void 0:e.datasets)==null?void 0:w[0])==null?void 0:v.colors;n=k&&k.length===a.length?k:tc(a.length)}const i=a.reduce((k,S)=>k+S,0),o=100,l=22,c=o+l,u=o+l;let h=0;const f=a.map((k,S)=>{const N=h/i*2*Math.PI-Math.PI/2;h+=k;const C=h/i*2*Math.PI-Math.PI/2,O=C-N>Math.PI?1:0,T=c+o*Math.cos(N),P=u+o*Math.sin(N),E=c+o*Math.cos(C),R=u+o*Math.sin(C);return{path:`M ${c} ${u} L ${T} ${P} A ${o} ${o} 0 ${O} 1 ${E} ${R} Z`,color:n[S],label:r[S],value:k,percentage:(k/i*100).toFixed(1)}});return t.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-around",children:[t.jsx("svg",{width:c*2,height:u*2,viewBox:`0 0 ${c*2} ${u*2}`,className:"max-w-xs",children:f.map((k,S)=>t.jsx("path",{d:k.path,fill:k.color,className:"hover:opacity-80 transition-opacity cursor-pointer drop-shadow-sm",children:t.jsx("title",{children:`${k.label}: ${k.value} (${k.percentage}%)`})},S))}),t.jsx("div",{className:"flex flex-col gap-2.5 mt-4 md:mt-0",children:f.map((k,S)=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:k.color}}),t.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:k.label}),t.jsx("span",{className:"text-sm font-bold text-gray-900 dark:text-white ml-auto pl-4",children:k.value})]},S))})]})},n7=({title:e,data:r,onOpenReport:a,showSummary:s})=>{const{t:n}=sr(),i=(r==null?void 0:r.labels)||[],o=(r==null?void 0:r.datasets)||[],l=i.length,c=o.reduce((u,h)=>u+(h.values||[]).reduce((f,y)=>f+y,0),0);return t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all p-4 border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-white",children:e}),t.jsx("button",{onClick:a,className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:n("dashboard.viewFullReport"),children:t.jsx(dn,{className:"w-3.5 h-3.5 text-gray-400"})})]}),!r||!o.length?t.jsx("div",{className:"h-48 flex items-center justify-center text-gray-400",children:t.jsx("div",{className:"text-xs",children:"No chart data available"})}):t.jsxs(t.Fragment,{children:[t.jsx(Jte,{data:r}),s&&l>0&&t.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-3 pt-3 border-t border-gray-100 dark:border-gray-700",children:[t.jsxs("div",{className:"bg-indigo-50 dark:bg-indigo-900/20 rounded-xl px-3 py-2 text-center",children:[t.jsx("div",{className:"text-lg font-bold text-indigo-600 dark:text-indigo-400",children:l}),t.jsx("div",{className:"text-[10px] text-gray-500 dark:text-gray-400 uppercase tracking-wide font-semibold",children:"Assignees"})]}),t.jsxs("div",{className:"bg-purple-50 dark:bg-purple-900/20 rounded-xl px-3 py-2 text-center",children:[t.jsx("div",{className:"text-lg font-bold text-purple-600 dark:text-purple-400",children:c}),t.jsx("div",{className:"text-[10px] text-gray-500 dark:text-gray-400 uppercase tracking-wide font-semibold",children:"Tasks"})]})]})]})]})},tre=({isOpen:e,onClose:r,title:a,data:s,redirectContext:n})=>{const{t:i}=sr();if(!e)return null;const o=(s==null?void 0:s.labels)||[],l=(s==null?void 0:s.datasets)||[],c=(s==null?void 0:s.hideFooterTotal)===!0,u=b=>{window.location.href=b},h=b=>n?n==="wo_status"?`/asm_app/work-orders?status=${encodeURIComponent(b)}`:n==="wo_type"?`/asm_app/work-orders?work_order_type=${encodeURIComponent(b)}&page=1`:null:null,f=(b,w)=>n?n==="wo_status"?`/asm_app/work-orders?status=${encodeURIComponent(b)}`:n==="wo_type"?`/asm_app/work-orders?work_order_type=${encodeURIComponent(b)}&page=1&status=${encodeURIComponent(w)}`:null:null,y=!!n;return t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl max-w-4xl w-full max-h-[90vh] overflow-hidden",children:[t.jsxs("div",{className:"bg-gradient-to-r from-indigo-500 to-purple-600 px-6 py-4 flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-white",children:a}),y&&t.jsx("p",{className:"text-indigo-200 text-xs mt-0.5",children:"Click a row or value to view filtered work orders"})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors p-1 rounded-lg hover:bg-white/20",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsx("div",{className:"p-6 overflow-auto max-h-[calc(90vh-120px)]",children:o.length===0||l.length===0?t.jsx("div",{className:"text-center text-gray-400 py-8",children:i("dashboard.noDataAvailable")}):t.jsxs("table",{className:"w-full text-sm border-collapse",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:[t.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-900/50 rounded-tl-lg",children:n==="wo_type"?"WO Type":n==="wo_status"?"Status":"Label"}),l.map((b,w)=>t.jsx("th",{className:"text-right py-3 px-4 font-semibold text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-900/50 last:rounded-tr-lg",children:(b.name||`Series ${w+1}`).replace(/_/g," ")},w))]})}),t.jsx("tbody",{children:o.map((b,w)=>{const v=h(b);return t.jsxs("tr",{className:`border-b border-gray-100 dark:border-gray-700/50 transition-colors ${y?"hover:bg-indigo-50 dark:hover:bg-indigo-900/20":"hover:bg-gray-50 dark:hover:bg-gray-700/30"}`,children:[t.jsx("td",{className:`py-2.5 px-4 text-gray-800 dark:text-gray-200 font-medium ${v?"cursor-pointer text-indigo-700 dark:text-indigo-300 hover:underline":""}`,onClick:v?()=>u(v):void 0,title:v?`View work orders for ${b}`:void 0,children:t.jsxs("span",{className:"flex items-center gap-1.5",children:[b||"Unknown",v&&t.jsx(dn,{size:9,className:"opacity-50 flex-shrink-0"})]})}),l.map((k,S)=>{var O,T;const N=(T=(O=k.values)==null?void 0:O[w])!=null?T:0,C=f(b,k.name||"");return t.jsx("td",{className:`py-2.5 px-4 text-right tabular-nums ${C?"cursor-pointer text-indigo-600 dark:text-indigo-400 font-semibold hover:text-indigo-800 dark:hover:text-indigo-200 hover:underline":"text-gray-600 dark:text-gray-300"}`,onClick:C?()=>u(C):void 0,title:C?`View ${k.name} work orders for ${b}`:void 0,children:N},S)})]},w)})}),!c&&t.jsx("tfoot",{children:t.jsxs("tr",{className:"border-t-2 border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-900/50",children:[t.jsx("td",{className:"py-3 px-4 font-bold text-gray-800 dark:text-gray-200",children:"Total"}),l.map((b,w)=>{const v=(b.values||[]).reduce((k,S)=>k+S,0);return t.jsx("td",{className:"py-3 px-4 text-right font-bold text-gray-800 dark:text-gray-200 tabular-nums",children:typeof v=="number"&&v%1!==0?v.toFixed(1):v},w)})]})})]})})]})})},rre=({title:e,data:r,onOpenReport:a})=>{var l;const{t:s}=sr(),[n,i]=p.useState(!1),o=gr.useMemo(()=>{var c,u,h,f;return(f=(h=(u=(c=r==null?void 0:r.datasets)==null?void 0:c[0])==null?void 0:u.values)==null?void 0:h.reduce((y,b)=>y+b,0))!=null?f:0},[r]);return p.useEffect(()=>{const c=()=>i(!1);if(n)return document.addEventListener("click",c),()=>document.removeEventListener("click",c)},[n]),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all p-5 border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:a,className:"w-10 h-10 bg-emerald-50 dark:bg-emerald-900/20 rounded-xl flex items-center justify-center hover:bg-emerald-100 transition-colors group",children:t.jsx(Qt,{className:"text-emerald-600 text-lg group-hover:scale-110 transition-transform"})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:e}),t.jsxs("p",{className:"text-xs text-gray-400",children:["Total: ",t.jsx("span",{className:"font-semibold text-emerald-600",children:o})]})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("button",{onClick:c=>{c.stopPropagation(),i(!n)},className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg",children:t.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"currentColor",viewBox:"0 0 20 20",children:t.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"})})}),n&&t.jsx("div",{className:"absolute right-0 top-full mt-1 w-48 bg-white dark:bg-gray-800 rounded-xl shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50",children:t.jsxs("button",{onClick:c=>{c.stopPropagation(),i(!1),a==null||a()},className:"w-full px-4 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(dn,{className:"text-gray-400",size:12}),s("dashboard.viewFullReport","View Full Report")]})})]})]}),r===null?t.jsx("div",{className:"h-64 flex items-center justify-center text-gray-400",children:t.jsxs("div",{className:"text-center",children:[t.jsx(Qt,{className:"text-4xl mx-auto mb-2 opacity-20"}),t.jsx("div",{className:"text-sm",children:"Loading..."})]})}):(l=r.datasets)!=null&&l.length?t.jsx(DM,{data:r,valueLabel:""}):t.jsx("div",{className:"h-64 flex items-center justify-center text-gray-400",children:t.jsxs("div",{className:"text-center",children:[t.jsx(Qt,{className:"text-4xl mx-auto mb-2 opacity-10"}),t.jsx("div",{className:"text-sm",children:"No inspection data"})]})})]})},are=({title:e,data:r,onOpenReport:a})=>{var l;const{t:s}=sr(),[n,i]=p.useState(!1),o=gr.useMemo(()=>{var c,u,h;return(u=(c=r==null?void 0:r.datasets)==null?void 0:c[0])!=null&&u.values?r.datasets[0].values.reduce((f,y)=>f+y,0):(h=r==null?void 0:r.totalRejected)!=null?h:0},[r]);return p.useEffect(()=>{const c=()=>i(!1);if(n)return document.addEventListener("click",c),()=>document.removeEventListener("click",c)},[n]),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all p-5 border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:a,className:"w-10 h-10 bg-red-50 dark:bg-red-900/20 rounded-xl flex items-center justify-center hover:bg-red-100 transition-colors group",children:t.jsx(Or,{className:"text-red-500 text-lg group-hover:scale-110 transition-transform"})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:e}),t.jsxs("p",{className:"text-xs text-gray-400",children:["Total: ",t.jsx("span",{className:"font-semibold text-red-600",children:o})]})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("button",{onClick:c=>{c.stopPropagation(),i(!n)},className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg",children:t.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"currentColor",viewBox:"0 0 20 20",children:t.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"})})}),n&&t.jsx("div",{className:"absolute right-0 top-full mt-1 w-48 bg-white dark:bg-gray-800 rounded-xl shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50",children:t.jsxs("button",{onClick:c=>{c.stopPropagation(),i(!1),a==null||a()},className:"w-full px-4 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(dn,{className:"text-gray-400",size:12}),s("dashboard.viewFullReport","View Full Report")]})})]})]}),r===null?t.jsx("div",{className:"h-64 flex items-center justify-center text-gray-400",children:t.jsxs("div",{className:"text-center",children:[t.jsx(Or,{className:"text-4xl mx-auto mb-2 opacity-20"}),t.jsx("div",{className:"text-sm",children:"Loading..."})]})}):(l=r.datasets)!=null&&l.length?t.jsx(ere,{data:r}):t.jsx("div",{className:"h-64 flex items-center justify-center text-gray-400",children:t.jsxs("div",{className:"text-center",children:[t.jsx(Or,{className:"text-4xl mx-auto mb-2 opacity-10"}),t.jsx("div",{className:"text-sm",children:"No rejection data"})]})})]})},sre=({isOpen:e,onClose:r,permittedIssueTypes:a,isAdmin:s,defaultWorkOrderType:n})=>{var Y,q;const{t:i}=sr(),[o,l]=p.useState(null),[c,u]=p.useState(!1),[h,f]=p.useState(""),[y,b]=p.useState(n||""),[w,v]=p.useState(""),[k,S]=p.useState(""),[N,C]=p.useState([]),[O,T]=p.useState([]);p.useEffect(()=>{b(n||"")},[n]),p.useEffect(()=>{if(!e)return;J(null,null,function*(){try{const[U,re]=yield Promise.all([fetch('/api/resource/Issue Type?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"}),fetch('/api/resource/Department?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"})]),X=yield U.json(),V=yield re.json();X.data&&C(X.data.map(I=>I.name)),V.data&&T(V.data.map(I=>I.name))}catch(U){console.error(U)}})},[e]);const P=s?N:a;if(p.useEffect(()=>{if(!e)return;J(null,null,function*(){u(!0);try{const U={};!s&&a.length>0?U.work_order_type=a.length===1?a[0]:a:y&&(U.work_order_type=y),h&&(U.department=h),w&&(U.from_date=w),k&&(U.to_date=k);const X=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:"Inspection Linked Work Orders Summary",filters:U,ignore_prepared_report:1})})).json();l(X.message||null)}catch(U){console.error(U)}finally{u(!1)}})},[e,y,h,w,k,a,s]),!e)return null;const E=(o==null?void 0:o.columns)||[],R=((o==null?void 0:o.result)||[]).filter(H=>H&&typeof H=="object"),z=R.filter(H=>!H.is_total_row),G=(o==null?void 0:o.report_summary)||[],ae=(q=(Y=G.find(H=>{var U;return(U=H.label)==null?void 0:U.toLowerCase().includes("total inspection")}))==null?void 0:Y.value)!=null?q:z.reduce((H,U)=>{const re=E.find(X=>{var V,I;return((V=X.label)==null?void 0:V.toLowerCase().includes("total inspection"))||((I=X.fieldname)==null?void 0:I.toLowerCase().includes("total_inspection"))});return H+(re&&parseFloat(U[re.fieldname])||0)},0),ee=G.length>0?G.map(H=>({label:H.label,value:H.value,color:H.color||"blue"})):[{label:"Total Inspections",value:ae,color:"blue"}],ne={blue:"text-blue-600 dark:text-blue-400",teal:"text-teal-600 dark:text-teal-400",green:"text-emerald-600 dark:text-emerald-400",red:"text-red-600 dark:text-red-400",orange:"text-orange-600 dark:text-orange-400",purple:"text-purple-600 dark:text-purple-400"},te=h||w||k||y&&(s||a.length===0);return t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl max-w-5xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[t.jsxs("div",{className:"bg-gradient-to-r from-emerald-500 to-teal-600 px-6 py-4 flex items-center justify-between flex-shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Qt,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:"Inspection Linked Work Orders Summary"})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white p-1 rounded-lg hover:bg-white/20 transition-colors",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsxs("div",{className:"px-6 py-3 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/30 flex-shrink-0 flex flex-col gap-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 whitespace-nowrap",children:"WO Type"}),t.jsxs("select",{value:y,onChange:H=>b(H.target.value),disabled:!s&&a.length>0,className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-emerald-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white min-w-[200px] disabled:opacity-60",children:[t.jsx("option",{value:"",children:"All Types"}),P.map(H=>t.jsx("option",{value:H,children:H},H))]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 whitespace-nowrap",children:"From Date"}),t.jsx("input",{type:"date",value:w,onChange:H=>v(H.target.value),className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-emerald-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 whitespace-nowrap",children:"To Date"}),t.jsx("input",{type:"date",value:k,onChange:H=>S(H.target.value),className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-emerald-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 whitespace-nowrap",children:"Department"}),t.jsxs("select",{value:h,onChange:H=>f(H.target.value),className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-emerald-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white min-w-[300px]",children:[t.jsx("option",{value:"",children:"All Departments"}),O.map(H=>t.jsx("option",{value:H,children:H},H))]})]}),te&&t.jsxs("button",{onClick:()=>{f(""),v(""),S(""),(s||a.length===0)&&b("")},className:"text-xs text-red-500 hover:text-red-700 flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-red-50 transition-colors",children:[t.jsx(ht,{size:10})," Clear"]})]})]}),!c&&ee.length>0&&t.jsx("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40 flex-shrink-0",children:t.jsx("div",{className:`grid gap-6 ${ee.length===1?"grid-cols-1":ee.length===2?"grid-cols-2":"grid-cols-3"}`,children:ee.map((H,U)=>t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-xs font-medium text-gray-500 mb-1",children:H.label}),t.jsx("div",{className:`text-2xl font-bold ${ne[H.color]||"text-blue-600"}`,children:H.value})]},U))})}),t.jsx("div",{className:"p-6 overflow-auto flex-1",children:c?t.jsx("div",{className:"flex items-center justify-center py-16",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-emerald-600"})}):R.length===0?t.jsx("div",{className:"text-center text-gray-400 py-16",children:"No data available"}):t.jsxs("table",{className:"w-full text-sm border-collapse",children:[t.jsx("thead",{children:t.jsx("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:E.map((H,U)=>t.jsx("th",{className:`py-3 px-4 font-semibold text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-900/50 ${U===0?"text-left":"text-right"}`,children:H.label||H.fieldname},U))})}),t.jsx("tbody",{children:R.map((H,U)=>t.jsx("tr",{className:"border-b border-gray-100 dark:border-gray-700/50 hover:bg-gray-50 dark:hover:bg-gray-700/30 transition-colors",children:E.map((re,X)=>{var V;return t.jsx("td",{className:`py-2.5 px-4 ${X===0?"text-gray-800 dark:text-gray-200 font-medium":"text-right text-gray-600 dark:text-gray-300 tabular-nums"}`,children:(V=H[re.fieldname])!=null?V:"—"},X)})},U))})]})})]})})},nre=({isOpen:e,onClose:r,permittedIssueTypes:a,isAdmin:s,defaultWorkOrderType:n})=>{const[i,o]=p.useState(null),[l,c]=p.useState(!1),[u,h]=p.useState(""),[f,y]=p.useState(""),[b,w]=p.useState(n||""),[v,k]=p.useState(""),[S,N]=p.useState([]),[C,O]=p.useState([]);p.useEffect(()=>{w(n||"")},[n]),p.useEffect(()=>{if(!e)return;J(null,null,function*(){try{const[re,X]=yield Promise.all([fetch('/api/resource/Issue Type?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"}),fetch('/api/resource/Department?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"})]),V=yield re.json(),I=yield X.json();V.data&&N(V.data.map(B=>B.name)),I.data&&O(I.data.map(B=>B.name))}catch(re){console.error(re)}})},[e]);const T=s?S:a;if(p.useEffect(()=>{if(!e)return;J(null,null,function*(){c(!0);try{const re={};!s&&a.length>0?re.work_order_type=a.length===1?a[0]:a:b&&(re.work_order_type=b),v&&(re.department=v),u&&(re.from_date=u),f&&(re.to_date=f);const V=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:"WO Rejection Summary",filters:re,ignore_prepared_report:1})})).json();o(V.message||null)}catch(re){console.error(re)}finally{c(!1)}})},[e,b,v,u,f,a,s]),!e)return null;const P=(i==null?void 0:i.columns)||[],E=((i==null?void 0:i.result)||[]).filter(U=>U&&typeof U=="object"&&U.custom_delete_status!=="Deleted"),R=E.filter(U=>!U.is_total_row),z=(i==null?void 0:i.report_summary)||[];((U,re)=>{var V,I;const X=U.find(B=>(B==null?void 0:B.fieldname)&&(B.fieldname.toLowerCase().includes("work_order_type")||B.fieldname.toLowerCase().includes("wo_type")||B.fieldname.toLowerCase()==="type"));return X?X.fieldname:(V=U[1])!=null&&V.fieldname?U[1].fieldname:((I=U[0])==null?void 0:I.fieldname)||""})(P);const ae=P.find(U=>{const re=((U.label||"")+(U.fieldname||"")).toLowerCase();return re.includes("total_work")||re.includes("total work")}),ee=P.find(U=>{const re=((U.label||"")+(U.fieldname||"")).toLowerCase();return re.includes("total_rejected")||re.includes("total rejected")||re.includes("rejected")&&!re.includes("%")}),ne=ae?R.reduce((U,re)=>U+(parseFloat(re[ae.fieldname])||0),0):null,te=ee?R.reduce((U,re)=>U+(parseFloat(re[ee.fieldname])||0),0):null,Y=ne&&te&&ne>0?(te/ne*100).toFixed(2)+"%":null,q=z.length>0?z.map(U=>({label:U.label,value:U.value,color:U.color||"blue"})):[...ne!==null?[{label:"Total Work Orders",value:ne,color:"blue"}]:[],...te!==null?[{label:"Total Rejected",value:te,color:"red"}]:[],...Y!==null?[{label:"Rejected %",value:Y,color:"orange"}]:[]],H={blue:"text-blue-600 dark:text-blue-400",red:"text-red-600 dark:text-red-400",orange:"text-orange-600 dark:text-orange-400",green:"text-emerald-600 dark:text-emerald-400",purple:"text-purple-600 dark:text-purple-400"};return t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl max-w-5xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[t.jsxs("div",{className:"bg-gradient-to-r from-red-500 to-rose-600 px-6 py-4 flex items-center justify-between flex-shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Or,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:"WO Rejection Summary"})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white p-1 rounded-lg hover:bg-white/20 transition-colors",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsxs("div",{className:"px-6 py-3 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/30 flex-shrink-0 flex flex-wrap items-center gap-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 whitespace-nowrap",children:"From Date"}),t.jsx("input",{type:"date",value:u,onChange:U=>h(U.target.value),className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-red-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 whitespace-nowrap",children:"To Date"}),t.jsx("input",{type:"date",value:f,onChange:U=>y(U.target.value),className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-red-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 whitespace-nowrap",children:"WO Type"}),t.jsxs("select",{value:b,onChange:U=>w(U.target.value),disabled:!s&&a.length>0,className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-red-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white min-w-[160px] disabled:opacity-60",children:[t.jsx("option",{value:"",children:"All Types"}),T.map(U=>t.jsx("option",{value:U,children:U},U))]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 whitespace-nowrap",children:"Department"}),t.jsxs("select",{value:v,onChange:U=>k(U.target.value),className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-red-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white min-w-[160px]",children:[t.jsx("option",{value:"",children:"All Departments"}),C.map(U=>t.jsx("option",{value:U,children:U},U))]})]}),(u||f||b||v)&&t.jsxs("button",{onClick:()=>{h(""),y(""),w(""),k("")},className:"text-xs text-red-500 hover:text-red-700 flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-red-50 transition-colors",children:[t.jsx(ht,{size:10})," Clear"]})]}),!l&&q.length>0&&t.jsx("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40 flex-shrink-0",children:t.jsx("div",{className:`grid gap-6 ${q.length===1?"grid-cols-1":q.length===2?"grid-cols-2":"grid-cols-3"}`,children:q.map((U,re)=>t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-xs font-medium text-gray-500 mb-1",children:U.label}),t.jsx("div",{className:`text-2xl font-bold ${H[U.color]||"text-blue-600"}`,children:U.value})]},re))})}),t.jsx("div",{className:"p-6 overflow-auto flex-1",children:l?t.jsx("div",{className:"flex items-center justify-center py-16",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-red-600"})}):E.length===0?t.jsx("div",{className:"text-center text-gray-400 py-16",children:"No data available"}):(()=>{const U=P.find(I=>{const B=((I.label||"")+(I.fieldname||"")).toLowerCase();return B.includes("work_order_type")||B.includes("wo_type")||B.includes("type")}),re=P.find(I=>{const B=((I.label||"")+(I.fieldname||"")).toLowerCase();return B.includes("department")||B.includes("dept")}),X=P.find(I=>{const B=((I.label||"")+(I.fieldname||"")).toLowerCase();return B.includes("total_rejected")||B.includes("total rejected")||B.includes("rejected")&&!B.includes("%")}),V=I=>{const B=new URLSearchParams,Q=U&&I[U.fieldname]||"",ie=re&&I[re.fieldname]||"";return Q&&B.set("work_order_type",Q),B.set("page","1"),ie&&B.set("department",ie),B.set("status","Rejected"),`/asm_app/work-orders?${B.toString()}`};return t.jsxs("table",{className:"w-full text-sm border-collapse",children:[t.jsx("thead",{children:t.jsx("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:P.map((I,B)=>t.jsxs("th",{className:`py-3 px-4 font-semibold text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-900/50 ${B===0?"text-left rounded-tl-lg":"text-right"} ${B===P.length-1?"rounded-tr-lg":""}`,children:[I.label||I.fieldname,X&&I.fieldname===X.fieldname&&t.jsx("span",{className:"ml-1 text-[9px] text-red-400 font-normal normal-case",children:"(click to view)"})]},B))})}),t.jsx("tbody",{children:E.map((I,B)=>t.jsx("tr",{className:"border-b border-gray-100 dark:border-gray-700/50 hover:bg-red-50/40 dark:hover:bg-red-900/10 transition-colors",children:P.map((Q,ie)=>{var be;const me=X&&Q.fieldname===X.fieldname,he=(be=I[Q.fieldname])!=null?be:"—",de=me&&parseFloat(I[Q.fieldname])||0,xe=me&&de>0,ge=xe?V(I):null;return t.jsx("td",{className:`py-2.5 px-4 ${ie===0?"text-gray-800 dark:text-gray-200 font-medium text-left":"text-right tabular-nums"} ${xe?"cursor-pointer text-red-600 dark:text-red-400 font-bold hover:text-red-800 dark:hover:text-red-200 hover:underline":"text-gray-600 dark:text-gray-300"}`,onClick:xe?()=>{window.location.href=ge}:void 0,title:xe?"View rejected work orders":void 0,children:xe?t.jsxs("span",{className:"flex items-center justify-end gap-1.5",children:[he,t.jsx(dn,{size:9,className:"opacity-60 flex-shrink-0"})]}):he},ie)})},B))})]})})()})]})})},ire=({data:e,onOpenReport:r})=>{var y,b,w;const[a,s]=p.useState(!1);p.useEffect(()=>{const v=()=>s(!1);if(a)return document.addEventListener("click",v),()=>document.removeEventListener("click",v)},[a]);const n=(e==null?void 0:e.labels)||[],i=((b=(y=e==null?void 0:e.datasets)==null?void 0:y[0])==null?void 0:b.values)||[],o=n.reduce((v,k,S)=>{var N;return Pd(k)||(v.labels.push(k),v.values.push((N=i[S])!=null?N:0)),v},{labels:[],values:[]}),l=o.labels,c=o.values,u=(w=e==null?void 0:e.overallAvg)!=null?w:0,h=tc(l.length),f=Math.max(...c,.001);return t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all p-5 border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:r,className:"w-10 h-10 bg-pink-50 dark:bg-pink-900/20 rounded-xl flex items-center justify-center hover:bg-pink-100 transition-colors group",children:t.jsx(vm,{className:"text-pink-600 text-base group-hover:scale-110 transition-transform"})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Time to Repair"}),t.jsxs("p",{className:"text-xs text-gray-400",children:["Overall Avg: ",t.jsxs("span",{className:"font-bold text-pink-600 dark:text-pink-400",children:[u.toFixed(3)," hrs"]})]})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("button",{onClick:v=>{v.stopPropagation(),s(!a)},className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg",children:t.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"currentColor",viewBox:"0 0 20 20",children:t.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"})})}),a&&t.jsx("div",{className:"absolute right-0 top-full mt-1 w-48 bg-white dark:bg-gray-800 rounded-xl shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50",children:t.jsxs("button",{onClick:v=>{v.stopPropagation(),s(!1),r==null||r()},className:"w-full px-4 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(dn,{className:"text-gray-400",size:12})," View Full Report"]})})]})]}),t.jsxs("div",{className:"bg-gradient-to-r from-pink-50 to-rose-50 dark:from-pink-900/20 dark:to-rose-900/20 rounded-xl px-4 py-3 mb-4 flex items-center justify-between",children:[t.jsx("span",{className:"text-xs font-semibold text-pink-700 dark:text-pink-300",children:"Overall Avg Time to Repair"}),t.jsxs("span",{className:"text-2xl font-bold text-pink-600 dark:text-pink-400",children:[u.toFixed(3)," ",t.jsx("span",{className:"text-sm font-normal",children:"hrs"})]})]}),!e||!l.length?t.jsx("div",{className:"h-40 flex items-center justify-center text-gray-400",children:t.jsxs("div",{className:"text-center",children:[t.jsx(vm,{className:"text-3xl mx-auto mb-1 opacity-20"}),t.jsx("div",{className:"text-xs",children:"Loading..."})]})}):t.jsx("div",{className:"space-y-2 max-h-56 overflow-y-auto",children:l.map((v,k)=>{const S=c[k]||0,N=f>0?S/f*100:0,C=h[k],O=Math.max(N,S>0?3:1);return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"flex-1 h-7 bg-gray-100 dark:bg-gray-700 rounded-lg overflow-hidden relative",children:[t.jsx("div",{className:"h-full rounded-lg transition-all duration-500 flex items-center justify-end pr-2",style:{width:`${O}%`,backgroundColor:C,opacity:.88},children:N>28&&t.jsxs("span",{className:"text-[9px] font-bold text-white whitespace-nowrap",children:[S.toFixed(2)," hrs"]})}),N<=28&&t.jsxs("span",{className:"absolute left-[calc(max(3%,6px)+6px)] top-1/2 -translate-y-1/2 text-[9px] font-bold text-gray-600 dark:text-gray-300 whitespace-nowrap",children:[S.toFixed(2)," hrs"]})]}),t.jsx("div",{className:"w-36 text-[11px] text-gray-700 dark:text-gray-200 font-medium truncate flex-shrink-0",title:v,children:v})]},k)})}),l.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-3 pt-2 border-t border-gray-100 dark:border-gray-700",children:l.map((v,k)=>t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("div",{className:"w-2 h-2 rounded-sm flex-shrink-0",style:{backgroundColor:h[k]}}),t.jsx("span",{className:"text-[9px] text-gray-400 truncate max-w-[90px]",children:v.length>14?v.substring(0,12)+"…":v})]},k))})]})},ore=({isOpen:e,onClose:r,permittedIssueTypes:a,isAdmin:s,defaultWorkOrderType:n})=>{const[i,o]=p.useState(null),[l,c]=p.useState(!1),[u,h]=p.useState(""),[f,y]=p.useState(n||""),[b,w]=p.useState([]),[v,k]=p.useState([]);p.useEffect(()=>{y(n||"")},[n]),p.useEffect(()=>{if(!e)return;J(null,null,function*(){try{const[U,re]=yield Promise.all([fetch('/api/resource/Department?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"}),fetch('/api/resource/Issue Type?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"})]),X=yield U.json(),V=yield re.json();X.data&&w(X.data.map(I=>I.name)),V.data&&k(V.data.map(I=>I.name))}catch(U){console.error(U)}})},[e]);const S=s?v:a;if(p.useEffect(()=>{if(!e)return;J(null,null,function*(){c(!0);try{const U={};!s&&a.length>0?U.work_order_type=a.length===1?a[0]:a:f&&(U.work_order_type=f),u&&(U.department=u);const X=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:"Time to Repair",filters:U,ignore_prepared_report:1})})).json();o(X.message||null)}catch(U){console.error(U)}finally{c(!1)}})},[e,u,f,a,s]),!e)return null;const N=(i==null?void 0:i.columns)||[],C=((i==null?void 0:i.result)||[]).filter(H=>H&&typeof H=="object"),O=C.filter(H=>!H.is_total_row),T=(i==null?void 0:i.report_summary)||[],P=N.find(H=>{const U=((H.label||"")+(H.fieldname||"")).toLowerCase();return U.includes("time_to_repair")||U.includes("time to repair")||U.includes("hours")})||N[N.length-1],E=N.find(H=>{const U=((H.label||"")+(H.fieldname||"")).toLowerCase();return U.includes("wo_type")||U.includes("wo type")||U.includes("work_order_type")})||N[1],R=T.find(H=>{var U,re;return((U=H.label)==null?void 0:U.toLowerCase().includes("avg"))||((re=H.label)==null?void 0:re.toLowerCase().includes("overall"))}),z=O.filter(H=>!Pd(E?H[E.fieldname]:null)),G=R?parseFloat(R.value)||0:z.length>0&&P?z.reduce((H,U)=>H+(parseFloat(U[P.fieldname])||0),0)/z.length:0,ae={};O.forEach(H=>{const U=E?H[E.fieldname]:null;if(Pd(U))return;const re=String(U),X=P&&parseFloat(H[P.fieldname])||0;ae[re]||(ae[re]={total:0,count:0}),ae[re].total+=X,ae[re].count+=1});const ee=Object.keys(ae),ne=ee.map(H=>parseFloat((ae[H].total/ae[H].count).toFixed(3))),te=Math.max(...ne,.001),Y=tc(ee.length),q=u||f&&(s||a.length===0);return t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl max-w-5xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[t.jsxs("div",{className:"bg-gradient-to-r from-pink-500 to-rose-600 px-6 py-4 flex items-center justify-between flex-shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(vm,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:"Time to Repair"})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white p-1 rounded-lg hover:bg-white/20 transition-colors",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsxs("div",{className:"px-6 py-3 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/30 flex-shrink-0 flex flex-wrap items-center gap-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 whitespace-nowrap",children:"Department"}),t.jsxs("select",{value:u,onChange:H=>h(H.target.value),className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-pink-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white min-w-[180px]",children:[t.jsx("option",{value:"",children:"All Departments"}),b.map(H=>t.jsx("option",{value:H,children:H},H))]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 whitespace-nowrap",children:"WO Type"}),t.jsxs("select",{value:f,onChange:H=>y(H.target.value),disabled:!s&&a.length>0,className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-pink-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white min-w-[180px] disabled:opacity-60",children:[t.jsx("option",{value:"",children:"All Types"}),S.map(H=>t.jsx("option",{value:H,children:H},H))]})]}),q&&t.jsxs("button",{onClick:()=>{h(""),y("")},className:"text-xs text-red-500 hover:text-red-700 flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-red-50 transition-colors",children:[t.jsx(ht,{size:10})," Clear"]})]}),!l&&t.jsxs("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40 flex-shrink-0 text-center",children:[t.jsx("div",{className:"text-xs font-medium text-gray-500 mb-1",children:"Overall Avg Time to Repair (Hours)"}),t.jsx("div",{className:"text-3xl font-bold text-pink-600 dark:text-pink-400",children:G.toFixed(3)})]}),t.jsx("div",{className:"p-6 overflow-auto flex-1 flex flex-col gap-6",children:l?t.jsx("div",{className:"flex items-center justify-center py-16",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-pink-600"})}):C.length===0?t.jsx("div",{className:"text-center text-gray-400 py-16",children:"No data available"}):t.jsxs(t.Fragment,{children:[ee.length>0&&t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/30 rounded-xl p-4",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-4",children:"Avg Time to Repair by WO Type (Hours)"}),t.jsx("div",{className:"space-y-3",children:ee.map((H,U)=>{const re=ne[U],X=te>0?re/te*100:0,V=Y[U],I=Math.max(X,re>0?2:1);return t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("div",{className:"flex-1 h-8 bg-white dark:bg-gray-700 rounded-lg overflow-hidden relative border border-gray-200 dark:border-gray-600",children:[t.jsx("div",{className:"h-full rounded-lg transition-all duration-500 flex items-center justify-end pr-2",style:{width:`${I}%`,backgroundColor:V,opacity:.85},children:X>20&&t.jsx("span",{className:"text-[11px] font-semibold text-white",children:re.toFixed(3)})}),X<=20&&t.jsx("span",{className:"absolute left-[calc(max(2%,4px)+8px)] top-1/2 -translate-y-1/2 text-[11px] font-semibold text-gray-700 dark:text-gray-200",children:re.toFixed(3)})]}),t.jsx("div",{className:"w-52 text-xs text-gray-700 dark:text-gray-200 font-medium truncate flex-shrink-0",title:H,children:H})]},U)})})]}),t.jsxs("table",{className:"w-full text-sm border-collapse",children:[t.jsx("thead",{children:t.jsx("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:N.map((H,U)=>t.jsx("th",{className:`py-3 px-4 font-semibold text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-900/50 ${U===0?"text-left":"text-right"}`,children:H.label||H.fieldname},U))})}),t.jsx("tbody",{children:C.map((H,U)=>t.jsx("tr",{className:`border-b border-gray-100 dark:border-gray-700/50 hover:bg-pink-50/40 dark:hover:bg-pink-900/10 transition-colors ${H.is_total_row?"font-bold bg-gray-50 dark:bg-gray-900/40 border-t-2 border-gray-300 dark:border-gray-600":""}`,children:N.map((re,X)=>{var he;const V=(re.fieldname||"").toLowerCase(),I=(re.label||"").toLowerCase(),B=!H.is_total_row&&(V==="name"||V==="work_order"||V==="work_order_id"||I==="work order"||I==="work order id"||I==="wo"),Q=(he=H[re.fieldname])!=null?he:"—",ie=B?String(Q):"",me=B&&ie&&ie!=="—";return t.jsx("td",{className:`py-2.5 px-4 ${X===0?"text-left font-medium":"text-right tabular-nums"} ${me?"cursor-pointer text-pink-600 dark:text-pink-400 font-semibold hover:text-pink-800 dark:hover:text-pink-200 hover:underline":"text-gray-800 dark:text-gray-200"}`,onClick:me?()=>{window.location.href=`/asm_app/work-orders?work_order_id=${encodeURIComponent(ie)}`}:void 0,title:me?`Open Work Order ${ie}`:void 0,children:me?t.jsxs("span",{className:"flex items-center gap-1.5",children:[Q,t.jsx(dn,{size:9,className:"opacity-50 flex-shrink-0"})]}):Q},X)})},U))})]})]})})]})})};function tc(e){const r=["#8B5CF6","#6366F1","#3B82F6","#06B6D4","#14B8A6","#EC4899","#A855F7","#0EA5E9","#10B981","#F472B6","#7C3AED","#2DD4BF"];return Array.from({length:e},(a,s)=>r[s%r.length])}function MM(e,r){return function(){return e.apply(r,arguments)}}const{toString:lre}=Object.prototype,{getPrototypeOf:_S}=Object,{iterator:rw,toStringTag:LM}=Symbol,aw=(e=>r=>{const a=lre.call(r);return e[a]||(e[a]=a.slice(8,-1).toLowerCase())})(Object.create(null)),cc=e=>(e=e.toLowerCase(),r=>aw(r)===e),sw=e=>r=>typeof r===e,{isArray:Vp}=Array,Np=sw("undefined");function Ax(e){return e!==null&&!Np(e)&&e.constructor!==null&&!Np(e.constructor)&&oo(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const FM=cc("ArrayBuffer");function cre(e){let r;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?r=ArrayBuffer.isView(e):r=e&&e.buffer&&FM(e.buffer),r}const dre=sw("string"),oo=sw("function"),IM=sw("number"),Ox=e=>e!==null&&typeof e=="object",ure=e=>e===!0||e===!1,lv=e=>{if(aw(e)!=="object")return!1;const r=_S(e);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(LM in e)&&!(rw in e)},mre=e=>{if(!Ox(e)||Ax(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch(r){return!1}},hre=cc("Date"),pre=cc("File"),gre=cc("Blob"),fre=cc("FileList"),xre=e=>Ox(e)&&oo(e.pipe),yre=e=>{let r;return e&&(typeof FormData=="function"&&e instanceof FormData||oo(e.append)&&((r=aw(e))==="formdata"||r==="object"&&oo(e.toString)&&e.toString()==="[object FormData]"))},bre=cc("URLSearchParams"),[vre,wre,jre,_re]=["ReadableStream","Request","Response","Headers"].map(cc),kre=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Px(e,r,{allOwnKeys:a=!1}={}){if(e===null||typeof e=="undefined")return;let s,n;if(typeof e!="object"&&(e=[e]),Vp(e))for(s=0,n=e.length;s<n;s++)r.call(null,e[s],s,e);else{if(Ax(e))return;const i=a?Object.getOwnPropertyNames(e):Object.keys(e),o=i.length;let l;for(s=0;s<o;s++)l=i[s],r.call(null,e[l],l,e)}}function zM(e,r){if(Ax(e))return null;r=r.toLowerCase();const a=Object.keys(e);let s=a.length,n;for(;s-- >0;)if(n=a[s],r===n.toLowerCase())return n;return null}const em=typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:global,$M=e=>!Np(e)&&e!==em;function CN(){const{caseless:e,skipUndefined:r}=$M(this)&&this||{},a={},s=(n,i)=>{const o=e&&zM(a,i)||i;lv(a[o])&&lv(n)?a[o]=CN(a[o],n):lv(n)?a[o]=CN({},n):Vp(n)?a[o]=n.slice():(!r||!Np(n))&&(a[o]=n)};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&Px(arguments[n],s);return a}const Nre=(e,r,a,{allOwnKeys:s}={})=>(Px(r,(n,i)=>{a&&oo(n)?e[i]=MM(n,a):e[i]=n},{allOwnKeys:s}),e),Sre=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Cre=(e,r,a,s)=>{e.prototype=Object.create(r.prototype,s),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:r.prototype}),a&&Object.assign(e.prototype,a)},Tre=(e,r,a,s)=>{let n,i,o;const l={};if(r=r||{},e==null)return r;do{for(n=Object.getOwnPropertyNames(e),i=n.length;i-- >0;)o=n[i],(!s||s(o,e,r))&&!l[o]&&(r[o]=e[o],l[o]=!0);e=a!==!1&&_S(e)}while(e&&(!a||a(e,r))&&e!==Object.prototype);return r},Ere=(e,r,a)=>{e=String(e),(a===void 0||a>e.length)&&(a=e.length),a-=r.length;const s=e.indexOf(r,a);return s!==-1&&s===a},Are=e=>{if(!e)return null;if(Vp(e))return e;let r=e.length;if(!IM(r))return null;const a=new Array(r);for(;r-- >0;)a[r]=e[r];return a},Ore=(e=>r=>e&&r instanceof e)(typeof Uint8Array!="undefined"&&_S(Uint8Array)),Pre=(e,r)=>{const s=(e&&e[rw]).call(e);let n;for(;(n=s.next())&&!n.done;){const i=n.value;r.call(e,i[0],i[1])}},Dre=(e,r)=>{let a;const s=[];for(;(a=e.exec(r))!==null;)s.push(a);return s},Rre=cc("HTMLFormElement"),Mre=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(a,s,n){return s.toUpperCase()+n}),i7=(({hasOwnProperty:e})=>(r,a)=>e.call(r,a))(Object.prototype),Lre=cc("RegExp"),UM=(e,r)=>{const a=Object.getOwnPropertyDescriptors(e),s={};Px(a,(n,i)=>{let o;(o=r(n,i,e))!==!1&&(s[i]=o||n)}),Object.defineProperties(e,s)},Fre=e=>{UM(e,(r,a)=>{if(oo(e)&&["arguments","caller","callee"].indexOf(a)!==-1)return!1;const s=e[a];if(oo(s)){if(r.enumerable=!1,"writable"in r){r.writable=!1;return}r.set||(r.set=()=>{throw Error("Can not rewrite read-only method '"+a+"'")})}})},Ire=(e,r)=>{const a={},s=n=>{n.forEach(i=>{a[i]=!0})};return Vp(e)?s(e):s(String(e).split(r)),a},zre=()=>{},$re=(e,r)=>e!=null&&Number.isFinite(e=+e)?e:r;function Ure(e){return!!(e&&oo(e.append)&&e[LM]==="FormData"&&e[rw])}const Bre=e=>{const r=new Array(10),a=(s,n)=>{if(Ox(s)){if(r.indexOf(s)>=0)return;if(Ax(s))return s;if(!("toJSON"in s)){r[n]=s;const i=Vp(s)?[]:{};return Px(s,(o,l)=>{const c=a(o,n+1);!Np(c)&&(i[l]=c)}),r[n]=void 0,i}}return s};return a(e,0)},Wre=cc("AsyncFunction"),Hre=e=>e&&(Ox(e)||oo(e))&&oo(e.then)&&oo(e.catch),BM=((e,r)=>e?setImmediate:r?((a,s)=>(em.addEventListener("message",({source:n,data:i})=>{n===em&&i===a&&s.length&&s.shift()()},!1),n=>{s.push(n),em.postMessage(a,"*")}))(`axios@${Math.random()}`,[]):a=>setTimeout(a))(typeof setImmediate=="function",oo(em.postMessage)),qre=typeof queueMicrotask!="undefined"?queueMicrotask.bind(em):typeof process!="undefined"&&process.nextTick||BM,Vre=e=>e!=null&&oo(e[rw]),Dt={isArray:Vp,isArrayBuffer:FM,isBuffer:Ax,isFormData:yre,isArrayBufferView:cre,isString:dre,isNumber:IM,isBoolean:ure,isObject:Ox,isPlainObject:lv,isEmptyObject:mre,isReadableStream:vre,isRequest:wre,isResponse:jre,isHeaders:_re,isUndefined:Np,isDate:hre,isFile:pre,isBlob:gre,isRegExp:Lre,isFunction:oo,isStream:xre,isURLSearchParams:bre,isTypedArray:Ore,isFileList:fre,forEach:Px,merge:CN,extend:Nre,trim:kre,stripBOM:Sre,inherits:Cre,toFlatObject:Tre,kindOf:aw,kindOfTest:cc,endsWith:Ere,toArray:Are,forEachEntry:Pre,matchAll:Dre,isHTMLForm:Rre,hasOwnProperty:i7,hasOwnProp:i7,reduceDescriptors:UM,freezeMethods:Fre,toObjectSet:Ire,toCamelCase:Mre,noop:zre,toFiniteNumber:$re,findKey:zM,global:em,isContextDefined:$M,isSpecCompliantForm:Ure,toJSONObject:Bre,isAsyncFn:Wre,isThenable:Hre,setImmediate:BM,asap:qre,isIterable:Vre};function Kr(e,r,a,s,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",r&&(this.code=r),a&&(this.config=a),s&&(this.request=s),n&&(this.response=n,this.status=n.status?n.status:null)}Dt.inherits(Kr,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Dt.toJSONObject(this.config),code:this.code,status:this.status}}});const WM=Kr.prototype,HM={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{HM[e]={value:e}});Object.defineProperties(Kr,HM);Object.defineProperty(WM,"isAxiosError",{value:!0});Kr.from=(e,r,a,s,n,i)=>{const o=Object.create(WM);Dt.toFlatObject(e,o,function(h){return h!==Error.prototype},u=>u!=="isAxiosError");const l=e&&e.message?e.message:"Error",c=r==null&&e?e.code:r;return Kr.call(o,l,c,a,s,n),e&&o.cause==null&&Object.defineProperty(o,"cause",{value:e,configurable:!0}),o.name=e&&e.name||"Error",i&&Object.assign(o,i),o};const Gre=null;function TN(e){return Dt.isPlainObject(e)||Dt.isArray(e)}function qM(e){return Dt.endsWith(e,"[]")?e.slice(0,-2):e}function o7(e,r,a){return e?e.concat(r).map(function(n,i){return n=qM(n),!a&&i?"["+n+"]":n}).join(a?".":""):r}function Kre(e){return Dt.isArray(e)&&!e.some(TN)}const Yre=Dt.toFlatObject(Dt,{},null,function(r){return/^is[A-Z]/.test(r)});function nw(e,r,a){if(!Dt.isObject(e))throw new TypeError("target must be an object");r=r||new FormData,a=Dt.toFlatObject(a,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,k){return!Dt.isUndefined(k[v])});const s=a.metaTokens,n=a.visitor||h,i=a.dots,o=a.indexes,c=(a.Blob||typeof Blob!="undefined"&&Blob)&&Dt.isSpecCompliantForm(r);if(!Dt.isFunction(n))throw new TypeError("visitor must be a function");function u(w){if(w===null)return"";if(Dt.isDate(w))return w.toISOString();if(Dt.isBoolean(w))return w.toString();if(!c&&Dt.isBlob(w))throw new Kr("Blob is not supported. Use a Buffer instead.");return Dt.isArrayBuffer(w)||Dt.isTypedArray(w)?c&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function h(w,v,k){let S=w;if(w&&!k&&typeof w=="object"){if(Dt.endsWith(v,"{}"))v=s?v:v.slice(0,-2),w=JSON.stringify(w);else if(Dt.isArray(w)&&Kre(w)||(Dt.isFileList(w)||Dt.endsWith(v,"[]"))&&(S=Dt.toArray(w)))return v=qM(v),S.forEach(function(C,O){!(Dt.isUndefined(C)||C===null)&&r.append(o===!0?o7([v],O,i):o===null?v:v+"[]",u(C))}),!1}return TN(w)?!0:(r.append(o7(k,v,i),u(w)),!1)}const f=[],y=Object.assign(Yre,{defaultVisitor:h,convertValue:u,isVisitable:TN});function b(w,v){if(!Dt.isUndefined(w)){if(f.indexOf(w)!==-1)throw Error("Circular reference detected in "+v.join("."));f.push(w),Dt.forEach(w,function(S,N){(!(Dt.isUndefined(S)||S===null)&&n.call(r,S,Dt.isString(N)?N.trim():N,v,y))===!0&&b(S,v?v.concat(N):[N])}),f.pop()}}if(!Dt.isObject(e))throw new TypeError("data must be an object");return b(e),r}function l7(e){const r={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(s){return r[s]})}function kS(e,r){this._pairs=[],e&&nw(e,this,r)}const VM=kS.prototype;VM.append=function(r,a){this._pairs.push([r,a])};VM.toString=function(r){const a=r?function(s){return r.call(this,s,l7)}:l7;return this._pairs.map(function(n){return a(n[0])+"="+a(n[1])},"").join("&")};function Jre(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function GM(e,r,a){if(!r)return e;const s=a&&a.encode||Jre;Dt.isFunction(a)&&(a={serialize:a});const n=a&&a.serialize;let i;if(n?i=n(r,a):i=Dt.isURLSearchParams(r)?r.toString():new kS(r,a).toString(s),i){const o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class c7{constructor(){this.handlers=[]}use(r,a,s){return this.handlers.push({fulfilled:r,rejected:a,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(r){this.handlers[r]&&(this.handlers[r]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(r){Dt.forEach(this.handlers,function(s){s!==null&&r(s)})}}const KM={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Zre=typeof URLSearchParams!="undefined"?URLSearchParams:kS,Xre=typeof FormData!="undefined"?FormData:null,Qre=typeof Blob!="undefined"?Blob:null,eae={isBrowser:!0,classes:{URLSearchParams:Zre,FormData:Xre,Blob:Qre},protocols:["http","https","file","blob","url","data"]},NS=typeof window!="undefined"&&typeof document!="undefined",EN=typeof navigator=="object"&&navigator||void 0,tae=NS&&(!EN||["ReactNative","NativeScript","NS"].indexOf(EN.product)<0),rae=typeof WorkerGlobalScope!="undefined"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",aae=NS&&window.location.href||"http://localhost",sae=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:NS,hasStandardBrowserEnv:tae,hasStandardBrowserWebWorkerEnv:rae,navigator:EN,origin:aae},Symbol.toStringTag,{value:"Module"})),hi=se(se({},sae),eae);function nae(e,r){return nw(e,new hi.classes.URLSearchParams,se({visitor:function(a,s,n,i){return hi.isNode&&Dt.isBuffer(a)?(this.append(s,a.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},r))}function iae(e){return Dt.matchAll(/\w+|\[(\w*)]/g,e).map(r=>r[0]==="[]"?"":r[1]||r[0])}function oae(e){const r={},a=Object.keys(e);let s;const n=a.length;let i;for(s=0;s<n;s++)i=a[s],r[i]=e[i];return r}function YM(e){function r(a,s,n,i){let o=a[i++];if(o==="__proto__")return!0;const l=Number.isFinite(+o),c=i>=a.length;return o=!o&&Dt.isArray(n)?n.length:o,c?(Dt.hasOwnProp(n,o)?n[o]=[n[o],s]:n[o]=s,!l):((!n[o]||!Dt.isObject(n[o]))&&(n[o]=[]),r(a,s,n[o],i)&&Dt.isArray(n[o])&&(n[o]=oae(n[o])),!l)}if(Dt.isFormData(e)&&Dt.isFunction(e.entries)){const a={};return Dt.forEachEntry(e,(s,n)=>{r(iae(s),n,a,0)}),a}return null}function lae(e,r,a){if(Dt.isString(e))try{return(r||JSON.parse)(e),Dt.trim(e)}catch(s){if(s.name!=="SyntaxError")throw s}return(a||JSON.stringify)(e)}const Dx={transitional:KM,adapter:["xhr","http","fetch"],transformRequest:[function(r,a){const s=a.getContentType()||"",n=s.indexOf("application/json")>-1,i=Dt.isObject(r);if(i&&Dt.isHTMLForm(r)&&(r=new FormData(r)),Dt.isFormData(r))return n?JSON.stringify(YM(r)):r;if(Dt.isArrayBuffer(r)||Dt.isBuffer(r)||Dt.isStream(r)||Dt.isFile(r)||Dt.isBlob(r)||Dt.isReadableStream(r))return r;if(Dt.isArrayBufferView(r))return r.buffer;if(Dt.isURLSearchParams(r))return a.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),r.toString();let l;if(i){if(s.indexOf("application/x-www-form-urlencoded")>-1)return nae(r,this.formSerializer).toString();if((l=Dt.isFileList(r))||s.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return nw(l?{"files[]":r}:r,c&&new c,this.formSerializer)}}return i||n?(a.setContentType("application/json",!1),lae(r)):r}],transformResponse:[function(r){const a=this.transitional||Dx.transitional,s=a&&a.forcedJSONParsing,n=this.responseType==="json";if(Dt.isResponse(r)||Dt.isReadableStream(r))return r;if(r&&Dt.isString(r)&&(s&&!this.responseType||n)){const o=!(a&&a.silentJSONParsing)&&n;try{return JSON.parse(r,this.parseReviver)}catch(l){if(o)throw l.name==="SyntaxError"?Kr.from(l,Kr.ERR_BAD_RESPONSE,this,null,this.response):l}}return r}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:hi.classes.FormData,Blob:hi.classes.Blob},validateStatus:function(r){return r>=200&&r<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Dt.forEach(["delete","get","head","post","put","patch"],e=>{Dx.headers[e]={}});const cae=Dt.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),dae=e=>{const r={};let a,s,n;return e&&e.split(`
|
||
`).forEach(function(o){n=o.indexOf(":"),a=o.substring(0,n).trim().toLowerCase(),s=o.substring(n+1).trim(),!(!a||r[a]&&cae[a])&&(a==="set-cookie"?r[a]?r[a].push(s):r[a]=[s]:r[a]=r[a]?r[a]+", "+s:s)}),r},d7=Symbol("internals");function Zg(e){return e&&String(e).trim().toLowerCase()}function cv(e){return e===!1||e==null?e:Dt.isArray(e)?e.map(cv):String(e)}function uae(e){const r=Object.create(null),a=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=a.exec(e);)r[s[1]]=s[2];return r}const mae=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function hk(e,r,a,s,n){if(Dt.isFunction(s))return s.call(this,r,a);if(n&&(r=a),!!Dt.isString(r)){if(Dt.isString(s))return r.indexOf(s)!==-1;if(Dt.isRegExp(s))return s.test(r)}}function hae(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(r,a,s)=>a.toUpperCase()+s)}function pae(e,r){const a=Dt.toCamelCase(" "+r);["get","set","has"].forEach(s=>{Object.defineProperty(e,s+a,{value:function(n,i,o){return this[s].call(this,r,n,i,o)},configurable:!0})})}let lo=class{constructor(r){r&&this.set(r)}set(r,a,s){const n=this;function i(l,c,u){const h=Zg(c);if(!h)throw new Error("header name must be a non-empty string");const f=Dt.findKey(n,h);(!f||n[f]===void 0||u===!0||u===void 0&&n[f]!==!1)&&(n[f||c]=cv(l))}const o=(l,c)=>Dt.forEach(l,(u,h)=>i(u,h,c));if(Dt.isPlainObject(r)||r instanceof this.constructor)o(r,a);else if(Dt.isString(r)&&(r=r.trim())&&!mae(r))o(dae(r),a);else if(Dt.isObject(r)&&Dt.isIterable(r)){let l={},c,u;for(const h of r){if(!Dt.isArray(h))throw TypeError("Object iterator must return a key-value pair");l[u=h[0]]=(c=l[u])?Dt.isArray(c)?[...c,h[1]]:[c,h[1]]:h[1]}o(l,a)}else r!=null&&i(a,r,s);return this}get(r,a){if(r=Zg(r),r){const s=Dt.findKey(this,r);if(s){const n=this[s];if(!a)return n;if(a===!0)return uae(n);if(Dt.isFunction(a))return a.call(this,n,s);if(Dt.isRegExp(a))return a.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(r,a){if(r=Zg(r),r){const s=Dt.findKey(this,r);return!!(s&&this[s]!==void 0&&(!a||hk(this,this[s],s,a)))}return!1}delete(r,a){const s=this;let n=!1;function i(o){if(o=Zg(o),o){const l=Dt.findKey(s,o);l&&(!a||hk(s,s[l],l,a))&&(delete s[l],n=!0)}}return Dt.isArray(r)?r.forEach(i):i(r),n}clear(r){const a=Object.keys(this);let s=a.length,n=!1;for(;s--;){const i=a[s];(!r||hk(this,this[i],i,r,!0))&&(delete this[i],n=!0)}return n}normalize(r){const a=this,s={};return Dt.forEach(this,(n,i)=>{const o=Dt.findKey(s,i);if(o){a[o]=cv(n),delete a[i];return}const l=r?hae(i):String(i).trim();l!==i&&delete a[i],a[l]=cv(n),s[l]=!0}),this}concat(...r){return this.constructor.concat(this,...r)}toJSON(r){const a=Object.create(null);return Dt.forEach(this,(s,n)=>{s!=null&&s!==!1&&(a[n]=r&&Dt.isArray(s)?s.join(", "):s)}),a}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([r,a])=>r+": "+a).join(`
|
||
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(r){return r instanceof this?r:new this(r)}static concat(r,...a){const s=new this(r);return a.forEach(n=>s.set(n)),s}static accessor(r){const s=(this[d7]=this[d7]={accessors:{}}).accessors,n=this.prototype;function i(o){const l=Zg(o);s[l]||(pae(n,o),s[l]=!0)}return Dt.isArray(r)?r.forEach(i):i(r),this}};lo.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Dt.reduceDescriptors(lo.prototype,({value:e},r)=>{let a=r[0].toUpperCase()+r.slice(1);return{get:()=>e,set(s){this[a]=s}}});Dt.freezeMethods(lo);function pk(e,r){const a=this||Dx,s=r||a,n=lo.from(s.headers);let i=s.data;return Dt.forEach(e,function(l){i=l.call(a,i,n.normalize(),r?r.status:void 0)}),n.normalize(),i}function JM(e){return!!(e&&e.__CANCEL__)}function Gp(e,r,a){Kr.call(this,e==null?"canceled":e,Kr.ERR_CANCELED,r,a),this.name="CanceledError"}Dt.inherits(Gp,Kr,{__CANCEL__:!0});function ZM(e,r,a){const s=a.config.validateStatus;!a.status||!s||s(a.status)?e(a):r(new Kr("Request failed with status code "+a.status,[Kr.ERR_BAD_REQUEST,Kr.ERR_BAD_RESPONSE][Math.floor(a.status/100)-4],a.config,a.request,a))}function gae(e){const r=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return r&&r[1]||""}function fae(e,r){e=e||10;const a=new Array(e),s=new Array(e);let n=0,i=0,o;return r=r!==void 0?r:1e3,function(c){const u=Date.now(),h=s[i];o||(o=u),a[n]=c,s[n]=u;let f=i,y=0;for(;f!==n;)y+=a[f++],f=f%e;if(n=(n+1)%e,n===i&&(i=(i+1)%e),u-o<r)return;const b=h&&u-h;return b?Math.round(y*1e3/b):void 0}}function xae(e,r){let a=0,s=1e3/r,n,i;const o=(u,h=Date.now())=>{a=h,n=null,i&&(clearTimeout(i),i=null),e(...u)};return[(...u)=>{const h=Date.now(),f=h-a;f>=s?o(u,h):(n=u,i||(i=setTimeout(()=>{i=null,o(n)},s-f)))},()=>n&&o(n)]}const Vv=(e,r,a=3)=>{let s=0;const n=fae(50,250);return xae(i=>{const o=i.loaded,l=i.lengthComputable?i.total:void 0,c=o-s,u=n(c),h=o<=l;s=o;const f={loaded:o,total:l,progress:l?o/l:void 0,bytes:c,rate:u||void 0,estimated:u&&l&&h?(l-o)/u:void 0,event:i,lengthComputable:l!=null,[r?"download":"upload"]:!0};e(f)},a)},u7=(e,r)=>{const a=e!=null;return[s=>r[0]({lengthComputable:a,total:e,loaded:s}),r[1]]},m7=e=>(...r)=>Dt.asap(()=>e(...r)),yae=hi.hasStandardBrowserEnv?((e,r)=>a=>(a=new URL(a,hi.origin),e.protocol===a.protocol&&e.host===a.host&&(r||e.port===a.port)))(new URL(hi.origin),hi.navigator&&/(msie|trident)/i.test(hi.navigator.userAgent)):()=>!0,bae=hi.hasStandardBrowserEnv?{write(e,r,a,s,n,i,o){if(typeof document=="undefined")return;const l=[`${e}=${encodeURIComponent(r)}`];Dt.isNumber(a)&&l.push(`expires=${new Date(a).toUTCString()}`),Dt.isString(s)&&l.push(`path=${s}`),Dt.isString(n)&&l.push(`domain=${n}`),i===!0&&l.push("secure"),Dt.isString(o)&&l.push(`SameSite=${o}`),document.cookie=l.join("; ")},read(e){if(typeof document=="undefined")return null;const r=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return r?decodeURIComponent(r[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function vae(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function wae(e,r){return r?e.replace(/\/?\/$/,"")+"/"+r.replace(/^\/+/,""):e}function XM(e,r,a){let s=!vae(r);return e&&(s||a==!1)?wae(e,r):r}const h7=e=>e instanceof lo?se({},e):e;function km(e,r){r=r||{};const a={};function s(u,h,f,y){return Dt.isPlainObject(u)&&Dt.isPlainObject(h)?Dt.merge.call({caseless:y},u,h):Dt.isPlainObject(h)?Dt.merge({},h):Dt.isArray(h)?h.slice():h}function n(u,h,f,y){if(Dt.isUndefined(h)){if(!Dt.isUndefined(u))return s(void 0,u,f,y)}else return s(u,h,f,y)}function i(u,h){if(!Dt.isUndefined(h))return s(void 0,h)}function o(u,h){if(Dt.isUndefined(h)){if(!Dt.isUndefined(u))return s(void 0,u)}else return s(void 0,h)}function l(u,h,f){if(f in r)return s(u,h);if(f in e)return s(void 0,u)}const c={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:l,headers:(u,h,f)=>n(h7(u),h7(h),f,!0)};return Dt.forEach(Object.keys(se(se({},e),r)),function(h){const f=c[h]||n,y=f(e[h],r[h],h);Dt.isUndefined(y)&&f!==l||(a[h]=y)}),a}const QM=e=>{const r=km({},e);let{data:a,withXSRFToken:s,xsrfHeaderName:n,xsrfCookieName:i,headers:o,auth:l}=r;if(r.headers=o=lo.from(o),r.url=GM(XM(r.baseURL,r.url,r.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&o.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),Dt.isFormData(a)){if(hi.hasStandardBrowserEnv||hi.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(Dt.isFunction(a.getHeaders)){const c=a.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([h,f])=>{u.includes(h.toLowerCase())&&o.set(h,f)})}}if(hi.hasStandardBrowserEnv&&(s&&Dt.isFunction(s)&&(s=s(r)),s||s!==!1&&yae(r.url))){const c=n&&i&&bae.read(i);c&&o.set(n,c)}return r},jae=typeof XMLHttpRequest!="undefined",_ae=jae&&function(e){return new Promise(function(a,s){const n=QM(e);let i=n.data;const o=lo.from(n.headers).normalize();let{responseType:l,onUploadProgress:c,onDownloadProgress:u}=n,h,f,y,b,w;function v(){b&&b(),w&&w(),n.cancelToken&&n.cancelToken.unsubscribe(h),n.signal&&n.signal.removeEventListener("abort",h)}let k=new XMLHttpRequest;k.open(n.method.toUpperCase(),n.url,!0),k.timeout=n.timeout;function S(){if(!k)return;const C=lo.from("getAllResponseHeaders"in k&&k.getAllResponseHeaders()),T={data:!l||l==="text"||l==="json"?k.responseText:k.response,status:k.status,statusText:k.statusText,headers:C,config:e,request:k};ZM(function(E){a(E),v()},function(E){s(E),v()},T),k=null}"onloadend"in k?k.onloadend=S:k.onreadystatechange=function(){!k||k.readyState!==4||k.status===0&&!(k.responseURL&&k.responseURL.indexOf("file:")===0)||setTimeout(S)},k.onabort=function(){k&&(s(new Kr("Request aborted",Kr.ECONNABORTED,e,k)),k=null)},k.onerror=function(O){const T=O&&O.message?O.message:"Network Error",P=new Kr(T,Kr.ERR_NETWORK,e,k);P.event=O||null,s(P),k=null},k.ontimeout=function(){let O=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const T=n.transitional||KM;n.timeoutErrorMessage&&(O=n.timeoutErrorMessage),s(new Kr(O,T.clarifyTimeoutError?Kr.ETIMEDOUT:Kr.ECONNABORTED,e,k)),k=null},i===void 0&&o.setContentType(null),"setRequestHeader"in k&&Dt.forEach(o.toJSON(),function(O,T){k.setRequestHeader(T,O)}),Dt.isUndefined(n.withCredentials)||(k.withCredentials=!!n.withCredentials),l&&l!=="json"&&(k.responseType=n.responseType),u&&([y,w]=Vv(u,!0),k.addEventListener("progress",y)),c&&k.upload&&([f,b]=Vv(c),k.upload.addEventListener("progress",f),k.upload.addEventListener("loadend",b)),(n.cancelToken||n.signal)&&(h=C=>{k&&(s(!C||C.type?new Gp(null,e,k):C),k.abort(),k=null)},n.cancelToken&&n.cancelToken.subscribe(h),n.signal&&(n.signal.aborted?h():n.signal.addEventListener("abort",h)));const N=gae(n.url);if(N&&hi.protocols.indexOf(N)===-1){s(new Kr("Unsupported protocol "+N+":",Kr.ERR_BAD_REQUEST,e));return}k.send(i||null)})},kae=(e,r)=>{const{length:a}=e=e?e.filter(Boolean):[];if(r||a){let s=new AbortController,n;const i=function(u){if(!n){n=!0,l();const h=u instanceof Error?u:this.reason;s.abort(h instanceof Kr?h:new Gp(h instanceof Error?h.message:h))}};let o=r&&setTimeout(()=>{o=null,i(new Kr(`timeout ${r} of ms exceeded`,Kr.ETIMEDOUT))},r);const l=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),e=null)};e.forEach(u=>u.addEventListener("abort",i));const{signal:c}=s;return c.unsubscribe=()=>Dt.asap(l),c}},Nae=function*(e,r){let a=e.byteLength;if(a<r){yield e;return}let s=0,n;for(;s<a;)n=s+r,yield e.slice(s,n),s=n},Sae=function(e,r){return $_(this,null,function*(){try{for(var a=kT(Cae(e)),s,n,i;s=!(n=yield new P0(a.next())).done;s=!1){const o=n.value;yield*U_(Nae(o,r))}}catch(n){i=[n]}finally{try{s&&(n=a.return)&&(yield new P0(n.call(a)))}finally{if(i)throw i[0]}}})},Cae=function(e){return $_(this,null,function*(){if(e[Symbol.asyncIterator]){yield*U_(e);return}const r=e.getReader();try{for(;;){const{done:a,value:s}=yield new P0(r.read());if(a)break;yield s}}finally{yield new P0(r.cancel())}})},p7=(e,r,a,s)=>{const n=Sae(e,r);let i=0,o,l=u=>{o||(o=!0,s&&s(u))};return new ReadableStream({pull(u){return J(this,null,function*(){try{const{done:h,value:f}=yield n.next();if(h){l(),u.close();return}let y=f.byteLength;if(a){let b=i+=y;a(b)}u.enqueue(new Uint8Array(f))}catch(h){throw l(h),h}})},cancel(u){return l(u),n.return()}},{highWaterMark:2})},g7=64*1024,{isFunction:yb}=Dt,Tae=(({Request:e,Response:r})=>({Request:e,Response:r}))(Dt.global),{ReadableStream:f7,TextEncoder:x7}=Dt.global,y7=(e,...r)=>{try{return!!e(...r)}catch(a){return!1}},Eae=e=>{e=Dt.merge.call({skipUndefined:!0},Tae,e);const{fetch:r,Request:a,Response:s}=e,n=r?yb(r):typeof fetch=="function",i=yb(a),o=yb(s);if(!n)return!1;const l=n&&yb(f7),c=n&&(typeof x7=="function"?(w=>v=>w.encode(v))(new x7):w=>J(null,null,function*(){return new Uint8Array(yield new a(w).arrayBuffer())})),u=i&&l&&y7(()=>{let w=!1;const v=new a(hi.origin,{body:new f7,method:"POST",get duplex(){return w=!0,"half"}}).headers.has("Content-Type");return w&&!v}),h=o&&l&&y7(()=>Dt.isReadableStream(new s("").body)),f={stream:h&&(w=>w.body)};n&&["text","arrayBuffer","blob","formData","stream"].forEach(w=>{!f[w]&&(f[w]=(v,k)=>{let S=v&&v[w];if(S)return S.call(v);throw new Kr(`Response type '${w}' is not supported`,Kr.ERR_NOT_SUPPORT,k)})});const y=w=>J(null,null,function*(){if(w==null)return 0;if(Dt.isBlob(w))return w.size;if(Dt.isSpecCompliantForm(w))return(yield new a(hi.origin,{method:"POST",body:w}).arrayBuffer()).byteLength;if(Dt.isArrayBufferView(w)||Dt.isArrayBuffer(w))return w.byteLength;if(Dt.isURLSearchParams(w)&&(w=w+""),Dt.isString(w))return(yield c(w)).byteLength}),b=(w,v)=>J(null,null,function*(){const k=Dt.toFiniteNumber(w.getContentLength());return k==null?y(v):k});return w=>J(null,null,function*(){let{url:v,method:k,data:S,signal:N,cancelToken:C,timeout:O,onDownloadProgress:T,onUploadProgress:P,responseType:E,headers:R,withCredentials:z="same-origin",fetchOptions:G}=QM(w),ae=r||fetch;E=E?(E+"").toLowerCase():"text";let ee=kae([N,C&&C.toAbortSignal()],O),ne=null;const te=ee&&ee.unsubscribe&&(()=>{ee.unsubscribe()});let Y;try{if(P&&u&&k!=="get"&&k!=="head"&&(Y=yield b(R,S))!==0){let V=new a(v,{method:"POST",body:S,duplex:"half"}),I;if(Dt.isFormData(S)&&(I=V.headers.get("content-type"))&&R.setContentType(I),V.body){const[B,Q]=u7(Y,Vv(m7(P)));S=p7(V.body,g7,B,Q)}}Dt.isString(z)||(z=z?"include":"omit");const q=i&&"credentials"in a.prototype,H=je(se({},G),{signal:ee,method:k.toUpperCase(),headers:R.normalize().toJSON(),body:S,duplex:"half",credentials:q?z:void 0});ne=i&&new a(v,H);let U=yield i?ae(ne,G):ae(v,H);const re=h&&(E==="stream"||E==="response");if(h&&(T||re&&te)){const V={};["status","statusText","headers"].forEach(ie=>{V[ie]=U[ie]});const I=Dt.toFiniteNumber(U.headers.get("content-length")),[B,Q]=T&&u7(I,Vv(m7(T),!0))||[];U=new s(p7(U.body,g7,B,()=>{Q&&Q(),te&&te()}),V)}E=E||"text";let X=yield f[Dt.findKey(f,E)||"text"](U,w);return!re&&te&&te(),yield new Promise((V,I)=>{ZM(V,I,{data:X,headers:lo.from(U.headers),status:U.status,statusText:U.statusText,config:w,request:ne})})}catch(q){throw te&&te(),q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)?Object.assign(new Kr("Network Error",Kr.ERR_NETWORK,w,ne),{cause:q.cause||q}):Kr.from(q,q&&q.code,w,ne)}})},Aae=new Map,eL=e=>{let r=e&&e.env||{};const{fetch:a,Request:s,Response:n}=r,i=[s,n,a];let o=i.length,l=o,c,u,h=Aae;for(;l--;)c=i[l],u=h.get(c),u===void 0&&h.set(c,u=l?new Map:Eae(r)),h=u;return u};eL();const SS={http:Gre,xhr:_ae,fetch:{get:eL}};Dt.forEach(SS,(e,r)=>{if(e){try{Object.defineProperty(e,"name",{value:r})}catch(a){}Object.defineProperty(e,"adapterName",{value:r})}});const b7=e=>`- ${e}`,Oae=e=>Dt.isFunction(e)||e===null||e===!1;function Pae(e,r){e=Dt.isArray(e)?e:[e];const{length:a}=e;let s,n;const i={};for(let o=0;o<a;o++){s=e[o];let l;if(n=s,!Oae(s)&&(n=SS[(l=String(s)).toLowerCase()],n===void 0))throw new Kr(`Unknown adapter '${l}'`);if(n&&(Dt.isFunction(n)||(n=n.get(r))))break;i[l||"#"+o]=n}if(!n){const o=Object.entries(i).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build"));let l=a?o.length>1?`since :
|
||
`+o.map(b7).join(`
|
||
`):" "+b7(o[0]):"as no adapter specified";throw new Kr("There is no suitable adapter to dispatch the request "+l,"ERR_NOT_SUPPORT")}return n}const tL={getAdapter:Pae,adapters:SS};function gk(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Gp(null,e)}function v7(e){return gk(e),e.headers=lo.from(e.headers),e.data=pk.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),tL.getAdapter(e.adapter||Dx.adapter,e)(e).then(function(s){return gk(e),s.data=pk.call(e,e.transformResponse,s),s.headers=lo.from(s.headers),s},function(s){return JM(s)||(gk(e),s&&s.response&&(s.response.data=pk.call(e,e.transformResponse,s.response),s.response.headers=lo.from(s.response.headers))),Promise.reject(s)})}const rL="1.13.2",iw={};["object","boolean","number","function","string","symbol"].forEach((e,r)=>{iw[e]=function(s){return typeof s===e||"a"+(r<1?"n ":" ")+e}});const w7={};iw.transitional=function(r,a,s){function n(i,o){return"[Axios v"+rL+"] Transitional option '"+i+"'"+o+(s?". "+s:"")}return(i,o,l)=>{if(r===!1)throw new Kr(n(o," has been removed"+(a?" in "+a:"")),Kr.ERR_DEPRECATED);return a&&!w7[o]&&(w7[o]=!0,console.warn(n(o," has been deprecated since v"+a+" and will be removed in the near future"))),r?r(i,o,l):!0}};iw.spelling=function(r){return(a,s)=>(console.warn(`${s} is likely a misspelling of ${r}`),!0)};function Dae(e,r,a){if(typeof e!="object")throw new Kr("options must be an object",Kr.ERR_BAD_OPTION_VALUE);const s=Object.keys(e);let n=s.length;for(;n-- >0;){const i=s[n],o=r[i];if(o){const l=e[i],c=l===void 0||o(l,i,e);if(c!==!0)throw new Kr("option "+i+" must be "+c,Kr.ERR_BAD_OPTION_VALUE);continue}if(a!==!0)throw new Kr("Unknown option "+i,Kr.ERR_BAD_OPTION)}}const dv={assertOptions:Dae,validators:iw},_c=dv.validators;let mm=class{constructor(r){this.defaults=r||{},this.interceptors={request:new c7,response:new c7}}request(r,a){return J(this,null,function*(){try{return yield this._request(r,a)}catch(s){if(s instanceof Error){let n={};Error.captureStackTrace?Error.captureStackTrace(n):n=new Error;const i=n.stack?n.stack.replace(/^.+\n/,""):"";try{s.stack?i&&!String(s.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(s.stack+=`
|
||
`+i):s.stack=i}catch(o){}}throw s}})}_request(r,a){typeof r=="string"?(a=a||{},a.url=r):a=r||{},a=km(this.defaults,a);const{transitional:s,paramsSerializer:n,headers:i}=a;s!==void 0&&dv.assertOptions(s,{silentJSONParsing:_c.transitional(_c.boolean),forcedJSONParsing:_c.transitional(_c.boolean),clarifyTimeoutError:_c.transitional(_c.boolean)},!1),n!=null&&(Dt.isFunction(n)?a.paramsSerializer={serialize:n}:dv.assertOptions(n,{encode:_c.function,serialize:_c.function},!0)),a.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?a.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:a.allowAbsoluteUrls=!0),dv.assertOptions(a,{baseUrl:_c.spelling("baseURL"),withXsrfToken:_c.spelling("withXSRFToken")},!0),a.method=(a.method||this.defaults.method||"get").toLowerCase();let o=i&&Dt.merge(i.common,i[a.method]);i&&Dt.forEach(["delete","get","head","post","put","patch","common"],w=>{delete i[w]}),a.headers=lo.concat(o,i);const l=[];let c=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(a)===!1||(c=c&&v.synchronous,l.unshift(v.fulfilled,v.rejected))});const u=[];this.interceptors.response.forEach(function(v){u.push(v.fulfilled,v.rejected)});let h,f=0,y;if(!c){const w=[v7.bind(this),void 0];for(w.unshift(...l),w.push(...u),y=w.length,h=Promise.resolve(a);f<y;)h=h.then(w[f++],w[f++]);return h}y=l.length;let b=a;for(;f<y;){const w=l[f++],v=l[f++];try{b=w(b)}catch(k){v.call(this,k);break}}try{h=v7.call(this,b)}catch(w){return Promise.reject(w)}for(f=0,y=u.length;f<y;)h=h.then(u[f++],u[f++]);return h}getUri(r){r=km(this.defaults,r);const a=XM(r.baseURL,r.url,r.allowAbsoluteUrls);return GM(a,r.params,r.paramsSerializer)}};Dt.forEach(["delete","get","head","options"],function(r){mm.prototype[r]=function(a,s){return this.request(km(s||{},{method:r,url:a,data:(s||{}).data}))}});Dt.forEach(["post","put","patch"],function(r){function a(s){return function(i,o,l){return this.request(km(l||{},{method:r,headers:s?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}mm.prototype[r]=a(),mm.prototype[r+"Form"]=a(!0)});let Rae=class aL{constructor(r){if(typeof r!="function")throw new TypeError("executor must be a function.");let a;this.promise=new Promise(function(i){a=i});const s=this;this.promise.then(n=>{if(!s._listeners)return;let i=s._listeners.length;for(;i-- >0;)s._listeners[i](n);s._listeners=null}),this.promise.then=n=>{let i;const o=new Promise(l=>{s.subscribe(l),i=l}).then(n);return o.cancel=function(){s.unsubscribe(i)},o},r(function(i,o,l){s.reason||(s.reason=new Gp(i,o,l),a(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(r){if(this.reason){r(this.reason);return}this._listeners?this._listeners.push(r):this._listeners=[r]}unsubscribe(r){if(!this._listeners)return;const a=this._listeners.indexOf(r);a!==-1&&this._listeners.splice(a,1)}toAbortSignal(){const r=new AbortController,a=s=>{r.abort(s)};return this.subscribe(a),r.signal.unsubscribe=()=>this.unsubscribe(a),r.signal}static source(){let r;return{token:new aL(function(n){r=n}),cancel:r}}};function Mae(e){return function(a){return e.apply(null,a)}}function Lae(e){return Dt.isObject(e)&&e.isAxiosError===!0}const AN={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(AN).forEach(([e,r])=>{AN[r]=e});function sL(e){const r=new mm(e),a=MM(mm.prototype.request,r);return Dt.extend(a,mm.prototype,r,{allOwnKeys:!0}),Dt.extend(a,r,null,{allOwnKeys:!0}),a.create=function(n){return sL(km(e,n))},a}const Js=sL(Dx);Js.Axios=mm;Js.CanceledError=Gp;Js.CancelToken=Rae;Js.isCancel=JM;Js.VERSION=rL;Js.toFormData=nw;Js.AxiosError=Kr;Js.Cancel=Js.CanceledError;Js.all=function(r){return Promise.all(r)};Js.spread=Mae;Js.isAxiosError=Lae;Js.mergeConfig=km;Js.AxiosHeaders=lo;Js.formToJSON=e=>YM(Dt.isHTMLForm(e)?new FormData(e):e);Js.getAdapter=tL.getAdapter;Js.HttpStatusCode=AN;Js.default=Js;const{Axios:QSe,AxiosError:e3e,CanceledError:t3e,isCancel:r3e,CancelToken:a3e,VERSION:s3e,all:n3e,Cancel:i3e,isAxiosError:o3e,spread:l3e,toFormData:c3e,AxiosHeaders:d3e,HttpStatusCode:u3e,formToJSON:m3e,getAdapter:h3e,mergeConfig:p3e}=Js;class Fae{constructor(){$s(this,"client");$s(this,"baseURL");$s(this,"siteName");this.baseURL="http://localhost:8000",this.siteName="seeraasm-med.seeraarabia.com",this.client=Js.create({baseURL:this.baseURL,timeout:parseInt("10000"),withCredentials:!0,headers:{"Content-Type":"application/json",Accept:"application/json"}}),this.client.interceptors.request.use(r=>{var a;return(a=r.url)!=null&&a.includes("/api/")&&(r.url=`/${this.siteName}${r.url}`),r}),this.client.interceptors.response.use(r=>r,r=>{var a;return((a=r.response)==null?void 0:a.status)===401&&(window.location.href="/login"),Promise.reject(r)})}login(r){return J(this,null,function*(){return(yield this.client.post("/api/method/login",r)).data})}logout(){return J(this,null,function*(){return(yield this.client.post("/api/method/logout")).data})}getCurrentUser(){return J(this,null,function*(){return(yield this.client.get("/api/method/frappe.auth.get_logged_user")).data})}callMethod(s){return J(this,arguments,function*(r,a={}){return(yield this.client.post(`/api/method/${r}`,a)).data})}frappeGet(s){return J(this,arguments,function*(r,a={}){return this.callMethod(r,a)})}getDocTypeRecords(n){return J(this,arguments,function*(r,a={},s=[]){const i=new URLSearchParams;return Object.keys(a).length>0&&i.append("filters",JSON.stringify(a)),s.length>0&&i.append("fields",JSON.stringify(s)),(yield this.client.get(`/api/resource/${r}?${i.toString()}`)).data})}getDocTypeRecord(r,a){return J(this,null,function*(){return(yield this.client.get(`/api/resource/${r}/${a}`)).data})}createDocTypeRecord(r,a){return J(this,null,function*(){return(yield this.client.post(`/api/resource/${r}`,a)).data})}updateDocTypeRecord(r,a,s){return J(this,null,function*(){return(yield this.client.put(`/api/resource/${r}/${a}`,s)).data})}deleteDocTypeRecord(r,a){return J(this,null,function*(){return(yield this.client.delete(`/api/resource/${r}/${a}`)).data})}uploadFile(r,a="Home"){return J(this,null,function*(){const s=new FormData;return s.append("file",r),s.append("folder",a),s.append("is_private","0"),(yield this.client.post("/api/method/upload_file",s,{headers:{"Content-Type":"multipart/form-data"}})).data})}}const nL=new Fae,Iae=()=>{const{t:e}=sr(),[r,a]=p.useState([]),[s,n]=p.useState(!0),[i,o]=p.useState(null),[l,c]=p.useState(""),u=hr();p.useEffect(()=>{h()},[]);const h=()=>J(null,null,function*(){var b,w;try{n(!0);const v=yield nL.getDocTypeRecords("User",{},["name","full_name","email","enabled","creation","modified"]);a(v.message||[])}catch(v){o(((w=(b=v.response)==null?void 0:b.data)==null?void 0:w.message)||"Failed to load users")}finally{n(!1)}}),f=r.filter(b=>{var w,v,k;return((w=b.full_name)==null?void 0:w.toLowerCase().includes(l.toLowerCase()))||((v=b.email)==null?void 0:v.toLowerCase().includes(l.toLowerCase()))||((k=b.name)==null?void 0:k.toLowerCase().includes(l.toLowerCase()))}),y=b=>{u(`/users/${b.name}`)};return s?t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900",children:t.jsx("div",{className:"animate-spin rounded-full h-32 w-32 border-b-2 border-indigo-600"})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900",children:[t.jsx("header",{className:"bg-white dark:bg-gray-800 shadow",children:t.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"flex justify-between items-center py-6",children:[t.jsxs("div",{className:"flex items-center",children:[t.jsx("button",{onClick:()=>u("/dashboard"),className:"mr-4 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300",children:t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),t.jsx("h1",{className:"text-3xl font-bold text-gray-900 dark:text-white",children:e("users.title")})]}),t.jsx("div",{className:"flex items-center space-x-4",children:t.jsx("button",{onClick:()=>u("/dashboard"),className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-md text-sm font-medium",children:e("users.backToDashboard")})})]})})}),t.jsxs("main",{className:"max-w-7xl mx-auto py-6 sm:px-6 lg:px-8",children:[i&&t.jsx("div",{className:"mb-6 rounded-md bg-red-50 dark:bg-red-900/20 p-4",children:t.jsx("div",{className:"text-sm text-red-700 dark:text-red-400",children:i})}),t.jsxs("div",{className:"mb-6 flex flex-col sm:flex-row sm:items-center sm:justify-between",children:[t.jsx("div",{className:"flex-1 min-w-0",children:t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:t.jsx("svg",{className:"h-5 w-5 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),t.jsx("input",{type:"text",placeholder:e("users.searchUsers"),value:l,onChange:b=>c(b.target.value),className:"block w-full pl-10 pr-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md leading-5 bg-white dark:bg-gray-700 placeholder-gray-500 dark:placeholder-gray-400 text-gray-900 dark:text-white focus:outline-none focus:placeholder-gray-400 focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"})]})}),t.jsx("div",{className:"mt-4 sm:mt-0 sm:ml-4",children:t.jsxs("button",{onClick:h,className:"inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500",children:[t.jsx("svg",{className:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),e("users.refresh")]})})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow overflow-hidden sm:rounded-md",children:[t.jsxs("div",{className:"px-4 py-5 sm:px-6",children:[t.jsxs("h3",{className:"text-lg leading-6 font-medium text-gray-900 dark:text-white",children:[e("users.title")," (",f.length,")"]}),t.jsx("p",{className:"mt-1 max-w-2xl text-sm text-gray-500 dark:text-gray-400",children:e("users.manageUsers")})]}),f.length===0?t.jsxs("div",{className:"text-center py-12",children:[t.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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.5 2.5 0 11-5 0 2.5 2.5 0 015 0z"})}),t.jsx("h3",{className:"mt-2 text-sm font-medium text-gray-900 dark:text-white",children:e("users.noUsersFound")}),t.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:e(l?"users.tryAdjustingSearch":"users.noUsersAvailable")})]}):t.jsx("ul",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:f.map(b=>{var w;return t.jsx("li",{children:t.jsxs("div",{className:"px-4 py-4 flex items-center justify-between hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer",onClick:()=>y(b),children:[t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0 h-10 w-10",children:t.jsx("div",{className:"h-10 w-10 rounded-full bg-indigo-100 dark:bg-indigo-900 flex items-center justify-center",children:t.jsx("span",{className:"text-sm font-medium text-indigo-600 dark:text-indigo-300",children:((w=b.full_name)==null?void 0:w.charAt(0))||b.name.charAt(0)})})}),t.jsxs("div",{className:"ml-4",children:[t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:b.full_name||b.name}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:b.email||e("users.noEmail")})]})]}),t.jsxs("div",{className:"flex items-center space-x-4",children:[t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:`w-2 h-2 rounded-full mr-2 ${b.enabled?"bg-green-400":"bg-red-400"}`}),b.enabled?e("users.active"):e("users.inactive")]})}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:[e("users.created"),": ",new Date(b.creation).toLocaleDateString()]}),t.jsx("svg",{className:"w-5 h-5 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})]})},b.name)})})]})]})]})},zae=()=>{const{t:e}=sr(),[r,a]=p.useState([]),[s,n]=p.useState(!0),[i,o]=p.useState(null);p.useEffect(()=>{l()},[]);const l=()=>J(null,null,function*(){try{n(!0);const f=yield nL.frappeGet("frappe.desk.doctype.event.event.get_events");a(f.message||[])}catch(f){console.log("API call failed, using demo events:",f);const y=[{name:"EVT001",subject:"Team Meeting - Asset Management Review",starts_on:new Date().toISOString(),ends_on:new Date(Date.now()+36e5).toISOString(),status:"Open",event_type:"Meeting",description:"Monthly review of asset management processes"},{name:"EVT002",subject:"System Maintenance Window",starts_on:new Date(Date.now()+864e5).toISOString(),ends_on:new Date(Date.now()+864e5+72e5).toISOString(),status:"Scheduled",event_type:"Maintenance",description:"Scheduled maintenance for Seera Arabia AMS"},{name:"EVT003",subject:"User Training Session",starts_on:new Date(Date.now()+1728e5).toISOString(),ends_on:new Date(Date.now()+1728e5+108e5).toISOString(),status:"Open",event_type:"Training",description:"Training session for new users on AMS features"}];a(y),o(null)}finally{n(!1)}}),c=f=>new Date(f).toLocaleString(),u=f=>{switch(f.toLowerCase()){case"open":return"bg-green-100 text-green-800";case"scheduled":return"bg-blue-100 text-blue-800";case"completed":return"bg-gray-100 text-gray-800";case"cancelled":return"bg-red-100 text-red-800";default:return"bg-gray-100 text-gray-800"}},h=f=>{switch(f.toLowerCase()){case"meeting":return"bg-purple-100 text-purple-800";case"training":return"bg-yellow-100 text-yellow-800";case"maintenance":return"bg-orange-100 text-orange-800";default:return"bg-gray-100 text-gray-800"}};return s?t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900",children:t.jsx("div",{className:"animate-spin rounded-full h-32 w-32 border-b-2 border-indigo-600"})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900",children:[t.jsx("header",{className:"bg-white dark:bg-gray-800 shadow",children:t.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"flex justify-between items-center py-6",children:[t.jsx("div",{className:"flex items-center",children:t.jsx("h1",{className:"text-3xl font-bold text-gray-900 dark:text-white",children:e("events.title")})}),t.jsx("div",{className:"flex items-center space-x-4",children:t.jsx("button",{onClick:l,className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-md text-sm font-medium",children:e("events.refreshEvents")})})]})})}),t.jsxs("main",{className:"max-w-7xl mx-auto py-6 sm:px-6 lg:px-8",children:[i&&t.jsx("div",{className:"mb-6 rounded-md bg-red-50 dark:bg-red-900/20 p-4",children:t.jsx("div",{className:"text-sm text-red-700 dark:text-red-400",children:i})}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow overflow-hidden sm:rounded-md",children:[t.jsxs("div",{className:"px-4 py-5 sm:px-6",children:[t.jsxs("h3",{className:"text-lg leading-6 font-medium text-gray-900 dark:text-white",children:[e("events.upcomingEvents")," (",r.length,")"]}),t.jsx("p",{className:"mt-1 max-w-2xl text-sm text-gray-500 dark:text-gray-400",children:e("events.eventsFromFrappe")})]}),r.length===0?t.jsxs("div",{className:"text-center py-12",children:[t.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),t.jsx("h3",{className:"mt-2 text-sm font-medium text-gray-900 dark:text-white",children:e("events.noEventsFound")}),t.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:e("events.noEventsScheduled")})]}):t.jsx("ul",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:r.map(f=>t.jsx("li",{children:t.jsx("div",{className:"px-4 py-4 hover:bg-gray-50 dark:hover:bg-gray-700",children:t.jsx("div",{className:"flex items-center justify-between",children:t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h4",{className:"text-lg font-medium text-gray-900 dark:text-white",children:f.subject}),t.jsxs("div",{className:"flex space-x-2",children:[t.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${u(f.status)}`,children:f.status}),t.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${h(f.event_type)}`,children:f.event_type})]})]}),f.description&&t.jsx("p",{className:"mt-1 text-sm text-gray-600 dark:text-gray-400",children:f.description}),t.jsxs("div",{className:"mt-2 flex items-center text-sm text-gray-500 dark:text-gray-400",children:[t.jsx("svg",{className:"flex-shrink-0 mr-1.5 h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),t.jsxs("span",{children:[c(f.starts_on)," - ",c(f.ends_on)]})]})]})})})},f.name))})]}),t.jsx("div",{className:"mt-8 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-md p-4",children:t.jsxs("div",{className:"flex",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("svg",{className:"h-5 w-5 text-blue-400",fill:"currentColor",viewBox:"0 0 20 20",children:t.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"})})}),t.jsxs("div",{className:"ml-3",children:[t.jsx("h3",{className:"text-sm font-medium text-blue-800 dark:text-blue-300",children:"API Endpoint Information"}),t.jsxs("div",{className:"mt-2 text-sm text-blue-700 dark:text-blue-400",children:[t.jsxs("p",{children:[t.jsx("strong",{children:"Endpoint:"})," ",t.jsx("code",{children:"frappe.desk.doctype.event.event.get_events"})]}),t.jsxs("p",{children:[t.jsx("strong",{children:"Full URL:"})," ",t.jsx("code",{children:"https://seeraasm-med.seeraarabia.com/api/method/frappe.desk.doctype.event.event.get_events"})]}),t.jsxs("p",{children:[t.jsx("strong",{children:"Method:"})," POST (Frappe API standard)"]})]})]})]})})]})]})},iL={Location:{doctype:"Location",title:"Create New Location",titleField:"location_name",fields:[{fieldname:"location_name",label:"Location Name",fieldtype:"Data",required:!0,placeholder:"Enter location name"},{fieldname:"parent_location",label:"Parent Location",fieldtype:"Link",linkDoctype:"Location",placeholder:"Select parent location (optional)"},{fieldname:"is_group",label:"Is Group",fieldtype:"Check",defaultValue:0,description:"Check if this location contains sub-locations"},{fieldname:"latitude",label:"Latitude",fieldtype:"Float",placeholder:"e.g., 24.7136"},{fieldname:"longitude",label:"Longitude",fieldtype:"Float",placeholder:"e.g., 46.6753"}]},Room:{doctype:"Room",title:"Create New Room",titleField:"name",fields:[{fieldname:"room",label:"Room Name/Number",fieldtype:"Data",required:!0,placeholder:"Enter room name or number"},{fieldname:"building",label:"Building",fieldtype:"Link",linkDoctype:"Building",placeholder:"Select building"},{fieldname:"location_name",label:"Location Name",fieldtype:"Link",linkDoctype:"Location",placeholder:"Select Location"},{fieldname:"department",label:"Department",fieldtype:"Link",linkDoctype:"Department",placeholder:"Select department"}]},Building:{doctype:"Building",title:"Create New Building",titleField:"name",fields:[{fieldname:"building",label:"Building Name",fieldtype:"Data",required:!0,placeholder:"Enter building name"}]},"Extension Directory":{doctype:"Extension Directory",title:"Create New Extension",titleField:"name",fields:[{fieldname:"extension_number",label:"Extension Number",fieldtype:"Data",required:!0,placeholder:"Enter extension number"}]},Department:{doctype:"Department",title:"Create New Department",titleField:"department_name",fields:[{fieldname:"department_name",label:"Department Name",fieldtype:"Data",required:!0,placeholder:"Enter department name"},{fieldname:"company",label:"Company",fieldtype:"Link",linkDoctype:"Company",required:!0,placeholder:"Select company"},{fieldname:"parent_department",label:"Parent Department",fieldtype:"Link",linkDoctype:"Department",placeholder:"Select parent department"},{fieldname:"is_group",label:"Is Group",fieldtype:"Check",defaultValue:0}]},"Issue Type":{doctype:"Issue Type",title:"Create New Issue Type",titleField:"name",fields:[{fieldname:"__newname",label:"Issue Type Name",fieldtype:"Data",required:!0,placeholder:"Enter issue type name"},{fieldname:"description",label:"Description",fieldtype:"Text",placeholder:"Enter description"}]},Manufacturer:{doctype:"Manufacturer",title:"Create New Manufacturer",titleField:"name",fields:[{fieldname:"short_name",label:"Manufacturer Name",fieldtype:"Data",required:!0,placeholder:"Enter manufacturer name"},{fieldname:"full_name",label:"Full Name",fieldtype:"Data",placeholder:"Enter full company name"},{fieldname:"website",label:"Website",fieldtype:"Data",placeholder:"https://example.com"},{fieldname:"country",label:"Country",fieldtype:"Link",linkDoctype:"Country",placeholder:"Select country"}]},Supplier:{doctype:"Supplier",title:"Create New Supplier",titleField:"supplier_name",fields:[{fieldname:"supplier_name",label:"Supplier Name",fieldtype:"Data",required:!0,placeholder:"Enter supplier name"},{fieldname:"supplier_group",label:"Supplier Group",fieldtype:"Link",linkDoctype:"Supplier Group",placeholder:"Select supplier group"},{fieldname:"supplier_type",label:"Supplier Type",fieldtype:"Select",options:["Company","Individual"],defaultValue:"Company"},{fieldname:"country",label:"Country",fieldtype:"Link",linkDoctype:"Country",placeholder:"Select country"}]},Warehouse:{doctype:"Warehouse",title:"Create New Warehouse",titleField:"warehouse_name",fields:[{fieldname:"warehouse_name",label:"Warehouse Name",fieldtype:"Data",required:!0,placeholder:"Enter warehouse name"},{fieldname:"company",label:"Company",fieldtype:"Link",linkDoctype:"Company",required:!0,placeholder:"Select company"},{fieldname:"parent_warehouse",label:"Parent Warehouse",fieldtype:"Link",linkDoctype:"Warehouse",placeholder:"Select parent warehouse"},{fieldname:"is_group",label:"Is Group",fieldtype:"Check",defaultValue:0}]},Item:{doctype:"Item",title:"Create New Item",titleField:"item_name",fields:[{fieldname:"item_code",label:"Item Code",fieldtype:"Data",required:!0,placeholder:"Enter item code"},{fieldname:"item_name",label:"Item Name",fieldtype:"Data",required:!0,placeholder:"Enter item name"},{fieldname:"item_group",label:"Item Group",fieldtype:"Link",linkDoctype:"Item Group",required:!0,placeholder:"Select item group"},{fieldname:"stock_uom",label:"Default Unit of Measure",fieldtype:"Link",linkDoctype:"UOM",required:!0,defaultValue:"Nos",placeholder:"Select UOM"},{fieldname:"is_stock_item",label:"Maintain Stock",fieldtype:"Check",defaultValue:1},{fieldname:"description",label:"Description",fieldtype:"Text",placeholder:"Enter item description"}]},Asset:{doctype:"Asset",title:"Create New Asset",titleField:"asset_name",fields:[{fieldname:"asset_name",label:"Asset Name",fieldtype:"Data",required:!0,placeholder:"Enter asset name"},{fieldname:"item_code",label:"Item Code",fieldtype:"Link",linkDoctype:"Item",required:!0,linkFilters:{is_fixed_asset:1},placeholder:"Select item"},{fieldname:"company",label:"Company",fieldtype:"Link",linkDoctype:"Company",required:!0,placeholder:"Select company"},{fieldname:"location",label:"Location",fieldtype:"Link",linkDoctype:"Location",placeholder:"Select location"},{fieldname:"custodian",label:"Custodian",fieldtype:"Link",linkDoctype:"Employee",placeholder:"Select custodian"}]},"Technical Department":{doctype:"Technical Department",title:"Create New Technical Department",titleField:"name",fields:[{fieldname:"department",label:"Department Name",fieldtype:"Data",required:!0,placeholder:"Enter technical department name"}]}},$ae=e=>iL[e]||null,Uae=e=>e in iL,Xg=new Map,Bae=e=>J(null,null,function*(){var r;try{return((r=(yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({roles:e.join(",")})})).json()).message)==null?void 0:r.has_role)===!0}catch(a){return console.error("[PermissionService] Error checking roles:",a),!1}}),Wae=e=>J(null,null,function*(){var a,s,n,i;const r=`create_${e}`;if(Xg.has(r)){const o=Xg.get(r);return console.log(`[PermissionService] ${e} (cached): ${o}`),o}console.log(`[PermissionService] Checking create permission for: ${e}`);try{const l=yield(yield fetch("/api/method/asset_lite.api.user_roles.has_create_permission",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({doctype:e})})).json();console.log(`[PermissionService] has_create_permission response for ${e}:`,l);const c=((a=l.message)==null?void 0:a.has_permission)===!0;return console.log(c?`[PermissionService] ${e}: Permission GRANTED via ${(s=l.message)==null?void 0:s.reason} (role: ${(n=l.message)==null?void 0:n.role})`:`[PermissionService] ${e}: Permission DENIED - ${(i=l.message)==null?void 0:i.reason}`),Xg.set(r,c),c}catch(o){console.error(`[PermissionService] Error checking permission for ${e}:`,o);try{if(yield Bae(["System Manager","Administrator"]))return console.log("[PermissionService] Fallback: User is admin, granting permission"),Xg.set(r,!0),!0}catch(l){console.error("[PermissionService] Fallback check failed:",l)}return Xg.set(r,!1),!1}});function oL(e){var r,a,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var n=e.length;for(r=0;r<n;r++)e[r]&&(a=oL(e[r]))&&(s&&(s+=" "),s+=a)}else for(a in e)e[a]&&(s&&(s+=" "),s+=a);return s}function va(){for(var e,r,a=0,s="",n=arguments.length;a<n;a++)(e=arguments[a])&&(r=oL(e))&&(s&&(s+=" "),s+=r);return s}function Hae(e){if(typeof document=="undefined")return;let r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}Hae(`:root{--toastify-color-light: #fff;--toastify-color-dark: #121212;--toastify-color-info: #3498db;--toastify-color-success: #07bc0c;--toastify-color-warning: #f1c40f;--toastify-color-error: hsl(6, 78%, 57%);--toastify-color-transparent: rgba(255, 255, 255, .7);--toastify-icon-color-info: var(--toastify-color-info);--toastify-icon-color-success: var(--toastify-color-success);--toastify-icon-color-warning: var(--toastify-color-warning);--toastify-icon-color-error: var(--toastify-color-error);--toastify-container-width: fit-content;--toastify-toast-width: 320px;--toastify-toast-offset: 16px;--toastify-toast-top: max(var(--toastify-toast-offset), env(safe-area-inset-top));--toastify-toast-right: max(var(--toastify-toast-offset), env(safe-area-inset-right));--toastify-toast-left: max(var(--toastify-toast-offset), env(safe-area-inset-left));--toastify-toast-bottom: max(var(--toastify-toast-offset), env(safe-area-inset-bottom));--toastify-toast-background: #fff;--toastify-toast-padding: 14px;--toastify-toast-min-height: 64px;--toastify-toast-max-height: 800px;--toastify-toast-bd-radius: 6px;--toastify-toast-shadow: 0px 4px 12px rgba(0, 0, 0, .1);--toastify-font-family: sans-serif;--toastify-z-index: 9999;--toastify-text-color-light: #757575;--toastify-text-color-dark: #fff;--toastify-text-color-info: #fff;--toastify-text-color-success: #fff;--toastify-text-color-warning: #fff;--toastify-text-color-error: #fff;--toastify-spinner-color: #616161;--toastify-spinner-color-empty-area: #e0e0e0;--toastify-color-progress-light: linear-gradient(to right, #4cd964, #5ac8fa, #007aff, #34aadc, #5856d6, #ff2d55);--toastify-color-progress-dark: #bb86fc;--toastify-color-progress-info: var(--toastify-color-info);--toastify-color-progress-success: var(--toastify-color-success);--toastify-color-progress-warning: var(--toastify-color-warning);--toastify-color-progress-error: var(--toastify-color-error);--toastify-color-progress-bgo: .2}.Toastify__toast-container{z-index:var(--toastify-z-index);-webkit-transform:translate3d(0,0,var(--toastify-z-index));position:fixed;width:var(--toastify-container-width);box-sizing:border-box;color:#fff;display:flex;flex-direction:column}.Toastify__toast-container--top-left{top:var(--toastify-toast-top);left:var(--toastify-toast-left)}.Toastify__toast-container--top-center{top:var(--toastify-toast-top);left:50%;transform:translate(-50%);align-items:center}.Toastify__toast-container--top-right{top:var(--toastify-toast-top);right:var(--toastify-toast-right);align-items:end}.Toastify__toast-container--bottom-left{bottom:var(--toastify-toast-bottom);left:var(--toastify-toast-left)}.Toastify__toast-container--bottom-center{bottom:var(--toastify-toast-bottom);left:50%;transform:translate(-50%);align-items:center}.Toastify__toast-container--bottom-right{bottom:var(--toastify-toast-bottom);right:var(--toastify-toast-right);align-items:end}.Toastify__toast{--y: 0;position:relative;touch-action:none;width:var(--toastify-toast-width);min-height:var(--toastify-toast-min-height);box-sizing:border-box;margin-bottom:1rem;padding:var(--toastify-toast-padding);border-radius:var(--toastify-toast-bd-radius);box-shadow:var(--toastify-toast-shadow);max-height:var(--toastify-toast-max-height);font-family:var(--toastify-font-family);z-index:0;display:flex;flex:1 auto;align-items:center;word-break:break-word}@media only screen and (max-width: 480px){.Toastify__toast-container{width:100vw;left:env(safe-area-inset-left);margin:0}.Toastify__toast-container--top-left,.Toastify__toast-container--top-center,.Toastify__toast-container--top-right{top:env(safe-area-inset-top);transform:translate(0)}.Toastify__toast-container--bottom-left,.Toastify__toast-container--bottom-center,.Toastify__toast-container--bottom-right{bottom:env(safe-area-inset-bottom);transform:translate(0)}.Toastify__toast-container--rtl{right:env(safe-area-inset-right);left:initial}.Toastify__toast{--toastify-toast-width: 100%;margin-bottom:0;border-radius:0}}.Toastify__toast-container[data-stacked=true]{width:var(--toastify-toast-width)}.Toastify__toast--stacked{position:absolute;width:100%;transform:translate3d(0,var(--y),0) scale(var(--s));transition:transform .3s}.Toastify__toast--stacked[data-collapsed] .Toastify__toast-body,.Toastify__toast--stacked[data-collapsed] .Toastify__close-button{transition:opacity .1s}.Toastify__toast--stacked[data-collapsed=false]{overflow:visible}.Toastify__toast--stacked[data-collapsed=true]:not(:last-child)>*{opacity:0}.Toastify__toast--stacked:after{content:"";position:absolute;left:0;right:0;height:calc(var(--g) * 1px);bottom:100%}.Toastify__toast--stacked[data-pos=top]{top:0}.Toastify__toast--stacked[data-pos=bot]{bottom:0}.Toastify__toast--stacked[data-pos=bot].Toastify__toast--stacked:before{transform-origin:top}.Toastify__toast--stacked[data-pos=top].Toastify__toast--stacked:before{transform-origin:bottom}.Toastify__toast--stacked:before{content:"";position:absolute;left:0;right:0;bottom:0;height:100%;transform:scaleY(3);z-index:-1}.Toastify__toast--rtl{direction:rtl}.Toastify__toast--close-on-click{cursor:pointer}.Toastify__toast-icon{margin-inline-end:10px;width:22px;flex-shrink:0;display:flex}.Toastify--animate{animation-fill-mode:both;animation-duration:.5s}.Toastify--animate-icon{animation-fill-mode:both;animation-duration:.3s}.Toastify__toast-theme--dark{background:var(--toastify-color-dark);color:var(--toastify-text-color-dark)}.Toastify__toast-theme--light,.Toastify__toast-theme--colored.Toastify__toast--default{background:var(--toastify-color-light);color:var(--toastify-text-color-light)}.Toastify__toast-theme--colored.Toastify__toast--info{color:var(--toastify-text-color-info);background:var(--toastify-color-info)}.Toastify__toast-theme--colored.Toastify__toast--success{color:var(--toastify-text-color-success);background:var(--toastify-color-success)}.Toastify__toast-theme--colored.Toastify__toast--warning{color:var(--toastify-text-color-warning);background:var(--toastify-color-warning)}.Toastify__toast-theme--colored.Toastify__toast--error{color:var(--toastify-text-color-error);background:var(--toastify-color-error)}.Toastify__progress-bar-theme--light{background:var(--toastify-color-progress-light)}.Toastify__progress-bar-theme--dark{background:var(--toastify-color-progress-dark)}.Toastify__progress-bar--info{background:var(--toastify-color-progress-info)}.Toastify__progress-bar--success{background:var(--toastify-color-progress-success)}.Toastify__progress-bar--warning{background:var(--toastify-color-progress-warning)}.Toastify__progress-bar--error{background:var(--toastify-color-progress-error)}.Toastify__progress-bar-theme--colored.Toastify__progress-bar--info,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--success,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--warning,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--error{background:var(--toastify-color-transparent)}.Toastify__close-button{color:#fff;position:absolute;top:6px;right:6px;background:transparent;outline:none;border:none;padding:0;cursor:pointer;opacity:.7;transition:.3s ease;z-index:1}.Toastify__toast--rtl .Toastify__close-button{left:6px;right:unset}.Toastify__close-button--light{color:#000;opacity:.3}.Toastify__close-button>svg{fill:currentColor;height:16px;width:14px}.Toastify__close-button:hover,.Toastify__close-button:focus{opacity:1}@keyframes Toastify__trackProgress{0%{transform:scaleX(1)}to{transform:scaleX(0)}}.Toastify__progress-bar{position:absolute;bottom:0;left:0;width:100%;height:100%;z-index:1;opacity:.7;transform-origin:left}.Toastify__progress-bar--animated{animation:Toastify__trackProgress linear 1 forwards}.Toastify__progress-bar--controlled{transition:transform .2s}.Toastify__progress-bar--rtl{right:0;left:initial;transform-origin:right;border-bottom-left-radius:initial}.Toastify__progress-bar--wrp{position:absolute;overflow:hidden;bottom:0;left:0;width:100%;height:5px;border-bottom-left-radius:var(--toastify-toast-bd-radius);border-bottom-right-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp[data-hidden=true]{opacity:0}.Toastify__progress-bar--bg{opacity:var(--toastify-color-progress-bgo);width:100%;height:100%}.Toastify__spinner{width:20px;height:20px;box-sizing:border-box;border:2px solid;border-radius:100%;border-color:var(--toastify-spinner-color-empty-area);border-right-color:var(--toastify-spinner-color);animation:Toastify__spin .65s linear infinite}@keyframes Toastify__bounceInRight{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(3000px,0,0)}60%{opacity:1;transform:translate3d(-25px,0,0)}75%{transform:translate3d(10px,0,0)}90%{transform:translate3d(-5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutRight{20%{opacity:1;transform:translate3d(-20px,var(--y),0)}to{opacity:0;transform:translate3d(2000px,var(--y),0)}}@keyframes Toastify__bounceInLeft{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(-3000px,0,0)}60%{opacity:1;transform:translate3d(25px,0,0)}75%{transform:translate3d(-10px,0,0)}90%{transform:translate3d(5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutLeft{20%{opacity:1;transform:translate3d(20px,var(--y),0)}to{opacity:0;transform:translate3d(-2000px,var(--y),0)}}@keyframes Toastify__bounceInUp{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,3000px,0)}60%{opacity:1;transform:translate3d(0,-20px,0)}75%{transform:translate3d(0,10px,0)}90%{transform:translate3d(0,-5px,0)}to{transform:translateZ(0)}}@keyframes Toastify__bounceOutUp{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,-2000px,0)}}@keyframes Toastify__bounceInDown{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,-3000px,0)}60%{opacity:1;transform:translate3d(0,25px,0)}75%{transform:translate3d(0,-10px,0)}90%{transform:translate3d(0,5px,0)}to{transform:none}}@keyframes Toastify__bounceOutDown{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,2000px,0)}}.Toastify__bounce-enter--top-left,.Toastify__bounce-enter--bottom-left{animation-name:Toastify__bounceInLeft}.Toastify__bounce-enter--top-right,.Toastify__bounce-enter--bottom-right{animation-name:Toastify__bounceInRight}.Toastify__bounce-enter--top-center{animation-name:Toastify__bounceInDown}.Toastify__bounce-enter--bottom-center{animation-name:Toastify__bounceInUp}.Toastify__bounce-exit--top-left,.Toastify__bounce-exit--bottom-left{animation-name:Toastify__bounceOutLeft}.Toastify__bounce-exit--top-right,.Toastify__bounce-exit--bottom-right{animation-name:Toastify__bounceOutRight}.Toastify__bounce-exit--top-center{animation-name:Toastify__bounceOutUp}.Toastify__bounce-exit--bottom-center{animation-name:Toastify__bounceOutDown}@keyframes Toastify__zoomIn{0%{opacity:0;transform:scale3d(.3,.3,.3)}50%{opacity:1}}@keyframes Toastify__zoomOut{0%{opacity:1}50%{opacity:0;transform:translate3d(0,var(--y),0) scale3d(.3,.3,.3)}to{opacity:0}}.Toastify__zoom-enter{animation-name:Toastify__zoomIn}.Toastify__zoom-exit{animation-name:Toastify__zoomOut}@keyframes Toastify__flipIn{0%{transform:perspective(400px) rotateX(90deg);animation-timing-function:ease-in;opacity:0}40%{transform:perspective(400px) rotateX(-20deg);animation-timing-function:ease-in}60%{transform:perspective(400px) rotateX(10deg);opacity:1}80%{transform:perspective(400px) rotateX(-5deg)}to{transform:perspective(400px)}}@keyframes Toastify__flipOut{0%{transform:translate3d(0,var(--y),0) perspective(400px)}30%{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(-20deg);opacity:1}to{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(90deg);opacity:0}}.Toastify__flip-enter{animation-name:Toastify__flipIn}.Toastify__flip-exit{animation-name:Toastify__flipOut}@keyframes Toastify__slideInRight{0%{transform:translate3d(110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInLeft{0%{transform:translate3d(-110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInUp{0%{transform:translate3d(0,110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInDown{0%{transform:translate3d(0,-110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideOutRight{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(110%,var(--y),0)}}@keyframes Toastify__slideOutLeft{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(-110%,var(--y),0)}}@keyframes Toastify__slideOutDown{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,500px,0)}}@keyframes Toastify__slideOutUp{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,-500px,0)}}.Toastify__slide-enter--top-left,.Toastify__slide-enter--bottom-left{animation-name:Toastify__slideInLeft}.Toastify__slide-enter--top-right,.Toastify__slide-enter--bottom-right{animation-name:Toastify__slideInRight}.Toastify__slide-enter--top-center{animation-name:Toastify__slideInDown}.Toastify__slide-enter--bottom-center{animation-name:Toastify__slideInUp}.Toastify__slide-exit--top-left,.Toastify__slide-exit--bottom-left{animation-name:Toastify__slideOutLeft;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--top-right,.Toastify__slide-exit--bottom-right{animation-name:Toastify__slideOutRight;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--top-center{animation-name:Toastify__slideOutUp;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-center{animation-name:Toastify__slideOutDown;animation-timing-function:ease-in;animation-duration:.3s}@keyframes Toastify__spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}
|
||
`);var Rx=e=>typeof e=="number"&&!isNaN(e),Nm=e=>typeof e=="string",Jd=e=>typeof e=="function",qae=e=>Nm(e)||Rx(e),ON=e=>Nm(e)||Jd(e)?e:null,Vae=(e,r)=>e===!1||Rx(e)&&e>0?e:r,PN=e=>p.isValidElement(e)||Nm(e)||Jd(e)||Rx(e);function Gae(e,r,a=300){let{scrollHeight:s,style:n}=e;requestAnimationFrame(()=>{n.minHeight="initial",n.height=s+"px",n.transition=`all ${a}ms`,requestAnimationFrame(()=>{n.height="0",n.padding="0",n.margin="0",setTimeout(r,a)})})}function Kae({enter:e,exit:r,appendPosition:a=!1,collapse:s=!0,collapseDuration:n=300}){return function({children:i,position:o,preventExitTransition:l,done:c,nodeRef:u,isIn:h,playToast:f}){let y=a?`${e}--${o}`:e,b=a?`${r}--${o}`:r,w=p.useRef(0);return p.useLayoutEffect(()=>{let v=u.current,k=y.split(" "),S=N=>{N.target===u.current&&(f(),v.removeEventListener("animationend",S),v.removeEventListener("animationcancel",S),w.current===0&&N.type!=="animationcancel"&&v.classList.remove(...k))};v.classList.add(...k),v.addEventListener("animationend",S),v.addEventListener("animationcancel",S)},[]),p.useEffect(()=>{let v=u.current,k=()=>{v.removeEventListener("animationend",k),s?Gae(v,c,n):c()};h||(l?k():(w.current=1,v.className+=` ${b}`,v.addEventListener("animationend",k)))},[h]),gr.createElement(gr.Fragment,null,i)}}function j7(e,r){return{content:lL(e.content,e.props),containerId:e.props.containerId,id:e.props.toastId,theme:e.props.theme,type:e.props.type,data:e.props.data||{},isLoading:e.props.isLoading,icon:e.props.icon,reason:e.removalReason,status:r}}function lL(e,r,a=!1){return p.isValidElement(e)&&!Nm(e.type)?p.cloneElement(e,{closeToast:r.closeToast,toastProps:r,data:r.data,isPaused:a}):Jd(e)?e({closeToast:r.closeToast,toastProps:r,data:r.data,isPaused:a}):e}function Yae({closeToast:e,theme:r,ariaLabel:a="close"}){return gr.createElement("button",{className:`Toastify__close-button Toastify__close-button--${r}`,type:"button",onClick:s=>{s.stopPropagation(),e(!0)},"aria-label":a},gr.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},gr.createElement("path",{fillRule:"evenodd",d:"M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"})))}function Jae({delay:e,isRunning:r,closeToast:a,type:s="default",hide:n,className:i,controlledProgress:o,progress:l,rtl:c,isIn:u,theme:h}){let f=n||o&&l===0,y={animationDuration:`${e}ms`,animationPlayState:r?"running":"paused"};o&&(y.transform=`scaleX(${l})`);let b=va("Toastify__progress-bar",o?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated",`Toastify__progress-bar-theme--${h}`,`Toastify__progress-bar--${s}`,{"Toastify__progress-bar--rtl":c}),w=Jd(i)?i({rtl:c,type:s,defaultClassName:b}):va(b,i),v={[o&&l>=1?"onTransitionEnd":"onAnimationEnd"]:o&&l<1?null:()=>{u&&a()}};return gr.createElement("div",{className:"Toastify__progress-bar--wrp","data-hidden":f},gr.createElement("div",{className:`Toastify__progress-bar--bg Toastify__progress-bar-theme--${h} Toastify__progress-bar--${s}`}),gr.createElement("div",se({role:"progressbar","aria-hidden":f?"true":"false","aria-label":"notification timer",className:w,style:y},v)))}var Zae=1,cL=()=>`${Zae++}`;function Xae(e,r,a){let s=1,n=0,i=[],o=[],l=r,c=new Map,u=new Set,h=N=>(u.add(N),()=>u.delete(N)),f=()=>{o=Array.from(c.values()),u.forEach(N=>N())},y=({containerId:N,toastId:C,updateId:O})=>{let T=N?N!==e:e!==1,P=c.has(C)&&O==null;return T||P},b=(N,C)=>{c.forEach(O=>{var T;(C==null||C===O.props.toastId)&&((T=O.toggle)==null||T.call(O,N))})},w=N=>{var C,O;(O=(C=N.props)==null?void 0:C.onClose)==null||O.call(C,N.removalReason),N.isActive=!1},v=N=>{if(N==null)c.forEach(w);else{let C=c.get(N);C&&w(C)}f()},k=()=>{n-=i.length,i=[]},S=N=>{var C,O;let{toastId:T,updateId:P}=N.props,E=P==null;N.staleId&&c.delete(N.staleId),N.isActive=!0,c.set(T,N),f(),a(j7(N,E?"added":"updated")),E&&((O=(C=N.props).onOpen)==null||O.call(C))};return{id:e,props:l,observe:h,toggle:b,removeToast:v,toasts:c,clearQueue:k,buildToast:(N,C)=>{if(y(C))return;let{toastId:O,updateId:T,data:P,staleId:E,delay:R}=C,z=T==null;z&&n++;let G=je(se(je(se({},l),{style:l.toastStyle,key:s++}),Object.fromEntries(Object.entries(C).filter(([ee,ne])=>ne!=null))),{toastId:O,updateId:T,data:P,isIn:!1,className:ON(C.className||l.toastClassName),progressClassName:ON(C.progressClassName||l.progressClassName),autoClose:C.isLoading?!1:Vae(C.autoClose,l.autoClose),closeToast(ee){c.get(O).removalReason=ee,v(O)},deleteToast(){let ee=c.get(O);if(ee!=null){if(a(j7(ee,"removed")),c.delete(O),n--,n<0&&(n=0),i.length>0){S(i.shift());return}f()}}});G.closeButton=l.closeButton,C.closeButton===!1||PN(C.closeButton)?G.closeButton=C.closeButton:C.closeButton===!0&&(G.closeButton=PN(l.closeButton)?l.closeButton:!0);let ae={content:N,props:G,staleId:E};l.limit&&l.limit>0&&n>l.limit&&z?i.push(ae):Rx(R)?setTimeout(()=>{S(ae)},R):S(ae)},setProps(N){l=N},setToggle:(N,C)=>{let O=c.get(N);O&&(O.toggle=C)},isToastActive:N=>{var C;return(C=c.get(N))==null?void 0:C.isActive},getSnapshot:()=>o}}var Di=new Map,tx=[],DN=new Set,Qae=e=>DN.forEach(r=>r(e)),dL=()=>Di.size>0;function ese(){tx.forEach(e=>mL(e.content,e.options)),tx=[]}var tse=(e,{containerId:r})=>{var a;return(a=Di.get(r||1))==null?void 0:a.toasts.get(e)};function uL(e,r){var a;if(r)return!!((a=Di.get(r))!=null&&a.isToastActive(e));let s=!1;return Di.forEach(n=>{n.isToastActive(e)&&(s=!0)}),s}function rse(e){if(!dL()){tx=tx.filter(r=>e!=null&&r.options.toastId!==e);return}if(e==null||qae(e))Di.forEach(r=>{r.removeToast(e)});else if(e&&("containerId"in e||"id"in e)){let r=Di.get(e.containerId);r?r.removeToast(e.id):Di.forEach(a=>{a.removeToast(e.id)})}}var ase=(e={})=>{Di.forEach(r=>{r.props.limit&&(!e.containerId||r.id===e.containerId)&&r.clearQueue()})};function mL(e,r){PN(e)&&(dL()||tx.push({content:e,options:r}),Di.forEach(a=>{a.buildToast(e,r)}))}function sse(e){var r;(r=Di.get(e.containerId||1))==null||r.setToggle(e.id,e.fn)}function hL(e,r){Di.forEach(a=>{(r==null||!(r!=null&&r.containerId)||(r==null?void 0:r.containerId)===a.id)&&a.toggle(e,r==null?void 0:r.id)})}function nse(e){let r=e.containerId||1;return{subscribe(a){let s=Xae(r,e,Qae);Di.set(r,s);let n=s.observe(a);return ese(),()=>{n(),Di.delete(r)}},setProps(a){var s;(s=Di.get(r))==null||s.setProps(a)},getSnapshot(){var a;return(a=Di.get(r))==null?void 0:a.getSnapshot()}}}function ise(e){return DN.add(e),()=>{DN.delete(e)}}function ose(e){return e&&(Nm(e.toastId)||Rx(e.toastId))?e.toastId:cL()}function Mx(e,r){return mL(e,r),r.toastId}function ow(e,r){return je(se({},r),{type:r&&r.type||e,toastId:ose(r)})}function lw(e){return(r,a)=>Mx(r,ow(e,a))}function We(e,r){return Mx(e,ow("default",r))}We.loading=(e,r)=>Mx(e,ow("default",se({isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1},r)));function lse(e,{pending:r,error:a,success:s},n){let i;r&&(i=Nm(r)?We.loading(r,n):We.loading(r.render,se(se({},n),r)));let o={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},l=(u,h,f)=>{if(h==null){We.dismiss(i);return}let y=je(se(se({type:u},o),n),{data:f}),b=Nm(h)?{render:h}:h;return i?We.update(i,se(se({},y),b)):We(b.render,se(se({},y),b)),f},c=Jd(e)?e():e;return c.then(u=>l("success",s,u)).catch(u=>l("error",a,u)),c}We.promise=lse;We.success=lw("success");We.info=lw("info");We.error=lw("error");We.warning=lw("warning");We.warn=We.warning;We.dark=(e,r)=>Mx(e,ow("default",se({theme:"dark"},r)));function cse(e){rse(e)}We.dismiss=cse;We.clearWaitingQueue=ase;We.isActive=uL;We.update=(e,r={})=>{let a=tse(e,r);if(a){let{props:s,content:n}=a,i=je(se(se({delay:100},s),r),{toastId:r.toastId||e,updateId:cL()});i.toastId!==e&&(i.staleId=e);let o=i.render||n;delete i.render,Mx(o,i)}};We.done=e=>{We.update(e,{progress:1})};We.onChange=ise;We.play=e=>hL(!0,e);We.pause=e=>hL(!1,e);function dse(e){var r;let{subscribe:a,getSnapshot:s,setProps:n}=p.useRef(nse(e)).current;n(e);let i=(r=p.useSyncExternalStore(a,s,s))==null?void 0:r.slice();function o(l){if(!i)return[];let c=new Map;return e.newestOnTop&&i.reverse(),i.forEach(u=>{let{position:h}=u.props;c.has(h)||c.set(h,[]),c.get(h).push(u)}),Array.from(c,u=>l(u[0],u[1]))}return{getToastToRender:o,isToastActive:uL,count:i==null?void 0:i.length}}function use(e){let[r,a]=p.useState(!1),[s,n]=p.useState(!1),i=p.useRef(null),o=p.useRef({start:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,didMove:!1}).current,{autoClose:l,pauseOnHover:c,closeToast:u,onClick:h,closeOnClick:f}=e;sse({id:e.toastId,containerId:e.containerId,fn:a}),p.useEffect(()=>{if(e.pauseOnFocusLoss)return y(),()=>{b()}},[e.pauseOnFocusLoss]);function y(){document.hasFocus()||S(),window.addEventListener("focus",k),window.addEventListener("blur",S)}function b(){window.removeEventListener("focus",k),window.removeEventListener("blur",S)}function w(E){if(e.draggable===!0||e.draggable===E.pointerType){N();let R=i.current;o.canCloseOnClick=!0,o.canDrag=!0,R.style.transition="none",e.draggableDirection==="x"?(o.start=E.clientX,o.removalDistance=R.offsetWidth*(e.draggablePercent/100)):(o.start=E.clientY,o.removalDistance=R.offsetHeight*(e.draggablePercent===80?e.draggablePercent*1.5:e.draggablePercent)/100)}}function v(E){let{top:R,bottom:z,left:G,right:ae}=i.current.getBoundingClientRect();E.nativeEvent.type!=="touchend"&&e.pauseOnHover&&E.clientX>=G&&E.clientX<=ae&&E.clientY>=R&&E.clientY<=z?S():k()}function k(){a(!0)}function S(){a(!1)}function N(){o.didMove=!1,document.addEventListener("pointermove",O),document.addEventListener("pointerup",T)}function C(){document.removeEventListener("pointermove",O),document.removeEventListener("pointerup",T)}function O(E){let R=i.current;if(o.canDrag&&R){o.didMove=!0,r&&S(),e.draggableDirection==="x"?o.delta=E.clientX-o.start:o.delta=E.clientY-o.start,o.start!==E.clientX&&(o.canCloseOnClick=!1);let z=e.draggableDirection==="x"?`${o.delta}px, var(--y)`:`0, calc(${o.delta}px + var(--y))`;R.style.transform=`translate3d(${z},0)`,R.style.opacity=`${1-Math.abs(o.delta/o.removalDistance)}`}}function T(){C();let E=i.current;if(o.canDrag&&o.didMove&&E){if(o.canDrag=!1,Math.abs(o.delta)>o.removalDistance){n(!0),e.closeToast(!0),e.collapseAll();return}E.style.transition="transform 0.2s, opacity 0.2s",E.style.removeProperty("transform"),E.style.removeProperty("opacity")}}let P={onPointerDown:w,onPointerUp:v};return l&&c&&(P.onMouseEnter=S,e.stacked||(P.onMouseLeave=k)),f&&(P.onClick=E=>{h&&h(E),o.canCloseOnClick&&u(!0)}),{playToast:k,pauseToast:S,isRunning:r,preventExitTransition:s,toastRef:i,eventHandlers:P}}var mse=typeof window!="undefined"?p.useLayoutEffect:p.useEffect,cw=n=>{var i=n,{theme:e,type:r,isLoading:a}=i,s=li(i,["theme","type","isLoading"]);return gr.createElement("svg",se({viewBox:"0 0 24 24",width:"100%",height:"100%",fill:e==="colored"?"currentColor":`var(--toastify-icon-color-${r})`},s))};function hse(e){return gr.createElement(cw,se({},e),gr.createElement("path",{d:"M23.32 17.191L15.438 2.184C14.728.833 13.416 0 11.996 0c-1.42 0-2.733.833-3.443 2.184L.533 17.448a4.744 4.744 0 000 4.368C1.243 23.167 2.555 24 3.975 24h16.05C22.22 24 24 22.044 24 19.632c0-.904-.251-1.746-.68-2.44zm-9.622 1.46c0 1.033-.724 1.823-1.698 1.823s-1.698-.79-1.698-1.822v-.043c0-1.028.724-1.822 1.698-1.822s1.698.79 1.698 1.822v.043zm.039-12.285l-.84 8.06c-.057.581-.408.943-.897.943-.49 0-.84-.367-.896-.942l-.84-8.065c-.057-.624.25-1.095.779-1.095h1.91c.528.005.84.476.784 1.1z"}))}function pse(e){return gr.createElement(cw,se({},e),gr.createElement("path",{d:"M12 0a12 12 0 1012 12A12.013 12.013 0 0012 0zm.25 5a1.5 1.5 0 11-1.5 1.5 1.5 1.5 0 011.5-1.5zm2.25 13.5h-4a1 1 0 010-2h.75a.25.25 0 00.25-.25v-4.5a.25.25 0 00-.25-.25h-.75a1 1 0 010-2h1a2 2 0 012 2v4.75a.25.25 0 00.25.25h.75a1 1 0 110 2z"}))}function gse(e){return gr.createElement(cw,se({},e),gr.createElement("path",{d:"M12 0a12 12 0 1012 12A12.014 12.014 0 0012 0zm6.927 8.2l-6.845 9.289a1.011 1.011 0 01-1.43.188l-4.888-3.908a1 1 0 111.25-1.562l4.076 3.261 6.227-8.451a1 1 0 111.61 1.183z"}))}function fse(e){return gr.createElement(cw,se({},e),gr.createElement("path",{d:"M11.983 0a12.206 12.206 0 00-8.51 3.653A11.8 11.8 0 000 12.207 11.779 11.779 0 0011.8 24h.214A12.111 12.111 0 0024 11.791 11.766 11.766 0 0011.983 0zM10.5 16.542a1.476 1.476 0 011.449-1.53h.027a1.527 1.527 0 011.523 1.47 1.475 1.475 0 01-1.449 1.53h-.027a1.529 1.529 0 01-1.523-1.47zM11 12.5v-6a1 1 0 012 0v6a1 1 0 11-2 0z"}))}function xse(){return gr.createElement("div",{className:"Toastify__spinner"})}var RN={info:pse,warning:hse,success:gse,error:fse,spinner:xse},yse=e=>e in RN;function bse({theme:e,type:r,isLoading:a,icon:s}){let n=null,i={theme:e,type:r};return s===!1||(Jd(s)?n=s(je(se({},i),{isLoading:a})):p.isValidElement(s)?n=p.cloneElement(s,i):a?n=RN.spinner():yse(r)&&(n=RN[r](i))),n}var vse=e=>{let{isRunning:r,preventExitTransition:a,toastRef:s,eventHandlers:n,playToast:i}=use(e),{closeButton:o,children:l,autoClose:c,onClick:u,type:h,hideProgressBar:f,closeToast:y,transition:b,position:w,className:v,style:k,progressClassName:S,updateId:N,role:C,progress:O,rtl:T,toastId:P,deleteToast:E,isIn:R,isLoading:z,closeOnClick:G,theme:ae,ariaLabel:ee}=e,ne=va("Toastify__toast",`Toastify__toast-theme--${ae}`,`Toastify__toast--${h}`,{"Toastify__toast--rtl":T},{"Toastify__toast--close-on-click":G}),te=Jd(v)?v({rtl:T,position:w,type:h,defaultClassName:ne}):va(ne,v),Y=bse(e),q=!!O||!c,H={closeToast:y,type:h,theme:ae},U=null;return o===!1||(Jd(o)?U=o(H):p.isValidElement(o)?U=p.cloneElement(o,H):U=Yae(H)),gr.createElement(b,{isIn:R,done:E,position:w,preventExitTransition:a,nodeRef:s,playToast:i},gr.createElement("div",se(je(se({id:P,tabIndex:0,onClick:u,"data-in":R,className:te},n),{style:k,ref:s}),R&&{role:C,"aria-label":ee}),Y!=null&&gr.createElement("div",{className:va("Toastify__toast-icon",{"Toastify--animate-icon Toastify__zoom-enter":!z})},Y),lL(l,e,!r),U,!e.customProgressBar&&gr.createElement(Jae,je(se({},N&&!q?{key:`p-${N}`}:{}),{rtl:T,theme:ae,delay:c,isRunning:r,isIn:R,closeToast:y,hide:f,type:h,className:S,controlledProgress:q,progress:O||0}))))},wse=(e,r=!1)=>({enter:`Toastify--animate Toastify__${e}-enter`,exit:`Toastify--animate Toastify__${e}-exit`,appendPosition:r}),au=Kae(wse("bounce",!0)),jse={position:"top-right",transition:au,autoClose:5e3,closeButton:!0,pauseOnHover:!0,pauseOnFocusLoss:!0,draggable:"touch",draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light","aria-label":"Notifications Alt+T",hotKeys:e=>e.altKey&&e.code==="KeyT"};function $a(e){let r=se(se({},jse),e),a=e.stacked,[s,n]=p.useState(!0),i=p.useRef(null),{getToastToRender:o,isToastActive:l,count:c}=dse(r),{className:u,style:h,rtl:f,containerId:y,hotKeys:b}=r;function w(k){let S=va("Toastify__toast-container",`Toastify__toast-container--${k}`,{"Toastify__toast-container--rtl":f});return Jd(u)?u({position:k,rtl:f,defaultClassName:S}):va(S,ON(u))}function v(){a&&(n(!0),We.play())}return mse(()=>{var k;if(a){let S=i.current.querySelectorAll('[data-in="true"]'),N=12,C=(k=r.position)==null?void 0:k.includes("top"),O=0,T=0;Array.from(S).reverse().forEach((P,E)=>{let R=P;R.classList.add("Toastify__toast--stacked"),E>0&&(R.dataset.collapsed=`${s}`),R.dataset.pos||(R.dataset.pos=C?"top":"bot");let z=O*(s?.2:1)+(s?0:N*E);R.style.setProperty("--y",`${C?z:z*-1}px`),R.style.setProperty("--g",`${N}`),R.style.setProperty("--s",`${1-(s?T:0)}`),O+=R.offsetHeight,T+=.025})}},[s,c,a]),p.useEffect(()=>{function k(S){var N;let C=i.current;b(S)&&((N=C.querySelector('[tabIndex="0"]'))==null||N.focus(),n(!1),We.pause()),S.key==="Escape"&&(document.activeElement===C||C!=null&&C.contains(document.activeElement))&&(n(!0),We.play())}return document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k)}},[b]),gr.createElement("section",{ref:i,className:"Toastify",id:y,onMouseEnter:()=>{a&&(n(!1),We.pause())},onMouseLeave:v,"aria-live":"polite","aria-atomic":"false","aria-relevant":"additions text","aria-label":r["aria-label"]},o((k,S)=>{let N=S.length?se({},h):je(se({},h),{pointerEvents:"none"});return gr.createElement("div",{tabIndex:-1,className:w(k),"data-stacked":a,style:N,key:`c-${k}`},S.map(({content:C,props:O})=>gr.createElement(vse,je(se({},O),{stacked:a,collapseAll:v,isIn:l(O.toastId,O.containerId),key:`t-${O.key}`}),C)))}))}const _se=({doctype:e,value:r,onChange:a,disabled:s=!1,placeholder:n="Search...",filters:i={}})=>{const[o,l]=p.useState(""),[c,u]=p.useState([]),[h,f]=p.useState(!1),[y,b]=p.useState(!1),w=p.useRef(null),v=p.useRef(null),k=p.useCallback((C="")=>J(null,null,function*(){if(e){b(!0);try{const O=new URLSearchParams({doctype:e,txt:C,page_length:"20"});i&&Object.keys(i).length>0&&O.append("filters",JSON.stringify(i));const T=yield At.apiCall(`/api/method/frappe.desk.search.search_link?${O.toString()}`);u(T||[])}catch(O){console.error(`Error fetching ${e} links:`,O),u([])}finally{b(!1)}}}),[e,i]);p.useEffect(()=>{if(h)return v.current&&clearTimeout(v.current),v.current=setTimeout(()=>k(o),300),()=>{v.current&&clearTimeout(v.current)}},[o,h,k]),p.useEffect(()=>{h&&k(o)},[h]),p.useEffect(()=>{const C=O=>{w.current&&!w.current.contains(O.target)&&(f(!1),l(""))};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[]);const S=C=>{a(C),l(""),f(!1)},N=()=>{a(""),l("")};return t.jsxs("div",{ref:w,className:"relative",children:[t.jsxs("div",{className:"relative",children:[t.jsx(za,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400",size:12}),t.jsx("input",{type:"text",value:h?o:r,placeholder:n,disabled:s,className:`w-full pl-9 pr-8 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md
|
||
focus:outline-none focus:ring-2 focus:ring-blue-500
|
||
disabled:bg-gray-100 dark:disabled:bg-gray-700
|
||
bg-white dark:bg-gray-700 text-gray-900 dark:text-white`,onFocus:()=>!s&&f(!0),onChange:C=>{l(C.target.value),f(!0)}}),r&&!s&&!h&&t.jsx("button",{type:"button",onClick:N,className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:t.jsx(ht,{size:12})})]}),h&&!s&&t.jsx("div",{className:"absolute z-50 w-full mt-1 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-md shadow-lg max-h-40 overflow-auto",children:y?t.jsxs("div",{className:"p-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:[t.jsx(tr,{className:"animate-spin inline mr-2",size:12}),"Loading..."]}):c.length>0?t.jsx("ul",{children:c.map((C,O)=>t.jsxs("li",{onClick:()=>S(C.value),className:`px-3 py-2 cursor-pointer text-sm hover:bg-blue-500 hover:text-white
|
||
${r===C.value?"bg-blue-50 dark:bg-blue-900/30":""}`,children:[C.value,C.description&&t.jsx("span",{className:"text-xs text-gray-500 ml-2",children:C.description})]},O))}):t.jsx("div",{className:"p-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:"No results found"})})]})},kse=({doctype:e,isOpen:r,onClose:a,onSuccess:s,initialValues:n={},parentFilters:i={},customConfig:o})=>{const[l,c]=p.useState({}),[u,h]=p.useState({}),[f,y]=p.useState(!1),[b,w]=p.useState(null);p.useEffect(()=>{const C=o||$ae(e);if(w(C),C){const O={};C.fields.forEach(T=>{T.defaultValue!==void 0?O[T.fieldname]=T.defaultValue:T.fieldtype==="Check"?O[T.fieldname]=0:O[T.fieldname]=""}),c(se(se({},O),n))}},[e,o,n]),p.useEffect(()=>{if(r&&b){const C={};b.fields.forEach(O=>{O.defaultValue!==void 0?C[O.fieldname]=O.defaultValue:O.fieldtype==="Check"?C[O.fieldname]=0:C[O.fieldname]=""}),c(se(se({},C),n)),h({})}},[r,b,n]);const v=p.useCallback((C,O)=>{c(T=>je(se({},T),{[C]:O})),h(T=>{const P=se({},T);return delete P[C],P})},[]),k=p.useCallback(()=>{if(!b)return!1;const C={};if(b.fields.forEach(O=>{if(O.required&&!O.hidden){const T=l[O.fieldname];(T==null||T==="")&&(C[O.fieldname]=`${O.label} is required`)}}),b.validateBeforeCreate){const O=b.validateBeforeCreate(l);if(O)return We.error(O,{position:"top-right",autoClose:4e3,icon:t.jsx(Or,{})}),!1}return h(C),Object.keys(C).length===0},[b,l]),S=C=>J(null,null,function*(){if(C.preventDefault(),!(!k()||!b)){y(!0);try{const O={};Object.entries(l).forEach(([P,E])=>{E!==""&&E!==null&&E!==void 0&&(O[P]=E)});const T=yield At.apiCall(`/api/resource/${b.doctype}`,{method:"POST",body:JSON.stringify(O)});if(T!=null&&T.data){const P=T.data;We.success(`${b.title.replace("Create New ","")} created successfully!`,{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),b.afterCreate&&b.afterCreate(P),s(P),a()}else throw new Error("Failed to create record")}catch(O){console.error("Error creating record:",O);const T=O instanceof Error?O.message:"Unknown error occurred";T.includes("Duplicate")||T.includes("already exists")?We.error("A record with this name already exists. Please use a different name.",{position:"top-right",autoClose:5e3,icon:t.jsx(pr,{})}):We.error(`Failed to create: ${T}`,{position:"top-right",autoClose:5e3,icon:t.jsx(pr,{})})}finally{y(!1)}}}),N=C=>{if(C.hidden)return null;const O=l[C.fieldname],T=u[C.fieldname],P=C.readOnly||f;if(C.dependsOn&&!l[C.dependsOn])return null;const E=`w-full px-3 py-2 text-sm border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500
|
||
${T?"border-red-500":"border-gray-300 dark:border-gray-600"}
|
||
${P?"bg-gray-100 dark:bg-gray-700 cursor-not-allowed":"bg-white dark:bg-gray-700"}
|
||
text-gray-900 dark:text-white`;switch(C.fieldtype){case"Data":return t.jsx("input",{type:"text",value:O||"",onChange:R=>v(C.fieldname,R.target.value),placeholder:C.placeholder,disabled:P,className:E});case"Text":return t.jsx("textarea",{value:O||"",onChange:R=>v(C.fieldname,R.target.value),placeholder:C.placeholder,disabled:P,rows:3,className:`${E} resize-none`});case"Select":return t.jsxs("select",{value:O||"",onChange:R=>v(C.fieldname,R.target.value),disabled:P,className:E,children:[t.jsxs("option",{value:"",children:["Select ",C.label]}),(C.options||[]).map(R=>{const z=typeof R=="string"?R:R.value,G=typeof R=="string"?R:R.label;return t.jsx("option",{value:z,children:G},z)})]});case"Link":return t.jsx(_se,{doctype:C.linkDoctype||"",value:O||"",onChange:R=>v(C.fieldname,R),disabled:P,placeholder:C.placeholder,filters:C.linkFilters||{}});case"Check":return t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:O===1||O===!0,onChange:R=>v(C.fieldname,R.target.checked?1:0),disabled:P,className:`w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500
|
||
dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2
|
||
dark:bg-gray-700 dark:border-gray-600`}),t.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:C.description||C.label})]});case"Int":return t.jsx("input",{type:"number",value:O||"",onChange:R=>v(C.fieldname,parseInt(R.target.value)||""),placeholder:C.placeholder,disabled:P,step:"1",className:E});case"Float":return t.jsx("input",{type:"number",value:O||"",onChange:R=>v(C.fieldname,parseFloat(R.target.value)||""),placeholder:C.placeholder,disabled:P,step:"0.01",className:E});case"Date":return t.jsx("input",{type:"date",value:O||"",onChange:R=>v(C.fieldname,R.target.value),disabled:P,className:E});case"Datetime":return t.jsx("input",{type:"datetime-local",value:O||"",onChange:R=>v(C.fieldname,R.target.value),disabled:P,className:E});default:return t.jsx("input",{type:"text",value:O||"",onChange:R=>v(C.fieldname,R.target.value),placeholder:C.placeholder,disabled:P,className:E})}};return!r||!b?null:t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[9999]",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[90vh] flex flex-col",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white flex items-center gap-2",children:[t.jsx(Rr,{className:"text-blue-500",size:16}),b.title]}),t.jsx("button",{type:"button",onClick:a,disabled:f,className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded transition-colors disabled:opacity-50",children:t.jsx(ht,{size:18})})]}),t.jsx("form",{onSubmit:S,className:"flex-1 overflow-y-auto p-4",children:t.jsx("div",{className:"space-y-4",children:b.fields.map(C=>C.hidden||C.dependsOn&&!l[C.dependsOn]?null:t.jsxs("div",{children:[C.fieldtype!=="Check"&&t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:[C.label,C.required&&t.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),N(C),C.description&&C.fieldtype!=="Check"&&t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:C.description}),u[C.fieldname]&&t.jsxs("p",{className:"mt-1 text-xs text-red-500 flex items-center gap-1",children:[t.jsx(Or,{size:10}),u[C.fieldname]]})]},C.fieldname))})}),t.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-gray-200 dark:border-gray-700",children:[t.jsx("button",{type:"button",onClick:a,disabled:f,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 hover:bg-gray-300 rounded-lg transition-colors disabled:opacity-50",children:"Cancel"}),t.jsx("button",{type:"submit",onClick:S,disabled:f,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-lg transition-colors disabled:opacity-50 flex items-center gap-2",children:f?t.jsxs(t.Fragment,{children:[t.jsx(tr,{className:"animate-spin",size:14}),"Creating..."]}):t.jsxs(t.Fragment,{children:[t.jsx(Rr,{size:14}),"Create"]})})]})]})})},Nse={},Je=({label:e,doctype:r,value:a,onChange:s,hideLabel:n=!1,placeholder:i,disabled:o=!1,filters:l,compact:c=!1,usePortal:u=!0,allowQuickCreate:h=!1,onQuickCreateSuccess:f,quickCreateInitialValues:y={},query:b})=>{const{t:w}=sr(),[v,k]=p.useState([]),[S,N]=p.useState(""),[C,O]=p.useState(!1),[T,P]=p.useState(!1),[E,R]=p.useState({top:0,left:0,width:0}),[z,G]=p.useState(!1),[ae,ee]=p.useState(null),ne=p.useRef(null),te=p.useRef(null),Y=p.useRef(null),q=p.useRef(null),H=p.useRef(""),U=p.useRef(!1),re=l||Nse,X=p.useMemo(()=>JSON.stringify(re),[re]),V=p.useMemo(()=>{const be=Uae(r);return console.log(`[LinkField] ${r} hasQuickCreateConfig: ${be}`),be},[r]);p.useEffect(()=>{ee(null),h&&V?(console.log(`[LinkField] Checking permission for ${r}...`),Wae(r).then(be=>{console.log(`[LinkField] Permission for ${r}: ${be}`),ee(be)}).catch(be=>{console.error(`[LinkField] Permission check failed for ${r}:`,be),ee(!1)})):(ee(!1),h&&!V&&console.warn(`[LinkField] ${r}: allowQuickCreate=true but no config in QuickCreateConfig.ts`))},[h,r,V]);const I=p.useMemo(()=>{const be=h&&V&&ae===!0;return console.log(`[LinkField] canQuickCreate for ${r}: ${be}`,{allowQuickCreate:h,hasQuickCreateConfig:V,hasPermission:ae}),be},[h,V,ae,r]),B=p.useCallback((be="",K=!1)=>J(null,null,function*(){const ye=`${be}-${X}-${b||""}`;if(!(!K&&H.current===ye)){H.current=ye,P(!0);try{let Z=null;if(b){const M=new URLSearchParams({txt:be,doctype:r,searchfield:"name",start:"0",page_len:"50"});re&&Object.keys(re).length>0&&M.append("filters",JSON.stringify(re));const we=yield At.apiCall(`/api/method/${b}?${M.toString()}`);Array.isArray(we)?Z=we.map(pe=>Array.isArray(pe)?{value:pe[0],description:pe[1]||void 0}:{value:pe.value||pe.name||pe,description:pe.description}):Z=[]}else{const M=new URLSearchParams({doctype:r,txt:be,page_length:"50"});re&&Object.keys(re).length>0&&M.append("filters",JSON.stringify(re)),Z=yield At.apiCall(`/api/method/frappe.desk.search.search_link?${M.toString()}`)}k(Z||[])}catch(Z){console.error(`Error fetching ${r} links:`,Z),k([])}finally{P(!1)}}}),[r,X,re,b]),Q=p.useCallback(be=>{q.current&&clearTimeout(q.current),q.current=setTimeout(()=>{B(be)},300)},[B]);p.useEffect(()=>{C&&!U.current&&(U.current=!0,B(S||"",!0)),C||(U.current=!1,H.current="")},[C]),p.useEffect(()=>()=>{q.current&&clearTimeout(q.current)},[]);const ie=p.useCallback(()=>{if(u&&te.current){const be=te.current.getBoundingClientRect();R({top:be.bottom+window.scrollY,left:be.left+window.scrollX,width:be.width})}},[u]);p.useEffect(()=>{if(C&&u){ie();const be=()=>ie();return window.addEventListener("scroll",be,!0),window.addEventListener("resize",be),()=>{window.removeEventListener("scroll",be,!0),window.removeEventListener("resize",be)}}},[C,u,ie]),p.useEffect(()=>{const be=K=>{const ye=K.target,Z=ne.current&&!ne.current.contains(ye),M=u&&Y.current&&!Y.current.contains(ye);u?Z&&M&&(O(!1),N("")):Z&&(O(!1),N(""))};return document.addEventListener("mousedown",be),()=>document.removeEventListener("mousedown",be)},[u]);const me=be=>{s(be),N(""),O(!1)},he=()=>{s(""),N(""),O(!1)},de=()=>{O(!1),N(""),G(!0)},xe=be=>{const K=be.name||be[Object.keys(be)[0]];me(K),f&&f(be)},ge=()=>{const be=`bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600
|
||
rounded-md w-full shadow-lg ${c?"mt-0.5":"mt-1"}`,K=u?{position:"fixed",top:`${E.top}px`,left:`${E.left}px`,width:`${E.width}px`,zIndex:1050,marginTop:c?"2px":"4px"}:{};if(!C||o)return null;const ye=t.jsxs("div",{ref:Y,children:[T&&t.jsxs("div",{className:`${u?"":"absolute z-[1050]"} ${be} text-center text-gray-500 dark:text-gray-400
|
||
${c?"p-1.5 text-[10px]":"p-3 text-sm"}`,style:K,children:[t.jsx("span",{className:"inline-block animate-spin mr-2",children:"⏳"}),w("linkField.loading")]}),!T&&t.jsxs("div",{className:`${u?"":"absolute z-[1050]"} ${be} overflow-hidden`,style:K,children:[v.length>0?t.jsx("ul",{className:`overflow-auto ${c?"max-h-36":"max-h-48"}`,children:v.map((Z,M)=>t.jsxs("li",{onClick:()=>me(Z.value),className:`cursor-pointer text-gray-900 dark:text-gray-100
|
||
hover:bg-blue-500 dark:hover:bg-blue-600 hover:text-white
|
||
${c?"px-2 py-1 text-xs":"px-3 py-2 text-sm"}
|
||
${a===Z.value?"bg-blue-50 dark:bg-blue-700 font-semibold":""}`,children:[Z.value,Z.description&&t.jsx("span",{className:`text-gray-600 dark:text-gray-300 ml-2
|
||
${c?"text-[9px] ml-1":"text-xs ml-2"}`,children:Z.description})]},M))}):t.jsx("div",{className:`text-center text-gray-500 dark:text-gray-400
|
||
${c?"p-1.5 text-[10px]":"p-3 text-sm"}`,children:w("linkField.noResultsFound")}),I&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700"}),t.jsxs("div",{onClick:de,className:`cursor-pointer flex items-center gap-2
|
||
text-green-600 dark:text-green-400
|
||
hover:bg-green-50 dark:hover:bg-green-900/20
|
||
hover:text-green-700 dark:hover:text-green-300
|
||
transition-colors
|
||
${c?"px-2 py-1.5 text-xs":"px-3 py-2.5 text-sm"}`,children:[t.jsx(Rr,{size:c?10:12}),t.jsx("span",{className:"font-medium",children:w("linkField.createNewDoctype",{doctype:r.replace(/_/g," ")})})]})]})]})]});return u?wx.createPortal(ye,document.body):ye};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:ne,className:`relative w-full ${c?"mb-2":n?"mb-0":"mb-4"}`,children:[!n&&t.jsx("label",{className:`block font-medium text-gray-700 dark:text-gray-300 ${c?"text-[10px] mb-0.5":"text-sm mb-1"}`,children:e}),t.jsxs("div",{className:"relative",children:[t.jsx("input",{ref:te,type:"text",value:C?S:a,placeholder:i||w("linkField.selectLabel",{label:e}),disabled:o,className:`w-full border border-gray-300 dark:border-gray-600 rounded-md
|
||
focus:outline-none disabled:bg-gray-100 dark:disabled:bg-gray-700
|
||
bg-white dark:bg-gray-700 text-gray-900 dark:text-white
|
||
${c?"px-2 py-1 text-xs focus:ring-1 focus:ring-blue-500 rounded":"px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500"}
|
||
${a?c?"pr-5":"pr-8":""}`,onFocus:()=>{o||(O(!0),N(""),u&&ie())},onChange:be=>{const K=be.target.value;N(K),Q(K)}}),a&&!o&&!C&&t.jsx("button",{type:"button",onClick:he,className:`absolute top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300
|
||
${c?"right-1 text-xs":"right-2 text-sm"}`,children:"✕"})]}),ge()]}),t.jsx(kse,{doctype:r,isOpen:z,onClose:()=>G(!1),onSuccess:xe,initialValues:y,parentFilters:re})]})},_l=({currentPage:e,totalCount:r=0,pageSize:a,hasMore:s=!1,itemLabel:n,onPageChange:i,className:o=""})=>{const{t:l}=sr(),c=n!=null?n:l("listPages.results"),u=r>0?Math.max(1,Math.ceil(r/a)):0,h=r>0,f=(e-1)*a+1,y=h?Math.min(e*a,r):e*a,[b,w]=p.useState(""),v=N=>{N.preventDefault();const C=parseInt(b.trim(),10);if(!Number.isNaN(C)&&C>=1){const O=h?Math.min(C,u):C;i(O),w("")}},k=()=>{if(u<=7)return Array.from({length:u},(C,O)=>O+1);const N=[];N.push(1),e>3&&N.push("ellipsis");for(let C=Math.max(2,e-1);C<=Math.min(u-1,e+1);C++)N.includes(C)||N.push(C);return e<u-2&&N.push("ellipsis"),u>1&&N.push(u),N};return s||e>1||h&&u>1?t.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 px-6 py-4 border-t border-gray-200 dark:border-gray-700 ${o}`,children:[t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:h?l("pagination.showingToOf",{start:f,end:y,total:r,label:c}):l("pagination.showingTo",{start:f,end:y,label:c})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>i(e-1),disabled:e<=1,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed",children:l("pagination.previous")}),h&&u>1&&t.jsx("div",{className:"flex items-center gap-1",children:k().map((N,C)=>N==="ellipsis"?t.jsx("span",{className:"px-2 text-gray-500 dark:text-gray-400",children:"…"},`e-${C}`):t.jsx("button",{type:"button",onClick:()=>i(N),className:`min-w-[2rem] px-2 py-1 text-sm font-medium rounded-lg transition-colors ${N===e?"bg-blue-600 text-white border border-blue-600":"text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600"}`,children:N},N))}),t.jsx("button",{type:"button",onClick:()=>i(e+1),disabled:h?e>=u:!s,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed",children:l("pagination.next")}),t.jsxs("form",{onSubmit:v,className:"flex items-center gap-1 ml-2",children:[t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400 whitespace-nowrap",children:l("pagination.goTo")}),t.jsx("input",{type:"number",min:1,max:h?u:void 0,value:b,onChange:N=>w(N.target.value),placeholder:h?`1-${u}`:l("pagination.page"),className:"w-14 px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),t.jsx("button",{type:"submit",className:"px-2 py-1 text-sm font-medium text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700",children:l("pagination.go")})]})]})]}):null};function xa(e){if(!e||typeof e!="object")return[];const r=[];for(const[a,s]of Object.entries(e))if(!(s==null||s===""))if(a==="creation_from")r.push(["creation",">=",s]);else if(a==="creation_to"){const n=new Date(s);if(!isNaN(n.getTime())){n.setDate(n.getDate()+1);const i=n.toISOString().slice(0,10);r.push(["creation","<",i])}}else if(a==="modified_from")r.push(["modified",">=",s]);else if(a==="modified_to"){const n=new Date(s);if(!isNaN(n.getTime())){n.setDate(n.getDate()+1);const i=n.toISOString().slice(0,10);r.push(["modified","<",i])}}else Array.isArray(s)&&s.length>=2?r.push([a,s[0],s[1]]):r.push([a,"=",s]);return r}function kl(e,r,a){if(!e||!r&&!a)return{};const s={};return e==="creation"?(r&&(s.creation_from=r),a&&(s.creation_to=a)):(r&&(s.modified_from=r),a&&(s.modified_to=a)),s}const CS=Object.freeze(Object.defineProperty({__proto__:null,buildDateRangeFilters:kl,toFrappeFilterArray:xa},Symbol.toStringTag,{value:"Module"}));function Sse(e,r,a){return J(this,null,function*(){var s,n;try{const o=yield(yield fetch(`/api/resource/${e}/${encodeURIComponent(r)}`,{method:"PUT",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({custom_delete_status:a})})).json();return o.data||o.message?{success:!0}:{success:!1,error:o.exc_type==="ValidationError"?o.exception||"Validation error":o._server_messages?((n=(s=JSON.parse(o._server_messages))==null?void 0:s[0])==null?void 0:n.message)||"Unknown error":"Failed to update delete status"}}catch(i){return{success:!1,error:i instanceof Error?i.message:"Network error"}}})}function Cse(e,r){return console.log("[DeleteRequest] userRoles:",e,"| isSystemManager:",r),r||e.includes("System Manager")?"System Manager":e.includes("Cluster Manager")?"Cluster Manager":e.includes("Contractor Supervisor")||e.includes("DR Approver")?"Contractor Supervisor":e.includes("End user")?"End user":"Other"}function Tse(e,r){const a={showRaiseRequest:!1,showApproveAsSupervisor:!1,showApproveAsCM:!1,showDirectDelete:!1};return r==="Deleted"?a:!r||r===""?e==="End user"?a:e==="System Manager"||e==="Cluster Manager"?je(se({},a),{showDirectDelete:!0}):e==="Contractor Supervisor"?je(se({},a),{showRaiseRequest:!0}):je(se({},a),{showRaiseRequest:!0}):r==="Delete Request With Supervisor"?e==="Contractor Supervisor"?je(se({},a),{showApproveAsSupervisor:!0}):e==="System Manager"||e==="Cluster Manager"?je(se({},a),{showApproveAsCM:!0}):a:r==="Delete Request With CM"&&(e==="System Manager"||e==="Cluster Manager")?je(se({},a),{showApproveAsCM:!0}):a}function Ese(e,r){return e==="reject"?"":e==="direct"||e==="cm_approve"?"Deleted":e==="supervisor_approve"||r==="Contractor Supervisor"?"Delete Request With CM":"Delete Request With Supervisor"}function Ase({doctype:e,docname:r,currentDeleteStatus:a,userRoles:s,isSystemManager:n,onSuccess:i}){const[o,l]=p.useState(!1),[c,u]=p.useState(null),[h,f]=p.useState(a),y=h!==a?h:a,b=p.useMemo(()=>Cse(s,n),[s,n]),w=p.useMemo(()=>Tse(b,y),[b,y]),v=p.useCallback(k=>J(null,null,function*(){if(!r)return;l(!0),u(null);const S=Ese(k,b),N=yield Sse(e,r,S);l(!1),N.success?(f(S),i==null||i(S)):u(N.error||"Failed to update delete status")}),[e,r,b,i]);return je(se({},w),{deleteStatus:y,loading:o,error:c,highestRole:b,raiseRequest:()=>v("raise"),approveAsSupervisor:()=>v("supervisor_approve"),approveAsCM:()=>v("cm_approve"),directDelete:()=>v("direct"),rejectRequest:()=>v("reject")})}const _7=({title:e,message:r,confirmLabel:a,confirmClass:s,icon:n,loading:i,onConfirm:o,onCancel:l})=>t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[9999]",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl p-6 max-w-md w-full mx-4 shadow-2xl",children:[t.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[t.jsx("span",{className:"mt-0.5 flex-shrink-0 text-xl",children:n}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold text-gray-800 dark:text-white",children:e}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:r})]})]}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:l,disabled:i,className:"px-4 py-2 bg-gray-200 hover:bg-gray-300 dark:bg-gray-600 dark:hover:bg-gray-500 text-gray-700 dark:text-gray-200 rounded-lg text-sm font-medium disabled:opacity-50",children:"Cancel"}),t.jsxs("button",{onClick:o,disabled:i,className:`px-4 py-2 text-white rounded-lg text-sm font-medium flex items-center gap-2 disabled:opacity-50 ${s}`,children:[i?t.jsx(tr,{className:"animate-spin",size:13}):null,a]})]})]})}),k7=({primaryLabel:e,primaryClass:r,primaryIcon:a,onPrimary:s,secondaryLabel:n,secondaryClass:i,secondaryIcon:o,onSecondary:l,disabled:c=!1,loading:u=!1})=>{const[h,f]=p.useState(!1),y=p.useRef(null);return p.useEffect(()=>{const b=w=>{y.current&&!y.current.contains(w.target)&&f(!1)};return h&&document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[h]),t.jsxs("div",{ref:y,className:"relative inline-flex rounded-lg overflow-visible",children:[t.jsxs("button",{type:"button",disabled:c,onClick:s,className:`px-4 py-2 text-white text-sm font-medium flex items-center gap-2 disabled:opacity-50 transition-colors rounded-l-lg ${r}`,children:[u?t.jsx(tr,{className:"animate-spin",size:13}):a,e]}),t.jsx("span",{className:"w-px bg-white/30"}),t.jsx("button",{type:"button",disabled:c,onClick:()=>f(b=>!b),className:`px-2 py-2 text-white text-sm font-medium flex items-center disabled:opacity-50 transition-colors rounded-r-lg ${r}`,"aria-label":"More options",children:t.jsx(Fr,{size:11,className:`transition-transform ${h?"rotate-180":""}`})}),h&&t.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg min-w-[160px] overflow-hidden",children:t.jsxs("button",{type:"button",disabled:c,onClick:()=>{f(!1),l()},className:`w-full px-4 py-2.5 text-sm font-medium flex items-center gap-2 transition-colors ${i}`,children:[o,n]})})]})},N7=({status:e})=>{if(!e)return null;const a={"Delete Request With Supervisor":{bg:"bg-orange-100 dark:bg-orange-900/30",text:"text-orange-700 dark:text-orange-300",label:"⏳ Delete Request Pending Supervisor"},"Delete Request With CM":{bg:"bg-yellow-100 dark:bg-yellow-900/30",text:"text-yellow-700 dark:text-yellow-300",label:"⏳ Delete Request Pending CM"},Deleted:{bg:"bg-red-100 dark:bg-red-900/30",text:"text-red-700 dark:text-red-300",label:"🗑 Marked for Deletion"}}[e];return a?t.jsx("span",{className:`inline-flex items-center px-2.5 py-1 rounded-full text-xs font-medium ${a.bg} ${a.text}`,children:a.label}):null},n0=({doctype:e,docname:r,currentDeleteStatus:a,userRoles:s,isSystemManager:n,onStatusChange:i,className:o="",inline:l=!1,redirectOnDelete:c,triggerMode:u=!1})=>{const h=hr(),[f,y]=p.useState(null),[b,w]=p.useState(!1),v=p.useRef(null),{showRaiseRequest:k,showApproveAsSupervisor:S,showApproveAsCM:N,showDirectDelete:C,deleteStatus:O,loading:T,error:P,raiseRequest:E,approveAsSupervisor:R,approveAsCM:z,directDelete:G,rejectRequest:ae}=Ase({doctype:e,docname:r,currentDeleteStatus:a,userRoles:s,isSystemManager:n,onSuccess:q=>{i==null||i(q),q==="Deleted"&&c&&h(c)}});p.useEffect(()=>{if(!b)return;const q=H=>{v.current&&!v.current.contains(H.target)&&w(!1)};return document.addEventListener("mousedown",q),()=>document.removeEventListener("mousedown",q)},[b]);const ee=()=>J(null,null,function*(){if(!f)return;yield{raise:E,supervisor_approve:R,supervisor_reject:ae,cm_approve:z,cm_reject:ae,direct:G}[f](),y(null)}),ne={raise:{title:"Request Deletion",message:"This will raise a deletion request to the Supervisor for review.",confirmLabel:"Raise Request",confirmClass:"bg-orange-600 hover:bg-orange-700",icon:t.jsx(Or,{className:"text-orange-500"})},supervisor_approve:{title:"Approve Deletion Request",message:"This will forward the deletion request to the Cluster Manager for final approval.",confirmLabel:"Approve & Forward",confirmClass:"bg-yellow-600 hover:bg-yellow-700",icon:t.jsx(Qt,{className:"text-yellow-500"})},supervisor_reject:{title:"Reject Deletion Request",message:"This will reject the deletion request and clear the status. The record will remain active.",confirmLabel:"Reject Request",confirmClass:"bg-gray-600 hover:bg-gray-700",icon:t.jsx(Mo,{className:"text-gray-500"})},cm_approve:{title:"Approve & Mark as Deleted",message:"This will mark the record as Deleted.",confirmLabel:"Approve & Delete",confirmClass:"bg-red-600 hover:bg-red-700",icon:t.jsx(wr,{className:"text-red-500"})},cm_reject:{title:"Reject Deletion Request",message:"This will reject the deletion request and clear the status. The record will remain active.",confirmLabel:"Reject Request",confirmClass:"bg-gray-600 hover:bg-gray-700",icon:t.jsx(Mo,{className:"text-gray-500"})},direct:{title:"Mark as Deleted",message:"This will immediately Delete The Record.",confirmLabel:"Delete",confirmClass:"bg-red-600 hover:bg-red-700",icon:t.jsx(wr,{className:"text-red-500"})}},te={"Delete Request With Supervisor":"Delete Request Pending Supervisor","Delete Request With CM":"Delete Request Pending Cluster Manager",Deleted:"Marked for Deletion"};if(u){const H=!!O?"text-orange-500 dark:text-orange-400 hover:bg-orange-50 dark:hover:bg-orange-900/20":"text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20";return!k&&!S&&!N&&!C&&!O?null:t.jsxs(t.Fragment,{children:[f&&t.jsx(_7,je(se({},ne[f]),{loading:T,onConfirm:ee,onCancel:()=>y(null)})),t.jsxs("div",{className:"relative",ref:v,children:[t.jsx("button",{type:"button",onClick:()=>w(re=>!re),title:O?te[O]:"Request Deletion",className:`p-2 rounded transition-colors ${H}`,disabled:T||!r,children:T?t.jsx(tr,{className:"animate-spin",size:14}):t.jsx(wr,{size:14})}),b&&t.jsxs("div",{className:"absolute right-0 mt-1 z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-xl p-3 min-w-[230px]",children:[O&&t.jsx("div",{className:"mb-3",children:t.jsx(N7,{status:O})}),P&&t.jsxs("p",{className:"text-xs text-red-500 mb-2 flex items-center gap-1",children:[t.jsx(Or,{size:10})," ",P]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[k&&t.jsxs("button",{type:"button",disabled:T||!r,onClick:()=>{w(!1),y("raise")},className:"w-full px-3 py-2 bg-orange-600 hover:bg-orange-700 text-white rounded-lg text-xs font-medium flex items-center gap-2 disabled:opacity-50",children:[t.jsx(wr,{size:11})," Request Deletion"]}),S&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",disabled:T||!r,onClick:()=>{w(!1),y("supervisor_approve")},className:"w-full px-3 py-2 bg-yellow-600 hover:bg-yellow-700 text-white rounded-lg text-xs font-medium flex items-center gap-2 disabled:opacity-50",children:[t.jsx(Qt,{size:11})," Approve & Forward to CM"]}),t.jsxs("button",{type:"button",disabled:T||!r,onClick:()=>{w(!1),y("supervisor_reject")},className:"w-full px-3 py-2 bg-gray-200 hover:bg-gray-300 dark:bg-gray-600 dark:hover:bg-gray-500 text-gray-700 dark:text-gray-200 rounded-lg text-xs font-medium flex items-center gap-2 disabled:opacity-50",children:[t.jsx(Mo,{size:11})," Reject Request"]})]}),N&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",disabled:T||!r,onClick:()=>{w(!1),y("cm_approve")},className:"w-full px-3 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-xs font-medium flex items-center gap-2 disabled:opacity-50",children:[t.jsx(Qt,{size:11})," Approve & Delete"]}),t.jsxs("button",{type:"button",disabled:T||!r,onClick:()=>{w(!1),y("cm_reject")},className:"w-full px-3 py-2 bg-gray-200 hover:bg-gray-300 dark:bg-gray-600 dark:hover:bg-gray-500 text-gray-700 dark:text-gray-200 rounded-lg text-xs font-medium flex items-center gap-2 disabled:opacity-50",children:[t.jsx(Mo,{size:11})," Reject Request"]})]}),C&&t.jsxs("button",{type:"button",disabled:T||!r,onClick:()=>{w(!1),y("direct")},className:"w-full px-3 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-xs font-medium flex items-center gap-2 disabled:opacity-50",children:[t.jsx(wr,{size:11})," Delete"]})]})]})]})]})}const Y=l?"flex flex-row flex-wrap items-center gap-2":"flex flex-col gap-2";return t.jsxs(t.Fragment,{children:[f&&t.jsx(_7,je(se({},ne[f]),{loading:T,onConfirm:ee,onCancel:()=>y(null)})),t.jsxs("div",{className:`${Y} ${o}`,children:[O&&t.jsx(N7,{status:O}),P&&t.jsxs("p",{className:"text-xs text-red-500 dark:text-red-400 flex items-center gap-1",children:[t.jsx(Or,{size:11})," ",P]}),k&&t.jsxs("button",{type:"button",disabled:T||!r,onClick:()=>y("raise"),className:"px-4 py-2 bg-orange-600 hover:bg-orange-700 text-white rounded-lg text-sm font-medium flex items-center gap-2 disabled:opacity-50 transition-colors",children:[T?t.jsx(tr,{className:"animate-spin",size:13}):t.jsx(wr,{size:13}),"Request Deletion"]}),S&&t.jsx(k7,{disabled:T||!r,loading:T,primaryLabel:"Approve Request",primaryClass:"bg-yellow-600 hover:bg-yellow-700",primaryIcon:t.jsx(Qt,{size:13}),onPrimary:()=>y("supervisor_approve"),secondaryLabel:"Reject Request",secondaryClass:"text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700",secondaryIcon:t.jsx(Mo,{size:13,className:"text-gray-500"}),onSecondary:()=>y("supervisor_reject")}),N&&t.jsx(k7,{disabled:T||!r,loading:T,primaryLabel:"Approve & Delete",primaryClass:"bg-red-600 hover:bg-red-700",primaryIcon:t.jsx(Qt,{size:13}),onPrimary:()=>y("cm_approve"),secondaryLabel:"Reject Request",secondaryClass:"text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700",secondaryIcon:t.jsx(Mo,{size:13,className:"text-gray-500"}),onSecondary:()=>y("cm_reject")}),C&&t.jsxs("button",{type:"button",disabled:T||!r,onClick:()=>y("direct"),className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-sm font-medium flex items-center gap-2 disabled:opacity-50 transition-colors",children:[T?t.jsx(tr,{className:"animate-spin",size:13}):t.jsx(wr,{size:13}),"Delete"]})]})]})},Ose={Work_Order:new Set(["name","asset","asset_name","work_order_type","company","department","repair_status","workflow_state","custom_priority_","creation","modified"]),Asset:new Set(["name","asset_name","custom_serial_number","company","location","custom_device_status","modified"])},bb=new Map;function Pse(e){const[r,a]=p.useState([]),[s,n]=p.useState(!1),[i,o]=p.useState(null),l=p.useRef(!1);return p.useEffect(()=>{if(!e)return;let u=!1;return J(null,null,function*(){if(!l.current){if(l.current=!0,bb.has(e)){u||a(bb.get(e)),l.current=!1;return}u||(n(!0),o(null));try{const f=yield fetch("/api/method/asset_lite.api.doctype_fields.get_export_fields",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({doctype:e})});if(!f.ok)throw new Error(`Server returned ${f.status}`);const y=yield f.json();if(y.exc)throw new Error(y.exc);const b=y.message||[],w=Ose[e],v=b.map((k,S)=>({key:k.fieldname,label:k.label||k.fieldname,fieldtype:k.fieldtype||"Data",default:w?w.has(k.fieldname):S<8}));console.log(`[useDoctypeFields] ✅ "${e}": ${v.length} fields from server`),bb.set(e,v),u||a(v)}catch(f){console.error("[useDoctypeFields] ❌",f),u||(o(f instanceof Error?f.message:"Failed to fetch fields"),a([{key:"name",label:"ID",fieldtype:"Data",default:!0},{key:"creation",label:"Created On",fieldtype:"Datetime",default:!1},{key:"modified",label:"Modified On",fieldtype:"Datetime",default:!0}]))}finally{l.current=!1,u||n(!1)}}}),()=>{u=!0}},[e]),{fields:r,loading:s,error:i,refetchFields:()=>{bb.delete(e),l.current=!1,a([]),o(null)}}}function pL(e){return e==null?"":typeof e=="boolean"?e?"Yes":"No":String(e)}function Dse(e,r,a){const s=r.map(u=>u.label),n=e.map(u=>r.map(h=>{const f=pL(u[h.key]);return f.includes(",")||f.includes('"')||f.includes(`
|
||
`)?`"${f.replace(/"/g,'""')}"`:f}).join(",")),i=[s.join(","),...n].join(`
|
||
`),o=new Blob(["\uFEFF"+i],{type:"text/csv;charset=utf-8;"}),l=URL.createObjectURL(o),c=document.createElement("a");c.href=l,c.download=a,c.click(),URL.revokeObjectURL(l)}function Rse(e,r,a){const s=[r.map(o=>o.label),...e.map(o=>r.map(l=>pL(o[l.key])))],n=Na.aoa_to_sheet(s),i=Na.book_new();Na.book_append_sheet(i,n,"Export"),lc(i,a)}const bi=({isOpen:e,onClose:r,doctype:a,selectedCount:s,pageCount:n,totalCount:i,onExport:o,onFetchAll:l,pageData:c,selectedRows:u,rowKey:h="name",extraColumns:f=[],hiddenColumns:y=[],defaultColumns:b,fileNamePrefix:w})=>{const{t:v}=sr(),{fields:k,loading:S}=Pse(a),N=gr.useMemo(()=>{const X=new Set(y),V=[...k.filter(I=>!X.has(I.key)),...f.filter(I=>!X.has(I.key))];if(b){const I=new Set(b);return V.map(B=>je(se({},B),{default:I.has(B.key)}))}return V},[k,f,y,b]),[C,O]=p.useState(s>0?"selected":"all_with_filters"),[T,P]=p.useState("csv"),[E,R]=p.useState(new Set),[z,G]=p.useState(""),[ae,ee]=p.useState(!1),ne=gr.useRef(!1);if(p.useEffect(()=>{O(s>0?"selected":"all_with_filters")},[s]),p.useEffect(()=>{N.length!==0&&(ne.current||(ne.current=!0,R(new Set(N.filter(X=>X.default).map(X=>X.key)))))},[N]),p.useEffect(()=>{e||(ne.current=!1,R(new Set))},[e]),!e)return null;const te=z.trim()?N.filter(X=>X.label.toLowerCase().includes(z.toLowerCase())||X.key.toLowerCase().includes(z.toLowerCase())):N,Y=X=>{R(V=>{const I=new Set(V);return I.has(X)?I.delete(X):I.add(X),I})},q=()=>R(new Set(N.map(X=>X.key))),H=()=>R(new Set(N.filter(X=>X.default).map(X=>X.key))),U=()=>R(new Set),re=()=>J(null,null,function*(){if(E.size!==0){ee(!0);try{if(o){yield o(C,T,[...E]),r();return}let X=[];if(C==="selected"){const ie=u!=null?u:new Set;X=c.filter(me=>ie.has(me[h]))}else if(C==="all_on_page")X=c;else{if(!l){alert("onFetchAll not provided for all_with_filters scope");return}X=yield l()}if(X.length===0){alert("No data to export.");return}const V=N.filter(ie=>E.has(ie.key)),I=w!=null?w:a.toLowerCase().replace(/\s+/g,"_"),B=new Date().toISOString().split("T")[0],Q=`${I}_export_${B}.${T==="csv"?"csv":"xlsx"}`;T==="csv"?Dse(X,V,Q):Rse(X,V,Q),r()}catch(X){console.error("Export failed:",X),alert(`Export failed: ${X instanceof Error?X.message:"Unknown error"}`)}finally{ee(!1)}}});return t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-2xl max-h-[92vh] flex flex-col animate-scale-in",children:[t.jsx("div",{className:"bg-gradient-to-r from-green-500 to-green-600 px-6 py-4 rounded-t-lg flex-shrink-0",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Sa,{className:"text-white text-xl"}),t.jsxs("div",{children:[t.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Export ",a.replace(/_/g," ")]}),t.jsxs("p",{className:"text-green-100 text-xs mt-0.5",children:[N.length," fields available · ",E.size," selected"]})]})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:ae,children:t.jsx(ht,{size:20})})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"What to export"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(fk,{value:"selected",current:C,onChange:O,disabled:s===0,badge:s,badgeColor:"green",label:"Selected rows",sub:`${s} row${s!==1?"s":""} selected`}),t.jsx(fk,{value:"all_on_page",current:C,onChange:O,badge:n,badgeColor:"blue",label:"Current page",sub:`${n} rows on this page`}),t.jsx(fk,{value:"all_with_filters",current:C,onChange:O,badge:i,badgeColor:"purple",label:"All records (current filters)",sub:`${i} total matching records`})]})]}),t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"File format"}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx(S7,{value:"csv",current:T,onChange:P,icon:t.jsx(ic,{className:"text-green-600 text-xl"}),label:"CSV",sub:"Universal, works everywhere"}),t.jsx(S7,{value:"excel",current:T,onChange:P,icon:t.jsx(oc,{className:"text-green-700 text-xl"}),label:"Excel (.xlsx)",sub:"Native Excel workbook"})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:["Columns to export",S&&t.jsx(tr,{className:"inline ml-2 animate-spin text-gray-400",size:12})]}),t.jsxs("div",{className:"flex gap-3 text-xs text-blue-600 dark:text-blue-400",children:[t.jsx("button",{onClick:q,className:"hover:underline",children:"All"}),t.jsx("button",{onClick:H,className:"hover:underline",children:"Default"}),t.jsx("button",{onClick:U,className:"hover:underline",children:"None"})]})]}),t.jsxs("div",{className:"relative mb-2",children:[t.jsx(za,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400",size:12}),t.jsx("input",{type:"text",value:z,onChange:X=>G(X.target.value),placeholder:"Search fields…",className:"w-full pl-8 pr-3 py-1.5 text-xs border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-green-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),z&&t.jsx("button",{onClick:()=>G(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:t.jsx(ht,{size:10})})]}),S?t.jsxs("div",{className:"flex items-center justify-center h-24 text-gray-400 text-sm gap-2",children:[t.jsx(tr,{className:"animate-spin"})," Loading fields…"]}):t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-1.5 max-h-52 overflow-y-auto p-2 bg-gray-50 dark:bg-gray-900/50 rounded-lg border border-gray-200 dark:border-gray-700",children:[te.map(X=>{const V=E.has(X.key);return t.jsxs("div",{onClick:()=>Y(X.key),className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-all text-xs select-none ${V?"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-200":"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-600 dark:text-gray-400"}`,children:[t.jsx("span",{className:"flex-shrink-0",children:V?t.jsx(Ra,{size:13,className:"text-green-600"}):t.jsx(Ur,{size:13,className:"text-gray-300 dark:text-gray-600"})}),t.jsx("span",{className:"truncate",title:`${X.label} (${X.key})`,children:X.label})]},X.key)}),te.length===0&&t.jsxs("p",{className:"col-span-3 text-center text-gray-400 text-xs py-4",children:['No fields match "',z,'"']})]}),t.jsxs("p",{className:"text-xs text-gray-400 mt-1.5",children:[E.size," of ",N.length," fields selected",z&&` · showing ${te.length} matching`]})]})]}),t.jsxs("div",{className:"flex-shrink-0 px-6 py-4 bg-gray-50 dark:bg-gray-900/50 border-t border-gray-200 dark:border-gray-700 rounded-b-lg flex justify-between items-center",children:[t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:[C==="selected"&&`Exporting ${s} selected row${s!==1?"s":""}`,C==="all_on_page"&&`Exporting ${n} rows from current page`,C==="all_with_filters"&&`Exporting up to ${i} records`]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{onClick:r,disabled:ae,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:"Cancel"}),t.jsx("button",{onClick:re,disabled:E.size===0||ae,className:"px-4 py-2 text-sm font-medium text-white bg-green-600 hover:bg-green-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:ae?t.jsxs(t.Fragment,{children:[t.jsx(tr,{className:"animate-spin",size:14})," Exporting…"]}):t.jsxs(t.Fragment,{children:[t.jsx(qc,{size:14})," Export"]})})]})]})]})})},Mse={green:"bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300",blue:"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300",purple:"bg-purple-100 dark:bg-purple-900/40 text-purple-700 dark:text-purple-300"},fk=({value:e,current:r,onChange:a,disabled:s,label:n,sub:i,badge:o,badgeColor:l})=>t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${r===e?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"} ${s?"opacity-50 cursor-not-allowed":""}`,children:[t.jsx("input",{type:"radio",name:"export_scope",value:e,checked:r===e,onChange:()=>!s&&a(e),disabled:s,className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-medium text-sm text-gray-900 dark:text-white",children:n}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:i})]}),t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold flex-shrink-0 ${Mse[l]}`,children:o.toLocaleString()})]}),S7=({value:e,current:r,onChange:a,icon:s,label:n,sub:i})=>t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${r===e?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"export_format",value:e,checked:r===e,onChange:()=>a(e),className:"text-green-600 focus:ring-green-500"}),s,t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-sm text-gray-900 dark:text-white",children:n}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:i})]})]}),Lse=({isOpen:e,onClose:r,selectedCount:a,totalCount:s,pageCount:n,onPrint:i,isPrinting:o})=>{const{t:l}=sr(),[c,u]=p.useState(a>0?"selected":"all_with_filters");return p.useEffect(()=>{a>0?u("selected"):u("all_with_filters")},[a]),e?t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-lg w-full animate-scale-in",children:[t.jsx("div",{className:"bg-gradient-to-r from-purple-500 to-purple-600 px-6 py-4 rounded-t-lg",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Hu,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:"Print QR Codes"})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:o,children:t.jsx(ht,{size:20})})]})}),t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"mb-5 p-3 bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-700 rounded-lg",children:[t.jsxs("p",{className:"text-sm text-purple-700 dark:text-purple-300 flex items-center gap-2",children:[t.jsx(Hu,{}),t.jsxs("span",{children:["Layout: ",t.jsx("strong",{children:"2 columns × 5 rows = 10 QR codes per A4 page"})]})]}),t.jsx("p",{className:"text-xs text-purple-500 dark:text-purple-400 mt-1 ml-6",children:"Each QR includes Asset Name and Asset ID"})]}),t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"Select Records"}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${c==="selected"?"border-purple-500 bg-purple-50 dark:bg-purple-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"} ${a===0?"opacity-50 cursor-not-allowed":""}`,children:[t.jsx("input",{type:"radio",name:"qr_scope",value:"selected",checked:c==="selected",onChange:()=>u("selected"),disabled:a===0,className:"text-purple-600 focus:ring-purple-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"Selected Rows"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:[a," asset(s) selected"]})]}),a>0&&t.jsx("span",{className:"bg-purple-100 dark:bg-purple-900/40 text-purple-700 dark:text-purple-300 px-2 py-1 rounded text-xs font-medium",children:a})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${c==="all_on_page"?"border-purple-500 bg-purple-50 dark:bg-purple-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"qr_scope",value:"all_on_page",checked:c==="all_on_page",onChange:()=>u("all_on_page"),className:"text-purple-600 focus:ring-purple-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"Current Page"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:[n," assets on this page"]})]}),t.jsx("span",{className:"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300 px-2 py-1 rounded text-xs font-medium",children:n})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${c==="all_with_filters"?"border-purple-500 bg-purple-50 dark:bg-purple-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"qr_scope",value:"all_with_filters",checked:c==="all_with_filters",onChange:()=>u("all_with_filters"),className:"text-purple-600 focus:ring-purple-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"All Records (with filters)"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["All ",s," matching assets"]})]}),t.jsx("span",{className:"bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300 px-2 py-1 rounded text-xs font-medium",children:s})]})]})]}),t.jsxs("div",{className:"px-6 py-4 bg-gray-50 dark:bg-gray-900/50 border-t border-gray-200 dark:border-gray-700 flex justify-end gap-3 rounded-b-lg",children:[t.jsx("button",{onClick:r,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",disabled:o,children:"Cancel"}),t.jsx("button",{onClick:()=>i(c),disabled:o,className:"px-4 py-2 text-sm font-medium text-white bg-purple-600 hover:bg-purple-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:o?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Fetching QR Codes..."]}):t.jsxs(t.Fragment,{children:[t.jsx(Hu,{}),"Print QRs"]})})]})]})}):null},Fse=()=>{const{t:e}=sr(),r=hr(),[a,s]=_a(),n=p.useRef(s),i=p.useMemo(()=>{const mt=parseInt(a.get("page")||"1",10);return Math.max(0,Number.isNaN(mt)?0:mt-1)},[a]),o=p.useCallback(mt=>{n.current(ft=>{const dr=new URLSearchParams(ft);return dr.set("page",String(mt+1)),dr})},[]);p.useEffect(()=>{n.current=s},[s]);const[l,c]=p.useState(()=>a.get("search")||""),[u,h]=p.useState(null),[f,y]=p.useState(null),b=p.useRef(null),w=20,[v,k]=p.useState(!1),[S,N]=p.useState(new Set),[C,O]=p.useState(!1),[T,P]=p.useState(!1),[E,R]=p.useState(!1),[z,G]=p.useState(!1),[ae,ee]=p.useState(!1),[ne,te]=p.useState([]),[Y,q]=p.useState(!1),{permissionFilters:H,loading:U,error:re}=jS("Asset"),[X,V]=p.useState(!1),I=["Maintenance Manager","Maintenance User","System Manager","Technician","Contractor Engineer","Work Control"],B=["Contractor Supervisor"];p.useEffect(()=>{J(null,null,function*(){try{console.log("🔍 [Role Check] Starting role check...");const dr=yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({roles:I.join(",")})})).json();if(console.log("🔍 [Role Check] API Response:",dr),dr.message){console.log("🔍 [Role Check] User roles:",dr.message.user_roles),console.log("🔍 [Role Check] Matching roles:",dr.message.matching_roles),console.log("✅ [Role Check] Has allowed role:",dr.message.has_role);const us=dr.message.user_roles||[],Bn=us.includes("System Manager");B.some(Sr=>us.includes(Sr))&&!Bn?(console.log("🚫 [Role Check] Blocked: Contractor Supervisor without System Manager"),V(!1)):V(dr.message.has_role)}else console.error("❌ [Role Check] Invalid response:",dr),V(!1);const Oe=yield(yield fetch("/api/method/asset_lite.api.user_roles.get_user_roles",{credentials:"include"})).json(),ar=Array.isArray(Oe.message)?Oe.message:[];te(ar),q(ar.includes("System Manager"))}catch(ft){console.error("❌ [Role Check] Error:",ft),V(!1)}})},[]);const[Q,ie]=p.useState(()=>a.get("date_filter_by")||""),[me,he]=p.useState(()=>a.get("date_start")||""),[de,xe]=p.useState(()=>a.get("date_end")||""),[ge,be]=p.useState(()=>a.get("asset_id")||""),[K,ye]=p.useState(()=>a.get("company")||""),[Z,M]=p.useState(()=>a.get("manufacturer")||""),[we,pe]=p.useState(()=>a.get("supplier")||""),[le,Fe]=p.useState(()=>a.get("location")||""),[ze,Re]=p.useState(()=>a.get("department")||""),[De,Et]=p.useState(()=>a.get("modality")||""),[jt,Ie]=p.useState(()=>a.get("device_status")||""),[$e,Qe]=p.useState(()=>a.get("asset_name")||""),[at,Ct]=p.useState(()=>a.get("serial_number")||""),vt=["creation desc","creation asc","modified desc","modified asc","asset_name asc","asset_name desc","name asc","name desc"],[er,nr]=p.useState(()=>a.get("sort_by")||"creation desc"),[dt,He]=p.useState(!0),[it,Ue]=p.useState(0),[Ve,lt]=p.useState([]),[st,Mt]=p.useState(!1),[Ot,Pt]=p.useState(""),[zt,Tt]=p.useState(()=>a.get("asset_name")||""),[Gt,Ye]=p.useState(()=>a.get("serial_number")||""),kt=p.useRef(null),Yt=p.useRef(null);p.useEffect(()=>{const mt=localStorage.getItem("assetFilterPresets");mt&<(JSON.parse(mt))},[]);const Ae=Q&&(me||de);p.useEffect(()=>{const mt=[ge,K,le,ze,De,Z,we,jt,$e,at,l].filter(Boolean).length+(Ae?1:0);Ue(mt)},[Ae,Q,me,de,ge,K,le,ze,De,Z,we,jt,$e,at,l]);const ke={};ge&&(ke.name=ge),K&&(ke.company=K),Z&&(ke.custom_manufacturer=Z),we&&(ke.supplier=we),le&&(ke.location=le),ze&&(ke.department=ze),De&&(ke.custom_modality=De),jt&&(ke.custom_device_status=jt),$e&&(ke.asset_name=["like",`%${$e}%`]),at&&(ke.custom_serial_number=["like",`%${at}%`]),l&&(ke.asset_name=["like",`%${l}%`]),Object.assign(ke,kl(Q,me,de)),ke.custom_delete_status=["!=","Deleted"];const Be=vt.includes(er)?er:"creation desc",{assets:yt,totalCount:Me,hasMore:Ke,loading:Xe,error:oe,refetch:_e}=U9(ke,w,i*w,Be,H),{deleteAsset:ve,loading:Se}=B9();p.useEffect(()=>{!Xe&&!v&&!U&&k(!0)},[Xe,v,U]);const Ce=p.useRef(!1);p.useEffect(()=>{if(!Ce.current){Ce.current=!0;return}n.current(mt=>{const ft=new URLSearchParams(mt);return Q?ft.set("date_filter_by",Q):ft.delete("date_filter_by"),me?ft.set("date_start",me):ft.delete("date_start"),de?ft.set("date_end",de):ft.delete("date_end"),ge?ft.set("asset_id",ge):ft.delete("asset_id"),K?ft.set("company",K):ft.delete("company"),Z?ft.set("manufacturer",Z):ft.delete("manufacturer"),we?ft.set("supplier",we):ft.delete("supplier"),le?ft.set("location",le):ft.delete("location"),ze?ft.set("department",ze):ft.delete("department"),De?ft.set("modality",De):ft.delete("modality"),jt?ft.set("device_status",jt):ft.delete("device_status"),$e?ft.set("asset_name",$e):ft.delete("asset_name"),at?ft.set("serial_number",at):ft.delete("serial_number"),l?ft.set("search",l):ft.delete("search"),er&&er!=="creation desc"?ft.set("sort_by",er):ft.delete("sort_by"),ft.set("page","1"),ft})},[Q,me,de,ge,K,Z,we,le,ze,De,jt,$e,at,l,er]),p.useEffect(()=>{N(new Set)},[Q,me,de,ge,K,Z,we,le,ze,De,jt,$e,at,l,i]);const Pe=mt=>{Tt(mt),kt.current&&clearTimeout(kt.current),kt.current=window.setTimeout(()=>{Qe(mt)},800)},rt=mt=>{Ye(mt),Yt.current&&clearTimeout(Yt.current),Yt.current=window.setTimeout(()=>{Ct(mt)},800)},ut=(mt,ft)=>{mt.key==="Enter"&&(mt.preventDefault(),ft==="assetName"?(kt.current&&clearTimeout(kt.current),Qe(zt)):ft==="serialNumber"&&(Yt.current&&clearTimeout(Yt.current),Ct(Gt)))},et=()=>{if(!Ot.trim()){alert("Please enter a filter name");return}const mt={id:Date.now(),name:Ot,filters:{dateFilterBy:Q,dateStart:me,dateEnd:de,sortBy:er,filterAssetId:ge,filterCompany:K,filterLocation:le,filterDepartment:ze,filterModality:De,filterManufacturer:Z,filterSupplier:we,filterDeviceStatus:jt,filterAssetName:$e,filterSerialNumber:at,searchTerm:l}},ft=[...Ve,mt];lt(ft),Pt(""),Mt(!1),localStorage.setItem("assetFilterPresets",JSON.stringify(ft))},nt=mt=>{const ft=mt.filters;ie(ft.dateFilterBy||""),he(ft.dateStart||""),xe(ft.dateEnd||""),nr(ft.sortBy||"creation desc"),be(ft.filterAssetId||""),ye(ft.filterCompany||""),Fe(ft.filterLocation||""),Re(ft.filterDepartment||""),Et(ft.filterModality||""),M(ft.filterManufacturer||""),pe(ft.filterSupplier||""),Ie(ft.filterDeviceStatus||""),Qe(ft.filterAssetName||""),Tt(ft.filterAssetName||""),Ct(ft.filterSerialNumber||""),Ye(ft.filterSerialNumber||""),c(ft.searchTerm||"")},ct=mt=>{const ft=Ve.filter(dr=>dr.id!==mt);lt(ft),localStorage.setItem("assetFilterPresets",JSON.stringify(ft))};p.useEffect(()=>()=>{kt.current&&clearTimeout(kt.current),Yt.current&&clearTimeout(Yt.current)},[]);const $t=mt=>{switch(mt){case"Delete Request With Supervisor":return"bg-orange-50 dark:bg-orange-900/10";case"Delete Request With CM":return"bg-yellow-50 dark:bg-yellow-900/10";case"Deleted":return"bg-red-50 dark:bg-red-900/10";default:return""}},Ut=mt=>mt?new Date(mt).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"-";p.useEffect(()=>{const mt=ft=>{b.current&&!b.current.contains(ft.target)&&y(null)};return f&&document.addEventListener("mousedown",mt),()=>{document.removeEventListener("mousedown",mt)}},[f]);const Xt=mt=>{N(ft=>{const dr=new Set(ft);return dr.has(mt)?dr.delete(mt):dr.add(mt),dr})},pt=()=>{S.size===yt.length?N(new Set):N(new Set(yt.map(mt=>mt.name)))},Wt=yt.length>0&&S.size===yt.length,rr=S.size>0&&S.size<yt.length,Mr=p.useCallback(()=>J(null,null,function*(){const mt=[];let ft=0;const dr=100;let vr=!0;const Oe=se(se({},ke),H),ar=xa(Oe);for(;vr;)try{const Ba=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Asset",filters:ar.length>0?ar:{},fields:["*"],limit_start:ft*dr,limit_page_length:dr,order_by:"creation desc"})})).json()).message||[];mt.push(...Ba),Ba.length<dr?vr=!1:ft++,ft>100&&(console.warn("Export safety limit reached"),vr=!1)}catch(us){throw console.error("Error fetching assets for export:",us),us}return mt}),[ke,H]),Br=()=>r("/assets/new"),Yr=mt=>r(`/assets/${mt}`),ma=mt=>r(`/assets/${mt}`),ps=mt=>r(`/assets/new?duplicate=${mt}`),hn=mt=>J(null,null,function*(){try{console.log("Fetching full asset details for:",mt.name);const vr=(yield(yield fetch(`/api/resource/Asset/${encodeURIComponent(mt.name)}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json()).data||mt;console.log("Full asset data:",vr),console.log("Building:",vr.custom_building),console.log("Room Number:",vr.custom_room_number);const Oe=new URLSearchParams;vr.name&&Oe.append("asset",vr.name),vr.asset_name&&Oe.append("asset_name",vr.asset_name),vr.custom_asset_type&&Oe.append("asset_type",vr.custom_asset_type),vr.custom_manufacturer&&Oe.append("manufacturer",vr.custom_manufacturer),vr.custom_serial_number&&Oe.append("serial_number",vr.custom_serial_number),vr.department&&Oe.append("department",vr.department),vr.custom_site_contractor&&Oe.append("site_contractor",vr.custom_site_contractor),vr.custom_subcontractor&&Oe.append("subcontractor",vr.custom_subcontractor),vr.company&&Oe.append("company",vr.company),vr.custom_service_agreement&&Oe.append("custom_service_agreement",vr.custom_service_agreement),vr.custom_service_coverage&&Oe.append("custom_service_coverage",vr.custom_service_coverage),vr.custom_site&&Oe.append("site_name",vr.custom_site),vr.supplier&&Oe.append("supplier",vr.supplier),vr.custom_building&&Oe.append("building",vr.custom_building),vr.custom_room_number&&Oe.append("room_no",vr.custom_room_number),vr.location&&Oe.append("location",vr.location),r(`/work-orders/new?${Oe.toString()}`)}catch(ft){console.error("Error fetching asset details:",ft);const dr=new URLSearchParams;mt.name&&dr.append("asset",mt.name),r(`/work-orders/new?${dr.toString()}`)}}),Rs=mt=>{r(`/work-orders?asset=${encodeURIComponent(mt)}`)},Un=mt=>J(null,null,function*(){try{yield ve(mt),h(null),_e(),alert("Asset deleted successfully!")}catch(ft){alert(`Failed to delete asset: ${ft instanceof Error?ft.message:"Unknown error"}`)}}),Tr=mt=>J(null,null,function*(){ee(!0);try{let ft=[];if(mt==="selected"?ft=yt.filter(Sr=>S.has(Sr.name)):mt==="all_on_page"?ft=yt:ft=yield Mr(),ft.length===0){alert("No assets to print.");return}const dr=ft.map(Sr=>Sr.name),vr=100,Oe=[];for(let Sr=0;Sr<dr.length;Sr+=vr){const ji=dr.slice(Sr,Sr+vr),js=yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({doctype:"File",filters:[["File","attached_to_doctype","=","Asset"],["File","attached_to_field","=","custom_attach_image"],["File","attached_to_name","in",ji]],fields:["attached_to_name","file_url"],limit_page_length:vr})})).json(),fo=(js==null?void 0:js.message)||[];Oe.push(...fo)}const ar={};Oe.forEach(Sr=>{Sr.attached_to_name&&Sr.file_url&&(ar[Sr.attached_to_name]=Sr.file_url)});const Bn=ft.map(Sr=>({name:Sr.name,asset_name:Sr.asset_name||Sr.name,qrUrl:ar[Sr.name]||null,technical_department:Sr.custom_technical_department||""})).map(Sr=>`
|
||
<div class="qr-cell">
|
||
<div class="qr-image-wrapper">
|
||
${Sr.qrUrl?`<img src="${Sr.qrUrl}" alt="QR" class="qr-img" />`:'<div class="qr-placeholder">No QR</div>'}
|
||
</div>
|
||
<div class="qr-info">
|
||
<div class="qr-asset-name" title="${Sr.asset_name}">${Sr.asset_name}</div>
|
||
<div class="qr-asset-id">${Sr.name}</div>
|
||
${Sr.technical_department?`<div class="qr-dept">${Sr.technical_department}</div>`:""}
|
||
</div>
|
||
</div>
|
||
`).join(""),Ba=window.open("","_blank");if(!Ba){alert("Pop-up blocked. Please allow pop-ups for this site.");return}Ba.document.write(`
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<title>QR Codes - ${ft.length} Assets</title>
|
||
<style>
|
||
@page {
|
||
size: A4;
|
||
margin: 4mm;
|
||
}
|
||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||
body {
|
||
font-family: Arial, sans-serif;
|
||
background: white;
|
||
}
|
||
.no-print {
|
||
padding: 12px 20px;
|
||
background: #6d28d9;
|
||
color: white;
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 12px;
|
||
}
|
||
.no-print button {
|
||
background: white;
|
||
color: #6d28d9;
|
||
border: none;
|
||
padding: 6px 16px;
|
||
border-radius: 4px;
|
||
font-weight: 600;
|
||
cursor: pointer;
|
||
font-size: 13px;
|
||
}
|
||
.no-print span { font-size: 14px; }
|
||
@media print {
|
||
.no-print { display: none !important; }
|
||
}
|
||
|
||
/* Grid: 2 columns, 5 rows per page = 10 per page */
|
||
.qr-grid {
|
||
display: grid;
|
||
grid-template-columns: 1fr 1fr;
|
||
gap: 1mm;
|
||
padding: 0;
|
||
}
|
||
.qr-cell {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
border: 1px solid #d1d5db;
|
||
border-radius: 6px;
|
||
padding: 2mm 3mm 2mm;
|
||
height: 54mm;
|
||
page-break-inside: avoid;
|
||
overflow: hidden;
|
||
}
|
||
.qr-image-wrapper {
|
||
flex: 1;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
width: 100%;
|
||
}
|
||
.qr-img {
|
||
max-width: 100%;
|
||
max-height: 38mm;
|
||
object-fit: contain;
|
||
}
|
||
.qr-placeholder {
|
||
width: 32mm;
|
||
height: 32mm;
|
||
background: #f3f4f6;
|
||
border: 2px dashed #d1d5db;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
color: #9ca3af;
|
||
font-size: 10px;
|
||
border-radius: 4px;
|
||
}
|
||
.qr-info {
|
||
text-align: center;
|
||
margin-top: 1mm;
|
||
width: 100%;
|
||
line-height: 1.3;
|
||
}
|
||
.qr-asset-name {
|
||
font-size: 8pt;
|
||
font-weight: 600;
|
||
color: #111827;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
max-width: 100%;
|
||
}
|
||
.qr-asset-id {
|
||
font-size: 7pt;
|
||
color: #6b7280;
|
||
margin-top: 1mm;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
}
|
||
.qr-dept {
|
||
font-size: 7pt;
|
||
color: #2563eb;
|
||
margin-top: 0.5mm;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
font-weight: 500;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="no-print">
|
||
<span>📄 ${ft.length} QR code(s)</span>
|
||
<button onclick="window.print()">🖨️ Print / Save PDF</button>
|
||
<button onclick="window.close()" style="background:#e5e7eb;color:#374151;margin-left:4px;">✕ Close</button>
|
||
</div>
|
||
<div class="qr-grid">
|
||
${Bn}
|
||
</div>
|
||
</body>
|
||
</html>
|
||
`),Ba.document.close(),G(!1)}catch(ft){console.error("QR print error:",ft),alert(`Failed to print QR codes: ${ft instanceof Error?ft.message:"Unknown error"}`)}finally{ee(!1)}}),Ir=mt=>{const ft=JSON.stringify(mt,null,2),dr=new Blob([ft],{type:"application/json"}),vr=URL.createObjectURL(dr),Oe=document.createElement("a");Oe.href=vr,Oe.download=`asset_${mt.name}.json`,Oe.click(),URL.revokeObjectURL(vr)},ws=mt=>J(null,null,function*(){var ar;const ft=`/files/${mt}-qr.png`;let dr=null;try{if((yield fetch(ft,{method:"HEAD",credentials:"include"})).ok)dr=ft;else{const Ba=yield(yield fetch(`/api/resource/File?filters=[["File","attached_to_name","=","${mt}"]]`,{credentials:"include"})).json();((ar=Ba==null?void 0:Ba.data)==null?void 0:ar.length)>0&&(dr=Ba.data[0].file_url)}}catch(us){console.error("Error fetching QR code:",us)}const vr=yt.find(us=>us.name===mt),Oe=window.open("","_blank");Oe&&(Oe.document.write(`
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<title>Print QR Code - ${mt}</title>
|
||
<style>
|
||
@page { margin: 0.5in; size: auto; }
|
||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||
body {
|
||
font-family: Arial, sans-serif;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
min-height: 100vh;
|
||
}
|
||
.qr-container {
|
||
text-align: center;
|
||
border: 2px solid #333;
|
||
padding: 20px;
|
||
border-radius: 8px;
|
||
background: white;
|
||
max-width: 400px;
|
||
}
|
||
.qr-image { width: 300px; height: 300px; margin: 15px auto; display: block; }
|
||
h1 { font-size: 20px; margin-bottom: 10px; }
|
||
.asset-info { margin: 10px 0; font-size: 14px; line-height: 1.5; }
|
||
.no-qr { width: 300px; height: 300px; margin: 15px auto; display: flex; align-items: center; justify-content: center; background: #f5f5f5; border: 2px dashed #ccc; border-radius: 8px; color: #999; font-size: 14px; }
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="qr-container">
|
||
<h1>Asset QR Code</h1>
|
||
<div class="asset-info">
|
||
<strong>Asset ID:</strong> ${mt}<br/>
|
||
<strong>Asset Name:</strong> ${(vr==null?void 0:vr.asset_name)||"N/A"}
|
||
</div>
|
||
${dr?`<img src="${dr}" alt="QR Code" class="qr-image" onload="window.print();" />`:'<div class="no-qr">No QR Code Available</div><script>setTimeout(() => window.print(), 500);<\/script>'}
|
||
</div>
|
||
</body>
|
||
</html>
|
||
`),Oe.document.close())}),Ca=()=>{ie(""),he(""),xe(""),nr("creation desc"),be(""),ye(""),M(""),pe(""),Fe(""),Re(""),Et(""),Ie(""),Qe(""),Ct(""),Tt(""),Ye(""),c(""),kt.current&&clearTimeout(kt.current),Yt.current&&clearTimeout(Yt.current),n.current(mt=>{const ft=new URLSearchParams(mt);return ft.delete("date_filter_by"),ft.delete("date_start"),ft.delete("date_end"),ft.delete("sort_by"),ft.delete("asset_id"),ft.delete("company"),ft.delete("manufacturer"),ft.delete("supplier"),ft.delete("location"),ft.delete("department"),ft.delete("modality"),ft.delete("device_status"),ft.delete("asset_name"),ft.delete("serial_number"),ft.delete("search"),ft.set("page","1"),ft})},pn=Ae||ge||K||Z||we||le||ze||De||jt||$e||at||l;return U&&!v?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("assets.loadingPermissions")})]})}):re?t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:"⚠️ Permission Error"}),t.jsxs("div",{className:"text-red-700 dark:text-red-400 space-y-3",children:[t.jsx("p",{children:t.jsx("strong",{children:"Unable to load user permissions."})}),t.jsx("p",{children:re}),t.jsx("button",{onClick:()=>window.location.reload(),className:"mt-2 bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded",children:"Retry"})]})]})}):Xe&&!v?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("listPages.loading")})]})}):oe?t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-6",children:[t.jsxs("h2",{className:"text-xl font-bold text-yellow-800 dark:text-yellow-300 mb-4",children:["⚠️ ",e("assets.apiNotAvailable")]}),t.jsxs("div",{className:"text-yellow-700 dark:text-yellow-400 space-y-3",children:[t.jsx("p",{children:t.jsx("strong",{children:e("assets.apiNotDeployed")})}),t.jsx("button",{onClick:()=>r("/assets/new"),className:"mt-2 bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:e("assets.tryCreatingNew")}),t.jsx("button",{onClick:_e,className:"mt-2 ml-2 bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded",children:e("common.tryAgain")})]})]})}):t.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-3xl font-bold text-gray-800 dark:text-white",children:e("assets.title")}),t.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:[e("assets.listTotal")," ",Me," asset",Me!==1?"s":"",S.size>0&&t.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",S.size," ",e("common.selected")]}),Xe&&v&&t.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400",children:[t.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-blue-500"}),e("common.updating")]})]})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("button",{onClick:()=>G(!0),className:"bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",disabled:Me===0,children:[t.jsx(Hu,{}),t.jsx("span",{className:"font-medium",children:"Print QRs"}),S.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:S.size})]}),t.jsxs("button",{onClick:()=>O(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",disabled:Me===0,children:[t.jsx(Sa,{}),t.jsx("span",{className:"font-medium",children:e("listPages.export")}),S.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:S.size})]}),X&&t.jsxs("button",{onClick:Br,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow-lg transition-all hover:shadow-xl",children:[t.jsx(Rr,{}),t.jsx("span",{className:"font-medium",children:e("assets.addAsset")})]})]})]}),t.jsxs("div",{className:"isolate bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-4",children:[t.jsx("div",{className:"bg-gradient-to-r from-blue-500 to-blue-600 dark:from-blue-600 dark:to-blue-700 px-4 py-3 rounded-t-lg",children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx("button",{onClick:()=>He(!dt),className:"text-white hover:bg-white/20 p-2 rounded-lg transition-all",children:dt?t.jsx(Ja,{size:14}):t.jsx(Fr,{size:14})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ds,{className:"text-white",size:16}),t.jsx("h3",{className:"text-white font-semibold text-sm",children:e("listPages.filters")})]}),it>0&&t.jsx("span",{className:"bg-white text-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:it})]}),pn&&t.jsx("div",{className:"flex-1 overflow-x-auto scrollbar-hide mx-2",children:t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[Ae&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("filters.filterBy"),":"]})," ",e(Q==="creation"?"filters.createdDate":"filters.latestModifiedDate")," ",me&&` ${me}`," ",de&&` - ${de}`,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),ie(""),he(""),xe("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),ge&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-blue-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("commonFields.assetId"),":"]})," ",ge,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),be("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),K&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-green-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("assets.selectHospital"),":"]})," ",K,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),ye("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),$e&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-cyan-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("commonFields.assetName"),":"]})," ",$e,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),Qe(""),Tt("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),at&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-lime-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("commonFields.serialNumber"),":"]})," ",at,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),Ct(""),Ye("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),jt&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-orange-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("assets.table.status"),":"]})," ",jt,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),Ie("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),le&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-purple-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("filters.location"),":"]})," ",le,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),Fe("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),ze&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-yellow-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("filters.dept"),":"]})," ",ze,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),Re("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),De&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-pink-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("filters.modality"),":"]})," ",De,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),Et("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),Z&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("filters.mfr"),":"]})," ",Z,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),M("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),we&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-teal-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("filters.supplier"),":"]})," ",we,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),pe("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]})]})}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[it>0&&t.jsxs("button",{onClick:()=>Mt(!0),className:"px-3 py-1.5 bg-white text-blue-600 hover:bg-blue-50 rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[t.jsx(ta,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),pn&&t.jsxs("button",{onClick:Ca,className:"px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[t.jsx(ht,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:"Clear"})]})]})]})}),dt&&t.jsxs("div",{className:"p-4",children:[Ve.length>0&&t.jsxs("div",{className:"mb-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[t.jsx(a0,{className:"text-yellow-500",size:12}),"Saved Filters"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:Ve.map(mt=>t.jsxs("div",{className:"group relative inline-flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-purple-100 to-blue-100 dark:from-purple-900/30 dark:to-blue-900/30 border border-purple-200 dark:border-purple-700 rounded-lg hover:shadow-md transition-all",children:[t.jsx("button",{onClick:()=>nt(mt),className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:mt.name}),t.jsx("button",{onClick:()=>ct(mt.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:t.jsx(wr,{size:10})})]},mt.id))})]}),t.jsx("div",{className:"space-y-5",children:t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 p-3 rounded-lg",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-3",children:[t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.sortBy")}),t.jsxs("select",{value:er,onChange:mt=>nr(mt.target.value),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"creation desc",children:e("filters.sortCreationNewest")}),t.jsx("option",{value:"creation asc",children:e("filters.sortCreationOldest")}),t.jsx("option",{value:"modified desc",children:e("filters.sortModifiedNewest")}),t.jsx("option",{value:"modified asc",children:e("filters.sortModifiedOldest")}),t.jsx("option",{value:"asset_name asc",children:e("filters.sortAssetNameAsc")}),t.jsx("option",{value:"asset_name desc",children:e("filters.sortAssetNameDesc")}),t.jsx("option",{value:"name asc",children:e("filters.sortNameAsc")}),t.jsx("option",{value:"name desc",children:e("filters.sortNameDesc")})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.filterBy")}),t.jsxs("select",{value:Q,onChange:mt=>{const ft=mt.target.value;ie(ft)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("filters.filterBy")}),t.jsx("option",{value:"creation",children:e("filters.createdDate")}),t.jsx("option",{value:"modified",children:e("filters.latestModifiedDate")})]})]}),Q&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.startDate")}),t.jsx("input",{type:"date",value:me,onChange:mt=>{const ft=mt.target.value;he(ft),de&&ft>de&&xe(ft)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.endDate")}),t.jsx("input",{type:"date",value:de,onChange:mt=>xe(mt.target.value),min:me||void 0,className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]}),t.jsxs("div",{className:"relative z-[60]",children:[t.jsx(Je,{label:e("commonFields.assetId"),doctype:"Asset",value:ge,onChange:mt=>be(mt),placeholder:e("assets.selectAssetId"),disabled:!1,compact:!0,filters:{custom_delete_status:["!=","Deleted"]}}),ge&&t.jsx("button",{onClick:()=>be(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("commonFields.assetName")}),t.jsx("input",{type:"text",value:zt,onChange:mt=>Pe(mt.target.value),onKeyDown:mt=>ut(mt,"assetName"),placeholder:e("common.typeToSearch"),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),zt&&zt!==$e&&t.jsx("span",{className:"absolute right-2 top-6 text-[9px] text-blue-500 animate-pulse",children:e("common.typing")}),$e&&t.jsx("button",{onClick:()=>{Qe(""),Tt("")},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("commonFields.serialNumber")}),t.jsx("input",{type:"text",value:Gt,onChange:mt=>rt(mt.target.value),onKeyDown:mt=>ut(mt,"serialNumber"),placeholder:e("common.typeToSearch"),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),Gt&&Gt!==at&&t.jsx("span",{className:"absolute right-2 top-6 text-[9px] text-blue-500 animate-pulse",children:e("common.typing")}),at&&t.jsx("button",{onClick:()=>{Ct(""),Ye("")},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[59]",children:[t.jsx(Je,{label:e("assets.selectHospital"),doctype:"Company",value:K,onChange:mt=>ye(mt),placeholder:e("linkField.selectLabel",{label:e("assets.selectHospital")}),disabled:!1,compact:!0,filters:{domain:"Healthcare"}}),K&&t.jsx("button",{onClick:()=>ye(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("assets.deviceStatus")}),t.jsxs("select",{value:jt,onChange:mt=>Ie(mt.target.value),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("filters.allStatuses")}),t.jsxs("option",{value:"Up",children:["✓ ",e("assets.status.up")]}),t.jsxs("option",{value:"Down",children:["⚠ ",e("assets.status.down")]})]}),jt&&t.jsx("button",{onClick:()=>Ie(""),className:"absolute right-8 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[58]",children:[t.jsx(Je,{label:e("filters.location"),doctype:"Location",value:le,onChange:mt=>Fe(mt),placeholder:e("linkField.selectLabel",{label:e("filters.location")}),disabled:!1,compact:!0}),le&&t.jsx("button",{onClick:()=>Fe(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[57]",children:[t.jsx(Je,{label:e("filters.dept"),doctype:"Department",value:ze,onChange:mt=>Re(mt),placeholder:e("linkField.selectLabel",{label:e("filters.dept")}),disabled:!1,compact:!0}),ze&&t.jsx("button",{onClick:()=>Re(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[56]",children:[t.jsx(Je,{label:e("filters.modality"),doctype:"Modality",value:De,onChange:mt=>Et(mt),placeholder:e("linkField.selectLabel",{label:e("filters.modality")}),disabled:!1,compact:!0}),De&&t.jsx("button",{onClick:()=>Et(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[55]",children:[t.jsx(Je,{label:e("filters.mfr"),doctype:"Manufacturer",value:Z,onChange:mt=>M(mt),placeholder:e("linkField.selectLabel",{label:e("filters.mfr")}),disabled:!1,compact:!0}),Z&&t.jsx("button",{onClick:()=>M(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[54]",children:[t.jsx(Je,{label:e("filters.supplier"),doctype:"Supplier",value:we,onChange:mt=>pe(mt),placeholder:e("linkField.selectLabel",{label:e("filters.supplier")}),disabled:!1,compact:!0}),we&&t.jsx("button",{onClick:()=>pe(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]})]})})})]})]}),st&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 animate-scale-in",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:e("common.saveFilterPreset")}),t.jsx("input",{type:"text",value:Ot,onChange:mt=>Pt(mt.target.value),onKeyDown:mt=>{mt.key==="Enter"&&(mt.preventDefault(),et())},placeholder:e("common.enterFilterNameExample"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white mb-4",autoFocus:!0}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:()=>{Mt(!1),Pt("")},className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",children:e("common.cancel")}),t.jsxs("button",{onClick:et,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors flex items-center gap-2",children:[t.jsx(ta,{size:12}),e("common.saveFilter")]})]})]})}),t.jsx(Lse,{isOpen:z,onClose:()=>G(!1),selectedCount:S.size,totalCount:Me,pageCount:yt.length,onPrint:Tr,isPrinting:ae}),t.jsx(bi,{isOpen:C,onClose:()=>O(!1),doctype:"Asset",selectedCount:S.size,pageCount:yt.length,totalCount:Me,pageData:yt,selectedRows:S,rowKey:"name",onFetchAll:Mr,fileNamePrefix:"assets",defaultColumns:["name","asset_name","custom_serial_number","company","location","custom_device_status","modified"],hiddenColumns:["docstatus","idx","amended_from","naming_series"]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden relative",children:[Xe&&v&&t.jsx("div",{className:"absolute inset-0 bg-white/60 dark:bg-gray-800/60 flex items-center justify-center z-10 backdrop-blur-[1px]",children:t.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-gray-700 px-4 py-2 rounded-lg shadow-lg",children:[t.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-blue-500"}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:e("common.filtering")})]})}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left",children:t.jsx("button",{onClick:pt,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:e(Wt?"common.deselectAllTitle":"common.selectAllTitle"),children:Wt?t.jsx(Ra,{className:"text-blue-600 dark:text-blue-400",size:18}):rr?t.jsxs("div",{className:"relative",children:[t.jsx(Ur,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Ur,{size:18})})}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("assets.table.assetName")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("assets.table.serialNo")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("assets.table.company")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("assets.table.location")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("assets.table.status")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("assets.table.updatedOn")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("assets.table.actions")})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:yt.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:8,className:"px-6 py-12 text-center text-gray-500 dark:text-gray-400",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx(za,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("assets.noAssetsFound")}),pn?t.jsx("button",{onClick:Ca,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:e("listPages.clearFilters")}):X?t.jsx("button",{onClick:Br,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:e("assets.createFirstAsset")}):null]})})}):yt.map(mt=>{var ft;return t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${S.has(mt.name)?"bg-blue-50 dark:bg-blue-900/20":$t(mt.custom_delete_status)}`,title:mt.custom_delete_status?`Delete Status: ${mt.custom_delete_status}`:void 0,onClick:()=>Yr(mt.name),children:[t.jsx("td",{className:"px-4 py-4",onClick:dr=>dr.stopPropagation(),children:t.jsx("button",{onClick:()=>Xt(mt.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:S.has(mt.name)?t.jsx(Ra,{className:"text-blue-600 dark:text-blue-400",size:18}):t.jsx(Ur,{size:18})})}),t.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:mt.asset_name}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:mt.name})]}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:mt.custom_serial_number||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:mt.company||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:mt.location||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:mt.custom_device_status||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:Ut(mt.modified)}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:t.jsxs("div",{className:"flex items-center gap-1",onClick:dr=>dr.stopPropagation(),children:[t.jsx("button",{onClick:()=>Yr(mt.name),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded transition-colors",title:e("assets.viewDetails"),children:t.jsx(Ps,{})}),t.jsx("button",{onClick:()=>ma(mt.name),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:e("assets.editAsset"),children:t.jsx(qr,{})}),t.jsx("button",{onClick:()=>ps(mt.name),className:"text-purple-600 dark:text-purple-400 hover:text-purple-900 dark:hover:text-purple-300 p-2 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded transition-colors",title:e("assets.duplicateAsset"),children:t.jsx(Vo,{})}),t.jsx("button",{onClick:()=>hn(mt),className:"text-orange-600 dark:text-orange-400 hover:text-orange-900 dark:hover:text-orange-300 p-2 hover:bg-orange-50 dark:hover:bg-orange-900/30 rounded transition-colors",title:e("assets.createWorkOrder"),children:t.jsx(vm,{})}),t.jsx("button",{onClick:()=>Rs(mt.name),className:"text-cyan-600 dark:text-cyan-400 hover:text-cyan-900 dark:hover:text-cyan-300 p-2 hover:bg-cyan-50 dark:hover:bg-cyan-900/30 rounded transition-colors",title:e("assets.viewLinkedWOs"),children:t.jsx(Ju,{})}),t.jsx("div",{onClick:dr=>dr.stopPropagation(),children:t.jsx(n0,{doctype:"Asset",docname:mt.name,currentDeleteStatus:(ft=mt.custom_delete_status)!=null?ft:null,userRoles:ne,isSystemManager:Y,triggerMode:!0,redirectOnDelete:"/assets",onStatusChange:()=>_e()})}),t.jsxs("div",{className:"relative",ref:f===mt.name?b:null,children:[t.jsx("button",{onClick:()=>y(f===mt.name?null:mt.name),className:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 p-2 hover:bg-gray-50 dark:hover:bg-gray-700 rounded transition-colors",title:e("assets.moreActions"),children:t.jsx(jx,{})}),f===mt.name&&t.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 z-10",children:[t.jsxs("button",{onClick:()=>{hn(mt),y(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2 rounded-t-lg",children:[t.jsx(vm,{className:"text-orange-500"}),e("assets.createWorkOrder")]}),t.jsxs("button",{onClick:()=>{Rs(mt.name),y(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(Ju,{className:"text-cyan-500"}),e("assets.viewLinkedWOs")]}),t.jsxs("button",{onClick:()=>{Ir(mt),y(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(qc,{className:"text-blue-500"}),e("assets.exportAsJson")]}),t.jsxs("button",{onClick:()=>{ws(mt.name),y(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2 rounded-b-lg",children:[t.jsx(yl,{className:"text-purple-500"}),e("assets.printAsset")]})]})]})]})})]},mt.name)})})]})}),t.jsx(_l,{currentPage:i+1,totalCount:Me,pageSize:w,hasMore:Ke,itemLabel:e("pagination.assets"),onPageChange:mt=>o(Math.max(0,mt-1))})]}),u&&t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx("div",{className:"flex-shrink-0 w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:t.jsx(wr,{className:"text-red-600 dark:text-red-400 text-xl"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:e("assets.deleteConfirmTitle")}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:e("assets.deleteConfirmMessage")}),t.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-md p-3 mb-4",children:t.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[t.jsxs("strong",{children:[e("commonFields.assetId"),":"]})," ",u]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>h(null),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-lg transition-colors",disabled:Se,children:e("common.cancel")}),t.jsx("button",{onClick:()=>Un(u),className:"px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50",disabled:Se,children:Se?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),e("common.deleting")]}):t.jsxs(t.Fragment,{children:[t.jsx(wr,{}),e("assets.deleteConfirmTitle")]})})]})]})]})})}),t.jsx("style",{children:`
|
||
@keyframes scale-in {
|
||
from {
|
||
transform: scale(0.95);
|
||
opacity: 0;
|
||
}
|
||
to {
|
||
transform: scale(1);
|
||
opacity: 1;
|
||
}
|
||
}
|
||
.animate-scale-in {
|
||
animation: scale-in 0.2s ease-out;
|
||
}
|
||
|
||
.scrollbar-hide {
|
||
-ms-overflow-style: none;
|
||
scrollbar-width: none;
|
||
}
|
||
.scrollbar-hide::-webkit-scrollbar {
|
||
display: none;
|
||
}
|
||
`})]})},Ise=e=>{const[r,a]=p.useState([]),[s,n]=p.useState(new Set),[i,o]=p.useState(!0),[l,c]=p.useState(null);return p.useEffect(()=>{J(null,null,function*(){try{o(!0);const f=yield At.apiCall(`/api/resource/DocType/${e}`),b=(f.data||f).fields||[],w=new Set;b.forEach(v=>{v.allow_on_submit===1&&w.add(v.fieldname)}),a(b),n(w),c(null)}catch(f){console.error(`[DocTypeMeta] Error fetching DocType meta for ${e}:`,f),c(f instanceof Error?f.message:"Unknown error"),a([]),n(new Set)}finally{o(!1)}})},[e]),{fields:r,allowOnSubmitFields:s,isAllowedOnSubmit:h=>s.has(h),loading:i,error:l}};function xk(e,r){if(!e||(e=e.trim(),!e))return!1;if(!e.startsWith("eval:"))return!!r[e];const a=e.substring(5).trim();try{return new Function("doc",`
|
||
try {
|
||
return Boolean(${a});
|
||
} catch (e) {
|
||
console.warn('Expression evaluation error:', e);
|
||
return false;
|
||
}
|
||
`)(r)}catch(s){return console.warn(`Failed to evaluate expression: ${e}`,s),!1}}function zse(e){if(!e)return null;const r=e.split(".");return r.length!==2?null:{linkField:r[0],targetField:r[1]}}const yk={};function gL(e,r){const[a,s]=p.useState([]),[n,i]=p.useState(!0),[o,l]=p.useState(null);p.useEffect(()=>{if(!e){i(!1);return}if(yk[e]){s(yk[e]),i(!1);return}J(null,null,function*(){var N;i(!0);try{const C=yield At.apiCall(`/api/method/frappe.client.get_doc?doctype=DocType&name=${encodeURIComponent(e)}`,{credentials:"include"});if((N=C==null?void 0:C.message)!=null&&N.fields){const O=C.message.fields.map(T=>({fieldname:T.fieldname,label:T.label,fieldtype:T.fieldtype,options:T.options,reqd:T.reqd,hidden:T.hidden,read_only:T.read_only,depends_on:T.depends_on,mandatory_depends_on:T.mandatory_depends_on,read_only_depends_on:T.read_only_depends_on,fetch_from:T.fetch_from,fetch_if_empty:T.fetch_if_empty,default:T.default,description:T.description,in_list_view:T.in_list_view,permlevel:T.permlevel,allow_on_submit:T.allow_on_submit}));yk[e]=O,s(O)}}catch(C){console.warn(`Could not fetch DocType meta for ${e}:`,C.message),l(C.message)}finally{i(!1)}})},[e]);const c=p.useMemo(()=>{const S={};return a.forEach(N=>{S[N.fieldname]=N}),S},[a]),u=p.useCallback(S=>{const N=c[S];if(!N)return{isVisible:!0,isReadOnly:!1,isMandatory:!1};let C=!(N.hidden===1||N.hidden===!0);N.depends_on&&C&&(C=xk(N.depends_on,r));let O=N.read_only===1||N.read_only===!0;N.read_only_depends_on&&(O=O||xk(N.read_only_depends_on,r));let T=N.reqd===1||N.reqd===!0;return N.mandatory_depends_on&&(T=T||xk(N.mandatory_depends_on,r)),{isVisible:C,isReadOnly:O,isMandatory:T}},[c,r]),h=p.useCallback(S=>u(S).isVisible,[u]),f=p.useCallback(S=>{const N=u(S);return N.isVisible&&N.isMandatory},[u]),y=p.useCallback(S=>u(S).isReadOnly,[u]),b=p.useCallback(S=>{const N=c[S];return(N==null?void 0:N.label)||S},[c]),w=p.useCallback(S=>{const N=c[S];return N!=null&&N.options?N.fieldtype==="Select"?N.options.split(`
|
||
`).filter(C=>C.trim()!==""):[]:[]},[c]),v=p.useCallback((S,N)=>{const C=c[S];if(!(C!=null&&C.fetch_from)||!N)return;const O=zse(C.fetch_from);if(O)return N[O.targetField]},[c]),k=p.useCallback(()=>{const S={};return a.forEach(N=>{const C=u(N.fieldname);if(C.isVisible&&C.isMandatory){const O=r[N.fieldname];(O==null||O==="")&&(S[N.fieldname]=`${N.label||N.fieldname} is required`)}}),{valid:Object.keys(S).length===0,errors:S}},[a,r,u]);return{loading:n,error:o,fields:a,getFieldState:u,shouldShowField:h,isMandatory:f,isReadOnly:y,getFieldLabel:b,getFieldOptions:w,getFetchFromValue:v,validateMandatory:k}}let cp=null,dp=null;const $se=(e,r)=>{cp=e,r&&(dp=r),console.log("[Workflow] User set manually:",e,"Roles:",r)},Use=()=>{cp=null,dp=null},dw=()=>J(null,null,function*(){try{if(cp&&dp)return console.log("[Workflow] Using cached user:",cp,"roles:",dp),{user:cp,roles:dp};const e=yield At.getUserDetails();if(e&&e.email){const r=e.email||e.user_id,a=e.roles||[];return cp=r,dp=a,console.log("[Workflow] User from getUserDetails():",r),console.log("[Workflow] Roles from getUserDetails():",a),{user:r,roles:a}}return console.warn("[Workflow] getUserDetails() returned no user"),{user:"",roles:[]}}catch(e){return console.error("[Workflow] Error getting user details:",e),{user:"",roles:[]}}}),Bse=()=>J(null,null,function*(){const{user:e}=yield dw();return e}),uw=()=>J(null,null,function*(){const{roles:e}=yield dw();return e}),Wse=["System Manager","System User","Manager","Administrator","Admin"],Lx=e=>String(e!=null?e:"").trim().toLowerCase(),fL=new Set(Wse.map(e=>Lx(e))),xL=e=>e.some(r=>Lx(r)==="system manager"),Hse=e=>e.some(r=>fL.has(Lx(r))),qse=()=>J(null,null,function*(){try{const e=yield uw(),r=xL(e);return console.log("[Workflow] Is System Manager:",r,"Roles:",e),r}catch(e){return console.error("[Workflow] Error checking System Manager role:",e),!1}}),Vse=e=>Lx(e)==="administrator",Fx=()=>J(null,null,function*(){try{const{user:e,roles:r}=yield dw();if(Vse(e))return console.log("[Workflow] Full access: Administrator user"),!0;if(xL(r))return console.log("[Workflow] Full access: System Manager role"),!0;if(Hse(r)){const a=r.filter(s=>fL.has(Lx(s)));return console.log("[Workflow] Full-access role(s):",a),!0}return!1}catch(e){return console.error("[Workflow] Error checking full-access roles:",e),!1}}),TS=(e,r)=>{if(!e||e.trim()==="")return!0;try{console.log("[Workflow] Evaluating condition:",e),console.log("[Workflow] Document data for condition:",{asset_type:r.asset_type,site_name:r.site_name,need_procurement:r.need_procurement,custom_assign_to_contractor:r.custom_assign_to_contractor,docstatus:r.docstatus});let a=e;a=a.replace(/\band\b/g,"&&"),a=a.replace(/\bor\b/g,"||"),a=a.replace(/\bnot\s+/g,"!"),a=a.replace(/\bTrue\b/g,"true"),a=a.replace(/\bFalse\b/g,"false"),a=a.replace(/\bNone\b/g,"null"),a=a.replace(/doc\.(\w+)/g,(n,i)=>{const o=r[i];return o==null||o===""?"false":typeof o=="string"?`"${o.replace(/"/g,'\\"')}"`:typeof o=="boolean"?o?"true":"false":typeof o=="number"?String(o):JSON.stringify(o)}),a=a.replace(/== 1/g,"=== 1"),a=a.replace(/== 0/g,"=== 0"),a=a.replace(/!= 1/g,"!== 1"),a=a.replace(/!= 0/g,"!== 0"),console.log("[Workflow] Transformed condition:",a);const s=new Function(`return (${a})`)();return console.log("[Workflow] Condition result:",s),!!s}catch(a){return console.error("[Workflow] Error evaluating condition:",e,a),!1}},mw=e=>J(null,null,function*(){var r,a,s,n;try{console.log("[Workflow] Getting workflow info for doctype:",e);const i=yield At.apiCall(`/api/resource/Workflow?filters=[["document_type","=","${e}"],["is_active","=",1]]&fields=["name","workflow_state_field"]&limit=1`);if(console.log("[Workflow] Workflow response:",i),!(i!=null&&i.data)||i.data.length===0)return console.warn("[Workflow] No active workflow found for doctype:",e),null;const o=i.data[0].name;console.log("[Workflow] Found workflow:",o);const l=yield At.apiCall(`/api/resource/Workflow/${encodeURIComponent(o)}`);return console.log("[Workflow] Full workflow data:",l==null?void 0:l.data),console.log("[Workflow] Transitions count:",(a=(r=l==null?void 0:l.data)==null?void 0:r.transitions)==null?void 0:a.length),console.log("[Workflow] States count:",(n=(s=l==null?void 0:l.data)==null?void 0:s.states)==null?void 0:n.length),{workflow_name:l.data.name,workflow_state:"",workflow_state_field:l.data.workflow_state_field,transitions:l.data.transitions||[],states:l.data.states||[]}}catch(i){return console.error("[Workflow] Error fetching workflow info:",i),null}}),yL=(e,r,a)=>J(null,null,function*(){try{console.log("[Workflow] Getting all transitions for state:",r);const s=yield mw(e);if(!s)return console.warn("[Workflow] No workflow info found"),[];console.log("[Workflow] All transitions from workflow:",s.transitions.length);let n=s.transitions.filter(l=>l.state===r);console.log("[Workflow] Transitions for state",r,":",n.length),a&&(n=n.filter(l=>{const c=TS(l.condition,a);return console.log(`[Workflow] Transition "${l.action}" (allowed: ${l.allowed}) condition "${l.condition||"none"}" = ${c}`),c}),console.log("[Workflow] Transitions after condition evaluation:",n.length));const i=new Set,o=[];for(const l of n){const c=`${l.action}::${l.next_state}`;i.has(c)?console.log(`[Workflow] Skipping duplicate: ${l.action} → ${l.next_state} (allowed: ${l.allowed})`):(i.add(c),o.push(l))}return console.log("[Workflow] Unique transitions after deduplication:",o.length),o}catch(s){return console.error("[Workflow] Error fetching all transitions:",s),[]}}),Gse=(e,r,a,s)=>J(null,null,function*(){var n;try{console.log("[Workflow] getWorkflowTransitions called with:",{doctype:e,docname:r,currentState:a});const i=yield Fx(),o=yield uw();if(console.log("[Workflow] User has full workflow access:",i),console.log("[Workflow] User roles:",o),i&&a){console.log("[Workflow] Full-access user: all transitions for state:",a);const u=yield yL(e,a,s);return console.log("[Workflow] Final transitions for full-access user:",u.map(h=>`${h.action} → ${h.next_state}`)),u}console.log("[Workflow] Standard user, using Frappe API");const l=yield At.apiCall("/api/method/frappe.model.workflow.get_transitions",{method:"POST",body:JSON.stringify({doc:JSON.stringify({doctype:e,name:r})})});console.log("[Workflow] Frappe transitions raw response:",l);let c=[];if(Array.isArray(l)?c=l:l!=null&&l.message&&Array.isArray(l.message)?c=l.message:l!=null&&l.data&&Array.isArray(l.data)?c=l.data:(n=l==null?void 0:l.data)!=null&&n.message&&Array.isArray(l.data.message)&&(c=l.data.message),console.log("[Workflow] Parsed transitions:",c),console.log("[Workflow] Transitions count:",c.length),c.length===0&&a&&s){console.log("[Workflow] Frappe API returned no transitions, trying local filtering");const u=yield mw(e);if(u){const h=u.transitions.filter(b=>!(b.state!==a||!o.includes(b.allowed)||!TS(b.condition,s))),f=new Set,y=[];for(const b of h){const w=`${b.action}::${b.next_state}`;f.has(w)||(f.add(w),y.push(b))}return console.log("[Workflow] Local filtered transitions:",y),y}}return c}catch(i){return console.error("[Workflow] Error fetching workflow transitions:",i),[]}}),Kse=(e,r,a,s)=>J(null,null,function*(){try{if(console.log("[Workflow] Applying action:",{doctype:e,docname:r,action:a,nextState:s}),(yield Fx())&&s)try{const o=yield At.apiCall("/api/method/frappe.model.workflow.apply_workflow",{method:"POST",body:JSON.stringify({doc:JSON.stringify({doctype:e,name:r}),action:a})});return console.log("[Workflow] Action applied successfully via workflow API"),o==null?void 0:o.message}catch(o){console.log("[Workflow] Normal workflow failed, full-access user forcing state change...");const l=yield At.apiCall(`/api/resource/${e}/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({workflow_state:s})});return console.log("[Workflow] Force update response:",l),l==null?void 0:l.data}const i=yield At.apiCall("/api/method/frappe.model.workflow.apply_workflow",{method:"POST",body:JSON.stringify({doc:JSON.stringify({doctype:e,name:r}),action:a})});return console.log("[Workflow] Action applied successfully"),i==null?void 0:i.message}catch(n){throw console.error("[Workflow] Error applying workflow action:",n),n}}),Yse=(e,r,a)=>J(null,null,function*(){try{if(yield Fx())return console.log("[Workflow] Full-access user can always edit"),!0;const s=yield mw(e);if(!s)return!0;const n=yield uw(),i=s.states.filter(l=>l.state===a);if(i.length===0)return!0;const o=i.some(l=>n.includes(l.allow_edit));return console.log("[Workflow] Can user edit:",o,"User roles:",n,"Allowed roles:",i.map(l=>l.allow_edit)),o}catch(s){return console.error("[Workflow] Error checking edit permission:",s),!1}}),bL=e=>{const r={Draft:{bg:"bg-gray-100 dark:bg-gray-700",text:"text-gray-800 dark:text-gray-200",border:"border-gray-300 dark:border-gray-600"},"Sent To Maintenance manger":{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-800 dark:text-blue-200",border:"border-blue-300 dark:border-blue-600"},"Sent to Supervisor":{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-800 dark:text-blue-200",border:"border-blue-300 dark:border-blue-600"},"Sent to Engineer":{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-800 dark:text-blue-200",border:"border-blue-300 dark:border-blue-600"},"Sent to Work Control":{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-800 dark:text-blue-200",border:"border-blue-300 dark:border-blue-600"},"Sent to technician":{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-800 dark:text-blue-200",border:"border-blue-300 dark:border-blue-600"},"Sent to General WOA":{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-800 dark:text-blue-200",border:"border-blue-300 dark:border-blue-600"},"Repair InProgress":{bg:"bg-yellow-100 dark:bg-yellow-900/30",text:"text-yellow-800 dark:text-yellow-200",border:"border-yellow-300 dark:border-yellow-600"},"Pending Purchase":{bg:"bg-orange-100 dark:bg-orange-900/30",text:"text-orange-800 dark:text-orange-200",border:"border-orange-300 dark:border-orange-600"},"Pending Approval":{bg:"bg-purple-100 dark:bg-purple-900/30",text:"text-purple-800 dark:text-purple-200",border:"border-purple-300 dark:border-purple-600"},Completed:{bg:"bg-green-100 dark:bg-green-900/30",text:"text-green-800 dark:text-green-200",border:"border-green-300 dark:border-green-600"},Approved:{bg:"bg-green-100 dark:bg-green-900/30",text:"text-green-800 dark:text-green-200",border:"border-green-300 dark:border-green-600"},Rejected:{bg:"bg-red-100 dark:bg-red-900/30",text:"text-red-800 dark:text-red-200",border:"border-red-300 dark:border-red-600"},Cancelled:{bg:"bg-red-100 dark:bg-red-900/30",text:"text-red-800 dark:text-red-200",border:"border-red-300 dark:border-red-600"},Closed:{bg:"bg-gray-100 dark:bg-gray-700",text:"text-gray-800 dark:text-gray-200",border:"border-gray-300 dark:border-gray-600"},Applied:{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-800 dark:text-blue-200",border:"border-blue-300 dark:border-blue-600"},"Sent to Procurement User":{bg:"bg-indigo-100 dark:bg-indigo-900/30",text:"text-indigo-800 dark:text-indigo-200",border:"border-indigo-300 dark:border-indigo-600"}};return r[e]||r.Draft},vL=e=>({Apply:"bg-blue-600 hover:bg-blue-700 text-white","Assign Technician":"bg-blue-600 hover:bg-blue-700 text-white","Back To Controller":"bg-gray-600 hover:bg-gray-700 text-white","Send For Repair":"bg-yellow-600 hover:bg-yellow-700 text-white","Send For Approval":"bg-purple-600 hover:bg-purple-700 text-white","Send to Supervisor":"bg-purple-600 hover:bg-purple-700 text-white","Material Request":"bg-orange-600 hover:bg-orange-700 text-white",Accept:"bg-green-600 hover:bg-green-700 text-white",Reject:"bg-red-600 hover:bg-red-700 text-white",Close:"bg-gray-600 hover:bg-gray-700 text-white","Re-Open":"bg-blue-600 hover:bg-blue-700 text-white",Cancel:"bg-red-600 hover:bg-red-700 text-white",Approve:"bg-green-600 hover:bg-green-700 text-white"})[e]||"bg-blue-600 hover:bg-blue-700 text-white",wL=e=>({Apply:"📤","Send For Repair":"🔧","Send For Approval":"📋","Material Request":"📦",Accept:"✅",Reject:"❌",Close:"🔒","Re-Open":"🔓",Cancel:"🚫",Approve:"✅"})[e]||"▶️",Iu={getWorkflowTransitions:Gse,applyWorkflowAction:Kse,getWorkflowInfo:mw,getCurrentUserRoles:uw,getCurrentUser:Bse,getCurrentUserAndRoles:dw,setCurrentUser:$se,clearCurrentUser:Use,canUserEditDocument:Yse,getWorkflowStateStyle:bL,getActionButtonStyle:vL,getActionIcon:wL,isSystemManager:qse,hasWorkflowFullAccess:Fx,getAllTransitionsForState:yL,evaluateCondition:TS},hw=({doctype:e,docname:r,workflowState:a,enabled:s=!0,docData:n})=>{const[i,o]=p.useState([]),[l,c]=p.useState(null),[u,h]=p.useState([]),[f,y]=p.useState(""),[b,w]=p.useState(!1),[v,k]=p.useState(!1),[S,N]=p.useState(!1),[C,O]=p.useState(null),[T,P]=p.useState(!0);p.useEffect(()=>{if(!s)return;J(null,null,function*(){try{const G=yield Iu.getWorkflowInfo(e);c(G)}catch(G){console.error("Error fetching workflow info:",G)}})},[e,s]),p.useEffect(()=>{if(!s)return;J(null,null,function*(){try{const[G,ae,ee,ne]=yield Promise.all([Iu.getCurrentUserRoles(),Iu.getCurrentUser(),Iu.isSystemManager(),Fx()]);h(G),y(ae),w(ee||ne),ne&&P(!0)}catch(G){console.error("Error fetching user info:",G)}})},[s]);const E=p.useCallback(()=>J(null,null,function*(){if(!r||!s){o([]);return}k(!0),O(null);try{const z=yield Iu.getWorkflowTransitions(e,r,a,n);if(console.log("[useWorkflow] Available transitions:",z),o(z),a){const G=yield Iu.canUserEditDocument(e,r,a);P(G)}}catch(z){console.error("Error fetching transitions:",z),O("Failed to load workflow actions"),o([])}finally{k(!1)}}),[e,r,a,s,n]);p.useEffect(()=>{E()},[E]);const R=p.useCallback((z,G)=>J(null,null,function*(){if(!r)return O("Document not saved yet"),!1;N(!0),O(null);try{return yield Iu.applyWorkflowAction(e,r,z,G),yield E(),!0}catch(ae){console.error("Error applying workflow action:",ae);let ee="Failed to apply action";if(ae.message)ee=ae.message;else if(ae._server_messages)try{ee=JSON.parse(ae._server_messages).map(te=>{try{return JSON.parse(te).message}catch(Y){return te}}).join(`
|
||
`)}catch(ne){ee=ae._server_messages}return O(ee),!1}finally{N(!1)}}),[e,r,E]);return{transitions:i,workflowInfo:l,userRoles:u,currentUser:f,isSystemManager:b,loading:v,actionLoading:S,error:C,canEdit:T,applyAction:R,refreshTransitions:E,getStateStyle:bL,getButtonStyle:vL,getIcon:wL}},Ix=({doctype:e,docname:r,workflowState:a,docData:s,onActionComplete:n,onStateChange:i,onWorkflowMeta:o,documentLabel:l="document",showStateInfo:c=!0,stateHeading:u="Workflow State",showFullAccessNote:h=!1,hideWhenNoWorkflow:f=!1,className:y=""})=>{const{t:b}=sr(),{transitions:w,loading:v,actionLoading:k,error:S,applyAction:N,canEdit:C,isSystemManager:O,workflowInfo:T,getStateStyle:P,getButtonStyle:E,getIcon:R}=hw({doctype:e,docname:r,workflowState:a,enabled:!!r,docData:s});p.useEffect(()=>{r&&(o==null||o({canEdit:C}))},[r,C,o]);const[z,G]=p.useState(null),ae=["Reject","Cancel","Close"],ee=(Y,q)=>J(null,null,function*(){if(ae.includes(Y)&&z!==Y){G(Y);return}G(null);const H=yield N(Y,q);n&&n(Y,H),H&&i&&i()}),ne=()=>{G(null)};if(!r||f&&!v&&!T)return null;const te=P(a||"Draft");return t.jsxs("div",{className:`space-y-4 ${y}`,children:[c&&a&&t.jsx("div",{className:`p-4 rounded-lg border ${te.bg} ${te.border}`,children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:u}),t.jsx("p",{className:`text-lg font-semibold ${te.text}`,children:a})]}),t.jsx("div",{className:`w-3 h-3 rounded-full ${te.bg.replace("100","500").replace("900/30","500")}`})]})}),v&&t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t.jsx(tr,{className:"animate-spin"}),t.jsx("span",{className:"text-sm",children:"Loading workflow actions..."})]}),S&&t.jsx("div",{className:"p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Or,{className:"text-red-500 mt-0.5"}),t.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:S})]})}),z&&t.jsxs("div",{className:"p-4 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:[t.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[t.jsx(Or,{className:"text-yellow-500 mt-0.5"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-yellow-800 dark:text-yellow-200",children:"Confirm Action"}),t.jsxs("p",{className:"text-xs text-yellow-600 dark:text-yellow-400 mt-1",children:["Are you sure you want to ",t.jsx("strong",{children:z})," this ",l,"?"]})]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>{const Y=w.find(q=>q.action===z);ee(z,Y==null?void 0:Y.next_state)},disabled:k,className:"px-3 py-1.5 bg-red-600 hover:bg-red-700 text-white text-sm rounded-md disabled:opacity-50",children:k?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(tr,{className:"animate-spin",size:12}),"Processing..."]}):`Yes, ${z}`}),t.jsx("button",{onClick:ne,disabled:k,className:"px-3 py-1.5 bg-gray-300 hover:bg-gray-400 text-gray-700 text-sm rounded-md disabled:opacity-50",children:"Cancel"})]})]}),!v&&w.length>0&&!z&&t.jsxs("div",{className:"space-y-2",children:[h&&O&&t.jsx("div",{className:"p-2 bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg mb-2",children:t.jsx("p",{className:"text-xs text-purple-700 dark:text-purple-300",children:b("workOrders.detail.systemManagerNote")})}),t.jsxs("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 flex items-center gap-1",children:[t.jsx(ro,{size:12}),"Available Actions (",w.length,")"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:w.map((Y,q)=>t.jsxs("button",{onClick:()=>ee(Y.action,Y.next_state),disabled:k,className:`px-4 py-2 rounded-lg text-sm font-medium transition-colors disabled:opacity-50 flex items-center gap-2 ${E(Y.action)}`,title:`Move to: ${Y.next_state}`,children:[k?t.jsx(tr,{className:"animate-spin",size:14}):t.jsx("span",{children:R(Y.action)}),Y.action]},`${Y.action}-${q}`))}),t.jsxs("div",{className:"mt-3 pt-2 border-t border-gray-200 dark:border-gray-600",children:[t.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:b("issues.actionResults")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:w.map((Y,q)=>t.jsxs("span",{className:"inline-block mr-3",children:[Y.action," → ",t.jsx("span",{className:"font-medium",children:Y.next_state})]},q))})]})]}),!v&&w.length===0&&r&&t.jsx("div",{className:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center",children:"No workflow actions available for your role"})})]})},Qg={getComments(e,r){return J(this,null,function*(){var i;const a=JSON.stringify([["reference_doctype","=",e],["reference_name","=",r],["comment_type","in",["Comment","Info","Edit","Attachment","Like"]]]),s=JSON.stringify(["name","owner","creation","modified","modified_by","comment_type","comment_email","comment_by","content","reference_doctype","reference_name","published","seen"]),n=yield At.apiCall(`/api/resource/Comment?filters=${encodeURIComponent(a)}&fields=${encodeURIComponent(s)}&order_by=creation asc&limit_page_length=100`);return(i=n==null?void 0:n.data)!=null?i:[]})},postComment(e,r,a){return J(this,null,function*(){const n=yield fetch("/api/resource/Comment",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({comment_type:"Comment",reference_doctype:e,reference_name:r,content:a})});if(!n.ok){const o=yield n.json().catch(()=>({}));throw new Error((o==null?void 0:o.exc)||(o==null?void 0:o._server_messages)||"Failed to post comment")}return(yield n.json()).data})},deleteComment(e){return J(this,null,function*(){const a=yield fetch(`/api/resource/Comment/${encodeURIComponent(e)}`,{method:"DELETE",credentials:"include"});if(!a.ok){const s=yield a.json().catch(()=>({}));throw new Error((s==null?void 0:s.exc)||"Failed to delete comment")}})},searchUsers(e){return J(this,null,function*(){var o;const a=JSON.stringify(e?[["enabled","=",1],["user_type","=","System User"],["name","like",`%${e}%`]]:[["enabled","=",1],["user_type","=","System User"]]),s=JSON.stringify(["name","full_name","user_image"]),n=yield fetch(`/api/resource/User?filters=${encodeURIComponent(a)}&fields=${encodeURIComponent(s)}&limit_page_length=20&order_by=full_name asc`,{credentials:"include"});return n.ok?((o=(yield n.json()).data)!=null?o:[]).filter(l=>l.name!=="Administrator"&&l.name!=="Guest"):[]})},getCurrentUser(){return J(this,null,function*(){return(yield(yield fetch("/api/method/frappe.auth.get_logged_user",{credentials:"include"})).json()).message||""})}};function Jse({referenceDoctype:e,referenceName:r,pollInterval:a=3e4}){const[s,n]=p.useState([]),[i,o]=p.useState(!0),[l,c]=p.useState(!1),[u,h]=p.useState(null),[f,y]=p.useState(""),[b,w]=p.useState([]),[v,k]=p.useState(!1),S=p.useRef(null);p.useEffect(()=>{Qg.getCurrentUser().then(y).catch(()=>{})},[]);const N=p.useCallback(()=>J(null,null,function*(){if(!r){n([]),o(!1);return}try{const P=yield Qg.getComments(e,r);n(P),h(null)}catch(P){console.error("Error fetching comments:",P),h(P.message||"Failed to load comments")}finally{o(!1)}}),[e,r]);p.useEffect(()=>{o(!0),N()},[N]),p.useEffect(()=>{if(!a||!r)return;const P=setInterval(N,a);return()=>clearInterval(P)},[a,N,r]);const C=p.useCallback(P=>J(null,null,function*(){if(r){c(!0);try{yield Qg.postComment(e,r,P),yield N()}catch(E){throw E}finally{c(!1)}}}),[e,r,N]),O=p.useCallback(P=>J(null,null,function*(){try{yield Qg.deleteComment(P),n(E=>E.filter(R=>R.name!==P))}catch(E){throw E}}),[]),T=p.useCallback(P=>J(null,null,function*(){S.current&&clearTimeout(S.current),k(!0),S.current=setTimeout(()=>J(null,null,function*(){try{const E=yield Qg.searchUsers(P);w(E)}catch(E){w([])}finally{k(!1)}}),250)}),[]);return{comments:s,loading:i,posting:l,error:u,currentUser:f,refetch:N,postComment:C,deleteComment:O,mentionUsers:b,mentionLoading:v,searchMentionUsers:T}}const Zse=({value:e,onChange:r,onSubmit:a,placeholder:s="Type a comment… Use @ to mention someone",disabled:n=!1,mentionUsers:i,mentionLoading:o,onMentionSearch:l,posting:c=!1})=>{const u=p.useRef(null),h=p.useRef(null),[f,y]=p.useState(!1),[b,w]=p.useState(""),[v,k]=p.useState(null),[S,N]=p.useState(0),[C,O]=p.useState([]),[T,P]=p.useState({top:0,left:0}),E=p.useCallback(()=>{var q,H;const te=u.current;if(!te)return;const Y=te.getBoundingClientRect();(H=(q=te.offsetParent)==null?void 0:q.getBoundingClientRect())!=null,P({top:te.offsetTop-4,left:te.offsetLeft})},[]),R=te=>{var re;const Y=te.target.value,q=(re=te.target.selectionStart)!=null?re:0;r(Y);const H=Y.substring(0,q),U=H.lastIndexOf("@");if(U!==-1){const X=U>0?Y[U-1]:" ";if(X===" "||X===`
|
||
`||U===0){const V=H.substring(U+1);if(!V.includes(" ")||V.length<=30){y(!0),w(V),k(U),N(0),l(V),E();return}}}y(!1),k(null)},z=p.useCallback(te=>{var V;if(v===null)return;const Y=u.current,q=e.substring(0,v),H=(V=Y==null?void 0:Y.selectionStart)!=null?V:v+b.length+1,U=e.substring(H),re=te.full_name||te.name,X=`${q}@${re} ${U}`;O(I=>[...I,{startIndex:v,displayText:re,userId:te.name,fullName:te.full_name||te.name}]),r(X),y(!1),k(null),w(""),setTimeout(()=>{if(Y){Y.focus();const I=q.length+re.length+2;Y.selectionStart=I,Y.selectionEnd=I}},0)},[v,b,e,r]),G=te=>{if(f&&i.length>0)switch(te.key){case"ArrowDown":te.preventDefault(),N(Y=>Math.min(Y+1,i.length-1));return;case"ArrowUp":te.preventDefault(),N(Y=>Math.max(Y-1,0));return;case"Enter":te.preventDefault(),z(i[S]);return;case"Escape":te.preventDefault(),y(!1);return}te.key==="Enter"&&(te.ctrlKey||te.metaKey)&&(te.preventDefault(),ee())},ae=p.useCallback(te=>{let Y=te;const q=window.location.origin,H=[...C].sort((U,re)=>re.startIndex-U.startIndex);for(const U of H){const re=`@${U.displayText}`,X=Y.indexOf(re);if(X===-1)continue;const V=`${q}/app/user-profile/${encodeURIComponent(U.userId)}`,I=`<span class="mention" data-id="${U.userId}" data-value="<a href="${V}" target="_blank">${U.fullName}" data-denotation-char="@" data-is-group="false" data-link="${V}">\uFEFF<span contenteditable="false"><span class="ql-mention-denotation-char">@</span><a href="${V}" target="_blank">${U.fullName}</a></span>\uFEFF</span>`;Y=Y.substring(0,X)+I+Y.substring(X+re.length)}return Y=Y.replace(/\n/g,"<br>"),`<div class="ql-editor read-mode"><p>${Y}</p></div>`},[C]),ee=()=>{const te=e.trim();if(!te||c)return;const Y=ae(te);a(Y),O([])};p.useEffect(()=>{const te=Y=>{h.current&&!h.current.contains(Y.target)&&u.current&&!u.current.contains(Y.target)&&y(!1)};return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[]),p.useEffect(()=>{if(!h.current)return;const te=h.current.querySelector(`[data-idx="${S}"]`);te==null||te.scrollIntoView({block:"nearest"})},[S]);const ne="";return t.jsxs("div",{className:"relative",children:[f&&t.jsx("div",{ref:h,className:`absolute z-50 bottom-full mb-1 w-72 max-h-52 overflow-y-auto
|
||
bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-600
|
||
rounded-lg shadow-lg`,style:{left:0},children:o&&i.length===0?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-sm text-gray-500 dark:text-gray-400",children:[t.jsx(tr,{className:"animate-spin",size:12}),"Searching users…"]}):i.length===0?t.jsx("div",{className:"px-3 py-4 text-sm text-gray-500 dark:text-gray-400",children:"No users found"}):i.map((te,Y)=>t.jsxs("button",{"data-idx":Y,type:"button",className:`w-full flex items-center gap-2.5 px-3 py-2 text-left transition-colors
|
||
${Y===S?"bg-teal-50 dark:bg-teal-900/30 text-teal-800 dark:text-teal-200":"text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700"}`,onMouseEnter:()=>N(Y),onMouseDown:q=>{q.preventDefault(),z(te)},children:[te.user_image?t.jsx("img",{src:`${ne}${te.user_image}`,alt:"",className:"w-7 h-7 rounded-full object-cover flex-shrink-0"}):t.jsx("div",{className:"w-7 h-7 rounded-full bg-gray-200 dark:bg-gray-600 flex items-center justify-center flex-shrink-0",children:t.jsx(nn,{className:"text-gray-500 dark:text-gray-400",size:10})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:te.full_name||te.name}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:te.name})]})]},te.name))}),t.jsxs("div",{className:"flex gap-2 items-end",children:[t.jsx("textarea",{ref:u,value:e,onChange:R,onKeyDown:G,placeholder:s,disabled:n||c,rows:3,className:`flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg
|
||
bg-white dark:bg-gray-700 text-gray-900 dark:text-white text-sm
|
||
disabled:bg-gray-100 dark:disabled:bg-gray-800
|
||
focus:outline-none focus:ring-2 focus:ring-teal-500 resize-none
|
||
placeholder:text-gray-400 dark:placeholder:text-gray-500`}),t.jsx("button",{type:"button",onClick:ee,disabled:n||c||!e.trim(),className:`px-4 py-2 bg-teal-600 hover:bg-teal-700 disabled:bg-teal-600/50
|
||
text-white text-sm font-medium rounded-lg transition-colors
|
||
disabled:cursor-not-allowed flex items-center gap-1.5 h-10 flex-shrink-0`,children:c?t.jsxs(t.Fragment,{children:[t.jsx(tr,{className:"animate-spin",size:12}),t.jsx("span",{children:"Posting…"})]}):t.jsx("span",{children:"Comment"})})]}),t.jsxs("p",{className:"mt-1 text-[10px] text-gray-400 dark:text-gray-500",children:[t.jsx("kbd",{className:"px-1 py-0.5 bg-gray-100 dark:bg-gray-700 rounded text-[9px]",children:"@"})," to mention · ",t.jsx("kbd",{className:"px-1 py-0.5 bg-gray-100 dark:bg-gray-700 rounded text-[9px]",children:"Ctrl+Enter"})," to post"]})]})},C7={Comment:{icon:t.jsx(nv,{size:10}),color:"text-blue-600 dark:text-blue-400",label:"Comment"},Info:{icon:t.jsx(ro,{size:10}),color:"text-gray-500 dark:text-gray-400",label:"Info"},Edit:{icon:t.jsx(qr,{size:10}),color:"text-orange-500 dark:text-orange-400",label:"Edit"},Attachment:{icon:t.jsx(BG,{size:10}),color:"text-purple-500 dark:text-purple-400",label:"Attachment"},Like:{icon:t.jsx(vf,{size:10}),color:"text-pink-500 dark:text-pink-400",label:"Like"}},Xse=e=>{if(!e)return"";const r=new Date(e),a=new Date,s=a.getTime()-r.getTime(),n=Math.floor(s/6e4),i=Math.floor(s/36e5),o=Math.floor(s/864e5);return n<1?"Just now":n<60?`${n}m ago`:i<24?`${i}h ago`:o<7?`${o}d ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:r.getFullYear()!==a.getFullYear()?"numeric":void 0})},Qse=e=>{if(!e)return"Unknown";const r=e.indexOf("@");return r===-1?e:e.substring(0,r).replace(/[._-]/g," ").replace(/\b\w/g,a=>a.toUpperCase())},ene=({html:e})=>{const r=e.replace(/<div class="ql-editor[^"]*">/g,"").replace(/<\/div>$/g,"");return t.jsx("div",{className:`comment-content text-sm text-gray-800 dark:text-gray-200 leading-relaxed
|
||
[&_a]:text-teal-600 [&_a]:dark:text-teal-400 [&_a]:underline [&_a]:font-medium
|
||
[&_.mention]:text-teal-700 [&_.mention]:dark:text-teal-300 [&_.mention]:font-semibold
|
||
[&_.mention]:bg-teal-50 [&_.mention]:dark:bg-teal-900/30 [&_.mention]:px-1 [&_.mention]:py-0.5
|
||
[&_.mention]:rounded [&_.mention]:pointer-events-none [&_.mention]:cursor-default
|
||
[&_.mention_a]:no-underline [&_.mention_a]:text-inherit
|
||
[&_p]:my-0`,dangerouslySetInnerHTML:{__html:r}})},Bm=({referenceDoctype:e,referenceName:r,title:a="Comments & Discussion",pollInterval:s=3e4,initialLimit:n=5,collapsible:i=!0,startCollapsed:o=!1})=>{const{comments:l,loading:c,posting:u,error:h,currentUser:f,refetch:y,postComment:b,deleteComment:w,mentionUsers:v,mentionLoading:k,searchMentionUsers:S}=Jse({referenceDoctype:e,referenceName:r,pollInterval:s}),[N,C]=p.useState(!o),[O,T]=p.useState(!1),[P,E]=p.useState(""),[R,z]=p.useState(null),G=p.useMemo(()=>l.filter(te=>te.comment_type==="Comment"),[l]),ae=p.useMemo(()=>O?l:l.slice(-n),[l,O,n]),ee=te=>J(null,null,function*(){try{yield b(te),E(""),We.success("Comment posted!",{position:"top-right",autoClose:2e3,icon:t.jsx(Qt,{})})}catch(Y){We.error(`Failed to post comment: ${Y.message||"Unknown error"}`,{position:"top-right",autoClose:5e3,icon:t.jsx(pr,{})})}}),ne=te=>J(null,null,function*(){z(te);try{yield w(te),We.success("Comment deleted",{position:"top-right",autoClose:2e3,icon:t.jsx(Qt,{})})}catch(Y){We.error(`Failed to delete: ${Y.message||"Unknown error"}`,{position:"top-right",autoClose:5e3,icon:t.jsx(pr,{})})}finally{z(null)}});return r?t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 overflow-hidden",children:[t.jsxs("div",{className:`flex items-center justify-between px-5 py-3 border-b border-gray-200 dark:border-gray-700 ${i?"cursor-pointer select-none":""}`,onClick:()=>i&&C(te=>!te),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(nv,{className:"text-teal-500",size:16}),t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white",children:a}),G.length>0&&t.jsx("span",{className:"px-2 py-0.5 bg-teal-100 dark:bg-teal-900/30 text-teal-700 dark:text-teal-300 rounded-full text-xs font-medium",children:G.length})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:te=>{te.stopPropagation(),y()},disabled:c,className:"p-1.5 text-gray-400 hover:text-teal-500 hover:bg-teal-50 dark:hover:bg-teal-900/20 rounded transition-colors disabled:opacity-50",title:"Refresh comments",children:t.jsx(Ma,{className:c?"animate-spin":"",size:11})}),i&&t.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:N?t.jsx(Ja,{size:12}):t.jsx(Fr,{size:12})})]})]}),N&&t.jsxs("div",{className:"p-5 space-y-5",children:[h&&t.jsxs("div",{className:"flex items-center gap-2 text-red-600 dark:text-red-400 text-sm bg-red-50 dark:bg-red-900/20 rounded-lg p-3",children:[t.jsx(Or,{size:12}),h]}),c&&l.length===0&&t.jsxs("div",{className:"flex items-center justify-center py-8",children:[t.jsx(tr,{className:"animate-spin text-teal-500 mr-2",size:16}),t.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Loading comments…"})]}),l.length>0&&t.jsxs(t.Fragment,{children:[!O&&l.length>n&&t.jsxs("button",{type:"button",onClick:()=>T(!0),className:`w-full text-center py-2 text-xs text-teal-600 dark:text-teal-400
|
||
hover:bg-teal-50 dark:hover:bg-teal-900/20 rounded-lg transition-colors font-medium`,children:["Show ",l.length-n," older comment",l.length-n!==1?"s":""]}),t.jsx("div",{className:"space-y-3",children:ae.map(te=>{const Y=C7[te.comment_type]||C7.Comment,q=te.comment_email===f||te.owner===f,H=R===te.name;return t.jsx("div",{className:`group relative rounded-lg border transition-colors ${te.comment_type==="Comment"?"bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600":"bg-gray-50 dark:bg-gray-800/50 border-gray-100 dark:border-gray-700/50"}`,children:t.jsxs("div",{className:"px-4 py-3",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-7 h-7 rounded-full bg-teal-100 dark:bg-teal-900/40 flex items-center justify-center flex-shrink-0",children:t.jsx(nn,{className:"text-teal-600 dark:text-teal-400",size:10})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:te.comment_by||Qse(te.comment_email||te.owner)}),te.comment_type!=="Comment"&&t.jsxs("span",{className:`ml-2 inline-flex items-center gap-1 text-[10px] font-medium ${Y.color}`,children:[Y.icon,Y.label]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"text-[11px] text-gray-400 dark:text-gray-500 flex items-center gap-1",title:new Date(te.creation).toLocaleString(),children:[t.jsx(ea,{size:9}),Xse(te.creation)]}),q&&te.comment_type==="Comment"&&t.jsx("button",{type:"button",onClick:()=>ne(te.name),disabled:H,className:`opacity-0 group-hover:opacity-100 p-1 text-gray-400 hover:text-red-500
|
||
hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-all disabled:opacity-50`,title:"Delete comment",children:H?t.jsx(tr,{className:"animate-spin",size:10}):t.jsx(wr,{size:10})})]})]}),t.jsx("div",{className:"ml-9",children:t.jsx(ene,{html:te.content})})]})},te.name)})}),O&&l.length>n&&t.jsx("button",{type:"button",onClick:()=>T(!1),className:`w-full text-center py-2 text-xs text-teal-600 dark:text-teal-400
|
||
hover:bg-teal-50 dark:hover:bg-teal-900/20 rounded-lg transition-colors font-medium`,children:"Show fewer comments"})]}),!c&&l.length===0&&t.jsxs("div",{className:"text-center py-8",children:[t.jsx(nv,{className:"mx-auto text-gray-300 dark:text-gray-600 mb-2",size:28}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No comments yet. Start the discussion!"})]}),t.jsx("div",{className:"pt-3 border-t border-gray-200 dark:border-gray-700",children:t.jsx(Zse,{value:P,onChange:E,onSubmit:ee,disabled:!r,posting:u,mentionUsers:v,mentionLoading:k,onMentionSearch:S})})]})]}):t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t.jsx(nv,{className:"text-gray-400"}),t.jsx("span",{className:"text-sm",children:"Save the document first to enable comments."})]})})},tne=({doctype:e,docname:r,limit:a=50,enabled:s=!0})=>{const[n,i]=p.useState([]),[o,l]=p.useState(!1),[c,u]=p.useState(null),h=p.useCallback(()=>J(null,null,function*(){if(!(!s||!e||!r)){l(!0),u(null);try{const f=yield At.apiCall(`/api/resource/Version?filters=[["ref_doctype","=","${encodeURIComponent(e)}"],["docname","=","${encodeURIComponent(r)}"]]&fields=["name","owner","creation","data"]&order_by=creation desc&limit=${a}`);if(f!=null&&f.data&&f.data.length>0){const y=f.data.map(b=>{let w={added:[],changed:[],removed:[],row_changed:[]};try{w=JSON.parse(b.data||"{}")}catch(k){console.error("Error parsing version data:",k)}const v=(w.changed||[]).map(k=>({field:k[0]||"",oldValue:k[1],newValue:k[2]}));return{name:b.name,owner:b.owner,creation:b.creation,changes:v,added:w.added||[],removed:w.removed||[],rowChanged:w.row_changed||[]}});i(y)}else i([])}catch(f){console.error(`Error fetching audit logs for ${e}/${r}:`,f),u(f instanceof Error?f.message:"Failed to load activity log"),i([])}finally{l(!1)}}}),[e,r,a,s]);return p.useEffect(()=>{h()},[h]),{auditLogs:n,loading:o,error:c,refetch:h}},rne=e=>e?e.replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase()):"",T7=e=>e==null||e===""?"(empty)":e===0?"0":e===1?"1":typeof e=="boolean"?e?"Yes":"No":typeof e=="object"?JSON.stringify(e):String(e),jL=e=>{if(!e)return"";const r=new Date(e),a=new Date,s=a.getTime()-r.getTime(),n=Math.floor(s/6e4),i=Math.floor(s/36e5),o=Math.floor(s/864e5);return n<1?"Just now":n<60?`${n} min${n>1?"s":""} ago`:i<24?`${i} hour${i>1?"s":""} ago`:o<7?`${o} day${o>1?"s":""} ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:r.getFullYear()!==a.getFullYear()?"numeric":void 0,hour:"2-digit",minute:"2-digit"})},_L=e=>{if(!e)return"Unknown";const r=e.indexOf("@");return r===-1?e:e.substring(0,r)},ane=e=>{const r=e.toLowerCase();return r.includes("status")||r.includes("state")||r.includes("workflow")?"text-purple-600 dark:text-purple-400":r.includes("date")?"text-blue-600 dark:text-blue-400":r.includes("technician")||r.includes("supervisor")||r.includes("assigned")||r.includes("location")||r.includes("department")||r.includes("building")||r.includes("room")?"text-green-600 dark:text-green-400":"text-gray-600 dark:text-gray-400"},sne=({log:e,isLatest:r,compact:a})=>{const s=a?"w-2.5 h-2.5":"w-3 h-3",n=a?"w-5 h-5":"w-6 h-6",i=a?8:10,o=a?"text-[10px]":"text-xs",l=a?"text-[9px]":"text-[10px]";return t.jsxs("div",{className:`relative ${a?"pl-6":"pl-8"}`,children:[t.jsx("div",{className:`absolute ${a?"left-1":"left-1.5"} top-1.5 ${s} rounded-full border-2 border-white dark:border-gray-800 ${r?"bg-blue-500":"bg-gray-300 dark:bg-gray-600"}`}),t.jsxs("div",{className:`${a?"p-2":"p-3"} rounded-lg ${r?"bg-blue-50 dark:bg-blue-900/20 border border-blue-100 dark:border-blue-800/50":"bg-gray-50 dark:bg-gray-700/50"}`,children:[t.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:`${n} rounded-full bg-gray-200 dark:bg-gray-600 flex items-center justify-center`,children:t.jsx(nn,{className:"text-gray-500 dark:text-gray-400",size:i})}),t.jsx("span",{className:`${o} font-medium text-gray-700 dark:text-gray-300`,children:_L(e.owner)})]}),t.jsxs("div",{className:`flex items-center gap-1 ${o} text-gray-500 dark:text-gray-400`,children:[t.jsx(ea,{size:i}),t.jsx("span",{title:new Date(e.creation).toLocaleString(),children:jL(e.creation)})]})]}),t.jsxs("div",{className:"space-y-1",children:[e.changes.length>0?e.changes.map((c,u)=>t.jsxs("div",{className:o,children:[t.jsx("span",{className:`font-medium ${ane(c.field)}`,children:rne(c.field)}),t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:" changed from "}),t.jsx("span",{className:`px-1 py-0.5 bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400 rounded ${l} font-mono`,children:T7(c.oldValue)}),t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:" → "}),t.jsx("span",{className:`px-1 py-0.5 bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400 rounded ${l} font-mono`,children:T7(c.newValue)})]},u)):t.jsx("p",{className:`${o} text-gray-500 dark:text-gray-400 italic`,children:"Document updated"}),e.added&&e.added.length>0&&t.jsxs("div",{className:`${o} text-green-600 dark:text-green-400`,children:[t.jsx("span",{className:"font-medium",children:"Added:"})," ",e.added.length," item(s)"]}),e.removed&&e.removed.length>0&&t.jsxs("div",{className:`${o} text-red-600 dark:text-red-400`,children:[t.jsx("span",{className:"font-medium",children:"Removed:"})," ",e.removed.length," item(s)"]}),e.rowChanged&&e.rowChanged.length>0&&t.jsxs("div",{className:`${o} text-orange-600 dark:text-orange-400`,children:[t.jsx("span",{className:"font-medium",children:"Modified:"})," ",e.rowChanged.length," row(s)"]})]})]})]})},E7=({creationDate:e,createdBy:r,doctype:a,compact:s})=>{const n=s?"w-2.5 h-2.5":"w-3 h-3",i=s?"w-5 h-5":"w-6 h-6",o=s?8:10,l=s?"text-[10px]":"text-xs",c=a.replace(/_/g," ");return t.jsxs("div",{className:`relative ${s?"pl-6":"pl-8"}`,children:[t.jsx("div",{className:`absolute ${s?"left-1":"left-1.5"} top-1.5 ${n} rounded-full border-2 border-white dark:border-gray-800 bg-green-500`}),t.jsxs("div",{className:`${s?"p-2":"p-3"} rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-100 dark:border-green-800/50`,children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:`${i} rounded-full bg-green-200 dark:bg-green-800 flex items-center justify-center`,children:t.jsx(nn,{className:"text-green-600 dark:text-green-400",size:o})}),t.jsx("span",{className:`${l} font-medium text-gray-700 dark:text-gray-300`,children:_L(r)})]}),t.jsxs("div",{className:`flex items-center gap-1 ${l} text-gray-500 dark:text-gray-400`,children:[t.jsx(ea,{size:o}),t.jsx("span",{title:new Date(e).toLocaleString(),children:jL(e)})]})]}),t.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 bg-green-100 dark:bg-green-800/50 text-green-700 dark:text-green-300 rounded ${l} font-medium`,children:[t.jsx(Qt,{size:o}),"Created this ",c]})]})]})},vi=({doctype:e,docname:r,creationDate:a,createdBy:s,title:n="Activity Log",limit:i=50,initialVisible:o=5,collapsible:l=!0,startCollapsed:c=!1,compact:u=!1,className:h="",onRefresh:f})=>{const[y,b]=p.useState(!c),[w,v]=p.useState(!1),{auditLogs:k,loading:S,refetch:N}=tne({doctype:e,docname:r,limit:i,enabled:!!r}),C=()=>{N(),f==null||f()};if(!r)return null;const O=u?14:16,T=u?"text-sm":"text-base",P=u?"left-2":"left-3",E=u?"text-[10px]":"text-xs",R=u?8:10,z=w?k:k.slice(0,o);return t.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 overflow-hidden ${h}`,children:[t.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:`flex items-center gap-2 flex-1 ${l?"cursor-pointer":""}`,onClick:()=>l&&b(!y),children:[t.jsx(ym,{className:"text-blue-500",size:O}),t.jsx("h2",{className:`${T} font-semibold text-gray-800 dark:text-white`,children:n}),k.length>0&&t.jsx("span",{className:"px-1.5 py-0.5 bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 rounded-full text-[10px] font-medium",children:k.length})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button",onClick:G=>{G.stopPropagation(),C()},disabled:S,className:"p-1 text-gray-400 hover:text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded transition-colors disabled:opacity-50",title:"Refresh activity log",children:t.jsx(Ma,{className:S?"animate-spin":"",size:u?10:12})}),l&&t.jsx("button",{type:"button",onClick:()=>b(!y),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors p-1",children:y?t.jsx(Ja,{size:u?12:14}):t.jsx(Fr,{size:u?12:14})})]})]}),y&&t.jsxs("div",{className:"p-3",children:[S&&t.jsxs("div",{className:"flex items-center justify-center py-6",children:[t.jsx(tr,{className:"animate-spin text-blue-500 mr-2",size:14}),t.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Loading..."})]}),!S&&k.length===0&&t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:`absolute ${P} top-0 bottom-0 w-0.5 bg-gray-200 dark:bg-gray-700`}),t.jsxs("div",{className:`relative ${u?"pl-6":"pl-8"} mb-3`,children:[t.jsx("div",{className:`absolute ${u?"left-1":"left-1.5"} top-1 ${u?"w-2.5 h-2.5":"w-3 h-3"} rounded-full border-2 border-white dark:border-gray-800 bg-gray-300 dark:bg-gray-600`}),t.jsx("div",{className:`${u?"p-2":"p-3"} rounded-lg bg-gray-50 dark:bg-gray-700/50`,children:t.jsx("p",{className:`${u?"text-[10px]":"text-xs"} text-gray-500 dark:text-gray-400 italic`,children:"No changes recorded yet"})})]}),a&&s&&t.jsx(E7,{creationDate:a,createdBy:s,doctype:e,compact:u})]}),!S&&k.length>0&&t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:`absolute ${P} top-0 bottom-0 w-0.5 bg-gray-200 dark:bg-gray-700`}),t.jsx("div",{className:"space-y-3",children:z.map((G,ae)=>t.jsx(sne,{log:G,isLatest:ae===0,compact:u},G.name))}),k.length>o&&t.jsx("div",{className:"mt-3 text-center",children:t.jsx("button",{type:"button",onClick:()=>v(!w),className:`inline-flex items-center gap-1 px-2 py-1 ${E} font-medium text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-md transition-colors`,children:w?t.jsxs(t.Fragment,{children:[t.jsx(Ja,{size:R})," Show Less"]}):t.jsxs(t.Fragment,{children:[t.jsx(Fr,{size:R})," Show All (",k.length,")"]})})}),a&&s&&t.jsx("div",{className:"mt-3",children:t.jsx(E7,{creationDate:a,createdBy:s,doctype:e,compact:u})})]})]})]})},nne=()=>{var Ye,kt,Yt;const{t:e}=sr(),{assetName:r}=hs(),a=hr(),[s]=_a(),n=s.get("duplicate"),i=r==="new",o=i&&!!n,{isAllowedOnSubmit:l}=Ise("Asset"),[c,u]=p.useState({asset_name:"",company:"",custom_serial_number:"",custom_technical_department:"",location:"",custom_manufacturer:"",department:"",custom_asset_type:"Non Biomedical",custom_category:"General",custom_manufacturing_year:"",custom_model:"",custom_class:"",custom_device_status:"",custom_down_time:0,asset_owner_company:"",custom_up_time:0,custom_total_hours:0,custom_modality:"",custom_attach_image:"",custom_site_contractor:"",custom_site:"",custom_total_amount:0,calculate_depreciation:!1,available_for_use_date:void 0,finance_books:[],custom_service_agreement:"",custom_service_coverage:"",custom_start_date:"",custom_end_date:"",custom_warranty:!1,custom_extended_warranty:!1,custom__service_contract:!1,custom_covering_spare_parts:!1,custom_spare_parts_labour:!1,custom_covering_labour:!1,custom_ppm_only:!1,custom_support_plan:"",custom_spare_parts:[],custom_total_spare_parts_amount:0,custom_building:"",custom_room_number:"",custom_recalled:"",is_existing_asset:!0,__islocal:!1}),{shouldShowField:h,isMandatory:f,isReadOnly:y}=gL("Asset",c),{asset:b,loading:w,error:v,refetch:k}=NG(o?n:i?null:r||null),{createAsset:S,updateAsset:N,submitAsset:C,loading:O}=B9(),T=(b==null?void 0:b.workflow_state)||"Draft",{transitions:P,workflowInfo:E,userRoles:R,isSystemManager:z,error:G,canEdit:ae,getStateStyle:ee}=hw({doctype:"Asset",docname:i?null:r||null,workflowState:T,enabled:!i&&!!r,docData:c}),[ne,te]=p.useState(i),Y=(Ye=b==null?void 0:b.docstatus)!=null?Ye:0,q=Y===1,H=Y===2,U=Y===0,re=!!(b!=null&&b.custom_delete_status),X=p.useMemo(()=>{const Ae=["System Manager","Contractor Supervisor","Contractor Manager"];return z||R.some(ke=>Ae.includes(ke))},[z,R]);p.useMemo(()=>X&&(E!=null&&E.transitions)?E.transitions.filter(ke=>ke.state===T).map(ke=>({action:ke.action,next_state:ke.next_state,allowed:ke.allowed,condition:ke.condition})):P,[X,E,T,P]);const V=p.useMemo(()=>i||X?!0:H?!1:E&&T?ae:U||P.length>0,[i,X,H,E,T,ae,U,P.length]),I=p.useMemo(()=>z?!0:!(R.includes("Contractor Supervisor")||R.includes("End user")&&R.filter(ke=>!["End user","All","Guest","Desk User"].includes(ke)).length===0),[z,R]),B=p.useMemo(()=>R.includes("Cluster Manager")||z,[z,R]),[Q,ie]=p.useState(!1),me=p.useRef(null);p.useEffect(()=>{const Ae=ke=>{me.current&&!me.current.contains(ke.target)&&ie(!1)};return document.addEventListener("mousedown",Ae),()=>document.removeEventListener("mousedown",Ae)},[]),p.useEffect(()=>{},[b,Y,U,q,H,ne]);const he=p.useCallback(Ae=>!ne||H||re||y(Ae)?!0:q?!l(Ae):!U,[ne,H,q,U,l,y,re]),de=p.useCallback(Ae=>h(Ae),[h]);p.useCallback(Ae=>f(Ae),[f]);const xe=p.useCallback(()=>!!(c.custom_building||c.department),[c.custom_building,c.department]),ge=p.useCallback(()=>!!(c.department||c.custom_room_number),[c.department,c.custom_room_number]),be=p.useCallback(()=>!!(c.custom_room_number||c.location),[c.custom_room_number,c.location]),[K,ye]=p.useState(""),[Z,M]=p.useState({}),[we,pe]=p.useState([]),[le,Fe]=p.useState([]),[ze,Re]=p.useState(!1),[De,Et]=p.useState(!1);p.useEffect(()=>{i&&!c.available_for_use_date&&u(Ae=>je(se({},Ae),{available_for_use_date:new Date().toISOString().split("T")[0],__islocal:!0}))},[i]),p.useEffect(()=>{function Ae(){return J(this,null,function*(){try{const ke=yield At.getUserDetails();ye(ke.custom_site_name||""),u(Be=>{const yt={};if(i||!Be.company){const Me=ke.custom_site_name||"King Fahad Specialist Hospital - Dammam";yt.company=Me,yt.asset_owner_company=Me}return!Be.custom_site&&ke.custom_phcc_site_name&&(yt.custom_site=ke.custom_phcc_site_name),se(se({},Be),yt)})}catch(ke){console.error("Error loading user details",ke)}})}Ae()},[i]);const jt=()=>{const ke={finance_book:"Depreciation Entries",depreciation_method:"Straight Line",total_number_of_depreciations:10,frequency_of_depreciation:12,depreciation_start_date:new Date().toISOString().split("T")[0]};u(Be=>je(se({},Be),{finance_books:[...Be.finance_books||[],ke]}))},Ie=Ae=>{u(ke=>{const Be=[...ke.finance_books||[]];return Be.splice(Ae,1),je(se({},ke),{finance_books:Be})})},$e=(Ae,ke)=>{u(Be=>{const yt=[...Be.finance_books||[]];return yt[Ae]=se(se({},yt[Ae]||{}),ke),je(se({},Be),{finance_books:yt})})};p.useEffect(()=>{if(c.calculate_depreciation&&(!c.finance_books||c.finance_books.length===0)){const ke={finance_book:"Depreciation Entries",depreciation_method:"Straight Line",total_number_of_depreciations:10,frequency_of_depreciation:12,depreciation_start_date:new Date().toISOString().split("T")[0]};u(Be=>je(se({},Be),{finance_books:[ke]}))}},[c.calculate_depreciation]);const Qe=(Ae,ke,Be)=>{u(yt=>{const Me=[...yt.custom_spare_parts||[]],Ke=se({},Me[Ae]);ke==="qty"||ke==="rate"?(Ke[ke]=Be,Ke.amount=(Ke.qty||0)*(Ke.rate||0)):Ke[ke]=Be,Me[Ae]=Ke;const Xe=Me.reduce((oe,_e)=>oe+(_e.amount||0),0);return je(se({},yt),{custom_spare_parts:Me,custom_total_spare_parts_amount:Xe})})},at=()=>{u(Ae=>je(se({},Ae),{custom_spare_parts:[...Ae.custom_spare_parts||[],{qty:0,rate:0,amount:0}]}))},Ct=Ae=>{u(ke=>{const Be=[...ke.custom_spare_parts||[]];Be.splice(Ae,1);const yt=Be.reduce((Me,Ke)=>Me+(Ke.amount||0),0);return je(se({},ke),{custom_spare_parts:Be,custom_total_spare_parts_amount:yt})})};p.useEffect(()=>{if(c.available_for_use_date){const Ae=new Date(c.available_for_use_date),Be=new Date().getTime()-Ae.getTime(),Me=Math.floor(Be/(1e3*60*60*24))*24,Ke=Me-(c.custom_down_time||0);u(Xe=>je(se({},Xe),{custom_total_hours:Me,custom_up_time:Ke}))}},[c.available_for_use_date,c.custom_down_time]);const vt=p.useRef("");p.useEffect(()=>{if(!ne){vt.current=c.custom_asset_type||"";return}const Ae=(c.custom_asset_type||"").toString().trim().toLowerCase(),ke=(vt.current||"").toString().trim().toLowerCase();Ae!==ke&&(vt.current=c.custom_asset_type||"",Ae==="biomedical"?c.custom_site_contractor!=="SAMAMA"&&u(Be=>je(se({},Be),{custom_site_contractor:"SAMAMA"})):ke==="biomedical"&&c.custom_site_contractor==="SAMAMA"&&u(Be=>je(se({},Be),{custom_site_contractor:""})))},[c.custom_asset_type,ne]),p.useEffect(()=>{const Ae={};c.company&&(Ae.company=c.company);const ke=K&&K.startsWith("Mobile")||c.company&&c.company.startsWith("Mobile");(K||c.company)&&(ke?Ae.department_name=["not like","Non Bio%"]:Ae.department_name=["not like","Non Bio%"]),M(Ae)},[c.company,K]);const er=p.useCallback((Ae,ke)=>J(null,null,function*(){if(!Ae){pe([]);return}Et(!0);try{const Be=new URLSearchParams;Be.append("building",Ae),ke&&Be.append("company",ke);const Ke=(yield(yield fetch(`/api/method/asset_lite.api.room_filter.get_department_count?${Be.toString()}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json()).message||0;pe(new Array(Ke).fill("")),console.log("Department count for Asset:",{building:Ae,company:ke,count:Ke})}catch(Be){console.error("Error fetching department count:",Be),pe([])}finally{Et(!1)}}),[]),nr=p.useCallback((Ae,ke)=>J(null,null,function*(){if(!Ae&&!ke){Fe([]);return}Re(!0);try{const Be=new URLSearchParams;Ae&&Be.append("building",Ae),ke&&Be.append("department",ke);const Ke=(yield(yield fetch(`/api/method/asset_lite.api.room_filter.get_room_count?${Be.toString()}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json()).message||0;Fe(new Array(Ke).fill("")),console.log("Room count for Asset:",{building:Ae,department:ke,count:Ke})}catch(Be){console.error("Error fetching room count:",Be),Fe([])}finally{Re(!1)}}),[]);p.useEffect(()=>{const Ae=c.custom_building||void 0,ke=c.company||void 0;Ae?er(Ae,ke):pe([])},[c.custom_building,c.company,er]),p.useEffect(()=>{const Ae=c.custom_building||void 0,ke=c.department||void 0;Ae||ke?nr(Ae,ke):Fe([])},[c.custom_building,c.department,nr]);const dt=p.useCallback(Ae=>J(null,null,function*(){if(u(ke=>je(se({},ke),{custom_room_number:Ae})),!Ae){u(ke=>je(se({},ke),{location:""}));return}try{const ke=c.custom_building||"",Be=c.department||"",yt=[["room_no","=",Ae]];ke&&yt.push(["building","=",ke]),Be&&yt.push(["department","=",Be]);const Me=JSON.stringify(yt),Ke=yield At.apiCall(`/api/resource/Infrastructure Location?filters=${encodeURIComponent(Me)}&fields=["location"]&limit=1`);Ke!=null&&Ke.data&&Ke.data.length>0&&Ke.data[0].location&&(u(Xe=>je(se({},Xe),{location:Ke.data[0].location})),console.log("Auto-set location:",Ke.data[0].location))}catch(ke){console.error("Error fetching location for room:",ke)}}),[c.custom_building,c.department]);p.useEffect(()=>{b&&(vt.current=b.custom_asset_type||"",u({asset_name:o?`${b.asset_name} (Copy)`:b.asset_name||"",company:b.company||"",custom_serial_number:o?"":b.custom_serial_number||"",custom_technical_department:b.custom_technical_department||"",location:b.location||"",custom_manufacturer:b.custom_manufacturer||"",department:b.department||"",custom_asset_type:b.custom_asset_type||"Non Biomedical",custom_category:b.custom_category||"General",custom_manufacturing_year:b.custom_manufacturing_year||"",custom_model:b.custom_model||"",custom_class:b.custom_class||"",custom_device_status:b.custom_device_status||"",custom_down_time:b.custom_down_time||0,asset_owner_company:b.asset_owner_company||"",custom_up_time:b.custom_up_time||0,custom_total_hours:b.custom_total_hours||0,custom_modality:b.custom_modality||"",custom_attach_image:b.custom_attach_image||"",custom_site_contractor:b.custom_site_contractor||"",custom_site:b.custom_site||"",custom_total_amount:b.custom_total_amount||0,gross_purchase_amount:b.gross_purchase_amount||0,available_for_use_date:b.available_for_use_date||"",calculate_depreciation:b.calculate_depreciation||!1,finance_books:b.finance_books||[],custom_service_agreement:b.custom_service_agreement||"",custom_service_coverage:b.custom_service_coverage||"",custom_start_date:b.custom_start_date?b.custom_start_date.split(" ")[0]:"",custom_end_date:b.custom_end_date?b.custom_end_date.split(" ")[0]:"",custom_building:b.custom_building||"",custom_room_number:b.custom_room_number||"",custom_recalled:b.custom_recalled||"",custom_warranty:b.custom_warranty||!1,custom_extended_warranty:b.custom_extended_warranty||!1,custom__service_contract:b.custom__service_contract||!1,custom_covering_spare_parts:b.custom_covering_spare_parts||!1,custom_spare_parts_labour:b.custom_spare_parts_labour||!1,custom_covering_labour:b.custom_covering_labour||!1,custom_ppm_only:b.custom_ppm_only||!1,custom_support_plan:b.custom_support_plan||"",custom_spare_parts:b.custom_spare_parts||[],custom_total_spare_parts_amount:b.custom_total_spare_parts_amount||0}))},[b,o]);const[He,it]=p.useState(null);p.useEffect(()=>{if(!r||r==="new")return;J(null,null,function*(){var ke;try{const Be=`/files/${r}-qr.png`;if((yield fetch(Be,{method:"HEAD"})).ok){it(Be);return}const Me=yield At.apiCall(`/api/resource/File?filters=[["File","attached_to_name","=","${r}"]]`);((ke=Me==null?void 0:Me.data)==null?void 0:ke.length)>0&&it(Me.data[0].file_url)}catch(Be){console.error("Error loading QR code:",Be)}})},[r,b]);const Ue=Ae=>{const{name:ke,value:Be}=Ae.target;u(yt=>je(se({},yt),{[ke]:Be}))},Ve=Ae=>J(null,null,function*(){if(Ae.preventDefault(),!c.asset_name){alert(e("assets.pleaseEnterAssetName"));return}if(!c.custom_asset_type){alert(e("assets.pleaseSelectCategory"));return}console.log("Submitting asset data:",c);try{if(i||o){const ke=yield S(c);if(ke.name){const yt=`/files/${ke.name}-qr.png`;it(yt)}const Be=e(o?"assets.detail.assetDuplicatedSuccess":"assets.detail.assetCreatedSuccess");alert(Be),a(`/assets/${ke.name}`)}else r&&(yield N(r,c),alert(e("assets.detail.assetUpdatedSuccess")),te(!1),k())}catch(ke){console.error("Asset save error:",ke);const Be=ke instanceof Error?ke.message:"Unknown error";Be.includes("404")||Be.includes("not found")||Be.includes("has no attribute")||Be.includes("417")?alert(`⚠️ Asset API Not Deployed
|
||
|
||
The Asset API endpoint (asset_api.py) is not deployed on your Frappe server yet.
|
||
|
||
To fix this:
|
||
1. SSH into your Frappe server
|
||
2. Navigate to: frappe-bench/apps/asset_lite/asset_lite/api/
|
||
3. Create the file: asset_api.py
|
||
4. Copy the content from frappe_asset_api.py in this project
|
||
5. Restart Frappe: bench restart
|
||
|
||
Error: `+Be):alert(e("assets.detail.failedToSave")+`:
|
||
|
||
`+Be)}}),lt=()=>{k()},st=()=>J(null,null,function*(){if(!r||i){alert(e("assets.detail.cannotSubmitNotSaved"));return}if(window.confirm(e("assets.detail.confirmSubmit")))try{yield C(r),alert(e("assets.detail.assetSubmittedSuccess")),k(),te(!1)}catch(Ae){console.error("Asset submit error:",Ae);const ke=Ae instanceof Error?Ae.message:"Unknown error";alert(e("assets.detail.failedToSubmit")+`:
|
||
|
||
`+ke)}});if(w)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("assets.loadingAssetDetails")})]})});if(v&&!i&&!o)return t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:[t.jsxs("p",{className:"text-red-600 dark:text-red-400",children:[e("common.error"),": ",v]}),t.jsx("button",{onClick:()=>a(-1),className:"mt-2 text-red-700 dark:text-red-400 underline hover:text-red-800 dark:hover:text-red-300",children:e("assets.backToList")})]})});if(v&&o)return t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-yellow-800 dark:text-yellow-300 mb-2",children:e("assets.sourceAssetNotFound")}),t.jsx("p",{className:"text-yellow-700 dark:text-yellow-400",children:e("assets.assetNotFoundMessage")}),t.jsxs("div",{className:"mt-4 flex gap-3",children:[t.jsx("button",{onClick:()=>a("/assets/new"),className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors",children:e("assets.createNewAsset")}),t.jsx("button",{onClick:()=>a(-1),className:"px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg transition-colors",children:e("assets.backToAssetsList")})]})]})});const Mt=()=>{if(!He||!b)return;const Ae=window.open("","_blank");Ae&&(Ae.document.write(`
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<title>Print QR Code - ${b.name}</title>
|
||
<style>
|
||
@page {
|
||
margin: 0.5in;
|
||
size: auto;
|
||
}
|
||
* {
|
||
margin: 0;
|
||
padding: 0;
|
||
box-sizing: border-box;
|
||
}
|
||
body {
|
||
font-family: Arial, sans-serif;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
min-height: 100vh;
|
||
padding: 0;
|
||
}
|
||
.qr-container {
|
||
text-align: center;
|
||
border: 2px solid #333;
|
||
padding: 20px;
|
||
border-radius: 8px;
|
||
background: white;
|
||
max-width: 400px;
|
||
}
|
||
.qr-image {
|
||
width: 300px;
|
||
height: 300px;
|
||
margin: 15px 0;
|
||
display: block;
|
||
margin-left: auto;
|
||
margin-right: auto;
|
||
}
|
||
h1 {
|
||
font-size: 20px;
|
||
margin-bottom: 10px;
|
||
}
|
||
.asset-info {
|
||
margin: 10px 0;
|
||
font-size: 14px;
|
||
line-height: 1.5;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="qr-container">
|
||
<h1>Asset QR Code</h1>
|
||
<div class="asset-info">
|
||
<strong>Asset ID:</strong> ${b.name}<br/>
|
||
<strong>Asset Name:</strong> ${b.asset_name||"N/A"}
|
||
</div>
|
||
<img src="${He}" alt="QR Code" class="qr-image" onload="window.print();" />
|
||
</div>
|
||
</body>
|
||
</html>
|
||
`),Ae.document.close())},Ot=()=>{const Ae=window.open("","_blank");Ae&&(Ae.document.write(`
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<title>Stay Plugged</title>
|
||
<style>
|
||
@page {
|
||
margin: 0.5in;
|
||
size: auto;
|
||
}
|
||
* {
|
||
margin: 0;
|
||
padding: 0;
|
||
box-sizing: border-box;
|
||
}
|
||
body {
|
||
font-family: Arial, sans-serif;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
min-height: 100vh;
|
||
padding: 0;
|
||
}
|
||
.image-container {
|
||
text-align: center;
|
||
padding: 40px;
|
||
max-width: 100%;
|
||
}
|
||
.stay-plugged-image {
|
||
max-width: 100%;
|
||
height: auto;
|
||
display: block;
|
||
margin: 0 auto;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="image-container">
|
||
<img src="/files/Stay Plugged.jpg" alt="Stay Plugged" class="stay-plugged-image" onload="window.print();" />
|
||
</div>
|
||
</body>
|
||
</html>
|
||
`),Ae.document.close())},Pt=()=>J(null,null,function*(){if(!r||i){alert(e("assets.detail.pleaseSaveFirstForPPM"));return}try{const Ae=yield At.apiCall(`/api/resource/Asset Maintenance Log?filters=[["asset_name","=","${r}"],["maintenance_status","=","Planned"]]&fields=["name","due_date","periodicity","custom_asset_names","asset_name","maintenance_type","assign_to_name"]`),ke=(Ae==null?void 0:Ae.data)||[],Be=(Ce,Pe)=>{const rt=new Date(Ce);return rt.setDate(rt.getDate()+Pe),rt},yt=(Ce,Pe)=>{const rt=new Date(Ce);return rt.setMonth(rt.getMonth()+Pe),rt},Me=(Ce,Pe)=>{const rt=new Date(Ce);return rt.setFullYear(rt.getFullYear()+Pe),rt},Ke=(Ce,Pe)=>{switch(Pe){case"Daily":return Be(Ce,1);case"Weekly":return Be(Ce,7);case"Monthly":return yt(Ce,1);case"Quarterly":return yt(Ce,3);case"Half-yearly":return yt(Ce,6);case"Yearly":return Me(Ce,1);case"2 Yearly":return Me(Ce,2);case"3 Yearly":return Me(Ce,3);default:return yt(Ce,1)}},Xe=Ce=>Ce.toISOString().split("T")[0],oe=Me(new Date,5),_e=[];for(const Ce of ke){let Pe=new Date(Ce.due_date);const rt=Ce.periodicity||"Monthly";for(let ut=0;ut<60&&(_e.push({asset_name:Ce.asset_name||"",custom_asset_names:Ce.custom_asset_names||"",serial_number:c.custom_serial_number||"N/A",due_date:Xe(Pe),periodicity:rt,maintenance_type:Ce.maintenance_type||"",assign_to_name:Ce.assign_to_name||"",status:"Planned"}),Pe=Ke(Pe,rt),!(Pe>oe));ut++);}_e.sort((Ce,Pe)=>new Date(Ce.due_date).getTime()-new Date(Pe.due_date).getTime());const ve=window.open("","_blank");if(!ve)return;const Se=_e.length>0?_e.map((Ce,Pe)=>`
|
||
<tr class="${Pe%2===0?"bg-white":"bg-gray-50"}">
|
||
<td class="border px-3 py-2">${Ce.asset_name}</td>
|
||
<td class="border px-3 py-2">${Ce.custom_asset_names}</td>
|
||
<td class="border px-3 py-2">${Ce.serial_number}</td>
|
||
<td class="border px-3 py-2">${Ce.due_date}</td>
|
||
<td class="border px-3 py-2">${Ce.periodicity}</td>
|
||
<td class="border px-3 py-2">${Ce.maintenance_type}</td>
|
||
<td class="border px-3 py-2">${Ce.assign_to_name}</td>
|
||
<td class="border px-3 py-2">
|
||
<span class="px-2 py-1 bg-yellow-100 text-yellow-800 rounded text-xs">${Ce.status}</span>
|
||
</td>
|
||
</tr>
|
||
`).join(""):'<tr><td colspan="8" class="border px-3 py-4 text-center text-gray-500">No planned maintenance found for this asset</td></tr>';ve.document.write(`
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<title>PPM Plan - ${r}</title>
|
||
<style>
|
||
@page {
|
||
margin: 0.5in;
|
||
size: landscape;
|
||
}
|
||
* {
|
||
margin: 0;
|
||
padding: 0;
|
||
box-sizing: border-box;
|
||
}
|
||
body {
|
||
font-family: Arial, sans-serif;
|
||
padding: 20px;
|
||
background: #f5f5f5;
|
||
}
|
||
.container {
|
||
max-width: 1400px;
|
||
margin: 0 auto;
|
||
background: white;
|
||
padding: 20px;
|
||
border-radius: 8px;
|
||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||
}
|
||
.header {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-bottom: 20px;
|
||
padding-bottom: 15px;
|
||
border-bottom: 2px solid #3b82f6;
|
||
}
|
||
h1 {
|
||
font-size: 24px;
|
||
color: #1f2937;
|
||
}
|
||
.asset-info {
|
||
font-size: 14px;
|
||
color: #6b7280;
|
||
}
|
||
.btn {
|
||
padding: 10px 20px;
|
||
font-size: 14px;
|
||
border: none;
|
||
border-radius: 5px;
|
||
cursor: pointer;
|
||
margin-left: 10px;
|
||
}
|
||
.btn-print {
|
||
background: #3b82f6;
|
||
color: white;
|
||
}
|
||
.btn-print:hover {
|
||
background: #2563eb;
|
||
}
|
||
.btn-close {
|
||
background: #6b7280;
|
||
color: white;
|
||
}
|
||
.btn-close:hover {
|
||
background: #4b5563;
|
||
}
|
||
.table-container {
|
||
overflow-x: auto;
|
||
margin-top: 20px;
|
||
}
|
||
table {
|
||
width: 100%;
|
||
border-collapse: collapse;
|
||
font-size: 13px;
|
||
}
|
||
th {
|
||
background: #3b82f6;
|
||
color: white;
|
||
padding: 12px 8px;
|
||
text-align: left;
|
||
border: 1px solid #2563eb;
|
||
font-weight: 600;
|
||
}
|
||
td {
|
||
border: 1px solid #e5e7eb;
|
||
padding: 8px;
|
||
}
|
||
.bg-white { background: white; }
|
||
.bg-gray-50 { background: #f9fafb; }
|
||
.summary {
|
||
margin-top: 20px;
|
||
padding: 15px;
|
||
background: #f0f9ff;
|
||
border-radius: 5px;
|
||
font-size: 14px;
|
||
color: #1e40af;
|
||
}
|
||
@media print {
|
||
.no-print { display: none; }
|
||
body { background: white; padding: 0; }
|
||
.container { box-shadow: none; padding: 0; }
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="container">
|
||
<div class="header">
|
||
<div>
|
||
<h1>PPM Planner Report</h1>
|
||
<div class="asset-info">
|
||
<strong>Asset ID:</strong> ${r} |
|
||
<strong>Asset Name:</strong> ${c.asset_name||"N/A"} |
|
||
<strong>Generated:</strong> ${new Date().toLocaleDateString()}
|
||
</div>
|
||
</div>
|
||
<div class="no-print">
|
||
<button class="btn btn-print" onclick="window.print()">Print / Save PDF</button>
|
||
<button class="btn btn-close" onclick="window.close()">Close</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="table-container">
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>Asset ID</th>
|
||
<th>Asset Name</th>
|
||
<th>Serial Number</th>
|
||
<th>Due Date</th>
|
||
<th>Periodicity</th>
|
||
<th>Maintenance Type</th>
|
||
<th>Assigned To</th>
|
||
<th>Status</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
${Se}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="summary">
|
||
<strong>Summary:</strong> ${_e.length} planned maintenance entries for the next 5 years
|
||
</div>
|
||
</div>
|
||
</body>
|
||
</html>
|
||
`),ve.document.close()}catch(Ae){console.error("Error fetching PPM Plan:",Ae),alert(e("assets.detail.failedToLoadPPMPlan"))}}),zt=()=>J(null,null,function*(){if(!r||i){alert(e("assets.detail.pleaseSaveFirstForHistory"));return}try{const Ae=yield At.apiCall(`/api/resource/Asset/${r}`),ke=(Ae==null?void 0:Ae.data)||{},Be=yield At.apiCall(`/api/resource/Work_Order?filters=[["asset","=","${r}"]]&fields=["name","work_order_type","repair_status","creation","total_repair_cost"]`),yt=(Be==null?void 0:Be.data)||[],Me=yield At.apiCall(`/api/resource/Asset Maintenance?filters=[["asset_name","=","${r}"]]&fields=["name","maintenance_team","custom_type_of_maintenance"]`),Ke=(Me==null?void 0:Me.data)||[];let Xe=[],oe=[];for(const pt of Ke){const Wt=yield At.apiCall(`/api/resource/Asset Maintenance/${pt.name}`),rr=(Wt==null?void 0:Wt.data)||{};rr.asset_maintenance_tasks&&(oe=[...oe,...rr.asset_maintenance_tasks.map(Br=>je(se({},Br),{maintenance_id:pt.name}))]);const Mr=yield At.apiCall(`/api/resource/Asset Maintenance Log?filters=[["asset_maintenance","=","${pt.name}"]]&fields=["name","maintenance_status","assign_to_name","maintenance_type","due_date","completion_date","periodicity","actions_performed"]&order_by=completion_date desc`);Xe=[...Xe,...(Mr==null?void 0:Mr.data)||[]]}const _e=Xe.filter(pt=>pt.maintenance_status==="Completed"),ve=Xe.filter(pt=>pt.maintenance_status!=="Completed"),Se={};Xe.forEach(pt=>{Se[pt.maintenance_status]=(Se[pt.maintenance_status]||0)+1});const Ce=ke.custom_spare_parts||[],Pe={};Ce.forEach(pt=>{const Wt=pt.work_order||"Unassigned";Pe[Wt]||(Pe[Wt]=[]),Pe[Wt].push(pt)});const rt=window.open("","_blank");if(!rt)return;const ut=yt.length>0?yt.map((pt,Wt)=>{const rr=pt.repair_status==="Completed"?"bg-green-100 text-green-800":pt.repair_status==="Work In Progress"?"bg-yellow-100 text-yellow-800":"bg-gray-100 text-gray-800";return`
|
||
<tr class="${Wt%2===0?"bg-white":"bg-gray-50"}">
|
||
<td class="px-4 py-3 font-medium text-blue-600">${pt.name}</td>
|
||
<td class="px-4 py-3">${pt.work_order_type||"-"}</td>
|
||
<td class="px-4 py-3"><span class="px-2 py-1 rounded-full text-xs font-medium ${rr}">${pt.repair_status||"-"}</span></td>
|
||
<td class="px-4 py-3 font-semibold">${parseFloat(pt.total_repair_cost||0).toFixed(2)} ر.س</td>
|
||
<td class="px-4 py-3 text-gray-500">${pt.creation?new Date(pt.creation).toLocaleDateString():"-"}</td>
|
||
</tr>
|
||
`}).join(""):'<tr><td colspan="5" class="px-4 py-8 text-center text-gray-500">No Work Orders Found</td></tr>';let et="";Object.keys(Pe).length>0?Object.keys(Pe).forEach(pt=>{et+=`
|
||
<div class="mb-4">
|
||
<div class="bg-amber-50 border-l-4 border-amber-400 px-4 py-2 mb-2">
|
||
<span class="font-medium">Work Order: </span>
|
||
<span class="text-blue-600 font-medium">${pt}</span>
|
||
</div>
|
||
<table class="w-full">
|
||
<thead>
|
||
<tr class="bg-gray-100">
|
||
<th class="px-4 py-2 text-left text-xs font-semibold text-gray-600">Item Name</th>
|
||
<th class="px-4 py-2 text-left text-xs font-semibold text-gray-600">Quantity</th>
|
||
<th class="px-4 py-2 text-left text-xs font-semibold text-gray-600">Cost</th>
|
||
<th class="px-4 py-2 text-left text-xs font-semibold text-gray-600">Amount</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
${Pe[pt].map((Wt,rr)=>`
|
||
<tr class="${rr%2===0?"bg-white":"bg-gray-50"}">
|
||
<td class="px-4 py-2">${Wt.item_code||"-"}</td>
|
||
<td class="px-4 py-2">${Wt.qty||0}</td>
|
||
<td class="px-4 py-2">${Wt.rate||0} ر.س</td>
|
||
<td class="px-4 py-2 font-medium">${Wt.amount||0} ر.س</td>
|
||
</tr>
|
||
`).join("")}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
`}):et='<p class="text-gray-500 text-center py-8">No Spare Parts Used</p>';const nt=Ke.length>0?Ke.map(pt=>`
|
||
<div class="bg-white border rounded-lg p-4 mb-3 shadow-sm">
|
||
<div class="flex justify-between items-start">
|
||
<div>
|
||
<p class="text-sm text-gray-500">Maintenance ID</p>
|
||
<p class="font-medium text-blue-600">${pt.name}</p>
|
||
</div>
|
||
<div class="text-right">
|
||
<p class="text-sm text-gray-500">Type</p>
|
||
<p class="font-medium">${pt.custom_type_of_maintenance||"-"}</p>
|
||
</div>
|
||
</div>
|
||
<div class="mt-2">
|
||
<p class="text-sm text-gray-500">Maintenance Team</p>
|
||
<p class="font-medium">${pt.maintenance_team||"-"}</p>
|
||
</div>
|
||
</div>
|
||
`).join(""):'<p class="text-gray-500 text-center py-8">No Maintenance Records Found</p>',ct=oe.length>0?oe.map((pt,Wt)=>`
|
||
<tr class="${Wt%2===0?"bg-white":"bg-gray-50"}">
|
||
<td class="px-4 py-3">${pt.assign_to_name||"-"}</td>
|
||
<td class="px-4 py-3">${pt.periodicity||"-"}</td>
|
||
<td class="px-4 py-3">${pt.next_due_date||"-"}</td>
|
||
<td class="px-4 py-3 text-blue-600 text-sm">${pt.maintenance_id||"-"}</td>
|
||
</tr>
|
||
`).join(""):'<tr><td colspan="4" class="px-4 py-8 text-center text-gray-500">No Maintenance Tasks Found</td></tr>',$t=Object.keys(Se).length>0?Object.entries(Se).map(([pt,Wt])=>`
|
||
<div class="flex items-center justify-between p-3 rounded-lg border ${pt==="Completed"?"bg-green-100 text-green-800 border-green-200":pt==="Planned"?"bg-blue-100 text-blue-800 border-blue-200":"bg-yellow-100 text-yellow-800 border-yellow-200"}">
|
||
<span class="font-medium">${pt}</span>
|
||
<span class="text-2xl font-bold">${Wt}</span>
|
||
</div>
|
||
`).join(""):'<p class="text-gray-500 text-center">No Data</p>',Ut=_e.length>0?_e.map((pt,Wt)=>`
|
||
<tr class="${Wt%2===0?"bg-white":"bg-gray-50"}">
|
||
<td class="px-3 py-2 text-blue-600 font-medium">${pt.name}</td>
|
||
<td class="px-3 py-2">${pt.assign_to_name||"-"}</td>
|
||
<td class="px-3 py-2">${pt.maintenance_type||"-"}</td>
|
||
<td class="px-3 py-2">${pt.due_date||"-"}</td>
|
||
<td class="px-3 py-2 text-green-600 font-medium">${pt.completion_date||"-"}</td>
|
||
<td class="px-3 py-2">${pt.periodicity||"-"}</td>
|
||
<td class="px-3 py-2 text-sm text-gray-600">${pt.actions_performed||"-"}</td>
|
||
</tr>
|
||
`).join(""):'<tr><td colspan="7" class="px-4 py-8 text-center text-gray-500">No Completed Maintenance Logs</td></tr>',Xt=ve.length>0?ve.map((pt,Wt)=>{const rr=pt.maintenance_status==="Planned"?"bg-blue-100 text-blue-800":"bg-yellow-100 text-yellow-800";return`
|
||
<tr class="${Wt%2===0?"bg-white":"bg-gray-50"}">
|
||
<td class="px-3 py-2 text-blue-600 font-medium">${pt.name}</td>
|
||
<td class="px-3 py-2">${pt.assign_to_name||"-"}</td>
|
||
<td class="px-3 py-2">${pt.maintenance_type||"-"}</td>
|
||
<td class="px-3 py-2">${pt.due_date||"-"}</td>
|
||
<td class="px-3 py-2">${pt.periodicity||"-"}</td>
|
||
<td class="px-3 py-2"><span class="px-2 py-1 rounded-full text-xs font-medium ${rr}">${pt.maintenance_status||"-"}</span></td>
|
||
<td class="px-3 py-2 text-sm text-gray-600">${pt.actions_performed||"-"}</td>
|
||
</tr>
|
||
`}).join(""):'<tr><td colspan="7" class="px-4 py-8 text-center text-gray-500">No Pending/Planned Maintenance Logs</td></tr>';rt.document.write(`
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<title>Asset History - ${r}</title>
|
||
<script src="https://cdn.tailwindcss.com"><\/script>
|
||
<style>
|
||
@page { margin: 0.5in; size: landscape; }
|
||
@media print {
|
||
.no-print { display: none !important; }
|
||
.page-break { page-break-before: always; }
|
||
}
|
||
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
|
||
.section-card {
|
||
background: white;
|
||
border-radius: 12px;
|
||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||
margin-bottom: 24px;
|
||
overflow: hidden;
|
||
}
|
||
.section-header {
|
||
padding: 16px 20px;
|
||
font-weight: 600;
|
||
font-size: 16px;
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 10px;
|
||
}
|
||
.section-content {
|
||
padding: 16px 20px;
|
||
}
|
||
table {
|
||
width: 100%;
|
||
border-collapse: collapse;
|
||
}
|
||
th {
|
||
text-align: left;
|
||
padding: 12px 16px;
|
||
font-size: 12px;
|
||
font-weight: 600;
|
||
text-transform: uppercase;
|
||
letter-spacing: 0.5px;
|
||
}
|
||
td {
|
||
border-top: 1px solid #e5e7eb;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body class="bg-gray-100 min-h-screen">
|
||
<!-- Header -->
|
||
<div class="bg-gradient-to-r from-blue-600 to-blue-800 text-white py-6 px-8 no-print">
|
||
<div class="max-w-7xl mx-auto flex justify-between items-center">
|
||
<div>
|
||
<h1 class="text-2xl font-bold">Asset History</h1>
|
||
<p class="text-blue-200 mt-1">Complete history and maintenance records</p>
|
||
</div>
|
||
<div class="flex gap-3">
|
||
<button onclick="window.print()" class="bg-white text-blue-600 px-4 py-2 rounded-lg font-medium hover:bg-blue-50 transition">
|
||
🖨️ Print / Save PDF
|
||
</button>
|
||
<button onclick="window.close()" class="bg-blue-700 text-white px-4 py-2 rounded-lg font-medium hover:bg-blue-600 transition">
|
||
✕ Close
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="max-w-7xl mx-auto py-6 px-8">
|
||
<!-- Asset Details Card -->
|
||
<div class="section-card">
|
||
<div class="section-header bg-gradient-to-r from-blue-500 to-blue-600 text-white">
|
||
<span>🔍</span> Asset Details
|
||
</div>
|
||
<div class="section-content">
|
||
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4">
|
||
<div class="bg-gray-50 rounded-lg p-4">
|
||
<p class="text-xs text-gray-500 uppercase tracking-wide">Asset ID</p>
|
||
<p class="font-semibold text-blue-600 mt-1">${r}</p>
|
||
</div>
|
||
<div class="bg-gray-50 rounded-lg p-4">
|
||
<p class="text-xs text-gray-500 uppercase tracking-wide">Asset Name</p>
|
||
<p class="font-semibold mt-1">${ke.asset_name||"-"}</p>
|
||
</div>
|
||
<div class="bg-gray-50 rounded-lg p-4">
|
||
<p class="text-xs text-gray-500 uppercase tracking-wide">🏥 Hospital</p>
|
||
<p class="font-semibold mt-1">${ke.company||"-"}</p>
|
||
</div>
|
||
<div class="bg-gray-50 rounded-lg p-4">
|
||
<p class="text-xs text-gray-500 uppercase tracking-wide">📍 Location</p>
|
||
<p class="font-semibold mt-1">${ke.location||"-"}</p>
|
||
</div>
|
||
<div class="bg-gray-50 rounded-lg p-4">
|
||
<p class="text-xs text-gray-500 uppercase tracking-wide">🚛 Supplier</p>
|
||
<p class="font-semibold mt-1">${ke.supplier||"-"}</p>
|
||
</div>
|
||
<div class="bg-amber-50 rounded-lg p-4 border border-amber-200">
|
||
<p class="text-xs text-amber-600 uppercase tracking-wide">💰 Total Repair Cost</p>
|
||
<p class="font-bold text-amber-700 mt-1 text-lg">${ke.custom_total_spare_parts_amount||0} ر.س</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Two Column Layout -->
|
||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||
<!-- Work Orders -->
|
||
<div class="section-card">
|
||
<div class="section-header bg-gradient-to-r from-indigo-500 to-indigo-600 text-white">
|
||
<span>🔗</span> Linked Work Orders
|
||
</div>
|
||
<div class="overflow-x-auto">
|
||
<table>
|
||
<thead class="bg-gray-50">
|
||
<tr>
|
||
<th class="text-gray-600">Work Order No</th>
|
||
<th class="text-gray-600">Type</th>
|
||
<th class="text-gray-600">Status</th>
|
||
<th class="text-gray-600">Repair Cost</th>
|
||
<th class="text-gray-600">Created</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
${ut}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Spare Parts -->
|
||
<div class="section-card">
|
||
<div class="section-header bg-gradient-to-r from-orange-500 to-orange-600 text-white">
|
||
<span>🛠️</span> Items Used for Repair
|
||
</div>
|
||
<div class="section-content max-h-96 overflow-y-auto">
|
||
${et}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Maintenance Section -->
|
||
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mt-6">
|
||
<!-- Maintenance Records -->
|
||
<div class="section-card">
|
||
<div class="section-header bg-gradient-to-r from-teal-500 to-teal-600 text-white">
|
||
<span>🛠️</span> Maintenance Records
|
||
</div>
|
||
<div class="section-content max-h-80 overflow-y-auto">
|
||
${nt}
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Maintenance Tasks -->
|
||
<div class="section-card lg:col-span-2">
|
||
<div class="section-header bg-gradient-to-r from-purple-500 to-purple-600 text-white">
|
||
<span>📋</span> Maintenance Tasks
|
||
</div>
|
||
<div class="overflow-x-auto">
|
||
<table>
|
||
<thead class="bg-gray-50">
|
||
<tr>
|
||
<th class="text-gray-600">Assigned To</th>
|
||
<th class="text-gray-600">Periodicity</th>
|
||
<th class="text-gray-600">Next Due Date</th>
|
||
<th class="text-gray-600">Maintenance ID</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
${ct}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Periodic Maintenance Summary -->
|
||
<div class="section-card mt-6">
|
||
<div class="section-header bg-gradient-to-r from-cyan-500 to-cyan-600 text-white">
|
||
<span>📜</span> Periodic Maintenance Summary
|
||
</div>
|
||
<div class="section-content">
|
||
<div class="grid grid-cols-2 md:grid-cols-4 gap-4">
|
||
${$t}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Completed Maintenance Logs -->
|
||
<div class="section-card mt-6">
|
||
<div class="section-header bg-gradient-to-r from-green-500 to-green-600 text-white">
|
||
<span>✅</span> Completed Maintenance Logs
|
||
</div>
|
||
<div class="overflow-x-auto">
|
||
<table>
|
||
<thead class="bg-gray-50">
|
||
<tr>
|
||
<th class="text-gray-600">Log ID</th>
|
||
<th class="text-gray-600">Assigned To</th>
|
||
<th class="text-gray-600">Type</th>
|
||
<th class="text-gray-600">Due Date</th>
|
||
<th class="text-gray-600">Completed</th>
|
||
<th class="text-gray-600">Periodicity</th>
|
||
<th class="text-gray-600">Actions</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
${Ut}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Pending/Planned Maintenance Logs -->
|
||
<div class="section-card mt-6">
|
||
<div class="section-header bg-gradient-to-r from-amber-500 to-amber-600 text-white">
|
||
<span>⏳</span> Pending/Planned Maintenance Logs
|
||
</div>
|
||
<div class="overflow-x-auto">
|
||
<table>
|
||
<thead class="bg-gray-50">
|
||
<tr>
|
||
<th class="text-gray-600">Log ID</th>
|
||
<th class="text-gray-600">Assigned To</th>
|
||
<th class="text-gray-600">Type</th>
|
||
<th class="text-gray-600">Due Date</th>
|
||
<th class="text-gray-600">Periodicity</th>
|
||
<th class="text-gray-600">Status</th>
|
||
<th class="text-gray-600">Actions</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
${Xt}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Footer -->
|
||
<div class="text-center text-gray-500 text-sm mt-8 pb-8">
|
||
Generated on ${new Date().toLocaleString()} | Asset: ${r}
|
||
</div>
|
||
</div>
|
||
</body>
|
||
</html>
|
||
`),rt.document.close()}catch(Ae){console.error("Error fetching Asset History:",Ae),alert("Failed to load Asset History. Please try again.")}}),Tt=()=>{if(!r||i){alert("Please save the asset first to view Installation Report");return}const Ae=window.open("","_blank");if(!Ae)return;const ke=new Date,Be=Xe=>{const oe=String(Xe.getDate()).padStart(2,"0"),_e=String(Xe.getMonth()+1).padStart(2,"0"),ve=Xe.getFullYear();return`${oe}/${_e}/${ve}`},yt=(b==null?void 0:b.custom_spare_parts)||[];let Me="";const Ke=3;if(yt.length>0){yt.forEach((Xe,oe)=>{Me+=`
|
||
<tr>
|
||
<td>${oe+1}</td>
|
||
<td>${Xe.item_name||""}</td>
|
||
<td>${Xe.item_code||""}</td>
|
||
<td>${Xe.uom||""}</td>
|
||
<td>${Xe.qty||""}</td>
|
||
</tr>
|
||
`});for(let Xe=yt.length;Xe<Ke;Xe++)Me+=`
|
||
<tr>
|
||
<td>${Xe+1}</td>
|
||
<td> </td>
|
||
<td> </td>
|
||
<td> </td>
|
||
<td> </td>
|
||
</tr>
|
||
`}else for(let Xe=0;Xe<Ke;Xe++)Me+=`
|
||
<tr>
|
||
<td>${Xe+1}</td>
|
||
<td> </td>
|
||
<td> </td>
|
||
<td> </td>
|
||
<td> </td>
|
||
</tr>
|
||
`;Ae.document.write(`
|
||
<!DOCTYPE html>
|
||
<html lang="ar" dir="rtl">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>Installation Report - ${r}</title>
|
||
<style>
|
||
@page {
|
||
margin: 0.5in;
|
||
size: A4;
|
||
}
|
||
body {
|
||
font-family: 'Times New Roman', serif;
|
||
margin: 0;
|
||
padding: 20px;
|
||
font-size: 12px;
|
||
line-height: 1.3;
|
||
direction: rtl;
|
||
text-align: right;
|
||
}
|
||
|
||
.header-line {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-bottom: 5px;
|
||
}
|
||
|
||
.header-right {
|
||
font-weight: bold;
|
||
}
|
||
|
||
.header-center {
|
||
font-weight: bold;
|
||
text-align: center;
|
||
flex-grow: 1;
|
||
}
|
||
|
||
.header-left {
|
||
font-weight: bold;
|
||
}
|
||
|
||
.dotted-line {
|
||
border-bottom: 1px dotted #000;
|
||
display: inline-block;
|
||
min-width: 100px;
|
||
}
|
||
|
||
.main-content {
|
||
margin: 15px 0;
|
||
text-align: justify;
|
||
}
|
||
|
||
.equipment-section {
|
||
margin: 15px 0;
|
||
}
|
||
|
||
.equipment-line {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
margin: 8px 0;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.equipment-item {
|
||
display: flex;
|
||
align-items: center;
|
||
direction: ltr;
|
||
text-align: left;
|
||
width: 48%;
|
||
}
|
||
|
||
.arabic-label {
|
||
direction: rtl;
|
||
text-align: right;
|
||
margin-left: 10px;
|
||
}
|
||
|
||
.colon {
|
||
margin: 0 5px;
|
||
}
|
||
|
||
.field-value {
|
||
border-bottom: 1px solid #000;
|
||
min-width: 120px;
|
||
display: inline-block;
|
||
height: 18px;
|
||
}
|
||
|
||
.location-line {
|
||
margin: 10px 0;
|
||
font-weight: bold;
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
width: 100%;
|
||
}
|
||
|
||
.location-arabic {
|
||
direction: rtl;
|
||
text-align: right;
|
||
}
|
||
|
||
.location-english {
|
||
direction: ltr;
|
||
text-align: left;
|
||
}
|
||
|
||
.parts-table {
|
||
width: 100%;
|
||
border-collapse: collapse;
|
||
margin: 15px 0;
|
||
border: 2px solid #000;
|
||
}
|
||
|
||
.parts-table th,
|
||
.parts-table td {
|
||
border: 1px solid #000;
|
||
padding: 6px;
|
||
text-align: center;
|
||
font-weight: bold;
|
||
vertical-align: middle;
|
||
}
|
||
|
||
.parts-table th {
|
||
background-color: #f8f8f8;
|
||
font-size: 11px;
|
||
}
|
||
|
||
.parts-table .row-number {
|
||
width: 8%;
|
||
}
|
||
|
||
.parts-table .description {
|
||
width: 35%;
|
||
}
|
||
|
||
.parts-table .part-number {
|
||
width: 25%;
|
||
}
|
||
|
||
.parts-table .unit {
|
||
width: 16%;
|
||
}
|
||
|
||
.parts-table .quantity {
|
||
width: 16%;
|
||
}
|
||
|
||
.footer-text {
|
||
margin: 20px 0;
|
||
text-align: justify;
|
||
}
|
||
|
||
.signatures-section {
|
||
margin-top: 40px;
|
||
}
|
||
|
||
.signature-row {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
margin: 30px 0;
|
||
}
|
||
|
||
.signature-block-right {
|
||
text-align: left;
|
||
width: 45%;
|
||
float: right;
|
||
}
|
||
|
||
.signature-block-left {
|
||
text-align: left;
|
||
width: 45%;
|
||
float: left;
|
||
}
|
||
|
||
.signature-title {
|
||
font-weight: bold;
|
||
margin-bottom: 3px;
|
||
font-size: 11px;
|
||
}
|
||
|
||
.signature-line {
|
||
border-bottom: 1px solid #000;
|
||
height: 25px;
|
||
margin: 8px 0;
|
||
display: inline-block;
|
||
width: 120px;
|
||
margin-left: 10px;
|
||
}
|
||
|
||
.signature-label {
|
||
font-size: 10px;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.seal-section {
|
||
text-align: center;
|
||
margin-top: 30px;
|
||
font-weight: bold;
|
||
font-size: 12px;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<!-- Header Section -->
|
||
<div class="header-line">
|
||
<div class="header-right">المملكة العربية السعودية</div>
|
||
<div class="header-center"></div>
|
||
<div class="header-left">الرقم: <span class="dotted-line">${r||""}</span></div>
|
||
</div>
|
||
|
||
<div class="header-line">
|
||
<div class="header-right">تجمع الجوف الصحي</div>
|
||
<div class="header-center">محضر تركيب</div>
|
||
<div class="header-left">التاريخ: <span class="dotted-line">${Be(ke)}</span> هـ</div>
|
||
</div>
|
||
|
||
<div class="header-line">
|
||
<div class="header-right">الصيانة الطبية</div>
|
||
<div class="header-center">INSTALLATION REPORT</div>
|
||
<div class="header-left">الموافق: <span class="dotted-line">${Be(ke)}</span> م</div>
|
||
</div>
|
||
|
||
<div style="margin: 15px 0; font-weight: bold;">
|
||
مستشفى <span class="dotted-line" style="min-width: 200px;">${c.company||""}</span>
|
||
</div>
|
||
|
||
<!-- Main Content -->
|
||
<div class="main-content">
|
||
تشهد مستشفى <span class="dotted-line" style="min-width: 180px;">${c.company||""}</span> بأن <span class="dotted-line" style="min-width: 180px;">${c.supplier||""}</span> قامت بتركيب و توريد قطع الغيار الخاصة التالية والتابعة:
|
||
</div>
|
||
|
||
<!-- Equipment Information -->
|
||
<div class="equipment-section">
|
||
<div class="equipment-line">
|
||
<div class="equipment-item">
|
||
<span>EQUIPMENT NAME</span>
|
||
<span class="colon">:</span>
|
||
<span class="field-value">${c.asset_name||""}</span>
|
||
<span class="arabic-label">اسم الجهاز:</span>
|
||
</div>
|
||
<div class="equipment-item">
|
||
<span>MFR</span>
|
||
<span class="colon">:</span>
|
||
<span class="field-value">${c.custom_manufacturer||""}</span>
|
||
<span class="arabic-label">صناعة:</span>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="equipment-line">
|
||
<div class="equipment-item">
|
||
<span>SERIAL NO</span>
|
||
<span class="colon">:</span>
|
||
<span class="field-value">${c.custom_serial_number||""}</span>
|
||
<span class="arabic-label">مسلسل:</span>
|
||
</div>
|
||
<div class="equipment-item">
|
||
<span>MODEL</span>
|
||
<span class="colon">:</span>
|
||
<span class="field-value">${c.custom_model||""}</span>
|
||
<span class="arabic-label">موديل:</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="location-line">
|
||
<span class="location-arabic">
|
||
التابع لقسم:
|
||
</span>
|
||
<span class="field-value" style="min-width: 300px; flex-grow: 1; margin: 0 10px; text-align: left;">${c.location||""}</span>
|
||
<span class="location-english">
|
||
LOCATION:
|
||
</span>
|
||
</div>
|
||
|
||
<!-- Parts Table -->
|
||
<table class="parts-table">
|
||
<thead>
|
||
<tr>
|
||
<th class="row-number">م</th>
|
||
<th class="description">وصف القطعة<br>DESCRIPTION</th>
|
||
<th class="part-number">رقم القطعة<br>PART NO.</th>
|
||
<th class="unit">الوحدة<br>UNIT</th>
|
||
<th class="quantity">الكمية<br>QTY.</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
${Me}
|
||
</tbody>
|
||
</table>
|
||
|
||
<!-- Footer Text -->
|
||
<div class="footer-text">
|
||
وذلك طبقا لعقد صيانة وإصلاح الأجهزة الطبية بمستشفى <span class="dotted-line" style="min-width: 150px;">${c.company||""}</span> والجهاز يعمل بحالة جيدة.
|
||
<br><br>
|
||
وﷲ الموفق .....
|
||
</div>
|
||
|
||
<!-- Signatures Section -->
|
||
<div class="signatures-section">
|
||
<!-- First Row -->
|
||
<div class="signature-row">
|
||
<div class="signature-block-right">
|
||
<div class="signature-title">المسئول في القسم Dept. Responsible</div>
|
||
<div><span class="signature-line"></span><span class="signature-label">Name</span></div>
|
||
<div><span class="signature-line"></span><span class="signature-label">Sign</span></div>
|
||
</div>
|
||
|
||
<div class="signature-block-left">
|
||
<div class="signature-title">مدير شركة سمامة Site Manager</div>
|
||
<div><span class="signature-line"></span><span class="signature-label">Name</span></div>
|
||
<div><span class="signature-line"></span><span class="signature-label">Sign</span></div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Installation Engineer - Right aligned -->
|
||
<div style="text-align: left; margin: 25px 0; width: 45%; float: right; clear: both;">
|
||
<div class="signature-title">مهندس/ فني التركيب Installation Eng</div>
|
||
<div><span class="signature-line"></span><span class="signature-label">Name</span></div>
|
||
<div><span class="signature-line"></span><span class="signature-label">Sign</span></div>
|
||
</div>
|
||
<div style="clear: both;"></div>
|
||
|
||
<!-- Second Row -->
|
||
<div class="signature-row">
|
||
<div class="signature-block-right">
|
||
<div class="signature-title">مشرف الوزارة بالمستشفى Hospital Supervisor</div>
|
||
<div><span class="signature-line"></span><span class="signature-label">Name</span></div>
|
||
<div><span class="signature-line"></span><span class="signature-label">Sign</span></div>
|
||
</div>
|
||
|
||
<div class="signature-block-left">
|
||
<div class="signature-title">مدير المستشفى/ المركز Hospital Manager</div>
|
||
<div><span class="signature-line"></span><span class="signature-label">Name</span></div>
|
||
<div><span class="signature-line"></span><span class="signature-label">Sign</span></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Official Seal -->
|
||
<div class="seal-section">
|
||
الختم الرسمي
|
||
</div>
|
||
|
||
<script>
|
||
window.onload = function() {
|
||
window.print();
|
||
};
|
||
<\/script>
|
||
</body>
|
||
</html>
|
||
`),Ae.document.close()},Gt=()=>{if(!r||i){alert("Please save the asset first to view Dismantling Report");return}const Ae=window.open("","_blank");if(!Ae)return;const ke=new Date,Be=Ke=>{const Xe=String(Ke.getDate()).padStart(2,"0"),oe=String(Ke.getMonth()+1).padStart(2,"0"),_e=Ke.getFullYear();return`${Xe}/${oe}/${_e}`},yt=b!=null&&b.creation?new Date(b.creation):null;let Me="";if(yt){const Ke=Math.floor((ke.getTime()-yt.getTime())/31536e6),Xe=Math.floor((ke.getTime()-yt.getTime())%(1e3*60*60*24*365)/(1e3*60*60*24*30));Me=`${Ke} سنة و ${Xe} شهر`}Ae.document.write(`
|
||
<!DOCTYPE html>
|
||
<html lang="ar" dir="rtl">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>Dismantling Report - ${r}</title>
|
||
<style>
|
||
@page {
|
||
margin: 0.5in;
|
||
size: A4;
|
||
}
|
||
body {
|
||
font-family: 'Times New Roman', serif;
|
||
margin: 0;
|
||
padding: 20px;
|
||
font-size: 12px;
|
||
line-height: 1.4;
|
||
direction: rtl;
|
||
text-align: right;
|
||
}
|
||
|
||
.header {
|
||
text-align: left;
|
||
margin-bottom: 30px;
|
||
}
|
||
|
||
.title {
|
||
text-align: center;
|
||
font-size: 14px;
|
||
font-weight: bold;
|
||
margin: 20px 0;
|
||
}
|
||
|
||
.department-line {
|
||
margin: 15px 0;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.section-title {
|
||
font-weight: bold;
|
||
margin: 20px 0 10px 0;
|
||
}
|
||
|
||
.reasons-section {
|
||
margin: 20px 0;
|
||
}
|
||
|
||
.reasons-table {
|
||
width: 60%;
|
||
border-collapse: collapse;
|
||
margin: 10px 0;
|
||
}
|
||
|
||
.reasons-table td {
|
||
border: 2px solid #000;
|
||
padding: 8px;
|
||
text-align: center;
|
||
font-weight: bold;
|
||
width: 16.66%;
|
||
height: 30px;
|
||
}
|
||
|
||
.reason-text {
|
||
margin: 8px 0;
|
||
text-align: right;
|
||
font-size: 11px;
|
||
direction: rtl;
|
||
word-wrap: break-word;
|
||
overflow-wrap: break-word;
|
||
}
|
||
|
||
.committee-opinion {
|
||
margin: 20px 0;
|
||
padding: 10px;
|
||
border: 1px solid #ccc;
|
||
text-align: justify;
|
||
}
|
||
|
||
.signatures-table {
|
||
width: 100%;
|
||
border-collapse: collapse;
|
||
margin: 20px 0;
|
||
}
|
||
|
||
.signatures-table td {
|
||
padding: 8px;
|
||
text-align: right;
|
||
vertical-align: top;
|
||
font-weight: bold;
|
||
direction: rtl;
|
||
word-wrap: break-word;
|
||
overflow-wrap: break-word;
|
||
}
|
||
|
||
.signature-title {
|
||
font-size: 11px;
|
||
height: 30px;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.signature-field {
|
||
height: 25px;
|
||
font-size: 10px;
|
||
}
|
||
|
||
.hospital-manager {
|
||
text-align: right;
|
||
margin: 20px 0;
|
||
}
|
||
|
||
.hospital-manager-table {
|
||
width: 100%;
|
||
margin: 0;
|
||
border-collapse: collapse;
|
||
float: right;
|
||
}
|
||
|
||
.hospital-manager-table td {
|
||
padding: 8px;
|
||
text-align: right;
|
||
font-weight: bold;
|
||
direction: rtl;
|
||
word-wrap: break-word;
|
||
overflow-wrap: break-word;
|
||
}
|
||
|
||
.seal-section {
|
||
text-align: center;
|
||
margin: 30px 0;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.footer {
|
||
margin-top: 40px;
|
||
text-align: right;
|
||
}
|
||
|
||
.footer-title {
|
||
font-weight: bold;
|
||
margin-bottom: 5px;
|
||
color: #0066cc;
|
||
}
|
||
|
||
.footer-name {
|
||
font-size: 11px;
|
||
color: #0066cc;
|
||
}
|
||
|
||
.logo {
|
||
width: 100px;
|
||
height: 60px;
|
||
margin: 0;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.logo img {
|
||
max-width: 100%;
|
||
max-height: 100%;
|
||
object-fit: contain;
|
||
}
|
||
|
||
.equipment-table {
|
||
width: 100%;
|
||
border: 1px solid black;
|
||
border-collapse: collapse;
|
||
}
|
||
|
||
.equipment-table td {
|
||
width: 25%;
|
||
border: 1px solid black;
|
||
padding: 8px;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<!-- Header Section -->
|
||
<div class="header">
|
||
<div class="logo"><img src='/files/SEMH!.png' onerror="this.style.display='none'"></div>
|
||
</div>
|
||
|
||
<!-- Title -->
|
||
<div class="title">
|
||
محضر تكهين / إبعاد عن الخدمة
|
||
</div>
|
||
|
||
<!-- Department -->
|
||
<div class="department-line">
|
||
القسم : <span style="border-bottom: 1px solid #000; min-width: 200px; display: inline-block;">${c.department||""}</span>
|
||
</div>
|
||
|
||
<!-- Equipment Data Section -->
|
||
<div class="section-title">0-1 بيانات الجهاز المطلوب تكهينه :</div>
|
||
|
||
<table class="equipment-table">
|
||
<tr>
|
||
<td>اسم الجهاز</td>
|
||
<td>${c.asset_name||""}</td>
|
||
<td>الرقم التسلسلي</td>
|
||
<td>${c.custom_serial_number||""}</td>
|
||
</tr>
|
||
<tr>
|
||
<td>الشركة الصانعة</td>
|
||
<td>${c.custom_manufacturer||""}</td>
|
||
<td>تاريخ التوريد</td>
|
||
<td>${yt?Be(yt):""}</td>
|
||
</tr>
|
||
<tr>
|
||
<td>الطراز/الموديل</td>
|
||
<td>${c.custom_model||""}</td>
|
||
<td>مدة استخدام الجهاز</td>
|
||
<td>${Me}</td>
|
||
</tr>
|
||
</table>
|
||
|
||
<!-- Reasons Section -->
|
||
<div class="section-title">2- أسباب طلب التكهين / إبعاد عن الخدمة :</div>
|
||
|
||
<table class="reasons-table">
|
||
<tr>
|
||
<td>أ</td>
|
||
<td>ب</td>
|
||
<td>ج</td>
|
||
<td>د</td>
|
||
<td>هـ</td>
|
||
<td>و</td>
|
||
</tr>
|
||
<tr>
|
||
<td> </td>
|
||
<td> </td>
|
||
<td> </td>
|
||
<td> </td>
|
||
<td> </td>
|
||
<td> </td>
|
||
</tr>
|
||
</table>
|
||
|
||
<div class="reason-text">
|
||
أ) تكاليف قطع الغيار المطلوبة للإصلاح أكثر من نصف قيمة الجهاز (مرفق عرض أسعار قطع الغيار اللازمة للإصلاح).
|
||
</div>
|
||
<div class="reason-text">
|
||
ب) توقف انتاج الجهاز وقطع الغيار من الشركة الصانعة حسب تقرير المورد.
|
||
</div>
|
||
<div class="reason-text">
|
||
ج) جهاز قديم وتم استخدامه أكثر من عشر سنوات.
|
||
</div>
|
||
<div class="reason-text">
|
||
د) ليس للجهاز وكيل معروف بالمملكة في الوقت الحالي ولا يمكن توفير قطع غيار للجهاز.
|
||
</div>
|
||
<div class="reason-text">
|
||
ه) تكرار أعطال الجهاز وإصلاحه على فترات متقاربة.
|
||
</div>
|
||
<div class="reason-text">
|
||
و) أخرى : <span style="border-bottom: 1px solid #000; min-width: 300px; display: inline-block;"></span>
|
||
</div>
|
||
|
||
<!-- Committee Opinion -->
|
||
<div class="section-title">3- مرئيات اللجنة:</div>
|
||
<div class="reason-text">
|
||
بناءاً على الفقرة أ. ج. و. يتم تكهين الجهاز وادراجه ضمن بنود الإحلال المطلوبة للمستشفى.
|
||
</div>
|
||
|
||
<!-- Signatures Section -->
|
||
<div class="section-title">توقيع اللجنة :</div>
|
||
|
||
<table class="signatures-table">
|
||
<tr>
|
||
<td class="signature-title">المقاول</td>
|
||
<td class="signature-title">رئيس القسم</td>
|
||
<td class="signature-title">مدير الصيانة الطبية</td>
|
||
<td class="signature-title">مدير مراقبة المخزون</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="signature-field">الإسم :</td>
|
||
<td class="signature-field">الإسم :</td>
|
||
<td class="signature-field">الإسم :</td>
|
||
<td class="signature-field">الإسم :</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="signature-field">التوقيع :</td>
|
||
<td class="signature-field">التوقيع :</td>
|
||
<td class="signature-field">التوقيع :</td>
|
||
<td class="signature-field">التوقيع :</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="signature-field">التاريخ :</td>
|
||
<td class="signature-field">التاريخ :</td>
|
||
<td class="signature-field">التاريخ :</td>
|
||
<td class="signature-field">التاريخ :</td>
|
||
</tr>
|
||
</table>
|
||
|
||
<!-- Hospital Manager Section -->
|
||
<div class="hospital-manager">
|
||
<table class="hospital-manager-table">
|
||
<tr>
|
||
<td class="signature-title">مدير مستشفى</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="signature-field">الإسم :</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="signature-field">التوقيع :</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="signature-field">التاريخ :</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="signature-field">الختم :</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<!-- Arabic text after last table -->
|
||
<div style="clear: both; text-align: left; margin: 20px 0;">
|
||
<div style="font-weight: bold; margin-bottom: 5px;">الصيانة الطبية بتجمع الجوف الصحي</div>
|
||
<div>المهندس/عبد العزيز زايد الخمعلي</div>
|
||
</div>
|
||
|
||
<!-- Footer -->
|
||
<div class="footer">
|
||
<div style="color: #0066cc; font-weight: bold;">تجمع الجوف الصحي</div>
|
||
<div style="color: #0066cc;">Aljouf Health Cluster</div>
|
||
</div>
|
||
|
||
<script>
|
||
window.onload = function() {
|
||
window.print();
|
||
};
|
||
<\/script>
|
||
</body>
|
||
</html>
|
||
`),Ae.document.close()};return t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("button",{onClick:()=>a(-1),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-2",children:[t.jsx(ia,{}),t.jsx("span",{className:"text-gray-900 dark:text-white font-medium",children:o?"Duplicate Asset":i?"New Asset Details":"Asset Details"})]}),b&&t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${ee(T).bg} ${ee(T).text} ${ee(T).border} border`,children:T})})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[!i&&!ne&&!H&&V&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative",ref:me,children:[t.jsxs("button",{onClick:()=>ie(!Q),className:"bg-blue-600 hover:bg-blue-700 text-white px-2 py-1 rounded-lg flex items-center gap-2",children:["Actions",t.jsx(Fr,{size:12,className:`transition-transform ${Q?"rotate-180":""}`})]}),Q&&t.jsx("div",{className:"absolute right-0 mt-2 w-56 bg-white dark:bg-gray-800 rounded-md shadow-lg z-50 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"py-1",children:[He&&t.jsxs("button",{onClick:()=>{Mt(),ie(!1)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(Hu,{size:14}),"Print QR"]}),t.jsxs("button",{onClick:()=>{Ot(),ie(!1)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(Hu,{size:14}),"Stay Plugged"]}),t.jsxs("button",{onClick:()=>{Pt(),ie(!1)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(rc,{size:14}),"PPM Plan"]}),t.jsxs("button",{onClick:()=>{zt(),ie(!1)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(ym,{size:14}),"Asset History"]}),t.jsxs("button",{onClick:()=>{Tt(),ie(!1)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(X4,{size:14}),"Installation Report"]}),(b==null?void 0:b.status)==="Scrapped"&&t.jsxs("button",{onClick:()=>{Gt(),ie(!1)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-red-50 dark:hover:bg-red-900/20 flex items-center gap-2 text-red-600 dark:text-red-400 border-t border-gray-200 dark:border-gray-700",children:[t.jsx(KG,{size:14}),"Dismantling Report"]})]})})]}),I&&!re&&t.jsxs("button",{onClick:()=>te(!0),className:"bg-blue-600 hover:bg-blue-700 text-white px-2 py-1 rounded-lg flex items-center gap-2",children:[t.jsx(qr,{}),"Edit"]}),U&&B&&t.jsxs("button",{onClick:st,disabled:O,className:"bg-purple-600 hover:bg-purple-700 text-white px-2 py-1 rounded-lg flex items-center gap-2 disabled:opacity-50",children:[t.jsx(Oc,{}),O?"Submitting...":"Submit"]})]}),H&&t.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 italic",children:"Cancelled documents cannot be edited"}),ne&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{i?a(-1):te(!1)},className:"bg-gray-300 hover:bg-gray-400 text-gray-700 dark:text-gray-800 px-2 py-1 rounded-lg",disabled:O,children:"Cancel"}),t.jsxs("button",{onClick:Ve,disabled:O,className:"bg-green-600 hover:bg-green-700 text-white px-2 py-1 rounded-lg flex items-center gap-2 disabled:opacity-50",children:[t.jsx(ta,{}),O?"Saving...":"Save Changes"]})]})]})]}),t.jsxs("form",{onSubmit:Ve,children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:e("assets.detail.assetInformation")}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:[e("assets.detail.assetName")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",name:"asset_name",value:c.asset_name,onChange:Ue,placeholder:e("assets.detail.placeholderAssetName"),required:!0,disabled:he("asset_name"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsx("input",{type:"hidden",name:"custom_asset_type",value:"Non Biomedical"}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Category"}),t.jsx("select",{name:"custom_category",value:c.custom_category||"General",onChange:Ue,disabled:he("custom_category"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:t.jsx("option",{value:"General",children:"General"})})]}),t.jsx(Je,{label:e("assets.detail.modality"),doctype:"Modality",value:c.custom_modality||"",onChange:Ae=>u(je(se({},c),{custom_modality:Ae})),disabled:he("custom_modality")}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.class")}),t.jsxs("select",{name:"custom_class",value:c.custom_class,onChange:Ue,disabled:he("custom_class"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("assets.detail.selectClass")}),t.jsx("option",{value:"Class A",children:e("assets.detail.classA")}),t.jsx("option",{value:"Class B",children:e("assets.detail.classB")}),t.jsx("option",{value:"Class C",children:e("assets.detail.classC")})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.assetId")}),t.jsx("input",{type:"text",value:i||o?e("assets.detail.autoGenerated"):b==null?void 0:b.name,disabled:!0,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400"}),o&&t.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:["💡 ",e("assets.detail.duplicatingFrom")," ",n]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[e("assets.detail.deviceStatus")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("select",{name:"custom_device_status",value:c.custom_device_status,onChange:Ue,disabled:!ne,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"Up",children:e("assets.status.up")}),t.jsx("option",{value:"Down",children:e("assets.status.down")})]})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:e("assets.detail.technicalSpecs")}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.serialCode")}),t.jsx("input",{type:"text",name:"custom_serial_number",value:c.custom_serial_number,onChange:Ue,placeholder:e("assets.detail.placeholderSerialCode"),disabled:he("custom_serial_number"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsx(Je,{label:e("assets.detail.technicalDepartment"),doctype:"Issue Type",value:c.custom_technical_department||"",onChange:Ae=>u(je(se({},c),{custom_technical_department:Ae})),disabled:he("custom_technical_department")}),t.jsx(Je,{label:e("assets.detail.manufacturer"),doctype:"Manufacturer",value:c.custom_manufacturer||"",onChange:Ae=>u(je(se({},c),{custom_manufacturer:Ae})),disabled:he("custom_manufacturer"),allowQuickCreate:!0}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.model")}),t.jsx("input",{type:"text",name:"custom_model",value:c.custom_model,onChange:Ue,placeholder:e("assets.detail.placeholderModelNumber"),disabled:he("custom_model"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.totalHours")}),t.jsx("input",{type:"number",name:"custom_total_hours",value:c.custom_total_hours||0,disabled:!0,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400"}),t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:e("assets.detail.calculatedFromAvailableDate")})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.downTimeHours")}),t.jsx("input",{type:"number",name:"custom_down_time",value:c.custom_down_time||0,onChange:Ue,placeholder:e("assets.detail.placeholderZero"),disabled:he("custom_down_time"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.upTimeHours")}),t.jsx("input",{type:"number",name:"custom_up_time",value:c.custom_up_time||0,disabled:!0,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400"}),t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:e("assets.detail.calculatedTotalMinusDown")})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:e("assets.detail.location")}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(Je,{label:e("assets.detail.hospital"),doctype:"Company",value:c.company||"",onChange:Ae=>{u(je(se({},c),{company:Ae,asset_owner_company:Ae,department:""}))},disabled:he("company"),filters:{domain:"Healthcare"}}),de("custom_site")&&t.jsx("div",{children:t.jsx(Je,{label:e("assets.detail.siteName"),doctype:"Mobile Team Site",value:c.custom_site||"",onChange:Ae=>u(je(se({},c),{custom_site:Ae})),disabled:he("custom_site"),placeholder:e("assets.detail.selectSite")})}),t.jsxs("div",{children:[t.jsx(Je,{label:e("assets.detail.building"),doctype:"Building",value:c.custom_building||"",onChange:Ae=>{u(ke=>je(se({},ke),{custom_building:Ae,department:"",custom_room_number:"",location:""}))},disabled:he("custom_building"),allowQuickCreate:!0}),!c.custom_building&&ne&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:e("assets.detail.selectBuildingFirst")})]}),xe()&&t.jsxs("div",{children:[t.jsx(Je,{label:e("assets.detail.department"),doctype:"Department",value:c.department||"",onChange:Ae=>{u(ke=>je(se({},ke),{department:Ae,custom_room_number:"",location:""}))},disabled:he("department"),query:c.custom_building?"asset_lite.api.room_filter.get_filtered_departments":void 0,filters:(()=>{const Ae={};return c.custom_building&&(Ae.building=c.custom_building),c.company&&(Ae.company=c.company),K&&K.startsWith("Mobile")||c.company&&c.company.startsWith("Mobile")||(Ae.department_name=["not like","Non Bio%"]),Ae})(),allowQuickCreate:!0}),De&&t.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400 flex items-center gap-1",children:[t.jsx(tr,{className:"animate-spin",size:10}),e("common.loading")]}),!De&&c.custom_building&&we.length===0&&t.jsx("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:e("assets.detail.noDepartmentsMapped")}),!De&&c.custom_building&&we.length>0&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:e("assets.detail.departmentsAvailable",{count:we.length})}),!c.department&&c.custom_building&&ne&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:e("assets.detail.selectDepartmentForRoom")})]}),ge()&&t.jsxs("div",{children:[t.jsx(Je,{label:e("assets.detail.roomNumber"),doctype:"Room",value:c.custom_room_number||"",onChange:dt,disabled:he("custom_room_number"),query:"asset_lite.api.room_filter.get_filtered_rooms",filters:(()=>{const Ae={};return c.custom_building&&(Ae.building=c.custom_building),c.department&&(Ae.department=c.department),Ae})(),allowQuickCreate:!0}),ze&&t.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400 flex items-center gap-1",children:[t.jsx(tr,{className:"animate-spin",size:10}),e("common.loading")]}),!ze&&(c.custom_building||c.department)&&le.length===0&&t.jsxs("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:["No rooms mapped to ",c.custom_building&&c.department?"this building + department":c.custom_building?"this building":"this department"]}),!ze&&(c.custom_building||c.department)&&le.length>0&&t.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:[le.length," room(s) available",c.custom_building&&!c.department&&" (filtered by building)",!c.custom_building&&c.department&&" (filtered by department)",c.custom_building&&c.department&&" (filtered by building + department)"]}),!c.custom_room_number&&c.department&&ne&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:e("assets.detail.selectRoomFirst")})]}),be()&&t.jsxs("div",{children:[t.jsx(Je,{label:e("assets.detail.location"),doctype:"Location",value:c.location||"",onChange:Ae=>u(je(se({},c),{location:Ae})),disabled:he("location"),allowQuickCreate:!0}),c.custom_room_number&&c.location&&t.jsxs("p",{className:"mt-1 text-xs text-green-600 dark:text-green-400",children:["✓ ",e("assets.detail.autoSetFromRoom")]})]}),((kt=c.custom_recalled)==null?void 0:kt.trim())&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.recalled")}),t.jsxs("select",{name:"custom_recalled",value:c.custom_recalled,disabled:!0,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white cursor-not-allowed",children:[t.jsx("option",{value:" ",children:" "}),t.jsx("option",{value:"Yes",children:e("common.yes")}),t.jsx("option",{value:"No",children:e("common.no")})]})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:e("assets.detail.moreDetails")}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex flex-col items-center my-4",children:[t.jsx("div",{className:"border-2 border-gray-300 dark:border-gray-600 p-3 rounded-lg bg-white dark:bg-gray-700",children:He?t.jsxs(t.Fragment,{children:[t.jsx("img",{src:He,alt:`QR Code for ${(b==null?void 0:b.name)||"Asset"}`,className:"w-[120px] h-[120px] object-contain",onError:Ae=>{const ke=Ae.target;ke.style.display="none";const Be=ke.nextElementSibling;Be&&(Be.style.display="flex")}}),t.jsx("div",{className:"w-[120px] h-[120px] hidden items-center justify-center bg-gray-100 dark:bg-gray-700 rounded",children:t.jsx(Hu,{size:80,className:"text-gray-400 dark:text-gray-500"})})]}):t.jsx("div",{className:"w-[120px] h-[120px] flex items-center justify-center bg-gray-100 dark:bg-gray-700 rounded",children:t.jsx(Hu,{size:80,className:"text-gray-400 dark:text-gray-500"})})}),(b==null?void 0:b.name)&&t.jsxs("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400 text-center",children:["Asset ID: ",b.name]})]}),!i&&b&&!o&&t.jsx("div",{className:"mb-6",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[t.jsxs("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx("span",{children:"📋"})," Workflow Actions"]}),t.jsx(Ix,{doctype:"Asset",docname:r||null,workflowState:T,onActionComplete:(Ae,ke)=>{ke&&k()},onStateChange:lt,showStateInfo:!0,className:""}),G&&t.jsx("div",{className:"mt-3 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:t.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:G})}),!1]})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Description"}),t.jsx("textarea",{rows:4,placeholder:e("assets.detail.placeholderDescription"),disabled:!ne,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 mt-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:e("assets.detail.coverage")}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.siteContractor")}),t.jsx("input",{type:"text",name:"custom_site_contractor",value:c.custom_site_contractor,onChange:Ue,disabled:he("custom_site_contractor"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.contractNumber")}),t.jsx("input",{type:"text",disabled:!ne,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.serviceAgreement")}),t.jsxs("select",{name:"custom_service_agreement",value:c.custom_service_agreement||"",onChange:Ue,disabled:he("custom_service_agreement"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("assets.detail.selectServiceAgreement")}),t.jsx("option",{value:"Warranty",children:e("assets.detail.warranty")}),t.jsx("option",{value:"Contract",children:e("assets.detail.contract")}),t.jsx("option",{value:"Frame Work",children:e("assets.detail.frameWork")}),t.jsx("option",{value:"Main Contractor",children:e("assets.detail.mainContractor")}),t.jsx("option",{value:"Out of warranty",children:e("assets.detail.outOfWarranty")}),t.jsx("option",{value:"Under Dismantle",children:e("assets.detail.underDismantle")}),t.jsx("option",{value:"Under Installation",children:e("assets.detail.underInstallation")})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.serviceCoverage")}),t.jsxs("select",{name:"custom_service_coverage",value:c.custom_service_coverage||"",onChange:Ue,disabled:he("custom_service_coverage"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("assets.detail.selectServiceCoverage")}),t.jsx("option",{value:"PM Only",children:e("assets.detail.pmOnly")}),t.jsx("option",{value:"Labour",children:e("assets.detail.labour")}),t.jsx("option",{value:"Labour & Parts",children:e("assets.detail.labourAndParts")}),t.jsx("option",{value:"Comprehensive",children:e("assets.detail.comprehensive")})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.startDate")}),t.jsx("input",{type:"date",name:"custom_start_date",value:c.custom_start_date||"",onChange:Ue,disabled:he("custom_start_date"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.endDate")}),t.jsx("input",{type:"date",name:"custom_end_date",value:c.custom_end_date||"",onChange:Ue,disabled:he("custom_end_date"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.totalAmount")}),t.jsx("input",{type:"number",name:"custom_total_amount",value:c.custom_total_amount,onChange:Ue,disabled:he("custom_total_amount"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Comments"}),t.jsx("textarea",{rows:2,disabled:!ne,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Acquisition Details"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.purchaseOrderNumber")}),t.jsx("input",{type:"text",placeholder:e("assets.detail.placeholderPONumber"),disabled:!ne,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsx(Je,{label:e("assets.detail.supplierVendor"),doctype:"Supplier",value:c.supplier||"",onChange:Ae=>u(je(se({},c),{supplier:Ae})),disabled:he("supplier")}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.grossPurchaseAmount")}),t.jsx("input",{type:"number",name:"gross_purchase_amount",value:c.gross_purchase_amount||0,onChange:Ue,disabled:he("gross_purchase_amount"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.purchaseDate")}),t.jsx("input",{type:"date",disabled:!ne,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.installationDate")}),t.jsx("input",{type:"date",disabled:!ne,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.availableForUseDate")}),t.jsx("input",{type:"date",name:"available_for_use_date",value:c.available_for_use_date||"",onChange:Ae=>u(ke=>je(se({},ke),{available_for_use_date:Ae.target.value})),disabled:he("available_for_use_date"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]})]})]}),t.jsx("div",{className:"mt-6",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6",children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:e("assets.detail.financialDetails")}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:e("assets.detail.depreciationMethodNote")}),t.jsxs("div",{className:"flex items-center mb-6",children:[t.jsx("input",{id:"calculate_depreciation",type:"checkbox",checked:c.calculate_depreciation,onChange:Ae=>u(je(se({},c),{calculate_depreciation:Ae.target.checked})),disabled:!ne,className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700"}),t.jsx("label",{htmlFor:"calculate_depreciation",className:"ml-2 text-sm font-medium text-gray-700 dark:text-gray-300",children:e("assets.detail.calculateDepreciation")})]}),c.calculate_depreciation&&t.jsxs("div",{className:"border-t pt-4",children:[t.jsxs("div",{className:"flex justify-between items-center mb-4",children:[t.jsx("h3",{className:"text-md font-semibold text-gray-800 dark:text-white",children:e("assets.detail.assetFinanceBooks")}),ne&&t.jsxs("button",{type:"button",onClick:jt,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 flex items-center gap-2",children:[t.jsx("span",{children:"+"})," ",e("assets.detail.addRow")]})]}),(!c.finance_books||c.finance_books.length===0)&&t.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400 bg-gray-50 dark:bg-gray-900 rounded-lg",children:e("assets.detail.noFinanceBooksYet")}),c.finance_books&&c.finance_books.length>0&&t.jsx("div",{className:"overflow-visible",children:t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full border-collapse",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-300 dark:border-gray-600",children:[t.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300 min-w-[200px]",children:e("assets.detail.financeBook")}),t.jsxs("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300 min-w-[200px]",children:[e("assets.detail.depreciationMethod"),"*"]}),t.jsxs("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300 min-w-[180px]",children:[e("assets.detail.totalDepreciations"),"*"]}),t.jsxs("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300 min-w-[180px]",children:[e("assets.detail.frequencyMonths"),"*"]}),t.jsxs("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300 min-w-[200px]",children:[e("assets.detail.depreciationPostingDate"),"*"]}),ne&&t.jsx("th",{className:"text-center px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300 min-w-[120px]",children:e("common.actions")})]})}),t.jsx("tbody",{children:c.finance_books.map((Ae,ke)=>{var Be,yt;return t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-750",children:[t.jsx("td",{className:"px-4 py-3 relative",style:{overflow:"visible"},children:t.jsx("div",{className:"relative z-20",children:t.jsx(Je,{label:"",doctype:"Finance Book",value:Ae.finance_book||"",onChange:Me=>$e(ke,{finance_book:Me}),disabled:!ne})})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("select",{value:Ae.depreciation_method||"",onChange:Me=>$e(ke,{depreciation_method:Me.target.value}),disabled:!ne,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("assets.detail.selectMethod")}),t.jsx("option",{value:"Straight Line",children:e("assets.detail.straightLine")}),t.jsx("option",{value:"Double Declining Balance",children:e("assets.detail.doubleDecliningBalance")}),t.jsx("option",{value:"Written Down Value",children:e("assets.detail.writtenDownValue")}),t.jsx("option",{value:"Manual",children:e("assets.detail.manual")})]})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("input",{type:"number",value:(Be=Ae.total_number_of_depreciations)!=null?Be:"",onChange:Me=>$e(ke,{total_number_of_depreciations:Number(Me.target.value)}),disabled:!ne,placeholder:e("assets.detail.placeholderZero"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("input",{type:"number",value:(yt=Ae.frequency_of_depreciation)!=null?yt:"",onChange:Me=>$e(ke,{frequency_of_depreciation:Number(Me.target.value)}),disabled:!ne,placeholder:"0",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("input",{type:"date",value:Ae.depreciation_start_date||"",onChange:Me=>$e(ke,{depreciation_start_date:Me.target.value}),disabled:!ne,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})}),ne&&t.jsx("td",{className:"px-4 py-3 text-center",children:t.jsx("button",{type:"button",onClick:()=>Ie(ke),className:"px-3 py-2 bg-red-600 text-white rounded-md hover:bg-red-700 transition-colors",children:"Remove"})})]},ke)})})]})})})]})]})}),t.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6 mt-6",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"End-of-Life Details"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Expected End-of-Life Date"}),t.jsx("input",{type:"date",disabled:!ne,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Disposal Method"}),t.jsxs("select",{disabled:!ne,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:"Recycling"}),t.jsx("option",{value:"Donation",children:"Donation"}),t.jsx("option",{value:"Sale",children:"Sale"})]})]})]})]})}),t.jsxs("div",{className:"mt-6 bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[t.jsxs("div",{className:"flex justify-between items-center mb-4",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white",children:"Spare Parts"}),ne&&t.jsxs("button",{type:"button",onClick:at,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 flex items-center gap-2 text-sm",children:[t.jsx("span",{children:"+"})," ",e("assets.detail.addRow")]})]}),(!c.custom_spare_parts||c.custom_spare_parts.length===0)&&t.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400 bg-gray-50 dark:bg-gray-900 rounded-lg",children:e("assets.detail.noSparePartsYet")}),c.custom_spare_parts&&c.custom_spare_parts.length>0&&t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full border-collapse",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-300 dark:border-gray-600",children:[t.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Item Code"}),t.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Item Name"}),t.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Qty"}),t.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Rate"}),t.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Amount"}),t.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"UOM"}),ne&&t.jsx("th",{className:"text-center px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Action"})]})}),t.jsx("tbody",{children:c.custom_spare_parts.map((Ae,ke)=>t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-750",children:[t.jsx("td",{className:"px-4 py-3",children:t.jsx("input",{type:"text",value:Ae.item_code||"",onChange:Be=>Qe(ke,"item_code",Be.target.value),disabled:!ne,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("input",{type:"text",value:Ae.item_name||"",onChange:Be=>Qe(ke,"item_name",Be.target.value),disabled:!ne,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("input",{type:"number",value:Ae.qty||0,onChange:Be=>Qe(ke,"qty",Number(Be.target.value)),disabled:!ne,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("input",{type:"number",value:Ae.rate||0,onChange:Be=>Qe(ke,"rate",Number(Be.target.value)),disabled:!ne,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("input",{type:"number",value:Ae.amount||0,disabled:!0,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("input",{type:"text",value:Ae.uom||"",onChange:Be=>Qe(ke,"uom",Be.target.value),disabled:!ne,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})}),ne&&t.jsx("td",{className:"px-4 py-3 text-center",children:t.jsx("button",{type:"button",onClick:()=>Ct(ke),className:"px-3 py-2 bg-red-600 text-white rounded-md hover:bg-red-700 transition-colors text-sm",children:"Remove"})})]},ke))}),t.jsx("tfoot",{children:t.jsxs("tr",{className:"bg-gray-100 dark:bg-gray-700 font-semibold",children:[t.jsx("td",{colSpan:4,className:"px-4 py-3 text-right text-sm text-gray-700 dark:text-gray-300",children:"Total Amount:"}),t.jsx("td",{className:"px-4 py-3 text-sm text-gray-900 dark:text-white",children:c.custom_total_spare_parts_amount||0}),t.jsx("td",{colSpan:ne?2:1})]})})]})})]})]}),!i&&t.jsx(Bm,{referenceDoctype:"Asset",referenceName:r||null,title:"Comments & Discussion",pollInterval:3e4,initialLimit:5,collapsible:!0,startCollapsed:!1}),!i&&!o&&t.jsx("div",{className:"mt-6",children:t.jsx(vi,{doctype:"Asset",docname:r||null,creationDate:b==null?void 0:b.creation,createdBy:b==null?void 0:b.owner,compact:!1,initialVisible:5,collapsible:!0,startCollapsed:!0})}),!i&&((b==null?void 0:b.docstatus)===0||(b==null?void 0:b.docstatus)===1||(b==null?void 0:b.docstatus)===2)&&t.jsxs("div",{className:"mt-6 bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Delete Request"}),t.jsx(n0,{doctype:"Asset",docname:r,currentDeleteStatus:(Yt=b==null?void 0:b.custom_delete_status)!=null?Yt:null,userRoles:R,isSystemManager:z,redirectOnDelete:"/assets",onStatusChange:()=>{k()}})]})]})},ine=["System Manager","Administrator","Contractor Supervisor","Contractor Manager","Work Control","End user"];function one(){const[e,r]=p.useState(""),[a,s]=p.useState(!1),[n,i]=p.useState(!0),[o,l]=p.useState(null);p.useEffect(()=>{J(null,null,function*(){try{i(!0);const h=yield fetch("/api/method/asset_lite.api.user_roles.get_user_info_with_roles",{method:"GET",headers:{"Content-Type":"application/json"}});if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);const f=yield h.json();if(f.message){const{user:y,roles:b}=f.message;if(r(y||""),!y||y==="Guest"){s(!1);return}const w=b.includes("Technician"),v=b.some(S=>ine.includes(S)),k=w&&!v;console.log("[useTechnicianFilter] User:",y),console.log("[useTechnicianFilter] Roles:",b),console.log("[useTechnicianFilter] Has Technician:",w),console.log("[useTechnicianFilter] Has Full Access:",v),console.log("[useTechnicianFilter] Is Technician Only:",k),s(k)}l(null)}catch(h){console.error("[useTechnicianFilter] Error checking technician role:",h),l(h instanceof Error?h.message:"Failed to check user roles"),s(!1)}finally{i(!1)}})},[]);const c=p.useMemo(()=>{if(!(!a||!e))return console.log("[useTechnicianFilter] Building OR filters for user:",e),[["owner","=",e],["assigned_technician","=",e],["custom_add_technicians","like",`%${e}%`]]},[a,e]);return{currentUser:e,isTechnicianOnly:a,technicianOrFilters:c,loading:n,error:o}}const lne=({isOpen:e,onClose:r})=>{const{t:a}=sr(),[s,n]=p.useState(!1),[i,o]=p.useState(null),[l,c]=p.useState([]),[u,h]=p.useState([]),[f,y]=p.useState(!0),[b,w]=p.useState(""),[v,k]=p.useState(""),[S,N]=p.useState(!1),C="Work Order Data",O=p.useCallback(()=>J(null,null,function*(){n(!0),o(null);try{const ne={};b&&(ne.work_order_type=b),v&&(ne.repair_status=v);const Y=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:C,filters:ne,ignore_prepared_report:1})})).json();if(Y.exc)throw new Error(Y.exc);Y.message&&(Y.message.columns&&Y.message.columns.length>0&&h(Y.message.columns),Y.message.result?c(Y.message.result):c([]))}catch(ne){console.error("Error fetching report:",ne),o(ne instanceof Error?ne.message:"Failed to fetch report data"),c([])}finally{n(!1)}}),[b,v]);p.useEffect(()=>{e&&O()},[e,O]),p.useEffect(()=>{const ne=te=>{te.key==="Escape"&&e&&r()};return document.addEventListener("keydown",ne),()=>document.removeEventListener("keydown",ne)},[e,r]),p.useEffect(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="unset",()=>{document.body.style.overflow="unset"}),[e]);const T=()=>{w(""),k("")},P=()=>{if(l.length!==0){N(!0);try{const te=[u.map(U=>U.label).join(","),...l.map(U=>u.map(re=>{let X=U[re.fieldname]||"";return typeof X=="string"&&(X.includes(",")||X.includes('"')||X.includes(`
|
||
`))&&(X=`"${X.replace(/"/g,'""')}"`),X}).join(","))].join(`
|
||
`),Y=new Blob(["\uFEFF"+te],{type:"text/csv;charset=utf-8;"}),q=URL.createObjectURL(Y),H=document.createElement("a");H.href=q,H.download=`work_order_report_${new Date().toISOString().split("T")[0]}.csv`,H.click(),URL.revokeObjectURL(q)}finally{N(!1)}}},E=()=>{if(l.length!==0){N(!0);try{const te=[u.map(U=>U.label),...l.map(U=>u.map(re=>U[re.fieldname]||""))],Y=Na.aoa_to_sheet(te),q=u.map(U=>({wch:U.width?Math.floor(U.width/7):15}));Y["!cols"]=q;const H=Na.book_new();Na.book_append_sheet(H,Y,"Work Order Report"),lc(H,`work_order_report_${new Date().toISOString().split("T")[0]}.xlsx`)}finally{N(!1)}}},R=()=>{const ne=window.open("","_blank");if(!ne){alert("Please allow popups for this site to print the report.");return}const te=`
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<title>Work Order Report</title>
|
||
<style>
|
||
body { font-family: Arial, sans-serif; margin: 20px; }
|
||
h1 { text-align: center; color: #333; margin-bottom: 20px; }
|
||
.meta { text-align: center; color: #666; margin-bottom: 20px; font-size: 12px; }
|
||
table { width: 100%; border-collapse: collapse; font-size: 11px; }
|
||
th { background-color: #4A90D9; color: white; padding: 10px 8px; text-align: left; font-weight: 600; }
|
||
td { padding: 8px; border-bottom: 1px solid #ddd; }
|
||
tr:nth-child(even) { background-color: #f9f9f9; }
|
||
tr:hover { background-color: #f5f5f5; }
|
||
.status-open { color: #D97706; font-weight: 500; }
|
||
.status-completed { color: #059669; font-weight: 500; }
|
||
.status-inprogress { color: #2563EB; font-weight: 500; }
|
||
.priority-urgent { color: #DC2626; font-weight: 600; }
|
||
.priority-normal { color: #6B7280; }
|
||
@media print {
|
||
body { margin: 0; }
|
||
table { page-break-inside: auto; }
|
||
tr { page-break-inside: avoid; page-break-after: auto; }
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<h1>Work Order Report</h1>
|
||
<div class="meta">
|
||
Generated on: ${new Date().toLocaleString()} | Total Records: ${l.length}
|
||
${b?` | Type: ${b}`:""}
|
||
${v?` | Status: ${v}`:""}
|
||
</div>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
${u.map(Y=>`<th>${Y.label}</th>`).join("")}
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
${l.map(Y=>`
|
||
<tr>
|
||
${u.map(q=>{let H=Y[q.fieldname]||"-",U="";return q.fieldname==="repair_status"&&(H.toLowerCase().includes("open")?U="status-open":H.toLowerCase().includes("completed")?U="status-completed":H.toLowerCase().includes("progress")&&(U="status-inprogress")),q.fieldname==="custom_priority_"&&(H.toLowerCase()==="urgent"?U="priority-urgent":U="priority-normal"),`<td class="${U}">${H}</td>`}).join("")}
|
||
</tr>
|
||
`).join("")}
|
||
</tbody>
|
||
</table>
|
||
<script>
|
||
window.onload = function() { window.print(); }
|
||
<\/script>
|
||
</body>
|
||
</html>
|
||
`;ne.document.write(te),ne.document.close()},z=()=>{R()},G=ne=>{switch(ne==null?void 0:ne.toLowerCase()){case"completed":case"closed":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300";case"work in progress":return"bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-300";case"open":case"pending review":return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-300";case"cancelled":return"bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-300";default:return"bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300"}},ae=ne=>{switch(ne==null?void 0:ne.toLowerCase()){case"urgent":return"bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-300";case"medium":return"bg-orange-100 dark:bg-orange-900/30 text-orange-800 dark:text-orange-300";default:return"bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300"}},ee=(ne,te)=>{if(ne==null||ne==="")return"-";switch(te.fieldtype){case"Date":return new Date(ne).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});case"Datetime":return new Date(ne).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});case"Currency":return new Intl.NumberFormat("en-US",{style:"currency",currency:"SAR"}).format(ne);case"Link":return ne;default:return String(ne)}};return e?t.jsxs("div",{className:"fixed inset-0 z-[80] bg-gray-50 dark:bg-gray-900 flex flex-col",children:[t.jsx("div",{className:"bg-gradient-to-r from-indigo-600 to-purple-600 px-6 py-4 flex-shrink-0 shadow-lg",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("button",{onClick:r,className:"p-2 text-white/80 hover:text-white hover:bg-white/20 rounded-lg transition-colors",title:"Go Back",children:t.jsx(ia,{size:18})}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(J9,{className:"text-white text-xl"}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-bold text-white",children:"Work Order Report"}),t.jsxs("p",{className:"text-white/70 text-sm",children:[l.length," record",l.length!==1?"s":""," found"]})]})]})]}),t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("button",{onClick:r,className:"p-2 text-white/80 hover:text-white hover:bg-white/20 rounded-lg transition-colors",title:"Close (Esc)",children:t.jsx(ht,{size:20})})})]})}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 px-6 py-3 border-b border-gray-200 dark:border-gray-700 flex-shrink-0 shadow-sm",children:[t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("button",{onClick:()=>y(!f),className:"flex items-center gap-2 px-4 py-2 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:[t.jsx(ds,{size:12}),"Filters",(b||v)&&t.jsx("span",{className:"bg-indigo-100 dark:bg-indigo-900/50 text-indigo-600 dark:text-indigo-400 px-2 py-0.5 rounded-full text-xs font-bold",children:[b,v].filter(Boolean).length}),f?t.jsx(Ja,{size:10}):t.jsx(Fr,{size:10})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:O,disabled:s,className:"p-2.5 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors disabled:opacity-50",title:"Refresh",children:t.jsx(Ma,{className:s?"animate-spin":"",size:14})}),t.jsxs("div",{className:"flex items-center gap-1 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg overflow-hidden",children:[t.jsxs("button",{onClick:P,disabled:l.length===0||S,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as CSV",children:[t.jsx(ic,{className:"text-green-600",size:14}),t.jsx("span",{children:"CSV"})]}),t.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),t.jsxs("button",{onClick:E,disabled:l.length===0||S,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as Excel",children:[t.jsx(oc,{className:"text-green-700",size:14}),t.jsx("span",{children:"Excel"})]}),t.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),t.jsxs("button",{onClick:z,disabled:l.length===0,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as PDF",children:[t.jsx(_x,{className:"text-red-600",size:14}),t.jsx("span",{children:"PDF"})]}),t.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),t.jsxs("button",{onClick:R,disabled:l.length===0,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Print",children:[t.jsx(yl,{className:"text-purple-600",size:14}),t.jsx("span",{children:"Print"})]})]})]})]}),f&&t.jsx("div",{className:"mt-4 p-4 bg-gray-50 dark:bg-gray-900/50 rounded-lg border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[t.jsx("div",{className:"relative z-[70]",children:t.jsx(Je,{label:"Work Order Type",doctype:"Issue Type",value:b,onChange:ne=>w(ne),placeholder:"All Types",disabled:!1,compact:!1})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Work Order Status"}),t.jsxs("select",{value:v,onChange:ne=>k(ne.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:"All Status"}),t.jsx("option",{value:"Open",children:"Open"}),t.jsx("option",{value:"Work In Progress",children:"Work In Progress"}),t.jsx("option",{value:"Pending Review",children:"Pending Review"}),t.jsx("option",{value:"Completed",children:"Completed"}),t.jsx("option",{value:"Executed",children:"Executed"}),t.jsx("option",{value:"Cancelled",children:"Cancelled"}),t.jsx("option",{value:"Closed",children:"Closed"})]})]}),t.jsx("div",{}),t.jsx("div",{className:"flex items-end",children:t.jsxs("button",{onClick:T,disabled:!b&&!v,className:"px-4 py-2 text-sm font-medium text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:[t.jsx(ht,{size:12}),"Clear Filters"]})})]})})]}),t.jsxs("div",{className:"flex-1 overflow-auto p-6",children:[s&&t.jsx("div",{className:"flex items-center justify-center py-20",children:t.jsxs("div",{className:"text-center",children:[t.jsx(tr,{className:"animate-spin text-indigo-500 text-5xl mx-auto mb-4"}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-lg",children:"Loading report data..."})]})}),i&&!s&&t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-8 text-center max-w-lg mx-auto",children:[t.jsx("p",{className:"text-red-600 dark:text-red-400 mb-4 text-lg",children:i}),t.jsx("button",{onClick:O,className:"px-6 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-sm font-medium transition-colors",children:"Try Again"})]}),!s&&!i&&l.length===0&&t.jsxs("div",{className:"text-center py-20",children:[t.jsx(za,{className:"text-gray-300 dark:text-gray-600 text-6xl mx-auto mb-4"}),t.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-xl",children:"No data found"}),t.jsx("p",{className:"text-gray-400 dark:text-gray-500 text-sm mt-2",children:"Try adjusting your filters"})]}),!s&&!i&&l.length>0&&t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden shadow-sm",children:t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 sticky top-0",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-600 dark:text-gray-300 uppercase tracking-wider w-16",children:"#"}),u.map((ne,te)=>t.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-600 dark:text-gray-300 uppercase tracking-wider whitespace-nowrap",style:{minWidth:ne.width||120},children:ne.label},te))]})}),t.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:l.map((ne,te)=>t.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[t.jsx("td",{className:"px-4 py-3 text-sm text-gray-500 dark:text-gray-400 font-medium",children:te+1}),u.map((Y,q)=>{const H=ne[Y.fieldname],U=ee(H,Y);return Y.fieldname==="repair_status"?t.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:t.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${G(H)}`,children:U})},q):Y.fieldname==="custom_priority_"?t.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:t.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${ae(H)}`,children:U})},q):Y.fieldtype==="Link"&&Y.fieldname==="name"?t.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:t.jsx("a",{href:`/asm_app/work-orders/${H}`,target:"_blank",rel:"noopener noreferrer",className:"text-indigo-600 dark:text-indigo-400 hover:underline font-medium text-sm",children:U})},q):t.jsx("td",{className:"px-4 py-3 text-sm text-gray-700 dark:text-gray-300",title:typeof H=="string"&&H.length>50?H:void 0,children:t.jsx("div",{className:"max-w-xs truncate",children:U})},q)})]},te))})]})})})]}),t.jsx("div",{className:"bg-white dark:bg-gray-800 px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex-shrink-0 shadow-inner",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Showing ",l.length," record",l.length!==1?"s":"",(b||v)&&" (filtered)"]}),t.jsx("button",{onClick:r,className:"px-6 py-2 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-lg text-sm font-medium transition-colors",children:"Close"})]})})]}):null},cne="/assets/asm_ui_app/asm_app/assets/ar_prompt-BqI4nTg7.mp3",A7="/assets/asm_ui_app/asm_app/assets/ar_no_selection-CHgRuCTX.mp3",dne="/assets/asm_ui_app/asm_app/assets/en_status_prompt-Cuwd6Pz-.mp3",une="/assets/asm_ui_app/asm_app/assets/en_no_selection_prompt-CVmv7vVD.mp3",mne=[{value:"Open",label:"Open",keywords:["open"],color:"not-started",icon:"⏳"},{value:"Work In Progress",label:"Work In Progress",keywords:["work in progress"],color:"in-progress",icon:"🔄"},{value:"Closed",label:"Closed",keywords:["closed"],color:"completed",icon:"✅"}];function hne(e,r){if(!e)return null;const a=e.toLowerCase().trim();for(const s of r)if(s.keywords.some(n=>new RegExp(`(^|[\\s،,])${n}([\\s،,]|$)`,"i").test(a)))return s.value;return null}const vb=18,bk=window.SpeechRecognition||window.webkitSpeechRecognition;function pne({onStatusConfirmed:e,selectedCount:r=0,selectedNames:a=[],isUpdating:s=!1,statusOptions:n=mne,widgetTitle:i="Voice Status Update",showLanguageToggle:o=!1,noSelectionLabel:l="project"}){const[c,u]=p.useState(r===0?"noselection":"prompted"),[h,f]=p.useState(""),[y,b]=p.useState(null),[w,v]=p.useState(!1),[k,S]=p.useState(Array(vb).fill(4)),[N,C]=p.useState("en"),O=p.useRef(null),T=p.useRef(null),P=p.useRef(null),E=p.useRef(null),R=p.useRef(null),z=p.useRef(null),G=p.useRef(null),ae=p.useRef(!1),ee=p.useRef(null),ne=n.map(de=>de.label).join(", "),te=n.map(de=>de.arLabel||de.label).join("، "),Y=`من فضلك قل الحالة: ${te}.`,q=`Please select at least one ${l} from the list in order to continue.`,H=N==="ar"?`قل: ${te}`:`Say: ${ne}`;function U(de){const ge=de==="ar"?cne:dne,be=new Audio(ge);be.onended=()=>u("ready"),be.onerror=()=>u("ready"),be.play().catch(()=>u("ready"))}p.useEffect(()=>{if(r===0){const xe=new Audio(une);xe.onended=()=>{new Audio(A7).play().catch(()=>{})},xe.onerror=()=>{new Audio(A7).play().catch(()=>{})},xe.play().catch(()=>{});return}const de=setTimeout(()=>U(N),1e3);return()=>{clearTimeout(de),X()}},[]);const re=p.useRef(!0);p.useEffect(()=>{if(re.current){re.current=!1;return}if(r===0||c==="listening"||c==="detected")return;window.speechSynthesis&&window.speechSynthesis.cancel(),u("prompted");const de=N,xe=setTimeout(()=>U(de),400);return()=>clearTimeout(xe)},[N]);function X(){G.current&&clearTimeout(G.current),P.current&&cancelAnimationFrame(P.current),T.current&&(T.current.disconnect(),T.current=null),O.current&&(O.current.close(),O.current=null),z.current&&(z.current.getTracks().forEach(de=>de.stop()),z.current=null),[E,R].forEach(de=>{if(de.current){try{de.current.stop()}catch(xe){}de.current=null}}),S(Array(vb).fill(4))}function V(){return J(this,null,function*(){try{let de=function(){P.current=requestAnimationFrame(de),be.getByteFrequencyData(ye),S(Array.from({length:vb},(Z,M)=>{const we=Math.floor(M*ye.length/vb);return 4+ye[we]/255*22}))};const xe=yield navigator.mediaDevices.getUserMedia({audio:!0});z.current=xe;const ge=new(window.AudioContext||window.webkitAudioContext);O.current=ge;const be=ge.createAnalyser();be.fftSize=64;const K=ge.createMediaStreamSource(xe);T.current=K,K.connect(be);const ye=new Uint8Array(be.frequencyBinCount);de()}catch(de){}})}function I(de,xe){if(!bk)return null;const ge=new bk;return ge.lang=de,ge.interimResults=!1,ge.continuous=!1,ge.maxAlternatives=3,ge.onresult=be=>{const K=be.results[be.resultIndex];if(K&&K.isFinal){const ye=K[0].transcript.trim();ye&&xe(ye,!0)}},ge.onerror=()=>{},ge.onend=()=>{},ge}function B(){return J(this,null,function*(){if(u("listening"),f(""),ee.current=null,yield V(),!bk){X(),u("ready");return}const de=N==="ar"?"ar-SA":"en-US";let xe="";const ge=(ye,Z)=>{if(ae.current||ee.current)return;f(ye);const M=hne(ye,n);if(M){ae.current=!0,ee.current=M,b(M),u("detected"),X(),setTimeout(()=>{e==null||e(M)},800);return}Z&&(xe+=ye+" ")},be=()=>{if(ee.current||ae.current||!xe.trim())return;u("notunderstood"),X(),N==="ar"?setTimeout(()=>u("ready"),1500):smartSpeak({text:`Please pick only from one of the values provided: ${ne}.`,lang:"en-US",onEnd:()=>u("ready"),onError:()=>u("ready")})},K=I(de,ge);if(!K){X(),u("ready");return}E.current=K,K.onend=()=>{!ee.current&&!ae.current&&be()};try{K.start()}catch(ye){}G.current=setTimeout(()=>{X(),u(ye=>ye==="listening"?"ready":ye)},8e3)})}function Q(de){ae.current||(b(de),ee.current=de,f(`Selected: ${de}`),u("detected"),X(),setTimeout(()=>{e&&!ae.current&&(ae.current=!0,e(de))},800))}function ie(){X(),ae.current=!1,ee.current=null,f(""),b(null),v(!1),r===0?(u("noselection"),smartSpeak({text:q,lang:"en-US",onEnd:()=>{},onError:()=>{}})):(u("prompted"),setTimeout(()=>U(N),500))}const me=y?n.find(de=>de.value===y):null,he=N==="ar";return t.jsxs("div",{className:"vsw-card",children:[t.jsxs("div",{className:"vsw-header",children:[t.jsx("div",{className:"vsw-logo",children:"🛠️"}),t.jsxs("div",{className:"vsw-brand",children:["SEERA",t.jsx("span",{children:"-ASM"})]}),r>0&&t.jsxs("span",{className:"vsw-selected-badge",children:[r," selected"]})]}),t.jsx("div",{className:"vsw-title",children:i}),t.jsx("div",{className:"vsw-subtitle",children:r===0?`No ${l}s selected`:`Updating ${r} record${r>1?"s":""}`}),o&&r>0&&t.jsx("div",{style:{display:"flex",gap:6,marginBottom:14,background:"#f1f5f9",borderRadius:10,padding:4},children:[{key:"en",label:"English"},{key:"ar",label:"عربي"}].map(({key:de,label:xe})=>t.jsx("button",{onClick:()=>C(de),style:{flex:1,padding:"6px 0",borderRadius:7,border:"none",fontSize:12,fontWeight:600,cursor:"pointer",transition:"all 0.15s",background:N===de?"#fff":"transparent",color:N===de?"#2563eb":"#64748b",boxShadow:N===de?"0 1px 4px rgba(0,0,0,0.1)":"none"},children:xe},de))}),c==="noselection"&&t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12,padding:16,marginBottom:16,background:"#fffbeb",border:"1px solid #fde68a",borderRadius:10},children:[t.jsx("span",{style:{fontSize:20,flexShrink:0},children:"⚠️"}),t.jsxs("div",{style:{width:"100%"},children:[t.jsxs("p",{style:{fontWeight:700,fontSize:14,color:"#92400e",margin:"0 0 2px"},children:["No ",l,"s selected"]}),t.jsxs("p",{style:{fontSize:13,color:"#b45309",margin:"0 0 10px",lineHeight:1.5},children:["Please select at least one ",l," from the list in order to continue."]}),t.jsx("p",{style:{fontWeight:700,fontSize:14,color:"#92400e",margin:"0 0 2px",direction:"rtl",textAlign:"right"},children:"لم يتم اختيار أي مشروع"}),t.jsx("p",{style:{fontSize:13,color:"#b45309",margin:0,lineHeight:1.5,direction:"rtl",textAlign:"right"},children:"من فضلك اختر مشروعاً واحداً على الأقل من القائمة للمتابعة"})]})]}),r>0&&t.jsxs(t.Fragment,{children:[a.length>0&&t.jsxs("div",{className:"vsw-wo-list",children:[a.slice(0,3).map(de=>t.jsx("span",{className:"vsw-wo-tag",children:de},de)),a.length>3&&t.jsxs("span",{className:"vsw-wo-tag vsw-wo-tag--more",children:["+",a.length-3," more"]})]}),t.jsx("div",{className:"vsw-status-row",children:n.map(de=>t.jsxs("div",{className:`vsw-pill ${y===de.value?`vsw-pill--active vsw-pill--${de.color}`:""}`,onClick:()=>Q(de.value),title:"Click to select manually",children:[t.jsx("span",{className:`vsw-dot vsw-dot--${de.color}`}),t.jsx("span",{children:he&&de.arLabel||de.label})]},de.value))}),t.jsxs("div",{className:"vsw-action-area",children:[c==="prompted"&&t.jsxs("div",{className:"vsw-status-message vsw-status-message--speaking",children:[t.jsx("div",{className:"vsw-speaking-icon",children:"🔊"}),t.jsx("div",{className:"vsw-speaking-text",children:he?"يرجى الانتظار…":"Please wait…"}),t.jsxs("div",{className:"vsw-speaking-dots",children:[t.jsx("span",{}),t.jsx("span",{}),t.jsx("span",{})]})]}),c==="ready"&&t.jsxs(t.Fragment,{children:[he&&t.jsx("div",{style:{width:"100%",padding:"12px 16px",marginBottom:8,background:"#f0f9ff",border:"1px solid #bae6fd",borderRadius:10,textAlign:"right",direction:"rtl"},children:t.jsx("p",{style:{margin:0,fontSize:14,fontWeight:600,color:"#0369a1"},children:Y})}),t.jsxs("button",{className:"vsw-speak-btn",onClick:B,children:[t.jsx("div",{className:"vsw-speak-btn-icon",children:"🎙️"}),t.jsxs("div",{className:"vsw-speak-btn-text",children:[t.jsx("span",{className:"vsw-speak-btn-title",children:he?"اضغط للتحدث":"Tap to Speak"}),t.jsx("span",{className:"vsw-speak-btn-hint",children:H})]})]})]}),c==="listening"&&t.jsxs("div",{className:"vsw-listening-area",children:[t.jsx("div",{className:"vsw-mic-active",children:"🔴"}),t.jsx("div",{className:"vsw-waveform vsw-waveform--active",children:k.map((de,xe)=>t.jsx("div",{className:"vsw-bar",style:{height:`${de}px`}},xe))}),t.jsx("div",{className:"vsw-mic-label vsw-mic-label--listening",children:he?"جاري الاستماع… تحدث الآن":"Listening… speak now"}),h&&t.jsx("div",{style:{marginTop:8,padding:"6px 12px",background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,fontSize:13,color:"#1e293b",maxWidth:"100%",direction:he?"rtl":"ltr"},children:h})]}),c==="detected"&&me&&t.jsxs("div",{className:"vsw-status-message vsw-status-message--detected",children:[me.icon," ",he?"تم اكتشاف الحالة!":"Status detected!"]}),c==="notunderstood"&&t.jsxs("div",{className:"vsw-status-message vsw-status-message--notunderstood",children:["⚠️ ",he?"من فضلك اختر من القيم المتاحة":"Please pick only from one of the values provided"]})]}),h&&c!=="listening"&&t.jsx("div",{className:"vsw-transcript vsw-transcript--filled",style:{direction:he?"rtl":"ltr"},children:h})]}),t.jsx("hr",{className:"vsw-divider"}),t.jsxs("div",{className:"vsw-actions",children:[t.jsx("button",{className:"vsw-btn vsw-btn--ghost",onClick:ie,disabled:s,children:he?"إعادة":"Reset"}),s&&t.jsx("button",{className:"vsw-btn vsw-btn--primary",disabled:!0,children:he?"جاري التحديث…":"Updating…"}),w&&t.jsx("button",{className:"vsw-btn vsw-btn--confirmed vsw-btn--primary",disabled:!0,children:he?"تم التحديث!":"Updated!"})]})]})}const gne=[{value:"Open",label:"Open",keywords:["open"],color:"not-started",icon:"⏳"},{value:"Work In Progress",label:"Work In Progress",keywords:["work in progress"],color:"in-progress",icon:"🔄"},{value:"Closed",label:"Closed",keywords:["closed"],color:"completed",icon:"✅"}],fne=[{value:"Open",label:"Open",arLabel:"مفتوح",keywords:["open","مفتوح","مفتوحة","افتح","open"],color:"not-started",icon:"📂"},{value:"Completed",label:"Completed",arLabel:"مكتمل",keywords:["completed","complete","done","finish","finished","مكتمل","مكتملة","اكتمل","منجز","منتهي","منتهية","تم"],color:"completed",icon:"✅"},{value:"Cancelled",label:"Cancelled",arLabel:"ملغي",keywords:["cancelled","canceled","cancel","ملغي","ملغاة","ملغى","الغي","إلغاء"],color:"in-progress",icon:"🚫"}],kL=({isOpen:e,onClose:r,selectedRows:a,onUpdateSuccess:s,doctype:n="Work_Order",fieldname:i="repair_status",statusOptions:o=gne,widgetTitle:l="Voice Status Update",showLanguageToggle:c=!1,noSelectionLabel:u="row"})=>{const[h,f]=p.useState(!1);if(!e)return null;const y=a.size,b=w=>J(null,null,function*(){if(y===0)return;const v=Array.from(a);f(!0);let k=0,S=0;for(const N of v)try{const O=yield(yield fetch("/api/method/frappe.client.set_value",{method:"POST",headers:{"Content-Type":"application/json","X-Frappe-CSRF-Token":window.csrf_token||"fetch"},credentials:"include",body:JSON.stringify({doctype:n,name:N,fieldname:i,value:w})})).json();if(O.exc||O.exception)throw new Error(O.exc||O.exception);k++}catch(C){console.error(`Failed to update ${N}:`,C),S++}f(!1),k>0&&S===0?setTimeout(()=>{s(),r()},2e3):k>0&&s()});return t.jsxs("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[80] p-4",onClick:w=>{w.target===w.currentTarget&&!h&&r()},children:[t.jsxs("div",{className:"relative animate-scale-in",children:[t.jsx("button",{onClick:()=>{h||r()},className:"absolute -top-3 -right-3 z-10 w-8 h-8 rounded-full bg-gray-600 hover:bg-gray-500 text-white flex items-center justify-center shadow-lg transition-colors",disabled:h,title:"Close",children:t.jsx(ht,{size:12})}),t.jsx(pne,{onStatusConfirmed:b,selectedCount:y,selectedNames:Array.from(a),isUpdating:h,statusOptions:o,widgetTitle:l,showLanguageToggle:c,noSelectionLabel:u})]}),t.jsx("style",{children:`
|
||
@keyframes scale-in {
|
||
from { transform: scale(0.92); opacity: 0; }
|
||
to { transform: scale(1); opacity: 1; }
|
||
}
|
||
.animate-scale-in { animation: scale-in 0.2s ease-out; }
|
||
`})]})},xne=["CARPENTARY","MASONRY","PAINTING","PLUMPING"],yne="Civil works-الأعمال المدنية",bne=({isOpen:e,onClose:r,selectedWorkOrders:a,onConfirmClose:s,isClosing:n})=>{const{t:i}=sr();if(!e)return null;const o=u=>{switch(u==null?void 0:u.toLowerCase()){case"closed":return"bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300";case"completed":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300";case"in progress":case"work in progress":case"repair inprogress":return"bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-300";case"pending":case"pending approval":case"pending review":case"open":return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-300";case"cancelled":return"bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-300";default:return"bg-purple-100 dark:bg-purple-900/30 text-purple-800 dark:text-purple-300"}},l=a.filter(u=>{var h;return((h=u.workflow_state)==null?void 0:h.toLowerCase())==="closed"}).length,c=a.length-l;return t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] overflow-hidden animate-scale-in",children:[t.jsx("div",{className:"bg-gradient-to-r from-orange-500 to-orange-600 px-6 py-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(jN,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:i("workOrders.closeModal.title")})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:n,children:t.jsx(ht,{size:20})})]})}),t.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-180px)]",children:[t.jsx("div",{className:"mb-4 p-4 bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(Or,{className:"text-orange-500 mt-0.5 flex-shrink-0"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-orange-800 dark:text-orange-200",children:i("workOrders.closeModal.confirmBulkClose")}),t.jsx("p",{className:"text-xs text-orange-600 dark:text-orange-400 mt-1",children:i("workOrders.closeModal.aboutToClose",{count:c})}),l>0&&t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:i("workOrders.closeModal.alreadyClosedNote",{count:l})})]})]})}),t.jsxs("div",{className:"mb-4",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:i("workOrders.closeModal.selectedWorkOrders",{count:a.length})}),t.jsx("div",{className:"max-h-64 overflow-y-auto border border-gray-200 dark:border-gray-700 rounded-lg",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700 sticky top-0",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:i("workOrders.closeModal.workOrderId")}),t.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:i("workOrders.closeModal.currentStatus")}),t.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:i("workOrders.closeModal.workflowState")})]})}),t.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:a.map(u=>{var f;const h=((f=u.workflow_state)==null?void 0:f.toLowerCase())==="closed";return t.jsxs("tr",{className:`${h?"bg-gray-50 dark:bg-gray-700/50 opacity-60":"bg-white dark:bg-gray-800"}`,children:[t.jsxs("td",{className:"px-4 py-3",children:[t.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:u.name}),h&&t.jsx("span",{className:"ml-2 text-xs text-gray-500",children:i("workOrders.closeModal.alreadyClosed")})]}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${o(u.repair_status)}`,children:u.repair_status||"Open"})})]},u.name)})})]})})]})]}),t.jsxs("div",{className:"px-6 py-4 bg-gray-50 dark:bg-gray-900/50 border-t border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[t.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:c>0?t.jsx("span",{children:i("workOrders.closeModal.willClose",{count:c})}):t.jsx("span",{className:"text-orange-600 dark:text-orange-400",children:i("workOrders.closeModal.allAlreadyClosed")})}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{onClick:r,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",disabled:n,children:i("workOrders.closeModal.cancel")}),t.jsx("button",{onClick:s,disabled:c===0||n,className:"px-4 py-2 text-sm font-medium text-white bg-orange-600 hover:bg-orange-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:n?t.jsxs(t.Fragment,{children:[t.jsx(tr,{className:"animate-spin",size:14}),i("workOrders.closeModal.closing")]}):t.jsxs(t.Fragment,{children:[t.jsx(jN,{size:14}),i("workOrders.closeModal.close")," ",c>0?`(${c})`:""]})})]})]})]})})},vne=()=>{const{t:e}=sr(),r=hr(),[a,s]=_a(),n=p.useRef(s),i=p.useMemo(()=>{const ot=parseInt(a.get("page")||"1",10);return Math.max(0,Number.isNaN(ot)?0:ot-1)},[a]),o=p.useCallback(ot=>{n.current(Lt=>{const oa=new URLSearchParams(Lt);return oa.set("page",String(ot+1)),oa})},[]);p.useEffect(()=>{n.current=s},[s]);const[l,c]=p.useState(null),[u,h]=p.useState(null),f=p.useRef(null),y=20;a.get("asset"),a.get("work_order_type");const[b,w]=p.useState(!1),[v,k]=p.useState(new Set),[S,N]=p.useState(!1),[C,O]=p.useState(!1),[T,P]=p.useState(!1),[E,R]=p.useState(!1),[z,G]=p.useState(!1),[ae,ee]=p.useState([]),[ne,te]=p.useState(!1),[Y,q]=p.useState(!1),[H,U]=p.useState(""),[re,X]=p.useState([]),[V,I]=p.useState(!1),{permissionFilters:B,loading:Q,error:ie}=jS("Work_Order"),{technicianOrFilters:me,isTechnicianOnly:he,loading:de,error:xe}=one(),ge=["System Manager","Cluster Manager","Contractor Supervisor","Contractor Manager","Work Control"],be=["System Manager","Cluster Manager","Work Control","End user"],K=["System Manager","Maintenance Manager","Work Control","Technician","Contractor Supervisor","Contractor Manager","Contractor Engineer"],ye=["Cluster Manager"],[Z,M]=p.useState(!1),[we,pe]=p.useState(!1),[le,Fe]=p.useState(!1);p.useEffect(()=>{J(null,null,function*(){try{const[Lt,oa,mr,Wa,Hr]=yield Promise.all([fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:ge.join(",")})}),fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:be.join(",")})}),fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:K.join(",")})}),fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:ye.join(",")})}),fetch("/api/method/frappe.auth.get_logged_user",{credentials:"include"})]),[Ts,ki,gn,Wn,Cn]=yield Promise.all([Lt.json(),oa.json(),mr.json(),Wa.json(),Hr.json()]);Ts.message&&M(Ts.message.has_role),ki.message&&pe(ki.message.has_role),gn.message&&Fe(gn.message.has_role),Wn.message&&te(Wn.message.has_role);const Hn=Cn.message||"";U(Hn);const Za=yield(yield fetch("/api/method/asset_lite.api.user_roles.get_user_roles",{credentials:"include"})).json(),ni=Array.isArray(Za.message)?Za.message:[];X(ni);const Jo=ni.includes("System Manager");I(Jo);const Ms=yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:["System Manager","Cluster Manager","Maintenance Manager","Work Control","Technician","Contractor Supervisor","Contractor Manager","Contractor Engineer"].join(",")})})).json();Ms.message&&q(!Ms.message.has_role)}catch(Lt){console.error("Error checking permissions:",Lt),M(!1),pe(!1),Fe(!1),te(!1),q(!1)}})},[]);const[ze,Re]=p.useState(()=>a.get("date_filter_by")||""),[De,Et]=p.useState(()=>a.get("date_start")||""),[jt,Ie]=p.useState(()=>a.get("date_end")||""),[$e,Qe]=p.useState(()=>a.get("work_order_id")||""),[at,Ct]=p.useState(()=>a.get("asset")||""),[vt,er]=p.useState(()=>a.get("work_order_type")||""),[nr,dt]=p.useState(()=>a.get("civil_work_category")||""),[He,it]=p.useState(()=>a.get("company")||""),[Ue,Ve]=p.useState(()=>a.get("status")||""),[lt,st]=p.useState(()=>a.get("serial_number")||""),[Mt,Ot]=p.useState(()=>a.get("manufacturer")||""),[Pt,zt]=p.useState(()=>a.get("supplier")||""),[Tt,Gt]=p.useState(()=>a.get("department")||""),[Ye,kt]=p.useState(()=>a.get("priority")||""),[Yt,Ae]=p.useState(()=>a.get("workflow_state")||""),ke=vt===yne,Be=["creation desc","creation asc","modified desc","modified asc","name asc","name desc"],[yt,Me]=p.useState(()=>a.get("sort_by")||"modified desc"),[Ke,Xe]=p.useState(!0),[oe,_e]=p.useState(0),[ve,Se]=p.useState([]),[Ce,Pe]=p.useState(!1),[rt,ut]=p.useState(""),[et,nt]=p.useState(()=>a.get("serial_number")||""),ct=p.useRef(null);p.useEffect(()=>{const ot=localStorage.getItem("workOrderFilterPresets");ot&&Se(JSON.parse(ot))},[]);const $t=ze&&(De||jt);p.useEffect(()=>{const ot=[$e,at,vt,ke?nr:"",He,Ue,lt,Mt,Pt,Tt,Ye,Yt].filter(Boolean).length+($t?1:0);_e(ot)},[$t,$e,at,vt,ke,nr,He,Ue,lt,Mt,Pt,Tt,Ye,Yt]);const Ut={};$e&&(Ut.name=$e),at&&(Ut.asset=at),vt&&(Ut.work_order_type=vt),ke&&nr&&(Ut.custom_civil_work_category=nr),He&&(Ut.company=He),Ue&&(Ut.repair_status=Ue),lt&&(Ut.custom_serial_number=["like",`%${lt}%`]),Mt&&(Ut.custom_manufacturer=Mt),Pt&&(Ut.supplier=Pt),Tt&&(Ut.department=Tt),Ye&&(Ut.custom_priority_=Ye),Yt&&(Ut.workflow_state=Yt),Object.assign(Ut,kl(ze,De,jt)),Ut.custom_delete_status=["!=","Deleted"],Y&&H&&(Ut.owner=H);const Xt=Be.includes(yt)?yt:"modified desc",{workOrders:pt,totalCount:Wt,hasMore:rr,loading:Mr,error:Br,refetch:Yr}=I9(Ut,y,i*y,Xt,B,me),{deleteWorkOrder:ma,loading:ps}=G4(),hn=p.useRef(!1);p.useEffect(()=>{!Mr&&!Q&&!de&&(Br||(hn.current=!0),b||w(!0))},[Mr,b,Q,de,Br]);const Rs=p.useRef(!1);p.useEffect(()=>{if(!Rs.current){Rs.current=!0;return}n.current(ot=>{const Lt=new URLSearchParams(ot);return ze?Lt.set("date_filter_by",ze):Lt.delete("date_filter_by"),De?Lt.set("date_start",De):Lt.delete("date_start"),jt?Lt.set("date_end",jt):Lt.delete("date_end"),$e?Lt.set("work_order_id",$e):Lt.delete("work_order_id"),at?Lt.set("asset",at):Lt.delete("asset"),vt?Lt.set("work_order_type",vt):Lt.delete("work_order_type"),ke&&nr?Lt.set("civil_work_category",nr):Lt.delete("civil_work_category"),He?Lt.set("company",He):Lt.delete("company"),Ue?Lt.set("status",Ue):Lt.delete("status"),lt?Lt.set("serial_number",lt):Lt.delete("serial_number"),Mt?Lt.set("manufacturer",Mt):Lt.delete("manufacturer"),Pt?Lt.set("supplier",Pt):Lt.delete("supplier"),Tt?Lt.set("department",Tt):Lt.delete("department"),Ye?Lt.set("priority",Ye):Lt.delete("priority"),Yt?Lt.set("workflow_state",Yt):Lt.delete("workflow_state"),yt&&yt!=="modified desc"?Lt.set("sort_by",yt):Lt.delete("sort_by"),Lt.set("page","1"),Lt})},[ze,De,jt,$e,at,vt,ke,nr,He,Ue,lt,Mt,Pt,Tt,Ye,Yt,yt]),p.useEffect(()=>{ke||dt("")},[ke]),p.useEffect(()=>{k(new Set)},[ze,De,jt,$e,at,vt,nr,He,Ue,lt,Mt,Pt,Tt,Ye,Yt,i]);const Un=ot=>{nt(ot),ct.current&&clearTimeout(ct.current),ct.current=window.setTimeout(()=>st(ot),800)},Tr=ot=>{ot.key==="Enter"&&(ot.preventDefault(),ct.current&&clearTimeout(ct.current),st(et))},Ir=()=>{if(!rt.trim()){alert("Please enter a filter name");return}const ot={id:Date.now(),name:rt,filters:{dateFilterBy:ze,dateStart:De,dateEnd:jt,sortBy:yt,filterWorkOrderId:$e,filterAsset:at,filterType:vt,filterCivilWorkCategory:nr,filterCompany:He,filterStatus:Ue,filterSerialNumber:lt,filterManufacturer:Mt,filterSupplier:Pt,filterDepartment:Tt,filterPriority:Ye,filterWorkflowState:Yt}},Lt=[...ve,ot];Se(Lt),ut(""),Pe(!1),localStorage.setItem("workOrderFilterPresets",JSON.stringify(Lt))},ws=ot=>{const Lt=ot.filters;Re(Lt.dateFilterBy||""),Et(Lt.dateStart||""),Ie(Lt.dateEnd||""),Me(Lt.sortBy||"modified desc"),Qe(Lt.filterWorkOrderId||""),Ct(Lt.filterAsset||""),er(Lt.filterType||""),dt(Lt.filterCivilWorkCategory||""),it(Lt.filterCompany||""),Ve(Lt.filterStatus||""),st(Lt.filterSerialNumber||""),nt(Lt.filterSerialNumber||""),Ot(Lt.filterManufacturer||""),zt(Lt.filterSupplier||""),Gt(Lt.filterDepartment||""),kt(Lt.filterPriority||""),Ae(Lt.filterWorkflowState||"")},Ca=ot=>{const Lt=ve.filter(oa=>oa.id!==ot);Se(Lt),localStorage.setItem("workOrderFilterPresets",JSON.stringify(Lt))};p.useEffect(()=>()=>{ct.current&&clearTimeout(ct.current)},[]),p.useEffect(()=>{const ot=Lt=>{f.current&&!f.current.contains(Lt.target)&&h(null)};return u&&document.addEventListener("mousedown",ot),()=>document.removeEventListener("mousedown",ot)},[u]);const pn=ot=>{k(Lt=>{const oa=new Set(Lt);return oa.has(ot)?oa.delete(ot):oa.add(ot),oa})},mt=()=>{v.size===pt.length?k(new Set):k(new Set(pt.map(ot=>ot.name)))},ft=pt.length>0&&v.size===pt.length,dr=v.size>0&&v.size<pt.length,vr=p.useCallback(()=>J(null,null,function*(){const ot=[];let Lt=0;const oa=100;let mr=!0;const Wa=se(se({},Ut),B),Hr=xa(Wa);for(;mr;)try{const Ts={doctype:"Work_Order",filters:Hr.length>0?Hr:{},fields:["*"],limit_start:Lt*oa,limit_page_length:oa,order_by:"creation desc"};me&&me.length>0&&(Ts.or_filters=me);const Wn=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ts)})).json()).message||[];ot.push(...Wn),Wn.length<oa?mr=!1:Lt++,Lt>100&&(console.warn("Export safety limit reached"),mr=!1)}catch(Ts){throw console.error("Error fetching work orders for export:",Ts),Ts}return ot}),[Ut,B,me]),Oe=()=>{const ot=pt.filter(Lt=>v.has(Lt.name)).map(Lt=>({name:Lt.name,workflow_state:Lt.workflow_state||"Draft",repair_status:Lt.repair_status||"Open"}));ee(ot),P(!0)},ar=()=>J(null,null,function*(){G(!0);const ot=ae.filter(Wa=>{var Hr;return((Hr=Wa.workflow_state)==null?void 0:Hr.toLowerCase())!=="closed"});let Lt=0,oa=0;const mr=[];for(const Wa of ot)try{const Ts=yield(yield fetch("/api/method/frappe.model.workflow.apply_workflow",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({doc:{doctype:"Work_Order",name:Wa.name},action:"Close"})})).json();if(Ts.exc||Ts.exception)throw new Error(Ts.exc||Ts.exception);Lt++}catch(Hr){console.error(`Failed to close ${Wa.name}:`,Hr),oa++,mr.push(Wa.name)}G(!1),P(!1),k(new Set),Yr(),Lt>0&&oa===0?alert(`Successfully closed ${Lt} work order${Lt!==1?"s":""}.`):Lt>0&&oa>0?alert(`Closed ${Lt} work order${Lt!==1?"s":""}. Failed to close ${oa}: ${mr.join(", ")}`):oa>0&&alert(`Failed to close work orders: ${mr.join(", ")}`)}),us=()=>r("/work-orders/new"),Bn=ot=>r(`/work-orders/${ot}`),Ba=ot=>r(`/work-orders/${ot}`),Sr=ot=>r(`/work-orders/new?duplicate=${ot}`),ji=ot=>J(null,null,function*(){try{yield ma(ot),c(null),Yr(),alert("Work order deleted successfully!")}catch(Lt){alert(`Failed to delete work order: ${Lt instanceof Error?Lt.message:"Unknown error"}`)}}),_i=ot=>{const Lt=JSON.stringify(ot,null,2),oa=new Blob([Lt],{type:"application/json"}),mr=URL.createObjectURL(oa),Wa=document.createElement("a");Wa.href=mr,Wa.download=`work_order_${ot.name}.json`,Wa.click(),URL.revokeObjectURL(mr)},js="Service_Report",fo=ot=>{const oa=`/printview?doctype=Work_Order&name=${encodeURIComponent(ot)}&format=${encodeURIComponent(js)}&trigger_print=1`;window.open(oa,"_blank")},xo=()=>{Re(""),Et(""),Ie(""),Me("modified desc"),Qe(""),Ct(""),er(""),dt(""),it(""),Ve(""),st(""),nt(""),Ot(""),zt(""),Gt(""),kt(""),Ae(""),n.current(ot=>{const Lt=new URLSearchParams(ot);return Lt.delete("date_filter_by"),Lt.delete("date_start"),Lt.delete("date_end"),Lt.delete("work_order_id"),Lt.delete("asset"),Lt.delete("work_order_type"),Lt.delete("civil_work_category"),Lt.delete("company"),Lt.delete("status"),Lt.delete("serial_number"),Lt.delete("manufacturer"),Lt.delete("supplier"),Lt.delete("department"),Lt.delete("priority"),Lt.delete("workflow_state"),Lt.set("page","1"),Lt}),ct.current&&clearTimeout(ct.current)},Go=$t||$e||at||vt||ke&&nr||He||Ue||lt||Mt||Pt||Tt||Ye||Yt,Ko=ot=>ot?new Date(ot).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"-",Sl=ot=>{switch(ot){case"Delete Request With Supervisor":return"bg-orange-50 dark:bg-orange-900/10";case"Delete Request With CM":return"bg-yellow-50 dark:bg-yellow-900/10";case"Deleted":return"bg-red-50 dark:bg-red-900/10";default:return""}},Vc=ot=>{switch(ot==null?void 0:ot.toLowerCase()){case"completed":return t.jsx(Qt,{className:"text-green-500"});case"in progress":return t.jsx(ea,{className:"text-blue-500"});case"pending":return t.jsx(Or,{className:"text-yellow-500"});default:return t.jsx(ea,{className:"text-gray-400"})}},Yo=ot=>{switch(ot==null?void 0:ot.toLowerCase()){case"completed":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300";case"in progress":return"bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-300";case"pending":case"open":return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-300";case"cancelled":return"bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-300";default:return"bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300"}},gs=ot=>{switch(ot==null?void 0:ot.toLowerCase()){case"high":case"urgent":return"bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-300";case"medium":return"bg-orange-100 dark:bg-orange-900/30 text-orange-800 dark:text-orange-300";case"low":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300";default:return"bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300"}};return(Q||de)&&!b?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("assets.loadingPermissions")})]})}):ie||xe?t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:"⚠️ Permission Error"}),t.jsxs("div",{className:"text-red-700 dark:text-red-400 space-y-3",children:[t.jsx("p",{children:t.jsx("strong",{children:"Unable to load user permissions."})}),t.jsx("p",{children:ie||xe}),t.jsx("button",{onClick:()=>window.location.reload(),className:"mt-2 bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded",children:"Retry"})]})]})}):Mr&&!b?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("workOrders.loadingWorkOrders")})]})}):Br&&b&&!hn.current?t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-yellow-800 dark:text-yellow-300 mb-4",children:"⚠️ Work Order API Not Available"}),t.jsxs("div",{className:"text-yellow-700 dark:text-yellow-400 space-y-3",children:[t.jsx("p",{children:t.jsx("strong",{children:"The Work Order API endpoint is not deployed yet."})}),t.jsx("button",{onClick:()=>r("/work-orders/new"),className:"mt-2 bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:"Try Creating a New Work Order (Demo)"}),t.jsx("button",{onClick:Yr,className:"mt-2 ml-2 bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded",children:"Try Again"})]})]})}):t.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-3xl font-bold text-gray-800 dark:text-white",children:e("workOrders.title")}),t.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:["Total: ",Wt," work order",Wt!==1?"s":"",v.size>0&&t.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",v.size," selected"]}),he&&t.jsx("span",{className:"ml-2 text-amber-600 dark:text-amber-400",children:"• Showing your assigned work orders"}),Mr&&b&&t.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400",children:[t.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-blue-500"}),"Updating..."]})]})]}),t.jsxs("div",{className:"flex gap-3",children:[le&&t.jsxs("button",{onClick:()=>R(!0),className:"bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",title:"Use this to bulk update work order status",children:[t.jsx(Q4,{}),t.jsx("span",{className:"font-medium",children:"Voice Command Assist"})]}),ne&&v.size>0&&t.jsxs("button",{onClick:Oe,className:"bg-orange-600 hover:bg-orange-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",children:[t.jsx(jN,{}),t.jsx("span",{className:"font-medium",children:"Close"}),t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:v.size})]}),t.jsxs("button",{onClick:()=>N(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",disabled:Wt===0,children:[t.jsx(Sa,{}),t.jsx("span",{className:"font-medium",children:e("listPages.export")}),v.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:v.size})]}),we&&t.jsxs("button",{onClick:us,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow-lg transition-all hover:shadow-xl",children:[t.jsx(Rr,{}),t.jsx("span",{className:"font-medium",children:e("workOrders.addWorkOrder")})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-4",children:[t.jsx("div",{className:"bg-gradient-to-r from-blue-500 to-blue-600 dark:from-blue-600 dark:to-blue-700 px-4 py-3 rounded-t-lg",children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx("button",{onClick:()=>Xe(!Ke),className:"text-white hover:bg-white/20 p-2 rounded-lg transition-all",children:Ke?t.jsx(Ja,{size:14}):t.jsx(Fr,{size:14})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ds,{className:"text-white",size:16}),t.jsx("h3",{className:"text-white font-semibold text-sm",children:"Filters"})]}),oe>0&&t.jsx("span",{className:"bg-white text-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:oe})]}),Go&&t.jsx("div",{className:"flex-1 overflow-x-auto scrollbar-hide mx-2",children:t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[$t&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("filters.filterBy"),":"]})," ",e(ze==="creation"?"filters.createdDate":"filters.latestModifiedDate")," ",De&&` ${De}`," ",jt&&` - ${jt}`,t.jsx("button",{onClick:ot=>{ot.stopPropagation(),Re(""),Et(""),Ie("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),$e&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-blue-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsx("span",{className:"font-semibold",children:"WO ID:"})," ",$e,t.jsx("button",{onClick:ot=>{ot.stopPropagation(),Qe("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),at&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-cyan-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsx("span",{className:"font-semibold",children:"Asset:"})," ",at,t.jsx("button",{onClick:ot=>{ot.stopPropagation(),Ct(""),a.delete("asset"),s(a)},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),vt&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-purple-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsx("span",{className:"font-semibold",children:"Type:"})," ",vt,t.jsx("button",{onClick:ot=>{ot.stopPropagation(),er(""),a.delete("work_order_type"),s(a)},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),ke&&nr&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-emerald-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsx("span",{className:"font-semibold",children:"Civil Category:"})," ",nr,t.jsx("button",{onClick:ot=>{ot.stopPropagation(),dt(""),a.delete("civil_work_category"),s(a)},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),He&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-green-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsx("span",{className:"font-semibold",children:"Hospital:"})," ",He,t.jsx("button",{onClick:ot=>{ot.stopPropagation(),it("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),Ue&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-orange-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsx("span",{className:"font-semibold",children:"Status:"})," ",Ue,t.jsx("button",{onClick:ot=>{ot.stopPropagation(),Ve("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),Yt&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-violet-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsx("span",{className:"font-semibold",children:"Workflow:"})," ",Yt,t.jsx("button",{onClick:ot=>{ot.stopPropagation(),Ae(""),a.delete("workflow_state"),s(a)},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),lt&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-lime-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsx("span",{className:"font-semibold",children:"Serial:"})," ",lt,t.jsx("button",{onClick:ot=>{ot.stopPropagation(),st(""),nt("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),Mt&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsx("span",{className:"font-semibold",children:"Mfr:"})," ",Mt,t.jsx("button",{onClick:ot=>{ot.stopPropagation(),Ot("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),Pt&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-teal-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsx("span",{className:"font-semibold",children:"Supplier:"})," ",Pt,t.jsx("button",{onClick:ot=>{ot.stopPropagation(),zt("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),Tt&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-yellow-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsx("span",{className:"font-semibold",children:"Dept:"})," ",Tt,t.jsx("button",{onClick:ot=>{ot.stopPropagation(),Gt("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),Ye&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-red-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsx("span",{className:"font-semibold",children:"Priority:"})," ",Ye,t.jsx("button",{onClick:ot=>{ot.stopPropagation(),kt("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]})]})}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[oe>0&&t.jsxs("button",{onClick:()=>Pe(!0),className:"px-3 py-1.5 bg-white text-blue-600 hover:bg-blue-50 rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[t.jsx(ta,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),Go&&t.jsxs("button",{onClick:xo,className:"px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[t.jsx(ht,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:"Clear"})]})]})]})}),Ke&&t.jsxs("div",{className:"p-4",children:[ve.length>0&&t.jsxs("div",{className:"mb-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[t.jsx(a0,{className:"text-yellow-500",size:12}),"Saved Filters"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:ve.map(ot=>t.jsxs("div",{className:"group relative inline-flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-purple-100 to-blue-100 dark:from-purple-900/30 dark:to-blue-900/30 border border-purple-200 dark:border-purple-700 rounded-lg hover:shadow-md transition-all",children:[t.jsx("button",{onClick:()=>ws(ot),className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:ot.name}),t.jsx("button",{onClick:()=>Ca(ot.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:t.jsx(wr,{size:10})})]},ot.id))})]}),t.jsx("div",{className:"space-y-5",children:t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 p-3 rounded-lg",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-3",children:[t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.sortBy")}),t.jsxs("select",{value:yt,onChange:ot=>Me(ot.target.value),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"creation desc",children:e("filters.sortCreationNewest")}),t.jsx("option",{value:"creation asc",children:e("filters.sortCreationOldest")}),t.jsx("option",{value:"modified desc",children:e("filters.sortModifiedNewest")}),t.jsx("option",{value:"modified asc",children:e("filters.sortModifiedOldest")}),t.jsx("option",{value:"name asc",children:e("filters.sortNameAsc")}),t.jsx("option",{value:"name desc",children:e("filters.sortNameDesc")})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.filterBy")}),t.jsxs("select",{value:ze,onChange:ot=>{const Lt=ot.target.value;Re(Lt)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("filters.filterBy")}),t.jsx("option",{value:"creation",children:e("filters.createdDate")}),t.jsx("option",{value:"modified",children:e("filters.latestModifiedDate")})]})]}),ze&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.startDate")}),t.jsx("input",{type:"date",value:De,onChange:ot=>{const Lt=ot.target.value;Et(Lt),jt&&Lt>jt&&Ie(Lt)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.endDate")}),t.jsx("input",{type:"date",value:jt,onChange:ot=>Ie(ot.target.value),min:De||void 0,className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]}),t.jsxs("div",{className:"relative z-[60]",children:[t.jsx(Je,{label:e("filters.workOrderId"),doctype:"Work_Order",value:$e,onChange:ot=>Qe(ot),placeholder:e("linkField.selectLabel",{label:e("filters.workOrderId")}),disabled:!1,compact:!0,filters:{custom_delete_status:["!=","Deleted"]}}),$e&&t.jsx("button",{onClick:()=>Qe(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[59]",children:[t.jsx(Je,{label:e("filters.asset"),doctype:"Asset",value:at,onChange:ot=>Ct(ot),placeholder:e("linkField.selectLabel",{label:e("filters.asset")}),disabled:!1,compact:!0,filters:{custom_delete_status:["!=","Deleted"]}}),at&&t.jsx("button",{onClick:()=>{Ct(""),a.delete("asset"),s(a)},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[58]",children:[t.jsx(Je,{label:e("filters.type"),doctype:"Issue Type",value:vt,onChange:ot=>{er(ot),a.has("work_order_type")&&(a.delete("work_order_type"),s(a))},placeholder:e("linkField.selectLabel",{label:e("filters.type")}),disabled:!1,compact:!0}),vt&&t.jsx("button",{onClick:()=>{er(""),a.delete("work_order_type"),s(a)},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),ke&&t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:"Civil Work Category"}),t.jsxs("select",{value:nr,onChange:ot=>dt(ot.target.value),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:"All Civil Categories"}),xne.map(ot=>t.jsx("option",{value:ot,children:ot},ot))]}),nr&&t.jsx("button",{onClick:()=>dt(""),className:"absolute right-8 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[57]",children:[t.jsx(Je,{label:e("filters.hospital"),doctype:"Company",value:He,onChange:ot=>it(ot),placeholder:e("linkField.selectLabel",{label:e("filters.hospital")}),disabled:!1,compact:!0,filters:{domain:"Healthcare"}}),He&&t.jsx("button",{onClick:()=>it(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.status")}),t.jsxs("select",{value:Ue,onChange:ot=>Ve(ot.target.value),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("filters.allStatuses")}),t.jsx("option",{value:"Open",children:e("workOrders.status.open")}),t.jsx("option",{value:"Work In Progress",children:e("workOrders.status.work_in_progress")}),t.jsx("option",{value:"Pending Review",children:e("workOrders.status.pending_review")}),t.jsx("option",{value:"Closed",children:e("workOrders.status.closed")})]}),Ue&&t.jsx("button",{onClick:()=>Ve(""),className:"absolute right-8 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[56]",children:[t.jsx(Je,{label:e("filters.workflowState","Workflow State"),doctype:"Workflow State",value:Yt,onChange:ot=>Ae(ot),placeholder:e("linkField.selectLabel",{label:e("filters.workflowState","Workflow State")}),disabled:!1,compact:!0}),Yt&&t.jsx("button",{onClick:()=>{Ae(""),a.delete("workflow_state"),s(a)},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("commonFields.serialNumber")}),t.jsx("input",{type:"text",value:et,onChange:ot=>Un(ot.target.value),onKeyDown:Tr,placeholder:e("common.typeToSearch"),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),et&&et!==lt&&t.jsx("span",{className:"absolute right-2 top-6 text-[9px] text-blue-500 animate-pulse",children:e("common.typing")}),lt&&t.jsx("button",{onClick:()=>{st(""),nt("")},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[55]",children:[t.jsx(Je,{label:e("filters.mfr"),doctype:"Manufacturer",value:Mt,onChange:ot=>Ot(ot),placeholder:e("linkField.selectLabel",{label:e("filters.mfr")}),disabled:!1,compact:!0}),Mt&&t.jsx("button",{onClick:()=>Ot(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[54]",children:[t.jsx(Je,{label:e("filters.supplier"),doctype:"Supplier",value:Pt,onChange:ot=>zt(ot),placeholder:e("linkField.selectLabel",{label:e("filters.supplier")}),disabled:!1,compact:!0}),Pt&&t.jsx("button",{onClick:()=>zt(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[53]",children:[t.jsx(Je,{label:e("filters.dept"),doctype:"Department",value:Tt,onChange:ot=>Gt(ot),placeholder:e("linkField.selectLabel",{label:e("filters.dept")}),disabled:!1,compact:!0}),Tt&&t.jsx("button",{onClick:()=>Gt(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.priority")}),t.jsxs("select",{value:Ye,onChange:ot=>kt(ot.target.value),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("filters.allPriorities")}),t.jsx("option",{value:"Normal",children:e("workOrders.priorityNormal")}),t.jsx("option",{value:"Urgent",children:e("workOrders.priorityUrgent")})]}),Ye&&t.jsx("button",{onClick:()=>kt(""),className:"absolute right-8 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(ht,{size:10})})]})]})})})]})]}),Ce&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 animate-scale-in",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:"Save Filter Preset"}),t.jsx("input",{type:"text",value:rt,onChange:ot=>ut(ot.target.value),onKeyDown:ot=>{ot.key==="Enter"&&(ot.preventDefault(),Ir())},placeholder:"Enter filter name (e.g., 'Pending High Priority')",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white mb-4",autoFocus:!0}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:()=>{Pe(!1),ut("")},className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",children:"Cancel"}),t.jsxs("button",{onClick:Ir,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors flex items-center gap-2",children:[t.jsx(ta,{size:12}),"Save Filter"]})]})]})}),t.jsx(bi,{isOpen:S,onClose:()=>N(!1),doctype:"Work_Order",selectedCount:v.size,pageCount:pt.length,totalCount:Wt,pageData:pt,selectedRows:v,rowKey:"name",onFetchAll:vr,fileNamePrefix:"work_orders",defaultColumns:["name","asset","asset_name","work_order_type","company","department","repair_status","workflow_state","custom_priority_","creation"],hiddenColumns:["docstatus","idx","amended_from","naming_series"]}),t.jsx(bne,{isOpen:T,onClose:()=>P(!1),selectedWorkOrders:ae,onConfirmClose:ar,isClosing:z}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden relative",children:[Mr&&b&&t.jsx("div",{className:"absolute inset-0 bg-white/60 dark:bg-gray-800/60 flex items-center justify-center z-10 backdrop-blur-[1px]",children:t.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-gray-700 px-4 py-2 rounded-lg shadow-lg",children:[t.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-blue-500"}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Filtering..."})]})}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left",children:t.jsx("button",{onClick:mt,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:ft?"Deselect all":"Select all",children:ft?t.jsx(Ra,{className:"text-blue-600 dark:text-blue-400",size:18}):dr?t.jsxs("div",{className:"relative",children:[t.jsx(Ur,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Ur,{size:18})})}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("workOrders.table.workOrderId")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("workOrders.table.asset")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("workOrders.table.type")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("workOrders.table.technicalReport")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("workOrders.table.department")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.status")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("workOrders.table.priority")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("common.actions")})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:pt.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:10,className:"px-6 py-12 text-center text-gray-500 dark:text-gray-400",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx(za,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("workOrders.table.noWorkOrdersFound")}),Go?t.jsx("button",{onClick:xo,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:e("common.clearFilters")}):we?t.jsx("button",{onClick:us,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:e("workOrders.table.createFirstWorkOrder")}):null]})})}):pt.map(ot=>{var Lt,oa;return t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${v.has(ot.name)?"bg-blue-50 dark:bg-blue-900/20":Sl((Lt=ot.custom_delete_status)!=null?Lt:void 0)}`,title:ot.custom_delete_status?`Delete Status: ${ot.custom_delete_status}`:void 0,onClick:()=>Bn(ot.name),children:[t.jsx("td",{className:"px-4 py-4",onClick:mr=>mr.stopPropagation(),children:t.jsx("button",{onClick:()=>pn(ot.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:v.has(ot.name)?t.jsx(Ra,{className:"text-blue-600 dark:text-blue-400",size:18}):t.jsx(Ur,{size:18})})}),t.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:ot.name}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:Ko(ot.modified)})]}),t.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[t.jsx("div",{className:"text-sm text-gray-900 dark:text-white",children:ot.asset_name||"-"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:ot.asset||""})]}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:ot.work_order_type||"-"}),t.jsx("td",{className:"px-6 py-4",children:t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300 max-w-xs truncate",title:ot.actions_performed||"",children:ot.actions_performed||"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:ot.department||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsxs("div",{className:"flex items-center gap-2",children:[Vc(ot.repair_status||""),t.jsx("span",{className:`px-3 py-1 inline-flex text-xs leading-5 font-semibold rounded-full ${Yo(ot.repair_status||"")}`,children:ot.repair_status||"Unknown"})]})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("span",{className:`px-3 py-1 inline-flex text-xs leading-5 font-semibold rounded-full ${gs(ot.custom_priority_||"")}`,children:ot.custom_priority_?e(`workOrders.priority.${ot.custom_priority_.toLowerCase()}`,ot.custom_priority_):e("workOrders.priority.normal","Normal")})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:t.jsxs("div",{className:"flex items-center gap-1",onClick:mr=>mr.stopPropagation(),children:[t.jsx("button",{onClick:()=>Bn(ot.name),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded transition-colors",title:"View Details",children:t.jsx(Ps,{})}),t.jsx("button",{onClick:()=>Ba(ot.name),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:"Edit Work Order",children:t.jsx(qr,{})}),t.jsx("button",{onClick:()=>Sr(ot.name),className:"text-purple-600 dark:text-purple-400 hover:text-purple-900 dark:hover:text-purple-300 p-2 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded transition-colors",title:"Duplicate Work Order",children:t.jsx(Vo,{})}),t.jsx("div",{onClick:mr=>mr.stopPropagation(),children:t.jsx(n0,{doctype:"Work_Order",docname:ot.name,currentDeleteStatus:(oa=ot.custom_delete_status)!=null?oa:null,userRoles:re,isSystemManager:V,triggerMode:!0,redirectOnDelete:"/work-orders",onStatusChange:()=>Yr()})}),t.jsxs("div",{className:"relative",ref:u===ot.name?f:null,children:[t.jsx("button",{onClick:()=>h(u===ot.name?null:ot.name),className:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 p-2 hover:bg-gray-50 dark:hover:bg-gray-700 rounded transition-colors",title:"More Actions",children:t.jsx(jx,{})}),u===ot.name&&t.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 z-10",children:[t.jsxs("button",{onClick:()=>{_i(ot),h(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2 rounded-t-lg",children:[t.jsx(qc,{className:"text-blue-500"}),"Export as JSON"]}),t.jsxs("button",{onClick:()=>{fo(ot.name),h(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2 rounded-b-lg",children:[t.jsx(yl,{className:"text-purple-500"}),"Print Work Order"]})]})]})]})})]},ot.name)})})]})}),t.jsx(_l,{currentPage:i+1,totalCount:Wt,pageSize:y,hasMore:rr,itemLabel:e("pagination.workOrders"),onPageChange:ot=>o(Math.max(0,ot-1))})]}),l&&t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx("div",{className:"flex-shrink-0 w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:t.jsx(wr,{className:"text-red-600 dark:text-red-400 text-xl"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:e("workOrders.deleteWorkOrder")}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:e("workOrders.deleteConfirmMessage")}),t.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-md p-3 mb-4",children:t.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[t.jsxs("strong",{children:[e("commonFields.workOrderId"),":"]})," ",l]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>c(null),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-lg transition-colors",disabled:ps,children:e("common.cancel")}),t.jsx("button",{onClick:()=>ji(l),className:"px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50",disabled:ps,children:ps?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),e("common.deleting")]}):t.jsxs(t.Fragment,{children:[t.jsx(wr,{}),e("workOrders.deleteWorkOrder")]})})]})]})]})})}),t.jsx(lne,{isOpen:C,onClose:()=>O(!1)}),t.jsx(kL,{isOpen:E,onClose:()=>R(!1),selectedRows:v,onUpdateSuccess:()=>{Yr(),k(new Set)}}),t.jsx("style",{children:`
|
||
@keyframes scale-in { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
|
||
.animate-scale-in { animation: scale-in 0.2s ease-out; }
|
||
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }
|
||
.scrollbar-hide::-webkit-scrollbar { display: none; }
|
||
`})]})},NL="--- Troubleshooting guide (completed) ---",wne="--- Troubleshooting tree (could not complete step) ---";function jne(e){return!!(e!=null&&e.includes(NL))}class _ne{constructor(){$s(this,"baseURL");this.baseURL=Ar.BASE_URL}getCSRFToken(){return J(this,null,function*(){try{return typeof window!="undefined"&&window.csrf_token?window.csrf_token:null}catch(r){return null}})}getHeaders(){return J(this,null,function*(){const r={Accept:"application/json","Content-Type":"application/json"},a=yield this.getCSRFToken();return a&&(r["X-Frappe-CSRF-Token"]=a),r})}getIssues(){return J(this,arguments,function*(r={}){const{filters:a={},fields:s=["name","subject","raised_by","status","priority","issue_type","opening_date","company","contact","creation","modified","first_responded_on","sla_resolution_date","sla_resolution_by"],limit_start:n=0,limit_page_length:i=20,order_by:o="creation desc"}=r,l=new URLSearchParams;if(l.append("fields",JSON.stringify(s)),l.append("limit_start",n.toString()),l.append("limit_page_length",i.toString()),l.append("order_by",o),Object.keys(a).length>0){const h=xa(a);h.length>0&&l.append("filters",JSON.stringify(h))}const c=yield fetch(`${this.baseURL}/api/resource/Issue?${l.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);return{data:(yield c.json()).data||[]}})}getIssue(r){return J(this,null,function*(){const a=yield fetch(`${this.baseURL}/api/resource/Issue/${encodeURIComponent(r)}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return(yield a.json()).data})}createIssue(r){return J(this,null,function*(){const a=yield fetch(`${this.baseURL}/api/resource/Issue`,{method:"POST",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(r)});if(!a.ok){const n=yield a.json().catch(()=>({}));throw new Error(n.message||`HTTP error! status: ${a.status}`)}return(yield a.json()).data})}updateIssue(r,a){return J(this,null,function*(){const s=yield fetch(`${this.baseURL}/api/resource/Issue/${encodeURIComponent(r)}`,{method:"PUT",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(a)});if(!s.ok){const i=yield s.json().catch(()=>({}));throw new Error(i.message||`HTTP error! status: ${s.status}`)}return(yield s.json()).data})}deleteIssue(r){return J(this,null,function*(){const a=yield fetch(`${this.baseURL}/api/resource/Issue/${encodeURIComponent(r)}`,{method:"DELETE",headers:yield this.getHeaders(),credentials:"include"});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`)})}getIssueCount(){return J(this,arguments,function*(r={}){var i,o;const a=new URLSearchParams;if(a.append("fields",JSON.stringify(["count(name) as count"])),Object.keys(r).length>0){const l=xa(r);l.length>0&&a.append("filters",JSON.stringify(l))}const s=yield fetch(`${this.baseURL}/api/resource/Issue?${a.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return((o=(i=(yield s.json()).data)==null?void 0:i[0])==null?void 0:o.count)||0})}}const Dd=new _ne,kne="Service_Report",ef=()=>{const e=new Date,r=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0"),n=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0");return`${r}-${a}-${s}T${n}:${i}`},vk=()=>{const e=new Date,r=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0"),n=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0"),o=String(e.getSeconds()).padStart(2,"0");return`${r}-${a}-${s} ${n}:${i}:${o}`},Lh=e=>{if(!e)return"";if(e.length===10)return`${e}T00:00`;if(e.includes(" ")){const[r,a]=e.split(" "),s=a.substring(0,5);return`${r}T${s}`}return e.includes("T")?e.substring(0,16):e},Fh=e=>e?e.includes("T")?e.replace("T"," ")+":00":e:"",kc=e=>{if(!e)return"-";try{return new Date(e.replace(" ","T")).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})}catch(r){return e}},Nne=(e,r)=>{if(!e)return"";const a=e.split("T")[0].split(" ")[0],s=new Date(a);return s.setDate(s.getDate()+r),s.toISOString().split("T")[0]},Sne=(e,r)=>{const a=new Date,s=l=>String(l).padStart(2,"0"),n=`${a.getFullYear()}-${s(a.getMonth()+1)}-${s(a.getDate())}T${s(a.getHours())}:${s(a.getMinutes())}`;if(!(e!=null&&e.trim()))return n;const i=e.split(" ")[0].split("T")[0];let o="00:00";return r&&String(r).trim().length>=5&&(o=String(r).substring(0,5)),`${i}T${o}`},Cne=["Normal","Medium","Urgent"],wk=e=>{if(!(e!=null&&e.trim()))return"Normal";const r=e.trim();if(Cne.includes(r))return r;const a=r.toLowerCase();return a==="low"?"Normal":a==="medium"?"Medium":a==="high"||a==="urgent"||a==="critical"?"Urgent":"Normal"},Tne=()=>{var _o,Rl,cd;const{t:e}=sr(),{workOrderName:r}=hs(),a=hr(),s=mo(),[n]=_a(),i=n.get("duplicate"),o=n.get("asset"),l=!!o,c=r==="new",u=c&&!!i,h=n.get("from_issue"),f=c&&!!h&&!u,[y,b]=p.useState(!f),w=()=>{if(!r||c)return;const Te=`/printview?doctype=Work_Order&name=${encodeURIComponent(r)}&format=${encodeURIComponent(kne)}&trigger_print=1`;window.open(Te,"_blank")||We.warning(e("workOrders.detail.pleaseAllowPopupsServiceReport"),{position:"top-right",autoClose:5e3,icon:t.jsx(Or,{})})},[v,k]=p.useState(!1),[S,N]=p.useState([]),[C,O]=p.useState(!1),[T,P]=p.useState(""),[E,R]=p.useState(!1),[z,G]=p.useState([]),[ae,ee]=p.useState([]),[ne,te]=p.useState(""),[Y,q]=p.useState(!1),[H,U]=p.useState(!1),[re,X]=p.useState(null),[V,I]=p.useState([]),[B,Q]=p.useState(!1),[ie,me]=p.useState([]),[he,de]=p.useState("room"),[xe,ge]=p.useState(!1),[be,K]=p.useState(!1),[ye,Z]=p.useState(0),{workOrder:M,loading:we,error:pe,refetch:le}=z9(u?i:c?null:r||null),{createWorkOrder:Fe,updateWorkOrder:ze,loading:Re}=G4();p.useEffect(()=>{if(c||!r)return;const fe=s.state;fe!=null&&fe.troubleshootGuideJustCompleted&&(le(),a({pathname:s.pathname,search:s.search,hash:s.hash},{replace:!0,state:{}}))},[s.state,s.pathname,s.search,s.hash,a,le,c,r]);const[De,Et]=p.useState(c),[jt,Ie]=p.useState(!1),[$e,Qe]=p.useState(null),at=["System Manager","Work Control","Contractor Supervisor","Contractor Manager","Maintenance Manager","Cluster Manager","Contractor Engineer","Quality Supervisor","Technician"],[Ct,vt]=p.useState(!1),[er,nr]=p.useState(null),dt=gr.useRef(!1),[He,it]=p.useState(!1),[Ue,Ve]=p.useState(!1),[lt,st]=p.useState(!1),[Mt,Ot]=p.useState([]),[Pt,zt]=p.useState([]),[Tt,Gt]=p.useState([]),[Ye,kt]=p.useState(!1),[Yt,Ae]=p.useState(""),[ke,Be]=p.useState(""),[yt,Me]=p.useState(""),[Ke,Xe]=p.useState(""),[oe,_e]=p.useState([]),[ve,Se]=p.useState([]),[Ce,Pe]=p.useState(!1),[rt,ut]=p.useState(!1),[et,nt]=p.useState(""),[ct,$t]=p.useState(!1),[Ut,Xt]=p.useState([]),[pt,Wt]=p.useState(!1),[rr,Mr]=p.useState(!1),[Br,Yr]=p.useState(!1),[ma,ps]=p.useState(null),[hn,Rs]=p.useState(!1),[Un,Tr]=p.useState(!1),[Ir,ws]=p.useState("give"),[Ca,pn]=p.useState([{parameter:"Quality of Service",rating:0,feedback:""},{parameter:"Timeliness",rating:0,feedback:""},{parameter:"Professionalism",rating:0,feedback:""},{parameter:"Communication",rating:0,feedback:""}]),[mt,ft]=p.useState(!1),[dr,vr]=p.useState(""),[Oe,ar]=p.useState({company:"King Fahad Specialist Hospital - Dammam",work_order_type:"",custom_type:"Corrective",custom_civil_work_category:"",asset:"",asset_name:"",description:"",repair_status:"Open",workflow_state:"Draft",department:"",custom_priority_:"Normal",asset_type:"Non Biomedical",manufacturer:"",supplier:"",serial_number:"",model:"",custom_site_contractor:"",custom_subcontractor:"",failure_date:c?ef():"",custom_deadline_date:"",completion_date:"",first_responded_on:"",actions_performed:"",stock_consumption:0,stock_items:[],site_name:"",need_procurement:0,custom_assign_to_contractor:"",assigned_technician:"",custom_assigned_engineer:"",docstatus:0,custom_assigned_supervisor:"",total_hours_spent:0,custom_pending_reason:"",total_repair_cost:0,custom_travel_hour:"",custom_service_agreement:"",custom_service_coverage:"",custom_start_date:"",custom_end_date:"",custom_total_amount:0,custom_location:"",custom_extension_no:"",custom_attachment:"",custom_attachment_on_close:"",custom_add_technicians:"",inspection:"",custom_department_no:"",custom_reason:"",custom_technical_department:"",custom_room_no:"",custom_building:"",issue:"",__islocal:!1}),us=Oe.asset_type==="Non Biomedical",Ba=p.useCallback(()=>{const fe=(M==null?void 0:M.workflow_state)||Oe.workflow_state||"Draft";return fe==="Cancelled"?2:fe==="Closed"?1:(M==null?void 0:M.docstatus)||Oe.docstatus||0},[M==null?void 0:M.workflow_state,Oe.workflow_state,M==null?void 0:M.docstatus,Oe.docstatus])(),_i=Ba===1||Ba===2,js=!!er,fo=!!(T&&(M!=null&&M.owner)&&T===M.owner),xo=fe=>{const Te=new Date;return Te.setDate(Te.getDate()-(fe-1)),Te.toISOString().split("T")[0]},Go=()=>J(null,null,function*(){var fe;try{const Te=yield At.apiCall("/api/resource/Work Order Settings/Work Order Settings");return(fe=Te==null?void 0:Te.data)!=null&&fe.custom_days&&parseInt(Te.data.custom_days)||1}catch(Te){return console.error("Error fetching days config:",Te),1}}),Ko=p.useCallback((fe,Te)=>J(null,null,function*(){if(!(!fe||!Te||!c)){ge(!0);try{const qe=yield Go(),Kt=xo(qe),lr=[["work_order_type","=",fe],["custom_room_no","=",Te],["workflow_state","not in",["Approved","Closed","Cancelled"]],["creation",">=",`${Kt} 00:00:00`]],Ht=yield At.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify(lr))}&fields=["name","workflow_state","creation"]&limit=10`);Ht!=null&&Ht.data&&Ht.data.length>0&&(me(Ht.data),de("room"),Q(!0))}catch(qe){console.error("Error checking duplicates by Room No:",qe)}finally{ge(!1)}}}),[c]),Sl=p.useCallback(fe=>J(null,null,function*(){if(!(!fe||!c)){ge(!0);try{const Te=[["asset","=",fe],["workflow_state","not in",["Approved","Closed","Cancelled"]]],qe=yield At.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify(Te))}&fields=["name","workflow_state","creation"]&limit=10`);qe!=null&&qe.data&&qe.data.length>0&&(me(qe.data),de("asset"),Q(!0))}catch(Te){console.error("Error checking duplicates by Asset:",Te)}finally{ge(!1)}}}),[c]),Vc=()=>{Q(!1),me([])},Yo=()=>{Q(!1),me([]),ar(he==="asset"?fe=>je(se({},fe),{asset:"",asset_name:""}):fe=>je(se({},fe),{work_order_type:"",custom_room_no:""}))};p.useEffect(()=>{const fe=Oe.work_order_type,Te=Oe.custom_room_no;if(c&&!Oe.asset&&fe&&Te){const qe=setTimeout(()=>{Ko(fe,Te)},500);return()=>clearTimeout(qe)}},[c,Oe.asset,Oe.work_order_type,Oe.custom_room_no,Ko]),p.useEffect(()=>{const fe=Oe.asset;if(c&&fe){const Te=setTimeout(()=>{Sl(fe)},500);return()=>clearTimeout(Te)}},[c,Oe.asset,Sl]),p.useEffect(()=>{const Te=setTimeout(()=>J(null,null,function*(){var Kt,lr;if(Oe.asset){K(!1),Z(0);return}if(!(Oe.custom_building||Oe.department||Oe.custom_room_no)){K(!1),Z(0);return}try{const Ht=[["docstatus","=","1"]];Oe.company&&Ht.push(["company","=",Oe.company]),Oe.custom_building&&Ht.push(["custom_building","=",Oe.custom_building]),Oe.department&&Ht.push(["department","=",Oe.department]),Oe.custom_room_no&&Ht.push(["custom_room_number","=",Oe.custom_room_no]);const jr=yield At.apiCall(`/api/resource/Asset?filters=${encodeURIComponent(JSON.stringify(Ht))}&fields=["name"]&limit=1000`),ra=((Kt=jr==null?void 0:jr.data)==null?void 0:Kt.length)||0;Z(ra),K(ra>=1);const ns=!!(Oe.custom_building&&Oe.department&&Oe.custom_room_no);ra===1&&((lr=jr.data[0])!=null&&lr.name)&&!Oe.asset&&ns&&(Al(jr.data[0].name),We.info(`Asset auto-selected: ${jr.data[0].name}`,{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}))}catch(Ht){console.error("Error checking asset count:",Ht),K(!1),Z(0)}}),500);return()=>clearTimeout(Te)},[Oe.asset,Oe.company,Oe.custom_building,Oe.department,Oe.custom_room_no]),p.useEffect(()=>{const fe=S.includes("Technician");!c&&(M==null?void 0:M.workflow_state)==="Repair InProgress"&&!js&&fe&&Et(!0)},[c,M==null?void 0:M.workflow_state,js,S]),p.useEffect(()=>{J(null,null,function*(){if(!c&&r&&(M==null?void 0:M.workflow_state)==="Repair InProgress"&&(!(M!=null&&M.first_responded_on)||M.first_responded_on==="")){const Te=vk();try{yield ze(r,{first_responded_on:Te}),ar(qe=>je(se({},qe),{first_responded_on:Lh(Te)})),We.info(e("workOrders.detail.firstRespondedOnSetTo",{datetime:kc(Te)}),{position:"top-right",autoClose:3e3,icon:t.jsx(ea,{})}),le(),setTimeout(()=>{gs()},500),console.log("Auto-set first_responded_on to:",Te)}catch(qe){console.error("Error auto-setting first_responded_on:",qe)}}})},[c,r,M==null?void 0:M.workflow_state,M==null?void 0:M.first_responded_on]),p.useEffect(()=>{J(null,null,function*(){if(!c&&r&&(M==null?void 0:M.workflow_state)==="Closed"&&(!(M!=null&&M.completion_date)||M.completion_date==="")){const Te=vk();try{yield ze(r,{completion_date:Te}),ar(qe=>je(se({},qe),{completion_date:Lh(Te)})),We.info(e("workOrders.detail.completionDateSetTo",{datetime:kc(Te)}),{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),le(),setTimeout(()=>{gs()},500),console.log("Auto-set completion_date to:",Te)}catch(qe){console.error("Error auto-setting completion_date:",qe)}}})},[c,r,M==null?void 0:M.workflow_state,M==null?void 0:M.completion_date]),p.useEffect(()=>{if(!T)return;O(!1),N([]),J(null,null,function*(){try{const qe=yield(yield fetch(`/api/method/asset_lite.api.user_roles.get_user_roles?_=${Date.now()}`,{method:"GET",headers:{"Content-Type":"application/json","Cache-Control":"no-cache, no-store, must-revalidate",Pragma:"no-cache"},credentials:"include"})).json();qe.message&&Array.isArray(qe.message)&&(N(qe.message),console.log("User roles fetched for:",T,qe.message))}catch(Te){console.error("Error fetching user roles:",Te),N([])}finally{O(!0)}})},[T]),p.useEffect(()=>{J(null,null,function*(){try{const qe=yield(yield fetch("/api/method/frappe.auth.get_logged_user",{method:"GET",headers:{"Content-Type":"application/json","Cache-Control":"no-cache, no-store, must-revalidate",Pragma:"no-cache"},credentials:"include"})).json();qe.message&&(P(qe.message),console.log("Current user:",qe.message))}catch(Te){console.error("Error fetching current user:",Te),P("")}})},[]),p.useEffect(()=>{J(null,null,function*(){try{const qe=yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({roles:at.join(",")})})).json();qe.message&&(vt(qe.message.has_role),console.log("Can delete/cancel:",qe.message.has_role))}catch(Te){console.error("Error checking delete permissions:",Te),vt(!1)}})},[]);const gs=p.useCallback(()=>J(null,null,function*(){if(!(c||!r)){Wt(!0);try{const fe=yield At.apiCall(`/api/resource/Version?filters=[["ref_doctype","=","Work_Order"],["docname","=","${encodeURIComponent(r)}"]]&fields=["name","owner","creation","data"]&order_by=creation desc&limit=50`);if(fe!=null&&fe.data&&fe.data.length>0){const Te=fe.data.map(qe=>{let Kt={added:[],changed:[],removed:[],row_changed:[]};try{Kt=JSON.parse(qe.data||"{}")}catch(Ht){console.error("Error parsing version data:",Ht)}const lr=(Kt.changed||[]).map(Ht=>({field:Ht[0]||"",oldValue:Ht[1],newValue:Ht[2]}));return{name:qe.name,owner:qe.owner,creation:qe.creation,changes:lr,added:Kt.added||[],removed:Kt.removed||[],rowChanged:Kt.row_changed||[]}});Xt(Te),console.log("Audit logs fetched:",Te.length)}else Xt([])}catch(fe){console.error("Error fetching audit logs:",fe),Xt([])}finally{Wt(!1)}}}),[c,r]);p.useEffect(()=>{gs()},[gs]);const ot=p.useCallback(()=>J(null,null,function*(){var fe;try{const qe=yield(yield fetch("/api/method/frappe.client.get_value",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({doctype:"User",filters:{name:T},fieldname:"full_name"})})).json();(fe=qe.message)!=null&&fe.full_name&&vr(qe.message.full_name)}catch(Te){console.error("Error fetching user full name:",Te)}}),[T]),Lt=p.useCallback(()=>J(null,null,function*(){if(!(c||!r||!(M!=null&&M.owner))){Rs(!0);try{const fe=JSON.stringify([["work_order","=",r],["feedback_by","=",(M==null?void 0:M.owner)||T]]),Te=yield At.apiCall(`/api/resource/Feedback?filters=${encodeURIComponent(fe)}&fields=["name"]&limit=1`);if(Te!=null&&Te.data&&Te.data.length>0){const qe=yield At.apiCall(`/api/resource/Feedback/${Te.data[0].name}`);qe!=null&&qe.data&&ps(qe.data)}else ps(null)}catch(fe){console.error("Error fetching feedback:",fe),ps(null)}finally{Rs(!1)}}}),[c,r,T]);p.useEffect(()=>{const fe=(M==null?void 0:M.workflow_state)||Oe.workflow_state||"";["Approved","Closed"].includes(fe)&&(T||M!=null&&M.owner)&&(Lt(),T&&ot())},[M==null?void 0:M.workflow_state,Oe.workflow_state,T,M==null?void 0:M.owner,Lt,ot]);const oa=()=>{pn([{parameter:"Quality of Service",rating:0,feedback:""},{parameter:"Timeliness",rating:0,feedback:""},{parameter:"Professionalism",rating:0,feedback:""},{parameter:"Communication",rating:0,feedback:""}]),ws("give"),Tr(!0)},mr=()=>{ma!=null&&ma.parameters&&pn(ma.parameters.map(fe=>({parameter:fe.parameter,rating:fe.rating||0,feedback:fe.feedback||""}))),ws("view"),Tr(!0)},Wa=()=>{ws("edit")},Hr=(fe,Te)=>{pn(qe=>{const Kt=[...qe];return Kt[fe]=je(se({},Kt[fe]),{rating:Te}),Kt})},Ts=fe=>{const Te=fe.filter(Kt=>Kt.rating>0);if(Te.length===0)return 0;const qe=Te.reduce((Kt,lr)=>Kt+lr.rating,0);return parseFloat((qe/Te.length).toFixed(2))},ki=()=>J(null,null,function*(){if(!Ca.some(Te=>Te.rating>0)){We.warning(e("workOrders.detail.pleaseProvideAtLeastOneRating"),{position:"top-right",autoClose:3e3,icon:t.jsx(Or,{})});return}ft(!0);try{const Te=Ts(Ca),qe={doctype:"Feedback",work_order:r,feedback_by:T,overall:Te,parameters:Ca.map((Ht,jr)=>({parameter:Ht.parameter,rating:Ht.rating,feedback:Ht.feedback||null,idx:jr+1}))},lr=yield(yield fetch("/api/resource/Feedback",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(qe)})).json();if(lr.data)ps(lr.data),Tr(!1),We.success(e("workOrders.detail.feedbackSubmittedSuccessfully"),{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})});else throw new Error(lr.exc||"Failed to submit feedback")}catch(Te){console.error("Error submitting feedback:",Te);const qe=Te instanceof Error?Te.message:"Unknown error";We.error(`${e("workOrders.detail.failedToSubmitFeedback")}: ${qe}`,{position:"top-right",autoClose:5e3,icon:t.jsx(pr,{})})}finally{ft(!1)}}),gn=()=>J(null,null,function*(){if(ma!=null&&ma.name){ft(!0);try{const fe=Ts(Ca),Te=Ca.map((lr,Ht)=>{var ra;const jr=(ra=ma.parameters)==null?void 0:ra[Ht];return je(se({},jr!=null&&jr.name?{name:jr.name}:{}),{parameter:lr.parameter,rating:lr.rating,feedback:lr.feedback||null,idx:Ht+1})}),Kt=yield(yield fetch(`/api/resource/Feedback/${ma.name}`,{method:"PUT",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({overall:fe,parameters:Te})})).json();if(Kt.data)ps(Kt.data),ws("view"),We.success(e("workOrders.detail.feedbackUpdatedSuccessfully"),{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})});else throw new Error(Kt.exc||"Failed to update feedback")}catch(fe){console.error("Error updating feedback:",fe);const Te=fe instanceof Error?fe.message:"Unknown error";We.error(`${e("workOrders.detail.failedToUpdateFeedback")}: ${Te}`,{position:"top-right",autoClose:5e3,icon:t.jsx(pr,{})})}finally{ft(!1)}}}),Wn=fe=>({"Medical Gas – الغازات الطبية":"Mechanical Maintenance-الصيانة الميكانيكية"})[fe]||fe,Cn=p.useCallback(fe=>J(null,null,function*(){if(!fe){Ot([]);return}const Te=Wn(fe);try{const qe=yield At.apiCall(`/api/resource/Asset Maintenance Team?filters=[["custom_expertise","=","${encodeURIComponent(Te)}"]]&fields=["maintenance_manager"]&limit=100`);if(qe!=null&&qe.data&&qe.data.length>0){const Kt=qe.data.map(Ht=>Ht.maintenance_manager).filter(Ht=>Ht),lr=[...new Set(Kt)];console.log("Filtered Managers based on expertise:",lr),Ot(lr)}else Ot([])}catch(qe){console.error("Error fetching managers based on expertise:",qe),Ot([])}}),[]),Hn=p.useCallback(fe=>J(null,null,function*(){if(!fe){zt([]);return}const Te=Wn(fe);try{console.log("Filtering technicians for work order type:",fe,"→ expertise:",Te);const qe=yield At.apiCall(`/api/resource/Asset Maintenance Team?filters=[["custom_expertise","=","${encodeURIComponent(Te)}"]]&fields=["name"]&limit=100`);if(qe!=null&&qe.data&&qe.data.length>0){const Kt=new Set,lr=qe.data.map(jr=>J(null,null,function*(){try{const ra=yield At.apiCall(`/api/resource/Asset Maintenance Team/${encodeURIComponent(jr.name)}`);ra!=null&&ra.data&&(ra.data.maintenance_team_members||[]).forEach(ha=>{ha.team_member&&Kt.add(ha.team_member)})}catch(ra){console.error("Error fetching team:",jr.name,ra)}}));yield Promise.all(lr);const Ht=Array.from(Kt);console.log("Filtered Technicians:",Ht),zt(Ht)}else zt([])}catch(qe){console.error("Error fetching technicians:",qe),zt([])}}),[]),yo=p.useCallback(fe=>J(null,null,function*(){if(!fe){Gt([]);return}const Te=Wn(fe);try{console.log("Filtering engineers for work order type:",fe,"→ expertise:",Te);const qe=yield At.apiCall(`/api/resource/Asset Maintenance Team?filters=[["custom_expertise","=","${encodeURIComponent(Te)}"]]&fields=["name"]&limit=100`);if(qe!=null&&qe.data&&qe.data.length>0){const Kt=new Set,lr=qe.data.map(jr=>J(null,null,function*(){try{const ra=yield At.apiCall(`/api/resource/Asset Maintenance Team/${encodeURIComponent(jr.name)}`);ra!=null&&ra.data&&(ra.data.maintenance_team_members||[]).forEach(ha=>{ha.team_member&&ha.maintenance_role==="Contractor Engineer"&&Kt.add(ha.team_member)})}catch(ra){console.error("Error fetching team for engineers:",jr.name,ra)}}));yield Promise.all(lr);const Ht=Array.from(Kt);console.log("Filtered Engineers (Contractor Engineer role):",Ht),Gt(Ht)}else Gt([])}catch(qe){console.error("Error fetching engineers:",qe),Gt([])}}),[]),Za=p.useCallback(fe=>J(null,null,function*(){if(!fe){_e([]);return}Pe(!0);try{const Te=JSON.stringify([["building","=",fe]]),qe=yield At.apiCall(`/api/resource/Infrastructure Location?filters=${encodeURIComponent(Te)}&fields=["department"]&limit=9999`);if(qe!=null&&qe.data&&qe.data.length>0){const Kt=qe.data.map(Ht=>Ht.department).filter(Ht=>Ht),lr=[...new Set(Kt)];console.log("Filtered Departments for building:",fe,lr),_e(lr)}else _e([])}catch(Te){console.error("Error fetching departments for building:",Te),_e([])}finally{Pe(!1)}}),[]),ni=p.useCallback((fe,Te)=>J(null,null,function*(){if(!fe&&!Te){Se([]);return}Pe(!0);try{const qe=new URLSearchParams;fe&&qe.append("building",fe),Te&&qe.append("department",Te);const Ht=(yield(yield fetch(`/api/method/asset_lite.api.room_filter.get_room_count?${qe.toString()}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json()).message||0;Se(new Array(Ht).fill("")),console.log("Room count:",{building:fe,department:Te,count:Ht})}catch(qe){console.error("Error fetching room count:",qe),Se([])}finally{Pe(!1)}}),[]),Jo=p.useCallback((fe,Te,qe)=>J(null,null,function*(){if(qe&&!(!fe&&!Te)){Pe(!0);try{const Kt=[["room_no","=",qe]];fe&&Kt.push(["building","=",fe]),Te&&Kt.push(["department","=",Te]);const lr=JSON.stringify(Kt),Ht=yield At.apiCall(`/api/resource/Infrastructure Location?filters=${encodeURIComponent(lr)}&fields=["location"]&limit=1`);if(Ht!=null&&Ht.data&&Ht.data.length>0&&Ht.data[0].location){const jr=Ht.data[0].location;console.log("Auto-setting location:",jr,{building:fe,department:Te,roomNo:qe}),ar(ra=>ra.custom_location===jr?ra:(We.info(e("workOrders.detail.locationAutoSetTo",{location:jr}),{position:"top-right",autoClose:2e3,icon:t.jsx(Qt,{})}),je(se({},ra),{custom_location:jr})))}}catch(Kt){console.error("Error fetching location:",Kt)}finally{Pe(!1)}}}),[]);p.useCallback(()=>J(null,null,function*(){q(!0);try{const Te=yield(yield fetch("/api/method/asset_lite.api.user_roles.get_users_with_role",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({role:"Technician"})})).json();if(Te.message&&Array.isArray(Te.message)){const qe=Te.message.map(Kt=>({name:Kt.name,full_name:Kt.full_name||Kt.name}));ee(qe),console.log("Fetched technicians:",qe.length)}else ee([]),console.log("No technicians found")}catch(fe){console.error("Error fetching technicians:",fe),ee([])}finally{q(!1)}}),[]);const hc=fe=>{G(Te=>Te.includes(fe)?Te.filter(qe=>qe!==fe):[...Te,fe])},d0=()=>{if(z.length===0){We.warning(e("workOrders.detail.noTechniciansSelected"),{position:"top-right",autoClose:3e3,icon:t.jsx(Or,{})});return}I(z),U(!0)},Ms=()=>{const fe=V.join(",");ar(Te=>je(se({},Te),{custom_add_technicians:fe})),U(!1),R(!1),I([]),We.success(e("workOrders.detail.techniciansAssignedSuccessfully",{count:V.length}),{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})})},bo=()=>{U(!1),I([])},Gc=p.useMemo(()=>{if(!ne)return ae;const fe=ne.toLowerCase();return ae.filter(Te=>Te.name.toLowerCase().includes(fe)||Te.full_name&&Te.full_name.toLowerCase().includes(fe))},[ae,ne]);p.useEffect(()=>{Oe.work_order_type?Cn(Oe.work_order_type):Ot([])},[Oe.work_order_type,Cn]),p.useEffect(()=>{Oe.work_order_type?Hn(Oe.work_order_type):zt([])},[Oe.work_order_type,Hn]),p.useEffect(()=>{Oe.work_order_type?yo(Oe.work_order_type):Gt([])},[Oe.work_order_type,yo]),p.useEffect(()=>{Oe.custom_building?Za(Oe.custom_building):_e([])},[Oe.custom_building,Za]),p.useEffect(()=>{const fe=Oe.custom_building||void 0,Te=Oe.department||void 0;fe||Te?ni(fe,Te):Se([])},[Oe.custom_building,Oe.department,ni]),p.useEffect(()=>{const fe=Oe.custom_building||void 0,Te=Oe.department||void 0,qe=Oe.custom_room_no||void 0;qe&&(fe||Te)&&Jo(fe,Te,qe)},[Oe.custom_building,Oe.department,Oe.custom_room_no,Jo]);const Cl=p.useCallback((fe,Te,qe)=>{if(!fe)return"";let Kt=0;const lr=qe===1;return Te==="Normal"?Kt=lr?30:5:Te==="Medium"?Kt=lr?30:3:Te==="Urgent"&&(Kt=lr?30:1),Nne(fe,Kt)},[]);p.useEffect(()=>{if(!De)return;const fe=Cl(Oe.failure_date,Oe.custom_priority_||"Normal",Oe.need_procurement||0);fe&&fe!==Oe.custom_deadline_date&&ar(Te=>je(se({},Te),{custom_deadline_date:fe}))},[Oe.failure_date,Oe.custom_priority_,Oe.need_procurement,De,Cl]),p.useEffect(()=>{us&&De&&ar(fe=>je(se({},fe),{asset:"",asset_name:"",serial_number:"",manufacturer:"",supplier:"",model:""}))},[us,De]);const{shouldShowField:la,isMandatory:du,isReadOnly:Tn}=gL("Work_Order",Oe);p.useCallback(fe=>la(fe),[la]),p.useCallback(fe=>du(fe),[du]);const Ii=p.useCallback(fe=>Tn(fe),[Tn]),Kc=p.useCallback(()=>!!(Oe.custom_building||Oe.department),[Oe.custom_building,Oe.department]),Km=p.useCallback(()=>!!(Oe.department||Oe.custom_room_no),[Oe.department,Oe.custom_room_no]),u0=p.useCallback(()=>!!(Oe.custom_room_no||Oe.custom_location),[Oe.custom_room_no,Oe.custom_location]);p.useCallback(fe=>_i||js||!De?!0:Ii(fe),[De,Ii,_i,js]),p.useMemo(()=>{if(!et)return ve.slice(0,30);const fe=et.toLowerCase();return ve.filter(Te=>Te.toLowerCase().includes(fe)).slice(0,50)},[ve,et]);const ng=p.useMemo(()=>{if(!c)return{asset_type:(M==null?void 0:M.asset_type)||Oe.asset_type||"",site_name:(M==null?void 0:M.site_name)||Oe.site_name||"",need_procurement:(M==null?void 0:M.need_procurement)||Oe.need_procurement||0,custom_assign_to_contractor:(M==null?void 0:M.custom_assign_to_contractor)||Oe.custom_assign_to_contractor||"",assigned_technician:(M==null?void 0:M.assigned_technician)||Oe.assigned_technician||"",custom_assigned_engineer:(M==null?void 0:M.custom_assigned_engineer)||Oe.custom_assigned_engineer||"",docstatus:(M==null?void 0:M.docstatus)||Oe.docstatus||0,company:(M==null?void 0:M.company)||Oe.company||"",department:(M==null?void 0:M.department)||Oe.department||"",repair_status:(M==null?void 0:M.repair_status)||Oe.repair_status||"",first_responded_on:(M==null?void 0:M.first_responded_on)||Oe.first_responded_on||""}},[c,M==null?void 0:M.asset_type,M==null?void 0:M.site_name,M==null?void 0:M.need_procurement,M==null?void 0:M.custom_assign_to_contractor,M==null?void 0:M.docstatus,M==null?void 0:M.company,M==null?void 0:M.department,M==null?void 0:M.repair_status,M==null?void 0:M.first_responded_on,Oe.first_responded_on,Oe.asset_type,Oe.site_name,Oe.need_procurement,Oe.custom_assign_to_contractor,Oe.docstatus,Oe.company,Oe.department,Oe.repair_status]),{transitions:vo,loading:wo,actionLoading:Yc,error:Jc,isSystemManager:Zo,applyAction:zi,getStateStyle:ig,getButtonStyle:m0,getIcon:Xo}=hw({doctype:"Work_Order",docname:c?null:r||null,workflowState:M==null?void 0:M.workflow_state,enabled:!c,docData:ng}),jo=p.useMemo(()=>{if(!vo||vo.length===0)return X(null),[];const fe=S.includes("Work Control"),Te=S.includes("System Manager")||Zo,qe=(M==null?void 0:M.workflow_state)||Oe.workflow_state||"Draft",Kt=Oe.assigned_technician||(M==null?void 0:M.assigned_technician)||"",lr=Oe.custom_assigned_supervisor||(M==null?void 0:M.custom_assigned_supervisor)||"",Ht=Oe.custom_assigned_engineer||(M==null?void 0:M.custom_assigned_engineer)||"",jr=(M==null?void 0:M.work_order_type)||"",ra=Yt!==""&&jr!==""&&jr!==Yt;if(qe==="Sent to Engineer"){if(ra){setTimeout(()=>X('WO Type has been changed. Use "Back To Controller" to send for reassignment, or revert the change.'),0);const _s=vo.find(Ml=>Ml.action==="Back To Controller"&&Ml.state==="Sent to Engineer");return _s?[_s]:[]}const Es=(Oe.actions_performed||(M==null?void 0:M.actions_performed)||"").trim().length>0,Xa=!!Kt,zr=vo.filter(_s=>_s.state==="Sent to Engineer"),Ni=zr.find(_s=>_s.action==="Send to Supervisor"),Zs=zr.find(_s=>_s.action==="Back To Controller"),ko=zr.filter(_s=>_s.action!=="Send to Supervisor"&&_s.action!=="Back To Controller"),Si=[];return Xa&&Es?(setTimeout(()=>X(null),0),Si.push(...ko),Ni&&Si.push(Ni),Zs&&Si.push(Zs)):Xa&&!Es?(setTimeout(()=>X('Technician assigned. Fill "Technical Report" to also enable "Send to Supervisor" option.'),0),Si.push(...ko),Zs&&Si.push(Zs)):!Xa&&Es?(setTimeout(()=>X('Technical Report filled. You can "Send to Supervisor" directly, OR assign a Technician for more workflow options.'),0),Ni&&Si.push(Ni),Zs&&Si.push(Zs)):(setTimeout(()=>X(null),0),Zs&&Si.push(Zs)),Si}if(qe==="Repair InProgress"){if(ra){setTimeout(()=>X('WO Type has been changed. Use "Back To Controller" to send for reassignment, or revert the change.'),0);const zr=vo.find(Ni=>Ni.action==="Back To Controller"&&Ni.state==="Repair InProgress");return zr?[zr]:[]}const Es=(Oe.actions_performed||(M==null?void 0:M.actions_performed)||"").trim().length>0,Xa=vo.filter(zr=>zr.state==="Repair InProgress");return Es?(setTimeout(()=>X(null),0),Xa):(setTimeout(()=>X('Please fill the "Technical Report" field to enable "Send For Approval" action.'),0),Xa.filter(zr=>zr.action!=="Send For Approval"))}const ns={};vo.forEach(is=>{ns[is.action]||(ns[is.action]=[]),ns[is.action].push(is)});const ha=[];let fs=null;return Object.entries(ns).forEach(([is,Es])=>{if(Es.length===1){const Xa=Es[0];if(is==="Apply"&&Xa.allowed==="Work Control"&&(fe||Te)){const zr=[];if(lr||zr.push("Assigned Supervisor"),Ht||zr.push("Assigned Engineer"),zr.length>0){fs=`Please assign ${zr.join(" and ")} before applying`,console.log(`Apply hidden for Work Control: ${fs}`);return}}ha.push(Xa)}else{const Xa=Es.find(zr=>zr.allowed==="Work Control");if(Es.find(zr=>zr.allowed==="End user"),fe||Te)if(Xa){if(is==="Apply"){const zr=[];if(lr||zr.push("Assigned Supervisor"),Ht||zr.push("Assigned Engineer"),zr.length>0){fs=`Please assign ${zr.join(" and ")} before applying`,console.log(`Apply hidden for Work Control: ${fs}`);return}}ha.push(Xa)}else Es.forEach(zr=>ha.push(zr));else Es.forEach(zr=>ha.push(zr))}}),setTimeout(()=>X(fs),0),ha.filter(is=>is.action==="Send For Approval"&&qe==="Repair InProgress"?Te?!0:T?!!(T===Kt||(Oe.custom_add_technicians||(M==null?void 0:M.custom_add_technicians)||"").split(",").map(Zs=>Zs.trim()).filter(Zs=>Zs).includes(T)):!1:!0)},[vo,S,Zo,T,Oe.assigned_technician,Oe.custom_assigned_supervisor,Oe.custom_assigned_engineer,Oe.workflow_state,Oe.custom_add_technicians,Oe.actions_performed,M==null?void 0:M.assigned_technician,M==null?void 0:M.custom_assigned_supervisor,M==null?void 0:M.custom_assigned_engineer,M==null?void 0:M.workflow_state,M==null?void 0:M.custom_add_technicians,M==null?void 0:M.work_order_type,M==null?void 0:M.actions_performed,Yt]);p.useMemo(()=>S.includes("Work Control")||Zo,[S,Zo]);const Tl="Stores - KFSH-D",[pc,Zc]=p.useState({}),h0=(fe,Te)=>J(null,null,function*(){if(!fe||!Te)return 0;try{const qe=yield At.apiCall(`/api/resource/Bin?filters=[["item_code","=","${fe}"],["warehouse","=","${Te}"]]&fields=["actual_qty"]&limit=1`);return qe!=null&&qe.data&&qe.data.length>0&&qe.data[0].actual_qty||0}catch(qe){return console.error("Error fetching available stock:",qe),0}}),Ym=fe=>J(null,null,function*(){var Te;if(!fe)return 0;try{const qe=yield At.apiCall(`/api/resource/Item/${fe}?fields=["valuation_rate"]`);return((Te=qe==null?void 0:qe.data)==null?void 0:Te.valuation_rate)||0}catch(qe){return console.error("Error fetching valuation rate:",qe),0}}),og=fe=>J(null,null,function*(){var Te;if(!fe)return Tl;try{const qe=yield At.apiCall(`/api/resource/Item/${fe}?fields=["item_defaults"]`),Kt=((Te=qe==null?void 0:qe.data)==null?void 0:Te.item_defaults)||[];return Kt.length>0&&Kt[0].default_warehouse?Kt[0].default_warehouse:Tl}catch(qe){return console.error("Error fetching item default warehouse:",qe),Tl}}),Jm=(fe,Te)=>J(null,null,function*(){const qe=[...Oe.stock_items||[]];if(Te){const Kt=qe.findIndex((lr,Ht)=>Ht!==fe&&lr.item_code===Te);if(Kt!==-1){We.warning(e("workOrders.detail.itemAlreadyAdded",{itemCode:Te,row:Kt+1}),{position:"top-right",autoClose:4e3,icon:t.jsx(Or,{}),toastId:`duplicate-item-${fe}`}),qe[fe]=je(se({},qe[fe]),{item_code:"",item_name:"",valuation_rate:0,custom_available_stock:0,total_value:0}),ar(je(se({},Oe),{stock_items:qe}));return}}if(qe[fe]=je(se({},qe[fe]),{item_code:Te}),Te){const[Kt,lr]=yield Promise.all([Ym(Te),og(Te)]);qe[fe].valuation_rate=Kt,qe[fe].total_value=Kt*(qe[fe].consumed_quantity||1),qe[fe].warehouse=lr;const Ht=yield h0(Te,lr);qe[fe].custom_available_stock=Ht,gc(fe,qe[fe].consumed_quantity,Ht,Te,lr)}ar(je(se({},Oe),{stock_items:qe}))}),p0=fe=>{ar(Te=>je(se({},Te),{custom_building:fe,department:"",custom_room_no:"",custom_location:""}))},lg=fe=>{ar(Te=>je(se({},Te),{department:fe,custom_room_no:"",custom_location:""}))},Zm=fe=>{ar(Te=>je(se({},Te),{custom_room_no:fe,custom_location:""}))},Xm=(fe,Te)=>J(null,null,function*(){const qe=[...Oe.stock_items||[]];if(qe[fe]=je(se({},qe[fe]),{warehouse:Te}),Te&&qe[fe].item_code){const Kt=yield h0(qe[fe].item_code,Te);qe[fe].custom_available_stock=Kt,gc(fe,qe[fe].consumed_quantity,Kt,qe[fe].item_code,Te)}ar(je(se({},Oe),{stock_items:qe}))}),gc=(fe,Te,qe,Kt,lr)=>{Te>qe?(Zc(Ht=>je(se({},Ht),{[fe]:`Insufficient stock for ${Kt} in ${lr}. Available: ${qe}, Required: ${Te}`})),We.warning(e("workOrders.detail.insufficientStock",{itemCode:Kt,available:qe,required:Te}),{position:"top-right",autoClose:5e3,icon:t.jsx(Or,{}),toastId:`stock-warning-${fe}`})):Zc(Ht=>{const jr=se({},Ht);return delete jr[fe],jr})},El=(fe,Te)=>{const qe=[...Oe.stock_items||[]],Kt=qe[fe].valuation_rate||0,lr=qe[fe].custom_available_stock||0;qe[fe]=je(se({},qe[fe]),{consumed_quantity:Te,total_value:Kt*Te}),qe[fe].item_code&&qe[fe].warehouse&&gc(fe,Te,lr,qe[fe].item_code,qe[fe].warehouse),ar(je(se({},Oe),{stock_items:qe}))},[cg,Xc]=p.useState({});p.useEffect(()=>{const fe={};Oe.company&&(fe.company=Oe.company),Xc(fe)},[Oe.company]);const ii=fe=>J(null,null,function*(){if(!fe)return null;try{Ie(!0);const Te=yield At.apiCall(`/api/resource/Asset/${fe}`);return(Te==null?void 0:Te.data)||null}catch(Te){return console.error("Error fetching asset details:",Te),null}finally{Ie(!1)}}),Qc=fe=>J(null,null,function*(){if(!fe)return null;try{Ie(!0);const Te=yield At.apiCall(`/api/resource/Asset?filters=[["custom_serial_number","=","${fe}"]]&fields=["name","asset_name","company","department","custom_serial_number","custom_asset_type","custom_manufacturer","supplier","custom_site_contractor","custom_subcontractor","custom_model","custom_service_agreement","custom_service_coverage","custom_start_date","custom_end_date","custom_total_amount","custom_site","location","custom_building","custom_room_number"]&limit=1`);return Te!=null&&Te.data&&Te.data.length>0?Te.data[0]:null}catch(Te){return console.error("Error fetching asset by serial number:",Te),null}finally{Ie(!1)}}),$i=fe=>fe?fe.split(" ")[0]:"",g0=fe=>{fe&&ar(Te=>je(se({},Te),{asset:fe.name||Te.asset,asset_name:fe.asset_name||"",company:fe.company||"",department:fe.department||"",serial_number:fe.custom_serial_number||"",asset_type:fe.custom_asset_type||"",manufacturer:fe.custom_manufacturer||"",supplier:fe.supplier||"",custom_site_contractor:fe.custom_site_contractor||"",custom_subcontractor:fe.custom_subcontractor||"",model:fe.custom_model||"",site_name:fe.custom_site||"",custom_service_agreement:fe.custom_service_agreement||"",custom_service_coverage:fe.custom_service_coverage||"",custom_start_date:$i(fe.custom_start_date)||"",custom_end_date:$i(fe.custom_end_date)||"",custom_total_amount:fe.custom_total_amount||0,custom_location:fe.location||fe.custom_location||"",custom_building:fe.custom_building||"",custom_room_no:fe.custom_room_number||""}))},Al=fe=>J(null,null,function*(){if(ar(Te=>je(se({},Te),{asset:fe})),fe){const Te=yield ii(fe);Te&&g0(Te)}else ar(Te=>je(se({},Te),{asset:"",asset_name:"",serial_number:"",asset_type:"Non Biomedical",manufacturer:"",supplier:"",custom_site_contractor:"",custom_subcontractor:"",model:"",site_name:"",custom_service_agreement:"",custom_service_coverage:"",custom_start_date:"",custom_end_date:"",custom_total_amount:0,custom_building:"",custom_room_no:"",custom_location:""}))}),uu=()=>J(null,null,function*(){if(!Oe.serial_number){We.warning(e("workOrders.detail.pleaseEnterSerialNumberToSearch"),{position:"top-right",autoClose:3e3,icon:t.jsx(Or,{})});return}const fe=yield Qc(Oe.serial_number);fe?(g0(fe),We.success(e("workOrders.detail.assetFound",{name:fe.asset_name||fe.name}),{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})})):We.error(e("workOrders.detail.noAssetFoundWithSerialNumber"),{position:"top-right",autoClose:4e3,icon:t.jsx(pr,{})})}),Qm=()=>J(null,null,function*(){if(Oe.serial_number&&!Oe.asset){const fe=yield Qc(Oe.serial_number);fe&&g0(fe)}}),eh=fe=>J(null,null,function*(){var Kt,lr;const Te=(Kt=fe.target.files)==null?void 0:Kt[0];if(!Te)return;const qe=10*1024*1024;if(Te.size>qe){We.error(e("workOrders.detail.fileSizeExceeds"),{position:"top-right",autoClose:4e3,icon:t.jsx(pr,{})});return}ut(!0);try{const Ht=new FormData;Ht.append("file",Te),Ht.append("is_private","0"),Ht.append("folder","Home/Attachments"),!c&&r&&(Ht.append("doctype","Work_Order"),Ht.append("docname",r));const jr=Ar.BASE_URL||"",ns=yield(yield fetch(`${jr}/api/method/upload_file`,{method:"POST",credentials:"include",body:Ht})).json();if((lr=ns.message)!=null&&lr.file_url)ar(ha=>je(se({},ha),{custom_attachment:ns.message.file_url})),We.success(e("workOrders.detail.fileUploadedSuccessfully"),{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})});else throw new Error("Upload failed")}catch(Ht){console.error("File upload error:",Ht),We.error(e("workOrders.detail.failedToUploadFile"),{position:"top-right",autoClose:4e3,icon:t.jsx(pr,{})})}finally{ut(!1),fe.target.value=""}}),f0=()=>{ar(fe=>je(se({},fe),{custom_attachment:""})),We.info(e("workOrders.detail.attachmentRemoved"),{position:"top-right",autoClose:2e3})},Ol=fe=>{if(!fe)return"";const Te=fe.split("/");return Te[Te.length-1]||fe};p.useEffect(()=>{if(c&&l&&!u){const fe={asset:n.get("asset")||"",asset_name:n.get("asset_name")||"",asset_type:n.get("asset_type")||"Non Biomedical",manufacturer:n.get("manufacturer")||"",supplier:n.get("supplier")||"",serial_number:n.get("serial_number")||"",department:n.get("department")||"",custom_site_contractor:n.get("site_contractor")||"",custom_subcontractor:n.get("subcontractor")||"",company:n.get("company")||"",site_name:n.get("site_name")||"",custom_building:n.get("building")||"",custom_room_no:n.get("room_no")||"",custom_location:n.get("location")||""};ar(Te=>je(se(se({},Te),fe),{repair_status:"Open",workflow_state:"Draft",custom_priority_:"Normal",failure_date:ef()}))}},[c,l,u,n]),p.useEffect(()=>{if(!f||!h){b(!0);return}b(!1);let fe=!1;return Dd.getIssue(h).then(Te=>{if(fe)return;const qe=(Te.subject||"").trim(),Kt=(Te.description||"").trim(),lr=qe&&Kt?`Subject: ${qe}
|
||
|
||
${Kt}`:qe||Kt||"";ar(Ht=>je(se({},Ht),{issue:Te.name||h,company:Te.company||Ht.company,work_order_type:Te.issue_type||Ht.work_order_type,custom_priority_:Te.priority?wk(Te.priority):Ht.custom_priority_,project:Te.project||Ht.project,description:lr||Ht.description,failure_date:Sne(Te.opening_date,Te.opening_time)}))}).catch(()=>{fe||(We.error(e("workOrders.detail.failedToLoadSupportIssue"),{position:"top-right",autoClose:5e3,icon:t.jsx(Or,{})}),ar(Te=>je(se({},Te),{issue:h})))}).finally(()=>{fe||b(!0)}),()=>{fe=!0}},[f,h,e]),p.useEffect(()=>{M&&!Ye&&!c&&!u&&(Ae(M.work_order_type||""),Be(M.custom_assigned_supervisor||""),Me(M.custom_assigned_engineer||""),Xe(M.assigned_technician||""),kt(!0),console.log("Initial values stored:",{workOrderType:M.work_order_type,supervisor:M.custom_assigned_supervisor,engineer:M.custom_assigned_engineer,technician:M.assigned_technician}))},[M,Ye,c,u]),p.useEffect(()=>{var fe;M&&(dt.current||nr((fe=M.custom_delete_status)!=null?fe:null),dt.current=!1,ar({company:M.company||"",work_order_type:M.work_order_type||"",asset:M.asset||"",asset_name:u?`${M.asset_name} (Copy)`:M.asset_name||"",description:M.description||"",repair_status:u?"Open":M.repair_status||"Open",workflow_state:u?"Draft":M.workflow_state||"Draft",department:M.department||"",custom_priority_:wk(M.custom_priority_||void 0),asset_type:M.asset_type||"Non Biomedical",custom_type:M.custom_type||"Corrective",manufacturer:M.manufacturer||"",supplier:M.supplier||"",serial_number:M.serial_number||"",model:M.model||"",custom_site_contractor:M.custom_site_contractor||"",custom_subcontractor:M.custom_subcontractor||"",failure_date:Lh(M.failure_date)||"",custom_deadline_date:$i(M.custom_deadline_date)||"",first_responded_on:Lh(M.first_responded_on)||"",completion_date:Lh(M.completion_date)||"",actions_performed:M.actions_performed||"",stock_consumption:M.stock_consumption||0,stock_items:M.stock_items||[],site_name:M.site_name||"",need_procurement:M.need_procurement||0,custom_assign_to_contractor:M.custom_assign_to_contractor||"",assigned_technician:M.assigned_technician||"",custom_assigned_engineer:M.custom_assigned_engineer||"",custom_add_technicians:M.custom_add_technicians||"",docstatus:M.docstatus||0,custom_assigned_supervisor:M.custom_assigned_supervisor||"",total_hours_spent:M.total_hours_spent||0,custom_pending_reason:M.custom_pending_reason||"",total_repair_cost:M.total_repair_cost||0,custom_travel_hour:M.custom_travel_hour||"",custom_service_agreement:M.custom_service_agreement||"",custom_service_coverage:M.custom_service_coverage||"",custom_start_date:$i(M.custom_start_date)||"",custom_end_date:$i(M.custom_end_date)||"",custom_total_amount:M.custom_total_amount||0,custom_location:M.custom_location||"",custom_extension_no:M.custom_extension_no||"",custom_attachment:M.custom_attachment||"",custom_attachment_on_close:M.custom_attachment_on_close||"",inspection:M.inspection||"",custom_department_no:M.custom_department_no||"",custom_reason:M.custom_reason||"",custom_technical_department:M.custom_technical_department||"",custom_room_no:M.custom_room_no||"",custom_building:M.custom_building||"",custom_civil_work_category:M.custom_civil_work_category||"",issue:M.issue||""}))},[M,u]);const ka=fe=>{const{name:Te,value:qe}=fe.target;ar(Kt=>je(se({},Kt),{[Te]:qe}))},Pl=fe=>{const Te=fe.target.value;ar(qe=>je(se({},qe),{custom_priority_:Te}))},dg=fe=>{const Te=fe.target.value;ar(qe=>je(se({},qe),{failure_date:Te}))},Ui=fe=>{const Te=fe.target.value;ar(qe=>je(se({},qe),{first_responded_on:Te}))},th=fe=>{const Te=fe.target.value;ar(qe=>je(se({},qe),{completion_date:Te}))},Bi=()=>{const fe=ef();ar(Te=>je(se({},Te),{failure_date:fe})),We.info(e("workOrders.detail.failureDateSetToCurrentTime"),{position:"top-right",autoClose:2e3,icon:t.jsx(ea,{})})},ed=()=>{const fe=ef();ar(Te=>je(se({},Te),{first_responded_on:fe})),We.info(e("workOrders.detail.firstRespondedOnSetToCurrentTime"),{position:"top-right",autoClose:2e3,icon:t.jsx(ea,{})})},td=()=>{const fe=ef();ar(Te=>je(se({},Te),{completion_date:fe})),We.info(e("workOrders.detail.completionDateSetToCurrentTime"),{position:"top-right",autoClose:2e3,icon:t.jsx(ea,{})})},rd=fe=>{fe===Yt&&Yt!==""?(ar(Te=>je(se({},Te),{work_order_type:fe,custom_assigned_supervisor:ke,custom_assigned_engineer:yt,assigned_technician:Ke,custom_civil_work_category:fe==="Civil works-الأعمال المدنية"?Te.custom_civil_work_category:""})),console.log("Reverted to original work_order_type, restored values:",{supervisor:ke,engineer:yt,technician:Ke})):ar(Te=>je(se({},Te),{work_order_type:fe,custom_assigned_supervisor:"",custom_assigned_engineer:"",custom_assign_to_contractor:"",assigned_technician:"",custom_civil_work_category:fe==="Civil works-الأعمال المدنية"?Te.custom_civil_work_category:""}))},ad=fe=>{ar(Te=>je(se({},Te),{custom_assigned_supervisor:fe}))},sd=p.useMemo(()=>S.includes("Work Control")||S.includes("System Manager"),[S]),Wi=()=>{if(sd&&!c){if(!Oe.custom_assigned_supervisor)return We.error(e("workOrders.detail.assignedSupervisorMandatory"),{position:"top-right",autoClose:5e3,icon:t.jsx(pr,{})}),!1;if(!Oe.custom_assigned_engineer)return We.error(e("workOrders.detail.assignedEngineerMandatory"),{position:"top-right",autoClose:5e3,icon:t.jsx(pr,{})}),!1;if(Vi==="Sent to Engineer"&&!Oe.assigned_technician)return We.error(e("workOrders.detail.assignedTechnicianMandatory"),{position:"top-right",autoClose:5e3,icon:t.jsx(pr,{})}),!1}return!0},fc=()=>J(null,null,function*(){if(r){Ve(!0);try{yield ze(r,{workflow_state:"Cancelled",docstatus:2,repair_status:"Cancelled"}),We.success(e("workOrders.detail.workOrderCancelledSuccessfully"),{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),it(!1),le(),setTimeout(()=>{gs()},500)}catch(fe){const Te=fe instanceof Error?fe.message:"Unknown error";We.error(e("workOrders.detail.failedToCancel",{error:Te}),{position:"top-right",autoClose:6e3,icon:t.jsx(pr,{})})}finally{Ve(!1)}}}),rh=()=>J(null,null,function*(){if(r)try{yield At.apiCall(`/api/resource/Work_Order/${r}`,{method:"DELETE"}),We.success(e("workOrders.detail.workOrderDeletedSuccessfully"),{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),a(-1)}catch(fe){const Te=fe instanceof Error?fe.message:"Unknown error";We.error(e("workOrders.detail.failedToDelete",{error:Te}),{position:"top-right",autoClose:6e3,icon:t.jsx(pr,{})})}}),nd=fe=>J(null,null,function*(){if(fe.preventDefault(),!Oe.work_order_type){We.error(e("workOrders.detail.pleaseSelectWorkOrderType"),{position:"top-right",autoClose:4e3,icon:t.jsx(pr,{})});return}if(be&&!Oe.asset){We.error("Asset is required based on your location selection. Please select an Asset.",{position:"top-right",autoClose:5e3,icon:t.jsx(pr,{})});return}if(!Wi())return;const lr=Oe,{__islocal:Te}=lr,qe=li(lr,["__islocal"]),Kt=je(se({},qe),{custom_priority_:wk(Oe.custom_priority_),failure_date:Fh(Oe.failure_date),first_responded_on:Fh(Oe.first_responded_on),completion_date:Fh(Oe.completion_date)});if(c){const Ht=String(Oe.issue||h||"").trim();Ht&&(Kt.issue=Ht)}try{if(c||u){const Ht=yield Fe(Kt),jr=e(u?"workOrders.detail.workOrderDuplicatedSuccessfully":f?"workOrders.detail.workOrderCreatedFromIssueSuccessfully":l?"workOrders.detail.workOrderCreatedFromAssetSuccessfully":"workOrders.detail.workOrderCreatedSuccessfully");We.success(jr,{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),a(`/work-orders/${Ht.name}`)}else r&&(yield ze(r,Kt),We.success(e("workOrders.detail.workOrderUpdatedSuccessfully"),{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),Et(!1),le(),setTimeout(()=>{gs()},500))}catch(Ht){console.error("Work order save error:",Ht);const jr=Ht instanceof Error?Ht.message:"Unknown error",ra=JSON.stringify(Ht);jr.includes("TimestampMismatchError")||jr.includes("Document has been modified")||jr.includes("Please refresh")||ra.includes("TimestampMismatchError")?(We.error(e("workOrders.detail.documentModifiedByAnotherUser"),{position:"top-right",autoClose:4e3,icon:t.jsx(Or,{})}),yield le(),We.info(e("workOrders.detail.pleaseReviewLatestChanges"),{position:"top-right",autoClose:5e3,icon:t.jsx(ro,{})})):We.error(e("workOrders.detail.failedToSaveWorkOrder",{error:jr}),{position:"top-right",autoClose:6e3,icon:t.jsx(pr,{})})}});p.useEffect(()=>{c||fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({roles:"Maintenance Manager"})}).then(fe=>fe.json()).then(fe=>{var Te;(Te=fe.message)!=null&&Te.has_role&&k(!0)}).catch(fe=>console.error("Role check error:",fe))},[c]);const ah=fe=>J(null,null,function*(){if(!r||c||!["Apply","Send For Repair"].includes(fe))return null;try{const qe=yield At.apiCall("/api/method/assign_supervisor_or_technician",{method:"POST",body:JSON.stringify({work_order:r,action:fe,asset_type:Oe.asset_type||(M==null?void 0:M.asset_type)||""})});return(qe==null?void 0:qe.message)||null}catch(qe){return console.error("Error in before_workflow_action:",qe),null}}),Hi=(fe,Te)=>J(null,null,function*(){if(["Reject","Cancel","Close"].includes(fe)&&($e==null?void 0:$e.action)!==fe){Qe({action:fe,nextState:Te||""});return}if(Qe(null),fe==="Cancel"&&r){const ha=vk();try{yield ze(r,{completion_date:ha}),ar(fs=>je(se({},fs),{completion_date:Lh(ha)})),console.log("Auto-set completion_date on Cancel:",ha)}catch(fs){console.error("Error setting completion_date on Cancel:",fs)}}const Kt=(M==null?void 0:M.workflow_state)||Oe.workflow_state||"Draft";if(fe==="Send to Supervisor"&&Kt==="Sent to Engineer"&&!(Oe.actions_performed||"").trim()){We.dismiss(),setTimeout(()=>{We.error(e("workOrders.detail.technicalReportMandatoryForSupervisor"),{position:"top-right",autoClose:8e3,hideProgressBar:!1,closeOnClick:!0,pauseOnHover:!0,draggable:!0,toastId:"technical-report-required",icon:t.jsx(Or,{})})},100);return}const lr=We.loading(e("workOrders.detail.applyingAction",{action:fe}),{position:"top-right"});yield le();const Ht=yield ah(fe);Ht!=null&&Ht.assigned_to&&(We.info(e("workOrders.detail.assignedTo",{name:Ht.assigned_to}),{position:"top-right",autoClose:4e3,icon:t.jsx(Qt,{})}),yield le());let jr=!1,ra=0;const ns=3;for(;!jr&&ra<ns;)try{jr=yield zi(fe,Te);break}catch(ha){const fs=(ha==null?void 0:ha.message)||String(ha);if((fs.includes("TimestampMismatchError")||fs.includes("Document has been modified")||fs.includes("Please refresh"))&&ra<ns-1)ra++,console.log(`Timestamp mismatch, retrying... (attempt ${ra})`),yield le(),yield new Promise(Es=>setTimeout(Es,500));else throw ha}if(We.dismiss(lr),jr)We.success(e("workOrders.detail.actionCompletedSuccessfully",{action:fe}),{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),le(),setTimeout(()=>gs(),500);else{const ha=Jc||"Please try again.";ha.includes("TimestampMismatchError")||ha.includes("Document has been modified")||ha.includes("Please refresh")?(We.error(e("workOrders.detail.documentModifiedRefreshing"),{position:"top-right",autoClose:4e3,icon:t.jsx(Or,{})}),yield le(),We.info(e("workOrders.detail.tryActionAgainAfterReview"),{position:"top-right",autoClose:5e3,icon:t.jsx(ro,{})})):We.error(e("workOrders.detail.failedToApplyAction",{action:fe,error:ha}),{position:"top-right",autoClose:6e3,icon:t.jsx(pr,{})})}}),mu=p.useMemo(()=>{var fe;return jne((fe=M==null?void 0:M.actions_performed)!=null?fe:Oe.actions_performed)},[M==null?void 0:M.actions_performed,Oe.actions_performed]);if(we||f&&!y)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e(f&&!y?"workOrders.detail.loadingSupportIssue":"workOrders.loadingDetails")})]})});if(pe&&!c&&!u)return t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:[t.jsxs("p",{className:"text-red-600 dark:text-red-400",children:[e("workOrders.detail.errorLabel"),": ",pe]}),t.jsx("button",{onClick:()=>a(-1),className:"mt-2 text-red-700 dark:text-red-400 underline hover:text-red-800 dark:hover:text-red-300",children:e("workOrders.detail.backToList")})]})});const xc=()=>e(u?"workOrders.detail.duplicateWorkOrder":f?"workOrders.detail.createFromSupportIssue":l?"workOrders.detail.createFromAsset":c?"workOrders.detail.newWorkOrder":"workOrders.detail.workOrderDetails"),qi=(M==null?void 0:M.workflow_state)||Oe.workflow_state||"Draft",En=ig(qi),Ls=(Rl=(_o=M==null?void 0:M.docstatus)!=null?_o:Oe.docstatus)!=null?Rl:0,Vi=(M==null?void 0:M.workflow_state)||Oe.workflow_state||"Draft",hu=S.includes("Work Control"),id=S.includes("Contractor Engineer"),od=S.includes("Contractor Supervisor")&&!Zo,Qo=c||Zo&&Ls===0||v&&Vi==="Sent to Team Leader"||hu&&(Vi==="Draft"||Vi==="Sent to Work Control")&&Ls===0||id&&Vi==="Sent to Engineer"&&Ls===0||!wo&&jo.length>0,pu=()=>{const fe=Oe.custom_priority_||"Normal";if(Oe.need_procurement===1)return`${fe} priority + Procurement: +30 days`;switch(fe){case"Urgent":return"Urgent priority: +1 day";case"Medium":return"Medium priority: +3 days";case"Normal":default:return"Normal priority: +5 days"}},el=fe=>fe?fe.replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,Te=>Te.toUpperCase()):"",ld=fe=>fe==null||fe===""?"(empty)":fe===0?"0":fe===1?"1":typeof fe=="boolean"?fe?"Yes":"No":typeof fe=="object"?JSON.stringify(fe):String(fe),Dl=fe=>{if(!fe)return"";const Te=new Date(fe),qe=new Date,Kt=qe.getTime()-Te.getTime(),lr=Math.floor(Kt/6e4),Ht=Math.floor(Kt/36e5),jr=Math.floor(Kt/864e5);return lr<1?"Just now":lr<60?`${lr} min${lr>1?"s":""} ago`:Ht<24?`${Ht} hour${Ht>1?"s":""} ago`:jr<7?`${jr} day${jr>1?"s":""} ago`:Te.toLocaleDateString("en-US",{month:"short",day:"numeric",year:Te.getFullYear()!==qe.getFullYear()?"numeric":void 0,hour:"2-digit",minute:"2-digit"})},tl=fe=>{if(!fe)return"Unknown";const Te=fe.indexOf("@");return Te===-1?fe:fe.substring(0,Te)},sh=fe=>{const Te=fe.toLowerCase();return Te.includes("status")||Te.includes("state")?"text-purple-600 dark:text-purple-400":Te.includes("date")?"text-blue-600 dark:text-blue-400":Te.includes("technician")||Te.includes("supervisor")||Te.includes("assigned")?"text-green-600 dark:text-green-400":"text-gray-600 dark:text-gray-400"};return t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[t.jsx($a,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:au}),B&&ie.length>0&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[9999]",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-lg w-full mx-4 shadow-xl",children:[t.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[t.jsx(Or,{className:"text-orange-500 text-2xl mt-0.5 flex-shrink-0"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:e("workOrders.detail.existingWorkOrderFound")}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1 text-sm",children:e(he==="asset"?"workOrders.detail.workOrderExistsForAsset":"workOrders.detail.workOrderExistsForTypeAndRoom")})]})]}),t.jsxs("div",{className:"mb-4 max-h-48 overflow-y-auto",children:[t.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 mb-2",children:e("workOrders.detail.existingWorkOrders")}),t.jsx("div",{className:"space-y-2",children:ie.map(fe=>t.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600",children:[t.jsxs("div",{children:[t.jsxs("a",{href:`/asm_app/work-orders/${fe.name}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 font-medium hover:underline flex items-center gap-1",children:[fe.name," ",t.jsx(dn,{size:10})]}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:[e("workOrders.detail.created"),": ",kc(fe.creation)]})]}),t.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${fe.workflow_state==="Draft"?"bg-gray-100 text-gray-700":fe.workflow_state==="Repair InProgress"?"bg-blue-100 text-blue-700":"bg-purple-100 text-purple-700"}`,children:fe.workflow_state})]},fe.name))})]}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:e("workOrders.detail.proceedWithNewWO")}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:Yo,className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg text-sm font-medium",children:e("common.cancel")}),t.jsxs("button",{onClick:Vc,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm font-medium flex items-center gap-2",children:[t.jsx(Qt,{size:14})," ",e("workOrders.detail.proceedAnyway")]})]})]})}),He&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl",children:[t.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[t.jsx(Mo,{className:"text-orange-500 text-xl mt-0.5"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:e("workOrders.cancelWorkOrder")}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:e("workOrders.cancelConfirmMessage")})]})]}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>it(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",disabled:Ue,children:e("workOrders.detail.noGoBack")}),t.jsx("button",{onClick:fc,disabled:Ue,className:"px-4 py-2 bg-orange-600 hover:bg-orange-700 text-white rounded-lg disabled:opacity-50 flex items-center gap-2",children:Ue?t.jsxs(t.Fragment,{children:[t.jsx(tr,{className:"animate-spin"}),e("workOrders.detail.cancelling")]}):t.jsxs(t.Fragment,{children:[t.jsx(Mo,{}),e("workOrders.detail.yesCancel")]})})]})]})}),lt&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl",children:[t.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[t.jsx(Or,{className:"text-red-500 text-xl mt-0.5"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:e("workOrders.deleteWorkOrder")}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:e("workOrders.deleteConfirmMessage")})]})]}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>st(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",children:e("common.cancel")}),t.jsx("button",{onClick:rh,disabled:Re,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg disabled:opacity-50 flex items-center gap-2",children:Re?t.jsxs(t.Fragment,{children:[t.jsx(tr,{className:"animate-spin"}),e("workOrders.detail.deleting")]}):t.jsxs(t.Fragment,{children:[t.jsx(wr,{}),e("common.delete")]})})]})]})}),E&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-lg w-full mx-4 shadow-xl max-h-[80vh] flex flex-col",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white flex items-center gap-2",children:[t.jsx(nn,{className:"text-blue-500"}),e("workOrders.detail.selectAdditionalTechnicians")]}),t.jsx("button",{onClick:()=>R(!1),className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded",children:t.jsx(ht,{size:18})})]}),t.jsx("div",{className:"mb-4",children:t.jsxs("div",{className:"relative",children:[t.jsx(za,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400",size:14}),t.jsx("input",{type:"text",placeholder:e("workOrders.detail.searchTechnicians"),value:ne,onChange:fe=>te(fe.target.value),className:"w-full pl-10 pr-4 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})}),t.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:e("workOrders.detail.techniciansSelected",{count:z.length})}),z.length>0&&t.jsx("button",{onClick:()=>G([]),className:"text-xs text-red-500 hover:text-red-700",children:e("workOrders.detail.clearAll")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto border border-gray-200 dark:border-gray-700 rounded-lg",children:Y?t.jsxs("div",{className:"flex items-center justify-center py-8",children:[t.jsx(tr,{className:"animate-spin text-blue-500 mr-2"}),t.jsx("span",{className:"text-sm text-gray-500",children:e("workOrders.detail.loadingTechnicians")})]}):Gc.length===0?t.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:t.jsx("p",{className:"text-sm",children:e(ne?"workOrders.detail.noTechniciansMatchSearch":"workOrders.detail.noTechniciansFound")})}):t.jsx("div",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:Gc.map(fe=>{const Te=z.includes(fe.name),qe=Oe.assigned_technician===fe.name;return t.jsxs("label",{className:`flex items-center gap-3 p-3 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors ${Te?"bg-blue-50 dark:bg-blue-900/20":""} ${qe?"opacity-50 cursor-not-allowed":""}`,children:[t.jsx("input",{type:"checkbox",checked:Te,onChange:()=>!qe&&hc(fe.name),disabled:qe,className:"w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:bg-gray-700 dark:border-gray-600"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:fe.full_name||fe.name}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:fe.name})]}),qe&&t.jsx("span",{className:"px-2 py-0.5 bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400 text-xs rounded",children:"Primary"}),Te&&!qe&&t.jsx(Qt,{className:"text-blue-500",size:16})]},fe.name)})})}),t.jsxs("div",{className:"flex justify-end gap-3 mt-4 pt-4 border-t border-gray-200 dark:border-gray-700",children:[t.jsx("button",{onClick:()=>R(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg text-sm",children:"Cancel"}),t.jsxs("button",{onClick:d0,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm flex items-center gap-2",children:[t.jsx(Qt,{size:14}),e("workOrders.detail.saveSelection")," (",z.length,")"]})]})]})}),H&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[60]",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl",children:[t.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[t.jsx(nn,{className:"text-blue-500 text-xl mt-0.5"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:"Confirm Technician Assignment"}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1 text-sm",children:"Are you sure you want to assign this work order to the following technician(s)?"})]})]}),t.jsxs("div",{className:"mb-4 max-h-48 overflow-y-auto",children:[t.jsxs("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 mb-2",children:["Selected Technicians (",V.length,"):"]}),t.jsx("div",{className:"space-y-2",children:V.map(fe=>{const Te=ae.find(lr=>lr.name===fe),qe=(Te==null?void 0:Te.full_name)||fe,Kt=fe;return t.jsxs("div",{className:"flex items-center gap-3 p-3 bg-blue-50 dark:bg-blue-900/20 rounded-lg border border-blue-200 dark:border-blue-800",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-blue-200 dark:bg-blue-800 flex items-center justify-center flex-shrink-0",children:t.jsx(nn,{className:"text-blue-600 dark:text-blue-400",size:12})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:qe}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:Kt})]})]},fe)})})]}),t.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t border-gray-200 dark:border-gray-700",children:[t.jsx("button",{onClick:bo,className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg text-sm font-medium",children:e("common.cancel")}),t.jsxs("button",{onClick:Ms,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm font-medium flex items-center gap-2",children:[t.jsx(Qt,{size:14}),e("workOrders.detail.confirmAssignment")]})]})]})}),Un&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[9999]",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl p-6 max-w-lg w-full mx-4 shadow-2xl max-h-[90vh] overflow-y-auto",children:[t.jsxs("div",{className:"flex items-center justify-between mb-5",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-bold text-gray-800 dark:text-white",children:Ir==="give"?`⭐ ${e("workOrders.detail.giveFeedback")}`:Ir==="edit"?`✏️ ${e("workOrders.detail.editFeedback")}`:`⭐ ${e("workOrders.detail.feedbackDetails")}`}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:[e("workOrders.detail.workOrder")," ",t.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:r})]})]}),t.jsx("button",{onClick:()=>Tr(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:t.jsx(ht,{size:16})})]}),t.jsxs("div",{className:"mb-5 p-3 bg-gray-50 dark:bg-gray-700/50 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:e("workOrders.detail.feedbackBy")}),t.jsx("p",{className:"text-sm font-medium text-gray-800 dark:text-white",children:dr||T})]}),t.jsx("div",{className:"space-y-5 mb-6",children:Ca.map((fe,Te)=>t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700/30 rounded-lg border border-gray-200 dark:border-gray-600",children:[t.jsx("label",{className:"block text-sm font-semibold text-gray-700 dark:text-gray-200 mb-2",children:fe.parameter}),t.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[[1,2,3,4,5].map(qe=>{const Kt=qe*.2,lr=fe.rating>=Kt,Ht=!lr&&fe.rating>=Kt-.1,jr=Ir==="view";return t.jsx("button",{type:"button",disabled:jr,onClick:()=>{jr||Hr(Te,Kt)},className:`text-2xl transition-all duration-150 ${jr?"cursor-default":"cursor-pointer hover:scale-110"} ${lr?"text-yellow-400":Ht?"text-yellow-300":"text-gray-300 dark:text-gray-500"}`,title:`${qe} star${qe>1?"s":""}`,children:"★"},qe)}),t.jsx("span",{className:"ml-2 text-xs text-gray-500 dark:text-gray-400 font-medium",children:fe.rating>0?`${(fe.rating*5).toFixed(1)} / 5`:e("workOrders.detail.notRated")})]})]},fe.parameter))}),(Ir==="view"||Ir==="edit")&&(ma==null?void 0:ma.overall)>0&&t.jsxs("div",{className:"mb-5 p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg text-center",children:[t.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 mb-1 font-medium",children:e("workOrders.detail.overallSatisfaction")}),t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsx("div",{className:"flex",children:[1,2,3,4,5].map(fe=>t.jsx("span",{className:`text-xl ${ma.overall>=fe*.2?"text-yellow-400":"text-gray-300 dark:text-gray-500"}`,children:"★"},fe))}),t.jsxs("span",{className:"text-lg font-bold text-blue-700 dark:text-blue-300",children:[(ma.overall*5).toFixed(1)," / 5"]})]})]}),(Ir==="give"||Ir==="edit")&&(()=>{const fe=Ts(Ca);return fe<=0?null:t.jsxs("div",{className:"mb-5 p-4 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg text-center",children:[t.jsx("p",{className:"text-xs text-green-600 dark:text-green-400 mb-1 font-medium",children:e("workOrders.detail.overallRatingPreview")}),t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsx("div",{className:"flex",children:[1,2,3,4,5].map(Te=>t.jsx("span",{className:`text-xl ${fe>=Te*.2?"text-yellow-400":"text-gray-300 dark:text-gray-500"}`,children:"★"},Te))}),t.jsxs("span",{className:"text-lg font-bold text-green-700 dark:text-green-300",children:[(fe*5).toFixed(1)," / 5"]})]})]})})(),t.jsx("div",{className:"flex justify-end gap-3 pt-4 border-t border-gray-200 dark:border-gray-700",children:Ir==="view"?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>Tr(!1),className:"px-4 py-2 bg-gray-200 hover:bg-gray-300 dark:bg-gray-600 dark:hover:bg-gray-500 text-gray-700 dark:text-gray-200 rounded-lg text-sm font-medium",children:e("listPages.close")}),fo&&t.jsxs("button",{onClick:Wa,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm font-medium flex items-center gap-2",children:[t.jsx(qr,{size:12}),e("workOrders.detail.editRating")]})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{Ir==="edit"?ws("view"):Tr(!1)},className:"px-4 py-2 bg-gray-200 hover:bg-gray-300 dark:bg-gray-600 dark:hover:bg-gray-500 text-gray-700 dark:text-gray-200 rounded-lg text-sm font-medium",disabled:mt,children:e("common.cancel")}),t.jsx("button",{onClick:Ir==="edit"?gn:ki,disabled:mt,className:"px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg text-sm font-medium flex items-center gap-2 disabled:opacity-50",children:mt?t.jsxs(t.Fragment,{children:[t.jsx(tr,{className:"animate-spin",size:12}),e(Ir==="edit"?"workOrders.detail.updating":"workOrders.detail.submitting")]}):t.jsxs(t.Fragment,{children:[t.jsx(Qt,{size:12}),e(Ir==="edit"?"workOrders.detail.updateFeedback":"workOrders.detail.submitFeedback")]})})]})})]})}),t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("button",{onClick:()=>a(-1),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-2",children:[t.jsx(ia,{}),t.jsx("span",{className:"text-gray-900 dark:text-white",children:xc()})]}),!c&&t.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${En.bg} ${En.text} ${En.border} border`,children:(M==null?void 0:M.repair_status)||Oe.repair_status||"Open"}),l&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1 bg-orange-100 dark:bg-orange-900/30 text-orange-700 dark:text-orange-300 rounded-full text-xs font-medium",children:[t.jsx(ov,{size:10}),e("workOrders.detail.linkedFromAsset")," ",o]}),jt&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1 bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 rounded-full text-xs font-medium",children:[t.jsx(tr,{className:"animate-spin",size:12}),e("workOrders.detail.loadingAssetDetails")]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[!c&&t.jsxs("button",{onClick:w,className:"bg-purple-600 hover:bg-purple-700 text-white px-6 py-2 rounded-lg flex items-center gap-2",title:e("workOrders.detail.printServiceReport"),children:[t.jsx(yl,{}),e("workOrders.detail.serviceReport")]}),!c&&r&&qi==="Repair InProgress"&&t.jsxs("button",{type:"button",onClick:()=>a(`/work-orders/${encodeURIComponent(r)}/troubleshoot`),title:mu?e("workOrders.detail.troubleshootingGuideDoneTitle"):void 0,className:mu?"bg-gray-500 hover:bg-gray-600 text-white px-6 py-2 rounded-lg flex items-center gap-2 shadow-sm ring-1 ring-gray-400/50 dark:ring-gray-500/50":"bg-violet-600 hover:bg-violet-700 text-white px-6 py-2 rounded-lg flex items-center gap-2",children:[mu?t.jsx(Qt,{className:"shrink-0","aria-hidden":!0}):t.jsx(Ju,{className:"shrink-0","aria-hidden":!0}),t.jsxs("span",{className:"flex flex-col items-start leading-tight text-left",children:[t.jsx("span",{children:e("workOrders.detail.troubleshootingTree")}),mu?t.jsx("span",{className:"text-[10px] font-medium opacity-90",children:e("workOrders.detail.troubleshootingGuideDone")}):null]})]}),!c&&!De&&!_i&&!js&&Qo&&!od&&C&&t.jsxs("button",{onClick:()=>{Et(!0),We.info(e("workOrders.detail.editModeEnabled"),{position:"top-right",autoClose:2e3,icon:t.jsx(qr,{})})},className:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(qr,{}),e("common.edit")]}),!c&&!De&&(M==null?void 0:M.docstatus)===1&&Ct&&t.jsxs("button",{onClick:()=>it(!0),className:"bg-orange-600 hover:bg-orange-700 text-white px-6 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(Mo,{}),e("common.cancel")]}),De&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{c?a(-1):(Et(!1),We.info(e("workOrders.detail.editCancelledChangesDiscarded"),{position:"top-right",autoClose:2e3,icon:t.jsx(pr,{})}))},className:"bg-gray-300 hover:bg-gray-400 text-gray-700 px-6 py-2 rounded-lg",disabled:Re,children:e("common.cancel")}),t.jsxs("button",{onClick:nd,disabled:Re||jt,className:"bg-green-600 hover:bg-green-700 text-white px-6 py-2 rounded-lg flex items-center gap-2 disabled:opacity-50",children:[t.jsx(ta,{}),e(Re?"common.saving":"common.saveChanges")]})]})]})]}),l&&c&&t.jsx("div",{className:"mb-6 bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(ov,{className:"text-orange-500 mt-0.5"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-semibold text-orange-800 dark:text-orange-300",children:e("workOrders.createFromAsset")}),t.jsxs("p",{className:"text-xs text-orange-700 dark:text-orange-400 mt-1",children:[e("workOrders.detail.assetInfoPrefilled")," ",t.jsx("strong",{children:Oe.asset_name||o}),".",e("assets.pleaseSelectWorkOrderType")]})]})]})}),t.jsx("form",{onSubmit:nd,className:"space-y-6",style:{overflow:"visible"},children:t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6",style:{overflow:"visible"},children:[t.jsxs("div",{className:"lg:col-span-3 space-y-6",style:{overflow:"visible"},children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white",children:"Asset Information"}),l&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-orange-100 dark:bg-orange-900/30 text-orange-600 dark:text-orange-400 rounded text-[10px] font-medium",children:[t.jsx(ov,{size:8}),e("workOrders.detail.fromAsset")]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[t.jsx("div",{children:t.jsx(Je,{label:e("workOrders.detail.hospital"),doctype:"Company",value:Oe.company||"",onChange:fe=>ar(je(se({},Oe),{company:fe,department:""})),disabled:!De,filters:{domain:"Healthcare"}})}),t.jsxs("div",{className:"relative z-[50]",children:[t.jsx(Je,{label:e("workOrders.detail.technicalDepartment"),doctype:"Issue Type",value:Oe.work_order_type||"",onChange:rd,disabled:!De}),Mt.length>0&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:e("workOrders.detail.supervisorsAvailableForType",{count:Mt.length})})]}),Oe.work_order_type==="Civil works-الأعمال المدنية"&&t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:[e("workOrders.detail.civilWorkCategory")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("select",{name:"custom_civil_work_category",value:Oe.custom_civil_work_category||"",onChange:ka,disabled:!De,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("workOrders.detail.selectCivilWorkCategory")}),t.jsx("option",{value:"CARPENTARY",children:"CARPENTARY"}),t.jsx("option",{value:"MASONRY",children:"MASONRY"}),t.jsx("option",{value:"PAINTING",children:"PAINTING"}),t.jsx("option",{value:"PLUMPING",children:"PLUMPING"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("workOrders.detail.woType")}),t.jsx("select",{name:"custom_type",value:Oe.custom_type,onChange:Pl,disabled:!De,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:t.jsx("option",{value:"Corrective",children:"Corrective"})})]}),t.jsx("div",{className:"relative z-[40]",children:(()=>{const fe={docstatus:1};return Oe.company&&(fe.company=Oe.company),Oe.custom_building&&(fe.custom_building=Oe.custom_building),Oe.department&&(fe.department=Oe.department),Oe.custom_room_no&&(fe.custom_room_number=Oe.custom_room_no),t.jsxs(t.Fragment,{children:[t.jsx(Je,{label:e("workOrders.detail.assetId"),doctype:"Asset",value:Oe.asset||"",onChange:Al,disabled:!De||jt||!!Oe.asset,filters:fe}),Oe.asset&&t.jsxs("div",{className:"flex items-center justify-between mt-1",children:[t.jsx("p",{className:"text-xs text-green-600 dark:text-green-400",children:"✓ Asset details auto-populated"}),De&&t.jsx("button",{type:"button",onClick:()=>Al(""),className:"text-xs text-red-500 hover:text-red-700 underline",children:"Clear Asset"})]}),be&&!Oe.asset&&t.jsxs("p",{className:"mt-1 text-xs text-red-500 flex items-center gap-1",children:[t.jsx(Or,{size:10}),"Asset is required based on your location selection"]}),!Oe.asset&&(Oe.custom_building||Oe.department||Oe.custom_room_no)&&!be&&ye>0&&t.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:[ye," asset(s) available for selected location"]})]})})()}),Oe.asset&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("workOrders.detail.assetName")}),t.jsx("input",{type:"text",name:"asset_name",value:Oe.asset_name,onChange:ka,disabled:!De,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsx("div",{children:t.jsx(Je,{label:e("workOrders.detail.extensionNo"),doctype:"Extension Directory",value:Oe.custom_extension_no||"",onChange:fe=>ar(je(se({},Oe),{custom_extension_no:fe})),disabled:!De,allowQuickCreate:!0})}),t.jsxs("div",{children:[t.jsx(Je,{label:e("workOrders.detail.building"),doctype:"Building",value:Oe.custom_building||"",onChange:p0,disabled:!De,allowQuickCreate:!0}),!Oe.custom_building&&De&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:e("workOrders.detail.selectBuildingFirst")})]}),Kc()&&t.jsxs("div",{children:[t.jsx(Je,{label:e("workOrders.detail.departmentName"),doctype:"Department",value:Oe.department||"",onChange:lg,disabled:!De,filters:oe.length>0?{name:["in",oe]}:cg,allowQuickCreate:!0}),Oe.custom_building&&oe.length===0&&!Ce&&t.jsx("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:"No departments mapped to this building"}),Oe.custom_building&&oe.length>0&&t.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:[oe.length," department(s) available for this building"]}),!Oe.department&&Oe.custom_building&&De&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:"Select Department to enable Room No"})]}),Km()&&t.jsxs("div",{children:[t.jsx(Je,{label:e("workOrders.detail.roomNo"),doctype:"Room",value:Oe.custom_room_no||"",onChange:Zm,disabled:!De,query:"asset_lite.api.room_filter.get_filtered_rooms",filters:(()=>{const fe={};return Oe.custom_building&&(fe.building=Oe.custom_building),Oe.department&&(fe.department=Oe.department),fe})(),allowQuickCreate:!0}),Ce&&t.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400 flex items-center gap-1",children:[t.jsx(tr,{className:"animate-spin",size:10}),"Loading..."]}),!Ce&&(Oe.custom_building||Oe.department)&&ve.length===0&&t.jsxs("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:["No rooms mapped to ",Oe.custom_building&&Oe.department?"this building + department":Oe.custom_building?"this building":"this department"]}),!Ce&&(Oe.custom_building||Oe.department)&&ve.length>0&&t.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:[ve.length," room(s) available",Oe.custom_building&&!Oe.department&&" (filtered by building)",!Oe.custom_building&&Oe.department&&" (filtered by department)",Oe.custom_building&&Oe.department&&" (filtered by building + department)"]}),!Oe.custom_room_no&&Oe.department&&De&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:"Select Room No to enable Location"})]}),u0()&&t.jsxs("div",{children:[t.jsx(Je,{label:e("workOrders.detail.location"),doctype:"Location",value:Oe.custom_location||"",onChange:fe=>ar(je(se({},Oe),{custom_location:fe})),disabled:!De,allowQuickCreate:!0}),Ce&&t.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400 flex items-center gap-1",children:[t.jsx(tr,{className:"animate-spin",size:10}),"Loading location data..."]}),(Oe.custom_building||Oe.department)&&Oe.custom_room_no&&Oe.custom_location&&t.jsx("p",{className:"mt-1 text-xs text-green-600 dark:text-green-400",children:"✓ Location auto-set from Infrastructure mapping"})]}),Oe.inspection&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Inspection"}),t.jsxs("div",{className:"flex items-center gap-3 p-2 bg-gray-100 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600",children:[t.jsx("span",{className:"text-gray-900 dark:text-white font-medium",children:Oe.inspection}),t.jsxs("button",{type:"button",onClick:()=>a(`/inspections/${Oe.inspection}`),className:"text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 flex items-center gap-1 text-sm",children:["View ",t.jsx(dn,{size:12})]})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Opening Attachment"}),Oe.custom_attachment?t.jsxs("div",{className:"flex items-center gap-3 p-2 bg-gray-50 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600",children:[t.jsx(Nv,{className:"text-blue-500 flex-shrink-0",size:16}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("a",{href:`${Oe.custom_attachment}`,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 dark:text-blue-400 hover:underline truncate block",children:Ol(Oe.custom_attachment)})}),De&&t.jsx("button",{type:"button",onClick:f0,className:"p-1 text-red-500 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors flex-shrink-0",title:e("workOrders.detail.removeAttachment"),children:t.jsx(ht,{size:12})})]}):De?t.jsxs("label",{className:"flex items-center gap-2 px-3 py-2 bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 rounded-lg cursor-pointer hover:bg-blue-100 dark:hover:bg-blue-900/30 transition-colors border border-blue-200 dark:border-blue-800 w-fit",children:[rt?t.jsxs(t.Fragment,{children:[t.jsx(tr,{className:"animate-spin",size:14}),t.jsx("span",{className:"text-sm",children:e("workOrders.detail.uploading")})]}):t.jsxs(t.Fragment,{children:[t.jsx(Tv,{size:14}),t.jsx("span",{className:"text-sm",children:e("workOrders.detail.uploadOpeningFile")})]}),t.jsx("input",{type:"file",onChange:eh,disabled:rt,className:"hidden",accept:"image/*,.pdf,.doc,.docx,.xls,.xlsx,.txt"})]}):t.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 italic",children:e("workOrders.detail.noAttachment")})]}),["Pending Approval","Approved","Rejected","Closed"].includes(qi)&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("workOrders.detail.closingAttachment")}),Oe.custom_attachment_on_close?t.jsxs("div",{className:"flex items-center gap-3 p-2 bg-gray-50 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600",children:[t.jsx(Nv,{className:"text-green-500 flex-shrink-0",size:16}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("a",{href:`${Oe.custom_attachment_on_close}`,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 dark:text-blue-400 hover:underline truncate block",children:Ol(Oe.custom_attachment_on_close)})}),De&&t.jsx("button",{type:"button",onClick:()=>{ar(fe=>je(se({},fe),{custom_attachment_on_close:""})),We.info(e("workOrders.detail.closingAttachmentRemoved"),{position:"top-right",autoClose:2e3})},className:"p-1 text-red-500 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors flex-shrink-0",title:e("workOrders.detail.removeClosingAttachment"),children:t.jsx(ht,{size:12})})]}):De?t.jsxs("label",{className:"flex items-center gap-2 px-3 py-2 bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400 rounded-lg cursor-pointer hover:bg-green-100 dark:hover:bg-green-900/30 transition-colors border border-green-200 dark:border-green-800 w-fit",children:[rt?t.jsxs(t.Fragment,{children:[t.jsx(tr,{className:"animate-spin",size:14}),t.jsx("span",{className:"text-sm",children:e("workOrders.detail.uploading")})]}):t.jsxs(t.Fragment,{children:[t.jsx(Tv,{size:14}),t.jsx("span",{className:"text-sm",children:e("workOrders.detail.uploadClosingFile")})]}),t.jsx("input",{type:"file",onChange:fe=>J(null,null,function*(){var Kt,lr;const Te=(Kt=fe.target.files)==null?void 0:Kt[0];if(!Te)return;const qe=10*1024*1024;if(Te.size>qe){We.error(e("workOrders.detail.fileSizeExceeds"),{position:"top-right",autoClose:4e3,icon:t.jsx(pr,{})});return}ut(!0);try{const Ht=new FormData;Ht.append("file",Te),Ht.append("is_private","0"),Ht.append("folder","Home/Attachments"),!c&&r&&(Ht.append("doctype","Work_Order"),Ht.append("docname",r));const jr=Ar.BASE_URL||"",ns=yield(yield fetch(`${jr}/api/method/upload_file`,{method:"POST",credentials:"include",body:Ht})).json();if((lr=ns.message)!=null&&lr.file_url)ar(ha=>je(se({},ha),{custom_attachment_on_close:ns.message.file_url})),We.success(e("workOrders.detail.closingAttachmentUploadedSuccessfully"),{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})});else throw new Error("Upload failed")}catch(Ht){console.error("File upload error:",Ht),We.error(e("workOrders.detail.failedToUploadClosingAttachment"),{position:"top-right",autoClose:4e3,icon:t.jsx(pr,{})})}finally{ut(!1),fe.target.value=""}}),disabled:rt,className:"hidden",accept:"image/*,.pdf,.doc,.docx,.xls,.xlsx,.txt"})]}):t.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 italic",children:e("workOrders.detail.noClosingAttachment")})]}),!us&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative z-[40]",children:[t.jsx(Je,{label:e("workOrders.detail.assetId"),doctype:"Asset",value:Oe.asset||"",onChange:Al,disabled:!De||jt,filters:Oe.company?{company:Oe.company}:{}}),Oe.asset&&t.jsx("p",{className:"mt-1 text-xs text-green-600 dark:text-green-400",children:"✓ Asset details auto-populated"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Serial Number"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",name:"serial_number",value:Oe.serial_number,onChange:ka,onBlur:Qm,disabled:!De||jt,placeholder:e("workOrders.detail.enterSerialNumber"),className:"flex-1 px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),De&&t.jsx("button",{type:"button",onClick:uu,disabled:jt||!Oe.serial_number,className:"px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md disabled:opacity-50 disabled:cursor-not-allowed",title:e("workOrders.detail.searchAssetBySerial"),children:t.jsx(za,{size:14})})]})]}),Oe.asset&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("workOrders.detail.assetName")}),t.jsx("input",{type:"text",name:"asset_name",value:Oe.asset_name,onChange:ka,disabled:!De,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsx("div",{children:t.jsx(Je,{label:e("workOrders.detail.manufacturer"),doctype:"Manufacturer",value:Oe.manufacturer||"",onChange:fe=>ar(je(se({},Oe),{manufacturer:fe})),disabled:!De})}),t.jsx("div",{children:t.jsx(Je,{label:e("workOrders.detail.supplier"),doctype:"Supplier",value:Oe.supplier||"",onChange:fe=>ar(je(se({},Oe),{supplier:fe})),disabled:!De})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("workOrders.detail.model")}),t.jsx("input",{type:"text",name:"model",value:Oe.model,onChange:ka,disabled:!De,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:e("workOrders.detail.workOrderInformation")}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("workOrders.detail.workOrderId")}),t.jsx("input",{type:"text",value:c||u?e("workOrders.detail.autoGenerated"):M==null?void 0:M.name,disabled:!0,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("workOrders.detail.priority")}),t.jsxs("select",{name:"custom_priority_",value:Oe.custom_priority_,onChange:Pl,disabled:!De,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"Normal",children:"Normal"}),t.jsx("option",{value:"Medium",children:"Medium"}),t.jsx("option",{value:"Urgent",children:"Urgent"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("commonFields.status")}),t.jsx("input",{type:"text",value:Oe.repair_status,disabled:!0,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("workOrders.detail.pendingReason")}),t.jsxs("select",{name:"custom_pending_reason",value:Oe.custom_pending_reason||"",onChange:fe=>{const Te=fe.target.value;ar(qe=>je(se({},qe),{custom_pending_reason:Te,custom_reason:Te==="Other"?qe.custom_reason:""}))},disabled:!De,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("workOrders.detail.selectPendingReason")}),t.jsx("option",{value:"Need Part",children:"Need Part"}),t.jsx("option",{value:"Waiting For Quotation",children:"Waiting For Quotation"}),t.jsx("option",{value:"Waiting For PO",children:"Waiting For PO"}),t.jsx("option",{value:"Waiting For Part Delivery",children:"Waiting For Part Delivery"}),t.jsx("option",{value:"Other",children:"Other"})]})]}),Oe.custom_pending_reason==="Other"&&t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:[e("workOrders.detail.otherReason")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",name:"custom_reason",value:Oe.custom_reason||"",onChange:ka,disabled:!De,placeholder:e("workOrders.detail.pleaseSpecifyReason"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]})]}),!us&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:e("workOrders.detail.serviceAgreementDetails")}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("workOrders.detail.siteContractor")}),t.jsx("input",{type:"text",name:"custom_site_contractor",value:Oe.custom_site_contractor,onChange:ka,disabled:!De,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("workOrders.detail.subcontractor")}),t.jsx("input",{type:"text",name:"custom_subcontractor",value:Oe.custom_subcontractor,onChange:ka,disabled:!De,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Service Agreement"}),t.jsxs("select",{name:"custom_service_agreement",value:Oe.custom_service_agreement||"",onChange:ka,disabled:!De,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("workOrders.detail.selectServiceAgreement")}),t.jsx("option",{value:"Warranty",children:"Warranty"}),t.jsx("option",{value:"Contract",children:"Contract"}),t.jsx("option",{value:"Frame Work",children:"Frame Work"}),t.jsx("option",{value:"Main Contractor",children:"Main Contractor"}),t.jsx("option",{value:"Out of warranty",children:"Out of warranty"}),t.jsx("option",{value:"Under Dismantle",children:"Under Dismantle"}),t.jsx("option",{value:"Under Installation",children:"Under Installation"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Service Coverage"}),t.jsxs("select",{name:"custom_service_coverage",value:Oe.custom_service_coverage||"",onChange:ka,disabled:!De,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("workOrders.detail.selectServiceCoverage")}),t.jsx("option",{value:"PM Only",children:"PM Only"}),t.jsx("option",{value:"Labour",children:"Labour"}),t.jsx("option",{value:"Labour & Parts",children:"Labour & Parts"}),t.jsx("option",{value:"Comprehensive",children:"Comprehensive"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("filters.startDate")}),t.jsx("input",{type:"date",name:"custom_start_date",value:Oe.custom_start_date||"",onChange:ka,disabled:!De,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("filters.endDate")}),t.jsx("input",{type:"date",name:"custom_end_date",value:Oe.custom_end_date||"",onChange:ka,disabled:!De,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("assets.detail.totalAmount")}),t.jsx("input",{type:"number",name:"custom_total_amount",min:"0",step:"0.01",value:Oe.custom_total_amount||0,onChange:ka,disabled:!De,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:e("workOrders.detail.description")}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsx("div",{className:"md:col-span-2",children:t.jsx(Je,{label:e("workOrders.detail.supportIssue"),doctype:"Issue",value:Oe.issue||"",onChange:fe=>ar(Te=>je(se({},Te),{issue:fe})),disabled:!De})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("workOrders.detail.natureOfComplaint")}),t.jsx("textarea",{name:"description",value:Oe.description,onChange:ka,disabled:!De||!c&&!(qi==="Draft"&&T===(M==null?void 0:M.owner)),placeholder:e("workOrders.detail.describeComplaint"),rows:4,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white resize-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("workOrders.detail.technicalReport")}),t.jsx("textarea",{name:"actions_performed",value:Oe.actions_performed,onChange:ka,disabled:!De,placeholder:e("workOrders.detail.describeWorkPerformed"),rows:4,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white resize-none"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:e("workOrders.detail.assignments")}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx(Je,{label:e("workOrders.detail.assignedSupervisor"),doctype:"User",value:Oe.custom_assigned_supervisor||"",onChange:ad,disabled:!De,filters:Mt.length>0?{name:["in",Mt]}:{}}),!Oe.work_order_type&&De&&t.jsx("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:e("workOrders.detail.selectWoTypeFirstForSupervisors")}),Oe.work_order_type&&Mt.length===0&&De&&t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:e("workOrders.detail.noSupervisorsFound")}),!c&&sd&&t.jsx("p",{className:"mt-1 text-xs text-red-500",children:e("workOrders.detail.requiredForExistingWO")})]}),t.jsxs("div",{children:[t.jsx(Je,{label:e("workOrders.detail.assignedEngineer"),doctype:"User",value:Oe.custom_assigned_engineer||"",onChange:fe=>ar(je(se({},Oe),{custom_assigned_engineer:fe})),disabled:!De,filters:Tt.length>0?{name:["in",Tt]}:{}}),!Oe.work_order_type&&De&&t.jsx("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:e("workOrders.detail.selectWoTypeFirstForEngineers")}),Oe.work_order_type&&Tt.length===0&&De&&t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:e("workOrders.detail.noEngineersFound")}),Tt.length>0&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:e("workOrders.detail.engineersAvailable",{count:Tt.length})}),!c&&sd&&t.jsx("p",{className:"mt-1 text-xs text-red-500",children:e("workOrders.detail.requiredForExistingWO")})]}),t.jsxs("div",{children:[t.jsx(Je,{label:e("workOrders.detail.assignedTechnician"),doctype:"User",value:Oe.assigned_technician||"",onChange:fe=>ar(je(se({},Oe),{assigned_technician:fe})),disabled:!De,filters:Pt.length>0?{name:["in",Pt]}:{}}),!Oe.work_order_type&&De&&t.jsx("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:e("workOrders.detail.selectWoTypeFirstForTechnicians")}),Oe.work_order_type&&Pt.length===0&&De&&t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:e("workOrders.detail.noTechniciansFoundForType")}),Pt.length>0&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:e("workOrders.detail.techniciansAvailable",{count:Pt.length})}),!c&&sd&&qi==="Sent to Engineer"&&t.jsx("p",{className:"mt-1 text-xs text-red-500",children:e("workOrders.detail.requiredForSentToEngineer")})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Failure Date & Time"}),t.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[t.jsx("input",{type:"datetime-local",name:"failure_date",value:Oe.failure_date,onChange:dg,disabled:!De,className:"flex-1 min-w-0 px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),De&&t.jsxs("button",{type:"button",onClick:Bi,className:"flex-shrink-0 px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-xs flex items-center gap-1",title:"Set to current date & time",children:[t.jsx(ea,{size:12}),"Now"]})]}),Oe.failure_date&&t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:kc(Fh(Oe.failure_date))})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Deadline Date",t.jsx("span",{className:"ml-1 text-xs text-gray-400",children:e("workOrders.detail.autoCalculated")})]}),t.jsx("input",{type:"date",name:"custom_deadline_date",value:Oe.custom_deadline_date,onChange:ka,disabled:!De,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),De&&Oe.failure_date&&t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:pu()})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Total Hours Spent"}),t.jsx("input",{type:"number",name:"total_hours_spent",min:"0",step:"0.5",value:Oe.total_hours_spent||0,onChange:ka,disabled:!De,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["First Responded On",t.jsx("span",{className:"ml-1 text-xs text-gray-400",children:e("workOrders.detail.autoSetOnRepairStart")})]}),t.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[t.jsx("input",{type:"datetime-local",name:"first_responded_on",value:Oe.first_responded_on,onChange:Ui,disabled:!De,className:"flex-1 min-w-0 px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),De&&t.jsxs("button",{type:"button",onClick:ed,className:"flex-shrink-0 px-3 py-2 bg-green-600 hover:bg-green-700 text-white rounded-md text-xs flex items-center gap-1",title:"Set to current date & time",children:[t.jsx(ea,{size:12}),"Now"]})]}),Oe.first_responded_on&&t.jsxs("p",{className:"mt-1 text-xs text-green-600 dark:text-green-400",children:["✓ ",kc(Fh(Oe.first_responded_on))]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Completion Date & Time",t.jsx("span",{className:"ml-1 text-xs text-gray-400",children:e("workOrders.detail.autoSetOnClose")})]}),t.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[t.jsx("input",{type:"datetime-local",name:"completion_date",value:Oe.completion_date,onChange:th,disabled:!De,className:"flex-1 min-w-0 px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),De&&t.jsxs("button",{type:"button",onClick:td,className:"flex-shrink-0 px-3 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-md text-xs flex items-center gap-1",title:"Set to current date & time",children:[t.jsx(ea,{size:12}),"Now"]})]}),Oe.completion_date&&t.jsxs("p",{className:"mt-1 text-xs text-purple-600 dark:text-purple-400",children:["✓ ",kc(Fh(Oe.completion_date))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Total Travel Hours"}),t.jsx("input",{type:"text",name:"custom_travel_hour",value:Oe.custom_travel_hour,onChange:ka,disabled:!De,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700 relative z-20",style:{overflow:"visible"},children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Stock Consumption Details"}),t.jsxs("div",{className:"mb-4",children:[t.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:Oe.stock_consumption===1,onChange:fe=>{var Te;ar(je(se({},Oe),{stock_consumption:fe.target.checked?1:0,stock_items:fe.target.checked?(Te=Oe.stock_items)!=null&&Te.length?Oe.stock_items:[{item_code:"",warehouse:Tl,consumed_quantity:1,valuation_rate:0,custom_available_stock:0,total_value:0}]:[]}))},disabled:!De,className:"w-5 h-5 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600 disabled:opacity-50"}),t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Parts Consumed"})]}),t.jsx("p",{className:"mt-1 ml-8 text-xs text-gray-500 dark:text-gray-400",children:"Check this if spare parts or items were used during the repair"})]}),Oe.stock_consumption===1&&t.jsxs("div",{className:"mt-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Stock Items"}),De&&t.jsxs("button",{type:"button",onClick:()=>{ar(je(se({},Oe),{stock_items:[...Oe.stock_items||[],{item_code:"",warehouse:Tl,consumed_quantity:1,valuation_rate:0,custom_available_stock:0,total_value:0}]})),We.info(e("workOrders.detail.newStockItemRowAdded"),{position:"top-right",autoClose:2e3,icon:t.jsx(Rr,{})})},className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-white bg-green-600 hover:bg-green-700 rounded-md transition-colors",children:[t.jsx(Rr,{size:10}),e("workOrders.detail.addItem")]})]}),t.jsx("div",{className:"stock-items-table-wrapper",children:t.jsx("div",{className:"stock-items-scroll-container",children:t.jsxs("table",{className:"w-full text-sm border border-gray-200 dark:border-gray-700 rounded-lg",children:[t.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-10",children:"#"}),t.jsxs("th",{className:"px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider min-w-[180px]",children:[e("workOrders.detail.item")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("th",{className:"px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-28",children:e("workOrders.detail.valuationRate")}),t.jsxs("th",{className:"px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider min-w-[180px]",children:[e("workOrders.detail.warehouse")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("th",{className:"px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-24",children:e("workOrders.detail.consumedQty")}),t.jsx("th",{className:"px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-28",children:e("workOrders.detail.availableStock")}),t.jsx("th",{className:"px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-28",children:e("workOrders.detail.totalValue")}),De&&t.jsx("th",{className:"px-3 py-3 text-center text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-16",children:e("workOrders.detail.action")})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:(Oe.stock_items||[]).length===0?t.jsx("tr",{children:t.jsxs("td",{colSpan:De?8:7,className:"px-4 py-8 text-center text-gray-500 dark:text-gray-400",children:[t.jsx("p",{children:e("workOrders.detail.noItemsAddedYet")}),De&&t.jsx("button",{type:"button",onClick:()=>{ar(je(se({},Oe),{stock_items:[{item_code:"",warehouse:Tl,consumed_quantity:1,valuation_rate:0,custom_available_stock:0,total_value:0}]}))},className:"mt-2 text-blue-600 dark:text-blue-400 hover:underline text-sm",children:e("workOrders.detail.addFirstItem")})]})}):(Oe.stock_items||[]).map((fe,Te)=>t.jsxs(gr.Fragment,{children:[t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 ${pc[Te]?"bg-red-50 dark:bg-red-900/20":""}`,children:[t.jsx("td",{className:"px-3 py-3 text-gray-500 dark:text-gray-400",children:Te+1}),t.jsx("td",{className:"px-3 py-3 relative",style:{zIndex:50-Te},children:t.jsx("div",{className:"relative",children:t.jsx(Je,{label:"",doctype:"Item",value:fe.item_code,onChange:qe=>Jm(Te,qe),disabled:!De,placeholder:e("workOrders.detail.selectItem"),compact:!0,usePortal:!0,filters:se(se({is_stock_item:1},Oe.company?{custom_hospital_name:Oe.company}:{}),Oe.work_order_type?{custom_technical_department:Oe.work_order_type}:{})})})}),t.jsx("td",{className:"px-3 py-3",children:t.jsx("input",{type:"number",min:"0",step:"0.01",value:fe.valuation_rate||0,onChange:qe=>{const Kt=[...Oe.stock_items||[]],lr=parseFloat(qe.target.value)||0,Ht=Kt[Te].consumed_quantity||0;Kt[Te]=je(se({},Kt[Te]),{valuation_rate:lr,total_value:lr*Ht}),ar(je(se({},Oe),{stock_items:Kt}))},disabled:!De,className:"w-full px-2 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})}),t.jsx("td",{className:"px-3 py-3 relative",style:{zIndex:50-Te},children:t.jsx("div",{className:"relative",children:t.jsx(Je,{label:"",doctype:"Warehouse",value:fe.warehouse,onChange:qe=>Xm(Te,qe),disabled:!De,placeholder:e("workOrders.detail.selectWarehouse"),compact:!0,usePortal:!0})})}),t.jsx("td",{className:"px-3 py-3",children:t.jsx("input",{type:"number",min:"1",value:fe.consumed_quantity||1,onChange:qe=>El(Te,parseInt(qe.target.value)||1),disabled:!De,className:`w-full px-2 py-1.5 text-sm border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white ${pc[Te]?"border-red-500 dark:border-red-500":"border-gray-300 dark:border-gray-600"}`})}),t.jsx("td",{className:"px-3 py-3",children:t.jsx("input",{type:"number",min:"0",value:fe.custom_available_stock||0,disabled:!0,className:"w-full px-2 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300",title:e("workOrders.detail.autoPopulatedFromStock")})}),t.jsx("td",{className:"px-3 py-3",children:t.jsx("input",{type:"number",min:"0",step:"0.01",value:fe.total_value||0,disabled:!0,className:"w-full px-2 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300"})}),De&&t.jsx("td",{className:"px-3 py-3 text-center",children:t.jsx("button",{type:"button",onClick:()=>{var lr;const qe=(lr=Oe.stock_items)==null?void 0:lr[Te],Kt=(Oe.stock_items||[]).filter((Ht,jr)=>jr!==Te);ar(je(se({},Oe),{stock_items:Kt})),Zc(Ht=>{const jr=se({},Ht);return delete jr[Te],jr}),We.warning(e("workOrders.detail.stockItemRemoved",{item:(qe==null?void 0:qe.item_code)||"row"}),{position:"top-right",autoClose:2e3,icon:t.jsx(wr,{})})},className:"p-1.5 text-red-500 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors",title:e("workOrders.detail.removeItem"),children:t.jsx(wr,{size:14})})})]}),pc[Te]&&t.jsx("tr",{className:"bg-red-50 dark:bg-red-900/30",children:t.jsx("td",{colSpan:De?8:7,className:"px-4 py-2",children:t.jsxs("div",{className:"flex items-center gap-2 text-red-600 dark:text-red-400 text-xs",children:[t.jsx(Or,{}),t.jsx("span",{children:pc[Te]})]})})})]},Te))})]})})}),(Oe.stock_items||[]).length>0&&t.jsxs("div",{className:"mt-3 flex flex-wrap justify-between items-center gap-4 text-sm bg-gray-50 dark:bg-gray-700/50 p-3 rounded-lg",children:[t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[e("workOrders.detail.totalItems")," ",t.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:(Oe.stock_items||[]).length})]}),t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["Total Qty: ",t.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:(Oe.stock_items||[]).reduce((fe,Te)=>fe+(Number(Te.consumed_quantity)||0),0)})]}),t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["Total Value: ",t.jsx("span",{className:"font-semibold text-green-600 dark:text-green-400",children:(Oe.stock_items||[]).reduce((fe,Te)=>fe+(Number(Te.total_value)||0),0).toFixed(2)})]})]})]}),t.jsx("div",{className:"mt-6 pt-4 border-t border-gray-200 dark:border-gray-700",children:t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Total Repair Cost"}),t.jsx("input",{type:"number",name:"total_repair_cost",min:"0",step:"0.01",value:Oe.total_repair_cost||0,onChange:ka,disabled:!De,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})})})]}),!c&&t.jsx(Bm,{referenceDoctype:"Work_Order",referenceName:r||null,title:"Comments & Discussion",pollInterval:3e4,initialLimit:5,collapsible:!0,startCollapsed:!1})]}),t.jsxs("div",{className:"space-y-6",children:[!c&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsx("div",{className:"flex items-center justify-between mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white",children:"Workflow Actions"})}),t.jsxs("div",{className:`p-4 rounded-lg border mb-4 ${En.bg} ${En.border}`,children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:e("workOrders.detail.currentState")}),t.jsx("p",{className:`text-lg font-semibold ${En.text}`,children:qi})]}),wo&&t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400 mb-4",children:[t.jsx(tr,{className:"animate-spin"}),t.jsx("span",{className:"text-sm",children:e("workOrders.detail.loadingActions")})]}),Jc&&t.jsx("div",{className:"p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg mb-4",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Or,{className:"text-red-500 mt-0.5"}),t.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:Jc})]})}),$e&&t.jsxs("div",{className:"p-4 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg mb-4",children:[t.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[t.jsx(Or,{className:"text-yellow-500 mt-0.5"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-yellow-800 dark:text-yellow-200",children:e("workOrders.detail.confirmAction")}),t.jsx("p",{className:"text-xs text-yellow-600 dark:text-yellow-400 mt-1",children:e("workOrders.detail.confirmActionMessage",{action:$e.action})})]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>Hi($e.action,$e.nextState),disabled:Yc,className:"px-3 py-1.5 bg-red-600 hover:bg-red-700 text-white text-sm rounded-md disabled:opacity-50",children:Yc?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(tr,{className:"animate-spin",size:12}),e("workOrders.detail.processing")]}):e("workOrders.detail.yesAction",{action:$e.action})}),t.jsx("button",{onClick:()=>Qe(null),disabled:Yc,className:"px-3 py-1.5 bg-gray-300 hover:bg-gray-400 text-gray-700 text-sm rounded-md disabled:opacity-50",children:e("common.cancel")})]})]}),!wo&&jo.length>0&&!$e&&t.jsxs("div",{className:"space-y-3",children:[Zo&&t.jsx("div",{className:"p-2 bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg mb-2",children:t.jsx("p",{className:"text-xs text-purple-700 dark:text-purple-300",children:e("workOrders.detail.systemManagerNote")})}),De&&jo.some(fe=>fe.action!=="Apply")&&t.jsx("div",{className:"p-2 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg mb-2",children:t.jsxs("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:[t.jsx(ro,{className:"inline mr-1",size:10}),e("workOrders.detail.saveToSeeActions")]})}),(()=>{const fe=De?jo.filter(Te=>Te.action==="Apply"):jo;return fe.length===0?null:t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 flex items-center gap-1",children:[t.jsx(ro,{size:12}),e("workOrders.detail.availableActions")," (",fe.length,")"]}),t.jsx("div",{className:"flex flex-col gap-2",children:fe.map((Te,qe)=>t.jsxs("button",{onClick:()=>Hi(Te.action,Te.next_state),disabled:Yc,className:`w-full px-4 py-2.5 rounded-lg text-sm font-medium transition-colors disabled:opacity-50 flex items-center justify-center gap-2 ${m0(Te.action)}`,children:[Yc?t.jsx(tr,{className:"animate-spin",size:14}):t.jsx("span",{children:Xo(Te.action)}),Te.action]},`${Te.action}-${Te.next_state}-${qe}`))})]})})(),(()=>{const fe=De?jo.filter(Te=>Te.action==="Apply"):jo;return fe.length===0?null:t.jsxs("div",{className:"mt-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-2",children:e("workOrders.detail.actionResults")}),fe.map((Te,qe)=>t.jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-300",children:[Te.action," → ",t.jsx("span",{className:"font-medium",children:Te.next_state})]},qe))]})})()]}),!c&&!wo&&qi==="Sent to Engineer"&&(()=>{const fe=!!(Oe.assigned_technician||M!=null&&M.assigned_technician),Te=!!(Oe.actions_performed||(M==null?void 0:M.actions_performed)||"").trim();return fe&&Te?t.jsx("div",{className:"p-4 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg mb-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(Qt,{className:"text-green-500 mt-0.5 flex-shrink-0",size:18}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-semibold text-green-800 dark:text-green-200 mb-1",children:e("workOrders.detail.allOptionsAvailable")}),t.jsx("p",{className:"text-xs text-green-600 dark:text-green-400",children:e("workOrders.detail.bothFilledMessage")})]})]})}):fe&&!Te?t.jsx("div",{className:"p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg mb-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(ro,{className:"text-blue-500 mt-0.5 flex-shrink-0",size:18}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-semibold text-blue-800 dark:text-blue-200 mb-2",children:e("workOrders.detail.technicianAssigned")}),t.jsx("div",{className:"mb-3 p-2 bg-green-100 dark:bg-green-900/30 rounded border border-green-200 dark:border-green-700",children:t.jsxs("p",{className:"text-xs text-green-700 dark:text-green-300 flex items-start gap-1",children:[t.jsx(Qt,{size:10,className:"mt-0.5 flex-shrink-0"}),t.jsxs("span",{className:"min-w-0",children:[e("workOrders.detail.assignedTechnicianLabel")," ",t.jsx("strong",{className:"break-all",children:Oe.assigned_technician||(M==null?void 0:M.assigned_technician)})]})]})}),t.jsxs("div",{className:"p-2 bg-white dark:bg-gray-800 rounded border border-blue-100 dark:border-blue-700",children:[t.jsx("p",{className:"text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("workOrders.detail.wantToEnableSendToSupervisor")}),t.jsxs("p",{className:"text-xs text-orange-600 dark:text-orange-400 flex items-start gap-1",children:[t.jsx(Or,{size:10,className:"mt-0.5 flex-shrink-0"}),t.jsx("span",{children:e("workOrders.detail.fillTechnicalReportToUnlock")})]})]})]})]})}):!fe&&Te?t.jsx("div",{className:"p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg mb-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(ro,{className:"text-blue-500 mt-0.5 flex-shrink-0",size:18}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm font-semibold text-blue-800 dark:text-blue-200 mb-2",children:e("workOrders.detail.technicalReportFilled")}),t.jsx("div",{className:"mb-3 p-2 bg-green-100 dark:bg-green-900/30 rounded border border-green-200 dark:border-green-700",children:t.jsxs("p",{className:"text-xs text-green-700 dark:text-green-300 flex items-center gap-1",children:[t.jsx(Qt,{size:10}),'"Send to Supervisor" button is now available above']})}),t.jsxs("div",{className:"p-2 bg-white dark:bg-gray-800 rounded border border-blue-100 dark:border-blue-700",children:[t.jsx("p",{className:"text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Want more workflow options?"}),t.jsxs("p",{className:"text-xs text-orange-600 dark:text-orange-400 flex items-center gap-1",children:[t.jsx(Or,{size:10}),'Assign a "Technician" to enable technician workflow actions']})]})]})]})}):t.jsx("div",{className:"p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg mb-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(ro,{className:"text-blue-500 mt-0.5 flex-shrink-0",size:18}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm font-semibold text-blue-800 dark:text-blue-200 mb-2",children:"Choose Your Path"}),t.jsxs("div",{className:"mb-3 p-2 bg-white dark:bg-gray-800 rounded border border-blue-100 dark:border-blue-700",children:[t.jsx("p",{className:"text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Option 1: Assign to Technician"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:'Edit the form → Fill "Assigned Technician" → Save → Proceed with technician workflow'})]}),t.jsxs("div",{className:"p-2 bg-white dark:bg-gray-800 rounded border border-blue-100 dark:border-blue-700",children:[t.jsx("p",{className:"text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Option 2: Send Directly to Supervisor"}),t.jsxs("p",{className:"text-xs text-orange-600 dark:text-orange-400 flex items-center gap-1",children:[t.jsx(Or,{size:10}),'Fill "Technical Report" field to enable "Send to Supervisor" button']})]})]})]})})})(),!c&&!wo&&qi==="Repair InProgress"&&(S.includes("Technician")||S.includes("Contractor Engineer"))&&((Oe.actions_performed||(M==null?void 0:M.actions_performed)||"").trim()?t.jsx("div",{className:"p-4 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg mb-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(Qt,{className:"text-green-500 mt-0.5 flex-shrink-0",size:18}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm font-semibold text-green-800 dark:text-green-200 mb-1",children:"Ready for Approval"}),t.jsx("p",{className:"text-xs text-green-600 dark:text-green-400",children:'Technical Report is filled. You can now use "Send For Approval" action.'})]})]})}):t.jsx("div",{className:"p-4 bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg mb-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(Or,{className:"text-orange-500 mt-0.5 flex-shrink-0",size:18}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm font-semibold text-orange-800 dark:text-orange-200 mb-2",children:"Action Required"}),t.jsxs("div",{className:"p-2 bg-white dark:bg-gray-800 rounded border border-orange-100 dark:border-orange-700",children:[t.jsx("p",{className:"text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Technical Report Required"}),t.jsxs("p",{className:"text-xs text-orange-600 dark:text-orange-400 flex items-center gap-1",children:[t.jsx(Or,{size:10}),'Please fill the "Technical Report" field to enable "Send For Approval" button']})]})]})]})})),!wo&&re&&t.jsx("div",{className:"p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg mb-4",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(ro,{className:"text-blue-500 mt-0.5 flex-shrink-0"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-blue-800 dark:text-blue-200",children:re.includes("WO Type has been changed")?"Technical Dept Changed":qi==="Sent to Engineer"?"Choose Your Path":qi==="Repair InProgress"?"Action Required":"Apply Action Unavailable"}),t.jsx("p",{className:"text-xs text-orange-600 dark:text-orange-400 mt-1",children:re}),!re.includes("Technical Dept has been changed")&&t.jsx("p",{className:"text-xs text-orange-500 dark:text-orange-500 mt-2",children:"→ Edit the form to assign the required fields, then save to enable the action."})]})]})}),!wo&&jo.length===0&&t.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center",children:"No workflow actions available"}),t.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 text-center mt-1",children:"(Conditions may not be met for available transitions)"})]})]}),!c&&["Approved","Closed"].includes((M==null?void 0:M.workflow_state)||Oe.workflow_state||"")&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Feedback"}),hn?t.jsxs("div",{className:"flex items-center justify-center py-4",children:[t.jsx(tr,{className:"animate-spin text-blue-500 mr-2",size:14}),t.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:e("workOrders.detail.checkingFeedback")})]}):ma?t.jsxs("div",{children:[t.jsxs("div",{className:"p-4 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg mb-4 text-center",children:[t.jsx("p",{className:"text-xs text-green-600 dark:text-green-400 mb-2 font-medium",children:fo?"Your Rating":"Owner Rating"}),t.jsx("div",{className:"flex items-center justify-center gap-1 mb-1",children:[1,2,3,4,5].map(fe=>t.jsx("span",{className:`text-xl ${(ma.overall||0)>=fe*.2?"text-yellow-400":"text-gray-300 dark:text-gray-500"}`,children:"★"},fe))}),t.jsxs("p",{className:"text-lg font-bold text-green-700 dark:text-green-300",children:[((ma.overall||0)*5).toFixed(1)," / 5"]})]}),t.jsx("button",{onClick:mr,className:"w-full px-4 py-2.5 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm font-medium flex items-center justify-center gap-2 transition-colors",children:"⭐ See Rating"})]}):fo?t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-4 text-center",children:e("workOrders.detail.howWasService")}),t.jsxs("button",{onClick:oa,className:"w-full px-4 py-2.5 bg-yellow-500 hover:bg-yellow-600 text-white rounded-lg text-sm font-medium flex items-center justify-center gap-2 transition-colors",children:["⭐ ",e("workOrders.detail.giveFeedback")]})]}):t.jsx("div",{className:"text-center py-4",children:t.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 italic",children:e("workOrders.detail.noFeedbackYet")})})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:e("workOrders.detail.statusSummary")}),!c&&M&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:e("workOrders.detail.priority")}),t.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:M.custom_priority_||"Normal"})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:e("workOrders.detail.created")}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:M.creation?kc(M.creation):"-"})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:e("workOrders.detail.lastModified")}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:M.modified?kc(M.modified):"-"})]})]}),c&&t.jsxs("div",{className:"text-center py-8",children:[t.jsx(ro,{className:"text-4xl text-gray-400 dark:text-gray-500 mx-auto mb-2"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e("workOrders.detail.statusInfoAfterCreation")})]})]}),!c&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center gap-2 cursor-pointer flex-1",onClick:()=>Mr(!rr),children:[t.jsx(ym,{className:"text-blue-500",size:16}),t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white",children:e("workOrders.detail.activityLog")}),Ut.length>0&&t.jsx("span",{className:"px-2 py-0.5 bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 rounded-full text-xs font-medium",children:Ut.length})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:fe=>{fe.stopPropagation(),gs(),We.info(e("workOrders.detail.activityLogRefreshed"),{position:"top-right",autoClose:1500,icon:t.jsx(Ma,{})})},disabled:pt,className:"p-1.5 text-gray-400 hover:text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded transition-colors disabled:opacity-50",title:e("workOrders.detail.refreshActivityLogTitle"),children:t.jsx(Ma,{className:`${pt?"animate-spin":""}`,size:12})}),t.jsx("button",{type:"button",onClick:()=>Mr(!rr),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:rr?t.jsx(Ja,{size:14}):t.jsx(Fr,{size:14})})]})]}),rr&&t.jsxs("div",{className:"p-4",children:[pt&&t.jsxs("div",{className:"flex items-center justify-center py-8",children:[t.jsx(tr,{className:"animate-spin text-blue-500 mr-2",size:16}),t.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:e("workOrders.detail.loadingActivity")})]}),!pt&&Ut.length===0&&t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute left-3 top-0 bottom-0 w-0.5 bg-gray-200 dark:bg-gray-700"}),t.jsxs("div",{className:"relative pl-8 mb-4",children:[t.jsx("div",{className:"absolute left-1.5 top-1 w-3 h-3 rounded-full border-2 border-white dark:border-gray-800 bg-gray-300 dark:bg-gray-600"}),t.jsx("div",{className:"p-3 rounded-lg bg-gray-50 dark:bg-gray-700/50",children:t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 italic",children:e("workOrders.detail.noChangesRecorded")})})]}),(M==null?void 0:M.creation)&&(M==null?void 0:M.owner)&&t.jsxs("div",{className:"relative pl-8",children:[t.jsx("div",{className:"absolute left-1.5 top-1 w-3 h-3 rounded-full border-2 border-white dark:border-gray-800 bg-green-500"}),t.jsxs("div",{className:"p-3 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-100 dark:border-green-800/50",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-6 h-6 rounded-full bg-green-200 dark:bg-green-800 flex items-center justify-center",children:t.jsx(nn,{className:"text-green-600 dark:text-green-400",size:10})}),t.jsx("span",{className:"text-xs font-medium text-gray-700 dark:text-gray-300",children:tl(M.owner)})]}),t.jsxs("div",{className:"flex items-center gap-1 text-xs text-gray-500 dark:text-gray-400",children:[t.jsx(ea,{size:10}),t.jsx("span",{title:kc(M.creation),children:Dl(M.creation)})]})]}),t.jsx("div",{className:"text-xs",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-1 bg-green-100 dark:bg-green-800/50 text-green-700 dark:text-green-300 rounded font-medium",children:[t.jsx(Qt,{size:10}),"Created this Work Order"]})})]})]})]}),!pt&&Ut.length>0&&t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute left-3 top-0 bottom-0 w-0.5 bg-gray-200 dark:bg-gray-700"}),t.jsx("div",{className:"space-y-4",children:(Br?Ut:Ut.slice(0,5)).map((fe,Te)=>t.jsxs("div",{className:"relative pl-8",children:[t.jsx("div",{className:`absolute left-1.5 top-1 w-3 h-3 rounded-full border-2 border-white dark:border-gray-800 ${Te===0?"bg-blue-500":"bg-gray-300 dark:bg-gray-600"}`}),t.jsxs("div",{className:`p-3 rounded-lg ${Te===0?"bg-blue-50 dark:bg-blue-900/20 border border-blue-100 dark:border-blue-800/50":"bg-gray-50 dark:bg-gray-700/50"}`,children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-6 h-6 rounded-full bg-gray-200 dark:bg-gray-600 flex items-center justify-center",children:t.jsx(nn,{className:"text-gray-500 dark:text-gray-400",size:10})}),t.jsx("span",{className:"text-xs font-medium text-gray-700 dark:text-gray-300",children:tl(fe.owner)})]}),t.jsxs("div",{className:"flex items-center gap-1 text-xs text-gray-500 dark:text-gray-400",children:[t.jsx(ea,{size:10}),t.jsx("span",{title:kc(fe.creation),children:Dl(fe.creation)})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[fe.changes.length>0?fe.changes.map((qe,Kt)=>t.jsxs("div",{className:"text-xs",children:[t.jsx("span",{className:`font-medium ${sh(qe.field)}`,children:el(qe.field)}),t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[" ",e("workOrders.detail.changedFrom")," "]}),t.jsx("span",{className:"px-1.5 py-0.5 bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400 rounded text-[10px] font-mono",children:ld(qe.oldValue)}),t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:" → "}),t.jsx("span",{className:"px-1.5 py-0.5 bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400 rounded text-[10px] font-mono",children:ld(qe.newValue)})]},Kt)):t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 italic",children:e("workOrders.detail.documentUpdated")}),fe.added&&fe.added.length>0&&t.jsxs("div",{className:"text-xs text-green-600 dark:text-green-400",children:[t.jsx("span",{className:"font-medium",children:e("workOrders.detail.added")})," ",fe.added.length," ",e("workOrders.detail.items")]}),fe.removed&&fe.removed.length>0&&t.jsxs("div",{className:"text-xs text-red-600 dark:text-red-400",children:[t.jsx("span",{className:"font-medium",children:e("workOrders.detail.removed")})," ",fe.removed.length," ",e("workOrders.detail.items")]}),fe.rowChanged&&fe.rowChanged.length>0&&t.jsxs("div",{className:"text-xs text-orange-600 dark:text-orange-400",children:[t.jsx("span",{className:"font-medium",children:e("workOrders.detail.modified")})," ",fe.rowChanged.length," ",e("workOrders.detail.rows")]})]})]})]},fe.name))}),Ut.length>5&&t.jsx("div",{className:"mt-4 text-center",children:t.jsx("button",{type:"button",onClick:()=>Yr(!Br),className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-md transition-colors",children:Br?t.jsxs(t.Fragment,{children:[t.jsx(Ja,{size:10}),e("workOrders.detail.showLess")]}):t.jsxs(t.Fragment,{children:[t.jsx(Fr,{size:10}),e("workOrders.detail.showAll")," (",Ut.length," ",e("workOrders.detail.entries"),")"]})})}),(M==null?void 0:M.creation)&&(M==null?void 0:M.owner)&&t.jsxs("div",{className:"relative pl-8 mt-4",children:[t.jsx("div",{className:"absolute left-1.5 top-1 w-3 h-3 rounded-full border-2 border-white dark:border-gray-800 bg-green-500"}),t.jsxs("div",{className:"p-3 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-100 dark:border-green-800/50",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-6 h-6 rounded-full bg-green-200 dark:bg-green-800 flex items-center justify-center",children:t.jsx(nn,{className:"text-green-600 dark:text-green-400",size:10})}),t.jsx("span",{className:"text-xs font-medium text-gray-700 dark:text-gray-300",children:tl(M.owner)})]}),t.jsxs("div",{className:"flex items-center gap-1 text-xs text-gray-500 dark:text-gray-400",children:[t.jsx(ea,{size:10}),t.jsx("span",{title:new Date(M.creation).toLocaleString(),children:Dl(M.creation)})]})]}),t.jsx("div",{className:"text-xs",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-1 bg-green-100 dark:bg-green-800/50 text-green-700 dark:text-green-300 rounded font-medium",children:[t.jsx(Qt,{size:10}),"Created this Work Order"]})})]})]})]})]})]}),!c&&((M==null?void 0:M.docstatus)===0||(M==null?void 0:M.docstatus)===2)&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Delete Request"}),t.jsx(n0,{doctype:"Work_Order",docname:r,currentDeleteStatus:(cd=M==null?void 0:M.custom_delete_status)!=null?cd:null,userRoles:S,isSystemManager:Zo,redirectOnDelete:"/work-orders",onStatusChange:fe=>{le()}})]})]})]})}),t.jsx("style",{children:`
|
||
/* Wrapper for table - allow natural flow */
|
||
.stock-items-table-wrapper {
|
||
width: 100%;
|
||
position: relative;
|
||
}
|
||
|
||
/* Scroll container handles horizontal scrolling only */
|
||
.stock-items-scroll-container {
|
||
width: 100%;
|
||
overflow-x: auto;
|
||
overflow-y: visible;
|
||
-webkit-overflow-scrolling: touch;
|
||
}
|
||
|
||
/* Table styling */
|
||
.stock-items-scroll-container table {
|
||
border-collapse: separate;
|
||
border-spacing: 0;
|
||
min-width: 100%;
|
||
}
|
||
|
||
.stock-items-scroll-container tbody tr td {
|
||
position: relative;
|
||
}
|
||
`})]})},Ene=()=>{const{t:e}=sr(),r=hr(),[a,s]=p.useState(0),[n,i]=p.useState(""),[o,l]=p.useState(""),[c,u]=p.useState(null),[h,f]=p.useState(null),y=p.useRef(null),b=20,w=o?{maintenance_status:o}:{},{logs:v,totalCount:k,hasMore:S,loading:N,error:C,refetch:O}=V1(w,b,a*b,"due_date asc"),{deleteLog:T,loading:P}=$9();p.useEffect(()=>{const re=X=>{y.current&&!y.current.contains(X.target)&&f(null)};return h&&document.addEventListener("mousedown",re),()=>{document.removeEventListener("mousedown",re)}},[h]);const E=()=>{r("/maintenance/new")},R=re=>{r(`/maintenance/${re}`)},z=re=>{r(`/maintenance/${re}`)},G=re=>J(null,null,function*(){try{yield T(re),u(null),O(),alert(e("maintenance.deletedSuccessfully"))}catch(X){alert(`Failed to delete: ${X instanceof Error?X.message:"Unknown error"}`)}}),ae=re=>{r(`/maintenance/new?duplicate=${re}`)},ee=re=>{const X=JSON.stringify(re,null,2),V=new Blob([X],{type:"application/json"}),I=URL.createObjectURL(V),B=document.createElement("a");B.href=I,B.download=`maintenance_${re.name}.json`,B.click(),URL.revokeObjectURL(I)},ne=re=>{window.open(`/maintenance/${re}?print=true`,"_blank")},te=()=>{const X=[["Log ID","Asset","Type","Status","Due Date","Assigned To"].join(","),...v.map(Q=>[Q.name,Q.asset_name||"",Q.maintenance_type||"",Q.maintenance_status||"",Q.due_date||"",Q.assign_to_name||""].join(","))].join(`
|
||
`),V=new Blob([X],{type:"text/csv"}),I=URL.createObjectURL(V),B=document.createElement("a");B.href=I,B.download=`maintenance_logs_${new Date().toISOString().split("T")[0]}.csv`,B.click(),URL.revokeObjectURL(I)},Y=re=>{switch(re==null?void 0:re.toLowerCase()){case"completed":return t.jsx(Qt,{className:"text-green-500"});case"planned":return t.jsx(Y4,{className:"text-blue-500"});case"overdue":return t.jsx(Or,{className:"text-red-500"});default:return t.jsx(ea,{className:"text-gray-400"})}},q=re=>{switch(re==null?void 0:re.toLowerCase()){case"completed":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300";case"planned":return"bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-300";case"overdue":return"bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-300";case"cancelled":return"bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300";default:return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-300"}},H=(re,X)=>!re||(X==null?void 0:X.toLowerCase())==="completed"?!1:new Date(re)<new Date;if(N&&a===0)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("listPages.loading")})]})});if(C)return t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-6",children:[t.jsxs("h2",{className:"text-xl font-bold text-yellow-800 dark:text-yellow-300 mb-4",children:["⚠️ ",e("maintenance.apiNotAvailable")]}),t.jsxs("div",{className:"text-yellow-700 dark:text-yellow-400 space-y-3",children:[t.jsx("p",{children:t.jsx("strong",{children:e("maintenance.apiNotDeployed")})}),t.jsxs("div",{className:"mt-4 flex gap-3",children:[t.jsx("button",{onClick:()=>r("/maintenance/new"),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:e("maintenance.tryCreatingNew")}),t.jsx("button",{onClick:O,className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded",children:e("common.tryAgain")})]})]}),t.jsx("div",{className:"mt-4 p-4 bg-white dark:bg-gray-800 rounded border border-yellow-300 dark:border-yellow-700",children:t.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:[t.jsx("strong",{children:"Technical Error:"})," ",C]})})]})});const U=v.filter(re=>{var X,V,I;return((X=re.name)==null?void 0:X.toLowerCase().includes(n.toLowerCase()))||((V=re.asset_name)==null?void 0:V.toLowerCase().includes(n.toLowerCase()))||((I=re.task_name)==null?void 0:I.toLowerCase().includes(n.toLowerCase()))});return t.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-3xl font-bold text-gray-800 dark:text-white",children:e("maintenance.title")}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:e("maintenance.listTotal",{count:k})})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("button",{onClick:te,className:"bg-green-600 hover:bg-green-700 text-white px-4 py-3 rounded-lg flex items-center gap-2 shadow transition-all",disabled:v.length===0,children:[t.jsx(Sa,{}),t.jsx("span",{className:"font-medium",children:e("listPages.exportAllOnPage")})]}),t.jsxs("button",{onClick:E,className:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-lg flex items-center gap-2 shadow-lg transition-all hover:shadow-xl",children:[t.jsx(Rr,{}),t.jsx("span",{className:"font-medium",children:e("maintenance.addMaintenance")})]})]})]}),t.jsxs("div",{className:"mb-6 grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4",children:t.jsxs("div",{className:"flex items-center gap-2 border border-gray-300 dark:border-gray-600 rounded-lg px-4 py-2 bg-white dark:bg-gray-700",children:[t.jsx(za,{className:"text-gray-400 dark:text-gray-500"}),t.jsx("input",{type:"text",placeholder:e("listPages.searchPlaceholder"),value:n,onChange:re=>i(re.target.value),className:"flex-1 outline-none text-gray-700 dark:text-gray-200 bg-transparent"})]})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4",children:t.jsxs("select",{value:o,onChange:re=>{l(re.target.value),s(0)},className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500",children:[t.jsx("option",{value:"",children:e("listPages.allStatuses")}),t.jsx("option",{value:"Planned",children:e("maintenance.status.planned")}),t.jsx("option",{value:"Completed",children:e("maintenance.status.completed")}),t.jsx("option",{value:"Overdue",children:e("maintenance.status.overdue")}),t.jsx("option",{value:"Cancelled",children:e("maintenance.status.cancelled")})]})})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden",children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("maintenance.logId")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.assetShort")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.typeShort")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("ppm.dueDate")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.status")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("listPages.actions")})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:U.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-gray-500 dark:text-gray-400",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx(za,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("listPages.noMaintenanceLogsFound")}),t.jsx("button",{onClick:E,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:e("listPages.createFirstMaintenanceLog")})]})})}):U.map(re=>{const X=H(re.due_date||"",re.maintenance_status||"");return t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${X?"bg-red-50 dark:bg-red-900/10":""}`,onClick:()=>R(re.name),children:[t.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:re.name}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:re.creation?new Date(re.creation).toLocaleDateString():""})]}),t.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[t.jsx("div",{className:"text-sm text-gray-900 dark:text-white",children:re.asset_name||"-"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:re.custom_asset_type||""})]}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:re.maintenance_type||"-"}),t.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[t.jsx("div",{className:"text-sm text-gray-900 dark:text-white",children:re.due_date?new Date(re.due_date).toLocaleDateString():"-"}),X&&t.jsx("div",{className:"text-xs text-red-600 dark:text-red-400 font-semibold",children:"Overdue"})]}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsxs("div",{className:"flex items-center gap-2",children:[Y(re.maintenance_status||""),t.jsx("span",{className:`px-3 py-1 inline-flex text-xs leading-5 font-semibold rounded-full ${q(re.maintenance_status||"")}`,children:re.maintenance_status||"Unknown"})]})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:t.jsxs("div",{className:"flex items-center gap-1",onClick:V=>V.stopPropagation(),children:[t.jsx("button",{onClick:()=>R(re.name),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded transition-colors",title:"View Details",children:t.jsx(Ps,{})}),t.jsx("button",{onClick:()=>z(re.name),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:"Edit Log",children:t.jsx(qr,{})}),t.jsx("button",{onClick:()=>ae(re.name),className:"text-purple-600 dark:text-purple-400 hover:text-purple-900 dark:hover:text-purple-300 p-2 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded transition-colors",title:"Duplicate",children:t.jsx(Vo,{})}),t.jsx("button",{onClick:()=>u(re.name),className:"text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300 p-2 hover:bg-red-50 dark:hover:bg-red-900/30 rounded transition-colors",title:"Delete",disabled:P,children:t.jsx(wr,{})}),t.jsxs("div",{className:"relative",ref:h===re.name?y:null,children:[t.jsx("button",{onClick:()=>f(h===re.name?null:re.name),className:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 p-2 hover:bg-gray-50 dark:hover:bg-gray-700 rounded transition-colors",title:"More Actions",children:t.jsx(jx,{})}),h===re.name&&t.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 z-10",children:[t.jsxs("button",{onClick:()=>{ee(re),f(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2 rounded-t-lg",children:[t.jsx(qc,{className:"text-blue-500"}),"Export as JSON"]}),t.jsxs("button",{onClick:()=>{ne(re.name),f(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2 rounded-b-lg",children:[t.jsx(yl,{className:"text-purple-500"}),"Print Log"]})]})]})]})})]},re.name)})})]})}),U.length>0&&t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 px-6 py-4 flex items-center justify-between border-t border-gray-200 dark:border-gray-600",children:[t.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:["Showing ",t.jsx("span",{className:"font-medium",children:a*b+1})," to"," ",t.jsx("span",{className:"font-medium",children:Math.min((a+1)*b,k)})," ","of ",t.jsx("span",{className:"font-medium",children:k})," results"]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:a===0,onClick:()=>s(a-1),className:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Previous"}),t.jsx("button",{disabled:!S,onClick:()=>s(a+1),className:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Next"})]})]})]}),c&&t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx("div",{className:"flex-shrink-0 w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:t.jsx(wr,{className:"text-red-600 dark:text-red-400 text-xl"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Delete Maintenance Log"}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:"Are you sure you want to delete this maintenance log? This action cannot be undone."}),t.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-md p-3 mb-4",children:t.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[t.jsx("strong",{children:"Log ID:"})," ",c]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>u(null),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-lg transition-colors",disabled:P,children:"Cancel"}),t.jsx("button",{onClick:()=>G(c),className:"px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50",disabled:P,children:P?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Deleting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(wr,{}),"Delete Log"]})})]})]})]})})})]})},Ane=At,One=({message:e,type:r,onClose:a})=>{p.useEffect(()=>{const n=setTimeout(a,1e4);return()=>clearTimeout(n)},[a]);const s=r==="warning"?"bg-yellow-500":r==="success"?"bg-green-500":"bg-red-500";return t.jsx("div",{className:`fixed top-4 right-4 ${s} text-white px-6 py-4 rounded-lg shadow-lg z-50 max-w-md`,children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(Or,{className:"mt-0.5 flex-shrink-0"}),t.jsx("p",{className:"text-sm",children:e}),t.jsx("button",{onClick:a,className:"ml-2 text-white hover:text-gray-200",children:t.jsx(ht,{})})]})})},Pne=()=>{const{t:e}=sr(),{logName:r}=hs(),a=hr(),[s]=_a(),n=s.get("duplicate"),i=r==="new",o=i&&!!n,{log:l,loading:c,error:u}=jG(o?n:i?null:r||null),{createLog:h,updateLog:f,loading:y}=$9(),b=(l==null?void 0:l.workflow_state)==="Approved",[w,v]=p.useState(i),[k,S]=p.useState([]),[N,C]=p.useState(null),[O,T]=p.useState(!1),[P,E]=p.useState({asset_name:"",custom_asset_type:"",item_code:"",item_name:"",custom_asset_names:"",custom_hospital_name:"",task:"",task_name:"",maintenance_type:"Preventive Maintenance",periodicity:"",has_certificate:0,custom_early_completion:"",maintenance_status:"Planned",custom_accepted_by_moh:0,assign_to_name:"",due_date:"",completion_date:"",custom_early_completion_reason:"",custom_accepted_by_moh_:0,custom_template:"",custom_table:[],description:""}),R=p.useCallback((X,V,I)=>{if(I!=="Completed"){E(me=>je(se({},me),{custom_early_completion:""}));return}if(!X||!V)return;const B=new Date(X),Q=new Date(V),ie=new Date(B.getFullYear(),B.getMonth(),1);if(Q<ie){E(de=>je(se({},de),{custom_early_completion:"Yes"}));const me=Q.toLocaleDateString(),he=B.toLocaleDateString();C({message:`⚠️ Warning: Completion Date (${me}) is before the Due Date Month (${he}). Please verify.`,type:"warning"})}},[]),z=p.useCallback(X=>J(null,null,function*(){var V;if(X){T(!0);try{const I=yield Ane.apiCall(`/api/resource/PPM Templates/${encodeURIComponent(X)}`,"GET");if((V=I==null?void 0:I.data)!=null&&V.ppm_template_table&&Array.isArray(I.data.ppm_template_table)){const B=I.data.ppm_template_table.map((Q,ie)=>({idx:ie+1,maintenance_name:Q.maintenance_name||"",working:0,defect_found:0,not_working:0}));S(B)}}catch(I){console.error("Error loading PPM template:",I),C({message:"Failed to load PPM template. Please add items manually.",type:"error"})}finally{T(!1)}}}),[]);p.useEffect(()=>{l&&(l.workflow_state==="Approved"&&v(!1),E({asset_name:l.asset_name||"",custom_asset_type:l.custom_asset_type||"",item_code:l.item_code||"",item_name:l.item_name||"",custom_asset_names:l.custom_asset_names||"",custom_hospital_name:l.custom_hospital_name||"",task:l.task||"",task_name:l.task_name||"",maintenance_type:l.maintenance_type||"Preventive Maintenance",periodicity:l.periodicity||"",has_certificate:l.has_certificate||0,custom_early_completion:o?"":l.custom_early_completion||"",maintenance_status:o?"Planned":l.maintenance_status||"Planned",custom_accepted_by_moh:l.custom_accepted_by_moh||0,assign_to_name:l.assign_to_name||"",due_date:l.due_date||"",completion_date:o?"":l.completion_date||"",custom_early_completion_reason:o?"":l.custom_early_completion_reason||"",custom_accepted_by_moh_:l.custom_accepted_by_moh_||0,custom_template:l.custom_template||"",custom_table:l.custom_table||[],description:l.description||""}),l.custom_table&&Array.isArray(l.custom_table)&&l.custom_table.length>0?S(l.custom_table.map((X,V)=>({name:X.name,idx:X.idx||V+1,maintenance_name:X.maintenance_name||"",working:X.working||0,defect_found:X.defect_found||0,not_working:X.not_working||0}))):l.custom_template&&(!l.custom_table||l.custom_table.length===0)&&z(l.custom_template))},[l,o,z]),p.useEffect(()=>{P.completion_date&&P.due_date&&R(P.due_date,P.completion_date,P.maintenance_status)},[P.completion_date,P.due_date,P.maintenance_status,R]);const G=X=>{const{name:V,value:I,type:B}=X.target,Q=X.target.checked;E(ie=>je(se({},ie),{[V]:B==="checkbox"?Q?1:0:I}))},ae=X=>{const V=X.target.value;E(I=>je(se({},I),{maintenance_status:V})),V==="Completed"?R(P.due_date||"",P.completion_date||"",V):E(I=>je(se({},I),{custom_early_completion:""}))},ee=X=>{const V=X.target.value;E(I=>je(se({},I),{completion_date:V})),P.maintenance_status==="Completed"&&R(P.due_date||"",V,P.maintenance_status)},ne=X=>J(null,null,function*(){const V=X.target.value;E(I=>je(se({},I),{custom_template:V})),(V&&k.length===0||V&&k.length>0&&window.confirm("Loading a template will replace existing checklist items. Continue?"))&&z(V)}),te=()=>{const X={idx:k.length+1,maintenance_name:"",working:0,defect_found:0,not_working:0};S([...k,X])},Y=X=>{const V=k.filter((I,B)=>B!==X).map((I,B)=>je(se({},I),{idx:B+1}));S(V)},q=(X,V,I)=>{const B=[...k];B[X]=je(se({},B[X]),{[V]:I}),S(B)},H=X=>J(null,null,function*(){if(X.preventDefault(),!P.asset_name){alert("Please enter Asset Name");return}if(!P.maintenance_type){alert("Please select Maintenance Type");return}const V=k.map((B,Q)=>{const ie={idx:B.idx||Q+1,maintenance_name:B.maintenance_name||"",working:B.working?1:0,defect_found:B.defect_found?1:0,not_working:B.not_working?1:0};return B.name&&typeof B.name=="string"&&B.name.trim()!==""&&(ie.name=B.name),ie}),I=je(se({},P),{custom_table:V});console.log("Submitting maintenance log data:",I);try{if(i||o){const B=yield h(I);alert(o?"Maintenance log duplicated successfully!":"Maintenance log created successfully!"),a(`/maintenance/${B.name}`)}else r&&(yield f(r,I),alert("Maintenance log updated successfully!"),v(!1))}catch(B){console.error("Maintenance log save error:",B),alert("Failed to save: "+(B instanceof Error?B.message:"Unknown error"))}}),U=X=>({Draft:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",Applied:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",Pending:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",Approved:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",Rejected:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",Completed:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200"})[X]||"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",re=X=>({Planned:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",Completed:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",Overdue:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",Cancelled:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"})[X]||"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300";return c?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading maintenance log..."})]})}):u&&!i&&!o?t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:[t.jsxs("p",{className:"text-red-600 dark:text-red-400",children:["Error: ",u]}),t.jsx("button",{onClick:()=>a(-1),className:"mt-2 text-red-700 dark:text-red-400 underline hover:text-red-800 dark:hover:text-red-300",children:"Back to maintenance logs"})]})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[N&&t.jsx(One,{message:N.message,type:N.type,onClose:()=>C(null)}),t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("button",{onClick:()=>a(-1),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-2",children:[t.jsx(ia,{}),t.jsx("span",{className:"text-gray-900 dark:text-white font-semibold",children:o?"Duplicate Maintenance Log":i?"New Maintenance Log":"Maintenance Log Details"})]}),!i&&(l==null?void 0:l.workflow_state)&&t.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-medium ${U(l.workflow_state)}`,children:l.workflow_state})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[!i&&!w&&!b&&t.jsxs("button",{onClick:()=>v(!0),className:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(qr,{}),"Edit"]}),w&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{i?a(-1):v(!1)},className:"bg-gray-300 hover:bg-gray-400 text-gray-700 px-6 py-2 rounded-lg",disabled:y,children:"Cancel"}),t.jsxs("button",{onClick:H,disabled:y,className:"bg-green-600 hover:bg-green-700 text-white px-6 py-2 rounded-lg flex items-center gap-2 disabled:opacity-50",children:[t.jsx(ta,{}),y?"Saving...":"Save Changes"]})]})]})]}),t.jsx("form",{onSubmit:H,className:"space-y-6",children:t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[t.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Basic Information"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Log ID"}),t.jsx("input",{type:"text",value:i||o?"Auto-generated":(l==null?void 0:l.name)||"",disabled:!0,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-700 text-gray-900 dark:text-white"}),o&&t.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:["💡 Duplicating from: ",n]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Hospital"}),t.jsx("input",{type:"text",name:"custom_hospital_name",value:P.custom_hospital_name||"",onChange:G,disabled:!w,placeholder:"Hospital name",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Asset Name ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",name:"asset_name",value:P.asset_name,onChange:G,required:!0,disabled:!w,placeholder:"Asset ID",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Asset Display Name"}),t.jsx("input",{type:"text",name:"custom_asset_names",value:P.custom_asset_names||"",onChange:G,disabled:!w,placeholder:"Display name",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Asset Type"}),t.jsx("input",{type:"text",name:"custom_asset_type",value:P.custom_asset_type||"",onChange:G,disabled:!w,placeholder:"e.g., Bio Medical",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Maintenance Details"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Maintenance Type ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("select",{name:"maintenance_type",value:P.maintenance_type,onChange:G,required:!0,disabled:!w,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"Preventive Maintenance",children:"Preventive Maintenance"}),t.jsx("option",{value:"Corrective Maintenance",children:"Corrective Maintenance"}),t.jsx("option",{value:"Calibration",children:"Calibration"}),t.jsx("option",{value:"Inspection",children:"Inspection"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Periodicity"}),t.jsxs("select",{name:"periodicity",value:P.periodicity||"",onChange:G,disabled:!w,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:"Select periodicity"}),t.jsx("option",{value:"Daily",children:"Daily"}),t.jsx("option",{value:"Weekly",children:"Weekly"}),t.jsx("option",{value:"Monthly",children:"Monthly"}),t.jsx("option",{value:"Quarterly",children:"Quarterly"}),t.jsx("option",{value:"Half Yearly",children:"Half Yearly"}),t.jsx("option",{value:"Yearly",children:"Yearly"}),t.jsx("option",{value:"2 Yearly",children:"2 Yearly"}),t.jsx("option",{value:"3 Yearly",children:"3 Yearly"})]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Template",O&&t.jsx("span",{className:"ml-2 text-blue-500",children:"(Loading...)"})]}),t.jsx("input",{type:"text",name:"custom_template",value:P.custom_template||"",onChange:ne,disabled:!w,placeholder:"PPM Template name",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),t.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Enter template name to auto-load checklist items"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Status"}),t.jsxs("select",{name:"maintenance_status",value:P.maintenance_status,onChange:ae,disabled:!w,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"Planned",children:"Planned"}),t.jsx("option",{value:"Completed",children:"Completed"}),t.jsx("option",{value:"Overdue",children:"Overdue"}),t.jsx("option",{value:"Cancelled",children:"Cancelled"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Assigned To"}),t.jsx("input",{type:"text",name:"assign_to_name",value:P.assign_to_name||"",onChange:G,disabled:!w,placeholder:"Technician name",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Due Date"}),t.jsx("input",{type:"date",name:"due_date",value:P.due_date||"",onChange:G,disabled:!w,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Completion Date"}),t.jsx("input",{type:"date",name:"completion_date",value:P.completion_date||"",onChange:ee,disabled:!w,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Completion & Approval"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Early Completion",P.custom_early_completion==="Yes"&&t.jsx("span",{className:"ml-2 text-yellow-500",children:"⚠️ Auto-detected"})]}),t.jsx("input",{type:"text",value:P.custom_early_completion||"No",disabled:!0,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-700 text-gray-900 dark:text-white"}),t.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Auto-set based on completion date vs due date"})]}),P.custom_early_completion==="Yes"&&t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Early Completion Reason ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",name:"custom_early_completion_reason",value:P.custom_early_completion_reason||"",onChange:G,disabled:!w,required:!0,placeholder:"Required when early completion",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"checkbox",name:"custom_accepted_by_moh",checked:!!P.custom_accepted_by_moh,onChange:G,disabled:!w,className:"w-4 h-4 text-blue-600 rounded focus:ring-2 focus:ring-blue-500"}),t.jsx("label",{className:"text-xs font-medium text-gray-700 dark:text-gray-300",children:"Accepted by MOH"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex justify-between items-center mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-base font-semibold text-gray-800 dark:text-white flex items-center gap-2",children:[t.jsx(K9,{}),"PPM Checklist Table",O&&t.jsx("span",{className:"text-sm text-blue-500 font-normal",children:"(Loading template...)"})]}),w&&t.jsxs("button",{type:"button",onClick:te,className:"flex items-center gap-1 px-3 py-1.5 bg-blue-600 hover:bg-blue-700 text-white text-sm rounded-md",children:[t.jsx(Rr,{className:"text-xs"}),"Add Row"]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"bg-gray-50 dark:bg-gray-700",children:[t.jsx("th",{className:"text-left py-3 px-3 text-xs font-medium text-gray-700 dark:text-gray-300 w-12",children:"#"}),t.jsx("th",{className:"text-left py-3 px-3 text-xs font-medium text-gray-700 dark:text-gray-300",children:"Maintenance Task"}),t.jsx("th",{className:"text-center py-3 px-3 text-xs font-medium text-green-600 dark:text-green-400 w-24",children:t.jsxs("div",{className:"flex items-center justify-center gap-1",children:[t.jsx(Oc,{})," Working"]})}),t.jsx("th",{className:"text-center py-3 px-3 text-xs font-medium text-yellow-600 dark:text-yellow-400 w-28",children:t.jsxs("div",{className:"flex items-center justify-center gap-1",children:[t.jsx(Or,{})," Defect"]})}),t.jsx("th",{className:"text-center py-3 px-3 text-xs font-medium text-red-600 dark:text-red-400 w-28",children:t.jsxs("div",{className:"flex items-center justify-center gap-1",children:[t.jsx(ht,{})," Not Working"]})}),w&&t.jsx("th",{className:"text-center py-3 px-3 text-xs font-medium text-gray-700 dark:text-gray-300 w-16",children:"Action"})]})}),t.jsx("tbody",{children:k.length===0?t.jsx("tr",{children:t.jsxs("td",{colSpan:w?6:5,className:"text-center py-8 text-gray-500 dark:text-gray-400",children:["No checklist items. ",w&&'Enter a template name above or click "Add Row" to add items.']})}):k.map((X,V)=>t.jsxs("tr",{className:"border-b border-gray-100 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50",children:[t.jsx("td",{className:"py-3 px-3 text-sm text-gray-600 dark:text-gray-400",children:X.idx||V+1}),t.jsx("td",{className:"py-3 px-3",children:w?t.jsx("input",{type:"text",value:X.maintenance_name,onChange:I=>q(V,"maintenance_name",I.target.value),placeholder:"Enter maintenance task",className:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-1 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):t.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:X.maintenance_name})}),t.jsx("td",{className:"py-3 px-3 text-center",children:t.jsx("input",{type:"checkbox",checked:!!X.working,onChange:I=>q(V,"working",I.target.checked?1:0),disabled:!w,className:"w-5 h-5 text-green-600 rounded focus:ring-2 focus:ring-green-500 cursor-pointer disabled:cursor-default"})}),t.jsx("td",{className:"py-3 px-3 text-center",children:t.jsx("input",{type:"checkbox",checked:!!X.defect_found,onChange:I=>q(V,"defect_found",I.target.checked?1:0),disabled:!w,className:"w-5 h-5 text-yellow-600 rounded focus:ring-2 focus:ring-yellow-500 cursor-pointer disabled:cursor-default"})}),t.jsx("td",{className:"py-3 px-3 text-center",children:t.jsx("input",{type:"checkbox",checked:!!X.not_working,onChange:I=>q(V,"not_working",I.target.checked?1:0),disabled:!w,className:"w-5 h-5 text-red-600 rounded focus:ring-2 focus:ring-red-500 cursor-pointer disabled:cursor-default"})}),w&&t.jsx("td",{className:"py-3 px-3 text-center",children:t.jsx("button",{type:"button",onClick:()=>Y(V),className:"text-red-500 hover:text-red-700 p-1",title:"Remove row",children:t.jsx(wr,{})})})]},X.name||V))})]})})]})]}),t.jsxs("div",{className:"space-y-6",children:[!i&&l&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Workflow Actions"}),t.jsx(Ix,{doctype:"Asset Maintenance Log",docname:l.name||null,workflowState:l.workflow_state,showStateInfo:!1,onActionComplete:(X,V)=>{V&&console.log(`Action "${X}" completed successfully`)},onStateChange:()=>{window.location.reload()}})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Status Summary"}),!i&&l?t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Current Status"}),t.jsx("span",{className:`inline-block px-3 py-1 rounded-full text-sm font-medium ${re(P.maintenance_status)}`,children:P.maintenance_status||"Planned"})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Workflow State"}),t.jsx("span",{className:`inline-block px-3 py-1 rounded-full text-sm font-medium ${U(l.workflow_state||"Draft")}`,children:l.workflow_state||"Draft"})]}),P.custom_early_completion==="Yes"&&t.jsxs("div",{className:"p-4 bg-yellow-50 dark:bg-yellow-900/20 rounded-lg border border-yellow-200 dark:border-yellow-800",children:[t.jsx("p",{className:"text-xs text-yellow-600 dark:text-yellow-400 mb-1",children:"⚠️ Early Completion"}),t.jsx("p",{className:"text-sm text-yellow-700 dark:text-yellow-300 font-medium",children:"Completion date is before the due month"})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Due Date"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:P.due_date?new Date(P.due_date).toLocaleDateString():"Not set"}),P.due_date&&new Date(P.due_date)<new Date&&P.maintenance_status!=="Completed"&&t.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 font-semibold mt-1",children:"⚠️ Overdue"})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Completion Date"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:P.completion_date?new Date(P.completion_date).toLocaleDateString():"Not completed"})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Assigned To"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:P.assign_to_name||"Unassigned"})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"PPM Checklist"}),t.jsxs("p",{className:"text-sm text-gray-900 dark:text-white",children:[k.length," item(s)"]}),k.length>0&&t.jsxs("div",{className:"mt-2 text-xs space-y-1",children:[t.jsxs("p",{className:"text-green-600 dark:text-green-400",children:["✓ Working: ",k.filter(X=>X.working).length]}),t.jsxs("p",{className:"text-yellow-600 dark:text-yellow-400",children:["⚠ Defects: ",k.filter(X=>X.defect_found).length]}),t.jsxs("p",{className:"text-red-600 dark:text-red-400",children:["✗ Not Working: ",k.filter(X=>X.not_working).length]})]})]})]}):t.jsxs("div",{className:"text-center py-8",children:[t.jsx(ea,{className:"text-4xl text-gray-400 dark:text-gray-500 mx-auto mb-2"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Status information will appear after creation"})]})]}),!i&&l&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Audit Information"}),t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Created By"}),t.jsx("p",{className:"text-gray-900 dark:text-white",children:l.owner||"-"})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Created On"}),t.jsx("p",{className:"text-gray-900 dark:text-white",children:l.creation?new Date(l.creation).toLocaleString():"-"})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Modified By"}),t.jsx("p",{className:"text-gray-900 dark:text-white",children:l.modified_by||"-"})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Modified On"}),t.jsx("p",{className:"text-gray-900 dark:text-white",children:l.modified?new Date(l.modified).toLocaleString():"-"})]})]})]})]})]})})]})};class Dne{getAssetMaintenances(r,a,s=20,n=0,i){return J(this,null,function*(){const o=new URLSearchParams;r&&o.append("filters",JSON.stringify(r)),a&&a.length>0&&o.append("fields",JSON.stringify(a)),o.append("limit",s.toString()),o.append("offset",n.toString()),i&&o.append("order_by",i);const l=`${Ar.ENDPOINTS.GET_ASSET_MAINTENANCES}?${o.toString()}`;return At.apiCall(l)})}getAssetMaintenanceDetails(r){return J(this,null,function*(){const a=new URLSearchParams;a.append("maintenance_name",r);const s=`${Ar.ENDPOINTS.GET_ASSET_MAINTENANCE_DETAILS}?${a.toString()}`;return At.apiCall(s)})}createAssetMaintenance(r){return J(this,null,function*(){const a=`${Ar.ENDPOINTS.CREATE_ASSET_MAINTENANCE}`;return At.apiCall(a,{method:"POST",body:JSON.stringify({maintenance_data:JSON.stringify(r)})})})}updateAssetMaintenance(r,a){return J(this,null,function*(){const s=`${Ar.ENDPOINTS.UPDATE_ASSET_MAINTENANCE}`;return At.apiCall(s,{method:"POST",body:JSON.stringify({maintenance_name:r,maintenance_data:JSON.stringify(a)})})})}deleteAssetMaintenance(r){return J(this,null,function*(){const a=`${Ar.ENDPOINTS.DELETE_ASSET_MAINTENANCE}`;return At.apiCall(a,{method:"POST",body:JSON.stringify({maintenance_name:r})})})}getMaintenanceTasks(r){return J(this,null,function*(){const a=new URLSearchParams;a.append("maintenance_name",r);const s=`${Ar.ENDPOINTS.GET_MAINTENANCE_TASKS}?${a.toString()}`;return At.apiCall(s)})}getServiceCoverage(r){return J(this,null,function*(){const a=new URLSearchParams;a.append("maintenance_name",r);const s=`${Ar.ENDPOINTS.GET_SERVICE_COVERAGE}?${a.toString()}`;return At.apiCall(s)})}getMaintenancesByAsset(r,a,s=20,n=0){return J(this,null,function*(){const i=new URLSearchParams;i.append("asset_name",r),a&&i.append("filters",JSON.stringify(a)),i.append("limit",s.toString()),i.append("offset",n.toString());const o=`${Ar.ENDPOINTS.GET_MAINTENANCES_BY_ASSET}?${i.toString()}`;return At.apiCall(o)})}getActiveServiceContracts(r,a=20,s=0){return J(this,null,function*(){const n=new URLSearchParams;r&&n.append("filters",JSON.stringify(r)),n.append("limit",a.toString()),n.append("offset",s.toString());const i=`${Ar.ENDPOINTS.GET_ACTIVE_SERVICE_CONTRACTS}?${n.toString()}`;return At.apiCall(i)})}}const Uf=new Dne;function Rne(e,r=20,a=0,s){const[n,i]=p.useState([]),[o,l]=p.useState(0),[c,u]=p.useState(!1),[h,f]=p.useState(!0),[y,b]=p.useState(null),[w,v]=p.useState(0),k=p.useRef(!1),S=JSON.stringify(e);p.useEffect(()=>{if(k.current&&y)return;let C=!1;return k.current=!0,J(null,null,function*(){try{f(!0);const T=yield Uf.getAssetMaintenances(e,void 0,r,a,s);C||(i(T.asset_maintenances),l(T.total_count),u(T.has_more),b(null))}catch(T){if(!C){const P=T instanceof Error?T.message:"Failed to fetch PPM schedules";P.includes("417")||P.includes("Expectation Failed")||P.includes("has no attribute")?b("API endpoint not deployed. Please deploy ppm_api.py to your Frappe server."):b(P),i([]),l(0),u(!1)}}finally{C||f(!1)}}),()=>{C=!0}},[S,r,a,s,w]);const N=p.useCallback(()=>{k.current=!1,v(C=>C+1)},[]);return{ppms:n,totalCount:o,hasMore:c,loading:h,error:y,refetch:N}}function Mne(e){const[r,a]=p.useState(null),[s,n]=p.useState(!0),[i,o]=p.useState(null),l=p.useCallback(()=>J(null,null,function*(){if(!e){a(null),n(!1);return}try{n(!0),o(null);const u=yield Uf.getAssetMaintenanceDetails(e);a(u)}catch(u){o(u instanceof Error?u.message:"Failed to fetch PPM details")}finally{n(!1)}}),[e]);p.useEffect(()=>{l()},[l]);const c=p.useCallback(()=>{l()},[l]);return{ppm:r,loading:s,error:i,refetch:c}}function SL(){const[e,r]=p.useState(!1),[a,s]=p.useState(null),n=p.useCallback(l=>J(null,null,function*(){try{return r(!0),s(null),yield Uf.createAssetMaintenance(l)}catch(c){const u=c instanceof Error?c.message:"Failed to create PPM schedule";throw s(u),c}finally{r(!1)}}),[]),i=p.useCallback((l,c)=>J(null,null,function*(){try{return r(!0),s(null),yield Uf.updateAssetMaintenance(l,c)}catch(u){const h=u instanceof Error?u.message:"Failed to update PPM schedule";throw s(h),u}finally{r(!1)}}),[]),o=p.useCallback(l=>J(null,null,function*(){try{return r(!0),s(null),yield Uf.deleteAssetMaintenance(l)}catch(c){const u=c instanceof Error?c.message:"Failed to delete PPM schedule";throw s(u),c}finally{r(!1)}}),[]);return{createPPM:n,updatePPM:i,deletePPM:o,loading:e,error:a}}const Lne=()=>{const{t:e}=sr(),r=hr(),[a,s]=p.useState(0),[n,i]=p.useState(""),[o,l]=p.useState(""),[c,u]=p.useState(null),[h,f]=p.useState(null),y=p.useRef(null),b=20,w=o?{company:o}:{},{ppms:v,totalCount:k,hasMore:S,loading:N,error:C,refetch:O}=Rne(w,b,a*b,"creation desc"),{deletePPM:T,loading:P}=SL();p.useEffect(()=>{const Y=q=>{y.current&&!y.current.contains(q.target)&&f(null)};return h&&document.addEventListener("mousedown",Y),()=>{document.removeEventListener("mousedown",Y)}},[h]);const E=()=>{r("/ppm/new")},R=Y=>{r(`/ppm/${Y}`)},z=Y=>{r(`/ppm/${Y}`)},G=Y=>J(null,null,function*(){try{yield T(Y),u(null),O(),alert(e("ppm.deletedSuccessfully"))}catch(q){alert(`Failed to delete: ${q instanceof Error?q.message:"Unknown error"}`)}}),ae=Y=>{r(`/ppm/new?duplicate=${Y}`)},ee=Y=>{const q=JSON.stringify(Y,null,2),H=new Blob([q],{type:"application/json"}),U=URL.createObjectURL(H),re=document.createElement("a");re.href=U,re.download=`ppm_${Y.name}.json`,re.click(),URL.revokeObjectURL(U)},ne=()=>{const q=[["PPM ID","Company","Asset","Asset Type","Frequency","No. of PMs","Total Amount"].join(","),...v.map(X=>[X.name,X.company||"",X.asset_name||"",X.custom_asset_type||"",X.custom_frequency||"",X.custom_no_of_pms||"",X.custom_total_amount||""].join(","))].join(`
|
||
`),H=new Blob([q],{type:"text/csv"}),U=URL.createObjectURL(H),re=document.createElement("a");re.href=U,re.download=`ppm_schedules_${new Date().toISOString().split("T")[0]}.csv`,re.click(),URL.revokeObjectURL(U)};if(N&&a===0)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("listPages.loading")})]})});if(C)return t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-6",children:[t.jsxs("h2",{className:"text-xl font-bold text-yellow-800 dark:text-yellow-300 mb-4",children:["⚠️ ",e("ppm.apiNotAvailable")]}),t.jsxs("div",{className:"text-yellow-700 dark:text-yellow-400 space-y-3",children:[t.jsx("p",{children:t.jsx("strong",{children:e("ppm.apiNotDeployed")})}),t.jsxs("div",{className:"mt-4 flex gap-3",children:[t.jsx("button",{onClick:()=>r("/ppm/new"),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:e("ppm.tryCreatingNew")}),t.jsx("button",{onClick:O,className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded",children:e("common.tryAgain")})]})]}),t.jsx("div",{className:"mt-4 p-4 bg-white dark:bg-gray-800 rounded border border-yellow-300 dark:border-yellow-700",children:t.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:[t.jsx("strong",{children:"Technical Error:"})," ",C]})})]})});const te=v.filter(Y=>{var q,H,U,re;return((q=Y.name)==null?void 0:q.toLowerCase().includes(n.toLowerCase()))||((H=Y.asset_name)==null?void 0:H.toLowerCase().includes(n.toLowerCase()))||((U=Y.company)==null?void 0:U.toLowerCase().includes(n.toLowerCase()))||((re=Y.custom_asset_type)==null?void 0:re.toLowerCase().includes(n.toLowerCase()))});return t.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-3xl font-bold text-gray-800 dark:text-white",children:e("ppm.title")}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:e("ppm.listTotal",{count:k})})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("button",{onClick:ne,className:"bg-green-600 hover:bg-green-700 text-white px-4 py-3 rounded-lg flex items-center gap-2 shadow transition-all",disabled:v.length===0,children:[t.jsx(Sa,{}),t.jsx("span",{className:"font-medium",children:e("listPages.export")})]}),t.jsxs("button",{onClick:E,className:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-lg flex items-center gap-2 shadow-lg transition-all hover:shadow-xl",children:[t.jsx(Rr,{}),t.jsx("span",{className:"font-medium",children:e("ppm.addPPM")})]})]})]}),t.jsxs("div",{className:"mb-6 grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4",children:t.jsxs("div",{className:"flex items-center gap-2 border border-gray-300 dark:border-gray-600 rounded-lg px-4 py-2 bg-white dark:bg-gray-700",children:[t.jsx(za,{className:"text-gray-400 dark:text-gray-500"}),t.jsx("input",{type:"text",placeholder:e("ppm.searchPlaceholder"),value:n,onChange:Y=>i(Y.target.value),className:"flex-1 outline-none text-gray-700 dark:text-gray-200 bg-transparent"})]})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4",children:t.jsx("input",{type:"text",placeholder:e("ppm.filterByCompany"),value:o,onChange:Y=>{l(Y.target.value),s(0)},className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500"})})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden",children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("ppm.pmId")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("ppm.company")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("ppm.asset")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("ppm.assetType")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("ppm.frequency")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("ppm.noOfPMs")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("ppm.totalAmount")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("listPages.actions")})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:te.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:8,className:"px-6 py-12 text-center text-gray-500 dark:text-gray-400",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx(za,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("ppm.noSchedulesFound")}),t.jsx("button",{onClick:E,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:e("ppm.createFirstSchedule")})]})})}):te.map(Y=>t.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors cursor-pointer",onClick:()=>R(Y.name),children:[t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:Y.name})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(K4,{className:"text-gray-400"}),t.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:Y.company||"-"})]})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:Y.asset_name||"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:Y.custom_asset_type||"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Y4,{className:"text-blue-500"}),t.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:Y.custom_frequency||"-"})]})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:Y.custom_no_of_pms||"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:Y.custom_total_amount?`$${Y.custom_total_amount.toLocaleString()}`:"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:t.jsxs("div",{className:"relative",onClick:q=>q.stopPropagation(),children:[t.jsx("button",{onClick:()=>f(h===Y.name?null:Y.name),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700",children:t.jsx(jx,{})}),h===Y.name&&t.jsxs("div",{ref:y,className:"absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 rounded-lg shadow-lg z-10 border border-gray-200 dark:border-gray-700",children:[t.jsxs("button",{onClick:()=>{R(Y.name),f(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(Ps,{}),e("listPages.view")]}),t.jsxs("button",{onClick:()=>{z(Y.name),f(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(qr,{}),e("listPages.edit")]}),t.jsxs("button",{onClick:()=>{ae(Y.name),f(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(Vo,{}),e("listPages.duplicate")]}),t.jsxs("button",{onClick:()=>{ee(Y),f(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(Sa,{}),e("listPages.export")]}),t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700"}),t.jsxs("button",{onClick:()=>{u(Y.name),f(null)},className:"w-full text-left px-4 py-2 text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 flex items-center gap-2",children:[t.jsx(wr,{}),e("listPages.delete")]})]})]})})]},Y.name))})]})}),(S||a>0)&&t.jsxs("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex items-center justify-between",children:[t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:e("pagination.showingToOf",{start:a*b+1,end:Math.min((a+1)*b,k),total:k,label:e("listPages.results")})}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>s(Math.max(0,a-1)),disabled:a===0,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed",children:e("pagination.previous")}),t.jsx("button",{onClick:()=>s(a+1),disabled:!S,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed",children:e("pagination.next")})]})]})]}),c&&t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4",children:[t.jsx("h3",{className:"text-lg font-bold text-gray-900 dark:text-white mb-4",children:e("ppm.confirmDelete")}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:e("ppm.deleteConfirmMessage")}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>u(null),className:"px-4 py-2 text-gray-700 dark:text-gray-300 bg-gray-200 dark:bg-gray-700 rounded-lg hover:bg-gray-300 dark:hover:bg-gray-600",children:e("common.cancel")}),t.jsx("button",{onClick:()=>G(c),disabled:P,className:"px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 disabled:opacity-50",children:e(P?"common.deleting":"common.delete")})]})]})})]})},Fne=()=>{const{t:e}=sr(),{ppmName:r}=hs(),a=hr(),[s]=_a(),n=s.get("duplicate"),i=r==="new",o=i&&!!n,{ppm:l,loading:c,error:u,refetch:h}=Mne(o?n:i?null:r||null),{createPPM:f,updatePPM:y,loading:b}=SL(),[w,v]=p.useState(i),[k,S]=p.useState({company:"",asset_name:"",custom_asset_type:"",maintenance_team:"",custom_frequency:"",custom_total_amount:0,custom_no_of_pms:0,custom_price_per_pm:0});p.useEffect(()=>{l&&S({company:l.company||"",asset_name:l.asset_name||"",custom_asset_type:l.custom_asset_type||"",maintenance_team:l.maintenance_team||"",custom_frequency:l.custom_frequency||"",custom_total_amount:l.custom_total_amount||0,custom_no_of_pms:l.custom_no_of_pms||0,custom_price_per_pm:l.custom_price_per_pm||0})},[l,o]);const N=O=>{const{name:T,value:P}=O.target;S(E=>je(se({},E),{[T]:T.includes("amount")||T.includes("pms")||T.includes("price")?parseFloat(P)||0:P}))},C=O=>J(null,null,function*(){var T;if(O.preventDefault(),!k.asset_name){alert(e("ppm.detail.pleaseEnterAssetName"));return}try{if(i||o){const P=yield f(k),E=e(o?"ppm.detail.duplicatedSuccessfully":"ppm.detail.createdSuccessfully");alert(E),(T=P.asset_maintenance)!=null&&T.name?a(`/ppm/${P.asset_maintenance.name}`):(h(),a(-1))}else r&&(yield y(r,k),alert(e("ppm.detail.updatedSuccessfully")),v(!1),h())}catch(P){console.error("PPM save error:",P),alert(e("ppm.detail.failedToSave")+": "+(P instanceof Error?P.message:"Unknown error"))}});return c?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("ppm.detail.loadingSchedule")})]})}):u&&!i&&!o?t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:[t.jsxs("p",{className:"text-red-600 dark:text-red-400",children:[e("ppm.detail.errorLoading"),": ",u]}),t.jsx("button",{onClick:()=>a(-1),className:"mt-2 text-red-700 dark:text-red-400 underline hover:text-red-800 dark:hover:text-red-300",children:e("ppm.detail.backToSchedules")})]})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsx("div",{className:"flex items-center gap-4",children:t.jsxs("button",{onClick:()=>a(-1),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-2",children:[t.jsx(ia,{}),t.jsx("span",{className:"text-gray-900 dark:text-white",children:e(o?"ppm.detail.duplicateSchedule":i?"ppm.detail.newSchedule":"ppm.detail.scheduleDetails")})]})}),t.jsx("div",{className:"flex items-center gap-3",children:!i&&!w&&t.jsxs("button",{onClick:()=>v(!0),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(qr,{}),e("common.edit")]})})]}),t.jsxs("form",{onSubmit:C,children:[t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[t.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6",children:[t.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white mb-4",children:e("ppm.detail.basicInformation")}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[e("ppm.company")," *"]}),w?t.jsx("input",{type:"text",name:"company",value:k.company,onChange:N,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0}):t.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t.jsx("p",{className:"text-gray-900 dark:text-white",children:(l==null?void 0:l.company)||"-"})})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[e("ppm.detail.assetName")," *"]}),w?t.jsx("input",{type:"text",name:"asset_name",value:k.asset_name,onChange:N,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0}):t.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t.jsx("p",{className:"text-gray-900 dark:text-white",children:(l==null?void 0:l.asset_name)||"-"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:e("ppm.assetType")}),w?t.jsx("input",{type:"text",name:"custom_asset_type",value:k.custom_asset_type,onChange:N,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500"}):t.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t.jsx("p",{className:"text-gray-900 dark:text-white",children:(l==null?void 0:l.custom_asset_type)||"-"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:e("ppm.detail.maintenanceTeam")}),w?t.jsx("input",{type:"text",name:"maintenance_team",value:k.maintenance_team,onChange:N,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500"}):t.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t.jsx("p",{className:"text-gray-900 dark:text-white",children:(l==null?void 0:l.maintenance_team)||"-"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:e("ppm.frequency")}),w?t.jsx("input",{type:"text",name:"custom_frequency",value:k.custom_frequency,onChange:N,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:e("ppm.detail.frequencyPlaceholder")}):t.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t.jsx("p",{className:"text-gray-900 dark:text-white",children:(l==null?void 0:l.custom_frequency)||"-"})})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6",children:[t.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white mb-4",children:e("ppm.detail.financialInformation")}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:e("ppm.detail.numberOfPMs")}),w?t.jsx("input",{type:"number",name:"custom_no_of_pms",value:k.custom_no_of_pms,onChange:N,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500",min:"0"}):t.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t.jsx("p",{className:"text-gray-900 dark:text-white",children:(l==null?void 0:l.custom_no_of_pms)||"-"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:e("ppm.detail.pricePerPM")}),w?t.jsx("input",{type:"number",name:"custom_price_per_pm",value:k.custom_price_per_pm,onChange:N,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500",min:"0",step:"0.01"}):t.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t.jsx("p",{className:"text-gray-900 dark:text-white",children:l!=null&&l.custom_price_per_pm?`$${l.custom_price_per_pm.toLocaleString()}`:"-"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:e("ppm.totalAmount")}),w?t.jsx("input",{type:"number",name:"custom_total_amount",value:k.custom_total_amount,onChange:N,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500",min:"0",step:"0.01"}):t.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t.jsx("p",{className:"text-gray-900 dark:text-white font-semibold",children:l!=null&&l.custom_total_amount?`$${l.custom_total_amount.toLocaleString()}`:"-"})})]})]})]})]}),t.jsx("div",{className:"lg:col-span-1",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6 space-y-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:e("ppm.detail.scheduleInformation")}),!i&&l&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:e("ppm.pmId")}),t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:l.name})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:e("users.created")}),t.jsx("p",{className:"text-xs text-gray-900 dark:text-white",children:l.creation?new Date(l.creation).toLocaleString():"-"})]})]}),i&&t.jsxs("div",{className:"text-center py-8",children:[t.jsx(X9,{className:"text-4xl text-gray-400 dark:text-gray-500 mx-auto mb-2"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e("ppm.detail.scheduleInfoAfterCreation")})]})]})})]}),w&&t.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[t.jsx("button",{type:"button",onClick:()=>{i?a(-1):(v(!1),l&&S({company:l.company||"",asset_name:l.asset_name||"",custom_asset_type:l.custom_asset_type||"",maintenance_team:l.maintenance_team||"",custom_frequency:l.custom_frequency||"",custom_total_amount:l.custom_total_amount||0,custom_no_of_pms:l.custom_no_of_pms||0,custom_price_per_pm:l.custom_price_per_pm||0}))},className:"px-6 py-2 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700",children:e("common.cancel")}),t.jsxs("button",{type:"submit",disabled:b,className:"px-6 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg flex items-center gap-2 disabled:opacity-50",children:[t.jsx(ta,{}),e(b?"common.saving":i?"common.create":"ppm.detail.saveChanges")]})]})]})]})};class Ine{submitDocument(r,a){return J(this,null,function*(){try{const s=yield this.fetchWithTimeout(`${Ar.BASE_URL}/api/resource/PM Schedule Generator/${encodeURIComponent(r)}`,{method:"GET",headers:{Accept:"application/json"},credentials:"include"},3e4);if(!s.ok){const l=yield s.text();console.warn("Failed to fetch document for submit:",l);return}const i=(yield s.json()).data;if(!i){console.warn("No document data received");return}const o=yield this.fetchWithTimeout(`${Ar.BASE_URL}/api/method/frappe.client.submit`,{method:"POST",headers:a,credentials:"include",body:JSON.stringify({doc:i})},6e4);if(o.ok)console.log("✅ Document submitted successfully");else{const l=yield o.text();console.warn("Failed to submit document:",l)}}catch(s){console.warn("Error submitting document:",s.message)}})}fetchWithTimeout(r,a,s=12e4){return J(this,null,function*(){var o,l;const n=new AbortController,i=setTimeout(()=>n.abort(),s);try{const c=yield fetch(r,je(se({},a),{signal:n.signal}));return clearTimeout(i),c}catch(c){throw clearTimeout(i),c.name==="AbortError"?new Error(`Request timeout after ${s}ms. The server may be slow or the request is too large.`):(o=c.message)!=null&&o.includes("Failed to fetch")||(l=c.message)!=null&&l.includes("ERR_CONNECTION_TIMED_OUT")?new Error(`Connection timeout. Please check:
|
||
1. Your internet connection
|
||
2. Server is accessible
|
||
3. Try with fewer assets`):c}})}getFilteredAssets(r){return J(this,null,function*(){const a=[];r.modality&&a.push(["custom_modality","=",r.modality]),r.asset_type&&a.push(["custom_asset_type","=",r.asset_type]),r.department&&a.push(["department","=",r.department]),r.location&&a.push(["location","=",r.location]),r.manufacturer&&a.push(["custom_manufacturer","=",r.manufacturer]),r.model&&a.push(["custom_model","=",r.model]);const s=JSON.stringify(a),n=JSON.stringify(["name","asset_name","custom_asset_type","department","location","custom_manufacturer","custom_model","custom_modality","company"]),i=yield At.apiCall(`/api/resource/Asset?filters=${encodeURIComponent(s)}&fields=${encodeURIComponent(n)}&limit_page_length=1000`);return(i==null?void 0:i.data)||[]})}createBulkMaintenanceSchedules(r){return J(this,null,function*(){var i,l,c,u,h,f;if(!r.hospital)throw new Error("Hospital/Company is required to create PM Schedule Generator");if(!r.periodicity)throw new Error("Periodicity is required");if(r.assets.length===0)throw new Error("At least one asset must be selected");r.assets.length>50&&console.warn(`Creating schedules for ${r.assets.length} assets. This may take a while...`);const a={doctype:"PM Schedule Generator",hospital:r.hospital,start_date:r.start_date,end_date:r.end_date,periodicity:r.periodicity,pm_for:r.pm_for||null,no_of_pms:r.no_of_pms||null,maintenance_team:r.maintenance_team||null,maintenance_manager:r.maintenance_manager||null,assign_to:r.assign_to||null,modality:r.modality||null,manufacturer:r.manufacturer||null,model:r.model||null,department:r.department||null,maintenance_entries:r.assets.map(y=>({doctype:"PM Entry Line",asset:y.name,start_date:r.start_date,end_date:r.end_date,manufacturer:y.custom_manufacturer||null,model:y.custom_model||null}))};console.log("Creating PM Schedule Generator with document:",JSON.stringify(a,null,2));const s=yield At.getCSRFToken(),n={"Content-Type":"application/json",Accept:"application/json"};s&&(n["X-Frappe-CSRF-Token"]=s);try{const y=yield this.fetchWithTimeout(`${Ar.BASE_URL}/api/method/frappe.client.insert`,{method:"POST",headers:n,credentials:"include",body:JSON.stringify({doc:a})},12e4),b=yield y.text();if(console.log("frappe.client.insert response:",b),!y.ok)throw new Error(`HTTP ${y.status}: ${b}`);const w=JSON.parse(b),v=(i=w==null?void 0:w.message)==null?void 0:i.name;if(v)return console.log("✅ PM Schedule Generator created successfully:",v),yield this.submitDocument(v,n),{success:!0,created:r.assets.length,document:v,message:`PM Schedule Generator "${v}" created and submitted with ${r.assets.length} assets`};throw new Error("No document name in response")}catch(y){console.warn("Method 1 (frappe.client.insert) failed:",y.message);try{const o=a,{doctype:b,maintenance_entries:w}=o,v=li(o,["doctype","maintenance_entries"]),k=je(se({},v),{maintenance_entries:w.map(E=>{var R=E,{doctype:T}=R,P=li(R,["doctype"]);return P})});console.log("Trying Resource API with:",JSON.stringify(k,null,2));const S=yield this.fetchWithTimeout(`${Ar.BASE_URL}/api/resource/PM%20Schedule%20Generator`,{method:"POST",headers:n,credentials:"include",body:JSON.stringify(k)},12e4),N=yield S.text();if(console.log("Resource API response:",N),!S.ok)throw new Error(`HTTP ${S.status}: ${N}`);const C=JSON.parse(N),O=(l=C==null?void 0:C.data)==null?void 0:l.name;if(O)return console.log("✅ PM Schedule Generator created via Resource API:",O),yield this.submitDocument(O,n),{success:!0,created:r.assets.length,document:O,message:`PM Schedule Generator "${O}" created and submitted with ${r.assets.length} assets`};throw new Error("No document name in response")}catch(b){console.warn("Method 2 (Resource API) failed:",b.message);const w=[];throw(((c=y==null?void 0:y.message)==null?void 0:c.includes("timeout"))||((u=y==null?void 0:y.message)==null?void 0:u.includes("Failed to fetch")))&&(((h=b==null?void 0:b.message)==null?void 0:h.includes("timeout"))||((f=b==null?void 0:b.message)==null?void 0:f.includes("Failed to fetch")))?w.push(`⚠️ Connection timeout detected. This usually means:
|
||
• The server is taking too long to process ${r.assets.length} assets
|
||
• Network connection is slow or unstable
|
||
• Server may be overloaded
|
||
|
||
💡 Suggestions:
|
||
• Try with fewer assets (10-20 at a time)
|
||
• Check your internet connection
|
||
• Try again later if server is busy`):(w.push("Failed to create PM Schedule Generator. Errors:"),y!=null&&y.message&&w.push(`• frappe.client.insert: ${y.message.substring(0,150)}`),b!=null&&b.message&&w.push(`• Resource API: ${b.message.substring(0,150)}`),w.push(`
|
||
Please ensure:
|
||
1. Hospital (${r.hospital}) is valid
|
||
2. You have permission to create PM Schedule Generator
|
||
3. All required fields are filled (including PM Name and Assign To)`)),new Error(`Failed to create PM Schedule Generator.
|
||
|
||
${w.join(`
|
||
`)}`)}}})}getFilterOptions(){return J(this,null,function*(){try{const r=yield At.apiCall(`/api/resource/Asset?fields=${encodeURIComponent(JSON.stringify(["custom_modality","custom_asset_type","department","location","custom_manufacturer","custom_model"]))}&limit_page_length=1000`),a=(r==null?void 0:r.data)||[];return{modalities:[...new Set(a.map(n=>n.custom_modality).filter(Boolean))],assetTypes:[...new Set(a.map(n=>n.custom_asset_type).filter(Boolean))],departments:[...new Set(a.map(n=>n.department).filter(Boolean))],locations:[...new Set(a.map(n=>n.location).filter(Boolean))],manufacturers:[...new Set(a.map(n=>n.custom_manufacturer).filter(Boolean))],models:[...new Set(a.map(n=>n.custom_model).filter(Boolean))],company:[...new Set(a.map(n=>n.company).filter(Boolean))]}}catch(r){return console.error("Error fetching filter options:",r),{modalities:[],assetTypes:[],departments:[],locations:[],manufacturers:[],models:[],company:[]}}})}getMaintenanceTeams(){return J(this,null,function*(){try{const r=yield At.apiCall(`/api/resource/Asset Maintenance Team?fields=${encodeURIComponent(JSON.stringify(["name"]))}&limit_page_length=1000`);return r!=null&&r.data&&r.data.length>0?r.data.map(a=>({name:a.name,maintenance_team_name:a.name})):[]}catch(r){return console.warn("Could not fetch maintenance teams:",(r==null?void 0:r.message)||"Unknown error"),[]}})}getMaintenanceTeamDetails(r){return J(this,null,function*(){try{const a=yield At.apiCall(`/api/resource/Asset Maintenance Team/${encodeURIComponent(r)}`);if(a!=null&&a.data){const s=a.data,n=[];return s.maintenance_team_members&&Array.isArray(s.maintenance_team_members)&&s.maintenance_team_members.forEach(i=>{i.team_member&&n.push(i.team_member)}),{name:s.name,maintenance_manager:s.maintenance_manager||void 0,team_members:n.length>0?n:void 0}}return null}catch(a){return console.warn("Could not fetch maintenance team details:",(a==null?void 0:a.message)||"Unknown error"),null}})}}const wb=new Ine,zne=()=>{const{t:e}=sr(),r=hr(),[a,s]=p.useState({}),[n,i]=p.useState([]),[o,l]=p.useState({start_date:"",end_date:"",maintenance_team:"",assign_to:"",pm_for:"",maintenance_manager:"",periodicity:"Monthly",maintenance_type:"Preventive",no_of_pms:"",department:""}),[c,u]=p.useState(!1),[h,f]=p.useState(!1),[y,b]=p.useState([]),[w,v]=p.useState({modalities:[],assetTypes:[],departments:[],locations:[],manufacturers:[],models:[],company:[]}),[k,S]=p.useState([]),[N,C]=p.useState(""),[O,T]=p.useState(null);p.useEffect(()=>{E(),R()},[]);const P=(H,U,re)=>{if(!H||!U||!re)return null;const X=parseInt(re,10);if(isNaN(X)||X<1)return null;const V=X-1;if(V<0)return null;const I=new Date(H),B=new Date(I);switch(U){case"Daily":B.setDate(B.getDate()+V);break;case"Weekly":B.setDate(B.getDate()+V*7);break;case"Monthly":B.setMonth(B.getMonth()+V);break;case"Quarterly":B.setMonth(B.getMonth()+V*3);break;case"Half-yearly":B.setMonth(B.getMonth()+V*6);break;case"Yearly":B.setFullYear(B.getFullYear()+V);break;case"2 Yearly":B.setFullYear(B.getFullYear()+V*2);break;case"3 Yearly":B.setFullYear(B.getFullYear()+V*3);break;default:return null}const Q=B.getFullYear(),ie=String(B.getMonth()+1).padStart(2,"0"),me=String(B.getDate()).padStart(2,"0");return`${Q}-${ie}-${me}`};p.useEffect(()=>{J(null,null,function*(){if(o.maintenance_team){const U=yield wb.getMaintenanceTeamDetails(o.maintenance_team);U&&l(re=>je(se({},re),{maintenance_manager:U.maintenance_manager||"",assign_to:U.team_members&&U.team_members.length===1?U.team_members[0]:re.assign_to}))}else l(U=>je(se({},U),{maintenance_manager:"",assign_to:""}))})},[o.maintenance_team]),p.useEffect(()=>{if(o.start_date&&o.periodicity&&o.no_of_pms){const H=P(o.start_date,o.periodicity,o.no_of_pms);H&&l(U=>je(se({},U),{end_date:H}))}},[o.start_date,o.periodicity,o.no_of_pms]);const E=()=>J(null,null,function*(){const H=yield wb.getFilterOptions();v(H)}),R=()=>J(null,null,function*(){const H=yield wb.getMaintenanceTeams();S(H)}),z=()=>J(null,null,function*(){f(!0);try{const H=new URLSearchParams;a.company&&H.append("company",a.company),a.custom_modality&&H.append("custom_modality",a.custom_modality),a.custom_manufacturer&&H.append("custom_manufacturer",a.custom_manufacturer),a.custom_device_status&&H.append("custom_device_status",a.custom_device_status),a.custom_model&&H.append("custom_model",a.custom_model),a.department&&H.append("department",a.department);const U=yield fetch(`/api/method/get_assets?${H.toString()}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"});if(!U.ok)throw new Error(`HTTP error! status: ${U.status}`);const X=(yield U.json()).message||[];b(X),i([])}catch(H){console.error("Error fetching assets:",H),alert("Failed to fetch assets: "+(H instanceof Error?H.message:"Unknown error"))}finally{f(!1)}}),G=(H,U)=>{s(re=>je(se({},re),{[H]:U||void 0}))},ae=H=>{i(U=>U.includes(H)?U.filter(re=>re!==H):[...U,H])},ee=()=>{const H=ne();n.length===H.length&&H.length>0?i([]):i(H.map(U=>U.name))},ne=()=>{if(!N)return y;const H=N.toLowerCase();return y.filter(U=>{var re,X,V,I,B,Q;return((re=U.asset_name)==null?void 0:re.toLowerCase().includes(H))||((X=U.custom_modality)==null?void 0:X.toLowerCase().includes(H))||((V=U.company)==null?void 0:V.toLowerCase().includes(H))||((I=U.custom_manufacturer)==null?void 0:I.toLowerCase().includes(H))||((B=U.custom_model)==null?void 0:B.toLowerCase().includes(H))||((Q=U.custom_device_status)==null?void 0:Q.toLowerCase().includes(H))})},te=()=>J(null,null,function*(){if(n.length===0){alert("Please select at least one asset");return}if(!a.company){alert("Please select a Hospital/Company in the filters first");return}if(!o.pm_for){alert("Please enter a PM Name");return}if(!o.start_date||!o.end_date){alert("Please select start and end dates");return}if(new Date(o.start_date)>new Date(o.end_date)){alert("Start date must be before end date");return}if(!o.assign_to){alert("Please assign the task to a team member. This is required for Asset Maintenance creation.");return}if(window.confirm(`Are you sure you want to create maintenance schedules for ${n.length} asset(s)?`)){u(!0);try{const U=y.filter(V=>n.includes(V.name)).map(V=>({name:V.name,custom_manufacturer:V.custom_manufacturer,custom_model:V.custom_model})),re={assets:U,start_date:o.start_date,end_date:o.end_date,maintenance_team:o.maintenance_team||void 0,assign_to:o.assign_to||void 0,maintenance_manager:o.maintenance_manager||void 0,periodicity:o.periodicity,maintenance_type:o.maintenance_type,no_of_pms:o.no_of_pms||void 0,pm_for:o.pm_for||void 0,hospital:a.company,modality:a.custom_modality,manufacturer:a.custom_manufacturer,model:a.custom_model,department:o.department||a.department||void 0};console.log("=== DEBUG: Selected Asset Details ===",U),console.log("=== DEBUG: bulkData ===",re);const X=yield wb.createBulkMaintenanceSchedules(re);T({show:!0,document:X.document,count:X.created||n.length,type:"pm_schedule"}),i([]),l({start_date:"",end_date:"",maintenance_team:"",assign_to:"",pm_for:"",maintenance_manager:"",periodicity:"Monthly",maintenance_type:"Preventive",no_of_pms:"",department:""})}catch(U){console.error("Error creating schedules:",U);const re=U instanceof Error?U.message:"Unknown error";alert(`Failed to create maintenance schedules:
|
||
|
||
${re}`)}finally{u(!1)}}}),Y=ne(),q=Object.values(a).some(H=>H);return t.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[t.jsxs("div",{className:"mb-6 flex items-center gap-4",children:[t.jsxs("button",{onClick:()=>r("/ppm-planner"),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-2",children:[t.jsx(ia,{}),t.jsx("span",{children:"Back to PPM Planner"})]}),t.jsx("h1",{className:"text-3xl font-bold text-gray-800 dark:text-white",children:"PPM Planner - Bulk Schedule Generator"})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6 mb-6",children:[t.jsxs("h2",{className:"text-xl font-semibold mb-4 flex items-center gap-2 text-gray-800 dark:text-white",children:[t.jsx(ds,{})," Filter Assets"]}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[t.jsx("div",{children:t.jsx(Je,{label:"Hospital/Company *",doctype:"Company",value:a.company||"",onChange:H=>G("company",H),placeholder:"Select a hospital/company"})}),t.jsx("div",{children:t.jsx(Je,{label:"Modality",doctype:"Modality",value:a.custom_modality||"",onChange:H=>G("custom_modality",H),placeholder:"Leave empty for all modalities"})}),t.jsx("div",{children:t.jsx(Je,{label:"Manufacturer",doctype:"Manufacturer",value:a.custom_manufacturer||"",onChange:H=>G("custom_manufacturer",H),placeholder:"Leave empty for all manufacturers"})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"Device Status"}),t.jsxs("select",{value:a.custom_device_status||"",onChange:H=>G("custom_device_status",H.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500",children:[t.jsx("option",{value:"",children:"All Statuses"}),t.jsx("option",{value:"Active",children:"Active"}),t.jsx("option",{value:"Inactive",children:"Inactive"}),t.jsx("option",{value:"Under Maintenance",children:"Under Maintenance"}),t.jsx("option",{value:"Decommissioned",children:"Decommissioned"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"Model"}),t.jsxs("select",{value:a.custom_model||"",onChange:H=>G("custom_model",H.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500",children:[t.jsx("option",{value:"",children:"Select Model (optional)"}),w.models.map(H=>t.jsx("option",{value:H,children:H},H))]})]}),t.jsx("div",{children:t.jsx(Je,{label:"Department",doctype:"Department",value:a.department||"",onChange:H=>G("department",H),placeholder:"Select department (optional)"})})]}),t.jsxs("div",{className:"mt-4 flex gap-3",children:[t.jsx("button",{onClick:z,disabled:h,className:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:h?t.jsxs(t.Fragment,{children:[t.jsx(tr,{className:"animate-spin"}),"Loading..."]}):t.jsxs(t.Fragment,{children:[t.jsx(za,{}),"Fetch Assets"]})}),q&&t.jsx("button",{onClick:()=>{s({}),b([]),i([])},className:"bg-gray-600 hover:bg-gray-700 text-white px-6 py-2 rounded-lg",children:"Clear Filters"})]})]}),y.length>0&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6 mb-6",children:[t.jsxs("div",{className:"flex justify-between items-center mb-4",children:[t.jsxs("h2",{className:"text-xl font-semibold text-gray-800 dark:text-white",children:["Select Assets (",n.length," of ",y.length," selected)"]}),t.jsxs("div",{className:"flex gap-3 items-center",children:[t.jsxs("div",{className:"relative",children:[t.jsx(za,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"}),t.jsx("input",{type:"text",placeholder:"Search assets...",value:N,onChange:H=>C(H.target.value),className:"pl-10 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),t.jsx("button",{onClick:ee,className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 px-4 py-2 border border-blue-600 dark:border-blue-400 rounded-lg",children:n.length===Y.length&&Y.length>0?"Deselect All":"Select All"})]})]}),t.jsx("div",{className:"max-h-96 overflow-y-auto border border-gray-200 dark:border-gray-700 rounded-lg",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 sticky top-0",children:t.jsxs("tr",{children:[t.jsx("th",{className:"text-left p-3 text-sm font-medium text-gray-700 dark:text-gray-300",children:t.jsx("input",{type:"checkbox",checked:n.length===Y.length&&Y.length>0,onChange:ee,className:"rounded"})}),t.jsx("th",{className:"text-left p-3 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Asset Name"}),t.jsx("th",{className:"text-left p-3 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Modality"}),t.jsx("th",{className:"text-left p-3 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Manufacturer"}),t.jsx("th",{className:"text-left p-3 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Model"}),t.jsx("th",{className:"text-left p-3 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Status"})]})}),t.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:Y.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"p-6 text-center text-gray-500 dark:text-gray-400",children:"No assets match your search criteria"})}):Y.map(H=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors ${n.includes(H.name)?"bg-blue-50 dark:bg-blue-900/20":""}`,children:[t.jsx("td",{className:"p-3",children:t.jsx("input",{type:"checkbox",checked:n.includes(H.name),onChange:()=>ae(H.name),className:"rounded"})}),t.jsx("td",{className:"p-3 text-sm text-gray-900 dark:text-white font-medium",children:H.asset_name}),t.jsx("td",{className:"p-3 text-sm text-gray-700 dark:text-gray-300",children:H.custom_modality||"-"}),t.jsx("td",{className:"p-3 text-sm text-gray-700 dark:text-gray-300",children:H.custom_manufacturer||"-"}),t.jsx("td",{className:"p-3 text-sm text-gray-700 dark:text-gray-300",children:H.custom_model||"-"}),t.jsx("td",{className:"p-3 text-sm",children:t.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${H.custom_device_status==="Active"?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":H.custom_device_status==="Inactive"?"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400":"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}`,children:H.custom_device_status||"-"})})]},H.name))})]})})]}),n.length>0&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6 mb-6",children:[t.jsxs("h2",{className:"text-xl font-semibold mb-4 flex items-center gap-2 text-gray-800 dark:text-white",children:[t.jsx(sv,{})," Schedule Configuration"]}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"PPM Name *"}),t.jsx("input",{type:"text",value:o.pm_for,onChange:H=>l(U=>je(se({},U),{pm_for:H.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Enter PM Name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"First PPM Date *"}),t.jsx("input",{type:"date",value:o.start_date,onChange:H=>l(U=>je(se({},U),{start_date:H.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"Periodicity *"}),t.jsxs("select",{value:o.periodicity,onChange:H=>l(U=>je(se({},U),{periodicity:H.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500",children:[t.jsx("option",{value:"Daily",children:"Daily"}),t.jsx("option",{value:"Weekly",children:"Weekly"}),t.jsx("option",{value:"Monthly",children:"Monthly"}),t.jsx("option",{value:"Quarterly",children:"Quarterly"}),t.jsx("option",{value:"Half-yearly",children:"Half-yearly"}),t.jsx("option",{value:"Yearly",children:"Yearly"}),t.jsx("option",{value:"2 Yearly",children:"2 Yearly"}),t.jsx("option",{value:"3 Yearly",children:"3 Yearly"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"Maintenance Type"}),t.jsxs("select",{value:o.maintenance_type,onChange:H=>l(U=>je(se({},U),{maintenance_type:H.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500",children:[t.jsx("option",{value:"Preventive",children:"Preventive"}),t.jsx("option",{value:"Corrective",children:"Corrective"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"No. of PMs"}),t.jsx("input",{type:"number",value:o.no_of_pms,onChange:H=>l(U=>je(se({},U),{no_of_pms:H.target.value})),min:"1",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Enter number of PMs"}),t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"End date will be auto-calculated"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"Last PPM Date *"}),t.jsx("input",{type:"date",value:o.end_date,onChange:H=>l(U=>je(se({},U),{end_date:H.target.value})),min:o.start_date,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0})]}),t.jsxs("div",{children:[t.jsx(Je,{label:"Maintenance Team",doctype:"Asset Maintenance Team",value:o.maintenance_team,onChange:H=>l(U=>je(se({},U),{maintenance_team:H}))}),o.maintenance_manager&&t.jsxs("div",{className:"mt-2 p-2 bg-blue-50 dark:bg-blue-900/20 rounded text-xs text-gray-600 dark:text-gray-400",children:[t.jsx("span",{className:"font-medium",children:"Maintenance Manager:"})," ",o.maintenance_manager]})]}),t.jsxs("div",{children:[t.jsx(Je,{label:"Assign To *",doctype:"User",value:o.assign_to,onChange:H=>l(U=>je(se({},U),{assign_to:H})),placeholder:o.maintenance_team?"Select user (auto-selected if only one team member)":"Select user to assign tasks"}),t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"Required for Asset Maintenance creation"}),o.assign_to&&t.jsxs("div",{className:"mt-1 p-2 bg-green-50 dark:bg-green-900/20 rounded text-xs text-gray-600 dark:text-gray-400",children:[t.jsx("span",{className:"font-medium",children:"Assigned To:"})," ",o.assign_to]})]}),t.jsx("div",{children:t.jsx(Je,{label:"Department",doctype:"Department",value:o.department,onChange:H=>l(U=>je(se({},U),{department:H})),placeholder:"Select department (optional)"})})]}),t.jsx("button",{onClick:te,disabled:c||!o.start_date||!o.end_date||!o.pm_for||!o.assign_to,className:"mt-6 bg-green-600 hover:bg-green-700 text-white px-6 py-3 rounded-lg flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed font-medium",children:c?t.jsxs(t.Fragment,{children:[t.jsx(tr,{className:"animate-spin"}),"Creating Schedules..."]}):t.jsxs(t.Fragment,{children:[t.jsx(Qt,{}),"Generate Maintenance Schedules (",n.length," asset",n.length!==1?"s":"",")"]})})]}),y.length===0&&!h&&!(O!=null&&O.show)&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-12 text-center",children:[t.jsx(ds,{className:"mx-auto text-4xl text-gray-400 dark:text-gray-600 mb-4"}),t.jsx("h3",{className:"text-lg font-semibold text-gray-700 dark:text-gray-300 mb-2",children:"No Assets Loaded"}),t.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:'Use the filters above to search for assets, then click "Fetch Assets" to load them.'}),t.jsx("p",{className:"text-sm text-blue-600 dark:text-blue-400",children:"Note: Only submitted assets without existing maintenance schedules will be shown."})]}),(O==null?void 0:O.show)&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl max-w-lg w-full p-6",children:[t.jsxs("div",{className:"text-center mb-6",children:[t.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900/30 rounded-full flex items-center justify-center mx-auto mb-4",children:t.jsx(Qt,{className:"text-green-600 dark:text-green-400 text-3xl"})}),t.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-2",children:"Schedules Created Successfully!"}),t.jsxs("p",{className:"text-gray-600 dark:text-gray-400",children:[O.count," maintenance schedule",O.count!==1?"s":""," have been created."]})]}),t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 rounded-lg p-4 mb-6",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"What was created:"}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Document:"}),t.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-400",children:O.document})]}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["A PM Schedule Generator document has been created with ",O.count," asset(s). Frappe will automatically create Asset Maintenance Logs when the document is submitted. You can view and manage it in the PPM Planner section."]})]})]}),t.jsxs("div",{className:"flex flex-col gap-3",children:[O.document&&t.jsxs("button",{onClick:()=>{r(`/ppm-planner/${O.document}`),T(null)},className:"w-full bg-blue-600 hover:bg-blue-700 text-white px-4 py-3 rounded-lg font-medium text-center flex items-center justify-center gap-2",children:[t.jsx(sv,{}),"View PPM Planner"]}),t.jsxs("button",{onClick:()=>r("/maintenance-calendar"),className:"w-full bg-purple-600 hover:bg-purple-700 text-white px-4 py-3 rounded-lg font-medium flex items-center justify-center gap-2",children:[t.jsx(sv,{}),"View Calendar"]}),t.jsx("button",{onClick:()=>T(null),className:"w-full bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 px-4 py-3 rounded-lg font-medium",children:"Create More Schedules"})]})]})})]})};function ES(e={},r=20,a=0,s="creation desc",n={}){const[i,o]=p.useState([]),[l,c]=p.useState(0),[u,h]=p.useState(!1),[f,y]=p.useState(!0),[b,w]=p.useState(null),[v,k]=p.useState(0),S=JSON.stringify(e),N=JSON.stringify(n);p.useEffect(()=>{let O=!1;const T=S,P=N,E=r,R=a,z=s;return J(null,null,function*(){try{y(!0),w(null);let ae={},ee={};try{ae=T?JSON.parse(T):{}}catch(Y){ae={}}try{ee=P?JSON.parse(P):{}}catch(Y){ee={}}const ne=se(se({},ae),ee),te=yield At.apiCall("/api/method/asset_lite.api.ppm_generator_api.get_pm_schedules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filters:JSON.stringify(ne),limit:E,offset:R,order_by:z,include_child_tables:!0,fields:JSON.stringify(["name","pm_for","hospital","modality","periodicity","start_date","end_date","due_date"])})});if(!O){const Y=(te==null?void 0:te.message)||te;if(Y&&Y.pm_schedules){const q=Y.pm_schedules||[];if(console.log("[usePMSchedules] Loaded",q.length,"PM Schedules"),q.length>0){const H=q[0];console.log("[usePMSchedules] 🔍 FIRST SCHEDULE FIELDS:",{name:H.name,pm_for:H.pm_for,"pm_for (bracket)":H.pm_for,allKeys:Object.keys(H),allKeysList:Object.keys(H).join(", "),fullObject:H})}o(q),c(Y.total_count||0),h(Y.has_more||!1)}else console.warn("[usePMSchedules] No pm_schedules in response:",te),o([]),c(0),h(!1)}}catch(ae){O||(console.error("Error fetching PM Schedules:",ae),w(ae instanceof Error?ae.message:"Failed to fetch PM Schedules"),o([]),c(0))}finally{O||y(!1)}}),()=>{O=!0}},[S,N,r,a,s,v]);const C=p.useCallback(()=>{k(O=>O+1)},[]);return{pmSchedules:i,totalCount:l,hasMore:u,loading:f,error:b,refetch:C}}function $ne(e){const[r,a]=p.useState(null),[s,n]=p.useState(!0),[i,o]=p.useState(null),l=p.useCallback(()=>J(null,null,function*(){if(!e){a(null),n(!1);return}n(!0),o(null);try{const c=yield At.apiCall("/api/method/asset_lite.api.ppm_generator_api.get_pm_schedule_details",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pm_schedule_name:e})});if(console.log("[usePMScheduleDetails] API Response:",c),c&&c.name&&!c.error)console.log("[usePMScheduleDetails] Setting PM Schedule:",c),a(c);else{const u=(c==null?void 0:c.error)||"PM Schedule not found";console.warn("[usePMScheduleDetails] Error or not found:",u),o(u),a(null)}}catch(c){console.error("Error fetching PM Schedule details:",c),o(c instanceof Error?c.message:"Failed to fetch PM Schedule"),a(null)}finally{n(!1)}}),[e]);return p.useEffect(()=>{l()},[l]),{pmSchedule:r,loading:s,error:i,refetch:l}}function CL(){const[e,r]=p.useState(!1);return{createPMSchedule:h=>J(null,null,function*(){r(!0);try{const f=yield At.apiCall("/api/method/asset_lite.api.ppm_generator_api.create_pm_schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pm_schedule_data:JSON.stringify(h)})});if(f!=null&&f.success)return f.pm_schedule;throw new Error((f==null?void 0:f.error)||"Failed to create PM Schedule")}finally{r(!1)}}),updatePMSchedule:(h,f)=>J(null,null,function*(){r(!0);try{const y=yield At.apiCall("/api/method/asset_lite.api.ppm_generator_api.update_pm_schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pm_schedule_name:h,pm_schedule_data:JSON.stringify(f)})});if(y!=null&&y.success)return y.pm_schedule;throw new Error((y==null?void 0:y.error)||"Failed to update PM Schedule")}finally{r(!1)}}),deletePMSchedule:h=>J(null,null,function*(){r(!0);try{const f=yield At.apiCall("/api/method/asset_lite.api.ppm_generator_api.delete_pm_schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pm_schedule_name:h})});if(!(f!=null&&f.success))throw new Error((f==null?void 0:f.error)||"Failed to delete PM Schedule")}finally{r(!1)}}),submitPMSchedule:h=>J(null,null,function*(){r(!0);try{const f=yield At.apiCall("/api/method/asset_lite.api.ppm_generator_api.submit_pm_schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pm_schedule_name:h})});if(f!=null&&f.success)return f.pm_schedule;throw new Error((f==null?void 0:f.error)||"Failed to submit PM Schedule")}finally{r(!1)}}),cancelPMSchedule:h=>J(null,null,function*(){r(!0);try{const f=yield At.apiCall("/api/method/asset_lite.api.ppm_generator_api.cancel_pm_schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pm_schedule_name:h})});if(f!=null&&f.success)return f.pm_schedule;throw new Error((f==null?void 0:f.error)||"Failed to cancel PM Schedule")}finally{r(!1)}}),addMaintenanceEntry:(h,f)=>J(null,null,function*(){r(!0);try{const y=yield At.apiCall("/api/method/asset_lite.api.ppm_generator_api.add_maintenance_entry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pm_schedule_name:h,entry_data:JSON.stringify(f)})});if(y!=null&&y.success)return y.maintenance_entries;throw new Error((y==null?void 0:y.error)||"Failed to add maintenance entry")}finally{r(!1)}}),removeMaintenanceEntry:(h,f)=>J(null,null,function*(){r(!0);try{const y=yield At.apiCall("/api/method/asset_lite.api.ppm_generator_api.remove_maintenance_entry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pm_schedule_name:h,entry_name:f})});if(y!=null&&y.success)return y.maintenance_entries;throw new Error((y==null?void 0:y.error)||"Failed to remove maintenance entry")}finally{r(!1)}}),updateMaintenanceEntry:(h,f,y)=>J(null,null,function*(){r(!0);try{const b=yield At.apiCall("/api/method/asset_lite.api.ppm_generator_api.update_maintenance_entry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pm_schedule_name:h,entry_name:f,entry_data:JSON.stringify(y)})});if(b!=null&&b.success)return b.maintenance_entries;throw new Error((b==null?void 0:b.error)||"Failed to update maintenance entry")}finally{r(!1)}}),loading:e}}const Une=({isOpen:e,onClose:r,selectedCount:a,totalCount:s,pageCount:n,onExport:i,isExporting:o,exportColumns:l})=>{const{t:c}=sr(),[u,h]=p.useState(a>0?"selected":"all_with_filters"),[f,y]=p.useState("csv"),[b,w]=p.useState(l.filter(N=>N.default).map(N=>N.key));p.useEffect(()=>{a>0?h("selected"):h("all_with_filters")},[a]);const v=N=>{w(C=>C.includes(N)?C.filter(O=>O!==N):[...C,N])},k=()=>{w(l.map(N=>N.key))},S=()=>{w(l.filter(N=>N.default).map(N=>N.key))};return e?t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] overflow-hidden animate-scale-in",children:[t.jsx("div",{className:"bg-gradient-to-r from-green-500 to-green-600 px-6 py-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Sa,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:c("ppmPlanner.export.title")})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:o,children:t.jsx(ht,{size:20})})]})}),t.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-180px)]",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:c("ppmPlanner.export.selectData")}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${u==="selected"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"} ${a===0?"opacity-50 cursor-not-allowed":""}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"selected",checked:u==="selected",onChange:()=>h("selected"),disabled:a===0,className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("ppmPlanner.export.selectedRows")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("ppmPlanner.export.selectedCount",{count:a})})]}),a>0&&t.jsxs("span",{className:"bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300 px-2 py-1 rounded text-xs font-medium",children:[a," ",c("common.selected")]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${u==="all_on_page"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"all_on_page",checked:u==="all_on_page",onChange:()=>h("all_on_page"),className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("ppmPlanner.export.currentPage")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("ppmPlanner.export.currentPageCount",{count:n})})]}),t.jsxs("span",{className:"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300 px-2 py-1 rounded text-xs font-medium",children:[n," ",c("common.rows")]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${u==="all_with_filters"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"all_with_filters",checked:u==="all_with_filters",onChange:()=>h("all_with_filters"),className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("ppmPlanner.export.allWithFilters")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("ppmPlanner.export.allWithFiltersCount",{count:s})})]}),t.jsxs("span",{className:"bg-purple-100 dark:bg-purple-900/40 text-purple-700 dark:text-purple-300 px-2 py-1 rounded text-xs font-medium",children:[s," ",c("common.total")]})]})]})]}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:c("listPages.exportFormat")}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${f==="csv"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"format",value:"csv",checked:f==="csv",onChange:()=>y("csv"),className:"text-green-600 focus:ring-green-500"}),t.jsx(ic,{className:"text-green-600 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("listPages.csv")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:c("ppmPlanner.export.csvDesc")})]})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${f==="excel"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"format",value:"excel",checked:f==="excel",onChange:()=>y("excel"),className:"text-green-600 focus:ring-green-500"}),t.jsx(oc,{className:"text-green-700 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("listPages.excel")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:c("ppmPlanner.export.excelDesc")})]})]})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:c("ppmPlanner.export.columnsToExport")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:k,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:c("ppmPlanner.export.selectAll")}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{onClick:S,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:c("ppmPlanner.export.resetToDefault")})]})]}),t.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2 max-h-48 overflow-y-auto p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg",children:l.map(N=>t.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${b.includes(N.key)?"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300":"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-400"}`,children:[t.jsx("input",{type:"checkbox",checked:b.includes(N.key),onChange:()=>v(N.key),className:"rounded text-green-600 focus:ring-green-500"}),t.jsx("span",{className:"text-sm truncate",children:N.label})]},N.key))}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:c("ppmPlanner.export.columnsSelected",{count:b.length})})]})]}),t.jsxs("div",{className:"px-6 py-4 bg-gray-50 dark:bg-gray-900/50 border-t border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[u==="selected"&&c("ppmPlanner.export.exportingSelected",{count:a}),u==="all_on_page"&&c("ppmPlanner.export.exportingPage",{count:n}),u==="all_with_filters"&&c("ppmPlanner.export.exportingAll",{count:s})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{onClick:r,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",disabled:o,children:c("common.cancel")}),t.jsx("button",{onClick:()=>i(u,f,b),disabled:b.length===0||o,className:"px-4 py-2 text-sm font-medium text-white bg-green-600 hover:bg-green-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:o?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),c("ppmPlanner.export.exporting")]}):t.jsxs(t.Fragment,{children:[t.jsx(qc,{}),c("ppmPlanner.export.exportButton")]})})]})]})]})}):null},Bne=({isOpen:e,onClose:r,selectedItems:a,onPrint:s,isPrinting:n})=>{const{t:i}=sr(),[o,l]=p.useState(""),[c,u]=p.useState(!0),[h,f]=p.useState(""),[y,b]=p.useState("A4"),[w,v]=p.useState([]),[k,S]=p.useState([]),[N,C]=p.useState(!1);p.useEffect(()=>{e&&(O(),T())},[e]);const O=()=>J(null,null,function*(){C(!0);try{const z=((yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Print Format",filters:{doc_type:"PM Schedule Generator",disabled:0},fields:["name"],limit_page_length:0})})).json()).message||[]).map(G=>G.name);v(z),z.length>0&&!o&&l(z[0])}catch(E){console.error("Error fetching print formats:",E)}finally{C(!1)}}),T=()=>J(null,null,function*(){try{const z=((yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Letter Head",filters:{disabled:0},fields:["name"],limit_page_length:0})})).json()).message||[]).map(G=>G.name);S(z),z.length>0&&!h&&f(z[0])}catch(E){console.error("Error fetching letterheads:",E)}}),P=()=>{if(!o){alert("Please select a print format");return}s(o,h,!c,y)};return e?t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-lg w-full max-h-[90vh] overflow-hidden animate-scale-in",children:[t.jsx("div",{className:"bg-gradient-to-r from-purple-500 to-purple-600 px-6 py-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(yl,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:"Print PM Schedules"})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:n,children:t.jsx(ht,{size:20})})]})}),t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"mb-6 p-4 bg-purple-50 dark:bg-purple-900/20 rounded-lg border border-purple-200 dark:border-purple-700",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ra,{className:"text-purple-600 dark:text-purple-400"}),t.jsxs("span",{className:"font-medium text-purple-800 dark:text-purple-300",children:[a.length," schedule",a.length!==1?"s":""," selected for printing"]})]}),t.jsxs("div",{className:"mt-2 text-sm text-purple-600 dark:text-purple-400 max-h-20 overflow-y-auto",children:[a.slice(0,5).join(", "),a.length>5&&` and ${a.length-5} more...`]})]}),t.jsxs("div",{className:"mb-4",children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Print Format ",t.jsx("span",{className:"text-red-500",children:"*"})]}),N?t.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-purple-500"}),"Loading formats..."]}):w.length===0?t.jsx("div",{className:"text-amber-600 dark:text-amber-400 text-sm p-3 bg-amber-50 dark:bg-amber-900/20 rounded-lg",children:"No print formats found for PM Schedule Generator. Please create one in ERPNext."}):t.jsxs("select",{value:o,onChange:E=>l(E.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:"Select Print Format"}),w.map(E=>t.jsx("option",{value:E,children:E},E))]})]}),t.jsx("div",{className:"mb-4",children:t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:c,onChange:E=>u(E.target.checked),className:"rounded text-purple-600 focus:ring-purple-500"}),t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Use Letterhead"})]})}),c&&t.jsxs("div",{className:"mb-4",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Letterhead"}),t.jsxs("select",{value:h,onChange:E=>f(E.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:"Default Letterhead"}),k.map(E=>t.jsx("option",{value:E,children:E},E))]})]}),t.jsxs("div",{className:"mb-6",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Page Size"}),t.jsxs("select",{value:y,onChange:E=>b(E.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"A4",children:"A4"}),t.jsx("option",{value:"Letter",children:"Letter"}),t.jsx("option",{value:"A3",children:"A3"}),t.jsx("option",{value:"A5",children:"A5"}),t.jsx("option",{value:"Legal",children:"Legal"})]})]})]}),t.jsxs("div",{className:"px-6 py-4 bg-gray-50 dark:bg-gray-900/50 border-t border-gray-200 dark:border-gray-700 flex justify-end gap-3",children:[t.jsx("button",{onClick:r,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",disabled:n,children:"Cancel"}),t.jsx("button",{onClick:P,disabled:!o||n||a.length===0,className:"px-4 py-2 text-sm font-medium text-white bg-purple-600 hover:bg-purple-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:n?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Preparing..."]}):t.jsxs(t.Fragment,{children:[t.jsx(yl,{}),"Print ",a.length," Schedule",a.length!==1?"s":""]})})]})]})}):null},Wne=()=>{const{t:e}=sr(),r=hr(),[a,s]=_a(),n=p.useRef(s),[i,o]=p.useState(0);p.useEffect(()=>{n.current=s},[s]);const[l,c]=p.useState(""),[u,h]=p.useState(null),[f,y]=p.useState(null),b=p.useRef(null),[w,v]=p.useState(!1),[k,S]=p.useState(()=>a.get("date_filter_by")||""),[N,C]=p.useState(()=>a.get("date_start")||""),[O,T]=p.useState(()=>a.get("date_end")||""),[P,E]=p.useState(""),[R,z]=p.useState(""),[G,ae]=p.useState(""),[ee,ne]=p.useState(""),te=["creation desc","creation asc","modified desc","modified asc","name asc","name desc","pm_for asc","pm_for desc"],[Y,q]=p.useState(()=>a.get("sort_by")||"creation desc"),[H,U]=p.useState(new Set),[re,X]=p.useState(!1),[V,I]=p.useState(!1),[B,Q]=p.useState(!1),[ie,me]=p.useState(!1),he=20,de=[{key:"name",label:e("commonFields.pmId"),default:!0},{key:"pm_for",label:e("commonFields.name"),default:!0},{key:"hospital",label:e("commonFields.hospital"),default:!0},{key:"modality",label:e("commonFields.modality"),default:!0},{key:"manufacturer",label:e("commonFields.manufacturer"),default:!0},{key:"periodicity",label:e("ppm.periodicity"),default:!0},{key:"maintenance_team",label:"Maintenance Team",default:!1},{key:"docstatus",label:e("commonFields.status"),default:!0},{key:"creation",label:e("commonFields.createdOn"),default:!1},{key:"modified",label:e("commonFields.modifiedOn"),default:!1},{key:"owner",label:e("commonFields.createdBy"),default:!1},{key:"modified_by",label:e("commonFields.modifiedBy"),default:!1}],xe=p.useMemo(()=>{const Ve={};return P&&(Ve.hospital=P),R&&(Ve.modality=R),G&&(Ve.manufacturer=G),ee&&(Ve.periodicity=ee),Object.assign(Ve,kl(k,N,O)),Ve},[P,R,G,ee,k,N,O]),ge=te.includes(Y)?Y:"creation desc",{pmSchedules:be,totalCount:K,hasMore:ye,loading:Z,error:M,refetch:we}=ES(xe,he,i*he,ge),{deletePMSchedule:pe,loading:le}=CL();p.useEffect(()=>{const Ve=lt=>{b.current&&!b.current.contains(lt.target)&&y(null)};return f&&document.addEventListener("mousedown",Ve),()=>{document.removeEventListener("mousedown",Ve)}},[f]),p.useEffect(()=>{U(new Set)},[P,R,G,ee,k,N,O,l,i]);const Fe=be.filter(Ve=>{var st,Mt,Ot,Pt,zt,Tt;if(!l)return!0;const lt=l.toLowerCase();return((st=Ve.name)==null?void 0:st.toLowerCase().includes(lt))||((Mt=Ve.pm_for)==null?void 0:Mt.toLowerCase().includes(lt))||((Ot=Ve.hospital)==null?void 0:Ot.toLowerCase().includes(lt))||((Pt=Ve.modality)==null?void 0:Pt.toLowerCase().includes(lt))||((zt=Ve.manufacturer)==null?void 0:zt.toLowerCase().includes(lt))||((Tt=Ve.maintenance_team)==null?void 0:Tt.toLowerCase().includes(lt))}),ze=()=>{H.size===Fe.length?U(new Set):U(new Set(Fe.map(Ve=>Ve.name)))},Re=Fe.length>0&&H.size===Fe.length,De=H.size>0&&H.size<Fe.length,Et=Ve=>{U(lt=>{const st=new Set(lt);return st.has(Ve)?st.delete(Ve):st.add(Ve),st})},jt=p.useCallback(()=>J(null,null,function*(){const Ve=[];let lt=0;const st=100;let Mt=!0;const Ot=xa(xe);for(;Mt;)try{const Tt=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"PM Schedule Generator",filters:Ot.length>0?Ot:{},fields:["*"],limit_start:lt*st,limit_page_length:st,order_by:"creation desc"})})).json()).message||[];Ve.push(...Tt),Tt.length<st?Mt=!1:lt++,lt>100&&(console.warn("Export safety limit reached"),Mt=!1)}catch(Pt){throw console.error("Error fetching schedules for export:",Pt),Pt}return Ve}),[xe]),Ie=(Ve,lt,st)=>J(null,null,function*(){I(!0);try{let Mt=[];switch(Ve){case"selected":Mt=Fe.filter(zt=>H.has(zt.name));break;case"all_on_page":Mt=Fe;break;case"all_with_filters":Mt=yield jt();break}if(Mt.length===0){alert("No data to export");return}const Ot=Mt.map(zt=>{const Tt=se({},zt);if(st.includes("docstatus")){const Gt=nr(zt);Tt.docstatus=Gt===1?"Submitted":Gt===2?"Cancelled":"Draft"}return Tt}),Pt=st.map(zt=>{const Tt=de.find(Gt=>Gt.key===zt);return(Tt==null?void 0:Tt.label)||zt});if(lt==="csv"){const zt=[Pt.join(","),...Ot.map(kt=>st.map(Yt=>{let Ae=kt[Yt]||"";return typeof Ae=="string"&&(Ae.includes(",")||Ae.includes('"')||Ae.includes(`
|
||
`))&&(Ae=`"${Ae.replace(/"/g,'""')}"`),Ae}).join(","))].join(`
|
||
`),Tt=new Blob(["\uFEFF"+zt],{type:"text/csv;charset=utf-8;"}),Gt=URL.createObjectURL(Tt),Ye=document.createElement("a");Ye.href=Gt,Ye.download=`ppm_schedules_export_${new Date().toISOString().split("T")[0]}.csv`,Ye.click(),URL.revokeObjectURL(Gt)}else if(lt==="excel"){const zt=[Pt,...Ot.map(Ye=>st.map(kt=>Ye[kt]||""))],Tt=Na.aoa_to_sheet(zt),Gt=Na.book_new();Na.book_append_sheet(Gt,Tt,"PPM Schedules"),lc(Gt,`ppm_schedules_export_${new Date().toISOString().split("T")[0]}.xlsx`)}X(!1),U(new Set)}catch(Mt){console.error("Export failed:",Mt),alert(`Export failed: ${Mt instanceof Error?Mt.message:"Unknown error"}`)}finally{I(!1)}}),$e=(Ve,lt,st,Mt)=>{me(!0);try{const Ot=Array.from(H);if(Ot.length===0){alert("No schedules selected for printing");return}const Pt=window.location.origin,zt=new URLSearchParams;zt.append("doctype","PM Schedule Generator"),zt.append("name",JSON.stringify(Ot)),zt.append("format",Ve),zt.append("no_letterhead",st?"1":"0"),lt&&!st&&zt.append("letterhead",lt),zt.append("options",JSON.stringify({"page-size":Mt}));const Tt=`${Pt}/api/method/frappe.utils.print_format.download_multi_pdf?${zt.toString()}`;window.open(Tt,"_blank"),Q(!1)}catch(Ot){console.error("Print failed:",Ot),alert(`Print failed: ${Ot instanceof Error?Ot.message:"Unknown error"}`)}finally{me(!1)}},Qe=()=>{r("/ppm-planner/new")},at=Ve=>{r(`/ppm-planner/${Ve}`)},Ct=Ve=>{r(`/ppm-planner/${Ve}`)},vt=Ve=>J(null,null,function*(){try{yield pe(Ve),we(),h(null)}catch(lt){console.error("Error deleting PM Schedule:",lt),alert("Failed to delete PM Schedule")}}),er=()=>{S(""),C(""),T(""),E(""),z(""),ae(""),ne(""),q("creation desc"),o(0)},nr=Ve=>{var lt;return Ve.docstatus!==void 0?Number(Ve.docstatus):((lt=Ve.maintenance_entries)==null?void 0:lt.length)>0?Number(Ve.maintenance_entries[0].docstatus):0},dt=k&&(N||O),He=dt||P||R||G||ee,it=[dt?"date":"",P,R,G,ee].filter(Boolean).length,Ue=Math.ceil(K/he);return t.jsxs("div",{className:"flex flex-col h-screen bg-gray-50 dark:bg-gray-900",children:[t.jsxs("div",{className:"flex-shrink-0 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 px-4 py-3 lg:px-6",children:[t.jsxs("div",{className:"flex justify-between items-center mb-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(rc,{className:"text-blue-600 dark:text-blue-400",size:24}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-xl font-bold text-gray-800 dark:text-white",children:e("sidebar.ppmPlanner")}),t.jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:[e("ppm.manageSchedules"),H.size>0&&t.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",H.size," selected"]})]})]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("button",{onClick:()=>X(!0),className:"px-3 py-1.5 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors flex items-center gap-2 text-sm",disabled:K===0,children:[t.jsx(Sa,{}),t.jsx("span",{children:e("listPages.export")}),H.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:H.size})]}),t.jsxs("button",{onClick:()=>Q(!0),className:"px-3 py-1.5 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors flex items-center gap-2 text-sm disabled:opacity-50 disabled:cursor-not-allowed",disabled:H.size===0,title:H.size===0?"Select schedules to print":`Print ${H.size} selected`,children:[t.jsx(yl,{}),t.jsx("span",{children:"Print"}),H.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:H.size})]}),t.jsxs("button",{onClick:Qe,className:"px-3 py-1.5 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors flex items-center gap-2 text-sm",children:[t.jsx(Rr,{}),t.jsx("span",{children:e("ppm.addPPM")})]})]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("div",{className:"flex-1 relative",children:[t.jsx(za,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400",size:14}),t.jsx("input",{type:"text",placeholder:e("listPages.searchPlaceholder"),value:l,onChange:Ve=>c(Ve.target.value),className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("button",{onClick:()=>v(!w),className:`px-3 py-1.5 border rounded-lg transition-colors flex items-center gap-2 text-sm ${He?"border-blue-500 bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400":"border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:[t.jsx(ds,{}),t.jsx("span",{children:e("listPages.filters")}),it>0&&t.jsx("span",{className:"bg-blue-600 text-white rounded-full w-5 h-5 flex items-center justify-center text-xs",children:it}),w?t.jsx(Ja,{}):t.jsx(Fr,{})]})]}),w&&t.jsxs("div",{className:"mt-3 p-3 bg-gray-50 dark:bg-gray-700/50 rounded-lg border border-gray-200 dark:border-gray-600",children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:e("filters.sortBy")}),t.jsxs("select",{value:Y,onChange:Ve=>{q(Ve.target.value),o(0)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"creation desc",children:e("filters.sortCreationNewest")}),t.jsx("option",{value:"creation asc",children:e("filters.sortCreationOldest")}),t.jsx("option",{value:"modified desc",children:e("filters.sortModifiedNewest")}),t.jsx("option",{value:"modified asc",children:e("filters.sortModifiedOldest")}),t.jsx("option",{value:"name asc",children:e("filters.sortNameAsc")}),t.jsx("option",{value:"name desc",children:e("filters.sortNameDesc")}),t.jsx("option",{value:"pm_for asc",children:e("filters.sortNameAsc")}),t.jsx("option",{value:"pm_for desc",children:e("filters.sortNameDesc")})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:e("filters.filterBy")}),t.jsxs("select",{value:k,onChange:Ve=>{const lt=Ve.target.value;S(lt),o(0)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("filters.filterBy")}),t.jsx("option",{value:"creation",children:e("filters.createdDate")}),t.jsx("option",{value:"modified",children:e("filters.latestModifiedDate")})]})]}),k&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:e("filters.startDate")}),t.jsx("input",{type:"date",value:N,onChange:Ve=>{const lt=Ve.target.value;C(lt),O&<>O&&T(lt),o(0)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:e("filters.endDate")}),t.jsx("input",{type:"date",value:O,onChange:Ve=>{T(Ve.target.value),o(0)},min:N||void 0,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]}),t.jsx("div",{children:t.jsx(Je,{label:e("commonFields.hospital"),doctype:"Company",value:P,onChange:E,placeholder:e("filters.allHospitals"),filters:{domain:"Healthcare"}})}),t.jsx("div",{children:t.jsx(Je,{label:e("commonFields.modality"),doctype:"Modality",value:R,onChange:z,placeholder:e("filters.allModalities"),filters:{}})}),t.jsx("div",{children:t.jsx(Je,{label:e("commonFields.manufacturer"),doctype:"Manufacturer",value:G,onChange:ae,placeholder:e("filters.allManufacturers"),filters:{}})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:e("ppm.periodicity")}),t.jsxs("select",{value:ee,onChange:Ve=>ne(Ve.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("listPages.all")}),t.jsx("option",{value:"Daily",children:"Daily"}),t.jsx("option",{value:"Weekly",children:"Weekly"}),t.jsx("option",{value:"Monthly",children:"Monthly"}),t.jsx("option",{value:"Quarterly",children:"Quarterly"}),t.jsx("option",{value:"Half-yearly",children:"Half-yearly"}),t.jsx("option",{value:"Yearly",children:"Yearly"})]})]})]}),He&&t.jsx("div",{className:"mt-4 flex justify-end",children:t.jsxs("button",{onClick:er,className:"px-4 py-2 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 flex items-center gap-2",children:[t.jsx(ht,{}),e("listPages.clearFilters")]})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto p-4 lg:p-5",children:Z&&i===0?t.jsxs("div",{className:"flex items-center justify-center h-full",children:[t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"}),t.jsx("span",{className:"ml-3 text-gray-600 dark:text-gray-400",children:e("listPages.loading")})]}):M?t.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:t.jsx("p",{className:"text-red-600 dark:text-red-400",children:M})}):Fe.length===0?t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-8 text-center",children:[t.jsx(rc,{className:"mx-auto text-gray-400 mb-4",size:48}),t.jsx("h3",{className:"text-lg font-semibold text-gray-700 dark:text-gray-300 mb-2",children:e("listPages.noResults")}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:e(l||He?"listPages.tryAdjustingFilters":"listPages.getStartedCreateFirst")}),!l&&!He&&t.jsx("button",{onClick:Qe,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors",children:e("ppm.addPPM")})]}):t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden",children:[t.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[t.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left",children:t.jsx("button",{onClick:ze,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:Re?"Deselect all":"Select all",children:Re?t.jsx(Ra,{className:"text-blue-600 dark:text-blue-400",size:18}):De?t.jsxs("div",{className:"relative",children:[t.jsx(Ur,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Ur,{size:18})})}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:e("commonFields.pmId")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:e("commonFields.name")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:e("commonFields.hospital")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:e("commonFields.modality")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:e("commonFields.manufacturer")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:e("ppm.periodicity")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:e("commonFields.status")}),t.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:e("listPages.actions")})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:Fe.map(Ve=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors ${H.has(Ve.name)?"bg-blue-50 dark:bg-blue-900/20":""}`,children:[t.jsx("td",{className:"px-4 py-4",children:t.jsx("button",{onClick:()=>Et(Ve.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:H.has(Ve.name)?t.jsx(Ra,{className:"text-blue-600 dark:text-blue-400",size:18}):t.jsx(Ur,{size:18})})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("button",{onClick:()=>at(Ve.name),className:"text-blue-600 dark:text-blue-400 hover:underline font-medium",children:Ve.name})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:Ve.pm_for||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:Ve.hospital||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:Ve.modality||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:Ve.manufacturer||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:Ve.periodicity||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:(()=>{const lt=nr(Ve);return t.jsx("span",{className:`px-2 py-1 text-xs font-semibold rounded-full ${lt===1?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":lt===0?"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400":"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-400"}`,children:lt===1?"Submitted":lt===2?"Cancelled":"Draft"})})()}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:t.jsxs("div",{className:"relative inline-block",ref:f===Ve.name?b:null,children:[t.jsx("button",{onClick:()=>y(f===Ve.name?null:Ve.name),className:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 p-2",children:t.jsx(jx,{})}),f===Ve.name&&t.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-white dark:bg-gray-700 rounded-lg shadow-lg border border-gray-200 dark:border-gray-600 z-10",children:[t.jsxs("button",{onClick:()=>{at(Ve.name),y(null)},className:"w-full px-4 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-600 flex items-center gap-2",children:[t.jsx(Ps,{})," ",e("listPages.view")]}),t.jsxs("button",{onClick:()=>{Ct(Ve.name),y(null)},className:"w-full px-4 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-600 flex items-center gap-2",children:[t.jsx(qr,{})," ",e("listPages.edit")]}),t.jsxs("button",{onClick:()=>{h(Ve.name),y(null)},className:"w-full px-4 py-2 text-left text-sm text-red-600 dark:text-red-400 hover:bg-gray-100 dark:hover:bg-gray-600 flex items-center gap-2",children:[t.jsx(wr,{})," ",e("listPages.delete")]})]})]})})]},Ve.name))})]}),Ue>1&&t.jsxs("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex items-center justify-between",children:[t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[e("listPages.showing")," ",i*he+1," ",e("listPages.to")," ",Math.min((i+1)*he,K)," ",e("listPages.of")," ",K," ",e("listPages.results")]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>o(Math.max(0,i-1)),disabled:i===0,className:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed text-gray-700 dark:text-gray-300",children:"Previous"}),t.jsx("button",{onClick:()=>o(i+1),disabled:!ye,className:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed text-gray-700 dark:text-gray-300",children:"Next"})]})]})]})}),t.jsx(Une,{isOpen:re,onClose:()=>X(!1),selectedCount:H.size,totalCount:K,pageCount:Fe.length,onExport:Ie,isExporting:V,exportColumns:de}),t.jsx(Bne,{isOpen:B,onClose:()=>Q(!1),selectedItems:Array.from(H),onPrint:$e,isPrinting:ie}),u&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 max-w-md",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:e("confirmations.confirmDelete")}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:e("confirmations.cannotUndo")}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>h(null),className:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300",disabled:le,children:e("common.cancel")}),t.jsx("button",{onClick:()=>vt(u),className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors",disabled:le,children:e(le?"common.deleting":"common.delete")})]})]})}),t.jsx("style",{children:`
|
||
@keyframes scale-in {
|
||
from {
|
||
transform: scale(0.95);
|
||
opacity: 0;
|
||
}
|
||
to {
|
||
transform: scale(1);
|
||
opacity: 1;
|
||
}
|
||
}
|
||
.animate-scale-in {
|
||
animation: scale-in 0.2s ease-out;
|
||
}
|
||
`})]})},Hne=()=>{const{t:e}=sr(),{scheduleName:r}=hs(),a=hr(),{pmSchedule:s,loading:n,error:i,refetch:o}=$ne(r||null),{updatePMSchedule:l,deletePMSchedule:c,submitPMSchedule:u,cancelPMSchedule:h,loading:f}=CL(),{logs:y,refetch:b}=V1({},1e4,0),[w,v]=p.useState(!1),[k,S]=p.useState(!1),[N,C]=p.useState(!1),[O,T]=p.useState(""),[P,E]=p.useState(""),[R,z]=p.useState(!1),[G,ae]=p.useState(!1),[ee,ne]=p.useState(new Set),[te,Y]=p.useState(!1),[q,H]=p.useState(!1),[U,re]=p.useState(new Set),[X,V]=p.useState([]),[I,B]=p.useState([]),[Q,ie]=p.useState([]),[me,he]=p.useState(""),[de,xe]=p.useState({hospital:"",modality:"",device_status:"",start_date:"",end_date:"",maintenance_team:"",maintenance_manager:"",periodicity:"Monthly",assign_to:"",due_date:"",next_pm_date:"",manufacturer:"",model:"",pm_for:"",asset_name:"",no_of_pms:""});p.useEffect(()=>{J(null,null,function*(){try{const it=yield(yield fetch("/api/method/frappe.auth.get_logged_user",{method:"GET",credentials:"include"})).json();it.message&&he(it.message)}catch(He){console.error("Error fetching current user:",He)}})},[]),p.useEffect(()=>{if(r){const dt=localStorage.getItem(`ppm_activity_${r}`);dt&&ie(JSON.parse(dt))}},[r]),p.useEffect(()=>{if(s!=null&&s.maintenance_entries&&y.length>0){const dt=[],He=[];s.maintenance_entries.forEach(it=>{y.filter(Ve=>Ve.asset_name===it.asset).forEach(Ve=>{Ve.workflow_state==="Applied"?He.push(je(se({},Ve),{asset_display_name:it.asset_name||it.asset})):Ve.maintenance_status==="Planned"&&(!Ve.workflow_state||Ve.workflow_state==="Draft")&&dt.push(je(se({},Ve),{asset_display_name:it.asset_name||it.asset}))})}),V(dt),B(He)}},[s,y]),p.useEffect(()=>{if(y.length>0&&(s!=null&&s.maintenance_entries)){const dt=[];if(s.maintenance_entries.forEach(He=>{y.filter(Ue=>Ue.asset_name===He.asset).forEach(Ue=>{const Ve=Ue.maintenance_status==="Planned"&&(!Ue.workflow_state||Ue.workflow_state==="Draft"),lt=Ue.workflow_state==="Applied";(Ve||lt)&&Ue.due_date&&dt.push(Ue.due_date)})}),dt.length>0){const He=dt.sort((it,Ue)=>new Date(it).getTime()-new Date(Ue).getTime())[0];console.log("📅 Pending due dates:",dt),console.log("📅 Earliest (Next PM Date):",He),xe(it=>it.next_pm_date!==He?je(se({},it),{next_pm_date:He}):it)}else console.log("📅 No pending entries found - all completed"),xe(He=>je(se({},He),{next_pm_date:""}))}},[s,y]),p.useEffect(()=>{s&&xe({hospital:s.hospital||"",modality:s.modality||"",device_status:s.device_status||"",start_date:s.start_date||"",end_date:s.end_date||"",maintenance_team:s.maintenance_team||"",maintenance_manager:s.maintenance_manager||"",periodicity:s.periodicity||"Monthly",assign_to:s.assign_to||"",due_date:s.due_date||"",next_pm_date:s.next_pm_date||"",manufacturer:s.manufacturer||"",model:s.model||"",pm_for:s.pm_for||"",asset_name:s.asset_name||"",no_of_pms:s.no_of_pms||""})},[s]),p.useEffect(()=>{if(O&&de.next_pm_date){const dt=new Date(O),He=new Date(de.next_pm_date);z(dt<He)}else z(!1)},[O,de.next_pm_date]);const ge=(dt,He,it)=>{if(!dt||!He||!it)return null;const Ue=parseInt(it,10);if(isNaN(Ue)||Ue<1)return null;const Ve=Ue-1;if(Ve<0)return null;const lt=new Date(dt),st=new Date(lt);switch(He){case"Daily":st.setDate(st.getDate()+Ve);break;case"Weekly":st.setDate(st.getDate()+Ve*7);break;case"Monthly":st.setMonth(st.getMonth()+Ve);break;case"Quarterly":st.setMonth(st.getMonth()+Ve*3);break;case"Half-yearly":st.setMonth(st.getMonth()+Ve*6);break;case"Yearly":st.setFullYear(st.getFullYear()+Ve);break;case"2 Yearly":st.setFullYear(st.getFullYear()+Ve*2);break;case"3 Yearly":st.setFullYear(st.getFullYear()+Ve*3);break;default:return null}const Mt=st.getFullYear(),Ot=String(st.getMonth()+1).padStart(2,"0"),Pt=String(st.getDate()).padStart(2,"0");return`${Mt}-${Ot}-${Pt}`},be=dt=>{const{name:He,value:it}=dt.target;xe(Ue=>{const Ve=je(se({},Ue),{[He]:it});if(He==="start_date"||He==="periodicity"||He==="no_of_pms"){const lt=ge(He==="start_date"?it:Ue.start_date,He==="periodicity"?it:Ue.periodicity,He==="no_of_pms"?it:Ue.no_of_pms);lt&&(Ve.end_date=lt)}return Ve})},K=()=>J(null,null,function*(){if(r)try{yield l(r,de),v(!1),o(),alert("PPM Planner updated successfully")}catch(dt){console.error("Error updating PPM Planner:",dt),alert("Failed to update PPM Planner")}}),ye=()=>J(null,null,function*(){if(r)try{yield c(r),a(-1)}catch(dt){console.error("Error deleting PPM Planner:",dt),alert("Failed to delete PPM Planner")}}),Z=()=>J(null,null,function*(){if(r)try{yield u(r),o(),alert("PPM Planner submitted successfully")}catch(dt){console.error("Error submitting PPM Planner:",dt),alert("Failed to submit PPM Planner")}}),M=()=>J(null,null,function*(){if(r)try{yield h(r),o(),alert("PPM Planner cancelled successfully")}catch(dt){console.error("Error cancelling PPM Planner:",dt),alert("Failed to cancel PPM Planner")}}),we=()=>{if(X.length===0){alert("No planned maintenance entries found to apply.");return}const dt=new Date().toISOString().split("T")[0];T(dt),E(""),ne(new Set(X.map(He=>He.name))),C(!0)},pe=dt=>{ne(He=>{const it=new Set(He);return it.has(dt)?it.delete(dt):it.add(dt),it})},le=()=>{ne(new Set(X.map(dt=>dt.name)))},Fe=()=>{ne(new Set)},ze=()=>J(null,null,function*(){if(!O){alert("Please enter a completion date.");return}if(R&&!P.trim()){alert("Please provide a reason for early completion.");return}if(ee.size===0){alert("Please select at least one entry to complete.");return}ae(!0);try{let dt=0,He=0;const it=[],Ue=X.filter(st=>ee.has(st.name));for(const st of Ue)try{const Mt={maintenance_status:"Completed",workflow_state:"Applied",completion_date:O};R&&P&&(Mt.custom_early_completion_reason=P,Mt.custom_early_completion="Yes");const Pt=yield(yield fetch("/api/method/frappe.client.set_value",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({doctype:"Asset Maintenance Log",name:st.name,fieldname:Mt})})).json();Pt.message?(dt++,it.push(st.name)):(He++,console.error(`Failed to apply ${st.name}:`,Pt))}catch(Mt){He++,console.error(`Error applying ${st.name}:`,Mt)}const lt=[{id:Date.now().toString(),user:me||"Unknown User",timestamp:new Date().toISOString(),action:"Applied",entriesCount:dt,completionDate:O,earlyReason:R?P:void 0,entries:it},...Q];ie(lt),r&&localStorage.setItem(`ppm_activity_${r}`,JSON.stringify(lt)),C(!1),T(""),E(""),ne(new Set),b(),o(),alert(He===0?`Successfully applied ${dt} maintenance entries. They are now pending approval.`:`Applied ${dt} entries. Failed to apply ${He} entries.`)}catch(dt){console.error("Error applying entries:",dt),alert("Failed to apply entries.")}finally{ae(!1)}}),Re=()=>{if(I.length===0){alert("No entries pending approval.");return}re(new Set(I.map(dt=>dt.name))),Y(!0)},De=dt=>{re(He=>{const it=new Set(He);return it.has(dt)?it.delete(dt):it.add(dt),it})},Et=()=>{re(new Set(I.map(dt=>dt.name)))},jt=()=>{re(new Set)},Ie=()=>J(null,null,function*(){if(U.size===0){alert("Please select at least one entry to approve.");return}H(!0);try{let dt=0,He=0;const it=[],Ue=I.filter(st=>U.has(st.name));for(const st of Ue)try{const Ot=yield(yield fetch(`/api/resource/Asset Maintenance Log/${encodeURIComponent(st.name)}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json();if(!Ot.data){console.error(`Failed to get document ${st.name}`),He++;continue}const Pt=je(se({},Ot.data),{workflow_state:"Approved",docstatus:1}),Tt=yield(yield fetch(`/api/resource/Asset Maintenance Log/${encodeURIComponent(st.name)}`,{method:"PUT",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(Pt)})).json();if(Tt.data&&Tt.data.docstatus===1)dt++,it.push(st.name),console.log(`✅ Successfully approved and submitted: ${st.name}`);else{console.log(`Trying alternative submit method for ${st.name}...`);const Gt=yield fetch("/api/method/frappe.desk.form.utils.get_next",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({doctype:"Asset Maintenance Log",name:st.name,workflow_action:"Approve"})}),kt=yield(yield fetch("/api/method/run_doc_method",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({dt:"Asset Maintenance Log",dn:st.name,method:"submit"})})).json();kt.message||!kt.exc?(dt++,it.push(st.name),console.log(`✅ Successfully submitted via run_doc_method: ${st.name}`)):(He++,console.error(`Failed to submit ${st.name}:`,kt))}}catch(Mt){He++,console.error(`Error approving ${st.name}:`,Mt)}const lt=[{id:Date.now().toString(),user:me||"Unknown User",timestamp:new Date().toISOString(),action:"Approved",entriesCount:dt,entries:it},...Q];ie(lt),r&&localStorage.setItem(`ppm_activity_${r}`,JSON.stringify(lt)),Y(!1),re(new Set),setTimeout(()=>{b(),o()},1e3),alert(He===0?`Successfully approved and submitted ${dt} maintenance entries. New planned entries should be created automatically.`:`Approved ${dt} entries. Failed to approve ${He} entries.`)}catch(dt){console.error("Error approving entries:",dt),alert("Failed to approve entries.")}finally{H(!1)}}),$e=dt=>{switch(dt){case"Planned":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400";case"Applied":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400";case"Approved":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}},Qe=dt=>y.filter(it=>it.asset_name===dt).filter(it=>{const Ue=it.maintenance_status==="Planned"&&(!it.workflow_state||it.workflow_state==="Draft"),Ve=it.workflow_state==="Applied";return Ue||Ve}),at=dt=>Qe(dt).length>0,Ct=()=>s!=null&&s.maintenance_entries?s.maintenance_entries.filter(dt=>at(dt.asset)):[];if(n)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(tr,{className:"animate-spin text-blue-600",size:24}),t.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Loading PPM Planner..."})]})});if(i)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:[t.jsx("p",{className:"text-red-600 dark:text-red-400",children:i}),t.jsx("button",{onClick:()=>a(-1),className:"mt-4 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors",children:"Back to List"})]})});if(!s)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4",children:[t.jsx("p",{className:"text-yellow-600 dark:text-yellow-400",children:"PPM Planner not found"}),t.jsx("button",{onClick:()=>a(-1),className:"mt-4 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors",children:"Back to List"})]})});const vt=s.docstatus===0,er=s.docstatus===1;s.docstatus;const nr=Ct();return t.jsxs("div",{className:"flex flex-col h-screen bg-gray-50 dark:bg-gray-900",children:[t.jsxs("div",{className:"flex-shrink-0 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 px-6 py-4",children:[t.jsxs("div",{className:"flex justify-between items-center mb-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>a(-1),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:t.jsx(ia,{className:"text-gray-600 dark:text-gray-400"})}),t.jsx(rc,{className:"text-blue-600 dark:text-blue-400",size:28}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:s.name}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"PPM Planner Details"})]}),t.jsx("span",{className:`ml-4 px-3 py-1 text-sm font-semibold rounded-full ${er?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":vt?"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400":"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-400"}`,children:er?"Submitted":vt?"Draft":"Cancelled"})]}),t.jsxs("div",{className:"flex gap-2",children:[er&&t.jsxs("div",{className:"flex gap-2 mr-4 pr-4 border-r border-gray-300 dark:border-gray-600",children:[X.length>0&&t.jsxs("button",{onClick:we,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors flex items-center gap-2",children:[t.jsx(ao,{}),"Bulk Complete(",X.length,")"]}),I.length>0&&t.jsxs("button",{onClick:Re,className:"px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors flex items-center gap-2",children:[t.jsx(vf,{}),"Approve (",I.length,")"]})]}),vt&&!w&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>v(!0),className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors flex items-center gap-2",children:[t.jsx(qr,{}),"Edit"]}),t.jsxs("button",{onClick:Z,disabled:f,className:"px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50",children:[t.jsx(Qt,{}),"Submit"]}),t.jsxs("button",{onClick:()=>S(!0),disabled:f,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50",children:[t.jsx(wr,{}),"Delete"]})]}),w&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:K,disabled:f,className:"px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50",children:[f?t.jsx(tr,{className:"animate-spin"}):t.jsx(ta,{}),"Save"]}),t.jsx("button",{onClick:()=>{v(!1),xe({hospital:s.hospital||"",modality:s.modality||"",device_status:s.device_status||"",start_date:s.start_date||"",end_date:s.end_date||"",maintenance_team:s.maintenance_team||"",maintenance_manager:s.maintenance_manager||"",periodicity:s.periodicity||"Monthly",assign_to:s.assign_to||"",due_date:s.due_date||"",next_pm_date:s.next_pm_date||"",manufacturer:s.manufacturer||"",model:s.model||"",pm_for:s.pm_for||"",asset_name:s.asset_name||"",no_of_pms:s.no_of_pms||""})},disabled:f,className:"px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg transition-colors disabled:opacity-50",children:"Cancel"})]}),er&&t.jsx("button",{onClick:M,disabled:f,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50",children:"Cancel Document"})]})]}),er&&t.jsxs("div",{className:"flex items-center gap-4 mt-2 pt-3 border-t border-gray-200 dark:border-gray-700",children:[t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Workflow Status:"}),X.length>0&&t.jsxs("span",{className:"px-3 py-1 text-sm font-medium rounded-full bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400",children:[X.length," Planned"]}),I.length>0&&t.jsxs("span",{className:"px-3 py-1 text-sm font-medium rounded-full bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400",children:[I.length," Pending Approval"]}),X.length===0&&I.length===0&&t.jsx("span",{className:"px-3 py-1 text-sm font-medium rounded-full bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",children:"All Approved ✓"})]})]}),t.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[t.jsx("div",{className:"flex-1 overflow-auto p-6",children:t.jsx("div",{className:"max-w-4xl mx-auto bg-white dark:bg-gray-800 rounded-lg shadow",children:t.jsxs("div",{className:"p-6 space-y-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:"Basic Information"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsx("div",{children:w?t.jsx(Je,{label:"Hospital *",doctype:"Company",value:de.hospital,onChange:dt=>xe(He=>je(se({},He),{hospital:dt})),placeholder:"Select Hospital",filters:{}}):t.jsxs(t.Fragment,{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Hospital"}),t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.hospital||"-"})]})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Modality"}),w?t.jsx("input",{type:"text",name:"modality",value:de.modality,onChange:be,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.modality||"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Device Status"}),w?t.jsx("input",{type:"text",name:"device_status",value:de.device_status,onChange:be,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.device_status||"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Periodicity *"}),w?t.jsxs("select",{name:"periodicity",value:de.periodicity,onChange:be,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"Daily",children:"Daily"}),t.jsx("option",{value:"Weekly",children:"Weekly"}),t.jsx("option",{value:"Monthly",children:"Monthly"}),t.jsx("option",{value:"Quarterly",children:"Quarterly"}),t.jsx("option",{value:"Half-yearly",children:"Half-yearly"}),t.jsx("option",{value:"Yearly",children:"Yearly"})]}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.periodicity||"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Manufacturer"}),w?t.jsx("input",{type:"text",name:"manufacturer",value:de.manufacturer,onChange:be,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.manufacturer||"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Model"}),w?t.jsx("input",{type:"text",name:"model",value:de.model,onChange:be,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.model||"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"PM Name"}),w?t.jsx("input",{type:"text",name:"pm_for",value:de.pm_for,onChange:be,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.pm_for||"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Asset Name"}),w?t.jsx("input",{type:"text",name:"asset_name",value:de.asset_name,onChange:be,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.asset_name||"-"})]})]})]}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:"Schedule Dates"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Start Date *"}),w?t.jsx("input",{type:"date",name:"start_date",value:de.start_date,onChange:be,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.start_date?new Date(s.start_date).toLocaleDateString():"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"End Date *"}),w?t.jsx("input",{type:"date",name:"end_date",value:de.end_date,onChange:be,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.end_date?new Date(s.end_date).toLocaleDateString():"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"First PM Date"}),w?t.jsx("input",{type:"date",name:"due_date",value:de.due_date,onChange:be,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.due_date?new Date(s.due_date).toLocaleDateString():"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Next PM Date"}),w?t.jsx("input",{type:"date",name:"next_pm_date",value:de.next_pm_date,onChange:be,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:de.next_pm_date?new Date(de.next_pm_date).toLocaleDateString():s.next_pm_date?new Date(s.next_pm_date).toLocaleDateString():"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"No. of PMs"}),w?t.jsx("input",{type:"number",name:"no_of_pms",value:de.no_of_pms,onChange:be,min:"1",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",placeholder:"Enter number of PMs"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.no_of_pms||"-"})]})]})]}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:"Assignment"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Maintenance Team"}),w?t.jsx("input",{type:"text",name:"maintenance_team",value:de.maintenance_team,onChange:be,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.maintenance_team||"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Maintenance Manager"}),w?t.jsx("input",{type:"text",name:"maintenance_manager",value:de.maintenance_manager,onChange:be,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.maintenance_manager||"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Assign To"}),w?t.jsx("input",{type:"text",name:"assign_to",value:de.assign_to,onChange:be,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.assign_to||"-"})]})]})]}),nr.length>0&&t.jsxs("div",{children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:["Pending Maintenance Entries",t.jsx("span",{className:"ml-2 text-sm font-normal text-gray-500 dark:text-gray-400",children:"(Showing Planned & Applied only)"})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full border-collapse border border-gray-300 dark:border-gray-600",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"bg-gray-100 dark:bg-gray-700",children:[t.jsx("th",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-left text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Asset"}),t.jsx("th",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-left text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Asset Name"}),t.jsx("th",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-left text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Manufacturer"}),t.jsx("th",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-left text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Maintenance Log"}),t.jsx("th",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-left text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Status"}),t.jsx("th",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-left text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Next PM Date"})]})}),t.jsx("tbody",{children:nr.map((dt,He)=>{const it=Qe(dt.asset);return it.map((Ue,Ve)=>t.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50",children:[Ve===0&&t.jsxs(t.Fragment,{children:[t.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-sm text-gray-900 dark:text-white",rowSpan:it.length,children:dt.asset?t.jsx("button",{onClick:()=>a(`/assets/${dt.asset}`),className:"text-blue-600 dark:text-blue-400 hover:underline",children:dt.asset}):"-"}),t.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-sm text-gray-900 dark:text-white",rowSpan:it.length,children:dt.asset_name||"-"}),t.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-sm text-gray-900 dark:text-white",rowSpan:it.length,children:dt.manufacturer||"-"})]}),t.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-sm text-gray-900 dark:text-white",children:t.jsx("button",{onClick:()=>a(`/maintenance/${Ue.name}`),className:"text-blue-600 dark:text-blue-400 hover:underline",children:Ue.name})}),t.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-sm",children:t.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${Ue.workflow_state==="Applied"?$e("Applied"):$e("Planned")}`,children:Ue.workflow_state==="Applied"?"Applied (Pending Approval)":"Planned"})}),t.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-sm text-gray-900 dark:text-white",children:Ue.due_date?new Date(Ue.due_date).toLocaleDateString():"-"})]},`${dt.name}-${Ue.name}`))})})]})})]}),er&&nr.length===0&&t.jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-6 text-center",children:[t.jsx(Qt,{className:"mx-auto text-green-600 dark:text-green-400 text-3xl mb-2"}),t.jsx("h3",{className:"text-lg font-semibold text-green-800 dark:text-green-300 mb-1",children:"All Maintenance Entries Completed"}),t.jsx("p",{className:"text-sm text-green-600 dark:text-green-400",children:"All maintenance entries have been approved. New planned entries will appear when generated."})]}),t.jsxs("div",{className:"pt-4 border-t border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-sm font-semibold text-gray-600 dark:text-gray-400 mb-3",children:"Metadata"}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-500",children:"Created:"}),t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:s.creation?new Date(s.creation).toLocaleString():"-"})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-500",children:"Created By:"}),t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:s.owner||"-"})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-500",children:"Modified:"}),t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:s.modified?new Date(s.modified).toLocaleString():"-"})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-500",children:"Modified By:"}),t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:s.modified_by||"-"})]})]})]})]})})}),t.jsx("div",{className:"w-80 flex-shrink-0 bg-white dark:bg-gray-800 border-l border-gray-200 dark:border-gray-700 overflow-auto",children:t.jsxs("div",{className:"p-4",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[t.jsx(ym,{className:"text-blue-600 dark:text-blue-400"}),t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:"Activity Log"})]}),Q.length===0?t.jsxs("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:[t.jsx(ym,{className:"mx-auto text-3xl mb-2 opacity-50"}),t.jsx("p",{className:"text-sm",children:"No activity recorded yet"})]}):t.jsx("div",{className:"space-y-3",children:Q.map(dt=>t.jsx("div",{className:`rounded-lg p-3 border ${dt.action==="Approved"?"bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-800":dt.action==="Applied"?"bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800":"bg-gray-50 dark:bg-gray-700 border-gray-200 dark:border-gray-600"}`,children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("div",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center ${dt.action==="Approved"?"bg-green-100 dark:bg-green-900/30":dt.action==="Applied"?"bg-blue-100 dark:bg-blue-900/30":"bg-gray-100 dark:bg-gray-600"}`,children:dt.action==="Approved"?t.jsx(vf,{className:"text-green-600 dark:text-green-400 text-sm"}):t.jsx(ao,{className:"text-blue-600 dark:text-blue-400 text-sm"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:`text-sm font-medium ${dt.action==="Approved"?"text-green-800 dark:text-green-300":dt.action==="Applied"?"text-blue-800 dark:text-blue-300":"text-gray-900 dark:text-white"}`,children:dt.action}),t.jsxs("div",{className:"flex items-center gap-1 mt-1 text-xs text-gray-500 dark:text-gray-400",children:[t.jsx(nn,{className:"text-[10px]"}),t.jsx("span",{className:"truncate",children:dt.user})]}),t.jsxs("div",{className:"flex items-center gap-1 mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:[t.jsx(ea,{className:"text-[10px]"}),t.jsx("span",{children:new Date(dt.timestamp).toLocaleString()})]}),t.jsx("div",{className:"mt-2 pt-2 border-t border-gray-200 dark:border-gray-600",children:t.jsxs("div",{className:"text-xs space-y-1",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Entries:"}),t.jsx("span",{className:`font-medium ${dt.action==="Approved"?"text-green-600 dark:text-green-400":"text-blue-600 dark:text-blue-400"}`,children:dt.entriesCount})]}),dt.completionDate&&t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Completion Date:"}),t.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:new Date(dt.completionDate).toLocaleDateString()})]})]})})]})]})},dt.id))})]})})]}),N&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 max-w-lg w-full mx-4",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center",children:t.jsx(ao,{className:"text-blue-600 dark:text-blue-400"})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:"Apply for Approval"}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[ee.size," of ",X.length," ",X.length===1?"entry":"entries"," selected"]})]})]}),t.jsxs("div",{className:"mb-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400",children:"Select Entries to Complete:"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"button",onClick:le,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:"Select All"}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{type:"button",onClick:Fe,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:"Deselect All"})]})]}),t.jsx("div",{className:"max-h-48 overflow-y-auto bg-gray-50 dark:bg-gray-700 rounded-lg p-3 space-y-2",children:X.map((dt,He)=>t.jsxs("label",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-all ${ee.has(dt.name)?"bg-blue-50 dark:bg-blue-900/30 border border-blue-200 dark:border-blue-700":"bg-white dark:bg-gray-600 border border-gray-200 dark:border-gray-500 hover:bg-gray-50 dark:hover:bg-gray-550"}`,children:[t.jsx("input",{type:"checkbox",checked:ee.has(dt.name),onChange:()=>pe(dt.name),className:"w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-5 h-5 bg-yellow-100 dark:bg-yellow-900/30 rounded-full flex items-center justify-center text-[10px] font-medium text-yellow-700 dark:text-yellow-400 flex-shrink-0",children:He+1}),t.jsxs("div",{className:"truncate",children:[t.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:dt.asset_display_name||dt.asset_name||"Unknown Asset"}),t.jsx("span",{className:"text-gray-400 dark:text-gray-500 mx-1",children:"-"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:dt.name})]})]}),dt.due_date&&t.jsxs("div",{className:"ml-7 text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:["Due: ",new Date(dt.due_date).toLocaleDateString()]})]})]},dt.name))}),t.jsxs("div",{className:"mt-2 flex items-center justify-between text-xs",children:[t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[ee.size," selected"]}),ee.size===0&&t.jsx("span",{className:"text-red-500 dark:text-red-400",children:"Please select at least one entry"})]})]}),t.jsxs("div",{className:"mb-4",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Completion Date *"}),t.jsx("input",{type:"date",value:O,onChange:dt=>T(dt.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),de.next_pm_date&&t.jsx("div",{className:"mb-4 p-3 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx(rc,{className:"text-blue-600 dark:text-blue-400"}),t.jsxs("span",{className:"text-gray-700 dark:text-gray-300",children:["Next PM Date: ",t.jsx("strong",{className:"text-blue-600 dark:text-blue-400",children:new Date(de.next_pm_date).toLocaleDateString()})]})]})}),R&&t.jsxs("div",{className:"mb-4",children:[t.jsx("div",{className:"p-3 bg-amber-50 dark:bg-amber-900/20 rounded-lg border border-amber-200 dark:border-amber-800 mb-3",children:t.jsxs("p",{className:"text-sm text-amber-700 dark:text-amber-400 flex items-center gap-2",children:[t.jsx("span",{className:"text-lg",children:"⚠️"}),"Completion date is before the Next PM Date. Please provide a reason."]})}),t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Early Completion Reason *"}),t.jsx("textarea",{value:P,onChange:dt=>E(dt.target.value),rows:3,placeholder:"Enter reason for early completion...",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-amber-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white resize-none"})]}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>{C(!1),T(""),E(""),ne(new Set)},className:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300 transition-colors",disabled:G,children:"Cancel"}),t.jsx("button",{onClick:ze,disabled:G||!O||ee.size===0||R&&!P.trim(),className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:G?t.jsxs(t.Fragment,{children:[t.jsx(tr,{className:"animate-spin"}),"Applying..."]}):t.jsxs(t.Fragment,{children:[t.jsx(ao,{}),"Complete (",ee.size,")"]})})]})]})}),te&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 max-w-lg w-full mx-4",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"w-10 h-10 bg-green-100 dark:bg-green-900/30 rounded-full flex items-center justify-center",children:t.jsx(vf,{className:"text-green-600 dark:text-green-400"})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:"Approve Entries"}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[U.size," of ",I.length," ",I.length===1?"entry":"entries"," selected"]})]})]}),t.jsxs("div",{className:"mb-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400",children:"Select Entries to Approve:"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"button",onClick:Et,className:"text-xs text-green-600 dark:text-green-400 hover:underline",children:"Select All"}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{type:"button",onClick:jt,className:"text-xs text-green-600 dark:text-green-400 hover:underline",children:"Deselect All"})]})]}),t.jsx("div",{className:"max-h-48 overflow-y-auto bg-gray-50 dark:bg-gray-700 rounded-lg p-3 space-y-2",children:I.map((dt,He)=>t.jsxs("label",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-all ${U.has(dt.name)?"bg-green-50 dark:bg-green-900/30 border border-green-200 dark:border-green-700":"bg-white dark:bg-gray-600 border border-gray-200 dark:border-gray-500 hover:bg-gray-50 dark:hover:bg-gray-550"}`,children:[t.jsx("input",{type:"checkbox",checked:U.has(dt.name),onChange:()=>De(dt.name),className:"w-4 h-4 text-green-600 bg-gray-100 border-gray-300 rounded focus:ring-green-500 dark:focus:ring-green-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-5 h-5 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center text-[10px] font-medium text-blue-700 dark:text-blue-400 flex-shrink-0",children:He+1}),t.jsxs("div",{className:"truncate",children:[t.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:dt.asset_display_name||dt.asset_name||"Unknown Asset"}),t.jsx("span",{className:"text-gray-400 dark:text-gray-500 mx-1",children:"-"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:dt.name})]})]}),dt.completion_date&&t.jsxs("div",{className:"ml-7 text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:["Completed: ",new Date(dt.completion_date).toLocaleDateString()]})]})]},dt.name))}),t.jsxs("div",{className:"mt-2 flex items-center justify-between text-xs",children:[t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[U.size," selected"]}),U.size===0&&t.jsx("span",{className:"text-red-500 dark:text-red-400",children:"Please select at least one entry"})]})]}),t.jsx("div",{className:"mb-4 p-3 bg-green-50 dark:bg-green-900/20 rounded-lg border border-green-200 dark:border-green-800",children:t.jsxs("p",{className:"text-sm text-green-700 dark:text-green-400",children:["✓ Approving will ",t.jsx("strong",{children:"submit"})," the documents (docstatus = 1) and trigger auto-creation of next planned entries."]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>{Y(!1),re(new Set)},className:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300 transition-colors",disabled:q,children:"Cancel"}),t.jsx("button",{onClick:Ie,disabled:q||U.size===0,className:"px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:q?t.jsxs(t.Fragment,{children:[t.jsx(tr,{className:"animate-spin"}),"Approving..."]}):t.jsxs(t.Fragment,{children:[t.jsx(vf,{}),"Approve (",U.size,")"]})})]})]})}),k&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 max-w-md",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:"Confirm Delete"}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:"Are you sure you want to delete this PPM Planner? This action cannot be undone."}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>S(!1),className:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300",disabled:f,children:"Cancel"}),t.jsx("button",{onClick:ye,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors",disabled:f,children:f?"Deleting...":"Delete"})]})]})})]})},qne=({month:e,year:r,filters:a={},viewType:s="maintenance-log",timeView:n="day-month"})=>{const{t:i}=sr(),o=hr(),l=new Date,[c,u]=p.useState(e!=null?e:l.getMonth()),[h,f]=p.useState(r!=null?r:l.getFullYear()),y=new Date(h,c,1).toISOString().split("T")[0],b=new Date(h,c+1,0).toISOString().split("T")[0],w=JSON.stringify(a),v=p.useMemo(()=>a,[w]),k=p.useMemo(()=>se({due_date:["between",[y,b]]},v),[y,b,v]),S=p.useMemo(()=>({}),[]),N=p.useMemo(()=>({}),[]),{logs:C,loading:O}=V1(s==="maintenance-log"?k:S,s==="maintenance-log"?1e3:0,0,"due_date asc"),{pmSchedules:T,loading:P}=ES(s==="ppm-planner"?v:S,1e3,0,"creation desc",N),E=s==="maintenance-log"?O:P,R=p.useMemo(()=>s==="maintenance-log"?C.filter(U=>{if(!U.due_date)return!1;const re=new Date(U.due_date);return re.getMonth()===c&&re.getFullYear()===h}):T.filter(re=>{const X=re.due_date||re.start_date;if(!X)return!1;const[V,I,B]=X.split("-").map(Number),Q=new Date(V,I-1,B);return Q.getMonth()===c&&Q.getFullYear()===h}),[C,T,c,h,s]);p.useEffect(()=>{s==="ppm-planner"&&!P&&(console.log("=== PPM PLANNER DEBUG ==="),console.log("[MaintenanceCalendar] Viewing Month:",c+1,"Year:",h),console.log("[MaintenanceCalendar] Total PM Schedules fetched:",T.length),console.log("[MaintenanceCalendar] Filtered for current month:",R.length),R.length>0?(console.log("[MaintenanceCalendar] Schedules showing in this month:"),R.forEach(U=>{console.log(` - ${U.name}: due_date=${U.due_date}, start_date=${U.start_date}`)})):(console.log("[MaintenanceCalendar] No schedules match this month."),console.log("[MaintenanceCalendar] Due dates in fetched data:"),T.slice(0,5).forEach(U=>{const re=U.due_date||U.start_date;console.log(` - ${U.name}: due_date=${U.due_date}, start_date=${U.start_date}, will show in: ${re?(()=>{const[X,V]=re.split("-").map(Number);return`${V}/${X}`})():"unknown"}`)}),console.log("[MaintenanceCalendar] TIP: Navigate to the month where due_dates match to see schedules.")),console.log("========================="))},[s,T,P,R.length,c,h]);const z=(U,re)=>{const X=new Date(re)<new Date&&U!=="Completed";switch(U){case"Completed":return"bg-green-500 text-white border-green-600";case"Planned":return X?"bg-red-500 text-white border-red-600":"bg-yellow-500 text-white border-yellow-600";case"Overdue":return"bg-red-600 text-white border-red-700";default:return"bg-gray-500 text-white border-gray-600"}},G=new Date(h,c,1).getDay(),ae=new Date(h,c+1,0).getDate(),ee=Array.from({length:ae},(U,re)=>re+1),ne=U=>{U>0?c===11?(u(0),f(h+1)):u(c+1):c===0?(u(11),f(h-1)):u(c-1)},te=U=>s==="maintenance-log"?R.filter(re=>re.due_date?new Date(re.due_date).getDate()===U:!1):R.filter(X=>{const V=X.due_date||X.start_date;if(!V)return!1;const[I,B,Q]=V.split("-").map(Number),ie=new Date(I,B-1,Q);return ie.getDate()===U&&ie.getMonth()===c&&ie.getFullYear()===h}),Y=()=>{u(l.getMonth()),f(l.getFullYear())},q=[i("maintenanceCalendarPage.months.january"),i("maintenanceCalendarPage.months.february"),i("maintenanceCalendarPage.months.march"),i("maintenanceCalendarPage.months.april"),i("maintenanceCalendarPage.months.may"),i("maintenanceCalendarPage.months.june"),i("maintenanceCalendarPage.months.july"),i("maintenanceCalendarPage.months.august"),i("maintenanceCalendarPage.months.september"),i("maintenanceCalendarPage.months.october"),i("maintenanceCalendarPage.months.november"),i("maintenanceCalendarPage.months.december")],H=[i("maintenanceCalendarPage.days.sun"),i("maintenanceCalendarPage.days.mon"),i("maintenanceCalendarPage.days.tue"),i("maintenanceCalendarPage.days.wed"),i("maintenanceCalendarPage.days.thu"),i("maintenanceCalendarPage.days.fri"),i("maintenanceCalendarPage.days.sat")];return t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow h-full flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"flex-shrink-0 flex justify-between items-center p-4 lg:p-6 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center gap-2 lg:gap-3",children:[t.jsx(rc,{className:"text-blue-600 dark:text-blue-400",size:20}),t.jsxs("h2",{className:"text-xl lg:text-2xl font-bold text-gray-800 dark:text-white",children:[q[c]," ",h]})]}),t.jsxs("div",{className:"flex gap-1 lg:gap-2",children:[t.jsx("button",{onClick:()=>ne(-1),className:"px-2 py-2 lg:px-4 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 rounded-lg text-gray-700 dark:text-gray-300 transition-colors",title:i("maintenanceCalendarPage.previousMonth"),children:t.jsx(Z4,{})}),t.jsx("button",{onClick:Y,className:"px-2 py-2 lg:px-4 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors text-xs lg:text-sm font-medium",children:i("maintenanceCalendarPage.today")}),t.jsx("button",{onClick:()=>ne(1),className:"px-2 py-2 lg:px-4 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 rounded-lg text-gray-700 dark:text-gray-300 transition-colors",title:i("maintenanceCalendarPage.nextMonth"),children:t.jsx(Fi,{})})]})]}),E?t.jsxs("div",{className:"flex items-center justify-center flex-1",children:[t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"}),t.jsx("span",{className:"ml-3 text-gray-600 dark:text-gray-400",children:i(s==="maintenance-log"?"maintenanceCalendarPage.loadingLogs":"maintenanceCalendarPage.loadingPpm")})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex-1 overflow-auto p-4 lg:p-6",children:[t.jsx("div",{className:"grid grid-cols-7 gap-1 lg:gap-2 mb-2",children:H.map(U=>t.jsx("div",{className:"text-center font-semibold p-1 lg:p-2 text-gray-700 dark:text-gray-300 text-xs lg:text-sm",children:U},U))}),t.jsxs("div",{className:"grid grid-cols-7 gap-1 lg:gap-2 auto-rows-fr",children:[Array.from({length:G}).map((U,re)=>t.jsx("div",{className:"p-1 lg:p-2"},`empty-${re}`)),ee.map(U=>{const re=te(U),X=U===l.getDate()&&c===l.getMonth()&&h===l.getFullYear();return t.jsxs("div",{className:`border rounded-lg p-1 lg:p-2 min-h-16 lg:min-h-20 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors flex flex-col ${X?"border-blue-500 border-2 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700"}`,children:[t.jsx("div",{className:`font-semibold mb-1 text-xs lg:text-sm flex-shrink-0 ${X?"text-blue-700 dark:text-blue-300":"text-gray-700 dark:text-gray-300"}`,children:U}),t.jsxs("div",{className:"space-y-1 flex-1 overflow-hidden",children:[re.slice(0,2).map(V=>{if(s==="maintenance-log"){const I=V,B=new Date(I.due_date||"")<new Date&&I.maintenance_status!=="Completed";return t.jsx("div",{onClick:()=>o(`/maintenance/${I.name}`),className:`text-xs p-1 rounded border ${z(I.maintenance_status||"Planned",I.due_date||"")} truncate cursor-pointer hover:opacity-80 transition-opacity`,title:`${I.asset_name||I.name} - ${I.maintenance_status||"Planned"}${B?` ${i("maintenanceCalendarPage.overdueInTooltip")}`:""} - ${i("maintenanceCalendarPage.clickToViewDetails")}`,children:t.jsx("div",{className:"truncate font-medium text-xs",children:I.asset_name||I.name})},I.name)}else{const I=V,Q=I.pm_for||I.pm_for||I["PM Name"]||null||I.name||i("maintenanceCalendarPage.ppmPlannerDefault"),ie=I.name?`${I.name}${I.modality?` - ${I.modality}`:""}${I.hospital?` - ${I.hospital}`:""} - ${i("maintenanceCalendarPage.clickToViewPpmPlanner")}`:i("maintenanceCalendarPage.clickToViewPpmPlanner");return t.jsx("div",{onClick:()=>o(`/ppm-planner/${I.name}`),className:"text-xs p-1 rounded border bg-purple-500 text-white border-purple-600 truncate cursor-pointer hover:opacity-80 transition-opacity",title:ie,children:t.jsx("div",{className:"truncate font-medium text-xs",children:Q})},I.name)}}),re.length>2&&t.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-medium",children:["+",re.length-2]})]})]},U)})]})]}),t.jsx("div",{className:"flex-shrink-0 border-t border-gray-200 dark:border-gray-700 p-3 lg:p-4 bg-gray-50 dark:bg-gray-900/30",children:t.jsxs("div",{className:"flex flex-col lg:flex-row justify-between items-center gap-3 lg:gap-4",children:[t.jsxs("div",{className:"flex flex-wrap gap-3 lg:gap-4 items-center justify-center lg:justify-start",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-3 h-3 bg-green-500 rounded border border-green-600"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:i("maintenanceCalendarPage.legendCompleted")})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-3 h-3 bg-yellow-500 rounded border border-yellow-600"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:i("maintenanceCalendarPage.legendPlanned")})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-3 h-3 bg-red-500 rounded border border-red-600"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:i("maintenanceCalendarPage.legendOverdue")})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-3 h-3 border-2 border-blue-500 rounded bg-blue-50 dark:bg-blue-900/20"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:i("maintenanceCalendarPage.legendToday")})]})]}),t.jsx("div",{className:"flex gap-4 lg:gap-6 text-center",children:s==="maintenance-log"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-lg lg:text-xl font-bold text-green-600 dark:text-green-400",children:R.filter(U=>U.maintenance_status==="Completed").length}),t.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:i("maintenanceCalendarPage.legendCompleted")})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-lg lg:text-xl font-bold text-yellow-600 dark:text-yellow-400",children:R.filter(U=>U.maintenance_status==="Planned"&&new Date(U.due_date||"")>=new Date).length}),t.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:i("maintenanceCalendarPage.legendPlanned")})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-lg lg:text-xl font-bold text-red-600 dark:text-red-400",children:R.filter(U=>new Date(U.due_date||"")<new Date&&U.maintenance_status!=="Completed").length}),t.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:i("maintenanceCalendarPage.legendOverdue")})]})]}):t.jsxs("div",{children:[t.jsx("div",{className:"text-lg lg:text-xl font-bold text-purple-600 dark:text-purple-400",children:R.length}),t.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:i("maintenanceCalendarPage.summaryPpmPlanners")})]})})]})})]})]})},Vne=()=>{const{t:e}=sr(),r=hr(),[a]=_a(),[s,n]=p.useState(""),[i,o]=p.useState(""),[l,c]=p.useState(""),[u,h]=p.useState("");p.useEffect(()=>{const O=a.get("hospital"),T=a.get("status");O&&n(O),T&&c(T)},[a]);const[f,y]=p.useState("maintenance-log"),[b,w]=p.useState(!1),[v,k]=p.useState(0);p.useEffect(()=>{const O=[s,i,l,u].filter(Boolean).length;k(O)},[s,i,l,u]);const S=()=>{n(""),o(""),c(""),h("")},N=s||i||l||u,C=p.useMemo(()=>{const O={};return s&&(O.company=s),i&&(O.department=i),l&&(O.maintenance_status=l),u&&(O.assign_to_name=u),O},[s,i,l,u]);return t.jsxs("div",{className:"flex flex-col h-screen bg-gray-50 dark:bg-gray-900 overflow-hidden",children:[t.jsxs("div",{className:"flex-shrink-0 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 px-4 py-2.5 lg:px-6",children:[t.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-3 md:gap-4",children:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[t.jsx(rc,{className:"text-blue-600 dark:text-blue-400 flex-shrink-0",size:22}),t.jsx("div",{className:"min-w-0",children:t.jsx("h1",{className:"text-lg md:text-xl font-bold text-gray-800 dark:text-white whitespace-nowrap",children:e("maintenanceCalendarPage.title")})})]}),t.jsxs("div",{className:"flex items-end gap-2 md:gap-3 flex-wrap md:flex-nowrap",children:[t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("maintenanceCalendarPage.viewType")}),t.jsxs("select",{value:f,onChange:O=>y(O.target.value),className:"px-2.5 md:px-3 py-1.5 text-xs md:text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"maintenance-log",children:e("maintenanceCalendarPage.maintenanceLog")}),t.jsx("option",{value:"ppm-planner",children:e("maintenanceCalendarPage.ppmPlanner")})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1 invisible",children:e("maintenanceCalendarPage.filters")}),t.jsxs("button",{onClick:()=>w(!b),className:`px-3 md:px-4 py-1.5 md:py-2 border rounded-lg transition-colors flex items-center gap-1.5 md:gap-2 text-xs md:text-sm ${N?"border-blue-500 bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400":"border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:[t.jsx(ds,{size:14}),t.jsx("span",{className:"hidden sm:inline",children:e("maintenanceCalendarPage.filters")}),v>0&&t.jsx("span",{className:"bg-blue-600 text-white rounded-full w-4 h-4 md:w-5 md:h-5 flex items-center justify-center text-[10px] md:text-xs",children:v}),b?t.jsx(Ja,{size:12}):t.jsx(Fr,{size:12})]})]}),f==="ppm-planner"&&t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1 invisible",children:e("maintenanceCalendarPage.yearlyMap")}),t.jsxs("button",{onClick:()=>r("/yearly-ppm-planner"),className:"px-3 md:px-4 py-1.5 md:py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors flex items-center gap-1.5 md:gap-2 text-xs md:text-sm font-medium whitespace-nowrap",title:e("maintenanceCalendarPage.yearlyMapTitle"),children:[t.jsx(UG,{size:14}),t.jsx("span",{className:"hidden sm:inline",children:e("maintenanceCalendarPage.yearlyMap")}),t.jsx("span",{className:"sm:hidden",children:e("maintenanceCalendarPage.mapShort")})]})]})]})]}),b&&t.jsxs("div",{className:"mt-2.5 md:mt-3 p-3 md:p-4 bg-gray-50 dark:bg-gray-700/50 rounded-lg border border-gray-200 dark:border-gray-600",children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[t.jsxs("div",{className:"relative z-[60]",children:[t.jsx(Je,{label:e("maintenanceCalendarPage.hospital"),doctype:"Company",value:s,onChange:O=>n(O),placeholder:e("maintenanceCalendarPage.selectHospital"),compact:!0}),s&&t.jsx("button",{onClick:()=>n(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[55]",children:[t.jsx(Je,{label:e("maintenanceCalendarPage.department"),doctype:"Department",value:i,onChange:O=>o(O),placeholder:e("maintenanceCalendarPage.allDepartments"),compact:!0}),i&&t.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("maintenanceCalendarPage.status")}),t.jsxs("select",{value:l,onChange:O=>c(O.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("maintenanceCalendarPage.allStatuses")}),t.jsx("option",{value:"Planned",children:e("maintenanceCalendarPage.planned")}),t.jsx("option",{value:"Completed",children:e("maintenanceCalendarPage.completed")}),t.jsx("option",{value:"Overdue",children:e("maintenanceCalendarPage.overdue")}),t.jsx("option",{value:"Cancelled",children:e("maintenanceCalendarPage.cancelled")})]}),l&&t.jsx("button",{onClick:()=>c(""),className:"absolute right-8 top-7 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[50]",children:[t.jsx(Je,{label:e("maintenanceCalendarPage.assignedTo"),doctype:"User",value:u,onChange:O=>h(O),placeholder:e("maintenanceCalendarPage.allTechnicians"),compact:!0}),u&&t.jsx("button",{onClick:()=>h(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]})]}),N&&t.jsx("div",{className:"mt-3 flex justify-end",children:t.jsxs("button",{onClick:S,className:"px-3 py-1.5 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 flex items-center gap-2",children:[t.jsx(ht,{}),e("maintenanceCalendarPage.clearFilters")]})})]})]}),t.jsx("div",{className:"flex-1 overflow-hidden px-3 pb-3 lg:px-4 lg:pb-4",children:t.jsx(qne,{filters:C,viewType:f,timeView:"day-month"})})]})},O7=()=>{const e=hr(),[r,a]=p.useState(2025),[s,n]=p.useState(2030),i=p.useMemo(()=>({}),[]),o=p.useMemo(()=>({}),[]),{pmSchedules:l,loading:c,error:u}=ES(i,1e3,0,"creation desc",o),h=(v,k,S,N,C)=>{const O=v.toLowerCase().trim(),T=k.getFullYear(),P=k.getMonth(),E=new Date(N,C,1),R=new Date(N,C+1,0,23,59,59,999);if(E>S||R<k)return!1;const z=(N-T)*12+(C-P);switch(O){case"daily":return E<=S&&R>=k;case"weekly":return E<=S&&R>=k;case"monthly":return z>=0&&E<=S;case"quarterly":return z>=0&&z%3===0&&E<=S;case"half-yearly":case"half yearly":return z>=0&&z%6===0&&E<=S;case"yearly":case"annually":return C===P&&E<=S&&E>=k;case"2 yearly":case"2-yearly":return z>=0&&z%24===0&&E<=S;case"3 yearly":case"3-yearly":return z>=0&&z%36===0&&E<=S;default:return E<=S&&R>=k}},f=p.useMemo(()=>{const v={};for(let k=r;k<=s;k++){v[k]={};for(let S=0;S<12;S++)v[k][S]=[]}return l.forEach(k=>{let S=null,N=null;if(k.start_date){const[T,P,E]=k.start_date.split("-").map(Number)}if(k.end_date){const[T,P,E]=k.end_date.split("-").map(Number);S=new Date(T,P-1,E)}if(k.due_date){const[T,P,E]=k.due_date.split("-").map(Number);N=new Date(T,P-1,E)}if(!N)return;const C=S||N,O=k.periodicity||"monthly";for(let T=r;T<=s;T++)for(let P=0;P<12;P++)h(O,N,C,T,P)&&(v[T][P].some(R=>R.name===k.name)||v[T][P].push(k))}),v},[l,r,s]);p.useEffect(()=>{c||(console.log("[YearlyPPMPlannerPage] PM Schedules count:",l.length),console.log("[YearlyPPMPlannerPage] Matrix years:",r,"to",s))},[l,c,r,s]);const y=v=>{a(k=>k+v),n(k=>k+v)},b=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],w=Array.from({length:s-r+1},(v,k)=>r+k);return t.jsxs("div",{className:"flex flex-col h-screen bg-gray-50 dark:bg-gray-900 overflow-hidden",children:[t.jsx("div",{className:"flex-shrink-0 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 px-4 py-3 lg:px-6",children:t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>e("/maintenance-calendar/month-view"),className:"p-1.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-lg transition-colors",title:"Back to Month View",children:t.jsx(ia,{className:"text-gray-600 dark:text-gray-400",size:18})}),t.jsx(rc,{className:"text-blue-600 dark:text-blue-400",size:24}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-xl font-bold text-gray-800 dark:text-white",children:"Site or Cluster PPM Calendar"}),t.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"View PM Schedule Generators across multiple years"})]})]}),t.jsxs("button",{onClick:()=>e("/maintenance-calendar/month-view"),className:"px-3 py-1.5 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors flex items-center gap-2 text-sm font-medium",title:"Go to Month View",children:[t.jsx(sv,{size:14}),"Month"]})]})}),t.jsx("div",{className:"flex-shrink-0 px-3 lg:px-4 py-2",children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-200 dark:border-gray-700 p-2",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("button",{onClick:()=>y(-1),className:"px-3 py-1.5 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 rounded-lg text-gray-700 dark:text-gray-300 transition-colors",children:t.jsx(Z4,{})}),t.jsxs("h2",{className:"text-lg font-bold text-gray-800 dark:text-white",children:[r," - ",s]}),t.jsx("button",{onClick:()=>y(1),className:"px-3 py-1.5 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 rounded-lg text-gray-700 dark:text-gray-300 transition-colors",children:t.jsx(Fi,{})})]})})}),t.jsx("div",{className:"flex-1 overflow-auto px-3 pb-3 lg:px-4 lg:pb-4",children:c?t.jsxs("div",{className:"flex items-center justify-center h-full",children:[t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"}),t.jsx("span",{className:"ml-3 text-gray-600 dark:text-gray-400",children:"Loading PPM Planners..."})]}):u?t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:t.jsxs("p",{className:"text-red-600 dark:text-red-400",children:["Error loading PPM Planners: ",u]})})}):t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full border-collapse",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 sticky top-0 z-10",children:t.jsxs("tr",{children:[t.jsx("th",{className:"border border-gray-300 dark:border-gray-600 px-4 py-3 text-left font-bold text-gray-800 dark:text-white bg-gray-200 dark:bg-gray-800",children:"Year/Month"}),b.map((v,k)=>t.jsx("th",{className:"border border-gray-300 dark:border-gray-600 px-2 py-3 text-center font-semibold text-gray-800 dark:text-white min-w-[140px]",children:v},k))]})}),t.jsx("tbody",{children:w.map(v=>t.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[t.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-4 py-3 font-bold text-gray-800 dark:text-white bg-gray-50 dark:bg-gray-800/50",children:v}),b.map((k,S)=>{var C;const N=((C=f[v])==null?void 0:C[S])||[];return t.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-2 py-2 align-top min-h-[60px]",children:N.length>0?t.jsx("div",{className:"space-y-1",children:N.map(O=>{const T=O.pm_for||O.pm_for||O["PM Name"]||null;N.indexOf(O)===0&&console.log("[YearlyCalendar] 🔍 SCHEDULE IN CELL:",{name:O.name,pm_for:O.pm_for,"pm_for (bracket)":O.pm_for,allKeys:Object.keys(O),pmName:T});const P=T||O.name||"PPM Planner",E=[];O.name&&E.push(O.name),O.modality&&E.push(O.modality),O.hospital&&E.push(O.hospital);const R=E.length>0?`${E.join(" - ")} - Click to view details`:"Click to view details";return t.jsx("div",{onClick:()=>e(`/ppm-planner/${O.name}`),className:"text-[10px] p-1 bg-blue-50 dark:bg-blue-900/30 border border-blue-200 dark:border-blue-700 rounded cursor-pointer hover:bg-blue-100 dark:hover:bg-blue-900/50 transition-colors group",title:R,children:t.jsx("div",{className:"font-medium text-blue-900 dark:text-blue-300 leading-tight group-hover:underline break-words",children:P})},O.name)})}):t.jsx("div",{className:"text-xs text-gray-300 dark:text-gray-700 text-center py-1",children:"-"})},S)})]},v))})]})})})})]})};function TL(e,r){const a=p.useRef(r);p.useEffect(function(){r!==a.current&&e.attributionControl!=null&&(a.current!=null&&e.attributionControl.removeAttribution(a.current),r!=null&&e.attributionControl.addAttribution(r)),a.current=r},[e,r])}const Gne=1;function Kne(e){return Object.freeze({__version:Gne,map:e})}function Yne(e,r){return Object.freeze(se(se({},e),r))}const AS=p.createContext(null);function OS(){const e=p.use(AS);if(e==null)throw new Error("No context provided: useLeafletContext() can only be used in a descendant of <MapContainer>");return e}function Jne(e){function r(a,s){const{instance:n,context:i}=e(a).current;p.useImperativeHandle(s,()=>n);const{children:o}=a;return o==null?null:gr.createElement(AS,{value:i},o)}return p.forwardRef(r)}function Zne(e){function r(a,s){const[n,i]=p.useState(!1),{instance:o}=e(a,i).current;p.useImperativeHandle(s,()=>o),p.useEffect(function(){n&&o.update()},[o,n,a.children]);const l=o._contentNode;return l?wx.createPortal(a.children,l):null}return p.forwardRef(r)}function Xne(e){function r(a,s){const{instance:n}=e(a).current;return p.useImperativeHandle(s,()=>n),null}return p.forwardRef(r)}function EL(e,r){const a=p.useRef(void 0);p.useEffect(function(){return r!=null&&e.instance.on(r),a.current=r,function(){a.current!=null&&e.instance.off(a.current),a.current=null}},[e,r])}function PS(e,r){var s;const a=(s=e.pane)!=null?s:r.pane;return a?je(se({},e),{pane:a}):e}function Qne(e,r){return function(s,n){const i=OS(),o=e(PS(s,i),i);return TL(i.map,s.attribution),EL(o.current,s.eventHandlers),r(o.current,i,s,n),o}}var jf={exports:{}};var eie=jf.exports,P7;function tie(){return P7||(P7=1,(function(e,r){(function(a,s){s(r)})(eie,(function(a){var s="1.9.4";function n(g){var j,A,W,ce;for(A=1,W=arguments.length;A<W;A++){ce=arguments[A];for(j in ce)g[j]=ce[j]}return g}var i=Object.create||(function(){function g(){}return function(j){return g.prototype=j,new g}})();function o(g,j){var A=Array.prototype.slice;if(g.bind)return g.bind.apply(g,A.call(arguments,1));var W=A.call(arguments,2);return function(){return g.apply(j,W.length?W.concat(A.call(arguments)):arguments)}}var l=0;function c(g){return"_leaflet_id"in g||(g._leaflet_id=++l),g._leaflet_id}function u(g,j,A){var W,ce,Ne,Ge;return Ge=function(){W=!1,ce&&(Ne.apply(A,ce),ce=!1)},Ne=function(){W?ce=arguments:(g.apply(A,arguments),setTimeout(Ge,j),W=!0)},Ne}function h(g,j,A){var W=j[1],ce=j[0],Ne=W-ce;return g===W&&A?g:((g-ce)%Ne+Ne)%Ne+ce}function f(){return!1}function y(g,j){if(j===!1)return g;var A=Math.pow(10,j===void 0?6:j);return Math.round(g*A)/A}function b(g){return g.trim?g.trim():g.replace(/^\s+|\s+$/g,"")}function w(g){return b(g).split(/\s+/)}function v(g,j){Object.prototype.hasOwnProperty.call(g,"options")||(g.options=g.options?i(g.options):{});for(var A in j)g.options[A]=j[A];return g.options}function k(g,j,A){var W=[];for(var ce in g)W.push(encodeURIComponent(A?ce.toUpperCase():ce)+"="+encodeURIComponent(g[ce]));return(!j||j.indexOf("?")===-1?"?":"&")+W.join("&")}var S=/\{ *([\w_ -]+) *\}/g;function N(g,j){return g.replace(S,function(A,W){var ce=j[W];if(ce===void 0)throw new Error("No value provided for variable "+A);return typeof ce=="function"&&(ce=ce(j)),ce})}var C=Array.isArray||function(g){return Object.prototype.toString.call(g)==="[object Array]"};function O(g,j){for(var A=0;A<g.length;A++)if(g[A]===j)return A;return-1}var T="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";function P(g){return window["webkit"+g]||window["moz"+g]||window["ms"+g]}var E=0;function R(g){var j=+new Date,A=Math.max(0,16-(j-E));return E=j+A,window.setTimeout(g,A)}var z=window.requestAnimationFrame||P("RequestAnimationFrame")||R,G=window.cancelAnimationFrame||P("CancelAnimationFrame")||P("CancelRequestAnimationFrame")||function(g){window.clearTimeout(g)};function ae(g,j,A){if(A&&z===R)g.call(j);else return z.call(window,o(g,j))}function ee(g){g&&G.call(window,g)}var ne={__proto__:null,extend:n,create:i,bind:o,get lastId(){return l},stamp:c,throttle:u,wrapNum:h,falseFn:f,formatNum:y,trim:b,splitWords:w,setOptions:v,getParamString:k,template:N,isArray:C,indexOf:O,emptyImageUrl:T,requestFn:z,cancelFn:G,requestAnimFrame:ae,cancelAnimFrame:ee};function te(){}te.extend=function(g){var j=function(){v(this),this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()},A=j.__super__=this.prototype,W=i(A);W.constructor=j,j.prototype=W;for(var ce in this)Object.prototype.hasOwnProperty.call(this,ce)&&ce!=="prototype"&&ce!=="__super__"&&(j[ce]=this[ce]);return g.statics&&n(j,g.statics),g.includes&&(Y(g.includes),n.apply(null,[W].concat(g.includes))),n(W,g),delete W.statics,delete W.includes,W.options&&(W.options=A.options?i(A.options):{},n(W.options,g.options)),W._initHooks=[],W.callInitHooks=function(){if(!this._initHooksCalled){A.callInitHooks&&A.callInitHooks.call(this),this._initHooksCalled=!0;for(var Ne=0,Ge=W._initHooks.length;Ne<Ge;Ne++)W._initHooks[Ne].call(this)}},j},te.include=function(g){var j=this.prototype.options;return n(this.prototype,g),g.options&&(this.prototype.options=j,this.mergeOptions(g.options)),this},te.mergeOptions=function(g){return n(this.prototype.options,g),this},te.addInitHook=function(g){var j=Array.prototype.slice.call(arguments,1),A=typeof g=="function"?g:function(){this[g].apply(this,j)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(A),this};function Y(g){if(!(typeof L=="undefined"||!L||!L.Mixin)){g=C(g)?g:[g];for(var j=0;j<g.length;j++)g[j]===L.Mixin.Events&&console.warn("Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.",new Error().stack)}}var q={on:function(g,j,A){if(typeof g=="object")for(var W in g)this._on(W,g[W],j);else{g=w(g);for(var ce=0,Ne=g.length;ce<Ne;ce++)this._on(g[ce],j,A)}return this},off:function(g,j,A){if(!arguments.length)delete this._events;else if(typeof g=="object")for(var W in g)this._off(W,g[W],j);else{g=w(g);for(var ce=arguments.length===1,Ne=0,Ge=g.length;Ne<Ge;Ne++)ce?this._off(g[Ne]):this._off(g[Ne],j,A)}return this},_on:function(g,j,A,W){if(typeof j!="function"){console.warn("wrong listener type: "+typeof j);return}if(this._listens(g,j,A)===!1){A===this&&(A=void 0);var ce={fn:j,ctx:A};W&&(ce.once=!0),this._events=this._events||{},this._events[g]=this._events[g]||[],this._events[g].push(ce)}},_off:function(g,j,A){var W,ce,Ne;if(this._events&&(W=this._events[g],!!W)){if(arguments.length===1){if(this._firingCount)for(ce=0,Ne=W.length;ce<Ne;ce++)W[ce].fn=f;delete this._events[g];return}if(typeof j!="function"){console.warn("wrong listener type: "+typeof j);return}var Ge=this._listens(g,j,A);if(Ge!==!1){var xt=W[Ge];this._firingCount&&(xt.fn=f,this._events[g]=W=W.slice()),W.splice(Ge,1)}}},fire:function(g,j,A){if(!this.listens(g,A))return this;var W=n({},j,{type:g,target:this,sourceTarget:j&&j.sourceTarget||this});if(this._events){var ce=this._events[g];if(ce){this._firingCount=this._firingCount+1||1;for(var Ne=0,Ge=ce.length;Ne<Ge;Ne++){var xt=ce[Ne],Nt=xt.fn;xt.once&&this.off(g,Nt,xt.ctx),Nt.call(xt.ctx||this,W)}this._firingCount--}}return A&&this._propagateEvent(W),this},listens:function(g,j,A,W){typeof g!="string"&&console.warn('"string" type argument expected');var ce=j;typeof j!="function"&&(W=!!j,ce=void 0,A=void 0);var Ne=this._events&&this._events[g];if(Ne&&Ne.length&&this._listens(g,ce,A)!==!1)return!0;if(W){for(var Ge in this._eventParents)if(this._eventParents[Ge].listens(g,j,A,W))return!0}return!1},_listens:function(g,j,A){if(!this._events)return!1;var W=this._events[g]||[];if(!j)return!!W.length;A===this&&(A=void 0);for(var ce=0,Ne=W.length;ce<Ne;ce++)if(W[ce].fn===j&&W[ce].ctx===A)return ce;return!1},once:function(g,j,A){if(typeof g=="object")for(var W in g)this._on(W,g[W],j,!0);else{g=w(g);for(var ce=0,Ne=g.length;ce<Ne;ce++)this._on(g[ce],j,A,!0)}return this},addEventParent:function(g){return this._eventParents=this._eventParents||{},this._eventParents[c(g)]=g,this},removeEventParent:function(g){return this._eventParents&&delete this._eventParents[c(g)],this},_propagateEvent:function(g){for(var j in this._eventParents)this._eventParents[j].fire(g.type,n({layer:g.target,propagatedFrom:g.target},g),!0)}};q.addEventListener=q.on,q.removeEventListener=q.clearAllEventListeners=q.off,q.addOneTimeEventListener=q.once,q.fireEvent=q.fire,q.hasEventListeners=q.listens;var H=te.extend(q);function U(g,j,A){this.x=A?Math.round(g):g,this.y=A?Math.round(j):j}var re=Math.trunc||function(g){return g>0?Math.floor(g):Math.ceil(g)};U.prototype={clone:function(){return new U(this.x,this.y)},add:function(g){return this.clone()._add(X(g))},_add:function(g){return this.x+=g.x,this.y+=g.y,this},subtract:function(g){return this.clone()._subtract(X(g))},_subtract:function(g){return this.x-=g.x,this.y-=g.y,this},divideBy:function(g){return this.clone()._divideBy(g)},_divideBy:function(g){return this.x/=g,this.y/=g,this},multiplyBy:function(g){return this.clone()._multiplyBy(g)},_multiplyBy:function(g){return this.x*=g,this.y*=g,this},scaleBy:function(g){return new U(this.x*g.x,this.y*g.y)},unscaleBy:function(g){return new U(this.x/g.x,this.y/g.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=re(this.x),this.y=re(this.y),this},distanceTo:function(g){g=X(g);var j=g.x-this.x,A=g.y-this.y;return Math.sqrt(j*j+A*A)},equals:function(g){return g=X(g),g.x===this.x&&g.y===this.y},contains:function(g){return g=X(g),Math.abs(g.x)<=Math.abs(this.x)&&Math.abs(g.y)<=Math.abs(this.y)},toString:function(){return"Point("+y(this.x)+", "+y(this.y)+")"}};function X(g,j,A){return g instanceof U?g:C(g)?new U(g[0],g[1]):g==null?g:typeof g=="object"&&"x"in g&&"y"in g?new U(g.x,g.y):new U(g,j,A)}function V(g,j){if(g)for(var A=j?[g,j]:g,W=0,ce=A.length;W<ce;W++)this.extend(A[W])}V.prototype={extend:function(g){var j,A;if(!g)return this;if(g instanceof U||typeof g[0]=="number"||"x"in g)j=A=X(g);else if(g=I(g),j=g.min,A=g.max,!j||!A)return this;return!this.min&&!this.max?(this.min=j.clone(),this.max=A.clone()):(this.min.x=Math.min(j.x,this.min.x),this.max.x=Math.max(A.x,this.max.x),this.min.y=Math.min(j.y,this.min.y),this.max.y=Math.max(A.y,this.max.y)),this},getCenter:function(g){return X((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,g)},getBottomLeft:function(){return X(this.min.x,this.max.y)},getTopRight:function(){return X(this.max.x,this.min.y)},getTopLeft:function(){return this.min},getBottomRight:function(){return this.max},getSize:function(){return this.max.subtract(this.min)},contains:function(g){var j,A;return typeof g[0]=="number"||g instanceof U?g=X(g):g=I(g),g instanceof V?(j=g.min,A=g.max):j=A=g,j.x>=this.min.x&&A.x<=this.max.x&&j.y>=this.min.y&&A.y<=this.max.y},intersects:function(g){g=I(g);var j=this.min,A=this.max,W=g.min,ce=g.max,Ne=ce.x>=j.x&&W.x<=A.x,Ge=ce.y>=j.y&&W.y<=A.y;return Ne&&Ge},overlaps:function(g){g=I(g);var j=this.min,A=this.max,W=g.min,ce=g.max,Ne=ce.x>j.x&&W.x<A.x,Ge=ce.y>j.y&&W.y<A.y;return Ne&&Ge},isValid:function(){return!!(this.min&&this.max)},pad:function(g){var j=this.min,A=this.max,W=Math.abs(j.x-A.x)*g,ce=Math.abs(j.y-A.y)*g;return I(X(j.x-W,j.y-ce),X(A.x+W,A.y+ce))},equals:function(g){return g?(g=I(g),this.min.equals(g.getTopLeft())&&this.max.equals(g.getBottomRight())):!1}};function I(g,j){return!g||g instanceof V?g:new V(g,j)}function B(g,j){if(g)for(var A=j?[g,j]:g,W=0,ce=A.length;W<ce;W++)this.extend(A[W])}B.prototype={extend:function(g){var j=this._southWest,A=this._northEast,W,ce;if(g instanceof ie)W=g,ce=g;else if(g instanceof B){if(W=g._southWest,ce=g._northEast,!W||!ce)return this}else return g?this.extend(me(g)||Q(g)):this;return!j&&!A?(this._southWest=new ie(W.lat,W.lng),this._northEast=new ie(ce.lat,ce.lng)):(j.lat=Math.min(W.lat,j.lat),j.lng=Math.min(W.lng,j.lng),A.lat=Math.max(ce.lat,A.lat),A.lng=Math.max(ce.lng,A.lng)),this},pad:function(g){var j=this._southWest,A=this._northEast,W=Math.abs(j.lat-A.lat)*g,ce=Math.abs(j.lng-A.lng)*g;return new B(new ie(j.lat-W,j.lng-ce),new ie(A.lat+W,A.lng+ce))},getCenter:function(){return new ie((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)},getSouthWest:function(){return this._southWest},getNorthEast:function(){return this._northEast},getNorthWest:function(){return new ie(this.getNorth(),this.getWest())},getSouthEast:function(){return new ie(this.getSouth(),this.getEast())},getWest:function(){return this._southWest.lng},getSouth:function(){return this._southWest.lat},getEast:function(){return this._northEast.lng},getNorth:function(){return this._northEast.lat},contains:function(g){typeof g[0]=="number"||g instanceof ie||"lat"in g?g=me(g):g=Q(g);var j=this._southWest,A=this._northEast,W,ce;return g instanceof B?(W=g.getSouthWest(),ce=g.getNorthEast()):W=ce=g,W.lat>=j.lat&&ce.lat<=A.lat&&W.lng>=j.lng&&ce.lng<=A.lng},intersects:function(g){g=Q(g);var j=this._southWest,A=this._northEast,W=g.getSouthWest(),ce=g.getNorthEast(),Ne=ce.lat>=j.lat&&W.lat<=A.lat,Ge=ce.lng>=j.lng&&W.lng<=A.lng;return Ne&&Ge},overlaps:function(g){g=Q(g);var j=this._southWest,A=this._northEast,W=g.getSouthWest(),ce=g.getNorthEast(),Ne=ce.lat>j.lat&&W.lat<A.lat,Ge=ce.lng>j.lng&&W.lng<A.lng;return Ne&&Ge},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(",")},equals:function(g,j){return g?(g=Q(g),this._southWest.equals(g.getSouthWest(),j)&&this._northEast.equals(g.getNorthEast(),j)):!1},isValid:function(){return!!(this._southWest&&this._northEast)}};function Q(g,j){return g instanceof B?g:new B(g,j)}function ie(g,j,A){if(isNaN(g)||isNaN(j))throw new Error("Invalid LatLng object: ("+g+", "+j+")");this.lat=+g,this.lng=+j,A!==void 0&&(this.alt=+A)}ie.prototype={equals:function(g,j){if(!g)return!1;g=me(g);var A=Math.max(Math.abs(this.lat-g.lat),Math.abs(this.lng-g.lng));return A<=(j===void 0?1e-9:j)},toString:function(g){return"LatLng("+y(this.lat,g)+", "+y(this.lng,g)+")"},distanceTo:function(g){return de.distance(this,me(g))},wrap:function(){return de.wrapLatLng(this)},toBounds:function(g){var j=180*g/40075017,A=j/Math.cos(Math.PI/180*this.lat);return Q([this.lat-j,this.lng-A],[this.lat+j,this.lng+A])},clone:function(){return new ie(this.lat,this.lng,this.alt)}};function me(g,j,A){return g instanceof ie?g:C(g)&&typeof g[0]!="object"?g.length===3?new ie(g[0],g[1],g[2]):g.length===2?new ie(g[0],g[1]):null:g==null?g:typeof g=="object"&&"lat"in g?new ie(g.lat,"lng"in g?g.lng:g.lon,g.alt):j===void 0?null:new ie(g,j,A)}var he={latLngToPoint:function(g,j){var A=this.projection.project(g),W=this.scale(j);return this.transformation._transform(A,W)},pointToLatLng:function(g,j){var A=this.scale(j),W=this.transformation.untransform(g,A);return this.projection.unproject(W)},project:function(g){return this.projection.project(g)},unproject:function(g){return this.projection.unproject(g)},scale:function(g){return 256*Math.pow(2,g)},zoom:function(g){return Math.log(g/256)/Math.LN2},getProjectedBounds:function(g){if(this.infinite)return null;var j=this.projection.bounds,A=this.scale(g),W=this.transformation.transform(j.min,A),ce=this.transformation.transform(j.max,A);return new V(W,ce)},infinite:!1,wrapLatLng:function(g){var j=this.wrapLng?h(g.lng,this.wrapLng,!0):g.lng,A=this.wrapLat?h(g.lat,this.wrapLat,!0):g.lat,W=g.alt;return new ie(A,j,W)},wrapLatLngBounds:function(g){var j=g.getCenter(),A=this.wrapLatLng(j),W=j.lat-A.lat,ce=j.lng-A.lng;if(W===0&&ce===0)return g;var Ne=g.getSouthWest(),Ge=g.getNorthEast(),xt=new ie(Ne.lat-W,Ne.lng-ce),Nt=new ie(Ge.lat-W,Ge.lng-ce);return new B(xt,Nt)}},de=n({},he,{wrapLng:[-180,180],R:6371e3,distance:function(g,j){var A=Math.PI/180,W=g.lat*A,ce=j.lat*A,Ne=Math.sin((j.lat-g.lat)*A/2),Ge=Math.sin((j.lng-g.lng)*A/2),xt=Ne*Ne+Math.cos(W)*Math.cos(ce)*Ge*Ge,Nt=2*Math.atan2(Math.sqrt(xt),Math.sqrt(1-xt));return this.R*Nt}}),xe=6378137,ge={R:xe,MAX_LATITUDE:85.0511287798,project:function(g){var j=Math.PI/180,A=this.MAX_LATITUDE,W=Math.max(Math.min(A,g.lat),-A),ce=Math.sin(W*j);return new U(this.R*g.lng*j,this.R*Math.log((1+ce)/(1-ce))/2)},unproject:function(g){var j=180/Math.PI;return new ie((2*Math.atan(Math.exp(g.y/this.R))-Math.PI/2)*j,g.x*j/this.R)},bounds:(function(){var g=xe*Math.PI;return new V([-g,-g],[g,g])})()};function be(g,j,A,W){if(C(g)){this._a=g[0],this._b=g[1],this._c=g[2],this._d=g[3];return}this._a=g,this._b=j,this._c=A,this._d=W}be.prototype={transform:function(g,j){return this._transform(g.clone(),j)},_transform:function(g,j){return j=j||1,g.x=j*(this._a*g.x+this._b),g.y=j*(this._c*g.y+this._d),g},untransform:function(g,j){return j=j||1,new U((g.x/j-this._b)/this._a,(g.y/j-this._d)/this._c)}};function K(g,j,A,W){return new be(g,j,A,W)}var ye=n({},de,{code:"EPSG:3857",projection:ge,transformation:(function(){var g=.5/(Math.PI*ge.R);return K(g,.5,-g,.5)})()}),Z=n({},ye,{code:"EPSG:900913"});function M(g){return document.createElementNS("http://www.w3.org/2000/svg",g)}function we(g,j){var A="",W,ce,Ne,Ge,xt,Nt;for(W=0,Ne=g.length;W<Ne;W++){for(xt=g[W],ce=0,Ge=xt.length;ce<Ge;ce++)Nt=xt[ce],A+=(ce?"L":"M")+Nt.x+" "+Nt.y;A+=j?Xe.svg?"z":"x":""}return A||"M0 0"}var pe=document.documentElement.style,le="ActiveXObject"in window,Fe=le&&!document.addEventListener,ze="msLaunchUri"in navigator&&!("documentMode"in document),Re=Ke("webkit"),De=Ke("android"),Et=Ke("android 2")||Ke("android 3"),jt=parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1],10),Ie=De&&Ke("Google")&&jt<537&&!("AudioNode"in window),$e=!!window.opera,Qe=!ze&&Ke("chrome"),at=Ke("gecko")&&!Re&&!$e&&!le,Ct=!Qe&&Ke("safari"),vt=Ke("phantom"),er="OTransition"in pe,nr=navigator.platform.indexOf("Win")===0,dt=le&&"transition"in pe,He="WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix&&!Et,it="MozPerspective"in pe,Ue=!window.L_DISABLE_3D&&(dt||He||it)&&!er&&!vt,Ve=typeof orientation!="undefined"||Ke("mobile"),lt=Ve&&Re,st=Ve&&He,Mt=!window.PointerEvent&&window.MSPointerEvent,Ot=!!(window.PointerEvent||Mt),Pt="ontouchstart"in window||!!window.TouchEvent,zt=!window.L_NO_TOUCH&&(Pt||Ot),Tt=Ve&&$e,Gt=Ve&&at,Ye=(window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI)>1,kt=(function(){var g=!1;try{var j=Object.defineProperty({},"passive",{get:function(){g=!0}});window.addEventListener("testPassiveEventSupport",f,j),window.removeEventListener("testPassiveEventSupport",f,j)}catch(A){}return g})(),Yt=(function(){return!!document.createElement("canvas").getContext})(),Ae=!!(document.createElementNS&&M("svg").createSVGRect),ke=!!Ae&&(function(){var g=document.createElement("div");return g.innerHTML="<svg/>",(g.firstChild&&g.firstChild.namespaceURI)==="http://www.w3.org/2000/svg"})(),Be=!Ae&&(function(){try{var g=document.createElement("div");g.innerHTML='<v:shape adj="1"/>';var j=g.firstChild;return j.style.behavior="url(#default#VML)",j&&typeof j.adj=="object"}catch(A){return!1}})(),yt=navigator.platform.indexOf("Mac")===0,Me=navigator.platform.indexOf("Linux")===0;function Ke(g){return navigator.userAgent.toLowerCase().indexOf(g)>=0}var Xe={ie:le,ielt9:Fe,edge:ze,webkit:Re,android:De,android23:Et,androidStock:Ie,opera:$e,chrome:Qe,gecko:at,safari:Ct,phantom:vt,opera12:er,win:nr,ie3d:dt,webkit3d:He,gecko3d:it,any3d:Ue,mobile:Ve,mobileWebkit:lt,mobileWebkit3d:st,msPointer:Mt,pointer:Ot,touch:zt,touchNative:Pt,mobileOpera:Tt,mobileGecko:Gt,retina:Ye,passiveEvents:kt,canvas:Yt,svg:Ae,vml:Be,inlineSvg:ke,mac:yt,linux:Me},oe=Xe.msPointer?"MSPointerDown":"pointerdown",_e=Xe.msPointer?"MSPointerMove":"pointermove",ve=Xe.msPointer?"MSPointerUp":"pointerup",Se=Xe.msPointer?"MSPointerCancel":"pointercancel",Ce={touchstart:oe,touchmove:_e,touchend:ve,touchcancel:Se},Pe={touchstart:Wt,touchmove:pt,touchend:pt,touchcancel:pt},rt={},ut=!1;function et(g,j,A){return j==="touchstart"&&Xt(),Pe[j]?(A=Pe[j].bind(this,A),g.addEventListener(Ce[j],A,!1),A):(console.warn("wrong event specified:",j),f)}function nt(g,j,A){if(!Ce[j]){console.warn("wrong event specified:",j);return}g.removeEventListener(Ce[j],A,!1)}function ct(g){rt[g.pointerId]=g}function $t(g){rt[g.pointerId]&&(rt[g.pointerId]=g)}function Ut(g){delete rt[g.pointerId]}function Xt(){ut||(document.addEventListener(oe,ct,!0),document.addEventListener(_e,$t,!0),document.addEventListener(ve,Ut,!0),document.addEventListener(Se,Ut,!0),ut=!0)}function pt(g,j){if(j.pointerType!==(j.MSPOINTER_TYPE_MOUSE||"mouse")){j.touches=[];for(var A in rt)j.touches.push(rt[A]);j.changedTouches=[j],g(j)}}function Wt(g,j){j.MSPOINTER_TYPE_TOUCH&&j.pointerType===j.MSPOINTER_TYPE_TOUCH&&Za(j),pt(g,j)}function rr(g){var j={},A,W;for(W in g)A=g[W],j[W]=A&&A.bind?A.bind(g):A;return g=j,j.type="dblclick",j.detail=2,j.isTrusted=!1,j._simulated=!0,j}var Mr=200;function Br(g,j){g.addEventListener("dblclick",j);var A=0,W;function ce(Ne){if(Ne.detail!==1){W=Ne.detail;return}if(!(Ne.pointerType==="mouse"||Ne.sourceCapabilities&&!Ne.sourceCapabilities.firesTouchEvents)){var Ge=Jo(Ne);if(!(Ge.some(function(Nt){return Nt instanceof HTMLLabelElement&&Nt.attributes.for})&&!Ge.some(function(Nt){return Nt instanceof HTMLInputElement||Nt instanceof HTMLSelectElement}))){var xt=Date.now();xt-A<=Mr?(W++,W===2&&j(rr(Ne))):W=1,A=xt}}}return g.addEventListener("click",ce),{dblclick:j,simDblclick:ce}}function Yr(g,j){g.removeEventListener("dblclick",j.dblclick),g.removeEventListener("click",j.simDblclick)}var ma=Bn(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),ps=Bn(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),hn=ps==="webkitTransition"||ps==="OTransition"?ps+"End":"transitionend";function Rs(g){return typeof g=="string"?document.getElementById(g):g}function Un(g,j){var A=g.style[j]||g.currentStyle&&g.currentStyle[j];if((!A||A==="auto")&&document.defaultView){var W=document.defaultView.getComputedStyle(g,null);A=W?W[j]:null}return A==="auto"?null:A}function Tr(g,j,A){var W=document.createElement(g);return W.className=j||"",A&&A.appendChild(W),W}function Ir(g){var j=g.parentNode;j&&j.removeChild(g)}function ws(g){for(;g.firstChild;)g.removeChild(g.firstChild)}function Ca(g){var j=g.parentNode;j&&j.lastChild!==g&&j.appendChild(g)}function pn(g){var j=g.parentNode;j&&j.firstChild!==g&&j.insertBefore(g,j.firstChild)}function mt(g,j){if(g.classList!==void 0)return g.classList.contains(j);var A=Oe(g);return A.length>0&&new RegExp("(^|\\s)"+j+"(\\s|$)").test(A)}function ft(g,j){if(g.classList!==void 0)for(var A=w(j),W=0,ce=A.length;W<ce;W++)g.classList.add(A[W]);else if(!mt(g,j)){var Ne=Oe(g);vr(g,(Ne?Ne+" ":"")+j)}}function dr(g,j){g.classList!==void 0?g.classList.remove(j):vr(g,b((" "+Oe(g)+" ").replace(" "+j+" "," ")))}function vr(g,j){g.className.baseVal===void 0?g.className=j:g.className.baseVal=j}function Oe(g){return g.correspondingElement&&(g=g.correspondingElement),g.className.baseVal===void 0?g.className:g.className.baseVal}function ar(g,j){"opacity"in g.style?g.style.opacity=j:"filter"in g.style&&us(g,j)}function us(g,j){var A=!1,W="DXImageTransform.Microsoft.Alpha";try{A=g.filters.item(W)}catch(ce){if(j===1)return}j=Math.round(j*100),A?(A.Enabled=j!==100,A.Opacity=j):g.style.filter+=" progid:"+W+"(opacity="+j+")"}function Bn(g){for(var j=document.documentElement.style,A=0;A<g.length;A++)if(g[A]in j)return g[A];return!1}function Ba(g,j,A){var W=j||new U(0,0);g.style[ma]=(Xe.ie3d?"translate("+W.x+"px,"+W.y+"px)":"translate3d("+W.x+"px,"+W.y+"px,0)")+(A?" scale("+A+")":"")}function Sr(g,j){g._leaflet_pos=j,Xe.any3d?Ba(g,j):(g.style.left=j.x+"px",g.style.top=j.y+"px")}function ji(g){return g._leaflet_pos||new U(0,0)}var _i,js,fo;if("onselectstart"in document)_i=function(){mr(window,"selectstart",Za)},js=function(){Hr(window,"selectstart",Za)};else{var xo=Bn(["userSelect","WebkitUserSelect","OUserSelect","MozUserSelect","msUserSelect"]);_i=function(){if(xo){var g=document.documentElement.style;fo=g[xo],g[xo]="none"}},js=function(){xo&&(document.documentElement.style[xo]=fo,fo=void 0)}}function Go(){mr(window,"dragstart",Za)}function Ko(){Hr(window,"dragstart",Za)}var Sl,Vc;function Yo(g){for(;g.tabIndex===-1;)g=g.parentNode;g.style&&(gs(),Sl=g,Vc=g.style.outlineStyle,g.style.outlineStyle="none",mr(window,"keydown",gs))}function gs(){Sl&&(Sl.style.outlineStyle=Vc,Sl=void 0,Vc=void 0,Hr(window,"keydown",gs))}function ot(g){do g=g.parentNode;while((!g.offsetWidth||!g.offsetHeight)&&g!==document.body);return g}function Lt(g){var j=g.getBoundingClientRect();return{x:j.width/g.offsetWidth||1,y:j.height/g.offsetHeight||1,boundingClientRect:j}}var oa={__proto__:null,TRANSFORM:ma,TRANSITION:ps,TRANSITION_END:hn,get:Rs,getStyle:Un,create:Tr,remove:Ir,empty:ws,toFront:Ca,toBack:pn,hasClass:mt,addClass:ft,removeClass:dr,setClass:vr,getClass:Oe,setOpacity:ar,testProp:Bn,setTransform:Ba,setPosition:Sr,getPosition:ji,get disableTextSelection(){return _i},get enableTextSelection(){return js},disableImageDrag:Go,enableImageDrag:Ko,preventOutline:Yo,restoreOutline:gs,getSizedParentNode:ot,getScale:Lt};function mr(g,j,A,W){if(j&&typeof j=="object")for(var ce in j)gn(g,ce,j[ce],A);else{j=w(j);for(var Ne=0,Ge=j.length;Ne<Ge;Ne++)gn(g,j[Ne],A,W)}return this}var Wa="_leaflet_events";function Hr(g,j,A,W){if(arguments.length===1)Ts(g),delete g[Wa];else if(j&&typeof j=="object")for(var ce in j)Wn(g,ce,j[ce],A);else if(j=w(j),arguments.length===2)Ts(g,function(xt){return O(j,xt)!==-1});else for(var Ne=0,Ge=j.length;Ne<Ge;Ne++)Wn(g,j[Ne],A,W);return this}function Ts(g,j){for(var A in g[Wa]){var W=A.split(/\d/)[0];(!j||j(W))&&Wn(g,W,null,null,A)}}var ki={mouseenter:"mouseover",mouseleave:"mouseout",wheel:!("onwheel"in window)&&"mousewheel"};function gn(g,j,A,W){var ce=j+c(A)+(W?"_"+c(W):"");if(g[Wa]&&g[Wa][ce])return this;var Ne=function(xt){return A.call(W||g,xt||window.event)},Ge=Ne;!Xe.touchNative&&Xe.pointer&&j.indexOf("touch")===0?Ne=et(g,j,Ne):Xe.touch&&j==="dblclick"?Ne=Br(g,Ne):"addEventListener"in g?j==="touchstart"||j==="touchmove"||j==="wheel"||j==="mousewheel"?g.addEventListener(ki[j]||j,Ne,Xe.passiveEvents?{passive:!1}:!1):j==="mouseenter"||j==="mouseleave"?(Ne=function(xt){xt=xt||window.event,bo(g,xt)&&Ge(xt)},g.addEventListener(ki[j],Ne,!1)):g.addEventListener(j,Ge,!1):g.attachEvent("on"+j,Ne),g[Wa]=g[Wa]||{},g[Wa][ce]=Ne}function Wn(g,j,A,W,ce){ce=ce||j+c(A)+(W?"_"+c(W):"");var Ne=g[Wa]&&g[Wa][ce];if(!Ne)return this;!Xe.touchNative&&Xe.pointer&&j.indexOf("touch")===0?nt(g,j,Ne):Xe.touch&&j==="dblclick"?Yr(g,Ne):"removeEventListener"in g?g.removeEventListener(ki[j]||j,Ne,!1):g.detachEvent("on"+j,Ne),g[Wa][ce]=null}function Cn(g){return g.stopPropagation?g.stopPropagation():g.originalEvent?g.originalEvent._stopped=!0:g.cancelBubble=!0,this}function Hn(g){return gn(g,"wheel",Cn),this}function yo(g){return mr(g,"mousedown touchstart dblclick contextmenu",Cn),g._leaflet_disable_click=!0,this}function Za(g){return g.preventDefault?g.preventDefault():g.returnValue=!1,this}function ni(g){return Za(g),Cn(g),this}function Jo(g){if(g.composedPath)return g.composedPath();for(var j=[],A=g.target;A;)j.push(A),A=A.parentNode;return j}function hc(g,j){if(!j)return new U(g.clientX,g.clientY);var A=Lt(j),W=A.boundingClientRect;return new U((g.clientX-W.left)/A.x-j.clientLeft,(g.clientY-W.top)/A.y-j.clientTop)}var d0=Xe.linux&&Xe.chrome?window.devicePixelRatio:Xe.mac?window.devicePixelRatio*3:window.devicePixelRatio>0?2*window.devicePixelRatio:1;function Ms(g){return Xe.edge?g.wheelDeltaY/2:g.deltaY&&g.deltaMode===0?-g.deltaY/d0:g.deltaY&&g.deltaMode===1?-g.deltaY*20:g.deltaY&&g.deltaMode===2?-g.deltaY*60:g.deltaX||g.deltaZ?0:g.wheelDelta?(g.wheelDeltaY||g.wheelDelta)/2:g.detail&&Math.abs(g.detail)<32765?-g.detail*20:g.detail?g.detail/-32765*60:0}function bo(g,j){var A=j.relatedTarget;if(!A)return!0;try{for(;A&&A!==g;)A=A.parentNode}catch(W){return!1}return A!==g}var Gc={__proto__:null,on:mr,off:Hr,stopPropagation:Cn,disableScrollPropagation:Hn,disableClickPropagation:yo,preventDefault:Za,stop:ni,getPropagationPath:Jo,getMousePosition:hc,getWheelDelta:Ms,isExternalTarget:bo,addListener:mr,removeListener:Hr},Cl=H.extend({run:function(g,j,A,W){this.stop(),this._el=g,this._inProgress=!0,this._duration=A||.25,this._easeOutPower=1/Math.max(W||.5,.2),this._startPos=ji(g),this._offset=j.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=ae(this._animate,this),this._step()},_step:function(g){var j=+new Date-this._startTime,A=this._duration*1e3;j<A?this._runFrame(this._easeOut(j/A),g):(this._runFrame(1),this._complete())},_runFrame:function(g,j){var A=this._startPos.add(this._offset.multiplyBy(g));j&&A._round(),Sr(this._el,A),this.fire("step")},_complete:function(){ee(this._animId),this._inProgress=!1,this.fire("end")},_easeOut:function(g){return 1-Math.pow(1-g,this._easeOutPower)}}),la=H.extend({options:{crs:ye,center:void 0,zoom:void 0,minZoom:void 0,maxZoom:void 0,layers:[],maxBounds:void 0,renderer:void 0,zoomAnimation:!0,zoomAnimationThreshold:4,fadeAnimation:!0,markerZoomAnimation:!0,transform3DLimit:8388608,zoomSnap:1,zoomDelta:1,trackResize:!0},initialize:function(g,j){j=v(this,j),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this._initContainer(g),this._initLayout(),this._onResize=o(this._onResize,this),this._initEvents(),j.maxBounds&&this.setMaxBounds(j.maxBounds),j.zoom!==void 0&&(this._zoom=this._limitZoom(j.zoom)),j.center&&j.zoom!==void 0&&this.setView(me(j.center),j.zoom,{reset:!0}),this.callInitHooks(),this._zoomAnimated=ps&&Xe.any3d&&!Xe.mobileOpera&&this.options.zoomAnimation,this._zoomAnimated&&(this._createAnimProxy(),mr(this._proxy,hn,this._catchTransitionEnd,this)),this._addLayers(this.options.layers)},setView:function(g,j,A){if(j=j===void 0?this._zoom:this._limitZoom(j),g=this._limitCenter(me(g),j,this.options.maxBounds),A=A||{},this._stop(),this._loaded&&!A.reset&&A!==!0){A.animate!==void 0&&(A.zoom=n({animate:A.animate},A.zoom),A.pan=n({animate:A.animate,duration:A.duration},A.pan));var W=this._zoom!==j?this._tryAnimatedZoom&&this._tryAnimatedZoom(g,j,A.zoom):this._tryAnimatedPan(g,A.pan);if(W)return clearTimeout(this._sizeTimer),this}return this._resetView(g,j,A.pan&&A.pan.noMoveStart),this},setZoom:function(g,j){return this._loaded?this.setView(this.getCenter(),g,{zoom:j}):(this._zoom=g,this)},zoomIn:function(g,j){return g=g||(Xe.any3d?this.options.zoomDelta:1),this.setZoom(this._zoom+g,j)},zoomOut:function(g,j){return g=g||(Xe.any3d?this.options.zoomDelta:1),this.setZoom(this._zoom-g,j)},setZoomAround:function(g,j,A){var W=this.getZoomScale(j),ce=this.getSize().divideBy(2),Ne=g instanceof U?g:this.latLngToContainerPoint(g),Ge=Ne.subtract(ce).multiplyBy(1-1/W),xt=this.containerPointToLatLng(ce.add(Ge));return this.setView(xt,j,{zoom:A})},_getBoundsCenterZoom:function(g,j){j=j||{},g=g.getBounds?g.getBounds():Q(g);var A=X(j.paddingTopLeft||j.padding||[0,0]),W=X(j.paddingBottomRight||j.padding||[0,0]),ce=this.getBoundsZoom(g,!1,A.add(W));if(ce=typeof j.maxZoom=="number"?Math.min(j.maxZoom,ce):ce,ce===1/0)return{center:g.getCenter(),zoom:ce};var Ne=W.subtract(A).divideBy(2),Ge=this.project(g.getSouthWest(),ce),xt=this.project(g.getNorthEast(),ce),Nt=this.unproject(Ge.add(xt).divideBy(2).add(Ne),ce);return{center:Nt,zoom:ce}},fitBounds:function(g,j){if(g=Q(g),!g.isValid())throw new Error("Bounds are not valid.");var A=this._getBoundsCenterZoom(g,j);return this.setView(A.center,A.zoom,j)},fitWorld:function(g){return this.fitBounds([[-90,-180],[90,180]],g)},panTo:function(g,j){return this.setView(g,this._zoom,{pan:j})},panBy:function(g,j){if(g=X(g).round(),j=j||{},!g.x&&!g.y)return this.fire("moveend");if(j.animate!==!0&&!this.getSize().contains(g))return this._resetView(this.unproject(this.project(this.getCenter()).add(g)),this.getZoom()),this;if(this._panAnim||(this._panAnim=new Cl,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),j.noMoveStart||this.fire("movestart"),j.animate!==!1){ft(this._mapPane,"leaflet-pan-anim");var A=this._getMapPanePos().subtract(g).round();this._panAnim.run(this._mapPane,A,j.duration||.25,j.easeLinearity)}else this._rawPanBy(g),this.fire("move").fire("moveend");return this},flyTo:function(g,j,A){if(A=A||{},A.animate===!1||!Xe.any3d)return this.setView(g,j,A);this._stop();var W=this.project(this.getCenter()),ce=this.project(g),Ne=this.getSize(),Ge=this._zoom;g=me(g),j=j===void 0?Ge:j;var xt=Math.max(Ne.x,Ne.y),Nt=xt*this.getZoomScale(Ge,j),qt=ce.distanceTo(W)||1,cr=1.42,Cr=cr*cr;function Jr(As){var Ll=As?-1:1,md=As?Nt:xt,gg=Nt*Nt-xt*xt+Ll*Cr*Cr*qt*qt,v0=2*md*Cr*qt,w0=gg/v0,vc=Math.sqrt(w0*w0+1)-w0,Fl=vc<1e-9?-18:Math.log(vc);return Fl}function fn(As){return(Math.exp(As)-Math.exp(-As))/2}function Fs(As){return(Math.exp(As)+Math.exp(-As))/2}function Ci(As){return fn(As)/Fs(As)}var Ta=Jr(0);function Ea(As){return xt*(Fs(Ta)/Fs(Ta+cr*As))}function pa(As){return xt*(Fs(Ta)*Ci(Ta+cr*As)-fn(Ta))/Cr}function yc(As){return 1-Math.pow(1-As,1.5)}var Gi=Date.now(),oh=(Jr(1)-Ta)/cr,bc=A.duration?1e3*A.duration:1e3*oh*.8;function pg(){var As=(Date.now()-Gi)/bc,Ll=yc(As)*oh;As<=1?(this._flyToFrame=ae(pg,this),this._move(this.unproject(W.add(ce.subtract(W).multiplyBy(pa(Ll)/qt)),Ge),this.getScaleZoom(xt/Ea(Ll),Ge),{flyTo:!0})):this._move(g,j)._moveEnd(!0)}return this._moveStart(!0,A.noMoveStart),pg.call(this),this},flyToBounds:function(g,j){var A=this._getBoundsCenterZoom(g,j);return this.flyTo(A.center,A.zoom,j)},setMaxBounds:function(g){return g=Q(g),this.listens("moveend",this._panInsideMaxBounds)&&this.off("moveend",this._panInsideMaxBounds),g.isValid()?(this.options.maxBounds=g,this._loaded&&this._panInsideMaxBounds(),this.on("moveend",this._panInsideMaxBounds)):(this.options.maxBounds=null,this)},setMinZoom:function(g){var j=this.options.minZoom;return this.options.minZoom=g,this._loaded&&j!==g&&(this.fire("zoomlevelschange"),this.getZoom()<this.options.minZoom)?this.setZoom(g):this},setMaxZoom:function(g){var j=this.options.maxZoom;return this.options.maxZoom=g,this._loaded&&j!==g&&(this.fire("zoomlevelschange"),this.getZoom()>this.options.maxZoom)?this.setZoom(g):this},panInsideBounds:function(g,j){this._enforcingBounds=!0;var A=this.getCenter(),W=this._limitCenter(A,this._zoom,Q(g));return A.equals(W)||this.panTo(W,j),this._enforcingBounds=!1,this},panInside:function(g,j){j=j||{};var A=X(j.paddingTopLeft||j.padding||[0,0]),W=X(j.paddingBottomRight||j.padding||[0,0]),ce=this.project(this.getCenter()),Ne=this.project(g),Ge=this.getPixelBounds(),xt=I([Ge.min.add(A),Ge.max.subtract(W)]),Nt=xt.getSize();if(!xt.contains(Ne)){this._enforcingBounds=!0;var qt=Ne.subtract(xt.getCenter()),cr=xt.extend(Ne).getSize().subtract(Nt);ce.x+=qt.x<0?-cr.x:cr.x,ce.y+=qt.y<0?-cr.y:cr.y,this.panTo(this.unproject(ce),j),this._enforcingBounds=!1}return this},invalidateSize:function(g){if(!this._loaded)return this;g=n({animate:!1,pan:!0},g===!0?{animate:!0}:g);var j=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var A=this.getSize(),W=j.divideBy(2).round(),ce=A.divideBy(2).round(),Ne=W.subtract(ce);return!Ne.x&&!Ne.y?this:(g.animate&&g.pan?this.panBy(Ne):(g.pan&&this._rawPanBy(Ne),this.fire("move"),g.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(o(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:j,newSize:A}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(g){if(g=this._locateOptions=n({timeout:1e4,watch:!1},g),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var j=o(this._handleGeolocationResponse,this),A=o(this._handleGeolocationError,this);return g.watch?this._locationWatchId=navigator.geolocation.watchPosition(j,A,g):navigator.geolocation.getCurrentPosition(j,A,g),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(g){if(this._container._leaflet_id){var j=g.code,A=g.message||(j===1?"permission denied":j===2?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:j,message:"Geolocation error: "+A+"."})}},_handleGeolocationResponse:function(g){if(this._container._leaflet_id){var j=g.coords.latitude,A=g.coords.longitude,W=new ie(j,A),ce=W.toBounds(g.coords.accuracy*2),Ne=this._locateOptions;if(Ne.setView){var Ge=this.getBoundsZoom(ce);this.setView(W,Ne.maxZoom?Math.min(Ge,Ne.maxZoom):Ge)}var xt={latlng:W,bounds:ce,timestamp:g.timestamp};for(var Nt in g.coords)typeof g.coords[Nt]=="number"&&(xt[Nt]=g.coords[Nt]);this.fire("locationfound",xt)}},addHandler:function(g,j){if(!j)return this;var A=this[g]=new j(this);return this._handlers.push(A),this.options[g]&&A.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch(j){this._container._leaflet_id=void 0,this._containerId=void 0}this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),Ir(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(ee(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload");var g;for(g in this._layers)this._layers[g].remove();for(g in this._panes)Ir(this._panes[g]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(g,j){var A="leaflet-pane"+(g?" leaflet-"+g.replace("Pane","")+"-pane":""),W=Tr("div",A,j||this._mapPane);return g&&(this._panes[g]=W),W},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var g=this.getPixelBounds(),j=this.unproject(g.getBottomLeft()),A=this.unproject(g.getTopRight());return new B(j,A)},getMinZoom:function(){return this.options.minZoom===void 0?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===void 0?this._layersMaxZoom===void 0?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(g,j,A){g=Q(g),A=X(A||[0,0]);var W=this.getZoom()||0,ce=this.getMinZoom(),Ne=this.getMaxZoom(),Ge=g.getNorthWest(),xt=g.getSouthEast(),Nt=this.getSize().subtract(A),qt=I(this.project(xt,W),this.project(Ge,W)).getSize(),cr=Xe.any3d?this.options.zoomSnap:1,Cr=Nt.x/qt.x,Jr=Nt.y/qt.y,fn=j?Math.max(Cr,Jr):Math.min(Cr,Jr);return W=this.getScaleZoom(fn,W),cr&&(W=Math.round(W/(cr/100))*(cr/100),W=j?Math.ceil(W/cr)*cr:Math.floor(W/cr)*cr),Math.max(ce,Math.min(Ne,W))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new U(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(g,j){var A=this._getTopLeftPoint(g,j);return new V(A,A.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(g){return this.options.crs.getProjectedBounds(g===void 0?this.getZoom():g)},getPane:function(g){return typeof g=="string"?this._panes[g]:g},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(g,j){var A=this.options.crs;return j=j===void 0?this._zoom:j,A.scale(g)/A.scale(j)},getScaleZoom:function(g,j){var A=this.options.crs;j=j===void 0?this._zoom:j;var W=A.zoom(g*A.scale(j));return isNaN(W)?1/0:W},project:function(g,j){return j=j===void 0?this._zoom:j,this.options.crs.latLngToPoint(me(g),j)},unproject:function(g,j){return j=j===void 0?this._zoom:j,this.options.crs.pointToLatLng(X(g),j)},layerPointToLatLng:function(g){var j=X(g).add(this.getPixelOrigin());return this.unproject(j)},latLngToLayerPoint:function(g){var j=this.project(me(g))._round();return j._subtract(this.getPixelOrigin())},wrapLatLng:function(g){return this.options.crs.wrapLatLng(me(g))},wrapLatLngBounds:function(g){return this.options.crs.wrapLatLngBounds(Q(g))},distance:function(g,j){return this.options.crs.distance(me(g),me(j))},containerPointToLayerPoint:function(g){return X(g).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(g){return X(g).add(this._getMapPanePos())},containerPointToLatLng:function(g){var j=this.containerPointToLayerPoint(X(g));return this.layerPointToLatLng(j)},latLngToContainerPoint:function(g){return this.layerPointToContainerPoint(this.latLngToLayerPoint(me(g)))},mouseEventToContainerPoint:function(g){return hc(g,this._container)},mouseEventToLayerPoint:function(g){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(g))},mouseEventToLatLng:function(g){return this.layerPointToLatLng(this.mouseEventToLayerPoint(g))},_initContainer:function(g){var j=this._container=Rs(g);if(j){if(j._leaflet_id)throw new Error("Map container is already initialized.")}else throw new Error("Map container not found.");mr(j,"scroll",this._onScroll,this),this._containerId=c(j)},_initLayout:function(){var g=this._container;this._fadeAnimated=this.options.fadeAnimation&&Xe.any3d,ft(g,"leaflet-container"+(Xe.touch?" leaflet-touch":"")+(Xe.retina?" leaflet-retina":"")+(Xe.ielt9?" leaflet-oldie":"")+(Xe.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var j=Un(g,"position");j!=="absolute"&&j!=="relative"&&j!=="fixed"&&j!=="sticky"&&(g.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var g=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),Sr(this._mapPane,new U(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(ft(g.markerPane,"leaflet-zoom-hide"),ft(g.shadowPane,"leaflet-zoom-hide"))},_resetView:function(g,j,A){Sr(this._mapPane,new U(0,0));var W=!this._loaded;this._loaded=!0,j=this._limitZoom(j),this.fire("viewprereset");var ce=this._zoom!==j;this._moveStart(ce,A)._move(g,j)._moveEnd(ce),this.fire("viewreset"),W&&this.fire("load")},_moveStart:function(g,j){return g&&this.fire("zoomstart"),j||this.fire("movestart"),this},_move:function(g,j,A,W){j===void 0&&(j=this._zoom);var ce=this._zoom!==j;return this._zoom=j,this._lastCenter=g,this._pixelOrigin=this._getNewPixelOrigin(g),W?A&&A.pinch&&this.fire("zoom",A):((ce||A&&A.pinch)&&this.fire("zoom",A),this.fire("move",A)),this},_moveEnd:function(g){return g&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return ee(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(g){Sr(this._mapPane,this._getMapPanePos().subtract(g))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(g){this._targets={},this._targets[c(this._container)]=this;var j=g?Hr:mr;j(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&j(window,"resize",this._onResize,this),Xe.any3d&&this.options.transform3DLimit&&(g?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){ee(this._resizeRequest),this._resizeRequest=ae(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var g=this._getMapPanePos();Math.max(Math.abs(g.x),Math.abs(g.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(g,j){for(var A=[],W,ce=j==="mouseout"||j==="mouseover",Ne=g.target||g.srcElement,Ge=!1;Ne;){if(W=this._targets[c(Ne)],W&&(j==="click"||j==="preclick")&&this._draggableMoved(W)){Ge=!0;break}if(W&&W.listens(j,!0)&&(ce&&!bo(Ne,g)||(A.push(W),ce))||Ne===this._container)break;Ne=Ne.parentNode}return!A.length&&!Ge&&!ce&&this.listens(j,!0)&&(A=[this]),A},_isClickDisabled:function(g){for(;g&&g!==this._container;){if(g._leaflet_disable_click)return!0;g=g.parentNode}},_handleDOMEvent:function(g){var j=g.target||g.srcElement;if(!(!this._loaded||j._leaflet_disable_events||g.type==="click"&&this._isClickDisabled(j))){var A=g.type;A==="mousedown"&&Yo(j),this._fireDOMEvent(g,A)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(g,j,A){if(g.type==="click"){var W=n({},g);W.type="preclick",this._fireDOMEvent(W,W.type,A)}var ce=this._findEventTargets(g,j);if(A){for(var Ne=[],Ge=0;Ge<A.length;Ge++)A[Ge].listens(j,!0)&&Ne.push(A[Ge]);ce=Ne.concat(ce)}if(ce.length){j==="contextmenu"&&Za(g);var xt=ce[0],Nt={originalEvent:g};if(g.type!=="keypress"&&g.type!=="keydown"&&g.type!=="keyup"){var qt=xt.getLatLng&&(!xt._radius||xt._radius<=10);Nt.containerPoint=qt?this.latLngToContainerPoint(xt.getLatLng()):this.mouseEventToContainerPoint(g),Nt.layerPoint=this.containerPointToLayerPoint(Nt.containerPoint),Nt.latlng=qt?xt.getLatLng():this.layerPointToLatLng(Nt.layerPoint)}for(Ge=0;Ge<ce.length;Ge++)if(ce[Ge].fire(j,Nt,!0),Nt.originalEvent._stopped||ce[Ge].options.bubblingMouseEvents===!1&&O(this._mouseEvents,j)!==-1)return}},_draggableMoved:function(g){return g=g.dragging&&g.dragging.enabled()?g:this,g.dragging&&g.dragging.moved()||this.boxZoom&&this.boxZoom.moved()},_clearHandlers:function(){for(var g=0,j=this._handlers.length;g<j;g++)this._handlers[g].disable()},whenReady:function(g,j){return this._loaded?g.call(j||this,{target:this}):this.on("load",g,j),this},_getMapPanePos:function(){return ji(this._mapPane)||new U(0,0)},_moved:function(){var g=this._getMapPanePos();return g&&!g.equals([0,0])},_getTopLeftPoint:function(g,j){var A=g&&j!==void 0?this._getNewPixelOrigin(g,j):this.getPixelOrigin();return A.subtract(this._getMapPanePos())},_getNewPixelOrigin:function(g,j){var A=this.getSize()._divideBy(2);return this.project(g,j)._subtract(A)._add(this._getMapPanePos())._round()},_latLngToNewLayerPoint:function(g,j,A){var W=this._getNewPixelOrigin(A,j);return this.project(g,j)._subtract(W)},_latLngBoundsToNewLayerBounds:function(g,j,A){var W=this._getNewPixelOrigin(A,j);return I([this.project(g.getSouthWest(),j)._subtract(W),this.project(g.getNorthWest(),j)._subtract(W),this.project(g.getSouthEast(),j)._subtract(W),this.project(g.getNorthEast(),j)._subtract(W)])},_getCenterLayerPoint:function(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))},_getCenterOffset:function(g){return this.latLngToLayerPoint(g).subtract(this._getCenterLayerPoint())},_limitCenter:function(g,j,A){if(!A)return g;var W=this.project(g,j),ce=this.getSize().divideBy(2),Ne=new V(W.subtract(ce),W.add(ce)),Ge=this._getBoundsOffset(Ne,A,j);return Math.abs(Ge.x)<=1&&Math.abs(Ge.y)<=1?g:this.unproject(W.add(Ge),j)},_limitOffset:function(g,j){if(!j)return g;var A=this.getPixelBounds(),W=new V(A.min.add(g),A.max.add(g));return g.add(this._getBoundsOffset(W,j))},_getBoundsOffset:function(g,j,A){var W=I(this.project(j.getNorthEast(),A),this.project(j.getSouthWest(),A)),ce=W.min.subtract(g.min),Ne=W.max.subtract(g.max),Ge=this._rebound(ce.x,-Ne.x),xt=this._rebound(ce.y,-Ne.y);return new U(Ge,xt)},_rebound:function(g,j){return g+j>0?Math.round(g-j)/2:Math.max(0,Math.ceil(g))-Math.max(0,Math.floor(j))},_limitZoom:function(g){var j=this.getMinZoom(),A=this.getMaxZoom(),W=Xe.any3d?this.options.zoomSnap:1;return W&&(g=Math.round(g/W)*W),Math.max(j,Math.min(A,g))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){dr(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(g,j){var A=this._getCenterOffset(g)._trunc();return(j&&j.animate)!==!0&&!this.getSize().contains(A)?!1:(this.panBy(A,j),!0)},_createAnimProxy:function(){var g=this._proxy=Tr("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(g),this.on("zoomanim",function(j){var A=ma,W=this._proxy.style[A];Ba(this._proxy,this.project(j.center,j.zoom),this.getZoomScale(j.zoom,1)),W===this._proxy.style[A]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){Ir(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var g=this.getCenter(),j=this.getZoom();Ba(this._proxy,this.project(g,j),this.getZoomScale(j,1))},_catchTransitionEnd:function(g){this._animatingZoom&&g.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(g,j,A){if(this._animatingZoom)return!0;if(A=A||{},!this._zoomAnimated||A.animate===!1||this._nothingToAnimate()||Math.abs(j-this._zoom)>this.options.zoomAnimationThreshold)return!1;var W=this.getZoomScale(j),ce=this._getCenterOffset(g)._divideBy(1-1/W);return A.animate!==!0&&!this.getSize().contains(ce)?!1:(ae(function(){this._moveStart(!0,A.noMoveStart||!1)._animateZoom(g,j,!0)},this),!0)},_animateZoom:function(g,j,A,W){this._mapPane&&(A&&(this._animatingZoom=!0,this._animateToCenter=g,this._animateToZoom=j,ft(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:g,zoom:j,noUpdate:W}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(o(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&dr(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});function du(g,j){return new la(g,j)}var Tn=te.extend({options:{position:"topright"},initialize:function(g){v(this,g)},getPosition:function(){return this.options.position},setPosition:function(g){var j=this._map;return j&&j.removeControl(this),this.options.position=g,j&&j.addControl(this),this},getContainer:function(){return this._container},addTo:function(g){this.remove(),this._map=g;var j=this._container=this.onAdd(g),A=this.getPosition(),W=g._controlCorners[A];return ft(j,"leaflet-control"),A.indexOf("bottom")!==-1?W.insertBefore(j,W.firstChild):W.appendChild(j),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(Ir(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(g){this._map&&g&&g.screenX>0&&g.screenY>0&&this._map.getContainer().focus()}}),Ii=function(g){return new Tn(g)};la.include({addControl:function(g){return g.addTo(this),this},removeControl:function(g){return g.remove(),this},_initControlPos:function(){var g=this._controlCorners={},j="leaflet-",A=this._controlContainer=Tr("div",j+"control-container",this._container);function W(ce,Ne){var Ge=j+ce+" "+j+Ne;g[ce+Ne]=Tr("div",Ge,A)}W("top","left"),W("top","right"),W("bottom","left"),W("bottom","right")},_clearControlPos:function(){for(var g in this._controlCorners)Ir(this._controlCorners[g]);Ir(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var Kc=Tn.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(g,j,A,W){return A<W?-1:W<A?1:0}},initialize:function(g,j,A){v(this,A),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,this._preventClick=!1;for(var W in g)this._addLayer(g[W],W);for(W in j)this._addLayer(j[W],W,!0)},onAdd:function(g){this._initLayout(),this._update(),this._map=g,g.on("zoomend",this._checkDisabledLayers,this);for(var j=0;j<this._layers.length;j++)this._layers[j].layer.on("add remove",this._onLayerChange,this);return this._container},addTo:function(g){return Tn.prototype.addTo.call(this,g),this._expandIfNotCollapsed()},onRemove:function(){this._map.off("zoomend",this._checkDisabledLayers,this);for(var g=0;g<this._layers.length;g++)this._layers[g].layer.off("add remove",this._onLayerChange,this)},addBaseLayer:function(g,j){return this._addLayer(g,j),this._map?this._update():this},addOverlay:function(g,j){return this._addLayer(g,j,!0),this._map?this._update():this},removeLayer:function(g){g.off("add remove",this._onLayerChange,this);var j=this._getLayer(c(g));return j&&this._layers.splice(this._layers.indexOf(j),1),this._map?this._update():this},expand:function(){ft(this._container,"leaflet-control-layers-expanded"),this._section.style.height=null;var g=this._map.getSize().y-(this._container.offsetTop+50);return g<this._section.clientHeight?(ft(this._section,"leaflet-control-layers-scrollbar"),this._section.style.height=g+"px"):dr(this._section,"leaflet-control-layers-scrollbar"),this._checkDisabledLayers(),this},collapse:function(){return dr(this._container,"leaflet-control-layers-expanded"),this},_initLayout:function(){var g="leaflet-control-layers",j=this._container=Tr("div",g),A=this.options.collapsed;j.setAttribute("aria-haspopup",!0),yo(j),Hn(j);var W=this._section=Tr("section",g+"-list");A&&(this._map.on("click",this.collapse,this),mr(j,{mouseenter:this._expandSafely,mouseleave:this.collapse},this));var ce=this._layersLink=Tr("a",g+"-toggle",j);ce.href="#",ce.title="Layers",ce.setAttribute("role","button"),mr(ce,{keydown:function(Ne){Ne.keyCode===13&&this._expandSafely()},click:function(Ne){Za(Ne),this._expandSafely()}},this),A||this.expand(),this._baseLayersList=Tr("div",g+"-base",W),this._separator=Tr("div",g+"-separator",W),this._overlaysList=Tr("div",g+"-overlays",W),j.appendChild(W)},_getLayer:function(g){for(var j=0;j<this._layers.length;j++)if(this._layers[j]&&c(this._layers[j].layer)===g)return this._layers[j]},_addLayer:function(g,j,A){this._map&&g.on("add remove",this._onLayerChange,this),this._layers.push({layer:g,name:j,overlay:A}),this.options.sortLayers&&this._layers.sort(o(function(W,ce){return this.options.sortFunction(W.layer,ce.layer,W.name,ce.name)},this)),this.options.autoZIndex&&g.setZIndex&&(this._lastZIndex++,g.setZIndex(this._lastZIndex)),this._expandIfNotCollapsed()},_update:function(){if(!this._container)return this;ws(this._baseLayersList),ws(this._overlaysList),this._layerControlInputs=[];var g,j,A,W,ce=0;for(A=0;A<this._layers.length;A++)W=this._layers[A],this._addItem(W),j=j||W.overlay,g=g||!W.overlay,ce+=W.overlay?0:1;return this.options.hideSingleBase&&(g=g&&ce>1,this._baseLayersList.style.display=g?"":"none"),this._separator.style.display=j&&g?"":"none",this},_onLayerChange:function(g){this._handlingClick||this._update();var j=this._getLayer(c(g.target)),A=j.overlay?g.type==="add"?"overlayadd":"overlayremove":g.type==="add"?"baselayerchange":null;A&&this._map.fire(A,j)},_createRadioElement:function(g,j){var A='<input type="radio" class="leaflet-control-layers-selector" name="'+g+'"'+(j?' checked="checked"':"")+"/>",W=document.createElement("div");return W.innerHTML=A,W.firstChild},_addItem:function(g){var j=document.createElement("label"),A=this._map.hasLayer(g.layer),W;g.overlay?(W=document.createElement("input"),W.type="checkbox",W.className="leaflet-control-layers-selector",W.defaultChecked=A):W=this._createRadioElement("leaflet-base-layers_"+c(this),A),this._layerControlInputs.push(W),W.layerId=c(g.layer),mr(W,"click",this._onInputClick,this);var ce=document.createElement("span");ce.innerHTML=" "+g.name;var Ne=document.createElement("span");j.appendChild(Ne),Ne.appendChild(W),Ne.appendChild(ce);var Ge=g.overlay?this._overlaysList:this._baseLayersList;return Ge.appendChild(j),this._checkDisabledLayers(),j},_onInputClick:function(){if(!this._preventClick){var g=this._layerControlInputs,j,A,W=[],ce=[];this._handlingClick=!0;for(var Ne=g.length-1;Ne>=0;Ne--)j=g[Ne],A=this._getLayer(j.layerId).layer,j.checked?W.push(A):j.checked||ce.push(A);for(Ne=0;Ne<ce.length;Ne++)this._map.hasLayer(ce[Ne])&&this._map.removeLayer(ce[Ne]);for(Ne=0;Ne<W.length;Ne++)this._map.hasLayer(W[Ne])||this._map.addLayer(W[Ne]);this._handlingClick=!1,this._refocusOnMap()}},_checkDisabledLayers:function(){for(var g=this._layerControlInputs,j,A,W=this._map.getZoom(),ce=g.length-1;ce>=0;ce--)j=g[ce],A=this._getLayer(j.layerId).layer,j.disabled=A.options.minZoom!==void 0&&W<A.options.minZoom||A.options.maxZoom!==void 0&&W>A.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var g=this._section;this._preventClick=!0,mr(g,"click",Za),this.expand();var j=this;setTimeout(function(){Hr(g,"click",Za),j._preventClick=!1})}}),Km=function(g,j,A){return new Kc(g,j,A)},u0=Tn.extend({options:{position:"topleft",zoomInText:'<span aria-hidden="true">+</span>',zoomInTitle:"Zoom in",zoomOutText:'<span aria-hidden="true">−</span>',zoomOutTitle:"Zoom out"},onAdd:function(g){var j="leaflet-control-zoom",A=Tr("div",j+" leaflet-bar"),W=this.options;return this._zoomInButton=this._createButton(W.zoomInText,W.zoomInTitle,j+"-in",A,this._zoomIn),this._zoomOutButton=this._createButton(W.zoomOutText,W.zoomOutTitle,j+"-out",A,this._zoomOut),this._updateDisabled(),g.on("zoomend zoomlevelschange",this._updateDisabled,this),A},onRemove:function(g){g.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(g){!this._disabled&&this._map._zoom<this._map.getMaxZoom()&&this._map.zoomIn(this._map.options.zoomDelta*(g.shiftKey?3:1))},_zoomOut:function(g){!this._disabled&&this._map._zoom>this._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(g.shiftKey?3:1))},_createButton:function(g,j,A,W,ce){var Ne=Tr("a",A,W);return Ne.innerHTML=g,Ne.href="#",Ne.title=j,Ne.setAttribute("role","button"),Ne.setAttribute("aria-label",j),yo(Ne),mr(Ne,"click",ni),mr(Ne,"click",ce,this),mr(Ne,"click",this._refocusOnMap,this),Ne},_updateDisabled:function(){var g=this._map,j="leaflet-disabled";dr(this._zoomInButton,j),dr(this._zoomOutButton,j),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||g._zoom===g.getMinZoom())&&(ft(this._zoomOutButton,j),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||g._zoom===g.getMaxZoom())&&(ft(this._zoomInButton,j),this._zoomInButton.setAttribute("aria-disabled","true"))}});la.mergeOptions({zoomControl:!0}),la.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new u0,this.addControl(this.zoomControl))});var ng=function(g){return new u0(g)},vo=Tn.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(g){var j="leaflet-control-scale",A=Tr("div",j),W=this.options;return this._addScales(W,j+"-line",A),g.on(W.updateWhenIdle?"moveend":"move",this._update,this),g.whenReady(this._update,this),A},onRemove:function(g){g.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(g,j,A){g.metric&&(this._mScale=Tr("div",j,A)),g.imperial&&(this._iScale=Tr("div",j,A))},_update:function(){var g=this._map,j=g.getSize().y/2,A=g.distance(g.containerPointToLatLng([0,j]),g.containerPointToLatLng([this.options.maxWidth,j]));this._updateScales(A)},_updateScales:function(g){this.options.metric&&g&&this._updateMetric(g),this.options.imperial&&g&&this._updateImperial(g)},_updateMetric:function(g){var j=this._getRoundNum(g),A=j<1e3?j+" m":j/1e3+" km";this._updateScale(this._mScale,A,j/g)},_updateImperial:function(g){var j=g*3.2808399,A,W,ce;j>5280?(A=j/5280,W=this._getRoundNum(A),this._updateScale(this._iScale,W+" mi",W/A)):(ce=this._getRoundNum(j),this._updateScale(this._iScale,ce+" ft",ce/j))},_updateScale:function(g,j,A){g.style.width=Math.round(this.options.maxWidth*A)+"px",g.innerHTML=j},_getRoundNum:function(g){var j=Math.pow(10,(Math.floor(g)+"").length-1),A=g/j;return A=A>=10?10:A>=5?5:A>=3?3:A>=2?2:1,j*A}}),wo=function(g){return new vo(g)},Yc='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8" class="leaflet-attribution-flag"><path fill="#4C7BE1" d="M0 0h12v4H0z"/><path fill="#FFD500" d="M0 4h12v3H0z"/><path fill="#E0BC00" d="M0 7h12v1H0z"/></svg>',Jc=Tn.extend({options:{position:"bottomright",prefix:'<a href="https://leafletjs.com" title="A JavaScript library for interactive maps">'+(Xe.inlineSvg?Yc+" ":"")+"Leaflet</a>"},initialize:function(g){v(this,g),this._attributions={}},onAdd:function(g){g.attributionControl=this,this._container=Tr("div","leaflet-control-attribution"),yo(this._container);for(var j in g._layers)g._layers[j].getAttribution&&this.addAttribution(g._layers[j].getAttribution());return this._update(),g.on("layeradd",this._addAttribution,this),this._container},onRemove:function(g){g.off("layeradd",this._addAttribution,this)},_addAttribution:function(g){g.layer.getAttribution&&(this.addAttribution(g.layer.getAttribution()),g.layer.once("remove",function(){this.removeAttribution(g.layer.getAttribution())},this))},setPrefix:function(g){return this.options.prefix=g,this._update(),this},addAttribution:function(g){return g?(this._attributions[g]||(this._attributions[g]=0),this._attributions[g]++,this._update(),this):this},removeAttribution:function(g){return g?(this._attributions[g]&&(this._attributions[g]--,this._update()),this):this},_update:function(){if(this._map){var g=[];for(var j in this._attributions)this._attributions[j]&&g.push(j);var A=[];this.options.prefix&&A.push(this.options.prefix),g.length&&A.push(g.join(", ")),this._container.innerHTML=A.join(' <span aria-hidden="true">|</span> ')}}});la.mergeOptions({attributionControl:!0}),la.addInitHook(function(){this.options.attributionControl&&new Jc().addTo(this)});var Zo=function(g){return new Jc(g)};Tn.Layers=Kc,Tn.Zoom=u0,Tn.Scale=vo,Tn.Attribution=Jc,Ii.layers=Km,Ii.zoom=ng,Ii.scale=wo,Ii.attribution=Zo;var zi=te.extend({initialize:function(g){this._map=g},enable:function(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}});zi.addTo=function(g,j){return g.addHandler(j,this),this};var ig={Events:q},m0=Xe.touch?"touchstart mousedown":"mousedown",Xo=H.extend({options:{clickTolerance:3},initialize:function(g,j,A,W){v(this,W),this._element=g,this._dragStartTarget=j||g,this._preventOutline=A},enable:function(){this._enabled||(mr(this._dragStartTarget,m0,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(Xo._dragging===this&&this.finishDrag(!0),Hr(this._dragStartTarget,m0,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(g){if(this._enabled&&(this._moved=!1,!mt(this._element,"leaflet-zoom-anim"))){if(g.touches&&g.touches.length!==1){Xo._dragging===this&&this.finishDrag();return}if(!(Xo._dragging||g.shiftKey||g.which!==1&&g.button!==1&&!g.touches)&&(Xo._dragging=this,this._preventOutline&&Yo(this._element),Go(),_i(),!this._moving)){this.fire("down");var j=g.touches?g.touches[0]:g,A=ot(this._element);this._startPoint=new U(j.clientX,j.clientY),this._startPos=ji(this._element),this._parentScale=Lt(A);var W=g.type==="mousedown";mr(document,W?"mousemove":"touchmove",this._onMove,this),mr(document,W?"mouseup":"touchend touchcancel",this._onUp,this)}}},_onMove:function(g){if(this._enabled){if(g.touches&&g.touches.length>1){this._moved=!0;return}var j=g.touches&&g.touches.length===1?g.touches[0]:g,A=new U(j.clientX,j.clientY)._subtract(this._startPoint);!A.x&&!A.y||Math.abs(A.x)+Math.abs(A.y)<this.options.clickTolerance||(A.x/=this._parentScale.x,A.y/=this._parentScale.y,Za(g),this._moved||(this.fire("dragstart"),this._moved=!0,ft(document.body,"leaflet-dragging"),this._lastTarget=g.target||g.srcElement,window.SVGElementInstance&&this._lastTarget instanceof window.SVGElementInstance&&(this._lastTarget=this._lastTarget.correspondingUseElement),ft(this._lastTarget,"leaflet-drag-target")),this._newPos=this._startPos.add(A),this._moving=!0,this._lastEvent=g,this._updatePosition())}},_updatePosition:function(){var g={originalEvent:this._lastEvent};this.fire("predrag",g),Sr(this._element,this._newPos),this.fire("drag",g)},_onUp:function(){this._enabled&&this.finishDrag()},finishDrag:function(g){dr(document.body,"leaflet-dragging"),this._lastTarget&&(dr(this._lastTarget,"leaflet-drag-target"),this._lastTarget=null),Hr(document,"mousemove touchmove",this._onMove,this),Hr(document,"mouseup touchend touchcancel",this._onUp,this),Ko(),js();var j=this._moved&&this._moving;this._moving=!1,Xo._dragging=!1,j&&this.fire("dragend",{noInertia:g,distance:this._newPos.distanceTo(this._startPos)})}});function jo(g,j,A){var W,ce=[1,4,2,8],Ne,Ge,xt,Nt,qt,cr,Cr,Jr;for(Ne=0,cr=g.length;Ne<cr;Ne++)g[Ne]._code=El(g[Ne],j);for(xt=0;xt<4;xt++){for(Cr=ce[xt],W=[],Ne=0,cr=g.length,Ge=cr-1;Ne<cr;Ge=Ne++)Nt=g[Ne],qt=g[Ge],Nt._code&Cr?qt._code&Cr||(Jr=gc(qt,Nt,Cr,j,A),Jr._code=El(Jr,j),W.push(Jr)):(qt._code&Cr&&(Jr=gc(qt,Nt,Cr,j,A),Jr._code=El(Jr,j),W.push(Jr)),W.push(Nt));g=W}return g}function Tl(g,j){var A,W,ce,Ne,Ge,xt,Nt,qt,cr;if(!g||g.length===0)throw new Error("latlngs not passed");ii(g)||(console.warn("latlngs are not flat! Only the first ring will be used"),g=g[0]);var Cr=me([0,0]),Jr=Q(g),fn=Jr.getNorthWest().distanceTo(Jr.getSouthWest())*Jr.getNorthEast().distanceTo(Jr.getNorthWest());fn<1700&&(Cr=pc(g));var Fs=g.length,Ci=[];for(A=0;A<Fs;A++){var Ta=me(g[A]);Ci.push(j.project(me([Ta.lat-Cr.lat,Ta.lng-Cr.lng])))}for(xt=Nt=qt=0,A=0,W=Fs-1;A<Fs;W=A++)ce=Ci[A],Ne=Ci[W],Ge=ce.y*Ne.x-Ne.y*ce.x,Nt+=(ce.x+Ne.x)*Ge,qt+=(ce.y+Ne.y)*Ge,xt+=Ge*3;xt===0?cr=Ci[0]:cr=[Nt/xt,qt/xt];var Ea=j.unproject(X(cr));return me([Ea.lat+Cr.lat,Ea.lng+Cr.lng])}function pc(g){for(var j=0,A=0,W=0,ce=0;ce<g.length;ce++){var Ne=me(g[ce]);j+=Ne.lat,A+=Ne.lng,W++}return me([j/W,A/W])}var Zc={__proto__:null,clipPolygon:jo,polygonCenter:Tl,centroid:pc};function h0(g,j){if(!j||!g.length)return g.slice();var A=j*j;return g=lg(g,A),g=Jm(g,A),g}function Ym(g,j,A){return Math.sqrt(Xc(g,j,A,!0))}function og(g,j,A){return Xc(g,j,A)}function Jm(g,j){var A=g.length,W=typeof Uint8Array!="undefined"?Uint8Array:Array,ce=new W(A);ce[0]=ce[A-1]=1,p0(g,ce,j,0,A-1);var Ne,Ge=[];for(Ne=0;Ne<A;Ne++)ce[Ne]&&Ge.push(g[Ne]);return Ge}function p0(g,j,A,W,ce){var Ne=0,Ge,xt,Nt;for(xt=W+1;xt<=ce-1;xt++)Nt=Xc(g[xt],g[W],g[ce],!0),Nt>Ne&&(Ge=xt,Ne=Nt);Ne>A&&(j[Ge]=1,p0(g,j,A,W,Ge),p0(g,j,A,Ge,ce))}function lg(g,j){for(var A=[g[0]],W=1,ce=0,Ne=g.length;W<Ne;W++)cg(g[W],g[ce])>j&&(A.push(g[W]),ce=W);return ce<Ne-1&&A.push(g[Ne-1]),A}var Zm;function Xm(g,j,A,W,ce){var Ne=W?Zm:El(g,A),Ge=El(j,A),xt,Nt,qt;for(Zm=Ge;;){if(!(Ne|Ge))return[g,j];if(Ne&Ge)return!1;xt=Ne||Ge,Nt=gc(g,j,xt,A,ce),qt=El(Nt,A),xt===Ne?(g=Nt,Ne=qt):(j=Nt,Ge=qt)}}function gc(g,j,A,W,ce){var Ne=j.x-g.x,Ge=j.y-g.y,xt=W.min,Nt=W.max,qt,cr;return A&8?(qt=g.x+Ne*(Nt.y-g.y)/Ge,cr=Nt.y):A&4?(qt=g.x+Ne*(xt.y-g.y)/Ge,cr=xt.y):A&2?(qt=Nt.x,cr=g.y+Ge*(Nt.x-g.x)/Ne):A&1&&(qt=xt.x,cr=g.y+Ge*(xt.x-g.x)/Ne),new U(qt,cr,ce)}function El(g,j){var A=0;return g.x<j.min.x?A|=1:g.x>j.max.x&&(A|=2),g.y<j.min.y?A|=4:g.y>j.max.y&&(A|=8),A}function cg(g,j){var A=j.x-g.x,W=j.y-g.y;return A*A+W*W}function Xc(g,j,A,W){var ce=j.x,Ne=j.y,Ge=A.x-ce,xt=A.y-Ne,Nt=Ge*Ge+xt*xt,qt;return Nt>0&&(qt=((g.x-ce)*Ge+(g.y-Ne)*xt)/Nt,qt>1?(ce=A.x,Ne=A.y):qt>0&&(ce+=Ge*qt,Ne+=xt*qt)),Ge=g.x-ce,xt=g.y-Ne,W?Ge*Ge+xt*xt:new U(ce,Ne)}function ii(g){return!C(g[0])||typeof g[0][0]!="object"&&typeof g[0][0]!="undefined"}function Qc(g){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),ii(g)}function $i(g,j){var A,W,ce,Ne,Ge,xt,Nt,qt;if(!g||g.length===0)throw new Error("latlngs not passed");ii(g)||(console.warn("latlngs are not flat! Only the first ring will be used"),g=g[0]);var cr=me([0,0]),Cr=Q(g),Jr=Cr.getNorthWest().distanceTo(Cr.getSouthWest())*Cr.getNorthEast().distanceTo(Cr.getNorthWest());Jr<1700&&(cr=pc(g));var fn=g.length,Fs=[];for(A=0;A<fn;A++){var Ci=me(g[A]);Fs.push(j.project(me([Ci.lat-cr.lat,Ci.lng-cr.lng])))}for(A=0,W=0;A<fn-1;A++)W+=Fs[A].distanceTo(Fs[A+1])/2;if(W===0)qt=Fs[0];else for(A=0,Ne=0;A<fn-1;A++)if(Ge=Fs[A],xt=Fs[A+1],ce=Ge.distanceTo(xt),Ne+=ce,Ne>W){Nt=(Ne-W)/ce,qt=[xt.x-Nt*(xt.x-Ge.x),xt.y-Nt*(xt.y-Ge.y)];break}var Ta=j.unproject(X(qt));return me([Ta.lat+cr.lat,Ta.lng+cr.lng])}var g0={__proto__:null,simplify:h0,pointToSegmentDistance:Ym,closestPointOnSegment:og,clipSegment:Xm,_getEdgeIntersection:gc,_getBitCode:El,_sqClosestPointOnSegment:Xc,isFlat:ii,_flat:Qc,polylineCenter:$i},Al={project:function(g){return new U(g.lng,g.lat)},unproject:function(g){return new ie(g.y,g.x)},bounds:new V([-180,-90],[180,90])},uu={R:6378137,R_MINOR:6356752314245179e-9,bounds:new V([-2003750834279e-5,-1549657073972e-5],[2003750834279e-5,1876465623138e-5]),project:function(g){var j=Math.PI/180,A=this.R,W=g.lat*j,ce=this.R_MINOR/A,Ne=Math.sqrt(1-ce*ce),Ge=Ne*Math.sin(W),xt=Math.tan(Math.PI/4-W/2)/Math.pow((1-Ge)/(1+Ge),Ne/2);return W=-A*Math.log(Math.max(xt,1e-10)),new U(g.lng*j*A,W)},unproject:function(g){for(var j=180/Math.PI,A=this.R,W=this.R_MINOR/A,ce=Math.sqrt(1-W*W),Ne=Math.exp(-g.y/A),Ge=Math.PI/2-2*Math.atan(Ne),xt=0,Nt=.1,qt;xt<15&&Math.abs(Nt)>1e-7;xt++)qt=ce*Math.sin(Ge),qt=Math.pow((1-qt)/(1+qt),ce/2),Nt=Math.PI/2-2*Math.atan(Ne*qt)-Ge,Ge+=Nt;return new ie(Ge*j,g.x*j/A)}},Qm={__proto__:null,LonLat:Al,Mercator:uu,SphericalMercator:ge},eh=n({},de,{code:"EPSG:3395",projection:uu,transformation:(function(){var g=.5/(Math.PI*uu.R);return K(g,.5,-g,.5)})()}),f0=n({},de,{code:"EPSG:4326",projection:Al,transformation:K(1/180,1,-1/180,.5)}),Ol=n({},he,{projection:Al,transformation:K(1,0,-1,0),scale:function(g){return Math.pow(2,g)},zoom:function(g){return Math.log(g)/Math.LN2},distance:function(g,j){var A=j.lng-g.lng,W=j.lat-g.lat;return Math.sqrt(A*A+W*W)},infinite:!0});he.Earth=de,he.EPSG3395=eh,he.EPSG3857=ye,he.EPSG900913=Z,he.EPSG4326=f0,he.Simple=Ol;var ka=H.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(g){return g.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(g){return g&&g.removeLayer(this),this},getPane:function(g){return this._map.getPane(g?this.options[g]||g:this.options.pane)},addInteractiveTarget:function(g){return this._map._targets[c(g)]=this,this},removeInteractiveTarget:function(g){return delete this._map._targets[c(g)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(g){var j=g.target;if(j.hasLayer(this)){if(this._map=j,this._zoomAnimated=j._zoomAnimated,this.getEvents){var A=this.getEvents();j.on(A,this),this.once("remove",function(){j.off(A,this)},this)}this.onAdd(j),this.fire("add"),j.fire("layeradd",{layer:this})}}});la.include({addLayer:function(g){if(!g._layerAdd)throw new Error("The provided object is not a Layer.");var j=c(g);return this._layers[j]?this:(this._layers[j]=g,g._mapToAdd=this,g.beforeAdd&&g.beforeAdd(this),this.whenReady(g._layerAdd,g),this)},removeLayer:function(g){var j=c(g);return this._layers[j]?(this._loaded&&g.onRemove(this),delete this._layers[j],this._loaded&&(this.fire("layerremove",{layer:g}),g.fire("remove")),g._map=g._mapToAdd=null,this):this},hasLayer:function(g){return c(g)in this._layers},eachLayer:function(g,j){for(var A in this._layers)g.call(j,this._layers[A]);return this},_addLayers:function(g){g=g?C(g)?g:[g]:[];for(var j=0,A=g.length;j<A;j++)this.addLayer(g[j])},_addZoomLimit:function(g){(!isNaN(g.options.maxZoom)||!isNaN(g.options.minZoom))&&(this._zoomBoundLayers[c(g)]=g,this._updateZoomLevels())},_removeZoomLimit:function(g){var j=c(g);this._zoomBoundLayers[j]&&(delete this._zoomBoundLayers[j],this._updateZoomLevels())},_updateZoomLevels:function(){var g=1/0,j=-1/0,A=this._getZoomSpan();for(var W in this._zoomBoundLayers){var ce=this._zoomBoundLayers[W].options;g=ce.minZoom===void 0?g:Math.min(g,ce.minZoom),j=ce.maxZoom===void 0?j:Math.max(j,ce.maxZoom)}this._layersMaxZoom=j===-1/0?void 0:j,this._layersMinZoom=g===1/0?void 0:g,A!==this._getZoomSpan()&&this.fire("zoomlevelschange"),this.options.maxZoom===void 0&&this._layersMaxZoom&&this.getZoom()>this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()<this._layersMinZoom&&this.setZoom(this._layersMinZoom)}});var Pl=ka.extend({initialize:function(g,j){v(this,j),this._layers={};var A,W;if(g)for(A=0,W=g.length;A<W;A++)this.addLayer(g[A])},addLayer:function(g){var j=this.getLayerId(g);return this._layers[j]=g,this._map&&this._map.addLayer(g),this},removeLayer:function(g){var j=g in this._layers?g:this.getLayerId(g);return this._map&&this._layers[j]&&this._map.removeLayer(this._layers[j]),delete this._layers[j],this},hasLayer:function(g){var j=typeof g=="number"?g:this.getLayerId(g);return j in this._layers},clearLayers:function(){return this.eachLayer(this.removeLayer,this)},invoke:function(g){var j=Array.prototype.slice.call(arguments,1),A,W;for(A in this._layers)W=this._layers[A],W[g]&&W[g].apply(W,j);return this},onAdd:function(g){this.eachLayer(g.addLayer,g)},onRemove:function(g){this.eachLayer(g.removeLayer,g)},eachLayer:function(g,j){for(var A in this._layers)g.call(j,this._layers[A]);return this},getLayer:function(g){return this._layers[g]},getLayers:function(){var g=[];return this.eachLayer(g.push,g),g},setZIndex:function(g){return this.invoke("setZIndex",g)},getLayerId:function(g){return c(g)}}),dg=function(g,j){return new Pl(g,j)},Ui=Pl.extend({addLayer:function(g){return this.hasLayer(g)?this:(g.addEventParent(this),Pl.prototype.addLayer.call(this,g),this.fire("layeradd",{layer:g}))},removeLayer:function(g){return this.hasLayer(g)?(g in this._layers&&(g=this._layers[g]),g.removeEventParent(this),Pl.prototype.removeLayer.call(this,g),this.fire("layerremove",{layer:g})):this},setStyle:function(g){return this.invoke("setStyle",g)},bringToFront:function(){return this.invoke("bringToFront")},bringToBack:function(){return this.invoke("bringToBack")},getBounds:function(){var g=new B;for(var j in this._layers){var A=this._layers[j];g.extend(A.getBounds?A.getBounds():A.getLatLng())}return g}}),th=function(g,j){return new Ui(g,j)},Bi=te.extend({options:{popupAnchor:[0,0],tooltipAnchor:[0,0],crossOrigin:!1},initialize:function(g){v(this,g)},createIcon:function(g){return this._createIcon("icon",g)},createShadow:function(g){return this._createIcon("shadow",g)},_createIcon:function(g,j){var A=this._getIconUrl(g);if(!A){if(g==="icon")throw new Error("iconUrl not set in Icon options (see the docs).");return null}var W=this._createImg(A,j&&j.tagName==="IMG"?j:null);return this._setIconStyles(W,g),(this.options.crossOrigin||this.options.crossOrigin==="")&&(W.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),W},_setIconStyles:function(g,j){var A=this.options,W=A[j+"Size"];typeof W=="number"&&(W=[W,W]);var ce=X(W),Ne=X(j==="shadow"&&A.shadowAnchor||A.iconAnchor||ce&&ce.divideBy(2,!0));g.className="leaflet-marker-"+j+" "+(A.className||""),Ne&&(g.style.marginLeft=-Ne.x+"px",g.style.marginTop=-Ne.y+"px"),ce&&(g.style.width=ce.x+"px",g.style.height=ce.y+"px")},_createImg:function(g,j){return j=j||document.createElement("img"),j.src=g,j},_getIconUrl:function(g){return Xe.retina&&this.options[g+"RetinaUrl"]||this.options[g+"Url"]}});function ed(g){return new Bi(g)}var td=Bi.extend({options:{iconUrl:"marker-icon.png",iconRetinaUrl:"marker-icon-2x.png",shadowUrl:"marker-shadow.png",iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]},_getIconUrl:function(g){return typeof td.imagePath!="string"&&(td.imagePath=this._detectIconPath()),(this.options.imagePath||td.imagePath)+Bi.prototype._getIconUrl.call(this,g)},_stripUrl:function(g){var j=function(A,W,ce){var Ne=W.exec(A);return Ne&&Ne[ce]};return g=j(g,/^url\((['"])?(.+)\1\)$/,2),g&&j(g,/^(.*)marker-icon\.png$/,1)},_detectIconPath:function(){var g=Tr("div","leaflet-default-icon-path",document.body),j=Un(g,"background-image")||Un(g,"backgroundImage");if(document.body.removeChild(g),j=this._stripUrl(j),j)return j;var A=document.querySelector('link[href$="leaflet.css"]');return A?A.href.substring(0,A.href.length-11-1):""}}),rd=zi.extend({initialize:function(g){this._marker=g},addHooks:function(){var g=this._marker._icon;this._draggable||(this._draggable=new Xo(g,g,!0)),this._draggable.on({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),ft(g,"leaflet-marker-draggable")},removeHooks:function(){this._draggable.off({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).disable(),this._marker._icon&&dr(this._marker._icon,"leaflet-marker-draggable")},moved:function(){return this._draggable&&this._draggable._moved},_adjustPan:function(g){var j=this._marker,A=j._map,W=this._marker.options.autoPanSpeed,ce=this._marker.options.autoPanPadding,Ne=ji(j._icon),Ge=A.getPixelBounds(),xt=A.getPixelOrigin(),Nt=I(Ge.min._subtract(xt).add(ce),Ge.max._subtract(xt).subtract(ce));if(!Nt.contains(Ne)){var qt=X((Math.max(Nt.max.x,Ne.x)-Nt.max.x)/(Ge.max.x-Nt.max.x)-(Math.min(Nt.min.x,Ne.x)-Nt.min.x)/(Ge.min.x-Nt.min.x),(Math.max(Nt.max.y,Ne.y)-Nt.max.y)/(Ge.max.y-Nt.max.y)-(Math.min(Nt.min.y,Ne.y)-Nt.min.y)/(Ge.min.y-Nt.min.y)).multiplyBy(W);A.panBy(qt,{animate:!1}),this._draggable._newPos._add(qt),this._draggable._startPos._add(qt),Sr(j._icon,this._draggable._newPos),this._onDrag(g),this._panRequest=ae(this._adjustPan.bind(this,g))}},_onDragStart:function(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup&&this._marker.closePopup(),this._marker.fire("movestart").fire("dragstart")},_onPreDrag:function(g){this._marker.options.autoPan&&(ee(this._panRequest),this._panRequest=ae(this._adjustPan.bind(this,g)))},_onDrag:function(g){var j=this._marker,A=j._shadow,W=ji(j._icon),ce=j._map.layerPointToLatLng(W);A&&Sr(A,W),j._latlng=ce,g.latlng=ce,g.oldLatLng=this._oldLatLng,j.fire("move",g).fire("drag",g)},_onDragEnd:function(g){ee(this._panRequest),delete this._oldLatLng,this._marker.fire("moveend").fire("dragend",g)}}),ad=ka.extend({options:{icon:new td,interactive:!0,keyboard:!0,title:"",alt:"Marker",zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250,pane:"markerPane",shadowPane:"shadowPane",bubblingMouseEvents:!1,autoPanOnFocus:!0,draggable:!1,autoPan:!1,autoPanPadding:[50,50],autoPanSpeed:10},initialize:function(g,j){v(this,j),this._latlng=me(g)},onAdd:function(g){this._zoomAnimated=this._zoomAnimated&&g.options.markerZoomAnimation,this._zoomAnimated&&g.on("zoomanim",this._animateZoom,this),this._initIcon(),this.update()},onRemove:function(g){this.dragging&&this.dragging.enabled()&&(this.options.draggable=!0,this.dragging.removeHooks()),delete this.dragging,this._zoomAnimated&&g.off("zoomanim",this._animateZoom,this),this._removeIcon(),this._removeShadow()},getEvents:function(){return{zoom:this.update,viewreset:this.update}},getLatLng:function(){return this._latlng},setLatLng:function(g){var j=this._latlng;return this._latlng=me(g),this.update(),this.fire("move",{oldLatLng:j,latlng:this._latlng})},setZIndexOffset:function(g){return this.options.zIndexOffset=g,this.update()},getIcon:function(){return this.options.icon},setIcon:function(g){return this.options.icon=g,this._map&&(this._initIcon(),this.update()),this._popup&&this.bindPopup(this._popup,this._popup.options),this},getElement:function(){return this._icon},update:function(){if(this._icon&&this._map){var g=this._map.latLngToLayerPoint(this._latlng).round();this._setPos(g)}return this},_initIcon:function(){var g=this.options,j="leaflet-zoom-"+(this._zoomAnimated?"animated":"hide"),A=g.icon.createIcon(this._icon),W=!1;A!==this._icon&&(this._icon&&this._removeIcon(),W=!0,g.title&&(A.title=g.title),A.tagName==="IMG"&&(A.alt=g.alt||"")),ft(A,j),g.keyboard&&(A.tabIndex="0",A.setAttribute("role","button")),this._icon=A,g.riseOnHover&&this.on({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&mr(A,"focus",this._panOnFocus,this);var ce=g.icon.createShadow(this._shadow),Ne=!1;ce!==this._shadow&&(this._removeShadow(),Ne=!0),ce&&(ft(ce,j),ce.alt=""),this._shadow=ce,g.opacity<1&&this._updateOpacity(),W&&this.getPane().appendChild(this._icon),this._initInteraction(),ce&&Ne&&this.getPane(g.shadowPane).appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&this.off({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&Hr(this._icon,"focus",this._panOnFocus,this),Ir(this._icon),this.removeInteractiveTarget(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&Ir(this._shadow),this._shadow=null},_setPos:function(g){this._icon&&Sr(this._icon,g),this._shadow&&Sr(this._shadow,g),this._zIndex=g.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(g){this._icon&&(this._icon.style.zIndex=this._zIndex+g)},_animateZoom:function(g){var j=this._map._latLngToNewLayerPoint(this._latlng,g.zoom,g.center).round();this._setPos(j)},_initInteraction:function(){if(this.options.interactive&&(ft(this._icon,"leaflet-interactive"),this.addInteractiveTarget(this._icon),rd)){var g=this.options.draggable;this.dragging&&(g=this.dragging.enabled(),this.dragging.disable()),this.dragging=new rd(this),g&&this.dragging.enable()}},setOpacity:function(g){return this.options.opacity=g,this._map&&this._updateOpacity(),this},_updateOpacity:function(){var g=this.options.opacity;this._icon&&ar(this._icon,g),this._shadow&&ar(this._shadow,g)},_bringToFront:function(){this._updateZIndex(this.options.riseOffset)},_resetZIndex:function(){this._updateZIndex(0)},_panOnFocus:function(){var g=this._map;if(g){var j=this.options.icon.options,A=j.iconSize?X(j.iconSize):X(0,0),W=j.iconAnchor?X(j.iconAnchor):X(0,0);g.panInside(this._latlng,{paddingTopLeft:W,paddingBottomRight:A.subtract(W)})}},_getPopupAnchor:function(){return this.options.icon.options.popupAnchor},_getTooltipAnchor:function(){return this.options.icon.options.tooltipAnchor}});function sd(g,j){return new ad(g,j)}var Wi=ka.extend({options:{stroke:!0,color:"#3388ff",weight:3,opacity:1,lineCap:"round",lineJoin:"round",dashArray:null,dashOffset:null,fill:!1,fillColor:null,fillOpacity:.2,fillRule:"evenodd",interactive:!0,bubblingMouseEvents:!0},beforeAdd:function(g){this._renderer=g.getRenderer(this)},onAdd:function(){this._renderer._initPath(this),this._reset(),this._renderer._addPath(this)},onRemove:function(){this._renderer._removePath(this)},redraw:function(){return this._map&&this._renderer._updatePath(this),this},setStyle:function(g){return v(this,g),this._renderer&&(this._renderer._updateStyle(this),this.options.stroke&&g&&Object.prototype.hasOwnProperty.call(g,"weight")&&this._updateBounds()),this},bringToFront:function(){return this._renderer&&this._renderer._bringToFront(this),this},bringToBack:function(){return this._renderer&&this._renderer._bringToBack(this),this},getElement:function(){return this._path},_reset:function(){this._project(),this._update()},_clickTolerance:function(){return(this.options.stroke?this.options.weight/2:0)+(this._renderer.options.tolerance||0)}}),fc=Wi.extend({options:{fill:!0,radius:10},initialize:function(g,j){v(this,j),this._latlng=me(g),this._radius=this.options.radius},setLatLng:function(g){var j=this._latlng;return this._latlng=me(g),this.redraw(),this.fire("move",{oldLatLng:j,latlng:this._latlng})},getLatLng:function(){return this._latlng},setRadius:function(g){return this.options.radius=this._radius=g,this.redraw()},getRadius:function(){return this._radius},setStyle:function(g){var j=g&&g.radius||this._radius;return Wi.prototype.setStyle.call(this,g),this.setRadius(j),this},_project:function(){this._point=this._map.latLngToLayerPoint(this._latlng),this._updateBounds()},_updateBounds:function(){var g=this._radius,j=this._radiusY||g,A=this._clickTolerance(),W=[g+A,j+A];this._pxBounds=new V(this._point.subtract(W),this._point.add(W))},_update:function(){this._map&&this._updatePath()},_updatePath:function(){this._renderer._updateCircle(this)},_empty:function(){return this._radius&&!this._renderer._bounds.intersects(this._pxBounds)},_containsPoint:function(g){return g.distanceTo(this._point)<=this._radius+this._clickTolerance()}});function rh(g,j){return new fc(g,j)}var nd=fc.extend({initialize:function(g,j,A){if(typeof j=="number"&&(j=n({},A,{radius:j})),v(this,j),this._latlng=me(g),isNaN(this.options.radius))throw new Error("Circle radius cannot be NaN");this._mRadius=this.options.radius},setRadius:function(g){return this._mRadius=g,this.redraw()},getRadius:function(){return this._mRadius},getBounds:function(){var g=[this._radius,this._radiusY||this._radius];return new B(this._map.layerPointToLatLng(this._point.subtract(g)),this._map.layerPointToLatLng(this._point.add(g)))},setStyle:Wi.prototype.setStyle,_project:function(){var g=this._latlng.lng,j=this._latlng.lat,A=this._map,W=A.options.crs;if(W.distance===de.distance){var ce=Math.PI/180,Ne=this._mRadius/de.R/ce,Ge=A.project([j+Ne,g]),xt=A.project([j-Ne,g]),Nt=Ge.add(xt).divideBy(2),qt=A.unproject(Nt).lat,cr=Math.acos((Math.cos(Ne*ce)-Math.sin(j*ce)*Math.sin(qt*ce))/(Math.cos(j*ce)*Math.cos(qt*ce)))/ce;(isNaN(cr)||cr===0)&&(cr=Ne/Math.cos(Math.PI/180*j)),this._point=Nt.subtract(A.getPixelOrigin()),this._radius=isNaN(cr)?0:Nt.x-A.project([qt,g-cr]).x,this._radiusY=Nt.y-Ge.y}else{var Cr=W.unproject(W.project(this._latlng).subtract([this._mRadius,0]));this._point=A.latLngToLayerPoint(this._latlng),this._radius=this._point.x-A.latLngToLayerPoint(Cr).x}this._updateBounds()}});function ah(g,j,A){return new nd(g,j,A)}var Hi=Wi.extend({options:{smoothFactor:1,noClip:!1},initialize:function(g,j){v(this,j),this._setLatLngs(g)},getLatLngs:function(){return this._latlngs},setLatLngs:function(g){return this._setLatLngs(g),this.redraw()},isEmpty:function(){return!this._latlngs.length},closestLayerPoint:function(g){for(var j=1/0,A=null,W=Xc,ce,Ne,Ge=0,xt=this._parts.length;Ge<xt;Ge++)for(var Nt=this._parts[Ge],qt=1,cr=Nt.length;qt<cr;qt++){ce=Nt[qt-1],Ne=Nt[qt];var Cr=W(g,ce,Ne,!0);Cr<j&&(j=Cr,A=W(g,ce,Ne))}return A&&(A.distance=Math.sqrt(j)),A},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");return $i(this._defaultShape(),this._map.options.crs)},getBounds:function(){return this._bounds},addLatLng:function(g,j){return j=j||this._defaultShape(),g=me(g),j.push(g),this._bounds.extend(g),this.redraw()},_setLatLngs:function(g){this._bounds=new B,this._latlngs=this._convertLatLngs(g)},_defaultShape:function(){return ii(this._latlngs)?this._latlngs:this._latlngs[0]},_convertLatLngs:function(g){for(var j=[],A=ii(g),W=0,ce=g.length;W<ce;W++)A?(j[W]=me(g[W]),this._bounds.extend(j[W])):j[W]=this._convertLatLngs(g[W]);return j},_project:function(){var g=new V;this._rings=[],this._projectLatlngs(this._latlngs,this._rings,g),this._bounds.isValid()&&g.isValid()&&(this._rawPxBounds=g,this._updateBounds())},_updateBounds:function(){var g=this._clickTolerance(),j=new U(g,g);this._rawPxBounds&&(this._pxBounds=new V([this._rawPxBounds.min.subtract(j),this._rawPxBounds.max.add(j)]))},_projectLatlngs:function(g,j,A){var W=g[0]instanceof ie,ce=g.length,Ne,Ge;if(W){for(Ge=[],Ne=0;Ne<ce;Ne++)Ge[Ne]=this._map.latLngToLayerPoint(g[Ne]),A.extend(Ge[Ne]);j.push(Ge)}else for(Ne=0;Ne<ce;Ne++)this._projectLatlngs(g[Ne],j,A)},_clipPoints:function(){var g=this._renderer._bounds;if(this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(g))){if(this.options.noClip){this._parts=this._rings;return}var j=this._parts,A,W,ce,Ne,Ge,xt,Nt;for(A=0,ce=0,Ne=this._rings.length;A<Ne;A++)for(Nt=this._rings[A],W=0,Ge=Nt.length;W<Ge-1;W++)xt=Xm(Nt[W],Nt[W+1],g,W,!0),xt&&(j[ce]=j[ce]||[],j[ce].push(xt[0]),(xt[1]!==Nt[W+1]||W===Ge-2)&&(j[ce].push(xt[1]),ce++))}},_simplifyPoints:function(){for(var g=this._parts,j=this.options.smoothFactor,A=0,W=g.length;A<W;A++)g[A]=h0(g[A],j)},_update:function(){this._map&&(this._clipPoints(),this._simplifyPoints(),this._updatePath())},_updatePath:function(){this._renderer._updatePoly(this)},_containsPoint:function(g,j){var A,W,ce,Ne,Ge,xt,Nt=this._clickTolerance();if(!this._pxBounds||!this._pxBounds.contains(g))return!1;for(A=0,Ne=this._parts.length;A<Ne;A++)for(xt=this._parts[A],W=0,Ge=xt.length,ce=Ge-1;W<Ge;ce=W++)if(!(!j&&W===0)&&Ym(g,xt[ce],xt[W])<=Nt)return!0;return!1}});function mu(g,j){return new Hi(g,j)}Hi._flat=Qc;var xc=Hi.extend({options:{fill:!0},isEmpty:function(){return!this._latlngs.length||!this._latlngs[0].length},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");return Tl(this._defaultShape(),this._map.options.crs)},_convertLatLngs:function(g){var j=Hi.prototype._convertLatLngs.call(this,g),A=j.length;return A>=2&&j[0]instanceof ie&&j[0].equals(j[A-1])&&j.pop(),j},_setLatLngs:function(g){Hi.prototype._setLatLngs.call(this,g),ii(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return ii(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var g=this._renderer._bounds,j=this.options.weight,A=new U(j,j);if(g=new V(g.min.subtract(A),g.max.add(A)),this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(g))){if(this.options.noClip){this._parts=this._rings;return}for(var W=0,ce=this._rings.length,Ne;W<ce;W++)Ne=jo(this._rings[W],g,!0),Ne.length&&this._parts.push(Ne)}},_updatePath:function(){this._renderer._updatePoly(this,!0)},_containsPoint:function(g){var j=!1,A,W,ce,Ne,Ge,xt,Nt,qt;if(!this._pxBounds||!this._pxBounds.contains(g))return!1;for(Ne=0,Nt=this._parts.length;Ne<Nt;Ne++)for(A=this._parts[Ne],Ge=0,qt=A.length,xt=qt-1;Ge<qt;xt=Ge++)W=A[Ge],ce=A[xt],W.y>g.y!=ce.y>g.y&&g.x<(ce.x-W.x)*(g.y-W.y)/(ce.y-W.y)+W.x&&(j=!j);return j||Hi.prototype._containsPoint.call(this,g,!0)}});function qi(g,j){return new xc(g,j)}var En=Ui.extend({initialize:function(g,j){v(this,j),this._layers={},g&&this.addData(g)},addData:function(g){var j=C(g)?g:g.features,A,W,ce;if(j){for(A=0,W=j.length;A<W;A++)ce=j[A],(ce.geometries||ce.geometry||ce.features||ce.coordinates)&&this.addData(ce);return this}var Ne=this.options;if(Ne.filter&&!Ne.filter(g))return this;var Ge=Ls(g,Ne);return Ge?(Ge.feature=pu(g),Ge.defaultOptions=Ge.options,this.resetStyle(Ge),Ne.onEachFeature&&Ne.onEachFeature(g,Ge),this.addLayer(Ge)):this},resetStyle:function(g){return g===void 0?this.eachLayer(this.resetStyle,this):(g.options=n({},g.defaultOptions),this._setLayerStyle(g,this.options.style),this)},setStyle:function(g){return this.eachLayer(function(j){this._setLayerStyle(j,g)},this)},_setLayerStyle:function(g,j){g.setStyle&&(typeof j=="function"&&(j=j(g.feature)),g.setStyle(j))}});function Ls(g,j){var A=g.type==="Feature"?g.geometry:g,W=A?A.coordinates:null,ce=[],Ne=j&&j.pointToLayer,Ge=j&&j.coordsToLatLng||hu,xt,Nt,qt,cr;if(!W&&!A)return null;switch(A.type){case"Point":return xt=Ge(W),Vi(Ne,g,xt,j);case"MultiPoint":for(qt=0,cr=W.length;qt<cr;qt++)xt=Ge(W[qt]),ce.push(Vi(Ne,g,xt,j));return new Ui(ce);case"LineString":case"MultiLineString":return Nt=id(W,A.type==="LineString"?0:1,Ge),new Hi(Nt,j);case"Polygon":case"MultiPolygon":return Nt=id(W,A.type==="Polygon"?1:2,Ge),new xc(Nt,j);case"GeometryCollection":for(qt=0,cr=A.geometries.length;qt<cr;qt++){var Cr=Ls({geometry:A.geometries[qt],type:"Feature",properties:g.properties},j);Cr&&ce.push(Cr)}return new Ui(ce);case"FeatureCollection":for(qt=0,cr=A.features.length;qt<cr;qt++){var Jr=Ls(A.features[qt],j);Jr&&ce.push(Jr)}return new Ui(ce);default:throw new Error("Invalid GeoJSON object.")}}function Vi(g,j,A,W){return g?g(j,A):new ad(A,W&&W.markersInheritOptions&&W)}function hu(g){return new ie(g[1],g[0],g[2])}function id(g,j,A){for(var W=[],ce=0,Ne=g.length,Ge;ce<Ne;ce++)Ge=j?id(g[ce],j-1,A):(A||hu)(g[ce]),W.push(Ge);return W}function x0(g,j){return g=me(g),g.alt!==void 0?[y(g.lng,j),y(g.lat,j),y(g.alt,j)]:[y(g.lng,j),y(g.lat,j)]}function od(g,j,A,W){for(var ce=[],Ne=0,Ge=g.length;Ne<Ge;Ne++)ce.push(j?od(g[Ne],ii(g[Ne])?0:j-1,A,W):x0(g[Ne],W));return!j&&A&&ce.length>0&&ce.push(ce[0].slice()),ce}function Qo(g,j){return g.feature?n({},g.feature,{geometry:j}):pu(j)}function pu(g){return g.type==="Feature"||g.type==="FeatureCollection"?g:{type:"Feature",properties:{},geometry:g}}var el={toGeoJSON:function(g){return Qo(this,{type:"Point",coordinates:x0(this.getLatLng(),g)})}};ad.include(el),nd.include(el),fc.include(el),Hi.include({toGeoJSON:function(g){var j=!ii(this._latlngs),A=od(this._latlngs,j?1:0,!1,g);return Qo(this,{type:(j?"Multi":"")+"LineString",coordinates:A})}}),xc.include({toGeoJSON:function(g){var j=!ii(this._latlngs),A=j&&!ii(this._latlngs[0]),W=od(this._latlngs,A?2:j?1:0,!0,g);return j||(W=[W]),Qo(this,{type:(A?"Multi":"")+"Polygon",coordinates:W})}}),Pl.include({toMultiPoint:function(g){var j=[];return this.eachLayer(function(A){j.push(A.toGeoJSON(g).geometry.coordinates)}),Qo(this,{type:"MultiPoint",coordinates:j})},toGeoJSON:function(g){var j=this.feature&&this.feature.geometry&&this.feature.geometry.type;if(j==="MultiPoint")return this.toMultiPoint(g);var A=j==="GeometryCollection",W=[];return this.eachLayer(function(ce){if(ce.toGeoJSON){var Ne=ce.toGeoJSON(g);if(A)W.push(Ne.geometry);else{var Ge=pu(Ne);Ge.type==="FeatureCollection"?W.push.apply(W,Ge.features):W.push(Ge)}}}),A?Qo(this,{geometries:W,type:"GeometryCollection"}):{type:"FeatureCollection",features:W}}});function ld(g,j){return new En(g,j)}var Dl=ld,tl=ka.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(g,j,A){this._url=g,this._bounds=Q(j),v(this,A)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(ft(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){Ir(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(g){return this.options.opacity=g,this._image&&this._updateOpacity(),this},setStyle:function(g){return g.opacity&&this.setOpacity(g.opacity),this},bringToFront:function(){return this._map&&Ca(this._image),this},bringToBack:function(){return this._map&&pn(this._image),this},setUrl:function(g){return this._url=g,this._image&&(this._image.src=g),this},setBounds:function(g){return this._bounds=Q(g),this._map&&this._reset(),this},getEvents:function(){var g={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(g.zoomanim=this._animateZoom),g},setZIndex:function(g){return this.options.zIndex=g,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var g=this._url.tagName==="IMG",j=this._image=g?this._url:Tr("img");if(ft(j,"leaflet-image-layer"),this._zoomAnimated&&ft(j,"leaflet-zoom-animated"),this.options.className&&ft(j,this.options.className),j.onselectstart=f,j.onmousemove=f,j.onload=o(this.fire,this,"load"),j.onerror=o(this._overlayOnError,this,"error"),(this.options.crossOrigin||this.options.crossOrigin==="")&&(j.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),g){this._url=j.src;return}j.src=this._url,j.alt=this.options.alt},_animateZoom:function(g){var j=this._map.getZoomScale(g.zoom),A=this._map._latLngBoundsToNewLayerBounds(this._bounds,g.zoom,g.center).min;Ba(this._image,A,j)},_reset:function(){var g=this._image,j=new V(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),A=j.getSize();Sr(g,j.min),g.style.width=A.x+"px",g.style.height=A.y+"px"},_updateOpacity:function(){ar(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire("error");var g=this.options.errorOverlayUrl;g&&this._url!==g&&(this._url=g,this._image.src=g)},getCenter:function(){return this._bounds.getCenter()}}),sh=function(g,j,A){return new tl(g,j,A)},_o=tl.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var g=this._url.tagName==="VIDEO",j=this._image=g?this._url:Tr("video");if(ft(j,"leaflet-image-layer"),this._zoomAnimated&&ft(j,"leaflet-zoom-animated"),this.options.className&&ft(j,this.options.className),j.onselectstart=f,j.onmousemove=f,j.onloadeddata=o(this.fire,this,"load"),g){for(var A=j.getElementsByTagName("source"),W=[],ce=0;ce<A.length;ce++)W.push(A[ce].src);this._url=A.length>0?W:[j.src];return}C(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(j.style,"objectFit")&&(j.style.objectFit="fill"),j.autoplay=!!this.options.autoplay,j.loop=!!this.options.loop,j.muted=!!this.options.muted,j.playsInline=!!this.options.playsInline;for(var Ne=0;Ne<this._url.length;Ne++){var Ge=Tr("source");Ge.src=this._url[Ne],j.appendChild(Ge)}}});function Rl(g,j,A){return new _o(g,j,A)}var cd=tl.extend({_initImage:function(){var g=this._image=this._url;ft(g,"leaflet-image-layer"),this._zoomAnimated&&ft(g,"leaflet-zoom-animated"),this.options.className&&ft(g,this.options.className),g.onselectstart=f,g.onmousemove=f}});function fe(g,j,A){return new cd(g,j,A)}var Te=ka.extend({options:{interactive:!1,offset:[0,0],className:"",pane:void 0,content:""},initialize:function(g,j){g&&(g instanceof ie||C(g))?(this._latlng=me(g),v(this,j)):(v(this,g),this._source=j),this.options.content&&(this._content=this.options.content)},openOn:function(g){return g=arguments.length?g:this._source._map,g.hasLayer(this)||g.addLayer(this),this},close:function(){return this._map&&this._map.removeLayer(this),this},toggle:function(g){return this._map?this.close():(arguments.length?this._source=g:g=this._source,this._prepareOpen(),this.openOn(g._map)),this},onAdd:function(g){this._zoomAnimated=g._zoomAnimated,this._container||this._initLayout(),g._fadeAnimated&&ar(this._container,0),clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.update(),g._fadeAnimated&&ar(this._container,1),this.bringToFront(),this.options.interactive&&(ft(this._container,"leaflet-interactive"),this.addInteractiveTarget(this._container))},onRemove:function(g){g._fadeAnimated?(ar(this._container,0),this._removeTimeout=setTimeout(o(Ir,void 0,this._container),200)):Ir(this._container),this.options.interactive&&(dr(this._container,"leaflet-interactive"),this.removeInteractiveTarget(this._container))},getLatLng:function(){return this._latlng},setLatLng:function(g){return this._latlng=me(g),this._map&&(this._updatePosition(),this._adjustPan()),this},getContent:function(){return this._content},setContent:function(g){return this._content=g,this.update(),this},getElement:function(){return this._container},update:function(){this._map&&(this._container.style.visibility="hidden",this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility="",this._adjustPan())},getEvents:function(){var g={zoom:this._updatePosition,viewreset:this._updatePosition};return this._zoomAnimated&&(g.zoomanim=this._animateZoom),g},isOpen:function(){return!!this._map&&this._map.hasLayer(this)},bringToFront:function(){return this._map&&Ca(this._container),this},bringToBack:function(){return this._map&&pn(this._container),this},_prepareOpen:function(g){var j=this._source;if(!j._map)return!1;if(j instanceof Ui){j=null;var A=this._source._layers;for(var W in A)if(A[W]._map){j=A[W];break}if(!j)return!1;this._source=j}if(!g)if(j.getCenter)g=j.getCenter();else if(j.getLatLng)g=j.getLatLng();else if(j.getBounds)g=j.getBounds().getCenter();else throw new Error("Unable to get source layer LatLng.");return this.setLatLng(g),this._map&&this.update(),!0},_updateContent:function(){if(this._content){var g=this._contentNode,j=typeof this._content=="function"?this._content(this._source||this):this._content;if(typeof j=="string")g.innerHTML=j;else{for(;g.hasChildNodes();)g.removeChild(g.firstChild);g.appendChild(j)}this.fire("contentupdate")}},_updatePosition:function(){if(this._map){var g=this._map.latLngToLayerPoint(this._latlng),j=X(this.options.offset),A=this._getAnchor();this._zoomAnimated?Sr(this._container,g.add(A)):j=j.add(g).add(A);var W=this._containerBottom=-j.y,ce=this._containerLeft=-Math.round(this._containerWidth/2)+j.x;this._container.style.bottom=W+"px",this._container.style.left=ce+"px"}},_getAnchor:function(){return[0,0]}});la.include({_initOverlay:function(g,j,A,W){var ce=j;return ce instanceof g||(ce=new g(W).setContent(j)),A&&ce.setLatLng(A),ce}}),ka.include({_initOverlay:function(g,j,A,W){var ce=A;return ce instanceof g?(v(ce,W),ce._source=this):(ce=j&&!W?j:new g(W,this),ce.setContent(A)),ce}});var qe=Te.extend({options:{pane:"popupPane",offset:[0,7],maxWidth:300,minWidth:50,maxHeight:null,autoPan:!0,autoPanPaddingTopLeft:null,autoPanPaddingBottomRight:null,autoPanPadding:[5,5],keepInView:!1,closeButton:!0,autoClose:!0,closeOnEscapeKey:!0,className:""},openOn:function(g){return g=arguments.length?g:this._source._map,!g.hasLayer(this)&&g._popup&&g._popup.options.autoClose&&g.removeLayer(g._popup),g._popup=this,Te.prototype.openOn.call(this,g)},onAdd:function(g){Te.prototype.onAdd.call(this,g),g.fire("popupopen",{popup:this}),this._source&&(this._source.fire("popupopen",{popup:this},!0),this._source instanceof Wi||this._source.on("preclick",Cn))},onRemove:function(g){Te.prototype.onRemove.call(this,g),g.fire("popupclose",{popup:this}),this._source&&(this._source.fire("popupclose",{popup:this},!0),this._source instanceof Wi||this._source.off("preclick",Cn))},getEvents:function(){var g=Te.prototype.getEvents.call(this);return(this.options.closeOnClick!==void 0?this.options.closeOnClick:this._map.options.closePopupOnClick)&&(g.preclick=this.close),this.options.keepInView&&(g.moveend=this._adjustPan),g},_initLayout:function(){var g="leaflet-popup",j=this._container=Tr("div",g+" "+(this.options.className||"")+" leaflet-zoom-animated"),A=this._wrapper=Tr("div",g+"-content-wrapper",j);if(this._contentNode=Tr("div",g+"-content",A),yo(j),Hn(this._contentNode),mr(j,"contextmenu",Cn),this._tipContainer=Tr("div",g+"-tip-container",j),this._tip=Tr("div",g+"-tip",this._tipContainer),this.options.closeButton){var W=this._closeButton=Tr("a",g+"-close-button",j);W.setAttribute("role","button"),W.setAttribute("aria-label","Close popup"),W.href="#close",W.innerHTML='<span aria-hidden="true">×</span>',mr(W,"click",function(ce){Za(ce),this.close()},this)}},_updateLayout:function(){var g=this._contentNode,j=g.style;j.width="",j.whiteSpace="nowrap";var A=g.offsetWidth;A=Math.min(A,this.options.maxWidth),A=Math.max(A,this.options.minWidth),j.width=A+1+"px",j.whiteSpace="",j.height="";var W=g.offsetHeight,ce=this.options.maxHeight,Ne="leaflet-popup-scrolled";ce&&W>ce?(j.height=ce+"px",ft(g,Ne)):dr(g,Ne),this._containerWidth=this._container.offsetWidth},_animateZoom:function(g){var j=this._map._latLngToNewLayerPoint(this._latlng,g.zoom,g.center),A=this._getAnchor();Sr(this._container,j.add(A))},_adjustPan:function(){if(this.options.autoPan){if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning){this._autopanning=!1;return}var g=this._map,j=parseInt(Un(this._container,"marginBottom"),10)||0,A=this._container.offsetHeight+j,W=this._containerWidth,ce=new U(this._containerLeft,-A-this._containerBottom);ce._add(ji(this._container));var Ne=g.layerPointToContainerPoint(ce),Ge=X(this.options.autoPanPadding),xt=X(this.options.autoPanPaddingTopLeft||Ge),Nt=X(this.options.autoPanPaddingBottomRight||Ge),qt=g.getSize(),cr=0,Cr=0;Ne.x+W+Nt.x>qt.x&&(cr=Ne.x+W-qt.x+Nt.x),Ne.x-cr-xt.x<0&&(cr=Ne.x-xt.x),Ne.y+A+Nt.y>qt.y&&(Cr=Ne.y+A-qt.y+Nt.y),Ne.y-Cr-xt.y<0&&(Cr=Ne.y-xt.y),(cr||Cr)&&(this.options.keepInView&&(this._autopanning=!0),g.fire("autopanstart").panBy([cr,Cr]))}},_getAnchor:function(){return X(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),Kt=function(g,j){return new qe(g,j)};la.mergeOptions({closePopupOnClick:!0}),la.include({openPopup:function(g,j,A){return this._initOverlay(qe,g,j,A).openOn(this),this},closePopup:function(g){return g=arguments.length?g:this._popup,g&&g.close(),this}}),ka.include({bindPopup:function(g,j){return this._popup=this._initOverlay(qe,this._popup,g,j),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(g){return this._popup&&(this instanceof Ui||(this._popup._source=this),this._popup._prepareOpen(g||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return this._popup?this._popup.isOpen():!1},setPopupContent:function(g){return this._popup&&this._popup.setContent(g),this},getPopup:function(){return this._popup},_openPopup:function(g){if(!(!this._popup||!this._map)){ni(g);var j=g.layer||g.target;if(this._popup._source===j&&!(j instanceof Wi)){this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(g.latlng);return}this._popup._source=j,this.openPopup(g.latlng)}},_movePopup:function(g){this._popup.setLatLng(g.latlng)},_onKeyPress:function(g){g.originalEvent.keyCode===13&&this._openPopup(g)}});var lr=Te.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(g){Te.prototype.onAdd.call(this,g),this.setOpacity(this.options.opacity),g.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(g){Te.prototype.onRemove.call(this,g),g.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var g=Te.prototype.getEvents.call(this);return this.options.permanent||(g.preclick=this.close),g},_initLayout:function(){var g="leaflet-tooltip",j=g+" "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=Tr("div",j),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+c(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(g){var j,A,W=this._map,ce=this._container,Ne=W.latLngToContainerPoint(W.getCenter()),Ge=W.layerPointToContainerPoint(g),xt=this.options.direction,Nt=ce.offsetWidth,qt=ce.offsetHeight,cr=X(this.options.offset),Cr=this._getAnchor();xt==="top"?(j=Nt/2,A=qt):xt==="bottom"?(j=Nt/2,A=0):xt==="center"?(j=Nt/2,A=qt/2):xt==="right"?(j=0,A=qt/2):xt==="left"?(j=Nt,A=qt/2):Ge.x<Ne.x?(xt="right",j=0,A=qt/2):(xt="left",j=Nt+(cr.x+Cr.x)*2,A=qt/2),g=g.subtract(X(j,A,!0)).add(cr).add(Cr),dr(ce,"leaflet-tooltip-right"),dr(ce,"leaflet-tooltip-left"),dr(ce,"leaflet-tooltip-top"),dr(ce,"leaflet-tooltip-bottom"),ft(ce,"leaflet-tooltip-"+xt),Sr(ce,g)},_updatePosition:function(){var g=this._map.latLngToLayerPoint(this._latlng);this._setPosition(g)},setOpacity:function(g){this.options.opacity=g,this._container&&ar(this._container,g)},_animateZoom:function(g){var j=this._map._latLngToNewLayerPoint(this._latlng,g.zoom,g.center);this._setPosition(j)},_getAnchor:function(){return X(this._source&&this._source._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}}),Ht=function(g,j){return new lr(g,j)};la.include({openTooltip:function(g,j,A){return this._initOverlay(lr,g,j,A).openOn(this),this},closeTooltip:function(g){return g.close(),this}}),ka.include({bindTooltip:function(g,j){return this._tooltip&&this.isTooltipOpen()&&this.unbindTooltip(),this._tooltip=this._initOverlay(lr,this._tooltip,g,j),this._initTooltipInteractions(),this._tooltip.options.permanent&&this._map&&this._map.hasLayer(this)&&this.openTooltip(),this},unbindTooltip:function(){return this._tooltip&&(this._initTooltipInteractions(!0),this.closeTooltip(),this._tooltip=null),this},_initTooltipInteractions:function(g){if(!(!g&&this._tooltipHandlersAdded)){var j=g?"off":"on",A={remove:this.closeTooltip,move:this._moveTooltip};this._tooltip.options.permanent?A.add=this._openTooltip:(A.mouseover=this._openTooltip,A.mouseout=this.closeTooltip,A.click=this._openTooltip,this._map?this._addFocusListeners():A.add=this._addFocusListeners),this._tooltip.options.sticky&&(A.mousemove=this._moveTooltip),this[j](A),this._tooltipHandlersAdded=!g}},openTooltip:function(g){return this._tooltip&&(this instanceof Ui||(this._tooltip._source=this),this._tooltip._prepareOpen(g)&&(this._tooltip.openOn(this._map),this.getElement?this._setAriaDescribedByOnLayer(this):this.eachLayer&&this.eachLayer(this._setAriaDescribedByOnLayer,this))),this},closeTooltip:function(){if(this._tooltip)return this._tooltip.close()},toggleTooltip:function(){return this._tooltip&&this._tooltip.toggle(this),this},isTooltipOpen:function(){return this._tooltip.isOpen()},setTooltipContent:function(g){return this._tooltip&&this._tooltip.setContent(g),this},getTooltip:function(){return this._tooltip},_addFocusListeners:function(){this.getElement?this._addFocusListenersOnLayer(this):this.eachLayer&&this.eachLayer(this._addFocusListenersOnLayer,this)},_addFocusListenersOnLayer:function(g){var j=typeof g.getElement=="function"&&g.getElement();j&&(mr(j,"focus",function(){this._tooltip._source=g,this.openTooltip()},this),mr(j,"blur",this.closeTooltip,this))},_setAriaDescribedByOnLayer:function(g){var j=typeof g.getElement=="function"&&g.getElement();j&&j.setAttribute("aria-describedby",this._tooltip._container.id)},_openTooltip:function(g){if(!(!this._tooltip||!this._map)){if(this._map.dragging&&this._map.dragging.moving()&&!this._openOnceFlag){this._openOnceFlag=!0;var j=this;this._map.once("moveend",function(){j._openOnceFlag=!1,j._openTooltip(g)});return}this._tooltip._source=g.layer||g.target,this.openTooltip(this._tooltip.options.sticky?g.latlng:void 0)}},_moveTooltip:function(g){var j=g.latlng,A,W;this._tooltip.options.sticky&&g.originalEvent&&(A=this._map.mouseEventToContainerPoint(g.originalEvent),W=this._map.containerPointToLayerPoint(A),j=this._map.layerPointToLatLng(W)),this._tooltip.setLatLng(j)}});var jr=Bi.extend({options:{iconSize:[12,12],html:!1,bgPos:null,className:"leaflet-div-icon"},createIcon:function(g){var j=g&&g.tagName==="DIV"?g:document.createElement("div"),A=this.options;if(A.html instanceof Element?(ws(j),j.appendChild(A.html)):j.innerHTML=A.html!==!1?A.html:"",A.bgPos){var W=X(A.bgPos);j.style.backgroundPosition=-W.x+"px "+-W.y+"px"}return this._setIconStyles(j,"icon"),j},createShadow:function(){return null}});function ra(g){return new jr(g)}Bi.Default=td;var ns=ka.extend({options:{tileSize:256,opacity:1,updateWhenIdle:Xe.mobile,updateWhenZooming:!0,updateInterval:200,zIndex:1,bounds:null,minZoom:0,maxZoom:void 0,maxNativeZoom:void 0,minNativeZoom:void 0,noWrap:!1,pane:"tilePane",className:"",keepBuffer:2},initialize:function(g){v(this,g)},onAdd:function(){this._initContainer(),this._levels={},this._tiles={},this._resetView()},beforeAdd:function(g){g._addZoomLimit(this)},onRemove:function(g){this._removeAllTiles(),Ir(this._container),g._removeZoomLimit(this),this._container=null,this._tileZoom=void 0},bringToFront:function(){return this._map&&(Ca(this._container),this._setAutoZIndex(Math.max)),this},bringToBack:function(){return this._map&&(pn(this._container),this._setAutoZIndex(Math.min)),this},getContainer:function(){return this._container},setOpacity:function(g){return this.options.opacity=g,this._updateOpacity(),this},setZIndex:function(g){return this.options.zIndex=g,this._updateZIndex(),this},isLoading:function(){return this._loading},redraw:function(){if(this._map){this._removeAllTiles();var g=this._clampZoom(this._map.getZoom());g!==this._tileZoom&&(this._tileZoom=g,this._updateLevels()),this._update()}return this},getEvents:function(){var g={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};return this.options.updateWhenIdle||(this._onMove||(this._onMove=u(this._onMoveEnd,this.options.updateInterval,this)),g.move=this._onMove),this._zoomAnimated&&(g.zoomanim=this._animateZoom),g},createTile:function(){return document.createElement("div")},getTileSize:function(){var g=this.options.tileSize;return g instanceof U?g:new U(g,g)},_updateZIndex:function(){this._container&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(g){for(var j=this.getPane().children,A=-g(-1/0,1/0),W=0,ce=j.length,Ne;W<ce;W++)Ne=j[W].style.zIndex,j[W]!==this._container&&Ne&&(A=g(A,+Ne));isFinite(A)&&(this.options.zIndex=A+g(-1,1),this._updateZIndex())},_updateOpacity:function(){if(this._map&&!Xe.ielt9){ar(this._container,this.options.opacity);var g=+new Date,j=!1,A=!1;for(var W in this._tiles){var ce=this._tiles[W];if(!(!ce.current||!ce.loaded)){var Ne=Math.min(1,(g-ce.loaded)/200);ar(ce.el,Ne),Ne<1?j=!0:(ce.active?A=!0:this._onOpaqueTile(ce),ce.active=!0)}}A&&!this._noPrune&&this._pruneTiles(),j&&(ee(this._fadeFrame),this._fadeFrame=ae(this._updateOpacity,this))}},_onOpaqueTile:f,_initContainer:function(){this._container||(this._container=Tr("div","leaflet-layer "+(this.options.className||"")),this._updateZIndex(),this.options.opacity<1&&this._updateOpacity(),this.getPane().appendChild(this._container))},_updateLevels:function(){var g=this._tileZoom,j=this.options.maxZoom;if(g!==void 0){for(var A in this._levels)A=Number(A),this._levels[A].el.children.length||A===g?(this._levels[A].el.style.zIndex=j-Math.abs(g-A),this._onUpdateLevel(A)):(Ir(this._levels[A].el),this._removeTilesAtZoom(A),this._onRemoveLevel(A),delete this._levels[A]);var W=this._levels[g],ce=this._map;return W||(W=this._levels[g]={},W.el=Tr("div","leaflet-tile-container leaflet-zoom-animated",this._container),W.el.style.zIndex=j,W.origin=ce.project(ce.unproject(ce.getPixelOrigin()),g).round(),W.zoom=g,this._setZoomTransform(W,ce.getCenter(),ce.getZoom()),f(W.el.offsetWidth),this._onCreateLevel(W)),this._level=W,W}},_onUpdateLevel:f,_onRemoveLevel:f,_onCreateLevel:f,_pruneTiles:function(){if(this._map){var g,j,A=this._map.getZoom();if(A>this.options.maxZoom||A<this.options.minZoom){this._removeAllTiles();return}for(g in this._tiles)j=this._tiles[g],j.retain=j.current;for(g in this._tiles)if(j=this._tiles[g],j.current&&!j.active){var W=j.coords;this._retainParent(W.x,W.y,W.z,W.z-5)||this._retainChildren(W.x,W.y,W.z,W.z+2)}for(g in this._tiles)this._tiles[g].retain||this._removeTile(g)}},_removeTilesAtZoom:function(g){for(var j in this._tiles)this._tiles[j].coords.z===g&&this._removeTile(j)},_removeAllTiles:function(){for(var g in this._tiles)this._removeTile(g)},_invalidateAll:function(){for(var g in this._levels)Ir(this._levels[g].el),this._onRemoveLevel(Number(g)),delete this._levels[g];this._removeAllTiles(),this._tileZoom=void 0},_retainParent:function(g,j,A,W){var ce=Math.floor(g/2),Ne=Math.floor(j/2),Ge=A-1,xt=new U(+ce,+Ne);xt.z=+Ge;var Nt=this._tileCoordsToKey(xt),qt=this._tiles[Nt];return qt&&qt.active?(qt.retain=!0,!0):(qt&&qt.loaded&&(qt.retain=!0),Ge>W?this._retainParent(ce,Ne,Ge,W):!1)},_retainChildren:function(g,j,A,W){for(var ce=2*g;ce<2*g+2;ce++)for(var Ne=2*j;Ne<2*j+2;Ne++){var Ge=new U(ce,Ne);Ge.z=A+1;var xt=this._tileCoordsToKey(Ge),Nt=this._tiles[xt];if(Nt&&Nt.active){Nt.retain=!0;continue}else Nt&&Nt.loaded&&(Nt.retain=!0);A+1<W&&this._retainChildren(ce,Ne,A+1,W)}},_resetView:function(g){var j=g&&(g.pinch||g.flyTo);this._setView(this._map.getCenter(),this._map.getZoom(),j,j)},_animateZoom:function(g){this._setView(g.center,g.zoom,!0,g.noUpdate)},_clampZoom:function(g){var j=this.options;return j.minNativeZoom!==void 0&&g<j.minNativeZoom?j.minNativeZoom:j.maxNativeZoom!==void 0&&j.maxNativeZoom<g?j.maxNativeZoom:g},_setView:function(g,j,A,W){var ce=Math.round(j);this.options.maxZoom!==void 0&&ce>this.options.maxZoom||this.options.minZoom!==void 0&&ce<this.options.minZoom?ce=void 0:ce=this._clampZoom(ce);var Ne=this.options.updateWhenZooming&&ce!==this._tileZoom;(!W||Ne)&&(this._tileZoom=ce,this._abortLoading&&this._abortLoading(),this._updateLevels(),this._resetGrid(),ce!==void 0&&this._update(g),A||this._pruneTiles(),this._noPrune=!!A),this._setZoomTransforms(g,j)},_setZoomTransforms:function(g,j){for(var A in this._levels)this._setZoomTransform(this._levels[A],g,j)},_setZoomTransform:function(g,j,A){var W=this._map.getZoomScale(A,g.zoom),ce=g.origin.multiplyBy(W).subtract(this._map._getNewPixelOrigin(j,A)).round();Xe.any3d?Ba(g.el,ce,W):Sr(g.el,ce)},_resetGrid:function(){var g=this._map,j=g.options.crs,A=this._tileSize=this.getTileSize(),W=this._tileZoom,ce=this._map.getPixelWorldBounds(this._tileZoom);ce&&(this._globalTileRange=this._pxBoundsToTileRange(ce)),this._wrapX=j.wrapLng&&!this.options.noWrap&&[Math.floor(g.project([0,j.wrapLng[0]],W).x/A.x),Math.ceil(g.project([0,j.wrapLng[1]],W).x/A.y)],this._wrapY=j.wrapLat&&!this.options.noWrap&&[Math.floor(g.project([j.wrapLat[0],0],W).y/A.x),Math.ceil(g.project([j.wrapLat[1],0],W).y/A.y)]},_onMoveEnd:function(){!this._map||this._map._animatingZoom||this._update()},_getTiledPixelBounds:function(g){var j=this._map,A=j._animatingZoom?Math.max(j._animateToZoom,j.getZoom()):j.getZoom(),W=j.getZoomScale(A,this._tileZoom),ce=j.project(g,this._tileZoom).floor(),Ne=j.getSize().divideBy(W*2);return new V(ce.subtract(Ne),ce.add(Ne))},_update:function(g){var j=this._map;if(j){var A=this._clampZoom(j.getZoom());if(g===void 0&&(g=j.getCenter()),this._tileZoom!==void 0){var W=this._getTiledPixelBounds(g),ce=this._pxBoundsToTileRange(W),Ne=ce.getCenter(),Ge=[],xt=this.options.keepBuffer,Nt=new V(ce.getBottomLeft().subtract([xt,-xt]),ce.getTopRight().add([xt,-xt]));if(!(isFinite(ce.min.x)&&isFinite(ce.min.y)&&isFinite(ce.max.x)&&isFinite(ce.max.y)))throw new Error("Attempted to load an infinite number of tiles");for(var qt in this._tiles){var cr=this._tiles[qt].coords;(cr.z!==this._tileZoom||!Nt.contains(new U(cr.x,cr.y)))&&(this._tiles[qt].current=!1)}if(Math.abs(A-this._tileZoom)>1){this._setView(g,A);return}for(var Cr=ce.min.y;Cr<=ce.max.y;Cr++)for(var Jr=ce.min.x;Jr<=ce.max.x;Jr++){var fn=new U(Jr,Cr);if(fn.z=this._tileZoom,!!this._isValidTile(fn)){var Fs=this._tiles[this._tileCoordsToKey(fn)];Fs?Fs.current=!0:Ge.push(fn)}}if(Ge.sort(function(Ta,Ea){return Ta.distanceTo(Ne)-Ea.distanceTo(Ne)}),Ge.length!==0){this._loading||(this._loading=!0,this.fire("loading"));var Ci=document.createDocumentFragment();for(Jr=0;Jr<Ge.length;Jr++)this._addTile(Ge[Jr],Ci);this._level.el.appendChild(Ci)}}}},_isValidTile:function(g){var j=this._map.options.crs;if(!j.infinite){var A=this._globalTileRange;if(!j.wrapLng&&(g.x<A.min.x||g.x>A.max.x)||!j.wrapLat&&(g.y<A.min.y||g.y>A.max.y))return!1}if(!this.options.bounds)return!0;var W=this._tileCoordsToBounds(g);return Q(this.options.bounds).overlaps(W)},_keyToBounds:function(g){return this._tileCoordsToBounds(this._keyToTileCoords(g))},_tileCoordsToNwSe:function(g){var j=this._map,A=this.getTileSize(),W=g.scaleBy(A),ce=W.add(A),Ne=j.unproject(W,g.z),Ge=j.unproject(ce,g.z);return[Ne,Ge]},_tileCoordsToBounds:function(g){var j=this._tileCoordsToNwSe(g),A=new B(j[0],j[1]);return this.options.noWrap||(A=this._map.wrapLatLngBounds(A)),A},_tileCoordsToKey:function(g){return g.x+":"+g.y+":"+g.z},_keyToTileCoords:function(g){var j=g.split(":"),A=new U(+j[0],+j[1]);return A.z=+j[2],A},_removeTile:function(g){var j=this._tiles[g];j&&(Ir(j.el),delete this._tiles[g],this.fire("tileunload",{tile:j.el,coords:this._keyToTileCoords(g)}))},_initTile:function(g){ft(g,"leaflet-tile");var j=this.getTileSize();g.style.width=j.x+"px",g.style.height=j.y+"px",g.onselectstart=f,g.onmousemove=f,Xe.ielt9&&this.options.opacity<1&&ar(g,this.options.opacity)},_addTile:function(g,j){var A=this._getTilePos(g),W=this._tileCoordsToKey(g),ce=this.createTile(this._wrapCoords(g),o(this._tileReady,this,g));this._initTile(ce),this.createTile.length<2&&ae(o(this._tileReady,this,g,null,ce)),Sr(ce,A),this._tiles[W]={el:ce,coords:g,current:!0},j.appendChild(ce),this.fire("tileloadstart",{tile:ce,coords:g})},_tileReady:function(g,j,A){j&&this.fire("tileerror",{error:j,tile:A,coords:g});var W=this._tileCoordsToKey(g);A=this._tiles[W],A&&(A.loaded=+new Date,this._map._fadeAnimated?(ar(A.el,0),ee(this._fadeFrame),this._fadeFrame=ae(this._updateOpacity,this)):(A.active=!0,this._pruneTiles()),j||(ft(A.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:A.el,coords:g})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),Xe.ielt9||!this._map._fadeAnimated?ae(this._pruneTiles,this):setTimeout(o(this._pruneTiles,this),250)))},_getTilePos:function(g){return g.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(g){var j=new U(this._wrapX?h(g.x,this._wrapX):g.x,this._wrapY?h(g.y,this._wrapY):g.y);return j.z=g.z,j},_pxBoundsToTileRange:function(g){var j=this.getTileSize();return new V(g.min.unscaleBy(j).floor(),g.max.unscaleBy(j).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var g in this._tiles)if(!this._tiles[g].loaded)return!1;return!0}});function ha(g){return new ns(g)}var fs=ns.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(g,j){this._url=g,j=v(this,j),j.detectRetina&&Xe.retina&&j.maxZoom>0?(j.tileSize=Math.floor(j.tileSize/2),j.zoomReverse?(j.zoomOffset--,j.minZoom=Math.min(j.maxZoom,j.minZoom+1)):(j.zoomOffset++,j.maxZoom=Math.max(j.minZoom,j.maxZoom-1)),j.minZoom=Math.max(0,j.minZoom)):j.zoomReverse?j.minZoom=Math.min(j.maxZoom,j.minZoom):j.maxZoom=Math.max(j.minZoom,j.maxZoom),typeof j.subdomains=="string"&&(j.subdomains=j.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(g,j){return this._url===g&&j===void 0&&(j=!0),this._url=g,j||this.redraw(),this},createTile:function(g,j){var A=document.createElement("img");return mr(A,"load",o(this._tileOnLoad,this,j,A)),mr(A,"error",o(this._tileOnError,this,j,A)),(this.options.crossOrigin||this.options.crossOrigin==="")&&(A.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),typeof this.options.referrerPolicy=="string"&&(A.referrerPolicy=this.options.referrerPolicy),A.alt="",A.src=this.getTileUrl(g),A},getTileUrl:function(g){var j={r:Xe.retina?"@2x":"",s:this._getSubdomain(g),x:g.x,y:g.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var A=this._globalTileRange.max.y-g.y;this.options.tms&&(j.y=A),j["-y"]=A}return N(this._url,n(j,this.options))},_tileOnLoad:function(g,j){Xe.ielt9?setTimeout(o(g,this,null,j),0):g(null,j)},_tileOnError:function(g,j,A){var W=this.options.errorTileUrl;W&&j.getAttribute("src")!==W&&(j.src=W),g(A,j)},_onTileRemove:function(g){g.tile.onload=null},_getZoomForUrl:function(){var g=this._tileZoom,j=this.options.maxZoom,A=this.options.zoomReverse,W=this.options.zoomOffset;return A&&(g=j-g),g+W},_getSubdomain:function(g){var j=Math.abs(g.x+g.y)%this.options.subdomains.length;return this.options.subdomains[j]},_abortLoading:function(){var g,j;for(g in this._tiles)if(this._tiles[g].coords.z!==this._tileZoom&&(j=this._tiles[g].el,j.onload=f,j.onerror=f,!j.complete)){j.src=T;var A=this._tiles[g].coords;Ir(j),delete this._tiles[g],this.fire("tileabort",{tile:j,coords:A})}},_removeTile:function(g){var j=this._tiles[g];if(j)return j.el.setAttribute("src",T),ns.prototype._removeTile.call(this,g)},_tileReady:function(g,j,A){if(!(!this._map||A&&A.getAttribute("src")===T))return ns.prototype._tileReady.call(this,g,j,A)}});function is(g,j){return new fs(g,j)}var Es=fs.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(g,j){this._url=g;var A=n({},this.defaultWmsParams);for(var W in j)W in this.options||(A[W]=j[W]);j=v(this,j);var ce=j.detectRetina&&Xe.retina?2:1,Ne=this.getTileSize();A.width=Ne.x*ce,A.height=Ne.y*ce,this.wmsParams=A},onAdd:function(g){this._crs=this.options.crs||g.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var j=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[j]=this._crs.code,fs.prototype.onAdd.call(this,g)},getTileUrl:function(g){var j=this._tileCoordsToNwSe(g),A=this._crs,W=I(A.project(j[0]),A.project(j[1])),ce=W.min,Ne=W.max,Ge=(this._wmsVersion>=1.3&&this._crs===f0?[ce.y,ce.x,Ne.y,Ne.x]:[ce.x,ce.y,Ne.x,Ne.y]).join(","),xt=fs.prototype.getTileUrl.call(this,g);return xt+k(this.wmsParams,xt,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+Ge},setParams:function(g,j){return n(this.wmsParams,g),j||this.redraw(),this}});function Xa(g,j){return new Es(g,j)}fs.WMS=Es,is.wms=Xa;var zr=ka.extend({options:{padding:.1},initialize:function(g){v(this,g),c(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),ft(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var g={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(g.zoomanim=this._onAnimZoom),g},_onAnimZoom:function(g){this._updateTransform(g.center,g.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(g,j){var A=this._map.getZoomScale(j,this._zoom),W=this._map.getSize().multiplyBy(.5+this.options.padding),ce=this._map.project(this._center,j),Ne=W.multiplyBy(-A).add(ce).subtract(this._map._getNewPixelOrigin(g,j));Xe.any3d?Ba(this._container,Ne,A):Sr(this._container,Ne)},_reset:function(){this._update(),this._updateTransform(this._center,this._zoom);for(var g in this._layers)this._layers[g]._reset()},_onZoomEnd:function(){for(var g in this._layers)this._layers[g]._project()},_updatePaths:function(){for(var g in this._layers)this._layers[g]._update()},_update:function(){var g=this.options.padding,j=this._map.getSize(),A=this._map.containerPointToLayerPoint(j.multiplyBy(-g)).round();this._bounds=new V(A,A.add(j.multiplyBy(1+g*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),Ni=zr.extend({options:{tolerance:0},getEvents:function(){var g=zr.prototype.getEvents.call(this);return g.viewprereset=this._onViewPreReset,g},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){zr.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var g=this._container=document.createElement("canvas");mr(g,"mousemove",this._onMouseMove,this),mr(g,"click dblclick mousedown mouseup contextmenu",this._onClick,this),mr(g,"mouseout",this._handleMouseOut,this),g._leaflet_disable_events=!0,this._ctx=g.getContext("2d")},_destroyContainer:function(){ee(this._redrawRequest),delete this._ctx,Ir(this._container),Hr(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var g;this._redrawBounds=null;for(var j in this._layers)g=this._layers[j],g._update();this._redraw()}},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){zr.prototype._update.call(this);var g=this._bounds,j=this._container,A=g.getSize(),W=Xe.retina?2:1;Sr(j,g.min),j.width=W*A.x,j.height=W*A.y,j.style.width=A.x+"px",j.style.height=A.y+"px",Xe.retina&&this._ctx.scale(2,2),this._ctx.translate(-g.min.x,-g.min.y),this.fire("update")}},_reset:function(){zr.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(g){this._updateDashArray(g),this._layers[c(g)]=g;var j=g._order={layer:g,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=j),this._drawLast=j,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(g){this._requestRedraw(g)},_removePath:function(g){var j=g._order,A=j.next,W=j.prev;A?A.prev=W:this._drawLast=W,W?W.next=A:this._drawFirst=A,delete g._order,delete this._layers[c(g)],this._requestRedraw(g)},_updatePath:function(g){this._extendRedrawBounds(g),g._project(),g._update(),this._requestRedraw(g)},_updateStyle:function(g){this._updateDashArray(g),this._requestRedraw(g)},_updateDashArray:function(g){if(typeof g.options.dashArray=="string"){var j=g.options.dashArray.split(/[, ]+/),A=[],W,ce;for(ce=0;ce<j.length;ce++){if(W=Number(j[ce]),isNaN(W))return;A.push(W)}g.options._dashArray=A}else g.options._dashArray=g.options.dashArray},_requestRedraw:function(g){this._map&&(this._extendRedrawBounds(g),this._redrawRequest=this._redrawRequest||ae(this._redraw,this))},_extendRedrawBounds:function(g){if(g._pxBounds){var j=(g.options.weight||0)+1;this._redrawBounds=this._redrawBounds||new V,this._redrawBounds.extend(g._pxBounds.min.subtract([j,j])),this._redrawBounds.extend(g._pxBounds.max.add([j,j]))}},_redraw:function(){this._redrawRequest=null,this._redrawBounds&&(this._redrawBounds.min._floor(),this._redrawBounds.max._ceil()),this._clear(),this._draw(),this._redrawBounds=null},_clear:function(){var g=this._redrawBounds;if(g){var j=g.getSize();this._ctx.clearRect(g.min.x,g.min.y,j.x,j.y)}else this._ctx.save(),this._ctx.setTransform(1,0,0,1,0,0),this._ctx.clearRect(0,0,this._container.width,this._container.height),this._ctx.restore()},_draw:function(){var g,j=this._redrawBounds;if(this._ctx.save(),j){var A=j.getSize();this._ctx.beginPath(),this._ctx.rect(j.min.x,j.min.y,A.x,A.y),this._ctx.clip()}this._drawing=!0;for(var W=this._drawFirst;W;W=W.next)g=W.layer,(!j||g._pxBounds&&g._pxBounds.intersects(j))&&g._updatePath();this._drawing=!1,this._ctx.restore()},_updatePoly:function(g,j){if(this._drawing){var A,W,ce,Ne,Ge=g._parts,xt=Ge.length,Nt=this._ctx;if(xt){for(Nt.beginPath(),A=0;A<xt;A++){for(W=0,ce=Ge[A].length;W<ce;W++)Ne=Ge[A][W],Nt[W?"lineTo":"moveTo"](Ne.x,Ne.y);j&&Nt.closePath()}this._fillStroke(Nt,g)}}},_updateCircle:function(g){if(!(!this._drawing||g._empty())){var j=g._point,A=this._ctx,W=Math.max(Math.round(g._radius),1),ce=(Math.max(Math.round(g._radiusY),1)||W)/W;ce!==1&&(A.save(),A.scale(1,ce)),A.beginPath(),A.arc(j.x,j.y/ce,W,0,Math.PI*2,!1),ce!==1&&A.restore(),this._fillStroke(A,g)}},_fillStroke:function(g,j){var A=j.options;A.fill&&(g.globalAlpha=A.fillOpacity,g.fillStyle=A.fillColor||A.color,g.fill(A.fillRule||"evenodd")),A.stroke&&A.weight!==0&&(g.setLineDash&&g.setLineDash(j.options&&j.options._dashArray||[]),g.globalAlpha=A.opacity,g.lineWidth=A.weight,g.strokeStyle=A.color,g.lineCap=A.lineCap,g.lineJoin=A.lineJoin,g.stroke())},_onClick:function(g){for(var j=this._map.mouseEventToLayerPoint(g),A,W,ce=this._drawFirst;ce;ce=ce.next)A=ce.layer,A.options.interactive&&A._containsPoint(j)&&(!(g.type==="click"||g.type==="preclick")||!this._map._draggableMoved(A))&&(W=A);this._fireEvent(W?[W]:!1,g)},_onMouseMove:function(g){if(!(!this._map||this._map.dragging.moving()||this._map._animatingZoom)){var j=this._map.mouseEventToLayerPoint(g);this._handleMouseHover(g,j)}},_handleMouseOut:function(g){var j=this._hoveredLayer;j&&(dr(this._container,"leaflet-interactive"),this._fireEvent([j],g,"mouseout"),this._hoveredLayer=null,this._mouseHoverThrottled=!1)},_handleMouseHover:function(g,j){if(!this._mouseHoverThrottled){for(var A,W,ce=this._drawFirst;ce;ce=ce.next)A=ce.layer,A.options.interactive&&A._containsPoint(j)&&(W=A);W!==this._hoveredLayer&&(this._handleMouseOut(g),W&&(ft(this._container,"leaflet-interactive"),this._fireEvent([W],g,"mouseover"),this._hoveredLayer=W)),this._fireEvent(this._hoveredLayer?[this._hoveredLayer]:!1,g),this._mouseHoverThrottled=!0,setTimeout(o(function(){this._mouseHoverThrottled=!1},this),32)}},_fireEvent:function(g,j,A){this._map._fireDOMEvent(j,A||j.type,g)},_bringToFront:function(g){var j=g._order;if(j){var A=j.next,W=j.prev;if(A)A.prev=W;else return;W?W.next=A:A&&(this._drawFirst=A),j.prev=this._drawLast,this._drawLast.next=j,j.next=null,this._drawLast=j,this._requestRedraw(g)}},_bringToBack:function(g){var j=g._order;if(j){var A=j.next,W=j.prev;if(W)W.next=A;else return;A?A.prev=W:W&&(this._drawLast=W),j.prev=null,j.next=this._drawFirst,this._drawFirst.prev=j,this._drawFirst=j,this._requestRedraw(g)}}});function Zs(g){return Xe.canvas?new Ni(g):null}var ko=(function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(g){return document.createElement("<lvml:"+g+' class="lvml">')}}catch(g){}return function(g){return document.createElement("<"+g+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}})(),Si={_initContainer:function(){this._container=Tr("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(zr.prototype._update.call(this),this.fire("update"))},_initPath:function(g){var j=g._container=ko("shape");ft(j,"leaflet-vml-shape "+(this.options.className||"")),j.coordsize="1 1",g._path=ko("path"),j.appendChild(g._path),this._updateStyle(g),this._layers[c(g)]=g},_addPath:function(g){var j=g._container;this._container.appendChild(j),g.options.interactive&&g.addInteractiveTarget(j)},_removePath:function(g){var j=g._container;Ir(j),g.removeInteractiveTarget(j),delete this._layers[c(g)]},_updateStyle:function(g){var j=g._stroke,A=g._fill,W=g.options,ce=g._container;ce.stroked=!!W.stroke,ce.filled=!!W.fill,W.stroke?(j||(j=g._stroke=ko("stroke")),ce.appendChild(j),j.weight=W.weight+"px",j.color=W.color,j.opacity=W.opacity,W.dashArray?j.dashStyle=C(W.dashArray)?W.dashArray.join(" "):W.dashArray.replace(/( *, *)/g," "):j.dashStyle="",j.endcap=W.lineCap.replace("butt","flat"),j.joinstyle=W.lineJoin):j&&(ce.removeChild(j),g._stroke=null),W.fill?(A||(A=g._fill=ko("fill")),ce.appendChild(A),A.color=W.fillColor||W.color,A.opacity=W.fillOpacity):A&&(ce.removeChild(A),g._fill=null)},_updateCircle:function(g){var j=g._point.round(),A=Math.round(g._radius),W=Math.round(g._radiusY||A);this._setPath(g,g._empty()?"M0 0":"AL "+j.x+","+j.y+" "+A+","+W+" 0,"+65535*360)},_setPath:function(g,j){g._path.v=j},_bringToFront:function(g){Ca(g._container)},_bringToBack:function(g){pn(g._container)}},_s=Xe.vml?ko:M,Ml=zr.extend({_initContainer:function(){this._container=_s("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=_s("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){Ir(this._container),Hr(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){zr.prototype._update.call(this);var g=this._bounds,j=g.getSize(),A=this._container;(!this._svgSize||!this._svgSize.equals(j))&&(this._svgSize=j,A.setAttribute("width",j.x),A.setAttribute("height",j.y)),Sr(A,g.min),A.setAttribute("viewBox",[g.min.x,g.min.y,j.x,j.y].join(" ")),this.fire("update")}},_initPath:function(g){var j=g._path=_s("path");g.options.className&&ft(j,g.options.className),g.options.interactive&&ft(j,"leaflet-interactive"),this._updateStyle(g),this._layers[c(g)]=g},_addPath:function(g){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(g._path),g.addInteractiveTarget(g._path)},_removePath:function(g){Ir(g._path),g.removeInteractiveTarget(g._path),delete this._layers[c(g)]},_updatePath:function(g){g._project(),g._update()},_updateStyle:function(g){var j=g._path,A=g.options;j&&(A.stroke?(j.setAttribute("stroke",A.color),j.setAttribute("stroke-opacity",A.opacity),j.setAttribute("stroke-width",A.weight),j.setAttribute("stroke-linecap",A.lineCap),j.setAttribute("stroke-linejoin",A.lineJoin),A.dashArray?j.setAttribute("stroke-dasharray",A.dashArray):j.removeAttribute("stroke-dasharray"),A.dashOffset?j.setAttribute("stroke-dashoffset",A.dashOffset):j.removeAttribute("stroke-dashoffset")):j.setAttribute("stroke","none"),A.fill?(j.setAttribute("fill",A.fillColor||A.color),j.setAttribute("fill-opacity",A.fillOpacity),j.setAttribute("fill-rule",A.fillRule||"evenodd")):j.setAttribute("fill","none"))},_updatePoly:function(g,j){this._setPath(g,we(g._parts,j))},_updateCircle:function(g){var j=g._point,A=Math.max(Math.round(g._radius),1),W=Math.max(Math.round(g._radiusY),1)||A,ce="a"+A+","+W+" 0 1,0 ",Ne=g._empty()?"M0 0":"M"+(j.x-A)+","+j.y+ce+A*2+",0 "+ce+-A*2+",0 ";this._setPath(g,Ne)},_setPath:function(g,j){g._path.setAttribute("d",j)},_bringToFront:function(g){Ca(g._path)},_bringToBack:function(g){pn(g._path)}});Xe.vml&&Ml.include(Si);function y0(g){return Xe.svg||Xe.vml?new Ml(g):null}la.include({getRenderer:function(g){var j=g.options.renderer||this._getPaneRenderer(g.options.pane)||this.options.renderer||this._renderer;return j||(j=this._renderer=this._createRenderer()),this.hasLayer(j)||this.addLayer(j),j},_getPaneRenderer:function(g){if(g==="overlayPane"||g===void 0)return!1;var j=this._paneRenderers[g];return j===void 0&&(j=this._createRenderer({pane:g}),this._paneRenderers[g]=j),j},_createRenderer:function(g){return this.options.preferCanvas&&Zs(g)||y0(g)}});var dd=xc.extend({initialize:function(g,j){xc.prototype.initialize.call(this,this._boundsToLatLngs(g),j)},setBounds:function(g){return this.setLatLngs(this._boundsToLatLngs(g))},_boundsToLatLngs:function(g){return g=Q(g),[g.getSouthWest(),g.getNorthWest(),g.getNorthEast(),g.getSouthEast()]}});function lj(g,j){return new dd(g,j)}Ml.create=_s,Ml.pointsToPath=we,En.geometryToLayer=Ls,En.coordsToLatLng=hu,En.coordsToLatLngs=id,En.latLngToCoords=x0,En.latLngsToCoords=od,En.getFeature=Qo,En.asFeature=pu,la.mergeOptions({boxZoom:!0});var oi=zi.extend({initialize:function(g){this._map=g,this._container=g._container,this._pane=g._panes.overlayPane,this._resetStateTimeout=0,g.on("unload",this._destroy,this)},addHooks:function(){mr(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){Hr(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){Ir(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){this._resetStateTimeout!==0&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(g){if(!g.shiftKey||g.which!==1&&g.button!==1)return!1;this._clearDeferredResetState(),this._resetState(),_i(),Go(),this._startPoint=this._map.mouseEventToContainerPoint(g),mr(document,{contextmenu:ni,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(g){this._moved||(this._moved=!0,this._box=Tr("div","leaflet-zoom-box",this._container),ft(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(g);var j=new V(this._point,this._startPoint),A=j.getSize();Sr(this._box,j.min),this._box.style.width=A.x+"px",this._box.style.height=A.y+"px"},_finish:function(){this._moved&&(Ir(this._box),dr(this._container,"leaflet-crosshair")),js(),Ko(),Hr(document,{contextmenu:ni,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(g){if(!(g.which!==1&&g.button!==1)&&(this._finish(),!!this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(o(this._resetState,this),0);var j=new B(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(j).fire("boxzoomend",{boxZoomBounds:j})}},_onKeyDown:function(g){g.keyCode===27&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});la.addInitHook("addHandler","boxZoom",oi),la.mergeOptions({doubleClickZoom:!0});var nh=zi.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(g){var j=this._map,A=j.getZoom(),W=j.options.zoomDelta,ce=g.originalEvent.shiftKey?A-W:A+W;j.options.doubleClickZoom==="center"?j.setZoom(ce):j.setZoomAround(g.containerPoint,ce)}});la.addInitHook("addHandler","doubleClickZoom",nh),la.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var rl=zi.extend({addHooks:function(){if(!this._draggable){var g=this._map;this._draggable=new Xo(g._mapPane,g._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),g.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),g.on("zoomend",this._onZoomEnd,this),g.whenReady(this._onZoomEnd,this))}ft(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){dr(this._map._container,"leaflet-grab"),dr(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var g=this._map;if(g._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var j=Q(this._map.options.maxBounds);this._offsetLimit=I(this._map.latLngToContainerPoint(j.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(j.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;g.fire("movestart").fire("dragstart"),g.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(g){if(this._map.options.inertia){var j=this._lastTime=+new Date,A=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(A),this._times.push(j),this._prunePositions(j)}this._map.fire("move",g).fire("drag",g)},_prunePositions:function(g){for(;this._positions.length>1&&g-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var g=this._map.getSize().divideBy(2),j=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=j.subtract(g).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(g,j){return g-(g-j)*this._viscosity},_onPreDragLimit:function(){if(!(!this._viscosity||!this._offsetLimit)){var g=this._draggable._newPos.subtract(this._draggable._startPos),j=this._offsetLimit;g.x<j.min.x&&(g.x=this._viscousLimit(g.x,j.min.x)),g.y<j.min.y&&(g.y=this._viscousLimit(g.y,j.min.y)),g.x>j.max.x&&(g.x=this._viscousLimit(g.x,j.max.x)),g.y>j.max.y&&(g.y=this._viscousLimit(g.y,j.max.y)),this._draggable._newPos=this._draggable._startPos.add(g)}},_onPreDragWrap:function(){var g=this._worldWidth,j=Math.round(g/2),A=this._initialWorldOffset,W=this._draggable._newPos.x,ce=(W-j+A)%g+j-A,Ne=(W+j+A)%g-j-A,Ge=Math.abs(ce+A)<Math.abs(Ne+A)?ce:Ne;this._draggable._absPos=this._draggable._newPos.clone(),this._draggable._newPos.x=Ge},_onDragEnd:function(g){var j=this._map,A=j.options,W=!A.inertia||g.noInertia||this._times.length<2;if(j.fire("dragend",g),W)j.fire("moveend");else{this._prunePositions(+new Date);var ce=this._lastPos.subtract(this._positions[0]),Ne=(this._lastTime-this._times[0])/1e3,Ge=A.easeLinearity,xt=ce.multiplyBy(Ge/Ne),Nt=xt.distanceTo([0,0]),qt=Math.min(A.inertiaMaxSpeed,Nt),cr=xt.multiplyBy(qt/Nt),Cr=qt/(A.inertiaDeceleration*Ge),Jr=cr.multiplyBy(-Cr/2).round();!Jr.x&&!Jr.y?j.fire("moveend"):(Jr=j._limitOffset(Jr,j.options.maxBounds),ae(function(){j.panBy(Jr,{duration:Cr,easeLinearity:Ge,noMoveStart:!0,animate:!0})}))}}});la.addInitHook("addHandler","dragging",rl),la.mergeOptions({keyboard:!0,keyboardPanDelta:80});var ug=zi.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,54,173]},initialize:function(g){this._map=g,this._setPanDelta(g.options.keyboardPanDelta),this._setZoomDelta(g.options.zoomDelta)},addHooks:function(){var g=this._map._container;g.tabIndex<=0&&(g.tabIndex="0"),mr(g,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)},removeHooks:function(){this._removeHooks(),Hr(this._map._container,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.off({focus:this._addHooks,blur:this._removeHooks},this)},_onMouseDown:function(){if(!this._focused){var g=document.body,j=document.documentElement,A=g.scrollTop||j.scrollTop,W=g.scrollLeft||j.scrollLeft;this._map._container.focus(),window.scrollTo(W,A)}},_onFocus:function(){this._focused=!0,this._map.fire("focus")},_onBlur:function(){this._focused=!1,this._map.fire("blur")},_setPanDelta:function(g){var j=this._panKeys={},A=this.keyCodes,W,ce;for(W=0,ce=A.left.length;W<ce;W++)j[A.left[W]]=[-1*g,0];for(W=0,ce=A.right.length;W<ce;W++)j[A.right[W]]=[g,0];for(W=0,ce=A.down.length;W<ce;W++)j[A.down[W]]=[0,g];for(W=0,ce=A.up.length;W<ce;W++)j[A.up[W]]=[0,-1*g]},_setZoomDelta:function(g){var j=this._zoomKeys={},A=this.keyCodes,W,ce;for(W=0,ce=A.zoomIn.length;W<ce;W++)j[A.zoomIn[W]]=g;for(W=0,ce=A.zoomOut.length;W<ce;W++)j[A.zoomOut[W]]=-g},_addHooks:function(){mr(document,"keydown",this._onKeyDown,this)},_removeHooks:function(){Hr(document,"keydown",this._onKeyDown,this)},_onKeyDown:function(g){if(!(g.altKey||g.ctrlKey||g.metaKey)){var j=g.keyCode,A=this._map,W;if(j in this._panKeys){if(!A._panAnim||!A._panAnim._inProgress)if(W=this._panKeys[j],g.shiftKey&&(W=X(W).multiplyBy(3)),A.options.maxBounds&&(W=A._limitOffset(X(W),A.options.maxBounds)),A.options.worldCopyJump){var ce=A.wrapLatLng(A.unproject(A.project(A.getCenter()).add(W)));A.panTo(ce)}else A.panBy(W)}else if(j in this._zoomKeys)A.setZoom(A.getZoom()+(g.shiftKey?3:1)*this._zoomKeys[j]);else if(j===27&&A._popup&&A._popup.options.closeOnEscapeKey)A.closePopup();else return;ni(g)}}});la.addInitHook("addHandler","keyboard",ug),la.mergeOptions({scrollWheelZoom:!0,wheelDebounceTime:40,wheelPxPerZoomLevel:60});var b0=zi.extend({addHooks:function(){mr(this._map._container,"wheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){Hr(this._map._container,"wheel",this._onWheelScroll,this)},_onWheelScroll:function(g){var j=Ms(g),A=this._map.options.wheelDebounceTime;this._delta+=j,this._lastMousePos=this._map.mouseEventToContainerPoint(g),this._startTime||(this._startTime=+new Date);var W=Math.max(A-(+new Date-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(o(this._performZoom,this),W),ni(g)},_performZoom:function(){var g=this._map,j=g.getZoom(),A=this._map.options.zoomSnap||0;g._stop();var W=this._delta/(this._map.options.wheelPxPerZoomLevel*4),ce=4*Math.log(2/(1+Math.exp(-Math.abs(W))))/Math.LN2,Ne=A?Math.ceil(ce/A)*A:ce,Ge=g._limitZoom(j+(this._delta>0?Ne:-Ne))-j;this._delta=0,this._startTime=null,Ge&&(g.options.scrollWheelZoom==="center"?g.setZoom(j+Ge):g.setZoomAround(this._lastMousePos,j+Ge))}});la.addInitHook("addHandler","scrollWheelZoom",b0);var ud=600;la.mergeOptions({tapHold:Xe.touchNative&&Xe.safari&&Xe.mobile,tapTolerance:15});var ih=zi.extend({addHooks:function(){mr(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){Hr(this._map._container,"touchstart",this._onDown,this)},_onDown:function(g){if(clearTimeout(this._holdTimeout),g.touches.length===1){var j=g.touches[0];this._startPos=this._newPos=new U(j.clientX,j.clientY),this._holdTimeout=setTimeout(o(function(){this._cancel(),this._isTapValid()&&(mr(document,"touchend",Za),mr(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",j))},this),ud),mr(document,"touchend touchcancel contextmenu",this._cancel,this),mr(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function g(){Hr(document,"touchend",Za),Hr(document,"touchend touchcancel",g)},_cancel:function(){clearTimeout(this._holdTimeout),Hr(document,"touchend touchcancel contextmenu",this._cancel,this),Hr(document,"touchmove",this._onMove,this)},_onMove:function(g){var j=g.touches[0];this._newPos=new U(j.clientX,j.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(g,j){var A=new MouseEvent(g,{bubbles:!0,cancelable:!0,view:window,screenX:j.screenX,screenY:j.screenY,clientX:j.clientX,clientY:j.clientY});A._simulated=!0,j.target.dispatchEvent(A)}});la.addInitHook("addHandler","tapHold",ih),la.mergeOptions({touchZoom:Xe.touch,bounceAtZoomLimits:!0});var mg=zi.extend({addHooks:function(){ft(this._map._container,"leaflet-touch-zoom"),mr(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){dr(this._map._container,"leaflet-touch-zoom"),Hr(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(g){var j=this._map;if(!(!g.touches||g.touches.length!==2||j._animatingZoom||this._zooming)){var A=j.mouseEventToContainerPoint(g.touches[0]),W=j.mouseEventToContainerPoint(g.touches[1]);this._centerPoint=j.getSize()._divideBy(2),this._startLatLng=j.containerPointToLatLng(this._centerPoint),j.options.touchZoom!=="center"&&(this._pinchStartLatLng=j.containerPointToLatLng(A.add(W)._divideBy(2))),this._startDist=A.distanceTo(W),this._startZoom=j.getZoom(),this._moved=!1,this._zooming=!0,j._stop(),mr(document,"touchmove",this._onTouchMove,this),mr(document,"touchend touchcancel",this._onTouchEnd,this),Za(g)}},_onTouchMove:function(g){if(!(!g.touches||g.touches.length!==2||!this._zooming)){var j=this._map,A=j.mouseEventToContainerPoint(g.touches[0]),W=j.mouseEventToContainerPoint(g.touches[1]),ce=A.distanceTo(W)/this._startDist;if(this._zoom=j.getScaleZoom(ce,this._startZoom),!j.options.bounceAtZoomLimits&&(this._zoom<j.getMinZoom()&&ce<1||this._zoom>j.getMaxZoom()&&ce>1)&&(this._zoom=j._limitZoom(this._zoom)),j.options.touchZoom==="center"){if(this._center=this._startLatLng,ce===1)return}else{var Ne=A._add(W)._divideBy(2)._subtract(this._centerPoint);if(ce===1&&Ne.x===0&&Ne.y===0)return;this._center=j.unproject(j.project(this._pinchStartLatLng,this._zoom).subtract(Ne),this._zoom)}this._moved||(j._moveStart(!0,!1),this._moved=!0),ee(this._animRequest);var Ge=o(j._move,j,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=ae(Ge,this,!0),Za(g)}},_onTouchEnd:function(){if(!this._moved||!this._zooming){this._zooming=!1;return}this._zooming=!1,ee(this._animRequest),Hr(document,"touchmove",this._onTouchMove,this),Hr(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))}});la.addInitHook("addHandler","touchZoom",mg),la.BoxZoom=oi,la.DoubleClickZoom=nh,la.Drag=rl,la.Keyboard=ug,la.ScrollWheelZoom=b0,la.TapHold=ih,la.TouchZoom=mg,a.Bounds=V,a.Browser=Xe,a.CRS=he,a.Canvas=Ni,a.Circle=nd,a.CircleMarker=fc,a.Class=te,a.Control=Tn,a.DivIcon=jr,a.DivOverlay=Te,a.DomEvent=Gc,a.DomUtil=oa,a.Draggable=Xo,a.Evented=H,a.FeatureGroup=Ui,a.GeoJSON=En,a.GridLayer=ns,a.Handler=zi,a.Icon=Bi,a.ImageOverlay=tl,a.LatLng=ie,a.LatLngBounds=B,a.Layer=ka,a.LayerGroup=Pl,a.LineUtil=g0,a.Map=la,a.Marker=ad,a.Mixin=ig,a.Path=Wi,a.Point=U,a.PolyUtil=Zc,a.Polygon=xc,a.Polyline=Hi,a.Popup=qe,a.PosAnimation=Cl,a.Projection=Qm,a.Rectangle=dd,a.Renderer=zr,a.SVG=Ml,a.SVGOverlay=cd,a.TileLayer=fs,a.Tooltip=lr,a.Transformation=be,a.Util=ne,a.VideoOverlay=_o,a.bind=o,a.bounds=I,a.canvas=Zs,a.circle=ah,a.circleMarker=rh,a.control=Ii,a.divIcon=ra,a.extend=n,a.featureGroup=th,a.geoJSON=ld,a.geoJson=Dl,a.gridLayer=ha,a.icon=ed,a.imageOverlay=sh,a.latLng=me,a.latLngBounds=Q,a.layerGroup=dg,a.map=du,a.marker=sd,a.point=X,a.polygon=qi,a.polyline=mu,a.popup=Kt,a.rectangle=lj,a.setOptions=v,a.stamp=c,a.svg=y0,a.svgOverlay=fe,a.tileLayer=is,a.tooltip=Ht,a.transformation=K,a.version=s,a.videoOverlay=Rl;var hg=window.L;a.noConflict=function(){return window.L=hg,this},window.L=a}))})(jf,jf.exports)),jf.exports}var Kp=tie();const pw=tu(Kp);function gw(e,r,a){return Object.freeze({instance:e,context:r,container:a})}function DS(e,r){return r==null?function(s,n){const i=p.useRef(void 0);return i.current||(i.current=e(s,n)),i}:function(s,n){const i=p.useRef(void 0);i.current||(i.current=e(s,n));const o=p.useRef(s),{instance:l}=i.current;return p.useEffect(function(){o.current!==s&&(r(l,s,o.current),o.current=s)},[l,s,r]),i}}function rie(e,r){p.useEffect(function(){var n;return((n=r.layerContainer)!=null?n:r.map).addLayer(e.instance),function(){var o;(o=r.layerContainer)==null||o.removeLayer(e.instance),r.map.removeLayer(e.instance)}},[r,e])}function AL(e){return function(a){const s=OS(),n=e(PS(a,s),s);return TL(s.map,a.attribution),EL(n.current,a.eventHandlers),rie(n.current,s),n}}function aie(e,r){const a=DS(e,r),s=AL(a);return Jne(s)}function OL(e,r){const a=DS(e),s=Qne(a,r);return Zne(s)}function sie(e,r){const a=DS(e,r),s=AL(a);return Xne(s)}function nie(e,r,a){const{opacity:s,zIndex:n}=r;s!=null&&s!==a.opacity&&e.setOpacity(s),n!=null&&n!==a.zIndex&&e.setZIndex(n)}function iie(){return OS().map}function oie(y,f){var b=y,{bounds:e,boundsOptions:r,center:a,children:s,className:n,id:i,placeholder:o,style:l,whenReady:c,zoom:u}=b,h=li(b,["bounds","boundsOptions","center","children","className","id","placeholder","style","whenReady","zoom"]);const[w]=p.useState({className:n,id:i,style:l}),[v,k]=p.useState(null),S=p.useRef(void 0);p.useImperativeHandle(f,()=>{var O;return(O=v==null?void 0:v.map)!=null?O:null},[v]);const N=p.useCallback(O=>{if(O!==null&&!S.current){const T=new Kp.Map(O,h);S.current=T,a!=null&&u!=null?T.setView(a,u):e!=null&&T.fitBounds(e,r),c!=null&&T.whenReady(c),k(Kne(T))}},[]);p.useEffect(()=>()=>{v==null||v.map.remove()},[v]);const C=v?gr.createElement(AS,{value:v},s):o!=null?o:null;return gr.createElement("div",je(se({},w),{ref:N}),C)}const lie=p.forwardRef(oie),cie=aie(function(n,s){var i=n,{position:r}=i,a=li(i,["position"]);const o=new Kp.Marker(r,a);return gw(o,Yne(s,{overlayContainer:o}))},function(r,a,s){a.position!==s.position&&r.setLatLng(a.position),a.icon!=null&&a.icon!==s.icon&&r.setIcon(a.icon),a.zIndexOffset!=null&&a.zIndexOffset!==s.zIndexOffset&&r.setZIndexOffset(a.zIndexOffset),a.opacity!=null&&a.opacity!==s.opacity&&r.setOpacity(a.opacity),r.dragging!=null&&a.draggable!==s.draggable&&(a.draggable===!0?r.dragging.enable():r.dragging.disable())}),die=OL(function(r,a){const s=new Kp.Popup(r,a.overlayContainer);return gw(s,a)},function(r,a,{position:s},n){p.useEffect(function(){const{instance:o}=r;function l(u){u.popup===o&&(o.update(),n(!0))}function c(u){u.popup===o&&n(!1)}return a.map.on({popupopen:l,popupclose:c}),a.overlayContainer==null?(s!=null&&o.setLatLng(s),o.openOn(a.map)):a.overlayContainer.bindPopup(o),function(){var h;a.map.off({popupopen:l,popupclose:c}),(h=a.overlayContainer)==null||h.unbindPopup(),a.map.removeLayer(o)}},[r,a,n,s])}),uie=sie(function(n,s){var i=n,{url:r}=i,a=li(i,["url"]);const o=new Kp.TileLayer(r,PS(a,s));return gw(o,s)},function(r,a,s){nie(r,a,s);const{url:n}=a;n!=null&&n!==s.url&&r.setUrl(n)}),mie=OL(function(r,a){const s=new Kp.Tooltip(r,a.overlayContainer);return gw(s,a)},function(r,a,{position:s},n){p.useEffect(function(){const o=a.overlayContainer;if(o==null)return;const{instance:l}=r,c=h=>{h.tooltip===l&&(s!=null&&l.setLatLng(s),l.update(),n(!0))},u=h=>{h.tooltip===l&&n(!1)};return o.on({tooltipopen:c,tooltipclose:u}),o.bindTooltip(l),function(){o.off({tooltipopen:c,tooltipclose:u}),o._map!=null&&o.unbindTooltip()}},[r,a,n,s])}),PL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=",DL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC",RL=pw.icon({iconUrl:PL,shadowUrl:DL,iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]});pw.Marker.prototype.options.icon=RL;const hie=pw.icon({iconUrl:PL,shadowUrl:DL,iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41],className:"department-marker-icon"}),pie=({locations:e})=>{const r=iie();return p.useEffect(()=>{if(e.length>0&&e.some(a=>a.latitude&&a.longitude)){const a=pw.latLngBounds(e.filter(s=>s.latitude&&s.longitude).map(s=>[s.latitude,s.longitude]));r.fitBounds(a,{padding:[30,30],maxZoom:8})}else r.setView([24.8,45.5],6)},[e,r]),null},gie=()=>{const{t:e}=sr(),r=hr(),[a,s]=p.useState(""),[n,i]=p.useState(""),[o,l]=p.useState([]),[c,u]=p.useState(!0),h=p.useRef({}),[f,y]=p.useState(null),[b,w]=p.useState(!1);p.useEffect(()=>{J(null,null,function*(){try{const G=yield(yield fetch("/api/method/frappe.auth.get_logged_user")).json(),ae=G==null?void 0:G.message;if(!ae){console.warn("[ActiveMap] Could not determine logged-in user, response:",G),y(null),w(!0);return}console.log("[ActiveMap] Logged-in user:",ae);const ne=yield(yield fetch(`/api/resource/User Permission?filters=${encodeURIComponent(JSON.stringify({user:ae,allow:"Issue Type"}))}&fields=["for_value"]&limit_page_length=0`)).json(),te=(ne==null?void 0:ne.data)||[];if(te.length>0){const Y=te.map(q=>q.for_value).filter(Boolean);console.log("[ActiveMap] Allowed departments:",Y),y(Y)}else console.log("[ActiveMap] No Issue Type permissions → showing all departments"),y(null)}catch(z){console.error("[ActiveMap] Error fetching User Permissions:",z),y(null)}finally{w(!0)}})},[]);const v=()=>J(null,null,function*(){if(b){u(!0);try{const R=[];if(!n){const z={latitude:["!=",""],longitude:["!=",""],custom_is_hospital:1};a&&(z.name=a);const G=yield At.apiCall(`/api/resource/Location?filters=${encodeURIComponent(JSON.stringify(z))}&fields=["name","latitude","longitude"]&limit_page_length=0`),ee=((G==null?void 0:G.data)||[]).map(te=>J(null,null,function*(){var q,H,U,re,X,V,I,B,Q,ie,me;const Y={assets:0,normal_work_orders:0,urgent_work_orders:0,planned_maintenance:0,completed_maintenance:0,overdue_maintenance:0,wo_open:0,wo_progress:0,wo_review:0,wo_completed:0,wo_closed:0,locationType:"hospital"};try{const he=yield At.apiCall(`/api/resource/Asset?filters=${encodeURIComponent(JSON.stringify({company:te.name}))}&fields=["name"]&limit_page_length=0`);Y.assets=((q=he==null?void 0:he.data)==null?void 0:q.length)||0;const de=yield At.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:te.name,custom_priority_:"Normal",repair_status:["in",["Open","Work In Progress","Closed"]]}))}&fields=["name"]&limit_page_length=0`);Y.normal_work_orders=((H=de==null?void 0:de.data)==null?void 0:H.length)||0;const xe=yield At.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:te.name,custom_priority_:"Urgent",repair_status:["in",["Open","Work In Progress","Closed"]]}))}&fields=["name"]&limit_page_length=0`);Y.urgent_work_orders=((U=xe==null?void 0:xe.data)==null?void 0:U.length)||0;const[ge,be,K,ye,Z,M,we,pe]=yield Promise.all([At.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:te.name,repair_status:"Open"}))}&fields=["name"]&limit_page_length=0`),At.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:te.name,repair_status:"Work In Progress"}))}&fields=["name"]&limit_page_length=0`),At.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:te.name,repair_status:"Pending Review"}))}&fields=["name"]&limit_page_length=0`),At.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:te.name,repair_status:"Completed"}))}&fields=["name"]&limit_page_length=0`),At.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:te.name,repair_status:"Closed"}))}&fields=["name"]&limit_page_length=0`),At.apiCall(`/api/resource/Asset Maintenance Log?filters=${encodeURIComponent(JSON.stringify({custom_hospital_name:te.name,maintenance_status:"Planned"}))}&fields=["name"]&limit_page_length=0`),At.apiCall(`/api/resource/Asset Maintenance Log?filters=${encodeURIComponent(JSON.stringify({custom_hospital_name:te.name,maintenance_status:"Completed"}))}&fields=["name"]&limit_page_length=0`),At.apiCall(`/api/resource/Asset Maintenance Log?filters=${encodeURIComponent(JSON.stringify({custom_hospital_name:te.name,maintenance_status:"Overdue"}))}&fields=["name"]&limit_page_length=0`)]);Y.wo_open=((re=ge==null?void 0:ge.data)==null?void 0:re.length)||0,Y.wo_progress=((X=be==null?void 0:be.data)==null?void 0:X.length)||0,Y.wo_review=((V=K==null?void 0:K.data)==null?void 0:V.length)||0,Y.wo_completed=((I=ye==null?void 0:ye.data)==null?void 0:I.length)||0,Y.wo_closed=((B=Z==null?void 0:Z.data)==null?void 0:B.length)||0,Y.planned_maintenance=((Q=M==null?void 0:M.data)==null?void 0:Q.length)||0,Y.completed_maintenance=((ie=we==null?void 0:we.data)==null?void 0:ie.length)||0,Y.overdue_maintenance=((me=pe==null?void 0:pe.data)==null?void 0:me.length)||0}catch(he){console.error(`Error fetching counts for hospital ${te.name}:`,he)}return se({name:te.name,latitude:parseFloat(te.latitude),longitude:parseFloat(te.longitude)},Y)})),ne=yield Promise.all(ee);R.push(...ne.filter(te=>!isNaN(te.latitude)&&!isNaN(te.longitude)))}if(!a){const z={latitude:["!=",""],longitude:["!=",""],custom_is_wo_type:1};if(n&&(z.name=n),f!==null&&f.length>0&&!n)z.name=["in",f];else if(f!==null&&f.length===0){console.log("[ActiveMap] User has Issue Type permissions but no matching values — skipping departments"),l(R),u(!1);return}console.log("[ActiveMap] Department filters:",z);const G=yield At.apiCall(`/api/resource/Location?filters=${encodeURIComponent(JSON.stringify(z))}&fields=["name","latitude","longitude"]&limit_page_length=0`),ae=(G==null?void 0:G.data)||[];console.log("[ActiveMap] Departments to show on map:",ae.map(te=>te.name));const ee=ae.map(te=>J(null,null,function*(){var q,H,U,re,X,V,I;const Y={assets:0,normal_work_orders:0,urgent_work_orders:0,planned_maintenance:0,completed_maintenance:0,overdue_maintenance:0,wo_open:0,wo_progress:0,wo_review:0,wo_completed:0,wo_closed:0,locationType:"department"};try{const B=yield At.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:te.name,custom_priority_:"Normal",repair_status:["in",["Open","Work In Progress","Closed"]]}))}&fields=["name"]&limit_page_length=0`);Y.normal_work_orders=((q=B==null?void 0:B.data)==null?void 0:q.length)||0;const Q=yield At.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:te.name,custom_priority_:"Urgent",repair_status:["in",["Open","Work In Progress","Closed"]]}))}&fields=["name"]&limit_page_length=0`);Y.urgent_work_orders=((H=Q==null?void 0:Q.data)==null?void 0:H.length)||0;const[ie,me,he,de,xe]=yield Promise.all([At.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:te.name,repair_status:"Open"}))}&fields=["name"]&limit_page_length=0`),At.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:te.name,repair_status:"Work In Progress"}))}&fields=["name"]&limit_page_length=0`),At.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:te.name,repair_status:"Pending Review"}))}&fields=["name"]&limit_page_length=0`),At.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:te.name,repair_status:"Completed"}))}&fields=["name"]&limit_page_length=0`),At.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:te.name,repair_status:"Closed"}))}&fields=["name"]&limit_page_length=0`)]);Y.wo_open=((U=ie==null?void 0:ie.data)==null?void 0:U.length)||0,Y.wo_progress=((re=me==null?void 0:me.data)==null?void 0:re.length)||0,Y.wo_review=((X=he==null?void 0:he.data)==null?void 0:X.length)||0,Y.wo_completed=((V=de==null?void 0:de.data)==null?void 0:V.length)||0,Y.wo_closed=((I=xe==null?void 0:xe.data)==null?void 0:I.length)||0}catch(B){console.error(`Error fetching counts for department ${te.name}:`,B)}return se({name:te.name,latitude:parseFloat(te.latitude),longitude:parseFloat(te.longitude)},Y)})),ne=yield Promise.all(ee);R.push(...ne.filter(te=>!isNaN(te.latitude)&&!isNaN(te.longitude)))}l(R)}catch(R){console.error("Error fetching map data:",R)}finally{u(!1)}}});p.useEffect(()=>{v()},[a,n,b]);const k=R=>{s(R),R&&i("")},S=R=>{i(R),R&&s("")},N=(R,z,G,ae)=>{const ee=new URLSearchParams;z==="hospital"?R&&ee.set("company",R):R&&ee.set("work_order_type",R),G&&ee.set("priority",G),ae&&ee.set("status",ae),r(`/work-orders?${ee.toString()}`)},C=R=>{const z=new URLSearchParams;R&&z.set("company",R),r(`/assets?${z.toString()}`)},O=(R,z)=>{const G=new URLSearchParams;R&&G.set("hospital",R),z&&G.set("status",z),r(`/maintenance-calendar?${G.toString()}`)},T=R=>t.jsxs("div",{className:"p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg min-w-[280px] max-w-[320px]",children:[t.jsxs("div",{className:"mb-4 pb-3 border-b border-gray-200 dark:border-gray-700",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:"px-2 py-0.5 bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 rounded text-xs font-medium",children:e("activeMap.hospital")})}),t.jsx("h3",{className:"text-lg font-bold text-gray-900 dark:text-white mt-1",children:R.name}),t.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:[e("activeMap.totalAssets"),": ",t.jsx("span",{className:"font-semibold text-gray-900 dark:text-white",children:R.assets})]})]}),t.jsxs("div",{className:"mb-4",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200 mb-2",children:e("activeMap.workOrderStatus")}),t.jsxs("div",{className:"flex gap-2 mb-3",children:[t.jsxs("button",{onClick:()=>N(R.name,"hospital","Normal"),className:"px-3 py-1.5 bg-blue-100 dark:bg-blue-900/30 hover:bg-blue-200 dark:hover:bg-blue-900/50 text-blue-700 dark:text-blue-300 rounded-lg text-xs font-semibold transition-colors cursor-pointer",children:[e("activeMap.normal"),": ",R.normal_work_orders]}),t.jsxs("button",{onClick:()=>N(R.name,"hospital","Urgent"),className:"px-3 py-1.5 bg-red-100 dark:bg-red-900/30 hover:bg-red-200 dark:hover:bg-red-900/50 text-red-700 dark:text-red-300 rounded-lg text-xs font-semibold transition-colors cursor-pointer",children:[e("activeMap.urgent"),": ",R.urgent_work_orders]})]}),t.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-200 dark:border-gray-700",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left font-semibold text-gray-700 dark:text-gray-300",children:e("activeMap.status")}),t.jsx("th",{className:"px-3 py-2 text-left font-semibold text-gray-700 dark:text-gray-300",children:e("activeMap.count")})]})}),t.jsxs("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:[t.jsxs("tr",{className:"bg-red-50 dark:bg-red-900/20 hover:bg-red-100 dark:hover:bg-red-900/30 transition-colors",children:[t.jsx("td",{className:"px-3 py-2 text-red-800 dark:text-red-300 font-medium",children:e("activeMap.open")}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("button",{onClick:()=>N(R.name,"hospital",void 0,"Open"),className:"text-red-700 dark:text-red-400 font-bold hover:underline cursor-pointer",children:R.wo_open})})]}),t.jsxs("tr",{className:"bg-yellow-50 dark:bg-yellow-900/20 hover:bg-yellow-100 dark:hover:bg-yellow-900/30 transition-colors",children:[t.jsx("td",{className:"px-3 py-2 text-yellow-800 dark:text-yellow-300 font-medium",children:e("activeMap.workInProgress")}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("button",{onClick:()=>N(R.name,"hospital",void 0,"Work In Progress"),className:"text-yellow-700 dark:text-yellow-400 font-bold hover:underline cursor-pointer",children:R.wo_progress})})]}),t.jsxs("tr",{className:"bg-blue-50 dark:bg-blue-900/20 hover:bg-blue-100 dark:hover:bg-blue-900/30 transition-colors",children:[t.jsx("td",{className:"px-3 py-2 text-blue-800 dark:text-blue-300 font-medium",children:e("activeMap.pendingReview")}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("button",{onClick:()=>N(R.name,"hospital",void 0,"Pending Review"),className:"text-blue-700 dark:text-blue-400 font-bold hover:underline cursor-pointer",children:R.wo_review})})]}),t.jsxs("tr",{className:"bg-green-50 dark:bg-green-900/20 hover:bg-green-100 dark:hover:bg-green-900/30 transition-colors",children:[t.jsx("td",{className:"px-3 py-2 text-green-800 dark:text-green-300 font-medium",children:e("activeMap.completed")}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("button",{onClick:()=>N(R.name,"hospital",void 0,"Completed"),className:"text-green-700 dark:text-green-400 font-bold hover:underline cursor-pointer",children:R.wo_completed})})]}),t.jsxs("tr",{className:"bg-gray-50 dark:bg-gray-900/20 hover:bg-gray-100 dark:hover:bg-gray-900/30 transition-colors",children:[t.jsx("td",{className:"px-3 py-2 text-gray-800 dark:text-gray-300 font-medium",children:e("activeMap.closed")}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("button",{onClick:()=>N(R.name,"hospital",void 0,"Closed"),className:"text-gray-700 dark:text-gray-400 font-bold hover:underline cursor-pointer",children:R.wo_closed})})]})]})]})})]}),t.jsxs("div",{className:"mb-4",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200 mb-2",children:e("activeMap.preventiveMaintenance")}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsxs("button",{onClick:()=>O(R.name,"Planned"),className:"px-3 py-1.5 bg-orange-100 dark:bg-orange-900/30 hover:bg-orange-200 dark:hover:bg-orange-900/50 text-orange-700 dark:text-orange-300 rounded-lg text-xs font-semibold transition-colors cursor-pointer",children:[e("activeMap.planned"),": ",R.planned_maintenance]}),t.jsxs("button",{onClick:()=>O(R.name,"Completed"),className:"px-3 py-1.5 bg-green-100 dark:bg-green-900/30 hover:bg-green-200 dark:hover:bg-green-900/50 text-green-700 dark:text-green-300 rounded-lg text-xs font-semibold transition-colors cursor-pointer",children:[e("activeMap.completed"),": ",R.completed_maintenance]}),t.jsxs("button",{onClick:()=>O(R.name,"Overdue"),className:"px-3 py-1.5 bg-red-100 dark:bg-red-900/30 hover:bg-red-200 dark:hover:bg-red-900/50 text-red-700 dark:text-red-300 rounded-lg text-xs font-semibold transition-colors cursor-pointer",children:[e("activeMap.overdue"),": ",R.overdue_maintenance]})]})]}),t.jsxs("div",{className:"flex gap-2 pt-3 border-t border-gray-200 dark:border-gray-700",children:[t.jsx("button",{onClick:()=>C(R.name),className:"flex-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 dark:bg-blue-700 dark:hover:bg-blue-600 text-white rounded-lg text-sm font-medium transition-colors cursor-pointer",children:e("activeMap.viewAssets")}),t.jsx("button",{onClick:()=>N(R.name,"hospital"),className:"flex-1 px-4 py-2 bg-purple-600 hover:bg-purple-700 dark:bg-purple-700 dark:hover:bg-purple-600 text-white rounded-lg text-sm font-medium transition-colors cursor-pointer",children:e("activeMap.viewWorkOrders")})]})]}),P=R=>t.jsxs("div",{className:"p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg min-w-[280px] max-w-[320px]",children:[t.jsxs("div",{className:"mb-4 pb-3 border-b border-gray-200 dark:border-gray-700",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:"px-2 py-0.5 bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 rounded text-xs font-medium",children:e("activeMap.deptWoType")})}),t.jsx("h3",{className:"text-lg font-bold text-gray-900 dark:text-white mt-1",children:R.name}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1 italic",children:e("activeMap.showingWorkOrdersByType")})]}),t.jsxs("div",{className:"mb-4",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200 mb-2",children:e("activeMap.workOrderStatus")}),t.jsxs("div",{className:"flex gap-2 mb-3",children:[t.jsxs("button",{onClick:()=>N(R.name,"department","Normal"),className:"px-3 py-1.5 bg-blue-100 dark:bg-blue-900/30 hover:bg-blue-200 dark:hover:bg-blue-900/50 text-blue-700 dark:text-blue-300 rounded-lg text-xs font-semibold transition-colors cursor-pointer",children:[e("activeMap.normal"),": ",R.normal_work_orders]}),t.jsxs("button",{onClick:()=>N(R.name,"department","Urgent"),className:"px-3 py-1.5 bg-red-100 dark:bg-red-900/30 hover:bg-red-200 dark:hover:bg-red-900/50 text-red-700 dark:text-red-300 rounded-lg text-xs font-semibold transition-colors cursor-pointer",children:[e("activeMap.urgent"),": ",R.urgent_work_orders]})]}),t.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-200 dark:border-gray-700",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left font-semibold text-gray-700 dark:text-gray-300",children:e("activeMap.status")}),t.jsx("th",{className:"px-3 py-2 text-left font-semibold text-gray-700 dark:text-gray-300",children:e("activeMap.count")})]})}),t.jsxs("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:[t.jsxs("tr",{className:"bg-red-50 dark:bg-red-900/20 hover:bg-red-100 dark:hover:bg-red-900/30 transition-colors",children:[t.jsx("td",{className:"px-3 py-2 text-red-800 dark:text-red-300 font-medium",children:e("activeMap.open")}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("button",{onClick:()=>N(R.name,"department",void 0,"Open"),className:"text-red-700 dark:text-red-400 font-bold hover:underline cursor-pointer",children:R.wo_open})})]}),t.jsxs("tr",{className:"bg-yellow-50 dark:bg-yellow-900/20 hover:bg-yellow-100 dark:hover:bg-yellow-900/30 transition-colors",children:[t.jsx("td",{className:"px-3 py-2 text-yellow-800 dark:text-yellow-300 font-medium",children:e("activeMap.workInProgress")}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("button",{onClick:()=>N(R.name,"department",void 0,"Work In Progress"),className:"text-yellow-700 dark:text-yellow-400 font-bold hover:underline cursor-pointer",children:R.wo_progress})})]}),t.jsxs("tr",{className:"bg-blue-50 dark:bg-blue-900/20 hover:bg-blue-100 dark:hover:bg-blue-900/30 transition-colors",children:[t.jsx("td",{className:"px-3 py-2 text-blue-800 dark:text-blue-300 font-medium",children:e("activeMap.pendingReview")}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("button",{onClick:()=>N(R.name,"department",void 0,"Pending Review"),className:"text-blue-700 dark:text-blue-400 font-bold hover:underline cursor-pointer",children:R.wo_review})})]}),t.jsxs("tr",{className:"bg-green-50 dark:bg-green-900/20 hover:bg-green-100 dark:hover:bg-green-900/30 transition-colors",children:[t.jsx("td",{className:"px-3 py-2 text-green-800 dark:text-green-300 font-medium",children:e("activeMap.completed")}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("button",{onClick:()=>N(R.name,"department",void 0,"Completed"),className:"text-green-700 dark:text-green-400 font-bold hover:underline cursor-pointer",children:R.wo_completed})})]}),t.jsxs("tr",{className:"bg-gray-50 dark:bg-gray-900/20 hover:bg-gray-100 dark:hover:bg-gray-900/30 transition-colors",children:[t.jsx("td",{className:"px-3 py-2 text-gray-800 dark:text-gray-300 font-medium",children:e("activeMap.closed")}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("button",{onClick:()=>N(R.name,"department",void 0,"Closed"),className:"text-gray-700 dark:text-gray-400 font-bold hover:underline cursor-pointer",children:R.wo_closed})})]})]})]})})]}),t.jsx("div",{className:"pt-3 border-t border-gray-200 dark:border-gray-700",children:t.jsx("button",{onClick:()=>N(R.name,"department"),className:"w-full px-4 py-2 bg-purple-600 hover:bg-purple-700 dark:bg-purple-700 dark:hover:bg-purple-600 text-white rounded-lg text-sm font-medium transition-colors cursor-pointer",children:e("activeMap.viewAllWorkOrders")})})]}),E=R=>{const z=R.urgent_work_orders>0?`🚨 ${e("activeMap.tooltipUrgent")}`:"",G=R.locationType==="department"?`📋 ${e("activeMap.tooltipDept")}`:`🏥 ${e("activeMap.tooltipHospital")}`;return t.jsxs("div",{className:"p-2 bg-white dark:bg-gray-800 rounded-lg shadow-lg min-w-[200px]",children:[t.jsxs("div",{className:"mb-2 pb-2 border-b border-gray-200 dark:border-gray-700",children:[t.jsx("div",{className:"flex items-center gap-1 mb-1",children:t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${R.locationType==="department"?"bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300":"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300"}`,children:G})}),t.jsxs("h4",{className:"text-sm font-bold text-gray-900 dark:text-white",children:[z,R.name]}),R.locationType==="hospital"&&t.jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-0.5",children:[e("activeMap.assets"),": ",t.jsx("span",{className:"font-semibold text-gray-900 dark:text-white",children:R.assets})]})]}),t.jsxs("div",{className:"space-y-1 text-xs",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:e("activeMap.normalWos")}),t.jsx("span",{className:"font-semibold text-blue-700 dark:text-blue-300",children:R.normal_work_orders})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:e("activeMap.urgentWos")}),t.jsx("span",{className:"font-semibold text-red-700 dark:text-red-300",children:R.urgent_work_orders})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:e("activeMap.closedWos")}),t.jsx("span",{className:"font-semibold text-gray-700 dark:text-gray-300",children:R.wo_closed})]}),R.locationType==="hospital"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:e("activeMap.plannedPms")}),t.jsx("span",{className:"font-semibold text-orange-700 dark:text-orange-300",children:R.planned_maintenance})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:e("activeMap.completedPms")}),t.jsx("span",{className:"font-semibold text-green-700 dark:text-green-300",children:R.completed_maintenance})]})]})]})]})};return t.jsxs("div",{className:"h-screen flex flex-col bg-gray-50 dark:bg-gray-900",children:[t.jsx("div",{className:"flex-shrink-0 bg-white dark:bg-gray-800 shadow-sm border-b border-gray-200 dark:border-gray-700 px-4 py-3",children:t.jsx("h1",{className:"text-xl font-semibold text-gray-800 dark:text-white",children:e("activeMap.title")})}),t.jsxs("div",{className:"flex-shrink-0 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 px-4 py-3 relative z-[1000]",children:[t.jsxs("div",{className:"flex flex-wrap gap-4",children:[t.jsxs("div",{className:"w-64 relative z-[1000]",children:[t.jsx(Je,{label:e("activeMap.hospital"),doctype:"Location",value:a,onChange:k,filters:{custom_is_hospital:1},placeholder:e("activeMap.selectHospital"),disabled:!!n}),n&&t.jsx("p",{className:"text-xs text-gray-500 mt-1",children:e("activeMap.clearDepartmentHint")})]}),t.jsxs("div",{className:"w-64 relative z-[1000]",children:[t.jsx(Je,{label:e("activeMap.departmentWoType"),doctype:"Location",value:n,onChange:S,filters:f!==null&&f.length>0?{custom_is_wo_type:1,name:["in",f]}:{custom_is_wo_type:1},placeholder:e("activeMap.selectDepartment"),disabled:!!a}),a&&t.jsx("p",{className:"text-xs text-gray-500 mt-1",children:e("activeMap.clearHospitalHint")})]}),(a||n)&&t.jsx("div",{className:"flex items-end",children:t.jsx("button",{onClick:()=>{s(""),i("")},className:"px-4 py-2 bg-gray-200 hover:bg-gray-300 dark:bg-gray-700 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-lg text-sm font-medium transition-colors",children:e("activeMap.clearFilters")})})]}),t.jsxs("div",{className:"flex gap-4 mt-3 text-xs",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"w-3 h-3 bg-blue-500 rounded-full"}),t.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:e("activeMap.legendHospital")})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"w-3 h-3 bg-green-500 rounded-full"}),t.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:e("activeMap.legendDepartment")})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"w-3 h-3 bg-red-500 rounded-full animate-pulse"}),t.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:e("activeMap.legendHasUrgent")})]})]})]}),t.jsxs("div",{className:"flex-1 relative",style:{zIndex:1},children:[c&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-white bg-opacity-75 z-[1000]",children:t.jsx("div",{className:"text-gray-600 dark:text-gray-300",children:e("activeMap.loading")})}),t.jsxs(lie,{center:[24.8,45.5],zoom:6,style:{height:"100%",width:"100%"},zoomControl:!0,children:[t.jsx(uie,{attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}),t.jsx(pie,{locations:o}),o.map(R=>{const z=`${R.locationType}-${R.latitude}-${R.longitude}`,G=R.locationType==="department";return t.jsxs(cie,{position:[R.latitude,R.longitude],icon:G?hie:RL,ref:ae=>{ae&&(h.current[z]=ae,setTimeout(()=>{const ee=ae.getElement();ee&&(R.urgent_work_orders>0&&ee.classList.add("urgent-marker"),G&&ee.classList.add("department-marker"))},100))},children:[t.jsx(mie,{permanent:!1,direction:"right",className:"hospital-tooltip-modern",children:E(R)}),t.jsx(die,{className:"hospital-popup-container",maxWidth:300,maxHeight:450,autoPan:!0,keepInView:!0,closeButton:!0,autoClose:!1,children:G?P(R):T(R)})]},z)})]})]}),t.jsx("style",{children:`
|
||
/* Ensure filter container and dropdowns stay above map */
|
||
.leaflet-container {
|
||
z-index: 1 !important;
|
||
}
|
||
|
||
/* LinkField dropdown z-index - ensure it's above everything */
|
||
[data-linkfield-dropdown],
|
||
.linkfield-dropdown,
|
||
.react-select__menu,
|
||
.react-select__menu-portal,
|
||
.select2-container,
|
||
.select2-dropdown {
|
||
z-index: 1050 !important;
|
||
}
|
||
|
||
/* Any dropdown menu from LinkField */
|
||
div[role="listbox"],
|
||
ul[role="listbox"],
|
||
.dropdown-menu,
|
||
.autocomplete-dropdown {
|
||
z-index: 1050 !important;
|
||
}
|
||
|
||
.hospital-tooltip-modern {
|
||
background: transparent !important;
|
||
border: none !important;
|
||
box-shadow: none !important;
|
||
}
|
||
|
||
.hospital-tooltip-modern .leaflet-tooltip-content-wrapper {
|
||
background: transparent !important;
|
||
border: none !important;
|
||
box-shadow: none !important;
|
||
padding: 0 !important;
|
||
}
|
||
|
||
.hospital-tooltip-modern .leaflet-tooltip-content {
|
||
margin: 0 !important;
|
||
}
|
||
|
||
.hospital-popup-container .leaflet-popup-content-wrapper {
|
||
padding: 0;
|
||
border-radius: 8px;
|
||
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
||
}
|
||
|
||
.hospital-popup-container .leaflet-popup-content {
|
||
margin: 0;
|
||
width: auto !important;
|
||
}
|
||
|
||
.urgent-marker {
|
||
animation: urgent-flash 2s infinite;
|
||
}
|
||
|
||
@keyframes urgent-flash {
|
||
0%, 50% {
|
||
filter: hue-rotate(0deg) brightness(1) saturate(1);
|
||
}
|
||
25%, 75% {
|
||
filter: hue-rotate(0deg) brightness(1.5) saturate(2) drop-shadow(0 0 10px red);
|
||
}
|
||
}
|
||
|
||
/* Department marker - purple tint */
|
||
.department-marker {
|
||
filter: hue-rotate(270deg) saturate(1.5) brightness(1);
|
||
}
|
||
|
||
/* When department marker has urgent */
|
||
.department-marker.urgent-marker {
|
||
animation: department-urgent-flash 2s infinite;
|
||
}
|
||
|
||
@keyframes department-urgent-flash {
|
||
0%, 50% {
|
||
filter: hue-rotate(270deg) saturate(1.5) brightness(1);
|
||
}
|
||
25%, 75% {
|
||
filter: hue-rotate(270deg) brightness(1.5) saturate(2) drop-shadow(0 0 10px red);
|
||
}
|
||
}
|
||
|
||
.leaflet-popup {
|
||
z-index: 2000 !important;
|
||
}
|
||
|
||
.leaflet-tooltip {
|
||
z-index: 2000 !important;
|
||
}
|
||
`})]})};class fie{getItems(r,a,s=20,n=0,i){return J(this,null,function*(){try{const{toFrappeFilterArray:o}=yield Wu(()=>J(null,null,function*(){const{toFrappeFilterArray:u}=yield Promise.resolve().then(()=>CS);return{toFrappeFilterArray:u}}),void 0);let l=[];r&&Object.keys(r).length>0&&(l=o(r));const c=yield At.apiCall("/api/method/asset_lite.api.item_api.get_items",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filters:l.length>0?l:[],fields:a||[],limit:s,offset:n,order_by:i||"creation desc"})});return{data:c.data||[],total:c.total||0}}catch(o){throw console.error("Error fetching items:",o),o}})}getItem(r){return J(this,null,function*(){try{return(yield At.apiCall(`/api/resource/Item/${encodeURIComponent(r)}`)).data}catch(a){throw console.error("Error fetching item:",a),a}})}createItem(r){return J(this,null,function*(){try{return(yield At.apiCall("/api/resource/Item",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).data}catch(a){throw console.error("Error creating item:",a),a}})}updateItem(r,a){return J(this,null,function*(){try{return(yield At.apiCall(`/api/resource/Item/${encodeURIComponent(r)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).data}catch(s){throw console.error("Error updating item:",s),s}})}deleteItem(r){return J(this,null,function*(){try{yield At.apiCall(`/api/resource/Item/${encodeURIComponent(r)}`,{method:"DELETE"})}catch(a){throw console.error("Error deleting item:",a),a}})}submitItem(r){return J(this,null,function*(){try{return(yield At.apiCall(`/api/resource/Item/${encodeURIComponent(r)}/submit`,{method:"POST"})).data}catch(a){throw console.error("Error submitting item:",a),a}})}cancelItem(r){return J(this,null,function*(){try{return(yield At.apiCall(`/api/resource/Item/${r}/cancel`,{method:"POST"})).data}catch(a){throw console.error("Error cancelling item:",a),a}})}}const up=new fie;function xie(e,r=20,a=0,s){const[n,i]=p.useState([]),[o,l]=p.useState(0),[c,u]=p.useState(!1),[h,f]=p.useState(!0),[y,b]=p.useState(null),[w,v]=p.useState(0);p.useRef(!1);const k=JSON.stringify(e);p.useEffect(()=>{let N=!1;return J(null,null,function*(){try{f(!0);const O=["name","item_code","item_name","item_group","stock_uom","disabled","is_stock_item","is_fixed_asset","custom_hospital_name","opening_stock","valuation_rate","standard_rate","creation","modified","owner","docstatus","custom_serial_no","custom_date_in","custom_code","custom_type","custom_volts","custom_w","custom_delete_status"],T=yield up.getItems(e,O,r,a,s);N||(i(T.data),l(T.total),u(T.data.length===r),b(null))}catch(O){if(!N){const T=O instanceof Error?O.message:"Failed to fetch items";b(T),i([]),l(0),u(!1)}}finally{N||f(!1)}}),()=>{N=!0}},[k,r,a,s,w]);const S=p.useCallback(()=>{v(N=>N+1)},[]);return{items:n,totalCount:o,hasMore:c,loading:h,error:y,refetch:S}}function yie(e){const[r,a]=p.useState(null),[s,n]=p.useState(!0),[i,o]=p.useState(null),l=p.useCallback(()=>J(null,null,function*(){if(!e){a(null),n(!1);return}try{n(!0),o(null);const u=yield up.getItem(e);a(u)}catch(u){o(u instanceof Error?u.message:"Failed to fetch item details")}finally{n(!1)}}),[e]);p.useEffect(()=>{l()},[l]);const c=p.useCallback(()=>{l()},[l]);return{item:r,loading:s,error:i,refetch:c}}function ML(){const[e,r]=p.useState(!1),[a,s]=p.useState(null),n=p.useCallback(c=>J(null,null,function*(){try{return r(!0),s(null),yield up.createItem(c)}catch(u){const h=u instanceof Error?u.message:"Failed to create item";throw s(h),u}finally{r(!1)}}),[]),i=p.useCallback((c,u)=>J(null,null,function*(){try{return r(!0),s(null),yield up.updateItem(c,u)}catch(h){const f=h instanceof Error?h.message:"Failed to update item";throw s(f),h}finally{r(!1)}}),[]),o=p.useCallback(c=>J(null,null,function*(){try{r(!0),s(null),yield up.deleteItem(c)}catch(u){const h=u instanceof Error?u.message:"Failed to delete item";throw s(h),u}finally{r(!1)}}),[]),l=p.useCallback(c=>J(null,null,function*(){try{return r(!0),s(null),yield up.submitItem(c)}catch(u){const h=u instanceof Error?u.message:"Failed to submit item";throw s(h),u}finally{r(!1)}}),[]);return{createItem:n,updateItem:i,deleteItem:o,submitItem:l,loading:e,error:a}}const bie=({isOpen:e,onClose:r,selectedCount:a,totalCount:s,pageCount:n,onExport:i,isExporting:o,exportColumns:l})=>{const{t:c}=sr(),[u,h]=p.useState(a>0?"selected":"all_with_filters"),[f,y]=p.useState("csv"),[b,w]=p.useState(l.filter(N=>N.default).map(N=>N.key));p.useEffect(()=>{a>0?h("selected"):h("all_with_filters")},[a]);const v=N=>{w(C=>C.includes(N)?C.filter(O=>O!==N):[...C,N])},k=()=>{w(l.map(N=>N.key))},S=()=>{w(l.filter(N=>N.default).map(N=>N.key))};return e?t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] overflow-hidden animate-scale-in",children:[t.jsx("div",{className:"bg-gradient-to-r from-green-500 to-green-600 px-6 py-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Sa,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:c("items.export.title")})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:o,children:t.jsx(ht,{size:20})})]})}),t.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-180px)]",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:c("items.export.selectData")}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${u==="selected"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"} ${a===0?"opacity-50 cursor-not-allowed":""}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"selected",checked:u==="selected",onChange:()=>h("selected"),disabled:a===0,className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("items.export.selectedRows")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("items.export.selectedCount",{count:a})})]}),a>0&&t.jsxs("span",{className:"bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300 px-2 py-1 rounded text-xs font-medium",children:[a," ",c("common.selected")]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${u==="all_on_page"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"all_on_page",checked:u==="all_on_page",onChange:()=>h("all_on_page"),className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("items.export.currentPage")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("items.export.currentPageCount",{count:n})})]}),t.jsxs("span",{className:"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300 px-2 py-1 rounded text-xs font-medium",children:[n," ",c("common.rows")]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${u==="all_with_filters"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"all_with_filters",checked:u==="all_with_filters",onChange:()=>h("all_with_filters"),className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("items.export.allWithFilters")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("items.export.allWithFiltersCount",{count:s})})]}),t.jsxs("span",{className:"bg-purple-100 dark:bg-purple-900/40 text-purple-700 dark:text-purple-300 px-2 py-1 rounded text-xs font-medium",children:[s," ",c("common.total")]})]})]})]}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:c("listPages.exportFormat")}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${f==="csv"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"format",value:"csv",checked:f==="csv",onChange:()=>y("csv"),className:"text-green-600 focus:ring-green-500"}),t.jsx(ic,{className:"text-green-600 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("listPages.csv")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:c("items.export.csvDesc")})]})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${f==="excel"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"format",value:"excel",checked:f==="excel",onChange:()=>y("excel"),className:"text-green-600 focus:ring-green-500"}),t.jsx(oc,{className:"text-green-700 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("listPages.excel")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:c("items.export.excelDesc")})]})]})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:c("items.export.columnsToExport")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:k,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:c("items.export.selectAll")}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{onClick:S,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:c("items.export.resetToDefault")})]})]}),t.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2 max-h-48 overflow-y-auto p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg",children:l.map(N=>t.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${b.includes(N.key)?"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300":"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-400"}`,children:[t.jsx("input",{type:"checkbox",checked:b.includes(N.key),onChange:()=>v(N.key),className:"rounded text-green-600 focus:ring-green-500"}),t.jsx("span",{className:"text-sm truncate",children:N.label})]},N.key))}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:c("items.export.columnsSelected",{count:b.length})})]})]}),t.jsxs("div",{className:"px-6 py-4 bg-gray-50 dark:bg-gray-900/50 border-t border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[u==="selected"&&c("items.export.exportingSelected",{count:a}),u==="all_on_page"&&c("items.export.exportingPage",{count:n}),u==="all_with_filters"&&c("items.export.exportingAll",{count:s})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{onClick:r,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",disabled:o,children:c("common.cancel")}),t.jsx("button",{onClick:()=>i(u,f,b),disabled:b.length===0||o,className:"px-4 py-2 text-sm font-medium text-white bg-green-600 hover:bg-green-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:o?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),c("items.export.exporting")]}):t.jsxs(t.Fragment,{children:[t.jsx(qc,{}),c("items.export.exportButton")]})})]})]})]})}):null},vie=()=>{const{t:e}=sr(),r=hr(),[a,s]=_a(),n=p.useRef(s);p.useEffect(()=>{n.current=s},[s]);const o=p.useMemo(()=>{const ke=parseInt(a.get("page")||"1",10);return Math.max(0,Number.isNaN(ke)?0:ke-1)},[a]),l=p.useCallback(ke=>{s(Be=>{const yt=new URLSearchParams(Be);return yt.set("page",String(ke+1)),yt})},[s]),[c,u]=p.useState(null),h=20,f=[{key:"name",label:"Item ID",default:!0},{key:"item_code",label:"Item Code",default:!0},{key:"item_name",label:"Item Name",default:!0},{key:"item_group",label:"Item Group",default:!0},{key:"custom_hospital_name",label:"Hospital",default:!0},{key:"custom_serial_no",label:"Serial No",default:!0},{key:"custom_technical_department",label:"Technical Department",default:!0},{key:"custom_date_in",label:"Date In",default:!0},{key:"custom_w",label:"Watts",default:!0},{key:"custom_volts",label:"Volts",default:!0},{key:"custom_type",label:"Type",default:!0},{key:"custom_code",label:"Code",default:!0},{key:"stock_uom",label:"Stock UOM",default:!1},{key:"custom_part_description",label:"Part Description",default:!1},{key:"brand",label:"Brand",default:!1},{key:"valuation_rate",label:"Valuation Rate",default:!1},{key:"opening_stock",label:"Opening Stock",default:!1},{key:"custom_last_calibration_date",label:"Last Calibration Date",default:!1},{key:"custom_next_due_calibration_date",label:"Next Calibration Date",default:!1},{key:"description",label:"Description",default:!1},{key:"creation",label:"Created On",default:!1},{key:"modified",label:"Modified On",default:!0},{key:"owner",label:"Created By",default:!1},{key:"modified_by",label:"Modified By",default:!1}],[y,b]=p.useState(!1),[w,v]=p.useState(new Set),[k,S]=p.useState(!1),[N,C]=p.useState(!1),[O,T]=p.useState([]),[P,E]=p.useState(!1);p.useEffect(()=>{J(null,null,function*(){try{const yt=yield(yield fetch("/api/method/asset_lite.api.user_roles.get_user_roles",{credentials:"include"})).json(),Me=Array.isArray(yt.message)?yt.message:[];T(Me),E(Me.includes("System Manager"))}catch(Be){console.error("Failed to fetch user roles:",Be)}})},[]);const[R,z]=p.useState(()=>a.get("date_filter_by")||""),[G,ae]=p.useState(()=>a.get("date_start")||""),[ee,ne]=p.useState(()=>a.get("date_end")||""),[te,Y]=p.useState(()=>a.get("item_id")||""),[q,H]=p.useState(()=>a.get("item_group")||""),[U,re]=p.useState(()=>a.get("company")||""),[X,V]=p.useState(()=>a.get("item_name")||""),I=["creation desc","creation asc","modified desc","modified asc","item_name asc","item_name desc","name asc","name desc"],[B,Q]=p.useState(()=>a.get("sort_by")||"creation desc"),[ie,me]=p.useState(!0),[he,de]=p.useState(0),[xe,ge]=p.useState([]),[be,K]=p.useState(!1),[ye,Z]=p.useState(""),[M,we]=p.useState(()=>a.get("item_name")||""),pe=p.useRef(null);p.useEffect(()=>{const ke=localStorage.getItem("itemFilterPresets");ke&&ge(JSON.parse(ke))},[]);const le=R&&(G||ee);p.useEffect(()=>{const ke=[te,q,U,X].filter(Boolean).length+(le?1:0);de(ke)},[te,q,U,X,le]);const Fe={};te&&(Fe.name=te),q&&(Fe.item_group=q),U&&(Fe.custom_hospital_name=U),X&&(Fe.item_name=["like",`%${X}%`]),Object.assign(Fe,kl(R,G,ee)),Fe.custom_delete_status=["!=","Deleted"];const ze=I.includes(B)?B:"creation desc",{items:Re,totalCount:De,hasMore:Et,loading:jt,error:Ie,refetch:$e}=xie(Object.keys(Fe).length>0?Fe:void 0,h,o*h,ze),{deleteItem:Qe,loading:at}=ML();p.useEffect(()=>{!jt&&!y&&b(!0)},[jt,y]);const Ct=p.useRef(!1);p.useEffect(()=>{if(!Ct.current){Ct.current=!0;return}n.current(ke=>{const Be=new URLSearchParams(ke);return R?Be.set("date_filter_by",R):Be.delete("date_filter_by"),G?Be.set("date_start",G):Be.delete("date_start"),ee?Be.set("date_end",ee):Be.delete("date_end"),te?Be.set("item_id",te):Be.delete("item_id"),q?Be.set("item_group",q):Be.delete("item_group"),U?Be.set("company",U):Be.delete("company"),X?Be.set("item_name",X):Be.delete("item_name"),B&&B!=="creation desc"?Be.set("sort_by",B):Be.delete("sort_by"),Be.set("page","1"),Be})},[R,G,ee,te,q,U,X,B]),p.useEffect(()=>{v(new Set)},[R,G,ee,te,q,U,X,o]);const vt=ke=>{we(ke),pe.current&&clearTimeout(pe.current),pe.current=window.setTimeout(()=>{V(ke)},800)},er=ke=>{ke.key==="Enter"&&(ke.preventDefault(),pe.current&&clearTimeout(pe.current),V(M))},nr=()=>{if(!ye.trim()){alert("Please enter a filter name");return}const ke={id:Date.now(),name:ye,filters:{dateFilterBy:R,dateStart:G,dateEnd:ee,sortBy:B,filterItemId:te,filterItemGroup:q,filterCompany:U,filterItemName:X}},Be=[...xe,ke];ge(Be),Z(""),K(!1),localStorage.setItem("itemFilterPresets",JSON.stringify(Be))},dt=ke=>{const Be=ke.filters;z(Be.dateFilterBy||""),ae(Be.dateStart||""),ne(Be.dateEnd||""),Q(Be.sortBy||"creation desc"),Y(Be.filterItemId||""),H(Be.filterItemGroup||""),re(Be.filterCompany||""),V(Be.filterItemName||""),we(Be.filterItemName||"")},He=ke=>{const Be=xe.filter(yt=>yt.id!==ke);ge(Be),localStorage.setItem("itemFilterPresets",JSON.stringify(Be))};p.useEffect(()=>()=>{pe.current&&clearTimeout(pe.current)},[]);const it=()=>{z(""),ae(""),ne(""),Q("creation desc"),Y(""),H(""),re(""),V(""),we(""),pe.current&&clearTimeout(pe.current),s(ke=>{const Be=new URLSearchParams(ke);return Be.delete("date_filter_by"),Be.delete("date_start"),Be.delete("date_end"),Be.delete("sort_by"),Be.delete("item_id"),Be.delete("item_group"),Be.delete("company"),Be.delete("item_name"),Be.set("page","1"),Be})},Ue=le||te||q||U||X,Ve=ke=>{switch(ke){case"Delete Request With Supervisor":return"bg-orange-50 dark:bg-orange-900/10";case"Delete Request With CM":return"bg-yellow-50 dark:bg-yellow-900/10";case"Deleted":return"bg-red-50 dark:bg-red-900/10";default:return""}},lt=ke=>ke?new Date(ke).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"-",st=ke=>{v(Be=>{const yt=new Set(Be);return yt.has(ke)?yt.delete(ke):yt.add(ke),yt})},Mt=()=>{w.size===Re.length?v(new Set):v(new Set(Re.map(ke=>ke.name)))},Ot=Re.length>0&&w.size===Re.length,Pt=w.size>0&&w.size<Re.length,zt=p.useCallback(()=>J(null,null,function*(){const ke=[];let Be=0;const yt=100;let Me=!0;const Ke=xa(Fe);for(;Me;)try{const _e=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Item",filters:Ke.length>0?Ke:{},fields:["*"],limit_start:Be*yt,limit_page_length:yt,order_by:"creation desc"})})).json()).message||[];ke.push(..._e),_e.length<yt?Me=!1:Be++,Be>100&&(console.warn("Export safety limit reached"),Me=!1)}catch(Xe){throw console.error("Error fetching items for export:",Xe),Xe}return ke}),[Fe]),Tt=(ke,Be,yt)=>J(null,null,function*(){C(!0);try{let Me=[];switch(ke){case"selected":Me=Re.filter(Xe=>w.has(Xe.name));break;case"all_on_page":Me=Re;break;case"all_with_filters":Me=yield zt();break}if(Me.length===0){alert(e("assets.noDataToExport"));return}const Ke=yt.map(Xe=>{const oe=f.find(_e=>_e.key===Xe);return(oe==null?void 0:oe.label)||Xe});if(Be==="csv"){const Xe=[Ke.join(","),...Me.map(Se=>yt.map(Ce=>{let Pe=Se[Ce]||"";return typeof Pe=="string"&&(Pe.includes(",")||Pe.includes('"')||Pe.includes(`
|
||
`))&&(Pe=`"${Pe.replace(/"/g,'""')}"`),Pe}).join(","))].join(`
|
||
`),oe=new Blob(["\uFEFF"+Xe],{type:"text/csv;charset=utf-8;"}),_e=URL.createObjectURL(oe),ve=document.createElement("a");ve.href=_e,ve.download=`items_export_${new Date().toISOString().split("T")[0]}.csv`,ve.click(),URL.revokeObjectURL(_e)}else if(Be==="excel"){const Xe=[Ke,...Me.map(ve=>yt.map(Se=>ve[Se]||""))],oe=Na.aoa_to_sheet(Xe),_e=Na.book_new();Na.book_append_sheet(_e,oe,"Items"),lc(_e,`items_export_${new Date().toISOString().split("T")[0]}.xlsx`)}S(!1),v(new Set)}catch(Me){console.error("Export failed:",Me),alert(`Export failed: ${Me instanceof Error?Me.message:"Unknown error"}`)}finally{C(!1)}}),Gt=()=>{r("/inventory/new")},Ye=ke=>{r(`/inventory/${encodeURIComponent(ke)}`)},kt=ke=>{r(`/inventory/${encodeURIComponent(ke)}`)},Yt=ke=>J(null,null,function*(){try{yield Qe(ke),u(null),$e(),alert("Item deleted successfully!")}catch(Be){alert(`Failed to delete: ${Be instanceof Error?Be.message:"Unknown error"}`)}}),Ae=ke=>{r(`/inventory/new?duplicate=${encodeURIComponent(ke)}`)};return jt&&!y?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("items.loadingItems")})]})}):Ie?t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:e("items.errorLoadingItems")}),t.jsxs("div",{className:"text-red-700 dark:text-red-400 space-y-3",children:[t.jsx("p",{children:t.jsx("strong",{children:e("items.failedToLoadItems")})}),t.jsxs("div",{className:"mt-4 flex gap-3",children:[t.jsx("button",{onClick:()=>r("/inventory/new"),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:e("items.addItem")}),t.jsx("button",{onClick:$e,className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded",children:e("common.tryAgain")})]})]}),t.jsx("div",{className:"mt-4 p-4 bg-white dark:bg-gray-800 rounded border border-red-300 dark:border-red-700",children:t.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:[t.jsx("strong",{children:"Technical Error:"})," ",Ie]})})]})}):t.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-3xl font-bold text-gray-800 dark:text-white",children:e("items.listTitle")}),t.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:[e("items.listTotal",{count:De}),w.size>0&&t.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",w.size," ",e("common.selected")]}),jt&&y&&t.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400",children:[t.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-blue-500"}),e("common.updating")]})]})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("button",{onClick:()=>S(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",disabled:De===0,children:[t.jsx(Sa,{}),t.jsx("span",{className:"font-medium",children:e("listPages.export")}),w.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:w.size})]}),t.jsxs("button",{onClick:Gt,className:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg flex items-center gap-2 shadow-lg transition-all hover:shadow-xl",children:[t.jsx(Rr,{}),t.jsx("span",{className:"font-medium",children:e("items.listAddItem")})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-4",children:[t.jsx("div",{className:"bg-gradient-to-r from-blue-500 to-blue-600 dark:from-blue-600 dark:to-blue-700 px-4 py-3 rounded-t-lg",children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx("button",{onClick:()=>me(!ie),className:"text-white hover:bg-white/20 p-2 rounded-lg transition-all",children:ie?t.jsx(Ja,{size:14}):t.jsx(Fr,{size:14})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ds,{className:"text-white",size:16}),t.jsx("h3",{className:"text-white font-semibold text-sm",children:e("listPages.filters")})]}),he>0&&t.jsx("span",{className:"bg-white text-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:he})]}),Ue&&t.jsx("div",{className:"flex-1 overflow-x-auto scrollbar-hide mx-2",children:t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[le&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("filters.filterBy"),":"]})," ",e(R==="creation"?"filters.createdDate":"filters.latestModifiedDate")," ",G&&` ${G}`," ",ee&&` - ${ee}`,t.jsx("button",{onClick:ke=>{ke.stopPropagation(),z(""),ae(""),ne("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),te&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-blue-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsx("span",{className:"font-semibold",children:"Item ID:"})," ",te,t.jsx("button",{onClick:ke=>{ke.stopPropagation(),Y("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),X&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-cyan-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsx("span",{className:"font-semibold",children:"Name:"})," ",X,t.jsx("button",{onClick:ke=>{ke.stopPropagation(),V(""),we("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),U&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-green-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsx("span",{className:"font-semibold",children:"Hospital:"})," ",U,t.jsx("button",{onClick:ke=>{ke.stopPropagation(),re("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]}),q&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-purple-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsx("span",{className:"font-semibold",children:"Item Group:"})," ",q,t.jsx("button",{onClick:ke=>{ke.stopPropagation(),H("")},className:"hover:text-red-500 transition-colors",children:t.jsx(ht,{className:"text-[9px]"})})]})]})}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[he>0&&t.jsxs("button",{onClick:()=>K(!0),className:"px-3 py-1.5 bg-white text-blue-600 hover:bg-blue-50 rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[t.jsx(ta,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),Ue&&t.jsxs("button",{onClick:it,className:"px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[t.jsx(ht,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:e("listPages.clear")})]})]})]})}),ie&&t.jsxs("div",{className:"p-4",children:[xe.length>0&&t.jsxs("div",{className:"mb-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[t.jsx(a0,{className:"text-yellow-500",size:12}),e("listPages.savedFilters")]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:xe.map(ke=>t.jsxs("div",{className:"group relative inline-flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-purple-100 to-blue-100 dark:from-purple-900/30 dark:to-blue-900/30 border border-purple-200 dark:border-purple-700 rounded-lg hover:shadow-md transition-all",children:[t.jsx("button",{onClick:()=>dt(ke),className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:ke.name}),t.jsx("button",{onClick:()=>He(ke.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:t.jsx(wr,{size:10})})]},ke.id))})]}),t.jsx("div",{className:"space-y-5",children:t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 p-3 rounded-lg",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.sortBy")}),t.jsxs("select",{value:B,onChange:ke=>Q(ke.target.value),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"creation desc",children:e("filters.sortCreationNewest")}),t.jsx("option",{value:"creation asc",children:e("filters.sortCreationOldest")}),t.jsx("option",{value:"modified desc",children:e("filters.sortModifiedNewest")}),t.jsx("option",{value:"modified asc",children:e("filters.sortModifiedOldest")}),t.jsx("option",{value:"item_name asc",children:e("filters.sortItemNameAsc")}),t.jsx("option",{value:"item_name desc",children:e("filters.sortItemNameDesc")}),t.jsx("option",{value:"name asc",children:e("filters.sortNameAsc")}),t.jsx("option",{value:"name desc",children:e("filters.sortNameDesc")})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.filterBy")}),t.jsxs("select",{value:R,onChange:ke=>{const Be=ke.target.value;z(Be)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("filters.filterBy")}),t.jsx("option",{value:"creation",children:e("filters.createdDate")}),t.jsx("option",{value:"modified",children:e("filters.latestModifiedDate")})]})]}),R&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.startDate")}),t.jsx("input",{type:"date",value:G,onChange:ke=>{const Be=ke.target.value;ae(Be),ee&&Be>ee&&ne(Be)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.endDate")}),t.jsx("input",{type:"date",value:ee,onChange:ke=>ne(ke.target.value),min:G||void 0,className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]}),t.jsxs("div",{className:"relative z-[60]",children:[t.jsx(Je,{label:e("items.itemId"),doctype:"Item",value:te,onChange:ke=>Y(ke),placeholder:e("linkField.selectLabel",{label:e("items.itemId")}),disabled:!1,compact:!0,filters:{custom_delete_status:["!=","Deleted"]}}),te&&t.jsx("button",{onClick:()=>Y(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("items.itemName")}),t.jsx("input",{type:"text",value:M,onChange:ke=>vt(ke.target.value),onKeyDown:er,placeholder:e("common.typeToSearch"),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),M&&M!==X&&t.jsx("span",{className:"absolute right-2 top-6 text-[9px] text-blue-500 animate-pulse",children:e("common.typing")}),X&&t.jsx("button",{onClick:()=>{V(""),we("")},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[59]",children:[t.jsx(Je,{label:e("items.selectHospital"),doctype:"Company",value:U,onChange:ke=>re(ke),placeholder:e("linkField.selectLabel",{label:e("items.selectHospital")}),disabled:!1,compact:!0,filters:{domain:"Healthcare"}}),U&&t.jsx("button",{onClick:()=>re(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[58]",children:[t.jsx(Je,{label:e("items.itemGroup"),doctype:"Item Group",value:q,onChange:ke=>H(ke),placeholder:e("linkField.selectLabel",{label:e("items.itemGroup")}),disabled:!1,compact:!0}),q&&t.jsx("button",{onClick:()=>H(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]})]})})})]})]}),be&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 animate-scale-in",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:e("common.saveFilterPreset")}),t.jsx("input",{type:"text",value:ye,onChange:ke=>Z(ke.target.value),onKeyDown:ke=>{ke.key==="Enter"&&(ke.preventDefault(),nr())},placeholder:e("common.enterFilterNameExample"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white mb-4",autoFocus:!0}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:()=>{K(!1),Z("")},className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",children:e("common.cancel")}),t.jsxs("button",{onClick:nr,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors flex items-center gap-2",children:[t.jsx(ta,{size:12}),e("common.saveFilter")]})]})]})}),t.jsx(bie,{isOpen:k,onClose:()=>S(!1),selectedCount:w.size,totalCount:De,pageCount:Re.length,onExport:Tt,isExporting:N,exportColumns:f}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden relative",children:[jt&&y&&t.jsx("div",{className:"absolute inset-0 bg-white/60 dark:bg-gray-800/60 flex items-center justify-center z-10 backdrop-blur-[1px]",children:t.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-gray-700 px-4 py-2 rounded-lg shadow-lg",children:[t.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-blue-500"}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:e("common.filtering")})]})}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left",children:t.jsx("button",{onClick:Mt,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:Ot?"Deselect all":"Select all",children:Ot?t.jsx(Ra,{className:"text-blue-600 dark:text-blue-400",size:18}):Pt?t.jsxs("div",{className:"relative",children:[t.jsx(Ur,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Ur,{size:18})})}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("items.itemCode")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("items.itemName")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("items.itemGroup")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("items.selectHospital")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("items.serialNo")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("items.dateIn")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.modifiedOn")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("listPages.actions")})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:Re.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:13,className:"px-6 py-12 text-center text-gray-500 dark:text-gray-400",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx(LG,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("items.noItemsFound")}),Ue?t.jsx("button",{onClick:it,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:e("common.clearFilters")}):t.jsx("button",{onClick:Gt,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:e("items.createFirstItem")})]})})}):Re.map(ke=>{var Be;return t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors cursor-pointer ${w.has(ke.name)?"bg-blue-50 dark:bg-blue-900/20":Ve(ke.custom_delete_status)}`,title:ke.custom_delete_status?`Delete Status: ${ke.custom_delete_status}`:void 0,onClick:()=>Ye(ke.name),children:[t.jsx("td",{className:"px-4 py-4",onClick:yt=>yt.stopPropagation(),children:t.jsx("button",{onClick:()=>st(ke.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:w.has(ke.name)?t.jsx(Ra,{className:"text-blue-600 dark:text-blue-400",size:18}):t.jsx(Ur,{size:18})})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:ke.item_code||ke.name})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:ke.item_name||"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:ke.item_group||"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:ke.custom_hospital_name||"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:ke.custom_serial_no||"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:ke.custom_date_in?lt(ke.custom_date_in):"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:lt(ke.modified)})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:t.jsxs("div",{className:"flex items-center gap-1",onClick:yt=>yt.stopPropagation(),children:[t.jsx("button",{onClick:()=>Ye(ke.name),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded transition-colors",title:"View Details",children:t.jsx(Ps,{})}),t.jsx("button",{onClick:()=>kt(ke.name),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:"Edit Item",children:t.jsx(qr,{})}),t.jsx("button",{onClick:()=>Ae(ke.name),className:"text-purple-600 dark:text-purple-400 hover:text-purple-900 dark:hover:text-purple-300 p-2 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded transition-colors",title:"Duplicate Item",children:t.jsx(Vo,{})}),t.jsx("div",{onClick:yt=>yt.stopPropagation(),children:t.jsx(n0,{doctype:"Item",docname:ke.name,currentDeleteStatus:(Be=ke.custom_delete_status)!=null?Be:null,userRoles:O,isSystemManager:P,triggerMode:!0,redirectOnDelete:"/inventory",onStatusChange:()=>$e()})})]})})]},ke.name)})})]})}),t.jsx(_l,{currentPage:o+1,totalCount:De,pageSize:h,hasMore:Et,itemLabel:e("pagination.items"),onPageChange:ke=>l(Math.max(0,ke-1))})]}),c&&t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx("div",{className:"flex-shrink-0 w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:t.jsx(wr,{className:"text-red-600 dark:text-red-400 text-xl"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:e("items.deleteItem")}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:e("items.deleteConfirmMessage")}),t.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-md p-3 mb-4",children:t.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[t.jsxs("strong",{children:[e("items.itemId"),":"]})," ",c]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>u(null),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-lg transition-colors",disabled:at,children:e("common.cancel")}),t.jsx("button",{onClick:()=>Yt(c),className:"px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50",disabled:at,children:at?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),e("common.deleting")]}):t.jsxs(t.Fragment,{children:[t.jsx(wr,{}),e("items.deleteItem")]})})]})]})]})})}),t.jsx("style",{children:`
|
||
@keyframes scale-in {
|
||
from {
|
||
transform: scale(0.95);
|
||
opacity: 0;
|
||
}
|
||
to {
|
||
transform: scale(1);
|
||
opacity: 1;
|
||
}
|
||
}
|
||
.animate-scale-in {
|
||
animation: scale-in 0.2s ease-out;
|
||
}
|
||
|
||
.scrollbar-hide {
|
||
-ms-overflow-style: none;
|
||
scrollbar-width: none;
|
||
}
|
||
.scrollbar-hide::-webkit-scrollbar {
|
||
display: none;
|
||
}
|
||
`})]})},wie=()=>{var he,de,xe,ge;const{t:e}=sr(),{itemName:r}=hs(),a=hr(),s=mo(),[n]=_a(),i=n.get("duplicate"),o=p.useMemo(()=>{if(r==="new")return"new";const be="/inventory/",K=window.location.pathname,ye=K.indexOf(be);if(ye!==-1){const Z=K.slice(ye+be.length);try{return decodeURIComponent(Z)}catch(M){return Z}}return r||""},[r,s.pathname]),l=o==="new",c=l&&!!i,[u,h]=p.useState(0),[f,y]=p.useState(!1),[b,w]=p.useState([]),[v,k]=p.useState(!1),[S,N]=p.useState(!1);p.useEffect(()=>{J(null,null,function*(){try{const K=yield At.apiCall("/api/method/asset_lite.api.user_roles.get_user_roles"),ye=Array.isArray(K)?K:(K==null?void 0:K.message)||[];w(ye),k(ye.includes("System Manager"))}catch(K){console.error("Error fetching roles:",K)}finally{N(!0)}})},[]);const[C,O]=p.useState({item_code:"",item_name:"",item_group:"",custom_technical_department:"",custom_hospital_name:"",custom_part_description:"",stock_uom:"Nos",custom_item_cost_per_unit:0,disabled:0,is_stock_item:1,is_fixed_asset:0,opening_stock:0,valuation_rate:0,standard_rate:0,custom_last_calibration_date:"",custom_next_due_calibration_date:"",description:"",brand:"",custom_warranty_in_months:"",valuation_method:"",has_batch_no:0,has_serial_no:0,custom_serial_no:"",custom_date_in:"",custom_code:"",custom_type:"",custom_volts:void 0,custom_w:void 0,is_purchase_item:1,is_sales_item:1,country_of_origin:"Saudi Arabia"}),{item:T,loading:P,error:E,refetch:R}=yie(c?i:l?null:o||null),{createItem:z,updateItem:G,loading:ae}=ML(),[ee,ne]=p.useState(l),te=(he=T==null?void 0:T.docstatus)!=null?he:0,Y=te===1,q=te===2,H=te===0,U=!!(T!=null&&T.custom_delete_status),re=C.item_group==="Tools",X=p.useCallback(be=>J(null,null,function*(){var K;if(be){y(!0);try{let ye=null;typeof window!="undefined"&&window.csrf_token&&(ye=window.csrf_token);const Z=JSON.stringify([["item_code","=",be]]),M=JSON.stringify(["actual_qty","warehouse"]),we=`${Ar.BASE_URL}/api/resource/Bin?filters=${encodeURIComponent(Z)}&fields=${encodeURIComponent(M)}&limit_page_length=0`,pe={Accept:"application/json","Content-Type":"application/json"};ye&&(pe["X-Frappe-CSRF-Token"]=ye);const le=yield fetch(we,{method:"GET",headers:pe,credentials:"include"});if(!le.ok)throw new Error(`HTTP error! status: ${le.status}`);const ze=((K=(yield le.json()).data)==null?void 0:K.reduce((Re,De)=>Re+(De.actual_qty||0),0))||0;h(ze)}catch(ye){console.error("Failed to fetch balance qty:",ye),h(0)}finally{y(!1)}}}),[]);p.useEffect(()=>{!l&&(T!=null&&T.item_code)&&X(T.item_code)},[l,T==null?void 0:T.item_code,X]),p.useEffect(()=>{var be,K,ye,Z,M,we,pe,le,Fe,ze;T&&!c?(O({item_code:T.item_code||"",item_name:T.item_name||"",item_group:T.item_group||"",custom_technical_department:T.custom_technical_department||"",custom_hospital_name:T.custom_hospital_name||"",custom_part_description:T.custom_part_description||"",stock_uom:T.stock_uom||"Nos",custom_item_cost_per_unit:T.custom_item_cost_per_unit||0,disabled:T.disabled||0,is_stock_item:(be=T.is_stock_item)!=null?be:1,is_fixed_asset:(K=T.is_fixed_asset)!=null?K:0,opening_stock:T.opening_stock||0,valuation_rate:(ye=T.valuation_rate)!=null?ye:0,standard_rate:T.standard_rate||0,custom_last_calibration_date:T.custom_last_calibration_date||"",custom_next_due_calibration_date:T.custom_next_due_calibration_date||"",description:T.description||"",brand:T.brand||"",custom_warranty_in_months:T.custom_warranty_in_months||"",valuation_method:T.valuation_method||"",has_batch_no:T.has_batch_no||0,has_serial_no:T.has_serial_no||0,is_purchase_item:(Z=T.is_purchase_item)!=null?Z:1,is_sales_item:(M=T.is_sales_item)!=null?M:1,country_of_origin:T.country_of_origin||"Saudi Arabia",uoms:T.uoms||[],item_defaults:T.item_defaults||[],custom_serial_no:T.custom_serial_no||"",custom_date_in:T.custom_date_in||"",custom_code:T.custom_code||"",custom_type:T.custom_type||"",custom_volts:T.custom_volts,custom_w:T.custom_w}),ne(!1)):c&&T&&O({item_code:"",item_name:T.item_name||"",item_group:T.item_group||"",custom_technical_department:T.custom_technical_department||"",custom_hospital_name:T.custom_hospital_name||"",custom_part_description:T.custom_part_description||"",stock_uom:T.stock_uom||"Nos",custom_item_cost_per_unit:T.custom_item_cost_per_unit||0,disabled:0,is_stock_item:(we=T.is_stock_item)!=null?we:1,is_fixed_asset:(pe=T.is_fixed_asset)!=null?pe:0,opening_stock:T.opening_stock||0,valuation_rate:(le=T.valuation_rate)!=null?le:0,standard_rate:T.standard_rate||0,custom_last_calibration_date:T.custom_last_calibration_date||"",custom_next_due_calibration_date:T.custom_next_due_calibration_date||"",description:T.description||"",brand:T.brand||"",custom_warranty_in_months:T.custom_warranty_in_months||"",valuation_method:T.valuation_method||"",has_batch_no:T.has_batch_no||0,has_serial_no:T.has_serial_no||0,is_purchase_item:(Fe=T.is_purchase_item)!=null?Fe:1,is_sales_item:(ze=T.is_sales_item)!=null?ze:1,country_of_origin:T.country_of_origin||"Saudi Arabia",uoms:T.uoms||[],item_defaults:T.item_defaults||[],custom_serial_no:T.custom_serial_no||"",custom_date_in:T.custom_date_in||"",custom_code:T.custom_code||"",custom_type:T.custom_type||"",custom_volts:T.custom_volts,custom_w:T.custom_w})},[T,c]);const V=()=>J(null,null,function*(){try{if(l){const be=yield z(C);a(`/inventory/${be.name}`)}else yield G(o,C),yield R(),C.item_code&&X(C.item_code),ne(!1),alert(e("items.itemUpdatedSuccessfully"))}catch(be){alert(`${e("items.failedToSave")}: ${be instanceof Error?be.message:"Unknown error"}`)}}),I=p.useCallback(be=>!!(!ee||q||U||Y),[ee,q,Y,U]);if(P)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("items.loadingItem")})]})});if(E&&!l)return t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:e("items.errorLoadingItem")}),t.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:E}),t.jsx("button",{onClick:()=>a(-1),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:e("items.backToInventory")})]})});const B="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",Q="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",ie="text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",me="bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700";return t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("button",{onClick:()=>a(-1),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-2",children:[t.jsx(ia,{}),t.jsx("span",{className:"text-gray-900 dark:text-white font-medium",children:l?e("items.newItem"):(T==null?void 0:T.item_name)||(T==null?void 0:T.item_code)||e("items.title")})]}),!l&&t.jsx("span",{className:"px-3 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300",children:(T==null?void 0:T.item_code)||o})]}),t.jsxs("div",{className:"flex gap-3",children:[!l&&!ee&&H&&!U&&t.jsxs("button",{onClick:()=>ne(!0),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(qr,{}),e("common.edit")]}),ee&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>{l?a(-1):(ne(!1),R())},className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg",children:e("common.cancel")}),t.jsxs("button",{type:"button",onClick:V,disabled:ae,className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 disabled:opacity-50",children:[t.jsx(ta,{}),e(ae?"common.saving":"common.save")]})]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[t.jsxs("div",{className:me,children:[t.jsx("h2",{className:ie,children:e("items.basicInformation")}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:Q,children:[e("items.itemCode")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",value:C.item_code,onChange:be=>O(je(se({},C),{item_code:be.target.value})),disabled:I("item_code")||!l,className:B,required:!0})]}),t.jsx(Je,{label:e("commonFields.hospital"),doctype:"Company",value:C.custom_hospital_name||"",onChange:be=>O(je(se({},C),{custom_hospital_name:be})),disabled:I("custom_hospital_name"),placeholder:e("items.selectHospital"),filters:{domain:"Healthcare"}}),t.jsx(Je,{label:e("items.itemGroup"),doctype:"Item Group",value:C.item_group||"",onChange:be=>O(je(se({},C),{item_group:be})),disabled:I("item_group"),placeholder:e("items.selectItemGroup")}),t.jsx(Je,{label:e("items.technicalDepartment"),doctype:"Issue Type",value:C.custom_technical_department||"",onChange:be=>O(je(se({},C),{custom_technical_department:be})),disabled:I("custom_technical_department"),placeholder:e("items.selectTechnicalDepartment")}),t.jsxs("div",{children:[t.jsx("label",{className:Q,children:e("items.stockUOM")}),t.jsx("input",{type:"text",value:C.stock_uom,onChange:be=>O(je(se({},C),{stock_uom:be.target.value})),disabled:I("stock_uom"),className:B})]}),t.jsxs("div",{children:[t.jsx("label",{className:Q,children:e("items.partDescription")}),t.jsx("input",{type:"text",value:C.custom_part_description,onChange:be=>O(je(se({},C),{custom_part_description:be.target.value})),disabled:I("custom_part_description"),className:B})]})]})]}),t.jsxs("div",{className:me,children:[t.jsx("h2",{className:ie,children:e("items.inventoryDetails")}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:Q,children:e("items.serialNo")}),t.jsx("input",{type:"text",value:C.custom_serial_no,onChange:be=>O(je(se({},C),{custom_serial_no:be.target.value})),disabled:I("custom_serial_no"),className:B})]}),t.jsxs("div",{children:[t.jsx("label",{className:Q,children:e("items.dateIn")}),t.jsx("input",{type:"date",value:C.custom_date_in,onChange:be=>O(je(se({},C),{custom_date_in:be.target.value})),disabled:I("custom_date_in"),className:B})]}),t.jsxs("div",{children:[t.jsx("label",{className:Q,children:e("items.watts")}),t.jsx("input",{type:"number",step:"0.01",value:(de=C.custom_w)!=null?de:"",onChange:be=>{const K=parseFloat(be.target.value);O(je(se({},C),{custom_w:be.target.value===""||isNaN(K)?void 0:K}))},disabled:I("custom_w"),className:B})]}),t.jsxs("div",{children:[t.jsx("label",{className:Q,children:e("items.volts")}),t.jsx("input",{type:"number",step:"0.01",value:(xe=C.custom_volts)!=null?xe:"",onChange:be=>{const K=parseFloat(be.target.value);O(je(se({},C),{custom_volts:be.target.value===""||isNaN(K)?void 0:K}))},disabled:I("custom_volts"),className:B})]}),t.jsxs("div",{children:[t.jsx("label",{className:Q,children:e("items.type")}),t.jsx("input",{type:"text",value:C.custom_type,onChange:be=>O(je(se({},C),{custom_type:be.target.value})),disabled:I("custom_type"),className:B})]}),t.jsxs("div",{children:[t.jsx("label",{className:Q,children:e("items.code")}),t.jsx("input",{type:"text",value:C.custom_code,onChange:be=>O(je(se({},C),{custom_code:be.target.value})),disabled:I("custom_code"),className:B})]})]})]}),t.jsxs("div",{className:me,children:[t.jsx("h2",{className:ie,children:e("items.stockInformation")}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"checkbox",id:"is_stock_item",checked:C.is_stock_item===1,onChange:be=>O(je(se({},C),{is_stock_item:be.target.checked?1:0})),disabled:I("is_stock_item"),className:"w-4 h-4"}),t.jsx("label",{htmlFor:"is_stock_item",className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:e("items.isStockItem")})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"checkbox",id:"is_fixed_asset",checked:C.is_fixed_asset===1,onChange:be=>O(je(se({},C),{is_fixed_asset:be.target.checked?1:0})),disabled:I("is_fixed_asset"),className:"w-4 h-4"}),t.jsx("label",{htmlFor:"is_fixed_asset",className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:e("items.isFixedAsset")})]}),l&&C.is_stock_item===1&&t.jsxs("div",{children:[t.jsx("label",{className:Q,children:e("items.openingStock")}),t.jsx("input",{type:"number",value:C.opening_stock,onChange:be=>O(je(se({},C),{opening_stock:parseFloat(be.target.value)||0})),disabled:I("opening_stock"),className:B})]}),C.is_stock_item===1&&t.jsxs("div",{children:[t.jsx("label",{className:Q,children:e("items.valuationRate")}),t.jsx("input",{type:"number",step:"0.01",value:C.valuation_rate,onChange:be=>O(je(se({},C),{valuation_rate:parseFloat(be.target.value)||0})),disabled:I("valuation_rate"),className:B})]}),!l&&C.is_stock_item===1&&t.jsxs("div",{children:[t.jsx("label",{className:Q,children:e("items.balanceQty")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"number",value:u,readOnly:!0,className:`${B} bg-gray-100 dark:bg-gray-800 cursor-not-allowed`}),t.jsx("button",{type:"button",onClick:()=>C.item_code&&X(C.item_code),disabled:f,className:"p-2 text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 disabled:opacity-50",title:e("items.refreshBalanceQty"),children:t.jsx(Ma,{className:f?"animate-spin":""})})]})]})]}),re&&t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:`${ie} mt-6`,children:e("items.calibrationInformation")}),t.jsxs("div",{className:"space-y-4 mt-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:Q,children:e("items.lastCalibrationDate")}),t.jsx("input",{type:"date",value:C.custom_last_calibration_date,onChange:be=>O(je(se({},C),{custom_last_calibration_date:be.target.value})),disabled:I("custom_last_calibration_date"),className:B})]}),t.jsxs("div",{children:[t.jsx("label",{className:Q,children:e("items.nextCalibrationDate")}),t.jsx("input",{type:"date",value:C.custom_next_due_calibration_date,onChange:be=>O(je(se({},C),{custom_next_due_calibration_date:be.target.value})),disabled:I("custom_next_due_calibration_date"),className:B})]})]})]}),t.jsx("h2",{className:`${ie} mt-6`,children:e("items.additionalInformation")}),t.jsxs("div",{className:"space-y-4 mt-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:Q,children:e("commonFields.description")}),t.jsx("textarea",{value:C.description,onChange:be=>O(je(se({},C),{description:be.target.value})),disabled:I("description"),rows:3,className:B})]}),t.jsxs("div",{children:[t.jsx("label",{className:Q,children:e("items.warrantyMonths")}),t.jsx("input",{type:"text",value:C.custom_warranty_in_months,onChange:be=>O(je(se({},C),{custom_warranty_in_months:be.target.value})),disabled:I("custom_warranty_in_months"),className:B})]})]})]})," ",!l&&t.jsx("div",{className:"mt-6",children:t.jsx(Bm,{referenceDoctype:"Item",referenceName:o||null,title:"Comments & Discussion",pollInterval:3e4,initialLimit:5,collapsible:!0,startCollapsed:!1})}),!l&&!c&&t.jsx("div",{className:"mt-6",children:t.jsx(vi,{doctype:"Item",docname:o||null,creationDate:T==null?void 0:T.creation,createdBy:T==null?void 0:T.owner,compact:!1,initialVisible:5,collapsible:!0,startCollapsed:!0})}),!l&&S&&t.jsx("div",{className:"mt-6 max-w-sm",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Delete Request"}),t.jsx(n0,{doctype:"Item",docname:o,currentDeleteStatus:(ge=T==null?void 0:T.custom_delete_status)!=null?ge:null,userRoles:b,isSystemManager:v,redirectOnDelete:"/inventory",onStatusChange:()=>R()})]})})]})," "]})};const jie=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),_ie=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,a,s)=>s?s.toUpperCase():a.toLowerCase()),D7=e=>{const r=_ie(e);return r.charAt(0).toUpperCase()+r.slice(1)},LL=(...e)=>e.filter((r,a,s)=>!!r&&r.trim()!==""&&s.indexOf(r)===a).join(" ").trim(),kie=e=>{for(const r in e)if(r.startsWith("aria-")||r==="role"||r==="title")return!0};var Nie={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Sie=p.forwardRef((u,c)=>{var h=u,{color:e="currentColor",size:r=24,strokeWidth:a=2,absoluteStrokeWidth:s,className:n="",children:i,iconNode:o}=h,l=li(h,["color","size","strokeWidth","absoluteStrokeWidth","className","children","iconNode"]);return p.createElement("svg",se(se(je(se({ref:c},Nie),{width:r,height:r,stroke:e,strokeWidth:s?Number(a)*24/Number(r):a,className:LL("lucide",n)}),!i&&!kie(l)&&{"aria-hidden":"true"}),l),[...o.map(([f,y])=>p.createElement(f,y)),...Array.isArray(i)?i:[i]])});const qs=(e,r)=>{const a=p.forwardRef((o,i)=>{var l=o,{className:s}=l,n=li(l,["className"]);return p.createElement(Sie,se({ref:i,iconNode:r,className:LL(`lucide-${jie(D7(e))}`,`lucide-${e}`,s)},n))});return a.displayName=D7(e),a};const Cie=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Tie=qs("bell",Cie);const Eie=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],Aie=qs("box",Eie);const Oie=[["path",{d:"M10 12h4",key:"a56b0p"}],["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M14 21v-3a2 2 0 0 0-4 0v3",key:"1rgiei"}],["path",{d:"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",key:"secmi2"}],["path",{d:"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16",key:"16ra0t"}]],Pie=qs("building-2",Oie);const Die=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m9 16 2 2 4-4",key:"19s6y9"}]],Rie=qs("calendar-check",Die);const Mie=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Lie=qs("calendar",Mie);const Fie=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Iie=qs("circle-question-mark",Fie);const zie=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]],$ie=qs("circle-user",zie);const Uie=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]],Bie=qs("clipboard-list",Uie);const Wie=[["rect",{x:"2",y:"6",width:"20",height:"8",rx:"1",key:"1estib"}],["path",{d:"M17 14v7",key:"7m2elx"}],["path",{d:"M7 14v7",key:"1cm7wv"}],["path",{d:"M17 3v3",key:"1v4jwn"}],["path",{d:"M7 3v3",key:"7o6guu"}],["path",{d:"M10 14 2.3 6.3",key:"1023jk"}],["path",{d:"m14 6 7.7 7.7",key:"1s8pl2"}],["path",{d:"m8 6 8 8",key:"hl96qh"}]],Hie=qs("construction",Wie);const qie=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],R7=qs("file-text",qie);const Vie=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Gie=qs("folder-open",Vie);const Kie=[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]],Yie=qs("languages",Kie);const Jie=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],Zie=qs("layout-dashboard",Jie);const Xie=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Qie=qs("log-out",Xie);const eoe=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],toe=qs("map",eoe);const roe=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],FL=qs("menu",roe);const aoe=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],soe=qs("moon",aoe);const noe=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],ioe=qs("package",noe);const ooe=[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]],loe=qs("shopping-cart",ooe);const coe=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],doe=qs("sun",coe);const uoe=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],moe=qs("users",uoe);const hoe=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],M7=qs("x",hoe),poe=({title:e="Coming Soon"})=>t.jsx("div",{className:"flex items-center justify-center min-h-screen bg-gray-50 dark:bg-gray-900 p-4",children:t.jsxs("div",{className:"text-center max-w-md",children:[t.jsx("div",{className:"mb-6 flex justify-center",children:t.jsx("div",{className:"bg-blue-100 dark:bg-blue-900/30 p-6 rounded-full",children:t.jsx(Hie,{size:64,className:"text-blue-600 dark:text-blue-400"})})}),t.jsx("h1",{className:"text-4xl font-bold text-gray-900 dark:text-white mb-4",children:e}),t.jsx("p",{className:"text-lg text-gray-600 dark:text-gray-400 mb-8",children:"Access Currently Denied"})]})}),IL=p.createContext(void 0),goe=({children:e})=>{const{i18n:r}=sr(),[a,s]=p.useState(()=>localStorage.getItem("i18nextLng")==="ar"?"ar":"en"),n=a==="ar";p.useEffect(()=>{const o=document.documentElement,l=document.documentElement;r.changeLanguage(a),l.setAttribute("lang",a),n?(l.setAttribute("dir","rtl"),o.classList.add("rtl"),o.classList.remove("ltr")):(l.setAttribute("dir","ltr"),o.classList.add("ltr"),o.classList.remove("rtl"))},[a,r,n]);const i=o=>J(null,null,function*(){s(o),localStorage.setItem("i18nextLng",o),yield Pf()});return t.jsx(IL.Provider,{value:{language:a,changeLanguage:i,isRTL:n},children:e})},zL=()=>{const e=p.useContext(IL);if(!e)throw new Error("useLanguage must be used within LanguageProvider");return e},$L=p.createContext(void 0),foe=({children:e})=>{const[r,a]=p.useState(!1),s=p.useCallback(()=>{a(!0)},[]),n=p.useCallback(()=>{a(!1)},[]);return t.jsx($L.Provider,{value:{mobileSidebarOpen:r,openMobileSidebar:s,closeMobileSidebar:n},children:e})},UL=()=>{const e=p.useContext($L);if(!e)throw new Error("useSidebarLayout must be used within SidebarLayoutProvider");return e},xoe=["System Manager","Contractor Supervisor","Contractor Manager","Work Control","Contractor Engineer"],yoe="Technician",boe="End User";function voe(){const[e,r]=p.useState(()=>typeof window!="undefined"?window.matchMedia("(min-width: 1024px)").matches:!1);return p.useEffect(()=>{const a=window.matchMedia("(min-width: 1024px)"),s=()=>r(a.matches);return a.addEventListener("change",s),()=>a.removeEventListener("change",s)},[]),e}const woe=({userEmail:e})=>{const[r,a]=p.useState(!1),[s,n]=p.useState(!0),i=mo(),o=hr(),l=voe(),{isRTL:c}=zL(),{t:u}=sr(),{mobileSidebarOpen:h,closeMobileSidebar:f}=UL(),y=()=>{l||f()},b=c?"border-l border-gray-200 dark:border-gray-700":"border-r border-gray-200 dark:border-gray-700",w=c?"border-r-4 border-white":"border-l-4 border-white",[v,k]=p.useState({isAdmin:!1,isTechnician:!1,isEndUser:!1,isLoading:!0}),[S,N]=p.useState(""),C="/assets/asm_ui_app/asm_app/",O="?v=1774269853",T="?v=1774269853",P=C.endsWith("/")?`${C}sidebar-background.jpg${O}`:`${C}/sidebar-background.jpg${O}`;p.useEffect(()=>{J(null,null,function*(){var Y,q,H;try{const X=((Y=(yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:xoe.join(",")})})).json()).message)==null?void 0:Y.has_role)||!1,B=((q=(yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:yoe})})).json()).message)==null?void 0:q.has_role)||!1,me=((H=(yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:boe})})).json()).message)==null?void 0:H.has_role)||!1;k({isAdmin:X,isTechnician:B,isEndUser:me,isLoading:!1}),console.log("User roles:",{isAdmin:X,isTechnician:B,isEndUser:me})}catch(U){console.error("Error fetching user roles:",U),k({isAdmin:!1,isTechnician:!1,isEndUser:!0,isLoading:!1})}})},[]),p.useEffect(()=>{J(null,null,function*(){var Y;try{const U=(yield(yield fetch("/api/method/frappe.auth.get_logged_user",{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json()).message;if(U){const X=yield(yield fetch(`/api/resource/User/${encodeURIComponent(U)}?fields=["full_name"]`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json();(Y=X.data)!=null&&Y.full_name?N(X.data.full_name):N(U)}}catch(q){console.error("Error fetching user full name:",q),e&&N(e)}})},[e]);const E=te=>{const{isAdmin:Y,isTechnician:q,isEndUser:H,isLoading:U}=v;if(U)return!1;if(Y)return!0;const re=["work-orders","support","assets","inventory","projects"],X=["work-orders","inspections","procurement","support","active-map","assets","inventory","projects"];let V=!1;return H&&re.includes(te)&&(V=!0),q&&X.includes(te)&&(V=!0),!Y&&!q&&!H&&(V=re.includes(te)),V},R=[{id:"dashboard",title:u("common.dashboard"),icon:t.jsx(Zie,{size:20}),path:"/dashboard",visible:v.isAdmin},{id:"assets",title:u("common.assets"),icon:t.jsx(ioe,{size:20}),path:"/assets",visible:E("assets")},{id:"inventory",title:u("sidebar.inventory"),icon:t.jsx(Aie,{size:20}),path:"/inventory",visible:E("inventory")},{id:"projects",title:u("sidebar.projects"),icon:t.jsx(Gie,{size:20}),path:"/projects",visible:E("projects")},{id:"work-orders",title:u("common.workOrders"),icon:t.jsx(Bie,{size:20}),path:"/work-orders",visible:E("work-orders")},{id:"inspections",title:u("sidebar.inspection"),icon:t.jsx(ao,{size:20}),path:"/inspections",visible:E("inspections")},{id:"sfda-entries",title:u("sidebar.sfdaEntries"),icon:t.jsx(R7,{size:20}),path:"/sfda-entries",visible:v.isAdmin},{id:"ppm-planner",title:u("sidebar.ppmPlanner"),icon:t.jsx(Rie,{size:20}),path:"/ppm-planner",visible:v.isAdmin},{id:"maintenance-calendar",title:u("sidebar.maintenanceCalendar"),icon:t.jsx(Lie,{size:20}),path:"/maintenance-calendar",visible:v.isAdmin},{id:"active-map",title:u("sidebar.activeMap"),icon:t.jsx(toe,{size:20}),path:"/active-map",visible:E("active-map")},{id:"maintenance-teams",title:u("sidebar.maintenanceTeam"),icon:t.jsx(moe,{size:20}),path:"/maintenance-teams",visible:v.isAdmin},{id:"facility-management",title:"Facility Management",icon:t.jsx(Pie,{size:20}),path:"/facility-management-external",visible:v.isAdmin},{id:"procurement",title:u("sidebar.procurement"),icon:t.jsx(loe,{size:20}),path:"/procurement",visible:E("procurement")},{id:"sla",title:u("sidebar.sla"),icon:t.jsx(R7,{size:20}),path:"/sla",visible:v.isAdmin},{id:"support",title:u("sidebar.support"),icon:t.jsx(Iie,{size:20}),path:"/support",visible:E("support")}],z=R.find(te=>te.id==="projects"),G=R.filter(te=>te.visible&&te.id!=="projects"),ae=te=>i.pathname===te,ee=i.pathname==="/projects"||i.pathname.startsWith("/projects/");p.useEffect(()=>{f()},[i.pathname,f]);const ne=c?`
|
||
fixed inset-y-0 right-0 z-50 h-screen
|
||
transition-transform duration-300 ease-in-out
|
||
${h?"translate-x-0":"translate-x-full"}
|
||
lg:relative lg:inset-auto lg:right-auto lg:z-auto lg:translate-x-0
|
||
`:`
|
||
fixed inset-y-0 left-0 z-50 h-screen
|
||
transition-transform duration-300 ease-in-out
|
||
${h?"translate-x-0":"-translate-x-full"}
|
||
lg:relative lg:inset-auto lg:left-auto lg:z-auto lg:translate-x-0
|
||
`;return v.isLoading?t.jsxs(t.Fragment,{children:[h&&t.jsx("button",{type:"button",className:"asm-app-sidebar-backdrop fixed inset-0 z-40 bg-black/50 lg:hidden",onClick:f,"aria-label":u("common.close",{defaultValue:"Close menu"})}),t.jsxs("div",{className:`
|
||
asm-app-sidebar
|
||
flex
|
||
h-screen
|
||
w-64
|
||
flex-col
|
||
items-center
|
||
justify-center
|
||
shadow-xl
|
||
${b}
|
||
${ne}
|
||
`,style:{backgroundImage:`url(${P})`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat"},children:[t.jsx("div",{className:"absolute inset-0 z-0 bg-black/60 dark:bg-black/70"}),t.jsxs("div",{className:"relative z-10 text-white",children:[t.jsx("div",{className:"mx-auto h-8 w-8 animate-spin rounded-full border-b-2 border-white"}),t.jsx("p",{className:"mt-2 text-sm",children:u("common.loading")})]})]})]}):t.jsxs(t.Fragment,{children:[h&&t.jsx("button",{type:"button",className:"asm-app-sidebar-backdrop fixed inset-0 z-40 bg-black/50 lg:hidden",onClick:f,"aria-label":u("common.close",{defaultValue:"Close menu"})}),t.jsxs("div",{className:`
|
||
asm-app-sidebar
|
||
h-screen
|
||
transition-all
|
||
duration-300
|
||
ease-in-out
|
||
flex
|
||
flex-col
|
||
shadow-xl
|
||
${b}
|
||
${r?"w-16":"w-64"}
|
||
${ne}
|
||
`,style:{backgroundImage:`url(${P})`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat"},children:[t.jsx("div",{className:"absolute inset-0 bg-black/60 dark:bg-black/70 z-0"}),t.jsxs("div",{className:"relative z-10 flex flex-col h-full bg-white/0 dark:bg-white/0",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200/30 dark:border-gray-700/30",children:[!r&&t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsxs("div",{className:"w-10 h-10 flex items-center justify-center bg-white/20 dark:bg-white/20 rounded-lg p-1 backdrop-blur-sm",children:[t.jsx("img",{src:`${C}${C.endsWith("/")?"":"/"}seera-logo.png${T}`,alt:"SEERA-ASM",className:"w-full h-full object-contain",onError:te=>{var Y;te.currentTarget.style.display="none",(Y=te.currentTarget.nextElementSibling)==null||Y.classList.remove("hidden")}}),t.jsxs("svg",{className:"w-6 h-6 hidden",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"#6366F1",fillOpacity:"0.9"}),t.jsx("path",{d:"M2 17L12 22L22 17V12L12 17L2 12V17Z",fill:"#8B5CF6",fillOpacity:"0.7"}),t.jsx("path",{d:"M12 12V17",stroke:"#A855F7",strokeWidth:"2",strokeLinecap:"round"})]})]}),t.jsx("h1",{className:"text-white dark:text-white text-lg font-semibold drop-shadow-lg",children:u("sidebar.title")})]}),r&&t.jsxs("div",{className:"w-8 h-8 flex items-center justify-center bg-white dark:bg-gray-700 rounded-lg p-1",children:[t.jsx("img",{src:`${C}${C.endsWith("/")?"":"/"}seera-logo.png?v=1765198405${T}`,alt:"SEERA-ASM",className:"w-full h-full object-contain",onError:te=>{var Y;te.currentTarget.style.display="none",(Y=te.currentTarget.nextElementSibling)==null||Y.classList.remove("hidden")}}),t.jsxs("svg",{className:"w-5 h-5 hidden",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"#6366F1",fillOpacity:"0.9"}),t.jsx("path",{d:"M2 17L12 22L22 17V12L12 17L2 12V17Z",fill:"#8B5CF6",fillOpacity:"0.7"}),t.jsx("path",{d:"M12 12V17",stroke:"#A855F7",strokeWidth:"2",strokeLinecap:"round"})]})]}),t.jsx("button",{type:"button",onClick:()=>{l?a(!r):f()},className:"text-white dark:text-white hover:bg-white/20 dark:hover:bg-white/20 p-2 rounded-lg transition-colors","aria-label":l?r?u("common.expandSidebar",{defaultValue:"Expand sidebar"}):u("common.collapseSidebar",{defaultValue:"Collapse sidebar"}):u("common.closeMenu",{defaultValue:"Close menu"}),children:l?r?t.jsx(FL,{size:20}):t.jsx(M7,{size:20}):t.jsx(M7,{size:20})})]}),t.jsx("nav",{className:"flex-1 overflow-y-auto py-4",children:G.map(te=>t.jsxs(gr.Fragment,{children:[te.id==="facility-management"?t.jsxs("a",{href:"/space-management/?from=asm",target:"_self",onClick:y,className:`
|
||
flex
|
||
items-center
|
||
px-4
|
||
py-3
|
||
text-white dark:text-white
|
||
hover:bg-white/20 dark:hover:bg-white/20
|
||
hover:text-white dark:hover:text-white
|
||
transition-all
|
||
duration-200
|
||
${r?"justify-center":""}
|
||
`,title:r?te.title:"",children:[t.jsx("span",{children:te.icon}),!r&&t.jsx("span",{className:`${c?"mr-4":"ml-4"} font-medium`,children:te.title})]}):t.jsxs(Df,{to:te.path,onClick:y,className:`
|
||
flex
|
||
items-center
|
||
px-4
|
||
py-3
|
||
text-white dark:text-white
|
||
hover:bg-white/20 dark:hover:bg-white/20
|
||
hover:text-white dark:hover:text-white
|
||
transition-all
|
||
duration-200
|
||
${ae(te.path)?`bg-white/30 dark:bg-white/30 text-white dark:text-white ${w}`:""}
|
||
${r?"justify-center":""}
|
||
`,title:r?te.title:"",children:[t.jsx("span",{children:te.icon}),!r&&t.jsx("span",{className:`${c?"mr-4":"ml-4"} font-medium`,children:te.title})]}),te.id==="inventory"&&(z==null?void 0:z.visible)&&t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>{if(r){o("/projects"),y();return}n(Y=>!Y)},className:`
|
||
w-full
|
||
flex
|
||
items-center
|
||
px-4
|
||
py-3
|
||
text-white dark:text-white
|
||
hover:bg-white/20 dark:hover:bg-white/20
|
||
transition-all duration-200
|
||
${ee?`bg-white/30 dark:bg-white/30 text-white dark:text-white ${w}`:""}
|
||
${r?"justify-center":""}
|
||
`,title:r?z.title:"",children:[t.jsx("span",{children:z.icon}),!r&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:`${c?"mr-4":"ml-4"} font-medium flex-1 text-left`,children:z.title}),t.jsx("span",{className:"opacity-80",children:s?t.jsx(Ja,{size:12}):t.jsx(Fr,{size:12})})]})]}),!r&&s&&t.jsxs("div",{className:`${c?"pr-6":"pl-6"} pb-2`,children:[t.jsxs(Df,{to:"/projects",onClick:y,className:`
|
||
flex items-center gap-2 px-4 py-2 text-white/90 hover:text-white
|
||
hover:bg-white/15 rounded-lg transition-colors
|
||
${i.pathname==="/projects"?"bg-white/20":""}
|
||
`,children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-white/70"}),t.jsx("span",{className:"text-sm font-medium",children:"Projects"})]}),t.jsxs(Df,{to:"/projects/reports",onClick:y,className:`
|
||
flex items-center gap-2 px-4 py-2 text-white/90 hover:text-white
|
||
hover:bg-white/15 rounded-lg transition-colors
|
||
${i.pathname.startsWith("/projects/reports")?"bg-white/20":""}
|
||
`,children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-white/70"}),t.jsx("span",{className:"text-sm font-medium",children:"Dashboard"})]})]})]})]},te.id))}),t.jsx("div",{className:`${r?"p-1":"p-2"} border-t border-white/10 backdrop-blur-sm bg-white/5 relative z-10`,children:!r&&t.jsx("div",{className:"text-[10px] text-white/50 dark:text-white/50 text-center leading-none",children:u("sidebar.version")})})]})]})]})},BL=p.createContext(void 0),joe=({children:e})=>{const[r,a]=p.useState(()=>localStorage.getItem("theme")||"light");p.useEffect(()=>{const n=document.documentElement;localStorage.setItem("theme",r),r==="dark"?n.classList.add("dark"):n.classList.remove("dark")},[r]);const s=()=>{a(n=>n==="light"?"dark":"light")};return t.jsx(BL.Provider,{value:{theme:r,toggleTheme:s},children:e})},_oe=()=>{const e=p.useContext(BL);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e};class koe{getNotifications(r=50,a=0){return J(this,null,function*(){var i,o,l,c;const s=localStorage.getItem("user"),n=s?JSON.parse(s).email:"";if(!n)return[];try{const u=JSON.stringify([["for_user","=",n]]),h=JSON.stringify(["name","subject","email_content","document_type","document_name","read","creation","from_user","type"]),f=yield At.apiCall(`/api/resource/Notification Log?filters=${encodeURIComponent(u)}&fields=${encodeURIComponent(h)}&order_by=creation desc&limit=${r}&offset=${a}`);return console.log("[NotificationService] Fetched notifications:",f==null?void 0:f.data),((i=f==null?void 0:f.data)==null?void 0:i.length)>0&&console.log("[NotificationService] First notification sample:",f.data[0]),(f==null?void 0:f.data)||[]}catch(u){return(o=u==null?void 0:u.message)!=null&&o.includes("417")||(l=u==null?void 0:u.message)!=null&&l.includes("EXPECTATION FAILED")?[]:((c=u==null?void 0:u.message)!=null&&c.includes("417")||console.warn("Notifications API not available:",(u==null?void 0:u.message)||"Unknown error"),[])}})}markAsRead(r){return J(this,null,function*(){var a,s,n,i;try{return yield At.apiCall(`/api/resource/Notification Log/${r}`,{method:"PUT",body:JSON.stringify({read:1})})}catch(o){if((a=o==null?void 0:o.message)!=null&&a.includes("417")||(s=o==null?void 0:o.message)!=null&&s.includes("EXPECTATION FAILED")||(n=o==null?void 0:o.message)!=null&&n.includes("PermissionError")||(i=o==null?void 0:o.message)!=null&&i.includes("Insufficient Permission"))return console.warn("[NotificationService] Cannot mark as read (permissions)"),{success:!1,reason:"permission_denied"};throw console.warn("Error marking notification as read:",(o==null?void 0:o.message)||"Unknown error"),o}})}markAllAsRead(){return J(this,null,function*(){try{const a=(yield this.getNotifications(1e3)).filter(n=>!n.read);let s=0;for(const n of a)try{const i=yield this.markAsRead(n.name);(i==null?void 0:i.success)!==!1&&s++}catch(i){console.error(`Error marking notification ${n.name} as read:`,i)}return{success:!0,marked:s,total:a.length}}catch(r){return console.error("Error marking all notifications as read:",r),{success:!1,marked:0,total:0}}})}getUnreadCount(){return J(this,null,function*(){try{return(yield this.getNotifications(1e3)).filter(a=>!a.read).length}catch(r){return console.error("Error getting unread count:",r),0}})}}const jk=new koe;function Noe(){const[e,r]=p.useState([]),[a,s]=p.useState(0),[n,i]=p.useState(!0),[o,l]=p.useState(null),c=p.useCallback(()=>J(null,null,function*(){var f,y;try{i(!0),l(null);const w=(yield jk.getNotifications()).filter(Boolean).filter(v=>{var k;return!((k=v.subject)!=null&&k.startsWith("Failed to send email"))});r(w),s(w.filter(v=>!v.read).length)}catch(b){if((f=b==null?void 0:b.message)!=null&&f.includes("417")||(y=b==null?void 0:b.message)!=null&&y.includes("EXPECTATION FAILED"))r([]),s(0),l(null);else{const w=b instanceof Error?b.message:"Failed to fetch notifications";l(w),console.warn("Error fetching notifications:",b)}}finally{i(!1)}}),[]);p.useEffect(()=>{c();const f=setInterval(c,3e4);return()=>clearInterval(f)},[c]);const u=p.useCallback(f=>J(null,null,function*(){const y=e,b=a;r(w=>w.map(v=>v.name===f?je(se({},v),{read:1}):v)),s(w=>Math.max(0,w-1));try{yield jk.markAsRead(f)}catch(w){throw console.error("Error marking notification as read:",w),r(y),s(b),w}}),[e,a]),h=p.useCallback(()=>J(null,null,function*(){const f=e,y=a;r(b=>b.map(w=>je(se({},w),{read:1}))),s(0);try{yield jk.markAllAsRead()}catch(b){throw console.error("Error marking all notifications as read:",b),r(f),s(y),b}}),[e,a]);return{notifications:e,unreadCount:a,loading:n,error:o,markAsRead:u,markAllAsRead:h,refetch:c}}const jb=e=>e?(new DOMParser().parseFromString(e,"text/html").body.textContent||"").replace(/\uFEFF/g,"").replace(/\s+/g," ").trim():"",Soe=()=>{const{notifications:e,unreadCount:r,markAsRead:a,markAllAsRead:s}=Noe(),[n,i]=p.useState(!1),[o,l]=p.useState(!1),c=p.useRef(null),u=hr();p.useEffect(()=>{const v=k=>{c.current&&!c.current.contains(k.target)&&i(!1)};return n&&document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[n]);const h=()=>J(null,null,function*(){l(!0);try{yield s()}catch(v){console.warn("[NotificationBell] Could not mark all as read:",v)}finally{l(!1)}}),f=v=>J(null,null,function*(){if(console.log("[NotificationBell] Clicked notification:",v),console.log("[NotificationBell] document_type:",v.document_type),console.log("[NotificationBell] document_name:",v.document_name),!v.read)try{yield a(v.name)}catch(k){console.warn("[NotificationBell] Could not mark as read (permission issue):",k)}if(v.document_type&&v.document_name){const k=v.document_type,S=v.document_name,N=k.replace(/_/g," ").trim();if(console.log("[NotificationBell] Normalized type:",N),console.log("[NotificationBell] Document name:",S),N==="Asset Maintenance Log"||N==="Asset Maintenance")console.log("[NotificationBell] Navigating to maintenance:",`/maintenance/${S}`),u(`/maintenance/${S}`);else if(N==="Work Order"||N==="Asset Repair")console.log("[NotificationBell] Navigating to work order:",`/work-orders/${S}`),u(`/work-orders/${S}`);else if(N==="Asset")console.log("[NotificationBell] Navigating to asset:",`/assets/${S}`),u(`/assets/${S}`);else if(N==="PM Schedule Generator"||N==="PM Schedule")console.log("[NotificationBell] Navigating to PPM planner:",`/ppm-planner/${S}`),u(`/ppm-planner/${S}`);else if(N==="PPM")console.log("[NotificationBell] Navigating to PPM:",`/ppm/${S}`),u(`/ppm/${S}`);else if(N==="Item")console.log("[NotificationBell] Navigating to inventory:",`/inventory/${S}`),u(`/inventory/${S}`);else if(N==="Inspection")console.log("[NotificationBell] Navigating to inspection:",`/inspections/${S}`),u(`/inspections/${S}`);else if(N==="Issue")console.log("[NotificationBell] Navigating to issue",`/issues/${S}`),u(`/support/${S}`);else if(N==="SFDA Entries")console.log("[NotificationBell] Navigating to SFDA Entries",`/sfda-entries/${S}`),u(`/sfda-entries/${S}`);else{console.warn(`[NotificationBell] Unknown document type: ${k}, opening in Frappe`);const C=k.toLowerCase().replace(/\s+/g,"-").replace(/_/g,"-");window.open(`/app/${C}/${S}`,"_blank")}}else console.warn("[NotificationBell] No document_type or document_name found:",{document_type:v.document_type,document_name:v.document_name,notification:v});i(!1)}),y=v=>{const k=new Date(v),N=new Date().getTime()-k.getTime(),C=Math.floor(N/6e4),O=Math.floor(N/36e5),T=Math.floor(N/864e5);return C<1?"Just now":C<60?`${C}m ago`:O<24?`${O}h ago`:T<7?`${T}d ago`:k.toLocaleDateString()},b=e.filter(v=>!v.read),w=e.filter(v=>v.read).slice(0,10);return t.jsxs("div",{className:"relative",ref:c,children:[t.jsxs("button",{onClick:()=>i(!n),className:"relative p-2 text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:"Notifications",children:[t.jsx(Tie,{size:20}),r>0&&t.jsx("span",{className:"absolute top-0 right-0 flex items-center justify-center w-5 h-5 text-xs font-bold text-white bg-red-500 rounded-full",children:r>9?"9+":r})]}),n&&t.jsxs("div",{className:"absolute right-0 mt-2 w-80 bg-white dark:bg-gray-800 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 z-[9999] max-h-96 overflow-hidden flex flex-col",children:[t.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between",children:[t.jsxs("h3",{className:"font-semibold text-gray-800 dark:text-white flex items-center gap-2",children:[t.jsx(wN,{}),"Notifications",r>0&&t.jsxs("span",{className:"text-xs bg-red-500 text-white px-2 py-0.5 rounded-full",children:[r," new"]})]}),r>0&&t.jsx("button",{onClick:h,disabled:o,className:`text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:underline ${o?"opacity-50 cursor-not-allowed":""}`,children:o?"Marking...":"Mark all read"})]}),t.jsx("div",{className:"overflow-y-auto flex-1",children:e.length===0?t.jsxs("div",{className:"p-8 text-center text-gray-500 dark:text-gray-400",children:[t.jsx(wN,{className:"mx-auto text-3xl mb-2 opacity-50"}),t.jsx("p",{children:"No notifications"})]}):t.jsxs(t.Fragment,{children:[b.length>0&&t.jsxs("div",{className:"p-2",children:[t.jsx("div",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 px-2 mb-1",children:"NEW"}),b.map(v=>t.jsx("div",{onClick:()=>f(v),className:"p-3 hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer border-l-4 border-blue-500 bg-blue-50 dark:bg-blue-900/20",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:jb(v.subject||"")||v.document_type||"Notification"}),v.email_content&&t.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-1 line-clamp-2",children:jb(v.email_content||"")}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-500 mt-1",children:y(v.creation)})]}),t.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full flex-shrink-0 mt-1"})]})},v.name))]}),w.length>0&&t.jsxs("div",{className:"p-2 border-t border-gray-200 dark:border-gray-700",children:[b.length>0&&t.jsx("div",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 px-2 mb-1",children:"EARLIER"}),w.map(v=>t.jsx("div",{onClick:()=>f(v),className:"p-3 hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer",children:t.jsx("div",{className:"flex items-start justify-between gap-2",children:t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 truncate",children:jb(v.subject||"")||v.document_type||"Notification"}),v.email_content&&t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1 line-clamp-2",children:jb(v.email_content||"")}),t.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:y(v.creation)})]})})},v.name))]})]})})]})]})},Coe=()=>{const{theme:e,toggleTheme:r}=_oe(),{language:a,changeLanguage:s}=zL(),{t:n}=sr(),{openMobileSidebar:i}=UL(),o=hr(),[l,c]=p.useState(""),[u,h]=p.useState(!1);p.useEffect(()=>{J(null,null,function*(){var b;try{const k=(yield(yield fetch("/api/method/frappe.auth.get_logged_user",{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json()).message;if(k){const N=yield(yield fetch(`/api/resource/User/${encodeURIComponent(k)}?fields=["full_name"]`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json();(b=N.data)!=null&&b.full_name?c(N.data.full_name):c(k)}}catch(w){console.error("Error fetching user full name:",w)}})},[]);const f=()=>J(null,null,function*(){var y;localStorage.removeItem("user"),localStorage.removeItem("sid");try{const b=((y=document.cookie.split("; ").find(w=>w.startsWith("X-Frappe-CSRF-Token=")))==null?void 0:y.split("=")[1])||"";yield fetch("/api/method/frappe.auth.logout",{method:"POST",headers:{"Content-Type":"application/json","X-Frappe-CSRF-Token":b},credentials:"include"}),yield fetch("/?cmd=web_logout",{credentials:"include"})}catch(b){console.error("Logout error:",b)}finally{window.location.href="/asm_app/login"}});return t.jsxs("header",{className:"h-14 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 px-4 flex items-center justify-between gap-2 flex-shrink-0",children:[t.jsx("button",{type:"button",onClick:i,className:"lg:hidden p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors text-gray-700 dark:text-gray-300 -ms-1","aria-label":n("common.menu",{defaultValue:"Open menu"}),title:n("common.menu",{defaultValue:"Menu"}),children:t.jsx(FL,{size:22})}),t.jsx("div",{className:"flex-1 lg:flex-none","aria-hidden":"true"}),t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[l&&t.jsxs("div",{className:"relative",children:[t.jsx("button",{type:"button",onClick:()=>o("/user-profile"),onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),className:"p-2 rounded-lg bg-[#7911cc] hover:bg-[#6a0fb5] transition-colors text-white",title:l,children:t.jsx($ie,{size:20})}),u&&t.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 px-3 py-1.5 bg-gray-800 dark:bg-gray-700 text-white text-xs rounded-lg whitespace-nowrap shadow-lg",children:[l,t.jsx("div",{className:"absolute -top-1 right-3 w-2 h-2 bg-gray-800 dark:bg-gray-700 rotate-45"})]})]}),t.jsx("div",{className:"relative",children:t.jsx(Soe,{})}),t.jsx("button",{onClick:()=>s(a==="en"?"ar":"en"),className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors text-gray-700 dark:text-gray-300",title:n("common.language"),children:t.jsx(Yie,{size:20})}),t.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors text-gray-700 dark:text-gray-300",title:n(e==="light"?"common.darkMode":"common.lightMode"),children:e==="light"?t.jsx(soe,{size:20}):t.jsx(doe,{size:20})}),t.jsx("button",{onClick:f,className:"p-2 rounded-lg hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors text-red-600 dark:text-red-400",title:n("common.logout"),children:t.jsx(Qie,{size:20})})]})]})},Toe=(e={})=>{const[r,a]=p.useState([]),[s,n]=p.useState(!0),[i,o]=p.useState(null),[l,c]=p.useState(0),u=JSON.stringify(e);p.useEffect(()=>{let f=!1;return J(null,null,function*(){try{n(!0),o(null);const y=yield Dd.getIssues(e);if(f)return;a(y.data);const b=yield Dd.getIssueCount(e.filters);if(f)return;c(b)}catch(y){if(f)return;o(y instanceof Error?y.message:"Failed to fetch issues")}finally{f||n(!1)}}),()=>{f=!0}},[u]);const h=p.useCallback(()=>J(null,null,function*(){try{n(!0),o(null);const f=yield Dd.getIssues(e);a(f.data);const y=yield Dd.getIssueCount(e.filters);c(y)}catch(f){o(f instanceof Error?f.message:"Failed to fetch issues")}finally{n(!1)}}),[u]);return{issues:r,loading:s,error:i,totalCount:l,refetch:h}},Eoe=e=>{const[r,a]=p.useState(null),[s,n]=p.useState(!1),[i,o]=p.useState(null),l=p.useCallback(()=>J(null,null,function*(){if(!e){a(null);return}try{n(!0),o(null);const c=yield Dd.getIssue(e);a(c)}catch(c){o(c instanceof Error?c.message:"Failed to fetch issue details")}finally{n(!1)}}),[e]);return p.useEffect(()=>{l()},[l]),{issue:r,loading:s,error:i,refetch:l}},Aoe=()=>{const[e,r]=p.useState(!1),[a,s]=p.useState(null);return{createIssue:l=>J(null,null,function*(){try{return r(!0),s(null),yield Dd.createIssue(l)}catch(c){const u=c instanceof Error?c.message:"Failed to create issue";throw s(u),c}finally{r(!1)}}),updateIssue:(l,c)=>J(null,null,function*(){try{return r(!0),s(null),yield Dd.updateIssue(l,c)}catch(u){const h=u instanceof Error?u.message:"Failed to update issue";throw s(h),u}finally{r(!1)}}),deleteIssue:l=>J(null,null,function*(){try{r(!0),s(null),yield Dd.deleteIssue(l)}catch(c){const u=c instanceof Error?c.message:"Failed to delete issue";throw s(u),c}finally{r(!1)}}),loading:e,error:a}},Ooe=["Work Control","System Manager"],Poe=["Open","Replied","On Hold"],Doe=({isOpen:e,onClose:r,selectedCount:a,totalCount:s,pageCount:n,onExport:i,isExporting:o,exportColumns:l})=>{const{t:c}=sr(),[u,h]=p.useState(a>0?"selected":"all_with_filters"),[f,y]=p.useState("csv"),[b,w]=p.useState(l.filter(N=>N.default).map(N=>N.key));p.useEffect(()=>{a>0?h("selected"):h("all_with_filters")},[a]);const v=N=>{w(C=>C.includes(N)?C.filter(O=>O!==N):[...C,N])},k=()=>w(l.map(N=>N.key)),S=()=>w(l.filter(N=>N.default).map(N=>N.key));return e?t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] overflow-hidden animate-scale-in",children:[t.jsx("div",{className:"bg-gradient-to-r from-green-500 to-green-600 px-6 py-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Sa,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:c("issues.export.title")})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:o,children:t.jsx(ht,{size:20})})]})}),t.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-180px)]",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:c("issues.export.selectData")}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${u==="selected"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"} ${a===0?"opacity-50 cursor-not-allowed":""}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"selected",checked:u==="selected",onChange:()=>h("selected"),disabled:a===0,className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("issues.export.selectedRows")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("issues.export.selectedCount",{count:a})})]}),a>0&&t.jsxs("span",{className:"bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300 px-2 py-1 rounded text-xs font-medium",children:[a," selected"]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${u==="all_on_page"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"all_on_page",checked:u==="all_on_page",onChange:()=>h("all_on_page"),className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("issues.export.currentPage")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("issues.export.currentPageCount",{count:n})})]}),t.jsxs("span",{className:"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300 px-2 py-1 rounded text-xs font-medium",children:[n," rows"]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${u==="all_with_filters"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"all_with_filters",checked:u==="all_with_filters",onChange:()=>h("all_with_filters"),className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("issues.export.allWithFilters")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("issues.export.allWithFiltersCount",{count:s})})]}),t.jsxs("span",{className:"bg-purple-100 dark:bg-purple-900/40 text-purple-700 dark:text-purple-300 px-2 py-1 rounded text-xs font-medium",children:[s," total"]})]})]})]}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:c("issues.export.exportFormat")}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${f==="csv"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"format",value:"csv",checked:f==="csv",onChange:()=>y("csv"),className:"text-green-600 focus:ring-green-500"}),t.jsx(ic,{className:"text-green-600 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("issues.export.csv")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:c("issues.export.csvDesc")})]})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${f==="excel"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"format",value:"excel",checked:f==="excel",onChange:()=>y("excel"),className:"text-green-600 focus:ring-green-500"}),t.jsx(oc,{className:"text-green-700 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("issues.export.excel")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:c("issues.export.excelDesc")})]})]})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:c("issues.export.columnsToExport")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:k,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:c("issues.export.selectAll")}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{onClick:S,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:c("issues.export.resetToDefault")})]})]}),t.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2 max-h-48 overflow-y-auto p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg",children:l.map(N=>t.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${b.includes(N.key)?"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300":"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-400"}`,children:[t.jsx("input",{type:"checkbox",checked:b.includes(N.key),onChange:()=>v(N.key),className:"rounded text-green-600 focus:ring-green-500"}),t.jsx("span",{className:"text-sm truncate",children:N.label})]},N.key))}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:c("issues.export.columnsSelected",{count:b.length})})]})]}),t.jsxs("div",{className:"px-6 py-4 bg-gray-50 dark:bg-gray-900/50 border-t border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[u==="selected"&&c("issues.export.exportingSelected",{count:a}),u==="all_on_page"&&c("issues.export.exportingPage",{count:n}),u==="all_with_filters"&&c("issues.export.exportingAll",{count:s})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{onClick:r,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",disabled:o,children:c("common.cancel")}),t.jsx("button",{onClick:()=>i(u,f,b),disabled:b.length===0||o,className:"px-4 py-2 text-sm font-medium text-white bg-green-600 hover:bg-green-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:o?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),c("issues.export.exporting")]}):t.jsxs(t.Fragment,{children:[t.jsx(qc,{}),c("issues.export.exportButton")]})})]})]})]})}):null},Roe=e=>{switch(e==null?void 0:e.toLowerCase()){case"open":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";case"replied":return"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300";case"on hold":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300";case"resolved":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300";case"closed":return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}},Moe=e=>{switch(e==null?void 0:e.toLowerCase()){case"high":return"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300";case"medium":return"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-300";case"low":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}},Loe=()=>{const{t:e}=sr(),r=hr(),[a,s]=_a(),n=p.useRef(s);p.useEffect(()=>{n.current=s},[s]);const i=p.useMemo(()=>{const He=parseInt(a.get("page")||"1",10);return Number.isNaN(He)||He<1?1:He},[a]),o=p.useCallback(He=>{const it=typeof He=="function"?He(i):He;s(Ue=>{const Ve=new URLSearchParams(Ue);return Ve.set("page",String(it)),Ve})},[i,s]),l=[{key:"name",label:e("issues.issueId"),default:!0},{key:"subject",label:e("issues.subject"),default:!0},{key:"status",label:e("commonFields.status"),default:!0},{key:"priority",label:e("commonFields.priority"),default:!0},{key:"raised_by",label:e("issues.raisedBy"),default:!0},{key:"company",label:e("commonFields.company"),default:!0},{key:"contact",label:e("issues.contact"),default:!1},{key:"issue_type",label:e("issues.issueType"),default:!1},{key:"opening_date",label:e("issues.openingDate"),default:!0},{key:"sla_resolution_date",label:e("issues.resolutionDate"),default:!1},{key:"sla_resolution_by",label:e("issues.resolvedBy"),default:!1},{key:"first_responded_on",label:e("issues.firstRespondedOn"),default:!1},{key:"description",label:e("commonFields.description"),default:!1},{key:"resolution_details",label:e("issues.resolutionDetails"),default:!1},{key:"creation",label:e("commonFields.createdOn"),default:!1},{key:"modified",label:e("commonFields.modifiedOn"),default:!1},{key:"owner",label:e("commonFields.createdBy"),default:!1}],[c]=p.useState(20),[u,h]=p.useState(!1),[f,y]=p.useState(new Set),[b,w]=p.useState(!1),[v,k]=p.useState(!1),[S,N]=p.useState(null),[C,O]=p.useState([]);p.useEffect(()=>{J(null,null,function*(){try{const it=yield At.apiCall("/api/method/asset_lite.api.user_roles.get_user_roles");if(Array.isArray(it))O(it);else if(it&&typeof it=="object"&&"message"in it){const Ue=it.message;Array.isArray(Ue)&&O(Ue)}}catch(it){O([])}})},[]);const T=p.useMemo(()=>Ooe.some(He=>C.includes(He)),[C]),[P,E]=p.useState(()=>a.get("date_filter_by")||""),[R,z]=p.useState(()=>a.get("date_start")||""),[G,ae]=p.useState(()=>a.get("date_end")||""),[ee,ne]=p.useState(()=>{const He=a.get("status");return He===null?"Open":He}),[te,Y]=p.useState(()=>a.get("priority")||""),[q,H]=p.useState(()=>a.get("company")||""),[U,re]=p.useState(()=>a.get("issue_id")||""),[X,V]=p.useState(()=>a.get("sort_by")||"creation desc"),[I,B]=p.useState(!1),[Q,ie]=p.useState(0),[me,he]=p.useState([]),[de,xe]=p.useState(!1),[ge,be]=p.useState("");p.useEffect(()=>{const He=localStorage.getItem("issueFilterPresets");He&&he(JSON.parse(He))},[]);const K=P&&(R||G);p.useEffect(()=>{const He=[ee,te,q,U].filter(Boolean).length+(K?1:0);ie(He)},[ee,te,q,U,K]);const ye=p.useMemo(()=>{const He={};return ee&&(He.status=ee),te&&(He.priority=te),q&&(He.company=q),U&&(He.name=U),Object.assign(He,kl(P,R,G)),He},[ee,te,q,U,P,R,G]),Z=["creation desc","creation asc","modified desc","modified asc","name asc","name desc"].includes(X)?X:"creation desc",{issues:M,loading:we,error:pe,totalCount:le,refetch:Fe}=Toe({filters:ye,limit_start:(i-1)*c,limit_page_length:c,order_by:Z});p.useEffect(()=>{!we&&!u&&h(!0)},[we,u]);const ze=p.useRef(!1);p.useEffect(()=>{if(!ze.current){ze.current=!0;return}n.current(He=>{const it=new URLSearchParams(He);return P?it.set("date_filter_by",P):it.delete("date_filter_by"),R?it.set("date_start",R):it.delete("date_start"),G?it.set("date_end",G):it.delete("date_end"),ee?it.set("status",ee):it.delete("status"),te?it.set("priority",te):it.delete("priority"),q?it.set("company",q):it.delete("company"),U?it.set("issue_id",U):it.delete("issue_id"),X&&X!=="creation desc"?it.set("sort_by",X):it.delete("sort_by"),it.set("page","1"),it})},[P,R,G,ee,te,q,U,X]),p.useEffect(()=>{y(new Set)},[P,R,G,ee,te,q,U,i]);const Re=He=>He?new Date(He).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-",De=()=>{E(""),z(""),ae(""),V("creation desc"),ne(""),Y(""),H(""),re(""),n.current(He=>{const it=new URLSearchParams(He);return it.delete("date_filter_by"),it.delete("date_start"),it.delete("date_end"),it.delete("sort_by"),it.delete("status"),it.delete("priority"),it.delete("company"),it.delete("issue_id"),it.set("page","1"),it})},Et=K||!!ee||!!te||!!q||!!U,jt=()=>{if(!ge.trim()){alert("Please enter a filter name");return}const He={id:Date.now(),name:ge,filters:{dateFilterBy:P,dateStart:R,dateEnd:G,sortBy:X,statusFilter:ee,priorityFilter:te,companyFilter:q,issueIdFilter:U}},it=[...me,He];he(it),be(""),xe(!1),localStorage.setItem("issueFilterPresets",JSON.stringify(it))},Ie=He=>{const it=He.filters;E(it.dateFilterBy||""),z(it.dateStart||""),ae(it.dateEnd||""),V(it.sortBy||"creation desc"),ne(it.statusFilter||""),Y(it.priorityFilter||""),H(it.companyFilter||""),re(it.issueIdFilter||"")},$e=He=>{const it=me.filter(Ue=>Ue.id!==He);he(it),localStorage.setItem("issueFilterPresets",JSON.stringify(it))},Qe=He=>{y(it=>{const Ue=new Set(it);return Ue.has(He)?Ue.delete(He):Ue.add(He),Ue})},at=()=>{f.size===M.length?y(new Set):y(new Set(M.map(He=>He.name)))},Ct=M.length>0&&f.size===M.length,vt=f.size>0&&f.size<M.length,er=p.useCallback(()=>J(null,null,function*(){const He=[];let it=0;const Ue=100;let Ve=!0;const lt=xa(ye);for(;Ve;)try{const Ot=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Issue",filters:lt.length>0?lt:{},fields:["*"],limit_start:it*Ue,limit_page_length:Ue,order_by:Z})})).json()).message||[];He.push(...Ot),Ot.length<Ue?Ve=!1:it++,it>100&&(console.warn("Export safety limit reached"),Ve=!1)}catch(st){throw console.error("Error fetching issues for export:",st),st}return He}),[ye,Z]),nr=(He,it,Ue)=>J(null,null,function*(){k(!0);try{let Ve=[];switch(He){case"selected":Ve=M.filter(st=>f.has(st.name));break;case"all_on_page":Ve=M;break;case"all_with_filters":Ve=yield er();break}if(Ve.length===0){alert(e("assets.noDataToExport"));return}const lt=Ue.map(st=>{var Mt;return((Mt=l.find(Ot=>Ot.key===st))==null?void 0:Mt.label)||st});if(it==="csv"){const st=[lt.join(","),...Ve.map(zt=>Ue.map(Tt=>{let Gt=zt[Tt]||"";return typeof Gt=="string"&&(Gt.includes(",")||Gt.includes('"')||Gt.includes(`
|
||
`))&&(Gt=`"${Gt.replace(/"/g,'""')}"`),Gt}).join(","))].join(`
|
||
`),Mt=new Blob(["\uFEFF"+st],{type:"text/csv;charset=utf-8;"}),Ot=URL.createObjectURL(Mt),Pt=document.createElement("a");Pt.href=Ot,Pt.download=`issues_export_${new Date().toISOString().split("T")[0]}.csv`,Pt.click(),URL.revokeObjectURL(Ot)}else if(it==="excel"){const st=[lt,...Ve.map(Pt=>Ue.map(zt=>Pt[zt]||""))],Mt=Na.aoa_to_sheet(st),Ot=Na.book_new();Na.book_append_sheet(Ot,Mt,"Issues"),lc(Ot,`issues_export_${new Date().toISOString().split("T")[0]}.xlsx`)}w(!1),y(new Set)}catch(Ve){console.error("Export failed:",Ve),alert(`Export failed: ${Ve instanceof Error?Ve.message:"Unknown error"}`)}finally{k(!1)}}),dt=He=>J(null,null,function*(){try{if(!(yield fetch(`/api/resource/Issue/${He}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to delete");N(null),Fe(),alert(e("issues.deletedSuccessfully"))}catch(it){alert(`Failed to delete: ${it instanceof Error?it.message:"Unknown error"}`)}});return we&&!u?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("issues.loadingIssues")})]})}):pe?t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:e("issues.errorLoadingIssues")}),t.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:pe}),t.jsx("button",{onClick:Fe,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:e("common.tryAgain")})]})}):t.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsx("div",{children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Cv,{className:"text-3xl text-blue-600 dark:text-blue-400"}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:e("issues.listTitle")}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[e("issues.listTotal"),": ",le,f.size>0&&t.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",f.size," ",e("issues.listSelected")]}),we&&u&&t.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400",children:[t.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-blue-500"}),e("common.filtering")]})]})]})]})}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("button",{onClick:()=>B(!I),className:`px-4 py-2 rounded-lg flex items-center gap-2 transition-colors ${I||Et?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300":"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600"}`,children:[t.jsx(ds,{}),e("listPages.filters"),Q>0&&t.jsx("span",{className:"bg-blue-600 text-white text-xs px-1.5 py-0.5 rounded-full",children:Q})]}),t.jsxs("button",{onClick:Fe,disabled:we,className:"px-4 py-2 rounded-lg bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 flex items-center gap-2 disabled:opacity-50",children:[t.jsx(Ma,{className:we?"animate-spin":""}),e("listPages.refresh")]}),t.jsxs("button",{onClick:()=>w(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",disabled:le===0,children:[t.jsx(Sa,{}),t.jsx("span",{className:"font-medium",children:e("listPages.export")}),f.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:f.size})]}),t.jsxs("button",{onClick:()=>r("/support/new?skip_precheck=1",{state:{newIssuePrecheckDone:!0}}),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow-lg transition-all hover:shadow-xl",children:[t.jsx(Rr,{}),t.jsx("span",{className:"font-medium",children:e("issues.newIssue")})]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-4",children:[t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e("issues.statsTotalIssues")}),t.jsx("p",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:le})]}),t.jsx(IG,{className:"text-3xl text-blue-500"})]})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e("issues.statsOpen")}),t.jsx("p",{className:"text-2xl font-bold text-blue-600",children:M.filter(He=>He.status==="Open").length})]}),t.jsx(ea,{className:"text-3xl text-blue-500"})]})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e("issues.statsResolved")}),t.jsx("p",{className:"text-2xl font-bold text-green-600",children:M.filter(He=>He.status==="Resolved").length})]}),t.jsx(Qt,{className:"text-3xl text-green-500"})]})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e("issues.statsClosed")}),t.jsx("p",{className:"text-2xl font-bold text-gray-600 dark:text-gray-300",children:M.filter(He=>He.status==="Closed").length})]}),t.jsx(pr,{className:"text-3xl text-gray-500"})]})})]}),I&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-4",children:[t.jsx("div",{className:"bg-gradient-to-r from-blue-500 to-blue-600 dark:from-blue-600 dark:to-blue-700 px-4 py-3 rounded-t-lg",children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ds,{className:"text-white",size:16}),t.jsx("h3",{className:"text-white font-semibold text-sm",children:e("listPages.filters")}),Q>0&&t.jsx("span",{className:"bg-white text-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:Q})]}),Et&&t.jsx("div",{className:"flex-1 overflow-x-auto scrollbar-hide mx-2",children:t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[U&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-blue-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("issues.issueId"),":"]})," ",U,t.jsx("button",{onClick:()=>re(""),className:"hover:text-red-500",children:t.jsx(ht,{className:"text-[9px]"})})]}),ee&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-green-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("filters.status"),":"]})," ",ee,t.jsx("button",{onClick:()=>ne(""),className:"hover:text-red-500",children:t.jsx(ht,{className:"text-[9px]"})})]}),te&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-orange-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("filters.priority"),":"]})," ",te,t.jsx("button",{onClick:()=>Y(""),className:"hover:text-red-500",children:t.jsx(ht,{className:"text-[9px]"})})]}),q&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-purple-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("filters.filterByCompany"),":"]})," ",q,t.jsx("button",{onClick:()=>H(""),className:"hover:text-red-500",children:t.jsx(ht,{className:"text-[9px]"})})]}),K&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("filters.filterBy"),":"]})," ",e(P==="creation"?"filters.createdDate":"filters.latestModifiedDate")," ",R&&` ${R}`," ",G&&` - ${G}`,t.jsx("button",{onClick:()=>{E(""),z(""),ae("")},className:"hover:text-red-500",children:t.jsx(ht,{className:"text-[9px]"})})]})]})}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Q>0&&t.jsxs("button",{onClick:()=>xe(!0),className:"px-3 py-1.5 bg-white text-blue-600 hover:bg-blue-50 rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[t.jsx(ta,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:e("listPages.saveFilterPreset")})]}),Et&&t.jsxs("button",{onClick:De,className:"px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[t.jsx(ht,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:e("listPages.clearFilters")})]})]})]})}),t.jsxs("div",{className:"p-4",children:[me.length>0&&t.jsxs("div",{className:"mb-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[t.jsx(a0,{className:"text-yellow-500",size:12}),e("inspections.savedFilters")]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:me.map(He=>t.jsxs("div",{className:"group relative inline-flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-purple-100 to-blue-100 dark:from-purple-900/30 dark:to-blue-900/30 border border-purple-200 dark:border-purple-700 rounded-lg hover:shadow-md transition-all",children:[t.jsx("button",{onClick:()=>Ie(He),className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:He.name}),t.jsx("button",{onClick:()=>$e(He.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:t.jsx(wr,{size:10})})]},He.id))})]}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 p-3 rounded-lg",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.sortBy")}),t.jsxs("select",{value:X,onChange:He=>{V(He.target.value),o(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"creation desc",children:e("filters.sortCreationNewest")}),t.jsx("option",{value:"creation asc",children:e("filters.sortCreationOldest")}),t.jsx("option",{value:"modified desc",children:e("filters.sortModifiedNewest")}),t.jsx("option",{value:"modified asc",children:e("filters.sortModifiedOldest")}),t.jsx("option",{value:"name asc",children:e("filters.sortNameAsc")}),t.jsx("option",{value:"name desc",children:e("filters.sortNameDesc")})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.filterBy")}),t.jsxs("select",{value:P,onChange:He=>{const it=He.target.value;E(it),o(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("filters.filterBy")}),t.jsx("option",{value:"creation",children:e("filters.createdDate")}),t.jsx("option",{value:"modified",children:e("filters.latestModifiedDate")})]})]}),P&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.startDate")}),t.jsx("input",{type:"date",value:R,onChange:He=>{const it=He.target.value;z(it),G&&it>G&&ae(it),o(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.endDate")}),t.jsx("input",{type:"date",value:G,onChange:He=>{ae(He.target.value),o(1)},min:R||void 0,className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]}),t.jsxs("div",{className:"relative z-[60]",children:[t.jsx(Je,{label:e("issues.issueId"),doctype:"Issue",value:U,onChange:He=>{re(He),o(1)},placeholder:e("linkField.selectLabel",{label:e("issues.issueId")}),disabled:!1,compact:!0}),U&&t.jsx("button",{onClick:()=>re(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.status")}),t.jsxs("select",{value:ee,onChange:He=>{ne(He.target.value),o(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("filters.allStatuses")}),t.jsx("option",{value:"Open",children:e("issues.status.open")}),t.jsx("option",{value:"Replied",children:e("issues.status.replied")}),t.jsx("option",{value:"On Hold",children:e("issues.status.on_hold")}),t.jsx("option",{value:"Resolved",children:e("issues.status.resolved")}),t.jsx("option",{value:"Closed",children:e("issues.status.closed")})]})]}),t.jsxs("div",{className:"relative z-[59]",children:[t.jsx(Je,{label:e("commonFields.priority"),doctype:"Issue Priority",value:te,onChange:He=>{Y(He),o(1)},placeholder:e("issues.allPriorities"),disabled:!1,compact:!0}),te&&t.jsx("button",{onClick:()=>Y(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[58]",children:[t.jsx(Je,{label:e("commonFields.company"),doctype:"Company",value:q,onChange:He=>{H(He),o(1)},placeholder:e("issues.allCompanies"),disabled:!1,compact:!0}),q&&t.jsx("button",{onClick:()=>H(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]})]})})]})]}),de&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 animate-scale-in",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:"Save Filter Preset"}),t.jsx("input",{type:"text",value:ge,onChange:He=>be(He.target.value),onKeyDown:He=>{He.key==="Enter"&&(He.preventDefault(),jt())},placeholder:"Enter filter name (e.g., 'Open High Priority')",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white mb-4",autoFocus:!0}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:()=>{xe(!1),be("")},className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",children:"Cancel"}),t.jsxs("button",{onClick:jt,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors flex items-center gap-2",children:[t.jsx(ta,{size:12}),"Save Filter"]})]})]})}),t.jsx(Doe,{isOpen:b,onClose:()=>w(!1),selectedCount:f.size,totalCount:le,pageCount:M.length,onExport:nr,isExporting:v,exportColumns:l}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-200 dark:border-gray-700 overflow-hidden relative",children:[we&&u&&t.jsx("div",{className:"absolute inset-0 bg-white/60 dark:bg-gray-800/60 flex items-center justify-center z-10 backdrop-blur-[1px]",children:t.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-gray-700 px-4 py-2 rounded-lg shadow-lg",children:[t.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-blue-500"}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:e("common.filtering")})]})}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left",children:t.jsx("button",{onClick:at,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:e(Ct?"listPages.deselectAllTitle":"listPages.selectAllTitle"),children:Ct?t.jsx(Ra,{className:"text-blue-600 dark:text-blue-400",size:18}):vt?t.jsxs("div",{className:"relative",children:[t.jsx(Ur,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Ur,{size:18})})}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("issues.issueId")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("issues.subject")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.status")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.priority")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.company")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("issues.openingDate")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("listPages.actions")})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:M.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:8,className:"px-4 py-12 text-center text-gray-500 dark:text-gray-400",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx(Cv,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("issues.noIssuesFound")}),Et?t.jsx("button",{onClick:De,className:"mt-4 text-blue-600 dark:text-blue-400 hover:underline",children:e("common.clearFilters")}):t.jsx("button",{onClick:()=>r("/support/new?skip_precheck=1",{state:{newIssuePrecheckDone:!0}}),className:"mt-4 text-blue-600 dark:text-blue-400 hover:underline",children:e("issues.createFirstIssue")})]})})}):M.map(He=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 cursor-pointer transition-colors ${f.has(He.name)?"bg-blue-50 dark:bg-blue-900/20":""}`,onClick:()=>r(`/support/${He.name}`),children:[t.jsx("td",{className:"px-4 py-3",onClick:it=>it.stopPropagation(),children:t.jsx("button",{onClick:()=>Qe(He.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:f.has(He.name)?t.jsx(Ra,{className:"text-blue-600 dark:text-blue-400",size:18}):t.jsx(Ur,{size:18})})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-400",children:He.name})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:"text-sm text-gray-900 dark:text-white line-clamp-1",children:He.subject||"-"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${Roe(He.status)}`,children:He.status?e(`issues.status.${He.status.toLowerCase().replace(/\\s+/g,"_")}`,He.status):"-"})}),t.jsx("td",{className:"px-4 py-3",children:He.priority?t.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${Moe(He.priority)}`,children:e(`issues.priority.${He.priority.toLowerCase()}`,He.priority)}):t.jsx("span",{className:"text-gray-400",children:"-"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300 line-clamp-1",children:He.company||"-"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:Re(He.opening_date)})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-1",onClick:it=>it.stopPropagation(),children:[t.jsx("button",{onClick:()=>r(`/support/${He.name}`),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded transition-colors",title:e("issues.viewDetails"),children:t.jsx(Ps,{})}),t.jsx("button",{onClick:()=>r(`/support/${He.name}`),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:e("issues.editIssue"),children:t.jsx(qr,{})}),T&&Poe.includes((He.status||"").trim())&&t.jsx("button",{type:"button",onClick:()=>r(`/work-orders/new?from_issue=${encodeURIComponent(He.name)}`),className:"text-emerald-600 dark:text-emerald-400 hover:text-emerald-900 dark:hover:text-emerald-300 p-2 hover:bg-emerald-50 dark:hover:bg-emerald-900/30 rounded transition-colors",title:e("issues.createWorkOrderFromIssue"),children:t.jsx(Ju,{})}),t.jsx("button",{onClick:()=>N(He.name),className:"text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300 p-2 hover:bg-red-50 dark:hover:bg-red-900/30 rounded transition-colors",title:e("issues.deleteIssue"),children:t.jsx(wr,{})})]})})]},He.name))})]})}),t.jsx(_l,{currentPage:i,totalCount:le,pageSize:c,itemLabel:e("pagination.issues"),onPageChange:He=>o(He)})]}),S&&t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx("div",{className:"flex-shrink-0 w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:t.jsx(wr,{className:"text-red-600 dark:text-red-400 text-xl"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:e("issues.deleteIssue")}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:e("issues.deleteConfirmMessage")}),t.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-md p-3 mb-4",children:t.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[t.jsxs("strong",{children:[e("issues.issueId"),":"]})," ",S]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>N(null),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-lg transition-colors",children:e("common.cancel")}),t.jsxs("button",{onClick:()=>dt(S),className:"px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors flex items-center gap-2",children:[t.jsx(wr,{}),e("issues.deleteIssue")]})]})]})]})})}),t.jsx("style",{children:`
|
||
@keyframes scale-in { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
|
||
.animate-scale-in { animation: scale-in 0.2s ease-out; }
|
||
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }
|
||
.scrollbar-hide::-webkit-scrollbar { display: none; }
|
||
`})]})},di="auto=format&fit=crop&w=960&q=80",Foe=[{id:"hvac",label:"Air conditioning"},{id:"power",label:"Power & electrical"},{id:"building",label:"Building systems"},{id:"app",label:"Application & account"}],Ioe={power:[{imageSrc:`https://images.unsplash.com/photo-1621905251918-48416bd8575a?${di}`,imageCaption:"Panels, breakers, and protection devices",title:"Breakers, RCDs, and panels",intro:"Read the steps below. When you have actually tried them, use the button below to continue.",bullets:["Identify whether one circuit or a whole area is affected.","Check the correct panel for that space; reset a tripped breaker only once if policy allows, and note which label matches the room or equipment.","If an RCD/GFCI device has tripped, press reset after unplugging new or suspect equipment—if it trips again, leave it off and report."]},{imageSrc:`https://images.unsplash.com/photo-1558494949-ef010cbdcc31?${di}`,imageCaption:"UPS, server rooms, and facility power indicators",title:"Power at the source",intro:"Confirm whether the issue is local or upstream before opening a ticket.",bullets:["Check if neighbouring rooms or equipment on the same feed still have power.","Note any recent work, outages, or generator/UPS transfers communicated by facilities.","Do not open energized panels beyond your training; photograph labels only if safe to do so."]},{imageSrc:`https://images.unsplash.com/photo-1473341304170-971dccb5ac1e?${di}`,imageCaption:"Isolating equipment and electrical safety",title:"Equipment and safety",intro:"Reduce risk and capture details technicians will need.",bullets:["Turn off or isolate affected equipment only if your procedure allows it.","Unplug new or suspect devices from the affected circuit where policy permits.","Record exact location, panel name, breaker label, and what changed just before the fault."]},{imageSrc:`https://images.unsplash.com/photo-1504917595217-d4dc5ebe6122?${di}`,imageCaption:"Notes, photos, and details for your ticket",title:"Before you escalate",intro:"If the problem is still there after the checks above, gather this for your ticket.",bullets:["List what you tried and the outcome (including repeated trips or resets).","Note any burning smell, heat, noise, or visible damage—stop and report immediately if unsafe.","Use Support issues → New issue with photos and panel labels if your site allows attachments."]}],hvac:[{imageSrc:`https://images.unsplash.com/photo-1770625467384-304e461ef1be?${di}`,imageCaption:"Digital thermostat, mode, and setpoint",title:"Quick HVAC checks",intro:"Work through these before reporting poor cooling or airflow.",bullets:["Confirm the thermostat mode (cool/heat/fan), setpoint, and that it is not in override or schedule lock.","Check return air paths and vents—blocked grilles are a common cause of weak airflow.","If there is a local isolator or shutoff for the unit, verify it is on per site policy only."]},{imageSrc:`https://images.unsplash.com/photo-1585771724684-38269d6639fd?${di}`,imageCaption:"Outdoor unit, lines, and coil area",title:"Filters and coils",intro:"Restricted airflow often traces to maintenance items.",bullets:["Note the last filter change date; a clogged filter reduces airflow and can trip limits.","Look for ice on lines or coils—if present, stop forcing the system and report.","Do not remove safety covers unless you are authorized and trained."]},{imageSrc:`https://images.unsplash.com/photo-1765850262030-1ae93e474473?${di}`,imageCaption:"Ceiling units, alarms, and wet areas near equipment",title:"Noise, water, and alarms",intro:"Capture symptoms that help narrow the fault.",bullets:["Record unusual sounds (grinding, squealing) and when they started.","Check for water near the unit or drain pan overflow indicators.","Copy any fault code or BMS alarm text shown on the panel or screen."]},{imageSrc:`https://images.unsplash.com/photo-1497366216548-37526070297c?${di}`,imageCaption:"Notes, readings, and what to send with your issue",title:"Ready for a ticket",intro:"Include this in your issue for faster routing.",bullets:["Building, floor, room, and asset tag if available.","Whether the space is occupied, sensitive (e.g. clinical), or time-critical.","What you already tried and current thermostat readings if visible."]}],building:[{imageSrc:`https://images.unsplash.com/photo-1502672260266-1c1ef2d93688?${di}`,imageCaption:"Doors, circulation, and access points",title:"Access, doors, and security",intro:"Many building tickets start with access or environmental comfort.",bullets:["Confirm whether the problem is one door/zone or a wider access failure.","Check for obstructions, broken glass, or propped doors that affect sensors.","Note if card readers or intercoms show an error code or LED pattern."]},{imageSrc:`https://images.unsplash.com/photo-1600585154526-990dced4db0d?${di}`,imageCaption:"Fixtures, pipes, and visible water",title:"Water and leaks",intro:"Treat active leaks as urgent; safety comes first.",bullets:["If water is near electrics, keep clear and report immediately per your emergency process.","Identify the source if safe (ceiling, fixture, pipe chase) and contain with approved materials only.","Photograph the area from a safe distance if your policy allows."]},{imageSrc:`https://images.unsplash.com/photo-1558618666-fcd25c85cd64?${di}`,imageCaption:"Lighting, outlets, and local circuits",title:"Lighting and small power",intro:"Local checks before logging a facilities issue.",bullets:["Try adjacent switches; confirm the circuit is not isolated for maintenance.","For recurring trips, note which device or circuit label is involved.","Report flickering that affects a whole zone—it may indicate a loose neutral upstream."]},{imageSrc:`https://images.unsplash.com/photo-1497366754035-f200968a6e72?${di}`,imageCaption:"Location, timing, and operational impact",title:"Escalation details",intro:"Help the team respond on first visit.",bullets:["Exact location, time noticed, and whether it is getting worse.","Impact on operations, safety, or compliance.","Any recent construction, cleaning, or vendor work nearby."]}],app:[{imageSrc:`https://images.unsplash.com/photo-1460925895917-afdab827c52f?${di}`,imageCaption:"Browser, session, and refresh",title:"Browser and session",intro:"Most application issues are fixed with a few quick steps.",bullets:["Hard refresh the page (Ctrl+Shift+R or Cmd+Shift+R) or try another browser.","Sign out and sign back in; clear site data only if your IT policy allows it.","Disable conflicting extensions temporarily to rule out ad blockers or script blockers."]},{imageSrc:`https://images.unsplash.com/photo-1544197150-b99a580bb7a8?${di}`,imageCaption:"Wi‑Fi, mobile data, and VPN connectivity",title:"Network and VPN",intro:"Confirm connectivity before reporting an app outage.",bullets:["Check other internal sites or the corporate intranet load correctly.","If you use VPN, reconnect or try the flow off VPN if permitted.","Note exact error text, URL, and approximate time of failure."]},{imageSrc:`https://images.unsplash.com/photo-1563013544-824ae1b704d3?${di}`,imageCaption:"Accounts, roles, and access control",title:"Permissions and data",intro:"Some errors are role or data related.",bullets:["Confirm you are using the correct company/site profile if the app supports multiple.","Try the same action on another device to see if it is account-specific.","Screenshot the error banner or toast message (redact personal data)."]},{imageSrc:`https://images.unsplash.com/photo-1555066931-4365d14bab8c?${di}`,imageCaption:"Steps, screenshots, and environment details",title:"Handover to support",intro:"Open a ticket with enough context to reproduce.",bullets:["Steps you took, expected result, and actual result.","Browser name and version, device type, and whether others are affected.","Attach screenshots only if allowed by your data policy."]}]},tf=4,_k="w-full min-h-[52px] sm:min-h-[48px] flex items-center justify-center gap-2 py-3.5 px-4 rounded-2xl text-white text-sm font-semibold shadow-lg transition-all bg-gradient-to-r from-violet-600 via-purple-600 to-fuchsia-600 hover:from-violet-700 hover:via-purple-700 hover:to-fuchsia-700 active:scale-[0.99] focus:outline-none focus-visible:ring-2 focus-visible:ring-violet-400 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-gray-900",zoe=({variant:e})=>{var E;const r=hr(),[a,s]=p.useState("power"),[n,i]=p.useState(0),[o,l]=p.useState(!1),[c,u]=p.useState(!1),[h,f]=p.useState(""),y=Ioe[a],b=y[Math.min(n,y.length-1)],w=Math.min(n+1,tf),v=p.useCallback(R=>{r("/support/new",{replace:!0,state:se({newIssuePrecheckDone:!0},R)})},[r]),k=p.useCallback(R=>{s(R),i(0),l(!1),u(!1),f("")},[]),S=p.useCallback(()=>{if(n>=tf-1){if(e==="newIssue"){v({});return}l(!0);return}i(R=>Math.min(R+1,tf-1))},[n,e,v]),N=p.useCallback(()=>{u(!0),f("")},[]),C=p.useCallback(()=>{u(!1),f("")},[]),O=p.useCallback(()=>{const R=h.trim();if(!R){We.error("Please explain why you can't complete this step to continue.",{position:"top-right",autoClose:4e3});return}v({precheckCantCompleteReason:R})},[h,v]),T=p.useMemo(()=>Array.from({length:tf},(R,z)=>t.jsx("div",{className:z===n?"h-2 w-10 sm:w-12 rounded-full bg-gradient-to-r from-violet-600 to-fuchsia-500 transition-all shadow-sm":"h-2 w-2 rounded-full bg-gray-300/90 dark:bg-gray-600 transition-all","aria-hidden":!0},z)),[n]);return t.jsxs(t.Fragment,{children:[t.jsx($a,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:au}),t.jsxs("div",{className:"min-h-full w-full max-w-lg mx-auto px-4 sm:px-5 py-4 sm:py-6 pb-28 sm:pb-24 bg-gradient-to-br from-violet-100/90 via-white to-fuchsia-100/80 dark:from-gray-950 dark:via-gray-900 dark:to-violet-950/50",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-6 sm:mb-8",children:[t.jsx("button",{type:"button",onClick:()=>r("/support"),className:"text-violet-700/70 dark:text-violet-300/80 hover:text-violet-900 dark:hover:text-white p-2 -ml-2 rounded-xl min-h-[44px] min-w-[44px] flex items-center justify-center","aria-label":"Back to support issues",children:t.jsx(ia,{className:"text-lg"})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-lg sm:text-xl font-semibold text-gray-900 dark:text-white",children:e==="newIssue"?"New issue":"Support"}),t.jsx("p",{className:"text-xs text-violet-700/80 dark:text-violet-300/90",children:e==="newIssue"?"Self-service checks before you create a ticket":"Self-service checks"})]})]}),t.jsx("p",{className:"text-[10px] sm:text-[11px] font-semibold tracking-wide text-gray-500 dark:text-gray-400 uppercase mb-3",children:"What type of problem is it?"}),t.jsx("div",{className:"flex flex-wrap gap-2 mb-6 sm:mb-8",children:Foe.map(({id:R,label:z})=>t.jsx("button",{type:"button",onClick:()=>k(R),className:`px-3.5 sm:px-4 py-2.5 rounded-2xl text-xs sm:text-sm font-medium transition-all min-h-[44px] ${a===R?"text-white shadow-md bg-gradient-to-r from-violet-600 to-fuchsia-600 ring-2 ring-violet-400/40":"bg-white/80 dark:bg-gray-800/90 text-gray-700 dark:text-gray-200 border border-gray-200/80 dark:border-gray-600 hover:border-violet-300 dark:hover:border-violet-500"}`,children:z},R))}),o?t.jsxs("div",{className:"rounded-2xl border border-violet-200/60 dark:border-gray-700 bg-white/95 dark:bg-gray-800/95 shadow-lg p-6 text-center space-y-4",children:[t.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Thanks for working through the checks"}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:"If the problem is still there, create a ticket from the support issues page with what you tried."}),t.jsx("button",{type:"button",onClick:()=>r("/support"),className:`${_k} max-w-xs mx-auto`,children:"Go to support issues"})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[t.jsx("p",{className:"text-[10px] sm:text-[11px] font-semibold tracking-wide text-gray-500 dark:text-gray-400 uppercase",children:"Self-service checks"}),t.jsxs("p",{className:"text-sm font-semibold bg-gradient-to-r from-violet-600 to-fuchsia-600 bg-clip-text text-transparent",children:["Step ",w," of ",tf]})]}),t.jsx("div",{className:"flex justify-center gap-2 mb-5 sm:mb-6",children:T}),t.jsxs("div",{className:"rounded-2xl border border-violet-200/60 dark:border-gray-700 bg-white/95 dark:bg-gray-800/95 shadow-lg shadow-violet-500/5 overflow-hidden backdrop-blur-sm",children:[b.imageSrc?t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50",children:[t.jsx("img",{src:b.imageSrc,alt:(E=b.imageCaption)!=null?E:b.title,className:"w-full max-h-48 sm:max-h-56 object-cover",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",onError:R=>{R.currentTarget.style.display="none"}}),b.imageCaption?t.jsx("p",{className:"text-center text-xs text-gray-500 dark:text-gray-400 py-2 px-4",children:b.imageCaption}):null]}):null,t.jsxs("div",{className:"p-5 sm:p-6 space-y-4",children:[t.jsx("h2",{className:"text-lg sm:text-xl font-bold text-gray-900 dark:text-white leading-snug",children:b.title}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:b.intro}),t.jsx("div",{className:"rounded-xl bg-violet-50/80 dark:bg-gray-900/60 divide-y divide-violet-100 dark:divide-gray-700 border border-violet-100/80 dark:border-gray-700",children:b.bullets.map((R,z)=>t.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 p-4 leading-relaxed",children:R},z))}),t.jsxs("button",{type:"button",onClick:S,className:_k,children:[t.jsx("span",{className:"flex h-7 w-7 items-center justify-center rounded-full border-2 border-white/90 shrink-0",children:t.jsx(Oc,{className:"text-xs"})}),"Yes, I've tried this"]}),c?t.jsxs("div",{className:"rounded-xl border border-violet-200/90 dark:border-violet-700/60 bg-gradient-to-br from-violet-50/95 via-fuchsia-50/50 to-violet-100/70 dark:from-violet-950/45 dark:via-fuchsia-950/25 dark:to-violet-900/35 p-4 sm:p-5 space-y-3 shadow-md shadow-violet-500/10",role:"region","aria-label":"Reason you cannot complete this step",children:[t.jsx("p",{className:"text-sm font-bold text-gray-900 dark:text-violet-50 leading-snug",children:"Why can't you complete this step? (required to continue)"}),t.jsx("textarea",{value:h,onChange:R=>f(R.target.value),rows:4,placeholder:"e.g. No access to the panel, site policy, or missing tools…",className:"w-full rounded-lg border border-violet-200/90 dark:border-violet-700/70 bg-white dark:bg-gray-900 text-gray-900 dark:text-white text-sm p-3 min-h-[100px] resize-y focus:ring-2 focus:ring-violet-500 focus:border-violet-500 outline-none placeholder:text-gray-400 dark:placeholder:text-gray-500"}),t.jsx("button",{type:"button",onClick:O,className:_k,children:"Save explanation and continue"}),t.jsx("button",{type:"button",onClick:C,className:"w-full min-h-[44px] text-center text-sm font-medium text-violet-700 dark:text-violet-300 underline underline-offset-2 hover:text-violet-900 dark:hover:text-violet-200",children:"Back to checks"})]}):t.jsx("button",{type:"button",onClick:N,className:"w-full min-h-[48px] text-center text-sm font-medium text-violet-700 dark:text-violet-300 underline underline-offset-2 hover:text-violet-900 dark:hover:text-violet-200",children:"I can't complete these checks"})]})]})]}),e==="standalone"&&!c?t.jsxs("div",{className:"mt-8 rounded-2xl bg-white/70 dark:bg-gray-800/60 border border-violet-200/50 dark:border-gray-700 p-5 flex gap-3 shadow-sm",children:[t.jsx(Cv,{className:"text-violet-600 dark:text-violet-400 text-xl shrink-0 mt-0.5"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-gray-900 dark:text-white text-sm",children:"Still need help?"}),t.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-300 mt-1 leading-relaxed",children:["To open a ticket without this checklist, use"," ",t.jsx("button",{type:"button",onClick:()=>r("/support/new",{state:{newIssuePrecheckDone:!0}}),className:"font-medium text-violet-700 dark:text-violet-300 underline underline-offset-2 hover:text-violet-900",children:"Create ticket directly"})," ","on the"," ",t.jsx("button",{type:"button",onClick:()=>r("/support"),className:"text-violet-600 dark:text-violet-400 underline underline-offset-2",children:"support issues"})," ","page."]})]})]}):null]})]})},$oe=["Work Control","System Manager"],Uoe=["Open","Replied","On Hold"],Boe=()=>new Date().toISOString().split("T")[0],Woe=()=>new Date().toTimeString().split(" ")[0],Hoe=e=>{switch(e==null?void 0:e.toLowerCase()){case"open":return{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-800 dark:text-blue-300",border:"border-blue-200 dark:border-blue-800"};case"replied":return{bg:"bg-purple-100 dark:bg-purple-900/30",text:"text-purple-800 dark:text-purple-300",border:"border-purple-200 dark:border-purple-800"};case"on hold":return{bg:"bg-yellow-100 dark:bg-yellow-900/30",text:"text-yellow-800 dark:text-yellow-300",border:"border-yellow-200 dark:border-yellow-800"};case"resolved":return{bg:"bg-green-100 dark:bg-green-900/30",text:"text-green-800 dark:text-green-300",border:"border-green-200 dark:border-green-800"};case"closed":return{bg:"bg-gray-100 dark:bg-gray-700",text:"text-gray-800 dark:text-gray-300",border:"border-gray-200 dark:border-gray-600"};default:return{bg:"bg-gray-100 dark:bg-gray-700",text:"text-gray-800 dark:text-gray-300",border:"border-gray-200 dark:border-gray-600"}}},qoe=()=>{const{t:e}=sr(),{issueName:r}=hs(),a=hr(),s=mo(),[n]=_a(),i=r==="new",o=s.state||void 0,l=(o==null?void 0:o.newIssuePrecheckDone)===!0||n.get("skip_precheck")==="1",[c,u]=p.useState({subject:"",raised_by:"",status:"Open",priority:"",issue_type:"",description:"",contact:"",company:"",customer:"",project:"",resolution_details:"",opening_date:i?Boe():"",opening_time:i?Woe():"",first_responded_on:"",sla_resolution_date:"",sla_resolution_by:""}),{issue:h,loading:f,error:y,refetch:b}=Eoe(i?null:r||null),{createIssue:w,updateIssue:v,deleteIssue:k,loading:S}=Aoe(),[N,C]=p.useState(i),[O,T]=p.useState(!1),P=p.useRef(!1),[E,R]=p.useState([]);p.useEffect(()=>{J(null,null,function*(){try{const re=yield At.apiCall("/api/method/asset_lite.api.user_roles.get_user_roles");if(Array.isArray(re))R(re);else if(re&&typeof re=="object"&&"message"in re){const X=re.message;Array.isArray(X)&&R(X)}}catch(re){R([])}})},[]);const z=!i&&Uoe.includes(((h==null?void 0:h.status)||c.status||"").trim())&&$oe.some(U=>E.includes(U));p.useEffect(()=>{var re;if(!i||!l)return;const U=(re=o==null?void 0:o.precheckCantCompleteReason)==null?void 0:re.trim();!U||P.current||(P.current=!0,u(X=>je(se({},X),{description:`${X.description?`${X.description}
|
||
|
||
`:""}Could not complete self-service checks: ${U}`})))},[i,l,o==null?void 0:o.precheckCantCompleteReason]),p.useEffect(()=>{if(!r||i||!h||h.workflow_state||h.status!=="Open")return;let U=!1;return At.apiCall("/api/method/asset_lite.api.issue_api.normalize_issue_workflow_state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({issue_name:r})}).then(()=>{U||b()}).catch(()=>{}),()=>{U=!0}},[r,i,h==null?void 0:h.name,h==null?void 0:h.workflow_state,h==null?void 0:h.status,b]);const G=p.useMemo(()=>{var U,re,X,V,I,B;if(!(!h||i))return{status:c.status||h.status||"",subject:(re=(U=c.subject)!=null?U:h.subject)!=null?re:"",priority:(V=(X=c.priority)!=null?X:h.priority)!=null?V:"",company:(B=(I=c.company)!=null?I:h.company)!=null?B:""}},[h,i,c.status,c.subject,c.priority,c.company]);p.useEffect(()=>{h&&!i&&(u({subject:h.subject||"",raised_by:h.raised_by||"",status:h.status||"Open",priority:h.priority||"",issue_type:h.issue_type||"",description:h.description||"",contact:h.contact||"",company:h.company||"",customer:h.customer||"",project:h.project||"",resolution_details:h.resolution_details||"",opening_date:h.opening_date||"",opening_time:h.opening_time||"",first_responded_on:h.first_responded_on?h.first_responded_on.split(" ")[0]:"",sla_resolution_date:h.sla_resolution_date?h.sla_resolution_date.split(" ")[0]:"",sla_resolution_by:h.sla_resolution_by||""}),C(!1))},[h,i]);const ae=U=>{const{name:re,value:X}=U.target;u(V=>je(se({},V),{[re]:X}))},ee=()=>J(null,null,function*(){if(!c.subject){We.error("Please enter a subject",{position:"top-right",autoClose:4e3,icon:t.jsx(pr,{})});return}try{if(i){const U=yield w(c);try{yield At.apiCall("/api/method/asset_lite.api.issue_api.assign_issue_to_work_control",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({issue_name:U.name})})}catch(re){console.warn("Failed to auto-assign issue to Work Control:",re)}We.success("Issue created successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),a(`/support/${U.name}`)}else yield v(r,c),We.success("Issue updated successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),C(!1),b()}catch(U){const re=U instanceof Error?U.message:"Unknown error";We.error(`Failed to save: ${re}`,{position:"top-right",autoClose:6e3,icon:t.jsx(pr,{})})}}),ne=()=>J(null,null,function*(){try{yield k(r),We.success("Issue deleted successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),a(-1)}catch(U){const re=U instanceof Error?U.message:"Unknown error";We.error(`Failed to delete: ${re}`,{position:"top-right",autoClose:6e3,icon:t.jsx(pr,{})})}}),te=p.useCallback(U=>!!(!N||["opening_date","opening_time"].includes(U)&&!i),[N,i]),Y=U=>U?new Date(U).toLocaleString():"-";if(i&&!l)return t.jsx(zoe,{variant:"newIssue"});if(f)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading issue details..."})]})});if(y&&!i)return t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:"Error Loading Issue"}),t.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:y}),t.jsx("button",{onClick:()=>a(-1),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:"Back to Issues"})]})});const q=(h==null?void 0:h.status)||c.status||"Open",H=Hoe(q);return t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[t.jsx($a,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:au}),t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("button",{onClick:()=>a(-1),className:"text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200",children:t.jsx(ia,{size:20})}),t.jsxs("div",{children:[t.jsxs("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white flex items-center gap-3",children:[i?e("issues.newIssue"):(h==null?void 0:h.name)||e("issues.issueDetails"),!i&&t.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-medium ${H.bg} ${H.text} ${H.border} border`,children:q})]}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:i?e("issues.createNewIssue"):c.subject})]})]}),t.jsxs("div",{className:"flex gap-3 flex-wrap",children:[!i&&z&&r&&t.jsxs("button",{type:"button",onClick:()=>a(`/work-orders/new?from_issue=${encodeURIComponent(r)}`),className:"bg-emerald-600 hover:bg-emerald-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(Ju,{}),e("issues.createWorkOrderFromIssue")]}),!i&&!N&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>C(!0),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(qr,{}),e("common.edit")]}),t.jsxs("button",{onClick:()=>T(!0),className:"bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(wr,{}),e("common.delete")]})]}),N&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{i?a(-1):(C(!1),b())},className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg",children:e("common.cancel")}),t.jsxs("button",{onClick:ee,disabled:S,className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 disabled:opacity-50",children:[t.jsx(ta,{}),e(S?"common.saving":"common.save")]})]})]})]}),O&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl",children:[t.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[t.jsx(Or,{className:"text-red-500 text-xl mt-0.5"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:"Delete Issue"}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Are you sure you want to delete this issue? This action cannot be undone."})]})]}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>T(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",children:"Cancel"}),t.jsx("button",{onClick:ne,disabled:S,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg disabled:opacity-50",children:S?"Deleting...":"Delete"})]})]})}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[t.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(FG,{className:"text-blue-500"}),e("issues.issueDetails")]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[e("issues.subject")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",name:"subject",value:c.subject,onChange:ae,disabled:te("subject"),placeholder:e("issues.enterSubject"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("commonFields.status")}),t.jsxs("select",{name:"status",value:c.status,onChange:ae,disabled:te("status"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-500",children:[t.jsx("option",{value:"Open",children:"Open"}),t.jsx("option",{value:"Replied",children:"Replied"}),t.jsx("option",{value:"On Hold",children:"On Hold"}),t.jsx("option",{value:"Resolved",children:"Resolved"}),t.jsx("option",{value:"Closed",children:"Closed"})]})]}),t.jsx("div",{children:t.jsx(Je,{label:e("commonFields.priority"),doctype:"Issue Priority",value:c.priority||"",onChange:U=>u(je(se({},c),{priority:U})),disabled:te("priority"),placeholder:e("issues.selectPriority")})})]}),t.jsx("div",{children:t.jsx(Je,{label:e("issues.issueType"),doctype:"Issue Type",value:c.issue_type||"",onChange:U=>u(je(se({},c),{issue_type:U})),disabled:te("issue_type"),placeholder:e("issues.selectIssueType")})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("commonFields.description")}),t.jsx("textarea",{name:"description",value:c.description,onChange:ae,disabled:te("description"),placeholder:e("issues.describeIssue"),rows:5,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-500 resize-none"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(nn,{className:"text-green-500"}),e("issues.contactInformation")]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("issues.raisedBy")}),t.jsxs("div",{className:"relative",children:[t.jsx(G9,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"}),t.jsx("input",{type:"email",name:"raised_by",value:c.raised_by,onChange:ae,disabled:te("raised_by"),placeholder:e("common.email"),className:"w-full pl-10 pr-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-500"})]})]}),t.jsx("div",{children:t.jsx(Je,{label:e("commonFields.company"),doctype:"Company",value:c.company||"",onChange:U=>u(je(se({},c),{company:U})),disabled:te("company"),placeholder:e("issues.selectCompany")})})]})]}),!i&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(Qt,{className:"text-purple-500"}),e("issues.resolution")]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("issues.firstRespondedOn")}),t.jsx("input",{type:"date",name:"first_responded_on",value:c.first_responded_on||"",onChange:ae,disabled:te("first_responded_on"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("issues.resolutionDate")}),t.jsx("input",{type:"date",name:"sla_resolution_date",value:c.sla_resolution_date||"",onChange:ae,disabled:te("sla_resolution_date"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-500"})]})]}),t.jsx("div",{children:t.jsx(Je,{label:e("issues.resolvedBy"),doctype:"User",value:c.sla_resolution_by||"",onChange:U=>u(je(se({},c),{sla_resolution_by:U})),disabled:te("sla_resolution_by"),placeholder:e("maintenance.selectUser")})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("issues.resolutionDetails")}),t.jsx("textarea",{name:"resolution_details",value:c.resolution_details,onChange:ae,disabled:te("resolution_details"),placeholder:e("issues.describeResolution"),rows:4,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-500 resize-none"})]})]})]}),!i&&t.jsx(Bm,{referenceDoctype:"Issue",referenceName:r||null,title:"Comments & Discussion",pollInterval:3e4,initialLimit:5,collapsible:!0,startCollapsed:!1})]}),t.jsxs("div",{className:"space-y-6",children:[!i&&r&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:e("issues.workflowActions")}),t.jsx(Ix,{doctype:"Issue",docname:r,workflowState:(h==null?void 0:h.workflow_state)||void 0,docData:G,onStateChange:()=>b(),documentLabel:e("issues.issueSingular"),stateHeading:e("workOrders.detail.currentState"),showFullAccessNote:!0})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(GG,{className:"text-orange-500"}),e("issues.statusInformation")]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:`p-4 rounded-lg border ${H.bg} ${H.border}`,children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:e("issues.currentStatus")}),t.jsx("p",{className:`text-xl font-semibold ${H.text}`,children:q})]}),c.priority&&t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:e("commonFields.priority")}),t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:c.priority})]}),c.issue_type&&t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:e("issues.issueType")}),t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:c.issue_type})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(rc,{className:"text-teal-500"}),e("issues.timeline")]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:e("issues.openingDate")}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:c.opening_date||"-"})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Opening Time"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:c.opening_time||"-"})]}),!i&&h&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Created"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:Y(h.creation)})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Last Modified"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:Y(h.modified)})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Modified By"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:h.modified_by||"-"})]})]})]})]}),c.company&&!i&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(K4,{className:"text-indigo-500"}),"Company"]}),t.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:c.company})})]})]})]})]})},Pa="auto=format&fit=crop&w=960&q=80",Voe={air_conditioning:[`https://images.unsplash.com/photo-1770625467384-304e461ef1be?${Pa}`,`https://images.unsplash.com/photo-1590620284812-3216c0ea0a75?${Pa}`,`https://images.unsplash.com/photo-1600607687939-ce8a6c25118c?${Pa}`,`https://images.unsplash.com/photo-1504917595217-d4dc5ebe6122?${Pa}`,`https://images.unsplash.com/photo-1770816306659-adcf99a11aeb?${Pa}`,`https://images.unsplash.com/photo-1585771724684-38269d6639fd?${Pa}`],power:[`https://images.unsplash.com/photo-1621905251918-48416bd8575a?${Pa}`,`https://images.unsplash.com/photo-1558618666-fcd25c85cd64?${Pa}`,`https://images.unsplash.com/photo-1558494949-ef010cbdcc31?${Pa}`,`https://images.unsplash.com/photo-1473341304170-971dccb5ac1e?${Pa}`,`https://images.unsplash.com/photo-1504917595217-d4dc5ebe6122?${Pa}`,`https://images.unsplash.com/photo-1621905251918-48416bd8575a?${Pa}`],building_systems:[`https://images.unsplash.com/photo-1600585154526-990dced4db0d?${Pa}`,`https://images.unsplash.com/photo-1502672260266-1c1ef2d93688?${Pa}`,`https://images.unsplash.com/photo-1556911220-e15b29be8c8f?${Pa}`,`https://images.unsplash.com/photo-1691465576659-938b08b99959?${Pa}`,`https://images.unsplash.com/photo-1556742049-0cfed4f6a45d?${Pa}`,`https://images.unsplash.com/photo-1497366754035-f200968a6e72?${Pa}`],applications_account:[`https://images.unsplash.com/photo-1460925895917-afdab827c52f?${Pa}`,`https://images.unsplash.com/photo-1544197150-b99a580bb7a8?${Pa}`,`https://images.unsplash.com/photo-1563013544-824ae1b704d3?${Pa}`,`https://images.unsplash.com/photo-1517694712202-14dd9538aa97?${Pa}`,`https://images.unsplash.com/photo-1555066931-4365d14bab8c?${Pa}`,`https://images.unsplash.com/photo-1544197150-b99a580bb7a8?${Pa}`],ultrasound:[`https://images.unsplash.com/photo-1565049981953-379c9c2a5d48?${Pa}`,`https://images.unsplash.com/photo-1691933880037-ce9d151ab922?${Pa}`,`https://images.unsplash.com/photo-1624004015322-a94d3a4eff39?${Pa}`,`https://images.unsplash.com/photo-1667264501379-c1537934c7ab?${Pa}`,`https://images.unsplash.com/flagged/photo-1560854350-13c0b47a3180?${Pa}`,`https://images.unsplash.com/photo-1521791136064-7986c2920216?${Pa}`,`https://images.unsplash.com/photo-1691435828932-911a7801adfb?${Pa}`,`https://images.unsplash.com/photo-1578016980868-197203ff4b02?${Pa}`]};function Goe(e,r){const a=Voe[e];if(!(!a||!a.length||r<0))return a[Math.min(r,a.length-1)]}const Koe=[{id:"boot",label:"System does not Power On / Boot Up",icon:"⚡",symptom:"Won't power on",startId:"q1",nodes:{q1:{type:"question",id:"q1",ref:"7-7-1",question:"Is the scanner plugged into a wall outlet?",yes:"q2",no:"a_plug"},a_plug:{type:"action",id:"a_plug",ref:"7-7-1",variant:"fix",title:"Plug in the scanner",body:"Make sure the scanner is plugged into a standard wall outlet. Do NOT use a red emergency power outlet."},q2:{type:"question",id:"q2",ref:"7-7-1",question:"Is there AC voltage at the wall outlet and is the circuit breaker ON?",yes:"q3",no:"a_power"},a_power:{type:"action",id:"a_power",ref:"7-7-1",variant:"escalate",title:"No mains power detected",body:"Check the circuit breaker and confirm mains supply. If the breaker is tripped, reset it. If AC is still absent, contact facilities — this is a building power issue."},q3:{type:"question",id:"q3",ref:"7-7-1",question:"Is there fan noise within a few seconds of pressing the ON/OFF switch?",yes:"a_ready",no:"a_no_fan"},a_ready:{type:"action",id:"a_ready",ref:"7-7-1",variant:"fix",title:"System is booting normally",body:"Fan noise confirms the Primary Power Supply is working. Wait for the system to fully boot. The ON/OFF button should illuminate amber (standby) then green (ready)."},a_no_fan:{type:"action",id:"a_no_fan",ref:"7-7-1",variant:"escalate",title:"Primary Power Supply suspect",body:`No fan noise indicates the Primary Power Supply (CPN) may be faulty.
|
||
• Check the power switch above the mains plug on the CPN — ensure it is ON.
|
||
• Check all connections to and from the Power Supply.
|
||
• Check the cable from the Power Supply to the GEF module (see Section 7-3 for voltage check points).
|
||
• If connections are OK but still no power, replace the Primary Power Supply. Contact your dealer.`}}},{id:"noise",label:"Noise in Image",icon:"📡",symptom:"Image noise / artefacts",startId:"q1",nodes:{q1:{type:"question",id:"q1",ref:"7-7-2",question:"Are there any electrical devices near the scanner (monitors, phones, other medical equipment)?",yes:"a_move",no:"a_probe"},a_move:{type:"action",id:"a_move",ref:"7-7-2",variant:"fix",title:"Remove interfering electrical devices",body:"Keep the scanner away from devices that may cause electromagnetic interference. Try a different wall socket on a separate circuit. Re-test image quality after moving the device."},a_probe:{type:"action",id:"a_probe",ref:"7-7-2",variant:"fix",title:"Check the probe / transducer",body:`No obvious nearby interference detected. Inspect the probe:
|
||
• Check the probe cable for kinks or damage.
|
||
• Try a different probe connector port.
|
||
• If noise persists with all probes, contact your dealer — possible GEF board issue.`}}},{id:"trackball",label:"Trackball Low Sensitivity",icon:"🖱️",symptom:"Trackball not working",startId:"q1",nodes:{q1:{type:"question",id:"q1",ref:"7-7-3",question:"Does the trackball move at all when rolled?",yes:"a_clean",no:"a_replace"},a_clean:{type:"action",id:"a_clean",ref:"7-7-3",variant:"fix",title:"Clean the trackball",body:`The ball moves but is sluggish — it needs cleaning.
|
||
• Remove the ball from the trackball housing.
|
||
• Clean the ball and the internal rollers with a dry lint-free cloth.
|
||
• Reinsert and test sensitivity.`},a_replace:{type:"action",id:"a_replace",ref:"7-7-3",variant:"escalate",title:"Replace the trackball unit",body:`The trackball does not respond at all — the unit is likely faulty.
|
||
• Replacement part: KTZ208256 (Trackball top fixation ring, Section 8-4).
|
||
• Contact your dealer for unit replacement if not in stock.`}}},{id:"shutdown",label:"System does not Power Off / Shutdown",icon:"🔴",symptom:"Won't shut down",startId:"q1",nodes:{q1:{type:"question",id:"q1",ref:"7-7-4",question:"After pressing the OFF button, does the system start the shutdown procedure at all?",yes:"q2",no:"a_switch"},a_switch:{type:"action",id:"a_switch",ref:"7-7-4",variant:"escalate",title:"Check ON/OFF switch and cable",body:`The shutdown procedure does not start — the ON/OFF switch or its cable may be faulty.
|
||
• Inspect the switch cable.
|
||
• If the cable is OK, the Primary Power Supply (CPN) is likely defective.
|
||
• Contact your dealer.`},q2:{type:"question",id:"q2",ref:"7-7-4",question:"Does the system eventually power off automatically (within ~3 minutes)?",yes:"a_normal",no:"a_cpn"},a_normal:{type:"action",id:"a_normal",ref:"7-7-4",variant:"fix",title:"Shutdown is working normally",body:"The system shuts down automatically after approximately 3 minutes as designed. This is normal behaviour — the OS completes its shutdown sequence before cutting power."},a_cpn:{type:"action",id:"a_cpn",ref:"7-7-4",variant:"escalate",title:"Primary Power Supply (CPN) defective",body:`The system starts shutdown but never fully powers off — the CPN is likely defective.
|
||
• Contact your dealer for CPN replacement.`}}},{id:"monitor",label:"Monitor Troubleshooting",icon:"🖥️",symptom:"Monitor / display issue",startId:"q1",nodes:{q1:{type:"question",id:"q1",ref:"7-7-5",question:"Is there any image at all on the monitor (even partial or distorted)?",yes:"q2",no:"a_no_image"},a_no_image:{type:"action",id:"a_no_image",ref:"7-7-5",variant:"fix",title:"No image — check power and cables",body:`Check these items in order:
|
||
• Power cord is properly connected to the monitor and wall.
|
||
• Mains supply switch is set to ON.
|
||
• Video cable is properly connected — no bent pins.
|
||
• If the Power Saving indicator is lit, the monitor is in sleep mode — move the mouse or press a key.
|
||
• If Power indicator flashes alternately green and orange: potential monitor failure — contact your dealer.`},q2:{type:"question",id:"q2",ref:"7-7-5",question:"Is the image fuzzy or the colour non-uniform?",yes:"a_fuzzy",no:"a_position"},a_fuzzy:{type:"action",id:"a_fuzzy",ref:"7-7-5",variant:"fix",title:"Fuzzy image or colour issues",body:`• Turn monitor off then on to activate Auto-Degauss (fixes colour non-uniformity).
|
||
• Adjust contrast and brightness settings.
|
||
• Check that no extra video cable is connected to the second video output with the other end loose — this increases video output level and causes fuzz.
|
||
• If problem persists after adjustments, contact your dealer.`},a_position:{type:"action",id:"a_position",ref:"7-7-5",variant:"fix",title:"Image not centred or sized correctly",body:"Adjust picture location, picture size, picture rotation, or pincushion distortion via the monitor's on-screen menu. Some video modes do not fill the screen to the edge — this is normal at higher refresh rates."}}},{id:"printer",label:"Printer Troubleshooting",icon:"🖨️",symptom:"Printer not working",startId:"q1",nodes:{q1:{type:"question",id:"q1",ref:"7-7-7",question:"Is the printer properly connected (signal and power cables secured at both ends)?",yes:"q2",no:"a_cables"},a_cables:{type:"action",id:"a_cables",ref:"7-7-7",variant:"fix",title:"Reconnect printer cables",body:"Check all signal and power supply cable connections between the printer and the scanner. Reseat all connectors firmly. Power-cycle the printer after reconnecting."},q2:{type:"question",id:"q2",ref:"7-7-7",question:"Is there paper/film loaded in the printer?",yes:"q3",no:"a_paper"},a_paper:{type:"action",id:"a_paper",ref:"7-7-7",variant:"fix",title:"Load printer paper / film",body:"Insert the correct printer paper or thermal film. Ensure it is loaded in the correct orientation. Close the paper tray firmly."},q3:{type:"question",id:"q3",ref:"7-7-7",question:"Is the Print key correctly configured in the system settings?",yes:"q4",no:"a_config"},a_config:{type:"action",id:"a_config",ref:"7-7-7",variant:"fix",title:"Configure the Print key",body:"Go to System Setup → Peripherals and configure the Print key(s) to point to the correct printer. Save the configuration and retry printing."},q4:{type:"question",id:"q4",ref:"7-7-7",question:"Is printing unavailable even by manual operation on the printer itself?",yes:"a_gef_cables",no:"q5"},a_gef_cables:{type:"action",id:"a_gef_cables",ref:"7-7-7",variant:"escalate",title:"Check GEF to backpanel signal cables",body:"Check the signal cables between the GEF board and the Back Panel. If connections are OK, the printer unit may need replacement — contact your dealer."},q5:{type:"question",id:"q5",ref:"7-7-7",question:"Is there still no image on the printout?",yes:"a_video_out",no:"a_printer_ok"},a_printer_ok:{type:"action",id:"a_printer_ok",ref:"7-7-7",variant:"fix",title:"Printer is OK",body:"The printer is functioning correctly. The issue was likely a temporary communication error. Monitor for recurrence."},a_video_out:{type:"action",id:"a_video_out",ref:"7-7-7",variant:"escalate",title:"Check video output / replace CKV",body:`No image on printout despite printer responding:
|
||
• Test video output from the system.
|
||
• If video output is faulty → Replace CKV board.
|
||
• If video output is OK → Replace the printer unit.
|
||
• Contact your dealer for board/unit replacement.`}}},{id:"network",label:"Network — No Connection",icon:"🌐",symptom:"No network connection",startId:"q1",nodes:{q1:{type:"question",id:"q1",ref:"7-7-10",question:"Is the network cable connected at both ends — scanner and wall socket?",yes:"q2",no:"a_cable"},a_cable:{type:"action",id:"a_cable",ref:"7-7-10",variant:"fix",title:"Reconnect the network cable",body:"Plug the network cable firmly into both the scanner's network port and the wall network socket. Ensure the clip locks in place at both ends."},q2:{type:"question",id:"q2",ref:"7-7-10",question:"Does replacing the cable with a known-good cable restore the connection?",yes:"a_bad_cable",no:"q3"},a_bad_cable:{type:"action",id:"a_bad_cable",ref:"7-7-10",variant:"fix",title:"Faulty cable — replace it",body:"The original cable was faulty. Replace it with the known-good cable permanently. Label and dispose of the faulty cable."},q3:{type:"question",id:"q3",ref:"7-7-10",question:"Can you ping from the scanner to a PC on the same network?",yes:"a_soft",no:"a_internal"},a_soft:{type:"action",id:"a_soft",ref:"7-7-10",variant:"fix",title:"Hardware OK — check network settings",body:`Ping is successful, so the hardware path inside the scanner is working. The issue is likely:
|
||
• Wrong IP address or subnet configured on the scanner.
|
||
• VLAN or firewall blocking DICOM traffic.
|
||
• Contact your IT/network team to verify the scanner's network configuration.`},a_internal:{type:"action",id:"a_internal",ref:"7-7-10",variant:"escalate",title:"Internal cable — check LAN connector",body:`No ping response indicates a hardware problem inside the scanner.
|
||
• Check the cable between the network connector on the Back Panel and the LAN connector on the GEF board.
|
||
• If the internal cable is OK, the GEF board's network interface may be faulty.
|
||
• Contact your dealer.`}}},{id:"vcr",label:"Unable to Record to VCR",icon:"📼",symptom:"Cannot record to VCR",startId:"q1",nodes:{q1:{type:"question",id:"q1",ref:"7-7-6",question:"Is the VCR properly connected (all signal and power cables secured)?",yes:"q2",no:"a_cables"},a_cables:{type:"action",id:"a_cables",ref:"7-7-6",variant:"fix",title:"Reconnect VCR cables",body:"Check all signal and power supply cable connections to the VCR unit. Reseat all connectors firmly at both ends. Power-cycle the VCR after reconnecting."},q2:{type:"question",id:"q2",ref:"7-7-6",question:"Is a tape inserted and rewound in the VCR?",yes:"q3",no:"a_tape"},a_tape:{type:"action",id:"a_tape",ref:"7-7-6",variant:"fix",title:"Insert and rewind the tape",body:"Put the VCR tape into the device and rewind it to the beginning before attempting to record."},q3:{type:"question",id:"q3",ref:"7-7-6",question:"Is recording impossible even by manual operation on the VCR itself?",yes:"q4",no:"a_signal_cables"},a_signal_cables:{type:"action",id:"a_signal_cables",ref:"7-7-6",variant:"fix",title:"Check signal cables between VCR and Internal I/O",body:"The VCR works manually but not from the scanner — check the signal cable connections between the VCR and the Internal I/O board. Reseat all connectors."},q4:{type:"question",id:"q4",ref:"7-7-6",question:"Is the video output of the system working correctly?",yes:"a_replace_vcr",no:"a_replace_ckv"},a_replace_vcr:{type:"action",id:"a_replace_vcr",ref:"7-7-6",variant:"escalate",title:"Replace the VCR unit",body:`The system video output is OK but the VCR still will not record — the VCR unit is faulty.
|
||
• Contact your dealer for VCR unit replacement.`},a_replace_ckv:{type:"action",id:"a_replace_ckv",ref:"7-7-6",variant:"escalate",title:"Replace the CKV board",body:`The system video output is faulty — the CKV board needs replacement.
|
||
• Contact your dealer for CKV board replacement.`}}},{id:"cdrw",label:"CD-RW Troubleshooting",icon:"💿",symptom:"CD-RW drive issue",startId:"c1",nodes:{c1:{type:"checklist",id:"c1",ref:"7-7-7-1",title:"CD-RW Backup Procedure",steps:["Insert an empty CD-RW disc into the drive.","Press the NETWORK key on the control panel to enter Sonoview.",'Click the "Open" icon to display the list of exams.',"Select the exam(s) you want to back up.",'Choose "CD-ROM" as the destination drive.',"Verify the backed-up images are visible on the CD-ROM after the process completes."]}}},{id:"mod",label:"MOD (MO Disk) Troubleshooting",icon:"💾",symptom:"MO disk drive issue",startId:"c1",nodes:{c1:{type:"checklist",id:"c1",ref:"7-7-8",title:"MOD Backup Procedure",steps:["Insert an empty MO disk into the drive.","Press the NETWORK key on the control panel to enter Sonoview.",'Click the "Open" icon to display the list of exams.',"Select the exam(s) you want to back up.",'Choose "MO" as the destination drive.',"Verify the backed-up images are visible on the MO disk after the process completes."]}}},{id:"audio",label:"Audio Test",icon:"🔊",symptom:"Audio / speaker issue",startId:"c1",nodes:{c1:{type:"checklist",id:"c1",ref:"7-7-9",title:"Loudspeaker Audio Test",steps:["Start a probe on the scanner.","Select PW-Mode (Pulsed Wave Doppler).","Locate the volume digipot on the control panel.","Slowly increase the volume from 0 to 96 dB.","Listen to both loudspeakers — both should produce clear audio at each volume level.","If one or both speakers produce no sound or distorted sound, contact your dealer."]}}}],Yoe=({onComplete:e})=>{const[r,a]=p.useState(null),[s,n]=p.useState(""),[i,o]=p.useState([]),l=p.useCallback(T=>{a(T),n(T.startId),o([])},[]),c=p.useCallback(T=>{if(!r)return;const P=r.nodes[s];P.type==="question"&&(o(E=>[...E,{nodeId:s,answer:T}]),n(T==="yes"?P.yes:P.no))},[r,s]),u=p.useCallback(()=>{if(!i.length){a(null),n(""),o([]);return}const T=i[i.length-1];n(T.nodeId),o(P=>P.slice(0,-1))},[i]),h=p.useCallback(()=>{r&&(n(r.startId),o([]))},[r]),f=p.useCallback(()=>{a(null),n(""),o([])},[]),y=r?r.nodes[s]:null,b=(y==null?void 0:y.type)==="action";gr.useEffect(()=>{b&&r&&(y==null?void 0:y.type)==="action"&&(e==null||e(r.id,y))},[b,r,y,e]);const w=i.map(T=>{if(!r)return null;const P=r.nodes[T.nodeId];return P.type!=="question"?null:{question:P.question,answer:T.answer}}).filter(Boolean),v="bg-gradient-to-r from-blue-500 to-teal-600",k="flex-1 min-h-[52px] flex items-center justify-center gap-2 py-3 px-4 rounded-2xl text-white text-sm font-semibold shadow-md transition-all active:scale-[0.98] focus:outline-none focus-visible:ring-2 focus-visible:ring-teal-400 focus-visible:ring-offset-2 bg-gradient-to-r from-teal-500 to-green-500 hover:from-teal-600 hover:to-green-600",S="flex-1 min-h-[52px] flex items-center justify-center gap-2 py-3 px-4 rounded-2xl text-white text-sm font-semibold shadow-md transition-all active:scale-[0.98] focus:outline-none focus-visible:ring-2 focus-visible:ring-red-400 focus-visible:ring-offset-2 bg-gradient-to-r from-red-500 to-orange-500 hover:from-red-600 hover:to-orange-600",N="flex items-center gap-1.5 text-sm font-medium text-blue-700 dark:text-teal-300 hover:text-blue-900 dark:hover:text-white transition-colors min-h-[44px] px-1",C="flex items-center gap-1.5 text-sm font-medium text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors min-h-[44px] px-1",O=T=>T==="fix"?{bg:"bg-green-50 dark:bg-green-900/20",border:"border-green-200 dark:border-green-800",icon:t.jsx(Qt,{className:"text-green-500 text-xl shrink-0 mt-0.5"}),badge:"bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300",badgeLabel:"Self-fix action"}:T==="escalate"?{bg:"bg-amber-50 dark:bg-amber-900/20",border:"border-amber-200 dark:border-amber-800",icon:t.jsx(WG,{className:"text-amber-500 text-xl shrink-0 mt-0.5"}),badge:"bg-amber-100 dark:bg-amber-900/40 text-amber-700 dark:text-amber-300",badgeLabel:"Contact your dealer"}:{bg:"bg-blue-50 dark:bg-blue-900/20",border:"border-blue-200 dark:border-blue-800",icon:t.jsx(Or,{className:"text-blue-500 text-xl shrink-0 mt-0.5"}),badge:"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300",badgeLabel:"Information"};return r?y?t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("button",{type:"button",onClick:u,className:N,children:[t.jsx(ia,{className:"text-sm"}),i.length===0?"All problems":"Back"]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{type:"button",onClick:f,className:C,title:"Back to problem list",children:t.jsx(sk,{className:"text-sm"})}),i.length>0&&t.jsx("button",{type:"button",onClick:h,className:C,title:"Restart this flowchart",children:t.jsx(fE,{className:"text-sm"})})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-base",children:r.icon}),t.jsx("span",{className:`text-xs font-semibold px-2.5 py-1 rounded-full text-white ${v}`,children:y.ref}),t.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:r.symptom})]}),w.length>0&&t.jsx("div",{className:"flex flex-col gap-1 px-3 py-2.5 rounded-xl bg-gray-50 dark:bg-gray-900/50 border border-gray-100 dark:border-gray-700",children:w.map((T,P)=>t.jsxs("div",{className:"flex items-start gap-2 text-xs text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:`shrink-0 font-bold mt-0.5 ${T.answer==="yes"?"text-green-600 dark:text-green-400":"text-red-500 dark:text-red-400"}`,children:T.answer==="yes"?"YES":"NO "}),t.jsx("span",{className:"leading-relaxed line-clamp-2",children:T.question})]},P))}),y.type==="question"&&t.jsxs("div",{className:"rounded-2xl border border-blue-200/60 dark:border-gray-700 bg-white/95 dark:bg-gray-800/95 shadow-lg shadow-blue-500/5 overflow-hidden",children:[t.jsx("div",{className:`h-1.5 w-full ${v}`}),t.jsxs("div",{className:"p-5 sm:p-6 space-y-5",children:[t.jsxs("p",{className:"text-[10px] font-semibold tracking-widest text-gray-400 dark:text-gray-500 uppercase",children:["Step ",i.length+1]}),t.jsx("h3",{className:"text-base sm:text-lg font-bold text-gray-900 dark:text-white leading-snug",children:y.question}),t.jsxs("div",{className:"flex gap-3 pt-1",children:[t.jsxs("button",{type:"button",onClick:()=>c("yes"),className:k,children:[t.jsx("span",{className:"text-lg",children:"✓"}),"YES"]}),t.jsxs("button",{type:"button",onClick:()=>c("no"),className:S,children:[t.jsx("span",{className:"text-lg",children:"✗"}),"NO"]})]})]})]}),y.type==="action"&&(()=>{const T=O(y.variant);return t.jsx("div",{className:`rounded-2xl border ${T.border} ${T.bg} overflow-hidden shadow-md`,children:t.jsxs("div",{className:"p-5 sm:p-6 space-y-4",children:[t.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs font-semibold px-2.5 py-1 rounded-full ${T.badge}`,children:[T.icon,T.badgeLabel]}),t.jsx("h3",{className:"text-base sm:text-lg font-bold text-gray-900 dark:text-white leading-snug",children:y.title}),t.jsx("div",{className:"rounded-xl bg-white/70 dark:bg-gray-900/40 border border-white/80 dark:border-gray-700 p-4",children:y.body.split(`
|
||
`).map((P,E)=>t.jsx("p",{className:`text-sm text-gray-700 dark:text-gray-300 leading-relaxed ${E>0&&P.startsWith("•")?"mt-1.5":E>0?"mt-2":""}`,children:P},E))}),t.jsxs("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:["GE Voluson 730 Service Manual · Section ",y.ref]}),t.jsxs("div",{className:"flex gap-3 pt-1",children:[t.jsxs("button",{type:"button",onClick:h,className:"flex-1 min-h-[48px] flex items-center justify-center gap-2 py-3 px-4 rounded-2xl text-sm font-semibold border-2 border-blue-300/80 dark:border-teal-700/60 text-blue-700 dark:text-teal-300 bg-white/80 dark:bg-gray-800/80 hover:bg-blue-50 dark:hover:bg-teal-950/30 transition-all active:scale-[0.98]",children:[t.jsx(fE,{className:"text-xs"}),"Restart flow"]}),t.jsxs("button",{type:"button",onClick:f,className:"flex-1 min-h-[48px] flex items-center justify-center gap-2 py-3 px-4 rounded-2xl text-sm font-semibold border-2 border-gray-200 dark:border-gray-600 text-gray-600 dark:text-gray-300 bg-white/80 dark:bg-gray-800/80 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-all active:scale-[0.98]",children:[t.jsx(sk,{className:"text-xs"}),"All problems"]})]})]})})})(),y.type==="checklist"&&t.jsxs("div",{className:"rounded-2xl border border-teal-200/60 dark:border-gray-700 bg-white/95 dark:bg-gray-800/95 shadow-lg overflow-hidden",children:[t.jsx("div",{className:`h-1.5 w-full ${v}`}),t.jsxs("div",{className:"p-5 sm:p-6 space-y-4",children:[t.jsx("span",{className:"inline-flex items-center gap-1.5 text-xs font-semibold px-2.5 py-1 rounded-full bg-teal-100 dark:bg-teal-900/40 text-teal-700 dark:text-teal-300",children:"📋 Step-by-step procedure"}),t.jsx("h3",{className:"text-base sm:text-lg font-bold text-gray-900 dark:text-white leading-snug",children:y.title}),t.jsx("div",{className:"rounded-xl bg-gray-50 dark:bg-gray-900/50 border border-gray-100 dark:border-gray-700 divide-y divide-gray-100 dark:divide-gray-700",children:y.steps.map((T,P)=>t.jsxs("div",{className:"flex items-start gap-3 p-3.5",children:[t.jsx("span",{className:`shrink-0 w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold text-white mt-0.5 ${v}`,children:P+1}),t.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 leading-relaxed",children:T})]},P))}),t.jsxs("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:["GE Voluson 730 Service Manual · Section ",y.ref]}),t.jsx("div",{className:"flex gap-3 pt-1",children:t.jsxs("button",{type:"button",onClick:f,className:"flex-1 min-h-[48px] flex items-center justify-center gap-2 py-3 px-4 rounded-2xl text-sm font-semibold border-2 border-gray-200 dark:border-gray-600 text-gray-600 dark:text-gray-300 bg-white/80 dark:bg-gray-800/80 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-all active:scale-[0.98]",children:[t.jsx(sk,{className:"text-xs"}),"All problems"]})})]})]})]}):null:t.jsxs("div",{className:"space-y-4",children:[t.jsx("p",{className:"text-[10px] sm:text-[11px] font-semibold tracking-wide text-gray-500 dark:text-gray-400 uppercase",children:"Select a problem type"}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:gap-3",children:Koe.map(T=>t.jsxs("button",{type:"button",onClick:()=>l(T),className:"w-full flex items-center gap-3 px-4 py-3.5 rounded-2xl text-left text-sm font-medium transition-all min-h-[56px] bg-white/80 dark:bg-gray-800/90 border border-blue-100 dark:border-gray-700 hover:border-teal-400 dark:hover:border-teal-500 hover:bg-blue-50/60 dark:hover:bg-teal-950/30 active:scale-[0.99] shadow-sm group",children:[t.jsx("span",{className:"text-xl shrink-0 w-7 text-center",children:T.icon}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("span",{className:"block text-gray-800 dark:text-gray-100 font-semibold text-sm leading-snug group-hover:text-teal-700 dark:group-hover:text-teal-300 transition-colors",children:T.symptom})}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600 group-hover:text-teal-400 transition-colors text-lg",children:"›"})]},T.id))})]})},kk="w-full min-h-[52px] sm:min-h-[48px] flex items-center justify-center gap-2 py-3.5 px-4 rounded-2xl text-white text-sm font-semibold shadow-lg transition-all bg-gradient-to-r from-violet-600 via-purple-600 to-fuchsia-600 hover:from-violet-700 hover:via-purple-700 hover:to-fuchsia-700 active:scale-[0.99] focus:outline-none focus-visible:ring-2 focus-visible:ring-violet-400 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-gray-900 disabled:opacity-60 disabled:pointer-events-none",L7="w-full min-h-[52px] sm:min-h-[48px] flex items-center justify-center gap-2 py-3.5 px-4 rounded-2xl text-sm font-semibold border-2 border-violet-300/90 dark:border-violet-600/80 text-violet-800 dark:text-violet-200 bg-white/90 dark:bg-gray-800/90 hover:bg-violet-50/90 dark:hover:bg-violet-950/50 active:scale-[0.99] focus:outline-none focus-visible:ring-2 focus-visible:ring-violet-400 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-gray-900",Joe="min-h-full w-full max-w-lg mx-auto px-4 sm:px-5 py-4 sm:py-6 pb-28 sm:pb-24 bg-gradient-to-br from-violet-100/90 via-white to-fuchsia-100/80 dark:from-gray-950 dark:via-gray-900 dark:to-violet-950/50",Zoe=["air_conditioning","power","building_systems","applications_account"],rf="ultrasound";function Xoe(e){const{t:r}=sr(),a=r(`workOrders.troubleshootTree.steps.${e}`,{returnObjects:!0});return Array.isArray(a)?a:[]}function F7(e){if(!e)return!1;const r=(e.custom_modality||"").toLowerCase(),a=(e.asset_name||"").toLowerCase();return!!(r.includes("ultrasound")||r.includes("us")||a.includes("ultrasound")||a.includes("ultra sound"))}const I7=()=>{const{t:e}=sr(),{workOrderName:r}=hs(),a=hr(),{workOrder:s,loading:n,refetch:i}=z9(r!=null?r:null),{updateWorkOrder:o,loading:l}=G4(),c=p.useMemo(()=>F7(s),[s]),u=p.useMemo(()=>c?[rf]:Zoe,[c]),[h,f]=p.useState("power"),[y,b]=p.useState(0),[w,v]=p.useState(!1),[k,S]=p.useState(""),[N,C]=p.useState(!1),[O,T]=p.useState(!1),P=p.useRef(!1);p.useEffect(()=>{!n&&s&&!P.current&&(P.current=!0,F7(s)&&f(rf))},[n,s]);const E=p.useRef(!1);p.useEffect(()=>{E.current=!1},[r]),p.useEffect(()=>{!r||n||!s||s.workflow_state!=="Repair InProgress"&&(E.current||(E.current=!0,We.info(e("workOrders.troubleshootTree.notAvailableUntilRepairInProgress"),{position:"top-right",autoClose:5e3}),a(`/work-orders/${encodeURIComponent(r)}`,{replace:!0})))},[r,n,s,a,e]);const R=Xoe(h),z=R.length,G=z?R[Math.min(y,z-1)]:null,ae=Goe(h,y),ee=p.useMemo(()=>Array.from({length:Math.max(z,1)},(Q,ie)=>t.jsx("div",{className:N||ie===y?"h-2 w-10 sm:w-12 rounded-full bg-gradient-to-r from-violet-600 to-fuchsia-500 transition-all shadow-sm":"h-2 w-2 rounded-full bg-gray-300/90 dark:bg-gray-600 transition-all","aria-hidden":!0},ie)),[z,y,N]),ne=p.useCallback(Q=>{f(Q),b(0),v(!1),S(""),C(!1)},[]),te=()=>{v(!1),S(""),y+1<z?b(Q=>Q+1):C(!0)},Y=()=>{v(!1),S(""),y>0&&b(Q=>Q-1)},q=()=>{C(!1),b(0),v(!1),S("")},H=()=>{a(r?`/work-orders/${encodeURIComponent(r)}`:"/support")},U=p.useCallback(()=>{v(!0),S("")},[]),re=p.useCallback(()=>{v(!1),S("")},[]),X=p.useCallback(()=>J(null,null,function*(){var ie;const Q=k.trim();if(!Q){We.error(e("workOrders.troubleshootTree.reasonRequiredToast"),{position:"top-right",autoClose:4e3});return}if(r){if(n){We.error(e("workOrders.troubleshootTree.workOrderStillLoading"),{position:"top-right",autoClose:4e3});return}if(!s){We.error(e("workOrders.troubleshootTree.saveExplanationFailed"),{position:"top-right",autoClose:4e3});return}const me=e(`workOrders.troubleshootTree.categories.${h}`),he=(ie=G==null?void 0:G.title)!=null?ie:"",de=`
|
||
|
||
${wne}
|
||
Work order: ${r}
|
||
Category: ${me}
|
||
Step ${y+1} of ${z}: ${he}
|
||
Reason: ${Q}
|
||
`,xe=(s.actions_performed||"").trimEnd(),ge=xe?`${xe}${de}`:de.trim();try{yield o(r,{actions_performed:ge}),i(),v(!1),S(""),We.success(e("workOrders.troubleshootTree.explanationSavedStayOnGuide"),{position:"top-right",autoClose:4e3})}catch(be){We.error(e("workOrders.troubleshootTree.saveExplanationFailed"),{position:"top-right",autoClose:4e3})}return}a("/support/new",{replace:!0,state:{newIssuePrecheckDone:!0,precheckCantCompleteReason:Q}})}),[k,e,r,n,s,h,y,z,G==null?void 0:G.title,o,a,i]),V=p.useCallback(()=>J(null,null,function*(){if(!r){a("/support");return}try{T(!0);const ie=((yield Uu.getWorkOrderDetails(r)).actions_performed||"").trimEnd(),me=e(`workOrders.troubleshootTree.categories.${h}`),he=`
|
||
|
||
${NL}
|
||
Work order: ${r}
|
||
Category completed: ${me}
|
||
Completed at: ${new Date().toISOString()}
|
||
`,de=ie?`${ie}${he}`:he.trim();yield o(r,{actions_performed:de}),a(`/work-orders/${encodeURIComponent(r)}`,{state:{troubleshootGuideJustCompleted:!0}})}catch(Q){We.error(e("workOrders.troubleshootTree.saveExplanationFailed"),{position:"top-right",autoClose:4e3})}finally{T(!1)}}),[r,o,a,e,h]),I=h==="air_conditioning"?"from-sky-400/90 to-cyan-700":h==="power"?"from-violet-500/90 to-purple-900":h==="building_systems"?"from-amber-400/90 to-stone-700":h==="ultrasound"?"from-blue-500/90 to-teal-700":"from-indigo-400/90 to-slate-700",B=p.useMemo(()=>r?c?`${e("workOrders.troubleshootTree.workOrderBadge",{id:r})} · ${e("workOrders.troubleshootTree.ultrasoundBadge",{defaultValue:"Ultrasound diagnostic"})}`:e("workOrders.troubleshootTree.workOrderBadge",{id:r}):e("workOrders.troubleshootTree.selfServiceTitle"),[r,c,e]);return t.jsxs(t.Fragment,{children:[t.jsx($a,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:au}),t.jsxs("div",{className:Joe,children:[t.jsxs("div",{className:"flex items-center gap-3 mb-6 sm:mb-8",children:[t.jsx("button",{type:"button",onClick:H,className:"text-violet-700/70 dark:text-violet-300/80 hover:text-violet-900 dark:hover:text-white p-2 -ml-2 rounded-xl min-h-[44px] min-w-[44px] flex items-center justify-center shrink-0","aria-label":e("workOrders.troubleshootTree.backToWorkOrder"),children:t.jsx(ia,{className:"text-lg"})}),t.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center shrink-0 shadow-md ${c?"bg-gradient-to-br from-blue-500 to-teal-600":"bg-gradient-to-br from-violet-600 to-fuchsia-600"}`,children:t.jsx(Ju,{className:"text-white text-lg","aria-hidden":!0})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h1",{className:"text-lg sm:text-xl font-semibold text-gray-900 dark:text-white truncate",children:c?e("workOrders.troubleshootTree.ultrasoundBadge",{defaultValue:"Ultrasound Diagnostic Guide"}):e("workOrders.troubleshootTree.pageTitle")}),t.jsx("p",{className:"text-xs text-violet-700/80 dark:text-violet-300/90 truncate",children:B})]})]}),c&&t.jsxs("div",{className:"mb-5 p-3 rounded-xl bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 flex items-start gap-2",children:[t.jsx("span",{className:"text-blue-500 text-base shrink-0 mt-0.5",children:"ℹ️"}),t.jsxs("p",{className:"text-xs text-blue-800 dark:text-blue-300 leading-relaxed",children:["This guide follows the official ",t.jsx("strong",{children:"GE Voluson 730 Service Manual, Section 7-7"})," troubleshooting trees. Start with the ",t.jsx("strong",{children:"GE Voluson 730"})," category for asset-specific steps."]})]}),t.jsx("p",{className:"text-[10px] sm:text-[11px] font-semibold tracking-wide text-gray-500 dark:text-gray-400 uppercase mb-3",children:e("workOrders.troubleshootTree.problemTypeTitle")}),t.jsx("div",{className:"flex flex-wrap gap-2 mb-6 sm:mb-8",children:u.map(Q=>{const ie=Q===rf,me=h===Q;return t.jsxs("button",{type:"button",onClick:()=>ne(Q),className:`px-3.5 sm:px-4 py-2.5 rounded-2xl text-xs sm:text-sm font-medium transition-all min-h-[44px] ${me?ie?"text-white shadow-md bg-gradient-to-r from-blue-500 to-teal-600 ring-2 ring-blue-400/40":"text-white shadow-md bg-gradient-to-r from-violet-600 to-fuchsia-600 ring-2 ring-violet-400/40":"bg-white/80 dark:bg-gray-800/90 text-gray-700 dark:text-gray-200 border border-gray-200/80 dark:border-gray-600 hover:border-violet-300 dark:hover:border-violet-500"}`,children:[ie&&"🔬 ",e(`workOrders.troubleshootTree.categories.${Q}`)]},Q)})}),c?t.jsx(Yoe,{}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[t.jsx("p",{className:"text-[10px] sm:text-[11px] font-semibold tracking-wide text-gray-500 dark:text-gray-400 uppercase",children:e("workOrders.troubleshootTree.selfServiceTitle")}),z>0?t.jsx("p",{className:`text-sm font-semibold bg-clip-text text-transparent shrink-0 ${h===rf?"bg-gradient-to-r from-blue-500 to-teal-600":"bg-gradient-to-r from-violet-600 to-fuchsia-600"}`,children:N?e("workOrders.troubleshootTree.guideCompleteBadge"):e("workOrders.troubleshootTree.stepOf",{current:y+1,total:z})}):null]}),t.jsx("div",{className:"flex justify-center gap-2 mb-5 sm:mb-6",children:ee}),t.jsx("div",{className:"rounded-2xl border border-violet-200/60 dark:border-gray-700 bg-white/95 dark:bg-gray-800/95 shadow-lg shadow-violet-500/5 overflow-hidden backdrop-blur-sm",children:N&&z>0?t.jsxs("div",{className:"p-6 sm:p-8 space-y-5 text-center",children:[t.jsx("div",{className:`mx-auto flex h-16 w-16 items-center justify-center rounded-full shadow-lg ${h===rf?"bg-gradient-to-br from-blue-500 to-teal-600 shadow-blue-500/30":"bg-gradient-to-br from-violet-600 to-fuchsia-600 shadow-violet-500/30"}`,children:t.jsx(Qt,{className:"text-3xl text-white","aria-hidden":!0})}),t.jsx("h2",{className:"text-lg sm:text-xl font-bold text-gray-900 dark:text-white leading-snug",children:e("workOrders.troubleshootTree.allStepsCompleteTitle")}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 leading-relaxed max-w-md mx-auto",children:e(r?"workOrders.troubleshootTree.allStepsCompleteBodyWo":"workOrders.troubleshootTree.allStepsCompleteBodyStandalone")}),t.jsxs("div",{className:"flex flex-col gap-3 pt-2 max-w-md mx-auto w-full",children:[t.jsx("button",{type:"button",onClick:()=>{r?V():a("/support")},className:kk,disabled:!!(r&&O),children:e(r?O?"common.saving":"workOrders.troubleshootTree.continueToResolveComplaint":"workOrders.troubleshootTree.backToSupportFromGuide")}),t.jsx("button",{type:"button",onClick:q,className:L7,children:e("workOrders.troubleshootTree.reviewCategoryAgain")})]})]}):G?t.jsxs(t.Fragment,{children:[ae?t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50",children:[t.jsx("img",{src:ae,alt:G.heroCaption,className:"w-full max-h-48 sm:max-h-56 object-cover",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",onError:Q=>{Q.currentTarget.style.display="none"}}),t.jsx("p",{className:"text-center text-xs text-gray-500 dark:text-gray-400 py-2 px-4",children:G.heroCaption})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`aspect-[16/10] max-h-52 sm:max-h-60 flex items-end p-4 bg-gradient-to-br ${I}`,children:t.jsx("span",{className:"text-white/90 text-xs font-medium max-w-[85%]",children:G.heroCaption})}),t.jsx("p",{className:"text-center text-xs text-gray-500 dark:text-gray-400 py-2 px-4",children:G.heroCaption})]}),t.jsxs("div",{className:"p-5 sm:p-6 space-y-4",children:[t.jsx("h2",{className:"text-lg sm:text-xl font-bold text-gray-900 dark:text-white leading-snug",children:G.title}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:e("workOrders.troubleshootTree.introHint")}),t.jsx("div",{className:"rounded-xl bg-violet-50/80 dark:bg-gray-900/60 divide-y divide-violet-100 dark:divide-gray-700 border border-violet-100/80 dark:border-gray-700",children:G.bullets.map((Q,ie)=>t.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 p-4 leading-relaxed",children:Q},ie))}),t.jsxs("div",{className:"flex flex-col gap-3",children:[y>0&&!w&&t.jsxs("button",{type:"button",onClick:Y,className:L7,children:[t.jsx(Z4,{className:"text-sm shrink-0","aria-hidden":!0}),e("workOrders.troubleshootTree.previousStep")]}),t.jsxs("button",{type:"button",onClick:te,className:kk,children:[t.jsx("span",{className:"flex h-7 w-7 items-center justify-center rounded-full border-2 border-white/90 shrink-0",children:t.jsx(Oc,{className:"text-xs"})}),e("workOrders.troubleshootTree.confirmTried")]})]}),w?t.jsxs("div",{className:"rounded-xl border border-violet-200/90 dark:border-violet-700/60 bg-gradient-to-br from-violet-50/95 via-fuchsia-50/50 to-violet-100/70 dark:from-violet-950/45 dark:via-fuchsia-950/25 dark:to-violet-900/35 p-4 sm:p-5 space-y-3 shadow-md shadow-violet-500/10",role:"region","aria-label":e("workOrders.troubleshootTree.cantCompleteStepPrompt"),children:[t.jsx("p",{className:"text-sm font-bold text-gray-900 dark:text-violet-50 leading-snug",children:e("workOrders.troubleshootTree.cantCompleteStepPrompt")}),t.jsx("textarea",{value:k,onChange:Q=>S(Q.target.value),rows:4,placeholder:e("workOrders.troubleshootTree.cantCompletePlaceholder"),className:"w-full rounded-lg border border-violet-200/90 dark:border-violet-700/70 bg-white dark:bg-gray-900 text-gray-900 dark:text-white text-sm p-3 min-h-[100px] resize-y focus:ring-2 focus:ring-violet-500 focus:border-violet-500 outline-none placeholder:text-gray-400 dark:placeholder:text-gray-500"}),t.jsx("button",{type:"button",onClick:()=>void X(),className:kk,disabled:l,children:e("workOrders.troubleshootTree.saveExplanationContinue")}),t.jsx("button",{type:"button",onClick:re,className:"w-full min-h-[48px] text-center text-sm font-medium text-violet-700 dark:text-violet-300 underline underline-offset-2 hover:text-violet-900 dark:hover:text-violet-200",children:e("workOrders.troubleshootTree.backToChecks")})]}):t.jsx("button",{type:"button",onClick:U,className:"w-full min-h-[48px] text-center text-sm font-medium text-violet-700 dark:text-violet-300 underline underline-offset-2 hover:text-violet-900 dark:hover:text-violet-200",children:e("workOrders.troubleshootTree.cantComplete")})]})]}):t.jsx("div",{className:"p-8 text-center text-sm text-gray-500 dark:text-gray-400",children:e("workOrders.troubleshootTree.noSteps")})})]}),t.jsxs("div",{className:"mt-8 rounded-2xl bg-white/70 dark:bg-gray-800/60 border border-violet-200/50 dark:border-gray-700 p-5 flex gap-3 shadow-sm",children:[t.jsx(Cv,{className:"text-violet-600 dark:text-violet-400 text-xl shrink-0 mt-0.5"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-gray-900 dark:text-white text-sm",children:e("workOrders.troubleshootTree.footerTitle")}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 mt-1 leading-relaxed",children:c?"If none of the steps above resolve the issue, escalate to GE Healthcare / SAMAMA with the error codes and findings documented in your Technical Report.":e("workOrders.troubleshootTree.footerHint")})]})]})]})]})};class Qoe{constructor(){$s(this,"baseURL");this.baseURL=Ar.BASE_URL}getCSRFToken(){return J(this,null,function*(){try{return typeof window!="undefined"&&window.csrf_token?window.csrf_token:null}catch(r){return null}})}getHeaders(){return J(this,null,function*(){const r={Accept:"application/json","Content-Type":"application/json"},a=yield this.getCSRFToken();return a&&(r["X-Frappe-CSRF-Token"]=a),r})}getMaintenanceTeams(){return J(this,arguments,function*(r={}){const{filters:a={},fields:s=["name","maintenance_team_name","maintenance_manager","maintenance_manager_name","company","custom_expertise","creation","modified"],limit_start:n=0,limit_page_length:i=20,order_by:o="creation desc"}=r,l=new URLSearchParams;if(l.append("fields",JSON.stringify(s)),l.append("limit_start",n.toString()),l.append("limit_page_length",i.toString()),l.append("order_by",o),Object.keys(a).length>0){const h=xa(a);h.length>0&&l.append("filters",JSON.stringify(h))}const c=yield fetch(`${this.baseURL}/api/resource/Asset Maintenance Team?${l.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);return{data:(yield c.json()).data||[]}})}getMaintenanceTeam(r){return J(this,null,function*(){const a=yield fetch(`${this.baseURL}/api/resource/Asset Maintenance Team/${encodeURIComponent(r)}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return(yield a.json()).data})}createMaintenanceTeam(r){return J(this,null,function*(){const a=yield fetch(`${this.baseURL}/api/resource/Asset Maintenance Team`,{method:"POST",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(r)});if(!a.ok){const n=yield a.json().catch(()=>({}));throw new Error(n.message||`HTTP error! status: ${a.status}`)}return(yield a.json()).data})}updateMaintenanceTeam(r,a){return J(this,null,function*(){const s=yield fetch(`${this.baseURL}/api/resource/Asset Maintenance Team/${encodeURIComponent(r)}`,{method:"PUT",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(a)});if(!s.ok){const i=yield s.json().catch(()=>({}));throw new Error(i.message||`HTTP error! status: ${s.status}`)}return(yield s.json()).data})}deleteMaintenanceTeam(r){return J(this,null,function*(){const a=yield fetch(`${this.baseURL}/api/resource/Asset Maintenance Team/${encodeURIComponent(r)}`,{method:"DELETE",headers:yield this.getHeaders(),credentials:"include"});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`)})}getMaintenanceTeamCount(){return J(this,arguments,function*(r={}){var i,o;const a=new URLSearchParams;if(a.append("fields",JSON.stringify(["count(name) as count"])),Object.keys(r).length>0){const l=xa(r);l.length>0&&a.append("filters",JSON.stringify(l))}const s=yield fetch(`${this.baseURL}/api/resource/Asset Maintenance Team?${a.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return((o=(i=(yield s.json()).data)==null?void 0:i[0])==null?void 0:o.count)||0})}getUserFullName(r){return J(this,null,function*(){var a;try{const s=yield fetch(`${this.baseURL}/api/resource/User/${encodeURIComponent(r)}?fields=["full_name"]`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});return s.ok&&((a=(yield s.json()).data)==null?void 0:a.full_name)||""}catch(s){return""}})}}const Rd=new Qoe,ele=(e={})=>{const[r,a]=p.useState([]),[s,n]=p.useState(!0),[i,o]=p.useState(null),[l,c]=p.useState(0),u=JSON.stringify(e);p.useEffect(()=>{let f=!1;return J(null,null,function*(){try{n(!0),o(null);const y=yield Rd.getMaintenanceTeams(e);if(f)return;a(y.data);const b=yield Rd.getMaintenanceTeamCount(e.filters);if(f)return;c(b)}catch(y){if(f)return;o(y instanceof Error?y.message:"Failed to fetch maintenance teams")}finally{f||n(!1)}}),()=>{f=!0}},[u]);const h=p.useCallback(()=>J(null,null,function*(){try{n(!0),o(null);const f=yield Rd.getMaintenanceTeams(e);a(f.data);const y=yield Rd.getMaintenanceTeamCount(e.filters);c(y)}catch(f){o(f instanceof Error?f.message:"Failed to fetch maintenance teams")}finally{n(!1)}}),[u]);return{teams:r,loading:s,error:i,totalCount:l,refetch:h}},tle=e=>{const[r,a]=p.useState(null),[s,n]=p.useState(!1),[i,o]=p.useState(null),l=p.useCallback(()=>J(null,null,function*(){if(!e){a(null);return}try{n(!0),o(null);const c=yield Rd.getMaintenanceTeam(e);a(c)}catch(c){o(c instanceof Error?c.message:"Failed to fetch maintenance team details")}finally{n(!1)}}),[e]);return p.useEffect(()=>{l()},[l]),{team:r,loading:s,error:i,refetch:l}},rle=()=>{const[e,r]=p.useState(!1),[a,s]=p.useState(null);return{createTeam:c=>J(null,null,function*(){try{return r(!0),s(null),yield Rd.createMaintenanceTeam(c)}catch(u){const h=u instanceof Error?u.message:"Failed to create maintenance team";throw s(h),u}finally{r(!1)}}),updateTeam:(c,u)=>J(null,null,function*(){try{return r(!0),s(null),yield Rd.updateMaintenanceTeam(c,u)}catch(h){const f=h instanceof Error?h.message:"Failed to update maintenance team";throw s(f),h}finally{r(!1)}}),deleteTeam:c=>J(null,null,function*(){try{r(!0),s(null),yield Rd.deleteMaintenanceTeam(c)}catch(u){const h=u instanceof Error?u.message:"Failed to delete maintenance team";throw s(h),u}finally{r(!1)}}),getUserFullName:c=>J(null,null,function*(){return yield Rd.getUserFullName(c)}),loading:e,error:a}},ale=({isOpen:e,onClose:r,selectedCount:a,totalCount:s,pageCount:n,onExport:i,isExporting:o,exportColumns:l})=>{const{t:c}=sr(),[u,h]=p.useState(a>0?"selected":"all_with_filters"),[f,y]=p.useState("csv"),[b,w]=p.useState(l.filter(N=>N.default).map(N=>N.key));p.useEffect(()=>{h(a>0?"selected":"all_with_filters")},[a]);const v=N=>w(C=>C.includes(N)?C.filter(O=>O!==N):[...C,N]),k=()=>w(l.map(N=>N.key)),S=()=>w(l.filter(N=>N.default).map(N=>N.key));return e?t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] overflow-hidden animate-scale-in",children:[t.jsx("div",{className:"bg-gradient-to-r from-green-500 to-green-600 px-6 py-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Sa,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:c("maintenance.export.title")})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:o,children:t.jsx(ht,{size:20})})]})}),t.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-180px)]",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:c("maintenance.export.selectData")}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${u==="selected"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"} ${a===0?"opacity-50 cursor-not-allowed":""}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"selected",checked:u==="selected",onChange:()=>h("selected"),disabled:a===0,className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("maintenance.export.selectedRows")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("maintenance.export.selectedCount",{count:a})})]}),a>0&&t.jsxs("span",{className:"bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300 px-2 py-1 rounded text-xs font-medium",children:[a," selected"]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${u==="all_on_page"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"all_on_page",checked:u==="all_on_page",onChange:()=>h("all_on_page"),className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("maintenance.export.currentPage")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("maintenance.export.currentPageCount",{count:n})})]}),t.jsxs("span",{className:"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300 px-2 py-1 rounded text-xs font-medium",children:[n," rows"]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${u==="all_with_filters"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"all_with_filters",checked:u==="all_with_filters",onChange:()=>h("all_with_filters"),className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("maintenance.export.allWithFilters")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("maintenance.export.allWithFiltersCount",{count:s})})]}),t.jsxs("span",{className:"bg-purple-100 dark:bg-purple-900/40 text-purple-700 dark:text-purple-300 px-2 py-1 rounded text-xs font-medium",children:[s," total"]})]})]})]}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:c("maintenance.export.exportFormat")}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${f==="csv"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"format",value:"csv",checked:f==="csv",onChange:()=>y("csv"),className:"text-green-600 focus:ring-green-500"}),t.jsx(ic,{className:"text-green-600 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("maintenance.export.csv")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:c("maintenance.export.csvDesc")})]})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${f==="excel"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"format",value:"excel",checked:f==="excel",onChange:()=>y("excel"),className:"text-green-600 focus:ring-green-500"}),t.jsx(oc,{className:"text-green-700 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("maintenance.export.excel")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:c("maintenance.export.excelDesc")})]})]})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:c("maintenance.export.columnsToExport")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:k,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:c("maintenance.export.selectAll")}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{onClick:S,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:c("maintenance.export.resetToDefault")})]})]}),t.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2 max-h-48 overflow-y-auto p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg",children:l.map(N=>t.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${b.includes(N.key)?"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300":"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-400"}`,children:[t.jsx("input",{type:"checkbox",checked:b.includes(N.key),onChange:()=>v(N.key),className:"rounded text-green-600 focus:ring-green-500"}),t.jsx("span",{className:"text-sm truncate",children:N.label})]},N.key))}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:c("maintenance.export.columnsSelected",{count:b.length})})]})]}),t.jsxs("div",{className:"px-6 py-4 bg-gray-50 dark:bg-gray-900/50 border-t border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[u==="selected"&&c("maintenance.export.exportingSelected",{count:a}),u==="all_on_page"&&c("maintenance.export.exportingPage",{count:n}),u==="all_with_filters"&&c("maintenance.export.exportingAll",{count:s})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{onClick:r,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",disabled:o,children:c("common.cancel")}),t.jsx("button",{onClick:()=>i(u,f,b),disabled:b.length===0||o,className:"px-4 py-2 text-sm font-medium text-white bg-green-600 hover:bg-green-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:o?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),c("maintenance.export.exporting")]}):t.jsxs(t.Fragment,{children:[t.jsx(qc,{}),c("maintenance.export.exportButton")]})})]})]})]})}):null},sle=()=>{const{t:e}=sr(),r=hr(),a=[{key:"name",label:e("maintenance.teamId"),default:!0},{key:"maintenance_team_name",label:e("maintenance.teamName"),default:!0},{key:"maintenance_manager",label:e("maintenance.managerEmail"),default:!0},{key:"maintenance_manager_name",label:e("maintenance.managerName"),default:!0},{key:"company",label:e("commonFields.hospital"),default:!0},{key:"custom_expertise",label:e("maintenance.expertise"),default:!0},{key:"creation",label:e("commonFields.createdOn"),default:!1},{key:"modified",label:e("commonFields.modifiedOn"),default:!1}],[s,n]=_a(),i=p.useRef(n);p.useEffect(()=>{i.current=n},[n]);const o=p.useMemo(()=>{const Qe=parseInt(s.get("page")||"1",10);return Number.isNaN(Qe)||Qe<1?1:Qe},[s]),l=p.useCallback(Qe=>{const at=typeof Qe=="function"?Qe(o):Qe;n(Ct=>{const vt=new URLSearchParams(Ct);return vt.set("page",String(at)),vt})},[o,n]),[c]=p.useState(20),[u,h]=p.useState(!1),[f,y]=p.useState(new Set),[b,w]=p.useState(!1),[v,k]=p.useState(!1),[S,N]=p.useState(null),[C,O]=p.useState(()=>s.get("date_filter_by")||""),[T,P]=p.useState(()=>s.get("date_start")||""),[E,R]=p.useState(()=>s.get("date_end")||""),[z,G]=p.useState(()=>s.get("company")||""),[ae,ee]=p.useState(()=>s.get("team_name")||""),[ne,te]=p.useState(()=>s.get("sort_by")||"creation desc"),[Y,q]=p.useState(!1),[H,U]=p.useState(0),[re,X]=p.useState([]),[V,I]=p.useState(!1),[B,Q]=p.useState("");p.useEffect(()=>{const Qe=localStorage.getItem("maintenanceTeamFilterPresets");Qe&&X(JSON.parse(Qe))},[]);const ie=C&&(T||E);p.useEffect(()=>{const Qe=[z,ae].filter(Boolean).length+(ie?1:0);U(Qe)},[z,ae,ie]);const me=p.useMemo(()=>{const Qe={};return z&&(Qe.company=z),ae&&(Qe.name=ae),Object.assign(Qe,kl(C,T,E)),Qe},[z,ae,C,T,E]),he=["creation desc","creation asc","modified desc","modified asc","name asc","name desc","maintenance_team_name asc","maintenance_team_name desc"].includes(ne)?ne:"creation desc",{teams:de,loading:xe,error:ge,totalCount:be,refetch:K}=ele({filters:me,limit_start:(o-1)*c,limit_page_length:c,order_by:he});p.useEffect(()=>{!xe&&!u&&h(!0)},[xe,u]);const ye=p.useRef(!1);p.useEffect(()=>{if(!ye.current){ye.current=!0;return}i.current(Qe=>{const at=new URLSearchParams(Qe);return C?at.set("date_filter_by",C):at.delete("date_filter_by"),T?at.set("date_start",T):at.delete("date_start"),E?at.set("date_end",E):at.delete("date_end"),z?at.set("company",z):at.delete("company"),ae?at.set("team_name",ae):at.delete("team_name"),ne&&ne!=="creation desc"?at.set("sort_by",ne):at.delete("sort_by"),at.set("page","1"),at})},[C,T,E,z,ae,ne]),p.useEffect(()=>{y(new Set)},[C,T,E,z,ae,o]);const Z=Qe=>Qe?new Date(Qe).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-",M=()=>{O(""),P(""),R(""),te("creation desc"),G(""),ee(""),i.current(Qe=>{const at=new URLSearchParams(Qe);return at.delete("date_filter_by"),at.delete("date_start"),at.delete("date_end"),at.delete("sort_by"),at.delete("company"),at.delete("team_name"),at.set("page","1"),at})},we=ie||!!z||!!ae,pe=()=>{if(!B.trim()){alert("Please enter a filter name");return}const Qe={id:Date.now(),name:B,filters:{dateFilterBy:C,dateStart:T,dateEnd:E,sortBy:ne,companyFilter:z,teamNameFilter:ae}},at=[...re,Qe];X(at),Q(""),I(!1),localStorage.setItem("maintenanceTeamFilterPresets",JSON.stringify(at))},le=Qe=>{const at=Qe.filters;O(at.dateFilterBy||""),P(at.dateStart||""),R(at.dateEnd||""),te(at.sortBy||"creation desc"),G(at.companyFilter||""),ee(at.teamNameFilter||"")},Fe=Qe=>{const at=re.filter(Ct=>Ct.id!==Qe);X(at),localStorage.setItem("maintenanceTeamFilterPresets",JSON.stringify(at))},ze=Qe=>{y(at=>{const Ct=new Set(at);return Ct.has(Qe)?Ct.delete(Qe):Ct.add(Qe),Ct})},Re=()=>{f.size===de.length?y(new Set):y(new Set(de.map(Qe=>Qe.name)))},De=de.length>0&&f.size===de.length,Et=f.size>0&&f.size<de.length,jt=p.useCallback(()=>J(null,null,function*(){const Qe=[];let at=0;const Ct=100;let vt=!0;const er=xa(me);for(;vt;)try{const He=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Asset Maintenance Team",filters:er.length>0?er:{},fields:["*"],limit_start:at*Ct,limit_page_length:Ct,order_by:he})})).json()).message||[];Qe.push(...He),He.length<Ct?vt=!1:at++,at>100&&(console.warn("Export safety limit reached"),vt=!1)}catch(nr){throw console.error("Error fetching teams for export:",nr),nr}return Qe}),[me]),Ie=(Qe,at,Ct)=>J(null,null,function*(){k(!0);try{let vt=[];switch(Qe){case"selected":vt=de.filter(nr=>f.has(nr.name));break;case"all_on_page":vt=de;break;case"all_with_filters":vt=yield jt();break}if(vt.length===0){alert(e("assets.noDataToExport"));return}const er=Ct.map(nr=>{var dt;return((dt=a.find(He=>He.key===nr))==null?void 0:dt.label)||nr});if(at==="csv"){const nr=[er.join(","),...vt.map(Ue=>Ct.map(Ve=>{let lt=Ue[Ve]||"";return typeof lt=="string"&&(lt.includes(",")||lt.includes('"')||lt.includes(`
|
||
`))&&(lt=`"${lt.replace(/"/g,'""')}"`),lt}).join(","))].join(`
|
||
`),dt=new Blob(["\uFEFF"+nr],{type:"text/csv;charset=utf-8;"}),He=URL.createObjectURL(dt),it=document.createElement("a");it.href=He,it.download=`maintenance_teams_export_${new Date().toISOString().split("T")[0]}.csv`,it.click(),URL.revokeObjectURL(He)}else if(at==="excel"){const nr=[er,...vt.map(it=>Ct.map(Ue=>it[Ue]||""))],dt=Na.aoa_to_sheet(nr),He=Na.book_new();Na.book_append_sheet(He,dt,"Maintenance Teams"),lc(He,`maintenance_teams_export_${new Date().toISOString().split("T")[0]}.xlsx`)}w(!1),y(new Set)}catch(vt){console.error("Export failed:",vt),alert(`Export failed: ${vt instanceof Error?vt.message:"Unknown error"}`)}finally{k(!1)}}),$e=Qe=>J(null,null,function*(){try{if(!(yield fetch(`/api/resource/Asset Maintenance Team/${encodeURIComponent(Qe)}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to delete");N(null),K(),alert(e("maintenance.deletedSuccessfully"))}catch(at){alert(`Failed to delete: ${at instanceof Error?at.message:"Unknown error"}`)}});return xe&&!u?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("maintenance.loadingTeams")})]})}):ge?t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:e("maintenance.errorLoadingTeams")}),t.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:ge}),t.jsx("button",{onClick:K,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:e("common.tryAgain")})]})}):t.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsx("div",{children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx($d,{className:"text-3xl text-indigo-600 dark:text-indigo-400"}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:e("maintenance.listTitle")}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[e("issues.listTotal"),": ",be,f.size>0&&t.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",f.size," ",e("issues.listSelected")]}),xe&&u&&t.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400",children:[t.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-blue-500"}),e("common.filtering")]})]})]})]})}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("button",{onClick:()=>q(!Y),className:`px-4 py-2 rounded-lg flex items-center gap-2 transition-colors ${Y||we?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300":"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600"}`,children:[t.jsx(ds,{}),e("listPages.filters"),H>0&&t.jsx("span",{className:"bg-blue-600 text-white text-xs px-1.5 py-0.5 rounded-full",children:H})]}),t.jsxs("button",{onClick:K,disabled:xe,className:"px-4 py-2 rounded-lg bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 flex items-center gap-2 disabled:opacity-50",children:[t.jsx(Ma,{className:xe?"animate-spin":""}),e("listPages.refresh")]}),t.jsxs("button",{onClick:()=>w(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",disabled:be===0,children:[t.jsx(Sa,{}),t.jsx("span",{className:"font-medium",children:e("listPages.export")}),f.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:f.size})]}),t.jsxs("button",{onClick:()=>r("/maintenance-teams/new"),className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow-lg transition-all hover:shadow-xl",children:[t.jsx(Rr,{}),t.jsx("span",{className:"font-medium",children:e("maintenance.newMaintenanceTeam")})]})]})]}),Y&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-4",children:[t.jsx("div",{className:"bg-gradient-to-r from-indigo-500 to-indigo-600 dark:from-indigo-600 dark:to-indigo-700 px-4 py-3 rounded-t-lg",children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ds,{className:"text-white",size:16}),t.jsx("h3",{className:"text-white font-semibold text-sm",children:e("listPages.filters")}),H>0&&t.jsx("span",{className:"bg-white text-indigo-600 px-2 py-0.5 rounded-full text-xs font-bold",children:H})]}),we&&t.jsx("div",{className:"flex-1 overflow-x-auto scrollbar-hide mx-2",children:t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[ie&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-amber-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e(C==="creation"?"filters.createdDate":"filters.latestModifiedDate"),":"]})," ",[T,E].filter(Boolean).join(" – "),t.jsx("button",{onClick:()=>{O(""),P(""),R("")},className:"hover:text-red-500",children:t.jsx(ht,{className:"text-[9px]"})})]}),z&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-green-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("filters.hospital"),":"]})," ",z,t.jsx("button",{onClick:()=>G(""),className:"hover:text-red-500",children:t.jsx(ht,{className:"text-[9px]"})})]}),ae&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("maintenance.teamName"),":"]})," ",ae,t.jsx("button",{onClick:()=>ee(""),className:"hover:text-red-500",children:t.jsx(ht,{className:"text-[9px]"})})]})]})}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[H>0&&t.jsxs("button",{onClick:()=>I(!0),className:"px-3 py-1.5 bg-white text-indigo-600 hover:bg-indigo-50 rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[t.jsx(ta,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:e("listPages.saveFilterPreset")})]}),we&&t.jsxs("button",{onClick:M,className:"px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[t.jsx(ht,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:e("listPages.clearFilters")})]})]})]})}),t.jsxs("div",{className:"p-4",children:[re.length>0&&t.jsxs("div",{className:"mb-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[t.jsx(a0,{className:"text-yellow-500",size:12}),e("inspections.savedFilters")]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:re.map(Qe=>t.jsxs("div",{className:"group relative inline-flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-purple-100 to-indigo-100 dark:from-purple-900/30 dark:to-indigo-900/30 border border-purple-200 dark:border-purple-700 rounded-lg hover:shadow-md transition-all",children:[t.jsx("button",{onClick:()=>le(Qe),className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:Qe.name}),t.jsx("button",{onClick:()=>Fe(Qe.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:t.jsx(wr,{size:10})})]},Qe.id))})]}),t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 p-3 rounded-lg",children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3 mb-3",children:[t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.sortBy")}),t.jsxs("select",{value:ne,onChange:Qe=>{te(Qe.target.value),l(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"creation desc",children:e("filters.sortCreationNewest")}),t.jsx("option",{value:"creation asc",children:e("filters.sortCreationOldest")}),t.jsx("option",{value:"modified desc",children:e("filters.sortModifiedNewest")}),t.jsx("option",{value:"modified asc",children:e("filters.sortModifiedOldest")}),t.jsx("option",{value:"name asc",children:e("filters.sortNameAsc")}),t.jsx("option",{value:"name desc",children:e("filters.sortNameDesc")}),t.jsx("option",{value:"maintenance_team_name asc",children:e("filters.sortTeamNameAsc")}),t.jsx("option",{value:"maintenance_team_name desc",children:e("filters.sortTeamNameDesc")})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.filterBy")}),t.jsxs("select",{value:C,onChange:Qe=>{const at=Qe.target.value;O(at),l(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("filters.filterBy")}),t.jsx("option",{value:"creation",children:e("filters.createdDate")}),t.jsx("option",{value:"modified",children:e("filters.latestModifiedDate")})]})]}),C&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.startDate")}),t.jsx("input",{type:"date",value:T,onChange:Qe=>{const at=Qe.target.value;P(at),E&&at>E&&R(at),l(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.endDate")}),t.jsx("input",{type:"date",value:E,onChange:Qe=>{R(Qe.target.value),l(1)},min:T||void 0,className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[t.jsxs("div",{className:"relative z-[60]",children:[t.jsx(Je,{label:"Hospital",doctype:"Company",value:z,onChange:Qe=>{G(Qe),l(1)},placeholder:"Select Hospital",disabled:!1,compact:!0}),z&&t.jsx("button",{onClick:()=>G(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[59]",children:[t.jsx(Je,{label:e("maintenance.teamName"),doctype:"Asset Maintenance Team",value:ae,onChange:Qe=>{ee(Qe),l(1)},placeholder:e("maintenance.selectTeam"),disabled:!1,compact:!0}),ae&&t.jsx("button",{onClick:()=>ee(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]})]})]})]})]}),V&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 animate-scale-in",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:e("listPages.saveFilterPreset")}),t.jsx("input",{type:"text",value:B,onChange:Qe=>Q(Qe.target.value),onKeyDown:Qe=>{Qe.key==="Enter"&&(Qe.preventDefault(),pe())},placeholder:e("listPages.enterFilterName"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white mb-4",autoFocus:!0}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:()=>{I(!1),Q("")},className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",children:e("common.cancel")}),t.jsxs("button",{onClick:pe,className:"px-4 py-2 text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 rounded-md transition-colors flex items-center gap-2",children:[t.jsx(ta,{size:12}),e("listPages.saveFilter")]})]})]})}),t.jsx(ale,{isOpen:b,onClose:()=>w(!1),selectedCount:f.size,totalCount:be,pageCount:de.length,onExport:Ie,isExporting:v,exportColumns:a}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-200 dark:border-gray-700 overflow-hidden relative",children:[xe&&u&&t.jsx("div",{className:"absolute inset-0 bg-white/60 dark:bg-gray-800/60 flex items-center justify-center z-10 backdrop-blur-[1px]",children:t.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-gray-700 px-4 py-2 rounded-lg shadow-lg",children:[t.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-indigo-500"}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:e("listPages.filtering")})]})}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left",children:t.jsx("button",{onClick:Re,className:"text-gray-500 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors",title:e(De?"listPages.deselectAllTitle":"listPages.selectAllTitle"),children:De?t.jsx(Ra,{className:"text-indigo-600 dark:text-indigo-400",size:18}):Et?t.jsxs("div",{className:"relative",children:[t.jsx(Ur,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Ur,{size:18})})}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("maintenance.teamName")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("maintenance.managerName")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.hospital")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("maintenance.expertise")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.createdOn")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("listPages.actions")})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:de.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"px-4 py-12 text-center text-gray-500 dark:text-gray-400",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx($d,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("listPages.noMaintenanceTeamsFound")}),we?t.jsx("button",{onClick:M,className:"mt-4 text-indigo-600 dark:text-indigo-400 hover:underline",children:e("common.clearFilters")}):t.jsx("button",{onClick:()=>r("/maintenance-teams/new"),className:"mt-4 text-indigo-600 dark:text-indigo-400 hover:underline",children:e("listPages.createFirstTeam")})]})})}):de.map(Qe=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 cursor-pointer transition-colors ${f.has(Qe.name)?"bg-indigo-50 dark:bg-indigo-900/20":""}`,onClick:()=>r(`/maintenance-teams/${Qe.name}`),children:[t.jsx("td",{className:"px-4 py-3",onClick:at=>at.stopPropagation(),children:t.jsx("button",{onClick:()=>ze(Qe.name),className:"text-gray-500 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors",children:f.has(Qe.name)?t.jsx(Ra,{className:"text-indigo-600 dark:text-indigo-400",size:18}):t.jsx(Ur,{size:18})})}),t.jsxs("td",{className:"px-4 py-3",children:[t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:Qe.maintenance_team_name}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:Qe.name})]}),t.jsxs("td",{className:"px-4 py-3",children:[t.jsx("div",{className:"text-sm text-gray-900 dark:text-white",children:Qe.maintenance_manager_name||"-"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:Qe.maintenance_manager||"-"})]}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:Qe.company||"-"})}),t.jsx("td",{className:"px-4 py-3",children:Qe.custom_expertise?t.jsx("span",{className:"inline-flex px-2 py-1 text-xs font-medium rounded-full bg-indigo-100 text-indigo-800 dark:bg-indigo-900/30 dark:text-indigo-300",children:Qe.custom_expertise}):t.jsx("span",{className:"text-gray-400",children:"-"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:Z(Qe.creation)})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-1",onClick:at=>at.stopPropagation(),children:[t.jsx("button",{onClick:()=>r(`/maintenance-teams/${Qe.name}`),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded transition-colors",title:e("maintenance.viewDetails"),children:t.jsx(Ps,{})}),t.jsx("button",{onClick:()=>r(`/maintenance-teams/${Qe.name}`),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:e("maintenance.editTeam"),children:t.jsx(qr,{})}),t.jsx("button",{onClick:()=>r(`/maintenance-teams/new?duplicate=${Qe.name}`),className:"text-purple-600 dark:text-purple-400 hover:text-purple-900 dark:hover:text-purple-300 p-2 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded transition-colors",title:e("maintenance.duplicateTeam"),children:t.jsx(Vo,{})}),t.jsx("button",{onClick:()=>N(Qe.name),className:"text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300 p-2 hover:bg-red-50 dark:hover:bg-red-900/30 rounded transition-colors",title:e("maintenance.deleteTeam"),children:t.jsx(wr,{})})]})})]},Qe.name))})]})}),t.jsx(_l,{currentPage:o,totalCount:be,pageSize:c,itemLabel:e("pagination.teams"),onPageChange:Qe=>l(Qe)})]}),S&&t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx("div",{className:"flex-shrink-0 w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:t.jsx(wr,{className:"text-red-600 dark:text-red-400 text-xl"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:e("maintenance.deleteTeam")}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:e("maintenance.deleteConfirmMessage")}),t.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-md p-3 mb-4",children:t.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[t.jsxs("strong",{children:[e("maintenance.team"),":"]})," ",S]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>N(null),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-lg transition-colors",children:e("common.cancel")}),t.jsxs("button",{onClick:()=>$e(S),className:"px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors flex items-center gap-2",children:[t.jsx(wr,{}),e("maintenance.deleteTeamButton")]})]})]})]})})}),t.jsx("style",{children:`
|
||
@keyframes scale-in { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
|
||
.animate-scale-in { animation: scale-in 0.2s ease-out; }
|
||
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }
|
||
.scrollbar-hide::-webkit-scrollbar { display: none; }
|
||
`})]})},nle=()=>{var X;const{t:e}=sr(),{teamName:r}=hs(),[a]=_a(),s=hr(),n=r==="new",i=a.get("duplicate"),[o,l]=p.useState({maintenance_team_name:"",maintenance_manager:"",maintenance_manager_name:"",company:"",custom_expertise:"",maintenance_team_members:[]}),{team:c,loading:u,error:h,refetch:f}=tle(n?i||null:r||null),{createTeam:y,updateTeam:b,deleteTeam:w,getUserFullName:v,loading:k}=rle(),[S,N]=p.useState(n),[C,O]=p.useState(!1),[T,P]=p.useState(null),[E,R]=p.useState(null),z=V=>J(null,null,function*(){if(!V)return{exists:!1};try{const I=yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},credentials:"include",body:JSON.stringify({doctype:"Asset Maintenance Team",filters:{},fields:["name","maintenance_team_name","maintenance_team_members.team_member"],limit_page_length:0})});if(!I.ok)return yield G(V);const Q=(yield I.json()).message||[];for(const ie of Q)if(!(ie.name===r||ie.name===(c==null?void 0:c.name))&&ie["maintenance_team_members.team_member"]===V)return{exists:!0,teamName:ie.maintenance_team_name||ie.name};return yield G(V)}catch(I){return console.error("Error checking member in other teams:",I),yield G(V)}}),G=V=>J(null,null,function*(){var I,B;try{const Q=yield fetch('/api/resource/Asset Maintenance Team?fields=["name","maintenance_team_name"]&limit_page_length=0',{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"});if(!Q.ok)return{exists:!1};const me=(yield Q.json()).data||[];for(const he of me){if(he.name===r||he.name===(c==null?void 0:c.name))continue;const de=yield fetch(`/api/resource/Asset Maintenance Team/${encodeURIComponent(he.name)}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"});if(!de.ok)continue;const xe=yield de.json();if((((I=xe.data)==null?void 0:I.maintenance_team_members)||[]).some(K=>K.team_member===V))return{exists:!0,teamName:((B=xe.data)==null?void 0:B.maintenance_team_name)||he.name}}return{exists:!1}}catch(Q){return console.error("Fallback check failed:",Q),{exists:!1}}});p.useEffect(()=>{var V;c&&(l({maintenance_team_name:n&&i?`${c.maintenance_team_name} (Copy)`:c.maintenance_team_name||"",maintenance_manager:c.maintenance_manager||"",maintenance_manager_name:c.maintenance_manager_name||"",company:c.company||"",custom_expertise:c.custom_expertise||"",maintenance_team_members:((V=c.maintenance_team_members)==null?void 0:V.map((I,B)=>je(se({},I),{idx:B+1,name:n?void 0:I.name})))||[]}),n||N(!1))},[c,n,i]);const ae=V=>{const{name:I,value:B}=V.target;l(Q=>je(se({},Q),{[I]:B}))},ee=V=>J(null,null,function*(){if(l(I=>je(se({},I),{maintenance_manager:V})),V){const I=yield v(V);l(B=>je(se({},B),{maintenance_manager_name:I}))}else l(I=>je(se({},I),{maintenance_manager_name:""}))}),ne=(V,I,B)=>J(null,null,function*(){var Q;if(I==="team_member"&&B){if((Q=o.maintenance_team_members)==null?void 0:Q.some((ge,be)=>be!==V&&ge.team_member===B)){We.error("This member is already added to this team!",{position:"top-right",autoClose:4e3,icon:t.jsx(pr,{})});return}R(V),We.info("Checking member availability...",{position:"top-right",autoClose:2e3,icon:()=>t.jsx("span",{children:"🔍"})});const{exists:me,teamName:he}=yield z(B);if(R(null),me){We.error(t.jsxs("div",{children:[t.jsx("strong",{children:"Cannot add member!"}),t.jsx("br",{}),t.jsxs("span",{className:"text-sm",children:["This member is already assigned to: ",t.jsx("b",{children:he})]})]}),{position:"top-right",autoClose:5e3,icon:t.jsx(pr,{})});return}const de=yield v(B),xe=[...o.maintenance_team_members||[]];xe[V]=je(se({},xe[V]),{team_member:B,full_name:de}),l(ge=>je(se({},ge),{maintenance_team_members:xe})),We.success("Member added successfully!",{position:"top-right",autoClose:2e3,icon:t.jsx(Qt,{})})}else{const ie=[...o.maintenance_team_members||[]];ie[V]=je(se({},ie[V]),{[I]:B}),l(me=>je(se({},me),{maintenance_team_members:ie}))}}),te=()=>{var I;const V={team_member:"",full_name:"",maintenance_role:"",idx:(((I=o.maintenance_team_members)==null?void 0:I.length)||0)+1};l(B=>je(se({},B),{maintenance_team_members:[...B.maintenance_team_members||[],V]}))},Y=V=>{var B;const I=((B=o.maintenance_team_members)==null?void 0:B.filter((Q,ie)=>ie!==V))||[];I.forEach((Q,ie)=>{Q.idx=ie+1}),l(Q=>je(se({},Q),{maintenance_team_members:I})),P(null)},q=()=>J(null,null,function*(){var V;if(!o.maintenance_team_name){We.error("Please enter a team name",{position:"top-right",autoClose:4e3,icon:t.jsx(pr,{})});return}try{const I=je(se({},o),{maintenance_team_members:(V=o.maintenance_team_members)==null?void 0:V.map(B=>({team_member:B.team_member,full_name:B.full_name,maintenance_role:B.maintenance_role})).filter(B=>B.team_member)});if(n){const B=yield y(I);We.success("Maintenance Team created successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),s(`/maintenance-teams/${B.name}`)}else yield b(r,I),We.success("Maintenance Team updated successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),N(!1),f()}catch(I){const B=I instanceof Error?I.message:"Unknown error";We.error(`Failed to save: ${B}`,{position:"top-right",autoClose:6e3,icon:t.jsx(pr,{})})}}),H=()=>J(null,null,function*(){try{yield w(r),We.success("Maintenance Team deleted successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),s(-1)}catch(V){const I=V instanceof Error?V.message:"Unknown error";We.error(`Failed to delete: ${I}`,{position:"top-right",autoClose:6e3,icon:t.jsx(pr,{})})}}),U=p.useCallback(V=>!S,[S]),re=V=>V?new Date(V).toLocaleString():"-";return u?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading maintenance team..."})]})}):h&&!n?t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:e("maintenance.errorLoadingTeam")}),t.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:h}),t.jsx("button",{onClick:()=>s(-1),className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded",children:e("maintenance.backToTeams")})]})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[t.jsx($a,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:au}),t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("button",{onClick:()=>s(-1),className:"text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200",children:t.jsx(ia,{size:20})}),t.jsxs("div",{children:[t.jsxs("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white flex items-center gap-3",children:[t.jsx($d,{className:"text-indigo-500"}),n?"New Maintenance Team":(c==null?void 0:c.maintenance_team_name)||"Maintenance Team"]}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:n?"Create a new maintenance team":c==null?void 0:c.name})]})]}),t.jsxs("div",{className:"flex gap-3",children:[!n&&!S&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>N(!0),className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(qr,{}),e("common.edit")]}),t.jsxs("button",{onClick:()=>O(!0),className:"bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(wr,{}),e("common.delete")]})]}),S&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{n?s(-1):(N(!1),f())},className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg",children:e("common.cancel")}),t.jsxs("button",{onClick:q,disabled:k,className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 disabled:opacity-50",children:[t.jsx(ta,{}),e(k?"common.saving":"common.save")]})]})]})]}),C&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl",children:[t.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[t.jsx(Or,{className:"text-red-500 text-xl mt-0.5"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:e("maintenance.deleteTeam")}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:e("confirmations.cannotUndo")})]})]}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>O(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",children:e("common.cancel")}),t.jsx("button",{onClick:H,disabled:k,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg disabled:opacity-50",children:e(k?"common.deleting":"common.delete")})]})]})}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[t.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx($d,{className:"text-indigo-500"}),e("maintenance.teamInformation")]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"md:col-span-2",children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[e("maintenance.teamName")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",name:"maintenance_team_name",value:o.maintenance_team_name,onChange:ae,disabled:U("maintenance_team_name"),placeholder:e("maintenance.enterTeamName"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]}),t.jsx("div",{children:t.jsx(Je,{label:e("commonFields.hospital"),doctype:"Company",value:o.company||"",onChange:V=>l(je(se({},o),{company:V})),disabled:U("company"),placeholder:e("maintenance.selectHospital")})}),t.jsx("div",{children:t.jsx(Je,{label:e("maintenance.expertise"),doctype:"Issue Type",value:o.custom_expertise||"",onChange:V=>l(je(se({},o),{custom_expertise:V})),disabled:U("custom_expertise"),placeholder:e("maintenance.selectExpertise"),allowQuickCreate:!0})}),t.jsx("div",{children:t.jsx(Je,{label:e("maintenance.manager"),doctype:"User",value:o.maintenance_manager||"",onChange:ee,disabled:U("maintenance_manager"),placeholder:e("maintenance.selectManager")})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("maintenance.managerName")}),t.jsx("input",{type:"text",value:o.maintenance_manager_name||"",disabled:!0,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white flex items-center gap-2",children:[t.jsx(YG,{className:"text-green-500"}),"Team Members"]}),S&&t.jsxs("button",{onClick:te,disabled:E!==null,className:"bg-green-600 hover:bg-green-700 text-white px-3 py-1.5 rounded-lg flex items-center gap-2 text-sm disabled:opacity-50 disabled:cursor-not-allowed",children:[t.jsx(Rr,{size:12}),"Add Member"]})]}),o.maintenance_team_members&&o.maintenance_team_members.length>0?t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:"#"}),t.jsxs("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:["Team Member",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:"Full Name"}),t.jsxs("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:["Role",t.jsx("span",{className:"text-red-500",children:"*"})]}),S&&t.jsx("th",{className:"px-3 py-2 text-center text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:"Action"})]})}),t.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:o.maintenance_team_members.map((V,I)=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 ${E===I?"opacity-70":""}`,children:[t.jsx("td",{className:"px-3 py-2 text-sm text-gray-600 dark:text-gray-400",children:I+1}),t.jsx("td",{className:"px-3 py-2",children:S?t.jsxs("div",{className:"relative",children:[t.jsx(Je,{label:"",doctype:"User",value:V.team_member||"",onChange:B=>ne(I,"team_member",B),disabled:E!==null,placeholder:e("maintenance.selectUser"),compact:!0}),E===I&&t.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2",children:t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-indigo-500"})})]}):t.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:V.team_member||"-"})}),t.jsx("td",{className:"px-3 py-2 text-sm text-gray-600 dark:text-gray-300",children:V.full_name||"-"}),t.jsx("td",{className:"px-3 py-2",children:S?t.jsx(Je,{label:"",doctype:"Role",value:V.maintenance_role||"",onChange:B=>ne(I,"maintenance_role",B),disabled:E!==null,placeholder:e("maintenance.selectRole"),compact:!0}):t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:V.maintenance_role||"-"})}),S&&t.jsx("td",{className:"px-3 py-2 text-center",children:t.jsx("button",{onClick:()=>P(I),className:"text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300 p-1.5 hover:bg-red-50 dark:hover:bg-red-900/30 rounded transition-colors",title:e("maintenance.removeMember"),children:t.jsx(wr,{size:14})})})]},I))})]})}):t.jsxs("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:[t.jsx($d,{className:"text-4xl mx-auto mb-2 text-gray-300 dark:text-gray-600"}),t.jsx("p",{children:e("maintenance.noTeamMembersYet")}),S&&t.jsxs("button",{onClick:te,className:"mt-3 text-indigo-600 dark:text-indigo-400 hover:underline",children:["+ ",e("maintenance.addFirstMember")]})]})]}),!n&&t.jsx(Bm,{referenceDoctype:"Asset Maintenance Team",referenceName:r||null,title:"Comments & Discussion",pollInterval:3e4,initialLimit:5,collapsible:!0,startCollapsed:!1})]}),t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(Av,{className:"text-blue-500"}),e("maintenance.teamSummary")]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"p-4 bg-indigo-50 dark:bg-indigo-900/30 rounded-lg border border-indigo-200 dark:border-indigo-800",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:e("maintenance.totalMembers")}),t.jsx("p",{className:"text-2xl font-bold text-indigo-600 dark:text-indigo-300",children:((X=o.maintenance_team_members)==null?void 0:X.filter(V=>V.team_member).length)||0})]}),o.maintenance_manager_name&&t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:e("maintenance.manager")}),t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:o.maintenance_manager_name})]}),o.company&&t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Hospital"}),t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:o.company})]}),o.custom_expertise&&t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Expertise"}),t.jsx("span",{className:"inline-flex px-2 py-1 text-xs font-medium rounded-full bg-indigo-100 text-indigo-800 dark:bg-indigo-900/30 dark:text-indigo-300",children:o.custom_expertise})]})]})]}),!n&&c&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(K4,{className:"text-teal-500"}),"Details"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Created"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:re(c.creation)})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Last Modified"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:re(c.modified)})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Modified By"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:c.modified_by||"-"})]})]})]})]})]}),T!==null&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-sm w-full mx-4 shadow-xl",children:[t.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[t.jsx(Or,{className:"text-orange-500 text-xl mt-0.5"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:"Remove Team Member"}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Are you sure you want to remove this team member?"})]})]}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>P(null),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",children:"Cancel"}),t.jsx("button",{onClick:()=>Y(T),className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg",children:"Remove"})]})]})})]})};class ile{constructor(){$s(this,"baseURL");this.baseURL=Ar.BASE_URL}getCSRFToken(){return J(this,null,function*(){try{return typeof window!="undefined"&&window.csrf_token?window.csrf_token:null}catch(r){return null}})}getHeaders(){return J(this,null,function*(){const r={Accept:"application/json","Content-Type":"application/json"},a=yield this.getCSRFToken();return a&&(r["X-Frappe-CSRF-Token"]=a),r})}getInspections(){return J(this,arguments,function*(r={}){const{filters:a={},fields:s=["name","workflow_state","inspection_type","status","inspection_date","target_closure_date","requested_by","technician_department","linked_corrective_wo_no","observation_note","technical_response","creation","modified","owner","modified_by","custom_delete_status"],limit_start:n=0,limit_page_length:i=20,order_by:o="creation desc"}=r,l=new URLSearchParams;if(l.append("fields",JSON.stringify(s)),l.append("limit_start",n.toString()),l.append("limit_page_length",i.toString()),l.append("order_by",o),Object.keys(a).length>0){const h=xa(a);h.length>0&&l.append("filters",JSON.stringify(h))}const c=yield fetch(`${this.baseURL}/api/resource/Inspection?${l.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);return{data:(yield c.json()).data||[]}})}getInspection(r){return J(this,null,function*(){const a=yield fetch(`${this.baseURL}/api/resource/Inspection/${encodeURIComponent(r)}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return(yield a.json()).data})}createInspection(r){return J(this,null,function*(){const a=yield fetch(`${this.baseURL}/api/resource/Inspection`,{method:"POST",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(r)});if(!a.ok){const n=yield a.json().catch(()=>({}));throw new Error(n.message||`HTTP error! status: ${a.status}`)}return(yield a.json()).data})}updateInspection(r,a){return J(this,null,function*(){const s=yield fetch(`${this.baseURL}/api/resource/Inspection/${encodeURIComponent(r)}`,{method:"PUT",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(a)});if(!s.ok){const i=yield s.json().catch(()=>({}));throw new Error(i.message||`HTTP error! status: ${s.status}`)}return(yield s.json()).data})}deleteInspection(r){return J(this,null,function*(){const a=yield fetch(`${this.baseURL}/api/resource/Inspection/${encodeURIComponent(r)}`,{method:"DELETE",headers:yield this.getHeaders(),credentials:"include"});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`)})}getInspectionCount(){return J(this,arguments,function*(r={}){var i,o;const a=new URLSearchParams;if(a.append("fields",JSON.stringify(["count(name) as count"])),Object.keys(r).length>0){const l=xa(r);l.length>0&&a.append("filters",JSON.stringify(l))}const s=yield fetch(`${this.baseURL}/api/resource/Inspection?${a.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return((o=(i=(yield s.json()).data)==null?void 0:i[0])==null?void 0:o.count)||0})}getCurrentUser(){return J(this,null,function*(){try{const r=yield fetch(`${this.baseURL}/api/method/frappe.auth.get_logged_user`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return(yield r.json()).message||""}catch(r){return console.error("Error getting current user:",r),""}})}}const Md=new ile;function ole(e={}){const[r,a]=p.useState([]),[s,n]=p.useState(!0),[i,o]=p.useState(null),[l,c]=p.useState(0),u=JSON.stringify(e);p.useEffect(()=>{let f=!1;return J(null,null,function*(){try{n(!0),o(null);const[y,b]=yield Promise.all([Md.getInspections(e),Md.getInspectionCount(e.filters||{})]);if(f)return;a(y.data),c(b)}catch(y){if(f)return;const b=y instanceof Error?y.message:"Failed to fetch inspections";o(b),console.error("Error fetching inspections:",y)}finally{f||n(!1)}}),()=>{f=!0}},[u]);const h=p.useCallback(()=>J(null,null,function*(){try{n(!0),o(null);const[f,y]=yield Promise.all([Md.getInspections(e),Md.getInspectionCount(e.filters||{})]);a(f.data),c(y)}catch(f){const y=f instanceof Error?f.message:"Failed to fetch inspections";o(y),console.error("Error fetching inspections:",f)}finally{n(!1)}}),[u]);return{inspections:r,loading:s,error:i,totalCount:l,refetch:h}}function lle(e){const[r,a]=p.useState(null),[s,n]=p.useState(!0),[i,o]=p.useState(null),l=p.useCallback(()=>J(null,null,function*(){if(!e){n(!1);return}try{n(!0),o(null);const c=yield Md.getInspection(e);a(c)}catch(c){const u=c instanceof Error?c.message:"Failed to fetch inspection";o(u),console.error("Error fetching inspection:",c)}finally{n(!1)}}),[e]);return p.useEffect(()=>{l()},[l]),{inspection:r,loading:s,error:i,refetch:l}}function cle(){const[e,r]=p.useState(!1),[a,s]=p.useState(null);return{createInspection:l=>J(null,null,function*(){try{return r(!0),s(null),yield Md.createInspection(l)}catch(c){const u=c instanceof Error?c.message:"Failed to create inspection";throw s(u),c}finally{r(!1)}}),updateInspection:(l,c)=>J(null,null,function*(){try{return r(!0),s(null),yield Md.updateInspection(l,c)}catch(u){const h=u instanceof Error?u.message:"Failed to update inspection";throw s(h),u}finally{r(!1)}}),deleteInspection:l=>J(null,null,function*(){try{r(!0),s(null),yield Md.deleteInspection(l)}catch(c){const u=c instanceof Error?c.message:"Failed to delete inspection";throw s(u),c}finally{r(!1)}}),loading:e,error:a}}const dle=({isOpen:e,onClose:r,permittedIssueTypes:a=[],isAdmin:s=!0})=>{const{t:n}=sr(),[i,o]=p.useState(!1),[l,c]=p.useState(null),[u,h]=p.useState([]),[f,y]=p.useState([]),[b,w]=p.useState(!0),[v,k]=p.useState(!1),[S,N]=p.useState([]),[C,O]=p.useState(""),[T,P]=p.useState(""),[E,R]=p.useState(""),z="Inspection";p.useEffect(()=>{if(!s)return;J(null,null,function*(){try{const xe=yield(yield fetch('/api/resource/Issue Type?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"})).json();xe.data&&N(xe.data.map(ge=>ge.name))}catch(de){console.error(de)}})},[s]),p.useEffect(()=>{!s&&a.length===1?R(a[0]):R("")},[a,s]);const G=p.useCallback(()=>J(null,null,function*(){var he;o(!0),c(null);try{const de={};C&&(de.status=C),T&&(de.only_late=T),E?de.work_order_type=E:!s&&a.length===1&&(de.work_order_type=a[0]);const ge=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:z,filters:de,ignore_prepared_report:1})})).json();if(ge.exc)throw new Error(ge.exc);if(ge.message)if(((he=ge.message.columns)==null?void 0:he.length)>0&&y(ge.message.columns),ge.message.result){let be=ge.message.result;!s&&a.length>1&&!E&&(be=be.filter(K=>a.includes(K.work_order_type))),h(be)}else h([])}catch(de){console.error("Error fetching report:",de),c(de instanceof Error?de.message:"Failed to fetch report data"),h([])}finally{o(!1)}}),[C,T,E,s,a]);p.useEffect(()=>{e&&G()},[e,G]),p.useEffect(()=>{const he=de=>{de.key==="Escape"&&e&&r()};return document.addEventListener("keydown",he),()=>document.removeEventListener("keydown",he)},[e,r]),p.useEffect(()=>(document.body.style.overflow=e?"hidden":"unset",()=>{document.body.style.overflow="unset"}),[e]);const ae=()=>{O(""),P(""),(s||a.length!==1)&&R("")},ee=()=>u.filter(he=>he.status!=="TOTAL"),ne=()=>u.find(he=>he.status==="TOTAL"),te=he=>{switch(he==null?void 0:he.toLowerCase()){case"closed":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300";case"in progress":return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-300";case"open":return"bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-300";default:return"bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300"}},Y=he=>he==="Yes"?"bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-300":"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300",q=(he,de)=>{if(he==null||he==="")return"-";switch(de.fieldtype){case"Date":return new Date(he).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});case"Datetime":return new Date(he).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});default:return String(he)}},H=()=>{const he=ee();if(he.length){k(!0);try{const de=[f.map(K=>K.label).join(","),...he.map(K=>f.map(ye=>{let Z=K[ye.fieldname]||"";return typeof Z=="string"&&(Z.includes(",")||Z.includes('"')||Z.includes(`
|
||
`))&&(Z=`"${Z.replace(/"/g,'""')}"`),Z}).join(","))].join(`
|
||
`),xe=new Blob(["\uFEFF"+de],{type:"text/csv;charset=utf-8;"}),ge=URL.createObjectURL(xe),be=document.createElement("a");be.href=ge,be.download=`inspection_report_${new Date().toISOString().split("T")[0]}.csv`,be.click(),URL.revokeObjectURL(ge)}finally{k(!1)}}},U=()=>{const he=ee();if(he.length){k(!0);try{const de=Na.aoa_to_sheet([f.map(ge=>ge.label),...he.map(ge=>f.map(be=>ge[be.fieldname]||""))]);de["!cols"]=f.map(ge=>({wch:ge.width?Math.floor(ge.width/7):15}));const xe=Na.book_new();Na.book_append_sheet(xe,de,"Inspection Report"),lc(xe,`inspection_report_${new Date().toISOString().split("T")[0]}.xlsx`)}finally{k(!1)}}},re=()=>{const he=ee(),de=ne(),xe=window.open("","_blank");if(!xe){alert("Please allow popups to print.");return}xe.document.write(`<!DOCTYPE html><html><head><title>Inspection Report</title>
|
||
<style>
|
||
body{font-family:Arial,sans-serif;margin:20px}
|
||
h1{text-align:center;color:#333;margin-bottom:20px}
|
||
.meta{text-align:center;color:#666;margin-bottom:20px;font-size:12px}
|
||
.summary{display:flex;justify-content:center;gap:30px;margin-bottom:20px;padding:15px;background:#f8f9fa;border-radius:8px}
|
||
.summary-item{text-align:center}.summary-label{font-size:11px;color:#666}
|
||
.summary-value{font-size:20px;font-weight:bold;color:#333}.summary-value.late{color:#DC2626}
|
||
table{width:100%;border-collapse:collapse;font-size:11px}
|
||
th{background-color:#0D9488;color:white;padding:10px 8px;text-align:left;font-weight:600}
|
||
td{padding:8px;border-bottom:1px solid #ddd}
|
||
tr:nth-child(even){background:#f9f9f9}
|
||
.status-open{color:#2563EB;font-weight:500}
|
||
.status-closed{color:#059669;font-weight:500}
|
||
.status-inprogress{color:#D97706;font-weight:500}
|
||
.late-yes{color:#DC2626;font-weight:600}.late-no{color:#059669}
|
||
@media print{body{margin:0}tr{page-break-inside:avoid}}
|
||
</style></head><body>
|
||
<h1>Inspection Report</h1>
|
||
<div class="meta">
|
||
Generated on: ${new Date().toLocaleString()} | Records: ${he.length}
|
||
${C?` | Status: ${C}`:""}
|
||
${E?` | Dept: ${E}`:""}
|
||
${T==="Yes"?" | Only Late":""}
|
||
</div>
|
||
${de?`
|
||
<div class="summary">
|
||
<div class="summary-item"><div class="summary-label">Total Inspections</div><div class="summary-value">${de.inspection||0}</div></div>
|
||
<div class="summary-item"><div class="summary-label">WO Created</div><div class="summary-value">${de.wo_created||0}</div></div>
|
||
<div class="summary-item"><div class="summary-label">Not Closed On Time</div><div class="summary-value late">${de.not_closed_on_time||0}</div></div>
|
||
</div>`:""}
|
||
<table>
|
||
<thead><tr><th>#</th>${f.map(ge=>`<th>${ge.label}</th>`).join("")}</tr></thead>
|
||
<tbody>
|
||
${he.map((ge,be)=>`
|
||
<tr><td>${be+1}</td>${f.map(K=>{let ye=ge[K.fieldname]||"-",Z="";return K.fieldname==="status"&&(String(ye).toLowerCase()==="open"?Z="status-open":String(ye).toLowerCase()==="closed"?Z="status-closed":String(ye).toLowerCase().includes("progress")&&(Z="status-inprogress")),K.fieldname==="not_closed_on_time"&&(Z=ye==="Yes"?"late-yes":"late-no"),`<td class="${Z}">${ye}</td>`}).join("")}</tr>
|
||
`).join("")}
|
||
</tbody>
|
||
</table>
|
||
<script>window.onload=function(){window.print()}<\/script>
|
||
</body></html>`),xe.document.close()},X=()=>re();if(!e)return null;const V=ee(),I=ne(),B=!!(C||T||E),Q=[C,T,E].filter(Boolean).length,ie=s?S:a,me=s||a.length>=1;return t.jsxs("div",{className:"fixed inset-0 z-[80] bg-gray-50 dark:bg-gray-900 flex flex-col",children:[t.jsx("div",{className:"bg-gradient-to-r from-teal-600 to-cyan-600 px-6 py-4 flex-shrink-0 shadow-lg",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("button",{onClick:r,className:"p-2 text-white/80 hover:text-white hover:bg-white/20 rounded-lg transition-colors",title:"Go Back",children:t.jsx(ia,{size:18})}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ao,{className:"text-white text-xl"}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-bold text-white",children:"Inspection Report"}),t.jsxs("p",{className:"text-white/70 text-sm",children:[V.length," record",V.length!==1?"s":""," found",E&&t.jsx("span",{className:"ml-2 bg-white/20 px-2 py-0.5 rounded-full text-xs",children:E})]})]})]})]}),t.jsx("button",{onClick:r,className:"p-2 text-white/80 hover:text-white hover:bg-white/20 rounded-lg transition-colors",title:"Close (Esc)",children:t.jsx(ht,{size:20})})]})}),I&&!i&&t.jsx("div",{className:"bg-white dark:bg-gray-800 px-6 py-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs("div",{className:"bg-teal-50 dark:bg-teal-900/20 rounded-lg p-4 border border-teal-200 dark:border-teal-800",children:[t.jsx("p",{className:"text-xs text-teal-600 dark:text-teal-400 font-medium",children:"Total Inspections"}),t.jsx("p",{className:"text-2xl font-bold text-teal-700 dark:text-teal-300",children:I.inspection||0})]}),t.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:[t.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 font-medium",children:"Work Orders Created"}),t.jsx("p",{className:"text-2xl font-bold text-blue-700 dark:text-blue-300",children:I.wo_created||0})]}),t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 rounded-lg p-4 border border-red-200 dark:border-red-800",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Or,{className:"text-red-500"}),t.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 font-medium",children:"Not Closed On Time"})]}),t.jsx("p",{className:"text-2xl font-bold text-red-700 dark:text-red-300",children:I.not_closed_on_time||0})]})]})}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 px-6 py-3 border-b border-gray-200 dark:border-gray-700 flex-shrink-0 shadow-sm",children:[t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("button",{onClick:()=>w(!b),className:"flex items-center gap-2 px-4 py-2 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:[t.jsx(ds,{size:12}),"Filters",B&&t.jsx("span",{className:"bg-teal-100 dark:bg-teal-900/50 text-teal-600 dark:text-teal-400 px-2 py-0.5 rounded-full text-xs font-bold",children:Q}),b?t.jsx(Ja,{size:10}):t.jsx(Fr,{size:10})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:G,disabled:i,className:"p-2.5 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors disabled:opacity-50",title:"Refresh",children:t.jsx(Ma,{className:i?"animate-spin":"",size:14})}),t.jsxs("div",{className:"flex items-center gap-1 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg overflow-hidden",children:[t.jsxs("button",{onClick:H,disabled:!V.length||v,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as CSV",children:[t.jsx(ic,{className:"text-green-600",size:14}),t.jsx("span",{children:"CSV"})]}),t.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),t.jsxs("button",{onClick:U,disabled:!V.length||v,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as Excel",children:[t.jsx(oc,{className:"text-green-700",size:14}),t.jsx("span",{children:"Excel"})]}),t.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),t.jsxs("button",{onClick:X,disabled:!V.length,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as PDF",children:[t.jsx(_x,{className:"text-red-600",size:14}),t.jsx("span",{children:"PDF"})]}),t.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),t.jsxs("button",{onClick:re,disabled:!V.length,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Print",children:[t.jsx(yl,{className:"text-purple-600",size:14}),t.jsx("span",{children:"Print"})]})]})]})]}),b&&t.jsxs("div",{className:"mt-4 p-4 bg-gray-50 dark:bg-gray-900/50 rounded-lg border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Status"}),t.jsxs("select",{value:C,onChange:he=>O(he.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:"All Status"}),t.jsx("option",{value:"Open",children:"Open"}),t.jsx("option",{value:"In Progress",children:"In Progress"}),t.jsx("option",{value:"Closed",children:"Closed"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Show Only Late"}),t.jsxs("select",{value:T,onChange:he=>P(he.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:"All Inspections"}),t.jsx("option",{value:"Yes",children:"Only Late (Not Closed On Time)"})]})]}),me&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Technical Department"}),!s&&a.length===1?t.jsxs("div",{className:"w-full px-3 py-2 text-sm border border-gray-200 dark:border-gray-600 rounded-lg bg-gray-50 dark:bg-gray-600 text-gray-700 dark:text-gray-300 flex items-center gap-2",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-teal-400 flex-shrink-0"}),E,t.jsx("span",{className:"ml-auto text-[10px] text-gray-400 dark:text-gray-500 uppercase tracking-wide",children:"Restricted"})]}):t.jsxs("select",{value:E,onChange:he=>R(he.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:s?"All Departments":"Select Department"}),ie.map(he=>t.jsx("option",{value:he,children:he},he))]})]}),t.jsx("div",{className:"flex items-end",children:t.jsxs("button",{onClick:ae,disabled:!B,className:"px-4 py-2 text-sm font-medium text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:[t.jsx(ht,{size:12}),"Clear Filters"]})})]}),B&&t.jsxs("div",{className:"flex flex-wrap gap-2 mt-3",children:[C&&t.jsxs("span",{className:"text-xs bg-teal-50 dark:bg-teal-900/30 text-teal-700 dark:text-teal-300 border border-teal-200 dark:border-teal-700 px-2 py-1 rounded-full",children:["Status: ",C]}),T&&t.jsx("span",{className:"text-xs bg-red-50 dark:bg-red-900/30 text-red-700 dark:text-red-300 border border-red-200 dark:border-red-700 px-2 py-1 rounded-full",children:"Only Late"}),E&&t.jsxs("span",{className:"text-xs bg-indigo-50 dark:bg-indigo-900/30 text-indigo-700 dark:text-indigo-300 border border-indigo-200 dark:border-indigo-700 px-2 py-1 rounded-full",children:["Dept: ",E]})]})]})]}),t.jsxs("div",{className:"flex-1 overflow-auto p-6",children:[i&&t.jsx("div",{className:"flex items-center justify-center py-20",children:t.jsxs("div",{className:"text-center",children:[t.jsx(tr,{className:"animate-spin text-teal-500 text-5xl mx-auto mb-4"}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-lg",children:"Loading report data..."})]})}),l&&!i&&t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-8 text-center max-w-lg mx-auto",children:[t.jsx("p",{className:"text-red-600 dark:text-red-400 mb-4 text-lg",children:l}),t.jsx("button",{onClick:G,className:"px-6 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-sm font-medium transition-colors",children:"Try Again"})]}),!i&&!l&&V.length===0&&t.jsxs("div",{className:"text-center py-20",children:[t.jsx(za,{className:"text-gray-300 dark:text-gray-600 text-6xl mx-auto mb-4"}),t.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-xl",children:"No data found"}),t.jsx("p",{className:"text-gray-400 dark:text-gray-500 text-sm mt-2",children:"Try adjusting your filters"})]}),!i&&!l&&V.length>0&&t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden shadow-sm",children:t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 sticky top-0",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-600 dark:text-gray-300 uppercase tracking-wider w-16",children:"#"}),f.map((he,de)=>t.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-600 dark:text-gray-300 uppercase tracking-wider whitespace-nowrap",style:{minWidth:he.width||120},children:he.label},de))]})}),t.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:V.map((he,de)=>t.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[t.jsx("td",{className:"px-4 py-3 text-sm text-gray-500 dark:text-gray-400 font-medium",children:de+1}),f.map((xe,ge)=>{const be=he[xe.fieldname],K=q(be,xe);return xe.fieldname==="status"?t.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:t.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${te(be)}`,children:K})},ge):xe.fieldname==="wo_created"?t.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:t.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${be==="Yes"?"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300":"bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-400"}`,children:K})},ge):xe.fieldname==="not_closed_on_time"?t.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:t.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${Y(be)}`,children:K})},ge):xe.fieldname==="inspection"?t.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:t.jsx("a",{href:`/asm_app/inspections/${be}`,target:"_blank",rel:"noopener noreferrer",className:"text-teal-600 dark:text-teal-400 hover:underline font-medium text-sm",children:K})},ge):t.jsx("td",{className:"px-4 py-3 text-sm text-gray-700 dark:text-gray-300",title:typeof be=="string"&&be.length>50?be:void 0,children:t.jsx("div",{className:"max-w-xs truncate",children:K})},ge)})]},de))})]})})})]}),t.jsx("div",{className:"bg-white dark:bg-gray-800 px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex-shrink-0 shadow-inner",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Showing ",V.length," record",V.length!==1?"s":"",B&&" (filtered)",E&&t.jsxs("span",{className:"ml-2 text-teal-600 dark:text-teal-400",children:["· ",E]})]}),t.jsx("button",{onClick:r,className:"px-6 py-2 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-lg text-sm font-medium transition-colors",children:"Close"})]})})]})},ule=({isOpen:e,onClose:r,selectedCount:a,totalCount:s,pageCount:n,onExport:i,isExporting:o,exportColumns:l})=>{const{t:c}=sr(),[u,h]=p.useState(a>0?"selected":"all_with_filters"),[f,y]=p.useState("csv"),[b,w]=p.useState(l.filter(N=>N.default).map(N=>N.key));p.useEffect(()=>{a>0?h("selected"):h("all_with_filters")},[a]);const v=N=>{w(C=>C.includes(N)?C.filter(O=>O!==N):[...C,N])},k=()=>w(l.map(N=>N.key)),S=()=>w(l.filter(N=>N.default).map(N=>N.key));return e?t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] overflow-hidden animate-scale-in",children:[t.jsx("div",{className:"bg-gradient-to-r from-teal-500 to-teal-600 px-6 py-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Sa,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:c("inspections.export.title")})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:o,children:t.jsx(ht,{size:20})})]})}),t.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-180px)]",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:c("inspections.export.selectData")}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${u==="selected"?"border-teal-500 bg-teal-50 dark:bg-teal-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"} ${a===0?"opacity-50 cursor-not-allowed":""}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"selected",checked:u==="selected",onChange:()=>h("selected"),disabled:a===0,className:"text-teal-600 focus:ring-teal-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("inspections.export.selectedRows")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("inspections.export.selectedCount",{count:a})})]}),a>0&&t.jsxs("span",{className:"bg-teal-100 dark:bg-teal-900/40 text-teal-700 dark:text-teal-300 px-2 py-1 rounded text-xs font-medium",children:[a," selected"]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${u==="all_on_page"?"border-teal-500 bg-teal-50 dark:bg-teal-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"all_on_page",checked:u==="all_on_page",onChange:()=>h("all_on_page"),className:"text-teal-600 focus:ring-teal-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("inspections.export.currentPage")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("inspections.export.currentPageCount",{count:n})})]}),t.jsxs("span",{className:"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300 px-2 py-1 rounded text-xs font-medium",children:[n," rows"]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${u==="all_with_filters"?"border-teal-500 bg-teal-50 dark:bg-teal-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"all_with_filters",checked:u==="all_with_filters",onChange:()=>h("all_with_filters"),className:"text-teal-600 focus:ring-teal-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("inspections.export.allWithFilters")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("inspections.export.allWithFiltersCount",{count:s})})]}),t.jsxs("span",{className:"bg-purple-100 dark:bg-purple-900/40 text-purple-700 dark:text-purple-300 px-2 py-1 rounded text-xs font-medium",children:[s," total"]})]})]})]}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:c("inspections.export.exportFormat")}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${f==="csv"?"border-teal-500 bg-teal-50 dark:bg-teal-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"format",value:"csv",checked:f==="csv",onChange:()=>y("csv"),className:"text-teal-600 focus:ring-teal-500"}),t.jsx(ic,{className:"text-teal-600 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("inspections.export.csv")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:c("inspections.export.csvDesc")})]})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${f==="excel"?"border-teal-500 bg-teal-50 dark:bg-teal-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"format",value:"excel",checked:f==="excel",onChange:()=>y("excel"),className:"text-teal-600 focus:ring-teal-500"}),t.jsx(oc,{className:"text-green-700 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("inspections.export.excel")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:c("inspections.export.excelDesc")})]})]})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:c("inspections.export.columnsToExport")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:k,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:c("inspections.export.selectAll")}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{onClick:S,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:c("inspections.export.resetToDefault")})]})]}),t.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2 max-h-48 overflow-y-auto p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg",children:l.map(N=>t.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${b.includes(N.key)?"bg-teal-100 dark:bg-teal-900/30 text-teal-800 dark:text-teal-300":"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-400"}`,children:[t.jsx("input",{type:"checkbox",checked:b.includes(N.key),onChange:()=>v(N.key),className:"rounded text-teal-600 focus:ring-teal-500"}),t.jsx("span",{className:"text-sm truncate",children:c(N.labelKey)})]},N.key))}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:c("inspections.export.columnsSelected",{count:b.length})})]})]}),t.jsxs("div",{className:"px-6 py-4 bg-gray-50 dark:bg-gray-900/50 border-t border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[u==="selected"&&c("inspections.export.exportingSelected",{count:a}),u==="all_on_page"&&c("inspections.export.exportingPage",{count:n}),u==="all_with_filters"&&c("inspections.export.exportingAll",{count:s})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{onClick:r,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",disabled:o,children:c("common.cancel")}),t.jsx("button",{onClick:()=>i(u,f,b),disabled:b.length===0||o,className:"px-4 py-2 text-sm font-medium text-white bg-teal-600 hover:bg-teal-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:o?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),c("inspections.export.exporting")]}):t.jsxs(t.Fragment,{children:[t.jsx(qc,{}),c("inspections.export.exportButton")]})})]})]})]})}):null},mle=e=>{switch(e==null?void 0:e.toLowerCase()){case"open":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";case"in progress":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300";case"closed":return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300";case"pending review":return"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}},hle=e=>{switch(e==null?void 0:e.toLowerCase()){case"draft":return"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-300";case"sent to supervisor":return"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300";case"closed":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}},ple=e=>{switch(e==null?void 0:e.toLowerCase()){case"inspection":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";case"safety inspection":return"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}},gle=()=>{const{t:e}=sr(),r=hr(),[a,s]=_a(),n=p.useRef(s);p.useEffect(()=>{n.current=s},[s]);const[i,o]=p.useState([]),[l,c]=p.useState(!0),u=p.useMemo(()=>{const Ae=parseInt(a.get("page")||"1",10);return Number.isNaN(Ae)||Ae<1?1:Ae},[a]),h=p.useCallback(Ae=>{const ke=typeof Ae=="function"?Ae(u):Ae;s(Be=>{const yt=new URLSearchParams(Be);return yt.set("page",String(ke)),yt})},[u,s]),f=[{key:"name",labelKey:"inspections.export.inspectionId",default:!0},{key:"inspection_type",labelKey:"inspections.export.inspectionType",default:!0},{key:"status",labelKey:"inspections.export.status",default:!0},{key:"workflow_state",labelKey:"inspections.export.workflowState",default:!0},{key:"inspection_date",labelKey:"inspections.export.inspectionDate",default:!0},{key:"target_closure_date",labelKey:"inspections.export.targetClosureDate",default:!0},{key:"requested_by",labelKey:"inspections.export.requestedBy",default:!0},{key:"work_order_type",labelKey:"inspections.export.technicalDepartment",default:!1},{key:"extension_no",labelKey:"inspections.export.extensionNo",default:!1},{key:"department",labelKey:"inspections.export.department",default:!1},{key:"location",labelKey:"inspections.export.location",default:!1},{key:"assigned_technician",labelKey:"inspections.export.assignedTechnician",default:!1},{key:"linked_corrective_wo_no",labelKey:"inspections.export.linkedWorkOrder",default:!0},{key:"observation_note",labelKey:"inspections.export.observationNote",default:!1},{key:"technical_response",labelKey:"inspections.export.technicalResponse",default:!1},{key:"creation",labelKey:"inspections.export.createdOn",default:!1},{key:"modified",labelKey:"inspections.export.modifiedOn",default:!1},{key:"owner",labelKey:"inspections.export.createdBy",default:!1}],[y]=p.useState(20),[b,w]=p.useState(!1),[v,k]=p.useState(new Set),[S,N]=p.useState(!1),[C,O]=p.useState(!1),[T,P]=p.useState(null),[E,R]=p.useState(!1),z=["System Manager","Contractor Supervisor","Contractor Manager","Work Control"],[G,ae]=p.useState(!1),[ee,ne]=p.useState(!1),[te,Y]=p.useState([]),[q,H]=p.useState(!1);p.useEffect(()=>{J(null,null,function*(){var ke,Be,yt;try{const Ke=yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:z.join(",")})})).json();if(Ke.message){const ve=Ke.message.has_role;ae(ve),ne(ve)}const oe=yield(yield fetch("/api/method/asset_lite.api.user_roles.get_user_roles",{credentials:"include"})).json(),_e=Array.isArray(oe.message)?oe.message:[];Y(_e),H(_e.includes("System Manager"));try{const Ce=(yield(yield fetch("/api/method/asset_lite.api.userperm_api.get_permission_filters?target_doctype=Work_Order",{credentials:"include"})).json()).message||{};c((ke=Ce.is_admin)!=null?ke:!0),o(((yt=(Be=Ce.restrictions)==null?void 0:Be["Issue Type"])==null?void 0:yt.values)||[])}catch(ve){console.error("Error fetching issue type permissions:",ve),c(!0),o([])}}catch(Me){console.error("Error checking permissions:",Me),ae(!1),ne(!1)}})},[]);const[U,re]=p.useState(()=>a.get("date_filter_by")||""),[X,V]=p.useState(()=>a.get("date_start")||""),[I,B]=p.useState(()=>a.get("date_end")||""),[Q,ie]=p.useState(()=>a.get("status")||""),[me,he]=p.useState(()=>a.get("workflow_state")||""),[de,xe]=p.useState(()=>a.get("inspection_type")||""),[ge,be]=p.useState(()=>a.get("work_order")||""),[K,ye]=p.useState(()=>a.get("department")||""),[Z,M]=p.useState(()=>a.get("sort_by")||"creation desc"),[we,pe]=p.useState(!1),[le,Fe]=p.useState(0),[ze,Re]=p.useState([]),[De,Et]=p.useState(!1),[jt,Ie]=p.useState("");p.useEffect(()=>{const Ae=localStorage.getItem("inspectionFilterPresets");Ae&&Re(JSON.parse(Ae))},[]);const $e=U&&(X||I);p.useEffect(()=>{const Ae=[Q,me,de,ge,K].filter(Boolean).length+($e?1:0);Fe(Ae)},[Q,me,de,ge,K,$e]);const Qe=p.useMemo(()=>{const Ae={};return Q&&(Ae.status=Q),me&&(Ae.workflow_state=me),de&&(Ae.inspection_type=de),ge&&(Ae.linked_corrective_wo_no=ge),K&&(Ae.work_order_type=K),Object.assign(Ae,kl(U,X,I)),Ae.custom_delete_status=["!=","Deleted"],Ae},[Q,me,de,ge,K,U,X,I]),at=["creation desc","creation asc","modified desc","modified asc","name asc","name desc"].includes(Z)?Z:"creation desc",{inspections:Ct,loading:vt,error:er,totalCount:nr,refetch:dt}=ole({filters:Qe,limit_start:(u-1)*y,limit_page_length:y,order_by:at});p.useEffect(()=>{!vt&&!b&&w(!0)},[vt,b]);const He=p.useRef(!1);p.useEffect(()=>{if(!He.current){He.current=!0;return}n.current(Ae=>{const ke=new URLSearchParams(Ae);return U?ke.set("date_filter_by",U):ke.delete("date_filter_by"),X?ke.set("date_start",X):ke.delete("date_start"),I?ke.set("date_end",I):ke.delete("date_end"),Q?ke.set("status",Q):ke.delete("status"),me?ke.set("workflow_state",me):ke.delete("workflow_state"),de?ke.set("inspection_type",de):ke.delete("inspection_type"),ge?ke.set("work_order",ge):ke.delete("work_order"),K?ke.set("department",K):ke.delete("department"),Z&&Z!=="creation desc"?ke.set("sort_by",Z):ke.delete("sort_by"),ke.set("page","1"),ke})},[U,X,I,Q,me,de,ge,K,Z]),p.useEffect(()=>{k(new Set)},[U,X,I,Q,me,de,ge,K,u]);const it=Ae=>{switch(Ae){case"Delete Request With Supervisor":return"bg-orange-50 dark:bg-orange-900/10";case"Delete Request With CM":return"bg-yellow-50 dark:bg-yellow-900/10";case"Deleted":return"bg-red-50 dark:bg-red-900/10";default:return""}},Ue=Ae=>Ae?new Date(Ae).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-",Ve=()=>{re(""),V(""),B(""),M("creation desc"),ie(""),he(""),xe(""),be(""),ye(""),n.current(Ae=>{const ke=new URLSearchParams(Ae);return ke.delete("date_filter_by"),ke.delete("date_start"),ke.delete("date_end"),ke.delete("sort_by"),ke.delete("status"),ke.delete("workflow_state"),ke.delete("inspection_type"),ke.delete("work_order"),ke.delete("department"),ke.set("page","1"),ke})},lt=$e||!!Q||!!me||!!de||!!ge||!!K,st=()=>{if(!jt.trim()){alert(e("common.enterFilterName"));return}const Ae={id:Date.now(),name:jt,filters:{dateFilterBy:U,dateStart:X,dateEnd:I,sortBy:Z,statusFilter:Q,workflowStateFilter:me,inspectionTypeFilter:de,workOrderFilter:ge,departmentFilter:K}},ke=[...ze,Ae];Re(ke),Ie(""),Et(!1),localStorage.setItem("inspectionFilterPresets",JSON.stringify(ke))},Mt=Ae=>{const ke=Ae.filters;re(ke.dateFilterBy||""),V(ke.dateStart||""),B(ke.dateEnd||""),M(ke.sortBy||"creation desc"),ie(ke.statusFilter||""),he(ke.workflowStateFilter||""),xe(ke.inspectionTypeFilter||""),be(ke.workOrderFilter||""),ye(ke.departmentFilter||"")},Ot=Ae=>{const ke=ze.filter(Be=>Be.id!==Ae);Re(ke),localStorage.setItem("inspectionFilterPresets",JSON.stringify(ke))},Pt=Ae=>{k(ke=>{const Be=new Set(ke);return Be.has(Ae)?Be.delete(Ae):Be.add(Ae),Be})},zt=()=>{v.size===Ct.length?k(new Set):k(new Set(Ct.map(Ae=>Ae.name)))},Tt=Ct.length>0&&v.size===Ct.length,Gt=v.size>0&&v.size<Ct.length,Ye=p.useCallback(()=>J(null,null,function*(){const Ae=[];let ke=0;const Be=100;let yt=!0;const Me=xa(Qe);for(;yt;)try{const oe=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Inspection",filters:Me.length>0?Me:{},fields:["*"],limit_start:ke*Be,limit_page_length:Be,order_by:at})})).json()).message||[];Ae.push(...oe),oe.length<Be?yt=!1:ke++,ke>100&&(console.warn("Export safety limit reached"),yt=!1)}catch(Ke){throw console.error("Error fetching inspections for export:",Ke),Ke}return Ae}),[Qe,at]),kt=(Ae,ke,Be)=>J(null,null,function*(){O(!0);try{let yt=[];switch(Ae){case"selected":yt=Ct.filter(Ke=>v.has(Ke.name));break;case"all_on_page":yt=Ct;break;case"all_with_filters":yt=yield Ye();break}if(yt.length===0){alert(e("assets.noDataToExport"));return}const Me=Be.map(Ke=>{var Xe;return e(((Xe=f.find(oe=>oe.key===Ke))==null?void 0:Xe.labelKey)||Ke)});if(ke==="csv"){const Ke=[Me.join(","),...yt.map(ve=>Be.map(Se=>{let Ce=ve[Se]||"";return typeof Ce=="string"&&(Ce.includes(",")||Ce.includes('"')||Ce.includes(`
|
||
`))&&(Ce=`"${Ce.replace(/"/g,'""')}"`),Ce}).join(","))].join(`
|
||
`),Xe=new Blob(["\uFEFF"+Ke],{type:"text/csv;charset=utf-8;"}),oe=URL.createObjectURL(Xe),_e=document.createElement("a");_e.href=oe,_e.download=`inspections_export_${new Date().toISOString().split("T")[0]}.csv`,_e.click(),URL.revokeObjectURL(oe)}else if(ke==="excel"){const Ke=[Me,...yt.map(_e=>Be.map(ve=>_e[ve]||""))],Xe=Na.aoa_to_sheet(Ke),oe=Na.book_new();Na.book_append_sheet(oe,Xe,"Inspections"),lc(oe,`inspections_export_${new Date().toISOString().split("T")[0]}.xlsx`)}N(!1),k(new Set)}catch(yt){console.error("Export failed:",yt),alert(`Export failed: ${yt instanceof Error?yt.message:"Unknown error"}`)}finally{O(!1)}}),Yt=Ae=>J(null,null,function*(){try{if(!(yield fetch(`/api/resource/Inspection/${Ae}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to delete");P(null),dt(),alert(e("inspections.deletedSuccessfully"))}catch(ke){alert(`Failed to delete: ${ke instanceof Error?ke.message:"Unknown error"}`)}});return vt&&!b?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-teal-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("inspections.loadingInspections")})]})}):er?t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:e("inspections.errorLoadingInspections")}),t.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:er}),t.jsx("button",{onClick:dt,className:"bg-teal-600 hover:bg-teal-700 text-white px-4 py-2 rounded",children:e("common.tryAgain")})]})}):t.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsx("div",{children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ao,{className:"text-3xl text-teal-600 dark:text-teal-400"}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:e("inspections.title")}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[e("common.total"),": ",nr,v.size>0&&t.jsxs("span",{className:"ml-2 text-teal-600 dark:text-teal-400",children:["• ",v.size," selected"]}),vt&&b&&t.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-teal-600 dark:text-teal-400",children:[t.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-teal-500"}),"Updating..."]})]})]})]})}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("button",{onClick:()=>pe(!we),className:`px-4 py-2 rounded-lg flex items-center gap-2 transition-colors ${we||lt?"bg-teal-100 text-teal-700 dark:bg-teal-900/30 dark:text-teal-300":"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600"}`,children:[t.jsx(ds,{}),e("listPages.filters"),le>0&&t.jsx("span",{className:"bg-teal-600 text-white text-xs px-1.5 py-0.5 rounded-full",children:le})]}),t.jsxs("button",{onClick:dt,disabled:vt,className:"px-4 py-2 rounded-lg bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 flex items-center gap-2 disabled:opacity-50",children:[t.jsx(Ma,{className:vt?"animate-spin":""}),e("listPages.refresh")]}),t.jsxs("button",{onClick:()=>R(!0),className:"bg-cyan-600 hover:bg-cyan-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",children:[t.jsx(ao,{}),t.jsx("span",{className:"font-medium",children:e("inspections.inspectionReport")})]}),t.jsxs("button",{onClick:()=>N(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",disabled:nr===0,children:[t.jsx(Sa,{}),t.jsx("span",{className:"font-medium",children:e("common.export")}),v.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:v.size})]}),ee&&t.jsxs("button",{onClick:()=>r("/inspections/new"),className:"bg-teal-600 hover:bg-teal-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow-lg transition-all hover:shadow-xl",children:[t.jsx(Rr,{}),t.jsx("span",{className:"font-medium",children:e("inspections.newInspection")})]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-4",children:[t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e("common.total")}),t.jsx("p",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:nr})]}),t.jsx(ao,{className:"text-3xl text-teal-500"})]})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e("inspections.stats.draft")}),t.jsx("p",{className:"text-2xl font-bold text-orange-600",children:Ct.filter(Ae=>Ae.workflow_state==="Draft").length})]}),t.jsx("div",{className:"w-10 h-10 rounded-full bg-orange-100 dark:bg-orange-900/30 flex items-center justify-center",children:t.jsx("span",{className:"text-orange-600 font-bold",children:"D"})})]})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e("inspections.stats.pendingApproval")}),t.jsx("p",{className:"text-2xl font-bold text-purple-600",children:Ct.filter(Ae=>Ae.workflow_state==="Sent to Supervisor").length})]}),t.jsx("div",{className:"w-10 h-10 rounded-full bg-purple-100 dark:bg-purple-900/30 flex items-center justify-center",children:t.jsx("span",{className:"text-purple-600 font-bold",children:"P"})})]})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e("inspections.stats.closed")}),t.jsx("p",{className:"text-2xl font-bold text-green-600",children:Ct.filter(Ae=>Ae.workflow_state==="Closed").length})]}),t.jsx("div",{className:"w-10 h-10 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:t.jsx("span",{className:"text-green-600 font-bold",children:"C"})})]})})]}),we&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-4",children:[t.jsx("div",{className:"bg-gradient-to-r from-teal-500 to-teal-600 dark:from-teal-600 dark:to-teal-700 px-4 py-3 rounded-t-lg",children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ds,{className:"text-white",size:16}),t.jsx("h3",{className:"text-white font-semibold text-sm",children:e("listPages.filters")}),le>0&&t.jsx("span",{className:"bg-white text-teal-600 px-2 py-0.5 rounded-full text-xs font-bold",children:le})]}),lt&&t.jsx("div",{className:"flex-1 overflow-x-auto scrollbar-hide mx-2",children:t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[Q&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-blue-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("inspections.filterStatus"),":"]})," ",e(`inspections.status.${(Q||"").toLowerCase().replace(/\s+/g,"_")}`,{defaultValue:Q}),t.jsx("button",{onClick:()=>ie(""),className:"hover:text-red-500",children:t.jsx(ht,{className:"text-[9px]"})})]}),me&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-purple-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("inspections.filterWorkflow"),":"]})," ",e(`inspections.workflowState.${(me||"").toLowerCase().replace(/\s+/g,"_")}`,{defaultValue:me}),t.jsx("button",{onClick:()=>he(""),className:"hover:text-red-500",children:t.jsx(ht,{className:"text-[9px]"})})]}),de&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-teal-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("inspections.filterType"),":"]})," ",e(`inspections.typeMap.${(de||"").toLowerCase().replace(/\s+/g,"_")}`,{defaultValue:de}),t.jsx("button",{onClick:()=>xe(""),className:"hover:text-red-500",children:t.jsx(ht,{className:"text-[9px]"})})]}),ge&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-orange-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("inspections.filterWorkOrder"),":"]})," ",ge,t.jsx("button",{onClick:()=>be(""),className:"hover:text-red-500",children:t.jsx(ht,{className:"text-[9px]"})})]}),K&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-green-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("inspections.filterDepartment"),":"]})," ",K,t.jsx("button",{onClick:()=>ye(""),className:"hover:text-red-500",children:t.jsx(ht,{className:"text-[9px]"})})]}),$e&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("filters.filterBy"),":"]})," ",e(U==="creation"?"filters.createdDate":"filters.latestModifiedDate")," ",X&&` ${X}`," ",I&&` - ${I}`,t.jsx("button",{onClick:()=>{re(""),V(""),B("")},className:"hover:text-red-500",children:t.jsx(ht,{className:"text-[9px]"})})]})]})}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[le>0&&t.jsxs("button",{onClick:()=>Et(!0),className:"px-3 py-1.5 bg-white text-teal-600 hover:bg-teal-50 rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[t.jsx(ta,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:e("common.save")})]}),lt&&t.jsxs("button",{onClick:Ve,className:"px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[t.jsx(ht,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:e("common.clearFilters")})]})]})]})}),t.jsxs("div",{className:"p-4",children:[ze.length>0&&t.jsxs("div",{className:"mb-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[t.jsx(a0,{className:"text-yellow-500",size:12}),e("inspections.savedFilters")]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:ze.map(Ae=>t.jsxs("div",{className:"group relative inline-flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-teal-100 to-blue-100 dark:from-teal-900/30 dark:to-blue-900/30 border border-teal-200 dark:border-teal-700 rounded-lg hover:shadow-md transition-all",children:[t.jsx("button",{onClick:()=>Mt(Ae),className:"text-xs font-medium text-teal-700 dark:text-teal-300",children:Ae.name}),t.jsx("button",{onClick:()=>Ot(Ae.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:t.jsx(wr,{size:10})})]},Ae.id))})]}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 p-3 rounded-lg",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-3",children:[t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.sortBy")}),t.jsxs("select",{value:Z,onChange:Ae=>{M(Ae.target.value),h(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"creation desc",children:e("filters.sortCreationNewest")}),t.jsx("option",{value:"creation asc",children:e("filters.sortCreationOldest")}),t.jsx("option",{value:"modified desc",children:e("filters.sortModifiedNewest")}),t.jsx("option",{value:"modified asc",children:e("filters.sortModifiedOldest")}),t.jsx("option",{value:"name asc",children:e("filters.sortNameAsc")}),t.jsx("option",{value:"name desc",children:e("filters.sortNameDesc")})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.filterBy")}),t.jsxs("select",{value:U,onChange:Ae=>{const ke=Ae.target.value;re(ke),h(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("filters.filterBy")}),t.jsx("option",{value:"creation",children:e("filters.createdDate")}),t.jsx("option",{value:"modified",children:e("filters.latestModifiedDate")})]})]}),U&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.startDate")}),t.jsx("input",{type:"date",value:X,onChange:Ae=>{const ke=Ae.target.value;V(ke),I&&ke>I&&B(ke),h(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.endDate")}),t.jsx("input",{type:"date",value:I,onChange:Ae=>{B(Ae.target.value),h(1)},min:X||void 0,className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.status")}),t.jsxs("select",{value:Q,onChange:Ae=>{ie(Ae.target.value),h(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("filters.allStatuses")}),t.jsx("option",{value:"Open",children:e("inspections.status.open")}),t.jsx("option",{value:"In Progress",children:e("inspections.status.in_progress")}),t.jsx("option",{value:"Pending Review",children:e("inspections.status.pending_review")}),t.jsx("option",{value:"Closed",children:e("inspections.status.closed")})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.workflowState")}),t.jsxs("select",{value:me,onChange:Ae=>{he(Ae.target.value),h(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("filters.allStates")}),t.jsx("option",{value:"Draft",children:e("inspections.workflowState.draft")}),t.jsx("option",{value:"Sent to Work Control",children:e("inspections.workflowState.sent_to_work_control")}),t.jsx("option",{value:"Sent to technician",children:e("inspections.workflowState.sent_to_technician")}),t.jsx("option",{value:"Sent to Supervisor",children:e("inspections.workflowState.sent_to_supervisor")}),t.jsx("option",{value:"Closed",children:e("inspections.workflowState.closed")})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("inspections.type")}),t.jsxs("select",{value:de,onChange:Ae=>{xe(Ae.target.value),h(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("filters.allTypes")}),t.jsx("option",{value:"Inspection",children:e("inspections.typeMap.inspection")}),t.jsx("option",{value:"Safety Inspection",children:e("inspections.typeMap.safety_inspection")})]})]}),t.jsxs("div",{className:"relative z-[60]",children:[t.jsx(Je,{label:e("inspections.filterWorkOrder"),doctype:"Work_Order",value:ge,onChange:Ae=>{be(Ae),h(1)},placeholder:e("inspections.selectWorkOrder"),disabled:!1,compact:!0,filters:{custom_delete_status:["!=","Deleted"]}}),ge&&t.jsx("button",{onClick:()=>be(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[59]",children:[t.jsx(Je,{label:e("inspections.technicalDepartment"),doctype:"Issue Type",value:K,onChange:Ae=>{ye(Ae),h(1)},placeholder:e("inspections.selectDepartment"),disabled:!1,compact:!0}),K&&t.jsx("button",{onClick:()=>ye(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(ht,{size:10})})]})]})})]})]}),De&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 animate-scale-in",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:e("common.saveFilterPreset")}),t.jsx("input",{type:"text",value:jt,onChange:Ae=>Ie(Ae.target.value),onKeyDown:Ae=>{Ae.key==="Enter"&&(Ae.preventDefault(),st())},placeholder:e("common.enterFilterName"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white mb-4",autoFocus:!0}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:()=>{Et(!1),Ie("")},className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",children:e("common.cancel")}),t.jsxs("button",{onClick:st,className:"px-4 py-2 text-sm font-medium text-white bg-teal-600 hover:bg-teal-700 rounded-md transition-colors flex items-center gap-2",children:[t.jsx(ta,{size:12}),e("common.saveFilter")]})]})]})}),t.jsx(ule,{isOpen:S,onClose:()=>N(!1),selectedCount:v.size,totalCount:nr,pageCount:Ct.length,onExport:kt,isExporting:C,exportColumns:f}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-200 dark:border-gray-700 overflow-hidden relative",children:[vt&&b&&t.jsx("div",{className:"absolute inset-0 bg-white/60 dark:bg-gray-800/60 flex items-center justify-center z-10 backdrop-blur-[1px]",children:t.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-gray-700 px-4 py-2 rounded-lg shadow-lg",children:[t.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-teal-500"}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:e("common.filtering")})]})}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left",children:t.jsx("button",{onClick:zt,className:"text-gray-500 dark:text-gray-400 hover:text-teal-600 dark:hover:text-teal-400 transition-colors",title:e(Tt?"common.deselectAllTitle":"common.selectAllTitle"),children:Tt?t.jsx(Ra,{className:"text-teal-600 dark:text-teal-400",size:18}):Gt?t.jsxs("div",{className:"relative",children:[t.jsx(Ur,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Ur,{size:18})})}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("inspections.inspectionId")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("inspections.type")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("filters.status")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("inspections.workflowStateHeader")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("inspections.targetDate")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("inspections.requestedBy")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("inspections.linkedWorkOrder")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("listPages.actions")})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:Ct.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:9,className:"px-4 py-12 text-center text-gray-500 dark:text-gray-400",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx(ao,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("inspections.noInspectionsFound")}),lt?t.jsx("button",{onClick:Ve,className:"mt-4 text-teal-600 dark:text-teal-400 hover:underline",children:e("common.clearFilters")}):ee?t.jsx("button",{onClick:()=>r("/inspections/new"),className:"mt-4 text-teal-600 dark:text-teal-400 hover:underline",children:e("inspections.createFirstInspection")}):null]})})}):Ct.map(Ae=>{var ke;return t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 cursor-pointer transition-colors ${v.has(Ae.name)?"bg-teal-50 dark:bg-teal-900/20":it(Ae.custom_delete_status)}`,title:Ae.custom_delete_status?`Delete Status: ${Ae.custom_delete_status}`:void 0,onClick:()=>r(`/inspections/${Ae.name}`),children:[t.jsx("td",{className:"px-4 py-3",onClick:Be=>Be.stopPropagation(),children:t.jsx("button",{onClick:()=>Pt(Ae.name),className:"text-gray-500 dark:text-gray-400 hover:text-teal-600 dark:hover:text-teal-400 transition-colors",children:v.has(Ae.name)?t.jsx(Ra,{className:"text-teal-600 dark:text-teal-400",size:18}):t.jsx(Ur,{size:18})})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:"text-sm font-medium text-teal-600 dark:text-teal-400",children:Ae.name})}),t.jsx("td",{className:"px-4 py-3",children:Ae.inspection_type?t.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${ple(Ae.inspection_type)}`,children:e(`inspections.typeMap.${(Ae.inspection_type||"").toLowerCase().replace(/\s+/g,"_")}`,{defaultValue:Ae.inspection_type})}):t.jsx("span",{className:"text-gray-400",children:"-"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${mle(Ae.status)}`,children:Ae.status?e(`inspections.status.${(Ae.status||"").toLowerCase().replace(/\s+/g,"_")}`,{defaultValue:Ae.status}):"-"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${hle(Ae.workflow_state)}`,children:Ae.workflow_state?e(`inspections.workflowState.${(Ae.workflow_state||"").toLowerCase().replace(/\s+/g,"_")}`,{defaultValue:Ae.workflow_state}):"-"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:Ue(Ae.target_closure_date||"")})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300 line-clamp-1",children:Ae.requested_by||"-"})}),t.jsx("td",{className:"px-4 py-3",onClick:Be=>Be.stopPropagation(),children:Ae.linked_corrective_wo_no?t.jsxs("button",{onClick:()=>r(`/work-orders/${Ae.linked_corrective_wo_no}`),className:"text-sm text-blue-600 dark:text-blue-400 hover:underline flex items-center gap-1",children:[Ae.linked_corrective_wo_no,t.jsx(dn,{size:10})]}):t.jsx("span",{className:"text-gray-400",children:"-"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-1",onClick:Be=>Be.stopPropagation(),children:[t.jsx("button",{onClick:()=>r(`/inspections/${Ae.name}`),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded transition-colors",title:e("inspections.viewDetails"),children:t.jsx(Ps,{})}),t.jsx("button",{onClick:()=>r(`/inspections/${Ae.name}?edit=true`),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:e("inspections.editInspection"),children:t.jsx(qr,{})}),t.jsx("div",{onClick:Be=>Be.stopPropagation(),children:t.jsx(n0,{doctype:"Inspection",docname:Ae.name,currentDeleteStatus:(ke=Ae.custom_delete_status)!=null?ke:null,userRoles:te,isSystemManager:q,triggerMode:!0,redirectOnDelete:"/inspections",onStatusChange:()=>dt()})})]})})]},Ae.name)})})]})}),t.jsx(_l,{currentPage:u,totalCount:nr,pageSize:y,itemLabel:e("pagination.inspections"),onPageChange:Ae=>h(Ae)})]}),T&&t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx("div",{className:"flex-shrink-0 w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:t.jsx(wr,{className:"text-red-600 dark:text-red-400 text-xl"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:e("inspections.deleteInspection")}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:e("inspections.deleteConfirmMessage")}),t.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-md p-3 mb-4",children:t.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[t.jsxs("strong",{children:[e("inspections.inspectionId"),":"]})," ",T]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>P(null),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-lg transition-colors",children:e("common.cancel")}),t.jsxs("button",{onClick:()=>Yt(T),className:"px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors flex items-center gap-2",children:[t.jsx(wr,{}),e("common.delete")]})]})]})]})})}),t.jsx(dle,{isOpen:E,onClose:()=>R(!1),permittedIssueTypes:i,isAdmin:l}),t.jsx("style",{children:`
|
||
@keyframes scale-in { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
|
||
.animate-scale-in { animation: scale-in 0.2s ease-out; }
|
||
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }
|
||
.scrollbar-hide::-webkit-scrollbar { display: none; }
|
||
`})]})},af=()=>new Date().toISOString().split("T")[0],fle=e=>{switch(e==null?void 0:e.toLowerCase()){case"open":return{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-800 dark:text-blue-300",border:"border-blue-200 dark:border-blue-800"};case"in progress":return{bg:"bg-yellow-100 dark:bg-yellow-900/30",text:"text-yellow-800 dark:text-yellow-300",border:"border-yellow-200 dark:border-yellow-800"};case"closed":return{bg:"bg-gray-100 dark:bg-gray-700",text:"text-gray-800 dark:text-gray-300",border:"border-gray-200 dark:border-gray-600"};default:return{bg:"bg-gray-100 dark:bg-gray-700",text:"text-gray-800 dark:text-gray-300",border:"border-gray-200 dark:border-gray-600"}}},xle=()=>{var Gt;const{t:e}=sr(),{inspectionName:r}=hs(),[a]=_a(),s=hr(),n=r==="new",i=a.get("edit")==="true",o=["System Manager","Contractor Supervisor","Contractor Manager"],[l,c]=p.useState(!1);p.useEffect(()=>{J(null,null,function*(){try{const Yt=yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:o.join(",")})})).json();Yt.message&&c(Yt.message.has_role)}catch(kt){console.error("Error checking permissions:",kt),c(!1)}})},[]);const[u,h]=p.useState([]),[f,y]=p.useState(!1);p.useEffect(()=>{J(null,null,function*(){try{const kt=yield At.apiCall("/api/method/asset_lite.api.user_roles.get_user_roles");Array.isArray(kt)?h(kt):kt!=null&&kt.message&&h(kt.message)}catch(kt){console.error("Error fetching roles:",kt)}finally{y(!0)}})},[]);const[b,w]=p.useState(!1),[v,k]=p.useState(!1);p.useEffect(()=>{J(null,null,function*(){try{const Yt=yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:o.join(",")})})).json();Yt.message&&c(Yt.message.has_role)}catch(kt){console.error("Error checking permissions:",kt),c(!1)}})},[]);const[S,N]=p.useState({inspection_type:"",status:"Open",inspection_date:n?af():"",target_closure_date:"",requested_by:"",technician_department:"",linked_corrective_wo_no:"",observation_note:"",technical_response:"",workflow_state:"Draft",work_order_type:"",department:"",location:"",assigned_technician:"",attachment:"",attachment_on_close:"",extension_no:"",docstatus:0}),[C,O]=p.useState(n),[T,P]=p.useState([]),[E,R]=p.useState(!1),[z,G]=p.useState([]),[ae,ee]=p.useState(!1),[ne,te]=p.useState(!1),[Y,q]=p.useState(!1),{inspection:H,loading:U,error:re,refetch:X}=lle(n?null:r||null),{createInspection:V,updateInspection:I,deleteInspection:B,loading:Q}=cle(),{isSystemManager:ie,canEdit:me,getStateStyle:he}=hw({doctype:"Inspection",docname:n?null:r||null,workflowState:S.workflow_state,enabled:!n,docData:S}),xe=u.includes("Work Control")&&!S.assigned_technician,[ge,be]=p.useState(n||i),[K,ye]=p.useState(!1),M=p.useCallback(()=>{const Ye=S.workflow_state||"Draft";return Ye==="Cancelled"?2:Ye==="Closed"?1:S.docstatus||0},[S.workflow_state,S.docstatus])(),we=M===1,pe=M===2,le=!!(H!=null&&H.custom_delete_status),Fe=we||pe||le,ze=p.useCallback(()=>J(null,null,function*(){if(!(n||!r)){ee(!0);try{const Ye=yield At.apiCall(`/api/resource/Version?filters=[["ref_doctype","=","Inspection"],["docname","=","${encodeURIComponent(r)}"]]&fields=["name","owner","creation","data"]&order_by=creation desc&limit=50`);if(Ye!=null&&Ye.data&&Ye.data.length>0){const kt=Ye.data.map(Yt=>{let Ae={added:[],changed:[],removed:[],row_changed:[]};try{Ae=JSON.parse(Yt.data||"{}")}catch(Be){console.error("Error parsing version data:",Be)}const ke=(Ae.changed||[]).map(Be=>({field:Be[0]||"",oldValue:Be[1],newValue:Be[2]}));return{name:Yt.name,owner:Yt.owner,creation:Yt.creation,changes:ke,added:Ae.added||[],removed:Ae.removed||[],rowChanged:Ae.row_changed||[]}});G(kt),console.log("Audit logs fetched:",kt.length)}else G([])}catch(Ye){console.error("Error fetching audit logs:",Ye),G([])}finally{ee(!1)}}}),[n,r]);p.useEffect(()=>{ze()},[ze]);const Re=Ye=>Ye?Ye.replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,kt=>kt.toUpperCase()):"",De=Ye=>Ye==null||Ye===""?"(empty)":Ye===0?"0":Ye===1?"1":typeof Ye=="boolean"?Ye?"Yes":"No":typeof Ye=="object"?JSON.stringify(Ye):String(Ye),Et=Ye=>{if(!Ye)return"";const kt=new Date(Ye),Yt=new Date,Ae=Yt.getTime()-kt.getTime(),ke=Math.floor(Ae/6e4),Be=Math.floor(Ae/36e5),yt=Math.floor(Ae/864e5);return ke<1?"Just now":ke<60?`${ke} min${ke>1?"s":""} ago`:Be<24?`${Be} hour${Be>1?"s":""} ago`:yt<7?`${yt} day${yt>1?"s":""} ago`:kt.toLocaleDateString("en-US",{month:"short",day:"numeric",year:kt.getFullYear()!==Yt.getFullYear()?"numeric":void 0,hour:"2-digit",minute:"2-digit"})},jt=Ye=>{if(!Ye)return"Unknown";const kt=Ye.indexOf("@");return kt===-1?Ye:Ye.substring(0,kt)},Ie=Ye=>{const kt=Ye.toLowerCase();return kt.includes("status")||kt.includes("state")?"text-purple-600 dark:text-purple-400":kt.includes("date")?"text-blue-600 dark:text-blue-400":kt.includes("technician")||kt.includes("supervisor")||kt.includes("assigned")?"text-green-600 dark:text-green-400":"text-gray-600 dark:text-gray-400"},$e=p.useCallback(Ye=>J(null,null,function*(){if(!Ye){P([]);return}try{console.log("Filtering technicians for work order type:",Ye);const kt=yield At.apiCall(`/api/resource/Asset Maintenance Team?filters=[["custom_expertise","=","${encodeURIComponent(Ye)}"]]&fields=["name"]&limit=100`);if(kt!=null&&kt.data&&kt.data.length>0){const Yt=new Set,Ae=kt.data.map(Be=>J(null,null,function*(){try{const yt=yield At.apiCall(`/api/resource/Asset Maintenance Team/${encodeURIComponent(Be.name)}`);yt!=null&&yt.data&&(yt.data.maintenance_team_members||[]).forEach(Ke=>{Ke.team_member&&Yt.add(Ke.team_member)})}catch(yt){console.error("Error fetching team:",Be.name,yt)}}));yield Promise.all(Ae);const ke=Array.from(Yt);console.log("Filtered Technicians:",ke),P(ke)}else P([])}catch(kt){console.error("Error fetching technicians:",kt),P([])}}),[]);p.useEffect(()=>{S.work_order_type?$e(S.work_order_type):P([])},[S.work_order_type,$e]);const Qe=Ye=>{if(!Ye)return!0;const kt=af();return Ye<kt?(We.error(e("inspections.detail.inspectionDateInPast"),{position:"top-right",autoClose:5e3,icon:t.jsx(Or,{})}),!1):!0},at=(Ye,kt)=>{if(!Ye)return!0;const Yt=af();return kt&&Ye<kt?(We.error(e("inspections.detail.targetClosureEarlier"),{position:"top-right",autoClose:5e3,icon:t.jsx(Or,{})}),!1):Ye<Yt?(We.error(e("inspections.detail.targetClosureInPast"),{position:"top-right",autoClose:5e3,icon:t.jsx(Or,{})}),!1):!0},Ct=Ye=>{const kt=Ye.target.value;Qe(kt)&&(N(Yt=>je(se({},Yt),{inspection_date:kt})),S.target_closure_date&&at(S.target_closure_date,kt))},vt=Ye=>{const kt=Ye.target.value;at(kt,S.inspection_date||"")&&N(Yt=>je(se({},Yt),{target_closure_date:kt}))},er=Ye=>{N(kt=>je(se({},kt),{work_order_type:Ye,assigned_technician:""}))},nr=Ye=>J(null,null,function*(){var Ae,ke;const kt=(Ae=Ye.target.files)==null?void 0:Ae[0];if(!kt)return;const Yt=10*1024*1024;if(kt.size>Yt){We.error(e("inspections.detail.fileSizeExceeds"),{position:"top-right",autoClose:4e3,icon:t.jsx(pr,{})});return}R(!0);try{const Be=new FormData;Be.append("file",kt),Be.append("is_private","0"),Be.append("folder","Home/Attachments"),!n&&r&&(Be.append("doctype","Inspection"),Be.append("docname",r));const yt=Ar.BASE_URL||"",Ke=yield(yield fetch(`${yt}/api/method/upload_file`,{method:"POST",credentials:"include",body:Be})).json();if((ke=Ke.message)!=null&&ke.file_url)N(Xe=>je(se({},Xe),{attachment:Ke.message.file_url})),We.success(e("inspections.detail.fileUploadedSuccess"),{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})});else throw new Error("Upload failed")}catch(Be){console.error("File upload error:",Be),We.error(e("inspections.detail.failedToUpload"),{position:"top-right",autoClose:4e3,icon:t.jsx(pr,{})})}finally{R(!1),Ye.target.value=""}}),dt=()=>{N(Ye=>je(se({},Ye),{attachment:""})),We.info(e("inspections.detail.attachmentRemoved"),{position:"top-right",autoClose:2e3})},He=Ye=>{if(!Ye)return"";const kt=Ye.split("/");return kt[kt.length-1]||Ye},it=()=>J(null,null,function*(){k(!0);try{yield I(r,je(se({},S),{workflow_state:"Cancelled",docstatus:2,status:"Cancelled"})),We.success(e("inspections.detail.cancelledSuccessfully"),{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),w(!1),X(),setTimeout(()=>{ze()},500)}catch(Ye){const kt=Ye instanceof Error?Ye.message:"Unknown error";We.error(e("inspections.detail.failedToCancel",{error:kt}),{position:"top-right",autoClose:6e3,icon:t.jsx(pr,{})})}finally{k(!1)}});p.useEffect(()=>{J(null,null,function*(){if(n&&!S.requested_by)try{const kt=yield Md.getCurrentUser();kt&&N(Yt=>je(se({},Yt),{requested_by:kt}))}catch(kt){console.error("Error fetching current user:",kt)}finally{O(!1)}else O(!1)})},[n]),p.useEffect(()=>{H&&!n&&(N({inspection_type:H.inspection_type||"",status:H.status||"Open",inspection_date:H.inspection_date||"",target_closure_date:H.target_closure_date||"",requested_by:H.requested_by||"",technician_department:H.technician_department||"",linked_corrective_wo_no:H.linked_corrective_wo_no||"",observation_note:H.observation_note||"",technical_response:H.technical_response||"",workflow_state:H.workflow_state||"Draft",work_order_type:H.work_order_type||"",department:H.department||"",location:H.location||"",assigned_technician:H.assigned_technician||"",attachment:H.attachment||"",attachment_on_close:H.attachment_on_close||"",extension_no:H.extension_no||"",docstatus:H.docstatus||0}),H.workflow_state==="Closed"||H.workflow_state==="Cancelled"||H.docstatus>=1?be(!1):i||be(!1))},[H,n,i]);const Ue=Ye=>{const{name:kt,value:Yt}=Ye.target;N(Ae=>je(se({},Ae),{[kt]:Yt}))},Ve=()=>J(null,null,function*(){if(!S.target_closure_date){We.error(e("inspections.detail.targetClosureMandatory"),{position:"top-right",autoClose:5e3,icon:t.jsx(pr,{})});return}if(!S.attachment){We.error(e("inspections.detail.attachmentMandatory"),{position:"top-right",autoClose:5e3,icon:t.jsx(pr,{})});return}if(!S.extension_no){We.error(e("inspections.detail.extensionMandatory"),{position:"top-right",autoClose:5e3,icon:t.jsx(pr,{})});return}if(Qe(S.inspection_date||"")&&at(S.target_closure_date||"",S.inspection_date||""))try{if(n){const Ye=yield V(S);We.success(e("inspections.detail.createdSuccessfully"),{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),s(`/inspections/${Ye.name}`)}else yield I(r,S),We.success(e("inspections.detail.updatedSuccessfully"),{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),be(!1),X(),setTimeout(()=>{ze()},500)}catch(Ye){const kt=Ye instanceof Error?Ye.message:"Unknown error";We.error(e("inspections.detail.failedToSave",{error:kt}),{position:"top-right",autoClose:6e3,icon:t.jsx(pr,{})})}}),lt=()=>J(null,null,function*(){try{yield B(r),We.success(e("inspections.detail.deletedSuccessfully"),{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),s(-1)}catch(Ye){const kt=Ye instanceof Error?Ye.message:"Unknown error";We.error(e("inspections.detail.failedToDelete",{error:kt}),{position:"top-right",autoClose:6e3,icon:t.jsx(pr,{})})}}),st=(Ye,kt)=>{kt&&(We.success(`Action "${Ye}" applied successfully!`,{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),setTimeout(()=>{ze()},500))},Mt=()=>{X()},Ot=p.useCallback(Ye=>!!(Fe||!ge||Ye==="linked_corrective_wo_no"||!n&&!me&&!ie),[ge,n,me,ie,Fe]);if(U||C)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-teal-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("inspections.detail.loadingDetails")})]})});if(re&&!n)return t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:e("inspections.detail.errorLoading")}),t.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:re}),t.jsx("button",{onClick:()=>s(-1),className:"bg-teal-600 hover:bg-teal-700 text-white px-4 py-2 rounded",children:e("inspections.detail.backToList")})]})});const Pt=(H==null?void 0:H.workflow_state)||S.workflow_state||"Draft",zt=he(Pt),Tt=fle(S.status||"Open");return t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[t.jsx($a,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:au}),t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("button",{onClick:()=>s(-1),className:"text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200",children:t.jsx(ia,{size:20})}),t.jsxs("div",{children:[t.jsxs("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white flex items-center gap-3",children:[n?e("inspections.detail.newInspection"):(H==null?void 0:H.name)||e("inspections.detail.inspectionDetails"),!n&&t.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-medium ${Tt.bg} ${Tt.text} ${Tt.border} border`,children:S.status||"Open"}),pe&&t.jsx("span",{className:"px-3 py-1 rounded-full text-sm font-medium bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300 border border-red-200 dark:border-red-800",children:e("inspections.detail.cancelled")}),ie&&!n&&t.jsx("span",{className:"px-2 py-0.5 bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 text-xs rounded-full",children:"System Manager"})]}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:n?e("inspections.detail.createNewRecord"):`${S.inspection_type||e("inspections.typeMap.inspection")}`})]})]}),t.jsxs("div",{className:"flex gap-3",children:[!n&&!ge&&t.jsxs(t.Fragment,{children:[!Fe&&t.jsxs("button",{onClick:()=>be(!0),className:"bg-teal-600 hover:bg-teal-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(qr,{}),e("common.edit")]}),we&&l&&t.jsxs("button",{onClick:()=>w(!0),className:"bg-orange-600 hover:bg-orange-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(Mo,{}),e("common.cancel")]})]}),ge&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{n?s(-1):(be(!1),X())},className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg",children:e("common.cancel")}),t.jsxs("button",{onClick:Ve,disabled:Q,className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 disabled:opacity-50",children:[t.jsx(ta,{}),e(Q?"common.saving":"common.save")]})]})]})]}),b&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl",children:[t.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[t.jsx(Mo,{className:"text-orange-500 text-xl mt-0.5"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:e("inspections.detail.cancelInspection")}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:e("inspections.detail.cancelConfirmMessage")})]})]}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>w(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",disabled:v,children:e("inspections.detail.noGoBack")}),t.jsx("button",{onClick:it,disabled:v,className:"px-4 py-2 bg-orange-600 hover:bg-orange-700 text-white rounded-lg disabled:opacity-50 flex items-center gap-2",children:v?t.jsxs(t.Fragment,{children:[t.jsx(tr,{className:"animate-spin"}),e("inspections.detail.cancelling")]}):t.jsxs(t.Fragment,{children:[t.jsx(Mo,{}),e("inspections.detail.yesCancel")]})})]})]})}),K&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl",children:[t.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[t.jsx(Or,{className:"text-red-500 text-xl mt-0.5"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:e("inspections.deleteInspection")}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:e("inspections.deleteConfirmMessage")})]})]}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>ye(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",children:e("common.cancel")}),t.jsx("button",{onClick:lt,disabled:Q,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg disabled:opacity-50",children:e(Q?"common.deleting":"common.delete")})]})]})}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[t.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(ao,{className:"text-teal-500"}),e("inspections.detail.inspectionDetails")]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("inspections.detail.inspectionType")}),t.jsxs("select",{name:"inspection_type",value:S.inspection_type,onChange:Ue,disabled:Ot("inspection_type"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-teal-500",children:[t.jsx("option",{value:"",children:e("inspections.detail.selectType")}),t.jsx("option",{value:"Inspection",children:e("inspections.typeMap.inspection")}),t.jsx("option",{value:"Safety Inspection",children:e("inspections.typeMap.safety_inspection")})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("inspections.detail.status")}),t.jsxs("select",{name:"status",value:S.status,onChange:Ue,disabled:Ot("status"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-teal-500",children:[t.jsx("option",{value:"Open",children:e("inspections.status.open")}),t.jsx("option",{value:"In Progress",children:e("inspections.status.in_progress")}),t.jsx("option",{value:"Pending Review",children:e("inspections.status.pending_review")}),t.jsx("option",{value:"Closed",children:e("inspections.status.closed")}),t.jsx("option",{value:"Cancelled",children:e("inspections.detail.cancelled")})]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(Je,{label:e("inspections.detail.workOrderType"),doctype:"Issue Type",value:S.work_order_type||"",onChange:er,disabled:Ot("work_order_type"),placeholder:e("inspections.detail.selectWorkOrderType")}),T.length>0&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:e("inspections.detail.techniciansAvailable",{count:T.length})})]}),t.jsx("div",{children:t.jsx(Je,{label:e("inspections.detail.department"),doctype:"Department",value:S.department||"",onChange:Ye=>N(je(se({},S),{department:Ye})),disabled:Ot("department"),placeholder:e("inspections.detail.selectDepartment"),allowQuickCreate:!0})})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsx("div",{children:t.jsx(Je,{label:e("inspections.detail.location"),doctype:"Location",value:S.location||"",onChange:Ye=>N(je(se({},S),{location:Ye})),disabled:Ot("location"),placeholder:e("inspections.detail.selectLocation"),allowQuickCreate:!0})}),t.jsx("div",{children:t.jsx(Je,{label:e("inspections.detail.extensionNo"),doctype:"Extension Directory",value:S.extension_no||"",onChange:Ye=>N(je(se({},S),{extension_no:Ye})),disabled:Ot("extension_no"),placeholder:e("inspections.detail.selectExtension"),allowQuickCreate:!0})})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("inspections.detail.inspectionDate")}),t.jsx("input",{type:"date",name:"inspection_date",value:S.inspection_date||"",onChange:Ct,min:af(),disabled:Ot("inspection_date"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-teal-500"}),t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:e("inspections.detail.cannotBeInPast")})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[e("inspections.detail.targetClosureDate")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"date",name:"target_closure_date",value:S.target_closure_date||"",onChange:vt,min:S.inspection_date||af(),disabled:Ot("target_closure_date"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-teal-500"}),t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:e("inspections.detail.cannotBeEarlier")})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("inspections.detail.openingAttachment")}),S.attachment?t.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600",children:[t.jsx(Nv,{className:"text-blue-500 flex-shrink-0",size:18}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("a",{href:`${S.attachment}`,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 dark:text-blue-400 hover:underline truncate block",children:He(S.attachment)})}),ge&&!Fe&&t.jsx("button",{type:"button",onClick:dt,className:"p-1.5 text-red-500 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors flex-shrink-0",title:e("inspections.detail.removeAttachment"),children:t.jsx(ht,{size:14})})]}):ge&&!Fe?t.jsxs("label",{className:"flex items-center gap-2 px-4 py-2.5 bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 rounded-lg cursor-pointer hover:bg-blue-100 dark:hover:bg-blue-900/30 transition-colors border border-blue-200 dark:border-blue-800 w-fit",children:[E?t.jsxs(t.Fragment,{children:[t.jsx(tr,{className:"animate-spin",size:14}),t.jsx("span",{className:"text-sm",children:e("inspections.detail.uploading")})]}):t.jsxs(t.Fragment,{children:[t.jsx(Tv,{size:14}),t.jsx("span",{className:"text-sm",children:e("inspections.detail.uploadFile")})]}),t.jsx("input",{type:"file",onChange:nr,disabled:E||Ot("attachment"),className:"hidden",accept:"image/*,.pdf,.doc,.docx,.xls,.xlsx,.txt"})]}):t.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 italic p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:e("inspections.detail.noAttachment")})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("inspections.detail.closingAttachment")}),S.attachment_on_close?t.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600",children:[t.jsx(Nv,{className:"text-green-500 flex-shrink-0",size:18}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("a",{href:`${S.attachment_on_close}`,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 dark:text-blue-400 hover:underline truncate block",children:He(S.attachment_on_close)})}),ge&&!Fe&&t.jsx("button",{type:"button",onClick:()=>{N(Ye=>je(se({},Ye),{attachment_on_close:""})),We.info(e("inspections.detail.closingAttachmentRemoved"),{position:"top-right",autoClose:2e3})},className:"p-1.5 text-red-500 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors flex-shrink-0",title:e("inspections.detail.removeClosingAttachment"),children:t.jsx(ht,{size:14})})]}):ge&&!Fe?t.jsxs("label",{className:"flex items-center gap-2 px-4 py-2.5 bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400 rounded-lg cursor-pointer hover:bg-green-100 dark:hover:bg-green-900/30 transition-colors border border-green-200 dark:border-green-800 w-fit",children:[E?t.jsxs(t.Fragment,{children:[t.jsx(tr,{className:"animate-spin",size:14}),t.jsx("span",{className:"text-sm",children:e("inspections.detail.uploading")})]}):t.jsxs(t.Fragment,{children:[t.jsx(Tv,{size:14}),t.jsx("span",{className:"text-sm",children:e("inspections.detail.uploadClosingFile")})]}),t.jsx("input",{type:"file",onChange:Ye=>J(null,null,function*(){var Ae,ke;const kt=(Ae=Ye.target.files)==null?void 0:Ae[0];if(!kt)return;const Yt=10*1024*1024;if(kt.size>Yt){We.error(e("inspections.detail.fileSizeExceeds"),{position:"top-right",autoClose:4e3,icon:t.jsx(pr,{})});return}R(!0);try{const Be=new FormData;Be.append("file",kt),Be.append("is_private","0"),Be.append("folder","Home/Attachments"),!n&&r&&(Be.append("doctype","Inspection"),Be.append("docname",r));const yt=Ar.BASE_URL||"",Ke=yield(yield fetch(`${yt}/api/method/upload_file`,{method:"POST",credentials:"include",body:Be})).json();if((ke=Ke.message)!=null&&ke.file_url)N(Xe=>je(se({},Xe),{attachment_on_close:Ke.message.file_url})),We.success(e("inspections.detail.closingAttachmentUploadedSuccess"),{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})});else throw new Error("Upload failed")}catch(Be){console.error("File upload error:",Be),We.error(e("inspections.detail.failedToUploadClosing"),{position:"top-right",autoClose:4e3,icon:t.jsx(pr,{})})}finally{R(!1),Ye.target.value=""}}),disabled:E||Ot("attachment_on_close"),className:"hidden",accept:"image/*,.pdf,.doc,.docx,.xls,.xlsx,.txt"})]}):t.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 italic p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:e("inspections.detail.noClosingAttachment")})]})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(nn,{className:"text-blue-500"}),e("inspections.detail.assignmentInformation")]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsx("div",{children:t.jsx(Je,{label:e("inspections.detail.requestedBy"),doctype:"User",value:S.requested_by||"",onChange:Ye=>N(je(se({},S),{requested_by:Ye})),disabled:Ot("requested_by"),placeholder:e("inspections.detail.selectUser")})}),t.jsx("div",{children:t.jsx(Je,{label:e("inspections.detail.technicalDepartment"),doctype:"Technical Department",value:S.technician_department||"",onChange:Ye=>N(je(se({},S),{technician_department:Ye})),disabled:Ot("technician_department"),placeholder:e("inspections.detail.selectDepartment"),allowQuickCreate:!0})}),t.jsxs("div",{children:[t.jsx(Je,{label:e("inspections.detail.assignedTechnician"),doctype:"User",value:S.assigned_technician||"",onChange:Ye=>N(je(se({},S),{assigned_technician:Ye})),disabled:Ot("assigned_technician"),placeholder:e("inspections.detail.selectTechnician"),filters:T.length>0?{name:["in",T]}:{}}),!S.work_order_type&&ge&&!Fe&&t.jsx("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:e("inspections.detail.selectWOTypeFirst")}),S.work_order_type&&T.length===0&&ge&&!Fe&&t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:e("inspections.detail.noTechniciansForType")})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(HG,{className:"text-green-500"}),e("inspections.detail.notesAndResponse")]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("inspections.detail.observationNote")}),t.jsx("textarea",{name:"observation_note",value:S.observation_note,onChange:Ue,disabled:Ot("observation_note"),placeholder:e("inspections.detail.placeholderObservation"),rows:4,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-teal-500 resize-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("inspections.detail.technicalResponse")}),t.jsx("textarea",{name:"technical_response",value:S.technical_response,onChange:Ue,disabled:Ot("technical_response"),placeholder:e("inspections.detail.placeholderTechnicalResponse"),rows:4,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-teal-500 resize-none"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(kv,{className:"text-orange-500"}),e("inspections.detail.linkedWorkOrder")]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[e("inspections.detail.linkedCorrectiveWO")," ",t.jsxs("span",{className:"text-xs text-gray-500",children:["(",e("inspections.detail.readOnly"),")"]})]}),S.linked_corrective_wo_no?t.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600",children:[t.jsx("span",{className:"text-gray-900 dark:text-white font-medium",children:S.linked_corrective_wo_no}),t.jsxs("button",{onClick:()=>s(`/work-orders/${S.linked_corrective_wo_no}`),className:"text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 flex items-center gap-1 text-sm",children:[e("inspections.detail.viewWorkOrder")," ",t.jsx(dn,{size:12})]})]}):t.jsx("div",{className:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600",children:t.jsx("span",{className:"text-gray-500 dark:text-gray-400 italic",children:e("inspections.detail.noLinkedWorkOrder")})})]})]}),!n&&t.jsx(Bm,{referenceDoctype:"Inspection",referenceName:r||null,title:"Comments & Discussion",pollInterval:3e4,initialLimit:5,collapsible:!0,startCollapsed:!1})]}),t.jsxs("div",{className:"space-y-4",children:[!n&&!ge&&!Fe&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-4 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-sm font-semibold text-gray-800 dark:text-white mb-3 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(kv,{className:"text-purple-500",size:14}),e("inspections.detail.workflowActions")]}),xe&&t.jsxs("div",{className:"mb-3 flex items-start gap-2 p-3 bg-amber-50 dark:bg-amber-900/20 border border-amber-300 dark:border-amber-700 rounded-lg",children:[t.jsx(Or,{className:"text-amber-500 flex-shrink-0 mt-0.5",size:14}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-semibold text-amber-800 dark:text-amber-300",children:"Technician Required"}),t.jsx("p",{className:"text-[11px] text-amber-700 dark:text-amber-400 mt-0.5",children:"Please assign a technician to this inspection before proceeding with workflow actions."})]})]}),!xe&&t.jsx(Ix,{doctype:"Inspection",docname:r||null,workflowState:Pt,onActionComplete:st,onStateChange:Mt,showStateInfo:!1}),t.jsxs("div",{className:"mt-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400 mb-2",children:e("inspections.detail.workflowProgress")}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:`flex flex-col items-center ${Pt==="Draft"?"text-orange-600":"text-green-600"}`,children:[t.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center text-[10px] ${Pt==="Draft"?"bg-orange-100 dark:bg-orange-900/30":"bg-green-100 dark:bg-green-900/30"}`,children:Pt==="Draft"?"1":t.jsx(Oc,{size:8})}),t.jsx("span",{className:"text-[8px] mt-0.5",children:e("inspections.detail.draftStep")})]}),t.jsx("div",{className:`flex-1 h-0.5 mx-0.5 ${Pt!=="Draft"?"bg-green-500":"bg-gray-300 dark:bg-gray-600"}`}),t.jsxs("div",{className:`flex flex-col items-center ${Pt==="Sent to Work Control"?"text-blue-600":["Sent to technician","Sent to Supervisor","Closed"].includes(Pt)?"text-green-600":"text-gray-400"}`,children:[t.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center text-[10px] ${Pt==="Sent to Work Control"?"bg-blue-100 dark:bg-blue-900/30":["Sent to technician","Sent to Supervisor","Closed"].includes(Pt)?"bg-green-100 dark:bg-green-900/30":"bg-gray-100 dark:bg-gray-700"}`,children:["Sent to technician","Sent to Supervisor","Closed"].includes(Pt)?t.jsx(Oc,{size:8}):"2"}),t.jsx("span",{className:"text-[8px] mt-0.5 text-center leading-tight",children:(()=>{const Ye=e("inspections.detail.workControl").split(" ");return Ye.length>=2?t.jsxs(t.Fragment,{children:[Ye[0],t.jsx("br",{}),Ye[1]]}):e("inspections.detail.workControl")})()})]}),t.jsx("div",{className:`flex-1 h-0.5 mx-0.5 ${["Sent to technician","Sent to Supervisor","Closed"].includes(Pt)?"bg-green-500":"bg-gray-300 dark:bg-gray-600"}`}),t.jsxs("div",{className:`flex flex-col items-center ${Pt==="Sent to technician"?"text-purple-600":["Sent to Supervisor","Closed"].includes(Pt)?"text-green-600":"text-gray-400"}`,children:[t.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center text-[10px] ${Pt==="Sent to technician"?"bg-purple-100 dark:bg-purple-900/30":["Sent to Supervisor","Closed"].includes(Pt)?"bg-green-100 dark:bg-green-900/30":"bg-gray-100 dark:bg-gray-700"}`,children:["Sent to Supervisor","Closed"].includes(Pt)?t.jsx(Oc,{size:8}):"3"}),t.jsx("span",{className:"text-[8px] mt-0.5",children:e("inspections.detail.technicianStep")})]}),t.jsx("div",{className:`flex-1 h-0.5 mx-0.5 ${["Sent to Supervisor","Closed"].includes(Pt)?"bg-green-500":"bg-gray-300 dark:bg-gray-600"}`}),t.jsxs("div",{className:`flex flex-col items-center ${Pt==="Sent to Supervisor"?"text-indigo-600":Pt==="Closed"?"text-green-600":"text-gray-400"}`,children:[t.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center text-[10px] ${Pt==="Sent to Supervisor"?"bg-indigo-100 dark:bg-indigo-900/30":Pt==="Closed"?"bg-green-100 dark:bg-green-900/30":"bg-gray-100 dark:bg-gray-700"}`,children:Pt==="Closed"?t.jsx(Oc,{size:8}):"4"}),t.jsx("span",{className:"text-[8px] mt-0.5",children:e("inspections.detail.supervisorStep")})]}),t.jsx("div",{className:`flex-1 h-0.5 mx-0.5 ${Pt==="Closed"?"bg-green-500":"bg-gray-300 dark:bg-gray-600"}`}),t.jsxs("div",{className:`flex flex-col items-center ${Pt==="Closed"?"text-green-600":"text-gray-400"}`,children:[t.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center text-[10px] ${Pt==="Closed"?"bg-green-100 dark:bg-green-900/30":"bg-gray-100 dark:bg-gray-700"}`,children:Pt==="Closed"?t.jsx(Oc,{size:8}):"5"}),t.jsx("span",{className:"text-[8px] mt-0.5",children:e("inspections.detail.closedStep")})]})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-4 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-sm font-semibold text-gray-800 dark:text-white mb-3 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(ao,{className:"text-teal-500",size:14}),e("inspections.detail.statusInfo")]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:`p-2 rounded-lg border ${zt.bg} ${zt.border}`,children:[t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:e("inspections.detail.workflow")}),t.jsx("p",{className:`text-sm font-semibold ${zt.text}`,children:Pt})]}),t.jsxs("div",{className:`p-2 rounded-lg border ${Tt.bg} ${Tt.border}`,children:[t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:e("inspections.detail.status")}),t.jsx("p",{className:`text-sm font-semibold ${Tt.text}`,children:S.status||"Open"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[S.inspection_type&&t.jsxs("div",{className:"p-2 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:e("inspections.detail.inspectionType")}),t.jsx("p",{className:"text-xs font-medium text-gray-900 dark:text-white truncate",children:S.inspection_type})]}),S.work_order_type&&t.jsxs("div",{className:"p-2 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:e("inspections.detail.woType")}),t.jsx("p",{className:"text-xs font-medium text-gray-900 dark:text-white truncate",children:S.work_order_type})]})]}),S.assigned_technician&&t.jsxs("div",{className:"p-2 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:e("inspections.detail.assignedTo")}),t.jsx("p",{className:"text-xs font-medium text-gray-900 dark:text-white truncate",children:S.assigned_technician})]})]})]}),!n&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center gap-2 cursor-pointer flex-1",onClick:()=>te(!ne),children:[t.jsx(ym,{className:"text-blue-500",size:14}),t.jsx("h2",{className:"text-sm font-semibold text-gray-800 dark:text-white",children:e("inspections.detail.activityLog")}),z.length>0&&t.jsx("span",{className:"px-1.5 py-0.5 bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 rounded-full text-[10px] font-medium",children:z.length})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button",onClick:Ye=>{Ye.stopPropagation(),ze(),We.info(e("inspections.detail.activityLogRefreshed"),{position:"top-right",autoClose:1500,icon:t.jsx(Ma,{})})},disabled:ae,className:"p-1 text-gray-400 hover:text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded transition-colors disabled:opacity-50",title:e("inspections.detail.refreshActivityLog"),children:t.jsx(Ma,{className:`${ae?"animate-spin":""}`,size:10})}),t.jsx("button",{type:"button",onClick:()=>te(!ne),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors p-1",children:ne?t.jsx(Ja,{size:12}):t.jsx(Fr,{size:12})})]})]}),ne&&t.jsxs("div",{className:"p-3",children:[ae&&t.jsxs("div",{className:"flex items-center justify-center py-6",children:[t.jsx(tr,{className:"animate-spin text-blue-500 mr-2",size:14}),t.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e("common.loading")})]}),!ae&&z.length===0&&t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute left-2 top-0 bottom-0 w-0.5 bg-gray-200 dark:bg-gray-700"}),t.jsxs("div",{className:"relative pl-6 mb-3",children:[t.jsx("div",{className:"absolute left-1 top-1 w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 bg-gray-300 dark:bg-gray-600"}),t.jsx("div",{className:"p-2 rounded-lg bg-gray-50 dark:bg-gray-700/50",children:t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400 italic",children:e("inspections.detail.noChangesRecorded")})})]}),(H==null?void 0:H.creation)&&(H==null?void 0:H.owner)&&t.jsxs("div",{className:"relative pl-6",children:[t.jsx("div",{className:"absolute left-1 top-1 w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 bg-green-500"}),t.jsxs("div",{className:"p-2 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-100 dark:border-green-800/50",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-5 h-5 rounded-full bg-green-200 dark:bg-green-800 flex items-center justify-center",children:t.jsx(nn,{className:"text-green-600 dark:text-green-400",size:8})}),t.jsx("span",{className:"text-[10px] font-medium text-gray-700 dark:text-gray-300",children:jt(H.owner)})]}),t.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-500 dark:text-gray-400",children:[t.jsx(ea,{size:8}),t.jsx("span",{title:new Date(H.creation).toLocaleString(),children:Et(H.creation)})]})]}),t.jsx("div",{className:"text-[10px]",children:t.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 bg-green-100 dark:bg-green-800/50 text-green-700 dark:text-green-300 rounded font-medium",children:[t.jsx(Qt,{size:8}),e("inspections.detail.createdThisInspection")]})})]})]})]}),!ae&&z.length>0&&t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute left-2 top-0 bottom-0 w-0.5 bg-gray-200 dark:bg-gray-700"}),t.jsx("div",{className:"space-y-3",children:(Y?z:z.slice(0,5)).map((Ye,kt)=>t.jsxs("div",{className:"relative pl-6",children:[t.jsx("div",{className:`absolute left-1 top-1 w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 ${kt===0?"bg-blue-500":"bg-gray-300 dark:bg-gray-600"}`}),t.jsxs("div",{className:`p-2 rounded-lg ${kt===0?"bg-blue-50 dark:bg-blue-900/20 border border-blue-100 dark:border-blue-800/50":"bg-gray-50 dark:bg-gray-700/50"}`,children:[t.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-5 h-5 rounded-full bg-gray-200 dark:bg-gray-600 flex items-center justify-center",children:t.jsx(nn,{className:"text-gray-500 dark:text-gray-400",size:8})}),t.jsx("span",{className:"text-[10px] font-medium text-gray-700 dark:text-gray-300",children:jt(Ye.owner)})]}),t.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-500 dark:text-gray-400",children:[t.jsx(ea,{size:8}),t.jsx("span",{title:new Date(Ye.creation).toLocaleString(),children:Et(Ye.creation)})]})]}),t.jsxs("div",{className:"space-y-1",children:[Ye.changes.length>0?Ye.changes.map((Yt,Ae)=>t.jsxs("div",{className:"text-[10px]",children:[t.jsx("span",{className:`font-medium ${Ie(Yt.field)}`,children:Re(Yt.field)}),t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[" ",e("inspections.detail.changedFrom")," "]}),t.jsx("span",{className:"px-1 py-0.5 bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400 rounded text-[9px] font-mono",children:De(Yt.oldValue)}),t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:" → "}),t.jsx("span",{className:"px-1 py-0.5 bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400 rounded text-[9px] font-mono",children:De(Yt.newValue)})]},Ae)):t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400 italic",children:e("inspections.detail.documentUpdated")}),Ye.added&&Ye.added.length>0&&t.jsxs("div",{className:"text-[10px] text-green-600 dark:text-green-400",children:[t.jsx("span",{className:"font-medium",children:e("inspections.detail.added")})," ",Ye.added.length," ",e("inspections.detail.items")]}),Ye.removed&&Ye.removed.length>0&&t.jsxs("div",{className:"text-[10px] text-red-600 dark:text-red-400",children:[t.jsx("span",{className:"font-medium",children:e("inspections.detail.removed")})," ",Ye.removed.length," ",e("inspections.detail.items")]}),Ye.rowChanged&&Ye.rowChanged.length>0&&t.jsxs("div",{className:"text-[10px] text-orange-600 dark:text-orange-400",children:[t.jsx("span",{className:"font-medium",children:e("inspections.detail.modified")})," ",Ye.rowChanged.length," ",e("inspections.detail.rows")]})]})]})]},Ye.name))}),z.length>5&&t.jsx("div",{className:"mt-3 text-center",children:t.jsx("button",{type:"button",onClick:()=>q(!Y),className:"inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-md transition-colors",children:Y?t.jsxs(t.Fragment,{children:[t.jsx(Ja,{size:8}),e("inspections.detail.showLess")]}):t.jsxs(t.Fragment,{children:[t.jsx(Fr,{size:8}),e("inspections.detail.showAll")," (",z.length,")"]})})}),(H==null?void 0:H.creation)&&(H==null?void 0:H.owner)&&t.jsxs("div",{className:"relative pl-6 mt-3",children:[t.jsx("div",{className:"absolute left-1 top-1 w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 bg-green-500"}),t.jsxs("div",{className:"p-2 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-100 dark:border-green-800/50",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-5 h-5 rounded-full bg-green-200 dark:bg-green-800 flex items-center justify-center",children:t.jsx(nn,{className:"text-green-600 dark:text-green-400",size:8})}),t.jsx("span",{className:"text-[10px] font-medium text-gray-700 dark:text-gray-300",children:jt(H.owner)})]}),t.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-500 dark:text-gray-400",children:[t.jsx(ea,{size:8}),t.jsx("span",{title:new Date(H.creation).toLocaleString(),children:Et(H.creation)})]})]}),t.jsx("div",{className:"text-[10px]",children:t.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 bg-green-100 dark:bg-green-800/50 text-green-700 dark:text-green-300 rounded font-medium",children:[t.jsx(Qt,{size:8}),e("inspections.detail.createdThisInspection")]})})]})]})]})]})]}),!n&&f&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-4 border border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-sm font-semibold text-gray-800 dark:text-white mb-3 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Delete Request"}),t.jsx(n0,{doctype:"Inspection",docname:r,currentDeleteStatus:(Gt=H==null?void 0:H.custom_delete_status)!=null?Gt:null,userRoles:u,isSystemManager:ie,redirectOnDelete:"/inspections",onStatusChange:()=>X()})]})]})]})]})};class yle{constructor(){$s(this,"baseURL");this.baseURL=Ar.BASE_URL}getCSRFToken(){return J(this,null,function*(){try{return typeof window!="undefined"&&window.csrf_token?window.csrf_token:null}catch(r){return null}})}getHeaders(){return J(this,null,function*(){const r={Accept:"application/json","Content-Type":"application/json"},a=yield this.getCSRFToken();return a&&(r["X-Frappe-CSRF-Token"]=a),r})}getSupportPlans(){return J(this,arguments,function*(r={}){const{filters:a={},fields:s=["name","support_plan","frequency","max_downtime_hrs","asset","starting_date","penalty_factor","custom_contractwarranty","custom_contract_value","warranty","warranty_start_date","warranty_end_date","war_status","extended_warranty","service_contract","spare_parts","spare_parts_labour","labour","ppm_only","start_date","end_date","service_contract_status","vendor","creation","modified","owner","modified_by","docstatus"],limit_start:n=0,limit_page_length:i=20,order_by:o="creation desc"}=r,l=new URLSearchParams;if(l.append("fields",JSON.stringify(s)),l.append("limit_start",n.toString()),l.append("limit_page_length",i.toString()),l.append("order_by",o),Object.keys(a).length>0){const h=xa(a);h.length>0&&l.append("filters",JSON.stringify(h))}const c=yield fetch(`${this.baseURL}/api/resource/Support Plans?${l.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);return{data:(yield c.json()).data||[]}})}getSupportPlan(r){return J(this,null,function*(){const a=yield fetch(`${this.baseURL}/api/resource/Support Plans/${encodeURIComponent(r)}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return(yield a.json()).data})}createSupportPlan(r){return J(this,null,function*(){const a=yield fetch(`${this.baseURL}/api/resource/Support Plans`,{method:"POST",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(r)});if(!a.ok){const n=yield a.json().catch(()=>({}));throw new Error(n.message||`HTTP error! status: ${a.status}`)}return(yield a.json()).data})}updateSupportPlan(r,a){return J(this,null,function*(){const s=yield fetch(`${this.baseURL}/api/resource/Support Plans/${encodeURIComponent(r)}`,{method:"PUT",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(a)});if(!s.ok){const i=yield s.json().catch(()=>({}));throw new Error(i.message||`HTTP error! status: ${s.status}`)}return(yield s.json()).data})}deleteSupportPlan(r){return J(this,null,function*(){const a=yield fetch(`${this.baseURL}/api/resource/Support Plans/${encodeURIComponent(r)}`,{method:"DELETE",headers:yield this.getHeaders(),credentials:"include"});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`)})}getSupportPlanCount(){return J(this,arguments,function*(r={}){var i,o;const a=new URLSearchParams;if(a.append("fields",JSON.stringify(["count(name) as count"])),Object.keys(r).length>0){const l=xa(r);l.length>0&&a.append("filters",JSON.stringify(l))}const s=yield fetch(`${this.baseURL}/api/resource/Support Plans?${a.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return((o=(i=(yield s.json()).data)==null?void 0:i[0])==null?void 0:o.count)||0})}getCurrentUser(){return J(this,null,function*(){try{const r=yield fetch(`${this.baseURL}/api/method/frappe.auth.get_logged_user`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return(yield r.json()).message||""}catch(r){return console.error("Error getting current user:",r),""}})}}const Bf=new yle,ble=(e={})=>{const[r,a]=p.useState([]),[s,n]=p.useState(!0),[i,o]=p.useState(null),[l,c]=p.useState(0),u=p.useCallback(()=>J(null,null,function*(){try{n(!0),o(null);const h=yield Bf.getSupportPlans(e);a(h.data);const y=yield(yield fetch("/api/method/frappe.client.get_count",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Support Plans",filters:e.filters||{}})})).json();c(y.message||h.data.length)}catch(h){o(h instanceof Error?h.message:"Failed to fetch support plans"),a([])}finally{n(!1)}}),[e.filters,e.limit_start,e.limit_page_length,e.order_by]);return p.useEffect(()=>{u()},[u]),{supportPlans:r,loading:s,error:i,totalCount:l,refetch:u}},vle=e=>{const[r,a]=p.useState(null),[s,n]=p.useState(!0),[i,o]=p.useState(null),l=p.useCallback(()=>J(null,null,function*(){if(!e){n(!1);return}try{n(!0),o(null);const c=yield Bf.getSupportPlan(e);a(c)}catch(c){o(c instanceof Error?c.message:"Failed to fetch support plan"),a(null)}finally{n(!1)}}),[e]);return p.useEffect(()=>{l()},[l]),{supportPlan:r,loading:s,error:i,refetch:l}},wle=()=>{const[e,r]=p.useState(!1),[a,s]=p.useState(null),n=p.useCallback(l=>J(null,null,function*(){try{return r(!0),s(null),yield Bf.createSupportPlan(l)}catch(c){const u=c instanceof Error?c.message:"Failed to create support plan";throw s(u),c}finally{r(!1)}}),[]),i=p.useCallback((l,c)=>J(null,null,function*(){try{return r(!0),s(null),yield Bf.updateSupportPlan(l,c)}catch(u){const h=u instanceof Error?u.message:"Failed to update support plan";throw s(h),u}finally{r(!1)}}),[]),o=p.useCallback(l=>J(null,null,function*(){try{r(!0),s(null),yield Bf.deleteSupportPlan(l)}catch(c){const u=c instanceof Error?c.message:"Failed to delete support plan";throw s(u),c}finally{r(!1)}}),[]);return{createSupportPlan:n,updateSupportPlan:i,deleteSupportPlan:o,loading:e,error:a}},jle=({isOpen:e,onClose:r,selectedCount:a,totalCount:s,pageCount:n,onExport:i,isExporting:o,exportColumns:l})=>{const{t:c}=sr(),[u,h]=p.useState(a>0?"selected":"all_with_filters"),[f,y]=p.useState("csv"),[b,w]=p.useState(l.filter(N=>N.default).map(N=>N.key));p.useEffect(()=>{h(a>0?"selected":"all_with_filters")},[a]);const v=N=>w(C=>C.includes(N)?C.filter(O=>O!==N):[...C,N]),k=()=>w(l.map(N=>N.key)),S=()=>w(l.filter(N=>N.default).map(N=>N.key));return e?t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] overflow-hidden animate-scale-in",children:[t.jsx("div",{className:"bg-gradient-to-r from-indigo-500 to-indigo-600 px-6 py-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Sa,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:c("supportPlans.export.title")})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:o,children:t.jsx(ht,{size:20})})]})}),t.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-180px)]",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:c("supportPlans.export.selectData")}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${u==="selected"?"border-indigo-500 bg-indigo-50 dark:bg-indigo-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"} ${a===0?"opacity-50 cursor-not-allowed":""}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"selected",checked:u==="selected",onChange:()=>h("selected"),disabled:a===0,className:"text-indigo-600"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("supportPlans.export.selectedRows")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("supportPlans.export.selectedCount",{count:a})})]}),a>0&&t.jsxs("span",{className:"bg-indigo-100 dark:bg-indigo-900/40 text-indigo-700 dark:text-indigo-300 px-2 py-1 rounded text-xs font-medium",children:[a," selected"]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${u==="all_on_page"?"border-indigo-500 bg-indigo-50 dark:bg-indigo-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"all_on_page",checked:u==="all_on_page",onChange:()=>h("all_on_page"),className:"text-indigo-600"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("supportPlans.export.currentPage")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("supportPlans.export.currentPageCount",{count:n})})]}),t.jsxs("span",{className:"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300 px-2 py-1 rounded text-xs font-medium",children:[n," rows"]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${u==="all_with_filters"?"border-indigo-500 bg-indigo-50 dark:bg-indigo-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"all_with_filters",checked:u==="all_with_filters",onChange:()=>h("all_with_filters"),className:"text-indigo-600"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("supportPlans.export.allWithFilters")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("supportPlans.export.allWithFiltersCount",{count:s})})]}),t.jsxs("span",{className:"bg-purple-100 dark:bg-purple-900/40 text-purple-700 dark:text-purple-300 px-2 py-1 rounded text-xs font-medium",children:[s," total"]})]})]})]}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:c("supportPlans.export.exportFormat")}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${f==="csv"?"border-indigo-500 bg-indigo-50 dark:bg-indigo-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"format",value:"csv",checked:f==="csv",onChange:()=>y("csv"),className:"text-indigo-600"}),t.jsx(ic,{className:"text-indigo-600 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("supportPlans.export.csv")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:c("supportPlans.export.csvDesc")})]})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${f==="excel"?"border-indigo-500 bg-indigo-50 dark:bg-indigo-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[t.jsx("input",{type:"radio",name:"format",value:"excel",checked:f==="excel",onChange:()=>y("excel"),className:"text-indigo-600"}),t.jsx(oc,{className:"text-green-700 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:c("supportPlans.export.excel")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:c("supportPlans.export.excelDesc")})]})]})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:c("supportPlans.export.columnsToExport")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:k,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:c("supportPlans.export.selectAll")}),t.jsx("span",{className:"text-gray-300",children:"|"}),t.jsx("button",{onClick:S,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:c("supportPlans.export.resetToDefault")})]})]}),t.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2 max-h-48 overflow-y-auto p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg",children:l.map(N=>t.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${b.includes(N.key)?"bg-indigo-100 dark:bg-indigo-900/30 text-indigo-800 dark:text-indigo-300":"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-400"}`,children:[t.jsx("input",{type:"checkbox",checked:b.includes(N.key),onChange:()=>v(N.key),className:"rounded text-indigo-600"}),t.jsx("span",{className:"text-sm truncate",children:N.label})]},N.key))}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:c("supportPlans.export.columnsSelected",{count:b.length})})]})]}),t.jsxs("div",{className:"px-6 py-4 bg-gray-50 dark:bg-gray-900/50 border-t border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[u==="selected"&&c("supportPlans.export.exportingSelected",{count:a}),u==="all_on_page"&&c("supportPlans.export.exportingPage",{count:n}),u==="all_with_filters"&&c("supportPlans.export.exportingAll",{count:s})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{onClick:r,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg",disabled:o,children:c("common.cancel")}),t.jsx("button",{onClick:()=>i(u,f,b),disabled:b.length===0||o,className:"px-4 py-2 text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 rounded-lg flex items-center gap-2 disabled:opacity-50",children:o?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),c("supportPlans.export.exporting")]}):t.jsxs(t.Fragment,{children:[t.jsx(qc,{}),c("supportPlans.export.exportButton")]})})]})]})]})}):null},_le=e=>{switch(e==null?void 0:e.toLowerCase()){case"contract":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";case"warranty":return"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}},z7=e=>{switch(e==null?void 0:e.toLowerCase()){case"active":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300";case"inactive":return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300";case"expired":return"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}},kle=e=>{switch(e==null?void 0:e.toLowerCase()){case"monthly":return"bg-cyan-100 text-cyan-800 dark:bg-cyan-900/30 dark:text-cyan-300";case"quarterly":return"bg-indigo-100 text-indigo-800 dark:bg-indigo-900/30 dark:text-indigo-300";case"half-yearly":return"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-300";case"yearly":return"bg-pink-100 text-pink-800 dark:bg-pink-900/30 dark:text-pink-300";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}},Nle=()=>{const{t:e}=sr(),r=hr(),a=[{key:"name",label:e("supportPlans.planId"),default:!0},{key:"support_plan",label:e("supportPlans.table.planName"),default:!0},{key:"frequency",label:e("supportPlans.table.frequency"),default:!0},{key:"custom_contractwarranty",label:e("supportPlans.table.type"),default:!0},{key:"custom_contract_value",label:e("supportPlans.table.contractValue"),default:!0},{key:"war_status",label:e("supportPlans.table.warrantyStatus"),default:!0},{key:"service_contract_status",label:e("supportPlans.table.contractStatus"),default:!0},{key:"max_downtime_hrs",label:"Max Downtime (hrs)",default:!1},{key:"penalty_factor",label:"Penalty Factor",default:!1},{key:"asset",label:e("filters.asset"),default:!1},{key:"vendor",label:e("commonFields.supplier"),default:!0},{key:"warranty_start_date",label:e("assets.warrantyStartDate"),default:!1},{key:"warranty_end_date",label:e("assets.warrantyEndDate"),default:!1},{key:"start_date",label:e("assets.serviceStartDate"),default:!1},{key:"end_date",label:e("assets.serviceEndDate"),default:!1},{key:"creation",label:e("commonFields.createdOn"),default:!1},{key:"owner",label:e("commonFields.createdBy"),default:!1}],[s,n]=_a(),i=p.useRef(n);p.useEffect(()=>{i.current=n},[n]);const o=p.useMemo(()=>{const Ue=parseInt(s.get("page")||"1",10);return Number.isNaN(Ue)||Ue<1?1:Ue},[s]),l=p.useCallback(Ue=>{const Ve=typeof Ue=="function"?Ue(o):Ue;n(lt=>{const st=new URLSearchParams(lt);return st.set("page",String(Ve)),st})},[o,n]),[c]=p.useState(20),[u,h]=p.useState(!1),[f,y]=p.useState(new Set),[b,w]=p.useState(!1),[v,k]=p.useState(!1),[S,N]=p.useState(null),[C,O]=p.useState(!0),[T,P]=p.useState(!0),[E,R]=p.useState(()=>s.get("date_filter_by")||""),[z,G]=p.useState(()=>s.get("date_start")||""),[ae,ee]=p.useState(()=>s.get("date_end")||""),[ne,te]=p.useState(()=>s.get("contract_warranty")||""),[Y,q]=p.useState(()=>s.get("frequency")||""),[H,U]=p.useState(()=>s.get("war_status")||""),[re,X]=p.useState(()=>s.get("service_contract_status")||""),[V,I]=p.useState(()=>s.get("vendor")||""),[B,Q]=p.useState(()=>s.get("asset")||""),[ie,me]=p.useState(!1),[he,de]=p.useState(0),[xe,ge]=p.useState([]),[be,K]=p.useState(!1),[ye,Z]=p.useState("");p.useEffect(()=>{const Ue=localStorage.getItem("supportPlanFilterPresets");Ue&&ge(JSON.parse(Ue))},[]);const M=E&&(z||ae);p.useEffect(()=>{const Ue=[ne,Y,H,re,V,B].filter(Boolean).length+(M?1:0);de(Ue)},[ne,Y,H,re,V,B,M]);const we=p.useMemo(()=>{const Ue={};return ne&&(Ue.custom_contractwarranty=ne),Y&&(Ue.frequency=Y),H&&(Ue.war_status=H),re&&(Ue.service_contract_status=re),V&&(Ue.vendor=V),B&&(Ue.asset=B),Object.assign(Ue,kl(E,z,ae)),Ue},[ne,Y,H,re,V,B,E,z,ae]),{supportPlans:pe,loading:le,error:Fe,totalCount:ze,refetch:Re}=ble({filters:we,limit_start:(o-1)*c,limit_page_length:c,order_by:"creation desc"});p.useEffect(()=>{!le&&!u&&h(!0)},[le,u]);const De=p.useRef(!1);p.useEffect(()=>{if(!De.current){De.current=!0;return}i.current(Ue=>{const Ve=new URLSearchParams(Ue);return E?Ve.set("date_filter_by",E):Ve.delete("date_filter_by"),z?Ve.set("date_start",z):Ve.delete("date_start"),ae?Ve.set("date_end",ae):Ve.delete("date_end"),ne?Ve.set("contract_warranty",ne):Ve.delete("contract_warranty"),Y?Ve.set("frequency",Y):Ve.delete("frequency"),H?Ve.set("war_status",H):Ve.delete("war_status"),re?Ve.set("service_contract_status",re):Ve.delete("service_contract_status"),V?Ve.set("vendor",V):Ve.delete("vendor"),B?Ve.set("asset",B):Ve.delete("asset"),Ve.set("page","1"),Ve})},[E,z,ae,ne,Y,H,re,V,B]),p.useEffect(()=>{y(new Set)},[E,z,ae,ne,Y,H,re,V,B,o]);const Et=Ue=>{if(!Ue)return"-";const Ve=typeof Ue=="string"?parseFloat(Ue):Ue;return new Intl.NumberFormat("en-US",{style:"currency",currency:"SAR"}).format(Ve)},jt=()=>{R(""),G(""),ee(""),te(""),q(""),U(""),X(""),I(""),Q(""),i.current(Ue=>{const Ve=new URLSearchParams(Ue);return Ve.delete("date_filter_by"),Ve.delete("date_start"),Ve.delete("date_end"),Ve.delete("contract_warranty"),Ve.delete("frequency"),Ve.delete("war_status"),Ve.delete("service_contract_status"),Ve.delete("vendor"),Ve.delete("asset"),Ve.set("page","1"),Ve})},Ie=M||!!ne||!!Y||!!H||!!re||!!V||!!B,$e=()=>{if(!ye.trim()){alert("Please enter a filter name");return}const Ue={id:Date.now(),name:ye,filters:{dateFilterBy:E,dateStart:z,dateEnd:ae,contractWarrantyFilter:ne,frequencyFilter:Y,warStatusFilter:H,serviceContractStatusFilter:re,vendorFilter:V,assetFilter:B}},Ve=[...xe,Ue];ge(Ve),Z(""),K(!1),localStorage.setItem("supportPlanFilterPresets",JSON.stringify(Ve))},Qe=Ue=>{const Ve=Ue.filters;R(Ve.dateFilterBy||""),G(Ve.dateStart||""),ee(Ve.dateEnd||""),te(Ve.contractWarrantyFilter||""),q(Ve.frequencyFilter||""),U(Ve.warStatusFilter||""),X(Ve.serviceContractStatusFilter||""),I(Ve.vendorFilter||""),Q(Ve.assetFilter||"")},at=Ue=>{const Ve=xe.filter(lt=>lt.id!==Ue);ge(Ve),localStorage.setItem("supportPlanFilterPresets",JSON.stringify(Ve))},Ct=Ue=>y(Ve=>{const lt=new Set(Ve);return lt.has(Ue)?lt.delete(Ue):lt.add(Ue),lt}),vt=()=>f.size===pe.length?y(new Set):y(new Set(pe.map(Ue=>Ue.name))),er=pe.length>0&&f.size===pe.length,nr=f.size>0&&f.size<pe.length,dt=p.useCallback(()=>J(null,null,function*(){const Ue=[];let Ve=0;const lt=100;let st=!0;const Mt=xa(we);for(;st;)try{const zt=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Support Plans",filters:Mt.length>0?Mt:{},fields:["*"],limit_start:Ve*lt,limit_page_length:lt,order_by:"creation desc"})})).json()).message||[];Ue.push(...zt),zt.length<lt?st=!1:Ve++,Ve>100&&(console.warn("Export safety limit reached"),st=!1)}catch(Ot){throw console.error("Error fetching support plans for export:",Ot),Ot}return Ue}),[we]),He=(Ue,Ve,lt)=>J(null,null,function*(){k(!0);try{let st=[];switch(Ue){case"selected":st=pe.filter(Ot=>f.has(Ot.name));break;case"all_on_page":st=pe;break;case"all_with_filters":st=yield dt();break}if(st.length===0){alert(e("assets.noDataToExport"));return}const Mt=lt.map(Ot=>{var Pt;return((Pt=a.find(zt=>zt.key===Ot))==null?void 0:Pt.label)||Ot});if(Ve==="csv"){const Ot=[Mt.join(","),...st.map(Gt=>lt.map(Ye=>{var Yt;let kt=(Yt=Gt[Ye])!=null?Yt:"";return typeof kt=="string"&&(kt.includes(",")||kt.includes('"')||kt.includes(`
|
||
`))&&(kt=`"${kt.replace(/"/g,'""')}"`),kt}).join(","))].join(`
|
||
`),Pt=new Blob(["\uFEFF"+Ot],{type:"text/csv;charset=utf-8;"}),zt=URL.createObjectURL(Pt),Tt=document.createElement("a");Tt.href=zt,Tt.download=`support_plans_export_${new Date().toISOString().split("T")[0]}.csv`,Tt.click(),URL.revokeObjectURL(zt)}else if(Ve==="excel"){const Ot=[Mt,...st.map(Tt=>lt.map(Gt=>{var Ye;return(Ye=Tt[Gt])!=null?Ye:""}))],Pt=Na.aoa_to_sheet(Ot),zt=Na.book_new();Na.book_append_sheet(zt,Pt,"Support Plans"),lc(zt,`support_plans_export_${new Date().toISOString().split("T")[0]}.xlsx`)}w(!1),y(new Set)}catch(st){console.error("Export failed:",st),alert(`Export failed: ${st instanceof Error?st.message:"Unknown error"}`)}finally{k(!1)}}),it=Ue=>J(null,null,function*(){try{if(!(yield fetch(`/api/resource/Support Plans/${encodeURIComponent(Ue)}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to delete");N(null),Re(),alert(e("supportPlans.deletedSuccessfully"))}catch(Ve){alert(`Failed to delete: ${Ve instanceof Error?Ve.message:"Unknown error"}`)}});return le&&!u?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("supportPlans.loadingSupportPlans")})]})}):Fe?t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:e("supportPlans.errorLoadingSupportPlans")}),t.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:Fe}),t.jsx("button",{onClick:Re,className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded",children:"Try Again"})]})}):t.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsx("div",{children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(pp,{className:"text-3xl text-indigo-600 dark:text-indigo-400"}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:e("supportPlans.listTitle")}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[e("issues.listTotal"),": ",ze,f.size>0&&t.jsxs("span",{className:"ml-2 text-indigo-600 dark:text-indigo-400",children:["• ",f.size," selected"]}),le&&u&&t.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-indigo-600 dark:text-indigo-400",children:[t.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-indigo-500"}),"Updating..."]})]})]})]})}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("button",{onClick:()=>me(!ie),className:`px-4 py-2 rounded-lg flex items-center gap-2 transition-colors ${ie||Ie?"bg-indigo-100 text-indigo-700 dark:bg-indigo-900/30 dark:text-indigo-300":"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600"}`,children:[t.jsx(ds,{}),"Filters",he>0&&t.jsx("span",{className:"bg-indigo-600 text-white text-xs px-1.5 py-0.5 rounded-full",children:he})]}),t.jsxs("button",{onClick:Re,disabled:le,className:"px-4 py-2 rounded-lg bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 flex items-center gap-2 disabled:opacity-50",children:[t.jsx(Ma,{className:le?"animate-spin":""}),"Refresh"]}),t.jsxs("button",{onClick:()=>w(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow",disabled:ze===0,children:[t.jsx(Sa,{}),t.jsx("span",{className:"font-medium",children:e("listPages.export")}),f.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:f.size})]}),T&&t.jsxs("button",{onClick:()=>r("/sla/new"),className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow-lg",children:[t.jsx(Rr,{}),t.jsx("span",{className:"font-medium",children:e("supportPlans.createFirstSupportPlan")})]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-4",children:[t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e("supportPlans.statsTotalPlans")}),t.jsx("p",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:ze})]}),t.jsx(pp,{className:"text-3xl text-indigo-500"})]})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e("supportPlans.statsContracts")}),t.jsx("p",{className:"text-2xl font-bold text-blue-600",children:pe.filter(Ue=>Ue.custom_contractwarranty==="Contract").length})]}),t.jsx("div",{className:"w-10 h-10 rounded-full bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center",children:t.jsx(kv,{className:"text-blue-600"})})]})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e("supportPlans.statsWarranties")}),t.jsx("p",{className:"text-2xl font-bold text-purple-600",children:pe.filter(Ue=>Ue.custom_contractwarranty==="Warranty").length})]}),t.jsx("div",{className:"w-10 h-10 rounded-full bg-purple-100 dark:bg-purple-900/30 flex items-center justify-center",children:t.jsx(Rf,{className:"text-purple-600"})})]})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e("supportPlans.statsActive")}),t.jsx("p",{className:"text-2xl font-bold text-green-600",children:pe.filter(Ue=>Ue.service_contract_status==="Active"||Ue.war_status==="Active").length})]}),t.jsx("div",{className:"w-10 h-10 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:t.jsx("span",{className:"text-green-600 font-bold",children:"✓"})})]})})]}),ie&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-4",children:[t.jsx("div",{className:"bg-gradient-to-r from-indigo-500 to-indigo-600 px-4 py-3 rounded-t-lg",children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ds,{className:"text-white",size:16}),t.jsx("h3",{className:"text-white font-semibold text-sm",children:"Filters"}),he>0&&t.jsx("span",{className:"bg-white text-indigo-600 px-2 py-0.5 rounded-full text-xs font-bold",children:he})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[he>0&&t.jsxs("button",{onClick:()=>K(!0),className:"px-3 py-1.5 bg-white text-indigo-600 hover:bg-indigo-50 rounded-md text-xs font-medium flex items-center gap-1.5",children:[t.jsx(ta,{size:12}),"Save"]}),Ie&&t.jsxs("button",{onClick:jt,className:"px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white rounded-md text-xs font-medium flex items-center gap-1.5",children:[t.jsx(ht,{size:12}),"Clear"]})]})]})}),t.jsxs("div",{className:"p-4",children:[xe.length>0&&t.jsxs("div",{className:"mb-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[t.jsx(a0,{className:"text-yellow-500",size:12}),"Saved Filters"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:xe.map(Ue=>t.jsxs("div",{className:"group relative inline-flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-indigo-100 to-blue-100 dark:from-indigo-900/30 dark:to-blue-900/30 border border-indigo-200 dark:border-indigo-700 rounded-lg hover:shadow-md",children:[t.jsx("button",{onClick:()=>Qe(Ue),className:"text-xs font-medium text-indigo-700 dark:text-indigo-300",children:Ue.name}),t.jsx("button",{onClick:()=>at(Ue.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700",children:t.jsx(wr,{size:10})})]},Ue.id))})]}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 p-3 rounded-lg",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-6 gap-3",children:[t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.filterBy")}),t.jsxs("select",{value:E,onChange:Ue=>{const Ve=Ue.target.value;R(Ve),l(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("filters.filterBy")}),t.jsx("option",{value:"creation",children:e("filters.createdDate")}),t.jsx("option",{value:"modified",children:e("filters.latestModifiedDate")})]})]}),E&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.startDate")}),t.jsx("input",{type:"date",value:z,onChange:Ue=>{const Ve=Ue.target.value;G(Ve),ae&&Ve>ae&&ee(Ve),l(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.endDate")}),t.jsx("input",{type:"date",value:ae,onChange:Ue=>{ee(Ue.target.value),l(1)},min:z||void 0,className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:"Contract/Warranty"}),t.jsxs("select",{value:ne,onChange:Ue=>{te(Ue.target.value),l(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:"All Types"}),t.jsx("option",{value:"Contract",children:"Contract"}),t.jsx("option",{value:"Warranty",children:"Warranty"})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:"Frequency"}),t.jsxs("select",{value:Y,onChange:Ue=>{q(Ue.target.value),l(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:"All Frequencies"}),t.jsx("option",{value:"Monthly",children:"Monthly"}),t.jsx("option",{value:"Quarterly",children:"Quarterly"}),t.jsx("option",{value:"Half-Yearly",children:"Half-Yearly"}),t.jsx("option",{value:"Yearly",children:"Yearly"})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:"Warranty Status"}),t.jsxs("select",{value:H,onChange:Ue=>{U(Ue.target.value),l(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:"All Statuses"}),t.jsx("option",{value:"Active",children:"Active"}),t.jsx("option",{value:"Inactive",children:"Inactive"}),t.jsx("option",{value:"Expired",children:"Expired"})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:"Contract Status"}),t.jsxs("select",{value:re,onChange:Ue=>{X(Ue.target.value),l(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:"All Statuses"}),t.jsx("option",{value:"Active",children:"Active"}),t.jsx("option",{value:"Inactive",children:"Inactive"}),t.jsx("option",{value:"Expired",children:"Expired"})]})]}),t.jsxs("div",{className:"relative z-[60]",children:[t.jsx(Je,{label:"Vendor",doctype:"Supplier",value:V,onChange:Ue=>{I(Ue),l(1)},placeholder:"Select Vendor",disabled:!1,compact:!0}),V&&t.jsx("button",{onClick:()=>I(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 z-10",children:t.jsx(ht,{size:10})})]}),t.jsxs("div",{className:"relative z-[59]",children:[t.jsx(Je,{label:"Asset",doctype:"Asset",value:B,onChange:Ue=>{Q(Ue),l(1)},placeholder:"Select Asset",disabled:!1,compact:!0}),B&&t.jsx("button",{onClick:()=>Q(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 z-10",children:t.jsx(ht,{size:10})})]})]})})]})]}),be&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 animate-scale-in",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:e("common.saveFilterPreset")}),t.jsx("input",{type:"text",value:ye,onChange:Ue=>Z(Ue.target.value),onKeyDown:Ue=>{Ue.key==="Enter"&&$e()},placeholder:e("common.enterFilterName"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white mb-4",autoFocus:!0}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:()=>{K(!1),Z("")},className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md",children:e("common.cancel")}),t.jsxs("button",{onClick:$e,className:"px-4 py-2 text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 rounded-md flex items-center gap-2",children:[t.jsx(ta,{size:12}),e("common.saveFilter")]})]})]})}),t.jsx(jle,{isOpen:b,onClose:()=>w(!1),selectedCount:f.size,totalCount:ze,pageCount:pe.length,onExport:He,isExporting:v,exportColumns:a}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-200 dark:border-gray-700 overflow-hidden relative",children:[le&&u&&t.jsx("div",{className:"absolute inset-0 bg-white/60 dark:bg-gray-800/60 flex items-center justify-center z-10 backdrop-blur-[1px]",children:t.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-gray-700 px-4 py-2 rounded-lg shadow-lg",children:[t.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-indigo-500"}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:e("common.filtering")})]})}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left",children:t.jsx("button",{onClick:vt,className:"text-gray-500 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400",title:er?"Deselect all":"Select all",children:er?t.jsx(Ra,{className:"text-indigo-600 dark:text-indigo-400",size:18}):nr?t.jsxs("div",{className:"relative",children:[t.jsx(Ur,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Ur,{size:18})})}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("supportPlans.table.planName","Plan Name")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("supportPlans.table.type","Type")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("supportPlans.table.frequency","Frequency")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("supportPlans.table.contractValue","Contract Value")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.status")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.supplier")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("listPages.actions")})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:pe.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:8,className:"px-4 py-12 text-center text-gray-500 dark:text-gray-400",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx(pp,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("supportPlans.noSupportPlansFound","No support plans found")}),Ie?t.jsx("button",{onClick:jt,className:"mt-4 text-indigo-600 dark:text-indigo-400 hover:underline",children:e("common.clearFilters")}):T?t.jsx("button",{onClick:()=>r("/sla/new"),className:"mt-4 text-indigo-600 dark:text-indigo-400 hover:underline",children:e("supportPlans.createFirstSupportPlan","Create your first support plan")}):null]})})}):pe.map(Ue=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 cursor-pointer transition-colors ${f.has(Ue.name)?"bg-indigo-50 dark:bg-indigo-900/20":""}`,onClick:()=>r(`/sla/${Ue.name}`),children:[t.jsx("td",{className:"px-4 py-3",onClick:Ve=>Ve.stopPropagation(),children:t.jsx("button",{onClick:()=>Ct(Ue.name),className:"text-gray-500 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400",children:f.has(Ue.name)?t.jsx(Ra,{className:"text-indigo-600 dark:text-indigo-400",size:18}):t.jsx(Ur,{size:18})})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{children:[t.jsx("span",{className:"text-sm font-medium text-indigo-600 dark:text-indigo-400",children:Ue.support_plan||Ue.name}),Ue.asset&&t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5 flex items-center gap-1",children:[t.jsx(vm,{size:10})," ",Ue.asset]})]})}),t.jsx("td",{className:"px-4 py-3",children:Ue.custom_contractwarranty?t.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${_le(Ue.custom_contractwarranty)}`,children:Ue.custom_contractwarranty}):t.jsx("span",{className:"text-gray-400",children:"-"})}),t.jsx("td",{className:"px-4 py-3",children:Ue.frequency?t.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${kle(Ue.frequency)}`,children:Ue.frequency}):t.jsx("span",{className:"text-gray-400",children:"-"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:Et(Ue.custom_contract_value)})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex flex-col gap-1",children:[Ue.custom_contractwarranty==="Warranty"&&Ue.war_status&&t.jsxs("span",{className:`inline-flex px-2 py-0.5 text-[10px] font-medium rounded-full ${z7(Ue.war_status)}`,children:[e("supportPlans.statusLabel.warrantyPrefix","W:")," ",e(`supportPlans.status.${Ue.war_status.toLowerCase().replace(/\\s+/g,"_")}`,Ue.war_status)]}),Ue.custom_contractwarranty==="Contract"&&Ue.service_contract_status&&t.jsxs("span",{className:`inline-flex px-2 py-0.5 text-[10px] font-medium rounded-full ${z7(Ue.service_contract_status)}`,children:[e("supportPlans.statusLabel.contractPrefix","C:")," ",e(`supportPlans.status.${Ue.service_contract_status.toLowerCase().replace(/\\s+/g,"_")}`,Ue.service_contract_status)]}),!Ue.war_status&&!Ue.service_contract_status&&t.jsx("span",{className:"text-gray-400",children:"-"})]})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300 line-clamp-1",children:Ue.vendor||"-"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-1",onClick:Ve=>Ve.stopPropagation(),children:[t.jsx("button",{onClick:()=>r(`/sla/${Ue.name}`),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded",title:e("supportPlans.viewDetails","View"),children:t.jsx(Ps,{})}),t.jsx("button",{onClick:()=>r(`/sla/${Ue.name}?edit=true`),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded",title:e("supportPlans.editSupportPlan","Edit"),children:t.jsx(qr,{})}),C&&t.jsx("button",{onClick:()=>N(Ue.name),className:"text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300 p-2 hover:bg-red-50 dark:hover:bg-red-900/30 rounded",title:e("common.delete"),children:t.jsx(wr,{})})]})})]},Ue.name))})]})}),t.jsx(_l,{currentPage:o,totalCount:ze,pageSize:c,itemLabel:e("pagination.plans"),onPageChange:Ue=>l(Ue)})]}),S&&t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx("div",{className:"flex-shrink-0 w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:t.jsx(wr,{className:"text-red-600 dark:text-red-400 text-xl"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:e("supportPlans.deleteSupportPlan")}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:e("supportPlans.deleteConfirmMessage")}),t.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-md p-3 mb-4",children:t.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[t.jsxs("strong",{children:[e("supportPlans.planId"),":"]})," ",S]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>N(null),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-lg",children:e("common.cancel")}),t.jsxs("button",{onClick:()=>it(S),className:"px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg flex items-center gap-2",children:[t.jsx(wr,{}),e("common.delete")]})]})]})]})})}),t.jsx("style",{children:`
|
||
@keyframes scale-in { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
|
||
.animate-scale-in { animation: scale-in 0.2s ease-out; }
|
||
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }
|
||
.scrollbar-hide::-webkit-scrollbar { display: none; }
|
||
`})]})},$7=e=>{switch(e==null?void 0:e.toLowerCase()){case"active":return{bg:"bg-green-100 dark:bg-green-900/30",text:"text-green-800 dark:text-green-300",border:"border-green-200 dark:border-green-800"};case"inactive":return{bg:"bg-gray-100 dark:bg-gray-700",text:"text-gray-800 dark:text-gray-300",border:"border-gray-200 dark:border-gray-600"};case"expired":return{bg:"bg-red-100 dark:bg-red-900/30",text:"text-red-800 dark:text-red-300",border:"border-red-200 dark:border-red-800"};default:return{bg:"bg-gray-100 dark:bg-gray-700",text:"text-gray-800 dark:text-gray-300",border:"border-gray-200 dark:border-gray-600"}}},Sle=()=>{var ie,me;const{t:e}=sr(),{slaName:r}=hs(),[a]=_a(),s=hr(),n=r==="new",i=a.get("edit")==="true",[o,l]=p.useState(!0),[c,u]=p.useState(!1),[h,f]=p.useState([]),[y,b]=p.useState(!1),[w,v]=p.useState(!1),[k,S]=p.useState(!1),[N,C]=p.useState({support_plan:"",frequency:"Quarterly",max_downtime_hrs:0,asset:null,starting_date:null,penalty_factor:5,custom_contractwarranty:"Contract",custom_contract_value:"",warranty:0,warranty_start_date:null,warranty_end_date:null,war_status:"Active",extended_warranty:0,start:null,end:null,service_contract:1,spare_parts:1,spare_parts_labour:0,labour:0,ppm_only:0,no:0,start_date:null,end_date:null,service_contract_status:"Active",vendor:null,asset_list:[]}),{supportPlan:O,loading:T,error:P,refetch:E}=vle(n?null:r||null),{createSupportPlan:R,updateSupportPlan:z,deleteSupportPlan:G,loading:ae}=wle(),[ee,ne]=p.useState(n||i),te=p.useCallback(()=>J(null,null,function*(){if(!(n||!r)){b(!0);try{const de=yield(yield fetch(`/api/resource/Version?filters=[["ref_doctype","=","Support Plans"],["docname","=","${encodeURIComponent(r)}"]]&fields=["name","owner","creation","data"]&order_by=creation desc&limit=50`)).json();if(de!=null&&de.data&&de.data.length>0){const xe=de.data.map(ge=>{let be={changed:[]};try{be=JSON.parse(ge.data||"{}")}catch(K){}return{name:ge.name,owner:ge.owner,creation:ge.creation,changes:(be.changed||[]).map(K=>({field:K[0]||"",oldValue:K[1],newValue:K[2]}))}});f(xe)}else f([])}catch(he){console.error("Error fetching audit logs:",he),f([])}finally{b(!1)}}}),[n,r]);p.useEffect(()=>{te()},[te]),p.useEffect(()=>{O&&!n&&(C({support_plan:O.support_plan||"",frequency:O.frequency||"Quarterly",max_downtime_hrs:O.max_downtime_hrs||0,asset:O.asset||null,starting_date:O.starting_date||null,penalty_factor:O.penalty_factor||5,custom_contractwarranty:O.custom_contractwarranty||"Contract",custom_contract_value:O.custom_contract_value||"",warranty:O.warranty||0,warranty_start_date:O.warranty_start_date||null,warranty_end_date:O.warranty_end_date||null,war_status:O.war_status||"Active",extended_warranty:O.extended_warranty||0,start:O.start||null,end:O.end||null,service_contract:O.service_contract||0,spare_parts:O.spare_parts||0,spare_parts_labour:O.spare_parts_labour||0,labour:O.labour||0,ppm_only:O.ppm_only||0,no:O.no||0,start_date:O.start_date||null,end_date:O.end_date||null,service_contract_status:O.service_contract_status||"Active",vendor:O.vendor||null,asset_list:O.asset_list||[]}),i||ne(!1))},[O,n,i]);const Y=he=>{const{name:de,value:xe,type:ge}=he.target;C(ge==="checkbox"?be=>je(se({},be),{[de]:he.target.checked?1:0}):ge==="number"?be=>je(se({},be),{[de]:parseFloat(xe)||0}):be=>je(se({},be),{[de]:xe}))},q=()=>J(null,null,function*(){var he;if(!((he=N.support_plan)!=null&&he.trim())){We.error("Support Plan Name is required",{position:"top-right",autoClose:5e3,icon:t.jsx(pr,{})});return}try{if(n){const de=yield R(N);We.success("Support Plan created successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),s(`/sla/${de.name}`)}else yield z(r,N),We.success("Support Plan updated successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),ne(!1),E(),setTimeout(()=>te(),500)}catch(de){const xe=de instanceof Error?de.message:"Unknown error";We.error(`Failed to save: ${xe}`,{position:"top-right",autoClose:6e3,icon:t.jsx(pr,{})})}}),H=()=>J(null,null,function*(){try{yield G(r),We.success("Support Plan deleted successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),s(-1)}catch(he){const de=he instanceof Error?he.message:"Unknown error";We.error(`Failed to delete: ${de}`,{position:"top-right",autoClose:6e3,icon:t.jsx(pr,{})})}}),U=p.useCallback(he=>!ee,[ee]),re=he=>he.replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,de=>de.toUpperCase()),X=he=>he==null||he===""?"(empty)":String(he),V=he=>{if(!he)return"";const de=new Date(he),xe=new Date,ge=xe.getTime()-de.getTime(),be=Math.floor(ge/6e4),K=Math.floor(ge/36e5),ye=Math.floor(ge/864e5);return be<1?"Just now":be<60?`${be} min${be>1?"s":""} ago`:K<24?`${K} hour${K>1?"s":""} ago`:ye<7?`${ye} day${ye>1?"s":""} ago`:de.toLocaleDateString("en-US",{month:"short",day:"numeric",year:de.getFullYear()!==xe.getFullYear()?"numeric":void 0,hour:"2-digit",minute:"2-digit"})},I=he=>he?he.split("@")[0]:"Unknown";if(T)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading support plan..."})]})});if(P&&!n)return t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:"Error Loading Support Plan"}),t.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:P}),t.jsx("button",{onClick:()=>s(-1),className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded",children:"Back to Support Plans"})]})});const B=$7(N.war_status||""),Q=$7(N.service_contract_status||"");return t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[t.jsx($a,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:au}),t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("button",{onClick:()=>s(-1),className:"text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200",children:t.jsx(ia,{size:20})}),t.jsxs("div",{children:[t.jsxs("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white flex items-center gap-3",children:[n?"New Support Plan":N.support_plan||(O==null?void 0:O.name)||"Support Plan Details",!n&&N.custom_contractwarranty&&t.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-medium ${N.custom_contractwarranty==="Contract"?"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":"bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300"}`,children:N.custom_contractwarranty})]}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:n?"Create a new support plan":`ID: ${r}`})]})]}),t.jsxs("div",{className:"flex gap-3",children:[!n&&!ee&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>ne(!0),className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(qr,{}),"Edit"]}),o&&t.jsxs("button",{onClick:()=>u(!0),className:"bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(wr,{}),"Delete"]})]}),ee&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{n?s(-1):(ne(!1),E())},className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg",children:"Cancel"}),t.jsxs("button",{onClick:q,disabled:ae,className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 disabled:opacity-50",children:[t.jsx(ta,{}),ae?"Saving...":"Save"]})]})]})]}),c&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl",children:[t.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[t.jsx(Or,{className:"text-red-500 text-xl mt-0.5"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:"Delete Support Plan"}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Are you sure you want to delete this support plan? This action cannot be undone."})]})]}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>u(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",children:"Cancel"}),t.jsx("button",{onClick:H,disabled:ae,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg disabled:opacity-50",children:ae?"Deleting...":"Delete"})]})]})}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[t.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(pp,{className:"text-indigo-500"}),"Basic Information"]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Support Plan Name ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",name:"support_plan",value:N.support_plan||"",onChange:Y,disabled:U("support_plan"),placeholder:"Enter plan name",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Contract/Warranty Type"}),t.jsxs("select",{name:"custom_contractwarranty",value:N.custom_contractwarranty||"",onChange:Y,disabled:U("custom_contractwarranty"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500",children:[t.jsx("option",{value:"Contract",children:"Contract"}),t.jsx("option",{value:"Warranty",children:"Warranty"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Frequency"}),t.jsxs("select",{name:"frequency",value:N.frequency||"",onChange:Y,disabled:U("frequency"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500",children:[t.jsx("option",{value:"Monthly",children:"Monthly"}),t.jsx("option",{value:"Quarterly",children:"Quarterly"}),t.jsx("option",{value:"Half-Yearly",children:"Half-Yearly"}),t.jsx("option",{value:"Yearly",children:"Yearly"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Contract Value"}),t.jsx("input",{type:"text",name:"custom_contract_value",value:N.custom_contract_value||"",onChange:Y,disabled:U("custom_contract_value"),placeholder:"e.g., 10000",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]}),t.jsx("div",{children:t.jsx(Je,{label:"Asset",doctype:"Asset",value:N.asset||"",onChange:he=>C(je(se({},N),{asset:he||null})),disabled:U("asset"),placeholder:"Select Asset"})}),t.jsx("div",{children:t.jsx(Je,{label:"Vendor",doctype:"Supplier",value:N.vendor||"",onChange:he=>C(je(se({},N),{vendor:he||null})),disabled:U("vendor"),placeholder:"Select Vendor"})})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(kv,{className:"text-orange-500"}),"Performance Settings"]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Max Downtime (hrs)"}),t.jsx("input",{type:"number",name:"max_downtime_hrs",value:N.max_downtime_hrs||0,onChange:Y,disabled:U("max_downtime_hrs"),min:"0",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Penalty Factor (%)"}),t.jsx("input",{type:"number",name:"penalty_factor",value:N.penalty_factor||0,onChange:Y,disabled:U("penalty_factor"),min:"0",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Starting Date"}),t.jsx("input",{type:"date",name:"starting_date",value:N.starting_date||"",onChange:Y,disabled:U("starting_date"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(Rf,{className:"text-purple-500"}),"Warranty Information"]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("input",{type:"checkbox",name:"warranty",checked:!!N.warranty,onChange:Y,disabled:U("warranty"),className:"h-4 w-4 text-indigo-600 rounded"}),t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Has Warranty"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("input",{type:"checkbox",name:"extended_warranty",checked:!!N.extended_warranty,onChange:Y,disabled:U("extended_warranty"),className:"h-4 w-4 text-indigo-600 rounded"}),t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Extended Warranty"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Warranty Status"}),t.jsxs("select",{name:"war_status",value:N.war_status||"",onChange:Y,disabled:U("war_status"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500",children:[t.jsx("option",{value:"Active",children:"Active"}),t.jsx("option",{value:"Inactive",children:"Inactive"}),t.jsx("option",{value:"Expired",children:"Expired"})]})]}),t.jsx("div",{}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Warranty Start Date"}),t.jsx("input",{type:"date",name:"warranty_start_date",value:N.warranty_start_date||"",onChange:Y,disabled:U("warranty_start_date"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Warranty End Date"}),t.jsx("input",{type:"date",name:"warranty_end_date",value:N.warranty_end_date||"",onChange:Y,disabled:U("warranty_end_date"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(vm,{className:"text-blue-500"}),"Service Contract"]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("input",{type:"checkbox",name:"service_contract",checked:!!N.service_contract,onChange:Y,disabled:U("service_contract"),className:"h-4 w-4 text-indigo-600 rounded"}),t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Has Service Contract"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Service Contract Status"}),t.jsxs("select",{name:"service_contract_status",value:N.service_contract_status||"",onChange:Y,disabled:U("service_contract_status"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500",children:[t.jsx("option",{value:"Active",children:"Active"}),t.jsx("option",{value:"Inactive",children:"Inactive"}),t.jsx("option",{value:"Expired",children:"Expired"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Start Date"}),t.jsx("input",{type:"date",name:"start_date",value:N.start_date||"",onChange:Y,disabled:U("start_date"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"End Date"}),t.jsx("input",{type:"date",name:"end_date",value:N.end_date||"",onChange:Y,disabled:U("end_date"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]})]}),t.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-200 dark:border-gray-700",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:"Inclusions"}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"checkbox",name:"spare_parts",checked:!!N.spare_parts,onChange:Y,disabled:U("spare_parts"),className:"h-4 w-4 text-indigo-600 rounded"}),t.jsx("label",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Spare Parts"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"checkbox",name:"spare_parts_labour",checked:!!N.spare_parts_labour,onChange:Y,disabled:U("spare_parts_labour"),className:"h-4 w-4 text-indigo-600 rounded"}),t.jsx("label",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Spare Parts + Labour"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"checkbox",name:"labour",checked:!!N.labour,onChange:Y,disabled:U("labour"),className:"h-4 w-4 text-indigo-600 rounded"}),t.jsx("label",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Labour Only"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"checkbox",name:"ppm_only",checked:!!N.ppm_only,onChange:Y,disabled:U("ppm_only"),className:"h-4 w-4 text-indigo-600 rounded"}),t.jsx("label",{className:"text-sm text-gray-600 dark:text-gray-400",children:"PPM Only"})]})]})]})]}),!n&&t.jsx(Bm,{referenceDoctype:"Support Plans",referenceName:r||null,title:"Comments & Discussion",pollInterval:3e4,initialLimit:5,collapsible:!0,startCollapsed:!1})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-4 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-sm font-semibold text-gray-800 dark:text-white mb-3 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(pp,{className:"text-indigo-500",size:14}),"Status Overview"]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:`p-3 rounded-lg border ${N.custom_contractwarranty==="Contract"?"bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800":"bg-purple-50 dark:bg-purple-900/20 border-purple-200 dark:border-purple-800"}`,children:[t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:"Type"}),t.jsx("p",{className:`text-sm font-semibold ${N.custom_contractwarranty==="Contract"?"text-blue-700 dark:text-blue-300":"text-purple-700 dark:text-purple-300"}`,children:N.custom_contractwarranty||"Not Set"})]}),N.custom_contractwarranty==="Warranty"&&t.jsxs("div",{className:`p-3 rounded-lg border ${B.bg} ${B.border}`,children:[t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:"Warranty Status"}),t.jsx("p",{className:`text-sm font-semibold ${B.text}`,children:N.war_status||"Not Set"})]}),N.custom_contractwarranty==="Contract"&&t.jsxs("div",{className:`p-3 rounded-lg border ${Q.bg} ${Q.border}`,children:[t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:"Contract Status"}),t.jsx("p",{className:`text-sm font-semibold ${Q.text}`,children:N.service_contract_status||"Not Set"})]}),N.frequency&&t.jsxs("div",{className:"p-3 bg-indigo-50 dark:bg-indigo-900/20 rounded-lg border border-indigo-200 dark:border-indigo-800",children:[t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:"Frequency"}),t.jsx("p",{className:"text-sm font-semibold text-indigo-700 dark:text-indigo-300",children:N.frequency})]}),N.custom_contract_value&&t.jsxs("div",{className:"p-3 bg-green-50 dark:bg-green-900/20 rounded-lg border border-green-200 dark:border-green-800",children:[t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:"Contract Value"}),t.jsx("p",{className:"text-sm font-semibold text-green-700 dark:text-green-300",children:new Intl.NumberFormat("en-US",{style:"currency",currency:"SAR"}).format(parseFloat(N.custom_contract_value)||0)})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-4 border border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-sm font-semibold text-gray-800 dark:text-white mb-3 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(rc,{className:"text-orange-500",size:14}),"Quick Info"]}),t.jsxs("div",{className:"space-y-2 text-sm",children:[N.asset&&t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Asset:"}),t.jsx("span",{className:"text-gray-900 dark:text-white font-medium",children:N.asset})]}),N.vendor&&t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Vendor:"}),t.jsx("span",{className:"text-gray-900 dark:text-white font-medium",children:N.vendor})]}),((ie=N.max_downtime_hrs)!=null?ie:0)>0&&t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Max Downtime:"}),t.jsxs("span",{className:"text-gray-900 dark:text-white font-medium",children:[N.max_downtime_hrs," hrs"]})]}),((me=N.penalty_factor)!=null?me:0)>0&&t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Penalty Factor:"}),t.jsxs("span",{className:"text-gray-900 dark:text-white font-medium",children:[N.penalty_factor,"%"]})]})]})]}),!n&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center gap-2 cursor-pointer flex-1",onClick:()=>v(!w),children:[t.jsx(ym,{className:"text-blue-500",size:14}),t.jsx("h2",{className:"text-sm font-semibold text-gray-800 dark:text-white",children:"Activity Log"}),h.length>0&&t.jsx("span",{className:"px-1.5 py-0.5 bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 rounded-full text-[10px] font-medium",children:h.length})]}),t.jsx("button",{onClick:()=>v(!w),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-1",children:w?t.jsx(Ja,{size:12}):t.jsx(Fr,{size:12})})]}),w&&t.jsx("div",{className:"p-3",children:y?t.jsxs("div",{className:"flex items-center justify-center py-4",children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-500 mr-2"}),t.jsx("span",{className:"text-xs text-gray-500",children:"Loading..."})]}):h.length===0?t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 text-center py-4",children:"No changes recorded yet"}):t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute left-2 top-0 bottom-0 w-0.5 bg-gray-200 dark:bg-gray-700"}),t.jsx("div",{className:"space-y-3",children:(k?h:h.slice(0,5)).map((he,de)=>t.jsxs("div",{className:"relative pl-6",children:[t.jsx("div",{className:`absolute left-1 top-1 w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 ${de===0?"bg-blue-500":"bg-gray-300 dark:bg-gray-600"}`}),t.jsxs("div",{className:`p-2 rounded-lg ${de===0?"bg-blue-50 dark:bg-blue-900/20":"bg-gray-50 dark:bg-gray-700/50"}`,children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"text-[10px] font-medium text-gray-700 dark:text-gray-300",children:I(he.owner)}),t.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-500",children:[t.jsx(ea,{size:8}),V(he.creation)]})]}),he.changes.length>0?he.changes.map((xe,ge)=>t.jsxs("div",{className:"text-[10px]",children:[t.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:re(xe.field)}),t.jsx("span",{className:"text-gray-500",children:" changed from "}),t.jsx("span",{className:"px-1 py-0.5 bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400 rounded text-[9px]",children:X(xe.oldValue)}),t.jsx("span",{className:"text-gray-500",children:" → "}),t.jsx("span",{className:"px-1 py-0.5 bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400 rounded text-[9px]",children:X(xe.newValue)})]},ge)):t.jsx("p",{className:"text-[10px] text-gray-500 italic",children:"Document updated"})]})]},he.name))}),h.length>5&&t.jsx("div",{className:"mt-3 text-center",children:t.jsx("button",{onClick:()=>S(!k),className:"inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-md",children:k?t.jsxs(t.Fragment,{children:[t.jsx(Ja,{size:8}),"Show Less"]}):t.jsxs(t.Fragment,{children:[t.jsx(Fr,{size:8}),"Show All (",h.length,")"]})})}),(O==null?void 0:O.creation)&&(O==null?void 0:O.owner)&&t.jsxs("div",{className:"relative pl-6 mt-3",children:[t.jsx("div",{className:"absolute left-1 top-1 w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 bg-green-500"}),t.jsxs("div",{className:"p-2 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-100 dark:border-green-800/50",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"text-[10px] font-medium text-gray-700 dark:text-gray-300",children:I(O.owner)}),t.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-500",children:[t.jsx(ea,{size:8}),V(O.creation)]})]}),t.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 bg-green-100 dark:bg-green-800/50 text-green-700 dark:text-green-300 rounded text-[10px] font-medium",children:[t.jsx(Qt,{size:8}),"Created this Support Plan"]})]})]})]})})]})]})]})]})},Cle=()=>J(null,null,function*(){var e;try{const s=(yield(yield fetch("/api/method/frappe.auth.get_logged_user",{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json()).message;if(!s)throw new Error("No user logged in");const i=yield(yield fetch("/api/method/frappe.client.get",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({doctype:"User",name:s})})).json();if(console.log("frappe.client.get response:",i),console.log("role_profile_name:",(e=i.message)==null?void 0:e.role_profile_name),i.message){const o=i.message;return o.roles||(o.roles=[]),o}throw new Error("Failed to fetch user profile")}catch(r){throw console.error("Error fetching user profile:",r),r}}),Tle=(e,r)=>J(null,null,function*(){try{const a=yield fetch(`/api/resource/User/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(r)}),s=yield a.json();if(!a.ok)throw new Error(s.exc||s.message||"Failed to update profile");return s.data}catch(a){throw console.error("Error updating user profile:",a),a}}),Ele=(e,r)=>J(null,null,function*(){try{const a=yield fetch("/api/method/frappe.core.doctype.user.user.update_password",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({new_password:e,old_password:r})}),s=yield a.json();if(!a.ok){let n="Failed to change password";if(s.exc){if(s.exc.includes("Incorrect Old Password"))n="Incorrect old password";else if(s.exc.includes("Password cannot be same"))n="New password cannot be the same as old password";else if(s._server_messages)try{const i=JSON.parse(s._server_messages);n=JSON.parse(i[0]).message||n}catch(i){}}throw new Error(n)}return{message:"Password changed successfully"}}catch(a){throw console.error("Error changing password:",a),a}}),WL="";function Ale(e){return J(this,null,function*(){const r=yield At.getCSRFTokenForGuest(),a={Accept:"application/json","Content-Type":"application/json"};r&&(a["X-Frappe-CSRF-Token"]=r);const s=yield fetch(`${WL}/api/method/asm_ui_app.api.two_factor.get_two_factor_status`,{method:"POST",credentials:"include",headers:a,body:JSON.stringify(e?{user:e}:{})}),n=yield s.json();if(!s.ok){const i=typeof n.message=="string"?n.message:n.exc||"Failed to load two-factor status";throw new Error(i)}return n.message})}function Ole(e){return J(this,null,function*(){const r=yield At.getCSRFTokenForGuest(),a={Accept:"application/json","Content-Type":"application/json"};r&&(a["X-Frappe-CSRF-Token"]=r);const s=yield fetch(`${WL}/api/method/frappe.twofactor.reset_otp_secret`,{method:"POST",credentials:"include",headers:a,body:JSON.stringify({user:e})}),n=yield s.json();if(!s.ok){const i=typeof n.message=="string"?n.message:n.exc||"Failed to reset OTP secret";throw new Error(i)}})}const Ple=()=>{const e=hr(),{t:r}=sr(),[a,s]=p.useState(!0),[n,i]=p.useState(!1),[o,l]=p.useState(!1),[c,u]=p.useState(!1),[h,f]=p.useState(null),[y,b]=p.useState(null),[w,v]=p.useState({first_name:"",middle_name:"",last_name:"",role_profile_name:"",custom_user_id:""}),[k,S]=p.useState(!1),[N,C]=p.useState({old_password:"",new_password:"",confirm_password:""}),[O,T]=p.useState(!1),[P,E]=p.useState(!1),[R,z]=p.useState(!1),[G,ae]=p.useState(null),[ee,ne]=p.useState(!0),[te,Y]=p.useState(!1);p.useEffect(()=>{J(null,null,function*(){var B;try{s(!0);const me=((B=(yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({roles:"System Manager"})})).json()).message)==null?void 0:B.has_role)||!1;l(me),console.log("Is System Manager:",me);const he=yield Cle();console.log("Full profile data:",JSON.stringify(he,null,2)),console.log("role_profile_name:",he.role_profile_name),console.log("All keys:",Object.keys(he)),f(he),v({first_name:he.first_name||"",middle_name:he.middle_name||"",last_name:he.last_name||"",role_profile_name:he.role_profile_name||"",custom_user_id:he.custom_user_id||""});try{const de=yield Ale(he.name);ae(de)}catch(de){console.warn("Could not load 2FA status:",de),ae(null)}finally{ne(!1)}}catch(Q){const ie=Q instanceof Error?Q.message:"Failed to load profile";b(ie),We.error(ie,{position:"top-right",autoClose:5e3,icon:t.jsx(pr,{})})}finally{s(!1)}})},[]);const q=I=>{const{name:B,value:Q}=I.target;v(ie=>je(se({},ie),{[B]:Q}))},H=I=>{const{name:B,value:Q}=I.target;C(ie=>je(se({},ie),{[B]:Q}))},U=()=>J(null,null,function*(){if(h!=null&&h.email)try{i(!0);const I={first_name:w.first_name,middle_name:w.middle_name,last_name:w.last_name,role_profile_name:w.role_profile_name},B=yield Tle(h.email,I);f(Q=>Q?se(se({},Q),B):B),We.success("Profile updated successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})})}catch(I){const B=I instanceof Error?I.message:"Failed to update profile";We.error(B,{position:"top-right",autoClose:5e3,icon:t.jsx(pr,{})})}finally{i(!1)}}),re=()=>J(null,null,function*(){if(h!=null&&h.name&&window.confirm(r("profile.resetOtpConfirm")))try{Y(!0),yield Ole(h.name),We.success(r("profile.resetOtpSuccess"),{position:"top-right",autoClose:5e3,icon:t.jsx(Qt,{})})}catch(I){const B=I instanceof Error?I.message:r("profile.resetOtpFailed");We.error(B,{position:"top-right",autoClose:5e3,icon:t.jsx(pr,{})})}finally{Y(!1)}}),X=()=>J(null,null,function*(){if(!N.old_password){We.error("Please enter your current password",{position:"top-right",autoClose:3e3,icon:t.jsx(Or,{})});return}if(!N.new_password){We.error("Please enter a new password",{position:"top-right",autoClose:3e3,icon:t.jsx(Or,{})});return}if(N.new_password.length<8){We.error("Password must be at least 8 characters long",{position:"top-right",autoClose:3e3,icon:t.jsx(Or,{})});return}if(N.new_password!==N.confirm_password){We.error("New passwords do not match",{position:"top-right",autoClose:3e3,icon:t.jsx(Or,{})});return}try{u(!0),yield Ele(N.new_password,N.old_password),We.success("Password changed successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Qt,{})}),C({old_password:"",new_password:"",confirm_password:""}),S(!1)}catch(I){const B=I instanceof Error?I.message:"Failed to change password";We.error(B,{position:"top-right",autoClose:5e3,icon:t.jsx(pr,{})})}finally{u(!1)}});if(a)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx(tr,{className:"animate-spin text-blue-500 text-4xl mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading profile..."})]})});if(y&&!h)return t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsxs("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:[t.jsx(pr,{className:"inline mr-2"}),"Error Loading Profile"]}),t.jsx("p",{className:"text-red-700 dark:text-red-400",children:y}),t.jsx("button",{onClick:()=>e(-1),className:"mt-4 bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded",children:"Go Back"})]})});const V=!ee&&!!(G!=null&&G.enabled_globally)&&!!(G!=null&&G.required_for_user)&&!!(G!=null&&G.otp_app);return t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[t.jsx($a,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:au}),t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsx("div",{className:"flex items-center gap-4",children:t.jsxs("button",{onClick:()=>e(-1),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-2",children:[t.jsx(ia,{}),t.jsx("span",{className:"text-gray-900 dark:text-white text-xl font-semibold",children:"User Profile"})]})}),t.jsx("button",{onClick:U,disabled:n,className:"bg-green-600 hover:bg-green-700 text-white px-6 py-2 rounded-lg flex items-center gap-2 disabled:opacity-50 shadow-lg transition-all",children:n?t.jsxs(t.Fragment,{children:[t.jsx(tr,{className:"animate-spin"}),"Saving..."]}):t.jsxs(t.Fragment,{children:[t.jsx(ta,{}),"Save Changes"]})})]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[t.jsx("div",{className:"lg:col-span-1",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 overflow-hidden",children:[t.jsxs("div",{className:"bg-gradient-to-r from-blue-500 to-blue-600 p-6 text-center",children:[t.jsx("div",{className:"w-24 h-24 bg-white/20 rounded-full mx-auto flex items-center justify-center mb-4",children:h!=null&&h.user_image?t.jsx("img",{src:h.user_image,alt:"Profile",className:"w-20 h-20 rounded-full object-cover"}):t.jsx(nn,{className:"text-white text-4xl"})}),t.jsx("h2",{className:"text-xl font-bold text-white",children:(h==null?void 0:h.full_name)||"User"}),t.jsx("p",{className:"text-white/80 text-sm mt-1",children:h==null?void 0:h.email})]}),t.jsxs("div",{className:"p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx($G,{className:"text-blue-500"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Username"}),t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:(h==null?void 0:h.username)||"-"})]})]}),t.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx(JG,{className:"text-green-500"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Role Profile"}),t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:(h==null?void 0:h.role_profile_name)||"-"})]})]}),t.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx(Rf,{className:"text-purple-500"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Status"}),t.jsx("p",{className:`text-sm font-medium ${h!=null&&h.enabled?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:h!=null&&h.enabled?"Active":"Inactive"})]})]}),ee&&t.jsxs("div",{className:"flex items-center gap-2 px-1 py-1 text-[11px] text-gray-400",children:[t.jsx(tr,{className:"animate-spin shrink-0",size:12}),t.jsx("span",{children:r("profile.twoFactorLoading")})]}),V&&t.jsx("div",{className:"rounded-lg border border-purple-200 bg-purple-50/80 p-3 dark:border-purple-800 dark:bg-purple-900/20",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Rf,{className:"mt-0.5 shrink-0 text-purple-600 dark:text-purple-400",size:13}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-xs font-semibold text-purple-900 dark:text-purple-200",children:r("profile.twoFactorSidebarTitle")}),t.jsx("p",{className:"mt-1 text-[11px] leading-snug text-purple-800/90 dark:text-purple-300/90",children:r("profile.twoFactorRequired")}),t.jsx("p",{className:"mt-1 text-[10px] leading-snug text-gray-600 dark:text-gray-400",children:r("profile.twoFactorOtpAppNoteShort")}),t.jsxs("button",{type:"button",onClick:re,disabled:te,className:"mt-2 inline-flex w-full items-center justify-center gap-1.5 rounded-md border border-purple-300 bg-white px-2 py-1.5 text-[11px] font-medium text-purple-800 hover:bg-purple-50 disabled:opacity-50 dark:border-purple-600 dark:bg-purple-950/40 dark:text-purple-200 dark:hover:bg-purple-900/40",children:[te?t.jsx(tr,{className:"animate-spin",size:10}):t.jsx(Rf,{size:10}),r("profile.resetOtp")]})]})]})})]})]})}),t.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 p-6",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(nn,{className:"text-blue-500"}),"Basic Information"]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Email",t.jsx("span",{className:"ml-1 text-gray-400",children:"(Read-only)"})]}),t.jsxs("div",{className:"relative",children:[t.jsx(G9,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400",size:14}),t.jsx("input",{type:"email",value:(h==null?void 0:h.email)||"",disabled:!0,className:"w-full pl-10 pr-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400 cursor-not-allowed"})]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Full Name",t.jsx("span",{className:"ml-1 text-gray-400",children:"(Auto-generated)"})]}),t.jsx("input",{type:"text",value:(h==null?void 0:h.full_name)||"",disabled:!0,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400 cursor-not-allowed"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["First Name ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",name:"first_name",value:w.first_name,onChange:q,placeholder:"Enter first name",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Middle Name"}),t.jsx("input",{type:"text",name:"middle_name",value:w.middle_name,onChange:q,placeholder:"Enter middle name",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Last Name"}),t.jsx("input",{type:"text",name:"last_name",value:w.last_name,onChange:q,placeholder:"Enter last name",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"User ID No"}),t.jsx("input",{type:"text",name:"custom_user_id",value:w.custom_user_id,onChange:q,placeholder:"Enter User No",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsx("div",{children:t.jsx(Je,{label:"Role Profile",doctype:"Role Profile",value:w.role_profile_name,onChange:I=>v(B=>je(se({},B),{role_profile_name:I})),placeholder:"Select Role Profile",disabled:!o})})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 p-6",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white flex items-center gap-2",children:[t.jsx(ak,{className:"text-orange-500"}),"Change Password"]}),t.jsx("button",{onClick:()=>S(!k),className:"text-sm text-blue-600 dark:text-blue-400 hover:underline",children:k?"Cancel":"Change Password"})]}),k?t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Current Password ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("div",{className:"relative",children:[t.jsx("input",{type:O?"text":"password",name:"old_password",value:N.old_password,onChange:H,placeholder:"Enter current password",className:"w-full px-3 py-2 pr-10 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),t.jsx("button",{type:"button",onClick:()=>T(!O),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:O?t.jsx(rk,{size:14}):t.jsx(Ps,{size:14})})]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["New Password ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("div",{className:"relative",children:[t.jsx("input",{type:P?"text":"password",name:"new_password",value:N.new_password,onChange:H,placeholder:"Enter new password (min 8 characters)",className:"w-full px-3 py-2 pr-10 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),t.jsx("button",{type:"button",onClick:()=>E(!P),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:P?t.jsx(rk,{size:14}):t.jsx(Ps,{size:14})})]}),N.new_password&&N.new_password.length<8&&t.jsx("p",{className:"mt-1 text-xs text-red-500",children:"Password must be at least 8 characters"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Confirm New Password ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("div",{className:"relative",children:[t.jsx("input",{type:R?"text":"password",name:"confirm_password",value:N.confirm_password,onChange:H,placeholder:"Confirm new password",className:"w-full px-3 py-2 pr-10 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),t.jsx("button",{type:"button",onClick:()=>z(!R),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:R?t.jsx(rk,{size:14}):t.jsx(Ps,{size:14})})]}),N.confirm_password&&N.new_password!==N.confirm_password&&t.jsx("p",{className:"mt-1 text-xs text-red-500",children:"Passwords do not match"}),N.confirm_password&&N.new_password===N.confirm_password&&N.new_password.length>=8&&t.jsxs("p",{className:"mt-1 text-xs text-green-500 flex items-center gap-1",children:[t.jsx(Qt,{size:10})," Passwords match"]})]}),t.jsx("div",{className:"pt-2",children:t.jsx("button",{onClick:X,disabled:c,className:"w-full bg-orange-600 hover:bg-orange-700 text-white px-4 py-2.5 rounded-lg flex items-center justify-center gap-2 disabled:opacity-50 transition-colors",children:c?t.jsxs(t.Fragment,{children:[t.jsx(tr,{className:"animate-spin"}),"Changing Password..."]}):t.jsxs(t.Fragment,{children:[t.jsx(ak,{}),"Change Password"]})})})]}):t.jsxs("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:[t.jsx(ak,{className:"mx-auto text-3xl mb-2 text-gray-300 dark:text-gray-600"}),t.jsx("p",{className:"text-sm",children:'Click "Change Password" to update your password'})]})]})]})]})]})},_f="custom_task_updates",kf="custom_project_updates";function MN(e,r){const a=r==null?void 0:r.fillTaskLink;return e.filter(s=>{const n=String(s.update_||"").trim(),i=String(s.date||"").trim(),o=String(s.task||"").trim();return n||i||o}).map((s,n)=>{const i={idx:n+1,update_:s.update_||""};s.date&&(i.date=s.date),s.name&&(i.name=s.name);const o=a!=null?a:s.task;return o&&(i.task=o),i})}class Dle{constructor(){$s(this,"baseURL",Ar.BASE_URL);$s(this,"TASK_FIELDS",["name","subject","project","status","priority","task_weight","is_group","is_template","is_milestone","expected_time","actual_time","progress","exp_start_date","exp_end_date","parent_task","completed_on","custom_risk","custom_action","custom_task_obstacle","custom_assign_to","total_costing_amount","total_billing_amount","company","depends_on_tasks","_assign","owner","creation","modified"])}clearCsrfTokenCache(){if(typeof window!="undefined")try{delete window.csrf_token;const r=window.frappe;if(r&&typeof r=="object"&&"csrf_token"in r)try{delete r.csrf_token}catch(a){r.csrf_token=""}}catch(r){}}getCSRFToken(){return J(this,null,function*(){var r;if(typeof window=="undefined")return null;if(window.csrf_token)return window.csrf_token;if((r=window.frappe)!=null&&r.csrf_token)return window.frappe.csrf_token;try{const a=yield fetch(`${this.baseURL}/api/method/frappe.sessions.get_csrf_token`,{credentials:"include",cache:"no-store"});if(a.ok){const s=yield a.json();if(s.message)return window.csrf_token=s.message,s.message}}catch(a){}return null})}mergeHeaders(r,a){const s=se({},r);if(!a)return s;if(a instanceof Headers)return a.forEach((n,i)=>{s[i]=n}),s;if(Array.isArray(a)){for(const[n,i]of a)s[n]=i;return s}return se(se({},s),a)}isFrappeCsrfError(r){if(!r||typeof r!="object")return!1;const a=r;if(a.exc_type==="CSRFTokenError")return!0;const s=typeof a.message=="string"?a.message:"";if(/csrf/i.test(s))return!0;if(a._server_messages&&typeof a._server_messages=="string"){try{const i=JSON.parse(a._server_messages)[0],o=typeof i=="string"?JSON.parse(i):i,l=typeof(o==null?void 0:o.message)=="string"?o.message:"";if(/invalid request/i.test(l)&&a.exc_type==="CSRFTokenError")return!0}catch(n){}if(/CSRFTokenError|csrf/i.test(a._server_messages))return!0}return!1}getHeaders(){return J(this,null,function*(){const r={Accept:"application/json","Content-Type":"application/json"},a=yield this.getCSRFToken();return a&&(r["X-Frappe-CSRF-Token"]=a),r})}parseFrappeError(r){return J(this,null,function*(){const a={403:"Permission denied. Your role does not have access to this DocType.",417:"Validation error. Check field values or role permissions for this DocType.",404:"Record not found.",500:"Server error. Check that all field names are correct."};try{const s=yield r.json();if(s._server_messages)try{const n=JSON.parse(s._server_messages),i=typeof n[0]=="string"?JSON.parse(n[0]):n[0];if(i!=null&&i.message)return new Error(i.message)}catch(n){}if(s.message&&typeof s.message=="string"&&s.message.trim())return new Error(s.message);if(s.exc_type){const n=s.exc?s.exc.split(`
|
||
`).slice(-2).join(" ").trim():"";return new Error(`${s.exc_type}: ${n||a[r.status]||r.statusText}`)}}catch(s){}return new Error(a[r.status]||`HTTP ${r.status}: ${r.statusText}`)})}fetchJson(r,a){return J(this,null,function*(){const s=yield fetch(r,je(se({credentials:"include"},a),{headers:se(se({},yield this.getHeaders()),(a==null?void 0:a.headers)||{})}));if(!s.ok)throw yield this.parseFrappeError(s.clone());return s.json()})}getProjects(){return J(this,arguments,function*(r={}){const{filters:a={},fields:s=["name","project_name","status","priority","company","customer","expected_start_date","expected_end_date","percent_complete","actual_time","creation","modified","owner"],limit_start:n=0,limit_page_length:i=20,order_by:o="modified desc"}=r,l=new URLSearchParams;if(l.set("fields",JSON.stringify(s)),l.set("limit_start",String(n)),l.set("limit_page_length",String(i)),l.set("order_by",o),Object.keys(a).length>0){const u=xa(a);u.length>0&&l.set("filters",JSON.stringify(u))}return{data:(yield this.fetchJson(`${this.baseURL}/api/resource/Project?${l}`)).data||[]}})}getProject(r){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Project/${encodeURIComponent(r)}`)).data})}getProjectCount(){return J(this,arguments,function*(r={}){var s,n;const a=new URLSearchParams;if(a.set("fields",JSON.stringify(["count(name) as count"])),Object.keys(r).length>0){const i=xa(r);i.length>0&&a.set("filters",JSON.stringify(i))}try{return((n=(s=(yield this.fetchJson(`${this.baseURL}/api/resource/Project?${a}`)).data)==null?void 0:s[0])==null?void 0:n.count)||0}catch(i){return 0}})}createProject(r){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Project`,{method:"POST",body:JSON.stringify(r)})).data})}updateProject(r,a){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Project/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify(a)})).data})}getProjectTemplates(){return J(this,arguments,function*(r={}){const{filters:a={},limit_start:s=0,limit_page_length:n=50,order_by:i="name asc"}=r,o=new URLSearchParams;if(o.set("fields",JSON.stringify(["name","project_type","creation","modified"])),o.set("limit_start",String(s)),o.set("limit_page_length",String(n)),o.set("order_by",i),Object.keys(a).length>0){const l=xa(a);l.length>0&&o.set("filters",JSON.stringify(l))}try{return{data:(yield this.fetchJson(`${this.baseURL}/api/resource/Project%20Template?${o}`)).data||[]}}catch(l){return{data:[]}}})}getProjectTemplate(r){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Project%20Template/${encodeURIComponent(r)}`)).data})}createProjectTemplate(r){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Project%20Template`,{method:"POST",body:JSON.stringify(r)})).data})}updateProjectTemplate(r,a){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Project%20Template/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify(a)})).data})}getProjectTemplateCount(){return J(this,arguments,function*(r={}){var s,n;const a=new URLSearchParams;if(a.set("fields",JSON.stringify(["count(name) as count"])),Object.keys(r).length>0){const i=xa(r);i.length>0&&a.set("filters",JSON.stringify(i))}try{return((n=(s=(yield this.fetchJson(`${this.baseURL}/api/resource/Project%20Template?${a}`)).data)==null?void 0:s[0])==null?void 0:n.count)||0}catch(i){return 0}})}getTasks(){return J(this,arguments,function*(r={}){const{filters:a={},fields:s=this.TASK_FIELDS,limit_start:n=0,limit_page_length:i=50,order_by:o="creation desc"}=r,l=new URLSearchParams;if(l.set("fields",JSON.stringify(s)),l.set("limit_start",String(n)),l.set("limit_page_length",String(i)),l.set("order_by",o),Object.keys(a).length>0){const u=xa(a);u.length>0&&l.set("filters",JSON.stringify(u))}return{data:(yield this.fetchJson(`${this.baseURL}/api/resource/Task?${l}`)).data||[]}})}getTasksForProject(r,a){return J(this,null,function*(){return this.getTasks(je(se({},a),{filters:{project:r},limit_page_length:100}))})}getTask(r){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Task/${encodeURIComponent(r)}`)).data})}createTask(r){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Task`,{method:"POST",body:JSON.stringify(r)})).data})}updateTask(r,a){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Task/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify(a)})).data})}getTaskCount(){return J(this,arguments,function*(r={}){var s,n;const a=new URLSearchParams;if(a.set("fields",JSON.stringify(["count(name) as count"])),Object.keys(r).length>0){const i=xa(r);i.length>0&&a.set("filters",JSON.stringify(i))}try{return((n=(s=(yield this.fetchJson(`${this.baseURL}/api/resource/Task?${a}`)).data)==null?void 0:s[0])==null?void 0:n.count)||0}catch(i){return 0}})}getTimesheets(){return J(this,arguments,function*(r={}){const{filters:a={},appendFilters:s=[],fields:n=["name","status","docstatus","currency","employee","customer","company","total_hours","total_billable_hours","total_billable_amount","total_costing_amount","creation","modified","owner"],limit_start:i=0,limit_page_length:o=20,order_by:l="creation desc"}=r,c=new URLSearchParams;c.set("fields",JSON.stringify(n)),c.set("limit_start",String(i)),c.set("limit_page_length",String(o)),c.set("order_by",l);let u=xa(a);return s.length&&(u=[...u,...s]),u.length>0&&c.set("filters",JSON.stringify(u)),{data:(yield this.fetchJson(`${this.baseURL}/api/resource/Timesheet?${c}`)).data||[]}})}getTimesheetsForProject(r,a){return J(this,null,function*(){const{limit_start:s=0,limit_page_length:n=50}=a||{},i=new URLSearchParams;return i.set("filters",JSON.stringify([["Timesheet Detail","project","=",r]])),i.set("fields",JSON.stringify(["name","status","docstatus","currency","total_hours","total_billable_hours","total_billable_amount","total_costing_amount","creation","modified"])),i.set("limit_start",String(s)),i.set("limit_page_length",String(n)),i.set("order_by","creation desc"),{data:(yield this.fetchJson(`${this.baseURL}/api/resource/Timesheet?${i}`)).data||[]}})}getTimesheet(r){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Timesheet/${encodeURIComponent(r)}`)).data})}createTimesheet(r){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Timesheet`,{method:"POST",body:JSON.stringify(r)})).data})}updateTimesheet(r,a){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Timesheet/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify(a)})).data})}submitTimesheet(r){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Timesheet/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({docstatus:1})})).data})}cancelTimesheet(r){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Timesheet/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({docstatus:2})})).data})}getTimesheetCount(){return J(this,arguments,function*(r={},a=[]){var i,o;const s=new URLSearchParams;s.set("fields",JSON.stringify(["count(name) as count"]));let n=xa(r);a.length&&(n=[...n,...a]),n.length>0&&s.set("filters",JSON.stringify(n));try{return((o=(i=(yield this.fetchJson(`${this.baseURL}/api/resource/Timesheet?${s}`)).data)==null?void 0:i[0])==null?void 0:o.count)||0}catch(l){return 0}})}getActivityTypes(){return J(this,arguments,function*(r={}){const{filters:a={},limit_start:s=0,limit_page_length:n=50,order_by:i="name asc"}=r,o=new URLSearchParams;if(o.set("fields",JSON.stringify(["name","activity_type","billing_rate","costing_rate","disabled","creation","modified"])),o.set("limit_start",String(s)),o.set("limit_page_length",String(n)),o.set("order_by",i),Object.keys(a).length>0){const l=xa(a);l.length>0&&o.set("filters",JSON.stringify(l))}try{return{data:(yield this.fetchJson(`${this.baseURL}/api/resource/Activity%20Type?${o}`)).data||[]}}catch(l){return{data:[]}}})}getActivityType(r){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Activity%20Type/${encodeURIComponent(r)}`)).data})}createActivityType(r){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Activity%20Type`,{method:"POST",body:JSON.stringify(r)})).data})}updateActivityType(r,a){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Activity%20Type/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify(a)})).data})}getActivityTypeCount(){return J(this,arguments,function*(r={}){var s,n;const a=new URLSearchParams;if(a.set("fields",JSON.stringify(["count(name) as count"])),Object.keys(r).length>0){const i=xa(r);i.length>0&&a.set("filters",JSON.stringify(i))}try{return((n=(s=(yield this.fetchJson(`${this.baseURL}/api/resource/Activity%20Type?${a}`)).data)==null?void 0:s[0])==null?void 0:n.count)||0}catch(i){return 0}})}getModuleCounts(){return J(this,null,function*(){const[r,a,s]=yield Promise.all([this.getProjectCount({status:"Open"}),this.getTaskCount({}),this.getTimesheetCount({})]);return{projects:r,tasks:a,timesheets:s}})}getMergedProjectProgressUpdates(r,a){return J(this,null,function*(){var f;const s=(f=a==null?void 0:a.maxTasks)!=null?f:120,n=yield this.getProject(r),{data:i}=yield this.getTasksForProject(r,{limit_page_length:s}),o=(n[kf]||[]).map(y=>je(se({},y),{_source:"project"})),l=i.map(y=>y.name).filter(Boolean).slice(0,s),c=yield Promise.all(l.map(y=>this.getTask(y).catch(()=>null))),u=[];for(const y of c){if(!y)continue;const b=y[_f]||[];for(const w of b)u.push(je(se({},w),{task:w.task||y.name,_source:"task"}))}const h=y=>String(y.date||"").slice(0,10)||"";return[...u,...o].sort((y,b)=>h(b).localeCompare(h(y)))})}}const Dr=new Dle;function Ih(e){if(!e||typeof e!="string")return"";let r=e.replace(/<br\s*\/?>/gi,`
|
||
`).replace(/<\/(p|div|li|tr)>/gi,`
|
||
`).replace(/<a[^>]*>([\s\S]*?)<\/a>/gi,(a,s)=>s.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim()).replace(/<[^>]+>/g," ");return r=r.replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,'"'),r.replace(/[ \t]+\n/g,`
|
||
`).replace(/\n{3,}/g,`
|
||
|
||
`).replace(/ +/g," ").trim()}function ti(e){if(e==null)return"Something went wrong";if(e instanceof Error)return Ih(e.message)||e.message;if(typeof e=="string")return Ih(e);const r=e;let a=typeof r.message=="string"?r.message:"";if(r._server_messages)try{const s=r._server_messages,n=typeof s=="string"?JSON.parse(s):s;if(Array.isArray(n)){const i=[];for(const o of n)try{const l=typeof o=="string"?JSON.parse(o):o;l&&typeof l.message=="string"?i.push(Ih(l.message)):typeof o=="string"&&i.push(Ih(o))}catch(l){typeof o=="string"&&i.push(Ih(o))}i.length&&(a=i.join(`
|
||
`))}}catch(s){}return!a&&typeof r.exc=="string"&&r.exc.length<800&&(a=r.exc),a?Ih(a):"Request failed. Check stock, warehouses, and linked documents."}const zh="Sales%20Order";class Rle{getCSRFToken(){return J(this,null,function*(){var r;if(typeof window=="undefined")return null;if(window.csrf_token)return window.csrf_token;if((r=window.frappe)!=null&&r.csrf_token)return window.frappe.csrf_token;try{const a=yield fetch("/api/method/frappe.sessions.get_csrf_token",{credentials:"include"});if(a.ok){const s=yield a.json();if(s.message)return window.csrf_token=s.message,s.message}}catch(a){}return null})}getHeaders(){return J(this,null,function*(){const r={"Content-Type":"application/json",Accept:"application/json"},a=yield this.getCSRFToken();return a&&(r["X-Frappe-CSRF-Token"]=a),r})}fetchJson(s){return J(this,arguments,function*(r,a={}){const n=yield this.getHeaders(),i=yield fetch(r,se({credentials:"include",headers:n},a)),o=yield i.json().catch(()=>({}));if(!i.ok)throw new Error(ti(o)||(o==null?void 0:o.message)||`HTTP ${i.status}`);if(o.exc)throw new Error(ti(o)||"Request failed");return o})}getSalesOrders(){return J(this,arguments,function*(r={}){var i,o,l,c;const a=new URLSearchParams,s=["name","customer","customer_name","transaction_date","status","grand_total","currency","docstatus","project","billing_status","delivery_status","creation","modified"];return a.set("fields",JSON.stringify(s)),(i=r.filters)!=null&&i.length&&a.set("filters",JSON.stringify(r.filters)),a.set("limit_start",String((o=r.limit_start)!=null?o:0)),a.set("limit_page_length",String((l=r.limit_page_length)!=null?l:20)),a.set("order_by",(c=r.order_by)!=null?c:"creation desc"),(yield this.fetchJson(`/api/resource/${zh}?${a}`)).data||[]})}getSalesOrderCount(){return J(this,arguments,function*(r=[]){var s,n,i;const a=new URLSearchParams;a.set("fields",JSON.stringify(["count(name) as count"])),r.length&&a.set("filters",JSON.stringify(r));try{return(i=(n=(s=(yield this.fetchJson(`/api/resource/${zh}?${a}`)).data)==null?void 0:s[0])==null?void 0:n.count)!=null?i:0}catch(o){return 0}})}getSalesOrderNamesForProject(r,a=25){return J(this,null,function*(){return(yield this.getSalesOrders({filters:[["Sales Order","project","=",r]],limit_start:0,limit_page_length:a,order_by:"modified desc"})).map(n=>n.name).filter(Boolean)})}getSalesOrder(r){return J(this,null,function*(){return(yield this.fetchJson(`/api/resource/${zh}/${encodeURIComponent(r)}`)).data})}createSalesOrder(r){return J(this,null,function*(){return(yield this.fetchJson(`/api/resource/${zh}`,{method:"POST",body:JSON.stringify(r)})).data})}updateSalesOrder(r,a){return J(this,null,function*(){return(yield this.fetchJson(`/api/resource/${zh}/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify(a)})).data})}submitSalesOrder(r){return J(this,null,function*(){return(yield this.fetchJson(`/api/resource/${zh}/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({docstatus:1})})).data})}}const Io=new Rle;class Mle{getCSRFToken(){return J(this,null,function*(){var r;if(typeof window=="undefined")return null;if(window.csrf_token)return window.csrf_token;if((r=window.frappe)!=null&&r.csrf_token)return window.frappe.csrf_token;try{const a=yield fetch("/api/method/frappe.sessions.get_csrf_token",{credentials:"include"});if(a.ok){const s=yield a.json();if(s.message)return window.csrf_token=s.message,s.message}}catch(a){}return null})}getHeaders(){return J(this,null,function*(){const r={"Content-Type":"application/json",Accept:"application/json"},a=yield this.getCSRFToken();return a&&(r["X-Frappe-CSRF-Token"]=a),r})}fetchJson(s){return J(this,arguments,function*(r,a={}){const n=yield fetch(r,se({credentials:"include"},a)),i=yield n.json();if(!n.ok){const o=ti(i)||(i==null?void 0:i.exc_type)||`HTTP ${n.status}`;throw new Error(o)}return i})}getDeliveryNotes(){return J(this,arguments,function*(r={}){var i,o,l,c;const a=new URLSearchParams,s=["name","customer","customer_name","posting_date","status","grand_total","currency","docstatus","creation"];return a.set("fields",JSON.stringify(s)),(i=r.filters)!=null&&i.length&&a.set("filters",JSON.stringify(r.filters)),a.set("limit_start",String((o=r.limit_start)!=null?o:0)),a.set("limit_page_length",String((l=r.limit_page_length)!=null?l:20)),a.set("order_by",(c=r.order_by)!=null?c:"creation desc"),(yield this.fetchJson(`/api/resource/Delivery Note?${a}`)).data||[]})}getDeliveryNoteCount(){return J(this,arguments,function*(r=[]){var s,n,i;const a=new URLSearchParams;a.set("fields",JSON.stringify(["count(name) as count"])),r.length&&a.set("filters",JSON.stringify(r));try{return(i=(n=(s=(yield this.fetchJson(`/api/resource/Delivery Note?${a}`)).data)==null?void 0:s[0])==null?void 0:n.count)!=null?i:0}catch(o){return 0}})}getDeliveryNote(r){return J(this,null,function*(){return(yield this.fetchJson(`/api/resource/Delivery Note/${encodeURIComponent(r)}`)).data})}createDeliveryNote(r){return J(this,null,function*(){const a=yield this.getHeaders();return(yield this.fetchJson("/api/resource/Delivery Note",{method:"POST",headers:a,body:JSON.stringify(je(se({},r),{doctype:"Delivery Note"}))})).data})}updateDeliveryNote(r,a){return J(this,null,function*(){const s=yield this.getHeaders();return(yield this.fetchJson(`/api/resource/Delivery Note/${encodeURIComponent(r)}`,{method:"PUT",headers:s,body:JSON.stringify(a)})).data})}submitDeliveryNote(r){return J(this,null,function*(){const a=yield this.getHeaders();return(yield this.fetchJson(`/api/resource/Delivery Note/${encodeURIComponent(r)}`,{method:"PUT",headers:a,body:JSON.stringify({docstatus:1})})).data})}}const tm=new Mle;class Lle{constructor(){$s(this,"baseURL","")}getCSRFToken(){return J(this,null,function*(){var r;if(typeof window=="undefined")return null;if(window.csrf_token)return window.csrf_token;if((r=window.frappe)!=null&&r.csrf_token)return window.frappe.csrf_token;try{const a=yield fetch("/api/method/frappe.sessions.get_csrf_token",{credentials:"include"});if(a.ok){const s=yield a.json();if(s.message)return window.csrf_token=s.message,s.message}}catch(a){}return null})}getHeaders(){return J(this,null,function*(){const r={"Content-Type":"application/json",Accept:"application/json"},a=yield this.getCSRFToken();return a&&(r["X-Frappe-CSRF-Token"]=a),r})}sanitizeErrorMessage(r){if(!r)return"Something went wrong.";const a=r.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim(),s=a.toLowerCase().indexOf("traceback"),n=s>=0?a.slice(0,s).trim():a;return n.length>220?`${n.slice(0,220)}…`:n||"Something went wrong."}parseFrappeError(r){if((r==null?void 0:r.exc_type)==="ValidationError")return r.exc||r.message||"Validation error";if(r!=null&&r.message)return this.sanitizeErrorMessage(String(r.message));if(r!=null&&r._server_messages)try{const a=JSON.parse(r._server_messages),s=a==null?void 0:a[0],n=typeof s=="string"?JSON.parse(s):s,i=(n==null?void 0:n.message)||s||r._server_messages;return this.sanitizeErrorMessage(String(i))}catch(a){return this.sanitizeErrorMessage(String(r._server_messages))}return"Unknown error"}fetchJson(s){return J(this,arguments,function*(r,a={}){const n=yield this.getHeaders(),i=yield fetch(r,se({credentials:"include",headers:n},a)),o=yield i.json().catch(()=>({}));if(!i.ok)throw new Error(this.parseFrappeError(o));if(o.exc)throw new Error(this.parseFrappeError(o));return o})}getSalesInvoices(){return J(this,arguments,function*(r={}){const{filters:a={},fields:s=["name","status","customer","customer_name","posting_date","currency","grand_total","outstanding_amount","docstatus","creation"],limit_start:n=0,limit_page_length:i=20,order_by:o="creation desc"}=r,l=new URLSearchParams;if(l.set("fields",JSON.stringify(s)),l.set("limit_start",String(n)),l.set("limit_page_length",String(i)),l.set("order_by",o),Object.keys(a).length>0){const u=xa(a);u.length>0&&l.set("filters",JSON.stringify(u))}return{data:(yield this.fetchJson(`${this.baseURL}/api/resource/Sales Invoice?${l}`)).data||[]}})}getSalesInvoicesBySalesOrders(r){return J(this,null,function*(){const{salesOrders:a,limit:s=1e3,orderBy:n="posting_date asc",fields:i=["name","posting_date","customer","customer_name","currency","grand_total","docstatus","status"]}=r;return a.length?(yield this.fetchJson(`${this.baseURL}/api/method/frappe.client.get_list`,{method:"POST",body:JSON.stringify({doctype:"Sales Invoice",fields:i,filters:[["Sales Invoice Item","sales_order","in",a]],order_by:n,limit_page_length:s})})).message||[]:[]})}getSalesInvoicesLinkedToProject(r){return J(this,null,function*(){const{project:a,limit:s=1e3,orderBy:n="posting_date asc",fields:i=["name","posting_date","customer","customer_name","currency","grand_total","docstatus","status"]}=r;if(!(a!=null&&a.trim()))return[];const o=h=>this.fetchJson(`${this.baseURL}/api/method/frappe.client.get_list`,{method:"POST",body:JSON.stringify({doctype:"Sales Invoice",fields:i,filters:h,order_by:n,limit_page_length:s})}).then(f=>f.message||[]).catch(()=>[]),[l,c]=yield Promise.all([o([["project","=",a]]),o([["Sales Invoice Item","project","=",a]])]),u=new Map;for(const h of l)h!=null&&h.name&&u.set(h.name,h);for(const h of c)h!=null&&h.name&&u.set(h.name,h);return[...u.values()].sort((h,f)=>String(h.posting_date||"").localeCompare(String(f.posting_date||"")))})}getSalesInvoiceCount(){return J(this,arguments,function*(r={}){var s,n;const a=new URLSearchParams;if(a.set("fields",JSON.stringify(["count(name) as count"])),Object.keys(r).length>0){const i=xa(r);i.length>0&&a.set("filters",JSON.stringify(i))}try{return((n=(s=(yield this.fetchJson(`${this.baseURL}/api/resource/Sales Invoice?${a}`)).data)==null?void 0:s[0])==null?void 0:n.count)||0}catch(i){return 0}})}getSalesInvoice(r){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Sales%20Invoice/${encodeURIComponent(r)}`)).data})}createSalesInvoice(r){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Sales%20Invoice`,{method:"POST",body:JSON.stringify(r)})).data})}updateSalesInvoice(r,a){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Sales%20Invoice/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify(a)})).data})}clearItemLinkNones(r){return J(this,null,function*(){var o;const a=yield this.getHeaders(),s=yield this.fetchJson(`${this.baseURL}/api/resource/Sales%20Invoice/${encodeURIComponent(r)}`),n=((o=s==null?void 0:s.data)==null?void 0:o.items)||[],i=["delivery_note","dn_detail","sales_order","so_detail","against_delivery_note","against_sales_order"];for(const l of n)!l.name||!i.some(u=>l[u]==="None"||l[u]==="none")||(yield this.fetchJson(`${this.baseURL}/api/method/frappe.client.set_value`,{method:"POST",headers:a,body:JSON.stringify({doctype:"Sales Invoice Item",name:l.name,fieldname:{delivery_note:"",dn_detail:"",sales_order:"",so_detail:"",against_delivery_note:"",against_sales_order:""}})}))})}submitSalesInvoice(r){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Sales%20Invoice/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({docstatus:1})})).data})}}const Pc=new Lle;class Fle{constructor(){$s(this,"csrfToken",null)}getCSRFToken(){return J(this,null,function*(){var r;if(typeof window=="undefined")return null;if(window.csrf_token)return window.csrf_token;if((r=window.frappe)!=null&&r.csrf_token)return window.frappe.csrf_token;try{const a=yield fetch("/api/method/frappe.sessions.get_csrf_token",{credentials:"include"});if(a.ok){const s=yield a.json();if(s.message)return window.csrf_token=s.message,s.message}}catch(a){}return null})}getHeaders(){return J(this,null,function*(){const r={"Content-Type":"application/json",Accept:"application/json"},a=yield this.getCSRFToken();return a&&(r["X-Frappe-CSRF-Token"]=a),r})}fetchJson(s){return J(this,arguments,function*(r,a={}){const n=yield fetch(r,se({credentials:"include"},a)),i=yield n.json();if(!n.ok){let o=(i==null?void 0:i.exc_type)||(i==null?void 0:i.message)||`HTTP ${n.status}`;if(i!=null&&i._server_messages)try{const l=JSON.parse(i._server_messages),c=Array.isArray(l)?l.map(u=>{try{return JSON.parse(u).message}catch(h){return u}}):[];c.length&&(o=c.join(`
|
||
`))}catch(l){}throw new Error(o)}return i})}getPaymentEntries(){return J(this,arguments,function*(r={}){var i,o,l;const a=new URLSearchParams,s=["name","payment_type","posting_date","party","party_name","party_type","paid_amount","received_amount","status","mode_of_payment","company","docstatus","creation"];return a.set("fields",JSON.stringify(s)),(i=r.filters)!=null&&i.length&&a.set("filters",JSON.stringify(r.filters)),a.set("limit_start",String((o=r.limit_start)!=null?o:0)),a.set("limit_page_length",String((l=r.limit_page_length)!=null?l:20)),a.set("order_by","creation desc"),(yield this.fetchJson(`/api/resource/Payment Entry?${a}`)).data||[]})}getPaymentEntryCount(){return J(this,arguments,function*(r=[]){var s,n,i;const a=new URLSearchParams;a.set("fields",JSON.stringify(["count(name) as count"])),r.length&&a.set("filters",JSON.stringify(r));try{return(i=(n=(s=(yield this.fetchJson(`/api/resource/Payment%20Entry?${a}`)).data)==null?void 0:s[0])==null?void 0:n.count)!=null?i:0}catch(o){return 0}})}getPaymentEntry(r){return J(this,null,function*(){return(yield this.fetchJson(`/api/resource/Payment Entry/${encodeURIComponent(r)}`)).data})}createPaymentEntry(r){return J(this,null,function*(){const a=yield this.getHeaders();return(yield this.fetchJson("/api/resource/Payment Entry",{method:"POST",headers:a,body:JSON.stringify(je(se({},r),{doctype:"Payment Entry"}))})).data})}updatePaymentEntry(r,a){return J(this,null,function*(){const s=yield this.getHeaders();return(yield this.fetchJson(`/api/resource/Payment Entry/${encodeURIComponent(r)}`,{method:"PUT",headers:s,body:JSON.stringify(a)})).data})}submitPaymentEntry(r){return J(this,null,function*(){const a=yield this.getHeaders();return(yield this.fetchJson(`/api/resource/Payment Entry/${encodeURIComponent(r)}`,{method:"PUT",headers:a,body:JSON.stringify({docstatus:1})})).data})}}const rm=new Fle,$h="Material%20Request";class Ile{getCSRFToken(){return J(this,null,function*(){var r;if(typeof window=="undefined")return null;if(window.csrf_token)return window.csrf_token;if((r=window.frappe)!=null&&r.csrf_token)return window.frappe.csrf_token;try{const a=yield fetch("/api/method/frappe.sessions.get_csrf_token",{credentials:"include"});if(a.ok){const s=yield a.json();if(s.message)return window.csrf_token=s.message,s.message}}catch(a){}return null})}getHeaders(){return J(this,null,function*(){const r={"Content-Type":"application/json",Accept:"application/json"},a=yield this.getCSRFToken();return a&&(r["X-Frappe-CSRF-Token"]=a),r})}fetchJson(s){return J(this,arguments,function*(r,a={}){const n=yield this.getHeaders(),i=yield fetch(r,se({credentials:"include",headers:n},a)),o=yield i.json().catch(()=>({}));if(!i.ok)throw new Error(ti(o)||(o==null?void 0:o.message)||`HTTP ${i.status}`);if(o.exc)throw new Error(ti(o)||"Request failed");return o})}getMaterialRequests(){return J(this,arguments,function*(r={}){var i,o,l,c;const a=new URLSearchParams,s=["name","material_request_type","transaction_date","status","company","docstatus","creation","modified"];return a.set("fields",JSON.stringify(s)),(i=r.filters)!=null&&i.length&&a.set("filters",JSON.stringify(r.filters)),a.set("limit_start",String((o=r.limit_start)!=null?o:0)),a.set("limit_page_length",String((l=r.limit_page_length)!=null?l:20)),a.set("order_by",(c=r.order_by)!=null?c:"creation desc"),(yield this.fetchJson(`/api/resource/${$h}?${a}`)).data||[]})}getMaterialRequestCount(){return J(this,arguments,function*(r=[]){var s,n,i;const a=new URLSearchParams;a.set("fields",JSON.stringify(["count(name) as count"])),r.length&&a.set("filters",JSON.stringify(r));try{return(i=(n=(s=(yield this.fetchJson(`/api/resource/${$h}?${a}`)).data)==null?void 0:s[0])==null?void 0:n.count)!=null?i:0}catch(o){return 0}})}getMaterialRequest(r){return J(this,null,function*(){return(yield this.fetchJson(`/api/resource/${$h}/${encodeURIComponent(r)}`)).data})}createMaterialRequest(r){return J(this,null,function*(){return(yield this.fetchJson(`/api/resource/${$h}`,{method:"POST",body:JSON.stringify(r)})).data})}updateMaterialRequest(r,a){return J(this,null,function*(){return(yield this.fetchJson(`/api/resource/${$h}/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify(a)})).data})}submitMaterialRequest(r){return J(this,null,function*(){return(yield this.fetchJson(`/api/resource/${$h}/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({docstatus:1})})).data})}}const am=new Ile,Uh="Purchase%20Order";class zle{getCSRFToken(){return J(this,null,function*(){var r;if(typeof window=="undefined")return null;if(window.csrf_token)return window.csrf_token;if((r=window.frappe)!=null&&r.csrf_token)return window.frappe.csrf_token;try{const a=yield fetch("/api/method/frappe.sessions.get_csrf_token",{credentials:"include"});if(a.ok){const s=yield a.json();if(s.message)return window.csrf_token=s.message,s.message}}catch(a){}return null})}getHeaders(){return J(this,null,function*(){const r={"Content-Type":"application/json",Accept:"application/json"},a=yield this.getCSRFToken();return a&&(r["X-Frappe-CSRF-Token"]=a),r})}fetchJson(s){return J(this,arguments,function*(r,a={}){const n=yield this.getHeaders(),i=yield fetch(r,se({credentials:"include",headers:n},a)),o=yield i.json().catch(()=>({}));if(!i.ok)throw new Error(ti(o)||(o==null?void 0:o.message)||`HTTP ${i.status}`);if(o.exc)throw new Error(ti(o)||"Request failed");return o})}getPurchaseOrders(){return J(this,arguments,function*(r={}){var i,o,l,c;const a=new URLSearchParams,s=["name","supplier","supplier_name","transaction_date","schedule_date","status","grand_total","currency","docstatus","company","creation","modified"];return a.set("fields",JSON.stringify(s)),(i=r.filters)!=null&&i.length&&a.set("filters",JSON.stringify(r.filters)),a.set("limit_start",String((o=r.limit_start)!=null?o:0)),a.set("limit_page_length",String((l=r.limit_page_length)!=null?l:20)),a.set("order_by",(c=r.order_by)!=null?c:"creation desc"),(yield this.fetchJson(`/api/resource/${Uh}?${a}`)).data||[]})}getPurchaseOrderCount(){return J(this,arguments,function*(r=[]){var s,n,i;const a=new URLSearchParams;a.set("fields",JSON.stringify(["count(name) as count"])),r.length&&a.set("filters",JSON.stringify(r));try{return(i=(n=(s=(yield this.fetchJson(`/api/resource/${Uh}?${a}`)).data)==null?void 0:s[0])==null?void 0:n.count)!=null?i:0}catch(o){return 0}})}getPurchaseOrder(r){return J(this,null,function*(){return(yield this.fetchJson(`/api/resource/${Uh}/${encodeURIComponent(r)}`)).data})}createPurchaseOrder(r){return J(this,null,function*(){return(yield this.fetchJson(`/api/resource/${Uh}`,{method:"POST",body:JSON.stringify(r)})).data})}updatePurchaseOrder(r,a){return J(this,null,function*(){return(yield this.fetchJson(`/api/resource/${Uh}/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify(a)})).data})}submitPurchaseOrder(r){return J(this,null,function*(){return(yield this.fetchJson(`/api/resource/${Uh}/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({docstatus:1})})).data})}}const sm=new zle,Bh="Purchase%20Receipt";class $le{getCSRFToken(){return J(this,null,function*(){var r;if(typeof window=="undefined")return null;if(window.csrf_token)return window.csrf_token;if((r=window.frappe)!=null&&r.csrf_token)return window.frappe.csrf_token;try{const a=yield fetch("/api/method/frappe.sessions.get_csrf_token",{credentials:"include"});if(a.ok){const s=yield a.json();if(s.message)return window.csrf_token=s.message,s.message}}catch(a){}return null})}getHeaders(){return J(this,null,function*(){const r={"Content-Type":"application/json",Accept:"application/json"},a=yield this.getCSRFToken();return a&&(r["X-Frappe-CSRF-Token"]=a),r})}fetchJson(s){return J(this,arguments,function*(r,a={}){const n=yield this.getHeaders(),i=yield fetch(r,se({credentials:"include",headers:n},a)),o=yield i.json().catch(()=>({}));if(!i.ok)throw new Error(ti(o)||(o==null?void 0:o.message)||`HTTP ${i.status}`);if(o.exc)throw new Error(ti(o)||"Request failed");return o})}getPurchaseReceipts(){return J(this,arguments,function*(r={}){var i,o,l,c;const a=new URLSearchParams,s=["name","supplier","supplier_name","posting_date","status","grand_total","currency","docstatus","company","creation","modified"];return a.set("fields",JSON.stringify(s)),(i=r.filters)!=null&&i.length&&a.set("filters",JSON.stringify(r.filters)),a.set("limit_start",String((o=r.limit_start)!=null?o:0)),a.set("limit_page_length",String((l=r.limit_page_length)!=null?l:20)),a.set("order_by",(c=r.order_by)!=null?c:"creation desc"),(yield this.fetchJson(`/api/resource/${Bh}?${a}`)).data||[]})}getPurchaseReceiptCount(){return J(this,arguments,function*(r=[]){var s,n,i;const a=new URLSearchParams;a.set("fields",JSON.stringify(["count(name) as count"])),r.length&&a.set("filters",JSON.stringify(r));try{return(i=(n=(s=(yield this.fetchJson(`/api/resource/${Bh}?${a}`)).data)==null?void 0:s[0])==null?void 0:n.count)!=null?i:0}catch(o){return 0}})}getPurchaseReceipt(r){return J(this,null,function*(){return(yield this.fetchJson(`/api/resource/${Bh}/${encodeURIComponent(r)}`)).data})}createPurchaseReceipt(r){return J(this,null,function*(){return(yield this.fetchJson(`/api/resource/${Bh}`,{method:"POST",body:JSON.stringify(r)})).data})}updatePurchaseReceipt(r,a){return J(this,null,function*(){return(yield this.fetchJson(`/api/resource/${Bh}/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify(a)})).data})}submitPurchaseReceipt(r){return J(this,null,function*(){return(yield this.fetchJson(`/api/resource/${Bh}/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({docstatus:1})})).data})}}const nm=new $le;class Ule{constructor(){$s(this,"baseURL",Ar.BASE_URL)}getCSRFToken(){return J(this,null,function*(){var r;if(typeof window=="undefined")return null;if(window.csrf_token)return window.csrf_token;if((r=window.frappe)!=null&&r.csrf_token)return window.frappe.csrf_token;try{const a=yield fetch(`${this.baseURL}/api/method/frappe.sessions.get_csrf_token`,{credentials:"include"});if(a.ok){const s=yield a.json();if(s.message)return window.csrf_token=s.message,s.message}}catch(a){}return null})}getHeaders(){return J(this,null,function*(){const r={Accept:"application/json","Content-Type":"application/json"},a=yield this.getCSRFToken();return a&&(r["X-Frappe-CSRF-Token"]=a),r})}parseFrappeError(r){return J(this,null,function*(){var s;try{const n=yield r.json();if(n._server_messages)try{const i=JSON.parse(n._server_messages),o=typeof i[0]=="string"?JSON.parse(i[0]):i[0];if(o!=null&&o.message)return new Error(o.message)}catch(i){}if(n.message&&typeof n.message=="string")return new Error(n.message);if(n.exc_type)return new Error(`${n.exc_type}: ${((s=n.exc)==null?void 0:s.split(`
|
||
`).slice(-2).join(" ").trim())||r.statusText}`)}catch(n){}const a={403:"Permission denied.",404:"Record not found.",417:"Validation error.",500:"Server error."};return new Error(a[r.status]||`HTTP ${r.status}`)})}fetchJson(r,a){return J(this,null,function*(){const s=yield fetch(r,je(se({credentials:"include"},a),{headers:se(se({},yield this.getHeaders()),(a==null?void 0:a.headers)||{})}));if(!s.ok)throw yield this.parseFrappeError(s.clone());return s.json()})}getCustomers(){return J(this,arguments,function*(r={}){const{limit_start:a=0,limit_page_length:s=20,filters:n={}}=r,i=new URLSearchParams;if(i.set("fields",JSON.stringify(["name","customer_name","customer_type","customer_group","territory","disabled","creation","modified"])),i.set("limit_start",String(a)),i.set("limit_page_length",String(s)),i.set("order_by","modified desc"),Object.keys(n).length>0){const l=xa(n);l.length>0&&i.set("filters",JSON.stringify(l))}return{data:(yield this.fetchJson(`${this.baseURL}/api/resource/Customer?${i}`)).data||[]}})}getCustomer(r){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Customer/${encodeURIComponent(r)}`)).data})}createCustomer(r){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Customer`,{method:"POST",body:JSON.stringify(r)})).data})}updateCustomer(r,a){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Customer/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify(a)})).data})}getCustomerCount(){return J(this,arguments,function*(r={}){var s,n;const a=new URLSearchParams;if(a.set("fields",JSON.stringify(["count(name) as count"])),Object.keys(r).length>0){const i=xa(r);i.length>0&&a.set("filters",JSON.stringify(i))}try{return((n=(s=(yield this.fetchJson(`${this.baseURL}/api/resource/Customer?${a}`)).data)==null?void 0:s[0])==null?void 0:n.count)||0}catch(i){return 0}})}getEmployees(){return J(this,arguments,function*(r={}){const{limit_start:a=0,limit_page_length:s=20,filters:n={}}=r,i=new URLSearchParams;if(i.set("fields",JSON.stringify(["name","employee_name","first_name","last_name","gender","status","company","designation","department","date_of_joining","creation","modified"])),i.set("limit_start",String(a)),i.set("limit_page_length",String(s)),i.set("order_by","modified desc"),Object.keys(n).length>0){const l=xa(n);l.length>0&&i.set("filters",JSON.stringify(l))}return{data:(yield this.fetchJson(`${this.baseURL}/api/resource/Employee?${i}`)).data||[]}})}getEmployee(r){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Employee/${encodeURIComponent(r)}`)).data})}createEmployee(r){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Employee`,{method:"POST",body:JSON.stringify(r)})).data})}updateEmployee(r,a){return J(this,null,function*(){return(yield this.fetchJson(`${this.baseURL}/api/resource/Employee/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify(a)})).data})}getEmployeeCount(){return J(this,arguments,function*(r={}){var s,n;const a=new URLSearchParams;if(a.set("fields",JSON.stringify(["count(name) as count"])),Object.keys(r).length>0){const i=xa(r);i.length>0&&a.set("filters",JSON.stringify(i))}try{return((n=(s=(yield this.fetchJson(`${this.baseURL}/api/resource/Employee?${a}`)).data)==null?void 0:s[0])==null?void 0:n.count)||0}catch(i){return 0}})}}const fl=new Ule,U7=()=>({projects:null,tasks:null,timesheets:null,salesOrders:null,deliveryNotes:null,salesInvoices:null,paymentEntries:null,materialRequests:null,purchaseOrders:null,purchaseReceipts:null,customers:null,employees:null,projectTemplates:null,activityTypes:null}),Qi=({label:e,sub:r,icon:a,count:s,loading:n,onClick:i,onNew:o,iconClassName:l="bg-gradient-to-br from-blue-600 to-indigo-700",cardClassName:c="",secondaryNew:u})=>t.jsx("div",{className:`group rounded-lg border overflow-hidden hover:shadow-md transition-all cursor-pointer shadow-sm h-full min-w-0 flex flex-col ${c||"bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700 hover:border-blue-300/80 dark:hover:border-blue-600"}`,onClick:i,children:t.jsxs("div",{className:"p-2 flex-1 flex flex-col min-h-0",children:[t.jsxs("div",{className:"flex items-start justify-between mb-1 gap-1",children:[t.jsx("div",{className:`w-7 h-7 rounded-md ${l} flex items-center justify-center text-white shadow-sm shrink-0`,children:t.jsx("span",{className:"text-xs",children:a})}),(o||u)&&t.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[o&&t.jsx("button",{type:"button",onClick:h=>{h.stopPropagation(),o()},className:"p-1 rounded-md bg-blue-600 text-white border border-blue-600 hover:bg-blue-700 shadow-sm",title:`New ${e}`,children:t.jsx(Rr,{size:9})}),u&&t.jsx("button",{type:"button",onClick:h=>{h.stopPropagation(),u.onClick()},className:"p-1 rounded-md border border-violet-200 dark:border-violet-700 bg-violet-50 dark:bg-violet-900/40 text-violet-700 dark:text-violet-200 hover:bg-violet-100 dark:hover:bg-violet-900/60",title:u.title,children:t.jsxs("span",{className:"text-[10px] flex items-center gap-0.5 font-bold",children:[t.jsx(Rr,{size:7}),u.icon]})})]})]}),t.jsx("p",{className:"font-semibold text-gray-900 dark:text-white text-xs leading-tight",children:e}),r&&t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400 mt-0.5 leading-snug line-clamp-2",children:r}),s!==void 0&&t.jsx("p",{className:"text-base font-bold text-gray-900 dark:text-white mt-auto pt-1 leading-none tabular-nums",children:n&&s===null?t.jsx(tr,{className:"animate-spin text-base text-gray-400"}):s!=null?s:0})]})}),_b="grid gap-1.5 w-full [grid-template-columns:repeat(auto-fit,minmax(6.75rem,1fr))]",kb=({title:e,subtitle:r,icon:a,children:s,headerClassName:n="bg-gradient-to-r from-slate-600 to-slate-800 dark:from-slate-700 dark:to-slate-900",bodyClassName:i="",className:o=""})=>t.jsxs("div",{className:`rounded-lg overflow-hidden shadow-sm border border-gray-200/70 dark:border-gray-700/80 ring-1 ring-black/[0.03] dark:ring-white/[0.06] flex flex-col min-h-0 h-full ${o}`,children:[t.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1.5 text-white shadow-inner shrink-0 ${n}`,children:[t.jsx("span",{className:"opacity-95 drop-shadow-sm shrink-0",children:a}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"text-xs font-semibold leading-tight tracking-tight",children:e}),r&&t.jsx("p",{className:"text-[9px] text-white/85 leading-snug mt-0.5 line-clamp-2",children:r})]})]}),t.jsx("div",{className:`p-2 flex-1 min-h-0 ${i}`,children:s})]}),Ble=()=>{var c,u,h;const{t:e}=sr(),r=hr(),[a,s]=p.useState(U7),[n,i]=p.useState(!0),o=p.useCallback(()=>J(null,null,function*(){i(!0),s(U7());const f=yield Promise.allSettled([Dr.getModuleCounts(),Io.getSalesOrderCount([]),tm.getDeliveryNoteCount([]),Pc.getSalesInvoiceCount({}),rm.getPaymentEntryCount([]),am.getMaterialRequestCount([]),sm.getPurchaseOrderCount([]),nm.getPurchaseReceiptCount([]),fl.getCustomerCount({}),fl.getEmployeeCount({}),Dr.getProjectTemplateCount({}),Dr.getActivityTypeCount({})]),y=w=>{const v=f[w];return v.status==="fulfilled"?v.value:0},b=f[0].status==="fulfilled"?f[0].value:{projects:0,tasks:0,timesheets:0};s({projects:b.projects,tasks:b.tasks,timesheets:b.timesheets,salesOrders:y(1),deliveryNotes:y(2),salesInvoices:y(3),paymentEntries:y(4),materialRequests:y(5),purchaseOrders:y(6),purchaseReceipts:y(7),customers:y(8),employees:y(9),projectTemplates:y(10),activityTypes:y(11)}),i(!1)}),[]);p.useEffect(()=>{o()},[o]);const l=n;return t.jsxs("div",{className:"p-3 min-h-screen bg-gray-50 dark:bg-gray-900 max-w-[1920px] mx-auto",children:[t.jsxs("div",{className:"flex flex-col gap-2 mb-3 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsx("div",{className:"w-9 h-9 rounded-lg bg-gradient-to-br from-blue-600 to-indigo-700 flex items-center justify-center shadow-md ring-2 ring-white/50 dark:ring-gray-700/50",children:t.jsx(gp,{className:"text-white text-sm drop-shadow"})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:e("projects.moduleTitle","Project Management")}),t.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-0.5",children:e("projects.hubSubtitle","Projects, tasks, timesheets, and linked other documents.")})]})]}),t.jsx("button",{type:"button",onClick:o,className:"p-2 text-gray-600 hover:text-blue-700 dark:text-gray-300 dark:hover:text-blue-400 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 shadow-sm self-start sm:self-center",title:e("common.refresh","Refresh"),children:t.jsx(Ma,{size:13,className:n?"animate-spin":""})})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[t.jsxs("button",{type:"button",onClick:()=>r("/projects/list"),className:"flex items-center gap-2 text-xs font-semibold px-3 py-1.5 rounded-full border border-sky-200 dark:border-sky-700 bg-gradient-to-r from-sky-100 to-blue-100 dark:from-sky-900/40 dark:to-blue-900/30 text-sky-950 dark:text-sky-100 shadow-sm hover:shadow transition-shadow",children:[t.jsx("span",{className:"text-blue-800 dark:text-sky-300 tabular-nums font-bold",children:n&&a.projects===null?"…":(c=a.projects)!=null?c:0}),"Open projects"]}),t.jsxs("button",{type:"button",onClick:()=>r("/projects/tasks"),className:"flex items-center gap-2 text-xs font-semibold px-3 py-1.5 rounded-full border border-indigo-200 dark:border-indigo-700 bg-gradient-to-r from-indigo-50 to-violet-100 dark:from-indigo-900/35 dark:to-violet-900/25 text-gray-800 dark:text-indigo-100 shadow-sm hover:shadow transition-shadow",children:[t.jsx("span",{className:"text-indigo-700 dark:text-indigo-300 tabular-nums font-bold",children:n&&a.tasks===null?"…":(u=a.tasks)!=null?u:0}),"Tasks"]}),t.jsxs("button",{type:"button",onClick:()=>r("/projects/timesheets"),className:"flex items-center gap-2 text-xs font-semibold px-3 py-1.5 rounded-full border border-emerald-200 dark:border-emerald-700 bg-gradient-to-r from-emerald-50 to-teal-100 dark:from-emerald-900/35 dark:to-teal-900/25 text-gray-800 dark:text-emerald-100 shadow-sm hover:shadow transition-shadow",children:[t.jsx("span",{className:"text-emerald-700 dark:text-emerald-300 tabular-nums font-bold",children:n&&a.timesheets===null?"…":(h=a.timesheets)!=null?h:0}),"Timesheets"]})]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-2 lg:gap-3 lg:items-stretch",children:[t.jsxs("div",{className:"flex flex-col gap-2 min-w-0",children:[t.jsx(kb,{title:"Masters",subtitle:"Customers, employees, templates, and activity types.",icon:t.jsx($d,{size:14}),headerClassName:"bg-gradient-to-r from-purple-600 to-violet-700 dark:from-purple-700 dark:to-violet-800",bodyClassName:"bg-white dark:bg-gray-900/40",children:t.jsxs("div",{className:_b,children:[t.jsx(Qi,{label:"Customers",sub:"Customer master",icon:t.jsx($d,{className:"text-white"}),iconClassName:"bg-gradient-to-br from-violet-500 to-purple-700",cardClassName:"bg-gradient-to-b from-white to-violet-50/40 dark:from-gray-800 dark:to-violet-950/20 border-violet-200/50 dark:border-violet-800/50",count:a.customers,loading:n,onClick:()=>r("/customers"),onNew:()=>r("/customers/new")}),t.jsx(Qi,{label:"Employees",sub:"Employee master",icon:t.jsx(Ev,{className:"text-white"}),iconClassName:"bg-gradient-to-br from-fuchsia-500 to-pink-700",cardClassName:"bg-gradient-to-b from-white to-fuchsia-50/35 dark:from-gray-800 dark:to-fuchsia-950/15 border-fuchsia-200/50 dark:border-fuchsia-800/50",count:a.employees,loading:n,onClick:()=>r("/employees"),onNew:()=>r("/employees/new")}),t.jsx(Qi,{label:"Project template",sub:"Reusable project templates",icon:t.jsx(V9,{className:"text-white"}),iconClassName:"bg-gradient-to-br from-purple-600 to-indigo-800",cardClassName:"bg-gradient-to-b from-white to-purple-50/35 dark:from-gray-800 dark:to-purple-950/20 border-purple-200/50 dark:border-purple-800/50",count:a.projectTemplates,loading:n,onClick:()=>r("/projects/templates"),onNew:()=>r("/projects/templates/new")}),t.jsx(Qi,{label:"Activity type",sub:"Billing categories",icon:t.jsx(Z9,{className:"text-white"}),iconClassName:"bg-gradient-to-br from-cyan-500 to-blue-700",cardClassName:"bg-gradient-to-b from-white to-cyan-50/30 dark:from-gray-800 dark:to-cyan-950/15 border-cyan-200/50 dark:border-cyan-800/50",count:a.activityTypes,loading:n,onClick:()=>r("/projects/activity-types"),onNew:()=>r("/projects/activity-types/new")})]})}),t.jsx(kb,{title:"Sales flow",subtitle:"Sales Order -> Delivery Note -> Sales Invoice -> Payment",icon:t.jsx(dm,{size:14}),headerClassName:"bg-gradient-to-r from-green-600 to-emerald-700 dark:from-green-700 dark:to-emerald-800",bodyClassName:"bg-white dark:bg-gray-900/40",children:t.jsxs("div",{className:_b,children:[t.jsx(Qi,{label:"Sales Order",sub:"Sales flow",icon:t.jsx(dm,{className:"text-white"}),iconClassName:"bg-gradient-to-br from-emerald-600 to-teal-700",cardClassName:"bg-gradient-to-b from-white to-emerald-50/45 dark:from-gray-800 dark:to-emerald-950/20 border-emerald-200/55 dark:border-emerald-800/50",count:a.salesOrders,loading:l,onClick:()=>r("/sales-orders")}),t.jsx(Qi,{label:"Delivery Note",sub:"Sales flow",icon:t.jsx(G1,{className:"text-white"}),iconClassName:"bg-gradient-to-br from-cyan-600 to-blue-700",cardClassName:"bg-gradient-to-b from-white to-cyan-50/40 dark:from-gray-800 dark:to-cyan-950/15 border-cyan-200/55 dark:border-cyan-800/50",count:a.deliveryNotes,loading:l,onClick:()=>r("/delivery-notes")}),t.jsx(Qi,{label:"Sales Invoice",sub:"Sales flow",icon:t.jsx(xm,{className:"text-white"}),iconClassName:"bg-gradient-to-br from-blue-600 to-indigo-700",cardClassName:"bg-gradient-to-b from-white to-blue-50/40 dark:from-gray-800 dark:to-blue-950/20 border-blue-200/55 dark:border-blue-800/50",count:a.salesInvoices,loading:l,onClick:()=>r("/invoices")}),t.jsx(Qi,{label:"Payment Entry",sub:"Sales flow",icon:t.jsx(Zu,{className:"text-white"}),iconClassName:"bg-gradient-to-br from-violet-600 to-purple-800",cardClassName:"bg-gradient-to-b from-white to-violet-50/40 dark:from-gray-800 dark:to-violet-950/20 border-violet-200/55 dark:border-violet-800/50",count:a.paymentEntries,loading:l,onClick:()=>r("/payment-entries")})]})})]}),t.jsxs("div",{className:"flex flex-col gap-2 min-w-0",children:[t.jsx(kb,{title:"Project & task management",subtitle:"Core project monitoring and planning.",icon:t.jsx(gp,{size:14}),headerClassName:"bg-gradient-to-r from-blue-600 to-indigo-700 dark:from-blue-700 dark:to-indigo-800",bodyClassName:"bg-white dark:bg-gray-900/40",children:t.jsxs("div",{className:_b,children:[t.jsx(Qi,{label:"Projects",sub:"Open projects",icon:t.jsx(gp,{className:"text-white"}),iconClassName:"bg-gradient-to-br from-sky-500 to-blue-700",cardClassName:"bg-gradient-to-b from-white to-sky-50/50 dark:from-gray-800 dark:to-sky-950/20 border-sky-200/60 dark:border-sky-800/50",count:a.projects,loading:n,onClick:()=>r("/projects/list"),onNew:()=>r("/projects/list/new")}),t.jsx(Qi,{label:"Tasks",sub:"All tasks",icon:t.jsx(bm,{className:"text-white"}),iconClassName:"bg-gradient-to-br from-indigo-500 to-violet-700",cardClassName:"bg-gradient-to-b from-white to-indigo-50/40 dark:from-gray-800 dark:to-indigo-950/20 border-indigo-200/50 dark:border-indigo-800/50",count:a.tasks,loading:n,onClick:()=>r("/projects/tasks"),onNew:()=>r("/projects/tasks/new")}),t.jsx(Qi,{label:"Timesheets",sub:"Time logs",icon:t.jsx(ea,{className:"text-white"}),iconClassName:"bg-gradient-to-br from-emerald-500 to-teal-700",cardClassName:"bg-gradient-to-b from-white to-emerald-50/40 dark:from-gray-800 dark:to-emerald-950/20 border-emerald-200/50 dark:border-emerald-800/50",count:a.timesheets,loading:n,onClick:()=>r("/projects/timesheets"),onNew:()=>r("/projects/timesheets/new"),secondaryNew:{title:"New Sales Order",icon:t.jsx(dm,{size:10}),onClick:()=>r("/sales-orders/new")}})]})}),t.jsx(kb,{title:"Buying / material flow",subtitle:"Material Request -> Purchase Order -> Purchase Receipt",icon:t.jsx(pE,{size:14}),headerClassName:"bg-gradient-to-r from-amber-500 via-orange-500 to-rose-600 dark:from-amber-600 dark:via-orange-600 dark:to-rose-700",bodyClassName:"bg-white dark:bg-gray-900/40",children:t.jsxs("div",{className:_b,children:[t.jsx(Qi,{label:"Material Request",sub:"Buying flow",icon:t.jsx(Ju,{className:"text-white"}),iconClassName:"bg-gradient-to-br from-amber-500 to-orange-600",cardClassName:"bg-gradient-to-b from-white to-amber-50/45 dark:from-gray-800 dark:to-amber-950/20 border-amber-200/55 dark:border-amber-800/50",count:a.materialRequests,loading:l,onClick:()=>r("/material-requests")}),t.jsx(Qi,{label:"Purchase Order",sub:"Buying flow",icon:t.jsx(pp,{className:"text-white"}),iconClassName:"bg-gradient-to-br from-orange-600 to-red-700",cardClassName:"bg-gradient-to-b from-white to-orange-50/40 dark:from-gray-800 dark:to-orange-950/20 border-orange-200/55 dark:border-orange-800/50",count:a.purchaseOrders,loading:l,onClick:()=>r("/purchase-orders")}),t.jsx(Qi,{label:"Purchase Receipt",sub:"Buying flow",icon:t.jsx(pE,{className:"text-white"}),iconClassName:"bg-gradient-to-br from-rose-600 to-pink-700",cardClassName:"bg-gradient-to-b from-white to-rose-50/40 dark:from-gray-800 dark:to-rose-950/20 border-rose-200/55 dark:border-rose-800/50",count:a.purchaseReceipts,loading:l,onClick:()=>r("/purchase-receipts")})]})})]})]})]})};var Wle=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"];function RS(e){if(typeof e!="string")return!1;var r=Wle;return r.includes(e)}var Hle=["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-errormessage","aria-expanded","aria-flowto","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","className","color","height","id","lang","max","media","method","min","name","style","target","width","role","tabIndex","accentHeight","accumulate","additive","alignmentBaseline","allowReorder","alphabetic","amplitude","arabicForm","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baselineShift","baseProfile","bbox","begin","bias","by","calcMode","capHeight","clip","clipPath","clipPathUnits","clipRule","colorInterpolation","colorInterpolationFilters","colorProfile","colorRendering","contentScriptType","contentStyleType","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominantBaseline","dur","dx","dy","edgeMode","elevation","enableBackground","end","exponent","externalResourcesRequired","fill","fillOpacity","fillRule","filter","filterRes","filterUnits","floodColor","floodOpacity","focusable","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","format","from","fx","fy","g1","g2","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","glyphRef","gradientTransform","gradientUnits","hanging","horizAdvX","horizOriginX","href","ideographic","imageRendering","in2","in","intercept","k1","k2","k3","k4","k","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letterSpacing","lightingColor","limitingConeAngle","local","markerEnd","markerHeight","markerMid","markerStart","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overlinePosition","overlineThickness","paintOrder","panose1","pathLength","patternContentUnits","patternTransform","patternUnits","pointerEvents","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","renderingIntent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","seed","shapeRendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stopColor","stopOpacity","strikethroughPosition","strikethroughThickness","string","stroke","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","strokeWidth","surfaceScale","systemLanguage","tableValues","targetX","targetY","textAnchor","textDecoration","textLength","textRendering","to","transform","u1","u2","underlinePosition","underlineThickness","unicode","unicodeBidi","unicodeRange","unitsPerEm","vAlphabetic","values","vectorEffect","version","vertAdvY","vertOriginX","vertOriginY","vHanging","vIdeographic","viewTarget","visibility","vMathematical","widths","wordSpacing","writingMode","x1","x2","x","xChannelSelector","xHeight","xlinkActuate","xlinkArcrole","xlinkHref","xlinkRole","xlinkShow","xlinkTitle","xlinkType","xmlBase","xmlLang","xmlns","xmlnsXlink","xmlSpace","y1","y2","y","yChannelSelector","z","zoomAndPan","ref","key","angle"],qle=new Set(Hle);function HL(e){return typeof e!="string"?!1:qle.has(e)}function qL(e){return typeof e=="string"&&e.startsWith("data-")}function ac(e){if(typeof e!="object"||e===null)return{};var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(HL(a)||qL(a))&&(r[a]=e[a]);return r}function rx(e){if(e==null)return null;if(p.isValidElement(e)&&typeof e.props=="object"&&e.props!==null){var r=e.props;return ac(r)}return typeof e=="object"&&!Array.isArray(e)?ac(e):null}function bl(e){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(HL(a)||qL(a)||RS(a))&&(r[a]=e[a]);return r}var Vle=["children","width","height","viewBox","className","style","title","desc"];function LN(){return LN=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},LN.apply(null,arguments)}function Gle(e,r){if(e==null)return{};var a,s,n=Kle(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function Kle(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}var MS=p.forwardRef((e,r)=>{var{children:a,width:s,height:n,viewBox:i,className:o,style:l,title:c,desc:u}=e,h=Gle(e,Vle),f=i||{width:s,height:n,x:0,y:0},y=va("recharts-surface",o);return p.createElement("svg",LN({},bl(h),{className:y,width:s,height:n,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:r}),p.createElement("title",null,c),p.createElement("desc",null,u),a)}),Yle=["children","className"];function FN(){return FN=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},FN.apply(null,arguments)}function Jle(e,r){if(e==null)return{};var a,s,n=Zle(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function Zle(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}var yi=p.forwardRef((e,r)=>{var{children:a,className:s}=e,n=Jle(e,Yle),i=va("recharts-layer",s);return p.createElement("g",FN({className:i},bl(n),{ref:r}),a)}),VL=p.createContext(null),Xle=()=>p.useContext(VL);function ms(e){return function(){return e}}const GL=Math.cos,Gv=Math.sin,dc=Math.sqrt,Kv=Math.PI,fw=2*Kv,IN=Math.PI,zN=2*IN,V0=1e-6,Qle=zN-V0;function KL(e){this._+=e[0];for(let r=1,a=e.length;r<a;++r)this._+=arguments[r]+e[r]}function ece(e){let r=Math.floor(e);if(!(r>=0))throw new Error(`invalid digits: ${e}`);if(r>15)return KL;const a=O0(10,r);return function(s){this._+=s[0];for(let n=1,i=s.length;n<i;++n)this._+=Math.round(arguments[n]*a)/a+s[n]}}class tce{constructor(r){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=r==null?KL:ece(r)}moveTo(r,a){this._append`M${this._x0=this._x1=+r},${this._y0=this._y1=+a}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(r,a){this._append`L${this._x1=+r},${this._y1=+a}`}quadraticCurveTo(r,a,s,n){this._append`Q${+r},${+a},${this._x1=+s},${this._y1=+n}`}bezierCurveTo(r,a,s,n,i,o){this._append`C${+r},${+a},${+s},${+n},${this._x1=+i},${this._y1=+o}`}arcTo(r,a,s,n,i){if(r=+r,a=+a,s=+s,n=+n,i=+i,i<0)throw new Error(`negative radius: ${i}`);let o=this._x1,l=this._y1,c=s-r,u=n-a,h=o-r,f=l-a,y=h*h+f*f;if(this._x1===null)this._append`M${this._x1=r},${this._y1=a}`;else if(y>V0)if(!(Math.abs(f*c-u*h)>V0)||!i)this._append`L${this._x1=r},${this._y1=a}`;else{let b=s-o,w=n-l,v=c*c+u*u,k=b*b+w*w,S=Math.sqrt(v),N=Math.sqrt(y),C=i*Math.tan((IN-Math.acos((v+y-k)/(2*S*N)))/2),O=C/N,T=C/S;Math.abs(O-1)>V0&&this._append`L${r+O*h},${a+O*f}`,this._append`A${i},${i},0,0,${+(f*b>h*w)},${this._x1=r+T*c},${this._y1=a+T*u}`}}arc(r,a,s,n,i,o){if(r=+r,a=+a,s=+s,o=!!o,s<0)throw new Error(`negative radius: ${s}`);let l=s*Math.cos(n),c=s*Math.sin(n),u=r+l,h=a+c,f=1^o,y=o?n-i:i-n;this._x1===null?this._append`M${u},${h}`:(Math.abs(this._x1-u)>V0||Math.abs(this._y1-h)>V0)&&this._append`L${u},${h}`,s&&(y<0&&(y=y%zN+zN),y>Qle?this._append`A${s},${s},0,1,${f},${r-l},${a-c}A${s},${s},0,1,${f},${this._x1=u},${this._y1=h}`:y>V0&&this._append`A${s},${s},0,${+(y>=IN)},${f},${this._x1=r+s*Math.cos(i)},${this._y1=a+s*Math.sin(i)}`)}rect(r,a,s,n){this._append`M${this._x0=this._x1=+r},${this._y0=this._y1=+a}h${s=+s}v${+n}h${-s}Z`}toString(){return this._}}function LS(e){let r=3;return e.digits=function(a){if(!arguments.length)return r;if(a==null)r=null;else{const s=Math.floor(a);if(!(s>=0))throw new RangeError(`invalid digits: ${a}`);r=s}return e},()=>new tce(r)}function FS(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function YL(e){this._context=e}YL.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,r){switch(e=+e,r=+r,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,r):this._context.moveTo(e,r);break;case 1:this._point=2;default:this._context.lineTo(e,r);break}}};function xw(e){return new YL(e)}function JL(e){return e[0]}function ZL(e){return e[1]}function XL(e,r){var a=ms(!0),s=null,n=xw,i=null,o=LS(l);e=typeof e=="function"?e:e===void 0?JL:ms(e),r=typeof r=="function"?r:r===void 0?ZL:ms(r);function l(c){var u,h=(c=FS(c)).length,f,y=!1,b;for(s==null&&(i=n(b=o())),u=0;u<=h;++u)!(u<h&&a(f=c[u],u,c))===y&&((y=!y)?i.lineStart():i.lineEnd()),y&&i.point(+e(f,u,c),+r(f,u,c));if(b)return i=null,b+""||null}return l.x=function(c){return arguments.length?(e=typeof c=="function"?c:ms(+c),l):e},l.y=function(c){return arguments.length?(r=typeof c=="function"?c:ms(+c),l):r},l.defined=function(c){return arguments.length?(a=typeof c=="function"?c:ms(!!c),l):a},l.curve=function(c){return arguments.length?(n=c,s!=null&&(i=n(s)),l):n},l.context=function(c){return arguments.length?(c==null?s=i=null:i=n(s=c),l):s},l}function Nb(e,r,a){var s=null,n=ms(!0),i=null,o=xw,l=null,c=LS(u);e=typeof e=="function"?e:e===void 0?JL:ms(+e),r=typeof r=="function"?r:ms(r===void 0?0:+r),a=typeof a=="function"?a:a===void 0?ZL:ms(+a);function u(f){var y,b,w,v=(f=FS(f)).length,k,S=!1,N,C=new Array(v),O=new Array(v);for(i==null&&(l=o(N=c())),y=0;y<=v;++y){if(!(y<v&&n(k=f[y],y,f))===S)if(S=!S)b=y,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),w=y-1;w>=b;--w)l.point(C[w],O[w]);l.lineEnd(),l.areaEnd()}S&&(C[y]=+e(k,y,f),O[y]=+r(k,y,f),l.point(s?+s(k,y,f):C[y],a?+a(k,y,f):O[y]))}if(N)return l=null,N+""||null}function h(){return XL().defined(n).curve(o).context(i)}return u.x=function(f){return arguments.length?(e=typeof f=="function"?f:ms(+f),s=null,u):e},u.x0=function(f){return arguments.length?(e=typeof f=="function"?f:ms(+f),u):e},u.x1=function(f){return arguments.length?(s=f==null?null:typeof f=="function"?f:ms(+f),u):s},u.y=function(f){return arguments.length?(r=typeof f=="function"?f:ms(+f),a=null,u):r},u.y0=function(f){return arguments.length?(r=typeof f=="function"?f:ms(+f),u):r},u.y1=function(f){return arguments.length?(a=f==null?null:typeof f=="function"?f:ms(+f),u):a},u.lineX0=u.lineY0=function(){return h().x(e).y(r)},u.lineY1=function(){return h().x(e).y(a)},u.lineX1=function(){return h().x(s).y(r)},u.defined=function(f){return arguments.length?(n=typeof f=="function"?f:ms(!!f),u):n},u.curve=function(f){return arguments.length?(o=f,i!=null&&(l=o(i)),u):o},u.context=function(f){return arguments.length?(f==null?i=l=null:l=o(i=f),u):i},u}class QL{constructor(r,a){this._context=r,this._x=a}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(r,a){switch(r=+r,a=+a,this._point){case 0:{this._point=1,this._line?this._context.lineTo(r,a):this._context.moveTo(r,a);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+r)/2,this._y0,this._x0,a,r,a):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+a)/2,r,this._y0,r,a);break}}this._x0=r,this._y0=a}}function rce(e){return new QL(e,!0)}function ace(e){return new QL(e,!1)}const IS={draw(e,r){const a=dc(r/Kv);e.moveTo(a,0),e.arc(0,0,a,0,fw)}},sce={draw(e,r){const a=dc(r/5)/2;e.moveTo(-3*a,-a),e.lineTo(-a,-a),e.lineTo(-a,-3*a),e.lineTo(a,-3*a),e.lineTo(a,-a),e.lineTo(3*a,-a),e.lineTo(3*a,a),e.lineTo(a,a),e.lineTo(a,3*a),e.lineTo(-a,3*a),e.lineTo(-a,a),e.lineTo(-3*a,a),e.closePath()}},eF=dc(1/3),nce=eF*2,ice={draw(e,r){const a=dc(r/nce),s=a*eF;e.moveTo(0,-a),e.lineTo(s,0),e.lineTo(0,a),e.lineTo(-s,0),e.closePath()}},oce={draw(e,r){const a=dc(r),s=-a/2;e.rect(s,s,a,a)}},lce=.8908130915292852,tF=Gv(Kv/10)/Gv(7*Kv/10),cce=Gv(fw/10)*tF,dce=-GL(fw/10)*tF,uce={draw(e,r){const a=dc(r*lce),s=cce*a,n=dce*a;e.moveTo(0,-a),e.lineTo(s,n);for(let i=1;i<5;++i){const o=fw*i/5,l=GL(o),c=Gv(o);e.lineTo(c*a,-l*a),e.lineTo(l*s-c*n,c*s+l*n)}e.closePath()}},Nk=dc(3),mce={draw(e,r){const a=-dc(r/(Nk*3));e.moveTo(0,a*2),e.lineTo(-Nk*a,-a),e.lineTo(Nk*a,-a),e.closePath()}},il=-.5,ol=dc(3)/2,$N=1/dc(12),hce=($N/2+1)*3,pce={draw(e,r){const a=dc(r/hce),s=a/2,n=a*$N,i=s,o=a*$N+a,l=-i,c=o;e.moveTo(s,n),e.lineTo(i,o),e.lineTo(l,c),e.lineTo(il*s-ol*n,ol*s+il*n),e.lineTo(il*i-ol*o,ol*i+il*o),e.lineTo(il*l-ol*c,ol*l+il*c),e.lineTo(il*s+ol*n,il*n-ol*s),e.lineTo(il*i+ol*o,il*o-ol*i),e.lineTo(il*l+ol*c,il*c-ol*l),e.closePath()}};function gce(e,r){let a=null,s=LS(n);e=typeof e=="function"?e:ms(e||IS),r=typeof r=="function"?r:ms(r===void 0?64:+r);function n(){let i;if(a||(a=i=s()),e.apply(this,arguments).draw(a,+r.apply(this,arguments)),i)return a=null,i+""||null}return n.type=function(i){return arguments.length?(e=typeof i=="function"?i:ms(i),n):e},n.size=function(i){return arguments.length?(r=typeof i=="function"?i:ms(+i),n):r},n.context=function(i){return arguments.length?(a=i==null?null:i,n):a},n}function Yv(){}function Jv(e,r,a){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+r)/6,(e._y0+4*e._y1+a)/6)}function rF(e){this._context=e}rF.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:Jv(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,r){switch(e=+e,r=+r,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,r):this._context.moveTo(e,r);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Jv(this,e,r);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=r}};function fce(e){return new rF(e)}function aF(e){this._context=e}aF.prototype={areaStart:Yv,areaEnd:Yv,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,r){switch(e=+e,r=+r,this._point){case 0:this._point=1,this._x2=e,this._y2=r;break;case 1:this._point=2,this._x3=e,this._y3=r;break;case 2:this._point=3,this._x4=e,this._y4=r,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+r)/6);break;default:Jv(this,e,r);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=r}};function xce(e){return new aF(e)}function sF(e){this._context=e}sF.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,r){switch(e=+e,r=+r,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var a=(this._x0+4*this._x1+e)/6,s=(this._y0+4*this._y1+r)/6;this._line?this._context.lineTo(a,s):this._context.moveTo(a,s);break;case 3:this._point=4;default:Jv(this,e,r);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=r}};function yce(e){return new sF(e)}function nF(e){this._context=e}nF.prototype={areaStart:Yv,areaEnd:Yv,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,r){e=+e,r=+r,this._point?this._context.lineTo(e,r):(this._point=1,this._context.moveTo(e,r))}};function bce(e){return new nF(e)}function B7(e){return e<0?-1:1}function W7(e,r,a){var s=e._x1-e._x0,n=r-e._x1,i=(e._y1-e._y0)/(s||n<0&&-0),o=(a-e._y1)/(n||s<0&&-0),l=(i*n+o*s)/(s+n);return(B7(i)+B7(o))*Math.min(Math.abs(i),Math.abs(o),.5*Math.abs(l))||0}function H7(e,r){var a=e._x1-e._x0;return a?(3*(e._y1-e._y0)/a-r)/2:r}function Sk(e,r,a){var s=e._x0,n=e._y0,i=e._x1,o=e._y1,l=(i-s)/3;e._context.bezierCurveTo(s+l,n+l*r,i-l,o-l*a,i,o)}function Zv(e){this._context=e}Zv.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:Sk(this,this._t0,H7(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,r){var a=NaN;if(e=+e,r=+r,!(e===this._x1&&r===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,r):this._context.moveTo(e,r);break;case 1:this._point=2;break;case 2:this._point=3,Sk(this,H7(this,a=W7(this,e,r)),a);break;default:Sk(this,this._t0,a=W7(this,e,r));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=r,this._t0=a}}};function iF(e){this._context=new oF(e)}(iF.prototype=Object.create(Zv.prototype)).point=function(e,r){Zv.prototype.point.call(this,r,e)};function oF(e){this._context=e}oF.prototype={moveTo:function(e,r){this._context.moveTo(r,e)},closePath:function(){this._context.closePath()},lineTo:function(e,r){this._context.lineTo(r,e)},bezierCurveTo:function(e,r,a,s,n,i){this._context.bezierCurveTo(r,e,s,a,i,n)}};function vce(e){return new Zv(e)}function wce(e){return new iF(e)}function lF(e){this._context=e}lF.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,r=this._y,a=e.length;if(a)if(this._line?this._context.lineTo(e[0],r[0]):this._context.moveTo(e[0],r[0]),a===2)this._context.lineTo(e[1],r[1]);else for(var s=q7(e),n=q7(r),i=0,o=1;o<a;++i,++o)this._context.bezierCurveTo(s[0][i],n[0][i],s[1][i],n[1][i],e[o],r[o]);(this._line||this._line!==0&&a===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(e,r){this._x.push(+e),this._y.push(+r)}};function q7(e){var r,a=e.length-1,s,n=new Array(a),i=new Array(a),o=new Array(a);for(n[0]=0,i[0]=2,o[0]=e[0]+2*e[1],r=1;r<a-1;++r)n[r]=1,i[r]=4,o[r]=4*e[r]+2*e[r+1];for(n[a-1]=2,i[a-1]=7,o[a-1]=8*e[a-1]+e[a],r=1;r<a;++r)s=n[r]/i[r-1],i[r]-=s,o[r]-=s*o[r-1];for(n[a-1]=o[a-1]/i[a-1],r=a-2;r>=0;--r)n[r]=(o[r]-n[r+1])/i[r];for(i[a-1]=(e[a]+n[a-1])/2,r=0;r<a-1;++r)i[r]=2*e[r+1]-n[r+1];return[n,i]}function jce(e){return new lF(e)}function yw(e,r){this._context=e,this._t=r}yw.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,r){switch(e=+e,r=+r,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,r):this._context.moveTo(e,r);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,r),this._context.lineTo(e,r);else{var a=this._x*(1-this._t)+e*this._t;this._context.lineTo(a,this._y),this._context.lineTo(a,r)}break}}this._x=e,this._y=r}};function _ce(e){return new yw(e,.5)}function kce(e){return new yw(e,0)}function Nce(e){return new yw(e,1)}function Sm(e,r){if((o=e.length)>1)for(var a=1,s,n,i=e[r[0]],o,l=i.length;a<o;++a)for(n=i,i=e[r[a]],s=0;s<l;++s)i[s][1]+=i[s][0]=isNaN(n[s][1])?n[s][0]:n[s][1]}function UN(e){for(var r=e.length,a=new Array(r);--r>=0;)a[r]=r;return a}function Sce(e,r){return e[r]}function Cce(e){const r=[];return r.key=e,r}function Tce(){var e=ms([]),r=UN,a=Sm,s=Sce;function n(i){var o=Array.from(e.apply(this,arguments),Cce),l,c=o.length,u=-1,h;for(const f of i)for(l=0,++u;l<c;++l)(o[l][u]=[0,+s(f,o[l].key,u,i)]).data=f;for(l=0,h=FS(r(o));l<c;++l)o[h[l]].index=l;return a(o,h),o}return n.keys=function(i){return arguments.length?(e=typeof i=="function"?i:ms(Array.from(i)),n):e},n.value=function(i){return arguments.length?(s=typeof i=="function"?i:ms(+i),n):s},n.order=function(i){return arguments.length?(r=i==null?UN:typeof i=="function"?i:ms(Array.from(i)),n):r},n.offset=function(i){return arguments.length?(a=i==null?Sm:i,n):a},n}function Ece(e,r){if((s=e.length)>0){for(var a,s,n=0,i=e[0].length,o;n<i;++n){for(o=a=0;a<s;++a)o+=e[a][n][1]||0;if(o)for(a=0;a<s;++a)e[a][n][1]/=o}Sm(e,r)}}function Ace(e,r){if((n=e.length)>0){for(var a=0,s=e[r[0]],n,i=s.length;a<i;++a){for(var o=0,l=0;o<n;++o)l+=e[o][a][1]||0;s[a][1]+=s[a][0]=-l/2}Sm(e,r)}}function Oce(e,r){if(!(!((o=e.length)>0)||!((i=(n=e[r[0]]).length)>0))){for(var a=0,s=1,n,i,o;s<i;++s){for(var l=0,c=0,u=0;l<o;++l){for(var h=e[r[l]],f=h[s][1]||0,y=h[s-1][1]||0,b=(f-y)/2,w=0;w<l;++w){var v=e[r[w]],k=v[s][1]||0,S=v[s-1][1]||0;b+=k-S}c+=f,u+=b*f}n[s-1][1]+=n[s-1][0]=a,c&&(a-=u/c)}n[s-1][1]+=n[s-1][0]=a,Sm(e,r)}}var Ck={},Tk={},V7;function Pce(){return V7||(V7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function r(a){return a==="__proto__"}e.isUnsafeProperty=r})(Tk)),Tk}var Ek={},G7;function cF(){return G7||(G7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function r(a){switch(typeof a){case"number":case"symbol":return!1;case"string":return a.includes(".")||a.includes("[")||a.includes("]")}}e.isDeepKey=r})(Ek)),Ek}var Ak={},K7;function zS(){return K7||(K7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function r(a){var s;return typeof a=="string"||typeof a=="symbol"?a:Object.is((s=a==null?void 0:a.valueOf)==null?void 0:s.call(a),-0)?"-0":String(a)}e.toKey=r})(Ak)),Ak}var Ok={},Pk={},Y7;function Dce(){return Y7||(Y7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function r(a){if(a==null)return"";if(typeof a=="string")return a;if(Array.isArray(a))return a.map(r).join(",");const s=String(a);return s==="0"&&Object.is(Number(a),-0)?"-0":s}e.toString=r})(Pk)),Pk}var J7;function $S(){return J7||(J7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=Dce(),a=zS();function s(n){if(Array.isArray(n))return n.map(a.toKey);if(typeof n=="symbol")return[n];n=r.toString(n);const i=[],o=n.length;if(o===0)return i;let l=0,c="",u="",h=!1;for(n.charCodeAt(0)===46&&(i.push(""),l++);l<o;){const f=n[l];u?f==="\\"&&l+1<o?(l++,c+=n[l]):f===u?u="":c+=f:h?f==='"'||f==="'"?u=f:f==="]"?(h=!1,i.push(c),c=""):c+=f:f==="["?(h=!0,c&&(i.push(c),c="")):f==="."?c&&(i.push(c),c=""):c+=f,l++}return c&&i.push(c),i}e.toPath=s})(Ok)),Ok}var Z7;function US(){return Z7||(Z7=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=Pce(),a=cF(),s=zS(),n=$S();function i(l,c,u){if(l==null)return u;switch(typeof c){case"string":{if(r.isUnsafeProperty(c))return u;const h=l[c];return h===void 0?a.isDeepKey(c)?i(l,n.toPath(c),u):u:h}case"number":case"symbol":{typeof c=="number"&&(c=s.toKey(c));const h=l[c];return h===void 0?u:h}default:{if(Array.isArray(c))return o(l,c,u);if(Object.is(c==null?void 0:c.valueOf(),-0)?c="-0":c=String(c),r.isUnsafeProperty(c))return u;const h=l[c];return h===void 0?u:h}}}function o(l,c,u){if(c.length===0)return u;let h=l;for(let f=0;f<c.length;f++){if(h==null||r.isUnsafeProperty(c[f]))return u;h=h[c[f]]}return h===void 0?u:h}e.get=i})(Ck)),Ck}var Dk,X7;function Rce(){return X7||(X7=1,Dk=US().get),Dk}var Mce=Rce();const Cm=tu(Mce);var Lce=4;function Gu(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Lce,a=O0(10,r),s=Math.round(e*a)/a;return Object.is(s,-0)?0:s}function Bs(e){for(var r=arguments.length,a=new Array(r>1?r-1:0),s=1;s<r;s++)a[s-1]=arguments[s];return e.reduce((n,i,o)=>{var l=a[o-1];return typeof l=="string"?n+l+i:l!==void 0?n+Gu(l)+i:n+i},"")}var Ln=e=>e===0?0:e>0?1:-1,$c=e=>typeof e=="number"&&e!=+e,Tm=e=>typeof e=="string"&&e.indexOf("%")===e.length-1,_r=e=>(typeof e=="number"||e instanceof Number)&&!$c(e),Uc=e=>_r(e)||typeof e=="string",Fce=0,ax=e=>{var r=++Fce;return"".concat(e||"").concat(r)},xi=function(r,a){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!_r(r)&&typeof r!="string")return s;var i;if(Tm(r)){if(a==null)return s;var o=r.indexOf("%");i=a*parseFloat(r.slice(0,o))/100}else i=+r;return $c(i)&&(i=s),n&&a!=null&&i>a&&(i=a),i},dF=e=>{if(!Array.isArray(e))return!1;for(var r=e.length,a={},s=0;s<r;s++)if(!a[String(e[s])])a[String(e[s])]=!0;else return!0;return!1};function wn(e,r,a){return _r(e)&&_r(r)?Gu(e+a*(r-e)):r}function Ice(e,r,a){if(!(!e||!e.length))return e.find(s=>s&&(typeof r=="function"?r(s):Cm(s,r))===a)}var _n=e=>e===null||typeof e=="undefined",zx=e=>_n(e)?e:"".concat(e.charAt(0).toUpperCase()).concat(e.slice(1));function so(e){return e!=null}function Yp(){}var zce=["type","size","sizeType"];function BN(){return BN=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},BN.apply(null,arguments)}function Q7(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function e8(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?Q7(Object(a),!0).forEach(function(s){$ce(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):Q7(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function $ce(e,r,a){return(r=Uce(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Uce(e){var r=Bce(e,"string");return typeof r=="symbol"?r:r+""}function Bce(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Wce(e,r){if(e==null)return{};var a,s,n=Hce(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function Hce(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}var uF={symbolCircle:IS,symbolCross:sce,symbolDiamond:ice,symbolSquare:oce,symbolStar:uce,symbolTriangle:mce,symbolWye:pce},qce=Math.PI/180,Vce=e=>{var r="symbol".concat(zx(e));return uF[r]||IS},Gce=(e,r,a)=>{if(r==="area")return e;switch(a){case"cross":return 5*e*e/9;case"diamond":return .5*e*e/Math.sqrt(3);case"square":return e*e;case"star":{var s=18*qce;return 1.25*e*e*(Math.tan(s)-Math.tan(s*2)*O0(Math.tan(s),2))}case"triangle":return Math.sqrt(3)*e*e/4;case"wye":return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},Kce=(e,r)=>{uF["symbol".concat(zx(e))]=r},BS=e=>{var{type:r="circle",size:a=64,sizeType:s="area"}=e,n=Wce(e,zce),i=e8(e8({},n),{},{type:r,size:a,sizeType:s}),o="circle";typeof r=="string"&&(o=r);var l=()=>{var y=Vce(o),b=gce().type(y).size(Gce(a,s,o)),w=b();if(w!==null)return w},{className:c,cx:u,cy:h}=i,f=bl(i);return _r(u)&&_r(h)&&_r(a)?p.createElement("path",BN({},f,{className:va("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(h,")"),d:l()})):null};BS.registerSymbol=Kce;var mF=e=>"radius"in e&&"startAngle"in e&&"endAngle"in e,Yce=(e,r)=>{if(!e||typeof e=="function"||typeof e=="boolean")return null;var a=e;if(p.isValidElement(e)&&(a=e.props),typeof a!="object"&&typeof a!="function")return null;var s={};return Object.keys(a).forEach(n=>{RS(n)&&typeof a[n]=="function"&&(s[n]=(i=>a[n](a,i)))}),s},Jce=(e,r,a)=>s=>(e(r,a,s),null),$x=(e,r,a)=>{if(e===null||typeof e!="object"&&typeof e!="function")return null;var s=null;return Object.keys(e).forEach(n=>{var i=e[n];RS(n)&&typeof i=="function"&&(s||(s={}),s[n]=Jce(i,r,a))}),s};function t8(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function Zce(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?t8(Object(a),!0).forEach(function(s){Xce(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):t8(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function Xce(e,r,a){return(r=Qce(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Qce(e){var r=ede(e,"string");return typeof r=="symbol"?r:r+""}function ede(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function In(e,r){var a=Zce({},e),s=r,n=Object.keys(r),i=n.reduce((o,l)=>(o[l]===void 0&&s[l]!==void 0&&(o[l]=s[l]),o),a);return i}function Xv(){return Xv=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},Xv.apply(null,arguments)}function r8(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function hF(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?r8(Object(a),!0).forEach(function(s){tde(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):r8(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function tde(e,r,a){return(r=rde(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function rde(e){var r=ade(e,"string");return typeof r=="symbol"?r:r+""}function ade(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var ml=32,sde={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle",labelStyle:{}};function nde(e){if(typeof e=="object"&&e!==null&&"strokeDasharray"in e)return String(e.strokeDasharray)}function ide(e){var{data:r,iconType:a,inactiveColor:s}=e,n=ml/2,i=ml/6,o=ml/3,l=r.inactive?s:r.color,c=a!=null?a:r.type;if(c==="none")return null;if(c==="plainline")return p.createElement("line",{strokeWidth:4,fill:"none",stroke:l,strokeDasharray:nde(r.payload),x1:0,y1:n,x2:ml,y2:n,className:"recharts-legend-icon"});if(c==="line")return p.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(n,"h").concat(o,`
|
||
A`).concat(i,",").concat(i,",0,1,1,").concat(2*o,",").concat(n,`
|
||
H`).concat(ml,"M").concat(2*o,",").concat(n,`
|
||
A`).concat(i,",").concat(i,",0,1,1,").concat(o,",").concat(n),className:"recharts-legend-icon"});if(c==="rect")return p.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(ml/8,"h").concat(ml,"v").concat(ml*3/4,"h").concat(-ml,"z"),className:"recharts-legend-icon"});if(p.isValidElement(r.legendIcon)){var u=hF({},r);return delete u.legendIcon,p.cloneElement(r.legendIcon,u)}return p.createElement(BS,{fill:l,cx:n,cy:n,size:ml,sizeType:"diameter",type:c})}function ode(e){var{payload:r,iconSize:a,layout:s,formatter:n,inactiveColor:i,iconType:o,labelStyle:l}=e,c={x:0,y:0,width:ml,height:ml},u={display:s==="horizontal"?"inline-block":"block",marginRight:10},h={display:"inline-block",verticalAlign:"middle",marginRight:4};return r.map((f,y)=>{var b=f.formatter||n,w=va({"recharts-legend-item":!0,["legend-item-".concat(y)]:!0,inactive:f.inactive});if(f.type==="none")return null;var v=typeof l=="object"?hF({},l):{};v.color=f.inactive?i:v.color||f.color;var k=b?b(f.value,f,y):f.value;return p.createElement("li",Xv({className:w,style:u,key:"legend-item-".concat(y)},$x(e,f,y)),p.createElement(MS,{width:a,height:a,viewBox:c,style:h,"aria-label":"".concat(f.value," legend icon")},p.createElement(ide,{data:f,iconType:o,inactiveColor:i})),p.createElement("span",{className:"recharts-legend-item-text",style:v},k))})}var lde=e=>{var r=In(e,sde),{payload:a,layout:s,align:n}=r;if(!a||!a.length)return null;var i={padding:0,margin:0,textAlign:s==="horizontal"?n:"left"};return p.createElement("ul",{className:"recharts-default-legend",style:i},p.createElement(ode,Xv({},r,{payload:a})))},Rk={},Mk={},a8;function cde(){return a8||(a8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function r(a,s){const n=new Map;for(let i=0;i<a.length;i++){const o=a[i],l=s(o,i,a);n.has(l)||n.set(l,o)}return Array.from(n.values())}e.uniqBy=r})(Mk)),Mk}var Lk={},s8;function dde(){return s8||(s8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function r(a,s){return function(...n){return a.apply(this,n.slice(0,s))}}e.ary=r})(Lk)),Lk}var Fk={},n8;function pF(){return n8||(n8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function r(a){return a}e.identity=r})(Fk)),Fk}var Ik={},zk={},$k={},i8;function ude(){return i8||(i8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function r(a){return Number.isSafeInteger(a)&&a>=0}e.isLength=r})($k)),$k}var o8;function gF(){return o8||(o8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=ude();function a(s){return s!=null&&typeof s!="function"&&r.isLength(s.length)}e.isArrayLike=a})(zk)),zk}var Uk={},l8;function mde(){return l8||(l8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function r(a){return typeof a=="object"&&a!==null}e.isObjectLike=r})(Uk)),Uk}var c8;function hde(){return c8||(c8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=gF(),a=mde();function s(n){return a.isObjectLike(n)&&r.isArrayLike(n)}e.isArrayLikeObject=s})(Ik)),Ik}var Bk={},Wk={},d8;function pde(){return d8||(d8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=US();function a(s){return function(n){return r.get(n,s)}}e.property=a})(Wk)),Wk}var Hk={},qk={},Vk={},Gk={},u8;function fF(){return u8||(u8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function r(a){return a!==null&&(typeof a=="object"||typeof a=="function")}e.isObject=r})(Gk)),Gk}var Kk={},m8;function xF(){return m8||(m8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function r(a){return a==null||typeof a!="object"&&typeof a!="function"}e.isPrimitive=r})(Kk)),Kk}var Yk={},h8;function yF(){return h8||(h8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function r(a,s){return a===s||Number.isNaN(a)&&Number.isNaN(s)}e.isEqualsSameValueZero=r})(Yk)),Yk}var p8;function gde(){return p8||(p8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=fF(),a=xF(),s=yF();function n(h,f,y){return typeof y!="function"?n(h,f,()=>{}):i(h,f,function b(w,v,k,S,N,C){const O=y(w,v,k,S,N,C);return O!==void 0?!!O:i(w,v,b,C)},new Map)}function i(h,f,y,b){if(f===h)return!0;switch(typeof f){case"object":return o(h,f,y,b);case"function":return Object.keys(f).length>0?i(h,se({},f),y,b):s.isEqualsSameValueZero(h,f);default:return r.isObject(h)?typeof f=="string"?f==="":!0:s.isEqualsSameValueZero(h,f)}}function o(h,f,y,b){if(f==null)return!0;if(Array.isArray(f))return c(h,f,y,b);if(f instanceof Map)return l(h,f,y,b);if(f instanceof Set)return u(h,f,y,b);const w=Object.keys(f);if(h==null||a.isPrimitive(h))return w.length===0;if(w.length===0)return!0;if(b!=null&&b.has(f))return b.get(f)===h;b==null||b.set(f,h);try{for(let v=0;v<w.length;v++){const k=w[v];if(!a.isPrimitive(h)&&!(k in h)||f[k]===void 0&&h[k]!==void 0||f[k]===null&&h[k]!==null||!y(h[k],f[k],k,h,f,b))return!1}return!0}finally{b==null||b.delete(f)}}function l(h,f,y,b){if(f.size===0)return!0;if(!(h instanceof Map))return!1;for(const[w,v]of f.entries()){const k=h.get(w);if(y(k,v,w,h,f,b)===!1)return!1}return!0}function c(h,f,y,b){if(f.length===0)return!0;if(!Array.isArray(h))return!1;const w=new Set;for(let v=0;v<f.length;v++){const k=f[v];let S=!1;for(let N=0;N<h.length;N++){if(w.has(N))continue;const C=h[N];let O=!1;if(y(C,k,v,h,f,b)&&(O=!0),O){w.add(N),S=!0;break}}if(!S)return!1}return!0}function u(h,f,y,b){return f.size===0?!0:h instanceof Set?c([...h],[...f],y,b):!1}e.isMatchWith=n,e.isSetMatch=u})(Vk)),Vk}var g8;function bF(){return g8||(g8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=gde();function a(s,n){return r.isMatchWith(s,n,()=>{})}e.isMatch=a})(qk)),qk}var Jk={},Zk={},Xk={},f8;function fde(){return f8||(f8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function r(a){return Object.getOwnPropertySymbols(a).filter(s=>Object.prototype.propertyIsEnumerable.call(a,s))}e.getSymbols=r})(Xk)),Xk}var Qk={},x8;function WS(){return x8||(x8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function r(a){return a==null?a===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(a)}e.getTag=r})(Qk)),Qk}var e2={},y8;function vF(){return y8||(y8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r="[object RegExp]",a="[object String]",s="[object Number]",n="[object Boolean]",i="[object Arguments]",o="[object Symbol]",l="[object Date]",c="[object Map]",u="[object Set]",h="[object Array]",f="[object Function]",y="[object ArrayBuffer]",b="[object Object]",w="[object Error]",v="[object DataView]",k="[object Uint8Array]",S="[object Uint8ClampedArray]",N="[object Uint16Array]",C="[object Uint32Array]",O="[object BigUint64Array]",T="[object Int8Array]",P="[object Int16Array]",E="[object Int32Array]",R="[object BigInt64Array]",z="[object Float32Array]",G="[object Float64Array]";e.argumentsTag=i,e.arrayBufferTag=y,e.arrayTag=h,e.bigInt64ArrayTag=R,e.bigUint64ArrayTag=O,e.booleanTag=n,e.dataViewTag=v,e.dateTag=l,e.errorTag=w,e.float32ArrayTag=z,e.float64ArrayTag=G,e.functionTag=f,e.int16ArrayTag=P,e.int32ArrayTag=E,e.int8ArrayTag=T,e.mapTag=c,e.numberTag=s,e.objectTag=b,e.regexpTag=r,e.setTag=u,e.stringTag=a,e.symbolTag=o,e.uint16ArrayTag=N,e.uint32ArrayTag=C,e.uint8ArrayTag=k,e.uint8ClampedArrayTag=S})(e2)),e2}var t2={},b8;function xde(){return b8||(b8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function r(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)}e.isTypedArray=r})(t2)),t2}var v8;function wF(){return v8||(v8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=fde(),a=WS(),s=vF(),n=xF(),i=xde();function o(h,f){return l(h,void 0,h,new Map,f)}function l(h,f,y,b=new Map,w=void 0){const v=w==null?void 0:w(h,f,y,b);if(v!==void 0)return v;if(n.isPrimitive(h))return h;if(b.has(h))return b.get(h);if(Array.isArray(h)){const k=new Array(h.length);b.set(h,k);for(let S=0;S<h.length;S++)k[S]=l(h[S],S,y,b,w);return Object.hasOwn(h,"index")&&(k.index=h.index),Object.hasOwn(h,"input")&&(k.input=h.input),k}if(h instanceof Date)return new Date(h.getTime());if(h instanceof RegExp){const k=new RegExp(h.source,h.flags);return k.lastIndex=h.lastIndex,k}if(h instanceof Map){const k=new Map;b.set(h,k);for(const[S,N]of h)k.set(S,l(N,S,y,b,w));return k}if(h instanceof Set){const k=new Set;b.set(h,k);for(const S of h)k.add(l(S,void 0,y,b,w));return k}if(typeof Buffer!="undefined"&&Buffer.isBuffer(h))return h.subarray();if(i.isTypedArray(h)){const k=new(Object.getPrototypeOf(h)).constructor(h.length);b.set(h,k);for(let S=0;S<h.length;S++)k[S]=l(h[S],S,y,b,w);return k}if(h instanceof ArrayBuffer||typeof SharedArrayBuffer!="undefined"&&h instanceof SharedArrayBuffer)return h.slice(0);if(h instanceof DataView){const k=new DataView(h.buffer.slice(0),h.byteOffset,h.byteLength);return b.set(h,k),c(k,h,y,b,w),k}if(typeof File!="undefined"&&h instanceof File){const k=new File([h],h.name,{type:h.type});return b.set(h,k),c(k,h,y,b,w),k}if(typeof Blob!="undefined"&&h instanceof Blob){const k=new Blob([h],{type:h.type});return b.set(h,k),c(k,h,y,b,w),k}if(h instanceof Error){const k=structuredClone(h);return b.set(h,k),k.message=h.message,k.name=h.name,k.stack=h.stack,k.cause=h.cause,k.constructor=h.constructor,c(k,h,y,b,w),k}if(h instanceof Boolean){const k=new Boolean(h.valueOf());return b.set(h,k),c(k,h,y,b,w),k}if(h instanceof Number){const k=new Number(h.valueOf());return b.set(h,k),c(k,h,y,b,w),k}if(h instanceof String){const k=new String(h.valueOf());return b.set(h,k),c(k,h,y,b,w),k}if(typeof h=="object"&&u(h)){const k=Object.create(Object.getPrototypeOf(h));return b.set(h,k),c(k,h,y,b,w),k}return h}function c(h,f,y=h,b,w){const v=[...Object.keys(f),...r.getSymbols(f)];for(let k=0;k<v.length;k++){const S=v[k],N=Object.getOwnPropertyDescriptor(h,S);(N==null||N.writable)&&(h[S]=l(f[S],S,y,b,w))}}function u(h){switch(a.getTag(h)){case s.argumentsTag:case s.arrayTag:case s.arrayBufferTag:case s.dataViewTag:case s.booleanTag:case s.dateTag:case s.float32ArrayTag:case s.float64ArrayTag:case s.int8ArrayTag:case s.int16ArrayTag:case s.int32ArrayTag:case s.mapTag:case s.numberTag:case s.objectTag:case s.regexpTag:case s.setTag:case s.stringTag:case s.symbolTag:case s.uint8ArrayTag:case s.uint8ClampedArrayTag:case s.uint16ArrayTag:case s.uint32ArrayTag:return!0;default:return!1}}e.cloneDeepWith=o,e.cloneDeepWithImpl=l,e.copyProperties=c})(Zk)),Zk}var w8;function yde(){return w8||(w8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=wF();function a(s){return r.cloneDeepWithImpl(s,void 0,s,new Map,void 0)}e.cloneDeep=a})(Jk)),Jk}var j8;function bde(){return j8||(j8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=bF(),a=yde();function s(n){return n=a.cloneDeep(n),i=>r.isMatch(i,n)}e.matches=s})(Hk)),Hk}var r2={},a2={},s2={},_8;function vde(){return _8||(_8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=wF(),a=WS(),s=vF();function n(i,o){return r.cloneDeepWith(i,(l,c,u,h)=>{const f=o==null?void 0:o(l,c,u,h);if(f!==void 0)return f;if(typeof i=="object"){if(a.getTag(i)===s.objectTag&&typeof i.constructor!="function"){const y={};return h.set(i,y),r.copyProperties(y,i,u,h),y}switch(Object.prototype.toString.call(i)){case s.numberTag:case s.stringTag:case s.booleanTag:{const y=new i.constructor(i==null?void 0:i.valueOf());return r.copyProperties(y,i),y}case s.argumentsTag:{const y={};return r.copyProperties(y,i),y.length=i.length,y[Symbol.iterator]=i[Symbol.iterator],y}default:return}}})}e.cloneDeepWith=n})(s2)),s2}var k8;function wde(){return k8||(k8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=vde();function a(s){return r.cloneDeepWith(s)}e.cloneDeep=a})(a2)),a2}var n2={},i2={},N8;function jF(){return N8||(N8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=/^(?:0|[1-9]\d*)$/;function a(s,n=Number.MAX_SAFE_INTEGER){switch(typeof s){case"number":return Number.isInteger(s)&&s>=0&&s<n;case"symbol":return!1;case"string":return r.test(s)}}e.isIndex=a})(i2)),i2}var o2={},S8;function jde(){return S8||(S8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=WS();function a(s){return s!==null&&typeof s=="object"&&r.getTag(s)==="[object Arguments]"}e.isArguments=a})(o2)),o2}var C8;function _de(){return C8||(C8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=cF(),a=jF(),s=jde(),n=$S();function i(o,l){let c;if(Array.isArray(l)?c=l:typeof l=="string"&&r.isDeepKey(l)&&(o==null?void 0:o[l])==null?c=n.toPath(l):c=[l],c.length===0)return!1;let u=o;for(let h=0;h<c.length;h++){const f=c[h];if((u==null||!Object.hasOwn(u,f))&&!((Array.isArray(u)||s.isArguments(u))&&a.isIndex(f)&&f<u.length))return!1;u=u[f]}return!0}e.has=i})(n2)),n2}var T8;function kde(){return T8||(T8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=bF(),a=zS(),s=wde(),n=US(),i=_de();function o(l,c){switch(typeof l){case"object":{Object.is(l==null?void 0:l.valueOf(),-0)&&(l="-0");break}case"number":{l=a.toKey(l);break}}return c=s.cloneDeep(c),function(u){const h=n.get(u,l);return h===void 0?i.has(u,l):c===void 0?h===void 0:r.isMatch(h,c)}}e.matchesProperty=o})(r2)),r2}var E8;function Nde(){return E8||(E8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=pF(),a=pde(),s=bde(),n=kde();function i(o){if(o==null)return r.identity;switch(typeof o){case"function":return o;case"object":return Array.isArray(o)&&o.length===2?n.matchesProperty(o[0],o[1]):s.matches(o);case"string":case"symbol":case"number":return a.property(o)}}e.iteratee=i})(Bk)),Bk}var A8;function Sde(){return A8||(A8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=cde(),a=dde(),s=pF(),n=hde(),i=Nde();function o(l,c=s.identity){return n.isArrayLikeObject(l)?r.uniqBy(Array.from(l),a.ary(i.iteratee(c),1)):[]}e.uniqBy=o})(Rk)),Rk}var l2,O8;function Cde(){return O8||(O8=1,l2=Sde().uniqBy),l2}var Tde=Cde();const P8=tu(Tde);function _F(e,r,a){return r===!0?P8(e,a):typeof r=="function"?P8(e,r):e}var c2={exports:{}},d2={};var D8;function Ede(){if(D8)return d2;D8=1;var e=Ip(),r=y9();function a(u,h){return u===h&&(u!==0||1/u===1/h)||u!==u&&h!==h}var s=typeof Object.is=="function"?Object.is:a,n=r.useSyncExternalStore,i=e.useRef,o=e.useEffect,l=e.useMemo,c=e.useDebugValue;return d2.useSyncExternalStoreWithSelector=function(u,h,f,y,b){var w=i(null);if(w.current===null){var v={hasValue:!1,value:null};w.current=v}else v=w.current;w=l(function(){function S(P){if(!N){if(N=!0,C=P,P=y(P),b!==void 0&&v.hasValue){var E=v.value;if(b(E,P))return O=E}return O=P}if(E=O,s(C,P))return E;var R=y(P);return b!==void 0&&b(E,R)?(C=P,E):(C=P,O=R)}var N=!1,C,O,T=f===void 0?null:f;return[function(){return S(h())},T===null?void 0:function(){return S(T())}]},[h,f,y,b]);var k=n(u,w[0],w[1]);return o(function(){v.hasValue=!0,v.value=k},[k]),c(k),k},d2}var R8;function Ade(){return R8||(R8=1,c2.exports=Ede()),c2.exports}var Ode=Ade(),HS=p.createContext(null),Pde=e=>e,ss=()=>{var e=p.useContext(HS);return e?e.store.dispatch:Pde},uv=()=>{},Dde=()=>uv,Rde=(e,r)=>e===r;function kr(e){var r=p.useContext(HS),a=p.useMemo(()=>r?s=>{if(s!=null)return e(s)}:uv,[r,e]);return Ode.useSyncExternalStoreWithSelector(r?r.subscription.addNestedSub:Dde,r?r.store.getState:uv,r?r.store.getState:uv,a,Rde)}function Mde(e,r=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(r)}function Lde(e,r=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(r)}function Fde(e,r="expected all items to be functions, instead received the following types: "){if(!e.every(a=>typeof a=="function")){const a=e.map(s=>typeof s=="function"?`function ${s.name||"unnamed"}()`:typeof s).join(", ");throw new TypeError(`${r}[${a}]`)}}var M8=e=>Array.isArray(e)?e:[e];function Ide(e){const r=Array.isArray(e[0])?e[0]:e;return Fde(r,"createSelector expects all input-selectors to be functions, but received the following types: "),r}function zde(e,r){const a=[],{length:s}=e;for(let n=0;n<s;n++)a.push(e[n].apply(null,r));return a}var $de=class{constructor(e){this.value=e}deref(){return this.value}},Ude=typeof WeakRef!="undefined"?WeakRef:$de,Bde=0,L8=1;function Sb(){return{s:Bde,v:void 0,o:null,p:null}}function kF(e,r={}){let a=Sb();const{resultEqualityCheck:s}=r;let n,i=0;function o(){var f,y;let l=a;const{length:c}=arguments;for(let b=0,w=c;b<w;b++){const v=arguments[b];if(typeof v=="function"||typeof v=="object"&&v!==null){let k=l.o;k===null&&(l.o=k=new WeakMap);const S=k.get(v);S===void 0?(l=Sb(),k.set(v,l)):l=S}else{let k=l.p;k===null&&(l.p=k=new Map);const S=k.get(v);S===void 0?(l=Sb(),k.set(v,l)):l=S}}const u=l;let h;if(l.s===L8)h=l.v;else if(h=e.apply(null,arguments),i++,s){const b=(y=(f=n==null?void 0:n.deref)==null?void 0:f.call(n))!=null?y:n;b!=null&&s(b,h)&&(h=b,i!==0&&i--),n=typeof h=="object"&&h!==null||typeof h=="function"?new Ude(h):h}return u.s=L8,u.v=h,h}return o.clearCache=()=>{a=Sb(),o.resetResultsCount()},o.resultsCount=()=>i,o.resetResultsCount=()=>{i=0},o}function Wde(e,...r){const a=typeof e=="function"?{memoize:e,memoizeOptions:r}:e,s=(...n)=>{let i=0,o=0,l,c={},u=n.pop();typeof u=="object"&&(c=u,u=n.pop()),Mde(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const h=se(se({},a),c),{memoize:f,memoizeOptions:y=[],argsMemoize:b=kF,argsMemoizeOptions:w=[]}=h,v=M8(y),k=M8(w),S=Ide(n),N=f(function(){return i++,u.apply(null,arguments)},...v),C=b(function(){o++;const T=zde(S,arguments);return l=N.apply(null,T),l},...k);return Object.assign(C,{resultFunc:u,memoizedResultFunc:N,dependencies:S,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:f,argsMemoize:b})};return Object.assign(s,{withTypes:()=>s}),s}var bt=Wde(kF),Hde=Object.assign((e,r=bt)=>{Lde(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const a=Object.keys(e),s=a.map(i=>e[i]);return r(s,(...i)=>i.reduce((o,l,c)=>(o[a[c]]=l,o),{}))},{withTypes:()=>Hde}),u2={},m2={},h2={},F8;function qde(){return F8||(F8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function r(s){return typeof s=="symbol"?1:s===null?2:s===void 0?3:s!==s?4:0}const a=(s,n,i)=>{if(s!==n){const o=r(s),l=r(n);if(o===l&&o===0){if(s<n)return i==="desc"?1:-1;if(s>n)return i==="desc"?-1:1}return i==="desc"?l-o:o-l}return 0};e.compareValues=a})(h2)),h2}var p2={},g2={},I8;function NF(){return I8||(I8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function r(a){return typeof a=="symbol"||a instanceof Symbol}e.isSymbol=r})(g2)),g2}var z8;function Vde(){return z8||(z8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=NF(),a=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function n(i,o){return Array.isArray(i)?!1:typeof i=="number"||typeof i=="boolean"||i==null||r.isSymbol(i)?!0:typeof i=="string"&&(s.test(i)||!a.test(i))||o!=null&&Object.hasOwn(o,i)}e.isKey=n})(p2)),p2}var $8;function Gde(){return $8||($8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=qde(),a=Vde(),s=$S();function n(i,o,l,c){if(i==null)return[];l=c?void 0:l,Array.isArray(i)||(i=Object.values(i)),Array.isArray(o)||(o=o==null?[null]:[o]),o.length===0&&(o=[null]),Array.isArray(l)||(l=l==null?[]:[l]),l=l.map(b=>String(b));const u=(b,w)=>{let v=b;for(let k=0;k<w.length&&v!=null;++k)v=v[w[k]];return v},h=(b,w)=>w==null||b==null?w:typeof b=="object"&&"key"in b?Object.hasOwn(w,b.key)?w[b.key]:u(w,b.path):typeof b=="function"?b(w):Array.isArray(b)?u(w,b):typeof w=="object"?w[b]:w,f=o.map(b=>(Array.isArray(b)&&b.length===1&&(b=b[0]),b==null||typeof b=="function"||Array.isArray(b)||a.isKey(b)?b:{key:b,path:s.toPath(b)}));return i.map(b=>({original:b,criteria:f.map(w=>h(w,b))})).slice().sort((b,w)=>{for(let v=0;v<f.length;v++){const k=r.compareValues(b.criteria[v],w.criteria[v],l[v]);if(k!==0)return k}return 0}).map(b=>b.original)}e.orderBy=n})(m2)),m2}var f2={},U8;function Kde(){return U8||(U8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function r(a,s=1){const n=[],i=Math.floor(s),o=(l,c)=>{for(let u=0;u<l.length;u++){const h=l[u];Array.isArray(h)&&c<i?o(h,c+1):n.push(h)}};return o(a,0),n}e.flatten=r})(f2)),f2}var x2={},B8;function SF(){return B8||(B8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=jF(),a=gF(),s=fF(),n=yF();function i(o,l,c){return s.isObject(c)&&(typeof l=="number"&&a.isArrayLike(c)&&r.isIndex(l)&&l<c.length||typeof l=="string"&&l in c)?n.isEqualsSameValueZero(c[l],o):!1}e.isIterateeCall=i})(x2)),x2}var W8;function Yde(){return W8||(W8=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=Gde(),a=Kde(),s=SF();function n(i,...o){const l=o.length;return l>1&&s.isIterateeCall(i,o[0],o[1])?o=[]:l>2&&s.isIterateeCall(o[0],o[1],o[2])&&(o=[o[0]]),r.orderBy(i,a.flatten(o),["asc"])}e.sortBy=n})(u2)),u2}var y2,H8;function Jde(){return H8||(H8=1,y2=Yde().sortBy),y2}var Zde=Jde();const bw=tu(Zde);var CF=e=>e.legend.settings,Xde=e=>e.legend.size,Qde=e=>e.legend.payload,eue=bt([Qde,CF],(e,r)=>{var{itemSorter:a}=r,s=e.flat(1);return a?bw(s,a):s});function tue(){return kr(eue)}var Cb=1;function TF(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[r,a]=p.useState({height:0,left:0,top:0,width:0}),s=p.useCallback(n=>{if(n!=null){var i=n.getBoundingClientRect(),o={height:i.height,left:i.left,top:i.top,width:i.width};(Math.abs(o.height-r.height)>Cb||Math.abs(o.left-r.left)>Cb||Math.abs(o.top-r.top)>Cb||Math.abs(o.width-r.width)>Cb)&&a({height:o.height,left:o.left,top:o.top,width:o.width})}},[r.width,r.height,r.top,r.left,...e]);return[r,s]}function Yn(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var rue=typeof Symbol=="function"&&Symbol.observable||"@@observable",q8=rue,b2=()=>Math.random().toString(36).substring(7).split("").join("."),aue={INIT:`@@redux/INIT${b2()}`,REPLACE:`@@redux/REPLACE${b2()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${b2()}`},Qv=aue;function qS(e){if(typeof e!="object"||e===null)return!1;let r=e;for(;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(e)===r||Object.getPrototypeOf(e)===null}function EF(e,r,a){if(typeof e!="function")throw new Error(Yn(2));if(typeof r=="function"&&typeof a=="function"||typeof a=="function"&&typeof arguments[3]=="function")throw new Error(Yn(0));if(typeof r=="function"&&typeof a=="undefined"&&(a=r,r=void 0),typeof a!="undefined"){if(typeof a!="function")throw new Error(Yn(1));return a(EF)(e,r)}let s=e,n=r,i=new Map,o=i,l=0,c=!1;function u(){o===i&&(o=new Map,i.forEach((k,S)=>{o.set(S,k)}))}function h(){if(c)throw new Error(Yn(3));return n}function f(k){if(typeof k!="function")throw new Error(Yn(4));if(c)throw new Error(Yn(5));let S=!0;u();const N=l++;return o.set(N,k),function(){if(S){if(c)throw new Error(Yn(6));S=!1,u(),o.delete(N),i=null}}}function y(k){if(!qS(k))throw new Error(Yn(7));if(typeof k.type=="undefined")throw new Error(Yn(8));if(typeof k.type!="string")throw new Error(Yn(17));if(c)throw new Error(Yn(9));try{c=!0,n=s(n,k)}finally{c=!1}return(i=o).forEach(N=>{N()}),k}function b(k){if(typeof k!="function")throw new Error(Yn(10));s=k,y({type:Qv.REPLACE})}function w(){const k=f;return{subscribe(S){if(typeof S!="object"||S===null)throw new Error(Yn(11));function N(){const O=S;O.next&&O.next(h())}return N(),{unsubscribe:k(N)}},[q8](){return this}}}return y({type:Qv.INIT}),{dispatch:y,subscribe:f,getState:h,replaceReducer:b,[q8]:w}}function sue(e){Object.keys(e).forEach(r=>{const a=e[r];if(typeof a(void 0,{type:Qv.INIT})=="undefined")throw new Error(Yn(12));if(typeof a(void 0,{type:Qv.PROBE_UNKNOWN_ACTION()})=="undefined")throw new Error(Yn(13))})}function AF(e){const r=Object.keys(e),a={};for(let i=0;i<r.length;i++){const o=r[i];typeof e[o]=="function"&&(a[o]=e[o])}const s=Object.keys(a);let n;try{sue(a)}catch(i){n=i}return function(o={},l){if(n)throw n;let c=!1;const u={};for(let h=0;h<s.length;h++){const f=s[h],y=a[f],b=o[f],w=y(b,l);if(typeof w=="undefined")throw l&&l.type,new Error(Yn(14));u[f]=w,c=c||w!==b}return c=c||s.length!==Object.keys(o).length,c?u:o}}function e1(...e){return e.length===0?r=>r:e.length===1?e[0]:e.reduce((r,a)=>(...s)=>r(a(...s)))}function nue(...e){return r=>(a,s)=>{const n=r(a,s);let i=()=>{throw new Error(Yn(15))};const o={getState:n.getState,dispatch:(c,...u)=>i(c,...u)},l=e.map(c=>c(o));return i=e1(...l)(n.dispatch),je(se({},n),{dispatch:i})}}function OF(e){return qS(e)&&"type"in e&&typeof e.type=="string"}var PF=Symbol.for("immer-nothing"),V8=Symbol.for("immer-draftable"),Li=Symbol.for("immer-state");function Gl(e,...r){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var $o=Object,Sp=$o.getPrototypeOf,t1="constructor",vw="prototype",WN="configurable",r1="enumerable",mv="writable",sx="value",Zd=e=>!!e&&!!e[Li];function sc(e){var r;return e?DF(e)||jw(e)||!!e[V8]||!!((r=e[t1])!=null&&r[V8])||_w(e)||kw(e):!1}var iue=$o[vw][t1].toString(),G8=new WeakMap;function DF(e){if(!e||!VS(e))return!1;const r=Sp(e);if(r===null||r===$o[vw])return!0;const a=$o.hasOwnProperty.call(r,t1)&&r[t1];if(a===Object)return!0;if(!sp(a))return!1;let s=G8.get(a);return s===void 0&&(s=Function.toString.call(a),G8.set(a,s)),s===iue}function ww(e,r,a=!0){Ux(e)===0?(a?Reflect.ownKeys(e):$o.keys(e)).forEach(n=>{r(n,e[n],e)}):e.forEach((s,n)=>r(n,s,e))}function Ux(e){const r=e[Li];return r?r.type_:jw(e)?1:_w(e)?2:kw(e)?3:0}var K8=(e,r,a=Ux(e))=>a===2?e.has(r):$o[vw].hasOwnProperty.call(e,r),HN=(e,r,a=Ux(e))=>a===2?e.get(r):e[r],a1=(e,r,a,s=Ux(e))=>{s===2?e.set(r,a):s===3?e.add(a):e[r]=a};function oue(e,r){return e===r?e!==0||1/e===1/r:e!==e&&r!==r}var jw=Array.isArray,_w=e=>e instanceof Map,kw=e=>e instanceof Set,VS=e=>typeof e=="object",sp=e=>typeof e=="function",v2=e=>typeof e=="boolean";function lue(e){const r=+e;return Number.isInteger(r)&&String(r)===e}var Ad=e=>e.copy_||e.base_,GS=e=>e.modified_?e.copy_:e.base_;function qN(e,r){if(_w(e))return new Map(e);if(kw(e))return new Set(e);if(jw(e))return Array[vw].slice.call(e);const a=DF(e);if(r===!0||r==="class_only"&&!a){const s=$o.getOwnPropertyDescriptors(e);delete s[Li];let n=Reflect.ownKeys(s);for(let i=0;i<n.length;i++){const o=n[i],l=s[o];l[mv]===!1&&(l[mv]=!0,l[WN]=!0),(l.get||l.set)&&(s[o]={[WN]:!0,[mv]:!0,[r1]:l[r1],[sx]:e[o]})}return $o.create(Sp(e),s)}else{const s=Sp(e);if(s!==null&&a)return se({},e);const n=$o.create(s);return $o.assign(n,e)}}function KS(e,r=!1){return Nw(e)||Zd(e)||!sc(e)||(Ux(e)>1&&$o.defineProperties(e,{set:Tb,add:Tb,clear:Tb,delete:Tb}),$o.freeze(e),r&&ww(e,(a,s)=>{KS(s,!0)},!1)),e}function cue(){Gl(2)}var Tb={[sx]:cue};function Nw(e){return e===null||!VS(e)?!0:$o.isFrozen(e)}var s1="MapSet",VN="Patches",Y8="ArrayMethods",RF={};function Em(e){const r=RF[e];return r||Gl(0,e),r}var J8=e=>!!RF[e],nx,MF=()=>nx,due=(e,r)=>({drafts_:[],parent_:e,immer_:r,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:J8(s1)?Em(s1):void 0,arrayMethodsPlugin_:J8(Y8)?Em(Y8):void 0});function Z8(e,r){r&&(e.patchPlugin_=Em(VN),e.patches_=[],e.inversePatches_=[],e.patchListener_=r)}function GN(e){KN(e),e.drafts_.forEach(uue),e.drafts_=null}function KN(e){e===nx&&(nx=e.parent_)}var X8=e=>nx=due(nx,e);function uue(e){const r=e[Li];r.type_===0||r.type_===1?r.revoke_():r.revoked_=!0}function Q8(e,r){r.unfinalizedDrafts_=r.drafts_.length;const a=r.drafts_[0];if(e!==void 0&&e!==a){a[Li].modified_&&(GN(r),Gl(4)),sc(e)&&(e=eA(r,e));const{patchPlugin_:n}=r;n&&n.generateReplacementPatches_(a[Li].base_,e,r)}else e=eA(r,a);return mue(r,e,!0),GN(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),e!==PF?e:void 0}function eA(e,r){if(Nw(r))return r;const a=r[Li];if(!a)return n1(r,e.handledSet_,e);if(!Sw(a,e))return r;if(!a.modified_)return a.base_;if(!a.finalized_){const{callbacks_:s}=a;if(s)for(;s.length>0;)s.pop()(e);IF(a,e)}return a.copy_}function mue(e,r,a=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&KS(r,a)}function LF(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Sw=(e,r)=>e.scope_===r,hue=[];function FF(e,r,a,s){var l;const n=Ad(e),i=e.type_;if(s!==void 0&&HN(n,s,i)===r){a1(n,s,a,i);return}if(!e.draftLocations_){const c=e.draftLocations_=new Map;ww(n,(u,h)=>{if(Zd(h)){const f=c.get(h)||[];f.push(u),c.set(h,f)}})}const o=(l=e.draftLocations_.get(r))!=null?l:hue;for(const c of o)a1(n,c,a,i)}function pue(e,r,a){e.callbacks_.push(function(n){var l,c;const i=r;if(!i||!Sw(i,n))return;(l=n.mapSetPlugin_)==null||l.fixSetContents(i);const o=GS(i);FF(e,(c=i.draft_)!=null?c:i,o,a),IF(i,n)})}function IF(e,r){var s,n;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||((n=(s=e.assigned_)==null?void 0:s.size)!=null?n:0)>0)){const{patchPlugin_:i}=r;if(i){const o=i.getPath(e);o&&i.generatePatches_(e,o,r)}LF(e)}}function gue(e,r,a){const{scope_:s}=e;if(Zd(a)){const n=a[Li];Sw(n,s)&&n.callbacks_.push(function(){hv(e);const o=GS(n);FF(e,a,o,r)})}else sc(a)&&e.callbacks_.push(function(){var o;const i=Ad(e);e.type_===3?i.has(a)&&n1(a,s.handledSet_,s):HN(i,r,e.type_)===a&&s.drafts_.length>1&&((o=e.assigned_.get(r))!=null?o:!1)===!0&&e.copy_&&n1(HN(e.copy_,r,e.type_),s.handledSet_,s)})}function n1(e,r,a){return!a.immer_.autoFreeze_&&a.unfinalizedDrafts_<1||Zd(e)||r.has(e)||!sc(e)||Nw(e)||(r.add(e),ww(e,(s,n)=>{if(Zd(n)){const i=n[Li];if(Sw(i,a)){const o=GS(i);a1(e,s,o,e.type_),LF(i)}}else sc(n)&&n1(n,r,a)})),e}function fue(e,r){const a=jw(e),s={type_:a?1:0,scope_:r?r.scope_:MF(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:r,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let n=s,i=i1;a&&(n=[s],i=ix);const{revoke:o,proxy:l}=Proxy.revocable(n,i);return s.draft_=l,s.revoke_=o,[l,s]}var i1={get(e,r){if(r===Li)return e;let a=e.scope_.arrayMethodsPlugin_;const s=e.type_===1&&typeof r=="string";if(s&&a!=null&&a.isArrayOperationMethod(r))return a.createMethodInterceptor(e,r);const n=Ad(e);if(!K8(n,r,e.type_))return xue(e,n,r);const i=n[r];if(e.finalized_||!sc(i)||s&&e.operationMethod&&(a!=null&&a.isMutatingArrayMethod(e.operationMethod))&&lue(r))return i;if(i===w2(e.base_,r)){hv(e);const o=e.type_===1?+r:r,l=JN(e.scope_,i,e,o);return e.copy_[o]=l}return i},has(e,r){return r in Ad(e)},ownKeys(e){return Reflect.ownKeys(Ad(e))},set(e,r,a){const s=zF(Ad(e),r);if(s!=null&&s.set)return s.set.call(e.draft_,a),!0;if(!e.modified_){const n=w2(Ad(e),r),i=n==null?void 0:n[Li];if(i&&i.base_===a)return e.copy_[r]=a,e.assigned_.set(r,!1),!0;if(oue(a,n)&&(a!==void 0||K8(e.base_,r,e.type_)))return!0;hv(e),YN(e)}return e.copy_[r]===a&&(a!==void 0||r in e.copy_)||Number.isNaN(a)&&Number.isNaN(e.copy_[r])||(e.copy_[r]=a,e.assigned_.set(r,!0),gue(e,r,a)),!0},deleteProperty(e,r){return hv(e),w2(e.base_,r)!==void 0||r in e.base_?(e.assigned_.set(r,!1),YN(e)):e.assigned_.delete(r),e.copy_&&delete e.copy_[r],!0},getOwnPropertyDescriptor(e,r){const a=Ad(e),s=Reflect.getOwnPropertyDescriptor(a,r);return s&&{[mv]:!0,[WN]:e.type_!==1||r!=="length",[r1]:s[r1],[sx]:a[r]}},defineProperty(){Gl(11)},getPrototypeOf(e){return Sp(e.base_)},setPrototypeOf(){Gl(12)}},ix={};for(let e in i1){let r=i1[e];ix[e]=function(){const a=arguments;return a[0]=a[0][0],r.apply(this,a)}}ix.deleteProperty=function(e,r){return ix.set.call(this,e,r,void 0)};ix.set=function(e,r,a){return i1.set.call(this,e[0],r,a,e[0])};function w2(e,r){const a=e[Li];return(a?Ad(a):e)[r]}function xue(e,r,a){var n;const s=zF(r,a);return s?sx in s?s[sx]:(n=s.get)==null?void 0:n.call(e.draft_):void 0}function zF(e,r){if(!(r in e))return;let a=Sp(e);for(;a;){const s=Object.getOwnPropertyDescriptor(a,r);if(s)return s;a=Sp(a)}}function YN(e){e.modified_||(e.modified_=!0,e.parent_&&YN(e.parent_))}function hv(e){e.copy_||(e.assigned_=new Map,e.copy_=qN(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var yue=class{constructor(r){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(a,s,n)=>{if(sp(a)&&!sp(s)){const o=s;s=a;const l=this;return function(u=o,...h){return l.produce(u,f=>s.call(this,f,...h))}}sp(s)||Gl(6),n!==void 0&&!sp(n)&&Gl(7);let i;if(sc(a)){const o=X8(this),l=JN(o,a,void 0);let c=!0;try{i=s(l),c=!1}finally{c?GN(o):KN(o)}return Z8(o,n),Q8(i,o)}else if(!a||!VS(a)){if(i=s(a),i===void 0&&(i=a),i===PF&&(i=void 0),this.autoFreeze_&&KS(i,!0),n){const o=[],l=[];Em(VN).generateReplacementPatches_(a,i,{patches_:o,inversePatches_:l}),n(o,l)}return i}else Gl(1,a)},this.produceWithPatches=(a,s)=>{if(sp(a))return(l,...c)=>this.produceWithPatches(l,u=>a(u,...c));let n,i;return[this.produce(a,s,(l,c)=>{n=l,i=c}),n,i]},v2(r==null?void 0:r.autoFreeze)&&this.setAutoFreeze(r.autoFreeze),v2(r==null?void 0:r.useStrictShallowCopy)&&this.setUseStrictShallowCopy(r.useStrictShallowCopy),v2(r==null?void 0:r.useStrictIteration)&&this.setUseStrictIteration(r.useStrictIteration)}createDraft(r){sc(r)||Gl(8),Zd(r)&&(r=pl(r));const a=X8(this),s=JN(a,r,void 0);return s[Li].isManual_=!0,KN(a),s}finishDraft(r,a){const s=r&&r[Li];(!s||!s.isManual_)&&Gl(9);const{scope_:n}=s;return Z8(n,a),Q8(void 0,n)}setAutoFreeze(r){this.autoFreeze_=r}setUseStrictShallowCopy(r){this.useStrictShallowCopy_=r}setUseStrictIteration(r){this.useStrictIteration_=r}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(r,a){let s;for(s=a.length-1;s>=0;s--){const i=a[s];if(i.path.length===0&&i.op==="replace"){r=i.value;break}}s>-1&&(a=a.slice(s+1));const n=Em(VN).applyPatches_;return Zd(r)?n(r,a):this.produce(r,i=>n(i,a))}};function JN(e,r,a,s){var l,c;const[n,i]=_w(r)?Em(s1).proxyMap_(r,a):kw(r)?Em(s1).proxySet_(r,a):fue(r,a);return((l=a==null?void 0:a.scope_)!=null?l:MF()).drafts_.push(n),i.callbacks_=(c=a==null?void 0:a.callbacks_)!=null?c:[],i.key_=s,a&&s!==void 0?pue(a,i,s):i.callbacks_.push(function(h){var y;(y=h.mapSetPlugin_)==null||y.fixSetContents(i);const{patchPlugin_:f}=h;i.modified_&&f&&f.generatePatches_(i,[],h)}),n}function pl(e){return Zd(e)||Gl(10,e),$F(e)}function $F(e){if(!sc(e)||Nw(e))return e;const r=e[Li];let a,s=!0;if(r){if(!r.modified_)return r.base_;r.finalized_=!0,a=qN(e,r.scope_.immer_.useStrictShallowCopy_),s=r.scope_.immer_.shouldUseStrictIteration()}else a=qN(e,!0);return ww(a,(n,i)=>{a1(a,n,$F(i))},s),r&&(r.finalized_=!1),a}var bue=new yue,UF=bue.produce;function BF(e){return({dispatch:a,getState:s})=>n=>i=>typeof i=="function"?i(a,s,e):n(i)}var vue=BF(),wue=BF,jue=typeof window!="undefined"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?e1:e1.apply(null,arguments)};function Ho(e,r){function a(...s){if(r){let n=r(...s);if(!n)throw new Error(Uo(0));return se(se({type:e,payload:n.payload},"meta"in n&&{meta:n.meta}),"error"in n&&{error:n.error})}return{type:e,payload:s[0]}}return a.toString=()=>`${e}`,a.type=e,a.match=s=>OF(s)&&s.type===e,a}var WF=class Nf extends Array{constructor(...r){super(...r),Object.setPrototypeOf(this,Nf.prototype)}static get[Symbol.species](){return Nf}concat(...r){return super.concat.apply(this,r)}prepend(...r){return r.length===1&&Array.isArray(r[0])?new Nf(...r[0].concat(this)):new Nf(...r.concat(this))}};function tA(e){return sc(e)?UF(e,()=>{}):e}function Eb(e,r,a){return e.has(r)?e.get(r):e.set(r,a(r)).get(r)}function _ue(e){return typeof e=="boolean"}var kue=()=>function(r){const{thunk:a=!0,immutableCheck:s=!0,serializableCheck:n=!0,actionCreatorCheck:i=!0}=r!=null?r:{};let o=new WF;return a&&(_ue(a)?o.push(vue):o.push(wue(a.extraArgument))),o},HF="RTK_autoBatch",ys=()=>e=>({payload:e,meta:{[HF]:!0}}),rA=e=>r=>{setTimeout(r,e)},qF=(e={type:"raf"})=>r=>(...a)=>{const s=r(...a);let n=!0,i=!1,o=!1;const l=new Set,c=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window!="undefined"&&window.requestAnimationFrame?window.requestAnimationFrame:rA(10):e.type==="callback"?e.queueNotification:rA(e.timeout),u=()=>{o=!1,i&&(i=!1,l.forEach(h=>h()))};return Object.assign({},s,{subscribe(h){const f=()=>n&&h(),y=s.subscribe(f);return l.add(h),()=>{y(),l.delete(h)}},dispatch(h){var f;try{return n=!((f=h==null?void 0:h.meta)!=null&&f[HF]),i=!n,i&&(o||(o=!0,c(u))),s.dispatch(h)}finally{n=!0}}})},Nue=e=>function(a){const{autoBatch:s=!0}=a!=null?a:{};let n=new WF(e);return s&&n.push(qF(typeof s=="object"?s:void 0)),n};function Sue(e){const r=kue(),{reducer:a=void 0,middleware:s,devTools:n=!0,preloadedState:i=void 0,enhancers:o=void 0}=e||{};let l;if(typeof a=="function")l=a;else if(qS(a))l=AF(a);else throw new Error(Uo(1));let c;typeof s=="function"?c=s(r):c=r();let u=e1;n&&(u=jue(se({trace:!1},typeof n=="object"&&n)));const h=nue(...c),f=Nue(h);let y=typeof o=="function"?o(f):f();const b=u(...y);return EF(l,i,b)}function VF(e){const r={},a=[];let s;const n={addCase(i,o){const l=typeof i=="string"?i:i.type;if(!l)throw new Error(Uo(28));if(l in r)throw new Error(Uo(29));return r[l]=o,n},addAsyncThunk(i,o){return o.pending&&(r[i.pending.type]=o.pending),o.rejected&&(r[i.rejected.type]=o.rejected),o.fulfilled&&(r[i.fulfilled.type]=o.fulfilled),o.settled&&a.push({matcher:i.settled,reducer:o.settled}),n},addMatcher(i,o){return a.push({matcher:i,reducer:o}),n},addDefaultCase(i){return s=i,n}};return e(n),[r,a,s]}function Cue(e){return typeof e=="function"}function Tue(e,r){let[a,s,n]=VF(r),i;if(Cue(e))i=()=>tA(e());else{const l=tA(e);i=()=>l}function o(l=i(),c){let u=[a[c.type],...s.filter(({matcher:h})=>h(c)).map(({reducer:h})=>h)];return u.filter(h=>!!h).length===0&&(u=[n]),u.reduce((h,f)=>{if(f)if(Zd(h)){const b=f(h,c);return b===void 0?h:b}else{if(sc(h))return UF(h,y=>f(y,c));{const y=f(h,c);if(y===void 0){if(h===null)return h;throw Error("A case reducer on a non-draftable value must not return undefined")}return y}}return h},l)}return o.getInitialState=i,o}var Eue="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Aue=(e=21)=>{let r="",a=e;for(;a--;)r+=Eue[Math.random()*64|0];return r},Oue=Symbol.for("rtk-slice-createasyncthunk");function Pue(e,r){return`${e}/${r}`}function Due({creators:e}={}){var a;const r=(a=e==null?void 0:e.asyncThunk)==null?void 0:a[Oue];return function(n){const{name:i,reducerPath:o=i}=n;if(!i)throw new Error(Uo(11));const l=(typeof n.reducers=="function"?n.reducers(Mue()):n.reducers)||{},c=Object.keys(l),u={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},h={addCase(O,T){const P=typeof O=="string"?O:O.type;if(!P)throw new Error(Uo(12));if(P in u.sliceCaseReducersByType)throw new Error(Uo(13));return u.sliceCaseReducersByType[P]=T,h},addMatcher(O,T){return u.sliceMatchers.push({matcher:O,reducer:T}),h},exposeAction(O,T){return u.actionCreators[O]=T,h},exposeCaseReducer(O,T){return u.sliceCaseReducersByName[O]=T,h}};c.forEach(O=>{const T=l[O],P={reducerName:O,type:Pue(i,O),createNotation:typeof n.reducers=="function"};Fue(T)?zue(P,T,h,r):Lue(P,T,h)});function f(){const[O={},T=[],P=void 0]=typeof n.extraReducers=="function"?VF(n.extraReducers):[n.extraReducers],E=se(se({},O),u.sliceCaseReducersByType);return Tue(n.initialState,R=>{for(let z in E)R.addCase(z,E[z]);for(let z of u.sliceMatchers)R.addMatcher(z.matcher,z.reducer);for(let z of T)R.addMatcher(z.matcher,z.reducer);P&&R.addDefaultCase(P)})}const y=O=>O,b=new Map,w=new WeakMap;let v;function k(O,T){return v||(v=f()),v(O,T)}function S(){return v||(v=f()),v.getInitialState()}function N(O,T=!1){function P(R){let z=R[O];return typeof z=="undefined"&&T&&(z=Eb(w,P,S)),z}function E(R=y){const z=Eb(b,T,()=>new WeakMap);return Eb(z,R,()=>{var ae;const G={};for(const[ee,ne]of Object.entries((ae=n.selectors)!=null?ae:{}))G[ee]=Rue(ne,R,()=>Eb(w,R,S),T);return G})}return{reducerPath:O,getSelectors:E,get selectors(){return E(P)},selectSlice:P}}const C=je(se({name:i,reducer:k,actions:u.actionCreators,caseReducers:u.sliceCaseReducersByName,getInitialState:S},N(o)),{injectInto(O,E={}){var R=E,{reducerPath:T}=R,P=li(R,["reducerPath"]);const z=T!=null?T:o;return O.inject({reducerPath:z,reducer:k},P),se(se({},C),N(z,!0))}});return C}}function Rue(e,r,a,s){function n(i,...o){let l=r(i);return typeof l=="undefined"&&s&&(l=a()),e(l,...o)}return n.unwrapped=e,n}var wi=Due();function Mue(){function e(r,a){return se({_reducerDefinitionType:"asyncThunk",payloadCreator:r},a)}return e.withTypes=()=>e,{reducer(r){return Object.assign({[r.name](...a){return r(...a)}}[r.name],{_reducerDefinitionType:"reducer"})},preparedReducer(r,a){return{_reducerDefinitionType:"reducerWithPrepare",prepare:r,reducer:a}},asyncThunk:e}}function Lue({type:e,reducerName:r,createNotation:a},s,n){let i,o;if("reducer"in s){if(a&&!Iue(s))throw new Error(Uo(17));i=s.reducer,o=s.prepare}else i=s;n.addCase(e,i).exposeCaseReducer(r,i).exposeAction(r,o?Ho(e,o):Ho(e))}function Fue(e){return e._reducerDefinitionType==="asyncThunk"}function Iue(e){return e._reducerDefinitionType==="reducerWithPrepare"}function zue({type:e,reducerName:r},a,s,n){if(!n)throw new Error(Uo(18));const{payloadCreator:i,fulfilled:o,pending:l,rejected:c,settled:u,options:h}=a,f=n(e,i,h);s.exposeAction(r,f),o&&s.addCase(f.fulfilled,o),l&&s.addCase(f.pending,l),c&&s.addCase(f.rejected,c),u&&s.addMatcher(f.settled,u),s.exposeCaseReducer(r,{fulfilled:o||Ab,pending:l||Ab,rejected:c||Ab,settled:u||Ab})}function Ab(){}var $ue="task",GF="listener",KF="completed",YS="cancelled",Uue=`task-${YS}`,Bue=`task-${KF}`,ZN=`${GF}-${YS}`,Wue=`${GF}-${KF}`,Cw=class{constructor(e){$s(this,"name","TaskAbortError");$s(this,"message");this.code=e,this.message=`${$ue} ${YS} (reason: ${e})`}},JS=(e,r)=>{if(typeof e!="function")throw new TypeError(Uo(32))},o1=()=>{},YF=(e,r=o1)=>(e.catch(r),e),JF=(e,r)=>(e.addEventListener("abort",r,{once:!0}),()=>e.removeEventListener("abort",r)),hm=e=>{if(e.aborted)throw new Cw(e.reason)};function ZF(e,r){let a=o1;return new Promise((s,n)=>{const i=()=>n(new Cw(e.reason));if(e.aborted){i();return}a=JF(e,i),r.finally(()=>a()).then(s,n)}).finally(()=>{a=o1})}var Hue=(e,r)=>J(null,null,function*(){try{return yield Promise.resolve(),{status:"ok",value:yield e()}}catch(a){return{status:a instanceof Cw?"cancelled":"rejected",error:a}}finally{r==null||r()}}),l1=e=>r=>YF(ZF(e,r).then(a=>(hm(e),a))),XF=e=>{const r=l1(e);return a=>r(new Promise(s=>setTimeout(s,a)))},{assign:vp}=Object,aA={},Tw="listenerMiddleware",que=(e,r)=>{const a=s=>JF(e,()=>s.abort(e.reason));return(s,n)=>{JS(s);const i=new AbortController;a(i);const o=Hue(()=>J(null,null,function*(){hm(e),hm(i.signal);const l=yield s({pause:l1(i.signal),delay:XF(i.signal),signal:i.signal});return hm(i.signal),l}),()=>i.abort(Bue));return n!=null&&n.autoJoin&&r.push(o.catch(o1)),{result:l1(e)(o),cancel(){i.abort(Uue)}}}},Vue=(e,r)=>{const a=(s,n)=>J(null,null,function*(){hm(r);let i=()=>{};const l=[new Promise((c,u)=>{let h=e({predicate:s,effect:(f,y)=>{y.unsubscribe(),c([f,y.getState(),y.getOriginalState()])}});i=()=>{h(),u()}})];n!=null&&l.push(new Promise(c=>setTimeout(c,n,null)));try{const c=yield ZF(r,Promise.race(l));return hm(r),c}finally{i()}});return(s,n)=>YF(a(s,n))},QF=e=>{let{type:r,actionCreator:a,matcher:s,predicate:n,effect:i}=e;if(r)n=Ho(r).match;else if(a)r=a.type,n=a.match;else if(s)n=s;else if(!n)throw new Error(Uo(21));return JS(i),{predicate:n,type:r,effect:i}},eI=vp(e=>{const{type:r,predicate:a,effect:s}=QF(e);return{id:Aue(),effect:s,type:r,predicate:a,pending:new Set,unsubscribe:()=>{throw new Error(Uo(22))}}},{withTypes:()=>eI}),sA=(e,r)=>{const{type:a,effect:s,predicate:n}=QF(r);return Array.from(e.values()).find(i=>(typeof a=="string"?i.type===a:i.predicate===n)&&i.effect===s)},XN=e=>{e.pending.forEach(r=>{r.abort(ZN)})},Gue=(e,r)=>()=>{for(const a of r.keys())XN(a);e.clear()},nA=(e,r,a)=>{try{e(r,a)}catch(s){setTimeout(()=>{throw s},0)}},tI=vp(Ho(`${Tw}/add`),{withTypes:()=>tI}),Kue=Ho(`${Tw}/removeAll`),rI=vp(Ho(`${Tw}/remove`),{withTypes:()=>rI}),Yue=(...e)=>{console.error(`${Tw}/error`,...e)},Bx=(e={})=>{const r=new Map,a=new Map,s=b=>{var v;const w=(v=a.get(b))!=null?v:0;a.set(b,w+1)},n=b=>{var v;const w=(v=a.get(b))!=null?v:1;w===1?a.delete(b):a.set(b,w-1)},{extra:i,onError:o=Yue}=e;JS(o);const l=b=>(b.unsubscribe=()=>r.delete(b.id),r.set(b.id,b),w=>{b.unsubscribe(),w!=null&&w.cancelActive&&XN(b)}),c=b=>{var v;const w=(v=sA(r,b))!=null?v:eI(b);return l(w)};vp(c,{withTypes:()=>c});const u=b=>{const w=sA(r,b);return w&&(w.unsubscribe(),b.cancelActive&&XN(w)),!!w};vp(u,{withTypes:()=>u});const h=(b,w,v,k)=>J(null,null,function*(){const S=new AbortController,N=Vue(c,S.signal),C=[];try{b.pending.add(S),s(b),yield Promise.resolve(b.effect(w,vp({},v,{getOriginalState:k,condition:(O,T)=>N(O,T).then(Boolean),take:N,delay:XF(S.signal),pause:l1(S.signal),extra:i,signal:S.signal,fork:que(S.signal,C),unsubscribe:b.unsubscribe,subscribe:()=>{r.set(b.id,b)},cancelActiveListeners:()=>{b.pending.forEach((O,T,P)=>{O!==S&&(O.abort(ZN),P.delete(O))})},cancel:()=>{S.abort(ZN),b.pending.delete(S)},throwIfCancelled:()=>{hm(S.signal)}})))}catch(O){O instanceof Cw||nA(o,O,{raisedBy:"effect"})}finally{yield Promise.all(C),S.abort(Wue),n(b),b.pending.delete(S)}}),f=Gue(r,a);return{middleware:b=>w=>v=>{if(!OF(v))return w(v);if(tI.match(v))return c(v.payload);if(Kue.match(v)){f();return}if(rI.match(v))return u(v.payload);let k=b.getState();const S=()=>{if(k===aA)throw new Error(Uo(23));return k};let N;try{if(N=w(v),r.size>0){const C=b.getState(),O=Array.from(r.values());for(const T of O){let P=!1;try{P=T.predicate(v,C,k)}catch(E){P=!1,nA(o,E,{raisedBy:"predicate"})}P&&h(T,v,b,S)}}}finally{k=aA}return N},startListening:c,stopListening:u,clearListeners:f}};function Uo(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var Jue={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},aI=wi({name:"chartLayout",initialState:Jue,reducers:{setLayout(e,r){e.layoutType=r.payload},setChartSize(e,r){e.width=r.payload.width,e.height=r.payload.height},setMargin(e,r){var a,s,n,i;e.margin.top=(a=r.payload.top)!==null&&a!==void 0?a:0,e.margin.right=(s=r.payload.right)!==null&&s!==void 0?s:0,e.margin.bottom=(n=r.payload.bottom)!==null&&n!==void 0?n:0,e.margin.left=(i=r.payload.left)!==null&&i!==void 0?i:0},setScale(e,r){e.scale=r.payload}}}),{setMargin:Zue,setLayout:Xue,setChartSize:Que,setScale:e0e}=aI.actions,t0e=aI.reducer;function sI(e,r,a){return Array.isArray(e)&&e&&r+a!==0?e.slice(r,a+1):e}function ja(e){return Number.isFinite(e)}function Bc(e){return typeof e=="number"&&e>0&&Number.isFinite(e)}function iA(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function mp(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?iA(Object(a),!0).forEach(function(s){r0e(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):iA(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function r0e(e,r,a){return(r=a0e(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function a0e(e){var r=s0e(e,"string");return typeof r=="symbol"?r:r+""}function s0e(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function ls(e,r,a){return _n(e)||_n(r)?a:Uc(r)?Cm(e,r,a):typeof r=="function"?r(e):a}var n0e=(e,r,a)=>{if(r&&a){var{width:s,height:n}=a,{align:i,verticalAlign:o,layout:l}=r;if((l==="vertical"||l==="horizontal"&&o==="middle")&&i!=="center"&&_r(e[i]))return mp(mp({},e),{},{[i]:e[i]+(s||0)});if((l==="horizontal"||l==="vertical"&&i==="center")&&o!=="middle"&&_r(e[o]))return mp(mp({},e),{},{[o]:e[o]+(n||0)})}return e},i0=(e,r)=>e==="horizontal"&&r==="xAxis"||e==="vertical"&&r==="yAxis"||e==="centric"&&r==="angleAxis"||e==="radial"&&r==="radiusAxis",nI=(e,r,a,s)=>{if(s)return e.map(l=>l.coordinate);var n,i,o=e.map(l=>(l.coordinate===r&&(n=!0),l.coordinate===a&&(i=!0),l.coordinate));return n||o.push(r),i||o.push(a),o},iI=(e,r,a)=>{if(!e)return null;var{duplicateDomain:s,type:n,range:i,scale:o,realScaleType:l,isCategorical:c,categoricalDomain:u,tickCount:h,ticks:f,niceTicks:y,axisType:b}=e;if(!o)return null;var w=l==="scaleBand"&&o.bandwidth?o.bandwidth()/2:2,v=n==="category"&&o.bandwidth?o.bandwidth()/w:0;if(v=b==="angleAxis"&&i&&i.length>=2?Ln(i[0]-i[1])*2*v:v,f||y){var k=(f||y||[]).map((S,N)=>{var C=s?s.indexOf(S):S,O=o.map(C);return ja(O)?{coordinate:O+v,value:S,offset:v,index:N}:null}).filter(so);return k}return c&&u?u.map((S,N)=>{var C=o.map(S);return ja(C)?{coordinate:C+v,value:S,index:N,offset:v}:null}).filter(so):o.ticks&&h!=null?o.ticks(h).map((S,N)=>{var C=o.map(S);return ja(C)?{coordinate:C+v,value:S,index:N,offset:v}:null}).filter(so):o.domain().map((S,N)=>{var C=o.map(S);return ja(C)?{coordinate:C+v,value:s?s[S]:S,index:N,offset:v}:null}).filter(so)},i0e=(e,r)=>{if(!r||r.length!==2||!_r(r[0])||!_r(r[1]))return e;var a=Math.min(r[0],r[1]),s=Math.max(r[0],r[1]),n=[e[0],e[1]];return(!_r(e[0])||e[0]<a)&&(n[0]=a),(!_r(e[1])||e[1]>s)&&(n[1]=s),n[0]>s&&(n[0]=s),n[1]<a&&(n[1]=a),n},o0e=e=>{var r,a=e.length;if(!(a<=0)){var s=(r=e[0])===null||r===void 0?void 0:r.length;if(!(s==null||s<=0))for(var n=0;n<s;++n)for(var i=0,o=0,l=0;l<a;++l){var c=e[l],u=c==null?void 0:c[n];if(u!=null){var h=u[1],f=u[0],y=$c(h)?f:h;y>=0?(u[0]=i,i+=y,u[1]=i):(u[0]=o,o+=y,u[1]=o)}}}},l0e=e=>{var r,a=e.length;if(!(a<=0)){var s=(r=e[0])===null||r===void 0?void 0:r.length;if(!(s==null||s<=0))for(var n=0;n<s;++n)for(var i=0,o=0;o<a;++o){var l=e[o],c=l==null?void 0:l[n];if(c!=null){var u=$c(c[1])?c[0]:c[1];u>=0?(c[0]=i,i+=u,c[1]=i):(c[0]=0,c[1]=0)}}}},c0e={sign:o0e,expand:Ece,none:Sm,silhouette:Ace,wiggle:Oce,positive:l0e},d0e=(e,r,a)=>{var s,n=(s=c0e[a])!==null&&s!==void 0?s:Sm,i=Tce().keys(r).value((l,c)=>Number(ls(l,c,0))).order(UN).offset(n),o=i(e);return o.forEach((l,c)=>{l.forEach((u,h)=>{var f=ls(e[h],r[c],0);Array.isArray(f)&&f.length===2&&_r(f[0])&&_r(f[1])&&(u[0]=f[0],u[1]=f[1])})}),o};function u0e(e){return e==null?void 0:String(e)}var oA=e=>{var{axis:r,ticks:a,offset:s,bandSize:n,entry:i,index:o}=e;if(r.type==="category")return a[o]?a[o].coordinate+s:null;var l=ls(i,r.dataKey,r.scale.domain()[o]);if(_n(l))return null;var c=r.scale.map(l);return _r(c)?c-n/2+s:null},m0e=e=>{var{numericAxis:r}=e,a=r.scale.domain();if(r.type==="number"){var s=Math.min(a[0],a[1]),n=Math.max(a[0],a[1]);return s<=0&&n>=0?0:n<0?n:s}return a[0]},h0e=e=>{var r=e.flat(2).filter(_r);return[Math.min(...r),Math.max(...r)]},p0e=e=>[e[0]===1/0?0:e[0],e[1]===-1/0?0:e[1]],g0e=(e,r,a)=>{if(e!=null)return p0e(Object.keys(e).reduce((s,n)=>{var i=e[n];if(!i)return s;var{stackedData:o}=i,l=o.reduce((c,u)=>{var h=sI(u,r,a),f=h0e(h);return!ja(f[0])||!ja(f[1])?c:[Math.min(c[0],f[0]),Math.max(c[1],f[1])]},[1/0,-1/0]);return[Math.min(l[0],s[0]),Math.max(l[1],s[1])]},[1/0,-1/0]))},lA=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,cA=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,c1=(e,r,a)=>{if(e&&e.scale&&e.scale.bandwidth){var s=e.scale.bandwidth();if(!a||s>0)return s}if(e&&r&&r.length>=2){for(var n=bw(r,h=>h.coordinate),i=1/0,o=1,l=n.length;o<l;o++){var c=n[o],u=n[o-1];i=Math.min(((c==null?void 0:c.coordinate)||0)-((u==null?void 0:u.coordinate)||0),i)}return i===1/0?0:i}return a?void 0:0};function dA(e){var{tooltipEntrySettings:r,dataKey:a,payload:s,value:n,name:i}=e;return mp(mp({},r),{},{dataKey:a,payload:s,value:n,name:i})}function Ew(e,r){if(e)return String(e);if(typeof r=="string")return r}var f0e=(e,r)=>{if(r==="horizontal")return e.relativeX;if(r==="vertical")return e.relativeY},x0e=(e,r)=>r==="centric"?e.angle:e.radius,su=e=>e.layout.width,nu=e=>e.layout.height,y0e=e=>e.layout.scale,oI=e=>e.layout.margin,Aw=bt(e=>e.cartesianAxis.xAxis,e=>Object.values(e)),Ow=bt(e=>e.cartesianAxis.yAxis,e=>Object.values(e)),lI="data-recharts-item-index",cI="data-recharts-item-id",Wx=60;function uA(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function Ob(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?uA(Object(a),!0).forEach(function(s){b0e(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):uA(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function b0e(e,r,a){return(r=v0e(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function v0e(e){var r=w0e(e,"string");return typeof r=="symbol"?r:r+""}function w0e(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var j0e=e=>e.brush.height;function _0e(e){var r=Ow(e);return r.reduce((a,s)=>{if(s.orientation==="left"&&!s.mirror&&!s.hide){var n=typeof s.width=="number"?s.width:Wx;return a+n}return a},0)}function k0e(e){var r=Ow(e);return r.reduce((a,s)=>{if(s.orientation==="right"&&!s.mirror&&!s.hide){var n=typeof s.width=="number"?s.width:Wx;return a+n}return a},0)}function N0e(e){var r=Aw(e);return r.reduce((a,s)=>s.orientation==="top"&&!s.mirror&&!s.hide?a+s.height:a,0)}function S0e(e){var r=Aw(e);return r.reduce((a,s)=>s.orientation==="bottom"&&!s.mirror&&!s.hide?a+s.height:a,0)}var kn=bt([su,nu,oI,j0e,_0e,k0e,N0e,S0e,CF,Xde],(e,r,a,s,n,i,o,l,c,u)=>{var h={left:(a.left||0)+n,right:(a.right||0)+i},f={top:(a.top||0)+o,bottom:(a.bottom||0)+l},y=Ob(Ob({},f),h),b=y.bottom;y.bottom+=s,y=n0e(y,c,u);var w=e-y.left-y.right,v=r-y.top-y.bottom;return Ob(Ob({brushBottom:b},y),{},{width:Math.max(w,0),height:Math.max(v,0)})}),C0e=bt(kn,e=>({x:e.left,y:e.top,width:e.width,height:e.height})),ZS=bt(su,nu,(e,r)=>({x:0,y:0,width:e,height:r})),T0e=p.createContext(null),ho=()=>p.useContext(T0e)!=null,Pw=e=>e.brush,Dw=bt([Pw,kn,oI],(e,r,a)=>({height:e.height,x:_r(e.x)?e.x:r.left,y:_r(e.y)?e.y:r.top+r.height+r.brushBottom-((a==null?void 0:a.bottom)||0),width:_r(e.width)?e.width:r.width})),j2={},_2={},k2={},mA;function E0e(){return mA||(mA=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function r(a,s,{signal:n,edges:i}={}){let o,l=null;const c=i!=null&&i.includes("leading"),u=i==null||i.includes("trailing"),h=()=>{l!==null&&(a.apply(o,l),o=void 0,l=null)},f=()=>{u&&h(),v()};let y=null;const b=()=>{y!=null&&clearTimeout(y),y=setTimeout(()=>{y=null,f()},s)},w=()=>{y!==null&&(clearTimeout(y),y=null)},v=()=>{w(),o=void 0,l=null},k=()=>{h()},S=function(...N){if(n!=null&&n.aborted)return;o=this,l=N;const C=y==null;b(),c&&C&&h()};return S.schedule=b,S.cancel=v,S.flush=k,n==null||n.addEventListener("abort",v,{once:!0}),S}e.debounce=r})(k2)),k2}var hA;function A0e(){return hA||(hA=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=E0e();function a(s,n=0,i={}){typeof i!="object"&&(i={});const{leading:o=!1,trailing:l=!0,maxWait:c}=i,u=Array(2);o&&(u[0]="leading"),l&&(u[1]="trailing");let h,f=null;const y=r.debounce(function(...v){h=s.apply(this,v),f=null},n,{edges:u}),b=function(...v){return c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(h=s.apply(this,v),f=Date.now(),y.cancel(),y.schedule(),h):(y.apply(this,v),h)},w=()=>(y.flush(),h);return b.cancel=y.cancel,b.flush=w,b}e.debounce=a})(_2)),_2}var pA;function O0e(){return pA||(pA=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=A0e();function a(s,n=0,i={}){const{leading:o=!0,trailing:l=!0}=i;return r.debounce(s,n,{leading:o,maxWait:n,trailing:l})}e.throttle=a})(j2)),j2}var N2,gA;function P0e(){return gA||(gA=1,N2=O0e().throttle),N2}var D0e=P0e();const R0e=tu(D0e);var d1=function(r,a){for(var s=arguments.length,n=new Array(s>2?s-2:0),i=2;i<s;i++)n[i-2]=arguments[i];if(typeof console!="undefined"&&console.warn&&(a===void 0&&console.warn("LogUtils requires an error message argument"),!r))if(a===void 0)console.warn("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var o=0;console.warn(a.replace(/%s/g,()=>n[o++]))}},Rc={width:"100%",height:"100%",debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},dI=(e,r,a)=>{var{width:s=Rc.width,height:n=Rc.height,aspect:i,maxHeight:o}=a,l=Tm(s)?e:Number(s),c=Tm(n)?r:Number(n);return i&&i>0&&(l?c=l/i:c&&(l=c*i),o&&c!=null&&c>o&&(c=o)),{calculatedWidth:l,calculatedHeight:c}},M0e={width:0,height:0,overflow:"visible"},L0e={width:0,overflowX:"visible"},F0e={height:0,overflowY:"visible"},I0e={},z0e=e=>{var{width:r,height:a}=e,s=Tm(r),n=Tm(a);return s&&n?M0e:s?L0e:n?F0e:I0e};function $0e(e){var{width:r,height:a,aspect:s}=e,n=r,i=a;return n===void 0&&i===void 0?(n=Rc.width,i=Rc.height):n===void 0?n=s&&s>0?void 0:Rc.width:i===void 0&&(i=s&&s>0?void 0:Rc.height),{width:n,height:i}}function QN(){return QN=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},QN.apply(null,arguments)}function fA(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function xA(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?fA(Object(a),!0).forEach(function(s){U0e(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):fA(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function U0e(e,r,a){return(r=B0e(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function B0e(e){var r=W0e(e,"string");return typeof r=="symbol"?r:r+""}function W0e(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var uI=p.createContext(Rc.initialDimension);function H0e(e){return Bc(e.width)&&Bc(e.height)}function mI(e){var{children:r,width:a,height:s}=e,n=p.useMemo(()=>({width:a,height:s}),[a,s]);return H0e(n)?p.createElement(uI.Provider,{value:n},r):null}var XS=()=>p.useContext(uI),q0e=p.forwardRef((e,r)=>{var{aspect:a,initialDimension:s=Rc.initialDimension,width:n,height:i,minWidth:o=Rc.minWidth,minHeight:l,maxHeight:c,children:u,debounce:h=Rc.debounce,id:f,className:y,onResize:b,style:w={}}=e,v=p.useRef(null),k=p.useRef();k.current=b,p.useImperativeHandle(r,()=>v.current);var[S,N]=p.useState({containerWidth:s.width,containerHeight:s.height}),C=p.useCallback((R,z)=>{N(G=>{var ae=Math.round(R),ee=Math.round(z);return G.containerWidth===ae&&G.containerHeight===ee?G:{containerWidth:ae,containerHeight:ee}})},[]);p.useEffect(()=>{if(v.current==null||typeof ResizeObserver=="undefined")return Yp;var R=ee=>{var ne,te=ee[0];if(te!=null){var{width:Y,height:q}=te.contentRect;C(Y,q),(ne=k.current)===null||ne===void 0||ne.call(k,Y,q)}};h>0&&(R=R0e(R,h,{trailing:!0,leading:!1}));var z=new ResizeObserver(R),{width:G,height:ae}=v.current.getBoundingClientRect();return C(G,ae),z.observe(v.current),()=>{z.disconnect()}},[C,h]);var{containerWidth:O,containerHeight:T}=S;d1(!a||a>0,"The aspect(%s) must be greater than zero.",a);var{calculatedWidth:P,calculatedHeight:E}=dI(O,T,{width:n,height:i,aspect:a,maxHeight:c});return d1(P!=null&&P>0||E!=null&&E>0,`The width(%s) and height(%s) of chart should be greater than 0,
|
||
please check the style of container, or the props width(%s) and height(%s),
|
||
or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
|
||
height and width.`,P,E,n,i,o,l,a),p.createElement("div",{id:f?"".concat(f):void 0,className:va("recharts-responsive-container",y),style:xA(xA({},w),{},{width:n,height:i,minWidth:o,minHeight:l,maxHeight:c}),ref:v},p.createElement("div",{style:z0e({width:n,height:i})},p.createElement(mI,{width:P,height:E},u)))}),Pb=p.forwardRef((e,r)=>{var a=XS();if(Bc(a.width)&&Bc(a.height))return e.children;var{width:s,height:n}=$0e({width:e.width,height:e.height,aspect:e.aspect}),{calculatedWidth:i,calculatedHeight:o}=dI(void 0,void 0,{width:s,height:n,aspect:e.aspect,maxHeight:e.maxHeight});return _r(i)&&_r(o)?p.createElement(mI,{width:i,height:o},e.children):p.createElement(q0e,QN({},e,{width:s,height:n,ref:r}))});function QS(e){if(e)return{x:e.x,y:e.y,upperWidth:"upperWidth"in e?e.upperWidth:e.width,lowerWidth:"lowerWidth"in e?e.lowerWidth:e.width,width:e.width,height:e.height}}var Rw=()=>{var e,r=ho(),a=kr(C0e),s=kr(Dw),n=(e=kr(Pw))===null||e===void 0?void 0:e.padding;return!r||!s||!n?a:{width:s.width-n.left-n.right,height:s.height-n.top-n.bottom,x:n.left,y:n.top}},V0e={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},hI=()=>{var e;return(e=kr(kn))!==null&&e!==void 0?e:V0e},e3=()=>kr(su),t3=()=>kr(nu),G0e=()=>kr(e=>e.layout.margin),Ua=e=>e.layout.layoutType,Jp=()=>kr(Ua),pI=()=>{var e=Jp();if(e==="horizontal"||e==="vertical")return e},gI=e=>{var r=e.layout.layoutType;if(r==="centric"||r==="radial")return r},K0e=()=>{var e=Jp();return e!==void 0},Hx=e=>{var r=ss(),a=ho(),{width:s,height:n}=e,i=XS(),o=s,l=n;return i&&(o=i.width>0?i.width:s,l=i.height>0?i.height:n),p.useEffect(()=>{!a&&Bc(o)&&Bc(l)&&r(Que({width:o,height:l}))},[r,a,o,l]),null},fI=Symbol.for("immer-nothing"),yA=Symbol.for("immer-draftable"),qo=Symbol.for("immer-state");function Kl(e,...r){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ox=Object.getPrototypeOf;function Cp(e){return!!e&&!!e[qo]}function Am(e){var r;return e?xI(e)||Array.isArray(e)||!!e[yA]||!!((r=e.constructor)!=null&&r[yA])||qx(e)||Lw(e):!1}var Y0e=Object.prototype.constructor.toString(),bA=new WeakMap;function xI(e){if(!e||typeof e!="object")return!1;const r=Object.getPrototypeOf(e);if(r===null||r===Object.prototype)return!0;const a=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;if(a===Object)return!0;if(typeof a!="function")return!1;let s=bA.get(a);return s===void 0&&(s=Function.toString.call(a),bA.set(a,s)),s===Y0e}function u1(e,r,a=!0){Mw(e)===0?(a?Reflect.ownKeys(e):Object.keys(e)).forEach(n=>{r(n,e[n],e)}):e.forEach((s,n)=>r(n,s,e))}function Mw(e){const r=e[qo];return r?r.type_:Array.isArray(e)?1:qx(e)?2:Lw(e)?3:0}function e4(e,r){return Mw(e)===2?e.has(r):Object.prototype.hasOwnProperty.call(e,r)}function yI(e,r,a){const s=Mw(e);s===2?e.set(r,a):s===3?e.add(a):e[r]=a}function J0e(e,r){return e===r?e!==0||1/e===1/r:e!==e&&r!==r}function qx(e){return e instanceof Map}function Lw(e){return e instanceof Set}function G0(e){return e.copy_||e.base_}function t4(e,r){if(qx(e))return new Map(e);if(Lw(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const a=xI(e);if(r===!0||r==="class_only"&&!a){const s=Object.getOwnPropertyDescriptors(e);delete s[qo];let n=Reflect.ownKeys(s);for(let i=0;i<n.length;i++){const o=n[i],l=s[o];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(s[o]={configurable:!0,writable:!0,enumerable:l.enumerable,value:e[o]})}return Object.create(ox(e),s)}else{const s=ox(e);if(s!==null&&a)return se({},e);const n=Object.create(s);return Object.assign(n,e)}}function r3(e,r=!1){return Fw(e)||Cp(e)||!Am(e)||(Mw(e)>1&&Object.defineProperties(e,{set:Db,add:Db,clear:Db,delete:Db}),Object.freeze(e),r&&Object.values(e).forEach(a=>r3(a,!0))),e}function Z0e(){Kl(2)}var Db={value:Z0e};function Fw(e){return e===null||typeof e!="object"?!0:Object.isFrozen(e)}var X0e={};function Om(e){const r=X0e[e];return r||Kl(0,e),r}var lx;function bI(){return lx}function Q0e(e,r){return{drafts_:[],parent_:e,immer_:r,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function vA(e,r){r&&(Om("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=r)}function r4(e){a4(e),e.drafts_.forEach(eme),e.drafts_=null}function a4(e){e===lx&&(lx=e.parent_)}function wA(e){return lx=Q0e(lx,e)}function eme(e){const r=e[qo];r.type_===0||r.type_===1?r.revoke_():r.revoked_=!0}function jA(e,r){r.unfinalizedDrafts_=r.drafts_.length;const a=r.drafts_[0];return e!==void 0&&e!==a?(a[qo].modified_&&(r4(r),Kl(4)),Am(e)&&(e=m1(r,e),r.parent_||h1(r,e)),r.patches_&&Om("Patches").generateReplacementPatches_(a[qo].base_,e,r.patches_,r.inversePatches_)):e=m1(r,a,[]),r4(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),e!==fI?e:void 0}function m1(e,r,a){if(Fw(r))return r;const s=e.immer_.shouldUseStrictIteration(),n=r[qo];if(!n)return u1(r,(i,o)=>_A(e,n,r,i,o,a),s),r;if(n.scope_!==e)return r;if(!n.modified_)return h1(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;const i=n.copy_;let o=i,l=!1;n.type_===3&&(o=new Set(i),i.clear(),l=!0),u1(o,(c,u)=>_A(e,n,i,c,u,a,l),s),h1(e,i,!1),a&&e.patches_&&Om("Patches").generatePatches_(n,a,e.patches_,e.inversePatches_)}return n.copy_}function _A(e,r,a,s,n,i,o){if(n==null||typeof n!="object"&&!o)return;const l=Fw(n);if(!(l&&!o)){if(Cp(n)){const c=i&&r&&r.type_!==3&&!e4(r.assigned_,s)?i.concat(s):void 0,u=m1(e,n,c);if(yI(a,s,u),Cp(u))e.canAutoFreeze_=!1;else return}else o&&a.add(n);if(Am(n)&&!l){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||r&&r.base_&&r.base_[s]===n&&l)return;m1(e,n),(!r||!r.scope_.parent_)&&typeof s!="symbol"&&(qx(a)?a.has(s):Object.prototype.propertyIsEnumerable.call(a,s))&&h1(e,n)}}}function h1(e,r,a=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&r3(r,a)}function tme(e,r){const a=Array.isArray(e),s={type_:a?1:0,scope_:r?r.scope_:bI(),modified_:!1,finalized_:!1,assigned_:{},parent_:r,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let n=s,i=a3;a&&(n=[s],i=cx);const{revoke:o,proxy:l}=Proxy.revocable(n,i);return s.draft_=l,s.revoke_=o,l}var a3={get(e,r){if(r===qo)return e;const a=G0(e);if(!e4(a,r))return rme(e,a,r);const s=a[r];return e.finalized_||!Am(s)?s:s===S2(e.base_,r)?(C2(e),e.copy_[r]=n4(s,e)):s},has(e,r){return r in G0(e)},ownKeys(e){return Reflect.ownKeys(G0(e))},set(e,r,a){const s=vI(G0(e),r);if(s!=null&&s.set)return s.set.call(e.draft_,a),!0;if(!e.modified_){const n=S2(G0(e),r),i=n==null?void 0:n[qo];if(i&&i.base_===a)return e.copy_[r]=a,e.assigned_[r]=!1,!0;if(J0e(a,n)&&(a!==void 0||e4(e.base_,r)))return!0;C2(e),s4(e)}return e.copy_[r]===a&&(a!==void 0||r in e.copy_)||Number.isNaN(a)&&Number.isNaN(e.copy_[r])||(e.copy_[r]=a,e.assigned_[r]=!0),!0},deleteProperty(e,r){return S2(e.base_,r)!==void 0||r in e.base_?(e.assigned_[r]=!1,C2(e),s4(e)):delete e.assigned_[r],e.copy_&&delete e.copy_[r],!0},getOwnPropertyDescriptor(e,r){const a=G0(e),s=Reflect.getOwnPropertyDescriptor(a,r);return s&&{writable:!0,configurable:e.type_!==1||r!=="length",enumerable:s.enumerable,value:a[r]}},defineProperty(){Kl(11)},getPrototypeOf(e){return ox(e.base_)},setPrototypeOf(){Kl(12)}},cx={};u1(a3,(e,r)=>{cx[e]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}});cx.deleteProperty=function(e,r){return cx.set.call(this,e,r,void 0)};cx.set=function(e,r,a){return a3.set.call(this,e[0],r,a,e[0])};function S2(e,r){const a=e[qo];return(a?G0(a):e)[r]}function rme(e,r,a){var n;const s=vI(r,a);return s?"value"in s?s.value:(n=s.get)==null?void 0:n.call(e.draft_):void 0}function vI(e,r){if(!(r in e))return;let a=ox(e);for(;a;){const s=Object.getOwnPropertyDescriptor(a,r);if(s)return s;a=ox(a)}}function s4(e){e.modified_||(e.modified_=!0,e.parent_&&s4(e.parent_))}function C2(e){e.copy_||(e.copy_=t4(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var ame=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(r,a,s)=>{if(typeof r=="function"&&typeof a!="function"){const i=a;a=r;const o=this;return function(c=i,...u){return o.produce(c,h=>a.call(this,h,...u))}}typeof a!="function"&&Kl(6),s!==void 0&&typeof s!="function"&&Kl(7);let n;if(Am(r)){const i=wA(this),o=n4(r,void 0);let l=!0;try{n=a(o),l=!1}finally{l?r4(i):a4(i)}return vA(i,s),jA(n,i)}else if(!r||typeof r!="object"){if(n=a(r),n===void 0&&(n=r),n===fI&&(n=void 0),this.autoFreeze_&&r3(n,!0),s){const i=[],o=[];Om("Patches").generateReplacementPatches_(r,n,i,o),s(i,o)}return n}else Kl(1,r)},this.produceWithPatches=(r,a)=>{if(typeof r=="function")return(o,...l)=>this.produceWithPatches(o,c=>r(c,...l));let s,n;return[this.produce(r,a,(o,l)=>{s=o,n=l}),s,n]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof(e==null?void 0:e.useStrictIteration)=="boolean"&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Am(e)||Kl(8),Cp(e)&&(e=sme(e));const r=wA(this),a=n4(e,void 0);return a[qo].isManual_=!0,a4(r),a}finishDraft(e,r){const a=e&&e[qo];(!a||!a.isManual_)&&Kl(9);const{scope_:s}=a;return vA(s,r),jA(void 0,s)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,r){let a;for(a=r.length-1;a>=0;a--){const n=r[a];if(n.path.length===0&&n.op==="replace"){e=n.value;break}}a>-1&&(r=r.slice(a+1));const s=Om("Patches").applyPatches_;return Cp(e)?s(e,r):this.produce(e,n=>s(n,r))}};function n4(e,r){const a=qx(e)?Om("MapSet").proxyMap_(e,r):Lw(e)?Om("MapSet").proxySet_(e,r):tme(e,r);return(r?r.scope_:bI()).drafts_.push(a),a}function sme(e){return Cp(e)||Kl(10,e),wI(e)}function wI(e){if(!Am(e)||Fw(e))return e;const r=e[qo];let a,s=!0;if(r){if(!r.modified_)return r.base_;r.finalized_=!0,a=t4(e,r.scope_.immer_.useStrictShallowCopy_),s=r.scope_.immer_.shouldUseStrictIteration()}else a=t4(e,!0);return u1(a,(n,i)=>{yI(a,n,wI(i))},s),r&&(r.finalized_=!1),a}var nme=new ame;nme.produce;var ime={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},jI=wi({name:"legend",initialState:ime,reducers:{setLegendSize(e,r){e.size.width=r.payload.width,e.size.height=r.payload.height},setLegendSettings(e,r){e.settings.align=r.payload.align,e.settings.layout=r.payload.layout,e.settings.verticalAlign=r.payload.verticalAlign,e.settings.itemSorter=r.payload.itemSorter},addLegendPayload:{reducer(e,r){e.payload.push(r.payload)},prepare:ys()},replaceLegendPayload:{reducer(e,r){var{prev:a,next:s}=r.payload,n=pl(e).payload.indexOf(a);n>-1&&(e.payload[n]=s)},prepare:ys()},removeLegendPayload:{reducer(e,r){var a=pl(e).payload.indexOf(r.payload);a>-1&&e.payload.splice(a,1)},prepare:ys()}}}),{setLegendSize:kA,setLegendSettings:ome,addLegendPayload:_I,replaceLegendPayload:kI,removeLegendPayload:NI}=jI.actions,lme=jI.reducer,T2={exports:{}},E2={};var NA;function cme(){if(NA)return E2;NA=1;var e=Ip();function r(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var a=typeof Object.is=="function"?Object.is:r,s=e.useSyncExternalStore,n=e.useRef,i=e.useEffect,o=e.useMemo,l=e.useDebugValue;return E2.useSyncExternalStoreWithSelector=function(c,u,h,f,y){var b=n(null);if(b.current===null){var w={hasValue:!1,value:null};b.current=w}else w=b.current;b=o(function(){function k(T){if(!S){if(S=!0,N=T,T=f(T),y!==void 0&&w.hasValue){var P=w.value;if(y(P,T))return C=P}return C=T}if(P=C,a(N,T))return P;var E=f(T);return y!==void 0&&y(P,E)?(N=T,P):(N=T,C=E)}var S=!1,N,C,O=h===void 0?null:h;return[function(){return k(u())},O===null?void 0:function(){return k(O())}]},[u,h,f,y]);var v=s(c,b[0],b[1]);return i(function(){w.hasValue=!0,w.value=v},[v]),l(v),v},E2}var SA;function dme(){return SA||(SA=1,T2.exports=cme()),T2.exports}dme();function ume(e){e()}function mme(){let e=null,r=null;return{clear(){e=null,r=null},notify(){ume(()=>{let a=e;for(;a;)a.callback(),a=a.next})},get(){const a=[];let s=e;for(;s;)a.push(s),s=s.next;return a},subscribe(a){let s=!0;const n=r={callback:a,next:null,prev:r};return n.prev?n.prev.next=n:e=n,function(){!s||e===null||(s=!1,n.next?n.next.prev=n.prev:r=n.prev,n.prev?n.prev.next=n.next:e=n.next)}}}}var CA={notify(){},get:()=>[]};function hme(e,r){let a,s=CA,n=0,i=!1;function o(v){h();const k=s.subscribe(v);let S=!1;return()=>{S||(S=!0,k(),f())}}function l(){s.notify()}function c(){w.onStateChange&&w.onStateChange()}function u(){return i}function h(){n++,a||(a=e.subscribe(c),s=mme())}function f(){n--,a&&n===0&&(a(),a=void 0,s.clear(),s=CA)}function y(){i||(i=!0,h())}function b(){i&&(i=!1,f())}const w={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:y,tryUnsubscribe:b,getListeners:()=>s};return w}var pme=()=>typeof window!="undefined"&&typeof window.document!="undefined"&&typeof window.document.createElement!="undefined",gme=pme(),fme=()=>typeof navigator!="undefined"&&navigator.product==="ReactNative",xme=fme(),yme=()=>gme||xme?p.useLayoutEffect:p.useEffect,bme=yme();function TA(e,r){return e===r?e!==0||r!==0||1/e===1/r:e!==e&&r!==r}function vme(e,r){if(TA(e,r))return!0;if(typeof e!="object"||e===null||typeof r!="object"||r===null)return!1;const a=Object.keys(e),s=Object.keys(r);if(a.length!==s.length)return!1;for(let n=0;n<a.length;n++)if(!Object.prototype.hasOwnProperty.call(r,a[n])||!TA(e[a[n]],r[a[n]]))return!1;return!0}var A2=Symbol.for("react-redux-context"),O2=typeof globalThis!="undefined"?globalThis:{};function wme(){var a;if(!p.createContext)return{};const e=(a=O2[A2])!=null?a:O2[A2]=new Map;let r=e.get(p.createContext);return r||(r=p.createContext(null),e.set(p.createContext,r)),r}var jme=wme();function _me(e){const{children:r,context:a,serverState:s,store:n}=e,i=p.useMemo(()=>{const c=hme(n);return{store:n,subscription:c,getServerState:s?()=>s:void 0}},[n,s]),o=p.useMemo(()=>n.getState(),[n]);bme(()=>{const{subscription:c}=i;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),o!==n.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[i,o]);const l=a||jme;return p.createElement(l.Provider,{value:i},r)}var kme=_me,Nme=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle","radius","throttledEvents"]);function Sme(e,r){return e==null&&r==null?!0:typeof e=="number"&&typeof r=="number"?e===r||e!==e&&r!==r:e===r}function Vx(e,r){var a=new Set([...Object.keys(e),...Object.keys(r)]);for(var s of a)if(Nme.has(s)){if(e[s]==null&&r[s]==null)continue;if(!vme(e[s],r[s]))return!1}else if(!Sme(e[s],r[s]))return!1;return!0}var Cme=["contextPayload"];function i4(){return i4=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},i4.apply(null,arguments)}function EA(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function Tp(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?EA(Object(a),!0).forEach(function(s){Tme(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):EA(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function Tme(e,r,a){return(r=Eme(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Eme(e){var r=Ame(e,"string");return typeof r=="symbol"?r:r+""}function Ame(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Ome(e,r){if(e==null)return{};var a,s,n=Pme(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function Pme(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}function Dme(e){return e.value}function Rme(e){var{contextPayload:r}=e,a=Ome(e,Cme),s=_F(r,e.payloadUniqBy,Dme),n=Tp(Tp({},a),{},{payload:s});return p.isValidElement(e.content)?p.cloneElement(e.content,n):typeof e.content=="function"?p.createElement(e.content,n):p.createElement(lde,n)}function Mme(e,r,a,s,n,i){var{layout:o,align:l,verticalAlign:c}=r,u,h;return(!e||(e.left===void 0||e.left===null)&&(e.right===void 0||e.right===null))&&(l==="center"&&o==="vertical"?u={left:((s||0)-i.width)/2}:u=l==="right"?{right:a&&a.right||0}:{left:a&&a.left||0}),(!e||(e.top===void 0||e.top===null)&&(e.bottom===void 0||e.bottom===null))&&(c==="middle"?h={top:((n||0)-i.height)/2}:h=c==="bottom"?{bottom:a&&a.bottom||0}:{top:a&&a.top||0}),Tp(Tp({},u),h)}function Lme(e){var r=ss();return p.useEffect(()=>{r(ome(e))},[r,e]),null}function Fme(e){var r=ss();return p.useEffect(()=>(r(kA(e)),()=>{r(kA({width:0,height:0}))}),[r,e]),null}function Ime(e,r,a,s){return e==="vertical"&&r!=null?{height:r}:e==="horizontal"?{width:a||s}:null}var zme={align:"center",iconSize:14,inactiveColor:"#ccc",itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function $me(e){var r=In(e,zme),a=tue(),s=Xle(),n=G0e(),{width:i,height:o,wrapperStyle:l,portal:c}=r,[u,h]=TF([a]),f=e3(),y=t3();if(f==null||y==null)return null;var b=f-((n==null?void 0:n.left)||0)-((n==null?void 0:n.right)||0),w=Ime(r.layout,o,i,b),v=c?l:Tp(Tp({position:"absolute",width:(w==null?void 0:w.width)||i||"auto",height:(w==null?void 0:w.height)||o||"auto"},Mme(l,r,n,f,y,u)),l),k=c!=null?c:s;if(k==null||a==null)return null;var S=p.createElement("div",{className:"recharts-legend-wrapper",style:v,ref:h},p.createElement(Lme,{layout:r.layout,align:r.align,verticalAlign:r.verticalAlign,itemSorter:r.itemSorter}),!c&&p.createElement(Fme,{width:u.width,height:u.height}),p.createElement(Rme,i4({},r,w,{margin:n,chartWidth:f,chartHeight:y,contextPayload:a})));return wx.createPortal(S,k)}var o4=p.memo($me,Vx);o4.displayName="Legend";function l4(){return l4=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},l4.apply(null,arguments)}function AA(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function sf(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?AA(Object(a),!0).forEach(function(s){Ume(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):AA(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function Ume(e,r,a){return(r=Bme(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Bme(e){var r=Wme(e,"string");return typeof r=="symbol"?r:r+""}function Wme(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Hme(e){return Array.isArray(e)&&Uc(e[0])&&Uc(e[1])?e.join(" ~ "):e}var Wh={separator:" : ",contentStyle:{margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},itemStyle:{display:"block",paddingTop:4,paddingBottom:4,color:"#000"},labelStyle:{},accessibilityLayer:!1};function qme(e,r){return r==null?e:bw(e,r)}var Vme=e=>{var{separator:r=Wh.separator,contentStyle:a,itemStyle:s,labelStyle:n=Wh.labelStyle,payload:i,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:u,label:h,labelFormatter:f,accessibilityLayer:y=Wh.accessibilityLayer}=e,b=()=>{if(i&&i.length){var T={padding:0,margin:0},P=qme(i,l),E=P.map((R,z)=>{if(!R||R.type==="none")return null;var G=R.formatter||o||Hme,{value:ae,name:ee}=R,ne=ae,te=ee;if(G){var Y=G(ae,ee,R,z,i);if(Array.isArray(Y))[ne,te]=Y;else if(Y!=null)ne=Y;else return null}var q=sf(sf({},Wh.itemStyle),{},{color:R.color||Wh.itemStyle.color},s);return p.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(z),style:q},Uc(te)?p.createElement("span",{className:"recharts-tooltip-item-name"},te):null,Uc(te)?p.createElement("span",{className:"recharts-tooltip-item-separator"},r):null,p.createElement("span",{className:"recharts-tooltip-item-value"},ne),p.createElement("span",{className:"recharts-tooltip-item-unit"},R.unit||""))});return p.createElement("ul",{className:"recharts-tooltip-item-list",style:T},E)}return null},w=sf(sf({},Wh.contentStyle),a),v=sf({margin:0},n),k=!_n(h),S=k?h:"",N=va("recharts-default-tooltip",c),C=va("recharts-tooltip-label",u);k&&f&&i!==void 0&&i!==null&&(S=f(h,i));var O=y?{role:"status","aria-live":"assertive"}:{};return p.createElement("div",l4({className:N,style:w},O),p.createElement("p",{className:C,style:v},p.isValidElement(S)?S:"".concat(S)),b())},nf="recharts-tooltip-wrapper",Gme={visibility:"hidden"};function Kme(e){var{coordinate:r,translateX:a,translateY:s}=e;return va(nf,{["".concat(nf,"-right")]:_r(a)&&r&&_r(r.x)&&a>=r.x,["".concat(nf,"-left")]:_r(a)&&r&&_r(r.x)&&a<r.x,["".concat(nf,"-bottom")]:_r(s)&&r&&_r(r.y)&&s>=r.y,["".concat(nf,"-top")]:_r(s)&&r&&_r(r.y)&&s<r.y})}function OA(e){var{allowEscapeViewBox:r,coordinate:a,key:s,offset:n,position:i,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=e;if(i&&_r(i[s]))return i[s];var h=a[s]-l-(n>0?n:0),f=a[s]+n;if(r[s])return o[s]?h:f;var y=c[s];if(y==null)return 0;if(o[s]){var b=h,w=y;return b<w?Math.max(f,y):Math.max(h,y)}if(u==null)return 0;var v=f+l,k=y+u;return v>k?Math.max(h,y):Math.max(f,y)}function Yme(e){var{translateX:r,translateY:a,useTranslate3d:s}=e;return{transform:s?"translate3d(".concat(r,"px, ").concat(a,"px, 0)"):"translate(".concat(r,"px, ").concat(a,"px)")}}function Jme(e){var{allowEscapeViewBox:r,coordinate:a,offsetTop:s,offsetLeft:n,position:i,reverseDirection:o,tooltipBox:l,useTranslate3d:c,viewBox:u}=e,h,f,y;return l.height>0&&l.width>0&&a?(f=OA({allowEscapeViewBox:r,coordinate:a,key:"x",offset:n,position:i,reverseDirection:o,tooltipDimension:l.width,viewBox:u,viewBoxDimension:u.width}),y=OA({allowEscapeViewBox:r,coordinate:a,key:"y",offset:s,position:i,reverseDirection:o,tooltipDimension:l.height,viewBox:u,viewBoxDimension:u.height}),h=Yme({translateX:f,translateY:y,useTranslate3d:c})):h=Gme,{cssProperties:h,cssClasses:Kme({translateX:f,translateY:y,coordinate:a})}}var Zme=()=>!(typeof window!="undefined"&&window.document&&window.document.createElement&&window.setTimeout),Gx={isSsr:Zme()};function SI(){var[e,r]=p.useState(()=>Gx.isSsr||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return p.useEffect(()=>{if(window.matchMedia){var a=window.matchMedia("(prefers-reduced-motion: reduce)"),s=()=>{r(a.matches)};return a.addEventListener("change",s),()=>{a.removeEventListener("change",s)}}},[]),e}function PA(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function Hh(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?PA(Object(a),!0).forEach(function(s){Xme(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):PA(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function Xme(e,r,a){return(r=Qme(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Qme(e){var r=ehe(e,"string");return typeof r=="symbol"?r:r+""}function ehe(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function the(e){if(!(e.prefersReducedMotion&&e.isAnimationActive==="auto")&&e.isAnimationActive&&e.active)return"transform ".concat(e.animationDuration,"ms ").concat(e.animationEasing)}function rhe(e){var r,a,s,n,i,o,l=SI(),[c,u]=p.useState(()=>({dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}));p.useEffect(()=>{var w=v=>{if(v.key==="Escape"){var k,S,N,C;u({dismissed:!0,dismissedAtCoordinate:{x:(k=(S=e.coordinate)===null||S===void 0?void 0:S.x)!==null&&k!==void 0?k:0,y:(N=(C=e.coordinate)===null||C===void 0?void 0:C.y)!==null&&N!==void 0?N:0}})}};return document.addEventListener("keydown",w),()=>{document.removeEventListener("keydown",w)}},[(r=e.coordinate)===null||r===void 0?void 0:r.x,(a=e.coordinate)===null||a===void 0?void 0:a.y]),c.dismissed&&(((s=(n=e.coordinate)===null||n===void 0?void 0:n.x)!==null&&s!==void 0?s:0)!==c.dismissedAtCoordinate.x||((i=(o=e.coordinate)===null||o===void 0?void 0:o.y)!==null&&i!==void 0?i:0)!==c.dismissedAtCoordinate.y)&&u(Hh(Hh({},c),{},{dismissed:!1}));var{cssClasses:h,cssProperties:f}=Jme({allowEscapeViewBox:e.allowEscapeViewBox,coordinate:e.coordinate,offsetLeft:typeof e.offset=="number"?e.offset:e.offset.x,offsetTop:typeof e.offset=="number"?e.offset:e.offset.y,position:e.position,reverseDirection:e.reverseDirection,tooltipBox:{height:e.lastBoundingBox.height,width:e.lastBoundingBox.width},useTranslate3d:e.useTranslate3d,viewBox:e.viewBox}),y=e.hasPortalFromProps?{}:Hh(Hh({transition:the({prefersReducedMotion:l,isAnimationActive:e.isAnimationActive,active:e.active,animationDuration:e.animationDuration,animationEasing:e.animationEasing})},f),{},{pointerEvents:"none",position:"absolute",top:0,left:0}),b=Hh(Hh({},y),{},{visibility:!c.dismissed&&e.active&&e.hasPayload?"visible":"hidden"},e.wrapperStyle);return p.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:h,style:b,ref:e.innerRef},e.children)}var ahe=p.memo(rhe),CI=()=>{var e;return(e=kr(r=>r.rootProps.accessibilityLayer))!==null&&e!==void 0?e:!0};function c4(){return c4=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},c4.apply(null,arguments)}function DA(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function RA(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?DA(Object(a),!0).forEach(function(s){she(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):DA(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function she(e,r,a){return(r=nhe(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function nhe(e){var r=ihe(e,"string");return typeof r=="symbol"?r:r+""}function ihe(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var MA={curveBasisClosed:xce,curveBasisOpen:yce,curveBasis:fce,curveBumpX:rce,curveBumpY:ace,curveLinearClosed:bce,curveLinear:xw,curveMonotoneX:vce,curveMonotoneY:wce,curveNatural:jce,curveStep:_ce,curveStepAfter:Nce,curveStepBefore:kce},p1=e=>ja(e.x)&&ja(e.y),LA=e=>e.base!=null&&p1(e.base)&&p1(e),of=e=>e.x,lf=e=>e.y,ohe=(e,r)=>{if(typeof e=="function")return e;var a="curve".concat(zx(e));if((a==="curveMonotone"||a==="curveBump")&&r){var s=MA["".concat(a).concat(r==="vertical"?"Y":"X")];if(s)return s}return MA[a]||xw},FA={connectNulls:!1,type:"linear"},lhe=e=>{var{type:r=FA.type,points:a=[],baseLine:s,layout:n,connectNulls:i=FA.connectNulls}=e,o=ohe(r,n),l=i?a.filter(p1):a;if(Array.isArray(s)){var c,u=a.map((w,v)=>RA(RA({},w),{},{base:s[v]}));n==="vertical"?c=Nb().y(lf).x1(of).x0(w=>w.base.x):c=Nb().x(of).y1(lf).y0(w=>w.base.y);var h=c.defined(LA).curve(o),f=i?u.filter(LA):u;return h(f)}var y;n==="vertical"&&_r(s)?y=Nb().y(lf).x1(of).x0(s):_r(s)?y=Nb().x(of).y1(lf).y0(s):y=XL().x(of).y(lf);var b=y.defined(p1).curve(o);return b(l)},s3=e=>{var{className:r,points:a,path:s,pathRef:n}=e,i=Jp();if((!a||!a.length)&&!s)return null;var o={type:e.type,points:e.points,baseLine:e.baseLine,layout:e.layout||i,connectNulls:e.connectNulls},l=a&&a.length?lhe(o):s;return p.createElement("path",c4({},ac(e),Yce(e),{className:va("recharts-curve",r),d:l===null?void 0:l,ref:n}))},che=["x","y","top","left","width","height","className"];function d4(){return d4=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},d4.apply(null,arguments)}function IA(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function dhe(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?IA(Object(a),!0).forEach(function(s){uhe(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):IA(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function uhe(e,r,a){return(r=mhe(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function mhe(e){var r=hhe(e,"string");return typeof r=="symbol"?r:r+""}function hhe(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function phe(e,r){if(e==null)return{};var a,s,n=ghe(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function ghe(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}var fhe=(e,r,a,s,n,i)=>"M".concat(e,",").concat(n,"v").concat(s,"M").concat(i,",").concat(r,"h").concat(a),xhe=e=>{var{x:r=0,y:a=0,top:s=0,left:n=0,width:i=0,height:o=0,className:l}=e,c=phe(e,che),u=dhe({x:r,y:a,top:s,left:n,width:i,height:o},c);return!_r(r)||!_r(a)||!_r(i)||!_r(o)||!_r(s)||!_r(n)?null:p.createElement("path",d4({},bl(u),{className:va("recharts-cross",l),d:fhe(r,a,i,o,s,n)}))};function yhe(e,r,a,s){var n=s/2;return{stroke:"none",fill:"#ccc",x:e==="horizontal"?r.x-n:a.left+.5,y:e==="horizontal"?a.top+.5:r.y-n,width:e==="horizontal"?s:a.width-1,height:e==="horizontal"?a.height-1:s}}function zA(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function $A(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?zA(Object(a),!0).forEach(function(s){bhe(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):zA(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function bhe(e,r,a){return(r=vhe(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function vhe(e){var r=whe(e,"string");return typeof r=="symbol"?r:r+""}function whe(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var jhe=e=>e.replace(/([A-Z])/g,r=>"-".concat(r.toLowerCase())),TI=(e,r,a)=>e.map(s=>"".concat(jhe(s)," ").concat(r,"ms ").concat(a)).join(","),_he=(e,r)=>[Object.keys(e),Object.keys(r)].reduce((a,s)=>a.filter(n=>s.includes(n))),dx=(e,r)=>Object.keys(r).reduce((a,s)=>$A($A({},a),{},{[s]:e(s,r[s])}),{});function UA(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function jn(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?UA(Object(a),!0).forEach(function(s){khe(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):UA(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function khe(e,r,a){return(r=Nhe(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Nhe(e){var r=She(e,"string");return typeof r=="symbol"?r:r+""}function She(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var g1=(e,r,a)=>e+(r-e)*a,u4=e=>{var{from:r,to:a}=e;return r!==a},EI=(e,r,a)=>{var s=dx((n,i)=>{if(u4(i)){var[o,l]=e(i.from,i.to,i.velocity);return jn(jn({},i),{},{from:o,velocity:l})}return i},r);return a<1?dx((n,i)=>u4(i)&&s[n]!=null?jn(jn({},i),{},{velocity:g1(i.velocity,s[n].velocity,a),from:g1(i.from,s[n].from,a)}):i,r):EI(e,s,a-1)};function Che(e,r,a,s,n,i){var o,l=s.reduce((y,b)=>jn(jn({},y),{},{[b]:{from:e[b],velocity:0,to:r[b]}}),{}),c=()=>dx((y,b)=>b.from,l),u=()=>!Object.values(l).filter(u4).length,h=null,f=y=>{o||(o=y);var b=y-o,w=b/a.dt;l=EI(a,l,w),n(jn(jn(jn({},e),r),c())),o=y,u()||(h=i.setTimeout(f))};return()=>(h=i.setTimeout(f),()=>{var y;(y=h)===null||y===void 0||y()})}function The(e,r,a,s,n,i,o){var l=null,c=n.reduce((f,y)=>{var b=e[y],w=r[y];return b==null||w==null?f:jn(jn({},f),{},{[y]:[b,w]})},{}),u,h=f=>{u||(u=f);var y=(f-u)/s,b=dx((v,k)=>g1(...k,a(y)),c);if(i(jn(jn(jn({},e),r),b)),y<1)l=o.setTimeout(h);else{var w=dx((v,k)=>g1(...k,a(1)),c);i(jn(jn(jn({},e),r),w))}};return()=>(l=o.setTimeout(h),()=>{var f;(f=l)===null||f===void 0||f()})}const Ehe=(e,r,a,s,n,i)=>{var o=_he(e,r);return a==null?()=>(n(jn(jn({},e),r)),()=>{}):a.isStepper===!0?Che(e,r,a,o,n,i):The(e,r,a,s,o,n,i)};var f1=1e-4,AI=(e,r)=>[0,3*e,3*r-6*e,3*e-3*r+1],OI=(e,r)=>e.map((a,s)=>a*O0(r,s)).reduce((a,s)=>a+s),BA=(e,r)=>a=>{var s=AI(e,r);return OI(s,a)},Ahe=(e,r)=>a=>{var s=AI(e,r),n=[...s.map((i,o)=>i*o).slice(1),0];return OI(n,a)},Ohe=e=>{var r,a=e.split("(");if(a.length!==2||a[0]!=="cubic-bezier")return null;var s=(r=a[1])===null||r===void 0||(r=r.split(")")[0])===null||r===void 0?void 0:r.split(",");if(s==null||s.length!==4)return null;var n=s.map(i=>parseFloat(i));return[n[0],n[1],n[2],n[3]]},Phe=function(){for(var r=arguments.length,a=new Array(r),s=0;s<r;s++)a[s]=arguments[s];if(a.length===1)switch(a[0]){case"linear":return[0,0,1,1];case"ease":return[.25,.1,.25,1];case"ease-in":return[.42,0,1,1];case"ease-out":return[.42,0,.58,1];case"ease-in-out":return[0,0,.58,1];default:{var n=Ohe(a[0]);if(n)return n}}return a.length===4?a:[0,0,1,1]},Dhe=(e,r,a,s)=>{var n=BA(e,a),i=BA(r,s),o=Ahe(e,a),l=u=>u>1?1:u<0?0:u,c=u=>{for(var h=u>1?1:u,f=h,y=0;y<8;++y){var b=n(f)-h,w=o(f);if(Math.abs(b-h)<f1||w<f1)return i(f);f=l(f-b/w)}return i(f)};return c.isStepper=!1,c},WA=function(){return Dhe(...Phe(...arguments))},Rhe=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:a=100,damping:s=8,dt:n=17}=r,i=(o,l,c)=>{var u=-(o-l)*a,h=c*s,f=c+(u-h)*n/1e3,y=c*n/1e3+o;return Math.abs(y-l)<f1&&Math.abs(f)<f1?[l,0]:[y,f]};return i.isStepper=!0,i.dt=n,i},Mhe=e=>{if(typeof e=="string")switch(e){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return WA(e);case"spring":return Rhe();default:if(e.split("(")[0]==="cubic-bezier")return WA(e)}return typeof e=="function"?e:null};function Lhe(e){var r,a=()=>null,s=!1,n=null,i=o=>{if(!s){if(Array.isArray(o)){if(!o.length)return;var l=o,[c,...u]=l;if(typeof c=="number"){n=e.setTimeout(i.bind(null,u),c);return}i(c),n=e.setTimeout(i.bind(null,u));return}typeof o=="string"&&(r=o,a(r)),typeof o=="object"&&(r=o,a(r)),typeof o=="function"&&o()}};return{stop:()=>{s=!0},start:o=>{s=!1,n&&(n(),n=null),i(o)},subscribe:o=>(a=o,()=>{a=()=>null}),getTimeoutController:()=>e}}class Fhe{setTimeout(r){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=performance.now(),n=null,i=o=>{o-s>=a?r(o):typeof requestAnimationFrame=="function"&&(n=requestAnimationFrame(i))};return n=requestAnimationFrame(i),()=>{n!=null&&cancelAnimationFrame(n)}}}function Ihe(){return Lhe(new Fhe)}var zhe=p.createContext(Ihe);function $he(e,r){var a=p.useContext(zhe);return p.useMemo(()=>r!=null?r:a(e),[e,r,a])}var Uhe={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},HA={t:0},P2={t:1};function Iw(e){var r=In(e,Uhe),{isActive:a,canBegin:s,duration:n,easing:i,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=r,h=SI(),f=a==="auto"?!Gx.isSsr&&!h:a,y=$he(r.animationId,r.animationManager),[b,w]=p.useState(f?HA:P2),v=p.useRef(null);return p.useEffect(()=>{f||w(P2)},[f]),p.useEffect(()=>{if(!f||!s)return Yp;var k=Ehe(HA,P2,Mhe(i),n,w,y.getTimeoutController()),S=()=>{v.current=k()};return y.start([c,o,S,n,l]),()=>{y.stop(),v.current&&v.current(),l()}},[f,s,n,i,o,c,l,y]),u(b.t)}function zw(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",a=p.useRef(ax(r)),s=p.useRef(e);return s.current!==e&&(a.current=ax(r),s.current=e),a.current}var Bhe=["radius"],Whe=["radius"],qA,VA,GA,KA,YA,JA,ZA,XA,QA,eO;function tO(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function rO(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?tO(Object(a),!0).forEach(function(s){Hhe(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):tO(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function Hhe(e,r,a){return(r=qhe(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function qhe(e){var r=Vhe(e,"string");return typeof r=="symbol"?r:r+""}function Vhe(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function x1(){return x1=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},x1.apply(null,arguments)}function aO(e,r){if(e==null)return{};var a,s,n=Ghe(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function Ghe(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}function Nc(e,r){return r||(r=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(r)}}))}var sO=(e,r,a,s,n)=>{var i=Gu(a),o=Gu(s),l=Math.min(Math.abs(i)/2,Math.abs(o)/2),c=o>=0?1:-1,u=i>=0?1:-1,h=o>=0&&i>=0||o<0&&i<0?1:0,f;if(l>0&&Array.isArray(n)){for(var y=[0,0,0,0],b=0,w=4;b<w;b++){var v,k=(v=n[b])!==null&&v!==void 0?v:0;y[b]=k>l?l:k}f=Bs(qA||(qA=Nc(["M",",",""])),e,r+c*y[0]),y[0]>0&&(f+=Bs(VA||(VA=Nc(["A ",",",",0,0,",",",",",""])),y[0],y[0],h,e+u*y[0],r)),f+=Bs(GA||(GA=Nc(["L ",",",""])),e+a-u*y[1],r),y[1]>0&&(f+=Bs(KA||(KA=Nc(["A ",",",",0,0,",`,
|
||
`,",",""])),y[1],y[1],h,e+a,r+c*y[1])),f+=Bs(YA||(YA=Nc(["L ",",",""])),e+a,r+s-c*y[2]),y[2]>0&&(f+=Bs(JA||(JA=Nc(["A ",",",",0,0,",`,
|
||
`,",",""])),y[2],y[2],h,e+a-u*y[2],r+s)),f+=Bs(ZA||(ZA=Nc(["L ",",",""])),e+u*y[3],r+s),y[3]>0&&(f+=Bs(XA||(XA=Nc(["A ",",",",0,0,",`,
|
||
`,",",""])),y[3],y[3],h,e,r+s-c*y[3])),f+="Z"}else if(l>0&&n===+n&&n>0){var S=Math.min(l,n);f=Bs(QA||(QA=Nc(["M ",",",`
|
||
A `,",",",0,0,",",",",",`
|
||
L `,",",`
|
||
A `,",",",0,0,",",",",",`
|
||
L `,",",`
|
||
A `,",",",0,0,",",",",",`
|
||
L `,",",`
|
||
A `,",",",0,0,",",",","," Z"])),e,r+c*S,S,S,h,e+u*S,r,e+a-u*S,r,S,S,h,e+a,r+c*S,e+a,r+s-c*S,S,S,h,e+a-u*S,r+s,e+u*S,r+s,S,S,h,e,r+s-c*S)}else f=Bs(eO||(eO=Nc(["M ",","," h "," v "," h "," Z"])),e,r,a,s,-a);return f},nO={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},PI=e=>{var r=In(e,nO),a=p.useRef(null),[s,n]=p.useState(-1);p.useEffect(()=>{if(a.current&&a.current.getTotalLength)try{var H=a.current.getTotalLength();H&&n(H)}catch(U){}},[]);var{x:i,y:o,width:l,height:c,radius:u,className:h}=r,{animationEasing:f,animationDuration:y,animationBegin:b,isAnimationActive:w,isUpdateAnimationActive:v}=r,k=p.useRef(l),S=p.useRef(c),N=p.useRef(i),C=p.useRef(o),O=p.useMemo(()=>({x:i,y:o,width:l,height:c,radius:u}),[i,o,l,c,u]),T=zw(O,"rectangle-");if(i!==+i||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var P=va("recharts-rectangle",h);if(!v){var E=bl(r),{radius:R}=E,z=aO(E,Bhe);return p.createElement("path",x1({},z,{x:Gu(i),y:Gu(o),width:Gu(l),height:Gu(c),radius:typeof u=="number"?u:void 0,className:P,d:sO(i,o,l,c,u)}))}var G=k.current,ae=S.current,ee=N.current,ne=C.current,te="0px ".concat(s===-1?1:s,"px"),Y="".concat(s,"px ").concat(s,"px"),q=TI(["strokeDasharray"],y,typeof f=="string"?f:nO.animationEasing);return p.createElement(Iw,{animationId:T,key:T,canBegin:s>0,duration:y,easing:f,isActive:v,begin:b},H=>{var U=wn(G,l,H),re=wn(ae,c,H),X=wn(ee,i,H),V=wn(ne,o,H);a.current&&(k.current=U,S.current=re,N.current=X,C.current=V);var I;w?H>0?I={transition:q,strokeDasharray:Y}:I={strokeDasharray:te}:I={strokeDasharray:Y};var B=bl(r),{radius:Q}=B,ie=aO(B,Whe);return p.createElement("path",x1({},ie,{radius:typeof u=="number"?u:void 0,className:P,d:sO(X,V,U,re,u),ref:a,style:rO(rO({},I),r.style)}))})};function iO(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function oO(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?iO(Object(a),!0).forEach(function(s){Khe(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):iO(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function Khe(e,r,a){return(r=Yhe(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Yhe(e){var r=Jhe(e,"string");return typeof r=="symbol"?r:r+""}function Jhe(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var y1=Math.PI/180,Zhe=e=>e*180/Math.PI,on=(e,r,a,s)=>({x:e+Math.cos(-y1*s)*a,y:r+Math.sin(-y1*s)*a}),DI=function(r,a){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(r-(s.left||0)-(s.right||0)),Math.abs(a-(s.top||0)-(s.bottom||0)))/2},Xhe=(e,r)=>{var{x:a,y:s}=e,{x:n,y:i}=r;return Math.sqrt(O0(a-n,2)+O0(s-i,2))},Qhe=(e,r)=>{var{x:a,y:s}=e,{cx:n,cy:i}=r,o=Xhe({x:a,y:s},{x:n,y:i});if(o<=0)return{radius:o,angle:0};var l=(a-n)/o,c=Math.acos(l);return s>i&&(c=2*Math.PI-c),{radius:o,angle:Zhe(c),angleInRadian:c}},epe=e=>{var{startAngle:r,endAngle:a}=e,s=Math.floor(r/360),n=Math.floor(a/360),i=Math.min(s,n);return{startAngle:r-i*360,endAngle:a-i*360}},tpe=(e,r)=>{var{startAngle:a,endAngle:s}=r,n=Math.floor(a/360),i=Math.floor(s/360),o=Math.min(n,i);return e+o*360},rpe=(e,r)=>{var{relativeX:a,relativeY:s}=e,{radius:n,angle:i}=Qhe({x:a,y:s},r),{innerRadius:o,outerRadius:l}=r;if(n<o||n>l||n===0)return null;var{startAngle:c,endAngle:u}=epe(r),h=i,f;if(c<=u){for(;h>u;)h-=360;for(;h<c;)h+=360;f=h>=c&&h<=u}else{for(;h>c;)h-=360;for(;h<u;)h+=360;f=h>=u&&h<=c}return f?oO(oO({},r),{},{radius:n,angle:tpe(h,r)}):null};function RI(e){var{cx:r,cy:a,radius:s,startAngle:n,endAngle:i}=e,o=on(r,a,s,n),l=on(r,a,s,i);return{points:[o,l],cx:r,cy:a,radius:s,startAngle:n,endAngle:i}}var lO,cO,dO,uO,mO,hO,pO;function m4(){return m4=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},m4.apply(null,arguments)}function im(e,r){return r||(r=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(r)}}))}var ape=(e,r)=>{var a=Ln(r-e),s=Math.min(Math.abs(r-e),359.999);return a*s},Rb=e=>{var{cx:r,cy:a,radius:s,angle:n,sign:i,isExternal:o,cornerRadius:l,cornerIsExternal:c}=e,u=l*(o?1:-1)+s,h=Math.asin(l/u)/y1,f=c?n:n+i*h,y=on(r,a,u,f),b=on(r,a,s,f),w=c?n-i*h:n,v=on(r,a,u*Math.cos(h*y1),w);return{center:y,circleTangency:b,lineTangency:v,theta:h}},MI=e=>{var{cx:r,cy:a,innerRadius:s,outerRadius:n,startAngle:i,endAngle:o}=e,l=ape(i,o),c=i+l,u=on(r,a,n,i),h=on(r,a,n,c),f=Bs(lO||(lO=im(["M ",",",`
|
||
A `,",",`,0,
|
||
`,",",`,
|
||
`,",",`
|
||
`])),u.x,u.y,n,n,+(Math.abs(l)>180),+(i>c),h.x,h.y);if(s>0){var y=on(r,a,s,i),b=on(r,a,s,c);f+=Bs(cO||(cO=im(["L ",",",`
|
||
A `,",",`,0,
|
||
`,",",`,
|
||
`,","," Z"])),b.x,b.y,s,s,+(Math.abs(l)>180),+(i<=c),y.x,y.y)}else f+=Bs(dO||(dO=im(["L ",","," Z"])),r,a);return f},spe=e=>{var{cx:r,cy:a,innerRadius:s,outerRadius:n,cornerRadius:i,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}=e,h=Ln(u-c),{circleTangency:f,lineTangency:y,theta:b}=Rb({cx:r,cy:a,radius:n,angle:c,sign:h,cornerRadius:i,cornerIsExternal:l}),{circleTangency:w,lineTangency:v,theta:k}=Rb({cx:r,cy:a,radius:n,angle:u,sign:-h,cornerRadius:i,cornerIsExternal:l}),S=l?Math.abs(c-u):Math.abs(c-u)-b-k;if(S<0)return o?Bs(uO||(uO=im(["M ",",",`
|
||
a`,",",",0,0,1,",`,0
|
||
a`,",",",0,0,1,",`,0
|
||
`])),y.x,y.y,i,i,i*2,i,i,-i*2):MI({cx:r,cy:a,innerRadius:s,outerRadius:n,startAngle:c,endAngle:u});var N=Bs(mO||(mO=im(["M ",",",`
|
||
A`,",",",0,0,",",",",",`
|
||
A`,",",",0,",",",",",",",`
|
||
A`,",",",0,0,",",",",",`
|
||
`])),y.x,y.y,i,i,+(h<0),f.x,f.y,n,n,+(S>180),+(h<0),w.x,w.y,i,i,+(h<0),v.x,v.y);if(s>0){var{circleTangency:C,lineTangency:O,theta:T}=Rb({cx:r,cy:a,radius:s,angle:c,sign:h,isExternal:!0,cornerRadius:i,cornerIsExternal:l}),{circleTangency:P,lineTangency:E,theta:R}=Rb({cx:r,cy:a,radius:s,angle:u,sign:-h,isExternal:!0,cornerRadius:i,cornerIsExternal:l}),z=l?Math.abs(c-u):Math.abs(c-u)-T-R;if(z<0&&i===0)return"".concat(N,"L").concat(r,",").concat(a,"Z");N+=Bs(hO||(hO=im(["L",",",`
|
||
A`,",",",0,0,",",",",",`
|
||
A`,",",",0,",",",",",",",`
|
||
A`,",",",0,0,",",",",","Z"])),E.x,E.y,i,i,+(h<0),P.x,P.y,s,s,+(z>180),+(h>0),C.x,C.y,i,i,+(h<0),O.x,O.y)}else N+=Bs(pO||(pO=im(["L",",","Z"])),r,a);return N},npe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},LI=e=>{var r=In(e,npe),{cx:a,cy:s,innerRadius:n,outerRadius:i,cornerRadius:o,forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:h,className:f}=r;if(i<n||u===h)return null;var y=va("recharts-sector",f),b=i-n,w=xi(o,b,0,!0),v;return w>0&&Math.abs(u-h)<360?v=spe({cx:a,cy:s,innerRadius:n,outerRadius:i,cornerRadius:Math.min(w,b/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:h}):v=MI({cx:a,cy:s,innerRadius:n,outerRadius:i,startAngle:u,endAngle:h}),p.createElement("path",m4({},bl(r),{className:y,d:v}))};function ipe(e,r,a){if(e==="horizontal")return[{x:r.x,y:a.top},{x:r.x,y:a.top+a.height}];if(e==="vertical")return[{x:a.left,y:r.y},{x:a.left+a.width,y:r.y}];if(mF(r)){if(e==="centric"){var{cx:s,cy:n,innerRadius:i,outerRadius:o,angle:l}=r,c=on(s,n,i,l),u=on(s,n,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return RI(r)}}var D2={},R2={},M2={},gO;function ope(){return gO||(gO=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=NF();function a(s){return r.isSymbol(s)?NaN:Number(s)}e.toNumber=a})(M2)),M2}var fO;function lpe(){return fO||(fO=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=ope();function a(s){return s?(s=r.toNumber(s),s===1/0||s===-1/0?(s<0?-1:1)*Number.MAX_VALUE:s===s?s:0):s===0?s:0}e.toFinite=a})(R2)),R2}var xO;function cpe(){return xO||(xO=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const r=SF(),a=lpe();function s(n,i,o){o&&typeof o!="number"&&r.isIterateeCall(n,i,o)&&(i=o=void 0),n=a.toFinite(n),i===void 0?(i=n,n=0):i=a.toFinite(i),o=o===void 0?n<i?1:-1:a.toFinite(o);const l=Math.max(Math.ceil((i-n)/(o||1)),0),c=new Array(l);for(let u=0;u<l;u++)c[u]=n,n+=o;return c}e.range=s})(D2)),D2}var L2,yO;function dpe(){return yO||(yO=1,L2=cpe().range),L2}var upe=dpe();const FI=tu(upe);var uc=e=>e.chartData,Kx=bt([uc],e=>{var r=e.chartData!=null?e.chartData.length-1:0;return{chartData:e.chartData,computedData:e.computedData,dataEndIndex:r,dataStartIndex:0}}),$w=(e,r,a,s)=>s?Kx(e):uc(e),mpe=(e,r,a)=>a?Kx(e):uc(e),hpe=bt([$w],e=>{var{chartData:r,dataStartIndex:a,dataEndIndex:s}=e;return r!=null?r.slice(a,s+1):[]}),ppe=bt([Kx],e=>{var{chartData:r,dataStartIndex:a,dataEndIndex:s}=e;return r!=null?r.slice(a,s+1):[]}),gpe=bt([uc],e=>{var{chartData:r,dataStartIndex:a,dataEndIndex:s}=e;return r!=null?r.slice(a,s+1):[]});function Lc(e){if(Array.isArray(e)&&e.length===2){var[r,a]=e;if(ja(r)&&ja(a))return!0}return!1}function bO(e,r,a){return a?e:[Math.min(e[0],r[0]),Math.max(e[1],r[1])]}function II(e,r){if(r&&typeof e!="function"&&Array.isArray(e)&&e.length===2){var[a,s]=e,n,i;if(ja(a))n=a;else if(typeof a=="function")return;if(ja(s))i=s;else if(typeof s=="function")return;var o=[n,i];if(Lc(o))return o}}function fpe(e,r,a){if(!(!a&&r==null)){if(typeof e=="function"&&r!=null)try{var s=e(r,a);if(Lc(s))return bO(s,r,a)}catch(b){}if(Array.isArray(e)&&e.length===2){var[n,i]=e,o,l;if(n==="auto")r!=null&&(o=Math.min(...r));else if(_r(n))o=n;else if(typeof n=="function")try{r!=null&&(o=n(r==null?void 0:r[0]))}catch(b){}else if(typeof n=="string"&&lA.test(n)){var c=lA.exec(n);if(c==null||c[1]==null||r==null)o=void 0;else{var u=+c[1];o=r[0]-u}}else o=r==null?void 0:r[0];if(i==="auto")r!=null&&(l=Math.max(...r));else if(_r(i))l=i;else if(typeof i=="function")try{r!=null&&(l=i(r==null?void 0:r[1]))}catch(b){}else if(typeof i=="string"&&cA.test(i)){var h=cA.exec(i);if(h==null||h[1]==null||r==null)l=void 0;else{var f=+h[1];l=r[1]+f}}else l=r==null?void 0:r[1];var y=[o,l];if(Lc(y))return r==null?y:bO(y,r,a)}}}var Zp=1e9,xpe={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},i3,Ss=!0,vl="[DecimalError] ",pm=vl+"Invalid argument: ",n3=vl+"Exponent out of range: ",Xp=Math.floor,K0=Math.pow,ype=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,zo,Pn=1e7,bs=7,zI=9007199254740991,b1=Xp(zI/bs),fr={};fr.absoluteValue=fr.abs=function(){var e=new this.constructor(this);return e.s&&(e.s=1),e};fr.comparedTo=fr.cmp=function(e){var r,a,s,n,i=this;if(e=new i.constructor(e),i.s!==e.s)return i.s||-e.s;if(i.e!==e.e)return i.e>e.e^i.s<0?1:-1;for(s=i.d.length,n=e.d.length,r=0,a=s<n?s:n;r<a;++r)if(i.d[r]!==e.d[r])return i.d[r]>e.d[r]^i.s<0?1:-1;return s===n?0:s>n^i.s<0?1:-1};fr.decimalPlaces=fr.dp=function(){var e=this,r=e.d.length-1,a=(r-e.e)*bs;if(r=e.d[r],r)for(;r%10==0;r/=10)a--;return a<0?0:a};fr.dividedBy=fr.div=function(e){return Hd(this,new this.constructor(e))};fr.dividedToIntegerBy=fr.idiv=function(e){var r=this,a=r.constructor;return cs(Hd(r,new a(e),0,1),a.precision)};fr.equals=fr.eq=function(e){return!this.cmp(e)};fr.exponent=function(){return cn(this)};fr.greaterThan=fr.gt=function(e){return this.cmp(e)>0};fr.greaterThanOrEqualTo=fr.gte=function(e){return this.cmp(e)>=0};fr.isInteger=fr.isint=function(){return this.e>this.d.length-2};fr.isNegative=fr.isneg=function(){return this.s<0};fr.isPositive=fr.ispos=function(){return this.s>0};fr.isZero=function(){return this.s===0};fr.lessThan=fr.lt=function(e){return this.cmp(e)<0};fr.lessThanOrEqualTo=fr.lte=function(e){return this.cmp(e)<1};fr.logarithm=fr.log=function(e){var r,a=this,s=a.constructor,n=s.precision,i=n+5;if(e===void 0)e=new s(10);else if(e=new s(e),e.s<1||e.eq(zo))throw Error(vl+"NaN");if(a.s<1)throw Error(vl+(a.s?"NaN":"-Infinity"));return a.eq(zo)?new s(0):(Ss=!1,r=Hd(ux(a,i),ux(e,i),i),Ss=!0,cs(r,n))};fr.minus=fr.sub=function(e){var r=this;return e=new r.constructor(e),r.s==e.s?BI(r,e):$I(r,(e.s=-e.s,e))};fr.modulo=fr.mod=function(e){var r,a=this,s=a.constructor,n=s.precision;if(e=new s(e),!e.s)throw Error(vl+"NaN");return a.s?(Ss=!1,r=Hd(a,e,0,1).times(e),Ss=!0,a.minus(r)):cs(new s(a),n)};fr.naturalExponential=fr.exp=function(){return UI(this)};fr.naturalLogarithm=fr.ln=function(){return ux(this)};fr.negated=fr.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e};fr.plus=fr.add=function(e){var r=this;return e=new r.constructor(e),r.s==e.s?$I(r,e):BI(r,(e.s=-e.s,e))};fr.precision=fr.sd=function(e){var r,a,s,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(pm+e);if(r=cn(n)+1,s=n.d.length-1,a=s*bs+1,s=n.d[s],s){for(;s%10==0;s/=10)a--;for(s=n.d[0];s>=10;s/=10)a++}return e&&r>a?r:a};fr.squareRoot=fr.sqrt=function(){var e,r,a,s,n,i,o,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(vl+"NaN")}for(e=cn(l),Ss=!1,n=Math.sqrt(+l),n==0||n==1/0?(r=Mc(l.d),(r.length+e)%2==0&&(r+="0"),n=Math.sqrt(r),e=Xp((e+1)/2)-(e<0||e%2),n==1/0?r="5e"+e:(r=n.toExponential(),r=r.slice(0,r.indexOf("e")+1)+e),s=new c(r)):s=new c(n.toString()),a=c.precision,n=o=a+3;;)if(i=s,s=i.plus(Hd(l,i,o+2)).times(.5),Mc(i.d).slice(0,o)===(r=Mc(s.d)).slice(0,o)){if(r=r.slice(o-3,o+1),n==o&&r=="4999"){if(cs(i,a+1,0),i.times(i).eq(l)){s=i;break}}else if(r!="9999")break;o+=4}return Ss=!0,cs(s,a)};fr.times=fr.mul=function(e){var r,a,s,n,i,o,l,c,u,h=this,f=h.constructor,y=h.d,b=(e=new f(e)).d;if(!h.s||!e.s)return new f(0);for(e.s*=h.s,a=h.e+e.e,c=y.length,u=b.length,c<u&&(i=y,y=b,b=i,o=c,c=u,u=o),i=[],o=c+u,s=o;s--;)i.push(0);for(s=u;--s>=0;){for(r=0,n=c+s;n>s;)l=i[n]+b[s]*y[n-s-1]+r,i[n--]=l%Pn|0,r=l/Pn|0;i[n]=(i[n]+r)%Pn|0}for(;!i[--o];)i.pop();return r?++a:i.shift(),e.d=i,e.e=a,Ss?cs(e,f.precision):e};fr.toDecimalPlaces=fr.todp=function(e,r){var a=this,s=a.constructor;return a=new s(a),e===void 0?a:(Wc(e,0,Zp),r===void 0?r=s.rounding:Wc(r,0,8),cs(a,e+cn(a)+1,r))};fr.toExponential=function(e,r){var a,s=this,n=s.constructor;return e===void 0?a=Pm(s,!0):(Wc(e,0,Zp),r===void 0?r=n.rounding:Wc(r,0,8),s=cs(new n(s),e+1,r),a=Pm(s,!0,e+1)),a};fr.toFixed=function(e,r){var a,s,n=this,i=n.constructor;return e===void 0?Pm(n):(Wc(e,0,Zp),r===void 0?r=i.rounding:Wc(r,0,8),s=cs(new i(n),e+cn(n)+1,r),a=Pm(s.abs(),!1,e+cn(s)+1),n.isneg()&&!n.isZero()?"-"+a:a)};fr.toInteger=fr.toint=function(){var e=this,r=e.constructor;return cs(new r(e),cn(e)+1,r.rounding)};fr.toNumber=function(){return+this};fr.toPower=fr.pow=function(e){var r,a,s,n,i,o,l=this,c=l.constructor,u=12,h=+(e=new c(e));if(!e.s)return new c(zo);if(l=new c(l),!l.s){if(e.s<1)throw Error(vl+"Infinity");return l}if(l.eq(zo))return l;if(s=c.precision,e.eq(zo))return cs(l,s);if(r=e.e,a=e.d.length-1,o=r>=a,i=l.s,o){if((a=h<0?-h:h)<=zI){for(n=new c(zo),r=Math.ceil(s/bs+4),Ss=!1;a%2&&(n=n.times(l),wO(n.d,r)),a=Xp(a/2),a!==0;)l=l.times(l),wO(l.d,r);return Ss=!0,e.s<0?new c(zo).div(n):cs(n,s)}}else if(i<0)throw Error(vl+"NaN");return i=i<0&&e.d[Math.max(r,a)]&1?-1:1,l.s=1,Ss=!1,n=e.times(ux(l,s+u)),Ss=!0,n=UI(n),n.s=i,n};fr.toPrecision=function(e,r){var a,s,n=this,i=n.constructor;return e===void 0?(a=cn(n),s=Pm(n,a<=i.toExpNeg||a>=i.toExpPos)):(Wc(e,1,Zp),r===void 0?r=i.rounding:Wc(r,0,8),n=cs(new i(n),e,r),a=cn(n),s=Pm(n,e<=a||a<=i.toExpNeg,e)),s};fr.toSignificantDigits=fr.tosd=function(e,r){var a=this,s=a.constructor;return e===void 0?(e=s.precision,r=s.rounding):(Wc(e,1,Zp),r===void 0?r=s.rounding:Wc(r,0,8)),cs(new s(a),e,r)};fr.toString=fr.valueOf=fr.val=fr.toJSON=fr[Symbol.for("nodejs.util.inspect.custom")]=function(){var e=this,r=cn(e),a=e.constructor;return Pm(e,r<=a.toExpNeg||r>=a.toExpPos)};function $I(e,r){var a,s,n,i,o,l,c,u,h=e.constructor,f=h.precision;if(!e.s||!r.s)return r.s||(r=new h(e)),Ss?cs(r,f):r;if(c=e.d,u=r.d,o=e.e,n=r.e,c=c.slice(),i=o-n,i){for(i<0?(s=c,i=-i,l=u.length):(s=u,n=o,l=c.length),o=Math.ceil(f/bs),l=o>l?o+1:l+1,i>l&&(i=l,s.length=1),s.reverse();i--;)s.push(0);s.reverse()}for(l=c.length,i=u.length,l-i<0&&(i=l,s=u,u=c,c=s),a=0;i;)a=(c[--i]=c[i]+u[i]+a)/Pn|0,c[i]%=Pn;for(a&&(c.unshift(a),++n),l=c.length;c[--l]==0;)c.pop();return r.d=c,r.e=n,Ss?cs(r,f):r}function Wc(e,r,a){if(e!==~~e||e<r||e>a)throw Error(pm+e)}function Mc(e){var r,a,s,n=e.length-1,i="",o=e[0];if(n>0){for(i+=o,r=1;r<n;r++)s=e[r]+"",a=bs-s.length,a&&(i+=zu(a)),i+=s;o=e[r],s=o+"",a=bs-s.length,a&&(i+=zu(a))}else if(o===0)return"0";for(;o%10===0;)o/=10;return i+o}var Hd=(function(){function e(s,n){var i,o=0,l=s.length;for(s=s.slice();l--;)i=s[l]*n+o,s[l]=i%Pn|0,o=i/Pn|0;return o&&s.unshift(o),s}function r(s,n,i,o){var l,c;if(i!=o)c=i>o?1:-1;else for(l=c=0;l<i;l++)if(s[l]!=n[l]){c=s[l]>n[l]?1:-1;break}return c}function a(s,n,i){for(var o=0;i--;)s[i]-=o,o=s[i]<n[i]?1:0,s[i]=o*Pn+s[i]-n[i];for(;!s[0]&&s.length>1;)s.shift()}return function(s,n,i,o){var l,c,u,h,f,y,b,w,v,k,S,N,C,O,T,P,E,R,z=s.constructor,G=s.s==n.s?1:-1,ae=s.d,ee=n.d;if(!s.s)return new z(s);if(!n.s)throw Error(vl+"Division by zero");for(c=s.e-n.e,E=ee.length,T=ae.length,b=new z(G),w=b.d=[],u=0;ee[u]==(ae[u]||0);)++u;if(ee[u]>(ae[u]||0)&&--c,i==null?N=i=z.precision:o?N=i+(cn(s)-cn(n))+1:N=i,N<0)return new z(0);if(N=N/bs+2|0,u=0,E==1)for(h=0,ee=ee[0],N++;(u<T||h)&&N--;u++)C=h*Pn+(ae[u]||0),w[u]=C/ee|0,h=C%ee|0;else{for(h=Pn/(ee[0]+1)|0,h>1&&(ee=e(ee,h),ae=e(ae,h),E=ee.length,T=ae.length),O=E,v=ae.slice(0,E),k=v.length;k<E;)v[k++]=0;R=ee.slice(),R.unshift(0),P=ee[0],ee[1]>=Pn/2&&++P;do h=0,l=r(ee,v,E,k),l<0?(S=v[0],E!=k&&(S=S*Pn+(v[1]||0)),h=S/P|0,h>1?(h>=Pn&&(h=Pn-1),f=e(ee,h),y=f.length,k=v.length,l=r(f,v,y,k),l==1&&(h--,a(f,E<y?R:ee,y))):(h==0&&(l=h=1),f=ee.slice()),y=f.length,y<k&&f.unshift(0),a(v,f,k),l==-1&&(k=v.length,l=r(ee,v,E,k),l<1&&(h++,a(v,E<k?R:ee,k))),k=v.length):l===0&&(h++,v=[0]),w[u++]=h,l&&v[0]?v[k++]=ae[O]||0:(v=[ae[O]],k=1);while((O++<T||v[0]!==void 0)&&N--)}return w[0]||w.shift(),b.e=c,cs(b,o?i+cn(b)+1:i)}})();function UI(e,r){var a,s,n,i,o,l,c=0,u=0,h=e.constructor,f=h.precision;if(cn(e)>16)throw Error(n3+cn(e));if(!e.s)return new h(zo);for(Ss=!1,l=f,o=new h(.03125);e.abs().gte(.1);)e=e.times(o),u+=5;for(s=Math.log(K0(2,u))/Math.LN10*2+5|0,l+=s,a=n=i=new h(zo),h.precision=l;;){if(n=cs(n.times(e),l),a=a.times(++c),o=i.plus(Hd(n,a,l)),Mc(o.d).slice(0,l)===Mc(i.d).slice(0,l)){for(;u--;)i=cs(i.times(i),l);return h.precision=f,r==null?(Ss=!0,cs(i,f)):i}i=o}}function cn(e){for(var r=e.e*bs,a=e.d[0];a>=10;a/=10)r++;return r}function F2(e,r,a){if(r>e.LN10.sd())throw Ss=!0,a&&(e.precision=a),Error(vl+"LN10 precision limit exceeded");return cs(new e(e.LN10),r)}function zu(e){for(var r="";e--;)r+="0";return r}function ux(e,r){var a,s,n,i,o,l,c,u,h,f=1,y=10,b=e,w=b.d,v=b.constructor,k=v.precision;if(b.s<1)throw Error(vl+(b.s?"NaN":"-Infinity"));if(b.eq(zo))return new v(0);if(r==null?(Ss=!1,u=k):u=r,b.eq(10))return r==null&&(Ss=!0),F2(v,u);if(u+=y,v.precision=u,a=Mc(w),s=a.charAt(0),i=cn(b),Math.abs(i)<15e14){for(;s<7&&s!=1||s==1&&a.charAt(1)>3;)b=b.times(e),a=Mc(b.d),s=a.charAt(0),f++;i=cn(b),s>1?(b=new v("0."+a),i++):b=new v(s+"."+a.slice(1))}else return c=F2(v,u+2,k).times(i+""),b=ux(new v(s+"."+a.slice(1)),u-y).plus(c),v.precision=k,r==null?(Ss=!0,cs(b,k)):b;for(l=o=b=Hd(b.minus(zo),b.plus(zo),u),h=cs(b.times(b),u),n=3;;){if(o=cs(o.times(h),u),c=l.plus(Hd(o,new v(n),u)),Mc(c.d).slice(0,u)===Mc(l.d).slice(0,u))return l=l.times(2),i!==0&&(l=l.plus(F2(v,u+2,k).times(i+""))),l=Hd(l,new v(f),u),v.precision=k,r==null?(Ss=!0,cs(l,k)):l;l=c,n+=2}}function vO(e,r){var a,s,n;for((a=r.indexOf("."))>-1&&(r=r.replace(".","")),(s=r.search(/e/i))>0?(a<0&&(a=s),a+=+r.slice(s+1),r=r.substring(0,s)):a<0&&(a=r.length),s=0;r.charCodeAt(s)===48;)++s;for(n=r.length;r.charCodeAt(n-1)===48;)--n;if(r=r.slice(s,n),r){if(n-=s,a=a-s-1,e.e=Xp(a/bs),e.d=[],s=(a+1)%bs,a<0&&(s+=bs),s<n){for(s&&e.d.push(+r.slice(0,s)),n-=bs;s<n;)e.d.push(+r.slice(s,s+=bs));r=r.slice(s),s=bs-r.length}else s-=n;for(;s--;)r+="0";if(e.d.push(+r),Ss&&(e.e>b1||e.e<-b1))throw Error(n3+a)}else e.s=0,e.e=0,e.d=[0];return e}function cs(e,r,a){var s,n,i,o,l,c,u,h,f=e.d;for(o=1,i=f[0];i>=10;i/=10)o++;if(s=r-o,s<0)s+=bs,n=r,u=f[h=0];else{if(h=Math.ceil((s+1)/bs),i=f.length,h>=i)return e;for(u=i=f[h],o=1;i>=10;i/=10)o++;s%=bs,n=s-bs+o}if(a!==void 0&&(i=K0(10,o-n-1),l=u/i%10|0,c=r<0||f[h+1]!==void 0||u%i,c=a<4?(l||c)&&(a==0||a==(e.s<0?3:2)):l>5||l==5&&(a==4||c||a==6&&(s>0?n>0?u/K0(10,o-n):0:f[h-1])%10&1||a==(e.s<0?8:7))),r<1||!f[0])return c?(i=cn(e),f.length=1,r=r-i-1,f[0]=K0(10,(bs-r%bs)%bs),e.e=Xp(-r/bs)||0):(f.length=1,f[0]=e.e=e.s=0),e;if(s==0?(f.length=h,i=1,h--):(f.length=h+1,i=K0(10,bs-s),f[h]=n>0?(u/K0(10,o-n)%K0(10,n)|0)*i:0),c)for(;;)if(h==0){(f[0]+=i)==Pn&&(f[0]=1,++e.e);break}else{if(f[h]+=i,f[h]!=Pn)break;f[h--]=0,i=1}for(s=f.length;f[--s]===0;)f.pop();if(Ss&&(e.e>b1||e.e<-b1))throw Error(n3+cn(e));return e}function BI(e,r){var a,s,n,i,o,l,c,u,h,f,y=e.constructor,b=y.precision;if(!e.s||!r.s)return r.s?r.s=-r.s:r=new y(e),Ss?cs(r,b):r;if(c=e.d,f=r.d,s=r.e,u=e.e,c=c.slice(),o=u-s,o){for(h=o<0,h?(a=c,o=-o,l=f.length):(a=f,s=u,l=c.length),n=Math.max(Math.ceil(b/bs),l)+2,o>n&&(o=n,a.length=1),a.reverse(),n=o;n--;)a.push(0);a.reverse()}else{for(n=c.length,l=f.length,h=n<l,h&&(l=n),n=0;n<l;n++)if(c[n]!=f[n]){h=c[n]<f[n];break}o=0}for(h&&(a=c,c=f,f=a,r.s=-r.s),l=c.length,n=f.length-l;n>0;--n)c[l++]=0;for(n=f.length;n>o;){if(c[--n]<f[n]){for(i=n;i&&c[--i]===0;)c[i]=Pn-1;--c[i],c[n]+=Pn}c[n]-=f[n]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--s;return c[0]?(r.d=c,r.e=s,Ss?cs(r,b):r):new y(0)}function Pm(e,r,a){var s,n=cn(e),i=Mc(e.d),o=i.length;return r?(a&&(s=a-o)>0?i=i.charAt(0)+"."+i.slice(1)+zu(s):o>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(n<0?"e":"e+")+n):n<0?(i="0."+zu(-n-1)+i,a&&(s=a-o)>0&&(i+=zu(s))):n>=o?(i+=zu(n+1-o),a&&(s=a-n-1)>0&&(i=i+"."+zu(s))):((s=n+1)<o&&(i=i.slice(0,s)+"."+i.slice(s)),a&&(s=a-o)>0&&(n+1===o&&(i+="."),i+=zu(s))),e.s<0?"-"+i:i}function wO(e,r){if(e.length>r)return e.length=r,!0}function WI(e){var r,a,s;function n(i){var o=this;if(!(o instanceof n))return new n(i);if(o.constructor=n,i instanceof n){o.s=i.s,o.e=i.e,o.d=(i=i.d)?i.slice():i;return}if(typeof i=="number"){if(i*0!==0)throw Error(pm+i);if(i>0)o.s=1;else if(i<0)i=-i,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(i===~~i&&i<1e7){o.e=0,o.d=[i];return}return vO(o,i.toString())}else if(typeof i!="string")throw Error(pm+i);if(i.charCodeAt(0)===45?(i=i.slice(1),o.s=-1):o.s=1,ype.test(i))vO(o,i);else throw Error(pm+i)}if(n.prototype=fr,n.ROUND_UP=0,n.ROUND_DOWN=1,n.ROUND_CEIL=2,n.ROUND_FLOOR=3,n.ROUND_HALF_UP=4,n.ROUND_HALF_DOWN=5,n.ROUND_HALF_EVEN=6,n.ROUND_HALF_CEIL=7,n.ROUND_HALF_FLOOR=8,n.clone=WI,n.config=n.set=bpe,e===void 0&&(e={}),e)for(s=["precision","rounding","toExpNeg","toExpPos","LN10"],r=0;r<s.length;)e.hasOwnProperty(a=s[r++])||(e[a]=this[a]);return n.config(e),n}function bpe(e){if(!e||typeof e!="object")throw Error(vl+"Object expected");var r,a,s,n=["precision",1,Zp,"rounding",0,8,"toExpNeg",-1/0,0,"toExpPos",0,1/0];for(r=0;r<n.length;r+=3)if((s=e[a=n[r]])!==void 0)if(Xp(s)===s&&s>=n[r+1]&&s<=n[r+2])this[a]=s;else throw Error(pm+a+": "+s);if((s=e[a="LN10"])!==void 0)if(s==Math.LN10)this[a]=new this(s);else throw Error(pm+a+": "+s);return this}var i3=WI(xpe);zo=new i3(1);const wa=i3;function HI(e){var r;return e===0?r=1:r=Math.floor(new wa(e).abs().log(10).toNumber())+1,r}function qI(e,r,a){for(var s=new wa(e),n=0,i=[];s.lt(r)&&n<1e5;)i.push(s.toNumber()),s=s.add(a),n++;return i}var VI=e=>{var[r,a]=e,[s,n]=[r,a];return r>a&&([s,n]=[a,r]),[s,n]},o3=(e,r,a)=>{if(e.lte(0))return new wa(0);var s=HI(e.toNumber()),n=new wa(10).pow(s),i=e.div(n),o=s!==1?.05:.1,l=new wa(Math.ceil(i.div(o).toNumber())).add(a).mul(o),c=l.mul(n);return r?new wa(c.toNumber()):new wa(Math.ceil(c.toNumber()))},GI=(e,r,a)=>{var s;if(e.lte(0))return new wa(0);var n=[1,2,2.5,5],i=e.toNumber(),o=Math.floor(new wa(i).abs().log(10).toNumber()),l=new wa(10).pow(o),c=e.div(l).toNumber(),u=n.findIndex(b=>b>=c-1e-10);if(u===-1&&(l=l.mul(10),u=0),u+=a,u>=n.length){var h=Math.floor(u/n.length);u%=n.length,l=l.mul(new wa(10).pow(h))}var f=(s=n[u])!==null&&s!==void 0?s:1,y=new wa(f).mul(l);return r?y:new wa(Math.ceil(y.toNumber()))},vpe=(e,r,a)=>{var s=new wa(1),n=new wa(e);if(!n.isint()&&a){var i=Math.abs(e);i<1?(s=new wa(10).pow(HI(e)-1),n=new wa(Math.floor(n.div(s).toNumber())).mul(s)):i>1&&(n=new wa(Math.floor(e)))}else e===0?n=new wa(Math.floor((r-1)/2)):a||(n=new wa(Math.floor(e)));for(var o=Math.floor((r-1)/2),l=[],c=0;c<r;c++)l.push(n.add(new wa(c-o).mul(s)).toNumber());return l},KI=function(r,a,s,n){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0,o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:o3;if(!Number.isFinite((a-r)/(s-1)))return{step:new wa(0),tickMin:new wa(0),tickMax:new wa(0)};var l=o(new wa(a).sub(r).div(s-1),n,i),c;r<=0&&a>=0?c=new wa(0):(c=new wa(r).add(a).div(2),c=c.sub(new wa(c).mod(l)));var u=Math.ceil(c.sub(r).div(l).toNumber()),h=Math.ceil(new wa(a).sub(c).div(l).toNumber()),f=u+h+1;return f>s?KI(r,a,s,n,i+1,o):(f<s&&(h=a>0?h+(s-f):h,u=a>0?u:u+(s-f)),{step:l,tickMin:c.sub(new wa(u).mul(l)),tickMax:c.add(new wa(h).mul(l))})},jO=function(r){var[a,s]=r,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"auto",l=Math.max(n,2),[c,u]=VI([a,s]);if(c===-1/0||u===1/0){var h=u===1/0?[c,...Array(n-1).fill(1/0)]:[...Array(n-1).fill(-1/0),u];return a>s?h.reverse():h}if(c===u)return vpe(c,n,i);var f=o==="snap125"?GI:o3,{step:y,tickMin:b,tickMax:w}=KI(c,u,l,i,0,f),v=qI(b,w.add(new wa(.1).mul(y)),y);return a>s?v.reverse():v},_O=function(r,a){var[s,n]=r,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"auto",[l,c]=VI([s,n]);if(l===-1/0||c===1/0)return[s,n];if(l===c)return[l];var u=o==="snap125"?GI:o3,h=Math.max(a,2),f=u(new wa(c).sub(l).div(h-1),i,0),y=[...qI(new wa(l),new wa(c),f),c];return i===!1&&(y=y.map(b=>Math.round(b))),s>n?y.reverse():y},YI=e=>e.rootProps.maxBarSize,wpe=e=>e.rootProps.barGap,JI=e=>e.rootProps.barCategoryGap,jpe=e=>e.rootProps.barSize,Yx=e=>e.rootProps.stackOffset,ZI=e=>e.rootProps.reverseStackOrder,l3=e=>e.options.chartName,c3=e=>e.rootProps.syncId,XI=e=>e.rootProps.syncMethod,d3=e=>e.options.eventEmitter,ri={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},R0={allowDecimals:!1,allowDataOverflow:!1,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"auto"},Sc={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!0,includeHidden:!1,radiusAxisId:0,reversed:!1,scale:"auto",tick:!0,tickCount:5,type:"auto"},Uw=(e,r)=>{if(!(!e||!r))return e!=null&&e.reversed?[r[1],r[0]]:r};function Bw(e,r,a){if(a!=="auto")return a;if(e!=null)return i0(e,r)?"category":"number"}function kO(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function v1(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?kO(Object(a),!0).forEach(function(s){_pe(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):kO(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function _pe(e,r,a){return(r=kpe(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function kpe(e){var r=Npe(e,"string");return typeof r=="symbol"?r:r+""}function Npe(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var NO={allowDataOverflow:R0.allowDataOverflow,allowDecimals:R0.allowDecimals,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:R0.angleAxisId,includeHidden:!1,name:void 0,reversed:R0.reversed,scale:R0.scale,tick:R0.tick,tickCount:void 0,ticks:void 0,type:R0.type,unit:void 0,niceTicks:"auto"},SO={allowDataOverflow:Sc.allowDataOverflow,allowDecimals:Sc.allowDecimals,allowDuplicatedCategory:Sc.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Sc.radiusAxisId,includeHidden:Sc.includeHidden,name:void 0,reversed:Sc.reversed,scale:Sc.scale,tick:Sc.tick,tickCount:Sc.tickCount,ticks:void 0,type:Sc.type,unit:void 0,niceTicks:"auto"},Spe=(e,r)=>{if(r!=null)return e.polarAxis.angleAxis[r]},u3=bt([Spe,gI],(e,r)=>{var a;if(e!=null)return e;var s=(a=Bw(r,"angleAxis",NO.type))!==null&&a!==void 0?a:"category";return v1(v1({},NO),{},{type:s})}),Cpe=(e,r)=>e.polarAxis.radiusAxis[r],m3=bt([Cpe,gI],(e,r)=>{var a;if(e!=null)return e;var s=(a=Bw(r,"radiusAxis",SO.type))!==null&&a!==void 0?a:"category";return v1(v1({},SO),{},{type:s})}),Ww=e=>e.polarOptions,h3=bt([su,nu,kn],DI),QI=bt([Ww,h3],(e,r)=>{if(e!=null)return xi(e.innerRadius,r,0)}),ez=bt([Ww,h3],(e,r)=>{if(e!=null)return xi(e.outerRadius,r,r*.8)}),Tpe=e=>{if(e==null)return[0,0];var{startAngle:r,endAngle:a}=e;return[r,a]},tz=bt([Ww],Tpe);bt([u3,tz],Uw);var rz=bt([h3,QI,ez],(e,r,a)=>{if(!(e==null||r==null||a==null))return[r,a]});bt([m3,rz],Uw);var az=bt([Ua,Ww,QI,ez,su,nu],(e,r,a,s,n,i)=>{if(!(e!=="centric"&&e!=="radial"||r==null||a==null||s==null)){var{cx:o,cy:l,startAngle:c,endAngle:u}=r;return{cx:xi(o,n,n/2),cy:xi(l,i,i/2),innerRadius:a,outerRadius:s,startAngle:c,endAngle:u,clockWise:!1}}}),Ds=(e,r)=>r,Jx=(e,r,a)=>a;function p3(e){return e==null?void 0:e.id}function sz(e,r,a){var{chartData:s=[]}=r,{allowDuplicatedCategory:n,dataKey:i}=a,o=new Map;return e.forEach(l=>{var c,u=(c=l.data)!==null&&c!==void 0?c:s;if(!(u==null||u.length===0)){var h=p3(l);u.forEach((f,y)=>{var b=i==null||n?y:String(ls(f,i,null)),w=ls(f,l.dataKey,0),v;o.has(b)?v=o.get(b):v={},Object.assign(v,{[h]:w}),o.set(b,v)})}}),Array.from(o.values())}function Hw(e){return"stackId"in e&&e.stackId!=null&&e.dataKey!=null}var qw=(e,r)=>e===r?!0:e==null||r==null?!1:e[0]===r[0]&&e[1]===r[1];function Vw(e,r){return Array.isArray(e)&&Array.isArray(r)&&e.length===0&&r.length===0?!0:e===r}function Epe(e,r){if(e.length===r.length){for(var a=0;a<e.length;a++)if(e[a]!==r[a])return!1;return!0}return!1}var zn=e=>{var r=Ua(e);return r==="horizontal"?"xAxis":r==="vertical"?"yAxis":r==="centric"?"angleAxis":"radiusAxis"},Qp=e=>e.tooltip.settings.axisId;function g3(e){if(e!=null){var r=e.ticks,a=e.bandwidth,s=e.range(),n=[Math.min(...s),Math.max(...s)];return{domain:()=>e.domain(),range:(function(i){function o(){return i.apply(this,arguments)}return o.toString=function(){return i.toString()},o})(()=>n),rangeMin:()=>n[0],rangeMax:()=>n[1],isInRange(i){var o=n[0],l=n[1];return o<=l?i>=o&&i<=l:i>=l&&i<=o},bandwidth:a?()=>a.call(e):void 0,ticks:r?i=>r.call(e,i):void 0,map:(i,o)=>{var l=e(i);if(l!=null){if(e.bandwidth&&o!==null&&o!==void 0&&o.position){var c=e.bandwidth();switch(o.position){case"middle":l+=c/2;break;case"end":l+=c;break}}return l}}}}}var nz=(e,r)=>{if(r!=null)switch(e){case"linear":{if(!Lc(r)){for(var a,s,n=0;n<r.length;n++){var i=r[n];ja(i)&&((a===void 0||i<a)&&(a=i),(s===void 0||i>s)&&(s=i))}return a!==void 0&&s!==void 0?[a,s]:void 0}return r}default:return r}};function Ku(e,r){return e==null||r==null?NaN:e<r?-1:e>r?1:e>=r?0:NaN}function Ape(e,r){return e==null||r==null?NaN:r<e?-1:r>e?1:r>=e?0:NaN}function f3(e){let r,a,s;e.length!==2?(r=Ku,a=(l,c)=>Ku(e(l),c),s=(l,c)=>e(l)-c):(r=e===Ku||e===Ape?e:Ope,a=e,s=e);function n(l,c,u=0,h=l.length){if(u<h){if(r(c,c)!==0)return h;do{const f=u+h>>>1;a(l[f],c)<0?u=f+1:h=f}while(u<h)}return u}function i(l,c,u=0,h=l.length){if(u<h){if(r(c,c)!==0)return h;do{const f=u+h>>>1;a(l[f],c)<=0?u=f+1:h=f}while(u<h)}return u}function o(l,c,u=0,h=l.length){const f=n(l,c,u,h-1);return f>u&&s(l[f-1],c)>-s(l[f],c)?f-1:f}return{left:n,center:o,right:i}}function Ope(){return 0}function iz(e){return e===null?NaN:+e}function*Ppe(e,r){for(let a of e)a!=null&&(a=+a)>=a&&(yield a)}const Dpe=f3(Ku),Zx=Dpe.right;f3(iz).center;class CO extends Map{constructor(r,a=Lpe){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:a}}),r!=null)for(const[s,n]of r)this.set(s,n)}get(r){return super.get(TO(this,r))}has(r){return super.has(TO(this,r))}set(r,a){return super.set(Rpe(this,r),a)}delete(r){return super.delete(Mpe(this,r))}}function TO({_intern:e,_key:r},a){const s=r(a);return e.has(s)?e.get(s):a}function Rpe({_intern:e,_key:r},a){const s=r(a);return e.has(s)?e.get(s):(e.set(s,a),a)}function Mpe({_intern:e,_key:r},a){const s=r(a);return e.has(s)&&(a=e.get(s),e.delete(s)),a}function Lpe(e){return e!==null&&typeof e=="object"?e.valueOf():e}function Fpe(e=Ku){if(e===Ku)return oz;if(typeof e!="function")throw new TypeError("compare is not a function");return(r,a)=>{const s=e(r,a);return s||s===0?s:(e(a,a)===0)-(e(r,r)===0)}}function oz(e,r){return(e==null||!(e>=e))-(r==null||!(r>=r))||(e<r?-1:e>r?1:0)}const Ipe=Math.sqrt(50),zpe=Math.sqrt(10),$pe=Math.sqrt(2);function w1(e,r,a){const s=(r-e)/Math.max(0,a),n=Math.floor(Math.log10(s)),i=s/Math.pow(10,n),o=i>=Ipe?10:i>=zpe?5:i>=$pe?2:1;let l,c,u;return n<0?(u=Math.pow(10,-n)/o,l=Math.round(e*u),c=Math.round(r*u),l/u<e&&++l,c/u>r&&--c,u=-u):(u=Math.pow(10,n)*o,l=Math.round(e/u),c=Math.round(r/u),l*u<e&&++l,c*u>r&&--c),c<l&&.5<=a&&a<2?w1(e,r,a*2):[l,c,u]}function h4(e,r,a){if(r=+r,e=+e,a=+a,!(a>0))return[];if(e===r)return[e];const s=r<e,[n,i,o]=s?w1(r,e,a):w1(e,r,a);if(!(i>=n))return[];const l=i-n+1,c=new Array(l);if(s)if(o<0)for(let u=0;u<l;++u)c[u]=(i-u)/-o;else for(let u=0;u<l;++u)c[u]=(i-u)*o;else if(o<0)for(let u=0;u<l;++u)c[u]=(n+u)/-o;else for(let u=0;u<l;++u)c[u]=(n+u)*o;return c}function p4(e,r,a){return r=+r,e=+e,a=+a,w1(e,r,a)[2]}function g4(e,r,a){r=+r,e=+e,a=+a;const s=r<e,n=s?p4(r,e,a):p4(e,r,a);return(s?-1:1)*(n<0?1/-n:n)}function EO(e,r){let a;for(const s of e)s!=null&&(a<s||a===void 0&&s>=s)&&(a=s);return a}function AO(e,r){let a;for(const s of e)s!=null&&(a>s||a===void 0&&s>=s)&&(a=s);return a}function lz(e,r,a=0,s=1/0,n){if(r=Math.floor(r),a=Math.floor(Math.max(0,a)),s=Math.floor(Math.min(e.length-1,s)),!(a<=r&&r<=s))return e;for(n=n===void 0?oz:Fpe(n);s>a;){if(s-a>600){const c=s-a+1,u=r-a+1,h=Math.log(c),f=.5*Math.exp(2*h/3),y=.5*Math.sqrt(h*f*(c-f)/c)*(u-c/2<0?-1:1),b=Math.max(a,Math.floor(r-u*f/c+y)),w=Math.min(s,Math.floor(r+(c-u)*f/c+y));lz(e,r,b,w,n)}const i=e[r];let o=a,l=s;for(cf(e,a,r),n(e[s],i)>0&&cf(e,a,s);o<l;){for(cf(e,o,l),++o,--l;n(e[o],i)<0;)++o;for(;n(e[l],i)>0;)--l}n(e[a],i)===0?cf(e,a,l):(++l,cf(e,l,s)),l<=r&&(a=l+1),r<=l&&(s=l-1)}return e}function cf(e,r,a){const s=e[r];e[r]=e[a],e[a]=s}function Upe(e,r,a){if(e=Float64Array.from(Ppe(e)),!(!(s=e.length)||isNaN(r=+r))){if(r<=0||s<2)return AO(e);if(r>=1)return EO(e);var s,n=(s-1)*r,i=Math.floor(n),o=EO(lz(e,i).subarray(0,i+1)),l=AO(e.subarray(i+1));return o+(l-o)*(n-i)}}function Bpe(e,r,a=iz){if(!(!(s=e.length)||isNaN(r=+r))){if(r<=0||s<2)return+a(e[0],0,e);if(r>=1)return+a(e[s-1],s-1,e);var s,n=(s-1)*r,i=Math.floor(n),o=+a(e[i],i,e),l=+a(e[i+1],i+1,e);return o+(l-o)*(n-i)}}function Wpe(e,r,a){e=+e,r=+r,a=(n=arguments.length)<2?(r=e,e=0,1):n<3?1:+a;for(var s=-1,n=Math.max(0,Math.ceil((r-e)/a))|0,i=new Array(n);++s<n;)i[s]=e+s*a;return i}function Nl(e,r){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(r).domain(e);break}return this}function iu(e,r){switch(arguments.length){case 0:break;case 1:{typeof e=="function"?this.interpolator(e):this.range(e);break}default:{this.domain(e),typeof r=="function"?this.interpolator(r):this.range(r);break}}return this}const f4=Symbol("implicit");function x3(){var e=new CO,r=[],a=[],s=f4;function n(i){let o=e.get(i);if(o===void 0){if(s!==f4)return s;e.set(i,o=r.push(i)-1)}return a[o%a.length]}return n.domain=function(i){if(!arguments.length)return r.slice();r=[],e=new CO;for(const o of i)e.has(o)||e.set(o,r.push(o)-1);return n},n.range=function(i){return arguments.length?(a=Array.from(i),n):a.slice()},n.unknown=function(i){return arguments.length?(s=i,n):s},n.copy=function(){return x3(r,a).unknown(s)},Nl.apply(n,arguments),n}function y3(){var e=x3().unknown(void 0),r=e.domain,a=e.range,s=0,n=1,i,o,l=!1,c=0,u=0,h=.5;delete e.unknown;function f(){var y=r().length,b=n<s,w=b?n:s,v=b?s:n;i=(v-w)/Math.max(1,y-c+u*2),l&&(i=Math.floor(i)),w+=(v-w-i*(y-c))*h,o=i*(1-c),l&&(w=Math.round(w),o=Math.round(o));var k=Wpe(y).map(function(S){return w+i*S});return a(b?k.reverse():k)}return e.domain=function(y){return arguments.length?(r(y),f()):r()},e.range=function(y){return arguments.length?([s,n]=y,s=+s,n=+n,f()):[s,n]},e.rangeRound=function(y){return[s,n]=y,s=+s,n=+n,l=!0,f()},e.bandwidth=function(){return o},e.step=function(){return i},e.round=function(y){return arguments.length?(l=!!y,f()):l},e.padding=function(y){return arguments.length?(c=Math.min(1,u=+y),f()):c},e.paddingInner=function(y){return arguments.length?(c=Math.min(1,y),f()):c},e.paddingOuter=function(y){return arguments.length?(u=+y,f()):u},e.align=function(y){return arguments.length?(h=Math.max(0,Math.min(1,y)),f()):h},e.copy=function(){return y3(r(),[s,n]).round(l).paddingInner(c).paddingOuter(u).align(h)},Nl.apply(f(),arguments)}function cz(e){var r=e.copy;return e.padding=e.paddingOuter,delete e.paddingInner,delete e.paddingOuter,e.copy=function(){return cz(r())},e}function Hpe(){return cz(y3.apply(null,arguments).paddingInner(1))}function b3(e,r,a){e.prototype=r.prototype=a,a.constructor=e}function dz(e,r){var a=Object.create(e.prototype);for(var s in r)a[s]=r[s];return a}function Xx(){}var mx=.7,j1=1/mx,wp="\\s*([+-]?\\d+)\\s*",hx="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Fc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",qpe=/^#([0-9a-f]{3,8})$/,Vpe=new RegExp(`^rgb\\(${wp},${wp},${wp}\\)$`),Gpe=new RegExp(`^rgb\\(${Fc},${Fc},${Fc}\\)$`),Kpe=new RegExp(`^rgba\\(${wp},${wp},${wp},${hx}\\)$`),Ype=new RegExp(`^rgba\\(${Fc},${Fc},${Fc},${hx}\\)$`),Jpe=new RegExp(`^hsl\\(${hx},${Fc},${Fc}\\)$`),Zpe=new RegExp(`^hsla\\(${hx},${Fc},${Fc},${hx}\\)$`),OO={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};b3(Xx,px,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:PO,formatHex:PO,formatHex8:Xpe,formatHsl:Qpe,formatRgb:DO,toString:DO});function PO(){return this.rgb().formatHex()}function Xpe(){return this.rgb().formatHex8()}function Qpe(){return uz(this).formatHsl()}function DO(){return this.rgb().formatRgb()}function px(e){var r,a;return e=(e+"").trim().toLowerCase(),(r=qpe.exec(e))?(a=r[1].length,r=parseInt(r[1],16),a===6?RO(r):a===3?new no(r>>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):a===8?Mb(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):a===4?Mb(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=Vpe.exec(e))?new no(r[1],r[2],r[3],1):(r=Gpe.exec(e))?new no(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=Kpe.exec(e))?Mb(r[1],r[2],r[3],r[4]):(r=Ype.exec(e))?Mb(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=Jpe.exec(e))?FO(r[1],r[2]/100,r[3]/100,1):(r=Zpe.exec(e))?FO(r[1],r[2]/100,r[3]/100,r[4]):OO.hasOwnProperty(e)?RO(OO[e]):e==="transparent"?new no(NaN,NaN,NaN,0):null}function RO(e){return new no(e>>16&255,e>>8&255,e&255,1)}function Mb(e,r,a,s){return s<=0&&(e=r=a=NaN),new no(e,r,a,s)}function ege(e){return e instanceof Xx||(e=px(e)),e?(e=e.rgb(),new no(e.r,e.g,e.b,e.opacity)):new no}function x4(e,r,a,s){return arguments.length===1?ege(e):new no(e,r,a,s==null?1:s)}function no(e,r,a,s){this.r=+e,this.g=+r,this.b=+a,this.opacity=+s}b3(no,x4,dz(Xx,{brighter(e){return e=e==null?j1:Math.pow(j1,e),new no(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?mx:Math.pow(mx,e),new no(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new no(gm(this.r),gm(this.g),gm(this.b),_1(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:MO,formatHex:MO,formatHex8:tge,formatRgb:LO,toString:LO}));function MO(){return`#${om(this.r)}${om(this.g)}${om(this.b)}`}function tge(){return`#${om(this.r)}${om(this.g)}${om(this.b)}${om((isNaN(this.opacity)?1:this.opacity)*255)}`}function LO(){const e=_1(this.opacity);return`${e===1?"rgb(":"rgba("}${gm(this.r)}, ${gm(this.g)}, ${gm(this.b)}${e===1?")":`, ${e})`}`}function _1(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function gm(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function om(e){return e=gm(e),(e<16?"0":"")+e.toString(16)}function FO(e,r,a,s){return s<=0?e=r=a=NaN:a<=0||a>=1?e=r=NaN:r<=0&&(e=NaN),new Yl(e,r,a,s)}function uz(e){if(e instanceof Yl)return new Yl(e.h,e.s,e.l,e.opacity);if(e instanceof Xx||(e=px(e)),!e)return new Yl;if(e instanceof Yl)return e;e=e.rgb();var r=e.r/255,a=e.g/255,s=e.b/255,n=Math.min(r,a,s),i=Math.max(r,a,s),o=NaN,l=i-n,c=(i+n)/2;return l?(r===i?o=(a-s)/l+(a<s)*6:a===i?o=(s-r)/l+2:o=(r-a)/l+4,l/=c<.5?i+n:2-i-n,o*=60):l=c>0&&c<1?0:o,new Yl(o,l,c,e.opacity)}function rge(e,r,a,s){return arguments.length===1?uz(e):new Yl(e,r,a,s==null?1:s)}function Yl(e,r,a,s){this.h=+e,this.s=+r,this.l=+a,this.opacity=+s}b3(Yl,rge,dz(Xx,{brighter(e){return e=e==null?j1:Math.pow(j1,e),new Yl(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?mx:Math.pow(mx,e),new Yl(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,r=isNaN(e)||isNaN(this.s)?0:this.s,a=this.l,s=a+(a<.5?a:1-a)*r,n=2*a-s;return new no(I2(e>=240?e-240:e+120,n,s),I2(e,n,s),I2(e<120?e+240:e-120,n,s),this.opacity)},clamp(){return new Yl(IO(this.h),Lb(this.s),Lb(this.l),_1(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=_1(this.opacity);return`${e===1?"hsl(":"hsla("}${IO(this.h)}, ${Lb(this.s)*100}%, ${Lb(this.l)*100}%${e===1?")":`, ${e})`}`}}));function IO(e){return e=(e||0)%360,e<0?e+360:e}function Lb(e){return Math.max(0,Math.min(1,e||0))}function I2(e,r,a){return(e<60?r+(a-r)*e/60:e<180?a:e<240?r+(a-r)*(240-e)/60:r)*255}const v3=e=>()=>e;function age(e,r){return function(a){return e+a*r}}function sge(e,r,a){return e=Math.pow(e,a),r=Math.pow(r,a)-e,a=1/a,function(s){return Math.pow(e+s*r,a)}}function nge(e){return(e=+e)==1?mz:function(r,a){return a-r?sge(r,a,e):v3(isNaN(r)?a:r)}}function mz(e,r){var a=r-e;return a?age(e,a):v3(isNaN(e)?r:e)}const zO=(function e(r){var a=nge(r);function s(n,i){var o=a((n=x4(n)).r,(i=x4(i)).r),l=a(n.g,i.g),c=a(n.b,i.b),u=mz(n.opacity,i.opacity);return function(h){return n.r=o(h),n.g=l(h),n.b=c(h),n.opacity=u(h),n+""}}return s.gamma=e,s})(1);function ige(e,r){r||(r=[]);var a=e?Math.min(r.length,e.length):0,s=r.slice(),n;return function(i){for(n=0;n<a;++n)s[n]=e[n]*(1-i)+r[n]*i;return s}}function oge(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function lge(e,r){var a=r?r.length:0,s=e?Math.min(a,e.length):0,n=new Array(s),i=new Array(a),o;for(o=0;o<s;++o)n[o]=eg(e[o],r[o]);for(;o<a;++o)i[o]=r[o];return function(l){for(o=0;o<s;++o)i[o]=n[o](l);return i}}function cge(e,r){var a=new Date;return e=+e,r=+r,function(s){return a.setTime(e*(1-s)+r*s),a}}function k1(e,r){return e=+e,r=+r,function(a){return e*(1-a)+r*a}}function dge(e,r){var a={},s={},n;(e===null||typeof e!="object")&&(e={}),(r===null||typeof r!="object")&&(r={});for(n in r)n in e?a[n]=eg(e[n],r[n]):s[n]=r[n];return function(i){for(n in a)s[n]=a[n](i);return s}}var y4=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,z2=new RegExp(y4.source,"g");function uge(e){return function(){return e}}function mge(e){return function(r){return e(r)+""}}function hge(e,r){var a=y4.lastIndex=z2.lastIndex=0,s,n,i,o=-1,l=[],c=[];for(e=e+"",r=r+"";(s=y4.exec(e))&&(n=z2.exec(r));)(i=n.index)>a&&(i=r.slice(a,i),l[o]?l[o]+=i:l[++o]=i),(s=s[0])===(n=n[0])?l[o]?l[o]+=n:l[++o]=n:(l[++o]=null,c.push({i:o,x:k1(s,n)})),a=z2.lastIndex;return a<r.length&&(i=r.slice(a),l[o]?l[o]+=i:l[++o]=i),l.length<2?c[0]?mge(c[0].x):uge(r):(r=c.length,function(u){for(var h=0,f;h<r;++h)l[(f=c[h]).i]=f.x(u);return l.join("")})}function eg(e,r){var a=typeof r,s;return r==null||a==="boolean"?v3(r):(a==="number"?k1:a==="string"?(s=px(r))?(r=s,zO):hge:r instanceof px?zO:r instanceof Date?cge:oge(r)?ige:Array.isArray(r)?lge:typeof r.valueOf!="function"&&typeof r.toString!="function"||isNaN(r)?dge:k1)(e,r)}function w3(e,r){return e=+e,r=+r,function(a){return Math.round(e*(1-a)+r*a)}}function pge(e,r){r===void 0&&(r=e,e=eg);for(var a=0,s=r.length-1,n=r[0],i=new Array(s<0?0:s);a<s;)i[a]=e(n,n=r[++a]);return function(o){var l=Math.max(0,Math.min(s-1,Math.floor(o*=s)));return i[l](o-l)}}function gge(e){return function(){return e}}function N1(e){return+e}var $O=[0,1];function Ri(e){return e}function b4(e,r){return(r-=e=+e)?function(a){return(a-e)/r}:gge(isNaN(r)?NaN:.5)}function fge(e,r){var a;return e>r&&(a=e,e=r,r=a),function(s){return Math.max(e,Math.min(r,s))}}function xge(e,r,a){var s=e[0],n=e[1],i=r[0],o=r[1];return n<s?(s=b4(n,s),i=a(o,i)):(s=b4(s,n),i=a(i,o)),function(l){return i(s(l))}}function yge(e,r,a){var s=Math.min(e.length,r.length)-1,n=new Array(s),i=new Array(s),o=-1;for(e[s]<e[0]&&(e=e.slice().reverse(),r=r.slice().reverse());++o<s;)n[o]=b4(e[o],e[o+1]),i[o]=a(r[o],r[o+1]);return function(l){var c=Zx(e,l,1,s)-1;return i[c](n[c](l))}}function Qx(e,r){return r.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function Gw(){var e=$O,r=$O,a=eg,s,n,i,o=Ri,l,c,u;function h(){var y=Math.min(e.length,r.length);return o!==Ri&&(o=fge(e[0],e[y-1])),l=y>2?yge:xge,c=u=null,f}function f(y){return y==null||isNaN(y=+y)?i:(c||(c=l(e.map(s),r,a)))(s(o(y)))}return f.invert=function(y){return o(n((u||(u=l(r,e.map(s),k1)))(y)))},f.domain=function(y){return arguments.length?(e=Array.from(y,N1),h()):e.slice()},f.range=function(y){return arguments.length?(r=Array.from(y),h()):r.slice()},f.rangeRound=function(y){return r=Array.from(y),a=w3,h()},f.clamp=function(y){return arguments.length?(o=y?!0:Ri,h()):o!==Ri},f.interpolate=function(y){return arguments.length?(a=y,h()):a},f.unknown=function(y){return arguments.length?(i=y,f):i},function(y,b){return s=y,n=b,h()}}function j3(){return Gw()(Ri,Ri)}function bge(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function S1(e,r){if(!isFinite(e)||e===0)return null;var a=(e=r?e.toExponential(r-1):e.toExponential()).indexOf("e"),s=e.slice(0,a);return[s.length>1?s[0]+s.slice(2):s,+e.slice(a+1)]}function Ep(e){return e=S1(Math.abs(e)),e?e[1]:NaN}function vge(e,r){return function(a,s){for(var n=a.length,i=[],o=0,l=e[0],c=0;n>0&&l>0&&(c+l+1>s&&(l=Math.max(1,s-c)),i.push(a.substring(n-=l,n+l)),!((c+=l+1)>s));)l=e[o=(o+1)%e.length];return i.reverse().join(r)}}function wge(e){return function(r){return r.replace(/[0-9]/g,function(a){return e[+a]})}}var jge=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function gx(e){if(!(r=jge.exec(e)))throw new Error("invalid format: "+e);var r;return new _3({fill:r[1],align:r[2],sign:r[3],symbol:r[4],zero:r[5],width:r[6],comma:r[7],precision:r[8]&&r[8].slice(1),trim:r[9],type:r[10]})}gx.prototype=_3.prototype;function _3(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}_3.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function _ge(e){e:for(var r=e.length,a=1,s=-1,n;a<r;++a)switch(e[a]){case".":s=n=a;break;case"0":s===0&&(s=a),n=a;break;default:if(!+e[a])break e;s>0&&(s=0);break}return s>0?e.slice(0,s)+e.slice(n+1):e}var C1;function kge(e,r){var a=S1(e,r);if(!a)return C1=void 0,e.toPrecision(r);var s=a[0],n=a[1],i=n-(C1=Math.max(-8,Math.min(8,Math.floor(n/3)))*3)+1,o=s.length;return i===o?s:i>o?s+new Array(i-o+1).join("0"):i>0?s.slice(0,i)+"."+s.slice(i):"0."+new Array(1-i).join("0")+S1(e,Math.max(0,r+i-1))[0]}function UO(e,r){var a=S1(e,r);if(!a)return e+"";var s=a[0],n=a[1];return n<0?"0."+new Array(-n).join("0")+s:s.length>n+1?s.slice(0,n+1)+"."+s.slice(n+1):s+new Array(n-s.length+2).join("0")}const BO={"%":(e,r)=>(e*100).toFixed(r),b:e=>Math.round(e).toString(2),c:e=>e+"",d:bge,e:(e,r)=>e.toExponential(r),f:(e,r)=>e.toFixed(r),g:(e,r)=>e.toPrecision(r),o:e=>Math.round(e).toString(8),p:(e,r)=>UO(e*100,r),r:UO,s:kge,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function WO(e){return e}var HO=Array.prototype.map,qO=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Nge(e){var r=e.grouping===void 0||e.thousands===void 0?WO:vge(HO.call(e.grouping,Number),e.thousands+""),a=e.currency===void 0?"":e.currency[0]+"",s=e.currency===void 0?"":e.currency[1]+"",n=e.decimal===void 0?".":e.decimal+"",i=e.numerals===void 0?WO:wge(HO.call(e.numerals,String)),o=e.percent===void 0?"%":e.percent+"",l=e.minus===void 0?"−":e.minus+"",c=e.nan===void 0?"NaN":e.nan+"";function u(f,y){f=gx(f);var b=f.fill,w=f.align,v=f.sign,k=f.symbol,S=f.zero,N=f.width,C=f.comma,O=f.precision,T=f.trim,P=f.type;P==="n"?(C=!0,P="g"):BO[P]||(O===void 0&&(O=12),T=!0,P="g"),(S||b==="0"&&w==="=")&&(S=!0,b="0",w="=");var E=(y&&y.prefix!==void 0?y.prefix:"")+(k==="$"?a:k==="#"&&/[boxX]/.test(P)?"0"+P.toLowerCase():""),R=(k==="$"?s:/[%p]/.test(P)?o:"")+(y&&y.suffix!==void 0?y.suffix:""),z=BO[P],G=/[defgprs%]/.test(P);O=O===void 0?6:/[gprs]/.test(P)?Math.max(1,Math.min(21,O)):Math.max(0,Math.min(20,O));function ae(ee){var ne=E,te=R,Y,q,H;if(P==="c")te=z(ee)+te,ee="";else{ee=+ee;var U=ee<0||1/ee<0;if(ee=isNaN(ee)?c:z(Math.abs(ee),O),T&&(ee=_ge(ee)),U&&+ee==0&&v!=="+"&&(U=!1),ne=(U?v==="("?v:l:v==="-"||v==="("?"":v)+ne,te=(P==="s"&&!isNaN(ee)&&C1!==void 0?qO[8+C1/3]:"")+te+(U&&v==="("?")":""),G){for(Y=-1,q=ee.length;++Y<q;)if(H=ee.charCodeAt(Y),48>H||H>57){te=(H===46?n+ee.slice(Y+1):ee.slice(Y))+te,ee=ee.slice(0,Y);break}}}C&&!S&&(ee=r(ee,1/0));var re=ne.length+ee.length+te.length,X=re<N?new Array(N-re+1).join(b):"";switch(C&&S&&(ee=r(X+ee,X.length?N-te.length:1/0),X=""),w){case"<":ee=ne+ee+te+X;break;case"=":ee=ne+X+ee+te;break;case"^":ee=X.slice(0,re=X.length>>1)+ne+ee+te+X.slice(re);break;default:ee=X+ne+ee+te;break}return i(ee)}return ae.toString=function(){return f+""},ae}function h(f,y){var b=Math.max(-8,Math.min(8,Math.floor(Ep(y)/3)))*3,w=Math.pow(10,-b),v=u((f=gx(f),f.type="f",f),{suffix:qO[8+b/3]});return function(k){return v(w*k)}}return{format:u,formatPrefix:h}}var Fb,k3,hz;Sge({thousands:",",grouping:[3],currency:["$",""]});function Sge(e){return Fb=Nge(e),k3=Fb.format,hz=Fb.formatPrefix,Fb}function Cge(e){return Math.max(0,-Ep(Math.abs(e)))}function Tge(e,r){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Ep(r)/3)))*3-Ep(Math.abs(e)))}function Ege(e,r){return e=Math.abs(e),r=Math.abs(r)-e,Math.max(0,Ep(r)-Ep(e))+1}function pz(e,r,a,s){var n=g4(e,r,a),i;switch(s=gx(s==null?",f":s),s.type){case"s":{var o=Math.max(Math.abs(e),Math.abs(r));return s.precision==null&&!isNaN(i=Tge(n,o))&&(s.precision=i),hz(s,o)}case"":case"e":case"g":case"p":case"r":{s.precision==null&&!isNaN(i=Ege(n,Math.max(Math.abs(e),Math.abs(r))))&&(s.precision=i-(s.type==="e"));break}case"f":case"%":{s.precision==null&&!isNaN(i=Cge(n))&&(s.precision=i-(s.type==="%")*2);break}}return k3(s)}function o0(e){var r=e.domain;return e.ticks=function(a){var s=r();return h4(s[0],s[s.length-1],a==null?10:a)},e.tickFormat=function(a,s){var n=r();return pz(n[0],n[n.length-1],a==null?10:a,s)},e.nice=function(a){a==null&&(a=10);var s=r(),n=0,i=s.length-1,o=s[n],l=s[i],c,u,h=10;for(l<o&&(u=o,o=l,l=u,u=n,n=i,i=u);h-- >0;){if(u=p4(o,l,a),u===c)return s[n]=o,s[i]=l,r(s);if(u>0)o=Math.floor(o/u)*u,l=Math.ceil(l/u)*u;else if(u<0)o=Math.ceil(o*u)/u,l=Math.floor(l*u)/u;else break;c=u}return e},e}function gz(){var e=j3();return e.copy=function(){return Qx(e,gz())},Nl.apply(e,arguments),o0(e)}function fz(e){var r;function a(s){return s==null||isNaN(s=+s)?r:s}return a.invert=a,a.domain=a.range=function(s){return arguments.length?(e=Array.from(s,N1),a):e.slice()},a.unknown=function(s){return arguments.length?(r=s,a):r},a.copy=function(){return fz(e).unknown(r)},e=arguments.length?Array.from(e,N1):[0,1],o0(a)}function xz(e,r){e=e.slice();var a=0,s=e.length-1,n=e[a],i=e[s],o;return i<n&&(o=a,a=s,s=o,o=n,n=i,i=o),e[a]=r.floor(n),e[s]=r.ceil(i),e}function VO(e){return Math.log(e)}function GO(e){return Math.exp(e)}function Age(e){return-Math.log(-e)}function Oge(e){return-Math.exp(-e)}function Pge(e){return isFinite(e)?+("1e"+e):e<0?0:e}function Dge(e){return e===10?Pge:e===Math.E?Math.exp:r=>Math.pow(e,r)}function Rge(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),r=>Math.log(r)/e)}function KO(e){return(r,a)=>-e(-r,a)}function N3(e){const r=e(VO,GO),a=r.domain;let s=10,n,i;function o(){return n=Rge(s),i=Dge(s),a()[0]<0?(n=KO(n),i=KO(i),e(Age,Oge)):e(VO,GO),r}return r.base=function(l){return arguments.length?(s=+l,o()):s},r.domain=function(l){return arguments.length?(a(l),o()):a()},r.ticks=l=>{const c=a();let u=c[0],h=c[c.length-1];const f=h<u;f&&([u,h]=[h,u]);let y=n(u),b=n(h),w,v;const k=l==null?10:+l;let S=[];if(!(s%1)&&b-y<k){if(y=Math.floor(y),b=Math.ceil(b),u>0){for(;y<=b;++y)for(w=1;w<s;++w)if(v=y<0?w/i(-y):w*i(y),!(v<u)){if(v>h)break;S.push(v)}}else for(;y<=b;++y)for(w=s-1;w>=1;--w)if(v=y>0?w/i(-y):w*i(y),!(v<u)){if(v>h)break;S.push(v)}S.length*2<k&&(S=h4(u,h,k))}else S=h4(y,b,Math.min(b-y,k)).map(i);return f?S.reverse():S},r.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=s===10?"s":","),typeof c!="function"&&(!(s%1)&&(c=gx(c)).precision==null&&(c.trim=!0),c=k3(c)),l===1/0)return c;const u=Math.max(1,s*l/r.ticks().length);return h=>{let f=h/i(Math.round(n(h)));return f*s<s-.5&&(f*=s),f<=u?c(h):""}},r.nice=()=>a(xz(a(),{floor:l=>i(Math.floor(n(l))),ceil:l=>i(Math.ceil(n(l)))})),r}function yz(){const e=N3(Gw()).domain([1,10]);return e.copy=()=>Qx(e,yz()).base(e.base()),Nl.apply(e,arguments),e}function YO(e){return function(r){return Math.sign(r)*Math.log1p(Math.abs(r/e))}}function JO(e){return function(r){return Math.sign(r)*Math.expm1(Math.abs(r))*e}}function S3(e){var r=1,a=e(YO(r),JO(r));return a.constant=function(s){return arguments.length?e(YO(r=+s),JO(r)):r},o0(a)}function bz(){var e=S3(Gw());return e.copy=function(){return Qx(e,bz()).constant(e.constant())},Nl.apply(e,arguments)}function ZO(e){return function(r){return r<0?-Math.pow(-r,e):Math.pow(r,e)}}function Mge(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function Lge(e){return e<0?-e*e:e*e}function C3(e){var r=e(Ri,Ri),a=1;function s(){return a===1?e(Ri,Ri):a===.5?e(Mge,Lge):e(ZO(a),ZO(1/a))}return r.exponent=function(n){return arguments.length?(a=+n,s()):a},o0(r)}function T3(){var e=C3(Gw());return e.copy=function(){return Qx(e,T3()).exponent(e.exponent())},Nl.apply(e,arguments),e}function Fge(){return T3.apply(null,arguments).exponent(.5)}function XO(e){return Math.sign(e)*e*e}function Ige(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function vz(){var e=j3(),r=[0,1],a=!1,s;function n(i){var o=Ige(e(i));return isNaN(o)?s:a?Math.round(o):o}return n.invert=function(i){return e.invert(XO(i))},n.domain=function(i){return arguments.length?(e.domain(i),n):e.domain()},n.range=function(i){return arguments.length?(e.range((r=Array.from(i,N1)).map(XO)),n):r.slice()},n.rangeRound=function(i){return n.range(i).round(!0)},n.round=function(i){return arguments.length?(a=!!i,n):a},n.clamp=function(i){return arguments.length?(e.clamp(i),n):e.clamp()},n.unknown=function(i){return arguments.length?(s=i,n):s},n.copy=function(){return vz(e.domain(),r).round(a).clamp(e.clamp()).unknown(s)},Nl.apply(n,arguments),o0(n)}function wz(){var e=[],r=[],a=[],s;function n(){var o=0,l=Math.max(1,r.length);for(a=new Array(l-1);++o<l;)a[o-1]=Bpe(e,o/l);return i}function i(o){return o==null||isNaN(o=+o)?s:r[Zx(a,o)]}return i.invertExtent=function(o){var l=r.indexOf(o);return l<0?[NaN,NaN]:[l>0?a[l-1]:e[0],l<a.length?a[l]:e[e.length-1]]},i.domain=function(o){if(!arguments.length)return e.slice();e=[];for(let l of o)l!=null&&!isNaN(l=+l)&&e.push(l);return e.sort(Ku),n()},i.range=function(o){return arguments.length?(r=Array.from(o),n()):r.slice()},i.unknown=function(o){return arguments.length?(s=o,i):s},i.quantiles=function(){return a.slice()},i.copy=function(){return wz().domain(e).range(r).unknown(s)},Nl.apply(i,arguments)}function jz(){var e=0,r=1,a=1,s=[.5],n=[0,1],i;function o(c){return c!=null&&c<=c?n[Zx(s,c,0,a)]:i}function l(){var c=-1;for(s=new Array(a);++c<a;)s[c]=((c+1)*r-(c-a)*e)/(a+1);return o}return o.domain=function(c){return arguments.length?([e,r]=c,e=+e,r=+r,l()):[e,r]},o.range=function(c){return arguments.length?(a=(n=Array.from(c)).length-1,l()):n.slice()},o.invertExtent=function(c){var u=n.indexOf(c);return u<0?[NaN,NaN]:u<1?[e,s[0]]:u>=a?[s[a-1],r]:[s[u-1],s[u]]},o.unknown=function(c){return arguments.length&&(i=c),o},o.thresholds=function(){return s.slice()},o.copy=function(){return jz().domain([e,r]).range(n).unknown(i)},Nl.apply(o0(o),arguments)}function _z(){var e=[.5],r=[0,1],a,s=1;function n(i){return i!=null&&i<=i?r[Zx(e,i,0,s)]:a}return n.domain=function(i){return arguments.length?(e=Array.from(i),s=Math.min(e.length,r.length-1),n):e.slice()},n.range=function(i){return arguments.length?(r=Array.from(i),s=Math.min(e.length,r.length-1),n):r.slice()},n.invertExtent=function(i){var o=r.indexOf(i);return[e[o-1],e[o]]},n.unknown=function(i){return arguments.length?(a=i,n):a},n.copy=function(){return _z().domain(e).range(r).unknown(a)},Nl.apply(n,arguments)}const $2=new Date,U2=new Date;function Nn(e,r,a,s){function n(i){return e(i=arguments.length===0?new Date:new Date(+i)),i}return n.floor=i=>(e(i=new Date(+i)),i),n.ceil=i=>(e(i=new Date(i-1)),r(i,1),e(i),i),n.round=i=>{const o=n(i),l=n.ceil(i);return i-o<l-i?o:l},n.offset=(i,o)=>(r(i=new Date(+i),o==null?1:Math.floor(o)),i),n.range=(i,o,l)=>{const c=[];if(i=n.ceil(i),l=l==null?1:Math.floor(l),!(i<o)||!(l>0))return c;let u;do c.push(u=new Date(+i)),r(i,l),e(i);while(u<i&&i<o);return c},n.filter=i=>Nn(o=>{if(o>=o)for(;e(o),!i(o);)o.setTime(o-1)},(o,l)=>{if(o>=o)if(l<0)for(;++l<=0;)for(;r(o,-1),!i(o););else for(;--l>=0;)for(;r(o,1),!i(o););}),a&&(n.count=(i,o)=>($2.setTime(+i),U2.setTime(+o),e($2),e(U2),Math.floor(a($2,U2))),n.every=i=>(i=Math.floor(i),!isFinite(i)||!(i>0)?null:i>1?n.filter(s?o=>s(o)%i===0:o=>n.count(0,o)%i===0):n)),n}const T1=Nn(()=>{},(e,r)=>{e.setTime(+e+r)},(e,r)=>r-e);T1.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?Nn(r=>{r.setTime(Math.floor(r/e)*e)},(r,a)=>{r.setTime(+r+a*e)},(r,a)=>(a-r)/e):T1);T1.range;const Ld=1e3,gl=Ld*60,Fd=gl*60,Xd=Fd*24,E3=Xd*7,QO=Xd*30,B2=Xd*365,lm=Nn(e=>{e.setTime(e-e.getMilliseconds())},(e,r)=>{e.setTime(+e+r*Ld)},(e,r)=>(r-e)/Ld,e=>e.getUTCSeconds());lm.range;const A3=Nn(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Ld)},(e,r)=>{e.setTime(+e+r*gl)},(e,r)=>(r-e)/gl,e=>e.getMinutes());A3.range;const O3=Nn(e=>{e.setUTCSeconds(0,0)},(e,r)=>{e.setTime(+e+r*gl)},(e,r)=>(r-e)/gl,e=>e.getUTCMinutes());O3.range;const P3=Nn(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Ld-e.getMinutes()*gl)},(e,r)=>{e.setTime(+e+r*Fd)},(e,r)=>(r-e)/Fd,e=>e.getHours());P3.range;const D3=Nn(e=>{e.setUTCMinutes(0,0,0)},(e,r)=>{e.setTime(+e+r*Fd)},(e,r)=>(r-e)/Fd,e=>e.getUTCHours());D3.range;const ey=Nn(e=>e.setHours(0,0,0,0),(e,r)=>e.setDate(e.getDate()+r),(e,r)=>(r-e-(r.getTimezoneOffset()-e.getTimezoneOffset())*gl)/Xd,e=>e.getDate()-1);ey.range;const Kw=Nn(e=>{e.setUTCHours(0,0,0,0)},(e,r)=>{e.setUTCDate(e.getUTCDate()+r)},(e,r)=>(r-e)/Xd,e=>e.getUTCDate()-1);Kw.range;const kz=Nn(e=>{e.setUTCHours(0,0,0,0)},(e,r)=>{e.setUTCDate(e.getUTCDate()+r)},(e,r)=>(r-e)/Xd,e=>Math.floor(e/Xd));kz.range;function Wm(e){return Nn(r=>{r.setDate(r.getDate()-(r.getDay()+7-e)%7),r.setHours(0,0,0,0)},(r,a)=>{r.setDate(r.getDate()+a*7)},(r,a)=>(a-r-(a.getTimezoneOffset()-r.getTimezoneOffset())*gl)/E3)}const Yw=Wm(0),E1=Wm(1),zge=Wm(2),$ge=Wm(3),Ap=Wm(4),Uge=Wm(5),Bge=Wm(6);Yw.range;E1.range;zge.range;$ge.range;Ap.range;Uge.range;Bge.range;function Hm(e){return Nn(r=>{r.setUTCDate(r.getUTCDate()-(r.getUTCDay()+7-e)%7),r.setUTCHours(0,0,0,0)},(r,a)=>{r.setUTCDate(r.getUTCDate()+a*7)},(r,a)=>(a-r)/E3)}const Jw=Hm(0),A1=Hm(1),Wge=Hm(2),Hge=Hm(3),Op=Hm(4),qge=Hm(5),Vge=Hm(6);Jw.range;A1.range;Wge.range;Hge.range;Op.range;qge.range;Vge.range;const R3=Nn(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,r)=>{e.setMonth(e.getMonth()+r)},(e,r)=>r.getMonth()-e.getMonth()+(r.getFullYear()-e.getFullYear())*12,e=>e.getMonth());R3.range;const M3=Nn(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,r)=>{e.setUTCMonth(e.getUTCMonth()+r)},(e,r)=>r.getUTCMonth()-e.getUTCMonth()+(r.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());M3.range;const Qd=Nn(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,r)=>{e.setFullYear(e.getFullYear()+r)},(e,r)=>r.getFullYear()-e.getFullYear(),e=>e.getFullYear());Qd.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Nn(r=>{r.setFullYear(Math.floor(r.getFullYear()/e)*e),r.setMonth(0,1),r.setHours(0,0,0,0)},(r,a)=>{r.setFullYear(r.getFullYear()+a*e)});Qd.range;const eu=Nn(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,r)=>{e.setUTCFullYear(e.getUTCFullYear()+r)},(e,r)=>r.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());eu.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Nn(r=>{r.setUTCFullYear(Math.floor(r.getUTCFullYear()/e)*e),r.setUTCMonth(0,1),r.setUTCHours(0,0,0,0)},(r,a)=>{r.setUTCFullYear(r.getUTCFullYear()+a*e)});eu.range;function Nz(e,r,a,s,n,i){const o=[[lm,1,Ld],[lm,5,5*Ld],[lm,15,15*Ld],[lm,30,30*Ld],[i,1,gl],[i,5,5*gl],[i,15,15*gl],[i,30,30*gl],[n,1,Fd],[n,3,3*Fd],[n,6,6*Fd],[n,12,12*Fd],[s,1,Xd],[s,2,2*Xd],[a,1,E3],[r,1,QO],[r,3,3*QO],[e,1,B2]];function l(u,h,f){const y=h<u;y&&([u,h]=[h,u]);const b=f&&typeof f.range=="function"?f:c(u,h,f),w=b?b.range(u,+h+1):[];return y?w.reverse():w}function c(u,h,f){const y=Math.abs(h-u)/f,b=f3(([,,k])=>k).right(o,y);if(b===o.length)return e.every(g4(u/B2,h/B2,f));if(b===0)return T1.every(Math.max(g4(u,h,f),1));const[w,v]=o[y/o[b-1][2]<o[b][2]/y?b-1:b];return w.every(v)}return[l,c]}const[Gge,Kge]=Nz(eu,M3,Jw,kz,D3,O3),[Yge,Jge]=Nz(Qd,R3,Yw,ey,P3,A3);function W2(e){if(0<=e.y&&e.y<100){var r=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return r.setFullYear(e.y),r}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function H2(e){if(0<=e.y&&e.y<100){var r=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return r.setUTCFullYear(e.y),r}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function df(e,r,a){return{y:e,m:r,d:a,H:0,M:0,S:0,L:0}}function Zge(e){var r=e.dateTime,a=e.date,s=e.time,n=e.periods,i=e.days,o=e.shortDays,l=e.months,c=e.shortMonths,u=uf(n),h=mf(n),f=uf(i),y=mf(i),b=uf(o),w=mf(o),v=uf(l),k=mf(l),S=uf(c),N=mf(c),C={a:H,A:U,b:re,B:X,c:null,d:nP,e:nP,f:vfe,g:Afe,G:Pfe,H:xfe,I:yfe,j:bfe,L:Sz,m:wfe,M:jfe,p:V,q:I,Q:lP,s:cP,S:_fe,u:kfe,U:Nfe,V:Sfe,w:Cfe,W:Tfe,x:null,X:null,y:Efe,Y:Ofe,Z:Dfe,"%":oP},O={a:B,A:Q,b:ie,B:me,c:null,d:iP,e:iP,f:Ffe,g:Gfe,G:Yfe,H:Rfe,I:Mfe,j:Lfe,L:Tz,m:Ife,M:zfe,p:he,q:de,Q:lP,s:cP,S:$fe,u:Ufe,U:Bfe,V:Wfe,w:Hfe,W:qfe,x:null,X:null,y:Vfe,Y:Kfe,Z:Jfe,"%":oP},T={a:G,A:ae,b:ee,B:ne,c:te,d:aP,e:aP,f:hfe,g:rP,G:tP,H:sP,I:sP,j:cfe,L:mfe,m:lfe,M:dfe,p:z,q:ofe,Q:gfe,s:ffe,S:ufe,u:rfe,U:afe,V:sfe,w:tfe,W:nfe,x:Y,X:q,y:rP,Y:tP,Z:ife,"%":pfe};C.x=P(a,C),C.X=P(s,C),C.c=P(r,C),O.x=P(a,O),O.X=P(s,O),O.c=P(r,O);function P(xe,ge){return function(be){var K=[],ye=-1,Z=0,M=xe.length,we,pe,le;for(be instanceof Date||(be=new Date(+be));++ye<M;)xe.charCodeAt(ye)===37&&(K.push(xe.slice(Z,ye)),(pe=eP[we=xe.charAt(++ye)])!=null?we=xe.charAt(++ye):pe=we==="e"?" ":"0",(le=ge[we])&&(we=le(be,pe)),K.push(we),Z=ye+1);return K.push(xe.slice(Z,ye)),K.join("")}}function E(xe,ge){return function(be){var K=df(1900,void 0,1),ye=R(K,xe,be+="",0),Z,M;if(ye!=be.length)return null;if("Q"in K)return new Date(K.Q);if("s"in K)return new Date(K.s*1e3+("L"in K?K.L:0));if(ge&&!("Z"in K)&&(K.Z=0),"p"in K&&(K.H=K.H%12+K.p*12),K.m===void 0&&(K.m="q"in K?K.q:0),"V"in K){if(K.V<1||K.V>53)return null;"w"in K||(K.w=1),"Z"in K?(Z=H2(df(K.y,0,1)),M=Z.getUTCDay(),Z=M>4||M===0?A1.ceil(Z):A1(Z),Z=Kw.offset(Z,(K.V-1)*7),K.y=Z.getUTCFullYear(),K.m=Z.getUTCMonth(),K.d=Z.getUTCDate()+(K.w+6)%7):(Z=W2(df(K.y,0,1)),M=Z.getDay(),Z=M>4||M===0?E1.ceil(Z):E1(Z),Z=ey.offset(Z,(K.V-1)*7),K.y=Z.getFullYear(),K.m=Z.getMonth(),K.d=Z.getDate()+(K.w+6)%7)}else("W"in K||"U"in K)&&("w"in K||(K.w="u"in K?K.u%7:"W"in K?1:0),M="Z"in K?H2(df(K.y,0,1)).getUTCDay():W2(df(K.y,0,1)).getDay(),K.m=0,K.d="W"in K?(K.w+6)%7+K.W*7-(M+5)%7:K.w+K.U*7-(M+6)%7);return"Z"in K?(K.H+=K.Z/100|0,K.M+=K.Z%100,H2(K)):W2(K)}}function R(xe,ge,be,K){for(var ye=0,Z=ge.length,M=be.length,we,pe;ye<Z;){if(K>=M)return-1;if(we=ge.charCodeAt(ye++),we===37){if(we=ge.charAt(ye++),pe=T[we in eP?ge.charAt(ye++):we],!pe||(K=pe(xe,be,K))<0)return-1}else if(we!=be.charCodeAt(K++))return-1}return K}function z(xe,ge,be){var K=u.exec(ge.slice(be));return K?(xe.p=h.get(K[0].toLowerCase()),be+K[0].length):-1}function G(xe,ge,be){var K=b.exec(ge.slice(be));return K?(xe.w=w.get(K[0].toLowerCase()),be+K[0].length):-1}function ae(xe,ge,be){var K=f.exec(ge.slice(be));return K?(xe.w=y.get(K[0].toLowerCase()),be+K[0].length):-1}function ee(xe,ge,be){var K=S.exec(ge.slice(be));return K?(xe.m=N.get(K[0].toLowerCase()),be+K[0].length):-1}function ne(xe,ge,be){var K=v.exec(ge.slice(be));return K?(xe.m=k.get(K[0].toLowerCase()),be+K[0].length):-1}function te(xe,ge,be){return R(xe,r,ge,be)}function Y(xe,ge,be){return R(xe,a,ge,be)}function q(xe,ge,be){return R(xe,s,ge,be)}function H(xe){return o[xe.getDay()]}function U(xe){return i[xe.getDay()]}function re(xe){return c[xe.getMonth()]}function X(xe){return l[xe.getMonth()]}function V(xe){return n[+(xe.getHours()>=12)]}function I(xe){return 1+~~(xe.getMonth()/3)}function B(xe){return o[xe.getUTCDay()]}function Q(xe){return i[xe.getUTCDay()]}function ie(xe){return c[xe.getUTCMonth()]}function me(xe){return l[xe.getUTCMonth()]}function he(xe){return n[+(xe.getUTCHours()>=12)]}function de(xe){return 1+~~(xe.getUTCMonth()/3)}return{format:function(xe){var ge=P(xe+="",C);return ge.toString=function(){return xe},ge},parse:function(xe){var ge=E(xe+="",!1);return ge.toString=function(){return xe},ge},utcFormat:function(xe){var ge=P(xe+="",O);return ge.toString=function(){return xe},ge},utcParse:function(xe){var ge=E(xe+="",!0);return ge.toString=function(){return xe},ge}}}var eP={"-":"",_:" ",0:"0"},$n=/^\s*\d+/,Xge=/^%/,Qge=/[\\^$*+?|[\]().{}]/g;function La(e,r,a){var s=e<0?"-":"",n=(s?-e:e)+"",i=n.length;return s+(i<a?new Array(a-i+1).join(r)+n:n)}function efe(e){return e.replace(Qge,"\\$&")}function uf(e){return new RegExp("^(?:"+e.map(efe).join("|")+")","i")}function mf(e){return new Map(e.map((r,a)=>[r.toLowerCase(),a]))}function tfe(e,r,a){var s=$n.exec(r.slice(a,a+1));return s?(e.w=+s[0],a+s[0].length):-1}function rfe(e,r,a){var s=$n.exec(r.slice(a,a+1));return s?(e.u=+s[0],a+s[0].length):-1}function afe(e,r,a){var s=$n.exec(r.slice(a,a+2));return s?(e.U=+s[0],a+s[0].length):-1}function sfe(e,r,a){var s=$n.exec(r.slice(a,a+2));return s?(e.V=+s[0],a+s[0].length):-1}function nfe(e,r,a){var s=$n.exec(r.slice(a,a+2));return s?(e.W=+s[0],a+s[0].length):-1}function tP(e,r,a){var s=$n.exec(r.slice(a,a+4));return s?(e.y=+s[0],a+s[0].length):-1}function rP(e,r,a){var s=$n.exec(r.slice(a,a+2));return s?(e.y=+s[0]+(+s[0]>68?1900:2e3),a+s[0].length):-1}function ife(e,r,a){var s=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(r.slice(a,a+6));return s?(e.Z=s[1]?0:-(s[2]+(s[3]||"00")),a+s[0].length):-1}function ofe(e,r,a){var s=$n.exec(r.slice(a,a+1));return s?(e.q=s[0]*3-3,a+s[0].length):-1}function lfe(e,r,a){var s=$n.exec(r.slice(a,a+2));return s?(e.m=s[0]-1,a+s[0].length):-1}function aP(e,r,a){var s=$n.exec(r.slice(a,a+2));return s?(e.d=+s[0],a+s[0].length):-1}function cfe(e,r,a){var s=$n.exec(r.slice(a,a+3));return s?(e.m=0,e.d=+s[0],a+s[0].length):-1}function sP(e,r,a){var s=$n.exec(r.slice(a,a+2));return s?(e.H=+s[0],a+s[0].length):-1}function dfe(e,r,a){var s=$n.exec(r.slice(a,a+2));return s?(e.M=+s[0],a+s[0].length):-1}function ufe(e,r,a){var s=$n.exec(r.slice(a,a+2));return s?(e.S=+s[0],a+s[0].length):-1}function mfe(e,r,a){var s=$n.exec(r.slice(a,a+3));return s?(e.L=+s[0],a+s[0].length):-1}function hfe(e,r,a){var s=$n.exec(r.slice(a,a+6));return s?(e.L=Math.floor(s[0]/1e3),a+s[0].length):-1}function pfe(e,r,a){var s=Xge.exec(r.slice(a,a+1));return s?a+s[0].length:-1}function gfe(e,r,a){var s=$n.exec(r.slice(a));return s?(e.Q=+s[0],a+s[0].length):-1}function ffe(e,r,a){var s=$n.exec(r.slice(a));return s?(e.s=+s[0],a+s[0].length):-1}function nP(e,r){return La(e.getDate(),r,2)}function xfe(e,r){return La(e.getHours(),r,2)}function yfe(e,r){return La(e.getHours()%12||12,r,2)}function bfe(e,r){return La(1+ey.count(Qd(e),e),r,3)}function Sz(e,r){return La(e.getMilliseconds(),r,3)}function vfe(e,r){return Sz(e,r)+"000"}function wfe(e,r){return La(e.getMonth()+1,r,2)}function jfe(e,r){return La(e.getMinutes(),r,2)}function _fe(e,r){return La(e.getSeconds(),r,2)}function kfe(e){var r=e.getDay();return r===0?7:r}function Nfe(e,r){return La(Yw.count(Qd(e)-1,e),r,2)}function Cz(e){var r=e.getDay();return r>=4||r===0?Ap(e):Ap.ceil(e)}function Sfe(e,r){return e=Cz(e),La(Ap.count(Qd(e),e)+(Qd(e).getDay()===4),r,2)}function Cfe(e){return e.getDay()}function Tfe(e,r){return La(E1.count(Qd(e)-1,e),r,2)}function Efe(e,r){return La(e.getFullYear()%100,r,2)}function Afe(e,r){return e=Cz(e),La(e.getFullYear()%100,r,2)}function Ofe(e,r){return La(e.getFullYear()%1e4,r,4)}function Pfe(e,r){var a=e.getDay();return e=a>=4||a===0?Ap(e):Ap.ceil(e),La(e.getFullYear()%1e4,r,4)}function Dfe(e){var r=e.getTimezoneOffset();return(r>0?"-":(r*=-1,"+"))+La(r/60|0,"0",2)+La(r%60,"0",2)}function iP(e,r){return La(e.getUTCDate(),r,2)}function Rfe(e,r){return La(e.getUTCHours(),r,2)}function Mfe(e,r){return La(e.getUTCHours()%12||12,r,2)}function Lfe(e,r){return La(1+Kw.count(eu(e),e),r,3)}function Tz(e,r){return La(e.getUTCMilliseconds(),r,3)}function Ffe(e,r){return Tz(e,r)+"000"}function Ife(e,r){return La(e.getUTCMonth()+1,r,2)}function zfe(e,r){return La(e.getUTCMinutes(),r,2)}function $fe(e,r){return La(e.getUTCSeconds(),r,2)}function Ufe(e){var r=e.getUTCDay();return r===0?7:r}function Bfe(e,r){return La(Jw.count(eu(e)-1,e),r,2)}function Ez(e){var r=e.getUTCDay();return r>=4||r===0?Op(e):Op.ceil(e)}function Wfe(e,r){return e=Ez(e),La(Op.count(eu(e),e)+(eu(e).getUTCDay()===4),r,2)}function Hfe(e){return e.getUTCDay()}function qfe(e,r){return La(A1.count(eu(e)-1,e),r,2)}function Vfe(e,r){return La(e.getUTCFullYear()%100,r,2)}function Gfe(e,r){return e=Ez(e),La(e.getUTCFullYear()%100,r,2)}function Kfe(e,r){return La(e.getUTCFullYear()%1e4,r,4)}function Yfe(e,r){var a=e.getUTCDay();return e=a>=4||a===0?Op(e):Op.ceil(e),La(e.getUTCFullYear()%1e4,r,4)}function Jfe(){return"+0000"}function oP(){return"%"}function lP(e){return+e}function cP(e){return Math.floor(+e/1e3)}var qh,Az,Oz;Zfe({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function Zfe(e){return qh=Zge(e),Az=qh.format,qh.parse,Oz=qh.utcFormat,qh.utcParse,qh}function Xfe(e){return new Date(e)}function Qfe(e){return e instanceof Date?+e:+new Date(+e)}function L3(e,r,a,s,n,i,o,l,c,u){var h=j3(),f=h.invert,y=h.domain,b=u(".%L"),w=u(":%S"),v=u("%I:%M"),k=u("%I %p"),S=u("%a %d"),N=u("%b %d"),C=u("%B"),O=u("%Y");function T(P){return(c(P)<P?b:l(P)<P?w:o(P)<P?v:i(P)<P?k:s(P)<P?n(P)<P?S:N:a(P)<P?C:O)(P)}return h.invert=function(P){return new Date(f(P))},h.domain=function(P){return arguments.length?y(Array.from(P,Qfe)):y().map(Xfe)},h.ticks=function(P){var E=y();return e(E[0],E[E.length-1],P==null?10:P)},h.tickFormat=function(P,E){return E==null?T:u(E)},h.nice=function(P){var E=y();return(!P||typeof P.range!="function")&&(P=r(E[0],E[E.length-1],P==null?10:P)),P?y(xz(E,P)):h},h.copy=function(){return Qx(h,L3(e,r,a,s,n,i,o,l,c,u))},h}function exe(){return Nl.apply(L3(Yge,Jge,Qd,R3,Yw,ey,P3,A3,lm,Az).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function txe(){return Nl.apply(L3(Gge,Kge,eu,M3,Jw,Kw,D3,O3,lm,Oz).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function Zw(){var e=0,r=1,a,s,n,i,o=Ri,l=!1,c;function u(f){return f==null||isNaN(f=+f)?c:o(n===0?.5:(f=(i(f)-a)*n,l?Math.max(0,Math.min(1,f)):f))}u.domain=function(f){return arguments.length?([e,r]=f,a=i(e=+e),s=i(r=+r),n=a===s?0:1/(s-a),u):[e,r]},u.clamp=function(f){return arguments.length?(l=!!f,u):l},u.interpolator=function(f){return arguments.length?(o=f,u):o};function h(f){return function(y){var b,w;return arguments.length?([b,w]=y,o=f(b,w),u):[o(0),o(1)]}}return u.range=h(eg),u.rangeRound=h(w3),u.unknown=function(f){return arguments.length?(c=f,u):c},function(f){return i=f,a=f(e),s=f(r),n=a===s?0:1/(s-a),u}}function l0(e,r){return r.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown())}function Pz(){var e=o0(Zw()(Ri));return e.copy=function(){return l0(e,Pz())},iu.apply(e,arguments)}function Dz(){var e=N3(Zw()).domain([1,10]);return e.copy=function(){return l0(e,Dz()).base(e.base())},iu.apply(e,arguments)}function Rz(){var e=S3(Zw());return e.copy=function(){return l0(e,Rz()).constant(e.constant())},iu.apply(e,arguments)}function F3(){var e=C3(Zw());return e.copy=function(){return l0(e,F3()).exponent(e.exponent())},iu.apply(e,arguments)}function rxe(){return F3.apply(null,arguments).exponent(.5)}function Mz(){var e=[],r=Ri;function a(s){if(s!=null&&!isNaN(s=+s))return r((Zx(e,s,1)-1)/(e.length-1))}return a.domain=function(s){if(!arguments.length)return e.slice();e=[];for(let n of s)n!=null&&!isNaN(n=+n)&&e.push(n);return e.sort(Ku),a},a.interpolator=function(s){return arguments.length?(r=s,a):r},a.range=function(){return e.map((s,n)=>r(n/(e.length-1)))},a.quantiles=function(s){return Array.from({length:s+1},(n,i)=>Upe(e,i/s))},a.copy=function(){return Mz(r).domain(e)},iu.apply(a,arguments)}function Xw(){var e=0,r=.5,a=1,s=1,n,i,o,l,c,u=Ri,h,f=!1,y;function b(v){return isNaN(v=+v)?y:(v=.5+((v=+h(v))-i)*(s*v<s*i?l:c),u(f?Math.max(0,Math.min(1,v)):v))}b.domain=function(v){return arguments.length?([e,r,a]=v,n=h(e=+e),i=h(r=+r),o=h(a=+a),l=n===i?0:.5/(i-n),c=i===o?0:.5/(o-i),s=i<n?-1:1,b):[e,r,a]},b.clamp=function(v){return arguments.length?(f=!!v,b):f},b.interpolator=function(v){return arguments.length?(u=v,b):u};function w(v){return function(k){var S,N,C;return arguments.length?([S,N,C]=k,u=pge(v,[S,N,C]),b):[u(0),u(.5),u(1)]}}return b.range=w(eg),b.rangeRound=w(w3),b.unknown=function(v){return arguments.length?(y=v,b):y},function(v){return h=v,n=v(e),i=v(r),o=v(a),l=n===i?0:.5/(i-n),c=i===o?0:.5/(o-i),s=i<n?-1:1,b}}function Lz(){var e=o0(Xw()(Ri));return e.copy=function(){return l0(e,Lz())},iu.apply(e,arguments)}function Fz(){var e=N3(Xw()).domain([.1,1,10]);return e.copy=function(){return l0(e,Fz()).base(e.base())},iu.apply(e,arguments)}function Iz(){var e=S3(Xw());return e.copy=function(){return l0(e,Iz()).constant(e.constant())},iu.apply(e,arguments)}function I3(){var e=C3(Xw());return e.copy=function(){return l0(e,I3()).exponent(e.exponent())},iu.apply(e,arguments)}function axe(){return I3.apply(null,arguments).exponent(.5)}const zz=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:y3,scaleDiverging:Lz,scaleDivergingLog:Fz,scaleDivergingPow:I3,scaleDivergingSqrt:axe,scaleDivergingSymlog:Iz,scaleIdentity:fz,scaleImplicit:f4,scaleLinear:gz,scaleLog:yz,scaleOrdinal:x3,scalePoint:Hpe,scalePow:T3,scaleQuantile:wz,scaleQuantize:jz,scaleRadial:vz,scaleSequential:Pz,scaleSequentialLog:Dz,scaleSequentialPow:F3,scaleSequentialQuantile:Mz,scaleSequentialSqrt:rxe,scaleSequentialSymlog:Rz,scaleSqrt:Fge,scaleSymlog:bz,scaleThreshold:_z,scaleTime:exe,scaleUtc:txe,tickFormat:pz},Symbol.toStringTag,{value:"Module"}));function sxe(e){var r=zz;if(e in r&&typeof r[e]=="function")return r[e]();var a="scale".concat(zx(e));if(a in r&&typeof r[a]=="function")return r[a]()}function dP(e,r,a){if(typeof e=="function")return e.copy().domain(r).range(a);if(e!=null){var s=sxe(e);if(s!=null)return s.domain(r).range(a),s}}function z3(e,r,a,s){if(!(a==null||s==null))return typeof e.scale=="function"?dP(e.scale,a,s):dP(r,a,s)}function nxe(e){return"scale".concat(zx(e))}function ixe(e){return nxe(e)in zz}var $z=(e,r,a)=>{if(e!=null){var{scale:s,type:n}=e;if(s==="auto")return n==="category"&&a&&(a.indexOf("LineChart")>=0||a.indexOf("AreaChart")>=0||a.indexOf("ComposedChart")>=0&&!r)?"point":n==="category"?"band":"linear";if(typeof s=="string")return ixe(s)?s:"point"}};function oxe(e,r){for(var a=0,s=e.length,n=e[0]<e[e.length-1];a<s;){var i=Math.floor((a+s)/2);(n?e[i]<r:e[i]>r)?a=i+1:s=i}return a}function Uz(e,r){if(e){var a=r!=null?r:e.domain(),s=a.map(i=>{var o;return(o=e(i))!==null&&o!==void 0?o:0}),n=e.range();if(!(a.length===0||n.length<2))return i=>{var o,l,c=oxe(s,i);if(c<=0)return a[0];if(c>=a.length)return a[a.length-1];var u=(o=s[c-1])!==null&&o!==void 0?o:0,h=(l=s[c])!==null&&l!==void 0?l:0;return Math.abs(i-u)<=Math.abs(i-h)?a[c-1]:a[c]}}}function lxe(e){if(e!=null)return"invert"in e&&typeof e.invert=="function"?e.invert.bind(e):Uz(e,void 0)}function uP(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function O1(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?uP(Object(a),!0).forEach(function(s){cxe(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):uP(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function cxe(e,r,a){return(r=dxe(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function dxe(e){var r=uxe(e,"string");return typeof r=="symbol"?r:r+""}function uxe(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var v4=[0,"auto"],yn={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:void 0,height:30,hide:!0,id:0,includeHidden:!1,interval:"preserveEnd",minTickGap:5,mirror:!1,name:void 0,orientation:"bottom",padding:{left:0,right:0},reversed:!1,scale:"auto",tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:"category",unit:void 0,niceTicks:"auto"},Bz=(e,r)=>e.cartesianAxis.xAxis[r],ou=(e,r)=>{var a=Bz(e,r);return a==null?yn:a},bn={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:v4,hide:!0,id:0,includeHidden:!1,interval:"preserveEnd",minTickGap:5,mirror:!1,name:void 0,orientation:"left",padding:{top:0,bottom:0},reversed:!1,scale:"auto",tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:"number",unit:void 0,niceTicks:"auto",width:Wx},Wz=(e,r)=>e.cartesianAxis.yAxis[r],lu=(e,r)=>{var a=Wz(e,r);return a==null?bn:a},mxe={domain:[0,"auto"],includeHidden:!1,reversed:!1,allowDataOverflow:!1,allowDuplicatedCategory:!1,dataKey:void 0,id:0,name:"",range:[64,64],scale:"auto",type:"number",unit:""},$3=(e,r)=>{var a=e.cartesianAxis.zAxis[r];return a==null?mxe:a},Vs=(e,r,a)=>{switch(r){case"xAxis":return ou(e,a);case"yAxis":return lu(e,a);case"zAxis":return $3(e,a);case"angleAxis":return u3(e,a);case"radiusAxis":return m3(e,a);default:throw new Error("Unexpected axis type: ".concat(r))}},hxe=(e,r,a)=>{switch(r){case"xAxis":return ou(e,a);case"yAxis":return lu(e,a);default:throw new Error("Unexpected axis type: ".concat(r))}},tg=(e,r,a)=>{switch(r){case"xAxis":return ou(e,a);case"yAxis":return lu(e,a);case"angleAxis":return u3(e,a);case"radiusAxis":return m3(e,a);default:throw new Error("Unexpected axis type: ".concat(r))}},Hz=e=>e.graphicalItems.cartesianItems.some(r=>r.type==="bar")||e.graphicalItems.polarItems.some(r=>r.type==="radialBar");function U3(e,r){return a=>{switch(e){case"xAxis":return"xAxisId"in a&&a.xAxisId===r;case"yAxis":return"yAxisId"in a&&a.yAxisId===r;case"zAxis":return"zAxisId"in a&&a.zAxisId===r;case"angleAxis":return"angleAxisId"in a&&a.angleAxisId===r;case"radiusAxis":return"radiusAxisId"in a&&a.radiusAxisId===r;default:return!1}}}var B3=e=>e.graphicalItems.cartesianItems,pxe=bt([Ds,Jx],U3),W3=(e,r,a)=>e.filter(a).filter(s=>(r==null?void 0:r.includeHidden)===!0?!0:!s.hide),rg=bt([B3,Vs,pxe],W3,{memoizeOptions:{resultEqualityCheck:Vw}}),qz=bt([rg],e=>e.filter(r=>r.type==="area"||r.type==="bar").filter(Hw)),Vz=e=>e.filter(r=>!("stackId"in r)||r.stackId===void 0),gxe=bt([rg],Vz),H3=e=>e.map(r=>r.data).filter(Boolean).flat(1),fxe=bt([rg],e=>e.some(r=>!r.data)),Gz=bt([rg],H3,{memoizeOptions:{resultEqualityCheck:Vw}}),q3=(e,r)=>{var{chartData:a=[],dataStartIndex:s,dataEndIndex:n}=r;return e.length>0?e:a.slice(s,n+1)},V3=bt([Gz,$w],q3),Kz=(e,r,a)=>(r==null?void 0:r.dataKey)!=null?e.map(s=>({value:ls(s,r.dataKey)})):a.length>0?a.map(s=>s.dataKey).flatMap(s=>e.map(n=>({value:ls(n,s)}))):e.map(s=>({value:s})),Yz=(e,r,a,s,n,i)=>{var{chartData:o=[],dataStartIndex:l,dataEndIndex:c}=s,u=Kz(e,r,a);if(n&&(r==null?void 0:r.dataKey)!=null&&i.length>0){var h=o.slice(l,c+1),f=h.map(y=>({value:ls(y,r.dataKey)})).filter(y=>y.value!=null);return[...f,...u]}return u},ty=bt([V3,Vs,rg,$w,fxe,Gz],Yz);function jp(e){if(Uc(e)||e instanceof Date){var r=Number(e);if(ja(r))return r}}function mP(e){if(Array.isArray(e)){var r=[jp(e[0]),jp(e[1])];return Lc(r)?r:void 0}var a=jp(e);if(a!=null)return[a,a]}function Hc(e){return e.map(jp).filter(so)}function xxe(e,r){var a=jp(e),s=jp(r);return a==null&&s==null?0:a==null?-1:s==null?1:a-s}var yxe=bt([ty],e=>e==null?void 0:e.map(r=>r.value).sort(xxe));function Jz(e,r){switch(e){case"xAxis":return r.direction==="x";case"yAxis":return r.direction==="y";default:return!1}}function bxe(e,r,a){if(!a)return[];if(!a.length)return[];var s;if(typeof r=="number"&&!$c(r))s=r;else if(Array.isArray(r)){var n=Hc(r);n.length>0&&(s=Math.max(...n))}return s==null?[]:Hc(a.flatMap(i=>{var o=ls(e,i.dataKey),l,c;if(Array.isArray(o)?[l,c]=o:l=c=o,!(!ja(l)||!ja(c)))return[s-l,s+c]}))}var Sn=e=>{var r=zn(e),a=Qp(e);return tg(e,r,a)},Pp=bt([Sn],e=>e==null?void 0:e.dataKey),vxe=bt([qz,$w,Sn],sz),Zz=(e,r,a,s)=>{var n={},i=r.reduce((o,l)=>{if(l.stackId==null)return o;var c=o[l.stackId];return c==null&&(c=[]),c.push(l),o[l.stackId]=c,o},n);return Object.fromEntries(Object.entries(i).map(o=>{var[l,c]=o,u=s?[...c].reverse():c,h=u.map(p3);return[l,{stackedData:d0e(e,h,a),graphicalItems:u}]}))},w4=bt([vxe,qz,Yx,ZI],Zz),Xz=(e,r,a,s)=>{var{dataStartIndex:n,dataEndIndex:i}=r;if(s==null&&a!=="zAxis"){var o=g0e(e,n,i);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},wxe=bt([Vs],e=>e.allowDataOverflow),G3=e=>{var r;if(e==null||!("domain"in e))return v4;if(e.domain!=null)return e.domain;if("ticks"in e&&e.ticks!=null){if(e.type==="number"){var a=Hc(e.ticks);return[Math.min(...a),Math.max(...a)]}if(e.type==="category")return e.ticks.map(String)}return(r=e==null?void 0:e.domain)!==null&&r!==void 0?r:v4},K3=bt([Vs],G3),Y3=bt([K3,wxe],II),jxe=bt([w4,uc,Ds,Y3],Xz,{memoizeOptions:{resultEqualityCheck:qw}}),Qw=e=>e.errorBars,_xe=(e,r,a)=>e.flatMap(s=>r[s.id]).filter(Boolean).filter(s=>Jz(a,s)),P1=function(){for(var r=arguments.length,a=new Array(r),s=0;s<r;s++)a[s]=arguments[s];var n=a.filter(Boolean);if(n.length!==0){var i=n.flat(),o=Math.min(...i),l=Math.max(...i);return[o,l]}},J3=function(r,a,s,n,i){var o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:[],l,c;if(s.length>0&&s.forEach(u=>{var h,f=u.data!=null?[...u.data]:o,y=(h=n[u.id])===null||h===void 0?void 0:h.filter(b=>Jz(i,b));f.forEach(b=>{var w,v=ls(b,(w=a.dataKey)!==null&&w!==void 0?w:u.dataKey),k=bxe(b,v,y);if(k.length>=2){var S=Math.min(...k),N=Math.max(...k);(l==null||S<l)&&(l=S),(c==null||N>c)&&(c=N)}var C=mP(v);C!=null&&(l=l==null?C[0]:Math.min(l,C[0]),c=c==null?C[1]:Math.max(c,C[1]))})}),(a==null?void 0:a.dataKey)!=null&&s.length===0&&r.forEach(u=>{var h=mP(ls(u,a.dataKey));h!=null&&(l=l==null?h[0]:Math.min(l,h[0]),c=c==null?h[1]:Math.max(c,h[1]))}),ja(l)&&ja(c))return[l,c]},kxe=bt([V3,Vs,gxe,Qw,Ds,hpe],J3,{memoizeOptions:{resultEqualityCheck:qw}});function Nxe(e){var{value:r}=e;if(Uc(r)||r instanceof Date)return r}var Sxe=(e,r,a)=>{var s=e.map(Nxe).filter(n=>n!=null);return a&&(r.dataKey==null||r.allowDuplicatedCategory&&dF(s))?FI(0,e.length):r.allowDuplicatedCategory?s:Array.from(new Set(s))},Qz=e=>e.referenceElements.dots,ag=(e,r,a)=>e.filter(s=>s.ifOverflow==="extendDomain").filter(s=>r==="xAxis"?s.xAxisId===a:s.yAxisId===a),Cxe=bt([Qz,Ds,Jx],ag),e$=e=>e.referenceElements.areas,Txe=bt([e$,Ds,Jx],ag),t$=e=>e.referenceElements.lines,Exe=bt([t$,Ds,Jx],ag),r$=(e,r)=>{if(e!=null){var a=Hc(e.map(s=>r==="xAxis"?s.x:s.y));if(a.length!==0)return[Math.min(...a),Math.max(...a)]}},Axe=bt(Cxe,Ds,r$),a$=(e,r)=>{if(e!=null){var a=Hc(e.flatMap(s=>[r==="xAxis"?s.x1:s.y1,r==="xAxis"?s.x2:s.y2]));if(a.length!==0)return[Math.min(...a),Math.max(...a)]}},Oxe=bt([Txe,Ds],a$);function Pxe(e){var r;if(e.x!=null)return Hc([e.x]);var a=(r=e.segment)===null||r===void 0?void 0:r.map(s=>s.x);return a==null||a.length===0?[]:Hc(a)}function Dxe(e){var r;if(e.y!=null)return Hc([e.y]);var a=(r=e.segment)===null||r===void 0?void 0:r.map(s=>s.y);return a==null||a.length===0?[]:Hc(a)}var s$=(e,r)=>{if(e!=null){var a=e.flatMap(s=>r==="xAxis"?Pxe(s):Dxe(s));if(a.length!==0)return[Math.min(...a),Math.max(...a)]}},Rxe=bt([Exe,Ds],s$),Mxe=bt(Axe,Rxe,Oxe,(e,r,a)=>P1(e,a,r)),Z3=(e,r,a,s,n,i,o,l)=>{if(a!=null)return a;var c=o==="vertical"&&l==="xAxis"||o==="horizontal"&&l==="yAxis",u=c?P1(s,i,n):P1(i,n);return fpe(r,u,e.allowDataOverflow)},Lxe=bt([Vs,K3,Y3,jxe,kxe,Mxe,Ua,Ds],Z3,{memoizeOptions:{resultEqualityCheck:qw}}),Fxe=[0,1],X3=(e,r,a,s,n,i,o)=>{if(!((e==null||a==null||a.length===0)&&o===void 0)){var{dataKey:l,type:c}=e,u=i0(r,i);if(u&&l==null){var h;return FI(0,(h=a==null?void 0:a.length)!==null&&h!==void 0?h:0)}return c==="category"?Sxe(s,e,u):n==="expand"&&!u?Fxe:o}},Q3=bt([Vs,Ua,V3,ty,Yx,Ds,Lxe],X3),c0=bt([Vs,Hz,l3],$z),eC=(e,r,a)=>{var{niceTicks:s}=r;if(s!=="none"){var n=G3(r),i=Array.isArray(n)&&(n[0]==="auto"||n[1]==="auto");if((s==="snap125"||s==="adaptive")&&r!=null&&r.tickCount&&Lc(e)){if(i)return jO(e,r.tickCount,r.allowDecimals,s);if(r.type==="number")return _O(e,r.tickCount,r.allowDecimals,s)}if(s==="auto"&&a==="linear"&&r!=null&&r.tickCount){if(i&&Lc(e))return jO(e,r.tickCount,r.allowDecimals,"adaptive");if(r.type==="number"&&Lc(e))return _O(e,r.tickCount,r.allowDecimals,"adaptive")}}},tC=bt([Q3,tg,c0],eC),rC=(e,r,a,s)=>{if(s!=="angleAxis"&&(e==null?void 0:e.type)==="number"&&Lc(r)&&Array.isArray(a)&&a.length>0){var n,i,o=r[0],l=(n=a[0])!==null&&n!==void 0?n:0,c=r[1],u=(i=a[a.length-1])!==null&&i!==void 0?i:0;return[Math.min(o,l),Math.max(c,u)]}return r},Ixe=bt([Vs,Q3,tC,Ds],rC),zxe=bt(ty,Vs,(e,r)=>{if(!(!r||r.type!=="number")){var a=1/0,s=Array.from(Hc(e.map(f=>f.value))).sort((f,y)=>f-y),n=s[0],i=s[s.length-1];if(n==null||i==null)return 1/0;var o=i-n;if(o===0)return 1/0;for(var l=0;l<s.length-1;l++){var c=s[l],u=s[l+1];if(!(c==null||u==null)){var h=u-c;a=Math.min(a,h)}}return a/o}}),n$=bt(zxe,Ua,JI,kn,(e,r,a,s,n)=>n,(e,r,a,s,n)=>{if(!ja(e))return 0;var i=r==="vertical"?s.height:s.width;if(n==="gap")return e*i/2;if(n==="no-gap"){var o=xi(a,e*i),l=e*i/2;return l-o-(l-o)/i*o}return 0}),$xe=(e,r,a)=>{var s=ou(e,r);return s==null||typeof s.padding!="string"?0:n$(e,"xAxis",r,a,s.padding)},Uxe=(e,r,a)=>{var s=lu(e,r);return s==null||typeof s.padding!="string"?0:n$(e,"yAxis",r,a,s.padding)},Bxe=bt(ou,$xe,(e,r)=>{var a,s;if(e==null)return{left:0,right:0};var{padding:n}=e;return typeof n=="string"?{left:r,right:r}:{left:((a=n.left)!==null&&a!==void 0?a:0)+r,right:((s=n.right)!==null&&s!==void 0?s:0)+r}}),Wxe=bt(lu,Uxe,(e,r)=>{var a,s;if(e==null)return{top:0,bottom:0};var{padding:n}=e;return typeof n=="string"?{top:r,bottom:r}:{top:((a=n.top)!==null&&a!==void 0?a:0)+r,bottom:((s=n.bottom)!==null&&s!==void 0?s:0)+r}}),Hxe=bt([kn,Bxe,Dw,Pw,(e,r,a)=>a],(e,r,a,s,n)=>{var{padding:i}=s;return n?[i.left,a.width-i.right]:[e.left+r.left,e.left+e.width-r.right]}),qxe=bt([kn,Ua,Wxe,Dw,Pw,(e,r,a)=>a],(e,r,a,s,n,i)=>{var{padding:o}=n;return i?[s.height-o.bottom,o.top]:r==="horizontal"?[e.top+e.height-a.bottom,e.top+a.top]:[e.top+a.top,e.top+e.height-a.bottom]}),ry=(e,r,a,s)=>{var n;switch(r){case"xAxis":return Hxe(e,a,s);case"yAxis":return qxe(e,a,s);case"zAxis":return(n=$3(e,a))===null||n===void 0?void 0:n.range;case"angleAxis":return tz(e);case"radiusAxis":return rz(e,a);default:return}},i$=bt([Vs,ry],Uw),Vxe=bt([c0,Ixe],nz),aC=bt([Vs,c0,Vxe,i$],z3),o$=(e,r,a,s)=>{if(!(a==null||a.dataKey==null)){var{type:n,scale:i}=a,o=i0(e,s);if(o&&(n==="number"||i!=="auto"))return r.map(l=>l.value)}},sC=bt([Ua,ty,tg,Ds],o$),ej=bt([aC],g3);bt([aC],lxe);bt([aC,yxe],Uz);bt([rg,Qw,Ds],_xe);function l$(e,r){return e.id<r.id?-1:e.id>r.id?1:0}var tj=(e,r)=>r,rj=(e,r,a)=>a,Gxe=bt(Aw,tj,rj,(e,r,a)=>e.filter(s=>s.orientation===r).filter(s=>s.mirror===a).sort(l$)),Kxe=bt(Ow,tj,rj,(e,r,a)=>e.filter(s=>s.orientation===r).filter(s=>s.mirror===a).sort(l$)),c$=(e,r)=>({width:e.width,height:r.height}),Yxe=(e,r)=>{var a=typeof r.width=="number"?r.width:Wx;return{width:a,height:e.height}},d$=bt(kn,ou,c$),Jxe=(e,r,a)=>{switch(r){case"top":return e.top;case"bottom":return a-e.bottom;default:return 0}},Zxe=(e,r,a)=>{switch(r){case"left":return e.left;case"right":return a-e.right;default:return 0}},Xxe=bt(nu,kn,Gxe,tj,rj,(e,r,a,s,n)=>{var i={},o;return a.forEach(l=>{var c=c$(r,l);o==null&&(o=Jxe(r,s,e));var u=s==="top"&&!n||s==="bottom"&&n;i[l.id]=o-Number(u)*c.height,o+=(u?-1:1)*c.height}),i}),Qxe=bt(su,kn,Kxe,tj,rj,(e,r,a,s,n)=>{var i={},o;return a.forEach(l=>{var c=Yxe(r,l);o==null&&(o=Zxe(r,s,e));var u=s==="left"&&!n||s==="right"&&n;i[l.id]=o-Number(u)*c.width,o+=(u?-1:1)*c.width}),i}),eye=(e,r)=>{var a=ou(e,r);if(a!=null)return Xxe(e,a.orientation,a.mirror)},tye=bt([kn,ou,eye,(e,r)=>r],(e,r,a,s)=>{if(r!=null){var n=a==null?void 0:a[s];return n==null?{x:e.left,y:0}:{x:e.left,y:n}}}),rye=(e,r)=>{var a=lu(e,r);if(a!=null)return Qxe(e,a.orientation,a.mirror)},aye=bt([kn,lu,rye,(e,r)=>r],(e,r,a,s)=>{if(r!=null){var n=a==null?void 0:a[s];return n==null?{x:0,y:e.top}:{x:n,y:e.top}}}),u$=bt(kn,lu,(e,r)=>{var a=typeof r.width=="number"?r.width:Wx;return{width:a,height:e.height}}),hP=(e,r,a)=>{switch(r){case"xAxis":return d$(e,a).width;case"yAxis":return u$(e,a).height;default:return}},m$=(e,r,a,s)=>{if(a!=null){var{allowDuplicatedCategory:n,type:i,dataKey:o}=a,l=i0(e,s),c=r.map(h=>h.value),u=c.filter(h=>h!=null);if(o&&l&&i==="category"&&n&&dF(u))return c}},nC=bt([Ua,ty,Vs,Ds],m$),pP=bt([Ua,hxe,c0,ej,nC,sC,ry,tC,Ds],(e,r,a,s,n,i,o,l,c)=>{if(r!=null){var u=i0(e,c);return{angle:r.angle,interval:r.interval,minTickGap:r.minTickGap,orientation:r.orientation,tick:r.tick,tickCount:r.tickCount,tickFormatter:r.tickFormatter,ticks:r.ticks,type:r.type,unit:r.unit,axisType:c,categoricalDomain:i,duplicateDomain:n,isCategorical:u,niceTicks:l,range:o,realScaleType:a,scale:s}}}),sye=(e,r,a,s,n,i,o,l,c)=>{if(!(r==null||s==null)){var u=i0(e,c),{type:h,ticks:f,tickCount:y}=r,b=a==="scaleBand"&&typeof s.bandwidth=="function"?s.bandwidth()/2:2,w=h==="category"&&s.bandwidth?s.bandwidth()/b:0;w=c==="angleAxis"&&i!=null&&i.length>=2?Ln(i[0]-i[1])*2*w:w;var v=f||n;return v?v.map((k,S)=>{var N=o?o.indexOf(k):k,C=s.map(N);return ja(C)?{index:S,coordinate:C+w,value:k,offset:w}:null}).filter(so):u&&l?l.map((k,S)=>{var N=s.map(k);return ja(N)?{coordinate:N+w,value:k,index:S,offset:w}:null}).filter(so):s.ticks?s.ticks(y).map((k,S)=>{var N=s.map(k);return ja(N)?{coordinate:N+w,value:k,index:S,offset:w}:null}).filter(so):s.domain().map((k,S)=>{var N=s.map(k);return ja(N)?{coordinate:N+w,value:o?o[k]:k,index:S,offset:w}:null}).filter(so)}},h$=bt([Ua,tg,c0,ej,tC,ry,nC,sC,Ds],sye),nye=(e,r,a,s,n,i,o)=>{if(!(r==null||a==null||s==null||s[0]===s[1])){var l=i0(e,o),{tickCount:c}=r,u=0;return u=o==="angleAxis"&&(s==null?void 0:s.length)>=2?Ln(s[0]-s[1])*2*u:u,l&&i?i.map((h,f)=>{var y=a.map(h);return ja(y)?{coordinate:y+u,value:h,index:f,offset:u}:null}).filter(so):a.ticks?a.ticks(c).map((h,f)=>{var y=a.map(h);return ja(y)?{coordinate:y+u,value:h,index:f,offset:u}:null}).filter(so):a.domain().map((h,f)=>{var y=a.map(h);return ja(y)?{coordinate:y+u,value:n?n[h]:h,index:f,offset:u}:null}).filter(so)}},Dp=bt([Ua,tg,ej,ry,nC,sC,Ds],nye),Rp=bt(Vs,ej,(e,r)=>{if(!(e==null||r==null))return O1(O1({},e),{},{scale:r})}),iye=bt([Vs,c0,Q3,i$],z3),oye=bt([iye],g3);bt((e,r,a)=>$3(e,a),oye,(e,r)=>{if(!(e==null||r==null))return O1(O1({},e),{},{scale:r})});var lye=bt([Ua,Aw,Ow],(e,r,a)=>{switch(e){case"horizontal":return r.some(s=>s.reversed)?"right-to-left":"left-to-right";case"vertical":return a.some(s=>s.reversed)?"bottom-to-top":"top-to-bottom";case"centric":case"radial":return"left-to-right";default:return}}),cye=(e,r,a)=>{var s;return(s=e.renderedTicks[r])===null||s===void 0?void 0:s[a]};bt([cye],e=>{if(!(!e||e.length===0))return r=>{var a,s=1/0,n=e[0];for(var i of e){var o=Math.abs(i.coordinate-r);o<s&&(s=o,n=i)}return(a=n)===null||a===void 0?void 0:a.value}});var p$=e=>e.options.defaultTooltipEventType,g$=e=>e.options.validateTooltipEventTypes;function f$(e,r,a){if(e==null)return r;var s=e?"axis":"item";return a==null?r:a.includes(s)?s:r}function ay(e,r){var a=p$(e),s=g$(e);return f$(r,a,s)}function dye(e){return kr(r=>ay(r,e))}var x$=(e,r)=>{var a,s=Number(r);if(!($c(s)||r==null))return s>=0?e==null||(a=e[s])===null||a===void 0?void 0:a.value:void 0},uye=e=>e.tooltip.settings,Bu={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},mye={itemInteraction:{click:Bu,hover:Bu},axisInteraction:{click:Bu,hover:Bu},keyboardInteraction:Bu,syncInteraction:{active:!1,index:null,dataKey:void 0,label:void 0,coordinate:void 0,sourceViewBox:void 0,graphicalItemId:void 0},tooltipItemPayloads:[],settings:{shared:void 0,trigger:"hover",axisId:0,active:!1,defaultIndex:void 0}},y$=wi({name:"tooltip",initialState:mye,reducers:{addTooltipEntrySettings:{reducer(e,r){e.tooltipItemPayloads.push(r.payload)},prepare:ys()},replaceTooltipEntrySettings:{reducer(e,r){var{prev:a,next:s}=r.payload,n=pl(e).tooltipItemPayloads.indexOf(a);n>-1&&(e.tooltipItemPayloads[n]=s)},prepare:ys()},removeTooltipEntrySettings:{reducer(e,r){var a=pl(e).tooltipItemPayloads.indexOf(r.payload);a>-1&&e.tooltipItemPayloads.splice(a,1)},prepare:ys()},setTooltipSettingsState(e,r){e.settings=r.payload},setActiveMouseOverItemIndex(e,r){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.keyboardInteraction.active=!1,e.itemInteraction.hover.active=!0,e.itemInteraction.hover.index=r.payload.activeIndex,e.itemInteraction.hover.dataKey=r.payload.activeDataKey,e.itemInteraction.hover.graphicalItemId=r.payload.activeGraphicalItemId,e.itemInteraction.hover.coordinate=r.payload.activeCoordinate},mouseLeaveChart(e){e.itemInteraction.hover.active=!1,e.axisInteraction.hover.active=!1},mouseLeaveItem(e){e.itemInteraction.hover.active=!1},setActiveClickItemIndex(e,r){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.itemInteraction.click.active=!0,e.keyboardInteraction.active=!1,e.itemInteraction.click.index=r.payload.activeIndex,e.itemInteraction.click.dataKey=r.payload.activeDataKey,e.itemInteraction.click.graphicalItemId=r.payload.activeGraphicalItemId,e.itemInteraction.click.coordinate=r.payload.activeCoordinate},setMouseOverAxisIndex(e,r){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.axisInteraction.hover.active=!0,e.keyboardInteraction.active=!1,e.axisInteraction.hover.index=r.payload.activeIndex,e.axisInteraction.hover.dataKey=r.payload.activeDataKey,e.axisInteraction.hover.coordinate=r.payload.activeCoordinate},setMouseClickAxisIndex(e,r){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.keyboardInteraction.active=!1,e.axisInteraction.click.active=!0,e.axisInteraction.click.index=r.payload.activeIndex,e.axisInteraction.click.dataKey=r.payload.activeDataKey,e.axisInteraction.click.coordinate=r.payload.activeCoordinate},setSyncInteraction(e,r){e.syncInteraction=r.payload},setKeyboardInteraction(e,r){e.keyboardInteraction.active=r.payload.active,e.keyboardInteraction.index=r.payload.activeIndex,e.keyboardInteraction.coordinate=r.payload.activeCoordinate}}}),{addTooltipEntrySettings:hye,replaceTooltipEntrySettings:pye,removeTooltipEntrySettings:gye,setTooltipSettingsState:fye,setActiveMouseOverItemIndex:b$,mouseLeaveItem:xye,mouseLeaveChart:v$,setActiveClickItemIndex:yye,setMouseOverAxisIndex:w$,setMouseClickAxisIndex:bye,setSyncInteraction:Sf,setKeyboardInteraction:D1}=y$.actions,vye=y$.reducer;function gP(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function Ib(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?gP(Object(a),!0).forEach(function(s){wye(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):gP(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function wye(e,r,a){return(r=jye(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function jye(e){var r=_ye(e,"string");return typeof r=="symbol"?r:r+""}function _ye(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function kye(e,r,a){return r==="axis"?a==="click"?e.axisInteraction.click:e.axisInteraction.hover:a==="click"?e.itemInteraction.click:e.itemInteraction.hover}function Nye(e){return e.index!=null}var j$=(e,r,a,s)=>{if(r==null)return Bu;var n=kye(e,r,a);if(n==null)return Bu;if(n.active)return n;if(e.keyboardInteraction.active)return e.keyboardInteraction;if(e.syncInteraction.active&&e.syncInteraction.index!=null)return e.syncInteraction;var i=e.settings.active===!0;if(Nye(n)){if(i)return Ib(Ib({},n),{},{active:!0})}else if(s!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:s,graphicalItemId:void 0};return Ib(Ib({},Bu),{},{coordinate:n.coordinate})};function Sye(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(e instanceof Date){var r=e.valueOf();return Number.isFinite(r)?r:void 0}var a=Number(e);return Number.isFinite(a)?a:void 0}function Cye(e,r){var a=Sye(e),s=r[0],n=r[1];if(a===void 0)return!1;var i=Math.min(s,n),o=Math.max(s,n);return a>=i&&a<=o}function Tye(e,r,a){if(a==null||r==null)return!0;var s=ls(e,r);return s==null||!Lc(a)?!0:Cye(s,a)}var Wf=(e,r,a,s)=>{var n=e==null?void 0:e.index;if(n==null)return null;var i=Number(n);if(!ja(i))return n;var o=0,l=1/0;r.length>0&&(l=r.length-1);var c=Math.max(o,Math.min(i,l)),u=r[c];return u==null||Tye(u,a,s)?String(c):null},_$=(e,r,a,s,n,i,o)=>{if(i!=null){var l=o[0],c=l==null?void 0:l.getPosition(i);if(c!=null)return c;var u=n==null?void 0:n[Number(i)];if(u)switch(a){case"horizontal":return{x:u.coordinate,y:(s.top+r)/2};default:return{x:(s.left+e)/2,y:u.coordinate}}}},k$=(e,r,a,s)=>{if(r==="axis")return e.tooltipItemPayloads;if(e.tooltipItemPayloads.length===0)return[];var n;if(a==="hover"?n=e.itemInteraction.hover.graphicalItemId:n=e.itemInteraction.click.graphicalItemId,e.syncInteraction.active&&n==null)return e.tooltipItemPayloads;if(n==null&&(s!=null||e.keyboardInteraction.active)){var i=e.tooltipItemPayloads[0];return i!=null?[i]:[]}return e.tooltipItemPayloads.filter(o=>{var l;return((l=o.settings)===null||l===void 0?void 0:l.graphicalItemId)===n})},N$=e=>e.options.tooltipPayloadSearcher,sg=e=>e.tooltip;function fP(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function xP(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?fP(Object(a),!0).forEach(function(s){Eye(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):fP(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function Eye(e,r,a){return(r=Aye(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Aye(e){var r=Oye(e,"string");return typeof r=="symbol"?r:r+""}function Oye(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Pye(e){if(typeof e=="string"||typeof e=="number")return e}function Dye(e){if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e}function Rye(e){if(typeof e=="string"||typeof e=="number")return e;if(typeof e=="function")return r=>e(r)}function yP(e){if(typeof e=="string")return e}function Mye(e){if(!(e==null||typeof e!="object")){var r="name"in e?Pye(e.name):void 0,a="unit"in e?Dye(e.unit):void 0,s="dataKey"in e?Rye(e.dataKey):void 0,n="payload"in e?e.payload:void 0,i="color"in e?yP(e.color):void 0,o="fill"in e?yP(e.fill):void 0;return{name:r,unit:a,dataKey:s,payload:n,color:i,fill:o}}}function Lye(e,r){return e!=null?e:r}var S$=(e,r,a,s,n,i,o)=>{if(!(r==null||i==null)){var{chartData:l,computedData:c,dataStartIndex:u,dataEndIndex:h}=a,f=[];return e.reduce((y,b)=>{var w,{dataDefinedOnItem:v,settings:k}=b,S=Lye(v,l),N=Array.isArray(S)?sI(S,u,h):S,C=(w=k==null?void 0:k.dataKey)!==null&&w!==void 0?w:s,O=k==null?void 0:k.nameKey,T;if(s&&Array.isArray(N)&&!Array.isArray(N[0])&&o==="axis"?T=Ice(N,s,n):T=i(N,r,c,O),Array.isArray(T))T.forEach(E=>{var R,z,G=Mye(E),ae=G==null?void 0:G.name,ee=G==null?void 0:G.dataKey,ne=G==null?void 0:G.payload,te=xP(xP({},k),{},{name:ae,unit:G==null?void 0:G.unit,color:(R=G==null?void 0:G.color)!==null&&R!==void 0?R:k==null?void 0:k.color,fill:(z=G==null?void 0:G.fill)!==null&&z!==void 0?z:k==null?void 0:k.fill});y.push(dA({tooltipEntrySettings:te,dataKey:ee,payload:ne,value:ls(ne,ee),name:ae==null?void 0:String(ae)}))});else{var P;y.push(dA({tooltipEntrySettings:k,dataKey:C,payload:T,value:ls(T,C),name:(P=ls(T,O))!==null&&P!==void 0?P:k==null?void 0:k.name}))}return y},f)}},iC=bt([Sn,Hz,l3],$z),Fye=bt([e=>e.graphicalItems.cartesianItems,e=>e.graphicalItems.polarItems],(e,r)=>[...e,...r]),Iye=bt([zn,Qp],U3),qm=bt([Fye,Sn,Iye],W3,{memoizeOptions:{resultEqualityCheck:Vw}}),zye=bt([qm],e=>e.filter(Hw)),C$=bt([qm],H3,{memoizeOptions:{resultEqualityCheck:Vw}}),$ye=bt([qm],e=>e.some(r=>!r.data)),Dm=bt([C$,uc],q3),Uye=bt([zye,uc,Sn],sz),oC=bt([Dm,Sn,qm,uc,$ye,C$],Yz),T$=bt([Sn],G3),Bye=bt([Sn],e=>e.allowDataOverflow),E$=bt([T$,Bye],II),Wye=bt([qm],e=>e.filter(Hw)),Hye=bt([Uye,Wye,Yx,ZI],Zz),qye=bt([Hye,uc,zn,E$],Xz),Vye=bt([qm],Vz),Gye=bt([Dm,Sn,Vye,Qw,zn,gpe],J3,{memoizeOptions:{resultEqualityCheck:qw}}),Kye=bt([Qz,zn,Qp],ag),Yye=bt([Kye,zn],r$),Jye=bt([e$,zn,Qp],ag),Zye=bt([Jye,zn],a$),Xye=bt([t$,zn,Qp],ag),Qye=bt([Xye,zn],s$),ebe=bt([Yye,Qye,Zye],P1),tbe=bt([Sn,T$,E$,qye,Gye,ebe,Ua,zn],Z3),Mp=bt([Sn,Ua,Dm,oC,Yx,zn,tbe],X3),rbe=bt([Mp,Sn,iC],eC),abe=bt([Sn,Mp,rbe,zn],rC),A$=e=>{var r=zn(e),a=Qp(e),s=!1;return ry(e,r,a,s)},O$=bt([Sn,A$],Uw),sbe=bt([Sn,iC,abe,O$],z3),P$=bt([sbe],g3),nbe=bt([Ua,oC,Sn,zn],m$),ibe=bt([Ua,oC,Sn,zn],o$),obe=(e,r,a,s,n,i,o,l)=>{if(r){var{type:c}=r,u=i0(e,l);if(s){var h=a==="scaleBand"&&s.bandwidth?s.bandwidth()/2:2,f=c==="category"&&s.bandwidth?s.bandwidth()/h:0;return f=l==="angleAxis"&&n!=null&&(n==null?void 0:n.length)>=2?Ln(n[0]-n[1])*2*f:f,u&&o?o.map((y,b)=>{var w=s.map(y);return ja(w)?{coordinate:w+f,value:y,index:b,offset:f}:null}).filter(so):s.domain().map((y,b)=>{var w=s.map(y);return ja(w)?{coordinate:w+f,value:i?i[y]:y,index:b,offset:f}:null}).filter(so)}}},cu=bt([Ua,Sn,iC,P$,A$,nbe,ibe,zn],obe),lC=bt([p$,g$,uye],(e,r,a)=>f$(a.shared,e,r)),D$=e=>e.tooltip.settings.trigger,cC=e=>e.tooltip.settings.defaultIndex,sy=bt([sg,lC,D$,cC],j$),Rm=bt([sy,Dm,Pp,Mp],Wf),R$=bt([cu,Rm],x$),dC=bt([sy],e=>{if(e)return e.dataKey}),M$=bt([sy],e=>{if(e)return e.graphicalItemId}),L$=bt([sg,lC,D$,cC],k$),lbe=bt([su,nu,Ua,kn,cu,cC,L$],_$),cbe=bt([sy,lbe],(e,r)=>e!=null&&e.coordinate?e.coordinate:r),dbe=bt([sy],e=>{var r;return(r=e==null?void 0:e.active)!==null&&r!==void 0?r:!1}),ube=bt([L$,Rm,uc,Pp,R$,N$,lC],S$);bt([ube],e=>{if(e!=null){var r=e.map(a=>a.payload).filter(a=>a!=null);return Array.from(new Set(r))}});function bP(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function vP(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?bP(Object(a),!0).forEach(function(s){mbe(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):bP(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function mbe(e,r,a){return(r=hbe(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function hbe(e){var r=pbe(e,"string");return typeof r=="symbol"?r:r+""}function pbe(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var gbe=()=>kr(Sn),fbe=()=>{var e=gbe(),r=kr(cu),a=kr(P$);return c1(!e||!a?void 0:vP(vP({},e),{},{scale:a}),r)};function wP(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function Vh(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?wP(Object(a),!0).forEach(function(s){xbe(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):wP(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function xbe(e,r,a){return(r=ybe(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function ybe(e){var r=bbe(e,"string");return typeof r=="symbol"?r:r+""}function bbe(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var vbe=(e,r,a,s)=>{var n=r.find(i=>i&&i.index===a);if(n){if(e==="horizontal")return{x:n.coordinate,y:s.relativeY};if(e==="vertical")return{x:s.relativeX,y:n.coordinate}}return{x:0,y:0}},wbe=(e,r,a,s)=>{var n=r.find(u=>u&&u.index===a);if(n){if(e==="centric"){var i=n.coordinate,{radius:o}=s;return Vh(Vh(Vh({},s),on(s.cx,s.cy,o,i)),{},{angle:i,radius:o})}var l=n.coordinate,{angle:c}=s;return Vh(Vh(Vh({},s),on(s.cx,s.cy,l,c)),{},{angle:c,radius:l})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function jbe(e,r){var{relativeX:a,relativeY:s}=e;return a>=r.left&&a<=r.left+r.width&&s>=r.top&&s<=r.top+r.height}var F$=(e,r,a,s,n)=>{var i,o=(i=r==null?void 0:r.length)!==null&&i!==void 0?i:0;if(o<=1||e==null)return 0;if(s==="angleAxis"&&n!=null&&Math.abs(Math.abs(n[1]-n[0])-360)<=1e-6)for(var l=0;l<o;l++){var c,u,h,f,y,b=l>0?(c=a[l-1])===null||c===void 0?void 0:c.coordinate:(u=a[o-1])===null||u===void 0?void 0:u.coordinate,w=(h=a[l])===null||h===void 0?void 0:h.coordinate,v=l>=o-1?(f=a[0])===null||f===void 0?void 0:f.coordinate:(y=a[l+1])===null||y===void 0?void 0:y.coordinate,k=void 0;if(!(b==null||w==null||v==null))if(Ln(w-b)!==Ln(v-w)){var S=[];if(Ln(v-w)===Ln(n[1]-n[0])){k=v;var N=w+n[1]-n[0];S[0]=Math.min(N,(N+b)/2),S[1]=Math.max(N,(N+b)/2)}else{k=b;var C=v+n[1]-n[0];S[0]=Math.min(w,(C+w)/2),S[1]=Math.max(w,(C+w)/2)}var O=[Math.min(w,(k+w)/2),Math.max(w,(k+w)/2)];if(e>O[0]&&e<=O[1]||e>=S[0]&&e<=S[1]){var T;return(T=a[l])===null||T===void 0?void 0:T.index}}else{var P=Math.min(b,v),E=Math.max(b,v);if(e>(P+w)/2&&e<=(E+w)/2){var R;return(R=a[l])===null||R===void 0?void 0:R.index}}}else if(r)for(var z=0;z<o;z++){var G=r[z];if(G!=null){var ae=r[z+1],ee=r[z-1];if(z===0&&ae!=null&&e<=(G.coordinate+ae.coordinate)/2||z===o-1&&ee!=null&&e>(G.coordinate+ee.coordinate)/2||z>0&&z<o-1&&ee!=null&&ae!=null&&e>(G.coordinate+ee.coordinate)/2&&e<=(G.coordinate+ae.coordinate)/2)return G.index}}return-1},_be=()=>kr(l3),uC=(e,r)=>r,I$=(e,r,a)=>a,mC=(e,r,a,s)=>s,kbe=bt(cu,e=>bw(e,r=>r.coordinate)),hC=bt([sg,uC,I$,mC],j$),pC=bt([hC,Dm,Pp,Mp],Wf),Nbe=(e,r,a)=>{if(r!=null){var s=sg(e);return r==="axis"?a==="hover"?s.axisInteraction.hover.dataKey:s.axisInteraction.click.dataKey:a==="hover"?s.itemInteraction.hover.dataKey:s.itemInteraction.click.dataKey}},z$=bt([sg,uC,I$,mC],k$),R1=bt([su,nu,Ua,kn,cu,mC,z$],_$),Sbe=bt([hC,R1],(e,r)=>{var a;return(a=e.coordinate)!==null&&a!==void 0?a:r}),$$=bt([cu,pC],x$),Cbe=bt([z$,pC,uc,Pp,$$,N$,uC],S$),Tbe=bt([hC,pC],(e,r)=>({isActive:e.active&&r!=null,activeIndex:r})),Ebe=(e,r,a,s,n,i,o)=>{if(!(!e||!a||!s||!n)&&jbe(e,o)){var l=f0e(e,r),c=F$(l,i,n,a,s),u=vbe(r,n,c,e);return{activeIndex:String(c),activeCoordinate:u}}},Abe=(e,r,a,s,n,i,o)=>{if(!(!e||!s||!n||!i||!a)){var l=rpe(e,a);if(l){var c=x0e(l,r),u=F$(c,o,i,s,n),h=wbe(r,i,u,l);return{activeIndex:String(u),activeCoordinate:h}}}},Obe=(e,r,a,s,n,i,o,l)=>{if(!(!e||!r||!s||!n||!i))return r==="horizontal"||r==="vertical"?Ebe(e,r,s,n,i,o,l):Abe(e,r,a,s,n,i,o)},Pbe=bt(e=>e.zIndex.zIndexMap,(e,r)=>r,(e,r,a)=>a,(e,r,a)=>{if(r!=null){var s=e[r];if(s!=null)return a?s.panoramaElement:s.element}}),Dbe=bt(e=>e.zIndex.zIndexMap,e=>{var r=Object.keys(e).map(s=>parseInt(s,10)).concat(Object.values(ri)),a=Array.from(new Set(r));return a.sort((s,n)=>s-n)},{memoizeOptions:{resultEqualityCheck:Epe}});function jP(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function _P(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?jP(Object(a),!0).forEach(function(s){Rbe(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):jP(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function Rbe(e,r,a){return(r=Mbe(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Mbe(e){var r=Lbe(e,"string");return typeof r=="symbol"?r:r+""}function Lbe(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var Fbe={},Ibe={zIndexMap:Object.values(ri).reduce((e,r)=>_P(_P({},e),{},{[r]:{element:void 0,panoramaElement:void 0,consumers:0}}),Fbe)},zbe=new Set(Object.values(ri));function $be(e){return zbe.has(e)}var U$=wi({name:"zIndex",initialState:Ibe,reducers:{registerZIndexPortal:{reducer:(e,r)=>{var{zIndex:a}=r.payload;e.zIndexMap[a]?e.zIndexMap[a].consumers+=1:e.zIndexMap[a]={consumers:1,element:void 0,panoramaElement:void 0}},prepare:ys()},unregisterZIndexPortal:{reducer:(e,r)=>{var{zIndex:a}=r.payload;e.zIndexMap[a]&&(e.zIndexMap[a].consumers-=1,e.zIndexMap[a].consumers<=0&&!$be(a)&&delete e.zIndexMap[a])},prepare:ys()},registerZIndexPortalElement:{reducer:(e,r)=>{var{zIndex:a,element:s,isPanorama:n}=r.payload;e.zIndexMap[a]?n?e.zIndexMap[a].panoramaElement=s:e.zIndexMap[a].element=s:e.zIndexMap[a]={consumers:0,element:n?void 0:s,panoramaElement:n?s:void 0}},prepare:ys()},unregisterZIndexPortalElement:{reducer:(e,r)=>{var{zIndex:a}=r.payload;e.zIndexMap[a]&&(r.payload.isPanorama?e.zIndexMap[a].panoramaElement=void 0:e.zIndexMap[a].element=void 0)},prepare:ys()}}}),{registerZIndexPortal:Ube,unregisterZIndexPortal:q2,registerZIndexPortalElement:Bbe,unregisterZIndexPortalElement:Wbe}=U$.actions,Hbe=U$.reducer;function mc(e){var{zIndex:r,children:a}=e,s=K0e(),n=s&&r!==void 0&&r!==0,i=ho(),o=p.useRef(void 0),l=p.useRef(new Set),c=ss(),u=kr(f=>Pbe(f,r,i));if(p.useLayoutEffect(()=>{if(!n){var f=l.current;f.forEach(b=>{c(q2({zIndex:b}))}),f.clear(),o.current=void 0;return}if(l.current.has(r)||(c(Ube({zIndex:r})),l.current.add(r)),u){o.current=u;var y=l.current;y.forEach(b=>{b!==r&&(c(q2({zIndex:b})),y.delete(b))})}},[c,r,n,u]),p.useLayoutEffect(()=>{var f=l.current;return()=>{f.forEach(y=>{c(q2({zIndex:y}))}),f.clear()}},[c]),!n)return a;var h=u!=null?u:o.current;return h?wx.createPortal(a,h):null}function j4(){return j4=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},j4.apply(null,arguments)}function kP(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function zb(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?kP(Object(a),!0).forEach(function(s){qbe(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):kP(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function qbe(e,r,a){return(r=Vbe(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Vbe(e){var r=Gbe(e,"string");return typeof r=="symbol"?r:r+""}function Gbe(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Kbe(e){var{cursor:r,cursorComp:a,cursorProps:s}=e;return p.isValidElement(r)?p.cloneElement(r,s):p.createElement(a,s)}function Ybe(e){var r,{coordinate:a,payload:s,index:n,offset:i,tooltipAxisBandSize:o,layout:l,cursor:c,tooltipEventType:u,chartName:h}=e,f=a,y=s,b=n;if(!c||!f||h!=="ScatterChart"&&u!=="axis")return null;var w,v,k;if(h==="ScatterChart")w=f,v=xhe,k=ri.cursorLine;else if(h==="BarChart")w=yhe(l,f,i,o),v=PI,k=ri.cursorRectangle;else if(l==="radial"&&mF(f)){var{cx:S,cy:N,radius:C,startAngle:O,endAngle:T}=RI(f);w={cx:S,cy:N,startAngle:O,endAngle:T,innerRadius:C,outerRadius:C},v=LI,k=ri.cursorLine}else w={points:ipe(l,f,i)},v=s3,k=ri.cursorLine;var P=typeof c=="object"&&"className"in c?c.className:void 0,E=zb(zb(zb(zb({stroke:"#ccc",pointerEvents:"none"},i),w),rx(c)),{},{payload:y,payloadIndex:b,className:va("recharts-tooltip-cursor",P)});return p.createElement(mc,{zIndex:(r=e.zIndex)!==null&&r!==void 0?r:k},p.createElement(Kbe,{cursor:c,cursorComp:v,cursorProps:E}))}function Jbe(e){var r=fbe(),a=hI(),s=Jp(),n=_be();return r==null||a==null||s==null||n==null?null:p.createElement(Ybe,j4({},e,{offset:a,layout:s,tooltipAxisBandSize:r,chartName:n}))}var B$=p.createContext(null),Zbe=()=>p.useContext(B$),V2={exports:{}},NP;function Xbe(){return NP||(NP=1,(function(e){var r=Object.prototype.hasOwnProperty,a="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(a=!1));function n(c,u,h){this.fn=c,this.context=u,this.once=h||!1}function i(c,u,h,f,y){if(typeof h!="function")throw new TypeError("The listener must be a function");var b=new n(h,f||c,y),w=a?a+u:u;return c._events[w]?c._events[w].fn?c._events[w]=[c._events[w],b]:c._events[w].push(b):(c._events[w]=b,c._eventsCount++),c}function o(c,u){--c._eventsCount===0?c._events=new s:delete c._events[u]}function l(){this._events=new s,this._eventsCount=0}l.prototype.eventNames=function(){var u=[],h,f;if(this._eventsCount===0)return u;for(f in h=this._events)r.call(h,f)&&u.push(a?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(h)):u},l.prototype.listeners=function(u){var h=a?a+u:u,f=this._events[h];if(!f)return[];if(f.fn)return[f.fn];for(var y=0,b=f.length,w=new Array(b);y<b;y++)w[y]=f[y].fn;return w},l.prototype.listenerCount=function(u){var h=a?a+u:u,f=this._events[h];return f?f.fn?1:f.length:0},l.prototype.emit=function(u,h,f,y,b,w){var v=a?a+u:u;if(!this._events[v])return!1;var k=this._events[v],S=arguments.length,N,C;if(k.fn){switch(k.once&&this.removeListener(u,k.fn,void 0,!0),S){case 1:return k.fn.call(k.context),!0;case 2:return k.fn.call(k.context,h),!0;case 3:return k.fn.call(k.context,h,f),!0;case 4:return k.fn.call(k.context,h,f,y),!0;case 5:return k.fn.call(k.context,h,f,y,b),!0;case 6:return k.fn.call(k.context,h,f,y,b,w),!0}for(C=1,N=new Array(S-1);C<S;C++)N[C-1]=arguments[C];k.fn.apply(k.context,N)}else{var O=k.length,T;for(C=0;C<O;C++)switch(k[C].once&&this.removeListener(u,k[C].fn,void 0,!0),S){case 1:k[C].fn.call(k[C].context);break;case 2:k[C].fn.call(k[C].context,h);break;case 3:k[C].fn.call(k[C].context,h,f);break;case 4:k[C].fn.call(k[C].context,h,f,y);break;default:if(!N)for(T=1,N=new Array(S-1);T<S;T++)N[T-1]=arguments[T];k[C].fn.apply(k[C].context,N)}}return!0},l.prototype.on=function(u,h,f){return i(this,u,h,f,!1)},l.prototype.once=function(u,h,f){return i(this,u,h,f,!0)},l.prototype.removeListener=function(u,h,f,y){var b=a?a+u:u;if(!this._events[b])return this;if(!h)return o(this,b),this;var w=this._events[b];if(w.fn)w.fn===h&&(!y||w.once)&&(!f||w.context===f)&&o(this,b);else{for(var v=0,k=[],S=w.length;v<S;v++)(w[v].fn!==h||y&&!w[v].once||f&&w[v].context!==f)&&k.push(w[v]);k.length?this._events[b]=k.length===1?k[0]:k:o(this,b)}return this},l.prototype.removeAllListeners=function(u){var h;return u?(h=a?a+u:u,this._events[h]&&o(this,h)):(this._events=new s,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=a,l.EventEmitter=l,e.exports=l})(V2)),V2.exports}var Qbe=Xbe();const eve=tu(Qbe);var fx=new eve,_4="recharts.syncEvent.tooltip",SP="recharts.syncEvent.brush",W$=(e,r)=>{if(r&&Array.isArray(e)){var a=Number.parseInt(r,10);if(!$c(a))return e[a]}},tve={chartName:"",tooltipPayloadSearcher:()=>{},eventEmitter:void 0,defaultTooltipEventType:"axis"},H$=wi({name:"options",initialState:tve,reducers:{createEventEmitter:e=>{e.eventEmitter==null&&(e.eventEmitter=Symbol("rechartsEventEmitter"))}}}),rve=H$.reducer,{createEventEmitter:ave}=H$.actions;function sve(e){return e.tooltip.syncInteraction}var nve={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},q$=wi({name:"chartData",initialState:nve,reducers:{setChartData(e,r){if(e.chartData=r.payload,r.payload==null){e.dataStartIndex=0,e.dataEndIndex=0;return}r.payload.length>0&&e.dataEndIndex!==r.payload.length-1&&(e.dataEndIndex=r.payload.length-1)},setComputedData(e,r){e.computedData=r.payload},setDataStartEndIndexes(e,r){var{startIndex:a,endIndex:s}=r.payload;a!=null&&(e.dataStartIndex=a),s!=null&&(e.dataEndIndex=s)}}}),{setChartData:CP,setDataStartEndIndexes:ive,setComputedData:f3e}=q$.actions,ove=q$.reducer,lve=["x","y"];function TP(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function Gh(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?TP(Object(a),!0).forEach(function(s){cve(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):TP(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function cve(e,r,a){return(r=dve(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function dve(e){var r=uve(e,"string");return typeof r=="symbol"?r:r+""}function uve(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function mve(e,r){if(e==null)return{};var a,s,n=hve(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function hve(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}function pve(){var e=kr(c3),r=kr(d3),a=ss(),s=kr(XI),n=kr(cu),i=Jp(),o=Rw(),l=kr(c=>c.rootProps.className);p.useEffect(()=>{if(e==null)return Yp;var c=(u,h,f)=>{if(r!==f&&e===u){if(h.payload.active===!1){a(Sf({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}if(s==="index"){var y;if(o&&h!==null&&h!==void 0&&(y=h.payload)!==null&&y!==void 0&&y.coordinate&&h.payload.sourceViewBox){var b=h.payload.coordinate,{x:w,y:v}=b,k=mve(b,lve),{x:S,y:N,width:C,height:O}=h.payload.sourceViewBox,T=Gh(Gh({},k),{},{x:o.x+(C?(w-S)/C:0)*o.width,y:o.y+(O?(v-N)/O:0)*o.height});a(Gh(Gh({},h),{},{payload:Gh(Gh({},h.payload),{},{coordinate:T})}))}else a(h);return}if(n!=null){var P;if(typeof s=="function"){var E={activeTooltipIndex:h.payload.index==null?void 0:Number(h.payload.index),isTooltipActive:h.payload.active,activeIndex:h.payload.index==null?void 0:Number(h.payload.index),activeLabel:h.payload.label,activeDataKey:h.payload.dataKey,activeCoordinate:h.payload.coordinate},R=s(n,E);P=n[R]}else s==="value"&&(P=n.find(q=>String(q.value)===h.payload.label));var{coordinate:z}=h.payload;if(z==null||o==null){a(Sf({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}if(P==null){a(Sf({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:h.payload.sourceViewBox,graphicalItemId:void 0}));return}var{x:G,y:ae}=z,ee=Math.min(G,o.x+o.width),ne=Math.min(ae,o.y+o.height),te={x:i==="horizontal"?P.coordinate:ee,y:i==="horizontal"?ne:P.coordinate},Y=Sf({active:h.payload.active,coordinate:te,dataKey:h.payload.dataKey,index:String(P.index),label:h.payload.label,sourceViewBox:h.payload.sourceViewBox,graphicalItemId:h.payload.graphicalItemId});a(Y)}}};return fx.on(_4,c),()=>{fx.off(_4,c)}},[l,a,r,e,s,n,i,o])}function gve(){var e=kr(c3),r=kr(d3),a=ss();p.useEffect(()=>{if(e==null)return Yp;var s=(n,i,o)=>{r!==o&&e===n&&a(ive(i))};return fx.on(SP,s),()=>{fx.off(SP,s)}},[a,r,e])}function fve(){var e=ss();p.useEffect(()=>{e(ave())},[e]),pve(),gve()}function xve(e,r,a,s,n,i){var o=kr(w=>Nbe(w,e,r)),l=kr(M$),c=kr(d3),u=kr(c3),h=kr(XI),f=kr(sve),y=(f==null?void 0:f.sourceViewBox)!=null,b=Rw();p.useEffect(()=>{if(!y&&u!=null&&c!=null){var w=Sf({active:i,coordinate:a,dataKey:o,index:n,label:typeof s=="number"?String(s):s,sourceViewBox:b,graphicalItemId:l});fx.emit(_4,u,w,c)}},[y,a,o,l,n,s,c,u,h,i,b])}function EP(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function AP(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?EP(Object(a),!0).forEach(function(s){yve(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):EP(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function yve(e,r,a){return(r=bve(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function bve(e){var r=vve(e,"string");return typeof r=="symbol"?r:r+""}function vve(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function wve(e){return e.dataKey}function jve(e,r){return p.isValidElement(e)?p.cloneElement(e,r):typeof e=="function"?p.createElement(e,r):p.createElement(Vme,r)}var OP=[],_ve={allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",axisId:0,contentStyle:{},cursor:!0,filterNull:!0,includeHidden:!1,isAnimationActive:"auto",itemSorter:"name",itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,wrapperStyle:{}};function $b(e){var r,a,s=In(e,_ve),{active:n,allowEscapeViewBox:i,animationDuration:o,animationEasing:l,content:c,filterNull:u,isAnimationActive:h,offset:f,payloadUniqBy:y,position:b,reverseDirection:w,useTranslate3d:v,wrapperStyle:k,cursor:S,shared:N,trigger:C,defaultIndex:O,portal:T,axisId:P}=s,E=ss(),R=typeof O=="number"?String(O):O;p.useEffect(()=>{E(fye({shared:N,trigger:C,axisId:P,active:n,defaultIndex:R}))},[E,N,C,P,n,R]);var z=Rw(),G=CI(),ae=dye(N),{activeIndex:ee,isActive:ne}=(r=kr(de=>Tbe(de,ae,C,R)))!==null&&r!==void 0?r:{},te=kr(de=>Cbe(de,ae,C,R)),Y=kr(de=>$$(de,ae,C,R)),q=kr(de=>Sbe(de,ae,C,R)),H=te,U=Zbe(),re=(a=n!=null?n:ne)!==null&&a!==void 0?a:!1,[X,V]=TF([H,re]),I=ae==="axis"?Y:void 0;xve(ae,C,q,I,ee,re);var B=T!=null?T:U;if(B==null||z==null||ae==null)return null;var Q=H!=null?H:OP;re||(Q=OP),u&&Q.length&&(Q=_F(Q.filter(de=>de.value!=null&&(de.hide!==!0||s.includeHidden)),y,wve));var ie=Q.length>0,me=AP(AP({},s),{},{payload:Q,label:I,active:re,activeIndex:ee,coordinate:q,accessibilityLayer:G}),he=p.createElement(ahe,{allowEscapeViewBox:i,animationDuration:o,animationEasing:l,isAnimationActive:h,active:re,coordinate:q,hasPayload:ie,offset:f,position:b,reverseDirection:w,useTranslate3d:v,viewBox:z,wrapperStyle:k,lastBoundingBox:X,innerRef:V,hasPortalFromProps:!!T},jve(c,me));return p.createElement(p.Fragment,null,wx.createPortal(he,B),re&&p.createElement(Jbe,{cursor:S,tooltipEventType:ae,coordinate:q,payload:Q,index:ee}))}var Lp=e=>null;Lp.displayName="Cell";function kve(e,r,a){return(r=Nve(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Nve(e){var r=Sve(e,"string");return typeof r=="symbol"?r:r+""}function Sve(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}class Cve{constructor(r){kve(this,"cache",new Map),this.maxSize=r}get(r){var a=this.cache.get(r);return a!==void 0&&(this.cache.delete(r),this.cache.set(r,a)),a}set(r,a){if(this.cache.has(r))this.cache.delete(r);else if(this.cache.size>=this.maxSize){var s=this.cache.keys().next().value;s!=null&&this.cache.delete(s)}this.cache.set(r,a)}clear(){this.cache.clear()}size(){return this.cache.size}}function PP(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function Tve(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?PP(Object(a),!0).forEach(function(s){Eve(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):PP(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function Eve(e,r,a){return(r=Ave(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Ave(e){var r=Ove(e,"string");return typeof r=="symbol"?r:r+""}function Ove(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var Pve={cacheSize:2e3,enableCache:!0},V$=Tve({},Pve),DP=new Cve(V$.cacheSize),Dve={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},RP="recharts_measurement_span";function Rve(e,r){var a=r.fontSize||"",s=r.fontFamily||"",n=r.fontWeight||"",i=r.fontStyle||"",o=r.letterSpacing||"",l=r.textTransform||"";return"".concat(e,"|").concat(a,"|").concat(s,"|").concat(n,"|").concat(i,"|").concat(o,"|").concat(l)}var MP=(e,r)=>{try{var a=document.getElementById(RP);a||(a=document.createElement("span"),a.setAttribute("id",RP),a.setAttribute("aria-hidden","true"),document.body.appendChild(a)),Object.assign(a.style,Dve,r),a.textContent="".concat(e);var s=a.getBoundingClientRect();return{width:s.width,height:s.height}}catch(n){return{width:0,height:0}}},Hf=function(r){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(r==null||Gx.isSsr)return{width:0,height:0};if(!V$.enableCache)return MP(r,a);var s=Rve(r,a),n=DP.get(s);if(n)return n;var i=MP(r,a);return DP.set(s,i),i},G$;function Mve(e,r,a){return(r=Lve(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Lve(e){var r=Fve(e,"string");return typeof r=="symbol"?r:r+""}function Fve(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var LP=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,FP=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,Ive=/^(px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q)$/,zve=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,$ve={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},Uve=["cm","mm","pt","pc","in","Q","px"];function Bve(e){return Uve.includes(e)}var hp="NaN";function Wve(e,r){return e*$ve[r]}class Jn{static parse(r){var a,[,s,n]=(a=zve.exec(r))!==null&&a!==void 0?a:[];return s==null?Jn.NaN:new Jn(parseFloat(s),n!=null?n:"")}constructor(r,a){this.num=r,this.unit=a,this.num=r,this.unit=a,$c(r)&&(this.unit=""),a!==""&&!Ive.test(a)&&(this.num=NaN,this.unit=""),Bve(a)&&(this.num=Wve(r,a),this.unit="px")}add(r){return this.unit!==r.unit?new Jn(NaN,""):new Jn(this.num+r.num,this.unit)}subtract(r){return this.unit!==r.unit?new Jn(NaN,""):new Jn(this.num-r.num,this.unit)}multiply(r){return this.unit!==""&&r.unit!==""&&this.unit!==r.unit?new Jn(NaN,""):new Jn(this.num*r.num,this.unit||r.unit)}divide(r){return this.unit!==""&&r.unit!==""&&this.unit!==r.unit?new Jn(NaN,""):new Jn(this.num/r.num,this.unit||r.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return $c(this.num)}}G$=Jn;Mve(Jn,"NaN",new G$(NaN,""));function K$(e){if(e==null||e.includes(hp))return hp;for(var r=e;r.includes("*")||r.includes("/");){var a,[,s,n,i]=(a=LP.exec(r))!==null&&a!==void 0?a:[],o=Jn.parse(s!=null?s:""),l=Jn.parse(i!=null?i:""),c=n==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return hp;r=r.replace(LP,c.toString())}for(;r.includes("+")||/.-\d+(?:\.\d+)?/.test(r);){var u,[,h,f,y]=(u=FP.exec(r))!==null&&u!==void 0?u:[],b=Jn.parse(h!=null?h:""),w=Jn.parse(y!=null?y:""),v=f==="+"?b.add(w):b.subtract(w);if(v.isNaN())return hp;r=r.replace(FP,v.toString())}return r}var IP=/\(([^()]*)\)/;function Hve(e){for(var r=e,a;(a=IP.exec(r))!=null;){var[,s]=a;r=r.replace(IP,K$(s))}return r}function qve(e){var r=e.replace(/\s+/g,"");return r=Hve(r),r=K$(r),r}function Vve(e){try{return qve(e)}catch(r){return hp}}function G2(e){var r=Vve(e.slice(5,-1));return r===hp?"":r}var Gve=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],Kve=["dx","dy","angle","className","breakAll"];function k4(){return k4=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},k4.apply(null,arguments)}function zP(e,r){if(e==null)return{};var a,s,n=Yve(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function Yve(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}var Y$=/[ \f\n\r\t\v\u2028\u2029]+/,J$=e=>{var{children:r,breakAll:a,style:s}=e;try{var n=[];_n(r)||(a?n=r.toString().split(""):n=r.toString().split(Y$));var i=n.map(l=>({word:l,width:Hf(l,s).width})),o=a?0:Hf(" ",s).width;return{wordsWithComputedWidth:i,spaceWidth:o}}catch(l){return null}};function Z$(e){return e==="start"||e==="middle"||e==="end"||e==="inherit"}function Jve(e){return _n(e)||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}var X$=(e,r,a,s)=>e.reduce((n,i)=>{var{word:o,width:l}=i,c=n[n.length-1];if(c&&l!=null&&(r==null||s||c.width+l+a<Number(r)))c.words.push(o),c.width+=l+a;else{var u={words:[o],width:l};n.push(u)}return n},[]),Q$=e=>e.reduce((r,a)=>r.width>a.width?r:a),Zve="…",$P=(e,r,a,s,n,i,o,l)=>{var c=e.slice(0,r),u=J$({breakAll:a,style:s,children:c+Zve});if(!u)return[!1,[]];var h=X$(u.wordsWithComputedWidth,i,o,l),f=h.length>n||Q$(h).width>Number(i);return[f,h]},Xve=(e,r,a,s,n)=>{var{maxLines:i,children:o,style:l,breakAll:c}=e,u=_r(i),h=String(o),f=X$(r,s,a,n);if(!u||n)return f;var y=f.length>i||Q$(f).width>Number(s);if(!y)return f;for(var b=0,w=h.length-1,v=0,k;b<=w&&v<=h.length-1;){var S=Math.floor((b+w)/2),N=S-1,[C,O]=$P(h,N,c,l,i,s,a,n),[T]=$P(h,S,c,l,i,s,a,n);if(!C&&!T&&(b=S+1),C&&T&&(w=S-1),!C&&T){k=O;break}v++}return k||f},UP=e=>{var r=_n(e)?[]:e.toString().split(Y$);return[{words:r,width:void 0}]},Qve=e=>{var{width:r,scaleToFit:a,children:s,style:n,breakAll:i,maxLines:o}=e;if((r||a)&&!Gx.isSsr){var l,c,u=J$({breakAll:i,children:s,style:n});if(u){var{wordsWithComputedWidth:h,spaceWidth:f}=u;l=h,c=f}else return UP(s);return Xve({breakAll:i,children:s,maxLines:o,style:n},l,c,r,!!a)}return UP(s)},eU="#808080",e1e={angle:0,breakAll:!1,capHeight:"0.71em",fill:eU,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},aj=p.forwardRef((e,r)=>{var a=In(e,e1e),{x:s,y:n,lineHeight:i,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:h}=a,f=zP(a,Gve),y=p.useMemo(()=>Qve({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:c,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,c,f.style,f.width]),{dx:b,dy:w,angle:v,className:k,breakAll:S}=f,N=zP(f,Kve);if(!Uc(s)||!Uc(n)||y.length===0)return null;var C=Number(s)+(_r(b)?b:0),O=Number(n)+(_r(w)?w:0);if(!ja(C)||!ja(O))return null;var T;switch(h){case"start":T=G2("calc(".concat(o,")"));break;case"middle":T=G2("calc(".concat((y.length-1)/2," * -").concat(i," + (").concat(o," / 2))"));break;default:T=G2("calc(".concat(y.length-1," * -").concat(i,")"));break}var P=[],E=y[0];if(c&&E!=null){var R=E.width,{width:z}=f;P.push("scale(".concat(_r(z)&&_r(R)?z/R:1,")"))}return v&&P.push("rotate(".concat(v,", ").concat(C,", ").concat(O,")")),P.length&&(N.transform=P.join(" ")),p.createElement("text",k4({},bl(N),{ref:r,x:C,y:O,className:va("recharts-text",k),textAnchor:u,fill:l.includes("url")?eU:l}),y.map((G,ae)=>{var ee=G.words.join(S?"":" ");return p.createElement("tspan",{x:C,dy:ae===0?T:i,key:"".concat(ee,"-").concat(ae)},ee)}))});aj.displayName="Text";function BP(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function Cc(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?BP(Object(a),!0).forEach(function(s){t1e(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):BP(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function t1e(e,r,a){return(r=r1e(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function r1e(e){var r=a1e(e,"string");return typeof r=="symbol"?r:r+""}function a1e(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var s1e=e=>{var{viewBox:r,position:a,offset:s=0,parentViewBox:n}=e,{x:i,y:o,height:l,upperWidth:c,lowerWidth:u}=QS(r),h=i,f=i+(c-u)/2,y=(h+f)/2,b=(c+u)/2,w=h+c/2,v=l>=0?1:-1,k=v*s,S=v>0?"end":"start",N=v>0?"start":"end",C=c>=0?1:-1,O=C*s,T=C>0?"end":"start",P=C>0?"start":"end",E=n;if(a==="top"){var R={x:h+c/2,y:o-k,horizontalAnchor:"middle",verticalAnchor:S};return E&&(R.height=Math.max(o-E.y,0),R.width=c),R}if(a==="bottom"){var z={x:f+u/2,y:o+l+k,horizontalAnchor:"middle",verticalAnchor:N};return E&&(z.height=Math.max(E.y+E.height-(o+l),0),z.width=u),z}if(a==="left"){var G={x:y-O,y:o+l/2,horizontalAnchor:T,verticalAnchor:"middle"};return E&&(G.width=Math.max(G.x-E.x,0),G.height=l),G}if(a==="right"){var ae={x:y+b+O,y:o+l/2,horizontalAnchor:P,verticalAnchor:"middle"};return E&&(ae.width=Math.max(E.x+E.width-ae.x,0),ae.height=l),ae}var ee=E?{width:b,height:l}:{};return a==="insideLeft"?Cc({x:y+O,y:o+l/2,horizontalAnchor:P,verticalAnchor:"middle"},ee):a==="insideRight"?Cc({x:y+b-O,y:o+l/2,horizontalAnchor:T,verticalAnchor:"middle"},ee):a==="insideTop"?Cc({x:h+c/2,y:o+k,horizontalAnchor:"middle",verticalAnchor:N},ee):a==="insideBottom"?Cc({x:f+u/2,y:o+l-k,horizontalAnchor:"middle",verticalAnchor:S},ee):a==="insideTopLeft"?Cc({x:h+O,y:o+k,horizontalAnchor:P,verticalAnchor:N},ee):a==="insideTopRight"?Cc({x:h+c-O,y:o+k,horizontalAnchor:T,verticalAnchor:N},ee):a==="insideBottomLeft"?Cc({x:f+O,y:o+l-k,horizontalAnchor:P,verticalAnchor:S},ee):a==="insideBottomRight"?Cc({x:f+u-O,y:o+l-k,horizontalAnchor:T,verticalAnchor:S},ee):a&&typeof a=="object"&&(_r(a.x)||Tm(a.x))&&(_r(a.y)||Tm(a.y))?Cc({x:i+xi(a.x,b),y:o+xi(a.y,l),horizontalAnchor:"end",verticalAnchor:"end"},ee):Cc({x:w,y:o+l/2,horizontalAnchor:"middle",verticalAnchor:"middle"},ee)},n1e=["labelRef"],i1e=["content"];function WP(e,r){if(e==null)return{};var a,s,n=o1e(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function o1e(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}function HP(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function Cf(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?HP(Object(a),!0).forEach(function(s){l1e(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):HP(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function l1e(e,r,a){return(r=c1e(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function c1e(e){var r=d1e(e,"string");return typeof r=="symbol"?r:r+""}function d1e(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Od(){return Od=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},Od.apply(null,arguments)}var tU=p.createContext(null),u1e=e=>{var{x:r,y:a,upperWidth:s,lowerWidth:n,width:i,height:o,children:l}=e,c=p.useMemo(()=>({x:r,y:a,upperWidth:s,lowerWidth:n,width:i,height:o}),[r,a,s,n,i,o]);return p.createElement(tU.Provider,{value:c},l)},rU=()=>{var e=p.useContext(tU),r=Rw();return e||(r?QS(r):void 0)},m1e=p.createContext(null),h1e=()=>{var e=p.useContext(m1e),r=kr(az);return e||r},p1e=e=>{var{value:r,formatter:a}=e,s=_n(e.children)?r:e.children;return typeof a=="function"?a(s):s},gC=e=>e!=null&&typeof e=="function",g1e=(e,r)=>{var a=Ln(r-e),s=Math.min(Math.abs(r-e),360);return a*s},f1e=(e,r,a,s,n)=>{var{offset:i,className:o}=e,{cx:l,cy:c,innerRadius:u,outerRadius:h,startAngle:f,endAngle:y,clockWise:b}=n,w=(u+h)/2,v=g1e(f,y),k=v>=0?1:-1,S,N;switch(r){case"insideStart":S=f+k*i,N=b;break;case"insideEnd":S=y-k*i,N=!b;break;case"end":S=y+k*i,N=b;break;default:throw new Error("Unsupported position ".concat(r))}N=v<=0?N:!N;var C=on(l,c,w,S),O=on(l,c,w,S+(N?1:-1)*359),T="M".concat(C.x,",").concat(C.y,`
|
||
A`).concat(w,",").concat(w,",0,1,").concat(N?0:1,`,
|
||
`).concat(O.x,",").concat(O.y),P=_n(e.id)?ax("recharts-radial-line-"):e.id;return p.createElement("text",Od({},s,{dominantBaseline:"central",className:va("recharts-radial-bar-label",o)}),p.createElement("defs",null,p.createElement("path",{id:P,d:T})),p.createElement("textPath",{xlinkHref:"#".concat(P)},a))},x1e=(e,r,a)=>{var{cx:s,cy:n,innerRadius:i,outerRadius:o,startAngle:l,endAngle:c}=e,u=(l+c)/2;if(a==="outside"){var{x:h,y:f}=on(s,n,o+r,u);return{x:h,y:f,textAnchor:h>=s?"start":"end",verticalAnchor:"middle"}}if(a==="center")return{x:s,y:n,textAnchor:"middle",verticalAnchor:"middle"};if(a==="centerTop")return{x:s,y:n,textAnchor:"middle",verticalAnchor:"start"};if(a==="centerBottom")return{x:s,y:n,textAnchor:"middle",verticalAnchor:"end"};var y=(i+o)/2,{x:b,y:w}=on(s,n,y,u);return{x:b,y:w,textAnchor:"middle",verticalAnchor:"middle"}},pv=e=>e!=null&&"cx"in e&&_r(e.cx),y1e={angle:0,offset:5,zIndex:ri.label,position:"middle",textBreakAll:!1};function b1e(e){if(!pv(e))return e;var{cx:r,cy:a,outerRadius:s}=e,n=s*2;return{x:r-s,y:a-s,width:n,upperWidth:n,lowerWidth:n,height:n}}function $u(e){var r=In(e,y1e),{viewBox:a,parentViewBox:s,position:n,value:i,children:o,content:l,className:c="",textBreakAll:u,labelRef:h}=r,f=h1e(),y=rU(),b=n==="center"?y:f!=null?f:y,w,v,k;a==null?w=b:pv(a)?w=a:w=QS(a);var S=b1e(w);if(!w||_n(i)&&_n(o)&&!p.isValidElement(l)&&typeof l!="function")return null;var N=Cf(Cf({},r),{},{viewBox:w});if(p.isValidElement(l)){var{labelRef:C}=N,O=WP(N,n1e);return p.cloneElement(l,O)}if(typeof l=="function"){var{content:T}=N,P=WP(N,i1e);if(v=p.createElement(l,P),p.isValidElement(v))return v}else v=p1e(r);var E=bl(r);if(pv(w)){if(n==="insideStart"||n==="insideEnd"||n==="end")return f1e(r,n,v,E,w);k=x1e(w,r.offset,r.position)}else{if(!S)return null;var R=s1e({viewBox:S,position:n,offset:r.offset,parentViewBox:pv(s)?void 0:s});k=Cf(Cf({x:R.x,y:R.y,textAnchor:R.horizontalAnchor,verticalAnchor:R.verticalAnchor},R.width!==void 0?{width:R.width}:{}),R.height!==void 0?{height:R.height}:{})}return p.createElement(mc,{zIndex:r.zIndex},p.createElement(aj,Od({ref:h,className:va("recharts-label",c)},E,k,{textAnchor:Z$(E.textAnchor)?E.textAnchor:k.textAnchor,breakAll:u}),v))}$u.displayName="Label";var v1e=(e,r,a)=>{if(!e)return null;var s={viewBox:r,labelRef:a};return e===!0?p.createElement($u,Od({key:"label-implicit"},s)):Uc(e)?p.createElement($u,Od({key:"label-implicit",value:e},s)):p.isValidElement(e)?e.type===$u?p.cloneElement(e,Cf({key:"label-implicit"},s)):p.createElement($u,Od({key:"label-implicit",content:e},s)):gC(e)?p.createElement($u,Od({key:"label-implicit",content:e},s)):e&&typeof e=="object"?p.createElement($u,Od({},e,{key:"label-implicit"},s)):null};function w1e(e){var{label:r,labelRef:a}=e,s=rU();return v1e(r,s,a)||null}var j1e=["valueAccessor"],_1e=["dataKey","clockWise","id","textBreakAll","zIndex"];function M1(){return M1=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},M1.apply(null,arguments)}function qP(e,r){if(e==null)return{};var a,s,n=k1e(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function k1e(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}var N1e=e=>{var r=Array.isArray(e.value)?e.value[e.value.length-1]:e.value;if(Jve(r))return r},aU=p.createContext(void 0),S1e=aU.Provider,sU=p.createContext(void 0),C1e=sU.Provider;function T1e(){return p.useContext(aU)}function E1e(){return p.useContext(sU)}function _p(e){var{valueAccessor:r=N1e}=e,a=qP(e,j1e),{dataKey:s,clockWise:n,id:i,textBreakAll:o,zIndex:l}=a,c=qP(a,_1e),u=T1e(),h=E1e(),f=u||h;return!f||!f.length?null:p.createElement(mc,{zIndex:l!=null?l:ri.label},p.createElement(yi,{className:"recharts-label-list"},f.map((y,b)=>{var w,v=_n(s)?r(y,b):ls(y.payload,s),k=_n(i)?{}:{id:"".concat(i,"-").concat(b)};return p.createElement($u,M1({key:"label-".concat(b)},bl(y),c,k,{fill:(w=a.fill)!==null&&w!==void 0?w:y.fill,parentViewBox:y.parentViewBox,value:v,textBreakAll:o,viewBox:y.viewBox,index:b,zIndex:0}))})))}_p.displayName="LabelList";function nU(e){var{label:r}=e;return r?r===!0?p.createElement(_p,{key:"labelList-implicit"}):p.isValidElement(r)||gC(r)?p.createElement(_p,{key:"labelList-implicit",content:r}):typeof r=="object"?p.createElement(_p,M1({key:"labelList-implicit"},r,{type:String(r.type)})):null:null}var iU=e=>e.graphicalItems.polarItems,A1e=bt([Ds,Jx],U3),sj=bt([iU,Vs,A1e],W3),O1e=bt([sj],H3),nj=bt([O1e,Kx],q3),P1e=bt([nj,Vs,sj],Kz);bt([nj,Vs,sj],(e,r,a)=>a.length>0?e.flatMap(s=>a.flatMap(n=>{var i,o=ls(s,(i=r.dataKey)!==null&&i!==void 0?i:n.dataKey);return{value:o,errorDomain:[]}})).filter(Boolean):(r==null?void 0:r.dataKey)!=null?e.map(s=>({value:ls(s,r.dataKey),errorDomain:[]})):e.map(s=>({value:s,errorDomain:[]})));var VP=()=>{},D1e=bt([nj,Vs,sj,Qw,Ds,ppe],J3),R1e=bt([Vs,K3,Y3,VP,D1e,VP,Ua,Ds],Z3),oU=bt([Vs,Ua,nj,P1e,Yx,Ds,R1e],X3),M1e=bt([oU,tg,c0],eC),L1e=bt([Vs,oU,M1e,Ds],rC);bt([c0,L1e],nz);var F1e={radiusAxis:{},angleAxis:{}},lU=wi({name:"polarAxis",initialState:F1e,reducers:{addRadiusAxis(e,r){e.radiusAxis[r.payload.id]=r.payload},removeRadiusAxis(e,r){delete e.radiusAxis[r.payload.id]},addAngleAxis(e,r){e.angleAxis[r.payload.id]=r.payload},removeAngleAxis(e,r){delete e.angleAxis[r.payload.id]}}}),{addRadiusAxis:x3e,removeRadiusAxis:y3e,addAngleAxis:b3e,removeAngleAxis:v3e}=lU.actions,I1e=lU.reducer;function cU(e){return e&&typeof e=="object"&&"className"in e&&typeof e.className=="string"?e.className:""}function GP(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function KP(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?GP(Object(a),!0).forEach(function(s){z1e(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):GP(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function z1e(e,r,a){return(r=$1e(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function $1e(e){var r=U1e(e,"string");return typeof r=="symbol"?r:r+""}function U1e(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var B1e=(e,r)=>r,fC=bt([iU,B1e],(e,r)=>e.filter(a=>a.type==="pie").find(a=>a.id===r)),W1e=[],xC=(e,r,a)=>(a==null?void 0:a.length)===0?W1e:a,dU=bt([Kx,fC,xC],(e,r,a)=>{var{chartData:s}=e;if(r!=null){var n;if((r==null?void 0:r.data)!=null&&r.data.length>0?n=r.data:n=s,(!n||!n.length)&&a!=null&&(n=a.map(i=>KP(KP({},r.presentationProps),i.props))),n!=null)return n}}),H1e=bt([dU,fC,xC],(e,r,a)=>{if(!(e==null||r==null))return e.map((s,n)=>{var i,o=ls(s,r.nameKey,r.name),l;return a!=null&&(i=a[n])!==null&&i!==void 0&&(i=i.props)!==null&&i!==void 0&&i.fill?l=a[n].props.fill:typeof s=="object"&&s!=null&&"fill"in s?l=s.fill:l=r.fill,{value:Ew(o,r.dataKey),color:l,payload:s,type:r.legendType}})}),q1e=bt([dU,fC,xC,kn],(e,r,a,s)=>{if(!(r==null||e==null))return Zwe({offset:s,pieSettings:r,displayedData:e,cells:a})}),K2={exports:{}},rs={};var YP;function V1e(){if(YP)return rs;YP=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),n=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),y=Symbol.for("react.view_transition"),b=Symbol.for("react.client.reference");function w(v){if(typeof v=="object"&&v!==null){var k=v.$$typeof;switch(k){case e:switch(v=v.type,v){case a:case n:case s:case c:case u:case y:return v;default:switch(v=v&&v.$$typeof,v){case o:case l:case f:case h:return v;case i:return v;default:return k}}case r:return k}}}return rs.ContextConsumer=i,rs.ContextProvider=o,rs.Element=e,rs.ForwardRef=l,rs.Fragment=a,rs.Lazy=f,rs.Memo=h,rs.Portal=r,rs.Profiler=n,rs.StrictMode=s,rs.Suspense=c,rs.SuspenseList=u,rs.isContextConsumer=function(v){return w(v)===i},rs.isContextProvider=function(v){return w(v)===o},rs.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===e},rs.isForwardRef=function(v){return w(v)===l},rs.isFragment=function(v){return w(v)===a},rs.isLazy=function(v){return w(v)===f},rs.isMemo=function(v){return w(v)===h},rs.isPortal=function(v){return w(v)===r},rs.isProfiler=function(v){return w(v)===n},rs.isStrictMode=function(v){return w(v)===s},rs.isSuspense=function(v){return w(v)===c},rs.isSuspenseList=function(v){return w(v)===u},rs.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===a||v===n||v===s||v===c||v===u||typeof v=="object"&&v!==null&&(v.$$typeof===f||v.$$typeof===h||v.$$typeof===o||v.$$typeof===i||v.$$typeof===l||v.$$typeof===b||v.getModuleId!==void 0)},rs.typeOf=w,rs}var JP;function G1e(){return JP||(JP=1,K2.exports=V1e()),K2.exports}var K1e=G1e(),ZP=e=>typeof e=="string"?e:e?e.displayName||e.name||"Component":"",XP=null,Y2=null,uU=e=>{if(e===XP&&Array.isArray(Y2))return Y2;var r=[];return p.Children.forEach(e,a=>{_n(a)||(K1e.isFragment(a)?r=r.concat(uU(a.props.children)):r.push(a))}),Y2=r,XP=e,r};function yC(e,r){var a=[],s=[];return Array.isArray(r)?s=r.map(n=>ZP(n)):s=[ZP(r)],uU(e).forEach(n=>{var i=Cm(n,"type.displayName")||Cm(n,"type.name");i&&s.indexOf(i)!==-1&&a.push(n)}),a}var J2={},QP;function Y1e(){return QP||(QP=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function r(a){var n;if(typeof a!="object"||a==null)return!1;if(Object.getPrototypeOf(a)===null)return!0;if(Object.prototype.toString.call(a)!=="[object Object]"){const i=a[Symbol.toStringTag];return i==null||!((n=Object.getOwnPropertyDescriptor(a,Symbol.toStringTag))!=null&&n.writable)?!1:a.toString()===`[object ${i}]`}let s=a;for(;Object.getPrototypeOf(s)!==null;)s=Object.getPrototypeOf(s);return Object.getPrototypeOf(a)===s}e.isPlainObject=r})(J2)),J2}var Z2,eD;function J1e(){return eD||(eD=1,Z2=Y1e().isPlainObject),Z2}var Z1e=J1e();const X1e=tu(Z1e);var tD,rD,aD,sD,nD;function iD(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function oD(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?iD(Object(a),!0).forEach(function(s){Q1e(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):iD(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function Q1e(e,r,a){return(r=ewe(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function ewe(e){var r=twe(e,"string");return typeof r=="symbol"?r:r+""}function twe(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function L1(){return L1=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},L1.apply(null,arguments)}function hf(e,r){return r||(r=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(r)}}))}var lD=(e,r,a,s,n)=>{var i=a-s,o;return o=Bs(tD||(tD=hf(["M ",",",""])),e,r),o+=Bs(rD||(rD=hf(["L ",",",""])),e+a,r),o+=Bs(aD||(aD=hf(["L ",",",""])),e+a-i/2,r+n),o+=Bs(sD||(sD=hf(["L ",",",""])),e+a-i/2-s,r+n),o+=Bs(nD||(nD=hf(["L ",","," Z"])),e,r),o},rwe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},awe=e=>{var r=In(e,rwe),{x:a,y:s,upperWidth:n,lowerWidth:i,height:o,className:l}=r,{animationEasing:c,animationDuration:u,animationBegin:h,isUpdateAnimationActive:f}=r,y=p.useRef(null),[b,w]=p.useState(-1),v=p.useRef(n),k=p.useRef(i),S=p.useRef(o),N=p.useRef(a),C=p.useRef(s),O=zw(e,"trapezoid-");if(p.useEffect(()=>{if(y.current&&y.current.getTotalLength)try{var te=y.current.getTotalLength();te&&w(te)}catch(Y){}},[]),a!==+a||s!==+s||n!==+n||i!==+i||o!==+o||n===0&&i===0||o===0)return null;var T=va("recharts-trapezoid",l);if(!f)return p.createElement("g",null,p.createElement("path",L1({},bl(r),{className:T,d:lD(a,s,n,i,o)})));var P=v.current,E=k.current,R=S.current,z=N.current,G=C.current,ae="0px ".concat(b===-1?1:b,"px"),ee="".concat(b,"px ").concat(b,"px"),ne=TI(["strokeDasharray"],u,c);return p.createElement(Iw,{animationId:O,key:O,canBegin:b>0,duration:u,easing:c,isActive:f,begin:h},te=>{var Y=wn(P,n,te),q=wn(E,i,te),H=wn(R,o,te),U=wn(z,a,te),re=wn(G,s,te);y.current&&(v.current=Y,k.current=q,S.current=H,N.current=U,C.current=re);var X=te>0?{transition:ne,strokeDasharray:ee}:{strokeDasharray:ae};return p.createElement("path",L1({},bl(r),{className:T,d:lD(U,re,Y,q,H),ref:y,style:oD(oD({},X),r.style)}))})},swe=["option","shapeType","activeClassName","inActiveClassName"];function nwe(e,r){if(e==null)return{};var a,s,n=iwe(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function iwe(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}function cD(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function F1(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?cD(Object(a),!0).forEach(function(s){owe(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):cD(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function owe(e,r,a){return(r=lwe(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function lwe(e){var r=cwe(e,"string");return typeof r=="symbol"?r:r+""}function cwe(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function dwe(e,r){return F1(F1({},r),e)}function uwe(e,r){return e==="symbols"}function dD(e){var{shapeType:r,elementProps:a}=e;switch(r){case"rectangle":return p.createElement(PI,a);case"trapezoid":return p.createElement(awe,a);case"sector":return p.createElement(LI,a);case"symbols":if(uwe(r))return p.createElement(BS,a);break;case"curve":return p.createElement(s3,a);default:return null}}function mwe(e){return p.isValidElement(e)?e.props:e}function mU(e){var{option:r,shapeType:a,activeClassName:s="recharts-active-shape",inActiveClassName:n="recharts-shape"}=e,i=nwe(e,swe),o;if(p.isValidElement(r))o=p.cloneElement(r,F1(F1({},i),mwe(r)));else if(typeof r=="function")o=r(i,i.index);else if(X1e(r)&&typeof r!="boolean"){var l=dwe(r,i);o=p.createElement(dD,{shapeType:a,elementProps:l})}else{var c=i;o=p.createElement(dD,{shapeType:a,elementProps:c})}return i.isActive?p.createElement(yi,{className:s},o):p.createElement(yi,{className:n},o)}var bC=(e,r,a)=>{var s=ss();return(n,i)=>o=>{e==null||e(n,i,o),s(b$({activeIndex:String(i),activeDataKey:r,activeCoordinate:n.tooltipPosition,activeGraphicalItemId:a}))}},vC=e=>{var r=ss();return(a,s)=>n=>{e==null||e(a,s,n),r(xye())}},wC=(e,r,a)=>{var s=ss();return(n,i)=>o=>{e==null||e(n,i,o),s(yye({activeIndex:String(i),activeDataKey:r,activeCoordinate:n.tooltipPosition,activeGraphicalItemId:a}))}};function hU(e){var{tooltipEntrySettings:r}=e,a=ss(),s=ho(),n=p.useRef(null);return p.useLayoutEffect(()=>{s||(n.current===null?a(hye(r)):n.current!==r&&a(pye({prev:n.current,next:r})),n.current=r)},[r,a,s]),p.useLayoutEffect(()=>()=>{n.current&&(a(gye(n.current)),n.current=null)},[a]),null}function hwe(e){var{legendPayload:r}=e,a=ss(),s=ho(),n=p.useRef(null);return p.useLayoutEffect(()=>{s||(n.current===null?a(_I(r)):n.current!==r&&a(kI({prev:n.current,next:r})),n.current=r)},[a,s,r]),p.useLayoutEffect(()=>()=>{n.current&&(a(NI(n.current)),n.current=null)},[a]),null}function pwe(e){var{legendPayload:r}=e,a=ss(),s=kr(Ua),n=p.useRef(null);return p.useLayoutEffect(()=>{s!=="centric"&&s!=="radial"||(n.current===null?a(_I(r)):n.current!==r&&a(kI({prev:n.current,next:r})),n.current=r)},[a,s,r]),p.useLayoutEffect(()=>()=>{n.current&&(a(NI(n.current)),n.current=null)},[a]),null}var X2,gwe=()=>{var[e]=p.useState(()=>ax("uid-"));return e},fwe=(X2=TW.useId)!==null&&X2!==void 0?X2:gwe;function xwe(e,r){var a=fwe();return r||(e?"".concat(e,"-").concat(a):a)}var ywe=p.createContext(void 0),pU=e=>{var{id:r,type:a,children:s}=e,n=xwe("recharts-".concat(a),r);return p.createElement(ywe.Provider,{value:n},s(n))},bwe={cartesianItems:[],polarItems:[]},gU=wi({name:"graphicalItems",initialState:bwe,reducers:{addCartesianGraphicalItem:{reducer(e,r){e.cartesianItems.push(r.payload)},prepare:ys()},replaceCartesianGraphicalItem:{reducer(e,r){var{prev:a,next:s}=r.payload,n=pl(e).cartesianItems.indexOf(a);n>-1&&(e.cartesianItems[n]=s)},prepare:ys()},removeCartesianGraphicalItem:{reducer(e,r){var a=pl(e).cartesianItems.indexOf(r.payload);a>-1&&e.cartesianItems.splice(a,1)},prepare:ys()},addPolarGraphicalItem:{reducer(e,r){e.polarItems.push(r.payload)},prepare:ys()},removePolarGraphicalItem:{reducer(e,r){var a=pl(e).polarItems.indexOf(r.payload);a>-1&&e.polarItems.splice(a,1)},prepare:ys()},replacePolarGraphicalItem:{reducer(e,r){var{prev:a,next:s}=r.payload,n=pl(e).polarItems.indexOf(a);n>-1&&(e.polarItems[n]=s)},prepare:ys()}}}),{addCartesianGraphicalItem:vwe,replaceCartesianGraphicalItem:wwe,removeCartesianGraphicalItem:jwe,addPolarGraphicalItem:_we,removePolarGraphicalItem:kwe,replacePolarGraphicalItem:Nwe}=gU.actions,Swe=gU.reducer,Cwe=e=>{var r=ss(),a=p.useRef(null);return p.useLayoutEffect(()=>{a.current===null?r(vwe(e)):a.current!==e&&r(wwe({prev:a.current,next:e})),a.current=e},[r,e]),p.useLayoutEffect(()=>()=>{a.current&&(r(jwe(a.current)),a.current=null)},[r]),null},Twe=p.memo(Cwe),Ewe=e=>{var r=ss(),a=p.useRef(null);return p.useLayoutEffect(()=>{a.current===null?r(_we(e)):a.current!==e&&r(Nwe({prev:a.current,next:e})),a.current=e},[r,e]),p.useLayoutEffect(()=>()=>{a.current&&(r(kwe(a.current)),a.current=null)},[r]),null},Awe=p.memo(Ewe),Owe=["key"],Pwe=["onMouseEnter","onClick","onMouseLeave"],Dwe=["id"],Rwe=["id"];function t0(){return t0=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},t0.apply(null,arguments)}function ij(e,r){if(e==null)return{};var a,s,n=Mwe(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function Mwe(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}function uD(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function Ns(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?uD(Object(a),!0).forEach(function(s){Lwe(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):uD(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function Lwe(e,r,a){return(r=Fwe(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Fwe(e){var r=Iwe(e,"string");return typeof r=="symbol"?r:r+""}function Iwe(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function zwe(e){var r=p.useMemo(()=>yC(e.children,Lp),[e.children]),a=kr(s=>H1e(s,e.id,r));return a==null?null:p.createElement(pwe,{legendPayload:a})}function $we(e){if(!(e==null||typeof e=="boolean"||typeof e=="function")){if(p.isValidElement(e)){var r,a=(r=e.props)===null||r===void 0?void 0:r.fill;return typeof a=="string"?a:void 0}var{fill:s}=e;return typeof s=="string"?s:void 0}}var Uwe=p.memo(e=>{var{dataKey:r,nameKey:a,sectors:s,stroke:n,strokeWidth:i,fill:o,name:l,hide:c,tooltipType:u,id:h,activeShape:f}=e,y=$we(f),b=s.map(v=>{var k=v.tooltipPayload;return y==null||k==null?k:k.map(S=>Ns(Ns({},S),{},{color:y,fill:y}))}),w={dataDefinedOnItem:b,getPosition:v=>{var k;return(k=s[Number(v)])===null||k===void 0?void 0:k.tooltipPosition},settings:{stroke:n,strokeWidth:i,fill:o,dataKey:r,nameKey:a,name:Ew(l,r),hide:c,type:u,color:o,unit:"",graphicalItemId:h}};return p.createElement(hU,{tooltipEntrySettings:w})}),Bwe=(e,r)=>e>r?"start":e<r?"end":"middle",Wwe=(e,r,a)=>xi(typeof r=="function"?r(e):r,a,a*.8),Hwe=(e,r,a)=>{var{top:s,left:n,width:i,height:o}=r,l=DI(i,o),c=n+xi(e.cx,i,i/2),u=s+xi(e.cy,o,o/2),h=xi(e.innerRadius,l,0),f=Wwe(a,e.outerRadius,l),y=e.maxRadius||Math.sqrt(i*i+o*o)/2;return{cx:c,cy:u,innerRadius:h,outerRadius:f,maxRadius:y}},qwe=(e,r)=>{var a=Ln(r-e),s=Math.min(Math.abs(r-e),360);return a*s},Vwe=(e,r)=>{if(p.isValidElement(e))return p.cloneElement(e,r);if(typeof e=="function")return e(r);var a=va("recharts-pie-label-line",typeof e!="boolean"?e.className:""),{key:s}=r,n=ij(r,Owe);return p.createElement(s3,t0({},n,{type:"linear",className:a}))},Gwe=(e,r,a)=>{if(p.isValidElement(e))return p.cloneElement(e,r);var s=a;if(typeof e=="function"&&(s=e(r),p.isValidElement(s)))return s;var n=va("recharts-pie-label-text",cU(e));return p.createElement(aj,t0({},r,{alignmentBaseline:"middle",className:n}),s)};function Kwe(e){var{sectors:r,props:a,showLabels:s}=e,{label:n,labelLine:i,dataKey:o}=a;if(!s||!n||!r)return null;var l=ac(a),c=rx(n),u=rx(i),h=typeof n=="object"&&"offsetRadius"in n&&typeof n.offsetRadius=="number"&&n.offsetRadius||20,f=r.map((y,b)=>{var w=(y.startAngle+y.endAngle)/2,v=on(y.cx,y.cy,y.outerRadius+h,w),k=Ns(Ns(Ns(Ns({},l),y),{},{stroke:"none"},c),{},{index:b,textAnchor:Bwe(v.x,y.cx)},v),S=Ns(Ns(Ns(Ns({},l),y),{},{fill:"none",stroke:y.fill},u),{},{index:b,points:[on(y.cx,y.cy,y.outerRadius,w),v],key:"line"});return p.createElement(mc,{zIndex:ri.label,key:"label-".concat(y.startAngle,"-").concat(y.endAngle,"-").concat(y.midAngle,"-").concat(b)},p.createElement(yi,null,i&&Vwe(i,S),Gwe(n,k,ls(y,o))))});return p.createElement(yi,{className:"recharts-pie-labels"},f)}function Ywe(e){var{sectors:r,props:a,showLabels:s}=e,{label:n}=a;return typeof n=="object"&&n!=null&&"position"in n?p.createElement(nU,{label:n}):p.createElement(Kwe,{sectors:r,props:a,showLabels:s})}function Jwe(e){var{sectors:r,activeShape:a,inactiveShape:s,allOtherPieProps:n,shape:i,id:o}=e,l=kr(Rm),c=kr(dC),u=kr(M$),{onMouseEnter:h,onClick:f,onMouseLeave:y}=n,b=ij(n,Pwe),w=bC(h,n.dataKey,o),v=vC(y),k=wC(f,n.dataKey,o);return r==null||r.length===0?null:p.createElement(p.Fragment,null,r.map((S,N)=>{if((S==null?void 0:S.startAngle)===0&&(S==null?void 0:S.endAngle)===0&&r.length!==1)return null;var C=u==null||u===o,O=String(N)===l&&(c==null||n.dataKey===c)&&C,T=l?s:null,P=a&&O?a:T,E=Ns(Ns({},S),{},{stroke:S.stroke,tabIndex:-1,[lI]:N,[cI]:o});return p.createElement(yi,t0({key:"sector-".concat(S==null?void 0:S.startAngle,"-").concat(S==null?void 0:S.endAngle,"-").concat(S.midAngle,"-").concat(N),tabIndex:-1,className:"recharts-pie-sector"},$x(b,S,N),{onMouseEnter:w(S,N),onMouseLeave:v(S,N),onClick:k(S,N)}),p.createElement(mU,t0({option:i!=null?i:P,index:N,shapeType:"sector",isActive:O},E)))}))}function Zwe(e){var r,{pieSettings:a,displayedData:s,cells:n,offset:i}=e,{cornerRadius:o,startAngle:l,endAngle:c,dataKey:u,nameKey:h,tooltipType:f}=a,y=Math.abs(a.minAngle),b=qwe(l,c),w=Math.abs(b),v=s.length<=1?0:(r=a.paddingAngle)!==null&&r!==void 0?r:0,k=s.filter(R=>ls(R,u,0)!==0).length,S=(w>=360?k:k-1)*v,N=s.reduce((R,z)=>{var G=ls(z,u,0);return R+(_r(G)?G:0)},0),C=y>0&&N>0&&s.some(R=>{var z=ls(R,u,0),G=(_r(z)?z:0)/N;return z!==0&&G*w<y}),O=C?y:0,T=w-k*O-S,P;if(N>0){var E;P=s.map((R,z)=>{var G=ls(R,u,0),ae=ls(R,h,z),ee=Hwe(a,i,R),ne=(_r(G)?G:0)/N,te,Y=Ns(Ns({},R),n&&n[z]&&n[z].props),q=Y!=null&&"fill"in Y&&typeof Y.fill=="string"?Y.fill:a.fill;z?te=E.endAngle+Ln(b)*v*(G!==0?1:0):te=l;var H=te+Ln(b)*((G!==0?O:0)+ne*T),U=(te+H)/2,re=(ee.innerRadius+ee.outerRadius)/2,X=[{name:ae,value:G,payload:Y,dataKey:u,type:f,color:q,fill:q,graphicalItemId:a.id}],V=on(ee.cx,ee.cy,re,U);return E=Ns(Ns(Ns(Ns({},a.presentationProps),{},{percent:ne,cornerRadius:typeof o=="string"?parseFloat(o):o,name:ae,tooltipPayload:X,midAngle:U,middleRadius:re,tooltipPosition:V},Y),ee),{},{value:G,dataKey:u,startAngle:te,endAngle:H,payload:Y,paddingAngle:G!==0?Ln(b)*v:0}),E})}return P}function Xwe(e){var{showLabels:r,sectors:a,children:s}=e,n=p.useMemo(()=>!r||!a?[]:a.map(i=>({value:i.value,payload:i.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:i.cx,cy:i.cy,innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,clockWise:!1},fill:i.fill})),[a,r]);return p.createElement(C1e,{value:r?n:void 0},s)}function Qwe(e){var{props:r,previousSectorsRef:a,id:s}=e,{sectors:n,isAnimationActive:i,animationBegin:o,animationDuration:l,animationEasing:c,activeShape:u,inactiveShape:h,onAnimationStart:f,onAnimationEnd:y}=r,b=zw(r,"recharts-pie-"),w=a.current,[v,k]=p.useState(!1),S=p.useCallback(()=>{typeof y=="function"&&y(),k(!1)},[y]),N=p.useCallback(()=>{typeof f=="function"&&f(),k(!0)},[f]);return p.createElement(Xwe,{showLabels:!v,sectors:n},p.createElement(Iw,{animationId:b,begin:o,duration:l,isActive:i,easing:c,onAnimationStart:N,onAnimationEnd:S,key:b},C=>{var O,T=[],P=n&&n[0],E=(O=P==null?void 0:P.startAngle)!==null&&O!==void 0?O:0;return n==null||n.forEach((R,z)=>{var G=w&&w[z],ae=z>0?Cm(R,"paddingAngle",0):0;if(G){var ee=wn(G.endAngle-G.startAngle,R.endAngle-R.startAngle,C),ne=Ns(Ns({},R),{},{startAngle:E+ae,endAngle:E+ee+ae});T.push(ne),E=ne.endAngle}else{var{endAngle:te,startAngle:Y}=R,q=wn(0,te-Y,C),H=Ns(Ns({},R),{},{startAngle:E+ae,endAngle:E+q+ae});T.push(H),E=H.endAngle}}),a.current=T,p.createElement(yi,null,p.createElement(Jwe,{sectors:T,activeShape:u,inactiveShape:h,allOtherPieProps:r,shape:r.shape,id:s}))}),p.createElement(Ywe,{showLabels:!v,sectors:n,props:r}),r.children)}var eje={animationBegin:400,animationDuration:1500,animationEasing:"ease",cx:"50%",cy:"50%",dataKey:"value",endAngle:360,fill:"#808080",hide:!1,innerRadius:0,isAnimationActive:"auto",label:!1,labelLine:!0,legendType:"rect",minAngle:0,nameKey:"name",outerRadius:"80%",paddingAngle:0,rootTabIndex:0,startAngle:0,stroke:"#fff",zIndex:ri.area};function tje(e){var{id:r}=e,a=ij(e,Dwe),{hide:s,className:n,rootTabIndex:i}=e,o=p.useMemo(()=>yC(e.children,Lp),[e.children]),l=kr(h=>q1e(h,r,o)),c=p.useRef(null),u=va("recharts-pie",n);return s||l==null?(c.current=null,p.createElement(yi,{tabIndex:i,className:u})):p.createElement(mc,{zIndex:e.zIndex},p.createElement(Uwe,{dataKey:e.dataKey,nameKey:e.nameKey,sectors:l,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:r,activeShape:e.activeShape}),p.createElement(yi,{tabIndex:i,className:u},p.createElement(Qwe,{props:Ns(Ns({},a),{},{sectors:l}),previousSectorsRef:c,id:r})))}function rje(e){var r=In(e,eje),{id:a}=r,s=ij(r,Rwe),n=ac(s);return p.createElement(pU,{id:a,type:"pie"},i=>p.createElement(p.Fragment,null,p.createElement(Awe,{type:"pie",id:i,data:s.data,dataKey:s.dataKey,hide:s.hide,angleAxisId:0,radiusAxisId:0,name:s.name,nameKey:s.nameKey,tooltipType:s.tooltipType,legendType:s.legendType,fill:s.fill,cx:s.cx,cy:s.cy,startAngle:s.startAngle,endAngle:s.endAngle,paddingAngle:s.paddingAngle,minAngle:s.minAngle,innerRadius:s.innerRadius,outerRadius:s.outerRadius,cornerRadius:s.cornerRadius,presentationProps:n,maxRadius:r.maxRadius}),p.createElement(zwe,t0({},s,{id:i})),p.createElement(tje,t0({},s,{id:i}))))}var fU=rje;fU.displayName="Pie";function mD(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function hD(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?mD(Object(a),!0).forEach(function(s){aje(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):mD(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function aje(e,r,a){return(r=sje(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function sje(e){var r=nje(e,"string");return typeof r=="symbol"?r:r+""}function nje(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var xU=0,ije={xAxis:{},yAxis:{},zAxis:{}},yU=wi({name:"cartesianAxis",initialState:ije,reducers:{addXAxis:{reducer(e,r){e.xAxis[r.payload.id]=r.payload},prepare:ys()},replaceXAxis:{reducer(e,r){var{prev:a,next:s}=r.payload;e.xAxis[a.id]!==void 0&&(a.id!==s.id&&delete e.xAxis[a.id],e.xAxis[s.id]=s)},prepare:ys()},removeXAxis:{reducer(e,r){delete e.xAxis[r.payload.id]},prepare:ys()},addYAxis:{reducer(e,r){e.yAxis[r.payload.id]=r.payload},prepare:ys()},replaceYAxis:{reducer(e,r){var{prev:a,next:s}=r.payload;e.yAxis[a.id]!==void 0&&(a.id!==s.id&&delete e.yAxis[a.id],e.yAxis[s.id]=s)},prepare:ys()},removeYAxis:{reducer(e,r){delete e.yAxis[r.payload.id]},prepare:ys()},addZAxis:{reducer(e,r){e.zAxis[r.payload.id]=r.payload},prepare:ys()},replaceZAxis:{reducer(e,r){var{prev:a,next:s}=r.payload;e.zAxis[a.id]!==void 0&&(a.id!==s.id&&delete e.zAxis[a.id],e.zAxis[s.id]=s)},prepare:ys()},removeZAxis:{reducer(e,r){delete e.zAxis[r.payload.id]},prepare:ys()},updateYAxisWidth(e,r){var{id:a,width:s}=r.payload,n=e.yAxis[a];if(n){var i,o=n.widthHistory||[];if(o.length===3&&o[0]===o[2]&&s===o[1]&&s!==n.width&&Math.abs(s-((i=o[0])!==null&&i!==void 0?i:0))<=1)return;var l=[...o,s].slice(-3);e.yAxis[a]=hD(hD({},n),{},{width:s,widthHistory:l})}}}}),{addXAxis:oje,replaceXAxis:lje,removeXAxis:cje,addYAxis:dje,replaceYAxis:uje,removeYAxis:mje,addZAxis:w3e,replaceZAxis:j3e,removeZAxis:_3e,updateYAxisWidth:hje}=yU.actions,pje=yU.reducer,gje=bt([kn],e=>({top:e.top,bottom:e.bottom,left:e.left,right:e.right})),fje=bt([gje,su,nu],(e,r,a)=>{if(!(!e||r==null||a==null))return{x:e.left,y:e.top,width:Math.max(0,r-e.left-e.right),height:Math.max(0,a-e.top-e.bottom)}}),bU=()=>kr(fje),pD=(e,r,a)=>{var s=a!=null?a:e;if(!_n(s))return xi(s,r,0)},xje=(e,r,a)=>{var s={},n=e.filter(Hw),i=e.filter(u=>u.stackId==null),o=n.reduce((u,h)=>{var f=u[h.stackId];return f==null&&(f=[]),f.push(h),u[h.stackId]=f,u},s),l=Object.entries(o).map(u=>{var h,[f,y]=u,b=y.map(v=>v.dataKey),w=pD(r,a,(h=y[0])===null||h===void 0?void 0:h.barSize);return{stackId:f,dataKeys:b,barSize:w}}),c=i.map(u=>{var h=[u.dataKey].filter(y=>y!=null),f=pD(r,a,u.barSize);return{stackId:void 0,dataKeys:h,barSize:f}});return[...l,...c]};function gD(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function Ub(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?gD(Object(a),!0).forEach(function(s){yje(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):gD(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function yje(e,r,a){return(r=bje(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function bje(e){var r=vje(e,"string");return typeof r=="symbol"?r:r+""}function vje(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function wje(e,r,a,s,n){var i,o=s.length;if(!(o<1)){var l=xi(e,a,0,!0),c,u=[];if(ja((i=s[0])===null||i===void 0?void 0:i.barSize)){var h=!1,f=a/o,y=s.reduce((N,C)=>N+(C.barSize||0),0);y+=(o-1)*l,y>=a&&(y-=(o-1)*l,l=0),y>=a&&f>0&&(h=!0,f*=.9,y=o*f);var b=(a-y)/2>>0,w={offset:b-l,size:0};c=s.reduce((N,C)=>{var O,T={stackId:C.stackId,dataKeys:C.dataKeys,position:{offset:w.offset+w.size+l,size:h?f:(O=C.barSize)!==null&&O!==void 0?O:0}},P=[...N,T];return w=T.position,P},u)}else{var v=xi(r,a,0,!0);a-2*v-(o-1)*l<=0&&(l=0);var k=(a-2*v-(o-1)*l)/o;k>1&&(k>>=0);var S=ja(n)?Math.min(k,n):k;c=s.reduce((N,C,O)=>[...N,{stackId:C.stackId,dataKeys:C.dataKeys,position:{offset:v+(k+l)*O+(k-S)/2,size:S}}],u)}return c}}var jje=(e,r,a,s,n,i,o)=>{var l=_n(o)?r:o,c=wje(a,s,n!==i?n:i,e,l);return n!==i&&c!=null&&(c=c.map(u=>Ub(Ub({},u),{},{position:Ub(Ub({},u.position),{},{offset:u.position.offset-n/2})}))),c},_je=(e,r)=>{var a=p3(r);if(!(!e||a==null||r==null)){var{stackId:s}=r;if(s!=null){var n=e[s];if(n){var{stackedData:i}=n;if(i)return i.find(o=>o.key===a)}}}},kje=(e,r)=>{if(!(e==null||r==null)){var a=e.find(s=>s.stackId===r.stackId&&r.dataKey!=null&&s.dataKeys.includes(r.dataKey));if(a!=null)return a.position}};function Nje(e,r){return e&&typeof e=="object"&&"zIndex"in e&&typeof e.zIndex=="number"&&ja(e.zIndex)?e.zIndex:r}var vU=e=>{var{chartData:r}=e,a=ss(),s=ho();return p.useEffect(()=>s?()=>{}:(a(CP(r)),()=>{a(CP(void 0))}),[r,a,s]),null},fD={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},wU=wi({name:"brush",initialState:fD,reducers:{setBrushSettings(e,r){return r.payload==null?fD:r.payload}}}),{setBrushSettings:k3e}=wU.actions,Sje=wU.reducer;function Cje(e){return(e%180+180)%180}var Tje=function(r){var{width:a,height:s}=r,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=Cje(n),o=i*Math.PI/180,l=Math.atan(s/a),c=o>l&&o<Math.PI-l?s/Math.sin(o):a/Math.cos(o);return Math.abs(c)},Eje={dots:[],areas:[],lines:[]},jU=wi({name:"referenceElements",initialState:Eje,reducers:{addDot:(e,r)=>{e.dots.push(r.payload)},removeDot:(e,r)=>{var a=pl(e).dots.findIndex(s=>s===r.payload);a!==-1&&e.dots.splice(a,1)},addArea:(e,r)=>{e.areas.push(r.payload)},removeArea:(e,r)=>{var a=pl(e).areas.findIndex(s=>s===r.payload);a!==-1&&e.areas.splice(a,1)},addLine:(e,r)=>{e.lines.push(r.payload)},removeLine:(e,r)=>{var a=pl(e).lines.findIndex(s=>s===r.payload);a!==-1&&e.lines.splice(a,1)}}}),{addDot:N3e,removeDot:S3e,addArea:C3e,removeArea:T3e,addLine:E3e,removeLine:A3e}=jU.actions,Aje=jU.reducer,Oje=p.createContext(void 0),Pje=e=>{var{children:r}=e,[a]=p.useState("".concat(ax("recharts"),"-clip")),s=bU();if(s==null)return null;var{x:n,y:i,width:o,height:l}=s;return p.createElement(Oje.Provider,{value:a},p.createElement("defs",null,p.createElement("clipPath",{id:a},p.createElement("rect",{x:n,y:i,height:l,width:o}))),r)};function _U(e,r){if(r<1)return[];if(r===1)return e;for(var a=[],s=0;s<e.length;s+=r){var n=e[s];n!==void 0&&a.push(n)}return a}function Dje(e,r,a){var s={width:e.width+r.width,height:e.height+r.height};return Tje(s,a)}function Rje(e,r,a){var s=a==="width",{x:n,y:i,width:o,height:l}=e;return r===1?{start:s?n:i,end:s?n+o:i+l}:{start:s?n+o:i+l,end:s?n:i}}function xx(e,r,a,s,n){if(e*r<e*s||e*r>e*n)return!1;var i=a();return e*(r-e*i/2-s)>=0&&e*(r+e*i/2-n)<=0}function Mje(e,r){return _U(e,r+1)}function Lje(e,r,a,s,n){for(var i=(s||[]).slice(),{start:o,end:l}=r,c=0,u=1,h=o,f=function(){var w=s==null?void 0:s[c];if(w===void 0)return{v:_U(s,u)};var v=c,k,S=()=>(k===void 0&&(k=a(w,v)),k),N=w.coordinate,C=c===0||xx(e,N,S,h,l);C||(c=0,h=o,u+=1),C&&(h=N+e*(S()/2+n),c+=u)},y;u<=i.length;)if(y=f(),y)return y.v;return[]}function Fje(e,r,a,s,n){var i=(s||[]).slice(),o=i.length;if(o===0)return[];for(var{start:l,end:c}=r,u=1;u<=o;u++){for(var h=(o-1)%u,f=l,y=!0,b=function(){var O=s[v];if(O==null)return 0;var T=v,P,E=()=>(P===void 0&&(P=a(O,T)),P),R=O.coordinate,z=v===h||xx(e,R,E,f,c);if(!z)return y=!1,1;z&&(f=R+e*(E()/2+n))},w,v=h;v<o&&(w=b(),!(w!==0&&w===1));v+=u);if(y){for(var k=[],S=h;S<o;S+=u){var N=s[S];N!=null&&k.push(N)}return k}}return[]}function xD(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function ui(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?xD(Object(a),!0).forEach(function(s){Ije(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):xD(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function Ije(e,r,a){return(r=zje(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function zje(e){var r=$je(e,"string");return typeof r=="symbol"?r:r+""}function $je(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Uje(e,r,a,s,n){for(var i=(s||[]).slice(),o=i.length,{start:l}=r,{end:c}=r,u=function(y){var b=i[y];if(b==null)return 1;var w=b,v,k=()=>(v===void 0&&(v=a(b,y)),v);if(y===o-1){var S=e*(w.coordinate+e*k()/2-c);i[y]=w=ui(ui({},w),{},{tickCoord:S>0?w.coordinate-S*e:w.coordinate})}else i[y]=w=ui(ui({},w),{},{tickCoord:w.coordinate});if(w.tickCoord!=null){var N=xx(e,w.tickCoord,k,l,c);N&&(c=w.tickCoord-e*(k()/2+n),i[y]=ui(ui({},w),{},{isShow:!0}))}},h=o-1;h>=0;h--)u(h);return i}function Bje(e,r,a,s,n,i){var o=(s||[]).slice(),l=o.length,{start:c,end:u}=r;if(i){var h=s[l-1];if(h!=null){var f=a(h,l-1),y=e*(h.coordinate+e*f/2-u);if(o[l-1]=h=ui(ui({},h),{},{tickCoord:y>0?h.coordinate-y*e:h.coordinate}),h.tickCoord!=null){var b=xx(e,h.tickCoord,()=>f,c,u);b&&(u=h.tickCoord-e*(f/2+n),o[l-1]=ui(ui({},h),{},{isShow:!0}))}}}for(var w=i?l-1:l,v=function(N){var C=o[N];if(C==null)return 1;var O=C,T,P=()=>(T===void 0&&(T=a(C,N)),T);if(N===0){var E=e*(O.coordinate-e*P()/2-c);o[N]=O=ui(ui({},O),{},{tickCoord:E<0?O.coordinate-E*e:O.coordinate})}else o[N]=O=ui(ui({},O),{},{tickCoord:O.coordinate});if(O.tickCoord!=null){var R=xx(e,O.tickCoord,P,c,u);R&&(c=O.tickCoord+e*(P()/2+n),o[N]=ui(ui({},O),{},{isShow:!0}))}},k=0;k<w;k++)v(k);return o}function jC(e,r,a){var{tick:s,ticks:n,viewBox:i,minTickGap:o,orientation:l,interval:c,tickFormatter:u,unit:h,angle:f}=e;if(!n||!n.length||!s)return[];if(_r(c)||Gx.isSsr){var y;return(y=Mje(n,_r(c)?c:0))!==null&&y!==void 0?y:[]}var b=[],w=l==="top"||l==="bottom"?"width":"height",v=h&&w==="width"?Hf(h,{fontSize:r,letterSpacing:a}):{width:0,height:0},k=(T,P)=>{var E=typeof u=="function"?u(T.value,P):T.value;return w==="width"?Dje(Hf(E,{fontSize:r,letterSpacing:a}),v,f):Hf(E,{fontSize:r,letterSpacing:a})[w]},S=n[0],N=n[1],C=n.length>=2&&S!=null&&N!=null?Ln(N.coordinate-S.coordinate):1,O=Rje(i,C,w);return c==="equidistantPreserveStart"?Lje(C,O,k,n,o):c==="equidistantPreserveEnd"?Fje(C,O,k,n,o):(c==="preserveStart"||c==="preserveStartEnd"?b=Bje(C,O,k,n,o,c==="preserveStartEnd"):b=Uje(C,O,k,n,o),b.filter(T=>T.isShow))}var Wje=e=>{var{ticks:r,label:a,labelGapWithTick:s=5,tickSize:n=0,tickMargin:i=0}=e,o=0;if(r){Array.from(r).forEach(h=>{if(h){var f=h.getBoundingClientRect();f.width>o&&(o=f.width)}});var l=a?a.getBoundingClientRect().width:0,c=n+i,u=o+c+l+(a?s:0);return Math.round(u)}return 0},Hje={xAxis:{},yAxis:{}},kU=wi({name:"renderedTicks",initialState:Hje,reducers:{setRenderedTicks:(e,r)=>{var{axisType:a,axisId:s,ticks:n}=r.payload;e[a][s]=n},removeRenderedTicks:(e,r)=>{var{axisType:a,axisId:s}=r.payload;delete e[a][s]}}}),{setRenderedTicks:qje,removeRenderedTicks:Vje}=kU.actions,Gje=kU.reducer,Kje=["axisLine","width","height","className","hide","ticks","axisType","axisId"];function Yje(e,r){if(e==null)return{};var a,s,n=Jje(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function Jje(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}function Mm(){return Mm=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},Mm.apply(null,arguments)}function yD(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function Us(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?yD(Object(a),!0).forEach(function(s){Zje(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):yD(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function Zje(e,r,a){return(r=Xje(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Xje(e){var r=Qje(e,"string");return typeof r=="symbol"?r:r+""}function Qje(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var qd={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd",zIndex:ri.axis};function e_e(e){var{x:r,y:a,width:s,height:n,orientation:i,mirror:o,axisLine:l,otherSvgProps:c}=e;if(!l)return null;var u=Us(Us(Us({},c),ac(l)),{},{fill:"none"});if(i==="top"||i==="bottom"){var h=+(i==="top"&&!o||i==="bottom"&&o);u=Us(Us({},u),{},{x1:r,y1:a+h*n,x2:r+s,y2:a+h*n})}else{var f=+(i==="left"&&!o||i==="right"&&o);u=Us(Us({},u),{},{x1:r+f*s,y1:a,x2:r+f*s,y2:a+n})}return p.createElement("line",Mm({},u,{className:va("recharts-cartesian-axis-line",Cm(l,"className"))}))}function t_e(e,r,a,s,n,i,o,l,c){var u,h,f,y,b,w,v=l?-1:1,k=e.tickSize||o,S=_r(e.tickCoord)?e.tickCoord:e.coordinate;switch(i){case"top":u=h=e.coordinate,y=a+ +!l*n,f=y-v*k,w=f-v*c,b=S;break;case"left":f=y=e.coordinate,h=r+ +!l*s,u=h-v*k,b=u-v*c,w=S;break;case"right":f=y=e.coordinate,h=r+ +l*s,u=h+v*k,b=u+v*c,w=S;break;default:u=h=e.coordinate,y=a+ +l*n,f=y+v*k,w=f+v*c,b=S;break}return{line:{x1:u,y1:f,x2:h,y2:y},tick:{x:b,y:w}}}function r_e(e,r){switch(e){case"left":return r?"start":"end";case"right":return r?"end":"start";default:return"middle"}}function a_e(e,r){switch(e){case"left":case"right":return"middle";case"top":return r?"start":"end";default:return r?"end":"start"}}function s_e(e){var{option:r,tickProps:a,value:s}=e,n,i=va(a.className,"recharts-cartesian-axis-tick-value");if(p.isValidElement(r))n=p.cloneElement(r,Us(Us({},a),{},{className:i}));else if(typeof r=="function")n=r(Us(Us({},a),{},{className:i}));else{var o="recharts-cartesian-axis-tick-value";typeof r!="boolean"&&(o=va(o,cU(r))),n=p.createElement(aj,Mm({},a,{className:o}),s)}return n}function n_e(e){var{ticks:r,axisType:a,axisId:s}=e,n=ss();return p.useEffect(()=>{if(s==null||a==null)return Yp;var i=r.map(o=>({value:o.value,coordinate:o.coordinate,offset:o.offset,index:o.index}));return n(qje({ticks:i,axisId:s,axisType:a})),()=>{n(Vje({axisId:s,axisType:a}))}},[n,r,s,a]),null}var i_e=p.forwardRef((e,r)=>{var{ticks:a=[],tick:s,tickLine:n,stroke:i,tickFormatter:o,unit:l,padding:c,tickTextProps:u,orientation:h,mirror:f,x:y,y:b,width:w,height:v,tickSize:k,tickMargin:S,fontSize:N,letterSpacing:C,getTicksConfig:O,events:T,axisType:P,axisId:E}=e,R=jC(Us(Us({},O),{},{ticks:a}),N,C),z=ac(O),G=rx(s),ae=Z$(z.textAnchor)?z.textAnchor:r_e(h,f),ee=a_e(h,f),ne={};typeof n=="object"&&(ne=n);var te=Us(Us({},z),{},{fill:"none"},ne),Y=R.map(U=>Us({entry:U},t_e(U,y,b,w,v,h,k,f,S))),q=Y.map(U=>{var{entry:re,line:X}=U;return p.createElement(yi,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(re.value,"-").concat(re.coordinate,"-").concat(re.tickCoord)},n&&p.createElement("line",Mm({},te,X,{className:va("recharts-cartesian-axis-tick-line",Cm(n,"className"))})))}),H=Y.map((U,re)=>{var X,V,{entry:I,tick:B}=U,Q=Us(Us(Us(Us({verticalAnchor:ee},z),{},{textAnchor:ae,stroke:"none",fill:i},B),{},{index:re,payload:I,visibleTicksCount:R.length,tickFormatter:o,padding:c},u),{},{angle:(X=(V=u==null?void 0:u.angle)!==null&&V!==void 0?V:z.angle)!==null&&X!==void 0?X:0}),ie=Us(Us({},Q),G);return p.createElement(yi,Mm({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(I.value,"-").concat(I.coordinate,"-").concat(I.tickCoord)},$x(T,I,re)),s&&p.createElement(s_e,{option:s,tickProps:ie,value:"".concat(typeof o=="function"?o(I.value,re):I.value).concat(l||"")}))});return p.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(P,"-ticks")},p.createElement(n_e,{ticks:R,axisId:E,axisType:P}),H.length>0&&p.createElement(mc,{zIndex:ri.label},p.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(P,"-tick-labels"),ref:r},H)),q.length>0&&p.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(P,"-tick-lines")},q))}),o_e=p.forwardRef((e,r)=>{var{axisLine:a,width:s,height:n,className:i,hide:o,ticks:l,axisType:c,axisId:u}=e,h=Yje(e,Kje),[f,y]=p.useState(""),[b,w]=p.useState(""),v=p.useRef(null);p.useImperativeHandle(r,()=>({getCalculatedWidth:()=>{var S;return Wje({ticks:v.current,label:(S=e.labelRef)===null||S===void 0?void 0:S.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}}));var k=p.useCallback(S=>{if(S){var N=S.getElementsByClassName("recharts-cartesian-axis-tick-value");v.current=N;var C=N[0];if(C){var O=window.getComputedStyle(C),T=O.fontSize,P=O.letterSpacing;(T!==f||P!==b)&&(y(T),w(P))}}},[f,b]);return o||s!=null&&s<=0||n!=null&&n<=0?null:p.createElement(mc,{zIndex:e.zIndex},p.createElement(yi,{className:va("recharts-cartesian-axis",i)},p.createElement(e_e,{x:e.x,y:e.y,width:s,height:n,orientation:e.orientation,mirror:e.mirror,axisLine:a,otherSvgProps:ac(e)}),p.createElement(i_e,{ref:k,axisType:c,events:h,fontSize:f,getTicksConfig:e,height:e.height,letterSpacing:b,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:l,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:u}),p.createElement(u1e,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},p.createElement(w1e,{label:e.label,labelRef:e.labelRef}),e.children)))}),_C=p.forwardRef((e,r)=>{var a=In(e,qd);return p.createElement(o_e,Mm({},a,{ref:r}))});_C.displayName="CartesianAxis";var l_e=["x1","y1","x2","y2","key"],c_e=["offset"],d_e=["xAxisId","yAxisId"],u_e=["xAxisId","yAxisId"];function bD(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function mi(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?bD(Object(a),!0).forEach(function(s){m_e(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):bD(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function m_e(e,r,a){return(r=h_e(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function h_e(e){var r=p_e(e,"string");return typeof r=="symbol"?r:r+""}function p_e(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function cm(){return cm=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},cm.apply(null,arguments)}function I1(e,r){if(e==null)return{};var a,s,n=g_e(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function g_e(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}var f_e=e=>{var{fill:r}=e;if(!r||r==="none")return null;var{fillOpacity:a,x:s,y:n,width:i,height:o,ry:l}=e;return p.createElement("rect",{x:s,y:n,ry:l,width:i,height:o,stroke:"none",fill:r,fillOpacity:a,className:"recharts-cartesian-grid-bg"})};function NU(e){var{option:r,lineItemProps:a}=e,s;if(p.isValidElement(r))s=p.cloneElement(r,a);else if(typeof r=="function")s=r(a);else{var n,{x1:i,y1:o,x2:l,y2:c,key:u}=a,h=I1(a,l_e),f=(n=ac(h))!==null&&n!==void 0?n:{},{offset:y}=f,b=I1(f,c_e);s=p.createElement("line",cm({},b,{x1:i,y1:o,x2:l,y2:c,fill:"none",key:u}))}return s}function x_e(e){var{x:r,width:a,horizontal:s=!0,horizontalPoints:n}=e;if(!s||!n||!n.length)return null;var{xAxisId:i,yAxisId:o}=e,l=I1(e,d_e),c=n.map((u,h)=>{var f=mi(mi({},l),{},{x1:r,y1:u,x2:r+a,y2:u,key:"line-".concat(h),index:h});return p.createElement(NU,{key:"line-".concat(h),option:s,lineItemProps:f})});return p.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function y_e(e){var{y:r,height:a,vertical:s=!0,verticalPoints:n}=e;if(!s||!n||!n.length)return null;var{xAxisId:i,yAxisId:o}=e,l=I1(e,u_e),c=n.map((u,h)=>{var f=mi(mi({},l),{},{x1:u,y1:r,x2:u,y2:r+a,key:"line-".concat(h),index:h});return p.createElement(NU,{option:s,lineItemProps:f,key:"line-".concat(h)})});return p.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function b_e(e){var{horizontalFill:r,fillOpacity:a,x:s,y:n,width:i,height:o,horizontalPoints:l,horizontal:c=!0}=e;if(!c||!r||!r.length||l==null)return null;var u=l.map(f=>Math.round(f+n-n)).sort((f,y)=>f-y);n!==u[0]&&u.unshift(0);var h=u.map((f,y)=>{var b=u[y+1],w=b==null,v=w?n+o-f:b-f;if(v<=0)return null;var k=y%r.length;return p.createElement("rect",{key:"react-".concat(y),y:f,x:s,height:v,width:i,stroke:"none",fill:r[k],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return p.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},h)}function v_e(e){var{vertical:r=!0,verticalFill:a,fillOpacity:s,x:n,y:i,width:o,height:l,verticalPoints:c}=e;if(!r||!a||!a.length)return null;var u=c.map(f=>Math.round(f+n-n)).sort((f,y)=>f-y);n!==u[0]&&u.unshift(0);var h=u.map((f,y)=>{var b=u[y+1],w=b==null,v=w?n+o-f:b-f;if(v<=0)return null;var k=y%a.length;return p.createElement("rect",{key:"react-".concat(y),x:f,y:i,width:v,height:l,stroke:"none",fill:a[k],fillOpacity:s,className:"recharts-cartesian-grid-bg"})});return p.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},h)}var w_e=(e,r)=>{var{xAxis:a,width:s,height:n,offset:i}=e;return nI(jC(mi(mi(mi({},qd),a),{},{ticks:iI(a),viewBox:{x:0,y:0,width:s,height:n}})),i.left,i.left+i.width,r)},j_e=(e,r)=>{var{yAxis:a,width:s,height:n,offset:i}=e;return nI(jC(mi(mi(mi({},qd),a),{},{ticks:iI(a),viewBox:{x:0,y:0,width:s,height:n}})),i.top,i.top+i.height,r)},__e={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:ri.grid};function gv(e){var r=e3(),a=t3(),s=hI(),n=mi(mi({},In(e,__e)),{},{x:_r(e.x)?e.x:s.left,y:_r(e.y)?e.y:s.top,width:_r(e.width)?e.width:s.width,height:_r(e.height)?e.height:s.height}),{xAxisId:i,yAxisId:o,x:l,y:c,width:u,height:h,syncWithTicks:f,horizontalValues:y,verticalValues:b}=n,w=ho(),v=kr(z=>pP(z,"xAxis",i,w)),k=kr(z=>pP(z,"yAxis",o,w));if(!Bc(u)||!Bc(h)||!_r(l)||!_r(c))return null;var S=n.verticalCoordinatesGenerator||w_e,N=n.horizontalCoordinatesGenerator||j_e,{horizontalPoints:C,verticalPoints:O}=n;if((!C||!C.length)&&typeof N=="function"){var T=y&&y.length,P=N({yAxis:k?mi(mi({},k),{},{ticks:T?y:k.ticks}):void 0,width:r!=null?r:u,height:a!=null?a:h,offset:s},T?!0:f);d1(Array.isArray(P),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof P,"]")),Array.isArray(P)&&(C=P)}if((!O||!O.length)&&typeof S=="function"){var E=b&&b.length,R=S({xAxis:v?mi(mi({},v),{},{ticks:E?b:v.ticks}):void 0,width:r!=null?r:u,height:a!=null?a:h,offset:s},E?!0:f);d1(Array.isArray(R),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof R,"]")),Array.isArray(R)&&(O=R)}return p.createElement(mc,{zIndex:n.zIndex},p.createElement("g",{className:"recharts-cartesian-grid"},p.createElement(f_e,{fill:n.fill,fillOpacity:n.fillOpacity,x:n.x,y:n.y,width:n.width,height:n.height,ry:n.ry}),p.createElement(b_e,cm({},n,{horizontalPoints:C})),p.createElement(v_e,cm({},n,{verticalPoints:O})),p.createElement(x_e,cm({},n,{offset:s,horizontalPoints:C,xAxis:v,yAxis:k})),p.createElement(y_e,cm({},n,{offset:s,verticalPoints:O,xAxis:v,yAxis:k}))))}gv.displayName="CartesianGrid";var k_e={},SU=wi({name:"errorBars",initialState:k_e,reducers:{addErrorBar:(e,r)=>{var{itemId:a,errorBar:s}=r.payload;e[a]||(e[a]=[]),e[a].push(s)},replaceErrorBar:(e,r)=>{var{itemId:a,prev:s,next:n}=r.payload;e[a]&&(e[a]=e[a].map(i=>i.dataKey===s.dataKey&&i.direction===s.direction?n:i))},removeErrorBar:(e,r)=>{var{itemId:a,errorBar:s}=r.payload;e[a]&&(e[a]=e[a].filter(n=>n.dataKey!==s.dataKey||n.direction!==s.direction))}}}),{addErrorBar:O3e,replaceErrorBar:P3e,removeErrorBar:D3e}=SU.actions,N_e=SU.reducer,S_e=["children"];function C_e(e,r){if(e==null)return{};var a,s,n=T_e(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function T_e(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}var E_e={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},A_e=p.createContext(E_e);function O_e(e){var{children:r}=e,a=C_e(e,S_e);return p.createElement(A_e.Provider,{value:a},r)}function CU(e,r){var a,s,n=kr(u=>ou(u,e)),i=kr(u=>lu(u,r)),o=(a=n==null?void 0:n.allowDataOverflow)!==null&&a!==void 0?a:yn.allowDataOverflow,l=(s=i==null?void 0:i.allowDataOverflow)!==null&&s!==void 0?s:bn.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function P_e(e){var{xAxisId:r,yAxisId:a,clipPathId:s}=e,n=bU(),{needClipX:i,needClipY:o,needClip:l}=CU(r,a);if(!l||!n)return null;var{x:c,y:u,width:h,height:f}=n;return p.createElement("clipPath",{id:"clipPath-".concat(s)},p.createElement("rect",{x:i?c:c-h/2,y:o?u:u-f/2,width:i?h:h*2,height:o?f:f*2}))}function Vm(e,r){var a,s;return(a=(s=e.graphicalItems.cartesianItems.find(n=>n.id===r))===null||s===void 0?void 0:s.xAxisId)!==null&&a!==void 0?a:xU}function Gm(e,r){var a,s;return(a=(s=e.graphicalItems.cartesianItems.find(n=>n.id===r))===null||s===void 0?void 0:s.yAxisId)!==null&&a!==void 0?a:xU}var D_e="Invariant failed";function R_e(e,r){throw new Error(D_e)}function N4(){return N4=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},N4.apply(null,arguments)}function kC(e){return p.createElement(mU,N4({shapeType:"rectangle",activeClassName:"recharts-active-bar",inActiveClassName:"recharts-inactive-bar"},e))}var M_e=function(r){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(s,n)=>{if(_r(r))return r;var i=_r(s)||_n(s);return i?r(s,n):(i||R_e(),a)}},L_e=(e,r,a)=>a,F_e=(e,r)=>r,ny=bt([B3,F_e],(e,r)=>e.filter(a=>a.type==="bar").find(a=>a.id===r)),I_e=bt([ny],e=>e==null?void 0:e.maxBarSize),z_e=(e,r,a,s)=>s,$_e=bt([Ua,B3,Vm,Gm,L_e],(e,r,a,s,n)=>r.filter(i=>e==="horizontal"?i.xAxisId===a:i.yAxisId===s).filter(i=>i.isPanorama===n).filter(i=>i.hide===!1).filter(i=>i.type==="bar")),U_e=(e,r,a)=>{var s=Ua(e),n=Vm(e,r),i=Gm(e,r);if(!(n==null||i==null))return s==="horizontal"?w4(e,"yAxis",i,a):w4(e,"xAxis",n,a)},B_e=(e,r)=>{var a=Ua(e),s=Vm(e,r),n=Gm(e,r);if(!(s==null||n==null))return a==="horizontal"?hP(e,"xAxis",s):hP(e,"yAxis",n)},W_e=bt([$_e,jpe,B_e],xje),H_e=(e,r,a)=>{var s,n,i=ny(e,r);if(i==null)return 0;var o=Vm(e,r),l=Gm(e,r);if(o==null||l==null)return 0;var c=Ua(e),u=YI(e),{maxBarSize:h}=i,f=_n(h)?u:h,y,b;return c==="horizontal"?(y=Rp(e,"xAxis",o,a),b=Dp(e,"xAxis",o,a)):(y=Rp(e,"yAxis",l,a),b=Dp(e,"yAxis",l,a)),(s=(n=c1(y,b,!0))!==null&&n!==void 0?n:f)!==null&&s!==void 0?s:0},TU=(e,r,a)=>{var s=Ua(e),n=Vm(e,r),i=Gm(e,r);if(!(n==null||i==null)){var o,l;return s==="horizontal"?(o=Rp(e,"xAxis",n,a),l=Dp(e,"xAxis",n,a)):(o=Rp(e,"yAxis",i,a),l=Dp(e,"yAxis",i,a)),c1(o,l)}},q_e=bt([W_e,YI,wpe,JI,H_e,TU,I_e],jje),V_e=(e,r,a)=>{var s=Vm(e,r);if(s!=null)return Rp(e,"xAxis",s,a)},G_e=(e,r,a)=>{var s=Gm(e,r);if(s!=null)return Rp(e,"yAxis",s,a)},K_e=(e,r,a)=>{var s=Vm(e,r);if(s!=null)return Dp(e,"xAxis",s,a)},Y_e=(e,r,a)=>{var s=Gm(e,r);if(s!=null)return Dp(e,"yAxis",s,a)},J_e=bt([q_e,ny],kje),Z_e=bt([U_e,ny],_je),X_e=bt([kn,ZS,V_e,G_e,K_e,Y_e,J_e,Ua,mpe,TU,Z_e,ny,z_e],(e,r,a,s,n,i,o,l,c,u,h,f,y)=>{var{chartData:b,dataStartIndex:w,dataEndIndex:v}=c;if(!(f==null||o==null||r==null||l!=="horizontal"&&l!=="vertical"||a==null||s==null||n==null||i==null||u==null)){var{data:k}=f,S;if(k!=null&&k.length>0?S=k:S=b==null?void 0:b.slice(w,v+1),S!=null)return Ske({layout:l,barSettings:f,pos:o,parentViewBox:r,bandSize:u,xAxis:a,yAxis:s,xAxisTicks:n,yAxisTicks:i,stackedData:h,displayedData:S,offset:e,cells:y,dataStartIndex:w})}}),Q_e=["index"];function S4(){return S4=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},S4.apply(null,arguments)}function eke(e,r){if(e==null)return{};var a,s,n=tke(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function tke(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}var EU=p.createContext(void 0),rke=e=>{var r=p.useContext(EU);if(r!=null)return r.stackId;if(e!=null)return u0e(e)},ake=(e,r)=>"recharts-bar-stack-clip-path-".concat(e,"-").concat(r),ske=e=>{var r=p.useContext(EU);if(r!=null){var{stackId:a}=r;return"url(#".concat(ake(a,e),")")}},AU=e=>{var{index:r}=e,a=eke(e,Q_e),s=ske(r);return p.createElement(yi,S4({className:"recharts-bar-stack-layer",clipPath:s},a))},nke=["onMouseEnter","onMouseLeave","onClick"],ike=["value","background","tooltipPosition"],oke=["id"],lke=["onMouseEnter","onClick","onMouseLeave"];function r0(){return r0=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},r0.apply(null,arguments)}function vD(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function Pi(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?vD(Object(a),!0).forEach(function(s){cke(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):vD(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function cke(e,r,a){return(r=dke(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function dke(e){var r=uke(e,"string");return typeof r=="symbol"?r:r+""}function uke(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function z1(e,r){if(e==null)return{};var a,s,n=mke(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function mke(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}var hke=e=>{var{dataKey:r,name:a,fill:s,legendType:n,hide:i}=e;return[{inactive:i,dataKey:r,type:n,color:s,value:Ew(a,r),payload:e}]},pke=p.memo(e=>{var{dataKey:r,stroke:a,strokeWidth:s,fill:n,name:i,hide:o,unit:l,tooltipType:c,id:u}=e,h={dataDefinedOnItem:void 0,getPosition:Yp,settings:{stroke:a,strokeWidth:s,fill:n,dataKey:r,nameKey:void 0,name:Ew(i,r),hide:o,type:c,color:n,unit:l,graphicalItemId:u}};return p.createElement(hU,{tooltipEntrySettings:h})});function gke(e){var r=kr(Rm),{data:a,dataKey:s,background:n,allOtherBarProps:i}=e,{onMouseEnter:o,onMouseLeave:l,onClick:c}=i,u=z1(i,nke),h=bC(o,s,i.id),f=vC(l),y=wC(c,s,i.id);if(!n||a==null)return null;var b=rx(n);return p.createElement(mc,{zIndex:Nje(n,ri.barBackground)},a.map((w,v)=>{var{value:k,background:S,tooltipPosition:N}=w,C=z1(w,ike);if(!S)return null;var O=h(w,v),T=f(w,v),P=y(w,v),E=Pi(Pi(Pi(Pi(Pi({option:n,isActive:String(v)===r},C),{},{fill:"#eee"},S),b),$x(u,w,v)),{},{onMouseEnter:O,onMouseLeave:T,onClick:P,dataKey:s,index:v,className:"recharts-bar-background-rectangle"});return p.createElement(kC,r0({key:"background-bar-".concat(v)},E))}))}function fke(e){var{showLabels:r,children:a,rects:s}=e,n=s==null?void 0:s.map(i=>{var o={x:i.x,y:i.y,width:i.width,lowerWidth:i.width,upperWidth:i.width,height:i.height};return Pi(Pi({},o),{},{value:i.value,payload:i.payload,parentViewBox:i.parentViewBox,viewBox:o,fill:i.fill})});return p.createElement(S1e,{value:r?n:void 0},a)}function xke(e){var{shape:r,activeBar:a,baseProps:s,entry:n,index:i,dataKey:o}=e,l=kr(Rm),c=kr(dC),u=a&&String(n.originalDataIndex)===l&&(c==null||o===c),[h,f]=p.useState(!1),[y,b]=p.useState(!1);p.useEffect(()=>{var C;return u?(f(!0),C=requestAnimationFrame(()=>{b(!0)})):b(!1),()=>{cancelAnimationFrame(C)}},[u]);var w=p.useCallback(()=>{u||f(!1)},[u]),v=u&&y,k=u||h,S;u?a===!0?S=r:S=a:S=r;var N=p.createElement(kC,r0({},s,{name:String(s.name)},n,{isActive:v,option:S,index:i,dataKey:o,onTransitionEnd:w}));return k?p.createElement(mc,{zIndex:ri.activeBar},p.createElement(AU,{index:n.originalDataIndex},N)):N}function yke(e){var{shape:r,baseProps:a,entry:s,index:n,dataKey:i}=e;return p.createElement(kC,r0({},a,{name:String(a.name)},s,{isActive:!1,option:r,index:n,dataKey:i}))}function bke(e){var r,{data:a,props:s}=e,n=(r=ac(s))!==null&&r!==void 0?r:{},{id:i}=n,o=z1(n,oke),{shape:l,dataKey:c,activeBar:u}=s,{onMouseEnter:h,onClick:f,onMouseLeave:y}=s,b=z1(s,lke),w=bC(h,c,i),v=vC(y),k=wC(f,c,i);return a?p.createElement(p.Fragment,null,a.map((S,N)=>p.createElement(AU,r0({index:S.originalDataIndex,key:"rectangle-".concat(S==null?void 0:S.x,"-").concat(S==null?void 0:S.y,"-").concat(S==null?void 0:S.value,"-").concat(N),className:"recharts-bar-rectangle"},$x(b,S,N),{onMouseEnter:w(S,N),onMouseLeave:v(S,N),onClick:k(S,N)}),u?p.createElement(xke,{shape:l,activeBar:u,baseProps:o,entry:S,index:N,dataKey:c}):p.createElement(yke,{shape:l,baseProps:o,entry:S,index:N,dataKey:c})))):null}function vke(e){var{props:r,previousRectanglesRef:a}=e,{data:s,layout:n,isAnimationActive:i,animationBegin:o,animationDuration:l,animationEasing:c,onAnimationEnd:u,onAnimationStart:h}=r,f=a.current,y=zw(r,"recharts-bar-"),[b,w]=p.useState(!1),v=!b,k=p.useCallback(()=>{typeof u=="function"&&u(),w(!1)},[u]),S=p.useCallback(()=>{typeof h=="function"&&h(),w(!0)},[h]);return p.createElement(fke,{showLabels:v,rects:s},p.createElement(Iw,{animationId:y,begin:o,duration:l,isActive:i,easing:c,onAnimationEnd:k,onAnimationStart:S,key:y},N=>{var C=N===1?s:s==null?void 0:s.map((O,T)=>{var P=f&&f[T];if(P)return Pi(Pi({},O),{},{x:wn(P.x,O.x,N),y:wn(P.y,O.y,N),width:wn(P.width,O.width,N),height:wn(P.height,O.height,N)});if(n==="horizontal"){var E=wn(0,O.height,N),R=wn(O.stackedBarStart,O.y,N);return Pi(Pi({},O),{},{y:R,height:E})}var z=wn(0,O.width,N),G=wn(O.stackedBarStart,O.x,N);return Pi(Pi({},O),{},{width:z,x:G})});return N>0&&(a.current=C!=null?C:null),C==null?null:p.createElement(yi,null,p.createElement(bke,{props:r,data:C}))}),p.createElement(nU,{label:r.label}),r.children)}function wke(e){var r=p.useRef(null);return p.createElement(vke,{previousRectanglesRef:r,props:e})}var OU=0,jke=(e,r)=>{var a=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:a,errorVal:ls(e,r)}};class _ke extends p.PureComponent{render(){var{hide:r,data:a,dataKey:s,className:n,xAxisId:i,yAxisId:o,needClip:l,background:c,id:u}=this.props;if(r||a==null)return null;var h=va("recharts-bar",n),f=u;return p.createElement(yi,{className:h,id:u},l&&p.createElement("defs",null,p.createElement(P_e,{clipPathId:f,xAxisId:i,yAxisId:o})),p.createElement(yi,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(f,")"):void 0},p.createElement(gke,{data:a,dataKey:s,background:c,allOtherBarProps:this.props}),p.createElement(wke,this.props)))}}var kke={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:OU,xAxisId:0,yAxisId:0,zIndex:ri.bar};function Nke(e){var{xAxisId:r,yAxisId:a,hide:s,legendType:n,minPointSize:i,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:h}=e,{needClip:f}=CU(r,a),y=Jp(),b=ho(),w=yC(e.children,Lp),v=kr(N=>X_e(N,e.id,b,w));if(y!=="vertical"&&y!=="horizontal")return null;var k,S=v==null?void 0:v[0];return S==null||S.height==null||S.width==null?k=0:k=y==="vertical"?S.height/2:S.width/2,p.createElement(O_e,{xAxisId:r,yAxisId:a,data:v,dataPointFormatter:jke,errorBarOffset:k},p.createElement(_ke,r0({},e,{layout:y,needClip:f,data:v,xAxisId:r,yAxisId:a,hide:s,legendType:n,minPointSize:i,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:h})))}function Ske(e){var{layout:r,barSettings:{dataKey:a,minPointSize:s,hasCustomShape:n},pos:i,bandSize:o,xAxis:l,yAxis:c,xAxisTicks:u,yAxisTicks:h,stackedData:f,displayedData:y,offset:b,cells:w,parentViewBox:v,dataStartIndex:k}=e,S=r==="horizontal"?c:l,N=f?S.scale.domain():null,C=m0e({numericAxis:S}),O=S.scale.map(C);return y.map((T,P)=>{var E,R,z,G,ae,ee;if(f){var ne=f[P+k];if(ne==null)return null;E=i0e(ne,N)}else E=ls(T,a),Array.isArray(E)||(E=[C,E]);var te=M_e(s,OU)(E[1],P);if(r==="horizontal"){var Y,q=c.scale.map(E[0]),H=c.scale.map(E[1]);if(q==null||H==null)return null;R=oA({axis:l,ticks:u,bandSize:o,offset:i.offset,entry:T,index:P}),z=(Y=H!=null?H:q)!==null&&Y!==void 0?Y:void 0,G=i.size;var U=q-H;if(ae=$c(U)?0:U,ee={x:R,y:b.top,width:G,height:b.height},Math.abs(te)>0&&Math.abs(ae)<Math.abs(te)){var re=Ln(ae||te)*(Math.abs(te)-Math.abs(ae));z-=re,ae+=re}}else{var X=l.scale.map(E[0]),V=l.scale.map(E[1]);if(X==null||V==null)return null;if(R=X,z=oA({axis:c,ticks:h,bandSize:o,offset:i.offset,entry:T,index:P}),G=V-X,ae=i.size,ee={x:b.left,y:z,width:b.width,height:ae},Math.abs(te)>0&&Math.abs(G)<Math.abs(te)){var I=Ln(G||te)*(Math.abs(te)-Math.abs(G));G+=I}}if(R==null||z==null||G==null||ae==null||!n&&(G===0||ae===0))return null;var B=Pi(Pi({},T),{},{stackedBarStart:O,x:R,y:z,width:G,height:ae,value:f?E:E[1],payload:T,background:ee,tooltipPosition:{x:R+G/2,y:z+ae/2},parentViewBox:v,originalDataIndex:P},w&&w[P]&&w[P].props);return B}).filter(Boolean)}function Cke(e){var r=In(e,kke),a=rke(r.stackId),s=ho();return p.createElement(pU,{id:r.id,type:"bar"},n=>p.createElement(p.Fragment,null,p.createElement(hwe,{legendPayload:hke(r)}),p.createElement(pke,{dataKey:r.dataKey,stroke:r.stroke,strokeWidth:r.strokeWidth,fill:r.fill,name:r.name,hide:r.hide,unit:r.unit,tooltipType:r.tooltipType,id:n}),p.createElement(Twe,{type:"bar",id:n,data:void 0,xAxisId:r.xAxisId,yAxisId:r.yAxisId,zAxisId:0,dataKey:r.dataKey,stackId:a,hide:r.hide,barSize:r.barSize,minPointSize:r.minPointSize,maxBarSize:r.maxBarSize,isPanorama:s,hasCustomShape:r.shape!=null}),p.createElement(mc,{zIndex:r.zIndex},p.createElement(Nke,r0({},r,{id:n})))))}var Tf=p.memo(Cke,Vx);Tf.displayName="Bar";var Tke=["domain","range"],Eke=["domain","range"];function wD(e,r){if(e==null)return{};var a,s,n=Ake(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function Ake(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}function jD(e,r){return e===r?!0:Array.isArray(e)&&e.length===2&&Array.isArray(r)&&r.length===2?e[0]===r[0]&&e[1]===r[1]:!1}function PU(e,r){if(e===r)return!0;var{domain:a,range:s}=e,n=wD(e,Tke),{domain:i,range:o}=r,l=wD(r,Eke);return!jD(a,i)||!jD(s,o)?!1:Vx(n,l)}var Oke=["type"],Pke=["dangerouslySetInnerHTML","ticks","scale"],Dke=["id","scale"];function C4(){return C4=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},C4.apply(null,arguments)}function _D(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function kD(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?_D(Object(a),!0).forEach(function(s){Rke(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):_D(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function Rke(e,r,a){return(r=Mke(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Mke(e){var r=Lke(e,"string");return typeof r=="symbol"?r:r+""}function Lke(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function T4(e,r){if(e==null)return{};var a,s,n=Fke(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function Fke(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}function Ike(e){var r=ss(),a=p.useRef(null),s=pI(),{type:n}=e,i=T4(e,Oke),o=Bw(s,"xAxis",n),l=p.useMemo(()=>{if(o!=null)return kD(kD({},i),{},{type:o})},[i,o]);return p.useLayoutEffect(()=>{l!=null&&(a.current===null?r(oje(l)):a.current!==l&&r(lje({prev:a.current,next:l})),a.current=l)},[l,r]),p.useLayoutEffect(()=>()=>{a.current&&(r(cje(a.current)),a.current=null)},[r]),null}var zke=e=>{var{xAxisId:r,className:a}=e,s=kr(ZS),n=ho(),i="xAxis",o=kr(S=>h$(S,i,r,n)),l=kr(S=>d$(S,r)),c=kr(S=>tye(S,r)),u=kr(S=>Bz(S,r));if(l==null||c==null||u==null)return null;var{dangerouslySetInnerHTML:h,ticks:f,scale:y}=e,b=T4(e,Pke),{id:w,scale:v}=u,k=T4(u,Dke);return p.createElement(_C,C4({},b,k,{x:c.x,y:c.y,width:l.width,height:l.height,className:va("recharts-".concat(i," ").concat(i),a),viewBox:s,ticks:o,axisType:i,axisId:r}))},$ke={allowDataOverflow:yn.allowDataOverflow,allowDecimals:yn.allowDecimals,allowDuplicatedCategory:yn.allowDuplicatedCategory,angle:yn.angle,axisLine:qd.axisLine,height:yn.height,hide:!1,includeHidden:yn.includeHidden,interval:yn.interval,label:!1,minTickGap:yn.minTickGap,mirror:yn.mirror,orientation:yn.orientation,padding:yn.padding,reversed:yn.reversed,scale:yn.scale,tick:yn.tick,tickCount:yn.tickCount,tickLine:qd.tickLine,tickSize:qd.tickSize,type:yn.type,niceTicks:yn.niceTicks,xAxisId:0},Uke=e=>{var r=In(e,$ke);return p.createElement(p.Fragment,null,p.createElement(Ike,{allowDataOverflow:r.allowDataOverflow,allowDecimals:r.allowDecimals,allowDuplicatedCategory:r.allowDuplicatedCategory,angle:r.angle,dataKey:r.dataKey,domain:r.domain,height:r.height,hide:r.hide,id:r.xAxisId,includeHidden:r.includeHidden,interval:r.interval,minTickGap:r.minTickGap,mirror:r.mirror,name:r.name,orientation:r.orientation,padding:r.padding,reversed:r.reversed,scale:r.scale,tick:r.tick,tickCount:r.tickCount,tickFormatter:r.tickFormatter,ticks:r.ticks,type:r.type,unit:r.unit,niceTicks:r.niceTicks}),p.createElement(zke,r))},fv=p.memo(Uke,PU);fv.displayName="XAxis";var Bke=["type"],Wke=["dangerouslySetInnerHTML","ticks","scale"],Hke=["id","scale"];function E4(){return E4=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},E4.apply(null,arguments)}function ND(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function SD(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?ND(Object(a),!0).forEach(function(s){qke(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):ND(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function qke(e,r,a){return(r=Vke(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Vke(e){var r=Gke(e,"string");return typeof r=="symbol"?r:r+""}function Gke(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function A4(e,r){if(e==null)return{};var a,s,n=Kke(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function Kke(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}function Yke(e){var r=ss(),a=p.useRef(null),s=pI(),{type:n}=e,i=A4(e,Bke),o=Bw(s,"yAxis",n),l=p.useMemo(()=>{if(o!=null)return SD(SD({},i),{},{type:o})},[o,i]);return p.useLayoutEffect(()=>{l!=null&&(a.current===null?r(dje(l)):a.current!==l&&r(uje({prev:a.current,next:l})),a.current=l)},[l,r]),p.useLayoutEffect(()=>()=>{a.current&&(r(mje(a.current)),a.current=null)},[r]),null}function Jke(e){var{yAxisId:r,className:a,width:s,label:n}=e,i=p.useRef(null),o=p.useRef(null),l=kr(ZS),c=ho(),u=ss(),h="yAxis",f=kr(P=>u$(P,r)),y=kr(P=>aye(P,r)),b=kr(P=>h$(P,h,r,c)),w=kr(P=>Wz(P,r));if(p.useLayoutEffect(()=>{if(!(s!=="auto"||!f||gC(n)||p.isValidElement(n)||w==null)){var P=i.current;if(P){var E=P.getCalculatedWidth();Math.round(f.width)!==Math.round(E)&&u(hje({id:r,width:E}))}}},[b,f,u,n,r,s,w]),f==null||y==null||w==null)return null;var{dangerouslySetInnerHTML:v,ticks:k,scale:S}=e,N=A4(e,Wke),{id:C,scale:O}=w,T=A4(w,Hke);return p.createElement(_C,E4({},N,T,{ref:i,labelRef:o,x:y.x,y:y.y,tickTextProps:s==="auto"?{width:void 0}:{width:s},width:f.width,height:f.height,className:va("recharts-".concat(h," ").concat(h),a),viewBox:l,ticks:b,axisType:h,axisId:r}))}var Zke={allowDataOverflow:bn.allowDataOverflow,allowDecimals:bn.allowDecimals,allowDuplicatedCategory:bn.allowDuplicatedCategory,angle:bn.angle,axisLine:qd.axisLine,hide:!1,includeHidden:bn.includeHidden,interval:bn.interval,label:!1,minTickGap:bn.minTickGap,mirror:bn.mirror,orientation:bn.orientation,padding:bn.padding,reversed:bn.reversed,scale:bn.scale,tick:bn.tick,tickCount:bn.tickCount,tickLine:qd.tickLine,tickSize:qd.tickSize,type:bn.type,niceTicks:bn.niceTicks,width:bn.width,yAxisId:0},Xke=e=>{var r=In(e,Zke);return p.createElement(p.Fragment,null,p.createElement(Yke,{interval:r.interval,id:r.yAxisId,scale:r.scale,type:r.type,domain:r.domain,allowDataOverflow:r.allowDataOverflow,dataKey:r.dataKey,allowDuplicatedCategory:r.allowDuplicatedCategory,allowDecimals:r.allowDecimals,tickCount:r.tickCount,padding:r.padding,includeHidden:r.includeHidden,reversed:r.reversed,ticks:r.ticks,width:r.width,orientation:r.orientation,mirror:r.mirror,hide:r.hide,unit:r.unit,name:r.name,angle:r.angle,minTickGap:r.minTickGap,tick:r.tick,tickFormatter:r.tickFormatter,niceTicks:r.niceTicks}),p.createElement(Jke,r))},xv=p.memo(Xke,PU);xv.displayName="YAxis";var Qke=(e,r)=>r,NC=bt([Qke,Ua,az,zn,O$,cu,kbe,kn],Obe);function e2e(e){return"getBBox"in e.currentTarget&&typeof e.currentTarget.getBBox=="function"}function SC(e){var r=e.currentTarget.getBoundingClientRect(),a,s;if(e2e(e)){var n=e.currentTarget.getBBox();a=n.width>0?r.width/n.width:1,s=n.height>0?r.height/n.height:1}else{var i=e.currentTarget;a=i.offsetWidth>0?r.width/i.offsetWidth:1,s=i.offsetHeight>0?r.height/i.offsetHeight:1}var o=(l,c)=>({relativeX:Math.round((l-r.left)/a),relativeY:Math.round((c-r.top)/s)});return"touches"in e?Array.from(e.touches).map(l=>o(l.clientX,l.clientY)):o(e.clientX,e.clientY)}var DU=Ho("mouseClick"),RU=Bx();RU.startListening({actionCreator:DU,effect:(e,r)=>{var a=e.payload,s=NC(r.getState(),SC(a));(s==null?void 0:s.activeIndex)!=null&&r.dispatch(bye({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate}))}});var O4=Ho("mouseMove"),MU=Bx(),Kh=null,M0=null,Q2=null;MU.startListening({actionCreator:O4,effect:(e,r)=>{var a=e.payload,s=r.getState(),{throttleDelay:n,throttledEvents:i}=s.eventSettings,o=i==="all"||(i==null?void 0:i.includes("mousemove"));Kh!==null&&(cancelAnimationFrame(Kh),Kh=null),M0!==null&&(typeof n!="number"||!o)&&(clearTimeout(M0),M0=null),Q2=SC(a);var l=()=>{var c=r.getState(),u=ay(c,c.tooltip.settings.shared);if(!Q2){Kh=null,M0=null;return}if(u==="axis"){var h=NC(c,Q2);(h==null?void 0:h.activeIndex)!=null?r.dispatch(w$({activeIndex:h.activeIndex,activeDataKey:void 0,activeCoordinate:h.activeCoordinate})):r.dispatch(v$())}Kh=null,M0=null};if(!o){l();return}n==="raf"?Kh=requestAnimationFrame(l):typeof n=="number"&&M0===null&&(M0=setTimeout(l,n))}});function t2e(e,r){return r instanceof HTMLElement?"HTMLElement <".concat(r.tagName,' class="').concat(r.className,'">'):r===window?"global.window":e==="children"&&typeof r=="object"&&r!==null?"<<CHILDREN>>":r}var CD={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:"none",syncId:void 0,syncMethod:"index",baseValue:void 0,reverseStackOrder:!1},LU=wi({name:"rootProps",initialState:CD,reducers:{updateOptions:(e,r)=>{var a;e.accessibilityLayer=r.payload.accessibilityLayer,e.barCategoryGap=r.payload.barCategoryGap,e.barGap=(a=r.payload.barGap)!==null&&a!==void 0?a:CD.barGap,e.barSize=r.payload.barSize,e.maxBarSize=r.payload.maxBarSize,e.stackOffset=r.payload.stackOffset,e.syncId=r.payload.syncId,e.syncMethod=r.payload.syncMethod,e.className=r.payload.className,e.baseValue=r.payload.baseValue,e.reverseStackOrder=r.payload.reverseStackOrder}}}),r2e=LU.reducer,{updateOptions:a2e}=LU.actions,s2e=null,n2e={updatePolarOptions:(e,r)=>e===null?r.payload:(e.startAngle=r.payload.startAngle,e.endAngle=r.payload.endAngle,e.cx=r.payload.cx,e.cy=r.payload.cy,e.innerRadius=r.payload.innerRadius,e.outerRadius=r.payload.outerRadius,e)},FU=wi({name:"polarOptions",initialState:s2e,reducers:n2e}),{updatePolarOptions:i2e}=FU.actions,o2e=FU.reducer,IU=Ho("keyDown"),zU=Ho("focus"),$U=Ho("blur"),oj=Bx(),Yh=null,L0=null,Bb=null;oj.startListening({actionCreator:IU,effect:(e,r)=>{Bb=e.payload,Yh!==null&&(cancelAnimationFrame(Yh),Yh=null);var a=r.getState(),{throttleDelay:s,throttledEvents:n}=a.eventSettings,i=n==="all"||n.includes("keydown");L0!==null&&(typeof s!="number"||!i)&&(clearTimeout(L0),L0=null);var o=()=>{try{var l=r.getState(),c=l.rootProps.accessibilityLayer!==!1;if(!c)return;var{keyboardInteraction:u}=l.tooltip,h=Bb;if(h!=="ArrowRight"&&h!=="ArrowLeft"&&h!=="Enter")return;var f=Wf(u,Dm(l),Pp(l),Mp(l)),y=f==null?-1:Number(f),b=!Number.isFinite(y)||y<0,w=cu(l),v=Dm(l),k=ay(l,l.tooltip.settings.shared);if(h==="Enter"){if(b)return;var S=R1(l,k,"hover",String(u.index));r.dispatch(D1({active:!u.active,activeIndex:u.index,activeCoordinate:S}));return}var N=lye(l),C=N==="left-to-right"?1:-1,O=h==="ArrowRight"?1:-1,T;if(b){var P=Pp(l),E=Mp(l),R=O*C,z=te=>({active:!1,index:String(te),dataKey:void 0,graphicalItemId:void 0,coordinate:void 0});if(T=-1,R>0){for(var G=0;G<v.length;G++)if(Wf(z(G),v,P,E)!=null){T=G;break}}else for(var ae=v.length-1;ae>=0;ae--)if(Wf(z(ae),v,P,E)!=null){T=ae;break}if(T<0)return}else{T=y+O*C;var ee=(w==null?void 0:w.length)||v.length;if(ee===0||T>=ee||T<0)return}var ne=R1(l,k,"hover",String(T));r.dispatch(D1({active:!0,activeIndex:T.toString(),activeCoordinate:ne}))}finally{Yh=null,L0=null}};if(!i){o();return}s==="raf"?Yh=requestAnimationFrame(o):typeof s=="number"&&L0===null&&(o(),Bb=null,L0=setTimeout(()=>{Bb?o():(L0=null,Yh=null)},s))}});oj.startListening({actionCreator:zU,effect:(e,r)=>{var a=r.getState(),s=a.rootProps.accessibilityLayer!==!1;if(s){var{keyboardInteraction:n}=a.tooltip;if(!n.active&&n.index==null){var i="0",o=ay(a,a.tooltip.settings.shared),l=R1(a,o,"hover",String(i));r.dispatch(D1({active:!0,activeIndex:i,activeCoordinate:l}))}}}});oj.startListening({actionCreator:$U,effect:(e,r)=>{var a=r.getState(),s=a.rootProps.accessibilityLayer!==!1;if(s){var{keyboardInteraction:n}=a.tooltip;n.active&&r.dispatch(D1({active:!1,activeIndex:n.index,activeCoordinate:n.coordinate}))}}});function UU(e){e.persist();var{currentTarget:r}=e;return new Proxy(e,{get:(a,s)=>{if(s==="currentTarget")return r;var n=Reflect.get(a,s);return typeof n=="function"?n.bind(a):n}})}var ul=Ho("externalEvent"),BU=Bx(),Wb=new Map,pf=new Map,eN=new Map;BU.startListening({actionCreator:ul,effect:(e,r)=>{var{handler:a,reactEvent:s}=e.payload;if(a!=null){var n=s.type,i=UU(s);eN.set(n,{handler:a,reactEvent:i});var o=Wb.get(n);o!==void 0&&(cancelAnimationFrame(o),Wb.delete(n));var l=r.getState(),{throttleDelay:c,throttledEvents:u}=l.eventSettings,h=u,f=h==="all"||(h==null?void 0:h.includes(n)),y=pf.get(n);y!==void 0&&(typeof c!="number"||!f)&&(clearTimeout(y),pf.delete(n));var b=()=>{var k=eN.get(n);try{if(!k)return;var{handler:S,reactEvent:N}=k,C=r.getState(),O={activeCoordinate:cbe(C),activeDataKey:dC(C),activeIndex:Rm(C),activeLabel:R$(C),activeTooltipIndex:Rm(C),isTooltipActive:dbe(C)};S&&S(O,N)}finally{Wb.delete(n),pf.delete(n),eN.delete(n)}};if(!f){b();return}if(c==="raf"){var w=requestAnimationFrame(b);Wb.set(n,w)}else if(typeof c=="number"){if(!pf.has(n)){b();var v=setTimeout(b,c);pf.set(n,v)}}else b()}}});var l2e=bt([sg],e=>e.tooltipItemPayloads),c2e=bt([l2e,(e,r)=>r,(e,r,a)=>a],(e,r,a)=>{if(r!=null){var s=e.find(i=>i.settings.graphicalItemId===a);if(s!=null){var{getPosition:n}=s;if(n!=null)return n(r)}}}),WU=Ho("touchMove"),HU=Bx(),F0=null,Mu=null,TD=null,gf=null;HU.startListening({actionCreator:WU,effect:(e,r)=>{var a=e.payload;if(!(a.touches==null||a.touches.length===0)){gf=UU(a);var s=r.getState(),{throttleDelay:n,throttledEvents:i}=s.eventSettings,o=i==="all"||i.includes("touchmove");F0!==null&&(cancelAnimationFrame(F0),F0=null),Mu!==null&&(typeof n!="number"||!o)&&(clearTimeout(Mu),Mu=null),TD=Array.from(a.touches).map(c=>SC({clientX:c.clientX,clientY:c.clientY,currentTarget:a.currentTarget}));var l=()=>{if(gf!=null){var c=r.getState(),u=ay(c,c.tooltip.settings.shared);if(u==="axis"){var h,f=(h=TD)===null||h===void 0?void 0:h[0];if(f==null){F0=null,Mu=null;return}var y=NC(c,f);(y==null?void 0:y.activeIndex)!=null&&r.dispatch(w$({activeIndex:y.activeIndex,activeDataKey:void 0,activeCoordinate:y.activeCoordinate}))}else if(u==="item"){var b,w=gf.touches[0];if(document.elementFromPoint==null||w==null)return;var v=document.elementFromPoint(w.clientX,w.clientY);if(!v||!v.getAttribute)return;var k=v.getAttribute(lI),S=(b=v.getAttribute(cI))!==null&&b!==void 0?b:void 0,N=qm(c).find(T=>T.id===S);if(k==null||N==null||S==null)return;var{dataKey:C}=N,O=c2e(c,k,S);r.dispatch(b$({activeDataKey:C,activeIndex:k,activeCoordinate:O,activeGraphicalItemId:S}))}F0=null,Mu=null}};if(!o){l();return}n==="raf"?F0=requestAnimationFrame(l):typeof n=="number"&&Mu===null&&(l(),gf=null,Mu=setTimeout(()=>{gf?l():(Mu=null,F0=null)},n))}}});var CC={throttleDelay:"raf",throttledEvents:["mousemove","touchmove","pointermove","scroll","wheel"]},qU=wi({name:"eventSettings",initialState:CC,reducers:{setEventSettings:(e,r)=>{r.payload.throttleDelay!=null&&(e.throttleDelay=r.payload.throttleDelay),r.payload.throttledEvents!=null&&(e.throttledEvents=r.payload.throttledEvents)}}}),{setEventSettings:d2e}=qU.actions,u2e=qU.reducer,m2e=AF({brush:Sje,cartesianAxis:pje,chartData:ove,errorBars:N_e,eventSettings:u2e,graphicalItems:Swe,layout:t0e,legend:lme,options:rve,polarAxis:I1e,polarOptions:o2e,referenceElements:Aje,renderedTicks:Gje,rootProps:r2e,tooltip:vye,zIndex:Hbe}),h2e=function(r){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Chart";return Sue({reducer:m2e,preloadedState:r,middleware:s=>{var n;return s({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((n="es6")!==null&&n!==void 0?n:"")}).concat([RU.middleware,MU.middleware,oj.middleware,BU.middleware,HU.middleware])},enhancers:s=>{var n=s;return typeof s=="function"&&(n=s()),n.concat(qF({type:"raf"}))},devTools:{serialize:{replacer:t2e},name:"recharts-".concat(a)}})};function VU(e){var{preloadedState:r,children:a,reduxStoreName:s}=e,n=ho(),i=p.useRef(null);if(n)return a;i.current==null&&(i.current=h2e(r,s));var o=HS;return p.createElement(kme,{context:o,store:i.current},a)}function p2e(e){var{layout:r,margin:a}=e,s=ss(),n=ho();return p.useEffect(()=>{n||(s(Xue(r)),s(Zue(a)))},[s,n,r,a]),null}var GU=p.memo(p2e,Vx);function KU(e){var r=ss();return p.useEffect(()=>{r(a2e(e))},[r,e]),null}var g2e=e=>{var r=ss();return p.useEffect(()=>{r(d2e(e))},[r,e]),null},YU=p.memo(g2e,Vx);function ED(e){var{zIndex:r,isPanorama:a}=e,s=p.useRef(null),n=ss();return p.useLayoutEffect(()=>(s.current&&n(Bbe({zIndex:r,element:s.current,isPanorama:a})),()=>{n(Wbe({zIndex:r,isPanorama:a}))}),[n,r,a]),p.createElement("g",{tabIndex:-1,ref:s,className:"recharts-zIndex-layer_".concat(r)})}function AD(e){var{children:r,isPanorama:a}=e,s=kr(Dbe);if(!s||s.length===0)return r;var n=s.filter(o=>o<0),i=s.filter(o=>o>0);return p.createElement(p.Fragment,null,n.map(o=>p.createElement(ED,{key:o,zIndex:o,isPanorama:a})),r,i.map(o=>p.createElement(ED,{key:o,zIndex:o,isPanorama:a})))}var f2e=["children"];function x2e(e,r){if(e==null)return{};var a,s,n=y2e(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function y2e(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}function $1(){return $1=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},$1.apply(null,arguments)}var b2e={width:"100%",height:"100%",display:"block"},v2e=p.forwardRef((e,r)=>{var a=e3(),s=t3(),n=CI();if(!Bc(a)||!Bc(s))return null;var{children:i,otherAttributes:o,title:l,desc:c}=e,u,h;return o!=null&&(typeof o.tabIndex=="number"?u=o.tabIndex:u=n?0:void 0,typeof o.role=="string"?h=o.role:h=n?"application":void 0),p.createElement(MS,$1({},o,{title:l,desc:c,role:h,tabIndex:u,width:a,height:s,style:b2e,ref:r}),i)}),w2e=e=>{var{children:r}=e,a=kr(Dw);if(!a)return null;var{width:s,height:n,y:i,x:o}=a;return p.createElement(MS,{width:s,height:n,x:o,y:i},r)},OD=p.forwardRef((e,r)=>{var{children:a}=e,s=x2e(e,f2e),n=ho();return n?p.createElement(w2e,null,p.createElement(AD,{isPanorama:!0},a)):p.createElement(v2e,$1({ref:r},s),p.createElement(AD,{isPanorama:!1},a))});function j2e(){var e=ss(),[r,a]=p.useState(null),s=kr(y0e);return p.useEffect(()=>{if(r!=null){var n=r.getBoundingClientRect(),i=n.width/r.offsetWidth;ja(i)&&i!==s&&e(e0e(i))}},[r,e,s]),a}function PD(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function _2e(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?PD(Object(a),!0).forEach(function(s){k2e(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):PD(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function k2e(e,r,a){return(r=N2e(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function N2e(e){var r=S2e(e,"string");return typeof r=="symbol"?r:r+""}function S2e(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Yu(){return Yu=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},Yu.apply(null,arguments)}var C2e=()=>(fve(),null);function U1(e){if(typeof e=="number")return e;if(typeof e=="string"){var r=parseFloat(e);if(!Number.isNaN(r))return r}return 0}var T2e=p.forwardRef((e,r)=>{var a,s,n=p.useRef(null),[i,o]=p.useState({containerWidth:U1((a=e.style)===null||a===void 0?void 0:a.width),containerHeight:U1((s=e.style)===null||s===void 0?void 0:s.height)}),l=p.useCallback((u,h)=>{o(f=>{var y=Math.round(u),b=Math.round(h);return f.containerWidth===y&&f.containerHeight===b?f:{containerWidth:y,containerHeight:b}})},[]),c=p.useCallback(u=>{if(typeof r=="function"&&r(u),n.current!=null&&(n.current.disconnect(),n.current=null),u!=null&&typeof ResizeObserver!="undefined"){var{width:h,height:f}=u.getBoundingClientRect();l(h,f);var y=w=>{var v=w[0];if(v!=null){var{width:k,height:S}=v.contentRect;l(k,S)}},b=new ResizeObserver(y);b.observe(u),n.current=b}},[r,l]);return p.useEffect(()=>()=>{var u=n.current;u!=null&&u.disconnect()},[l]),p.createElement(p.Fragment,null,p.createElement(Hx,{width:i.containerWidth,height:i.containerHeight}),p.createElement("div",Yu({ref:c},e)))}),E2e=p.forwardRef((e,r)=>{var{width:a,height:s}=e,[n,i]=p.useState({containerWidth:U1(a),containerHeight:U1(s)}),o=p.useCallback((c,u)=>{i(h=>{var f=Math.round(c),y=Math.round(u);return h.containerWidth===f&&h.containerHeight===y?h:{containerWidth:f,containerHeight:y}})},[]),l=p.useCallback(c=>{if(typeof r=="function"&&r(c),c!=null){var{width:u,height:h}=c.getBoundingClientRect();o(u,h)}},[r,o]);return p.createElement(p.Fragment,null,p.createElement(Hx,{width:n.containerWidth,height:n.containerHeight}),p.createElement("div",Yu({ref:l},e)))}),A2e=p.forwardRef((e,r)=>{var{width:a,height:s}=e;return p.createElement(p.Fragment,null,p.createElement(Hx,{width:a,height:s}),p.createElement("div",Yu({ref:r},e)))}),O2e=p.forwardRef((e,r)=>{var{width:a,height:s}=e;return typeof a=="string"||typeof s=="string"?p.createElement(E2e,Yu({},e,{ref:r})):typeof a=="number"&&typeof s=="number"?p.createElement(A2e,Yu({},e,{width:a,height:s,ref:r})):p.createElement(p.Fragment,null,p.createElement(Hx,{width:a,height:s}),p.createElement("div",Yu({ref:r},e)))});function P2e(e){return e?T2e:O2e}var D2e=p.forwardRef((e,r)=>{var{children:a,className:s,height:n,onClick:i,onContextMenu:o,onDoubleClick:l,onMouseDown:c,onMouseEnter:u,onMouseLeave:h,onMouseMove:f,onMouseUp:y,onTouchEnd:b,onTouchMove:w,onTouchStart:v,style:k,width:S,responsive:N,dispatchTouchEvents:C=!0}=e,O=p.useRef(null),T=ss(),[P,E]=p.useState(null),[R,z]=p.useState(null),G=j2e(),ae=XS(),ee=(ae==null?void 0:ae.width)>0?ae.width:S,ne=(ae==null?void 0:ae.height)>0?ae.height:n,te=p.useCallback(ge=>{G(ge),typeof r=="function"&&r(ge),E(ge),z(ge),ge!=null&&(O.current=ge)},[G,r,E,z]),Y=p.useCallback(ge=>{T(DU(ge)),T(ul({handler:i,reactEvent:ge}))},[T,i]),q=p.useCallback(ge=>{T(O4(ge)),T(ul({handler:u,reactEvent:ge}))},[T,u]),H=p.useCallback(ge=>{T(v$()),T(ul({handler:h,reactEvent:ge}))},[T,h]),U=p.useCallback(ge=>{T(O4(ge)),T(ul({handler:f,reactEvent:ge}))},[T,f]),re=p.useCallback(()=>{T(zU())},[T]),X=p.useCallback(()=>{T($U())},[T]),V=p.useCallback(ge=>{T(IU(ge.key))},[T]),I=p.useCallback(ge=>{T(ul({handler:o,reactEvent:ge}))},[T,o]),B=p.useCallback(ge=>{T(ul({handler:l,reactEvent:ge}))},[T,l]),Q=p.useCallback(ge=>{T(ul({handler:c,reactEvent:ge}))},[T,c]),ie=p.useCallback(ge=>{T(ul({handler:y,reactEvent:ge}))},[T,y]),me=p.useCallback(ge=>{T(ul({handler:v,reactEvent:ge}))},[T,v]),he=p.useCallback(ge=>{C&&T(WU(ge)),T(ul({handler:w,reactEvent:ge}))},[T,C,w]),de=p.useCallback(ge=>{T(ul({handler:b,reactEvent:ge}))},[T,b]),xe=P2e(N);return p.createElement(B$.Provider,{value:P},p.createElement(VL.Provider,{value:R},p.createElement(xe,{width:ee!=null?ee:k==null?void 0:k.width,height:ne!=null?ne:k==null?void 0:k.height,className:va("recharts-wrapper",s),style:_2e({position:"relative",cursor:"default",width:ee,height:ne},k),onClick:Y,onContextMenu:I,onDoubleClick:B,onFocus:re,onBlur:X,onKeyDown:V,onMouseDown:Q,onMouseEnter:q,onMouseLeave:H,onMouseMove:U,onMouseUp:ie,onTouchEnd:de,onTouchMove:he,onTouchStart:me,ref:te},p.createElement(C2e,null),a)))}),R2e=["width","height","responsive","children","className","style","compact","title","desc"];function M2e(e,r){if(e==null)return{};var a,s,n=L2e(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function L2e(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}var JU=p.forwardRef((e,r)=>{var{width:a,height:s,responsive:n,children:i,className:o,style:l,compact:c,title:u,desc:h}=e,f=M2e(e,R2e),y=ac(f);return c?p.createElement(p.Fragment,null,p.createElement(Hx,{width:a,height:s}),p.createElement(OD,{otherAttributes:y,title:u,desc:h},i)):p.createElement(D2e,{className:o,style:l,width:a,height:s,responsive:n!=null?n:!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},p.createElement(OD,{otherAttributes:y,title:u,desc:h,ref:r},p.createElement(Pje,null,i)))});function P4(){return P4=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},P4.apply(null,arguments)}function DD(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function F2e(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?DD(Object(a),!0).forEach(function(s){I2e(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):DD(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function I2e(e,r,a){return(r=z2e(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function z2e(e){var r=$2e(e,"string");return typeof r=="symbol"?r:r+""}function $2e(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var U2e={top:5,right:5,bottom:5,left:5},B2e=F2e({accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:U2e,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},CC),W2e=p.forwardRef(function(r,a){var s,n=In(r.categoricalChartProps,B2e),{chartName:i,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:u}=r,h={chartName:i,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return p.createElement(VU,{preloadedState:{options:h},reduxStoreName:(s=u.id)!==null&&s!==void 0?s:i},p.createElement(vU,{chartData:u.data}),p.createElement(GU,{layout:n.layout,margin:n.margin}),p.createElement(YU,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),p.createElement(KU,{baseValue:n.baseValue,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),p.createElement(JU,P4({},n,{ref:a})))}),H2e=["axis","item"],tN=p.forwardRef((e,r)=>p.createElement(W2e,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:H2e,tooltipPayloadSearcher:W$,categoricalChartProps:e,ref:r}));function q2e(e){var r=ss();return p.useEffect(()=>{r(i2e(e))},[r,e]),null}var V2e=["layout"];function D4(){return D4=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)({}).hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},D4.apply(null,arguments)}function G2e(e,r){if(e==null)return{};var a,s,n=K2e(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)a=i[s],r.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function K2e(e,r){if(e==null)return{};var a={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(r.indexOf(s)!==-1)continue;a[s]=e[s]}return a}function RD(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function Y2e(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?RD(Object(a),!0).forEach(function(s){J2e(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):RD(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function J2e(e,r,a){return(r=Z2e(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Z2e(e){var r=X2e(e,"string");return typeof r=="symbol"?r:r+""}function X2e(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var Q2e={top:5,right:5,bottom:5,left:5},ZU=Y2e({accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:Q2e,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},CC),eNe=p.forwardRef(function(r,a){var s,n=In(r.categoricalChartProps,ZU),{layout:i}=n,o=G2e(n,V2e),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:h}=r,f={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:h,eventEmitter:void 0};return p.createElement(VU,{preloadedState:{options:f},reduxStoreName:(s=n.id)!==null&&s!==void 0?s:l},p.createElement(vU,{chartData:n.data}),p.createElement(GU,{layout:i,margin:n.margin}),p.createElement(YU,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),p.createElement(KU,{baseValue:void 0,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),p.createElement(q2e,{cx:n.cx,cy:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius}),p.createElement(JU,D4({},o,{ref:a})))});function MD(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,s)}return a}function LD(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?MD(Object(a),!0).forEach(function(s){tNe(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):MD(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function tNe(e,r,a){return(r=rNe(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function rNe(e){var r=aNe(e,"string");return typeof r=="symbol"?r:r+""}function aNe(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var s=a.call(e,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var sNe=["item"],nNe=LD(LD({},ZU),{},{layout:"centric",startAngle:0,endAngle:360}),iNe=p.forwardRef((e,r)=>{var a=In(e,nNe);return p.createElement(eNe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:sNe,tooltipPayloadSearcher:W$,categoricalChartProps:a,ref:r})});function oNe(e){return e.replace(/ /gi," ").replace(/&#(\d+);/g,(r,a)=>String.fromCharCode(Number(a))).replace(/&#x([0-9a-f]+);/gi,(r,a)=>String.fromCharCode(parseInt(a,16))).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'")}function lNe(e){const r=e.replace(/<\/p>/gi,`
|
||
`).replace(/<br\s*\/?>/gi,`
|
||
`).replace(/<\/div>/gi,`
|
||
`).replace(/<\/li>/gi,`
|
||
`).replace(/<[^>]+>/g,"");return oNe(r)}function R4(e){if(e==null)return"";let r=String(e).trim();if(!r)return"";if(r.startsWith("["))try{const l=JSON.parse(r);if(Array.isArray(l)&&l.every(c=>typeof c=="string"))return l.map(c=>c.trim()).filter(Boolean).join(`
|
||
|
||
`)}catch(l){}let a=r;const s=a.match(/<div[^>]*class="[^"]*ql-editor[^"]*"[^>]*>([\s\S]*?)<\/div>/i);s&&(a=s[1].trim());const i=(/<\/?[a-z][\s\S]*>/i.test(a)?lNe(a):a).replace(/\r\n/g,`
|
||
`),o=[...i.matchAll(/"((?:[^"\\]|\\.)*)"\s*,?/g)].map(l=>l[1].replace(/\\"/g,'"'));return o.length>=2?o.map(l=>l.trim()).filter(Boolean).join(`
|
||
|
||
`):o.length===1&&!i.replace(/"((?:[^"\\]|\\.)*)"\s*,?/g,"").replace(/[\s,]/g,"")?o[0].trim():i.replace(/\n{3,}/g,`
|
||
|
||
`).trim()}const Hb=["#2563eb","#4f46e5","#7c3aed","#0ea5e9","#14b8a6","#10b981","#f59e0b","#64748b","#ec4899","#06b6d4","#84cc16","#f97316","#a855f7","#2dd4bf","#eab308"],M4=["Open","Raised","Warning","Penalty","Change Requests","Problems","Letter"],cNe=30,I0=1380,XU=`
|
||
/* Snapshot charts: 4 columns (xl+) / print; 2 columns sm–xl; 1 column on narrow screens. */
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-charts-section {
|
||
width: 100% !important;
|
||
max-width: 100% !important;
|
||
box-sizing: border-box !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-charts-four {
|
||
display: grid !important;
|
||
grid-template-columns: minmax(0, 1fr) !important;
|
||
gap: 10px !important;
|
||
align-items: stretch !important;
|
||
padding-top: 10px !important;
|
||
padding-bottom: 12px !important;
|
||
padding-left: 6px !important;
|
||
padding-right: 6px !important;
|
||
box-sizing: border-box !important;
|
||
}
|
||
@media (min-width: 640px) and (max-width: 1279px) {
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-charts-four {
|
||
grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
|
||
}
|
||
}
|
||
@media (min-width: 1280px), print {
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-charts-four {
|
||
grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
|
||
}
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-chart-col {
|
||
min-width: 0 !important;
|
||
min-height: 0 !important;
|
||
max-width: 100% !important;
|
||
}
|
||
/* Clip horizontal bleed only; vertical overflow visible so bar heights are not clipped. */
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-weekly-chart-card {
|
||
overflow-x: hidden !important;
|
||
overflow-y: visible !important;
|
||
max-width: 100% !important;
|
||
box-sizing: border-box !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-weekly-chart-card .recharts-wrapper,
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-weekly-chart-card .recharts-surface {
|
||
max-width: 100% !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-weekly-chart.reports-chart-plot-shell,
|
||
#asm-project-reports-root .reports-project-snapshot .reports-chart-plot-shell.reports-snapshot-weekly-chart {
|
||
width: 100% !important;
|
||
max-width: 100% !important;
|
||
box-sizing: border-box !important;
|
||
min-height: 10rem !important;
|
||
height: 100% !important;
|
||
flex: 1 1 auto !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-weekly-chart .recharts-responsive-container {
|
||
width: 100% !important;
|
||
max-width: 100% !important;
|
||
}
|
||
/* Updates | Notes: force two columns from md+ and in print (Tailwind lg: alone stacks in print preview). */
|
||
#asm-project-reports-root .reports-snapshot-updates-notes-row {
|
||
display: grid !important;
|
||
grid-template-columns: minmax(0, 1fr) !important;
|
||
gap: 8px !important;
|
||
align-items: stretch !important;
|
||
}
|
||
@media (min-width: 768px), print {
|
||
#asm-project-reports-root .reports-snapshot-updates-notes-row {
|
||
grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
|
||
}
|
||
}
|
||
/* Bottom task tables: three columns in print like lg: */
|
||
@media print {
|
||
#asm-project-reports-root .reports-snapshot-bottom-tasks {
|
||
display: grid !important;
|
||
grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
|
||
gap: 6px !important;
|
||
align-items: start !important;
|
||
}
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-invoice-chart {
|
||
min-height: 156px !important;
|
||
height: 156px !important;
|
||
flex-shrink: 0 !important;
|
||
overflow: hidden !important;
|
||
max-width: 100% !important;
|
||
padding: 0 !important;
|
||
}
|
||
@media print {
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-invoice-chart {
|
||
min-height: 124px !important;
|
||
height: 124px !important;
|
||
}
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-progress-row {
|
||
display: flex !important;
|
||
flex-direction: column !important;
|
||
align-items: stretch !important;
|
||
gap: 8px !important;
|
||
}
|
||
@media (min-width: 768px), print {
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-progress-row {
|
||
flex-direction: row !important;
|
||
flex-wrap: nowrap !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-progress-row > * {
|
||
flex: 1 1 0 !important;
|
||
min-width: 0 !important;
|
||
}
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-table-scroll {
|
||
max-height: 11rem !important;
|
||
overflow-y: auto !important;
|
||
overflow-x: auto !important;
|
||
}
|
||
@media print {
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-table-scroll {
|
||
max-height: 10rem !important;
|
||
overflow-y: auto !important;
|
||
overflow-x: auto !important;
|
||
-webkit-overflow-scrolling: touch !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-weekly-chart.reports-chart-plot-shell {
|
||
display: block !important;
|
||
min-height: 11rem !important;
|
||
height: 100% !important;
|
||
max-height: none !important;
|
||
flex: 1 1 auto !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-weekly-chart .recharts-responsive-container {
|
||
width: 100% !important;
|
||
height: 100% !important;
|
||
min-height: 120px !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-invoice-chart .recharts-responsive-container {
|
||
width: 100% !important;
|
||
height: 100% !important;
|
||
min-height: 104px !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-donut-inner {
|
||
min-height: 132px !important;
|
||
height: 132px !important;
|
||
min-width: 132px !important;
|
||
width: 132px !important;
|
||
margin-left: auto !important;
|
||
margin-right: auto !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-donut-inner .recharts-responsive-container {
|
||
width: 100% !important;
|
||
height: 100% !important;
|
||
min-height: 132px !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-weekly-chart-card {
|
||
overflow-x: hidden !important;
|
||
overflow-y: visible !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-invoice-chart {
|
||
min-height: 128px !important;
|
||
height: 128px !important;
|
||
overflow: visible !important;
|
||
}
|
||
/* Donut card uses overflow-x-hidden on screen — some print engines clip the SVG. */
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-overall-card {
|
||
overflow: visible !important;
|
||
}
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-notes-body {
|
||
max-height: 11rem !important;
|
||
overflow-y: auto !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-donut-legend {
|
||
max-height: none !important;
|
||
overflow: visible !important;
|
||
}
|
||
/* Project Overview row: keep start/end date pills aligned with top of meta column (print/PDF flex/grid stretch) */
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-overview-inner {
|
||
align-items: start !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-overview-dates {
|
||
align-self: start !important;
|
||
justify-content: flex-start !important;
|
||
align-content: flex-start !important;
|
||
}
|
||
/* md+ and print: right-align date rows in the third column (main axis is column → do not use justify-content:end) */
|
||
@media (min-width: 768px), print {
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-overview-dates {
|
||
align-items: flex-end !important;
|
||
}
|
||
}
|
||
@media screen and (max-width: 767px) {
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-overview-dates {
|
||
align-items: flex-start !important;
|
||
}
|
||
}
|
||
/*
|
||
* Print: viewport is often < 768px so Tailwind md:grid-cols-12 does not apply — dates fall below.
|
||
* Force the same 5 + 4 + 3 column row as the dashboard.
|
||
*/
|
||
@media print {
|
||
#asm-project-reports-root .reports-snapshot-overview-inner {
|
||
display: grid !important;
|
||
grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
|
||
gap: 6px !important;
|
||
align-items: start !important;
|
||
}
|
||
#asm-project-reports-root .reports-snapshot-overview-meta {
|
||
grid-column: 1 / span 5 !important;
|
||
max-width: none !important;
|
||
}
|
||
#asm-project-reports-root .reports-snapshot-overview-timeline {
|
||
grid-column: 6 / span 4 !important;
|
||
max-width: none !important;
|
||
border-left: 1px solid #e5e7eb !important;
|
||
padding-left: 8px !important;
|
||
}
|
||
#asm-project-reports-root.dark .reports-snapshot-overview-timeline {
|
||
border-left-color: #4b5563 !important;
|
||
}
|
||
#asm-project-reports-root .reports-snapshot-overview-dates {
|
||
grid-column: 10 / span 3 !important;
|
||
max-width: none !important;
|
||
}
|
||
}
|
||
`,QU=`
|
||
${XU}
|
||
#asm-project-reports-root .reports-project-snapshot {
|
||
overflow: visible !important;
|
||
}
|
||
@media print {
|
||
/* Let the snapshot span pages so flex/grid does not squash chart cells to 0 height. */
|
||
#asm-project-reports-root .reports-project-snapshot {
|
||
page-break-inside: auto !important;
|
||
break-inside: auto !important;
|
||
}
|
||
}
|
||
@media screen {
|
||
#asm-project-reports-root .reports-project-snapshot {
|
||
page-break-inside: avoid;
|
||
break-inside: avoid;
|
||
}
|
||
}
|
||
#asm-project-reports-root .dashboard-report-project-scope { display: none !important; }
|
||
#asm-project-reports-root .reports-selected-project-banner {
|
||
display: block !important;
|
||
page-break-after: avoid !important;
|
||
break-after: avoid !important;
|
||
page-break-inside: avoid !important;
|
||
break-inside: avoid !important;
|
||
margin-bottom: 12px !important;
|
||
-webkit-print-color-adjust: exact !important;
|
||
print-color-adjust: exact !important;
|
||
background: #ecfdf5 !important;
|
||
border: 1px solid #2dd4bf !important;
|
||
box-shadow: none !important;
|
||
}
|
||
#asm-project-reports-root .reports-selected-project-banner p:nth-child(1) {
|
||
color: #0f766e !important;
|
||
}
|
||
#asm-project-reports-root .reports-selected-project-banner p:nth-child(2) {
|
||
color: #0f172a !important;
|
||
}
|
||
#asm-project-reports-root .reports-selected-project-banner p:nth-child(3) {
|
||
color: #475569 !important;
|
||
}
|
||
#asm-project-reports-root .reports-chart-grid {
|
||
display: grid !important;
|
||
grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
|
||
gap: 10px !important;
|
||
align-items: start !important;
|
||
}
|
||
#asm-project-reports-root .reports-chart-grid > * {
|
||
min-width: 0 !important;
|
||
max-width: 100% !important;
|
||
box-sizing: border-box !important;
|
||
}
|
||
#asm-project-reports-root .reports-snapshot-split {
|
||
display: grid !important;
|
||
grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
|
||
gap: 8px !important;
|
||
align-items: start !important;
|
||
}
|
||
#asm-project-reports-root .reports-snapshot-split > * {
|
||
min-width: 0 !important;
|
||
max-width: 100% !important;
|
||
box-sizing: border-box !important;
|
||
}
|
||
#asm-project-reports-root .reports-chart-grid > * {
|
||
page-break-inside: avoid !important;
|
||
break-inside: avoid !important;
|
||
overflow: hidden !important;
|
||
}
|
||
#asm-project-reports-root .reports-table-block {
|
||
page-break-inside: avoid !important;
|
||
break-inside: avoid !important;
|
||
overflow: visible !important;
|
||
}
|
||
#asm-project-reports-root {
|
||
padding: 0 !important;
|
||
margin: 0 !important;
|
||
min-height: 0 !important;
|
||
background: #fff !important;
|
||
color: #111827 !important;
|
||
-webkit-print-color-adjust: exact !important;
|
||
print-color-adjust: exact !important;
|
||
}
|
||
#asm-project-reports-root * { box-shadow: none !important; }
|
||
#asm-project-reports-root .min-h-screen { min-height: 0 !important; }
|
||
#asm-project-reports-root .mb-6 { margin-bottom: 10px !important; }
|
||
#asm-project-reports-root .mb-4 { margin-bottom: 8px !important; }
|
||
#asm-project-reports-root .mb-3 { margin-bottom: 6px !important; }
|
||
`,eB=`
|
||
@media print {
|
||
#asm-project-reports-root .reports-project-snapshot .recharts-wrapper {
|
||
overflow: visible !important;
|
||
}
|
||
}
|
||
#asm-project-reports-root .reports-chart-grid .recharts-legend-wrapper,
|
||
#asm-project-reports-root .reports-project-snapshot .recharts-legend-wrapper {
|
||
max-width: calc(100% - 8px) !important;
|
||
box-sizing: border-box !important;
|
||
}
|
||
#asm-project-reports-root .reports-chart-grid .recharts-legend-item-text,
|
||
#asm-project-reports-root .reports-project-snapshot .recharts-legend-item-text {
|
||
fill: #111827 !important;
|
||
color: #111827 !important;
|
||
font-size: 8px !important;
|
||
}
|
||
#asm-project-reports-root .reports-chart-grid .recharts-default-legend,
|
||
#asm-project-reports-root .reports-project-snapshot .recharts-default-legend {
|
||
display: flex !important;
|
||
flex-wrap: wrap !important;
|
||
justify-content: center !important;
|
||
row-gap: 2px !important;
|
||
column-gap: 8px !important;
|
||
width: 100% !important;
|
||
padding: 0 4px !important;
|
||
box-sizing: border-box !important;
|
||
}
|
||
#asm-project-reports-root .reports-chart-grid .recharts-default-legend li,
|
||
#asm-project-reports-root .reports-project-snapshot .recharts-default-legend li {
|
||
margin-right: 0 !important;
|
||
margin-left: 0 !important;
|
||
}
|
||
#asm-project-reports-root .reports-chart-grid .recharts-cartesian-axis-tick text,
|
||
#asm-project-reports-root .reports-project-snapshot .recharts-cartesian-axis-tick text {
|
||
font-size: 8px !important;
|
||
}
|
||
`,dNe=`
|
||
@media print and (orientation: landscape) {
|
||
/*
|
||
* Do not set @page { size: ... } here — it locks orientation in some browsers and hides the
|
||
* print dialog’s layout control. Margins only; user picks Portrait/Landscape in the dialog.
|
||
*/
|
||
@page {
|
||
margin: 2mm;
|
||
}
|
||
/*
|
||
* One landscape sheet: root scale ~80% + tighter vertical rhythm.
|
||
* (Avoid forcing height on .recharts-surface — that breaks layout; scale on the root is OK here.)
|
||
*/
|
||
#asm-project-reports-root.reports-print-root {
|
||
transform: scale(0.8) !important;
|
||
transform-origin: top left !important;
|
||
width: calc(100% / 0.8) !important;
|
||
max-width: none !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-body {
|
||
padding: 4px 6px !important;
|
||
gap: 4px !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-overview-inner {
|
||
padding: 4px 6px !important;
|
||
gap: 4px !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-weekly-chart.reports-chart-plot-shell {
|
||
min-height: 8.5rem !important;
|
||
height: 100% !important;
|
||
flex: 1 1 auto !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-weekly-chart .recharts-responsive-container {
|
||
min-height: 112px !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-invoice-chart {
|
||
min-height: 80px !important;
|
||
height: 80px !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-invoice-chart .recharts-responsive-container {
|
||
min-height: 72px !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-donut-inner {
|
||
min-height: 88px !important;
|
||
height: 88px !important;
|
||
min-width: 88px !important;
|
||
width: 88px !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-donut-inner .recharts-responsive-container {
|
||
min-height: 88px !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-donut-legend {
|
||
max-height: 1.9rem !important;
|
||
overflow: hidden !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-table-scroll {
|
||
max-height: 3.75rem !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-notes-body,
|
||
#asm-project-reports-root .reports-snapshot-updates-notes-row .reports-snapshot-notes-body {
|
||
max-height: 3.5rem !important;
|
||
padding: 3px 5px !important;
|
||
}
|
||
#asm-project-reports-root .reports-snapshot-updates-notes-row {
|
||
gap: 2px !important;
|
||
}
|
||
#asm-project-reports-root .reports-snapshot-bottom-tasks {
|
||
gap: 3px !important;
|
||
}
|
||
#asm-project-reports-root .reports-snapshot-bottom-tasks h3 {
|
||
margin-bottom: 1px !important;
|
||
line-height: 1 !important;
|
||
}
|
||
/* Keep each bottom table block together so headers are not orphaned on the previous page. */
|
||
#asm-project-reports-root .reports-snapshot-bottom-tasks > div {
|
||
break-inside: avoid !important;
|
||
page-break-inside: avoid !important;
|
||
}
|
||
}
|
||
`,uNe=`
|
||
@media print {
|
||
@page {
|
||
margin: 3mm;
|
||
}
|
||
html, body {
|
||
height: auto !important;
|
||
margin: 0 !important;
|
||
padding: 0 !important;
|
||
overflow: visible !important;
|
||
background: #fff !important;
|
||
}
|
||
/*
|
||
* App shell (see asm-app-sidebar / asm-app-main on Sidebar + main column): hide nav chrome
|
||
* so only the report (#asm-project-reports-root) prints across the full page width.
|
||
*/
|
||
.asm-app-sidebar-backdrop {
|
||
display: none !important;
|
||
}
|
||
.asm-app-sidebar {
|
||
display: none !important;
|
||
}
|
||
.asm-app-main {
|
||
flex: none !important;
|
||
width: 100% !important;
|
||
min-width: 0 !important;
|
||
max-width: 100% !important;
|
||
overflow: visible !important;
|
||
}
|
||
.asm-app-main > header {
|
||
display: none !important;
|
||
}
|
||
.asm-app-main > div.flex-1.overflow-y-auto {
|
||
overflow: visible !important;
|
||
width: 100% !important;
|
||
max-width: 100% !important;
|
||
}
|
||
.flex.h-screen.overflow-hidden {
|
||
height: auto !important;
|
||
min-height: 0 !important;
|
||
overflow: visible !important;
|
||
}
|
||
/* Print should be the report content only (no filter row). KPI strip removed from UI. */
|
||
#asm-project-reports-root .dashboard-report-project-scope {
|
||
display: none !important;
|
||
}
|
||
/* Do not use body * visibility:hidden — blank pages in Desk / some browsers. */
|
||
/* Do not use CSS zoom on the root — breaks SVG/Recharts in print; 1:1 like dashboard (may span pages). */
|
||
#asm-project-reports-root.reports-print-root {
|
||
position: relative !important;
|
||
left: auto !important;
|
||
top: auto !important;
|
||
width: 100% !important;
|
||
max-width: 100% !important;
|
||
min-width: 0 !important;
|
||
min-height: 0 !important;
|
||
margin: 0 !important;
|
||
padding: 0 !important;
|
||
box-sizing: border-box !important;
|
||
background: #fff !important;
|
||
color: #111827 !important;
|
||
-webkit-print-color-adjust: exact !important;
|
||
print-color-adjust: exact !important;
|
||
}
|
||
#asm-project-reports-root .reports-print-chrome-only {
|
||
display: none !important;
|
||
}
|
||
${QU}
|
||
${eB}
|
||
/*
|
||
* REPORT_PRINT_LAYOUT_CSS sets overflow:hidden on chart cards — fine on screen;
|
||
* in print it can clip Recharts surfaces (blank plot area with legend still visible).
|
||
*/
|
||
#asm-project-reports-root .reports-chart-grid > * {
|
||
overflow: visible !important;
|
||
}
|
||
/* Compact “Report project” banner — saves vertical space for single-page print. */
|
||
#asm-project-reports-root .reports-selected-project-banner {
|
||
padding: 3px 8px !important;
|
||
margin-bottom: 6px !important;
|
||
border-radius: 6px !important;
|
||
}
|
||
#asm-project-reports-root .reports-selected-project-banner p:nth-child(1) {
|
||
font-size: 7px !important;
|
||
letter-spacing: 0.06em !important;
|
||
margin: 0 !important;
|
||
line-height: 1.05 !important;
|
||
}
|
||
#asm-project-reports-root .reports-selected-project-banner p:nth-child(2) {
|
||
font-size: 13px !important;
|
||
margin: 2px 0 0 !important;
|
||
line-height: 1.15 !important;
|
||
}
|
||
#asm-project-reports-root .reports-selected-project-banner p:nth-child(3) {
|
||
font-size: 8px !important;
|
||
margin: 1px 0 0 !important;
|
||
line-height: 1.1 !important;
|
||
}
|
||
/* Avoid a tall empty “loading” box in print when updates are still fetching. */
|
||
#asm-project-reports-root .reports-snapshot-updates-loading {
|
||
height: auto !important;
|
||
min-height: 0 !important;
|
||
padding: 4px 0 !important;
|
||
}
|
||
}
|
||
${dNe}
|
||
`;function mNe(e){const r=e;return`
|
||
html { width: ${r}px !important; min-width: ${r}px !important; background: #fff !important; }
|
||
body { width: ${r}px !important; min-width: ${r}px !important; overflow: visible !important; margin: 0 !important; background: #fff !important; }
|
||
#asm-project-reports-root {
|
||
min-width: ${r}px !important;
|
||
width: ${r}px !important;
|
||
max-width: ${r}px !important;
|
||
overflow: visible !important;
|
||
box-sizing: border-box !important;
|
||
}
|
||
#asm-project-reports-root .reports-export-strip-hidden { display: none !important; }
|
||
${QU}
|
||
${eB}
|
||
#asm-project-reports-root.reports-png-export-active .reports-snapshot-split {
|
||
grid-template-columns: minmax(0, 1.34fr) minmax(0, 0.66fr) !important;
|
||
gap: 14px !important;
|
||
}
|
||
#asm-project-reports-root.reports-png-export-active .reports-project-snapshot .reports-snapshot-body {
|
||
padding: 12px 14px !important;
|
||
gap: 12px !important;
|
||
}
|
||
#asm-project-reports-root.reports-png-export-active .reports-project-snapshot .reports-snapshot-overview-inner {
|
||
padding: 12px 14px !important;
|
||
gap: 12px !important;
|
||
}
|
||
#asm-project-reports-root.reports-png-export-active .reports-project-snapshot .reports-snapshot-overview-meta .flex.flex-wrap {
|
||
gap: 6px 14px !important;
|
||
row-gap: 6px !important;
|
||
}
|
||
#asm-project-reports-root.reports-png-export-active .reports-project-snapshot .reports-snapshot-charts-four {
|
||
display: grid !important;
|
||
grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
|
||
gap: 12px !important;
|
||
}
|
||
#asm-project-reports-root.reports-png-export-active .reports-project-snapshot .reports-snapshot-budget-metrics {
|
||
padding: 4px 0 !important;
|
||
line-height: 1.45 !important;
|
||
}
|
||
#asm-project-reports-root.reports-png-export-active .reports-project-snapshot .reports-snapshot-invoice-chart {
|
||
min-height: 140px !important;
|
||
height: 140px !important;
|
||
overflow: hidden !important;
|
||
max-width: 100% !important;
|
||
}
|
||
#asm-project-reports-root.reports-png-export-active .reports-project-snapshot .reports-snapshot-overall-card {
|
||
padding: 11px 12px !important;
|
||
}
|
||
#asm-project-reports-root.reports-png-export-active .reports-project-snapshot .reports-snapshot-donut-inner {
|
||
width: 132px !important;
|
||
height: 132px !important;
|
||
}
|
||
#asm-project-reports-root.reports-png-export-active .reports-project-snapshot .reports-snapshot-donut-legend {
|
||
margin-top: 8px !important;
|
||
padding: 4px 4px 10px !important;
|
||
gap: 6px 12px !important;
|
||
}
|
||
#asm-project-reports-root.reports-png-export-active .reports-project-snapshot .reports-snapshot-donut-legend li {
|
||
line-height: 1.45 !important;
|
||
}
|
||
#asm-project-reports-root.reports-png-export-active .reports-project-snapshot .reports-snapshot-legend-label {
|
||
max-width: 10rem !important;
|
||
white-space: normal !important;
|
||
overflow: visible !important;
|
||
text-overflow: clip !important;
|
||
line-height: 1.35 !important;
|
||
}
|
||
#asm-project-reports-root.reports-png-export-active .reports-project-snapshot .reports-snapshot-table-scroll {
|
||
max-height: 10.5rem !important;
|
||
}
|
||
#asm-project-reports-root.reports-png-export-active .reports-project-snapshot table th,
|
||
#asm-project-reports-root.reports-png-export-active .reports-project-snapshot table td {
|
||
padding-left: 7px !important;
|
||
padding-right: 7px !important;
|
||
}
|
||
`}const hNe=`
|
||
@media screen {
|
||
#asm-project-reports-root .reports-selected-project-banner {
|
||
display: none !important;
|
||
}
|
||
}
|
||
`,pNe=`
|
||
@media screen {
|
||
#asm-project-reports-root .reports-dashboard-scroll-body {
|
||
max-height: min(11rem, 32vh);
|
||
overflow: auto;
|
||
overscroll-behavior: contain;
|
||
}
|
||
}
|
||
@media print {
|
||
#asm-project-reports-root .reports-dashboard-scroll-body {
|
||
max-height: 11rem !important;
|
||
overflow: auto !important;
|
||
}
|
||
}
|
||
`,gNe=`
|
||
@media screen {
|
||
/* Clip card chrome only — do not set overflow on .recharts-* or charts can measure 0×0 and render blank */
|
||
#asm-project-reports-root .reports-chart-grid > * {
|
||
overflow: hidden !important;
|
||
}
|
||
}
|
||
`,fNe=`
|
||
@media screen and (orientation: landscape) and (min-width: 1024px) {
|
||
#asm-project-reports-root .reports-chart-grid {
|
||
width: 100% !important;
|
||
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
|
||
justify-items: stretch !important;
|
||
}
|
||
#asm-project-reports-root .reports-chart-grid > * {
|
||
min-width: 0 !important;
|
||
}
|
||
#asm-project-reports-root .reports-chart-plot-shell {
|
||
display: block !important;
|
||
width: 100% !important;
|
||
max-width: 100% !important;
|
||
min-width: 0 !important;
|
||
box-sizing: border-box !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-invoice-chart {
|
||
display: block !important;
|
||
width: 100% !important;
|
||
max-width: 100% !important;
|
||
min-width: 0 !important;
|
||
box-sizing: border-box !important;
|
||
}
|
||
#asm-project-reports-root .reports-chart-plot-shell > .recharts-responsive-container,
|
||
#asm-project-reports-root .reports-snapshot-invoice-chart > .recharts-responsive-container {
|
||
width: 100% !important;
|
||
min-width: 0 !important;
|
||
}
|
||
#asm-project-reports-root .reports-project-snapshot .reports-snapshot-weekly-chart {
|
||
min-height: 12rem !important;
|
||
height: 100% !important;
|
||
flex: 1 1 auto !important;
|
||
}
|
||
}
|
||
`,xNe=1,rN=500,yNe=200;function bNe(){return J(this,null,function*(){const e=[];let r=0;for(let a=0;a<yNe;a++){const n=(yield Dr.getTasks({limit_start:r,limit_page_length:rN,order_by:"modified desc"})).data||[];if(e.push(...n),n.length<rN)break;r+=rN}return e})}function FD(e){return e.toISOString().slice(0,10)}function ID(e){const r=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return`${r}-${a}-${s}`}function yx(e){const r=new Date(e);return r.setHours(0,0,0,0),r}function vNe(e){return e.reduce((r,a)=>r+a.value,0)}function zD(e){return e.status!=="Completed"&&e.status!=="Cancelled"}function wNe(e){const r=String(e!=null?e:"").trim().toLowerCase();return r==="yes"||r==="y"||r==="1"||r==="true"}function jNe(e){const r=e.trim();if(!r)return"";const a=r.toLowerCase();for(const s of M4)if(s.toLowerCase()===a)return s;return r}function _Ne(e){const r=(e||"").trim().toLowerCase();return r?r==="urgent"||r==="high"||/\burgent\b/.test(r)||/\bhigh\b/.test(r)?"High":r==="medium"||/\bmedium\b/.test(r)?"Medium":(r==="low"||/\blow\b/.test(r),"Low"):"Low"}function kNe(e,r){var s;const a=new Map;for(const n of e){const i=r(n)||"Unknown";a.set(i,((s=a.get(i))!=null?s:0)+1)}return[...a.entries()].map(([n,i])=>({name:n,value:i})).sort((n,i)=>i.value-n.value)}function $D(e,r){const a=yx(r).getTime()-yx(e).getTime();return Math.floor(a/(1440*60*1e3))}function L4(e){if(!e)return null;const r=new Date(e);return Number.isNaN(r.getTime())?null:yx(r)}function NNe(e,r){const a=L4(e||void 0),s=L4(r||void 0);if(!a||!s)return{durationDays:0,elapsedDays:0,pctElapsed:0};const n=Math.max(1,$D(a,s)),i=yx(new Date),o=s<i?s:i,l=o<a?0:$D(a,o),c=Math.min(100,Math.round(l/n*100));return{durationDays:n,elapsedDays:l,pctElapsed:c}}function aN(e){const r=L4(e||void 0);if(!r)return"—";const a=String(r.getDate()).padStart(2,"0"),s=String(r.getMonth()+1).padStart(2,"0"),n=r.getFullYear();return`${a}/${s}/${n}`}function SNe(e){const r=e.toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"2-digit"}).replace(/,/g,"").trim().split(/\s+/);return r.length>=3?`${r[0]}-${r[1]}-${r[2]}`:e.toLocaleDateString("en-GB")}const UD="(orientation: landscape) and (min-width: 1024px)";function CNe(){return p.useSyncExternalStore(e=>{if(typeof window=="undefined")return()=>{};const r=window.matchMedia(UD),a=()=>e();return r.addEventListener("change",a),window.addEventListener("resize",a),()=>{r.removeEventListener("change",a),window.removeEventListener("resize",a)}},()=>typeof window!="undefined"?window.matchMedia(UD).matches:!1,()=>!1)}function TNe(){const[e,r]=p.useState(!1);return p.useEffect(()=>{const a=()=>{let o=!1;try{o=window.matchMedia("print").matches}catch(l){o=!1}r(o)},s=()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{r(!0)})})},n=()=>r(!1);window.addEventListener("beforeprint",s),window.addEventListener("afterprint",n);let i=null;try{i=window.matchMedia("print"),i.addEventListener("change",a)}catch(o){}return()=>{window.removeEventListener("beforeprint",s),window.removeEventListener("afterprint",n),i==null||i.removeEventListener("change",a)}},[]),e}function BD(e,r,a){const[s,n]=p.useState({width:r,height:a});return p.useLayoutEffect(()=>{const i=e.current;if(!i||typeof ResizeObserver=="undefined")return;const o=()=>{const c=i.getBoundingClientRect(),u=Math.floor(c.width),h=Math.floor(c.height);if(u<=0)return;const f=Math.max(96,h);n(y=>y.width===u&&y.height===f?y:{width:u,height:f})};o();const l=new ResizeObserver(o);return l.observe(i),()=>l.disconnect()},[e]),s}const sN=({active:e,payload:r,label:a})=>{var o;if(!e||!(r!=null&&r.length))return null;const s=(o=r[0])==null?void 0:o.payload,n=s==null?void 0:s.docname,i=(s==null?void 0:s.label)!=null?String(s.label):"";return t.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 px-3 py-2 shadow-lg text-xs",children:[t.jsx("div",{className:"font-semibold text-gray-800 dark:text-gray-100 mb-0.5",children:n||i||a}),r.map((l,c)=>t.jsxs("div",{className:"text-gray-600 dark:text-gray-300",children:[l.name,": ",t.jsx("span",{className:"font-mono font-semibold",children:l.value})]},c))]})};function ENe(e){const r=typeof e=="number"?e:Number(e);if(!Number.isFinite(r))return"";const a=Math.abs(r);return a>=1e6?`${(r/1e6).toFixed(a>=1e7?0:1)}M`:a>=1e3?`${Math.round(r/1e3)}k`:`${Math.round(r)}`}const ANe=()=>{var Gt,Ye,kt,Yt,Ae,ke,Be,yt;const{t:e}=sr(),r=CNe(),a=TNe(),s=p.useRef(null),n=p.useRef(null),i=a?216:r?296:272,o=BD(s,220,i),l=BD(n,220,i),c=hr(),[u,h]=_a(),f=(Gt=u.get("project"))!=null?Gt:"",y=p.useMemo(()=>{const Me=new Date,Ke=new Date;return Ke.setDate(Ke.getDate()-cNe),{from:FD(Ke),to:FD(Me)}},[]),[b,w]=p.useState(!0),[v,k]=p.useState(""),[S,N]=p.useState([]),[C,O]=p.useState([]),[T,P]=p.useState(""),[E,R]=p.useState([]),[z,G]=p.useState(!1),[ae,ee]=p.useState([]),[ne,te]=p.useState(!1),[Y,q]=p.useState(0),[H,U]=p.useState(!1),[re,X]=p.useState(""),V=p.useRef(null),I=p.useRef(null),[B,Q]=p.useState(!1),[ie,me]=p.useState(null),[he,de]=p.useState([]),[xe,ge]=p.useState(!1),be=p.useCallback(()=>J(null,null,function*(){w(!0),k("");try{const Me=yield Promise.allSettled([Dr.getProjectCount({status:"Open"}),Dr.getTaskCount({status:["!=","Completed"]}),Dr.getProjects({filters:{status:"Open"},limit_page_length:2e3,order_by:"modified desc",fields:["name","project_name","status","total_billed_amount","total_sales_amount","estimated_costing","percent_complete","expected_start_date","expected_end_date","department","customer","company","notes"]})]),Xe=((ve,Se)=>Me[ve].status==="fulfilled"?Me[ve].value:Se)(2,{data:[]}),oe=yield bNe();N(oe||[]),O(Xe.data),P(ve=>{var Pe;const Ce=new URLSearchParams(window.location.search).get("project");return Ce&&Xe.data.some(rt=>rt.name===Ce)?Ce:ve&&Xe.data.some(rt=>rt.name===ve)?ve:((Pe=Xe.data[0])==null?void 0:Pe.name)||""});const _e=Me.map((ve,Se)=>ve.status==="rejected"?Se:-1).filter(ve=>ve!==-1);_e.length&&k(`Some data failed to load (sources: ${_e.join(", ")}).`)}catch(Me){const Ke=typeof(Me==null?void 0:Me.message)=="string"?Me.message:"Failed to load dashboard data.";k(Ke),O([]),N([])}finally{w(!1)}}),[y.from,y.to]);p.useEffect(()=>{be()},[be]),p.useEffect(()=>{if(!T){de([]);return}let Me=!1;return ge(!0),Dr.getMergedProjectProgressUpdates(T).then(Ke=>{Me||de(Ke)}).catch(()=>{Me||de([])}).finally(()=>{Me||ge(!1)}),()=>{Me=!0}},[T,Y]);const K=p.useCallback(()=>{q(Me=>Me+1),be()},[be]),ye=p.useCallback(()=>{window.dispatchEvent(new Event("resize")),requestAnimationFrame(()=>{window.print()})},[]),Z=p.useCallback(()=>J(null,null,function*(){const Me=I.current;if(!Me)return;Q(!0);const Ke=window.scrollY,Xe=Me.style.width,oe=Me.style.maxWidth,_e=Me.style.boxSizing;window.scrollTo(0,0),yield new Promise(ve=>{requestAnimationFrame(()=>requestAnimationFrame(()=>ve()))}),yield new Promise(ve=>setTimeout(ve,450));try{Me.classList.add("reports-png-export-active"),Me.style.setProperty("width",`${I0}px`,"important"),Me.style.setProperty("max-width",`${I0}px`,"important"),Me.style.setProperty("box-sizing","border-box","important"),window.dispatchEvent(new Event("resize")),yield new Promise(Xt=>{requestAnimationFrame(()=>requestAnimationFrame(()=>Xt()))}),yield new Promise(Xt=>setTimeout(Xt,200));const ve=(yield Wu(()=>J(null,null,function*(){const{default:Xt}=yield import("./html2canvas.esm-CkdxXkdF.js");return{default:Xt}}),[])).default,Se=Xt=>{const pt=Xt.createElement("style");pt.textContent=mNe(I0),Xt.head.appendChild(pt);const Wt=Xt.getElementById("asm-project-reports-root");if(Wt){const rr=Wt;rr.style.setProperty("overflow","visible","important"),rr.style.setProperty("max-height","none","important")}Xt.documentElement.style.width=`${I0}px`,Xt.body.style.width=`${I0}px`,Xt.querySelectorAll(".print-hidden").forEach(rr=>{var Mr;(Mr=rr.parentNode)==null||Mr.removeChild(rr)}),Xt.querySelectorAll(".reports-selected-project-banner").forEach(rr=>{rr.style.setProperty("display","block","important")}),Xt.querySelectorAll("#asm-project-reports-root *").forEach(rr=>{const Mr=rr;if(Mr.closest(".reports-project-snapshot"))return;const Br=Xt.defaultView;if(Br)try{const Yr=Br.getComputedStyle(Mr).overflowY;(Yr==="auto"||Yr==="scroll")&&(Mr.style.setProperty("overflow","visible","important"),Mr.style.setProperty("max-height","none","important"))}catch(Yr){}})},Ce=I0,Pe=Me.scrollHeight,rt=15800;let ut=Math.min(2.25,Math.max(1,window.devicePixelRatio||1))*xNe;for(;Pe*ut>rt||Ce*ut>rt;)ut*=.88;ut=Math.max(.22,ut);const et=yield ve(Me,{scale:ut,width:Ce,height:Pe,windowWidth:I0,windowHeight:Pe,scrollX:0,scrollY:0,x:0,y:0,useCORS:!0,allowTaint:!0,foreignObjectRendering:!1,logging:!1,backgroundColor:"#ffffff",imageTimeout:2e4,onclone:Se}),nt=yield new Promise(Xt=>{et.toBlob(pt=>Xt(pt),"image/png",.92)});if(!nt)throw new Error("no blob");const ct=URL.createObjectURL(nt),$t=document.createElement("a"),Ut=T?T.replace(/[^a-zA-Z0-9-_]+/g,"_").slice(0,80):"all-projects";$t.href=ct,$t.download=`project-reports-${Ut}-${new Date().toISOString().slice(0,10)}.png`,$t.rel="noopener",document.body.appendChild($t),$t.click(),document.body.removeChild($t),URL.revokeObjectURL(ct)}catch(ve){window.alert("Could not export an image of this page. Use Print and choose “Save as PDF” instead.")}finally{Me.classList.remove("reports-png-export-active"),Me.style.width=Xe,Me.style.maxWidth=oe,Me.style.boxSizing=_e,window.dispatchEvent(new Event("resize")),window.scrollTo(0,Ke),Q(!1)}}),[T]),M=p.useCallback(Me=>{P(Me),h(Ke=>{const Xe=new URLSearchParams(Ke);return Me?Xe.set("project",Me):Xe.delete("project"),Xe},{replace:!0})},[h]);p.useEffect(()=>{C.length&&f&&C.some(Me=>Me.name===f)&&P(Me=>Me===f?Me:f)},[f,C]),p.useEffect(()=>{if(!H)return;const Me=Ke=>{const Xe=V.current;Xe&&!Xe.contains(Ke.target)&&(U(!1),X(""))};return document.addEventListener("mousedown",Me),()=>document.removeEventListener("mousedown",Me)},[H]),p.useEffect(()=>{if(!T){me(null);return}let Me=!1;return Dr.getProject(T).then(Ke=>{Me||me(Ke)}).catch(()=>{Me||me(null)}),()=>{Me=!0}},[T,Y]);const we=p.useMemo(()=>{const Me=re.trim().toLowerCase();return Me?C.filter(Ke=>{const Xe=(Ke.project_name||"").toLowerCase(),oe=(Ke.name||"").toLowerCase();return Xe.includes(Me)||oe.includes(Me)}):C},[C,re]),pe=p.useMemo(()=>T?S.filter(Me=>String(Me.project||"")===T):S,[S,T]);p.useEffect(()=>{if(!T){R([]);return}let Me=!1;return G(!0),Dr.getTasksForProject(T,{limit_page_length:500}).then(Ke=>{Me||R(Ke.data)}).catch(()=>{Me||R([])}).finally(()=>{Me||G(!1)}),()=>{Me=!0}},[T,Y]),p.useEffect(()=>{if(!T){ee([]);return}let Me=!1;te(!0);const Ke=["name","posting_date","grand_total","currency","docstatus","status"];return Promise.all([Io.getSalesOrderNamesForProject(T,1e3).then(Xe=>Xe.length?Pc.getSalesInvoicesBySalesOrders({salesOrders:Xe,limit:1e3,orderBy:"posting_date asc",fields:[...Ke]}):[]),Pc.getSalesInvoicesLinkedToProject({project:T,limit:1e3,orderBy:"posting_date asc",fields:[...Ke]})]).then(([Xe,oe])=>{if(Me)return;const _e=new Map;for(const Se of Xe)Se!=null&&Se.name&&_e.set(Se.name,Se);for(const Se of oe)Se!=null&&Se.name&&_e.set(Se.name,Se);const ve=[..._e.values()].sort((Se,Ce)=>String(Se.posting_date||"").localeCompare(String(Ce.posting_date||"")));ee(ve)}).catch(()=>{Me||ee([])}).finally(()=>{Me||te(!1)}),()=>{Me=!0}},[T,Y]);const le=p.useMemo(()=>C.find(Me=>Me.name===T),[C,T]),Fe=p.useMemo(()=>{if(!T)return null;const Me=le,Ke=ie;return!Me&&!Ke?null:se(se({},Me||{}),Ke||{})},[T,le,ie]),ze=p.useMemo(()=>NNe(Fe==null?void 0:Fe.expected_start_date,Fe==null?void 0:Fe.expected_end_date),[Fe==null?void 0:Fe.expected_start_date,Fe==null?void 0:Fe.expected_end_date]),Re=p.useMemo(()=>SNe(new Date),[Y]),De=p.useMemo(()=>{var Xe,oe;const Me=le;if(!Me)return 0;const Ke=Number((oe=(Xe=Me.estimated_costing)!=null?Xe:Me.total_sales_amount)!=null?oe:0);return Number.isFinite(Ke)?Ke:0},[le]),Et=p.useMemo(()=>{var Xe;const Me=le;if(!Me)return 0;const Ke=Number((Xe=Me.total_billed_amount)!=null?Xe:0);return Number.isFinite(Ke)?Ke:0},[le]),jt=Math.max(0,De-Et),Ie=De>0?Math.min(100,Math.round(Et/De*100)):0,$e=p.useMemo(()=>De?(ae||[]).filter(Ke=>{var Xe;return((Xe=Ke.docstatus)!=null?Xe:0)!==2}).slice(0,12).map((Ke,Xe)=>{var ve;const oe=Math.max(0,Number((ve=Ke.grand_total)!=null?ve:0)||0),_e=Math.max(0,De-oe);return{name:`INVOICE ${Xe+1}`,key:Ke.name,docname:Ke.name,spent:oe,remaining:_e}}):[],[ae,De]),Qe=yx(new Date),at=new Date(Qe);at.setDate(at.getDate()-7);const Ct=ID(Qe),vt=ID(at),er=p.useMemo(()=>kNe(E,Me=>Me.status||"Unknown"),[E]),nr=p.useMemo(()=>vNe(er),[er]),dt=p.useMemo(()=>E.filter(Me=>{if(Me.status==="Completed"||Me.status==="Cancelled")return!1;const Ke=Me.exp_end_date?String(Me.exp_end_date).slice(0,10):"";return Ke?Ke>=vt&&Ke<Ct:!1}).slice(0,12),[E,vt,Ct]),He=p.useMemo(()=>E.filter(Me=>{if(Me.status==="Completed"||Me.status==="Cancelled")return!1;const Ke=Me.exp_end_date?String(Me.exp_end_date).slice(0,10):"";return Ke&&Ke>=Ct}).sort((Me,Ke)=>(Me.exp_end_date||"").localeCompare(Ke.exp_end_date||"")).slice(0,12),[E,Ct]),it=p.useMemo(()=>{const Me=pe.filter(zD).filter(_e=>wNe(_e.custom_risk));let Ke=0,Xe=0,oe=0;for(const _e of Me){const ve=_Ne(_e.priority);ve==="High"?Ke+=1:ve==="Medium"?Xe+=1:oe+=1}return[{name:"High",count:Ke,fill:"#ef4444"},{name:"Medium",count:Xe,fill:"#14b8a6"},{name:"Low",count:oe,fill:"#22c55e"}]},[pe]),Ue=p.useMemo(()=>{var Xe;const Me=pe.filter(zD),Ke=new Map;for(const oe of M4)Ke.set(oe,0);for(const oe of Me){const _e=jNe(String(oe.custom_action||""));!_e||!Ke.has(_e)||Ke.set(_e,((Xe=Ke.get(_e))!=null?Xe:0)+1)}return M4.map(oe=>{var _e;return{name:oe.length>11?`${oe.slice(0,8)}…`:oe,fullLabel:oe,KPI:(_e=Ke.get(oe))!=null?_e:0}})},[pe]),Ve=p.useMemo(()=>it.reduce((Me,Ke)=>Math.max(Me,Number(Ke.count)||0),0),[it]),lt=p.useMemo(()=>Math.max(5,Ve),[Ve]),st=p.useMemo(()=>Ue.reduce((Me,Ke)=>Math.max(Me,Number(Ke.KPI)||0),0),[Ue]),Mt=p.useMemo(()=>Math.max(5,st),[st]),Ot=p.useMemo(()=>E.filter(Me=>String(Me.custom_task_obstacle||"").trim()).sort((Me,Ke)=>String(Me.exp_end_date||"").localeCompare(String(Ke.exp_end_date||""))).slice(0,40),[E]),Pt=Me=>{try{if(Me._assign){const Ke=JSON.parse(Me._assign);if(Array.isArray(Ke)&&Ke[0])return String(Ke[0])}}catch(Ke){}return Me.owner||"—"},zt="reports-chart-plot-shell reports-snapshot-weekly-chart w-full min-w-0 flex-1 h-full min-h-[10rem]",Tt=a?!1:"auto";return t.jsxs(t.Fragment,{children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:uNe}}),t.jsx("style",{dangerouslySetInnerHTML:{__html:XU}}),t.jsx("style",{dangerouslySetInnerHTML:{__html:gNe}}),t.jsx("style",{dangerouslySetInnerHTML:{__html:fNe}}),t.jsx("style",{dangerouslySetInnerHTML:{__html:hNe}}),t.jsx("style",{dangerouslySetInnerHTML:{__html:pNe}}),t.jsxs("div",{ref:I,id:"asm-project-reports-root",className:"reports-print-root p-6 min-h-screen bg-gray-50 dark:bg-gray-900",children:[t.jsxs("div",{className:"reports-print-chrome-only flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("button",{type:"button",onClick:()=>c("/projects"),className:"mt-1 p-2 rounded-lg text-gray-500 hover:text-gray-800 dark:hover:text-gray-200 border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800",children:t.jsx(ia,{size:14})}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-11 h-11 rounded-xl bg-gradient-to-br from-teal-500 to-cyan-600 flex items-center justify-center shadow-md",children:t.jsx(gE,{className:"text-white text-lg"})}),t.jsx("div",{children:t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:e("projects.reportsDashboardTitle","Project reports")})})]})]}),t.jsxs("div",{className:"reports-export-strip-hidden print:hidden flex flex-wrap items-center justify-end gap-2",children:[t.jsxs("button",{type:"button",onClick:ye,className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-semibold text-white bg-violet-600 hover:bg-violet-700 shadow-sm border border-violet-700/30",children:[t.jsx(yl,{size:13}),"Print"]}),t.jsxs("button",{type:"button",onClick:Z,disabled:B||b,className:"!hidden inline-flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-semibold text-white bg-emerald-600 hover:bg-emerald-700 shadow-sm border border-emerald-700/30 disabled:opacity-50 disabled:pointer-events-none",children:[B?t.jsx(tr,{className:"animate-spin",size:13}):t.jsx(Sa,{size:13}),"Export"]}),t.jsx("button",{type:"button",onClick:K,disabled:b,title:e("common.refresh","Refresh"),"aria-label":e("common.refresh","Refresh"),className:"inline-flex items-center justify-center p-2.5 rounded-lg bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-600 text-gray-700 dark:text-gray-200 hover:border-teal-400 hover:text-teal-700 shadow-sm disabled:opacity-50",children:t.jsx(Ma,{size:14,className:b?"animate-spin":""})})]})]}),v&&t.jsx("div",{className:"mb-6 rounded-xl border border-rose-200 dark:border-rose-800 bg-rose-50/80 dark:bg-rose-950/30 px-4 py-3 text-sm text-rose-900 dark:text-rose-100",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"font-semibold",children:"Reports couldn’t load completely"}),t.jsx("p",{className:"text-xs opacity-80 break-words",children:v})]}),t.jsxs("button",{type:"button",onClick:K,className:"shrink-0 inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-white/90 dark:bg-gray-800/70 border border-rose-200 dark:border-rose-700 text-xs font-semibold hover:shadow",children:[t.jsx(Ma,{size:11,className:b?"animate-spin":""}),"Retry"]})]})}),t.jsxs("div",{className:"dashboard-report-project-scope mb-6 rounded-2xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-md px-4 py-3 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs font-bold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:e("projects.reportProjectFilter","Report project")}),t.jsx("p",{className:"text-[11px] text-gray-500 dark:text-gray-400 mt-0.5",children:e("projects.reportProjectFilterHint","Selection applies to charts, KPIs, and tasks. Project snapshot and project updates appear only when a project is selected.")})]}),t.jsxs("div",{ref:V,className:"relative w-full sm:w-[min(28rem,100%)] shrink-0",children:[t.jsx("label",{htmlFor:"report-project-search-global",className:"text-[11px] font-medium text-gray-600 dark:text-gray-300 sr-only",children:e("projects.reportProjectFilter","Report project")}),t.jsxs("button",{type:"button",onClick:()=>{U(Me=>!Me),H||X("")},className:"w-full flex items-center justify-between gap-2 text-left text-sm rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-900/50 text-gray-900 dark:text-white px-3 py-2.5 hover:border-teal-400 focus:outline-none focus:ring-2 focus:ring-teal-400/40",children:[t.jsx("span",{className:"truncate",children:T?((Ye=C.find(Me=>Me.name===T))==null?void 0:Ye.project_name)||T:e("projects.selectProjectPlaceholder","Select project…")}),t.jsx(Fr,{size:12,className:`shrink-0 opacity-70 transition-transform ${H?"rotate-180":""}`})]}),H&&t.jsxs("div",{className:"absolute right-0 z-[70] mt-1 w-full min-w-[16rem] max-h-[min(24rem,70vh)] flex flex-col rounded-lg border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 shadow-xl overflow-hidden",children:[t.jsxs("div",{className:"flex items-center gap-2 px-2 py-2 border-b border-gray-100 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx(za,{className:"text-gray-400 shrink-0 text-xs"}),t.jsx("input",{id:"report-project-search-global",type:"search",value:re,onChange:Me=>X(Me.target.value),placeholder:e("projects.searchProjectPlaceholder","Search by name or ID…"),autoComplete:"off",className:"flex-1 min-w-0 bg-transparent text-sm text-gray-900 dark:text-white placeholder:text-gray-400 focus:outline-none"})]}),t.jsxs("ul",{className:"overflow-y-auto max-h-[min(20rem,60vh)] py-1 text-sm",children:[t.jsx("li",{children:t.jsx("button",{type:"button",className:"w-full text-left px-3 py-2 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700",onClick:()=>{M(""),U(!1),X("")},children:e("projects.clearProjectSelection","Clear selection")})}),we.length===0?t.jsx("li",{className:"px-3 py-4 text-center text-gray-400 text-xs",children:e("projects.noMatchingOpenProjects","No matching open projects.")}):we.map(Me=>t.jsx("li",{children:t.jsxs("button",{type:"button",className:`w-full text-left px-3 py-2 hover:bg-gray-100 dark:hover:bg-gray-700 ${Me.name===T?"bg-teal-50 dark:bg-teal-900/30 text-teal-800 dark:text-teal-200 font-medium":"text-gray-800 dark:text-gray-200"}`,onClick:()=>{M(Me.name),U(!1),X("")},children:[t.jsx("span",{className:"block truncate",children:Me.project_name||Me.name}),t.jsx("span",{className:"block text-[10px] text-gray-400 font-mono truncate",children:Me.name})]})},Me.name))]}),C.length>=2e3&&t.jsx("p",{className:"px-3 py-1.5 text-[10px] text-gray-500 border-t border-gray-100 dark:border-gray-700 bg-gray-50/80 dark:bg-gray-900/30",children:e("projects.projectPickerLimitNote","Showing up to 2,000 most recently modified open projects. Refine search to find one.")})]})]})]}),T&&t.jsxs("div",{className:"reports-selected-project-banner mb-5 rounded-xl border border-teal-200 bg-teal-50/95 px-4 py-3 text-center shadow-sm dark:border-teal-800 dark:bg-teal-950/50",children:[t.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-teal-700 dark:text-teal-300",children:e("projects.reportProjectFilter","Report project")}),t.jsx("p",{className:"mt-1 text-lg sm:text-xl font-semibold text-gray-900 dark:text-white",children:((kt=C.find(Me=>Me.name===T))==null?void 0:kt.project_name)||T}),t.jsx("p",{className:"mt-0.5 text-[11px] text-gray-500 dark:text-gray-400 font-mono tabular-nums",children:T})]}),T?t.jsx(t.Fragment,{children:t.jsxs("div",{className:"reports-project-snapshot bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 shadow-sm overflow-x-auto overflow-y-visible mb-3",children:[t.jsx("div",{className:"flex flex-col gap-0.5 px-2 py-1 bg-gradient-to-r from-teal-600 to-emerald-700 text-white",children:t.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[t.jsx(gp,{size:12,className:"shrink-0 opacity-95"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"text-[10px] font-bold leading-tight",children:"Project snapshot"}),t.jsxs("p",{className:"text-[9px] text-white/85 leading-snug line-clamp-2",children:[t.jsx("span",{className:"text-white/90",children:"Using "}),t.jsx("span",{className:"font-semibold text-white",children:((Yt=C.find(Me=>Me.name===T))==null?void 0:Yt.project_name)||T}),t.jsx("span",{className:"text-white/90",children:" from the report filter."})]})]})]})}),t.jsxs("div",{className:"reports-snapshot-body p-1.5 flex flex-col gap-2.5",children:[T&&Fe&&t.jsxs("div",{className:"rounded-md border border-gray-200 dark:border-gray-600 overflow-hidden shadow-sm bg-white dark:bg-gray-800",children:[t.jsx("div",{className:"bg-gradient-to-r from-slate-800 to-blue-900 text-white text-center py-0.5 px-2",children:t.jsx("h2",{className:"text-[9px] font-bold tracking-wide leading-none",children:e("projects.projectOverviewBanner","Project Overview")})}),t.jsxs("div",{className:"reports-snapshot-overview-inner p-1.5 grid grid-cols-1 md:grid-cols-12 gap-1.5 items-start",children:[t.jsxs("div",{className:"reports-snapshot-overview-meta md:col-span-5 min-w-0 text-[10px] text-gray-800 dark:text-gray-200 leading-snug space-y-0.5 self-start",children:[t.jsxs("p",{className:"font-semibold line-clamp-2",children:[t.jsx("span",{className:"font-bold",children:e("projects.overviewProjectNameLabel","Project Name :")})," ",Fe.project_name||Fe.name]}),t.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-0 text-[10px]",children:[t.jsxs("span",{children:[t.jsx("span",{className:"font-bold",children:e("projects.overviewDepartmentLabel","Department:")})," ",Fe.department?String(Fe.department):"—"]}),t.jsxs("span",{children:[t.jsx("span",{className:"font-bold",children:e("projects.overviewDateLabel","DATE:")})," ",Re]}),t.jsxs("span",{children:[t.jsx("span",{className:"font-bold",children:e("projects.overviewProgressLabel","Progress:")})," ",nr>0&&(Ae=Fe.percent_complete)!=null?Ae:0,"%"]}),t.jsxs("span",{children:[t.jsx("span",{className:"font-bold",children:e("projects.overviewCustomerLabel","Customer:")})," ",Fe.customer||"—"]})]})]}),t.jsxs("div",{className:"reports-snapshot-overview-timeline md:col-span-4 min-w-0 md:border-l md:border-gray-200 dark:md:border-gray-600 md:pl-2 space-y-1 self-start",children:[t.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[t.jsx("span",{className:"text-[9px] font-semibold underline decoration-gray-400 shrink-0 w-[5.75rem]",children:e("projects.overviewDatesUpToday","Dates up today")}),t.jsxs("div",{className:"flex-1 flex items-center gap-1.5 min-w-0",children:[t.jsx("div",{className:"h-2 flex-1 bg-gray-100 dark:bg-gray-700 rounded-full overflow-hidden min-w-0",children:t.jsx("div",{className:"h-full bg-blue-600 dark:bg-blue-500 rounded-full transition-all",style:{width:`${ze.durationDays?ze.pctElapsed:0}%`}})}),t.jsx("span",{className:"text-[9px] font-mono tabular-nums font-semibold text-gray-800 dark:text-gray-100 shrink-0",children:ze.durationDays?ze.elapsedDays:"—"})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[t.jsx("span",{className:"text-[9px] font-semibold underline decoration-gray-400 shrink-0 w-[5.75rem]",children:e("projects.overviewProjectDuration","Project Duration")}),t.jsxs("div",{className:"flex-1 flex items-center gap-1.5 min-w-0",children:[t.jsx("div",{className:"h-2 flex-1 bg-gray-100 dark:bg-gray-700 rounded-full overflow-hidden min-w-0",children:t.jsx("div",{className:"h-full bg-blue-600 dark:bg-blue-500 rounded-full w-full"})}),t.jsx("span",{className:"text-[9px] font-mono tabular-nums font-semibold text-gray-800 dark:text-gray-100 shrink-0",children:ze.durationDays||"—"})]})]})]}),t.jsxs("div",{className:"reports-snapshot-overview-dates md:col-span-3 flex flex-col gap-1.5 self-start items-start md:items-end",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-[9px] font-semibold text-gray-600 dark:text-gray-300 whitespace-nowrap",children:e("projects.overviewStartDateLabel","Start:")}),t.jsx("span",{className:"inline-flex rounded bg-teal-700 dark:bg-teal-800 text-white text-[10px] font-medium px-1.5 py-0.5 tabular-nums",children:aN(Fe.expected_start_date)})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-[9px] font-semibold text-gray-600 dark:text-gray-300 whitespace-nowrap",children:e("projects.overviewEndDateLabel","End:")}),t.jsx("span",{className:"inline-flex rounded bg-teal-700 dark:bg-teal-800 text-white text-[10px] font-medium px-1.5 py-0.5 tabular-nums",children:aN(Fe.expected_end_date)})]})]})]})]}),t.jsxs("div",{className:"reports-snapshot-charts-section rounded-md border border-gray-200 dark:border-gray-600 overflow-x-auto shadow-sm bg-white dark:bg-gray-800",children:[t.jsx("div",{className:"bg-gradient-to-r from-slate-800 via-slate-800 to-blue-900 text-white text-center py-1.5 px-2",children:t.jsx("h2",{className:"text-[9px] font-bold tracking-wide leading-none",children:e("projects.weeklyProjectStatus","Weekly Project status")})}),t.jsxs("div",{className:"reports-snapshot-charts-four grid min-w-0",children:[t.jsxs("div",{className:"reports-snapshot-chart-col flex flex-col min-w-0 min-h-0 max-w-full rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800/90 shadow-sm overflow-hidden",children:[t.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-0.5 bg-gradient-to-r from-teal-600 to-cyan-600 text-white shrink-0",children:[t.jsx(gE,{className:"shrink-0 opacity-95",size:11,"aria-hidden":!0}),t.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wide leading-none",children:e("projects.snapshotProjectBudget","Project budget")})]}),t.jsx("div",{className:"flex flex-1 min-h-0 flex-col gap-1.5 p-1.5 min-w-0",children:le?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"rounded-md border border-gray-200 dark:border-gray-600 p-1.5 bg-white dark:bg-gray-800/90 shadow-sm shrink-0 min-w-0 w-full",children:[t.jsxs("div",{className:"flex items-start justify-between gap-1.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-[9px] font-bold uppercase tracking-wide text-gray-600 dark:text-gray-300",children:"Budget & Billing"}),t.jsx("p",{className:"text-[9px] text-gray-500 dark:text-gray-400 leading-tight mt-0.5 line-clamp-2",children:"Budget = estimated / sales · Used = billed"})]}),t.jsxs("span",{className:"text-[9px] font-mono bg-gray-100 dark:bg-gray-700/80 text-gray-800 dark:text-gray-100 px-1 py-0.5 rounded shrink-0",children:[Ie,"%"]})]}),t.jsxs("p",{className:"reports-snapshot-budget-metrics mt-1.5 text-[9px] leading-snug text-gray-700 dark:text-gray-200 tabular-nums",children:[t.jsx("span",{className:"text-gray-500",children:"Total"})," ",t.jsx("span",{className:"font-semibold text-gray-900 dark:text-white",children:De.toLocaleString()}),t.jsx("span",{className:"mx-1 text-gray-300 dark:text-gray-600",children:"·"}),t.jsx("span",{className:"text-gray-500",children:"Used"})," ",t.jsx("span",{className:"font-semibold text-gray-900 dark:text-white",children:Et.toLocaleString()}),t.jsx("span",{className:"mx-1 text-gray-300 dark:text-gray-600",children:"·"}),t.jsx("span",{className:"text-gray-500",children:"Balance"})," ",t.jsx("span",{className:"font-semibold text-gray-900 dark:text-white",children:jt.toLocaleString()})]}),t.jsxs("div",{className:"mt-1",children:[t.jsx("div",{className:"h-1 w-full bg-gray-100 dark:bg-gray-700/50 rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-gradient-to-r from-teal-500 to-emerald-600 rounded-full transition-all",style:{width:`${Ie}%`}})}),t.jsxs("div",{className:"mt-0.5 flex items-center justify-between text-[8px] text-gray-500 leading-none",children:[t.jsx("span",{children:"0"}),t.jsx("span",{children:De.toLocaleString()})]})]})]}),t.jsxs("div",{className:"rounded-md border border-gray-200 dark:border-gray-600 p-1.5 flex flex-col min-w-0 min-h-0 flex-1 bg-white dark:bg-gray-800/90 shadow-sm",children:[t.jsx("p",{className:"text-[9px] font-bold uppercase tracking-wide text-gray-600 dark:text-gray-300 leading-none shrink-0",children:"Budget (by invoice)"}),t.jsx("p",{className:"text-[8px] text-gray-500 dark:text-gray-400 mb-0.5 mt-0.5 leading-tight line-clamp-1 shrink-0",children:"Linked via SO lines or Project · stacked per invoice"}),t.jsx("div",{className:`reports-snapshot-invoice-chart mx-auto w-[calc(100%-8px)] max-w-full rounded border border-gray-200 dark:border-gray-600 bg-white/70 dark:bg-gray-800/60 ${r?"min-h-[9.75rem] h-[9.75rem]":"min-h-[9.25rem] h-[9.25rem]"}`,children:ne?t.jsx("div",{className:"h-full flex items-center justify-center text-gray-400",children:t.jsx(tr,{className:"animate-spin text-sm"})}):$e.length===0?t.jsx("div",{className:"h-full flex items-center justify-center text-[10px] text-gray-400 text-center px-1",children:"No linked Sales Invoices."}):t.jsx(Pb,{width:"100%",height:"100%",minHeight:112,debounce:a?0:32,children:t.jsxs(tN,{data:$e,margin:a?{top:4,right:6,left:2,bottom:18}:{top:6,right:8,left:4,bottom:20},barCategoryGap:"16%",children:[t.jsx(gv,{strokeDasharray:"3 3",className:"stroke-gray-200 dark:stroke-gray-600"}),t.jsx(fv,{dataKey:"name",tick:{fontSize:7},interval:0,angle:0,textAnchor:"middle",height:18,tickMargin:0,padding:{left:10,right:10}}),t.jsx(xv,{tick:{fontSize:7},width:a?26:r?28:30,tickMargin:2,tickFormatter:ENe}),t.jsx($b,{content:t.jsx(sN,{})}),t.jsx(Tf,{dataKey:"spent",name:"Spent",stackId:"b",fill:"#2563eb",radius:[1,1,0,0],maxBarSize:a?14:r?13:12,isAnimationActive:Tt}),t.jsx(Tf,{dataKey:"remaining",name:"Rem.",stackId:"b",fill:"#14b8a6",radius:[1,1,0,0],maxBarSize:a?14:r?13:12,isAnimationActive:Tt})]})},`inv-${r}-${a}`)}),$e.length>0&&t.jsxs("p",{className:"mt-0.5 text-[7px] text-gray-500 text-center leading-tight",children:[t.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-sm bg-[#2563eb] align-middle mr-0.5","aria-hidden":!0}),"Spent",t.jsx("span",{className:"mx-1.5 text-gray-400",children:"·"}),t.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-sm bg-[#14b8a6] align-middle mr-0.5","aria-hidden":!0}),"Remaining (vs budget)"]}),ae.length>12&&t.jsxs("p",{className:"mt-0.5 text-[8px] text-gray-500",children:["First 12 of ",ae.length," invoices."]})]})]}):t.jsx("div",{className:"flex flex-1 items-center justify-center text-[9px] text-gray-400 border border-dashed rounded-md px-2 text-center py-4",children:"Select a project above."})})]}),t.jsxs("div",{className:"reports-snapshot-chart-col flex flex-col min-w-0 min-h-0 max-w-full rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800/90 shadow-sm overflow-hidden",children:[t.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-0.5 bg-gradient-to-r from-teal-600 to-emerald-700 text-white shrink-0",children:[t.jsx(K9,{className:"shrink-0",size:11,"aria-hidden":!0}),t.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wide leading-none",children:"Tasks status"})]}),t.jsx("div",{className:"flex flex-1 min-h-0 flex-col p-1.5 min-w-0",children:t.jsx("div",{className:"reports-snapshot-overall-card rounded-md border border-gray-200 dark:border-gray-600 bg-white/50 dark:bg-gray-800/40 p-1.5 flex flex-col overflow-hidden min-w-0 min-h-0 flex-1",children:t.jsx("div",{className:"flex flex-1 flex-col min-h-0 gap-2 min-w-0 w-full",children:z?t.jsx("div",{className:"w-full h-16 flex items-center justify-center text-gray-400",children:t.jsx(tr,{className:"animate-spin text-sm"})}):T?er.length===0?t.jsx("div",{className:"w-full min-h-16 flex items-center justify-center text-[9px] text-gray-400 border border-dashed rounded-md",children:"No tasks."}):t.jsxs("div",{className:"flex flex-1 flex-col min-h-0 w-full min-w-0",children:[t.jsx("div",{className:"flex flex-1 min-h-[9rem] w-full items-center justify-center",children:t.jsxs("div",{className:`reports-snapshot-donut-inner relative shrink-0 mx-auto ${r?"h-[140px] w-[140px]":"h-[128px] w-[128px]"}`,children:[t.jsx("div",{className:"absolute inset-0",children:t.jsx(Pb,{width:"100%",height:"100%",debounce:a?0:32,children:t.jsxs(iNe,{margin:{top:0,right:0,bottom:0,left:0},children:[t.jsx(fU,{data:er,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:r?36:30,outerRadius:r?58:48,paddingAngle:.5,label:!1,isAnimationActive:Tt,children:er.map((Me,Ke)=>t.jsx(Lp,{fill:Hb[Ke%Hb.length],stroke:"#fff",strokeWidth:1},Ke))}),t.jsx($b,{content:t.jsx(sN,{})})]})},`donut-${r}-${a}`)}),t.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center pointer-events-none px-1 text-center",children:[t.jsx("span",{className:"text-[6px] font-bold uppercase tracking-wide text-gray-500 dark:text-gray-400 leading-none",children:e("projects.snapshotOverallShort","Overall")}),t.jsxs("span",{className:"text-sm font-bold text-gray-900 dark:text-white tabular-nums leading-tight",children:[nr>0&&(Be=(ke=Fe==null?void 0:Fe.percent_complete)!=null?ke:le==null?void 0:le.percent_complete)!=null?Be:0,"%"]})]})]})}),t.jsx("ul",{className:"reports-snapshot-donut-legend list-none m-0 w-full shrink-0 border-t border-gray-200/90 dark:border-gray-600/80 pt-1.5 pb-0.5 flex flex-wrap justify-center gap-x-1.5 gap-y-1 content-start max-h-[3.5rem] overflow-y-auto",children:er.map((Me,Ke)=>{const Xe=nr?Math.round(Me.value/nr*100):0;return t.jsxs("li",{className:"inline-flex items-center gap-0.5 text-[7px] text-gray-700 dark:text-gray-200 leading-none whitespace-nowrap",children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0 border border-white/80 dark:border-gray-600",style:{backgroundColor:Hb[Ke%Hb.length]},"aria-hidden":!0}),t.jsxs("span",{className:"reports-snapshot-legend-label max-w-[5.5rem] truncate",title:`${Me.name} (${Xe}%)`,children:[Me.name," (",Xe,"%)"]})]},Me.name)})})]}):t.jsx("div",{className:"w-full min-h-16 flex items-center justify-center text-[9px] text-gray-400 border border-dashed rounded-md px-2 text-center",children:"Select a project above."})})})})]}),t.jsx("div",{className:"reports-snapshot-chart-col flex flex-col min-w-0 min-h-0 max-w-full",children:t.jsxs("div",{className:"reports-snapshot-weekly-chart-card rounded-md border border-gray-200 dark:border-gray-600 overflow-x-hidden overflow-y-visible flex flex-col flex-1 min-h-0 w-full min-w-0 max-w-full bg-white dark:bg-gray-800/90 shadow-sm h-full",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-1.5 py-1 bg-gradient-to-r from-amber-500 to-orange-600 text-white shrink-0",children:[t.jsx(Or,{size:11,className:"shrink-0","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-[9px] font-bold leading-none",children:"Risks / Issues"}),t.jsx("p",{className:"text-[8px] text-white/90 line-clamp-2 leading-tight",children:"Open tasks with Risk = Yes, by priority (High includes Urgent)."})]})]}),t.jsx("div",{className:"p-1 pb-2 flex flex-1 flex-col min-h-0 items-stretch w-full min-w-0 max-w-full",children:b?t.jsx("div",{className:"flex min-h-[7rem] flex-1 items-center justify-center text-gray-400",children:t.jsx(tr,{className:"animate-spin text-lg"})}):t.jsx("div",{ref:s,className:zt,children:t.jsx(Pb,{width:o.width,height:o.height,debounce:a?0:32,children:t.jsxs(tN,{data:it,margin:a?{top:14,right:0,left:0,bottom:6}:{top:18,right:0,left:0,bottom:8},barCategoryGap:"6%",children:[t.jsx(gv,{vertical:!1,strokeDasharray:"3 3",className:"stroke-gray-200/90 dark:stroke-gray-600/80"}),t.jsx(fv,{dataKey:"name",tick:{fontSize:8},interval:0,height:22,tickMargin:4,tickLine:!1,axisLine:{stroke:"#d1d5db"},padding:{left:0,right:0}}),t.jsx(xv,{tick:{fontSize:8},width:18,allowDecimals:!1,domain:[0,lt],ticks:lt<=5?[0,1,2,3,4,5]:void 0,tickLine:!1,axisLine:{stroke:"#d1d5db"}}),t.jsx($b,{content:t.jsx(sN,{})}),t.jsx(o4,{verticalAlign:"bottom",align:"center",wrapperStyle:{paddingTop:4,margin:0,width:"100%"},content:()=>t.jsx("div",{className:"flex flex-wrap justify-center gap-x-3 gap-y-1 text-[7px] leading-none text-gray-700 dark:text-gray-200",children:it.map(Me=>t.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[t.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-sm",style:{backgroundColor:Me.fill},"aria-hidden":!0}),Me.name]},Me.name))})}),t.jsxs(Tf,{dataKey:"count",name:"Count",maxBarSize:a?22:r?28:24,radius:[1,1,0,0],isAnimationActive:Tt,children:[it.map(Me=>t.jsx(Lp,{fill:Me.count>0?Me.fill:"transparent",stroke:"none"},Me.name)),t.jsx(_p,{dataKey:"count",content:Me=>{const Ke=Number(Me.x)||0,Xe=Number(Me.y)||0,oe=Number(Me.width)||0,_e=Number(Me.height)||0,ve=Number(Me.value)||0,Se=Ke+oe/2;return ve>0?t.jsx("text",{x:Se,y:Xe-4,textAnchor:"middle",fontSize:9,fontWeight:600,className:"fill-gray-900 dark:fill-gray-100",children:ve}):t.jsx("text",{x:Se,y:Xe+_e+11,textAnchor:"middle",fontSize:8,className:"fill-gray-400 dark:fill-gray-500",children:"0"})}})]})]})},`risk-${r}-${a}-${o.width}-${o.height}`)})})]})}),t.jsx("div",{className:"reports-snapshot-chart-col flex flex-col min-w-0 min-h-0 max-w-full",children:t.jsxs("div",{className:"reports-snapshot-weekly-chart-card rounded-md border border-gray-200 dark:border-gray-600 overflow-x-hidden overflow-y-visible flex flex-col flex-1 min-h-0 w-full min-w-0 max-w-full bg-white dark:bg-gray-800/90 shadow-sm h-full",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-1.5 py-1 bg-gradient-to-r from-sky-600 to-indigo-700 text-white shrink-0",children:[t.jsx(MG,{size:11,className:"shrink-0","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-[9px] font-bold leading-none",children:"Actions"}),t.jsx("p",{className:"text-[8px] text-white/90 line-clamp-2 leading-tight",children:"Open tasks by Action (custom field)."})]})]}),t.jsx("div",{className:"p-1 pb-2 flex flex-1 flex-col min-h-0 items-stretch w-full min-w-0 max-w-full",children:b?t.jsx("div",{className:"flex min-h-[7rem] flex-1 items-center justify-center text-gray-400",children:t.jsx(tr,{className:"animate-spin text-lg"})}):t.jsx("div",{ref:n,className:zt,children:t.jsx(Pb,{width:l.width,height:l.height,debounce:a?0:32,children:t.jsxs(tN,{data:Ue,margin:a?{top:14,right:0,left:0,bottom:28}:{top:18,right:0,left:0,bottom:32},barCategoryGap:"4%",children:[t.jsx(gv,{vertical:!1,strokeDasharray:"3 3",className:"stroke-gray-200/90 dark:stroke-gray-600/80"}),t.jsx(fv,{dataKey:"name",tick:{fontSize:6},interval:0,angle:a?-10:-12,textAnchor:"end",height:a?30:r?32:34,tickMargin:2,tickLine:!1,axisLine:{stroke:"#d1d5db"},padding:{left:0,right:0}}),t.jsx(xv,{tick:{fontSize:8},width:18,allowDecimals:!1,domain:[0,Mt],ticks:Mt<=5?[0,1,2,3,4,5]:void 0,tickLine:!1,axisLine:{stroke:"#d1d5db"}}),t.jsx($b,{content:({payload:Me})=>{var Xe,oe;if(!(Me!=null&&Me.length))return null;const Ke=(Xe=Me[0])==null?void 0:Xe.payload;return t.jsxs("div",{className:"rounded border border-gray-200 bg-white px-2 py-1 text-[10px] shadow dark:bg-gray-800 dark:border-gray-600",children:[t.jsx("div",{className:"font-semibold text-gray-800 dark:text-gray-100",children:Ke.fullLabel}),t.jsxs("div",{className:"text-gray-600 dark:text-gray-300",children:["KPI: ",(oe=Ke.KPI)!=null?oe:0]})]})}}),t.jsx(o4,{verticalAlign:"bottom",align:"center",wrapperStyle:{paddingTop:4,margin:0,width:"100%"},content:()=>t.jsx("div",{className:"flex flex-wrap justify-center gap-x-3 gap-y-1 text-[7px] leading-none text-gray-700 dark:text-gray-200",children:t.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[t.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-sm bg-[#2563eb]","aria-hidden":!0}),"KPI (open tasks)"]})})}),t.jsx(Tf,{dataKey:"KPI",name:"KPI",fill:"#2563eb",maxBarSize:a?18:r?24:20,radius:[1,1,0,0],isAnimationActive:Tt,children:t.jsx(_p,{dataKey:"KPI",content:Me=>{const Ke=Number(Me.x)||0,Xe=Number(Me.y)||0,oe=Number(Me.width)||0,_e=Number(Me.height)||0,ve=Number(Me.value)||0,Se=Ke+oe/2;return ve>0?t.jsx("text",{x:Se,y:Xe-4,textAnchor:"middle",fontSize:9,fontWeight:600,className:"fill-gray-900 dark:fill-gray-100",children:ve}):t.jsx("text",{x:Se,y:Xe+_e+11,textAnchor:"middle",fontSize:8,className:"fill-gray-400 dark:fill-gray-500",children:"0"})}})})]})},`actions-${r}-${a}-${l.width}-${l.height}`)})})]})})]})]}),(Fe||le)&&t.jsxs("div",{className:"reports-snapshot-updates-notes-row grid gap-1.5 min-w-0",children:[t.jsxs("div",{className:"rounded-md border border-violet-500/30 dark:border-violet-600/40 overflow-hidden shadow-sm bg-white dark:bg-gray-800 min-w-0 flex flex-col",children:[t.jsx("div",{className:"bg-gradient-to-r from-violet-600 to-fuchsia-700 text-white px-2 py-0.5 shrink-0",children:t.jsx("h3",{className:"text-[9px] font-bold uppercase tracking-wide leading-none",children:e("projects.snapshotUpdatesColumn","Updates")})}),t.jsx("div",{className:"reports-snapshot-notes-body p-1.5 flex-1 min-h-0 max-h-[min(12rem,36vh)] overflow-y-auto",children:xe?t.jsx("div",{className:"reports-snapshot-updates-loading h-16 flex items-center justify-center text-gray-400",children:t.jsx(tr,{className:"animate-spin text-sm"})}):he.length===0?t.jsx("p",{className:"text-[9px] text-gray-400",children:"No updates for this project."}):t.jsxs("table",{className:"w-full text-[8px] text-left",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-600 text-gray-500 dark:text-gray-400",children:[t.jsx("th",{className:"py-0.5 pr-1 font-semibold",children:"Update"}),t.jsx("th",{className:"py-0.5 px-0.5 font-semibold w-[4.5rem]",children:"Date"}),t.jsx("th",{className:"py-0.5 pl-0.5 font-semibold",children:"Task"})]})}),t.jsx("tbody",{children:he.slice(0,25).map((Me,Ke)=>t.jsxs("tr",{className:"border-t border-gray-100 dark:border-gray-700 align-top",children:[t.jsx("td",{className:"py-0.5 pr-1 text-gray-800 dark:text-gray-200 break-words",children:Me.update_||"—"}),t.jsx("td",{className:"py-0.5 px-0.5 font-mono text-gray-600 dark:text-gray-400 whitespace-nowrap",children:Me.date?aN(String(Me.date).slice(0,10)):"—"}),t.jsx("td",{className:"py-0.5 pl-0.5",children:Me.task?t.jsx("button",{type:"button",onClick:()=>c(`/projects/tasks/${encodeURIComponent(Me.task)}`),className:"text-violet-700 dark:text-violet-300 hover:underline font-mono text-[8px] text-left",children:Me.task}):"—"})]},`${Me.name||"n"}-${Me.task||""}-${Ke}`))})]})})]}),t.jsxs("div",{className:"rounded-md border border-teal-500/35 dark:border-teal-600/45 overflow-hidden shadow-sm bg-white dark:bg-gray-800 min-w-0 flex flex-col",children:[t.jsx("div",{className:"bg-gradient-to-r from-teal-500 to-emerald-600 text-white px-2 py-0.5 shrink-0",children:t.jsx("h3",{className:"text-[9px] font-bold uppercase tracking-wide leading-none",children:e("projects.snapshotNotesColumn","Notes")})}),t.jsx("div",{className:"reports-snapshot-notes-body p-1.5 flex-1 min-h-0 max-h-[min(12rem,36vh)] overflow-y-auto",children:t.jsx("p",{className:"text-[9px] text-gray-700 dark:text-gray-200 whitespace-pre-wrap leading-tight",children:R4((yt=Fe==null?void 0:Fe.notes)!=null?yt:le==null?void 0:le.notes)||"No notes for this project."})})]})]}),t.jsxs("div",{className:"reports-snapshot-bottom-tasks grid grid-cols-1 lg:grid-cols-3 gap-1.5 min-w-0",children:[t.jsxs("div",{className:"min-h-0 shrink-0 min-w-0",children:[t.jsxs("h3",{className:"text-[9px] font-bold uppercase tracking-wide text-gray-600 dark:text-gray-300 mb-0.5 leading-none",children:["Last week Tasks",dt.length>0&&t.jsxs("span",{className:"ml-1 text-[9px] font-mono text-gray-500",children:["(",dt.length,")"]})]}),t.jsx("div",{className:"rounded-md border border-gray-200 dark:border-gray-600 overflow-hidden",children:t.jsx("div",{className:"reports-snapshot-table-scroll",children:t.jsxs("table",{className:"min-w-full text-[9px] table-fixed w-full",children:[t.jsx("thead",{className:"sticky top-0 z-10",children:t.jsxs("tr",{className:"bg-violet-700 text-white text-left",children:[t.jsx("th",{className:"px-1 py-0.5 w-7",children:"N"}),t.jsx("th",{className:"px-1 py-0.5",children:"Task"}),t.jsx("th",{className:"px-1 py-0.5",children:"Assigned"}),t.jsx("th",{className:"px-1 py-0.5 w-[4.5rem]",children:"Action"})]})}),t.jsx("tbody",{children:dt.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:4,className:"px-1.5 py-1 text-gray-400 text-center",children:"None"})}):dt.map((Me,Ke)=>{const Xe=`/projects/tasks/${encodeURIComponent(Me.name)}`;return t.jsxs("tr",{tabIndex:0,role:"link",className:"border-t border-gray-100 dark:border-gray-700 text-rose-700 dark:text-rose-300 cursor-pointer hover:bg-rose-50/80 dark:hover:bg-rose-950/20",onClick:()=>c(Xe),onKeyDown:oe=>{(oe.key==="Enter"||oe.key===" ")&&(oe.preventDefault(),c(Xe))},children:[t.jsx("td",{className:"px-1 py-0.5 font-mono tabular-nums text-gray-600 dark:text-gray-400",children:Ke+1}),t.jsx("td",{className:"px-1.5 py-0.5 truncate",title:Me.subject||Me.name,children:Me.subject||Me.name}),t.jsx("td",{className:"px-1.5 py-0.5 truncate",children:Pt(Me)}),t.jsx("td",{className:"px-1.5 py-0.5 font-medium text-gray-800 dark:text-gray-200 truncate",title:Me.status||"",children:Me.status||"—"})]},Me.name)})})]})})}),dt.length>20&&t.jsxs("p",{className:"mt-0.5 text-[9px] text-gray-500",children:["Scroll to see all ",dt.length," items."]})]}),t.jsxs("div",{className:"min-h-0 shrink-0 min-w-0",children:[t.jsxs("h3",{className:"text-[9px] font-bold uppercase tracking-wide text-gray-600 dark:text-gray-300 mb-0.5 leading-none",children:["Upcoming Tasks",He.length>0&&t.jsxs("span",{className:"ml-1 text-[9px] font-mono text-gray-500",children:["(",He.length,")"]})]}),t.jsx("div",{className:"rounded-md border border-gray-200 dark:border-gray-600 overflow-hidden",children:t.jsx("div",{className:"reports-snapshot-table-scroll",children:t.jsxs("table",{className:"min-w-full text-[9px] table-fixed w-full",children:[t.jsx("thead",{className:"sticky top-0 z-10",children:t.jsxs("tr",{className:"bg-violet-700 text-white text-left",children:[t.jsx("th",{className:"px-1 py-0.5 w-7",children:"N"}),t.jsx("th",{className:"px-1 py-0.5 w-[32%]",children:"Task"}),t.jsx("th",{className:"px-1 py-0.5 w-[22%]",children:"Assigned to"}),t.jsx("th",{className:"px-1 py-0.5 w-[17%]",children:"Start Date"}),t.jsx("th",{className:"px-1 py-0.5 w-[17%]",children:"End Date"})]})}),t.jsx("tbody",{children:He.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,className:"px-1.5 py-1 text-gray-400 text-center",children:"None"})}):He.map((Me,Ke)=>{var oe,_e;const Xe=`/projects/tasks/${encodeURIComponent(Me.name)}`;return t.jsxs("tr",{tabIndex:0,role:"link",className:"border-t border-gray-100 dark:border-gray-700 cursor-pointer hover:bg-slate-100/90 dark:hover:bg-slate-800/60",onClick:()=>c(Xe),onKeyDown:ve=>{(ve.key==="Enter"||ve.key===" ")&&(ve.preventDefault(),c(Xe))},children:[t.jsx("td",{className:"px-1 py-0.5 font-mono tabular-nums text-gray-600 dark:text-gray-400",children:Ke+1}),t.jsx("td",{className:"px-1.5 py-0.5 text-gray-800 dark:text-gray-200 truncate",title:Me.subject||Me.name,children:Me.subject||Me.name}),t.jsx("td",{className:"px-1.5 py-0.5 truncate",children:Pt(Me)}),t.jsx("td",{className:"px-1 py-0.5 font-mono tabular-nums text-gray-600 dark:text-gray-400",children:((oe=Me.exp_start_date)==null?void 0:oe.slice(0,10))||"—"}),t.jsx("td",{className:"px-1 py-0.5 font-mono tabular-nums text-gray-600 dark:text-gray-400",children:((_e=Me.exp_end_date)==null?void 0:_e.slice(0,10))||"—"})]},Me.name)})})]})})})]}),t.jsxs("div",{className:"min-h-0 shrink-0 min-w-0",children:[t.jsxs("h3",{className:"text-[9px] font-bold uppercase tracking-wide text-gray-600 dark:text-gray-300 mb-0.5 leading-none",children:["Obstacles",Ot.length>0&&t.jsxs("span",{className:"ml-1 text-[9px] font-mono text-gray-500",children:["(",Ot.length,")"]})]}),t.jsx("div",{className:"rounded-md border border-gray-200 dark:border-gray-600 overflow-hidden",children:t.jsx("div",{className:"reports-snapshot-table-scroll",children:t.jsxs("table",{className:"min-w-full text-[9px] table-fixed w-full",children:[t.jsx("thead",{className:"sticky top-0 z-10",children:t.jsxs("tr",{className:"bg-violet-700 text-white text-left",children:[t.jsx("th",{className:"px-1 py-0.5 w-7",children:"N"}),t.jsx("th",{className:"px-1 py-0.5",children:"Task"})]})}),t.jsx("tbody",{children:Ot.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:2,className:"px-1.5 py-1 text-gray-400 text-center",children:"None"})}):Ot.map((Me,Ke)=>{const Xe=`/projects/tasks/${encodeURIComponent(Me.name)}`,oe=String(Me.custom_task_obstacle||"").trim();return t.jsxs("tr",{className:"border-t border-gray-100 dark:border-gray-700",children:[t.jsx("td",{className:"px-1 py-0.5 font-mono tabular-nums text-gray-600 dark:text-gray-400 align-top",children:Ke+1}),t.jsxs("td",{className:"px-1.5 py-0.5 align-top text-gray-800 dark:text-gray-200",children:[t.jsx("button",{type:"button",onClick:()=>c(Xe),className:"text-left font-medium text-blue-600 dark:text-blue-400 hover:underline block w-full truncate",title:Me.subject||Me.name,children:Me.subject||Me.name}),oe?t.jsx("p",{className:"text-[8px] text-gray-500 dark:text-gray-400 mt-0.5 whitespace-pre-wrap break-words",children:oe}):null]})]},Me.name)})})]})})})]})]})]})]})}):null]})]})};function iy(e){var r,a,s,n,i,o;return JSON.stringify({filters:(r=e.filters)!=null?r:{},appendFilters:(a=e.appendFilters)!=null?a:[],fields:(s=e.fields)!=null?s:null,limit_start:(n=e.limit_start)!=null?n:0,limit_page_length:(i=e.limit_page_length)!=null?i:20,order_by:(o=e.order_by)!=null?o:""})}const ONe=(e={})=>{const[r,a]=p.useState([]),[s,n]=p.useState(!0),[i,o]=p.useState(null),[l,c]=p.useState(0),u=iy(e),h=p.useRef(0);p.useEffect(()=>{const y=++h.current;let b=!1;return J(null,null,function*(){try{n(!0),o(null);const[w,v]=yield Promise.all([Dr.getProjects(e),Dr.getProjectCount(e.filters)]);if(b||y!==h.current)return;a(w.data),c(v)}catch(w){if(b||y!==h.current)return;o(w instanceof Error?w.message:"Failed to fetch projects")}finally{!b&&y===h.current&&n(!1)}}),()=>{b=!0}},[u]);const f=p.useCallback(()=>J(null,null,function*(){const y=++h.current;try{n(!0),o(null);const[b,w]=yield Promise.all([Dr.getProjects(e),Dr.getProjectCount(e.filters)]);if(y!==h.current)return;a(b.data),c(w)}catch(b){if(y!==h.current)return;o(b instanceof Error?b.message:"Failed to fetch projects")}finally{y===h.current&&n(!1)}}),[u]);return{projects:r,loading:s,error:i,totalCount:l,refetch:f}},PNe=e=>{const[r,a]=p.useState(null),[s,n]=p.useState(!1),[i,o]=p.useState(null),l=p.useCallback(()=>J(null,null,function*(){if(!e){a(null);return}try{n(!0),o(null),a(yield Dr.getProject(e))}catch(c){o(c instanceof Error?c.message:"Failed to fetch project")}finally{n(!1)}}),[e]);return p.useEffect(()=>{l()},[l]),{project:r,loading:s,error:i,refetch:l}},DNe=(e={})=>{const[r,a]=p.useState([]),[s,n]=p.useState(!0),[i,o]=p.useState(null),[l,c]=p.useState(0),u=iy(e),h=p.useRef(0);p.useEffect(()=>{const y=++h.current;let b=!1;return J(null,null,function*(){try{n(!0),o(null);const[w,v]=yield Promise.all([Dr.getTasks(e),Dr.getTaskCount(e.filters)]);if(b||y!==h.current)return;a(w.data),c(v)}catch(w){if(b||y!==h.current)return;o(w instanceof Error?w.message:"Failed to fetch tasks")}finally{!b&&y===h.current&&n(!1)}}),()=>{b=!0}},[u]);const f=p.useCallback(()=>J(null,null,function*(){const y=++h.current;try{n(!0),o(null);const[b,w]=yield Promise.all([Dr.getTasks(e),Dr.getTaskCount(e.filters)]);if(y!==h.current)return;a(b.data),c(w)}catch(b){if(y!==h.current)return;o(b instanceof Error?b.message:"Failed to fetch tasks")}finally{y===h.current&&n(!1)}}),[u]);return{tasks:r,loading:s,error:i,totalCount:l,refetch:f}},RNe=e=>{const[r,a]=p.useState([]),[s,n]=p.useState(!1),[i,o]=p.useState(null),l=p.useCallback(()=>J(null,null,function*(){if(!e){a([]);return}try{n(!0),o(null);const{data:c}=yield Dr.getTasksForProject(e);a(c)}catch(c){o(c instanceof Error?c.message:"Failed to fetch tasks")}finally{n(!1)}}),[e]);return p.useEffect(()=>{l()},[l]),{tasks:r,loading:s,error:i,refetch:l}},MNe=e=>{const[r,a]=p.useState(null),[s,n]=p.useState(!1),[i,o]=p.useState(null),l=p.useCallback(()=>J(null,null,function*(){if(!e){a(null);return}try{n(!0),o(null),a(yield Dr.getTask(e))}catch(c){o(c instanceof Error?c.message:"Failed to fetch task")}finally{n(!1)}}),[e]);return p.useEffect(()=>{l()},[l]),{task:r,loading:s,error:i,refetch:l}},LNe=(e={})=>{const[r,a]=p.useState([]),[s,n]=p.useState(!0),[i,o]=p.useState(null),[l,c]=p.useState(0),u=iy(e),h=p.useRef(0);p.useEffect(()=>{const y=++h.current;let b=!1;return J(null,null,function*(){try{n(!0),o(null);const[w,v]=yield Promise.all([Dr.getTimesheets(e),Dr.getTimesheetCount(e.filters||{},e.appendFilters||[])]);if(b||y!==h.current)return;a(w.data),c(v)}catch(w){if(b||y!==h.current)return;o(w instanceof Error?w.message:"Failed to fetch timesheets")}finally{!b&&y===h.current&&n(!1)}}),()=>{b=!0}},[u]);const f=p.useCallback(()=>J(null,null,function*(){const y=++h.current;try{n(!0),o(null);const[b,w]=yield Promise.all([Dr.getTimesheets(e),Dr.getTimesheetCount(e.filters||{},e.appendFilters||[])]);if(y!==h.current)return;a(b.data),c(w)}catch(b){if(y!==h.current)return;o(b instanceof Error?b.message:"Failed to fetch timesheets")}finally{y===h.current&&n(!1)}}),[u]);return{timesheets:r,loading:s,error:i,totalCount:l,refetch:f}},FNe=e=>{const[r,a]=p.useState([]),[s,n]=p.useState(!1),[i,o]=p.useState(null),l=p.useCallback(()=>J(null,null,function*(){if(!e){a([]);return}try{n(!0),o(null);const{data:c}=yield Dr.getTimesheetsForProject(e);a(c)}catch(c){o(c instanceof Error?c.message:"Failed to fetch timesheets")}finally{n(!1)}}),[e]);return p.useEffect(()=>{l()},[l]),{timesheets:r,loading:s,error:i,refetch:l}},INe=e=>{const[r,a]=p.useState(null),[s,n]=p.useState(!1),[i,o]=p.useState(null),l=p.useCallback(()=>J(null,null,function*(){if(!e){a(null);return}try{n(!0),o(null),a(yield Dr.getTimesheet(e))}catch(c){o(c instanceof Error?c.message:"Failed to fetch timesheet")}finally{n(!1)}}),[e]);return p.useEffect(()=>{l()},[l]),{timesheet:r,loading:s,error:i,refetch:l}},zNe=(e={})=>{const[r,a]=p.useState([]),[s,n]=p.useState(!0),[i,o]=p.useState(0),l=iy(e),c=p.useRef(0);p.useEffect(()=>{const h=++c.current;let f=!1;return J(null,null,function*(){try{n(!0);const[y,b]=yield Promise.all([Dr.getProjectTemplates(e),Dr.getProjectTemplateCount(e.filters||{})]);if(f||h!==c.current)return;a(y.data),o(b)}catch(y){}finally{!f&&h===c.current&&n(!1)}}),()=>{f=!0}},[l]);const u=p.useCallback(()=>J(null,null,function*(){const h=++c.current;try{n(!0);const[f,y]=yield Promise.all([Dr.getProjectTemplates(e),Dr.getProjectTemplateCount(e.filters||{})]);if(h!==c.current)return;a(f.data),o(y)}catch(f){}finally{h===c.current&&n(!1)}}),[l]);return{templates:r,loading:s,totalCount:i,refetch:u}},$Ne=e=>{const[r,a]=p.useState(null),[s,n]=p.useState(!1),[i,o]=p.useState(null),l=p.useCallback(()=>J(null,null,function*(){if(!e){a(null);return}try{n(!0),o(null),a(yield Dr.getProjectTemplate(e))}catch(c){o(c instanceof Error?c.message:"Failed to fetch template")}finally{n(!1)}}),[e]);return p.useEffect(()=>{l()},[l]),{template:r,loading:s,error:i,refetch:l}},UNe=(e={})=>{const[r,a]=p.useState([]),[s,n]=p.useState(!0),[i,o]=p.useState(0),l=iy(e),c=p.useRef(0);p.useEffect(()=>{const h=++c.current;let f=!1;return J(null,null,function*(){try{n(!0);const[y,b]=yield Promise.all([Dr.getActivityTypes(e),Dr.getActivityTypeCount(e.filters||{})]);if(f||h!==c.current)return;a(y.data),o(b)}catch(y){}finally{!f&&h===c.current&&n(!1)}}),()=>{f=!0}},[l]);const u=p.useCallback(()=>J(null,null,function*(){const h=++c.current;try{n(!0);const[f,y]=yield Promise.all([Dr.getActivityTypes(e),Dr.getActivityTypeCount(e.filters||{})]);if(h!==c.current)return;a(f.data),o(y)}catch(f){}finally{h===c.current&&n(!1)}}),[l]);return{activityTypes:r,loading:s,totalCount:i,refetch:u}},BNe=e=>{const[r,a]=p.useState(null),[s,n]=p.useState(!1),[i,o]=p.useState(null),l=p.useCallback(()=>J(null,null,function*(){if(!e){a(null);return}try{n(!0),o(null),a(yield Dr.getActivityType(e))}catch(c){o(c instanceof Error?c.message:"Failed to fetch activity type")}finally{n(!1)}}),[e]);return p.useEffect(()=>{l()},[l]),{activityType:r,loading:s,error:i,refetch:l}},oy=()=>{const[e,r]=p.useState(!1),[a,s]=p.useState(null),n=i=>J(null,null,function*(){try{return r(!0),s(null),yield i()}catch(o){const l=o instanceof Error?o.message:"Operation failed";throw s(l),o}finally{r(!1)}});return{createProject:i=>n(()=>Dr.createProject(i)),updateProject:(i,o)=>n(()=>Dr.updateProject(i,o)),createTask:i=>n(()=>Dr.createTask(i)),updateTask:(i,o)=>n(()=>Dr.updateTask(i,o)),createTimesheet:i=>n(()=>Dr.createTimesheet(i)),updateTimesheet:(i,o)=>n(()=>Dr.updateTimesheet(i,o)),submitTimesheet:i=>n(()=>Dr.submitTimesheet(i)),cancelTimesheet:i=>n(()=>Dr.cancelTimesheet(i)),createProjectTemplate:i=>n(()=>Dr.createProjectTemplate(i)),updateProjectTemplate:(i,o)=>n(()=>Dr.updateProjectTemplate(i,o)),createActivityType:i=>n(()=>Dr.createActivityType(i)),updateActivityType:(i,o)=>n(()=>Dr.updateActivityType(i,o)),loading:e,error:a}};function po(e,r){const[a,s]=p.useState(new Set);p.useEffect(()=>{s(new Set)},[r]);const n=p.useCallback(c=>{s(u=>{const h=new Set(u);return h.has(c)?h.delete(c):h.add(c),h})},[]),i=p.useCallback(()=>{s(c=>{const u=e.map(f=>f.name);return u.length===0?new Set:u.every(f=>c.has(f))?new Set:new Set(u)})},[e]),o=e.length>0&&e.every(c=>a.has(c.name)),l=e.some(c=>a.has(c.name))&&!o;return{selectedRows:a,toggleRow:n,toggleAllOnPage:i,allOnPageSelected:o,someOnPageSelected:l}}function WNe(e){if(e==null)return{};if(Array.isArray(e))return e.length>0?e:{};const r=xa(e);return r.length>0?r:{}}function go(e){return J(this,null,function*(){const{doctype:r,filters:a,orderBy:s="modified desc",fields:n=["*"],pageSize:i=100,maxPages:o=100,orFilters:l}=e,c=WNe(a),u=[];let h=0,f=!0;for(;f;){const y={doctype:r,filters:c,fields:n,limit_start:h*i,limit_page_length:i,order_by:s};l&&l.length>0&&(y.or_filters=l);const b=yield At.getCSRFToken(),w={"Content-Type":"application/json"};b&&(w["X-Frappe-CSRF-Token"]=b);const v=yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:w,credentials:"include",body:JSON.stringify(y)}),k=yield v.json();if(k.exc)throw new Error(typeof k.exc=="string"?k.exc:"get_list failed");if(!v.ok)throw new Error(typeof k.message=="string"?k.message:`get_list failed (${v.status})`);const S=Array.isArray(k.message)?k.message:[];u.push(...S),S.length<i?f=!1:(h+=1,h>=o&&(console.warn("[fetchAllRowsForExport] maxPages safety limit reached"),f=!1))}return u})}const HNe=e=>{switch(e==null?void 0:e.toLowerCase()){case"open":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";case"completed":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300";case"cancelled":return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}},qNe=e=>{switch(e==null?void 0:e.toLowerCase()){case"high":return"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300";case"medium":return"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-300";case"low":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}},VNe=()=>{const{t:e}=sr(),r=hr(),[a,s]=_a(),n=p.useRef(s);p.useEffect(()=>{n.current=s},[s]);const i=p.useMemo(()=>{const we=parseInt(a.get("page")||"1",10);return Number.isNaN(we)||we<1?1:we},[a]),o=p.useCallback(we=>{const pe=typeof we=="function"?we(i):we;s(le=>{const Fe=new URLSearchParams(le);return Fe.set("page",String(pe)),Fe})},[i,s]),l=20,[c,u]=p.useState(!1),[h,f]=p.useState(()=>a.get("status")||""),[y,b]=p.useState(()=>a.get("priority")||""),[w,v]=p.useState(()=>a.get("q")||""),[k,S]=p.useState(()=>a.get("date_filter_by")||""),[N,C]=p.useState(()=>a.get("date_start")||""),[O,T]=p.useState(()=>a.get("date_end")||""),[P,E]=p.useState(()=>a.get("sort_by")||"modified desc"),[R,z]=p.useState(!1),[G,ae]=p.useState(!1),ee=p.useRef(!1),ne=p.useRef(!0),te=p.useRef(null),Y=p.useMemo(()=>{const we={};return h&&(we.status=h),y&&(we.priority=y),w&&(we.project_name=["like",`%${w}%`]),Object.assign(we,kl(k,N,O)),we},[h,y,w,k,N,O]),q=["creation desc","creation asc","modified desc","modified asc","name asc","name desc"].includes(P)?P:"modified desc",{projects:H,loading:U,error:re,totalCount:X,refetch:V}=ONe({filters:Y,limit_start:(i-1)*l,limit_page_length:l,order_by:q}),I=p.useMemo(()=>`${i}|${P}|${JSON.stringify(Y)}`,[i,P,Y]),{selectedRows:B,toggleRow:Q,toggleAllOnPage:ie,allOnPageSelected:me,someOnPageSelected:he}=po(H,I),de=p.useCallback(()=>go({doctype:"Project",filters:Y,orderBy:q}),[Y,q]),xe=Math.ceil(X/l),ge=we=>we?new Date(we).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-",be=()=>{f(""),b(""),v(""),S(""),C(""),T(""),E("modified desc"),s(we=>{const pe=new URLSearchParams(we);return pe.delete("status"),pe.delete("priority"),pe.delete("q"),pe.delete("date_filter_by"),pe.delete("date_start"),pe.delete("date_end"),pe.delete("sort_by"),pe.set("page","1"),pe})},K=!!h||!!y||!!w||!!(k&&(N||O)),ye=p.useCallback(()=>{s(we=>{const pe=new URLSearchParams(we);return h?pe.set("status",h):pe.delete("status"),y?pe.set("priority",y):pe.delete("priority"),w?pe.set("q",w):pe.delete("q"),k?pe.set("date_filter_by",k):pe.delete("date_filter_by"),N?pe.set("date_start",N):pe.delete("date_start"),O?pe.set("date_end",O):pe.delete("date_end"),P!=="modified desc"?pe.set("sort_by",P):pe.delete("sort_by"),pe.set("page","1"),pe})},[h,y,w,k,N,O,P,s]);p.useEffect(()=>{if(!ee.current){ee.current=!0;return}n.current(we=>{const pe=new URLSearchParams(we);return h?pe.set("status",h):pe.delete("status"),y?pe.set("priority",y):pe.delete("priority"),k?pe.set("date_filter_by",k):pe.delete("date_filter_by"),N?pe.set("date_start",N):pe.delete("date_start"),O?pe.set("date_end",O):pe.delete("date_end"),P!=="modified desc"?pe.set("sort_by",P):pe.delete("sort_by"),pe.set("page","1"),pe})},[h,y,k,N,O,P]),p.useEffect(()=>{if(ee.current){if(ne.current){ne.current=!1;return}return te.current&&window.clearTimeout(te.current),te.current=window.setTimeout(()=>{n.current(we=>{const pe=new URLSearchParams(we);return w?pe.set("q",w):pe.delete("q"),pe.set("page","1"),pe})},450),()=>{te.current&&window.clearTimeout(te.current)}}},[w]);const Z=we=>r(`/projects/list/${encodeURIComponent(we)}?edit=1`),M=we=>r(`/projects/list/new?duplicate=${encodeURIComponent(we)}`);return t.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm mb-4",children:[t.jsx("button",{onClick:()=>r("/projects"),className:"text-gray-500 hover:text-blue-600 dark:text-gray-400 dark:hover:text-blue-400",children:e("projects.moduleTitle")}),t.jsx("span",{className:"text-gray-400",children:"/"}),t.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:e("projects.projectsDoctype")})]}),t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:justify-between sm:items-center",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-3xl font-bold text-gray-800 dark:text-white",children:e("projects.title")}),t.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:[e("projects.listTotal"),X," ",e(X!==1?"projects.listProjects":"projects.listProject"),B.size>0&&t.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",B.size," ",e("common.selected")]}),U&&t.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400",children:[t.jsx(Ma,{className:"animate-spin h-3 w-3"}),e("common.updating")]})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-3",children:[t.jsxs("button",{type:"button",onClick:()=>ae(!0),className:"bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",title:"Bulk-update project status by voice",children:[t.jsx(Q4,{}),t.jsx("span",{className:"font-medium",children:"Voice Command Assist"})]}),t.jsxs("button",{type:"button",onClick:()=>z(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all disabled:opacity-50",disabled:X===0&&B.size===0,children:[t.jsx(Sa,{}),t.jsx("span",{className:"font-medium",children:e("listPages.export")}),B.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:B.size})]}),t.jsxs("button",{type:"button",onClick:()=>r("/projects/list/new"),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow-lg transition-all hover:shadow-xl",children:[t.jsx(Rr,{}),t.jsx("span",{className:"font-medium",children:e("projects.newProject")})]})]})]}),t.jsx(bi,{isOpen:R,onClose:()=>z(!1),doctype:"Project",selectedCount:B.size,pageCount:H.length,totalCount:X,pageData:H,selectedRows:B,rowKey:"name",onFetchAll:de,fileNamePrefix:"projects"}),t.jsx(kL,{isOpen:G,onClose:()=>ae(!1),selectedRows:B,onUpdateSuccess:()=>{V()},doctype:"Project",fieldname:"status",statusOptions:fne,widgetTitle:"Voice Project Status Update",showLanguageToggle:!0,noSelectionLabel:"project"}),t.jsxs("div",{className:"isolate bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-6",children:[t.jsx("div",{className:"bg-gradient-to-r from-blue-500 to-blue-600 dark:from-blue-600 dark:to-blue-700 px-4 py-3 rounded-t-lg",children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx("button",{onClick:()=>u(we=>!we),className:"text-white hover:bg-white/20 p-2 rounded-lg transition-all",children:c?t.jsx(Ja,{size:14}):t.jsx(Fr,{size:14})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ds,{className:"text-white",size:16}),t.jsx("span",{className:"text-white font-semibold text-sm",children:e("listPages.filters")})]}),K&&t.jsx("span",{className:"bg-white text-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:[w,h,y,k&&N].filter(Boolean).length})]}),K&&t.jsx("div",{className:"flex-1 overflow-x-auto mx-2",children:t.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[w&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-white/90 text-blue-700 rounded-full text-[10px] font-medium whitespace-nowrap",children:[t.jsx("span",{className:"font-semibold",children:"Name:"})," ",w,t.jsx("button",{onClick:()=>v(""),children:t.jsx(ht,{className:"text-[9px] hover:text-red-500"})})]}),h&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-white/90 text-blue-700 rounded-full text-[10px] font-medium whitespace-nowrap",children:[t.jsx("span",{className:"font-semibold",children:"Status:"})," ",h,t.jsx("button",{onClick:()=>f(""),children:t.jsx(ht,{className:"text-[9px] hover:text-red-500"})})]}),y&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-white/90 text-blue-700 rounded-full text-[10px] font-medium whitespace-nowrap",children:[t.jsx("span",{className:"font-semibold",children:"Priority:"})," ",y,t.jsx("button",{onClick:()=>b(""),children:t.jsx(ht,{className:"text-[9px] hover:text-red-500"})})]}),k&&N&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-white/90 text-blue-700 rounded-full text-[10px] font-medium whitespace-nowrap",children:[t.jsxs("span",{className:"font-semibold",children:[k==="creation"?"Created":"Modified",":"]})," ",N,O?` – ${O}`:"",t.jsx("button",{onClick:()=>{S(""),C(""),T("")},children:t.jsx(ht,{className:"text-[9px] hover:text-red-500"})})]})]})}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[K&&t.jsx("button",{onClick:be,className:"text-white/80 hover:text-white text-xs underline whitespace-nowrap",children:"Clear all"}),t.jsx("button",{onClick:()=>V(),className:"text-white hover:bg-white/20 p-1.5 rounded-lg transition-all",title:"Refresh",children:t.jsx(Ma,{size:12,className:U?"animate-spin":""})})]})]})}),c&&t.jsx("div",{className:"p-4",children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Search"}),t.jsxs("div",{className:"relative",children:[t.jsx(za,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400 text-xs"}),t.jsx("input",{type:"text",value:w,onChange:we=>v(we.target.value),onKeyDown:we=>we.key==="Enter"&&ye(),placeholder:e("projects.searchPlaceholder"),className:"w-full pl-8 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:outline-none"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Status"}),t.jsxs("select",{value:h,onChange:we=>f(we.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:outline-none",children:[t.jsx("option",{value:"",children:"All Status"}),t.jsx("option",{value:"Open",children:"Open"}),t.jsx("option",{value:"Completed",children:"Completed"}),t.jsx("option",{value:"Cancelled",children:"Cancelled"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Priority"}),t.jsxs("select",{value:y,onChange:we=>b(we.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:outline-none",children:[t.jsx("option",{value:"",children:"All Priority"}),t.jsx("option",{value:"High",children:"High"}),t.jsx("option",{value:"Medium",children:"Medium"}),t.jsx("option",{value:"Low",children:"Low"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Date Filter By"}),t.jsxs("select",{value:k,onChange:we=>S(we.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:outline-none",children:[t.jsx("option",{value:"",children:"None"}),t.jsx("option",{value:"creation",children:"Created"}),t.jsx("option",{value:"modified",children:"Modified"})]})]}),k&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"From"}),t.jsx("input",{type:"date",value:N,onChange:we=>C(we.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"To"}),t.jsx("input",{type:"date",value:O,onChange:we=>T(we.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:outline-none"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Sort By"}),t.jsxs("select",{value:P,onChange:we=>E(we.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:outline-none",children:[t.jsx("option",{value:"modified desc",children:"Modified (newest)"}),t.jsx("option",{value:"creation desc",children:"Created (newest)"}),t.jsx("option",{value:"modified asc",children:"Modified (oldest)"}),t.jsx("option",{value:"creation asc",children:"Created (oldest)"}),t.jsx("option",{value:"name asc",children:"Name A–Z"}),t.jsx("option",{value:"name desc",children:"Name Z–A"})]})]})]})})]}),re&&t.jsx("div",{className:"mb-4 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg text-red-700 dark:text-red-300",children:re}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden relative",children:[U?t.jsx("div",{className:"p-12 text-center text-gray-500 dark:text-gray-400",children:e("common.loading")}):H.length===0?t.jsx("div",{className:"p-12 text-center text-gray-500 dark:text-gray-400",children:e("projects.noProjects")}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"w-10 px-4 py-3 text-left",children:t.jsx("button",{type:"button",onClick:ie,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:me?"Deselect all":"Select all","aria-label":"Select all on page",children:me?t.jsx(Ra,{className:"text-blue-600 dark:text-blue-400",size:18}):he?t.jsxs("div",{className:"relative inline-block",children:[t.jsx(Ur,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Ur,{size:18})})}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-700 dark:text-gray-300 uppercase tracking-wider",children:e("projects.projectName")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.status")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.priority")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("projects.customer")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("projects.expectedEnd")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("projects.progress")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("common.actions")})]})}),t.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:H.map(we=>{var pe,le;return t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${B.has(we.name)?"bg-blue-50 dark:bg-blue-900/20":""}`,onClick:()=>r(`/projects/list/${we.name}`),children:[t.jsx("td",{className:"w-10 px-4 py-3",onClick:Fe=>Fe.stopPropagation(),children:t.jsx("button",{type:"button",onClick:()=>Q(we.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors","aria-label":`Select ${we.name}`,children:B.has(we.name)?t.jsx(Ra,{className:"text-blue-600 dark:text-blue-400",size:18}):t.jsx(Ur,{size:18})})}),t.jsxs("td",{className:"px-6 py-4",children:[t.jsx("span",{className:"text-[15px] font-medium text-gray-900 dark:text-white hover:underline",children:we.project_name||we.name}),t.jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400",children:we.name})]}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${HNe(we.status||"")}`,children:we.status||"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${qNe(we.priority||"")}`,children:we.priority||"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:we.customer||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:ge(we.expected_end_date||"")}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"flex-1 h-2 bg-gray-200 dark:bg-gray-600 rounded-full overflow-hidden max-w-[80px]",children:t.jsx("div",{className:"h-full bg-blue-500 rounded-full",style:{width:`${(pe=we.percent_complete)!=null?pe:0}%`}})}),t.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:[(le=we.percent_complete)!=null?le:0,"%"]})]})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",onClick:Fe=>Fe.stopPropagation(),children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button",onClick:()=>r(`/projects/list/${we.name}`),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded transition-colors",title:e("common.view"),"aria-label":e("common.view"),children:t.jsx(Ps,{})}),t.jsx("button",{type:"button",onClick:()=>Z(we.name),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:e("common.edit","Edit"),"aria-label":e("common.edit","Edit"),children:t.jsx(qr,{})}),t.jsx("button",{type:"button",onClick:()=>M(we.name),className:"text-purple-600 dark:text-purple-400 hover:text-purple-900 dark:hover:text-purple-300 p-2 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded transition-colors",title:e("common.duplicate","Duplicate"),"aria-label":e("common.duplicate","Duplicate"),children:t.jsx(Vo,{})})]})})]},we.name)})})]})}),xe>1&&t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 px-4 py-3",children:t.jsx(_l,{currentPage:i,totalPages:xe,totalCount:X,pageSize:l,onPageChange:o})})]})]})},un="Seera Arabia",Er="SAR",Fp="KSA Tax Charges - SA";function Ql(e){var a;const r=(a=e.tax_rate)!=null?a:e.rate;return typeof r=="number"&&!Number.isNaN(r)?r:0}function Xn(e){const r=(e||"").trim();return!r||r==="INR"?Er:r}function tB(e){return`SAR ${Number(e!=null?e:0).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}const Lu=({title:e,icon:r,defaultOpen:a=!0,children:s,badge:n})=>{const[i,o]=p.useState(a);return t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden shadow-sm",children:[t.jsxs("button",{type:"button",onClick:()=>o(l=>!l),className:"w-full flex items-center justify-between px-5 py-3.5 hover:bg-gray-50 dark:hover:bg-gray-700/30 transition-colors text-left",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-gray-700 dark:text-gray-200",children:[r,t.jsx("span",{children:e}),n]}),i?t.jsx(Fr,{className:"text-gray-400 text-xs flex-shrink-0"}):t.jsx(Fi,{className:"text-gray-400 text-xs flex-shrink-0"})]}),i&&t.jsx("div",{className:"px-5 py-5 bg-white dark:bg-gray-800 border-t border-gray-100 dark:border-gray-700/50",children:s})]})},ca=({children:e,required:r})=>t.jsxs("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1.5",children:[e,r&&t.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),da=({children:e})=>t.jsx("div",{className:"px-3 py-2.5 text-sm text-gray-800 dark:text-gray-200 bg-gray-50 dark:bg-gray-900/30 rounded-lg min-h-[38px] flex items-center border border-gray-100 dark:border-gray-700/50",children:e||t.jsx("span",{className:"text-gray-400 dark:text-gray-600",children:"—"})}),WD=({icon:e,label:r,value:a,loading:s,color:n,onClick:i})=>t.jsxs("button",{onClick:i,disabled:!i,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl border text-xs font-semibold transition-all ${n} ${i?"hover:shadow-sm hover:scale-105 cursor-pointer":"cursor-default"}`,children:[t.jsx("span",{children:e}),s?t.jsx(tr,{className:"animate-spin",size:10}):t.jsx("span",{className:"font-bold",children:a}),t.jsx("span",{className:"font-normal opacity-80",children:r})]}),HD=e=>{switch(e==null?void 0:e.toLowerCase()){case"open":return"bg-green-100 text-green-800 dark:bg-green-900/40 dark:text-green-300 border border-green-200/90 dark:border-green-800";case"completed":return"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/40 dark:text-emerald-300 border border-emerald-200/90 dark:border-emerald-800";case"cancelled":return"bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-400 border border-slate-200 dark:border-slate-600";default:return"bg-slate-100 text-slate-600 dark:bg-slate-700 dark:text-slate-400 border border-slate-200 dark:border-slate-600"}},qD=e=>{switch(e==null?void 0:e.toLowerCase()){case"high":return"bg-red-100 text-red-800 dark:bg-red-900/40 dark:text-red-300 border border-red-200 dark:border-red-800";case"medium":return"bg-purple-100 text-purple-800 dark:bg-purple-900/40 dark:text-purple-300 border border-purple-200 dark:border-purple-700";case"low":return"bg-green-100 text-green-800 dark:bg-green-900/40 dark:text-green-300 border border-green-200 dark:border-green-800";case"urgent":return"bg-red-200 text-red-900 dark:bg-red-800/50 dark:text-red-200 border border-red-300 dark:border-red-700";default:return"bg-slate-100 text-slate-600 dark:bg-slate-700 border border-slate-200 dark:border-slate-600"}},ff=e=>e?new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"—",Fu=tB,ll=e=>e?e.substring(0,8):"",GNe=()=>{var K,ye,Z,M,we,pe;const{t:e}=sr(),{projectName:r}=hs(),[a]=_a(),s=hr(),n=r==="new",i=n?null:r||null,o=a.get("source_so")||"",l=p.useMemo(()=>n&&a.get("duplicate")||"",[n,a]),c=p.useMemo(()=>!n&&(a.get("edit")||"")==="1",[n,a]),[u,h]=p.useState(n),[f,y]=p.useState(null),[b,w]=p.useState(""),[v,k]=p.useState([]),{project:S,loading:N,error:C,refetch:O}=PNe(i),{tasks:T,loading:P}=RNe(i),{timesheets:E,loading:R}=FNe(i),{createProject:z,updateProject:G,loading:ae}=oy(),ee=E.filter(le=>le.docstatus===1),ne={costing:ee.reduce((le,Fe)=>le+(Fe.total_costing_amount||0),0),billable:ee.reduce((le,Fe)=>le+(Fe.total_billable_amount||0),0),hours:ee.reduce((le,Fe)=>le+(Fe.total_hours||0),0)},te={project_name:"",status:"Open",is_active:"Yes",priority:"Medium",company:un,customer:"",project_template:"",project_type:"",custom_project_manager:"",expected_start_date:"",expected_end_date:"",department:"",percent_complete_method:"Task Completion",percent_complete:0,description:"",notes:"",estimated_costing:void 0,collect_progress:0,holiday_list:"",frequency:"Hourly",day_to_send:"Monday",from_time:"",to_time:"",first_email:"",second_email:"",daily_time_to_send:"",weekly_time_to_send:"",subject:"",message:""},[Y,q]=p.useState(te),[H,U]=p.useState(!1),[re,X]=p.useState([]),[V,I]=p.useState([]),B=le=>{var Fe,ze;return q({project_name:le.project_name||"",status:le.status||"Open",is_active:le.is_active||"Yes",priority:le.priority||"Medium",company:le.company||un,customer:le.customer||"",project_template:le.project_template||"",project_type:le.project_type||"",custom_project_manager:le.custom_project_manager||"",expected_start_date:le.expected_start_date||"",expected_end_date:le.expected_end_date||"",department:le.department||"",percent_complete_method:le.percent_complete_method||"Task Completion",percent_complete:(Fe=le.percent_complete)!=null?Fe:0,description:le.description||"",notes:R4(le.notes||"")||"",estimated_costing:le.estimated_costing!=null?le.estimated_costing:void 0,collect_progress:(ze=le.collect_progress)!=null?ze:0,holiday_list:le.holiday_list||"",frequency:le.frequency||"Hourly",from_time:le.from_time||"",to_time:le.to_time||"",first_email:le.first_email||"",second_email:le.second_email||"",daily_time_to_send:le.daily_time_to_send||"",day_to_send:le.day_to_send||"Monday",weekly_time_to_send:le.weekly_time_to_send||"",subject:le.subject||"",message:le.message||""})};p.useEffect(()=>{S&&!n&&B(S)},[S,n]),p.useEffect(()=>{c&&h(!0)},[c]),p.useEffect(()=>{n&&!l&&X([])},[n,l]),p.useEffect(()=>{!S||n||X((S[kf]||[]).map(le=>({name:le.name,update_:le.update_,date:le.date?String(le.date).slice(0,10):"",task:le.task})))},[S,n]),p.useEffect(()=>{if(!i||n){I([]);return}let le=!1;const Fe=T.map(ze=>ze.name).filter(Boolean).slice(0,120);return J(null,null,function*(){const ze=yield Promise.all(Fe.map(De=>Dr.getTask(De).catch(()=>null)));if(le)return;const Re=[];for(const De of ze){if(!De)continue;const Et=De.custom_task_updates||[];for(const jt of Et)Re.push(je(se({},jt),{task:jt.task||De.name,date:jt.date?String(jt.date).slice(0,10):jt.date}))}I(Re)}),()=>{le=!0}},[i,n,T]);const Q=p.useMemo(()=>{const le=V.map(Re=>({row:Re,source:"task"})),Fe=re.map((Re,De)=>({row:Re,source:"project",projectIndex:De})),ze=Re=>String(Re.date||"").slice(0,10)||"";return[...le,...Fe].sort((Re,De)=>ze(De.row).localeCompare(ze(Re.row)))},[V,re]);p.useEffect(()=>{if(!n||!l)return;let le=!1;return U(!0),Dr.getProject(l).then(Fe=>{if(le)return;const ze=je(se({},Fe),{name:"",project_name:Fe.project_name?`${Fe.project_name} (Copy)`:""});B(ze);const Re=ze[kf]||[];X(Re.map(De=>({update_:De.update_,date:De.date?String(De.date).slice(0,10):"",task:De.task}))),h(!0)}).catch(()=>{}).finally(()=>{le||U(!1)}),()=>{le=!0}},[n,l]),p.useEffect(()=>{if(!i||n){y(null),k([]);return}let le=!1;return Io.getSalesOrderCount([["Sales Order","project","=",i]]).then(Fe=>{le||y(Fe)}).catch(()=>{le||y(0)}),()=>{le=!0}},[i,n]),p.useEffect(()=>{if(o){w(o);return}if(!i||n){w("");return}Io.getSalesOrderNamesForProject(i,1).then(le=>w((le==null?void 0:le[0])||"")).catch(()=>w(""))},[i,n,o]),p.useEffect(()=>{k([])},[i,n,f]);const ie=(le,Fe)=>q(ze=>je(se({},ze),{[le]:Fe})),me=n||u,he=n||u||!!Number(Y.collect_progress),de="w-full px-3 py-2.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-blue-400 focus:outline-none transition-colors",xe="w-full px-3 py-2.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:border-blue-400 focus:outline-none transition-colors",ge=()=>J(null,null,function*(){var Fe,ze;if(!((Fe=Y.project_name)!=null&&Fe.trim())){We.error("Project Name is required",{icon:t.jsx(pr,{})});return}const le=je(se({},Y),{estimated_costing:(ze=Y.estimated_costing)!=null?ze:0,[kf]:MN(re)});try{if(n){const Re=yield z(le);if(We.success("Project created successfully",{icon:t.jsx(Qt,{})}),h(!1),o){try{yield Io.updateSalesOrder(o,{project:Re.name})}catch(De){We.error(ti(De)||"Failed to link Sales Order",{icon:t.jsx(pr,{})})}s(`/projects/list/${Re.name}?source_so=${encodeURIComponent(o)}`);return}s(`/projects/list/${Re.name}`)}else yield G(r,le),We.success("Project saved",{icon:t.jsx(Qt,{})}),h(!1),O()}catch(Re){We.error(ti(Re)||"Error saving project",{icon:t.jsx(pr,{})})}}),be=()=>{S&&(B(S),X((S[kf]||[]).map(le=>({name:le.name,update_:le.update_,date:le.date?String(le.date).slice(0,10):"",task:le.task})))),h(!1)};return N&&!n?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsxs("div",{className:"flex flex-col items-center gap-3",children:[t.jsx("div",{className:"animate-spin rounded-full h-10 w-10 border-[3px] border-blue-600 border-t-transparent"}),t.jsx("p",{className:"text-sm text-gray-500",children:"Loading project…"})]})}):!n&&(C||!S)?t.jsxs("div",{className:"p-6",children:[t.jsxs("button",{onClick:()=>s("/projects/list"),className:"flex items-center gap-2 text-gray-600 dark:text-gray-400 mb-4 text-sm hover:text-gray-900",children:[t.jsx(ia,{})," Back to Projects"]}),t.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 rounded-lg text-red-700 dark:text-red-300",children:C||"Project not found"})]}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900",children:[t.jsx($a,{position:"top-right",autoClose:3500}),t.jsx("div",{className:"bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 shadow-sm",children:t.jsxs("div",{className:"px-6 py-4",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs mb-3 text-gray-400 dark:text-gray-500",children:[t.jsx("button",{onClick:()=>s("/projects"),className:"hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:e("projects.moduleTitle","Project Management")}),t.jsx("span",{children:"/"}),t.jsx("button",{onClick:()=>s("/projects/list"),className:"hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:"Projects"}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-gray-600 dark:text-gray-300 font-medium",children:n?"New Project":(S==null?void 0:S.project_name)||r})]}),t.jsxs("div",{className:"flex items-start justify-between gap-4 flex-nowrap overflow-x-auto",children:[t.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[t.jsx("button",{onClick:()=>s("/projects/list"),className:"mt-1 p-1.5 rounded-lg text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors flex-shrink-0",children:t.jsx(ia,{size:13})}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-blue-500 to-blue-600 flex items-center justify-center flex-shrink-0 shadow-sm",children:t.jsx(gp,{className:"text-white text-sm"})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white leading-tight",children:n?"New Project":(S==null?void 0:S.project_name)||r}),n&&l&&t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:["Duplicating from ",t.jsx("span",{className:"font-mono",children:l}),H?"…":""]}),!n&&t.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 font-mono",children:r})]})]}),!n&&t.jsxs("div",{className:"flex items-center flex-wrap gap-2 mt-3 ml-12",children:[t.jsx("span",{className:`px-2.5 py-1 rounded-lg text-xs font-semibold ${HD((S==null?void 0:S.status)||"")}`,children:(S==null?void 0:S.status)||"Open"}),t.jsx("span",{className:`px-2.5 py-1 rounded-lg text-xs font-semibold ${qD((S==null?void 0:S.priority)||"")}`,children:(S==null?void 0:S.priority)||"—"}),t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400",children:[t.jsx("div",{className:"w-20 h-1.5 bg-gray-200 dark:bg-gray-600 rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-green-600 dark:bg-green-500 rounded-full transition-all",style:{width:`${Math.min((K=S==null?void 0:S.percent_complete)!=null?K:0,100)}%`}})}),t.jsxs("span",{className:"font-semibold tabular-nums",children:[(ye=S==null?void 0:S.percent_complete)!=null?ye:0,"%"]})]}),t.jsx(WD,{icon:t.jsx(bm,{size:10}),label:"Tasks",value:T.length,loading:P,color:"bg-purple-50 dark:bg-purple-900/20 border-purple-200 dark:border-purple-700 text-purple-800 dark:text-purple-200",onClick:()=>s(`/projects/tasks?project=${r}`)}),t.jsx(WD,{icon:t.jsx(ea,{size:10}),label:"Timesheets",value:E.length,loading:R,color:"bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-700 text-green-800 dark:text-green-200",onClick:()=>s(`/projects/timesheets?project=${encodeURIComponent(r)}`)})]})]})]}),t.jsxs("div",{className:"flex gap-2 flex-shrink-0 flex-nowrap items-center whitespace-nowrap",children:[!n&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:()=>s(`/projects/tasks/new?project=${encodeURIComponent(r||"")}`),className:"flex items-center gap-1.5 px-3 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg text-xs font-medium shadow-sm transition-colors",children:[t.jsx(Rr,{size:10}),t.jsx(bm,{size:10})," Task"]}),t.jsxs("button",{type:"button",onClick:()=>{const le=new URLSearchParams;le.set("project",r||""),Y.customer&&le.set("customer",Y.customer),Y.company&&le.set("company",Y.company),s(`/projects/timesheets/new?${le.toString()}`)},className:"flex items-center gap-1.5 px-3 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg text-xs font-medium shadow-sm transition-colors",children:[t.jsx(Rr,{size:10}),t.jsx(ea,{size:10})," Timesheet"]}),t.jsxs("button",{type:"button",onClick:()=>{const le=new URLSearchParams;le.set("project",r||""),Y.customer&&le.set("customer",Y.customer),Y.company&&le.set("company",Y.company),s(`/sales-orders/new?${le.toString()}`)},className:"flex items-center gap-1.5 px-3 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg text-xs font-medium shadow-sm transition-colors",children:[t.jsx(Rr,{size:10}),t.jsx(dm,{size:10})," Sales Order"]}),t.jsxs("button",{type:"button",onClick:()=>{const le=new URLSearchParams;le.set("project",r||""),Y.company&&le.set("company",Y.company),s(`/material-requests/new?${le.toString()}`)},className:"flex items-center gap-1.5 px-3 py-2 bg-orange-600 hover:bg-orange-700 text-white rounded-lg text-xs font-medium shadow-sm transition-colors",children:[t.jsx(Rr,{size:10}),t.jsx(zd,{size:10})," Material Request"]})]}),!u&&!n&&t.jsxs("button",{onClick:()=>h(!0),className:"flex items-center gap-1.5 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm font-medium transition-all shadow-lg hover:shadow-xl",children:[t.jsx(qr,{size:12})," Edit"]}),(u||n)&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:ge,disabled:ae,className:"flex items-center gap-1.5 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg disabled:opacity-50 text-sm font-medium transition-all shadow-lg hover:shadow-xl",children:[ae?t.jsx(tr,{className:"animate-spin",size:12}):t.jsx(ta,{size:12}),ae?"Saving…":"Save"]}),!n&&t.jsxs("button",{onClick:be,className:"flex items-center gap-1.5 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg text-sm text-gray-600 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[t.jsx(ht,{size:12})," Cancel"]})]})]})]})]})}),t.jsxs("div",{className:"px-6 py-6 space-y-3",children:[t.jsx(Lu,{title:"Details",defaultOpen:!0,children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-5",children:[t.jsxs("div",{children:[t.jsx(ca,{required:!0,children:"Project Name"}),me?t.jsx("input",{type:"text",value:Y.project_name||"",onChange:le=>ie("project_name",le.target.value),className:de,placeholder:"Enter project name"}):t.jsx(da,{children:Y.project_name})]}),t.jsxs("div",{children:[t.jsx(ca,{children:"Expected Start Date"}),me?t.jsx("input",{type:"date",value:Y.expected_start_date||"",onChange:le=>ie("expected_start_date",le.target.value),className:de}):t.jsx(da,{children:ff(Y.expected_start_date)})]}),t.jsxs("div",{children:[t.jsx(ca,{children:"Status"}),me?t.jsxs("select",{value:Y.status||"Open",onChange:le=>ie("status",le.target.value),className:xe,children:[t.jsx("option",{value:"Open",children:"Open"}),t.jsx("option",{value:"Completed",children:"Completed"}),t.jsx("option",{value:"Cancelled",children:"Cancelled"})]}):t.jsx(da,{children:t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${HD(Y.status||"")}`,children:Y.status})})]}),t.jsxs("div",{children:[t.jsx(ca,{children:"Expected End Date"}),me?t.jsx("input",{type:"date",value:Y.expected_end_date||"",onChange:le=>ie("expected_end_date",le.target.value),className:de}):t.jsx(da,{children:ff(Y.expected_end_date)})]}),t.jsxs("div",{children:[t.jsx(ca,{children:"Project Type"}),me?t.jsx(Je,{label:"Project Type",hideLabel:!0,doctype:"Project Type",value:Y.project_type||"",onChange:le=>ie("project_type",le),placeholder:"Select project type…"}):t.jsx(da,{children:Y.project_type||"—"})]}),t.jsxs("div",{children:[t.jsx(ca,{children:"Priority"}),me?t.jsxs("select",{value:Y.priority||"Medium",onChange:le=>ie("priority",le.target.value),className:xe,children:[t.jsx("option",{value:"Low",children:"Low"}),t.jsx("option",{value:"Medium",children:"Medium"}),t.jsx("option",{value:"High",children:"High"}),t.jsx("option",{value:"Urgent",children:"Urgent"})]}):t.jsx(da,{children:t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${qD(Y.priority||"")}`,children:Y.priority})})]}),t.jsxs("div",{children:[t.jsx(ca,{children:"Project Manager"}),me?t.jsx(Je,{label:"Project Manager",hideLabel:!0,doctype:"User",value:Y.custom_project_manager||"",onChange:le=>ie("custom_project_manager",le),placeholder:"Select project manager…"}):t.jsx(da,{children:Y.custom_project_manager||"—"})]}),t.jsxs("div",{children:[t.jsx(ca,{children:"Department"}),me?t.jsx(Je,{label:"Department",hideLabel:!0,doctype:"Department",value:Y.department||"",onChange:le=>ie("department",le),placeholder:"Select department…",allowQuickCreate:!0}):t.jsx(da,{children:Y.department||"—"})]}),t.jsxs("div",{children:[t.jsx(ca,{children:"Is Active"}),me?t.jsxs("select",{value:Y.is_active||"Yes",onChange:le=>ie("is_active",le.target.value),className:xe,children:[t.jsx("option",{value:"Yes",children:"Yes"}),t.jsx("option",{value:"No",children:"No"})]}):t.jsx(da,{children:Y.is_active})]}),t.jsxs("div",{children:[t.jsx(ca,{children:"% Complete Method"}),me?t.jsxs("select",{value:Y.percent_complete_method||"Task Completion",onChange:le=>ie("percent_complete_method",le.target.value),className:xe,children:[t.jsx("option",{value:"Manual",children:"Manual"}),t.jsx("option",{value:"Task Completion",children:"Task Completion"}),t.jsx("option",{value:"Task Progress",children:"Task Progress"}),t.jsx("option",{value:"Task Weight",children:"Task Weight"})]}):t.jsx(da,{children:Y.percent_complete_method})]}),t.jsxs("div",{children:[t.jsx(ca,{children:"From Template"}),n?t.jsx(Je,{label:"From Template",hideLabel:!0,doctype:"Project Template",value:Y.project_template||"",onChange:le=>ie("project_template",le),placeholder:"Select template…",allowQuickCreate:!0}):t.jsx(da,{children:Y.project_template||"—"})]}),t.jsxs("div",{children:[t.jsx(ca,{children:"% Completed"}),me&&Y.percent_complete_method==="Manual"?t.jsx("input",{type:"number",min:0,max:100,step:.001,value:(Z=Y.percent_complete)!=null?Z:0,onChange:le=>ie("percent_complete",parseFloat(le.target.value)||0),className:de}):t.jsx(da,{children:t.jsxs("div",{className:"flex items-center gap-2 w-full min-w-0",children:[t.jsx("div",{className:"flex-1 h-2 bg-gray-200 dark:bg-gray-600 rounded-full overflow-hidden min-w-0",children:t.jsx("div",{className:"h-full bg-green-600 dark:bg-green-500 rounded-full transition-all",style:{width:`${Math.min((M=Y.percent_complete)!=null?M:0,100)}%`}})}),t.jsxs("span",{className:"text-sm font-semibold min-w-[52px] text-right tabular-nums flex-shrink-0",children:[((we=Y.percent_complete)!=null?we:0).toLocaleString("en-US",{minimumFractionDigits:3,maximumFractionDigits:3}),"%"]})]})})]})]})}),t.jsx(Lu,{title:"Customer Details",defaultOpen:!0,children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-5",children:[t.jsxs("div",{children:[t.jsx(ca,{children:"Customer"}),me?t.jsx(Je,{label:"Customer",hideLabel:!0,doctype:"Customer",value:Y.customer||"",onChange:le=>ie("customer",le),placeholder:"Select customer…",allowQuickCreate:!0}):t.jsx(da,{children:Y.customer||"—"})]}),t.jsxs("div",{children:[t.jsx(ca,{children:"Sales Order"}),!n&&i?t.jsx(da,{children:b?t.jsx("button",{type:"button",onClick:()=>s(`/sales-orders/${encodeURIComponent(b)}`),className:"text-blue-700 hover:underline font-medium",title:"Open sales order",children:b}):f!=null&&f>0?t.jsxs("button",{type:"button",onClick:()=>s(`/sales-orders?project=${encodeURIComponent(r)}`),className:"text-blue-700 hover:underline font-medium",title:"Open sales orders list",children:[f," linked — open list"]}):t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"—"})}):t.jsx(da,{children:t.jsx("span",{className:"text-gray-400",children:"—"})})]})]})}),t.jsx(Lu,{title:"Notes",defaultOpen:!0,children:me?t.jsx("textarea",{rows:4,value:Y.notes||"",onChange:le=>ie("notes",le.target.value),className:"w-full px-3 py-2.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-400 focus:outline-none resize-y",placeholder:"Add notes…"}):t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap min-h-[40px] leading-relaxed",children:R4(Y.notes)||t.jsx("span",{className:"text-gray-400 italic",children:"No notes"})})}),t.jsx(Lu,{title:"Updates",icon:t.jsx(q9,{className:"text-violet-500",size:13}),defaultOpen:!0,badge:!n&&Q.length>0?t.jsx("span",{className:"ml-2 text-[10px] font-mono bg-white/20 px-1.5 py-0.5 rounded",children:Q.length}):null,children:t.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:[t.jsxs("div",{className:`grid ${me&&!n?"grid-cols-[40px_1fr_8rem_1fr_36px]":"grid-cols-[40px_1fr_8rem_1fr]"} bg-gray-50 dark:bg-gray-900/50 border-b border-gray-200 dark:border-gray-700`,children:[t.jsx("div",{className:"px-3 py-2 text-xs font-medium text-gray-500 uppercase",children:"No."}),t.jsx("div",{className:"px-3 py-2 text-xs font-medium text-gray-500 uppercase",children:"Update"}),t.jsx("div",{className:"px-3 py-2 text-xs font-medium text-gray-500 uppercase",children:"Date"}),t.jsx("div",{className:"px-3 py-2 text-xs font-medium text-gray-500 uppercase",children:"Task"}),me&&!n&&t.jsx("div",{className:"py-2 w-9"})]}),Q.length===0?t.jsx("div",{className:"py-8 text-center text-sm text-gray-400 italic",children:"No updates yet."}):t.jsx("div",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:Q.map((le,Fe)=>{const{row:ze,source:Re,projectIndex:De}=le,Et=me&&!n&&Re==="project"&&De!==void 0;return t.jsxs("div",{className:`grid ${Et?"grid-cols-[40px_1fr_8rem_1fr_36px]":"grid-cols-[40px_1fr_8rem_1fr]"} items-center hover:bg-gray-50/80 dark:hover:bg-gray-800/40`,children:[t.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 font-medium",children:Fe+1}),t.jsx("div",{className:"px-3 py-1.5 min-w-0",children:Et?t.jsx("input",{type:"text",value:ze.update_||"",onChange:jt=>{const Ie=De;X($e=>$e.map((Qe,at)=>at===Ie?je(se({},Qe),{update_:jt.target.value}):Qe))},className:de,placeholder:"Update…"}):t.jsx("span",{className:"text-sm text-gray-800 dark:text-gray-200",children:ze.update_||"—"})}),t.jsx("div",{className:"px-3 py-1.5",children:Et?t.jsx("input",{type:"date",value:ze.date?String(ze.date).slice(0,10):"",onChange:jt=>{const Ie=De;X($e=>$e.map((Qe,at)=>at===Ie?je(se({},Qe),{date:jt.target.value}):Qe))},className:de}):t.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:ze.date?ff(String(ze.date).slice(0,10)):"—"})}),t.jsx("div",{className:"px-3 py-1.5 min-w-0",children:Et?t.jsx(Je,{label:"Task",hideLabel:!0,doctype:"Task",value:ze.task||"",onChange:jt=>{const Ie=De;X($e=>$e.map((Qe,at)=>at===Ie?je(se({},Qe),{task:jt}):Qe))},placeholder:"Task…",filters:i?{project:i}:void 0,compact:!0}):ze.task?t.jsx("button",{type:"button",onClick:()=>s(`/projects/tasks/${encodeURIComponent(ze.task)}`),className:"text-sm text-indigo-600 dark:text-indigo-400 hover:underline font-mono truncate max-w-full block text-left",children:ze.task}):t.jsx("span",{className:"text-sm text-gray-400",children:"—"})}),Et&&t.jsx("div",{className:"flex justify-center",children:t.jsx("button",{type:"button",onClick:()=>{const jt=De;X(Ie=>Ie.filter(($e,Qe)=>Qe!==jt))},className:"p-1.5 text-red-400 hover:text-red-600 rounded transition-colors",title:"Remove row",children:t.jsx(wr,{size:11})})})]},`${Re}-${ze.name||De}-${Fe}`)})}),me&&!n&&t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 px-3 py-2 bg-gray-50 dark:bg-gray-900/30",children:t.jsxs("button",{type:"button",onClick:()=>X(le=>[...le,{}]),className:"flex items-center gap-1.5 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 font-medium",children:[t.jsx(Rr,{size:10})," Add Row"]})}),n&&t.jsx("p",{className:"text-[11px] text-gray-500 px-3 py-2 border-t border-gray-100 dark:border-gray-700",children:"Save the project first to add updates and to load task-sourced rows."})]})}),!n&&S&&t.jsx(Lu,{title:"Start and End Dates",icon:t.jsx(ea,{className:"text-sky-500",size:13}),defaultOpen:!0,children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-5",children:[t.jsxs("div",{children:[t.jsx(ca,{children:"Actual Start Date (via Timesheet)"}),t.jsx(da,{children:ff(S.actual_start_date)})]}),t.jsxs("div",{children:[t.jsx(ca,{children:"Actual End Date (via Timesheet)"}),t.jsx(da,{children:ff(S.actual_end_date)})]}),t.jsxs("div",{children:[t.jsx(ca,{children:"Actual Time in Hours (via Timesheet)"}),t.jsx(da,{children:S.actual_time!=null&&S.actual_time!==""?Number(S.actual_time).toLocaleString("en-US",{maximumFractionDigits:2}):"—"})]})]})}),t.jsx(Lu,{title:"Costing and Billing",icon:t.jsx(Zu,{className:"text-emerald-500",size:13}),defaultOpen:!0,children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-5",children:[t.jsxs("div",{children:[t.jsx(ca,{children:"Estimated Cost"}),me?t.jsx("input",{type:"number",min:0,step:"0.01",value:Y.estimated_costing===void 0||Y.estimated_costing===null?"":Y.estimated_costing,onChange:le=>{const Fe=le.target.value;if(Fe===""){ie("estimated_costing",void 0);return}const ze=parseFloat(Fe);ie("estimated_costing",Number.isFinite(ze)?ze:void 0)},className:de}):t.jsx(da,{children:Fu(S==null?void 0:S.estimated_costing)})]}),n?t.jsx("div",{}):t.jsxs("div",{children:[t.jsx(ca,{children:"Total Sales Amount (via Sales Order)"}),t.jsx(da,{children:Fu(S==null?void 0:S.total_sales_amount)})]}),n?t.jsx("div",{}):t.jsxs("div",{children:[t.jsx(ca,{children:"Total Costing Amount (via Timesheet)"}),t.jsx(da,{children:Fu(ne.costing||(S==null?void 0:S.total_costing_amount))})]}),n?t.jsx("div",{}):t.jsxs("div",{children:[t.jsx(ca,{children:"Total Billable Amount (via Timesheet)"}),t.jsx(da,{children:Fu(ne.billable||(S==null?void 0:S.total_billable_amount))})]}),n?t.jsx("div",{}):t.jsxs("div",{children:[t.jsx(ca,{children:"Total Purchase Cost (via Purchase Invoice)"}),t.jsx(da,{children:Fu(S==null?void 0:S.total_purchase_cost)})]}),n?t.jsx("div",{}):t.jsxs("div",{children:[t.jsx(ca,{children:"Total Billed Amount (via Sales Invoice)"}),t.jsx(da,{children:Fu(S==null?void 0:S.total_billed_amount)})]}),t.jsxs("div",{children:[t.jsx(ca,{required:!0,children:"Hospital"}),me?t.jsx(Je,{label:"Company",hideLabel:!0,doctype:"Company",value:Y.company||"",onChange:le=>ie("company",le),placeholder:"Select company…"}):t.jsx(da,{children:Y.company||"—"})]}),n?t.jsx("div",{}):t.jsxs("div",{children:[t.jsx(ca,{children:"Total Consumed Material Cost (via Stock Entry)"}),t.jsx(da,{children:Fu(S==null?void 0:S.total_consumed_material_cost)})]}),n?t.jsx("div",{}):t.jsx("div",{className:"hidden sm:block","aria-hidden":!0}),n?null:t.jsxs("div",{children:[t.jsx(ca,{children:"Default Cost Center"}),t.jsx(da,{children:(S==null?void 0:S.cost_center)||"—"})]})]})}),!n&&t.jsx(Lu,{title:"Margin",icon:t.jsx(J4,{className:"text-purple-500",size:13}),defaultOpen:!0,children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-5",children:[t.jsxs("div",{children:[t.jsx(ca,{children:"Gross Margin"}),t.jsx(da,{children:Fu(S==null?void 0:S.gross_margin)})]}),t.jsxs("div",{children:[t.jsx(ca,{children:"Gross Margin %"}),t.jsxs(da,{children:[((pe=S==null?void 0:S.per_gross_margin)!=null?pe:0).toLocaleString("en-US",{minimumFractionDigits:3,maximumFractionDigits:3}),"%"]})]})]})}),he&&t.jsx(Lu,{title:"Monitor Progress",icon:t.jsx(wN,{className:"text-blue-500",size:13}),defaultOpen:!0,children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("input",{type:"checkbox",id:"collect_progress",checked:!!Y.collect_progress,disabled:!me,onChange:le=>ie("collect_progress",le.target.checked?1:0),className:"w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500 cursor-pointer disabled:cursor-default"}),t.jsx("label",{htmlFor:"collect_progress",className:`text-sm font-medium ${me?"cursor-pointer":"cursor-default"} text-gray-700 dark:text-gray-300`,children:"Collect Progress"})]}),!!Y.collect_progress&&t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-5 pt-4 border-t border-gray-100 dark:border-gray-700",children:[t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{children:[t.jsx(ca,{children:"Holiday List"}),me?t.jsx(Je,{label:"Holiday List",hideLabel:!0,doctype:"Holiday List",value:Y.holiday_list||"",onChange:le=>ie("holiday_list",le),placeholder:"Select holiday list…"}):t.jsx(da,{children:Y.holiday_list||"—"})]}),t.jsxs("div",{children:[t.jsx(ca,{children:"Frequency To Collect Progress"}),me?t.jsxs("select",{value:Y.frequency||"Hourly",onChange:le=>ie("frequency",le.target.value),className:xe,children:[t.jsx("option",{value:"Hourly",children:"Hourly"}),t.jsx("option",{value:"Twice Daily",children:"Twice Daily"}),t.jsx("option",{value:"Daily",children:"Daily"}),t.jsx("option",{value:"Weekly",children:"Weekly"})]}):t.jsx(da,{children:Y.frequency})]}),Y.frequency==="Hourly"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx(ca,{children:"From Time"}),me?t.jsx("input",{type:"time",value:ll(Y.from_time),onChange:le=>ie("from_time",le.target.value),className:de}):t.jsx(da,{children:ll(Y.from_time)||"—"})]}),t.jsxs("div",{children:[t.jsx(ca,{children:"To Time"}),me?t.jsx("input",{type:"time",value:ll(Y.to_time),onChange:le=>ie("to_time",le.target.value),className:de}):t.jsx(da,{children:ll(Y.to_time)||"—"})]})]}),Y.frequency==="Twice Daily"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx(ca,{children:"First Email"}),me?t.jsx("input",{type:"time",value:ll(Y.first_email),onChange:le=>ie("first_email",le.target.value),className:de}):t.jsx(da,{children:ll(Y.first_email)||"—"})]}),t.jsxs("div",{children:[t.jsx(ca,{children:"Second Email"}),me?t.jsx("input",{type:"time",value:ll(Y.second_email),onChange:le=>ie("second_email",le.target.value),className:de}):t.jsx(da,{children:ll(Y.second_email)||"—"})]})]}),Y.frequency==="Daily"&&t.jsxs("div",{children:[t.jsx(ca,{children:"Daily Time to send"}),me?t.jsx("input",{type:"time",value:ll(Y.daily_time_to_send),onChange:le=>ie("daily_time_to_send",le.target.value),className:de}):t.jsx(da,{children:ll(Y.daily_time_to_send)||"—"})]}),Y.frequency==="Weekly"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx(ca,{children:"Day to Send"}),me?t.jsx("select",{value:Y.day_to_send||"Monday",onChange:le=>ie("day_to_send",le.target.value),className:xe,children:["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"].map(le=>t.jsx("option",{value:le,children:le},le))}):t.jsx(da,{children:Y.day_to_send})]}),t.jsxs("div",{children:[t.jsx(ca,{children:"Weekly Time to send"}),me?t.jsx("input",{type:"time",value:ll(Y.weekly_time_to_send),onChange:le=>ie("weekly_time_to_send",le.target.value),className:de}):t.jsx(da,{children:ll(Y.weekly_time_to_send)||"—"})]})]})]}),t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{children:[t.jsx(ca,{required:!0,children:"Subject"}),me?t.jsx("input",{type:"text",value:Y.subject||"",onChange:le=>ie("subject",le.target.value),className:de,placeholder:"Email subject…"}):t.jsx(da,{children:Y.subject||"—"})]}),t.jsxs("div",{children:[t.jsx(ca,{required:!0,children:"Message"}),me?t.jsx("textarea",{rows:5,value:Y.message||"",onChange:le=>ie("message",le.target.value),className:`${de} resize-y`,placeholder:"Message to project users…"}):t.jsx("div",{className:"px-3 py-2.5 text-sm text-gray-800 dark:text-gray-200 bg-gray-50 dark:bg-gray-900/30 rounded-lg min-h-[38px] border border-gray-100 dark:border-gray-700/50 whitespace-pre-wrap",children:Y.message||"—"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1.5",children:"Message will be sent to the users to get their status on the Project"})]})]})]})]})}),!n&&t.jsx(vi,{doctype:"Project",docname:r||"",creationDate:S==null?void 0:S.creation,createdBy:S==null?void 0:S.owner,compact:!1,initialVisible:5,collapsible:!0,startCollapsed:!0})]})]})},KNe=e=>{switch(e==null?void 0:e.toLowerCase()){case"open":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";case"working":return"bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-300";case"completed":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300";case"cancelled":return"bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400";case"overdue":return"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300";default:return"bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400"}},YNe=e=>{switch(e==null?void 0:e.toLowerCase()){case"high":return"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300";case"medium":return"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-300";case"low":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300";default:return"bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400"}},JNe=()=>{const{t:e}=sr(),r=hr(),[a,s]=_a(),n=20,i=p.useMemo(()=>{const Z=parseInt(a.get("page")||"1",10);return Number.isNaN(Z)||Z<1?1:Z},[a]),o=p.useCallback(Z=>{const M=typeof Z=="function"?Z(i):Z;s(we=>{const pe=new URLSearchParams(we);return pe.set("page",String(M)),pe})},[i,s]),[l,c]=p.useState(!1),[u,h]=p.useState(a.get("status")||""),[f,y]=p.useState(a.get("priority")||""),[b,w]=p.useState(a.get("project")||""),[v,k]=p.useState(a.get("q")||""),[S,N]=p.useState(a.get("date_filter_by")||""),[C,O]=p.useState(a.get("date_start")||""),[T,P]=p.useState(a.get("date_end")||""),[E,R]=p.useState(a.get("sort_by")||"creation desc"),[z,G]=p.useState(!1),ae=p.useRef(!1),ee=p.useRef(!0),ne=p.useRef(null),te=p.useRef(s);p.useEffect(()=>{te.current=s},[s]);const Y=p.useMemo(()=>{const Z={};return u&&(Z.status=u),f&&(Z.priority=f),b&&(Z.project=b),v&&(Z.subject=["like",`%${v}%`]),Object.assign(Z,kl(S,C,T)),Z},[u,f,b,v,S,C,T]),{tasks:q,loading:H,error:U,totalCount:re,refetch:X}=DNe({filters:Y,limit_start:(i-1)*n,limit_page_length:n,order_by:E}),V=p.useMemo(()=>`${i}|${E}|${JSON.stringify(Y)}`,[i,E,Y]),{selectedRows:I,toggleRow:B,toggleAllOnPage:Q,allOnPageSelected:ie,someOnPageSelected:me}=po(q,V),he=p.useCallback(()=>go({doctype:"Task",filters:Y,orderBy:E}),[Y,E]),de=Math.ceil(re/n),xe=Z=>Z?new Date(Z).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-",ge=()=>{h(""),y(""),w(""),k(""),N(""),O(""),P(""),R("creation desc"),s(Z=>{const M=new URLSearchParams(Z);return["status","priority","project","q","date_filter_by","date_start","date_end","sort_by"].forEach(we=>M.delete(we)),M.set("page","1"),M})};p.useEffect(()=>{if(!ae.current){ae.current=!0;return}te.current(Z=>{const M=new URLSearchParams(Z);return u?M.set("status",u):M.delete("status"),f?M.set("priority",f):M.delete("priority"),b?M.set("project",b):M.delete("project"),S?M.set("date_filter_by",S):M.delete("date_filter_by"),C?M.set("date_start",C):M.delete("date_start"),T?M.set("date_end",T):M.delete("date_end"),E!=="creation desc"?M.set("sort_by",E):M.delete("sort_by"),M.set("page","1"),M})},[u,f,b,S,C,T,E]),p.useEffect(()=>{if(ae.current){if(ee.current){ee.current=!1;return}return ne.current&&window.clearTimeout(ne.current),ne.current=window.setTimeout(()=>{te.current(Z=>{const M=new URLSearchParams(Z);return v?M.set("q",v):M.delete("q"),M.set("page","1"),M})},450),()=>{ne.current&&window.clearTimeout(ne.current)}}},[v]);const be=!!(u||f||b||v||S&&(C||T)),K=Z=>r(`/projects/tasks/${encodeURIComponent(Z)}?edit=1`),ye=Z=>r(`/projects/tasks/new?duplicate=${encodeURIComponent(Z)}`);return t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>r("/projects"),className:"text-sm text-gray-500 hover:text-indigo-600 dark:text-gray-400 dark:hover:text-indigo-400",children:e("projects.moduleTitle")}),t.jsx("span",{className:"text-gray-400",children:"/"}),t.jsxs("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white flex items-center gap-2",children:[t.jsx(bm,{className:"text-indigo-500"})," ",e("projects.tasksDoctype")]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>G(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all disabled:opacity-50",disabled:re===0&&I.size===0,children:[t.jsx(Sa,{})," ",t.jsx("span",{className:"font-medium",children:e("listPages.export")}),I.size>0&&t.jsx("span",{className:"bg-white/25 px-1.5 py-0.5 rounded text-xs font-bold",children:I.size})]}),t.jsxs("button",{onClick:()=>r("/projects/tasks/new"),className:"flex items-center gap-2 px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700",children:[t.jsx(Rr,{})," ",e("projects.newTask")]})]})]}),t.jsx(bi,{isOpen:z,onClose:()=>G(!1),doctype:"Task",selectedCount:I.size,pageCount:q.length,totalCount:re,pageData:q,selectedRows:I,rowKey:"name",onFetchAll:he,fileNamePrefix:"tasks"}),t.jsxs("div",{className:"isolate bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-6",children:[t.jsx("div",{className:"bg-gradient-to-r from-blue-500 to-blue-600 dark:from-blue-600 dark:to-blue-700 px-4 py-2.5 rounded-t-lg",children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx("button",{onClick:()=>c(Z=>!Z),className:"text-white hover:bg-white/20 p-1.5 rounded-lg transition-all",children:l?t.jsx(Ja,{size:12}):t.jsx(Fr,{size:12})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ds,{className:"text-white",size:13}),t.jsx("span",{className:"text-white font-semibold text-sm",children:"Filters"})]}),be&&t.jsx("span",{className:"bg-white text-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:[v,u,f,b,S&&C].filter(Boolean).length})]}),be&&t.jsx("div",{className:"flex-1 overflow-x-auto mx-2",children:t.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[v&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap",children:[t.jsx("span",{className:"font-semibold",children:"Subject:"})," ",v,t.jsx("button",{onClick:()=>k(""),children:t.jsx(ht,{className:"text-[9px] hover:text-red-500"})})]}),u&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap",children:[t.jsx("span",{className:"font-semibold",children:"Status:"})," ",u,t.jsx("button",{onClick:()=>h(""),children:t.jsx(ht,{className:"text-[9px] hover:text-red-500"})})]}),f&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap",children:[t.jsx("span",{className:"font-semibold",children:"Priority:"})," ",f,t.jsx("button",{onClick:()=>y(""),children:t.jsx(ht,{className:"text-[9px] hover:text-red-500"})})]}),b&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap",children:[t.jsx("span",{className:"font-semibold",children:"Project:"})," ",b,t.jsx("button",{onClick:()=>w(""),children:t.jsx(ht,{className:"text-[9px] hover:text-red-500"})})]}),S&&C&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap",children:[t.jsxs("span",{className:"font-semibold",children:[S==="creation"?"Created":"Modified",":"]})," ",C,T?` – ${T}`:"",t.jsx("button",{onClick:()=>{N(""),O(""),P("")},children:t.jsx(ht,{className:"text-[9px] hover:text-red-500"})})]})]})}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[be&&t.jsx("button",{onClick:ge,className:"text-white/80 hover:text-white text-xs underline whitespace-nowrap",children:"Clear all"}),t.jsx("button",{onClick:()=>X(),className:"text-white hover:bg-white/20 p-1.5 rounded-lg transition-all",title:"Refresh",children:t.jsx(Ma,{size:12,className:H?"animate-spin":""})})]})]})}),l&&t.jsx("div",{className:"p-4",children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Search"}),t.jsxs("div",{className:"relative",children:[t.jsx(za,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400 text-xs"}),t.jsx("input",{type:"text",value:v,onChange:Z=>k(Z.target.value),onKeyDown:Z=>Z.key==="Enter"&&Z.preventDefault(),placeholder:"Search by task subject…",className:"w-full pl-8 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-400 focus:outline-none"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Status"}),t.jsxs("select",{value:u,onChange:Z=>h(Z.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-400 focus:outline-none",children:[t.jsx("option",{value:"",children:"All Status"}),t.jsx("option",{value:"Open",children:"Open"}),t.jsx("option",{value:"Working",children:"Working"}),t.jsx("option",{value:"Completed",children:"Completed"}),t.jsx("option",{value:"Cancelled",children:"Cancelled"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Priority"}),t.jsxs("select",{value:f,onChange:Z=>y(Z.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-400 focus:outline-none",children:[t.jsx("option",{value:"",children:"All Priority"}),t.jsx("option",{value:"High",children:"High"}),t.jsx("option",{value:"Medium",children:"Medium"}),t.jsx("option",{value:"Low",children:"Low"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Project"}),t.jsx(Je,{label:"Project",hideLabel:!0,value:b,onChange:w,doctype:"Project",placeholder:"Filter by project…",compact:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Date Filter By"}),t.jsxs("select",{value:S,onChange:Z=>N(Z.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-400 focus:outline-none",children:[t.jsx("option",{value:"",children:"None"}),t.jsx("option",{value:"creation",children:"Created"}),t.jsx("option",{value:"modified",children:"Modified"})]})]}),S&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"From"}),t.jsx("input",{type:"date",value:C,onChange:Z=>O(Z.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-400 focus:outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"To"}),t.jsx("input",{type:"date",value:T,onChange:Z=>P(Z.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-400 focus:outline-none"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Sort By"}),t.jsxs("select",{value:E,onChange:Z=>R(Z.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-400 focus:outline-none",children:[t.jsx("option",{value:"creation desc",children:"Created (newest)"}),t.jsx("option",{value:"creation asc",children:"Created (oldest)"}),t.jsx("option",{value:"exp_end_date asc",children:"Due date (soonest)"}),t.jsx("option",{value:"priority desc",children:"Priority (high first)"})]})]})]})})]}),U&&t.jsx("div",{className:"mb-4 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg text-red-700 dark:text-red-300 text-sm",children:U}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden",children:[H?t.jsx("div",{className:"p-12 text-center text-gray-500 dark:text-gray-400",children:e("common.loading")}):q.length===0?t.jsxs("div",{className:"p-12 text-center",children:[t.jsx(bm,{className:"text-4xl text-gray-300 dark:text-gray-600 mx-auto mb-3"}),t.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:e("projects.noTasks")})]}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"w-10 px-4 py-3 text-left",children:t.jsx("button",{type:"button",onClick:Q,className:"text-gray-500 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors",title:ie?"Deselect all":"Select all","aria-label":"Select all on page",children:ie?t.jsx(Ra,{className:"text-indigo-600 dark:text-indigo-400",size:18}):me?t.jsxs("div",{className:"relative inline-block",children:[t.jsx(Ur,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Ur,{size:18})})}),[e("projects.taskColumn"),e("projects.project"),e("commonFields.status"),e("commonFields.priority"),e("projects.assignedTo"),e("projects.dueDate"),"Exp. Time",""].map(Z=>t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:Z},Z))]})}),t.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:q.map(Z=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${I.has(Z.name)?"bg-indigo-50 dark:bg-indigo-900/20":""}`,onClick:()=>r(`/projects/tasks/${Z.name}`),children:[t.jsx("td",{className:"w-10 px-4 py-3",onClick:M=>M.stopPropagation(),children:t.jsx("button",{type:"button",onClick:()=>B(Z.name),className:"text-gray-500 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors","aria-label":`Select ${Z.name}`,children:I.has(Z.name)?t.jsx(Ra,{className:"text-indigo-600 dark:text-indigo-400",size:18}):t.jsx(Ur,{size:18})})}),t.jsxs("td",{className:"px-6 py-4",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:Z.subject||Z.name}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:Z.name})]}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:Z.project?t.jsx("button",{onClick:M=>{M.stopPropagation(),r(`/projects/list/${Z.project}`)},className:"text-sm text-indigo-600 dark:text-indigo-400 hover:underline",children:Z.project}):t.jsx("span",{className:"text-gray-400 text-sm",children:"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${KNe(Z.status||"")}`,children:Z.status||"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${YNe(Z.priority||"")}`,children:Z.priority||"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:Z._assign&&JSON.parse(Z._assign)[0]||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:xe(Z.exp_end_date||"")}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:Z.expected_time?`${Z.expected_time}h`:"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",onClick:M=>M.stopPropagation(),children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>r(`/projects/tasks/${Z.name}`),className:"text-indigo-600 dark:text-indigo-400 hover:text-indigo-900 dark:hover:text-indigo-300 p-2 hover:bg-indigo-50 dark:hover:bg-indigo-900/30 rounded transition-colors",title:"View",children:t.jsx(Ps,{})}),t.jsx("button",{onClick:()=>K(Z.name),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:"Edit",children:t.jsx(qr,{})}),t.jsx("button",{onClick:()=>ye(Z.name),className:"text-purple-600 dark:text-purple-400 hover:text-purple-900 dark:hover:text-purple-300 p-2 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded transition-colors",title:"Duplicate",children:t.jsx(Vo,{})})]})})]},Z.name))})]})}),de>1&&t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 px-4 py-3",children:t.jsx(_l,{currentPage:i,totalPages:de,totalCount:re,pageSize:n,onPageChange:o})})]})]})},ZNe="/assets/asm_ui_app/asm_app/assets/ar_task_prompt-CTPTWoU4.mp3",XNe="/assets/asm_ui_app/asm_app/assets/en_task_prompt-MpN_x5Ld.mp3",qb=18,VD=window.SpeechRecognition||window.webkitSpeechRecognition;function QNe({onUpdateConfirmed:e,isSubmitting:r=!1}){const[a,s]=p.useState("prompted"),[n,i]=p.useState(""),[o,l]=p.useState(""),[c,u]=p.useState(Array(qb).fill(4)),[h,f]=p.useState("en"),y=p.useRef(null),b=p.useRef(null),w=p.useRef(null),v=p.useRef(null),k=p.useRef(null),S=p.useRef(null),N=p.useRef(""),C=h==="ar";p.useEffect(()=>{const ne=setTimeout(()=>T(h),800);return()=>{clearTimeout(ne),P()}},[]);const O=p.useRef(!0);p.useEffect(()=>{if(O.current){O.current=!1;return}if(a==="listening"||a==="preview"||a==="saved")return;window.speechSynthesis&&window.speechSynthesis.cancel(),s("prompted");const ne=h,te=setTimeout(()=>T(ne),400);return()=>clearTimeout(te)},[h]);function T(ne){const te=ne==="ar"?ZNe:XNe,Y=new Audio(te);Y.onended=()=>s("ready"),Y.onerror=()=>s("ready"),Y.play().catch(()=>s("ready"))}function P(){if(S.current&&clearTimeout(S.current),w.current&&cancelAnimationFrame(w.current),b.current&&(b.current.disconnect(),b.current=null),y.current&&(y.current.close(),y.current=null),k.current&&(k.current.getTracks().forEach(ne=>ne.stop()),k.current=null),v.current){try{v.current.stop()}catch(ne){}v.current=null}u(Array(qb).fill(4))}function E(){return J(this,null,function*(){try{let ne=function(){w.current=requestAnimationFrame(ne),q.getByteFrequencyData(U),u(Array.from({length:qb},(re,X)=>{const V=Math.floor(X*U.length/qb);return 4+U[V]/255*22}))};const te=yield navigator.mediaDevices.getUserMedia({audio:!0});k.current=te;const Y=new(window.AudioContext||window.webkitAudioContext);y.current=Y;const q=Y.createAnalyser();q.fftSize=64;const H=Y.createMediaStreamSource(te);b.current=H,H.connect(q);const U=new Uint8Array(q.frequencyBinCount);ne()}catch(ne){}})}function R(){return J(this,null,function*(){if(s("listening"),i(""),l(""),N.current="",yield E(),!VD){P(),s("ready");return}const ne=new VD;v.current=ne,ne.lang=C?"ar-SA":"en-US",ne.interimResults=!1,ne.continuous=!1,ne.maxAlternatives=1,ne.onresult=te=>{const Y=te.results[te.resultIndex];if(Y&&Y.isFinal){const q=Y[0].transcript.trim();N.current=q,i(q)}},ne.onend=()=>{P();const te=N.current.trim();te.length>0?(l(te),s("preview")):s("ready")},ne.onerror=()=>{P(),s("ready")},ne.start(),S.current=setTimeout(()=>{v.current&&v.current.stop()},15e3)})}function z(){v.current&&v.current.stop()}function G(){!o.trim()||r||(e(o.trim()),s("saved"))}function ae(){P(),i(""),l(""),N.current="",s("ready")}function ee(){P(),i(""),l(""),N.current="",s("prompted"),window.speechSynthesis&&window.speechSynthesis.cancel(),setTimeout(()=>T(h),400)}return t.jsxs("div",{style:Xr.card,children:[t.jsxs("div",{style:Xr.header,children:[t.jsx("div",{style:Xr.logo,children:"📝"}),t.jsxs("div",{style:Xr.brand,children:["SEERA",t.jsx("span",{style:Xr.brandAccent,children:"-ASM"})]}),t.jsx("span",{style:Xr.badge,children:"Task Update"})]}),t.jsx("div",{style:Xr.title,children:"Voice Task Update"}),t.jsx("div",{style:Xr.subtitle,children:"Speak your progress note — it will be added to Task Updates"}),t.jsx("div",{style:{display:"flex",gap:6,marginBottom:16,background:"#f1f5f9",borderRadius:10,padding:4},children:[{key:"en",label:"English"},{key:"ar",label:"عربي"}].map(({key:ne,label:te})=>t.jsx("button",{onClick:()=>f(ne),style:{flex:1,padding:"6px 0",borderRadius:7,border:"none",fontSize:12,fontWeight:600,cursor:"pointer",transition:"all 0.15s",background:h===ne?"#fff":"transparent",color:h===ne?"#7c3aed":"#64748b",boxShadow:h===ne?"0 1px 4px rgba(0,0,0,0.1)":"none"},children:te},ne))}),t.jsxs("div",{style:Xr.actionArea,children:[a==="prompted"&&t.jsxs("div",{style:se(se({},Xr.statusMsg),Xr.speakingMsg),children:[t.jsx("div",{style:Xr.speakingIcon,children:"🔊"}),t.jsx("div",{style:Xr.speakingText,children:C?"يرجى الانتظار…":"Please wait…"}),t.jsxs("div",{style:Xr.dots,children:[t.jsx("span",{style:Xr.dot}),t.jsx("span",{style:je(se({},Xr.dot),{animationDelay:"0.2s"})}),t.jsx("span",{style:je(se({},Xr.dot),{animationDelay:"0.4s"})})]})]}),a==="ready"&&t.jsxs("button",{style:Xr.speakBtn,onClick:R,children:[t.jsx("div",{style:Xr.speakBtnIcon,children:"🎙️"}),t.jsxs("div",{children:[t.jsx("span",{style:Xr.speakBtnTitle,children:C?"اضغط للتحدث":"Tap to Speak"}),t.jsx("span",{style:Xr.speakBtnHint,children:C?"تحدث عن تحديث مهمتك بوضوح":"Speak your task update clearly"})]})]}),a==="listening"&&t.jsxs("div",{style:Xr.listeningArea,children:[t.jsx("div",{style:Xr.micActive,children:"🔴"}),t.jsx("div",{style:Xr.waveform,children:c.map((ne,te)=>t.jsx("div",{style:je(se({},Xr.bar),{height:`${ne}px`})},te))}),t.jsx("div",{style:Xr.micLabel,children:C?"جاري الاستماع… تحدث الآن":"Listening… speak your update"}),n&&t.jsxs("div",{style:Xr.liveTranscript,children:[t.jsx("em",{style:{color:"#64748b",fontSize:12},children:C?"يسمع:":"Hearing:"}),t.jsx("p",{style:{margin:"4px 0 0",fontSize:13,color:"#1e293b",direction:C?"rtl":"ltr"},children:n})]}),t.jsx("button",{style:Xr.stopBtn,onClick:z,children:C?"⏹ انتهيت":"⏹ Done Speaking"})]}),a==="preview"&&t.jsxs("div",{style:Xr.previewArea,children:[t.jsx("div",{style:Xr.previewLabel,children:C?"✅ تم! راجع وعدّل إذا لزم:":"✅ Got it! Review and edit if needed:"}),t.jsx("textarea",{style:je(se({},Xr.textarea),{direction:C?"rtl":"ltr"}),value:o,onChange:ne=>l(ne.target.value),rows:4,placeholder:C?"نص التحديث…":"Your update text…",autoFocus:!0}),t.jsx("p",{style:Xr.previewHint,children:C?"📅 سيتم إضافة تاريخ اليوم تلقائياً":"📅 Today's date will be added automatically"})]}),a==="saved"&&t.jsx("div",{style:se(se({},Xr.statusMsg),Xr.savedMsg),children:C?"✅ تمت إضافة التحديث!":"✅ Update added to task!"})]}),t.jsxs("div",{style:Xr.actions,children:[a!=="saved"&&t.jsx("button",{style:Xr.ghostBtn,onClick:ee,disabled:r,children:C?"إعادة":"Reset"}),a==="listening"&&t.jsx("button",{style:je(se({},Xr.primaryBtn),{background:"#dc2626"}),onClick:z,children:C?"إيقاف":"Stop"}),a==="preview"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{style:Xr.ghostBtn,onClick:ae,children:C?"🔄 إعادة التسجيل":"🔄 Re-record"}),t.jsx("button",{style:se(se({},Xr.primaryBtn),r?Xr.disabledBtn:{}),onClick:G,disabled:r||!o.trim(),children:r?C?"جاري الحفظ…":"Saving…":C?"✅ إضافة التحديث":"✅ Add Update"})]}),a==="saved"&&t.jsx("button",{style:Xr.ghostBtn,onClick:ee,children:C?"إضافة تحديث آخر":"Add Another"})]})]})}const Xr={card:{background:"#ffffff",border:"1px solid #e2e8f0",borderRadius:16,padding:"28px 28px 24px",width:"100%",maxWidth:480,boxShadow:"0 8px 32px rgba(0,0,0,0.12)",fontFamily:"inherit",color:"#1e293b"},header:{display:"flex",alignItems:"center",gap:10,marginBottom:20},logo:{width:36,height:36,borderRadius:8,background:"linear-gradient(135deg,#8b5cf6,#7c3aed)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:16},brand:{fontWeight:700,fontSize:15,letterSpacing:"0.03em",color:"#1e293b"},brandAccent:{color:"#7c3aed"},badge:{marginLeft:"auto",background:"#f5f3ff",border:"1px solid #ddd6fe",color:"#6d28d9",fontSize:11,fontWeight:600,padding:"3px 10px",borderRadius:100},title:{fontSize:22,fontWeight:700,marginBottom:4},subtitle:{fontSize:13,color:"#64748b",marginBottom:12},actionArea:{display:"flex",flexDirection:"column",alignItems:"center",gap:12,marginBottom:20,minHeight:100,justifyContent:"center"},statusMsg:{display:"flex",alignItems:"center",gap:10,fontSize:14,fontWeight:600,padding:"16px 20px",borderRadius:10,width:"100%"},speakingMsg:{flexDirection:"column",background:"#f5f3ff",border:"1px solid #ddd6fe",color:"#7c3aed",gap:8},savedMsg:{background:"#f0fdf4",border:"1px solid #bbf7d0",color:"#16a34a",fontSize:16,justifyContent:"center"},speakingIcon:{fontSize:28},speakingText:{fontSize:14,fontWeight:600,color:"#7c3aed"},dots:{display:"flex",gap:4},dot:{display:"inline-block",width:6,height:6,borderRadius:"50%",background:"#8b5cf6",animation:"vsw-dot 1.2s ease-in-out infinite"},speakBtn:{width:"100%",padding:"14px 16px",borderRadius:12,border:"1px solid #ddd6fe",background:"#f5f3ff",color:"#5b21b6",fontFamily:"inherit",cursor:"pointer",display:"flex",alignItems:"center",gap:12,transition:"all 0.2s"},speakBtnIcon:{width:40,height:40,borderRadius:"50%",background:"#7c3aed",color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:18,flexShrink:0},speakBtnTitle:{display:"block",fontSize:15,fontWeight:600,color:"#5b21b6"},speakBtnHint:{display:"block",fontSize:11,color:"#8b5cf6",marginTop:2},listeningArea:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,width:"100%"},micActive:{fontSize:36},waveform:{display:"flex",alignItems:"center",gap:3,height:30},bar:{width:3,borderRadius:2,background:"linear-gradient(to top,#8b5cf6,#c4b5fd)",transition:"height 0.08s ease"},micLabel:{fontSize:13,color:"#ef4444",fontWeight:600},liveTranscript:{width:"100%",background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:"8px 12px",marginTop:4},stopBtn:{marginTop:8,padding:"8px 20px",borderRadius:8,border:"1px solid #fecaca",background:"#fef2f2",color:"#dc2626",fontFamily:"inherit",fontSize:13,fontWeight:600,cursor:"pointer"},previewArea:{width:"100%"},previewLabel:{fontSize:13,fontWeight:600,color:"#16a34a",marginBottom:8},textarea:{width:"100%",padding:"10px 12px",border:"1px solid #c4b5fd",borderRadius:8,fontSize:14,fontFamily:"inherit",color:"#1e293b",background:"#fafafa",resize:"vertical",outline:"none",boxSizing:"border-box"},previewHint:{fontSize:11,color:"#64748b",marginTop:6},actions:{display:"flex",gap:10},ghostBtn:{flex:1,padding:"10px 18px",borderRadius:8,border:"1px solid #e2e8f0",background:"#f1f5f9",color:"#475569",fontFamily:"inherit",fontSize:14,fontWeight:600,cursor:"pointer"},primaryBtn:{flex:1,padding:"10px 18px",borderRadius:8,border:"none",background:"#7c3aed",color:"#fff",fontFamily:"inherit",fontSize:14,fontWeight:600,cursor:"pointer"},disabledBtn:{opacity:.45,cursor:"not-allowed"}};function e4e(){const e=new Date,r=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return`${r}-${a}-${s}`}const t4e=({isOpen:e,onClose:r,taskName:a,onUpdateSuccess:s})=>{const[n,i]=p.useState(!1),[o,l]=p.useState("");if(!e)return null;const c=u=>J(null,null,function*(){if(!(!a||!u.trim())){i(!0),l("");try{const f=yield(yield fetch(`/api/resource/Task/${encodeURIComponent(a)}`,{credentials:"include"})).json();if(f.exc||f.exception)throw new Error(f.exc||f.exception||"Failed to fetch task");const b=(f.data.custom_task_updates||[]).map(N=>({name:N.name,update_:N.update_,date:N.date,task:N.task})),w={doctype:"Updates",update_:u.trim(),date:e4e(),task:a},v=[...b,w],S=yield(yield fetch(`/api/resource/Task/${encodeURIComponent(a)}`,{method:"PUT",headers:{"Content-Type":"application/json","X-Frappe-CSRF-Token":window.csrf_token||"fetch"},credentials:"include",body:JSON.stringify({custom_task_updates:v})})).json();if(S.exc||S.exception)throw new Error(S.exc||S.exception||"Failed to save update");r(),s()}catch(h){const f=h instanceof Error?h.message:"Unknown error";l(`Failed to save: ${f}`)}finally{i(!1)}}});return t.jsxs("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[80] p-4",onClick:u=>{u.target===u.currentTarget&&!n&&r()},children:[t.jsxs("div",{className:"relative animate-scale-in",children:[t.jsx("button",{onClick:()=>{n||r()},className:"absolute -top-3 -right-3 z-10 w-8 h-8 rounded-full bg-gray-600 hover:bg-gray-500 text-white flex items-center justify-center shadow-lg transition-colors",disabled:n,title:"Close",children:t.jsx(ht,{size:12})}),o&&t.jsxs("div",{className:"mb-3 px-4 py-2 bg-red-50 border border-red-300 rounded-lg text-red-700 text-sm font-medium flex items-center gap-2",children:["⚠️ ",o,t.jsx("button",{onClick:()=>l(""),className:"ml-auto text-red-400 hover:text-red-600",children:t.jsx(ht,{size:10})})]}),t.jsx(QNe,{onUpdateConfirmed:c,isSubmitting:n})]}),t.jsx("style",{children:`
|
||
@keyframes scale-in {
|
||
from { transform: scale(0.92); opacity: 0; }
|
||
to { transform: scale(1); opacity: 1; }
|
||
}
|
||
.animate-scale-in { animation: scale-in 0.2s ease-out; }
|
||
`})]})},r4e=["Open","Raised","Warning","Penalty","Change Requests","Problems","Letter"],z0=({title:e,icon:r,defaultOpen:a=!0,children:s,headerExtra:n})=>{const[i,o]=p.useState(a);return t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden shadow-sm",children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5 hover:bg-gray-50 dark:hover:bg-gray-700/30 transition-colors",children:[t.jsxs("button",{type:"button",onClick:()=>o(l=>!l),className:"flex items-center gap-2 text-sm font-semibold text-gray-700 dark:text-gray-200 flex-1 text-left",children:[r,t.jsx("span",{children:e})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[n,t.jsx("button",{type:"button",onClick:()=>o(l=>!l),children:i?t.jsx(Fr,{className:"text-gray-400 text-xs flex-shrink-0"}):t.jsx(Fi,{className:"text-gray-400 text-xs flex-shrink-0"})})]})]}),i&&t.jsx("div",{className:"px-5 py-5 bg-white dark:bg-gray-800 border-t border-gray-100 dark:border-gray-700/50",children:s})]})},Os=({children:e,required:r})=>t.jsxs("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:[e,r&&t.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),an=({children:e})=>t.jsx("div",{className:"px-3 py-2 text-sm text-gray-800 dark:text-gray-200 bg-gray-50 dark:bg-gray-900/30 rounded-lg min-h-[36px] flex items-center border border-transparent",children:e||t.jsx("span",{className:"text-gray-400 dark:text-gray-600",children:"-"})}),GD=e=>{switch(e==null?void 0:e.toLowerCase()){case"open":return"bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300";case"working":return"bg-amber-100 text-amber-800 dark:bg-amber-900/40 dark:text-amber-300";case"pending review":return"bg-purple-100 text-purple-800 dark:bg-purple-900/40 dark:text-purple-300";case"completed":return"bg-green-100 text-green-800 dark:bg-green-900/40 dark:text-green-300";case"cancelled":return"bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400";case"overdue":return"bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300";default:return"bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400"}},KD=e=>{switch(e==null?void 0:e.toLowerCase()){case"high":return"bg-red-100 text-red-800 dark:bg-red-900/40 dark:text-red-300";case"medium":return"bg-orange-100 text-orange-800 dark:bg-orange-900/40 dark:text-orange-300";case"low":return"bg-green-100 text-green-800 dark:bg-green-900/40 dark:text-green-300";case"urgent":return"bg-red-200 text-red-900 dark:bg-red-800/50 dark:text-red-200";default:return"bg-gray-100 text-gray-600"}},Vb=e=>e?new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-",YD=tB,a4e=()=>{var he,de,xe,ge,be,K,ye,Z;const{t:e}=sr(),{taskName:r}=hs(),a=hr(),[s]=_a(),n=r==="new",i=p.useMemo(()=>!n&&(s.get("edit")||"")==="1",[n,s]),o=p.useMemo(()=>n&&s.get("duplicate")||"",[n,s]),[l,c]=p.useState(!1),{task:u,loading:h,error:f,refetch:y}=MNe(n?null:r||null),{createTask:b,updateTask:w,loading:v}=oy(),[k,S]=p.useState(n),[N,C]=p.useState(!1),T={subject:"",project:n&&s.get("project")||"",status:"Open",priority:"Medium",task_weight:0,is_group:0,is_template:0,is_milestone:0,exp_start_date:"",exp_end_date:"",expected_time:0,progress:0,completed_on:"",custom_risk:"",custom_action:"",custom_task_obstacle:"",description:"",color:"",department:"",company:un,parent_task:"",custom_assign_to:""},[P,E]=p.useState(T);p.useEffect(()=>{i&&S(!0)},[i]),p.useEffect(()=>{if(!n||!o)return;let M=!1;return c(!0),Dr.getTask(o).then(we=>{if(M)return;E(le=>je(se(se({},le),we),{name:"",subject:we.subject?`${we.subject} (Copy)`:"",status:"Open",progress:0}));const pe=we[_f]||[];ae(pe.map(le=>({update_:le.update_,date:le.date?String(le.date).slice(0,10):""}))),S(!0)}).catch(()=>{}).finally(()=>{M||c(!1)}),()=>{M=!0}},[n,o]);const[R,z]=p.useState([]),[G,ae]=p.useState([]),[ee,ne]=p.useState(null);p.useEffect(()=>{P.parent_task?Dr.getTask(P.parent_task).then(M=>ne({subject:M.subject,status:M.status})).catch(()=>ne({})):ne(null)},[P.parent_task]);const te=M=>{var we,pe,le,Fe,ze,Re;E({subject:M.subject||"",project:M.project||"",status:M.status||"Open",priority:M.priority||"Medium",task_weight:(we=M.task_weight)!=null?we:0,is_group:(pe=M.is_group)!=null?pe:0,is_template:(le=M.is_template)!=null?le:0,is_milestone:(Fe=M.is_milestone)!=null?Fe:0,exp_start_date:M.exp_start_date||"",exp_end_date:M.exp_end_date||"",expected_time:(ze=M.expected_time)!=null?ze:0,progress:(Re=M.progress)!=null?Re:0,description:M.description||"",color:M.color||"",department:M.department||"",company:M.company||un,parent_task:M.parent_task||"",custom_assign_to:M.custom_assign_to||"",completed_on:M.completed_on?String(M.completed_on).slice(0,10):"",custom_risk:M.custom_risk||"",custom_action:M.custom_action||"",custom_task_obstacle:M.custom_task_obstacle||""}),z(M.depends_on||[]),ae((M[_f]||[]).map(De=>({name:De.name,update_:De.update_,date:De.date?String(De.date).slice(0,10):"",task:De.task})))};p.useEffect(()=>{u&&!n&&te(u)},[u,n]),p.useEffect(()=>{n&&!o&&ae([])},[n,o]);const Y=(M,we)=>E(pe=>je(se({},pe),{[M]:we})),q=n||k,H="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-amber-400 focus:outline-none",U="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-amber-400 focus:outline-none",re=()=>z(M=>[...M,{task:"",subject:"",_isNew:!0}]),X=(M,we)=>J(null,null,function*(){if(z(pe=>pe.map((le,Fe)=>Fe===M?je(se({},le),{task:we,subject:""}):le)),!!we)try{const pe=yield Dr.getTask(we);z(le=>le.map((Fe,ze)=>ze===M?je(se({},Fe),{task:we,subject:pe.subject||we}):Fe))}catch(pe){}}),V=M=>{z(we=>we.filter((pe,le)=>le!==M))},I=()=>ae(M=>[...M,{}]),B=M=>ae(we=>we.filter((pe,le)=>le!==M)),Q=()=>{y(),We.success("Voice update added!",{icon:t.jsx(Qt,{})})},ie=()=>J(null,null,function*(){var M;if(!((M=P.subject)!=null&&M.trim())){We.error("Task Subject is required",{icon:t.jsx(pr,{})});return}if(P.status==="Completed"&&!String(P.completed_on||"").trim()){We.error("Completed On: This field is mandatory",{icon:t.jsx(pr,{})});return}try{const we={subject:P.subject,project:P.project||void 0,status:P.status,priority:P.priority,task_weight:P.task_weight,is_group:P.is_group,is_template:P.is_template,is_milestone:P.is_milestone,expected_time:P.expected_time,progress:P.progress,description:P.description,department:P.department||void 0,company:P.company||void 0,parent_task:P.parent_task||void 0,custom_assign_to:P.custom_assign_to||void 0,depends_on:R.filter(pe=>pe.task).map((pe,le)=>({task:pe.task,idx:le+1})),custom_risk:P.custom_risk||void 0,custom_action:P.custom_action||void 0,custom_task_obstacle:P.custom_task_obstacle||void 0};if(P.exp_start_date&&(we.exp_start_date=P.exp_start_date),P.exp_end_date&&(we.exp_end_date=P.exp_end_date),P.status==="Completed"?we.completed_on=P.completed_on:we.completed_on=null,n){const pe=yield b(we),le=MN(G,{fillTaskLink:pe.name});le.length&&(yield w(pe.name,{[_f]:le})),We.success("Task created",{icon:t.jsx(Qt,{})}),S(!1),a(`/projects/tasks/${pe.name}`)}else yield w(r,je(se({},we),{[_f]:MN(G,{fillTaskLink:r})})),We.success("Task saved",{icon:t.jsx(Qt,{})}),S(!1),y()}catch(we){We.error(we instanceof Error?we.message:"Error saving task",{icon:t.jsx(pr,{})})}}),me=()=>{u&&te(u),S(!1)};return h&&!n?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-amber-500"})}):!n&&(f||!u)?t.jsxs("div",{className:"p-6",children:[t.jsxs("button",{onClick:()=>a("/projects/tasks"),className:"flex items-center gap-2 text-gray-600 mb-4 text-sm hover:text-gray-900",children:[t.jsx(ia,{})," Back to Tasks"]}),t.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 rounded-lg text-red-700 dark:text-red-300",children:f||"Task not found"})]}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900",children:[t.jsx($a,{position:"top-right",autoClose:3500}),!n&&r&&t.jsx(t4e,{isOpen:N,onClose:()=>C(!1),taskName:r,onUpdateSuccess:Q}),t.jsx("div",{className:"bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 shadow-sm",children:t.jsxs("div",{className:"px-6 py-4",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs mb-3 text-gray-400 dark:text-gray-500",children:[t.jsx("button",{onClick:()=>a("/projects"),className:"hover:text-amber-600 dark:hover:text-amber-400 transition-colors",children:e("projects.moduleTitle","Project Management")}),t.jsx("span",{children:"/"}),t.jsx("button",{onClick:()=>a("/projects/tasks"),className:"hover:text-amber-600 dark:hover:text-amber-400 transition-colors",children:e("projects.tasksDoctype","Tasks")}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-gray-600 dark:text-gray-300 font-medium",children:n?"New Task":(u==null?void 0:u.subject)||r})]}),t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[t.jsx("button",{onClick:()=>a("/projects/tasks"),className:"mt-1 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 flex-shrink-0 transition-colors",children:t.jsx(ia,{})}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[t.jsx("div",{className:"w-9 h-9 rounded-lg bg-amber-500 flex items-center justify-center flex-shrink-0 shadow-sm",children:t.jsx(bm,{className:"text-white text-sm"})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white leading-tight",children:n?"New Task":(u==null?void 0:u.subject)||r}),!n&&t.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:r})]})]}),!n&&u&&t.jsxs("div",{className:"flex items-center flex-wrap gap-2 mt-2 ml-12",children:[t.jsx("span",{className:`px-2.5 py-0.5 rounded-full text-xs font-semibold ${GD(u.status||"")}`,children:u.status||"Open"}),t.jsx("span",{className:`px-2.5 py-0.5 rounded-full text-xs font-semibold ${KD(u.priority||"")}`,children:u.priority||"-"}),u.project&&t.jsx("button",{onClick:()=>a(`/projects/list/${u.project}`),className:"text-xs text-indigo-600 dark:text-indigo-400 border border-indigo-200 dark:border-indigo-700 rounded-full px-2.5 py-0.5 hover:underline",children:u.project}),u.progress!==void 0&&u.progress>0&&t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400",children:[t.jsx("div",{className:"w-20 h-1.5 bg-gray-200 dark:bg-gray-600 rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-amber-500 rounded-full",style:{width:`${Math.min(u.progress,100)}%`}})}),t.jsxs("span",{className:"font-medium",children:[u.progress,"%"]})]})]})]})]}),t.jsxs("div",{className:"flex gap-2 flex-wrap flex-shrink-0",children:[!n&&t.jsxs("button",{onClick:()=>{const M=new URLSearchParams;u!=null&&u.project&&M.set("project",u.project),M.set("task",(u==null?void 0:u.name)||r||""),a(`/projects/timesheets/new?${M.toString()}`)},className:"flex items-center gap-2 px-4 py-2 border border-green-500 text-green-600 dark:text-green-400 rounded-lg hover:bg-green-50 dark:hover:bg-green-900/20 text-sm transition-colors",title:"Create a timesheet for this task",children:[t.jsx(ea,{size:13})," Create Timesheet"]}),!k&&!n&&t.jsxs("button",{onClick:()=>S(!0),className:"flex items-center gap-2 px-4 py-2 bg-amber-500 text-white rounded-lg hover:bg-amber-600 text-sm transition-colors shadow-sm",children:[t.jsx(qr,{size:13})," Edit"]}),(k||n)&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:ie,disabled:v,className:"flex items-center gap-2 px-4 py-2 bg-amber-500 text-white rounded-lg hover:bg-amber-600 disabled:opacity-50 text-sm shadow-sm",children:[v?t.jsx(tr,{className:"animate-spin",size:13}):t.jsx(ta,{size:13}),v?"Saving…":"Save"]}),!n&&t.jsxs("button",{onClick:me,className:"flex items-center gap-1.5 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg text-sm text-gray-600 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700/50",children:[t.jsx(ht,{size:13})," Cancel"]})]})]})]})]})}),t.jsxs("div",{className:"px-6 py-6 space-y-3",children:[t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm px-5 py-5",children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-4",children:[t.jsxs("div",{className:"sm:col-span-2",children:[t.jsx(Os,{required:!0,children:"Subject"}),q?t.jsx("input",{type:"text",value:P.subject||"",onChange:M=>Y("subject",M.target.value),className:H,placeholder:"Enter task subject"}):t.jsx(an,{children:P.subject})]}),t.jsxs("div",{children:[t.jsx(Os,{children:"Status"}),q?t.jsxs("select",{value:P.status||"Open",onChange:M=>Y("status",M.target.value),className:U,children:[t.jsx("option",{value:"Open",children:"Open"}),t.jsx("option",{value:"Working",children:"Working"}),t.jsx("option",{value:"Pending Review",children:"Pending Review"}),t.jsx("option",{value:"Overdue",children:"Overdue"}),t.jsx("option",{value:"Template",children:"Template"}),t.jsx("option",{value:"Completed",children:"Completed"}),t.jsx("option",{value:"Cancelled",children:"Cancelled"})]}):t.jsx(an,{children:t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${GD(P.status||"")}`,children:P.status})})]}),P.status==="Completed"&&t.jsxs("div",{children:[t.jsx(Os,{required:!0,children:"Completed On"}),q?t.jsx("input",{type:"date",value:P.completed_on||"",onChange:M=>Y("completed_on",M.target.value),className:H}):t.jsx(an,{children:Vb(P.completed_on)})]}),t.jsxs("div",{children:[t.jsx(Os,{children:"Project"}),q?t.jsx(Je,{label:"Project",hideLabel:!0,doctype:"Project",value:P.project||"",onChange:M=>Y("project",M),placeholder:"Link to project…"}):t.jsx(an,{children:P.project?t.jsx("button",{onClick:()=>a(`/projects/list/${P.project}`),className:"text-indigo-600 dark:text-indigo-400 hover:underline",children:P.project}):"-"})]}),t.jsxs("div",{children:[t.jsx(Os,{children:"Risk"}),q?t.jsxs("select",{value:P.custom_risk||"",onChange:M=>Y("custom_risk",M.target.value),className:U,children:[t.jsx("option",{value:"",children:"—"}),t.jsx("option",{value:"Yes",children:"Yes"}),t.jsx("option",{value:"No",children:"No"})]}):t.jsx(an,{children:P.custom_risk||"—"})]}),t.jsxs("div",{children:[t.jsx(Os,{children:"Action"}),q?t.jsxs("select",{value:P.custom_action||"",onChange:M=>Y("custom_action",M.target.value),className:U,children:[t.jsx("option",{value:"",children:"—"}),r4e.map(M=>t.jsx("option",{value:M,children:M},M))]}):t.jsx(an,{children:P.custom_action||"—"})]}),t.jsxs("div",{children:[t.jsx(Os,{children:"Priority"}),q?t.jsxs("select",{value:P.priority||"Medium",onChange:M=>Y("priority",M.target.value),className:U,children:[t.jsx("option",{value:"Low",children:"Low"}),t.jsx("option",{value:"Medium",children:"Medium"}),t.jsx("option",{value:"High",children:"High"}),t.jsx("option",{value:"Urgent",children:"Urgent"})]}):t.jsx(an,{children:t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${KD(P.priority||"")}`,children:P.priority})})]}),t.jsxs("div",{children:[t.jsx(Os,{children:"Weight"}),q?t.jsx("input",{type:"number",min:0,step:.1,value:(he=P.task_weight)!=null?he:0,onChange:M=>Y("task_weight",parseFloat(M.target.value)||0),className:H}):t.jsx(an,{children:(de=P.task_weight)!=null?de:0})]}),t.jsxs("div",{children:[t.jsx(Os,{children:"Parent Task"}),q?t.jsx(Je,{label:"Parent Task",hideLabel:!0,doctype:"Task",value:P.parent_task||"",onChange:M=>Y("parent_task",M),placeholder:"Select parent task…",filters:{is_group:1}}):t.jsx(an,{children:P.parent_task?t.jsx("button",{onClick:()=>a(`/projects/tasks/${P.parent_task}`),className:"text-indigo-600 dark:text-indigo-400 hover:underline",children:P.parent_task}):"-"})]}),t.jsxs("div",{children:[t.jsx(Os,{children:"Assign to"}),q?t.jsx(Je,{label:"Assign to",hideLabel:!0,doctype:"User",value:P.custom_assign_to||"",onChange:M=>Y("custom_assign_to",M),placeholder:"Select user…"}):t.jsx(an,{children:P.custom_assign_to||"—"})]}),t.jsx("div",{className:"sm:col-span-2 flex flex-wrap gap-6 pt-1",children:[{key:"is_group",label:"Is Group"},{key:"is_template",label:"Is Template"}].map(({key:M,label:we})=>t.jsxs("label",{className:`flex items-center gap-2 ${q?"cursor-pointer":"cursor-default"}`,children:[t.jsx("input",{type:"checkbox",checked:!!P[M],onChange:pe=>Y(M,pe.target.checked?1:0),disabled:!q,className:"w-4 h-4 text-amber-500 border-gray-300 rounded focus:ring-amber-400"}),t.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 font-medium",children:we})]},M))})]})}),t.jsx(z0,{title:"Timeline",icon:t.jsx(rc,{className:"text-indigo-500",size:13}),defaultOpen:!0,children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-4",children:[t.jsxs("div",{children:[t.jsx(Os,{children:"Expected Start Date"}),q?t.jsx("input",{type:"date",value:P.exp_start_date||"",onChange:M=>Y("exp_start_date",M.target.value),className:H}):t.jsx(an,{children:Vb(P.exp_start_date)})]}),t.jsxs("div",{children:[t.jsx(Os,{children:"Expected End Date"}),q?t.jsx("input",{type:"date",value:P.exp_end_date||"",onChange:M=>Y("exp_end_date",M.target.value),className:H}):t.jsx(an,{children:Vb(P.exp_end_date)})]}),t.jsxs("div",{children:[t.jsx(Os,{children:"Expected Time (In hours)"}),q?t.jsx("input",{type:"number",min:0,step:.5,value:(xe=P.expected_time)!=null?xe:0,onChange:M=>Y("expected_time",parseFloat(M.target.value)||0),className:H}):t.jsx(an,{children:(ge=P.expected_time)!=null?ge:0})]}),t.jsxs("div",{children:[t.jsx(Os,{children:"% Progress"}),q?t.jsx("input",{type:"number",min:0,max:100,value:(be=P.progress)!=null?be:0,onChange:M=>Y("progress",parseInt(M.target.value)||0),className:H}):t.jsx(an,{children:t.jsxs("div",{className:"flex items-center gap-2 w-full",children:[t.jsx("div",{className:"flex-1 h-2 bg-gray-200 dark:bg-gray-600 rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-amber-500 rounded-full",style:{width:`${Math.min((K=P.progress)!=null?K:0,100)}%`}})}),t.jsxs("span",{className:"text-sm font-medium min-w-[36px] text-right",children:[(ye=P.progress)!=null?ye:0,"%"]})]})})]}),t.jsx("div",{className:"sm:col-span-2",children:t.jsxs("label",{className:`flex items-center gap-2 ${q?"cursor-pointer":"cursor-default"}`,children:[t.jsx("input",{type:"checkbox",checked:!!P.is_milestone,onChange:M=>Y("is_milestone",M.target.checked?1:0),disabled:!q,className:"w-4 h-4 text-amber-500 border-gray-300 rounded focus:ring-amber-400"}),t.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 font-medium",children:"Is Milestone"})]})})]})}),t.jsx(z0,{title:"Task Updates",icon:t.jsx(q9,{className:"text-violet-500",size:13}),defaultOpen:!0,headerExtra:!n&&r?t.jsxs("button",{type:"button",onClick:M=>{M.stopPropagation(),C(!0)},className:"flex items-center gap-1.5 px-3 py-1 bg-purple-600 hover:bg-purple-700 text-white text-xs font-medium rounded-lg transition-colors shadow-sm",title:"Add a voice update",children:[t.jsx(Q4,{size:10}),"Voice Update"]}):null,children:t.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:[t.jsxs("div",{className:`grid ${q?"grid-cols-[40px_1fr_8rem_36px]":"grid-cols-[40px_1fr_8rem]"} bg-gray-50 dark:bg-gray-900/50 border-b border-gray-200 dark:border-gray-700`,children:[t.jsx("div",{className:"px-3 py-2 text-xs font-medium text-gray-500 uppercase",children:"No."}),t.jsx("div",{className:"px-3 py-2 text-xs font-medium text-gray-500 uppercase",children:"Update"}),t.jsx("div",{className:"px-3 py-2 text-xs font-medium text-gray-500 uppercase",children:"Date"}),q&&t.jsx("div",{className:"py-2 w-9"})]}),G.length===0?t.jsx("div",{className:"py-8 text-center text-sm text-gray-400 italic",children:"No updates yet."}):t.jsx("div",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:G.map((M,we)=>t.jsxs("div",{className:`grid ${q?"grid-cols-[40px_1fr_8rem_36px]":"grid-cols-[40px_1fr_8rem]"} items-center hover:bg-gray-50/80 dark:hover:bg-gray-800/40`,children:[t.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 font-medium",children:we+1}),t.jsx("div",{className:"px-3 py-1.5 min-w-0",children:q?t.jsx("input",{type:"text",value:M.update_||"",onChange:pe=>ae(le=>le.map((Fe,ze)=>ze===we?je(se({},Fe),{update_:pe.target.value}):Fe)),className:H,placeholder:"Update text…"}):t.jsx("span",{className:"text-sm text-gray-800 dark:text-gray-200",children:M.update_||"—"})}),t.jsx("div",{className:"px-3 py-1.5",children:q?t.jsx("input",{type:"date",value:M.date?String(M.date).slice(0,10):"",onChange:pe=>ae(le=>le.map((Fe,ze)=>ze===we?je(se({},Fe),{date:pe.target.value}):Fe)),className:H}):t.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:M.date?Vb(String(M.date).slice(0,10)):"—"})}),q&&t.jsx("div",{className:"flex justify-center",children:t.jsx("button",{type:"button",onClick:()=>B(we),className:"p-1.5 text-red-400 hover:text-red-600 rounded transition-colors",title:"Remove row",children:t.jsx(wr,{size:11})})})]},M.name||`row-${we}`))}),q&&t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 px-3 py-2 bg-gray-50 dark:bg-gray-900/30",children:t.jsxs("button",{type:"button",onClick:I,className:"flex items-center gap-1.5 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 font-medium",children:[t.jsx(Rr,{size:10})," Add Row"]})})]})}),t.jsx(z0,{title:"Details",icon:t.jsx(X4,{className:"text-gray-400",size:13}),defaultOpen:!1,children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx(Os,{children:"Task Description"}),q?t.jsx("textarea",{rows:6,value:P.description||"",onChange:M=>Y("description",M.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-amber-400 focus:outline-none resize-y",placeholder:"Task description…"}):t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap min-h-[60px] leading-relaxed",children:P.description||t.jsx("span",{className:"text-gray-400 italic",children:"No description"})})]}),t.jsxs("div",{children:[t.jsx(Os,{children:"Task Obstacles"}),q?t.jsx("textarea",{rows:4,value:P.custom_task_obstacle||"",onChange:M=>Y("custom_task_obstacle",M.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-amber-400 focus:outline-none resize-y",placeholder:"Describe obstacles…"}):t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap min-h-[48px] leading-relaxed",children:P.custom_task_obstacle||t.jsx("span",{className:"text-gray-400 italic",children:"—"})})]})]})}),t.jsx(z0,{title:"Dependencies",icon:t.jsx(ov,{className:"text-blue-500",size:13}),defaultOpen:!0,children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx(Os,{children:"Dependent Tasks"}),t.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:[t.jsxs("div",{className:`grid ${q?"grid-cols-[40px_1fr_1fr_36px]":"grid-cols-[40px_1fr_1fr]"} bg-gray-50 dark:bg-gray-900/50 border-b border-gray-200 dark:border-gray-700`,children:[t.jsx("div",{className:"px-3 py-2 text-xs font-medium text-gray-500 uppercase",children:"No."}),t.jsx("div",{className:"px-3 py-2 text-xs font-medium text-gray-500 uppercase",children:"Task"}),t.jsx("div",{className:"px-3 py-2 text-xs font-medium text-gray-500 uppercase",children:"Subject"}),q&&t.jsx("div",{className:"py-2 w-9"})]}),R.length===0?t.jsx("div",{className:"py-8 text-center text-sm text-gray-400 dark:text-gray-500 italic",children:"No Data"}):t.jsx("div",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:R.map((M,we)=>t.jsxs("div",{className:`grid ${q?"grid-cols-[40px_1fr_1fr_36px]":"grid-cols-[40px_1fr_1fr]"} items-center hover:bg-gray-50 dark:hover:bg-gray-700/30`,children:[t.jsx("div",{className:"px-3 py-2.5 text-xs text-gray-500 dark:text-gray-400 font-medium",children:we+1}),t.jsx("div",{className:"px-3 py-1.5",children:q?t.jsx(Je,{label:"Task",hideLabel:!0,doctype:"Task",value:M.task||"",onChange:pe=>X(we,pe),placeholder:"Select task…",compact:!0}):t.jsx("button",{onClick:()=>M.task&&a(`/projects/tasks/${M.task}`),className:"text-sm text-indigo-600 dark:text-indigo-400 hover:underline",children:M.task||"-"})}),t.jsx("div",{className:"px-3 py-2.5",children:t.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:M.subject||(M.task?t.jsx("span",{className:"text-gray-400 italic text-xs",children:"fetching…"}):"-")})}),q&&t.jsx("div",{className:"flex justify-center",children:t.jsx("button",{type:"button",onClick:()=>V(we),className:"p-1.5 text-red-400 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors",title:"Remove row",children:t.jsx(wr,{size:11})})})]},we))}),q&&t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 px-3 py-2 bg-gray-50 dark:bg-gray-900/30",children:t.jsxs("button",{type:"button",onClick:re,className:"flex items-center gap-1.5 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 font-medium transition-colors",children:[t.jsx(Rr,{size:10})," Add Row"]})})]})]}),!n&&t.jsxs("div",{children:[t.jsx(Os,{children:"Actual Time In Hours (via Timesheet)"}),t.jsx(an,{children:(Z=u==null?void 0:u.actual_time)!=null?Z:0})]})]})}),!n&&t.jsx(z0,{title:"Costing",icon:t.jsx(Zu,{className:"text-emerald-500",size:13}),defaultOpen:!1,children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-4",children:[t.jsxs("div",{children:[t.jsx(Os,{children:"Total Costing Amount (via Timesheet)"}),t.jsx(an,{children:YD(u==null?void 0:u.total_costing_amount)})]}),t.jsxs("div",{children:[t.jsx(Os,{children:"Total Billable Amount (via Timesheet)"}),t.jsx(an,{children:YD(u==null?void 0:u.total_billing_amount)})]})]})}),!n&&(P.parent_task||R.length>0)&&t.jsx(z0,{title:"Task Hierarchy",icon:t.jsx(Y9,{className:"text-purple-500",size:13}),defaultOpen:!0,children:t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute left-[19px] top-0 bottom-0 w-0.5 bg-gradient-to-b from-purple-200 via-indigo-200 to-indigo-100 dark:from-purple-700 dark:via-indigo-700 dark:to-indigo-800"}),t.jsxs("div",{className:"space-y-2 ml-1",children:[P.parent_task&&t.jsxs("div",{className:"flex items-center gap-3 relative",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-purple-100 dark:bg-purple-900/40 border-2 border-purple-300 dark:border-purple-600 flex items-center justify-center flex-shrink-0 z-10",children:t.jsx("svg",{className:"w-4 h-4 text-purple-600 dark:text-purple-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),t.jsx("button",{onClick:()=>a(`/projects/tasks/${P.parent_task}`),className:"flex-1 text-left px-4 py-2.5 rounded-xl bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-700 hover:bg-purple-100 dark:hover:bg-purple-900/40 transition-colors group",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-semibold text-purple-500 dark:text-purple-400 uppercase tracking-wide mb-0.5",children:"Parent Task"}),t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white group-hover:text-purple-700 dark:group-hover:text-purple-300",children:(ee==null?void 0:ee.subject)||P.parent_task}),t.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mt-0.5",children:P.parent_task})]}),(ee==null?void 0:ee.status)&&t.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-purple-100 dark:bg-purple-800 text-purple-700 dark:text-purple-300 font-medium",children:ee.status})]})})]}),t.jsxs("div",{className:"flex items-center gap-3 relative",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-indigo-500 border-2 border-indigo-400 flex items-center justify-center flex-shrink-0 z-10 shadow-md",children:t.jsx(bm,{className:"text-white",size:14})}),t.jsxs("div",{className:"flex-1 px-4 py-2.5 rounded-xl bg-indigo-50 dark:bg-indigo-900/30 border-2 border-indigo-300 dark:border-indigo-600 shadow-sm",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-semibold text-indigo-500 dark:text-indigo-400 uppercase tracking-wide mb-0.5",children:"Current Task"}),t.jsx("p",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:P.subject||(u==null?void 0:u.name)}),t.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mt-0.5",children:u==null?void 0:u.name})]}),t.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${P.status==="Completed"?"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300":P.status==="Working"?"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":P.status==="Overdue"?"bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300":"bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-400"}`,children:P.status})]}),P.progress!==void 0&&t.jsx("div",{className:"mt-2",children:t.jsx("div",{className:"h-1.5 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-indigo-500 rounded-full transition-all",style:{width:`${P.progress}%`}})})})]})]}),R.filter(M=>M.task).map((M,we)=>t.jsxs("div",{className:"flex items-center gap-3 relative",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-teal-100 dark:bg-teal-900/40 border-2 border-teal-300 dark:border-teal-600 flex items-center justify-center flex-shrink-0 z-10",children:t.jsx("svg",{className:"w-4 h-4 text-teal-600 dark:text-teal-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),t.jsx("button",{onClick:()=>a(`/projects/tasks/${M.task}`),className:"flex-1 text-left px-4 py-2.5 rounded-xl bg-teal-50 dark:bg-teal-900/20 border border-teal-200 dark:border-teal-700 hover:bg-teal-100 dark:hover:bg-teal-900/40 transition-colors group",children:t.jsxs("div",{children:[t.jsxs("p",{className:"text-xs font-semibold text-teal-500 dark:text-teal-400 uppercase tracking-wide mb-0.5",children:["Depends on #",we+1]}),t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white group-hover:text-teal-700 dark:group-hover:text-teal-300",children:M.subject||M.task}),M.subject&&M.task!==M.subject&&t.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mt-0.5",children:M.task})]})})]},we))]})]})}),t.jsx(z0,{title:"More Info",icon:t.jsx(ro,{className:"text-gray-400",size:13}),defaultOpen:!1,children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-4",children:[t.jsxs("div",{children:[t.jsx(Os,{children:"Department"}),q?t.jsx(Je,{label:"Department",hideLabel:!0,doctype:"Department",value:P.department||"",onChange:M=>Y("department",M),placeholder:"Select department…",allowQuickCreate:!0}):t.jsx(an,{children:P.department||"-"})]}),t.jsxs("div",{children:[t.jsx(Os,{children:"Company"}),q?t.jsx(Je,{label:"Company",hideLabel:!0,doctype:"Company",value:P.company||"",onChange:M=>Y("company",M),placeholder:"Select company…"}):t.jsx(an,{children:P.company||"-"})]}),!n&&(u==null?void 0:u.template_task)&&t.jsxs("div",{children:[t.jsx(Os,{children:"Template Task"}),t.jsx(an,{children:t.jsx("button",{onClick:()=>a(`/projects/tasks/${u.template_task}`),className:"text-indigo-600 dark:text-indigo-400 hover:underline",children:u.template_task})})]})]})}),!n&&t.jsx(vi,{doctype:"Task",docname:r||"",creationDate:u==null?void 0:u.creation,createdBy:u==null?void 0:u.owner,compact:!1,initialVisible:5,collapsible:!0,startCollapsed:!0})]})]})},s4e=e=>{switch(e==null?void 0:e.toLowerCase()){case"submitted":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300";case"draft":return"bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400";case"cancelled":return"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300";default:return"bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400"}},n4e=()=>{const{t:e}=sr(),r=hr(),[a,s]=_a(),n=p.useRef(s),i=20;p.useEffect(()=>{n.current=s},[s]);const o=p.useMemo(()=>{const Z=parseInt(a.get("page")||"1",10);return Number.isNaN(Z)||Z<1?1:Z},[a]),l=p.useCallback(Z=>{const M=typeof Z=="function"?Z(o):Z;s(we=>{const pe=new URLSearchParams(we);return pe.set("page",String(M)),pe})},[o,s]),[c,u]=p.useState(!1),[h,f]=p.useState(a.get("status")||""),[y,b]=p.useState(a.get("q")||""),[w,v]=p.useState(a.get("date_filter_by")||""),[k,S]=p.useState(a.get("date_start")||""),[N,C]=p.useState(a.get("date_end")||""),[O,T]=p.useState(a.get("sort_by")||"creation desc"),[P,E]=p.useState(!1),R=p.useRef(!1),z=p.useRef(!0),G=p.useRef(null),ae=p.useMemo(()=>{var Z;return((Z=a.get("project"))==null?void 0:Z.trim())||""},[a]),[ee,ne]=p.useState(ae);p.useEffect(()=>{ne(ae)},[ae]);const te=p.useMemo(()=>ae?[["Timesheet Detail","project","=",ae]]:[],[ae]),Y=p.useMemo(()=>{const Z={};return h&&(Z.status=h),y&&(Z.name=["like",`%${y}%`]),Object.assign(Z,kl(w,k,N)),Z},[h,y,w,k,N]),{timesheets:q,loading:H,error:U,totalCount:re,refetch:X}=LNe({filters:Y,appendFilters:te,limit_start:(o-1)*i,limit_page_length:i,order_by:O}),V=p.useMemo(()=>`${o}|${O}|${ae}|${JSON.stringify(Y)}|${JSON.stringify(te)}`,[o,O,ae,Y,te]),{selectedRows:I,toggleRow:B,toggleAllOnPage:Q,allOnPageSelected:ie,someOnPageSelected:me}=po(q,V),he=p.useMemo(()=>{let Z=xa(Y);return te.length&&(Z=[...Z,...te]),Z.length>0?Z:{}},[Y,te]),de=p.useCallback(()=>go({doctype:"Timesheet",filters:he,orderBy:O}),[he,O]),xe=Math.ceil(re/i),ge=()=>{f(""),b(""),v(""),S(""),C(""),T("creation desc"),ne(""),s(Z=>{const M=new URLSearchParams(Z);return["status","q","date_filter_by","date_start","date_end","sort_by","project"].forEach(we=>M.delete(we)),M.set("page","1"),M})};p.useEffect(()=>{if(!R.current){R.current=!0;return}n.current(Z=>{const M=new URLSearchParams(Z);h?M.set("status",h):M.delete("status"),w?M.set("date_filter_by",w):M.delete("date_filter_by"),k?M.set("date_start",k):M.delete("date_start"),N?M.set("date_end",N):M.delete("date_end"),O!=="creation desc"?M.set("sort_by",O):M.delete("sort_by");const we=ee.trim();return we?M.set("project",we):M.delete("project"),M.set("page","1"),M})},[h,w,k,N,O,ee]),p.useEffect(()=>{if(R.current){if(z.current){z.current=!1;return}return G.current&&window.clearTimeout(G.current),G.current=window.setTimeout(()=>{n.current(Z=>{const M=new URLSearchParams(Z);return y?M.set("q",y):M.delete("q"),M.set("page","1"),M})},450),()=>{G.current&&window.clearTimeout(G.current)}}},[y]);const be=!!(h||y||ae||w&&(k||N)),K=Z=>r(`/projects/timesheets/${encodeURIComponent(Z)}?edit=1`),ye=Z=>r(`/projects/timesheets/new?duplicate=${encodeURIComponent(Z)}`);return t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>r("/projects"),className:"text-sm text-gray-500 hover:text-indigo-600 dark:text-gray-400 dark:hover:text-indigo-400",children:e("projects.moduleTitle")}),t.jsx("span",{className:"text-gray-400",children:"/"}),t.jsxs("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white flex items-center gap-2",children:[t.jsx(ea,{className:"text-indigo-500"})," ",e("projects.timesheetDoctype")]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>E(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all disabled:opacity-50",disabled:re===0&&I.size===0,children:[t.jsx(Sa,{})," ",t.jsx("span",{className:"font-medium",children:e("listPages.export")}),I.size>0&&t.jsx("span",{className:"bg-white/25 px-1.5 py-0.5 rounded text-xs font-bold",children:I.size})]}),t.jsxs("button",{type:"button",onClick:()=>{const Z=new URLSearchParams;ae&&Z.set("project",ae);const M=Z.toString();r(M?`/projects/timesheets/new?${M}`:"/projects/timesheets/new")},className:"flex items-center gap-2 px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700",children:[t.jsx(Rr,{})," ",e("projects.newTimesheet")]})]})]}),t.jsx(bi,{isOpen:P,onClose:()=>E(!1),doctype:"Timesheet",selectedCount:I.size,pageCount:q.length,totalCount:re,pageData:q,selectedRows:I,rowKey:"name",onFetchAll:de,fileNamePrefix:"timesheets"}),t.jsxs("div",{className:"isolate bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-6",children:[t.jsx("div",{className:"bg-gradient-to-r from-blue-500 to-blue-600 dark:from-blue-600 dark:to-blue-700 px-4 py-2.5 rounded-t-lg",children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx("button",{onClick:()=>u(Z=>!Z),className:"text-white hover:bg-white/20 p-1.5 rounded-lg transition-all",children:c?t.jsx(Ja,{size:12}):t.jsx(Fr,{size:12})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ds,{className:"text-white",size:13}),t.jsx("span",{className:"text-white font-semibold text-sm",children:"Filters"})]}),be&&t.jsx("span",{className:"bg-white text-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:[h,y,ae,w&&k].filter(Boolean).length})]}),be&&t.jsx("div",{className:"flex-1 overflow-x-auto mx-2",children:t.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[y&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-white/90 text-gray-700 rounded-full text-[10px] font-medium whitespace-nowrap",children:[t.jsx("span",{className:"font-semibold",children:"ID:"})," ",y,t.jsx("button",{onClick:()=>b(""),children:t.jsx(ht,{className:"text-[9px] hover:text-red-500"})})]}),h&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap",children:[t.jsx("span",{className:"font-semibold",children:"Status:"})," ",h,t.jsx("button",{onClick:()=>f(""),children:t.jsx(ht,{className:"text-[9px] hover:text-red-500"})})]}),ae&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap",children:[t.jsx("span",{className:"font-semibold",children:"Project:"})," ",ae,t.jsx("button",{type:"button",onClick:()=>{ne(""),s(Z=>{const M=new URLSearchParams(Z);return M.delete("project"),M.set("page","1"),M})},children:t.jsx(ht,{className:"text-[9px] hover:text-red-500"})})]}),w&&k&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap",children:[t.jsxs("span",{className:"font-semibold",children:[w==="creation"?"Created":"Modified",":"]})," ",k,N?` – ${N}`:"",t.jsx("button",{type:"button",onClick:()=>{v(""),S(""),C("")},children:t.jsx(ht,{className:"text-[9px] hover:text-red-500"})})]})]})}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[be&&t.jsx("button",{onClick:ge,className:"text-white/80 hover:text-white text-xs underline whitespace-nowrap",children:"Clear all"}),t.jsx("button",{onClick:()=>X(),className:"text-white hover:bg-white/20 p-1.5 rounded-lg transition-all",title:"Refresh",children:t.jsx(Ma,{size:12,className:H?"animate-spin":""})})]})]})}),c&&t.jsx("div",{className:"p-4",children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Project"}),t.jsx("input",{type:"text",value:ee,onChange:Z=>ne(Z.target.value),onKeyDown:Z=>Z.key==="Enter"&&Z.preventDefault(),placeholder:"Filter by project…",className:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-400 focus:outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Timesheet ID"}),t.jsxs("div",{className:"relative",children:[t.jsx(za,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400 text-xs"}),t.jsx("input",{type:"text",value:y,onChange:Z=>b(Z.target.value),onKeyDown:Z=>Z.key==="Enter"&&Z.preventDefault(),placeholder:"Search by ID…",className:"w-full pl-8 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-400 focus:outline-none"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Status"}),t.jsxs("select",{value:h,onChange:Z=>f(Z.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-400 focus:outline-none",children:[t.jsx("option",{value:"",children:"All Status"}),t.jsx("option",{value:"Draft",children:"Draft"}),t.jsx("option",{value:"Submitted",children:"Submitted"}),t.jsx("option",{value:"Cancelled",children:"Cancelled"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Date Filter By"}),t.jsxs("select",{value:w,onChange:Z=>v(Z.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-400 focus:outline-none",children:[t.jsx("option",{value:"",children:"None"}),t.jsx("option",{value:"creation",children:"Created"}),t.jsx("option",{value:"modified",children:"Modified"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Sort By"}),t.jsxs("select",{value:O,onChange:Z=>T(Z.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-400 focus:outline-none",children:[t.jsx("option",{value:"creation desc",children:"Created (newest)"}),t.jsx("option",{value:"creation asc",children:"Created (oldest)"}),t.jsx("option",{value:"modified desc",children:"Modified (newest)"}),t.jsx("option",{value:"total_hours desc",children:"Hours (highest)"}),t.jsx("option",{value:"total_hours asc",children:"Hours (lowest)"})]})]}),w&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"From"}),t.jsx("input",{type:"date",value:k,onChange:Z=>S(Z.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-400 focus:outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"To"}),t.jsx("input",{type:"date",value:N,onChange:Z=>C(Z.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-400 focus:outline-none"})]})]})]})})]}),U&&t.jsx("div",{className:"mb-4 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg text-red-700 dark:text-red-300 text-sm",children:U}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden",children:[H?t.jsx("div",{className:"p-12 text-center text-gray-500 dark:text-gray-400",children:e("common.loading")}):q.length===0?t.jsxs("div",{className:"p-12 text-center",children:[t.jsx(ea,{className:"text-4xl text-gray-300 dark:text-gray-600 mx-auto mb-3"}),t.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:e("projects.noTimesheets")})]}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"w-10 px-4 py-3 text-left",children:t.jsx("button",{type:"button",onClick:Q,className:"text-gray-500 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors",title:ie?"Deselect all":"Select all","aria-label":"Select all on page",children:ie?t.jsx(Ra,{className:"text-indigo-600 dark:text-indigo-400",size:18}):me?t.jsxs("div",{className:"relative inline-block",children:[t.jsx(Ur,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Ur,{size:18})})}),[e("projects.timesheetId"),e("commonFields.status"),e("projects.totalHours"),"Billable Hrs","Billing Amt","Costing Amt","Created",""].map(Z=>t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:Z},Z))]})}),t.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:q.map(Z=>{var M,we,pe,le;return t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${I.has(Z.name)?"bg-indigo-50 dark:bg-indigo-900/20":""}`,onClick:()=>r(`/projects/timesheets/${Z.name}`),children:[t.jsx("td",{className:"w-10 px-4 py-3",onClick:Fe=>Fe.stopPropagation(),children:t.jsx("button",{type:"button",onClick:()=>B(Z.name),className:"text-gray-500 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors","aria-label":`Select ${Z.name}`,children:I.has(Z.name)?t.jsx(Ra,{className:"text-indigo-600 dark:text-indigo-400",size:18}):t.jsx(Ur,{size:18})})}),t.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:Z.name}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:Z.modified?new Date(Z.modified).toLocaleDateString():""})]}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${s4e(Z.status||"")}`,children:Z.status||"Draft"})}),t.jsxs("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 dark:text-white",children:[(M=Z.total_hours)!=null?M:0," hrs"]}),t.jsxs("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:[(we=Z.total_billable_hours)!=null?we:0," hrs"]}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:(pe=Z.total_billable_amount)!=null?pe:"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:(le=Z.total_costing_amount)!=null?le:"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400",children:Z.creation?new Date(Z.creation).toLocaleDateString():"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",onClick:Fe=>Fe.stopPropagation(),children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>r(`/projects/timesheets/${Z.name}`),className:"text-indigo-600 dark:text-indigo-400 hover:text-indigo-900 dark:hover:text-indigo-300 p-2 hover:bg-indigo-50 dark:hover:bg-indigo-900/30 rounded transition-colors",title:"View",children:t.jsx(Ps,{})}),t.jsx("button",{onClick:()=>K(Z.name),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:"Edit",children:t.jsx(qr,{})}),t.jsx("button",{onClick:()=>ye(Z.name),className:"text-purple-600 dark:text-purple-400 hover:text-purple-900 dark:hover:text-purple-300 p-2 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded transition-colors",title:"Duplicate",children:t.jsx(Vo,{})})]})})]},Z.name)})})]})}),xe>1&&t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 px-4 py-3",children:t.jsx(_l,{currentPage:o,totalPages:xe,totalCount:re,pageSize:i,onPageChange:l})})]})]})},JD=e=>{switch(e==null?void 0:e.toLowerCase()){case"submitted":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300";case"cancelled":return"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300";default:return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300"}},sn=({children:e,required:r})=>t.jsxs("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1.5",children:[e,r&&t.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),Ys=({children:e,className:r})=>t.jsx("div",{className:`px-3 py-2.5 text-sm text-gray-800 dark:text-gray-200 bg-gray-50 dark:bg-gray-900/30 rounded-lg min-h-[36px] flex items-center border border-transparent dark:border-gray-700/50 ${r||""}`,children:e||t.jsx("span",{className:"text-gray-400 dark:text-gray-600",children:"—"})}),ZD="w-full px-3 py-2.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-indigo-400 focus:border-indigo-400 transition-colors",Gb=({title:e,icon:r,children:a,defaultOpen:s=!0})=>{const[n,i]=p.useState(s);return t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden shadow-sm",children:[t.jsxs("button",{type:"button",onClick:()=>i(o=>!o),className:"w-full flex items-center justify-between px-5 py-3.5 hover:bg-gray-50 dark:hover:bg-gray-700/30 transition-colors text-left",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-gray-700 dark:text-gray-200",children:[r,t.jsx("span",{children:e})]}),n?t.jsx(Fr,{className:"text-gray-400 text-xs flex-shrink-0"}):t.jsx(Fi,{className:"text-gray-400 text-xs flex-shrink-0"})]}),n&&t.jsx("div",{className:"px-5 py-5 bg-white dark:bg-gray-800 border-t border-gray-100 dark:border-gray-700/50",children:a})]})},Kb=({title:e,icon:r,children:a})=>t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden shadow-sm",children:[t.jsxs("div",{className:"px-4 py-2.5 border-b border-gray-100 dark:border-gray-700 bg-gray-50/90 dark:bg-gray-900/40 flex items-center gap-2",children:[r,t.jsx("h3",{className:"text-xs font-bold text-gray-600 dark:text-gray-300 uppercase tracking-wider",children:e})]}),t.jsx("div",{className:"p-4 sm:p-5",children:a})]}),Yb=(e={})=>({activity_type:"",from_time:void 0,to_time:void 0,hours:void 0,project:e.project||"",task:e.task||"",note:"",is_billable:0,completed:0}),XD=e=>e.length===16?e+":00":e,i4e=e=>e.filter(r=>r.from_time&&r.from_time.trim()!=="").map(r=>{var a;return je(se({},r),{from_time:XD(r.from_time.replace("T"," ")),to_time:(a=r.to_time)!=null&&a.trim()?XD(r.to_time.replace("T"," ")):void 0})}),o4e=()=>{var Z,M,we,pe,le,Fe,ze;const{t:e}=sr(),{timesheetName:r}=hs(),[a]=_a(),s=hr(),n=r==="new",i=p.useMemo(()=>!n&&(a.get("edit")||"")==="1",[n,a]),o=p.useMemo(()=>n&&a.get("duplicate")||"",[n,a]),[l,c]=p.useState(!1),u=a.get("project")||"",h=a.get("task")||"",f=a.get("customer")||"",y=a.get("company")||un,{timesheet:b,loading:w,error:v,refetch:k}=INe(n?null:r||null),{createTimesheet:S,updateTimesheet:N,submitTimesheet:C,loading:O}=oy(),[T,P]=p.useState(!1),[E,R]=p.useState(n);p.useEffect(()=>{i&&R(!0)},[i]);const[z,G]=p.useState(null),[ae,ee]=p.useState(!1),[ne,te]=p.useState(-1),[Y,q]=p.useState(0),H=p.useRef(null),U=p.useRef(null),re=Re=>{const De=Math.floor(Re/3600).toString().padStart(2,"0"),Et=Math.floor(Re%3600/60).toString().padStart(2,"0"),jt=(Re%60).toString().padStart(2,"0");return`${De}:${Et}:${jt}`},X=()=>{if(!ye)return;const Re=new Date,De=Re.toISOString().replace("T"," ").slice(0,19),Et=Yb({project:I.parent_project||u,task:h});Et.from_time=De,B(Ie=>je(se({},Ie),{time_logs:[...Ie.time_logs||[],Et]}));const jt=(I.time_logs||[]).length;te(jt),G(jt),H.current=Re,q(0),ee(!0),U.current=setInterval(()=>{q(Ie=>Ie+1)},1e3)},V=()=>{if(U.current&&clearInterval(U.current),H.current&&ne>=0){const Re=new Date,De=Re.toISOString().replace("T"," ").slice(0,19),Et=(Re.getTime()-H.current.getTime())/36e5;B(jt=>{const Ie=[...jt.time_logs||[]];return Ie[ne]&&(Ie[ne]=je(se({},Ie[ne]),{to_time:De,hours:parseFloat(Et.toFixed(4))})),je(se({},jt),{time_logs:Ie})})}ee(!1),te(-1),H.current=null};p.useEffect(()=>()=>{U.current&&clearInterval(U.current)},[]);const[I,B]=p.useState({status:"Draft",currency:Er,exchange_rate:1,employee:"",customer:f,parent_project:u,company:y,note:"",time_logs:[Yb({project:u,task:h})]}),Q=p.useCallback(Re=>{var Et,jt;const De=Re.parent_project||Re.project||"";B({status:Re.status||"Draft",currency:Re.currency||Er,exchange_rate:(Et=Re.exchange_rate)!=null?Et:1,employee:Re.employee||"",customer:Re.customer||"",parent_project:De,company:Re.company||Re.hospital||un,note:Re.note||"",time_logs:(jt=Re.time_logs)!=null&&jt.length?Re.time_logs:[]})},[]);p.useEffect(()=>{b&&!n&&Q(b)},[b,n,Q]),p.useEffect(()=>{if(!n||!o)return;let Re=!1;return c(!0),Dr.getTimesheet(o).then(De=>{if(Re)return;const Et=Array.isArray(De.time_logs)?De.time_logs.map(Ie=>({activity_type:Ie.activity_type||"",from_time:void 0,to_time:void 0,hours:void 0,project:u||Ie.project||"",task:h||Ie.task||"",note:Ie.note||"",is_billable:Ie.is_billable||0,completed:0})):[],jt=Et.length?Et:[Yb({project:u,task:h})];B(Ie=>je(se({},Ie),{status:"Draft",note:De.note||"",parent_project:u||De.parent_project||De.project||Ie.parent_project,customer:f||De.customer||Ie.customer,company:y,time_logs:jt})),R(!0)}).catch(()=>{}).finally(()=>{Re||c(!1)}),()=>{Re=!0}},[n,o,u,h,f,y]);const ie=(Re,De)=>B(Et=>je(se({},Et),{[Re]:De})),me=()=>{B(Re=>je(se({},Re),{time_logs:[...Re.time_logs||[],Yb({project:Re.parent_project||u,task:h})]}))},he=(Re,De,Et)=>B(jt=>{const Ie=[...jt.time_logs||[]],$e=je(se({},Ie[Re]),{[De]:Et});if(De==="from_time"||De==="to_time"){const Qe=De==="from_time"?Et:$e.from_time,at=De==="to_time"?Et:$e.to_time;if(Qe&&at){const Ct=new Date(Qe.replace(" ","T")).getTime(),vt=new Date(at.replace(" ","T")).getTime();if(vt>Ct){const er=parseFloat(((vt-Ct)/36e5).toFixed(4));$e.hours=er,(!$e.billing_hours||$e.billing_hours===Ie[Re].hours)&&($e.billing_hours=er)}}}if(De==="is_billable"&&Et&&!$e.billing_hours&&$e.hours&&($e.billing_hours=$e.hours),De==="billing_rate"||De==="billing_hours"){const Qe=De==="billing_rate"?parseFloat(Et)||0:$e.billing_rate||0,at=De==="billing_hours"?parseFloat(Et)||0:$e.billing_hours||0;$e.billing_amount=parseFloat((Qe*at).toFixed(2))}return $e.costing_amount=parseFloat((($e.costing_rate||0)*($e.hours||0)).toFixed(2)),Ie[Re]=$e,je(se({},jt),{time_logs:Ie})}),de=Re=>B(De=>{const Et=[...De.time_logs||[]];return Et.splice(Re,1),G(null),je(se({},De),{time_logs:Et})}),xe=(I.time_logs||[]).reduce((Re,De)=>Re+(De.hours||0),0),ge=()=>J(null,null,function*(){const Re=i4e(I.time_logs||[]);if(Re.length===0){We.error("At least one time log with a From Time is required.",{icon:t.jsx(pr,{})});return}const De={status:I.status,currency:I.currency,exchange_rate:I.exchange_rate,naming_series:I.naming_series,time_logs:Re,employee:I.employee||void 0,customer:I.customer||void 0,company:I.company||void 0,parent_project:I.parent_project||void 0,note:I.note||void 0};try{if(n){const Et=yield S(De);We.success(e("projects.timesheetCreated"),{icon:t.jsx(Qt,{})}),R(!1),s(`/projects/timesheets/${Et.name}`)}else yield N(r,De),We.success(e("projects.timesheetUpdated"),{icon:t.jsx(Qt,{})}),R(!1),k()}catch(Et){We.error(Et instanceof Error?Et.message:e("common.error"),{icon:t.jsx(pr,{})})}}),be=()=>{b&&Q(b),R(!1),G(null)},K=()=>J(null,null,function*(){if(!(!r||n))try{P(!0),yield C(r),We.success("Timesheet submitted",{icon:t.jsx(Qt,{})}),k()}catch(Re){We.error(Re instanceof Error?Re.message:"Error submitting",{icon:t.jsx(pr,{})})}finally{P(!1)}}),ye=n||E;return w?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsx(tr,{className:"animate-spin text-indigo-500 text-3xl"})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900",children:[t.jsx($a,{position:"top-right",autoClose:3500}),t.jsx("div",{className:"bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 shadow-sm",children:t.jsxs("div",{className:"px-6 py-4",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs mb-3 text-gray-400 dark:text-gray-500",children:[t.jsx("button",{onClick:()=>s("/projects"),className:"hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors",children:e("projects.moduleTitle")}),t.jsx("span",{children:"/"}),t.jsx("button",{onClick:()=>s("/projects/timesheets"),className:"hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors",children:"Timesheets"}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-gray-600 dark:text-gray-300 font-medium",children:n?"New Timesheet":r})]}),t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[t.jsx("button",{onClick:()=>s("/projects/timesheets"),className:"mt-1 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 flex-shrink-0 transition-colors",children:t.jsx(ia,{})}),t.jsx("div",{className:"min-w-0",children:t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[t.jsx("div",{className:"w-9 h-9 rounded-lg bg-indigo-600 flex items-center justify-center flex-shrink-0 shadow-sm",children:t.jsx(ea,{className:"text-white text-sm"})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white leading-tight",children:n?"New Timesheet":r}),!n&&t.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mt-0.5",children:"Series: TS-.YYYY.-"})]}),t.jsxs("span",{className:`inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-xs font-semibold ${(b==null?void 0:b.docstatus)===1?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300":(b==null?void 0:b.docstatus)===2?"bg-red-100 text-red-700":JD(I.status||"Draft")}`,children:[t.jsx(ea,{size:9}),(b==null?void 0:b.docstatus)===1?"Submitted":(b==null?void 0:b.docstatus)===2?"Cancelled":I.status||"Draft"]})]})})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[!n&&!E&&(b==null?void 0:b.docstatus)===1&&t.jsxs("button",{onClick:()=>{const Re=new URLSearchParams({customer:I.customer||""});I.company&&Re.set("company",String(I.company)),I.parent_project&&Re.set("project",String(I.parent_project)),s(`/invoices/new?${Re.toString()}`)},className:"flex items-center gap-2 px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 text-sm font-medium",children:[t.jsx(xm,{size:13})," Create Sales Invoice"]}),!n&&!E&&(b==null?void 0:b.docstatus)===0&&t.jsxs("button",{onClick:K,disabled:T,className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 text-sm font-medium",children:[T?t.jsx(tr,{className:"animate-spin"}):t.jsx(Lm,{size:12}),"Submit"]}),ye&&(ae?t.jsxs("button",{type:"button",onClick:V,className:"flex items-center gap-2 px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 text-sm font-medium shadow-sm",children:[t.jsx(qG,{size:11}),t.jsx("span",{className:"font-mono tracking-widest",children:re(Y)}),"Stop Timer"]}):t.jsxs("button",{type:"button",onClick:X,className:"flex items-center gap-2 px-4 py-2 bg-gray-800 dark:bg-gray-700 text-white rounded-lg hover:bg-gray-900 dark:hover:bg-gray-600 text-sm font-medium",children:[t.jsx(VG,{})," Start Timer"]})),!n&&!E&&t.jsxs("button",{onClick:()=>R(!0),className:"flex items-center gap-2 px-4 py-2 border border-indigo-500 text-indigo-600 dark:text-indigo-400 rounded-lg hover:bg-indigo-50 dark:hover:bg-indigo-900/20 text-sm transition-colors",children:[t.jsx(qr,{})," ",e("common.edit")]}),ye&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:ge,disabled:O,className:"flex items-center gap-2 px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 disabled:opacity-50 text-sm font-medium shadow-sm",children:[O?t.jsx(tr,{className:"animate-spin"}):t.jsx(ta,{}),e(O?"common.saving":"common.save")]}),!n&&t.jsx("button",{onClick:be,className:"px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-600 dark:text-gray-400 text-sm",children:t.jsx(ht,{})})]})]})]})]})}),t.jsxs("div",{className:"px-6 py-6 space-y-3",children:[v&&!n&&t.jsx("div",{className:"p-3 bg-red-50 dark:bg-red-900/20 rounded-lg text-red-700 dark:text-red-300 text-sm",children:v}),!n&&b&&t.jsx(Kb,{title:"Summary",icon:t.jsx(ea,{className:"text-indigo-500 flex-shrink-0",size:13}),children:t.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[{label:"Total Hours",value:`${(Z=b.total_hours)!=null?Z:0} hrs`},{label:"Billable Hours",value:`${(M=b.total_billable_hours)!=null?M:0} hrs`},{label:"Billable Amount",value:`${b.currency||Er} ${(we=b.total_billable_amount)!=null?we:0}`},{label:"Costing Amount",value:`${b.currency||Er} ${(pe=b.total_costing_amount)!=null?pe:0}`}].map(({label:Re,value:De})=>t.jsxs("div",{className:"rounded-lg border border-gray-200/80 dark:border-gray-600/80 bg-gray-50/80 dark:bg-gray-900/40 px-3 py-2.5 min-h-[72px] flex flex-col justify-center",children:[t.jsx("p",{className:"text-[10px] font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1",children:Re}),t.jsx("p",{className:"text-sm font-semibold text-gray-900 dark:text-white tabular-nums leading-snug",children:De})]},Re))})}),t.jsx(Kb,{title:"Document",icon:t.jsx(Ju,{className:"text-indigo-500 flex-shrink-0",size:13}),children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx(sn,{children:"Series"}),t.jsx(Ys,{children:"TS-.YYYY.-"})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx(sn,{children:"Status"}),ye?t.jsxs("select",{value:I.status||"Draft",onChange:Re=>ie("status",Re.target.value),className:ZD,children:[t.jsx("option",{value:"Draft",children:"Draft"}),t.jsx("option",{value:"Submitted",children:"Submitted"}),t.jsx("option",{value:"Cancelled",children:"Cancelled"})]}):t.jsx(Ys,{children:t.jsx("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-xs font-semibold ${JD(I.status||"Draft")}`,children:I.status||"Draft"})})]})]})}),t.jsx(Kb,{title:"Organization",icon:t.jsx(Y9,{className:"text-indigo-500 flex-shrink-0",size:13}),children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx(sn,{children:"Hospital"}),ye?t.jsx(Je,{label:"Hospital",hideLabel:!0,doctype:"Company",value:I.company||"",onChange:Re=>ie("company",Re),placeholder:"Select hospital / company…"}):t.jsx(Ys,{children:I.company})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx(sn,{children:"Project"}),ye?t.jsx(Je,{label:"Project",hideLabel:!0,doctype:"Project",value:I.parent_project||"",onChange:Re=>ie("parent_project",Re),placeholder:"Select project…"}):t.jsx(Ys,{children:I.parent_project?t.jsx("button",{type:"button",onClick:()=>s(`/projects/list/${I.parent_project}`),className:"text-indigo-600 dark:text-indigo-400 hover:underline font-medium",children:I.parent_project}):null})]})]})}),t.jsx(Kb,{title:"Customer & currency",icon:t.jsx(Zu,{className:"text-indigo-500 flex-shrink-0",size:13}),children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-x-8 gap-y-4",children:[t.jsxs("div",{className:"min-w-0 sm:col-span-2 lg:col-span-1",children:[t.jsx(sn,{children:"Customer"}),ye?t.jsx(Je,{label:"Customer",hideLabel:!0,doctype:"Customer",value:I.customer||"",onChange:Re=>ie("customer",Re),placeholder:"Select customer…"}):t.jsx(Ys,{children:I.customer})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx(sn,{children:"Currency"}),t.jsx(Ys,{children:I.currency||Er})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx(sn,{children:"Exchange rate"}),t.jsx(Ys,{children:(le=I.exchange_rate)!=null?le:1})]})]})}),t.jsx(Gb,{title:"Employee Detail",icon:t.jsx(nn,{className:"text-indigo-500",size:13}),children:t.jsxs("div",{className:"max-w-sm",children:[t.jsx(sn,{children:"Employee"}),ye?t.jsx(Je,{label:"Employee",hideLabel:!0,doctype:"Employee",value:I.employee||"",onChange:Re=>ie("employee",Re),placeholder:"Select employee…",filters:{status:"Active"},allowQuickCreate:!0}):t.jsx(Ys,{children:I.employee})]})}),t.jsxs(Gb,{title:"Time Sheets",icon:t.jsx(ea,{className:"text-indigo-500",size:13}),defaultOpen:!0,children:[t.jsxs("div",{className:"overflow-x-auto rounded-lg border border-gray-200 dark:border-gray-700 mb-3",children:[t.jsxs("div",{className:`grid ${ye?"grid-cols-[40px_minmax(130px,1fr)_155px_155px_70px_minmax(110px,1fr)_58px_36px]":"grid-cols-[40px_minmax(130px,1fr)_155px_155px_70px_minmax(110px,1fr)_58px]"}
|
||
bg-gray-50 dark:bg-gray-900/50 border-b border-gray-200 dark:border-gray-700 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase`,children:[t.jsx("div",{className:"px-3 py-2",children:"No."}),t.jsx("div",{className:"px-3 py-2",children:"Activity Type"}),t.jsxs("div",{className:"px-3 py-2",children:["From Time ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsx("div",{className:"px-3 py-2",children:"To Time"}),t.jsx("div",{className:"px-3 py-2",children:"Hrs"}),t.jsx("div",{className:"px-3 py-2",children:"Project"}),t.jsx("div",{className:"px-3 py-2 text-center",children:"Billable"}),t.jsx("div",{className:"py-2"}),ye&&t.jsx("div",{className:"py-2"})]}),(I.time_logs||[]).length===0?t.jsx("div",{className:"py-10 text-center text-sm text-gray-400 dark:text-gray-500 italic",children:ye?'Click "Add Row" below to add time entries':"No time logs"}):t.jsx("div",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:(I.time_logs||[]).map((Re,De)=>{var Et,jt,Ie,$e,Qe,at,Ct;return t.jsxs(gr.Fragment,{children:[t.jsxs("div",{className:`grid ${ye?"grid-cols-[40px_minmax(130px,1fr)_155px_155px_70px_minmax(110px,1fr)_58px_32px_36px]":"grid-cols-[40px_minmax(130px,1fr)_155px_155px_70px_minmax(110px,1fr)_58px_32px]"}
|
||
items-center hover:bg-gray-50 dark:hover:bg-gray-700/20
|
||
${z===De?"bg-indigo-50 dark:bg-indigo-900/10":""}
|
||
${ae&&ne===De?"bg-red-50 dark:bg-red-900/10 border-l-2 border-red-400":""}`,children:[t.jsx("div",{className:"px-3 py-2.5 text-xs text-gray-500 font-medium",children:De+1}),t.jsx("div",{className:"px-2 py-1.5",onClick:vt=>vt.stopPropagation(),children:ye?t.jsx(Je,{label:"Activity Type",hideLabel:!0,doctype:"Activity Type",value:Re.activity_type||"",onChange:vt=>he(De,"activity_type",vt),placeholder:"Activity…",allowQuickCreate:!0,compact:!0}):t.jsx("span",{className:"text-sm text-gray-800 dark:text-gray-200",children:Re.activity_type||"-"})}),t.jsx("div",{className:"px-2 py-1.5",onClick:vt=>vt.stopPropagation(),children:ye?t.jsx("input",{type:"datetime-local",value:Re.from_time?Re.from_time.replace(" ","T").slice(0,16):"",onChange:vt=>he(De,"from_time",vt.target.value||void 0),required:!0,className:`text-xs border rounded px-2 py-1.5 w-full focus:outline-none focus:ring-1 focus:ring-indigo-400 ${Re.from_time?"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700":"border-red-300 bg-red-50 dark:bg-red-900/20 dark:border-red-600"} text-gray-900 dark:text-white`}):t.jsx("span",{className:"text-xs text-gray-700 dark:text-gray-300",children:Re.from_time||"-"})}),t.jsx("div",{className:"px-2 py-1.5",onClick:vt=>vt.stopPropagation(),children:ye?t.jsx("input",{type:"datetime-local",value:Re.to_time?Re.to_time.replace(" ","T").slice(0,16):"",onChange:vt=>he(De,"to_time",vt.target.value||void 0),className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1.5 w-full bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-indigo-400"}):t.jsx("span",{className:"text-xs text-gray-700 dark:text-gray-300",children:Re.to_time||"-"})}),t.jsx("div",{className:"px-2 py-1.5",onClick:vt=>vt.stopPropagation(),children:ye?t.jsx("input",{type:"number",min:0,step:.25,value:(Et=Re.hours)!=null?Et:"",onChange:vt=>he(De,"hours",parseFloat(vt.target.value)||void 0),placeholder:"0",className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1.5 w-full bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-indigo-400"}):t.jsx("span",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:((jt=Re.hours)!=null?jt:0).toFixed(3)})}),t.jsx("div",{className:"px-2 py-1.5",onClick:vt=>vt.stopPropagation(),children:ye?t.jsx(Je,{label:"Project",hideLabel:!0,doctype:"Project",value:Re.project||"",onChange:vt=>he(De,"project",vt),placeholder:"Project…",compact:!0}):t.jsx("span",{className:"text-sm text-gray-800 dark:text-gray-200",children:Re.project||"-"})}),t.jsx("div",{className:"px-3 py-2.5 flex justify-center",onClick:vt=>vt.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:!!Re.is_billable,onChange:vt=>he(De,"is_billable",vt.target.checked?1:0),disabled:!ye,className:"w-4 h-4 text-green-600 rounded cursor-pointer"})}),t.jsx("div",{className:"flex justify-center",onClick:vt=>vt.stopPropagation(),children:t.jsx("button",{type:"button",onClick:()=>G(z===De?null:De),className:`p-1.5 rounded transition-colors ${z===De?"text-indigo-600 bg-indigo-100 dark:bg-indigo-900/30":"text-gray-400 hover:text-indigo-600 hover:bg-indigo-50 dark:hover:bg-indigo-900/20"}`,title:"Edit row details",children:t.jsx(xl,{size:11})})}),ye&&t.jsx("div",{className:"flex justify-center",onClick:vt=>vt.stopPropagation(),children:t.jsx("button",{type:"button",onClick:()=>de(De),className:"p-1.5 text-red-400 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors",title:"Remove row",children:t.jsx(wr,{size:11})})})]}),z===De&&t.jsxs("div",{className:"border-t border-indigo-100 dark:border-indigo-800/40 bg-indigo-50/60 dark:bg-indigo-900/10 px-4 py-4 mx-0",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("span",{className:"text-xs font-semibold text-indigo-700 dark:text-indigo-400 uppercase tracking-wide",children:["Editing Row #",De+1]}),t.jsx("button",{type:"button",onClick:()=>G(null),className:"text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 px-2 py-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-700",children:"✕ Close"})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-3",children:[t.jsxs("div",{children:[t.jsx(sn,{children:"Activity Type"}),ye?t.jsx(Je,{label:"Activity Type",hideLabel:!0,doctype:"Activity Type",value:Re.activity_type||"",onChange:vt=>he(De,"activity_type",vt),placeholder:"Select activity…",allowQuickCreate:!0}):t.jsx(Ys,{children:Re.activity_type||"-"})]}),t.jsxs("div",{children:[t.jsx(sn,{children:"Hours"}),t.jsx(Ys,{children:((Ie=Re.hours)!=null?Ie:0).toFixed(3)})]}),t.jsxs("div",{children:[t.jsx(sn,{required:!0,children:"From Time"}),ye?t.jsx("input",{type:"datetime-local",value:Re.from_time?Re.from_time.replace(" ","T").slice(0,16):"",onChange:vt=>he(De,"from_time",vt.target.value||void 0),className:"w-full text-sm border border-gray-300 dark:border-gray-600 rounded-lg px-3 py-2 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-400 focus:outline-none"}):t.jsx(Ys,{children:Re.from_time||"-"})]}),t.jsxs("div",{children:[t.jsx(sn,{children:"To Time"}),ye?t.jsx("input",{type:"datetime-local",value:Re.to_time?Re.to_time.replace(" ","T").slice(0,16):"",onChange:vt=>he(De,"to_time",vt.target.value||void 0),className:"w-full text-sm border border-gray-300 dark:border-gray-600 rounded-lg px-3 py-2 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-400 focus:outline-none"}):t.jsx(Ys,{children:Re.to_time||"-"})]}),t.jsxs("div",{className:"sm:col-span-2",children:[t.jsx(sn,{children:"Description"}),ye?t.jsx("textarea",{rows:2,value:Re.note||"",onChange:vt=>he(De,"note",vt.target.value),placeholder:"Add notes…",className:"w-full text-sm border border-gray-300 dark:border-gray-600 rounded-lg px-3 py-2 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-400 focus:outline-none resize-none"}):t.jsx(Ys,{children:Re.note||"-"})]}),t.jsxs("div",{children:[t.jsx(sn,{children:"Project"}),ye?t.jsx(Je,{label:"Project",hideLabel:!0,doctype:"Project",value:Re.project||"",onChange:vt=>he(De,"project",vt),placeholder:"Select project…"}):t.jsx(Ys,{children:Re.project||"-"})]}),t.jsxs("div",{className:"flex items-center gap-3 pt-5",children:[t.jsx("input",{type:"checkbox",id:`completed-${De}`,checked:!!Re.completed,onChange:vt=>he(De,"completed",vt.target.checked?1:0),disabled:!ye,className:"w-4 h-4 text-green-600 rounded"}),t.jsx("label",{htmlFor:`completed-${De}`,className:"text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer",children:"Completed"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("input",{type:"checkbox",id:`billable-${De}`,checked:!!Re.is_billable,onChange:vt=>he(De,"is_billable",vt.target.checked?1:0),disabled:!ye,className:"w-4 h-4 text-green-600 rounded"}),t.jsx("label",{htmlFor:`billable-${De}`,className:"text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer",children:"Is Billable"})]}),t.jsxs("div",{children:[t.jsx(sn,{children:"Billing Hours"}),ye?t.jsx("input",{type:"number",min:0,step:.01,value:($e=Re.billing_hours)!=null?$e:"",onChange:vt=>he(De,"billing_hours",parseFloat(vt.target.value)||void 0),placeholder:"0",className:"w-full text-sm border border-gray-300 dark:border-gray-600 rounded-lg px-3 py-2 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-400 focus:outline-none"}):t.jsx(Ys,{children:(Qe=Re.billing_hours)!=null?Qe:"-"})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3 mt-3 pt-3 border-t border-indigo-100 dark:border-indigo-800/40",children:[t.jsxs("div",{children:[t.jsxs(sn,{children:["Billing Rate (",I.currency||Er,")"]}),ye?t.jsx("input",{type:"number",min:0,step:.01,value:(at=Re.billing_rate)!=null?at:"",onChange:vt=>he(De,"billing_rate",parseFloat(vt.target.value)||void 0),placeholder:"0.00",className:"w-full text-sm border border-gray-300 dark:border-gray-600 rounded-lg px-3 py-2 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-400 focus:outline-none"}):t.jsx(Ys,{children:Re.billing_rate!=null?`${I.currency||Er} ${Re.billing_rate.toFixed(2)}`:"-"})]}),t.jsxs("div",{children:[t.jsxs(sn,{children:["Billing Amount (",I.currency||Er,")"]}),t.jsx(Ys,{className:"font-semibold text-green-700 dark:text-green-400",children:Re.billing_amount!=null?`${I.currency||Er} ${Re.billing_amount.toFixed(2)}`:"-"})]}),t.jsxs("div",{children:[t.jsxs(sn,{children:["Costing Rate (",I.currency||Er,")"]}),ye?t.jsx("input",{type:"number",min:0,step:.01,value:(Ct=Re.costing_rate)!=null?Ct:"",onChange:vt=>he(De,"costing_rate",parseFloat(vt.target.value)||void 0),placeholder:"0.00",className:"w-full text-sm border border-gray-300 dark:border-gray-600 rounded-lg px-3 py-2 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-400 focus:outline-none"}):t.jsx(Ys,{children:Re.costing_rate!=null?`${I.currency||Er} ${Re.costing_rate.toFixed(2)}`:"-"})]}),t.jsxs("div",{children:[t.jsxs(sn,{children:["Costing Amount (",I.currency||Er,")"]}),t.jsx(Ys,{children:Re.costing_amount!=null?`${I.currency||Er} ${Re.costing_amount.toFixed(2)}`:"-"})]})]})]}),!ye&&!!Re.completed&&t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/30 px-6 pb-1 text-xs text-green-600 dark:text-green-400",children:"✓ Completed"})]},De)})})]}),ye&&t.jsxs("button",{type:"button",onClick:me,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-indigo-700 dark:text-indigo-400 border border-indigo-300 dark:border-indigo-700 rounded-lg hover:bg-indigo-50 dark:hover:bg-indigo-900/20 transition-colors",children:[t.jsx(Rr,{size:10})," Add Row"]}),t.jsxs("div",{className:"mt-4 flex items-center justify-between border-t border-gray-100 dark:border-gray-700 pt-3",children:[t.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Total Working Hours"}),t.jsx("span",{className:"text-sm font-bold text-gray-900 dark:text-white bg-gray-100 dark:bg-gray-700 px-3 py-1 rounded-lg",children:n?xe.toFixed(3):((Fe=b==null?void 0:b.total_hours)!=null?Fe:xe).toFixed?((ze=b==null?void 0:b.total_hours)!=null?ze:xe).toFixed(3):"0.000"})]})]}),t.jsx(Gb,{title:"Billing Details",icon:t.jsx(Zu,{className:"text-indigo-500",size:13}),defaultOpen:!1,children:t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:(()=>{const Re=I.time_logs||[],De=I.currency||Er,Et=Re.filter(Ct=>Ct.is_billable).reduce((Ct,vt)=>Ct+(vt.billing_hours||vt.hours||0),0),jt=Re.filter(Ct=>Ct.is_billable).reduce((Ct,vt)=>Ct+(vt.billing_amount||0),0),Ie=Re.reduce((Ct,vt)=>Ct+(vt.costing_amount||0),0),$e=b==null?void 0:b.total_billable_hours,Qe=b==null?void 0:b.total_billable_amount,at=b==null?void 0:b.total_costing_amount;return[{label:"Total Billable Hours",value:`${($e!=null?$e:Et).toFixed?($e!=null?$e:Et).toFixed(3):Et.toFixed(3)} hrs`},{label:"Total Billable Amount",value:`${De} ${(Qe!=null?Qe:jt).toFixed(2)}`},{label:"Total Costing Amount",value:`${De} ${(at!=null?at:Ie).toFixed(2)}`}].map(({label:Ct,value:vt})=>t.jsxs("div",{children:[t.jsx(sn,{children:Ct}),t.jsx(Ys,{children:vt})]},Ct))})()})}),t.jsx(Gb,{title:"Note",icon:t.jsx(X4,{className:"text-gray-400",size:13}),defaultOpen:!1,children:ye?t.jsx("textarea",{value:I.note||"",onChange:Re=>ie("note",Re.target.value),rows:4,placeholder:"Add notes for this timesheet…",className:`${ZD} resize-y`}):t.jsx(Ys,{children:I.note})}),!n&&b&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm py-4 px-5 grid grid-cols-2 sm:grid-cols-3 gap-3 text-xs text-gray-400 dark:text-gray-500",children:[t.jsxs("div",{children:[t.jsx("span",{className:"font-medium block text-gray-500 dark:text-gray-400",children:"Created By"}),b.owner||"-"]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium block text-gray-500 dark:text-gray-400",children:"Created"}),b.creation?new Date(b.creation).toLocaleString():"-"]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium block text-gray-500 dark:text-gray-400",children:"Modified"}),b.modified?new Date(b.modified).toLocaleString():"-"]})]}),!n&&t.jsx(vi,{doctype:"Timesheet",docname:r||"",creationDate:b==null?void 0:b.creation,createdBy:b==null?void 0:b.owner,compact:!1,initialVisible:5,collapsible:!0,startCollapsed:!0})]})]})},xf=20,l4e=()=>{const{t:e}=sr(),r=hr(),[a,s]=p.useState(""),[n,i]=p.useState(0),[o,l]=p.useState(!1),c=p.useMemo(()=>{const T={};return a.trim()&&(T.activity_type=["like",`%${a.trim()}%`]),T},[a]),{activityTypes:u,loading:h,totalCount:f,refetch:y}=UNe({filters:c,limit_start:n*xf,limit_page_length:xf,order_by:"name asc"});p.useEffect(()=>{y()},[n,c,y]);const b=p.useMemo(()=>`${n}|${JSON.stringify(c)}`,[n,c]),{selectedRows:w,toggleRow:v,toggleAllOnPage:k,allOnPageSelected:S,someOnPageSelected:N}=po(u,b),C=p.useCallback(()=>go({doctype:"Activity Type",filters:c,orderBy:"name asc"}),[c]),O=Math.max(1,Math.ceil(f/xf));return t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{type:"button",onClick:()=>r("/projects"),className:"text-sm text-gray-500 hover:text-teal-600 dark:text-gray-400 dark:hover:text-teal-400",children:e("projects.moduleTitle")}),t.jsx("span",{className:"text-gray-400",children:"/"}),t.jsxs("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white flex items-center gap-2",children:[t.jsx(Z9,{className:"text-teal-500"})," ",e("projects.activityTypeDoctype")]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>l(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all text-sm font-medium disabled:opacity-50",disabled:f===0&&w.size===0,children:[t.jsx(Sa,{})," ",e("listPages.export"),w.size>0&&t.jsx("span",{className:"bg-white/25 px-1.5 py-0.5 rounded text-xs font-bold",children:w.size})]}),t.jsx("button",{type:"button",onClick:()=>y(),className:"p-2 text-gray-500 border border-gray-200 dark:border-gray-600 rounded-lg hover:text-teal-600","aria-label":"Refresh",children:t.jsx(Ma,{size:14,className:h?"animate-spin":""})}),t.jsxs("button",{type:"button",onClick:()=>r("/projects/activity-types/new"),className:"flex items-center gap-2 px-4 py-2 bg-teal-600 text-white rounded-lg hover:bg-teal-700 text-sm font-medium",children:[t.jsx(Rr,{size:12})," New"]})]})]}),t.jsxs("div",{className:"mb-4 flex flex-wrap gap-3 items-center",children:[t.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-md",children:[t.jsx(za,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 text-xs"}),t.jsx("input",{value:a,onChange:T=>{s(T.target.value),i(0)},placeholder:"Search activity type…",className:"w-full pl-9 pr-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("span",{className:"text-xs text-gray-500",children:[f," total"]})]}),t.jsx(bi,{isOpen:o,onClose:()=>l(!1),doctype:"Activity Type",selectedCount:w.size,pageCount:u.length,totalCount:f,pageData:u,selectedRows:w,rowKey:"name",onFetchAll:C,fileNamePrefix:"activity_types"}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden",children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx("th",{className:"w-10 px-2 py-3",children:t.jsx("input",{type:"checkbox",className:"rounded border-gray-300 dark:border-gray-600 text-teal-600 focus:ring-teal-500",checked:S,ref:T=>{T&&(T.indeterminate=N)},onChange:k,"aria-label":"Select all on page"})}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Name"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Billing rate"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Costing rate"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Status"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-3 px-4 w-24",children:" "})]})}),t.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:h?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"text-center py-10 text-gray-400",children:"Loading…"})}):u.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"text-center py-10 text-gray-400",children:"No activity types found"})}):u.map(T=>{var P,E;return t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/30 cursor-pointer ${w.has(T.name)?"bg-teal-50/80 dark:bg-teal-900/20":""}`,onClick:()=>r(`/projects/activity-types/${encodeURIComponent(T.name)}`),children:[t.jsx("td",{className:"w-10 px-2 py-3",onClick:R=>R.stopPropagation(),children:t.jsx("input",{type:"checkbox",className:"rounded border-gray-300 dark:border-gray-600 text-teal-600 focus:ring-teal-500",checked:w.has(T.name),onChange:()=>v(T.name),"aria-label":`Select ${T.name}`})}),t.jsx("td",{className:"py-3 px-4 font-medium text-teal-600",children:T.activity_type||T.name}),t.jsx("td",{className:"py-3 px-4 text-gray-600 dark:text-gray-300",children:(P=T.billing_rate)!=null?P:"—"}),t.jsx("td",{className:"py-3 px-4 text-gray-600 dark:text-gray-300",children:(E=T.costing_rate)!=null?E:"—"}),t.jsx("td",{className:"py-3 px-4",children:t.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${T.disabled?"bg-red-100 text-red-700":"bg-green-100 text-green-700"}`,children:T.disabled?"Disabled":"Active"})}),t.jsx("td",{className:"py-3 px-4 text-right",children:t.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),r(`/projects/activity-types/${encodeURIComponent(T.name)}`)},className:"text-teal-600 hover:text-teal-800 p-1","aria-label":"View",children:t.jsx(Ps,{})})})]},T.name)})})]})}),f>xf&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-100 dark:border-gray-700",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:["Page ",n+1," of ",O]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"button",disabled:n===0,onClick:()=>i(T=>Math.max(0,T-1)),className:"px-3 py-1 text-xs border rounded disabled:opacity-40",children:"Prev"}),t.jsx("button",{type:"button",disabled:(n+1)*xf>=f,onClick:()=>i(T=>T+1),className:"px-3 py-1 text-xs border rounded disabled:opacity-40",children:"Next"})]})]})]})]})},c4e=()=>{var O,T;const{t:e}=sr(),{activityTypeName:r}=hs(),a=hr(),s=r==="new",{activityType:n,loading:i,error:o,refetch:l}=BNe(s?null:r||null),{createActivityType:c,updateActivityType:u,loading:h}=oy(),[f,y]=p.useState(s),[b,w]=p.useState({activity_type:"",billing_rate:void 0,costing_rate:void 0,disabled:0});p.useEffect(()=>{var P;n&&!s&&w({activity_type:n.activity_type||n.name||"",billing_rate:n.billing_rate,costing_rate:n.costing_rate,disabled:(P=n.disabled)!=null?P:0})},[n,s]);const v=(P,E)=>w(R=>je(se({},R),{[P]:E})),k=()=>J(null,null,function*(){var P,E,R;if(!((P=b.activity_type)!=null&&P.trim())){We.error("Activity Type name is required");return}try{if(s){const z=je(se(se({activity_type:b.activity_type.trim()},b.billing_rate!==void 0?{billing_rate:b.billing_rate}:{}),b.costing_rate!==void 0?{costing_rate:b.costing_rate}:{}),{disabled:(E=b.disabled)!=null?E:0}),G=yield c(z);We.success("Activity Type created",{icon:t.jsx(Qt,{})}),a(`/projects/activity-types/${encodeURIComponent(G.name)}`)}else{const z=je(se(se({},b.billing_rate!==void 0?{billing_rate:b.billing_rate}:{}),b.costing_rate!==void 0?{costing_rate:b.costing_rate}:{}),{disabled:(R=b.disabled)!=null?R:0});yield u(r,z),We.success("Activity Type updated",{icon:t.jsx(Qt,{})}),y(!1),l()}}catch(z){We.error(z instanceof Error?z.message:e("common.error"),{icon:t.jsx(pr,{})})}}),S=()=>{var P;y(!1),n&&w({activity_type:n.activity_type||n.name||"",billing_rate:n.billing_rate,costing_rate:n.costing_rate,disabled:(P=n.disabled)!=null?P:0})},N=P=>`w-full px-3 py-2 text-sm border rounded-lg ${P?"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-teal-400":"border-transparent bg-gray-50 dark:bg-gray-800 text-gray-800 dark:text-gray-200 cursor-default"}`,C=s||f;return i?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsx(tr,{className:"animate-spin text-teal-500 text-3xl"})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 px-6 py-6",children:[t.jsx($a,{position:"top-right",autoClose:3500}),t.jsxs("div",{className:"flex items-center gap-2 text-sm mb-6",children:[t.jsx("button",{onClick:()=>a("/projects"),className:"text-gray-500 hover:text-indigo-600 dark:text-gray-400",children:e("projects.moduleTitle")}),t.jsx("span",{className:"text-gray-400",children:"/"}),t.jsx("button",{onClick:()=>a("/projects/activity-types"),className:"text-gray-500 hover:text-teal-600 dark:text-gray-400",children:e("projects.activityTypeDoctype")}),t.jsx("span",{className:"text-gray-400",children:"/"}),t.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:s?e("projects.newActivityType"):(n==null?void 0:n.activity_type)||(n==null?void 0:n.name)||r})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 dark:border-gray-700 flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>a("/projects/activity-types"),className:"text-gray-400 hover:text-gray-700 dark:hover:text-gray-300",children:t.jsx(ia,{})}),t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:s?e("projects.newActivityType"):b.activity_type||r})]}),t.jsxs("div",{className:"flex gap-2",children:[!s&&!f&&t.jsxs("button",{onClick:()=>y(!0),className:"flex items-center gap-2 px-4 py-2 border border-teal-500 text-teal-600 dark:text-teal-400 rounded-lg hover:bg-teal-50 dark:hover:bg-teal-900/20 text-sm",children:[t.jsx(qr,{})," ",e("common.edit")]}),C&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:k,disabled:h,className:"flex items-center gap-2 px-4 py-2 bg-teal-600 text-white rounded-lg hover:bg-teal-700 disabled:opacity-50 text-sm",children:[h?t.jsx(tr,{className:"animate-spin"}):t.jsx(ta,{}),e(h?"common.saving":"common.save")]}),!s&&t.jsx("button",{onClick:S,className:"px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-600 dark:text-gray-400 text-sm",children:t.jsx(ht,{})})]})]})]}),o&&!s&&t.jsx("div",{className:"mx-6 mt-4 p-3 bg-red-50 dark:bg-red-900/20 rounded text-red-700 dark:text-red-300 text-sm",children:o}),t.jsxs("div",{className:"p-6 space-y-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-semibold text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:["Activity Type *",s&&t.jsx("span",{className:"ml-1 text-gray-400 font-normal normal-case text-xs",children:"(becomes the record name)"})]}),t.jsx("input",{type:"text",value:b.activity_type||"",onChange:P=>v("activity_type",P.target.value),disabled:!s,className:N(s),placeholder:"e.g. Design, Development, Testing..."}),!s&&t.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Activity Type name cannot be changed after creation."})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-semibold text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Billing Rate"}),t.jsx("input",{type:"number",min:0,step:.01,value:(O=b.billing_rate)!=null?O:"",onChange:P=>v("billing_rate",P.target.value?parseFloat(P.target.value):void 0),disabled:!C,className:N(C),placeholder:"0.00"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-semibold text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Costing Rate"}),t.jsx("input",{type:"number",min:0,step:.01,value:(T=b.costing_rate)!=null?T:"",onChange:P=>v("costing_rate",P.target.value?parseFloat(P.target.value):void 0),disabled:!C,className:N(C),placeholder:"0.00"})]})]}),t.jsx("div",{children:t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:!!b.disabled,onChange:P=>v("disabled",P.target.checked?1:0),disabled:!C,className:"w-4 h-4 text-red-500 rounded"}),t.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Disabled"})]})}),!s&&n&&t.jsxs("div",{className:"pt-4 border-t border-gray-100 dark:border-gray-700 grid grid-cols-2 gap-3 text-xs text-gray-500 dark:text-gray-400",children:[t.jsxs("div",{children:[t.jsx("span",{className:"font-medium block",children:"Created"}),n.creation?new Date(n.creation).toLocaleString():"-"]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium block",children:"Modified"}),n.modified?new Date(n.modified).toLocaleString():"-"]})]}),!s&&t.jsx("div",{className:"pt-4",children:t.jsx(vi,{doctype:"Activity Type",docname:(n==null?void 0:n.name)||r||"",creationDate:n==null?void 0:n.creation,createdBy:n==null?void 0:n.owner,compact:!1,initialVisible:5,collapsible:!0,startCollapsed:!0})})]})]})]})},yf=20,d4e=()=>{const{t:e}=sr(),r=hr(),[a,s]=p.useState(""),[n,i]=p.useState(0),[o,l]=p.useState(!1),c=p.useMemo(()=>{const T={};return a.trim()&&(T.name=["like",`%${a.trim()}%`]),T},[a]),{templates:u,loading:h,totalCount:f,refetch:y}=zNe({filters:c,limit_start:n*yf,limit_page_length:yf,order_by:"name asc"});p.useEffect(()=>{y()},[n,c,y]);const b=p.useMemo(()=>`${n}|${JSON.stringify(c)}`,[n,c]),{selectedRows:w,toggleRow:v,toggleAllOnPage:k,allOnPageSelected:S,someOnPageSelected:N}=po(u,b),C=p.useCallback(()=>go({doctype:"Project Template",filters:c,orderBy:"name asc"}),[c]),O=Math.max(1,Math.ceil(f/yf));return t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{type:"button",onClick:()=>r("/projects"),className:"text-sm text-gray-500 hover:text-violet-600 dark:text-gray-400 dark:hover:text-violet-400",children:e("projects.moduleTitle")}),t.jsx("span",{className:"text-gray-400",children:"/"}),t.jsxs("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white flex items-center gap-2",children:[t.jsx(V9,{className:"text-violet-500"})," ",e("projects.projectTemplateDoctype")]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>l(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all text-sm font-medium disabled:opacity-50",disabled:f===0&&w.size===0,children:[t.jsx(Sa,{})," ",e("listPages.export"),w.size>0&&t.jsx("span",{className:"bg-white/25 px-1.5 py-0.5 rounded text-xs font-bold",children:w.size})]}),t.jsx("button",{type:"button",onClick:()=>y(),className:"p-2 text-gray-500 border border-gray-200 dark:border-gray-600 rounded-lg hover:text-violet-600","aria-label":"Refresh",children:t.jsx(Ma,{size:14,className:h?"animate-spin":""})}),t.jsxs("button",{type:"button",onClick:()=>r("/projects/templates/new"),className:"flex items-center gap-2 px-4 py-2 bg-violet-600 text-white rounded-lg hover:bg-violet-700 text-sm font-medium",children:[t.jsx(Rr,{size:12})," New"]})]})]}),t.jsxs("div",{className:"mb-4 flex flex-wrap gap-3 items-center",children:[t.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-md",children:[t.jsx(za,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 text-xs"}),t.jsx("input",{value:a,onChange:T=>{s(T.target.value),i(0)},placeholder:"Search template…",className:"w-full pl-9 pr-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("span",{className:"text-xs text-gray-500",children:[f," total"]})]}),t.jsx(bi,{isOpen:o,onClose:()=>l(!1),doctype:"Project Template",selectedCount:w.size,pageCount:u.length,totalCount:f,pageData:u,selectedRows:w,rowKey:"name",onFetchAll:C,fileNamePrefix:"project_templates"}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden",children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx("th",{className:"w-10 px-2 py-3",children:t.jsx("input",{type:"checkbox",className:"rounded border-gray-300 dark:border-gray-600 text-violet-600 focus:ring-violet-500",checked:S,ref:T=>{T&&(T.indeterminate=N)},onChange:k,"aria-label":"Select all on page"})}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Name"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Project type"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Modified"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-3 px-4 w-24",children:" "})]})}),t.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:h?t.jsx("tr",{children:t.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-400",children:"Loading…"})}):u.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-400",children:"No templates found"})}):u.map(T=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/30 cursor-pointer ${w.has(T.name)?"bg-violet-50/80 dark:bg-violet-900/20":""}`,onClick:()=>r(`/projects/templates/${encodeURIComponent(T.name)}`),children:[t.jsx("td",{className:"w-10 px-2 py-3",onClick:P=>P.stopPropagation(),children:t.jsx("input",{type:"checkbox",className:"rounded border-gray-300 dark:border-gray-600 text-violet-600 focus:ring-violet-500",checked:w.has(T.name),onChange:()=>v(T.name),"aria-label":`Select ${T.name}`})}),t.jsx("td",{className:"py-3 px-4 font-medium text-violet-600",children:T.name}),t.jsx("td",{className:"py-3 px-4 text-gray-600 dark:text-gray-300",children:T.project_type||"—"}),t.jsx("td",{className:"py-3 px-4 text-gray-500 text-xs",children:T.modified?new Date(T.modified).toLocaleDateString():"—"}),t.jsx("td",{className:"py-3 px-4 text-right",children:t.jsx("button",{type:"button",onClick:P=>{P.stopPropagation(),r(`/projects/templates/${encodeURIComponent(T.name)}`)},className:"text-violet-600 hover:text-violet-800 p-1","aria-label":"View",children:t.jsx(Ps,{})})})]},T.name))})]})}),f>yf&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-100 dark:border-gray-700",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:["Page ",n+1," of ",O]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"button",disabled:n===0,onClick:()=>i(T=>Math.max(0,T-1)),className:"px-3 py-1 text-xs border rounded disabled:opacity-40",children:"Prev"}),t.jsx("button",{type:"button",disabled:(n+1)*yf>=f,onClick:()=>i(T=>T+1),className:"px-3 py-1 text-xs border rounded disabled:opacity-40",children:"Next"})]})]})]})]})},QD=()=>({task:"",subject:"",duration:void 0}),u4e=e=>e.filter(r=>{var a;return(a=r.task)==null?void 0:a.trim()}).map(({task:r,duration:a})=>se({task:r.trim()},a!==void 0?{duration:a}:{})),m4e=()=>{const{t:e}=sr(),{templateName:r}=hs(),a=hr(),s=r==="new",{template:n,loading:i,error:o,refetch:l}=$Ne(s?null:r||null),{createProjectTemplate:c,updateProjectTemplate:u,loading:h}=oy(),[f,y]=p.useState(s),[b,w]=p.useState({name:"",project_type:"",tasks:[QD()]});p.useEffect(()=>{var P;n&&!s&&w({name:n.name||"",project_type:n.project_type||"",tasks:(P=n.tasks)!=null&&P.length?n.tasks:[]})},[n,s]);const v=(P,E)=>w(R=>je(se({},R),{[P]:E})),k=()=>w(P=>je(se({},P),{tasks:[...P.tasks||[],QD()]})),S=(P,E,R)=>w(z=>{const G=[...z.tasks||[]];return G[P]=je(se({},G[P]),{[E]:R}),je(se({},z),{tasks:G})}),N=P=>w(E=>{const R=[...E.tasks||[]];return R.splice(P,1),je(se({},E),{tasks:R})}),C=()=>J(null,null,function*(){var R,z;if(!((R=b.name)!=null&&R.trim())){We.error("Template name is required");return}const P=u4e(b.tasks||[]),E=je(se({name:b.name.trim()},(z=b.project_type)!=null&&z.trim()?{project_type:b.project_type.trim()}:{}),{tasks:P});try{if(s){const G=yield c(E);We.success(e("projects.templateCreated"),{icon:t.jsx(Qt,{})}),a(`/projects/templates/${encodeURIComponent(G.name)}`)}else yield u(r,E),We.success(e("projects.templateUpdated"),{icon:t.jsx(Qt,{})}),y(!1),l()}catch(G){We.error(G instanceof Error?G.message:e("common.error"),{icon:t.jsx(pr,{})})}}),O=P=>`w-full px-3 py-2 text-sm border rounded-lg ${P?"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-purple-400":"border-transparent bg-gray-50 dark:bg-gray-800 text-gray-800 dark:text-gray-200 cursor-default"}`,T=s||f;return i?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsx(tr,{className:"animate-spin text-purple-500 text-3xl"})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 px-6 py-6",children:[t.jsx($a,{position:"top-right",autoClose:3500}),t.jsxs("div",{className:"flex items-center gap-2 text-sm mb-6",children:[t.jsx("button",{onClick:()=>a("/projects"),className:"text-gray-500 hover:text-indigo-600 dark:text-gray-400",children:e("projects.moduleTitle")}),t.jsx("span",{className:"text-gray-400",children:"/"}),t.jsx("button",{onClick:()=>a("/projects/templates"),className:"text-gray-500 hover:text-purple-600 dark:text-gray-400",children:e("projects.projectTemplateDoctype")}),t.jsx("span",{className:"text-gray-400",children:"/"}),t.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:s?e("projects.newProjectTemplate"):r})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 dark:border-gray-700 flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>a("/projects/templates"),className:"text-gray-400 hover:text-gray-700 dark:hover:text-gray-300",children:t.jsx(ia,{})}),t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:s?e("projects.newProjectTemplate"):b.name||r})]}),t.jsxs("div",{className:"flex gap-2",children:[!s&&!f&&t.jsxs("button",{onClick:()=>y(!0),className:"flex items-center gap-2 px-4 py-2 border border-purple-500 text-purple-600 dark:text-purple-400 rounded-lg hover:bg-purple-50 dark:hover:bg-purple-900/20 text-sm",children:[t.jsx(qr,{})," ",e("common.edit")]}),T&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:C,disabled:h,className:"flex items-center gap-2 px-4 py-2 bg-purple-600 text-white rounded-lg hover:bg-purple-700 disabled:opacity-50 text-sm",children:[h?t.jsx(tr,{className:"animate-spin"}):t.jsx(ta,{}),e(h?"common.saving":"common.save")]}),!s&&t.jsx("button",{onClick:()=>y(!1),className:"px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg text-sm",children:t.jsx(ht,{})})]})]})]}),o&&!s&&t.jsx("div",{className:"mx-6 mt-4 p-3 bg-red-50 dark:bg-red-900/20 rounded text-red-700 dark:text-red-300 text-sm",children:o}),t.jsxs("div",{className:"p-6 grid grid-cols-1 sm:grid-cols-2 gap-4 border-b border-gray-100 dark:border-gray-700",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-semibold text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Name *"}),t.jsx("input",{type:"text",value:b.name||"",onChange:P=>v("name",P.target.value),disabled:!s,className:O(s),placeholder:"Template name..."}),!s&&t.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Name cannot be changed after creation"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-semibold text-gray-600 dark:text-gray-400 uppercase tracking-wide mb-1",children:"Project Type"}),T?t.jsx(Je,{label:"Project Type",hideLabel:!0,value:b.project_type||"",onChange:P=>v("project_type",P),doctype:"Project Type",placeholder:"Select project type..."}):t.jsx("div",{className:"px-3 py-2 text-sm text-gray-800 dark:text-gray-200",children:b.project_type||"-"})]})]}),t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 uppercase tracking-wide",children:"Tasks"}),T&&t.jsxs("button",{onClick:k,className:"flex items-center gap-1.5 px-3 py-1.5 bg-purple-600 text-white text-xs rounded-lg hover:bg-purple-700",children:[t.jsx(Rr,{})," Add Row"]})]}),t.jsxs("div",{className:"flex items-start gap-2 mb-3 p-3 bg-blue-50 dark:bg-blue-900/20 rounded-lg border border-blue-200 dark:border-blue-800 text-xs text-blue-700 dark:text-blue-300",children:[t.jsx(ro,{className:"mt-0.5 flex-shrink-0"}),t.jsxs("span",{children:["Each row links to a ",t.jsx("strong",{children:"Task"})," that has ",t.jsx("strong",{children:"Is Template = Yes"}),". To create a new template task, first go to"," ",t.jsx("button",{onClick:()=>a("/projects/tasks/new"),className:"underline hover:text-blue-900 dark:hover:text-blue-100",children:"Tasks → New Task"})," ",'and check "Is Template", then come back and select it here.']})]}),(b.tasks||[]).length===0?t.jsx("div",{className:"py-8 text-center text-gray-400 dark:text-gray-500 text-sm bg-gray-50 dark:bg-gray-900/30 rounded-lg border border-dashed border-gray-300 dark:border-gray-600",children:T?'Click "Add Row" to link template tasks':"No tasks defined"}):t.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-200 dark:border-gray-700",children:t.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700 text-sm",children:[t.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/50",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 uppercase w-10",children:"No."}),t.jsxs("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 uppercase min-w-[280px]",children:["Task * ",t.jsx("span",{className:"font-normal normal-case text-gray-400",children:"(is_template=Yes)"})]}),t.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 uppercase",children:"Subject"}),t.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 uppercase w-28",children:"Duration (days)"}),T&&t.jsx("th",{className:"px-3 py-2 w-10"})]})}),t.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:(b.tasks||[]).map((P,E)=>{var R,z;return t.jsxs("tr",{children:[t.jsx("td",{className:"px-3 py-2 text-gray-500 text-xs font-medium",children:E+1}),t.jsx("td",{className:"px-2 py-1.5 min-w-[280px]",children:T?t.jsx(Je,{label:"Task",hideLabel:!0,value:P.task||"",onChange:G=>S(E,"task",G),doctype:"Task",placeholder:"Search template task...",compact:!0}):t.jsx("span",{className:"text-gray-800 dark:text-gray-200 font-medium",children:P.task||"-"})}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("span",{className:"text-gray-600 dark:text-gray-400 text-xs italic",children:P.subject||"(from task)"})}),t.jsx("td",{className:"px-2 py-1.5",children:T?t.jsx("input",{type:"number",min:0,value:(R=P.duration)!=null?R:"",onChange:G=>S(E,"duration",G.target.value?parseInt(G.target.value):void 0),placeholder:"0",className:"w-full px-2 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-1 focus:ring-purple-400"}):t.jsx("span",{className:"text-gray-700 dark:text-gray-300 text-sm",children:(z=P.duration)!=null?z:"-"})}),T&&t.jsx("td",{className:"px-3 py-2",children:t.jsx("button",{onClick:()=>N(E),className:"text-red-500 hover:text-red-700 p-1 rounded hover:bg-red-50 dark:hover:bg-red-900/20",children:t.jsx(wr,{size:12})})})]},E)})})]})}),!s&&n&&t.jsxs("div",{className:"mt-6 pt-4 border-t border-gray-100 dark:border-gray-700 grid grid-cols-2 gap-3 text-xs text-gray-500 dark:text-gray-400",children:[t.jsxs("div",{children:[t.jsx("span",{className:"font-medium block",children:"Created"}),n.creation?new Date(n.creation).toLocaleString():"-"]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium block",children:"Modified"}),n.modified?new Date(n.modified).toLocaleString():"-"]})]}),!s&&t.jsx("div",{className:"mt-4",children:t.jsx(vi,{doctype:"Project Template",docname:(n==null?void 0:n.name)||r||"",creationDate:n==null?void 0:n.creation,createdBy:n==null?void 0:n.owner,compact:!1,initialVisible:5,collapsible:!0,startCollapsed:!0})})]})]})]})},h4e=e=>e?"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300":"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-300",p4e=()=>{const{t:e}=sr(),r=hr(),[a,s]=p.useState([]),[n,i]=p.useState(!0),[o,l]=p.useState(""),[c,u]=p.useState(0),[h,f]=p.useState(0),[y,b]=p.useState(!1),w=20,v=p.useMemo(()=>{const z={};return o.trim()&&(z.customer_name=["like",`%${o.trim()}%`]),z},[o]),k=p.useCallback((z=0)=>J(null,null,function*(){i(!0);try{const[{data:G},ae]=yield Promise.all([fl.getCustomers({limit_start:z*w,limit_page_length:w,filters:v}),fl.getCustomerCount(v)]);s(G),f(ae),u(z)}catch(G){We.error(G instanceof Error?G.message:"Failed to load customers")}finally{i(!1)}}),[v]);p.useEffect(()=>{k(0)},[k]);const S=p.useMemo(()=>`${c}|${JSON.stringify(v)}`,[c,v]),{selectedRows:N,toggleRow:C,toggleAllOnPage:O,allOnPageSelected:T,someOnPageSelected:P}=po(a,S),E=p.useCallback(()=>go({doctype:"Customer",filters:v,orderBy:"modified desc"}),[v]),R=z=>{l(z.target.value)};return t.jsxs("div",{className:"p-6",children:[t.jsx($a,{position:"top-right",autoClose:3e3}),t.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[t.jsx("button",{onClick:()=>r("/projects"),className:"text-gray-400 hover:text-gray-700 dark:hover:text-gray-300",children:t.jsx(ia,{})}),t.jsx("div",{className:"w-10 h-10 rounded-xl bg-cyan-600 flex items-center justify-center",children:t.jsx(Ev,{className:"text-white text-lg"})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:"Customers"}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:[h," total"]})]}),t.jsxs("div",{className:"ml-auto flex flex-wrap gap-2 items-center",children:[t.jsxs("button",{type:"button",onClick:()=>b(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all text-sm font-medium disabled:opacity-50",disabled:h===0&&N.size===0||n,children:[t.jsx(Sa,{})," ",e("listPages.export"),N.size>0&&t.jsx("span",{className:"bg-white/25 px-1.5 py-0.5 rounded text-xs font-bold",children:N.size})]}),t.jsxs("div",{className:"relative",children:[t.jsx(za,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 text-xs"}),t.jsx("input",{value:o,onChange:R,placeholder:"Search customers…",className:"pl-8 pr-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white w-52 focus:outline-none focus:ring-2 focus:ring-cyan-400"})]}),t.jsxs("button",{onClick:()=>r("/customers/new"),className:"flex items-center gap-2 px-4 py-2 bg-cyan-600 text-white rounded-lg hover:bg-cyan-700 text-sm font-medium",children:[t.jsx(Rr,{size:11})," New Customer"]})]})]}),t.jsx(bi,{isOpen:y,onClose:()=>b(!1),doctype:"Customer",selectedCount:N.size,pageCount:a.length,totalCount:h,pageData:a,selectedRows:N,rowKey:"name",onFetchAll:E,fileNamePrefix:"customers"}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm overflow-hidden",children:n?t.jsx("div",{className:"flex justify-center items-center py-16",children:t.jsx(tr,{className:"animate-spin text-cyan-500 text-2xl"})}):a.length===0?t.jsxs("div",{className:"py-16 text-center text-gray-400 dark:text-gray-500",children:[t.jsx(Ev,{className:"mx-auto text-4xl mb-3 opacity-30"}),t.jsx("p",{className:"text-sm",children:"No customers found"}),t.jsx("button",{onClick:()=>r("/customers/new"),className:"mt-3 text-sm text-cyan-600 hover:underline",children:"+ Create first customer"})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-[2.5rem_1fr_1fr_1fr_1fr_100px] bg-gray-50 dark:bg-gray-900/50 border-b border-gray-200 dark:border-gray-700 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:[t.jsx("div",{className:"px-2 py-3 flex items-center justify-center",children:t.jsx("input",{type:"checkbox",className:"rounded border-gray-300 dark:border-gray-600 text-cyan-600 focus:ring-cyan-500",checked:T,ref:z=>{z&&(z.indeterminate=P)},onChange:O,"aria-label":"Select all on page"})}),t.jsx("div",{className:"px-4 py-3",children:"Customer Name"}),t.jsx("div",{className:"px-4 py-3",children:"Type"}),t.jsx("div",{className:"px-4 py-3",children:"Customer Group"}),t.jsx("div",{className:"px-4 py-3",children:"Territory"}),t.jsx("div",{className:"px-4 py-3",children:"Status"})]}),t.jsx("div",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:a.map(z=>t.jsxs("div",{role:"button",tabIndex:0,onClick:()=>r(`/customers/${encodeURIComponent(z.name)}`),onKeyDown:G=>{(G.key==="Enter"||G.key===" ")&&(G.preventDefault(),r(`/customers/${encodeURIComponent(z.name)}`))},className:`grid grid-cols-[2.5rem_1fr_1fr_1fr_1fr_100px] w-full text-left hover:bg-gray-50 dark:hover:bg-gray-700/30 transition-colors cursor-pointer ${N.has(z.name)?"bg-cyan-50/70 dark:bg-cyan-900/15":""}`,children:[t.jsx("div",{className:"px-2 py-3 flex items-center justify-center",onClick:G=>G.stopPropagation(),children:t.jsx("input",{type:"checkbox",className:"rounded border-gray-300 dark:border-gray-600 text-cyan-600 focus:ring-cyan-500",checked:N.has(z.name),onChange:()=>C(z.name),"aria-label":`Select ${z.name}`})}),t.jsxs("div",{className:"px-4 py-3",children:[t.jsx("p",{className:"text-sm font-medium text-indigo-600 dark:text-indigo-400",children:z.customer_name||z.name}),t.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:z.name})]}),t.jsx("div",{className:"px-4 py-3 text-sm text-gray-700 dark:text-gray-300",children:z.customer_type||"-"}),t.jsx("div",{className:"px-4 py-3 text-sm text-gray-700 dark:text-gray-300",children:z.customer_group||"-"}),t.jsx("div",{className:"px-4 py-3 text-sm text-gray-700 dark:text-gray-300",children:z.territory||"-"}),t.jsx("div",{className:"px-4 py-3",children:t.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${h4e(z.disabled)}`,children:z.disabled?"Disabled":"Active"})})]},z.name))}),t.jsxs("div",{className:"px-4 py-3 border-t border-gray-100 dark:border-gray-700 flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[t.jsxs("span",{children:["Page ",c+1]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>k(c-1),disabled:c===0,className:"px-3 py-1 border border-gray-300 dark:border-gray-600 rounded disabled:opacity-40 hover:bg-gray-50 dark:hover:bg-gray-700",children:"Prev"}),t.jsx("button",{onClick:()=>k(c+1),disabled:a.length<w,className:"px-3 py-1 border border-gray-300 dark:border-gray-600 rounded disabled:opacity-40 hover:bg-gray-50 dark:hover:bg-gray-700",children:"Next"})]})]})]})})]})},Jh=({children:e,required:r})=>t.jsxs("label",{className:"block text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1",children:[e,r&&t.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),Zh=({children:e})=>t.jsx("div",{className:"px-3 py-2 text-sm text-gray-800 dark:text-gray-200 bg-gray-50 dark:bg-gray-800/60 rounded-lg min-h-[38px] flex items-center",children:e||t.jsx("span",{className:"text-gray-400",children:"-"})}),nN="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-cyan-400",g4e=({title:e,children:r,defaultOpen:a=!0})=>{const[s,n]=p.useState(a);return t.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700",children:[t.jsxs("button",{type:"button",onClick:()=>n(i=>!i),className:"w-full flex items-center justify-between px-6 py-3 hover:bg-gray-50 dark:hover:bg-gray-700/30 transition-colors",children:[t.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:e}),s?t.jsx(Fr,{className:"text-gray-400 text-xs"}):t.jsx(Fi,{className:"text-gray-400 text-xs"})]}),s&&t.jsx("div",{className:"px-6 pb-5",children:r})]})},f4e=["Company","Individual","Hospital"],x4e=()=>{var T,P;const{customerName:e}=hs(),r=hr(),a=e==="new",[s,n]=p.useState(null),[i,o]=p.useState(!a),[l,c]=p.useState(!1),[u,h]=p.useState(a),[f,y]=p.useState(""),b={customer_name:"",customer_type:"Company",customer_group:"All Customer Groups",territory:"All Territories",language:"en",is_internal_customer:0,default_commission_rate:0,so_required:0,dn_required:0,is_frozen:0,disabled:0},[w,v]=p.useState(b),k=p.useCallback(E=>{var R,z,G,ae,ee,ne;v({customer_name:E.customer_name||"",customer_type:E.customer_type||"Company",customer_group:E.customer_group||"",territory:E.territory||"",language:E.language||"en",is_internal_customer:(R=E.is_internal_customer)!=null?R:0,default_commission_rate:(z=E.default_commission_rate)!=null?z:0,so_required:(G=E.so_required)!=null?G:0,dn_required:(ae=E.dn_required)!=null?ae:0,is_frozen:(ee=E.is_frozen)!=null?ee:0,disabled:(ne=E.disabled)!=null?ne:0})},[]);p.useEffect(()=>{!a&&e&&(o(!0),fl.getCustomer(e).then(E=>{n(E),k(E)}).catch(E=>y(E.message)).finally(()=>o(!1)))},[e,a,k]);const S=(E,R)=>v(z=>je(se({},z),{[E]:R})),N=()=>J(null,null,function*(){var E;if(!((E=w.customer_name)!=null&&E.trim())){We.error("Customer Name is required");return}c(!0);try{if(a){const R=yield fl.createCustomer(w);We.success("Customer created",{icon:t.jsx(Qt,{})}),r(`/customers/${encodeURIComponent(R.name)}`)}else{const R=yield fl.updateCustomer(e,w);We.success("Customer updated",{icon:t.jsx(Qt,{})}),n(R),k(R),h(!1)}}catch(R){We.error(R instanceof Error?R.message:"Save failed",{icon:t.jsx(pr,{})})}finally{c(!1)}}),C=()=>{s&&k(s),h(!1)},O=a||u;return i?t.jsx("div",{className:"flex justify-center items-center min-h-[400px]",children:t.jsx(tr,{className:"animate-spin text-cyan-500 text-3xl"})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 px-6 py-6",children:[t.jsx($a,{position:"top-right",autoClose:3500}),t.jsxs("div",{className:"flex items-center gap-2 text-sm mb-6 text-gray-500 dark:text-gray-400",children:[t.jsx("button",{onClick:()=>r("/projects"),className:"hover:text-cyan-600",children:"Project Management"}),t.jsx("span",{children:"/"}),t.jsx("button",{onClick:()=>r("/customers"),className:"hover:text-cyan-600",children:"Customers"}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:a?"New Customer":e})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 dark:border-gray-700 flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>r("/customers"),className:"text-gray-400 hover:text-gray-700 dark:hover:text-gray-300",children:t.jsx(ia,{})}),t.jsx("div",{className:"w-10 h-10 rounded-xl bg-cyan-600 flex items-center justify-center flex-shrink-0",children:t.jsx(Ev,{className:"text-white"})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:a?"New Customer":(s==null?void 0:s.customer_name)||e}),!a&&s&&t.jsx("span",{className:`text-xs px-2 py-0.5 rounded font-medium ${s.disabled?"bg-red-100 text-red-700":"bg-green-100 text-green-700"}`,children:s.disabled?"Disabled":"Active"})]})]}),t.jsxs("div",{className:"flex gap-2",children:[!a&&!u&&t.jsxs("button",{onClick:()=>h(!0),className:"flex items-center gap-2 px-4 py-2 bg-cyan-600 text-white rounded-lg hover:bg-cyan-700 text-sm",children:[t.jsx(qr,{})," Edit"]}),O&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:N,disabled:l,className:"flex items-center gap-2 px-4 py-2 bg-cyan-600 text-white rounded-lg hover:bg-cyan-700 disabled:opacity-50 text-sm font-medium",children:[l?t.jsx(tr,{className:"animate-spin"}):t.jsx(ta,{}),l?"Saving…":"Save"]}),!a&&t.jsx("button",{onClick:C,className:"px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-600 dark:text-gray-400 text-sm",children:t.jsx(ht,{})})]})]})]}),f&&t.jsx("div",{className:"mx-6 mt-4 p-3 bg-red-50 dark:bg-red-900/20 rounded text-red-700 dark:text-red-300 text-sm",children:f}),t.jsxs("div",{className:"p-6 grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-4 border-b border-gray-100 dark:border-gray-700",children:[t.jsxs("div",{className:"sm:col-span-2",children:[t.jsx(Jh,{required:!0,children:"Customer Name"}),O?t.jsx("input",{value:w.customer_name||"",onChange:E=>S("customer_name",E.target.value),className:nN,placeholder:"Enter customer name"}):t.jsx(Zh,{children:w.customer_name})]}),t.jsxs("div",{children:[t.jsx(Jh,{children:"Customer Type"}),O?t.jsx("select",{value:w.customer_type||"Company",onChange:E=>S("customer_type",E.target.value),className:nN,children:f4e.map(E=>t.jsx("option",{children:E},E))}):t.jsx(Zh,{children:w.customer_type})]}),t.jsxs("div",{children:[t.jsx(Jh,{children:"Territory"}),O?t.jsx(Je,{label:"Territory",hideLabel:!0,doctype:"Territory",value:w.territory||"",onChange:E=>S("territory",E),placeholder:"Select territory…"}):t.jsx(Zh,{children:w.territory})]}),t.jsxs("div",{children:[t.jsx(Jh,{children:"Customer Group"}),O?t.jsx(Je,{label:"Customer Group",hideLabel:!0,doctype:"Customer Group",value:w.customer_group||"",onChange:E=>S("customer_group",E),placeholder:"Select group…"}):t.jsx(Zh,{children:w.customer_group})]}),t.jsxs("div",{children:[t.jsx(Jh,{children:"Language"}),O?t.jsx(Je,{label:"Language",hideLabel:!0,doctype:"Language",value:w.language||"",onChange:E=>S("language",E),placeholder:"Select language…"}):t.jsx(Zh,{children:w.language})]})]}),t.jsx(g4e,{title:"Settings",defaultOpen:!1,children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-4",children:[t.jsxs("div",{children:[t.jsx(Jh,{children:"Default Commission Rate (%)"}),O?t.jsx("input",{type:"number",min:0,max:100,step:.01,value:(T=w.default_commission_rate)!=null?T:0,onChange:E=>S("default_commission_rate",parseFloat(E.target.value)||0),className:nN}):t.jsx(Zh,{children:(P=w.default_commission_rate)!=null?P:0})]}),[{field:"is_internal_customer",label:"Is Internal Customer"},{field:"so_required",label:"Sales Order Required"},{field:"dn_required",label:"Delivery Note Required"},{field:"is_frozen",label:"Is Frozen"},{field:"disabled",label:"Disabled"}].map(({field:E,label:R})=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("input",{type:"checkbox",id:E,checked:!!w[E],onChange:z=>S(E,z.target.checked?1:0),disabled:!O,className:"w-4 h-4 text-cyan-600 rounded"}),t.jsx("label",{htmlFor:E,className:"text-sm text-gray-700 dark:text-gray-300",children:R})]},E))]})}),!a&&s&&t.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 dark:border-gray-700 grid grid-cols-2 sm:grid-cols-3 gap-3 text-xs text-gray-400 dark:text-gray-500",children:[t.jsxs("div",{children:[t.jsx("span",{className:"font-medium block text-gray-500 dark:text-gray-400",children:"Created By"}),s.owner]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium block text-gray-500 dark:text-gray-400",children:"Created"}),s.creation?new Date(s.creation).toLocaleString():"-"]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium block text-gray-500 dark:text-gray-400",children:"Modified"}),s.modified?new Date(s.modified).toLocaleString():"-"]})]}),!a&&t.jsx("div",{className:"px-6 pb-6",children:t.jsx(vi,{doctype:"Customer",docname:(s==null?void 0:s.name)||e||"",creationDate:s==null?void 0:s.creation,createdBy:s==null?void 0:s.owner,compact:!1,initialVisible:5,collapsible:!0,startCollapsed:!0})})]})]})},iN=20,y4e=e=>{const r=(e||"").toLowerCase();return r==="active"?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-300":r==="inactive"||r==="left"?"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300":"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300"},b4e=()=>{const{t:e}=sr(),r=hr(),[a,s]=p.useState([]),[n,i]=p.useState(!0),[o,l]=p.useState(""),[c,u]=p.useState(0),[h,f]=p.useState(0),[y,b]=p.useState(!1),w=p.useMemo(()=>{const R={};return o.trim()&&(R.employee_name=["like",`%${o.trim()}%`]),R},[o]),v=p.useCallback((R=0)=>J(null,null,function*(){i(!0);try{const[{data:z},G]=yield Promise.all([fl.getEmployees({limit_start:R*iN,limit_page_length:iN,filters:w}),fl.getEmployeeCount(w)]);s(z),f(G),u(R)}catch(z){We.error(z instanceof Error?z.message:"Failed to load employees")}finally{i(!1)}}),[w]);p.useEffect(()=>{v(0)},[v]);const k=p.useMemo(()=>`${c}|${JSON.stringify(w)}`,[c,w]),{selectedRows:S,toggleRow:N,toggleAllOnPage:C,allOnPageSelected:O,someOnPageSelected:T}=po(a,k),P=p.useCallback(()=>go({doctype:"Employee",filters:w,orderBy:"modified desc"}),[w]),E=R=>{l(R.target.value)};return t.jsxs("div",{className:"p-6",children:[t.jsx($a,{position:"top-right",autoClose:3e3}),t.jsxs("div",{className:"flex items-center gap-3 mb-6 flex-wrap",children:[t.jsx("button",{type:"button",onClick:()=>r("/projects"),className:"text-gray-400 hover:text-gray-700 dark:hover:text-gray-300",children:t.jsx(ia,{})}),t.jsx("div",{className:"w-10 h-10 rounded-xl bg-teal-600 flex items-center justify-center",children:t.jsx(Av,{className:"text-white text-lg"})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:"Employees"}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:[h," total"]})]}),t.jsxs("div",{className:"ml-auto flex flex-wrap gap-2 items-center",children:[t.jsxs("button",{type:"button",onClick:()=>b(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all text-sm font-medium disabled:opacity-50",disabled:h===0&&S.size===0||n,children:[t.jsx(Sa,{})," ",e("listPages.export"),S.size>0&&t.jsx("span",{className:"bg-white/25 px-1.5 py-0.5 rounded text-xs font-bold",children:S.size})]}),t.jsxs("div",{className:"relative",children:[t.jsx(za,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 text-xs"}),t.jsx("input",{value:o,onChange:E,placeholder:"Search employees…",className:"pl-8 pr-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white w-52 focus:outline-none focus:ring-2 focus:ring-teal-400"})]}),t.jsxs("button",{type:"button",onClick:()=>r("/employees/new"),className:"flex items-center gap-2 px-4 py-2 bg-teal-600 text-white rounded-lg hover:bg-teal-700 text-sm font-medium",children:[t.jsx(Rr,{size:11})," New Employee"]})]})]}),t.jsx(bi,{isOpen:y,onClose:()=>b(!1),doctype:"Employee",selectedCount:S.size,pageCount:a.length,totalCount:h,pageData:a,selectedRows:S,rowKey:"name",onFetchAll:P,fileNamePrefix:"employees"}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm overflow-hidden",children:n?t.jsx("div",{className:"flex justify-center items-center py-16",children:t.jsx(tr,{className:"animate-spin text-teal-500 text-2xl"})}):a.length===0?t.jsxs("div",{className:"py-16 text-center text-gray-400 dark:text-gray-500",children:[t.jsx(Av,{className:"mx-auto text-4xl mb-3 opacity-30"}),t.jsx("p",{className:"text-sm",children:"No employees found"}),t.jsx("button",{type:"button",onClick:()=>r("/employees/new"),className:"mt-3 text-sm text-teal-600 hover:underline",children:"+ Create first employee"})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-[2.5rem_1fr_1fr_1fr_1fr_120px] bg-gray-50 dark:bg-gray-900/50 border-b border-gray-200 dark:border-gray-700 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:[t.jsx("div",{className:"px-2 py-3 flex items-center justify-center",children:t.jsx("input",{type:"checkbox",className:"rounded border-gray-300 dark:border-gray-600 text-teal-600 focus:ring-teal-500",checked:O,ref:R=>{R&&(R.indeterminate=T)},onChange:C,"aria-label":"Select all on page"})}),t.jsx("div",{className:"px-4 py-3",children:"Name"}),t.jsx("div",{className:"px-4 py-3",children:"ID"}),t.jsx("div",{className:"px-4 py-3",children:"Department"}),t.jsx("div",{className:"px-4 py-3",children:"Company"}),t.jsx("div",{className:"px-4 py-3",children:"Status"})]}),t.jsx("div",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:a.map(R=>t.jsxs("div",{role:"button",tabIndex:0,onClick:()=>r(`/employees/${encodeURIComponent(R.name)}`),onKeyDown:z=>{(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),r(`/employees/${encodeURIComponent(R.name)}`))},className:`grid grid-cols-[2.5rem_1fr_1fr_1fr_1fr_120px] w-full text-left hover:bg-gray-50 dark:hover:bg-gray-700/30 transition-colors cursor-pointer ${S.has(R.name)?"bg-teal-50/80 dark:bg-teal-900/20":""}`,children:[t.jsx("div",{className:"px-2 py-3 flex items-center justify-center",onClick:z=>z.stopPropagation(),children:t.jsx("input",{type:"checkbox",className:"rounded border-gray-300 dark:border-gray-600 text-teal-600 focus:ring-teal-500",checked:S.has(R.name),onChange:()=>N(R.name),"aria-label":`Select ${R.name}`})}),t.jsx("div",{className:"px-4 py-3",children:t.jsx("p",{className:"text-sm font-medium text-teal-600 dark:text-teal-400",children:R.employee_name||R.name})}),t.jsx("div",{className:"px-4 py-3 text-sm text-gray-700 dark:text-gray-300",children:R.name}),t.jsx("div",{className:"px-4 py-3 text-sm text-gray-700 dark:text-gray-300",children:R.department||"—"}),t.jsx("div",{className:"px-4 py-3 text-sm text-gray-700 dark:text-gray-300",children:R.company||"—"}),t.jsx("div",{className:"px-4 py-3",children:t.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${y4e(R.status)}`,children:R.status||"—"})})]},R.name))}),t.jsxs("div",{className:"px-4 py-3 border-t border-gray-100 dark:border-gray-700 flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[t.jsxs("span",{children:["Page ",c+1," · Showing ",a.length," of ",h]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"button",onClick:()=>v(c-1),disabled:c===0,className:"px-3 py-1 border border-gray-300 dark:border-gray-600 rounded disabled:opacity-40 hover:bg-gray-50 dark:hover:bg-gray-700",children:"Prev"}),t.jsx("button",{type:"button",onClick:()=>v(c+1),disabled:(c+1)*iN>=h,className:"px-3 py-1 border border-gray-300 dark:border-gray-600 rounded disabled:opacity-40 hover:bg-gray-50 dark:hover:bg-gray-700",children:"Next"})]})]})]})})]})},Ao=({children:e,required:r})=>t.jsxs("label",{className:"block text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1",children:[e,r&&t.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),Oo=({children:e})=>t.jsx("div",{className:"px-3 py-2 text-sm text-gray-800 dark:text-gray-200 bg-gray-50 dark:bg-gray-800/60 rounded-lg min-h-[38px] flex items-center",children:e||t.jsx("span",{className:"text-gray-400",children:"-"})}),Nd="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-teal-400",v4e=({title:e,children:r,defaultOpen:a=!0})=>{const[s,n]=p.useState(a);return t.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700",children:[t.jsxs("button",{type:"button",onClick:()=>n(i=>!i),className:"w-full flex items-center justify-between px-6 py-3 hover:bg-gray-50 dark:hover:bg-gray-700/30 transition-colors",children:[t.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:e}),s?t.jsx(Fr,{className:"text-gray-400 text-xs"}):t.jsx(Fi,{className:"text-gray-400 text-xs"})]}),s&&t.jsx("div",{className:"px-6 pb-5",children:r})]})},e9=e=>{switch(e){case"Active":return"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-300";case"Inactive":return"bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400";case"Left":return"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300";case"On Leave":return"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-300";default:return"bg-gray-100 text-gray-600"}},w4e=()=>{const{employeeName:e}=hs(),r=hr(),a=e==="new",[s,n]=p.useState(null),[i,o]=p.useState(!a),[l,c]=p.useState(!1),[u,h]=p.useState(a),[f,y]=p.useState(""),b={first_name:"",middle_name:"",last_name:"",salutation:"",gender:"",date_of_birth:"",date_of_joining:"",status:"Active",company:"",designation:"",branch:"",department:"",reports_to:"",employee_number:""},[w,v]=p.useState(b),k=p.useCallback(P=>{v({first_name:P.first_name||"",middle_name:P.middle_name||"",last_name:P.last_name||"",salutation:P.salutation||"",gender:P.gender||"",date_of_birth:P.date_of_birth||"",date_of_joining:P.date_of_joining||"",status:P.status||"Active",company:P.company||"",designation:P.designation||"",branch:P.branch||"",department:P.department||"",reports_to:P.reports_to||"",employee_number:P.employee_number||""})},[]);p.useEffect(()=>{!a&&e&&(o(!0),fl.getEmployee(e).then(P=>{n(P),k(P)}).catch(P=>y(P.message)).finally(()=>o(!1)))},[e,a,k]);const S=(P,E)=>v(R=>je(se({},R),{[P]:E})),N=()=>J(null,null,function*(){var P;if(!((P=w.first_name)!=null&&P.trim())){We.error("First Name is required");return}if(!w.gender){We.error("Gender is required");return}if(!w.date_of_birth){We.error("Date of Birth is required");return}if(!w.date_of_joining){We.error("Date of Joining is required");return}c(!0);try{if(a){const E=yield fl.createEmployee(w);We.success("Employee created",{icon:t.jsx(Qt,{})}),r(`/employees/${encodeURIComponent(E.name)}`)}else{const E=yield fl.updateEmployee(e,w);We.success("Employee updated",{icon:t.jsx(Qt,{})}),n(E),k(E),h(!1)}}catch(E){We.error(E instanceof Error?E.message:"Save failed",{icon:t.jsx(pr,{})})}finally{c(!1)}}),C=()=>{s&&k(s),h(!1)},O=a||u,T=(s==null?void 0:s.employee_name)||[s==null?void 0:s.first_name,s==null?void 0:s.last_name].filter(Boolean).join(" ")||e;return i?t.jsx("div",{className:"flex justify-center items-center min-h-[400px]",children:t.jsx(tr,{className:"animate-spin text-teal-500 text-3xl"})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 px-6 py-6",children:[t.jsx($a,{position:"top-right",autoClose:3500}),t.jsxs("div",{className:"flex items-center gap-2 text-sm mb-6 text-gray-500 dark:text-gray-400",children:[t.jsx("button",{onClick:()=>r("/projects"),className:"hover:text-teal-600",children:"Project Management"}),t.jsx("span",{children:"/"}),t.jsx("button",{onClick:()=>r("/employees"),className:"hover:text-teal-600",children:"Employees"}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:a?"New Employee":T})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 dark:border-gray-700 flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>r("/employees"),className:"text-gray-400 hover:text-gray-700 dark:hover:text-gray-300",children:t.jsx(ia,{})}),t.jsx("div",{className:"w-10 h-10 rounded-xl bg-teal-600 flex items-center justify-center flex-shrink-0",children:t.jsx(Av,{className:"text-white"})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:a?"New Employee":T}),!a&&s&&t.jsx("span",{className:`text-xs px-2 py-0.5 rounded font-medium ${e9(s.status)}`,children:s.status||"Active"})]})]}),t.jsxs("div",{className:"flex gap-2",children:[!a&&!u&&t.jsxs("button",{onClick:()=>h(!0),className:"flex items-center gap-2 px-4 py-2 bg-teal-600 text-white rounded-lg hover:bg-teal-700 text-sm",children:[t.jsx(qr,{})," Edit"]}),O&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:N,disabled:l,className:"flex items-center gap-2 px-4 py-2 bg-teal-600 text-white rounded-lg hover:bg-teal-700 disabled:opacity-50 text-sm font-medium",children:[l?t.jsx(tr,{className:"animate-spin"}):t.jsx(ta,{}),l?"Saving…":"Save"]}),!a&&t.jsx("button",{onClick:C,className:"px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-600 dark:text-gray-400 text-sm",children:t.jsx(ht,{})})]})]})]}),f&&t.jsx("div",{className:"mx-6 mt-4 p-3 bg-red-50 dark:bg-red-900/20 rounded text-red-700 dark:text-red-300 text-sm",children:f}),t.jsxs("div",{className:"p-6 grid grid-cols-1 sm:grid-cols-3 gap-x-6 gap-y-4 border-b border-gray-100 dark:border-gray-700",children:[t.jsxs("div",{children:[t.jsx(Ao,{children:"Series"}),t.jsx(Oo,{children:"HR-EMP-"})]}),t.jsxs("div",{children:[t.jsx(Ao,{required:!0,children:"Gender"}),O?t.jsxs("select",{value:w.gender||"",onChange:P=>S("gender",P.target.value),className:Nd,children:[t.jsx("option",{value:"",children:"Select gender"}),t.jsx("option",{children:"Male"}),t.jsx("option",{children:"Female"}),t.jsx("option",{children:"Other"}),t.jsx("option",{children:"Prefer not to say"})]}):t.jsx(Oo,{children:w.gender})]}),t.jsxs("div",{children:[t.jsx(Ao,{required:!0,children:"Date of Joining"}),O?t.jsx("input",{type:"date",value:w.date_of_joining||"",onChange:P=>S("date_of_joining",P.target.value),className:Nd}):t.jsx(Oo,{children:w.date_of_joining})]}),t.jsxs("div",{children:[t.jsx(Ao,{required:!0,children:"First Name"}),O?t.jsx("input",{value:w.first_name||"",onChange:P=>S("first_name",P.target.value),className:Nd,placeholder:"First name"}):t.jsx(Oo,{children:w.first_name})]}),t.jsxs("div",{children:[t.jsx(Ao,{required:!0,children:"Date of Birth"}),O?t.jsx("input",{type:"date",value:w.date_of_birth||"",onChange:P=>S("date_of_birth",P.target.value),className:Nd}):t.jsx(Oo,{children:w.date_of_birth})]}),t.jsxs("div",{children:[t.jsx(Ao,{children:"Status"}),O?t.jsxs("select",{value:w.status||"Active",onChange:P=>S("status",P.target.value),className:Nd,children:[t.jsx("option",{children:"Active"}),t.jsx("option",{children:"Inactive"}),t.jsx("option",{children:"Left"}),t.jsx("option",{children:"On Leave"})]}):t.jsx(Oo,{children:t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${e9(w.status)}`,children:w.status||"Active"})})]}),t.jsxs("div",{children:[t.jsx(Ao,{children:"Middle Name"}),O?t.jsx("input",{value:w.middle_name||"",onChange:P=>S("middle_name",P.target.value),className:Nd,placeholder:"Middle name"}):t.jsx(Oo,{children:w.middle_name})]}),t.jsxs("div",{children:[t.jsx(Ao,{children:"Salutation"}),O?t.jsxs("select",{value:w.salutation||"",onChange:P=>S("salutation",P.target.value),className:Nd,children:[t.jsx("option",{value:"",children:"Select"}),t.jsx("option",{children:"Mr."}),t.jsx("option",{children:"Ms."}),t.jsx("option",{children:"Mrs."}),t.jsx("option",{children:"Dr."}),t.jsx("option",{children:"Prof."})]}):t.jsx(Oo,{children:w.salutation})]}),t.jsxs("div",{children:[t.jsx(Ao,{children:"Last Name"}),O?t.jsx("input",{value:w.last_name||"",onChange:P=>S("last_name",P.target.value),className:Nd,placeholder:"Last name"}):t.jsx(Oo,{children:w.last_name})]})]}),t.jsx(v4e,{title:"Company Details",children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-x-6 gap-y-4",children:[t.jsxs("div",{children:[t.jsx(Ao,{required:!0,children:"Hospital"}),O?t.jsx(Je,{label:"Hospital",hideLabel:!0,doctype:"Company",value:w.company||"",onChange:P=>S("company",P),placeholder:"Select hospital…"}):t.jsx(Oo,{children:w.company})]}),t.jsxs("div",{children:[t.jsx(Ao,{children:"Designation"}),O?t.jsx(Je,{label:"Designation",hideLabel:!0,doctype:"Designation",value:w.designation||"",onChange:P=>S("designation",P),placeholder:"Select designation…"}):t.jsx(Oo,{children:w.designation})]}),t.jsxs("div",{children:[t.jsx(Ao,{children:"Department"}),O?t.jsx(Je,{label:"Department",hideLabel:!0,doctype:"Department",value:w.department||"",onChange:P=>S("department",P),placeholder:"Select department…"}):t.jsx(Oo,{children:w.department})]}),t.jsxs("div",{children:[t.jsx(Ao,{children:"Employee Number"}),O?t.jsx("input",{value:w.employee_number||"",onChange:P=>S("employee_number",P.target.value),className:Nd,placeholder:"e.g. EMP-001"}):t.jsx(Oo,{children:w.employee_number})]})]})}),!a&&s&&t.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 dark:border-gray-700 grid grid-cols-2 sm:grid-cols-3 gap-3 text-xs text-gray-400 dark:text-gray-500",children:[t.jsxs("div",{children:[t.jsx("span",{className:"font-medium block text-gray-500 dark:text-gray-400",children:"Created By"}),s.owner]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium block text-gray-500 dark:text-gray-400",children:"Created"}),s.creation?new Date(s.creation).toLocaleString():"-"]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium block text-gray-500 dark:text-gray-400",children:"Modified"}),s.modified?new Date(s.modified).toLocaleString():"-"]})]}),!a&&t.jsx("div",{className:"px-6 pb-6",children:t.jsx(vi,{doctype:"Employee",docname:(s==null?void 0:s.name)||e||"",creationDate:s==null?void 0:s.creation,createdBy:s==null?void 0:s.owner,compact:!1,initialVisible:5,collapsible:!0,startCollapsed:!0})})]})]})},j4e=(e,r)=>r===2?"bg-red-100 text-red-700":r===1||e==="Paid"?"bg-green-100 text-green-800":e==="Overdue"?"bg-orange-100 text-orange-800":"bg-yellow-100 text-yellow-800",Jb=20,_4e=()=>{const{t:e}=sr(),r=hr(),[a,s]=_a(),n=p.useRef(s);p.useEffect(()=>{n.current=s},[s]);const i=p.useMemo(()=>{const de=parseInt(a.get("page")||"1",10);return Number.isNaN(de)||de<1?1:de},[a]),o=p.useCallback(de=>{const xe=typeof de=="function"?de(i):de;s(ge=>{const be=new URLSearchParams(ge);return be.set("page",String(xe)),be})},[i,s]),[l,c]=p.useState(!1),[u,h]=p.useState(a.get("status")||""),[f,y]=p.useState(a.get("q")||""),[b,w]=p.useState(a.get("sort_by")||"creation desc"),[v,k]=p.useState([]),[S,N]=p.useState(0),[C,O]=p.useState(!0),[T,P]=p.useState(null),[E,R]=p.useState(!1),z=p.useRef(!1),G=p.useRef(!0),ae=p.useRef(null),ee=p.useRef(0),ne=p.useMemo(()=>{const de={};return u&&(de.status=u),f&&(de.name=["like",`%${f}%`]),de},[u,f]),te=p.useCallback(()=>J(null,null,function*(){const de=++ee.current;try{O(!0),P(null);const[xe,ge]=yield Promise.all([Pc.getSalesInvoices({filters:ne,limit_start:(i-1)*Jb,limit_page_length:Jb,order_by:b}),Pc.getSalesInvoiceCount(ne)]);if(de!==ee.current)return;k(xe.data),N(ge)}catch(xe){if(de!==ee.current)return;P(xe instanceof Error?xe.message:"Failed to fetch invoices")}finally{de===ee.current&&O(!1)}}),[ne,i,b]);p.useEffect(()=>{te()},[te]);const Y=p.useMemo(()=>`${i}|${b}|${JSON.stringify(ne)}`,[i,b,ne]),{selectedRows:q,toggleRow:H,toggleAllOnPage:U,allOnPageSelected:re,someOnPageSelected:X}=po(v,Y),V=p.useCallback(()=>go({doctype:"Sales Invoice",filters:ne,orderBy:b}),[ne,b]),I=Math.ceil(S/Jb),B=()=>{h(""),y(""),w("creation desc"),s(de=>{const xe=new URLSearchParams(de);return["status","q","sort_by"].forEach(ge=>xe.delete(ge)),xe.set("page","1"),xe})};p.useEffect(()=>{if(!z.current){z.current=!0;return}n.current(de=>{const xe=new URLSearchParams(de);return u?xe.set("status",u):xe.delete("status"),b!=="creation desc"?xe.set("sort_by",b):xe.delete("sort_by"),xe.set("page","1"),xe})},[u,b]),p.useEffect(()=>{if(z.current){if(G.current){G.current=!1;return}return ae.current&&window.clearTimeout(ae.current),ae.current=window.setTimeout(()=>{n.current(de=>{const xe=new URLSearchParams(de);return f?xe.set("q",f):xe.delete("q"),xe.set("page","1"),xe})},450),()=>{ae.current&&window.clearTimeout(ae.current)}}},[f]);const Q=!!(u||f),ie=de=>r(`/invoices/${encodeURIComponent(de)}`),me=de=>r(`/invoices/${encodeURIComponent(de)}?edit=1`),he=de=>r(`/invoices/new?duplicate=${encodeURIComponent(de)}`);return t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>r("/projects"),className:"text-sm text-gray-500 hover:text-indigo-600",children:"Project Management"}),t.jsx("span",{className:"text-gray-400",children:"/"}),t.jsxs("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white flex items-center gap-2",children:[t.jsx(xm,{className:"text-indigo-500"})," Sales Invoices"]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>R(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all disabled:opacity-50",disabled:S===0&&q.size===0,children:[t.jsx(Sa,{})," ",t.jsx("span",{className:"font-medium",children:e("listPages.export")}),q.size>0&&t.jsx("span",{className:"bg-white/25 px-1.5 py-0.5 rounded text-xs font-bold",children:q.size})]}),t.jsxs("button",{onClick:()=>r("/invoices/new"),className:"flex items-center gap-2 px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700",children:[t.jsx(Rr,{})," New Invoice"]})]})]}),t.jsx(bi,{isOpen:E,onClose:()=>R(!1),doctype:"Sales Invoice",selectedCount:q.size,pageCount:v.length,totalCount:S,pageData:v,selectedRows:q,rowKey:"name",onFetchAll:V,fileNamePrefix:"sales_invoices"}),t.jsxs("div",{className:"isolate bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-6",children:[t.jsx("div",{className:"bg-gradient-to-r from-blue-500 to-blue-600 dark:from-blue-600 dark:to-blue-700 px-4 py-2.5 rounded-t-lg",children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx("button",{onClick:()=>c(de=>!de),className:"text-white hover:bg-white/20 p-1.5 rounded-lg",children:l?t.jsx(Ja,{size:12}):t.jsx(Fr,{size:12})}),t.jsx(ds,{className:"text-white",size:13}),t.jsx("span",{className:"text-white font-semibold text-sm",children:"Filters"}),Q&&t.jsx("span",{className:"bg-white text-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:[u,f].filter(Boolean).length})]}),Q&&t.jsx("div",{className:"flex-1 overflow-x-auto mx-2",children:t.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[f&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap",children:[t.jsx("span",{className:"font-semibold",children:"ID:"})," ",f,t.jsx("button",{onClick:()=>y(""),children:t.jsx(ht,{className:"text-[9px] hover:text-red-500"})})]}),u&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap",children:[t.jsx("span",{className:"font-semibold",children:"Status:"})," ",u,t.jsx("button",{onClick:()=>h(""),children:t.jsx(ht,{className:"text-[9px] hover:text-red-500"})})]})]})}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Q&&t.jsx("button",{onClick:B,className:"text-white/80 hover:text-white text-xs underline",children:"Clear all"}),t.jsx("button",{onClick:te,className:"text-white hover:bg-white/20 p-1.5 rounded-lg",title:"Refresh",children:t.jsx(Ma,{size:12,className:C?"animate-spin":""})})]})]})}),l&&t.jsx("div",{className:"p-4",children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 uppercase tracking-wide mb-1",children:"Invoice ID"}),t.jsxs("div",{className:"relative",children:[t.jsx(za,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400 text-xs"}),t.jsx("input",{type:"text",value:f,onChange:de=>y(de.target.value),onKeyDown:de=>de.key==="Enter"&&de.preventDefault(),placeholder:"Search by ID…",className:"w-full pl-8 pr-3 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-400 focus:outline-none"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 uppercase tracking-wide mb-1",children:"Status"}),t.jsxs("select",{value:u,onChange:de=>h(de.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-400 focus:outline-none",children:[t.jsx("option",{value:"",children:"All Status"}),t.jsx("option",{value:"Draft",children:"Draft"}),t.jsx("option",{value:"Submitted",children:"Submitted"}),t.jsx("option",{value:"Paid",children:"Paid"}),t.jsx("option",{value:"Unpaid",children:"Unpaid"}),t.jsx("option",{value:"Overdue",children:"Overdue"}),t.jsx("option",{value:"Cancelled",children:"Cancelled"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-600 uppercase tracking-wide mb-1",children:"Sort By"}),t.jsxs("select",{value:b,onChange:de=>w(de.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-400 focus:outline-none",children:[t.jsx("option",{value:"creation desc",children:"Created (newest)"}),t.jsx("option",{value:"creation asc",children:"Created (oldest)"}),t.jsx("option",{value:"posting_date desc",children:"Date (newest)"}),t.jsx("option",{value:"grand_total desc",children:"Amount (highest)"})]})]})]})})]}),T&&t.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg text-red-700 text-sm",children:T}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden",children:[C?t.jsx("div",{className:"p-12 text-center text-gray-500",children:"Loading…"}):v.length===0?t.jsxs("div",{className:"p-12 text-center",children:[t.jsx(xm,{className:"text-4xl text-gray-300 mx-auto mb-3"}),t.jsx("p",{className:"text-gray-500",children:"No sales invoices yet"})]}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"w-10 px-4 py-3 text-left",children:t.jsx("button",{type:"button",onClick:U,className:"text-gray-500 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors",title:re?"Deselect all":"Select all","aria-label":"Select all on page",children:re?t.jsx(Ra,{className:"text-indigo-600 dark:text-indigo-400",size:18}):X?t.jsxs("div",{className:"relative inline-block",children:[t.jsx(Ur,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Ur,{size:18})})}),["Invoice ID","Customer","Status","Date","Grand Total","Outstanding",""].map(de=>t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:de},de))]})}),t.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:v.map(de=>{var xe,ge;return t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${q.has(de.name)?"bg-indigo-50 dark:bg-indigo-900/20":""}`,onClick:()=>ie(de.name),children:[t.jsx("td",{className:"w-10 px-4 py-3",onClick:be=>be.stopPropagation(),children:t.jsx("button",{type:"button",onClick:()=>H(de.name),className:"text-gray-500 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors","aria-label":`Select ${de.name}`,children:q.has(de.name)?t.jsx(Ra,{className:"text-indigo-600 dark:text-indigo-400",size:18}):t.jsx(Ur,{size:18})})}),t.jsx("td",{className:"px-6 py-4 font-medium text-gray-900 dark:text-white text-sm",children:de.name}),t.jsx("td",{className:"px-6 py-4 text-sm text-gray-700 dark:text-gray-300",children:de.customer_name||de.customer||"-"}),t.jsx("td",{className:"px-6 py-4",children:t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${j4e(de.status||"",de.docstatus)}`,children:de.status||"Draft"})}),t.jsx("td",{className:"px-6 py-4 text-sm text-gray-500",children:de.posting_date||"-"}),t.jsxs("td",{className:"px-6 py-4 text-sm font-medium text-gray-900 dark:text-white",children:[de.currency||""," ",((xe=de.grand_total)!=null?xe:0).toFixed(2)]}),t.jsx("td",{className:"px-6 py-4 text-sm text-gray-500",children:((ge=de.outstanding_amount)!=null?ge:0).toFixed(2)}),t.jsx("td",{className:"px-6 py-3",onClick:be=>be.stopPropagation(),children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>ie(de.name),className:"text-indigo-600 dark:text-indigo-400 hover:text-indigo-900 dark:hover:text-indigo-300 p-2 hover:bg-indigo-50 dark:hover:bg-indigo-900/30 rounded transition-colors",title:"View",children:t.jsx(Ps,{})}),t.jsx("button",{onClick:()=>me(de.name),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:"Edit",children:t.jsx(qr,{})}),t.jsx("button",{onClick:()=>he(de.name),className:"text-purple-600 dark:text-purple-400 hover:text-purple-900 dark:hover:text-purple-300 p-2 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded transition-colors",title:"Duplicate",children:t.jsx(Vo,{})})]})})]},de.name)})})]})}),I>1&&t.jsx("div",{className:"border-t border-gray-200 px-4 py-3",children:t.jsx(_l,{currentPage:i,totalPages:I,totalCount:S,pageSize:Jb,onPageChange:o})})]})]})},aa=({children:e,required:r})=>t.jsxs("label",{className:"block text-[11px] font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1",children:[e,r&&t.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),Wl=({children:e})=>t.jsx("div",{className:"px-3 py-2 text-sm text-gray-800 dark:text-gray-200 bg-gray-50 dark:bg-gray-800/60 rounded min-h-[34px] flex items-center",children:e||t.jsx("span",{className:"text-gray-400",children:"-"})}),Jl="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-indigo-400",X0=Jl+" text-right",rB="w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-indigo-400",k4e=rB+" text-right",Ef=({title:e,children:r,defaultOpen:a=!1})=>{const[s,n]=p.useState(a);return t.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-600 mt-3 pt-1",children:[t.jsxs("button",{type:"button",onClick:()=>n(i=>!i),className:"flex items-center gap-2 py-1 text-xs font-semibold text-blue-600 dark:text-blue-400 hover:underline",children:[s?t.jsx(Fr,{size:9}):t.jsx(Fi,{size:9}),e]}),s&&t.jsx("div",{className:"mt-2",children:r})]})},Zb=({title:e,children:r,defaultOpen:a=!0})=>{const[s,n]=p.useState(a);return t.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700",children:[t.jsxs("button",{type:"button",onClick:()=>n(i=>!i),className:"w-full flex items-center justify-between px-6 py-3 hover:bg-gray-50 dark:hover:bg-gray-700/30",children:[t.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:e}),s?t.jsx(Fr,{className:"text-gray-400 text-xs"}):t.jsx(Fi,{className:"text-gray-400 text-xs"})]}),s&&t.jsx("div",{className:"px-6 pb-5",children:r})]})},N4e=()=>({item_code:"",item_name:"",description:"",qty:1,uom:"",stock_uom:"",conversion_factor:1,rate:0,amount:0,price_list_rate:0,discount_percentage:0,net_rate:0,net_amount:0,income_account:"",expense_account:"",item_tax_template:"",is_free_item:0,grant_commission:1}),pi=e=>{if(e==null||e==="")return;const r=String(e);if(r.toLowerCase()!=="none")return r},oN=e=>{var s,n;const r=pi((s=e.sales_order)!=null?s:e.against_sales_order),a=pi((n=e.delivery_note)!=null?n:e.against_delivery_note);return je(se({},e),{sales_order:r,delivery_note:a,so_detail:pi(e.so_detail),dn_detail:pi(e.dn_detail),against_sales_order:r,against_delivery_note:a})},S4e=(e,r)=>{var n,i,o,l,c,u,h,f,y;const a=pi((n=e.sales_order)!=null?n:e.against_sales_order),s=pi((i=e.delivery_note)!=null?i:e.against_delivery_note);return je(se({},e.name?{name:e.name}:{}),{item_code:e.item_code,item_name:e.item_name||e.item_code,description:e.description||void 0,qty:(o=e.qty)!=null?o:1,uom:e.uom||void 0,stock_uom:e.stock_uom||void 0,conversion_factor:(l=e.conversion_factor)!=null?l:1,price_list_rate:(c=e.price_list_rate)!=null?c:0,discount_percentage:(u=e.discount_percentage)!=null?u:0,rate:(h=e.rate)!=null?h:0,amount:(f=e.amount)!=null?f:0,item_tax_template:e.item_tax_template||void 0,is_free_item:(y=e.is_free_item)!=null?y:0,income_account:e.income_account||void 0,expense_account:e.expense_account||void 0,cost_center:e.cost_center||void 0,project:e.project||void 0,sales_order:a,delivery_note:s,so_detail:pi(e.so_detail),dn_detail:pi(e.dn_detail),pos_invoice:pi(e.pos_invoice),pos_invoice_item:e.pos_invoice_item||void 0,delivered_qty:e.delivered_qty!=null?e.delivered_qty:void 0,idx:r+1})},C4e=({item:e,rowNo:r,onChange:a,onClose:s,onDelete:n,onInsertBelow:i})=>{var h,f,y,b,w,v,k,S,N;const[o,l]=p.useState(!1),c=p.useCallback(C=>J(null,null,function*(){if(C)try{l(!0);const P=(yield(yield fetch(`/api/resource/Item/${encodeURIComponent(C)}`,{credentials:"include"})).json()).data;if(!P)return;P.item_name&&a("item_name",P.item_name),P.description&&a("description",P.description),P.stock_uom&&a("stock_uom",P.stock_uom),(P.sales_uom||P.stock_uom)&&a("uom",P.sales_uom||P.stock_uom)}catch(O){}finally{l(!1)}}),[a]),u=(C,O)=>a(C,O);return t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"p-0",children:t.jsxs("div",{className:"border border-blue-300 dark:border-blue-600 rounded-lg mx-2 my-1 bg-white dark:bg-gray-800 shadow-md",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-blue-50 dark:bg-blue-900/30 rounded-t-lg border-b border-blue-200 dark:border-blue-700",children:[t.jsxs("span",{className:"text-sm font-semibold text-blue-700 dark:text-blue-300",children:["Editing Row #",r," ",o&&t.jsx(tr,{className:"inline animate-spin ml-1 text-xs"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:i,className:"px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300",children:"Insert Below"}),t.jsx("button",{onClick:n,className:"px-2 py-1 text-xs border border-red-300 dark:border-red-700 rounded text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20",children:"Delete"}),t.jsx("button",{onClick:s,className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:t.jsx(ht,{size:13})})]})]}),t.jsxs("div",{className:"p-4 space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(aa,{required:!0,children:"Item"}),t.jsx(Je,{label:"Item",hideLabel:!0,doctype:"Item",value:e.item_code||"",onChange:C=>{a("item_code",C),c(C)},placeholder:"Select item…"})]}),t.jsxs("div",{children:[t.jsx(aa,{required:!0,children:"Item Name"}),t.jsx("input",{type:"text",value:e.item_name||"",onChange:C=>a("item_name",C.target.value),className:Jl,placeholder:"Item name…"})]})]}),t.jsxs(Ef,{title:"Description",defaultOpen:!!e.description,children:[t.jsx(aa,{children:"Description"}),t.jsx("textarea",{rows:2,value:e.description||"",onChange:C=>a("description",C.target.value),className:Jl,placeholder:"Description…"})]}),t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsxs("div",{children:[t.jsx(aa,{required:!0,children:"Quantity"}),t.jsx("input",{type:"number",min:0,step:"1",value:(h=e.qty)!=null?h:1,onChange:C=>u("qty",parseFloat(C.target.value)||0),className:X0})]}),t.jsxs("div",{children:[t.jsx(aa,{required:!0,children:"UOM"}),t.jsx("input",{type:"text",value:e.uom||"",onChange:C=>a("uom",C.target.value),className:Jl,placeholder:"UOM…"})]}),t.jsxs("div",{children:[t.jsx(aa,{children:"Stock UOM"}),t.jsx("input",{type:"text",value:e.stock_uom||"",onChange:C=>a("stock_uom",C.target.value),className:Jl,placeholder:"Stock UOM…"})]}),t.jsxs("div",{children:[t.jsx(aa,{required:!0,children:"UOM Conversion Factor"}),t.jsx("input",{type:"number",min:0,step:"0.001",value:(f=e.conversion_factor)!=null?f:1,onChange:C=>a("conversion_factor",parseFloat(C.target.value)||1),className:X0})]})]}),t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsxs("div",{children:[t.jsx(aa,{children:"Price List Rate"}),t.jsx("input",{type:"number",min:0,step:"0.01",value:(y=e.price_list_rate)!=null?y:0,onChange:C=>a("price_list_rate",parseFloat(C.target.value)||0),className:X0})]}),t.jsxs("div",{children:[t.jsx(aa,{children:"Discount %"}),t.jsx("input",{type:"number",min:0,max:100,step:"0.01",value:(b=e.discount_percentage)!=null?b:0,onChange:C=>a("discount_percentage",parseFloat(C.target.value)||0),className:X0})]}),t.jsxs("div",{children:[t.jsx(aa,{required:!0,children:"Rate"}),t.jsx("input",{type:"number",min:0,step:"0.01",value:(w=e.rate)!=null?w:0,onChange:C=>u("rate",parseFloat(C.target.value)||0),className:X0})]}),t.jsxs("div",{children:[t.jsx(aa,{required:!0,children:"Amount"}),t.jsx("div",{className:"px-3 py-2 text-sm font-semibold text-gray-800 dark:text-gray-100 bg-gray-50 dark:bg-gray-700 rounded text-right",children:(e.amount||0).toFixed(2)})]})]}),t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsxs("div",{children:[t.jsx(aa,{children:"Net Rate"}),t.jsx("div",{className:"px-3 py-2 text-sm text-gray-600 dark:text-gray-300 bg-gray-50 dark:bg-gray-700 rounded text-right",children:(e.net_rate||e.rate||0).toFixed(2)})]}),t.jsxs("div",{children:[t.jsx(aa,{children:"Net Amount"}),t.jsx("div",{className:"px-3 py-2 text-sm text-gray-600 dark:text-gray-300 bg-gray-50 dark:bg-gray-700 rounded text-right",children:(e.net_amount||e.amount||0).toFixed(2)})]}),t.jsxs("div",{children:[t.jsx(aa,{children:"Item Tax Template"}),t.jsx("input",{type:"text",value:e.item_tax_template||"",onChange:C=>a("item_tax_template",C.target.value),className:Jl,placeholder:"Tax template…"})]}),t.jsxs("div",{className:"flex flex-col justify-end gap-2 pb-1",children:[t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[t.jsx("input",{type:"checkbox",checked:!!e.is_free_item,onChange:C=>a("is_free_item",C.target.checked?1:0),className:"rounded border-gray-300"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Is Free Item"})]}),t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[t.jsx("input",{type:"checkbox",checked:e.grant_commission!==0,onChange:C=>a("grant_commission",C.target.checked?1:0),className:"rounded border-gray-300"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Grant Commission"})]})]})]}),t.jsx(Ef,{title:"Accounting Details",defaultOpen:!0,children:t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(aa,{required:!0,children:"Income Account"}),t.jsx(Je,{label:"Income Account",hideLabel:!0,doctype:"Account",value:e.income_account||"",onChange:C=>a("income_account",C),placeholder:"Income account…"})]}),t.jsxs("div",{children:[t.jsx(aa,{children:"Expense Account"}),t.jsx(Je,{label:"Expense Account",hideLabel:!0,doctype:"Account",value:e.expense_account||"",onChange:C=>a("expense_account",C),placeholder:"Expense account…"})]})]})}),t.jsx(Ef,{title:"Accounting Dimensions",children:t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(aa,{children:"Cost Center"}),t.jsx(Je,{label:"Cost Center",hideLabel:!0,doctype:"Cost Center",value:e.cost_center||"",onChange:C=>a("cost_center",C),placeholder:"Cost center…"})]}),t.jsxs("div",{children:[t.jsx(aa,{children:"Project"}),t.jsx(Je,{label:"Project",hideLabel:!0,doctype:"Project",value:e.project||"",onChange:C=>a("project",C),placeholder:"Project…"})]})]})}),t.jsx(Ef,{title:"References",defaultOpen:!!(pi((v=e.sales_order)!=null?v:e.against_sales_order)||pi((k=e.delivery_note)!=null?k:e.against_delivery_note)||pi(e.pos_invoice)),children:t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(aa,{children:"Sales Order"}),t.jsx(Je,{label:"Sales Order",hideLabel:!0,doctype:"Sales Order",value:pi((S=e.sales_order)!=null?S:e.against_sales_order)||"",onChange:C=>{a("sales_order",C),a("against_sales_order",C)},placeholder:"Sales Order…"})]}),t.jsxs("div",{children:[t.jsx(aa,{children:"Delivery Note"}),t.jsx(Je,{label:"Delivery Note",hideLabel:!0,doctype:"Delivery Note",value:pi((N=e.delivery_note)!=null?N:e.against_delivery_note)||"",onChange:C=>{a("delivery_note",C),a("against_delivery_note",C)},placeholder:"Delivery Note…"})]}),t.jsxs("div",{children:[t.jsx(aa,{children:"POS Invoice"}),t.jsx(Je,{label:"POS Invoice",hideLabel:!0,doctype:"POS Invoice",value:e.pos_invoice||"",onChange:C=>a("pos_invoice",C),placeholder:"POS Invoice…"})]}),t.jsxs("div",{children:[t.jsx(aa,{children:"Delivered Qty"}),t.jsx("div",{className:"px-3 py-2 text-sm text-gray-700 dark:text-gray-200 bg-gray-50 dark:bg-gray-700 rounded",children:e.delivered_qty!=null?+e.delivered_qty:"—"})]})]})})]})]})})})},T4e=({tax:e,rowNo:r,onChange:a,onClose:s,onDelete:n,onInsertBelow:i})=>{var o;return t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"p-0",children:t.jsxs("div",{className:"border border-blue-300 dark:border-blue-600 rounded-lg mx-2 my-1 bg-white dark:bg-gray-800 shadow-md",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-blue-50 dark:bg-blue-900/30 rounded-t-lg border-b border-blue-200",children:[t.jsxs("span",{className:"text-sm font-semibold text-blue-700 dark:text-blue-300",children:["Tax Row #",r]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:i,className:"px-2 py-1 text-xs border border-gray-300 rounded hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300",children:"Insert Below"}),t.jsx("button",{type:"button",onClick:n,className:"px-2 py-1 text-xs border border-red-300 rounded text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20",children:"Delete"}),t.jsx("button",{type:"button",onClick:s,className:"p-1 text-gray-400 hover:text-gray-600",children:t.jsx(ht,{size:13})})]})]}),t.jsxs("div",{className:"p-4 space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(aa,{required:!0,children:"Type"}),t.jsxs("select",{value:e.charge_type||"",onChange:l=>a("charge_type",l.target.value),className:Jl,children:[t.jsx("option",{value:"",children:"Select type…"}),t.jsx("option",{value:"Actual",children:"Actual"}),t.jsx("option",{value:"On Net Total",children:"On Net Total"}),t.jsx("option",{value:"On Previous Row Amount",children:"On Previous Row Amount"}),t.jsx("option",{value:"On Previous Row Total",children:"On Previous Row Total"}),t.jsx("option",{value:"On Item Quantity",children:"On Item Quantity"}),t.jsx("option",{value:"Inter Company Transaction",children:"Inter Company Transaction"})]})]}),t.jsxs("div",{children:[t.jsx(aa,{children:"Description"}),t.jsx("textarea",{rows:3,value:e.description||"",onChange:l=>a("description",l.target.value),className:Jl,placeholder:"Description…"})]})]}),t.jsxs("div",{children:[t.jsx(aa,{required:!0,children:"Account Head"}),t.jsx(Je,{label:"Account Head",hideLabel:!0,doctype:"Account",value:e.account_head||"",onChange:l=>a("account_head",l),placeholder:"Account…"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"checkbox",checked:!!e.included_in_print_rate,onChange:l=>a("included_in_print_rate",l.target.checked?1:0),className:"rounded border-gray-300"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Tax included in basic rate"})]}),t.jsx(Ef,{title:"Accounting dimensions",defaultOpen:!0,children:t.jsxs("div",{children:[t.jsx(aa,{children:"Cost Center"}),t.jsx(Je,{label:"Cost Center",hideLabel:!0,doctype:"Cost Center",value:e.cost_center||"",onChange:l=>a("cost_center",l),placeholder:"Cost center…"})]})}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.charge_type==="Actual"&&t.jsxs("div",{children:[t.jsx(aa,{children:"Tax amount"}),t.jsx("input",{type:"number",min:0,step:"0.01",value:(o=e.tax_amount)!=null?o:0,onChange:l=>a("tax_amount",parseFloat(l.target.value)||0),className:X0})]}),t.jsxs("div",{children:[t.jsx(aa,{children:"Tax rate"}),t.jsx("input",{type:"number",min:0,step:"0.01",value:Ql(e),onChange:l=>a("tax_rate",parseFloat(l.target.value)||0),className:X0})]}),t.jsxs("div",{children:[t.jsx(aa,{children:"Account currency"}),t.jsx("input",{value:e.account_currency||Er,onChange:l=>a("account_currency",l.target.value),className:Jl})]})]})]})]})})})},E4e=()=>({charge_type:"",account_head:"",tax_rate:0,account_currency:Er,included_in_print_rate:0}),Xb=e=>{var r,a;return je(se({},e),{tax_rate:(a=(r=e.tax_rate)!=null?r:e.rate)!=null?a:0,tax_amount:e.tax_amount})},A4e=(e,r)=>{var s,n;const a=je(se({},e.name?{name:e.name}:{}),{charge_type:e.charge_type,account_head:e.account_head||void 0,description:e.description||void 0,included_in_print_rate:(s=e.included_in_print_rate)!=null?s:0,cost_center:e.cost_center||void 0,rate:Ql(e),account_currency:e.account_currency||Er,idx:r+1});return e.charge_type==="Actual"&&(a.tax_amount=(n=e.tax_amount)!=null?n:0),a},O4e=()=>{var be,K,ye,Z,M,we;const{invoiceName:e}=hs(),[r]=_a(),a=hr(),s=e==="new",n=r.get("customer")||"",i=r.get("dn")||"",o=r.get("so")||"",l=r.get("company")||un,c=r.get("project")||"",[u,h]=p.useState(null),[f,y]=p.useState(!s),[b,w]=p.useState(null),[v,k]=p.useState(s),[S,N]=p.useState(!1),[C,O]=p.useState(!1),[T,P]=p.useState(null),[E,R]=p.useState(null),z=new Date().toISOString().split("T")[0],[G,ae]=p.useState({customer:n,posting_date:z,currency:Er,company:l,project:c||void 0,taxes_and_charges:Fp,items:[],taxes:[]}),ee=p.useCallback(pe=>{ae({customer:pe.customer||"",posting_date:pe.posting_date||z,currency:pe.currency==="INR"?Er:pe.currency||Er,company:pe.company||un,project:pe.project||"",items:(pe.items||[]).map(le=>oN(le)),tax_category:pe.tax_category||"",taxes_and_charges:pe.taxes_and_charges||"",shipping_rule:pe.shipping_rule||"",incoterm:pe.incoterm||"",taxes:(pe.taxes||[]).map(Xb),selling_price_list:pe.selling_price_list||"",price_list_currency:pe.price_list_currency||"",conversion_rate:pe.conversion_rate||1,plc_conversion_rate:pe.plc_conversion_rate||1}),P(null),R(null)},[z]);p.useEffect(()=>{const pe=G.company;!s||!pe||fetch(`/api/resource/Company/${encodeURIComponent(pe)}`,{credentials:"include"}).then(le=>le.json()).then(le=>{var Fe;if((Fe=le.data)!=null&&Fe.default_currency){const ze=Xn(le.data.default_currency);ae(Re=>je(se({},Re),{currency:ze,selling_price_list:Re.selling_price_list||"Standard Selling",price_list_currency:Re.price_list_currency||ze}))}}).catch(()=>{})},[G.company,s]),p.useEffect(()=>{!s||!i||fetch(`/api/resource/Delivery Note/${encodeURIComponent(i)}`,{credentials:"include"}).then(pe=>pe.json()).then(pe=>{const le=pe.data;if(!le)return;const Fe=le.project||"";ae(ze=>{var Re;return je(se({},ze),{customer:le.customer||ze.customer,company:le.company||ze.company,project:Fe||ze.project,tax_category:le.tax_category||ze.tax_category,taxes_and_charges:le.taxes_and_charges||ze.taxes_and_charges,shipping_rule:le.shipping_rule||ze.shipping_rule,incoterm:le.incoterm||ze.incoterm,taxes:((Re=le.taxes)!=null&&Re.length?le.taxes:ze.taxes||[]).map(Xb),items:(le.items||[]).map(De=>oN({item_code:De.item_code,item_name:De.item_name,description:De.description||De.item_name||De.item_code,qty:De.qty,uom:De.uom,stock_uom:De.stock_uom,rate:De.rate,amount:De.amount,project:De.project||Fe||void 0,delivery_note:i,sales_order:pi(De.against_sales_order),so_detail:pi(De.so_detail),dn_detail:De.name||void 0}))})})}).catch(()=>{})},[s,i]),p.useEffect(()=>{!s||!o||i||fetch(`/api/resource/Sales Order/${encodeURIComponent(o)}`,{credentials:"include"}).then(pe=>pe.json()).then(pe=>{const le=pe.data;if(!le)return;const Fe=String(le.project||"").trim()||c;ae(ze=>{var Re,De,Et,jt,Ie;return je(se({},ze),{customer:le.customer||ze.customer,company:le.company||ze.company,project:Fe||ze.project,tax_category:le.tax_category||ze.tax_category,taxes_and_charges:le.taxes_and_charges||ze.taxes_and_charges,shipping_rule:le.shipping_rule||ze.shipping_rule,incoterm:le.incoterm||ze.incoterm,taxes:((Re=le.taxes)!=null&&Re.length?le.taxes:ze.taxes||[]).map(Xb),currency:le.currency||ze.currency,selling_price_list:le.selling_price_list||ze.selling_price_list||"Standard Selling",price_list_currency:le.currency||ze.price_list_currency||ze.currency,conversion_rate:(Et=(De=le.conversion_rate)!=null?De:ze.conversion_rate)!=null?Et:1,plc_conversion_rate:(Ie=(jt=le.plc_conversion_rate)!=null?jt:ze.plc_conversion_rate)!=null?Ie:1,items:(le.items||[]).map($e=>{var Qe,at;return oN({item_code:$e.item_code,item_name:$e.item_name,description:$e.description||$e.item_name||$e.item_code,qty:$e.qty,uom:$e.uom,stock_uom:$e.stock_uom,conversion_factor:(Qe=$e.conversion_factor)!=null?Qe:1,rate:$e.rate,amount:(at=$e.amount)!=null?at:($e.qty||0)*($e.rate||0),income_account:$e.income_account,expense_account:$e.expense_account,item_tax_template:$e.item_tax_template,cost_center:$e.cost_center,project:$e.project||Fe||void 0,sales_order:o,so_detail:$e.name||void 0})})})})}).catch(()=>{})},[s,o,i]),p.useEffect(()=>{s||(y(!0),Pc.getSalesInvoice(e).then(pe=>{h(pe),ee(pe)}).catch(pe=>w(pe.message)).finally(()=>y(!1)))},[e,s,ee]);const ne=(pe,le)=>ae(Fe=>je(se({},Fe),{[pe]:le})),te=(pe,le,Fe)=>ae(ze=>{const Re=[...ze.items||[]],De=je(se({},Re[pe]),{[le]:Fe});if(le==="qty"||le==="rate"){const Et=parseFloat(String(le==="qty"?Fe:De.qty))||0,jt=parseFloat(String(le==="rate"?Fe:De.rate))||0;De.amount=parseFloat((Et*jt).toFixed(4)),De.net_amount=De.amount,De.net_rate=jt}return Re[pe]=De,je(se({},ze),{items:Re})}),Y=pe=>{ae(le=>{const Fe=[...le.items||[]],ze=N4e();let Re;return pe!==void 0?(Fe.splice(pe+1,0,ze),Re=pe+1):(Fe.push(ze),Re=Fe.length-1),setTimeout(()=>P(Re),0),je(se({},le),{items:Fe})})},q=pe=>{ae(le=>{const Fe=[...le.items||[]];return Fe.splice(pe,1),je(se({},le),{items:Fe})}),P(null)},H=(pe,le)=>J(null,null,function*(){if(te(pe,"item_code",le),!!le)try{const Re=(yield(yield fetch(`/api/resource/Item/${encodeURIComponent(le)}`,{credentials:"include"})).json()).data;if(!Re)return;ae(De=>{const Et=[...De.items||[]];return Et[pe]=je(se({},Et[pe]),{item_code:le,item_name:Re.item_name||le,description:Re.description||Et[pe].description||"",stock_uom:Re.stock_uom||Et[pe].stock_uom||"",uom:Re.sales_uom||Re.stock_uom||Et[pe].uom||""}),je(se({},De),{items:Et})})}catch(Fe){}}),U=(pe,le,Fe)=>ae(ze=>{const Re=[...ze.taxes||[]];return Re[pe]=je(se({},Re[pe]),{[le]:Fe}),je(se({},ze),{taxes:Re})}),re=pe=>{ae(le=>{const Fe=[...le.taxes||[]],ze=E4e();let Re;return pe!==void 0?(Fe.splice(pe+1,0,ze),Re=pe+1):(Fe.push(ze),Re=Fe.length-1),setTimeout(()=>R(Re),0),je(se({},le),{taxes:Fe})})},X=pe=>{ae(le=>{const Fe=[...le.taxes||[]];return Fe.splice(pe,1),je(se({},le),{taxes:Fe})}),R(null)},V=pe=>J(null,null,function*(){var le;if(pe)try{const Re=(yield(yield fetch(`/api/resource/Sales Taxes and Charges Template/${encodeURIComponent(pe)}`,{credentials:"include"})).json()).data;(le=Re==null?void 0:Re.taxes)!=null&&le.length&&ae(De=>je(se({},De),{taxes:Re.taxes.map(Et=>{var jt;return Xb({charge_type:Et.charge_type,account_head:Et.account_head,description:Et.description,rate:Et.rate,tax_amount:Et.tax_amount,cost_center:Et.cost_center,account_currency:Et.account_currency,included_in_print_rate:(jt=Et.included_in_print_rate)!=null?jt:0})})}))}catch(Fe){}});p.useEffect(()=>{!s||i||o||V(Fp)},[s,i,o]);const I=(G.items||[]).reduce((pe,le)=>pe+(le.amount||0),0),Q=((pe,le)=>{let Fe=le;return pe.map(ze=>{const Re=Ql(ze);let De=0;return ze.charge_type==="On Net Total"?De=le*(Re/100):ze.charge_type==="Actual"?De=ze.tax_amount||0:ze.charge_type==="On Previous Row Amount"||ze.charge_type==="On Previous Row Total"?De=Fe*(Re/100):De=le*(Re/100),Fe+=De,je(se({},ze),{_computed_amt:De,_computed_total:Fe})})})(G.taxes||[],I),ie=Q.reduce((pe,le)=>pe+le._computed_amt,0),me=I+ie,he=()=>J(null,null,function*(){if(!G.customer){We.error("Customer is required",{icon:t.jsx(pr,{})});return}if(!G.posting_date){We.error("Posting date is required",{icon:t.jsx(pr,{})});return}try{N(!0);const pe={customer:G.customer,posting_date:G.posting_date,currency:G.currency||void 0,selling_price_list:G.selling_price_list||"Standard Selling",price_list_currency:G.price_list_currency||G.currency||void 0,conversion_rate:G.conversion_rate||1,plc_conversion_rate:G.plc_conversion_rate||1,company:G.company||void 0,project:G.project||void 0,tax_category:G.tax_category||void 0,taxes_and_charges:G.taxes_and_charges||void 0,shipping_rule:G.shipping_rule||void 0,incoterm:G.incoterm||void 0,items:(G.items||[]).filter(le=>le.item_code).map((le,Fe)=>S4e(je(se({},le),{project:le.project||G.project}),Fe)),taxes:(G.taxes||[]).filter(le=>le.charge_type).map((le,Fe)=>A4e(le,Fe))};if(s){const le=yield Pc.createSalesInvoice(pe);We.success("Sales Invoice created",{icon:t.jsx(Qt,{})}),k(!1),a(`/invoices/${le.name}`)}else{const le=yield Pc.updateSalesInvoice(e,pe);h(le),ee(le),We.success("Sales Invoice saved",{icon:t.jsx(Qt,{})}),k(!1)}}catch(pe){We.error(pe instanceof Error?pe.message:"Error saving invoice",{icon:t.jsx(pr,{})})}finally{N(!1)}}),de=()=>J(null,null,function*(){if(!(!e||s))try{O(!0),yield Pc.clearItemLinkNones(e);const pe=yield Pc.submitSalesInvoice(e);h(pe),ee(pe),We.success("Sales Invoice submitted",{icon:t.jsx(Qt,{})})}catch(pe){We.error(pe instanceof Error?pe.message:"Error submitting",{icon:t.jsx(pr,{})})}finally{O(!1)}}),xe=s||v,ge=!s&&(u==null?void 0:u.docstatus)===1;return f?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsx(tr,{className:"animate-spin text-indigo-500 text-3xl"})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 px-6 py-6",children:[t.jsx($a,{position:"top-right",autoClose:3500}),t.jsxs("div",{className:"flex items-center gap-2 text-sm mb-6 text-gray-500",children:[t.jsx("button",{onClick:()=>a("/projects"),className:"hover:text-indigo-600",children:"Project Management"}),t.jsx("span",{children:"/"}),t.jsx("button",{onClick:()=>a("/invoices"),className:"hover:text-indigo-600",children:"Sales Invoices"}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:s?"New Sales Invoice":e})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 dark:border-gray-700 flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>a("/invoices"),className:"text-gray-400 hover:text-gray-700",children:t.jsx(ia,{})}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx(xm,{className:"text-indigo-500"}),t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:s?"New Sales Invoice":e}),!s&&t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${(()=>{const pe=(u==null?void 0:u.status)||"";return(u==null?void 0:u.docstatus)===2||pe==="Cancelled"?"bg-red-100 text-red-700":!u||u.docstatus===0?"bg-yellow-100 text-yellow-800":pe==="Paid"?"bg-green-100 text-green-800":pe==="Partly Paid"?"bg-indigo-100 text-indigo-800":pe==="Unpaid"?"bg-orange-100 text-orange-800":pe==="Overdue"?"bg-red-100 text-red-700":pe==="Return"||pe==="Credit Note Issued"?"bg-orange-100 text-orange-800":"bg-green-100 text-green-800"})()}`,children:(u==null?void 0:u.docstatus)===2?"Cancelled":(u==null?void 0:u.docstatus)===0?"Draft":(u==null?void 0:u.status)||"Submitted"})]}),G.customer&&t.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:G.customer})]})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[!s&&!v&&(u==null?void 0:u.docstatus)===0&&t.jsxs("button",{onClick:de,disabled:C,className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 text-sm font-medium",children:[C?t.jsx(tr,{className:"animate-spin"}):t.jsx(Lm,{size:12})," Submit"]}),!s&&!v&&ge&&((be=u==null?void 0:u.outstanding_amount)!=null?be:0)>0&&t.jsxs("button",{onClick:()=>{const pe=new URLSearchParams({si:e,customer:(u==null?void 0:u.customer)||"",company:(u==null?void 0:u.company)||"",project:(u==null?void 0:u.project)||"",amount:String((u==null?void 0:u.outstanding_amount)||(u==null?void 0:u.grand_total)||0),currency:(u==null?void 0:u.currency)||""});a(`/payment-entries/new?${pe}`)},className:"flex items-center gap-2 px-4 py-2 bg-teal-600 hover:bg-teal-700 text-white text-sm font-semibold rounded-lg shadow transition-colors",children:[t.jsx(Zu,{size:13})," Create Payment"]}),!s&&!v&&!ge&&t.jsxs("button",{onClick:()=>k(!0),className:"flex items-center gap-2 px-4 py-2 border border-indigo-500 text-indigo-600 rounded-lg hover:bg-indigo-50 text-sm",children:[t.jsx(qr,{})," Edit"]}),xe&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:he,disabled:S,className:"flex items-center gap-2 px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 disabled:opacity-50 text-sm font-medium",children:[S?t.jsx(tr,{className:"animate-spin"}):t.jsx(ta,{}),S?"Saving…":"Save"]}),!s&&t.jsx("button",{onClick:()=>{u&&ee(u),k(!1)},className:"px-3 py-2 border border-gray-300 rounded-lg text-gray-600 text-sm",children:t.jsx(ht,{})})]})]})]}),b&&t.jsx("div",{className:"mx-6 mt-4 p-3 bg-red-50 rounded-lg text-red-700 text-sm",children:b}),t.jsx("div",{className:"px-6 pt-5 pb-4",children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-4",children:[t.jsxs("div",{children:[t.jsx(aa,{required:!0,children:"Customer"}),xe?t.jsx(Je,{label:"Customer",hideLabel:!0,doctype:"Customer",value:G.customer||"",onChange:pe=>ne("customer",pe),placeholder:"Select customer…"}):t.jsx(Wl,{children:G.customer})]}),t.jsxs("div",{children:[t.jsx(aa,{required:!0,children:"Posting Date"}),xe?t.jsx("input",{type:"date",value:G.posting_date||"",onChange:pe=>ne("posting_date",pe.target.value),className:Jl}):t.jsx(Wl,{children:G.posting_date})]}),t.jsxs("div",{children:[t.jsx(aa,{children:"Currency"}),xe?t.jsxs("select",{value:G.currency||Er,onChange:pe=>ne("currency",pe.target.value),className:Jl,children:[t.jsx("option",{value:"SAR",children:"SAR"}),t.jsx("option",{value:"USD",children:"USD"}),t.jsx("option",{value:"EUR",children:"EUR"})]}):t.jsx(Wl,{children:G.currency})]}),t.jsxs("div",{children:[t.jsx(aa,{children:"Company"}),xe?t.jsx(Je,{label:"Company",hideLabel:!0,doctype:"Company",value:G.company||"",onChange:pe=>ne("company",pe),placeholder:"Select company…"}):t.jsx(Wl,{children:G.company})]})]})}),t.jsxs(Zb,{title:"Items",children:[t.jsx("div",{className:"overflow-x-auto -mx-2",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-8",children:"No."}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 min-w-[200px]",children:"Item"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3",children:"Item Name"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-24",children:"Qty"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:"Rate"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:"Amount"}),t.jsx("th",{className:"w-20 py-2 px-3"})]})}),t.jsxs("tbody",{children:[(G.items||[]).map((pe,le)=>{var Fe,ze,Re,De,Et;return t.jsxs(gr.Fragment,{children:[t.jsxs("tr",{className:`border-b border-gray-100 dark:border-gray-700 align-middle ${T===le?"bg-blue-50/60 dark:bg-blue-900/10":""}`,children:[t.jsx("td",{className:"py-1.5 px-3 text-gray-400 text-xs",children:le+1}),t.jsx("td",{className:"py-1.5 px-2 min-w-[200px]",children:xe?t.jsx(Je,{label:"Item",hideLabel:!0,doctype:"Item",value:pe.item_code||"",onChange:jt=>H(le,jt),placeholder:"Select item…"}):t.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-200",children:pe.item_code||t.jsx("span",{className:"text-gray-400 italic text-xs",children:"No item"})})}),t.jsx("td",{className:"py-1.5 px-3 text-gray-600 dark:text-gray-400 max-w-[180px] truncate text-sm",children:pe.item_name||t.jsx("span",{className:"text-gray-400",children:"-"})}),t.jsx("td",{className:"py-1.5 px-2 w-24",children:xe?t.jsx("input",{type:"number",min:0,step:"0.001",value:(Fe=pe.qty)!=null?Fe:1,onChange:jt=>te(le,"qty",parseFloat(jt.target.value)||0),className:"w-full px-2 py-1 text-sm text-right border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-400"}):t.jsx("span",{className:"block text-right text-gray-700 dark:text-gray-300 text-sm pr-1",children:(ze=pe.qty)!=null?ze:0})}),t.jsx("td",{className:"py-1.5 px-2 w-28",children:xe?t.jsx("input",{type:"number",min:0,step:"0.01",value:(Re=pe.rate)!=null?Re:0,onChange:jt=>te(le,"rate",parseFloat(jt.target.value)||0),className:"w-full px-2 py-1 text-sm text-right border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-400"}):t.jsx("span",{className:"block text-right text-gray-700 dark:text-gray-300 text-sm pr-1",children:((De=pe.rate)!=null?De:0).toFixed(2)})}),t.jsx("td",{className:"py-1.5 px-3 text-right font-semibold text-gray-900 dark:text-white text-sm",children:((Et=pe.amount)!=null?Et:0).toFixed(2)}),t.jsx("td",{className:"py-1.5 px-2",children:t.jsxs("div",{className:"flex items-center justify-end gap-1",children:[xe&&t.jsx("button",{onClick:()=>P(T===le?null:le),className:`p-1.5 rounded text-xs ${T===le?"bg-blue-600 text-white":"text-indigo-600 hover:bg-indigo-50 dark:hover:bg-indigo-900/20"}`,title:"More fields",children:t.jsx(xl,{size:11})}),xe&&t.jsx("button",{onClick:()=>q(le),className:"p-1.5 text-red-400 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 rounded text-xs",title:"Delete row",children:t.jsx(wr,{size:11})})]})})]}),xe&&T===le&&t.jsx(C4e,{item:pe,rowNo:le+1,onChange:(jt,Ie)=>{jt==="item_code"?H(le,Ie):te(le,jt,Ie)},onClose:()=>P(null),onDelete:()=>q(le),onInsertBelow:()=>Y(le)})]},le)}),xe&&t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"py-2 px-3",children:t.jsxs("button",{onClick:()=>Y(),className:"flex items-center gap-1.5 text-indigo-600 hover:text-indigo-700 text-sm font-medium",children:[t.jsx(Rr,{size:10})," Add Row"]})})})]})]})}),t.jsxs("div",{className:"mt-3 flex justify-between items-center text-sm border-t border-gray-100 dark:border-gray-700 pt-3",children:[t.jsxs("span",{className:"text-gray-500",children:["Total Quantity: ",t.jsx("strong",{className:"text-gray-800 dark:text-gray-200",children:(G.items||[]).reduce((pe,le)=>pe+(le.qty||0),0)})]}),t.jsxs("span",{className:"text-gray-500",children:["Total: ",t.jsxs("strong",{className:"text-gray-900 dark:text-white text-base",children:[Xn(G.currency)," ",I.toFixed(2)]})]})]})]}),t.jsxs(Zb,{title:"Taxes and Charges",defaultOpen:!0,children:[t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-x-8 gap-y-3",children:[t.jsxs("div",{children:[t.jsx(aa,{children:"Tax Category"}),xe?t.jsx(Je,{label:"Tax Category",hideLabel:!0,doctype:"Tax Category",value:G.tax_category||"",onChange:pe=>ne("tax_category",pe),placeholder:"Select tax category…"}):t.jsx(Wl,{children:G.tax_category})]}),t.jsxs("div",{children:[t.jsx(aa,{children:"Shipping Rule"}),xe?t.jsx(Je,{label:"Shipping Rule",hideLabel:!0,doctype:"Shipping Rule",value:G.shipping_rule||"",onChange:pe=>ne("shipping_rule",pe),placeholder:"Select shipping rule…"}):t.jsx(Wl,{children:G.shipping_rule})]}),t.jsxs("div",{children:[t.jsx(aa,{children:"Incoterm"}),xe?t.jsx(Je,{label:"Incoterm",hideLabel:!0,doctype:"Incoterm",value:G.incoterm||"",onChange:pe=>ne("incoterm",pe),placeholder:"Select incoterm…"}):t.jsx(Wl,{children:G.incoterm})]})]}),t.jsxs("div",{className:"mt-3",children:[t.jsx(aa,{children:"Sales Taxes and Charges Template"}),xe?t.jsx(Je,{label:"Sales Taxes and Charges Template",hideLabel:!0,doctype:"Sales Taxes and Charges Template",value:G.taxes_and_charges||"",onChange:pe=>{ne("taxes_and_charges",pe),V(pe)},placeholder:"Select template…"}):t.jsx(Wl,{children:G.taxes_and_charges})]}),t.jsxs("div",{className:"overflow-x-auto -mx-2 mt-4",children:[t.jsx("p",{className:"text-[11px] font-semibold text-gray-500 uppercase tracking-wide px-2 mb-2",children:"Sales Taxes and Charges"}),t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-8",children:"No."}),t.jsxs("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-44",children:["Type ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsxs("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3",children:["Account Head ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-24",children:"Tax Rate"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:"Amount"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:"Total"}),xe&&t.jsx("th",{className:"w-16 py-2 px-2"})]})}),t.jsxs("tbody",{children:[Q.length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:xe?7:6,className:"py-10 text-center text-gray-400 text-sm",children:"No tax rows — use Add Row or pick a template."})}),Q.map((pe,le)=>{var Fe,ze;return t.jsxs(gr.Fragment,{children:[t.jsxs("tr",{className:`border-b border-gray-100 dark:border-gray-700 align-middle ${E===le?"bg-blue-50/60 dark:bg-blue-900/10":""}`,children:[t.jsx("td",{className:"py-1.5 px-3 text-gray-400 text-xs",children:le+1}),t.jsx("td",{className:"py-1.5 px-2 w-44",children:xe?t.jsxs("select",{value:pe.charge_type||"",onChange:Re=>U(le,"charge_type",Re.target.value),className:rB,children:[t.jsx("option",{value:"",children:"Select type…"}),t.jsx("option",{value:"Actual",children:"Actual"}),t.jsx("option",{value:"On Net Total",children:"On Net Total"}),t.jsx("option",{value:"On Previous Row Amount",children:"On Previous Row Amount"}),t.jsx("option",{value:"On Previous Row Total",children:"On Previous Row Total"}),t.jsx("option",{value:"On Item Quantity",children:"On Item Quantity"}),t.jsx("option",{value:"Inter Company Transaction",children:"Inter Company Transaction"})]}):t.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:pe.charge_type||"-"})}),t.jsx("td",{className:"py-1.5 px-2",children:xe?t.jsx(Je,{label:"Account Head",hideLabel:!0,doctype:"Account",value:pe.account_head||"",onChange:Re=>U(le,"account_head",Re),placeholder:"Account Head"}):t.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:pe.account_head||"-"})}),t.jsx("td",{className:"py-1.5 px-2 w-24",children:xe?t.jsx("input",{type:"number",min:0,step:"0.01",value:Ql(pe),onChange:Re=>U(le,"tax_rate",parseFloat(Re.target.value)||0),className:k4e}):t.jsx("span",{className:"block text-right text-gray-700 dark:text-gray-300 pr-1",children:Ql(pe)})}),t.jsx("td",{className:"py-1.5 px-3 text-right text-gray-700 dark:text-gray-300 text-sm",children:((Fe=pe._computed_amt)!=null?Fe:0).toFixed(2)}),t.jsx("td",{className:"py-1.5 px-3 text-right font-semibold text-gray-900 dark:text-white text-sm",children:((ze=pe._computed_total)!=null?ze:0).toFixed(2)}),xe&&t.jsx("td",{className:"py-1.5 px-2",children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button",onClick:()=>R(E===le?null:le),className:`p-1.5 rounded text-xs ${E===le?"bg-blue-600 text-white":"text-indigo-600 hover:bg-indigo-50 dark:hover:bg-indigo-900/20"}`,title:"More fields",children:t.jsx(xl,{size:11})}),t.jsx("button",{type:"button",onClick:()=>X(le),className:"p-1.5 text-red-400 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 rounded",children:t.jsx(wr,{size:11})})]})})]}),xe&&E===le&&t.jsx(T4e,{tax:pe,rowNo:le+1,onChange:(Re,De)=>U(le,Re,De),onClose:()=>R(null),onDelete:()=>X(le),onInsertBelow:()=>re(le)})]},le)}),xe&&t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"py-2 px-3",children:t.jsxs("button",{type:"button",onClick:()=>re(),className:"flex items-center gap-1.5 text-indigo-600 hover:text-indigo-700 text-sm font-medium",children:[t.jsx(Rr,{size:10})," Add Row"]})})})]})]})]}),t.jsxs("div",{className:"mt-3 flex justify-end text-sm text-gray-500 pt-2 border-t border-gray-100 dark:border-gray-700",children:["Total Taxes and Charges (",Xn(G.currency),"):"," ",t.jsxs("strong",{className:"ml-2 text-gray-900 dark:text-white",children:[Xn(G.currency)," ",((K=u==null?void 0:u.total_taxes_and_charges)!=null?K:ie).toFixed(2)]})]})]}),t.jsx(Zb,{title:"Totals",children:t.jsx("div",{className:"space-y-3 max-w-xs ml-auto",children:[{label:"Net Total",value:((ye=u==null?void 0:u.net_total)!=null?ye:I).toFixed(2)},{label:"Total Taxes",value:((Z=u==null?void 0:u.total_taxes_and_charges)!=null?Z:ie).toFixed(2)},{label:"Grand Total",value:((M=u==null?void 0:u.grand_total)!=null?M:me).toFixed(2)},{label:"Outstanding",value:(u!=null&&(we=u.outstanding_amount)!=null?we:me).toFixed(2)}].map(({label:pe,value:le})=>t.jsxs("div",{className:"flex justify-between items-center text-sm border-b border-gray-100 dark:border-gray-700 pb-2 last:border-0",children:[t.jsx("span",{className:"text-gray-500",children:pe}),t.jsxs("span",{className:"font-semibold text-gray-900 dark:text-white",children:[Xn(G.currency)," ",le]})]},pe))})}),!s&&u&&t.jsx(Zb,{title:"Meta",defaultOpen:!1,children:t.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[t.jsxs("div",{children:[t.jsx(aa,{children:"Created By"}),t.jsx(Wl,{children:u.owner})]}),t.jsxs("div",{children:[t.jsx(aa,{children:"Created"}),t.jsx(Wl,{children:u.creation?new Date(u.creation).toLocaleString():"-"})]}),t.jsxs("div",{children:[t.jsx(aa,{children:"Modified"}),t.jsx(Wl,{children:u.modified?new Date(u.modified).toLocaleString():"-"})]})]})}),!s&&t.jsx(vi,{doctype:"Sales Invoice",docname:(u==null?void 0:u.name)||e||"",creationDate:u==null?void 0:u.creation,createdBy:u==null?void 0:u.owner,compact:!1,initialVisible:5,collapsible:!0,startCollapsed:!0})]})]})},$0=20;function P4e(e){const r=[];return e.search&&r.push(["Sales Order","name","like",`%${e.search}%`]),e.project&&r.push(["Sales Order","project","=",e.project]),e.status==="Draft"&&r.push(["Sales Order","docstatus","=",0]),e.status==="Submitted"&&r.push(["Sales Order","docstatus","=",1]),e.status==="Cancelled"&&r.push(["Sales Order","docstatus","=",2]),r}function D4e(e){return e.docstatus===2?"bg-red-100 text-red-700":e.docstatus===1?e.billing_status==="Fully Billed"?"bg-green-100 text-green-700":(e.delivery_status==="Fully Delivered","bg-blue-100 text-blue-700"):"bg-yellow-100 text-yellow-800"}function R4e(e){return e.docstatus===2?"Cancelled":e.docstatus===1?e.status||"Submitted":"Draft"}const M4e=()=>{var ie;const{t:e}=sr(),r=hr(),[a,s]=_a(),[n,i]=p.useState([]),[o,l]=p.useState(!0),[c,u]=p.useState(0),[h,f]=p.useState(0),[y,b]=p.useState(!1),w=((ie=a.get("project"))==null?void 0:ie.trim())||"",[v,k]=p.useState(""),[S,N]=p.useState(""),[C,O]=p.useState(w),[T,P]=p.useState({search:"",status:"",project:w}),[E,R]=p.useState(!1),z=p.useRef(!1),G=p.useRef(null);p.useEffect(()=>{var he;const me=((he=a.get("project"))==null?void 0:he.trim())||"";O(me),P(de=>de.project===me?de:(f(0),je(se({},de),{project:me})))},[a]);const ae=p.useCallback((me,he)=>J(null,null,function*(){l(!0);try{const de=[];he.search&&de.push(["Sales Order","name","like",`%${he.search}%`]),he.project&&de.push(["Sales Order","project","=",he.project]),he.status==="Draft"&&de.push(["Sales Order","docstatus","=",0]),he.status==="Submitted"&&de.push(["Sales Order","docstatus","=",1]),he.status==="Cancelled"&&de.push(["Sales Order","docstatus","=",2]);const[xe,ge]=yield Promise.all([Io.getSalesOrders({filters:de,limit_start:me,limit_page_length:$0}),Io.getSalesOrderCount(de)]);i(xe),u(ge)}catch(de){We.error(de.message||"Failed to load")}finally{l(!1)}}),[]);p.useEffect(()=>{ae(0,T)},[ae,T]);const ee=p.useMemo(()=>`${h}|${T.search}|${T.status}|${T.project}`,[h,T.search,T.status,T.project]),{selectedRows:ne,toggleRow:te,toggleAllOnPage:Y,allOnPageSelected:q,someOnPageSelected:H}=po(n,ee);p.useEffect(()=>{if(!z.current){z.current=!0;return}const me={search:T.search,status:S,project:C.trim()};P(me),f(0),s(he=>{const de=new URLSearchParams(he);return me.project?de.set("project",me.project):de.delete("project"),de})},[S,C]),p.useEffect(()=>{if(z.current)return G.current&&window.clearTimeout(G.current),G.current=window.setTimeout(()=>{const me={search:v,status:S,project:C.trim()};P(me),f(0)},450),()=>{G.current&&window.clearTimeout(G.current)}},[v,S,C]);const U=()=>{k(""),N(""),O(""),P({search:"",status:"",project:""}),f(0),s(me=>{const he=new URLSearchParams(me);return he.delete("project"),he})},re=!!(T.search||T.status||T.project),X=me=>{f(me),ae(me*$0,T)},V=me=>r(`/sales-orders/${encodeURIComponent(me)}`),I=me=>r(`/sales-orders/${encodeURIComponent(me)}?edit=1`),B=me=>r(`/sales-orders/new?duplicate=${encodeURIComponent(me)}`),Q=p.useCallback(()=>go({doctype:"Sales Order",filters:P4e(T),orderBy:"modified desc"}),[T]);return t.jsxs("div",{className:"p-6",children:[t.jsx($a,{position:"top-right",autoClose:3e3}),t.jsxs("div",{className:"flex items-center justify-between mb-6 gap-4 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl bg-blue-600 flex items-center justify-center",children:t.jsx(dm,{className:"text-white text-base"})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:"Sales Orders"}),t.jsxs("p",{className:"text-xs text-gray-500",children:[c," total"]})]})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("button",{onClick:()=>ae(h*$0,T),className:"p-2 text-gray-500 hover:text-blue-600 border border-gray-200 rounded-lg",children:t.jsx(Ma,{size:13})}),t.jsxs("button",{type:"button",onClick:()=>R(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all text-sm font-medium disabled:opacity-50",disabled:c===0&&ne.size===0,children:[t.jsx(Sa,{})," ",e("listPages.export"),ne.size>0&&t.jsx("span",{className:"bg-white/25 px-1.5 py-0.5 rounded text-xs font-bold",children:ne.size})]}),t.jsxs("button",{type:"button",onClick:()=>{const me=T.project?`?project=${encodeURIComponent(T.project)}`:"";r(`/sales-orders/new${me}`)},className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 text-sm font-medium",children:[t.jsx(Rr,{size:11})," New Order"]})]})]}),t.jsx(bi,{isOpen:E,onClose:()=>R(!1),doctype:"Sales Order",selectedCount:ne.size,pageCount:n.length,totalCount:c,pageData:n,selectedRows:ne,rowKey:"name",onFetchAll:Q,fileNamePrefix:"sales_orders"}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl mb-5 overflow-hidden",children:[t.jsxs("button",{onClick:()=>b(me=>!me),className:"w-full flex items-center justify-between px-4 py-3 bg-gradient-to-r from-blue-500 to-blue-600 dark:from-blue-600 dark:to-blue-700 text-white",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[t.jsx(za,{size:12})," Filters",re&&t.jsx("span",{className:"bg-white/30 text-white text-xs px-2 py-0.5 rounded-full",children:"Active"})]}),y?t.jsx(Ja,{size:11}):t.jsx(Fr,{size:11})]}),re&&t.jsxs("div",{className:"px-4 py-2 bg-blue-50 dark:bg-blue-900/20 flex flex-wrap gap-2 items-center border-b border-blue-100 dark:border-blue-800",children:[T.search&&t.jsxs("span",{className:"flex items-center gap-1 text-xs bg-blue-100 dark:bg-blue-800 text-blue-700 dark:text-blue-300 px-2 py-1 rounded-full",children:["ID: ",T.search,t.jsx("button",{type:"button",onClick:()=>{k(""),P(me=>je(se({},me),{search:""}))},children:t.jsx(ht,{size:9})})]}),T.project&&t.jsxs("span",{className:"flex items-center gap-1 text-xs bg-blue-100 dark:bg-blue-800 text-blue-700 dark:text-blue-300 px-2 py-1 rounded-full",children:["Project: ",T.project,t.jsx("button",{type:"button",onClick:()=>{O(""),P(me=>je(se({},me),{project:""})),s(me=>{const he=new URLSearchParams(me);return he.delete("project"),he})},children:t.jsx(ht,{size:9})})]}),T.status&&t.jsxs("span",{className:"flex items-center gap-1 text-xs bg-blue-100 dark:bg-blue-800 text-blue-700 dark:text-blue-300 px-2 py-1 rounded-full",children:["Status: ",T.status,t.jsx("button",{type:"button",onClick:()=>{N(""),P(me=>je(se({},me),{status:""}))},children:t.jsx(ht,{size:9})})]}),t.jsx("button",{type:"button",onClick:U,className:"text-xs text-blue-600 hover:underline ml-auto",children:"Clear All"})]}),y&&t.jsxs("div",{className:"px-4 py-3 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[11px] font-semibold text-gray-500 uppercase tracking-wide mb-1",children:"Order ID"}),t.jsx("input",{value:v,onChange:me=>k(me.target.value),onKeyDown:me=>me.key==="Enter"&&me.preventDefault(),placeholder:"Search…",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-blue-400"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[11px] font-semibold text-gray-500 uppercase tracking-wide mb-1",children:"Project"}),t.jsx("input",{value:C,onChange:me=>O(me.target.value),onKeyDown:me=>me.key==="Enter"&&me.preventDefault(),placeholder:"Project name…",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-blue-400"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[11px] font-semibold text-gray-500 uppercase tracking-wide mb-1",children:"Status"}),t.jsxs("select",{value:S,onChange:me=>N(me.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-blue-400",children:[t.jsx("option",{value:"",children:"All"}),t.jsx("option",{value:"Draft",children:"Draft"}),t.jsx("option",{value:"Submitted",children:"Submitted"}),t.jsx("option",{value:"Cancelled",children:"Cancelled"})]})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl overflow-hidden",children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx("th",{className:"w-10 px-4 py-3 text-left",children:t.jsx("button",{type:"button",onClick:Y,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:q?"Deselect all":"Select all","aria-label":"Select all on page",children:q?t.jsx(Ra,{className:"text-blue-600 dark:text-blue-400",size:18}):H?t.jsxs("div",{className:"relative inline-block",children:[t.jsx(Ur,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Ur,{size:18})})}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Order ID"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Customer"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Date"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Status"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Grand Total"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4 w-28",children:" "})]})}),t.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:o?t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"text-center py-10 text-gray-400",children:"Loading…"})}):n.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"text-center py-10 text-gray-400",children:"No sales orders found"})}):n.map(me=>{var he;return t.jsxs("tr",{onClick:()=>V(me.name),className:`cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors ${ne.has(me.name)?"bg-blue-50 dark:bg-blue-900/20":""}`,children:[t.jsx("td",{className:"w-10 px-4 py-3",onClick:de=>de.stopPropagation(),children:t.jsx("button",{type:"button",onClick:()=>te(me.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors","aria-label":`Select ${me.name}`,children:ne.has(me.name)?t.jsx(Ra,{className:"text-blue-600 dark:text-blue-400",size:18}):t.jsx(Ur,{size:18})})}),t.jsx("td",{className:"py-3 px-4 font-medium text-gray-900 dark:text-white",children:me.name}),t.jsx("td",{className:"py-3 px-4 text-gray-700 dark:text-gray-300",children:me.customer_name||me.customer||"-"}),t.jsx("td",{className:"py-3 px-4 text-gray-500",children:me.transaction_date||"-"}),t.jsx("td",{className:"py-3 px-4",children:t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${D4e(me)}`,children:R4e(me)})}),t.jsxs("td",{className:"py-3 px-4 text-right font-semibold text-gray-900 dark:text-white",children:[me.currency||"SAR"," ",((he=me.grand_total)!=null?he:0).toFixed(2)]}),t.jsx("td",{className:"py-2 px-4",onClick:de=>de.stopPropagation(),children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>V(me.name),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded transition-colors",title:"View",children:t.jsx(Ps,{})}),t.jsx("button",{onClick:()=>I(me.name),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:"Edit",children:t.jsx(qr,{})}),t.jsx("button",{onClick:()=>B(me.name),className:"text-purple-600 dark:text-purple-400 hover:text-purple-900 dark:hover:text-purple-300 p-2 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded transition-colors",title:"Duplicate",children:t.jsx(Vo,{})})]})})]},me.name)})})]})}),c>$0&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-100 dark:border-gray-700",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:[h*$0+1,"–",Math.min((h+1)*$0,c)," of ",c]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:h===0,onClick:()=>X(h-1),className:"px-3 py-1 text-xs border border-gray-300 rounded disabled:opacity-40",children:"Prev"}),t.jsx("button",{disabled:(h+1)*$0>=c,onClick:()=>X(h+1),className:"px-3 py-1 text-xs border border-gray-300 rounded disabled:opacity-40",children:"Next"})]})]})]})]})},Qr=({children:e,required:r})=>t.jsxs("label",{className:"block text-[11px] font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1",children:[e,r&&t.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),Hl=({children:e})=>t.jsx("div",{className:"px-3 py-2 text-sm text-gray-800 dark:text-gray-200 bg-gray-50 dark:bg-gray-800/60 rounded min-h-[34px] flex items-center",children:e||t.jsx("span",{className:"text-gray-400",children:"-"})}),Zl="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-blue-400",np=Zl+" text-right",lN="w-full px-2 py-1 text-sm text-right border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-blue-400",t9="w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-blue-400",L4e=({items:e})=>{const[r,a]=p.useState(!1),s=p.useRef(null);return p.useEffect(()=>{const n=i=>{s.current&&!s.current.contains(i.target)&&a(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[]),t.jsxs("div",{className:"relative",ref:s,children:[t.jsxs("button",{onClick:()=>a(n=>!n),className:"flex items-center gap-1.5 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 text-sm font-medium shadow-sm",children:["Create",t.jsx(Fr,{size:10,className:`transition-transform ${r?"rotate-180":""}`})]}),r&&t.jsxs("div",{className:"absolute right-0 mt-1 w-52 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl shadow-xl z-50 py-1.5 overflow-hidden",children:[t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-bold text-gray-400 dark:text-gray-500 uppercase tracking-wider border-b border-gray-100 dark:border-gray-700 mb-1",children:"Create from this order"}),e.map(({label:n,icon:i,onClick:o})=>t.jsxs("button",{onClick:()=>{o(),a(!1)},className:"w-full flex items-center gap-3 px-4 py-2.5 text-sm text-gray-700 dark:text-gray-300 hover:bg-blue-50 dark:hover:bg-blue-900/20 hover:text-blue-700 dark:hover:text-blue-300 transition-colors text-left",children:[t.jsx("span",{className:"text-gray-400 group-hover:text-blue-500",children:i}),n]},n))]})]})},Cd=({title:e,children:r,defaultOpen:a=!1})=>{const[s,n]=p.useState(a);return t.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-600 mt-3 pt-1",children:[t.jsxs("button",{type:"button",onClick:()=>n(i=>!i),className:"flex items-center gap-2 py-1 text-xs font-semibold text-blue-600 dark:text-blue-400 hover:underline",children:[s?t.jsx(Fr,{size:9}):t.jsx(Fi,{size:9}),e]}),s&&t.jsx("div",{className:"mt-2",children:r})]})},F4e=({item:e,rowNo:r,onChange:a,onClose:s,onDelete:n,onInsertBelow:i})=>{var o,l,c,u,h,f,y,b,w,v,k,S;return t.jsx("tr",{children:t.jsx("td",{colSpan:8,className:"p-0",children:t.jsxs("div",{className:"border border-blue-300 dark:border-blue-600 rounded-lg mx-2 my-1 bg-white dark:bg-gray-800 shadow-md",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-blue-50 dark:bg-blue-900/30 rounded-t-lg border-b border-blue-200 dark:border-blue-700",children:[t.jsxs("span",{className:"text-sm font-semibold text-blue-700 dark:text-blue-300",children:["Editing Row #",r]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:i,className:"px-2 py-1 text-xs border border-gray-300 rounded hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-600",children:"Insert Below"}),t.jsx("button",{onClick:n,className:"px-2 py-1 text-xs border border-red-300 rounded text-red-500 hover:bg-red-50",children:"Delete"}),t.jsx("button",{onClick:s,className:"p-1 text-gray-400 hover:text-gray-600",children:t.jsx(ht,{size:13})})]})]}),t.jsxs("div",{className:"p-4 space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(Qr,{required:!0,children:"Item Code"}),t.jsx(Je,{label:"Item",hideLabel:!0,doctype:"Item",value:e.item_code||"",onChange:N=>a("item_code",N),placeholder:"Select item…"})]}),t.jsxs("div",{children:[t.jsx(Qr,{children:"Delivery Date"}),t.jsx("input",{type:"date",value:e.delivery_date||"",onChange:N=>a("delivery_date",N.target.value),className:Zl})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"flex items-center gap-2 pt-4",children:[t.jsx("input",{type:"checkbox",checked:!!e.ensure_delivery_based_on_produced_serial_no,onChange:N=>a("ensure_delivery_based_on_produced_serial_no",N.target.checked?1:0),className:"rounded"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Ensure Delivery Based on Produced Serial No"})]}),t.jsxs("div",{children:[t.jsx(Qr,{required:!0,children:"Item Name"}),t.jsx("input",{value:e.item_name||"",onChange:N=>a("item_name",N.target.value),className:Zl,placeholder:"Item name…"})]})]}),t.jsx(Cd,{title:"Description",defaultOpen:!!e.description,children:t.jsx("textarea",{rows:2,value:e.description||"",onChange:N=>a("description",N.target.value),className:Zl,placeholder:"Description…"})}),t.jsx(Cd,{title:"Quantity and Rate",defaultOpen:!0,children:t.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[t.jsxs("div",{children:[t.jsx(Qr,{required:!0,children:"Quantity"}),t.jsx("input",{type:"number",min:0,step:"1",value:(o=e.qty)!=null?o:0,onChange:N=>a("qty",parseFloat(N.target.value)||0),className:np})]}),t.jsxs("div",{children:[t.jsx(Qr,{required:!0,children:"UOM"}),t.jsx(Je,{label:"UOM",hideLabel:!0,doctype:"UOM",value:e.uom||"",onChange:N=>a("uom",N),placeholder:"UOM…"})]}),t.jsxs("div",{children:[t.jsx(Qr,{children:"Stock UOM"}),t.jsx(Je,{label:"Stock UOM",hideLabel:!0,doctype:"UOM",value:e.stock_uom||"",onChange:N=>a("stock_uom",N),placeholder:"Stock UOM…"})]}),t.jsxs("div",{children:[t.jsx(Qr,{required:!0,children:"UOM Conversion Factor"}),t.jsx("input",{type:"number",min:0,step:"0.001",value:(l=e.conversion_factor)!=null?l:1,onChange:N=>a("conversion_factor",parseFloat(N.target.value)||1),className:np})]}),t.jsxs("div",{children:[t.jsx(Qr,{children:"Qty as per Stock UOM"}),t.jsx("div",{className:"px-3 py-2 text-sm text-gray-600 bg-gray-50 dark:bg-gray-700 rounded text-right",children:((e.qty||0)*(e.conversion_factor||1)).toFixed(3)})]}),t.jsxs("div",{children:[t.jsx(Qr,{children:"Price List Rate"}),t.jsx("input",{type:"number",min:0,step:"0.01",value:(c=e.price_list_rate)!=null?c:0,onChange:N=>a("price_list_rate",parseFloat(N.target.value)||0),className:np})]})]})}),t.jsx(Cd,{title:"Discount and Margin",children:t.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[t.jsxs("div",{children:[t.jsx(Qr,{required:!0,children:"Rate"}),t.jsx("input",{type:"number",min:0,step:"0.01",value:(u=e.rate)!=null?u:0,onChange:N=>a("rate",parseFloat(N.target.value)||0),className:np})]}),t.jsxs("div",{children:[t.jsx(Qr,{children:"Rate of Stock UOM"}),t.jsx("div",{className:"px-3 py-2 text-sm text-right bg-gray-50 dark:bg-gray-700 rounded",children:((h=e.stock_uom_rate)!=null?h:0).toFixed(2)})]}),t.jsxs("div",{children:[t.jsx(Qr,{required:!0,children:"Amount"}),t.jsx("div",{className:"px-3 py-2 text-sm font-semibold text-right bg-gray-50 dark:bg-gray-700 rounded",children:((e.qty||0)*(e.rate||0)).toFixed(2)})]}),t.jsxs("div",{children:[t.jsx(Qr,{children:"Item Tax Template"}),t.jsx("input",{value:e.item_tax_template||"",onChange:N=>a("item_tax_template",N.target.value),className:Zl,placeholder:"Tax template…"})]}),t.jsxs("div",{children:[t.jsx(Qr,{children:"Billed Amount"}),t.jsx("div",{className:"px-3 py-2 text-sm text-right bg-gray-50 dark:bg-gray-700 rounded",children:((f=e.billed_amt)!=null?f:0).toFixed(2)})]}),t.jsxs("div",{children:[t.jsx(Qr,{children:"Valuation Rate"}),t.jsx("div",{className:"px-3 py-2 text-sm text-right bg-gray-50 dark:bg-gray-700 rounded",children:((y=e.valuation_rate)!=null?y:0).toFixed(2)})]}),t.jsxs("div",{children:[t.jsx(Qr,{children:"Gross Profit"}),t.jsx("div",{className:"px-3 py-2 text-sm text-right bg-gray-50 dark:bg-gray-700 rounded",children:((b=e.gross_profit)!=null?b:0).toFixed(2)})]}),t.jsxs("div",{className:"flex flex-col justify-end gap-2 pb-1",children:[t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:!!e.is_free_item,onChange:N=>a("is_free_item",N.target.checked?1:0),className:"rounded"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Is Free Item"})]}),t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:e.grant_commission!==0,onChange:N=>a("grant_commission",N.target.checked?1:0),className:"rounded"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Grant Commission"})]})]})]})}),t.jsx(Cd,{title:"Drop Ship",children:t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"checkbox",checked:!!e.delivered_by_supplier,onChange:N=>a("delivered_by_supplier",N.target.checked?1:0),className:"rounded"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Supplier delivers to Customer"})]}),e.delivered_by_supplier?t.jsxs("div",{children:[t.jsx(Qr,{children:"Supplier"}),t.jsx(Je,{label:"Supplier",hideLabel:!0,doctype:"Supplier",value:e.supplier||"",onChange:N=>a("supplier",N),placeholder:"Select supplier…"})]}):null]})}),t.jsx(Cd,{title:"Item Weight Details",children:t.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[t.jsxs("div",{children:[t.jsx(Qr,{children:"Weight Per Unit"}),t.jsx("input",{type:"number",min:0,step:"0.001",value:(w=e.weight_per_unit)!=null?w:0,onChange:N=>a("weight_per_unit",parseFloat(N.target.value)||0),className:np})]}),t.jsxs("div",{children:[t.jsx(Qr,{children:"Weight UOM"}),t.jsx("input",{value:e.weight_uom||"",onChange:N=>a("weight_uom",N.target.value),className:Zl,placeholder:"UOM…"})]}),t.jsxs("div",{children:[t.jsx(Qr,{children:"Total Weight"}),t.jsx("div",{className:"px-3 py-2 text-sm text-right bg-gray-50 dark:bg-gray-700 rounded",children:((v=e.total_weight)!=null?v:0).toFixed(3)})]})]})}),t.jsx(Cd,{title:"Warehouse and Reference",children:t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(Qr,{children:"Delivery Warehouse"}),t.jsx(Je,{label:"Warehouse",hideLabel:!0,doctype:"Warehouse",value:e.delivery_warehouse||"",onChange:N=>a("delivery_warehouse",N),placeholder:"Warehouse…"})]}),t.jsx("div",{className:"flex items-end pb-2",children:t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:!!e.against_blanket_order,onChange:N=>a("against_blanket_order",N.target.checked?1:0),className:"rounded"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Against Blanket Order"})]})})]})}),t.jsx(Cd,{title:"Available Quantity",children:t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(Qr,{children:"Qty (Warehouse)"}),t.jsx("div",{className:"px-3 py-2 text-sm text-right bg-gray-50 dark:bg-gray-700 rounded",children:(k=e.actual_qty)!=null?k:0})]}),t.jsxs("div",{children:[t.jsx(Qr,{children:"Qty (Company)"}),t.jsx("div",{className:"px-3 py-2 text-sm text-right bg-gray-50 dark:bg-gray-700 rounded",children:(S=e.company_total_stock)!=null?S:0})]})]})}),t.jsx(Cd,{title:"Manufacturing Section",children:t.jsxs("div",{children:[t.jsx(Qr,{children:"BOM No"}),t.jsx(Je,{label:"BOM",hideLabel:!0,doctype:"BOM",value:e.bom_no||"",onChange:N=>a("bom_no",N),placeholder:"BOM…"})]})})]})]})})})},I4e=({tax:e,rowNo:r,onChange:a,onClose:s,onDelete:n,onInsertBelow:i})=>t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"p-0",children:t.jsxs("div",{className:"border border-blue-300 dark:border-blue-600 rounded-lg mx-2 my-1 bg-white dark:bg-gray-800 shadow-md",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-blue-50 dark:bg-blue-900/30 rounded-t-lg border-b border-blue-200",children:[t.jsxs("span",{className:"text-sm font-semibold text-blue-700 dark:text-blue-300",children:["Editing Row #",r]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:i,className:"px-2 py-1 text-xs border border-gray-300 rounded hover:bg-gray-50 text-gray-600",children:"Insert Below"}),t.jsx("button",{onClick:n,className:"px-2 py-1 text-xs border border-red-300 rounded text-red-500 hover:bg-red-50",children:"Delete"}),t.jsx("button",{onClick:s,className:"p-1 text-gray-400 hover:text-gray-600",children:t.jsx(ht,{size:13})})]})]}),t.jsxs("div",{className:"p-4 space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(Qr,{required:!0,children:"Type"}),t.jsxs("select",{value:e.charge_type||"",onChange:o=>a("charge_type",o.target.value),className:Zl,children:[t.jsx("option",{value:"",children:"Select type…"}),t.jsx("option",{value:"Actual",children:"Actual"}),t.jsx("option",{value:"On Net Total",children:"On Net Total"}),t.jsx("option",{value:"On Previous Row Amount",children:"On Previous Row Amount"}),t.jsx("option",{value:"On Previous Row Total",children:"On Previous Row Total"}),t.jsx("option",{value:"On Item Quantity",children:"On Item Quantity"}),t.jsx("option",{value:"Inter Company Transaction",children:"Inter Company Transaction"})]})]}),t.jsxs("div",{children:[t.jsx(Qr,{children:"Description"}),t.jsx("textarea",{rows:3,value:e.description||"",onChange:o=>a("description",o.target.value),className:Zl,placeholder:"Description…"})]})]}),t.jsxs("div",{children:[t.jsx(Qr,{required:!0,children:"Account Head"}),t.jsx(Je,{label:"Account Head",hideLabel:!0,doctype:"Account",value:e.account_head||"",onChange:o=>a("account_head",o),placeholder:"Account…"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"checkbox",checked:!!e.included_in_print_rate,onChange:o=>a("included_in_print_rate",o.target.checked?1:0),className:"rounded"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Is this Tax included in Basic Rate?"})]}),t.jsx("p",{className:"text-xs text-blue-500 dark:text-blue-400",children:"If checked, the tax amount will be considered as already included in the Print Rate / Print Amount"}),t.jsx(Cd,{title:"Accounting Dimensions",defaultOpen:!0,children:t.jsxs("div",{children:[t.jsx(Qr,{children:"Cost Center"}),t.jsx(Je,{label:"Cost Center",hideLabel:!0,doctype:"Cost Center",value:e.cost_center||"",onChange:o=>a("cost_center",o),placeholder:"Cost center…"})]})}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(Qr,{required:!0,children:"Tax Rate"}),t.jsx("input",{type:"number",min:0,step:"0.01",value:Ql(e),onChange:o=>a("tax_rate",parseFloat(o.target.value)||0),className:np})]}),t.jsxs("div",{children:[t.jsx(Qr,{children:"Account Currency"}),t.jsx("input",{value:e.account_currency||Er,onChange:o=>a("account_currency",o.target.value),className:Zl})]})]})]})]})})}),z4e=()=>({item_code:"",item_name:"",qty:1,rate:0,amount:0,uom:"",conversion_factor:1,is_free_item:0,grant_commission:0}),$4e=()=>({charge_type:"",account_head:"",tax_rate:0,account_currency:Er,included_in_print_rate:0}),U4e=()=>{var le,Fe,ze,Re,De,Et,jt;const{soName:e}=hs(),[r]=_a(),a=hr(),s=e==="new",n=r.get("project")||"",i=r.get("customer")||"",o=r.get("company")||un,l=r.get("project")||"",[c,u]=p.useState(null),[h,f]=p.useState(!s),[y,b]=p.useState(!1),[w,v]=p.useState(!1),[k,S]=p.useState(s),[N,C]=p.useState(null),[O,T]=p.useState(null),P=p.useRef(null),E=new Date().toISOString().split("T")[0],[R,z]=p.useState({customer:i,customer_name:i,company:o,project:n,transaction_date:E,currency:Er,order_type:"Sales",taxes_and_charges:Fp,items:[],taxes:[]}),G=p.useCallback(Ie=>{z({customer:Ie.customer||"",customer_name:Ie.customer_name||Ie.customer||"",company:Ie.company||un,project:Ie.project||l||"",transaction_date:Ie.transaction_date||E,currency:Ie.currency==="INR"?Er:Ie.currency||Er,order_type:Ie.order_type||"Sales",cost_center:Ie.cost_center||"",selling_price_list:Ie.selling_price_list||"",price_list_currency:Ie.price_list_currency||"",conversion_rate:Ie.conversion_rate||1,plc_conversion_rate:Ie.plc_conversion_rate||1,tax_category:Ie.tax_category||"",taxes_and_charges:Ie.taxes_and_charges||"",items:Ie.items||[],taxes:Ie.taxes||[]}),C(null),T(null)},[l,E]);p.useEffect(()=>{s||(f(!0),Io.getSalesOrder(e).then(Ie=>{u(Ie),G(Ie)}).catch(Ie=>We.error(ti(Ie))).finally(()=>f(!1)))},[e,s,G]);const[ae,ee]=p.useState(!1);p.useEffect(()=>{l&&z(Ie=>je(se({},Ie),{project:Ie.project||l}))},[l]),p.useEffect(()=>{!l||s||!c||ae||c.docstatus!==0||String(c.project||"").trim()||(ee(!0),Io.updateSalesOrder(e,{project:l}).then($e=>{u($e),G($e)}).catch($e=>We.error(ti($e))))},[c,ae,l,s,e,G]),p.useEffect(()=>{const Ie=R.company;!s||!Ie||fetch(`/api/resource/Company/${encodeURIComponent(Ie)}`,{credentials:"include"}).then($e=>$e.json()).then($e=>{var Qe;if((Qe=$e.data)!=null&&Qe.default_currency){const at=Xn($e.data.default_currency);z(Ct=>je(se({},Ct),{currency:at,selling_price_list:Ct.selling_price_list||"Standard Selling",price_list_currency:Ct.price_list_currency||at}))}}).catch(()=>{})},[R.company,s]);const ne=(Ie,$e)=>z(Qe=>je(se({},Qe),{[Ie]:$e})),te=p.useCallback(()=>{const Ie=R.project;if(Ie&&String(Ie).trim()){a(`/projects/list/${encodeURIComponent(String(Ie))}`);return}const $e=new URLSearchParams;!s&&e&&$e.set("source_so",String(e)),R.customer&&$e.set("customer",String(R.customer)),R.company&&$e.set("company",String(R.company)),a(`/projects/list/new?${$e.toString()}`)},[R,s,a,e]),Y=(Ie,$e,Qe)=>z(at=>{const Ct=[...at.items||[]],vt=je(se({},Ct[Ie]),{[$e]:Qe});if($e==="qty"||$e==="rate"){const er=parseFloat(String($e==="qty"?Qe:vt.qty))||0,nr=parseFloat(String($e==="rate"?Qe:vt.rate))||0;vt.amount=parseFloat((er*nr).toFixed(4))}return Ct[Ie]=vt,je(se({},at),{items:Ct})}),q=(Ie,$e)=>J(null,null,function*(){if(Y(Ie,"item_code",$e),!!$e)try{const Ct=(yield(yield fetch(`/api/resource/Item/${encodeURIComponent($e)}`,{credentials:"include"})).json()).data;if(!Ct)return;z(vt=>{var nr;const er=[...vt.items||[]];return er[Ie]=je(se({},er[Ie]),{item_code:$e,item_name:Ct.item_name||$e,description:Ct.description||Ct.item_name||$e,stock_uom:Ct.stock_uom||"",uom:Ct.sales_uom||Ct.stock_uom||"",price_list_rate:(nr=Ct.standard_rate)!=null?nr:0,rate:er[Ie].rate||Ct.standard_rate||0}),je(se({},vt),{items:er})})}catch(Qe){}}),H=Ie=>{z($e=>{const Qe=[...$e.items||[]],at=z4e();let Ct;return Ie!==void 0?(Qe.splice(Ie+1,0,at),Ct=Ie+1):(Qe.push(at),Ct=Qe.length-1),setTimeout(()=>C(Ct),0),je(se({},$e),{items:Qe})})},U=Ie=>{z($e=>{const Qe=[...$e.items||[]];return Qe.splice(Ie,1),je(se({},$e),{items:Qe})}),C(null)},re=(Ie,$e,Qe)=>z(at=>{const Ct=[...at.taxes||[]];return Ct[Ie]=je(se({},Ct[Ie]),{[$e]:Qe}),je(se({},at),{taxes:Ct})}),X=Ie=>{z($e=>{const Qe=[...$e.taxes||[]],at=$4e();let Ct;return Ie!==void 0?(Qe.splice(Ie+1,0,at),Ct=Ie+1):(Qe.push(at),Ct=Qe.length-1),setTimeout(()=>T(Ct),0),je(se({},$e),{taxes:Qe})})},V=Ie=>{z($e=>{const Qe=[...$e.taxes||[]];return Qe.splice(Ie,1),je(se({},$e),{taxes:Qe})}),T(null)},I=(R.items||[]).reduce((Ie,$e)=>Ie+($e.qty||0)*($e.rate||0),0),Q=((Ie,$e)=>{let Qe=$e;return Ie.map(at=>{const Ct=Ql(at);let vt=0;return at.charge_type==="On Net Total"?vt=$e*(Ct/100):at.charge_type==="Actual"?vt=at.tax_amount||0:at.charge_type==="On Previous Row Amount"||at.charge_type==="On Previous Row Total"?vt=Qe*(Ct/100):vt=$e*(Ct/100),Qe+=vt,je(se({},at),{_computed_amt:vt,_computed_total:Qe})})})(R.taxes||[],I),ie=Q.reduce((Ie,$e)=>Ie+$e._computed_amt,0),me=I+ie,he=Ie=>J(null,null,function*(){var $e;if(Ie)try{const Ct=(yield(yield fetch(`/api/resource/Sales Taxes and Charges Template/${encodeURIComponent(Ie)}`,{credentials:"include"})).json()).data;($e=Ct==null?void 0:Ct.taxes)!=null&&$e.length&&z(vt=>je(se({},vt),{taxes:Ct.taxes.map(er=>{var nr,dt,He;return{charge_type:er.charge_type,account_head:er.account_head,description:er.description,tax_rate:(dt=(nr=er.rate)!=null?nr:er.tax_rate)!=null?dt:0,cost_center:er.cost_center,account_currency:er.account_currency,included_in_print_rate:(He=er.included_in_print_rate)!=null?He:0}})}))}catch(Qe){}});p.useEffect(()=>{s&&he(Fp)},[s]);const de=()=>({customer:R.customer,company:R.company||void 0,project:R.project||void 0,cost_center:R.cost_center||void 0,transaction_date:R.transaction_date,currency:R.currency||void 0,order_type:R.order_type||"Sales",selling_price_list:R.selling_price_list||"Standard Selling",price_list_currency:R.price_list_currency||R.currency||void 0,conversion_rate:R.conversion_rate||1,plc_conversion_rate:R.plc_conversion_rate||1,tax_category:R.tax_category||void 0,taxes_and_charges:R.taxes_and_charges||void 0,items:(R.items||[]).filter(Ie=>Ie.item_code).map((Ie,$e)=>{var Qe,at,Ct,vt,er,nr,dt,He,it;return{item_code:Ie.item_code,item_name:Ie.item_name||Ie.item_code,description:Ie.description||Ie.item_name||Ie.item_code,qty:(Qe=Ie.qty)!=null?Qe:1,uom:Ie.uom||void 0,stock_uom:Ie.stock_uom||void 0,conversion_factor:(at=Ie.conversion_factor)!=null?at:1,rate:(Ct=Ie.rate)!=null?Ct:0,amount:(Ie.qty||0)*(Ie.rate||0),price_list_rate:(vt=Ie.price_list_rate)!=null?vt:0,delivery_date:Ie.delivery_date||void 0,item_tax_template:Ie.item_tax_template||void 0,is_free_item:(er=Ie.is_free_item)!=null?er:0,grant_commission:(nr=Ie.grant_commission)!=null?nr:0,delivered_by_supplier:(dt=Ie.delivered_by_supplier)!=null?dt:0,supplier:Ie.supplier||void 0,weight_per_unit:Ie.weight_per_unit||void 0,weight_uom:Ie.weight_uom||void 0,delivery_warehouse:Ie.delivery_warehouse||void 0,against_blanket_order:(He=Ie.against_blanket_order)!=null?He:0,ensure_delivery_based_on_produced_serial_no:(it=Ie.ensure_delivery_based_on_produced_serial_no)!=null?it:0,bom_no:Ie.bom_no||void 0,project:R.project||void 0,cost_center:R.cost_center||void 0,idx:$e+1}}),taxes:(R.taxes||[]).filter(Ie=>Ie.charge_type).map((Ie,$e)=>{var Qe;return{charge_type:Ie.charge_type,account_head:Ie.account_head||void 0,description:Ie.description||void 0,included_in_print_rate:(Qe=Ie.included_in_print_rate)!=null?Qe:0,cost_center:Ie.cost_center||void 0,rate:Ql(Ie),account_currency:Ie.account_currency||Er,idx:$e+1}})}),xe=()=>J(null,null,function*(){if(!R.customer){We.error("Customer is required");return}try{if(b(!0),s){const Ie=yield Io.createSalesOrder(de());We.success("Sales Order created"),S(!1),a(`/sales-orders/${Ie.name}`)}else{const Ie=yield Io.updateSalesOrder(e,de());u(Ie),G(Ie),We.success("Sales Order saved"),S(!1)}}catch(Ie){We.error(ti(Ie)||"Error saving")}finally{b(!1)}}),ge=()=>J(null,null,function*(){if(!(!e||s))try{v(!0);const Ie=yield Io.submitSalesOrder(e);u(Ie),G(Ie),We.success("Sales Order submitted")}catch(Ie){We.error(ti(Ie)||"Error submitting")}finally{v(!1)}}),be=()=>{const Ie=new URLSearchParams;return R.customer&&Ie.set("customer",R.customer),R.company&&Ie.set("company",String(R.company||"")),R.project&&Ie.set("project",String(R.project||"")),Ie},K=()=>{const Ie=be();Ie.set("so",e),a(`/delivery-notes/new?${Ie.toString()}`)},ye=()=>{const Ie=be();Ie.set("so",e),a(`/invoices/new?${Ie.toString()}`)},Z=()=>{const Ie=new URLSearchParams;R.project&&Ie.set("project",String(R.project)),R.company&&Ie.set("company",String(R.company||"")),a(`/material-requests/new?${Ie.toString()}`)},M=s||k,we=!s&&(c==null?void 0:c.docstatus)===1,pe=s?"New Sales Order":R.customer_name||e||"";return h?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsx(tr,{className:"animate-spin text-blue-500 text-3xl"})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 px-6 py-6",children:[t.jsx($a,{position:"top-right",autoClose:3500}),t.jsxs("div",{className:"flex items-center gap-2 text-sm mb-6 text-gray-500",children:[t.jsx("button",{type:"button",onClick:()=>a("/projects"),className:"hover:text-blue-600",children:"Project Management"}),t.jsx("span",{children:"/"}),t.jsx("button",{type:"button",onClick:()=>a("/sales-orders"),className:"hover:text-blue-600",children:"Sales Orders"}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:s?"New Sales Order":e})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 dark:border-gray-700 flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>a("/sales-orders"),className:"text-gray-400 hover:text-gray-700",children:t.jsx(ia,{})}),t.jsx(dm,{className:"text-blue-500"}),t.jsx("div",{children:t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:pe}),!s&&e&&t.jsx("span",{className:"text-xs text-gray-400 font-mono",children:e}),!s&&t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${(()=>{const Ie=(c==null?void 0:c.status)||"";return(c==null?void 0:c.docstatus)===2||Ie==="Cancelled"?"bg-red-100 text-red-700":!c||c.docstatus===0?"bg-yellow-100 text-yellow-800":Ie==="Completed"?"bg-green-100 text-green-800":Ie==="To Deliver and Bill"||Ie==="To Bill"||Ie==="To Deliver"?"bg-blue-100 text-blue-800":Ie==="On Hold"?"bg-orange-100 text-orange-800":Ie==="Closed"?"bg-gray-100 text-gray-700":"bg-green-100 text-green-800"})()}`,children:(c==null?void 0:c.docstatus)===2?"Cancelled":(c==null?void 0:c.docstatus)===0?"Draft":(c==null?void 0:c.status)||"Submitted"}),R.project&&t.jsx("button",{type:"button",onClick:()=>a(`/projects/list/${encodeURIComponent(String(R.project))}`),className:"text-xs text-blue-700 dark:text-blue-400 border border-blue-200 dark:border-blue-700 rounded-full px-2.5 py-0.5 hover:underline",children:R.project})]})})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("button",{type:"button",onClick:te,title:R.project?"Open linked project":"Link a project (scrolls to Project field)",className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 text-sm font-medium shadow-sm",children:[t.jsx(Rr,{size:10}),t.jsx(gp,{size:13}),"Project"]}),we&&t.jsx(L4e,{items:[{label:"Delivery Note",icon:t.jsx(G1,{size:13}),onClick:K},{label:"Sales Invoice",icon:t.jsx(xm,{size:13}),onClick:ye},{label:"Material Request",icon:t.jsx(zd,{size:13}),onClick:Z}]}),!s&&!k&&(c==null?void 0:c.docstatus)===0&&t.jsxs("button",{onClick:ge,disabled:w,className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 text-sm font-medium",children:[w?t.jsx(tr,{className:"animate-spin"}):t.jsx(Lm,{size:12})," Submit"]}),!s&&!k&&!we&&t.jsxs("button",{type:"button",onClick:()=>S(!0),className:"flex items-center gap-2 px-4 py-2 border border-blue-500 text-blue-600 rounded-lg hover:bg-blue-50 text-sm",children:[t.jsx(qr,{})," Edit"]}),M&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:xe,disabled:y,className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 text-sm font-medium",children:[y?t.jsx(tr,{className:"animate-spin"}):t.jsx(ta,{}),y?"Saving…":"Save"]}),!s&&t.jsx("button",{onClick:()=>{c&&G(c),S(!1)},className:"px-3 py-2 border border-gray-300 rounded-lg text-gray-600 text-sm",children:t.jsx(ht,{})})]})]})]}),t.jsx("div",{className:"px-6 pt-5 pb-4",children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-4",children:[t.jsxs("div",{children:[t.jsx(Qr,{required:!0,children:"Customer"}),M?t.jsx(Je,{label:"Customer",hideLabel:!0,doctype:"Customer",value:R.customer||"",onChange:Ie=>{ne("customer",Ie),ne("customer_name",Ie)},placeholder:"Select customer…"}):t.jsx(Hl,{children:R.customer})]}),t.jsxs("div",{children:[t.jsx(Qr,{required:!0,children:"Transaction Date"}),M?t.jsx("input",{type:"date",value:R.transaction_date||"",onChange:Ie=>ne("transaction_date",Ie.target.value),className:Zl}):t.jsx(Hl,{children:R.transaction_date})]}),t.jsxs("div",{children:[t.jsx(Qr,{children:"Company"}),M?t.jsx(Je,{label:"Company",hideLabel:!0,doctype:"Company",value:R.company||"",onChange:Ie=>ne("company",Ie),placeholder:"Select company…"}):t.jsx(Hl,{children:R.company})]}),t.jsxs("div",{ref:P,className:"scroll-mt-28",children:[t.jsx(Qr,{children:"Project"}),t.jsx(Hl,{children:R.project?t.jsx("button",{type:"button",onClick:()=>a(`/projects/list/${encodeURIComponent(String(R.project))}`),className:"text-blue-700 hover:underline font-medium",title:"Open project",children:R.project}):t.jsx("button",{type:"button",onClick:te,className:"text-blue-700 hover:underline font-medium",title:"Create / link a project",children:"—"})})]}),t.jsxs("div",{children:[t.jsx(Qr,{children:"Currency"}),M?t.jsxs("select",{value:R.currency||Er,onChange:Ie=>ne("currency",Ie.target.value),className:Zl,children:[t.jsx("option",{value:"SAR",children:"SAR"}),t.jsx("option",{value:"USD",children:"USD"}),t.jsx("option",{value:"EUR",children:"EUR"})]}):t.jsx(Hl,{children:R.currency})]}),t.jsxs("div",{children:[t.jsx(Qr,{children:"Cost Center"}),M?t.jsx(Je,{label:"Cost Center",hideLabel:!0,doctype:"Cost Center",value:R.cost_center||"",onChange:Ie=>ne("cost_center",Ie),placeholder:"Cost center…"}):t.jsx(Hl,{children:R.cost_center})]})]})}),t.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700",children:[t.jsx("div",{className:"px-6 py-3 bg-gray-50 dark:bg-gray-900/20 border-b border-gray-100 dark:border-gray-700",children:t.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Items"})}),t.jsxs("div",{className:"px-6 pb-5",children:[t.jsx("div",{className:"overflow-x-auto -mx-2 mt-3",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-8",children:"No."}),t.jsxs("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 min-w-[180px]",children:["Item Code ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsxs("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-32",children:["Delivery Date ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsxs("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-24",children:["Quantity ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsxs("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:["Rate (",Xn(R.currency),")"]}),t.jsxs("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:["Amount (",Xn(R.currency),")"]}),M&&t.jsx("th",{className:"w-16 py-2 px-2"})]})}),t.jsxs("tbody",{children:[(R.items||[]).map((Ie,$e)=>{var Qe,at,Ct,vt;return t.jsxs(gr.Fragment,{children:[t.jsxs("tr",{className:`border-b border-gray-100 dark:border-gray-700 align-middle ${N===$e?"bg-blue-50/60 dark:bg-blue-900/10":""}`,children:[t.jsx("td",{className:"py-1.5 px-3 text-gray-400 text-xs",children:$e+1}),t.jsx("td",{className:"py-1.5 px-2 min-w-[180px]",children:M?t.jsx(Je,{label:"Item",hideLabel:!0,doctype:"Item",value:Ie.item_code||"",onChange:er=>q($e,er),placeholder:"Item Code"}):t.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-200",children:Ie.item_code||"-"})}),t.jsx("td",{className:"py-1.5 px-2 w-32",children:M?t.jsx("input",{type:"date",value:Ie.delivery_date||"",onChange:er=>Y($e,"delivery_date",er.target.value),className:t9}):t.jsx("span",{className:"text-gray-500 text-sm",children:Ie.delivery_date||"-"})}),t.jsx("td",{className:"py-1.5 px-2 w-24",children:M?t.jsx("input",{type:"number",min:0,step:"1",value:(Qe=Ie.qty)!=null?Qe:0,onChange:er=>Y($e,"qty",parseFloat(er.target.value)||0),className:lN}):t.jsx("span",{className:"block text-right text-gray-700 dark:text-gray-300 text-sm pr-1",children:(at=Ie.qty)!=null?at:0})}),t.jsx("td",{className:"py-1.5 px-2 w-28",children:M?t.jsx("input",{type:"number",min:0,step:"0.01",value:(Ct=Ie.rate)!=null?Ct:0,onChange:er=>Y($e,"rate",parseFloat(er.target.value)||0),className:lN}):t.jsx("span",{className:"block text-right text-gray-700 dark:text-gray-300 text-sm pr-1",children:((vt=Ie.rate)!=null?vt:0).toFixed(2)})}),t.jsx("td",{className:"py-1.5 px-3 text-right font-semibold text-gray-900 dark:text-white text-sm",children:((Ie.qty||0)*(Ie.rate||0)).toFixed(2)}),M&&t.jsx("td",{className:"py-1.5 px-2",children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>C(N===$e?null:$e),className:`p-1.5 rounded text-xs ${N===$e?"bg-blue-600 text-white":"text-blue-600 hover:bg-blue-50"}`,title:"More fields",children:t.jsx(xl,{size:11})}),t.jsx("button",{onClick:()=>U($e),className:"p-1.5 text-red-400 hover:text-red-600 hover:bg-red-50 rounded",children:t.jsx(wr,{size:11})})]})})]}),M&&N===$e&&t.jsx(F4e,{item:Ie,rowNo:$e+1,onChange:(er,nr)=>{er==="item_code"?q($e,nr):Y($e,er,nr)},onClose:()=>C(null),onDelete:()=>U($e),onInsertBelow:()=>H($e)})]},$e)}),M&&t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"py-2 px-3",children:t.jsxs("button",{type:"button",onClick:()=>H(),className:"flex items-center gap-1.5 text-blue-600 hover:text-blue-700 text-sm font-medium",children:[t.jsx(Rr,{size:10})," Add Row"]})})})]})]})}),t.jsxs("div",{className:"mt-3 flex justify-between text-sm border-t border-gray-100 dark:border-gray-700 pt-3",children:[t.jsxs("span",{className:"text-gray-500",children:["Total Qty: ",t.jsx("strong",{children:(R.items||[]).reduce((Ie,$e)=>Ie+($e.qty||0),0)})]}),t.jsxs("span",{className:"text-gray-500",children:["Total: ",t.jsxs("strong",{className:"text-gray-900 dark:text-white",children:[Xn(R.currency)," ",I.toFixed(2)]})]})]})]})]}),t.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700",children:[t.jsx("div",{className:"px-6 py-3 bg-gray-50 dark:bg-gray-900/20 border-b border-gray-100 dark:border-gray-700",children:t.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Taxes"})}),t.jsxs("div",{className:"px-6 pt-4 pb-2 grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-3",children:[t.jsxs("div",{children:[t.jsx(Qr,{children:"Tax Category"}),M?t.jsx(Je,{label:"Tax Category",hideLabel:!0,doctype:"Tax Category",value:R.tax_category||"",onChange:Ie=>ne("tax_category",Ie),placeholder:"Select tax category…"}):t.jsx(Hl,{children:R.tax_category})]}),t.jsxs("div",{children:[t.jsx(Qr,{children:"Sales Taxes and Charges Template"}),M?t.jsx(Je,{label:"Sales Taxes and Charges Template",hideLabel:!0,doctype:"Sales Taxes and Charges Template",value:R.taxes_and_charges||"",onChange:Ie=>{ne("taxes_and_charges",Ie),he(Ie)},placeholder:"Select template…"}):t.jsx(Hl,{children:R.taxes_and_charges})]})]}),t.jsxs("div",{className:"px-6 pb-5",children:[t.jsx("div",{className:"overflow-x-auto -mx-2 mt-3",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-8",children:"No."}),t.jsxs("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-44",children:["Type ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsxs("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3",children:["Account Head ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-24",children:"Tax Rate"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:"Amount"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:"Total"}),M&&t.jsx("th",{className:"w-16 py-2 px-2"})]})}),t.jsxs("tbody",{children:[Q.map((Ie,$e)=>{var Qe,at;return t.jsxs(gr.Fragment,{children:[t.jsxs("tr",{className:`border-b border-gray-100 dark:border-gray-700 align-middle ${O===$e?"bg-blue-50/60 dark:bg-blue-900/10":""}`,children:[t.jsx("td",{className:"py-1.5 px-3 text-gray-400 text-xs",children:$e+1}),t.jsx("td",{className:"py-1.5 px-2 w-44",children:M?t.jsxs("select",{value:Ie.charge_type||"",onChange:Ct=>re($e,"charge_type",Ct.target.value),className:t9,children:[t.jsx("option",{value:"",children:"Select type…"}),t.jsx("option",{value:"Actual",children:"Actual"}),t.jsx("option",{value:"On Net Total",children:"On Net Total"}),t.jsx("option",{value:"On Previous Row Amount",children:"On Previous Row Amount"}),t.jsx("option",{value:"On Previous Row Total",children:"On Previous Row Total"}),t.jsx("option",{value:"On Item Quantity",children:"On Item Quantity"}),t.jsx("option",{value:"Inter Company Transaction",children:"Inter Company Transaction"})]}):t.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:Ie.charge_type||"-"})}),t.jsx("td",{className:"py-1.5 px-2",children:M?t.jsx(Je,{label:"Account Head",hideLabel:!0,doctype:"Account",value:Ie.account_head||"",onChange:Ct=>re($e,"account_head",Ct),placeholder:"Account Head"}):t.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:Ie.account_head||"-"})}),t.jsx("td",{className:"py-1.5 px-2 w-24",children:M?t.jsx("input",{type:"number",min:0,step:"0.01",value:Ql(Ie),onChange:Ct=>re($e,"tax_rate",parseFloat(Ct.target.value)||0),className:lN}):t.jsx("span",{className:"block text-right text-gray-700 dark:text-gray-300 pr-1",children:Ql(Ie)})}),t.jsx("td",{className:"py-1.5 px-3 text-right text-gray-700 dark:text-gray-300 text-sm",children:((Qe=Ie._computed_amt)!=null?Qe:0).toFixed(2)}),t.jsx("td",{className:"py-1.5 px-3 text-right font-semibold text-gray-900 dark:text-white text-sm",children:((at=Ie._computed_total)!=null?at:0).toFixed(2)}),M&&t.jsx("td",{className:"py-1.5 px-2",children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>T(O===$e?null:$e),className:`p-1.5 rounded text-xs ${O===$e?"bg-blue-600 text-white":"text-blue-600 hover:bg-blue-50"}`,title:"More fields",children:t.jsx(xl,{size:11})}),t.jsx("button",{onClick:()=>V($e),className:"p-1.5 text-red-400 hover:text-red-600 hover:bg-red-50 rounded",children:t.jsx(wr,{size:11})})]})})]}),M&&O===$e&&t.jsx(I4e,{tax:Ie,rowNo:$e+1,onChange:(Ct,vt)=>re($e,Ct,vt),onClose:()=>T(null),onDelete:()=>V($e),onInsertBelow:()=>X($e)})]},$e)}),M&&t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"py-2 px-3",children:t.jsxs("button",{type:"button",onClick:()=>X(),className:"flex items-center gap-1.5 text-blue-600 hover:text-blue-700 text-sm font-medium",children:[t.jsx(Rr,{size:10})," Add Row"]})})})]})]})}),(R.taxes||[]).length>0&&t.jsxs("div",{className:"mt-2 flex justify-end text-sm text-gray-500 pt-2 border-t border-gray-100 dark:border-gray-700",children:["Total Taxes and Charges:"," ",t.jsxs("strong",{className:"ml-2 text-gray-900 dark:text-white",children:[Xn(R.currency)," ",((le=c==null?void 0:c.total_taxes_and_charges)!=null?le:ie).toFixed(2)]})]})]})]}),t.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700 px-6 py-4",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"Totals"}),t.jsx("div",{className:"space-y-2 max-w-xs ml-auto",children:[{label:"Net Total",value:((Fe=c==null?void 0:c.net_total)!=null?Fe:I).toFixed(2)},{label:"Total Taxes",value:((ze=c==null?void 0:c.total_taxes_and_charges)!=null?ze:ie).toFixed(2)},{label:"Grand Total",value:((Re=c==null?void 0:c.grand_total)!=null?Re:me).toFixed(2)},{label:"Rounding Adjustment",value:((De=c==null?void 0:c.rounding_adjustment)!=null?De:0).toFixed(2)},{label:"Rounded Total",value:((Et=c==null?void 0:c.rounded_total)!=null?Et:me).toFixed(2)},{label:"Advance Paid",value:((jt=c==null?void 0:c.advance_paid)!=null?jt:0).toFixed(2)}].map(({label:Ie,value:$e})=>t.jsxs("div",{className:"flex justify-between text-sm border-b border-gray-100 dark:border-gray-700 pb-1.5 last:border-0",children:[t.jsx("span",{className:"text-gray-500",children:Ie}),t.jsxs("span",{className:"font-semibold text-gray-900 dark:text-white",children:[Xn(R.currency)," ",$e]})]},Ie))})]}),!s&&c&&t.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700 px-6 py-4 grid grid-cols-3 gap-4 text-sm bg-gray-50 dark:bg-gray-900/20",children:[t.jsxs("div",{children:[t.jsx(Qr,{children:"Created By"}),t.jsx(Hl,{children:c.owner})]}),t.jsxs("div",{children:[t.jsx(Qr,{children:"Created"}),t.jsx(Hl,{children:c.creation?new Date(c.creation).toLocaleString():"-"})]}),t.jsxs("div",{children:[t.jsx(Qr,{children:"Modified"}),t.jsx(Hl,{children:c.modified?new Date(c.modified).toLocaleString():"-"})]})]}),!s&&t.jsx(vi,{doctype:"Sales Order",docname:(c==null?void 0:c.name)||e||"",creationDate:c==null?void 0:c.creation,createdBy:c==null?void 0:c.owner,compact:!1,initialVisible:5,collapsible:!0,startCollapsed:!0})]})]})},U0=20;function B4e(e){return e.docstatus===2?"bg-red-100 text-red-700":e.docstatus===1?e.status==="Completed"?"bg-green-100 text-green-700":e.status==="Stopped"?"bg-red-100 text-red-700":"bg-green-100 text-green-700":"bg-yellow-100 text-yellow-800"}function W4e(e){return e.docstatus===2?"Cancelled":e.docstatus===1?e.status||"Submitted":"Draft"}function r9(e){const r=[];return e.search&&r.push(["Purchase Order","name","like",`%${e.search}%`]),e.status==="Draft"&&r.push(["Purchase Order","docstatus","=",0]),e.status==="Submitted"&&r.push(["Purchase Order","docstatus","=",1]),e.status==="Cancelled"&&r.push(["Purchase Order","docstatus","=",2]),e.status==="Completed"&&r.push(["Purchase Order","status","=","Completed"]),r}const H4e=()=>{const{t:e}=sr(),r=hr(),[a,s]=p.useState([]),[n,i]=p.useState(!0),[o,l]=p.useState(0),[c,u]=p.useState(0),[h,f]=p.useState(!1),[y,b]=p.useState(""),[w,v]=p.useState(""),[k,S]=p.useState({search:"",status:""}),[N,C]=p.useState(!1),O=p.useCallback((q,H)=>J(null,null,function*(){i(!0);try{const U=r9(H),[re,X]=yield Promise.all([sm.getPurchaseOrders({filters:U,limit_start:q,limit_page_length:U0}),sm.getPurchaseOrderCount(U)]);s(re),l(X)}catch(U){We.error(U.message||"Failed to load")}finally{i(!1)}}),[]);p.useEffect(()=>{O(0,k)},[O,k]);const T=p.useMemo(()=>`${c}|${k.search}|${k.status}`,[c,k.search,k.status]),{selectedRows:P,toggleRow:E,toggleAllOnPage:R,allOnPageSelected:z,someOnPageSelected:G}=po(a,T),ae=()=>{S({search:y,status:w}),u(0)},ee=()=>{b(""),v(""),S({search:"",status:""}),u(0)},ne=!!(k.search||k.status),te=q=>{u(q),O(q*U0,k)},Y=p.useCallback(()=>go({doctype:"Purchase Order",filters:r9(k),orderBy:"modified desc"}),[k]);return t.jsxs("div",{className:"p-6",children:[t.jsx($a,{position:"top-right",autoClose:3e3}),t.jsxs("div",{className:"flex items-center justify-between mb-6 gap-4 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl bg-amber-500 flex items-center justify-center",children:t.jsx(eS,{className:"text-white text-base"})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:"Purchase Orders"}),t.jsxs("p",{className:"text-xs text-gray-500",children:[o," total"]})]})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("button",{onClick:()=>O(c*U0,k),className:"p-2 text-gray-500 hover:text-amber-600 border border-gray-200 rounded-lg",children:t.jsx(Ma,{size:13})}),t.jsxs("button",{type:"button",onClick:()=>C(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all text-sm font-medium disabled:opacity-50",disabled:o===0&&P.size===0,children:[t.jsx(Sa,{})," ",e("listPages.export"),P.size>0&&t.jsx("span",{className:"bg-white/25 px-1.5 py-0.5 rounded text-xs font-bold",children:P.size})]}),t.jsxs("button",{onClick:()=>r("/purchase-orders/new"),className:"flex items-center gap-2 px-4 py-2 bg-amber-500 text-white rounded-lg hover:bg-amber-600 text-sm font-medium",children:[t.jsx(Rr,{size:11})," New Purchase Order"]})]})]}),t.jsx(bi,{isOpen:N,onClose:()=>C(!1),doctype:"Purchase Order",selectedCount:P.size,pageCount:a.length,totalCount:o,pageData:a,selectedRows:P,rowKey:"name",onFetchAll:Y,fileNamePrefix:"purchase_orders"}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl mb-5 overflow-hidden",children:[t.jsxs("button",{onClick:()=>f(q=>!q),className:"w-full flex items-center justify-between px-4 py-3 bg-gradient-to-r from-indigo-600 to-indigo-700 text-white",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[t.jsx(za,{size:12})," Filters",ne&&t.jsx("span",{className:"bg-white/30 text-white text-xs px-2 py-0.5 rounded-full",children:"Active"})]}),h?t.jsx(Ja,{size:11}):t.jsx(Fr,{size:11})]}),ne&&t.jsxs("div",{className:"px-4 py-2 bg-indigo-50 dark:bg-indigo-900/20 flex flex-wrap gap-2 items-center border-b border-indigo-100 dark:border-indigo-800",children:[k.search&&t.jsxs("span",{className:"flex items-center gap-1 text-xs bg-indigo-100 dark:bg-indigo-800 text-indigo-700 dark:text-indigo-300 px-2 py-1 rounded-full",children:["ID: ",k.search,t.jsx("button",{onClick:()=>{b(""),S(q=>je(se({},q),{search:""}))},children:t.jsx(ht,{size:9})})]}),k.status&&t.jsxs("span",{className:"flex items-center gap-1 text-xs bg-indigo-100 dark:bg-indigo-800 text-indigo-700 dark:text-indigo-300 px-2 py-1 rounded-full",children:["Status: ",k.status,t.jsx("button",{onClick:()=>{v(""),S(q=>je(se({},q),{status:""}))},children:t.jsx(ht,{size:9})})]}),t.jsx("button",{onClick:ee,className:"text-xs text-indigo-600 hover:underline ml-auto",children:"Clear All"})]}),h&&t.jsxs("div",{className:"px-4 py-3 grid grid-cols-1 sm:grid-cols-3 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[11px] font-semibold text-gray-500 uppercase tracking-wide mb-1",children:"Order ID"}),t.jsx("input",{value:y,onChange:q=>b(q.target.value),onKeyDown:q=>q.key==="Enter"&&ae(),placeholder:"Search…",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-400"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[11px] font-semibold text-gray-500 uppercase tracking-wide mb-1",children:"Status"}),t.jsxs("select",{value:w,onChange:q=>v(q.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-400",children:[t.jsx("option",{value:"",children:"All"}),t.jsx("option",{value:"Draft",children:"Draft"}),t.jsx("option",{value:"Submitted",children:"Submitted"}),t.jsx("option",{value:"Cancelled",children:"Cancelled"}),t.jsx("option",{value:"Completed",children:"Completed"})]})]}),t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsx("button",{onClick:ae,className:"px-4 py-2 bg-indigo-600 text-white text-sm rounded hover:bg-indigo-700",children:"Apply"}),t.jsx("button",{onClick:ee,className:"px-4 py-2 border border-gray-300 text-gray-600 text-sm rounded hover:bg-gray-50",children:"Clear"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl overflow-hidden",children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx("th",{className:"w-10 px-2 py-3",children:t.jsx("input",{type:"checkbox",className:"rounded border-gray-300 dark:border-gray-600 text-amber-600 focus:ring-amber-500",checked:z,ref:q=>{q&&(q.indeterminate=G)},onChange:R,"aria-label":"Select all on page"})}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"PO ID"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Supplier"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Transaction Date"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Schedule Date"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Status"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Grand Total"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Company"})]})}),t.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:n?t.jsx("tr",{children:t.jsx("td",{colSpan:8,className:"text-center py-10 text-gray-400",children:"Loading…"})}):a.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:8,className:"text-center py-10 text-gray-400",children:"No purchase orders found"})}):a.map(q=>{var H;return t.jsxs("tr",{onClick:()=>r(`/purchase-orders/${q.name}`),className:`cursor-pointer hover:bg-amber-50 dark:hover:bg-amber-900/10 transition-colors ${P.has(q.name)?"bg-amber-50/90 dark:bg-amber-900/20":""}`,children:[t.jsx("td",{className:"w-10 px-2 py-3",onClick:U=>U.stopPropagation(),children:t.jsx("input",{type:"checkbox",className:"rounded border-gray-300 dark:border-gray-600 text-amber-600 focus:ring-amber-500",checked:P.has(q.name),onChange:()=>E(q.name),"aria-label":`Select ${q.name}`})}),t.jsx("td",{className:"py-3 px-4 font-medium text-amber-600",children:q.name}),t.jsx("td",{className:"py-3 px-4 text-gray-700 dark:text-gray-300",children:q.supplier_name||q.supplier||"-"}),t.jsx("td",{className:"py-3 px-4 text-gray-500",children:q.transaction_date||"-"}),t.jsx("td",{className:"py-3 px-4 text-gray-500",children:q.schedule_date||"-"}),t.jsx("td",{className:"py-3 px-4",children:t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${B4e(q)}`,children:W4e(q)})}),t.jsx("td",{className:"py-3 px-4 text-right font-semibold text-gray-900 dark:text-white",children:((H=q.grand_total)!=null?H:0).toFixed(2)}),t.jsx("td",{className:"py-3 px-4 text-gray-500",children:q.company||"-"})]},q.name)})})]})}),o>U0&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-100 dark:border-gray-700",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:[c*U0+1,"–",Math.min((c+1)*U0,o)," of ",o]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:c===0,onClick:()=>te(c-1),className:"px-3 py-1 text-xs border border-gray-300 rounded disabled:opacity-40",children:"Prev"}),t.jsx("button",{disabled:(c+1)*U0>=o,onClick:()=>te(c+1),className:"px-3 py-1 text-xs border border-gray-300 rounded disabled:opacity-40",children:"Next"})]})]})]})]})},sa=({children:e,required:r})=>t.jsxs("label",{className:"block text-[11px] font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1",children:[e,r&&t.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),to=({children:e})=>t.jsx("div",{className:"px-3 py-2 text-sm text-gray-800 dark:text-gray-200 bg-gray-50 dark:bg-gray-800/60 rounded min-h-[34px] flex items-center",children:e||t.jsx("span",{className:"text-gray-400",children:"-"})}),Ic="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-amber-400",ip=Ic+" text-right",cN="w-full px-2 py-1 text-sm text-right border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-amber-400",a9="w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-amber-400",q4e=({items:e})=>{const[r,a]=p.useState(!1),s=p.useRef(null);return p.useEffect(()=>{const n=i=>{s.current&&!s.current.contains(i.target)&&a(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[]),t.jsxs("div",{className:"relative",ref:s,children:[t.jsxs("button",{onClick:()=>a(n=>!n),className:"flex items-center gap-1.5 px-4 py-2 bg-amber-500 text-white rounded-lg hover:bg-amber-600 text-sm font-medium shadow-sm",children:["Create",t.jsx(Fr,{size:10,className:`transition-transform ${r?"rotate-180":""}`})]}),r&&t.jsxs("div",{className:"absolute right-0 mt-1 w-52 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl shadow-xl z-50 py-1.5 overflow-hidden",children:[t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-bold text-gray-400 dark:text-gray-500 uppercase tracking-wider border-b border-gray-100 dark:border-gray-700 mb-1",children:"Create from this order"}),e.map(({label:n,icon:i,onClick:o})=>t.jsxs("button",{onClick:()=>{o(),a(!1)},className:"w-full flex items-center gap-3 px-4 py-2.5 text-sm text-gray-700 dark:text-gray-300 hover:bg-amber-50 dark:hover:bg-amber-900/20 hover:text-amber-700 dark:hover:text-amber-300 transition-colors text-left",children:[t.jsx("span",{className:"text-gray-400",children:i}),n]},n))]})]})},Td=({title:e,children:r,defaultOpen:a=!1})=>{const[s,n]=p.useState(a);return t.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-600 mt-3 pt-1",children:[t.jsxs("button",{type:"button",onClick:()=>n(i=>!i),className:"flex items-center gap-2 py-1 text-xs font-semibold text-amber-600 dark:text-amber-400 hover:underline",children:[s?t.jsx(Fr,{size:9}):t.jsx(Fi,{size:9}),e]}),s&&t.jsx("div",{className:"mt-2",children:r})]})},V4e=({item:e,rowNo:r,onChange:a,onClose:s,onDelete:n,onInsertBelow:i})=>{var o,l,c,u,h,f,y,b;return t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"p-0",children:t.jsxs("div",{className:"border border-amber-300 dark:border-amber-600 rounded-lg mx-2 my-1 bg-white dark:bg-gray-800 shadow-md",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-amber-50 dark:bg-amber-900/30 rounded-t-lg border-b border-amber-200 dark:border-amber-700",children:[t.jsxs("span",{className:"text-sm font-semibold text-amber-700 dark:text-amber-300",children:["Editing Row #",r]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:i,className:"px-2 py-1 text-xs border border-gray-300 rounded hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-600",children:"Insert Below"}),t.jsx("button",{onClick:n,className:"px-2 py-1 text-xs border border-red-300 rounded text-red-500 hover:bg-red-50",children:"Delete"}),t.jsx("button",{onClick:s,className:"p-1 text-gray-400 hover:text-gray-600",children:t.jsx(ht,{size:13})})]})]}),t.jsxs("div",{className:"p-4 space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(sa,{required:!0,children:"Item Code"}),t.jsx(Je,{label:"Item",hideLabel:!0,doctype:"Item",value:e.item_code||"",onChange:w=>a("item_code",w),placeholder:"Select item…"})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"Schedule Date"}),t.jsx("input",{type:"date",value:e.schedule_date||"",onChange:w=>a("schedule_date",w.target.value),className:Ic})]})]}),t.jsxs("div",{children:[t.jsx(sa,{required:!0,children:"Item Name"}),t.jsx("input",{value:e.item_name||"",onChange:w=>a("item_name",w.target.value),className:Ic,placeholder:"Item name…"})]}),t.jsx(Td,{title:"Description",defaultOpen:!!e.description,children:t.jsx("textarea",{rows:2,value:e.description||"",onChange:w=>a("description",w.target.value),className:Ic,placeholder:"Description…"})}),t.jsx(Td,{title:"Quantity and Rate",defaultOpen:!0,children:t.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[t.jsxs("div",{children:[t.jsx(sa,{required:!0,children:"Quantity"}),t.jsx("input",{type:"number",min:0,step:"1",value:(o=e.qty)!=null?o:0,onChange:w=>a("qty",parseFloat(w.target.value)||0),className:ip})]}),t.jsxs("div",{children:[t.jsx(sa,{required:!0,children:"UOM"}),t.jsx(Je,{label:"UOM",hideLabel:!0,doctype:"UOM",value:e.uom||"",onChange:w=>a("uom",w),placeholder:"UOM…"})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"Stock UOM"}),t.jsx(Je,{label:"Stock UOM",hideLabel:!0,doctype:"UOM",value:e.stock_uom||"",onChange:w=>a("stock_uom",w),placeholder:"Stock UOM…"})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"UOM Conversion Factor"}),t.jsx("input",{type:"number",min:0,step:"0.001",value:(l=e.conversion_factor)!=null?l:1,onChange:w=>a("conversion_factor",parseFloat(w.target.value)||1),className:ip})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"Stock Qty (auto)"}),t.jsx("div",{className:"px-3 py-2 text-sm text-gray-600 bg-gray-50 dark:bg-gray-700 rounded text-right",children:((e.qty||0)*(e.conversion_factor||1)).toFixed(3)})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"Price List Rate"}),t.jsx("input",{type:"number",min:0,step:"0.01",value:(c=e.price_list_rate)!=null?c:0,onChange:w=>a("price_list_rate",parseFloat(w.target.value)||0),className:ip})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"Last Purchase Rate"}),t.jsx("div",{className:"px-3 py-2 text-sm text-right bg-gray-50 dark:bg-gray-700 rounded",children:((u=e.last_purchase_rate)!=null?u:0).toFixed(2)})]})]})}),t.jsx(Td,{title:"Discount and Margin",children:t.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[t.jsxs("div",{children:[t.jsx(sa,{required:!0,children:"Rate"}),t.jsx("input",{type:"number",min:0,step:"0.01",value:(h=e.rate)!=null?h:0,onChange:w=>a("rate",parseFloat(w.target.value)||0),className:ip})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"Amount (auto)"}),t.jsx("div",{className:"px-3 py-2 text-sm font-semibold text-right bg-gray-50 dark:bg-gray-700 rounded",children:((e.qty||0)*(e.rate||0)).toFixed(2)})]}),t.jsx("div",{className:"flex flex-col justify-end gap-2 pb-1",children:t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:!!e.is_free_item,onChange:w=>a("is_free_item",w.target.checked?1:0),className:"rounded"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Is Free Item"})]})})]})}),t.jsx(Td,{title:"Warehouse and Reference",children:t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(sa,{children:"Warehouse"}),t.jsx(Je,{label:"Warehouse",hideLabel:!0,doctype:"Warehouse",value:e.warehouse||"",onChange:w=>a("warehouse",w),placeholder:"Warehouse…"})]}),t.jsx("div",{className:"flex items-end pb-2",children:t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:!!e.against_blanket_order,onChange:w=>a("against_blanket_order",w.target.checked?1:0),className:"rounded"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Against Blanket Order"})]})}),e.material_request&&t.jsxs("div",{children:[t.jsx(sa,{children:"Material Request"}),t.jsx(to,{children:e.material_request})]})]})}),t.jsx(Td,{title:"Available Quantity",children:t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(sa,{children:"Actual Qty (Warehouse)"}),t.jsx("div",{className:"px-3 py-2 text-sm text-right bg-gray-50 dark:bg-gray-700 rounded",children:(f=e.actual_qty)!=null?f:0})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"Company Total Stock"}),t.jsx("div",{className:"px-3 py-2 text-sm text-right bg-gray-50 dark:bg-gray-700 rounded",children:(y=e.company_total_stock)!=null?y:0})]})]})}),t.jsx(Td,{title:"Accounting Details",children:t.jsxs("div",{children:[t.jsx(sa,{children:"Expense Account"}),t.jsx(Je,{label:"Account",hideLabel:!0,doctype:"Account",value:e.expense_account||"",onChange:w=>a("expense_account",w),placeholder:"Expense account…"})]})}),t.jsx(Td,{title:"Accounting Dimensions",children:t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(sa,{children:"Cost Center"}),t.jsx(Je,{label:"Cost Center",hideLabel:!0,doctype:"Cost Center",value:e.cost_center||"",onChange:w=>a("cost_center",w),placeholder:"Cost center…"})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"Project"}),t.jsx(Je,{label:"Project",hideLabel:!0,doctype:"Project",value:e.project||"",onChange:w=>a("project",w),placeholder:"Project…"})]})]})}),t.jsx(Td,{title:"Item Weight Details",children:t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(sa,{children:"Weight Per Unit"}),t.jsx("input",{type:"number",min:0,step:"0.001",value:(b=e.weight_per_unit)!=null?b:0,onChange:w=>a("weight_per_unit",parseFloat(w.target.value)||0),className:ip})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"Total Weight (auto)"}),t.jsx("div",{className:"px-3 py-2 text-sm text-right bg-gray-50 dark:bg-gray-700 rounded",children:((e.qty||0)*(e.weight_per_unit||0)).toFixed(3)})]})]})})]})]})})})},G4e=({tax:e,rowNo:r,onChange:a,onClose:s,onDelete:n,onInsertBelow:i})=>{var o;return t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"p-0",children:t.jsxs("div",{className:"border border-amber-300 dark:border-amber-600 rounded-lg mx-2 my-1 bg-white dark:bg-gray-800 shadow-md",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-amber-50 dark:bg-amber-900/30 rounded-t-lg border-b border-amber-200",children:[t.jsxs("span",{className:"text-sm font-semibold text-amber-700 dark:text-amber-300",children:["Editing Row #",r]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:i,className:"px-2 py-1 text-xs border border-gray-300 rounded hover:bg-gray-50 text-gray-600",children:"Insert Below"}),t.jsx("button",{onClick:n,className:"px-2 py-1 text-xs border border-red-300 rounded text-red-500 hover:bg-red-50",children:"Delete"}),t.jsx("button",{onClick:s,className:"p-1 text-gray-400 hover:text-gray-600",children:t.jsx(ht,{size:13})})]})]}),t.jsxs("div",{className:"p-4 space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(sa,{required:!0,children:"Type"}),t.jsxs("select",{value:e.charge_type||"",onChange:l=>a("charge_type",l.target.value),className:Ic,children:[t.jsx("option",{value:"",children:"Select type…"}),t.jsx("option",{value:"Actual",children:"Actual"}),t.jsx("option",{value:"On Net Total",children:"On Net Total"}),t.jsx("option",{value:"On Previous Row Amount",children:"On Previous Row Amount"})]})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"Description"}),t.jsx("textarea",{rows:3,value:e.description||"",onChange:l=>a("description",l.target.value),className:Ic,placeholder:"Description…"})]})]}),t.jsxs("div",{children:[t.jsx(sa,{required:!0,children:"Account Head"}),t.jsx(Je,{label:"Account Head",hideLabel:!0,doctype:"Account",value:e.account_head||"",onChange:l=>a("account_head",l),placeholder:"Account…"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"checkbox",checked:!!e.included_in_print_rate,onChange:l=>a("included_in_print_rate",l.target.checked?1:0),className:"rounded"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Is this Tax included in Basic Rate?"})]}),t.jsx("p",{className:"text-xs text-amber-500 dark:text-amber-400",children:"If checked, the tax amount will be considered as already included in the Print Rate / Print Amount"}),t.jsx(Td,{title:"Accounting Dimensions",defaultOpen:!0,children:t.jsxs("div",{children:[t.jsx(sa,{children:"Cost Center"}),t.jsx(Je,{label:"Cost Center",hideLabel:!0,doctype:"Cost Center",value:e.cost_center||"",onChange:l=>a("cost_center",l),placeholder:"Cost center…"})]})}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(sa,{required:!0,children:"Tax Rate"}),t.jsx("input",{type:"number",min:0,step:"0.01",value:(o=e.rate)!=null?o:0,onChange:l=>a("rate",parseFloat(l.target.value)||0),className:ip})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"Account Currency"}),t.jsx("input",{value:e.account_currency||Er,onChange:l=>a("account_currency",l.target.value),className:Ic})]})]})]})]})})})},K4e=()=>({item_code:"",item_name:"",qty:1,rate:0,amount:0,uom:"",conversion_factor:1,is_free_item:0}),Y4e=()=>({charge_type:"",account_head:"",rate:0,account_currency:Er,included_in_print_rate:0}),J4e=()=>{var xe,ge,be,K,ye;const{poName:e}=hs(),[r]=_a(),a=hr(),s=e==="new",n=r.get("project")||"",i=r.get("supplier")||"",o=r.get("company")||un,l=r.get("mr")||"",[c,u]=p.useState(null),[h,f]=p.useState(!s),[y,b]=p.useState(!1),[w,v]=p.useState(!1),[k,S]=p.useState(s),[N,C]=p.useState(null),[O,T]=p.useState(null),P=new Date().toISOString().split("T")[0],[E,R]=p.useState({supplier:i,supplier_name:i,company:o,project:n,transaction_date:P,schedule_date:P,currency:Er,items:[],taxes:[]}),z=p.useCallback(Z=>{R({supplier:Z.supplier||"",supplier_name:Z.supplier_name||Z.supplier||"",company:Z.company||un,project:Z.project||"",transaction_date:Z.transaction_date||P,schedule_date:Z.schedule_date||"",currency:Z.currency||Er,cost_center:Z.cost_center||"",set_warehouse:Z.set_warehouse||"",tax_category:Z.tax_category||"",taxes_and_charges:Z.taxes_and_charges||"",items:Z.items||[],taxes:Z.taxes||[]}),C(null),T(null)},[P]);p.useEffect(()=>{!s||!l||fetch(`/api/resource/Material Request/${encodeURIComponent(l)}`,{credentials:"include"}).then(Z=>Z.json()).then(Z=>{const M=Z.data;M&&R(we=>je(se({},we),{company:M.company||we.company,project:M.project||we.project,schedule_date:M.transaction_date||we.schedule_date,items:(M.items||[]).map(pe=>({item_code:pe.item_code,item_name:pe.item_name,description:pe.description,qty:pe.qty,uom:pe.uom,stock_uom:pe.stock_uom,rate:0,amount:0,schedule_date:pe.required_by||we.schedule_date,material_request:l,material_request_item:pe.name,warehouse:pe.warehouse,project:pe.project||M.project,cost_center:pe.cost_center}))}))}).catch(()=>{})},[s,l]),p.useEffect(()=>{s||(f(!0),sm.getPurchaseOrder(e).then(Z=>{u(Z),z(Z)}).catch(Z=>We.error(Z.message)).finally(()=>f(!1)))},[e,s,z]),p.useEffect(()=>{const Z=E.company;!s||!Z||fetch(`/api/resource/Company/${encodeURIComponent(Z)}`,{credentials:"include"}).then(M=>M.json()).then(M=>{var we;if((we=M.data)!=null&&we.default_currency){const pe=Xn(M.data.default_currency);R(le=>je(se({},le),{currency:pe,buying_price_list:le.buying_price_list||"Standard Buying",price_list_currency:le.price_list_currency||pe}))}}).catch(()=>{})},[E.company,s]);const G=(Z,M)=>R(we=>je(se({},we),{[Z]:M})),ae=(Z,M,we)=>R(pe=>{const le=[...pe.items||[]],Fe=je(se({},le[Z]),{[M]:we});if(M==="qty"||M==="rate"){const ze=parseFloat(String(M==="qty"?we:Fe.qty))||0,Re=parseFloat(String(M==="rate"?we:Fe.rate))||0;Fe.amount=parseFloat((ze*Re).toFixed(4))}if(M==="qty"||M==="conversion_factor"){const ze=parseFloat(String(M==="qty"?we:Fe.qty))||0,Re=parseFloat(String(M==="conversion_factor"?we:Fe.conversion_factor))||1;Fe.stock_qty=parseFloat((ze*Re).toFixed(4))}return le[Z]=Fe,je(se({},pe),{items:le})}),ee=(Z,M)=>J(null,null,function*(){if(ae(Z,"item_code",M),!!M)try{const le=(yield(yield fetch(`/api/resource/Item/${encodeURIComponent(M)}`,{credentials:"include"})).json()).data;if(!le)return;R(Fe=>{var Re;const ze=[...Fe.items||[]];return ze[Z]=je(se({},ze[Z]),{item_code:M,item_name:le.item_name||M,description:le.description||le.item_name||M,stock_uom:le.stock_uom||"",uom:le.purchase_uom||le.stock_uom||"",price_list_rate:(Re=le.standard_rate)!=null?Re:0,rate:ze[Z].rate||le.standard_rate||0}),je(se({},Fe),{items:ze})})}catch(we){}}),ne=Z=>{R(M=>{const we=[...M.items||[]],pe=K4e();let le;return Z!==void 0?(we.splice(Z+1,0,pe),le=Z+1):(we.push(pe),le=we.length-1),setTimeout(()=>C(le),0),je(se({},M),{items:we})})},te=Z=>{R(M=>{const we=[...M.items||[]];return we.splice(Z,1),je(se({},M),{items:we})}),C(null)},Y=(Z,M,we)=>R(pe=>{const le=[...pe.taxes||[]];return le[Z]=je(se({},le[Z]),{[M]:we}),je(se({},pe),{taxes:le})}),q=Z=>{R(M=>{const we=[...M.taxes||[]],pe=Y4e();let le;return Z!==void 0?(we.splice(Z+1,0,pe),le=Z+1):(we.push(pe),le=we.length-1),setTimeout(()=>T(le),0),je(se({},M),{taxes:we})})},H=Z=>{R(M=>{const we=[...M.taxes||[]];return we.splice(Z,1),je(se({},M),{taxes:we})}),T(null)},U=(E.items||[]).reduce((Z,M)=>Z+(M.qty||0)*(M.rate||0),0),re=(E.taxes||[]).reduce((Z,M)=>M.charge_type==="On Net Total"?Z+(M.rate||0)/100*U:Z+(M.tax_amount||0),0),X=U+re,V=Z=>J(null,null,function*(){var M;if(Z)try{const le=(yield(yield fetch(`/api/resource/Purchase Taxes and Charges Template/${encodeURIComponent(Z)}`,{credentials:"include"})).json()).data;(M=le==null?void 0:le.taxes)!=null&&M.length&&R(Fe=>je(se({},Fe),{taxes:le.taxes.map(ze=>{var Re;return{charge_type:ze.charge_type,account_head:ze.account_head,description:ze.description,rate:ze.rate,cost_center:ze.cost_center,account_currency:ze.account_currency,included_in_print_rate:(Re=ze.included_in_print_rate)!=null?Re:0}})}))}catch(we){}}),I=()=>({supplier:E.supplier,company:E.company||void 0,project:E.project||void 0,cost_center:E.cost_center||void 0,transaction_date:E.transaction_date,schedule_date:E.schedule_date||void 0,currency:E.currency||void 0,set_warehouse:E.set_warehouse||void 0,tax_category:E.tax_category||void 0,taxes_and_charges:E.taxes_and_charges||void 0,items:(E.items||[]).filter(Z=>Z.item_code).map((Z,M)=>{var we,pe,le,Fe,ze,Re;return{item_code:Z.item_code,item_name:Z.item_name||Z.item_code,description:Z.description||Z.item_name||Z.item_code,qty:(we=Z.qty)!=null?we:1,uom:Z.uom||void 0,stock_uom:Z.stock_uom||void 0,conversion_factor:(pe=Z.conversion_factor)!=null?pe:1,rate:(le=Z.rate)!=null?le:0,amount:(Z.qty||0)*(Z.rate||0),price_list_rate:(Fe=Z.price_list_rate)!=null?Fe:0,schedule_date:Z.schedule_date||E.schedule_date||void 0,is_free_item:(ze=Z.is_free_item)!=null?ze:0,warehouse:Z.warehouse||E.set_warehouse||void 0,expense_account:Z.expense_account||void 0,against_blanket_order:(Re=Z.against_blanket_order)!=null?Re:0,weight_per_unit:Z.weight_per_unit||void 0,project:Z.project||E.project||void 0,cost_center:Z.cost_center||E.cost_center||void 0,idx:M+1}}),taxes:(E.taxes||[]).filter(Z=>Z.charge_type).map((Z,M)=>{var we,pe;return{charge_type:Z.charge_type,account_head:Z.account_head||void 0,description:Z.description||void 0,included_in_print_rate:(we=Z.included_in_print_rate)!=null?we:0,cost_center:Z.cost_center||void 0,rate:(pe=Z.rate)!=null?pe:0,account_currency:Z.account_currency||Er,idx:M+1}})}),B=()=>J(null,null,function*(){if(!E.supplier){We.error("Supplier is required");return}try{if(b(!0),s){const Z=yield sm.createPurchaseOrder(I());We.success("Purchase Order created"),S(!1),a(`/purchase-orders/${Z.name}`)}else{const Z=yield sm.updatePurchaseOrder(e,I());u(Z),z(Z),We.success("Purchase Order saved"),S(!1)}}catch(Z){We.error(Z.message||"Error saving")}finally{b(!1)}}),Q=()=>J(null,null,function*(){if(!(!e||s))try{v(!0);const Z=yield sm.submitPurchaseOrder(e);u(Z),z(Z),We.success("Purchase Order submitted")}catch(Z){We.error(Z.message||"Error submitting")}finally{v(!1)}}),ie=()=>{const Z=new URLSearchParams;Z.set("po",e),E.supplier&&Z.set("supplier",E.supplier),E.company&&Z.set("company",String(E.company)),E.project&&Z.set("project",String(E.project)),a(`/purchase-receipts/new?${Z.toString()}`)},me=s||k,he=!s&&(c==null?void 0:c.docstatus)===1,de=s?"New Purchase Order":E.supplier_name||e||"";return h?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsx(tr,{className:"animate-spin text-amber-500 text-3xl"})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 px-6 py-6",children:[t.jsx($a,{position:"top-right",autoClose:3500}),t.jsxs("div",{className:"flex items-center gap-2 text-sm mb-6 text-gray-500",children:[t.jsx("button",{onClick:()=>a("/purchase-orders"),className:"hover:text-amber-600",children:"Purchase Orders"}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:s?"New Purchase Order":e})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 dark:border-gray-700 flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>a("/purchase-orders"),className:"text-gray-400 hover:text-gray-700",children:t.jsx(ia,{})}),t.jsx(eS,{className:"text-amber-500"}),t.jsx("div",{children:t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:de}),!s&&e&&t.jsx("span",{className:"text-xs text-gray-400 font-mono",children:e}),!s&&t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${(()=>{const Z=(c==null?void 0:c.status)||"";return(c==null?void 0:c.docstatus)===2||Z==="Cancelled"?"bg-red-100 text-red-700":!c||c.docstatus===0?"bg-yellow-100 text-yellow-800":Z==="Completed"?"bg-green-100 text-green-800":Z==="To Receive and Bill"||Z==="To Bill"||Z==="To Receive"?"bg-blue-100 text-blue-800":Z==="Closed"?"bg-gray-100 text-gray-700":"bg-green-100 text-green-800"})()}`,children:(c==null?void 0:c.docstatus)===2?"Cancelled":(c==null?void 0:c.docstatus)===0?"Draft":(c==null?void 0:c.status)||"Submitted"})]})})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[he&&t.jsx(q4e,{items:[{label:"Purchase Receipt",icon:t.jsx(zG,{size:13}),onClick:ie}]}),!s&&!k&&(c==null?void 0:c.docstatus)===0&&t.jsxs("button",{onClick:Q,disabled:w,className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 text-sm font-medium",children:[w?t.jsx(tr,{className:"animate-spin"}):t.jsx(Lm,{size:12})," Submit"]}),!s&&!k&&!he&&t.jsxs("button",{onClick:()=>S(!0),className:"flex items-center gap-2 px-4 py-2 border border-amber-500 text-amber-600 rounded-lg hover:bg-amber-50 text-sm",children:[t.jsx(qr,{})," Edit"]}),me&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:B,disabled:y,className:"flex items-center gap-2 px-4 py-2 bg-amber-500 text-white rounded-lg hover:bg-amber-600 disabled:opacity-50 text-sm font-medium",children:[y?t.jsx(tr,{className:"animate-spin"}):t.jsx(ta,{}),y?"Saving…":"Save"]}),!s&&t.jsx("button",{onClick:()=>{c&&z(c),S(!1)},className:"px-3 py-2 border border-gray-300 rounded-lg text-gray-600 text-sm",children:t.jsx(ht,{})})]})]})]}),t.jsx("div",{className:"px-6 pt-5 pb-4",children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-4",children:[t.jsxs("div",{children:[t.jsx(sa,{required:!0,children:"Supplier"}),me?t.jsx(Je,{label:"Supplier",hideLabel:!0,doctype:"Supplier",value:E.supplier||"",onChange:Z=>{G("supplier",Z),G("supplier_name",Z)},placeholder:"Select supplier…"}):t.jsx(to,{children:E.supplier_name||E.supplier})]}),t.jsxs("div",{children:[t.jsx(sa,{required:!0,children:"Transaction Date"}),me?t.jsx("input",{type:"date",value:E.transaction_date||"",onChange:Z=>G("transaction_date",Z.target.value),className:Ic}):t.jsx(to,{children:E.transaction_date})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"Schedule Date"}),me?t.jsx("input",{type:"date",value:E.schedule_date||"",onChange:Z=>G("schedule_date",Z.target.value),className:Ic}):t.jsx(to,{children:E.schedule_date})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"Company"}),me?t.jsx(Je,{label:"Company",hideLabel:!0,doctype:"Company",value:E.company||"",onChange:Z=>G("company",Z),placeholder:"Select company…"}):t.jsx(to,{children:E.company})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"Project"}),me?t.jsx(Je,{label:"Project",hideLabel:!0,doctype:"Project",value:E.project||"",onChange:Z=>G("project",Z),placeholder:"Select project…"}):t.jsx(to,{children:E.project})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"Set Warehouse"}),me?t.jsx(Je,{label:"Warehouse",hideLabel:!0,doctype:"Warehouse",value:E.set_warehouse||"",onChange:Z=>G("set_warehouse",Z),placeholder:"Set warehouse…"}):t.jsx(to,{children:E.set_warehouse})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"Currency"}),me?t.jsxs("select",{value:E.currency||Er,onChange:Z=>G("currency",Z.target.value),className:Ic,children:[t.jsx("option",{value:"SAR",children:"SAR"}),t.jsx("option",{value:"USD",children:"USD"}),t.jsx("option",{value:"EUR",children:"EUR"})]}):t.jsx(to,{children:E.currency})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"Cost Center"}),me?t.jsx(Je,{label:"Cost Center",hideLabel:!0,doctype:"Cost Center",value:E.cost_center||"",onChange:Z=>G("cost_center",Z),placeholder:"Cost center…"}):t.jsx(to,{children:E.cost_center})]})]})}),t.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700",children:[t.jsx("div",{className:"px-6 py-3 bg-gray-50 dark:bg-gray-900/20 border-b border-gray-100 dark:border-gray-700",children:t.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Items"})}),t.jsxs("div",{className:"px-6 pb-5",children:[t.jsx("div",{className:"overflow-x-auto -mx-2 mt-3",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-8",children:"No."}),t.jsxs("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 min-w-[180px]",children:["Item Code ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-32",children:"Schedule Date"}),t.jsxs("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-24",children:["Qty ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsxs("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:["Rate (",E.currency||Er,")"]}),t.jsxs("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:["Amount (",E.currency||Er,")"]}),me&&t.jsx("th",{className:"w-16 py-2 px-2"})]})}),t.jsxs("tbody",{children:[(E.items||[]).map((Z,M)=>{var we,pe,le,Fe;return t.jsxs(gr.Fragment,{children:[t.jsxs("tr",{className:`border-b border-gray-100 dark:border-gray-700 align-middle ${N===M?"bg-amber-50/60 dark:bg-amber-900/10":""}`,children:[t.jsx("td",{className:"py-1.5 px-3 text-gray-400 text-xs",children:M+1}),t.jsx("td",{className:"py-1.5 px-2 min-w-[180px]",children:me?t.jsx(Je,{label:"Item",hideLabel:!0,doctype:"Item",value:Z.item_code||"",onChange:ze=>ee(M,ze),placeholder:"Item Code"}):t.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-200",children:Z.item_code||"-"})}),t.jsx("td",{className:"py-1.5 px-2 w-32",children:me?t.jsx("input",{type:"date",value:Z.schedule_date||"",onChange:ze=>ae(M,"schedule_date",ze.target.value),className:a9}):t.jsx("span",{className:"text-gray-500 text-sm",children:Z.schedule_date||"-"})}),t.jsx("td",{className:"py-1.5 px-2 w-24",children:me?t.jsx("input",{type:"number",min:0,step:"1",value:(we=Z.qty)!=null?we:0,onChange:ze=>ae(M,"qty",parseFloat(ze.target.value)||0),className:cN}):t.jsx("span",{className:"block text-right text-gray-700 dark:text-gray-300 text-sm pr-1",children:(pe=Z.qty)!=null?pe:0})}),t.jsx("td",{className:"py-1.5 px-2 w-28",children:me?t.jsx("input",{type:"number",min:0,step:"0.01",value:(le=Z.rate)!=null?le:0,onChange:ze=>ae(M,"rate",parseFloat(ze.target.value)||0),className:cN}):t.jsx("span",{className:"block text-right text-gray-700 dark:text-gray-300 text-sm pr-1",children:((Fe=Z.rate)!=null?Fe:0).toFixed(2)})}),t.jsx("td",{className:"py-1.5 px-3 text-right font-semibold text-gray-900 dark:text-white text-sm",children:((Z.qty||0)*(Z.rate||0)).toFixed(2)}),me&&t.jsx("td",{className:"py-1.5 px-2",children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>C(N===M?null:M),className:`p-1.5 rounded text-xs ${N===M?"bg-amber-500 text-white":"text-amber-600 hover:bg-amber-50"}`,title:"More fields",children:t.jsx(xl,{size:11})}),t.jsx("button",{onClick:()=>te(M),className:"p-1.5 text-red-400 hover:text-red-600 hover:bg-red-50 rounded",children:t.jsx(wr,{size:11})})]})})]}),me&&N===M&&t.jsx(V4e,{item:Z,rowNo:M+1,onChange:(ze,Re)=>{ze==="item_code"?ee(M,Re):ae(M,ze,Re)},onClose:()=>C(null),onDelete:()=>te(M),onInsertBelow:()=>ne(M)})]},M)}),me&&t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"py-2 px-3",children:t.jsxs("button",{onClick:()=>ne(),className:"flex items-center gap-1.5 text-amber-600 hover:text-amber-700 text-sm font-medium",children:[t.jsx(Rr,{size:10})," Add Row"]})})})]})]})}),t.jsxs("div",{className:"mt-3 flex justify-between text-sm border-t border-gray-100 dark:border-gray-700 pt-3",children:[t.jsxs("span",{className:"text-gray-500",children:["Total Qty: ",t.jsx("strong",{children:(E.items||[]).reduce((Z,M)=>Z+(M.qty||0),0)})]}),t.jsxs("span",{className:"text-gray-500",children:["Net Total: ",t.jsxs("strong",{className:"text-gray-900 dark:text-white",children:[E.currency||Er," ",U.toFixed(2)]})]})]})]})]}),t.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700",children:[t.jsx("div",{className:"px-6 py-3 bg-gray-50 dark:bg-gray-900/20 border-b border-gray-100 dark:border-gray-700",children:t.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Taxes and Charges"})}),t.jsxs("div",{className:"px-6 pt-4 pb-2 grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-3",children:[t.jsxs("div",{children:[t.jsx(sa,{children:"Tax Category"}),me?t.jsx(Je,{label:"Tax Category",hideLabel:!0,doctype:"Tax Category",value:E.tax_category||"",onChange:Z=>G("tax_category",Z),placeholder:"Select tax category…"}):t.jsx(to,{children:E.tax_category})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"Purchase Taxes and Charges Template"}),me?t.jsx(Je,{label:"Purchase Taxes and Charges Template",hideLabel:!0,doctype:"Purchase Taxes and Charges Template",value:E.taxes_and_charges||"",onChange:Z=>{G("taxes_and_charges",Z),V(Z)},placeholder:"Select template…"}):t.jsx(to,{children:E.taxes_and_charges})]})]}),t.jsxs("div",{className:"px-6 pb-5",children:[t.jsx("div",{className:"overflow-x-auto -mx-2 mt-3",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-8",children:"No."}),t.jsxs("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-44",children:["Type ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsxs("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3",children:["Account Head ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-24",children:"Tax Rate"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:"Amount"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:"Total"}),me&&t.jsx("th",{className:"w-16 py-2 px-2"})]})}),t.jsxs("tbody",{children:[(E.taxes||[]).map((Z,M)=>{var le,Fe;const we=Z.charge_type==="On Net Total"?(Z.rate||0)/100*U:Z.charge_type==="Actual"?Z.tax_amount||0:(Z.rate||0)/100*U,pe=U+(E.taxes||[]).slice(0,M+1).reduce((ze,Re)=>{const De=Re.charge_type==="On Net Total"?(Re.rate||0)/100*U:Re.charge_type==="Actual"?Re.tax_amount||0:(Re.rate||0)/100*U;return ze+De},0);return t.jsxs(gr.Fragment,{children:[t.jsxs("tr",{className:`border-b border-gray-100 dark:border-gray-700 align-middle ${O===M?"bg-amber-50/60 dark:bg-amber-900/10":""}`,children:[t.jsx("td",{className:"py-1.5 px-3 text-gray-400 text-xs",children:M+1}),t.jsx("td",{className:"py-1.5 px-2 w-44",children:me?t.jsxs("select",{value:Z.charge_type||"",onChange:ze=>Y(M,"charge_type",ze.target.value),className:a9,children:[t.jsx("option",{value:"",children:"Select type…"}),t.jsx("option",{value:"Actual",children:"Actual"}),t.jsx("option",{value:"On Net Total",children:"On Net Total"}),t.jsx("option",{value:"On Previous Row Amount",children:"On Previous Row Amount"})]}):t.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:Z.charge_type||"-"})}),t.jsx("td",{className:"py-1.5 px-2",children:me?t.jsx(Je,{label:"Account Head",hideLabel:!0,doctype:"Account",value:Z.account_head||"",onChange:ze=>Y(M,"account_head",ze),placeholder:"Account Head"}):t.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:Z.account_head||"-"})}),t.jsx("td",{className:"py-1.5 px-2 w-24",children:me?t.jsx("input",{type:"number",min:0,step:"0.01",value:(le=Z.rate)!=null?le:0,onChange:ze=>Y(M,"rate",parseFloat(ze.target.value)||0),className:cN}):t.jsx("span",{className:"block text-right text-gray-700 dark:text-gray-300 pr-1",children:(Fe=Z.rate)!=null?Fe:0})}),t.jsx("td",{className:"py-1.5 px-3 text-right text-gray-700 dark:text-gray-300 text-sm",children:we.toFixed(2)}),t.jsx("td",{className:"py-1.5 px-3 text-right font-semibold text-gray-900 dark:text-white text-sm",children:pe.toFixed(2)}),me&&t.jsx("td",{className:"py-1.5 px-2",children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>T(O===M?null:M),className:`p-1.5 rounded text-xs ${O===M?"bg-amber-500 text-white":"text-amber-600 hover:bg-amber-50"}`,title:"More fields",children:t.jsx(xl,{size:11})}),t.jsx("button",{onClick:()=>H(M),className:"p-1.5 text-red-400 hover:text-red-600 hover:bg-red-50 rounded",children:t.jsx(wr,{size:11})})]})})]}),me&&O===M&&t.jsx(G4e,{tax:Z,rowNo:M+1,onChange:(ze,Re)=>Y(M,ze,Re),onClose:()=>T(null),onDelete:()=>H(M),onInsertBelow:()=>q(M)})]},M)}),me&&t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"py-2 px-3",children:t.jsxs("button",{onClick:()=>q(),className:"flex items-center gap-1.5 text-amber-600 hover:text-amber-700 text-sm font-medium",children:[t.jsx(Rr,{size:10})," Add Row"]})})})]})]})}),(E.taxes||[]).length>0&&t.jsxs("div",{className:"mt-2 flex justify-end text-sm text-gray-500 pt-2 border-t border-gray-100 dark:border-gray-700",children:["Total Taxes and Charges: ",t.jsxs("strong",{className:"ml-2 text-gray-900 dark:text-white",children:[E.currency||Er," ",re.toFixed(2)]})]})]})]}),t.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700 px-6 py-4",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"Totals"}),t.jsx("div",{className:"space-y-2 max-w-xs ml-auto",children:[{label:"Net Total",value:((xe=c==null?void 0:c.net_total)!=null?xe:U).toFixed(2)},{label:"Total Taxes",value:((ge=c==null?void 0:c.total_taxes_and_charges)!=null?ge:re).toFixed(2)},{label:"Grand Total",value:((be=c==null?void 0:c.grand_total)!=null?be:X).toFixed(2)},{label:"Rounded Total",value:((K=c==null?void 0:c.rounded_total)!=null?K:X).toFixed(2)},{label:"Advance Paid",value:((ye=c==null?void 0:c.advance_paid)!=null?ye:0).toFixed(2)}].map(({label:Z,value:M})=>t.jsxs("div",{className:"flex justify-between text-sm border-b border-gray-100 dark:border-gray-700 pb-1.5 last:border-0",children:[t.jsx("span",{className:"text-gray-500",children:Z}),t.jsxs("span",{className:"font-semibold text-gray-900 dark:text-white",children:[E.currency||Er," ",M]})]},Z))})]}),!s&&c&&t.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700 px-6 py-4 grid grid-cols-3 gap-4 text-sm bg-gray-50 dark:bg-gray-900/20",children:[t.jsxs("div",{children:[t.jsx(sa,{children:"Created By"}),t.jsx(to,{children:c.owner})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"Created"}),t.jsx(to,{children:c.creation?new Date(c.creation).toLocaleString():"-"})]}),t.jsxs("div",{children:[t.jsx(sa,{children:"Modified"}),t.jsx(to,{children:c.modified?new Date(c.modified).toLocaleString():"-"})]})]}),!s&&t.jsx(vi,{doctype:"Purchase Order",docname:(c==null?void 0:c.name)||e||"",creationDate:c==null?void 0:c.creation,createdBy:c==null?void 0:c.owner,compact:!1,initialVisible:5,collapsible:!0,startCollapsed:!0})]})]})},B0=20;function Z4e(e){const r=[];return e.search&&r.push(["Delivery Note","name","like",`%${e.search}%`]),e.status==="Draft"&&r.push(["Delivery Note","docstatus","=",0]),e.status==="Submitted"&&r.push(["Delivery Note","docstatus","=",1]),e.status==="Cancelled"&&r.push(["Delivery Note","docstatus","=",2]),r}function X4e(e){return e.docstatus===2?"bg-red-100 text-red-700":e.docstatus===1?"bg-green-100 text-green-700":"bg-yellow-100 text-yellow-800"}function Q4e(e){return e.docstatus===2?"Cancelled":e.docstatus===1?e.status||"Submitted":"Draft"}const eSe=()=>{const{t:e}=sr(),r=hr(),[a,s]=p.useState([]),[n,i]=p.useState(!0),[o,l]=p.useState(0),[c,u]=p.useState(0),[h,f]=p.useState(!1),[y,b]=p.useState(""),[w,v]=p.useState(""),[k,S]=p.useState({search:"",status:""}),[N,C]=p.useState(!1),O=p.useRef(!1),T=p.useRef(null),P=p.useCallback((X,V)=>J(null,null,function*(){i(!0);try{const I=[];V.search&&I.push(["Delivery Note","name","like",`%${V.search}%`]),V.status==="Draft"&&I.push(["Delivery Note","docstatus","=",0]),V.status==="Submitted"&&I.push(["Delivery Note","docstatus","=",1]),V.status==="Cancelled"&&I.push(["Delivery Note","docstatus","=",2]);const[B,Q]=yield Promise.all([tm.getDeliveryNotes({filters:I,limit_start:X,limit_page_length:B0}),tm.getDeliveryNoteCount(I)]);s(B),l(Q)}catch(I){We.error(I.message||"Failed to load")}finally{i(!1)}}),[]);p.useEffect(()=>{P(0,k)},[P,k]);const E=p.useMemo(()=>`${c}|${k.search}|${k.status}`,[c,k.search,k.status]),{selectedRows:R,toggleRow:z,toggleAllOnPage:G,allOnPageSelected:ae,someOnPageSelected:ee}=po(a,E);p.useEffect(()=>{if(!O.current){O.current=!0;return}S(X=>je(se({},X),{status:w})),u(0)},[w]),p.useEffect(()=>{if(O.current)return T.current&&window.clearTimeout(T.current),T.current=window.setTimeout(()=>{S(X=>je(se({},X),{search:y})),u(0)},450),()=>{T.current&&window.clearTimeout(T.current)}},[y]);const ne=()=>{b(""),v(""),S({search:"",status:""}),u(0)},te=!!(k.search||k.status),Y=X=>{u(X),P(X*B0,k)},q=X=>r(`/delivery-notes/${encodeURIComponent(X)}`),H=X=>r(`/delivery-notes/${encodeURIComponent(X)}?edit=1`),U=X=>r(`/delivery-notes/new?duplicate=${encodeURIComponent(X)}`),re=p.useCallback(()=>go({doctype:"Delivery Note",filters:Z4e(k),orderBy:"modified desc"}),[k]);return t.jsxs("div",{className:"p-6",children:[t.jsx($a,{position:"top-right",autoClose:3e3}),t.jsxs("div",{className:"flex items-center justify-between mb-6 gap-4 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl bg-teal-600 flex items-center justify-center",children:t.jsx(G1,{className:"text-white text-base"})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:"Delivery Notes"}),t.jsxs("p",{className:"text-xs text-gray-500",children:[o," total"]})]})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("button",{onClick:()=>P(c*B0,k),className:"p-2 text-gray-500 hover:text-indigo-600 border border-gray-200 rounded-lg",children:t.jsx(Ma,{size:13})}),t.jsxs("button",{type:"button",onClick:()=>C(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all text-sm font-medium disabled:opacity-50",disabled:o===0&&R.size===0,children:[t.jsx(Sa,{})," ",e("listPages.export"),R.size>0&&t.jsx("span",{className:"bg-white/25 px-1.5 py-0.5 rounded text-xs font-bold",children:R.size})]}),t.jsxs("button",{onClick:()=>r("/delivery-notes/new"),className:"flex items-center gap-2 px-4 py-2 bg-teal-600 text-white rounded-lg hover:bg-teal-700 text-sm font-medium",children:[t.jsx(Rr,{size:11})," New Note"]})]})]}),t.jsx(bi,{isOpen:N,onClose:()=>C(!1),doctype:"Delivery Note",selectedCount:R.size,pageCount:a.length,totalCount:o,pageData:a,selectedRows:R,rowKey:"name",onFetchAll:re,fileNamePrefix:"delivery_notes"}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl mb-5 overflow-hidden",children:[t.jsxs("button",{onClick:()=>f(X=>!X),className:"w-full flex items-center justify-between px-4 py-3 bg-gradient-to-r from-blue-500 to-blue-600 dark:from-blue-600 dark:to-blue-700 text-white",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[t.jsx(za,{size:12})," Filters ",te&&t.jsx("span",{className:"bg-white/30 text-white text-xs px-2 py-0.5 rounded-full",children:"Active"})]}),h?t.jsx(Ja,{size:11}):t.jsx(Fr,{size:11})]}),te&&t.jsxs("div",{className:"px-4 py-2 bg-blue-50 dark:bg-blue-900/20 flex flex-wrap gap-2 items-center border-b border-blue-100 dark:border-blue-900/30",children:[k.search&&t.jsxs("span",{className:"flex items-center gap-1 text-xs bg-blue-100 text-blue-700 px-2 py-1 rounded-full",children:["ID: ",k.search,t.jsx("button",{onClick:()=>{b(""),S(X=>je(se({},X),{search:""}))},children:t.jsx(ht,{size:9})})]}),k.status&&t.jsxs("span",{className:"flex items-center gap-1 text-xs bg-blue-100 text-blue-700 px-2 py-1 rounded-full",children:["Status: ",k.status,t.jsx("button",{onClick:()=>{v(""),S(X=>je(se({},X),{status:""}))},children:t.jsx(ht,{size:9})})]}),t.jsx("button",{onClick:ne,className:"text-xs text-blue-600 hover:underline ml-auto",children:"Clear All"})]}),h&&t.jsxs("div",{className:"px-4 py-3 grid grid-cols-1 sm:grid-cols-3 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[11px] font-semibold text-gray-500 uppercase tracking-wide mb-1",children:"Note ID"}),t.jsx("input",{value:y,onChange:X=>b(X.target.value),onKeyDown:X=>X.key==="Enter"&&X.preventDefault(),placeholder:"Search…",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-400"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[11px] font-semibold text-gray-500 uppercase tracking-wide mb-1",children:"Status"}),t.jsxs("select",{value:w,onChange:X=>v(X.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-400",children:[t.jsx("option",{value:"",children:"All"}),t.jsx("option",{value:"Draft",children:"Draft"}),t.jsx("option",{value:"Submitted",children:"Submitted"}),t.jsx("option",{value:"Cancelled",children:"Cancelled"})]})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl overflow-hidden",children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx("th",{className:"w-10 px-4 py-3 text-left",children:t.jsx("button",{type:"button",onClick:G,className:"text-gray-500 dark:text-gray-400 hover:text-teal-600 dark:hover:text-teal-400 transition-colors",title:ae?"Deselect all":"Select all","aria-label":"Select all on page",children:ae?t.jsx(Ra,{className:"text-teal-600 dark:text-teal-400",size:18}):ee?t.jsxs("div",{className:"relative inline-block",children:[t.jsx(Ur,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Ur,{size:18})})}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Note ID"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Customer"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Date"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Status"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Grand Total"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4 w-28",children:" "})]})}),t.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:n?t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"text-center py-10 text-gray-400",children:"Loading…"})}):a.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"text-center py-10 text-gray-400",children:"No delivery notes found"})}):a.map(X=>{var V;return t.jsxs("tr",{onClick:()=>q(X.name),className:`cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors ${R.has(X.name)?"bg-teal-50 dark:bg-teal-900/20":""}`,children:[t.jsx("td",{className:"w-10 px-4 py-3",onClick:I=>I.stopPropagation(),children:t.jsx("button",{type:"button",onClick:()=>z(X.name),className:"text-gray-500 dark:text-gray-400 hover:text-teal-600 dark:hover:text-teal-400 transition-colors","aria-label":`Select ${X.name}`,children:R.has(X.name)?t.jsx(Ra,{className:"text-teal-600 dark:text-teal-400",size:18}):t.jsx(Ur,{size:18})})}),t.jsx("td",{className:"py-3 px-4 font-medium text-gray-900 dark:text-white",children:X.name}),t.jsx("td",{className:"py-3 px-4 text-gray-700 dark:text-gray-300",children:X.customer_name||X.customer||"-"}),t.jsx("td",{className:"py-3 px-4 text-gray-500",children:X.posting_date||"-"}),t.jsx("td",{className:"py-3 px-4",children:t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${X4e(X)}`,children:Q4e(X)})}),t.jsxs("td",{className:"py-3 px-4 text-right font-semibold text-gray-900 dark:text-white",children:[X.currency||"SAR"," ",((V=X.grand_total)!=null?V:0).toFixed(2)]}),t.jsx("td",{className:"py-2 px-4",onClick:I=>I.stopPropagation(),children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>q(X.name),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded transition-colors",title:"View",children:t.jsx(Ps,{})}),t.jsx("button",{onClick:()=>H(X.name),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:"Edit",children:t.jsx(qr,{})}),t.jsx("button",{onClick:()=>U(X.name),className:"text-purple-600 dark:text-purple-400 hover:text-purple-900 dark:hover:text-purple-300 p-2 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded transition-colors",title:"Duplicate",children:t.jsx(Vo,{})})]})})]},X.name)})})]})}),o>B0&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-100 dark:border-gray-700",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:[c*B0+1,"–",Math.min((c+1)*B0,o)," of ",o]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:c===0,onClick:()=>Y(c-1),className:"px-3 py-1 text-xs border border-gray-300 rounded disabled:opacity-40",children:"Prev"}),t.jsx("button",{disabled:(c+1)*B0>=o,onClick:()=>Y(c+1),className:"px-3 py-1 text-xs border border-gray-300 rounded disabled:opacity-40",children:"Next"})]})]})]})]})},ua=({children:e,required:r})=>t.jsxs("label",{className:"block text-[11px] font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1",children:[e,r&&t.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),cl=({children:e})=>t.jsx("div",{className:"px-3 py-2 text-sm text-gray-800 dark:text-gray-200 bg-gray-50 dark:bg-gray-800/60 rounded min-h-[34px] flex items-center",children:e||t.jsx("span",{className:"text-gray-400",children:"-"})}),s9="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-teal-400",tSe="w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-teal-400",dN="w-full px-2 py-1 text-sm text-right border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-teal-400",qf="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-teal-400",W0="w-full px-3 py-2 text-sm text-right border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-teal-400",Xh="w-full px-3 py-2 text-sm bg-gray-50 dark:bg-gray-800/60 text-gray-600 dark:text-gray-400 rounded min-h-[34px] flex items-center",Ed=({label:e,children:r,defaultOpen:a=!1})=>{const[s,n]=p.useState(a);return t.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden mt-3",children:[t.jsxs("button",{type:"button",onClick:()=>n(i=>!i),className:"w-full flex items-center gap-2 px-3 py-2 text-[11px] font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider bg-gray-50 dark:bg-gray-800/80 hover:bg-gray-100 dark:hover:bg-gray-700/60 transition-colors text-left",children:[s?t.jsx(Fr,{size:9}):t.jsx(Fi,{size:9}),e]}),s&&t.jsx("div",{className:"p-3 grid grid-cols-1 sm:grid-cols-2 gap-3 bg-white dark:bg-gray-800",children:r})]})},rSe=({items:e})=>{const[r,a]=p.useState(!1),s=p.useRef(null);return p.useEffect(()=>{const n=i=>{s.current&&!s.current.contains(i.target)&&a(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[]),t.jsxs("div",{className:"relative",ref:s,children:[t.jsxs("button",{onClick:()=>a(n=>!n),className:"flex items-center gap-1.5 px-4 py-2 bg-teal-600 text-white rounded-lg hover:bg-teal-700 text-sm font-medium shadow-sm",children:["Create ",t.jsx(Fr,{size:10,className:`transition-transform ${r?"rotate-180":""}`})]}),r&&t.jsxs("div",{className:"absolute right-0 mt-1 w-52 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl shadow-xl z-50 py-1.5",children:[t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-bold text-gray-400 uppercase tracking-wider border-b border-gray-100 dark:border-gray-700 mb-1",children:"Create from this note"}),e.map(({label:n,icon:i,onClick:o})=>t.jsxs("button",{onClick:()=>{o(),a(!1)},className:"w-full flex items-center gap-3 px-4 py-2.5 text-sm text-gray-700 dark:text-gray-300 hover:bg-teal-50 dark:hover:bg-teal-900/20 hover:text-teal-700 transition-colors text-left",children:[t.jsx("span",{className:"text-gray-400",children:i}),n]},n))]})]})},aSe=({item:e,rowNo:r,currency:a,onChange:s,onClose:n,onDelete:i,onInsertBelow:o})=>{var u,h,f,y,b,w,v,k,S;const l=(N,C)=>s(N,C),c=a||Er;return t.jsx("tr",{children:t.jsx("td",{colSpan:8,className:"p-0",children:t.jsxs("div",{className:"bg-blue-50/60 dark:bg-blue-900/10 border-b border-blue-200 dark:border-blue-800 px-4 py-3",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("span",{className:"text-xs font-bold text-teal-700 dark:text-teal-300 uppercase tracking-wider",children:["Editing Row #",r]}),t.jsxs("div",{className:"flex gap-1",children:[t.jsx("button",{onClick:o,className:"px-2 py-1 text-[11px] bg-teal-600 text-white rounded hover:bg-teal-700",children:"Insert Below"}),t.jsx("button",{onClick:i,className:"px-2 py-1 text-[11px] bg-red-500 text-white rounded hover:bg-red-600",children:"Delete"}),t.jsx("button",{onClick:n,className:"px-2 py-1 text-[11px] bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300 rounded hover:bg-gray-300",children:"ESC"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(ua,{required:!0,children:"Item Code"}),t.jsx(Je,{label:"Item Code",hideLabel:!0,doctype:"Item",value:e.item_code||"",onChange:N=>l("item_code",N)})]}),t.jsxs("div",{children:[t.jsx(ua,{children:"Item Name"}),t.jsx("input",{value:e.item_name||"",onChange:N=>l("item_name",N.target.value),className:qf})]})]}),t.jsx(Ed,{label:"Description",children:t.jsxs("div",{className:"sm:col-span-2",children:[t.jsx(ua,{children:"Description"}),t.jsx("textarea",{value:e.description||"",onChange:N=>l("description",N.target.value),rows:2,className:qf+" resize-none"})]})}),t.jsxs(Ed,{label:"Quantity and Warehouse",defaultOpen:!0,children:[t.jsxs("div",{children:[t.jsx(ua,{required:!0,children:"Quantity"}),t.jsx("input",{type:"number",min:0,step:"1",value:(u=e.qty)!=null?u:1,onChange:N=>l("qty",parseFloat(N.target.value)||0),className:W0})]}),t.jsxs("div",{children:[t.jsx(ua,{required:!0,children:"UOM"}),t.jsx(Je,{label:"UOM",hideLabel:!0,doctype:"UOM",value:e.uom||"",onChange:N=>l("uom",N)})]}),t.jsxs("div",{children:[t.jsx(ua,{children:"Stock UOM"}),t.jsx(Je,{label:"Stock UOM",hideLabel:!0,doctype:"UOM",value:e.stock_uom||"",onChange:N=>l("stock_uom",N)})]}),t.jsxs("div",{children:[t.jsx(ua,{children:"UOM Conversion Factor"}),t.jsx("input",{type:"number",min:0,step:"0.0001",value:(h=e.conversion_factor)!=null?h:1,onChange:N=>l("conversion_factor",parseFloat(N.target.value)||1),className:W0})]}),t.jsxs("div",{children:[t.jsx(ua,{children:"Stock Qty (auto)"}),t.jsx("div",{className:Xh,children:((e.qty||1)*(e.conversion_factor||1)).toFixed(3)})]})]}),t.jsxs(Ed,{label:`Discount and Margin (${c})`,defaultOpen:!0,children:[t.jsxs("div",{children:[t.jsxs(ua,{children:["Price List Rate (",c,")"]}),t.jsx("input",{type:"number",min:0,step:"0.01",value:(f=e.price_list_rate)!=null?f:0,onChange:N=>l("price_list_rate",parseFloat(N.target.value)||0),className:W0})]}),t.jsxs("div",{children:[t.jsx(ua,{children:"Discount %"}),t.jsx("input",{type:"number",min:0,max:100,step:"0.01",value:(y=e.discount_percentage)!=null?y:0,onChange:N=>l("discount_percentage",parseFloat(N.target.value)||0),className:W0})]}),t.jsxs("div",{children:[t.jsxs(ua,{children:["Discount Amount (",c,")"]}),t.jsx("input",{type:"number",min:0,step:"0.01",value:(b=e.discount_amount)!=null?b:0,onChange:N=>l("discount_amount",parseFloat(N.target.value)||0),className:W0})]}),t.jsxs("div",{children:[t.jsxs(ua,{children:["Rate (",c,")"]}),t.jsx("input",{type:"number",min:0,step:"0.01",value:(w=e.rate)!=null?w:0,onChange:N=>l("rate",parseFloat(N.target.value)||0),className:W0})]}),t.jsxs("div",{children:[t.jsxs(ua,{children:["Amount (",c,") (auto)"]}),t.jsx("div",{className:Xh,children:((e.qty||0)*(e.rate||0)).toFixed(2)})]}),t.jsxs("div",{className:"flex items-center gap-2 pt-4",children:[t.jsx("input",{type:"checkbox",id:`fi-${r}`,checked:!!e.is_free_item,onChange:N=>l("is_free_item",N.target.checked?1:0),className:"w-4 h-4 text-teal-600 rounded"}),t.jsx("label",{htmlFor:`fi-${r}`,className:"text-sm text-gray-700 dark:text-gray-300",children:"Is Free Item"})]}),t.jsxs("div",{className:"flex items-center gap-2 pt-4",children:[t.jsx("input",{type:"checkbox",id:`gc-${r}`,checked:!!e.grant_commission,onChange:N=>l("grant_commission",N.target.checked?1:0),className:"w-4 h-4 text-teal-600 rounded"}),t.jsx("label",{htmlFor:`gc-${r}`,className:"text-sm text-gray-700 dark:text-gray-300",children:"Grant Commission"})]})]}),t.jsxs(Ed,{label:"Warehouse and Reference",children:[t.jsxs("div",{children:[t.jsx(ua,{children:"Warehouse"}),t.jsx(Je,{label:"Warehouse",hideLabel:!0,doctype:"Warehouse",value:e.warehouse||"",onChange:N=>l("warehouse",N)})]}),t.jsxs("div",{children:[t.jsx(ua,{children:"Against Sales Order"}),t.jsx("div",{className:Xh,children:e.against_sales_order||"-"})]})]}),t.jsxs(Ed,{label:"Available Quantity",children:[t.jsxs("div",{children:[t.jsx(ua,{children:"Actual Qty (Warehouse)"}),t.jsx("div",{className:Xh,children:(v=e.actual_qty)!=null?v:0})]}),t.jsxs("div",{children:[t.jsx(ua,{children:"Company Total Stock"}),t.jsx("div",{className:Xh,children:(k=e.company_total_stock)!=null?k:0})]})]}),t.jsxs(Ed,{label:"Item Weight Details",children:[t.jsxs("div",{children:[t.jsx(ua,{children:"Weight Per Unit"}),t.jsx("input",{type:"number",min:0,step:"0.001",value:(S=e.weight_per_unit)!=null?S:0,onChange:N=>l("weight_per_unit",parseFloat(N.target.value)||0),className:W0})]}),t.jsxs("div",{children:[t.jsx(ua,{children:"Total Weight (auto)"}),t.jsx("div",{className:Xh,children:((e.weight_per_unit||0)*(e.qty||0)).toFixed(3)})]})]}),t.jsx(Ed,{label:"Accounting Details",children:t.jsxs("div",{className:"sm:col-span-2",children:[t.jsx(ua,{children:"Expense Account"}),t.jsx(Je,{label:"Expense Account",hideLabel:!0,doctype:"Account",value:e.expense_account||"",onChange:N=>l("expense_account",N)})]})}),t.jsxs(Ed,{label:"Accounting Dimensions",children:[t.jsxs("div",{children:[t.jsx(ua,{children:"Cost Center"}),t.jsx(Je,{label:"Cost Center",hideLabel:!0,doctype:"Cost Center",value:e.cost_center||"",onChange:N=>l("cost_center",N)})]}),t.jsxs("div",{children:[t.jsx(ua,{children:"Project"}),t.jsx(Je,{label:"Project",hideLabel:!0,doctype:"Project",value:e.project||"",onChange:N=>l("project",N)})]})]})]})})})},sSe=({tax:e,rowNo:r,onChange:a,onClose:s,onDelete:n})=>{const i=(o,l)=>a(o,l);return t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"p-0",children:t.jsxs("div",{className:"bg-blue-50/60 dark:bg-blue-900/10 border-b border-blue-200 dark:border-blue-800 px-4 py-3",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("span",{className:"text-xs font-bold text-teal-700 dark:text-teal-300 uppercase tracking-wider",children:["Editing Tax Row #",r]}),t.jsxs("div",{className:"flex gap-1",children:[t.jsx("button",{onClick:n,className:"px-2 py-1 text-[11px] bg-red-500 text-white rounded hover:bg-red-600",children:"Delete"}),t.jsx("button",{onClick:s,className:"px-2 py-1 text-[11px] bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300 rounded hover:bg-gray-300",children:"ESC"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(ua,{required:!0,children:"Type"}),t.jsxs("select",{value:e.charge_type||"",onChange:o=>i("charge_type",o.target.value),className:qf,children:[t.jsx("option",{value:"",children:"Select…"}),t.jsx("option",{value:"Actual",children:"Actual"}),t.jsx("option",{value:"On Net Total",children:"On Net Total"}),t.jsx("option",{value:"On Previous Row Amount",children:"On Previous Row Amount"}),t.jsx("option",{value:"On Previous Row Total",children:"On Previous Row Total"}),t.jsx("option",{value:"On Item Quantity",children:"On Item Quantity"})]})]}),t.jsxs("div",{children:[t.jsx(ua,{children:"Description"}),t.jsx("input",{value:e.description||"",onChange:o=>i("description",o.target.value),className:qf})]}),t.jsxs("div",{children:[t.jsx(ua,{required:!0,children:"Account Head"}),t.jsx(Je,{label:"Account Head",hideLabel:!0,doctype:"Account",value:e.account_head||"",onChange:o=>i("account_head",o)})]}),t.jsxs("div",{className:"flex items-center gap-2 pt-5",children:[t.jsx("input",{type:"checkbox",id:`incl-${r}`,checked:!!e.included_in_print_rate,onChange:o=>i("included_in_print_rate",o.target.checked?1:0),className:"w-4 h-4 text-teal-600 rounded"}),t.jsx("label",{htmlFor:`incl-${r}`,className:"text-sm text-gray-700 dark:text-gray-300",children:"Included in Basic Rate"})]})]}),t.jsxs(Ed,{label:"Accounting Dimensions",children:[t.jsxs("div",{children:[t.jsx(ua,{children:"Cost Center"}),t.jsx(Je,{label:"Cost Center",hideLabel:!0,doctype:"Cost Center",value:e.cost_center||"",onChange:o=>i("cost_center",o)})]}),t.jsxs("div",{children:[t.jsx(ua,{children:"Account Currency"}),t.jsx("input",{value:e.account_currency||"",onChange:o=>i("account_currency",o.target.value),className:qf})]})]})]})})})},nSe=()=>({item_code:"",item_name:"",qty:1,rate:0,amount:0,uom:"",conversion_factor:1}),iSe=()=>({charge_type:"On Net Total",account_head:"",rate:15}),oSe=()=>{var be;const{dnName:e}=hs(),[r]=_a(),a=hr(),s=e==="new",n=r.get("so")||"",i=r.get("customer")||"",o=r.get("company")||un,l=r.get("project")||"",[c,u]=p.useState(null),[h,f]=p.useState(!s),[y,b]=p.useState(!1),[w,v]=p.useState(!1),[k,S]=p.useState(s),[N,C]=p.useState(null),[O,T]=p.useState(null),[P,E]=p.useState([]),R=new Date().toISOString().split("T")[0],[z,G]=p.useState({customer:i,company:o,project:l,posting_date:R,currency:Er,taxes_and_charges:Fp,items:[]}),ae=p.useCallback(K=>{G({customer:K.customer||"",company:K.company||un,project:K.project||"",posting_date:K.posting_date||R,currency:K.currency==="INR"?Er:K.currency||Er,cost_center:K.cost_center||"",items:K.items||[],selling_price_list:K.selling_price_list||"",price_list_currency:K.price_list_currency||"",conversion_rate:K.conversion_rate||1,plc_conversion_rate:K.plc_conversion_rate||1,tax_category:K.tax_category||"",taxes_and_charges:K.taxes_and_charges||""}),E(K.taxes||[])},[R]);p.useEffect(()=>{const K=z.company;!s||!K||fetch(`/api/resource/Company/${encodeURIComponent(K)}`,{credentials:"include"}).then(ye=>ye.json()).then(ye=>{var Z;if((Z=ye.data)!=null&&Z.default_currency){const M=Xn(ye.data.default_currency);G(we=>je(se({},we),{currency:M,selling_price_list:we.selling_price_list||"Standard Selling",price_list_currency:we.price_list_currency||M}))}}).catch(()=>{})},[z.company,s]),p.useEffect(()=>{!s||!n||Io.getSalesOrder(n).then(K=>{var ye;G(Z=>je(se({},Z),{customer:K.customer||Z.customer,company:K.company||Z.company,project:K.project||Z.project,cost_center:K.cost_center||Z.cost_center,currency:K.currency||Z.currency,selling_price_list:K.selling_price_list||"Standard Selling",price_list_currency:K.price_list_currency||K.currency,conversion_rate:K.conversion_rate||1,plc_conversion_rate:K.plc_conversion_rate||1,taxes_and_charges:K.taxes_and_charges||"",tax_category:K.tax_category||"",items:(K.items||[]).map(M=>{var we;return{item_code:M.item_code,item_name:M.item_name,description:M.description||M.item_name||M.item_code,qty:M.qty,uom:M.uom,stock_uom:M.stock_uom,rate:M.rate,amount:M.amount,against_sales_order:n,so_detail:M.name||void 0,conversion_factor:(we=M.conversion_factor)!=null?we:1,warehouse:M.warehouse||void 0,expense_account:M.expense_account||void 0,cost_center:M.cost_center||K.cost_center||void 0,project:M.project||K.project||void 0}})})),K.taxes_and_charges?B(K.taxes_and_charges):(ye=K.taxes)!=null&&ye.length&&E(K.taxes.map(Z=>{var M,we,pe;return{charge_type:Z.charge_type,account_head:Z.account_head,description:Z.description,rate:(we=(M=Z.rate)!=null?M:Z.tax_rate)!=null?we:0,cost_center:Z.cost_center,account_currency:Z.account_currency,included_in_print_rate:(pe=Z.included_in_print_rate)!=null?pe:0}}))}).catch(()=>{})},[s,n]),p.useEffect(()=>{s||(f(!0),tm.getDeliveryNote(e).then(K=>{u(K),ae(K)}).catch(K=>We.error(K.message)).finally(()=>f(!1)))},[e,s,ae]);const ee=(K,ye)=>G(Z=>je(se({},Z),{[K]:ye})),ne=(K,ye,Z)=>G(M=>{const we=[...M.items||[]],pe=je(se({},we[K]),{[ye]:Z});if(ye==="qty"||ye==="rate"){const le=parseFloat(String(ye==="qty"?Z:pe.qty))||0,Fe=parseFloat(String(ye==="rate"?Z:pe.rate))||0;pe.amount=parseFloat((le*Fe).toFixed(4))}return we[K]=pe,je(se({},M),{items:we})}),te=(K,ye)=>J(null,null,function*(){if(ne(K,"item_code",ye),!!ye)try{const we=(yield(yield fetch(`/api/resource/Item/${encodeURIComponent(ye)}`,{credentials:"include"})).json()).data;if(!we)return;G(pe=>{const le=[...pe.items||[]];return le[K]=je(se({},le[K]),{item_code:ye,item_name:we.item_name||ye,stock_uom:we.stock_uom||"",uom:we.sales_uom||we.stock_uom||"",description:we.description||""}),je(se({},pe),{items:le})})}catch(Z){}}),Y=K=>{G(ye=>{const Z=[...ye.items||[]],M=K!==void 0?K+1:Z.length;return Z.splice(M,0,nSe()),je(se({},ye),{items:Z})})},q=K=>{G(ye=>{const Z=[...ye.items||[]];return Z.splice(K,1),je(se({},ye),{items:Z})}),C(null)},H=(K,ye,Z)=>E(M=>{const we=[...M];return we[K]=je(se({},we[K]),{[ye]:Z}),we}),U=()=>E(K=>[...K,iSe()]),re=K=>{E(ye=>{const Z=[...ye];return Z.splice(K,1),Z}),T(null)},X=(z.items||[]).reduce((K,ye)=>K+(ye.amount||0),0),V=P.reduce((K,ye)=>{const Z=Ql(ye);return ye.charge_type==="On Net Total"?K+X*(Z/100):ye.charge_type==="Actual"?K+(ye.tax_amount||0):K+X*(Z/100)},0),I=X+V,B=K=>J(null,null,function*(){var ye;if(K)try{const we=(yield(yield fetch(`/api/resource/Sales Taxes and Charges Template/${encodeURIComponent(K)}`,{credentials:"include"})).json()).data;(ye=we==null?void 0:we.taxes)!=null&&ye.length&&E(we.taxes.map(pe=>{var le;return{charge_type:pe.charge_type,account_head:pe.account_head,description:pe.description,rate:pe.rate,cost_center:pe.cost_center,account_currency:pe.account_currency,included_in_print_rate:(le=pe.included_in_print_rate)!=null?le:0}}))}catch(Z){}});p.useEffect(()=>{!s||n||B(Fp)},[s,n]);const Q=K=>({customer:z.customer,company:z.company||void 0,project:z.project||void 0,cost_center:z.cost_center||void 0,posting_date:z.posting_date,currency:z.currency||void 0,selling_price_list:z.selling_price_list||"Standard Selling",price_list_currency:z.price_list_currency||z.currency||void 0,conversion_rate:z.conversion_rate||1,plc_conversion_rate:z.plc_conversion_rate||1,tax_category:z.tax_category||void 0,taxes_and_charges:z.taxes_and_charges||void 0,items:(K||z.items||[]).filter(ye=>ye.item_code).map((ye,Z)=>{var M,we,pe,le,Fe,ze,Re,De,Et,jt,Ie;return{item_code:ye.item_code,item_name:ye.item_name||ye.item_code,description:ye.description||void 0,qty:(M=ye.qty)!=null?M:1,uom:ye.uom||void 0,stock_uom:ye.stock_uom||void 0,conversion_factor:(we=ye.conversion_factor)!=null?we:1,price_list_rate:(pe=ye.price_list_rate)!=null?pe:0,discount_percentage:(le=ye.discount_percentage)!=null?le:0,discount_amount:(Fe=ye.discount_amount)!=null?Fe:0,rate:(ze=ye.rate)!=null?ze:0,amount:(Re=ye.amount)!=null?Re:0,is_free_item:(De=ye.is_free_item)!=null?De:0,grant_commission:(Et=ye.grant_commission)!=null?Et:0,warehouse:ye.warehouse||void 0,expense_account:ye.expense_account||void 0,cost_center:ye.cost_center||void 0,project:ye.project||z.project||void 0,against_sales_order:ye.against_sales_order||void 0,so_detail:ye.so_detail||void 0,weight_per_unit:(jt=ye.weight_per_unit)!=null?jt:0,total_weight:(Ie=ye.total_weight)!=null?Ie:0,idx:Z+1}}),taxes:P.filter(ye=>ye.account_head).map((ye,Z)=>{var M,we;return{charge_type:ye.charge_type||"On Net Total",account_head:ye.account_head,description:ye.description||ye.account_head,included_in_print_rate:(M=ye.included_in_print_rate)!=null?M:0,rate:(we=ye.rate)!=null?we:0,cost_center:ye.cost_center||void 0,account_currency:ye.account_currency||void 0,idx:Z+1}})}),ie=K=>J(null,null,function*(){const ye=K.filter(M=>M.against_sales_order&&!M.so_detail);if(!ye.length)return K;const Z=ye[0].against_sales_order;try{const pe=((yield(yield fetch(`/api/resource/Sales%20Order%20Item?filters=${encodeURIComponent(JSON.stringify([["parent","=",Z]]))}&fields=${encodeURIComponent(JSON.stringify(["name","item_code","idx"]))}&limit=100`,{credentials:"include"})).json()).data||[]).sort((Fe,ze)=>(Fe.idx||0)-(ze.idx||0)),le=new Set;return K.map(Fe=>{if(!Fe.against_sales_order||Fe.so_detail)return Fe;const ze=pe.find(Re=>Re.item_code===Fe.item_code&&!le.has(Re.name));return ze?(le.add(ze.name),je(se({},Fe),{so_detail:ze.name})):Fe})}catch(M){return K}}),me=()=>J(null,null,function*(){if(!z.customer){We.error("Customer is required");return}try{b(!0);const K=yield ie([...z.items||[]]);if(s){const ye=yield tm.createDeliveryNote(Q(K));We.success("Delivery Note created"),S(!1),a(`/delivery-notes/${ye.name}`)}else{const ye=yield tm.updateDeliveryNote(e,Q(K));u(ye),ae(ye),We.success("Delivery Note saved"),S(!1)}}catch(K){We.error(ti(K)||"Error saving")}finally{b(!1)}}),he=()=>J(null,null,function*(){if(!(!e||s))try{v(!0);const K=yield tm.submitDeliveryNote(e);u(K),ae(K),We.success("Delivery Note submitted")}catch(K){We.error(ti(K)||"Error submitting")}finally{v(!1)}}),de=()=>{const K=new URLSearchParams;K.set("dn",e),z.customer&&K.set("customer",z.customer),z.company&&K.set("company",String(z.company)),z.project&&K.set("project",String(z.project)),a(`/invoices/new?${K.toString()}`)},xe=s||k,ge=!s&&(c==null?void 0:c.docstatus)===1;return h?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsx(tr,{className:"animate-spin text-teal-500 text-3xl"})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 px-6 py-6",children:[t.jsx($a,{position:"top-right",autoClose:3500}),t.jsxs("div",{className:"flex items-center gap-2 text-sm mb-6 text-gray-500",children:[t.jsx("button",{onClick:()=>a("/projects"),className:"hover:text-indigo-600",children:"Project Management"}),t.jsx("span",{children:"/"}),t.jsx("button",{onClick:()=>a("/delivery-notes"),className:"hover:text-indigo-600",children:"Delivery Notes"}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:s?"New Delivery Note":e})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 dark:border-gray-700 flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>a("/delivery-notes"),className:"text-gray-400 hover:text-gray-700",children:t.jsx(ia,{})}),t.jsx(G1,{className:"text-teal-500"}),t.jsx("div",{children:t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:s?"New Delivery Note":z.customer||e}),!s&&t.jsx("span",{className:"text-sm text-gray-400 font-normal",children:e}),!s&&t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${(()=>{const K=(c==null?void 0:c.status)||"";return(c==null?void 0:c.docstatus)===2||K==="Cancelled"?"bg-red-100 text-red-700":!c||c.docstatus===0?"bg-yellow-100 text-yellow-800":K==="Completed"?"bg-green-100 text-green-800":K==="To Bill"?"bg-blue-100 text-blue-800":K==="Return Issued"?"bg-orange-100 text-orange-800":K==="Closed"?"bg-gray-100 text-gray-700":"bg-green-100 text-green-800"})()}`,children:(c==null?void 0:c.docstatus)===2?"Cancelled":(c==null?void 0:c.docstatus)===0?"Draft":(c==null?void 0:c.status)||"Submitted"})]})})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[ge&&t.jsx(rSe,{items:[{label:"Sales Invoice",icon:t.jsx(xm,{size:13}),onClick:de}]}),!s&&!k&&(c==null?void 0:c.docstatus)===0&&t.jsxs("button",{onClick:he,disabled:w,className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 text-sm font-medium",children:[w?t.jsx(tr,{className:"animate-spin"}):t.jsx(Lm,{size:12})," Submit"]}),!s&&!k&&!ge&&t.jsxs("button",{onClick:()=>S(!0),className:"flex items-center gap-2 px-4 py-2 border border-teal-500 text-teal-600 rounded-lg hover:bg-teal-50 text-sm",children:[t.jsx(qr,{})," Edit"]}),xe&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:me,disabled:y,className:"flex items-center gap-2 px-4 py-2 bg-teal-600 text-white rounded-lg hover:bg-teal-700 disabled:opacity-50 text-sm font-medium",children:[y?t.jsx(tr,{className:"animate-spin"}):t.jsx(ta,{}),y?"Saving…":"Save"]}),!s&&t.jsx("button",{onClick:()=>{c&&ae(c),S(!1)},className:"px-3 py-2 border border-gray-300 rounded-lg text-gray-600 text-sm",children:t.jsx(ht,{})})]})]})]}),t.jsx("div",{className:"px-6 pt-5 pb-4",children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-4",children:[t.jsxs("div",{children:[t.jsx(ua,{required:!0,children:"Customer"}),xe?t.jsx(Je,{label:"Customer",hideLabel:!0,doctype:"Customer",value:z.customer||"",onChange:K=>ee("customer",K),placeholder:"Select customer…"}):t.jsx(cl,{children:z.customer})]}),t.jsxs("div",{children:[t.jsx(ua,{required:!0,children:"Posting Date"}),xe?t.jsx("input",{type:"date",value:z.posting_date||"",onChange:K=>ee("posting_date",K.target.value),className:s9}):t.jsx(cl,{children:z.posting_date})]}),t.jsxs("div",{children:[t.jsx(ua,{children:"Company"}),xe?t.jsx(Je,{label:"Company",hideLabel:!0,doctype:"Company",value:z.company||"",onChange:K=>ee("company",K),placeholder:"Select company…"}):t.jsx(cl,{children:z.company})]}),t.jsxs("div",{children:[t.jsx(ua,{children:"Project"}),xe?t.jsx(Je,{label:"Project",hideLabel:!0,doctype:"Project",value:z.project||"",onChange:K=>ee("project",K),placeholder:"Select project…"}):t.jsx(cl,{children:z.project})]}),t.jsxs("div",{children:[t.jsx(ua,{children:"Currency"}),xe?t.jsxs("select",{value:z.currency||Er,onChange:K=>ee("currency",K.target.value),className:s9,children:[t.jsx("option",{value:"SAR",children:"SAR"}),t.jsx("option",{value:"USD",children:"USD"}),t.jsx("option",{value:"EUR",children:"EUR"})]}):t.jsx(cl,{children:z.currency})]}),t.jsxs("div",{children:[t.jsx(ua,{children:"Cost Center"}),xe?t.jsx(Je,{label:"Cost Center",hideLabel:!0,doctype:"Cost Center",value:z.cost_center||"",onChange:K=>ee("cost_center",K)}):t.jsx(cl,{children:z.cost_center})]}),n&&t.jsxs("div",{children:[t.jsx(ua,{children:"Against Sales Order"}),t.jsx(cl,{children:n})]})]})}),t.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700",children:[t.jsx("div",{className:"px-6 py-3 bg-gray-50 dark:bg-gray-900/20 border-b border-gray-100 dark:border-gray-700",children:t.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Items"})}),t.jsx("div",{className:"px-6 pb-4",children:t.jsx("div",{className:"overflow-x-auto -mx-2 mt-3",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-8",children:"No."}),t.jsxs("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 min-w-[180px]",children:["Item Code ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsxs("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:["UOM ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsxs("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-24",children:["Qty ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsxs("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:["Rate (",z.currency||Er,")"]}),t.jsxs("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:["Amount (",z.currency||Er,")"]}),xe&&t.jsx("th",{className:"w-16 py-2 px-2"})]})}),t.jsxs("tbody",{children:[(z.items||[]).map((K,ye)=>{var Z,M,we,pe;return t.jsxs(gr.Fragment,{children:[t.jsxs("tr",{className:`border-b border-gray-100 dark:border-gray-700 align-middle ${N===ye?"bg-blue-50/60 dark:bg-blue-900/10":""}`,children:[t.jsx("td",{className:"py-1.5 px-3 text-gray-400 text-xs",children:ye+1}),t.jsx("td",{className:"py-1.5 px-2 min-w-[180px]",children:xe?t.jsx(Je,{label:"Item",hideLabel:!0,doctype:"Item",value:K.item_code||"",onChange:le=>te(ye,le),placeholder:"Item Code"}):t.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-200",children:K.item_code||"-"})}),t.jsx("td",{className:"py-1.5 px-2 w-28",children:xe?t.jsx(Je,{label:"UOM",hideLabel:!0,doctype:"UOM",value:K.uom||"",onChange:le=>ne(ye,"uom",le),placeholder:"UOM"}):t.jsx("span",{className:"text-gray-500 text-sm",children:K.uom||"-"})}),t.jsx("td",{className:"py-1.5 px-2 w-24",children:xe?t.jsx("input",{type:"number",min:0,step:"1",value:(Z=K.qty)!=null?Z:1,onChange:le=>ne(ye,"qty",parseFloat(le.target.value)||0),className:dN}):t.jsx("span",{className:"block text-right text-sm pr-1",children:(M=K.qty)!=null?M:0})}),t.jsx("td",{className:"py-1.5 px-2 w-28",children:xe?t.jsx("input",{type:"number",min:0,step:"0.01",value:(we=K.rate)!=null?we:0,onChange:le=>ne(ye,"rate",parseFloat(le.target.value)||0),className:dN}):t.jsx("span",{className:"block text-right text-sm pr-1",children:((pe=K.rate)!=null?pe:0).toFixed(2)})}),t.jsx("td",{className:"py-1.5 px-3 text-right font-semibold text-gray-900 dark:text-white text-sm",children:((K.qty||0)*(K.rate||0)).toFixed(2)}),xe&&t.jsx("td",{className:"py-1.5 px-2",children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>C(N===ye?null:ye),className:`p-1.5 rounded text-xs ${N===ye?"bg-teal-600 text-white":"text-teal-600 hover:bg-teal-50"}`,title:"More fields",children:t.jsx(xl,{size:11})}),t.jsx("button",{onClick:()=>q(ye),className:"p-1.5 text-red-400 hover:text-red-600 hover:bg-red-50 rounded",children:t.jsx(wr,{size:11})})]})})]}),xe&&N===ye&&t.jsx(aSe,{item:K,rowNo:ye+1,currency:z.currency||Er,onChange:(le,Fe)=>{le==="item_code"?te(ye,Fe):ne(ye,le,Fe)},onClose:()=>C(null),onDelete:()=>q(ye),onInsertBelow:()=>Y(ye)})]},ye)}),xe&&t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"py-2 px-3",children:t.jsxs("button",{onClick:()=>Y(),className:"flex items-center gap-1.5 text-teal-600 hover:text-teal-700 text-sm font-medium",children:[t.jsx(Rr,{size:10})," Add Row"]})})})]})]})})})]}),t.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700",children:[t.jsx("div",{className:"px-6 py-3 bg-gray-50 dark:bg-gray-900/20 border-b border-gray-100 dark:border-gray-700",children:t.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Taxes and Charges"})}),t.jsxs("div",{className:"px-6 pt-4 pb-2 grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-3",children:[t.jsxs("div",{children:[t.jsx(ua,{children:"Tax Category"}),xe?t.jsx(Je,{label:"Tax Category",hideLabel:!0,doctype:"Tax Category",value:z.tax_category||"",onChange:K=>ee("tax_category",K),placeholder:"Select tax category…"}):t.jsx(cl,{children:z.tax_category})]}),t.jsxs("div",{children:[t.jsx(ua,{children:"Sales Taxes and Charges Template"}),xe?t.jsx(Je,{label:"Sales Taxes and Charges Template",hideLabel:!0,doctype:"Sales Taxes and Charges Template",value:z.taxes_and_charges||"",onChange:K=>{ee("taxes_and_charges",K),B(K)},placeholder:"Select template…"}):t.jsx(cl,{children:z.taxes_and_charges})]})]}),t.jsx("div",{className:"px-6 pb-4 mt-3",children:t.jsx("div",{className:"overflow-x-auto -mx-2",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-8",children:"No."}),t.jsxs("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-36",children:["Type ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsxs("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 min-w-[180px]",children:["Account Head ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-24",children:"Tax Rate"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:"Amount"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:"Total"}),xe&&t.jsx("th",{className:"w-16 py-2 px-2"})]})}),t.jsxs("tbody",{children:[P.map((K,ye)=>{var we,pe;const Z=K.charge_type==="On Net Total"?X*((K.rate||0)/100):K.tax_amount||0,M=X+P.slice(0,ye+1).reduce((le,Fe)=>le+(Fe.charge_type==="On Net Total"?X*((Fe.rate||0)/100):Fe.tax_amount||0),0);return t.jsxs(gr.Fragment,{children:[t.jsxs("tr",{className:`border-b border-gray-100 dark:border-gray-700 align-middle ${O===ye?"bg-blue-50/60 dark:bg-blue-900/10":""}`,children:[t.jsx("td",{className:"py-1.5 px-3 text-gray-400 text-xs",children:ye+1}),t.jsx("td",{className:"py-1.5 px-2 w-36",children:xe?t.jsxs("select",{value:K.charge_type||"",onChange:le=>H(ye,"charge_type",le.target.value),className:tSe,children:[t.jsx("option",{value:"",children:"Type…"}),t.jsx("option",{value:"Actual",children:"Actual"}),t.jsx("option",{value:"On Net Total",children:"On Net Total"}),t.jsx("option",{value:"On Previous Row Amount",children:"On Previous Row Amount"})]}):t.jsx("span",{className:"text-sm text-gray-700",children:K.charge_type||"-"})}),t.jsx("td",{className:"py-1.5 px-2 min-w-[180px]",children:xe?t.jsx(Je,{label:"Account Head",hideLabel:!0,doctype:"Account",value:K.account_head||"",onChange:le=>H(ye,"account_head",le),placeholder:"Account…"}):t.jsx("span",{className:"text-sm text-gray-700",children:K.account_head||"-"})}),t.jsx("td",{className:"py-1.5 px-2 w-24",children:xe?t.jsx("input",{type:"number",min:0,step:"0.01",value:(we=K.rate)!=null?we:0,onChange:le=>H(ye,"rate",parseFloat(le.target.value)||0),className:dN}):t.jsx("span",{className:"block text-right text-sm pr-1",children:(pe=K.rate)!=null?pe:0})}),t.jsx("td",{className:"py-1.5 px-3 text-right text-sm text-gray-700 dark:text-gray-300",children:Z.toFixed(2)}),t.jsx("td",{className:"py-1.5 px-3 text-right text-sm font-semibold text-gray-900 dark:text-white",children:M.toFixed(2)}),xe&&t.jsx("td",{className:"py-1.5 px-2",children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>T(O===ye?null:ye),className:`p-1.5 rounded text-xs ${O===ye?"bg-teal-600 text-white":"text-teal-600 hover:bg-teal-50"}`,children:t.jsx(xl,{size:11})}),t.jsx("button",{onClick:()=>re(ye),className:"p-1.5 text-red-400 hover:text-red-600 hover:bg-red-50 rounded",children:t.jsx(wr,{size:11})})]})})]}),xe&&O===ye&&t.jsx(sSe,{tax:K,rowNo:ye+1,onChange:(le,Fe)=>H(ye,le,Fe),onClose:()=>T(null),onDelete:()=>re(ye)})]},ye)}),xe&&t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"py-2 px-3",children:t.jsxs("button",{onClick:U,className:"flex items-center gap-1.5 text-teal-600 hover:text-teal-700 text-sm font-medium",children:[t.jsx(Rr,{size:10})," Add Tax Row"]})})})]})]})})})]}),t.jsx("div",{className:"border-t border-gray-100 dark:border-gray-700 px-6 py-4",children:t.jsx("div",{className:"flex justify-end",children:t.jsxs("div",{className:"w-full max-w-xs space-y-2 text-sm",children:[t.jsxs("div",{className:"flex justify-between text-gray-600 dark:text-gray-400",children:[t.jsxs("span",{children:["Net Total (",Xn(z.currency),")"]}),t.jsx("span",{className:"font-medium",children:X.toFixed(2)})]}),t.jsxs("div",{className:"flex justify-between text-gray-600 dark:text-gray-400",children:[t.jsxs("span",{children:["Total Taxes and Charges (",Xn(z.currency),")"]}),t.jsx("span",{className:"font-medium",children:((be=c==null?void 0:c.total_taxes_and_charges)!=null?be:V).toFixed(2)})]}),t.jsxs("div",{className:"flex justify-between font-bold text-gray-900 dark:text-white border-t border-gray-200 dark:border-gray-700 pt-2 text-base",children:[t.jsxs("span",{children:["Grand Total (",Xn(z.currency),")"]}),t.jsx("span",{children:I.toFixed(2)})]})]})})}),!s&&c&&t.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700 px-6 py-4 grid grid-cols-3 gap-4 text-sm bg-gray-50 dark:bg-gray-900/20",children:[t.jsxs("div",{children:[t.jsx(ua,{children:"Created By"}),t.jsx(cl,{children:c.owner})]}),t.jsxs("div",{children:[t.jsx(ua,{children:"Created"}),t.jsx(cl,{children:c.creation?new Date(c.creation).toLocaleString():"-"})]}),t.jsxs("div",{children:[t.jsx(ua,{children:"Modified"}),t.jsx(cl,{children:c.modified?new Date(c.modified).toLocaleString():"-"})]})]}),!s&&t.jsx(vi,{doctype:"Delivery Note",docname:(c==null?void 0:c.name)||e||"",creationDate:c==null?void 0:c.creation,createdBy:c==null?void 0:c.owner,compact:!1,initialVisible:5,collapsible:!0,startCollapsed:!0})]})]})},H0=20;function lSe(e){const r=[];return e.search&&r.push(["Material Request","name","like",`%${e.search}%`]),e.status==="Draft"&&r.push(["Material Request","docstatus","=",0]),e.status==="Submitted"&&r.push(["Material Request","docstatus","=",1]),e.status==="Cancelled"&&r.push(["Material Request","docstatus","=",2]),e.type&&r.push(["Material Request","material_request_type","=",e.type]),r}function cSe(e){return e.docstatus===2?"bg-red-100 text-red-700":e.docstatus===1?"bg-green-100 text-green-700":"bg-yellow-100 text-yellow-800"}function dSe(e){return e.docstatus===2?"Cancelled":e.docstatus===1?e.status||"Submitted":e.status||"Draft"}const uSe=()=>{const{t:e}=sr(),r=hr(),[a,s]=p.useState([]),[n,i]=p.useState(!0),[o,l]=p.useState(0),[c,u]=p.useState(0),[h,f]=p.useState(!1),[y,b]=p.useState(""),[w,v]=p.useState(""),[k,S]=p.useState(""),[N,C]=p.useState({search:"",status:"",type:""}),[O,T]=p.useState(!1),P=p.useCallback((U,re)=>J(null,null,function*(){i(!0);try{const X=[];re.search&&X.push(["Material Request","name","like",`%${re.search}%`]),re.status==="Draft"&&X.push(["Material Request","docstatus","=",0]),re.status==="Submitted"&&X.push(["Material Request","docstatus","=",1]),re.status==="Cancelled"&&X.push(["Material Request","docstatus","=",2]),re.type&&X.push(["Material Request","material_request_type","=",re.type]);const[V,I]=yield Promise.all([am.getMaterialRequests({filters:X,limit_start:U,limit_page_length:H0}),am.getMaterialRequestCount(X)]);s(V),l(I)}catch(X){We.error(X.message||"Failed to load")}finally{i(!1)}}),[]);p.useEffect(()=>{P(0,N)},[P,N]);const E=p.useMemo(()=>`${c}|${N.search}|${N.status}|${N.type}`,[c,N.search,N.status,N.type]),{selectedRows:R,toggleRow:z,toggleAllOnPage:G,allOnPageSelected:ae,someOnPageSelected:ee}=po(a,E),ne=()=>{C({search:y,status:w,type:k}),u(0)},te=()=>{b(""),v(""),S(""),C({search:"",status:"",type:""}),u(0)},Y=!!(N.search||N.status||N.type),q=U=>{u(U),P(U*H0,N)},H=p.useCallback(()=>go({doctype:"Material Request",filters:lSe(N),orderBy:"modified desc"}),[N]);return t.jsxs("div",{className:"p-6",children:[t.jsx($a,{position:"top-right",autoClose:3e3}),t.jsxs("div",{className:"flex items-center justify-between mb-6 gap-4 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl bg-orange-500 flex items-center justify-center",children:t.jsx(zd,{className:"text-white text-base"})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:"Material Requests"}),t.jsxs("p",{className:"text-xs text-gray-500",children:[o," total"]})]})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("button",{onClick:()=>P(c*H0,N),className:"p-2 text-gray-500 hover:text-indigo-600 border border-gray-200 rounded-lg",children:t.jsx(Ma,{size:13})}),t.jsxs("button",{type:"button",onClick:()=>T(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all text-sm font-medium disabled:opacity-50",disabled:o===0&&R.size===0,children:[t.jsx(Sa,{})," ",e("listPages.export"),R.size>0&&t.jsx("span",{className:"bg-white/25 px-1.5 py-0.5 rounded text-xs font-bold",children:R.size})]}),t.jsxs("button",{onClick:()=>r("/material-requests/new"),className:"flex items-center gap-2 px-4 py-2 bg-orange-500 text-white rounded-lg hover:bg-orange-600 text-sm font-medium",children:[t.jsx(Rr,{size:11})," New Request"]})]})]}),t.jsx(bi,{isOpen:O,onClose:()=>T(!1),doctype:"Material Request",selectedCount:R.size,pageCount:a.length,totalCount:o,pageData:a,selectedRows:R,rowKey:"name",onFetchAll:H,fileNamePrefix:"material_requests"}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl mb-5 overflow-hidden",children:[t.jsxs("button",{onClick:()=>f(U=>!U),className:"w-full flex items-center justify-between px-4 py-3 bg-gradient-to-r from-indigo-600 to-indigo-700 text-white",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[t.jsx(za,{size:12})," Filters ",Y&&t.jsx("span",{className:"bg-white/30 text-white text-xs px-2 py-0.5 rounded-full",children:"Active"})]}),h?t.jsx(Ja,{size:11}):t.jsx(Fr,{size:11})]}),Y&&t.jsxs("div",{className:"px-4 py-2 bg-indigo-50 dark:bg-indigo-900/20 flex flex-wrap gap-2 items-center border-b border-indigo-100",children:[N.search&&t.jsxs("span",{className:"flex items-center gap-1 text-xs bg-indigo-100 text-indigo-700 px-2 py-1 rounded-full",children:["ID: ",N.search,t.jsx("button",{onClick:()=>{b(""),C(U=>je(se({},U),{search:""}))},children:t.jsx(ht,{size:9})})]}),N.status&&t.jsxs("span",{className:"flex items-center gap-1 text-xs bg-indigo-100 text-indigo-700 px-2 py-1 rounded-full",children:["Status: ",N.status,t.jsx("button",{onClick:()=>{v(""),C(U=>je(se({},U),{status:""}))},children:t.jsx(ht,{size:9})})]}),N.type&&t.jsxs("span",{className:"flex items-center gap-1 text-xs bg-indigo-100 text-indigo-700 px-2 py-1 rounded-full",children:["Type: ",N.type,t.jsx("button",{onClick:()=>{S(""),C(U=>je(se({},U),{type:""}))},children:t.jsx(ht,{size:9})})]}),t.jsx("button",{onClick:te,className:"text-xs text-indigo-600 hover:underline ml-auto",children:"Clear All"})]}),h&&t.jsxs("div",{className:"px-4 py-3 grid grid-cols-1 sm:grid-cols-4 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[11px] font-semibold text-gray-500 uppercase tracking-wide mb-1",children:"Request ID"}),t.jsx("input",{value:y,onChange:U=>b(U.target.value),onKeyDown:U=>U.key==="Enter"&&ne(),placeholder:"Search…",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-400"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[11px] font-semibold text-gray-500 uppercase tracking-wide mb-1",children:"Type"}),t.jsxs("select",{value:k,onChange:U=>S(U.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-400",children:[t.jsx("option",{value:"",children:"All"}),t.jsx("option",{value:"Purchase",children:"Purchase"}),t.jsx("option",{value:"Material Transfer",children:"Material Transfer"}),t.jsx("option",{value:"Manufacture",children:"Manufacture"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[11px] font-semibold text-gray-500 uppercase tracking-wide mb-1",children:"Status"}),t.jsxs("select",{value:w,onChange:U=>v(U.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-400",children:[t.jsx("option",{value:"",children:"All"}),t.jsx("option",{value:"Draft",children:"Draft"}),t.jsx("option",{value:"Submitted",children:"Submitted"}),t.jsx("option",{value:"Cancelled",children:"Cancelled"})]})]}),t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsx("button",{onClick:ne,className:"px-4 py-2 bg-indigo-600 text-white text-sm rounded hover:bg-indigo-700",children:"Apply"}),t.jsx("button",{onClick:te,className:"px-4 py-2 border border-gray-300 text-gray-600 text-sm rounded hover:bg-gray-50",children:"Clear"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl overflow-hidden",children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx("th",{className:"w-10 px-2 py-3",children:t.jsx("input",{type:"checkbox",className:"rounded border-gray-300 dark:border-gray-600 text-orange-600 focus:ring-orange-500",checked:ae,ref:U=>{U&&(U.indeterminate=ee)},onChange:G,"aria-label":"Select all on page"})}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Request ID"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Type"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Date"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Company"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Status"})]})}),t.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:n?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"text-center py-10 text-gray-400",children:"Loading…"})}):a.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"text-center py-10 text-gray-400",children:"No material requests found"})}):a.map(U=>t.jsxs("tr",{onClick:()=>r(`/material-requests/${U.name}`),className:`cursor-pointer hover:bg-orange-50 dark:hover:bg-orange-900/10 transition-colors ${R.has(U.name)?"bg-orange-50/90 dark:bg-orange-900/20":""}`,children:[t.jsx("td",{className:"w-10 px-2 py-3",onClick:re=>re.stopPropagation(),children:t.jsx("input",{type:"checkbox",className:"rounded border-gray-300 dark:border-gray-600 text-orange-600 focus:ring-orange-500",checked:R.has(U.name),onChange:()=>z(U.name),"aria-label":`Select ${U.name}`})}),t.jsx("td",{className:"py-3 px-4 font-medium text-orange-600",children:U.name}),t.jsx("td",{className:"py-3 px-4 text-gray-700 dark:text-gray-300",children:U.material_request_type||"-"}),t.jsx("td",{className:"py-3 px-4 text-gray-500",children:U.transaction_date||"-"}),t.jsx("td",{className:"py-3 px-4 text-gray-500",children:U.company||"-"}),t.jsx("td",{className:"py-3 px-4",children:t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${cSe(U)}`,children:dSe(U)})})]},U.name))})]})}),o>H0&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-100 dark:border-gray-700",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:[c*H0+1,"–",Math.min((c+1)*H0,o)," of ",o]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:c===0,onClick:()=>q(c-1),className:"px-3 py-1 text-xs border border-gray-300 rounded disabled:opacity-40",children:"Prev"}),t.jsx("button",{disabled:(c+1)*H0>=o,onClick:()=>q(c+1),className:"px-3 py-1 text-xs border border-gray-300 rounded disabled:opacity-40",children:"Next"})]})]})]})]})},On=({children:e,required:r})=>t.jsxs("label",{className:"block text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1",children:[e,r&&t.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),Qb=({children:e})=>t.jsx("div",{className:"px-3 py-2 text-sm text-gray-800 dark:text-gray-200 bg-gray-50 dark:bg-gray-800/60 rounded-lg min-h-[38px] flex items-center",children:e||t.jsx("span",{className:"text-gray-400",children:"-"})}),n9="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-orange-400",mSe="w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-orange-400",hSe="w-full px-2 py-1 text-sm text-right border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-orange-400",uN="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-orange-400",mN="w-full px-3 py-2 text-sm text-right border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-orange-400",i9=({title:e,icon:r,defaultOpen:a=!0,children:s})=>{const[n,i]=p.useState(a);return t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden shadow-sm",children:[t.jsxs("button",{type:"button",onClick:()=>i(o=>!o),className:"w-full flex items-center justify-between px-5 py-3.5 hover:bg-gray-50 dark:hover:bg-gray-700/30 transition-colors text-left",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-gray-700 dark:text-gray-200",children:[r,t.jsx("span",{children:e})]}),n?t.jsx(Fr,{className:"text-gray-400 text-xs flex-shrink-0"}):t.jsx(Fi,{className:"text-gray-400 text-xs flex-shrink-0"})]}),n&&t.jsx("div",{className:"px-5 py-5 bg-white dark:bg-gray-800 border-t border-gray-100 dark:border-gray-700/50",children:s})]})},Qh=({label:e,children:r,defaultOpen:a=!1})=>{const[s,n]=p.useState(a);return t.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden mt-3",children:[t.jsxs("button",{type:"button",onClick:()=>n(i=>!i),className:"w-full flex items-center gap-2 px-3 py-2 text-[11px] font-bold text-gray-500 uppercase tracking-wider bg-gray-50 dark:bg-gray-800/80 hover:bg-gray-100 transition-colors text-left",children:[s?t.jsx(Fr,{size:9}):t.jsx(Fi,{size:9}),e]}),s&&t.jsx("div",{className:"p-3 grid grid-cols-1 sm:grid-cols-2 gap-3 bg-white dark:bg-gray-800",children:r})]})},pSe=({items:e})=>{const[r,a]=p.useState(!1),s=p.useRef(null);return p.useEffect(()=>{const n=i=>{s.current&&!s.current.contains(i.target)&&a(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[]),t.jsxs("div",{className:"relative",ref:s,children:[t.jsxs("button",{onClick:()=>a(n=>!n),className:"flex items-center gap-1.5 px-4 py-2 bg-amber-600 text-white rounded-lg hover:bg-amber-700 text-sm font-medium shadow-sm",children:["Create ",t.jsx(Fr,{size:10,className:`transition-transform ${r?"rotate-180":""}`})]}),r&&t.jsxs("div",{className:"absolute right-0 mt-1 w-52 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl shadow-xl z-50 py-1.5",children:[t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-bold text-gray-400 uppercase tracking-wider border-b border-gray-100 dark:border-gray-700 mb-1",children:"Create from this request"}),e.map(({label:n,icon:i,onClick:o})=>t.jsxs("button",{onClick:()=>{o(),a(!1)},className:"w-full flex items-center gap-3 px-4 py-2.5 text-sm text-gray-700 dark:text-gray-300 hover:bg-amber-50 dark:hover:bg-amber-900/20 hover:text-amber-700 transition-colors text-left",children:[t.jsx("span",{className:"text-gray-400",children:i}),n]},n))]})]})},gSe=({item:e,rowNo:r,onChange:a,onClose:s,onDelete:n,onInsertBelow:i})=>{var l,c,u;const o=(h,f)=>a(h,f);return t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"p-0",children:t.jsxs("div",{className:"bg-amber-50/60 dark:bg-amber-900/10 border-b border-amber-200 dark:border-amber-800 px-4 py-3",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("span",{className:"text-xs font-bold text-amber-700 dark:text-amber-300 uppercase tracking-wider",children:["Editing Row #",r]}),t.jsxs("div",{className:"flex gap-1",children:[t.jsx("button",{onClick:i,className:"px-2 py-1 text-[11px] bg-amber-600 text-white rounded hover:bg-amber-700",children:"Insert Below"}),t.jsx("button",{onClick:n,className:"px-2 py-1 text-[11px] bg-red-500 text-white rounded hover:bg-red-600",children:"Delete"}),t.jsx("button",{onClick:s,className:"px-2 py-1 text-[11px] bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300 rounded hover:bg-gray-300",children:"ESC"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(On,{required:!0,children:"Item Code"}),t.jsx(Je,{label:"Item Code",hideLabel:!0,doctype:"Item",value:e.item_code||"",onChange:h=>o("item_code",h)})]}),t.jsxs("div",{children:[t.jsx(On,{required:!0,children:"Required By"}),t.jsx("input",{type:"date",value:e.schedule_date||"",onChange:h=>o("schedule_date",h.target.value),className:uN})]}),t.jsxs("div",{children:[t.jsx(On,{children:"Item Name"}),t.jsx("input",{value:e.item_name||"",onChange:h=>o("item_name",h.target.value),className:uN})]})]}),t.jsx(Qh,{label:"Description",children:t.jsxs("div",{className:"sm:col-span-2",children:[t.jsx(On,{children:"Description"}),t.jsx("textarea",{value:e.description||"",onChange:h=>o("description",h.target.value),rows:2,className:uN+" resize-none"})]})}),t.jsxs(Qh,{label:"Quantity and Warehouse",defaultOpen:!0,children:[t.jsxs("div",{children:[t.jsx(On,{required:!0,children:"Quantity"}),t.jsx("input",{type:"number",min:0,step:"1",value:(l=e.qty)!=null?l:1,onChange:h=>o("qty",parseFloat(h.target.value)||0),className:mN})]}),t.jsxs("div",{children:[t.jsx(On,{required:!0,children:"UOM"}),t.jsx(Je,{label:"UOM",hideLabel:!0,doctype:"UOM",value:e.uom||"",onChange:h=>o("uom",h)})]}),t.jsxs("div",{children:[t.jsx(On,{children:"Stock UOM"}),t.jsx(Je,{label:"Stock UOM",hideLabel:!0,doctype:"UOM",value:e.stock_uom||"",onChange:h=>o("stock_uom",h)})]}),t.jsxs("div",{children:[t.jsx(On,{children:"UOM Conversion Factor"}),t.jsx("input",{type:"number",min:0,step:"0.0001",value:(c=e.conversion_factor)!=null?c:1,onChange:h=>o("conversion_factor",parseFloat(h.target.value)||1),className:mN})]}),t.jsxs("div",{children:[t.jsx(On,{children:"Target Warehouse"}),t.jsx(Je,{label:"Target Warehouse",hideLabel:!0,doctype:"Warehouse",value:e.warehouse||"",onChange:h=>o("warehouse",h)})]})]}),t.jsx(Qh,{label:"Rate",children:t.jsxs("div",{children:[t.jsx(On,{children:"Rate"}),t.jsx("input",{type:"number",min:0,step:"0.01",value:(u=e.rate)!=null?u:0,onChange:h=>o("rate",parseFloat(h.target.value)||0),className:mN})]})}),t.jsx(Qh,{label:"Accounting Details",children:t.jsxs("div",{className:"sm:col-span-2",children:[t.jsx(On,{children:"Expense Account"}),t.jsx(Je,{label:"Expense Account",hideLabel:!0,doctype:"Account",value:e.expense_account||"",onChange:h=>o("expense_account",h)})]})}),t.jsx(Qh,{label:"Manufacturing",children:t.jsxs("div",{children:[t.jsx(On,{children:"BOM No"}),t.jsx(Je,{label:"BOM No",hideLabel:!0,doctype:"BOM",value:e.bom_no||"",onChange:h=>o("bom_no",h)})]})}),t.jsxs(Qh,{label:"Accounting Dimensions",children:[t.jsxs("div",{children:[t.jsx(On,{children:"Cost Center"}),t.jsx(Je,{label:"Cost Center",hideLabel:!0,doctype:"Cost Center",value:e.cost_center||"",onChange:h=>o("cost_center",h)})]}),t.jsxs("div",{children:[t.jsx(On,{children:"Project"}),t.jsx(Je,{label:"Project",hideLabel:!0,doctype:"Project",value:e.project||"",onChange:h=>o("project",h)})]})]})]})})})},o9=e=>({item_code:"",item_name:"",qty:1,uom:"",schedule_date:e}),fSe=()=>{const{mrName:e}=hs(),[r]=_a(),a=hr(),s=e==="new",n=r.get("project")||"",i=r.get("customer")||"",o=r.get("company")||un,[l,c]=p.useState(null),[u,h]=p.useState(!s),[f,y]=p.useState(!1),[b,w]=p.useState(!1),[v,k]=p.useState(s),[S,N]=p.useState(null),[C,O]=p.useState(!0),[T,P]=p.useState(null),E=new Date().toISOString().split("T")[0],[R,z]=p.useState({material_request_type:"Purchase",company:o,project:n,customer:i,transaction_date:E,schedule_date:E,items:[o9(E)]}),G=p.useCallback(he=>{const de=(he.items||[]).map(xe=>je(se({},xe),{schedule_date:xe.schedule_date||xe.required_by||""}));z({material_request_type:he.material_request_type||"Purchase",company:he.company||un,project:he.project||"",customer:he.customer||"",transaction_date:he.transaction_date||E,schedule_date:he.schedule_date||E,items:de})},[E]),ae=p.useCallback(()=>{s||!e||(h(!0),am.getMaterialRequest(e).then(he=>{c(he),G(he)}).catch(he=>We.error(he.message)).finally(()=>h(!1)))},[s,e,G]);p.useEffect(()=>{ae()},[ae]),p.useEffect(()=>{Iu.getWorkflowInfo("Material Request").then(he=>P(!!he)).catch(()=>P(!1))},[]);const ee=p.useCallback(he=>{O(he.canEdit)},[]),ne=(he,de)=>z(xe=>je(se({},xe),{[he]:de})),te=(he,de,xe)=>z(ge=>{const be=[...ge.items||[]];return be[he]=je(se({},be[he]),{[de]:xe}),je(se({},ge),{items:be})}),Y=(he,de)=>J(null,null,function*(){if(te(he,"item_code",de),!!de)try{const be=(yield(yield fetch(`/api/resource/Item/${encodeURIComponent(de)}`,{credentials:"include"})).json()).data;if(!be)return;z(K=>{const ye=[...K.items||[]];return ye[he]=je(se({},ye[he]),{item_code:de,item_name:be.item_name||de,stock_uom:be.stock_uom||"",uom:be.purchase_uom||be.stock_uom||"",description:be.description||""}),je(se({},K),{items:ye})})}catch(xe){}}),q=he=>{z(de=>{const xe=[...de.items||[]],ge=he!==void 0?he+1:xe.length;return xe.splice(ge,0,o9(E)),je(se({},de),{items:xe})})},H=he=>{z(de=>{const xe=[...de.items||[]];return xe.splice(he,1),je(se({},de),{items:xe})}),N(null)},U=()=>{const de=(R.items||[]).map(xe=>xe.schedule_date||xe.required_by||"").filter(Boolean).sort()[0]||R.schedule_date||E;return{material_request_type:R.material_request_type||"Purchase",company:R.company||void 0,project:R.project||void 0,customer:R.customer||void 0,transaction_date:R.transaction_date,schedule_date:de,items:(R.items||[]).filter(xe=>xe.item_code).map((xe,ge)=>{var be,K,ye;return je(se({},xe.name?{name:xe.name}:{}),{item_code:xe.item_code,item_name:xe.item_name||xe.item_code,description:xe.description||void 0,qty:(be=xe.qty)!=null?be:1,uom:xe.uom||void 0,stock_uom:xe.stock_uom||void 0,conversion_factor:(K=xe.conversion_factor)!=null?K:1,schedule_date:xe.schedule_date||xe.required_by||de,warehouse:xe.warehouse||void 0,rate:(ye=xe.rate)!=null?ye:0,expense_account:xe.expense_account||void 0,cost_center:xe.cost_center||R.cost_center||void 0,project:xe.project||R.project||void 0,idx:ge+1})})}},re=()=>J(null,null,function*(){try{if(y(!0),s){const he=yield am.createMaterialRequest(U());We.success("Material Request created"),k(!1),a(`/material-requests/${he.name}`)}else yield am.updateMaterialRequest(e,U()),We.success("Material Request saved"),k(!1),ae()}catch(he){We.error(he.message||"Error saving")}finally{y(!1)}}),X=()=>J(null,null,function*(){if(!(!e||s))try{w(!0);const he=yield am.submitMaterialRequest(e);c(he),G(he),We.success("Material Request submitted")}catch(he){We.error(he.message||"Error submitting")}finally{w(!1)}}),V=()=>{const he=new URLSearchParams;he.set("mr",e),R.company&&he.set("company",String(R.company)),R.project&&he.set("project",String(R.project)),a(`/purchase-orders/new?${he.toString()}`)},I=(l==null?void 0:l.workflow_state)||"",B=p.useMemo(()=>l?se({},l):void 0,[l]),Q=s||v&&C,ie=!s&&(l==null?void 0:l.docstatus)===1,me=!s&&(l==null?void 0:l.docstatus)===0&&T===!1;return u?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsx(tr,{className:"animate-spin text-orange-500 text-3xl"})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900",children:[t.jsx($a,{position:"top-right",autoClose:3500}),t.jsx("div",{className:"sticky top-0 z-10 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 shadow-sm",children:t.jsxs("div",{className:"px-6 py-4",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-gray-400 mb-2.5",children:[t.jsx("button",{onClick:()=>a("/projects"),className:"hover:text-orange-500 transition-colors",children:"Project Management"}),t.jsx("span",{children:"/"}),t.jsx("button",{onClick:()=>a("/material-requests"),className:"hover:text-orange-500 transition-colors",children:"Material Requests"}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-gray-600 dark:text-gray-300 font-medium",children:s?"New Material Request":e})]}),t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>a("/material-requests"),className:"p-1.5 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:t.jsx(ia,{size:14})}),t.jsx(zd,{className:"text-orange-500 text-xl"}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-lg font-bold text-gray-900 dark:text-white",children:s?"New Material Request":e}),!s&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-0.5",children:[t.jsx("span",{className:`inline-block px-2 py-0.5 rounded text-xs font-semibold ${(()=>{const he=(l==null?void 0:l.status)||"";return(l==null?void 0:l.docstatus)===2||he==="Cancelled"?"bg-red-100 text-red-700":!l||l.docstatus===0?"bg-yellow-100 text-yellow-800":he==="Transferred"||he==="Issued"?"bg-green-100 text-green-800":he==="Partially Ordered"||he==="Ordered"?"bg-blue-100 text-blue-800":he==="Pending"?"bg-orange-100 text-orange-800":he==="Stopped"||he==="Closed"?"bg-gray-100 text-gray-700":"bg-green-100 text-green-800"})()}`,children:(l==null?void 0:l.docstatus)===2?"Cancelled":(l==null?void 0:l.docstatus)===0?"Draft":(l==null?void 0:l.status)||"Submitted"}),I?t.jsx("span",{className:"inline-block px-2 py-0.5 rounded text-xs font-medium bg-violet-100 text-violet-800 dark:bg-violet-900/40 dark:text-violet-200 border border-violet-200 dark:border-violet-700",children:I}):null]})]})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[ie&&t.jsx(pSe,{items:[{label:"Purchase Order",icon:t.jsx(eS,{size:13}),onClick:V}]}),me&&!v&&t.jsxs("button",{onClick:X,disabled:b,className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 text-sm font-medium shadow-sm",children:[b?t.jsx(tr,{className:"animate-spin",size:12}):t.jsx(Lm,{size:12})," Submit"]}),!s&&!v&&!ie&&C&&t.jsxs("button",{onClick:()=>k(!0),className:"flex items-center gap-2 px-4 py-2 border border-orange-500 text-orange-600 rounded-lg hover:bg-orange-50 text-sm font-medium",children:[t.jsx(qr,{size:12})," Edit"]}),Q&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:re,disabled:f,className:"flex items-center gap-2 px-4 py-2 bg-orange-500 text-white rounded-lg hover:bg-orange-600 disabled:opacity-50 text-sm font-medium shadow-sm",children:[f?t.jsx(tr,{className:"animate-spin",size:12}):t.jsx(ta,{size:12}),f?"Saving…":"Save"]}),!s&&t.jsx("button",{onClick:()=>{l&&G(l),k(!1)},className:"p-2 border border-gray-300 rounded-lg text-gray-500 hover:bg-gray-100 text-sm",children:t.jsx(ht,{size:12})})]})]})]})]})}),t.jsx("div",{className:"px-6 py-6",children:t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6 items-start",children:[t.jsxs("div",{className:`space-y-3 ${s?"lg:col-span-4":"lg:col-span-3"}`,children:[t.jsx(i9,{title:"Details",icon:t.jsx(zd,{size:12,className:"text-orange-500"}),children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-4",children:[t.jsxs("div",{children:[t.jsx(On,{required:!0,children:"Purpose (Type)"}),Q?t.jsxs("select",{value:R.material_request_type||"Purchase",onChange:he=>ne("material_request_type",he.target.value),className:n9,children:[t.jsx("option",{value:"Purchase",children:"Purchase"}),t.jsx("option",{value:"Material Transfer",children:"Material Transfer"}),t.jsx("option",{value:"Manufacture",children:"Manufacture"}),t.jsx("option",{value:"Customer Provided",children:"Customer Provided"}),t.jsx("option",{value:"Material Issue",children:"Material Issue"})]}):t.jsx(Qb,{children:R.material_request_type})]}),t.jsxs("div",{children:[t.jsx(On,{required:!0,children:"Transaction Date"}),Q?t.jsx("input",{type:"date",value:R.transaction_date||"",onChange:he=>ne("transaction_date",he.target.value),className:n9}):t.jsx(Qb,{children:R.transaction_date})]}),t.jsxs("div",{children:[t.jsx(On,{children:"Company"}),Q?t.jsx(Je,{label:"Company",hideLabel:!0,doctype:"Company",value:R.company||"",onChange:he=>ne("company",he),placeholder:"Select company…"}):t.jsx(Qb,{children:R.company})]}),t.jsxs("div",{children:[t.jsx(On,{children:"Project"}),Q?t.jsx(Je,{label:"Project",hideLabel:!0,doctype:"Project",value:R.project||"",onChange:he=>ne("project",he),placeholder:"Select project…"}):t.jsx(Qb,{children:R.project})]})]})}),t.jsx(i9,{title:"Items",icon:t.jsx(zd,{size:12,className:"text-amber-500"}),children:t.jsx("div",{className:"overflow-x-auto -mx-2",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-8",children:"No."}),t.jsxs("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 min-w-[180px]",children:["Item Code ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsxs("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:["UOM ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsxs("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-24",children:["Qty ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-32",children:"Required By"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-36",children:"Target Warehouse"}),Q&&t.jsx("th",{className:"w-16 py-2 px-2"})]})}),t.jsxs("tbody",{children:[(R.items||[]).map((he,de)=>{var xe,ge;return t.jsxs(gr.Fragment,{children:[t.jsxs("tr",{className:`border-b border-gray-100 dark:border-gray-700 align-middle ${S===de?"bg-amber-50/60 dark:bg-amber-900/10":""}`,children:[t.jsx("td",{className:"py-1.5 px-3 text-gray-400 text-xs",children:de+1}),t.jsx("td",{className:"py-1.5 px-2 min-w-[180px]",children:Q?t.jsx(Je,{label:"Item",hideLabel:!0,doctype:"Item",value:he.item_code||"",onChange:be=>Y(de,be),placeholder:"Select item…"}):t.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-200",children:he.item_code||"-"})}),t.jsx("td",{className:"py-1.5 px-2 w-28",children:Q?t.jsx(Je,{label:"UOM",hideLabel:!0,doctype:"UOM",value:he.uom||"",onChange:be=>te(de,"uom",be),placeholder:"UOM"}):t.jsx("span",{className:"text-gray-500 text-sm",children:he.uom||"-"})}),t.jsx("td",{className:"py-1.5 px-2 w-24",children:Q?t.jsx("input",{type:"number",min:0,step:"1",value:(xe=he.qty)!=null?xe:1,onChange:be=>te(de,"qty",parseFloat(be.target.value)||0),className:hSe}):t.jsx("span",{className:"block text-right text-sm pr-1",children:(ge=he.qty)!=null?ge:0})}),t.jsx("td",{className:"py-1.5 px-2 w-32",children:Q?t.jsx("input",{type:"date",value:he.schedule_date||he.required_by||"",onChange:be=>te(de,"schedule_date",be.target.value),className:mSe}):t.jsx("span",{className:"text-gray-500 text-sm",children:he.schedule_date||he.required_by||"-"})}),t.jsx("td",{className:"py-1.5 px-2 w-36",children:Q?t.jsx(Je,{label:"Warehouse",hideLabel:!0,doctype:"Warehouse",value:he.warehouse||"",onChange:be=>te(de,"warehouse",be),placeholder:"Warehouse"}):t.jsx("span",{className:"text-gray-500 text-sm truncate max-w-[120px] block",children:he.warehouse||"-"})}),Q&&t.jsx("td",{className:"py-1.5 px-2",children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>N(S===de?null:de),className:`p-1.5 rounded text-xs ${S===de?"bg-amber-600 text-white":"text-amber-600 hover:bg-amber-50"}`,children:t.jsx(xl,{size:11})}),t.jsx("button",{onClick:()=>H(de),className:"p-1.5 text-red-400 hover:text-red-600 hover:bg-red-50 rounded",children:t.jsx(wr,{size:11})})]})})]}),Q&&S===de&&t.jsx(gSe,{item:he,rowNo:de+1,onChange:(be,K)=>{be==="item_code"?Y(de,K):te(de,be,K)},onClose:()=>N(null),onDelete:()=>H(de),onInsertBelow:()=>q(de)})]},de)}),Q&&t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"py-2 px-3",children:t.jsxs("button",{onClick:()=>q(),className:"flex items-center gap-1.5 text-orange-600 hover:text-orange-700 text-sm font-medium",children:[t.jsx(Rr,{size:10})," Add Row"]})})})]})]})})})]}),!s&&e&&t.jsxs("aside",{className:"lg:col-span-1 space-y-6 lg:sticky lg:top-28 lg:self-start",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-5 border border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Workflow Actions"}),t.jsx(Ix,{doctype:"Material Request",docname:e,workflowState:I,docData:B,documentLabel:"Material Request",onStateChange:ae,onWorkflowMeta:ee,className:"space-y-4"})]}),t.jsx(vi,{doctype:"Material Request",docname:e||"",creationDate:l==null?void 0:l.creation,createdBy:l==null?void 0:l.owner,compact:!0,initialVisible:5,collapsible:!0,startCollapsed:!0})]})]})})]})},q0=20;function xSe(e){const r=[];return e.search&&r.push(["Purchase Receipt","name","like",`%${e.search}%`]),e.status==="Draft"&&r.push(["Purchase Receipt","docstatus","=",0]),e.status==="Submitted"&&r.push(["Purchase Receipt","docstatus","=",1]),e.status==="Cancelled"&&r.push(["Purchase Receipt","docstatus","=",2]),r}function ySe(e){return e.docstatus===2?"bg-red-100 text-red-700":e.docstatus===1?"bg-green-100 text-green-700":"bg-yellow-100 text-yellow-800"}function bSe(e){return e.docstatus===2?"Cancelled":e.docstatus===1?e.status||"Submitted":"Draft"}const vSe=()=>{const{t:e}=sr(),r=hr(),[a,s]=p.useState([]),[n,i]=p.useState(!0),[o,l]=p.useState(0),[c,u]=p.useState(0),[h,f]=p.useState(!1),[y,b]=p.useState(""),[w,v]=p.useState(""),[k,S]=p.useState({search:"",status:""}),[N,C]=p.useState(!1),O=p.useCallback((q,H)=>J(null,null,function*(){i(!0);try{const U=[];H.search&&U.push(["Purchase Receipt","name","like",`%${H.search}%`]),H.status==="Draft"&&U.push(["Purchase Receipt","docstatus","=",0]),H.status==="Submitted"&&U.push(["Purchase Receipt","docstatus","=",1]),H.status==="Cancelled"&&U.push(["Purchase Receipt","docstatus","=",2]);const[re,X]=yield Promise.all([nm.getPurchaseReceipts({filters:U,limit_start:q,limit_page_length:q0}),nm.getPurchaseReceiptCount(U)]);s(re),l(X)}catch(U){We.error(U.message||"Failed to load")}finally{i(!1)}}),[]);p.useEffect(()=>{O(0,k)},[O,k]);const T=p.useMemo(()=>`${c}|${k.search}|${k.status}`,[c,k.search,k.status]),{selectedRows:P,toggleRow:E,toggleAllOnPage:R,allOnPageSelected:z,someOnPageSelected:G}=po(a,T),ae=()=>{S({search:y,status:w}),u(0)},ee=()=>{b(""),v(""),S({search:"",status:""}),u(0)},ne=!!(k.search||k.status),te=q=>{u(q),O(q*q0,k)},Y=p.useCallback(()=>go({doctype:"Purchase Receipt",filters:xSe(k),orderBy:"modified desc"}),[k]);return t.jsxs("div",{className:"p-6",children:[t.jsx($a,{position:"top-right",autoClose:3e3}),t.jsxs("div",{className:"flex items-center justify-between mb-6 gap-4 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl bg-green-500 flex items-center justify-center",children:t.jsx(ao,{className:"text-white text-base"})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:"Purchase Receipts"}),t.jsxs("p",{className:"text-xs text-gray-500",children:[o," total"]})]})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("button",{onClick:()=>O(c*q0,k),className:"p-2 text-gray-500 hover:text-green-600 border border-gray-200 rounded-lg",children:t.jsx(Ma,{size:13})}),t.jsxs("button",{type:"button",onClick:()=>C(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all text-sm font-medium disabled:opacity-50",disabled:o===0&&P.size===0,children:[t.jsx(Sa,{})," ",e("listPages.export"),P.size>0&&t.jsx("span",{className:"bg-white/25 px-1.5 py-0.5 rounded text-xs font-bold",children:P.size})]}),t.jsxs("button",{onClick:()=>r("/purchase-receipts/new"),className:"flex items-center gap-2 px-4 py-2 bg-green-500 text-white rounded-lg hover:bg-green-600 text-sm font-medium",children:[t.jsx(Rr,{size:11})," New Receipt"]})]})]}),t.jsx(bi,{isOpen:N,onClose:()=>C(!1),doctype:"Purchase Receipt",selectedCount:P.size,pageCount:a.length,totalCount:o,pageData:a,selectedRows:P,rowKey:"name",onFetchAll:Y,fileNamePrefix:"purchase_receipts"}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl mb-5 overflow-hidden",children:[t.jsxs("button",{onClick:()=>f(q=>!q),className:"w-full flex items-center justify-between px-4 py-3 bg-gradient-to-r from-green-500 to-green-600 text-white",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[t.jsx(za,{size:12})," Filters",ne&&t.jsx("span",{className:"bg-white/30 text-white text-xs px-2 py-0.5 rounded-full",children:"Active"})]}),h?t.jsx(Ja,{size:11}):t.jsx(Fr,{size:11})]}),ne&&t.jsxs("div",{className:"px-4 py-2 bg-green-50 dark:bg-green-900/20 flex flex-wrap gap-2 items-center border-b border-green-100 dark:border-green-800",children:[k.search&&t.jsxs("span",{className:"flex items-center gap-1 text-xs bg-green-100 dark:bg-green-800 text-green-700 dark:text-green-300 px-2 py-1 rounded-full",children:["ID: ",k.search,t.jsx("button",{onClick:()=>{b(""),S(q=>je(se({},q),{search:""}))},children:t.jsx(ht,{size:9})})]}),k.status&&t.jsxs("span",{className:"flex items-center gap-1 text-xs bg-green-100 dark:bg-green-800 text-green-700 dark:text-green-300 px-2 py-1 rounded-full",children:["Status: ",k.status,t.jsx("button",{onClick:()=>{v(""),S(q=>je(se({},q),{status:""}))},children:t.jsx(ht,{size:9})})]}),t.jsx("button",{onClick:ee,className:"text-xs text-green-600 hover:underline ml-auto",children:"Clear All"})]}),h&&t.jsxs("div",{className:"px-4 py-3 grid grid-cols-1 sm:grid-cols-3 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[11px] font-semibold text-gray-500 uppercase tracking-wide mb-1",children:"Receipt ID"}),t.jsx("input",{value:y,onChange:q=>b(q.target.value),onKeyDown:q=>q.key==="Enter"&&ae(),placeholder:"Search…",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-green-400"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[11px] font-semibold text-gray-500 uppercase tracking-wide mb-1",children:"Status"}),t.jsxs("select",{value:w,onChange:q=>v(q.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-green-400",children:[t.jsx("option",{value:"",children:"All"}),t.jsx("option",{value:"Draft",children:"Draft"}),t.jsx("option",{value:"Submitted",children:"Submitted"}),t.jsx("option",{value:"Cancelled",children:"Cancelled"})]})]}),t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsx("button",{onClick:ae,className:"px-4 py-2 bg-green-500 text-white text-sm rounded hover:bg-green-600",children:"Apply"}),t.jsx("button",{onClick:ee,className:"px-4 py-2 border border-gray-300 text-gray-600 text-sm rounded hover:bg-gray-50",children:"Clear"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl overflow-hidden",children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx("th",{className:"w-10 px-2 py-3",children:t.jsx("input",{type:"checkbox",className:"rounded border-gray-300 dark:border-gray-600 text-green-600 focus:ring-green-500",checked:z,ref:q=>{q&&(q.indeterminate=G)},onChange:R,"aria-label":"Select all on page"})}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"PR ID"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Supplier"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Posting Date"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Status"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Grand Total"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Company"})]})}),t.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:n?t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"text-center py-10 text-gray-400",children:"Loading…"})}):a.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"text-center py-10 text-gray-400",children:"No purchase receipts found"})}):a.map(q=>{var H;return t.jsxs("tr",{onClick:()=>r(`/purchase-receipts/${q.name}`),className:`cursor-pointer hover:bg-green-50 dark:hover:bg-green-900/10 transition-colors ${P.has(q.name)?"bg-green-50/90 dark:bg-green-900/20":""}`,children:[t.jsx("td",{className:"w-10 px-2 py-3",onClick:U=>U.stopPropagation(),children:t.jsx("input",{type:"checkbox",className:"rounded border-gray-300 dark:border-gray-600 text-green-600 focus:ring-green-500",checked:P.has(q.name),onChange:()=>E(q.name),"aria-label":`Select ${q.name}`})}),t.jsx("td",{className:"py-3 px-4 font-medium text-green-600",children:q.name}),t.jsx("td",{className:"py-3 px-4 text-gray-700 dark:text-gray-300",children:q.supplier_name||q.supplier||"-"}),t.jsx("td",{className:"py-3 px-4 text-gray-500",children:q.posting_date||"-"}),t.jsx("td",{className:"py-3 px-4",children:t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${ySe(q)}`,children:bSe(q)})}),t.jsxs("td",{className:"py-3 px-4 text-right font-semibold text-gray-900 dark:text-white",children:["SAR ",((H=q.grand_total)!=null?H:0).toFixed(2)]}),t.jsx("td",{className:"py-3 px-4 text-gray-500",children:q.company||"-"})]},q.name)})})]})}),o>q0&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-100 dark:border-gray-700",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:[c*q0+1,"–",Math.min((c+1)*q0,o)," of ",o]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:c===0,onClick:()=>te(c-1),className:"px-3 py-1 text-xs border border-gray-300 rounded disabled:opacity-40",children:"Prev"}),t.jsx("button",{disabled:(c+1)*q0>=o,onClick:()=>te(c+1),className:"px-3 py-1 text-xs border border-gray-300 rounded disabled:opacity-40",children:"Next"})]})]})]})]})},Gr=({children:e,required:r})=>t.jsxs("label",{className:"block text-[11px] font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1",children:[e,r&&t.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),ql=({children:e})=>t.jsx("div",{className:"px-3 py-2 text-sm text-gray-800 dark:text-gray-200 bg-gray-50 dark:bg-gray-800/60 rounded min-h-[34px] flex items-center",children:e||t.jsx("span",{className:"text-gray-400",children:"-"})}),Vd="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-green-400",Y0=Vd+" text-right",ev="w-full px-2 py-1 text-sm text-right border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-green-400",wSe="w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-green-400",Sd="px-3 py-2 text-sm text-right bg-gray-50 dark:bg-gray-700/60 rounded text-gray-600 dark:text-gray-300",Ac=({title:e,children:r,defaultOpen:a=!1})=>{const[s,n]=p.useState(a);return t.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-600 mt-3 pt-1",children:[t.jsxs("button",{type:"button",onClick:()=>n(i=>!i),className:"flex items-center gap-2 py-1 text-xs font-semibold text-blue-600 dark:text-blue-400 hover:underline",children:[s?t.jsx(Fr,{size:9}):t.jsx(Fi,{size:9}),e]}),s&&t.jsx("div",{className:"mt-2",children:r})]})},jSe=({item:e,rowNo:r,onChange:a,onClose:s,onDelete:n,onInsertBelow:i})=>{var o,l,c,u,h,f,y,b,w,v,k,S,N,C,O,T,P,E,R;return t.jsx("tr",{children:t.jsx("td",{colSpan:8,className:"p-0",children:t.jsxs("div",{className:"border border-blue-300 dark:border-blue-600 rounded-lg mx-2 my-1 bg-white dark:bg-gray-800 shadow-md",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-blue-50 dark:bg-blue-900/30 rounded-t-lg border-b border-blue-200 dark:border-blue-700",children:[t.jsxs("span",{className:"text-sm font-semibold text-blue-700 dark:text-blue-300",children:["Editing Row #",r]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:i,className:"px-2 py-1 text-xs border border-gray-300 rounded hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-600",children:"Insert Below"}),t.jsx("button",{onClick:n,className:"px-2 py-1 text-xs border border-red-300 rounded text-red-500 hover:bg-red-50",children:"Delete"}),t.jsx("button",{onClick:s,className:"p-1 text-gray-400 hover:text-gray-600",children:t.jsx(ht,{size:13})})]})]}),t.jsxs("div",{className:"p-4 space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(Gr,{required:!0,children:"Item Code"}),t.jsx(Je,{label:"Item",hideLabel:!0,doctype:"Item",value:e.item_code||"",onChange:z=>a("item_code",z),placeholder:"Select item…"})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Item Name"}),t.jsx("input",{value:e.item_name||"",onChange:z=>a("item_name",z.target.value),className:Vd,placeholder:"Item name…"})]})]}),t.jsx(Ac,{title:"Description",defaultOpen:!!e.description,children:t.jsx("textarea",{rows:2,value:e.description||"",onChange:z=>a("description",z.target.value),className:Vd,placeholder:"Description…"})}),t.jsx(Ac,{title:"Received and Accepted",defaultOpen:!0,children:t.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[t.jsxs("div",{children:[t.jsx(Gr,{required:!0,children:"Received Qty"}),t.jsx("input",{type:"number",min:0,step:"1",value:(o=e.received_qty)!=null?o:0,onChange:z=>a("received_qty",parseFloat(z.target.value)||0),className:Y0})]}),t.jsxs("div",{children:[t.jsx(Gr,{required:!0,children:"UOM"}),t.jsx(Je,{label:"UOM",hideLabel:!0,doctype:"UOM",value:e.uom||"",onChange:z=>a("uom",z),placeholder:"UOM…"})]}),t.jsxs("div",{children:[t.jsx(Gr,{required:!0,children:"Accepted Qty"}),t.jsx("input",{type:"number",min:0,step:"1",value:(c=(l=e.qty)!=null?l:e.received_qty)!=null?c:0,onChange:z=>a("qty",parseFloat(z.target.value)||0),className:Y0})]}),t.jsxs("div",{className:"flex items-center gap-2 pt-4",children:[t.jsx("input",{type:"checkbox",checked:!!e.retain_sample,onChange:z=>a("retain_sample",z.target.checked?1:0),className:"rounded"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Retain Sample"})]}),e.retain_sample?t.jsxs("div",{children:[t.jsx(Gr,{children:"Sample Quantity"}),t.jsx("input",{type:"number",min:0,step:"0.001",value:(u=e.sample_quantity)!=null?u:0,onChange:z=>a("sample_quantity",parseFloat(z.target.value)||0),className:Y0})]}):null,t.jsxs("div",{children:[t.jsx(Gr,{children:"Rejected Qty"}),t.jsx("input",{type:"number",min:0,step:"0.001",value:(h=e.rejected_qty)!=null?h:0,onChange:z=>a("rejected_qty",parseFloat(z.target.value)||0),className:Y0})]})]})}),t.jsx(Ac,{title:"Rate and Amount",defaultOpen:!0,children:t.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[t.jsxs("div",{children:[t.jsx(Gr,{children:"Price List Rate"}),t.jsx("div",{className:Sd,children:((f=e.price_list_rate)!=null?f:0).toFixed(2)})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Price List Rate (Company Currency)"}),t.jsx("div",{className:Sd,children:((y=e.price_list_rate)!=null?y:0).toFixed(2)})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Last Purchase Rate"}),t.jsx("div",{className:Sd,children:((b=e.valuation_rate)!=null?b:0).toFixed(2)})]})]})}),t.jsx(Ac,{title:"Discount and Margin",children:t.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[t.jsxs("div",{children:[t.jsx(Gr,{required:!0,children:"Rate"}),t.jsx("input",{type:"number",min:0,step:"0.01",value:(w=e.rate)!=null?w:0,onChange:z=>a("rate",parseFloat(z.target.value)||0),className:Y0})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Rate (Company Currency)"}),t.jsx("div",{className:Sd,children:((v=e.rate)!=null?v:0).toFixed(2)})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Amount"}),t.jsx("div",{className:"px-3 py-2 text-sm font-semibold text-right bg-gray-50 dark:bg-gray-700/60 rounded",children:(((S=(k=e.qty)!=null?k:e.received_qty)!=null?S:0)*(e.rate||0)).toFixed(2)})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Amount (Company Currency)"}),t.jsx("div",{className:Sd,children:(((C=(N=e.qty)!=null?N:e.received_qty)!=null?C:0)*(e.rate||0)).toFixed(2)})]}),t.jsxs("div",{className:"flex items-center gap-2 pt-4",children:[t.jsx("input",{type:"checkbox",checked:!!e.is_free_item,onChange:z=>a("is_free_item",z.target.checked?1:0),className:"rounded"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Is Free Item"})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Net Rate"}),t.jsx("div",{className:Sd,children:((T=(O=e.net_rate)!=null?O:e.rate)!=null?T:0).toFixed(2)})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Net Amount"}),t.jsx("div",{className:Sd,children:((P=e.net_amount)!=null?P:0).toFixed(2)})]})]})}),t.jsx(Ac,{title:"Warehouse and Reference",defaultOpen:!0,children:t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(Gr,{children:"Accepted Warehouse"}),t.jsx(Je,{label:"Warehouse",hideLabel:!0,doctype:"Warehouse",value:e.warehouse||"",onChange:z=>a("warehouse",z),placeholder:"Warehouse…"})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Rejected Warehouse"}),t.jsx(Je,{label:"Warehouse",hideLabel:!0,doctype:"Warehouse",value:e.rejected_warehouse||"",onChange:z=>a("rejected_warehouse",z),placeholder:"Rejected Warehouse…"})]}),t.jsxs("div",{className:"flex items-center gap-2 pt-4",children:[t.jsx("input",{type:"checkbox",checked:!!e.allow_zero_valuation_rate,onChange:z=>a("allow_zero_valuation_rate",z.target.checked?1:0),className:"rounded"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Allow Zero Valuation Rate"})]}),t.jsxs("div",{className:"flex items-center gap-2 pt-4",children:[t.jsx("input",{type:"checkbox",checked:!!e.from_warehouse,onChange:z=>a("from_warehouse",z.target.checked?1:0),className:"rounded"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Return Qty from Rejected Warehouse"})]}),e.purchase_order&&t.jsxs("div",{children:[t.jsx(Gr,{children:"Purchase Order"}),t.jsx("div",{className:Sd+" text-left",children:e.purchase_order})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Schedule Date"}),t.jsx("input",{type:"date",value:e.schedule_date||"",onChange:z=>a("schedule_date",z.target.value),className:Vd})]})]})}),t.jsx(Ac,{title:"Serial and Batch No",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"checkbox",checked:!!e.use_serial_batch_fields,onChange:z=>a("use_serial_batch_fields",z.target.checked?1:0),className:"rounded"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Use Serial / Batch Fields"})]})}),t.jsx(Ac,{title:"Item Weight Details",children:t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(Gr,{children:"Weight Per Unit"}),t.jsx("input",{type:"number",min:0,step:"0.001",value:(E=e.weight_per_unit)!=null?E:0,onChange:z=>a("weight_per_unit",parseFloat(z.target.value)||0),className:Y0})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Total Weight"}),t.jsx("div",{className:Sd,children:((R=e.total_weight)!=null?R:0).toFixed(3)})]})]})}),t.jsx(Ac,{title:"Accounting Details",children:t.jsxs("div",{children:[t.jsx(Gr,{children:"Expense Account"}),t.jsx(Je,{label:"Expense Account",hideLabel:!0,doctype:"Account",value:e.expense_account||"",onChange:z=>a("expense_account",z),placeholder:"Expense Account…"})]})}),t.jsx(Ac,{title:"Accounting Dimensions",children:t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(Gr,{children:"Cost Center"}),t.jsx(Je,{label:"Cost Center",hideLabel:!0,doctype:"Cost Center",value:e.cost_center||"",onChange:z=>a("cost_center",z),placeholder:"Cost center…"})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Project"}),t.jsx(Je,{label:"Project",hideLabel:!0,doctype:"Project",value:e.project||"",onChange:z=>a("project",z),placeholder:"Project…"})]})]})})]})]})})})},_Se=({tax:e,rowNo:r,onChange:a,onClose:s,onDelete:n,onInsertBelow:i})=>{var o;return t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"p-0",children:t.jsxs("div",{className:"border border-blue-300 dark:border-blue-600 rounded-lg mx-2 my-1 bg-white dark:bg-gray-800 shadow-md",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-blue-50 dark:bg-blue-900/30 rounded-t-lg border-b border-blue-200",children:[t.jsxs("span",{className:"text-sm font-semibold text-blue-700 dark:text-blue-300",children:["Editing Row #",r]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:i,className:"px-2 py-1 text-xs border border-gray-300 rounded hover:bg-gray-50 text-gray-600",children:"Insert Below"}),t.jsx("button",{onClick:n,className:"px-2 py-1 text-xs border border-red-300 rounded text-red-500 hover:bg-red-50",children:"Delete"}),t.jsx("button",{onClick:s,className:"p-1 text-gray-400 hover:text-gray-600",children:t.jsx(ht,{size:13})})]})]}),t.jsxs("div",{className:"p-4 space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(Gr,{required:!0,children:"Type"}),t.jsxs("select",{value:e.charge_type||"",onChange:l=>a("charge_type",l.target.value),className:Vd,children:[t.jsx("option",{value:"",children:"Select type…"}),t.jsx("option",{value:"Actual",children:"Actual"}),t.jsx("option",{value:"On Net Total",children:"On Net Total"}),t.jsx("option",{value:"On Previous Row Amount",children:"On Previous Row Amount"}),t.jsx("option",{value:"On Previous Row Total",children:"On Previous Row Total"}),t.jsx("option",{value:"On Item Quantity",children:"On Item Quantity"}),t.jsx("option",{value:"Inter Company Transaction",children:"Inter Company Transaction"})]})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Description"}),t.jsx("textarea",{rows:3,value:e.description||"",onChange:l=>a("description",l.target.value),className:Vd,placeholder:"Description…"})]})]}),t.jsxs("div",{children:[t.jsx(Gr,{required:!0,children:"Account Head"}),t.jsx(Je,{label:"Account Head",hideLabel:!0,doctype:"Account",value:e.account_head||"",onChange:l=>a("account_head",l),placeholder:"Account…"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"checkbox",checked:!!e.included_in_print_rate,onChange:l=>a("included_in_print_rate",l.target.checked?1:0),className:"rounded"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Is this Tax included in Basic Rate?"})]}),t.jsx("p",{className:"text-xs text-blue-500 dark:text-blue-400",children:"If checked, the tax amount will be considered as already included in the Print Rate / Print Amount"}),t.jsx(Ac,{title:"Accounting Dimensions",defaultOpen:!0,children:t.jsxs("div",{children:[t.jsx(Gr,{children:"Cost Center"}),t.jsx(Je,{label:"Cost Center",hideLabel:!0,doctype:"Cost Center",value:e.cost_center||"",onChange:l=>a("cost_center",l),placeholder:"Cost center…"})]})}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(Gr,{required:!0,children:"Tax Rate"}),t.jsx("input",{type:"number",min:0,step:"0.01",value:(o=e.rate)!=null?o:0,onChange:l=>a("rate",parseFloat(l.target.value)||0),className:Y0})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Account Currency"}),t.jsx("input",{value:e.account_currency||Er,onChange:l=>a("account_currency",l.target.value),className:Vd})]})]})]})]})})})},kSe=()=>({item_code:"",item_name:"",received_qty:0,qty:0,rejected_qty:0,rate:0,amount:0,uom:"",conversion_factor:1,is_free_item:0,retain_sample:0}),NSe=()=>({charge_type:"",account_head:"",rate:0,account_currency:Er,included_in_print_rate:0}),SSe=()=>{var de,xe,ge,be;const{prName:e}=hs(),[r]=_a(),a=hr(),s=e==="new",n=r.get("po")||"",i=r.get("supplier")||"",o=r.get("company")||un,l=r.get("project")||"",[c,u]=p.useState(null),[h,f]=p.useState(!s),[y,b]=p.useState(!1),[w,v]=p.useState(!1),[k,S]=p.useState(s),[N,C]=p.useState(null),[O,T]=p.useState(null),P=new Date().toISOString().split("T")[0],[E,R]=p.useState({supplier:i,supplier_name:i,company:o,project:l,posting_date:P,currency:Er,items:[],taxes:[]}),z=p.useCallback(K=>{R({supplier:K.supplier||"",supplier_name:K.supplier_name||K.supplier||"",company:K.company||un,project:K.project||"",posting_date:K.posting_date||P,currency:K.currency||Er,set_warehouse:K.set_warehouse||"",cost_center:K.cost_center||"",tax_category:K.tax_category||"",taxes_and_charges:K.taxes_and_charges||"",items:K.items||[],taxes:K.taxes||[]}),C(null),T(null)},[P]);p.useEffect(()=>{s||(f(!0),nm.getPurchaseReceipt(e).then(K=>{u(K),z(K)}).catch(K=>We.error(K.message)).finally(()=>f(!1)))},[e,s,z]),p.useEffect(()=>{const K=E.company;!s||!K||fetch(`/api/resource/Company/${encodeURIComponent(K)}`,{credentials:"include"}).then(ye=>ye.json()).then(ye=>{var Z;if((Z=ye.data)!=null&&Z.default_currency){const M=Xn(ye.data.default_currency);R(we=>je(se({},we),{currency:M,buying_price_list:we.buying_price_list||"Standard Buying",price_list_currency:we.price_list_currency||M}))}}).catch(()=>{})},[E.company,s]),p.useEffect(()=>{!s||!n||fetch(`/api/resource/Purchase Order/${encodeURIComponent(n)}`,{credentials:"include"}).then(K=>K.json()).then(K=>{const ye=K.data;ye&&R(Z=>je(se({},Z),{supplier:ye.supplier||Z.supplier,supplier_name:ye.supplier_name||ye.supplier||Z.supplier_name,company:ye.company||Z.company,project:ye.project||Z.project,items:(ye.items||[]).map(M=>{var we,pe,le,Fe,ze,Re;return{item_code:M.item_code,item_name:M.item_name,uom:M.uom||M.stock_uom,stock_uom:M.stock_uom,conversion_factor:(we=M.conversion_factor)!=null?we:1,received_qty:(pe=M.qty)!=null?pe:0,qty:(le=M.qty)!=null?le:0,rejected_qty:0,rate:(Fe=M.rate)!=null?Fe:0,amount:((ze=M.qty)!=null?ze:0)*((Re=M.rate)!=null?Re:0),warehouse:M.warehouse||"",purchase_order:n,purchase_order_item:M.name,schedule_date:M.schedule_date||"",project:ye.project||"",cost_center:M.cost_center||"",expense_account:M.expense_account||""}})}))}).catch(()=>{})},[s,n]);const G=(K,ye)=>R(Z=>je(se({},Z),{[K]:ye})),ae=(K,ye,Z)=>R(M=>{var le;const we=[...M.items||[]],pe=je(se({},we[K]),{[ye]:Z});if(ye==="qty"||ye==="received_qty"||ye==="rate"){const Fe=parseFloat(String(ye==="qty"||ye==="received_qty"?Z:(le=pe.qty)!=null?le:pe.received_qty))||0,ze=parseFloat(String(ye==="rate"?Z:pe.rate))||0;pe.amount=parseFloat((Fe*ze).toFixed(4))}return we[K]=pe,je(se({},M),{items:we})}),ee=(K,ye)=>J(null,null,function*(){if(ae(K,"item_code",ye),!!ye)try{const we=(yield(yield fetch(`/api/resource/Item/${encodeURIComponent(ye)}`,{credentials:"include"})).json()).data;if(!we)return;R(pe=>{var Fe;const le=[...pe.items||[]];return le[K]=je(se({},le[K]),{item_code:ye,item_name:we.item_name||ye,description:we.description||we.item_name||ye,stock_uom:we.stock_uom||"",uom:we.purchase_uom||we.stock_uom||"",price_list_rate:(Fe=we.standard_rate)!=null?Fe:0,rate:le[K].rate||we.standard_rate||0}),je(se({},pe),{items:le})})}catch(Z){}}),ne=K=>{R(ye=>{const Z=[...ye.items||[]],M=kSe();let we;return K!==void 0?(Z.splice(K+1,0,M),we=K+1):(Z.push(M),we=Z.length-1),setTimeout(()=>C(we),0),je(se({},ye),{items:Z})})},te=K=>{R(ye=>{const Z=[...ye.items||[]];return Z.splice(K,1),je(se({},ye),{items:Z})}),C(null)},Y=(K,ye,Z)=>R(M=>{const we=[...M.taxes||[]];return we[K]=je(se({},we[K]),{[ye]:Z}),je(se({},M),{taxes:we})}),q=K=>{R(ye=>{const Z=[...ye.taxes||[]],M=NSe();let we;return K!==void 0?(Z.splice(K+1,0,M),we=K+1):(Z.push(M),we=Z.length-1),setTimeout(()=>T(we),0),je(se({},ye),{taxes:Z})})},H=K=>{R(ye=>{const Z=[...ye.taxes||[]];return Z.splice(K,1),je(se({},ye),{taxes:Z})}),T(null)},U=(E.items||[]).reduce((K,ye)=>{var Z,M;return K+((M=(Z=ye.qty)!=null?Z:ye.received_qty)!=null?M:0)*(ye.rate||0)},0),re=(E.taxes||[]).reduce((K,ye)=>ye.charge_type==="On Net Total"?K+(ye.rate||0)/100*U:ye.charge_type==="Actual"?K+(ye.tax_amount||0):K+(ye.rate||0)/100*U,0),X=U+re,V=K=>J(null,null,function*(){var ye;if(K)try{const we=(yield(yield fetch(`/api/resource/Purchase Taxes and Charges Template/${encodeURIComponent(K)}`,{credentials:"include"})).json()).data;(ye=we==null?void 0:we.taxes)!=null&&ye.length&&R(pe=>je(se({},pe),{taxes:we.taxes.map(le=>{var Fe;return{charge_type:le.charge_type,account_head:le.account_head,description:le.description,rate:le.rate,cost_center:le.cost_center,account_currency:le.account_currency,included_in_print_rate:(Fe=le.included_in_print_rate)!=null?Fe:0}})}))}catch(Z){}}),I=()=>({supplier:E.supplier,company:E.company||void 0,project:E.project||void 0,posting_date:E.posting_date,currency:E.currency||void 0,set_warehouse:E.set_warehouse||void 0,cost_center:E.cost_center||void 0,tax_category:E.tax_category||void 0,taxes_and_charges:E.taxes_and_charges||void 0,items:(E.items||[]).filter(K=>K.item_code).map((K,ye)=>{var Z,M,we,pe,le,Fe,ze,Re,De,Et,jt,Ie;return{item_code:K.item_code,item_name:K.item_name||K.item_code,description:K.description||K.item_name||K.item_code,received_qty:(Z=K.received_qty)!=null?Z:0,qty:(we=(M=K.qty)!=null?M:K.received_qty)!=null?we:0,rejected_qty:(pe=K.rejected_qty)!=null?pe:0,uom:K.uom||void 0,stock_uom:K.stock_uom||void 0,conversion_factor:(le=K.conversion_factor)!=null?le:1,rate:(Fe=K.rate)!=null?Fe:0,amount:((Re=(ze=K.qty)!=null?ze:K.received_qty)!=null?Re:0)*((De=K.rate)!=null?De:0),price_list_rate:(Et=K.price_list_rate)!=null?Et:0,warehouse:K.warehouse||void 0,rejected_warehouse:K.rejected_warehouse||void 0,expense_account:K.expense_account||void 0,cost_center:K.cost_center||void 0,project:K.project||E.project||void 0,purchase_order:K.purchase_order||void 0,purchase_order_item:K.purchase_order_item||void 0,schedule_date:K.schedule_date||void 0,is_free_item:(jt=K.is_free_item)!=null?jt:0,retain_sample:(Ie=K.retain_sample)!=null?Ie:0,sample_quantity:K.sample_quantity||void 0,weight_per_unit:K.weight_per_unit||void 0,idx:ye+1}}),taxes:(E.taxes||[]).filter(K=>K.charge_type).map((K,ye)=>{var Z,M;return{charge_type:K.charge_type,account_head:K.account_head||void 0,description:K.description||void 0,included_in_print_rate:(Z=K.included_in_print_rate)!=null?Z:0,cost_center:K.cost_center||void 0,rate:(M=K.rate)!=null?M:0,account_currency:K.account_currency||Er,idx:ye+1}})}),B=()=>J(null,null,function*(){if(!E.supplier){We.error("Supplier is required");return}try{if(b(!0),s){const K=yield nm.createPurchaseReceipt(I());We.success("Purchase Receipt created"),S(!1),a(`/purchase-receipts/${K.name}`)}else{const K=yield nm.updatePurchaseReceipt(e,I());u(K),z(K),We.success("Purchase Receipt saved"),S(!1)}}catch(K){We.error(K.message||"Error saving")}finally{b(!1)}}),Q=()=>J(null,null,function*(){if(!(!e||s))try{v(!0);const K=yield nm.submitPurchaseReceipt(e);u(K),z(K),We.success("Purchase Receipt submitted")}catch(K){We.error(K.message||"Error submitting")}finally{v(!1)}}),ie=s||k,me=!s&&(c==null?void 0:c.docstatus)===1,he=s?"New Purchase Receipt":E.supplier_name||e||"";return h?t.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:t.jsx(tr,{className:"animate-spin text-green-500 text-3xl"})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 px-6 py-6",children:[t.jsx($a,{position:"top-right",autoClose:3500}),t.jsxs("div",{className:"flex items-center gap-2 text-sm mb-6 text-gray-500",children:[t.jsx("button",{onClick:()=>a("/purchase-receipts"),className:"hover:text-green-600",children:"Purchase Receipts"}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:s?"New Purchase Receipt":e})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 dark:border-gray-700 flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>a("/purchase-receipts"),className:"text-gray-400 hover:text-gray-700",children:t.jsx(ia,{})}),t.jsx(ao,{className:"text-green-500"}),t.jsx("div",{children:t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:he}),!s&&e&&t.jsx("span",{className:"text-xs text-gray-400 font-mono",children:e}),!s&&t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${(()=>{const K=(c==null?void 0:c.status)||"";return(c==null?void 0:c.docstatus)===2||K==="Cancelled"?"bg-red-100 text-red-700":!c||c.docstatus===0?"bg-yellow-100 text-yellow-800":K==="Completed"?"bg-green-100 text-green-800":K==="Return Issued"?"bg-orange-100 text-orange-800":K==="Closed"?"bg-gray-100 text-gray-700":"bg-green-100 text-green-800"})()}`,children:(c==null?void 0:c.docstatus)===2?"Cancelled":(c==null?void 0:c.docstatus)===0?"Draft":(c==null?void 0:c.status)||"Submitted"})]})})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[!s&&!k&&(c==null?void 0:c.docstatus)===0&&t.jsxs("button",{onClick:Q,disabled:w,className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 text-sm font-medium",children:[w?t.jsx(tr,{className:"animate-spin"}):t.jsx(Lm,{size:12})," Submit"]}),!s&&!k&&!me&&t.jsxs("button",{onClick:()=>S(!0),className:"flex items-center gap-2 px-4 py-2 border border-green-500 text-green-600 rounded-lg hover:bg-green-50 text-sm",children:[t.jsx(qr,{})," Edit"]}),ie&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:B,disabled:y,className:"flex items-center gap-2 px-4 py-2 bg-green-500 text-white rounded-lg hover:bg-green-600 disabled:opacity-50 text-sm font-medium",children:[y?t.jsx(tr,{className:"animate-spin"}):t.jsx(ta,{}),y?"Saving…":"Save"]}),!s&&t.jsx("button",{onClick:()=>{c&&z(c),S(!1)},className:"px-3 py-2 border border-gray-300 rounded-lg text-gray-600 text-sm",children:t.jsx(ht,{})})]})]})]}),t.jsx("div",{className:"px-6 pt-5 pb-4",children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-4",children:[t.jsxs("div",{children:[t.jsx(Gr,{required:!0,children:"Supplier"}),ie?t.jsx(Je,{label:"Supplier",hideLabel:!0,doctype:"Supplier",value:E.supplier||"",onChange:K=>{G("supplier",K),G("supplier_name",K)},placeholder:"Select supplier…"}):t.jsx(ql,{children:E.supplier_name||E.supplier})]}),t.jsxs("div",{children:[t.jsx(Gr,{required:!0,children:"Posting Date"}),ie?t.jsx("input",{type:"date",value:E.posting_date||"",onChange:K=>G("posting_date",K.target.value),className:Vd}):t.jsx(ql,{children:E.posting_date})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Company"}),ie?t.jsx(Je,{label:"Company",hideLabel:!0,doctype:"Company",value:E.company||"",onChange:K=>G("company",K),placeholder:"Select company…"}):t.jsx(ql,{children:E.company})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Project"}),ie?t.jsx(Je,{label:"Project",hideLabel:!0,doctype:"Project",value:E.project||"",onChange:K=>G("project",K),placeholder:"Select project…"}):t.jsx(ql,{children:E.project})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Set Warehouse"}),ie?t.jsx(Je,{label:"Warehouse",hideLabel:!0,doctype:"Warehouse",value:E.set_warehouse||"",onChange:K=>G("set_warehouse",K),placeholder:"Warehouse…"}):t.jsx(ql,{children:E.set_warehouse})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Currency"}),ie?t.jsxs("select",{value:E.currency||Er,onChange:K=>G("currency",K.target.value),className:Vd,children:[t.jsx("option",{value:"SAR",children:"SAR"}),t.jsx("option",{value:"USD",children:"USD"}),t.jsx("option",{value:"EUR",children:"EUR"})]}):t.jsx(ql,{children:E.currency})]})]})}),t.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700",children:[t.jsx("div",{className:"px-6 py-3 bg-gray-50 dark:bg-gray-900/20 border-b border-gray-100 dark:border-gray-700",children:t.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Items"})}),t.jsxs("div",{className:"px-6 pb-5",children:[t.jsx("div",{className:"overflow-x-auto -mx-2 mt-3",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-8",children:"No."}),t.jsxs("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 min-w-[180px]",children:["Item Code ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 min-w-[140px]",children:"Item Name"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-24",children:"Received Qty"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-24",children:"Accepted Qty"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:"Rate"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:"Amount"}),ie&&t.jsx("th",{className:"w-16 py-2 px-2"})]})}),t.jsxs("tbody",{children:[(E.items||[]).map((K,ye)=>{var Z,M,we,pe,le,Fe,ze,Re,De;return t.jsxs(gr.Fragment,{children:[t.jsxs("tr",{className:`border-b border-gray-100 dark:border-gray-700 align-middle ${N===ye?"bg-blue-50/60 dark:bg-blue-900/10":""}`,children:[t.jsx("td",{className:"py-1.5 px-3 text-gray-400 text-xs",children:ye+1}),t.jsx("td",{className:"py-1.5 px-2 min-w-[180px]",children:ie?t.jsx(Je,{label:"Item",hideLabel:!0,doctype:"Item",value:K.item_code||"",onChange:Et=>ee(ye,Et),placeholder:"Item Code"}):t.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-200",children:K.item_code||"-"})}),t.jsx("td",{className:"py-1.5 px-2 min-w-[140px]",children:t.jsx("span",{className:"text-gray-500 text-sm",children:K.item_name||"-"})}),t.jsx("td",{className:"py-1.5 px-2 w-24",children:ie?t.jsx("input",{type:"number",min:0,step:"1",value:(Z=K.received_qty)!=null?Z:0,onChange:Et=>ae(ye,"received_qty",parseFloat(Et.target.value)||0),className:ev}):t.jsx("span",{className:"block text-right text-gray-700 dark:text-gray-300 text-sm pr-1",children:((M=K.received_qty)!=null?M:0).toFixed(3)})}),t.jsx("td",{className:"py-1.5 px-2 w-24",children:ie?t.jsx("input",{type:"number",min:0,step:"1",value:(pe=(we=K.qty)!=null?we:K.received_qty)!=null?pe:0,onChange:Et=>ae(ye,"qty",parseFloat(Et.target.value)||0),className:ev}):t.jsx("span",{className:"block text-right text-gray-700 dark:text-gray-300 text-sm pr-1",children:((le=K.qty)!=null?le:0).toFixed(3)})}),t.jsx("td",{className:"py-1.5 px-2 w-28",children:ie?t.jsx("input",{type:"number",min:0,step:"0.01",value:(Fe=K.rate)!=null?Fe:0,onChange:Et=>ae(ye,"rate",parseFloat(Et.target.value)||0),className:ev}):t.jsx("span",{className:"block text-right text-gray-700 dark:text-gray-300 text-sm pr-1",children:((ze=K.rate)!=null?ze:0).toFixed(2)})}),t.jsx("td",{className:"py-1.5 px-3 text-right font-semibold text-gray-900 dark:text-white text-sm",children:(((De=(Re=K.qty)!=null?Re:K.received_qty)!=null?De:0)*(K.rate||0)).toFixed(2)}),ie&&t.jsx("td",{className:"py-1.5 px-2",children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>C(N===ye?null:ye),className:`p-1.5 rounded text-xs ${N===ye?"bg-blue-600 text-white":"text-green-600 hover:bg-green-50"}`,title:"More fields",children:t.jsx(xl,{size:11})}),t.jsx("button",{onClick:()=>te(ye),className:"p-1.5 text-red-400 hover:text-red-600 hover:bg-red-50 rounded",children:t.jsx(wr,{size:11})})]})})]}),ie&&N===ye&&t.jsx(jSe,{item:K,rowNo:ye+1,onChange:(Et,jt)=>{Et==="item_code"?ee(ye,jt):ae(ye,Et,jt)},onClose:()=>C(null),onDelete:()=>te(ye),onInsertBelow:()=>ne(ye)})]},ye)}),ie&&t.jsx("tr",{children:t.jsx("td",{colSpan:8,className:"py-2 px-3",children:t.jsxs("button",{onClick:()=>ne(),className:"flex items-center gap-1.5 text-green-600 hover:text-green-700 text-sm font-medium",children:[t.jsx(Rr,{size:10})," Add Row"]})})})]})]})}),t.jsxs("div",{className:"mt-3 flex justify-between text-sm border-t border-gray-100 dark:border-gray-700 pt-3",children:[t.jsxs("span",{className:"text-gray-500",children:["Total Qty: ",t.jsx("strong",{children:(E.items||[]).reduce((K,ye)=>{var Z,M;return K+((M=(Z=ye.qty)!=null?Z:ye.received_qty)!=null?M:0)},0).toFixed(3)})]}),t.jsxs("span",{className:"text-gray-500",children:["Total: ",t.jsxs("strong",{className:"text-gray-900 dark:text-white",children:[E.currency||Er," ",U.toFixed(2)]})]})]})]})]}),t.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700",children:[t.jsx("div",{className:"px-6 py-3 bg-gray-50 dark:bg-gray-900/20 border-b border-gray-100 dark:border-gray-700",children:t.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Taxes and Charges"})}),t.jsxs("div",{className:"px-6 pt-4 pb-2 grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-3",children:[t.jsxs("div",{children:[t.jsx(Gr,{children:"Tax Category"}),ie?t.jsx(Je,{label:"Tax Category",hideLabel:!0,doctype:"Tax Category",value:E.tax_category||"",onChange:K=>G("tax_category",K),placeholder:"Select tax category…"}):t.jsx(ql,{children:E.tax_category})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Purchase Taxes and Charges Template"}),ie?t.jsx(Je,{label:"Purchase Taxes and Charges Template",hideLabel:!0,doctype:"Purchase Taxes and Charges Template",value:E.taxes_and_charges||"",onChange:K=>{G("taxes_and_charges",K),V(K)},placeholder:"Select template…"}):t.jsx(ql,{children:E.taxes_and_charges})]})]}),t.jsxs("div",{className:"px-6 pb-5",children:[t.jsx("div",{className:"overflow-x-auto -mx-2 mt-3",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-8",children:"No."}),t.jsxs("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-44",children:["Type ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsxs("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3",children:["Account Head ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-24",children:"Tax Rate"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:"Amount"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:"Total"}),ie&&t.jsx("th",{className:"w-16 py-2 px-2"})]})}),t.jsxs("tbody",{children:[(E.taxes||[]).map((K,ye)=>{var we,pe;const Z=K.charge_type==="On Net Total"?(K.rate||0)/100*U:K.charge_type==="Actual"?K.tax_amount||0:(K.rate||0)/100*U,M=U+(E.taxes||[]).slice(0,ye+1).reduce((le,Fe)=>{const ze=Fe.charge_type==="On Net Total"?(Fe.rate||0)/100*U:Fe.charge_type==="Actual"?Fe.tax_amount||0:(Fe.rate||0)/100*U;return le+ze},0);return t.jsxs(gr.Fragment,{children:[t.jsxs("tr",{className:`border-b border-gray-100 dark:border-gray-700 align-middle ${O===ye?"bg-blue-50/60 dark:bg-blue-900/10":""}`,children:[t.jsx("td",{className:"py-1.5 px-3 text-gray-400 text-xs",children:ye+1}),t.jsx("td",{className:"py-1.5 px-2 w-44",children:ie?t.jsxs("select",{value:K.charge_type||"",onChange:le=>Y(ye,"charge_type",le.target.value),className:wSe,children:[t.jsx("option",{value:"",children:"Select type…"}),t.jsx("option",{value:"Actual",children:"Actual"}),t.jsx("option",{value:"On Net Total",children:"On Net Total"}),t.jsx("option",{value:"On Previous Row Amount",children:"On Previous Row Amount"}),t.jsx("option",{value:"On Previous Row Total",children:"On Previous Row Total"}),t.jsx("option",{value:"On Item Quantity",children:"On Item Quantity"}),t.jsx("option",{value:"Inter Company Transaction",children:"Inter Company Transaction"})]}):t.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:K.charge_type||"-"})}),t.jsx("td",{className:"py-1.5 px-2",children:ie?t.jsx(Je,{label:"Account Head",hideLabel:!0,doctype:"Account",value:K.account_head||"",onChange:le=>Y(ye,"account_head",le),placeholder:"Account Head"}):t.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:K.account_head||"-"})}),t.jsx("td",{className:"py-1.5 px-2 w-24",children:ie?t.jsx("input",{type:"number",min:0,step:"0.01",value:(we=K.rate)!=null?we:0,onChange:le=>Y(ye,"rate",parseFloat(le.target.value)||0),className:ev}):t.jsx("span",{className:"block text-right text-gray-700 dark:text-gray-300 pr-1",children:(pe=K.rate)!=null?pe:0})}),t.jsx("td",{className:"py-1.5 px-3 text-right text-gray-700 dark:text-gray-300 text-sm",children:Z.toFixed(2)}),t.jsx("td",{className:"py-1.5 px-3 text-right font-semibold text-gray-900 dark:text-white text-sm",children:M.toFixed(2)}),ie&&t.jsx("td",{className:"py-1.5 px-2",children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>T(O===ye?null:ye),className:`p-1.5 rounded text-xs ${O===ye?"bg-blue-600 text-white":"text-green-600 hover:bg-green-50"}`,title:"More fields",children:t.jsx(xl,{size:11})}),t.jsx("button",{onClick:()=>H(ye),className:"p-1.5 text-red-400 hover:text-red-600 hover:bg-red-50 rounded",children:t.jsx(wr,{size:11})})]})})]}),ie&&O===ye&&t.jsx(_Se,{tax:K,rowNo:ye+1,onChange:(le,Fe)=>Y(ye,le,Fe),onClose:()=>T(null),onDelete:()=>H(ye),onInsertBelow:()=>q(ye)})]},ye)}),ie&&t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"py-2 px-3",children:t.jsxs("button",{onClick:()=>q(),className:"flex items-center gap-1.5 text-green-600 hover:text-green-700 text-sm font-medium",children:[t.jsx(Rr,{size:10})," Add Row"]})})})]})]})}),(E.taxes||[]).length>0&&t.jsxs("div",{className:"mt-2 flex justify-end text-sm text-gray-500 pt-2 border-t border-gray-100 dark:border-gray-700",children:["Total Taxes and Charges: ",t.jsxs("strong",{className:"ml-2 text-gray-900 dark:text-white",children:[E.currency||Er," ",re.toFixed(2)]})]})]})]}),t.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700 px-6 py-4",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"Totals"}),t.jsx("div",{className:"space-y-2 max-w-xs ml-auto",children:[{label:"Net Total",value:((de=c==null?void 0:c.net_total)!=null?de:U).toFixed(2)},{label:"Total Taxes",value:((xe=c==null?void 0:c.total_taxes_and_charges)!=null?xe:re).toFixed(2)},{label:"Grand Total",value:((ge=c==null?void 0:c.grand_total)!=null?ge:X).toFixed(2)},{label:"Rounded Total",value:((be=c==null?void 0:c.rounded_total)!=null?be:X).toFixed(2)}].map(({label:K,value:ye})=>t.jsxs("div",{className:"flex justify-between text-sm border-b border-gray-100 dark:border-gray-700 pb-1.5 last:border-0",children:[t.jsx("span",{className:"text-gray-500",children:K}),t.jsxs("span",{className:"font-semibold text-gray-900 dark:text-white",children:[E.currency||Er," ",ye]})]},K))})]}),!s&&c&&t.jsxs("div",{className:"border-t border-gray-100 dark:border-gray-700 px-6 py-4 grid grid-cols-3 gap-4 text-sm bg-gray-50 dark:bg-gray-900/20",children:[t.jsxs("div",{children:[t.jsx(Gr,{children:"Created By"}),t.jsx(ql,{children:c.owner})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Created"}),t.jsx(ql,{children:c.creation?new Date(c.creation).toLocaleString():"-"})]}),t.jsxs("div",{children:[t.jsx(Gr,{children:"Modified"}),t.jsx(ql,{children:c.modified?new Date(c.modified).toLocaleString():"-"})]})]}),!s&&t.jsx(vi,{doctype:"Purchase Receipt",docname:(c==null?void 0:c.name)||e||"",creationDate:c==null?void 0:c.creation,createdBy:c==null?void 0:c.owner,compact:!1,initialVisible:5,collapsible:!0,startCollapsed:!0})]})]})},ep=20,CSe=(e,r)=>r===1?e==="Paid"?"bg-green-100 text-green-700":"bg-blue-100 text-blue-700":r===2?"bg-red-100 text-red-700":"bg-yellow-100 text-yellow-700",TSe=(e,r)=>r===2?"Cancelled":r===1?e||"Submitted":"Draft";function ESe(){const{t:e}=sr(),r=hr(),[a,s]=p.useState([]),[n,i]=p.useState(0),[o,l]=p.useState(0),[c,u]=p.useState(!0),[h,f]=p.useState(!0),[y,b]=p.useState(""),[w,v]=p.useState(""),[k,S]=p.useState(""),[N,C]=p.useState(!1),O=p.useCallback(()=>{const re=[];return y&&re.push(["name","like",`%${y}%`]),w&&re.push(["party","like",`%${w}%`]),k&&re.push(["payment_type","=",k]),re},[y,w,k]),T=p.useCallback((re=0)=>J(null,null,function*(){u(!0);try{const X=O(),[V,I]=yield Promise.all([rm.getPaymentEntries({filters:X,limit_start:re*ep,limit_page_length:ep}),rm.getPaymentEntryCount(X)]);s(V),i(I),l(re)}catch(X){We.error(X.message||"Error loading")}finally{u(!1)}}),[O]);p.useEffect(()=>{T(0)},[T]);const P=p.useMemo(()=>`${o}|${y}|${w}|${k}`,[o,y,w,k]),{selectedRows:E,toggleRow:R,toggleAllOnPage:z,allOnPageSelected:G,someOnPageSelected:ae}=po(a,P),ee=p.useCallback(()=>go({doctype:"Payment Entry",filters:O(),orderBy:"modified desc"}),[O]),ne=re=>T(re),te=[y,w,k].filter(Boolean).length,Y=()=>{b(""),v(""),S("")},q=re=>r(`/payment-entries/${encodeURIComponent(re)}`),H=re=>r(`/payment-entries/${encodeURIComponent(re)}?edit=1`),U=re=>r(`/payment-entries/new?duplicate=${encodeURIComponent(re)}`);return t.jsxs(t.Fragment,{children:[t.jsx($a,{position:"top-right",autoClose:3e3}),t.jsxs("div",{className:"px-6 py-6 space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl bg-teal-600 flex items-center justify-center shadow",children:t.jsx(Zu,{className:"text-white",size:18})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:"Payment Entries"}),t.jsxs("p",{className:"text-xs text-gray-500",children:[n," total"]})]})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("button",{onClick:()=>T(o),className:"p-2 text-gray-500 hover:text-teal-600 hover:bg-teal-50 rounded-lg transition-colors",children:t.jsx(Ma,{size:14})}),t.jsxs("button",{type:"button",onClick:()=>C(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all text-sm font-medium disabled:opacity-50",disabled:n===0&&E.size===0,children:[t.jsx(Sa,{})," ",e("listPages.export"),E.size>0&&t.jsx("span",{className:"bg-white/25 px-1.5 py-0.5 rounded text-xs font-bold",children:E.size})]}),t.jsxs("button",{onClick:()=>r("/payment-entries/new"),className:"flex items-center gap-2 px-4 py-2 bg-teal-600 hover:bg-teal-700 text-white text-sm font-semibold rounded-lg shadow transition-colors",children:[t.jsx(Rr,{size:12})," New Entry"]})]})]}),t.jsx(bi,{isOpen:N,onClose:()=>C(!1),doctype:"Payment Entry",selectedCount:E.size,pageCount:a.length,totalCount:n,pageData:a,selectedRows:E,rowKey:"name",onFetchAll:ee,fileNamePrefix:"payment_entries"}),t.jsxs("div",{className:"rounded-xl border border-blue-200 dark:border-blue-800 overflow-hidden shadow-sm",children:[t.jsxs("button",{onClick:()=>f(re=>!re),className:"w-full flex items-center justify-between px-4 py-3 bg-gradient-to-r from-blue-500 to-blue-600 dark:from-blue-600 dark:to-blue-700 text-white text-sm font-semibold",children:[t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(ds,{size:12})," Filters ",te>0&&t.jsx("span",{className:"bg-white/25 text-white text-[10px] px-1.5 py-0.5 rounded-full",children:te})]}),h?t.jsx(Ja,{size:12}):t.jsx(Fr,{size:12})]}),h&&t.jsxs("div",{className:"p-4 bg-white dark:bg-gray-800 grid grid-cols-1 sm:grid-cols-3 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-semibold text-gray-500 uppercase mb-1",children:"Payment ID"}),t.jsx("input",{value:y,onChange:re=>b(re.target.value),placeholder:"Search by ID…",className:"w-full border border-gray-200 dark:border-gray-600 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-indigo-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-semibold text-gray-500 uppercase mb-1",children:"Party"}),t.jsx("input",{value:w,onChange:re=>v(re.target.value),placeholder:"Customer / Supplier…",className:"w-full border border-gray-200 dark:border-gray-600 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-indigo-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-semibold text-gray-500 uppercase mb-1",children:"Type"}),t.jsxs("select",{value:k,onChange:re=>S(re.target.value),className:"w-full border border-gray-200 dark:border-gray-600 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-indigo-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100",children:[t.jsx("option",{value:"",children:"All Types"}),t.jsx("option",{value:"Receive",children:"Receive"}),t.jsx("option",{value:"Pay",children:"Pay"}),t.jsx("option",{value:"Internal Transfer",children:"Internal Transfer"})]})]}),te>0&&t.jsxs("div",{className:"sm:col-span-3 flex flex-wrap gap-2 items-center",children:[y&&t.jsxs("span",{className:"flex items-center gap-1 bg-blue-100 text-blue-700 text-xs px-2 py-1 rounded-full",children:["ID: ",y,t.jsx("button",{onClick:()=>b(""),children:t.jsx(ht,{size:9})})]}),w&&t.jsxs("span",{className:"flex items-center gap-1 bg-blue-100 text-blue-700 text-xs px-2 py-1 rounded-full",children:["Party: ",w,t.jsx("button",{onClick:()=>v(""),children:t.jsx(ht,{size:9})})]}),k&&t.jsxs("span",{className:"flex items-center gap-1 bg-blue-100 text-blue-700 text-xs px-2 py-1 rounded-full",children:["Type: ",k,t.jsx("button",{onClick:()=>S(""),children:t.jsx(ht,{size:9})})]}),t.jsx("button",{onClick:Y,className:"text-xs text-blue-600 hover:text-blue-800 font-medium ml-1",children:"Clear all"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl overflow-hidden",children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx("th",{className:"w-10 px-4 py-3 text-left",children:t.jsx("button",{type:"button",onClick:z,className:"text-gray-500 dark:text-gray-400 hover:text-teal-600 dark:hover:text-teal-400 transition-colors",title:G?"Deselect all":"Select all","aria-label":"Select all on page",children:G?t.jsx(Ra,{className:"text-teal-600 dark:text-teal-400",size:18}):ae?t.jsxs("div",{className:"relative inline-block",children:[t.jsx(Ur,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Ur,{size:18})})}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Payment ID"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Type"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Date"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Party"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Amount"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4",children:"Status"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-3 px-4 w-28",children:" "})]})}),t.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:c?t.jsx("tr",{children:t.jsx("td",{colSpan:8,className:"text-center py-10 text-gray-400",children:"Loading…"})}):a.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:8,className:"text-center py-10 text-gray-400",children:"No payment entries found"})}):a.map(re=>t.jsxs("tr",{onClick:()=>q(re.name),className:`cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors ${E.has(re.name)?"bg-teal-50 dark:bg-teal-900/20":""}`,children:[t.jsx("td",{className:"w-10 px-4 py-3",onClick:X=>X.stopPropagation(),children:t.jsx("button",{type:"button",onClick:()=>R(re.name),className:"text-gray-500 dark:text-gray-400 hover:text-teal-600 dark:hover:text-teal-400 transition-colors","aria-label":`Select ${re.name}`,children:E.has(re.name)?t.jsx(Ra,{className:"text-teal-600 dark:text-teal-400",size:18}):t.jsx(Ur,{size:18})})}),t.jsx("td",{className:"py-3 px-4 font-medium text-gray-900 dark:text-white",children:re.name}),t.jsx("td",{className:"py-3 px-4 text-gray-700 dark:text-gray-300",children:re.payment_type||"-"}),t.jsx("td",{className:"py-3 px-4 text-gray-500",children:re.posting_date||"-"}),t.jsx("td",{className:"py-3 px-4 text-gray-700 dark:text-gray-300",children:re.party_name||re.party||"-"}),t.jsx("td",{className:"py-3 px-4 text-right font-semibold text-gray-900 dark:text-white",children:(re.paid_amount||0).toFixed(2)}),t.jsx("td",{className:"py-3 px-4",children:t.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold ${CSe(re.status,re.docstatus)}`,children:TSe(re.status,re.docstatus)})}),t.jsx("td",{className:"py-2 px-4",onClick:X=>X.stopPropagation(),children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>q(re.name),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded transition-colors",title:"View",children:t.jsx(Ps,{})}),t.jsx("button",{onClick:()=>H(re.name),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:"Edit",children:t.jsx(qr,{})}),t.jsx("button",{onClick:()=>U(re.name),className:"text-purple-600 dark:text-purple-400 hover:text-purple-900 dark:hover:text-purple-300 p-2 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded transition-colors",title:"Duplicate",children:t.jsx(Vo,{})})]})})]},re.name))})]})}),n>ep&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-100 dark:border-gray-700",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:[o*ep+1,"–",Math.min((o+1)*ep,n)," of ",n]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:o===0,onClick:()=>ne(o-1),className:"px-3 py-1 text-xs border border-gray-300 rounded disabled:opacity-40",children:"Prev"}),t.jsx("button",{disabled:(o+1)*ep>=n,onClick:()=>ne(o+1),className:"px-3 py-1 text-xs border border-gray-300 rounded disabled:opacity-40",children:"Next"})]})]})]})]})]})}const eo=({children:e,required:r})=>t.jsxs("label",{className:"block text-[11px] font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1",children:[e,r&&t.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),Ei=({children:e})=>t.jsx("p",{className:"text-sm text-gray-800 dark:text-gray-200 min-h-[20px] py-0.5",children:e||t.jsx("span",{className:"text-gray-400 italic",children:"—"})}),J0="w-full border border-gray-200 dark:border-gray-600 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-teal-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100",l9=J0+" text-right",ASe=e=>{var a;const r=(a=e.docstatus)!=null?a:0;if(r===2)return t.jsx("span",{className:"px-2 py-1 rounded-full text-xs font-bold bg-red-100 text-red-700",children:"Cancelled"});if(r===1){const s=e.status||"Submitted";return s==="Paid"?t.jsx("span",{className:"px-2 py-1 rounded-full text-xs font-bold bg-green-100 text-green-700",children:"Paid"}):t.jsx("span",{className:"px-2 py-1 rounded-full text-xs font-bold bg-blue-100 text-blue-700",children:s})}return t.jsx("span",{className:"px-2 py-1 rounded-full text-xs font-bold bg-yellow-100 text-yellow-700",children:"Draft"})},tp=({title:e,children:r})=>t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden",children:[t.jsx("div",{className:"px-4 py-2.5 border-b border-gray-100 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:t.jsx("h3",{className:"text-xs font-bold text-gray-600 dark:text-gray-300 uppercase tracking-wider",children:e})}),t.jsx("div",{className:"p-4",children:r})]}),OSe=()=>({reference_doctype:"Sales Invoice",reference_name:"",total_amount:0,outstanding_amount:0,allocated_amount:0,exchange_rate:1}),PSe="Cash - SA";function DSe(){var re,X,V,I;const{peName:e}=hs(),r=hr(),[a]=_a(),s=e==="new",n=a.get("si")||"",i=a.get("customer")||"",o=a.get("company")||un,l=a.get("project")||"",c=parseFloat(a.get("amount")||"0"),u=a.get("currency")||Er,[h,f]=p.useState(null),[y,b]=p.useState(!s),[w,v]=p.useState(!1),[k,S]=p.useState(!1),[N,C]=p.useState(s),O=new Date().toISOString().split("T")[0],[T,P]=p.useState({payment_type:"Receive",posting_date:O,company:o,party_type:"Customer",party:i||"",party_name:i||"",mode_of_payment:"Cash",paid_to:PSe,reference_date:O,reference_no:"",paid_amount:c||0,received_amount:c||0,source_exchange_rate:1,target_exchange_rate:1,project:l||"",references:n?[{reference_doctype:"Sales Invoice",reference_name:n,total_amount:c,outstanding_amount:c,allocated_amount:c,exchange_rate:1}]:[]}),E=p.useCallback(B=>{P({payment_type:B.payment_type||"Receive",posting_date:B.posting_date||O,company:B.company||un,party_type:B.party_type||"Customer",party:B.party||"",party_name:B.party_name||"",mode_of_payment:B.mode_of_payment||"",paid_from:B.paid_from||"",paid_to:B.paid_to||"",paid_from_account_currency:B.paid_from_account_currency||"",paid_to_account_currency:B.paid_to_account_currency||"",paid_amount:B.paid_amount||0,received_amount:B.received_amount||0,source_exchange_rate:B.source_exchange_rate||1,target_exchange_rate:B.target_exchange_rate||1,total_allocated_amount:B.total_allocated_amount||0,unallocated_amount:B.unallocated_amount||0,difference_amount:B.difference_amount||0,project:B.project||"",cost_center:B.cost_center||"",remarks:B.remarks||"",reference_no:B.reference_no||"",reference_date:B.reference_date||"",references:B.references||[]})},[O]);p.useEffect(()=>{!s||!n||fetch(`/api/resource/Sales Invoice/${encodeURIComponent(n)}`,{credentials:"include"}).then(B=>B.json()).then(B=>{const Q=B.data;if(!Q)return;const ie=Q.outstanding_amount||Q.grand_total||0;P(me=>je(se({},me),{party:Q.customer||me.party,party_name:Q.customer_name||Q.customer||me.party_name,company:Q.company||me.company,project:Q.project||me.project,paid_from:Q.debit_to||"",paid_from_account_currency:Q.currency||u,paid_to_account_currency:Q.currency||u,paid_amount:ie,received_amount:ie,references:[{reference_doctype:"Sales Invoice",reference_name:n,total_amount:Q.grand_total||0,outstanding_amount:ie,allocated_amount:ie,exchange_rate:1}],remarks:`Amount ${Q.currency||""} ${ie} received from ${Q.customer_name||Q.customer}
|
||
Amount ${Q.currency||""} ${ie} against Sales Invoice ${n}`}))}).catch(()=>{})},[s,n]),p.useEffect(()=>{s||(b(!0),rm.getPaymentEntry(e).then(B=>{f(B),E(B)}).catch(B=>We.error(B.message)).finally(()=>b(!1)))},[e,s,E]);const R=(B,Q)=>P(ie=>je(se({},ie),{[B]:Q})),z=(B,Q,ie)=>{P(me=>{const he=[...me.references||[]];return he[B]=je(se({},he[B]),{[Q]:ie}),Q==="outstanding_amount"&&(he[B].allocated_amount=ie),je(se({},me),{references:he})})},G=()=>P(B=>je(se({},B),{references:[...B.references||[],OSe()]})),ae=B=>P(Q=>je(se({},Q),{references:(Q.references||[]).filter((ie,me)=>me!==B)})),ee=(T.references||[]).reduce((B,Q)=>B+(Q.allocated_amount||0),0),ne=(B,Q,ie)=>J(null,null,function*(){if(ie)try{const de=(yield(yield fetch(`/api/resource/${encodeURIComponent(Q)}/${encodeURIComponent(ie)}`,{credentials:"include"})).json()).data;if(!de)return;P(xe=>{const ge=[...xe.references||[]];return ge[B]=je(se({},ge[B]),{total_amount:de.grand_total||de.outstanding_amount||0,outstanding_amount:de.outstanding_amount||de.grand_total||0,allocated_amount:de.outstanding_amount||de.grand_total||0}),je(se({},xe),{references:ge,paid_amount:de.outstanding_amount||de.grand_total||0,received_amount:de.outstanding_amount||de.grand_total||0})})}catch(me){}}),te=()=>({payment_type:T.payment_type||"Receive",posting_date:T.posting_date,company:T.company||void 0,party_type:T.party_type||"Customer",party:T.party,party_name:T.party_name||T.party,mode_of_payment:T.mode_of_payment||void 0,paid_from:T.paid_from||void 0,paid_to:T.paid_to||void 0,paid_from_account_currency:T.paid_from_account_currency||void 0,paid_to_account_currency:T.paid_to_account_currency||void 0,paid_amount:T.paid_amount||ee,received_amount:T.received_amount||ee,source_exchange_rate:T.source_exchange_rate||1,target_exchange_rate:T.target_exchange_rate||1,project:T.project||void 0,cost_center:T.cost_center||void 0,remarks:T.remarks||void 0,reference_no:T.reference_no||void 0,reference_date:T.reference_date||void 0,references:(T.references||[]).filter(B=>B.reference_name).map((B,Q)=>({reference_doctype:B.reference_doctype||"Sales Invoice",reference_name:B.reference_name,total_amount:B.total_amount||0,outstanding_amount:B.outstanding_amount||0,allocated_amount:B.allocated_amount||0,exchange_rate:B.exchange_rate||1,idx:Q+1}))}),Y=()=>J(null,null,function*(){if(!T.party){We.error("Party is required");return}try{if(v(!0),s){const B=yield rm.createPaymentEntry(te());We.success("Payment Entry created"),C(!1),r(`/payment-entries/${B.name}`)}else{const B=yield rm.updatePaymentEntry(e,te());f(B),E(B),We.success("Payment Entry saved"),C(!1)}}catch(B){We.error(B.message||"Error saving")}finally{v(!1)}}),q=()=>J(null,null,function*(){if(!(!e||s))try{S(!0);const B=yield rm.submitPaymentEntry(e);f(B),E(B),We.success("Payment Entry submitted")}catch(B){We.error(B.message||"Error submitting")}finally{S(!1)}}),H=N&&((re=h==null?void 0:h.docstatus)!=null?re:0)<1,U=((X=h==null?void 0:h.docstatus)!=null?X:0)===1;return y?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-teal-600"})}):t.jsxs(t.Fragment,{children:[t.jsx($a,{position:"top-right",autoClose:3e3}),t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 px-6 py-6 space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>r("/payment-entries"),className:"p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg transition-colors",children:t.jsx(ia,{size:14})}),t.jsx("div",{className:"w-9 h-9 rounded-xl bg-teal-600 flex items-center justify-center shadow-sm",children:t.jsx(Zu,{className:"text-white",size:15})}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("h1",{className:"text-lg font-bold text-gray-900 dark:text-white",children:s?"New Payment Entry":(h==null?void 0:h.party_name)||(h==null?void 0:h.party)||e}),!s&&ASe(h||{})]}),!s&&t.jsx("p",{className:"text-xs text-gray-400",children:e})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[H&&t.jsxs("button",{onClick:Y,disabled:w,className:"flex items-center gap-2 px-4 py-2 bg-teal-600 hover:bg-teal-700 text-white text-sm font-semibold rounded-lg shadow disabled:opacity-50 transition-colors",children:[t.jsx(ta,{size:13}),w?"Saving…":"Save"]}),!s&&!N&&!U&&t.jsx("button",{onClick:()=>C(!0),className:"flex items-center gap-2 px-4 py-2 border border-teal-500 text-teal-600 hover:bg-teal-50 text-sm font-semibold rounded-lg transition-colors",children:"Edit"}),!s&&!U&&!N&&t.jsxs("button",{onClick:q,disabled:k,className:"flex items-center gap-2 px-4 py-2 bg-green-600 hover:bg-green-700 text-white text-sm font-semibold rounded-lg shadow disabled:opacity-50 transition-colors",children:[t.jsx(Oc,{size:12}),k?"Submitting…":"Submit"]})]})]}),t.jsx(tp,{title:"Payment Details",children:t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(eo,{required:!0,children:"Payment Type"}),H?t.jsxs("select",{value:T.payment_type||"Receive",onChange:B=>R("payment_type",B.target.value),className:J0,children:[t.jsx("option",{value:"Receive",children:"Receive"}),t.jsx("option",{value:"Pay",children:"Pay"}),t.jsx("option",{value:"Internal Transfer",children:"Internal Transfer"})]}):t.jsx(Ei,{children:T.payment_type})]}),t.jsxs("div",{children:[t.jsx(eo,{required:!0,children:"Posting Date"}),H?t.jsx("input",{type:"date",value:T.posting_date||"",onChange:B=>R("posting_date",B.target.value),className:J0}):t.jsx(Ei,{children:T.posting_date})]}),t.jsxs("div",{children:[t.jsx(eo,{children:"Mode of Payment"}),H?t.jsx(Je,{label:"Mode of Payment",hideLabel:!0,doctype:"Mode of Payment",value:T.mode_of_payment||"",onChange:B=>R("mode_of_payment",B),placeholder:"Cash, Bank…"}):t.jsx(Ei,{children:T.mode_of_payment})]}),t.jsxs("div",{children:[t.jsx(eo,{children:"Company"}),H?t.jsx(Je,{label:"Company",hideLabel:!0,doctype:"Company",value:T.company||"",onChange:B=>R("company",B),placeholder:"Company…"}):t.jsx(Ei,{children:T.company})]})]})}),t.jsx(tp,{title:"Payment From / To",children:t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(eo,{children:"Party Type"}),H?t.jsxs("select",{value:T.party_type||"Customer",onChange:B=>R("party_type",B.target.value),className:J0,children:[t.jsx("option",{value:"Customer",children:"Customer"}),t.jsx("option",{value:"Supplier",children:"Supplier"}),t.jsx("option",{value:"Employee",children:"Employee"})]}):t.jsx(Ei,{children:T.party_type})]}),t.jsxs("div",{children:[t.jsx(eo,{required:!0,children:"Party"}),H?t.jsx(Je,{label:"Party",hideLabel:!0,doctype:T.party_type||"Customer",value:T.party||"",onChange:B=>{R("party",B),R("party_name",B)},placeholder:"Select party…"}):t.jsx(Ei,{children:T.party_name||T.party})]}),t.jsxs("div",{children:[t.jsx(eo,{children:"Project"}),H?t.jsx(Je,{label:"Project",hideLabel:!0,doctype:"Project",value:T.project||"",onChange:B=>R("project",B),placeholder:"Project…"}):t.jsx(Ei,{children:T.project})]}),t.jsxs("div",{children:[t.jsx(eo,{children:"Cost Center"}),H?t.jsx(Je,{label:"Cost Center",hideLabel:!0,doctype:"Cost Center",value:T.cost_center||"",onChange:B=>R("cost_center",B),placeholder:"Cost center…"}):t.jsx(Ei,{children:T.cost_center})]})]})}),t.jsx(tp,{title:"Accounts",children:t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(eo,{children:"Account Paid From"}),H?t.jsx(Je,{label:"Account Paid From",hideLabel:!0,doctype:"Account",value:T.paid_from||"",onChange:B=>R("paid_from",B),placeholder:"Debtors account…"}):t.jsx(Ei,{children:T.paid_from})]}),t.jsxs("div",{children:[t.jsx(eo,{children:"Account Paid To"}),H?t.jsx(Je,{label:"Account Paid To",hideLabel:!0,doctype:"Account",value:T.paid_to||"",onChange:B=>R("paid_to",B),placeholder:"Cash / Bank account…"}):t.jsx(Ei,{children:T.paid_to})]}),t.jsxs("div",{children:[t.jsx(eo,{required:!0,children:"Paid Amount"}),H?t.jsx("input",{type:"number",min:0,step:"0.01",value:(V=T.paid_amount)!=null?V:0,onChange:B=>{const Q=parseFloat(B.target.value)||0;R("paid_amount",Q),R("received_amount",Q)},className:l9}):t.jsx(Ei,{children:(T.paid_amount||0).toFixed(2)})]}),t.jsxs("div",{children:[t.jsx(eo,{children:"Received Amount"}),H?t.jsx("input",{type:"number",min:0,step:"0.01",value:(I=T.received_amount)!=null?I:0,onChange:B=>R("received_amount",parseFloat(B.target.value)||0),className:l9}):t.jsx(Ei,{children:(T.received_amount||0).toFixed(2)})]})]})}),t.jsx(tp,{title:"Transaction ID",children:t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(eo,{children:"Cheque / Reference No"}),H?t.jsx("input",{type:"text",value:T.reference_no||"",onChange:B=>R("reference_no",B.target.value),className:J0,placeholder:"Reference number…"}):t.jsx(Ei,{children:T.reference_no})]}),t.jsxs("div",{children:[t.jsx(eo,{children:"Cheque / Reference Date"}),H?t.jsx("input",{type:"date",value:T.reference_date||"",onChange:B=>R("reference_date",B.target.value),className:J0}):t.jsx(Ei,{children:T.reference_date})]})]})}),t.jsxs(tp,{title:"Payment References",children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40",children:[t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-8",children:"No."}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3",children:"Type"}),t.jsx("th",{className:"text-left text-[10px] font-semibold text-gray-500 uppercase py-2 px-3",children:"Reference"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:"Total Amount"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:"Outstanding"}),t.jsx("th",{className:"text-right text-[10px] font-semibold text-gray-500 uppercase py-2 px-3 w-28",children:"Allocated"}),H&&t.jsx("th",{className:"w-10 py-2 px-2"})]})}),t.jsxs("tbody",{children:[(T.references||[]).map((B,Q)=>{var ie,me;return t.jsxs("tr",{className:"border-b border-gray-100 dark:border-gray-700 align-middle",children:[t.jsx("td",{className:"py-2 px-3 text-gray-400 text-xs",children:Q+1}),t.jsx("td",{className:"py-2 px-3 w-40",children:H?t.jsxs("select",{value:B.reference_doctype||"",onChange:he=>z(Q,"reference_doctype",he.target.value),className:"w-full border border-gray-200 rounded px-2 py-1 text-xs bg-white dark:bg-gray-700 dark:border-gray-600 dark:text-gray-100",children:[t.jsx("option",{value:"Sales Invoice",children:"Sales Invoice"}),t.jsx("option",{value:"Purchase Invoice",children:"Purchase Invoice"}),t.jsx("option",{value:"Sales Order",children:"Sales Order"}),t.jsx("option",{value:"Purchase Order",children:"Purchase Order"}),t.jsx("option",{value:"Journal Entry",children:"Journal Entry"})]}):t.jsx("span",{className:"text-gray-700 dark:text-gray-300 text-xs",children:B.reference_doctype})}),t.jsx("td",{className:"py-2 px-3 min-w-[180px]",children:H?t.jsx(Je,{label:"Reference",hideLabel:!0,doctype:B.reference_doctype||"Sales Invoice",value:B.reference_name||"",onChange:he=>{z(Q,"reference_name",he),he&&ne(Q,B.reference_doctype||"Sales Invoice",he)},placeholder:"Select document…"}):t.jsx("span",{className:"text-teal-600 font-medium text-xs",children:B.reference_name||"-"})}),t.jsx("td",{className:"py-2 px-3 text-right text-gray-700 dark:text-gray-300 text-xs",children:H?t.jsx("input",{type:"number",min:0,step:"0.01",value:(ie=B.total_amount)!=null?ie:0,onChange:he=>z(Q,"total_amount",parseFloat(he.target.value)||0),className:"w-full border border-gray-200 rounded px-2 py-1 text-xs text-right bg-white dark:bg-gray-700 dark:border-gray-600 dark:text-gray-100"}):(B.total_amount||0).toFixed(2)}),t.jsx("td",{className:"py-2 px-3 text-right text-gray-700 dark:text-gray-300 text-xs",children:(B.outstanding_amount||0).toFixed(2)}),t.jsx("td",{className:"py-2 px-3 text-right font-semibold text-gray-900 dark:text-white text-xs",children:H?t.jsx("input",{type:"number",min:0,step:"0.01",value:(me=B.allocated_amount)!=null?me:0,onChange:he=>z(Q,"allocated_amount",parseFloat(he.target.value)||0),className:"w-full border border-gray-200 rounded px-2 py-1 text-xs text-right bg-white dark:bg-gray-700 dark:border-gray-600 dark:text-gray-100"}):(B.allocated_amount||0).toFixed(2)}),H&&t.jsx("td",{className:"py-2 px-2",children:t.jsx("button",{onClick:()=>ae(Q),className:"p-1 text-red-400 hover:text-red-600 rounded",children:t.jsx(wr,{size:11})})})]},Q)}),H&&t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"py-2 px-3",children:t.jsxs("button",{onClick:G,className:"flex items-center gap-1.5 text-teal-600 hover:text-teal-700 text-sm font-medium",children:[t.jsx(Rr,{size:10})," Add Row"]})})})]})]})}),t.jsxs("div",{className:"flex justify-end mt-3 pt-3 border-t border-gray-100 dark:border-gray-700 gap-6 text-sm",children:[t.jsxs("span",{className:"text-gray-500",children:["Total Allocated: ",t.jsx("strong",{className:"text-gray-900 dark:text-white",children:ee.toFixed(2)})]}),t.jsxs("span",{className:"text-gray-500",children:["Unallocated: ",t.jsx("strong",{className:"text-gray-900 dark:text-white",children:Math.max(0,(T.paid_amount||0)-ee).toFixed(2)})]})]})]}),t.jsx(tp,{title:"Remarks",children:t.jsx("div",{children:H?t.jsx("textarea",{rows:3,value:T.remarks||"",onChange:B=>R("remarks",B.target.value),className:J0,placeholder:"Remarks…"}):t.jsx(Ei,{children:T.remarks})})}),!s&&t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 p-4",children:t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[{label:"Paid Amount",value:(T.paid_amount||0).toFixed(2)},{label:"Total Allocated",value:ee.toFixed(2)},{label:"Unallocated",value:Math.max(0,(T.paid_amount||0)-ee).toFixed(2)}].map(({label:B,value:Q})=>t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"text-[10px] font-semibold text-gray-500 uppercase mb-1",children:B}),t.jsx("span",{className:"font-semibold text-gray-900 dark:text-white",children:Q})]},B))})}),!s&&h&&t.jsx(vi,{doctype:"Payment Entry",docname:h.name||e||"",creationDate:h.creation,createdBy:h.owner,compact:!1,initialVisible:5,collapsible:!0,startCollapsed:!0})]})]})}const hN="SFDA Entries";class RSe{constructor(){$s(this,"baseURL");this.baseURL=Ar.BASE_URL}getHeaders(){return J(this,null,function*(){const r={Accept:"application/json","Content-Type":"application/json"};return typeof window!="undefined"&&window.csrf_token&&(r["X-Frappe-CSRF-Token"]=window.csrf_token),r})}getEntries(){return J(this,arguments,function*(r={}){const{filters:a={},fields:s=["name","title","date","passed","passed_date","creation","modified"],limit_start:n=0,limit_page_length:i=20,order_by:o="modified desc"}=r,l=new URLSearchParams;if(l.append("fields",JSON.stringify(s)),l.append("limit_start",n.toString()),l.append("limit_page_length",i.toString()),l.append("order_by",o),Object.keys(a).length>0){const h=xa(a);h.length>0&&l.append("filters",JSON.stringify(h))}const c=yield fetch(`${this.baseURL}/api/resource/${encodeURIComponent(hN)}?${l.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);return{data:(yield c.json()).data||[]}})}getEntry(r){return J(this,null,function*(){const a=yield fetch(`${this.baseURL}/api/resource/${encodeURIComponent(hN)}/${encodeURIComponent(r)}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return(yield a.json()).data})}getEntryCount(){return J(this,arguments,function*(r={}){var i,o;const a=new URLSearchParams;if(a.append("fields",JSON.stringify(["count(name) as count"])),Object.keys(r).length>0){const l=xa(r);l.length>0&&a.append("filters",JSON.stringify(l))}const s=yield fetch(`${this.baseURL}/api/resource/${encodeURIComponent(hN)}?${a.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return((o=(i=(yield s.json()).data)==null?void 0:i[0])==null?void 0:o.count)||0})}}const F4=new RSe;function MSe(e={}){const[r,a]=p.useState([]),[s,n]=p.useState(!0),[i,o]=p.useState(null),[l,c]=p.useState(0),u=JSON.stringify(e),h=p.useCallback(()=>J(null,null,function*(){try{n(!0),o(null);const[f,y]=yield Promise.all([F4.getEntries(e),F4.getEntryCount(e.filters||{})]);a(f.data),c(y)}catch(f){const y=f instanceof Error?f.message:"Failed to fetch SFDA entries";o(y),console.error("Error fetching SFDA entries:",f)}finally{n(!1)}}),[u]);return p.useEffect(()=>{h()},[h]),{entries:r,loading:s,error:i,totalCount:l,refetch:h}}function LSe(e){const[r,a]=p.useState(null),[s,n]=p.useState(!0),[i,o]=p.useState(null),l=p.useCallback(()=>J(null,null,function*(){if(!e){n(!1);return}try{n(!0),o(null);const c=yield F4.getEntry(e);a(c)}catch(c){const u=c instanceof Error?c.message:"Failed to fetch SFDA entry";o(u),console.error("Error fetching SFDA entry:",c)}finally{n(!1)}}),[e]);return p.useEffect(()=>{l()},[l]),{entry:r,loading:s,error:i,refetch:l}}function c9(e){const r=(e||"").trim().toLowerCase();return r==="yes"?0:r==="no"?1:2}function FSe(e){return(e||"").trim().toLowerCase()==="yes"}function ISe(e){const r=new Set;for(const a of e)if(FSe(a.serial_no_matching))for(const s of["serial_no","catalog_number"]){const n=a[s];if(n)for(const i of n.split(",")){const o=i.trim();o&&r.add(o)}}return Array.from(r)}function zSe(e){return[...e].sort((r,a)=>{var n,i;const s=c9(r.serial_no_matching)-c9(a.serial_no_matching);return s!==0?s:((n=r.idx)!=null?n:0)-((i=a.idx)!=null?i:0)})}function $Se(e){const r=e||[],a=p.useMemo(()=>zSe(r),[r]),s=p.useMemo(()=>ISe(r),[r]),n=s.join("\0"),[i,o]=p.useState(new Set),[l,c]=p.useState(!1);return p.useEffect(()=>{if(s.length===0){o(new Set),c(!1);return}let u=!1;return c(!0),Q0.getExistingSerialNumbers(s).then(h=>{u||o(h)}).catch(h=>{console.error("Error resolving SFDA asset matches:",h),u||o(new Set)}).finally(()=>{u||c(!1)}),()=>{u=!0}},[n]),{sortedDeviceList:a,matchedSerialNumbers:i,matchesLoading:l}}const USe=()=>{const{t:e}=sr(),r=hr(),[a,s]=_a(),n=p.useRef(s);p.useEffect(()=>{n.current=s},[s]);const i=p.useMemo(()=>{const ge=parseInt(a.get("page")||"1",10);return Number.isNaN(ge)||ge<1?1:ge},[a]),o=p.useCallback(ge=>{const be=typeof ge=="function"?ge(i):ge;s(K=>{const ye=new URLSearchParams(K);return ye.set("page",String(be)),ye})},[i,s]),l=20,[c,u]=p.useState(!1),[h,f]=p.useState(!0),[y,b]=p.useState(0),[w,v]=p.useState([]),[k,S]=p.useState(!1),[N,C]=p.useState(""),[O,T]=p.useState(()=>a.get("title")||""),[P,E]=p.useState(()=>a.get("passed")||""),[R,z]=p.useState(()=>a.get("date_start")||""),[G,ae]=p.useState(()=>a.get("date_end")||""),[ee,ne]=p.useState(()=>a.get("sort_by")||"modified desc");p.useEffect(()=>{const ge=localStorage.getItem("sfdaEntriesFilterPresets");ge&&v(JSON.parse(ge))},[]);const te=!!(R||G);p.useEffect(()=>{const ge=[O,P].filter(Boolean).length+(te?1:0);b(ge)},[O,P,te]);const Y=p.useMemo(()=>{const ge={};return O&&(ge.title=["like",`%${O}%`]),P==="1"&&(ge.passed=1),P==="0"&&(ge.passed=0),R&&G?ge.date=["between",[R,G]]:R?ge.date=[">=",R]:G&&(ge.date=["<=",G]),ge},[O,P,R,G]),q=["creation desc","creation asc","modified desc","modified asc","name asc","name desc","date desc","date asc"].includes(ee)?ee:"modified desc",{entries:H,loading:U,error:re,totalCount:X,refetch:V}=MSe({filters:Y,limit_start:(i-1)*l,limit_page_length:l,order_by:q});p.useEffect(()=>{!U&&!c&&u(!0)},[U,c]);const I=p.useRef(!1);p.useEffect(()=>{if(!I.current){I.current=!0;return}n.current(ge=>{const be=new URLSearchParams(ge);return O?be.set("title",O):be.delete("title"),P?be.set("passed",P):be.delete("passed"),R?be.set("date_start",R):be.delete("date_start"),G?be.set("date_end",G):be.delete("date_end"),ee&&ee!=="modified desc"?be.set("sort_by",ee):be.delete("sort_by"),be.set("page","1"),be})},[O,P,R,G,ee]);const B=()=>{T(""),E(""),z(""),ae(""),ne("modified desc"),n.current(ge=>{const be=new URLSearchParams(ge);return be.delete("title"),be.delete("passed"),be.delete("date_start"),be.delete("date_end"),be.delete("sort_by"),be.set("page","1"),be})},Q=!!(O||P||te),ie=()=>{if(!N.trim())return;const ge={id:Date.now(),name:N,filters:{titleFilter:O,passedFilter:P,dateStart:R,dateEnd:G,sortBy:ee}},be=[...w,ge];v(be),C(""),S(!1),localStorage.setItem("sfdaEntriesFilterPresets",JSON.stringify(be))},me=ge=>{const be=ge.filters;T(be.titleFilter||""),E(be.passedFilter||""),z(be.dateStart||""),ae(be.dateEnd||""),ne(be.sortBy||"modified desc")},he=ge=>{const be=w.filter(K=>K.id!==ge);v(be),localStorage.setItem("sfdaEntriesFilterPresets",JSON.stringify(be))},de=ge=>ge?new Date(ge).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-",xe=H.filter(ge=>ge.passed===1||ge.passed===!0).length;return U&&!c?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("sfdaEntries.loading")})]})}):re?t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:e("sfdaEntries.errorLoading")}),t.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:re}),t.jsx("button",{onClick:V,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:e("common.tryAgain")})]})}):t.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsx("div",{children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(iv,{className:"text-3xl text-blue-600 dark:text-blue-400"}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:e("sfdaEntries.title")}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[e("common.total"),": ",X,U&&c&&t.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400",children:[t.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-blue-500"}),"Updating..."]})]})]})]})}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("button",{onClick:()=>f(!h),className:`px-4 py-2 rounded-lg flex items-center gap-2 transition-colors ${h||Q?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300":"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600"}`,children:[t.jsx(ds,{}),e("listPages.filters"),y>0&&t.jsx("span",{className:"bg-blue-600 text-white text-xs px-1.5 py-0.5 rounded-full",children:y})]}),t.jsxs("button",{onClick:V,disabled:U,className:"px-4 py-2 rounded-lg bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 flex items-center gap-2 disabled:opacity-50",children:[t.jsx(Ma,{className:U?"animate-spin":""}),e("listPages.refresh")]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4",children:[t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e("common.total")}),t.jsx("p",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:X})]}),t.jsx(iv,{className:"text-3xl text-blue-500"})]})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e("sfdaEntries.stats.passed")}),t.jsx("p",{className:"text-2xl font-bold text-green-600",children:xe})]}),t.jsx(Qt,{className:"text-3xl text-green-500"})]})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:e("sfdaEntries.stats.notPassed")}),t.jsx("p",{className:"text-2xl font-bold text-orange-600",children:H.length-xe})]}),t.jsx(pr,{className:"text-3xl text-orange-500"})]})})]}),h&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-4",children:[t.jsx("div",{className:"bg-gradient-to-r from-blue-500 to-blue-600 dark:from-blue-600 dark:to-blue-700 px-4 py-3 rounded-t-lg",children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ds,{className:"text-white",size:16}),t.jsx("h3",{className:"text-white font-semibold text-sm",children:e("listPages.filters")}),y>0&&t.jsx("span",{className:"bg-white text-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:y})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[y>0&&t.jsxs("button",{onClick:()=>S(!0),className:"px-3 py-1.5 bg-white text-blue-600 hover:bg-blue-50 rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[t.jsx(ta,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:e("common.save")})]}),Q&&t.jsxs("button",{onClick:B,className:"px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[t.jsx(ht,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:e("common.clearFilters")})]})]})]})}),t.jsxs("div",{className:"p-4",children:[w.length>0&&t.jsxs("div",{className:"mb-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[t.jsx(a0,{className:"text-yellow-500",size:12}),e("sfdaEntries.savedFilters")]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:w.map(ge=>t.jsxs("div",{className:"group relative inline-flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-blue-100 to-indigo-100 dark:from-blue-900/30 dark:to-indigo-900/30 border border-blue-200 dark:border-blue-700 rounded-lg hover:shadow-md transition-all",children:[t.jsx("button",{onClick:()=>me(ge),className:"text-xs font-medium text-blue-700 dark:text-blue-300",children:ge.name}),t.jsx("button",{onClick:()=>he(ge.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:t.jsx(wr,{size:10})})]},ge.id))})]}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 p-3 rounded-lg",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("filters.sortBy")}),t.jsxs("select",{value:ee,onChange:ge=>{ne(ge.target.value),o(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"modified desc",children:e("filters.sortModifiedNewest")}),t.jsx("option",{value:"modified asc",children:e("filters.sortModifiedOldest")}),t.jsx("option",{value:"creation desc",children:e("filters.sortCreationNewest")}),t.jsx("option",{value:"creation asc",children:e("filters.sortCreationOldest")}),t.jsx("option",{value:"date desc",children:e("sfdaEntries.filters.dateNewest")}),t.jsx("option",{value:"date asc",children:e("sfdaEntries.filters.dateOldest")}),t.jsx("option",{value:"name asc",children:e("filters.sortNameAsc")}),t.jsx("option",{value:"name desc",children:e("filters.sortNameDesc")})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("sfdaEntries.filters.title")}),t.jsx("input",{type:"text",value:O,onChange:ge=>{T(ge.target.value),o(1)},placeholder:e("sfdaEntries.filters.titlePlaceholder"),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("sfdaEntries.filters.dateStart")}),t.jsx("input",{type:"date",value:R,onChange:ge=>{z(ge.target.value),o(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("sfdaEntries.filters.dateEnd")}),t.jsx("input",{type:"date",value:G,onChange:ge=>{ae(ge.target.value),o(1)},min:R||void 0,className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("sfdaEntries.filters.passed")}),t.jsxs("select",{value:P,onChange:ge=>{E(ge.target.value),o(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("listPages.all")}),t.jsx("option",{value:"1",children:e("common.yes")}),t.jsx("option",{value:"0",children:e("common.no")})]})]})]})})]})]}),k&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 animate-scale-in",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:e("common.saveFilterPreset")}),t.jsx("input",{type:"text",value:N,onChange:ge=>C(ge.target.value),onKeyDown:ge=>{ge.key==="Enter"&&ie()},placeholder:e("common.enterFilterName"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white mb-4",autoFocus:!0}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:()=>{S(!1),C("")},className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",children:e("common.cancel")}),t.jsxs("button",{onClick:ie,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors flex items-center gap-2",children:[t.jsx(ta,{size:12}),e("common.saveFilter")]})]})]})}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-200 dark:border-gray-700 overflow-hidden relative",children:[U&&c&&t.jsx("div",{className:"absolute inset-0 bg-white/60 dark:bg-gray-800/60 flex items-center justify-center z-10 backdrop-blur-[1px]",children:t.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-gray-700 px-4 py-2 rounded-lg shadow-lg",children:[t.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-blue-500"}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:e("common.filtering")})]})}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("sfdaEntries.columns.title")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("sfdaEntries.columns.date")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("sfdaEntries.columns.passed")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("listPages.actions")})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:H.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:4,className:"px-4 py-12 text-center text-gray-500 dark:text-gray-400",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx(iv,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("sfdaEntries.noEntriesFound")}),Q&&t.jsx("button",{onClick:B,className:"mt-4 text-blue-600 dark:text-blue-400 hover:underline",children:e("common.clearFilters")})]})})}):H.map(ge=>t.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 cursor-pointer transition-colors",onClick:()=>r(`/sfda-entries/${encodeURIComponent(ge.name)}`),children:[t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white line-clamp-2",children:ge.title||"-"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:de(ge.date)})}),t.jsx("td",{className:"px-4 py-3",children:ge.passed===1||ge.passed===!0?t.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300",children:[t.jsx(Qt,{size:10}),e("common.yes")]}):t.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-400",children:[t.jsx(pr,{size:10}),e("common.no")]})}),t.jsx("td",{className:"px-4 py-3",onClick:be=>be.stopPropagation(),children:t.jsx("button",{onClick:()=>r(`/sfda-entries/${encodeURIComponent(ge.name)}`),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded transition-colors",title:e("sfdaEntries.viewDetails"),children:t.jsx(Ps,{})})})]},ge.name))})]})}),t.jsx(_l,{currentPage:i,totalCount:X,pageSize:l,itemLabel:e("sfdaEntries.paginationLabel"),onPageChange:ge=>o(ge)})]}),t.jsx("style",{children:`
|
||
@keyframes scale-in { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
|
||
.animate-scale-in { animation: scale-in 0.2s ease-out; }
|
||
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }
|
||
.scrollbar-hide::-webkit-scrollbar { display: none; }
|
||
`})]})},I4=[{key:"ncmdr_ref",labelKey:"sfdaEntries.columns.ncmdrRef"},{key:"manufacturer",labelKey:"sfdaEntries.columns.manufacturer"},{key:"material",labelKey:"sfdaEntries.deviceFields.material"},{key:"serial_no",labelKey:"sfdaEntries.deviceFields.serialNo"},{key:"serial_no_matching",labelKey:"sfdaEntries.deviceFields.matching"}],z4=[{key:"catalog_number",labelKey:"sfdaEntries.deviceFields.catalogNumber"},{key:"udi",labelKey:"sfdaEntries.deviceFields.udi"},{key:"gstn",labelKey:"sfdaEntries.deviceFields.gtin"},{key:"material_description",labelKey:"sfdaEntries.deviceFields.materialDescription"},{key:"batch",labelKey:"sfdaEntries.deviceFields.batch"}],BSe=1+I4.length+2+z4.length;function WSe(e){return e?e.startsWith("http")?e:`${e}`:null}function HSe(e){return(e||"").trim().toLowerCase()==="yes"}function qSe(e){return(e||"").trim()||"-"}const d9=({value:e,isMatch:r,onNavigate:a,title:s})=>{const n=(e||"").trim();return n?r?t.jsx("button",{type:"button",title:s,onClick:()=>a(`/assets?serial_number=${encodeURIComponent(n)}`),className:"text-red-600 dark:text-red-400 hover:underline font-medium text-left text-xs line-clamp-3 break-words",children:n}):t.jsx("span",{className:"text-xs line-clamp-3 break-words",children:n}):t.jsx(t.Fragment,{children:"-"})},VSe=()=>{const{t:e}=sr(),{entryName:r}=hs(),a=hr(),{entry:s,loading:n,error:i}=LSe(r||null),o=v=>v?new Date(v).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-",l=v=>v?new Date(v).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"-",c=v=>{if(!v)return"-";const k=v.indexOf("@");return k===-1?v:v.substring(0,k)},u=(s==null?void 0:s.passed)===1||(s==null?void 0:s.passed)===!0,h=(s==null?void 0:s.device_list)||[],{sortedDeviceList:f,matchedSerialNumbers:y,matchesLoading:b}=$Se(h),w=p.useMemo(()=>{const v=new Set;return h.forEach(k=>{k.ncmdr_ref&&v.add(k.ncmdr_ref)}),v.size},[h]);return n?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("sfdaEntries.detail.loading")})]})}):i||!s?t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:e("sfdaEntries.detail.errorLoading")}),t.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:i||e("sfdaEntries.detail.notFound")}),t.jsx("button",{onClick:()=>a("/sfda-entries"),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:e("sfdaEntries.detail.backToList")})]})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[t.jsx("div",{className:"mb-6 flex justify-between items-center",children:t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("button",{onClick:()=>a("/sfda-entries"),className:"text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200",children:t.jsx(ia,{size:20})}),t.jsxs("div",{children:[t.jsxs("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white flex items-center gap-3 flex-wrap",children:[t.jsx(iv,{className:"text-blue-500"}),s.title||s.name,t.jsxs("span",{className:`inline-flex items-center gap-1 px-3 py-1 rounded-full text-sm font-medium ${u?"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300 border border-green-200 dark:border-green-800":"bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-gray-600"}`,children:[u?t.jsx(Qt,{size:12}):t.jsx(pr,{size:12}),e(u?"sfdaEntries.detail.passed":"sfdaEntries.detail.notPassed")]})]}),t.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:[o(s.date)," · ",w," ",e("sfdaEntries.detail.alerts")," · ",h.length," ",e("sfdaEntries.detail.devices")]})]})]})}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6 mb-6",children:[t.jsx("div",{className:"lg:col-span-3",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700 h-full",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(ro,{className:"text-blue-500"}),e("sfdaEntries.detail.entryInformation")]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsx(tv,{label:e("sfdaEntries.columns.title"),value:s.title,highlight:!0}),t.jsx(tv,{label:e("sfdaEntries.columns.date"),value:o(s.date)}),t.jsx(tv,{label:e("sfdaEntries.detail.alertCount"),value:String(w)}),t.jsx(tv,{label:e("sfdaEntries.detail.passedDate"),value:l(s.passed_date)})]})]})}),t.jsx("div",{className:"lg:col-span-1",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-4 border border-gray-200 dark:border-gray-700 h-full",children:[t.jsxs("h2",{className:"text-sm font-semibold text-gray-800 dark:text-white mb-3 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[t.jsx(nn,{className:"text-purple-500",size:14}),e("sfdaEntries.detail.auditInfo")]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"p-2 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:e("commonFields.createdOn")}),t.jsx("p",{className:"text-xs font-medium text-gray-900 dark:text-white",children:l(s.creation)})]}),t.jsxs("div",{className:"p-2 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:e("commonFields.createdBy")}),t.jsx("p",{className:"text-xs font-medium text-gray-900 dark:text-white",children:c(s.owner)})]}),t.jsxs("div",{className:"p-2 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:e("commonFields.modifiedOn")}),t.jsx("p",{className:"text-xs font-medium text-gray-900 dark:text-white",children:l(s.modified)})]})]})]})})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white flex items-center gap-2",children:[t.jsx(J9,{className:"text-orange-500"}),e("sfdaEntries.detail.deviceList")]}),t.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400 flex items-center gap-2",children:[f.length," ",e("sfdaEntries.detail.devices"),b&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400",children:[t.jsx("span",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-blue-500"}),e("sfdaEntries.detail.resolvingMatches")]})]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-2 py-2 text-left text-[10px] font-medium text-gray-500 dark:text-gray-400 uppercase",children:"#"}),I4.map(v=>t.jsx("th",{className:"px-2 py-2 text-left text-[10px] font-medium text-gray-500 dark:text-gray-400 uppercase whitespace-nowrap",children:e(v.labelKey)},v.key)),t.jsx("th",{className:"px-2 py-2 text-left text-[10px] font-medium text-gray-500 dark:text-gray-400 uppercase whitespace-nowrap",children:e("sfdaEntries.detail.adeDetailPdf")}),t.jsx("th",{className:"px-2 py-2 text-left text-[10px] font-medium text-gray-500 dark:text-gray-400 uppercase whitespace-nowrap",children:e("sfdaEntries.detail.adeDetailUrl")}),z4.map(v=>t.jsx("th",{className:"px-2 py-2 text-left text-[10px] font-medium text-gray-500 dark:text-gray-400 uppercase whitespace-nowrap",children:e(v.labelKey)},v.key))]})}),t.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:f.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:BSe,className:"px-2 py-6 text-center text-xs text-gray-500 dark:text-gray-400",children:e("sfdaEntries.detail.noDevices")})}):f.map((v,k)=>{const S=WSe(v.detail_pdf),N=HSe(v.serial_no_matching),C=(v.serial_no||"").trim(),O=(v.catalog_number||"").trim(),T=N&&C!==""&&y.has(C),P=N&&O!==""&&y.has(O),E=e("sfdaEntries.detail.openMatchingAsset"),R=z=>t.jsx("td",{className:"px-2 py-2 text-xs text-gray-700 dark:text-gray-300 max-w-[10rem]",children:z.key==="serial_no_matching"?t.jsx("span",{className:"line-clamp-3 break-words",children:qSe(v.serial_no_matching)}):z.key==="serial_no"?t.jsx(d9,{value:v.serial_no,isMatch:T,onNavigate:a,title:E}):z.key==="catalog_number"?t.jsx(d9,{value:v.catalog_number,isMatch:P,onNavigate:a,title:E}):t.jsx("span",{className:"line-clamp-3 break-words",children:v[z.key]||"-"})},z.key);return t.jsxs("tr",{className:N?"bg-orange-50 dark:bg-orange-900/25 hover:bg-orange-100 dark:hover:bg-orange-900/35":"hover:bg-gray-50 dark:hover:bg-gray-700/50",children:[t.jsx("td",{className:"px-2 py-2 text-xs text-gray-500 dark:text-gray-400",children:k+1}),I4.map(R),t.jsx("td",{className:"px-2 py-2 text-xs",children:S?t.jsxs("a",{href:S,target:"_blank",rel:"noopener noreferrer",className:"text-red-600 dark:text-red-400 hover:underline inline-flex items-center gap-1 whitespace-nowrap",children:[t.jsx(_x,{size:10}),e("sfdaEntries.detail.openPdfNewTab")]}):"-"}),t.jsx("td",{className:"px-2 py-2 text-xs max-w-[6rem]",children:v.ade_detail_url?t.jsx("a",{href:v.ade_detail_url,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:underline inline-flex items-center gap-1",title:e("sfdaEntries.detail.viewAde"),children:t.jsx(dn,{size:9})}):"-"}),z4.map(R)]},v.name||k)})})]})})]})]})},tv=({label:e,value:r,highlight:a})=>t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:e}),t.jsx("div",{className:`px-3 py-2 rounded-md border text-sm ${a?"bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800 text-blue-800 dark:text-blue-300 font-medium":"bg-gray-50 dark:bg-gray-700/50 border-gray-200 dark:border-gray-600 text-gray-900 dark:text-white"}`,children:r||"-"})]}),yr=({children:e})=>{const r=localStorage.getItem("user"),a=r?JSON.parse(r).email:"";return t.jsx(foe,{children:t.jsxs("div",{className:"flex h-screen overflow-hidden bg-gray-50 dark:bg-gray-900",children:[t.jsx(woe,{userEmail:a}),t.jsxs("div",{className:"asm-app-main flex min-w-0 flex-1 flex-col overflow-hidden",children:[t.jsx(Coe,{userEmail:a}),t.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 dark:bg-gray-900",children:e})]})]})})},br=({children:e})=>{const[r,a]=p.useState("loading");return p.useEffect(()=>{let s=!1;return J(null,null,function*(){if(localStorage.getItem("user")){s||a("authed");return}const n=yield L9();s||a(n.ok?"authed":"guest")}),()=>{s=!0}},[]),r==="loading"?t.jsx("div",{className:"flex h-screen items-center justify-center bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"flex flex-col items-center gap-3 text-gray-600 dark:text-gray-400",children:[t.jsxs("svg",{className:"h-10 w-10 animate-spin text-indigo-600",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","aria-hidden":!0,children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.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"})]}),t.jsx("span",{className:"text-sm",children:"Loading…"})]})}):r==="guest"?t.jsx(bf,{to:"/login",replace:!0}):t.jsx(t.Fragment,{children:e})},GSe=()=>t.jsx(ZV,{basename:"/asm_app",children:t.jsxs(CV,{children:[t.jsx(ur,{path:"/login",element:t.jsx(cG,{})}),t.jsx(ur,{path:"/dashboard",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(Ute,{})})})}),t.jsx(ur,{path:"/assets",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(Fse,{})})})}),t.jsx(ur,{path:"/assets/:assetName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(nne,{})})})}),t.jsx(ur,{path:"/work-orders",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(vne,{})})})}),t.jsx(ur,{path:"/work-orders/:workOrderName/troubleshoot",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(I7,{})})})}),t.jsx(ur,{path:"/work-orders/:workOrderName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(Tne,{})})})}),t.jsx(ur,{path:"/maintenance",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(Ene,{})})})}),t.jsx(ur,{path:"/maintenance/:logName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(Pne,{})})})}),t.jsx(ur,{path:"/ppm",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(Lne,{})})})}),t.jsx(ur,{path:"/ppm/:ppmName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(Fne,{})})})}),t.jsx(ur,{path:"/ppm-planner",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(Wne,{})})})}),t.jsx(ur,{path:"/ppm-planner/new",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(zne,{})})})}),t.jsx(ur,{path:"/ppm-planner/:scheduleName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(Hne,{})})})}),t.jsx(ur,{path:"/maintenance-calendar",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(O7,{})})})}),t.jsx(ur,{path:"/maintenance-calendar/month-view",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(Vne,{})})})}),t.jsx(ur,{path:"/yearly-ppm-planner",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(O7,{})})})}),t.jsx(ur,{path:"/active-map",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(gie,{})})})}),t.jsx(ur,{path:"/inventory",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(vie,{})})})}),t.jsx(ur,{path:"/inventory/:itemName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(wie,{})})})}),t.jsx(ur,{path:"/users",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(Iae,{})})})}),t.jsx(ur,{path:"/events",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(zae,{})})})}),t.jsx(ur,{path:"/old-dashboard",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(xG,{})})})}),t.jsx(ur,{path:"/maintenance-teams",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(sle,{})})})}),t.jsx(ur,{path:"/maintenance-teams/:teamName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(nle,{})})})}),t.jsx(ur,{path:"/inspections",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(gle,{})})})}),t.jsx(ur,{path:"/inspections/:inspectionName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(xle,{})})})}),t.jsx(ur,{path:"/procurement",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(poe,{title:"Procurement"})})})}),t.jsx(ur,{path:"/sla",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(Nle,{})})})}),t.jsx(ur,{path:"/sla/:slaName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(Sle,{})})})}),t.jsx(ur,{path:"/support",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(Loe,{})})})}),t.jsx(ur,{path:"/support/troubleshoot",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(I7,{})})})}),t.jsx(ur,{path:"/support/:issueName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(qoe,{})})})}),t.jsx(ur,{path:"/user-profile",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(Ple,{})})})}),t.jsx(ur,{path:"/projects",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(Ble,{})})})}),t.jsx(ur,{path:"/projects/reports",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(ANe,{})})})}),t.jsx(ur,{path:"/projects/project-updates",element:t.jsx(bf,{to:"/projects",replace:!0})}),t.jsx(ur,{path:"/projects/project-updates/:updateName",element:t.jsx(bf,{to:"/projects",replace:!0})}),t.jsx(ur,{path:"/projects/list",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(VNe,{})})})}),t.jsx(ur,{path:"/projects/list/:projectName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(GNe,{})})})}),t.jsx(ur,{path:"/projects/tasks",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(JNe,{})})})}),t.jsx(ur,{path:"/projects/tasks/:taskName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(a4e,{})})})}),t.jsx(ur,{path:"/projects/timesheets",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(n4e,{})})})}),t.jsx(ur,{path:"/projects/timesheets/:timesheetName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(o4e,{})})})}),t.jsx(ur,{path:"/projects/activity-types",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(l4e,{})})})}),t.jsx(ur,{path:"/projects/activity-types/:activityTypeName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(c4e,{})})})}),t.jsx(ur,{path:"/projects/templates",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(d4e,{})})})}),t.jsx(ur,{path:"/projects/templates/:templateName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(m4e,{})})})}),t.jsx(ur,{path:"/customers",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(p4e,{})})})}),t.jsx(ur,{path:"/customers/:customerName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(x4e,{})})})}),t.jsx(ur,{path:"/employees",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(b4e,{})})})}),t.jsx(ur,{path:"/employees/:employeeName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(w4e,{})})})}),t.jsx(ur,{path:"/invoices",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(_4e,{})})})}),t.jsx(ur,{path:"/invoices/:invoiceName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(O4e,{})})})}),t.jsx(ur,{path:"/sales-orders",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(M4e,{})})})}),t.jsx(ur,{path:"/sales-orders/:soName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(U4e,{})})})}),t.jsx(ur,{path:"/purchase-orders",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(H4e,{})})})}),t.jsx(ur,{path:"/purchase-orders/:poName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(J4e,{})})})}),t.jsx(ur,{path:"/delivery-notes",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(eSe,{})})})}),t.jsx(ur,{path:"/delivery-notes/:dnName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(oSe,{})})})}),t.jsx(ur,{path:"/material-requests",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(uSe,{})})})}),t.jsx(ur,{path:"/material-requests/:mrName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(fSe,{})})})}),t.jsx(ur,{path:"/purchase-receipts",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(vSe,{})})})}),t.jsx(ur,{path:"/purchase-receipts/:prName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(SSe,{})})})}),t.jsx(ur,{path:"/payment-entries",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(ESe,{})})})}),t.jsx(ur,{path:"/payment-entries/:peName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(DSe,{})})})}),t.jsx(ur,{path:"/sfda-entries",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(USe,{})})})}),t.jsx(ur,{path:"/sfda-entries/:entryName",element:t.jsx(br,{children:t.jsx(yr,{children:t.jsx(VSe,{})})})}),t.jsx(ur,{path:"/",element:t.jsx(bf,{to:"/login",replace:!0})}),t.jsx(ur,{path:"*",element:t.jsx(bf,{to:"/login",replace:!0})})]})});RW.createRoot(document.getElementById("root")).render(t.jsx(p.StrictMode,{children:t.jsx(goe,{children:t.jsx(joe,{children:t.jsx(GSe,{})})})}))});export default KSe();
|