1924 lines
2.9 MiB
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var KC=Object.defineProperty,JC=Object.defineProperties;var QC=Object.getOwnPropertyDescriptors;var rm=Object.getOwnPropertySymbols;var fw=Object.prototype.hasOwnProperty,hw=Object.prototype.propertyIsEnumerable;var k0=(e,r)=>(r=Symbol[e])?r:Symbol.for("Symbol."+e),e6=e=>{throw TypeError(e)};var yp=(e,r,a)=>r in e?KC(e,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[r]=a,Te=(e,r)=>{for(var a in r||(r={}))fw.call(r,a)&&yp(e,a,r[a]);if(rm)for(var a of rm(r))hw.call(r,a)&&yp(e,a,r[a]);return e},Ke=(e,r)=>JC(e,QC(r));var Ji=(e,r)=>{var a={};for(var s in e)fw.call(e,s)&&r.indexOf(s)<0&&(a[s]=e[s]);if(e!=null&&rm)for(var s of rm(e))r.indexOf(s)<0&&hw.call(e,s)&&(a[s]=e[s]);return a};var Ii=(e,r,a)=>yp(e,typeof r!="symbol"?r+"":r,a);var me=(e,r,a)=>new Promise((s,n)=>{var i=h=>{try{u(a.next(h))}catch(g){n(g)}},c=h=>{try{u(a.throw(h))}catch(g){n(g)}},u=h=>h.done?s(h.value):Promise.resolve(h.value).then(i,c);u((a=a.apply(e,r)).next())}),xd=function(e,r){this[0]=e,this[1]=r},bp=(e,r,a)=>{var s=(c,u,h,g)=>{try{var y=a[c](u),w=(u=y.value)instanceof xd,E=y.done;Promise.resolve(w?u[0]:u).then(S=>w?s(c==="return"?c:"next",u[1]?{done:S.done,value:S.value}:S,h,g):h({value:S,done:E})).catch(S=>s("throw",S,h,g))}catch(S){g(S)}},n=c=>i[c]=u=>new Promise((h,g)=>s(c,u,h,g)),i={};return a=a.apply(e,r),i[k0("asyncIterator")]=()=>i,n("next"),n("throw"),n("return"),i},vp=e=>{var r=e[k0("asyncIterator")],a=!1,s,n={};return r==null?(r=e[k0("iterator")](),s=i=>n[i]=c=>r[i](c)):(r=r.call(e),s=i=>n[i]=c=>{if(a){if(a=!1,i==="throw")throw c;return c}return a=!0,{done:!1,value:new xd(new Promise(u=>{var h=r[i](c);h instanceof Object||e6("Object expected"),u(h)}),1)}}),n[k0("iterator")]=()=>n,s("next"),"throw"in r?s("throw"):n.throw=i=>{throw i},"return"in r&&s("return"),n},mw=(e,r,a)=>(r=e[k0("asyncIterator")])?r.call(e):(e=e[k0("iterator")](),r={},a=(s,n)=>(n=e[s])&&(r[s]=i=>new Promise((c,u,h)=>(i=n.call(e,i),h=i.done,Promise.resolve(i.value).then(g=>c({value:g,done:h}),u)))),a("next"),a("return"),r);function t6(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 c of i.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).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)}})();var am=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function J1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var wp={exports:{}},Gu={};var gw;function r6(){if(gw)return Gu;gw=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function a(s,n,i){var c=null;if(i!==void 0&&(c=""+i),n.key!==void 0&&(c=""+n.key),"key"in n){i={};for(var u in n)u!=="key"&&(i[u]=n[u])}else i=n;return n=i.ref,{$$typeof:e,type:s,key:c,ref:n!==void 0?n:null,props:i}}return Gu.Fragment=r,Gu.jsx=a,Gu.jsxs=a,Gu}var xw;function a6(){return xw||(xw=1,wp.exports=r6()),wp.exports}var t=a6(),_p={exports:{}},ma={};var pw;function s6(){if(pw)return ma;pw=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"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),w=Symbol.for("react.activity"),E=Symbol.iterator;function S(te){return te===null||typeof te!="object"?null:(te=E&&te[E]||te["@@iterator"],typeof te=="function"?te:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,O={};function M(te,q,J){this.props=te,this.context=q,this.refs=O,this.updater=J||A}M.prototype.isReactComponent={},M.prototype.setState=function(te,q){if(typeof te!="object"&&typeof te!="function"&&te!=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,te,q,"setState")},M.prototype.forceUpdate=function(te){this.updater.enqueueForceUpdate(this,te,"forceUpdate")};function R(){}R.prototype=M.prototype;function F(te,q,J){this.props=te,this.context=q,this.refs=O,this.updater=J||A}var z=F.prototype=new R;z.constructor=F,C(z,M.prototype),z.isPureReactComponent=!0;var W=Array.isArray;function X(){}var B={H:null,A:null,T:null,S:null},Y=Object.prototype.hasOwnProperty;function G(te,q,J){var ae=J.ref;return{$$typeof:e,type:te,key:q,ref:ae!==void 0?ae:null,props:J}}function ie(te,q){return G(te.type,q,te.props)}function fe(te){return typeof te=="object"&&te!==null&&te.$$typeof===e}function K(te){var q={"=":"=0",":":"=2"};return"$"+te.replace(/[=:]/g,function(J){return q[J]})}var ke=/\/+/g;function ge(te,q){return typeof te=="object"&&te!==null&&te.key!=null?K(""+te.key):q.toString(36)}function re(te){switch(te.status){case"fulfilled":return te.value;case"rejected":throw te.reason;default:switch(typeof te.status=="string"?te.then(X,X):(te.status="pending",te.then(function(q){te.status==="pending"&&(te.status="fulfilled",te.value=q)},function(q){te.status==="pending"&&(te.status="rejected",te.reason=q)})),te.status){case"fulfilled":return te.value;case"rejected":throw te.reason}}throw te}function we(te,q,J,ae,oe){var le=typeof te;(le==="undefined"||le==="boolean")&&(te=null);var be=!1;if(te===null)be=!0;else switch(le){case"bigint":case"string":case"number":be=!0;break;case"object":switch(te.$$typeof){case e:case r:be=!0;break;case y:return be=te._init,we(be(te._payload),q,J,ae,oe)}}if(be)return oe=oe(te),be=ae===""?"."+ge(te,0):ae,W(oe)?(J="",be!=null&&(J=be.replace(ke,"$&/")+"/"),we(oe,q,J,"",function(Pe){return Pe})):oe!=null&&(fe(oe)&&(oe=ie(oe,J+(oe.key==null||te&&te.key===oe.key?"":(""+oe.key).replace(ke,"$&/")+"/")+be)),q.push(oe)),1;be=0;var Z=ae===""?".":ae+":";if(W(te))for(var Le=0;Le<te.length;Le++)ae=te[Le],le=Z+ge(ae,Le),be+=we(ae,q,J,le,oe);else if(Le=S(te),typeof Le=="function")for(te=Le.call(te),Le=0;!(ae=te.next()).done;)ae=ae.value,le=Z+ge(ae,Le++),be+=we(ae,q,J,le,oe);else if(le==="object"){if(typeof te.then=="function")return we(re(te),q,J,ae,oe);throw q=String(te),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys(te).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.")}return be}function ee(te,q,J){if(te==null)return te;var ae=[],oe=0;return we(te,ae,"","",function(le){return q.call(J,le,oe++)}),ae}function ve(te){if(te._status===-1){var q=te._result;q=q(),q.then(function(J){(te._status===0||te._status===-1)&&(te._status=1,te._result=J)},function(J){(te._status===0||te._status===-1)&&(te._status=2,te._result=J)}),te._status===-1&&(te._status=0,te._result=q)}if(te._status===1)return te._result.default;throw te._result}var ce=typeof reportError=="function"?reportError:function(te){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var q=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof te=="object"&&te!==null&&typeof te.message=="string"?String(te.message):String(te),error:te});if(!window.dispatchEvent(q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",te);return}console.error(te)},ye={map:ee,forEach:function(te,q,J){ee(te,function(){q.apply(this,arguments)},J)},count:function(te){var q=0;return ee(te,function(){q++}),q},toArray:function(te){return ee(te,function(q){return q})||[]},only:function(te){if(!fe(te))throw Error("React.Children.only expected to receive a single React element child.");return te}};return ma.Activity=w,ma.Children=ye,ma.Component=M,ma.Fragment=a,ma.Profiler=n,ma.PureComponent=F,ma.StrictMode=s,ma.Suspense=h,ma.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=B,ma.__COMPILER_RUNTIME={__proto__:null,c:function(te){return B.H.useMemoCache(te)}},ma.cache=function(te){return function(){return te.apply(null,arguments)}},ma.cacheSignal=function(){return null},ma.cloneElement=function(te,q,J){if(te==null)throw Error("The argument must be a React element, but you passed "+te+".");var ae=C({},te.props),oe=te.key;if(q!=null)for(le in q.key!==void 0&&(oe=""+q.key),q)!Y.call(q,le)||le==="key"||le==="__self"||le==="__source"||le==="ref"&&q.ref===void 0||(ae[le]=q[le]);var le=arguments.length-2;if(le===1)ae.children=J;else if(1<le){for(var be=Array(le),Z=0;Z<le;Z++)be[Z]=arguments[Z+2];ae.children=be}return G(te.type,oe,ae)},ma.createContext=function(te){return te={$$typeof:c,_currentValue:te,_currentValue2:te,_threadCount:0,Provider:null,Consumer:null},te.Provider=te,te.Consumer={$$typeof:i,_context:te},te},ma.createElement=function(te,q,J){var ae,oe={},le=null;if(q!=null)for(ae in q.key!==void 0&&(le=""+q.key),q)Y.call(q,ae)&&ae!=="key"&&ae!=="__self"&&ae!=="__source"&&(oe[ae]=q[ae]);var be=arguments.length-2;if(be===1)oe.children=J;else if(1<be){for(var Z=Array(be),Le=0;Le<be;Le++)Z[Le]=arguments[Le+2];oe.children=Z}if(te&&te.defaultProps)for(ae in be=te.defaultProps,be)oe[ae]===void 0&&(oe[ae]=be[ae]);return G(te,le,oe)},ma.createRef=function(){return{current:null}},ma.forwardRef=function(te){return{$$typeof:u,render:te}},ma.isValidElement=fe,ma.lazy=function(te){return{$$typeof:y,_payload:{_status:-1,_result:te},_init:ve}},ma.memo=function(te,q){return{$$typeof:g,type:te,compare:q===void 0?null:q}},ma.startTransition=function(te){var q=B.T,J={};B.T=J;try{var ae=te(),oe=B.S;oe!==null&&oe(J,ae),typeof ae=="object"&&ae!==null&&typeof ae.then=="function"&&ae.then(X,ce)}catch(le){ce(le)}finally{q!==null&&J.types!==null&&(q.types=J.types),B.T=q}},ma.unstable_useCacheRefresh=function(){return B.H.useCacheRefresh()},ma.use=function(te){return B.H.use(te)},ma.useActionState=function(te,q,J){return B.H.useActionState(te,q,J)},ma.useCallback=function(te,q){return B.H.useCallback(te,q)},ma.useContext=function(te){return B.H.useContext(te)},ma.useDebugValue=function(){},ma.useDeferredValue=function(te,q){return B.H.useDeferredValue(te,q)},ma.useEffect=function(te,q){return B.H.useEffect(te,q)},ma.useEffectEvent=function(te){return B.H.useEffectEvent(te)},ma.useId=function(){return B.H.useId()},ma.useImperativeHandle=function(te,q,J){return B.H.useImperativeHandle(te,q,J)},ma.useInsertionEffect=function(te,q){return B.H.useInsertionEffect(te,q)},ma.useLayoutEffect=function(te,q){return B.H.useLayoutEffect(te,q)},ma.useMemo=function(te,q){return B.H.useMemo(te,q)},ma.useOptimistic=function(te,q){return B.H.useOptimistic(te,q)},ma.useReducer=function(te,q,J){return B.H.useReducer(te,q,J)},ma.useRef=function(te){return B.H.useRef(te)},ma.useState=function(te){return B.H.useState(te)},ma.useSyncExternalStore=function(te,q,J){return B.H.useSyncExternalStore(te,q,J)},ma.useTransition=function(){return B.H.useTransition()},ma.version="19.2.1",ma}var yw;function ug(){return yw||(yw=1,_p.exports=s6()),_p.exports}var _=ug();const ea=J1(_);var kp={exports:{}},Yu={},Np={exports:{}},jp={};var bw;function n6(){return bw||(bw=1,(function(e){function r(we,ee){var ve=we.length;we.push(ee);e:for(;0<ve;){var ce=ve-1>>>1,ye=we[ce];if(0<n(ye,ee))we[ce]=ee,we[ve]=ye,ve=ce;else break e}}function a(we){return we.length===0?null:we[0]}function s(we){if(we.length===0)return null;var ee=we[0],ve=we.pop();if(ve!==ee){we[0]=ve;e:for(var ce=0,ye=we.length,te=ye>>>1;ce<te;){var q=2*(ce+1)-1,J=we[q],ae=q+1,oe=we[ae];if(0>n(J,ve))ae<ye&&0>n(oe,J)?(we[ce]=oe,we[ae]=ve,ce=ae):(we[ce]=J,we[q]=ve,ce=q);else if(ae<ye&&0>n(oe,ve))we[ce]=oe,we[ae]=ve,ce=ae;else break e}}return ee}function n(we,ee){var ve=we.sortIndex-ee.sortIndex;return ve!==0?ve:we.id-ee.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 c=Date,u=c.now();e.unstable_now=function(){return c.now()-u}}var h=[],g=[],y=1,w=null,E=3,S=!1,A=!1,C=!1,O=!1,M=typeof setTimeout=="function"?setTimeout:null,R=typeof clearTimeout=="function"?clearTimeout:null,F=typeof setImmediate!="undefined"?setImmediate:null;function z(we){for(var ee=a(g);ee!==null;){if(ee.callback===null)s(g);else if(ee.startTime<=we)s(g),ee.sortIndex=ee.expirationTime,r(h,ee);else break;ee=a(g)}}function W(we){if(C=!1,z(we),!A)if(a(h)!==null)A=!0,X||(X=!0,K());else{var ee=a(g);ee!==null&&re(W,ee.startTime-we)}}var X=!1,B=-1,Y=5,G=-1;function ie(){return O?!0:!(e.unstable_now()-G<Y)}function fe(){if(O=!1,X){var we=e.unstable_now();G=we;var ee=!0;try{e:{A=!1,C&&(C=!1,R(B),B=-1),S=!0;var ve=E;try{t:{for(z(we),w=a(h);w!==null&&!(w.expirationTime>we&&ie());){var ce=w.callback;if(typeof ce=="function"){w.callback=null,E=w.priorityLevel;var ye=ce(w.expirationTime<=we);if(we=e.unstable_now(),typeof ye=="function"){w.callback=ye,z(we),ee=!0;break t}w===a(h)&&s(h),z(we)}else s(h);w=a(h)}if(w!==null)ee=!0;else{var te=a(g);te!==null&&re(W,te.startTime-we),ee=!1}}break e}finally{w=null,E=ve,S=!1}ee=void 0}}finally{ee?K():X=!1}}}var K;if(typeof F=="function")K=function(){F(fe)};else if(typeof MessageChannel!="undefined"){var ke=new MessageChannel,ge=ke.port2;ke.port1.onmessage=fe,K=function(){ge.postMessage(null)}}else K=function(){M(fe,0)};function re(we,ee){B=M(function(){we(e.unstable_now())},ee)}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(we){we.callback=null},e.unstable_forceFrameRate=function(we){0>we||125<we?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Y=0<we?Math.floor(1e3/we):5},e.unstable_getCurrentPriorityLevel=function(){return E},e.unstable_next=function(we){switch(E){case 1:case 2:case 3:var ee=3;break;default:ee=E}var ve=E;E=ee;try{return we()}finally{E=ve}},e.unstable_requestPaint=function(){O=!0},e.unstable_runWithPriority=function(we,ee){switch(we){case 1:case 2:case 3:case 4:case 5:break;default:we=3}var ve=E;E=we;try{return ee()}finally{E=ve}},e.unstable_scheduleCallback=function(we,ee,ve){var ce=e.unstable_now();switch(typeof ve=="object"&&ve!==null?(ve=ve.delay,ve=typeof ve=="number"&&0<ve?ce+ve:ce):ve=ce,we){case 1:var ye=-1;break;case 2:ye=250;break;case 5:ye=1073741823;break;case 4:ye=1e4;break;default:ye=5e3}return ye=ve+ye,we={id:y++,callback:ee,priorityLevel:we,startTime:ve,expirationTime:ye,sortIndex:-1},ve>ce?(we.sortIndex=ve,r(g,we),a(h)===null&&we===a(g)&&(C?(R(B),B=-1):C=!0,re(W,ve-ce))):(we.sortIndex=ye,r(h,we),A||S||(A=!0,X||(X=!0,K()))),we},e.unstable_shouldYield=ie,e.unstable_wrapCallback=function(we){var ee=E;return function(){var ve=E;E=ee;try{return we.apply(this,arguments)}finally{E=ve}}}})(jp)),jp}var vw;function i6(){return vw||(vw=1,Np.exports=n6()),Np.exports}var Sp={exports:{}},vi={};var ww;function o6(){if(ww)return vi;ww=1;var e=ug();function r(h){var g="https://react.dev/errors/"+h;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)g+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+h+"; visit "+g+" 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(h,g,y){var w=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:n,key:w==null?null:""+w,children:h,containerInfo:g,implementation:y}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(h,g){if(h==="font")return"";if(typeof g=="string")return g==="use-credentials"?g:""}return vi.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,vi.createPortal=function(h,g){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!g||g.nodeType!==1&&g.nodeType!==9&&g.nodeType!==11)throw Error(r(299));return i(h,g,null,y)},vi.flushSync=function(h){var g=c.T,y=s.p;try{if(c.T=null,s.p=2,h)return h()}finally{c.T=g,s.p=y,s.d.f()}},vi.preconnect=function(h,g){typeof h=="string"&&(g?(g=g.crossOrigin,g=typeof g=="string"?g==="use-credentials"?g:"":void 0):g=null,s.d.C(h,g))},vi.prefetchDNS=function(h){typeof h=="string"&&s.d.D(h)},vi.preinit=function(h,g){if(typeof h=="string"&&g&&typeof g.as=="string"){var y=g.as,w=u(y,g.crossOrigin),E=typeof g.integrity=="string"?g.integrity:void 0,S=typeof g.fetchPriority=="string"?g.fetchPriority:void 0;y==="style"?s.d.S(h,typeof g.precedence=="string"?g.precedence:void 0,{crossOrigin:w,integrity:E,fetchPriority:S}):y==="script"&&s.d.X(h,{crossOrigin:w,integrity:E,fetchPriority:S,nonce:typeof g.nonce=="string"?g.nonce:void 0})}},vi.preinitModule=function(h,g){if(typeof h=="string")if(typeof g=="object"&&g!==null){if(g.as==null||g.as==="script"){var y=u(g.as,g.crossOrigin);s.d.M(h,{crossOrigin:y,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0})}}else g==null&&s.d.M(h)},vi.preload=function(h,g){if(typeof h=="string"&&typeof g=="object"&&g!==null&&typeof g.as=="string"){var y=g.as,w=u(y,g.crossOrigin);s.d.L(h,y,{crossOrigin:w,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0,type:typeof g.type=="string"?g.type:void 0,fetchPriority:typeof g.fetchPriority=="string"?g.fetchPriority:void 0,referrerPolicy:typeof g.referrerPolicy=="string"?g.referrerPolicy:void 0,imageSrcSet:typeof g.imageSrcSet=="string"?g.imageSrcSet:void 0,imageSizes:typeof g.imageSizes=="string"?g.imageSizes:void 0,media:typeof g.media=="string"?g.media:void 0})}},vi.preloadModule=function(h,g){if(typeof h=="string")if(g){var y=u(g.as,g.crossOrigin);s.d.m(h,{as:typeof g.as=="string"&&g.as!=="script"?g.as:void 0,crossOrigin:y,integrity:typeof g.integrity=="string"?g.integrity:void 0})}else s.d.m(h)},vi.requestFormReset=function(h){s.d.r(h)},vi.unstable_batchedUpdates=function(h,g){return h(g)},vi.useFormState=function(h,g,y){return c.H.useFormState(h,g,y)},vi.useFormStatus=function(){return c.H.useHostTransitionStatus()},vi.version="19.2.1",vi}var _w;function _4(){if(_w)return Sp.exports;_w=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(),Sp.exports=o6(),Sp.exports}var kw;function l6(){if(kw)return Yu;kw=1;var e=i6(),r=ug(),a=_4();function s(o){var d="https://react.dev/errors/"+o;if(1<arguments.length){d+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)d+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+o+"; visit "+d+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11)}function i(o){var d=o,p=o;if(o.alternate)for(;d.return;)d=d.return;else{o=d;do d=o,(d.flags&4098)!==0&&(p=d.return),o=d.return;while(o)}return d.tag===3?p:null}function c(o){if(o.tag===13){var d=o.memoizedState;if(d===null&&(o=o.alternate,o!==null&&(d=o.memoizedState)),d!==null)return d.dehydrated}return null}function u(o){if(o.tag===31){var d=o.memoizedState;if(d===null&&(o=o.alternate,o!==null&&(d=o.memoizedState)),d!==null)return d.dehydrated}return null}function h(o){if(i(o)!==o)throw Error(s(188))}function g(o){var d=o.alternate;if(!d){if(d=i(o),d===null)throw Error(s(188));return d!==o?null:o}for(var p=o,N=d;;){var I=p.return;if(I===null)break;var U=I.alternate;if(U===null){if(N=I.return,N!==null){p=N;continue}break}if(I.child===U.child){for(U=I.child;U;){if(U===p)return h(I),o;if(U===N)return h(I),d;U=U.sibling}throw Error(s(188))}if(p.return!==N.return)p=I,N=U;else{for(var xe=!1,Ie=I.child;Ie;){if(Ie===p){xe=!0,p=I,N=U;break}if(Ie===N){xe=!0,N=I,p=U;break}Ie=Ie.sibling}if(!xe){for(Ie=U.child;Ie;){if(Ie===p){xe=!0,p=U,N=I;break}if(Ie===N){xe=!0,N=U,p=I;break}Ie=Ie.sibling}if(!xe)throw Error(s(189))}}if(p.alternate!==N)throw Error(s(190))}if(p.tag!==3)throw Error(s(188));return p.stateNode.current===p?o:d}function y(o){var d=o.tag;if(d===5||d===26||d===27||d===6)return o;for(o=o.child;o!==null;){if(d=y(o),d!==null)return d;o=o.sibling}return null}var w=Object.assign,E=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),A=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),R=Symbol.for("react.consumer"),F=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),X=Symbol.for("react.suspense_list"),B=Symbol.for("react.memo"),Y=Symbol.for("react.lazy"),G=Symbol.for("react.activity"),ie=Symbol.for("react.memo_cache_sentinel"),fe=Symbol.iterator;function K(o){return o===null||typeof o!="object"?null:(o=fe&&o[fe]||o["@@iterator"],typeof o=="function"?o:null)}var ke=Symbol.for("react.client.reference");function ge(o){if(o==null)return null;if(typeof o=="function")return o.$$typeof===ke?null:o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case C:return"Fragment";case M:return"Profiler";case O:return"StrictMode";case W:return"Suspense";case X:return"SuspenseList";case G:return"Activity"}if(typeof o=="object")switch(o.$$typeof){case A:return"Portal";case F:return o.displayName||"Context";case R:return(o._context.displayName||"Context")+".Consumer";case z:var d=o.render;return o=o.displayName,o||(o=d.displayName||d.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case B:return d=o.displayName||null,d!==null?d:ge(o.type)||"Memo";case Y:d=o._payload,o=o._init;try{return ge(o(d))}catch(p){}}return null}var re=Array.isArray,we=r.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ve={pending:!1,data:null,method:null,action:null},ce=[],ye=-1;function te(o){return{current:o}}function q(o){0>ye||(o.current=ce[ye],ce[ye]=null,ye--)}function J(o,d){ye++,ce[ye]=o.current,o.current=d}var ae=te(null),oe=te(null),le=te(null),be=te(null);function Z(o,d){switch(J(le,d),J(oe,o),J(ae,null),d.nodeType){case 9:case 11:o=(o=d.documentElement)&&(o=o.namespaceURI)?Iv(o):0;break;default:if(o=d.tagName,d=d.namespaceURI)d=Iv(d),o=Mv(d,o);else switch(o){case"svg":o=1;break;case"math":o=2;break;default:o=0}}q(ae),J(ae,o)}function Le(){q(ae),q(oe),q(le)}function Pe(o){o.memoizedState!==null&&J(be,o);var d=ae.current,p=Mv(d,o.type);d!==p&&(J(oe,o),J(ae,p))}function Be(o){oe.current===o&&(q(ae),q(oe)),be.current===o&&(q(be),Wu._currentValue=ve)}var pe,rt;function ct(o){if(pe===void 0)try{throw Error()}catch(p){var d=p.stack.trim().match(/\n( *(at )?)/);pe=d&&d[1]||"",rt=-1<p.stack.indexOf(`
at`)?" (<anonymous>)":-1<p.stack.indexOf("@")?"@unknown:0:0":""}return`
`+pe+o+rt}var et=!1;function It(o,d){if(!o||et)return"";et=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var N={DetermineComponentFrameRoot:function(){try{if(d){var dr=function(){throw Error()};if(Object.defineProperty(dr.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(dr,[])}catch(er){var Vt=er}Reflect.construct(o,[],dr)}else{try{dr.call()}catch(er){Vt=er}o.call(dr.prototype)}}else{try{throw Error()}catch(er){Vt=er}(dr=o())&&typeof dr.catch=="function"&&dr.catch(function(){})}}catch(er){if(er&&Vt&&typeof er.stack=="string")return[er.stack,Vt.stack]}return[null,null]}};N.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var I=Object.getOwnPropertyDescriptor(N.DetermineComponentFrameRoot,"name");I&&I.configurable&&Object.defineProperty(N.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var U=N.DetermineComponentFrameRoot(),xe=U[0],Ie=U[1];if(xe&&Ie){var lt=xe.split(`
`),Ut=Ie.split(`
`);for(I=N=0;N<lt.length&&!lt[N].includes("DetermineComponentFrameRoot");)N++;for(;I<Ut.length&&!Ut[I].includes("DetermineComponentFrameRoot");)I++;if(N===lt.length||I===Ut.length)for(N=lt.length-1,I=Ut.length-1;1<=N&&0<=I&&lt[N]!==Ut[I];)I--;for(;1<=N&&0<=I;N--,I--)if(lt[N]!==Ut[I]){if(N!==1||I!==1)do if(N--,I--,0>I||lt[N]!==Ut[I]){var nr=`
`+lt[N].replace(" at new "," at ");return o.displayName&&nr.includes("<anonymous>")&&(nr=nr.replace("<anonymous>",o.displayName)),nr}while(1<=N&&0<=I);break}}}finally{et=!1,Error.prepareStackTrace=p}return(p=o?o.displayName||o.name:"")?ct(p):""}function ft(o,d){switch(o.tag){case 26:case 27:case 5:return ct(o.type);case 16:return ct("Lazy");case 13:return o.child!==d&&d!==null?ct("Suspense Fallback"):ct("Suspense");case 19:return ct("SuspenseList");case 0:case 15:return It(o.type,!1);case 11:return It(o.type.render,!1);case 1:return It(o.type,!0);case 31:return ct("Activity");default:return""}}function Lt(o){try{var d="",p=null;do d+=ft(o,p),p=o,o=o.return;while(o);return d}catch(N){return`
Error generating stack: `+N.message+`
`+N.stack}}var Je=Object.prototype.hasOwnProperty,Ve=e.unstable_scheduleCallback,Xe=e.unstable_cancelCallback,Rt=e.unstable_shouldYield,qe=e.unstable_requestPaint,Dt=e.unstable_now,ar=e.unstable_getCurrentPriorityLevel,yt=e.unstable_ImmediatePriority,St=e.unstable_UserBlockingPriority,Ot=e.unstable_NormalPriority,Yt=e.unstable_LowPriority,Ye=e.unstable_IdlePriority,wt=e.log,zt=e.unstable_setDisableYieldValue,qt=null,kt=null;function ze(o){if(typeof wt=="function"&&zt(o),kt&&typeof kt.setStrictMode=="function")try{kt.setStrictMode(qt,o)}catch(d){}}var nt=Math.clz32?Math.clz32:pr,_t=Math.log,lr=Math.LN2;function pr(o){return o>>>=0,o===0?32:31-(_t(o)/lr|0)|0}var Nr=256,rr=262144,_r=4194304;function Nt(o){var d=o&42;if(d!==0)return d;switch(o&-o){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 o&261888;case 262144:case 524288:case 1048576:case 2097152:return o&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return o&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return o}}function Cr(o,d,p){var N=o.pendingLanes;if(N===0)return 0;var I=0,U=o.suspendedLanes,xe=o.pingedLanes;o=o.warmLanes;var Ie=N&134217727;return Ie!==0?(N=Ie&~U,N!==0?I=Nt(N):(xe&=Ie,xe!==0?I=Nt(xe):p||(p=Ie&~o,p!==0&&(I=Nt(p))))):(Ie=N&~U,Ie!==0?I=Nt(Ie):xe!==0?I=Nt(xe):p||(p=N&~o,p!==0&&(I=Nt(p)))),I===0?0:d!==0&&d!==I&&(d&U)===0&&(U=I&-I,p=d&-d,U>=p||U===32&&(p&4194048)!==0)?d:I}function yr(o,d){return(o.pendingLanes&~(o.suspendedLanes&~o.pingedLanes)&d)===0}function jt(o,d){switch(o){case 1:case 2:case 4:case 8:case 64:return d+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 d+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 Tt(){var o=_r;return _r<<=1,(_r&62914560)===0&&(_r=4194304),o}function He(o){for(var d=[],p=0;31>p;p++)d.push(o);return d}function Fe(o,d){o.pendingLanes|=d,d!==268435456&&(o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0)}function Ze(o,d,p,N,I,U){var xe=o.pendingLanes;o.pendingLanes=p,o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0,o.expiredLanes&=p,o.entangledLanes&=p,o.errorRecoveryDisabledLanes&=p,o.shellSuspendCounter=0;var Ie=o.entanglements,lt=o.expirationTimes,Ut=o.hiddenUpdates;for(p=xe&~p;0<p;){var nr=31-nt(p),dr=1<<nr;Ie[nr]=0,lt[nr]=-1;var Vt=Ut[nr];if(Vt!==null)for(Ut[nr]=null,nr=0;nr<Vt.length;nr++){var er=Vt[nr];er!==null&&(er.lane&=-536870913)}p&=~dr}N!==0&&vt(o,N,0),U!==0&&I===0&&o.tag!==0&&(o.suspendedLanes|=U&~(xe&~d))}function vt(o,d,p){o.pendingLanes|=d,o.suspendedLanes&=~d;var N=31-nt(d);o.entangledLanes|=d,o.entanglements[N]=o.entanglements[N]|1073741824|p&261930}function ir(o,d){var p=o.entangledLanes|=d;for(o=o.entanglements;p;){var N=31-nt(p),I=1<<N;I&d|o[N]&d&&(o[N]|=d),p&=~I}}function fr(o,d){var p=d&-d;return p=(p&42)!==0?1:Kt(p),(p&(o.suspendedLanes|d))!==0?0:p}function Kt(o){switch(o){case 2:o=1;break;case 8:o=4;break;case 32:o=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:o=128;break;case 268435456:o=134217728;break;default:o=0}return o}function Re(o){return o&=-o,2<o?8<o?(o&134217727)!==0?32:268435456:8:2}function Q(){var o=ee.p;return o!==0?o:(o=window.event,o===void 0?32:nw(o.type))}function he(o,d){var p=ee.p;try{return ee.p=o,d()}finally{ee.p=p}}var Se=Math.random().toString(36).slice(2),ne="__reactFiber$"+Se,_e="__reactProps$"+Se,Ce="__reactContainer$"+Se,Qe="__reactEvents$"+Se,xt="__reactListeners$"+Se,dt="__reactHandles$"+Se,at="__reactResources$"+Se,$e="__reactMarker$"+Se;function tt(o){delete o[ne],delete o[_e],delete o[Qe],delete o[xt],delete o[dt]}function gt(o){var d=o[ne];if(d)return d;for(var p=o.parentNode;p;){if(d=p[Ce]||p[ne]){if(p=d.alternate,d.child!==null||p!==null&&p.child!==null)for(o=Hv(o);o!==null;){if(p=o[ne])return p;o=Hv(o)}return d}o=p,p=o.parentNode}return null}function Wt(o){if(o=o[ne]||o[Ce]){var d=o.tag;if(d===5||d===6||d===13||d===31||d===26||d===27||d===3)return o}return null}function Ft(o){var d=o.tag;if(d===5||d===26||d===27||d===6)return o.stateNode;throw Error(s(33))}function Zt(o){var d=o[at];return d||(d=o[at]={hoistableStyles:new Map,hoistableScripts:new Map}),d}function br(o){o[$e]=!0}var Ht=new Set,fa={};function qr(o,d){vr(o,d),vr(o+"Capture",d)}function vr(o,d){for(fa[o]=d,o=0;o<d.length;o++)Ht.add(d[o])}var da=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]*$"),zr={},Kr={};function Yr(o){return Je.call(Kr,o)?!0:Je.call(zr,o)?!1:da.test(o)?Kr[o]=!0:(zr[o]=!0,!1)}function Gr(o,d,p){if(Yr(d))if(p===null)o.removeAttribute(d);else{switch(typeof p){case"undefined":case"function":case"symbol":o.removeAttribute(d);return;case"boolean":var N=d.toLowerCase().slice(0,5);if(N!=="data-"&&N!=="aria-"){o.removeAttribute(d);return}}o.setAttribute(d,""+p)}}function Sa(o,d,p){if(p===null)o.removeAttribute(d);else{switch(typeof p){case"undefined":case"function":case"symbol":case"boolean":o.removeAttribute(d);return}o.setAttribute(d,""+p)}}function Ps(o,d,p,N){if(N===null)o.removeAttribute(p);else{switch(typeof N){case"undefined":case"function":case"symbol":case"boolean":o.removeAttribute(p);return}o.setAttributeNS(d,p,""+N)}}function ha(o){switch(typeof o){case"bigint":case"boolean":case"number":case"string":case"undefined":return o;case"object":return o;default:return""}}function _s(o){var d=o.type;return(o=o.nodeName)&&o.toLowerCase()==="input"&&(d==="checkbox"||d==="radio")}function Wi(o,d,p){var N=Object.getOwnPropertyDescriptor(o.constructor.prototype,d);if(!o.hasOwnProperty(d)&&typeof N!="undefined"&&typeof N.get=="function"&&typeof N.set=="function"){var I=N.get,U=N.set;return Object.defineProperty(o,d,{configurable:!0,get:function(){return I.call(this)},set:function(xe){p=""+xe,U.call(this,xe)}}),Object.defineProperty(o,d,{enumerable:N.enumerable}),{getValue:function(){return p},setValue:function(xe){p=""+xe},stopTracking:function(){o._valueTracker=null,delete o[d]}}}}function De(o){if(!o._valueTracker){var d=_s(o)?"checked":"value";o._valueTracker=Wi(o,d,""+o[d])}}function wr(o){if(!o)return!1;var d=o._valueTracker;if(!d)return!0;var p=d.getValue(),N="";return o&&(N=_s(o)?o.checked?"true":"false":o.value),o=N,o!==p?(d.setValue(o),!0):!1}function Cn(o){if(o=o||(typeof document!="undefined"?document:void 0),typeof o=="undefined")return null;try{return o.activeElement||o.body}catch(d){return o.body}}var un=/[\n"\\]/g;function Wr(o){return o.replace(un,function(d){return"\\"+d.charCodeAt(0).toString(16)+" "})}function mt(o,d,p,N,I,U,xe,Ie){o.name="",xe!=null&&typeof xe!="function"&&typeof xe!="symbol"&&typeof xe!="boolean"?o.type=xe:o.removeAttribute("type"),d!=null?xe==="number"?(d===0&&o.value===""||o.value!=d)&&(o.value=""+ha(d)):o.value!==""+ha(d)&&(o.value=""+ha(d)):xe!=="submit"&&xe!=="reset"||o.removeAttribute("value"),d!=null?Me(o,xe,ha(d)):p!=null?Me(o,xe,ha(p)):N!=null&&o.removeAttribute("value"),I==null&&U!=null&&(o.defaultChecked=!!U),I!=null&&(o.checked=I&&typeof I!="function"&&typeof I!="symbol"),Ie!=null&&typeof Ie!="function"&&typeof Ie!="symbol"&&typeof Ie!="boolean"?o.name=""+ha(Ie):o.removeAttribute("name")}function We(o,d,p,N,I,U,xe,Ie){if(U!=null&&typeof U!="function"&&typeof U!="symbol"&&typeof U!="boolean"&&(o.type=U),d!=null||p!=null){if(!(U!=="submit"&&U!=="reset"||d!=null)){De(o);return}p=p!=null?""+ha(p):"",d=d!=null?""+ha(d):p,Ie||d===o.value||(o.value=d),o.defaultValue=d}N=N!=null?N:I,N=typeof N!="function"&&typeof N!="symbol"&&!!N,o.checked=Ie?o.checked:!!N,o.defaultChecked=!!N,xe!=null&&typeof xe!="function"&&typeof xe!="symbol"&&typeof xe!="boolean"&&(o.name=xe),De(o)}function Me(o,d,p){d==="number"&&Cn(o.ownerDocument)===o||o.defaultValue===""+p||(o.defaultValue=""+p)}function Qt(o,d,p,N){if(o=o.options,d){d={};for(var I=0;I<p.length;I++)d["$"+p[I]]=!0;for(p=0;p<o.length;p++)I=d.hasOwnProperty("$"+o[p].value),o[p].selected!==I&&(o[p].selected=I),I&&N&&(o[p].defaultSelected=!0)}else{for(p=""+ha(p),d=null,I=0;I<o.length;I++){if(o[I].value===p){o[I].selected=!0,N&&(o[I].defaultSelected=!0);return}d!==null||o[I].disabled||(d=o[I])}d!==null&&(d.selected=!0)}}function Pr(o,d,p){if(d!=null&&(d=""+ha(d),d!==o.value&&(o.value=d),p==null)){o.defaultValue!==d&&(o.defaultValue=d);return}o.defaultValue=p!=null?""+ha(p):""}function Oa(o,d,p,N){if(d==null){if(N!=null){if(p!=null)throw Error(s(92));if(re(N)){if(1<N.length)throw Error(s(93));N=N[0]}p=N}p==null&&(p=""),d=p}p=ha(d),o.defaultValue=p,N=o.textContent,N===p&&N!==""&&N!==null&&(o.value=N),De(o)}function Va(o,d){if(d){var p=o.firstChild;if(p&&p===o.lastChild&&p.nodeType===3){p.nodeValue=d;return}}o.textContent=d}var fn=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 Ea(o,d,p){var N=d.indexOf("--")===0;p==null||typeof p=="boolean"||p===""?N?o.setProperty(d,""):d==="float"?o.cssFloat="":o[d]="":N?o.setProperty(d,p):typeof p!="number"||p===0||fn.has(d)?d==="float"?o.cssFloat=p:o[d]=(""+p).trim():o[d]=p+"px"}function xr(o,d,p){if(d!=null&&typeof d!="object")throw Error(s(62));if(o=o.style,p!=null){for(var N in p)!p.hasOwnProperty(N)||d!=null&&d.hasOwnProperty(N)||(N.indexOf("--")===0?o.setProperty(N,""):N==="float"?o.cssFloat="":o[N]="");for(var I in d)N=d[I],d.hasOwnProperty(I)&&p[I]!==N&&Ea(o,I,N)}else for(var U in d)d.hasOwnProperty(U)&&Ea(o,U,d[U])}function ua(o){if(o.indexOf("-")===-1)return!1;switch(o){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 Jn=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"]]),mi=/^[\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 hn(o){return mi.test(""+o)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":o}function Ts(){}var Ai=null;function Hi(o){return o=o.target||o.srcElement||window,o.correspondingUseElement&&(o=o.correspondingUseElement),o.nodeType===3?o.parentNode:o}var it=null,bt=null;function Qr(o){var d=Wt(o);if(d&&(o=d.stateNode)){var p=o[_e]||null;e:switch(o=d.stateNode,d.type){case"input":if(mt(o,p.value,p.defaultValue,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name),d=p.name,p.type==="radio"&&d!=null){for(p=o;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll('input[name="'+Wr(""+d)+'"][type="radio"]'),d=0;d<p.length;d++){var N=p[d];if(N!==o&&N.form===o.form){var I=N[_e]||null;if(!I)throw Error(s(90));mt(N,I.value,I.defaultValue,I.defaultValue,I.checked,I.defaultChecked,I.type,I.name)}}for(d=0;d<p.length;d++)N=p[d],N.form===o.form&&wr(N)}break e;case"textarea":Pr(o,p.value,p.defaultValue);break e;case"select":d=p.value,d!=null&&Qt(o,!!p.multiple,d,!1)}}}var gr=!1;function En(o,d,p){if(gr)return o(d,p);gr=!0;try{var N=o(d);return N}finally{if(gr=!1,(it!==null||bt!==null)&&(Fh(),it&&(d=it,o=bt,bt=it=null,Qr(d),o)))for(d=0;d<o.length;d++)Qr(o[d])}}function Lr(o,d){var p=o.stateNode;if(p===null)return null;var N=p[_e]||null;if(N===null)return null;p=N[d];e:switch(d){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(N=!N.disabled)||(o=o.type,N=!(o==="button"||o==="input"||o==="select"||o==="textarea")),o=!N;break e;default:o=!1}if(o)return null;if(p&&typeof p!="function")throw Error(s(231,d,typeof p));return p}var oa=!(typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"),gi=!1;if(oa)try{var As={};Object.defineProperty(As,"passive",{get:function(){gi=!0}}),window.addEventListener("test",As,As),window.removeEventListener("test",As,As)}catch(o){gi=!1}var Os=null,$s=null,Qa=null;function en(){if(Qa)return Qa;var o,d=$s,p=d.length,N,I="value"in Os?Os.value:Os.textContent,U=I.length;for(o=0;o<p&&d[o]===I[o];o++);var xe=p-o;for(N=1;N<=xe&&d[p-N]===I[U-N];N++);return Qa=I.slice(o,1<N?1-N:void 0)}function Qn(o){var d=o.keyCode;return"charCode"in o?(o=o.charCode,o===0&&d===13&&(o=13)):o=d,o===10&&(o=13),32<=o||o===13?o:0}function Bn(){return!0}function So(){return!1}function cs(o){function d(p,N,I,U,xe){this._reactName=p,this._targetInst=I,this.type=N,this.nativeEvent=U,this.target=xe,this.currentTarget=null;for(var Ie in o)o.hasOwnProperty(Ie)&&(p=o[Ie],this[Ie]=p?p(U):U[Ie]);return this.isDefaultPrevented=(U.defaultPrevented!=null?U.defaultPrevented:U.returnValue===!1)?Bn:So,this.isPropagationStopped=So,this}return w(d.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=Bn)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=Bn)},persist:function(){},isPersistent:Bn}),d}var Ds={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(o){return o.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},es=cs(Ds),ei=w({},Ds,{view:0,detail:0}),ga=cs(ei),ti,Tn,Oi,Zo=w({},ei,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ko,button:0,buttons:0,relatedTarget:function(o){return o.relatedTarget===void 0?o.fromElement===o.srcElement?o.toElement:o.fromElement:o.relatedTarget},movementX:function(o){return"movementX"in o?o.movementX:(o!==Oi&&(Oi&&o.type==="mousemove"?(ti=o.screenX-Oi.screenX,Tn=o.screenY-Oi.screenY):Tn=ti=0,Oi=o),ti)},movementY:function(o){return"movementY"in o?o.movementY:Tn}}),Pa=cs(Zo),ri=w({},Zo,{dataTransfer:0}),xl=cs(ri),mn=w({},ei,{relatedTarget:0}),Co=cs(mn),Gt=w({},Ds,{animationName:0,elapsedTime:0,pseudoElement:0}),na=cs(Gt),Ls=w({},Ds,{clipboardData:function(o){return"clipboardData"in o?o.clipboardData:window.clipboardData}}),An=cs(Ls),pc=w({},Ds,{data:0}),Bl=cs(pc),$i={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},yc={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"},pl={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ts(o){var d=this.nativeEvent;return d.getModifierState?d.getModifierState(o):(o=pl[o])?!!d[o]:!1}function Ko(){return ts}var rs=w({},ei,{key:function(o){if(o.key){var d=$i[o.key]||o.key;if(d!=="Unidentified")return d}return o.type==="keypress"?(o=Qn(o),o===13?"Enter":String.fromCharCode(o)):o.type==="keydown"||o.type==="keyup"?yc[o.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ko,charCode:function(o){return o.type==="keypress"?Qn(o):0},keyCode:function(o){return o.type==="keydown"||o.type==="keyup"?o.keyCode:0},which:function(o){return o.type==="keypress"?Qn(o):o.type==="keydown"||o.type==="keyup"?o.keyCode:0}}),Jo=cs(rs),io=w({},Zo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),za=cs(io),$r=w({},ei,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ko}),bc=cs($r),Wa=w({},Ds,{propertyName:0,elapsedTime:0,pseudoElement:0}),Un=cs(Wa),zn=w({},Zo,{deltaX:function(o){return"deltaX"in o?o.deltaX:"wheelDeltaX"in o?-o.wheelDeltaX:0},deltaY:function(o){return"deltaY"in o?o.deltaY:"wheelDeltaY"in o?-o.wheelDeltaY:"wheelDelta"in o?-o.wheelDelta:0},deltaZ:0,deltaMode:0}),Vi=cs(zn),ai=w({},Ds,{newState:0,oldState:0}),oo=cs(ai),On=[9,13,27,32],Eo=oa&&"CompositionEvent"in window,lo=null;oa&&"documentMode"in document&&(lo=document.documentMode);var vc=oa&&"TextEvent"in window&&!lo,yl=oa&&(!Eo||lo&&8<lo&&11>=lo),xi=" ",ds=!1;function Ul(o,d){switch(o){case"keyup":return On.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function co(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var To=!1;function Rs(o,d){switch(o){case"compositionend":return co(d);case"keypress":return d.which!==32?null:(ds=!0,xi);case"textInput":return o=d.data,o===xi&&ds?null:o;default:return null}}function Di(o,d){if(To)return o==="compositionend"||!Eo&&Ul(o,d)?(o=en(),Qa=$s=Os=null,To=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(d.ctrlKey||d.altKey||d.metaKey)||d.ctrlKey&&d.altKey){if(d.char&&1<d.char.length)return d.char;if(d.which)return String.fromCharCode(d.which)}return null;case"compositionend":return yl&&d.locale!=="ko"?null:d.data;default:return null}}var Wn={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 si(o){var d=o&&o.nodeName&&o.nodeName.toLowerCase();return d==="input"?!!Wn[o.type]:d==="textarea"}function ni(o,d,p,N){it?bt?bt.push(N):bt=[N]:it=N,d=zh(d,"onChange"),0<d.length&&(p=new es("onChange","change",null,p,N),o.push({event:p,listeners:d}))}var pi=null,yi=null;function Qo(o){Tv(o,0)}function Ao(o){var d=Ft(o);if(wr(d))return o}function gn(o,d){if(o==="change")return d}var zl=!1;if(oa){var Hn;if(oa){var ii="oninput"in document;if(!ii){var ja=document.createElement("div");ja.setAttribute("oninput","return;"),ii=typeof ja.oninput=="function"}Hn=ii}else Hn=!1;zl=Hn&&(!document.documentMode||9<document.documentMode)}function tn(){pi&&(pi.detachEvent("onpropertychange",Ne),yi=pi=null)}function Ne(o){if(o.propertyName==="value"&&Ao(yi)){var d=[];ni(d,yi,o,Hi(o)),En(Qo,d)}}function l(o,d,p){o==="focusin"?(tn(),pi=d,yi=p,pi.attachEvent("onpropertychange",Ne)):o==="focusout"&&tn()}function f(o){if(o==="selectionchange"||o==="keyup"||o==="keydown")return Ao(yi)}function x(o,d){if(o==="click")return Ao(d)}function b(o,d){if(o==="input"||o==="change")return Ao(d)}function v(o,d){return o===d&&(o!==0||1/o===1/d)||o!==o&&d!==d}var j=typeof Object.is=="function"?Object.is:v;function T(o,d){if(j(o,d))return!0;if(typeof o!="object"||o===null||typeof d!="object"||d===null)return!1;var p=Object.keys(o),N=Object.keys(d);if(p.length!==N.length)return!1;for(N=0;N<p.length;N++){var I=p[N];if(!Je.call(d,I)||!j(o[I],d[I]))return!1}return!0}function P(o){for(;o&&o.firstChild;)o=o.firstChild;return o}function H(o,d){var p=P(o);o=0;for(var N;p;){if(p.nodeType===3){if(N=o+p.textContent.length,o<=d&&N>=d)return{node:p,offset:d-o};o=N}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=P(p)}}function de(o,d){return o&&d?o===d?!0:o&&o.nodeType===3?!1:d&&d.nodeType===3?de(o,d.parentNode):"contains"in o?o.contains(d):o.compareDocumentPosition?!!(o.compareDocumentPosition(d)&16):!1:!1}function je(o){o=o!=null&&o.ownerDocument!=null&&o.ownerDocument.defaultView!=null?o.ownerDocument.defaultView:window;for(var d=Cn(o.document);d instanceof o.HTMLIFrameElement;){try{var p=typeof d.contentWindow.location.href=="string"}catch(N){p=!1}if(p)o=d.contentWindow;else break;d=Cn(o.document)}return d}function Ae(o){var d=o&&o.nodeName&&o.nodeName.toLowerCase();return d&&(d==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||d==="textarea"||o.contentEditable==="true")}var Ge=oa&&"documentMode"in document&&11>=document.documentMode,ot=null,ut=null,At=null,se=!1;function Ee(o,d,p){var N=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;se||ot==null||ot!==Cn(N)||(N=ot,"selectionStart"in N&&Ae(N)?N={start:N.selectionStart,end:N.selectionEnd}:(N=(N.ownerDocument&&N.ownerDocument.defaultView||window).getSelection(),N={anchorNode:N.anchorNode,anchorOffset:N.anchorOffset,focusNode:N.focusNode,focusOffset:N.focusOffset}),At&&T(At,N)||(At=N,N=zh(ut,"onSelect"),0<N.length&&(d=new es("onSelect","select",null,d,p),o.push({event:d,listeners:N}),d.target=ot)))}function Ue(o,d){var p={};return p[o.toLowerCase()]=d.toLowerCase(),p["Webkit"+o]="webkit"+d,p["Moz"+o]="moz"+d,p}var ht={animationend:Ue("Animation","AnimationEnd"),animationiteration:Ue("Animation","AnimationIteration"),animationstart:Ue("Animation","AnimationStart"),transitionrun:Ue("Transition","TransitionRun"),transitionstart:Ue("Transition","TransitionStart"),transitioncancel:Ue("Transition","TransitionCancel"),transitionend:Ue("Transition","TransitionEnd")},ur={},tr={};oa&&(tr=document.createElement("div").style,"AnimationEvent"in window||(delete ht.animationend.animation,delete ht.animationiteration.animation,delete ht.animationstart.animation),"TransitionEvent"in window||delete ht.transitionend.transition);function Ar(o){if(ur[o])return ur[o];if(!ht[o])return o;var d=ht[o],p;for(p in d)if(d.hasOwnProperty(p)&&p in tr)return ur[o]=d[p];return o}var ra=Ar("animationend"),La=Ar("animationiteration"),Dr=Ar("animationstart"),Ta=Ar("transitionrun"),gs=Ar("transitionstart"),vs=Ar("transitioncancel"),as=Ar("transitionend"),xn=new Map,xa="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(" ");xa.push("scrollEnd");function Bs(o,d){xn.set(o,d),qr(d,[o])}var pn=typeof reportError=="function"?reportError:function(o){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var d=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof o=="object"&&o!==null&&typeof o.message=="string"?String(o.message):String(o),error:o});if(!window.dispatchEvent(d))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",o);return}console.error(o)},oi=[],ws=0,$n=0;function bl(){for(var o=ws,d=$n=ws=0;d<o;){var p=oi[d];oi[d++]=null;var N=oi[d];oi[d++]=null;var I=oi[d];oi[d++]=null;var U=oi[d];if(oi[d++]=null,N!==null&&I!==null){var xe=N.pending;xe===null?I.next=I:(I.next=xe.next,xe.next=I),N.pending=I}U!==0&&wc(p,I,U)}}function vl(o,d,p,N){oi[ws++]=o,oi[ws++]=d,oi[ws++]=p,oi[ws++]=N,$n|=N,o.lanes|=N,o=o.alternate,o!==null&&(o.lanes|=N)}function du(o,d,p,N){return vl(o,d,p,N),ad(o)}function Oo(o,d){return vl(o,null,null,d),ad(o)}function wc(o,d,p){o.lanes|=p;var N=o.alternate;N!==null&&(N.lanes|=p);for(var I=!1,U=o.return;U!==null;)U.childLanes|=p,N=U.alternate,N!==null&&(N.childLanes|=p),U.tag===22&&(o=U.stateNode,o===null||o._visibility&1||(I=!0)),o=U,U=U.return;return o.tag===3?(U=o.stateNode,I&&d!==null&&(I=31-nt(p),o=U.hiddenUpdates,N=o[I],N===null?o[I]=[d]:N.push(d),d.lane=p|536870912),U):null}function ad(o){if(50<Iu)throw Iu=0,Wx=null,Error(s(185));for(var d=o.return;d!==null;)o=d,d=o.return;return o.tag===3?o.stateNode:null}var Wl={};function zg(o,d,p,N){this.tag=o,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=d,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=N,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function bi(o,d,p,N){return new zg(o,d,p,N)}function Qd(o){return o=o.prototype,!(!o||!o.isReactComponent)}function Do(o,d){var p=o.alternate;return p===null?(p=bi(o.tag,d,o.key,o.mode),p.elementType=o.elementType,p.type=o.type,p.stateNode=o.stateNode,p.alternate=o,o.alternate=p):(p.pendingProps=d,p.type=o.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=o.flags&65011712,p.childLanes=o.childLanes,p.lanes=o.lanes,p.child=o.child,p.memoizedProps=o.memoizedProps,p.memoizedState=o.memoizedState,p.updateQueue=o.updateQueue,d=o.dependencies,p.dependencies=d===null?null:{lanes:d.lanes,firstContext:d.firstContext},p.sibling=o.sibling,p.index=o.index,p.ref=o.ref,p.refCleanup=o.refCleanup,p}function uu(o,d){o.flags&=65011714;var p=o.alternate;return p===null?(o.childLanes=0,o.lanes=d,o.child=null,o.subtreeFlags=0,o.memoizedProps=null,o.memoizedState=null,o.updateQueue=null,o.dependencies=null,o.stateNode=null):(o.childLanes=p.childLanes,o.lanes=p.lanes,o.child=p.child,o.subtreeFlags=0,o.deletions=null,o.memoizedProps=p.memoizedProps,o.memoizedState=p.memoizedState,o.updateQueue=p.updateQueue,o.type=p.type,d=p.dependencies,o.dependencies=d===null?null:{lanes:d.lanes,firstContext:d.firstContext}),o}function sd(o,d,p,N,I,U){var xe=0;if(N=o,typeof o=="function")Qd(o)&&(xe=1);else if(typeof o=="string")xe=BC(o,p,ae.current)?26:o==="html"||o==="head"||o==="body"?27:5;else e:switch(o){case G:return o=bi(31,p,d,I),o.elementType=G,o.lanes=U,o;case C:return Hl(p.children,I,U,d);case O:xe=8,I|=24;break;case M:return o=bi(12,p,d,I|2),o.elementType=M,o.lanes=U,o;case W:return o=bi(13,p,d,I),o.elementType=W,o.lanes=U,o;case X:return o=bi(19,p,d,I),o.elementType=X,o.lanes=U,o;default:if(typeof o=="object"&&o!==null)switch(o.$$typeof){case F:xe=10;break e;case R:xe=9;break e;case z:xe=11;break e;case B:xe=14;break e;case Y:xe=16,N=null;break e}xe=29,p=Error(s(130,o===null?"null":typeof o,"")),N=null}return d=bi(xe,p,d,I),d.elementType=o,d.type=N,d.lanes=U,d}function Hl(o,d,p,N){return o=bi(7,o,N,d),o.lanes=p,o}function e0(o,d,p){return o=bi(6,o,null,d),o.lanes=p,o}function fu(o){var d=bi(18,null,null,0);return d.stateNode=o,d}function hu(o,d,p){return d=bi(4,o.children!==null?o.children:[],o.key,d),d.lanes=p,d.stateNode={containerInfo:o.containerInfo,pendingChildren:null,implementation:o.implementation},d}var m=new WeakMap;function k(o,d){if(typeof o=="object"&&o!==null){var p=m.get(o);return p!==void 0?p:(d={value:o,source:d,stack:Lt(d)},m.set(o,d),d)}return{value:o,source:d,stack:Lt(d)}}var D=[],V=0,ue=null,Oe=0,st=[],Et=0,$t=null,cr=1,Er="";function Vr(o,d){D[V++]=Oe,D[V++]=ue,ue=o,Oe=d}function va(o,d,p){st[Et++]=cr,st[Et++]=Er,st[Et++]=$t,$t=o;var N=cr;o=Er;var I=32-nt(N)-1;N&=~(1<<I),p+=1;var U=32-nt(d)+I;if(30<U){var xe=I-I%5;U=(N&(1<<xe)-1).toString(32),N>>=xe,I-=xe,cr=1<<32-nt(d)+I|p<<I|N,Er=U+o}else cr=1<<U|p<<I|N,Er=o}function Dn(o){o.return!==null&&(Vr(o,1),va(o,1,0))}function Vs(o){for(;o===ue;)ue=D[--V],D[V]=null,Oe=D[--V],D[V]=null;for(;o===$t;)$t=st[--Et],st[Et]=null,Er=st[--Et],st[Et]=null,cr=st[--Et],st[Et]=null}function Ri(o,d){st[Et++]=cr,st[Et++]=Er,st[Et++]=$t,cr=d.id,Er=d.overflow,$t=o}var Ga=null,Ya=null,Da=!1,wl=null,Gi=!1,t0=Error(s(519));function _l(o){var d=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw nd(k(d,o)),t0}function mu(o){var d=o.stateNode,p=o.type,N=o.memoizedProps;switch(d[ne]=o,d[_e]=N,p){case"dialog":Fa("cancel",d),Fa("close",d);break;case"iframe":case"object":case"embed":Fa("load",d);break;case"video":case"audio":for(p=0;p<Pu.length;p++)Fa(Pu[p],d);break;case"source":Fa("error",d);break;case"img":case"image":case"link":Fa("error",d),Fa("load",d);break;case"details":Fa("toggle",d);break;case"input":Fa("invalid",d),We(d,N.value,N.defaultValue,N.checked,N.defaultChecked,N.type,N.name,!0);break;case"select":Fa("invalid",d);break;case"textarea":Fa("invalid",d),Oa(d,N.value,N.defaultValue,N.children)}p=N.children,typeof p!="string"&&typeof p!="number"&&typeof p!="bigint"||d.textContent===""+p||N.suppressHydrationWarning===!0||Rv(d.textContent,p)?(N.popover!=null&&(Fa("beforetoggle",d),Fa("toggle",d)),N.onScroll!=null&&Fa("scroll",d),N.onScrollEnd!=null&&Fa("scrollend",d),N.onClick!=null&&(d.onclick=Ts),d=!0):d=!1,d||_l(o,!0)}function Us(o){for(Ga=o.return;Ga;)switch(Ga.tag){case 5:case 31:case 13:Gi=!1;return;case 27:case 3:Gi=!0;return;default:Ga=Ga.return}}function el(o){if(o!==Ga)return!1;if(!Da)return Us(o),Da=!0,!1;var d=o.tag,p;if((p=d!==3&&d!==27)&&((p=d===5)&&(p=o.type,p=!(p!=="form"&&p!=="button")||ap(o.type,o.memoizedProps)),p=!p),p&&Ya&&_l(o),Us(o),d===13){if(o=o.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(s(317));Ya=Wv(o)}else if(d===31){if(o=o.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(s(317));Ya=Wv(o)}else d===27?(d=Ya,Ic(o.type)?(o=lp,lp=null,Ya=o):Ya=d):Ya=Ga?Fo(o.stateNode.nextSibling):null;return!0}function $l(){Ya=Ga=null,Da=!1}function gu(){var o=wl;return o!==null&&(Zi===null?Zi=o:Zi.push.apply(Zi,o),wl=null),o}function nd(o){wl===null?wl=[o]:wl.push(o)}var id=te(null),kl=null,tl=null;function _c(o,d,p){J(id,d._currentValue),d._currentValue=p}function Vl(o){o._currentValue=id.current,q(id)}function Wg(o,d,p){for(;o!==null;){var N=o.alternate;if((o.childLanes&d)!==d?(o.childLanes|=d,N!==null&&(N.childLanes|=d)):N!==null&&(N.childLanes&d)!==d&&(N.childLanes|=d),o===p)break;o=o.return}}function Hg(o,d,p,N){var I=o.child;for(I!==null&&(I.return=o);I!==null;){var U=I.dependencies;if(U!==null){var xe=I.child;U=U.firstContext;e:for(;U!==null;){var Ie=U;U=I;for(var lt=0;lt<d.length;lt++)if(Ie.context===d[lt]){U.lanes|=p,Ie=U.alternate,Ie!==null&&(Ie.lanes|=p),Wg(U.return,p,o),N||(xe=null);break e}U=Ie.next}}else if(I.tag===18){if(xe=I.return,xe===null)throw Error(s(341));xe.lanes|=p,U=xe.alternate,U!==null&&(U.lanes|=p),Wg(xe,p,o),xe=null}else xe=I.child;if(xe!==null)xe.return=I;else for(xe=I;xe!==null;){if(xe===o){xe=null;break}if(I=xe.sibling,I!==null){I.return=xe.return,xe=I;break}xe=xe.return}I=xe}}function r0(o,d,p,N){o=null;for(var I=d,U=!1;I!==null;){if(!U){if((I.flags&524288)!==0)U=!0;else if((I.flags&262144)!==0)break}if(I.tag===10){var xe=I.alternate;if(xe===null)throw Error(s(387));if(xe=xe.memoizedProps,xe!==null){var Ie=I.type;j(I.pendingProps.value,xe.value)||(o!==null?o.push(Ie):o=[Ie])}}else if(I===be.current){if(xe=I.alternate,xe===null)throw Error(s(387));xe.memoizedState.memoizedState!==I.memoizedState.memoizedState&&(o!==null?o.push(Wu):o=[Wu])}I=I.return}o!==null&&Hg(d,o,p,N),d.flags|=262144}function ih(o){for(o=o.firstContext;o!==null;){if(!j(o.context._currentValue,o.memoizedValue))return!0;o=o.next}return!1}function od(o){kl=o,tl=null,o=o.dependencies,o!==null&&(o.firstContext=null)}function li(o){return yb(kl,o)}function oh(o,d){return kl===null&&od(o),yb(o,d)}function yb(o,d){var p=d._currentValue;if(d={context:d,memoizedValue:p,next:null},tl===null){if(o===null)throw Error(s(308));tl=d,o.dependencies={lanes:0,firstContext:d},o.flags|=524288}else tl=tl.next=d;return p}var IS=typeof AbortController!="undefined"?AbortController:function(){var o=[],d=this.signal={aborted:!1,addEventListener:function(p,N){o.push(N)}};this.abort=function(){d.aborted=!0,o.forEach(function(p){return p()})}},MS=e.unstable_scheduleCallback,PS=e.unstable_NormalPriority,yn={$$typeof:F,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function $g(){return{controller:new IS,data:new Map,refCount:0}}function xu(o){o.refCount--,o.refCount===0&&MS(PS,function(){o.controller.abort()})}var pu=null,Vg=0,a0=0,s0=null;function LS(o,d){if(pu===null){var p=pu=[];Vg=0,a0=qx(),s0={status:"pending",value:void 0,then:function(N){p.push(N)}}}return Vg++,d.then(bb,bb),d}function bb(){if(--Vg===0&&pu!==null){s0!==null&&(s0.status="fulfilled");var o=pu;pu=null,a0=0,s0=null;for(var d=0;d<o.length;d++)(0,o[d])()}}function BS(o,d){var p=[],N={status:"pending",value:null,reason:null,then:function(I){p.push(I)}};return o.then(function(){N.status="fulfilled",N.value=d;for(var I=0;I<p.length;I++)(0,p[I])(d)},function(I){for(N.status="rejected",N.reason=I,I=0;I<p.length;I++)(0,p[I])(void 0)}),N}var vb=we.S;we.S=function(o,d){av=Dt(),typeof d=="object"&&d!==null&&typeof d.then=="function"&&LS(o,d),vb!==null&&vb(o,d)};var ld=te(null);function Gg(){var o=ld.current;return o!==null?o:xs.pooledCache}function lh(o,d){d===null?J(ld,ld.current):J(ld,d.pool)}function wb(){var o=Gg();return o===null?null:{parent:yn._currentValue,pool:o}}var n0=Error(s(460)),Yg=Error(s(474)),ch=Error(s(542)),dh={then:function(){}};function _b(o){return o=o.status,o==="fulfilled"||o==="rejected"}function kb(o,d,p){switch(p=o[p],p===void 0?o.push(d):p!==d&&(d.then(Ts,Ts),d=p),d.status){case"fulfilled":return d.value;case"rejected":throw o=d.reason,jb(o),o;default:if(typeof d.status=="string")d.then(Ts,Ts);else{if(o=xs,o!==null&&100<o.shellSuspendCounter)throw Error(s(482));o=d,o.status="pending",o.then(function(N){if(d.status==="pending"){var I=d;I.status="fulfilled",I.value=N}},function(N){if(d.status==="pending"){var I=d;I.status="rejected",I.reason=N}})}switch(d.status){case"fulfilled":return d.value;case"rejected":throw o=d.reason,jb(o),o}throw dd=d,n0}}function cd(o){try{var d=o._init;return d(o._payload)}catch(p){throw p!==null&&typeof p=="object"&&typeof p.then=="function"?(dd=p,n0):p}}var dd=null;function Nb(){if(dd===null)throw Error(s(459));var o=dd;return dd=null,o}function jb(o){if(o===n0||o===ch)throw Error(s(483))}var i0=null,yu=0;function uh(o){var d=yu;return yu+=1,i0===null&&(i0=[]),kb(i0,o,d)}function bu(o,d){d=d.props.ref,o.ref=d!==void 0?d:null}function fh(o,d){throw d.$$typeof===E?Error(s(525)):(o=Object.prototype.toString.call(d),Error(s(31,o==="[object Object]"?"object with keys {"+Object.keys(d).join(", ")+"}":o)))}function Sb(o){function d(Ct,pt){if(o){var Bt=Ct.deletions;Bt===null?(Ct.deletions=[pt],Ct.flags|=16):Bt.push(pt)}}function p(Ct,pt){if(!o)return null;for(;pt!==null;)d(Ct,pt),pt=pt.sibling;return null}function N(Ct){for(var pt=new Map;Ct!==null;)Ct.key!==null?pt.set(Ct.key,Ct):pt.set(Ct.index,Ct),Ct=Ct.sibling;return pt}function I(Ct,pt){return Ct=Do(Ct,pt),Ct.index=0,Ct.sibling=null,Ct}function U(Ct,pt,Bt){return Ct.index=Bt,o?(Bt=Ct.alternate,Bt!==null?(Bt=Bt.index,Bt<pt?(Ct.flags|=67108866,pt):Bt):(Ct.flags|=67108866,pt)):(Ct.flags|=1048576,pt)}function xe(Ct){return o&&Ct.alternate===null&&(Ct.flags|=67108866),Ct}function Ie(Ct,pt,Bt,or){return pt===null||pt.tag!==6?(pt=e0(Bt,Ct.mode,or),pt.return=Ct,pt):(pt=I(pt,Bt),pt.return=Ct,pt)}function lt(Ct,pt,Bt,or){var Xr=Bt.type;return Xr===C?nr(Ct,pt,Bt.props.children,or,Bt.key):pt!==null&&(pt.elementType===Xr||typeof Xr=="object"&&Xr!==null&&Xr.$$typeof===Y&&cd(Xr)===pt.type)?(pt=I(pt,Bt.props),bu(pt,Bt),pt.return=Ct,pt):(pt=sd(Bt.type,Bt.key,Bt.props,null,Ct.mode,or),bu(pt,Bt),pt.return=Ct,pt)}function Ut(Ct,pt,Bt,or){return pt===null||pt.tag!==4||pt.stateNode.containerInfo!==Bt.containerInfo||pt.stateNode.implementation!==Bt.implementation?(pt=hu(Bt,Ct.mode,or),pt.return=Ct,pt):(pt=I(pt,Bt.children||[]),pt.return=Ct,pt)}function nr(Ct,pt,Bt,or,Xr){return pt===null||pt.tag!==7?(pt=Hl(Bt,Ct.mode,or,Xr),pt.return=Ct,pt):(pt=I(pt,Bt),pt.return=Ct,pt)}function dr(Ct,pt,Bt){if(typeof pt=="string"&&pt!==""||typeof pt=="number"||typeof pt=="bigint")return pt=e0(""+pt,Ct.mode,Bt),pt.return=Ct,pt;if(typeof pt=="object"&&pt!==null){switch(pt.$$typeof){case S:return Bt=sd(pt.type,pt.key,pt.props,null,Ct.mode,Bt),bu(Bt,pt),Bt.return=Ct,Bt;case A:return pt=hu(pt,Ct.mode,Bt),pt.return=Ct,pt;case Y:return pt=cd(pt),dr(Ct,pt,Bt)}if(re(pt)||K(pt))return pt=Hl(pt,Ct.mode,Bt,null),pt.return=Ct,pt;if(typeof pt.then=="function")return dr(Ct,uh(pt),Bt);if(pt.$$typeof===F)return dr(Ct,oh(Ct,pt),Bt);fh(Ct,pt)}return null}function Vt(Ct,pt,Bt,or){var Xr=pt!==null?pt.key:null;if(typeof Bt=="string"&&Bt!==""||typeof Bt=="number"||typeof Bt=="bigint")return Xr!==null?null:Ie(Ct,pt,""+Bt,or);if(typeof Bt=="object"&&Bt!==null){switch(Bt.$$typeof){case S:return Bt.key===Xr?lt(Ct,pt,Bt,or):null;case A:return Bt.key===Xr?Ut(Ct,pt,Bt,or):null;case Y:return Bt=cd(Bt),Vt(Ct,pt,Bt,or)}if(re(Bt)||K(Bt))return Xr!==null?null:nr(Ct,pt,Bt,or,null);if(typeof Bt.then=="function")return Vt(Ct,pt,uh(Bt),or);if(Bt.$$typeof===F)return Vt(Ct,pt,oh(Ct,Bt),or);fh(Ct,Bt)}return null}function er(Ct,pt,Bt,or,Xr){if(typeof or=="string"&&or!==""||typeof or=="number"||typeof or=="bigint")return Ct=Ct.get(Bt)||null,Ie(pt,Ct,""+or,Xr);if(typeof or=="object"&&or!==null){switch(or.$$typeof){case S:return Ct=Ct.get(or.key===null?Bt:or.key)||null,lt(pt,Ct,or,Xr);case A:return Ct=Ct.get(or.key===null?Bt:or.key)||null,Ut(pt,Ct,or,Xr);case Y:return or=cd(or),er(Ct,pt,Bt,or,Xr)}if(re(or)||K(or))return Ct=Ct.get(Bt)||null,nr(pt,Ct,or,Xr,null);if(typeof or.then=="function")return er(Ct,pt,Bt,uh(or),Xr);if(or.$$typeof===F)return er(Ct,pt,Bt,oh(pt,or),Xr);fh(pt,or)}return null}function Mr(Ct,pt,Bt,or){for(var Xr=null,qa=null,Hr=pt,wa=pt=0,Ma=null;Hr!==null&&wa<Bt.length;wa++){Hr.index>wa?(Ma=Hr,Hr=null):Ma=Hr.sibling;var Xa=Vt(Ct,Hr,Bt[wa],or);if(Xa===null){Hr===null&&(Hr=Ma);break}o&&Hr&&Xa.alternate===null&&d(Ct,Hr),pt=U(Xa,pt,wa),qa===null?Xr=Xa:qa.sibling=Xa,qa=Xa,Hr=Ma}if(wa===Bt.length)return p(Ct,Hr),Da&&Vr(Ct,wa),Xr;if(Hr===null){for(;wa<Bt.length;wa++)Hr=dr(Ct,Bt[wa],or),Hr!==null&&(pt=U(Hr,pt,wa),qa===null?Xr=Hr:qa.sibling=Hr,qa=Hr);return Da&&Vr(Ct,wa),Xr}for(Hr=N(Hr);wa<Bt.length;wa++)Ma=er(Hr,Ct,wa,Bt[wa],or),Ma!==null&&(o&&Ma.alternate!==null&&Hr.delete(Ma.key===null?wa:Ma.key),pt=U(Ma,pt,wa),qa===null?Xr=Ma:qa.sibling=Ma,qa=Ma);return o&&Hr.forEach(function(Uc){return d(Ct,Uc)}),Da&&Vr(Ct,wa),Xr}function ta(Ct,pt,Bt,or){if(Bt==null)throw Error(s(151));for(var Xr=null,qa=null,Hr=pt,wa=pt=0,Ma=null,Xa=Bt.next();Hr!==null&&!Xa.done;wa++,Xa=Bt.next()){Hr.index>wa?(Ma=Hr,Hr=null):Ma=Hr.sibling;var Uc=Vt(Ct,Hr,Xa.value,or);if(Uc===null){Hr===null&&(Hr=Ma);break}o&&Hr&&Uc.alternate===null&&d(Ct,Hr),pt=U(Uc,pt,wa),qa===null?Xr=Uc:qa.sibling=Uc,qa=Uc,Hr=Ma}if(Xa.done)return p(Ct,Hr),Da&&Vr(Ct,wa),Xr;if(Hr===null){for(;!Xa.done;wa++,Xa=Bt.next())Xa=dr(Ct,Xa.value,or),Xa!==null&&(pt=U(Xa,pt,wa),qa===null?Xr=Xa:qa.sibling=Xa,qa=Xa);return Da&&Vr(Ct,wa),Xr}for(Hr=N(Hr);!Xa.done;wa++,Xa=Bt.next())Xa=er(Hr,Ct,wa,Xa.value,or),Xa!==null&&(o&&Xa.alternate!==null&&Hr.delete(Xa.key===null?wa:Xa.key),pt=U(Xa,pt,wa),qa===null?Xr=Xa:qa.sibling=Xa,qa=Xa);return o&&Hr.forEach(function(ZC){return d(Ct,ZC)}),Da&&Vr(Ct,wa),Xr}function hs(Ct,pt,Bt,or){if(typeof Bt=="object"&&Bt!==null&&Bt.type===C&&Bt.key===null&&(Bt=Bt.props.children),typeof Bt=="object"&&Bt!==null){switch(Bt.$$typeof){case S:e:{for(var Xr=Bt.key;pt!==null;){if(pt.key===Xr){if(Xr=Bt.type,Xr===C){if(pt.tag===7){p(Ct,pt.sibling),or=I(pt,Bt.props.children),or.return=Ct,Ct=or;break e}}else if(pt.elementType===Xr||typeof Xr=="object"&&Xr!==null&&Xr.$$typeof===Y&&cd(Xr)===pt.type){p(Ct,pt.sibling),or=I(pt,Bt.props),bu(or,Bt),or.return=Ct,Ct=or;break e}p(Ct,pt);break}else d(Ct,pt);pt=pt.sibling}Bt.type===C?(or=Hl(Bt.props.children,Ct.mode,or,Bt.key),or.return=Ct,Ct=or):(or=sd(Bt.type,Bt.key,Bt.props,null,Ct.mode,or),bu(or,Bt),or.return=Ct,Ct=or)}return xe(Ct);case A:e:{for(Xr=Bt.key;pt!==null;){if(pt.key===Xr)if(pt.tag===4&&pt.stateNode.containerInfo===Bt.containerInfo&&pt.stateNode.implementation===Bt.implementation){p(Ct,pt.sibling),or=I(pt,Bt.children||[]),or.return=Ct,Ct=or;break e}else{p(Ct,pt);break}else d(Ct,pt);pt=pt.sibling}or=hu(Bt,Ct.mode,or),or.return=Ct,Ct=or}return xe(Ct);case Y:return Bt=cd(Bt),hs(Ct,pt,Bt,or)}if(re(Bt))return Mr(Ct,pt,Bt,or);if(K(Bt)){if(Xr=K(Bt),typeof Xr!="function")throw Error(s(150));return Bt=Xr.call(Bt),ta(Ct,pt,Bt,or)}if(typeof Bt.then=="function")return hs(Ct,pt,uh(Bt),or);if(Bt.$$typeof===F)return hs(Ct,pt,oh(Ct,Bt),or);fh(Ct,Bt)}return typeof Bt=="string"&&Bt!==""||typeof Bt=="number"||typeof Bt=="bigint"?(Bt=""+Bt,pt!==null&&pt.tag===6?(p(Ct,pt.sibling),or=I(pt,Bt),or.return=Ct,Ct=or):(p(Ct,pt),or=e0(Bt,Ct.mode,or),or.return=Ct,Ct=or),xe(Ct)):p(Ct,pt)}return function(Ct,pt,Bt,or){try{yu=0;var Xr=hs(Ct,pt,Bt,or);return i0=null,Xr}catch(Hr){if(Hr===n0||Hr===ch)throw Hr;var qa=bi(29,Hr,null,Ct.mode);return qa.lanes=or,qa.return=Ct,qa}finally{}}}var ud=Sb(!0),Cb=Sb(!1),kc=!1;function qg(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Xg(o,d){o=o.updateQueue,d.updateQueue===o&&(d.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,callbacks:null})}function Nc(o){return{lane:o,tag:0,payload:null,callback:null,next:null}}function jc(o,d,p){var N=o.updateQueue;if(N===null)return null;if(N=N.shared,(Ka&2)!==0){var I=N.pending;return I===null?d.next=d:(d.next=I.next,I.next=d),N.pending=d,d=ad(o),wc(o,null,p),d}return vl(o,N,d,p),ad(o)}function vu(o,d,p){if(d=d.updateQueue,d!==null&&(d=d.shared,(p&4194048)!==0)){var N=d.lanes;N&=o.pendingLanes,p|=N,d.lanes=p,ir(o,p)}}function Zg(o,d){var p=o.updateQueue,N=o.alternate;if(N!==null&&(N=N.updateQueue,p===N)){var I=null,U=null;if(p=p.firstBaseUpdate,p!==null){do{var xe={lane:p.lane,tag:p.tag,payload:p.payload,callback:null,next:null};U===null?I=U=xe:U=U.next=xe,p=p.next}while(p!==null);U===null?I=U=d:U=U.next=d}else I=U=d;p={baseState:N.baseState,firstBaseUpdate:I,lastBaseUpdate:U,shared:N.shared,callbacks:N.callbacks},o.updateQueue=p;return}o=p.lastBaseUpdate,o===null?p.firstBaseUpdate=d:o.next=d,p.lastBaseUpdate=d}var Kg=!1;function wu(){if(Kg){var o=s0;if(o!==null)throw o}}function _u(o,d,p,N){Kg=!1;var I=o.updateQueue;kc=!1;var U=I.firstBaseUpdate,xe=I.lastBaseUpdate,Ie=I.shared.pending;if(Ie!==null){I.shared.pending=null;var lt=Ie,Ut=lt.next;lt.next=null,xe===null?U=Ut:xe.next=Ut,xe=lt;var nr=o.alternate;nr!==null&&(nr=nr.updateQueue,Ie=nr.lastBaseUpdate,Ie!==xe&&(Ie===null?nr.firstBaseUpdate=Ut:Ie.next=Ut,nr.lastBaseUpdate=lt))}if(U!==null){var dr=I.baseState;xe=0,nr=Ut=lt=null,Ie=U;do{var Vt=Ie.lane&-536870913,er=Vt!==Ie.lane;if(er?(Ia&Vt)===Vt:(N&Vt)===Vt){Vt!==0&&Vt===a0&&(Kg=!0),nr!==null&&(nr=nr.next={lane:0,tag:Ie.tag,payload:Ie.payload,callback:null,next:null});e:{var Mr=o,ta=Ie;Vt=d;var hs=p;switch(ta.tag){case 1:if(Mr=ta.payload,typeof Mr=="function"){dr=Mr.call(hs,dr,Vt);break e}dr=Mr;break e;case 3:Mr.flags=Mr.flags&-65537|128;case 0:if(Mr=ta.payload,Vt=typeof Mr=="function"?Mr.call(hs,dr,Vt):Mr,Vt==null)break e;dr=w({},dr,Vt);break e;case 2:kc=!0}}Vt=Ie.callback,Vt!==null&&(o.flags|=64,er&&(o.flags|=8192),er=I.callbacks,er===null?I.callbacks=[Vt]:er.push(Vt))}else er={lane:Vt,tag:Ie.tag,payload:Ie.payload,callback:Ie.callback,next:null},nr===null?(Ut=nr=er,lt=dr):nr=nr.next=er,xe|=Vt;if(Ie=Ie.next,Ie===null){if(Ie=I.shared.pending,Ie===null)break;er=Ie,Ie=er.next,er.next=null,I.lastBaseUpdate=er,I.shared.pending=null}}while(!0);nr===null&&(lt=dr),I.baseState=lt,I.firstBaseUpdate=Ut,I.lastBaseUpdate=nr,U===null&&(I.shared.lanes=0),Ac|=xe,o.lanes=xe,o.memoizedState=dr}}function Eb(o,d){if(typeof o!="function")throw Error(s(191,o));o.call(d)}function Tb(o,d){var p=o.callbacks;if(p!==null)for(o.callbacks=null,o=0;o<p.length;o++)Eb(p[o],d)}var o0=te(null),hh=te(0);function Ab(o,d){o=ec,J(hh,o),J(o0,d),ec=o|d.baseLanes}function Jg(){J(hh,ec),J(o0,o0.current)}function Qg(){ec=hh.current,q(o0),q(hh)}var uo=te(null),Ro=null;function Sc(o){var d=o.alternate;J(rn,rn.current&1),J(uo,o),Ro===null&&(d===null||o0.current!==null||d.memoizedState!==null)&&(Ro=o)}function ex(o){J(rn,rn.current),J(uo,o),Ro===null&&(Ro=o)}function Ob(o){o.tag===22?(J(rn,rn.current),J(uo,o),Ro===null&&(Ro=o)):Cc()}function Cc(){J(rn,rn.current),J(uo,uo.current)}function fo(o){q(uo),Ro===o&&(Ro=null),q(rn)}var rn=te(0);function mh(o){for(var d=o;d!==null;){if(d.tag===13){var p=d.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||ip(p)||op(p)))return d}else if(d.tag===19&&(d.memoizedProps.revealOrder==="forwards"||d.memoizedProps.revealOrder==="backwards"||d.memoizedProps.revealOrder==="unstable_legacy-backwards"||d.memoizedProps.revealOrder==="together")){if((d.flags&128)!==0)return d}else if(d.child!==null){d.child.return=d,d=d.child;continue}if(d===o)break;for(;d.sibling===null;){if(d.return===null||d.return===o)return null;d=d.return}d.sibling.return=d.return,d=d.sibling}return null}var Gl=0,pa=null,us=null,bn=null,gh=!1,l0=!1,fd=!1,xh=0,ku=0,c0=null,US=0;function Gs(){throw Error(s(321))}function tx(o,d){if(d===null)return!1;for(var p=0;p<d.length&&p<o.length;p++)if(!j(o[p],d[p]))return!1;return!0}function rx(o,d,p,N,I,U){return Gl=U,pa=d,d.memoizedState=null,d.updateQueue=null,d.lanes=0,we.H=o===null||o.memoizedState===null?m2:px,fd=!1,U=p(N,I),fd=!1,l0&&(U=Rb(d,p,N,I)),Db(o),U}function Db(o){we.H=Su;var d=us!==null&&us.next!==null;if(Gl=0,bn=us=pa=null,gh=!1,ku=0,c0=null,d)throw Error(s(300));o===null||vn||(o=o.dependencies,o!==null&&ih(o)&&(vn=!0))}function Rb(o,d,p,N){pa=o;var I=0;do{if(l0&&(c0=null),ku=0,l0=!1,25<=I)throw Error(s(301));if(I+=1,bn=us=null,o.updateQueue!=null){var U=o.updateQueue;U.lastEffect=null,U.events=null,U.stores=null,U.memoCache!=null&&(U.memoCache.index=0)}we.H=g2,U=d(p,N)}while(l0);return U}function zS(){var o=we.H,d=o.useState()[0];return d=typeof d.then=="function"?Nu(d):d,o=o.useState()[0],(us!==null?us.memoizedState:null)!==o&&(pa.flags|=1024),d}function ax(){var o=xh!==0;return xh=0,o}function sx(o,d,p){d.updateQueue=o.updateQueue,d.flags&=-2053,o.lanes&=~p}function nx(o){if(gh){for(o=o.memoizedState;o!==null;){var d=o.queue;d!==null&&(d.pending=null),o=o.next}gh=!1}Gl=0,bn=us=pa=null,l0=!1,ku=xh=0,c0=null}function Fi(){var o={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return bn===null?pa.memoizedState=bn=o:bn=bn.next=o,bn}function an(){if(us===null){var o=pa.alternate;o=o!==null?o.memoizedState:null}else o=us.next;var d=bn===null?pa.memoizedState:bn.next;if(d!==null)bn=d,us=o;else{if(o===null)throw pa.alternate===null?Error(s(467)):Error(s(310));us=o,o={memoizedState:us.memoizedState,baseState:us.baseState,baseQueue:us.baseQueue,queue:us.queue,next:null},bn===null?pa.memoizedState=bn=o:bn=bn.next=o}return bn}function ph(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Nu(o){var d=ku;return ku+=1,c0===null&&(c0=[]),o=kb(c0,o,d),d=pa,(bn===null?d.memoizedState:bn.next)===null&&(d=d.alternate,we.H=d===null||d.memoizedState===null?m2:px),o}function yh(o){if(o!==null&&typeof o=="object"){if(typeof o.then=="function")return Nu(o);if(o.$$typeof===F)return li(o)}throw Error(s(438,String(o)))}function ix(o){var d=null,p=pa.updateQueue;if(p!==null&&(d=p.memoCache),d==null){var N=pa.alternate;N!==null&&(N=N.updateQueue,N!==null&&(N=N.memoCache,N!=null&&(d={data:N.data.map(function(I){return I.slice()}),index:0})))}if(d==null&&(d={data:[],index:0}),p===null&&(p=ph(),pa.updateQueue=p),p.memoCache=d,p=d.data[d.index],p===void 0)for(p=d.data[d.index]=Array(o),N=0;N<o;N++)p[N]=ie;return d.index++,p}function Yl(o,d){return typeof d=="function"?d(o):d}function bh(o){var d=an();return ox(d,us,o)}function ox(o,d,p){var N=o.queue;if(N===null)throw Error(s(311));N.lastRenderedReducer=p;var I=o.baseQueue,U=N.pending;if(U!==null){if(I!==null){var xe=I.next;I.next=U.next,U.next=xe}d.baseQueue=I=U,N.pending=null}if(U=o.baseState,I===null)o.memoizedState=U;else{d=I.next;var Ie=xe=null,lt=null,Ut=d,nr=!1;do{var dr=Ut.lane&-536870913;if(dr!==Ut.lane?(Ia&dr)===dr:(Gl&dr)===dr){var Vt=Ut.revertLane;if(Vt===0)lt!==null&&(lt=lt.next={lane:0,revertLane:0,gesture:null,action:Ut.action,hasEagerState:Ut.hasEagerState,eagerState:Ut.eagerState,next:null}),dr===a0&&(nr=!0);else if((Gl&Vt)===Vt){Ut=Ut.next,Vt===a0&&(nr=!0);continue}else dr={lane:0,revertLane:Ut.revertLane,gesture:null,action:Ut.action,hasEagerState:Ut.hasEagerState,eagerState:Ut.eagerState,next:null},lt===null?(Ie=lt=dr,xe=U):lt=lt.next=dr,pa.lanes|=Vt,Ac|=Vt;dr=Ut.action,fd&&p(U,dr),U=Ut.hasEagerState?Ut.eagerState:p(U,dr)}else Vt={lane:dr,revertLane:Ut.revertLane,gesture:Ut.gesture,action:Ut.action,hasEagerState:Ut.hasEagerState,eagerState:Ut.eagerState,next:null},lt===null?(Ie=lt=Vt,xe=U):lt=lt.next=Vt,pa.lanes|=dr,Ac|=dr;Ut=Ut.next}while(Ut!==null&&Ut!==d);if(lt===null?xe=U:lt.next=Ie,!j(U,o.memoizedState)&&(vn=!0,nr&&(p=s0,p!==null)))throw p;o.memoizedState=U,o.baseState=xe,o.baseQueue=lt,N.lastRenderedState=U}return I===null&&(N.lanes=0),[o.memoizedState,N.dispatch]}function lx(o){var d=an(),p=d.queue;if(p===null)throw Error(s(311));p.lastRenderedReducer=o;var N=p.dispatch,I=p.pending,U=d.memoizedState;if(I!==null){p.pending=null;var xe=I=I.next;do U=o(U,xe.action),xe=xe.next;while(xe!==I);j(U,d.memoizedState)||(vn=!0),d.memoizedState=U,d.baseQueue===null&&(d.baseState=U),p.lastRenderedState=U}return[U,N]}function Fb(o,d,p){var N=pa,I=an(),U=Da;if(U){if(p===void 0)throw Error(s(407));p=p()}else p=d();var xe=!j((us||I).memoizedState,p);if(xe&&(I.memoizedState=p,vn=!0),I=I.queue,ux(Pb.bind(null,N,I,o),[o]),I.getSnapshot!==d||xe||bn!==null&&bn.memoizedState.tag&1){if(N.flags|=2048,d0(9,{destroy:void 0},Mb.bind(null,N,I,p,d),null),xs===null)throw Error(s(349));U||(Gl&127)!==0||Ib(N,d,p)}return p}function Ib(o,d,p){o.flags|=16384,o={getSnapshot:d,value:p},d=pa.updateQueue,d===null?(d=ph(),pa.updateQueue=d,d.stores=[o]):(p=d.stores,p===null?d.stores=[o]:p.push(o))}function Mb(o,d,p,N){d.value=p,d.getSnapshot=N,Lb(d)&&Bb(o)}function Pb(o,d,p){return p(function(){Lb(d)&&Bb(o)})}function Lb(o){var d=o.getSnapshot;o=o.value;try{var p=d();return!j(o,p)}catch(N){return!0}}function Bb(o){var d=Oo(o,2);d!==null&&Ki(d,o,2)}function cx(o){var d=Fi();if(typeof o=="function"){var p=o;if(o=p(),fd){ze(!0);try{p()}finally{ze(!1)}}}return d.memoizedState=d.baseState=o,d.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Yl,lastRenderedState:o},d}function Ub(o,d,p,N){return o.baseState=p,ox(o,us,typeof N=="function"?N:Yl)}function WS(o,d,p,N,I){if(_h(o))throw Error(s(485));if(o=d.action,o!==null){var U={payload:I,action:o,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(xe){U.listeners.push(xe)}};we.T!==null?p(!0):U.isTransition=!1,N(U),p=d.pending,p===null?(U.next=d.pending=U,zb(d,U)):(U.next=p.next,d.pending=p.next=U)}}function zb(o,d){var p=d.action,N=d.payload,I=o.state;if(d.isTransition){var U=we.T,xe={};we.T=xe;try{var Ie=p(I,N),lt=we.S;lt!==null&&lt(xe,Ie),Wb(o,d,Ie)}catch(Ut){dx(o,d,Ut)}finally{U!==null&&xe.types!==null&&(U.types=xe.types),we.T=U}}else try{U=p(I,N),Wb(o,d,U)}catch(Ut){dx(o,d,Ut)}}function Wb(o,d,p){p!==null&&typeof p=="object"&&typeof p.then=="function"?p.then(function(N){Hb(o,d,N)},function(N){return dx(o,d,N)}):Hb(o,d,p)}function Hb(o,d,p){d.status="fulfilled",d.value=p,$b(d),o.state=p,d=o.pending,d!==null&&(p=d.next,p===d?o.pending=null:(p=p.next,d.next=p,zb(o,p)))}function dx(o,d,p){var N=o.pending;if(o.pending=null,N!==null){N=N.next;do d.status="rejected",d.reason=p,$b(d),d=d.next;while(d!==N)}o.action=null}function $b(o){o=o.listeners;for(var d=0;d<o.length;d++)(0,o[d])()}function Vb(o,d){return d}function Gb(o,d){if(Da){var p=xs.formState;if(p!==null){e:{var N=pa;if(Da){if(Ya){t:{for(var I=Ya,U=Gi;I.nodeType!==8;){if(!U){I=null;break t}if(I=Fo(I.nextSibling),I===null){I=null;break t}}U=I.data,I=U==="F!"||U==="F"?I:null}if(I){Ya=Fo(I.nextSibling),N=I.data==="F!";break e}}_l(N)}N=!1}N&&(d=p[0])}}return p=Fi(),p.memoizedState=p.baseState=d,N={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Vb,lastRenderedState:d},p.queue=N,p=u2.bind(null,pa,N),N.dispatch=p,N=cx(!1),U=xx.bind(null,pa,!1,N.queue),N=Fi(),I={state:d,dispatch:null,action:o,pending:null},N.queue=I,p=WS.bind(null,pa,I,U,p),I.dispatch=p,N.memoizedState=o,[d,p,!1]}function Yb(o){var d=an();return qb(d,us,o)}function qb(o,d,p){if(d=ox(o,d,Vb)[0],o=bh(Yl)[0],typeof d=="object"&&d!==null&&typeof d.then=="function")try{var N=Nu(d)}catch(xe){throw xe===n0?ch:xe}else N=d;d=an();var I=d.queue,U=I.dispatch;return p!==d.memoizedState&&(pa.flags|=2048,d0(9,{destroy:void 0},HS.bind(null,I,p),null)),[N,U,o]}function HS(o,d){o.action=d}function Xb(o){var d=an(),p=us;if(p!==null)return qb(d,p,o);an(),d=d.memoizedState,p=an();var N=p.queue.dispatch;return p.memoizedState=o,[d,N,!1]}function d0(o,d,p,N){return o={tag:o,create:p,deps:N,inst:d,next:null},d=pa.updateQueue,d===null&&(d=ph(),pa.updateQueue=d),p=d.lastEffect,p===null?d.lastEffect=o.next=o:(N=p.next,p.next=o,o.next=N,d.lastEffect=o),o}function Zb(){return an().memoizedState}function vh(o,d,p,N){var I=Fi();pa.flags|=o,I.memoizedState=d0(1|d,{destroy:void 0},p,N===void 0?null:N)}function wh(o,d,p,N){var I=an();N=N===void 0?null:N;var U=I.memoizedState.inst;us!==null&&N!==null&&tx(N,us.memoizedState.deps)?I.memoizedState=d0(d,U,p,N):(pa.flags|=o,I.memoizedState=d0(1|d,U,p,N))}function Kb(o,d){vh(8390656,8,o,d)}function ux(o,d){wh(2048,8,o,d)}function $S(o){pa.flags|=4;var d=pa.updateQueue;if(d===null)d=ph(),pa.updateQueue=d,d.events=[o];else{var p=d.events;p===null?d.events=[o]:p.push(o)}}function Jb(o){var d=an().memoizedState;return $S({ref:d,nextImpl:o}),function(){if((Ka&2)!==0)throw Error(s(440));return d.impl.apply(void 0,arguments)}}function Qb(o,d){return wh(4,2,o,d)}function e2(o,d){return wh(4,4,o,d)}function t2(o,d){if(typeof d=="function"){o=o();var p=d(o);return function(){typeof p=="function"?p():d(null)}}if(d!=null)return o=o(),d.current=o,function(){d.current=null}}function r2(o,d,p){p=p!=null?p.concat([o]):null,wh(4,4,t2.bind(null,d,o),p)}function fx(){}function a2(o,d){var p=an();d=d===void 0?null:d;var N=p.memoizedState;return d!==null&&tx(d,N[1])?N[0]:(p.memoizedState=[o,d],o)}function s2(o,d){var p=an();d=d===void 0?null:d;var N=p.memoizedState;if(d!==null&&tx(d,N[1]))return N[0];if(N=o(),fd){ze(!0);try{o()}finally{ze(!1)}}return p.memoizedState=[N,d],N}function hx(o,d,p){return p===void 0||(Gl&1073741824)!==0&&(Ia&261930)===0?o.memoizedState=d:(o.memoizedState=p,o=nv(),pa.lanes|=o,Ac|=o,p)}function n2(o,d,p,N){return j(p,d)?p:o0.current!==null?(o=hx(o,p,N),j(o,d)||(vn=!0),o):(Gl&42)===0||(Gl&1073741824)!==0&&(Ia&261930)===0?(vn=!0,o.memoizedState=p):(o=nv(),pa.lanes|=o,Ac|=o,d)}function i2(o,d,p,N,I){var U=ee.p;ee.p=U!==0&&8>U?U:8;var xe=we.T,Ie={};we.T=Ie,xx(o,!1,d,p);try{var lt=I(),Ut=we.S;if(Ut!==null&&Ut(Ie,lt),lt!==null&&typeof lt=="object"&&typeof lt.then=="function"){var nr=BS(lt,N);ju(o,d,nr,go(o))}else ju(o,d,N,go(o))}catch(dr){ju(o,d,{then:function(){},status:"rejected",reason:dr},go())}finally{ee.p=U,xe!==null&&Ie.types!==null&&(xe.types=Ie.types),we.T=xe}}function VS(){}function mx(o,d,p,N){if(o.tag!==5)throw Error(s(476));var I=o2(o).queue;i2(o,I,d,ve,p===null?VS:function(){return l2(o),p(N)})}function o2(o){var d=o.memoizedState;if(d!==null)return d;d={memoizedState:ve,baseState:ve,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Yl,lastRenderedState:ve},next:null};var p={};return d.next={memoizedState:p,baseState:p,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Yl,lastRenderedState:p},next:null},o.memoizedState=d,o=o.alternate,o!==null&&(o.memoizedState=d),d}function l2(o){var d=o2(o);d.next===null&&(d=o.alternate.memoizedState),ju(o,d.next.queue,{},go())}function gx(){return li(Wu)}function c2(){return an().memoizedState}function d2(){return an().memoizedState}function GS(o){for(var d=o.return;d!==null;){switch(d.tag){case 24:case 3:var p=go();o=Nc(p);var N=jc(d,o,p);N!==null&&(Ki(N,d,p),vu(N,d,p)),d={cache:$g()},o.payload=d;return}d=d.return}}function YS(o,d,p){var N=go();p={lane:N,revertLane:0,gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null},_h(o)?f2(d,p):(p=du(o,d,p,N),p!==null&&(Ki(p,o,N),h2(p,d,N)))}function u2(o,d,p){var N=go();ju(o,d,p,N)}function ju(o,d,p,N){var I={lane:N,revertLane:0,gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null};if(_h(o))f2(d,I);else{var U=o.alternate;if(o.lanes===0&&(U===null||U.lanes===0)&&(U=d.lastRenderedReducer,U!==null))try{var xe=d.lastRenderedState,Ie=U(xe,p);if(I.hasEagerState=!0,I.eagerState=Ie,j(Ie,xe))return vl(o,d,I,0),xs===null&&bl(),!1}catch(lt){}finally{}if(p=du(o,d,I,N),p!==null)return Ki(p,o,N),h2(p,d,N),!0}return!1}function xx(o,d,p,N){if(N={lane:2,revertLane:qx(),gesture:null,action:N,hasEagerState:!1,eagerState:null,next:null},_h(o)){if(d)throw Error(s(479))}else d=du(o,p,N,2),d!==null&&Ki(d,o,2)}function _h(o){var d=o.alternate;return o===pa||d!==null&&d===pa}function f2(o,d){l0=gh=!0;var p=o.pending;p===null?d.next=d:(d.next=p.next,p.next=d),o.pending=d}function h2(o,d,p){if((p&4194048)!==0){var N=d.lanes;N&=o.pendingLanes,p|=N,d.lanes=p,ir(o,p)}}var Su={readContext:li,use:yh,useCallback:Gs,useContext:Gs,useEffect:Gs,useImperativeHandle:Gs,useLayoutEffect:Gs,useInsertionEffect:Gs,useMemo:Gs,useReducer:Gs,useRef:Gs,useState:Gs,useDebugValue:Gs,useDeferredValue:Gs,useTransition:Gs,useSyncExternalStore:Gs,useId:Gs,useHostTransitionStatus:Gs,useFormState:Gs,useActionState:Gs,useOptimistic:Gs,useMemoCache:Gs,useCacheRefresh:Gs};Su.useEffectEvent=Gs;var m2={readContext:li,use:yh,useCallback:function(o,d){return Fi().memoizedState=[o,d===void 0?null:d],o},useContext:li,useEffect:Kb,useImperativeHandle:function(o,d,p){p=p!=null?p.concat([o]):null,vh(4194308,4,t2.bind(null,d,o),p)},useLayoutEffect:function(o,d){return vh(4194308,4,o,d)},useInsertionEffect:function(o,d){vh(4,2,o,d)},useMemo:function(o,d){var p=Fi();d=d===void 0?null:d;var N=o();if(fd){ze(!0);try{o()}finally{ze(!1)}}return p.memoizedState=[N,d],N},useReducer:function(o,d,p){var N=Fi();if(p!==void 0){var I=p(d);if(fd){ze(!0);try{p(d)}finally{ze(!1)}}}else I=d;return N.memoizedState=N.baseState=I,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:I},N.queue=o,o=o.dispatch=YS.bind(null,pa,o),[N.memoizedState,o]},useRef:function(o){var d=Fi();return o={current:o},d.memoizedState=o},useState:function(o){o=cx(o);var d=o.queue,p=u2.bind(null,pa,d);return d.dispatch=p,[o.memoizedState,p]},useDebugValue:fx,useDeferredValue:function(o,d){var p=Fi();return hx(p,o,d)},useTransition:function(){var o=cx(!1);return o=i2.bind(null,pa,o.queue,!0,!1),Fi().memoizedState=o,[!1,o]},useSyncExternalStore:function(o,d,p){var N=pa,I=Fi();if(Da){if(p===void 0)throw Error(s(407));p=p()}else{if(p=d(),xs===null)throw Error(s(349));(Ia&127)!==0||Ib(N,d,p)}I.memoizedState=p;var U={value:p,getSnapshot:d};return I.queue=U,Kb(Pb.bind(null,N,U,o),[o]),N.flags|=2048,d0(9,{destroy:void 0},Mb.bind(null,N,U,p,d),null),p},useId:function(){var o=Fi(),d=xs.identifierPrefix;if(Da){var p=Er,N=cr;p=(N&~(1<<32-nt(N)-1)).toString(32)+p,d="_"+d+"R_"+p,p=xh++,0<p&&(d+="H"+p.toString(32)),d+="_"}else p=US++,d="_"+d+"r_"+p.toString(32)+"_";return o.memoizedState=d},useHostTransitionStatus:gx,useFormState:Gb,useActionState:Gb,useOptimistic:function(o){var d=Fi();d.memoizedState=d.baseState=o;var p={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return d.queue=p,d=xx.bind(null,pa,!0,p),p.dispatch=d,[o,d]},useMemoCache:ix,useCacheRefresh:function(){return Fi().memoizedState=GS.bind(null,pa)},useEffectEvent:function(o){var d=Fi(),p={impl:o};return d.memoizedState=p,function(){if((Ka&2)!==0)throw Error(s(440));return p.impl.apply(void 0,arguments)}}},px={readContext:li,use:yh,useCallback:a2,useContext:li,useEffect:ux,useImperativeHandle:r2,useInsertionEffect:Qb,useLayoutEffect:e2,useMemo:s2,useReducer:bh,useRef:Zb,useState:function(){return bh(Yl)},useDebugValue:fx,useDeferredValue:function(o,d){var p=an();return n2(p,us.memoizedState,o,d)},useTransition:function(){var o=bh(Yl)[0],d=an().memoizedState;return[typeof o=="boolean"?o:Nu(o),d]},useSyncExternalStore:Fb,useId:c2,useHostTransitionStatus:gx,useFormState:Yb,useActionState:Yb,useOptimistic:function(o,d){var p=an();return Ub(p,us,o,d)},useMemoCache:ix,useCacheRefresh:d2};px.useEffectEvent=Jb;var g2={readContext:li,use:yh,useCallback:a2,useContext:li,useEffect:ux,useImperativeHandle:r2,useInsertionEffect:Qb,useLayoutEffect:e2,useMemo:s2,useReducer:lx,useRef:Zb,useState:function(){return lx(Yl)},useDebugValue:fx,useDeferredValue:function(o,d){var p=an();return us===null?hx(p,o,d):n2(p,us.memoizedState,o,d)},useTransition:function(){var o=lx(Yl)[0],d=an().memoizedState;return[typeof o=="boolean"?o:Nu(o),d]},useSyncExternalStore:Fb,useId:c2,useHostTransitionStatus:gx,useFormState:Xb,useActionState:Xb,useOptimistic:function(o,d){var p=an();return us!==null?Ub(p,us,o,d):(p.baseState=o,[o,p.queue.dispatch])},useMemoCache:ix,useCacheRefresh:d2};g2.useEffectEvent=Jb;function yx(o,d,p,N){d=o.memoizedState,p=p(N,d),p=p==null?d:w({},d,p),o.memoizedState=p,o.lanes===0&&(o.updateQueue.baseState=p)}var bx={enqueueSetState:function(o,d,p){o=o._reactInternals;var N=go(),I=Nc(N);I.payload=d,p!=null&&(I.callback=p),d=jc(o,I,N),d!==null&&(Ki(d,o,N),vu(d,o,N))},enqueueReplaceState:function(o,d,p){o=o._reactInternals;var N=go(),I=Nc(N);I.tag=1,I.payload=d,p!=null&&(I.callback=p),d=jc(o,I,N),d!==null&&(Ki(d,o,N),vu(d,o,N))},enqueueForceUpdate:function(o,d){o=o._reactInternals;var p=go(),N=Nc(p);N.tag=2,d!=null&&(N.callback=d),d=jc(o,N,p),d!==null&&(Ki(d,o,p),vu(d,o,p))}};function x2(o,d,p,N,I,U,xe){return o=o.stateNode,typeof o.shouldComponentUpdate=="function"?o.shouldComponentUpdate(N,U,xe):d.prototype&&d.prototype.isPureReactComponent?!T(p,N)||!T(I,U):!0}function p2(o,d,p,N){o=d.state,typeof d.componentWillReceiveProps=="function"&&d.componentWillReceiveProps(p,N),typeof d.UNSAFE_componentWillReceiveProps=="function"&&d.UNSAFE_componentWillReceiveProps(p,N),d.state!==o&&bx.enqueueReplaceState(d,d.state,null)}function hd(o,d){var p=d;if("ref"in d){p={};for(var N in d)N!=="ref"&&(p[N]=d[N])}if(o=o.defaultProps){p===d&&(p=w({},p));for(var I in o)p[I]===void 0&&(p[I]=o[I])}return p}function y2(o){pn(o)}function b2(o){console.error(o)}function v2(o){pn(o)}function kh(o,d){try{var p=o.onUncaughtError;p(d.value,{componentStack:d.stack})}catch(N){setTimeout(function(){throw N})}}function w2(o,d,p){try{var N=o.onCaughtError;N(p.value,{componentStack:p.stack,errorBoundary:d.tag===1?d.stateNode:null})}catch(I){setTimeout(function(){throw I})}}function vx(o,d,p){return p=Nc(p),p.tag=3,p.payload={element:null},p.callback=function(){kh(o,d)},p}function _2(o){return o=Nc(o),o.tag=3,o}function k2(o,d,p,N){var I=p.type.getDerivedStateFromError;if(typeof I=="function"){var U=N.value;o.payload=function(){return I(U)},o.callback=function(){w2(d,p,N)}}var xe=p.stateNode;xe!==null&&typeof xe.componentDidCatch=="function"&&(o.callback=function(){w2(d,p,N),typeof I!="function"&&(Oc===null?Oc=new Set([this]):Oc.add(this));var Ie=N.stack;this.componentDidCatch(N.value,{componentStack:Ie!==null?Ie:""})})}function qS(o,d,p,N,I){if(p.flags|=32768,N!==null&&typeof N=="object"&&typeof N.then=="function"){if(d=p.alternate,d!==null&&r0(d,p,I,!0),p=uo.current,p!==null){switch(p.tag){case 31:case 13:return Ro===null?Ih():p.alternate===null&&Ys===0&&(Ys=3),p.flags&=-257,p.flags|=65536,p.lanes=I,N===dh?p.flags|=16384:(d=p.updateQueue,d===null?p.updateQueue=new Set([N]):d.add(N),Vx(o,N,I)),!1;case 22:return p.flags|=65536,N===dh?p.flags|=16384:(d=p.updateQueue,d===null?(d={transitions:null,markerInstances:null,retryQueue:new Set([N])},p.updateQueue=d):(p=d.retryQueue,p===null?d.retryQueue=new Set([N]):p.add(N)),Vx(o,N,I)),!1}throw Error(s(435,p.tag))}return Vx(o,N,I),Ih(),!1}if(Da)return d=uo.current,d!==null?((d.flags&65536)===0&&(d.flags|=256),d.flags|=65536,d.lanes=I,N!==t0&&(o=Error(s(422),{cause:N}),nd(k(o,p)))):(N!==t0&&(d=Error(s(423),{cause:N}),nd(k(d,p))),o=o.current.alternate,o.flags|=65536,I&=-I,o.lanes|=I,N=k(N,p),I=vx(o.stateNode,N,I),Zg(o,I),Ys!==4&&(Ys=2)),!1;var U=Error(s(520),{cause:N});if(U=k(U,p),Fu===null?Fu=[U]:Fu.push(U),Ys!==4&&(Ys=2),d===null)return!0;N=k(N,p),p=d;do{switch(p.tag){case 3:return p.flags|=65536,o=I&-I,p.lanes|=o,o=vx(p.stateNode,N,o),Zg(p,o),!1;case 1:if(d=p.type,U=p.stateNode,(p.flags&128)===0&&(typeof d.getDerivedStateFromError=="function"||U!==null&&typeof U.componentDidCatch=="function"&&(Oc===null||!Oc.has(U))))return p.flags|=65536,I&=-I,p.lanes|=I,I=_2(I),k2(I,o,p,N),Zg(p,I),!1}p=p.return}while(p!==null);return!1}var wx=Error(s(461)),vn=!1;function ci(o,d,p,N){d.child=o===null?Cb(d,null,p,N):ud(d,o.child,p,N)}function N2(o,d,p,N,I){p=p.render;var U=d.ref;if("ref"in N){var xe={};for(var Ie in N)Ie!=="ref"&&(xe[Ie]=N[Ie])}else xe=N;return od(d),N=rx(o,d,p,xe,U,I),Ie=ax(),o!==null&&!vn?(sx(o,d,I),ql(o,d,I)):(Da&&Ie&&Dn(d),d.flags|=1,ci(o,d,N,I),d.child)}function j2(o,d,p,N,I){if(o===null){var U=p.type;return typeof U=="function"&&!Qd(U)&&U.defaultProps===void 0&&p.compare===null?(d.tag=15,d.type=U,S2(o,d,U,N,I)):(o=sd(p.type,null,N,d,d.mode,I),o.ref=d.ref,o.return=d,d.child=o)}if(U=o.child,!Tx(o,I)){var xe=U.memoizedProps;if(p=p.compare,p=p!==null?p:T,p(xe,N)&&o.ref===d.ref)return ql(o,d,I)}return d.flags|=1,o=Do(U,N),o.ref=d.ref,o.return=d,d.child=o}function S2(o,d,p,N,I){if(o!==null){var U=o.memoizedProps;if(T(U,N)&&o.ref===d.ref)if(vn=!1,d.pendingProps=N=U,Tx(o,I))(o.flags&131072)!==0&&(vn=!0);else return d.lanes=o.lanes,ql(o,d,I)}return _x(o,d,p,N,I)}function C2(o,d,p,N){var I=N.children,U=o!==null?o.memoizedState:null;if(o===null&&d.stateNode===null&&(d.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),N.mode==="hidden"){if((d.flags&128)!==0){if(U=U!==null?U.baseLanes|p:p,o!==null){for(N=d.child=o.child,I=0;N!==null;)I=I|N.lanes|N.childLanes,N=N.sibling;N=I&~U}else N=0,d.child=null;return E2(o,d,U,p,N)}if((p&536870912)!==0)d.memoizedState={baseLanes:0,cachePool:null},o!==null&&lh(d,U!==null?U.cachePool:null),U!==null?Ab(d,U):Jg(),Ob(d);else return N=d.lanes=536870912,E2(o,d,U!==null?U.baseLanes|p:p,p,N)}else U!==null?(lh(d,U.cachePool),Ab(d,U),Cc(),d.memoizedState=null):(o!==null&&lh(d,null),Jg(),Cc());return ci(o,d,I,p),d.child}function Cu(o,d){return o!==null&&o.tag===22||d.stateNode!==null||(d.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),d.sibling}function E2(o,d,p,N,I){var U=Gg();return U=U===null?null:{parent:yn._currentValue,pool:U},d.memoizedState={baseLanes:p,cachePool:U},o!==null&&lh(d,null),Jg(),Ob(d),o!==null&&r0(o,d,N,!0),d.childLanes=I,null}function Nh(o,d){return d=Sh({mode:d.mode,children:d.children},o.mode),d.ref=o.ref,o.child=d,d.return=o,d}function T2(o,d,p){return ud(d,o.child,null,p),o=Nh(d,d.pendingProps),o.flags|=2,fo(d),d.memoizedState=null,o}function XS(o,d,p){var N=d.pendingProps,I=(d.flags&128)!==0;if(d.flags&=-129,o===null){if(Da){if(N.mode==="hidden")return o=Nh(d,N),d.lanes=536870912,Cu(null,o);if(ex(d),(o=Ya)?(o=zv(o,Gi),o=o!==null&&o.data==="&"?o:null,o!==null&&(d.memoizedState={dehydrated:o,treeContext:$t!==null?{id:cr,overflow:Er}:null,retryLane:536870912,hydrationErrors:null},p=fu(o),p.return=d,d.child=p,Ga=d,Ya=null)):o=null,o===null)throw _l(d);return d.lanes=536870912,null}return Nh(d,N)}var U=o.memoizedState;if(U!==null){var xe=U.dehydrated;if(ex(d),I)if(d.flags&256)d.flags&=-257,d=T2(o,d,p);else if(d.memoizedState!==null)d.child=o.child,d.flags|=128,d=null;else throw Error(s(558));else if(vn||r0(o,d,p,!1),I=(p&o.childLanes)!==0,vn||I){if(N=xs,N!==null&&(xe=fr(N,p),xe!==0&&xe!==U.retryLane))throw U.retryLane=xe,Oo(o,xe),Ki(N,o,xe),wx;Ih(),d=T2(o,d,p)}else o=U.treeContext,Ya=Fo(xe.nextSibling),Ga=d,Da=!0,wl=null,Gi=!1,o!==null&&Ri(d,o),d=Nh(d,N),d.flags|=4096;return d}return o=Do(o.child,{mode:N.mode,children:N.children}),o.ref=d.ref,d.child=o,o.return=d,o}function jh(o,d){var p=d.ref;if(p===null)o!==null&&o.ref!==null&&(d.flags|=4194816);else{if(typeof p!="function"&&typeof p!="object")throw Error(s(284));(o===null||o.ref!==p)&&(d.flags|=4194816)}}function _x(o,d,p,N,I){return od(d),p=rx(o,d,p,N,void 0,I),N=ax(),o!==null&&!vn?(sx(o,d,I),ql(o,d,I)):(Da&&N&&Dn(d),d.flags|=1,ci(o,d,p,I),d.child)}function A2(o,d,p,N,I,U){return od(d),d.updateQueue=null,p=Rb(d,N,p,I),Db(o),N=ax(),o!==null&&!vn?(sx(o,d,U),ql(o,d,U)):(Da&&N&&Dn(d),d.flags|=1,ci(o,d,p,U),d.child)}function O2(o,d,p,N,I){if(od(d),d.stateNode===null){var U=Wl,xe=p.contextType;typeof xe=="object"&&xe!==null&&(U=li(xe)),U=new p(N,U),d.memoizedState=U.state!==null&&U.state!==void 0?U.state:null,U.updater=bx,d.stateNode=U,U._reactInternals=d,U=d.stateNode,U.props=N,U.state=d.memoizedState,U.refs={},qg(d),xe=p.contextType,U.context=typeof xe=="object"&&xe!==null?li(xe):Wl,U.state=d.memoizedState,xe=p.getDerivedStateFromProps,typeof xe=="function"&&(yx(d,p,xe,N),U.state=d.memoizedState),typeof p.getDerivedStateFromProps=="function"||typeof U.getSnapshotBeforeUpdate=="function"||typeof U.UNSAFE_componentWillMount!="function"&&typeof U.componentWillMount!="function"||(xe=U.state,typeof U.componentWillMount=="function"&&U.componentWillMount(),typeof U.UNSAFE_componentWillMount=="function"&&U.UNSAFE_componentWillMount(),xe!==U.state&&bx.enqueueReplaceState(U,U.state,null),_u(d,N,U,I),wu(),U.state=d.memoizedState),typeof U.componentDidMount=="function"&&(d.flags|=4194308),N=!0}else if(o===null){U=d.stateNode;var Ie=d.memoizedProps,lt=hd(p,Ie);U.props=lt;var Ut=U.context,nr=p.contextType;xe=Wl,typeof nr=="object"&&nr!==null&&(xe=li(nr));var dr=p.getDerivedStateFromProps;nr=typeof dr=="function"||typeof U.getSnapshotBeforeUpdate=="function",Ie=d.pendingProps!==Ie,nr||typeof U.UNSAFE_componentWillReceiveProps!="function"&&typeof U.componentWillReceiveProps!="function"||(Ie||Ut!==xe)&&p2(d,U,N,xe),kc=!1;var Vt=d.memoizedState;U.state=Vt,_u(d,N,U,I),wu(),Ut=d.memoizedState,Ie||Vt!==Ut||kc?(typeof dr=="function"&&(yx(d,p,dr,N),Ut=d.memoizedState),(lt=kc||x2(d,p,lt,N,Vt,Ut,xe))?(nr||typeof U.UNSAFE_componentWillMount!="function"&&typeof U.componentWillMount!="function"||(typeof U.componentWillMount=="function"&&U.componentWillMount(),typeof U.UNSAFE_componentWillMount=="function"&&U.UNSAFE_componentWillMount()),typeof U.componentDidMount=="function"&&(d.flags|=4194308)):(typeof U.componentDidMount=="function"&&(d.flags|=4194308),d.memoizedProps=N,d.memoizedState=Ut),U.props=N,U.state=Ut,U.context=xe,N=lt):(typeof U.componentDidMount=="function"&&(d.flags|=4194308),N=!1)}else{U=d.stateNode,Xg(o,d),xe=d.memoizedProps,nr=hd(p,xe),U.props=nr,dr=d.pendingProps,Vt=U.context,Ut=p.contextType,lt=Wl,typeof Ut=="object"&&Ut!==null&&(lt=li(Ut)),Ie=p.getDerivedStateFromProps,(Ut=typeof Ie=="function"||typeof U.getSnapshotBeforeUpdate=="function")||typeof U.UNSAFE_componentWillReceiveProps!="function"&&typeof U.componentWillReceiveProps!="function"||(xe!==dr||Vt!==lt)&&p2(d,U,N,lt),kc=!1,Vt=d.memoizedState,U.state=Vt,_u(d,N,U,I),wu();var er=d.memoizedState;xe!==dr||Vt!==er||kc||o!==null&&o.dependencies!==null&&ih(o.dependencies)?(typeof Ie=="function"&&(yx(d,p,Ie,N),er=d.memoizedState),(nr=kc||x2(d,p,nr,N,Vt,er,lt)||o!==null&&o.dependencies!==null&&ih(o.dependencies))?(Ut||typeof U.UNSAFE_componentWillUpdate!="function"&&typeof U.componentWillUpdate!="function"||(typeof U.componentWillUpdate=="function"&&U.componentWillUpdate(N,er,lt),typeof U.UNSAFE_componentWillUpdate=="function"&&U.UNSAFE_componentWillUpdate(N,er,lt)),typeof U.componentDidUpdate=="function"&&(d.flags|=4),typeof U.getSnapshotBeforeUpdate=="function"&&(d.flags|=1024)):(typeof U.componentDidUpdate!="function"||xe===o.memoizedProps&&Vt===o.memoizedState||(d.flags|=4),typeof U.getSnapshotBeforeUpdate!="function"||xe===o.memoizedProps&&Vt===o.memoizedState||(d.flags|=1024),d.memoizedProps=N,d.memoizedState=er),U.props=N,U.state=er,U.context=lt,N=nr):(typeof U.componentDidUpdate!="function"||xe===o.memoizedProps&&Vt===o.memoizedState||(d.flags|=4),typeof U.getSnapshotBeforeUpdate!="function"||xe===o.memoizedProps&&Vt===o.memoizedState||(d.flags|=1024),N=!1)}return U=N,jh(o,d),N=(d.flags&128)!==0,U||N?(U=d.stateNode,p=N&&typeof p.getDerivedStateFromError!="function"?null:U.render(),d.flags|=1,o!==null&&N?(d.child=ud(d,o.child,null,I),d.child=ud(d,null,p,I)):ci(o,d,p,I),d.memoizedState=U.state,o=d.child):o=ql(o,d,I),o}function D2(o,d,p,N){return $l(),d.flags|=256,ci(o,d,p,N),d.child}var kx={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Nx(o){return{baseLanes:o,cachePool:wb()}}function jx(o,d,p){return o=o!==null?o.childLanes&~p:0,d&&(o|=mo),o}function R2(o,d,p){var N=d.pendingProps,I=!1,U=(d.flags&128)!==0,xe;if((xe=U)||(xe=o!==null&&o.memoizedState===null?!1:(rn.current&2)!==0),xe&&(I=!0,d.flags&=-129),xe=(d.flags&32)!==0,d.flags&=-33,o===null){if(Da){if(I?Sc(d):Cc(),(o=Ya)?(o=zv(o,Gi),o=o!==null&&o.data!=="&"?o:null,o!==null&&(d.memoizedState={dehydrated:o,treeContext:$t!==null?{id:cr,overflow:Er}:null,retryLane:536870912,hydrationErrors:null},p=fu(o),p.return=d,d.child=p,Ga=d,Ya=null)):o=null,o===null)throw _l(d);return op(o)?d.lanes=32:d.lanes=536870912,null}var Ie=N.children;return N=N.fallback,I?(Cc(),I=d.mode,Ie=Sh({mode:"hidden",children:Ie},I),N=Hl(N,I,p,null),Ie.return=d,N.return=d,Ie.sibling=N,d.child=Ie,N=d.child,N.memoizedState=Nx(p),N.childLanes=jx(o,xe,p),d.memoizedState=kx,Cu(null,N)):(Sc(d),Sx(d,Ie))}var lt=o.memoizedState;if(lt!==null&&(Ie=lt.dehydrated,Ie!==null)){if(U)d.flags&256?(Sc(d),d.flags&=-257,d=Cx(o,d,p)):d.memoizedState!==null?(Cc(),d.child=o.child,d.flags|=128,d=null):(Cc(),Ie=N.fallback,I=d.mode,N=Sh({mode:"visible",children:N.children},I),Ie=Hl(Ie,I,p,null),Ie.flags|=2,N.return=d,Ie.return=d,N.sibling=Ie,d.child=N,ud(d,o.child,null,p),N=d.child,N.memoizedState=Nx(p),N.childLanes=jx(o,xe,p),d.memoizedState=kx,d=Cu(null,N));else if(Sc(d),op(Ie)){if(xe=Ie.nextSibling&&Ie.nextSibling.dataset,xe)var Ut=xe.dgst;xe=Ut,N=Error(s(419)),N.stack="",N.digest=xe,nd({value:N,source:null,stack:null}),d=Cx(o,d,p)}else if(vn||r0(o,d,p,!1),xe=(p&o.childLanes)!==0,vn||xe){if(xe=xs,xe!==null&&(N=fr(xe,p),N!==0&&N!==lt.retryLane))throw lt.retryLane=N,Oo(o,N),Ki(xe,o,N),wx;ip(Ie)||Ih(),d=Cx(o,d,p)}else ip(Ie)?(d.flags|=192,d.child=o.child,d=null):(o=lt.treeContext,Ya=Fo(Ie.nextSibling),Ga=d,Da=!0,wl=null,Gi=!1,o!==null&&Ri(d,o),d=Sx(d,N.children),d.flags|=4096);return d}return I?(Cc(),Ie=N.fallback,I=d.mode,lt=o.child,Ut=lt.sibling,N=Do(lt,{mode:"hidden",children:N.children}),N.subtreeFlags=lt.subtreeFlags&65011712,Ut!==null?Ie=Do(Ut,Ie):(Ie=Hl(Ie,I,p,null),Ie.flags|=2),Ie.return=d,N.return=d,N.sibling=Ie,d.child=N,Cu(null,N),N=d.child,Ie=o.child.memoizedState,Ie===null?Ie=Nx(p):(I=Ie.cachePool,I!==null?(lt=yn._currentValue,I=I.parent!==lt?{parent:lt,pool:lt}:I):I=wb(),Ie={baseLanes:Ie.baseLanes|p,cachePool:I}),N.memoizedState=Ie,N.childLanes=jx(o,xe,p),d.memoizedState=kx,Cu(o.child,N)):(Sc(d),p=o.child,o=p.sibling,p=Do(p,{mode:"visible",children:N.children}),p.return=d,p.sibling=null,o!==null&&(xe=d.deletions,xe===null?(d.deletions=[o],d.flags|=16):xe.push(o)),d.child=p,d.memoizedState=null,p)}function Sx(o,d){return d=Sh({mode:"visible",children:d},o.mode),d.return=o,o.child=d}function Sh(o,d){return o=bi(22,o,null,d),o.lanes=0,o}function Cx(o,d,p){return ud(d,o.child,null,p),o=Sx(d,d.pendingProps.children),o.flags|=2,d.memoizedState=null,o}function F2(o,d,p){o.lanes|=d;var N=o.alternate;N!==null&&(N.lanes|=d),Wg(o.return,d,p)}function Ex(o,d,p,N,I,U){var xe=o.memoizedState;xe===null?o.memoizedState={isBackwards:d,rendering:null,renderingStartTime:0,last:N,tail:p,tailMode:I,treeForkCount:U}:(xe.isBackwards=d,xe.rendering=null,xe.renderingStartTime=0,xe.last=N,xe.tail=p,xe.tailMode=I,xe.treeForkCount=U)}function I2(o,d,p){var N=d.pendingProps,I=N.revealOrder,U=N.tail;N=N.children;var xe=rn.current,Ie=(xe&2)!==0;if(Ie?(xe=xe&1|2,d.flags|=128):xe&=1,J(rn,xe),ci(o,d,N,p),N=Da?Oe:0,!Ie&&o!==null&&(o.flags&128)!==0)e:for(o=d.child;o!==null;){if(o.tag===13)o.memoizedState!==null&&F2(o,p,d);else if(o.tag===19)F2(o,p,d);else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===d)break e;for(;o.sibling===null;){if(o.return===null||o.return===d)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}switch(I){case"forwards":for(p=d.child,I=null;p!==null;)o=p.alternate,o!==null&&mh(o)===null&&(I=p),p=p.sibling;p=I,p===null?(I=d.child,d.child=null):(I=p.sibling,p.sibling=null),Ex(d,!1,I,p,U,N);break;case"backwards":case"unstable_legacy-backwards":for(p=null,I=d.child,d.child=null;I!==null;){if(o=I.alternate,o!==null&&mh(o)===null){d.child=I;break}o=I.sibling,I.sibling=p,p=I,I=o}Ex(d,!0,p,null,U,N);break;case"together":Ex(d,!1,null,null,void 0,N);break;default:d.memoizedState=null}return d.child}function ql(o,d,p){if(o!==null&&(d.dependencies=o.dependencies),Ac|=d.lanes,(p&d.childLanes)===0)if(o!==null){if(r0(o,d,p,!1),(p&d.childLanes)===0)return null}else return null;if(o!==null&&d.child!==o.child)throw Error(s(153));if(d.child!==null){for(o=d.child,p=Do(o,o.pendingProps),d.child=p,p.return=d;o.sibling!==null;)o=o.sibling,p=p.sibling=Do(o,o.pendingProps),p.return=d;p.sibling=null}return d.child}function Tx(o,d){return(o.lanes&d)!==0?!0:(o=o.dependencies,!!(o!==null&&ih(o)))}function ZS(o,d,p){switch(d.tag){case 3:Z(d,d.stateNode.containerInfo),_c(d,yn,o.memoizedState.cache),$l();break;case 27:case 5:Pe(d);break;case 4:Z(d,d.stateNode.containerInfo);break;case 10:_c(d,d.type,d.memoizedProps.value);break;case 31:if(d.memoizedState!==null)return d.flags|=128,ex(d),null;break;case 13:var N=d.memoizedState;if(N!==null)return N.dehydrated!==null?(Sc(d),d.flags|=128,null):(p&d.child.childLanes)!==0?R2(o,d,p):(Sc(d),o=ql(o,d,p),o!==null?o.sibling:null);Sc(d);break;case 19:var I=(o.flags&128)!==0;if(N=(p&d.childLanes)!==0,N||(r0(o,d,p,!1),N=(p&d.childLanes)!==0),I){if(N)return I2(o,d,p);d.flags|=128}if(I=d.memoizedState,I!==null&&(I.rendering=null,I.tail=null,I.lastEffect=null),J(rn,rn.current),N)break;return null;case 22:return d.lanes=0,C2(o,d,p,d.pendingProps);case 24:_c(d,yn,o.memoizedState.cache)}return ql(o,d,p)}function M2(o,d,p){if(o!==null)if(o.memoizedProps!==d.pendingProps)vn=!0;else{if(!Tx(o,p)&&(d.flags&128)===0)return vn=!1,ZS(o,d,p);vn=(o.flags&131072)!==0}else vn=!1,Da&&(d.flags&1048576)!==0&&va(d,Oe,d.index);switch(d.lanes=0,d.tag){case 16:e:{var N=d.pendingProps;if(o=cd(d.elementType),d.type=o,typeof o=="function")Qd(o)?(N=hd(o,N),d.tag=1,d=O2(null,d,o,N,p)):(d.tag=0,d=_x(null,d,o,N,p));else{if(o!=null){var I=o.$$typeof;if(I===z){d.tag=11,d=N2(null,d,o,N,p);break e}else if(I===B){d.tag=14,d=j2(null,d,o,N,p);break e}}throw d=ge(o)||o,Error(s(306,d,""))}}return d;case 0:return _x(o,d,d.type,d.pendingProps,p);case 1:return N=d.type,I=hd(N,d.pendingProps),O2(o,d,N,I,p);case 3:e:{if(Z(d,d.stateNode.containerInfo),o===null)throw Error(s(387));N=d.pendingProps;var U=d.memoizedState;I=U.element,Xg(o,d),_u(d,N,null,p);var xe=d.memoizedState;if(N=xe.cache,_c(d,yn,N),N!==U.cache&&Hg(d,[yn],p,!0),wu(),N=xe.element,U.isDehydrated)if(U={element:N,isDehydrated:!1,cache:xe.cache},d.updateQueue.baseState=U,d.memoizedState=U,d.flags&256){d=D2(o,d,N,p);break e}else if(N!==I){I=k(Error(s(424)),d),nd(I),d=D2(o,d,N,p);break e}else{switch(o=d.stateNode.containerInfo,o.nodeType){case 9:o=o.body;break;default:o=o.nodeName==="HTML"?o.ownerDocument.body:o}for(Ya=Fo(o.firstChild),Ga=d,Da=!0,wl=null,Gi=!0,p=Cb(d,null,N,p),d.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling}else{if($l(),N===I){d=ql(o,d,p);break e}ci(o,d,N,p)}d=d.child}return d;case 26:return jh(o,d),o===null?(p=Yv(d.type,null,d.pendingProps,null))?d.memoizedState=p:Da||(p=d.type,o=d.pendingProps,N=Wh(le.current).createElement(p),N[ne]=d,N[_e]=o,di(N,p,o),br(N),d.stateNode=N):d.memoizedState=Yv(d.type,o.memoizedProps,d.pendingProps,o.memoizedState),null;case 27:return Pe(d),o===null&&Da&&(N=d.stateNode=$v(d.type,d.pendingProps,le.current),Ga=d,Gi=!0,I=Ya,Ic(d.type)?(lp=I,Ya=Fo(N.firstChild)):Ya=I),ci(o,d,d.pendingProps.children,p),jh(o,d),o===null&&(d.flags|=4194304),d.child;case 5:return o===null&&Da&&((I=N=Ya)&&(N=SC(N,d.type,d.pendingProps,Gi),N!==null?(d.stateNode=N,Ga=d,Ya=Fo(N.firstChild),Gi=!1,I=!0):I=!1),I||_l(d)),Pe(d),I=d.type,U=d.pendingProps,xe=o!==null?o.memoizedProps:null,N=U.children,ap(I,U)?N=null:xe!==null&&ap(I,xe)&&(d.flags|=32),d.memoizedState!==null&&(I=rx(o,d,zS,null,null,p),Wu._currentValue=I),jh(o,d),ci(o,d,N,p),d.child;case 6:return o===null&&Da&&((o=p=Ya)&&(p=CC(p,d.pendingProps,Gi),p!==null?(d.stateNode=p,Ga=d,Ya=null,o=!0):o=!1),o||_l(d)),null;case 13:return R2(o,d,p);case 4:return Z(d,d.stateNode.containerInfo),N=d.pendingProps,o===null?d.child=ud(d,null,N,p):ci(o,d,N,p),d.child;case 11:return N2(o,d,d.type,d.pendingProps,p);case 7:return ci(o,d,d.pendingProps,p),d.child;case 8:return ci(o,d,d.pendingProps.children,p),d.child;case 12:return ci(o,d,d.pendingProps.children,p),d.child;case 10:return N=d.pendingProps,_c(d,d.type,N.value),ci(o,d,N.children,p),d.child;case 9:return I=d.type._context,N=d.pendingProps.children,od(d),I=li(I),N=N(I),d.flags|=1,ci(o,d,N,p),d.child;case 14:return j2(o,d,d.type,d.pendingProps,p);case 15:return S2(o,d,d.type,d.pendingProps,p);case 19:return I2(o,d,p);case 31:return XS(o,d,p);case 22:return C2(o,d,p,d.pendingProps);case 24:return od(d),N=li(yn),o===null?(I=Gg(),I===null&&(I=xs,U=$g(),I.pooledCache=U,U.refCount++,U!==null&&(I.pooledCacheLanes|=p),I=U),d.memoizedState={parent:N,cache:I},qg(d),_c(d,yn,I)):((o.lanes&p)!==0&&(Xg(o,d),_u(d,null,null,p),wu()),I=o.memoizedState,U=d.memoizedState,I.parent!==N?(I={parent:N,cache:N},d.memoizedState=I,d.lanes===0&&(d.memoizedState=d.updateQueue.baseState=I),_c(d,yn,N)):(N=U.cache,_c(d,yn,N),N!==I.cache&&Hg(d,[yn],p,!0))),ci(o,d,d.pendingProps.children,p),d.child;case 29:throw d.pendingProps}throw Error(s(156,d.tag))}function Xl(o){o.flags|=4}function Ax(o,d,p,N,I){if((d=(o.mode&32)!==0)&&(d=!1),d){if(o.flags|=16777216,(I&335544128)===I)if(o.stateNode.complete)o.flags|=8192;else if(cv())o.flags|=8192;else throw dd=dh,Yg}else o.flags&=-16777217}function P2(o,d){if(d.type!=="stylesheet"||(d.state.loading&4)!==0)o.flags&=-16777217;else if(o.flags|=16777216,!Jv(d))if(cv())o.flags|=8192;else throw dd=dh,Yg}function Ch(o,d){d!==null&&(o.flags|=4),o.flags&16384&&(d=o.tag!==22?Tt():536870912,o.lanes|=d,m0|=d)}function Eu(o,d){if(!Da)switch(o.tailMode){case"hidden":d=o.tail;for(var p=null;d!==null;)d.alternate!==null&&(p=d),d=d.sibling;p===null?o.tail=null:p.sibling=null;break;case"collapsed":p=o.tail;for(var N=null;p!==null;)p.alternate!==null&&(N=p),p=p.sibling;N===null?d||o.tail===null?o.tail=null:o.tail.sibling=null:N.sibling=null}}function ks(o){var d=o.alternate!==null&&o.alternate.child===o.child,p=0,N=0;if(d)for(var I=o.child;I!==null;)p|=I.lanes|I.childLanes,N|=I.subtreeFlags&65011712,N|=I.flags&65011712,I.return=o,I=I.sibling;else for(I=o.child;I!==null;)p|=I.lanes|I.childLanes,N|=I.subtreeFlags,N|=I.flags,I.return=o,I=I.sibling;return o.subtreeFlags|=N,o.childLanes=p,d}function KS(o,d,p){var N=d.pendingProps;switch(Vs(d),d.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ks(d),null;case 1:return ks(d),null;case 3:return p=d.stateNode,N=null,o!==null&&(N=o.memoizedState.cache),d.memoizedState.cache!==N&&(d.flags|=2048),Vl(yn),Le(),p.pendingContext&&(p.context=p.pendingContext,p.pendingContext=null),(o===null||o.child===null)&&(el(d)?Xl(d):o===null||o.memoizedState.isDehydrated&&(d.flags&256)===0||(d.flags|=1024,gu())),ks(d),null;case 26:var I=d.type,U=d.memoizedState;return o===null?(Xl(d),U!==null?(ks(d),P2(d,U)):(ks(d),Ax(d,I,null,N,p))):U?U!==o.memoizedState?(Xl(d),ks(d),P2(d,U)):(ks(d),d.flags&=-16777217):(o=o.memoizedProps,o!==N&&Xl(d),ks(d),Ax(d,I,o,N,p)),null;case 27:if(Be(d),p=le.current,I=d.type,o!==null&&d.stateNode!=null)o.memoizedProps!==N&&Xl(d);else{if(!N){if(d.stateNode===null)throw Error(s(166));return ks(d),null}o=ae.current,el(d)?mu(d):(o=$v(I,N,p),d.stateNode=o,Xl(d))}return ks(d),null;case 5:if(Be(d),I=d.type,o!==null&&d.stateNode!=null)o.memoizedProps!==N&&Xl(d);else{if(!N){if(d.stateNode===null)throw Error(s(166));return ks(d),null}if(U=ae.current,el(d))mu(d);else{var xe=Wh(le.current);switch(U){case 1:U=xe.createElementNS("http://www.w3.org/2000/svg",I);break;case 2:U=xe.createElementNS("http://www.w3.org/1998/Math/MathML",I);break;default:switch(I){case"svg":U=xe.createElementNS("http://www.w3.org/2000/svg",I);break;case"math":U=xe.createElementNS("http://www.w3.org/1998/Math/MathML",I);break;case"script":U=xe.createElement("div"),U.innerHTML="<script><\/script>",U=U.removeChild(U.firstChild);break;case"select":U=typeof N.is=="string"?xe.createElement("select",{is:N.is}):xe.createElement("select"),N.multiple?U.multiple=!0:N.size&&(U.size=N.size);break;default:U=typeof N.is=="string"?xe.createElement(I,{is:N.is}):xe.createElement(I)}}U[ne]=d,U[_e]=N;e:for(xe=d.child;xe!==null;){if(xe.tag===5||xe.tag===6)U.appendChild(xe.stateNode);else if(xe.tag!==4&&xe.tag!==27&&xe.child!==null){xe.child.return=xe,xe=xe.child;continue}if(xe===d)break e;for(;xe.sibling===null;){if(xe.return===null||xe.return===d)break e;xe=xe.return}xe.sibling.return=xe.return,xe=xe.sibling}d.stateNode=U;e:switch(di(U,I,N),I){case"button":case"input":case"select":case"textarea":N=!!N.autoFocus;break e;case"img":N=!0;break e;default:N=!1}N&&Xl(d)}}return ks(d),Ax(d,d.type,o===null?null:o.memoizedProps,d.pendingProps,p),null;case 6:if(o&&d.stateNode!=null)o.memoizedProps!==N&&Xl(d);else{if(typeof N!="string"&&d.stateNode===null)throw Error(s(166));if(o=le.current,el(d)){if(o=d.stateNode,p=d.memoizedProps,N=null,I=Ga,I!==null)switch(I.tag){case 27:case 5:N=I.memoizedProps}o[ne]=d,o=!!(o.nodeValue===p||N!==null&&N.suppressHydrationWarning===!0||Rv(o.nodeValue,p)),o||_l(d,!0)}else o=Wh(o).createTextNode(N),o[ne]=d,d.stateNode=o}return ks(d),null;case 31:if(p=d.memoizedState,o===null||o.memoizedState!==null){if(N=el(d),p!==null){if(o===null){if(!N)throw Error(s(318));if(o=d.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(s(557));o[ne]=d}else $l(),(d.flags&128)===0&&(d.memoizedState=null),d.flags|=4;ks(d),o=!1}else p=gu(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=p),o=!0;if(!o)return d.flags&256?(fo(d),d):(fo(d),null);if((d.flags&128)!==0)throw Error(s(558))}return ks(d),null;case 13:if(N=d.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(I=el(d),N!==null&&N.dehydrated!==null){if(o===null){if(!I)throw Error(s(318));if(I=d.memoizedState,I=I!==null?I.dehydrated:null,!I)throw Error(s(317));I[ne]=d}else $l(),(d.flags&128)===0&&(d.memoizedState=null),d.flags|=4;ks(d),I=!1}else I=gu(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=I),I=!0;if(!I)return d.flags&256?(fo(d),d):(fo(d),null)}return fo(d),(d.flags&128)!==0?(d.lanes=p,d):(p=N!==null,o=o!==null&&o.memoizedState!==null,p&&(N=d.child,I=null,N.alternate!==null&&N.alternate.memoizedState!==null&&N.alternate.memoizedState.cachePool!==null&&(I=N.alternate.memoizedState.cachePool.pool),U=null,N.memoizedState!==null&&N.memoizedState.cachePool!==null&&(U=N.memoizedState.cachePool.pool),U!==I&&(N.flags|=2048)),p!==o&&p&&(d.child.flags|=8192),Ch(d,d.updateQueue),ks(d),null);case 4:return Le(),o===null&&Jx(d.stateNode.containerInfo),ks(d),null;case 10:return Vl(d.type),ks(d),null;case 19:if(q(rn),N=d.memoizedState,N===null)return ks(d),null;if(I=(d.flags&128)!==0,U=N.rendering,U===null)if(I)Eu(N,!1);else{if(Ys!==0||o!==null&&(o.flags&128)!==0)for(o=d.child;o!==null;){if(U=mh(o),U!==null){for(d.flags|=128,Eu(N,!1),o=U.updateQueue,d.updateQueue=o,Ch(d,o),d.subtreeFlags=0,o=p,p=d.child;p!==null;)uu(p,o),p=p.sibling;return J(rn,rn.current&1|2),Da&&Vr(d,N.treeForkCount),d.child}o=o.sibling}N.tail!==null&&Dt()>Dh&&(d.flags|=128,I=!0,Eu(N,!1),d.lanes=4194304)}else{if(!I)if(o=mh(U),o!==null){if(d.flags|=128,I=!0,o=o.updateQueue,d.updateQueue=o,Ch(d,o),Eu(N,!0),N.tail===null&&N.tailMode==="hidden"&&!U.alternate&&!Da)return ks(d),null}else 2*Dt()-N.renderingStartTime>Dh&&p!==536870912&&(d.flags|=128,I=!0,Eu(N,!1),d.lanes=4194304);N.isBackwards?(U.sibling=d.child,d.child=U):(o=N.last,o!==null?o.sibling=U:d.child=U,N.last=U)}return N.tail!==null?(o=N.tail,N.rendering=o,N.tail=o.sibling,N.renderingStartTime=Dt(),o.sibling=null,p=rn.current,J(rn,I?p&1|2:p&1),Da&&Vr(d,N.treeForkCount),o):(ks(d),null);case 22:case 23:return fo(d),Qg(),N=d.memoizedState!==null,o!==null?o.memoizedState!==null!==N&&(d.flags|=8192):N&&(d.flags|=8192),N?(p&536870912)!==0&&(d.flags&128)===0&&(ks(d),d.subtreeFlags&6&&(d.flags|=8192)):ks(d),p=d.updateQueue,p!==null&&Ch(d,p.retryQueue),p=null,o!==null&&o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(p=o.memoizedState.cachePool.pool),N=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(N=d.memoizedState.cachePool.pool),N!==p&&(d.flags|=2048),o!==null&&q(ld),null;case 24:return p=null,o!==null&&(p=o.memoizedState.cache),d.memoizedState.cache!==p&&(d.flags|=2048),Vl(yn),ks(d),null;case 25:return null;case 30:return null}throw Error(s(156,d.tag))}function JS(o,d){switch(Vs(d),d.tag){case 1:return o=d.flags,o&65536?(d.flags=o&-65537|128,d):null;case 3:return Vl(yn),Le(),o=d.flags,(o&65536)!==0&&(o&128)===0?(d.flags=o&-65537|128,d):null;case 26:case 27:case 5:return Be(d),null;case 31:if(d.memoizedState!==null){if(fo(d),d.alternate===null)throw Error(s(340));$l()}return o=d.flags,o&65536?(d.flags=o&-65537|128,d):null;case 13:if(fo(d),o=d.memoizedState,o!==null&&o.dehydrated!==null){if(d.alternate===null)throw Error(s(340));$l()}return o=d.flags,o&65536?(d.flags=o&-65537|128,d):null;case 19:return q(rn),null;case 4:return Le(),null;case 10:return Vl(d.type),null;case 22:case 23:return fo(d),Qg(),o!==null&&q(ld),o=d.flags,o&65536?(d.flags=o&-65537|128,d):null;case 24:return Vl(yn),null;case 25:return null;default:return null}}function L2(o,d){switch(Vs(d),d.tag){case 3:Vl(yn),Le();break;case 26:case 27:case 5:Be(d);break;case 4:Le();break;case 31:d.memoizedState!==null&&fo(d);break;case 13:fo(d);break;case 19:q(rn);break;case 10:Vl(d.type);break;case 22:case 23:fo(d),Qg(),o!==null&&q(ld);break;case 24:Vl(yn)}}function Tu(o,d){try{var p=d.updateQueue,N=p!==null?p.lastEffect:null;if(N!==null){var I=N.next;p=I;do{if((p.tag&o)===o){N=void 0;var U=p.create,xe=p.inst;N=U(),xe.destroy=N}p=p.next}while(p!==I)}}catch(Ie){ns(d,d.return,Ie)}}function Ec(o,d,p){try{var N=d.updateQueue,I=N!==null?N.lastEffect:null;if(I!==null){var U=I.next;N=U;do{if((N.tag&o)===o){var xe=N.inst,Ie=xe.destroy;if(Ie!==void 0){xe.destroy=void 0,I=d;var lt=p,Ut=Ie;try{Ut()}catch(nr){ns(I,lt,nr)}}}N=N.next}while(N!==U)}}catch(nr){ns(d,d.return,nr)}}function B2(o){var d=o.updateQueue;if(d!==null){var p=o.stateNode;try{Tb(d,p)}catch(N){ns(o,o.return,N)}}}function U2(o,d,p){p.props=hd(o.type,o.memoizedProps),p.state=o.memoizedState;try{p.componentWillUnmount()}catch(N){ns(o,d,N)}}function Au(o,d){try{var p=o.ref;if(p!==null){switch(o.tag){case 26:case 27:case 5:var N=o.stateNode;break;case 30:N=o.stateNode;break;default:N=o.stateNode}typeof p=="function"?o.refCleanup=p(N):p.current=N}}catch(I){ns(o,d,I)}}function Nl(o,d){var p=o.ref,N=o.refCleanup;if(p!==null)if(typeof N=="function")try{N()}catch(I){ns(o,d,I)}finally{o.refCleanup=null,o=o.alternate,o!=null&&(o.refCleanup=null)}else if(typeof p=="function")try{p(null)}catch(I){ns(o,d,I)}else p.current=null}function z2(o){var d=o.type,p=o.memoizedProps,N=o.stateNode;try{e:switch(d){case"button":case"input":case"select":case"textarea":p.autoFocus&&N.focus();break e;case"img":p.src?N.src=p.src:p.srcSet&&(N.srcset=p.srcSet)}}catch(I){ns(o,o.return,I)}}function Ox(o,d,p){try{var N=o.stateNode;vC(N,o.type,p,d),N[_e]=d}catch(I){ns(o,o.return,I)}}function W2(o){return o.tag===5||o.tag===3||o.tag===26||o.tag===27&&Ic(o.type)||o.tag===4}function Dx(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||W2(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.tag===27&&Ic(o.type)||o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function Rx(o,d,p){var N=o.tag;if(N===5||N===6)o=o.stateNode,d?(p.nodeType===9?p.body:p.nodeName==="HTML"?p.ownerDocument.body:p).insertBefore(o,d):(d=p.nodeType===9?p.body:p.nodeName==="HTML"?p.ownerDocument.body:p,d.appendChild(o),p=p._reactRootContainer,p!=null||d.onclick!==null||(d.onclick=Ts));else if(N!==4&&(N===27&&Ic(o.type)&&(p=o.stateNode,d=null),o=o.child,o!==null))for(Rx(o,d,p),o=o.sibling;o!==null;)Rx(o,d,p),o=o.sibling}function Eh(o,d,p){var N=o.tag;if(N===5||N===6)o=o.stateNode,d?p.insertBefore(o,d):p.appendChild(o);else if(N!==4&&(N===27&&Ic(o.type)&&(p=o.stateNode),o=o.child,o!==null))for(Eh(o,d,p),o=o.sibling;o!==null;)Eh(o,d,p),o=o.sibling}function H2(o){var d=o.stateNode,p=o.memoizedProps;try{for(var N=o.type,I=d.attributes;I.length;)d.removeAttributeNode(I[0]);di(d,N,p),d[ne]=o,d[_e]=p}catch(U){ns(o,o.return,U)}}var Zl=!1,wn=!1,Fx=!1,$2=typeof WeakSet=="function"?WeakSet:Set,Vn=null;function QS(o,d){if(o=o.containerInfo,tp=Xh,o=je(o),Ae(o)){if("selectionStart"in o)var p={start:o.selectionStart,end:o.selectionEnd};else e:{p=(p=o.ownerDocument)&&p.defaultView||window;var N=p.getSelection&&p.getSelection();if(N&&N.rangeCount!==0){p=N.anchorNode;var I=N.anchorOffset,U=N.focusNode;N=N.focusOffset;try{p.nodeType,U.nodeType}catch(ta){p=null;break e}var xe=0,Ie=-1,lt=-1,Ut=0,nr=0,dr=o,Vt=null;t:for(;;){for(var er;dr!==p||I!==0&&dr.nodeType!==3||(Ie=xe+I),dr!==U||N!==0&&dr.nodeType!==3||(lt=xe+N),dr.nodeType===3&&(xe+=dr.nodeValue.length),(er=dr.firstChild)!==null;)Vt=dr,dr=er;for(;;){if(dr===o)break t;if(Vt===p&&++Ut===I&&(Ie=xe),Vt===U&&++nr===N&&(lt=xe),(er=dr.nextSibling)!==null)break;dr=Vt,Vt=dr.parentNode}dr=er}p=Ie===-1||lt===-1?null:{start:Ie,end:lt}}else p=null}p=p||{start:0,end:0}}else p=null;for(rp={focusedElem:o,selectionRange:p},Xh=!1,Vn=d;Vn!==null;)if(d=Vn,o=d.child,(d.subtreeFlags&1028)!==0&&o!==null)o.return=d,Vn=o;else for(;Vn!==null;){switch(d=Vn,U=d.alternate,o=d.flags,d.tag){case 0:if((o&4)!==0&&(o=d.updateQueue,o=o!==null?o.events:null,o!==null))for(p=0;p<o.length;p++)I=o[p],I.ref.impl=I.nextImpl;break;case 11:case 15:break;case 1:if((o&1024)!==0&&U!==null){o=void 0,p=d,I=U.memoizedProps,U=U.memoizedState,N=p.stateNode;try{var Mr=hd(p.type,I);o=N.getSnapshotBeforeUpdate(Mr,U),N.__reactInternalSnapshotBeforeUpdate=o}catch(ta){ns(p,p.return,ta)}}break;case 3:if((o&1024)!==0){if(o=d.stateNode.containerInfo,p=o.nodeType,p===9)np(o);else if(p===1)switch(o.nodeName){case"HEAD":case"HTML":case"BODY":np(o);break;default:o.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((o&1024)!==0)throw Error(s(163))}if(o=d.sibling,o!==null){o.return=d.return,Vn=o;break}Vn=d.return}}function V2(o,d,p){var N=p.flags;switch(p.tag){case 0:case 11:case 15:Jl(o,p),N&4&&Tu(5,p);break;case 1:if(Jl(o,p),N&4)if(o=p.stateNode,d===null)try{o.componentDidMount()}catch(xe){ns(p,p.return,xe)}else{var I=hd(p.type,d.memoizedProps);d=d.memoizedState;try{o.componentDidUpdate(I,d,o.__reactInternalSnapshotBeforeUpdate)}catch(xe){ns(p,p.return,xe)}}N&64&&B2(p),N&512&&Au(p,p.return);break;case 3:if(Jl(o,p),N&64&&(o=p.updateQueue,o!==null)){if(d=null,p.child!==null)switch(p.child.tag){case 27:case 5:d=p.child.stateNode;break;case 1:d=p.child.stateNode}try{Tb(o,d)}catch(xe){ns(p,p.return,xe)}}break;case 27:d===null&&N&4&&H2(p);case 26:case 5:Jl(o,p),d===null&&N&4&&z2(p),N&512&&Au(p,p.return);break;case 12:Jl(o,p);break;case 31:Jl(o,p),N&4&&q2(o,p);break;case 13:Jl(o,p),N&4&&X2(o,p),N&64&&(o=p.memoizedState,o!==null&&(o=o.dehydrated,o!==null&&(p=lC.bind(null,p),EC(o,p))));break;case 22:if(N=p.memoizedState!==null||Zl,!N){d=d!==null&&d.memoizedState!==null||wn,I=Zl;var U=wn;Zl=N,(wn=d)&&!U?Ql(o,p,(p.subtreeFlags&8772)!==0):Jl(o,p),Zl=I,wn=U}break;case 30:break;default:Jl(o,p)}}function G2(o){var d=o.alternate;d!==null&&(o.alternate=null,G2(d)),o.child=null,o.deletions=null,o.sibling=null,o.tag===5&&(d=o.stateNode,d!==null&&tt(d)),o.stateNode=null,o.return=null,o.dependencies=null,o.memoizedProps=null,o.memoizedState=null,o.pendingProps=null,o.stateNode=null,o.updateQueue=null}var Fs=null,Yi=!1;function Kl(o,d,p){for(p=p.child;p!==null;)Y2(o,d,p),p=p.sibling}function Y2(o,d,p){if(kt&&typeof kt.onCommitFiberUnmount=="function")try{kt.onCommitFiberUnmount(qt,p)}catch(U){}switch(p.tag){case 26:wn||Nl(p,d),Kl(o,d,p),p.memoizedState?p.memoizedState.count--:p.stateNode&&(p=p.stateNode,p.parentNode.removeChild(p));break;case 27:wn||Nl(p,d);var N=Fs,I=Yi;Ic(p.type)&&(Fs=p.stateNode,Yi=!1),Kl(o,d,p),Bu(p.stateNode),Fs=N,Yi=I;break;case 5:wn||Nl(p,d);case 6:if(N=Fs,I=Yi,Fs=null,Kl(o,d,p),Fs=N,Yi=I,Fs!==null)if(Yi)try{(Fs.nodeType===9?Fs.body:Fs.nodeName==="HTML"?Fs.ownerDocument.body:Fs).removeChild(p.stateNode)}catch(U){ns(p,d,U)}else try{Fs.removeChild(p.stateNode)}catch(U){ns(p,d,U)}break;case 18:Fs!==null&&(Yi?(o=Fs,Bv(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,p.stateNode),_0(o)):Bv(Fs,p.stateNode));break;case 4:N=Fs,I=Yi,Fs=p.stateNode.containerInfo,Yi=!0,Kl(o,d,p),Fs=N,Yi=I;break;case 0:case 11:case 14:case 15:Ec(2,p,d),wn||Ec(4,p,d),Kl(o,d,p);break;case 1:wn||(Nl(p,d),N=p.stateNode,typeof N.componentWillUnmount=="function"&&U2(p,d,N)),Kl(o,d,p);break;case 21:Kl(o,d,p);break;case 22:wn=(N=wn)||p.memoizedState!==null,Kl(o,d,p),wn=N;break;default:Kl(o,d,p)}}function q2(o,d){if(d.memoizedState===null&&(o=d.alternate,o!==null&&(o=o.memoizedState,o!==null))){o=o.dehydrated;try{_0(o)}catch(p){ns(d,d.return,p)}}}function X2(o,d){if(d.memoizedState===null&&(o=d.alternate,o!==null&&(o=o.memoizedState,o!==null&&(o=o.dehydrated,o!==null))))try{_0(o)}catch(p){ns(d,d.return,p)}}function eC(o){switch(o.tag){case 31:case 13:case 19:var d=o.stateNode;return d===null&&(d=o.stateNode=new $2),d;case 22:return o=o.stateNode,d=o._retryCache,d===null&&(d=o._retryCache=new $2),d;default:throw Error(s(435,o.tag))}}function Th(o,d){var p=eC(o);d.forEach(function(N){if(!p.has(N)){p.add(N);var I=cC.bind(null,o,N);N.then(I,I)}})}function qi(o,d){var p=d.deletions;if(p!==null)for(var N=0;N<p.length;N++){var I=p[N],U=o,xe=d,Ie=xe;e:for(;Ie!==null;){switch(Ie.tag){case 27:if(Ic(Ie.type)){Fs=Ie.stateNode,Yi=!1;break e}break;case 5:Fs=Ie.stateNode,Yi=!1;break e;case 3:case 4:Fs=Ie.stateNode.containerInfo,Yi=!0;break e}Ie=Ie.return}if(Fs===null)throw Error(s(160));Y2(U,xe,I),Fs=null,Yi=!1,U=I.alternate,U!==null&&(U.return=null),I.return=null}if(d.subtreeFlags&13886)for(d=d.child;d!==null;)Z2(d,o),d=d.sibling}var rl=null;function Z2(o,d){var p=o.alternate,N=o.flags;switch(o.tag){case 0:case 11:case 14:case 15:qi(d,o),Xi(o),N&4&&(Ec(3,o,o.return),Tu(3,o),Ec(5,o,o.return));break;case 1:qi(d,o),Xi(o),N&512&&(wn||p===null||Nl(p,p.return)),N&64&&Zl&&(o=o.updateQueue,o!==null&&(N=o.callbacks,N!==null&&(p=o.shared.hiddenCallbacks,o.shared.hiddenCallbacks=p===null?N:p.concat(N))));break;case 26:var I=rl;if(qi(d,o),Xi(o),N&512&&(wn||p===null||Nl(p,p.return)),N&4){var U=p!==null?p.memoizedState:null;if(N=o.memoizedState,p===null)if(N===null)if(o.stateNode===null){e:{N=o.type,p=o.memoizedProps,I=I.ownerDocument||I;t:switch(N){case"title":U=I.getElementsByTagName("title")[0],(!U||U[$e]||U[ne]||U.namespaceURI==="http://www.w3.org/2000/svg"||U.hasAttribute("itemprop"))&&(U=I.createElement(N),I.head.insertBefore(U,I.querySelector("head > title"))),di(U,N,p),U[ne]=o,br(U),N=U;break e;case"link":var xe=Zv("link","href",I).get(N+(p.href||""));if(xe){for(var Ie=0;Ie<xe.length;Ie++)if(U=xe[Ie],U.getAttribute("href")===(p.href==null||p.href===""?null:p.href)&&U.getAttribute("rel")===(p.rel==null?null:p.rel)&&U.getAttribute("title")===(p.title==null?null:p.title)&&U.getAttribute("crossorigin")===(p.crossOrigin==null?null:p.crossOrigin)){xe.splice(Ie,1);break t}}U=I.createElement(N),di(U,N,p),I.head.appendChild(U);break;case"meta":if(xe=Zv("meta","content",I).get(N+(p.content||""))){for(Ie=0;Ie<xe.length;Ie++)if(U=xe[Ie],U.getAttribute("content")===(p.content==null?null:""+p.content)&&U.getAttribute("name")===(p.name==null?null:p.name)&&U.getAttribute("property")===(p.property==null?null:p.property)&&U.getAttribute("http-equiv")===(p.httpEquiv==null?null:p.httpEquiv)&&U.getAttribute("charset")===(p.charSet==null?null:p.charSet)){xe.splice(Ie,1);break t}}U=I.createElement(N),di(U,N,p),I.head.appendChild(U);break;default:throw Error(s(468,N))}U[ne]=o,br(U),N=U}o.stateNode=N}else Kv(I,o.type,o.stateNode);else o.stateNode=Xv(I,N,o.memoizedProps);else U!==N?(U===null?p.stateNode!==null&&(p=p.stateNode,p.parentNode.removeChild(p)):U.count--,N===null?Kv(I,o.type,o.stateNode):Xv(I,N,o.memoizedProps)):N===null&&o.stateNode!==null&&Ox(o,o.memoizedProps,p.memoizedProps)}break;case 27:qi(d,o),Xi(o),N&512&&(wn||p===null||Nl(p,p.return)),p!==null&&N&4&&Ox(o,o.memoizedProps,p.memoizedProps);break;case 5:if(qi(d,o),Xi(o),N&512&&(wn||p===null||Nl(p,p.return)),o.flags&32){I=o.stateNode;try{Va(I,"")}catch(Mr){ns(o,o.return,Mr)}}N&4&&o.stateNode!=null&&(I=o.memoizedProps,Ox(o,I,p!==null?p.memoizedProps:I)),N&1024&&(Fx=!0);break;case 6:if(qi(d,o),Xi(o),N&4){if(o.stateNode===null)throw Error(s(162));N=o.memoizedProps,p=o.stateNode;try{p.nodeValue=N}catch(Mr){ns(o,o.return,Mr)}}break;case 3:if(Vh=null,I=rl,rl=Hh(d.containerInfo),qi(d,o),rl=I,Xi(o),N&4&&p!==null&&p.memoizedState.isDehydrated)try{_0(d.containerInfo)}catch(Mr){ns(o,o.return,Mr)}Fx&&(Fx=!1,K2(o));break;case 4:N=rl,rl=Hh(o.stateNode.containerInfo),qi(d,o),Xi(o),rl=N;break;case 12:qi(d,o),Xi(o);break;case 31:qi(d,o),Xi(o),N&4&&(N=o.updateQueue,N!==null&&(o.updateQueue=null,Th(o,N)));break;case 13:qi(d,o),Xi(o),o.child.flags&8192&&o.memoizedState!==null!=(p!==null&&p.memoizedState!==null)&&(Oh=Dt()),N&4&&(N=o.updateQueue,N!==null&&(o.updateQueue=null,Th(o,N)));break;case 22:I=o.memoizedState!==null;var lt=p!==null&&p.memoizedState!==null,Ut=Zl,nr=wn;if(Zl=Ut||I,wn=nr||lt,qi(d,o),wn=nr,Zl=Ut,Xi(o),N&8192)e:for(d=o.stateNode,d._visibility=I?d._visibility&-2:d._visibility|1,I&&(p===null||lt||Zl||wn||md(o)),p=null,d=o;;){if(d.tag===5||d.tag===26){if(p===null){lt=p=d;try{if(U=lt.stateNode,I)xe=U.style,typeof xe.setProperty=="function"?xe.setProperty("display","none","important"):xe.display="none";else{Ie=lt.stateNode;var dr=lt.memoizedProps.style,Vt=dr!=null&&dr.hasOwnProperty("display")?dr.display:null;Ie.style.display=Vt==null||typeof Vt=="boolean"?"":(""+Vt).trim()}}catch(Mr){ns(lt,lt.return,Mr)}}}else if(d.tag===6){if(p===null){lt=d;try{lt.stateNode.nodeValue=I?"":lt.memoizedProps}catch(Mr){ns(lt,lt.return,Mr)}}}else if(d.tag===18){if(p===null){lt=d;try{var er=lt.stateNode;I?Uv(er,!0):Uv(lt.stateNode,!1)}catch(Mr){ns(lt,lt.return,Mr)}}}else if((d.tag!==22&&d.tag!==23||d.memoizedState===null||d===o)&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===o)break e;for(;d.sibling===null;){if(d.return===null||d.return===o)break e;p===d&&(p=null),d=d.return}p===d&&(p=null),d.sibling.return=d.return,d=d.sibling}N&4&&(N=o.updateQueue,N!==null&&(p=N.retryQueue,p!==null&&(N.retryQueue=null,Th(o,p))));break;case 19:qi(d,o),Xi(o),N&4&&(N=o.updateQueue,N!==null&&(o.updateQueue=null,Th(o,N)));break;case 30:break;case 21:break;default:qi(d,o),Xi(o)}}function Xi(o){var d=o.flags;if(d&2){try{for(var p,N=o.return;N!==null;){if(W2(N)){p=N;break}N=N.return}if(p==null)throw Error(s(160));switch(p.tag){case 27:var I=p.stateNode,U=Dx(o);Eh(o,U,I);break;case 5:var xe=p.stateNode;p.flags&32&&(Va(xe,""),p.flags&=-33);var Ie=Dx(o);Eh(o,Ie,xe);break;case 3:case 4:var lt=p.stateNode.containerInfo,Ut=Dx(o);Rx(o,Ut,lt);break;default:throw Error(s(161))}}catch(nr){ns(o,o.return,nr)}o.flags&=-3}d&4096&&(o.flags&=-4097)}function K2(o){if(o.subtreeFlags&1024)for(o=o.child;o!==null;){var d=o;K2(d),d.tag===5&&d.flags&1024&&d.stateNode.reset(),o=o.sibling}}function Jl(o,d){if(d.subtreeFlags&8772)for(d=d.child;d!==null;)V2(o,d.alternate,d),d=d.sibling}function md(o){for(o=o.child;o!==null;){var d=o;switch(d.tag){case 0:case 11:case 14:case 15:Ec(4,d,d.return),md(d);break;case 1:Nl(d,d.return);var p=d.stateNode;typeof p.componentWillUnmount=="function"&&U2(d,d.return,p),md(d);break;case 27:Bu(d.stateNode);case 26:case 5:Nl(d,d.return),md(d);break;case 22:d.memoizedState===null&&md(d);break;case 30:md(d);break;default:md(d)}o=o.sibling}}function Ql(o,d,p){for(p=p&&(d.subtreeFlags&8772)!==0,d=d.child;d!==null;){var N=d.alternate,I=o,U=d,xe=U.flags;switch(U.tag){case 0:case 11:case 15:Ql(I,U,p),Tu(4,U);break;case 1:if(Ql(I,U,p),N=U,I=N.stateNode,typeof I.componentDidMount=="function")try{I.componentDidMount()}catch(Ut){ns(N,N.return,Ut)}if(N=U,I=N.updateQueue,I!==null){var Ie=N.stateNode;try{var lt=I.shared.hiddenCallbacks;if(lt!==null)for(I.shared.hiddenCallbacks=null,I=0;I<lt.length;I++)Eb(lt[I],Ie)}catch(Ut){ns(N,N.return,Ut)}}p&&xe&64&&B2(U),Au(U,U.return);break;case 27:H2(U);case 26:case 5:Ql(I,U,p),p&&N===null&&xe&4&&z2(U),Au(U,U.return);break;case 12:Ql(I,U,p);break;case 31:Ql(I,U,p),p&&xe&4&&q2(I,U);break;case 13:Ql(I,U,p),p&&xe&4&&X2(I,U);break;case 22:U.memoizedState===null&&Ql(I,U,p),Au(U,U.return);break;case 30:break;default:Ql(I,U,p)}d=d.sibling}}function Ix(o,d){var p=null;o!==null&&o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(p=o.memoizedState.cachePool.pool),o=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(o=d.memoizedState.cachePool.pool),o!==p&&(o!=null&&o.refCount++,p!=null&&xu(p))}function Mx(o,d){o=null,d.alternate!==null&&(o=d.alternate.memoizedState.cache),d=d.memoizedState.cache,d!==o&&(d.refCount++,o!=null&&xu(o))}function al(o,d,p,N){if(d.subtreeFlags&10256)for(d=d.child;d!==null;)J2(o,d,p,N),d=d.sibling}function J2(o,d,p,N){var I=d.flags;switch(d.tag){case 0:case 11:case 15:al(o,d,p,N),I&2048&&Tu(9,d);break;case 1:al(o,d,p,N);break;case 3:al(o,d,p,N),I&2048&&(o=null,d.alternate!==null&&(o=d.alternate.memoizedState.cache),d=d.memoizedState.cache,d!==o&&(d.refCount++,o!=null&&xu(o)));break;case 12:if(I&2048){al(o,d,p,N),o=d.stateNode;try{var U=d.memoizedProps,xe=U.id,Ie=U.onPostCommit;typeof Ie=="function"&&Ie(xe,d.alternate===null?"mount":"update",o.passiveEffectDuration,-0)}catch(lt){ns(d,d.return,lt)}}else al(o,d,p,N);break;case 31:al(o,d,p,N);break;case 13:al(o,d,p,N);break;case 23:break;case 22:U=d.stateNode,xe=d.alternate,d.memoizedState!==null?U._visibility&2?al(o,d,p,N):Ou(o,d):U._visibility&2?al(o,d,p,N):(U._visibility|=2,u0(o,d,p,N,(d.subtreeFlags&10256)!==0||!1)),I&2048&&Ix(xe,d);break;case 24:al(o,d,p,N),I&2048&&Mx(d.alternate,d);break;default:al(o,d,p,N)}}function u0(o,d,p,N,I){for(I=I&&((d.subtreeFlags&10256)!==0||!1),d=d.child;d!==null;){var U=o,xe=d,Ie=p,lt=N,Ut=xe.flags;switch(xe.tag){case 0:case 11:case 15:u0(U,xe,Ie,lt,I),Tu(8,xe);break;case 23:break;case 22:var nr=xe.stateNode;xe.memoizedState!==null?nr._visibility&2?u0(U,xe,Ie,lt,I):Ou(U,xe):(nr._visibility|=2,u0(U,xe,Ie,lt,I)),I&&Ut&2048&&Ix(xe.alternate,xe);break;case 24:u0(U,xe,Ie,lt,I),I&&Ut&2048&&Mx(xe.alternate,xe);break;default:u0(U,xe,Ie,lt,I)}d=d.sibling}}function Ou(o,d){if(d.subtreeFlags&10256)for(d=d.child;d!==null;){var p=o,N=d,I=N.flags;switch(N.tag){case 22:Ou(p,N),I&2048&&Ix(N.alternate,N);break;case 24:Ou(p,N),I&2048&&Mx(N.alternate,N);break;default:Ou(p,N)}d=d.sibling}}var Du=8192;function f0(o,d,p){if(o.subtreeFlags&Du)for(o=o.child;o!==null;)Q2(o,d,p),o=o.sibling}function Q2(o,d,p){switch(o.tag){case 26:f0(o,d,p),o.flags&Du&&o.memoizedState!==null&&UC(p,rl,o.memoizedState,o.memoizedProps);break;case 5:f0(o,d,p);break;case 3:case 4:var N=rl;rl=Hh(o.stateNode.containerInfo),f0(o,d,p),rl=N;break;case 22:o.memoizedState===null&&(N=o.alternate,N!==null&&N.memoizedState!==null?(N=Du,Du=16777216,f0(o,d,p),Du=N):f0(o,d,p));break;default:f0(o,d,p)}}function ev(o){var d=o.alternate;if(d!==null&&(o=d.child,o!==null)){d.child=null;do d=o.sibling,o.sibling=null,o=d;while(o!==null)}}function Ru(o){var d=o.deletions;if((o.flags&16)!==0){if(d!==null)for(var p=0;p<d.length;p++){var N=d[p];Vn=N,rv(N,o)}ev(o)}if(o.subtreeFlags&10256)for(o=o.child;o!==null;)tv(o),o=o.sibling}function tv(o){switch(o.tag){case 0:case 11:case 15:Ru(o),o.flags&2048&&Ec(9,o,o.return);break;case 3:Ru(o);break;case 12:Ru(o);break;case 22:var d=o.stateNode;o.memoizedState!==null&&d._visibility&2&&(o.return===null||o.return.tag!==13)?(d._visibility&=-3,Ah(o)):Ru(o);break;default:Ru(o)}}function Ah(o){var d=o.deletions;if((o.flags&16)!==0){if(d!==null)for(var p=0;p<d.length;p++){var N=d[p];Vn=N,rv(N,o)}ev(o)}for(o=o.child;o!==null;){switch(d=o,d.tag){case 0:case 11:case 15:Ec(8,d,d.return),Ah(d);break;case 22:p=d.stateNode,p._visibility&2&&(p._visibility&=-3,Ah(d));break;default:Ah(d)}o=o.sibling}}function rv(o,d){for(;Vn!==null;){var p=Vn;switch(p.tag){case 0:case 11:case 15:Ec(8,p,d);break;case 23:case 22:if(p.memoizedState!==null&&p.memoizedState.cachePool!==null){var N=p.memoizedState.cachePool.pool;N!=null&&N.refCount++}break;case 24:xu(p.memoizedState.cache)}if(N=p.child,N!==null)N.return=p,Vn=N;else e:for(p=o;Vn!==null;){N=Vn;var I=N.sibling,U=N.return;if(G2(N),N===p){Vn=null;break e}if(I!==null){I.return=U,Vn=I;break e}Vn=U}}}var tC={getCacheForType:function(o){var d=li(yn),p=d.data.get(o);return p===void 0&&(p=o(),d.data.set(o,p)),p},cacheSignal:function(){return li(yn).controller.signal}},rC=typeof WeakMap=="function"?WeakMap:Map,Ka=0,xs=null,Ra=null,Ia=0,ss=0,ho=null,Tc=!1,h0=!1,Px=!1,ec=0,Ys=0,Ac=0,gd=0,Lx=0,mo=0,m0=0,Fu=null,Zi=null,Bx=!1,Oh=0,av=0,Dh=1/0,Rh=null,Oc=null,Rn=0,Dc=null,g0=null,tc=0,Ux=0,zx=null,sv=null,Iu=0,Wx=null;function go(){return(Ka&2)!==0&&Ia!==0?Ia&-Ia:we.T!==null?qx():Q()}function nv(){if(mo===0)if((Ia&536870912)===0||Da){var o=rr;rr<<=1,(rr&3932160)===0&&(rr=262144),mo=o}else mo=536870912;return o=uo.current,o!==null&&(o.flags|=32),mo}function Ki(o,d,p){(o===xs&&(ss===2||ss===9)||o.cancelPendingCommit!==null)&&(x0(o,0),Rc(o,Ia,mo,!1)),Fe(o,p),((Ka&2)===0||o!==xs)&&(o===xs&&((Ka&2)===0&&(gd|=p),Ys===4&&Rc(o,Ia,mo,!1)),jl(o))}function iv(o,d,p){if((Ka&6)!==0)throw Error(s(327));var N=!p&&(d&127)===0&&(d&o.expiredLanes)===0||yr(o,d),I=N?nC(o,d):$x(o,d,!0),U=N;do{if(I===0){h0&&!N&&Rc(o,d,0,!1);break}else{if(p=o.current.alternate,U&&!aC(p)){I=$x(o,d,!1),U=!1;continue}if(I===2){if(U=d,o.errorRecoveryDisabledLanes&U)var xe=0;else xe=o.pendingLanes&-536870913,xe=xe!==0?xe:xe&536870912?536870912:0;if(xe!==0){d=xe;e:{var Ie=o;I=Fu;var lt=Ie.current.memoizedState.isDehydrated;if(lt&&(x0(Ie,xe).flags|=256),xe=$x(Ie,xe,!1),xe!==2){if(Px&&!lt){Ie.errorRecoveryDisabledLanes|=U,gd|=U,I=4;break e}U=Zi,Zi=I,U!==null&&(Zi===null?Zi=U:Zi.push.apply(Zi,U))}I=xe}if(U=!1,I!==2)continue}}if(I===1){x0(o,0),Rc(o,d,0,!0);break}e:{switch(N=o,U=I,U){case 0:case 1:throw Error(s(345));case 4:if((d&4194048)!==d)break;case 6:Rc(N,d,mo,!Tc);break e;case 2:Zi=null;break;case 3:case 5:break;default:throw Error(s(329))}if((d&62914560)===d&&(I=Oh+300-Dt(),10<I)){if(Rc(N,d,mo,!Tc),Cr(N,0,!0)!==0)break e;tc=d,N.timeoutHandle=Pv(ov.bind(null,N,p,Zi,Rh,Bx,d,mo,gd,m0,Tc,U,"Throttled",-0,0),I);break e}ov(N,p,Zi,Rh,Bx,d,mo,gd,m0,Tc,U,null,-0,0)}}break}while(!0);jl(o)}function ov(o,d,p,N,I,U,xe,Ie,lt,Ut,nr,dr,Vt,er){if(o.timeoutHandle=-1,dr=d.subtreeFlags,dr&8192||(dr&16785408)===16785408){dr={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Ts},Q2(d,U,dr);var Mr=(U&62914560)===U?Oh-Dt():(U&4194048)===U?av-Dt():0;if(Mr=zC(dr,Mr),Mr!==null){tc=U,o.cancelPendingCommit=Mr(gv.bind(null,o,d,U,p,N,I,xe,Ie,lt,nr,dr,null,Vt,er)),Rc(o,U,xe,!Ut);return}}gv(o,d,U,p,N,I,xe,Ie,lt)}function aC(o){for(var d=o;;){var p=d.tag;if((p===0||p===11||p===15)&&d.flags&16384&&(p=d.updateQueue,p!==null&&(p=p.stores,p!==null)))for(var N=0;N<p.length;N++){var I=p[N],U=I.getSnapshot;I=I.value;try{if(!j(U(),I))return!1}catch(xe){return!1}}if(p=d.child,d.subtreeFlags&16384&&p!==null)p.return=d,d=p;else{if(d===o)break;for(;d.sibling===null;){if(d.return===null||d.return===o)return!0;d=d.return}d.sibling.return=d.return,d=d.sibling}}return!0}function Rc(o,d,p,N){d&=~Lx,d&=~gd,o.suspendedLanes|=d,o.pingedLanes&=~d,N&&(o.warmLanes|=d),N=o.expirationTimes;for(var I=d;0<I;){var U=31-nt(I),xe=1<<U;N[U]=-1,I&=~xe}p!==0&&vt(o,p,d)}function Fh(){return(Ka&6)===0?(Mu(0),!1):!0}function Hx(){if(Ra!==null){if(ss===0)var o=Ra.return;else o=Ra,tl=kl=null,nx(o),i0=null,yu=0,o=Ra;for(;o!==null;)L2(o.alternate,o),o=o.return;Ra=null}}function x0(o,d){var p=o.timeoutHandle;p!==-1&&(o.timeoutHandle=-1,kC(p)),p=o.cancelPendingCommit,p!==null&&(o.cancelPendingCommit=null,p()),tc=0,Hx(),xs=o,Ra=p=Do(o.current,null),Ia=d,ss=0,ho=null,Tc=!1,h0=yr(o,d),Px=!1,m0=mo=Lx=gd=Ac=Ys=0,Zi=Fu=null,Bx=!1,(d&8)!==0&&(d|=d&32);var N=o.entangledLanes;if(N!==0)for(o=o.entanglements,N&=d;0<N;){var I=31-nt(N),U=1<<I;d|=o[I],N&=~U}return ec=d,bl(),p}function lv(o,d){pa=null,we.H=Su,d===n0||d===ch?(d=Nb(),ss=3):d===Yg?(d=Nb(),ss=4):ss=d===wx?8:d!==null&&typeof d=="object"&&typeof d.then=="function"?6:1,ho=d,Ra===null&&(Ys=1,kh(o,k(d,o.current)))}function cv(){var o=uo.current;return o===null?!0:(Ia&4194048)===Ia?Ro===null:(Ia&62914560)===Ia||(Ia&536870912)!==0?o===Ro:!1}function dv(){var o=we.H;return we.H=Su,o===null?Su:o}function uv(){var o=we.A;return we.A=tC,o}function Ih(){Ys=4,Tc||(Ia&4194048)!==Ia&&uo.current!==null||(h0=!0),(Ac&134217727)===0&&(gd&134217727)===0||xs===null||Rc(xs,Ia,mo,!1)}function $x(o,d,p){var N=Ka;Ka|=2;var I=dv(),U=uv();(xs!==o||Ia!==d)&&(Rh=null,x0(o,d)),d=!1;var xe=Ys;e:do try{if(ss!==0&&Ra!==null){var Ie=Ra,lt=ho;switch(ss){case 8:Hx(),xe=6;break e;case 3:case 2:case 9:case 6:uo.current===null&&(d=!0);var Ut=ss;if(ss=0,ho=null,p0(o,Ie,lt,Ut),p&&h0){xe=0;break e}break;default:Ut=ss,ss=0,ho=null,p0(o,Ie,lt,Ut)}}sC(),xe=Ys;break}catch(nr){lv(o,nr)}while(!0);return d&&o.shellSuspendCounter++,tl=kl=null,Ka=N,we.H=I,we.A=U,Ra===null&&(xs=null,Ia=0,bl()),xe}function sC(){for(;Ra!==null;)fv(Ra)}function nC(o,d){var p=Ka;Ka|=2;var N=dv(),I=uv();xs!==o||Ia!==d?(Rh=null,Dh=Dt()+500,x0(o,d)):h0=yr(o,d);e:do try{if(ss!==0&&Ra!==null){d=Ra;var U=ho;t:switch(ss){case 1:ss=0,ho=null,p0(o,d,U,1);break;case 2:case 9:if(_b(U)){ss=0,ho=null,hv(d);break}d=function(){ss!==2&&ss!==9||xs!==o||(ss=7),jl(o)},U.then(d,d);break e;case 3:ss=7;break e;case 4:ss=5;break e;case 7:_b(U)?(ss=0,ho=null,hv(d)):(ss=0,ho=null,p0(o,d,U,7));break;case 5:var xe=null;switch(Ra.tag){case 26:xe=Ra.memoizedState;case 5:case 27:var Ie=Ra;if(xe?Jv(xe):Ie.stateNode.complete){ss=0,ho=null;var lt=Ie.sibling;if(lt!==null)Ra=lt;else{var Ut=Ie.return;Ut!==null?(Ra=Ut,Mh(Ut)):Ra=null}break t}}ss=0,ho=null,p0(o,d,U,5);break;case 6:ss=0,ho=null,p0(o,d,U,6);break;case 8:Hx(),Ys=6;break e;default:throw Error(s(462))}}iC();break}catch(nr){lv(o,nr)}while(!0);return tl=kl=null,we.H=N,we.A=I,Ka=p,Ra!==null?0:(xs=null,Ia=0,bl(),Ys)}function iC(){for(;Ra!==null&&!Rt();)fv(Ra)}function fv(o){var d=M2(o.alternate,o,ec);o.memoizedProps=o.pendingProps,d===null?Mh(o):Ra=d}function hv(o){var d=o,p=d.alternate;switch(d.tag){case 15:case 0:d=A2(p,d,d.pendingProps,d.type,void 0,Ia);break;case 11:d=A2(p,d,d.pendingProps,d.type.render,d.ref,Ia);break;case 5:nx(d);default:L2(p,d),d=Ra=uu(d,ec),d=M2(p,d,ec)}o.memoizedProps=o.pendingProps,d===null?Mh(o):Ra=d}function p0(o,d,p,N){tl=kl=null,nx(d),i0=null,yu=0;var I=d.return;try{if(qS(o,I,d,p,Ia)){Ys=1,kh(o,k(p,o.current)),Ra=null;return}}catch(U){if(I!==null)throw Ra=I,U;Ys=1,kh(o,k(p,o.current)),Ra=null;return}d.flags&32768?(Da||N===1?o=!0:h0||(Ia&536870912)!==0?o=!1:(Tc=o=!0,(N===2||N===9||N===3||N===6)&&(N=uo.current,N!==null&&N.tag===13&&(N.flags|=16384))),mv(d,o)):Mh(d)}function Mh(o){var d=o;do{if((d.flags&32768)!==0){mv(d,Tc);return}o=d.return;var p=KS(d.alternate,d,ec);if(p!==null){Ra=p;return}if(d=d.sibling,d!==null){Ra=d;return}Ra=d=o}while(d!==null);Ys===0&&(Ys=5)}function mv(o,d){do{var p=JS(o.alternate,o);if(p!==null){p.flags&=32767,Ra=p;return}if(p=o.return,p!==null&&(p.flags|=32768,p.subtreeFlags=0,p.deletions=null),!d&&(o=o.sibling,o!==null)){Ra=o;return}Ra=o=p}while(o!==null);Ys=6,Ra=null}function gv(o,d,p,N,I,U,xe,Ie,lt){o.cancelPendingCommit=null;do Ph();while(Rn!==0);if((Ka&6)!==0)throw Error(s(327));if(d!==null){if(d===o.current)throw Error(s(177));if(U=d.lanes|d.childLanes,U|=$n,Ze(o,p,U,xe,Ie,lt),o===xs&&(Ra=xs=null,Ia=0),g0=d,Dc=o,tc=p,Ux=U,zx=I,sv=N,(d.subtreeFlags&10256)!==0||(d.flags&10256)!==0?(o.callbackNode=null,o.callbackPriority=0,dC(Ot,function(){return vv(),null})):(o.callbackNode=null,o.callbackPriority=0),N=(d.flags&13878)!==0,(d.subtreeFlags&13878)!==0||N){N=we.T,we.T=null,I=ee.p,ee.p=2,xe=Ka,Ka|=4;try{QS(o,d,p)}finally{Ka=xe,ee.p=I,we.T=N}}Rn=1,xv(),pv(),yv()}}function xv(){if(Rn===1){Rn=0;var o=Dc,d=g0,p=(d.flags&13878)!==0;if((d.subtreeFlags&13878)!==0||p){p=we.T,we.T=null;var N=ee.p;ee.p=2;var I=Ka;Ka|=4;try{Z2(d,o);var U=rp,xe=je(o.containerInfo),Ie=U.focusedElem,lt=U.selectionRange;if(xe!==Ie&&Ie&&Ie.ownerDocument&&de(Ie.ownerDocument.documentElement,Ie)){if(lt!==null&&Ae(Ie)){var Ut=lt.start,nr=lt.end;if(nr===void 0&&(nr=Ut),"selectionStart"in Ie)Ie.selectionStart=Ut,Ie.selectionEnd=Math.min(nr,Ie.value.length);else{var dr=Ie.ownerDocument||document,Vt=dr&&dr.defaultView||window;if(Vt.getSelection){var er=Vt.getSelection(),Mr=Ie.textContent.length,ta=Math.min(lt.start,Mr),hs=lt.end===void 0?ta:Math.min(lt.end,Mr);!er.extend&&ta>hs&&(xe=hs,hs=ta,ta=xe);var Ct=H(Ie,ta),pt=H(Ie,hs);if(Ct&&pt&&(er.rangeCount!==1||er.anchorNode!==Ct.node||er.anchorOffset!==Ct.offset||er.focusNode!==pt.node||er.focusOffset!==pt.offset)){var Bt=dr.createRange();Bt.setStart(Ct.node,Ct.offset),er.removeAllRanges(),ta>hs?(er.addRange(Bt),er.extend(pt.node,pt.offset)):(Bt.setEnd(pt.node,pt.offset),er.addRange(Bt))}}}}for(dr=[],er=Ie;er=er.parentNode;)er.nodeType===1&&dr.push({element:er,left:er.scrollLeft,top:er.scrollTop});for(typeof Ie.focus=="function"&&Ie.focus(),Ie=0;Ie<dr.length;Ie++){var or=dr[Ie];or.element.scrollLeft=or.left,or.element.scrollTop=or.top}}Xh=!!tp,rp=tp=null}finally{Ka=I,ee.p=N,we.T=p}}o.current=d,Rn=2}}function pv(){if(Rn===2){Rn=0;var o=Dc,d=g0,p=(d.flags&8772)!==0;if((d.subtreeFlags&8772)!==0||p){p=we.T,we.T=null;var N=ee.p;ee.p=2;var I=Ka;Ka|=4;try{V2(o,d.alternate,d)}finally{Ka=I,ee.p=N,we.T=p}}Rn=3}}function yv(){if(Rn===4||Rn===3){Rn=0,qe();var o=Dc,d=g0,p=tc,N=sv;(d.subtreeFlags&10256)!==0||(d.flags&10256)!==0?Rn=5:(Rn=0,g0=Dc=null,bv(o,o.pendingLanes));var I=o.pendingLanes;if(I===0&&(Oc=null),Re(p),d=d.stateNode,kt&&typeof kt.onCommitFiberRoot=="function")try{kt.onCommitFiberRoot(qt,d,void 0,(d.current.flags&128)===128)}catch(lt){}if(N!==null){d=we.T,I=ee.p,ee.p=2,we.T=null;try{for(var U=o.onRecoverableError,xe=0;xe<N.length;xe++){var Ie=N[xe];U(Ie.value,{componentStack:Ie.stack})}}finally{we.T=d,ee.p=I}}(tc&3)!==0&&Ph(),jl(o),I=o.pendingLanes,(p&261930)!==0&&(I&42)!==0?o===Wx?Iu++:(Iu=0,Wx=o):Iu=0,Mu(0)}}function bv(o,d){(o.pooledCacheLanes&=d)===0&&(d=o.pooledCache,d!=null&&(o.pooledCache=null,xu(d)))}function Ph(){return xv(),pv(),yv(),vv()}function vv(){if(Rn!==5)return!1;var o=Dc,d=Ux;Ux=0;var p=Re(tc),N=we.T,I=ee.p;try{ee.p=32>p?32:p,we.T=null,p=zx,zx=null;var U=Dc,xe=tc;if(Rn=0,g0=Dc=null,tc=0,(Ka&6)!==0)throw Error(s(331));var Ie=Ka;if(Ka|=4,tv(U.current),J2(U,U.current,xe,p),Ka=Ie,Mu(0,!1),kt&&typeof kt.onPostCommitFiberRoot=="function")try{kt.onPostCommitFiberRoot(qt,U)}catch(lt){}return!0}finally{ee.p=I,we.T=N,bv(o,d)}}function wv(o,d,p){d=k(p,d),d=vx(o.stateNode,d,2),o=jc(o,d,2),o!==null&&(Fe(o,2),jl(o))}function ns(o,d,p){if(o.tag===3)wv(o,o,p);else for(;d!==null;){if(d.tag===3){wv(d,o,p);break}else if(d.tag===1){var N=d.stateNode;if(typeof d.type.getDerivedStateFromError=="function"||typeof N.componentDidCatch=="function"&&(Oc===null||!Oc.has(N))){o=k(p,o),p=_2(2),N=jc(d,p,2),N!==null&&(k2(p,N,d,o),Fe(N,2),jl(N));break}}d=d.return}}function Vx(o,d,p){var N=o.pingCache;if(N===null){N=o.pingCache=new rC;var I=new Set;N.set(d,I)}else I=N.get(d),I===void 0&&(I=new Set,N.set(d,I));I.has(p)||(Px=!0,I.add(p),o=oC.bind(null,o,d,p),d.then(o,o))}function oC(o,d,p){var N=o.pingCache;N!==null&&N.delete(d),o.pingedLanes|=o.suspendedLanes&p,o.warmLanes&=~p,xs===o&&(Ia&p)===p&&(Ys===4||Ys===3&&(Ia&62914560)===Ia&&300>Dt()-Oh?(Ka&2)===0&&x0(o,0):Lx|=p,m0===Ia&&(m0=0)),jl(o)}function _v(o,d){d===0&&(d=Tt()),o=Oo(o,d),o!==null&&(Fe(o,d),jl(o))}function lC(o){var d=o.memoizedState,p=0;d!==null&&(p=d.retryLane),_v(o,p)}function cC(o,d){var p=0;switch(o.tag){case 31:case 13:var N=o.stateNode,I=o.memoizedState;I!==null&&(p=I.retryLane);break;case 19:N=o.stateNode;break;case 22:N=o.stateNode._retryCache;break;default:throw Error(s(314))}N!==null&&N.delete(d),_v(o,p)}function dC(o,d){return Ve(o,d)}var Lh=null,y0=null,Gx=!1,Bh=!1,Yx=!1,Fc=0;function jl(o){o!==y0&&o.next===null&&(y0===null?Lh=y0=o:y0=y0.next=o),Bh=!0,Gx||(Gx=!0,fC())}function Mu(o,d){if(!Yx&&Bh){Yx=!0;do for(var p=!1,N=Lh;N!==null;){if(o!==0){var I=N.pendingLanes;if(I===0)var U=0;else{var xe=N.suspendedLanes,Ie=N.pingedLanes;U=(1<<31-nt(42|o)+1)-1,U&=I&~(xe&~Ie),U=U&201326741?U&201326741|1:U?U|2:0}U!==0&&(p=!0,Sv(N,U))}else U=Ia,U=Cr(N,N===xs?U:0,N.cancelPendingCommit!==null||N.timeoutHandle!==-1),(U&3)===0||yr(N,U)||(p=!0,Sv(N,U));N=N.next}while(p);Yx=!1}}function uC(){kv()}function kv(){Bh=Gx=!1;var o=0;Fc!==0&&_C()&&(o=Fc);for(var d=Dt(),p=null,N=Lh;N!==null;){var I=N.next,U=Nv(N,d);U===0?(N.next=null,p===null?Lh=I:p.next=I,I===null&&(y0=p)):(p=N,(o!==0||(U&3)!==0)&&(Bh=!0)),N=I}Rn!==0&&Rn!==5||Mu(o),Fc!==0&&(Fc=0)}function Nv(o,d){for(var p=o.suspendedLanes,N=o.pingedLanes,I=o.expirationTimes,U=o.pendingLanes&-62914561;0<U;){var xe=31-nt(U),Ie=1<<xe,lt=I[xe];lt===-1?((Ie&p)===0||(Ie&N)!==0)&&(I[xe]=jt(Ie,d)):lt<=d&&(o.expiredLanes|=Ie),U&=~Ie}if(d=xs,p=Ia,p=Cr(o,o===d?p:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),N=o.callbackNode,p===0||o===d&&(ss===2||ss===9)||o.cancelPendingCommit!==null)return N!==null&&N!==null&&Xe(N),o.callbackNode=null,o.callbackPriority=0;if((p&3)===0||yr(o,p)){if(d=p&-p,d===o.callbackPriority)return d;switch(N!==null&&Xe(N),Re(p)){case 2:case 8:p=St;break;case 32:p=Ot;break;case 268435456:p=Ye;break;default:p=Ot}return N=jv.bind(null,o),p=Ve(p,N),o.callbackPriority=d,o.callbackNode=p,d}return N!==null&&N!==null&&Xe(N),o.callbackPriority=2,o.callbackNode=null,2}function jv(o,d){if(Rn!==0&&Rn!==5)return o.callbackNode=null,o.callbackPriority=0,null;var p=o.callbackNode;if(Ph()&&o.callbackNode!==p)return null;var N=Ia;return N=Cr(o,o===xs?N:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),N===0?null:(iv(o,N,d),Nv(o,Dt()),o.callbackNode!=null&&o.callbackNode===p?jv.bind(null,o):null)}function Sv(o,d){if(Ph())return null;iv(o,d,!0)}function fC(){NC(function(){(Ka&6)!==0?Ve(yt,uC):kv()})}function qx(){if(Fc===0){var o=a0;o===0&&(o=Nr,Nr<<=1,(Nr&261888)===0&&(Nr=256)),Fc=o}return Fc}function Cv(o){return o==null||typeof o=="symbol"||typeof o=="boolean"?null:typeof o=="function"?o:hn(""+o)}function Ev(o,d){var p=d.ownerDocument.createElement("input");return p.name=d.name,p.value=d.value,o.id&&p.setAttribute("form",o.id),d.parentNode.insertBefore(p,d),o=new FormData(o),p.parentNode.removeChild(p),o}function hC(o,d,p,N,I){if(d==="submit"&&p&&p.stateNode===I){var U=Cv((I[_e]||null).action),xe=N.submitter;xe&&(d=(d=xe[_e]||null)?Cv(d.formAction):xe.getAttribute("formAction"),d!==null&&(U=d,xe=null));var Ie=new es("action","action",null,N,I);o.push({event:Ie,listeners:[{instance:null,listener:function(){if(N.defaultPrevented){if(Fc!==0){var lt=xe?Ev(I,xe):new FormData(I);mx(p,{pending:!0,data:lt,method:I.method,action:U},null,lt)}}else typeof U=="function"&&(Ie.preventDefault(),lt=xe?Ev(I,xe):new FormData(I),mx(p,{pending:!0,data:lt,method:I.method,action:U},U,lt))},currentTarget:I}]})}}for(var Xx=0;Xx<xa.length;Xx++){var Zx=xa[Xx],mC=Zx.toLowerCase(),gC=Zx[0].toUpperCase()+Zx.slice(1);Bs(mC,"on"+gC)}Bs(ra,"onAnimationEnd"),Bs(La,"onAnimationIteration"),Bs(Dr,"onAnimationStart"),Bs("dblclick","onDoubleClick"),Bs("focusin","onFocus"),Bs("focusout","onBlur"),Bs(Ta,"onTransitionRun"),Bs(gs,"onTransitionStart"),Bs(vs,"onTransitionCancel"),Bs(as,"onTransitionEnd"),vr("onMouseEnter",["mouseout","mouseover"]),vr("onMouseLeave",["mouseout","mouseover"]),vr("onPointerEnter",["pointerout","pointerover"]),vr("onPointerLeave",["pointerout","pointerover"]),qr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),qr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),qr("onBeforeInput",["compositionend","keypress","textInput","paste"]),qr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),qr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),qr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Pu="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(" "),xC=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Pu));function Tv(o,d){d=(d&4)!==0;for(var p=0;p<o.length;p++){var N=o[p],I=N.event;N=N.listeners;e:{var U=void 0;if(d)for(var xe=N.length-1;0<=xe;xe--){var Ie=N[xe],lt=Ie.instance,Ut=Ie.currentTarget;if(Ie=Ie.listener,lt!==U&&I.isPropagationStopped())break e;U=Ie,I.currentTarget=Ut;try{U(I)}catch(nr){pn(nr)}I.currentTarget=null,U=lt}else for(xe=0;xe<N.length;xe++){if(Ie=N[xe],lt=Ie.instance,Ut=Ie.currentTarget,Ie=Ie.listener,lt!==U&&I.isPropagationStopped())break e;U=Ie,I.currentTarget=Ut;try{U(I)}catch(nr){pn(nr)}I.currentTarget=null,U=lt}}}}function Fa(o,d){var p=d[Qe];p===void 0&&(p=d[Qe]=new Set);var N=o+"__bubble";p.has(N)||(Av(d,o,2,!1),p.add(N))}function Kx(o,d,p){var N=0;d&&(N|=4),Av(p,o,N,d)}var Uh="_reactListening"+Math.random().toString(36).slice(2);function Jx(o){if(!o[Uh]){o[Uh]=!0,Ht.forEach(function(p){p!=="selectionchange"&&(xC.has(p)||Kx(p,!1,o),Kx(p,!0,o))});var d=o.nodeType===9?o:o.ownerDocument;d===null||d[Uh]||(d[Uh]=!0,Kx("selectionchange",!1,d))}}function Av(o,d,p,N){switch(nw(d)){case 2:var I=$C;break;case 8:I=VC;break;default:I=hp}p=I.bind(null,d,p,o),I=void 0,!gi||d!=="touchstart"&&d!=="touchmove"&&d!=="wheel"||(I=!0),N?I!==void 0?o.addEventListener(d,p,{capture:!0,passive:I}):o.addEventListener(d,p,!0):I!==void 0?o.addEventListener(d,p,{passive:I}):o.addEventListener(d,p,!1)}function Qx(o,d,p,N,I){var U=N;if((d&1)===0&&(d&2)===0&&N!==null)e:for(;;){if(N===null)return;var xe=N.tag;if(xe===3||xe===4){var Ie=N.stateNode.containerInfo;if(Ie===I)break;if(xe===4)for(xe=N.return;xe!==null;){var lt=xe.tag;if((lt===3||lt===4)&&xe.stateNode.containerInfo===I)return;xe=xe.return}for(;Ie!==null;){if(xe=gt(Ie),xe===null)return;if(lt=xe.tag,lt===5||lt===6||lt===26||lt===27){N=U=xe;continue e}Ie=Ie.parentNode}}N=N.return}En(function(){var Ut=U,nr=Hi(p),dr=[];e:{var Vt=xn.get(o);if(Vt!==void 0){var er=es,Mr=o;switch(o){case"keypress":if(Qn(p)===0)break e;case"keydown":case"keyup":er=Jo;break;case"focusin":Mr="focus",er=Co;break;case"focusout":Mr="blur",er=Co;break;case"beforeblur":case"afterblur":er=Co;break;case"click":if(p.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":er=Pa;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":er=xl;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":er=bc;break;case ra:case La:case Dr:er=na;break;case as:er=Un;break;case"scroll":case"scrollend":er=ga;break;case"wheel":er=Vi;break;case"copy":case"cut":case"paste":er=An;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":er=za;break;case"toggle":case"beforetoggle":er=oo}var ta=(d&4)!==0,hs=!ta&&(o==="scroll"||o==="scrollend"),Ct=ta?Vt!==null?Vt+"Capture":null:Vt;ta=[];for(var pt=Ut,Bt;pt!==null;){var or=pt;if(Bt=or.stateNode,or=or.tag,or!==5&&or!==26&&or!==27||Bt===null||Ct===null||(or=Lr(pt,Ct),or!=null&&ta.push(Lu(pt,or,Bt))),hs)break;pt=pt.return}0<ta.length&&(Vt=new er(Vt,Mr,null,p,nr),dr.push({event:Vt,listeners:ta}))}}if((d&7)===0){e:{if(Vt=o==="mouseover"||o==="pointerover",er=o==="mouseout"||o==="pointerout",Vt&&p!==Ai&&(Mr=p.relatedTarget||p.fromElement)&&(gt(Mr)||Mr[Ce]))break e;if((er||Vt)&&(Vt=nr.window===nr?nr:(Vt=nr.ownerDocument)?Vt.defaultView||Vt.parentWindow:window,er?(Mr=p.relatedTarget||p.toElement,er=Ut,Mr=Mr?gt(Mr):null,Mr!==null&&(hs=i(Mr),ta=Mr.tag,Mr!==hs||ta!==5&&ta!==27&&ta!==6)&&(Mr=null)):(er=null,Mr=Ut),er!==Mr)){if(ta=Pa,or="onMouseLeave",Ct="onMouseEnter",pt="mouse",(o==="pointerout"||o==="pointerover")&&(ta=za,or="onPointerLeave",Ct="onPointerEnter",pt="pointer"),hs=er==null?Vt:Ft(er),Bt=Mr==null?Vt:Ft(Mr),Vt=new ta(or,pt+"leave",er,p,nr),Vt.target=hs,Vt.relatedTarget=Bt,or=null,gt(nr)===Ut&&(ta=new ta(Ct,pt+"enter",Mr,p,nr),ta.target=Bt,ta.relatedTarget=hs,or=ta),hs=or,er&&Mr)t:{for(ta=pC,Ct=er,pt=Mr,Bt=0,or=Ct;or;or=ta(or))Bt++;or=0;for(var Xr=pt;Xr;Xr=ta(Xr))or++;for(;0<Bt-or;)Ct=ta(Ct),Bt--;for(;0<or-Bt;)pt=ta(pt),or--;for(;Bt--;){if(Ct===pt||pt!==null&&Ct===pt.alternate){ta=Ct;break t}Ct=ta(Ct),pt=ta(pt)}ta=null}else ta=null;er!==null&&Ov(dr,Vt,er,ta,!1),Mr!==null&&hs!==null&&Ov(dr,hs,Mr,ta,!0)}}e:{if(Vt=Ut?Ft(Ut):window,er=Vt.nodeName&&Vt.nodeName.toLowerCase(),er==="select"||er==="input"&&Vt.type==="file")var qa=gn;else if(si(Vt))if(zl)qa=b;else{qa=f;var Hr=l}else er=Vt.nodeName,!er||er.toLowerCase()!=="input"||Vt.type!=="checkbox"&&Vt.type!=="radio"?Ut&&ua(Ut.elementType)&&(qa=gn):qa=x;if(qa&&(qa=qa(o,Ut))){ni(dr,qa,p,nr);break e}Hr&&Hr(o,Vt,Ut),o==="focusout"&&Ut&&Vt.type==="number"&&Ut.memoizedProps.value!=null&&Me(Vt,"number",Vt.value)}switch(Hr=Ut?Ft(Ut):window,o){case"focusin":(si(Hr)||Hr.contentEditable==="true")&&(ot=Hr,ut=Ut,At=null);break;case"focusout":At=ut=ot=null;break;case"mousedown":se=!0;break;case"contextmenu":case"mouseup":case"dragend":se=!1,Ee(dr,p,nr);break;case"selectionchange":if(Ge)break;case"keydown":case"keyup":Ee(dr,p,nr)}var wa;if(Eo)e:{switch(o){case"compositionstart":var Ma="onCompositionStart";break e;case"compositionend":Ma="onCompositionEnd";break e;case"compositionupdate":Ma="onCompositionUpdate";break e}Ma=void 0}else To?Ul(o,p)&&(Ma="onCompositionEnd"):o==="keydown"&&p.keyCode===229&&(Ma="onCompositionStart");Ma&&(yl&&p.locale!=="ko"&&(To||Ma!=="onCompositionStart"?Ma==="onCompositionEnd"&&To&&(wa=en()):(Os=nr,$s="value"in Os?Os.value:Os.textContent,To=!0)),Hr=zh(Ut,Ma),0<Hr.length&&(Ma=new Bl(Ma,o,null,p,nr),dr.push({event:Ma,listeners:Hr}),wa?Ma.data=wa:(wa=co(p),wa!==null&&(Ma.data=wa)))),(wa=vc?Rs(o,p):Di(o,p))&&(Ma=zh(Ut,"onBeforeInput"),0<Ma.length&&(Hr=new Bl("onBeforeInput","beforeinput",null,p,nr),dr.push({event:Hr,listeners:Ma}),Hr.data=wa)),hC(dr,o,Ut,p,nr)}Tv(dr,d)})}function Lu(o,d,p){return{instance:o,listener:d,currentTarget:p}}function zh(o,d){for(var p=d+"Capture",N=[];o!==null;){var I=o,U=I.stateNode;if(I=I.tag,I!==5&&I!==26&&I!==27||U===null||(I=Lr(o,p),I!=null&&N.unshift(Lu(o,I,U)),I=Lr(o,d),I!=null&&N.push(Lu(o,I,U))),o.tag===3)return N;o=o.return}return[]}function pC(o){if(o===null)return null;do o=o.return;while(o&&o.tag!==5&&o.tag!==27);return o||null}function Ov(o,d,p,N,I){for(var U=d._reactName,xe=[];p!==null&&p!==N;){var Ie=p,lt=Ie.alternate,Ut=Ie.stateNode;if(Ie=Ie.tag,lt!==null&&lt===N)break;Ie!==5&&Ie!==26&&Ie!==27||Ut===null||(lt=Ut,I?(Ut=Lr(p,U),Ut!=null&&xe.unshift(Lu(p,Ut,lt))):I||(Ut=Lr(p,U),Ut!=null&&xe.push(Lu(p,Ut,lt)))),p=p.return}xe.length!==0&&o.push({event:d,listeners:xe})}var yC=/\r\n?/g,bC=/\u0000|\uFFFD/g;function Dv(o){return(typeof o=="string"?o:""+o).replace(yC,`
`).replace(bC,"")}function Rv(o,d){return d=Dv(d),Dv(o)===d}function fs(o,d,p,N,I,U){switch(p){case"children":typeof N=="string"?d==="body"||d==="textarea"&&N===""||Va(o,N):(typeof N=="number"||typeof N=="bigint")&&d!=="body"&&Va(o,""+N);break;case"className":Sa(o,"class",N);break;case"tabIndex":Sa(o,"tabindex",N);break;case"dir":case"role":case"viewBox":case"width":case"height":Sa(o,p,N);break;case"style":xr(o,N,U);break;case"data":if(d!=="object"){Sa(o,"data",N);break}case"src":case"href":if(N===""&&(d!=="a"||p!=="href")){o.removeAttribute(p);break}if(N==null||typeof N=="function"||typeof N=="symbol"||typeof N=="boolean"){o.removeAttribute(p);break}N=hn(""+N),o.setAttribute(p,N);break;case"action":case"formAction":if(typeof N=="function"){o.setAttribute(p,"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 U=="function"&&(p==="formAction"?(d!=="input"&&fs(o,d,"name",I.name,I,null),fs(o,d,"formEncType",I.formEncType,I,null),fs(o,d,"formMethod",I.formMethod,I,null),fs(o,d,"formTarget",I.formTarget,I,null)):(fs(o,d,"encType",I.encType,I,null),fs(o,d,"method",I.method,I,null),fs(o,d,"target",I.target,I,null)));if(N==null||typeof N=="symbol"||typeof N=="boolean"){o.removeAttribute(p);break}N=hn(""+N),o.setAttribute(p,N);break;case"onClick":N!=null&&(o.onclick=Ts);break;case"onScroll":N!=null&&Fa("scroll",o);break;case"onScrollEnd":N!=null&&Fa("scrollend",o);break;case"dangerouslySetInnerHTML":if(N!=null){if(typeof N!="object"||!("__html"in N))throw Error(s(61));if(p=N.__html,p!=null){if(I.children!=null)throw Error(s(60));o.innerHTML=p}}break;case"multiple":o.multiple=N&&typeof N!="function"&&typeof N!="symbol";break;case"muted":o.muted=N&&typeof N!="function"&&typeof N!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(N==null||typeof N=="function"||typeof N=="boolean"||typeof N=="symbol"){o.removeAttribute("xlink:href");break}p=hn(""+N),o.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",p);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":N!=null&&typeof N!="function"&&typeof N!="symbol"?o.setAttribute(p,""+N):o.removeAttribute(p);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":N&&typeof N!="function"&&typeof N!="symbol"?o.setAttribute(p,""):o.removeAttribute(p);break;case"capture":case"download":N===!0?o.setAttribute(p,""):N!==!1&&N!=null&&typeof N!="function"&&typeof N!="symbol"?o.setAttribute(p,N):o.removeAttribute(p);break;case"cols":case"rows":case"size":case"span":N!=null&&typeof N!="function"&&typeof N!="symbol"&&!isNaN(N)&&1<=N?o.setAttribute(p,N):o.removeAttribute(p);break;case"rowSpan":case"start":N==null||typeof N=="function"||typeof N=="symbol"||isNaN(N)?o.removeAttribute(p):o.setAttribute(p,N);break;case"popover":Fa("beforetoggle",o),Fa("toggle",o),Gr(o,"popover",N);break;case"xlinkActuate":Ps(o,"http://www.w3.org/1999/xlink","xlink:actuate",N);break;case"xlinkArcrole":Ps(o,"http://www.w3.org/1999/xlink","xlink:arcrole",N);break;case"xlinkRole":Ps(o,"http://www.w3.org/1999/xlink","xlink:role",N);break;case"xlinkShow":Ps(o,"http://www.w3.org/1999/xlink","xlink:show",N);break;case"xlinkTitle":Ps(o,"http://www.w3.org/1999/xlink","xlink:title",N);break;case"xlinkType":Ps(o,"http://www.w3.org/1999/xlink","xlink:type",N);break;case"xmlBase":Ps(o,"http://www.w3.org/XML/1998/namespace","xml:base",N);break;case"xmlLang":Ps(o,"http://www.w3.org/XML/1998/namespace","xml:lang",N);break;case"xmlSpace":Ps(o,"http://www.w3.org/XML/1998/namespace","xml:space",N);break;case"is":Gr(o,"is",N);break;case"innerText":case"textContent":break;default:(!(2<p.length)||p[0]!=="o"&&p[0]!=="O"||p[1]!=="n"&&p[1]!=="N")&&(p=Jn.get(p)||p,Gr(o,p,N))}}function ep(o,d,p,N,I,U){switch(p){case"style":xr(o,N,U);break;case"dangerouslySetInnerHTML":if(N!=null){if(typeof N!="object"||!("__html"in N))throw Error(s(61));if(p=N.__html,p!=null){if(I.children!=null)throw Error(s(60));o.innerHTML=p}}break;case"children":typeof N=="string"?Va(o,N):(typeof N=="number"||typeof N=="bigint")&&Va(o,""+N);break;case"onScroll":N!=null&&Fa("scroll",o);break;case"onScrollEnd":N!=null&&Fa("scrollend",o);break;case"onClick":N!=null&&(o.onclick=Ts);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!fa.hasOwnProperty(p))e:{if(p[0]==="o"&&p[1]==="n"&&(I=p.endsWith("Capture"),d=p.slice(2,I?p.length-7:void 0),U=o[_e]||null,U=U!=null?U[p]:null,typeof U=="function"&&o.removeEventListener(d,U,I),typeof N=="function")){typeof U!="function"&&U!==null&&(p in o?o[p]=null:o.hasAttribute(p)&&o.removeAttribute(p)),o.addEventListener(d,N,I);break e}p in o?o[p]=N:N===!0?o.setAttribute(p,""):Gr(o,p,N)}}}function di(o,d,p){switch(d){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Fa("error",o),Fa("load",o);var N=!1,I=!1,U;for(U in p)if(p.hasOwnProperty(U)){var xe=p[U];if(xe!=null)switch(U){case"src":N=!0;break;case"srcSet":I=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,d));default:fs(o,d,U,xe,p,null)}}I&&fs(o,d,"srcSet",p.srcSet,p,null),N&&fs(o,d,"src",p.src,p,null);return;case"input":Fa("invalid",o);var Ie=U=xe=I=null,lt=null,Ut=null;for(N in p)if(p.hasOwnProperty(N)){var nr=p[N];if(nr!=null)switch(N){case"name":I=nr;break;case"type":xe=nr;break;case"checked":lt=nr;break;case"defaultChecked":Ut=nr;break;case"value":U=nr;break;case"defaultValue":Ie=nr;break;case"children":case"dangerouslySetInnerHTML":if(nr!=null)throw Error(s(137,d));break;default:fs(o,d,N,nr,p,null)}}We(o,U,Ie,lt,Ut,xe,I,!1);return;case"select":Fa("invalid",o),N=xe=U=null;for(I in p)if(p.hasOwnProperty(I)&&(Ie=p[I],Ie!=null))switch(I){case"value":U=Ie;break;case"defaultValue":xe=Ie;break;case"multiple":N=Ie;default:fs(o,d,I,Ie,p,null)}d=U,p=xe,o.multiple=!!N,d!=null?Qt(o,!!N,d,!1):p!=null&&Qt(o,!!N,p,!0);return;case"textarea":Fa("invalid",o),U=I=N=null;for(xe in p)if(p.hasOwnProperty(xe)&&(Ie=p[xe],Ie!=null))switch(xe){case"value":N=Ie;break;case"defaultValue":I=Ie;break;case"children":U=Ie;break;case"dangerouslySetInnerHTML":if(Ie!=null)throw Error(s(91));break;default:fs(o,d,xe,Ie,p,null)}Oa(o,N,I,U);return;case"option":for(lt in p)if(p.hasOwnProperty(lt)&&(N=p[lt],N!=null))switch(lt){case"selected":o.selected=N&&typeof N!="function"&&typeof N!="symbol";break;default:fs(o,d,lt,N,p,null)}return;case"dialog":Fa("beforetoggle",o),Fa("toggle",o),Fa("cancel",o),Fa("close",o);break;case"iframe":case"object":Fa("load",o);break;case"video":case"audio":for(N=0;N<Pu.length;N++)Fa(Pu[N],o);break;case"image":Fa("error",o),Fa("load",o);break;case"details":Fa("toggle",o);break;case"embed":case"source":case"link":Fa("error",o),Fa("load",o);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Ut in p)if(p.hasOwnProperty(Ut)&&(N=p[Ut],N!=null))switch(Ut){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,d));default:fs(o,d,Ut,N,p,null)}return;default:if(ua(d)){for(nr in p)p.hasOwnProperty(nr)&&(N=p[nr],N!==void 0&&ep(o,d,nr,N,p,void 0));return}}for(Ie in p)p.hasOwnProperty(Ie)&&(N=p[Ie],N!=null&&fs(o,d,Ie,N,p,null))}function vC(o,d,p,N){switch(d){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var I=null,U=null,xe=null,Ie=null,lt=null,Ut=null,nr=null;for(er in p){var dr=p[er];if(p.hasOwnProperty(er)&&dr!=null)switch(er){case"checked":break;case"value":break;case"defaultValue":lt=dr;default:N.hasOwnProperty(er)||fs(o,d,er,null,N,dr)}}for(var Vt in N){var er=N[Vt];if(dr=p[Vt],N.hasOwnProperty(Vt)&&(er!=null||dr!=null))switch(Vt){case"type":U=er;break;case"name":I=er;break;case"checked":Ut=er;break;case"defaultChecked":nr=er;break;case"value":xe=er;break;case"defaultValue":Ie=er;break;case"children":case"dangerouslySetInnerHTML":if(er!=null)throw Error(s(137,d));break;default:er!==dr&&fs(o,d,Vt,er,N,dr)}}mt(o,xe,Ie,lt,Ut,nr,U,I);return;case"select":er=xe=Ie=Vt=null;for(U in p)if(lt=p[U],p.hasOwnProperty(U)&&lt!=null)switch(U){case"value":break;case"multiple":er=lt;default:N.hasOwnProperty(U)||fs(o,d,U,null,N,lt)}for(I in N)if(U=N[I],lt=p[I],N.hasOwnProperty(I)&&(U!=null||lt!=null))switch(I){case"value":Vt=U;break;case"defaultValue":Ie=U;break;case"multiple":xe=U;default:U!==lt&&fs(o,d,I,U,N,lt)}d=Ie,p=xe,N=er,Vt!=null?Qt(o,!!p,Vt,!1):!!N!=!!p&&(d!=null?Qt(o,!!p,d,!0):Qt(o,!!p,p?[]:"",!1));return;case"textarea":er=Vt=null;for(Ie in p)if(I=p[Ie],p.hasOwnProperty(Ie)&&I!=null&&!N.hasOwnProperty(Ie))switch(Ie){case"value":break;case"children":break;default:fs(o,d,Ie,null,N,I)}for(xe in N)if(I=N[xe],U=p[xe],N.hasOwnProperty(xe)&&(I!=null||U!=null))switch(xe){case"value":Vt=I;break;case"defaultValue":er=I;break;case"children":break;case"dangerouslySetInnerHTML":if(I!=null)throw Error(s(91));break;default:I!==U&&fs(o,d,xe,I,N,U)}Pr(o,Vt,er);return;case"option":for(var Mr in p)if(Vt=p[Mr],p.hasOwnProperty(Mr)&&Vt!=null&&!N.hasOwnProperty(Mr))switch(Mr){case"selected":o.selected=!1;break;default:fs(o,d,Mr,null,N,Vt)}for(lt in N)if(Vt=N[lt],er=p[lt],N.hasOwnProperty(lt)&&Vt!==er&&(Vt!=null||er!=null))switch(lt){case"selected":o.selected=Vt&&typeof Vt!="function"&&typeof Vt!="symbol";break;default:fs(o,d,lt,Vt,N,er)}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 ta in p)Vt=p[ta],p.hasOwnProperty(ta)&&Vt!=null&&!N.hasOwnProperty(ta)&&fs(o,d,ta,null,N,Vt);for(Ut in N)if(Vt=N[Ut],er=p[Ut],N.hasOwnProperty(Ut)&&Vt!==er&&(Vt!=null||er!=null))switch(Ut){case"children":case"dangerouslySetInnerHTML":if(Vt!=null)throw Error(s(137,d));break;default:fs(o,d,Ut,Vt,N,er)}return;default:if(ua(d)){for(var hs in p)Vt=p[hs],p.hasOwnProperty(hs)&&Vt!==void 0&&!N.hasOwnProperty(hs)&&ep(o,d,hs,void 0,N,Vt);for(nr in N)Vt=N[nr],er=p[nr],!N.hasOwnProperty(nr)||Vt===er||Vt===void 0&&er===void 0||ep(o,d,nr,Vt,N,er);return}}for(var Ct in p)Vt=p[Ct],p.hasOwnProperty(Ct)&&Vt!=null&&!N.hasOwnProperty(Ct)&&fs(o,d,Ct,null,N,Vt);for(dr in N)Vt=N[dr],er=p[dr],!N.hasOwnProperty(dr)||Vt===er||Vt==null&&er==null||fs(o,d,dr,Vt,N,er)}function Fv(o){switch(o){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function wC(){if(typeof performance.getEntriesByType=="function"){for(var o=0,d=0,p=performance.getEntriesByType("resource"),N=0;N<p.length;N++){var I=p[N],U=I.transferSize,xe=I.initiatorType,Ie=I.duration;if(U&&Ie&&Fv(xe)){for(xe=0,Ie=I.responseEnd,N+=1;N<p.length;N++){var lt=p[N],Ut=lt.startTime;if(Ut>Ie)break;var nr=lt.transferSize,dr=lt.initiatorType;nr&&Fv(dr)&&(lt=lt.responseEnd,xe+=nr*(lt<Ie?1:(Ie-Ut)/(lt-Ut)))}if(--N,d+=8*(U+xe)/(I.duration/1e3),o++,10<o)break}}if(0<o)return d/o/1e6}return navigator.connection&&(o=navigator.connection.downlink,typeof o=="number")?o:5}var tp=null,rp=null;function Wh(o){return o.nodeType===9?o:o.ownerDocument}function Iv(o){switch(o){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Mv(o,d){if(o===0)switch(d){case"svg":return 1;case"math":return 2;default:return 0}return o===1&&d==="foreignObject"?0:o}function ap(o,d){return o==="textarea"||o==="noscript"||typeof d.children=="string"||typeof d.children=="number"||typeof d.children=="bigint"||typeof d.dangerouslySetInnerHTML=="object"&&d.dangerouslySetInnerHTML!==null&&d.dangerouslySetInnerHTML.__html!=null}var sp=null;function _C(){var o=window.event;return o&&o.type==="popstate"?o===sp?!1:(sp=o,!0):(sp=null,!1)}var Pv=typeof setTimeout=="function"?setTimeout:void 0,kC=typeof clearTimeout=="function"?clearTimeout:void 0,Lv=typeof Promise=="function"?Promise:void 0,NC=typeof queueMicrotask=="function"?queueMicrotask:typeof Lv!="undefined"?function(o){return Lv.resolve(null).then(o).catch(jC)}:Pv;function jC(o){setTimeout(function(){throw o})}function Ic(o){return o==="head"}function Bv(o,d){var p=d,N=0;do{var I=p.nextSibling;if(o.removeChild(p),I&&I.nodeType===8)if(p=I.data,p==="/$"||p==="/&"){if(N===0){o.removeChild(I),_0(d);return}N--}else if(p==="$"||p==="$?"||p==="$~"||p==="$!"||p==="&")N++;else if(p==="html")Bu(o.ownerDocument.documentElement);else if(p==="head"){p=o.ownerDocument.head,Bu(p);for(var U=p.firstChild;U;){var xe=U.nextSibling,Ie=U.nodeName;U[$e]||Ie==="SCRIPT"||Ie==="STYLE"||Ie==="LINK"&&U.rel.toLowerCase()==="stylesheet"||p.removeChild(U),U=xe}}else p==="body"&&Bu(o.ownerDocument.body);p=I}while(p);_0(d)}function Uv(o,d){var p=o;o=0;do{var N=p.nextSibling;if(p.nodeType===1?d?(p._stashedDisplay=p.style.display,p.style.display="none"):(p.style.display=p._stashedDisplay||"",p.getAttribute("style")===""&&p.removeAttribute("style")):p.nodeType===3&&(d?(p._stashedText=p.nodeValue,p.nodeValue=""):p.nodeValue=p._stashedText||""),N&&N.nodeType===8)if(p=N.data,p==="/$"){if(o===0)break;o--}else p!=="$"&&p!=="$?"&&p!=="$~"&&p!=="$!"||o++;p=N}while(p)}function np(o){var d=o.firstChild;for(d&&d.nodeType===10&&(d=d.nextSibling);d;){var p=d;switch(d=d.nextSibling,p.nodeName){case"HTML":case"HEAD":case"BODY":np(p),tt(p);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(p.rel.toLowerCase()==="stylesheet")continue}o.removeChild(p)}}function SC(o,d,p,N){for(;o.nodeType===1;){var I=p;if(o.nodeName.toLowerCase()!==d.toLowerCase()){if(!N&&(o.nodeName!=="INPUT"||o.type!=="hidden"))break}else if(N){if(!o[$e])switch(d){case"meta":if(!o.hasAttribute("itemprop"))break;return o;case"link":if(U=o.getAttribute("rel"),U==="stylesheet"&&o.hasAttribute("data-precedence"))break;if(U!==I.rel||o.getAttribute("href")!==(I.href==null||I.href===""?null:I.href)||o.getAttribute("crossorigin")!==(I.crossOrigin==null?null:I.crossOrigin)||o.getAttribute("title")!==(I.title==null?null:I.title))break;return o;case"style":if(o.hasAttribute("data-precedence"))break;return o;case"script":if(U=o.getAttribute("src"),(U!==(I.src==null?null:I.src)||o.getAttribute("type")!==(I.type==null?null:I.type)||o.getAttribute("crossorigin")!==(I.crossOrigin==null?null:I.crossOrigin))&&U&&o.hasAttribute("async")&&!o.hasAttribute("itemprop"))break;return o;default:return o}}else if(d==="input"&&o.type==="hidden"){var U=I.name==null?null:""+I.name;if(I.type==="hidden"&&o.getAttribute("name")===U)return o}else return o;if(o=Fo(o.nextSibling),o===null)break}return null}function CC(o,d,p){if(d==="")return null;for(;o.nodeType!==3;)if((o.nodeType!==1||o.nodeName!=="INPUT"||o.type!=="hidden")&&!p||(o=Fo(o.nextSibling),o===null))return null;return o}function zv(o,d){for(;o.nodeType!==8;)if((o.nodeType!==1||o.nodeName!=="INPUT"||o.type!=="hidden")&&!d||(o=Fo(o.nextSibling),o===null))return null;return o}function ip(o){return o.data==="$?"||o.data==="$~"}function op(o){return o.data==="$!"||o.data==="$?"&&o.ownerDocument.readyState!=="loading"}function EC(o,d){var p=o.ownerDocument;if(o.data==="$~")o._reactRetry=d;else if(o.data!=="$?"||p.readyState!=="loading")d();else{var N=function(){d(),p.removeEventListener("DOMContentLoaded",N)};p.addEventListener("DOMContentLoaded",N),o._reactRetry=N}}function Fo(o){for(;o!=null;o=o.nextSibling){var d=o.nodeType;if(d===1||d===3)break;if(d===8){if(d=o.data,d==="$"||d==="$!"||d==="$?"||d==="$~"||d==="&"||d==="F!"||d==="F")break;if(d==="/$"||d==="/&")return null}}return o}var lp=null;function Wv(o){o=o.nextSibling;for(var d=0;o;){if(o.nodeType===8){var p=o.data;if(p==="/$"||p==="/&"){if(d===0)return Fo(o.nextSibling);d--}else p!=="$"&&p!=="$!"&&p!=="$?"&&p!=="$~"&&p!=="&"||d++}o=o.nextSibling}return null}function Hv(o){o=o.previousSibling;for(var d=0;o;){if(o.nodeType===8){var p=o.data;if(p==="$"||p==="$!"||p==="$?"||p==="$~"||p==="&"){if(d===0)return o;d--}else p!=="/$"&&p!=="/&"||d++}o=o.previousSibling}return null}function $v(o,d,p){switch(d=Wh(p),o){case"html":if(o=d.documentElement,!o)throw Error(s(452));return o;case"head":if(o=d.head,!o)throw Error(s(453));return o;case"body":if(o=d.body,!o)throw Error(s(454));return o;default:throw Error(s(451))}}function Bu(o){for(var d=o.attributes;d.length;)o.removeAttributeNode(d[0]);tt(o)}var Io=new Map,Vv=new Set;function Hh(o){return typeof o.getRootNode=="function"?o.getRootNode():o.nodeType===9?o:o.ownerDocument}var rc=ee.d;ee.d={f:TC,r:AC,D:OC,C:DC,L:RC,m:FC,X:MC,S:IC,M:PC};function TC(){var o=rc.f(),d=Fh();return o||d}function AC(o){var d=Wt(o);d!==null&&d.tag===5&&d.type==="form"?l2(d):rc.r(o)}var b0=typeof document=="undefined"?null:document;function Gv(o,d,p){var N=b0;if(N&&typeof d=="string"&&d){var I=Wr(d);I='link[rel="'+o+'"][href="'+I+'"]',typeof p=="string"&&(I+='[crossorigin="'+p+'"]'),Vv.has(I)||(Vv.add(I),o={rel:o,crossOrigin:p,href:d},N.querySelector(I)===null&&(d=N.createElement("link"),di(d,"link",o),br(d),N.head.appendChild(d)))}}function OC(o){rc.D(o),Gv("dns-prefetch",o,null)}function DC(o,d){rc.C(o,d),Gv("preconnect",o,d)}function RC(o,d,p){rc.L(o,d,p);var N=b0;if(N&&o&&d){var I='link[rel="preload"][as="'+Wr(d)+'"]';d==="image"&&p&&p.imageSrcSet?(I+='[imagesrcset="'+Wr(p.imageSrcSet)+'"]',typeof p.imageSizes=="string"&&(I+='[imagesizes="'+Wr(p.imageSizes)+'"]')):I+='[href="'+Wr(o)+'"]';var U=I;switch(d){case"style":U=v0(o);break;case"script":U=w0(o)}Io.has(U)||(o=w({rel:"preload",href:d==="image"&&p&&p.imageSrcSet?void 0:o,as:d},p),Io.set(U,o),N.querySelector(I)!==null||d==="style"&&N.querySelector(Uu(U))||d==="script"&&N.querySelector(zu(U))||(d=N.createElement("link"),di(d,"link",o),br(d),N.head.appendChild(d)))}}function FC(o,d){rc.m(o,d);var p=b0;if(p&&o){var N=d&&typeof d.as=="string"?d.as:"script",I='link[rel="modulepreload"][as="'+Wr(N)+'"][href="'+Wr(o)+'"]',U=I;switch(N){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":U=w0(o)}if(!Io.has(U)&&(o=w({rel:"modulepreload",href:o},d),Io.set(U,o),p.querySelector(I)===null)){switch(N){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(p.querySelector(zu(U)))return}N=p.createElement("link"),di(N,"link",o),br(N),p.head.appendChild(N)}}}function IC(o,d,p){rc.S(o,d,p);var N=b0;if(N&&o){var I=Zt(N).hoistableStyles,U=v0(o);d=d||"default";var xe=I.get(U);if(!xe){var Ie={loading:0,preload:null};if(xe=N.querySelector(Uu(U)))Ie.loading=5;else{o=w({rel:"stylesheet",href:o,"data-precedence":d},p),(p=Io.get(U))&&cp(o,p);var lt=xe=N.createElement("link");br(lt),di(lt,"link",o),lt._p=new Promise(function(Ut,nr){lt.onload=Ut,lt.onerror=nr}),lt.addEventListener("load",function(){Ie.loading|=1}),lt.addEventListener("error",function(){Ie.loading|=2}),Ie.loading|=4,$h(xe,d,N)}xe={type:"stylesheet",instance:xe,count:1,state:Ie},I.set(U,xe)}}}function MC(o,d){rc.X(o,d);var p=b0;if(p&&o){var N=Zt(p).hoistableScripts,I=w0(o),U=N.get(I);U||(U=p.querySelector(zu(I)),U||(o=w({src:o,async:!0},d),(d=Io.get(I))&&dp(o,d),U=p.createElement("script"),br(U),di(U,"link",o),p.head.appendChild(U)),U={type:"script",instance:U,count:1,state:null},N.set(I,U))}}function PC(o,d){rc.M(o,d);var p=b0;if(p&&o){var N=Zt(p).hoistableScripts,I=w0(o),U=N.get(I);U||(U=p.querySelector(zu(I)),U||(o=w({src:o,async:!0,type:"module"},d),(d=Io.get(I))&&dp(o,d),U=p.createElement("script"),br(U),di(U,"link",o),p.head.appendChild(U)),U={type:"script",instance:U,count:1,state:null},N.set(I,U))}}function Yv(o,d,p,N){var I=(I=le.current)?Hh(I):null;if(!I)throw Error(s(446));switch(o){case"meta":case"title":return null;case"style":return typeof p.precedence=="string"&&typeof p.href=="string"?(d=v0(p.href),p=Zt(I).hoistableStyles,N=p.get(d),N||(N={type:"style",instance:null,count:0,state:null},p.set(d,N)),N):{type:"void",instance:null,count:0,state:null};case"link":if(p.rel==="stylesheet"&&typeof p.href=="string"&&typeof p.precedence=="string"){o=v0(p.href);var U=Zt(I).hoistableStyles,xe=U.get(o);if(xe||(I=I.ownerDocument||I,xe={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},U.set(o,xe),(U=I.querySelector(Uu(o)))&&!U._p&&(xe.instance=U,xe.state.loading=5),Io.has(o)||(p={rel:"preload",as:"style",href:p.href,crossOrigin:p.crossOrigin,integrity:p.integrity,media:p.media,hrefLang:p.hrefLang,referrerPolicy:p.referrerPolicy},Io.set(o,p),U||LC(I,o,p,xe.state))),d&&N===null)throw Error(s(528,""));return xe}if(d&&N!==null)throw Error(s(529,""));return null;case"script":return d=p.async,p=p.src,typeof p=="string"&&d&&typeof d!="function"&&typeof d!="symbol"?(d=w0(p),p=Zt(I).hoistableScripts,N=p.get(d),N||(N={type:"script",instance:null,count:0,state:null},p.set(d,N)),N):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,o))}}function v0(o){return'href="'+Wr(o)+'"'}function Uu(o){return'link[rel="stylesheet"]['+o+"]"}function qv(o){return w({},o,{"data-precedence":o.precedence,precedence:null})}function LC(o,d,p,N){o.querySelector('link[rel="preload"][as="style"]['+d+"]")?N.loading=1:(d=o.createElement("link"),N.preload=d,d.addEventListener("load",function(){return N.loading|=1}),d.addEventListener("error",function(){return N.loading|=2}),di(d,"link",p),br(d),o.head.appendChild(d))}function w0(o){return'[src="'+Wr(o)+'"]'}function zu(o){return"script[async]"+o}function Xv(o,d,p){if(d.count++,d.instance===null)switch(d.type){case"style":var N=o.querySelector('style[data-href~="'+Wr(p.href)+'"]');if(N)return d.instance=N,br(N),N;var I=w({},p,{"data-href":p.href,"data-precedence":p.precedence,href:null,precedence:null});return N=(o.ownerDocument||o).createElement("style"),br(N),di(N,"style",I),$h(N,p.precedence,o),d.instance=N;case"stylesheet":I=v0(p.href);var U=o.querySelector(Uu(I));if(U)return d.state.loading|=4,d.instance=U,br(U),U;N=qv(p),(I=Io.get(I))&&cp(N,I),U=(o.ownerDocument||o).createElement("link"),br(U);var xe=U;return xe._p=new Promise(function(Ie,lt){xe.onload=Ie,xe.onerror=lt}),di(U,"link",N),d.state.loading|=4,$h(U,p.precedence,o),d.instance=U;case"script":return U=w0(p.src),(I=o.querySelector(zu(U)))?(d.instance=I,br(I),I):(N=p,(I=Io.get(U))&&(N=w({},p),dp(N,I)),o=o.ownerDocument||o,I=o.createElement("script"),br(I),di(I,"link",N),o.head.appendChild(I),d.instance=I);case"void":return null;default:throw Error(s(443,d.type))}else d.type==="stylesheet"&&(d.state.loading&4)===0&&(N=d.instance,d.state.loading|=4,$h(N,p.precedence,o));return d.instance}function $h(o,d,p){for(var N=p.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),I=N.length?N[N.length-1]:null,U=I,xe=0;xe<N.length;xe++){var Ie=N[xe];if(Ie.dataset.precedence===d)U=Ie;else if(U!==I)break}U?U.parentNode.insertBefore(o,U.nextSibling):(d=p.nodeType===9?p.head:p,d.insertBefore(o,d.firstChild))}function cp(o,d){o.crossOrigin==null&&(o.crossOrigin=d.crossOrigin),o.referrerPolicy==null&&(o.referrerPolicy=d.referrerPolicy),o.title==null&&(o.title=d.title)}function dp(o,d){o.crossOrigin==null&&(o.crossOrigin=d.crossOrigin),o.referrerPolicy==null&&(o.referrerPolicy=d.referrerPolicy),o.integrity==null&&(o.integrity=d.integrity)}var Vh=null;function Zv(o,d,p){if(Vh===null){var N=new Map,I=Vh=new Map;I.set(p,N)}else I=Vh,N=I.get(p),N||(N=new Map,I.set(p,N));if(N.has(o))return N;for(N.set(o,null),p=p.getElementsByTagName(o),I=0;I<p.length;I++){var U=p[I];if(!(U[$e]||U[ne]||o==="link"&&U.getAttribute("rel")==="stylesheet")&&U.namespaceURI!=="http://www.w3.org/2000/svg"){var xe=U.getAttribute(d)||"";xe=o+xe;var Ie=N.get(xe);Ie?Ie.push(U):N.set(xe,[U])}}return N}function Kv(o,d,p){o=o.ownerDocument||o,o.head.insertBefore(p,d==="title"?o.querySelector("head > title"):null)}function BC(o,d,p){if(p===1||d.itemProp!=null)return!1;switch(o){case"meta":case"title":return!0;case"style":if(typeof d.precedence!="string"||typeof d.href!="string"||d.href==="")break;return!0;case"link":if(typeof d.rel!="string"||typeof d.href!="string"||d.href===""||d.onLoad||d.onError)break;switch(d.rel){case"stylesheet":return o=d.disabled,typeof d.precedence=="string"&&o==null;default:return!0}case"script":if(d.async&&typeof d.async!="function"&&typeof d.async!="symbol"&&!d.onLoad&&!d.onError&&d.src&&typeof d.src=="string")return!0}return!1}function Jv(o){return!(o.type==="stylesheet"&&(o.state.loading&3)===0)}function UC(o,d,p,N){if(p.type==="stylesheet"&&(typeof N.media!="string"||matchMedia(N.media).matches!==!1)&&(p.state.loading&4)===0){if(p.instance===null){var I=v0(N.href),U=d.querySelector(Uu(I));if(U){d=U._p,d!==null&&typeof d=="object"&&typeof d.then=="function"&&(o.count++,o=Gh.bind(o),d.then(o,o)),p.state.loading|=4,p.instance=U,br(U);return}U=d.ownerDocument||d,N=qv(N),(I=Io.get(I))&&cp(N,I),U=U.createElement("link"),br(U);var xe=U;xe._p=new Promise(function(Ie,lt){xe.onload=Ie,xe.onerror=lt}),di(U,"link",N),p.instance=U}o.stylesheets===null&&(o.stylesheets=new Map),o.stylesheets.set(p,d),(d=p.state.preload)&&(p.state.loading&3)===0&&(o.count++,p=Gh.bind(o),d.addEventListener("load",p),d.addEventListener("error",p))}}var up=0;function zC(o,d){return o.stylesheets&&o.count===0&&qh(o,o.stylesheets),0<o.count||0<o.imgCount?function(p){var N=setTimeout(function(){if(o.stylesheets&&qh(o,o.stylesheets),o.unsuspend){var U=o.unsuspend;o.unsuspend=null,U()}},6e4+d);0<o.imgBytes&&up===0&&(up=62500*wC());var I=setTimeout(function(){if(o.waitingForImages=!1,o.count===0&&(o.stylesheets&&qh(o,o.stylesheets),o.unsuspend)){var U=o.unsuspend;o.unsuspend=null,U()}},(o.imgBytes>up?50:800)+d);return o.unsuspend=p,function(){o.unsuspend=null,clearTimeout(N),clearTimeout(I)}}:null}function Gh(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)qh(this,this.stylesheets);else if(this.unsuspend){var o=this.unsuspend;this.unsuspend=null,o()}}}var Yh=null;function qh(o,d){o.stylesheets=null,o.unsuspend!==null&&(o.count++,Yh=new Map,d.forEach(WC,o),Yh=null,Gh.call(o))}function WC(o,d){if(!(d.state.loading&4)){var p=Yh.get(o);if(p)var N=p.get(null);else{p=new Map,Yh.set(o,p);for(var I=o.querySelectorAll("link[data-precedence],style[data-precedence]"),U=0;U<I.length;U++){var xe=I[U];(xe.nodeName==="LINK"||xe.getAttribute("media")!=="not all")&&(p.set(xe.dataset.precedence,xe),N=xe)}N&&p.set(null,N)}I=d.instance,xe=I.getAttribute("data-precedence"),U=p.get(xe)||N,U===N&&p.set(null,I),p.set(xe,I),this.count++,N=Gh.bind(this),I.addEventListener("load",N),I.addEventListener("error",N),U?U.parentNode.insertBefore(I,U.nextSibling):(o=o.nodeType===9?o.head:o,o.insertBefore(I,o.firstChild)),d.state.loading|=4}}var Wu={$$typeof:F,Provider:null,Consumer:null,_currentValue:ve,_currentValue2:ve,_threadCount:0};function HC(o,d,p,N,I,U,xe,Ie,lt){this.tag=1,this.containerInfo=o,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=He(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=He(0),this.hiddenUpdates=He(null),this.identifierPrefix=N,this.onUncaughtError=I,this.onCaughtError=U,this.onRecoverableError=xe,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=lt,this.incompleteTransitions=new Map}function Qv(o,d,p,N,I,U,xe,Ie,lt,Ut,nr,dr){return o=new HC(o,d,p,xe,lt,Ut,nr,dr,Ie),d=1,U===!0&&(d|=24),U=bi(3,null,null,d),o.current=U,U.stateNode=o,d=$g(),d.refCount++,o.pooledCache=d,d.refCount++,U.memoizedState={element:N,isDehydrated:p,cache:d},qg(U),o}function ew(o){return o?(o=Wl,o):Wl}function tw(o,d,p,N,I,U){I=ew(I),N.context===null?N.context=I:N.pendingContext=I,N=Nc(d),N.payload={element:p},U=U===void 0?null:U,U!==null&&(N.callback=U),p=jc(o,N,d),p!==null&&(Ki(p,o,d),vu(p,o,d))}function rw(o,d){if(o=o.memoizedState,o!==null&&o.dehydrated!==null){var p=o.retryLane;o.retryLane=p!==0&&p<d?p:d}}function fp(o,d){rw(o,d),(o=o.alternate)&&rw(o,d)}function aw(o){if(o.tag===13||o.tag===31){var d=Oo(o,67108864);d!==null&&Ki(d,o,67108864),fp(o,67108864)}}function sw(o){if(o.tag===13||o.tag===31){var d=go();d=Kt(d);var p=Oo(o,d);p!==null&&Ki(p,o,d),fp(o,d)}}var Xh=!0;function $C(o,d,p,N){var I=we.T;we.T=null;var U=ee.p;try{ee.p=2,hp(o,d,p,N)}finally{ee.p=U,we.T=I}}function VC(o,d,p,N){var I=we.T;we.T=null;var U=ee.p;try{ee.p=8,hp(o,d,p,N)}finally{ee.p=U,we.T=I}}function hp(o,d,p,N){if(Xh){var I=mp(N);if(I===null)Qx(o,d,N,Zh,p),iw(o,N);else if(YC(I,o,d,p,N))N.stopPropagation();else if(iw(o,N),d&4&&-1<GC.indexOf(o)){for(;I!==null;){var U=Wt(I);if(U!==null)switch(U.tag){case 3:if(U=U.stateNode,U.current.memoizedState.isDehydrated){var xe=Nt(U.pendingLanes);if(xe!==0){var Ie=U;for(Ie.pendingLanes|=2,Ie.entangledLanes|=2;xe;){var lt=1<<31-nt(xe);Ie.entanglements[1]|=lt,xe&=~lt}jl(U),(Ka&6)===0&&(Dh=Dt()+500,Mu(0))}}break;case 31:case 13:Ie=Oo(U,2),Ie!==null&&Ki(Ie,U,2),Fh(),fp(U,2)}if(U=mp(N),U===null&&Qx(o,d,N,Zh,p),U===I)break;I=U}I!==null&&N.stopPropagation()}else Qx(o,d,N,null,p)}}function mp(o){return o=Hi(o),gp(o)}var Zh=null;function gp(o){if(Zh=null,o=gt(o),o!==null){var d=i(o);if(d===null)o=null;else{var p=d.tag;if(p===13){if(o=c(d),o!==null)return o;o=null}else if(p===31){if(o=u(d),o!==null)return o;o=null}else if(p===3){if(d.stateNode.current.memoizedState.isDehydrated)return d.tag===3?d.stateNode.containerInfo:null;o=null}else d!==o&&(o=null)}}return Zh=o,null}function nw(o){switch(o){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(ar()){case yt:return 2;case St:return 8;case Ot:case Yt:return 32;case Ye:return 268435456;default:return 32}default:return 32}}var xp=!1,Mc=null,Pc=null,Lc=null,Hu=new Map,$u=new Map,Bc=[],GC="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 iw(o,d){switch(o){case"focusin":case"focusout":Mc=null;break;case"dragenter":case"dragleave":Pc=null;break;case"mouseover":case"mouseout":Lc=null;break;case"pointerover":case"pointerout":Hu.delete(d.pointerId);break;case"gotpointercapture":case"lostpointercapture":$u.delete(d.pointerId)}}function Vu(o,d,p,N,I,U){return o===null||o.nativeEvent!==U?(o={blockedOn:d,domEventName:p,eventSystemFlags:N,nativeEvent:U,targetContainers:[I]},d!==null&&(d=Wt(d),d!==null&&aw(d)),o):(o.eventSystemFlags|=N,d=o.targetContainers,I!==null&&d.indexOf(I)===-1&&d.push(I),o)}function YC(o,d,p,N,I){switch(d){case"focusin":return Mc=Vu(Mc,o,d,p,N,I),!0;case"dragenter":return Pc=Vu(Pc,o,d,p,N,I),!0;case"mouseover":return Lc=Vu(Lc,o,d,p,N,I),!0;case"pointerover":var U=I.pointerId;return Hu.set(U,Vu(Hu.get(U)||null,o,d,p,N,I)),!0;case"gotpointercapture":return U=I.pointerId,$u.set(U,Vu($u.get(U)||null,o,d,p,N,I)),!0}return!1}function ow(o){var d=gt(o.target);if(d!==null){var p=i(d);if(p!==null){if(d=p.tag,d===13){if(d=c(p),d!==null){o.blockedOn=d,he(o.priority,function(){sw(p)});return}}else if(d===31){if(d=u(p),d!==null){o.blockedOn=d,he(o.priority,function(){sw(p)});return}}else if(d===3&&p.stateNode.current.memoizedState.isDehydrated){o.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}o.blockedOn=null}function Kh(o){if(o.blockedOn!==null)return!1;for(var d=o.targetContainers;0<d.length;){var p=mp(o.nativeEvent);if(p===null){p=o.nativeEvent;var N=new p.constructor(p.type,p);Ai=N,p.target.dispatchEvent(N),Ai=null}else return d=Wt(p),d!==null&&aw(d),o.blockedOn=p,!1;d.shift()}return!0}function lw(o,d,p){Kh(o)&&p.delete(d)}function qC(){xp=!1,Mc!==null&&Kh(Mc)&&(Mc=null),Pc!==null&&Kh(Pc)&&(Pc=null),Lc!==null&&Kh(Lc)&&(Lc=null),Hu.forEach(lw),$u.forEach(lw)}function Jh(o,d){o.blockedOn===d&&(o.blockedOn=null,xp||(xp=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,qC)))}var Qh=null;function cw(o){Qh!==o&&(Qh=o,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Qh===o&&(Qh=null);for(var d=0;d<o.length;d+=3){var p=o[d],N=o[d+1],I=o[d+2];if(typeof N!="function"){if(gp(N||p)===null)continue;break}var U=Wt(p);U!==null&&(o.splice(d,3),d-=3,mx(U,{pending:!0,data:I,method:p.method,action:N},N,I))}}))}function _0(o){function d(lt){return Jh(lt,o)}Mc!==null&&Jh(Mc,o),Pc!==null&&Jh(Pc,o),Lc!==null&&Jh(Lc,o),Hu.forEach(d),$u.forEach(d);for(var p=0;p<Bc.length;p++){var N=Bc[p];N.blockedOn===o&&(N.blockedOn=null)}for(;0<Bc.length&&(p=Bc[0],p.blockedOn===null);)ow(p),p.blockedOn===null&&Bc.shift();if(p=(o.ownerDocument||o).$$reactFormReplay,p!=null)for(N=0;N<p.length;N+=3){var I=p[N],U=p[N+1],xe=I[_e]||null;if(typeof U=="function")xe||cw(p);else if(xe){var Ie=null;if(U&&U.hasAttribute("formAction")){if(I=U,xe=U[_e]||null)Ie=xe.formAction;else if(gp(I)!==null)continue}else Ie=xe.action;typeof Ie=="function"?p[N+1]=Ie:(p.splice(N,3),N-=3),cw(p)}}}function dw(){function o(U){U.canIntercept&&U.info==="react-transition"&&U.intercept({handler:function(){return new Promise(function(xe){return I=xe})},focusReset:"manual",scroll:"manual"})}function d(){I!==null&&(I(),I=null),N||setTimeout(p,20)}function p(){if(!N&&!navigation.transition){var U=navigation.currentEntry;U&&U.url!=null&&navigation.navigate(U.url,{state:U.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var N=!1,I=null;return navigation.addEventListener("navigate",o),navigation.addEventListener("navigatesuccess",d),navigation.addEventListener("navigateerror",d),setTimeout(p,100),function(){N=!0,navigation.removeEventListener("navigate",o),navigation.removeEventListener("navigatesuccess",d),navigation.removeEventListener("navigateerror",d),I!==null&&(I(),I=null)}}}function pp(o){this._internalRoot=o}em.prototype.render=pp.prototype.render=function(o){var d=this._internalRoot;if(d===null)throw Error(s(409));var p=d.current,N=go();tw(p,N,o,d,null,null)},em.prototype.unmount=pp.prototype.unmount=function(){var o=this._internalRoot;if(o!==null){this._internalRoot=null;var d=o.containerInfo;tw(o.current,2,null,o,null,null),Fh(),d[Ce]=null}};function em(o){this._internalRoot=o}em.prototype.unstable_scheduleHydration=function(o){if(o){var d=Q();o={blockedOn:null,target:o,priority:d};for(var p=0;p<Bc.length&&d!==0&&d<Bc[p].priority;p++);Bc.splice(p,0,o),p===0&&ow(o)}};var uw=r.version;if(uw!=="19.2.1")throw Error(s(527,uw,"19.2.1"));ee.findDOMNode=function(o){var d=o._reactInternals;if(d===void 0)throw typeof o.render=="function"?Error(s(188)):(o=Object.keys(o).join(","),Error(s(268,o)));return o=g(d),o=o!==null?y(o):null,o=o===null?null:o.stateNode,o};var XC={bundleType:0,version:"19.2.1",rendererPackageName:"react-dom",currentDispatcherRef:we,reconcilerVersion:"19.2.1"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__!="undefined"){var tm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!tm.isDisabled&&tm.supportsFiber)try{qt=tm.inject(XC),kt=tm}catch(o){}}return Yu.createRoot=function(o,d){if(!n(o))throw Error(s(299));var p=!1,N="",I=y2,U=b2,xe=v2;return d!=null&&(d.unstable_strictMode===!0&&(p=!0),d.identifierPrefix!==void 0&&(N=d.identifierPrefix),d.onUncaughtError!==void 0&&(I=d.onUncaughtError),d.onCaughtError!==void 0&&(U=d.onCaughtError),d.onRecoverableError!==void 0&&(xe=d.onRecoverableError)),d=Qv(o,1,!1,null,null,p,N,null,I,U,xe,dw),o[Ce]=d.current,Jx(o),new pp(d)},Yu.hydrateRoot=function(o,d,p){if(!n(o))throw Error(s(299));var N=!1,I="",U=y2,xe=b2,Ie=v2,lt=null;return p!=null&&(p.unstable_strictMode===!0&&(N=!0),p.identifierPrefix!==void 0&&(I=p.identifierPrefix),p.onUncaughtError!==void 0&&(U=p.onUncaughtError),p.onCaughtError!==void 0&&(xe=p.onCaughtError),p.onRecoverableError!==void 0&&(Ie=p.onRecoverableError),p.formState!==void 0&&(lt=p.formState)),d=Qv(o,1,!0,d,p!=null?p:null,N,I,lt,U,xe,Ie,dw),d.context=ew(null),p=d.current,N=go(),N=Kt(N),I=Nc(N),I.callback=null,jc(p,I,N),p=N,d.current.lanes=p,Fe(d,p),jl(d),o[Ce]=d.current,Jx(o),new em(d)},Yu.version="19.2.1",Yu}var Nw;function c6(){if(Nw)return kp.exports;Nw=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(),kp.exports=l6(),kp.exports}var d6=c6();const ca=e=>typeof e=="string",qu=()=>{let e,r;const a=new Promise((s,n)=>{e=s,r=n});return a.resolve=e,a.reject=r,a},jw=e=>e==null?"":""+e,u6=(e,r,a)=>{e.forEach(s=>{r[s]&&(a[s]=r[s])})},f6=/###/g,Sw=e=>e&&e.indexOf("###")>-1?e.replace(f6,"."):e,Cw=e=>!e||ca(e),cf=(e,r,a)=>{const s=ca(r)?r.split("."):r;let n=0;for(;n<s.length-1;){if(Cw(e))return{};const i=Sw(s[n]);!e[i]&&a&&(e[i]=new a),Object.prototype.hasOwnProperty.call(e,i)?e=e[i]:e={},++n}return Cw(e)?{}:{obj:e,k:Sw(s[n])}},Ew=(e,r,a)=>{const{obj:s,k:n}=cf(e,r,Object);if(s!==void 0||r.length===1){s[n]=a;return}let i=r[r.length-1],c=r.slice(0,r.length-1),u=cf(e,c,Object);for(;u.obj===void 0&&c.length;)i=`${c[c.length-1]}.${i}`,c=c.slice(0,c.length-1),u=cf(e,c,Object),u!=null&&u.obj&&typeof u.obj[`${u.k}.${i}`]!="undefined"&&(u.obj=void 0);u.obj[`${u.k}.${i}`]=a},h6=(e,r,a,s)=>{const{obj:n,k:i}=cf(e,r,Object);n[i]=n[i]||[],n[i].push(a)},Mm=(e,r)=>{const{obj:a,k:s}=cf(e,r);if(a&&Object.prototype.hasOwnProperty.call(a,s))return a[s]},m6=(e,r,a)=>{const s=Mm(e,a);return s!==void 0?s:Mm(r,a)},k4=(e,r,a)=>{for(const s in r)s!=="__proto__"&&s!=="constructor"&&(s in e?ca(e[s])||e[s]instanceof String||ca(r[s])||r[s]instanceof String?a&&(e[s]=r[s]):k4(e[s],r[s],a):e[s]=r[s]);return e},N0=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var g6={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const x6=e=>ca(e)?e.replace(/[&<>"'\/]/g,r=>g6[r]):e;class p6{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 y6=[" ",",","?","!",";"],b6=new p6(20),v6=(e,r,a)=>{r=r||"",a=a||"";const s=y6.filter(c=>r.indexOf(c)<0&&a.indexOf(c)<0);if(s.length===0)return!0;const n=b6.getRegExp(`(${s.map(c=>c==="?"?"\\?":c).join("|")})`);let i=!n.test(e);if(!i){const c=e.indexOf(a);c>0&&!n.test(e.substring(0,c))&&(i=!0)}return i},g1=(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 c,u="";for(let h=i;h<s.length;++h)if(h!==i&&(u+=a),u+=s[h],c=n[u],c!==void 0){if(["string","number","boolean"].indexOf(typeof c)>-1&&h<s.length-1)continue;i+=h-i+1;break}n=c}return n},kf=e=>e==null?void 0:e.replace("_","-"),w6={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 Pm{constructor(r,a={}){this.init(r,a)}init(r,a={}){this.prefix=a.prefix||"i18next:",this.logger=r||w6,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:(ca(r[0])&&(r[0]=`${s}${this.prefix} ${r[0]}`),this.logger[a](r))}create(r){return new Pm(this.logger,Te({prefix:`${this.prefix}:${r}:`},this.options))}clone(r){return r=r||this.options,r.prefix=r.prefix||this.prefix,new Pm(this.logger,r)}}var Dl=new Pm;class fg{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 c=0;c<i;c++)n(...a)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([n,i])=>{for(let c=0;c<i;c++)n.apply(n,[r,...a])})}}class Tw extends fg{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 g,y;const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,c=n.ignoreJSONStructure!==void 0?n.ignoreJSONStructure:this.options.ignoreJSONStructure;let u;r.indexOf(".")>-1?u=r.split("."):(u=[r,a],s&&(Array.isArray(s)?u.push(...s):ca(s)&&i?u.push(...s.split(i)):u.push(s)));const h=Mm(this.data,u);return!h&&!a&&!s&&r.indexOf(".")>-1&&(r=u[0],a=u[1],s=u.slice(2).join(".")),h||!c||!ca(s)?h:g1((y=(g=this.data)==null?void 0:g[r])==null?void 0:y[a],s,i)}addResource(r,a,s,n,i={silent:!1}){const c=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator;let u=[r,a];s&&(u=u.concat(c?s.split(c):s)),r.indexOf(".")>-1&&(u=r.split("."),n=a,a=u[1]),this.addNamespaces(a),Ew(this.data,u,n),i.silent||this.emit("added",r,a,s,n)}addResources(r,a,s,n={silent:!1}){for(const i in s)(ca(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,c={silent:!1,skipCopy:!1}){let u=[r,a];r.indexOf(".")>-1&&(u=r.split("."),n=s,s=a,a=u[1]),this.addNamespaces(a);let h=Mm(this.data,u)||{};c.skipCopy||(s=JSON.parse(JSON.stringify(s))),n?k4(h,s,i):h=Te(Te({},h),s),Ew(this.data,u,h),c.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 N4={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,r,a,s,n){return e.forEach(i=>{var c,u;r=(u=(c=this.processors[i])==null?void 0:c.process(r,a,s,n))!=null?u:r}),r}};const j4=Symbol("i18next/PATH_KEY");function _6(){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===j4?e:(e.push(n),a=Proxy.revocable(s,r),a.proxy)},Proxy.revocable(Object.create(null),r).proxy}function x1(e,r){var s;const{[j4]:a}=e(_6());return a.join((s=r==null?void 0:r.keySeparator)!=null?s:".")}const Aw={},Cp=e=>!ca(e)&&typeof e!="boolean"&&typeof e!="number";class Lm extends fg{constructor(r,a={}){super(),u6(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],r,this),this.options=a,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Dl.create("translator")}changeLanguage(r){r&&(this.language=r)}exists(r,a={interpolation:{}}){const s=Te({},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=Cp(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 c=s&&r.indexOf(s)>-1,u=!this.options.userDefinedKeySeparator&&!a.keySeparator&&!this.options.userDefinedNsSeparator&&!a.nsSeparator&&!v6(r,s,n);if(c&&!u){const h=r.match(this.interpolator.nestingRegexp);if(h&&h.length>0)return{key:r,namespaces:ca(i)?[i]:i};const g=r.split(s);(s!==n||s===n&&this.options.ns.indexOf(g[0])>-1)&&(i=g.shift()),r=g.join(n)}return{key:r,namespaces:ca(i)?[i]:i}}translate(r,a,s){let n=typeof a=="object"?Te({},a):a;if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n=Te({},n)),n||(n={}),r==null)return"";typeof r=="function"&&(r=x1(r,Te(Te({},this.options),n))),Array.isArray(r)||(r=[String(r)]);const i=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,c=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:u,namespaces:h}=this.extractFromKey(r[r.length-1],n),g=h[h.length-1];let y=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;y===void 0&&(y=":");const w=n.lng||this.language,E=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((w==null?void 0:w.toLowerCase())==="cimode")return E?i?{res:`${g}${y}${u}`,usedKey:u,exactUsedKey:u,usedLng:w,usedNS:g,usedParams:this.getUsedParamsDetails(n)}:`${g}${y}${u}`:i?{res:u,usedKey:u,exactUsedKey:u,usedLng:w,usedNS:g,usedParams:this.getUsedParamsDetails(n)}:u;const S=this.resolve(r,n);let A=S==null?void 0:S.res;const C=(S==null?void 0:S.usedKey)||u,O=(S==null?void 0:S.exactUsedKey)||u,M=["[object Number]","[object Function]","[object RegExp]"],R=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,F=!this.i18nFormat||this.i18nFormat.handleAsObject,z=n.count!==void 0&&!ca(n.count),W=Lm.hasDefaultValue(n),X=z?this.pluralResolver.getSuffix(w,n.count,n):"",B=n.ordinal&&z?this.pluralResolver.getSuffix(w,n.count,{ordinal:!1}):"",Y=z&&!n.ordinal&&n.count===0,G=Y&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${X}`]||n[`defaultValue${B}`]||n.defaultValue;let ie=A;F&&!A&&W&&(ie=G);const fe=Cp(ie),K=Object.prototype.toString.apply(ie);if(F&&ie&&fe&&M.indexOf(K)<0&&!(ca(R)&&Array.isArray(ie))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const ke=this.options.returnedObjectHandler?this.options.returnedObjectHandler(C,ie,Ke(Te({},n),{ns:h})):`key '${u} (${this.language})' returned an object instead of string.`;return i?(S.res=ke,S.usedParams=this.getUsedParamsDetails(n),S):ke}if(c){const ke=Array.isArray(ie),ge=ke?[]:{},re=ke?O:C;for(const we in ie)if(Object.prototype.hasOwnProperty.call(ie,we)){const ee=`${re}${c}${we}`;W&&!A?ge[we]=this.translate(ee,Ke(Te({},n),{defaultValue:Cp(G)?G[we]:void 0,joinArrays:!1,ns:h})):ge[we]=this.translate(ee,Ke(Te({},n),{joinArrays:!1,ns:h})),ge[we]===ee&&(ge[we]=ie[we])}A=ge}}else if(F&&ca(R)&&Array.isArray(A))A=A.join(R),A&&(A=this.extendTranslation(A,r,n,s));else{let ke=!1,ge=!1;!this.isValidLookup(A)&&W&&(ke=!0,A=G),this.isValidLookup(A)||(ge=!0,A=u);const we=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&ge?void 0:A,ee=W&&G!==A&&this.options.updateMissing;if(ge||ke||ee){if(this.logger.log(ee?"updateKey":"missingKey",w,g,u,ee?G:A),c){const te=this.resolve(u,Ke(Te({},n),{keySeparator:!1}));te&&te.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 ve=[];const ce=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ce&&ce[0])for(let te=0;te<ce.length;te++)ve.push(ce[te]);else this.options.saveMissingTo==="all"?ve=this.languageUtils.toResolveHierarchy(n.lng||this.language):ve.push(n.lng||this.language);const ye=(te,q,J)=>{var oe;const ae=W&&J!==A?J:we;this.options.missingKeyHandler?this.options.missingKeyHandler(te,g,q,ae,ee,n):(oe=this.backendConnector)!=null&&oe.saveMissing&&this.backendConnector.saveMissing(te,g,q,ae,ee,n),this.emit("missingKey",te,g,q,A)};this.options.saveMissing&&(this.options.saveMissingPlurals&&z?ve.forEach(te=>{const q=this.pluralResolver.getSuffixes(te,n);Y&&n[`defaultValue${this.options.pluralSeparator}zero`]&&q.indexOf(`${this.options.pluralSeparator}zero`)<0&&q.push(`${this.options.pluralSeparator}zero`),q.forEach(J=>{ye([te],u+J,n[`defaultValue${J}`]||G)})}):ye(ve,u,G))}A=this.extendTranslation(A,r,n,S,s),ge&&A===u&&this.options.appendNamespaceToMissingKey&&(A=`${g}${y}${u}`),(ge||ke)&&this.options.parseMissingKeyHandler&&(A=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${g}${y}${u}`:u,ke?A:void 0,n))}return i?(S.res=A,S.usedParams=this.getUsedParamsDetails(n),S):A}extendTranslation(r,a,s,n,i){var h,g;if((h=this.i18nFormat)!=null&&h.parse)r=this.i18nFormat.parse(r,Te(Te({},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(Ke(Te({},s),{interpolation:Te(Te({},this.options.interpolation),s.interpolation)}));const y=ca(r)&&(((g=s==null?void 0:s.interpolation)==null?void 0:g.skipOnVariables)!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let w;if(y){const S=r.match(this.interpolator.nestingRegexp);w=S&&S.length}let E=s.replace&&!ca(s.replace)?s.replace:s;if(this.options.interpolation.defaultVariables&&(E=Te(Te({},this.options.interpolation.defaultVariables),E)),r=this.interpolator.interpolate(r,E,s.lng||this.language||n.usedLng,s),y){const S=r.match(this.interpolator.nestingRegexp),A=S&&S.length;w<A&&(s.nest=!1)}!s.lng&&n&&n.res&&(s.lng=this.language||n.usedLng),s.nest!==!1&&(r=this.interpolator.nest(r,(...S)=>(i==null?void 0:i[0])===S[0]&&!s.context?(this.logger.warn(`It seems you are nesting recursively key: ${S[0]} in key: ${a[0]}`),null):this.translate(...S,a),s)),s.interpolation&&this.interpolator.reset()}const c=s.postProcess||this.options.postProcess,u=ca(c)?[c]:c;return r!=null&&(u!=null&&u.length)&&s.applyPostProcessor!==!1&&(r=N4.handle(u,r,a,this.options&&this.options.postProcessPassResolved?Te({i18nResolved:Ke(Te({},n),{usedParams:this.getUsedParamsDetails(s)})},s):s,this)),r}resolve(r,a={}){let s,n,i,c,u;return ca(r)&&(r=[r]),r.forEach(h=>{if(this.isValidLookup(s))return;const g=this.extractFromKey(h,a),y=g.key;n=y;let w=g.namespaces;this.options.fallbackNS&&(w=w.concat(this.options.fallbackNS));const E=a.count!==void 0&&!ca(a.count),S=E&&!a.ordinal&&a.count===0,A=a.context!==void 0&&(ca(a.context)||typeof a.context=="number")&&a.context!=="",C=a.lngs?a.lngs:this.languageUtils.toResolveHierarchy(a.lng||this.language,a.fallbackLng);w.forEach(O=>{var M,R;this.isValidLookup(s)||(u=O,!Aw[`${C[0]}-${O}`]&&((M=this.utils)!=null&&M.hasLoadedNamespace)&&!((R=this.utils)!=null&&R.hasLoadedNamespace(u))&&(Aw[`${C[0]}-${O}`]=!0,this.logger.warn(`key "${n}" for languages "${C.join(", ")}" won't get resolved as namespace "${u}" 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!!!")),C.forEach(F=>{var X;if(this.isValidLookup(s))return;c=F;const z=[y];if((X=this.i18nFormat)!=null&&X.addLookupKeys)this.i18nFormat.addLookupKeys(z,y,F,O,a);else{let B;E&&(B=this.pluralResolver.getSuffix(F,a.count,a));const Y=`${this.options.pluralSeparator}zero`,G=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(E&&(a.ordinal&&B.indexOf(G)===0&&z.push(y+B.replace(G,this.options.pluralSeparator)),z.push(y+B),S&&z.push(y+Y)),A){const ie=`${y}${this.options.contextSeparator||"_"}${a.context}`;z.push(ie),E&&(a.ordinal&&B.indexOf(G)===0&&z.push(ie+B.replace(G,this.options.pluralSeparator)),z.push(ie+B),S&&z.push(ie+Y))}}let W;for(;W=z.pop();)this.isValidLookup(s)||(i=W,s=this.getResource(F,O,W,a))}))})}),{res:s,usedKey:n,exactUsedKey:i,usedLng:c,usedNS:u}}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&&!ca(r.replace);let n=s?r.replace:r;if(s&&typeof r.count!="undefined"&&(n.count=r.count),this.options.interpolation.defaultVariables&&(n=Te(Te({},this.options.interpolation.defaultVariables),n)),!s){n=Te({},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 Ow{constructor(r){this.options=r,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Dl.create("languageUtils")}getScriptPartFromCode(r){if(r=kf(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=kf(r),!r||r.indexOf("-")<0)return r;const a=r.split("-");return this.formatLanguageCode(a[0])}formatLanguageCode(r){if(ca(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(c=>{if(c===i)return c;if(!(c.indexOf("-")<0&&i.indexOf("-")<0)&&(c.indexOf("-")>0&&i.indexOf("-")<0&&c.substring(0,c.indexOf("-"))===i||c.indexOf(i)===0&&i.length>1))return c})}),a||(a=this.getFallbackCodes(this.options.fallbackLng)[0]),a}getFallbackCodes(r,a){if(!r)return[];if(typeof r=="function"&&(r=r(a)),ca(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=c=>{c&&(this.isSupportedCode(c)?n.push(c):this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`))};return ca(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))):ca(r)&&i(this.formatLanguageCode(r)),s.forEach(c=>{n.indexOf(c)<0&&i(this.formatLanguageCode(c))}),n}}const Dw={zero:0,one:1,two:2,few:3,many:4,other:5},Rw={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class k6{constructor(r,a={}){this.languageUtils=r,this.options=a,this.logger=Dl.create("pluralResolver"),this.pluralRulesCache={}}addRule(r,a){this.rules[r]=a}clearCache(){this.pluralRulesCache={}}getRule(r,a={}){const s=kf(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 c;try{c=new Intl.PluralRules(s,{type:n})}catch(u){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),Rw;if(!r.match(/-|_/))return Rw;const h=this.languageUtils.getLanguagePartFromCode(r);c=this.getRule(h,a)}return this.pluralRulesCache[i]=c,c}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)=>Dw[n]-Dw[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 Fw=(e,r,a,s=".",n=!0)=>{let i=m6(e,r,a);return!i&&n&&ca(a)&&(i=g1(e,a,s),i===void 0&&(i=g1(r,a,s))),i},Ep=e=>e.replace(/\$/g,"$$$$");class Iw{constructor(r={}){var a;this.logger=Dl.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:c,suffix:u,suffixEscaped:h,formatSeparator:g,unescapeSuffix:y,unescapePrefix:w,nestingPrefix:E,nestingPrefixEscaped:S,nestingSuffix:A,nestingSuffixEscaped:C,nestingOptionsSeparator:O,maxReplaces:M,alwaysFormat:R}=r.interpolation;this.escape=a!==void 0?a:x6,this.escapeValue=s!==void 0?s:!0,this.useRawValueToEscape=n!==void 0?n:!1,this.prefix=i?N0(i):c||"{{",this.suffix=u?N0(u):h||"}}",this.formatSeparator=g||",",this.unescapePrefix=y?"":w||"-",this.unescapeSuffix=this.unescapePrefix?"":y||"",this.nestingPrefix=E?N0(E):S||N0("$t("),this.nestingSuffix=A?N0(A):C||N0(")"),this.nestingOptionsSeparator=O||",",this.maxReplaces=M||1e3,this.alwaysFormat=R!==void 0?R:!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 S;let i,c,u;const h=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},g=A=>{if(A.indexOf(this.formatSeparator)<0){const R=Fw(a,h,A,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(R,void 0,s,Ke(Te(Te({},n),a),{interpolationkey:A})):R}const C=A.split(this.formatSeparator),O=C.shift().trim(),M=C.join(this.formatSeparator).trim();return this.format(Fw(a,h,O,this.options.keySeparator,this.options.ignoreJSONStructure),M,s,Ke(Te(Te({},n),a),{interpolationkey:O}))};this.resetRegExp();const y=(n==null?void 0:n.missingInterpolationHandler)||this.options.missingInterpolationHandler,w=((S=n==null?void 0:n.interpolation)==null?void 0:S.skipOnVariables)!==void 0?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:A=>Ep(A)},{regex:this.regexp,safeValue:A=>this.escapeValue?Ep(this.escape(A)):Ep(A)}].forEach(A=>{for(u=0;i=A.regex.exec(r);){const C=i[1].trim();if(c=g(C),c===void 0)if(typeof y=="function"){const M=y(r,i,n);c=ca(M)?M:""}else if(n&&Object.prototype.hasOwnProperty.call(n,C))c="";else if(w){c=i[0];continue}else this.logger.warn(`missed to pass in variable ${C} for interpolating ${r}`),c="";else!ca(c)&&!this.useRawValueToEscape&&(c=jw(c));const O=A.safeValue(c);if(r=r.replace(i[0],O),w?(A.regex.lastIndex+=c.length,A.regex.lastIndex-=i[0].length):A.regex.lastIndex=0,u++,u>=this.maxReplaces)break}}),r}nest(r,a,s={}){let n,i,c;const u=(h,g)=>{var C;const y=this.nestingOptionsSeparator;if(h.indexOf(y)<0)return h;const w=h.split(new RegExp(`${y}[ ]*{`));let E=`{${w[1]}`;h=w[0],E=this.interpolate(E,c);const S=E.match(/'/g),A=E.match(/"/g);(((C=S==null?void 0:S.length)!=null?C:0)%2===0&&!A||A.length%2!==0)&&(E=E.replace(/'/g,'"'));try{c=JSON.parse(E),g&&(c=Te(Te({},g),c))}catch(O){return this.logger.warn(`failed parsing options string in nesting for key ${h}`,O),`${h}${y}${E}`}return c.defaultValue&&c.defaultValue.indexOf(this.prefix)>-1&&delete c.defaultValue,h};for(;n=this.nestingRegexp.exec(r);){let h=[];c=Te({},s),c=c.replace&&!ca(c.replace)?c.replace:c,c.applyPostProcessor=!1,delete c.defaultValue;const g=/{.*}/.test(n[1])?n[1].lastIndexOf("}")+1:n[1].indexOf(this.formatSeparator);if(g!==-1&&(h=n[1].slice(g).split(this.formatSeparator).map(y=>y.trim()).filter(Boolean),n[1]=n[1].slice(0,g)),i=a(u.call(this,n[1].trim(),c),c),i&&n[0]===r&&!ca(i))return i;ca(i)||(i=jw(i)),i||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${r}`),i=""),h.length&&(i=h.reduce((y,w)=>this.format(y,w,s.lng,Ke(Te({},s),{interpolationkey:n[1].trim()})),i.trim())),r=r.replace(n[0],i),this.regexp.lastIndex=0}return r}}const N6=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(c=>{if(c){const[u,...h]=c.split(":"),g=h.join(":").trim().replace(/^'+|'+$/g,""),y=u.trim();a[y]||(a[y]=g),g==="false"&&(a[y]=!1),g==="true"&&(a[y]=!0),isNaN(g)||(a[y]=parseInt(g,10))}})}return{formatName:r,formatOptions:a}},Mw=e=>{const r={};return(a,s,n)=>{let i=n;n&&n.interpolationkey&&n.formatParams&&n.formatParams[n.interpolationkey]&&n[n.interpolationkey]&&(i=Ke(Te({},i),{[n.interpolationkey]:void 0}));const c=s+JSON.stringify(i);let u=r[c];return u||(u=e(kf(s),n),r[c]=u),u(a)}},j6=e=>(r,a,s)=>e(kf(a),s)(r);class S6{constructor(r={}){this.logger=Dl.create("formatter"),this.options=r,this.init(r)}init(r,a={interpolation:{}}){this.formatSeparator=a.interpolation.formatSeparator||",";const s=a.cacheInBuiltFormats?Mw:j6;this.formats={number:s((n,i)=>{const c=new Intl.NumberFormat(n,Te({},i));return u=>c.format(u)}),currency:s((n,i)=>{const c=new Intl.NumberFormat(n,Ke(Te({},i),{style:"currency"}));return u=>c.format(u)}),datetime:s((n,i)=>{const c=new Intl.DateTimeFormat(n,Te({},i));return u=>c.format(u)}),relativetime:s((n,i)=>{const c=new Intl.RelativeTimeFormat(n,Te({},i));return u=>c.format(u,i.range||"day")}),list:s((n,i)=>{const c=new Intl.ListFormat(n,Te({},i));return u=>c.format(u)})}}add(r,a){this.formats[r.toLowerCase().trim()]=a}addCached(r,a){this.formats[r.toLowerCase().trim()]=Mw(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(u=>u.indexOf(")")>-1)){const u=i.findIndex(h=>h.indexOf(")")>-1);i[0]=[i[0],...i.splice(1,u)].join(this.formatSeparator)}return i.reduce((u,h)=>{var w;const{formatName:g,formatOptions:y}=N6(h);if(this.formats[g]){let E=u;try{const S=((w=n==null?void 0:n.formatParams)==null?void 0:w[n.interpolationkey])||{},A=S.locale||S.lng||n.locale||n.lng||s;E=this.formats[g](u,A,Te(Te(Te({},y),n),S))}catch(S){this.logger.warn(S)}return E}else this.logger.warn(`there was no format function for ${g}`);return u},r)}}const C6=(e,r)=>{e.pending[r]!==void 0&&(delete e.pending[r],e.pendingCount--)};class E6 extends fg{constructor(r,a,s,n={}){var i,c;super(),this.backend=r,this.store=a,this.services=s,this.languageUtils=s.languageUtils,this.options=n,this.logger=Dl.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=[],(c=(i=this.backend)==null?void 0:i.init)==null||c.call(i,s,n.backend,n)}queueLoad(r,a,s,n){const i={},c={},u={},h={};return r.forEach(g=>{let y=!0;a.forEach(w=>{const E=`${g}|${w}`;!s.reload&&this.store.hasResourceBundle(g,w)?this.state[E]=2:this.state[E]<0||(this.state[E]===1?c[E]===void 0&&(c[E]=!0):(this.state[E]=1,y=!1,c[E]===void 0&&(c[E]=!0),i[E]===void 0&&(i[E]=!0),h[w]===void 0&&(h[w]=!0)))}),y||(u[g]=!0)}),(Object.keys(i).length||Object.keys(c).length)&&this.queue.push({pending:c,pendingCount:Object.keys(c).length,loaded:{},errors:[],callback:n}),{toLoad:Object.keys(i),pending:Object.keys(c),toLoadLanguages:Object.keys(u),toLoadNamespaces:Object.keys(h)}}loaded(r,a,s){const n=r.split("|"),i=n[0],c=n[1];a&&this.emit("failedLoading",i,c,a),!a&&s&&this.store.addResourceBundle(i,c,s,void 0,void 0,{skipCopy:!0}),this.state[r]=a?-1:2,a&&s&&(this.state[r]=0);const u={};this.queue.forEach(h=>{h6(h.loaded,[i],c),C6(h,r),a&&h.errors.push(a),h.pendingCount===0&&!h.done&&(Object.keys(h.loaded).forEach(g=>{u[g]||(u[g]={});const y=h.loaded[g];y.length&&y.forEach(w=>{u[g][w]===void 0&&(u[g][w]=!0)})}),h.done=!0,h.errors.length?h.callback(h.errors):h.callback())}),this.emit("loaded",u),this.queue=this.queue.filter(h=>!h.done)}read(r,a,s,n=0,i=this.retryTimeout,c){if(!r.length)return c(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:r,ns:a,fcName:s,tried:n,wait:i,callback:c});return}this.readingCalls++;const u=(g,y)=>{if(this.readingCalls--,this.waitingReads.length>0){const w=this.waitingReads.shift();this.read(w.lng,w.ns,w.fcName,w.tried,w.wait,w.callback)}if(g&&y&&n<this.maxRetries){setTimeout(()=>{this.read.call(this,r,a,s,n+1,i*2,c)},i);return}c(g,y)},h=this.backend[s].bind(this.backend);if(h.length===2){try{const g=h(r,a);g&&typeof g.then=="function"?g.then(y=>u(null,y)).catch(u):u(null,g)}catch(g){u(g)}return}return h(r,a,u)}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();ca(r)&&(r=this.languageUtils.toResolveHierarchy(r)),ca(a)&&(a=[a]);const i=this.queueLoad(r,a,s,n);if(!i.toLoad.length)return i.pending.length||n(),null;i.toLoad.forEach(c=>{this.loadOne(c)})}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,(c,u)=>{c&&this.logger.warn(`${a}loading namespace ${i} for language ${n} failed`,c),!c&&u&&this.logger.log(`${a}loaded namespace ${i} for language ${n}`,u),this.loaded(r,c,u)})}saveMissing(r,a,s,n,i,c={},u=()=>{}){var h,g,y,w,E;if((g=(h=this.services)==null?void 0:h.utils)!=null&&g.hasLoadedNamespace&&!((w=(y=this.services)==null?void 0:y.utils)!=null&&w.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((E=this.backend)!=null&&E.create){const S=Ke(Te({},c),{isUpdate:i}),A=this.backend.create.bind(this.backend);if(A.length<6)try{let C;A.length===5?C=A(r,a,s,n,S):C=A(r,a,s,n),C&&typeof C.then=="function"?C.then(O=>u(null,O)).catch(u):u(null,C)}catch(C){u(C)}else A(r,a,s,n,u,S)}!r||!r[0]||this.store.addResource(r[0],a,s,n)}}}const Pw=()=>({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]),ca(e[1])&&(r.defaultValue=e[1]),ca(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}),Lw=e=>{var r,a;return ca(e.ns)&&(e.ns=[e.ns]),ca(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),ca(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},sm=()=>{},T6=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(a=>{typeof e[a]=="function"&&(e[a]=e[a].bind(e))})};class df extends fg{constructor(r={},a){if(super(),this.options=Lw(r),this.services={},this.logger=Dl,this.modules={external:[]},T6(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&&(ca(r.ns)?r.defaultNS=r.ns:r.ns.indexOf("translation")<0&&(r.defaultNS=r.ns[0]));const s=Pw();this.options=Te(Te(Te({},s),this.options),Lw(r)),this.options.interpolation=Te(Te({},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=g=>g?typeof g=="function"?new g:g:null;if(!this.options.isClone){this.modules.logger?Dl.init(n(this.modules.logger),this.options):Dl.init(null,this.options);let g;this.modules.formatter?g=this.modules.formatter:g=S6;const y=new Ow(this.options);this.store=new Tw(this.options.resources,this.options);const w=this.services;w.logger=Dl,w.resourceStore=this.store,w.languageUtils=y,w.pluralResolver=new k6(y,{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"),g&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(w.formatter=n(g),w.formatter.init&&w.formatter.init(w,this.options),this.options.interpolation.format=w.formatter.format.bind(w.formatter)),w.interpolator=new Iw(this.options),w.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},w.backendConnector=new E6(n(this.modules.backend),w.resourceStore,w,this.options),w.backendConnector.on("*",(S,...A)=>{this.emit(S,...A)}),this.modules.languageDetector&&(w.languageDetector=n(this.modules.languageDetector),w.languageDetector.init&&w.languageDetector.init(w,this.options.detection,this.options)),this.modules.i18nFormat&&(w.i18nFormat=n(this.modules.i18nFormat),w.i18nFormat.init&&w.i18nFormat.init(this)),this.translator=new Lm(this.services,this.options),this.translator.on("*",(S,...A)=>{this.emit(S,...A)}),this.modules.external.forEach(S=>{S.init&&S.init(this)})}if(this.format=this.options.interpolation.format,a||(a=sm),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const g=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);g.length>0&&g[0]!=="dev"&&(this.options.lng=g[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(g=>{this[g]=(...y)=>this.store[g](...y)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(g=>{this[g]=(...y)=>(this.store[g](...y),this)});const u=qu(),h=()=>{const g=(y,w)=>{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),u.resolve(w),a(y,w)};if(this.languages&&!this.isInitialized)return g(null,this.t.bind(this));this.changeLanguage(this.options.lng,g)};return this.options.resources||!this.options.initAsync?h():setTimeout(h,0),u}loadResources(r,a=sm){var i,c;let s=a;const n=ca(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 u=[],h=g=>{if(!g||g==="cimode")return;this.services.languageUtils.toResolveHierarchy(g).forEach(w=>{w!=="cimode"&&u.indexOf(w)<0&&u.push(w)})};n?h(n):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(y=>h(y)),(c=(i=this.options.preload)==null?void 0:i.forEach)==null||c.call(i,g=>h(g)),this.services.backendConnector.load(u,this.options.ns,g=>{!g&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),s(g)})}else s(null)}reloadResources(r,a,s){const n=qu();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=sm),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"&&N4.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=qu();this.emit("languageChanging",r);const n=u=>{this.language=u,this.languages=this.services.languageUtils.toResolveHierarchy(u),this.resolvedLanguage=void 0,this.setResolvedLanguage(u)},i=(u,h)=>{h?this.isLanguageChangingTo===r&&(n(h),this.translator.changeLanguage(h),this.isLanguageChangingTo=void 0,this.emit("languageChanged",h),this.logger.log("languageChanged",h)):this.isLanguageChangingTo=void 0,s.resolve((...g)=>this.t(...g)),a&&a(u,(...g)=>this.t(...g))},c=u=>{var y,w;!r&&!u&&this.services.languageDetector&&(u=[]);const h=ca(u)?u:u&&u[0],g=this.store.hasLanguageSomeTranslations(h)?h:this.services.languageUtils.getBestMatchFromCodes(ca(u)?[u]:u);g&&(this.language||n(g),this.translator.language||this.translator.changeLanguage(g),(w=(y=this.services.languageDetector)==null?void 0:y.cacheUserLanguage)==null||w.call(y,g)),this.loadResources(g,E=>{i(E,g)})};return!r&&this.services.languageDetector&&!this.services.languageDetector.async?c(this.services.languageDetector.detect()):!r&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(c):this.services.languageDetector.detect(c):c(r),s}getFixedT(r,a,s){const n=(i,c,...u)=>{let h;typeof c!="object"?h=this.options.overloadTranslationOptionHandler([i,c].concat(u)):h=Te({},c),h.lng=h.lng||n.lng,h.lngs=h.lngs||n.lngs,h.ns=h.ns||n.ns,h.keyPrefix!==""&&(h.keyPrefix=h.keyPrefix||s||n.keyPrefix);const g=this.options.keySeparator||".";let y;return h.keyPrefix&&Array.isArray(i)?y=i.map(w=>(typeof w=="function"&&(w=x1(w,Te(Te({},this.options),c))),`${h.keyPrefix}${g}${w}`)):(typeof i=="function"&&(i=x1(i,Te(Te({},this.options),c))),y=h.keyPrefix?`${h.keyPrefix}${g}${i}`:i),this.t(y,h)};return ca(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 c=(u,h)=>{const g=this.services.backendConnector.state[`${u}|${h}`];return g===-1||g===0||g===2};if(a.precheck){const u=a.precheck(this,c);if(u!==void 0)return u}return!!(this.hasResourceBundle(s,r)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||c(s,r)&&(!n||c(i,r)))}loadNamespaces(r,a){const s=qu();return this.options.ns?(ca(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=qu();ca(r)&&(r=[r]);const n=this.options.preload||[],i=r.filter(c=>n.indexOf(c)<0&&this.services.languageUtils.isSupportedCode(c));return i.length?(this.options.preload=n.concat(i),this.loadResources(c=>{s.resolve(),a&&a(c)}),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 c=new Intl.Locale(r);if(c&&c.getTextInfo){const u=c.getTextInfo();if(u&&u.direction)return u.direction}}catch(c){}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 Ow(Pw());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 df(r,a);return s.createInstance=df.createInstance,s}cloneInstance(r={},a=sm){const s=r.forkResourceStore;s&&delete r.forkResourceStore;const n=Ke(Te(Te({},this.options),r),{isClone:!0}),i=new df(n);if((r.debug!==void 0||r.prefix!==void 0)&&(i.logger=i.logger.clone(r)),["store","services","language"].forEach(u=>{i[u]=this[u]}),i.services=Te({},this.services),i.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},s){const u=Object.keys(this.store.data).reduce((h,g)=>(h[g]=Te({},this.store.data[g]),h[g]=Object.keys(h[g]).reduce((y,w)=>(y[w]=Te({},h[g][w]),y),h[g]),h),{});i.store=new Tw(u,n),i.services.resourceStore=i.store}return r.interpolation&&(i.services.interpolator=new Iw(n)),i.translator=new Lm(i.services,n),i.translator.on("*",(u,...h)=>{i.emit(u,...h)}),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 Zn=df.createInstance();Zn.createInstance;Zn.dir;Zn.init;Zn.loadResources;Zn.reloadResources;Zn.use;Zn.changeLanguage;Zn.getFixedT;Zn.t;Zn.exists;Zn.setDefaultNamespace;Zn.hasLoadedNamespace;Zn.loadNamespaces;Zn.loadLanguages;const A6=(e,r,a,s)=>{var i,c,u,h;const n=[a,Te({code:r},s||{})];if((c=(i=e==null?void 0:e.services)==null?void 0:i.logger)!=null&&c.forward)return e.services.logger.forward(n,"warn","react-i18next::",!0);Fd(n[0])&&(n[0]=`react-i18next:: ${n[0]}`),(h=(u=e==null?void 0:e.services)==null?void 0:u.logger)!=null&&h.warn?e.services.logger.warn(...n):console!=null&&console.warn&&console.warn(...n)},Bw={},S4=(e,r,a,s)=>{Fd(a)&&Bw[a]||(Fd(a)&&(Bw[a]=new Date),A6(e,r,a,s))},C4=(e,r)=>()=>{if(e.isInitialized)r();else{const a=()=>{setTimeout(()=>{e.off("initialized",a)},0),r()};e.on("initialized",a)}},p1=(e,r,a)=>{e.loadNamespaces(r,C4(e,a))},Uw=(e,r,a,s)=>{if(Fd(a)&&(a=[a]),e.options.preload&&e.options.preload.indexOf(r)>-1)return p1(e,a,s);a.forEach(n=>{e.options.ns.indexOf(n)<0&&e.options.ns.push(n)}),e.loadLanguages(r,C4(e,s))},O6=(e,r,a={})=>!r.languages||!r.languages.length?(S4(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}}),Fd=e=>typeof e=="string",D6=e=>typeof e=="object"&&e!==null,R6=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,F6={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},I6=e=>F6[e],M6=e=>e.replace(R6,I6);let y1={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:M6};const P6=(e={})=>{y1=Te(Te({},y1),e)},L6=()=>y1;let E4;const B6=e=>{E4=e},U6=()=>E4,z6={type:"3rdParty",init(e){P6(e.options.react),B6(e)}},W6=_.createContext();class H6{constructor(){this.usedNamespaces={}}addUsedNamespaces(r){r.forEach(a=>{this.usedNamespaces[a]||(this.usedNamespaces[a]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var Tp={exports:{}},Ap={};var zw;function $6(){if(zw)return Ap;zw=1;var e=ug();function r(w,E){return w===E&&(w!==0||1/w===1/E)||w!==w&&E!==E}var a=typeof Object.is=="function"?Object.is:r,s=e.useState,n=e.useEffect,i=e.useLayoutEffect,c=e.useDebugValue;function u(w,E){var S=E(),A=s({inst:{value:S,getSnapshot:E}}),C=A[0].inst,O=A[1];return i(function(){C.value=S,C.getSnapshot=E,h(C)&&O({inst:C})},[w,S,E]),n(function(){return h(C)&&O({inst:C}),w(function(){h(C)&&O({inst:C})})},[w]),c(S),S}function h(w){var E=w.getSnapshot;w=w.value;try{var S=E();return!a(w,S)}catch(A){return!0}}function g(w,E){return E()}var y=typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"?g:u;return Ap.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:y,Ap}var Ww;function V6(){return Ww||(Ww=1,Tp.exports=$6()),Tp.exports}var G6=V6();const Y6=(e,r)=>Fd(r)?r:D6(r)&&Fd(r.defaultValue)?r.defaultValue:Array.isArray(e)?e[e.length-1]:e,q6={t:Y6,ready:!1},X6=()=>()=>{},Rr=(e,r={})=>{var G,ie,fe;const{i18n:a}=r,{i18n:s,defaultNS:n}=_.useContext(W6)||{},i=a||s||U6();i&&!i.reportNamespaces&&(i.reportNamespaces=new H6),i||S4(i,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const c=_.useMemo(()=>{var K;return Te(Te(Te({},L6()),(K=i==null?void 0:i.options)==null?void 0:K.react),r)},[i,r]),{useSuspense:u,keyPrefix:h}=c,g=n||((G=i==null?void 0:i.options)==null?void 0:G.defaultNS),y=Fd(g)?[g]:g||["translation"],w=_.useMemo(()=>y,y);(fe=(ie=i==null?void 0:i.reportNamespaces)==null?void 0:ie.addUsedNamespaces)==null||fe.call(ie,w);const E=_.useRef(0),S=_.useCallback(K=>{if(!i)return X6;const{bindI18n:ke,bindI18nStore:ge}=c,re=()=>{E.current+=1,K()};return ke&&i.on(ke,re),ge&&i.store.on(ge,re),()=>{ke&&ke.split(" ").forEach(we=>i.off(we,re)),ge&&ge.split(" ").forEach(we=>i.store.off(we,re))}},[i,c]),A=_.useRef(),C=_.useCallback(()=>{if(!i)return q6;const K=!!(i.isInitialized||i.initializedStoreOnce)&&w.every(ve=>O6(ve,i,c)),ke=r.lng||i.language,ge=E.current,re=A.current;if(re&&re.ready===K&&re.lng===ke&&re.keyPrefix===h&&re.revision===ge)return re;const ee={t:i.getFixedT(ke,c.nsMode==="fallback"?w:w[0],h),ready:K,lng:ke,keyPrefix:h,revision:ge};return A.current=ee,ee},[i,w,h,c,r.lng]),[O,M]=_.useState(0),{t:R,ready:F}=G6.useSyncExternalStore(S,C,C);_.useEffect(()=>{if(i&&!F&&!u){const K=()=>M(ke=>ke+1);r.lng?Uw(i,r.lng,w,K):p1(i,w,K)}},[i,r.lng,w,F,u,O]);const z=i||{},W=_.useRef(null),X=_.useRef(),B=K=>{const ke=Object.getOwnPropertyDescriptors(K);ke.__original&&delete ke.__original;const ge=Object.create(Object.getPrototypeOf(K),ke);if(!Object.prototype.hasOwnProperty.call(ge,"__original"))try{Object.defineProperty(ge,"__original",{value:K,writable:!1,enumerable:!1,configurable:!1})}catch(re){}return ge},Y=_.useMemo(()=>{const K=z,ke=K==null?void 0:K.language;let ge=K;K&&(W.current&&W.current.__original===K?X.current!==ke?(ge=B(K),W.current=ge,X.current=ke):ge=W.current:(ge=B(K),W.current=ge,X.current=ke));const re=[R,ge,F];return re.t=R,re.i18n=ge,re.ready=F,re},[R,z,F,z.resolvedLanguage,z.language,z.languages]);if(i&&u&&!F)throw new Promise(K=>{const ke=()=>K();r.lng?Uw(i,r.lng,w,ke):p1(i,w,ke)});return Y},{slice:Z6,forEach:K6}=[];function J6(e){return K6.call(Z6.call(arguments,1),r=>{if(r)for(const a in r)e[a]===void 0&&(e[a]=r[a])}),e}function Q6(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 Hw=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,e5=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 c=s.maxAge-0;if(Number.isNaN(c))throw new Error("maxAge should be a Number");i+=`; Max-Age=${Math.floor(c)}`}if(s.domain){if(!Hw.test(s.domain))throw new TypeError("option domain is invalid");i+=`; Domain=${s.domain}`}if(s.path){if(!Hw.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},$w={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=e5(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 t5={name:"cookie",lookup(e){let{lookupCookie:r}=e;if(r&&typeof document!="undefined")return $w.read(r)||void 0},cacheUserLanguage(e,r){let{lookupCookie:a,cookieMinutes:s,cookieDomain:n,cookieOptions:i}=r;a&&typeof document!="undefined"&&$w.create(a,e,s,n,i)}},r5={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 c=n.substring(1).split("&");for(let u=0;u<c.length;u++){const h=c[u].indexOf("=");h>0&&c[u].substring(0,h)===r&&(a=c[u].substring(h+1))}}return a}},a5={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 c=i.substring(1);if(r){const u=c.split("&");for(let h=0;h<u.length;h++){const g=u[h].indexOf("=");g>0&&u[h].substring(0,g)===r&&(s=u[h].substring(g+1))}}if(s)return s;if(!s&&a>-1){const u=i.match(/\/([a-zA-Z-]*)/g);return Array.isArray(u)?(n=u[typeof a=="number"?a:0])==null?void 0:n.replace("/",""):void 0}}}return s}};let j0=null;const Vw=()=>{if(j0!==null)return j0;try{if(j0=typeof window!="undefined"&&window.localStorage!==null,!j0)return!1;const e="i18next.translate.boo";window.localStorage.setItem(e,"foo"),window.localStorage.removeItem(e)}catch(e){j0=!1}return j0};var s5={name:"localStorage",lookup(e){let{lookupLocalStorage:r}=e;if(r&&Vw())return window.localStorage.getItem(r)||void 0},cacheUserLanguage(e,r){let{lookupLocalStorage:a}=r;a&&Vw()&&window.localStorage.setItem(a,e)}};let S0=null;const Gw=()=>{if(S0!==null)return S0;try{if(S0=typeof window!="undefined"&&window.sessionStorage!==null,!S0)return!1;const e="i18next.translate.boo";window.sessionStorage.setItem(e,"foo"),window.sessionStorage.removeItem(e)}catch(e){S0=!1}return S0};var n5={name:"sessionStorage",lookup(e){let{lookupSessionStorage:r}=e;if(r&&Gw())return window.sessionStorage.getItem(r)||void 0},cacheUserLanguage(e,r){let{lookupSessionStorage:a}=r;a&&Gw()&&window.sessionStorage.setItem(a,e)}},i5={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}},o5={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}},l5={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}},c5={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 T4=!1;try{document.cookie,T4=!0}catch(e){}const A4=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];T4||A4.splice(1,1);const d5=()=>({order:A4,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:e=>e});class O4{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=J6(a,this.options||{},d5()),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(t5),this.addDetector(r5),this.addDetector(s5),this.addDetector(n5),this.addDetector(i5),this.addDetector(o5),this.addDetector(l5),this.addDetector(c5),this.addDetector(a5)}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&&!Q6(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)}))}}O4.type="languageDetector";const u5={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')"},f5={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",sla:"Service Level Agreement (SLA)",support:"Support",inspection:"Inspection",deleteRequests:"Delete Requests",userProfile:"User Profile",dataImport:"Data Import"},h5={title:"Data Import",documentType:"Document Type",fileLabel:"Import file",fileHint:"Use .xlsx, .xls, or .csv. The first row must use the same field names as in the downloaded template.",toastImportSuccess:"Import completed.",toastImportPartial:"Completed with some issues — see the log below.",toastImportError:"Import finished with errors — see the log below.",toastImportStatus:"Import status: {{status}}",chooseFile:"Choose file",clearFile:"Remove file",downloadFile:"Download file",previewSaveHintPrefix:"Click on",previewSaveAction:"Save",previewSaveHintSuffix:"to add records to the system.",alignedWorkbookNotApplied:"The aligned workbook was not saved to your selection (validation did not finish successfully). Fix the issues above, then validation will replace the file with ERP-matched link values.",normalizationNotes:"Values aligned to existing masters (before import)",downloadTemplate:"Download template",startImport:"Start import",importing:"Importing…",templateDownloaded:"Template downloaded",progress:"{{done}} / {{total}} rows",importFinishedOk:"Import completed: {{count}} row(s) processed successfully.",importFinishedMixed:"Import finished: {{ok}} succeeded, {{fail}} failed — see log below.",logsTitle:"Import log",logRow:"Row",logStatus:"Status",logMessage:"Message",statusOk:"OK",statusFailed:"Failed",successImported:"Successfully imported {{name}}",importSummaryLine:"Successfully imported {{ok}} out of {{total}} rows.",importSummaryLineAllOk:"{{total}} out of {{total}} — all rows imported successfully.",importSummaryLineAllFailed:"No rows imported successfully ({{total}} row(s) failed).",importSummaryBadgeAll:"Success",importSummaryBadgePartial:"Partial success",importSummaryBadgeNone:"Failed",errors:{noFile:"Please choose a file first (.xlsx, .xls, or .csv).",noRows:"The file has no data rows.",noSchema:"Could not load Location fields. Try again or contact your administrator.",parseFailed:"Could not read the file: {{message}}",headerValidation:"Fix the column issues below before importing data rows.",previewNotReady:"Wait for file validation to finish before starting import.",fixPreviewFirst:"Resolve the issues below (or use Add actions) before starting import."},templateModal:{title:"Download template",fileType:"File type",fileTypeExcel:"Excel (.xlsx)",fileTypeCsv:"CSV",exportType:"Export type",exportTypeBlank:"Blank template",blankHint:"Only the header row is included — no data rows are exported.",selectFields:"Select columns",selectAll:"Select all",selectMandatory:"Select mandatory",unselectAll:"Unselect all",fieldsSelected:"columns selected",export:"Download",nothingSelected:"Select at least one column."},locationQuickHint:"Create or review locations before linking them in your import file.",btnAddLocation:"Add location",btnViewLocations:"View all locations",previewTitle:"Import file errors and warnings",previewHeaderIssue:"Header / column map",previewRowHeading:"Row {{row}}",previewColumnHeading:"Column {{n}} ({{label}})",previewGenericHeading:"Import",validatingFile:"Validating file…",addMaster:"Add {{doctype}}",mastersCreated:"Created {{count}} master record(s). Preview refreshed."},m5={title:"Locations",subtitle:"Browse location records in the system.",listTotal:"{{count}} location(s) total",backToDataImport:"← Data import",backToList:"Back to locations",viewRow:"View",editRow:"Edit",deleteRow:"Delete",deleteConfirm:'Delete location "{{name}}"? This cannot be undone.',deleteSuccess:"Location deleted.",saveMissingName:"Save completed but the server did not return a location ID.",add:"Add location",searchPlaceholder:"Search by name or location name…",loading:"Loading locations…",empty:"No locations match your search.",yes:"Yes",no:"No",colActions:"Actions",open:"Open",refresh:"Refresh list",paginationLabel:"locations",newTitle:"New location",roomNoPlaceholder:"Room number or name",locationMasterPlaceholder:"Location (master) name",createRoom:"Create",createLocationMaster:"Create",viewLocation:"View",viewLocationDesk:"Open Location in Desk",viewLocationDetails:"View location details",fieldRoom:"Room",formHintDataImportStyle:"Use Building and Department search above. For Room and Location, type a value or use Add room / Add location to create a master — no pick list from existing records.",roomTextPlaceholder:"Type or add a room",locationTextPlaceholder:"Type or add a location",addRoomAction:"Add room",addLocationAction:"Add location",sectionDetails:"Location details",fieldLocationId:"Location ID",fieldLocationName:"Location name",fieldLocationNamePlaceholder:"Enter location name",fieldContainsSubLocations:"This location contains sub-locations",fieldContainsSubLocationsHelp:"Enable if child locations can be added under this one.",fieldDepartment:"Department",fieldDepartmentPlaceholder:"Department (optional)",fieldParent:"Parent location",fieldParentPlaceholder:"Select parent (optional)",fieldParentPlaceholderDesk:"Select parent location (optional)",mapTitle:"Map (latitude & longitude)",mapHint:"Click the map to place the pin, or drag the pin to adjust coordinates.",fieldIsContainer:"Is container",fieldIsContainerHelp:"Check if it is a hydroponic unit.",fieldIsGroup:"Is group",fieldCustomHospital:"Is hospital",fieldCustomWoType:"Is WO type",fieldLatitude:"Latitude",fieldLatitudePlaceholder:"e.g., 24.7136",fieldLongitude:"Longitude",fieldLongitudePlaceholder:"e.g., 46.6753",save:"Save",saved:"Location saved.",validationName:"Location name is required.",validationId:"Location ID is required.",errorDuplicateEntry:'Location name "{{name}}" already exists. Choose a different name.',errorDuplicateGeneric:"This location name already exists. Use a unique location name.",fieldLabel:{building:"Building",department:"Department",room_no:"Room No",location:"Location",name:"ID",owner:"Owner",creation:"Created",modified:"Modified",modified_by:"Modified by",docstatus:"Doc status",idx:"Idx",location_name:"Location name",parent_location:"Parent",is_container:"Container",is_group:"Group",custom_is_hospital:"Hospital",custom_is_wo_type:"WO type",latitude:"Latitude",longitude:"Longitude",lft:"Lft",rgt:"Rgt"}},g5={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",forgotPasswordSent:"If that email is registered, password reset instructions have been sent.",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.",forgotPasswordClose:"Cancel",forgotPasswordTimeout:"The request took too long (email server may be slow). Please try again in a minute.",forgotPasswordCannotReset:"Password reset is not available for this account.",forgotPasswordFailed:"Could not send the reset email. Please try again, or contact support.",finishingSignOut:"Finishing sign-out…",afterPasswordResetSignIn:"Your password was updated. Please sign in with your new password.",resetPasswordTitle:"Reset password",resetNewPassword:"New password",resetConfirmPassword:"Confirm password",resetConfirm:"Confirm",resetInvalidLink:"This reset link is invalid or missing. Request a new one from the login page.",resetEnterPassword:"Please enter a new password.",resetPasswordMismatch:"Passwords do not match.",resetFailed:"Could not reset password. The link may have expired.",backToSignIn:"Back to sign in"},x5={title:"Dashboard",loading:"Loading dashboard...",totalAssets:"TOTAL NO. OF ASSETS",assetsDown:"Assets Down",openWorkOrders:"OPEN WORK ORDERS",workOrdersInProgress:"WORK ORDERS WORK 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"},p5={assetId:"Asset ID",assetName:"Asset Name",serialNumber:"Serial Number",localId:"Local ID",technicalDepartment:"Technical Department",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"},y5={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)"},b5={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."},v5={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",localId:"Local ID",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",placeholderLocalId:"e.g. LOC-001",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",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"}},w5=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","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!","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","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","civilWorkCategoryMandatory":"Please select a 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","serialNo":"Serial No","localId":"Local ID","enterLocalId":"Enter local ID","searchAssetByLocalId":"Search asset by local ID","pleaseEnterLocalIdToSearch":"Please enter a local ID to search","noAssetFoundWithLocalId":"No asset found with this local ID","assetNotAvailable":"This asset is not available (must be submitted and not deleted)","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"}}`),_5={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 "}},k5={title:"PPM",ppmDetails:"PPM Details",addPPM:"Add New PPM",periodicity:"Periodicity",dueDate:"Due Date",manageSchedules:"Manage PM Schedules",bulkScheduleGenerator:"Bulk schedule generator — filter assets, then configure and generate",filterAssets:"Filter assets",selectAssets:"Select assets",scheduleConfiguration:"Schedule configuration",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"}},N5={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 "}},j5={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"},S5={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",technicalDepartment:"Technical Department",selectTechnicalDepartment:"Select Technical Department",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 action cannot be undone.",backToInventory:"Back to Inventory",loadingItem:"Loading item...",errorLoadingItem:"Error Loading Item",createNewItem:"Create a 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 ",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 ",currentPage:"Current Page",currentPageCount:"Export {{count}} item on current page",allWithFilters:"All Records (with current filters)",allWithFiltersCount:"Export all {{count}} item 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 "}},C5={title:"Issues",issueDetails:"Issue Details",newIssue:"New Issue",addIssue:"Add New Issue",issueId:"Issue 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 issue subject",selectPriority:"Select priority",selectIssueType:"Select issue type",describeIssue:"Describe the issue in detail...",contactInformation:"Contact Information",createNewIssue:"Create a new support issue",resolution:"Resolution",describeResolution:"Describe how the issue was resolved...",selectCompany:"Select company",statusInformation:"Status Information",currentStatus:"Current Status",timeline:"Timeline",loadingIssues:"Loading issues...",errorLoadingIssues:"Error Loading Issues",deleteConfirmMessage:"Are you sure you want to delete this issue? This action cannot be undone.",deletedSuccessfully:"Issue deleted successfully!",listTitle:"Support Issues",listTotal:"Total",listSelected:"selected",statsTotalIssues:"Total Issues",statsOpen:"Open",statsResolved:"Resolved",statsClosed:"Closed",export:{title:"Export Issues",selectData:"Select Data to Export",selectedRows:"Selected Rows",selectedCount:"Export {{count}} selected issue ",currentPage:"Current Page",currentPageCount:"Export {{count}} issue on current page",allWithFilters:"All Records (with current filters)",allWithFiltersCount:"Export all {{count}} issue 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 "},status:{open:"Open",replied:"Replied",on_hold:"On Hold",resolved:"Resolved",closed:"Closed"},priority:{low:"Low",medium:"Medium",high:"High",critical:"Critical"}},E5={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 terms.",noUsersAvailable:"No users available.",backToDashboard:"Back to Dashboard",refresh:"Refresh",active:"Active",inactive:"Inactive",noEmail:"No email",created:"Created"},T5={title:"Events",eventDetails:"Event Details",newEvent:"New Event",addEvent:"Add New Event",upcomingEvents:"Upcoming Events",eventsFromFrappe:"Events from your Frappe backend",noEventsFound:"No events found",noEventsScheduled:"No events are currently scheduled.",refreshEvents:"Refresh Events"},A5={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:"issues",teams:"teams",inspections:"inspections",plans:"plans"},O5={loading:"Loading...",noResultsFound:"No results found",createNewDoctype:"Create New {{doctype}}",selectLabel:"Select {{label}}"},D5={loadingSupportPlans:"Loading support plans...",errorLoadingSupportPlans:"Error Loading Support Plans",deleteConfirmMessage:"Are you sure you want to delete this support plan? This action 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"},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 ",currentPage:"Current Page",currentPageCount:"Export {{count}} plan on current page",allWithFilters:"All Records (with current filters)",allWithFiltersCount:"Export all {{count}} plan ",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 "}},R5={title:"Inspections",loadingInspections:"Loading inspections...",errorLoadingInspections:"Error Loading Inspections",deleteConfirmMessage:"Are you sure you want to delete this inspection? This action cannot be undone.",inspectionId:"Inspection ID",deleteInspection:"Delete Inspection",deletedSuccessfully:"Inspection deleted successfully!",noInspectionsFound:"No inspections found",createFirstInspection:"Create your first inspection",type:"Inspection 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:"Status",filterWorkflow:"Workflow",filterType:"Type",filterWorkOrder:"Work Order",filterDepartment:"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",extensionNo:"Extension No",department:"Department",location:"Location",assignedTechnician:"Assigned Technician",selectedRows:"Selected Rows",selectedCount:"Export {{count}} selected inspection(s)",currentPage:"Current Page",currentPageCount:"Export {{count}} inspection(s) on current page",allWithFilters:"All Records (with current filters)",allWithFiltersCount:"Export all {{count}} inspection(s) 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(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)",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 inspection details...",errorLoading:"Error Loading Inspection",backToList:"Back to Inspections",newInspection:"New Inspection",inspectionDetails:"Inspection Details",createNewRecord:"Create a new inspection record",cancelInspection:"Cancel Inspection",cancelConfirmMessage:"Are you sure you want to cancel this inspection? This will mark the inspection as cancelled and you can then delete it if needed.",noGoBack:"No, Go Back",yesCancel:"Yes, Cancel",assignedEngineer:"Assigned Engineer",selectEngineer:"Select Engineer",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 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 & Response",observationNote:"Observation Note",placeholderObservation:"Enter observation notes...",technicalResponse:"Technical Response",placeholderTechnicalResponse:"Enter technical response...",linkedWorkOrder:"Linked Work Order",linkedCorrectiveWO:"Linked Corrective Work Order",readOnly:"Read-only",viewWorkOrder:"View Work Order",noLinkedWorkOrder:"No linked work order",workflowActions:"Workflow Actions",workflowProgress:"Workflow Progress",workControl:"Work Control",technicianStep:"Technician",supervisorStep:"Supervisor",draftStep:"Draft",closedStep:"Closed",statusInfo:"Status Info",documentStatus:"Document Status",woType:"WO Type",assignedTo:"Assigned To",submitted:"Submitted",cancelled:"Cancelled",added:"Added:",removed:"Removed:",modified:"Modified:",items:"item(s)",rows:"row(s)",activityLog:"Activity Log",activityLogRefreshed:"Activity log refreshed",refreshActivityLog:"Refresh activity log",noChangesRecorded:"No changes recorded yet",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:"Inspection cancelled successfully!",failedToCancel:"Failed to cancel: {{error}}",failedToSave:"Failed to save: {{error}}",failedToDelete:"Failed to delete: {{error}}",targetClosureMandatory:"Target Closure Date is mandatory to save.",attachmentMandatory:"Attachment is mandatory to save.",extensionMandatory:"Extension No is mandatory to save.",createdSuccessfully:"Inspection created successfully!",updatedSuccessfully:"Inspection updated successfully!",deletedSuccessfully:"Inspection deleted successfully!",inspectionDateInPast:"Inspection Date cannot be in the past.",targetClosureEarlier:"Target Closure Date cannot be earlier than Inspection Date.",targetClosureInPast:"Target Closure Date cannot be in the past.",fileSizeExceeds:"File size exceeds 10MB limit",fileUploadedSuccess:"File uploaded successfully",failedToUpload:"Failed to upload file",closingAttachmentRemoved:"Closing attachment removed",closingAttachmentUploadedSuccess:"Closing attachment uploaded successfully",failedToUploadClosing:"Failed to upload closing attachment",attachmentRemoved:"Attachment removed",systemManager:"System Manager",workflow:"Workflow"}},F5={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",clearHospitalHint:"Clear hospital to filter by department",clearFilters:"Clear Filters",legendHospital:"Hospital",legendDepartment:"Department (WO Type)",legendHasUrgent:"Has Urgent WOs",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:"Showing Work Orders by Type",deptWoType:"Department / Work Order Type",tooltipDept:"Dept",tooltipHospital:"Hospital",tooltipUrgent:"URGENT! ",normalWos:"Normal WOs:",urgentWos:"Urgent WOs:",closedWos:"Closed WOs:",plannedPms:"Planned PMs:",completedPms:"Completed PMs:",assets:"Assets"},I5={title:"Maintenance Calendar",viewType:"View Type",maintenanceLog:"Maintenance Log",ppmPlanner:"PPM Planner",filters:"Filters",yearlyMap:"Yearly Map",yearlyMapTitle:"View Yearly PPM Planner Map",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 Planners...",overdueInTooltip:"(Overdue)",clickToViewDetails:"Click to view details",clickToViewPpmPlanner:"Click to view PPM Planner",ppmPlannerDefault:"PPM Planner",legendCompleted:"Completed",legendPlanned:"Planned",legendOverdue:"Overdue",legendToday:"Today",summaryPpmPlanners:"PPM Planners"},M5={plannedPms:"Planned PMs",completedPms:"Completed PMs",overduePms:"Overdue PMs"},P5={common:u5,sidebar:f5,dataImport:h5,locations:m5,login:g5,dashboard:x5,commonFields:p5,filters:y5,listPages:b5,assets:v5,workOrders:w5,maintenance:_5,ppm:k5,ppmPlanner:N5,exportModal:j5,items:S5,issues:C5,users:E5,events:T5,pagination:A5,linkField:O5,supportPlans:D5,inspections:R5,activeMap:F5,maintenanceCalendarPage:I5,assetDetail:M5},L5={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:"أدخل اسم المرشح (مثال: 'مفتوح أولوية عالية')"},B5={title:"أصول سيرا",loggedInAs:"تم تسجيل الدخول كـ:",version:"أصول سيرا نظام إدارة الأصول الإصدار 2.26",inventory:"المخزون",ppmPlanner:"مخطط الصيانة الوقائية",maintenanceCalendar:"تقويم الصيانة",activeMap:"الخريطة النشطة",maintenanceTeam:"فريق الصيانة",procurement:"المشتريات",sla:"اتفاقية مستوى الخدمة",support:"الدعم",inspection:"التفتيش",userProfile:"الملف الشخصي",dataImport:"استيراد البيانات"},U5={title:"استيراد البيانات",documentType:"نوع المستند",fileLabel:"ملف الاستيراد",fileHint:"الصيغ: ‎.xlsx و ‎.xls و ‎.csv. الصف الأول يجب أن يستخدم نفس أسماء الحقول كما في القالب.",toastImportSuccess:"اكتمل الاستيراد.",toastImportPartial:"اكتمل مع وجود مشكلات — راجع السجل أدناه.",toastImportError:"انتهى الاستيراد بأخطاء — راجع السجل أدناه.",toastImportStatus:"حالة الاستيراد: {{status}}",chooseFile:"اختر ملفاً",clearFile:"إزالة الملف",downloadFile:"تنزيل الملف",previewSaveHintPrefix:"انقر فوق",previewSaveAction:"حفظ",previewSaveHintSuffix:"لإضافة السجلات إلى النظام.",alignedWorkbookNotApplied:"لم يُحفظ الملف المُحاذي لاختيارك (لم يكتمل التحقق بنجاح). أصلح المشكلات أعلاه، ثم سيستبدل التحقق الملف بقيم الربط المطابقة للنظام.",normalizationNotes:"تمت مطابقة القيم مع السجلات الموجودة (قبل الاستيراد)",downloadTemplate:"تنزيل القالب",startImport:"بدء الاستيراد",importing:"جاري الاستيراد…",templateDownloaded:"تم تنزيل القالب",progress:"{{done}} / {{total}} صف",importFinishedOk:"اكتمل الاستيراد: {{count}} صف بنجاح.",importFinishedMixed:"انتهى الاستيراد: {{ok}} نجح، {{fail}} فشل — راجع السجل أدناه.",logsTitle:"سجل الاستيراد",logRow:"الصف",logStatus:"الحالة",logMessage:"الرسالة",statusOk:"موافق",statusFailed:"فشل",successImported:"تم الاستيراد بنجاح: {{name}}",importSummaryLine:"تم استيراد {{ok}} من أصل {{total}} صفاً بنجاح.",importSummaryLineAllOk:"{{total}} من أصل {{total}} — تم استيراد كل الصفوف بنجاح.",importSummaryLineAllFailed:"لم يُستورد أي صف بنجاح ({{total}} صف فشل).",importSummaryBadgeAll:"نجاح كامل",importSummaryBadgePartial:"نجاح جزئي",importSummaryBadgeNone:"فشل",errors:{noFile:"يرجى اختيار ملف أولاً (‎.xlsx أو ‎.xls أو ‎.csv).",noRows:"الملف لا يحتوي على صفوف بيانات.",noSchema:"تعذر تحميل حقول الموقع. حاول مرة أخرى أو اتصل بالمسؤول.",parseFailed:"تعذر قراءة الملف: {{message}}",headerValidation:"صحح مشاكل الأعمدة أدناه قبل استيراد صفوف البيانات.",previewNotReady:"انتظر انتهاء التحقق من الملف قبل بدء الاستيراد.",fixPreviewFirst:"عالج المشكلات أدناه (أو استخدم إجراءات الإضافة) قبل بدء الاستيراد."},templateModal:{title:"تنزيل القالب",fileType:"نوع الملف",fileTypeExcel:"Excel (‎.xlsx)",fileTypeCsv:"CSV",exportType:"نوع التصدير",exportTypeBlank:"قالب فارغ",blankHint:"يُصدَر صف الرؤوس فقط — لا توجد صفوف بيانات.",selectFields:"اختر الأعمدة",selectAll:"تحديد الكل",selectMandatory:"تحديد الإلزامية",unselectAll:"إلغاء التحديد",fieldsSelected:"عمود محدد",export:"تنزيل",nothingSelected:"اختر عموداً واحداً على الأقل."},locationQuickHint:"أنشئ المواقع أو راجعها قبل ربطها في ملف الاستيراد.",btnAddLocation:"إضافة موقع",btnViewLocations:"عرض كل المواقع",previewTitle:"أخطاء وتحذيرات ملف الاستيراد",previewHeaderIssue:"رأس الجدول / تعيين الأعمدة",previewRowHeading:"الصف {{row}}",previewColumnHeading:"العمود {{n}} ({{label}})",previewGenericHeading:"الاستيراد",validatingFile:"جاري التحقق من الملف…",addMaster:"إضافة {{doctype}}",mastersCreated:"تم إنشاء {{count}} سجل رئيسي. تم تحديث المعاينة."},z5={title:"المواقع",subtitle:"استعراض سجلات المواقع في النظام.",listTotal:"إجمالي {{count}} موقعاً",backToDataImport:"← استيراد البيانات",backToList:"العودة إلى المواقع",viewRow:"عرض",editRow:"تعديل",deleteRow:"حذف",deleteConfirm:'حذف الموقع "{{name}}"؟ لا يمكن التراجع عن هذا الإجراء.',deleteSuccess:"تم حذف الموقع.",saveMissingName:"اكتمل الحفظ لكن الخادم لم يُرجِع معرّف الموقع.",add:"إضافة موقع",searchPlaceholder:"بحث بالمعرّف أو اسم الموقع…",loading:"جاري تحميل المواقع…",empty:"لا توجد مواقع مطابقة للبحث.",yes:"نعم",no:"لا",colActions:"إجراءات",open:"فتح",refresh:"تحديث القائمة",paginationLabel:"مواقع",newTitle:"موقع جديد",roomNoPlaceholder:"رقم أو اسم الغرفة",locationMasterPlaceholder:"اسم الموقع (السجل الرئيسي)",createRoom:"إنشاء",createLocationMaster:"إنشاء",viewLocation:"عرض",viewLocationDesk:"فتح الموقع في لوحة إدارة النظام",viewLocationDetails:"عرض تفاصيل الموقع",fieldRoom:"غرفة",formHintDataImportStyle:"استخدم البحث عن المبنى والقسم أعلاه. للغرفة والموقع اكتب القيمة أو استخدم «إضافة غرفة» / «إضافة موقع» لإنشاء سجل رئيسي — دون قائمة اختيار من السجلات الحالية.",roomTextPlaceholder:"اكتب أو أضف غرفة",locationTextPlaceholder:"اكتب أو أضف موقعاً",addRoomAction:"إضافة غرفة",addLocationAction:"إضافة موقع",sectionDetails:"تفاصيل الموقع",fieldLocationId:"معرّف الموقع",fieldLocationName:"اسم الموقع",fieldLocationNamePlaceholder:"أدخل اسم الموقع",fieldContainsSubLocations:"يحتوي هذا الموقع على مواقع فرعية",fieldContainsSubLocationsHelp:"فعّلها إذا كان يمكن إضافة مواقع تابعة تحت هذا الموقع.",fieldDepartment:"القسم",fieldDepartmentPlaceholder:"القسم (اختياري)",fieldParent:"الموقع الأب",fieldParentPlaceholder:"اختر الأب (اختياري)",fieldParentPlaceholderDesk:"اختر الموقع الأب (اختياري)",mapTitle:"الخريطة (خط العرض والطول)",mapHint:"انقر على الخريطة لوضع الدبوس، أو اسحب الدبوس لتعديل الإحداثيات.",fieldIsContainer:"حاوية",fieldIsContainerHelp:"حدد إذا كانت وحدة زراعة مائية (هيدروبونيك).",fieldIsGroup:"مجموعة",fieldCustomHospital:"مستشفى",fieldCustomWoType:"نوع أمر عمل",fieldLatitude:"خط العرض",fieldLatitudePlaceholder:"مثال: 24.7136",fieldLongitude:"خط الطول",fieldLongitudePlaceholder:"مثال: 46.6753",save:"حفظ",saved:"تم حفظ الموقع.",validationName:"اسم الموقع مطلوب.",validationId:"معرّف الموقع مطلوب.",errorDuplicateEntry:'اسم الموقع "{{name}}" مستخدم مسبقاً. اختر اسماً آخر.',errorDuplicateGeneric:"اسم هذا الموقع موجود مسبقاً. استخدم اسماً فريداً.",fieldLabel:{building:"المبنى",department:"القسم",room_no:"رقم الغرفة",location:"الموقع",name:"المعرّف",owner:"المالك",creation:"تاريخ الإنشاء",modified:"آخر تعديل",modified_by:"عُدّل بواسطة",docstatus:"حالة المستند",idx:"ترتيب",location_name:"اسم الموقع",parent_location:"الأب",is_container:"حاوية",is_group:"مجموعة",custom_is_hospital:"مستشفى",custom_is_wo_type:"نوع أمر عمل",latitude:"خط العرض",longitude:"خط الطول",lft:"يسار الشجرة",rgt:"يمين الشجرة"}},W5={title:"أصول سيرا",subtitle:"نظام إدارة الأصول",signIn:"قم بتسجيل الدخول للمتابعة",emailPlaceholder:"أدخل بريدك الإلكتروني",passwordPlaceholder:"أدخل كلمة المرور",loginFailed:"فشل تسجيل الدخول. يرجى التحقق من بيانات الاعتماد الخاصة بك.",demoLogin:"تسجيل دخول تجريبي",or:"أو",forgotPassword:"نسيت كلمة المرور؟",forgotPasswordTitle:"نسيت كلمة المرور؟",forgotPasswordHint:"أدخل البريد الإلكتروني أو اسم المستخدم الذي تستخدمه لتسجيل الدخول. سنرسل تعليمات إعادة التعيين إلى بريدك المسجل.",forgotPasswordUserRequired:"يرجى إدخال البريد الإلكتروني أو اسم المستخدم.",forgotPasswordUserPlaceholder:"البريد أو اسم المستخدم",forgotPasswordSubmit:"إرسال رابط إعادة التعيين",forgotPasswordSent:"إذا كان هذا البريد مسجلاً، ستصلك تعليمات إعادة تعيين كلمة المرور.",forgotPasswordSentSuccess:"تم إرسال تعليمات إعادة تعيين كلمة المرور إلى بريدك الإلكتروني المسجل. يرجى التحقق من صندوق الوارد.",forgotPasswordNotFound:"لم يتم العثور على حساب مستخدم بالبريد الإلكتروني المقدم.",forgotPasswordClose:"إلغاء",forgotPasswordTimeout:"استغرق الطلب وقتاً طويلاً (قد يكون خادم البريد بطيئاً). حاول مرة أخرى بعد دقيقة.",forgotPasswordCannotReset:"إعادة تعيين كلمة المرور غير متاحة لهذا الحساب.",forgotPasswordFailed:"تعذر إرسال رسالة إعادة التعيين. حاول مرة أخرى أو تواصل مع الدعم.",finishingSignOut:"جاري إنهاء تسجيل الخروج…",afterPasswordResetSignIn:"تم تحديث كلمة المرور. يرجى تسجيل الدخول بكلمة المرور الجديدة.",resetPasswordTitle:"إعادة تعيين كلمة المرور",resetNewPassword:"كلمة المرور الجديدة",resetConfirmPassword:"تأكيد كلمة المرور",resetConfirm:"تأكيد",resetInvalidLink:"رابط إعادة التعيين غير صالح أو مفقود. اطلب رابطاً جديداً من صفحة تسجيل الدخول.",resetEnterPassword:"يرجى إدخال كلمة مرور جديدة.",resetPasswordMismatch:"كلمتا المرور غير متطابقتين.",resetFailed:"تعذر إعادة تعيين كلمة المرور. قد يكون الرابط منتهياً.",backToSignIn:"العودة لتسجيل الدخول"},H5={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:"مفتوح"},$5={assetId:"معرف الأصل",assetName:"اسم الأصل",serialNumber:"الرقم التسلسلي",localId:"المعرف المحلي",technicalDepartment:"القسم الفني",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:"الاسم"},V5={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:"اسم الفريق (ي-أ)"},G5={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:"لا يمكن التراجع عن هذا الإجراء."},Y5={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:"الرمز التسلسلي",localId:"المعرف المحلي",technicalDepartment:"القسم الفني",manufacturer:"الشركة المصنعة",model:"الموديل",totalHours:"إجمالي الساعات",downTimeHours:"وقت التوقف (بالساعات)",upTimeHours:"وقت التشغيل (بالساعات)",placeholderAssetName:"مثال: كمبيوتر محمول موديل X",placeholderSerialCode:"مثال: SN-12345",placeholderLocalId:"مثال: LOC-001",placeholderModelNumber:"رقم الموديل",placeholderZero:"0",placeholderDescription:"وصف موجز للأصل",placeholderPONumber:"رقم أمر الشراء",selectClass:"اختر الفئة",classA:"فئة أ",classB:"فئة ب",classC:"فئة ج",autoGenerated:"يُولد تلقائياً",calculatedFromAvailableDate:"محسوب من تاريخ التوفر للاستخدام",calculatedTotalMinusDown:"محسوب: إجمالي الساعات - وقت التوقف",hospital:"المستشفى",siteName:"اسم الموقع",selectSite:"اختر الموقع",building:"المبنى",department:"القسم",roomNumber:"رقم الغرفة",location:"الموقع",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:"تفاصيل إضافية"}},q5=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":"فئة الأعمال المدنية","civilWorkCategoryMandatory":"يرجى اختيار فئة الأعمال المدنية.","selectCivilWorkCategory":"اختر فئة الأعمال المدنية","selectPendingReason":"اختر سبب الانتظار","pleaseSpecifyReason":"يرجى تحديد السبب...","selectServiceAgreement":"اختر اتفاقية الخدمة","selectServiceCoverage":"اختر تغطية الخدمة","describeComplaint":"صف طبيعة الشكوى...","describeWorkPerformed":"صف العمل المنفذ...","enterSerialNumber":"أدخل الرقم التسلسلي","searchAssetBySerial":"البحث عن الأصل بالرقم التسلسلي","serialNo":"الرقم التسلسلي","localId":"المعرف المحلي","enterLocalId":"أدخل المعرف المحلي","searchAssetByLocalId":"البحث عن الأصل بالمعرف المحلي","pleaseEnterLocalIdToSearch":"يرجى إدخال المعرف المحلي للبحث","noAssetFoundWithLocalId":"لم يتم العثور على أصل بهذا المعرف المحلي","assetNotAvailable":"هذا الأصل غير متاح (يجب أن يكون مُعتمدًا وغير محذوف)","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":"حفظ التحديد"}}`),X5={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}} صف"}},Z5={title:"الصيانة الوقائية",ppmDetails:"تفاصيل الصيانة الوقائية",addPPM:"إضافة صيانة وقائية جديدة",periodicity:"الدورية",dueDate:"تاريخ الاستحقاق",manageSchedules:"إدارة الجداول",bulkScheduleGenerator:"مولد الجداول المجمّع — صفِّ الأصول ثم اضبط الإعدادات وأنشئ",filterAssets:"تصفية الأصول",selectAssets:"اختيار الأصول",scheduleConfiguration:"إعداد الجدول",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:"خطأ"}},K5={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 ? 'اً' : ''}}"}},J5={title:"تصدير",whatToExport:"ما الذي سيتم تصديره",selectedRows:"الصفوف المحددة",currentPage:"الصفحة الحالية",allWithFilters:"الكل مع المرشحات",exportSelected:"تصدير {count} محدد",exportPage:"تصدير {count} في الصفحة الحالية",exportAll:"تصدير الكل {count}",columnsToExport:"الأعمدة للتصدير",selectAll:"تحديد الكل",selectDefault:"تحديد الافتراضي",exporting:"جاري التصدير...",exportingSelected:"جاري تصدير {count} صف(وف) محدد(ة)",exportingPage:"جاري تصدير {count} صف(وف) من الصفحة الحالية",exportingAll:"جاري تصدير جميع {count} صف(وف)",selected:"محدد",rows:"صفوف"},Q5={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 ? 'اً' : ''}}"}},eE={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:"حرجة"}},tE={title:"المستخدمون",userDetails:"تفاصيل المستخدم",newUser:"مستخدم جديد",addUser:"إضافة مستخدم جديد",searchUsers:"بحث عن مستخدمين...",manageUsers:"إدارة حسابات المستخدمين والصلاحيات",noUsersFound:"لم يتم العثور على مستخدمين",tryAdjustingSearch:"حاول تعديل مصطلحات البحث.",noUsersAvailable:"لا يوجد مستخدمون متاحون.",backToDashboard:"العودة إلى لوحة التحكم",refresh:"تحديث",active:"نشط",inactive:"غير نشط",noEmail:"لا يوجد بريد إلكتروني",created:"تاريخ الإنشاء"},rE={title:"الفعاليات",eventDetails:"تفاصيل الفعالية",newEvent:"فعالية جديدة",addEvent:"إضافة فعالية",upcomingEvents:"الفعاليات القادمة",eventsFromFrappe:"فعاليات من نظام Frappe",noEventsFound:"لم يتم العثور على فعاليات",noEventsScheduled:"لا توجد فعاليات مجدولة حالياً.",refreshEvents:"تحديث الفعاليات"},aE={previous:"السابق",next:"التالي",goTo:"انتقل إلى",go:"انتقال",page:"صفحة",showingToOf:"عرض {{start}} إلى {{end}} من {{total}} {{label}}",showingTo:"عرض {{start}} إلى {{end}} {{label}}",items:"أصناف",assets:"أصول",workOrders:"أوامر عمل",issues:"تذاكر",teams:"فرق",inspections:"عمليات تفتيش",plans:"خطط"},sE={loading:"جاري التحميل...",noResultsFound:"لم يتم العثور على نتائج",createNewDoctype:"إنشاء {{doctype}} جديد",selectLabel:"اختر {{label}}"},nE={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}} صف"}},iE={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:"سير العمل"}},oE={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:"الأصول"},lE={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:"مخططات الصيانة الوقائية"},cE={plannedPms:"صيانة مخطط لها",completedPms:"صيانة مكتملة",overduePms:"صيانة متأخرة"},dE={common:L5,sidebar:B5,dataImport:U5,locations:z5,login:W5,dashboard:H5,commonFields:$5,filters:V5,listPages:G5,assets:Y5,workOrders:q5,maintenance:X5,ppm:Z5,ppmPlanner:K5,exportModal:J5,items:Q5,issues:eE,users:tE,events:rE,pagination:aE,linkField:sE,supportPlans:nE,inspections:iE,activeMap:oE,maintenanceCalendarPage:lE,assetDetail:cE},Or={BASE_URL:"https://kfsh-dammam-asm.seeraarabia.com",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",DASHBOARD_WO_METRICS:"/api/method/asset_lite.api.dashboard_api.get_dashboard_work_order_metrics",DASHBOARD_ASSET_STATUS:"/api/method/asset_lite.api.dashboard_api.get_asset_device_status_summary",DASHBOARD_MAINTENANCE_INSIGHTS:"/api/method/asset_lite.api.dashboard_api.get_maintenance_insights",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_WORK_ORDER_FEEDBACK:"/api/method/asset_lite.api.work_order_api.get_work_order_feedback",SAVE_WORK_ORDER_FEEDBACK:"/api/method/asset_lite.api.work_order_api.save_work_order_feedback",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",LOGOUT:"/api/method/logout",CSRF_TOKEN:"/api/method/frappe.sessions.get_csrf_token",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 uE{constructor(){Ii(this,"baseURL");Ii(this,"endpoints");Ii(this,"defaultHeaders");Ii(this,"timeout");this.baseURL=Or.BASE_URL,this.endpoints=Or.ENDPOINTS,this.defaultHeaders=Or.DEFAULT_HEADERS,this.timeout=Or.TIMEOUT}getCSRFToken(){return me(this,null,function*(){try{if(typeof window!="undefined"&&window.csrf_token)return window.csrf_token;const r=localStorage.getItem("user"),a=localStorage.getItem("frappe_session_id");if(!r&&!a)return null;const s=yield fetch(`${this.baseURL}${this.endpoints.CSRF_TOKEN}`,{method:"GET",headers:{Accept:"application/json"},credentials:"include"});return s.ok&&(yield s.json()).message||null}catch(r){return null}})}apiCall(s){return me(this,arguments,function*(r,a={}){const n=`${this.baseURL}${r}`,i=Te({method:"GET",headers:Te(Te({},this.defaultHeaders),a.headers)},a),c=yield this.getCSRFToken();c&&(i.headers["X-Frappe-CSRF-Token"]=c);try{const u=new AbortController,h=setTimeout(()=>u.abort(),this.timeout),g=yield fetch(n,Ke(Te({},i),{credentials:"include",signal:u.signal}));if(clearTimeout(h),!g.ok){const w=yield g.json().catch(()=>({}));throw new vd(w.error||`HTTP error! status: ${g.status}`,g.status)}const y=yield g.json();return y.message!==void 0?y.message:y}catch(u){throw u instanceof Error?(console.error("API call failed:",u),new vd(u.message)):u}})}login(r){return me(this,null,function*(){const a=new FormData;a.append("usr",r.email),a.append("pwd",r.password);const s=`${this.baseURL}${this.endpoints.LOGIN}`;try{const n=new AbortController,i=setTimeout(()=>n.abort(),this.timeout),c=yield fetch(s,{method:"POST",headers:{Accept:"application/json"},body:a,credentials:"include",signal:n.signal});if(clearTimeout(i),!c.ok){const h=yield c.json().catch(()=>({})),g="Invalid credentials. Please try again.";throw new vd(g,c.status)}const u=yield c.json();return typeof u.message=="string"&&u.message==="Logged In"?{message:{full_name:u.full_name,user_id:u.user||u.email,home_page:u.home_page,sid:u.sid}}:u.message&&typeof u.message=="object"?{message:u.message}:u.full_name||u.user?{message:u}:{message:u}}catch(n){throw n instanceof Error?new vd("Login failed. Please try again."):n}})}getCSRFTokenForGuest(){return me(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 me(this,null,function*(){yield this.apiCall(this.endpoints.LOGOUT,{method:"POST"})})}getUserDetails(r){return me(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 me(this,null,function*(){const c=new URLSearchParams({doctype:r,limit:n.toString(),offset:i.toString()});return a&&c.append("filters",JSON.stringify(a)),s&&c.append("fields",JSON.stringify(s)),this.apiCall(`${this.endpoints.DOCTYPE_RECORDS}?${c}`)})}getDashboardStats(){return me(this,null,function*(){return this.apiCall(this.endpoints.DASHBOARD_STATS)})}getNumberCards(){return me(this,null,function*(){return this.apiCall(this.endpoints.DASHBOARD_NUMBER_CARDS)})}listDashboardCharts(r=!0){return me(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 me(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}`)})}getDashboardWorkOrderMetrics(r){return me(this,null,function*(){const a=new URLSearchParams;r&&a.append("filters",JSON.stringify(r));const s=a.toString();return this.apiCall(`${this.endpoints.DASHBOARD_WO_METRICS}${s?`?${s}`:""}`)})}getAssetDeviceStatusSummary(r){return me(this,null,function*(){const a=new URLSearchParams;r&&a.append("filters",JSON.stringify(r));const s=a.toString();return this.apiCall(`${this.endpoints.DASHBOARD_ASSET_STATUS}${s?`?${s}`:""}`)})}getMaintenanceInsights(r){return me(this,null,function*(){const a=new URLSearchParams;r&&a.append("filters",JSON.stringify(r));const s=a.toString();return this.apiCall(`${this.endpoints.DASHBOARD_MAINTENANCE_INSIGHTS}${s?`?${s}`:""}`)})}getKycDetails(){return me(this,null,function*(){return this.apiCall(this.endpoints.KYC_DETAILS)})}uploadFile(r){return me(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 me(this,null,function*(){const a=r?`?user=${encodeURIComponent(r)}`:"";return this.apiCall(`${this.endpoints.GET_USER_PERMISSIONS}${a}`)})}getPermissionFilters(r,a){return me(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 me(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 me(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 me(this,null,function*(){return this.apiCall(this.endpoints.GET_CONFIGURED_DOCTYPES)})}getUserDefaults(r){return me(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 vd extends Error{constructor(a,s,n){super(a);Ii(this,"status");Ii(this,"code");this.name="ApiError",this.status=s,this.code=n}}const Xt=new uE,Op=Object.freeze(Object.defineProperty({__proto__:null,ApiError:vd,default:Xt},Symbol.toStringTag,{value:"Module"}));function fE(e){return me(this,null,function*(){try{const r=yield Xt.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 c=`${s.context}.${n}`;a[c]=i}else n.includes("."),a[n]=i}),a}catch(r){return console.error("Error fetching translations from Frappe:",r),{}}})}function hE(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 c=s[i];n[c]||(n[c]={}),n=n[c]}n[s[s.length-1]]=e[a]}else r[a]=e[a]}),r}function Yw(e){return me(this,null,function*(){const r=yield fE(e);return hE(r)})}Zn.use(O4).use(z6).init({resources:{en:{translation:P5},ar:{translation:dE}},fallbackLng:"en",defaultNS:"translation",interpolation:{escapeValue:!1},detection:{order:["localStorage","navigator"],caches:["localStorage"]}});function Q1(){return me(this,null,function*(){try{if(!localStorage.getItem("user"))return;const r=yield Yw("en");Object.keys(r).length>0&&Zn.addResourceBundle("en","translation",r,!0,!0);const a=yield Yw("ar");Object.keys(a).length>0&&Zn.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)}})}Zn.on("initialized",()=>{Q1()});var qw="popstate";function mE(e={}){function r(s,n){let{pathname:i,search:c,hash:u}=s.location;return b1("",{pathname:i,search:c,hash:u},n.state&&n.state.usr||null,n.state&&n.state.key||"default")}function a(s,n){return typeof n=="string"?n:Nf(n)}return xE(r,a,null,e)}function Is(e,r){if(e===!1||e===null||typeof e=="undefined")throw new Error(r)}function _o(e,r){if(!e){typeof console!="undefined"&&console.warn(r);try{throw new Error(r)}catch(a){}}}function gE(){return Math.random().toString(36).substring(2,10)}function Xw(e,r){return{usr:e.state,key:e.key,idx:r}}function b1(e,r,a=null,s){return Ke(Te({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof r=="string"?J0(r):r),{state:a,key:r&&r.key||s||gE()})}function Nf({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 J0(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 xE(e,r,a,s={}){let{window:n=document.defaultView,v5Compat:i=!1}=s,c=n.history,u="POP",h=null,g=y();g==null&&(g=0,c.replaceState(Ke(Te({},c.state),{idx:g}),""));function y(){return(c.state||{idx:null}).idx}function w(){u="POP";let O=y(),M=O==null?null:O-g;g=O,h&&h({action:u,location:C.location,delta:M})}function E(O,M){u="PUSH";let R=b1(C.location,O,M);g=y()+1;let F=Xw(R,g),z=C.createHref(R);try{c.pushState(F,"",z)}catch(W){if(W instanceof DOMException&&W.name==="DataCloneError")throw W;n.location.assign(z)}i&&h&&h({action:u,location:C.location,delta:1})}function S(O,M){u="REPLACE";let R=b1(C.location,O,M);g=y();let F=Xw(R,g),z=C.createHref(R);c.replaceState(F,"",z),i&&h&&h({action:u,location:C.location,delta:0})}function A(O){return pE(O)}let C={get action(){return u},get location(){return e(n,c)},listen(O){if(h)throw new Error("A history only accepts one active listener");return n.addEventListener(qw,w),h=O,()=>{n.removeEventListener(qw,w),h=null}},createHref(O){return r(n,O)},createURL:A,encodeLocation(O){let M=A(O);return{pathname:M.pathname,search:M.search,hash:M.hash}},push:E,replace:S,go(O){return c.go(O)}};return C}function pE(e,r=!1){let a="http://localhost";typeof window!="undefined"&&(a=window.location.origin!=="null"?window.location.origin:window.location.href),Is(a,"No window.location.(origin|href) available to create URL");let s=typeof e=="string"?e:Nf(e);return s=s.replace(/ $/,"%20"),!r&&s.startsWith("//")&&(s=a+s),new URL(s,a)}function D4(e,r,a="/"){return yE(e,r,a,!1)}function yE(e,r,a,s){let n=typeof r=="string"?J0(r):r,i=dc(n.pathname||"/",a);if(i==null)return null;let c=R4(e);bE(c);let u=null;for(let h=0;u==null&&h<c.length;++h){let g=AE(i);u=EE(c[h],g,s)}return u}function R4(e,r=[],a=[],s="",n=!1){let i=(c,u,h=n,g)=>{let y={relativePath:g===void 0?c.path||"":g,caseSensitive:c.caseSensitive===!0,childrenIndex:u,route:c};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(s)&&h)return;Is(y.relativePath.startsWith(s),`Absolute route path "${y.relativePath}" nested under path "${s}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(s.length)}let w=ic([s,y.relativePath]),E=a.concat(y);c.children&&c.children.length>0&&(Is(c.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${w}".`),R4(c.children,r,E,w,h)),!(c.path==null&&!c.index)&&r.push({path:w,score:SE(w,c.index),routesMeta:E})};return e.forEach((c,u)=>{var h;if(c.path===""||!((h=c.path)!=null&&h.includes("?")))i(c,u);else for(let g of F4(c.path))i(c,u,!0,g)}),r}function F4(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 c=F4(s.join("/")),u=[];return u.push(...c.map(h=>h===""?i:[i,h].join("/"))),n&&u.push(...c),u.map(h=>e.startsWith("/")&&h===""?"/":h)}function bE(e){e.sort((r,a)=>r.score!==a.score?a.score-r.score:CE(r.routesMeta.map(s=>s.childrenIndex),a.routesMeta.map(s=>s.childrenIndex)))}var vE=/^:[\w-]+$/,wE=3,_E=2,kE=1,NE=10,jE=-2,Zw=e=>e==="*";function SE(e,r){let a=e.split("/"),s=a.length;return a.some(Zw)&&(s+=jE),r&&(s+=_E),a.filter(n=>!Zw(n)).reduce((n,i)=>n+(vE.test(i)?wE:i===""?kE:NE),s)}function CE(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 EE(e,r,a=!1){let{routesMeta:s}=e,n={},i="/",c=[];for(let u=0;u<s.length;++u){let h=s[u],g=u===s.length-1,y=i==="/"?r:r.slice(i.length)||"/",w=Bm({path:h.relativePath,caseSensitive:h.caseSensitive,end:g},y),E=h.route;if(!w&&g&&a&&!s[s.length-1].route.index&&(w=Bm({path:h.relativePath,caseSensitive:h.caseSensitive,end:!1},y)),!w)return null;Object.assign(n,w.params),c.push({params:n,pathname:ic([i,w.pathname]),pathnameBase:IE(ic([i,w.pathnameBase])),route:E}),w.pathnameBase!=="/"&&(i=ic([i,w.pathnameBase]))}return c}function Bm(e,r){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[a,s]=TE(e.path,e.caseSensitive,e.end),n=r.match(a);if(!n)return null;let i=n[0],c=i.replace(/(.)\/+$/,"$1"),u=n.slice(1);return{params:s.reduce((g,{paramName:y,isOptional:w},E)=>{if(y==="*"){let A=u[E]||"";c=i.slice(0,i.length-A.length).replace(/(.)\/+$/,"$1")}const S=u[E];return w&&!S?g[y]=void 0:g[y]=(S||"").replace(/%2F/g,"/"),g},{}),pathname:i,pathnameBase:c,pattern:e}}function TE(e,r=!1,a=!0){_o(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,(c,u,h)=>(s.push({paramName:u,isOptional:h!=null}),h?"/?([^\\/]+)?":"/([^\\/]+)")).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 AE(e){try{return e.split("/").map(r=>decodeURIComponent(r).replace(/\//g,"%2F")).join("/")}catch(r){return _o(!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 dc(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 OE=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,DE=e=>OE.test(e);function RE(e,r="/"){let{pathname:a,search:s="",hash:n=""}=typeof e=="string"?J0(e):e,i;if(a)if(DE(a))i=a;else{if(a.includes("//")){let c=a;a=a.replace(/\/\/+/g,"/"),_o(!1,`Pathnames cannot have embedded double slashes - normalizing ${c} -> ${a}`)}a.startsWith("/")?i=Kw(a.substring(1),"/"):i=Kw(a,r)}else i=r;return{pathname:i,search:ME(s),hash:PE(n)}}function Kw(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 Dp(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 FE(e){return e.filter((r,a)=>a===0||r.route.path&&r.route.path.length>0)}function ey(e){let r=FE(e);return r.map((a,s)=>s===r.length-1?a.pathname:a.pathnameBase)}function ty(e,r,a,s=!1){let n;typeof e=="string"?n=J0(e):(n=Te({},e),Is(!n.pathname||!n.pathname.includes("?"),Dp("?","pathname","search",n)),Is(!n.pathname||!n.pathname.includes("#"),Dp("#","pathname","hash",n)),Is(!n.search||!n.search.includes("#"),Dp("#","search","hash",n)));let i=e===""||n.pathname==="",c=i?"/":n.pathname,u;if(c==null)u=a;else{let w=r.length-1;if(!s&&c.startsWith("..")){let E=c.split("/");for(;E[0]==="..";)E.shift(),w-=1;n.pathname=E.join("/")}u=w>=0?r[w]:"/"}let h=RE(n,u),g=c&&c!=="/"&&c.endsWith("/"),y=(i||c===".")&&a.endsWith("/");return!h.pathname.endsWith("/")&&(g||y)&&(h.pathname+="/"),h}var ic=e=>e.join("/").replace(/\/\/+/g,"/"),IE=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),ME=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,PE=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function LE(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function BE(e){return e.map(r=>r.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var I4=["POST","PUT","PATCH","DELETE"];new Set(I4);var UE=["GET",...I4];new Set(UE);var Q0=_.createContext(null);Q0.displayName="DataRouter";var hg=_.createContext(null);hg.displayName="DataRouterState";_.createContext(!1);var M4=_.createContext({isTransitioning:!1});M4.displayName="ViewTransition";var zE=_.createContext(new Map);zE.displayName="Fetchers";var WE=_.createContext(null);WE.displayName="Await";var qo=_.createContext(null);qo.displayName="Navigation";var Uf=_.createContext(null);Uf.displayName="Location";var fl=_.createContext({outlet:null,matches:[],isDataRoute:!1});fl.displayName="Route";var ry=_.createContext(null);ry.displayName="RouteError";function HE(e,{relative:r}={}){Is(eu(),"useHref() may be used only in the context of a <Router> component.");let{basename:a,navigator:s}=_.useContext(qo),{hash:n,pathname:i,search:c}=zf(e,{relative:r}),u=i;return a!=="/"&&(u=i==="/"?a:ic([a,i])),s.createHref({pathname:u,search:c,hash:n})}function eu(){return _.useContext(Uf)!=null}function hl(){return Is(eu(),"useLocation() may be used only in the context of a <Router> component."),_.useContext(Uf).location}var P4="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function L4(e){_.useContext(qo).static||_.useLayoutEffect(e)}function Na(){let{isDataRoute:e}=_.useContext(fl);return e?r8():$E()}function $E(){Is(eu(),"useNavigate() may be used only in the context of a <Router> component.");let e=_.useContext(Q0),{basename:r,navigator:a}=_.useContext(qo),{matches:s}=_.useContext(fl),{pathname:n}=hl(),i=JSON.stringify(ey(s)),c=_.useRef(!1);return L4(()=>{c.current=!0}),_.useCallback((h,g={})=>{if(_o(c.current,P4),!c.current)return;if(typeof h=="number"){a.go(h);return}let y=ty(h,JSON.parse(i),n,g.relative==="path");e==null&&r!=="/"&&(y.pathname=y.pathname==="/"?r:ic([r,y.pathname])),(g.replace?a.replace:a.push)(y,g.state,g)},[r,a,i,n,e])}_.createContext(null);function ml(){let{matches:e}=_.useContext(fl),r=e[e.length-1];return r?r.params:{}}function zf(e,{relative:r}={}){let{matches:a}=_.useContext(fl),{pathname:s}=hl(),n=JSON.stringify(ey(a));return _.useMemo(()=>ty(e,JSON.parse(n),s,r==="path"),[e,n,s,r])}function VE(e,r){return B4(e,r)}function B4(e,r,a,s,n){var R;Is(eu(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i}=_.useContext(qo),{matches:c}=_.useContext(fl),u=c[c.length-1],h=u?u.params:{},g=u?u.pathname:"/",y=u?u.pathnameBase:"/",w=u&&u.route;{let F=w&&w.path||"";U4(g,!w||F.endsWith("*")||F.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${g}" (under <Route path="${F}">) 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="${F}"> to <Route path="${F==="/"?"*":`${F}/*`}">.`)}let E=hl(),S;if(r){let F=typeof r=="string"?J0(r):r;Is(y==="/"||((R=F.pathname)==null?void 0:R.startsWith(y)),`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 "${y}" but pathname "${F.pathname}" was given in the \`location\` prop.`),S=F}else S=E;let A=S.pathname||"/",C=A;if(y!=="/"){let F=y.replace(/^\//,"").split("/");C="/"+A.replace(/^\//,"").split("/").slice(F.length).join("/")}let O=D4(e,{pathname:C});_o(w||O!=null,`No routes matched location "${S.pathname}${S.search}${S.hash}" `),_o(O==null||O[O.length-1].route.element!==void 0||O[O.length-1].route.Component!==void 0||O[O.length-1].route.lazy!==void 0,`Matched leaf route at location "${S.pathname}${S.search}${S.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 M=ZE(O&&O.map(F=>Object.assign({},F,{params:Object.assign({},h,F.params),pathname:ic([y,i.encodeLocation?i.encodeLocation(F.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:F.pathname]),pathnameBase:F.pathnameBase==="/"?y:ic([y,i.encodeLocation?i.encodeLocation(F.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:F.pathnameBase])})),c,a,s,n);return r&&M?_.createElement(Uf.Provider,{value:{location:Te({pathname:"/",search:"",hash:"",state:null,key:"default"},S),navigationType:"POP"}},M):M}function GE(){let e=t8(),r=LE(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},c=null;return console.error("Error handled by React Router default ErrorBoundary:",e),c=_.createElement(_.Fragment,null,_.createElement("p",null,"💿 Hey developer 👋"),_.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",_.createElement("code",{style:i},"ErrorBoundary")," or"," ",_.createElement("code",{style:i},"errorElement")," prop on your route.")),_.createElement(_.Fragment,null,_.createElement("h2",null,"Unexpected Application Error!"),_.createElement("h3",{style:{fontStyle:"italic"}},r),a?_.createElement("pre",{style:n},a):null,c)}var YE=_.createElement(GE,null),qE=class extends _.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?_.createElement(fl.Provider,{value:this.props.routeContext},_.createElement(ry.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function XE({routeContext:e,match:r,children:a}){let s=_.useContext(Q0);return s&&s.static&&s.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=r.route.id),_.createElement(fl.Provider,{value:e},a)}function ZE(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,c=a==null?void 0:a.errors;if(c!=null){let y=i.findIndex(w=>w.route.id&&(c==null?void 0:c[w.route.id])!==void 0);Is(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(c).join(",")}`),i=i.slice(0,Math.min(i.length,y+1))}let u=!1,h=-1;if(a)for(let y=0;y<i.length;y++){let w=i[y];if((w.route.HydrateFallback||w.route.hydrateFallbackElement)&&(h=y),w.route.id){let{loaderData:E,errors:S}=a,A=w.route.loader&&!E.hasOwnProperty(w.route.id)&&(!S||S[w.route.id]===void 0);if(w.route.lazy||A){u=!0,h>=0?i=i.slice(0,h+1):i=[i[0]];break}}}let g=a&&s?(y,w)=>{var E,S,A;s(y,{location:a.location,params:(A=(S=(E=a.matches)==null?void 0:E[0])==null?void 0:S.params)!=null?A:{},unstable_pattern:BE(a.matches),errorInfo:w})}:void 0;return i.reduceRight((y,w,E)=>{let S,A=!1,C=null,O=null;a&&(S=c&&w.route.id?c[w.route.id]:void 0,C=w.route.errorElement||YE,u&&(h<0&&E===0?(U4("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),A=!0,O=null):h===E&&(A=!0,O=w.route.hydrateFallbackElement||null)));let M=r.concat(i.slice(0,E+1)),R=()=>{let F;return S?F=C:A?F=O:w.route.Component?F=_.createElement(w.route.Component,null):w.route.element?F=w.route.element:F=y,_.createElement(XE,{match:w,routeContext:{outlet:y,matches:M,isDataRoute:a!=null},children:F})};return a&&(w.route.ErrorBoundary||w.route.errorElement||E===0)?_.createElement(qE,{location:a.location,revalidation:a.revalidation,component:C,error:S,children:R(),routeContext:{outlet:null,matches:M,isDataRoute:!0},onError:g}):R()},null)}function ay(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function KE(e){let r=_.useContext(Q0);return Is(r,ay(e)),r}function JE(e){let r=_.useContext(hg);return Is(r,ay(e)),r}function QE(e){let r=_.useContext(fl);return Is(r,ay(e)),r}function sy(e){let r=QE(e),a=r.matches[r.matches.length-1];return Is(a.route.id,`${e} can only be used on routes that contain a unique "id"`),a.route.id}function e8(){return sy("useRouteId")}function t8(){var s;let e=_.useContext(ry),r=JE("useRouteError"),a=sy("useRouteError");return e!==void 0?e:(s=r.errors)==null?void 0:s[a]}function r8(){let{router:e}=KE("useNavigate"),r=sy("useNavigate"),a=_.useRef(!1);return L4(()=>{a.current=!0}),_.useCallback((c,...u)=>me(null,[c,...u],function*(n,i={}){_o(a.current,P4),a.current&&(typeof n=="number"?yield e.navigate(n):yield e.navigate(n,Te({fromRouteId:r},i)))}),[e,r])}var Jw={};function U4(e,r,a){!r&&!Jw[e]&&(Jw[e]=!0,_o(!1,a))}_.memo(a8);function a8({routes:e,future:r,state:a,unstable_onError:s}){return B4(e,void 0,a,s,r)}function Um({to:e,replace:r,state:a,relative:s}){Is(eu(),"<Navigate> may be used only in the context of a <Router> component.");let{static:n}=_.useContext(qo);_o(!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}=_.useContext(fl),{pathname:c}=hl(),u=Na(),h=ty(e,ey(i),c,s==="path"),g=JSON.stringify(h);return _.useEffect(()=>{u(JSON.parse(g),{replace:r,state:a,relative:s})},[u,g,s,r,a]),null}function _a(e){Is(!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 s8({basename:e="/",children:r=null,location:a,navigationType:s="POP",navigator:n,static:i=!1,unstable_useTransitions:c}){Is(!eu(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let u=e.replace(/^\/*/,"/"),h=_.useMemo(()=>({basename:u,navigator:n,static:i,unstable_useTransitions:c,future:{}}),[u,n,i,c]);typeof a=="string"&&(a=J0(a));let{pathname:g="/",search:y="",hash:w="",state:E=null,key:S="default"}=a,A=_.useMemo(()=>{let C=dc(g,u);return C==null?null:{location:{pathname:C,search:y,hash:w,state:E,key:S},navigationType:s}},[u,g,y,w,E,S,s]);return _o(A!=null,`<Router basename="${u}"> is not able to match the URL "${g}${y}${w}" because it does not start with the basename, so the <Router> won't render anything.`),A==null?null:_.createElement(qo.Provider,{value:h},_.createElement(Uf.Provider,{children:r,value:A}))}function n8({children:e,location:r}){return VE(v1(e),r)}function v1(e,r=[]){let a=[];return _.Children.forEach(e,(s,n)=>{if(!_.isValidElement(s))return;let i=[...r,n];if(s.type===_.Fragment){a.push.apply(a,v1(s.props.children,i));return}Is(s.type===_a,`[${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>`),Is(!s.props.index||!s.props.children,"An index route cannot have child routes.");let c={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&&(c.children=v1(s.props.children,i)),a.push(c)}),a}var Tm="get",Am="application/x-www-form-urlencoded";function mg(e){return typeof HTMLElement!="undefined"&&e instanceof HTMLElement}function i8(e){return mg(e)&&e.tagName.toLowerCase()==="button"}function o8(e){return mg(e)&&e.tagName.toLowerCase()==="form"}function l8(e){return mg(e)&&e.tagName.toLowerCase()==="input"}function c8(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function d8(e,r){return e.button===0&&(!r||r==="_self")&&!c8(e)}function w1(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 u8(e,r){let a=w1(e);return r&&r.forEach((s,n)=>{a.has(n)||r.getAll(n).forEach(i=>{a.append(n,i)})}),a}var nm=null;function f8(){if(nm===null)try{new FormData(document.createElement("form"),0),nm=!1}catch(e){nm=!0}return nm}var h8=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Rp(e){return e!=null&&!h8.has(e)?(_o(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Am}"`),null):e}function m8(e,r){let a,s,n,i,c;if(o8(e)){let u=e.getAttribute("action");s=u?dc(u,r):null,a=e.getAttribute("method")||Tm,n=Rp(e.getAttribute("enctype"))||Am,i=new FormData(e)}else if(i8(e)||l8(e)&&(e.type==="submit"||e.type==="image")){let u=e.form;if(u==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let h=e.getAttribute("formaction")||u.getAttribute("action");if(s=h?dc(h,r):null,a=e.getAttribute("formmethod")||u.getAttribute("method")||Tm,n=Rp(e.getAttribute("formenctype"))||Rp(u.getAttribute("enctype"))||Am,i=new FormData(u,e),!f8()){let{name:g,type:y,value:w}=e;if(y==="image"){let E=g?`${g}.`:"";i.append(`${E}x`,"0"),i.append(`${E}y`,"0")}else g&&i.append(g,w)}}else{if(mg(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');a=Tm,s=null,n=Am,c=e}return i&&n==="text/plain"&&(c=i,i=void 0),{action:s,method:a.toLowerCase(),encType:n,formData:i,body:c}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function ny(e,r){if(e===!1||e===null||typeof e=="undefined")throw new Error(r)}function g8(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&&dc(s.pathname,r)==="/"?s.pathname=`${r.replace(/\/$/,"")}/_root.${a}`:s.pathname=`${s.pathname.replace(/\/$/,"")}.${a}`,s}function x8(e,r){return me(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 p8(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 y8(e,r,a){return me(this,null,function*(){let s=yield Promise.all(e.map(n=>me(null,null,function*(){let i=r.routes[n.route.id];if(i){let c=yield x8(i,a);return c.links?c.links():[]}return[]})));return _8(s.flat(1).filter(p8).filter(n=>n.rel==="stylesheet"||n.rel==="preload").map(n=>n.rel==="stylesheet"?Ke(Te({},n),{rel:"prefetch",as:"style"}):Ke(Te({},n),{rel:"prefetch"})))})}function Qw(e,r,a,s,n,i){let c=(h,g)=>a[g]?h.route.id!==a[g].route.id:!0,u=(h,g)=>{var y;return a[g].pathname!==h.pathname||((y=a[g].route.path)==null?void 0:y.endsWith("*"))&&a[g].params["*"]!==h.params["*"]};return i==="assets"?r.filter((h,g)=>c(h,g)||u(h,g)):i==="data"?r.filter((h,g)=>{var w;let y=s.routes[h.route.id];if(!y||!y.hasLoader)return!1;if(c(h,g)||u(h,g))return!0;if(h.route.shouldRevalidate){let E=h.route.shouldRevalidate({currentUrl:new URL(n.pathname+n.search+n.hash,window.origin),currentParams:((w=a[0])==null?void 0:w.params)||{},nextUrl:new URL(e,window.origin),nextParams:h.params,defaultShouldRevalidate:!0});if(typeof E=="boolean")return E}return!0}):[]}function b8(e,r,{includeHydrateFallback:a}={}){return v8(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 v8(e){return[...new Set(e)]}function w8(e){let r={},a=Object.keys(e).sort();for(let s of a)r[s]=e[s];return r}function _8(e,r){let a=new Set;return new Set(r),e.reduce((s,n)=>{let i=JSON.stringify(w8(n));return a.has(i)||(a.add(i),s.push({key:i,link:n})),s},[])}function z4(){let e=_.useContext(Q0);return ny(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function k8(){let e=_.useContext(hg);return ny(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var iy=_.createContext(void 0);iy.displayName="FrameworkContext";function W4(){let e=_.useContext(iy);return ny(e,"You must render this element inside a <HydratedRouter> element"),e}function N8(e,r){let a=_.useContext(iy),[s,n]=_.useState(!1),[i,c]=_.useState(!1),{onFocus:u,onBlur:h,onMouseEnter:g,onMouseLeave:y,onTouchStart:w}=r,E=_.useRef(null);_.useEffect(()=>{if(e==="render"&&c(!0),e==="viewport"){let C=M=>{M.forEach(R=>{c(R.isIntersecting)})},O=new IntersectionObserver(C,{threshold:.5});return E.current&&O.observe(E.current),()=>{O.disconnect()}}},[e]),_.useEffect(()=>{if(s){let C=setTimeout(()=>{c(!0)},100);return()=>{clearTimeout(C)}}},[s]);let S=()=>{n(!0)},A=()=>{n(!1),c(!1)};return a?e!=="intent"?[i,E,{}]:[i,E,{onFocus:Xu(u,S),onBlur:Xu(h,A),onMouseEnter:Xu(g,S),onMouseLeave:Xu(y,A),onTouchStart:Xu(w,S)}]:[!1,E,{}]}function Xu(e,r){return a=>{e&&e(a),a.defaultPrevented||r(a)}}function j8(a){var s=a,{page:e}=s,r=Ji(s,["page"]);let{router:n}=z4(),i=_.useMemo(()=>D4(n.routes,e,n.basename),[n.routes,e,n.basename]);return i?_.createElement(C8,Te({page:e,matches:i},r)):null}function S8(e){let{manifest:r,routeModules:a}=W4(),[s,n]=_.useState([]);return _.useEffect(()=>{let i=!1;return y8(e,r,a).then(c=>{i||n(c)}),()=>{i=!0}},[e,r,a]),s}function C8(s){var n=s,{page:e,matches:r}=n,a=Ji(n,["page","matches"]);let i=hl(),{manifest:c,routeModules:u}=W4(),{basename:h}=z4(),{loaderData:g,matches:y}=k8(),w=_.useMemo(()=>Qw(e,r,y,c,i,"data"),[e,r,y,c,i]),E=_.useMemo(()=>Qw(e,r,y,c,i,"assets"),[e,r,y,c,i]),S=_.useMemo(()=>{if(e===i.pathname+i.search+i.hash)return[];let O=new Set,M=!1;if(r.forEach(F=>{var W;let z=c.routes[F.route.id];!z||!z.hasLoader||(!w.some(X=>X.route.id===F.route.id)&&F.route.id in g&&((W=u[F.route.id])!=null&&W.shouldRevalidate)||z.hasClientLoader?M=!0:O.add(F.route.id))}),O.size===0)return[];let R=g8(e,h,"data");return M&&O.size>0&&R.searchParams.set("_routes",r.filter(F=>O.has(F.route.id)).map(F=>F.route.id).join(",")),[R.pathname+R.search]},[h,g,i,c,w,r,e,u]),A=_.useMemo(()=>b8(E,c),[E,c]),C=S8(E);return _.createElement(_.Fragment,null,S.map(O=>_.createElement("link",Te({key:O,rel:"prefetch",as:"fetch",href:O},a))),A.map(O=>_.createElement("link",Te({key:O,rel:"modulepreload",href:O},a))),C.map(({key:O,link:M})=>_.createElement("link",Te({key:O,nonce:a.nonce},M))))}function E8(...e){return r=>{e.forEach(a=>{typeof a=="function"?a(r):a!=null&&(a.current=r)})}}var H4=typeof window!="undefined"&&typeof window.document!="undefined"&&typeof window.document.createElement!="undefined";try{H4&&(window.__reactRouterVersion="7.10.0")}catch(e){}function T8({basename:e,children:r,unstable_useTransitions:a,window:s}){let n=_.useRef();n.current==null&&(n.current=mE({window:s,v5Compat:!0}));let i=n.current,[c,u]=_.useState({action:i.action,location:i.location}),h=_.useCallback(g=>{a===!1?u(g):_.startTransition(()=>u(g))},[a]);return _.useLayoutEffect(()=>i.listen(h),[i,h]),_.createElement(s8,{basename:e,children:r,location:c.location,navigationType:c.action,navigator:i,unstable_useTransitions:a===!0})}var $4=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,oy=_.forwardRef(function(A,S){var C=A,{onClick:r,discover:a="render",prefetch:s="none",relative:n,reloadDocument:i,replace:c,state:u,target:h,to:g,preventScrollReset:y,viewTransition:w}=C,E=Ji(C,["onClick","discover","prefetch","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"]);let{basename:O,unstable_useTransitions:M}=_.useContext(qo),R=typeof g=="string"&&$4.test(g),F,z=!1;if(typeof g=="string"&&R&&(F=g,H4))try{let K=new URL(window.location.href),ke=g.startsWith("//")?new URL(K.protocol+g):new URL(g),ge=dc(ke.pathname,O);ke.origin===K.origin&&ge!=null?g=ge+ke.search+ke.hash:z=!0}catch(K){_o(!1,`<Link to="${g}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let W=HE(g,{relative:n}),[X,B,Y]=N8(s,E),G=R8(g,{replace:c,state:u,target:h,preventScrollReset:y,relative:n,viewTransition:w,unstable_useTransitions:M});function ie(K){r&&r(K),K.defaultPrevented||G(K)}let fe=_.createElement("a",Ke(Te(Te({},E),Y),{href:F||W,onClick:z||i?r:ie,ref:E8(S,B),target:h,"data-discover":!R&&a==="render"?"true":void 0}));return X&&!R?_.createElement(_.Fragment,null,fe,_.createElement(j8,{page:W})):fe});oy.displayName="Link";var A8=_.forwardRef(function(w,y){var E=w,{"aria-current":r="page",caseSensitive:a=!1,className:s="",end:n=!1,style:i,to:c,viewTransition:u,children:h}=E,g=Ji(E,["aria-current","caseSensitive","className","end","style","to","viewTransition","children"]);let S=zf(c,{relative:g.relative}),A=hl(),C=_.useContext(hg),{navigator:O,basename:M}=_.useContext(qo),R=C!=null&&L8(S)&&u===!0,F=O.encodeLocation?O.encodeLocation(S).pathname:S.pathname,z=A.pathname,W=C&&C.navigation&&C.navigation.location?C.navigation.location.pathname:null;a||(z=z.toLowerCase(),W=W?W.toLowerCase():null,F=F.toLowerCase()),W&&M&&(W=dc(W,M)||W);const X=F!=="/"&&F.endsWith("/")?F.length-1:F.length;let B=z===F||!n&&z.startsWith(F)&&z.charAt(X)==="/",Y=W!=null&&(W===F||!n&&W.startsWith(F)&&W.charAt(F.length)==="/"),G={isActive:B,isPending:Y,isTransitioning:R},ie=B?r:void 0,fe;typeof s=="function"?fe=s(G):fe=[s,B?"active":null,Y?"pending":null,R?"transitioning":null].filter(Boolean).join(" ");let K=typeof i=="function"?i(G):i;return _.createElement(oy,Ke(Te({},g),{"aria-current":ie,className:fe,ref:y,style:K,to:c,viewTransition:u}),typeof h=="function"?h(G):h)});A8.displayName="NavLink";var O8=_.forwardRef((A,S)=>{var C=A,{discover:e="render",fetcherKey:r,navigate:a,reloadDocument:s,replace:n,state:i,method:c=Tm,action:u,onSubmit:h,relative:g,preventScrollReset:y,viewTransition:w}=C,E=Ji(C,["discover","fetcherKey","navigate","reloadDocument","replace","state","method","action","onSubmit","relative","preventScrollReset","viewTransition"]);let{unstable_useTransitions:O}=_.useContext(qo),M=M8(),R=P8(u,{relative:g}),F=c.toLowerCase()==="get"?"get":"post",z=typeof u=="string"&&$4.test(u),W=X=>{if(h&&h(X),X.defaultPrevented)return;X.preventDefault();let B=X.nativeEvent.submitter,Y=(B==null?void 0:B.getAttribute("formmethod"))||c,G=()=>M(B||X.currentTarget,{fetcherKey:r,method:Y,navigate:a,replace:n,state:i,relative:g,preventScrollReset:y,viewTransition:w});O&&a!==!1?_.startTransition(()=>G()):G()};return _.createElement("form",Ke(Te({ref:S,method:F,action:R,onSubmit:s?h:W},E),{"data-discover":!z&&e==="render"?"true":void 0}))});O8.displayName="Form";function D8(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function V4(e){let r=_.useContext(Q0);return Is(r,D8(e)),r}function R8(e,{target:r,replace:a,state:s,preventScrollReset:n,relative:i,viewTransition:c,unstable_useTransitions:u}={}){let h=Na(),g=hl(),y=zf(e,{relative:i});return _.useCallback(w=>{if(d8(w,r)){w.preventDefault();let E=a!==void 0?a:Nf(g)===Nf(y),S=()=>h(e,{replace:E,state:s,preventScrollReset:n,relative:i,viewTransition:c});u?_.startTransition(()=>S()):S()}},[g,h,y,a,s,r,e,n,i,c,u])}function Sn(e){_o(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=_.useRef(w1(e)),a=_.useRef(!1),s=hl(),n=_.useMemo(()=>u8(s.search,a.current?null:r.current),[s.search]),i=Na(),c=_.useCallback((u,h)=>{const g=w1(typeof u=="function"?u(new URLSearchParams(n)):u);a.current=!0,i("?"+g,h)},[i,n]);return[n,c]}var F8=0,I8=()=>`__${String(++F8)}__`;function M8(){let{router:e}=V4("useSubmit"),{basename:r}=_.useContext(qo),a=e8(),s=e.fetch,n=e.navigate;return _.useCallback((u,...h)=>me(null,[u,...h],function*(i,c={}){let{action:g,method:y,encType:w,formData:E,body:S}=m8(i,r);if(c.navigate===!1){let A=c.fetcherKey||I8();yield s(A,a,c.action||g,{preventScrollReset:c.preventScrollReset,formData:E,body:S,formMethod:c.method||y,formEncType:c.encType||w,flushSync:c.flushSync})}else yield n(c.action||g,{preventScrollReset:c.preventScrollReset,formData:E,body:S,formMethod:c.method||y,formEncType:c.encType||w,replace:c.replace,state:c.state,fromRouteId:a,flushSync:c.flushSync,viewTransition:c.viewTransition})}),[s,n,r,a])}function P8(e,{relative:r}={}){let{basename:a}=_.useContext(qo),s=_.useContext(fl);Is(s,"useFormAction must be used inside a RouteContext");let[n]=s.matches.slice(-1),i=Te({},zf(e||".",{relative:r})),c=hl();if(e==null){i.search=c.search;let u=new URLSearchParams(i.search),h=u.getAll("index");if(h.some(y=>y==="")){u.delete("index"),h.filter(w=>w).forEach(w=>u.append("index",w));let y=u.toString();i.search=y?`?${y}`:""}}return(!e||e===".")&&n.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),a!=="/"&&(i.pathname=i.pathname==="/"?a:ic([a,i.pathname])),Nf(i)}function L8(e,{relative:r}={}){let a=_.useContext(M4);Is(a!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:s}=V4("useViewTransitionState"),n=zf(e,{relative:r});if(!a.isTransitioning)return!1;let i=dc(a.currentLocation.pathname,s)||a.currentLocation.pathname,c=dc(a.nextLocation.pathname,s)||a.nextLocation.pathname;return Bm(n.pathname,c)!=null||Bm(n.pathname,i)!=null}var gg=_4();const B8="modulepreload",U8=function(e){return"/assets/asm_ui_app/asm_app/"+e},e_={},Nd=function(r,a,s){let n=Promise.resolve();if(a&&a.length>0){let h=function(g){return Promise.all(g.map(y=>Promise.resolve(y).then(w=>({status:"fulfilled",value:w}),w=>({status:"rejected",reason:w}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),u=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));n=h(a.map(g=>{if(g=U8(g),g in e_)return;e_[g]=!0;const y=g.endsWith(".css"),w=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${g}"]${w}`))return;const E=document.createElement("link");if(E.rel=y?"stylesheet":B8,y||(E.as="script"),E.crossOrigin="",E.href=g,u&&E.setAttribute("nonce",u),document.head.appendChild(E),y)return new Promise((S,A)=>{E.addEventListener("load",S),E.addEventListener("error",()=>A(new Error(`Unable to preload CSS for ${g}`)))})}))}function i(c){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=c,window.dispatchEvent(u),!u.defaultPrevented)throw c}return n.then(c=>{for(const u of c||[])u.status==="rejected"&&i(u.reason);return r().catch(i)})},Fp="asm_post_pwd_reset",z8=!1,W8=()=>{const[e,r]=_.useState({email:"",password:""}),[a,s]=_.useState(!1),[n,i]=_.useState(null),[c,u]=_.useState(!1),[h,g]=_.useState(""),[y,w]=_.useState(!1),[E,S]=_.useState(null),[A,C]=_.useState(null),[O,M]=_.useState(()=>typeof window!="undefined"&&new URLSearchParams(window.location.search).get("manual_login")==="1"),[R,F]=_.useState(!1),z=_.useRef(null),W=_.useRef(!1),X=Na(),[B]=Sn(),{t:Y}=Rr(),G=ve=>(ve.role_profile_name||"")==="End User"?"/work-orders":"/dashboard";_.useEffect(()=>{sessionStorage.getItem(Fp)==="1"&&(sessionStorage.removeItem(Fp),F(!0))},[]),_.useEffect(()=>{B.get("manual_login")!=="1"||W.current||(W.current=!0,me(null,null,function*(){try{localStorage.removeItem("user"),localStorage.removeItem("frappe_session_id");const ve=(yield Nd(()=>me(null,null,function*(){const{default:ce}=yield Promise.resolve().then(()=>Op);return{default:ce}}),[])).default;try{yield ve.logout()}catch(ce){}sessionStorage.setItem(Fp,"1")}catch(ve){console.warn("Post-reset session clear:",ve)}finally{X({pathname:"/login",search:""},{replace:!0}),M(!1)}}))},[B,X]);const ie="/assets/asm_ui_app/asm_app/",fe="?v=1768316563",K=ve=>{const{name:ce,value:ye}=ve.target;r(te=>Ke(Te({},te),{[ce]:ye})),i(null)},ke=ve=>me(null,null,function*(){var ce;ve.preventDefault(),s(!0),i(null);try{const ye=(yield Nd(()=>me(null,null,function*(){const{default:q}=yield Promise.resolve().then(()=>Op);return{default:q}}),void 0)).default,te=yield ye.login(e);if(te&&te.message){const q=Ke(Te({},te.message),{email:e.email});localStorage.setItem("user",JSON.stringify(q)),te.message.sid&&ye.setSessionId(te.message.sid);try{yield Q1()}catch(J){console.warn("Could not load translations after login:",J)}try{const ae=yield(yield fetch(`/api/method/frappe.client.get?doctype=User&name=${encodeURIComponent(e.email)}&fields=["role_profile_name"]`,{credentials:"include"})).json(),oe=((ce=ae==null?void 0:ae.message)==null?void 0:ce.role_profile_name)||"",le=Ke(Te({},q),{role_profile_name:oe});localStorage.setItem("user",JSON.stringify(le)),X(G(le))}catch(J){X(G(q))}}else i(Y("login.loginFailed"))}catch(ye){console.error("Login error:",ye),i(ye.message||Y("login.loginFailed"))}finally{s(!1)}}),ge=()=>{var ve;(ve=z.current)==null||ve.abort(),z.current=null,u(!1),S(null),C(null),w(!1)},re=()=>{var ve;(ve=z.current)==null||ve.abort(),z.current=null,g(e.email),S(null),C(null),w(!1),u(!0)},we=ve=>{if(!ve||typeof ve!="object")return"";const ce=ve,ye=ce.message;if(typeof ye=="string")return ye;if(ye&&typeof ye=="object"){const te=ye.message;if(typeof te=="string")return te}if(Array.isArray(ce._server_messages)&&ce._server_messages.length>0)try{const te=JSON.parse(String(ce._server_messages[0]));return typeof te.message=="string"?te.message:""}catch(te){return""}return""},ee=ve=>me(null,null,function*(){var J;ve.preventDefault(),S(null),C(null);const ce=h.trim();if(!ce){S(Y("login.forgotPasswordUserRequired"));return}(J=z.current)==null||J.abort();const ye=new AbortController;z.current=ye;const q=window.setTimeout(()=>ye.abort(),45e3);w(!0);try{const ae=(yield Nd(()=>me(null,null,function*(){const{default:pe}=yield Promise.resolve().then(()=>Op);return{default:pe}}),void 0)).default,oe=window,le=oe.csrf_token||(yield ae.getCSRFToken())||"";le&&(oe.csrf_token=le);const be=yield fetch("/api/method/frappe.core.doctype.user.user.reset_password",{method:"POST",credentials:"include",signal:ye.signal,headers:Te({Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},le?{"X-Frappe-CSRF-Token":le}:{}),body:new URLSearchParams({user:ce})}),Z=yield be.text();let Le={};try{Le=Z?JSON.parse(Z):{}}catch(pe){Le={}}const Pe=we(Le).trim(),Be=Pe.toLowerCase();if(be.ok){if(Be==="not allowed"||Be==="disabled"){S(Y("login.forgotPasswordCannotReset"));return}C(Y("login.forgotPasswordSentSuccess"));return}if(be.status===403){S(Y("login.forgotPasswordFailed"));return}if(be.status===404||Be==="not found"){S(Y("login.forgotPasswordNotFound"));return}S(Pe||Y("login.loginFailed"))}catch(ae){if((ae instanceof Error?ae.name:"")==="AbortError"){S(Y("login.forgotPasswordTimeout"));return}S(Y("login.loginFailed"))}finally{clearTimeout(q),w(!1),z.current===ye&&(z.current=null)}});return O?t.jsx("div",{className:"flex min-h-screen items-center justify-center bg-gray-50 dark:bg-gray-900 px-4",children:t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:Y("login.finishingSignOut")})}):t.jsxs("div",{className:"flex min-h-screen items-center justify-center bg-gray-50 px-4 py-12 dark:bg-gray-900 sm:px-6 lg:px-8",children:[t.jsxs("div",{className:"w-full max-w-md space-y-8",children:[t.jsxs("div",{children:[t.jsx("div",{className:"mb-6 flex justify-center",children:t.jsxs("div",{className:"flex h-32 w-32 items-center justify-center rounded-2xl bg-white p-4 shadow-2xl dark:bg-gray-800",children:[t.jsx("img",{src:`${ie}${ie.endsWith("/")?"":"/"}seera-logo.png${fe}`,alt:"Seera Arabia",className:"h-full w-full object-contain",onError:ve=>{const ce=ve.currentTarget.parentElement;ce&&ce.classList.add("bg-gradient-to-br","from-indigo-600","to-purple-600"),ve.currentTarget.style.display="none";const ye=ve.currentTarget.nextElementSibling;ye&&ye.classList.remove("hidden")}}),t.jsxs("svg",{className:"hidden h-20 w-20",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:Y("login.title")}),t.jsx("p",{className:"mt-2 text-center text-sm font-medium text-indigo-600 dark:text-indigo-400",children:Y("login.subtitle")}),t.jsx("p",{className:"mt-1 text-center text-xs text-gray-600 dark:text-gray-400",children:Y("login.signIn")})]}),R&&t.jsx("div",{className:"rounded-md border border-green-200 bg-green-50 p-3 text-sm text-green-800 dark:border-green-800 dark:bg-green-900/30 dark:text-green-200",children:Y("login.afterPasswordResetSignIn")}),t.jsxs("form",{className:"mt-8 space-y-6",onSubmit:ke,children:[t.jsxs("div",{className:"-space-y-px rounded-md shadow-sm",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"email",className:"sr-only",children:Y("common.email")}),t.jsx("input",{id:"email",name:"email",type:"email",required:!0,className:"relative block w-full appearance-none rounded-none rounded-t-md border border-gray-300 bg-white px-3 py-2 text-gray-900 placeholder-gray-500 focus:z-10 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 sm:text-sm",placeholder:Y("login.emailPlaceholder"),value:e.email,onChange:K})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"password",className:"sr-only",children:Y("common.password")}),t.jsx("input",{id:"password",name:"password",type:"password",required:!0,className:"relative block w-full appearance-none rounded-none rounded-b-md border border-gray-300 bg-white px-3 py-2 text-gray-900 placeholder-gray-500 focus:z-10 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 sm:text-sm",placeholder:Y("login.passwordPlaceholder"),value:e.password,onChange:K})]})]}),n&&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:n})}),t.jsxs("div",{className:"space-y-3",children:[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:a?t.jsxs("div",{className:"flex items-center",children:[t.jsxs("svg",{className:"-ml-1 mr-3 h-5 w-5 animate-spin 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"})]}),Y("common.loading")]}):Y("common.login")}),t.jsx("div",{className:"text-center",children:t.jsx("button",{type:"button",onClick:re,className:"text-sm font-medium text-indigo-600 hover:text-indigo-500 dark:text-indigo-400",children:Y("login.forgotPassword")})}),z8]})]})]}),c&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",role:"dialog","aria-modal":"true","aria-labelledby":"forgot-password-title",onClick:ve=>{ve.target===ve.currentTarget&&ge()},children:t.jsxs("div",{className:"w-full max-w-md rounded-lg bg-white p-6 shadow-xl dark:bg-gray-800",children:[t.jsx("h3",{id:"forgot-password-title",className:"text-lg font-semibold text-gray-900 dark:text-white",children:Y("login.forgotPasswordTitle")}),t.jsx("p",{className:"mt-2 text-sm text-gray-600 dark:text-gray-400",children:Y("login.forgotPasswordHint")}),t.jsxs("form",{className:"mt-4 space-y-4",onSubmit:ee,children:[t.jsx("input",{type:"text",autoComplete:"username",className:"block w-full rounded-md border border-gray-300 px-3 py-2 text-gray-900 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white sm:text-sm",placeholder:Y("login.forgotPasswordUserPlaceholder"),value:h,onChange:ve=>g(ve.target.value)}),E&&t.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:E}),A&&t.jsx("p",{className:"text-sm text-green-700 dark:text-green-400",children:A}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:ge,className:"rounded-md border border-gray-300 px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:text-gray-200 dark:hover:bg-gray-700",children:Y("login.forgotPasswordClose")}),t.jsx("button",{type:"submit",disabled:y,className:"rounded-md bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 disabled:opacity-50",children:Y(y?"common.loading":"login.forgotPasswordSubmit")})]})]})]})})]})};var G4={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},t_=ea.createContext&&ea.createContext(G4),H8=["attr","size","title"];function $8(e,r){if(e==null)return{};var a=V8(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 V8(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 zm(){return zm=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},zm.apply(this,arguments)}function r_(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 Wm(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?r_(Object(a),!0).forEach(function(s){G8(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):r_(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function G8(e,r,a){return r=Y8(r),r in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Y8(e){var r=q8(e,"string");return typeof r=="symbol"?r:r+""}function q8(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 Y4(e){return e&&e.map((r,a)=>ea.createElement(r.tag,Wm({key:a},r.attr),Y4(r.child)))}function Sr(e){return r=>ea.createElement(X8,zm({attr:Wm({},e.attr)},r),Y4(e.child))}function X8(e){var r=a=>{var{attr:s,size:n,title:i}=e,c=$8(e,H8),u=n||a.size||"1em",h;return a.className&&(h=a.className),e.className&&(h=(h?h+" ":"")+e.className),ea.createElement("svg",zm({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,s,c,{className:h,style:Wm(Wm({color:e.color||a.color},a.style),e.style),height:u,width:u,xmlns:"http://www.w3.org/2000/svg"}),i&&ea.createElement("title",null,i),e.children)};return t_!==void 0?ea.createElement(t_.Consumer,null,a=>r(a)):r(G4)}function Z8(e){return Sr({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 Kn(e){return Sr({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 K8(e){return Sr({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 po(e){return Sr({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 a_(e){return Sr({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 J8(e){return Sr({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 _1(e){return Sr({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 ly(e){return Sr({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 $o(e){return Sr({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 cy(e){return Sr({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 uf(e){return Sr({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 q4(e){return Sr({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M512 144v288c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V144c0-26.5 21.5-48 48-48h88l12.3-32.9c7-18.7 24.9-31.1 44.9-31.1h125.5c20 0 37.9 12.4 44.9 31.1L376 96h88c26.5 0 48 21.5 48 48zM376 288c0-66.2-53.8-120-120-120s-120 53.8-120 120 53.8 120 120 120 120-53.8 120-120zm-32 0c0 48.5-39.5 88-88 88s-88-39.5-88-88 39.5-88 88-88 88 39.5 88 88z"},child:[]}]})(e)}function X4(e){return Sr({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 Tr(e){return Sr({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 jn(e){return Sr({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 Z4(e){return Sr({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 on(e){return Sr({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 dy(e){return Sr({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 uy(e){return Sr({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 Mn(e){return Sr({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 Wo(e){return Sr({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 s_(e){return Sr({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 Ja(e){return Sr({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 Hm(e){return Sr({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 Q8(e){return Sr({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 Om(e){return Sr({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 tu(e){return Sr({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 Vo(e){return Sr({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 Ms(e){return Sr({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 Wf(e){return Sr({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 K4(e){return Sr({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 eT(e){return Sr({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 Jr(e){return Sr({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 ps(e){return Sr({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 Ip(e){return Sr({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 to(e){return Sr({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 tT(e){return Sr({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 ff(e){return Sr({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 No(e){return Sr({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 zi(e){return Sr({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 Ks(e){return Sr({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 Hf(e){return Sr({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 $m(e){return Sr({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 Hs(e){return Sr({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 Vm(e){return Sr({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 n_(e){return Sr({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 Id(e){return Sr({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 rT(e){return Sr({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 il(e){return Sr({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 Mp(e){return Sr({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 Pp(e){return Sr({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 J4(e){return Sr({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M48 48a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm0 160a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm0 160a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm448 16H176a16 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 aT(e){return Sr({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 k1(e){return Sr({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 sT(e){return Sr({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 Js(e){return Sr({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 Go(e){return Sr({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 jd(e){return Sr({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 bs(e){return Sr({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 In(e){return Sr({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 fy(e){return Sr({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 nT(e){return Sr({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 Ir(e){return Sr({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 ys(e){return Sr({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 ul(e){return Sr({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 iT(e){return Sr({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 Ui(e){return Sr({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 Q4(e){return Sr({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 oT(e){return Sr({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 rf(e){return Sr({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 Br(e){return Sr({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 Pt(e){return Sr({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 e3(e){return Sr({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 lT(e){return Sr({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 la(e){return Sr({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 Gm(e){return Sr({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 i_(e){return Sr({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 o_(e){return Sr({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 cT(e){return Sr({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 dT(e){return Sr({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 uT(e){return Sr({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 Yn(e){return Sr({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 Sd(e){return Sr({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 Md(e){return Sr({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)}const l_=220;function fT(e){var a;const r=e.match(/Duplicate entry\s+['"]([^'"]+)['"]\s+for key/i)||e.match(/Duplicate entry\s+([^\s,')]+)\s+for key/i);return((a=r==null?void 0:r[1])==null?void 0:a.trim())||void 0}function hT(e){var a,s;let r=e.replace(/\r\n/g,`
`).trim();if(r.startsWith('["')&&r.endsWith('"]'))try{const n=JSON.parse(r);Array.isArray(n)&&typeof n[0]=="string"&&(r=n[0])}catch(n){}if(r.includes("|")){const n=r.split("|"),i=(s=(a=n[n.length-1])==null?void 0:a.trim())!=null?s:r;i.length>0&&!i.includes('File "')&&(r=i)}if(r.includes("Traceback (most recent call last)")){const n=r.lastIndexOf("IntegrityError");if(n>=0)r=r.slice(n);else{const i=r.split(`
`).map(c=>c.trim()).filter(c=>c.length>0&&!c.startsWith('File "')).pop();i&&i.length<400&&(r=i)}}return r.replace(/\s+/g," ").trim()}function C0(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(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&#39;/g,"'").replace(/&quot;/g,'"'),r.replace(/[ \t]+\n/g,`
`).replace(/\n{3,}/g,`
`).replace(/ +/g," ").trim()}function t3(e){if(e==null)return"Something went wrong";if(e instanceof Error)return C0(e.message)||e.message;if(typeof e=="string")return C0(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 c of n)try{const u=typeof c=="string"?JSON.parse(c):c;u&&typeof u.message=="string"?i.push(C0(u.message)):typeof c=="string"&&i.push(C0(c))}catch(u){typeof c=="string"&&i.push(C0(c))}i.length&&(a=i.join(`
`))}}catch(s){}return!a&&typeof r.exc=="string"&&r.exc.length<800&&(a=r.exc),a?C0(a):"Request failed. Check stock, warehouses, and linked documents."}function mT(e){if(!e||typeof e!="string")return"Something went wrong. Please try again.";const r=fT(e);if(r||/1062/i.test(e)&&/Duplicate entry/i.test(e))return r?`This ID is already in use (${r}). Use a different location name or ID.`:"This record already exists. Use a unique name or ID.";let a=hT(e);const s=a.match(/IntegrityError\([^)]*"([^"]{1,180})"/i);return s!=null&&s[1]&&!s[1].includes("Traceback")&&(a=s[1]),a=a.replace(/^\(['"]?\w+['"]?,\s*['"][^'"]*['"]?\s*,\s*/i,""),a.length>l_?`${a.slice(0,l_-1)}…`:a||"Something went wrong. Please try again."}const r3="wo-feedback",a3="WO Feedback";function gT(){return me(this,null,function*(){const e=yield Xt.getCSRFToken();return e||Xt.getCSRFTokenForGuest()})}function s3(a){return me(this,arguments,function*(e,r={}){const s=yield gT(),n={Accept:"application/json","Content-Type":"application/json"};s&&(n["X-Frappe-CSRF-Token"]=s);const i=yield fetch(`${Or.BASE_URL}/api/method/${e}`,{method:"POST",credentials:"include",headers:n,body:JSON.stringify(r)}),c=yield i.json().catch(()=>({}));if(!i.ok||c.exc)throw new Error(t3(c)||(c==null?void 0:c.message)||`HTTP ${i.status}`);return Object.prototype.hasOwnProperty.call(c,"message")?c.message:null})}function xT(e){return e?e.split(`
`).map(r=>r.trim()).filter(Boolean):[]}function pT(e){return e?typeof document=="undefined"?e.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim():(new DOMParser().parseFromString(e,"text/html").body.textContent||"").replace(/\s+/g," ").trim():""}function n3(e){const r=(e==null?void 0:e.web_form)||{},s=(r.web_form_fields||[]).find(n=>n.fieldname==="rating");return{title:String(r.title||"WO Feedback"),introductionHtml:String(r.introduction_text||""),introductionText:pT(String(r.introduction_text||"")),buttonLabel:String(r.button_label||"Save"),successTitle:String(r.success_title||"Feedback Submitted"),successMessage:String(r.success_message||"Your feedback was submitted successfully."),ratingOptions:xT(s==null?void 0:s.options)}}function yT(){return me(this,null,function*(){const e=new URLSearchParams({doctype:a3,web_form_name:r3}),r=yield fetch(`${Or.BASE_URL}/api/method/frappe.website.doctype.web_form.web_form.get_form_data?${e}`,{credentials:"include",headers:{Accept:"application/json"}}),a=yield r.json().catch(()=>({}));if(!r.ok||a.exc)throw new Error(t3(a)||"Failed to load web form");return n3(a.message||a)})}function bT(e){return me(this,null,function*(){const r=yield s3("asset_lite.api.wo_feedback_api.get_wo_feedback_for_work_order",{work_order:e});return r!=null&&r.name?r:null})}function vT(e){return me(this,null,function*(){const r=JSON.stringify({work_order:e.work_order,requester_name:e.requester_name,rating:e.rating,comments:e.comments||"",doctype:a3});return s3("frappe.website.doctype.web_form.web_form.accept",{web_form:r3,data:r})})}const Dm={getWebFormConfig:yT,getFeedbackForWorkOrder:bT,submitFeedback:vT,parseWebFormConfig:n3},Lp="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-indigo-400",wT=({workOrder:e,defaultRequesterName:r="",compact:a=!1,onSuccess:s})=>{const[n,i]=_.useState("loading"),[c,u]=_.useState(null),[h,g]=_.useState(null),[y,w]=_.useState(r),[E,S]=_.useState(""),[A,C]=_.useState(""),[O,M]=_.useState(!1),[R,F]=_.useState("");_.useEffect(()=>{w(r)},[r]),_.useEffect(()=>{if(!e){i("error"),F("Work Order is required.");return}let X=!1;return me(null,null,function*(){i("loading"),F("");try{const[B,Y]=yield Promise.all([Dm.getWebFormConfig(),Dm.getFeedbackForWorkOrder(e)]);if(X)return;u(B),Y?(g(Y),i("existing")):i("form")}catch(B){if(X)return;F(B instanceof Error?B.message:"Failed to load feedback form"),i("error")}}),()=>{X=!0}},[e]);const z=X=>me(null,null,function*(){if(X.preventDefault(),!y.trim()){F("Requester Name is required.");return}if(!E){F("Please select a rating.");return}M(!0),F("");try{const B=yield Dm.submitFeedback({work_order:e,requester_name:y.trim(),rating:E,comments:A.trim()});g(B),i("success"),s==null||s(B)}catch(B){F(B instanceof Error?B.message:"Failed to submit feedback")}finally{M(!1)}});if(n==="loading")return t.jsxs("div",{className:`flex items-center justify-center gap-2 text-gray-500 ${a?"py-4":"py-10"}`,children:[t.jsx(Ir,{className:"animate-spin text-indigo-500"}),t.jsx("span",{className:"text-sm",children:"Loading feedback form…"})]});if(n==="error"&&!c)return t.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 dark:bg-red-900/20 dark:border-red-800 px-4 py-3 text-sm text-red-700 dark:text-red-300",children:R||"Unable to load feedback form."});const W=(c==null?void 0:c.title)||"WO Feedback";return n==="existing"&&h?t.jsxs("div",{className:a?"space-y-3":"space-y-4",children:[!a&&(c==null?void 0:c.introductionText)&&t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:c.introductionText}),t.jsxs("div",{className:"rounded-lg border border-green-200 dark:border-green-800 bg-green-50 dark:bg-green-900/20 p-4 text-center",children:[t.jsx(Tr,{className:"mx-auto text-green-600 mb-2"}),t.jsx("p",{className:"text-sm font-semibold text-green-800 dark:text-green-300",children:"Feedback already submitted"}),t.jsxs("p",{className:"text-xs text-green-700 dark:text-green-400 mt-2",children:[t.jsx("span",{className:"font-medium",children:"Requester:"})," ",h.requester_name||"—"]}),t.jsx("p",{className:"text-sm font-bold text-green-800 dark:text-green-200 mt-1",children:h.rating||"—"}),h.comments&&t.jsxs("p",{className:"text-xs text-green-700 dark:text-green-400 mt-2 text-left",children:[t.jsx("span",{className:"font-medium",children:"Comments:"})," ",h.comments]})]})]}):n==="success"&&h?t.jsxs("div",{className:`rounded-lg border border-green-200 dark:border-green-800 bg-green-50 dark:bg-green-900/20 p-4 text-center ${a?"":"py-8"}`,children:[t.jsx(Tr,{className:"mx-auto text-green-600 text-2xl mb-3"}),t.jsx("h3",{className:"text-base font-bold text-green-800 dark:text-green-200",children:(c==null?void 0:c.successTitle)||"Feedback Submitted"}),t.jsx("p",{className:"text-sm text-green-700 dark:text-green-300 mt-1",children:(c==null?void 0:c.successMessage)||"Your feedback was submitted successfully."}),t.jsx("p",{className:"text-xs text-green-600 dark:text-green-400 mt-3",children:h.rating}),h.comments&&t.jsx("p",{className:"text-xs text-green-600 dark:text-green-400 mt-2",children:h.comments})]}):t.jsxs("form",{onSubmit:z,className:a?"space-y-3":"space-y-4",children:[!a&&t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-white",children:W}),(c==null?void 0:c.introductionText)&&t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:c.introductionText})]}),a&&(c==null?void 0:c.introductionText)&&t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:c.introductionText}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase mb-1",children:"Work Order"}),t.jsx("div",{className:"px-3 py-2 text-sm bg-gray-100 dark:bg-gray-900/40 border border-gray-200 dark:border-gray-700 rounded-lg text-gray-800 dark:text-gray-200",children:e})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase mb-1",children:["Requester Name ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",value:y,onChange:X=>w(X.target.value),className:Lp,placeholder:"Your name",required:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase mb-1",children:["Rating ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("select",{value:E,onChange:X=>S(X.target.value),className:Lp,required:!0,children:[t.jsx("option",{value:"",children:"Select rating…"}),((c==null?void 0:c.ratingOptions)||[]).map(X=>t.jsx("option",{value:X,children:X},X))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase mb-1",children:"Comments"}),t.jsx("textarea",{value:A,onChange:X=>C(X.target.value),className:`${Lp} min-h-[88px] resize-y`,placeholder:"Optional comments…",rows:3})]}),R&&t.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:R}),t.jsx("button",{type:"submit",disabled:O,className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg text-sm font-medium disabled:opacity-50",children:O?t.jsxs(t.Fragment,{children:[t.jsx(Ir,{className:"animate-spin",size:14}),"Submitting…"]}):(c==null?void 0:c.buttonLabel)||"Save"})]})},_T=()=>{const[e]=Sn(),r=(e.get("work_order")||"").trim(),a="/assets/asm_ui_app/asm_app/",s=`${a}${a.endsWith("/")?"":"/"}seera-logo.png`;return t.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-white to-indigo-50 dark:from-gray-900 dark:via-gray-900 dark:to-indigo-950 flex flex-col items-center justify-center p-4",children:t.jsxs("div",{className:"w-full max-w-md",children:[t.jsx("div",{className:"flex justify-center mb-6",children:t.jsx("img",{src:s,alt:"Logo",className:"h-10 object-contain",onError:n=>{n.target.style.display="none"}})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-2xl shadow-xl border border-gray-200 dark:border-gray-700 p-6 md:p-8",children:r?t.jsxs(t.Fragment,{children:[t.jsx("h1",{className:"text-lg font-bold text-gray-900 dark:text-white mb-1 text-center",children:"Work Order Feedback"}),t.jsx(wT,{workOrder:r})]}):t.jsxs("div",{className:"text-center py-6",children:[t.jsx("h1",{className:"text-lg font-bold text-gray-900 dark:text-white mb-2",children:"Work Order Feedback"}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"A work order link is required. Please use the link shared with you, for example:"}),t.jsx("p",{className:"mt-3 text-xs font-mono text-indigo-600 dark:text-indigo-400 break-all",children:"/asm_app/wo-feedback?work_order=WO-00001"})]})})]})})};function xg(e,r=[]){const[a,s]=_.useState(null),[n,i]=_.useState(!0),[c,u]=_.useState(null),h=_.useCallback(()=>me(null,null,function*(){try{i(!0),u(null);const y=yield e();s(y)}catch(y){y instanceof vd?u(y.message):u(y instanceof Error?y.message:"Unknown error")}finally{i(!1)}}),r);_.useEffect(()=>{h()},[h]);const g=_.useCallback(()=>{h()},[h]);return{data:a,loading:n,error:c,refetch:g}}function kT(e){return xg(()=>Xt.getUserDetails(e),[e])}function NT(){return xg(()=>Xt.getDashboardStats())}function jT(){return xg(()=>Xt.getNumberCards())}function ST(e,r){return xg(()=>Xt.getDashboardChartData(e,r),[e,JSON.stringify(r||{})])}function CT(){const[e,r]=_.useState(Xt.isAuthenticated());return{isAuthenticated:e,login:n=>me(null,null,function*(){try{const i=yield Xt.login(n);if(i&&i.message)return i.message.sid&&Xt.setSessionId(i.message.sid),r(!0),i;throw new Error("Login failed")}catch(i){throw r(!1),i}}),logout:()=>me(null,null,function*(){try{yield Xt.logout()}finally{Xt.setSessionId(""),r(!1)}})}}const ET=()=>{const[e,r]=_.useState({}),[a,s]=_.useState(!1),n=()=>me(null,null,function*(){s(!0);const i={};try{console.log("Testing basic connectivity...");try{const c=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)});c.ok?i.csrfToken="✅ Basic Connectivity: SUCCESS":i.csrfToken=`❌ Basic Connectivity: HTTP ${c.status}`}catch(c){i.csrfToken=`❌ Basic Connectivity: ${c instanceof Error?c.message:"Unknown error"}`}console.log("Testing Frappe system endpoint...");try{yield Xt.apiCall("/api/method/frappe.auth.get_logged_user",{method:"GET",headers:{"Content-Type":"application/json"}}),i.dashboardStats="✅ Frappe System API: SUCCESS"}catch(c){const u=c instanceof Error?c.message:"Unknown";u.includes("403")||u.includes("401")?i.dashboardStats="✅ Frappe System API: SUCCESS (auth required)":i.dashboardStats=`❌ Frappe System API: ${u}`}console.log("Testing Custom User Details...");try{const c=yield Xt.getUserDetails();i.userDetails=c?"✅ Custom API: SUCCESS":"❌ Custom API: Failed"}catch(c){i.userDetails=`❌ Custom API (Expected): ${c instanceof Error?c.message:"Unknown"}`}console.log("Testing Custom Dashboard Stats...");try{const c=yield Xt.getDashboardStats();i.doctypeRecords=c?"✅ Custom Stats: SUCCESS":"❌ Custom Stats: Failed"}catch(c){i.doctypeRecords=`❌ Custom Stats (Expected): ${c instanceof Error?c.message:"Unknown"}`}}catch(c){console.error("API Test Error:",c),c instanceof vd?i.error=`${c.message} (Status: ${c.status})`:i.error=c instanceof Error?c.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"]})]})]})]})},Bp=e=>Number.isFinite(e)?Math.max(0,e):0;function TT({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 g=a[0].values.map(Bp),y=g.reduce((O,M)=>O+M,0)||1,w=Math.min(100,s/2-10),E=w+10,S=w+10;let A=0;const C=a[0].values.map((O,M)=>a[0].color||c_(M));return t.jsx("svg",{width:E*2,height:S*2,viewBox:`0 0 ${E*2} ${S*2}`,children:g.map((O,M)=>{const R=A/y*2*Math.PI;A+=O;const F=A/y*2*Math.PI,z=F-R>Math.PI?1:0,W=E+w*Math.cos(R),X=S+w*Math.sin(R),B=E+w*Math.cos(F),Y=S+w*Math.sin(F),G=`M ${E} ${S} L ${W} ${X} A ${w} ${w} 0 ${z} 1 ${B} ${Y} Z`;return t.jsx("path",{d:G,fill:C[M]},M)})})}const n=a,i=Math.max(...n.flatMap(g=>g.values.map(Bp)),1),c=Math.max(r.length*60,300),u=s-40,h=Math.max(20,(c-40)/r.length-10);return t.jsxs("svg",{width:c,height:s,viewBox:`0 0 ${c} ${s}`,children:[t.jsx("line",{x1:30,y1:10,x2:30,y2:u,stroke:"#e5e7eb"}),t.jsx("line",{x1:30,y1:u,x2:c-10,y2:u,stroke:"#e5e7eb"}),r.map((g,y)=>{const w=40+y*(h+10);let E=0;return t.jsxs("g",{children:[n.map((S,A)=>{const O=Bp(S.values[y]||0)/i*(u-20),M=u-O-E,R=S.color||c_(A);return E+=O,t.jsx("rect",{x:w,y:M,width:h,height:O,fill:R,rx:2},A)}),t.jsx("text",{x:w+h/2,y:s-5,textAnchor:"middle",fontSize:"10",fill:"#6b7280",children:AT(g,8)})]},y)})]})}function c_(e){const r=["#4F46E5","#10B981","#F59E0B","#EF4444","#6366F1","#22C55E","#E11D48"];return r[e%r.length]}function AT(e,r){return e.length>r?e.slice(0,r-1)+"…":e}const OT=({chartName:e,filters:r})=>{const{data:a,loading:s,error:n}=ST(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(TT,{type:a.type,labels:a.labels,datasets:a.datasets})]})},DT=()=>{var S,A,C,O;const[e,r]=_.useState(null),[a,s]=_.useState([]),n=Na(),{logout:i}=CT(),{loading:c,error:u}=NT(),{data:h}=jT(),{data:g,loading:y,error:w}=kT();_.useEffect(()=>{const M=localStorage.getItem("user");M?r(JSON.parse(M)):g&&r(g);const R=[{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(R)},[g]);const E=()=>me(null,null,function*(){try{yield i(),localStorage.removeItem("user"),n("/login")}catch(M){console.error("Logout error:",M),localStorage.removeItem("user"),n("/login")}});return c||y?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:E,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:[(u||w)&&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:u||w||"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:(S=h==null?void 0:h.total_assets)!=null?S:"-"})]})})]})})}),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:(A=h==null?void 0:h.work_orders_open)!=null?A:"-"})]})})]})})}),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:(C=h==null?void 0:h.work_orders_in_progress)!=null?C:"-"})]})})]})})}),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:(O=h==null?void 0:h.work_orders_completed)!=null?O:"-"})]})})]})})})]}),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(M=>t.jsx(OT,{chartName:M},M))}),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(M=>{var R;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:((R=M.full_name)==null?void 0:R.charAt(0))||M.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:M.full_name||M.name}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:M.email||"No email"})]})]}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(M.creation).toLocaleDateString()})]})},M.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(ET,{})})]})]})};var Ym={};Ym.version="0.18.5";var i3=1252,RT=[874,932,936,949,950,1250,1251,1252,1253,1254,1255,1256,1257,1258,1e4],hy={0:1252,1:65001,2:65001,77:1e4,128:932,129:949,130:1361,134:936,136:950,161:1253,162:1254,163:1258,177:1255,178:1256,186:1257,204:1251,222:874,238:1250,255:1252,69:6969},my=function(e){RT.indexOf(e)!=-1&&(i3=hy[0]=e)};function FT(){my(1252)}var ol=function(e){my(e)};function gy(){ol(1200),FT()}function d_(e){for(var r=[],a=0,s=e.length;a<s;++a)r[a]=e.charCodeAt(a);return r}function IT(e){for(var r=[],a=0;a<e.length>>1;++a)r[a]=String.fromCharCode(e.charCodeAt(2*a)+(e.charCodeAt(2*a+1)<<8));return r.join("")}function o3(e){for(var r=[],a=0;a<e.length>>1;++a)r[a]=String.fromCharCode(e.charCodeAt(2*a+1)+(e.charCodeAt(2*a)<<8));return r.join("")}var af=function(e){var r=e.charCodeAt(0),a=e.charCodeAt(1);return r==255&&a==254?IT(e.slice(2)):r==254&&a==255?o3(e.slice(2)):r==65279?e.slice(1):e},im=function(r){return String.fromCharCode(r)},u_=function(r){return String.fromCharCode(r)},jf,$c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Sf(e){for(var r="",a=0,s=0,n=0,i=0,c=0,u=0,h=0,g=0;g<e.length;)a=e.charCodeAt(g++),i=a>>2,s=e.charCodeAt(g++),c=(a&3)<<4|s>>4,n=e.charCodeAt(g++),u=(s&15)<<2|n>>6,h=n&63,isNaN(s)?u=h=64:isNaN(n)&&(h=64),r+=$c.charAt(i)+$c.charAt(c)+$c.charAt(u)+$c.charAt(h);return r}function ko(e){var r="",a=0,s=0,n=0,i=0,c=0,u=0,h=0;e=e.replace(/[^\w\+\/\=]/g,"");for(var g=0;g<e.length;)i=$c.indexOf(e.charAt(g++)),c=$c.indexOf(e.charAt(g++)),a=i<<2|c>>4,r+=String.fromCharCode(a),u=$c.indexOf(e.charAt(g++)),s=(c&15)<<4|u>>2,u!==64&&(r+=String.fromCharCode(s)),h=$c.indexOf(e.charAt(g++)),n=(u&3)<<6|h,h!==64&&(r+=String.fromCharCode(n));return r}var Ca=(function(){return typeof Buffer!="undefined"&&typeof process!="undefined"&&typeof process.versions!="undefined"&&!!process.versions.node})(),hc=(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 Gc(e){return Ca?Buffer.alloc?Buffer.alloc(e):new Buffer(e):typeof Uint8Array!="undefined"?new Uint8Array(e):new Array(e)}function f_(e){return Ca?Buffer.allocUnsafe?Buffer.allocUnsafe(e):new Buffer(e):typeof Uint8Array!="undefined"?new Uint8Array(e):new Array(e)}var vo=function(r){return Ca?hc(r,"binary"):r.split("").map(function(a){return a.charCodeAt(0)&255})};function pg(e){if(typeof ArrayBuffer=="undefined")return vo(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 Zc(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 MT(e){if(typeof Uint8Array=="undefined")throw new Error("Unsupported");return new Uint8Array(e)}function xy(e){if(typeof ArrayBuffer=="undefined")throw new Error("Unsupported");if(e instanceof ArrayBuffer)return xy(new Uint8Array(e));for(var r=new Array(e.length),a=0;a<e.length;++a)r[a]=e[a];return r}var qn=Ca?function(e){return Buffer.concat(e.map(function(r){return Buffer.isBuffer(r)?r:hc(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 PT(e){for(var r=[],a=0,s=e.length+250,n=Gc(e.length+255),i=0;i<e.length;++i){var c=e.charCodeAt(i);if(c<128)n[a++]=c;else if(c<2048)n[a++]=192|c>>6&31,n[a++]=128|c&63;else if(c>=55296&&c<57344){c=(c&1023)+64;var u=e.charCodeAt(++i)&1023;n[a++]=240|c>>8&7,n[a++]=128|c>>2&63,n[a++]=128|u>>6&15|(c&3)<<4,n[a++]=128|u&63}else n[a++]=224|c>>12&15,n[a++]=128|c>>6&63,n[a++]=128|c&63;a>s&&(r.push(n.slice(0,a)),a=0,n=Gc(65535),s=65530)}return r.push(n.slice(0,a)),qn(r)}var Bi=/\u0000/g,sf=/[\u0001-\u0006]/g;function W0(e){for(var r="",a=e.length-1;a>=0;)r+=e.charAt(a--);return r}function ll(e,r){var a=""+e;return a.length>=r?a:Xs("0",r-a.length)+a}function py(e,r){var a=""+e;return a.length>=r?a:Xs(" ",r-a.length)+a}function qm(e,r){var a=""+e;return a.length>=r?a:a+Xs(" ",r-a.length)}function LT(e,r){var a=""+Math.round(e);return a.length>=r?a:Xs("0",r-a.length)+a}function BT(e,r){var a=""+e;return a.length>=r?a:Xs("0",r-a.length)+a}var h_=Math.pow(2,32);function E0(e,r){if(e>h_||e<-h_)return LT(e,r);var a=Math.round(e);return BT(a,r)}function Xm(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 m_=[["Sun","Sunday"],["Mon","Monday"],["Tue","Tuesday"],["Wed","Wednesday"],["Thu","Thursday"],["Fri","Friday"],["Sat","Saturday"]],Up=[["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 UT(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 aa={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"秒 "'},g_={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},zT={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 Zm(e,r,a){for(var s=e<0?-1:1,n=e*s,i=0,c=1,u=0,h=1,g=0,y=0,w=Math.floor(n);g<r&&(w=Math.floor(n),u=w*c+i,y=w*g+h,!(n-w<5e-8));)n=1/(n-w),i=c,c=u,h=g,g=y;if(y>r&&(g>r?(y=h,u=i):(y=g,u=c)),!a)return[0,s*u,y];var E=Math.floor(s*u/y);return[E,s*u-E*y,y]}function wd(e,r,a){if(e>2958465||e<0)return null;var s=e|0,n=Math.floor(86400*(e-s)),i=0,c=[],u={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(u.u)<1e-6&&(u.u=0),r&&r.date1904&&(s+=1462),u.u>.9999&&(u.u=0,++n==86400&&(u.T=n=0,++s,++u.D)),s===60)c=a?[1317,10,29]:[1900,2,29],i=3;else if(s===0)c=a?[1317,8,29]:[1900,1,0],i=6;else{s>60&&--s;var h=new Date(1900,0,1);h.setDate(h.getDate()+s-1),c=[h.getFullYear(),h.getMonth()+1,h.getDate()],i=h.getDay(),s<60&&(i=(i+6)%7),a&&(i=YT(h,c))}return u.y=c[0],u.m=c[1],u.d=c[2],u.S=n%60,n=Math.floor(n/60),u.M=n%60,n=Math.floor(n/60),u.H=n,u.q=i,u}var l3=new Date(1899,11,31,0,0,0),WT=l3.getTime(),HT=new Date(1900,2,1,0,0,0);function c3(e,r){var a=e.getTime();return r?a-=1461*24*60*60*1e3:e>=HT&&(a+=1440*60*1e3),(a-(WT+(e.getTimezoneOffset()-l3.getTimezoneOffset())*6e4))/(1440*60*1e3)}function yy(e){return e.indexOf(".")==-1?e:e.replace(/(?:\.0*|(\.\d*[1-9])0+)$/,"$1")}function $T(e){return e.indexOf("E")==-1?e:e.replace(/(?:\.0*|(\.\d*[1-9])0+)[Ee]/,"$1E").replace(/(E[+-])(\d)$/,"$10$2")}function VT(e){var r=e<0?12:11,a=yy(e.toFixed(12));return a.length<=r||(a=e.toPrecision(10),a.length<=r)?a:e.toExponential(5)}function GT(e){var r=yy(e.toFixed(11));return r.length>(e<0?12:11)||r==="0"||r==="-0"?e.toPrecision(6):r}function Cf(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=VT(e):r===10?a=e.toFixed(10).substr(0,12):a=GT(e),yy($T(a.toUpperCase()))}function Pd(e,r){switch(typeof e){case"string":return e;case"boolean":return e?"TRUE":"FALSE";case"number":return(e|0)===e?e.toString(10):Cf(e);case"undefined":return"";case"object":if(e==null)return"";if(e instanceof Date)return Yo(14,c3(e,r&&r.date1904),r)}throw new Error("unsupported value in General format: "+e)}function YT(e,r){r[0]-=581;var a=e.getDay();return e<60&&(a=(a+6)%7),a}function qT(e,r,a,s){var n="",i=0,c=0,u=a.y,h,g=0;switch(e){case 98:u=a.y+543;case 121:switch(r.length){case 1:case 2:h=u%100,g=2;break;default:h=u%1e4,g=4;break}break;case 109:switch(r.length){case 1:case 2:h=a.m,g=r.length;break;case 3:return Up[a.m-1][1];case 5:return Up[a.m-1][0];default:return Up[a.m-1][2]}break;case 100:switch(r.length){case 1:case 2:h=a.d,g=r.length;break;case 3:return m_[a.q][0];default:return m_[a.q][1]}break;case 104:switch(r.length){case 1:case 2:h=1+(a.H+11)%12,g=r.length;break;default:throw"bad hour format: "+r}break;case 72:switch(r.length){case 1:case 2:h=a.H,g=r.length;break;default:throw"bad hour format: "+r}break;case 77:switch(r.length){case 1:case 2:h=a.M,g=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")?ll(a.S,r.length):(s>=2?c=s===3?1e3:100:c=s===1?10:1,i=Math.round(c*(a.S+a.u)),i>=60*c&&(i=0),r==="s"?i===0?"0":""+i/c:(n=ll(i,2+s),r==="ss"?n.substr(0,2):"."+n.substr(2,r.length-1)));case 90:switch(r){case"[h]":case"[hh]":h=a.D*24+a.H;break;case"[m]":case"[mm]":h=(a.D*24+a.H)*60+a.M;break;case"[s]":case"[ss]":h=((a.D*24+a.H)*60+a.M)*60+Math.round(a.S+a.u);break;default:throw"bad abstime format: "+r}g=r.length===3?1:2;break;case 101:h=u,g=1;break}var y=g>0?ll(h,g):"";return y}function Vc(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 d3=/%/g;function XT(e,r,a){var s=r.replace(d3,""),n=r.length-s.length;return oc(e,s,a*Math.pow(10,2*n))+Xs("%",n)}function ZT(e,r,a){for(var s=r.length-1;r.charCodeAt(s-1)===44;)--s;return oc(e,r.substr(0,s),a/Math.pow(10,3*(r.length-s)))}function u3(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"-"+u3(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 c=Math.floor(Math.log(r)*Math.LOG10E);for(a.indexOf(".")===-1?a=a.charAt(0)+"."+a.substr(1)+"E+"+(c-a.length+i):a+="E+"+(c-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(u,h,g,y){return h+g+y.substr(0,(n+i)%n)+"."+y.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 f3=/# (\?+)( ?)\/( ?)(\d+)/;function KT(e,r,a){var s=parseInt(e[4],10),n=Math.round(r*s),i=Math.floor(n/s),c=n-i*s,u=s;return a+(i===0?"":""+i)+" "+(c===0?Xs(" ",e[1].length+1+e[4].length):py(c,e[1].length)+e[2]+"/"+e[3]+ll(u,e[4].length))}function JT(e,r,a){return a+(r===0?"":""+r)+Xs(" ",e[1].length+2+e[4].length)}var h3=/^#*0*\.([0#]+)/,m3=/\).*[0#]/,g3=/\(###\) ###\\?-####/;function Mi(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 x_(e,r){var a=Math.pow(10,r);return""+Math.round(e*a)/a}function p_(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 QT(e,r){return r<(""+Math.round((e-Math.floor(e))*Math.pow(10,r))).length?1:0}function eA(e){return e<2147483647&&e>-2147483648?""+(e>=0?e|0:e-1|0):""+Math.floor(e)}function Po(e,r,a){if(e.charCodeAt(0)===40&&!r.match(m3)){var s=r.replace(/\( */,"").replace(/ \)/,"").replace(/\)/,"");return a>=0?Po("n",s,a):"("+Po("n",s,-a)+")"}if(r.charCodeAt(r.length-1)===44)return ZT(e,r,a);if(r.indexOf("%")!==-1)return XT(e,r,a);if(r.indexOf("E")!==-1)return u3(r,a);if(r.charCodeAt(0)===36)return"$"+Po(e,r.substr(r.charAt(1)==" "?2:1),a);var n,i,c,u,h=Math.abs(a),g=a<0?"-":"";if(r.match(/^00+$/))return g+E0(h,r.length);if(r.match(/^[#?]+$/))return n=E0(a,0),n==="0"&&(n=""),n.length>r.length?n:Mi(r.substr(0,r.length-n.length))+n;if(i=r.match(f3))return KT(i,h,g);if(r.match(/^#+0+$/))return g+E0(h,r.length-r.indexOf("0"));if(i=r.match(h3))return n=x_(a,i[1].length).replace(/^([^\.]+)$/,"$1."+Mi(i[1])).replace(/\.$/,"."+Mi(i[1])).replace(/\.(\d*)$/,function(A,C){return"."+C+Xs("0",Mi(i[1]).length-C.length)}),r.indexOf("0.")!==-1?n:n.replace(/^0\./,".");if(r=r.replace(/^#+([0.])/,"$1"),i=r.match(/^(0*)\.(#*)$/))return g+x_(h,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 g+Vc(E0(h,0));if(i=r.match(/^#,##0\.([#0]*0)$/))return a<0?"-"+Po(e,r,-a):Vc(""+(Math.floor(a)+QT(a,i[1].length)))+"."+ll(p_(a,i[1].length),i[1].length);if(i=r.match(/^#,#*,#0/))return Po(e,r.replace(/^#,#*,/,""),a);if(i=r.match(/^([0#]+)(\\?-([0#]+))+$/))return n=W0(Po(e,r.replace(/[\\-]/g,""),a)),c=0,W0(W0(r.replace(/\\/g,"")).replace(/[0#]/g,function(A){return c<n.length?n.charAt(c++):A==="0"?"0":""}));if(r.match(g3))return n=Po(e,"##########",a),"("+n.substr(0,3)+") "+n.substr(3,3)+"-"+n.substr(6);var y="";if(i=r.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/))return c=Math.min(i[4].length,7),u=Zm(h,Math.pow(10,c)-1,!1),n=""+g,y=oc("n",i[1],u[1]),y.charAt(y.length-1)==" "&&(y=y.substr(0,y.length-1)+"0"),n+=y+i[2]+"/"+i[3],y=qm(u[2],c),y.length<i[4].length&&(y=Mi(i[4].substr(i[4].length-y.length))+y),n+=y,n;if(i=r.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/))return c=Math.min(Math.max(i[1].length,i[4].length),7),u=Zm(h,Math.pow(10,c)-1,!0),g+(u[0]||(u[1]?"":"0"))+" "+(u[1]?py(u[1],c)+i[2]+"/"+i[3]+qm(u[2],c):Xs(" ",2*c+1+i[2].length+i[3].length));if(i=r.match(/^[#0?]+$/))return n=E0(a,0),r.length<=n.length?n:Mi(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"),c=n.indexOf(".");var w=r.indexOf(".")-c,E=r.length-n.length-w;return Mi(r.substr(0,w)+n+r.substr(r.length-E))}if(i=r.match(/^00,000\.([#0]*0)$/))return c=p_(a,i[1].length),a<0?"-"+Po(e,r,-a):Vc(eA(a)).replace(/^\d,\d{3}$/,"0$&").replace(/^\d*$/,function(A){return"00,"+(A.length<3?ll(0,3-A.length):"")+A})+"."+ll(c,i[1].length);switch(r){case"###,##0.00":return Po(e,"#,##0.00",a);case"###,###":case"##,###":case"#,###":var S=Vc(E0(h,0));return S!=="0"?g+S:"";case"###,###.00":return Po(e,"###,##0.00",a).replace(/^0\./,".");case"#,###.00":return Po(e,"#,##0.00",a).replace(/^0\./,".")}throw new Error("unsupported format |"+r+"|")}function tA(e,r,a){for(var s=r.length-1;r.charCodeAt(s-1)===44;)--s;return oc(e,r.substr(0,s),a/Math.pow(10,3*(r.length-s)))}function rA(e,r,a){var s=r.replace(d3,""),n=r.length-s.length;return oc(e,s,a*Math.pow(10,2*n))+Xs("%",n)}function x3(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"-"+x3(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 c=Math.floor(Math.log(r)*Math.LOG10E);a.indexOf(".")===-1?a=a.charAt(0)+"."+a.substr(1)+"E+"+(c-a.length+i):a+="E+"+(c-i),a=a.replace(/\+-/,"-")}a=a.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/,function(u,h,g,y){return h+g+y.substr(0,(n+i)%n)+"."+y.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 Al(e,r,a){if(e.charCodeAt(0)===40&&!r.match(m3)){var s=r.replace(/\( */,"").replace(/ \)/,"").replace(/\)/,"");return a>=0?Al("n",s,a):"("+Al("n",s,-a)+")"}if(r.charCodeAt(r.length-1)===44)return tA(e,r,a);if(r.indexOf("%")!==-1)return rA(e,r,a);if(r.indexOf("E")!==-1)return x3(r,a);if(r.charCodeAt(0)===36)return"$"+Al(e,r.substr(r.charAt(1)==" "?2:1),a);var n,i,c,u,h=Math.abs(a),g=a<0?"-":"";if(r.match(/^00+$/))return g+ll(h,r.length);if(r.match(/^[#?]+$/))return n=""+a,a===0&&(n=""),n.length>r.length?n:Mi(r.substr(0,r.length-n.length))+n;if(i=r.match(f3))return JT(i,h,g);if(r.match(/^#+0+$/))return g+ll(h,r.length-r.indexOf("0"));if(i=r.match(h3))return n=(""+a).replace(/^([^\.]+)$/,"$1."+Mi(i[1])).replace(/\.$/,"."+Mi(i[1])),n=n.replace(/\.(\d*)$/,function(A,C){return"."+C+Xs("0",Mi(i[1]).length-C.length)}),r.indexOf("0.")!==-1?n:n.replace(/^0\./,".");if(r=r.replace(/^#+([0.])/,"$1"),i=r.match(/^(0*)\.(#*)$/))return g+(""+h).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^(-?\d*)$/,"$1.").replace(/^0\./,i[1].length?"0.":".");if(i=r.match(/^#{1,3},##0(\.?)$/))return g+Vc(""+h);if(i=r.match(/^#,##0\.([#0]*0)$/))return a<0?"-"+Al(e,r,-a):Vc(""+a)+"."+Xs("0",i[1].length);if(i=r.match(/^#,#*,#0/))return Al(e,r.replace(/^#,#*,/,""),a);if(i=r.match(/^([0#]+)(\\?-([0#]+))+$/))return n=W0(Al(e,r.replace(/[\\-]/g,""),a)),c=0,W0(W0(r.replace(/\\/g,"")).replace(/[0#]/g,function(A){return c<n.length?n.charAt(c++):A==="0"?"0":""}));if(r.match(g3))return n=Al(e,"##########",a),"("+n.substr(0,3)+") "+n.substr(3,3)+"-"+n.substr(6);var y="";if(i=r.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/))return c=Math.min(i[4].length,7),u=Zm(h,Math.pow(10,c)-1,!1),n=""+g,y=oc("n",i[1],u[1]),y.charAt(y.length-1)==" "&&(y=y.substr(0,y.length-1)+"0"),n+=y+i[2]+"/"+i[3],y=qm(u[2],c),y.length<i[4].length&&(y=Mi(i[4].substr(i[4].length-y.length))+y),n+=y,n;if(i=r.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/))return c=Math.min(Math.max(i[1].length,i[4].length),7),u=Zm(h,Math.pow(10,c)-1,!0),g+(u[0]||(u[1]?"":"0"))+" "+(u[1]?py(u[1],c)+i[2]+"/"+i[3]+qm(u[2],c):Xs(" ",2*c+1+i[2].length+i[3].length));if(i=r.match(/^[#0?]+$/))return n=""+a,r.length<=n.length?n:Mi(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"),c=n.indexOf(".");var w=r.indexOf(".")-c,E=r.length-n.length-w;return Mi(r.substr(0,w)+n+r.substr(r.length-E))}if(i=r.match(/^00,000\.([#0]*0)$/))return a<0?"-"+Al(e,r,-a):Vc(""+a).replace(/^\d,\d{3}$/,"0$&").replace(/^\d*$/,function(A){return"00,"+(A.length<3?ll(0,3-A.length):"")+A})+"."+ll(0,i[1].length);switch(r){case"###,###":case"##,###":case"#,###":var S=Vc(""+h);return S!=="0"?g+S:"";default:if(r.match(/\.[0#?]*$/))return Al(e,r.slice(0,r.lastIndexOf(".")),a)+Mi(r.slice(r.lastIndexOf(".")))}throw new Error("unsupported format |"+r+"|")}function oc(e,r,a){return(a|0)===a?Al(e,r,a):Po(e,r,a)}function aA(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 p3=/\[[HhMmSs\u0E0A\u0E19\u0E17]*\]/;function ru(e){for(var r=0,a="",s="";r<e.length;)switch(a=e.charAt(r)){case"G":Xm(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(p3))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 sA(e,r,a,s){for(var n=[],i="",c=0,u="",h="t",g,y,w,E="H";c<e.length;)switch(u=e.charAt(c)){case"G":if(!Xm(e,c))throw new Error("unrecognized character "+u+" in "+e);n[n.length]={t:"G",v:"General"},c+=7;break;case'"':for(i="";(w=e.charCodeAt(++c))!==34&&c<e.length;)i+=String.fromCharCode(w);n[n.length]={t:"t",v:i},++c;break;case"\\":var S=e.charAt(++c),A=S==="("||S===")"?S:"t";n[n.length]={t:A,v:S},++c;break;case"_":n[n.length]={t:"t",v:" "},c+=2;break;case"@":n[n.length]={t:"T",v:r},++c;break;case"B":case"b":if(e.charAt(c+1)==="1"||e.charAt(c+1)==="2"){if(g==null&&(g=wd(r,a,e.charAt(c+1)==="2"),g==null))return"";n[n.length]={t:"X",v:e.substr(c,2)},h=u,c+=2;break}case"M":case"D":case"Y":case"H":case"S":case"E":u=u.toLowerCase();case"m":case"d":case"y":case"h":case"s":case"e":case"g":if(r<0||g==null&&(g=wd(r,a),g==null))return"";for(i=u;++c<e.length&&e.charAt(c).toLowerCase()===u;)i+=u;u==="m"&&h.toLowerCase()==="h"&&(u="M"),u==="h"&&(u=E),n[n.length]={t:u,v:i},h=u;break;case"A":case"a":case"上":var C={t:u,v:u};if(g==null&&(g=wd(r,a)),e.substr(c,3).toUpperCase()==="A/P"?(g!=null&&(C.v=g.H>=12?"P":"A"),C.t="T",E="h",c+=3):e.substr(c,5).toUpperCase()==="AM/PM"?(g!=null&&(C.v=g.H>=12?"PM":"AM"),C.t="T",c+=5,E="h"):e.substr(c,5).toUpperCase()==="上午/下午"?(g!=null&&(C.v=g.H>=12?"下午":"上午"),C.t="T",c+=5,E="h"):(C.t="t",++c),g==null&&C.t==="T")return"";n[n.length]=C,h=u;break;case"[":for(i=u;e.charAt(c++)!=="]"&&c<e.length;)i+=e.charAt(c);if(i.slice(-1)!=="]")throw'unterminated "[" block: |'+i+"|";if(i.match(p3)){if(g==null&&(g=wd(r,a),g==null))return"";n[n.length]={t:"Z",v:i.toLowerCase()},h=i.charAt(1)}else i.indexOf("$")>-1&&(i=(i.match(/\$([^-\[\]]*)/)||[])[1]||"$",ru(e)||(n[n.length]={t:"t",v:i}));break;case".":if(g!=null){for(i=u;++c<e.length&&(u=e.charAt(c))==="0";)i+=u;n[n.length]={t:"s",v:i};break}case"0":case"#":for(i=u;++c<e.length&&"0#?.,E+-%".indexOf(u=e.charAt(c))>-1;)i+=u;n[n.length]={t:"n",v:i};break;case"?":for(i=u;e.charAt(++c)===u;)i+=u;n[n.length]={t:u,v:i},h=u;break;case"*":++c,(e.charAt(c)==" "||e.charAt(c)=="*")&&++c;break;case"(":case")":n[n.length]={t:s===1?"t":u,v:u},++c;break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(i=u;c<e.length&&"0123456789".indexOf(e.charAt(++c))>-1;)i+=e.charAt(c);n[n.length]={t:"D",v:i};break;case" ":n[n.length]={t:u,v:u},++c;break;case"$":n[n.length]={t:"t",v:"$"},++c;break;default:if(",$-+/():!^&'~{}<>=€acfijklopqrtuvwxzP".indexOf(u)===-1)throw new Error("unrecognized character "+u+" in "+e);n[n.length]={t:"t",v:u},++c;break}var O=0,M=0,R;for(c=n.length-1,h="t";c>=0;--c)switch(n[c].t){case"h":case"H":n[c].t=E,h="h",O<1&&(O=1);break;case"s":(R=n[c].v.match(/\.0+$/))&&(M=Math.max(M,R[0].length-1)),O<3&&(O=3);case"d":case"y":case"M":case"e":h=n[c].t;break;case"m":h==="s"&&(n[c].t="M",O<2&&(O=2));break;case"X":break;case"Z":O<1&&n[c].v.match(/[Hh]/)&&(O=1),O<2&&n[c].v.match(/[Mm]/)&&(O=2),O<3&&n[c].v.match(/[Ss]/)&&(O=3)}switch(O){case 0:break;case 1:g.u>=.5&&(g.u=0,++g.S),g.S>=60&&(g.S=0,++g.M),g.M>=60&&(g.M=0,++g.H);break;case 2:g.u>=.5&&(g.u=0,++g.S),g.S>=60&&(g.S=0,++g.M);break}var F="",z;for(c=0;c<n.length;++c)switch(n[c].t){case"t":case"T":case" ":case"D":break;case"X":n[c].v="",n[c].t=";";break;case"d":case"m":case"y":case"h":case"H":case"M":case"s":case"e":case"b":case"Z":n[c].v=qT(n[c].t.charCodeAt(0),n[c].v,g,M),n[c].t="t";break;case"n":case"?":for(z=c+1;n[z]!=null&&((u=n[z].t)==="?"||u==="D"||(u===" "||u==="t")&&n[z+1]!=null&&(n[z+1].t==="?"||n[z+1].t==="t"&&n[z+1].v==="/")||n[c].t==="("&&(u===" "||u==="n"||u===")")||u==="t"&&(n[z].v==="/"||n[z].v===" "&&n[z+1]!=null&&n[z+1].t=="?"));)n[c].v+=n[z].v,n[z]={v:"",t:";"},++z;F+=n[c].v,c=z-1;break;case"G":n[c].t="t",n[c].v=Pd(r,a);break}var W="",X,B;if(F.length>0){F.charCodeAt(0)==40?(X=r<0&&F.charCodeAt(0)===45?-r:r,B=oc("n",F,X)):(X=r<0&&s>1?-r:r,B=oc("n",F,X),X<0&&n[0]&&n[0].t=="t"&&(B=B.substr(1),n[0].v="-"+n[0].v)),z=B.length-1;var Y=n.length;for(c=0;c<n.length;++c)if(n[c]!=null&&n[c].t!="t"&&n[c].v.indexOf(".")>-1){Y=c;break}var G=n.length;if(Y===n.length&&B.indexOf("E")===-1){for(c=n.length-1;c>=0;--c)n[c]==null||"n?".indexOf(n[c].t)===-1||(z>=n[c].v.length-1?(z-=n[c].v.length,n[c].v=B.substr(z+1,n[c].v.length)):z<0?n[c].v="":(n[c].v=B.substr(0,z+1),z=-1),n[c].t="t",G=c);z>=0&&G<n.length&&(n[G].v=B.substr(0,z+1)+n[G].v)}else if(Y!==n.length&&B.indexOf("E")===-1){for(z=B.indexOf(".")-1,c=Y;c>=0;--c)if(!(n[c]==null||"n?".indexOf(n[c].t)===-1)){for(y=n[c].v.indexOf(".")>-1&&c===Y?n[c].v.indexOf(".")-1:n[c].v.length-1,W=n[c].v.substr(y+1);y>=0;--y)z>=0&&(n[c].v.charAt(y)==="0"||n[c].v.charAt(y)==="#")&&(W=B.charAt(z--)+W);n[c].v=W,n[c].t="t",G=c}for(z>=0&&G<n.length&&(n[G].v=B.substr(0,z+1)+n[G].v),z=B.indexOf(".")+1,c=Y;c<n.length;++c)if(!(n[c]==null||"n?(".indexOf(n[c].t)===-1&&c!==Y)){for(y=n[c].v.indexOf(".")>-1&&c===Y?n[c].v.indexOf(".")+1:0,W=n[c].v.substr(0,y);y<n[c].v.length;++y)z<B.length&&(W+=B.charAt(z++));n[c].v=W,n[c].t="t",G=c}}}for(c=0;c<n.length;++c)n[c]!=null&&"n?".indexOf(n[c].t)>-1&&(X=s>1&&r<0&&c>0&&n[c-1].v==="-"?-r:r,n[c].v=oc(n[c].t,n[c].v,X),n[c].t="t");var ie="";for(c=0;c!==n.length;++c)n[c]!=null&&(ie+=n[c].v);return ie}var y_=/\[(=|>[=]?|<[>=]?)(-?\d+(?:\.\d*)?)\]/;function b_(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 nA(e,r){var a=aA(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 c=a[0].match(y_),u=a[1].match(y_);return b_(r,c)?[s,a[0]]:b_(r,u)?[s,a[1]]:[s,a[c!=null&&u!=null?2:1]]}return[s,i]}function Yo(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:aa)[e],s==null&&(s=a.table&&a.table[g_[e]]||aa[g_[e]]),s==null&&(s=zT[e]||"General");break}if(Xm(s,0))return Pd(r,a);r instanceof Date&&(r=c3(r,a.date1904));var n=nA(s,r);if(Xm(n[1]))return Pd(r,a);if(r===!0)r="TRUE";else if(r===!1)r="FALSE";else if(r===""||r==null)return"";return sA(n[1],r,a,n[0])}function lc(e,r){if(typeof r!="number"){r=+r||-1;for(var a=0;a<392;++a){if(aa[a]==null){r<0&&(r=a);continue}if(aa[a]==e){r=a;break}}r<0&&(r=391)}return aa[r]=e,r}function yg(e){for(var r=0;r!=392;++r)e[r]!==void 0&&lc(e[r],r)}function au(){aa=UT()}var iA={5:'"$"#,##0_);\\("$"#,##0\\)',6:'"$"#,##0_);[Red]\\("$"#,##0\\)',7:'"$"#,##0.00_);\\("$"#,##0.00\\)',8:'"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',23:"General",24:"General",25:"General",26:"General",27:"m/d/yy",28:"m/d/yy",29:"m/d/yy",30:"m/d/yy",31:"m/d/yy",32:"h:mm:ss",33:"h:mm:ss",34:"h:mm:ss",35:"h:mm:ss",36:"m/d/yy",41:'_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)',42:'_("$"* #,##0_);_("$"* (#,##0);_("$"* "-"_);_(@_)',43:'_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)',44:'_("$"* #,##0.00_);_("$"* (#,##0.00);_("$"* "-"??_);_(@_)',50:"m/d/yy",51:"m/d/yy",52:"m/d/yy",53:"m/d/yy",54:"m/d/yy",55:"m/d/yy",56:"m/d/yy",57:"m/d/yy",58:"m/d/yy",59:"0",60:"0.00",61:"#,##0",62:"#,##0.00",63:'"$"#,##0_);\\("$"#,##0\\)',64:'"$"#,##0_);[Red]\\("$"#,##0\\)',65:'"$"#,##0.00_);\\("$"#,##0.00\\)',66:'"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',67:"0%",68:"0.00%",69:"# ?/?",70:"# ??/??",71:"m/d/yy",72:"m/d/yy",73:"d-mmm-yy",74:"d-mmm",75:"mmm-yy",76:"h:mm",77:"h:mm:ss",78:"m/d/yy h:mm",79:"mm:ss",80:"[h]:mm:ss",81:"mmss.0"},y3=/[dD]+|[mM]+|[yYeE]+|[Hh]+|[Ss]+/g;function oA(e){var r=typeof e=="number"?aa[e]:e;return r=r.replace(y3,"(\\d+)"),new RegExp("^"+r+"$")}function lA(e,r,a){var s=-1,n=-1,i=-1,c=-1,u=-1,h=-1;(r.match(y3)||[]).forEach(function(w,E){var S=parseInt(a[E+1],10);switch(w.toLowerCase().charAt(0)){case"y":s=S;break;case"d":i=S;break;case"h":c=S;break;case"s":h=S;break;case"m":c>=0?u=S:n=S;break}}),h>=0&&u==-1&&n>=0&&(u=n,n=-1);var g=(""+(s>=0?s:new Date().getFullYear())).slice(-4)+"-"+("00"+(n>=1?n:1)).slice(-2)+"-"+("00"+(i>=1?i:1)).slice(-2);g.length==7&&(g="0"+g),g.length==8&&(g="20"+g);var y=("00"+(c>=0?c:0)).slice(-2)+":"+("00"+(u>=0?u:0)).slice(-2)+":"+("00"+(h>=0?h:0)).slice(-2);return c==-1&&u==-1&&h==-1?g:s==-1&&n==-1&&i==-1?y:g+"T"+y}var cA=(function(){var e={};e.version="1.2.0";function r(){for(var B=0,Y=new Array(256),G=0;G!=256;++G)B=G,B=B&1?-306674912^B>>>1:B>>>1,B=B&1?-306674912^B>>>1:B>>>1,B=B&1?-306674912^B>>>1:B>>>1,B=B&1?-306674912^B>>>1:B>>>1,B=B&1?-306674912^B>>>1:B>>>1,B=B&1?-306674912^B>>>1:B>>>1,B=B&1?-306674912^B>>>1:B>>>1,B=B&1?-306674912^B>>>1:B>>>1,Y[G]=B;return typeof Int32Array!="undefined"?new Int32Array(Y):Y}var a=r();function s(B){var Y=0,G=0,ie=0,fe=typeof Int32Array!="undefined"?new Int32Array(4096):new Array(4096);for(ie=0;ie!=256;++ie)fe[ie]=B[ie];for(ie=0;ie!=256;++ie)for(G=B[ie],Y=256+ie;Y<4096;Y+=256)G=fe[Y]=G>>>8^B[G&255];var K=[];for(ie=1;ie!=16;++ie)K[ie-1]=typeof Int32Array!="undefined"?fe.subarray(ie*256,ie*256+256):fe.slice(ie*256,ie*256+256);return K}var n=s(a),i=n[0],c=n[1],u=n[2],h=n[3],g=n[4],y=n[5],w=n[6],E=n[7],S=n[8],A=n[9],C=n[10],O=n[11],M=n[12],R=n[13],F=n[14];function z(B,Y){for(var G=Y^-1,ie=0,fe=B.length;ie<fe;)G=G>>>8^a[(G^B.charCodeAt(ie++))&255];return~G}function W(B,Y){for(var G=Y^-1,ie=B.length-15,fe=0;fe<ie;)G=F[B[fe++]^G&255]^R[B[fe++]^G>>8&255]^M[B[fe++]^G>>16&255]^O[B[fe++]^G>>>24]^C[B[fe++]]^A[B[fe++]]^S[B[fe++]]^E[B[fe++]]^w[B[fe++]]^y[B[fe++]]^g[B[fe++]]^h[B[fe++]]^u[B[fe++]]^c[B[fe++]]^i[B[fe++]]^a[B[fe++]];for(ie+=15;fe<ie;)G=G>>>8^a[(G^B[fe++])&255];return~G}function X(B,Y){for(var G=Y^-1,ie=0,fe=B.length,K=0,ke=0;ie<fe;)K=B.charCodeAt(ie++),K<128?G=G>>>8^a[(G^K)&255]:K<2048?(G=G>>>8^a[(G^(192|K>>6&31))&255],G=G>>>8^a[(G^(128|K&63))&255]):K>=55296&&K<57344?(K=(K&1023)+64,ke=B.charCodeAt(ie++)&1023,G=G>>>8^a[(G^(240|K>>8&7))&255],G=G>>>8^a[(G^(128|K>>2&63))&255],G=G>>>8^a[(G^(128|ke>>6&15|(K&3)<<4))&255],G=G>>>8^a[(G^(128|ke&63))&255]):(G=G>>>8^a[(G^(224|K>>12&15))&255],G=G>>>8^a[(G^(128|K>>6&63))&255],G=G>>>8^a[(G^(128|K&63))&255]);return~G}return e.table=a,e.bstr=z,e.buf=W,e.str=X,e})(),Zr=(function(){var r={};r.version="1.2.1";function a(Q,he){for(var Se=Q.split("/"),ne=he.split("/"),_e=0,Ce=0,Qe=Math.min(Se.length,ne.length);_e<Qe;++_e){if(Ce=Se[_e].length-ne[_e].length)return Ce;if(Se[_e]!=ne[_e])return Se[_e]<ne[_e]?-1:1}return Se.length-ne.length}function s(Q){if(Q.charAt(Q.length-1)=="/")return Q.slice(0,-1).indexOf("/")===-1?Q:s(Q.slice(0,-1));var he=Q.lastIndexOf("/");return he===-1?Q:Q.slice(0,he+1)}function n(Q){if(Q.charAt(Q.length-1)=="/")return n(Q.slice(0,-1));var he=Q.lastIndexOf("/");return he===-1?Q:Q.slice(he+1)}function i(Q,he){typeof he=="string"&&(he=new Date(he));var Se=he.getHours();Se=Se<<6|he.getMinutes(),Se=Se<<5|he.getSeconds()>>>1,Q.write_shift(2,Se);var ne=he.getFullYear()-1980;ne=ne<<4|he.getMonth()+1,ne=ne<<5|he.getDate(),Q.write_shift(2,ne)}function c(Q){var he=Q.read_shift(2)&65535,Se=Q.read_shift(2)&65535,ne=new Date,_e=Se&31;Se>>>=5;var Ce=Se&15;Se>>>=4,ne.setMilliseconds(0),ne.setFullYear(Se+1980),ne.setMonth(Ce-1),ne.setDate(_e);var Qe=he&31;he>>>=5;var xt=he&63;return he>>>=6,ne.setHours(he),ne.setMinutes(xt),ne.setSeconds(Qe<<1),ne}function u(Q){fi(Q,0);for(var he={},Se=0;Q.l<=Q.length-4;){var ne=Q.read_shift(2),_e=Q.read_shift(2),Ce=Q.l+_e,Qe={};switch(ne){case 21589:Se=Q.read_shift(1),Se&1&&(Qe.mtime=Q.read_shift(4)),_e>5&&(Se&2&&(Qe.atime=Q.read_shift(4)),Se&4&&(Qe.ctime=Q.read_shift(4))),Qe.mtime&&(Qe.mt=new Date(Qe.mtime*1e3));break}Q.l=Ce,he[ne]=Qe}return he}var h;function g(){return h||(h={})}function y(Q,he){if(Q[0]==80&&Q[1]==75)return Nr(Q,he);if((Q[0]|32)==109&&(Q[1]|32)==105)return Fe(Q,he);if(Q.length<512)throw new Error("CFB file size "+Q.length+" < 512");var Se=3,ne=512,_e=0,Ce=0,Qe=0,xt=0,dt=0,at=[],$e=Q.slice(0,512);fi($e,0);var tt=w($e);switch(Se=tt[0],Se){case 3:ne=512;break;case 4:ne=4096;break;case 0:if(tt[1]==0)return Nr(Q,he);default:throw new Error("Major Version: Expected 3 or 4 saw "+Se)}ne!==512&&($e=Q.slice(0,ne),fi($e,28));var gt=Q.slice(0,ne);E($e,Se);var Wt=$e.read_shift(4,"i");if(Se===3&&Wt!==0)throw new Error("# Directory Sectors: Expected 0 saw "+Wt);$e.l+=4,Qe=$e.read_shift(4,"i"),$e.l+=4,$e.chk("00100000","Mini Stream Cutoff Size: "),xt=$e.read_shift(4,"i"),_e=$e.read_shift(4,"i"),dt=$e.read_shift(4,"i"),Ce=$e.read_shift(4,"i");for(var Ft=-1,Zt=0;Zt<109&&(Ft=$e.read_shift(4,"i"),!(Ft<0));++Zt)at[Zt]=Ft;var br=S(Q,ne);O(dt,Ce,br,ne,at);var Ht=R(br,Qe,at,ne);Ht[Qe].name="!Directory",_e>0&&xt!==ke&&(Ht[xt].name="!MiniFAT"),Ht[at[0]].name="!FAT",Ht.fat_addrs=at,Ht.ssz=ne;var fa={},qr=[],vr=[],da=[];F(Qe,Ht,br,qr,_e,fa,vr,xt),A(vr,da,qr),qr.shift();var zr={FileIndex:vr,FullPaths:da};return he&&he.raw&&(zr.raw={header:gt,sectors:br}),zr}function w(Q){if(Q[Q.l]==80&&Q[Q.l+1]==75)return[0,0];Q.chk(ge,"Header Signature: "),Q.l+=16;var he=Q.read_shift(2,"u");return[Q.read_shift(2,"u"),he]}function E(Q,he){var Se=9;switch(Q.l+=2,Se=Q.read_shift(2)){case 9:if(he!=3)throw new Error("Sector Shift: Expected 9 saw "+Se);break;case 12:if(he!=4)throw new Error("Sector Shift: Expected 12 saw "+Se);break;default:throw new Error("Sector Shift: Expected 9 or 12 saw "+Se)}Q.chk("0600","Mini Sector Shift: "),Q.chk("000000000000","Reserved: ")}function S(Q,he){for(var Se=Math.ceil(Q.length/he)-1,ne=[],_e=1;_e<Se;++_e)ne[_e-1]=Q.slice(_e*he,(_e+1)*he);return ne[Se-1]=Q.slice(Se*he),ne}function A(Q,he,Se){for(var ne=0,_e=0,Ce=0,Qe=0,xt=0,dt=Se.length,at=[],$e=[];ne<dt;++ne)at[ne]=$e[ne]=ne,he[ne]=Se[ne];for(;xt<$e.length;++xt)ne=$e[xt],_e=Q[ne].L,Ce=Q[ne].R,Qe=Q[ne].C,at[ne]===ne&&(_e!==-1&&at[_e]!==_e&&(at[ne]=at[_e]),Ce!==-1&&at[Ce]!==Ce&&(at[ne]=at[Ce])),Qe!==-1&&(at[Qe]=ne),_e!==-1&&ne!=at[ne]&&(at[_e]=at[ne],$e.lastIndexOf(_e)<xt&&$e.push(_e)),Ce!==-1&&ne!=at[ne]&&(at[Ce]=at[ne],$e.lastIndexOf(Ce)<xt&&$e.push(Ce));for(ne=1;ne<dt;++ne)at[ne]===ne&&(Ce!==-1&&at[Ce]!==Ce?at[ne]=at[Ce]:_e!==-1&&at[_e]!==_e&&(at[ne]=at[_e]));for(ne=1;ne<dt;++ne)if(Q[ne].type!==0){if(xt=ne,xt!=at[xt])do xt=at[xt],he[ne]=he[xt]+"/"+he[ne];while(xt!==0&&at[xt]!==-1&&xt!=at[xt]);at[ne]=-1}for(he[0]+="/",ne=1;ne<dt;++ne)Q[ne].type!==2&&(he[ne]+="/")}function C(Q,he,Se){for(var ne=Q.start,_e=Q.size,Ce=[],Qe=ne;Se&&_e>0&&Qe>=0;)Ce.push(he.slice(Qe*K,Qe*K+K)),_e-=K,Qe=bd(Se,Qe*4);return Ce.length===0?sr(0):qn(Ce).slice(0,Q.size)}function O(Q,he,Se,ne,_e){var Ce=ke;if(Q===ke){if(he!==0)throw new Error("DIFAT chain shorter than expected")}else if(Q!==-1){var Qe=Se[Q],xt=(ne>>>2)-1;if(!Qe)return;for(var dt=0;dt<xt&&(Ce=bd(Qe,dt*4))!==ke;++dt)_e.push(Ce);O(bd(Qe,ne-4),he-1,Se,ne,_e)}}function M(Q,he,Se,ne,_e){var Ce=[],Qe=[];_e||(_e=[]);var xt=ne-1,dt=0,at=0;for(dt=he;dt>=0;){_e[dt]=!0,Ce[Ce.length]=dt,Qe.push(Q[dt]);var $e=Se[Math.floor(dt*4/ne)];if(at=dt*4&xt,ne<4+at)throw new Error("FAT boundary crossed: "+dt+" 4 "+ne);if(!Q[$e])break;dt=bd(Q[$e],at)}return{nodes:Ce,data:O_([Qe])}}function R(Q,he,Se,ne){var _e=Q.length,Ce=[],Qe=[],xt=[],dt=[],at=ne-1,$e=0,tt=0,gt=0,Wt=0;for($e=0;$e<_e;++$e)if(xt=[],gt=$e+he,gt>=_e&&(gt-=_e),!Qe[gt]){dt=[];var Ft=[];for(tt=gt;tt>=0;){Ft[tt]=!0,Qe[tt]=!0,xt[xt.length]=tt,dt.push(Q[tt]);var Zt=Se[Math.floor(tt*4/ne)];if(Wt=tt*4&at,ne<4+Wt)throw new Error("FAT boundary crossed: "+tt+" 4 "+ne);if(!Q[Zt]||(tt=bd(Q[Zt],Wt),Ft[tt]))break}Ce[gt]={nodes:xt,data:O_([dt])}}return Ce}function F(Q,he,Se,ne,_e,Ce,Qe,xt){for(var dt=0,at=ne.length?2:0,$e=he[Q].data,tt=0,gt=0,Wt;tt<$e.length;tt+=128){var Ft=$e.slice(tt,tt+128);fi(Ft,64),gt=Ft.read_shift(2),Wt=jy(Ft,0,gt-at),ne.push(Wt);var Zt={name:Wt,type:Ft.read_shift(1),color:Ft.read_shift(1),L:Ft.read_shift(4,"i"),R:Ft.read_shift(4,"i"),C:Ft.read_shift(4,"i"),clsid:Ft.read_shift(16),state:Ft.read_shift(4,"i"),start:0,size:0},br=Ft.read_shift(2)+Ft.read_shift(2)+Ft.read_shift(2)+Ft.read_shift(2);br!==0&&(Zt.ct=z(Ft,Ft.l-8));var Ht=Ft.read_shift(2)+Ft.read_shift(2)+Ft.read_shift(2)+Ft.read_shift(2);Ht!==0&&(Zt.mt=z(Ft,Ft.l-8)),Zt.start=Ft.read_shift(4,"i"),Zt.size=Ft.read_shift(4,"i"),Zt.size<0&&Zt.start<0&&(Zt.size=Zt.type=0,Zt.start=ke,Zt.name=""),Zt.type===5?(dt=Zt.start,_e>0&&dt!==ke&&(he[dt].name="!StreamData")):Zt.size>=4096?(Zt.storage="fat",he[Zt.start]===void 0&&(he[Zt.start]=M(Se,Zt.start,he.fat_addrs,he.ssz)),he[Zt.start].name=Zt.name,Zt.content=he[Zt.start].data.slice(0,Zt.size)):(Zt.storage="minifat",Zt.size<0?Zt.size=0:dt!==ke&&Zt.start!==ke&&he[dt]&&(Zt.content=C(Zt,he[dt].data,(he[xt]||{}).data))),Zt.content&&fi(Zt.content,0),Ce[Wt]=Zt,Qe.push(Zt)}}function z(Q,he){return new Date((bo(Q,he+4)/1e7*Math.pow(2,32)+bo(Q,he)/1e7-11644473600)*1e3)}function W(Q,he){return g(),y(h.readFileSync(Q),he)}function X(Q,he){var Se=he&&he.type;switch(Se||Ca&&Buffer.isBuffer(Q)&&(Se="buffer"),Se||"base64"){case"file":return W(Q,he);case"base64":return y(vo(ko(Q)),he);case"binary":return y(vo(Q),he)}return y(Q,he)}function B(Q,he){var Se=he||{},ne=Se.root||"Root Entry";if(Q.FullPaths||(Q.FullPaths=[]),Q.FileIndex||(Q.FileIndex=[]),Q.FullPaths.length!==Q.FileIndex.length)throw new Error("inconsistent CFB structure");Q.FullPaths.length===0&&(Q.FullPaths[0]=ne+"/",Q.FileIndex[0]={name:ne,type:5}),Se.CLSID&&(Q.FileIndex[0].clsid=Se.CLSID),Y(Q)}function Y(Q){var he="Sh33tJ5";if(!Zr.find(Q,"/"+he)){var Se=sr(4);Se[0]=55,Se[1]=Se[3]=50,Se[2]=54,Q.FileIndex.push({name:he,type:2,content:Se,size:4,L:69,R:69,C:69}),Q.FullPaths.push(Q.FullPaths[0]+he),G(Q)}}function G(Q,he){B(Q);for(var Se=!1,ne=!1,_e=Q.FullPaths.length-1;_e>=0;--_e){var Ce=Q.FileIndex[_e];switch(Ce.type){case 0:ne?Se=!0:(Q.FileIndex.pop(),Q.FullPaths.pop());break;case 1:case 2:case 5:ne=!0,isNaN(Ce.R*Ce.L*Ce.C)&&(Se=!0),Ce.R>-1&&Ce.L>-1&&Ce.R==Ce.L&&(Se=!0);break;default:Se=!0;break}}if(!(!Se&&!he)){var Qe=new Date(1987,1,19),xt=0,dt=Object.create?Object.create(null):{},at=[];for(_e=0;_e<Q.FullPaths.length;++_e)dt[Q.FullPaths[_e]]=!0,Q.FileIndex[_e].type!==0&&at.push([Q.FullPaths[_e],Q.FileIndex[_e]]);for(_e=0;_e<at.length;++_e){var $e=s(at[_e][0]);ne=dt[$e],ne||(at.push([$e,{name:n($e).replace("/",""),type:1,clsid:we,ct:Qe,mt:Qe,content:null}]),dt[$e]=!0)}for(at.sort(function(Wt,Ft){return a(Wt[0],Ft[0])}),Q.FullPaths=[],Q.FileIndex=[],_e=0;_e<at.length;++_e)Q.FullPaths[_e]=at[_e][0],Q.FileIndex[_e]=at[_e][1];for(_e=0;_e<at.length;++_e){var tt=Q.FileIndex[_e],gt=Q.FullPaths[_e];if(tt.name=n(gt).replace("/",""),tt.L=tt.R=tt.C=-(tt.color=1),tt.size=tt.content?tt.content.length:0,tt.start=0,tt.clsid=tt.clsid||we,_e===0)tt.C=at.length>1?1:-1,tt.size=0,tt.type=5;else if(gt.slice(-1)=="/"){for(xt=_e+1;xt<at.length&&s(Q.FullPaths[xt])!=gt;++xt);for(tt.C=xt>=at.length?-1:xt,xt=_e+1;xt<at.length&&s(Q.FullPaths[xt])!=s(gt);++xt);tt.R=xt>=at.length?-1:xt,tt.type=1}else s(Q.FullPaths[_e+1]||"")==s(gt)&&(tt.R=_e+1),tt.type=2}}}function ie(Q,he){var Se=he||{};if(Se.fileType=="mad")return Ze(Q,Se);switch(G(Q),Se.fileType){case"zip":return _r(Q,Se)}var ne=(function(Wt){for(var Ft=0,Zt=0,br=0;br<Wt.FileIndex.length;++br){var Ht=Wt.FileIndex[br];if(Ht.content){var fa=Ht.content.length;fa>0&&(fa<4096?Ft+=fa+63>>6:Zt+=fa+511>>9)}}for(var qr=Wt.FullPaths.length+3>>2,vr=Ft+7>>3,da=Ft+127>>7,zr=vr+Zt+qr+da,Kr=zr+127>>7,Yr=Kr<=109?0:Math.ceil((Kr-109)/127);zr+Kr+Yr+127>>7>Kr;)Yr=++Kr<=109?0:Math.ceil((Kr-109)/127);var Gr=[1,Yr,Kr,da,qr,Zt,Ft,0];return Wt.FileIndex[0].size=Ft<<6,Gr[7]=(Wt.FileIndex[0].start=Gr[0]+Gr[1]+Gr[2]+Gr[3]+Gr[4]+Gr[5])+(Gr[6]+7>>3),Gr})(Q),_e=sr(ne[7]<<9),Ce=0,Qe=0;{for(Ce=0;Ce<8;++Ce)_e.write_shift(1,re[Ce]);for(Ce=0;Ce<8;++Ce)_e.write_shift(2,0);for(_e.write_shift(2,62),_e.write_shift(2,3),_e.write_shift(2,65534),_e.write_shift(2,9),_e.write_shift(2,6),Ce=0;Ce<3;++Ce)_e.write_shift(2,0);for(_e.write_shift(4,0),_e.write_shift(4,ne[2]),_e.write_shift(4,ne[0]+ne[1]+ne[2]+ne[3]-1),_e.write_shift(4,0),_e.write_shift(4,4096),_e.write_shift(4,ne[3]?ne[0]+ne[1]+ne[2]-1:ke),_e.write_shift(4,ne[3]),_e.write_shift(-4,ne[1]?ne[0]-1:ke),_e.write_shift(4,ne[1]),Ce=0;Ce<109;++Ce)_e.write_shift(-4,Ce<ne[2]?ne[1]+Ce:-1)}if(ne[1])for(Qe=0;Qe<ne[1];++Qe){for(;Ce<236+Qe*127;++Ce)_e.write_shift(-4,Ce<ne[2]?ne[1]+Ce:-1);_e.write_shift(-4,Qe===ne[1]-1?ke:Qe+1)}var xt=function(Wt){for(Qe+=Wt;Ce<Qe-1;++Ce)_e.write_shift(-4,Ce+1);Wt&&(++Ce,_e.write_shift(-4,ke))};for(Qe=Ce=0,Qe+=ne[1];Ce<Qe;++Ce)_e.write_shift(-4,ee.DIFSECT);for(Qe+=ne[2];Ce<Qe;++Ce)_e.write_shift(-4,ee.FATSECT);xt(ne[3]),xt(ne[4]);for(var dt=0,at=0,$e=Q.FileIndex[0];dt<Q.FileIndex.length;++dt)$e=Q.FileIndex[dt],$e.content&&(at=$e.content.length,!(at<4096)&&($e.start=Qe,xt(at+511>>9)));for(xt(ne[6]+7>>3);_e.l&511;)_e.write_shift(-4,ee.ENDOFCHAIN);for(Qe=Ce=0,dt=0;dt<Q.FileIndex.length;++dt)$e=Q.FileIndex[dt],$e.content&&(at=$e.content.length,!(!at||at>=4096)&&($e.start=Qe,xt(at+63>>6)));for(;_e.l&511;)_e.write_shift(-4,ee.ENDOFCHAIN);for(Ce=0;Ce<ne[4]<<2;++Ce){var tt=Q.FullPaths[Ce];if(!tt||tt.length===0){for(dt=0;dt<17;++dt)_e.write_shift(4,0);for(dt=0;dt<3;++dt)_e.write_shift(4,-1);for(dt=0;dt<12;++dt)_e.write_shift(4,0);continue}$e=Q.FileIndex[Ce],Ce===0&&($e.start=$e.size?$e.start-1:ke);var gt=Ce===0&&Se.root||$e.name;if(at=2*(gt.length+1),_e.write_shift(64,gt,"utf16le"),_e.write_shift(2,at),_e.write_shift(1,$e.type),_e.write_shift(1,$e.color),_e.write_shift(-4,$e.L),_e.write_shift(-4,$e.R),_e.write_shift(-4,$e.C),$e.clsid)_e.write_shift(16,$e.clsid,"hex");else for(dt=0;dt<4;++dt)_e.write_shift(4,0);_e.write_shift(4,$e.state||0),_e.write_shift(4,0),_e.write_shift(4,0),_e.write_shift(4,0),_e.write_shift(4,0),_e.write_shift(4,$e.start),_e.write_shift(4,$e.size),_e.write_shift(4,0)}for(Ce=1;Ce<Q.FileIndex.length;++Ce)if($e=Q.FileIndex[Ce],$e.size>=4096)if(_e.l=$e.start+1<<9,Ca&&Buffer.isBuffer($e.content))$e.content.copy(_e,_e.l,0,$e.size),_e.l+=$e.size+511&-512;else{for(dt=0;dt<$e.size;++dt)_e.write_shift(1,$e.content[dt]);for(;dt&511;++dt)_e.write_shift(1,0)}for(Ce=1;Ce<Q.FileIndex.length;++Ce)if($e=Q.FileIndex[Ce],$e.size>0&&$e.size<4096)if(Ca&&Buffer.isBuffer($e.content))$e.content.copy(_e,_e.l,0,$e.size),_e.l+=$e.size+63&-64;else{for(dt=0;dt<$e.size;++dt)_e.write_shift(1,$e.content[dt]);for(;dt&63;++dt)_e.write_shift(1,0)}if(Ca)_e.l=_e.length;else for(;_e.l<_e.length;)_e.write_shift(1,0);return _e}function fe(Q,he){var Se=Q.FullPaths.map(function(dt){return dt.toUpperCase()}),ne=Se.map(function(dt){var at=dt.split("/");return at[at.length-(dt.slice(-1)=="/"?2:1)]}),_e=!1;he.charCodeAt(0)===47?(_e=!0,he=Se[0].slice(0,-1)+he):_e=he.indexOf("/")!==-1;var Ce=he.toUpperCase(),Qe=_e===!0?Se.indexOf(Ce):ne.indexOf(Ce);if(Qe!==-1)return Q.FileIndex[Qe];var xt=!Ce.match(sf);for(Ce=Ce.replace(Bi,""),xt&&(Ce=Ce.replace(sf,"!")),Qe=0;Qe<Se.length;++Qe)if((xt?Se[Qe].replace(sf,"!"):Se[Qe]).replace(Bi,"")==Ce||(xt?ne[Qe].replace(sf,"!"):ne[Qe]).replace(Bi,"")==Ce)return Q.FileIndex[Qe];return null}var K=64,ke=-2,ge="d0cf11e0a1b11ae1",re=[208,207,17,224,161,177,26,225],we="00000000000000000000000000000000",ee={MAXREGSECT:-6,DIFSECT:-4,FATSECT:-3,ENDOFCHAIN:ke,FREESECT:-1,HEADER_SIGNATURE:ge,HEADER_MINOR_VERSION:"3e00",MAXREGSID:-6,NOSTREAM:-1,HEADER_CLSID:we,EntryTypes:["unknown","storage","stream","lockbytes","property","root"]};function ve(Q,he,Se){g();var ne=ie(Q,Se);h.writeFileSync(he,ne)}function ce(Q){for(var he=new Array(Q.length),Se=0;Se<Q.length;++Se)he[Se]=String.fromCharCode(Q[Se]);return he.join("")}function ye(Q,he){var Se=ie(Q,he);switch(he&&he.type||"buffer"){case"file":return g(),h.writeFileSync(he.filename,Se),Se;case"binary":return typeof Se=="string"?Se:ce(Se);case"base64":return Sf(typeof Se=="string"?Se:ce(Se));case"buffer":if(Ca)return Buffer.isBuffer(Se)?Se:hc(Se);case"array":return typeof Se=="string"?vo(Se):Se}return Se}var te;function q(Q){try{var he=Q.InflateRaw,Se=new he;if(Se._processChunk(new Uint8Array([3,0]),Se._finishFlushFlag),Se.bytesRead)te=Q;else throw new Error("zlib does not expose bytesRead")}catch(ne){console.error("cannot use native zlib: "+(ne.message||ne))}}function J(Q,he){if(!te)return lr(Q,he);var Se=te.InflateRaw,ne=new Se,_e=ne._processChunk(Q.slice(Q.l),ne._finishFlushFlag);return Q.l+=ne.bytesRead,_e}function ae(Q){return te?te.deflateRawSync(Q):Ye(Q)}var oe=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],le=[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],be=[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 Z(Q){var he=(Q<<1|Q<<11)&139536|(Q<<5|Q<<15)&558144;return(he>>16|he>>8|he)&255}for(var Le=typeof Uint8Array!="undefined",Pe=Le?new Uint8Array(256):[],Be=0;Be<256;++Be)Pe[Be]=Z(Be);function pe(Q,he){var Se=Pe[Q&255];return he<=8?Se>>>8-he:(Se=Se<<8|Pe[Q>>8&255],he<=16?Se>>>16-he:(Se=Se<<8|Pe[Q>>16&255],Se>>>24-he))}function rt(Q,he){var Se=he&7,ne=he>>>3;return(Q[ne]|(Se<=6?0:Q[ne+1]<<8))>>>Se&3}function ct(Q,he){var Se=he&7,ne=he>>>3;return(Q[ne]|(Se<=5?0:Q[ne+1]<<8))>>>Se&7}function et(Q,he){var Se=he&7,ne=he>>>3;return(Q[ne]|(Se<=4?0:Q[ne+1]<<8))>>>Se&15}function It(Q,he){var Se=he&7,ne=he>>>3;return(Q[ne]|(Se<=3?0:Q[ne+1]<<8))>>>Se&31}function ft(Q,he){var Se=he&7,ne=he>>>3;return(Q[ne]|(Se<=1?0:Q[ne+1]<<8))>>>Se&127}function Lt(Q,he,Se){var ne=he&7,_e=he>>>3,Ce=(1<<Se)-1,Qe=Q[_e]>>>ne;return Se<8-ne||(Qe|=Q[_e+1]<<8-ne,Se<16-ne)||(Qe|=Q[_e+2]<<16-ne,Se<24-ne)||(Qe|=Q[_e+3]<<24-ne),Qe&Ce}function Je(Q,he,Se){var ne=he&7,_e=he>>>3;return ne<=5?Q[_e]|=(Se&7)<<ne:(Q[_e]|=Se<<ne&255,Q[_e+1]=(Se&7)>>8-ne),he+3}function Ve(Q,he,Se){var ne=he&7,_e=he>>>3;return Se=(Se&1)<<ne,Q[_e]|=Se,he+1}function Xe(Q,he,Se){var ne=he&7,_e=he>>>3;return Se<<=ne,Q[_e]|=Se&255,Se>>>=8,Q[_e+1]=Se,he+8}function Rt(Q,he,Se){var ne=he&7,_e=he>>>3;return Se<<=ne,Q[_e]|=Se&255,Se>>>=8,Q[_e+1]=Se&255,Q[_e+2]=Se>>>8,he+16}function qe(Q,he){var Se=Q.length,ne=2*Se>he?2*Se:he+5,_e=0;if(Se>=he)return Q;if(Ca){var Ce=f_(ne);if(Q.copy)Q.copy(Ce);else for(;_e<Q.length;++_e)Ce[_e]=Q[_e];return Ce}else if(Le){var Qe=new Uint8Array(ne);if(Qe.set)Qe.set(Q);else for(;_e<Se;++_e)Qe[_e]=Q[_e];return Qe}return Q.length=ne,Q}function Dt(Q){for(var he=new Array(Q),Se=0;Se<Q;++Se)he[Se]=0;return he}function ar(Q,he,Se){var ne=1,_e=0,Ce=0,Qe=0,xt=0,dt=Q.length,at=Le?new Uint16Array(32):Dt(32);for(Ce=0;Ce<32;++Ce)at[Ce]=0;for(Ce=dt;Ce<Se;++Ce)Q[Ce]=0;dt=Q.length;var $e=Le?new Uint16Array(dt):Dt(dt);for(Ce=0;Ce<dt;++Ce)at[_e=Q[Ce]]++,ne<_e&&(ne=_e),$e[Ce]=0;for(at[0]=0,Ce=1;Ce<=ne;++Ce)at[Ce+16]=xt=xt+at[Ce-1]<<1;for(Ce=0;Ce<dt;++Ce)xt=Q[Ce],xt!=0&&($e[Ce]=at[xt+16]++);var tt=0;for(Ce=0;Ce<dt;++Ce)if(tt=Q[Ce],tt!=0)for(xt=pe($e[Ce],ne)>>ne-tt,Qe=(1<<ne+4-tt)-1;Qe>=0;--Qe)he[xt|Qe<<tt]=tt&15|Ce<<4;return ne}var yt=Le?new Uint16Array(512):Dt(512),St=Le?new Uint16Array(32):Dt(32);if(!Le){for(var Ot=0;Ot<512;++Ot)yt[Ot]=0;for(Ot=0;Ot<32;++Ot)St[Ot]=0}(function(){for(var Q=[],he=0;he<32;he++)Q.push(5);ar(Q,St,32);var Se=[];for(he=0;he<=143;he++)Se.push(8);for(;he<=255;he++)Se.push(9);for(;he<=279;he++)Se.push(7);for(;he<=287;he++)Se.push(8);ar(Se,yt,288)})();var Yt=(function(){for(var he=Le?new Uint8Array(32768):[],Se=0,ne=0;Se<be.length-1;++Se)for(;ne<be[Se+1];++ne)he[ne]=Se;for(;ne<32768;++ne)he[ne]=29;var _e=Le?new Uint8Array(259):[];for(Se=0,ne=0;Se<le.length-1;++Se)for(;ne<le[Se+1];++ne)_e[ne]=Se;function Ce(xt,dt){for(var at=0;at<xt.length;){var $e=Math.min(65535,xt.length-at),tt=at+$e==xt.length;for(dt.write_shift(1,+tt),dt.write_shift(2,$e),dt.write_shift(2,~$e&65535);$e-- >0;)dt[dt.l++]=xt[at++]}return dt.l}function Qe(xt,dt){for(var at=0,$e=0,tt=Le?new Uint16Array(32768):[];$e<xt.length;){var gt=Math.min(65535,xt.length-$e);if(gt<10){for(at=Je(dt,at,+($e+gt==xt.length)),at&7&&(at+=8-(at&7)),dt.l=at/8|0,dt.write_shift(2,gt),dt.write_shift(2,~gt&65535);gt-- >0;)dt[dt.l++]=xt[$e++];at=dt.l*8;continue}at=Je(dt,at,+($e+gt==xt.length)+2);for(var Wt=0;gt-- >0;){var Ft=xt[$e];Wt=(Wt<<5^Ft)&32767;var Zt=-1,br=0;if((Zt=tt[Wt])&&(Zt|=$e&-32768,Zt>$e&&(Zt-=32768),Zt<$e))for(;xt[Zt+br]==xt[$e+br]&&br<250;)++br;if(br>2){Ft=_e[br],Ft<=22?at=Xe(dt,at,Pe[Ft+1]>>1)-1:(Xe(dt,at,3),at+=5,Xe(dt,at,Pe[Ft-23]>>5),at+=3);var Ht=Ft<8?0:Ft-4>>2;Ht>0&&(Rt(dt,at,br-le[Ft]),at+=Ht),Ft=he[$e-Zt],at=Xe(dt,at,Pe[Ft]>>3),at-=3;var fa=Ft<4?0:Ft-2>>1;fa>0&&(Rt(dt,at,$e-Zt-be[Ft]),at+=fa);for(var qr=0;qr<br;++qr)tt[Wt]=$e&32767,Wt=(Wt<<5^xt[$e])&32767,++$e;gt-=br-1}else Ft<=143?Ft=Ft+48:at=Ve(dt,at,1),at=Xe(dt,at,Pe[Ft]),tt[Wt]=$e&32767,++$e}at=Xe(dt,at,0)-1}return dt.l=(at+7)/8|0,dt.l}return function(dt,at){return dt.length<8?Ce(dt,at):Qe(dt,at)}})();function Ye(Q){var he=sr(50+Math.floor(Q.length*1.1)),Se=Yt(Q,he);return he.slice(0,Se)}var wt=Le?new Uint16Array(32768):Dt(32768),zt=Le?new Uint16Array(32768):Dt(32768),qt=Le?new Uint16Array(128):Dt(128),kt=1,ze=1;function nt(Q,he){var Se=It(Q,he)+257;he+=5;var ne=It(Q,he)+1;he+=5;var _e=et(Q,he)+4;he+=4;for(var Ce=0,Qe=Le?new Uint8Array(19):Dt(19),xt=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],dt=1,at=Le?new Uint8Array(8):Dt(8),$e=Le?new Uint8Array(8):Dt(8),tt=Qe.length,gt=0;gt<_e;++gt)Qe[oe[gt]]=Ce=ct(Q,he),dt<Ce&&(dt=Ce),at[Ce]++,he+=3;var Wt=0;for(at[0]=0,gt=1;gt<=dt;++gt)$e[gt]=Wt=Wt+at[gt-1]<<1;for(gt=0;gt<tt;++gt)(Wt=Qe[gt])!=0&&(xt[gt]=$e[Wt]++);var Ft=0;for(gt=0;gt<tt;++gt)if(Ft=Qe[gt],Ft!=0){Wt=Pe[xt[gt]]>>8-Ft;for(var Zt=(1<<7-Ft)-1;Zt>=0;--Zt)qt[Wt|Zt<<Ft]=Ft&7|gt<<3}var br=[];for(dt=1;br.length<Se+ne;)switch(Wt=qt[ft(Q,he)],he+=Wt&7,Wt>>>=3){case 16:for(Ce=3+rt(Q,he),he+=2,Wt=br[br.length-1];Ce-- >0;)br.push(Wt);break;case 17:for(Ce=3+ct(Q,he),he+=3;Ce-- >0;)br.push(0);break;case 18:for(Ce=11+ft(Q,he),he+=7;Ce-- >0;)br.push(0);break;default:br.push(Wt),dt<Wt&&(dt=Wt);break}var Ht=br.slice(0,Se),fa=br.slice(Se);for(gt=Se;gt<286;++gt)Ht[gt]=0;for(gt=ne;gt<30;++gt)fa[gt]=0;return kt=ar(Ht,wt,286),ze=ar(fa,zt,30),he}function _t(Q,he){if(Q[0]==3&&!(Q[1]&3))return[Gc(he),2];for(var Se=0,ne=0,_e=f_(he||1<<18),Ce=0,Qe=_e.length>>>0,xt=0,dt=0;(ne&1)==0;){if(ne=ct(Q,Se),Se+=3,ne>>>1)ne>>1==1?(xt=9,dt=5):(Se=nt(Q,Se),xt=kt,dt=ze);else{Se&7&&(Se+=8-(Se&7));var at=Q[Se>>>3]|Q[(Se>>>3)+1]<<8;if(Se+=32,at>0)for(!he&&Qe<Ce+at&&(_e=qe(_e,Ce+at),Qe=_e.length);at-- >0;)_e[Ce++]=Q[Se>>>3],Se+=8;continue}for(;;){!he&&Qe<Ce+32767&&(_e=qe(_e,Ce+32767),Qe=_e.length);var $e=Lt(Q,Se,xt),tt=ne>>>1==1?yt[$e]:wt[$e];if(Se+=tt&15,tt>>>=4,(tt>>>8&255)===0)_e[Ce++]=tt;else{if(tt==256)break;tt-=257;var gt=tt<8?0:tt-4>>2;gt>5&&(gt=0);var Wt=Ce+le[tt];gt>0&&(Wt+=Lt(Q,Se,gt),Se+=gt),$e=Lt(Q,Se,dt),tt=ne>>>1==1?St[$e]:zt[$e],Se+=tt&15,tt>>>=4;var Ft=tt<4?0:tt-2>>1,Zt=be[tt];for(Ft>0&&(Zt+=Lt(Q,Se,Ft),Se+=Ft),!he&&Qe<Wt&&(_e=qe(_e,Wt+100),Qe=_e.length);Ce<Wt;)_e[Ce]=_e[Ce-Zt],++Ce}}}return he?[_e,Se+7>>>3]:[_e.slice(0,Ce),Se+7>>>3]}function lr(Q,he){var Se=Q.slice(Q.l||0),ne=_t(Se,he);return Q.l+=ne[1],ne[0]}function pr(Q,he){if(Q)typeof console!="undefined"&&console.error(he);else throw new Error(he)}function Nr(Q,he){var Se=Q;fi(Se,0);var ne=[],_e=[],Ce={FileIndex:ne,FullPaths:_e};B(Ce,{root:he.root});for(var Qe=Se.length-4;(Se[Qe]!=80||Se[Qe+1]!=75||Se[Qe+2]!=5||Se[Qe+3]!=6)&&Qe>=0;)--Qe;Se.l=Qe+4,Se.l+=4;var xt=Se.read_shift(2);Se.l+=6;var dt=Se.read_shift(4);for(Se.l=dt,Qe=0;Qe<xt;++Qe){Se.l+=20;var at=Se.read_shift(4),$e=Se.read_shift(4),tt=Se.read_shift(2),gt=Se.read_shift(2),Wt=Se.read_shift(2);Se.l+=8;var Ft=Se.read_shift(4),Zt=u(Se.slice(Se.l+tt,Se.l+tt+gt));Se.l+=tt+gt+Wt;var br=Se.l;Se.l=Ft+4,rr(Se,at,$e,Ce,Zt),Se.l=br}return Ce}function rr(Q,he,Se,ne,_e){Q.l+=2;var Ce=Q.read_shift(2),Qe=Q.read_shift(2),xt=c(Q);if(Ce&8257)throw new Error("Unsupported ZIP encryption");for(var dt=Q.read_shift(4),at=Q.read_shift(4),$e=Q.read_shift(4),tt=Q.read_shift(2),gt=Q.read_shift(2),Wt="",Ft=0;Ft<tt;++Ft)Wt+=String.fromCharCode(Q[Q.l++]);if(gt){var Zt=u(Q.slice(Q.l,Q.l+gt));(Zt[21589]||{}).mt&&(xt=Zt[21589].mt),((_e||{})[21589]||{}).mt&&(xt=_e[21589].mt)}Q.l+=gt;var br=Q.slice(Q.l,Q.l+at);switch(Qe){case 8:br=J(Q,$e);break;case 0:break;default:throw new Error("Unsupported ZIP Compression method "+Qe)}var Ht=!1;Ce&8&&(dt=Q.read_shift(4),dt==134695760&&(dt=Q.read_shift(4),Ht=!0),at=Q.read_shift(4),$e=Q.read_shift(4)),at!=he&&pr(Ht,"Bad compressed size: "+he+" != "+at),$e!=Se&&pr(Ht,"Bad uncompressed size: "+Se+" != "+$e),ir(ne,Wt,br,{unsafe:!0,mt:xt})}function _r(Q,he){var Se=he||{},ne=[],_e=[],Ce=sr(1),Qe=Se.compression?8:0,xt=0,dt=0,at=0,$e=0,tt=0,gt=Q.FullPaths[0],Wt=gt,Ft=Q.FileIndex[0],Zt=[],br=0;for(dt=1;dt<Q.FullPaths.length;++dt)if(Wt=Q.FullPaths[dt].slice(gt.length),Ft=Q.FileIndex[dt],!(!Ft.size||!Ft.content||Wt=="Sh33tJ5")){var Ht=$e,fa=sr(Wt.length);for(at=0;at<Wt.length;++at)fa.write_shift(1,Wt.charCodeAt(at)&127);fa=fa.slice(0,fa.l),Zt[tt]=cA.buf(Ft.content,0);var qr=Ft.content;Qe==8&&(qr=ae(qr)),Ce=sr(30),Ce.write_shift(4,67324752),Ce.write_shift(2,20),Ce.write_shift(2,xt),Ce.write_shift(2,Qe),Ft.mt?i(Ce,Ft.mt):Ce.write_shift(4,0),Ce.write_shift(-4,Zt[tt]),Ce.write_shift(4,qr.length),Ce.write_shift(4,Ft.content.length),Ce.write_shift(2,fa.length),Ce.write_shift(2,0),$e+=Ce.length,ne.push(Ce),$e+=fa.length,ne.push(fa),$e+=qr.length,ne.push(qr),Ce=sr(46),Ce.write_shift(4,33639248),Ce.write_shift(2,0),Ce.write_shift(2,20),Ce.write_shift(2,xt),Ce.write_shift(2,Qe),Ce.write_shift(4,0),Ce.write_shift(-4,Zt[tt]),Ce.write_shift(4,qr.length),Ce.write_shift(4,Ft.content.length),Ce.write_shift(2,fa.length),Ce.write_shift(2,0),Ce.write_shift(2,0),Ce.write_shift(2,0),Ce.write_shift(2,0),Ce.write_shift(4,0),Ce.write_shift(4,Ht),br+=Ce.l,_e.push(Ce),br+=fa.length,_e.push(fa),++tt}return Ce=sr(22),Ce.write_shift(4,101010256),Ce.write_shift(2,0),Ce.write_shift(2,0),Ce.write_shift(2,tt),Ce.write_shift(2,tt),Ce.write_shift(4,br),Ce.write_shift(4,$e),Ce.write_shift(2,0),qn([qn(ne),qn(_e),Ce])}var Nt={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 Cr(Q,he){if(Q.ctype)return Q.ctype;var Se=Q.name||"",ne=Se.match(/\.([^\.]+)$/);return ne&&Nt[ne[1]]||he&&(ne=(Se=he).match(/[\.\\]([^\.\\])+$/),ne&&Nt[ne[1]])?Nt[ne[1]]:"application/octet-stream"}function yr(Q){for(var he=Sf(Q),Se=[],ne=0;ne<he.length;ne+=76)Se.push(he.slice(ne,ne+76));return Se.join(`\r
`)+`\r
`}function jt(Q){var he=Q.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7E-\xFF=]/g,function(at){var $e=at.charCodeAt(0).toString(16).toUpperCase();return"="+($e.length==1?"0"+$e:$e)});he=he.replace(/ $/mg,"=20").replace(/\t$/mg,"=09"),he.charAt(0)==`
`&&(he="=0D"+he.slice(1)),he=he.replace(/\r(?!\n)/mg,"=0D").replace(/\n\n/mg,`
=0A`).replace(/([^\r\n])\n/mg,"$1=0A");for(var Se=[],ne=he.split(`\r
`),_e=0;_e<ne.length;++_e){var Ce=ne[_e];if(Ce.length==0){Se.push("");continue}for(var Qe=0;Qe<Ce.length;){var xt=76,dt=Ce.slice(Qe,Qe+xt);dt.charAt(xt-1)=="="?xt--:dt.charAt(xt-2)=="="?xt-=2:dt.charAt(xt-3)=="="&&(xt-=3),dt=Ce.slice(Qe,Qe+xt),Qe+=xt,Qe<Ce.length&&(dt+="="),Se.push(dt)}}return Se.join(`\r
`)}function Tt(Q){for(var he=[],Se=0;Se<Q.length;++Se){for(var ne=Q[Se];Se<=Q.length&&ne.charAt(ne.length-1)=="=";)ne=ne.slice(0,ne.length-1)+Q[++Se];he.push(ne)}for(var _e=0;_e<he.length;++_e)he[_e]=he[_e].replace(/[=][0-9A-Fa-f]{2}/g,function(Ce){return String.fromCharCode(parseInt(Ce.slice(1),16))});return vo(he.join(`\r
`))}function He(Q,he,Se){for(var ne="",_e="",Ce="",Qe,xt=0;xt<10;++xt){var dt=he[xt];if(!dt||dt.match(/^\s*$/))break;var at=dt.match(/^(.*?):\s*([^\s].*)$/);if(at)switch(at[1].toLowerCase()){case"content-location":ne=at[2].trim();break;case"content-type":Ce=at[2].trim();break;case"content-transfer-encoding":_e=at[2].trim();break}}switch(++xt,_e.toLowerCase()){case"base64":Qe=vo(ko(he.slice(xt).join("")));break;case"quoted-printable":Qe=Tt(he.slice(xt));break;default:throw new Error("Unsupported Content-Transfer-Encoding "+_e)}var $e=ir(Q,ne.slice(Se.length),Qe,{unsafe:!0});Ce&&($e.ctype=Ce)}function Fe(Q,he){if(ce(Q.slice(0,13)).toLowerCase()!="mime-version:")throw new Error("Unsupported MAD header");var Se=he&&he.root||"",ne=(Ca&&Buffer.isBuffer(Q)?Q.toString("binary"):ce(Q)).split(`\r
`),_e=0,Ce="";for(_e=0;_e<ne.length;++_e)if(Ce=ne[_e],!!/^Content-Location:/i.test(Ce)&&(Ce=Ce.slice(Ce.indexOf("file")),Se||(Se=Ce.slice(0,Ce.lastIndexOf("/")+1)),Ce.slice(0,Se.length)!=Se))for(;Se.length>0&&(Se=Se.slice(0,Se.length-1),Se=Se.slice(0,Se.lastIndexOf("/")+1),Ce.slice(0,Se.length)!=Se););var Qe=(ne[1]||"").match(/boundary="(.*?)"/);if(!Qe)throw new Error("MAD cannot find boundary");var xt="--"+(Qe[1]||""),dt=[],at=[],$e={FileIndex:dt,FullPaths:at};B($e);var tt,gt=0;for(_e=0;_e<ne.length;++_e){var Wt=ne[_e];Wt!==xt&&Wt!==xt+"--"||(gt++&&He($e,ne.slice(tt,_e),Se),tt=_e)}return $e}function Ze(Q,he){var Se=he||{},ne=Se.boundary||"SheetJS";ne="------="+ne;for(var _e=["MIME-Version: 1.0",'Content-Type: multipart/related; boundary="'+ne.slice(2)+'"',"","",""],Ce=Q.FullPaths[0],Qe=Ce,xt=Q.FileIndex[0],dt=1;dt<Q.FullPaths.length;++dt)if(Qe=Q.FullPaths[dt].slice(Ce.length),xt=Q.FileIndex[dt],!(!xt.size||!xt.content||Qe=="Sh33tJ5")){Qe=Qe.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7E-\xFF]/g,function(br){return"_x"+br.charCodeAt(0).toString(16)+"_"}).replace(/[\u0080-\uFFFF]/g,function(br){return"_u"+br.charCodeAt(0).toString(16)+"_"});for(var at=xt.content,$e=Ca&&Buffer.isBuffer(at)?at.toString("binary"):ce(at),tt=0,gt=Math.min(1024,$e.length),Wt=0,Ft=0;Ft<=gt;++Ft)(Wt=$e.charCodeAt(Ft))>=32&&Wt<128&&++tt;var Zt=tt>=gt*4/5;_e.push(ne),_e.push("Content-Location: "+(Se.root||"file:///C:/SheetJS/")+Qe),_e.push("Content-Transfer-Encoding: "+(Zt?"quoted-printable":"base64")),_e.push("Content-Type: "+Cr(xt,Qe)),_e.push(""),_e.push(Zt?jt($e):yr($e))}return _e.push(ne+`--\r
`),_e.join(`\r
`)}function vt(Q){var he={};return B(he,Q),he}function ir(Q,he,Se,ne){var _e=ne&&ne.unsafe;_e||B(Q);var Ce=!_e&&Zr.find(Q,he);if(!Ce){var Qe=Q.FullPaths[0];he.slice(0,Qe.length)==Qe?Qe=he:(Qe.slice(-1)!="/"&&(Qe+="/"),Qe=(Qe+he).replace("//","/")),Ce={name:n(he),type:2},Q.FileIndex.push(Ce),Q.FullPaths.push(Qe),_e||Zr.utils.cfb_gc(Q)}return Ce.content=Se,Ce.size=Se?Se.length:0,ne&&(ne.CLSID&&(Ce.clsid=ne.CLSID),ne.mt&&(Ce.mt=ne.mt),ne.ct&&(Ce.ct=ne.ct)),Ce}function fr(Q,he){B(Q);var Se=Zr.find(Q,he);if(Se){for(var ne=0;ne<Q.FileIndex.length;++ne)if(Q.FileIndex[ne]==Se)return Q.FileIndex.splice(ne,1),Q.FullPaths.splice(ne,1),!0}return!1}function Kt(Q,he,Se){B(Q);var ne=Zr.find(Q,he);if(ne){for(var _e=0;_e<Q.FileIndex.length;++_e)if(Q.FileIndex[_e]==ne)return Q.FileIndex[_e].name=n(Se),Q.FullPaths[_e]=Se,!0}return!1}function Re(Q){G(Q,!0)}return r.find=fe,r.read=X,r.parse=y,r.write=ye,r.writeFile=ve,r.utils={cfb_new:vt,cfb_add:ir,cfb_del:fr,cfb_mov:Kt,cfb_gc:Re,ReadShift:hf,CheckField:U3,prep_blob:fi,bconcat:qn,use_zlib:q,_deflateRaw:Ye,_inflateRaw:lr,consts:ee},r})();function dA(e){return typeof e=="string"?pg(e):Array.isArray(e)?MT(e):e}function $f(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=pg(r);break;default:throw new Error("Unsupported encoding "+a)}return Deno.writeFileSync(e,r)}var s=a=="utf8"?Rl(r):r;if(typeof IE_SaveFile!="undefined")return IE_SaveFile(s,e);if(typeof Blob!="undefined"){var n=new Blob([dA(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 c=document.createElement("a");if(c.download!=null)return c.download=e,c.href=i,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL&&typeof setTimeout!="undefined"&&setTimeout(function(){URL.revokeObjectURL(i)},6e4),i}}if(typeof $!="undefined"&&typeof File!="undefined"&&typeof Folder!="undefined")try{var u=File(e);return u.open("w"),u.encoding="binary",Array.isArray(r)&&(r=Zc(r)),u.write(r),u.close(),r}catch(h){if(!h.message||!h.message.match(/onstruct/))throw h}throw new Error("cannot save file "+e)}function uA(e){if(typeof Deno!="undefined")return Deno.readFileSync(e);if(typeof $!="undefined"&&typeof File!="undefined"&&typeof Folder!="undefined")try{var r=File(e);r.open("r"),r.encoding="binary";var a=r.read();return r.close(),a}catch(s){if(!s.message||!s.message.match(/onstruct/))throw s}throw new Error("Cannot access file "+e)}function Qs(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 v_(e,r){for(var a=[],s=Qs(e),n=0;n!==s.length;++n)a[e[s[n]][r]]==null&&(a[e[s[n]][r]]=s[n]);return a}function bg(e){for(var r=[],a=Qs(e),s=0;s!==a.length;++s)r[e[a[s]]]=a[s];return r}function vg(e){for(var r=[],a=Qs(e),s=0;s!==a.length;++s)r[e[a[s]]]=parseInt(a[s],10);return r}function fA(e){for(var r=[],a=Qs(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 Km=new Date(1899,11,30,0,0,0);function Pn(e,r){var a=e.getTime(),s=Km.getTime()+(e.getTimezoneOffset()-Km.getTimezoneOffset())*6e4;return(a-s)/(1440*60*1e3)}var b3=new Date,hA=Km.getTime()+(b3.getTimezoneOffset()-Km.getTimezoneOffset())*6e4,w_=b3.getTimezoneOffset();function wg(e){var r=new Date;return r.setTime(e*24*60*60*1e3+hA),r.getTimezoneOffset()!==w_&&r.setTime(r.getTime()+(r.getTimezoneOffset()-w_)*6e4),r}function mA(e){var r=0,a=0,s=!1,n=e.match(/P([0-9\.]+Y)?([0-9\.]+M)?([0-9\.]+D)?T([0-9\.]+H)?([0-9\.]+M)?([0-9\.]+S)?/);if(!n)throw new Error("|"+e+"| is not an ISO8601 Duration");for(var i=1;i!=n.length;++i)if(n[i]){switch(a=1,i>3&&(s=!0),n[i].slice(n[i].length-1)){case"Y":throw new Error("Unsupported ISO Duration Field: "+n[i].slice(n[i].length-1));case"D":a*=24;case"H":a*=60;case"M":if(s)a*=60;else throw new Error("Unsupported ISO Duration Field: M")}r+=a*parseInt(n[i],10)}return r}var __=new Date("2017-02-19T19:06:09.000Z"),v3=isNaN(__.getFullYear())?new Date("2/19/17"):__,gA=v3.getFullYear()==2017;function Cs(e,r){var a=new Date(e);if(gA)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(v3.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 Ld(e,r){if(Ca&&Buffer.isBuffer(e)){if(r){if(e[0]==255&&e[1]==254)return Rl(e.slice(2).toString("utf16le"));if(e[1]==254&&e[2]==255)return Rl(o3(e.slice(2).toString("binary")))}return e.toString("binary")}if(typeof TextDecoder!="undefined")try{if(r){if(e[0]==255&&e[1]==254)return Rl(new TextDecoder("utf-16le").decode(e.slice(2)));if(e[0]==254&&e[1]==255)return Rl(new TextDecoder("utf-16be").decode(e.slice(2)))}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 Es(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]=Es(e[a]));return r}function Xs(e,r){for(var a="";a.length<r;)a+=e;return a}function cl(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 xA=["january","february","march","april","may","june","july","august","september","october","november","december"];function Y0(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 c=e.toLowerCase();if(c.match(/jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec/)){if(c=c.replace(/[^a-z]/g,"").replace(/([^a-z]|^)[ap]m?([^a-z]|$)/,""),c.length>3&&xA.indexOf(c)==-1)return a}else if(c.match(/[a-z]/))return a;return s<0||s>8099?a:(n>0||i>1)&&s!=101?r:e.match(/[^-0-9:,\/\\]/)?a:r}var pA=(function(){var e="abacaba".split(/(:?b)/i).length==5;return function(a,s,n){if(e||typeof s=="string")return a.split(s);for(var i=a.split(s),c=[i[0]],u=1;u<i.length;++u)c.push(n),c.push(i[u]);return c}})();function w3(e){return e?e.content&&e.type?Ld(e.content,!0):e.data?af(e.data):e.asNodeBuffer&&Ca?af(e.asNodeBuffer().toString("binary")):e.asBinary?af(e.asBinary()):e._data&&e._data.getContent?af(Ld(Array.prototype.slice.call(e._data.getContent(),0))):null:null}function _3(e){if(!e)return null;if(e.data)return d_(e.data);if(e.asNodeBuffer&&Ca)return e.asNodeBuffer();if(e._data&&e._data.getContent){var r=e._data.getContent();return typeof r=="string"?d_(r):Array.prototype.slice.call(r)}return e.content&&e.type?e.content:null}function yA(e){return e&&e.name.slice(-4)===".bin"?_3(e):w3(e)}function Uo(e,r){for(var a=e.FullPaths||Qs(e.files),s=r.toLowerCase().replace(/[\/]/g,"\\"),n=s.replace(/\\/g,"/"),i=0;i<a.length;++i){var c=a[i].replace(/^Root Entry[\/]/,"").toLowerCase();if(s==c||n==c)return e.files?e.files[a[i]]:e.FileIndex[i]}return null}function by(e,r){var a=Uo(e,r);if(a==null)throw new Error("Cannot find file "+r+" in zip");return a}function kn(e,r,a){if(!a)return yA(by(e,r));if(!r)return null;try{return kn(e,r)}catch(s){return null}}function wo(e,r,a){if(!a)return w3(by(e,r));if(!r)return null;try{return wo(e,r)}catch(s){return null}}function bA(e,r,a){return _3(by(e,r))}function k_(e){for(var r=e.FullPaths||Qs(e.files),a=[],s=0;s<r.length;++s)r[s].slice(-1)!="/"&&a.push(r[s].replace(/^Root Entry[\/]/,""));return a.sort()}function ka(e,r,a){if(e.FullPaths){if(typeof a=="string"){var s;return Ca?s=hc(a):s=PT(a),Zr.utils.cfb_add(e,r,s)}Zr.utils.cfb_add(e,r,a)}else e.file(r,a)}function vy(){return Zr.utils.cfb_new()}function k3(e,r){switch(r.type){case"base64":return Zr.read(e,{type:"base64"});case"binary":return Zr.read(e,{type:"binary"});case"buffer":case"array":return Zr.read(e,{type:"buffer"})}throw new Error("Unrecognized type "+r.type)}function nf(e,r){if(e.charAt(0)=="/")return e.slice(1);var a=r.split("/");r.slice(-1)!="/"&&a.pop();for(var s=e.split("/");s.length!==0;){var n=s.shift();n===".."?a.pop():n!=="."&&a.push(n)}return a.join("/")}var cn=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r
`,vA=/([^"\s?>\/]+)\s*=\s*((?:")([^"]*)(?:")|(?:')([^']*)(?:')|([^'">\s]+))/g,N_=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s*[\/\?]?>/mg,wA=/<[^>]*>/g,Ti=cn.match(N_)?N_:wA,_A=/<\w*:/,kA=/<(\/?)\w+:/;function ia(e,r,a){for(var s={},n=0,i=0;n!==e.length&&!((i=e.charCodeAt(n))===32||i===10||i===13);++n);if(r||(s[0]=e.slice(0,n)),n===e.length)return s;var c=e.match(vA),u=0,h="",g=0,y="",w="",E=1;if(c)for(g=0;g!=c.length;++g){for(w=c[g],i=0;i!=w.length&&w.charCodeAt(i)!==61;++i);for(y=w.slice(0,i).trim();w.charCodeAt(i+1)==32;)++i;for(E=(n=w.charCodeAt(i+1))==34||n==39?1:0,h=w.slice(i+1+E,w.length-E),u=0;u!=y.length&&y.charCodeAt(u)!==58;++u);if(u===y.length)y.indexOf("_")>0&&(y=y.slice(0,y.indexOf("_"))),s[y]=h,s[y.toLowerCase()]=h;else{var S=(u===5&&y.slice(0,5)==="xmlns"?"xmlns":"")+y.slice(u+1);if(s[S]&&y.slice(u-3,u)=="ext")continue;s[S]=h,s[S.toLowerCase()]=h}}return s}function Ml(e){return e.replace(kA,"<$1")}var N3={"&quot;":'"',"&apos;":"'","&gt;":">","&lt;":"<","&amp;":"&"},wy=bg(N3),Ha=(function(){var e=/&(?:quot|apos|gt|lt|amp|#x?([\da-fA-F]+));/ig,r=/_x([\da-fA-F]{4})_/ig;return function a(s){var n=s+"",i=n.indexOf("<![CDATA[");if(i==-1)return n.replace(e,function(u,h){return N3[u]||String.fromCharCode(parseInt(h,u.indexOf("x")>-1?16:10))||u}).replace(r,function(u,h){return String.fromCharCode(parseInt(h,16))});var c=n.indexOf("]]>");return a(n.slice(0,i))+n.slice(i+9,c)+a(n.slice(c+3))}})(),_y=/[&<>'"]/g,NA=/[\u0000-\u0008\u000b-\u001f]/g;function ls(e){var r=e+"";return r.replace(_y,function(a){return wy[a]}).replace(NA,function(a){return"_x"+("000"+a.charCodeAt(0).toString(16)).slice(-4)+"_"})}function j_(e){return ls(e).replace(/ /g,"_x0020_")}var j3=/[\u0000-\u001f]/g;function ky(e){var r=e+"";return r.replace(_y,function(a){return wy[a]}).replace(/\n/g,"<br/>").replace(j3,function(a){return"&#x"+("000"+a.charCodeAt(0).toString(16)).slice(-4)+";"})}function jA(e){var r=e+"";return r.replace(_y,function(a){return wy[a]}).replace(j3,function(a){return"&#x"+a.charCodeAt(0).toString(16).toUpperCase()+";"})}var S_=(function(){var e=/&#(\d+);/g;function r(a,s){return String.fromCharCode(parseInt(s,10))}return function(s){return s.replace(e,r)}})();function SA(e){return e.replace(/(\r\n|[\r\n])/g,"&#10;")}function Ss(e){switch(e){case 1:case!0:case"1":case"true":case"TRUE":return!0;default:return!1}}function zp(e){for(var r="",a=0,s=0,n=0,i=0,c=0,u=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){c=(s&31)<<6,c|=n&63,r+=String.fromCharCode(c);continue}if(i=e.charCodeAt(a++),s<240){r+=String.fromCharCode((s&15)<<12|(n&63)<<6|i&63);continue}c=e.charCodeAt(a++),u=((s&7)<<18|(n&63)<<12|(i&63)<<6|c&63)-65536,r+=String.fromCharCode(55296+(u>>>10&1023)),r+=String.fromCharCode(56320+(u&1023))}return r}function C_(e){var r=Gc(2*e.length),a,s,n=1,i=0,c=0,u;for(s=0;s<e.length;s+=n)n=1,(u=e.charCodeAt(s))<128?a=u:u<224?(a=(u&31)*64+(e.charCodeAt(s+1)&63),n=2):u<240?(a=(u&15)*4096+(e.charCodeAt(s+1)&63)*64+(e.charCodeAt(s+2)&63),n=3):(n=4,a=(u&7)*262144+(e.charCodeAt(s+1)&63)*4096+(e.charCodeAt(s+2)&63)*64+(e.charCodeAt(s+3)&63),a-=65536,c=55296+(a>>>10&1023),a=56320+(a&1023)),c!==0&&(r[i++]=c&255,r[i++]=c>>>8,c=0),r[i++]=a%256,r[i++]=a>>>8;return r.slice(0,i).toString("ucs2")}function E_(e){return hc(e,"binary").toString("utf8")}var om="foo bar baz☃🍣",ms=Ca&&(E_(om)==zp(om)&&E_||C_(om)==zp(om)&&C_)||zp,Rl=Ca?function(e){return hc(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("")},Ef=(function(){var e={};return function(a,s){var n=a+"|"+(s||"");return e[n]?e[n]:e[n]=new RegExp("<(?:\\w+:)?"+a+'(?: xml:space="preserve")?(?:[^>]*)>([\\s\\S]*?)</(?:\\w+:)?'+a+">",s||"")}})(),S3=(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}})(),CA=(function(){var e={};return function(a){return e[a]!==void 0?e[a]:e[a]=new RegExp("<(?:vt:)?"+a+">([\\s\\S]*?)</(?:vt:)?"+a+">","g")}})(),EA=/<\/?(?:vt:)?variant>/g,TA=/<(?:vt:)([^>]*)>([\s\S]*)</;function T_(e,r){var a=ia(e),s=e.match(CA(a.baseType))||[],n=[];if(s.length!=a.size){if(r.WTF)throw new Error("unexpected vector length "+s.length+" != "+a.size);return n}return s.forEach(function(i){var c=i.replace(EA,"").match(TA);c&&n.push({v:ms(c[2]),t:c[1]})}),n}var C3=/(^\s|\s$|\n)/;function hi(e,r){return"<"+e+(r.match(C3)?' xml:space="preserve"':"")+">"+r+"</"+e+">"}function Tf(e){return Qs(e).map(function(r){return" "+r+'="'+e[r]+'"'}).join("")}function kr(e,r,a){return"<"+e+(a!=null?Tf(a):"")+(r!=null?(r.match(C3)?' xml:space="preserve"':"")+">"+r+"</"+e:"/")+">"}function N1(e,r){try{return e.toISOString().replace(/\.\d*/,"")}catch(a){if(r)throw a}return""}function AA(e,r){switch(typeof e){case"string":var a=kr("vt:lpwstr",ls(e));return a=a.replace(/&quot;/g,"_x0022_"),a;case"number":return kr((e|0)==e?"vt:i4":"vt:r8",ls(String(e)));case"boolean":return kr("vt:bool",e?"true":"false")}if(e instanceof Date)return kr("vt:filetime",N1(e));throw new Error("Unable to serialize "+e)}function Ny(e){if(Ca&&Buffer.isBuffer(e))return e.toString("utf8");if(typeof e=="string")return e;if(typeof Uint8Array!="undefined"&&e instanceof Uint8Array)return ms(Zc(xy(e)));throw new Error("Bad input format: expected Buffer or string")}var Af=/<(\/?)([^\s?><!\/:]*:|)([^\s?<>:\/]+)(?:[\s?:\/][^>]*)?>/mg,Fn={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"},Vd=["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"],yo={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 OA(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 DA(e,r,a){var s=(r<0||1/r==-1/0?1:0)<<7,n=0,i=0,c=s?-r:r;isFinite(c)?c==0?n=i=0:(n=Math.floor(Math.log(c)/Math.LN2),i=c*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 u=0;u<=5;++u,i/=256)e[a+u]=i&255;e[a+6]=(n&15)<<4|i&15,e[a+7]=n>>4|s}var A_=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},O_=Ca?function(e){return e[0].length>0&&Buffer.isBuffer(e[0][0])?Buffer.concat(e[0].map(function(r){return Buffer.isBuffer(r)?r:hc(r)})):A_(e)}:A_,D_=function(e,r,a){for(var s=[],n=r;n<a;n+=2)s.push(String.fromCharCode(sc(e,n)));return s.join("").replace(Bi,"")},jy=Ca?function(e,r,a){return Buffer.isBuffer(e)?e.toString("utf16le",r,a).replace(Bi,""):D_(e,r,a)}:D_,R_=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("")},E3=Ca?function(e,r,a){return Buffer.isBuffer(e)?e.toString("hex",r,r+a):R_(e,r,a)}:R_,F_=function(e,r,a){for(var s=[],n=r;n<a;n++)s.push(String.fromCharCode(F0(e,n)));return s.join("")},Vf=Ca?function(r,a,s){return Buffer.isBuffer(r)?r.toString("utf8",a,s):F_(r,a,s)}:F_,T3=function(e,r){var a=bo(e,r);return a>0?Vf(e,r+4,r+4+a-1):""},A3=T3,O3=function(e,r){var a=bo(e,r);return a>0?Vf(e,r+4,r+4+a-1):""},D3=O3,R3=function(e,r){var a=2*bo(e,r);return a>0?Vf(e,r+4,r+4+a-1):""},F3=R3,I3=function(r,a){var s=bo(r,a);return s>0?jy(r,a+4,a+4+s):""},M3=I3,P3=function(e,r){var a=bo(e,r);return a>0?Vf(e,r+4,r+4+a):""},L3=P3,B3=function(e,r){return OA(e,r)},Jm=B3,Sy=function(r){return Array.isArray(r)||typeof Uint8Array!="undefined"&&r instanceof Uint8Array};Ca&&(A3=function(r,a){if(!Buffer.isBuffer(r))return T3(r,a);var s=r.readUInt32LE(a);return s>0?r.toString("utf8",a+4,a+4+s-1):""},D3=function(r,a){if(!Buffer.isBuffer(r))return O3(r,a);var s=r.readUInt32LE(a);return s>0?r.toString("utf8",a+4,a+4+s-1):""},F3=function(r,a){if(!Buffer.isBuffer(r))return R3(r,a);var s=2*r.readUInt32LE(a);return r.toString("utf16le",a+4,a+4+s-1)},M3=function(r,a){if(!Buffer.isBuffer(r))return I3(r,a);var s=r.readUInt32LE(a);return r.toString("utf16le",a+4,a+4+s)},L3=function(r,a){if(!Buffer.isBuffer(r))return P3(r,a);var s=r.readUInt32LE(a);return r.toString("utf8",a+4,a+4+s)},Jm=function(r,a){return Buffer.isBuffer(r)?r.readDoubleLE(a):B3(r,a)},Sy=function(r){return Buffer.isBuffer(r)||Array.isArray(r)||typeof Uint8Array!="undefined"&&r instanceof Uint8Array});var F0=function(e,r){return e[r]},sc=function(e,r){return e[r+1]*256+e[r]},RA=function(e,r){var a=e[r+1]*256+e[r];return a<32768?a:(65535-a+1)*-1},bo=function(e,r){return e[r+3]*(1<<24)+(e[r+2]<<16)+(e[r+1]<<8)+e[r]},bd=function(e,r){return e[r+3]<<24|e[r+2]<<16|e[r+1]<<8|e[r]},FA=function(e,r){return e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3]};function hf(e,r){var a="",s,n,i=[],c,u,h,g;switch(r){case"dbcs":if(g=this.l,Ca&&Buffer.isBuffer(this))a=this.slice(this.l,this.l+2*e).toString("utf16le");else for(h=0;h<e;++h)a+=String.fromCharCode(sc(this,g)),g+=2;e*=2;break;case"utf8":a=Vf(this,this.l,this.l+e);break;case"utf16le":e*=2,a=jy(this,this.l,this.l+e);break;case"wstr":return hf.call(this,e,"dbcs");case"lpstr-ansi":a=A3(this,this.l),e=4+bo(this,this.l);break;case"lpstr-cp":a=D3(this,this.l),e=4+bo(this,this.l);break;case"lpwstr":a=F3(this,this.l),e=4+2*bo(this,this.l);break;case"lpp4":e=4+bo(this,this.l),a=M3(this,this.l),e&2&&(e+=2);break;case"8lpp4":e=4+bo(this,this.l),a=L3(this,this.l),e&3&&(e+=4-(e&3));break;case"cstr":for(e=0,a="";(c=F0(this,this.l+e++))!==0;)i.push(im(c));a=i.join("");break;case"_wstr":for(e=0,a="";(c=sc(this,this.l+e))!==0;)i.push(im(c)),e+=2;e+=2,a=i.join("");break;case"dbcs-cont":for(a="",g=this.l,h=0;h<e;++h){if(this.lens&&this.lens.indexOf(g)!==-1)return c=F0(this,g),this.l=g+1,u=hf.call(this,e-h,c?"dbcs-cont":"sbcs-cont"),i.join("")+u;i.push(im(sc(this,g))),g+=2}a=i.join(""),e*=2;break;case"cpstr":case"sbcs-cont":for(a="",g=this.l,h=0;h!=e;++h){if(this.lens&&this.lens.indexOf(g)!==-1)return c=F0(this,g),this.l=g+1,u=hf.call(this,e-h,c?"dbcs-cont":"sbcs-cont"),i.join("")+u;i.push(im(F0(this,g))),g+=1}a=i.join("");break;default:switch(e){case 1:return s=F0(this,this.l),this.l++,s;case 2:return s=(r==="i"?RA:sc)(this,this.l),this.l+=2,s;case 4:case-4:return r==="i"||(this[this.l+3]&128)===0?(s=(e>0?bd:FA)(this,this.l),this.l+=4,s):(n=bo(this,this.l),this.l+=4,n);case 8:case-8:if(r==="f")return e==8?n=Jm(this,this.l):n=Jm([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=E3(this,this.l,e);break}}return this.l+=e,a}var IA=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},MA=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},PA=function(e,r,a){e[a]=r&255,e[a+1]=r>>>8&255};function LA(e,r,a){var s=0,n=0;if(a==="dbcs"){for(n=0;n!=r.length;++n)PA(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 c=r.charCodeAt(n);this[this.l++]=c&255,this[this.l++]=c>>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,IA(this,r,this.l);break;case 8:if(s=8,a==="f"){DA(this,r,this.l);break}case 16:break;case-4:s=4,MA(this,r,this.l);break}return this.l+=s,this}function U3(e,r){var a=E3(this,this.l,e.length>>1);if(a!==e)throw new Error(r+"Expected "+e+" saw "+a);this.l+=e.length>>1}function fi(e,r){e.l=r,e.read_shift=hf,e.chk=U3,e.write_shift=LA}function Ei(e,r){e.l+=r}function sr(e){var r=Gc(e);return fi(r,0),r}function mc(e,r,a){if(e){var s,n,i;fi(e,e.l||0);for(var c=e.length,u=0,h=0;e.l<c;){u=e.read_shift(1),u&128&&(u=(u&127)+((e.read_shift(1)&127)<<7));var g=Mf[u]||Mf[65535];for(s=e.read_shift(1),i=s&127,n=1;n<4&&s&128;++n)i+=((s=e.read_shift(1))&127)<<7*n;h=e.l+i;var y=g.f&&g.f(e,i,a);if(e.l=h,r(y,g,u))return}}}function ro(){var e=[],r=Ca?256:2048,a=function(g){var y=sr(g);return fi(y,0),y},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(g){return s&&g<s.length-s.l?s:(n(),s=a(Math.max(g+1,r)))},c=function(){return n(),qn(e)},u=function(g){n(),s=g,s.l==null&&(s.l=s.length),i(r)};return{next:i,push:u,end:c,_bufs:e}}function mr(e,r,a,s){var n=+r,i;if(!isNaN(n)){s||(s=Mf[n].p||(a||[]).length||0),i=1+(n>=128?1:0)+1,s>=128&&++i,s>=16384&&++i,s>=2097152&&++i;var c=e.next(i);n<=127?c.write_shift(1,n):(c.write_shift(1,(n&127)+128),c.write_shift(1,n>>7));for(var u=0;u!=4;++u)if(s>=128)c.write_shift(1,(s&127)+128),s>>=7;else{c.write_shift(1,s);break}s>0&&Sy(a)&&e.push(a)}}function mf(e,r,a){var s=Es(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 I_(e,r,a){var s=Es(e);return s.s=mf(s.s,r.s,a),s.e=mf(s.e,r.s,a),s}function gf(e,r){if(e.cRel&&e.c<0)for(e=Es(e);e.c<0;)e.c+=r>8?16384:256;if(e.rRel&&e.r<0)for(e=Es(e);e.r<0;)e.r+=r>8?1048576:r>5?65536:16384;var a=sa(e);return!e.cRel&&e.cRel!=null&&(a=zA(a)),!e.rRel&&e.rRel!=null&&(a=BA(a)),a}function Wp(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?"":"$")+zs(e.s.c)+":"+(e.e.cRel?"":"$")+zs(e.e.c):e.s.c==0&&!e.s.cRel&&e.e.c==(r.biff>=12?16383:255)&&!e.e.cRel?(e.s.rRel?"":"$")+nn(e.s.r)+":"+(e.e.rRel?"":"$")+nn(e.e.r):gf(e.s,r.biff)+":"+gf(e.e,r.biff)}function Cy(e){return parseInt(UA(e),10)-1}function nn(e){return""+(e+1)}function BA(e){return e.replace(/([A-Z]|^)(\d+)$/,"$1$$$2")}function UA(e){return e.replace(/\$(\d+)$/,"$1")}function Ey(e){for(var r=WA(e),a=0,s=0;s!==r.length;++s)a=26*a+r.charCodeAt(s)-64;return a-1}function zs(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 zA(e){return e.replace(/^([A-Z])/,"$$$1")}function WA(e){return e.replace(/^\$([A-Z])/,"$1")}function HA(e){return e.replace(/(\$?[A-Z]*)(\$?\d*)/,"$1,$2").split(",")}function Ws(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 sa(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 no(e){var r=e.indexOf(":");return r==-1?{s:Ws(e),e:Ws(e)}:{s:Ws(e.slice(0,r)),e:Ws(e.slice(r+1))}}function ba(e,r){return typeof r=="undefined"||typeof r=="number"?ba(e.s,e.e):(typeof e!="string"&&(e=sa(e)),typeof r!="string"&&(r=sa(r)),e==r?e:e+":"+r)}function $a(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 M_(e,r){var a=e.t=="d"&&r instanceof Date;if(e.z!=null)try{return e.w=Yo(e.z,a?Pn(r):r)}catch(s){}try{return e.w=Yo((e.XF||{}).numFmtId||(a?14:0),a?Pn(r):r)}catch(s){return""+r}}function uc(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"?gc[e.v]||e.v:r==null?M_(e,e.v):M_(e,r))}function Kc(e,r){var a=r&&r.sheet?r.sheet:"Sheet1",s={};return s[a]=e,{SheetNames:[a],Sheets:s}}function z3(e,r,a){var s=a||{},n=e?Array.isArray(e):s.dense,i=e||(n?[]:{}),c=0,u=0;if(i&&s.origin!=null){if(typeof s.origin=="number")c=s.origin;else{var h=typeof s.origin=="string"?Ws(s.origin):s.origin;c=h.r,u=h.c}i["!ref"]||(i["!ref"]="A1:A1")}var g={s:{c:1e7,r:1e7},e:{c:0,r:0}};if(i["!ref"]){var y=$a(i["!ref"]);g.s.c=y.s.c,g.s.r=y.s.r,g.e.c=Math.max(g.e.c,y.e.c),g.e.r=Math.max(g.e.r,y.e.r),c==-1&&(g.e.r=c=y.e.r+1)}for(var w=0;w!=r.length;++w)if(r[w]){if(!Array.isArray(r[w]))throw new Error("aoa_to_sheet expects an array of arrays");for(var E=0;E!=r[w].length;++E)if(typeof r[w][E]!="undefined"){var S={v:r[w][E]},A=c+w,C=u+E;if(g.s.r>A&&(g.s.r=A),g.s.c>C&&(g.s.c=C),g.e.r<A&&(g.e.r=A),g.e.c<C&&(g.e.c=C),r[w][E]&&typeof r[w][E]=="object"&&!Array.isArray(r[w][E])&&!(r[w][E]instanceof Date))S=r[w][E];else if(Array.isArray(S.v)&&(S.f=r[w][E][1],S.v=S.v[0]),S.v===null)if(S.f)S.t="n";else if(s.nullError)S.t="e",S.v=0;else if(s.sheetStubs)S.t="z";else continue;else typeof S.v=="number"?S.t="n":typeof S.v=="boolean"?S.t="b":S.v instanceof Date?(S.z=s.dateNF||aa[14],s.cellDates?(S.t="d",S.w=Yo(S.z,Pn(S.v))):(S.t="n",S.v=Pn(S.v),S.w=Yo(S.z,S.v))):S.t="s";if(n)i[A]||(i[A]=[]),i[A][C]&&i[A][C].z&&(S.z=i[A][C].z),i[A][C]=S;else{var O=sa({c:C,r:A});i[O]&&i[O].z&&(S.z=i[O].z),i[O]=S}}}return g.s.c<1e7&&(i["!ref"]=ba(g)),i}function su(e,r){return z3(null,e,r)}function $A(e){return e.read_shift(4,"i")}function dl(e,r){return r||(r=sr(4)),r.write_shift(4,e),r}function Ci(e){var r=e.read_shift(4);return r===0?"":e.read_shift(r,"dbcs")}function Xn(e,r){var a=!1;return r==null&&(a=!0,r=sr(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 VA(e){return{ich:e.read_shift(2),ifnt:e.read_shift(2)}}function GA(e,r){return r||(r=sr(4)),r.write_shift(2,0),r.write_shift(2,0),r}function Ty(e,r){var a=e.l,s=e.read_shift(1),n=Ci(e),i=[],c={t:n,h:n};if((s&1)!==0){for(var u=e.read_shift(4),h=0;h!=u;++h)i.push(VA(e));c.r=i}else c.r=[{ich:0,ifnt:0}];return e.l=a+r,c}function YA(e,r){var a=!1;return r==null&&(a=!0,r=sr(15+4*e.t.length)),r.write_shift(1,0),Xn(e.t,r),a?r.slice(0,r.l):r}var qA=Ty;function XA(e,r){var a=!1;return r==null&&(a=!0,r=sr(23+4*e.t.length)),r.write_shift(1,1),Xn(e.t,r),r.write_shift(4,1),GA({},r),a?r.slice(0,r.l):r}function Xo(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 Gd(e,r){return r==null&&(r=sr(8)),r.write_shift(-4,e.c),r.write_shift(3,e.iStyleRef||e.s),r.write_shift(1,0),r}function Yd(e){var r=e.read_shift(2);return r+=e.read_shift(1)<<16,e.l++,{c:-1,iStyleRef:r}}function qd(e,r){return r==null&&(r=sr(4)),r.write_shift(3,e.iStyleRef||e.s),r.write_shift(1,0),r}var ZA=Ci,W3=Xn;function Ay(e){var r=e.read_shift(4);return r===0||r===4294967295?"":e.read_shift(r,"dbcs")}function Qm(e,r){var a=!1;return r==null&&(a=!0,r=sr(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 KA=Ci,j1=Ay,Oy=Qm;function Dy(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?Jm([0,0,0,0,r[0]&252,r[1],r[2],r[3]],0):bd(r,0)>>2;return a?n/100:n}function H3(e,r){r==null&&(r=sr(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 $3(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 JA(e,r){return r||(r=sr(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 Xd=$3,nu=JA;function ji(e){if(e.length-e.l<8)throw"XLS Xnum Buffer underflow";return e.read_shift(8,"f")}function Bd(e,r){return(r||sr(8)).write_shift(8,e,"f")}function QA(e){var r={},a=e.read_shift(1),s=a>>>1,n=e.read_shift(1),i=e.read_shift(2,"i"),c=e.read_shift(1),u=e.read_shift(1),h=e.read_shift(1);switch(e.l++,s){case 0:r.auto=1;break;case 1:r.index=n;var g=Cd[n];g&&(r.rgb=Df(g));break;case 2:r.rgb=Df([c,u,h]);break;case 3:r.theme=n;break}return i!=0&&(r.tint=i>0?i/32767:i/32768),r}function eg(e,r){if(r||(r=sr(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 e7(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 t7(e,r){r||(r=sr(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}function V3(e,r){var a={2:"BITMAP",3:"METAFILEPICT",8:"DIB",14:"ENHMETAFILE"},s=e.read_shift(4);switch(s){case 0:return"";case 4294967295:case 4294967294:return a[e.read_shift(4)]||""}if(s>400)throw new Error("Unsupported Clipboard: "+s.toString(16));return e.l-=4,e.read_shift(0,r==1?"lpstr":"lpwstr")}function r7(e){return V3(e,1)}function a7(e){return V3(e,2)}var Ry=2,Qi=3,lm=11,P_=12,tg=19,cm=64,s7=65,n7=71,i7=4108,o7=4126,Gn=80,G3=81,l7=[Gn,G3],S1={1:{n:"CodePage",t:Ry},2:{n:"Category",t:Gn},3:{n:"PresentationFormat",t:Gn},4:{n:"ByteCount",t:Qi},5:{n:"LineCount",t:Qi},6:{n:"ParagraphCount",t:Qi},7:{n:"SlideCount",t:Qi},8:{n:"NoteCount",t:Qi},9:{n:"HiddenCount",t:Qi},10:{n:"MultimediaClipCount",t:Qi},11:{n:"ScaleCrop",t:lm},12:{n:"HeadingPairs",t:i7},13:{n:"TitlesOfParts",t:o7},14:{n:"Manager",t:Gn},15:{n:"Company",t:Gn},16:{n:"LinksUpToDate",t:lm},17:{n:"CharacterCount",t:Qi},19:{n:"SharedDoc",t:lm},22:{n:"HyperlinksChanged",t:lm},23:{n:"AppVersion",t:Qi,p:"version"},24:{n:"DigSig",t:s7},26:{n:"ContentType",t:Gn},27:{n:"ContentStatus",t:Gn},28:{n:"Language",t:Gn},29:{n:"Version",t:Gn},255:{},2147483648:{n:"Locale",t:tg},2147483651:{n:"Behavior",t:tg},1919054434:{}},C1={1:{n:"CodePage",t:Ry},2:{n:"Title",t:Gn},3:{n:"Subject",t:Gn},4:{n:"Author",t:Gn},5:{n:"Keywords",t:Gn},6:{n:"Comments",t:Gn},7:{n:"Template",t:Gn},8:{n:"LastAuthor",t:Gn},9:{n:"RevNumber",t:Gn},10:{n:"EditTime",t:cm},11:{n:"LastPrinted",t:cm},12:{n:"CreatedDate",t:cm},13:{n:"ModifiedDate",t:cm},14:{n:"PageCount",t:Qi},15:{n:"WordCount",t:Qi},16:{n:"CharCount",t:Qi},17:{n:"Thumbnail",t:n7},18:{n:"Application",t:Gn},19:{n:"DocSecurity",t:Qi},255:{},2147483648:{n:"Locale",t:tg},2147483651:{n:"Behavior",t:tg},1919054434:{}},L_={1:"US",2:"CA",3:"",7:"RU",20:"EG",30:"GR",31:"NL",32:"BE",33:"FR",34:"ES",36:"HU",39:"IT",41:"CH",43:"AT",44:"GB",45:"DK",46:"SE",47:"NO",48:"PL",49:"DE",52:"MX",55:"BR",61:"AU",64:"NZ",66:"TH",81:"JP",82:"KR",84:"VN",86:"CN",90:"TR",105:"JS",213:"DZ",216:"MA",218:"LY",351:"PT",354:"IS",358:"FI",420:"CZ",886:"TW",961:"LB",962:"JO",963:"SY",964:"IQ",965:"KW",966:"SA",971:"AE",972:"IL",974:"QA",981:"IR",65535:"US"},c7=[null,"solid","mediumGray","darkGray","lightGray","darkHorizontal","darkVertical","darkDown","darkUp","darkGrid","darkTrellis","lightHorizontal","lightVertical","lightDown","lightUp","lightGrid","lightTrellis","gray125","gray0625"];function d7(e){return e.map(function(r){return[r>>16&255,r>>8&255,r&255]})}var u7=d7([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]),Cd=Es(u7),gc={0:"#NULL!",7:"#DIV/0!",15:"#VALUE!",23:"#REF!",29:"#NAME?",36:"#NUM!",42:"#N/A",43:"#GETTING_DATA",255:"#WTF?"},Y3={"#NULL!":0,"#DIV/0!":7,"#VALUE!":15,"#REF!":23,"#NAME?":29,"#NUM!":36,"#N/A":42,"#GETTING_DATA":43,"#WTF?":255},E1={"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"},dm={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 Fy(){return{workbooks:[],sheets:[],charts:[],dialogs:[],macros:[],rels:[],strs:[],comments:[],threadedcomments:[],links:[],coreprops:[],extprops:[],custprops:[],themes:[],styles:[],calcchains:[],vba:[],drawings:[],metadata:[],people:[],TODO:[],xmlns:""}}function f7(e){var r=Fy();if(!e||!e.match)return r;var a={};if((e.match(Ti)||[]).forEach(function(s){var n=ia(s);switch(n[0].replace(_A,"<")){case"<?xml":break;case"<Types":r.xmlns=n["xmlns"+(n[0].match(/<(\w+):/)||["",""])[1]];break;case"<Default":a[n.Extension]=n.ContentType;break;case"<Override":r[E1[n.ContentType]]!==void 0&&r[E1[n.ContentType]].push(n.PartName);break}}),r.xmlns!==Fn.CT)throw new Error("Unknown Namespace: "+r.xmlns);return r.calcchain=r.calcchains.length>0?r.calcchains[0]:"",r.sst=r.strs.length>0?r.strs[0]:"",r.style=r.styles.length>0?r.styles[0]:"",r.defaults=a,delete r.calcchains,r}function q3(e,r){var a=fA(E1),s=[],n;s[s.length]=cn,s[s.length]=kr("Types",null,{xmlns:Fn.CT,"xmlns:xsd":Fn.xsd,"xmlns:xsi":Fn.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(h){return kr("Default",null,{Extension:h[0],ContentType:h[1]})}));var i=function(h){e[h]&&e[h].length>0&&(n=e[h][0],s[s.length]=kr("Override",null,{PartName:(n[0]=="/"?"":"/")+n,ContentType:dm[h][r.bookType]||dm[h].xlsx}))},c=function(h){(e[h]||[]).forEach(function(g){s[s.length]=kr("Override",null,{PartName:(g[0]=="/"?"":"/")+g,ContentType:dm[h][r.bookType]||dm[h].xlsx})})},u=function(h){(e[h]||[]).forEach(function(g){s[s.length]=kr("Override",null,{PartName:(g[0]=="/"?"":"/")+g,ContentType:a[h][0]})})};return i("workbooks"),c("sheets"),c("charts"),u("themes"),["strs","styles"].forEach(i),["coreprops","extprops","custprops"].forEach(u),u("vba"),u("comments"),u("threadedcomments"),u("drawings"),c("metadata"),u("people"),s.length>2&&(s[s.length]="</Types>",s[1]=s[1].replace("/>",">")),s.join("")}var Aa={WB:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",SHEET:"http://sheetjs.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",XLINK:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink",CXML:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml",CXMLP:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps",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",CHART:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",CHARTEX:"http://schemas.microsoft.com/office/2014/relationships/chartEx",CS:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet",WS:["http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet","http://purl.oclc.org/ooxml/officeDocument/relationships/worksheet"],DS:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/dialogsheet",MS:"http://schemas.microsoft.com/office/2006/relationships/xlMacrosheet",IMG:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",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 Of(e){var r=e.lastIndexOf("/");return e.slice(0,r+1)+"_rels/"+e.slice(r+1)+".rels"}function xf(e,r){var a={"!id":{}};if(!e)return a;r.charAt(0)!=="/"&&(r="/"+r);var s={};return(e.match(Ti)||[]).forEach(function(n){var i=ia(n);if(i[0]==="<Relationship"){var c={};c.Type=i.Type,c.Target=i.Target,c.Id=i.Id,i.TargetMode&&(c.TargetMode=i.TargetMode);var u=i.TargetMode==="External"?i.Target:nf(i.Target,r);a[u]=c,s[i.Id]=c}}),a["!id"]=s,a}function H0(e){var r=[cn,kr("Relationships",null,{xmlns:Fn.RELS})];return Qs(e["!id"]).forEach(function(a){r[r.length]=kr("Relationship",null,e["!id"][a])}),r.length>2&&(r[r.length]="</Relationships>",r[1]=r[1].replace("/>",">")),r.join("")}function os(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,[Aa.HLINK,Aa.XPATH,Aa.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}var h7="application/vnd.oasis.opendocument.spreadsheet";function m7(e,r){for(var a=Ny(e),s,n;s=Af.exec(a);)switch(s[3]){case"manifest":break;case"file-entry":if(n=ia(s[0],!1),n.path=="/"&&n.type!==h7)throw new Error("This OpenDocument is not a spreadsheet");break;case"encryption-data":case"algorithm":case"start-key-generation":case"key-derivation":throw new Error("Unsupported ODS Encryption");default:if(r&&r.WTF)throw s}}function g7(e){var r=[cn];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 B_(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 x7(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 p7(e){var r=[cn];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(B_(e[a][0],e[a][1])),r.push(x7("",e[a][0]));return r.push(B_("","Document","pkg")),r.push("</rdf:RDF>"),r.join("")}function X3(){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 '+Ym.version+"</meta:generator></office:meta></office:document-meta>"}var Ho=[["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"]],y7=(function(){for(var e=new Array(Ho.length),r=0;r<Ho.length;++r){var a=Ho[r],s="(?:"+a[0].slice(0,a[0].indexOf(":"))+":)"+a[0].slice(a[0].indexOf(":")+1);e[r]=new RegExp("<"+s+"[^>]*>([\\s\\S]*?)</"+s+">")}return e})();function Z3(e){var r={};e=ms(e);for(var a=0;a<Ho.length;++a){var s=Ho[a],n=e.match(y7[a]);n!=null&&n.length>0&&(r[s[1]]=Ha(n[1])),s[2]==="date"&&r[s[1]]&&(r[s[1]]=Cs(r[s[1]]))}return r}function Hp(e,r,a,s,n){n[e]!=null||r==null||r===""||(n[e]=r,r=ls(r),s[s.length]=a?kr(e,r,a):hi(e,r))}function K3(e,r){var a=r||{},s=[cn,kr("cp:coreProperties",null,{"xmlns:cp":Fn.CORE_PROPS,"xmlns:dc":Fn.dc,"xmlns:dcterms":Fn.dcterms,"xmlns:dcmitype":Fn.dcmitype,"xmlns:xsi":Fn.xsi})],n={};if(!e&&!a.Props)return s.join("");e&&(e.CreatedDate!=null&&Hp("dcterms:created",typeof e.CreatedDate=="string"?e.CreatedDate:N1(e.CreatedDate,a.WTF),{"xsi:type":"dcterms:W3CDTF"},s,n),e.ModifiedDate!=null&&Hp("dcterms:modified",typeof e.ModifiedDate=="string"?e.ModifiedDate:N1(e.ModifiedDate,a.WTF),{"xsi:type":"dcterms:W3CDTF"},s,n));for(var i=0;i!=Ho.length;++i){var c=Ho[i],u=a.Props&&a.Props[c[1]]!=null?a.Props[c[1]]:e?e[c[1]]:null;u===!0?u="1":u===!1?u="0":typeof u=="number"&&(u=String(u)),u!=null&&Hp(c[0],u,null,s,n)}return s.length>2&&(s[s.length]="</cp:coreProperties>",s[1]=s[1].replace("/>",">")),s.join("")}var Ed=[["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"]],J3=["Worksheets","SheetNames","NamedRanges","DefinedNames","Chartsheets","ChartNames"];function Q3(e,r,a,s){var n=[];if(typeof e=="string")n=T_(e,s);else for(var i=0;i<e.length;++i)n=n.concat(e[i].map(function(y){return{v:y}}));var c=typeof r=="string"?T_(r,s).map(function(y){return y.v}):r,u=0,h=0;if(c.length>0)for(var g=0;g!==n.length;g+=2){switch(h=+n[g+1].v,n[g].v){case"Worksheets":case"工作表":case"Листы":case"أوراق العمل":case"ワークシート":case"גליונות עבודה":case"Arbeitsblätter":case"Çalışma Sayfaları":case"Feuilles de calcul":case"Fogli di lavoro":case"Folhas de cálculo":case"Planilhas":case"Regneark":case"Hojas de cálculo":case"Werkbladen":a.Worksheets=h,a.SheetNames=c.slice(u,u+h);break;case"Named Ranges":case"Rangos con nombre":case"名前付き一覧":case"Benannte Bereiche":case"Navngivne områder":a.NamedRanges=h,a.DefinedNames=c.slice(u,u+h);break;case"Charts":case"Diagramme":a.Chartsheets=h,a.ChartNames=c.slice(u,u+h);break}u+=h}}function b7(e,r,a){var s={};return r||(r={}),e=ms(e),Ed.forEach(function(n){var i=(e.match(Ef(n[0]))||[])[1];switch(n[2]){case"string":i&&(r[n[1]]=Ha(i));break;case"bool":r[n[1]]=i==="true";break;case"raw":var c=e.match(new RegExp("<"+n[0]+"[^>]*>([\\s\\S]*?)</"+n[0]+">"));c&&c.length>0&&(s[n[1]]=c[1]);break}}),s.HeadingPairs&&s.TitlesOfParts&&Q3(s.HeadingPairs,s.TitlesOfParts,r,a),r}function eN(e){var r=[],a=kr;return e||(e={}),e.Application="SheetJS",r[r.length]=cn,r[r.length]=kr("Properties",null,{xmlns:Fn.EXT_PROPS,"xmlns:vt":Fn.vt}),Ed.forEach(function(s){if(e[s[1]]!==void 0){var n;switch(s[2]){case"string":n=ls(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>"+ls(s)+"</vt:lpstr>"}).join(""),{size:e.Worksheets,baseType:"lpstr"})),r.length>2&&(r[r.length]="</Properties>",r[1]=r[1].replace("/>",">")),r.join("")}var v7=/<[^>]+>[^<]*/g;function w7(e,r){var a={},s="",n=e.match(v7);if(n)for(var i=0;i!=n.length;++i){var c=n[i],u=ia(c);switch(u[0]){case"<?xml":break;case"<Properties":break;case"<property":s=Ha(u.name);break;case"</property>":s=null;break;default:if(c.indexOf("<vt:")===0){var h=c.split(">"),g=h[0].slice(4),y=h[1];switch(g){case"lpstr":case"bstr":case"lpwstr":a[s]=Ha(y);break;case"bool":a[s]=Ss(y);break;case"i1":case"i2":case"i4":case"i8":case"int":case"uint":a[s]=parseInt(y,10);break;case"r4":case"r8":case"decimal":a[s]=parseFloat(y);break;case"filetime":case"date":a[s]=Cs(y);break;case"cy":case"error":a[s]=Ha(y);break;default:if(g.slice(-1)=="/")break;r.WTF&&typeof console!="undefined"&&console.warn("Unexpected",c,g,h)}}else if(c.slice(0,2)!=="</"){if(r.WTF)throw new Error(c)}}}return a}function tN(e){var r=[cn,kr("Properties",null,{xmlns:Fn.CUST_PROPS,"xmlns:vt":Fn.vt})];if(!e)return r.join("");var a=1;return Qs(e).forEach(function(n){++a,r[r.length]=kr("property",AA(e[n]),{fmtid:"{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",pid:a,name:ls(n)})}),r.length>2&&(r[r.length]="</Properties>",r[1]=r[1].replace("/>",">")),r.join("")}var T1={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"},$p;function _7(e,r,a){$p||($p=bg(T1)),r=$p[r]||r,e[r]=a}function k7(e,r){var a=[];return Qs(T1).map(function(s){for(var n=0;n<Ho.length;++n)if(Ho[n][1]==s)return Ho[n];for(n=0;n<Ed.length;++n)if(Ed[n][1]==s)return Ed[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(hi(T1[s[1]]||s[1],n))}}),kr("DocumentProperties",a.join(""),{xmlns:yo.o})}function N7(e,r){var a=["Worksheets","SheetNames"],s="CustomDocumentProperties",n=[];return e&&Qs(e).forEach(function(i){if(Object.prototype.hasOwnProperty.call(e,i)){for(var c=0;c<Ho.length;++c)if(i==Ho[c][1])return;for(c=0;c<Ed.length;++c)if(i==Ed[c][1])return;for(c=0;c<a.length;++c)if(i==a[c])return;var u=e[i],h="string";typeof u=="number"?(h="float",u=String(u)):u===!0||u===!1?(h="boolean",u=u?"1":"0"):u=String(u),n.push(kr(j_(i),u,{"dt:dt":h}))}}),r&&Qs(r).forEach(function(i){if(Object.prototype.hasOwnProperty.call(r,i)&&!(e&&Object.prototype.hasOwnProperty.call(e,i))){var c=r[i],u="string";typeof c=="number"?(u="float",c=String(c)):c===!0||c===!1?(u="boolean",c=c?"1":"0"):c instanceof Date?(u="dateTime.tz",c=c.toISOString()):c=String(c),n.push(kr(j_(i),c,{"dt:dt":u}))}}),"<"+s+' xmlns="'+yo.o+'">'+n.join("")+"</"+s+">"}function Iy(e){var r=e.read_shift(4),a=e.read_shift(4);return new Date((a/1e7*Math.pow(2,32)+r/1e7-11644473600)*1e3).toISOString().replace(/\.000/,"")}function j7(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 c=sr(8);return c.write_shift(4,s),c.write_shift(4,n),c}function rN(e,r,a){var s=e.l,n=e.read_shift(0,"lpstr-cp");if(a)for(;e.l-s&3;)++e.l;return n}function aN(e,r,a){var s=e.read_shift(0,"lpwstr");return s}function sN(e,r,a){return r===31?aN(e):rN(e,r,a)}function A1(e,r,a){return sN(e,r,a===!1?0:4)}function S7(e,r){if(!r)throw new Error("VtUnalignedString must have positive length");return sN(e,r,0)}function C7(e){for(var r=e.read_shift(4),a=[],s=0;s!=r;++s){var n=e.l;a[s]=e.read_shift(0,"lpwstr").replace(Bi,""),e.l-n&2&&(e.l+=2)}return a}function E7(e){for(var r=e.read_shift(4),a=[],s=0;s!=r;++s)a[s]=e.read_shift(0,"lpstr-cp").replace(Bi,"");return a}function T7(e){var r=e.l,a=rg(e,G3);e[e.l]==0&&e[e.l+1]==0&&e.l-r&2&&(e.l+=2);var s=rg(e,Qi);return[a,s]}function A7(e){for(var r=e.read_shift(4),a=[],s=0;s<r/2;++s)a.push(T7(e));return a}function U_(e,r){for(var a=e.read_shift(4),s={},n=0;n!=a;++n){var i=e.read_shift(4),c=e.read_shift(4);s[i]=e.read_shift(c,r===1200?"utf16le":"utf8").replace(Bi,"").replace(sf,"!"),r===1200&&c%2&&(e.l+=2)}return e.l&3&&(e.l=e.l>>3<<2),s}function nN(e){var r=e.read_shift(4),a=e.slice(e.l,e.l+r);return e.l+=r,(r&3)>0&&(e.l+=4-(r&3)&3),a}function O7(e){var r={};return r.Size=e.read_shift(4),e.l+=r.Size+3-(r.Size-1)%4,r}function rg(e,r,a){var s=e.read_shift(2),n,i=a||{};if(e.l+=2,r!==P_&&s!==r&&l7.indexOf(r)===-1&&!((r&65534)==4126&&(s&65534)==4126))throw new Error("Expected type "+r+" saw "+s);switch(r===P_?s:r){case 2:return n=e.read_shift(2,"i"),i.raw||(e.l+=2),n;case 3:return n=e.read_shift(4,"i"),n;case 11:return e.read_shift(4)!==0;case 19:return n=e.read_shift(4),n;case 30:return rN(e,s,4).replace(Bi,"");case 31:return aN(e);case 64:return Iy(e);case 65:return nN(e);case 71:return O7(e);case 80:return A1(e,s,!i.raw).replace(Bi,"");case 81:return S7(e,s).replace(Bi,"");case 4108:return A7(e);case 4126:case 4127:return s==4127?C7(e):E7(e);default:throw new Error("TypedPropertyValue unrecognized type "+r+" "+s)}}function z_(e,r){var a=sr(4),s=sr(4);switch(a.write_shift(4,e==80?31:e),e){case 3:s.write_shift(-4,r);break;case 5:s=sr(8),s.write_shift(8,r,"f");break;case 11:s.write_shift(4,r?1:0);break;case 64:s=j7(r);break;case 31:case 80:for(s=sr(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])}function W_(e,r){var a=e.l,s=e.read_shift(4),n=e.read_shift(4),i=[],c=0,u=0,h=-1,g={};for(c=0;c!=n;++c){var y=e.read_shift(4),w=e.read_shift(4);i[c]=[y,w+a]}i.sort(function(R,F){return R[1]-F[1]});var E={};for(c=0;c!=n;++c){if(e.l!==i[c][1]){var S=!0;if(c>0&&r)switch(r[i[c-1][0]].t){case 2:e.l+2===i[c][1]&&(e.l+=2,S=!1);break;case 80:e.l<=i[c][1]&&(e.l=i[c][1],S=!1);break;case 4108:e.l<=i[c][1]&&(e.l=i[c][1],S=!1);break}if((!r||c==0)&&e.l<=i[c][1]&&(S=!1,e.l=i[c][1]),S)throw new Error("Read Error: Expected address "+i[c][1]+" at "+e.l+" :"+c)}if(r){var A=r[i[c][0]];if(E[A.n]=rg(e,A.t,{raw:!0}),A.p==="version"&&(E[A.n]=String(E[A.n]>>16)+"."+("0000"+String(E[A.n]&65535)).slice(-4)),A.n=="CodePage")switch(E[A.n]){case 0:E[A.n]=1252;case 874:case 932:case 936:case 949:case 950:case 1250:case 1251:case 1253:case 1254:case 1255:case 1256:case 1257:case 1258:case 1e4:case 1200:case 1201:case 1252:case 65e3:case-536:case 65001:case-535:ol(u=E[A.n]>>>0&65535);break;default:throw new Error("Unsupported CodePage: "+E[A.n])}}else if(i[c][0]===1){if(u=E.CodePage=rg(e,Ry),ol(u),h!==-1){var C=e.l;e.l=i[h][1],g=U_(e,u),e.l=C}}else if(i[c][0]===0){if(u===0){h=c,e.l=i[c+1][1];continue}g=U_(e,u)}else{var O=g[i[c][0]],M;switch(e[e.l]){case 65:e.l+=4,M=nN(e);break;case 30:e.l+=4,M=A1(e,e[e.l-4]).replace(/\u0000+$/,"");break;case 31:e.l+=4,M=A1(e,e[e.l-4]).replace(/\u0000+$/,"");break;case 3:e.l+=4,M=e.read_shift(4,"i");break;case 19:e.l+=4,M=e.read_shift(4);break;case 5:e.l+=4,M=e.read_shift(8,"f");break;case 11:e.l+=4,M=sn(e,4);break;case 64:e.l+=4,M=Cs(Iy(e));break;default:throw new Error("unparsed value: "+e[e.l])}E[O]=M}}return e.l=a+s,E}var iN=["CodePage","Thumbnail","_PID_LINKBASE","_PID_HLINKS","SystemIdentifier","FMTID"];function D7(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 H_(e,r,a){var s=sr(8),n=[],i=[],c=8,u=0,h=sr(8),g=sr(8);if(h.write_shift(4,2),h.write_shift(4,1200),g.write_shift(4,1),i.push(h),n.push(g),c+=8+h.length,!r){g=sr(8),g.write_shift(4,0),n.unshift(g);var y=[sr(4)];for(y[0].write_shift(4,e.length),u=0;u<e.length;++u){var w=e[u][0];for(h=sr(8+2*(w.length+1)+(w.length%2?0:2)),h.write_shift(4,u+2),h.write_shift(4,w.length+1),h.write_shift(0,w,"dbcs");h.l!=h.length;)h.write_shift(1,0);y.push(h)}h=qn(y),i.unshift(h),c+=8+h.length}for(u=0;u<e.length;++u)if(!(r&&!r[e[u][0]])&&!(iN.indexOf(e[u][0])>-1||J3.indexOf(e[u][0])>-1)&&e[u][1]!=null){var E=e[u][1],S=0;if(r){S=+r[e[u][0]];var A=a[S];if(A.p=="version"&&typeof E=="string"){var C=E.split(".");E=(+C[0]<<16)+(+C[1]||0)}h=z_(A.t,E)}else{var O=D7(E);O==-1&&(O=31,E=String(E)),h=z_(O,E)}i.push(h),g=sr(8),g.write_shift(4,r?S:2+u),n.push(g),c+=8+h.length}var M=8*(i.length+1);for(u=0;u<i.length;++u)n[u].write_shift(4,M),M+=i[u].length;return s.write_shift(4,c),s.write_shift(4,i.length),qn([s].concat(n).concat(i))}function $_(e,r,a){var s=e.content;if(!s)return{};fi(s,0);var n,i,c,u,h=0;s.chk("feff","Byte Order: "),s.read_shift(2);var g=s.read_shift(4),y=s.read_shift(16);if(y!==Zr.utils.consts.HEADER_CLSID&&y!==a)throw new Error("Bad PropertySet CLSID "+y);if(n=s.read_shift(4),n!==1&&n!==2)throw new Error("Unrecognized #Sets: "+n);if(i=s.read_shift(16),u=s.read_shift(4),n===1&&u!==s.l)throw new Error("Length mismatch: "+u+" !== "+s.l);n===2&&(c=s.read_shift(16),h=s.read_shift(4));var w=W_(s,r),E={SystemIdentifier:g};for(var S in w)E[S]=w[S];if(E.FMTID=i,n===1)return E;if(h-s.l==2&&(s.l+=2),s.l!==h)throw new Error("Length mismatch 2: "+s.l+" !== "+h);var A;try{A=W_(s,null)}catch(C){}for(S in A)E[S]=A[S];return E.FMTID=[i,c],E}function V_(e,r,a,s,n,i){var c=sr(n?68:48),u=[c];c.write_shift(2,65534),c.write_shift(2,0),c.write_shift(4,842412599),c.write_shift(16,Zr.utils.consts.HEADER_CLSID,"hex"),c.write_shift(4,n?2:1),c.write_shift(16,r,"hex"),c.write_shift(4,n?68:48);var h=H_(e,a,s);if(u.push(h),n){var g=H_(n,null,null);c.write_shift(16,i,"hex"),c.write_shift(4,68+h.length),u.push(g)}return qn(u)}function zc(e,r){return e.read_shift(r),null}function R7(e,r){r||(r=sr(e));for(var a=0;a<e;++a)r.write_shift(1,0);return r}function F7(e,r,a){for(var s=[],n=e.l+r;e.l<n;)s.push(a(e,n-e.l));if(n!==e.l)throw new Error("Slurp error");return s}function sn(e,r){return e.read_shift(r)===1}function Pi(e,r){return r||(r=sr(2)),r.write_shift(2,+!!e),r}function Nn(e){return e.read_shift(2,"u")}function zo(e,r){return r||(r=sr(2)),r.write_shift(2,e),r}function oN(e,r){return F7(e,r,Nn)}function I7(e){var r=e.read_shift(1),a=e.read_shift(1);return a===1?r:r===1}function lN(e,r,a){return a||(a=sr(2)),a.write_shift(1,r=="e"?+e:+!!e),a.write_shift(1,r=="e"?1:0),a}function Gf(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 c=s?e.read_shift(s,n):"";return c}function M7(e){var r=e.read_shift(2),a=e.read_shift(1),s=a&4,n=a&8,i=1+(a&1),c=0,u,h={};n&&(c=e.read_shift(2)),s&&(u=e.read_shift(4));var g=i==2?"dbcs-cont":"sbcs-cont",y=r===0?"":e.read_shift(r,g);return n&&(e.l+=4*c),s&&(e.l+=u),h.t=y,n||(h.raw="<t>"+h.t+"</t>",h.r=h.t),h}function P7(e){var r=e.t||"",a=sr(3);a.write_shift(2,r.length),a.write_shift(1,1);var s=sr(2*r.length);s.write_shift(2*r.length,r,"utf16le");var n=[a,s];return qn(n)}function Ud(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 Yf(e,r,a){var s=e.read_shift(a&&a.biff==2?1:2);return s===0?(e.l++,""):Ud(e,s,a)}function Zd(e,r,a){if(a.biff>5)return Yf(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 cN(e,r,a){return a||(a=sr(3+2*e.length)),a.write_shift(2,e.length),a.write_shift(1,1),a.write_shift(31,e,"utf16le"),a}function L7(e){var r=e.read_shift(1);e.l++;var a=e.read_shift(2);return e.l+=2,[r,a]}function B7(e){var r=e.read_shift(4),a=e.l,s=!1;r>24&&(e.l+=r-24,e.read_shift(16)==="795881f43b1d7f48af2c825dc4852763"&&(s=!0),e.l=a);var n=e.read_shift((s?r-24:r)>>1,"utf16le").replace(Bi,"");return s&&(e.l+=24),n}function U7(e){for(var r=e.read_shift(2),a="";r-- >0;)a+="../";var s=e.read_shift(0,"lpstr-ansi");if(e.l+=2,e.read_shift(2)!=57005)throw new Error("Bad FileMoniker");var n=e.read_shift(4);if(n===0)return a+s.replace(/\\/g,"/");var i=e.read_shift(4);if(e.read_shift(2)!=3)throw new Error("Bad FileMoniker");var c=e.read_shift(i>>1,"utf16le").replace(Bi,"");return a+c}function z7(e,r){var a=e.read_shift(16);switch(a){case"e0c9ea79f9bace118c8200aa004ba90b":return B7(e);case"0303000000000000c000000000000046":return U7(e);default:throw new Error("Unsupported Moniker "+a)}}function um(e){var r=e.read_shift(4),a=r>0?e.read_shift(r,"utf16le").replace(Bi,""):"";return a}function G_(e,r){r||(r=sr(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 W7(e,r){var a=e.l+r,s=e.read_shift(4);if(s!==2)throw new Error("Unrecognized streamVersion: "+s);var n=e.read_shift(2);e.l+=2;var i,c,u,h,g="",y,w;n&16&&(i=um(e,a-e.l)),n&128&&(c=um(e,a-e.l)),(n&257)===257&&(u=um(e,a-e.l)),(n&257)===1&&(h=z7(e,a-e.l)),n&8&&(g=um(e,a-e.l)),n&32&&(y=e.read_shift(16)),n&64&&(w=Iy(e)),e.l=a;var E=c||u||h||"";E&&g&&(E+="#"+g),E||(E="#"+g),n&2&&E.charAt(0)=="/"&&E.charAt(1)!="/"&&(E="file://"+E);var S={Target:E};return y&&(S.guid=y),w&&(S.time=w),i&&(S.Tooltip=i),S}function H7(e){var r=sr(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 c=[8,6815827,6619237,4849780,83];for(a=0;a<c.length;++a)r.write_shift(4,c[a]);if(i==28)s=s.slice(1),G_(s,r);else if(i&2){for(c="e0 c9 ea 79 f9 ba ce 11 8c 82 00 aa 00 4b a9 0b".split(" "),a=0;a<c.length;++a)r.write_shift(1,parseInt(c[a],16));var u=n>-1?s.slice(0,n):s;for(r.write_shift(4,2*(u.length+1)),a=0;a<u.length;++a)r.write_shift(2,u.charCodeAt(a));r.write_shift(2,0),i&8&&G_(n>-1?s.slice(n+1):"",r)}else{for(c="03 03 00 00 00 00 00 00 c0 00 00 00 00 00 00 46".split(" "),a=0;a<c.length;++a)r.write_shift(1,parseInt(c[a],16));for(var h=0;s.slice(h*3,h*3+3)=="../"||s.slice(h*3,h*3+3)=="..\\";)++h;for(r.write_shift(2,h),r.write_shift(4,s.length-3*h+1),a=0;a<s.length-3*h;++a)r.write_shift(1,s.charCodeAt(a+3*h)&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 dN(e){var r=e.read_shift(1),a=e.read_shift(1),s=e.read_shift(1),n=e.read_shift(1);return[r,a,s,n]}function uN(e,r){var a=dN(e);return a[3]=0,a}function Pl(e){var r=e.read_shift(2),a=e.read_shift(2),s=e.read_shift(2);return{r,c:a,ixfe:s}}function zd(e,r,a,s){return s||(s=sr(6)),s.write_shift(2,e),s.write_shift(2,r),s.write_shift(2,a||0),s}function $7(e){var r=e.read_shift(2),a=e.read_shift(2);return e.l+=8,{type:r,flags:a}}function V7(e,r,a){return r===0?"":Zd(e,r,a)}function G7(e,r,a){var s=a.biff>8?4:2,n=e.read_shift(s),i=e.read_shift(s,"i"),c=e.read_shift(s,"i");return[n,i,c]}function fN(e){var r=e.read_shift(2),a=Dy(e);return[r,a]}function Y7(e,r,a){e.l+=4,r-=4;var s=e.l+r,n=Gf(e,r,a),i=e.read_shift(2);if(s-=e.l,i!==s)throw new Error("Malformed AddinUdf: padding = "+s+" != "+i);return e.l+=i,n}function _g(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 hN(e,r){return r||(r=sr(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 mN(e){var r=e.read_shift(2),a=e.read_shift(2),s=e.read_shift(1),n=e.read_shift(1);return{s:{c:s,r},e:{c:n,r:a}}}var q7=mN;function gN(e){e.l+=4;var r=e.read_shift(2),a=e.read_shift(2),s=e.read_shift(2);return e.l+=12,[a,r,s]}function X7(e){var r={};return e.l+=4,e.l+=16,r.fSharedNote=e.read_shift(2),e.l+=4,r}function Z7(e){var r={};return e.l+=4,e.cf=e.read_shift(2),r}function wi(e){e.l+=2,e.l+=e.read_shift(2)}var K7={0:wi,4:wi,5:wi,6:wi,7:Z7,8:wi,9:wi,10:wi,11:wi,12:wi,13:X7,14:wi,15:wi,16:wi,17:wi,18:wi,19:wi,20:wi,21:gN};function J7(e,r){for(var a=e.l+r,s=[];e.l<a;){var n=e.read_shift(2);e.l-=2;try{s.push(K7[n](e,a-e.l))}catch(i){return e.l=a,s}}return e.l!=a&&(e.l=a),s}function fm(e,r){var a={BIFFVer:0,dt:0};switch(a.BIFFVer=e.read_shift(2),r-=2,r>=2&&(a.dt=e.read_shift(2),e.l-=2),a.BIFFVer){case 1536:case 1280:case 1024:case 768:case 512:case 2:case 7:break;default:if(r>6)throw new Error("Unexpected BIFF Ver "+a.BIFFVer)}return e.read_shift(r),a}function My(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=sr(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 Q7(e,r){return r===0||e.read_shift(2),1200}function e9(e,r,a){if(a.enc)return e.l+=r,"";var s=e.l,n=Zd(e,0,a);return e.read_shift(r+s-e.l),n}function t9(e,r){var a=!r||r.biff==8,s=sr(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 r9(e,r,a){var s=a&&a.biff==8||r==2?e.read_shift(2):(e.l+=r,0);return{fDialog:s&16,fBelow:s&64,fRight:s&128}}function a9(e,r,a){var s=e.read_shift(4),n=e.read_shift(1)&3,i=e.read_shift(1);switch(i){case 0:i="Worksheet";break;case 1:i="Macrosheet";break;case 2:i="Chartsheet";break;case 6:i="VBAModule";break}var c=Gf(e,0,a);return c.length===0&&(c="Sheet1"),{pos:s,hs:n,dt:i,name:c}}function s9(e,r){var a=!r||r.biff>=8?2:1,s=sr(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 n9(e,r){for(var a=e.l+r,s=e.read_shift(4),n=e.read_shift(4),i=[],c=0;c!=n&&e.l<a;++c)i.push(M7(e));return i.Count=s,i.Unique=n,i}function i9(e,r){var a=sr(8);a.write_shift(4,e.Count),a.write_shift(4,e.Unique);for(var s=[],n=0;n<e.length;++n)s[n]=P7(e[n]);var i=qn([a].concat(s));return i.parts=[a.length].concat(s.map(function(c){return c.length})),i}function o9(e,r){var a={};return a.dsst=e.read_shift(2),e.l+=r-2,a}function l9(e){var r={};r.r=e.read_shift(2),r.c=e.read_shift(2),r.cnt=e.read_shift(2)-r.c;var a=e.read_shift(2);e.l+=4;var s=e.read_shift(1);return e.l+=3,s&7&&(r.level=s&7),s&32&&(r.hidden=!0),s&64&&(r.hpt=a/20),r}function c9(e){var r=$7(e);if(r.type!=2211)throw new Error("Invalid Future Record "+r.type);var a=e.read_shift(4);return a!==0}function d9(e){return e.read_shift(2),e.read_shift(4)}function Y_(e,r,a){var s=0;a&&a.biff==2||(s=e.read_shift(2));var n=e.read_shift(2);a&&a.biff==2&&(s=1-(n>>15),n&=32767);var i={Unsynced:s&1,DyZero:(s&2)>>1,ExAsc:(s&4)>>2,ExDsc:(s&8)>>3};return[i,n]}function u9(e){var r=e.read_shift(2),a=e.read_shift(2),s=e.read_shift(2),n=e.read_shift(2),i=e.read_shift(2),c=e.read_shift(2),u=e.read_shift(2),h=e.read_shift(2),g=e.read_shift(2);return{Pos:[r,a],Dim:[s,n],Flags:i,CurTab:c,FirstTab:u,Selected:h,TabRatio:g}}function f9(){var e=sr(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 h9(e,r,a){if(a&&a.biff>=2&&a.biff<5)return{};var s=e.read_shift(2);return{RTL:s&64}}function m9(e){var r=sr(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 g9(){}function x9(e,r,a){var s={dyHeight:e.read_shift(2),fl:e.read_shift(2)};switch(a&&a.biff||8){case 2:break;case 3:case 4:e.l+=2;break;default:e.l+=10;break}return s.name=Gf(e,0,a),s}function p9(e,r){var a=e.name||"Arial",s=r&&r.biff==5,n=s?15+a.length:16+2*a.length,i=sr(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 y9(e){var r=Pl(e);return r.isst=e.read_shift(4),r}function b9(e,r,a,s){var n=sr(10);return zd(e,r,s,n),n.write_shift(4,a),n}function v9(e,r,a){a.biffguess&&a.biff==2&&(a.biff=5);var s=e.l+r,n=Pl(e);a.biff==2&&e.l++;var i=Yf(e,s-e.l,a);return n.val=i,n}function w9(e,r,a,s,n){var i=!n||n.biff==8,c=sr(8+ +i+(1+i)*a.length);return zd(e,r,s,c),c.write_shift(2,a.length),i&&c.write_shift(1,1),c.write_shift((1+i)*a.length,a,i?"utf16le":"sbcs"),c}function _9(e,r,a){var s=e.read_shift(2),n=Zd(e,0,a);return[s,n]}function k9(e,r,a,s){var n=a&&a.biff==5;s||(s=sr(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}var N9=Zd;function q_(e,r,a){var s=e.l+r,n=a.biff==8||!a.biff?4:2,i=e.read_shift(n),c=e.read_shift(n),u=e.read_shift(2),h=e.read_shift(2);return e.l=s,{s:{r:i,c:u},e:{r:c,c:h}}}function j9(e,r){var a=r.biff==8||!r.biff?4:2,s=sr(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 S9(e){var r=e.read_shift(2),a=e.read_shift(2),s=fN(e);return{r,c:a,ixfe:s[0],rknum:s[1]}}function C9(e,r){for(var a=e.l+r-2,s=e.read_shift(2),n=e.read_shift(2),i=[];e.l<a;)i.push(fN(e));if(e.l!==a)throw new Error("MulRK read error");var c=e.read_shift(2);if(i.length!=c-n+1)throw new Error("MulRK length mismatch");return{r:s,c:n,C:c,rkrec:i}}function E9(e,r){for(var a=e.l+r-2,s=e.read_shift(2),n=e.read_shift(2),i=[];e.l<a;)i.push(e.read_shift(2));if(e.l!==a)throw new Error("MulBlank read error");var c=e.read_shift(2);if(i.length!=c-n+1)throw new Error("MulBlank length mismatch");return{r:s,c:n,C:c,ixfe:i}}function T9(e,r,a,s){var n={},i=e.read_shift(4),c=e.read_shift(4),u=e.read_shift(4),h=e.read_shift(2);return n.patternType=c7[u>>26],s.cellStyles&&(n.alc=i&7,n.fWrap=i>>3&1,n.alcV=i>>4&7,n.fJustLast=i>>7&1,n.trot=i>>8&255,n.cIndent=i>>16&15,n.fShrinkToFit=i>>20&1,n.iReadOrder=i>>22&2,n.fAtrNum=i>>26&1,n.fAtrFnt=i>>27&1,n.fAtrAlc=i>>28&1,n.fAtrBdr=i>>29&1,n.fAtrPat=i>>30&1,n.fAtrProt=i>>31&1,n.dgLeft=c&15,n.dgRight=c>>4&15,n.dgTop=c>>8&15,n.dgBottom=c>>12&15,n.icvLeft=c>>16&127,n.icvRight=c>>23&127,n.grbitDiag=c>>30&3,n.icvTop=u&127,n.icvBottom=u>>7&127,n.icvDiag=u>>14&127,n.dgDiag=u>>21&15,n.icvFore=h&127,n.icvBack=h>>7&127,n.fsxButton=h>>14&1),n}function A9(e,r,a){var s={};return s.ifnt=e.read_shift(2),s.numFmtId=e.read_shift(2),s.flags=e.read_shift(2),s.fStyle=s.flags>>2&1,r-=6,s.data=T9(e,r,s.fStyle,a),s}function X_(e,r,a,s){var n=a&&a.biff==5;s||(s=sr(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 O9(e){e.l+=4;var r=[e.read_shift(2),e.read_shift(2)];if(r[0]!==0&&r[0]--,r[1]!==0&&r[1]--,r[0]>7||r[1]>7)throw new Error("Bad Gutters: "+r.join("|"));return r}function D9(e){var r=sr(8);return r.write_shift(4,0),r.write_shift(2,0),r.write_shift(2,0),r}function Z_(e,r,a){var s=Pl(e);(a.biff==2||r==9)&&++e.l;var n=I7(e);return s.val=n,s.t=n===!0||n===!1?"b":"e",s}function R9(e,r,a,s,n,i){var c=sr(8);return zd(e,r,s,c),lN(a,i,c),c}function F9(e,r,a){a.biffguess&&a.biff==2&&(a.biff=5);var s=Pl(e),n=ji(e);return s.val=n,s}function I9(e,r,a,s){var n=sr(14);return zd(e,r,s,n),Bd(a,n),n}var K_=V7;function M9(e,r,a){var s=e.l+r,n=e.read_shift(2),i=e.read_shift(2);if(a.sbcch=i,i==1025||i==14849)return[i,n];if(i<1||i>255)throw new Error("Unexpected SupBook type: "+i);for(var c=Ud(e,i),u=[];s>e.l;)u.push(Yf(e));return[i,n,c,u]}function J_(e,r,a){var s=e.read_shift(2),n,i={fBuiltIn:s&1,fWantAdvise:s>>>1&1,fWantPict:s>>>2&1,fOle:s>>>3&1,fOleLink:s>>>4&1,cf:s>>>5&1023,fIcon:s>>>15&1};return a.sbcch===14849&&(n=Y7(e,r-2,a)),i.body=n||e.read_shift(r-2),typeof n=="string"&&(i.Name=n),i}var P9=["_xlnm.Consolidate_Area","_xlnm.Auto_Open","_xlnm.Auto_Close","_xlnm.Extract","_xlnm.Database","_xlnm.Criteria","_xlnm.Print_Area","_xlnm.Print_Titles","_xlnm.Recorder","_xlnm.Data_Form","_xlnm.Auto_Activate","_xlnm.Auto_Deactivate","_xlnm.Sheet_Title","_xlnm._FilterDatabase"];function Q_(e,r,a){var s=e.l+r,n=e.read_shift(2),i=e.read_shift(1),c=e.read_shift(1),u=e.read_shift(a&&a.biff==2?1:2),h=0;(!a||a.biff>=5)&&(a.biff!=5&&(e.l+=2),h=e.read_shift(2),a.biff==5&&(e.l+=2),e.l+=4);var g=Ud(e,c,a);n&32&&(g=P9[g.charCodeAt(0)]);var y=s-e.l;a&&a.biff==2&&--y;var w=s==e.l||u===0||!(y>0)?[]:JF(e,y,a,u);return{chKey:i,Name:g,itab:h,rgce:w}}function xN(e,r,a){if(a.biff<8)return L9(e,r,a);for(var s=[],n=e.l+r,i=e.read_shift(a.biff>8?4:2);i--!==0;)s.push(G7(e,a.biff>8?12:6,a));if(e.l!=n)throw new Error("Bad ExternSheet: "+e.l+" != "+n);return s}function L9(e,r,a){e[e.l+1]==3&&e[e.l]++;var s=Gf(e,r,a);return s.charCodeAt(0)==3?s.slice(1):s}function B9(e,r,a){if(a.biff<8){e.l+=r;return}var s=e.read_shift(2),n=e.read_shift(2),i=Ud(e,s,a),c=Ud(e,n,a);return[i,c]}function U9(e,r,a){var s=mN(e);e.l++;var n=e.read_shift(1);return r-=8,[QF(e,r,a),n,s]}function ek(e,r,a){var s=q7(e);switch(a.biff){case 2:e.l++,r-=7;break;case 3:case 4:e.l+=2,r-=8;break;default:e.l+=6,r-=12}return[s,ZF(e,r,a)]}function z9(e){var r=e.read_shift(4)!==0,a=e.read_shift(4)!==0,s=e.read_shift(4);return[r,a,s]}function W9(e,r,a){if(!(a.biff<8)){var s=e.read_shift(2),n=e.read_shift(2),i=e.read_shift(2),c=e.read_shift(2),u=Zd(e,0,a);return a.biff<8&&e.read_shift(1),[{r:s,c:n},u,c,i]}}function H9(e,r,a){return W9(e,r,a)}function $9(e,r){for(var a=[],s=e.read_shift(2);s--;)a.push(_g(e));return a}function V9(e){var r=sr(2+e.length*8);r.write_shift(2,e.length);for(var a=0;a<e.length;++a)hN(e[a],r);return r}function G9(e,r,a){if(a&&a.biff<8)return q9(e,r,a);var s=gN(e),n=J7(e,r-22,s[1]);return{cmo:s,ft:n}}var Y9={8:function(e,r){var a=e.l+r;e.l+=10;var s=e.read_shift(2);e.l+=4,e.l+=2,e.l+=2,e.l+=2,e.l+=4;var n=e.read_shift(1);return e.l+=n,e.l=a,{fmt:s}}};function q9(e,r,a){e.l+=4;var s=e.read_shift(2),n=e.read_shift(2),i=e.read_shift(2);e.l+=2,e.l+=2,e.l+=2,e.l+=2,e.l+=2,e.l+=2,e.l+=2,e.l+=2,e.l+=2,e.l+=6,r-=36;var c=[];return c.push((Y9[s]||Ei)(e,r,a)),{cmo:[n,s,i],ft:c}}function X9(e,r,a){var s=e.l,n="";try{e.l+=4;var i=(a.lastobj||{cmo:[0,0]}).cmo[1],c;[0,5,7,11,12,14].indexOf(i)==-1?e.l+=6:c=L7(e,6,a);var u=e.read_shift(2);e.read_shift(2),Nn(e,2);var h=e.read_shift(2);e.l+=h;for(var g=1;g<e.lens.length-1;++g){if(e.l-s!=e.lens[g])throw new Error("TxO: bad continue record");var y=e[e.l],w=Ud(e,e.lens[g+1]-e.lens[g]-1);if(n+=w,n.length>=(y?u:2*u))break}if(n.length!==u&&n.length!==u*2)throw new Error("cchText: "+u+" != "+n.length);return e.l=s+r,{t:n}}catch(E){return e.l=s+r,{t:n}}}function Z9(e,r){var a=_g(e);e.l+=16;var s=W7(e,r-24);return[a,s]}function K9(e){var r=sr(24),a=Ws(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,H7(e[1])])}function J9(e,r){e.read_shift(2);var a=_g(e),s=e.read_shift((r-10)/2,"dbcs-cont");return s=s.replace(Bi,""),[a,s]}function Q9(e){var r=e[1].Tooltip,a=sr(10+2*(r.length+1));a.write_shift(2,2048);var s=Ws(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 eO(e){var r=[0,0],a;return a=e.read_shift(2),r[0]=L_[a]||a,a=e.read_shift(2),r[1]=L_[a]||a,r}function tO(e){return e||(e=sr(4)),e.write_shift(2,1),e.write_shift(2,1),e}function rO(e){for(var r=e.read_shift(2),a=[];r-- >0;)a.push(uN(e));return a}function aO(e){for(var r=e.read_shift(2),a=[];r-- >0;)a.push(uN(e));return a}function sO(e){e.l+=2;var r={cxfs:0,crc:0};return r.cxfs=e.read_shift(2),r.crc=e.read_shift(4),r}function pN(e,r,a){if(!a.cellStyles)return Ei(e,r);var s=a&&a.biff>=12?4:2,n=e.read_shift(s),i=e.read_shift(s),c=e.read_shift(s),u=e.read_shift(s),h=e.read_shift(2);s==2&&(e.l+=2);var g={s:n,e:i,w:c,ixfe:u,flags:h};return(a.biff>=5||!a.biff)&&(g.level=h>>8&7),g}function nO(e,r){var a=sr(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 iO(e,r){var a={};return r<32||(e.l+=16,a.header=ji(e),a.footer=ji(e),e.l+=2),a}function oO(e,r,a){var s={area:!1};if(a.biff!=5)return e.l+=r,s;var n=e.read_shift(1);return e.l+=3,n&16&&(s.area=!0),s}function lO(e){for(var r=sr(2*e),a=0;a<e;++a)r.write_shift(2,a+1);return r}var cO=Pl,dO=oN,uO=Yf;function fO(e){var r=e.read_shift(2),a=e.read_shift(2),s=e.read_shift(4),n={fmt:r,env:a,len:s,data:e.slice(e.l,e.l+s)};return e.l+=s,n}function hO(e,r,a){a.biffguess&&a.biff==5&&(a.biff=2);var s=Pl(e);++e.l;var n=Zd(e,r-7,a);return s.t="str",s.val=n,s}function mO(e){var r=Pl(e);++e.l;var a=ji(e);return r.t="n",r.val=a,r}function gO(e,r,a){var s=sr(15);return Kf(s,e,r),s.write_shift(8,a,"f"),s}function xO(e){var r=Pl(e);++e.l;var a=e.read_shift(2);return r.t="n",r.val=a,r}function pO(e,r,a){var s=sr(9);return Kf(s,e,r),s.write_shift(2,a),s}function yO(e){var r=e.read_shift(1);return r===0?(e.l++,""):e.read_shift(r,"sbcs-cont")}function bO(e,r){e.l+=6,e.l+=2,e.l+=1,e.l+=3,e.l+=1,e.l+=r-13}function vO(e,r,a){var s=e.l+r,n=Pl(e),i=e.read_shift(2),c=Ud(e,i,a);return e.l=s,n.t="str",n.val=c,n}var wO=[2,3,48,49,131,139,140,245],O1=(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=bg({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(u,h){var g=[],y=Gc(1);switch(h.type){case"base64":y=vo(ko(u));break;case"binary":y=vo(u);break;case"buffer":case"array":y=u;break}fi(y,0);var w=y.read_shift(1),E=!!(w&136),S=!1,A=!1;switch(w){case 2:break;case 3:break;case 48:S=!0,E=!0;break;case 49:S=!0,E=!0;break;case 131:break;case 139:break;case 140:A=!0;break;case 245:break;default:throw new Error("DBF Unsupported Version: "+w.toString(16))}var C=0,O=521;w==2&&(C=y.read_shift(2)),y.l+=3,w!=2&&(C=y.read_shift(4)),C>1048576&&(C=1e6),w!=2&&(O=y.read_shift(2));var M=y.read_shift(2),R=h.codepage||1252;w!=2&&(y.l+=16,y.read_shift(1),y[y.l]!==0&&(R=e[y[y.l]]),y.l+=1,y.l+=2),A&&(y.l+=36);for(var F=[],z={},W=Math.min(y.length,w==2?521:O-10-(S?264:0)),X=A?32:11;y.l<W&&y[y.l]!=13;)switch(z={},z.name=jf.utils.decode(R,y.slice(y.l,y.l+X)).replace(/[\u0000\r\n].*$/g,""),y.l+=X,z.type=String.fromCharCode(y.read_shift(1)),w!=2&&!A&&(z.offset=y.read_shift(4)),z.len=y.read_shift(1),w==2&&(z.offset=y.read_shift(2)),z.dec=y.read_shift(1),z.name.length&&F.push(z),w!=2&&(y.l+=A?13:14),z.type){case"B":(!S||z.len!=8)&&h.WTF&&console.log("Skipping "+z.name+":"+z.type);break;case"G":case"P":h.WTF&&console.log("Skipping "+z.name+":"+z.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: "+z.type)}if(y[y.l]!==13&&(y.l=O-1),y.read_shift(1)!==13)throw new Error("DBF Terminator not found "+y.l+" "+y[y.l]);y.l=O;var B=0,Y=0;for(g[0]=[],Y=0;Y!=F.length;++Y)g[0][Y]=F[Y].name;for(;C-- >0;){if(y[y.l]===42){y.l+=M;continue}for(++y.l,g[++B]=[],Y=0,Y=0;Y!=F.length;++Y){var G=y.slice(y.l,y.l+F[Y].len);y.l+=F[Y].len,fi(G,0);var ie=jf.utils.decode(R,G);switch(F[Y].type){case"C":ie.trim().length&&(g[B][Y]=ie.replace(/\s+$/,""));break;case"D":ie.length===8?g[B][Y]=new Date(+ie.slice(0,4),+ie.slice(4,6)-1,+ie.slice(6,8)):g[B][Y]=ie;break;case"F":g[B][Y]=parseFloat(ie.trim());break;case"+":case"I":g[B][Y]=A?G.read_shift(-4,"i")^2147483648:G.read_shift(4,"i");break;case"L":switch(ie.trim().toUpperCase()){case"Y":case"T":g[B][Y]=!0;break;case"N":case"F":g[B][Y]=!1;break;case"":case"?":break;default:throw new Error("DBF Unrecognized L:|"+ie+"|")}break;case"M":if(!E)throw new Error("DBF Unexpected MEMO for type "+w.toString(16));g[B][Y]="##MEMO##"+(A?parseInt(ie.trim(),10):G.read_shift(4));break;case"N":ie=ie.replace(/\u0000/g,"").trim(),ie&&ie!="."&&(g[B][Y]=+ie||0);break;case"@":g[B][Y]=new Date(G.read_shift(-8,"f")-621356832e5);break;case"T":g[B][Y]=new Date((G.read_shift(4)-2440588)*864e5+G.read_shift(4));break;case"Y":g[B][Y]=G.read_shift(4,"i")/1e4+G.read_shift(4,"i")/1e4*Math.pow(2,32);break;case"O":g[B][Y]=-G.read_shift(-8,"f");break;case"B":if(S&&F[Y].len==8){g[B][Y]=G.read_shift(8,"f");break}case"G":case"P":G.l+=F[Y].len;break;case"0":if(F[Y].name==="_NullFlags")break;default:throw new Error("DBF Unsupported data type "+F[Y].type)}}}if(w!=2&&y.l<y.length&&y[y.l++]!=26)throw new Error("DBF EOF Marker missing "+(y.l-1)+" of "+y.length+" "+y[y.l-1].toString(16));return h&&h.sheetRows&&(g=g.slice(0,h.sheetRows)),h.DBF=F,g}function s(u,h){var g=h||{};g.dateNF||(g.dateNF="yyyymmdd");var y=su(a(u,g),g);return y["!cols"]=g.DBF.map(function(w){return{wch:w.len,DBF:w}}),delete g.DBF,y}function n(u,h){try{return Kc(s(u,h),h)}catch(g){if(h&&h.WTF)throw g}return{SheetNames:[],Sheets:{}}}var i={B:8,C:250,L:1,D:8,"?":0,"":0};function c(u,h){var g=h||{};if(+g.codepage>=0&&ol(+g.codepage),g.type=="string")throw new Error("Cannot write DBF to JS string");var y=ro(),w=ng(u,{header:1,raw:!0,cellDates:!0}),E=w[0],S=w.slice(1),A=u["!cols"]||[],C=0,O=0,M=0,R=1;for(C=0;C<E.length;++C){if(((A[C]||{}).DBF||{}).name){E[C]=A[C].DBF.name,++M;continue}if(E[C]!=null){if(++M,typeof E[C]=="number"&&(E[C]=E[C].toString(10)),typeof E[C]!="string")throw new Error("DBF Invalid column name "+E[C]+" |"+typeof E[C]+"|");if(E.indexOf(E[C])!==C){for(O=0;O<1024;++O)if(E.indexOf(E[C]+"_"+O)==-1){E[C]+="_"+O;break}}}}var F=$a(u["!ref"]),z=[],W=[],X=[];for(C=0;C<=F.e.c-F.s.c;++C){var B="",Y="",G=0,ie=[];for(O=0;O<S.length;++O)S[O][C]!=null&&ie.push(S[O][C]);if(ie.length==0||E[C]==null){z[C]="?";continue}for(O=0;O<ie.length;++O){switch(typeof ie[O]){case"number":Y="B";break;case"string":Y="C";break;case"boolean":Y="L";break;case"object":Y=ie[O]instanceof Date?"D":"C";break;default:Y="C"}G=Math.max(G,String(ie[O]).length),B=B&&B!=Y?"C":Y}G>250&&(G=250),Y=((A[C]||{}).DBF||{}).type,Y=="C"&&A[C].DBF.len>G&&(G=A[C].DBF.len),B=="B"&&Y=="N"&&(B="N",X[C]=A[C].DBF.dec,G=A[C].DBF.len),W[C]=B=="C"||Y=="N"?G:i[B]||0,R+=W[C],z[C]=B}var fe=y.next(32);for(fe.write_shift(4,318902576),fe.write_shift(4,S.length),fe.write_shift(2,296+32*M),fe.write_shift(2,R),C=0;C<4;++C)fe.write_shift(4,0);for(fe.write_shift(4,0|(+r[i3]||3)<<8),C=0,O=0;C<E.length;++C)if(E[C]!=null){var K=y.next(32),ke=(E[C].slice(-10)+"\0\0\0\0\0\0\0\0\0\0\0").slice(0,11);K.write_shift(1,ke,"sbcs"),K.write_shift(1,z[C]=="?"?"C":z[C],"sbcs"),K.write_shift(4,O),K.write_shift(1,W[C]||i[z[C]]||0),K.write_shift(1,X[C]||0),K.write_shift(1,2),K.write_shift(4,0),K.write_shift(1,0),K.write_shift(4,0),K.write_shift(4,0),O+=W[C]||i[z[C]]||0}var ge=y.next(264);for(ge.write_shift(4,13),C=0;C<65;++C)ge.write_shift(4,0);for(C=0;C<S.length;++C){var re=y.next(R);for(re.write_shift(1,0),O=0;O<E.length;++O)if(E[O]!=null)switch(z[O]){case"L":re.write_shift(1,S[C][O]==null?63:S[C][O]?84:70);break;case"B":re.write_shift(8,S[C][O]||0,"f");break;case"N":var we="0";for(typeof S[C][O]=="number"&&(we=S[C][O].toFixed(X[O]||0)),M=0;M<W[O]-we.length;++M)re.write_shift(1,32);re.write_shift(1,we,"sbcs");break;case"D":S[C][O]?(re.write_shift(4,("0000"+S[C][O].getFullYear()).slice(-4),"sbcs"),re.write_shift(2,("00"+(S[C][O].getMonth()+1)).slice(-2),"sbcs"),re.write_shift(2,("00"+S[C][O].getDate()).slice(-2),"sbcs")):re.write_shift(8,"00000000","sbcs");break;case"C":var ee=String(S[C][O]!=null?S[C][O]:"").slice(0,W[O]);for(re.write_shift(1,ee,"sbcs"),M=0;M<W[O]-ee.length;++M)re.write_shift(1,32);break}}return y.next(1).write_shift(1,26),y.end()}return{to_workbook:n,to_sheet:s,from_sheet:c}})(),yN=(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("+Qs(e).join("|").replace(/\|\|\|/,"|\\||").replace(/([?()+])/g,"\\$1")+"|\\|)","gm"),a=function(E,S){var A=e[S];return typeof A=="number"?u_(A):A},s=function(E,S,A){var C=S.charCodeAt(0)-32<<4|A.charCodeAt(0)-48;return C==59?E:u_(C)};e["|"]=254;function n(E,S){switch(S.type){case"base64":return i(ko(E),S);case"binary":return i(E,S);case"buffer":return i(Ca&&Buffer.isBuffer(E)?E.toString("binary"):Zc(E),S);case"array":return i(Ld(E),S)}throw new Error("Unrecognized type "+S.type)}function i(E,S){var A=E.split(/[\n\r]+/),C=-1,O=-1,M=0,R=0,F=[],z=[],W=null,X={},B=[],Y=[],G=[],ie=0,fe;for(+S.codepage>=0&&ol(+S.codepage);M!==A.length;++M){ie=0;var K=A[M].trim().replace(/\x1B([\x20-\x2F])([\x30-\x3F])/g,s).replace(r,a),ke=K.replace(/;;/g,"\0").split(";").map(function(oe){return oe.replace(/\u0000/g,";")}),ge=ke[0],re;if(K.length>0)switch(ge){case"ID":break;case"E":break;case"B":break;case"O":break;case"W":break;case"P":ke[1].charAt(0)=="P"&&z.push(K.slice(3).replace(/;;/g,";"));break;case"C":var we=!1,ee=!1,ve=!1,ce=!1,ye=-1,te=-1;for(R=1;R<ke.length;++R)switch(ke[R].charAt(0)){case"A":break;case"X":O=parseInt(ke[R].slice(1))-1,ee=!0;break;case"Y":for(C=parseInt(ke[R].slice(1))-1,ee||(O=0),fe=F.length;fe<=C;++fe)F[fe]=[];break;case"K":re=ke[R].slice(1),re.charAt(0)==='"'?re=re.slice(1,re.length-1):re==="TRUE"?re=!0:re==="FALSE"?re=!1:isNaN(cl(re))?isNaN(Y0(re).getDate())||(re=Cs(re)):(re=cl(re),W!==null&&ru(W)&&(re=wg(re))),we=!0;break;case"E":ce=!0;var q=$0(ke[R].slice(1),{r:C,c:O});F[C][O]=[F[C][O],q];break;case"S":ve=!0,F[C][O]=[F[C][O],"S5S"];break;case"G":break;case"R":ye=parseInt(ke[R].slice(1))-1;break;case"C":te=parseInt(ke[R].slice(1))-1;break;default:if(S&&S.WTF)throw new Error("SYLK bad record "+K)}if(we&&(F[C][O]&&F[C][O].length==2?F[C][O][0]=re:F[C][O]=re,W=null),ve){if(ce)throw new Error("SYLK shared formula cannot have own formula");var J=ye>-1&&F[ye][te];if(!J||!J[1])throw new Error("SYLK shared formula cannot find base");F[C][O][1]=MN(J[1],{r:C-ye,c:O-te})}break;case"F":var ae=0;for(R=1;R<ke.length;++R)switch(ke[R].charAt(0)){case"X":O=parseInt(ke[R].slice(1))-1,++ae;break;case"Y":for(C=parseInt(ke[R].slice(1))-1,fe=F.length;fe<=C;++fe)F[fe]=[];break;case"M":ie=parseInt(ke[R].slice(1))/20;break;case"F":break;case"G":break;case"P":W=z[parseInt(ke[R].slice(1))];break;case"S":break;case"D":break;case"N":break;case"W":for(G=ke[R].slice(1).split(" "),fe=parseInt(G[0],10);fe<=parseInt(G[1],10);++fe)ie=parseInt(G[2],10),Y[fe-1]=ie===0?{hidden:!0}:{wch:ie},Yc(Y[fe-1]);break;case"C":O=parseInt(ke[R].slice(1))-1,Y[O]||(Y[O]={});break;case"R":C=parseInt(ke[R].slice(1))-1,B[C]||(B[C]={}),ie>0?(B[C].hpt=ie,B[C].hpx=X0(ie)):ie===0&&(B[C].hidden=!0);break;default:if(S&&S.WTF)throw new Error("SYLK bad record "+K)}ae<1&&(W=null);break;default:if(S&&S.WTF)throw new Error("SYLK bad record "+K)}}return B.length>0&&(X["!rows"]=B),Y.length>0&&(X["!cols"]=Y),S&&S.sheetRows&&(F=F.slice(0,S.sheetRows)),[F,X]}function c(E,S){var A=n(E,S),C=A[0],O=A[1],M=su(C,S);return Qs(O).forEach(function(R){M[R]=O[R]}),M}function u(E,S){return Kc(c(E,S),S)}function h(E,S,A,C){var O="C;Y"+(A+1)+";X"+(C+1)+";K";switch(E.t){case"n":O+=E.v||0,E.f&&!E.F&&(O+=";E"+Wy(E.f,{r:A,c:C}));break;case"b":O+=E.v?"TRUE":"FALSE";break;case"e":O+=E.w||E.v;break;case"d":O+='"'+(E.w||E.v)+'"';break;case"s":O+='"'+E.v.replace(/"/g,"").replace(/;/g,";;")+'"';break}return O}function g(E,S){S.forEach(function(A,C){var O="F;W"+(C+1)+" "+(C+1)+" ";A.hidden?O+="0":(typeof A.width=="number"&&!A.wpx&&(A.wpx=Rf(A.width)),typeof A.wpx=="number"&&!A.wch&&(A.wch=Ff(A.wpx)),typeof A.wch=="number"&&(O+=Math.round(A.wch))),O.charAt(O.length-1)!=" "&&E.push(O)})}function y(E,S){S.forEach(function(A,C){var O="F;";A.hidden?O+="M0;":A.hpt?O+="M"+20*A.hpt+";":A.hpx&&(O+="M"+20*If(A.hpx)+";"),O.length>2&&E.push(O+"R"+(C+1))})}function w(E,S){var A=["ID;PWXL;N;E"],C=[],O=$a(E["!ref"]),M,R=Array.isArray(E),F=`\r
`;A.push("P;PGeneral"),A.push("F;P0;DG0G8;M255"),E["!cols"]&&g(A,E["!cols"]),E["!rows"]&&y(A,E["!rows"]),A.push("B;Y"+(O.e.r-O.s.r+1)+";X"+(O.e.c-O.s.c+1)+";D"+[O.s.c,O.s.r,O.e.c,O.e.r].join(" "));for(var z=O.s.r;z<=O.e.r;++z)for(var W=O.s.c;W<=O.e.c;++W){var X=sa({r:z,c:W});M=R?(E[z]||[])[W]:E[X],!(!M||M.v==null&&(!M.f||M.F))&&C.push(h(M,E,z,W))}return A.join(F)+F+C.join(F)+F+"E"+F}return{to_workbook:u,to_sheet:c,from_sheet:w}})(),bN=(function(){function e(i,c){switch(c.type){case"base64":return r(ko(i),c);case"binary":return r(i,c);case"buffer":return r(Ca&&Buffer.isBuffer(i)?i.toString("binary"):Zc(i),c);case"array":return r(Ld(i),c)}throw new Error("Unrecognized type "+c.type)}function r(i,c){for(var u=i.split(`
`),h=-1,g=-1,y=0,w=[];y!==u.length;++y){if(u[y].trim()==="BOT"){w[++h]=[],g=0;continue}if(!(h<0)){var E=u[y].trim().split(","),S=E[0],A=E[1];++y;for(var C=u[y]||"";(C.match(/["]/g)||[]).length&1&&y<u.length-1;)C+=`
`+u[++y];switch(C=C.trim(),+S){case-1:if(C==="BOT"){w[++h]=[],g=0;continue}else if(C!=="EOD")throw new Error("Unrecognized DIF special command "+C);break;case 0:C==="TRUE"?w[h][g]=!0:C==="FALSE"?w[h][g]=!1:isNaN(cl(A))?isNaN(Y0(A).getDate())?w[h][g]=A:w[h][g]=Cs(A):w[h][g]=cl(A),++g;break;case 1:C=C.slice(1,C.length-1),C=C.replace(/""/g,'"'),C&&C.match(/^=".*"$/)&&(C=C.slice(2,-1)),w[h][g++]=C!==""?C:null;break}if(C==="EOD")break}}return c&&c.sheetRows&&(w=w.slice(0,c.sheetRows)),w}function a(i,c){return su(e(i,c),c)}function s(i,c){return Kc(a(i,c),c)}var n=(function(){var i=function(h,g,y,w,E){h.push(g),h.push(y+","+w),h.push('"'+E.replace(/"/g,'""')+'"')},c=function(h,g,y,w){h.push(g+","+y),h.push(g==1?'"'+w.replace(/"/g,'""')+'"':w)};return function(h){var g=[],y=$a(h["!ref"]),w,E=Array.isArray(h);i(g,"TABLE",0,1,"sheetjs"),i(g,"VECTORS",0,y.e.r-y.s.r+1,""),i(g,"TUPLES",0,y.e.c-y.s.c+1,""),i(g,"DATA",0,0,"");for(var S=y.s.r;S<=y.e.r;++S){c(g,-1,0,"BOT");for(var A=y.s.c;A<=y.e.c;++A){var C=sa({r:S,c:A});if(w=E?(h[S]||[])[A]:h[C],!w){c(g,1,0,"");continue}switch(w.t){case"n":var O=w.w;!O&&w.v!=null&&(O=w.v),O==null?w.f&&!w.F?c(g,1,0,"="+w.f):c(g,1,0,""):c(g,0,O,"V");break;case"b":c(g,0,w.v?1:0,w.v?"TRUE":"FALSE");break;case"s":c(g,1,0,isNaN(w.v)?w.v:'="'+w.v+'"');break;case"d":w.w||(w.w=Yo(w.z||aa[14],Pn(Cs(w.v)))),c(g,0,w.w,"V");break;default:c(g,1,0,"")}}}c(g,-1,0,"EOD");var M=`\r
`,R=g.join(M);return R}})();return{to_workbook:s,to_sheet:a,from_sheet:n}})(),vN=(function(){function e(w){return w.replace(/\\b/g,"\\").replace(/\\c/g,":").replace(/\\n/g,`
`)}function r(w){return w.replace(/\\/g,"\\b").replace(/:/g,"\\c").replace(/\n/g,"\\n")}function a(w,E){for(var S=w.split(`
`),A=-1,C=-1,O=0,M=[];O!==S.length;++O){var R=S[O].trim().split(":");if(R[0]==="cell"){var F=Ws(R[1]);if(M.length<=F.r)for(A=M.length;A<=F.r;++A)M[A]||(M[A]=[]);switch(A=F.r,C=F.c,R[2]){case"t":M[A][C]=e(R[3]);break;case"v":M[A][C]=+R[3];break;case"vtf":var z=R[R.length-1];case"vtc":switch(R[3]){case"nl":M[A][C]=!!+R[4];break;default:M[A][C]=+R[4];break}R[2]=="vtf"&&(M[A][C]=[M[A][C],z])}}}return E&&E.sheetRows&&(M=M.slice(0,E.sheetRows)),M}function s(w,E){return su(a(w,E),E)}function n(w,E){return Kc(s(w,E),E)}var i=["socialcalc:version:1.5","MIME-Version: 1.0","Content-Type: multipart/mixed; boundary=SocialCalcSpreadsheetControlSave"].join(`
`),c=["--SocialCalcSpreadsheetControlSave","Content-type: text/plain; charset=UTF-8"].join(`
`)+`
`,u=["# SocialCalc Spreadsheet Control Save","part:sheet"].join(`
`),h="--SocialCalcSpreadsheetControlSave--";function g(w){if(!w||!w["!ref"])return"";for(var E=[],S=[],A,C="",O=no(w["!ref"]),M=Array.isArray(w),R=O.s.r;R<=O.e.r;++R)for(var F=O.s.c;F<=O.e.c;++F)if(C=sa({r:R,c:F}),A=M?(w[R]||[])[F]:w[C],!(!A||A.v==null||A.t==="z")){switch(S=["cell",C,"t"],A.t){case"s":case"str":S.push(r(A.v));break;case"n":A.f?(S[2]="vtf",S[3]="n",S[4]=A.v,S[5]=r(A.f)):(S[2]="v",S[3]=A.v);break;case"b":S[2]="vt"+(A.f?"f":"c"),S[3]="nl",S[4]=A.v?"1":"0",S[5]=r(A.f||(A.v?"TRUE":"FALSE"));break;case"d":var z=Pn(Cs(A.v));S[2]="vtc",S[3]="nd",S[4]=""+z,S[5]=A.w||Yo(A.z||aa[14],z);break;case"e":continue}E.push(S.join(":"))}return E.push("sheet:c:"+(O.e.c-O.s.c+1)+":r:"+(O.e.r-O.s.r+1)+":tvf:1"),E.push("valueformat:1:text-wiki"),E.join(`
`)}function y(w){return[i,c,u,c,g(w),h].join(`
`)}return{to_workbook:n,to_sheet:s,from_sheet:y}})(),q0=(function(){function e(y,w,E,S,A){A.raw?w[E][S]=y:y===""||(y==="TRUE"?w[E][S]=!0:y==="FALSE"?w[E][S]=!1:isNaN(cl(y))?isNaN(Y0(y).getDate())?w[E][S]=y:w[E][S]=Cs(y):w[E][S]=cl(y))}function r(y,w){var E=w||{},S=[];if(!y||y.length===0)return S;for(var A=y.split(/[\r\n]/),C=A.length-1;C>=0&&A[C].length===0;)--C;for(var O=10,M=0,R=0;R<=C;++R)M=A[R].indexOf(" "),M==-1?M=A[R].length:M++,O=Math.max(O,M);for(R=0;R<=C;++R){S[R]=[];var F=0;for(e(A[R].slice(0,O).trim(),S,R,F,E),F=1;F<=(A[R].length-O)/10+1;++F)e(A[R].slice(O+(F-1)*10,O+F*10).trim(),S,R,F,E)}return E.sheetRows&&(S=S.slice(0,E.sheetRows)),S}var a={44:",",9:" ",59:";",124:"|"},s={44:3,9:2,59:1,124:0};function n(y){for(var w={},E=!1,S=0,A=0;S<y.length;++S)(A=y.charCodeAt(S))==34?E=!E:!E&&A in a&&(w[A]=(w[A]||0)+1);A=[];for(S in w)Object.prototype.hasOwnProperty.call(w,S)&&A.push([w[S],S]);if(!A.length){w=s;for(S in w)Object.prototype.hasOwnProperty.call(w,S)&&A.push([w[S],S])}return A.sort(function(C,O){return C[0]-O[0]||s[C[1]]-s[O[1]]}),a[A.pop()[1]]||44}function i(y,w){var E=w||{},S="",A=E.dense?[]:{},C={s:{c:0,r:0},e:{c:0,r:0}};y.slice(0,4)=="sep="?y.charCodeAt(5)==13&&y.charCodeAt(6)==10?(S=y.charAt(4),y=y.slice(7)):y.charCodeAt(5)==13||y.charCodeAt(5)==10?(S=y.charAt(4),y=y.slice(6)):S=n(y.slice(0,1024)):E&&E.FS?S=E.FS:S=n(y.slice(0,1024));var O=0,M=0,R=0,F=0,z=0,W=S.charCodeAt(0),X=!1,B=0,Y=y.charCodeAt(0);y=y.replace(/\r\n/mg,`
`);var G=E.dateNF!=null?oA(E.dateNF):null;function ie(){var fe=y.slice(F,z),K={};if(fe.charAt(0)=='"'&&fe.charAt(fe.length-1)=='"'&&(fe=fe.slice(1,-1).replace(/""/g,'"')),fe.length===0)K.t="z";else if(E.raw)K.t="s",K.v=fe;else if(fe.trim().length===0)K.t="s",K.v=fe;else if(fe.charCodeAt(0)==61)fe.charCodeAt(1)==34&&fe.charCodeAt(fe.length-1)==34?(K.t="s",K.v=fe.slice(2,-1).replace(/""/g,'"')):MR(fe)?(K.t="n",K.f=fe.slice(1)):(K.t="s",K.v=fe);else if(fe=="TRUE")K.t="b",K.v=!0;else if(fe=="FALSE")K.t="b",K.v=!1;else if(!isNaN(R=cl(fe)))K.t="n",E.cellText!==!1&&(K.w=fe),K.v=R;else if(!isNaN(Y0(fe).getDate())||G&&fe.match(G)){K.z=E.dateNF||aa[14];var ke=0;G&&fe.match(G)&&(fe=lA(fe,E.dateNF,fe.match(G)||[]),ke=1),E.cellDates?(K.t="d",K.v=Cs(fe,ke)):(K.t="n",K.v=Pn(Cs(fe,ke))),E.cellText!==!1&&(K.w=Yo(K.z,K.v instanceof Date?Pn(K.v):K.v)),E.cellNF||delete K.z}else K.t="s",K.v=fe;if(K.t=="z"||(E.dense?(A[O]||(A[O]=[]),A[O][M]=K):A[sa({c:M,r:O})]=K),F=z+1,Y=y.charCodeAt(F),C.e.c<M&&(C.e.c=M),C.e.r<O&&(C.e.r=O),B==W)++M;else if(M=0,++O,E.sheetRows&&E.sheetRows<=O)return!0}e:for(;z<y.length;++z)switch(B=y.charCodeAt(z)){case 34:Y===34&&(X=!X);break;case W:case 10:case 13:if(!X&&ie())break e;break}return z-F>0&&ie(),A["!ref"]=ba(C),A}function c(y,w){return!(w&&w.PRN)||w.FS||y.slice(0,4)=="sep="||y.indexOf(" ")>=0||y.indexOf(",")>=0||y.indexOf(";")>=0?i(y,w):su(r(y,w),w)}function u(y,w){var E="",S=w.type=="string"?[0,0,0,0]:Zy(y,w);switch(w.type){case"base64":E=ko(y);break;case"binary":E=y;break;case"buffer":w.codepage==65001?E=y.toString("utf8"):w.codepage&&typeof jf!="undefined"||(E=Ca&&Buffer.isBuffer(y)?y.toString("binary"):Zc(y));break;case"array":E=Ld(y);break;case"string":E=y;break;default:throw new Error("Unrecognized type "+w.type)}return S[0]==239&&S[1]==187&&S[2]==191?E=ms(E.slice(3)):w.type!="string"&&w.type!="buffer"&&w.codepage==65001?E=ms(E):w.type=="binary",E.slice(0,19)=="socialcalc:version:"?vN.to_sheet(w.type=="string"?E:ms(E),w):c(E,w)}function h(y,w){return Kc(u(y,w),w)}function g(y){for(var w=[],E=$a(y["!ref"]),S,A=Array.isArray(y),C=E.s.r;C<=E.e.r;++C){for(var O=[],M=E.s.c;M<=E.e.c;++M){var R=sa({r:C,c:M});if(S=A?(y[C]||[])[M]:y[R],!S||S.v==null){O.push(" ");continue}for(var F=(S.w||(uc(S),S.w)||"").slice(0,10);F.length<10;)F+=" ";O.push(F+(M===0?" ":""))}w.push(O.join(""))}return w.join(`
`)}return{to_workbook:h,to_sheet:u,from_sheet:g}})();function _O(e,r){var a=r||{},s=!!a.WTF;a.WTF=!0;try{var n=yN.to_workbook(e,a);return a.WTF=s,n}catch(i){if(a.WTF=s,!i.message.match(/SYLK bad record ID/)&&s)throw i;return q0.to_workbook(e,r)}}var Td=(function(){function e(q,J,ae){if(q){fi(q,q.l||0);for(var oe=ae.Enum||ye;q.l<q.length;){var le=q.read_shift(2),be=oe[le]||oe[65535],Z=q.read_shift(2),Le=q.l+Z,Pe=be.f&&be.f(q,Z,ae);if(q.l=Le,J(Pe,be,le))return}}}function r(q,J){switch(J.type){case"base64":return a(vo(ko(q)),J);case"binary":return a(vo(q),J);case"buffer":case"array":return a(q,J)}throw"Unsupported type "+J.type}function a(q,J){if(!q)return q;var ae=J||{},oe=ae.dense?[]:{},le="Sheet1",be="",Z=0,Le={},Pe=[],Be=[],pe={s:{r:0,c:0},e:{r:0,c:0}},rt=ae.sheetRows||0;if(q[2]==0&&(q[3]==8||q[3]==9)&&q.length>=16&&q[14]==5&&q[15]===108)throw new Error("Unsupported Works 3 for Mac file");if(q[2]==2)ae.Enum=ye,e(q,function(ft,Lt,Je){switch(Je){case 0:ae.vers=ft,ft>=4096&&(ae.qpro=!0);break;case 6:pe=ft;break;case 204:ft&&(be=ft);break;case 222:be=ft;break;case 15:case 51:ae.qpro||(ft[1].v=ft[1].v.slice(1));case 13:case 14:case 16:Je==14&&(ft[2]&112)==112&&(ft[2]&15)>1&&(ft[2]&15)<15&&(ft[1].z=ae.dateNF||aa[14],ae.cellDates&&(ft[1].t="d",ft[1].v=wg(ft[1].v))),ae.qpro&&ft[3]>Z&&(oe["!ref"]=ba(pe),Le[le]=oe,Pe.push(le),oe=ae.dense?[]:{},pe={s:{r:0,c:0},e:{r:0,c:0}},Z=ft[3],le=be||"Sheet"+(Z+1),be="");var Ve=ae.dense?(oe[ft[0].r]||[])[ft[0].c]:oe[sa(ft[0])];if(Ve){Ve.t=ft[1].t,Ve.v=ft[1].v,ft[1].z!=null&&(Ve.z=ft[1].z),ft[1].f!=null&&(Ve.f=ft[1].f);break}ae.dense?(oe[ft[0].r]||(oe[ft[0].r]=[]),oe[ft[0].r][ft[0].c]=ft[1]):oe[sa(ft[0])]=ft[1];break}},ae);else if(q[2]==26||q[2]==14)ae.Enum=te,q[2]==14&&(ae.qpro=!0,q.l=0),e(q,function(ft,Lt,Je){switch(Je){case 204:le=ft;break;case 22:ft[1].v=ft[1].v.slice(1);case 23:case 24:case 25:case 37:case 39:case 40:if(ft[3]>Z&&(oe["!ref"]=ba(pe),Le[le]=oe,Pe.push(le),oe=ae.dense?[]:{},pe={s:{r:0,c:0},e:{r:0,c:0}},Z=ft[3],le="Sheet"+(Z+1)),rt>0&&ft[0].r>=rt)break;ae.dense?(oe[ft[0].r]||(oe[ft[0].r]=[]),oe[ft[0].r][ft[0].c]=ft[1]):oe[sa(ft[0])]=ft[1],pe.e.c<ft[0].c&&(pe.e.c=ft[0].c),pe.e.r<ft[0].r&&(pe.e.r=ft[0].r);break;case 27:ft[14e3]&&(Be[ft[14e3][0]]=ft[14e3][1]);break;case 1537:Be[ft[0]]=ft[1],ft[0]==Z&&(le=ft[1]);break}},ae);else throw new Error("Unrecognized LOTUS BOF "+q[2]);if(oe["!ref"]=ba(pe),Le[be||le]=oe,Pe.push(be||le),!Be.length)return{SheetNames:Pe,Sheets:Le};for(var ct={},et=[],It=0;It<Be.length;++It)Le[Pe[It]]?(et.push(Be[It]||Pe[It]),ct[Be[It]]=Le[Be[It]]||Le[Pe[It]]):(et.push(Be[It]),ct[Be[It]]={"!ref":"A1"});return{SheetNames:et,Sheets:ct}}function s(q,J){var ae=J||{};if(+ae.codepage>=0&&ol(+ae.codepage),ae.type=="string")throw new Error("Cannot write WK1 to JS string");var oe=ro(),le=$a(q["!ref"]),be=Array.isArray(q),Z=[];jr(oe,0,i(1030)),jr(oe,6,h(le));for(var Le=Math.min(le.e.r,8191),Pe=le.s.r;Pe<=Le;++Pe)for(var Be=nn(Pe),pe=le.s.c;pe<=le.e.c;++pe){Pe===le.s.r&&(Z[pe]=zs(pe));var rt=Z[pe]+Be,ct=be?(q[Pe]||[])[pe]:q[rt];if(!(!ct||ct.t=="z"))if(ct.t=="n")(ct.v|0)==ct.v&&ct.v>=-32768&&ct.v<=32767?jr(oe,13,S(Pe,pe,ct.v)):jr(oe,14,C(Pe,pe,ct.v));else{var et=uc(ct);jr(oe,15,w(Pe,pe,et.slice(0,239)))}}return jr(oe,1),oe.end()}function n(q,J){var ae=J||{};if(+ae.codepage>=0&&ol(+ae.codepage),ae.type=="string")throw new Error("Cannot write WK3 to JS string");var oe=ro();jr(oe,0,c(q));for(var le=0,be=0;le<q.SheetNames.length;++le)(q.Sheets[q.SheetNames[le]]||{})["!ref"]&&jr(oe,27,ce(q.SheetNames[le],be++));var Z=0;for(le=0;le<q.SheetNames.length;++le){var Le=q.Sheets[q.SheetNames[le]];if(!(!Le||!Le["!ref"])){for(var Pe=$a(Le["!ref"]),Be=Array.isArray(Le),pe=[],rt=Math.min(Pe.e.r,8191),ct=Pe.s.r;ct<=rt;++ct)for(var et=nn(ct),It=Pe.s.c;It<=Pe.e.c;++It){ct===Pe.s.r&&(pe[It]=zs(It));var ft=pe[It]+et,Lt=Be?(Le[ct]||[])[It]:Le[ft];if(!(!Lt||Lt.t=="z"))if(Lt.t=="n")jr(oe,23,ie(ct,It,Z,Lt.v));else{var Je=uc(Lt);jr(oe,22,B(ct,It,Z,Je.slice(0,239)))}}++Z}}return jr(oe,1),oe.end()}function i(q){var J=sr(2);return J.write_shift(2,q),J}function c(q){var J=sr(26);J.write_shift(2,4096),J.write_shift(2,4),J.write_shift(4,0);for(var ae=0,oe=0,le=0,be=0;be<q.SheetNames.length;++be){var Z=q.SheetNames[be],Le=q.Sheets[Z];if(!(!Le||!Le["!ref"])){++le;var Pe=no(Le["!ref"]);ae<Pe.e.r&&(ae=Pe.e.r),oe<Pe.e.c&&(oe=Pe.e.c)}}return ae>8191&&(ae=8191),J.write_shift(2,ae),J.write_shift(1,le),J.write_shift(1,oe),J.write_shift(2,0),J.write_shift(2,0),J.write_shift(1,1),J.write_shift(1,2),J.write_shift(4,0),J.write_shift(4,0),J}function u(q,J,ae){var oe={s:{c:0,r:0},e:{c:0,r:0}};return J==8&&ae.qpro?(oe.s.c=q.read_shift(1),q.l++,oe.s.r=q.read_shift(2),oe.e.c=q.read_shift(1),q.l++,oe.e.r=q.read_shift(2),oe):(oe.s.c=q.read_shift(2),oe.s.r=q.read_shift(2),J==12&&ae.qpro&&(q.l+=2),oe.e.c=q.read_shift(2),oe.e.r=q.read_shift(2),J==12&&ae.qpro&&(q.l+=2),oe.s.c==65535&&(oe.s.c=oe.e.c=oe.s.r=oe.e.r=0),oe)}function h(q){var J=sr(8);return J.write_shift(2,q.s.c),J.write_shift(2,q.s.r),J.write_shift(2,q.e.c),J.write_shift(2,q.e.r),J}function g(q,J,ae){var oe=[{c:0,r:0},{t:"n",v:0},0,0];return ae.qpro&&ae.vers!=20768?(oe[0].c=q.read_shift(1),oe[3]=q.read_shift(1),oe[0].r=q.read_shift(2),q.l+=2):(oe[2]=q.read_shift(1),oe[0].c=q.read_shift(2),oe[0].r=q.read_shift(2)),oe}function y(q,J,ae){var oe=q.l+J,le=g(q,J,ae);if(le[1].t="s",ae.vers==20768){q.l++;var be=q.read_shift(1);return le[1].v=q.read_shift(be,"utf8"),le}return ae.qpro&&q.l++,le[1].v=q.read_shift(oe-q.l,"cstr"),le}function w(q,J,ae){var oe=sr(7+ae.length);oe.write_shift(1,255),oe.write_shift(2,J),oe.write_shift(2,q),oe.write_shift(1,39);for(var le=0;le<oe.length;++le){var be=ae.charCodeAt(le);oe.write_shift(1,be>=128?95:be)}return oe.write_shift(1,0),oe}function E(q,J,ae){var oe=g(q,J,ae);return oe[1].v=q.read_shift(2,"i"),oe}function S(q,J,ae){var oe=sr(7);return oe.write_shift(1,255),oe.write_shift(2,J),oe.write_shift(2,q),oe.write_shift(2,ae,"i"),oe}function A(q,J,ae){var oe=g(q,J,ae);return oe[1].v=q.read_shift(8,"f"),oe}function C(q,J,ae){var oe=sr(13);return oe.write_shift(1,255),oe.write_shift(2,J),oe.write_shift(2,q),oe.write_shift(8,ae,"f"),oe}function O(q,J,ae){var oe=q.l+J,le=g(q,J,ae);if(le[1].v=q.read_shift(8,"f"),ae.qpro)q.l=oe;else{var be=q.read_shift(2);z(q.slice(q.l,q.l+be),le),q.l+=be}return le}function M(q,J,ae){var oe=J&32768;return J&=-32769,J=(oe?q:0)+(J>=8192?J-16384:J),(oe?"":"$")+(ae?zs(J):nn(J))}var R={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]},F=["","","","","","","","","","+","-","*","/","^","=","<>","<=",">=","<",">","","","","","&","","","","","","",""];function z(q,J){fi(q,0);for(var ae=[],oe=0,le="",be="",Z="",Le="";q.l<q.length;){var Pe=q[q.l++];switch(Pe){case 0:ae.push(q.read_shift(8,"f"));break;case 1:be=M(J[0].c,q.read_shift(2),!0),le=M(J[0].r,q.read_shift(2),!1),ae.push(be+le);break;case 2:{var Be=M(J[0].c,q.read_shift(2),!0),pe=M(J[0].r,q.read_shift(2),!1);be=M(J[0].c,q.read_shift(2),!0),le=M(J[0].r,q.read_shift(2),!1),ae.push(Be+pe+":"+be+le)}break;case 3:if(q.l<q.length){console.error("WK1 premature formula end");return}break;case 4:ae.push("("+ae.pop()+")");break;case 5:ae.push(q.read_shift(2));break;case 6:{for(var rt="";Pe=q[q.l++];)rt+=String.fromCharCode(Pe);ae.push('"'+rt.replace(/"/g,'""')+'"')}break;case 8:ae.push("-"+ae.pop());break;case 23:ae.push("+"+ae.pop());break;case 22:ae.push("NOT("+ae.pop()+")");break;case 20:case 21:Le=ae.pop(),Z=ae.pop(),ae.push(["AND","OR"][Pe-20]+"("+Z+","+Le+")");break;default:if(Pe<32&&F[Pe])Le=ae.pop(),Z=ae.pop(),ae.push(Z+F[Pe]+Le);else if(R[Pe]){if(oe=R[Pe][1],oe==69&&(oe=q[q.l++]),oe>ae.length){console.error("WK1 bad formula parse 0x"+Pe.toString(16)+":|"+ae.join("|")+"|");return}var ct=ae.slice(-oe);ae.length-=oe,ae.push(R[Pe][0]+"("+ct.join(",")+")")}else return Pe<=7?console.error("WK1 invalid opcode "+Pe.toString(16)):Pe<=24?console.error("WK1 unsupported op "+Pe.toString(16)):Pe<=30?console.error("WK1 invalid opcode "+Pe.toString(16)):Pe<=115?console.error("WK1 unsupported function opcode "+Pe.toString(16)):console.error("WK1 unrecognized opcode "+Pe.toString(16))}}ae.length==1?J[1].f=""+ae[0]:console.error("WK1 bad formula parse |"+ae.join("|")+"|")}function W(q){var J=[{c:0,r:0},{t:"n",v:0},0];return J[0].r=q.read_shift(2),J[3]=q[q.l++],J[0].c=q[q.l++],J}function X(q,J){var ae=W(q);return ae[1].t="s",ae[1].v=q.read_shift(J-4,"cstr"),ae}function B(q,J,ae,oe){var le=sr(6+oe.length);le.write_shift(2,q),le.write_shift(1,ae),le.write_shift(1,J),le.write_shift(1,39);for(var be=0;be<oe.length;++be){var Z=oe.charCodeAt(be);le.write_shift(1,Z>=128?95:Z)}return le.write_shift(1,0),le}function Y(q,J){var ae=W(q);ae[1].v=q.read_shift(2);var oe=ae[1].v>>1;if(ae[1].v&1)switch(oe&7){case 0:oe=(oe>>3)*5e3;break;case 1:oe=(oe>>3)*500;break;case 2:oe=(oe>>3)/20;break;case 3:oe=(oe>>3)/200;break;case 4:oe=(oe>>3)/2e3;break;case 5:oe=(oe>>3)/2e4;break;case 6:oe=(oe>>3)/16;break;case 7:oe=(oe>>3)/64;break}return ae[1].v=oe,ae}function G(q,J){var ae=W(q),oe=q.read_shift(4),le=q.read_shift(4),be=q.read_shift(2);if(be==65535)return oe===0&&le===3221225472?(ae[1].t="e",ae[1].v=15):oe===0&&le===3489660928?(ae[1].t="e",ae[1].v=42):ae[1].v=0,ae;var Z=be&32768;return be=(be&32767)-16446,ae[1].v=(1-Z*2)*(le*Math.pow(2,be+32)+oe*Math.pow(2,be)),ae}function ie(q,J,ae,oe){var le=sr(14);if(le.write_shift(2,q),le.write_shift(1,ae),le.write_shift(1,J),oe==0)return le.write_shift(4,0),le.write_shift(4,0),le.write_shift(2,65535),le;var be=0,Z=0,Le=0,Pe=0;return oe<0&&(be=1,oe=-oe),Z=Math.log2(oe)|0,oe/=Math.pow(2,Z-31),Pe=oe>>>0,(Pe&2147483648)==0&&(oe/=2,++Z,Pe=oe>>>0),oe-=Pe,Pe|=2147483648,Pe>>>=0,oe*=Math.pow(2,32),Le=oe>>>0,le.write_shift(4,Le),le.write_shift(4,Pe),Z+=16383+(be?32768:0),le.write_shift(2,Z),le}function fe(q,J){var ae=G(q);return q.l+=J-14,ae}function K(q,J){var ae=W(q),oe=q.read_shift(4);return ae[1].v=oe>>6,ae}function ke(q,J){var ae=W(q),oe=q.read_shift(8,"f");return ae[1].v=oe,ae}function ge(q,J){var ae=ke(q);return q.l+=J-10,ae}function re(q,J){return q[q.l+J-1]==0?q.read_shift(J,"cstr"):""}function we(q,J){var ae=q[q.l++];ae>J-1&&(ae=J-1);for(var oe="";oe.length<ae;)oe+=String.fromCharCode(q[q.l++]);return oe}function ee(q,J,ae){if(!(!ae.qpro||J<21)){var oe=q.read_shift(1);q.l+=17,q.l+=1,q.l+=2;var le=q.read_shift(J-21,"cstr");return[oe,le]}}function ve(q,J){for(var ae={},oe=q.l+J;q.l<oe;){var le=q.read_shift(2);if(le==14e3){for(ae[le]=[0,""],ae[le][0]=q.read_shift(2);q[q.l];)ae[le][1]+=String.fromCharCode(q[q.l]),q.l++;q.l++}}return ae}function ce(q,J){var ae=sr(5+q.length);ae.write_shift(2,14e3),ae.write_shift(2,J);for(var oe=0;oe<q.length;++oe){var le=q.charCodeAt(oe);ae[ae.l++]=le>127?95:le}return ae[ae.l++]=0,ae}var ye={0:{n:"BOF",f:Nn},1:{n:"EOF"},2:{n:"CALCMODE"},3:{n:"CALCORDER"},4:{n:"SPLIT"},5:{n:"SYNC"},6:{n:"RANGE",f:u},7:{n:"WINDOW1"},8:{n:"COLW1"},9:{n:"WINTWO"},10:{n:"COLW2"},11:{n:"NAME"},12:{n:"BLANK"},13:{n:"INTEGER",f:E},14:{n:"NUMBER",f:A},15:{n:"LABEL",f:y},16:{n:"FORMULA",f:O},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:y},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:re},222:{n:"SHEETNAMELP",f:we},65535:{n:""}},te={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:X},23:{n:"NUMBER17",f:G},24:{n:"NUMBER18",f:Y},25:{n:"FORMULA19",f:fe},26:{n:"FORMULA1A"},27:{n:"XFORMAT",f:ve},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:K},38:{n:"??"},39:{n:"NUMBER27",f:ke},40:{n:"FORMULA28",f:ge},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:re},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:ee},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}})();function kO(e){var r={},a=e.match(Ti),s=0,n=!1;if(a)for(;s!=a.length;++s){var i=ia(a[s]);switch(i[0].replace(/\w*:/g,"")){case"<condense":break;case"<extend":break;case"<shadow":if(!i.val)break;case"<shadow>":case"<shadow/>":r.shadow=1;break;case"</shadow>":break;case"<charset":if(i.val=="1")break;r.cp=hy[parseInt(i.val,10)];break;case"<outline":if(!i.val)break;case"<outline>":case"<outline/>":r.outline=1;break;case"</outline>":break;case"<rFont":r.name=i.val;break;case"<sz":r.sz=i.val;break;case"<strike":if(!i.val)break;case"<strike>":case"<strike/>":r.strike=1;break;case"</strike>":break;case"<u":if(!i.val)break;switch(i.val){case"double":r.uval="double";break;case"singleAccounting":r.uval="single-accounting";break;case"doubleAccounting":r.uval="double-accounting";break}case"<u>":case"<u/>":r.u=1;break;case"</u>":break;case"<b":if(i.val=="0")break;case"<b>":case"<b/>":r.b=1;break;case"</b>":break;case"<i":if(i.val=="0")break;case"<i>":case"<i/>":r.i=1;break;case"</i>":break;case"<color":i.rgb&&(r.color=i.rgb.slice(2,8));break;case"<color>":case"<color/>":case"</color>":break;case"<family":r.family=i.val;break;case"<family>":case"<family/>":case"</family>":break;case"<vertAlign":r.valign=i.val;break;case"<vertAlign>":case"<vertAlign/>":case"</vertAlign>":break;case"<scheme":break;case"<scheme>":case"<scheme/>":case"</scheme>":break;case"<extLst":case"<extLst>":case"</extLst>":break;case"<ext":n=!0;break;case"</ext>":n=!1;break;default:if(i[0].charCodeAt(1)!==47&&!n)throw new Error("Unrecognized rich format "+i[0])}}return r}var NO=(function(){var e=Ef("t"),r=Ef("rPr");function a(i){var c=i.match(e);if(!c)return{t:"s",v:""};var u={t:"s",v:Ha(c[1])},h=i.match(r);return h&&(u.s=kO(h[1])),u}var s=/<(?:\w+:)?r>/g,n=/<\/(?:\w+:)?r>/;return function(c){return c.replace(s,"").split(n).map(a).filter(function(u){return u.v})}})(),jO=(function(){var r=/(\r\n|\n)/g;function a(n,i,c){var u=[];n.u&&u.push("text-decoration: underline;"),n.uval&&u.push("text-underline-style:"+n.uval+";"),n.sz&&u.push("font-size:"+n.sz+"pt;"),n.outline&&u.push("text-effect: outline;"),n.shadow&&u.push("text-shadow: auto;"),i.push('<span style="'+u.join("")+'">'),n.b&&(i.push("<b>"),c.push("</b>")),n.i&&(i.push("<i>"),c.push("</i>")),n.strike&&(i.push("<s>"),c.push("</s>"));var h=n.valign||"";return h=="superscript"||h=="super"?h="sup":h=="subscript"&&(h="sub"),h!=""&&(i.push("<"+h+">"),c.push("</"+h+">")),c.push("</span>"),n}function s(n){var i=[[],n.v,[]];return n.v?(n.s&&a(n.s,i[0],i[2]),i[0].join("")+i[1].replace(r,"<br/>")+i[2].join("")):""}return function(i){return i.map(s).join("")}})(),SO=/<(?:\w+:)?t[^>]*>([^<]*)<\/(?:\w+:)?t>/g,CO=/<(?:\w+:)?r>/,EO=/<(?:\w+:)?rPh.*?>([\s\S]*?)<\/(?:\w+:)?rPh>/g;function Py(e,r){var a=r?r.cellHTML:!0,s={};return e?(e.match(/^\s*<(?:\w+:)?t[^>]*>/)?(s.t=Ha(ms(e.slice(e.indexOf(">")+1).split(/<\/(?:\w+:)?t>/)[0]||"")),s.r=ms(e),a&&(s.h=ky(s.t))):e.match(CO)&&(s.r=ms(e),s.t=Ha(ms((e.replace(EO,"").match(SO)||[]).join("").replace(Ti,""))),a&&(s.h=jO(NO(s.r)))),s):{t:""}}var TO=/<(?:\w+:)?sst([^>]*)>([\s\S]*)<\/(?:\w+:)?sst>/,AO=/<(?:\w+:)?(?:si|sstItem)>/g,OO=/<\/(?:\w+:)?(?:si|sstItem)>/;function DO(e,r){var a=[],s="";if(!e)return a;var n=e.match(TO);if(n){s=n[2].replace(AO,"").split(OO);for(var i=0;i!=s.length;++i){var c=Py(s[i].trim(),r);c!=null&&(a[a.length]=c)}n=ia(n[1]),a.Count=n.count,a.Unique=n.uniqueCount}return a}var RO=/^\s|\s$|[\t\n\r]/;function wN(e,r){if(!r.bookSST)return"";var a=[cn];a[a.length]=kr("sst",null,{xmlns:Vd[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(RO)&&(i+=' xml:space="preserve"'),i+=">"+ls(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 FO(e){return[e.read_shift(4),e.read_shift(4)]}function IO(e,r){var a=[],s=!1;return mc(e,function(i,c,u){switch(u){case 159:a.Count=i[0],a.Unique=i[1];break;case 19:a.push(i);break;case 160:return!0;case 35:s=!0;break;case 36:s=!1;break;default:if(c.T,!s||r.WTF)throw new Error("Unexpected record 0x"+u.toString(16))}}),a}function MO(e,r){return r||(r=sr(8)),r.write_shift(4,e.Count),r.write_shift(4,e.Unique),r}var PO=YA;function LO(e){var r=ro();mr(r,159,MO(e));for(var a=0;a<e.length;++a)mr(r,19,PO(e[a]));return mr(r,160),r.end()}function _N(e){for(var r=[],a=e.split(""),s=0;s<a.length;++s)r[s]=a[s].charCodeAt(0);return r}function cc(e,r){var a={};return a.Major=e.read_shift(2),a.Minor=e.read_shift(2),r>=4&&(e.l+=r-4),a}function BO(e){var r={};return r.id=e.read_shift(0,"lpp4"),r.R=cc(e,4),r.U=cc(e,4),r.W=cc(e,4),r}function UO(e){for(var r=e.read_shift(4),a=e.l+r-4,s={},n=e.read_shift(4),i=[];n-- >0;)i.push({t:e.read_shift(4),v:e.read_shift(0,"lpp4")});if(s.name=e.read_shift(0,"lpp4"),s.comps=i,e.l!=a)throw new Error("Bad DataSpaceMapEntry: "+e.l+" != "+a);return s}function zO(e){var r=[];e.l+=4;for(var a=e.read_shift(4);a-- >0;)r.push(UO(e));return r}function WO(e){var r=[];e.l+=4;for(var a=e.read_shift(4);a-- >0;)r.push(e.read_shift(0,"lpp4"));return r}function HO(e){var r={};return e.read_shift(4),e.l+=4,r.id=e.read_shift(0,"lpp4"),r.name=e.read_shift(0,"lpp4"),r.R=cc(e,4),r.U=cc(e,4),r.W=cc(e,4),r}function $O(e){var r=HO(e);if(r.ename=e.read_shift(0,"8lpp4"),r.blksz=e.read_shift(4),r.cmode=e.read_shift(4),e.read_shift(4)!=4)throw new Error("Bad !Primary record");return r}function kN(e,r){var a=e.l+r,s={};s.Flags=e.read_shift(4)&63,e.l+=4,s.AlgID=e.read_shift(4);var n=!1;switch(s.AlgID){case 26126:case 26127:case 26128:n=s.Flags==36;break;case 26625:n=s.Flags==4;break;case 0:n=s.Flags==16||s.Flags==4||s.Flags==36;break;default:throw"Unrecognized encryption algorithm: "+s.AlgID}if(!n)throw new Error("Encryption Flags/AlgID mismatch");return s.AlgIDHash=e.read_shift(4),s.KeySize=e.read_shift(4),s.ProviderType=e.read_shift(4),e.l+=8,s.CSPName=e.read_shift(a-e.l>>1,"utf16le"),e.l=a,s}function NN(e,r){var a={},s=e.l+r;return e.l+=4,a.Salt=e.slice(e.l,e.l+16),e.l+=16,a.Verifier=e.slice(e.l,e.l+16),e.l+=16,e.read_shift(4),a.VerifierHash=e.slice(e.l,s),e.l=s,a}function VO(e){var r=cc(e);switch(r.Minor){case 2:return[r.Minor,GO(e)];case 3:return[r.Minor,YO()];case 4:return[r.Minor,qO(e)]}throw new Error("ECMA-376 Encrypted file unrecognized Version: "+r.Minor)}function GO(e){var r=e.read_shift(4);if((r&63)!=36)throw new Error("EncryptionInfo mismatch");var a=e.read_shift(4),s=kN(e,a),n=NN(e,e.length-e.l);return{t:"Std",h:s,v:n}}function YO(){throw new Error("File is password-protected: ECMA-376 Extensible")}function qO(e){var r=["saltSize","blockSize","keyBits","hashSize","cipherAlgorithm","cipherChaining","hashAlgorithm","saltValue"];e.l+=4;var a=e.read_shift(e.length-e.l,"utf8"),s={};return a.replace(Ti,function(i){var c=ia(i);switch(Ml(c[0])){case"<?xml":break;case"<encryption":case"</encryption>":break;case"<keyData":r.forEach(function(u){s[u]=c[u]});break;case"<dataIntegrity":s.encryptedHmacKey=c.encryptedHmacKey,s.encryptedHmacValue=c.encryptedHmacValue;break;case"<keyEncryptors>":case"<keyEncryptors":s.encs=[];break;case"</keyEncryptors>":break;case"<keyEncryptor":s.uri=c.uri;break;case"</keyEncryptor>":break;case"<encryptedKey":s.encs.push(c);break;default:throw c[0]}}),s}function XO(e,r){var a={},s=a.EncryptionVersionInfo=cc(e,4);if(r-=4,s.Minor!=2)throw new Error("unrecognized minor version code: "+s.Minor);if(s.Major>4||s.Major<2)throw new Error("unrecognized major version code: "+s.Major);a.Flags=e.read_shift(4),r-=4;var n=e.read_shift(4);return r-=4,a.EncryptionHeader=kN(e,n),r-=n,a.EncryptionVerifier=NN(e,r),a}function ZO(e){var r={},a=r.EncryptionVersionInfo=cc(e,4);if(a.Major!=1||a.Minor!=1)throw"unrecognized version code "+a.Major+" : "+a.Minor;return r.Salt=e.read_shift(16),r.EncryptedVerifier=e.read_shift(16),r.EncryptedVerifierHash=e.read_shift(16),r}function Ly(e){var r=0,a,s=_N(e),n=s.length+1,i,c,u,h,g;for(a=Gc(n),a[0]=s.length,i=1;i!=n;++i)a[i]=s[i-1];for(i=n-1;i>=0;--i)c=a[i],u=(r&16384)===0?0:1,h=r<<1&32767,g=u|h,r=g^c;return r^52811}var jN=(function(){var e=[187,255,255,186,255,255,185,128,0,190,15,0,191,15,0],r=[57840,7439,52380,33984,4364,3600,61902,12606,6258,57657,54287,34041,10252,43370,20163],a=[44796,19929,39858,10053,20106,40212,10761,31585,63170,64933,60267,50935,40399,11199,17763,35526,1453,2906,5812,11624,23248,885,1770,3540,7080,14160,28320,56640,55369,41139,20807,41614,21821,43642,17621,28485,56970,44341,19019,38038,14605,29210,60195,50791,40175,10751,21502,43004,24537,18387,36774,3949,7898,15796,31592,63184,47201,24803,49606,37805,14203,28406,56812,17824,35648,1697,3394,6788,13576,27152,43601,17539,35078,557,1114,2228,4456,30388,60776,51953,34243,7079,14158,28316,14128,28256,56512,43425,17251,34502,7597,13105,26210,52420,35241,883,1766,3532,4129,8258,16516,33032,4657,9314,18628],s=function(c){return(c/2|c*128)&255},n=function(c,u){return s(c^u)},i=function(c){for(var u=r[c.length-1],h=104,g=c.length-1;g>=0;--g)for(var y=c[g],w=0;w!=7;++w)y&64&&(u^=a[h]),y*=2,--h;return u};return function(c){for(var u=_N(c),h=i(u),g=u.length,y=Gc(16),w=0;w!=16;++w)y[w]=0;var E,S,A;for((g&1)===1&&(E=h>>8,y[g]=n(e[0],E),--g,E=h&255,S=u[u.length-1],y[g]=n(S,E));g>0;)--g,E=h>>8,y[g]=n(u[g],E),--g,E=h&255,y[g]=n(u[g],E);for(g=15,A=15-u.length;A>0;)E=h>>8,y[g]=n(e[A],E),--g,--A,E=h&255,y[g]=n(u[g],E),--g,--A;return y}})(),KO=function(e,r,a,s,n){n||(n=r),s||(s=jN(e));var i,c;for(i=0;i!=r.length;++i)c=r[i],c^=s[a],c=(c>>5|c<<3)&255,n[i]=c,++a;return[n,a,s]},JO=function(e){var r=0,a=jN(e);return function(s){var n=KO("",s,r,a);return r=n[1],n[0]}};function QO(e,r,a,s){var n={key:Nn(e),verificationBytes:Nn(e)};return a.password&&(n.verifier=Ly(a.password)),s.valid=n.verificationBytes===n.verifier,s.valid&&(s.insitu=JO(a.password)),n}function eD(e,r,a){var s=a||{};return s.Info=e.read_shift(2),e.l-=2,s.Info===1?s.Data=ZO(e):s.Data=XO(e,r),s}function tD(e,r,a){var s={Type:a.biff>=8?e.read_shift(2):0};return s.Type?eD(e,r-2,s):QO(e,a.biff>=8?r:r-2,a,s),s}var SN=(function(){function e(n,i){switch(i.type){case"base64":return r(ko(n),i);case"binary":return r(n,i);case"buffer":return r(Ca&&Buffer.isBuffer(n)?n.toString("binary"):Zc(n),i);case"array":return r(Ld(n),i)}throw new Error("Unrecognized type "+i.type)}function r(n,i){var c=i||{},u=c.dense?[]:{},h=n.match(/\\trowd.*?\\row\b/g);if(!h.length)throw new Error("RTF missing table");var g={s:{c:0,r:0},e:{c:0,r:h.length-1}};return h.forEach(function(y,w){Array.isArray(u)&&(u[w]=[]);for(var E=/\\\w+\b/g,S=0,A,C=-1;A=E.exec(y);){switch(A[0]){case"\\cell":var O=y.slice(S,E.lastIndex-A[0].length);if(O[0]==" "&&(O=O.slice(1)),++C,O.length){var M={v:O,t:"s"};Array.isArray(u)?u[w][C]=M:u[sa({r:w,c:C})]=M}break}S=E.lastIndex}C>g.e.c&&(g.e.c=C)}),u["!ref"]=ba(g),u}function a(n,i){return Kc(e(n,i),i)}function s(n){for(var i=["{\\rtf1\\ansi"],c=$a(n["!ref"]),u,h=Array.isArray(n),g=c.s.r;g<=c.e.r;++g){i.push("\\trowd\\trautofit1");for(var y=c.s.c;y<=c.e.c;++y)i.push("\\cellx"+(y+1));for(i.push("\\pard\\intbl"),y=c.s.c;y<=c.e.c;++y){var w=sa({r:g,c:y});u=h?(n[g]||[])[y]:n[w],!(!u||u.v==null&&(!u.f||u.F))&&(i.push(" "+(u.w||(uc(u),u.w))),i.push("\\cell"))}i.push("\\pard\\intbl\\row")}return i.join("")+"}"}return{to_workbook:a,to_sheet:e,from_sheet:s}})();function rD(e){var r=e.slice(e[0]==="#"?1:0).slice(0,6);return[parseInt(r.slice(0,2),16),parseInt(r.slice(2,4),16),parseInt(r.slice(4,6),16)]}function Df(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)}function aD(e){var r=e[0]/255,a=e[1]/255,s=e[2]/255,n=Math.max(r,a,s),i=Math.min(r,a,s),c=n-i;if(c===0)return[0,0,r];var u=0,h=0,g=n+i;switch(h=c/(g>1?2-g:g),n){case r:u=((a-s)/c+6)%6;break;case a:u=(s-r)/c+2;break;case s:u=(r-a)/c+4;break}return[u/6,h,g/2]}function sD(e){var r=e[0],a=e[1],s=e[2],n=a*2*(s<.5?s:1-s),i=s-n/2,c=[i,i,i],u=6*r,h;if(a!==0)switch(u|0){case 0:case 6:h=n*u,c[0]+=n,c[1]+=h;break;case 1:h=n*(2-u),c[0]+=h,c[1]+=n;break;case 2:h=n*(u-2),c[1]+=n,c[2]+=h;break;case 3:h=n*(4-u),c[1]+=h,c[2]+=n;break;case 4:h=n*(u-4),c[2]+=n,c[0]+=h;break;case 5:h=n*(6-u),c[2]+=h,c[0]+=n;break}for(var g=0;g!=3;++g)c[g]=Math.round(c[g]*255);return c}function ag(e,r){if(r===0)return e;var a=aD(rD(e));return r<0?a[2]=a[2]*(1+r):a[2]=1-(1-a[2])*(1-r),Df(sD(a))}var CN=6,nD=15,iD=1,Ni=CN;function Rf(e){return Math.floor((e+Math.round(128/Ni)/256)*Ni)}function Ff(e){return Math.floor((e-5)/Ni*100+.5)/100}function sg(e){return Math.round((e*Ni+5)/Ni*256)/256}function Vp(e){return sg(Ff(Rf(e)))}function By(e){var r=Math.abs(e-Vp(e)),a=Ni;if(r>.005)for(Ni=iD;Ni<nD;++Ni)Math.abs(e-Vp(e))<=r&&(r=Math.abs(e-Vp(e)),a=Ni);Ni=a}function Yc(e){e.width?(e.wpx=Rf(e.width),e.wch=Ff(e.wpx),e.MDW=Ni):e.wpx?(e.wch=Ff(e.wpx),e.width=sg(e.wch),e.MDW=Ni):typeof e.wch=="number"&&(e.width=sg(e.wch),e.wpx=Rf(e.width),e.MDW=Ni),e.customWidth&&delete e.customWidth}var oD=96,EN=oD;function If(e){return e*96/EN}function X0(e){return e*EN/96}var lD={None:"none",Solid:"solid",Gray50:"mediumGray",Gray75:"darkGray",Gray25:"lightGray",HorzStripe:"darkHorizontal",VertStripe:"darkVertical",ReverseDiagStripe:"darkDown",DiagStripe:"darkUp",DiagCross:"darkGrid",ThickDiagCross:"darkTrellis",ThinHorzStripe:"lightHorizontal",ThinVertStripe:"lightVertical",ThinReverseDiagStripe:"lightDown",ThinHorzCross:"lightGrid"};function cD(e,r,a,s){r.Borders=[];var n={},i=!1;(e[0].match(Ti)||[]).forEach(function(c){var u=ia(c);switch(Ml(u[0])){case"<borders":case"<borders>":case"</borders>":break;case"<border":case"<border>":case"<border/>":n={},u.diagonalUp&&(n.diagonalUp=Ss(u.diagonalUp)),u.diagonalDown&&(n.diagonalDown=Ss(u.diagonalDown)),r.Borders.push(n);break;case"</border>":break;case"<left/>":break;case"<left":case"<left>":break;case"</left>":break;case"<right/>":break;case"<right":case"<right>":break;case"</right>":break;case"<top/>":break;case"<top":case"<top>":break;case"</top>":break;case"<bottom/>":break;case"<bottom":case"<bottom>":break;case"</bottom>":break;case"<diagonal":case"<diagonal>":case"<diagonal/>":break;case"</diagonal>":break;case"<horizontal":case"<horizontal>":case"<horizontal/>":break;case"</horizontal>":break;case"<vertical":case"<vertical>":case"<vertical/>":break;case"</vertical>":break;case"<start":case"<start>":case"<start/>":break;case"</start>":break;case"<end":case"<end>":case"<end/>":break;case"</end>":break;case"<color":case"<color>":break;case"<color/>":case"</color>":break;case"<extLst":case"<extLst>":case"</extLst>":break;case"<ext":i=!0;break;case"</ext>":i=!1;break;default:if(s&&s.WTF&&!i)throw new Error("unrecognized "+u[0]+" in borders")}})}function dD(e,r,a,s){r.Fills=[];var n={},i=!1;(e[0].match(Ti)||[]).forEach(function(c){var u=ia(c);switch(Ml(u[0])){case"<fills":case"<fills>":case"</fills>":break;case"<fill>":case"<fill":case"<fill/>":n={},r.Fills.push(n);break;case"</fill>":break;case"<gradientFill>":break;case"<gradientFill":case"</gradientFill>":r.Fills.push(n),n={};break;case"<patternFill":case"<patternFill>":u.patternType&&(n.patternType=u.patternType);break;case"<patternFill/>":case"</patternFill>":break;case"<bgColor":n.bgColor||(n.bgColor={}),u.indexed&&(n.bgColor.indexed=parseInt(u.indexed,10)),u.theme&&(n.bgColor.theme=parseInt(u.theme,10)),u.tint&&(n.bgColor.tint=parseFloat(u.tint)),u.rgb&&(n.bgColor.rgb=u.rgb.slice(-6));break;case"<bgColor/>":case"</bgColor>":break;case"<fgColor":n.fgColor||(n.fgColor={}),u.theme&&(n.fgColor.theme=parseInt(u.theme,10)),u.tint&&(n.fgColor.tint=parseFloat(u.tint)),u.rgb!=null&&(n.fgColor.rgb=u.rgb.slice(-6));break;case"<fgColor/>":case"</fgColor>":break;case"<stop":case"<stop/>":break;case"</stop>":break;case"<color":case"<color/>":break;case"</color>":break;case"<extLst":case"<extLst>":case"</extLst>":break;case"<ext":i=!0;break;case"</ext>":i=!1;break;default:if(s&&s.WTF&&!i)throw new Error("unrecognized "+u[0]+" in fills")}})}function uD(e,r,a,s){r.Fonts=[];var n={},i=!1;(e[0].match(Ti)||[]).forEach(function(c){var u=ia(c);switch(Ml(u[0])){case"<fonts":case"<fonts>":case"</fonts>":break;case"<font":case"<font>":break;case"</font>":case"<font/>":r.Fonts.push(n),n={};break;case"<name":u.val&&(n.name=ms(u.val));break;case"<name/>":case"</name>":break;case"<b":n.bold=u.val?Ss(u.val):1;break;case"<b/>":n.bold=1;break;case"<i":n.italic=u.val?Ss(u.val):1;break;case"<i/>":n.italic=1;break;case"<u":switch(u.val){case"none":n.underline=0;break;case"single":n.underline=1;break;case"double":n.underline=2;break;case"singleAccounting":n.underline=33;break;case"doubleAccounting":n.underline=34;break}break;case"<u/>":n.underline=1;break;case"<strike":n.strike=u.val?Ss(u.val):1;break;case"<strike/>":n.strike=1;break;case"<outline":n.outline=u.val?Ss(u.val):1;break;case"<outline/>":n.outline=1;break;case"<shadow":n.shadow=u.val?Ss(u.val):1;break;case"<shadow/>":n.shadow=1;break;case"<condense":n.condense=u.val?Ss(u.val):1;break;case"<condense/>":n.condense=1;break;case"<extend":n.extend=u.val?Ss(u.val):1;break;case"<extend/>":n.extend=1;break;case"<sz":u.val&&(n.sz=+u.val);break;case"<sz/>":case"</sz>":break;case"<vertAlign":u.val&&(n.vertAlign=u.val);break;case"<vertAlign/>":case"</vertAlign>":break;case"<family":u.val&&(n.family=parseInt(u.val,10));break;case"<family/>":case"</family>":break;case"<scheme":u.val&&(n.scheme=u.val);break;case"<scheme/>":case"</scheme>":break;case"<charset":if(u.val=="1")break;u.codepage=hy[parseInt(u.val,10)];break;case"<color":if(n.color||(n.color={}),u.auto&&(n.color.auto=Ss(u.auto)),u.rgb)n.color.rgb=u.rgb.slice(-6);else if(u.indexed){n.color.index=parseInt(u.indexed,10);var h=Cd[n.color.index];n.color.index==81&&(h=Cd[1]),h||(h=Cd[1]),n.color.rgb=h[0].toString(16)+h[1].toString(16)+h[2].toString(16)}else u.theme&&(n.color.theme=parseInt(u.theme,10),u.tint&&(n.color.tint=parseFloat(u.tint)),u.theme&&a.themeElements&&a.themeElements.clrScheme&&(n.color.rgb=ag(a.themeElements.clrScheme[n.color.theme].rgb,n.color.tint||0)));break;case"<color/>":case"</color>":break;case"<AlternateContent":i=!0;break;case"</AlternateContent>":i=!1;break;case"<extLst":case"<extLst>":case"</extLst>":break;case"<ext":i=!0;break;case"</ext>":i=!1;break;default:if(s&&s.WTF&&!i)throw new Error("unrecognized "+u[0]+" in fonts")}})}function fD(e,r,a){r.NumberFmt=[];for(var s=Qs(aa),n=0;n<s.length;++n)r.NumberFmt[s[n]]=aa[s[n]];var i=e[0].match(Ti);if(i)for(n=0;n<i.length;++n){var c=ia(i[n]);switch(Ml(c[0])){case"<numFmts":case"</numFmts>":case"<numFmts/>":case"<numFmts>":break;case"<numFmt":{var u=Ha(ms(c.formatCode)),h=parseInt(c.numFmtId,10);if(r.NumberFmt[h]=u,h>0){if(h>392){for(h=392;h>60&&r.NumberFmt[h]!=null;--h);r.NumberFmt[h]=u}lc(u,h)}}break;case"</numFmt>":break;default:if(a.WTF)throw new Error("unrecognized "+c[0]+" in numFmts")}}}function hD(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]=kr("numFmt",null,{numFmtId:s,formatCode:ls(e[s])}))}),r.length===1?"":(r[r.length]="</numFmts>",r[0]=kr("numFmts",null,{count:r.length-2}).replace("/>",">"),r.join(""))}var hm=["numFmtId","fillId","fontId","borderId","xfId"],mm=["applyAlignment","applyBorder","applyFill","applyFont","applyNumberFormat","applyProtection","pivotButton","quotePrefix"];function mD(e,r,a){r.CellXf=[];var s,n=!1;(e[0].match(Ti)||[]).forEach(function(i){var c=ia(i),u=0;switch(Ml(c[0])){case"<cellXfs":case"<cellXfs>":case"<cellXfs/>":case"</cellXfs>":break;case"<xf":case"<xf/>":for(s=c,delete s[0],u=0;u<hm.length;++u)s[hm[u]]&&(s[hm[u]]=parseInt(s[hm[u]],10));for(u=0;u<mm.length;++u)s[mm[u]]&&(s[mm[u]]=Ss(s[mm[u]]));if(r.NumberFmt&&s.numFmtId>392){for(u=392;u>60;--u)if(r.NumberFmt[s.numFmtId]==r.NumberFmt[u]){s.numFmtId=u;break}}r.CellXf.push(s);break;case"</xf>":break;case"<alignment":case"<alignment/>":var h={};c.vertical&&(h.vertical=c.vertical),c.horizontal&&(h.horizontal=c.horizontal),c.textRotation!=null&&(h.textRotation=c.textRotation),c.indent&&(h.indent=c.indent),c.wrapText&&(h.wrapText=Ss(c.wrapText)),s.alignment=h;break;case"</alignment>":break;case"<protection":break;case"</protection>":case"<protection/>":break;case"<AlternateContent":n=!0;break;case"</AlternateContent>":n=!1;break;case"<extLst":case"<extLst>":case"</extLst>":break;case"<ext":n=!0;break;case"</ext>":n=!1;break;default:if(a&&a.WTF&&!n)throw new Error("unrecognized "+c[0]+" in cellXfs")}})}function gD(e){var r=[];return r[r.length]=kr("cellXfs",null),e.forEach(function(a){r[r.length]=kr("xf",null,a)}),r[r.length]="</cellXfs>",r.length===2?"":(r[0]=kr("cellXfs",null,{count:r.length-2}).replace("/>",">"),r.join(""))}var xD=(function(){var r=/<(?:\w+:)?numFmts([^>]*)>[\S\s]*?<\/(?:\w+:)?numFmts>/,a=/<(?:\w+:)?cellXfs([^>]*)>[\S\s]*?<\/(?:\w+:)?cellXfs>/,s=/<(?:\w+:)?fills([^>]*)>[\S\s]*?<\/(?:\w+:)?fills>/,n=/<(?:\w+:)?fonts([^>]*)>[\S\s]*?<\/(?:\w+:)?fonts>/,i=/<(?:\w+:)?borders([^>]*)>[\S\s]*?<\/(?:\w+:)?borders>/;return function(u,h,g){var y={};if(!u)return y;u=u.replace(/<!--([\s\S]*?)-->/mg,"").replace(/<!DOCTYPE[^\[]*\[[^\]]*\]>/gm,"");var w;return(w=u.match(r))&&fD(w,y,g),(w=u.match(n))&&uD(w,y,h,g),(w=u.match(s))&&dD(w,y,h,g),(w=u.match(i))&&cD(w,y,h,g),(w=u.match(a))&&mD(w,y,g),y}})();function TN(e,r){var a=[cn,kr("styleSheet",null,{xmlns:Vd[0],"xmlns:vt":Fn.vt})],s;return e.SSF&&(s=hD(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=gD(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 pD(e,r){var a=e.read_shift(2),s=Ci(e);return[a,s]}function yD(e,r,a){a||(a=sr(6+4*r.length)),a.write_shift(2,e),Xn(r,a);var s=a.length>a.l?a.slice(0,a.l):a;return a.l==null&&(a.l=a.length),s}function bD(e,r,a){var s={};s.sz=e.read_shift(2)/20;var n=e7(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 c=e.read_shift(1);c!=0&&(s.underline=c);var u=e.read_shift(1);u>0&&(s.family=u);var h=e.read_shift(1);switch(h>0&&(s.charset=h),e.l++,s.color=QA(e),e.read_shift(1)){case 1:s.scheme="major";break;case 2:s.scheme="minor";break}return s.name=Ci(e),s}function vD(e,r){r||(r=sr(153)),r.write_shift(2,e.sz*20),t7(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),eg(e.color,r);var s=0;return s=2,r.write_shift(1,s),Xn(e.name,r),r.length>r.l?r.slice(0,r.l):r}var wD=["none","solid","mediumGray","darkGray","lightGray","darkHorizontal","darkVertical","darkDown","darkUp","darkGrid","darkTrellis","lightHorizontal","lightVertical","lightDown","lightUp","lightGrid","lightTrellis","gray125","gray0625"],Gp,_D=Ei;function tk(e,r){r||(r=sr(84)),Gp||(Gp=bg(wD));var a=Gp[e.patternType];a==null&&(a=40),r.write_shift(4,a);var s=0;if(a!=40)for(eg({auto:1},r),eg({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 kD(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 AN(e,r,a){a||(a=sr(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 Zu(e,r){return r||(r=sr(10)),r.write_shift(1,0),r.write_shift(1,0),r.write_shift(4,0),r.write_shift(4,0),r}var ND=Ei;function jD(e,r){return r||(r=sr(51)),r.write_shift(1,0),Zu(null,r),Zu(null,r),Zu(null,r),Zu(null,r),Zu(null,r),r.length>r.l?r.slice(0,r.l):r}function SD(e,r){return r||(r=sr(52)),r.write_shift(4,e.xfId),r.write_shift(2,1),r.write_shift(1,0),r.write_shift(1,0),Qm(e.name||"",r),r.length>r.l?r.slice(0,r.l):r}function CD(e,r,a){var s=sr(2052);return s.write_shift(4,e),Qm(r,s),Qm(a,s),s.length>s.l?s.slice(0,s.l):s}function ED(e,r,a){var s={};s.NumberFmt=[];for(var n in aa)s.NumberFmt[n]=aa[n];s.CellXf=[],s.Fonts=[];var i=[],c=!1;return mc(e,function(h,g,y){switch(y){case 44:s.NumberFmt[h[0]]=h[1],lc(h[1],h[0]);break;case 43:s.Fonts.push(h),h.color.theme!=null&&r&&r.themeElements&&r.themeElements.clrScheme&&(h.color.rgb=ag(r.themeElements.clrScheme[h.color.theme].rgb,h.color.tint||0));break;case 1025:break;case 45:break;case 46:break;case 47:i[i.length-1]==617&&s.CellXf.push(h);break;case 48:case 507:case 572:case 475:break;case 1171:case 2102:case 1130:case 512:case 2095:case 3072:break;case 35:c=!0;break;case 36:c=!1;break;case 37:i.push(y),c=!0;break;case 38:i.pop(),c=!1;break;default:if(g.T>0)i.push(y);else if(g.T<0)i.pop();else if(!c||a.WTF&&i[i.length-1]!=37)throw new Error("Unexpected record 0x"+y.toString(16))}}),s}function TD(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&&(mr(e,615,dl(a)),[[5,8],[23,26],[41,44],[50,392]].forEach(function(s){for(var n=s[0];n<=s[1];++n)r[n]!=null&&mr(e,44,yD(n,r[n]))}),mr(e,616))}}function AD(e){var r=1;mr(e,611,dl(r)),mr(e,43,vD({sz:12,color:{theme:1},name:"Calibri",family:2})),mr(e,612)}function OD(e){var r=2;mr(e,603,dl(r)),mr(e,45,tk({patternType:"none"})),mr(e,45,tk({patternType:"gray125"})),mr(e,604)}function DD(e){var r=1;mr(e,613,dl(r)),mr(e,46,jD()),mr(e,614)}function RD(e){var r=1;mr(e,626,dl(r)),mr(e,47,AN({numFmtId:0},65535)),mr(e,627)}function FD(e,r){mr(e,617,dl(r.length)),r.forEach(function(a){mr(e,47,AN(a,0))}),mr(e,618)}function ID(e){var r=1;mr(e,619,dl(r)),mr(e,48,SD({xfId:0,name:"Normal"})),mr(e,620)}function MD(e){var r=0;mr(e,505,dl(r)),mr(e,506)}function PD(e){var r=0;mr(e,508,CD(r,"TableStyleMedium9","PivotStyleMedium4")),mr(e,509)}function LD(e,r){var a=ro();return mr(a,278),TD(a,e.SSF),AD(a),OD(a),DD(a),RD(a),FD(a,r.cellXfs),ID(a),MD(a),PD(a),mr(a,279),a.end()}var BD=["</a:lt1>","</a:dk1>","</a:lt2>","</a:dk2>","</a:accent1>","</a:accent2>","</a:accent3>","</a:accent4>","</a:accent5>","</a:accent6>","</a:hlink>","</a:folHlink>"];function UD(e,r,a){r.themeElements.clrScheme=[];var s={};(e[0].match(Ti)||[]).forEach(function(n){var i=ia(n);switch(i[0]){case"<a:clrScheme":case"</a:clrScheme>":break;case"<a:srgbClr":s.rgb=i.val;break;case"<a:sysClr":s.rgb=i.lastClr;break;case"<a:dk1>":case"</a:dk1>":case"<a:lt1>":case"</a:lt1>":case"<a:dk2>":case"</a:dk2>":case"<a:lt2>":case"</a:lt2>":case"<a:accent1>":case"</a:accent1>":case"<a:accent2>":case"</a:accent2>":case"<a:accent3>":case"</a:accent3>":case"<a:accent4>":case"</a:accent4>":case"<a:accent5>":case"</a:accent5>":case"<a:accent6>":case"</a:accent6>":case"<a:hlink>":case"</a:hlink>":case"<a:folHlink>":case"</a:folHlink>":i[0].charAt(1)==="/"?(r.themeElements.clrScheme[BD.indexOf(i[0])]=s,s={}):s.name=i[0].slice(3,i[0].length-1);break;default:if(a&&a.WTF)throw new Error("Unrecognized "+i[0]+" in clrScheme")}})}function zD(){}function WD(){}var HD=/<a:clrScheme([^>]*)>[\s\S]*<\/a:clrScheme>/,$D=/<a:fontScheme([^>]*)>[\s\S]*<\/a:fontScheme>/,VD=/<a:fmtScheme([^>]*)>[\s\S]*<\/a:fmtScheme>/;function GD(e,r,a){r.themeElements={};var s;[["clrScheme",HD,UD],["fontScheme",$D,zD],["fmtScheme",VD,WD]].forEach(function(n){if(!(s=e.match(n[1])))throw new Error(n[0]+" not found in themeElements");n[2](s,r,a)})}var YD=/<a:themeElements([^>]*)>[\s\S]*<\/a:themeElements>/;function ON(e,r){(!e||e.length===0)&&(e=Uy());var a,s={};if(!(a=e.match(YD)))throw new Error("themeElements not found in theme");return GD(a[0],s,r),s.raw=e,s}function Uy(e,r){if(r&&r.themeXLSX)return r.themeXLSX;if(e&&typeof e.raw=="string")return e.raw;var a=[cn];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 qD(e,r,a){var s=e.l+r,n=e.read_shift(4);if(n!==124226){if(!a.cellStyles){e.l=s;return}var i=e.slice(e.l);e.l=s;var c;try{c=k3(i,{type:"array"})}catch(h){return}var u=wo(c,"theme/theme/theme1.xml",!0);if(u)return ON(u,a)}}function XD(e){return e.read_shift(4)}function ZD(e){var r={};switch(r.xclrType=e.read_shift(2),r.nTintShade=e.read_shift(2),r.xclrType){case 0:e.l+=4;break;case 1:r.xclrValue=KD(e,4);break;case 2:r.xclrValue=dN(e);break;case 3:r.xclrValue=XD(e);break;case 4:e.l+=4;break}return e.l+=8,r}function KD(e,r){return Ei(e,r)}function JD(e,r){return Ei(e,r)}function QD(e){var r=e.read_shift(2),a=e.read_shift(2)-4,s=[r];switch(r){case 4:case 5:case 7:case 8:case 9:case 10:case 11:case 13:s[1]=ZD(e);break;case 6:s[1]=JD(e,a);break;case 14:case 15:s[1]=e.read_shift(a===1?1:2);break;default:throw new Error("Unrecognized ExtProp type: "+r+" "+a)}return s}function eR(e,r){var a=e.l+r;e.l+=2;var s=e.read_shift(2);e.l+=2;for(var n=e.read_shift(2),i=[];n-- >0;)i.push(QD(e,a-e.l));return{ixfe:s,ext:i}}function tR(e,r){r.forEach(function(a){a[0]})}function rR(e,r){return{flags:e.read_shift(4),version:e.read_shift(4),name:Ci(e)}}function aR(e){var r=sr(12+2*e.name.length);return r.write_shift(4,e.flags),r.write_shift(4,e.version),Xn(e.name,r),r.slice(0,r.l)}function sR(e){for(var r=[],a=e.read_shift(4);a-- >0;)r.push([e.read_shift(4),e.read_shift(4)]);return r}function nR(e){var r=sr(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 iR(e,r){var a=sr(8+2*r.length);return a.write_shift(4,e),Xn(r,a),a.slice(0,a.l)}function oR(e){return e.l+=4,e.read_shift(4)!=0}function lR(e,r){var a=sr(8);return a.write_shift(4,e),a.write_shift(4,1),a}function cR(e,r,a){var s={Types:[],Cell:[],Value:[]},n=a||{},i=[],c=!1,u=2;return mc(e,function(h,g,y){switch(y){case 335:s.Types.push({name:h.name});break;case 51:h.forEach(function(w){u==1?s.Cell.push({type:s.Types[w[0]-1].name,index:w[1]}):u==0&&s.Value.push({type:s.Types[w[0]-1].name,index:w[1]})});break;case 337:u=h?1:0;break;case 338:u=2;break;case 35:i.push(y),c=!0;break;case 36:i.pop(),c=!1;break;default:if(!g.T){if(!c||n.WTF&&i[i.length-1]!=35)throw new Error("Unexpected record 0x"+y.toString(16))}}}),s}function dR(){var e=ro();return mr(e,332),mr(e,334,dl(1)),mr(e,335,aR({name:"XLDAPR",version:12e4,flags:3496657072})),mr(e,336),mr(e,339,iR(1,"XLDAPR")),mr(e,52),mr(e,35,dl(514)),mr(e,4096,dl(0)),mr(e,4097,zo(1)),mr(e,36),mr(e,53),mr(e,340),mr(e,337,lR(1)),mr(e,51,nR([[1,0]])),mr(e,338),mr(e,333),e.end()}function uR(e,r,a){var s={Types:[],Cell:[],Value:[]};if(!e)return s;var n=!1,i=2,c;return e.replace(Ti,function(u){var h=ia(u);switch(Ml(h[0])){case"<?xml":break;case"<metadata":case"</metadata>":break;case"<metadataTypes":case"</metadataTypes>":break;case"<metadataType":s.Types.push({name:h.name});break;case"</metadataType>":break;case"<futureMetadata":for(var g=0;g<s.Types.length;++g)s.Types[g].name==h.name&&(c=s.Types[g]);break;case"</futureMetadata>":break;case"<bk>":break;case"</bk>":break;case"<rc":i==1?s.Cell.push({type:s.Types[h.t-1].name,index:+h.v}):i==0&&s.Value.push({type:s.Types[h.t-1].name,index:+h.v});break;case"</rc>":break;case"<cellMetadata":i=1;break;case"</cellMetadata>":i=2;break;case"<valueMetadata":i=0;break;case"</valueMetadata>":i=2;break;case"<extLst":case"<extLst>":case"</extLst>":case"<extLst/>":break;case"<ext":n=!0;break;case"</ext>":n=!1;break;case"<rvb":if(!c)break;c.offsets||(c.offsets=[]),c.offsets.push(+h.i);break;default:if(!n&&a.WTF)throw new Error("unrecognized "+h[0]+" in metadata")}return u}),s}function DN(){var e=[cn];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 fR(e){var r=[];if(!e)return r;var a=1;return(e.match(Ti)||[]).forEach(function(s){var n=ia(s);switch(n[0]){case"<?xml":break;case"<calcChain":case"<calcChain>":case"</calcChain>":break;case"<c":delete n[0],n.i?a=n.i:n.i=a,r.push(n);break}}),r}function hR(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=sa(a);var s=e.read_shift(1);return s&2&&(r.l="1"),s&8&&(r.a="1"),r}function mR(e,r,a){var s=[];return mc(e,function(i,c,u){switch(u){case 63:s.push(i);break;default:if(!c.T)throw new Error("Unexpected record 0x"+u.toString(16))}}),s}function gR(e,r,a,s){if(!e)return e;var n=s||{},i=!1;mc(e,function(u,h,g){switch(g){case 359:case 363:case 364:case 366:case 367:case 368:case 369:case 370:case 371:case 472:case 577:case 578:case 579:case 580:case 581:case 582:case 583:case 584:case 585:case 586:case 587:break;case 35:i=!0;break;case 36:i=!1;break;default:if(!h.T){if(!i||n.WTF)throw new Error("Unexpected record 0x"+g.toString(16))}}},n)}function xR(e,r){if(!e)return"??";var a=(e.match(/<c:chart [^>]*r:id="([^"]*)"/)||["",""])[1];return r["!id"][a].Target}var I0=1024;function RN(e,r){for(var a=[21600,21600],s=["m0,0l0",a[1],a[0],a[1],a[0],"0xe"].join(","),n=[kr("xml",null,{"xmlns:v":yo.v,"xmlns:o":yo.o,"xmlns:x":yo.x,"xmlns:mv":yo.mv}).replace(/\/>/,">"),kr("o:shapelayout",kr("o:idmap",null,{"v:ext":"edit",data:e}),{"v:ext":"edit"}),kr("v:shapetype",[kr("v:stroke",null,{joinstyle:"miter"}),kr("v:path",null,{gradientshapeok:"t","o:connecttype":"rect"})].join(""),{id:"_x0000_t202","o:spt":202,coordsize:a.join(","),path:s})];I0<e*1e3;)I0+=1e3;return r.forEach(function(i){var c=Ws(i[0]),u={color2:"#BEFF82",type:"gradient"};u.type=="gradient"&&(u.angle="-180");var h=u.type=="gradient"?kr("o:fill",null,{type:"gradientUnscaled","v:ext":"view"}):null,g=kr("v:fill",h,u),y={on:"t",obscured:"t"};++I0,n=n.concat(["<v:shape"+Tf({id:"_x0000_s"+I0,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"})+">",g,kr("v:shadow",null,y),kr("v:path",null,{"o:connecttype":"none"}),'<v:textbox><div style="text-align:left"></div></v:textbox>','<x:ClientData ObjectType="Note">',"<x:MoveWithCells/>","<x:SizeWithCells/>",hi("x:Anchor",[c.c+1,0,c.r+1,0,c.c+3,20,c.r+5,20].join(",")),hi("x:AutoFill","False"),hi("x:Row",String(c.r)),hi("x:Column",String(c.c)),i[1].hidden?"":"<x:Visible/>","</x:ClientData>","</v:shape>"])}),n.push("</xml>"),n.join("")}function rk(e,r,a,s){var n=Array.isArray(e),i;r.forEach(function(c){var u=Ws(c.ref);if(n?(e[u.r]||(e[u.r]=[]),i=e[u.r][u.c]):i=e[c.ref],!i){i={t:"z"},n?e[u.r][u.c]=i:e[c.ref]=i;var h=$a(e["!ref"]||"BDWGO1000001:A1");h.s.r>u.r&&(h.s.r=u.r),h.e.r<u.r&&(h.e.r=u.r),h.s.c>u.c&&(h.s.c=u.c),h.e.c<u.c&&(h.e.c=u.c);var g=ba(h);g!==e["!ref"]&&(e["!ref"]=g)}i.c||(i.c=[]);var y={a:c.author,t:c.t,r:c.r,T:a};c.h&&(y.h=c.h);for(var w=i.c.length-1;w>=0;--w){if(!a&&i.c[w].T)return;a&&!i.c[w].T&&i.c.splice(w,1)}if(a&&s){for(w=0;w<s.length;++w)if(y.a==s[w].id){y.a=s[w].name||y.a;break}}i.c.push(y)})}function pR(e,r){if(e.match(/<(?:\w+:)?comments *\/>/))return[];var a=[],s=[],n=e.match(/<(?:\w+:)?authors>([\s\S]*)<\/(?:\w+:)?authors>/);n&&n[1]&&n[1].split(/<\/\w*:?author>/).forEach(function(c){if(!(c===""||c.trim()==="")){var u=c.match(/<(?:\w+:)?author[^>]*>(.*)/);u&&a.push(u[1])}});var i=e.match(/<(?:\w+:)?commentList>([\s\S]*)<\/(?:\w+:)?commentList>/);return i&&i[1]&&i[1].split(/<\/\w*:?comment>/).forEach(function(c){if(!(c===""||c.trim()==="")){var u=c.match(/<(?:\w+:)?comment[^>]*>/);if(u){var h=ia(u[0]),g={author:h.authorId&&a[h.authorId]||"sheetjsghost",ref:h.ref,guid:h.guid},y=Ws(h.ref);if(!(r.sheetRows&&r.sheetRows<=y.r)){var w=c.match(/<(?:\w+:)?text>([\s\S]*)<\/(?:\w+:)?text>/),E=!!w&&!!w[1]&&Py(w[1])||{r:"",t:"",h:""};g.r=E.r,E.r=="<t></t>"&&(E.t=E.h=""),g.t=(E.t||"").replace(/\r\n/g,`
`).replace(/\r/g,`
`),r.cellHTML&&(g.h=E.h),s.push(g)}}}}),s}function FN(e){var r=[cn,kr("comments",null,{xmlns:Vd[0]})],a=[];return r.push("<authors>"),e.forEach(function(s){s[1].forEach(function(n){var i=ls(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(h){h.a&&(n=a.indexOf(ls(h.a))),i.push(h.t||"")}),r.push('<comment ref="'+s[0]+'" authorId="'+n+'"><text>'),i.length<=1)r.push(hi("t",ls(i[0]||"")));else{for(var c=`Comment:
`+i[0]+`
`,u=1;u<i.length;++u)c+=`Reply:
`+i[u]+`
`;r.push(hi("t",ls(c)))}r.push("</text></comment>")}),r.push("</commentList>"),r.length>2&&(r[r.length]="</comments>",r[1]=r[1].replace("/>",">")),r.join("")}function yR(e,r){var a=[],s=!1,n={},i=0;return e.replace(Ti,function(u,h){var g=ia(u);switch(Ml(g[0])){case"<?xml":break;case"<ThreadedComments":break;case"</ThreadedComments>":break;case"<threadedComment":n={author:g.personId,guid:g.id,ref:g.ref,T:1};break;case"</threadedComment>":n.t!=null&&a.push(n);break;case"<text>":case"<text":i=h+u.length;break;case"</text>":n.t=e.slice(i,h).replace(/\r\n/g,`
`).replace(/\r/g,`
`);break;case"<mentions":case"<mentions>":s=!0;break;case"</mentions>":s=!1;break;case"<extLst":case"<extLst>":case"</extLst>":case"<extLst/>":break;case"<ext":s=!0;break;case"</ext>":s=!1;break;default:if(!s&&r.WTF)throw new Error("unrecognized "+g[0]+" in threaded comments")}return u}),a}function bR(e,r,a){var s=[cn,kr("ThreadedComments",null,{xmlns:Fn.TCMNT}).replace(/[\/]>/,">")];return e.forEach(function(n){var i="";(n[1]||[]).forEach(function(c,u){if(!c.T){delete c.ID;return}c.a&&r.indexOf(c.a)==-1&&r.push(c.a);var h={ref:n[0],id:"{54EE7951-7262-4200-6969-"+("000000000000"+a.tcid++).slice(-12)+"}"};u==0?i=h.id:h.parentId=i,c.ID=h.id,c.a&&(h.personId="{54EE7950-7262-4200-6969-"+("000000000000"+r.indexOf(c.a)).slice(-12)+"}"),s.push(kr("threadedComment",hi("text",c.t||""),h))})}),s.push("</ThreadedComments>"),s.join("")}function vR(e,r){var a=[],s=!1;return e.replace(Ti,function(i){var c=ia(i);switch(Ml(c[0])){case"<?xml":break;case"<personList":break;case"</personList>":break;case"<person":a.push({name:c.displayname,id:c.id});break;case"</person>":break;case"<extLst":case"<extLst>":case"</extLst>":case"<extLst/>":break;case"<ext":s=!0;break;case"</ext>":s=!1;break;default:if(!s&&r.WTF)throw new Error("unrecognized "+c[0]+" in threaded comments")}return i}),a}function wR(e){var r=[cn,kr("personList",null,{xmlns:Fn.TCMNT,"xmlns:x":Vd[0]}).replace(/[\/]>/,">")];return e.forEach(function(a,s){r.push(kr("person",null,{displayName:a,id:"{54EE7950-7262-4200-6969-"+("000000000000"+s).slice(-12)+"}",userId:a,providerId:"None"}))}),r.push("</personList>"),r.join("")}function _R(e){var r={};r.iauthor=e.read_shift(4);var a=Xd(e);return r.rfx=a.s,r.ref=sa(a.s),e.l+=16,r}function kR(e,r){return r==null&&(r=sr(36)),r.write_shift(4,e[1].iauthor),nu(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 NR=Ci;function jR(e){return Xn(e.slice(0,54))}function SR(e,r){var a=[],s=[],n={},i=!1;return mc(e,function(u,h,g){switch(g){case 632:s.push(u);break;case 635:n=u;break;case 637:n.t=u.t,n.h=u.h,n.r=u.r;break;case 636:if(n.author=s[n.iauthor],delete n.iauthor,r.sheetRows&&n.rfx&&r.sheetRows<=n.rfx.r)break;n.t||(n.t=""),delete n.rfx,a.push(n);break;case 3072:break;case 35:i=!0;break;case 36:i=!1;break;case 37:break;case 38:break;default:if(!h.T){if(!i||r.WTF)throw new Error("Unexpected record 0x"+g.toString(16))}}}),a}function CR(e){var r=ro(),a=[];return mr(r,628),mr(r,630),e.forEach(function(s){s[1].forEach(function(n){a.indexOf(n.a)>-1||(a.push(n.a.slice(0,54)),mr(r,632,jR(n.a)))})}),mr(r,631),mr(r,633),e.forEach(function(s){s[1].forEach(function(n){n.iauthor=a.indexOf(n.a);var i={s:Ws(s[0]),e:Ws(s[0])};mr(r,635,kR([i,n])),n.t&&n.t.length>0&&mr(r,637,XA(n)),mr(r,636),delete n.iauthor})}),mr(r,634),mr(r,629),r.end()}var ER="application/vnd.ms-office.vbaProject";function TR(e){var r=Zr.utils.cfb_new({root:"R"});return e.FullPaths.forEach(function(a,s){if(!(a.slice(-1)==="/"||!a.match(/_VBA_PROJECT_CUR/))){var n=a.replace(/^[^\/]*/,"R").replace(/\/_VBA_PROJECT_CUR\u0000*/,"");Zr.utils.cfb_add(r,n,e.FileIndex[s].content)}}),Zr.write(r)}function AR(e,r){r.FullPaths.forEach(function(a,s){if(s!=0){var n=a.replace(/[^\/]*[\/]/,"/_VBA_PROJECT_CUR/");n.slice(-1)!=="/"&&Zr.utils.cfb_add(e,n,r.FileIndex[s].content)}})}var IN=["xlsb","xlsm","xlam","biff8","xla"];function OR(){return{"!type":"dialog"}}function DR(){return{"!type":"dialog"}}function RR(){return{"!type":"macro"}}function FR(){return{"!type":"macro"}}var $0=(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,c){var u=!1,h=!1;i.length==0?h=!0:i.charAt(0)=="["&&(h=!0,i=i.slice(1,-1)),c.length==0?u=!0:c.charAt(0)=="["&&(u=!0,c=c.slice(1,-1));var g=i.length>0?parseInt(i,10)|0:0,y=c.length>0?parseInt(c,10)|0:0;return u?y+=r.c:--y,h?g+=r.r:--g,n+(u?"":"$")+zs(y)+(h?"":"$")+nn(g)}return function(n,i){return r=i,n.replace(e,a)}})(),zy=/(^|[^._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,Wy=(function(){return function(r,a){return r.replace(zy,function(s,n,i,c,u,h){var g=Ey(c)-(i?0:a.c),y=Cy(h)-(u?0:a.r),w=y==0?"":u?y+1:"["+y+"]",E=g==0?"":i?g+1:"["+g+"]";return n+"R"+w+"C"+E})}})();function MN(e,r){return e.replace(zy,function(a,s,n,i,c,u){return s+(n=="$"?n+i:zs(Ey(i)+r.c))+(c=="$"?c+u:nn(Cy(u)+r.r))})}function IR(e,r,a){var s=no(r),n=s.s,i=Ws(a),c={r:i.r-n.r,c:i.c-n.c};return MN(e,c)}function MR(e){return e.length!=1}function ak(e){return e.replace(/_xlfn\./g,"")}function _n(e){e.l+=1}function qc(e,r){var a=e.read_shift(2);return[a&16383,a>>14&1,a>>15&1]}function PN(e,r,a){var s=2;if(a){if(a.biff>=2&&a.biff<=5)return LN(e);a.biff==12&&(s=4)}var n=e.read_shift(s),i=e.read_shift(s),c=qc(e),u=qc(e);return{s:{r:n,c:c[0],cRel:c[1],rRel:c[2]},e:{r:i,c:u[0],cRel:u[1],rRel:u[2]}}}function LN(e){var r=qc(e),a=qc(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 PR(e,r,a){if(a.biff<8)return LN(e);var s=e.read_shift(a.biff==12?4:2),n=e.read_shift(a.biff==12?4:2),i=qc(e),c=qc(e);return{s:{r:s,c:i[0],cRel:i[1],rRel:i[2]},e:{r:n,c:c[0],cRel:c[1],rRel:c[2]}}}function BN(e,r,a){if(a&&a.biff>=2&&a.biff<=5)return LR(e);var s=e.read_shift(a&&a.biff==12?4:2),n=qc(e);return{r:s,c:n[0],cRel:n[1],rRel:n[2]}}function LR(e){var r=qc(e),a=e.read_shift(1);return{r:r[0],c:a,cRel:r[1],rRel:r[2]}}function BR(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 UR(e,r,a){var s=a&&a.biff?a.biff:8;if(s>=2&&s<=5)return zR(e);var n=e.read_shift(s>=12?4:2),i=e.read_shift(2),c=(i&16384)>>14,u=(i&32768)>>15;if(i&=16383,u==1)for(;n>524287;)n-=1048576;if(c==1)for(;i>8191;)i=i-16384;return{r:n,c:i,cRel:c,rRel:u}}function zR(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 WR(e,r,a){var s=(e[e.l++]&96)>>5,n=PN(e,a.biff>=2&&a.biff<=5?6:8,a);return[s,n]}function HR(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 c=PN(e,i,a);return[s,n,c]}function $R(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 VR(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 GR(e,r,a){var s=(e[e.l++]&96)>>5,n=PR(e,r-1,a);return[s,n]}function YR(e,r,a){var s=(e[e.l++]&96)>>5;return e.l+=a.biff==2?6:a.biff==12?14:7,[s]}function sk(e){var r=e[e.l+1]&1,a=1;return e.l+=4,[r,a]}function qR(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 XR(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 ZR(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 KR(e){var r=e[e.l+1]&255?1:0;return e.l+=2,[r,e.read_shift(2)]}function JR(e,r,a){var s=e[e.l+1]&255?1:0;return e.l+=a&&a.biff==2?3:4,[s]}function UN(e){var r=e.read_shift(1),a=e.read_shift(1);return[r,a]}function QR(e){return e.read_shift(2),UN(e)}function eF(e){return e.read_shift(2),UN(e)}function tF(e,r,a){var s=(e[e.l]&96)>>5;e.l+=1;var n=BN(e,0,a);return[s,n]}function rF(e,r,a){var s=(e[e.l]&96)>>5;e.l+=1;var n=UR(e,0,a);return[s,n]}function aF(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=BN(e,0,a);return[s,n,i]}function sF(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[oI[n],HN[n],s]}function nF(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)]:iF(e);return[n,(i[0]===0?HN:iI)[i[1]]]}function iF(e){return[e[e.l+1]>>7,e.read_shift(2)&32767]}function oF(e,r,a){e.l+=a&&a.biff==2?3:4}function lF(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 cF(e){return e.l++,gc[e.read_shift(1)]}function dF(e){return e.l++,e.read_shift(2)}function uF(e){return e.l++,e.read_shift(1)!==0}function fF(e){return e.l++,ji(e)}function hF(e,r,a){return e.l++,Gf(e,r-1,a)}function mF(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]=sn(e,1)?"TRUE":"FALSE",r!=12&&(e.l+=7);break;case 37:case 16:a[1]=gc[e[e.l]],e.l+=r==12?4:8;break;case 0:e.l+=8;break;case 1:a[1]=ji(e);break;case 2:a[1]=Zd(e,0,{biff:r>0&&r<8?2:r});break;default:throw new Error("Bad SerAr: "+a[0])}return a}function gF(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?Xd:_g)(e));return n}function xF(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,c=[];i!=s&&(c[i]=[]);++i)for(var u=0;u!=n;++u)c[i][u]=mF(e,a.biff);return c}function pF(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 yF(e,r,a){if(a.biff==5)return bF(e);var s=e.read_shift(1)>>>5&3,n=e.read_shift(2),i=e.read_shift(4);return[s,n,i]}function bF(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 vF(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 wF(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 _F(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 kF(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 NF=Ei,jF=Ei,SF=Ei;function qf(e,r,a){return e.l+=2,[BR(e)]}function Hy(e){return e.l+=6,[]}var CF=qf,EF=Hy,TF=Hy,AF=qf;function zN(e){return e.l+=2,[Nn(e),e.read_shift(2)&1]}var OF=qf,DF=zN,RF=Hy,FF=qf,IF=qf,MF=["Data","All","Headers","??","?Data2","??","?DataHeaders","??","Totals","??","??","??","?DataTotals","??","??","??","?Current"];function PF(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),c=MF[a>>2&31];return{ixti:r,coltype:a&3,rt:c,idx:s,c:n,C:i}}function LF(e){return e.l+=2,[e.read_shift(4)]}function BF(e,r,a){return e.l+=5,e.l+=2,e.l+=a.biff==2?1:4,["PTGSHEET"]}function UF(e,r,a){return e.l+=a.biff==2?4:5,["PTGENDSHEET"]}function zF(e){var r=e.read_shift(1)>>>5&3,a=e.read_shift(2);return[r,a]}function WF(e){var r=e.read_shift(1)>>>5&3,a=e.read_shift(2);return[r,a]}function HF(e){return e.l+=4,[0,0]}var nk={1:{n:"PtgExp",f:lF},2:{n:"PtgTbl",f:SF},3:{n:"PtgAdd",f:_n},4:{n:"PtgSub",f:_n},5:{n:"PtgMul",f:_n},6:{n:"PtgDiv",f:_n},7:{n:"PtgPower",f:_n},8:{n:"PtgConcat",f:_n},9:{n:"PtgLt",f:_n},10:{n:"PtgLe",f:_n},11:{n:"PtgEq",f:_n},12:{n:"PtgGe",f:_n},13:{n:"PtgGt",f:_n},14:{n:"PtgNe",f:_n},15:{n:"PtgIsect",f:_n},16:{n:"PtgUnion",f:_n},17:{n:"PtgRange",f:_n},18:{n:"PtgUplus",f:_n},19:{n:"PtgUminus",f:_n},20:{n:"PtgPercent",f:_n},21:{n:"PtgParen",f:_n},22:{n:"PtgMissArg",f:_n},23:{n:"PtgStr",f:hF},26:{n:"PtgSheet",f:BF},27:{n:"PtgEndSheet",f:UF},28:{n:"PtgErr",f:cF},29:{n:"PtgBool",f:uF},30:{n:"PtgInt",f:dF},31:{n:"PtgNum",f:fF},32:{n:"PtgArray",f:YR},33:{n:"PtgFunc",f:sF},34:{n:"PtgFuncVar",f:nF},35:{n:"PtgName",f:pF},36:{n:"PtgRef",f:tF},37:{n:"PtgArea",f:WR},38:{n:"PtgMemArea",f:vF},39:{n:"PtgMemErr",f:NF},40:{n:"PtgMemNoMem",f:jF},41:{n:"PtgMemFunc",f:wF},42:{n:"PtgRefErr",f:_F},43:{n:"PtgAreaErr",f:$R},44:{n:"PtgRefN",f:rF},45:{n:"PtgAreaN",f:GR},46:{n:"PtgMemAreaN",f:zF},47:{n:"PtgMemNoMemN",f:WF},57:{n:"PtgNameX",f:yF},58:{n:"PtgRef3d",f:aF},59:{n:"PtgArea3d",f:HR},60:{n:"PtgRefErr3d",f:kF},61:{n:"PtgAreaErr3d",f:VR},255:{}},$F={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},VF={1:{n:"PtgElfLel",f:zN},2:{n:"PtgElfRw",f:FF},3:{n:"PtgElfCol",f:CF},6:{n:"PtgElfRwV",f:IF},7:{n:"PtgElfColV",f:AF},10:{n:"PtgElfRadical",f:OF},11:{n:"PtgElfRadicalS",f:RF},13:{n:"PtgElfColS",f:EF},15:{n:"PtgElfColSV",f:TF},16:{n:"PtgElfRadicalLel",f:DF},25:{n:"PtgList",f:PF},29:{n:"PtgSxName",f:LF},255:{}},GF={0:{n:"PtgAttrNoop",f:HF},1:{n:"PtgAttrSemi",f:JR},2:{n:"PtgAttrIf",f:ZR},4:{n:"PtgAttrChoose",f:qR},8:{n:"PtgAttrGoto",f:XR},16:{n:"PtgAttrSum",f:oF},32:{n:"PtgAttrBaxcel",f:sk},33:{n:"PtgAttrBaxcel",f:sk},64:{n:"PtgAttrSpace",f:QR},65:{n:"PtgAttrSpaceSemi",f:eF},128:{n:"PtgAttrIfError",f:KR},255:{}};function Xf(e,r,a,s){if(s.biff<8)return Ei(e,r);for(var n=e.l+r,i=[],c=0;c!==a.length;++c)switch(a[c][0]){case"PtgArray":a[c][1]=xF(e,0,s),i.push(a[c][1]);break;case"PtgMemArea":a[c][2]=gF(e,a[c][1],s),i.push(a[c][2]);break;case"PtgExp":s&&s.biff==12&&(a[c][1][1]=e.read_shift(4),i.push(a[c][1]));break;case"PtgList":case"PtgElfRadicalS":case"PtgElfColS":case"PtgElfColSV":throw"Unsupported "+a[c][0]}return r=n-e.l,r!==0&&i.push(Ei(e,r)),i}function Zf(e,r,a){for(var s=e.l+r,n,i,c=[];s!=e.l;)r=s-e.l,i=e[e.l],n=nk[i]||nk[$F[i]],(i===24||i===25)&&(n=(i===24?VF:GF)[e[e.l+1]]),!n||!n.f?Ei(e,r):c.push([n.n,n.f(e,r,a)]);return c}function YF(e){for(var r=[],a=0;a<e.length;++a){for(var s=e[a],n=[],i=0;i<s.length;++i){var c=s[i];if(c)switch(c[0]){case 2:n.push('"'+c[1].replace(/"/g,'""')+'"');break;default:n.push(c[1])}else n.push("")}r.push(n.join(","))}return r.join(";")}var qF={PtgAdd:"+",PtgConcat:"&",PtgDiv:"/",PtgEq:"=",PtgGe:">=",PtgGt:">",PtgLe:"<=",PtgLt:"<",PtgMul:"*",PtgNe:"<>",PtgPower:"^",PtgSub:"-"};function XF(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 WN(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 ik(e,r,a){var s=WN(e,r,a);return s=="#REF"?s:XF(s,a)}function ki(e,r,a,s,n){var i=n&&n.biff||8,c={s:{c:0,r:0}},u=[],h,g,y,w=0,E=0,S,A="";if(!e[0]||!e[0][0])return"";for(var C=-1,O="",M=0,R=e[0].length;M<R;++M){var F=e[0][M];switch(F[0]){case"PtgUminus":u.push("-"+u.pop());break;case"PtgUplus":u.push("+"+u.pop());break;case"PtgPercent":u.push(u.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(h=u.pop(),g=u.pop(),C>=0){switch(e[0][C][1][0]){case 0:O=Xs(" ",e[0][C][1][1]);break;case 1:O=Xs("\r",e[0][C][1][1]);break;default:if(O="",n.WTF)throw new Error("Unexpected PtgAttrSpaceType "+e[0][C][1][0])}g=g+O,C=-1}u.push(g+qF[F[0]]+h);break;case"PtgIsect":h=u.pop(),g=u.pop(),u.push(g+" "+h);break;case"PtgUnion":h=u.pop(),g=u.pop(),u.push(g+","+h);break;case"PtgRange":h=u.pop(),g=u.pop(),u.push(g+":"+h);break;case"PtgAttrChoose":break;case"PtgAttrGoto":break;case"PtgAttrIf":break;case"PtgAttrIfError":break;case"PtgRef":y=mf(F[1][1],c,n),u.push(gf(y,i));break;case"PtgRefN":y=a?mf(F[1][1],a,n):F[1][1],u.push(gf(y,i));break;case"PtgRef3d":w=F[1][1],y=mf(F[1][2],c,n),A=ik(s,w,n),u.push(A+"!"+gf(y,i));break;case"PtgFunc":case"PtgFuncVar":var z=F[1][0],W=F[1][1];z||(z=0),z&=127;var X=z==0?[]:u.slice(-z);u.length-=z,W==="User"&&(W=X.shift()),u.push(W+"("+X.join(",")+")");break;case"PtgBool":u.push(F[1]?"TRUE":"FALSE");break;case"PtgInt":u.push(F[1]);break;case"PtgNum":u.push(String(F[1]));break;case"PtgStr":u.push('"'+F[1].replace(/"/g,'""')+'"');break;case"PtgErr":u.push(F[1]);break;case"PtgAreaN":S=I_(F[1][1],a?{s:a}:c,n),u.push(Wp(S,n));break;case"PtgArea":S=I_(F[1][1],c,n),u.push(Wp(S,n));break;case"PtgArea3d":w=F[1][1],S=F[1][2],A=ik(s,w,n),u.push(A+"!"+Wp(S,n));break;case"PtgAttrSum":u.push("SUM("+u.pop()+")");break;case"PtgAttrBaxcel":case"PtgAttrSemi":break;case"PtgName":E=F[1][2];var B=(s.names||[])[E-1]||(s[0]||[])[E],Y=B?B.Name:"SH33TJSNAME"+String(E);Y&&Y.slice(0,6)=="_xlfn."&&!n.xlfn&&(Y=Y.slice(6)),u.push(Y);break;case"PtgNameX":var G=F[1][1];E=F[1][2];var ie;if(n.biff<=5)G<0&&(G=-G),s[G]&&(ie=s[G][E]);else{var fe="";if(((s[G]||[])[0]||[])[0]==14849||(((s[G]||[])[0]||[])[0]==1025?s[G][E]&&s[G][E].itab>0&&(fe=s.SheetNames[s[G][E].itab-1]+"!"):fe=s.SheetNames[E-1]+"!"),s[G]&&s[G][E])fe+=s[G][E].Name;else if(s[0]&&s[0][E])fe+=s[0][E].Name;else{var K=(WN(s,G,n)||"").split(";;");K[E-1]?fe=K[E-1]:fe+="SH33TJSERRX"}u.push(fe);break}ie||(ie={Name:"SH33TJSERRY"}),u.push(ie.Name);break;case"PtgParen":var ke="(",ge=")";if(C>=0){switch(O="",e[0][C][1][0]){case 2:ke=Xs(" ",e[0][C][1][1])+ke;break;case 3:ke=Xs("\r",e[0][C][1][1])+ke;break;case 4:ge=Xs(" ",e[0][C][1][1])+ge;break;case 5:ge=Xs("\r",e[0][C][1][1])+ge;break;default:if(n.WTF)throw new Error("Unexpected PtgAttrSpaceType "+e[0][C][1][0])}C=-1}u.push(ke+u.pop()+ge);break;case"PtgRefErr":u.push("#REF!");break;case"PtgRefErr3d":u.push("#REF!");break;case"PtgExp":y={c:F[1][1],r:F[1][0]};var re={c:a.c,r:a.r};if(s.sharedf[sa(y)]){var we=s.sharedf[sa(y)];u.push(ki(we,c,re,s,n))}else{var ee=!1;for(h=0;h!=s.arrayf.length;++h)if(g=s.arrayf[h],!(y.c<g[0].s.c||y.c>g[0].e.c)&&!(y.r<g[0].s.r||y.r>g[0].e.r)){u.push(ki(g[1],c,re,s,n)),ee=!0;break}ee||u.push(F[1])}break;case"PtgArray":u.push("{"+YF(F[1])+"}");break;case"PtgMemArea":break;case"PtgAttrSpace":case"PtgAttrSpaceSemi":C=M;break;case"PtgTbl":break;case"PtgMemErr":break;case"PtgMissArg":u.push("");break;case"PtgAreaErr":u.push("#REF!");break;case"PtgAreaErr3d":u.push("#REF!");break;case"PtgList":u.push("Table"+F[1].idx+"[#"+F[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(F));default:throw new Error("Unrecognized Formula Token: "+String(F))}var ve=["PtgAttrSpace","PtgAttrSpaceSemi","PtgAttrGoto"];if(n.biff!=3&&C>=0&&ve.indexOf(e[0][M][0])==-1){F=e[0][C];var ce=!0;switch(F[1][0]){case 4:ce=!1;case 0:O=Xs(" ",F[1][1]);break;case 5:ce=!1;case 1:O=Xs("\r",F[1][1]);break;default:if(O="",n.WTF)throw new Error("Unexpected PtgAttrSpaceType "+F[1][0])}u.push((ce?O:"")+u.pop()+(ce?"":O)),C=-1}}if(u.length>1&&n.WTF)throw new Error("bad formula stack");return u[0]}function ZF(e,r,a){var s=e.l+r,n=a.biff==2?1:2,i,c=e.read_shift(n);if(c==65535)return[[],Ei(e,r-2)];var u=Zf(e,c,a);return r!==c+n&&(i=Xf(e,r-c-n,u,a)),e.l=s,[u,i]}function KF(e,r,a){var s=e.l+r,n=a.biff==2?1:2,i,c=e.read_shift(n);if(c==65535)return[[],Ei(e,r-2)];var u=Zf(e,c,a);return r!==c+n&&(i=Xf(e,r-c-n,u,a)),e.l=s,[u,i]}function JF(e,r,a,s){var n=e.l+r,i=Zf(e,s,a),c;return n!==e.l&&(c=Xf(e,n-e.l,i,a)),[i,c]}function QF(e,r,a){var s=e.l+r,n,i=e.read_shift(2),c=Zf(e,i,a);return i==65535?[[],Ei(e,r-2)]:(r!==i+2&&(n=Xf(e,s-i-2,c,a)),[c,n])}function eI(e){var r;if(sc(e,e.l+6)!==65535)return[ji(e),"n"];switch(e[e.l]){case 0:return e.l+=8,["String","s"];case 1:return r=e[e.l+2]===1,e.l+=8,[r,"b"];case 2:return r=e[e.l+2],e.l+=8,[r,"e"];case 3:return e.l+=8,["","s"]}return[]}function tI(e){if(e==null){var r=sr(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 Bd(e);return Bd(0)}function Yp(e,r,a){var s=e.l+r,n=Pl(e);a.biff==2&&++e.l;var i=eI(e),c=e.read_shift(1);a.biff!=2&&(e.read_shift(1),a.biff>=5&&e.read_shift(4));var u=KF(e,s-e.l,a);return{cell:n,val:i[0],formula:u,shared:c>>3&1,tt:i[1]}}function rI(e,r,a,s,n){var i=zd(r,a,n),c=tI(e.v),u=sr(6),h=33;u.write_shift(2,h),u.write_shift(4,0);for(var g=sr(e.bf.length),y=0;y<e.bf.length;++y)g[y]=e.bf[y];var w=qn([i,c,u,g]);return w}function kg(e,r,a){var s=e.read_shift(4),n=Zf(e,s,a),i=e.read_shift(4),c=i>0?Xf(e,i,n,a):null;return[n,c]}var aI=kg,Ng=kg,sI=kg,nI=kg,iI={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"},HN={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"},oI={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 ok(e){return e.slice(0,3)=="of:"&&(e=e.slice(3)),e.charCodeAt(0)==61&&(e=e.slice(1),e.charCodeAt(0)==61&&(e=e.slice(1))),e=e.replace(/COM\.MICROSOFT\./g,""),e=e.replace(/\[((?:\.[A-Z]+[0-9]+)(?::\.[A-Z]+[0-9]+)?)\]/g,function(r,a){return a.replace(/\./g,"")}),e=e.replace(/\[.(#[A-Z]*[?!])\]/g,"$1"),e.replace(/[;~]/g,",").replace(/\|/g,";")}function lI(e){var r="of:="+e.replace(zy,"$1[.$2$3$4$5]").replace(/\]:\[/g,":");return r.replace(/;/g,"|").replace(/,/g,";")}function qp(e){var r=e.split(":"),a=r[0].split(".")[0];return[a,r[0].split(".")[1]+(r.length>1?":"+(r[1].split(".")[1]||r[1].split(".")[0]):"")]}function cI(e){return e.replace(/\./,"!")}var pf={},V0={},yf=typeof Map!="undefined";function $y(e,r,a){var s=0,n=e.length;if(a){if(yf?a.has(r):Object.prototype.hasOwnProperty.call(a,r)){for(var i=yf?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&&(yf?(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 jg(e,r){var a={min:e+1,max:e+1},s=-1;return r.MDW&&(Ni=r.MDW),r.width!=null?a.customWidth=1:r.wpx!=null?s=Ff(r.wpx):r.wch!=null&&(s=r.wch),s>-1?(a.width=sg(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 Ad(e,r){if(e){var a=[.7,.7,.75,.75,.3,.3];r=="xlml"&&(a=[1,1,1,1,.5,.5]),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 Jc(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){lc(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 $N(e,r,a,s,n,i){try{s.cellNF&&(e.z=aa[r])}catch(u){if(s.WTF)throw u}if(!(e.t==="z"&&!s.cellStyles)){if(e.t==="d"&&typeof e.v=="string"&&(e.v=Cs(e.v)),(!s||s.cellText!==!1)&&e.t!=="z")try{if(aa[r]==null&&lc(iA[r]||"General",r),e.t==="e")e.w=e.w||gc[e.v];else if(r===0)if(e.t==="n")(e.v|0)===e.v?e.w=e.v.toString(10):e.w=Cf(e.v);else if(e.t==="d"){var c=Pn(e.v);(c|0)===c?e.w=c.toString(10):e.w=Cf(c)}else{if(e.v===void 0)return"";e.w=Pd(e.v,V0)}else e.t==="d"?e.w=Yo(r,Pn(e.v),V0):e.w=Yo(r,e.v,V0)}catch(u){if(s.WTF)throw u}if(s.cellStyles&&a!=null)try{e.s=i.Fills[a],e.s.fgColor&&e.s.fgColor.theme&&!e.s.fgColor.rgb&&(e.s.fgColor.rgb=ag(n.themeElements.clrScheme[e.s.fgColor.theme].rgb,e.s.fgColor.tint||0),s.WTF&&(e.s.fgColor.raw_rgb=n.themeElements.clrScheme[e.s.fgColor.theme].rgb)),e.s.bgColor&&e.s.bgColor.theme&&(e.s.bgColor.rgb=ag(n.themeElements.clrScheme[e.s.bgColor.theme].rgb,e.s.bgColor.tint||0),s.WTF&&(e.s.bgColor.raw_rgb=n.themeElements.clrScheme[e.s.bgColor.theme].rgb))}catch(u){if(s.WTF&&i.Fills)throw u}}}function dI(e,r,a){if(e&&e["!ref"]){var s=$a(e["!ref"]);if(s.e.c<s.s.c||s.e.r<s.s.r)throw new Error("Bad range ("+a+"): "+e["!ref"])}}function uI(e,r){var a=$a(r);a.s.r<=a.e.r&&a.s.c<=a.e.c&&a.s.r>=0&&a.s.c>=0&&(e["!ref"]=ba(a))}var fI=/<(?:\w:)?mergeCell ref="[A-Z0-9:]+"\s*[\/]?>/g,hI=/<(?:\w+:)?sheetData[^>]*>([\s\S]*)<\/(?:\w+:)?sheetData>/,mI=/<(?:\w:)?hyperlink [^>]*>/mg,gI=/"(\w*:\w*)"/,xI=/<(?:\w:)?col\b[^>]*[\/]?>/g,pI=/<(?:\w:)?autoFilter[^>]*([\/]|>([\s\S]*)<\/(?:\w:)?autoFilter)>/g,yI=/<(?:\w:)?pageMargins[^>]*\/>/g,VN=/<(?:\w:)?sheetPr\b(?:[^>a-z][^>]*)?\/>/,bI=/<(?:\w:)?sheetPr[^>]*(?:[\/]|>([\s\S]*)<\/(?:\w:)?sheetPr)>/,vI=/<(?:\w:)?sheetViews[^>]*(?:[\/]|>([\s\S]*)<\/(?:\w:)?sheetViews)>/;function wI(e,r,a,s,n,i,c){if(!e)return e;s||(s={"!id":{}});var u=r.dense?[]:{},h={s:{r:2e6,c:2e6},e:{r:0,c:0}},g="",y="",w=e.match(hI);w?(g=e.slice(0,w.index),y=e.slice(w.index+w[0].length)):g=y=e;var E=g.match(VN);E?Vy(E[0],u,n,a):(E=g.match(bI))&&kI(E[0],E[1]||"",u,n,a);var S=(g.match(/<(?:\w*:)?dimension/)||{index:-1}).index;if(S>0){var A=g.slice(S,S+50).match(gI);A&&uI(u,A[1])}var C=g.match(vI);C&&C[1]&&MI(C[1],n);var O=[];if(r.cellStyles){var M=g.match(xI);M&&OI(O,M)}w&&BI(w[1],u,r,h,i,c);var R=y.match(pI);R&&(u["!autofilter"]=RI(R[0]));var F=[],z=y.match(fI);if(z)for(S=0;S!=z.length;++S)F[S]=$a(z[S].slice(z[S].indexOf('"')+1));var W=y.match(mI);W&&EI(u,W,s);var X=y.match(yI);if(X&&(u["!margins"]=TI(ia(X[0]))),!u["!ref"]&&h.e.c>=h.s.c&&h.e.r>=h.s.r&&(u["!ref"]=ba(h)),r.sheetRows>0&&u["!ref"]){var B=$a(u["!ref"]);r.sheetRows<=+B.e.r&&(B.e.r=r.sheetRows-1,B.e.r>h.e.r&&(B.e.r=h.e.r),B.e.r<B.s.r&&(B.s.r=B.e.r),B.e.c>h.e.c&&(B.e.c=h.e.c),B.e.c<B.s.c&&(B.s.c=B.e.c),u["!fullref"]=u["!ref"],u["!ref"]=ba(B))}return O.length>0&&(u["!cols"]=O),F.length>0&&(u["!merges"]=F),u}function _I(e){if(e.length===0)return"";for(var r='<mergeCells count="'+e.length+'">',a=0;a!=e.length;++a)r+='<mergeCell ref="'+ba(e[a])+'"/>';return r+"</mergeCells>"}function Vy(e,r,a,s){var n=ia(e);a.Sheets[s]||(a.Sheets[s]={}),n.codeName&&(a.Sheets[s].CodeName=Ha(ms(n.codeName)))}function kI(e,r,a,s,n){Vy(e.slice(0,e.indexOf(">")),a,s,n)}function NI(e,r,a,s,n){var i=!1,c={},u=null;if(s.bookType!=="xlsx"&&r.vbaraw){var h=r.SheetNames[a];try{r.Workbook&&(h=r.Workbook.Sheets[a].CodeName||h)}catch(y){}i=!0,c.codeName=Rl(ls(h))}if(e&&e["!outline"]){var g={summaryBelow:1,summaryRight:1};e["!outline"].above&&(g.summaryBelow=0),e["!outline"].left&&(g.summaryRight=0),u=(u||"")+kr("outlinePr",null,g)}!i&&!u||(n[n.length]=kr("sheetPr",u,c))}var jI=["objects","scenarios","selectLockedCells","selectUnlockedCells"],SI=["formatColumns","formatRows","formatCells","insertColumns","insertRows","insertHyperlinks","deleteColumns","deleteRows","sort","autoFilter","pivotTables"];function CI(e){var r={sheet:1};return jI.forEach(function(a){e[a]!=null&&e[a]&&(r[a]="1")}),SI.forEach(function(a){e[a]!=null&&!e[a]&&(r[a]="0")}),e.password&&(r.password=Ly(e.password).toString(16).toUpperCase()),kr("sheetProtection",null,r)}function EI(e,r,a){for(var s=Array.isArray(e),n=0;n!=r.length;++n){var i=ia(ms(r[n]),!0);if(!i.ref)return;var c=((a||{})["!id"]||[])[i.id];c?(i.Target=c.Target,i.location&&(i.Target+="#"+Ha(i.location))):(i.Target="#"+Ha(i.location),c={Target:i.Target,TargetMode:"Internal"}),i.Rel=c,i.tooltip&&(i.Tooltip=i.tooltip,delete i.tooltip);for(var u=$a(i.ref),h=u.s.r;h<=u.e.r;++h)for(var g=u.s.c;g<=u.e.c;++g){var y=sa({c:g,r:h});s?(e[h]||(e[h]=[]),e[h][g]||(e[h][g]={t:"z",v:void 0}),e[h][g].l=i):(e[y]||(e[y]={t:"z",v:void 0}),e[y].l=i)}}}function TI(e){var r={};return["left","right","top","bottom","header","footer"].forEach(function(a){e[a]&&(r[a]=parseFloat(e[a]))}),r}function AI(e){return Ad(e),kr("pageMargins",null,e)}function OI(e,r){for(var a=!1,s=0;s!=r.length;++s){var n=ia(r[s],!0);n.hidden&&(n.hidden=Ss(n.hidden));var i=parseInt(n.min,10)-1,c=parseInt(n.max,10)-1;for(n.outlineLevel&&(n.level=+n.outlineLevel||0),delete n.min,delete n.max,n.width=+n.width,!a&&n.width&&(a=!0,By(n.width)),Yc(n);i<=c;)e[i++]=Es(n)}}function DI(e,r){for(var a=["<cols>"],s,n=0;n!=r.length;++n)(s=r[n])&&(a[a.length]=kr("col",null,jg(n,s)));return a[a.length]="</cols>",a.join("")}function RI(e){var r={ref:(e.match(/ref="([^"]*)"/)||[])[1]};return r}function FI(e,r,a,s){var n=typeof e.ref=="string"?e.ref:ba(e.ref);a.Workbook||(a.Workbook={Sheets:[]}),a.Workbook.Names||(a.Workbook.Names=[]);var i=a.Workbook.Names,c=no(n);c.s.r==c.e.r&&(c.e.r=no(r["!ref"]).e.r,n=ba(c));for(var u=0;u<i.length;++u){var h=i[u];if(h.Name=="_xlnm._FilterDatabase"&&h.Sheet==s){h.Ref="'"+a.SheetNames[s]+"'!"+n;break}}return u==i.length&&i.push({Name:"_xlnm._FilterDatabase",Sheet:s,Ref:"'"+a.SheetNames[s]+"'!"+n}),kr("autoFilter",null,{ref:n})}var II=/<(?:\w:)?sheetView(?:[^>a-z][^>]*)?\/?>/;function MI(e,r){r.Views||(r.Views=[{}]),(e.match(II)||[]).forEach(function(a,s){var n=ia(a);r.Views[s]||(r.Views[s]={}),+n.zoomScale&&(r.Views[s].zoom=+n.zoomScale),Ss(n.rightToLeft)&&(r.Views[s].RTL=!0)})}function PI(e,r,a,s){var n={workbookViewId:"0"};return(((s||{}).Workbook||{}).Views||[])[0]&&(n.rightToLeft=s.Workbook.Views[0].RTL?"1":"0"),kr("sheetViews",kr("sheetView",null,n),{})}function LI(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,c=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=gc[e.v];break;case"d":s&&s.cellDates?n=Cs(e.v,-1).toISOString():(e=Es(e),e.t="n",n=""+(e.v=Pn(Cs(e.v)))),typeof e.z=="undefined"&&(e.z=aa[14]);break;default:n=e.v;break}var u=hi("v",ls(n)),h={r},g=Jc(s.cellXfs,e,s);switch(g!==0&&(h.s=g),e.t){case"n":break;case"d":h.t="d";break;case"b":h.t="b";break;case"e":h.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){u=hi("v",""+$y(s.Strings,e.v,s.revStrings)),h.t="s";break}h.t="str";break}if(e.t!=i&&(e.t=i,e.v=c),typeof e.f=="string"&&e.f){var y=e.F&&e.F.slice(0,r.length)==r?{t:"array",ref:e.F}:null;u=kr("f",ls(e.f),y)+(e.v!=null?u:"")}return e.l&&a["!links"].push([r,e.l]),e.D&&(h.cm=1),kr("c",u,h)}var BI=(function(){var e=/<(?:\w+:)?c[ \/>]/,r=/<\/(?:\w+:)?row>/,a=/r=["']([^"']*)["']/,s=/<(?:\w+:)?is>([\S\s]*?)<\/(?:\w+:)?is>/,n=/ref=["']([^"']*)["']/,i=Ef("v"),c=Ef("f");return function(h,g,y,w,E,S){for(var A=0,C="",O=[],M=[],R=0,F=0,z=0,W="",X,B,Y=0,G=0,ie,fe,K=0,ke=0,ge=Array.isArray(S.CellXf),re,we=[],ee=[],ve=Array.isArray(g),ce=[],ye={},te=!1,q=!!y.sheetStubs,J=h.split(r),ae=0,oe=J.length;ae!=oe;++ae){C=J[ae].trim();var le=C.length;if(le!==0){var be=0;e:for(A=0;A<le;++A)switch(C[A]){case">":if(C[A-1]!="/"){++A;break e}if(y&&y.cellStyles){if(B=ia(C.slice(be,A),!0),Y=B.r!=null?parseInt(B.r,10):Y+1,G=-1,y.sheetRows&&y.sheetRows<Y)continue;ye={},te=!1,B.ht&&(te=!0,ye.hpt=parseFloat(B.ht),ye.hpx=X0(ye.hpt)),B.hidden=="1"&&(te=!0,ye.hidden=!0),B.outlineLevel!=null&&(te=!0,ye.level=+B.outlineLevel),te&&(ce[Y-1]=ye)}break;case"<":be=A;break}if(be>=A)break;if(B=ia(C.slice(be,A),!0),Y=B.r!=null?parseInt(B.r,10):Y+1,G=-1,!(y.sheetRows&&y.sheetRows<Y)){w.s.r>Y-1&&(w.s.r=Y-1),w.e.r<Y-1&&(w.e.r=Y-1),y&&y.cellStyles&&(ye={},te=!1,B.ht&&(te=!0,ye.hpt=parseFloat(B.ht),ye.hpx=X0(ye.hpt)),B.hidden=="1"&&(te=!0,ye.hidden=!0),B.outlineLevel!=null&&(te=!0,ye.level=+B.outlineLevel),te&&(ce[Y-1]=ye)),O=C.slice(A).split(e);for(var Z=0;Z!=O.length&&O[Z].trim().charAt(0)=="<";++Z);for(O=O.slice(Z),A=0;A!=O.length;++A)if(C=O[A].trim(),C.length!==0){if(M=C.match(a),R=A,F=0,z=0,C="<c "+(C.slice(0,1)=="<"?">":"")+C,M!=null&&M.length===2){for(R=0,W=M[1],F=0;F!=W.length&&!((z=W.charCodeAt(F)-64)<1||z>26);++F)R=26*R+z;--R,G=R}else++G;for(F=0;F!=C.length&&C.charCodeAt(F)!==62;++F);if(++F,B=ia(C.slice(0,F),!0),B.r||(B.r=sa({r:Y-1,c:G})),W=C.slice(F),X={t:""},(M=W.match(i))!=null&&M[1]!==""&&(X.v=Ha(M[1])),y.cellFormula){if((M=W.match(c))!=null&&M[1]!==""){if(X.f=Ha(ms(M[1])).replace(/\r\n/g,`
`),y.xlfn||(X.f=ak(X.f)),M[0].indexOf('t="array"')>-1)X.F=(W.match(n)||[])[1],X.F.indexOf(":")>-1&&we.push([$a(X.F),X.F]);else if(M[0].indexOf('t="shared"')>-1){fe=ia(M[0]);var Le=Ha(ms(M[1]));y.xlfn||(Le=ak(Le)),ee[parseInt(fe.si,10)]=[fe,Le,B.r]}}else(M=W.match(/<f[^>]*\/>/))&&(fe=ia(M[0]),ee[fe.si]&&(X.f=IR(ee[fe.si][1],ee[fe.si][2],B.r)));var Pe=Ws(B.r);for(F=0;F<we.length;++F)Pe.r>=we[F][0].s.r&&Pe.r<=we[F][0].e.r&&Pe.c>=we[F][0].s.c&&Pe.c<=we[F][0].e.c&&(X.F=we[F][1])}if(B.t==null&&X.v===void 0)if(X.f||X.F)X.v=0,X.t="n";else if(q)X.t="z";else continue;else X.t=B.t||"n";switch(w.s.c>G&&(w.s.c=G),w.e.c<G&&(w.e.c=G),X.t){case"n":if(X.v==""||X.v==null){if(!q)continue;X.t="z"}else X.v=parseFloat(X.v);break;case"s":if(typeof X.v=="undefined"){if(!q)continue;X.t="z"}else ie=pf[parseInt(X.v,10)],X.v=ie.t,X.r=ie.r,y.cellHTML&&(X.h=ie.h);break;case"str":X.t="s",X.v=X.v!=null?ms(X.v):"",y.cellHTML&&(X.h=ky(X.v));break;case"inlineStr":M=W.match(s),X.t="s",M!=null&&(ie=Py(M[1]))?(X.v=ie.t,y.cellHTML&&(X.h=ie.h)):X.v="";break;case"b":X.v=Ss(X.v);break;case"d":y.cellDates?X.v=Cs(X.v,1):(X.v=Pn(Cs(X.v,1)),X.t="n");break;case"e":(!y||y.cellText!==!1)&&(X.w=X.v),X.v=Y3[X.v];break}if(K=ke=0,re=null,ge&&B.s!==void 0&&(re=S.CellXf[B.s],re!=null&&(re.numFmtId!=null&&(K=re.numFmtId),y.cellStyles&&re.fillId!=null&&(ke=re.fillId))),$N(X,K,ke,y,E,S),y.cellDates&&ge&&X.t=="n"&&ru(aa[K])&&(X.t="d",X.v=wg(X.v)),B.cm&&y.xlmeta){var Be=(y.xlmeta.Cell||[])[+B.cm-1];Be&&Be.type=="XLDAPR"&&(X.D=!0)}if(ve){var pe=Ws(B.r);g[pe.r]||(g[pe.r]=[]),g[pe.r][pe.c]=X}else g[B.r]=X}}}}ce.length>0&&(g["!rows"]=ce)}})();function UI(e,r,a,s){var n=[],i=[],c=$a(e["!ref"]),u="",h,g="",y=[],w=0,E=0,S=e["!rows"],A=Array.isArray(e),C={r:g},O,M=-1;for(E=c.s.c;E<=c.e.c;++E)y[E]=zs(E);for(w=c.s.r;w<=c.e.r;++w){for(i=[],g=nn(w),E=c.s.c;E<=c.e.c;++E){h=y[E]+g;var R=A?(e[w]||[])[E]:e[h];R!==void 0&&(u=LI(R,h,e,r))!=null&&i.push(u)}(i.length>0||S&&S[w])&&(C={r:g},S&&S[w]&&(O=S[w],O.hidden&&(C.hidden=1),M=-1,O.hpx?M=If(O.hpx):O.hpt&&(M=O.hpt),M>-1&&(C.ht=M,C.customHeight=1),O.level&&(C.outlineLevel=O.level)),n[n.length]=kr("row",i.join(""),C))}if(S)for(;w<S.length;++w)S&&S[w]&&(C={r:w+1},O=S[w],O.hidden&&(C.hidden=1),M=-1,O.hpx?M=If(O.hpx):O.hpt&&(M=O.hpt),M>-1&&(C.ht=M,C.customHeight=1),O.level&&(C.outlineLevel=O.level),n[n.length]=kr("row","",C));return n.join("")}function GN(e,r,a,s){var n=[cn,kr("worksheet",null,{xmlns:Vd[0],"xmlns:r":Fn.r})],i=a.SheetNames[e],c=0,u="",h=a.Sheets[i];h==null&&(h={});var g=h["!ref"]||"A1",y=$a(g);if(y.e.c>16383||y.e.r>1048575){if(r.WTF)throw new Error("Range "+g+" exceeds format limit A1:XFD1048576");y.e.c=Math.min(y.e.c,16383),y.e.r=Math.min(y.e.c,1048575),g=ba(y)}s||(s={}),h["!comments"]=[];var w=[];NI(h,a,e,r,n),n[n.length]=kr("dimension",null,{ref:g}),n[n.length]=PI(h,r,e,a),r.sheetFormat&&(n[n.length]=kr("sheetFormatPr",null,{defaultRowHeight:r.sheetFormat.defaultRowHeight||"16",baseColWidth:r.sheetFormat.baseColWidth||"10",outlineLevelRow:r.sheetFormat.outlineLevelRow||"7"})),h["!cols"]!=null&&h["!cols"].length>0&&(n[n.length]=DI(h,h["!cols"])),n[c=n.length]="<sheetData/>",h["!links"]=[],h["!ref"]!=null&&(u=UI(h,r),u.length>0&&(n[n.length]=u)),n.length>c+1&&(n[n.length]="</sheetData>",n[c]=n[c].replace("/>",">")),h["!protect"]&&(n[n.length]=CI(h["!protect"])),h["!autofilter"]!=null&&(n[n.length]=FI(h["!autofilter"],h,a,e)),h["!merges"]!=null&&h["!merges"].length>0&&(n[n.length]=_I(h["!merges"]));var E=-1,S,A=-1;return h["!links"].length>0&&(n[n.length]="<hyperlinks>",h["!links"].forEach(function(C){C[1].Target&&(S={ref:C[0]},C[1].Target.charAt(0)!="#"&&(A=os(s,-1,ls(C[1].Target).replace(/#.*$/,""),Aa.HLINK),S["r:id"]="rId"+A),(E=C[1].Target.indexOf("#"))>-1&&(S.location=ls(C[1].Target.slice(E+1))),C[1].Tooltip&&(S.tooltip=ls(C[1].Tooltip)),n[n.length]=kr("hyperlink",null,S))}),n[n.length]="</hyperlinks>"),delete h["!links"],h["!margins"]!=null&&(n[n.length]=AI(h["!margins"])),(!r||r.ignoreEC||r.ignoreEC==null)&&(n[n.length]=hi("ignoredErrors",kr("ignoredError",null,{numberStoredAsText:1,sqref:g}))),w.length>0&&(A=os(s,-1,"../drawings/drawing"+(e+1)+".xml",Aa.DRAW),n[n.length]=kr("drawing",null,{"r:id":"rId"+A}),h["!drawing"]=w),h["!comments"].length>0&&(A=os(s,-1,"../drawings/vmlDrawing"+(e+1)+".vml",Aa.VML),n[n.length]=kr("legacyDrawing",null,{"r:id":"rId"+A}),h["!legacy"]=A),n.length>1&&(n[n.length]="</worksheet>",n[1]=n[1].replace("/>",">")),n.join("")}function zI(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 WI(e,r,a){var s=sr(145),n=(a["!rows"]||[])[e]||{};s.write_shift(4,e),s.write_shift(4,0);var i=320;n.hpx?i=If(n.hpx)*20:n.hpt&&(i=n.hpt*20),s.write_shift(2,i),s.write_shift(1,0);var c=0;n.level&&(c|=n.level),n.hidden&&(c|=16),(n.hpx||n.hpt)&&(c|=32),s.write_shift(1,c),s.write_shift(1,0);var u=0,h=s.l;s.l+=4;for(var g={r:e,c:0},y=0;y<16;++y)if(!(r.s.c>y+1<<10||r.e.c<y<<10)){for(var w=-1,E=-1,S=y<<10;S<y+1<<10;++S){g.c=S;var A=Array.isArray(a)?(a[g.r]||[])[g.c]:a[sa(g)];A&&(w<0&&(w=S),E=S)}w<0||(++u,s.write_shift(4,w),s.write_shift(4,E))}var C=s.l;return s.l=h,s.write_shift(4,u),s.l=C,s.length>s.l?s.slice(0,s.l):s}function HI(e,r,a,s){var n=WI(s,a,r);(n.length>17||(r["!rows"]||[])[s])&&mr(e,0,n)}var $I=Xd,VI=nu;function GI(){}function YI(e,r){var a={},s=e[e.l];return++e.l,a.above=!(s&64),a.left=!(s&128),e.l+=18,a.name=ZA(e),a}function qI(e,r,a){a==null&&(a=sr(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 eg({auto:1},a),a.write_shift(-4,-1),a.write_shift(-4,-1),W3(e,a),a.slice(0,a.l)}function XI(e){var r=Xo(e);return[r]}function ZI(e,r,a){return a==null&&(a=sr(8)),Gd(r,a)}function KI(e){var r=Yd(e);return[r]}function JI(e,r,a){return a==null&&(a=sr(4)),qd(r,a)}function QI(e){var r=Xo(e),a=e.read_shift(1);return[r,a,"b"]}function eM(e,r,a){return a==null&&(a=sr(9)),Gd(r,a),a.write_shift(1,e.v?1:0),a}function tM(e){var r=Yd(e),a=e.read_shift(1);return[r,a,"b"]}function rM(e,r,a){return a==null&&(a=sr(5)),qd(r,a),a.write_shift(1,e.v?1:0),a}function aM(e){var r=Xo(e),a=e.read_shift(1);return[r,a,"e"]}function sM(e,r,a){return a==null&&(a=sr(9)),Gd(r,a),a.write_shift(1,e.v),a}function nM(e){var r=Yd(e),a=e.read_shift(1);return[r,a,"e"]}function iM(e,r,a){return a==null&&(a=sr(8)),qd(r,a),a.write_shift(1,e.v),a.write_shift(2,0),a.write_shift(1,0),a}function oM(e){var r=Xo(e),a=e.read_shift(4);return[r,a,"s"]}function lM(e,r,a){return a==null&&(a=sr(12)),Gd(r,a),a.write_shift(4,r.v),a}function cM(e){var r=Yd(e),a=e.read_shift(4);return[r,a,"s"]}function dM(e,r,a){return a==null&&(a=sr(8)),qd(r,a),a.write_shift(4,r.v),a}function uM(e){var r=Xo(e),a=ji(e);return[r,a,"n"]}function fM(e,r,a){return a==null&&(a=sr(16)),Gd(r,a),Bd(e.v,a),a}function YN(e){var r=Yd(e),a=ji(e);return[r,a,"n"]}function hM(e,r,a){return a==null&&(a=sr(12)),qd(r,a),Bd(e.v,a),a}function mM(e){var r=Xo(e),a=Dy(e);return[r,a,"n"]}function gM(e,r,a){return a==null&&(a=sr(12)),Gd(r,a),H3(e.v,a),a}function xM(e){var r=Yd(e),a=Dy(e);return[r,a,"n"]}function pM(e,r,a){return a==null&&(a=sr(8)),qd(r,a),H3(e.v,a),a}function yM(e){var r=Xo(e),a=Ty(e);return[r,a,"is"]}function bM(e){var r=Xo(e),a=Ci(e);return[r,a,"str"]}function vM(e,r,a){return a==null&&(a=sr(12+4*e.v.length)),Gd(r,a),Xn(e.v,a),a.length>a.l?a.slice(0,a.l):a}function wM(e){var r=Yd(e),a=Ci(e);return[r,a,"str"]}function _M(e,r,a){return a==null&&(a=sr(8+4*e.v.length)),qd(r,a),Xn(e.v,a),a.length>a.l?a.slice(0,a.l):a}function kM(e,r,a){var s=e.l+r,n=Xo(e);n.r=a["!row"];var i=e.read_shift(1),c=[n,i,"b"];if(a.cellFormula){e.l+=2;var u=Ng(e,s-e.l,a);c[3]=ki(u,null,n,a.supbooks,a)}else e.l=s;return c}function NM(e,r,a){var s=e.l+r,n=Xo(e);n.r=a["!row"];var i=e.read_shift(1),c=[n,i,"e"];if(a.cellFormula){e.l+=2;var u=Ng(e,s-e.l,a);c[3]=ki(u,null,n,a.supbooks,a)}else e.l=s;return c}function jM(e,r,a){var s=e.l+r,n=Xo(e);n.r=a["!row"];var i=ji(e),c=[n,i,"n"];if(a.cellFormula){e.l+=2;var u=Ng(e,s-e.l,a);c[3]=ki(u,null,n,a.supbooks,a)}else e.l=s;return c}function SM(e,r,a){var s=e.l+r,n=Xo(e);n.r=a["!row"];var i=Ci(e),c=[n,i,"str"];if(a.cellFormula){e.l+=2;var u=Ng(e,s-e.l,a);c[3]=ki(u,null,n,a.supbooks,a)}else e.l=s;return c}var CM=Xd,EM=nu;function TM(e,r){return r==null&&(r=sr(4)),r.write_shift(4,e),r}function AM(e,r){var a=e.l+r,s=Xd(e),n=Ay(e),i=Ci(e),c=Ci(e),u=Ci(e);e.l=a;var h={rfx:s,relId:n,loc:i,display:u};return c&&(h.Tooltip=c),h}function OM(e,r){var a=sr(50+4*(e[1].Target.length+(e[1].Tooltip||"").length));nu({s:Ws(e[0]),e:Ws(e[0])},a),Oy("rId"+r,a);var s=e[1].Target.indexOf("#"),n=s==-1?"":e[1].Target.slice(s+1);return Xn(n||"",a),Xn(e[1].Tooltip||"",a),Xn("",a),a.slice(0,a.l)}function DM(){}function RM(e,r,a){var s=e.l+r,n=$3(e),i=e.read_shift(1),c=[n];if(c[2]=i,a.cellFormula){var u=aI(e,s-e.l,a);c[1]=u}else e.l=s;return c}function FM(e,r,a){var s=e.l+r,n=Xd(e),i=[n];if(a.cellFormula){var c=nI(e,s-e.l,a);i[1]=c,e.l=s}else e.l=s;return i}function IM(e,r,a){a==null&&(a=sr(18));var s=jg(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 qN=["left","right","top","bottom","header","footer"];function MM(e){var r={};return qN.forEach(function(a){r[a]=ji(e)}),r}function PM(e,r){return r==null&&(r=sr(48)),Ad(e),qN.forEach(function(a){Bd(e[a],r)}),r}function LM(e){var r=e.read_shift(2);return e.l+=28,{RTL:r&32}}function BM(e,r,a){a==null&&(a=sr(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 UM(e){var r=sr(24);return r.write_shift(4,4),r.write_shift(4,1),nu(e,r),r}function zM(e,r){return r==null&&(r=sr(66)),r.write_shift(2,e.password?Ly(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 WM(){}function HM(){}function $M(e,r,a,s,n,i,c){if(!e)return e;var u=r||{};s||(s={"!id":{}});var h=u.dense?[]:{},g,y={s:{r:2e6,c:2e6},e:{r:0,c:0}},w=!1,E=!1,S,A,C,O,M,R,F,z,W,X=[];u.biff=12,u["!row"]=0;var B=0,Y=!1,G=[],ie={},fe=u.supbooks||n.supbooks||[[]];if(fe.sharedf=ie,fe.arrayf=G,fe.SheetNames=n.SheetNames||n.Sheets.map(function(ve){return ve.name}),!u.supbooks&&(u.supbooks=fe,n.Names))for(var K=0;K<n.Names.length;++K)fe[0][K+1]=n.Names[K];var ke=[],ge=[],re=!1;Mf[16]={n:"BrtShortReal",f:YN};var we;if(mc(e,function(ce,ye,te){if(!E)switch(te){case 148:g=ce;break;case 0:S=ce,u.sheetRows&&u.sheetRows<=S.r&&(E=!0),z=nn(O=S.r),u["!row"]=S.r,(ce.hidden||ce.hpt||ce.level!=null)&&(ce.hpt&&(ce.hpx=X0(ce.hpt)),ge[ce.r]=ce);break;case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 13:case 14:case 15:case 16:case 17:case 18:case 62:switch(A={t:ce[2]},ce[2]){case"n":A.v=ce[1];break;case"s":F=pf[ce[1]],A.v=F.t,A.r=F.r;break;case"b":A.v=!!ce[1];break;case"e":A.v=ce[1],u.cellText!==!1&&(A.w=gc[A.v]);break;case"str":A.t="s",A.v=ce[1];break;case"is":A.t="s",A.v=ce[1].t;break}if((C=c.CellXf[ce[0].iStyleRef])&&$N(A,C.numFmtId,null,u,i,c),M=ce[0].c==-1?M+1:ce[0].c,u.dense?(h[O]||(h[O]=[]),h[O][M]=A):h[zs(M)+z]=A,u.cellFormula){for(Y=!1,B=0;B<G.length;++B){var q=G[B];S.r>=q[0].s.r&&S.r<=q[0].e.r&&M>=q[0].s.c&&M<=q[0].e.c&&(A.F=ba(q[0]),Y=!0)}!Y&&ce.length>3&&(A.f=ce[3])}if(y.s.r>S.r&&(y.s.r=S.r),y.s.c>M&&(y.s.c=M),y.e.r<S.r&&(y.e.r=S.r),y.e.c<M&&(y.e.c=M),u.cellDates&&C&&A.t=="n"&&ru(aa[C.numFmtId])){var J=wd(A.v);J&&(A.t="d",A.v=new Date(J.y,J.m-1,J.d,J.H,J.M,J.S,J.u))}we&&(we.type=="XLDAPR"&&(A.D=!0),we=void 0);break;case 1:case 12:if(!u.sheetStubs||w)break;A={t:"z",v:void 0},M=ce[0].c==-1?M+1:ce[0].c,u.dense?(h[O]||(h[O]=[]),h[O][M]=A):h[zs(M)+z]=A,y.s.r>S.r&&(y.s.r=S.r),y.s.c>M&&(y.s.c=M),y.e.r<S.r&&(y.e.r=S.r),y.e.c<M&&(y.e.c=M),we&&(we.type=="XLDAPR"&&(A.D=!0),we=void 0);break;case 176:X.push(ce);break;case 49:we=((u.xlmeta||{}).Cell||[])[ce-1];break;case 494:var ae=s["!id"][ce.relId];for(ae?(ce.Target=ae.Target,ce.loc&&(ce.Target+="#"+ce.loc),ce.Rel=ae):ce.relId==""&&(ce.Target="#"+ce.loc),O=ce.rfx.s.r;O<=ce.rfx.e.r;++O)for(M=ce.rfx.s.c;M<=ce.rfx.e.c;++M)u.dense?(h[O]||(h[O]=[]),h[O][M]||(h[O][M]={t:"z",v:void 0}),h[O][M].l=ce):(R=sa({c:M,r:O}),h[R]||(h[R]={t:"z",v:void 0}),h[R].l=ce);break;case 426:if(!u.cellFormula)break;G.push(ce),W=u.dense?h[O][M]:h[zs(M)+z],W.f=ki(ce[1],y,{r:S.r,c:M},fe,u),W.F=ba(ce[0]);break;case 427:if(!u.cellFormula)break;ie[sa(ce[0].s)]=ce[1],W=u.dense?h[O][M]:h[zs(M)+z],W.f=ki(ce[1],y,{r:S.r,c:M},fe,u);break;case 60:if(!u.cellStyles)break;for(;ce.e>=ce.s;)ke[ce.e--]={width:ce.w/256,hidden:!!(ce.flags&1),level:ce.level},re||(re=!0,By(ce.w/256)),Yc(ke[ce.e+1]);break;case 161:h["!autofilter"]={ref:ba(ce)};break;case 476:h["!margins"]=ce;break;case 147:n.Sheets[a]||(n.Sheets[a]={}),ce.name&&(n.Sheets[a].CodeName=ce.name),(ce.above||ce.left)&&(h["!outline"]={above:ce.above,left:ce.left});break;case 137:n.Views||(n.Views=[{}]),n.Views[0]||(n.Views[0]={}),ce.RTL&&(n.Views[0].RTL=!0);break;case 485:break;case 64:case 1053:break;case 151:break;case 152:case 175:case 644:case 625:case 562:case 396:case 1112:case 1146:case 471:case 1050:case 649:case 1105:case 589:case 607:case 564:case 1055:case 168:case 174:case 1180:case 499:case 507:case 550:case 171:case 167:case 1177:case 169:case 1181:case 551:case 552:case 661:case 639:case 478:case 537:case 477:case 536:case 1103:case 680:case 1104:case 1024:case 663:case 535:case 678:case 504:case 1043:case 428:case 170:case 3072:case 50:case 2070:case 1045:break;case 35:w=!0;break;case 36:w=!1;break;case 37:w=!0;break;case 38:w=!1;break;default:if(!ye.T){if(!w||u.WTF)throw new Error("Unexpected record 0x"+te.toString(16))}}},u),delete u.supbooks,delete u["!row"],!h["!ref"]&&(y.s.r<2e6||g&&(g.e.r>0||g.e.c>0||g.s.r>0||g.s.c>0))&&(h["!ref"]=ba(g||y)),u.sheetRows&&h["!ref"]){var ee=$a(h["!ref"]);u.sheetRows<=+ee.e.r&&(ee.e.r=u.sheetRows-1,ee.e.r>y.e.r&&(ee.e.r=y.e.r),ee.e.r<ee.s.r&&(ee.s.r=ee.e.r),ee.e.c>y.e.c&&(ee.e.c=y.e.c),ee.e.c<ee.s.c&&(ee.s.c=ee.e.c),h["!fullref"]=h["!ref"],h["!ref"]=ba(ee))}return X.length>0&&(h["!merges"]=X),ke.length>0&&(h["!cols"]=ke),ge.length>0&&(h["!rows"]=ge),h}function VM(e,r,a,s,n,i,c){if(r.v===void 0)return!1;var u="";switch(r.t){case"b":u=r.v?"1":"0";break;case"d":r=Es(r),r.z=r.z||aa[14],r.v=Pn(Cs(r.v)),r.t="n";break;case"n":case"e":u=""+r.v;break;default:u=r.v;break}var h={r:a,c:s};switch(h.s=Jc(n.cellXfs,r,n),r.l&&i["!links"].push([sa(h),r.l]),r.c&&i["!comments"].push([sa(h),r.c]),r.t){case"s":case"str":return n.bookSST?(u=$y(n.Strings,r.v,n.revStrings),h.t="s",h.v=u,c?mr(e,18,dM(r,h)):mr(e,7,lM(r,h))):(h.t="str",c?mr(e,17,_M(r,h)):mr(e,6,vM(r,h))),!0;case"n":return r.v==(r.v|0)&&r.v>-1e3&&r.v<1e3?c?mr(e,13,pM(r,h)):mr(e,2,gM(r,h)):c?mr(e,16,hM(r,h)):mr(e,5,fM(r,h)),!0;case"b":return h.t="b",c?mr(e,15,rM(r,h)):mr(e,4,eM(r,h)),!0;case"e":return h.t="e",c?mr(e,14,iM(r,h)):mr(e,3,sM(r,h)),!0}return c?mr(e,12,JI(r,h)):mr(e,1,ZI(r,h)),!0}function GM(e,r,a,s){var n=$a(r["!ref"]||"A1"),i,c="",u=[];mr(e,145);var h=Array.isArray(r),g=n.e.r;r["!rows"]&&(g=Math.max(n.e.r,r["!rows"].length-1));for(var y=n.s.r;y<=g;++y){c=nn(y),HI(e,r,n,y);var w=!1;if(y<=n.e.r)for(var E=n.s.c;E<=n.e.c;++E){y===n.s.r&&(u[E]=zs(E)),i=u[E]+c;var S=h?(r[y]||[])[E]:r[i];if(!S){w=!1;continue}w=VM(e,S,y,E,s,r,w)}}mr(e,146)}function YM(e,r){!r||!r["!merges"]||(mr(e,177,TM(r["!merges"].length)),r["!merges"].forEach(function(a){mr(e,176,EM(a))}),mr(e,178))}function qM(e,r){!r||!r["!cols"]||(mr(e,390),r["!cols"].forEach(function(a,s){a&&mr(e,60,IM(s,a))}),mr(e,391))}function XM(e,r){!r||!r["!ref"]||(mr(e,648),mr(e,649,UM($a(r["!ref"]))),mr(e,650))}function ZM(e,r,a){r["!links"].forEach(function(s){if(s[1].Target){var n=os(a,-1,s[1].Target.replace(/#.*$/,""),Aa.HLINK);mr(e,494,OM(s,n))}}),delete r["!links"]}function KM(e,r,a,s){if(r["!comments"].length>0){var n=os(s,-1,"../drawings/vmlDrawing"+(a+1)+".vml",Aa.VML);mr(e,551,Oy("rId"+n)),r["!legacy"]=n}}function JM(e,r,a,s){if(r["!autofilter"]){var n=r["!autofilter"],i=typeof n.ref=="string"?n.ref:ba(n.ref);a.Workbook||(a.Workbook={Sheets:[]}),a.Workbook.Names||(a.Workbook.Names=[]);var c=a.Workbook.Names,u=no(i);u.s.r==u.e.r&&(u.e.r=no(r["!ref"]).e.r,i=ba(u));for(var h=0;h<c.length;++h){var g=c[h];if(g.Name=="_xlnm._FilterDatabase"&&g.Sheet==s){g.Ref="'"+a.SheetNames[s]+"'!"+i;break}}h==c.length&&c.push({Name:"_xlnm._FilterDatabase",Sheet:s,Ref:"'"+a.SheetNames[s]+"'!"+i}),mr(e,161,nu($a(i))),mr(e,162)}}function QM(e,r,a){mr(e,133),mr(e,137,BM(r,a)),mr(e,138),mr(e,134)}function eP(e,r){r["!protect"]&&mr(e,535,zM(r["!protect"]))}function tP(e,r,a,s){var n=ro(),i=a.SheetNames[e],c=a.Sheets[i]||{},u=i;try{a&&a.Workbook&&(u=a.Workbook.Sheets[e].CodeName||u)}catch(g){}var h=$a(c["!ref"]||"A1");if(h.e.c>16383||h.e.r>1048575){if(r.WTF)throw new Error("Range "+(c["!ref"]||"A1")+" exceeds format limit A1:XFD1048576");h.e.c=Math.min(h.e.c,16383),h.e.r=Math.min(h.e.c,1048575)}return c["!links"]=[],c["!comments"]=[],mr(n,129),(a.vbaraw||c["!outline"])&&mr(n,147,qI(u,c["!outline"])),mr(n,148,VI(h)),QM(n,c,a.Workbook),qM(n,c),GM(n,c,e,r),eP(n,c),JM(n,c,a,e),YM(n,c),ZM(n,c,s),c["!margins"]&&mr(n,476,PM(c["!margins"])),(!r||r.ignoreEC||r.ignoreEC==null)&&XM(n,c),KM(n,c,e,s),mr(n,130),n.end()}function rP(e){var r=[],a=e.match(/^<c:numCache>/),s;(e.match(/<c:pt idx="(\d*)">(.*?)<\/c:pt>/mg)||[]).forEach(function(i){var c=i.match(/<c:pt idx="(\d*?)"><c:v>(.*)<\/c:v><\/c:pt>/);c&&(r[+c[1]]=a?+c[2]:c[2])});var n=Ha((e.match(/<c:formatCode>([\s\S]*?)<\/c:formatCode>/)||["","General"])[1]);return(e.match(/<c:f>(.*?)<\/c:f>/mg)||[]).forEach(function(i){s=i.replace(/<.*?>/g,"")}),[r,n,s]}function aP(e,r,a,s,n,i){var c=i||{"!type":"chart"};if(!e)return i;var u=0,h=0,g="A",y={s:{r:2e6,c:2e6},e:{r:0,c:0}};return(e.match(/<c:numCache>[\s\S]*?<\/c:numCache>/gm)||[]).forEach(function(w){var E=rP(w);y.s.r=y.s.c=0,y.e.c=u,g=zs(u),E[0].forEach(function(S,A){c[g+nn(A)]={t:"n",v:S,z:E[1]},h=A}),y.e.r<h&&(y.e.r=h),++u}),u>0&&(c["!ref"]=ba(y)),c}function sP(e,r,a,s,n){if(!e)return e;s||(s={"!id":{}});var i={"!type":"chart","!drawel":null,"!rel":""},c,u=e.match(VN);return u&&Vy(u[0],i,n,a),(c=e.match(/drawing r:id="(.*?)"/))&&(i["!rel"]=c[1]),s["!id"][i["!rel"]]&&(i["!drawel"]=s["!id"][i["!rel"]]),i}function nP(e,r){e.l+=10;var a=Ci(e);return{name:a}}function iP(e,r,a,s,n){if(!e)return e;s||(s={"!id":{}});var i={"!type":"chart","!drawel":null,"!rel":""},c=!1;return mc(e,function(h,g,y){switch(y){case 550:i["!rel"]=h;break;case 651:n.Sheets[a]||(n.Sheets[a]={}),h.name&&(n.Sheets[a].CodeName=h.name);break;case 562:case 652:case 669:case 679:case 551:case 552:case 476:case 3072:break;case 35:c=!0;break;case 36:c=!1;break;case 37:break;case 38:break;default:if(!(g.T>0)){if(!(g.T<0)){if(!c||r.WTF)throw new Error("Unexpected record 0x"+y.toString(16))}}}},r),s["!id"][i["!rel"]]&&(i["!drawel"]=s["!id"][i["!rel"]]),i}var Gy=[["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"]],oP=[["activeTab",0,"int"],["autoFilterDateGrouping",!0,"bool"],["firstSheet",0,"int"],["minimized",!1,"bool"],["showHorizontalScroll",!0,"bool"],["showSheetTabs",!0,"bool"],["showVerticalScroll",!0,"bool"],["tabRatio",600,"int"],["visibility","visible"]],lP=[],cP=[["calcCompleted","true"],["calcMode","auto"],["calcOnSave","true"],["concurrentCalc","true"],["fullCalcOnLoad","false"],["fullPrecision","true"],["iterate","false"],["iterateCount","100"],["iterateDelta","0.001"],["refMode","A1"]];function lk(e,r){for(var a=0;a!=e.length;++a)for(var s=e[a],n=0;n!=r.length;++n){var i=r[n];if(s[i[0]]==null)s[i[0]]=i[1];else switch(i[2]){case"bool":typeof s[i[0]]=="string"&&(s[i[0]]=Ss(s[i[0]]));break;case"int":typeof s[i[0]]=="string"&&(s[i[0]]=parseInt(s[i[0]],10));break}}}function ck(e,r){for(var a=0;a!=r.length;++a){var s=r[a];if(e[s[0]]==null)e[s[0]]=s[1];else switch(s[2]){case"bool":typeof e[s[0]]=="string"&&(e[s[0]]=Ss(e[s[0]]));break;case"int":typeof e[s[0]]=="string"&&(e[s[0]]=parseInt(e[s[0]],10));break}}}function XN(e){ck(e.WBProps,Gy),ck(e.CalcPr,cP),lk(e.WBView,oP),lk(e.Sheets,lP),V0.date1904=Ss(e.WBProps.date1904)}function dP(e){return!e.Workbook||!e.Workbook.WBProps?"false":Ss(e.Workbook.WBProps.date1904)?"true":"false"}var uP="][*?/\\".split("");function ZN(e,r){if(e.length>31)throw new Error("Sheet names cannot exceed 31 chars");var a=!0;return uP.forEach(function(s){if(e.indexOf(s)!=-1)throw new Error("Sheet name cannot contain : \\ / ? * [ ]")}),a}function fP(e,r,a){e.forEach(function(s,n){ZN(s);for(var i=0;i<n;++i)if(s==e[i])throw new Error("Duplicate Sheet Name: "+s);if(a){var c=r&&r[n]&&r[n].CodeName||s;if(c.charCodeAt(0)==95&&c.length>22)throw new Error("Bad Code Name: Worksheet"+c)}})}function hP(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||[];fP(e.SheetNames,r,!!e.vbaraw);for(var a=0;a<e.SheetNames.length;++a)dI(e.Sheets[e.SheetNames[a]],e.SheetNames[a],a)}var mP=/<\w+:workbook/;function gP(e,r){if(!e)throw new Error("Could not find file");var a={AppVersion:{},WBProps:{},WBView:[],Sheets:[],CalcPr:{},Names:[],xmlns:""},s=!1,n="xmlns",i={},c=0;if(e.replace(Ti,function(h,g){var y=ia(h);switch(Ml(y[0])){case"<?xml":break;case"<workbook":h.match(mP)&&(n="xmlns"+h.match(/<(\w+):/)[1]),a.xmlns=y[n];break;case"</workbook>":break;case"<fileVersion":delete y[0],a.AppVersion=y;break;case"<fileVersion/>":case"</fileVersion>":break;case"<fileSharing":break;case"<fileSharing/>":break;case"<workbookPr":case"<workbookPr/>":Gy.forEach(function(w){if(y[w[0]]!=null)switch(w[2]){case"bool":a.WBProps[w[0]]=Ss(y[w[0]]);break;case"int":a.WBProps[w[0]]=parseInt(y[w[0]],10);break;default:a.WBProps[w[0]]=y[w[0]]}}),y.codeName&&(a.WBProps.CodeName=ms(y.codeName));break;case"</workbookPr>":break;case"<workbookProtection":break;case"<workbookProtection/>":break;case"<bookViews":case"<bookViews>":case"</bookViews>":break;case"<workbookView":case"<workbookView/>":delete y[0],a.WBView.push(y);break;case"</workbookView>":break;case"<sheets":case"<sheets>":case"</sheets>":break;case"<sheet":switch(y.state){case"hidden":y.Hidden=1;break;case"veryHidden":y.Hidden=2;break;default:y.Hidden=0}delete y.state,y.name=Ha(ms(y.name)),delete y[0],a.Sheets.push(y);break;case"</sheet>":break;case"<functionGroups":case"<functionGroups/>":break;case"<functionGroup":break;case"<externalReferences":case"</externalReferences>":case"<externalReferences>":break;case"<externalReference":break;case"<definedNames/>":break;case"<definedNames>":case"<definedNames":s=!0;break;case"</definedNames>":s=!1;break;case"<definedName":i={},i.Name=ms(y.name),y.comment&&(i.Comment=y.comment),y.localSheetId&&(i.Sheet=+y.localSheetId),Ss(y.hidden||"0")&&(i.Hidden=!0),c=g+h.length;break;case"</definedName>":i.Ref=Ha(ms(e.slice(c,g))),a.Names.push(i);break;case"<definedName/>":break;case"<calcPr":delete y[0],a.CalcPr=y;break;case"<calcPr/>":delete y[0],a.CalcPr=y;break;case"</calcPr>":break;case"<oleSize":break;case"<customWorkbookViews>":case"</customWorkbookViews>":case"<customWorkbookViews":break;case"<customWorkbookView":case"</customWorkbookView>":break;case"<pivotCaches>":case"</pivotCaches>":case"<pivotCaches":break;case"<pivotCache":break;case"<smartTagPr":case"<smartTagPr/>":break;case"<smartTagTypes":case"<smartTagTypes>":case"</smartTagTypes>":break;case"<smartTagType":break;case"<webPublishing":case"<webPublishing/>":break;case"<fileRecoveryPr":case"<fileRecoveryPr/>":break;case"<webPublishObjects>":case"<webPublishObjects":case"</webPublishObjects>":break;case"<webPublishObject":break;case"<extLst":case"<extLst>":case"</extLst>":case"<extLst/>":break;case"<ext":s=!0;break;case"</ext>":s=!1;break;case"<ArchID":break;case"<AlternateContent":case"<AlternateContent>":s=!0;break;case"</AlternateContent>":s=!1;break;case"<revisionPtr":break;default:if(!s&&r.WTF)throw new Error("unrecognized "+y[0]+" in workbook")}return h}),Vd.indexOf(a.xmlns)===-1)throw new Error("Unknown Namespace: "+a.xmlns);return XN(a),a}function KN(e){var r=[cn];r[r.length]=kr("workbook",null,{xmlns:Vd[0],"xmlns:r":Fn.r});var a=e.Workbook&&(e.Workbook.Names||[]).length>0,s={codeName:"ThisWorkbook"};e.Workbook&&e.Workbook.WBProps&&(Gy.forEach(function(u){e.Workbook.WBProps[u[0]]!=null&&e.Workbook.WBProps[u[0]]!=u[1]&&(s[u[0]]=e.Workbook.WBProps[u[0]])}),e.Workbook.WBProps.CodeName&&(s.codeName=e.Workbook.WBProps.CodeName,delete s.CodeName)),r[r.length]=kr("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 c={name:ls(e.SheetNames[i].slice(0,31))};if(c.sheetId=""+(i+1),c["r:id"]="rId"+(i+1),n[i])switch(n[i].Hidden){case 1:c.state="hidden";break;case 2:c.state="veryHidden";break}r[r.length]=kr("sheet",null,c)}return r[r.length]="</sheets>",a&&(r[r.length]="<definedNames>",e.Workbook&&e.Workbook.Names&&e.Workbook.Names.forEach(function(u){var h={name:u.Name};u.Comment&&(h.comment=u.Comment),u.Sheet!=null&&(h.localSheetId=""+u.Sheet),u.Hidden&&(h.hidden="1"),u.Ref&&(r[r.length]=kr("definedName",ls(u.Ref),h))}),r[r.length]="</definedNames>"),r.length>2&&(r[r.length]="</workbook>",r[1]=r[1].replace("/>",">")),r.join("")}function xP(e,r){var a={};return a.Hidden=e.read_shift(4),a.iTabID=e.read_shift(4),a.strRelID=j1(e),a.name=Ci(e),a}function pP(e,r){return r||(r=sr(127)),r.write_shift(4,e.Hidden),r.write_shift(4,e.iTabID),Oy(e.strRelID,r),Xn(e.name.slice(0,31),r),r.length>r.l?r.slice(0,r.l):r}function yP(e,r){var a={},s=e.read_shift(4);a.defaultThemeVersion=e.read_shift(4);var n=r>8?Ci(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 bP(e,r){r||(r=sr(72));var a=0;return e&&e.filterPrivacy&&(a|=8),r.write_shift(4,a),r.write_shift(4,0),W3(e&&e.CodeName||"ThisWorkbook",r),r.slice(0,r.l)}function vP(e,r){var a={};return e.read_shift(4),a.ArchID=e.read_shift(4),e.l+=r-8,a}function wP(e,r,a){var s=e.l+r;e.l+=4,e.l+=1;var n=e.read_shift(4),i=KA(e),c=sI(e,0,a),u=Ay(e);e.l=s;var h={Name:i,Ptg:c};return n<268435455&&(h.Sheet=n),u&&(h.Comment=u),h}function _P(e,r){var a={AppVersion:{},WBProps:{},WBView:[],Sheets:[],CalcPr:{},xmlns:""},s=[],n=!1;r||(r={}),r.biff=12;var i=[],c=[[]];return c.SheetNames=[],c.XTI=[],Mf[16]={n:"BrtFRTArchID$",f:vP},mc(e,function(h,g,y){switch(y){case 156:c.SheetNames.push(h.name),a.Sheets.push(h);break;case 153:a.WBProps=h;break;case 39:h.Sheet!=null&&(r.SID=h.Sheet),h.Ref=ki(h.Ptg,null,null,c,r),delete r.SID,delete h.Ptg,i.push(h);break;case 1036:break;case 357:case 358:case 355:case 667:c[0].length?c.push([y,h]):c[0]=[y,h],c[c.length-1].XTI=[];break;case 362:c.length===0&&(c[0]=[],c[0].XTI=[]),c[c.length-1].XTI=c[c.length-1].XTI.concat(h),c.XTI=c.XTI.concat(h);break;case 361:break;case 2071:case 158:case 143:case 664:case 353:break;case 3072:case 3073:case 534:case 677:case 157:case 610:case 2050:case 155:case 548:case 676:case 128:case 665:case 2128:case 2125:case 549:case 2053:case 596:case 2076:case 2075:case 2082:case 397:case 154:case 1117:case 553:case 2091:break;case 35:s.push(y),n=!0;break;case 36:s.pop(),n=!1;break;case 37:s.push(y),n=!0;break;case 38:s.pop(),n=!1;break;case 16:break;default:if(!g.T){if(!n||r.WTF&&s[s.length-1]!=37&&s[s.length-1]!=35)throw new Error("Unexpected record 0x"+y.toString(16))}}},r),XN(a),a.Names=i,a.supbooks=c,a}function kP(e,r){mr(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]};mr(e,156,pP(n))}mr(e,144)}function NP(e,r){r||(r=sr(127));for(var a=0;a!=4;++a)r.write_shift(4,0);return Xn("SheetJS",r),Xn(Ym.version,r),Xn(Ym.version,r),Xn("7262",r),r.length>r.l?r.slice(0,r.l):r}function jP(e,r){r||(r=sr(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 SP(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||(mr(e,135),mr(e,158,jP(n)),mr(e,136))}}function CP(e,r){var a=ro();return mr(a,131),mr(a,128,NP()),mr(a,153,bP(e.Workbook&&e.Workbook.WBProps||null)),SP(a,e),kP(a,e),mr(a,132),a.end()}function EP(e,r,a){return r.slice(-4)===".bin"?_P(e,a):gP(e,a)}function TP(e,r,a,s,n,i,c,u){return r.slice(-4)===".bin"?$M(e,s,a,n,i,c,u):wI(e,s,a,n,i,c,u)}function AP(e,r,a,s,n,i,c,u){return r.slice(-4)===".bin"?iP(e,s,a,n,i):sP(e,s,a,n,i)}function OP(e,r,a,s,n,i,c,u){return r.slice(-4)===".bin"?RR():FR()}function DP(e,r,a,s,n,i,c,u){return r.slice(-4)===".bin"?OR():DR()}function RP(e,r,a,s){return r.slice(-4)===".bin"?ED(e,a,s):xD(e,a,s)}function FP(e,r,a){return ON(e,a)}function IP(e,r,a){return r.slice(-4)===".bin"?IO(e,a):DO(e,a)}function MP(e,r,a){return r.slice(-4)===".bin"?SR(e,a):pR(e,a)}function PP(e,r,a){return r.slice(-4)===".bin"?mR(e):fR(e)}function LP(e,r,a,s){return a.slice(-4)===".bin"?gR(e,r,a,s):void 0}function BP(e,r,a){return r.slice(-4)===".bin"?cR(e,r,a):uR(e,r,a)}function UP(e,r,a){return(r.slice(-4)===".bin"?CP:KN)(e)}function zP(e,r,a,s,n){return(r.slice(-4)===".bin"?tP:GN)(e,a,s,n)}function WP(e,r,a){return(r.slice(-4)===".bin"?LD:TN)(e,a)}function HP(e,r,a){return(r.slice(-4)===".bin"?LO:wN)(e,a)}function $P(e,r,a){return(r.slice(-4)===".bin"?CR:FN)(e)}function VP(e){return(e.slice(-4)===".bin"?dR:DN)()}var JN=/([\w:]+)=((?:")([^"]*)(?:")|(?:')([^']*)(?:'))/g,QN=/([\w:]+)=((?:")(?:[^"]*)(?:")|(?:')(?:[^']*)(?:'))/;function sl(e,r){var a=e.split(/\s+/),s=[];if(s[0]=a[0],a.length===1)return s;var n=e.match(JN),i,c,u,h;if(n)for(h=0;h!=n.length;++h)i=n[h].match(QN),(c=i[1].indexOf(":"))===-1?s[i[1]]=i[2].slice(1,i[2].length-1):(i[1].slice(0,6)==="xmlns:"?u="xmlns"+i[1].slice(6):u=i[1].slice(c+1),s[u]=i[2].slice(1,i[2].length-1));return s}function GP(e){var r=e.split(/\s+/),a={};if(r.length===1)return a;var s=e.match(JN),n,i,c,u;if(s)for(u=0;u!=s.length;++u)n=s[u].match(QN),(i=n[1].indexOf(":"))===-1?a[n[1]]=n[2].slice(1,n[2].length-1):(n[1].slice(0,6)==="xmlns:"?c="xmlns"+n[1].slice(6):c=n[1].slice(i+1),a[c]=n[2].slice(1,n[2].length-1));return a}var bf;function YP(e,r){var a=bf[e]||Ha(e);return a==="General"?Pd(r):Yo(a,r)}function qP(e,r,a,s){var n=s;switch((a[0].match(/dt:dt="([\w.]+)"/)||["",""])[1]){case"boolean":n=Ss(s);break;case"i2":case"int":n=parseInt(s,10);break;case"r4":case"float":n=parseFloat(s);break;case"date":case"dateTime.tz":n=Cs(s);break;case"i8":case"string":case"fixed":case"uuid":case"bin.base64":break;default:throw new Error("bad custprop:"+a[0])}e[Ha(r)]=n}function XP(e,r,a){if(e.t!=="z"){if(!a||a.cellText!==!1)try{e.t==="e"?e.w=e.w||gc[e.v]:r==="General"?e.t==="n"?(e.v|0)===e.v?e.w=e.v.toString(10):e.w=Cf(e.v):e.w=Pd(e.v):e.w=YP(r||"General",e.v)}catch(i){if(a.WTF)throw i}try{var s=bf[r]||r||"General";if(a.cellNF&&(e.z=s),a.cellDates&&e.t=="n"&&ru(s)){var n=wd(e.v);n&&(e.t="d",e.v=new Date(n.y,n.m-1,n.d,n.H,n.M,n.S,n.u))}}catch(i){if(a.WTF)throw i}}}function ZP(e,r,a){if(a.cellStyles&&r.Interior){var s=r.Interior;s.Pattern&&(s.patternType=lD[s.Pattern]||s.Pattern)}e[r.ID]=r}function KP(e,r,a,s,n,i,c,u,h,g){var y="General",w=s.StyleID,E={};g=g||{};var S=[],A=0;for(w===void 0&&u&&(w=u.StyleID),w===void 0&&c&&(w=c.StyleID);i[w]!==void 0&&(i[w].nf&&(y=i[w].nf),i[w].Interior&&S.push(i[w].Interior),!!i[w].Parent);)w=i[w].Parent;switch(a.Type){case"Boolean":s.t="b",s.v=Ss(e);break;case"String":s.t="s",s.r=S_(Ha(e)),s.v=e.indexOf("<")>-1?Ha(r||e).replace(/<.*?>/g,""):s.r;break;case"DateTime":e.slice(-1)!="Z"&&(e+="Z"),s.v=(Cs(e)-new Date(Date.UTC(1899,11,30)))/(1440*60*1e3),s.v!==s.v?s.v=Ha(e):s.v<60&&(s.v=s.v-1),(!y||y=="General")&&(y="yyyy-mm-dd");case"Number":s.v===void 0&&(s.v=+e),s.t||(s.t="n");break;case"Error":s.t="e",s.v=Y3[e],g.cellText!==!1&&(s.w=e);break;default:e==""&&r==""?s.t="z":(s.t="s",s.v=S_(r||e));break}if(XP(s,y,g),g.cellFormula!==!1)if(s.Formula){var C=Ha(s.Formula);C.charCodeAt(0)==61&&(C=C.slice(1)),s.f=$0(C,n),delete s.Formula,s.ArrayRange=="RC"?s.F=$0("RC:RC",n):s.ArrayRange&&(s.F=$0(s.ArrayRange,n),h.push([$a(s.F),s.F]))}else for(A=0;A<h.length;++A)n.r>=h[A][0].s.r&&n.r<=h[A][0].e.r&&n.c>=h[A][0].s.c&&n.c<=h[A][0].e.c&&(s.F=h[A][1]);g.cellStyles&&(S.forEach(function(O){!E.patternType&&O.patternType&&(E.patternType=O.patternType)}),s.s=E),s.StyleID!==void 0&&(s.ixfe=s.StyleID)}function JP(e){e.t=e.v||"",e.t=e.t.replace(/\r\n/g,`
`).replace(/\r/g,`
`),e.v=e.w=e.ixfe=void 0}function Xp(e,r){var a=r||{};au();var s=af(Ny(e));(a.type=="binary"||a.type=="array"||a.type=="base64")&&(s=ms(s));var n=s.slice(0,1024).toLowerCase(),i=!1;if(n=n.replace(/".*?"/g,""),(n.indexOf(">")&1023)>Math.min(n.indexOf(",")&1023,n.indexOf(";")&1023)){var c=Es(a);return c.type="string",q0.to_workbook(s,c)}if(n.indexOf("<?xml")==-1&&["html","table","head","meta","script","style","div"].forEach(function(Lt){n.indexOf("<"+Lt)>=0&&(i=!0)}),i)return PL(s,a);bf={"General Number":"General","General Date":aa[22],"Long Date":"dddd, mmmm dd, yyyy","Medium Date":aa[15],"Short Date":aa[14],"Long Time":aa[19],"Medium Time":aa[18],"Short Time":aa[20],Currency:'"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',Fixed:aa[2],Standard:aa[4],Percent:aa[10],Scientific:aa[11],"Yes/No":'"Yes";"Yes";"No";@',"True/False":'"True";"True";"False";@',"On/Off":'"Yes";"Yes";"No";@'};var u,h=[],g,y={},w=[],E=a.dense?[]:{},S="",A={},C={},O=sl('<Data ss:Type="String">'),M=0,R=0,F=0,z={s:{r:2e6,c:2e6},e:{r:0,c:0}},W={},X={},B="",Y=0,G=[],ie={},fe={},K=0,ke=[],ge=[],re={},we=[],ee,ve=!1,ce=[],ye=[],te={},q=0,J=0,ae={Sheets:[],WBProps:{date1904:!1}},oe={};Af.lastIndex=0,s=s.replace(/<!--([\s\S]*?)-->/mg,"");for(var le="";u=Af.exec(s);)switch(u[3]=(le=u[3]).toLowerCase()){case"data":if(le=="data"){if(u[1]==="/"){if((g=h.pop())[0]!==u[3])throw new Error("Bad state: "+g.join("|"))}else u[0].charAt(u[0].length-2)!=="/"&&h.push([u[3],!0]);break}if(h[h.length-1][1])break;u[1]==="/"?KP(s.slice(M,u.index),B,O,h[h.length-1][0]=="comment"?re:A,{c:R,r:F},W,we[R],C,ce,a):(B="",O=sl(u[0]),M=u.index+u[0].length);break;case"cell":if(u[1]==="/")if(ge.length>0&&(A.c=ge),(!a.sheetRows||a.sheetRows>F)&&A.v!==void 0&&(a.dense?(E[F]||(E[F]=[]),E[F][R]=A):E[zs(R)+nn(F)]=A),A.HRef&&(A.l={Target:Ha(A.HRef)},A.HRefScreenTip&&(A.l.Tooltip=A.HRefScreenTip),delete A.HRef,delete A.HRefScreenTip),(A.MergeAcross||A.MergeDown)&&(q=R+(parseInt(A.MergeAcross,10)|0),J=F+(parseInt(A.MergeDown,10)|0),G.push({s:{c:R,r:F},e:{c:q,r:J}})),!a.sheetStubs)A.MergeAcross?R=q+1:++R;else if(A.MergeAcross||A.MergeDown){for(var be=R;be<=q;++be)for(var Z=F;Z<=J;++Z)(be>R||Z>F)&&(a.dense?(E[Z]||(E[Z]=[]),E[Z][be]={t:"z"}):E[zs(be)+nn(Z)]={t:"z"});R=q+1}else++R;else A=GP(u[0]),A.Index&&(R=+A.Index-1),R<z.s.c&&(z.s.c=R),R>z.e.c&&(z.e.c=R),u[0].slice(-2)==="/>"&&++R,ge=[];break;case"row":u[1]==="/"||u[0].slice(-2)==="/>"?(F<z.s.r&&(z.s.r=F),F>z.e.r&&(z.e.r=F),u[0].slice(-2)==="/>"&&(C=sl(u[0]),C.Index&&(F=+C.Index-1)),R=0,++F):(C=sl(u[0]),C.Index&&(F=+C.Index-1),te={},(C.AutoFitHeight=="0"||C.Height)&&(te.hpx=parseInt(C.Height,10),te.hpt=If(te.hpx),ye[F]=te),C.Hidden=="1"&&(te.hidden=!0,ye[F]=te));break;case"worksheet":if(u[1]==="/"){if((g=h.pop())[0]!==u[3])throw new Error("Bad state: "+g.join("|"));w.push(S),z.s.r<=z.e.r&&z.s.c<=z.e.c&&(E["!ref"]=ba(z),a.sheetRows&&a.sheetRows<=z.e.r&&(E["!fullref"]=E["!ref"],z.e.r=a.sheetRows-1,E["!ref"]=ba(z))),G.length&&(E["!merges"]=G),we.length>0&&(E["!cols"]=we),ye.length>0&&(E["!rows"]=ye),y[S]=E}else z={s:{r:2e6,c:2e6},e:{r:0,c:0}},F=R=0,h.push([u[3],!1]),g=sl(u[0]),S=Ha(g.Name),E=a.dense?[]:{},G=[],ce=[],ye=[],oe={name:S,Hidden:0},ae.Sheets.push(oe);break;case"table":if(u[1]==="/"){if((g=h.pop())[0]!==u[3])throw new Error("Bad state: "+g.join("|"))}else{if(u[0].slice(-2)=="/>")break;h.push([u[3],!1]),we=[],ve=!1}break;case"style":u[1]==="/"?ZP(W,X,a):X=sl(u[0]);break;case"numberformat":X.nf=Ha(sl(u[0]).Format||"General"),bf[X.nf]&&(X.nf=bf[X.nf]);for(var Le=0;Le!=392&&aa[Le]!=X.nf;++Le);if(Le==392){for(Le=57;Le!=392;++Le)if(aa[Le]==null){lc(X.nf,Le);break}}break;case"column":if(h[h.length-1][0]!=="table")break;if(ee=sl(u[0]),ee.Hidden&&(ee.hidden=!0,delete ee.Hidden),ee.Width&&(ee.wpx=parseInt(ee.Width,10)),!ve&&ee.wpx>10){ve=!0,Ni=CN;for(var Pe=0;Pe<we.length;++Pe)we[Pe]&&Yc(we[Pe])}ve&&Yc(ee),we[ee.Index-1||we.length]=ee;for(var Be=0;Be<+ee.Span;++Be)we[we.length]=Es(ee);break;case"namedrange":if(u[1]==="/")break;ae.Names||(ae.Names=[]);var pe=ia(u[0]),rt={Name:pe.Name,Ref:$0(pe.RefersTo.slice(1),{r:0,c:0})};ae.Sheets.length>0&&(rt.Sheet=ae.Sheets.length-1),ae.Names.push(rt);break;case"namedcell":break;case"b":break;case"i":break;case"u":break;case"s":break;case"em":break;case"h2":break;case"h3":break;case"sub":break;case"sup":break;case"span":break;case"alignment":break;case"borders":break;case"border":break;case"font":if(u[0].slice(-2)==="/>")break;u[1]==="/"?B+=s.slice(Y,u.index):Y=u.index+u[0].length;break;case"interior":if(!a.cellStyles)break;X.Interior=sl(u[0]);break;case"protection":break;case"author":case"title":case"description":case"created":case"keywords":case"subject":case"category":case"company":case"lastauthor":case"lastsaved":case"lastprinted":case"version":case"revision":case"totaltime":case"hyperlinkbase":case"manager":case"contentstatus":case"identifier":case"language":case"appname":if(u[0].slice(-2)==="/>")break;u[1]==="/"?_7(ie,le,s.slice(K,u.index)):K=u.index+u[0].length;break;case"paragraphs":break;case"styles":case"workbook":if(u[1]==="/"){if((g=h.pop())[0]!==u[3])throw new Error("Bad state: "+g.join("|"))}else h.push([u[3],!1]);break;case"comment":if(u[1]==="/"){if((g=h.pop())[0]!==u[3])throw new Error("Bad state: "+g.join("|"));JP(re),ge.push(re)}else h.push([u[3],!1]),g=sl(u[0]),re={a:g.Author};break;case"autofilter":if(u[1]==="/"){if((g=h.pop())[0]!==u[3])throw new Error("Bad state: "+g.join("|"))}else if(u[0].charAt(u[0].length-2)!=="/"){var ct=sl(u[0]);E["!autofilter"]={ref:$0(ct.Range).replace(/\$/g,"")},h.push([u[3],!0])}break;case"name":break;case"datavalidation":if(u[1]==="/"){if((g=h.pop())[0]!==u[3])throw new Error("Bad state: "+g.join("|"))}else u[0].charAt(u[0].length-2)!=="/"&&h.push([u[3],!0]);break;case"pixelsperinch":break;case"componentoptions":case"documentproperties":case"customdocumentproperties":case"officedocumentsettings":case"pivottable":case"pivotcache":case"names":case"mapinfo":case"pagebreaks":case"querytable":case"sorting":case"schema":case"conditionalformatting":case"smarttagtype":case"smarttags":case"excelworkbook":case"workbookoptions":case"worksheetoptions":if(u[1]==="/"){if((g=h.pop())[0]!==u[3])throw new Error("Bad state: "+g.join("|"))}else u[0].charAt(u[0].length-2)!=="/"&&h.push([u[3],!0]);break;case"null":break;default:if(h.length==0&&u[3]=="document"||h.length==0&&u[3]=="uof")return mk(s,a);var et=!0;switch(h[h.length-1][0]){case"officedocumentsettings":switch(u[3]){case"allowpng":break;case"removepersonalinformation":break;case"downloadcomponents":break;case"locationofcomponents":break;case"colors":break;case"color":break;case"index":break;case"rgb":break;case"targetscreensize":break;case"readonlyrecommended":break;default:et=!1}break;case"componentoptions":switch(u[3]){case"toolbar":break;case"hideofficelogo":break;case"spreadsheetautofit":break;case"label":break;case"caption":break;case"maxheight":break;case"maxwidth":break;case"nextsheetnumber":break;default:et=!1}break;case"excelworkbook":switch(u[3]){case"date1904":ae.WBProps.date1904=!0;break;case"windowheight":break;case"windowwidth":break;case"windowtopx":break;case"windowtopy":break;case"tabratio":break;case"protectstructure":break;case"protectwindow":break;case"protectwindows":break;case"activesheet":break;case"displayinknotes":break;case"firstvisiblesheet":break;case"supbook":break;case"sheetname":break;case"sheetindex":break;case"sheetindexfirst":break;case"sheetindexlast":break;case"dll":break;case"acceptlabelsinformulas":break;case"donotsavelinkvalues":break;case"iteration":break;case"maxiterations":break;case"maxchange":break;case"path":break;case"xct":break;case"count":break;case"selectedsheets":break;case"calculation":break;case"uncalced":break;case"startupprompt":break;case"crn":break;case"externname":break;case"formula":break;case"colfirst":break;case"collast":break;case"wantadvise":break;case"boolean":break;case"error":break;case"text":break;case"ole":break;case"noautorecover":break;case"publishobjects":break;case"donotcalculatebeforesave":break;case"number":break;case"refmoder1c1":break;case"embedsavesmarttags":break;default:et=!1}break;case"workbookoptions":switch(u[3]){case"owcversion":break;case"height":break;case"width":break;default:et=!1}break;case"worksheetoptions":switch(u[3]){case"visible":if(u[0].slice(-2)!=="/>")if(u[1]==="/")switch(s.slice(K,u.index)){case"SheetHidden":oe.Hidden=1;break;case"SheetVeryHidden":oe.Hidden=2;break}else K=u.index+u[0].length;break;case"header":E["!margins"]||Ad(E["!margins"]={},"xlml"),isNaN(+ia(u[0]).Margin)||(E["!margins"].header=+ia(u[0]).Margin);break;case"footer":E["!margins"]||Ad(E["!margins"]={},"xlml"),isNaN(+ia(u[0]).Margin)||(E["!margins"].footer=+ia(u[0]).Margin);break;case"pagemargins":var It=ia(u[0]);E["!margins"]||Ad(E["!margins"]={},"xlml"),isNaN(+It.Top)||(E["!margins"].top=+It.Top),isNaN(+It.Left)||(E["!margins"].left=+It.Left),isNaN(+It.Right)||(E["!margins"].right=+It.Right),isNaN(+It.Bottom)||(E["!margins"].bottom=+It.Bottom);break;case"displayrighttoleft":ae.Views||(ae.Views=[]),ae.Views[0]||(ae.Views[0]={}),ae.Views[0].RTL=!0;break;case"freezepanes":break;case"frozennosplit":break;case"splithorizontal":case"splitvertical":break;case"donotdisplaygridlines":break;case"activerow":break;case"activecol":break;case"toprowbottompane":break;case"leftcolumnrightpane":break;case"unsynced":break;case"print":break;case"printerrors":break;case"panes":break;case"scale":break;case"pane":break;case"number":break;case"layout":break;case"pagesetup":break;case"selected":break;case"protectobjects":break;case"enableselection":break;case"protectscenarios":break;case"validprinterinfo":break;case"horizontalresolution":break;case"verticalresolution":break;case"numberofcopies":break;case"activepane":break;case"toprowvisible":break;case"leftcolumnvisible":break;case"fittopage":break;case"rangeselection":break;case"papersizeindex":break;case"pagelayoutzoom":break;case"pagebreakzoom":break;case"filteron":break;case"fitwidth":break;case"fitheight":break;case"commentslayout":break;case"zoom":break;case"lefttoright":break;case"gridlines":break;case"allowsort":break;case"allowfilter":break;case"allowinsertrows":break;case"allowdeleterows":break;case"allowinsertcols":break;case"allowdeletecols":break;case"allowinserthyperlinks":break;case"allowformatcells":break;case"allowsizecols":break;case"allowsizerows":break;case"nosummaryrowsbelowdetail":E["!outline"]||(E["!outline"]={}),E["!outline"].above=!0;break;case"tabcolorindex":break;case"donotdisplayheadings":break;case"showpagelayoutzoom":break;case"nosummarycolumnsrightdetail":E["!outline"]||(E["!outline"]={}),E["!outline"].left=!0;break;case"blackandwhite":break;case"donotdisplayzeros":break;case"displaypagebreak":break;case"rowcolheadings":break;case"donotdisplayoutline":break;case"noorientation":break;case"allowusepivottables":break;case"zeroheight":break;case"viewablerange":break;case"selection":break;case"protectcontents":break;default:et=!1}break;case"pivottable":case"pivotcache":switch(u[3]){case"immediateitemsondrop":break;case"showpagemultipleitemlabel":break;case"compactrowindent":break;case"location":break;case"pivotfield":break;case"orientation":break;case"layoutform":break;case"layoutsubtotallocation":break;case"layoutcompactrow":break;case"position":break;case"pivotitem":break;case"datatype":break;case"datafield":break;case"sourcename":break;case"parentfield":break;case"ptlineitems":break;case"ptlineitem":break;case"countofsameitems":break;case"item":break;case"itemtype":break;case"ptsource":break;case"cacheindex":break;case"consolidationreference":break;case"filename":break;case"reference":break;case"nocolumngrand":break;case"norowgrand":break;case"blanklineafteritems":break;case"hidden":break;case"subtotal":break;case"basefield":break;case"mapchilditems":break;case"function":break;case"refreshonfileopen":break;case"printsettitles":break;case"mergelabels":break;case"defaultversion":break;case"refreshname":break;case"refreshdate":break;case"refreshdatecopy":break;case"versionlastrefresh":break;case"versionlastupdate":break;case"versionupdateablemin":break;case"versionrefreshablemin":break;case"calculation":break;default:et=!1}break;case"pagebreaks":switch(u[3]){case"colbreaks":break;case"colbreak":break;case"rowbreaks":break;case"rowbreak":break;case"colstart":break;case"colend":break;case"rowend":break;default:et=!1}break;case"autofilter":switch(u[3]){case"autofiltercolumn":break;case"autofiltercondition":break;case"autofilterand":break;case"autofilteror":break;default:et=!1}break;case"querytable":switch(u[3]){case"id":break;case"autoformatfont":break;case"autoformatpattern":break;case"querysource":break;case"querytype":break;case"enableredirections":break;case"refreshedinxl9":break;case"urlstring":break;case"htmltables":break;case"connection":break;case"commandtext":break;case"refreshinfo":break;case"notitles":break;case"nextid":break;case"columninfo":break;case"overwritecells":break;case"donotpromptforfile":break;case"textwizardsettings":break;case"source":break;case"number":break;case"decimal":break;case"thousandseparator":break;case"trailingminusnumbers":break;case"formatsettings":break;case"fieldtype":break;case"delimiters":break;case"tab":break;case"comma":break;case"autoformatname":break;case"versionlastedit":break;case"versionlastrefresh":break;default:et=!1}break;case"datavalidation":switch(u[3]){case"range":break;case"type":break;case"min":break;case"max":break;case"sort":break;case"descending":break;case"order":break;case"casesensitive":break;case"value":break;case"errorstyle":break;case"errormessage":break;case"errortitle":break;case"inputmessage":break;case"inputtitle":break;case"combohide":break;case"inputhide":break;case"condition":break;case"qualifier":break;case"useblank":break;case"value1":break;case"value2":break;case"format":break;case"cellrangelist":break;default:et=!1}break;case"sorting":case"conditionalformatting":switch(u[3]){case"range":break;case"type":break;case"min":break;case"max":break;case"sort":break;case"descending":break;case"order":break;case"casesensitive":break;case"value":break;case"errorstyle":break;case"errormessage":break;case"errortitle":break;case"cellrangelist":break;case"inputmessage":break;case"inputtitle":break;case"combohide":break;case"inputhide":break;case"condition":break;case"qualifier":break;case"useblank":break;case"value1":break;case"value2":break;case"format":break;default:et=!1}break;case"mapinfo":case"schema":case"data":switch(u[3]){case"map":break;case"entry":break;case"range":break;case"xpath":break;case"field":break;case"xsdtype":break;case"filteron":break;case"aggregate":break;case"elementtype":break;case"attributetype":break;case"schema":case"element":case"complextype":case"datatype":case"all":case"attribute":case"extends":break;case"row":break;default:et=!1}break;case"smarttags":break;default:et=!1;break}if(et||u[3].match(/!\[CDATA/))break;if(!h[h.length-1][1])throw"Unrecognized tag: "+u[3]+"|"+h.join("|");if(h[h.length-1][0]==="customdocumentproperties"){if(u[0].slice(-2)==="/>")break;u[1]==="/"?qP(fe,le,ke,s.slice(K,u.index)):(ke=u,K=u.index+u[0].length);break}if(a.WTF)throw"Unrecognized tag: "+u[3]+"|"+h.join("|")}var ft={};return!a.bookSheets&&!a.bookProps&&(ft.Sheets=y),ft.SheetNames=w,ft.Workbook=ae,ft.SSF=Es(aa),ft.Props=ie,ft.Custprops=fe,ft}function D1(e,r){switch(qy(r=r||{}),r.type||"base64"){case"base64":return Xp(ko(e),r);case"binary":case"buffer":case"file":return Xp(e,r);case"array":return Xp(Zc(e),r)}}function QP(e,r){var a=[];return e.Props&&a.push(k7(e.Props,r)),e.Custprops&&a.push(N7(e.Props,e.Custprops)),a.join("")}function eL(){return""}function tL(e,r){var a=['<Style ss:ID="Default" ss:Name="Normal"><NumberFormat/></Style>'];return r.cellXfs.forEach(function(s,n){var i=[];i.push(kr("NumberFormat",null,{"ss:Format":ls(aa[s.numFmtId])}));var c={"ss:ID":"s"+(21+n)};a.push(kr("Style",i.join(""),c))}),kr("Styles",a.join(""))}function ej(e){return kr("NamedRange",null,{"ss:Name":e.Name,"ss:RefersTo":"="+Wy(e.Ref,{r:0,c:0})})}function rL(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(ej(n)))}return kr("Names",a.join(""))}function aL(e,r,a,s){if(!e||!((s||{}).Workbook||{}).Names)return"";for(var n=s.Workbook.Names,i=[],c=0;c<n.length;++c){var u=n[c];u.Sheet==a&&(u.Name.match(/^_xlfn\./)||i.push(ej(u)))}return i.join("")}function sL(e,r,a,s){if(!e)return"";var n=[];if(e["!margins"]&&(n.push("<PageSetup>"),e["!margins"].header&&n.push(kr("Header",null,{"x:Margin":e["!margins"].header})),e["!margins"].footer&&n.push(kr("Footer",null,{"x:Margin":e["!margins"].footer})),n.push(kr("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(kr("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(hi("ProtectContents","True")),e["!protect"].objects&&n.push(hi("ProtectObjects","True")),e["!protect"].scenarios&&n.push(hi("ProtectScenarios","True")),e["!protect"].selectLockedCells!=null&&!e["!protect"].selectLockedCells?n.push(hi("EnableSelection","NoSelection")):e["!protect"].selectUnlockedCells!=null&&!e["!protect"].selectUnlockedCells&&n.push(hi("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(c){e["!protect"][c[0]]&&n.push("<"+c[1]+"/>")})),n.length==0?"":kr("WorksheetOptions",n.join(""),{xmlns:yo.x})}function nL(e){return e.map(function(r){var a=SA(r.t||""),s=kr("ss:Data",a,{xmlns:"http://www.w3.org/TR/REC-html40"});return kr("Comment",s,{"ss:Author":r.a})}).join("")}function iL(e,r,a,s,n,i,c){if(!e||e.v==null&&e.f==null)return"";var u={};if(e.f&&(u["ss:Formula"]="="+ls(Wy(e.f,c))),e.F&&e.F.slice(0,r.length)==r){var h=Ws(e.F.slice(r.length+1));u["ss:ArrayRange"]="RC:R"+(h.r==c.r?"":"["+(h.r-c.r)+"]")+"C"+(h.c==c.c?"":"["+(h.c-c.c)+"]")}if(e.l&&e.l.Target&&(u["ss:HRef"]=ls(e.l.Target),e.l.Tooltip&&(u["x:HRefScreenTip"]=ls(e.l.Tooltip))),a["!merges"])for(var g=a["!merges"],y=0;y!=g.length;++y)g[y].s.c!=c.c||g[y].s.r!=c.r||(g[y].e.c>g[y].s.c&&(u["ss:MergeAcross"]=g[y].e.c-g[y].s.c),g[y].e.r>g[y].s.r&&(u["ss:MergeDown"]=g[y].e.r-g[y].s.r));var w="",E="";switch(e.t){case"z":if(!s.sheetStubs)return"";break;case"n":w="Number",E=String(e.v);break;case"b":w="Boolean",E=e.v?"1":"0";break;case"e":w="Error",E=gc[e.v];break;case"d":w="DateTime",E=new Date(e.v).toISOString(),e.z==null&&(e.z=e.z||aa[14]);break;case"s":w="String",E=jA(e.v||"");break}var S=Jc(s.cellXfs,e,s);u["ss:StyleID"]="s"+(21+S),u["ss:Index"]=c.c+1;var A=e.v!=null?E:"",C=e.t=="z"?"":'<Data ss:Type="'+w+'">'+A+"</Data>";return(e.c||[]).length>0&&(C+=nL(e.c)),kr("Cell",C,u)}function oL(e,r){var a='<Row ss:Index="'+(e+1)+'"';return r&&(r.hpt&&!r.hpx&&(r.hpx=X0(r.hpt)),r.hpx&&(a+=' ss:AutoFitHeight="0" ss:Height="'+r.hpx+'"'),r.hidden&&(a+=' ss:Hidden="1"')),a+">"}function lL(e,r,a,s){if(!e["!ref"])return"";var n=$a(e["!ref"]),i=e["!merges"]||[],c=0,u=[];e["!cols"]&&e["!cols"].forEach(function(O,M){Yc(O);var R=!!O.width,F=jg(M,O),z={"ss:Index":M+1};R&&(z["ss:Width"]=Rf(F.width)),O.hidden&&(z["ss:Hidden"]="1"),u.push(kr("Column",null,z))});for(var h=Array.isArray(e),g=n.s.r;g<=n.e.r;++g){for(var y=[oL(g,(e["!rows"]||[])[g])],w=n.s.c;w<=n.e.c;++w){var E=!1;for(c=0;c!=i.length;++c)if(!(i[c].s.c>w)&&!(i[c].s.r>g)&&!(i[c].e.c<w)&&!(i[c].e.r<g)){(i[c].s.c!=w||i[c].s.r!=g)&&(E=!0);break}if(!E){var S={r:g,c:w},A=sa(S),C=h?(e[g]||[])[w]:e[A];y.push(iL(C,A,e,r,a,s,S))}}y.push("</Row>"),y.length>2&&u.push(y.join(""))}return u.join("")}function cL(e,r,a){var s=[],n=a.SheetNames[e],i=a.Sheets[n],c=i?aL(i,r,e,a):"";return c.length>0&&s.push("<Names>"+c+"</Names>"),c=i?lL(i,r,e,a):"",c.length>0&&s.push("<Table>"+c+"</Table>"),s.push(sL(i,r,e,a)),s.join("")}function dL(e,r){r||(r={}),e.SSF||(e.SSF=Es(aa)),e.SSF&&(au(),yg(e.SSF),r.revssf=vg(e.SSF),r.revssf[e.SSF[65535]]=0,r.ssf=e.SSF,r.cellXfs=[],Jc(r.cellXfs,{},{revssf:{General:0}}));var a=[];a.push(QP(e,r)),a.push(eL()),a.push(""),a.push("");for(var s=0;s<e.SheetNames.length;++s)a.push(kr("Worksheet",cL(s,r,e),{"ss:Name":ls(e.SheetNames[s])}));return a[2]=tL(e,r),a[3]=rL(e),cn+kr("Workbook",a.join(""),{xmlns:yo.ss,"xmlns:o":yo.o,"xmlns:x":yo.x,"xmlns:ss":yo.ss,"xmlns:dt":yo.dt,"xmlns:html":yo.html})}function uL(e){var r={},a=e.content;if(a.l=28,r.AnsiUserType=a.read_shift(0,"lpstr-ansi"),r.AnsiClipboardFormat=r7(a),a.length-a.l<=4)return r;var s=a.read_shift(4);if(s==0||s>40||(a.l-=4,r.Reserved1=a.read_shift(0,"lpstr-ansi"),a.length-a.l<=4)||(s=a.read_shift(4),s!==1907505652)||(r.UnicodeClipboardFormat=a7(a),s=a.read_shift(4),s==0||s>40))return r;a.l-=4,r.Reserved2=a.read_shift(0,"lpwstr")}var fL=[60,1084,2066,2165,2175];function hL(e,r,a,s,n){var i=s,c=[],u=a.slice(a.l,a.l+i);if(n&&n.enc&&n.enc.insitu&&u.length>0)switch(e){case 9:case 521:case 1033:case 2057:case 47:case 405:case 225:case 406:case 312:case 404:case 10:break;case 133:break;default:n.enc.insitu(u)}c.push(u),a.l+=i;for(var h=sc(a,a.l),g=R1[h],y=0;g!=null&&fL.indexOf(h)>-1;)i=sc(a,a.l+2),y=a.l+4,h==2066?y+=4:(h==2165||h==2175)&&(y+=12),u=a.slice(y,a.l+4+i),c.push(u),a.l+=4+i,g=R1[h=sc(a,a.l)];var w=qn(c);fi(w,0);var E=0;w.lens=[];for(var S=0;S<c.length;++S)w.lens.push(E),E+=c[S].length;if(w.length<s)throw"XLS Record 0x"+e.toString(16)+" Truncated: "+w.length+" < "+s;return r.f(w,w.length,n)}function Sl(e,r,a){if(e.t!=="z"&&e.XF){var s=0;try{s=e.z||e.XF.numFmtId||0,r.cellNF&&(e.z=aa[s])}catch(i){if(r.WTF)throw i}if(!r||r.cellText!==!1)try{e.t==="e"?e.w=e.w||gc[e.v]:s===0||s=="General"?e.t==="n"?(e.v|0)===e.v?e.w=e.v.toString(10):e.w=Cf(e.v):e.w=Pd(e.v):e.w=Yo(s,e.v,{date1904:!!a,dateNF:r&&r.dateNF})}catch(i){if(r.WTF)throw i}if(r.cellDates&&s&&e.t=="n"&&ru(aa[s]||String(s))){var n=wd(e.v);n&&(e.t="d",e.v=new Date(n.y,n.m-1,n.d,n.H,n.M,n.S,n.u))}}}function gm(e,r,a){return{v:e,ixfe:r,t:a}}function mL(e,r){var a={opts:{}},s={},n=r.dense?[]:{},i={},c={},u=null,h=[],g="",y={},w,E="",S,A,C,O,M={},R=[],F,z,W=[],X=[],B={Sheets:[],WBProps:{date1904:!1},Views:[{}]},Y={},G=function(Ye){return Ye<8?Cd[Ye]:Ye<64&&X[Ye-8]||Cd[Ye]},ie=function(Ye,wt,zt){var qt=wt.XF.data;if(!(!qt||!qt.patternType||!zt||!zt.cellStyles)){wt.s={},wt.s.patternType=qt.patternType;var kt;(kt=Df(G(qt.icvFore)))&&(wt.s.fgColor={rgb:kt}),(kt=Df(G(qt.icvBack)))&&(wt.s.bgColor={rgb:kt})}},fe=function(Ye,wt,zt){if(!(te>1)&&!(zt.sheetRows&&Ye.r>=zt.sheetRows)){if(zt.cellStyles&&wt.XF&&wt.XF.data&&ie(Ye,wt,zt),delete wt.ixfe,delete wt.XF,w=Ye,E=sa(Ye),(!c||!c.s||!c.e)&&(c={s:{r:0,c:0},e:{r:0,c:0}}),Ye.r<c.s.r&&(c.s.r=Ye.r),Ye.c<c.s.c&&(c.s.c=Ye.c),Ye.r+1>c.e.r&&(c.e.r=Ye.r+1),Ye.c+1>c.e.c&&(c.e.c=Ye.c+1),zt.cellFormula&&wt.f){for(var qt=0;qt<R.length;++qt)if(!(R[qt][0].s.c>Ye.c||R[qt][0].s.r>Ye.r)&&!(R[qt][0].e.c<Ye.c||R[qt][0].e.r<Ye.r)){wt.F=ba(R[qt][0]),(R[qt][0].s.c!=Ye.c||R[qt][0].s.r!=Ye.r)&&delete wt.f,wt.f&&(wt.f=""+ki(R[qt][1],c,Ye,ce,K));break}}zt.dense?(n[Ye.r]||(n[Ye.r]=[]),n[Ye.r][Ye.c]=wt):n[E]=wt}},K={enc:!1,sbcch:0,snames:[],sharedf:M,arrayf:R,rrtabid:[],lastuser:"",biff:8,codepage:0,winlocked:0,cellStyles:!!r&&!!r.cellStyles,WTF:!!r&&!!r.wtf};r.password&&(K.password=r.password);var ke,ge=[],re=[],we=[],ee=[],ve=!1,ce=[];ce.SheetNames=K.snames,ce.sharedf=K.sharedf,ce.arrayf=K.arrayf,ce.names=[],ce.XTI=[];var ye=0,te=0,q=0,J=[],ae=[],oe;K.codepage=1200,ol(1200);for(var le=!1;e.l<e.length-1;){var be=e.l,Z=e.read_shift(2);if(Z===0&&ye===10)break;var Le=e.l===e.length?0:e.read_shift(2),Pe=R1[Z];if(Pe&&Pe.f){if(r.bookSheets&&ye===133&&Z!==133)break;if(ye=Z,Pe.r===2||Pe.r==12){var Be=e.read_shift(2);if(Le-=2,!K.enc&&Be!==Z&&((Be&255)<<8|Be>>8)!==Z)throw new Error("rt mismatch: "+Be+"!="+Z);Pe.r==12&&(e.l+=10,Le-=10)}var pe={};if(Z===10?pe=Pe.f(e,Le,K):pe=hL(Z,Pe,e,Le,K),te==0&&[9,521,1033,2057].indexOf(ye)===-1)continue;switch(Z){case 34:a.opts.Date1904=B.WBProps.date1904=pe;break;case 134:a.opts.WriteProtect=!0;break;case 47:if(K.enc||(e.l=0),K.enc=pe,!r.password)throw new Error("File is password-protected");if(pe.valid==null)throw new Error("Encryption scheme unsupported");if(!pe.valid)throw new Error("Password is incorrect");break;case 92:K.lastuser=pe;break;case 66:var rt=Number(pe);switch(rt){case 21010:rt=1200;break;case 32768:rt=1e4;break;case 32769:rt=1252;break}ol(K.codepage=rt),le=!0;break;case 317:K.rrtabid=pe;break;case 25:K.winlocked=pe;break;case 439:a.opts.RefreshAll=pe;break;case 12:a.opts.CalcCount=pe;break;case 16:a.opts.CalcDelta=pe;break;case 17:a.opts.CalcIter=pe;break;case 13:a.opts.CalcMode=pe;break;case 14:a.opts.CalcPrecision=pe;break;case 95:a.opts.CalcSaveRecalc=pe;break;case 15:K.CalcRefMode=pe;break;case 2211:a.opts.FullCalc=pe;break;case 129:pe.fDialog&&(n["!type"]="dialog"),pe.fBelow||((n["!outline"]||(n["!outline"]={})).above=!0),pe.fRight||((n["!outline"]||(n["!outline"]={})).left=!0);break;case 224:W.push(pe);break;case 430:ce.push([pe]),ce[ce.length-1].XTI=[];break;case 35:case 547:ce[ce.length-1].push(pe);break;case 24:case 536:oe={Name:pe.Name,Ref:ki(pe.rgce,c,null,ce,K)},pe.itab>0&&(oe.Sheet=pe.itab-1),ce.names.push(oe),ce[0]||(ce[0]=[],ce[0].XTI=[]),ce[ce.length-1].push(pe),pe.Name=="_xlnm._FilterDatabase"&&pe.itab>0&&pe.rgce&&pe.rgce[0]&&pe.rgce[0][0]&&pe.rgce[0][0][0]=="PtgArea3d"&&(ae[pe.itab-1]={ref:ba(pe.rgce[0][0][1][2])});break;case 22:K.ExternCount=pe;break;case 23:ce.length==0&&(ce[0]=[],ce[0].XTI=[]),ce[ce.length-1].XTI=ce[ce.length-1].XTI.concat(pe),ce.XTI=ce.XTI.concat(pe);break;case 2196:if(K.biff<8)break;oe!=null&&(oe.Comment=pe[1]);break;case 18:n["!protect"]=pe;break;case 19:pe!==0&&K.WTF&&console.error("Password verifier: "+pe);break;case 133:i[pe.pos]=pe,K.snames.push(pe.name);break;case 10:{if(--te)break;if(c.e){if(c.e.r>0&&c.e.c>0){if(c.e.r--,c.e.c--,n["!ref"]=ba(c),r.sheetRows&&r.sheetRows<=c.e.r){var ct=c.e.r;c.e.r=r.sheetRows-1,n["!fullref"]=n["!ref"],n["!ref"]=ba(c),c.e.r=ct}c.e.r++,c.e.c++}ge.length>0&&(n["!merges"]=ge),re.length>0&&(n["!objects"]=re),we.length>0&&(n["!cols"]=we),ee.length>0&&(n["!rows"]=ee),B.Sheets.push(Y)}g===""?y=n:s[g]=n,n=r.dense?[]:{}}break;case 9:case 521:case 1033:case 2057:{if(K.biff===8&&(K.biff={9:2,521:3,1033:4}[Z]||{512:2,768:3,1024:4,1280:5,1536:8,2:2,7:2}[pe.BIFFVer]||8),K.biffguess=pe.BIFFVer==0,pe.BIFFVer==0&&pe.dt==4096&&(K.biff=5,le=!0,ol(K.codepage=28591)),K.biff==8&&pe.BIFFVer==0&&pe.dt==16&&(K.biff=2),te++)break;if(n=r.dense?[]:{},K.biff<8&&!le&&(le=!0,ol(K.codepage=r.codepage||1252)),K.biff<5||pe.BIFFVer==0&&pe.dt==4096){g===""&&(g="Sheet1"),c={s:{r:0,c:0},e:{r:0,c:0}};var et={pos:e.l-Le,name:g};i[et.pos]=et,K.snames.push(g)}else g=(i[be]||{name:""}).name;pe.dt==32&&(n["!type"]="chart"),pe.dt==64&&(n["!type"]="macro"),ge=[],re=[],K.arrayf=R=[],we=[],ee=[],ve=!1,Y={Hidden:(i[be]||{hs:0}).hs,name:g}}break;case 515:case 3:case 2:n["!type"]=="chart"&&(r.dense?(n[pe.r]||[])[pe.c]:n[sa({c:pe.c,r:pe.r})])&&++pe.c,F={ixfe:pe.ixfe,XF:W[pe.ixfe]||{},v:pe.val,t:"n"},q>0&&(F.z=J[F.ixfe>>8&63]),Sl(F,r,a.opts.Date1904),fe({c:pe.c,r:pe.r},F,r);break;case 5:case 517:F={ixfe:pe.ixfe,XF:W[pe.ixfe],v:pe.val,t:pe.t},q>0&&(F.z=J[F.ixfe>>8&63]),Sl(F,r,a.opts.Date1904),fe({c:pe.c,r:pe.r},F,r);break;case 638:F={ixfe:pe.ixfe,XF:W[pe.ixfe],v:pe.rknum,t:"n"},q>0&&(F.z=J[F.ixfe>>8&63]),Sl(F,r,a.opts.Date1904),fe({c:pe.c,r:pe.r},F,r);break;case 189:for(var It=pe.c;It<=pe.C;++It){var ft=pe.rkrec[It-pe.c][0];F={ixfe:ft,XF:W[ft],v:pe.rkrec[It-pe.c][1],t:"n"},q>0&&(F.z=J[F.ixfe>>8&63]),Sl(F,r,a.opts.Date1904),fe({c:It,r:pe.r},F,r)}break;case 6:case 518:case 1030:{if(pe.val=="String"){u=pe;break}if(F=gm(pe.val,pe.cell.ixfe,pe.tt),F.XF=W[F.ixfe],r.cellFormula){var Lt=pe.formula;if(Lt&&Lt[0]&&Lt[0][0]&&Lt[0][0][0]=="PtgExp"){var Je=Lt[0][0][1][0],Ve=Lt[0][0][1][1],Xe=sa({r:Je,c:Ve});M[Xe]?F.f=""+ki(pe.formula,c,pe.cell,ce,K):F.F=((r.dense?(n[Je]||[])[Ve]:n[Xe])||{}).F}else F.f=""+ki(pe.formula,c,pe.cell,ce,K)}q>0&&(F.z=J[F.ixfe>>8&63]),Sl(F,r,a.opts.Date1904),fe(pe.cell,F,r),u=pe}break;case 7:case 519:if(u)u.val=pe,F=gm(pe,u.cell.ixfe,"s"),F.XF=W[F.ixfe],r.cellFormula&&(F.f=""+ki(u.formula,c,u.cell,ce,K)),q>0&&(F.z=J[F.ixfe>>8&63]),Sl(F,r,a.opts.Date1904),fe(u.cell,F,r),u=null;else throw new Error("String record expects Formula");break;case 33:case 545:{R.push(pe);var Rt=sa(pe[0].s);if(S=r.dense?(n[pe[0].s.r]||[])[pe[0].s.c]:n[Rt],r.cellFormula&&S){if(!u||!Rt||!S)break;S.f=""+ki(pe[1],c,pe[0],ce,K),S.F=ba(pe[0])}}break;case 1212:{if(!r.cellFormula)break;if(E){if(!u)break;M[sa(u.cell)]=pe[0],S=r.dense?(n[u.cell.r]||[])[u.cell.c]:n[sa(u.cell)],(S||{}).f=""+ki(pe[0],c,w,ce,K)}}break;case 253:F=gm(h[pe.isst].t,pe.ixfe,"s"),h[pe.isst].h&&(F.h=h[pe.isst].h),F.XF=W[F.ixfe],q>0&&(F.z=J[F.ixfe>>8&63]),Sl(F,r,a.opts.Date1904),fe({c:pe.c,r:pe.r},F,r);break;case 513:r.sheetStubs&&(F={ixfe:pe.ixfe,XF:W[pe.ixfe],t:"z"},q>0&&(F.z=J[F.ixfe>>8&63]),Sl(F,r,a.opts.Date1904),fe({c:pe.c,r:pe.r},F,r));break;case 190:if(r.sheetStubs)for(var qe=pe.c;qe<=pe.C;++qe){var Dt=pe.ixfe[qe-pe.c];F={ixfe:Dt,XF:W[Dt],t:"z"},q>0&&(F.z=J[F.ixfe>>8&63]),Sl(F,r,a.opts.Date1904),fe({c:qe,r:pe.r},F,r)}break;case 214:case 516:case 4:F=gm(pe.val,pe.ixfe,"s"),F.XF=W[F.ixfe],q>0&&(F.z=J[F.ixfe>>8&63]),Sl(F,r,a.opts.Date1904),fe({c:pe.c,r:pe.r},F,r);break;case 0:case 512:te===1&&(c=pe);break;case 252:h=pe;break;case 1054:if(K.biff==4){J[q++]=pe[1];for(var ar=0;ar<q+163&&aa[ar]!=pe[1];++ar);ar>=163&&lc(pe[1],q+163)}else lc(pe[1],pe[0]);break;case 30:{J[q++]=pe;for(var yt=0;yt<q+163&&aa[yt]!=pe;++yt);yt>=163&&lc(pe,q+163)}break;case 229:ge=ge.concat(pe);break;case 93:re[pe.cmo[0]]=K.lastobj=pe;break;case 438:K.lastobj.TxO=pe;break;case 127:K.lastobj.ImData=pe;break;case 440:for(O=pe[0].s.r;O<=pe[0].e.r;++O)for(C=pe[0].s.c;C<=pe[0].e.c;++C)S=r.dense?(n[O]||[])[C]:n[sa({c:C,r:O})],S&&(S.l=pe[1]);break;case 2048:for(O=pe[0].s.r;O<=pe[0].e.r;++O)for(C=pe[0].s.c;C<=pe[0].e.c;++C)S=r.dense?(n[O]||[])[C]:n[sa({c:C,r:O})],S&&S.l&&(S.l.Tooltip=pe[1]);break;case 28:{if(K.biff<=5&&K.biff>=2)break;S=r.dense?(n[pe[0].r]||[])[pe[0].c]:n[sa(pe[0])];var St=re[pe[2]];S||(r.dense?(n[pe[0].r]||(n[pe[0].r]=[]),S=n[pe[0].r][pe[0].c]={t:"z"}):S=n[sa(pe[0])]={t:"z"},c.e.r=Math.max(c.e.r,pe[0].r),c.s.r=Math.min(c.s.r,pe[0].r),c.e.c=Math.max(c.e.c,pe[0].c),c.s.c=Math.min(c.s.c,pe[0].c)),S.c||(S.c=[]),A={a:pe[1],t:St.TxO.t},S.c.push(A)}break;case 2173:tR(W[pe.ixfe],pe.ext);break;case 125:{if(!K.cellStyles)break;for(;pe.e>=pe.s;)we[pe.e--]={width:pe.w/256,level:pe.level||0,hidden:!!(pe.flags&1)},ve||(ve=!0,By(pe.w/256)),Yc(we[pe.e+1])}break;case 520:{var Ot={};pe.level!=null&&(ee[pe.r]=Ot,Ot.level=pe.level),pe.hidden&&(ee[pe.r]=Ot,Ot.hidden=!0),pe.hpt&&(ee[pe.r]=Ot,Ot.hpt=pe.hpt,Ot.hpx=X0(pe.hpt))}break;case 38:case 39:case 40:case 41:n["!margins"]||Ad(n["!margins"]={}),n["!margins"][{38:"left",39:"right",40:"top",41:"bottom"}[Z]]=pe;break;case 161:n["!margins"]||Ad(n["!margins"]={}),n["!margins"].header=pe.header,n["!margins"].footer=pe.footer;break;case 574:pe.RTL&&(B.Views[0].RTL=!0);break;case 146:X=pe;break;case 2198:ke=pe;break;case 140:z=pe;break;case 442:g?Y.CodeName=pe||Y.name:B.WBProps.CodeName=pe||"ThisWorkbook";break}}else Pe||console.error("Missing Info for XLS Record 0x"+Z.toString(16)),e.l+=Le}return a.SheetNames=Qs(i).sort(function(Yt,Ye){return Number(Yt)-Number(Ye)}).map(function(Yt){return i[Yt].name}),r.bookSheets||(a.Sheets=s),!a.SheetNames.length&&y["!ref"]?(a.SheetNames.push("Sheet1"),a.Sheets&&(a.Sheets.Sheet1=y)):a.Preamble=y,a.Sheets&&ae.forEach(function(Yt,Ye){a.Sheets[a.SheetNames[Ye]]["!autofilter"]=Yt}),a.Strings=h,a.SSF=Es(aa),K.enc&&(a.Encryption=K.enc),ke&&(a.Themes=ke),a.Metadata={},z!==void 0&&(a.Metadata.Country=z),ce.names.length>0&&(B.Names=ce.names),a.Workbook=B,a}var vf={SI:"e0859ff2f94f6810ab9108002b27b3d9",DSI:"02d5cdd59c2e1b10939708002b2cf9ae",UDI:"05d5cdd59c2e1b10939708002b2cf9ae"};function gL(e,r,a){var s=Zr.find(e,"/!DocumentSummaryInformation");if(s&&s.size>0)try{var n=$_(s,S1,vf.DSI);for(var i in n)r[i]=n[i]}catch(g){if(a.WTF)throw g}var c=Zr.find(e,"/!SummaryInformation");if(c&&c.size>0)try{var u=$_(c,C1,vf.SI);for(var h in u)r[h]==null&&(r[h]=u[h])}catch(g){if(a.WTF)throw g}r.HeadingPairs&&r.TitlesOfParts&&(Q3(r.HeadingPairs,r.TitlesOfParts,r,a),delete r.HeadingPairs,delete r.TitlesOfParts)}function xL(e,r){var a=[],s=[],n=[],i=0,c,u=v_(S1,"n"),h=v_(C1,"n");if(e.Props)for(c=Qs(e.Props),i=0;i<c.length;++i)(Object.prototype.hasOwnProperty.call(u,c[i])?a:Object.prototype.hasOwnProperty.call(h,c[i])?s:n).push([c[i],e.Props[c[i]]]);if(e.Custprops)for(c=Qs(e.Custprops),i=0;i<c.length;++i)Object.prototype.hasOwnProperty.call(e.Props||{},c[i])||(Object.prototype.hasOwnProperty.call(u,c[i])?a:Object.prototype.hasOwnProperty.call(h,c[i])?s:n).push([c[i],e.Custprops[c[i]]]);var g=[];for(i=0;i<n.length;++i)iN.indexOf(n[i][0])>-1||J3.indexOf(n[i][0])>-1||n[i][1]!=null&&g.push(n[i]);s.length&&Zr.utils.cfb_add(r,"/SummaryInformation",V_(s,vf.SI,h,C1)),(a.length||g.length)&&Zr.utils.cfb_add(r,"/DocumentSummaryInformation",V_(a,vf.DSI,u,S1,g.length?g:null,vf.UDI))}function tj(e,r){r||(r={}),qy(r),gy(),r.codepage&&my(r.codepage);var a,s;if(e.FullPaths){if(Zr.find(e,"/encryption"))throw new Error("File is password-protected");a=Zr.find(e,"!CompObj"),s=Zr.find(e,"/Workbook")||Zr.find(e,"/Book")}else{switch(r.type){case"base64":e=vo(ko(e));break;case"binary":e=vo(e);break;case"buffer":break;case"array":Array.isArray(e)||(e=Array.prototype.slice.call(e));break}fi(e,0),s={content:e}}var n,i;if(a&&uL(a),r.bookProps&&!r.bookSheets)n={};else{var c=Ca?"buffer":"array";if(s&&s.content)n=mL(s.content,r);else if((i=Zr.find(e,"PerfectOffice_MAIN"))&&i.content)n=Td.to_workbook(i.content,(r.type=c,r));else if((i=Zr.find(e,"NativeContent_MAIN"))&&i.content)n=Td.to_workbook(i.content,(r.type=c,r));else throw(i=Zr.find(e,"MN0"))&&i.content?new Error("Unsupported Works 4 for Mac file"):new Error("Cannot find Workbook stream");r.bookVBA&&e.FullPaths&&Zr.find(e,"/_VBA_PROJECT_CUR/VBA/dir")&&(n.vbaraw=TR(e))}var u={};return e.FullPaths&&gL(e,u,r),n.Props=n.Custprops=u,r.bookFiles&&(n.cfb=e),n}function pL(e,r){var a=r||{},s=Zr.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 Zr.utils.cfb_add(s,n,rj(e,a)),a.biff==8&&(e.Props||e.Custprops)&&xL(e,s),a.biff==8&&e.vbaraw&&AR(s,Zr.read(e.vbaraw,{type:typeof e.vbaraw=="string"?"binary":"buffer"})),s}var Mf={0:{f:zI},1:{f:XI},2:{f:mM},3:{f:aM},4:{f:QI},5:{f:uM},6:{f:bM},7:{f:oM},8:{f:SM},9:{f:jM},10:{f:kM},11:{f:NM},12:{f:KI},13:{f:xM},14:{f:nM},15:{f:tM},16:{f:YN},17:{f:wM},18:{f:cM},19:{f:Ty},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:wP},40:{},42:{},43:{f:bD},44:{f:pD},45:{f:_D},46:{f:ND},47:{f:kD},48:{},49:{f:$A},50:{},51:{f:sR},52:{T:1},53:{T:-1},54:{T:1},55:{T:-1},56:{T:1},57:{T:-1},58:{},59:{},60:{f:pN},62:{f:yM},63:{f:hR},64:{f:WM},65:{},66:{},67:{},68:{},69:{},70:{},128:{},129:{T:1},130:{T:-1},131:{T:1,f:Ei,p:0},132:{T:-1},133:{T:1},134:{T:-1},135:{T:1},136:{T:-1},137:{T:1,f:LM},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:YI},148:{f:$I,p:16},151:{f:DM},152:{},153:{f:yP},154:{},155:{},156:{f:xP},157:{},158:{},159:{T:1,f:FO},160:{T:-1},161:{T:1,f:Xd},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:CM},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:rR},336:{T:-1},337:{f:oR,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:j1},357:{},358:{},359:{},360:{T:1},361:{},362:{f:xN},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:RM},427:{f:FM},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:MM},477:{},478:{},479:{T:1},480:{T:-1},481:{T:1},482:{T:-1},483:{T:1},484:{T:-1},485:{f:GI},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:AM},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:j1},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:NR},633:{T:1},634:{T:-1},635:{T:1,f:_R},636:{T:-1},637:{f:qA},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:nP},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:HM},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:""}},R1={6:{f:Yp},10:{f:zc},12:{f:Nn},13:{f:Nn},14:{f:sn},15:{f:sn},16:{f:ji},17:{f:sn},18:{f:sn},19:{f:Nn},20:{f:K_},21:{f:K_},23:{f:xN},24:{f:Q_},25:{f:sn},26:{},27:{},28:{f:H9},29:{},34:{f:sn},35:{f:J_},38:{f:ji},39:{f:ji},40:{f:ji},41:{f:ji},42:{f:sn},43:{f:sn},47:{f:tD},49:{f:x9},51:{f:Nn},60:{},61:{f:u9},64:{f:sn},65:{f:g9},66:{f:Nn},77:{},80:{},81:{},82:{},85:{f:Nn},89:{},90:{},91:{},92:{f:e9},93:{f:G9},94:{},95:{f:sn},96:{},97:{},99:{f:sn},125:{f:pN},128:{f:O9},129:{f:r9},130:{f:Nn},131:{f:sn},132:{f:sn},133:{f:a9},134:{},140:{f:eO},141:{f:Nn},144:{},146:{f:aO},151:{},152:{},153:{},154:{},155:{},156:{f:Nn},157:{},158:{},160:{f:dO},161:{f:iO},174:{},175:{},176:{},177:{},178:{},180:{},181:{},182:{},184:{},185:{},189:{f:C9},190:{f:E9},193:{f:zc},197:{},198:{},199:{},200:{},201:{},202:{f:sn},203:{},204:{},205:{},206:{},207:{},208:{},209:{},210:{},211:{},213:{},215:{},216:{},217:{},218:{f:Nn},220:{},221:{f:sn},222:{},224:{f:A9},225:{f:Q7},226:{f:zc},227:{},229:{f:$9},233:{},235:{},236:{},237:{},239:{},240:{},241:{},242:{},244:{},245:{},246:{},247:{},248:{},249:{},251:{},252:{f:n9},253:{f:y9},255:{f:o9},256:{},259:{},290:{},311:{},312:{},315:{},317:{f:oN},318:{},319:{},320:{},330:{},331:{},333:{},334:{},335:{},336:{},337:{},338:{},339:{},340:{},351:{},352:{f:sn},353:{f:zc},401:{},402:{},403:{},404:{},405:{},406:{},407:{},408:{},425:{},426:{},427:{},428:{},429:{},430:{f:M9},431:{f:sn},432:{},433:{},434:{},437:{},438:{f:X9},439:{f:sn},440:{f:Z9},441:{},442:{f:Yf},443:{},444:{f:Nn},445:{},446:{},448:{f:zc},449:{f:d9,r:2},450:{f:zc},512:{f:q_},513:{f:cO},515:{f:F9},516:{f:v9},517:{f:Z_},519:{f:uO},520:{f:l9},523:{},545:{f:ek},549:{f:Y_},566:{},574:{f:h9},638:{f:S9},659:{},1048:{},1054:{f:_9},1084:{},1212:{f:U9},2048:{f:J9},2049:{},2050:{},2051:{},2052:{},2053:{},2054:{},2055:{},2056:{},2057:{f:fm},2058:{},2059:{},2060:{},2061:{},2062:{},2063:{},2064:{},2066:{},2067:{},2128:{},2129:{},2130:{},2131:{},2132:{},2133:{},2134:{},2135:{},2136:{},2137:{},2138:{},2146:{},2147:{r:12},2148:{},2149:{},2150:{},2151:{f:zc},2152:{},2154:{},2155:{},2156:{},2161:{},2162:{},2164:{},2165:{},2166:{},2167:{},2168:{},2169:{},2170:{},2171:{},2172:{f:sO,r:12},2173:{f:eR,r:12},2174:{},2175:{},2180:{},2181:{},2182:{},2183:{},2184:{},2185:{},2186:{},2187:{},2188:{f:sn,r:12},2189:{},2190:{r:12},2191:{},2192:{},2194:{},2195:{},2196:{f:B9,r:12},2197:{},2198:{f:qD,r:12},2199:{},2200:{},2201:{},2202:{f:z9,r:12},2203:{f:zc},2204:{},2205:{},2206:{},2207:{},2211:{f:c9},2212:{},2213:{},2214:{},2215:{},4097:{},4098:{},4099:{},4102:{},4103:{},4105:{},4106:{},4107:{},4108:{},4109:{},4116:{},4117:{},4118:{},4119:{},4120:{},4121:{},4122:{},4123:{},4124:{},4125:{},4126:{},4127:{},4128:{},4129:{},4130:{},4132:{},4133:{},4134:{f:Nn},4135:{},4146:{},4147:{},4148:{},4149:{},4154:{},4156:{},4157:{},4158:{},4159:{},4160:{},4161:{},4163:{},4164:{f:oO},4165:{},4166:{},4168:{},4170:{},4171:{},4174:{},4175:{},4176:{},4177:{},4187:{},4188:{f:rO},4189:{},4191:{},4192:{},4193:{},4194:{},4195:{},4196:{},4197:{},4198:{},4199:{},4200:{},0:{f:q_},1:{},2:{f:xO},3:{f:mO},4:{f:hO},5:{f:Z_},7:{f:yO},8:{},9:{f:fm},11:{},22:{f:Nn},30:{f:N9},31:{},32:{},33:{f:ek},36:{},37:{f:Y_},50:{f:bO},62:{},52:{},67:{},68:{f:Nn},69:{},86:{},126:{},127:{f:fO},135:{},136:{},137:{},145:{},148:{},149:{},150:{},169:{},171:{},188:{},191:{},192:{},194:{},195:{},214:{f:vO},223:{},234:{},354:{},421:{},518:{f:Yp},521:{f:fm},536:{f:Q_},547:{f:J_},561:{},579:{},1030:{f:Yp},1033:{f:fm},1091:{},2157:{},2163:{},2177:{},2240:{},2241:{},2242:{},2243:{},2244:{},2245:{},2246:{},2247:{},2248:{},2249:{},2250:{},2251:{},2262:{r:12},29282:{}};function jr(e,r,a,s){var n=r;if(!isNaN(n)){var i=s||(a||[]).length||0,c=e.next(4);c.write_shift(2,n),c.write_shift(2,i),i>0&&Sy(a)&&e.push(a)}}function yL(e,r,a,s){var n=(a||[]).length||0;if(n<=8224)return jr(e,r,a,n);var i=r;if(!isNaN(i)){for(var c=a.parts||[],u=0,h=0,g=0;g+(c[u]||8224)<=8224;)g+=c[u]||8224,u++;var y=e.next(4);for(y.write_shift(2,i),y.write_shift(2,g),e.push(a.slice(h,h+g)),h+=g;h<n;){for(y=e.next(4),y.write_shift(2,60),g=0;g+(c[u]||8224)<=8224;)g+=c[u]||8224,u++;y.write_shift(2,g),e.push(a.slice(h,h+g)),h+=g}}}function Kf(e,r,a){return e||(e=sr(7)),e.write_shift(2,r),e.write_shift(2,a),e.write_shift(2,0),e.write_shift(1,0),e}function bL(e,r,a,s){var n=sr(9);return Kf(n,e,r),lN(a,s||"b",n),n}function vL(e,r,a){var s=sr(8+2*a.length);return Kf(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 wL(e,r,a,s){if(r.v!=null)switch(r.t){case"d":case"n":var n=r.t=="d"?Pn(Cs(r.v)):r.v;n==(n|0)&&n>=0&&n<65536?jr(e,2,pO(a,s,n)):jr(e,3,gO(a,s,n));return;case"b":case"e":jr(e,5,bL(a,s,r.v,r.t));return;case"s":case"str":jr(e,4,vL(a,s,(r.v||"").slice(0,255)));return}jr(e,1,Kf(null,a,s))}function _L(e,r,a,s){var n=Array.isArray(r),i=$a(r["!ref"]||"A1"),c,u="",h=[];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),c=ba(i)}for(var g=i.s.r;g<=i.e.r;++g){u=nn(g);for(var y=i.s.c;y<=i.e.c;++y){g===i.s.r&&(h[y]=zs(y)),c=h[y]+u;var w=n?(r[g]||[])[y]:r[c];w&&wL(e,w,g,y)}}}function kL(e,r){for(var a=r||{},s=ro(),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 jr(s,a.biff==4?1033:a.biff==3?521:9,My(e,16,a)),_L(s,e.Sheets[e.SheetNames[n]],n,a),jr(s,10),s.end()}function NL(e,r,a){jr(e,49,p9({sz:12,name:"Arial"},a))}function jL(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&&jr(e,1054,k9(n,r[n],a))})}function SL(e,r){var a=sr(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),jr(e,2151,a),a=sr(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),hN($a(r["!ref"]||"A1"),a),a.write_shift(4,4),jr(e,2152,a)}function CL(e,r){for(var a=0;a<16;++a)jr(e,224,X_({numFmtId:0,style:!0},0,r));r.cellXfs.forEach(function(s){jr(e,224,X_(s,0,r))})}function EL(e,r){for(var a=0;a<r["!links"].length;++a){var s=r["!links"][a];jr(e,440,K9(s)),s[1].Tooltip&&jr(e,2048,Q9(s))}delete r["!links"]}function TL(e,r){if(r){var a=0;r.forEach(function(s,n){++a<=256&&s&&jr(e,125,nO(jg(n,s),n))})}}function AL(e,r,a,s,n){var i=16+Jc(n.cellXfs,r,n);if(r.v==null&&!r.bf){jr(e,513,zd(a,s,i));return}if(r.bf)jr(e,6,rI(r,a,s,n,i));else switch(r.t){case"d":case"n":var c=r.t=="d"?Pn(Cs(r.v)):r.v;jr(e,515,I9(a,s,c,i));break;case"b":case"e":jr(e,517,R9(a,s,r.v,i,n,r.t));break;case"s":case"str":if(n.bookSST){var u=$y(n.Strings,r.v,n.revStrings);jr(e,253,b9(a,s,u,i))}else jr(e,516,w9(a,s,(r.v||"").slice(0,255),i,n));break;default:jr(e,513,zd(a,s,i))}}function OL(e,r,a){var s=ro(),n=a.SheetNames[e],i=a.Sheets[n]||{},c=(a||{}).Workbook||{},u=(c.Sheets||[])[e]||{},h=Array.isArray(i),g=r.biff==8,y,w="",E=[],S=$a(i["!ref"]||"A1"),A=g?65536:16384;if(S.e.c>255||S.e.r>=A){if(r.WTF)throw new Error("Range "+(i["!ref"]||"A1")+" exceeds format limit A1:IV16384");S.e.c=Math.min(S.e.c,255),S.e.r=Math.min(S.e.c,A-1)}jr(s,2057,My(a,16,r)),jr(s,13,zo(1)),jr(s,12,zo(100)),jr(s,15,Pi(!0)),jr(s,17,Pi(!1)),jr(s,16,Bd(.001)),jr(s,95,Pi(!0)),jr(s,42,Pi(!1)),jr(s,43,Pi(!1)),jr(s,130,zo(1)),jr(s,128,D9()),jr(s,131,Pi(!1)),jr(s,132,Pi(!1)),g&&TL(s,i["!cols"]),jr(s,512,j9(S,r)),g&&(i["!links"]=[]);for(var C=S.s.r;C<=S.e.r;++C){w=nn(C);for(var O=S.s.c;O<=S.e.c;++O){C===S.s.r&&(E[O]=zs(O)),y=E[O]+w;var M=h?(i[C]||[])[O]:i[y];M&&(AL(s,M,C,O,r),g&&M.l&&i["!links"].push([y,M.l]))}}var R=u.CodeName||u.name||n;return g&&jr(s,574,m9((c.Views||[])[0])),g&&(i["!merges"]||[]).length&&jr(s,229,V9(i["!merges"])),g&&EL(s,i),jr(s,442,cN(R)),g&&SL(s,i),jr(s,10),s.end()}function DL(e,r,a){var s=ro(),n=(e||{}).Workbook||{},i=n.Sheets||[],c=n.WBProps||{},u=a.biff==8,h=a.biff==5;if(jr(s,2057,My(e,5,a)),a.bookType=="xla"&&jr(s,135),jr(s,225,u?zo(1200):null),jr(s,193,R7(2)),h&&jr(s,191),h&&jr(s,192),jr(s,226),jr(s,92,t9("SheetJS",a)),jr(s,66,zo(u?1200:1252)),u&&jr(s,353,zo(0)),u&&jr(s,448),jr(s,317,lO(e.SheetNames.length)),u&&e.vbaraw&&jr(s,211),u&&e.vbaraw){var g=c.CodeName||"ThisWorkbook";jr(s,442,cN(g))}jr(s,156,zo(17)),jr(s,25,Pi(!1)),jr(s,18,Pi(!1)),jr(s,19,zo(0)),u&&jr(s,431,Pi(!1)),u&&jr(s,444,zo(0)),jr(s,61,f9()),jr(s,64,Pi(!1)),jr(s,141,zo(0)),jr(s,34,Pi(dP(e)=="true")),jr(s,14,Pi(!0)),u&&jr(s,439,Pi(!1)),jr(s,218,zo(0)),NL(s,e,a),jL(s,e.SSF,a),CL(s,a),u&&jr(s,352,Pi(!1));var y=s.end(),w=ro();u&&jr(w,140,tO()),u&&a.Strings&&yL(w,252,i9(a.Strings)),jr(w,10);var E=w.end(),S=ro(),A=0,C=0;for(C=0;C<e.SheetNames.length;++C)A+=(u?12:11)+(u?2:1)*e.SheetNames[C].length;var O=y.length+A+E.length;for(C=0;C<e.SheetNames.length;++C){var M=i[C]||{};jr(S,133,s9({pos:O,hs:M.Hidden||0,dt:0,name:e.SheetNames[C]},a)),O+=r[C].length}var R=S.end();if(A!=R.length)throw new Error("BS8 "+A+" != "+R.length);var F=[];return y.length&&F.push(y),R.length&&F.push(R),E.length&&F.push(E),qn(F)}function RL(e,r){var a=r||{},s=[];e&&!e.SSF&&(e.SSF=Es(aa)),e&&e.SSF&&(au(),yg(e.SSF),a.revssf=vg(e.SSF),a.revssf[e.SSF[65535]]=0,a.ssf=e.SSF),a.Strings=[],a.Strings.Count=0,a.Strings.Unique=0,Xy(a),a.cellXfs=[],Jc(a.cellXfs,{},{revssf:{General:0}}),e.Props||(e.Props={});for(var n=0;n<e.SheetNames.length;++n)s[s.length]=OL(n,a,e);return s.unshift(DL(e,s,a)),qn(s)}function rj(e,r){for(var a=0;a<=e.SheetNames.length;++a){var s=e.Sheets[e.SheetNames[a]];if(!(!s||!s["!ref"])){var n=no(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 RL(e,r);case 4:case 3:case 2:return kL(e,r)}throw new Error("invalid type "+i.bookType+" for BIFF")}function dk(e,r){var a=r||{},s=a.dense?[]:{};e=e.replace(/<!--.*?-->/g,"");var n=e.match(/<table/i);if(!n)throw new Error("Invalid HTML: could not find <table>");var i=e.match(/<\/table/i),c=n.index,u=i&&i.index||e.length,h=pA(e.slice(c,u),/(:?<tr[^>]*>)/i,"<tr>"),g=-1,y=0,w=0,E=0,S={s:{r:1e7,c:1e7},e:{r:0,c:0}},A=[];for(c=0;c<h.length;++c){var C=h[c].trim(),O=C.slice(0,3).toLowerCase();if(O=="<tr"){if(++g,a.sheetRows&&a.sheetRows<=g){--g;break}y=0;continue}if(!(O!="<td"&&O!="<th")){var M=C.split(/<\/t[dh]>/i);for(u=0;u<M.length;++u){var R=M[u].trim();if(R.match(/<t[dh]/i)){for(var F=R,z=0;F.charAt(0)=="<"&&(z=F.indexOf(">"))>-1;)F=F.slice(z+1);for(var W=0;W<A.length;++W){var X=A[W];X.s.c==y&&X.s.r<g&&g<=X.e.r&&(y=X.e.c+1,W=-1)}var B=ia(R.slice(0,R.indexOf(">")));E=B.colspan?+B.colspan:1,((w=+B.rowspan)>1||E>1)&&A.push({s:{r:g,c:y},e:{r:g+(w||1)-1,c:y+E-1}});var Y=B.t||B["data-t"]||"";if(!F.length){y+=E;continue}if(F=S3(F),S.s.r>g&&(S.s.r=g),S.e.r<g&&(S.e.r=g),S.s.c>y&&(S.s.c=y),S.e.c<y&&(S.e.c=y),!F.length){y+=E;continue}var G={t:"s",v:F};a.raw||!F.trim().length||Y=="s"||(F==="TRUE"?G={t:"b",v:!0}:F==="FALSE"?G={t:"b",v:!1}:isNaN(cl(F))?isNaN(Y0(F).getDate())||(G={t:"d",v:Cs(F)},a.cellDates||(G={t:"n",v:Pn(G.v)}),G.z=a.dateNF||aa[14]):G={t:"n",v:cl(F)}),a.dense?(s[g]||(s[g]=[]),s[g][y]=G):s[sa({r:g,c:y})]=G,y+=E}}}}return s["!ref"]=ba(S),A.length&&(s["!merges"]=A),s}function FL(e,r,a,s){for(var n=e["!merges"]||[],i=[],c=r.s.c;c<=r.e.c;++c){for(var u=0,h=0,g=0;g<n.length;++g)if(!(n[g].s.r>a||n[g].s.c>c)&&!(n[g].e.r<a||n[g].e.c<c)){if(n[g].s.r<a||n[g].s.c<c){u=-1;break}u=n[g].e.r-n[g].s.r+1,h=n[g].e.c-n[g].s.c+1;break}if(!(u<0)){var y=sa({r:a,c}),w=s.dense?(e[a]||[])[c]:e[y],E=w&&w.v!=null&&(w.h||ky(w.w||(uc(w),w.w)||""))||"",S={};u>1&&(S.rowspan=u),h>1&&(S.colspan=h),s.editable?E='<span contenteditable="true">'+E+"</span>":w&&(S["data-t"]=w&&w.t||"z",w.v!=null&&(S["data-v"]=w.v),w.z!=null&&(S["data-z"]=w.z),w.l&&(w.l.Target||"#").charAt(0)!="#"&&(E='<a href="'+w.l.Target+'">'+E+"</a>")),S.id=(s.id||"sjs")+"-"+y,i.push(kr("td",E,S))}}var A="<tr>";return A+i.join("")+"</tr>"}var IL='<html><head><meta charset="utf-8"/><title>SheetJS Table Export</title></head><body>',ML="</body></html>";function PL(e,r){var a=e.match(/<table[\s\S]*?>[\s\S]*?<\/table>/gi);if(!a||a.length==0)throw new Error("Invalid HTML: could not find <table>");if(a.length==1)return Kc(dk(a[0],r),r);var s=Jy();return a.forEach(function(n,i){Qy(s,dk(n,r),"Sheet"+(i+1))}),s}function LL(e,r,a){var s=[];return s.join("")+"<table"+(a&&a.id?' id="'+a.id+'"':"")+">"}function aj(e,r){var a=r||{},s=a.header!=null?a.header:IL,n=a.footer!=null?a.footer:ML,i=[s],c=no(e["!ref"]);a.dense=Array.isArray(e),i.push(LL(e,c,a));for(var u=c.s.r;u<=c.e.r;++u)i.push(FL(e,c,u,a));return i.push("</table>"+n),i.join("")}function sj(e,r,a){var s=a||{},n=0,i=0;if(s.origin!=null)if(typeof s.origin=="number")n=s.origin;else{var c=typeof s.origin=="string"?Ws(s.origin):s.origin;n=c.r,i=c.c}var u=r.getElementsByTagName("tr"),h=Math.min(s.sheetRows||1e7,u.length),g={s:{r:0,c:0},e:{r:n,c:i}};if(e["!ref"]){var y=no(e["!ref"]);g.s.r=Math.min(g.s.r,y.s.r),g.s.c=Math.min(g.s.c,y.s.c),g.e.r=Math.max(g.e.r,y.e.r),g.e.c=Math.max(g.e.c,y.e.c),n==-1&&(g.e.r=n=y.e.r+1)}var w=[],E=0,S=e["!rows"]||(e["!rows"]=[]),A=0,C=0,O=0,M=0,R=0,F=0;for(e["!cols"]||(e["!cols"]=[]);A<u.length&&C<h;++A){var z=u[A];if(uk(z)){if(s.display)continue;S[C]={hidden:!0}}var W=z.children;for(O=M=0;O<W.length;++O){var X=W[O];if(!(s.display&&uk(X))){var B=X.hasAttribute("data-v")?X.getAttribute("data-v"):X.hasAttribute("v")?X.getAttribute("v"):S3(X.innerHTML),Y=X.getAttribute("data-z")||X.getAttribute("z");for(E=0;E<w.length;++E){var G=w[E];G.s.c==M+i&&G.s.r<C+n&&C+n<=G.e.r&&(M=G.e.c+1-i,E=-1)}F=+X.getAttribute("colspan")||1,((R=+X.getAttribute("rowspan")||1)>1||F>1)&&w.push({s:{r:C+n,c:M+i},e:{r:C+n+(R||1)-1,c:M+i+(F||1)-1}});var ie={t:"s",v:B},fe=X.getAttribute("data-t")||X.getAttribute("t")||"";B!=null&&(B.length==0?ie.t=fe||"z":s.raw||B.trim().length==0||fe=="s"||(B==="TRUE"?ie={t:"b",v:!0}:B==="FALSE"?ie={t:"b",v:!1}:isNaN(cl(B))?isNaN(Y0(B).getDate())||(ie={t:"d",v:Cs(B)},s.cellDates||(ie={t:"n",v:Pn(ie.v)}),ie.z=s.dateNF||aa[14]):ie={t:"n",v:cl(B)})),ie.z===void 0&&Y!=null&&(ie.z=Y);var K="",ke=X.getElementsByTagName("A");if(ke&&ke.length)for(var ge=0;ge<ke.length&&!(ke[ge].hasAttribute("href")&&(K=ke[ge].getAttribute("href"),K.charAt(0)!="#"));++ge);K&&K.charAt(0)!="#"&&(ie.l={Target:K}),s.dense?(e[C+n]||(e[C+n]=[]),e[C+n][M+i]=ie):e[sa({c:M+i,r:C+n})]=ie,g.e.c<M+i&&(g.e.c=M+i),M+=F}}++C}return w.length&&(e["!merges"]=(e["!merges"]||[]).concat(w)),g.e.r=Math.max(g.e.r,C-1+n),e["!ref"]=ba(g),C>=h&&(e["!fullref"]=ba((g.e.r=u.length-A+C-1+n,g))),e}function nj(e,r){var a=r||{},s=a.dense?[]:{};return sj(s,e,r)}function BL(e,r){return Kc(nj(e,r),r)}function uk(e){var r="",a=UL(e);return a&&(r=a(e).getPropertyValue("display")),r||(r=e.style&&e.style.display),r==="none"}function UL(e){return e.ownerDocument.defaultView&&typeof e.ownerDocument.defaultView.getComputedStyle=="function"?e.ownerDocument.defaultView.getComputedStyle:typeof getComputedStyle=="function"?getComputedStyle:null}function zL(e){var r=e.replace(/[\t\r\n]/g," ").trim().replace(/ +/g," ").replace(/<text:s\/>/g," ").replace(/<text:s text:c="(\d+)"\/>/g,function(s,n){return Array(parseInt(n,10)+1).join(" ")}).replace(/<text:tab[^>]*\/>/g," ").replace(/<text:line-break\/>/g,`
`),a=Ha(r.replace(/<[^>]*>/g,""));return[a]}var fk={day:["d","dd"],month:["m","mm"],year:["y","yy"],hours:["h","hh"],minutes:["m","mm"],seconds:["s","ss"],"am-pm":["A/P","AM/PM"],"day-of-week":["ddd","dddd"],era:["e","ee"],quarter:["\\Qm",'m\\"th quarter"']};function ij(e,r){var a=r||{},s=Ny(e),n=[],i,c,u={name:""},h="",g=0,y,w,E={},S=[],A=a.dense?[]:{},C,O,M={value:""},R="",F=0,z=[],W=-1,X=-1,B={s:{r:1e6,c:1e7},e:{r:0,c:0}},Y=0,G={},ie=[],fe={},K=0,ke=0,ge=[],re=1,we=1,ee=[],ve={Names:[]},ce={},ye=["",""],te=[],q={},J="",ae=0,oe=!1,le=!1,be=0;for(Af.lastIndex=0,s=s.replace(/<!--([\s\S]*?)-->/mg,"").replace(/<!DOCTYPE[^\[]*\[[^\]]*\]>/gm,"");C=Af.exec(s);)switch(C[3]=C[3].replace(/_.*$/,"")){case"table":case"工作表":C[1]==="/"?(B.e.c>=B.s.c&&B.e.r>=B.s.r?A["!ref"]=ba(B):A["!ref"]="A1:A1",a.sheetRows>0&&a.sheetRows<=B.e.r&&(A["!fullref"]=A["!ref"],B.e.r=a.sheetRows-1,A["!ref"]=ba(B)),ie.length&&(A["!merges"]=ie),ge.length&&(A["!rows"]=ge),y.name=y.名称||y.name,typeof JSON!="undefined"&&JSON.stringify(y),S.push(y.name),E[y.name]=A,le=!1):C[0].charAt(C[0].length-2)!=="/"&&(y=ia(C[0],!1),W=X=-1,B.s.r=B.s.c=1e7,B.e.r=B.e.c=0,A=a.dense?[]:{},ie=[],ge=[],le=!0);break;case"table-row-group":C[1]==="/"?--Y:++Y;break;case"table-row":case"行":if(C[1]==="/"){W+=re,re=1;break}if(w=ia(C[0],!1),w.行号?W=w.行号-1:W==-1&&(W=0),re=+w["number-rows-repeated"]||1,re<10)for(be=0;be<re;++be)Y>0&&(ge[W+be]={level:Y});X=-1;break;case"covered-table-cell":C[1]!=="/"&&++X,a.sheetStubs&&(a.dense?(A[W]||(A[W]=[]),A[W][X]={t:"z"}):A[sa({r:W,c:X})]={t:"z"}),R="",z=[];break;case"table-cell":case"数据":if(C[0].charAt(C[0].length-2)==="/")++X,M=ia(C[0],!1),we=parseInt(M["number-columns-repeated"]||"1",10),O={t:"z",v:null},M.formula&&a.cellFormula!=!1&&(O.f=ok(Ha(M.formula))),(M.数据类型||M["value-type"])=="string"&&(O.t="s",O.v=Ha(M["string-value"]||""),a.dense?(A[W]||(A[W]=[]),A[W][X]=O):A[sa({r:W,c:X})]=O),X+=we-1;else if(C[1]!=="/"){++X,R="",F=0,z=[],we=1;var Z=re?W+re-1:W;if(X>B.e.c&&(B.e.c=X),X<B.s.c&&(B.s.c=X),W<B.s.r&&(B.s.r=W),Z>B.e.r&&(B.e.r=Z),M=ia(C[0],!1),te=[],q={},O={t:M.数据类型||M["value-type"],v:null},a.cellFormula)if(M.formula&&(M.formula=Ha(M.formula)),M["number-matrix-columns-spanned"]&&M["number-matrix-rows-spanned"]&&(K=parseInt(M["number-matrix-rows-spanned"],10)||0,ke=parseInt(M["number-matrix-columns-spanned"],10)||0,fe={s:{r:W,c:X},e:{r:W+K-1,c:X+ke-1}},O.F=ba(fe),ee.push([fe,O.F])),M.formula)O.f=ok(M.formula);else for(be=0;be<ee.length;++be)W>=ee[be][0].s.r&&W<=ee[be][0].e.r&&X>=ee[be][0].s.c&&X<=ee[be][0].e.c&&(O.F=ee[be][1]);switch((M["number-columns-spanned"]||M["number-rows-spanned"])&&(K=parseInt(M["number-rows-spanned"],10)||0,ke=parseInt(M["number-columns-spanned"],10)||0,fe={s:{r:W,c:X},e:{r:W+K-1,c:X+ke-1}},ie.push(fe)),M["number-columns-repeated"]&&(we=parseInt(M["number-columns-repeated"],10)),O.t){case"boolean":O.t="b",O.v=Ss(M["boolean-value"]);break;case"float":O.t="n",O.v=parseFloat(M.value);break;case"percentage":O.t="n",O.v=parseFloat(M.value);break;case"currency":O.t="n",O.v=parseFloat(M.value);break;case"date":O.t="d",O.v=Cs(M["date-value"]),a.cellDates||(O.t="n",O.v=Pn(O.v)),O.z="m/d/yy";break;case"time":O.t="n",O.v=mA(M["time-value"])/86400,a.cellDates&&(O.t="d",O.v=wg(O.v)),O.z="HH:MM:SS";break;case"number":O.t="n",O.v=parseFloat(M.数据数值);break;default:if(O.t==="string"||O.t==="text"||!O.t)O.t="s",M["string-value"]!=null&&(R=Ha(M["string-value"]),z=[]);else throw new Error("Unsupported value type "+O.t)}}else{if(oe=!1,O.t==="s"&&(O.v=R||"",z.length&&(O.R=z),oe=F==0),ce.Target&&(O.l=ce),te.length>0&&(O.c=te,te=[]),R&&a.cellText!==!1&&(O.w=R),oe&&(O.t="z",delete O.v),(!oe||a.sheetStubs)&&!(a.sheetRows&&a.sheetRows<=W))for(var Le=0;Le<re;++Le){if(we=parseInt(M["number-columns-repeated"]||"1",10),a.dense)for(A[W+Le]||(A[W+Le]=[]),A[W+Le][X]=Le==0?O:Es(O);--we>0;)A[W+Le][X+we]=Es(O);else for(A[sa({r:W+Le,c:X})]=O;--we>0;)A[sa({r:W+Le,c:X+we})]=Es(O);B.e.c<=X&&(B.e.c=X)}we=parseInt(M["number-columns-repeated"]||"1",10),X+=we-1,we=0,O={},R="",z=[]}ce={};break;case"document":case"document-content":case"电子表格文档":case"spreadsheet":case"主体":case"scripts":case"styles":case"font-face-decls":case"master-styles":if(C[1]==="/"){if((i=n.pop())[0]!==C[3])throw"Bad state: "+i}else C[0].charAt(C[0].length-2)!=="/"&&n.push([C[3],!0]);break;case"annotation":if(C[1]==="/"){if((i=n.pop())[0]!==C[3])throw"Bad state: "+i;q.t=R,z.length&&(q.R=z),q.a=J,te.push(q)}else C[0].charAt(C[0].length-2)!=="/"&&n.push([C[3],!1]);J="",ae=0,R="",F=0,z=[];break;case"creator":C[1]==="/"?J=s.slice(ae,C.index):ae=C.index+C[0].length;break;case"meta":case"元数据":case"settings":case"config-item-set":case"config-item-map-indexed":case"config-item-map-entry":case"config-item-map-named":case"shapes":case"frame":case"text-box":case"image":case"data-pilot-tables":case"list-style":case"form":case"dde-links":case"event-listeners":case"chart":if(C[1]==="/"){if((i=n.pop())[0]!==C[3])throw"Bad state: "+i}else C[0].charAt(C[0].length-2)!=="/"&&n.push([C[3],!1]);R="",F=0,z=[];break;case"scientific-number":break;case"currency-symbol":break;case"currency-style":break;case"number-style":case"percentage-style":case"date-style":case"time-style":if(C[1]==="/"){if(G[u.name]=h,(i=n.pop())[0]!==C[3])throw"Bad state: "+i}else C[0].charAt(C[0].length-2)!=="/"&&(h="",u=ia(C[0],!1),n.push([C[3],!0]));break;case"script":break;case"libraries":break;case"automatic-styles":break;case"default-style":case"page-layout":break;case"style":break;case"map":break;case"font-face":break;case"paragraph-properties":break;case"table-properties":break;case"table-column-properties":break;case"table-row-properties":break;case"table-cell-properties":break;case"number":switch(n[n.length-1][0]){case"time-style":case"date-style":c=ia(C[0],!1),h+=fk[C[3]][c.style==="long"?1:0];break}break;case"fraction":break;case"day":case"month":case"year":case"era":case"day-of-week":case"week-of-year":case"quarter":case"hours":case"minutes":case"seconds":case"am-pm":switch(n[n.length-1][0]){case"time-style":case"date-style":c=ia(C[0],!1),h+=fk[C[3]][c.style==="long"?1:0];break}break;case"boolean-style":break;case"boolean":break;case"text-style":break;case"text":if(C[0].slice(-2)==="/>")break;if(C[1]==="/")switch(n[n.length-1][0]){case"number-style":case"date-style":case"time-style":h+=s.slice(g,C.index);break}else g=C.index+C[0].length;break;case"named-range":c=ia(C[0],!1),ye=qp(c["cell-range-address"]);var Pe={Name:c.name,Ref:ye[0]+"!"+ye[1]};le&&(Pe.Sheet=S.length),ve.Names.push(Pe);break;case"text-content":break;case"text-properties":break;case"embedded-text":break;case"body":case"电子表格":break;case"forms":break;case"table-column":break;case"table-header-rows":break;case"table-rows":break;case"table-column-group":break;case"table-header-columns":break;case"table-columns":break;case"null-date":break;case"graphic-properties":break;case"calculation-settings":break;case"named-expressions":break;case"label-range":break;case"label-ranges":break;case"named-expression":break;case"sort":break;case"sort-by":break;case"sort-groups":break;case"tab":break;case"line-break":break;case"span":break;case"p":case"文本串":if(["master-styles"].indexOf(n[n.length-1][0])>-1)break;if(C[1]==="/"&&(!M||!M["string-value"])){var Be=zL(s.slice(F,C.index));R=(R.length>0?R+`
`:"")+Be[0]}else ia(C[0],!1),F=C.index+C[0].length;break;case"s":break;case"database-range":if(C[1]==="/")break;try{ye=qp(ia(C[0])["target-range-address"]),E[ye[0]]["!autofilter"]={ref:ye[1]}}catch(rt){}break;case"date":break;case"object":break;case"title":case"标题":break;case"desc":break;case"binary-data":break;case"table-source":break;case"scenario":break;case"iteration":break;case"content-validations":break;case"content-validation":break;case"help-message":break;case"error-message":break;case"database-ranges":break;case"filter":break;case"filter-and":break;case"filter-or":break;case"filter-condition":break;case"list-level-style-bullet":break;case"list-level-style-number":break;case"list-level-properties":break;case"sender-firstname":case"sender-lastname":case"sender-initials":case"sender-title":case"sender-position":case"sender-email":case"sender-phone-private":case"sender-fax":case"sender-company":case"sender-phone-work":case"sender-street":case"sender-city":case"sender-postal-code":case"sender-country":case"sender-state-or-province":case"author-name":case"author-initials":case"chapter":case"file-name":case"template-name":case"sheet-name":break;case"event-listener":break;case"initial-creator":case"creation-date":case"print-date":case"generator":case"document-statistic":case"user-defined":case"editing-duration":case"editing-cycles":break;case"config-item":break;case"page-number":break;case"page-count":break;case"time":break;case"cell-range-source":break;case"detective":break;case"operation":break;case"highlighted-range":break;case"data-pilot-table":case"source-cell-range":case"source-service":case"data-pilot-field":case"data-pilot-level":case"data-pilot-subtotals":case"data-pilot-subtotal":case"data-pilot-members":case"data-pilot-member":case"data-pilot-display-info":case"data-pilot-sort-info":case"data-pilot-layout-info":case"data-pilot-field-reference":case"data-pilot-groups":case"data-pilot-group":case"data-pilot-group-member":break;case"rect":break;case"dde-connection-decls":case"dde-connection-decl":case"dde-link":case"dde-source":break;case"properties":break;case"property":break;case"a":if(C[1]!=="/"){if(ce=ia(C[0],!1),!ce.href)break;ce.Target=Ha(ce.href),delete ce.href,ce.Target.charAt(0)=="#"&&ce.Target.indexOf(".")>-1?(ye=qp(ce.Target.slice(1)),ce.Target="#"+ye[0]+"!"+ye[1]):ce.Target.match(/^\.\.[\\\/]/)&&(ce.Target=ce.Target.slice(3))}break;case"table-protection":break;case"data-pilot-grand-total":break;case"office-document-common-attrs":break;default:switch(C[2]){case"dc:":case"calcext:":case"loext:":case"ooo:":case"chartooo:":case"draw:":case"style:":case"chart:":case"form:":case"uof:":case"表:":case"字:":break;default:if(a.WTF)throw new Error(C)}}var pe={Sheets:E,SheetNames:S,Workbook:ve};return a.bookSheets&&delete pe.Sheets,pe}function hk(e,r){r=r||{},Uo(e,"META-INF/manifest.xml")&&m7(kn(e,"META-INF/manifest.xml"),r);var a=wo(e,"content.xml");if(!a)throw new Error("Missing content.xml in ODS / UOF file");var s=ij(ms(a),r);return Uo(e,"meta.xml")&&(s.Props=Z3(kn(e,"meta.xml"))),s}function mk(e,r){return ij(e,r)}var WL=(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 "+Tf({"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 cn+r}})(),gk=(function(){var e=function(i){return ls(i).replace(/ +/g,function(c){return'<text:s text:c="'+c.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,c,u){var h=[];h.push(' <table:table table:name="'+ls(c.SheetNames[u])+`" table:style-name="ta1">
`);var g=0,y=0,w=no(i["!ref"]||"A1"),E=i["!merges"]||[],S=0,A=Array.isArray(i);if(i["!cols"])for(y=0;y<=w.e.c;++y)h.push(" <table:table-column"+(i["!cols"][y]?' table:style-name="co'+i["!cols"][y].ods+'"':"")+`></table:table-column>
`);var C="",O=i["!rows"]||[];for(g=0;g<w.s.r;++g)C=O[g]?' table:style-name="ro'+O[g].ods+'"':"",h.push(" <table:table-row"+C+`></table:table-row>
`);for(;g<=w.e.r;++g){for(C=O[g]?' table:style-name="ro'+O[g].ods+'"':"",h.push(" <table:table-row"+C+`>
`),y=0;y<w.s.c;++y)h.push(r);for(;y<=w.e.c;++y){var M=!1,R={},F="";for(S=0;S!=E.length;++S)if(!(E[S].s.c>y)&&!(E[S].s.r>g)&&!(E[S].e.c<y)&&!(E[S].e.r<g)){(E[S].s.c!=y||E[S].s.r!=g)&&(M=!0),R["table:number-columns-spanned"]=E[S].e.c-E[S].s.c+1,R["table:number-rows-spanned"]=E[S].e.r-E[S].s.r+1;break}if(M){h.push(a);continue}var z=sa({r:g,c:y}),W=A?(i[g]||[])[y]:i[z];if(W&&W.f&&(R["table:formula"]=ls(lI(W.f)),W.F&&W.F.slice(0,z.length)==z)){var X=no(W.F);R["table:number-matrix-columns-spanned"]=X.e.c-X.s.c+1,R["table:number-matrix-rows-spanned"]=X.e.r-X.s.r+1}if(!W){h.push(r);continue}switch(W.t){case"b":F=W.v?"TRUE":"FALSE",R["office:value-type"]="boolean",R["office:boolean-value"]=W.v?"true":"false";break;case"n":F=W.w||String(W.v||0),R["office:value-type"]="float",R["office:value"]=W.v||0;break;case"s":case"str":F=W.v==null?"":W.v,R["office:value-type"]="string";break;case"d":F=W.w||Cs(W.v).toISOString(),R["office:value-type"]="date",R["office:date-value"]=Cs(W.v).toISOString(),R["table:style-name"]="ce1";break;default:h.push(r);continue}var B=e(F);if(W.l&&W.l.Target){var Y=W.l.Target;Y=Y.charAt(0)=="#"?"#"+cI(Y.slice(1)):Y,Y.charAt(0)!="#"&&!Y.match(/^\w+:/)&&(Y="../"+Y),B=kr("text:a",B,{"xlink:href":Y.replace(/&/g,"&amp;")})}h.push(" "+kr("table:table-cell",kr("text:p",B,{}),R)+`
`)}h.push(` </table:table-row>
`)}return h.push(` </table:table>
`),h.join("")},n=function(i,c){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 u=0;c.SheetNames.map(function(g){return c.Sheets[g]}).forEach(function(g){if(g&&g["!cols"]){for(var y=0;y<g["!cols"].length;++y)if(g["!cols"][y]){var w=g["!cols"][y];if(w.width==null&&w.wpx==null&&w.wch==null)continue;Yc(w),w.ods=u;var E=g["!cols"][y].wpx+"px";i.push(' <style:style style:name="co'+u+`" style:family="table-column">
`),i.push(' <style:table-column-properties fo:break-before="auto" style:column-width="'+E+`"/>
`),i.push(` </style:style>
`),++u}}});var h=0;c.SheetNames.map(function(g){return c.Sheets[g]}).forEach(function(g){if(g&&g["!rows"]){for(var y=0;y<g["!rows"].length;++y)if(g["!rows"][y]){g["!rows"][y].ods=h;var w=g["!rows"][y].hpx+"px";i.push(' <style:style style:name="ro'+h+`" style:family="table-row">
`),i.push(' <style:table-row-properties fo:break-before="auto" style:row-height="'+w+`"/>
`),i.push(` </style:style>
`),++h}}}),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(c,u){var h=[cn],g=Tf({"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"}),y=Tf({"xmlns:config":"urn:oasis:names:tc:opendocument:xmlns:config:1.0","office:mimetype":"application/vnd.oasis.opendocument.spreadsheet"});u.bookType=="fods"?(h.push("<office:document"+g+y+`>
`),h.push(X3().replace(/office:document-meta/g,"office:meta"))):h.push("<office:document-content"+g+`>
`),n(h,c),h.push(` <office:body>
`),h.push(` <office:spreadsheet>
`);for(var w=0;w!=c.SheetNames.length;++w)h.push(s(c.Sheets[c.SheetNames[w]],c,w));return h.push(` </office:spreadsheet>
`),h.push(` </office:body>
`),u.bookType=="fods"?h.push("</office:document>"):h.push("</office:document-content>"),h.join("")}})();function oj(e,r){if(r.bookType=="fods")return gk(e,r);var a=vy(),s="",n=[],i=[];return s="mimetype",ka(a,s,"application/vnd.oasis.opendocument.spreadsheet"),s="content.xml",ka(a,s,gk(e,r)),n.push([s,"text/xml"]),i.push([s,"ContentFile"]),s="styles.xml",ka(a,s,WL(e,r)),n.push([s,"text/xml"]),i.push([s,"StylesFile"]),s="meta.xml",ka(a,s,cn+X3()),n.push([s,"text/xml"]),i.push([s,"MetadataFile"]),s="manifest.rdf",ka(a,s,p7(i)),n.push([s,"application/rdf+xml"]),s="META-INF/manifest.xml",ka(a,s,g7(n)),a}function Wd(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function F1(e){return typeof TextDecoder!="undefined"?new TextDecoder().decode(e):ms(Zc(e))}function HL(e){return typeof TextEncoder!="undefined"?new TextEncoder().encode(e):vo(Rl(e))}function $L(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 Xc(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 xk(e){return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>>24}function VL(e,r){for(var a=(e[r+15]&127)<<7|e[r+14]>>1,s=e[r+14]&1,n=r+13;n>=r;--n)s=s*256+e[n];return(e[r+15]&128?-s:s)*Math.pow(10,a-6176)}function GL(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 Pf(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 is(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 Zs(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 Za(e){for(var r=[],a=[0];a[0]<e.length;){var s=a[0],n=Pf(e,a),i=n&7;n=Math.floor(n/8);var c=0,u;if(n==0)break;switch(i){case 0:{for(var h=a[0];e[a[0]++]>=128;);u=e.slice(h,a[0])}break;case 5:c=4,u=e.slice(a[0],a[0]+c),a[0]+=c;break;case 1:c=8,u=e.slice(a[0],a[0]+c),a[0]+=c;break;case 2:c=Pf(e,a),u=e.slice(a[0],a[0]+c),a[0]+=c;break;case 3:case 4:default:throw new Error("PB Type ".concat(i," for Field ").concat(n," at offset ").concat(s))}var g={data:u,type:i};r[n]==null?r[n]=[g]:r[n].push(g)}return r}function ui(e){var r=[];return e.forEach(function(a,s){a.forEach(function(n){n.data&&(r.push(is(s*8+n.type)),n.type==2&&r.push(is(n.data.length)),r.push(n.data))})}),Xc(r)}function Yy(e,r){return(e==null?void 0:e.map(function(a){return r(a.data)}))||[]}function Lo(e){for(var r,a=[],s=[0];s[0]<e.length;){var n=Pf(e,s),i=Za(e.slice(s[0],s[0]+n));s[0]+=n;var c={id:Zs(i[1][0].data),messages:[]};i[2].forEach(function(u){var h=Za(u.data),g=Zs(h[3][0].data);c.messages.push({meta:h,data:e.slice(s[0],s[0]+g)}),s[0]+=g}),(r=i[3])!=null&&r[0]&&(c.merge=Zs(i[3][0].data)>>>0>0),a.push(c)}return a}function T0(e){var r=[];return e.forEach(function(a){var s=[];s[1]=[{data:is(a.id),type:0}],s[2]=[],a.merge!=null&&(s[3]=[{data:is(+!!a.merge),type:0}]);var n=[];a.messages.forEach(function(c){n.push(c.data),c.meta[3]=[{type:0,data:is(c.data.length)}],s[2].push({data:ui(c.meta),type:2})});var i=ui(s);r.push(is(i.length)),r.push(i),n.forEach(function(c){return r.push(c)})}),Xc(r)}function YL(e,r){if(e!=0)throw new Error("Unexpected Snappy chunk type ".concat(e));for(var a=[0],s=Pf(r,a),n=[];a[0]<r.length;){var i=r[a[0]]&3;if(i==0){var c=r[a[0]++]>>2;if(c<60)++c;else{var u=c-59;c=r[a[0]],u>1&&(c|=r[a[0]+1]<<8),u>2&&(c|=r[a[0]+2]<<16),u>3&&(c|=r[a[0]+3]<<24),c>>>=0,c++,a[0]+=u}n.push(r.slice(a[0],a[0]+c)),a[0]+=c;continue}else{var h=0,g=0;if(i==1?(g=(r[a[0]]>>2&7)+4,h=(r[a[0]++]&224)<<3,h|=r[a[0]++]):(g=(r[a[0]++]>>2)+1,i==2?(h=r[a[0]]|r[a[0]+1]<<8,a[0]+=2):(h=(r[a[0]]|r[a[0]+1]<<8|r[a[0]+2]<<16|r[a[0]+3]<<24)>>>0,a[0]+=4)),n=[Xc(n)],h==0)throw new Error("Invalid offset 0");if(h>n[0].length)throw new Error("Invalid offset beyond length");if(g>=h)for(n.push(n[0].slice(-h)),g-=h;g>=n[n.length-1].length;)n.push(n[n.length-1]),g-=n[n.length-1].length;n.push(n[0].slice(-h,-h+g))}}var y=Xc(n);if(y.length!=s)throw new Error("Unexpected length: ".concat(y.length," != ").concat(s));return y}function Bo(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(YL(s,e.slice(a,a+n))),a+=n}if(a!==e.length)throw new Error("data is not a valid framed stream!");return Xc(r)}function A0(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=is(s),c=i.length;r.push(i),s<=60?(c++,r.push(new Uint8Array([s-1<<2]))):s<=256?(c+=2,r.push(new Uint8Array([240,s-1&255]))):s<=65536?(c+=3,r.push(new Uint8Array([244,s-1&255,s-1>>8&255]))):s<=16777216?(c+=4,r.push(new Uint8Array([248,s-1&255,s-1>>8&255,s-1>>16&255]))):s<=4294967296&&(c+=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)),c+=s,n[0]=0,n[1]=c&255,n[2]=c>>8&255,n[3]=c>>16&255,a+=s}return Xc(r)}function qL(e,r,a,s){var n=Wd(e),i=n.getUint32(4,!0),c=(s>1?12:8)+xk(i&(s>1?3470:398))*4,u=-1,h=-1,g=NaN,y=new Date(2001,0,1);i&512&&(u=n.getUint32(c,!0),c+=4),c+=xk(i&(s>1?12288:4096))*4,i&16&&(h=n.getUint32(c,!0),c+=4),i&32&&(g=n.getFloat64(c,!0),c+=8),i&64&&(y.setTime(y.getTime()+n.getFloat64(c,!0)*1e3),c+=8);var w;switch(e[2]){case 0:break;case 2:w={t:"n",v:g};break;case 3:w={t:"s",v:r[h]};break;case 5:w={t:"d",v:y};break;case 6:w={t:"b",v:g>0};break;case 7:w={t:"n",v:g/86400};break;case 8:w={t:"e",v:0};break;case 9:if(u>-1)w={t:"s",v:a[u]};else if(h>-1)w={t:"s",v:r[h]};else if(!isNaN(g))w={t:"n",v:g};else throw new Error("Unsupported cell type ".concat(e.slice(0,4)));break;default:throw new Error("Unsupported cell type ".concat(e.slice(0,4)))}return w}function XL(e,r,a){var s=Wd(e),n=s.getUint32(8,!0),i=12,c=-1,u=-1,h=NaN,g=NaN,y=new Date(2001,0,1);n&1&&(h=VL(e,i),i+=16),n&2&&(g=s.getFloat64(i,!0),i+=8),n&4&&(y.setTime(y.getTime()+s.getFloat64(i,!0)*1e3),i+=8),n&8&&(u=s.getUint32(i,!0),i+=4),n&16&&(c=s.getUint32(i,!0),i+=4);var w;switch(e[1]){case 0:break;case 2:w={t:"n",v:h};break;case 3:w={t:"s",v:r[u]};break;case 5:w={t:"d",v:y};break;case 6:w={t:"b",v:g>0};break;case 7:w={t:"n",v:g/86400};break;case 8:w={t:"e",v:0};break;case 9:if(c>-1)w={t:"s",v:a[c]};else throw new Error("Unsupported cell type ".concat(e[1]," : ").concat(n&31," : ").concat(e.slice(0,4)));break;case 10:w={t:"n",v:h};break;default:throw new Error("Unsupported cell type ".concat(e[1]," : ").concat(n&31," : ").concat(e.slice(0,4)))}return w}function Zp(e,r){var a=new Uint8Array(32),s=Wd(a),n=12,i=0;switch(a[0]=5,e.t){case"n":a[1]=2,GL(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 Kp(e,r){var a=new Uint8Array(32),s=Wd(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 ZL(e,r,a){switch(e[0]){case 0:case 1:case 2:case 3:return qL(e,r,a,e[0]);case 5:return XL(e,r,a);default:throw new Error("Unsupported payload version ".concat(e[0]))}}function _i(e){var r=Za(e);return Pf(r[1][0].data)}function pk(e,r){var a=Za(r.data),s=Zs(a[1][0].data),n=a[3],i=[];return(n||[]).forEach(function(c){var u=Za(c.data),h=Zs(u[1][0].data)>>>0;switch(s){case 1:i[h]=F1(u[3][0].data);break;case 8:{var g=e[_i(u[9][0].data)][0],y=Za(g.data),w=e[_i(y[1][0].data)][0],E=Zs(w.meta[1][0].data);if(E!=2001)throw new Error("2000 unexpected reference to ".concat(E));var S=Za(w.data);i[h]=S[3].map(function(A){return F1(A.data)}).join("")}break}}),i}function KL(e,r){var a,s,n,i,c,u,h,g,y,w,E,S,A,C,O=Za(e),M=Zs(O[1][0].data)>>>0,R=Zs(O[2][0].data)>>>0,F=((s=(a=O[8])==null?void 0:a[0])==null?void 0:s.data)&&Zs(O[8][0].data)>0||!1,z,W;if((i=(n=O[7])==null?void 0:n[0])!=null&&i.data&&r!=0)z=(u=(c=O[7])==null?void 0:c[0])==null?void 0:u.data,W=(g=(h=O[6])==null?void 0:h[0])==null?void 0:g.data;else if((w=(y=O[4])==null?void 0:y[0])!=null&&w.data&&r!=1)z=(S=(E=O[4])==null?void 0:E[0])==null?void 0:S.data,W=(C=(A=O[3])==null?void 0:A[0])==null?void 0:C.data;else throw"NUMBERS Tile missing ".concat(r," cell storage");for(var X=F?4:1,B=Wd(z),Y=[],G=0;G<z.length/2;++G){var ie=B.getUint16(G*2,!0);ie<65535&&Y.push([G,ie])}if(Y.length!=R)throw"Expected ".concat(R," cells, found ").concat(Y.length);var fe=[];for(G=0;G<Y.length-1;++G)fe[Y[G][0]]=W.subarray(Y[G][1]*X,Y[G+1][1]*X);return Y.length>=1&&(fe[Y[Y.length-1][0]]=W.subarray(Y[Y.length-1][1]*X)),{R:M,cells:fe}}function JL(e,r){var a,s=Za(r.data),n=(a=s==null?void 0:s[7])!=null&&a[0]?Zs(s[7][0].data)>>>0>0?1:0:-1,i=Yy(s[5],function(c){return KL(c,n)});return{nrows:Zs(s[4][0].data)>>>0,data:i.reduce(function(c,u){return c[u.R]||(c[u.R]=[]),u.cells.forEach(function(h,g){if(c[u.R][g])throw new Error("Duplicate cell r=".concat(u.R," c=").concat(g));c[u.R][g]=h}),c},[])}}function QL(e,r,a){var s,n=Za(r.data),i={s:{r:0,c:0},e:{r:0,c:0}};if(i.e.r=(Zs(n[6][0].data)>>>0)-1,i.e.r<0)throw new Error("Invalid row varint ".concat(n[6][0].data));if(i.e.c=(Zs(n[7][0].data)>>>0)-1,i.e.c<0)throw new Error("Invalid col varint ".concat(n[7][0].data));a["!ref"]=ba(i);var c=Za(n[4][0].data),u=pk(e,e[_i(c[4][0].data)][0]),h=(s=c[17])!=null&&s[0]?pk(e,e[_i(c[17][0].data)][0]):[],g=Za(c[3][0].data),y=0;g[1].forEach(function(w){var E=Za(w.data),S=e[_i(E[2][0].data)][0],A=Zs(S.meta[1][0].data);if(A!=6002)throw new Error("6001 unexpected reference to ".concat(A));var C=JL(e,S);C.data.forEach(function(O,M){O.forEach(function(R,F){var z=sa({r:y+M,c:F}),W=ZL(R,u,h);W&&(a[z]=W)})}),y+=C.nrows})}function eB(e,r){var a=Za(r.data),s={"!ref":"A1"},n=e[_i(a[2][0].data)],i=Zs(n[0].meta[1][0].data);if(i!=6001)throw new Error("6000 unexpected reference to ".concat(i));return QL(e,n[0],s),s}function tB(e,r){var a,s=Za(r.data),n={name:(a=s[1])!=null&&a[0]?F1(s[1][0].data):"",sheets:[]},i=Yy(s[2],_i);return i.forEach(function(c){e[c].forEach(function(u){var h=Zs(u.meta[1][0].data);h==6e3&&n.sheets.push(eB(e,u))})}),n}function rB(e,r){var a=Jy(),s=Za(r.data),n=Yy(s[1],_i);if(n.forEach(function(i){e[i].forEach(function(c){var u=Zs(c.meta[1][0].data);if(u==2){var h=tB(e,c);h.sheets.forEach(function(g,y){Qy(a,g,y==0?h.name:h.name+"_"+y,!0)})}})}),a.SheetNames.length==0)throw new Error("Empty NUMBERS file");return a}function Jp(e){var r,a,s,n,i={},c=[];if(e.FullPaths.forEach(function(h){if(h.match(/\.iwpv2/))throw new Error("Unsupported password protection")}),e.FileIndex.forEach(function(h){if(h.name.match(/\.iwa$/)){var g;try{g=Bo(h.content)}catch(w){return console.log("?? "+h.content.length+" "+(w.message||w))}var y;try{y=Lo(g)}catch(w){return console.log("## "+(w.message||w))}y.forEach(function(w){i[w.id]=w.messages,c.push(w.id)})}}),!c.length)throw new Error("File has no messages");var u=((n=(s=(a=(r=i==null?void 0:i[1])==null?void 0:r[0])==null?void 0:a.meta)==null?void 0:s[1])==null?void 0:n[0].data)&&Zs(i[1][0].meta[1][0].data)==1&&i[1][0];if(u||c.forEach(function(h){i[h].forEach(function(g){var y=Zs(g.meta[1][0].data)>>>0;if(y==1)if(!u)u=g;else throw new Error("Document has multiple roots")})}),!u)throw new Error("Cannot find Document root");return rB(i,u)}function aB(e,r,a){var s,n,i,c;if(!((s=e[6])!=null&&s[0])||!((n=e[7])!=null&&n[0]))throw"Mutation only works on post-BNC storages!";var u=((c=(i=e[8])==null?void 0:i[0])==null?void 0:c.data)&&Zs(e[8][0].data)>0||!1;if(u)throw"Math only works with normal offsets";for(var h=0,g=Wd(e[7][0].data),y=0,w=[],E=Wd(e[4][0].data),S=0,A=[],C=0;C<r.length;++C){if(r[C]==null){g.setUint16(C*2,65535,!0),E.setUint16(C*2,65535);continue}g.setUint16(C*2,y,!0),E.setUint16(C*2,S,!0);var O,M;switch(typeof r[C]){case"string":O=Zp({t:"s",v:r[C]},a),M=Kp({t:"s",v:r[C]},a);break;case"number":O=Zp({t:"n",v:r[C]},a),M=Kp({t:"n",v:r[C]},a);break;case"boolean":O=Zp({t:"b",v:r[C]},a),M=Kp({t:"b",v:r[C]},a);break;default:throw new Error("Unsupported value "+r[C])}w.push(O),y+=O.length,A.push(M),S+=M.length,++h}for(e[2][0].data=is(h);C<e[7][0].data.length/2;++C)g.setUint16(C*2,65535,!0),E.setUint16(C*2,65535,!0);return e[6][0].data=Xc(w),e[3][0].data=Xc(A),h}function sB(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=no(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(ba(s)));var i=ng(a,{range:s,header:1}),c=["~Sh33tJ5~"];i.forEach(function(J){return J.forEach(function(ae){typeof ae=="string"&&c.push(ae)})});var u={},h=[],g=Zr.read(r.numbers,{type:"base64"});g.FileIndex.map(function(J,ae){return[J,g.FullPaths[ae]]}).forEach(function(J){var ae=J[0],oe=J[1];if(ae.type==2&&ae.name.match(/\.iwa/)){var le=ae.content,be=Bo(le),Z=Lo(be);Z.forEach(function(Le){h.push(Le.id),u[Le.id]={deps:[],location:oe,type:Zs(Le.messages[0].meta[1][0].data)}})}}),h.sort(function(J,ae){return J-ae});var y=h.filter(function(J){return J>1}).map(function(J){return[J,is(J)]});g.FileIndex.map(function(J,ae){return[J,g.FullPaths[ae]]}).forEach(function(J){var ae=J[0];if(J[1],!!ae.name.match(/\.iwa/)){var oe=Lo(Bo(ae.content));oe.forEach(function(le){le.messages.forEach(function(be){y.forEach(function(Z){le.messages.some(function(Le){return Zs(Le.meta[1][0].data)!=11006&&$L(Le.data,Z[1])})&&u[Z[0]].deps.push(le.id)})})})}});for(var w=Zr.find(g,u[1].location),E=Lo(Bo(w.content)),S,A=0;A<E.length;++A){var C=E[A];C.id==1&&(S=C)}var O=_i(Za(S.messages[0].data)[1][0].data);for(w=Zr.find(g,u[O].location),E=Lo(Bo(w.content)),A=0;A<E.length;++A)C=E[A],C.id==O&&(S=C);for(O=_i(Za(S.messages[0].data)[2][0].data),w=Zr.find(g,u[O].location),E=Lo(Bo(w.content)),A=0;A<E.length;++A)C=E[A],C.id==O&&(S=C);for(O=_i(Za(S.messages[0].data)[2][0].data),w=Zr.find(g,u[O].location),E=Lo(Bo(w.content)),A=0;A<E.length;++A)C=E[A],C.id==O&&(S=C);var M=Za(S.messages[0].data);{M[6][0].data=is(s.e.r+1),M[7][0].data=is(s.e.c+1);var R=_i(M[46][0].data),F=Zr.find(g,u[R].location),z=Lo(Bo(F.content));{for(var W=0;W<z.length&&z[W].id!=R;++W);if(z[W].id!=R)throw"Bad ColumnRowUIDMapArchive";var X=Za(z[W].messages[0].data);X[1]=[],X[2]=[],X[3]=[];for(var B=0;B<=s.e.c;++B){var Y=[];Y[1]=Y[2]=[{type:0,data:is(B+420690)}],X[1].push({type:2,data:ui(Y)}),X[2].push({type:0,data:is(B)}),X[3].push({type:0,data:is(B)})}X[4]=[],X[5]=[],X[6]=[];for(var G=0;G<=s.e.r;++G)Y=[],Y[1]=Y[2]=[{type:0,data:is(G+726270)}],X[4].push({type:2,data:ui(Y)}),X[5].push({type:0,data:is(G)}),X[6].push({type:0,data:is(G)});z[W].messages[0].data=ui(X)}F.content=A0(T0(z)),F.size=F.content.length,delete M[46];var ie=Za(M[4][0].data);{ie[7][0].data=is(s.e.r+1);var fe=Za(ie[1][0].data),K=_i(fe[2][0].data);F=Zr.find(g,u[K].location),z=Lo(Bo(F.content));{if(z[0].id!=K)throw"Bad HeaderStorageBucket";var ke=Za(z[0].messages[0].data);for(G=0;G<i.length;++G){var ge=Za(ke[2][0].data);ge[1][0].data=is(G),ge[4][0].data=is(i[G].length),ke[2][G]={type:ke[2][0].type,data:ui(ge)}}z[0].messages[0].data=ui(ke)}F.content=A0(T0(z)),F.size=F.content.length;var re=_i(ie[2][0].data);F=Zr.find(g,u[re].location),z=Lo(Bo(F.content));{if(z[0].id!=re)throw"Bad HeaderStorageBucket";for(ke=Za(z[0].messages[0].data),B=0;B<=s.e.c;++B)ge=Za(ke[2][0].data),ge[1][0].data=is(B),ge[4][0].data=is(s.e.r+1),ke[2][B]={type:ke[2][0].type,data:ui(ge)};z[0].messages[0].data=ui(ke)}F.content=A0(T0(z)),F.size=F.content.length;var we=_i(ie[4][0].data);(function(){for(var J=Zr.find(g,u[we].location),ae=Lo(Bo(J.content)),oe,le=0;le<ae.length;++le){var be=ae[le];be.id==we&&(oe=be)}var Z=Za(oe.messages[0].data);{Z[3]=[];var Le=[];c.forEach(function(pe,rt){Le[1]=[{type:0,data:is(rt)}],Le[2]=[{type:0,data:is(1)}],Le[3]=[{type:2,data:HL(pe)}],Z[3].push({type:2,data:ui(Le)})})}oe.messages[0].data=ui(Z);var Pe=T0(ae),Be=A0(Pe);J.content=Be,J.size=J.content.length})();var ee=Za(ie[3][0].data);{var ve=ee[1][0];delete ee[2];var ce=Za(ve.data);{var ye=_i(ce[2][0].data);(function(){for(var J=Zr.find(g,u[ye].location),ae=Lo(Bo(J.content)),oe,le=0;le<ae.length;++le){var be=ae[le];be.id==ye&&(oe=be)}var Z=Za(oe.messages[0].data);{delete Z[6],delete ee[7];var Le=new Uint8Array(Z[5][0].data);Z[5]=[];for(var Pe=0,Be=0;Be<=s.e.r;++Be){var pe=Za(Le);Pe+=aB(pe,i[Be],c),pe[1][0].data=is(Be),Z[5].push({data:ui(pe),type:2})}Z[1]=[{type:0,data:is(s.e.c+1)}],Z[2]=[{type:0,data:is(s.e.r+1)}],Z[3]=[{type:0,data:is(Pe)}],Z[4]=[{type:0,data:is(s.e.r+1)}]}oe.messages[0].data=ui(Z);var rt=T0(ae),ct=A0(rt);J.content=ct,J.size=J.content.length})()}ve.data=ui(ce)}ie[3][0].data=ui(ee)}M[4][0].data=ui(ie)}S.messages[0].data=ui(M);var te=T0(E),q=A0(te);return w.content=q,w.size=w.content.length,g}function lj(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 qy(e){lj([["cellNF",!1],["cellHTML",!0],["cellFormula",!0],["cellStyles",!1],["cellText",!0],["cellDates",!1],["sheetStubs",!1],["sheetRows",0,"n"],["bookDeps",!1],["bookSheets",!1],["bookProps",!1],["bookFiles",!1],["bookVBA",!1],["password",""],["WTF",!1]])(e)}function Xy(e){lj([["cellDates",!1],["bookSST",!1],["bookType","xlsx"],["compression",!1],["WTF",!1]])(e)}function nB(e){return Aa.WS.indexOf(e)>-1?"sheet":e==Aa.CS?"chart":e==Aa.DS?"dialog":e==Aa.MS?"macro":e&&e.length?e:"sheet"}function iB(e,r){if(!e)return 0;try{e=r.map(function(s){return s.id||(s.id=s.strRelID),[s.name,e["!id"][s.id].Target,nB(e["!id"][s.id].Type)]})}catch(a){return null}return!e||e.length===0?null:e}function oB(e,r,a,s,n,i,c,u,h,g,y,w){try{i[s]=xf(wo(e,a,!0),r);var E=kn(e,r),S;switch(u){case"sheet":S=TP(E,r,n,h,i[s],g,y,w);break;case"chart":if(S=AP(E,r,n,h,i[s],g,y,w),!S||!S["!drawel"])break;var A=nf(S["!drawel"].Target,r),C=Of(A),O=xR(wo(e,A,!0),xf(wo(e,C,!0),A)),M=nf(O,A),R=Of(M);S=aP(wo(e,M,!0),M,h,xf(wo(e,R,!0),M),g,S);break;case"macro":S=OP(E,r,n,h,i[s],g,y,w);break;case"dialog":S=DP(E,r,n,h,i[s],g,y,w);break;default:throw new Error("Unrecognized sheet type "+u)}c[s]=S;var F=[];i&&i[s]&&Qs(i[s]).forEach(function(z){var W="";if(i[s][z].Type==Aa.CMNT){W=nf(i[s][z].Target,r);var X=MP(kn(e,W,!0),W,h);if(!X||!X.length)return;rk(S,X,!1)}i[s][z].Type==Aa.TCMNT&&(W=nf(i[s][z].Target,r),F=F.concat(yR(kn(e,W,!0),h)))}),F&&F.length&&rk(S,F,!0,h.people||[])}catch(z){if(h.WTF)throw z}}function Mo(e){return e.charAt(0)=="/"?e.slice(1):e}function lB(e,r){if(au(),r=r||{},qy(r),Uo(e,"META-INF/manifest.xml")||Uo(e,"objectdata.xml"))return hk(e,r);if(Uo(e,"Index/Document.iwa")){if(typeof Uint8Array=="undefined")throw new Error("NUMBERS file parsing requires Uint8Array support");if(typeof Jp!="undefined"){if(e.FileIndex)return Jp(e);var a=Zr.utils.cfb_new();return k_(e).forEach(function(ge){ka(a,ge,bA(e,ge))}),Jp(a)}throw new Error("Unsupported NUMBERS file")}if(!Uo(e,"[Content_Types].xml"))throw Uo(e,"index.xml.gz")?new Error("Unsupported NUMBERS 08 file"):Uo(e,"index.xml")?new Error("Unsupported NUMBERS 09 file"):new Error("Unsupported ZIP file");var s=k_(e),n=f7(wo(e,"[Content_Types].xml")),i=!1,c,u;if(n.workbooks.length===0&&(u="xl/workbook.xml",kn(e,u,!0)&&n.workbooks.push(u)),n.workbooks.length===0){if(u="xl/workbook.bin",!kn(e,u,!0))throw new Error("Could not find workbook");n.workbooks.push(u),i=!0}n.workbooks[0].slice(-3)=="bin"&&(i=!0);var h={},g={};if(!r.bookSheets&&!r.bookProps){if(pf=[],n.sst)try{pf=IP(kn(e,Mo(n.sst)),n.sst,r)}catch(ge){if(r.WTF)throw ge}r.cellStyles&&n.themes.length&&(h=FP(wo(e,n.themes[0].replace(/^\//,""),!0)||"",n.themes[0],r)),n.style&&(g=RP(kn(e,Mo(n.style)),n.style,h,r))}n.links.map(function(ge){try{var re=xf(wo(e,Of(Mo(ge))),ge);return LP(kn(e,Mo(ge)),re,ge,r)}catch(we){}});var y=EP(kn(e,Mo(n.workbooks[0])),n.workbooks[0],r),w={},E="";n.coreprops.length&&(E=kn(e,Mo(n.coreprops[0]),!0),E&&(w=Z3(E)),n.extprops.length!==0&&(E=kn(e,Mo(n.extprops[0]),!0),E&&b7(E,w,r)));var S={};(!r.bookSheets||r.bookProps)&&n.custprops.length!==0&&(E=wo(e,Mo(n.custprops[0]),!0),E&&(S=w7(E,r)));var A={};if((r.bookSheets||r.bookProps)&&(y.Sheets?c=y.Sheets.map(function(re){return re.name}):w.Worksheets&&w.SheetNames.length>0&&(c=w.SheetNames),r.bookProps&&(A.Props=w,A.Custprops=S),r.bookSheets&&typeof c!="undefined"&&(A.SheetNames=c),r.bookSheets?A.SheetNames:r.bookProps))return A;c={};var C={};r.bookDeps&&n.calcchain&&(C=PP(kn(e,Mo(n.calcchain)),n.calcchain));var O=0,M={},R,F;{var z=y.Sheets;w.Worksheets=z.length,w.SheetNames=[];for(var W=0;W!=z.length;++W)w.SheetNames[W]=z[W].name}var X=i?"bin":"xml",B=n.workbooks[0].lastIndexOf("/"),Y=(n.workbooks[0].slice(0,B+1)+"_rels/"+n.workbooks[0].slice(B+1)+".rels").replace(/^\//,"");Uo(e,Y)||(Y="xl/_rels/workbook."+X+".rels");var G=xf(wo(e,Y,!0),Y.replace(/_rels.*/,"s5s"));(n.metadata||[]).length>=1&&(r.xlmeta=BP(kn(e,Mo(n.metadata[0])),n.metadata[0],r)),(n.people||[]).length>=1&&(r.people=vR(kn(e,Mo(n.people[0])),r)),G&&(G=iB(G,y.Sheets));var ie=kn(e,"xl/worksheets/sheet.xml",!0)?1:0;e:for(O=0;O!=w.Worksheets;++O){var fe="sheet";if(G&&G[O]?(R="xl/"+G[O][1].replace(/[\/]?xl\//,""),Uo(e,R)||(R=G[O][1]),Uo(e,R)||(R=Y.replace(/_rels\/.*$/,"")+G[O][1]),fe=G[O][2]):(R="xl/worksheets/sheet"+(O+1-ie)+"."+X,R=R.replace(/sheet0\./,"sheet.")),F=R.replace(/^(.*)(\/)([^\/]*)$/,"$1/_rels/$3.rels"),r&&r.sheets!=null)switch(typeof r.sheets){case"number":if(O!=r.sheets)continue e;break;case"string":if(w.SheetNames[O].toLowerCase()!=r.sheets.toLowerCase())continue e;break;default:if(Array.isArray&&Array.isArray(r.sheets)){for(var K=!1,ke=0;ke!=r.sheets.length;++ke)typeof r.sheets[ke]=="number"&&r.sheets[ke]==O&&(K=1),typeof r.sheets[ke]=="string"&&r.sheets[ke].toLowerCase()==w.SheetNames[O].toLowerCase()&&(K=1);if(!K)continue e}}oB(e,R,F,w.SheetNames[O],O,M,c,fe,r,y,h,g)}return A={Directory:n,Workbook:y,Props:w,Custprops:S,Deps:C,Sheets:c,SheetNames:w.SheetNames,Strings:pf,Styles:g,Themes:h,SSF:Es(aa)},r&&r.bookFiles&&(e.files?(A.keys=s,A.files=e.files):(A.keys=[],A.files={},e.FullPaths.forEach(function(ge,re){ge=ge.replace(/^Root Entry[\/]/,""),A.keys.push(ge),A.files[ge]=e.FileIndex[re]}))),r&&r.bookVBA&&(n.vba.length>0?A.vbaraw=kn(e,Mo(n.vba[0]),!0):n.defaults&&n.defaults.bin===ER&&(A.vbaraw=kn(e,"xl/vbaProject.bin",!0))),A}function cB(e,r){var a=r||{},s="Workbook",n=Zr.find(e,s);try{if(s="/!DataSpaces/Version",n=Zr.find(e,s),!n||!n.content)throw new Error("ECMA-376 Encrypted file missing "+s);if(BO(n.content),s="/!DataSpaces/DataSpaceMap",n=Zr.find(e,s),!n||!n.content)throw new Error("ECMA-376 Encrypted file missing "+s);var i=zO(n.content);if(i.length!==1||i[0].comps.length!==1||i[0].comps[0].t!==0||i[0].name!=="StrongEncryptionDataSpace"||i[0].comps[0].v!=="EncryptedPackage")throw new Error("ECMA-376 Encrypted file bad "+s);if(s="/!DataSpaces/DataSpaceInfo/StrongEncryptionDataSpace",n=Zr.find(e,s),!n||!n.content)throw new Error("ECMA-376 Encrypted file missing "+s);var c=WO(n.content);if(c.length!=1||c[0]!="StrongEncryptionTransform")throw new Error("ECMA-376 Encrypted file bad "+s);if(s="/!DataSpaces/TransformInfo/StrongEncryptionTransform/!Primary",n=Zr.find(e,s),!n||!n.content)throw new Error("ECMA-376 Encrypted file missing "+s);$O(n.content)}catch(h){}if(s="/EncryptionInfo",n=Zr.find(e,s),!n||!n.content)throw new Error("ECMA-376 Encrypted file missing "+s);var u=VO(n.content);if(s="/EncryptedPackage",n=Zr.find(e,s),!n||!n.content)throw new Error("ECMA-376 Encrypted file missing "+s);if(u[0]==4&&typeof decrypt_agile!="undefined")return decrypt_agile(u[1],n.content,a.password||"",a);if(u[0]==2&&typeof decrypt_std76!="undefined")return decrypt_std76(u[1],n.content,a.password||"",a);throw new Error("File is password-protected")}function dB(e,r){return r.bookType=="ods"?oj(e,r):r.bookType=="numbers"?sB(e,r):r.bookType=="xlsb"?uB(e,r):fB(e,r)}function uB(e,r){I0=1024,e&&!e.SSF&&(e.SSF=Es(aa)),e&&e.SSF&&(au(),yg(e.SSF),r.revssf=vg(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,yf?r.revStrings=new Map:(r.revStrings={},r.revStrings.foo=[],delete r.revStrings.foo);var a=r.bookType=="xlsb"?"bin":"xml",s=IN.indexOf(r.bookType)>-1,n=Fy();Xy(r=r||{});var i=vy(),c="",u=0;if(r.cellXfs=[],Jc(r.cellXfs,{},{revssf:{General:0}}),e.Props||(e.Props={}),c="docProps/core.xml",ka(i,c,K3(e.Props,r)),n.coreprops.push(c),os(r.rels,2,c,Aa.CORE_PROPS),c="docProps/app.xml",!(e.Props&&e.Props.SheetNames))if(!e.Workbook||!e.Workbook.Sheets)e.Props.SheetNames=e.SheetNames;else{for(var h=[],g=0;g<e.SheetNames.length;++g)(e.Workbook.Sheets[g]||{}).Hidden!=2&&h.push(e.SheetNames[g]);e.Props.SheetNames=h}for(e.Props.Worksheets=e.Props.SheetNames.length,ka(i,c,eN(e.Props)),n.extprops.push(c),os(r.rels,3,c,Aa.EXT_PROPS),e.Custprops!==e.Props&&Qs(e.Custprops||{}).length>0&&(c="docProps/custom.xml",ka(i,c,tN(e.Custprops)),n.custprops.push(c),os(r.rels,4,c,Aa.CUST_PROPS)),u=1;u<=e.SheetNames.length;++u){var y={"!id":{}},w=e.Sheets[e.SheetNames[u-1]],E=(w||{})["!type"]||"sheet";switch(E){case"chart":default:c="xl/worksheets/sheet"+u+"."+a,ka(i,c,zP(u-1,c,r,e,y)),n.sheets.push(c),os(r.wbrels,-1,"worksheets/sheet"+u+"."+a,Aa.WS[0])}if(w){var S=w["!comments"],A=!1,C="";S&&S.length>0&&(C="xl/comments"+u+"."+a,ka(i,C,$P(S,C)),n.comments.push(C),os(y,-1,"../comments"+u+"."+a,Aa.CMNT),A=!0),w["!legacy"]&&A&&ka(i,"xl/drawings/vmlDrawing"+u+".vml",RN(u,w["!comments"])),delete w["!comments"],delete w["!legacy"]}y["!id"].rId1&&ka(i,Of(c),H0(y))}return r.Strings!=null&&r.Strings.length>0&&(c="xl/sharedStrings."+a,ka(i,c,HP(r.Strings,c,r)),n.strs.push(c),os(r.wbrels,-1,"sharedStrings."+a,Aa.SST)),c="xl/workbook."+a,ka(i,c,UP(e,c)),n.workbooks.push(c),os(r.rels,1,c,Aa.WB),c="xl/theme/theme1.xml",ka(i,c,Uy(e.Themes,r)),n.themes.push(c),os(r.wbrels,-1,"theme/theme1.xml",Aa.THEME),c="xl/styles."+a,ka(i,c,WP(e,c,r)),n.styles.push(c),os(r.wbrels,-1,"styles."+a,Aa.STY),e.vbaraw&&s&&(c="xl/vbaProject.bin",ka(i,c,e.vbaraw),n.vba.push(c),os(r.wbrels,-1,"vbaProject.bin",Aa.VBA)),c="xl/metadata."+a,ka(i,c,VP(c)),n.metadata.push(c),os(r.wbrels,-1,"metadata."+a,Aa.XLMETA),ka(i,"[Content_Types].xml",q3(n,r)),ka(i,"_rels/.rels",H0(r.rels)),ka(i,"xl/_rels/workbook."+a+".rels",H0(r.wbrels)),delete r.revssf,delete r.ssf,i}function fB(e,r){I0=1024,e&&!e.SSF&&(e.SSF=Es(aa)),e&&e.SSF&&(au(),yg(e.SSF),r.revssf=vg(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,yf?r.revStrings=new Map:(r.revStrings={},r.revStrings.foo=[],delete r.revStrings.foo);var a="xml",s=IN.indexOf(r.bookType)>-1,n=Fy();Xy(r=r||{});var i=vy(),c="",u=0;if(r.cellXfs=[],Jc(r.cellXfs,{},{revssf:{General:0}}),e.Props||(e.Props={}),c="docProps/core.xml",ka(i,c,K3(e.Props,r)),n.coreprops.push(c),os(r.rels,2,c,Aa.CORE_PROPS),c="docProps/app.xml",!(e.Props&&e.Props.SheetNames))if(!e.Workbook||!e.Workbook.Sheets)e.Props.SheetNames=e.SheetNames;else{for(var h=[],g=0;g<e.SheetNames.length;++g)(e.Workbook.Sheets[g]||{}).Hidden!=2&&h.push(e.SheetNames[g]);e.Props.SheetNames=h}e.Props.Worksheets=e.Props.SheetNames.length,ka(i,c,eN(e.Props)),n.extprops.push(c),os(r.rels,3,c,Aa.EXT_PROPS),e.Custprops!==e.Props&&Qs(e.Custprops||{}).length>0&&(c="docProps/custom.xml",ka(i,c,tN(e.Custprops)),n.custprops.push(c),os(r.rels,4,c,Aa.CUST_PROPS));var y=["SheetJ5"];for(r.tcid=0,u=1;u<=e.SheetNames.length;++u){var w={"!id":{}},E=e.Sheets[e.SheetNames[u-1]],S=(E||{})["!type"]||"sheet";switch(S){case"chart":default:c="xl/worksheets/sheet"+u+"."+a,ka(i,c,GN(u-1,r,e,w)),n.sheets.push(c),os(r.wbrels,-1,"worksheets/sheet"+u+"."+a,Aa.WS[0])}if(E){var A=E["!comments"],C=!1,O="";if(A&&A.length>0){var M=!1;A.forEach(function(R){R[1].forEach(function(F){F.T==!0&&(M=!0)})}),M&&(O="xl/threadedComments/threadedComment"+u+"."+a,ka(i,O,bR(A,y,r)),n.threadedcomments.push(O),os(w,-1,"../threadedComments/threadedComment"+u+"."+a,Aa.TCMNT)),O="xl/comments"+u+"."+a,ka(i,O,FN(A)),n.comments.push(O),os(w,-1,"../comments"+u+"."+a,Aa.CMNT),C=!0}E["!legacy"]&&C&&ka(i,"xl/drawings/vmlDrawing"+u+".vml",RN(u,E["!comments"])),delete E["!comments"],delete E["!legacy"]}w["!id"].rId1&&ka(i,Of(c),H0(w))}return r.Strings!=null&&r.Strings.length>0&&(c="xl/sharedStrings."+a,ka(i,c,wN(r.Strings,r)),n.strs.push(c),os(r.wbrels,-1,"sharedStrings."+a,Aa.SST)),c="xl/workbook."+a,ka(i,c,KN(e)),n.workbooks.push(c),os(r.rels,1,c,Aa.WB),c="xl/theme/theme1.xml",ka(i,c,Uy(e.Themes,r)),n.themes.push(c),os(r.wbrels,-1,"theme/theme1.xml",Aa.THEME),c="xl/styles."+a,ka(i,c,TN(e,r)),n.styles.push(c),os(r.wbrels,-1,"styles."+a,Aa.STY),e.vbaraw&&s&&(c="xl/vbaProject.bin",ka(i,c,e.vbaraw),n.vba.push(c),os(r.wbrels,-1,"vbaProject.bin",Aa.VBA)),c="xl/metadata."+a,ka(i,c,DN()),n.metadata.push(c),os(r.wbrels,-1,"metadata."+a,Aa.XLMETA),y.length>1&&(c="xl/persons/person.xml",ka(i,c,wR(y)),n.people.push(c),os(r.wbrels,-1,"persons/person.xml",Aa.PEOPLE)),ka(i,"[Content_Types].xml",q3(n,r)),ka(i,"_rels/.rels",H0(r.rels)),ka(i,"xl/_rels/workbook."+a+".rels",H0(r.wbrels)),delete r.revssf,delete r.ssf,i}function Zy(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=ko(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 hB(e,r){return Zr.find(e,"EncryptedPackage")?cB(e,r):tj(e,r)}function mB(e,r){var a,s=e,n=r||{};return n.type||(n.type=Ca&&Buffer.isBuffer(e)?"buffer":"base64"),a=k3(s,n),lB(a,n)}function cj(e,r){var a=0;e:for(;a<e.length;)switch(e.charCodeAt(a)){case 10:case 13:case 32:++a;break;case 60:return D1(e.slice(a),r);default:break e}return q0.to_workbook(e,r)}function gB(e,r){var a="",s=Zy(e,r);switch(r.type){case"base64":a=ko(e);break;case"binary":a=e;break;case"buffer":a=e.toString("binary");break;case"array":a=Ld(e);break;default:throw new Error("Unrecognized type "+r.type)}return s[0]==239&&s[1]==187&&s[2]==191&&(a=ms(a)),r.type="binary",cj(a,r)}function xB(e,r){var a=e;return r.type=="base64"&&(a=ko(a)),a=jf.utils.decode(1200,a.slice(2),"str"),r.type="binary",cj(a,r)}function pB(e){return e.match(/[^\x00-\x7F]/)?Rl(e):e}function Qp(e,r,a,s){return s?(a.type="string",q0.to_workbook(e,a)):q0.to_workbook(r,a)}function Z0(e,r){gy();var a=r||{};if(typeof ArrayBuffer!="undefined"&&e instanceof ArrayBuffer)return Z0(new Uint8Array(e),(a=Es(a),a.type="array",a));typeof Uint8Array!="undefined"&&e instanceof Uint8Array&&!a.type&&(a.type=typeof Deno!="undefined"?"buffer":"array");var s=e,n=[0,0,0,0],i=!1;if(a.cellStyles&&(a.cellNF=!0,a.sheetStubs=!0),V0={},a.dateNF&&(V0.dateNF=a.dateNF),a.type||(a.type=Ca&&Buffer.isBuffer(e)?"buffer":"base64"),a.type=="file"&&(a.type=Ca?"buffer":"binary",s=uA(e),typeof Uint8Array!="undefined"&&!Ca&&(a.type="array")),a.type=="string"&&(i=!0,a.type="binary",a.codepage=65001,s=pB(e)),a.type=="array"&&typeof Uint8Array!="undefined"&&e instanceof Uint8Array&&typeof ArrayBuffer!="undefined"){var c=new ArrayBuffer(3),u=new Uint8Array(c);if(u.foo="bar",!u.foo)return a=Es(a),a.type="array",Z0(xy(s),a)}switch((n=Zy(s,a))[0]){case 208:if(n[1]===207&&n[2]===17&&n[3]===224&&n[4]===161&&n[5]===177&&n[6]===26&&n[7]===225)return hB(Zr.read(s,a),a);break;case 9:if(n[1]<=8)return tj(s,a);break;case 60:return D1(s,a);case 73:if(n[1]===73&&n[2]===42&&n[3]===0)throw new Error("TIFF Image File is not a spreadsheet");if(n[1]===68)return _O(s,a);break;case 84:if(n[1]===65&&n[2]===66&&n[3]===76)return bN.to_workbook(s,a);break;case 80:return n[1]===75&&n[2]<9&&n[3]<9?mB(s,a):Qp(e,s,a,i);case 239:return n[3]===60?D1(s,a):Qp(e,s,a,i);case 255:if(n[1]===254)return xB(s,a);if(n[1]===0&&n[2]===2&&n[3]===0)return Td.to_workbook(s,a);break;case 0:if(n[1]===0&&(n[2]>=2&&n[3]===0||n[2]===0&&(n[3]===8||n[3]===9)))return Td.to_workbook(s,a);break;case 3:case 131:case 139:case 140:return O1.to_workbook(s,a);case 123:if(n[1]===92&&n[2]===114&&n[3]===116)return SN.to_workbook(s,a);break;case 10:case 13:case 32:return gB(s,a);case 137:if(n[1]===80&&n[2]===78&&n[3]===71)throw new Error("PNG Image File is not a spreadsheet");break}return wO.indexOf(n[0])>-1&&n[2]<=12&&n[3]<=31?O1.to_workbook(s,a):Qp(e,s,a,i)}function dj(e,r){switch(r.type){case"base64":case"binary":break;case"buffer":case"array":r.type="";break;case"file":return $f(r.file,Zr.write(e,{type:Ca?"buffer":""}));case"string":throw new Error("'string' output type invalid for '"+r.bookType+"' files");default:throw new Error("Unrecognized type "+r.type)}return Zr.write(e,r)}function yB(e,r){var a=Es(r||{}),s=dB(e,a);return bB(s,a)}function bB(e,r){var a={},s=Ca?"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?Zr.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(pg(n))}return r.password&&typeof encrypt_agile!="undefined"?dj(encrypt_agile(n,r.password),r):r.type==="file"?$f(r.file,n):r.type=="string"?ms(n):n}function vB(e,r){var a=r||{},s=pL(e,a);return dj(s,a)}function Ol(e,r,a){a||(a="");var s=a+e;switch(r.type){case"base64":return Sf(Rl(s));case"binary":return Rl(s);case"string":return e;case"file":return $f(r.file,s,"utf8");case"buffer":return Ca?hc(s,"utf8"):typeof TextEncoder!="undefined"?new TextEncoder().encode(s):Ol(s,{type:"binary"}).split("").map(function(n){return n.charCodeAt(0)})}throw new Error("Unrecognized type "+r.type)}function wB(e,r){switch(r.type){case"base64":return Sf(e);case"binary":return e;case"string":return e;case"file":return $f(r.file,e,"binary");case"buffer":return Ca?hc(e,"binary"):e.split("").map(function(a){return a.charCodeAt(0)})}throw new Error("Unrecognized type "+r.type)}function xm(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"?Sf(a):r.type=="string"?ms(a):a;case"file":return $f(r.file,e);case"buffer":return e;default:throw new Error("Unrecognized type "+r.type)}}function Jf(e,r){gy(),hP(e);var a=Es(r||{});if(a.cellStyles&&(a.cellNF=!0,a.sheetStubs=!0),a.type=="array"){a.type="binary";var s=Jf(e,a);return a.type="array",pg(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 Ol(dL(e,a),a);case"slk":case"sylk":return Ol(yN.from_sheet(e.Sheets[e.SheetNames[n]],a),a);case"htm":case"html":return Ol(aj(e.Sheets[e.SheetNames[n]],a),a);case"txt":return wB(uj(e.Sheets[e.SheetNames[n]],a),a);case"csv":return Ol(Ky(e.Sheets[e.SheetNames[n]],a),a,"\uFEFF");case"dif":return Ol(bN.from_sheet(e.Sheets[e.SheetNames[n]],a),a);case"dbf":return xm(O1.from_sheet(e.Sheets[e.SheetNames[n]],a),a);case"prn":return Ol(q0.from_sheet(e.Sheets[e.SheetNames[n]],a),a);case"rtf":return Ol(SN.from_sheet(e.Sheets[e.SheetNames[n]],a),a);case"eth":return Ol(vN.from_sheet(e.Sheets[e.SheetNames[n]],a),a);case"fods":return Ol(oj(e,a),a);case"wk1":return xm(Td.sheet_to_wk1(e.Sheets[e.SheetNames[n]],a),a);case"wk3":return xm(Td.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),xm(rj(e,a),a);case"biff5":a.biff||(a.biff=5);case"biff8":case"xla":case"xls":return a.biff||(a.biff=8),vB(e,a);case"xlsx":case"xlsm":case"xlam":case"xlsb":case"numbers":case"ods":return yB(e,a);default:throw new Error("Unrecognized bookType |"+a.bookType+"|")}}function _B(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 jo(e,r,a){var s={};return s.type="file",s.file=r,_B(s),Jf(e,s)}function kB(e,r,a,s,n,i,c,u){var h=nn(a),g=u.defval,y=u.raw||!Object.prototype.hasOwnProperty.call(u,"raw"),w=!0,E=n===1?[]:{};if(n!==1)if(Object.defineProperty)try{Object.defineProperty(E,"__rowNum__",{value:a,enumerable:!1})}catch(O){E.__rowNum__=a}else E.__rowNum__=a;if(!c||e[a])for(var S=r.s.c;S<=r.e.c;++S){var A=c?e[a][S]:e[s[S]+h];if(A===void 0||A.t===void 0){if(g===void 0)continue;i[S]!=null&&(E[i[S]]=g);continue}var C=A.v;switch(A.t){case"z":if(C==null)break;continue;case"e":C=C==0?null:void 0;break;case"s":case"d":case"b":case"n":break;default:throw new Error("unrecognized type "+A.t)}if(i[S]!=null){if(C==null)if(A.t=="e"&&C===null)E[i[S]]=null;else if(g!==void 0)E[i[S]]=g;else if(y&&C===null)E[i[S]]=null;else continue;else E[i[S]]=y&&(A.t!=="n"||A.t==="n"&&u.rawNumbers!==!1)?C:uc(A,C,u);C!=null&&(w=!1)}}return{row:E,isempty:w}}function ng(e,r){if(e==null||e["!ref"]==null)return[];var a={t:"n",v:0},s=0,n=1,i=[],c=0,u="",h={s:{r:0,c:0},e:{r:0,c:0}},g=r||{},y=g.range!=null?g.range:e["!ref"];switch(g.header===1?s=1:g.header==="A"?s=2:Array.isArray(g.header)?s=3:g.header==null&&(s=0),typeof y){case"string":h=$a(y);break;case"number":h=$a(e["!ref"]),h.s.r=y;break;default:h=y}s>0&&(n=0);var w=nn(h.s.r),E=[],S=[],A=0,C=0,O=Array.isArray(e),M=h.s.r,R=0,F={};O&&!e[M]&&(e[M]=[]);var z=g.skipHidden&&e["!cols"]||[],W=g.skipHidden&&e["!rows"]||[];for(R=h.s.c;R<=h.e.c;++R)if(!(z[R]||{}).hidden)switch(E[R]=zs(R),a=O?e[M][R]:e[E[R]+w],s){case 1:i[R]=R-h.s.c;break;case 2:i[R]=E[R];break;case 3:i[R]=g.header[R-h.s.c];break;default:if(a==null&&(a={w:"__EMPTY",t:"s"}),u=c=uc(a,null,g),C=F[c]||0,!C)F[c]=1;else{do u=c+"_"+C++;while(F[u]);F[c]=C,F[u]=1}i[R]=u}for(M=h.s.r+n;M<=h.e.r;++M)if(!(W[M]||{}).hidden){var X=kB(e,h,M,E,s,i,O,g);(X.isempty===!1||(s===1?g.blankrows!==!1:g.blankrows))&&(S[A++]=X.row)}return S.length=A,S}var yk=/"/g;function NB(e,r,a,s,n,i,c,u){for(var h=!0,g=[],y="",w=nn(a),E=r.s.c;E<=r.e.c;++E)if(s[E]){var S=u.dense?(e[a]||[])[E]:e[s[E]+w];if(S==null)y="";else if(S.v!=null){h=!1,y=""+(u.rawNumbers&&S.t=="n"?S.v:uc(S,null,u));for(var A=0,C=0;A!==y.length;++A)if((C=y.charCodeAt(A))===n||C===i||C===34||u.forceQuotes){y='"'+y.replace(yk,'""')+'"';break}y=="ID"&&(y='"ID"')}else S.f!=null&&!S.F?(h=!1,y="="+S.f,y.indexOf(",")>=0&&(y='"'+y.replace(yk,'""')+'"')):y="";g.push(y)}return u.blankrows===!1&&h?null:g.join(c)}function Ky(e,r){var a=[],s=r==null?{}:r;if(e==null||e["!ref"]==null)return"";var n=$a(e["!ref"]),i=s.FS!==void 0?s.FS:",",c=i.charCodeAt(0),u=s.RS!==void 0?s.RS:`
`,h=u.charCodeAt(0),g=new RegExp((i=="|"?"\\|":i)+"+$"),y="",w=[];s.dense=Array.isArray(e);for(var E=s.skipHidden&&e["!cols"]||[],S=s.skipHidden&&e["!rows"]||[],A=n.s.c;A<=n.e.c;++A)(E[A]||{}).hidden||(w[A]=zs(A));for(var C=0,O=n.s.r;O<=n.e.r;++O)(S[O]||{}).hidden||(y=NB(e,n,O,w,c,h,i,s),y!=null&&(s.strip&&(y=y.replace(g,"")),(y||s.blankrows!==!1)&&a.push((C++?u:"")+y)));return delete s.dense,a.join("")}function uj(e,r){r||(r={}),r.FS=" ",r.RS=`
`;var a=Ky(e,r);return a}function jB(e){var r="",a,s="";if(e==null||e["!ref"]==null)return[];var n=$a(e["!ref"]),i="",c=[],u,h=[],g=Array.isArray(e);for(u=n.s.c;u<=n.e.c;++u)c[u]=zs(u);for(var y=n.s.r;y<=n.e.r;++y)for(i=nn(y),u=n.s.c;u<=n.e.c;++u)if(r=c[u]+i,a=g?(e[y]||[])[u]: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}}h[h.length]=r+"="+s}return h}function fj(e,r,a){var s=a||{},n=+!s.skipHeader,i=e||{},c=0,u=0;if(i&&s.origin!=null)if(typeof s.origin=="number")c=s.origin;else{var h=typeof s.origin=="string"?Ws(s.origin):s.origin;c=h.r,u=h.c}var g,y={s:{c:0,r:0},e:{c:u,r:c+r.length-1+n}};if(i["!ref"]){var w=$a(i["!ref"]);y.e.c=Math.max(y.e.c,w.e.c),y.e.r=Math.max(y.e.r,w.e.r),c==-1&&(c=w.e.r+1,y.e.r=c+r.length-1+n)}else c==-1&&(c=0,y.e.r=r.length-1+n);var E=s.header||[],S=0;r.forEach(function(C,O){Qs(C).forEach(function(M){(S=E.indexOf(M))==-1&&(E[S=E.length]=M);var R=C[M],F="z",z="",W=sa({c:u+S,r:c+O+n});g=Lf(i,W),R&&typeof R=="object"&&!(R instanceof Date)?i[W]=R:(typeof R=="number"?F="n":typeof R=="boolean"?F="b":typeof R=="string"?F="s":R instanceof Date?(F="d",s.cellDates||(F="n",R=Pn(R)),z=s.dateNF||aa[14]):R===null&&s.nullError&&(F="e",R=0),g?(g.t=F,g.v=R,delete g.w,delete g.R,z&&(g.z=z)):i[W]=g={t:F,v:R},z&&(g.z=z))})}),y.e.c=Math.max(y.e.c,u+E.length-1);var A=nn(c);if(n)for(S=0;S<E.length;++S)i[zs(S+u)+A]={t:"s",v:E[S]};return i["!ref"]=ba(y),i}function SB(e,r){return fj(null,e,r)}function Lf(e,r,a){if(typeof r=="string"){if(Array.isArray(e)){var s=Ws(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"?Lf(e,sa(r)):Lf(e,sa({r,c:a||0}))}function CB(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 Jy(){return{SheetNames:[],Sheets:{}}}function Qy(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 c=i&&i[1]||a;for(++n;n<=65535&&e.SheetNames.indexOf(a=c+n)!=-1;++n);}if(ZN(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 EB(e,r,a){e.Workbook||(e.Workbook={}),e.Workbook.Sheets||(e.Workbook.Sheets=[]);var s=CB(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 TB(e,r){return e.z=r,e}function hj(e,r,a){return r?(e.l={Target:r},a&&(e.l.Tooltip=a)):delete e.l,e}function AB(e,r,a){return hj(e,"#"+r,a)}function OB(e,r,a){e.c||(e.c=[]),e.c.push({t:r,a:a||"SheetJS"})}function DB(e,r,a,s){for(var n=typeof r!="string"?r:$a(r),i=typeof r=="string"?r:ba(r),c=n.s.r;c<=n.e.r;++c)for(var u=n.s.c;u<=n.e.c;++u){var h=Lf(e,c,u);h.t="n",h.F=i,delete h.v,c==n.s.r&&u==n.s.c&&(h.f=a,s&&(h.D=!0))}return e}var Ur={encode_col:zs,encode_row:nn,encode_cell:sa,encode_range:ba,decode_col:Ey,decode_row:Cy,split_cell:HA,decode_cell:Ws,decode_range:no,format_cell:uc,sheet_add_aoa:z3,sheet_add_json:fj,sheet_add_dom:sj,aoa_to_sheet:su,json_to_sheet:SB,table_to_sheet:nj,table_to_book:BL,sheet_to_csv:Ky,sheet_to_txt:uj,sheet_to_json:ng,sheet_to_html:aj,sheet_to_formulae:jB,sheet_to_row_object_array:ng,sheet_get_cell:Lf,book_new:Jy,book_append_sheet:Qy,book_set_sheet_visibility:EB,cell_set_number_format:TB,cell_set_hyperlink:hj,cell_set_internal_link:AB,cell_add_comment:OB,sheet_set_array_formula:DB,consts:{SHEET_VISIBLE:0,SHEET_HIDDEN:1,SHEET_VERY_HIDDEN:2}};const RB=({isOpen:e,onClose:r,permittedIssueTypes:a=[],isAdmin:s=!0,defaultWorkOrderType:n="",defaultFromDate:i="",defaultToDate:c=""})=>{const{t:u}=Rr(),[h,g]=_.useState(!1),[y,w]=_.useState(null),[E,S]=_.useState([]),[A,C]=_.useState([]),[O,M]=_.useState(!0),[R,F]=_.useState(i),[z,W]=_.useState(c),[X,B]=_.useState(""),[Y,G]=_.useState(!1),[ie,fe]=_.useState([]);_.useEffect(()=>{if(!s)return;me(null,null,function*(){try{const oe=yield(yield fetch('/api/resource/Issue Type?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"})).json();oe.data&&fe(oe.data.map(le=>le.name))}catch(ae){console.error("Error fetching issue types:",ae)}})},[s]),_.useEffect(()=>{F(i)},[i]),_.useEffect(()=>{W(c)},[c]),_.useEffect(()=>{!s&&a.length===1?B(a[0]):B(n||"")},[a,s,n]);const K="Technicians working Hours",ke=_.useCallback(()=>me(null,null,function*(){g(!0),w(null);try{const J={};R&&(J.from_date=R),z&&(J.to_date=z),X?J.work_order_type=X:!s&&a.length>0&&a.length===1&&(J.work_order_type=a[0]);const oe=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:K,filters:J,ignore_prepared_report:1})})).json();if(oe.exc)throw new Error(oe.exc);if(oe.message)if(oe.message.columns&&oe.message.columns.length>0&&C(oe.message.columns),oe.message.result){let le=oe.message.result;!s&&a.length>1&&!X&&(le=le.filter(be=>a.includes(be.work_order_type))),S(le)}else S([])}catch(J){console.error("Error fetching report:",J),w(J instanceof Error?J.message:"Failed to fetch report data"),S([])}finally{g(!1)}}),[R,z,X,s,a]);_.useEffect(()=>{e&&ke()},[e,ke]),_.useEffect(()=>{const J=ae=>{ae.key==="Escape"&&e&&r()};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},[e,r]),_.useEffect(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="unset",()=>{document.body.style.overflow="unset"}),[e]);const ge=()=>{F(""),W(""),s&&B("")},re=()=>{const J=E.length,ae=E.reduce((le,be)=>le+(parseFloat(be.total_hours)||0),0),oe=J>0?ae/J:0;return{totalTechnicians:J,totalHours:ae,avgHours:oe}},we=()=>{if(E.length!==0){G(!0);try{const ae=[A.map(Z=>Z.label).join(","),...E.map(Z=>A.map(Le=>{let Pe=Z[Le.fieldname]||"";return typeof Pe=="string"&&(Pe.includes(",")||Pe.includes('"')||Pe.includes(`
`))&&(Pe=`"${Pe.replace(/"/g,'""')}"`),Pe}).join(","))].join(`
`),oe=new Blob(["\uFEFF"+ae],{type:"text/csv;charset=utf-8;"}),le=URL.createObjectURL(oe),be=document.createElement("a");be.href=le,be.download=`technician_working_hours_${new Date().toISOString().split("T")[0]}.csv`,be.click(),URL.revokeObjectURL(le)}finally{G(!1)}}},ee=()=>{if(E.length!==0){G(!0);try{const ae=[A.map(Z=>Z.label),...E.map(Z=>A.map(Le=>Z[Le.fieldname]||""))],oe=Ur.aoa_to_sheet(ae),le=A.map(Z=>({wch:Z.width?Math.floor(Z.width/7):20}));oe["!cols"]=le;const be=Ur.book_new();Ur.book_append_sheet(be,oe,"Technician Hours"),jo(be,`technician_working_hours_${new Date().toISOString().split("T")[0]}.xlsx`)}finally{G(!1)}}},ve=()=>{const J=re(),ae=window.open("","_blank");if(!ae){alert("Please allow popups for this site to print the report.");return}const oe=`
<!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; }
.hours-cell { font-weight: 600; color: #0891B2; }
@media print { body { margin: 0; } tr { page-break-inside: avoid; } }
</style>
</head>
<body>
<h1>Technicians Working Hours Report</h1>
<div class="meta">
Generated on: ${new Date().toLocaleString()}
${R?` | From: ${R}`:""}
${z?` | To: ${z}`:""}
${X?` | Department: ${X}`:""}
</div>
<div class="summary">
<div class="summary-item">
<div class="summary-label">Total Technicians</div>
<div class="summary-value">${J.totalTechnicians}</div>
</div>
<div class="summary-item">
<div class="summary-label">Total Hours</div>
<div class="summary-value hours">${J.totalHours.toFixed(2)}</div>
</div>
<div class="summary-item">
<div class="summary-label">Average Hours</div>
<div class="summary-value hours">${J.avgHours.toFixed(2)}</div>
</div>
</div>
<table>
<thead>
<tr>
<th>#</th>
${A.map(le=>`<th>${le.label}</th>`).join("")}
</tr>
</thead>
<tbody>
${E.map((le,be)=>`
<tr>
<td>${be+1}</td>
${A.map(Z=>{let Le=le[Z.fieldname]||"-";return`<td class="${Z.fieldname==="total_hours"?"hours-cell":""}">${Le}</td>`}).join("")}
</tr>
`).join("")}
</tbody>
</table>
<script>window.onload = function() { window.print(); }<\/script>
</body>
</html>
`;ae.document.write(oe),ae.document.close()},ce=()=>{ve()},ye=(J,ae)=>{if(J==null||J==="")return"-";switch(ae.fieldtype){case"Float":return typeof J=="number"?J.toFixed(2):J;case"Date":return new Date(J).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});case"Datetime":return new Date(J).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});default:return String(J)}};if(!e)return null;const te=re(),q=!!(R||z||X);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(Kn,{size:18})}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Ja,{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:[E.length," technician",E.length!==1?"s":""," found"]})]})]})]}),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(Pt,{size:20})})]})}),!h&&E.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(Sd,{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:te.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(Ja,{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:te.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(o_,{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:te.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:()=>M(!O),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(Hs,{size:12}),"Filters",q&&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:[R,z,X].filter(Boolean).length}),O?t.jsx(Mn,{size:10}):t.jsx(on,{size:10})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:ke,disabled:h,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(Ui,{className:h?"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:we,disabled:E.length===0||Y,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",children:[t.jsx(No,{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:ee,disabled:E.length===0||Y,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",children:[t.jsx(zi,{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:ce,disabled:E.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",children:[t.jsx(Hf,{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:ve,disabled:E.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",children:[t.jsx(Go,{className:"text-purple-600",size:14}),t.jsx("span",{children:"Print"})]})]})]})]}),O&&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:R,onChange:J=>F(J.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:z,onChange:J=>W(J.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"}),X,t.jsx("span",{className:"ml-auto text-[10px] text-gray-400 dark:text-gray-500 uppercase",children:"Restricted"})]}):t.jsxs("select",{value:X,onChange:J=>B(J.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?ie:a).map(J=>t.jsx("option",{value:J,children:J},J))]})]}),t.jsx("div",{className:"flex items-end",children:t.jsxs("button",{onClick:ge,disabled:!q,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(Pt,{size:12}),"Clear Filters"]})})]})})]}),t.jsxs("div",{className:"flex-1 overflow-auto p-6",children:[h&&t.jsx("div",{className:"flex items-center justify-center py-20",children:t.jsxs("div",{className:"text-center",children:[t.jsx(Ir,{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..."})]})}),y&&!h&&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:y}),t.jsx("button",{onClick:ke,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"})]}),!h&&!y&&E.length===0&&t.jsxs("div",{className:"text-center py-20",children:[t.jsx(In,{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"})]}),!h&&!y&&E.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:"#"}),A.map((J,ae)=>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:J.width||150},children:J.label},ae))]})}),t.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:E.map((J,ae)=>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:ae+1}),A.map((oe,le)=>{const be=J[oe.fieldname],Z=ye(be,oe);return oe.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(Ja,{size:12}),Z," hrs"]})},le):oe.fieldname==="engineer"&&be?t.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:t.jsx("a",{href:`/app/user/${be}`,target:"_blank",rel:"noopener noreferrer",className:"text-cyan-600 dark:text-cyan-400 hover:underline font-medium text-sm",children:Z})},le):oe.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(o_,{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:Z})]})},le):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:Z})},le)})]},ae))})]})})})]}),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 ",E.length," technician",E.length!==1?"s":"",q&&" (filtered)",te.totalHours>0&&t.jsxs("span",{className:"ml-2 text-cyan-600 dark:text-cyan-400",children:["• Total: ",te.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"})]})})]})},FB=({isOpen:e,onClose:r,permittedIssueTypes:a=[],isAdmin:s=!0,defaultWorkOrderType:n="",defaultFromDate:i="",defaultToDate:c=""})=>{const{t:u}=Rr(),[h,g]=_.useState(!1),[y,w]=_.useState(null),[E,S]=_.useState([]),[A,C]=_.useState([]),[O,M]=_.useState(!1),[R,F]=_.useState(i),[z,W]=_.useState(c),[X,B]=_.useState(""),[Y,G]=_.useState(!1),[ie,fe]=_.useState([]);_.useEffect(()=>{if(!s)return;me(null,null,function*(){try{const oe=yield(yield fetch('/api/resource/Issue Type?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"})).json();oe.data&&fe(oe.data.map(le=>le.name))}catch(ae){console.error("Error fetching issue types:",ae)}})},[s]),_.useEffect(()=>{F(i)},[i]),_.useEffect(()=>{W(c)},[c]),_.useEffect(()=>{!s&&a.length===1?B(a[0]):B(n||"")},[a,s,n]);const K="Technician Work Order Summary",ke=_.useCallback(()=>me(null,null,function*(){g(!0),w(null);try{const J={};R&&(J.from_date=R),z&&(J.to_date=z),X?J.work_order_type=X:!s&&a.length===1&&(J.work_order_type=a[0]);const oe=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:K,filters:J,ignore_prepared_report:1})})).json();if(oe.exc)throw new Error(oe.exc);if(oe.message)if(oe.message.columns&&oe.message.columns.length>0&&C(oe.message.columns),oe.message.result){let le=oe.message.result;!s&&a.length>1&&!X&&(le=le.filter(be=>a.includes(be.work_order_type))),S(le)}else S([])}catch(J){console.error("Error fetching report:",J),w(J instanceof Error?J.message:"Failed to fetch report data"),S([])}finally{g(!1)}}),[R,z,X,s,a]);_.useEffect(()=>{e&&ke()},[e,ke]),_.useEffect(()=>{const J=ae=>{ae.key==="Escape"&&e&&r()};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},[e,r]),_.useEffect(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="unset",()=>{document.body.style.overflow="unset"}),[e]);const ge=()=>{F(""),W(""),s&&B("")},re=()=>{const J=E.length,ae=E.reduce((Le,Pe)=>Le+(parseInt(Pe.total)||0),0),oe=E.reduce((Le,Pe)=>Le+(parseInt(Pe.completed)||0),0),le=E.reduce((Le,Pe)=>Le+(parseInt(Pe.in_progress)||0),0),be=E.reduce((Le,Pe)=>Le+(parseInt(Pe.open)||0),0),Z=ae>0?(oe/ae*100).toFixed(1):"0";return{totalTechnicians:J,totalWorkOrders:ae,totalCompleted:oe,totalInProgress:le,totalOpen:be,completionRate:Z}},we=()=>{if(E.length!==0){G(!0);try{const ae=[A.map(Z=>Z.label).join(","),...E.map(Z=>A.map(Le=>{let Pe=Z[Le.fieldname]||"";return typeof Pe=="string"&&(Pe.includes(",")||Pe.includes('"')||Pe.includes(`
`))&&(Pe=`"${Pe.replace(/"/g,'""')}"`),Pe}).join(","))].join(`
`),oe=new Blob(["\uFEFF"+ae],{type:"text/csv;charset=utf-8;"}),le=URL.createObjectURL(oe),be=document.createElement("a");be.href=le,be.download=`technician_work_order_summary_${new Date().toISOString().split("T")[0]}.csv`,be.click(),URL.revokeObjectURL(le)}finally{G(!1)}}},ee=()=>{if(E.length!==0){G(!0);try{const ae=[A.map(Z=>Z.label),...E.map(Z=>A.map(Le=>Z[Le.fieldname]||""))],oe=Ur.aoa_to_sheet(ae),le=A.map(Z=>({wch:Z.width?Math.floor(Z.width/7):20}));oe["!cols"]=le;const be=Ur.book_new();Ur.book_append_sheet(be,oe,"Work Order Summary"),jo(be,`technician_work_order_summary_${new Date().toISOString().split("T")[0]}.xlsx`)}finally{G(!1)}}},ve=()=>{const J=re(),ae=window.open("","_blank");if(!ae){alert("Please allow popups for this site to print the report.");return}const oe=`
<!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; }
.count-cell { font-weight: 600; text-align: center; }
.completed { color: #10B981; }
.in-progress { color: #3B82F6; }
.open { color: #F59E0B; }
@media print { body { margin: 0; } tr { page-break-inside: avoid; } }
</style>
</head>
<body>
<h1>Technician Work Order Summary Report</h1>
<div class="meta">
Generated on: ${new Date().toLocaleString()}
${R?` | From: ${R}`:""}
${z?` | To: ${z}`:""}
${X?` | Department: ${X}`:""}
</div>
<div class="summary">
<div class="summary-item"><div class="summary-label">Total Technicians</div><div class="summary-value">${J.totalTechnicians}</div></div>
<div class="summary-item"><div class="summary-label">Total Work Orders</div><div class="summary-value">${J.totalWorkOrders}</div></div>
<div class="summary-item"><div class="summary-label">Completed</div><div class="summary-value completed">${J.totalCompleted}</div></div>
<div class="summary-item"><div class="summary-label">In Progress</div><div class="summary-value in-progress">${J.totalInProgress}</div></div>
<div class="summary-item"><div class="summary-label">Open</div><div class="summary-value open">${J.totalOpen}</div></div>
<div class="summary-item"><div class="summary-label">Completion Rate</div><div class="summary-value completed">${J.completionRate}%</div></div>
</div>
<table>
<thead>
<tr><th>#</th>${A.map(le=>`<th>${le.label}</th>`).join("")}</tr>
</thead>
<tbody>
${E.map((le,be)=>`
<tr>
<td>${be+1}</td>
${A.map(Z=>{let Le=le[Z.fieldname]||"-",Pe="";return Z.fieldname==="completed"?Pe="count-cell completed":Z.fieldname==="in_progress"?Pe="count-cell in-progress":Z.fieldname==="open"?Pe="count-cell open":Z.fieldname==="total"&&(Pe="count-cell"),`<td class="${Pe}">${Le}</td>`}).join("")}
</tr>
`).join("")}
</tbody>
</table>
<script>window.onload = function() { window.print(); }<\/script>
</body>
</html>
`;ae.document.write(oe),ae.document.close()},ce=()=>{ve()},ye=(J,ae)=>{if(J==null||J==="")return"-";switch(ae.fieldtype){case"Int":return parseInt(J)||0;case"Float":return typeof J=="number"?J.toFixed(2):J;default:return String(J)}};if(!e)return null;const te=re(),q=!!(R||z||X);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(Kn,{size:18})}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Vm,{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:[E.length," technician",E.length!==1?"s":""," found",X&&t.jsx("span",{className:"ml-2 bg-white/20 px-2 py-0.5 rounded-full text-xs",children:X})]})]})]})]}),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(Pt,{size:20})})]})}),!h&&E.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(Sd,{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:()=>M(!O),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(Hs,{size:12}),"Filters",q&&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:[R,z,X].filter(Boolean).length}),O?t.jsx(Mn,{size:10}):t.jsx(on,{size:10})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:ke,disabled:h,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(Ui,{className:h?"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:we,disabled:E.length===0||Y,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",children:[t.jsx(No,{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:ee,disabled:E.length===0||Y,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",children:[t.jsx(zi,{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:ce,disabled:E.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",children:[t.jsx(Hf,{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:ve,disabled:E.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",children:[t.jsx(Go,{className:"text-purple-600",size:14}),t.jsx("span",{children:"Print"})]})]})]})]}),O&&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:R,onChange:J=>F(J.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"})]}),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:z,onChange:J=>W(J.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"})]}),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"}),X,t.jsx("span",{className:"ml-auto text-[10px] text-gray-400 dark:text-gray-500 uppercase tracking-wide",children:"Restricted"})]}):t.jsxs("select",{value:X,onChange:J=>B(J.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?ie:a).map(J=>t.jsx("option",{value:J,children:J},J))]})]}),t.jsx("div",{className:"flex items-end",children:t.jsxs("button",{onClick:ge,disabled:!q,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(Pt,{size:12}),"Clear Filters"]})})]})})]}),t.jsxs("div",{className:"flex-1 overflow-auto p-6",children:[h&&t.jsx("div",{className:"flex items-center justify-center py-20",children:t.jsxs("div",{className:"text-center",children:[t.jsx(Ir,{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..."})]})}),y&&!h&&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:y}),t.jsx("button",{onClick:ke,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"})]}),!h&&!y&&E.length===0&&t.jsxs("div",{className:"text-center py-20",children:[t.jsx(In,{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."})]}),!h&&!y&&E.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:"#"}),A.map((J,ae)=>t.jsx("th",{className:`px-4 py-3 text-xs font-semibold text-gray-600 dark:text-gray-300 uppercase tracking-wider whitespace-nowrap ${J.fieldtype==="Int"?"text-center":"text-left"}`,style:{minWidth:J.width||120},children:J.label},ae))]})}),t.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:E.map((J,ae)=>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:ae+1}),A.map((oe,le)=>{const be=J[oe.fieldname],Z=ye(be,oe);return oe.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(Vm,{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:Z})]})},le):oe.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:Z})},le):oe.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:Z})},le):oe.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:Z})},le):oe.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:Z})},le):t.jsx("td",{className:"px-4 py-3 text-sm text-gray-700 dark:text-gray-300",children:Z},le)})]},ae))})]})})})]}),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 ",E.length," technician",E.length!==1?"s":"",X&&t.jsxs("span",{className:"ml-2 text-purple-600 dark:text-purple-400",children:["· ",X]}),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"})]})})]})},pm="Civil works-الأعمال المدنية",e1=["total_wo","not_assigned","pending_with_contractor","completed_by_contractor","pending_with_moh","total_completed","urgent_total","urgent_completed","urgent_pending_review","contractor_completion_rate","completion_rate"],IB=({kpiMonthlyChartData:e,dashFromDate:r,chartElement:a,onOpenDetail:s})=>{var c;const{t:n}=Rr(),i=()=>me(null,null,function*(){var kt;if(!((kt=e==null?void 0:e.labels)!=null&&kt.length))return;const u=["JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"],h=r?new Date(r+"T00:00:00"):new Date,g=`${u[h.getMonth()]}-${h.getFullYear()}`,y=e.allDatasets||e.datasets||[],w=e.labels,E={total_wo:["Total WO","Total WOs","total_wo","total_wos"],not_assigned:["Not Assigned","not_assigned"],pending_with_contractor:["Pending with Contractor","pending_with_contractor"],completed_by_contractor:["Total Completed by Contractor","Completed by Contractor","completed_by_contractor"],pending_with_moh:["Total Pending with MOH","Pending with MOH","pending_with_moh"],total_completed:["Total Completed","total_completed"],urgent_total:["Urgent","Urgent Total","urgent_total"],urgent_completed:["Completed","Urgent Completed","urgent_completed"],urgent_pending_review:["Pending","Urgent Pending Review","urgent_pending_review"],contractor_completion_rate:["Contractor Completion Rate (%)","contractor_completion_rate","Total WO Completion Rate %"],completion_rate:["Total Completion Rate (%)","completion_rate","Urgent WO Completion Rate %","Urgent Completion Rate (%)"]},S=(ze,nt)=>{var _t;for(const lr of E[ze]||[ze]){const pr=y.find(Nr=>Nr.name===lr);if(((_t=pr==null?void 0:pr.values)==null?void 0:_t[nt])!==void 0)return Number(pr.values[nt])||0}return 0},A=new Set(["CARPENTARY","MASONRY","PAINTING","PLUMPING"]),C=[];let O=null;w.forEach((ze,nt)=>{A.has(ze)&&C.push(nt),ze===pm&&(O=nt)});const M=new Set(C),R={};O!==null?e1.forEach(ze=>{R[ze]=S(ze,O)}):e1.forEach(ze=>{R[ze]=C.reduce((nt,_t)=>nt+S(ze,_t),0)}),R.total_wo>0&&(R.contractor_completion_rate=parseFloat((R.completed_by_contractor/R.total_wo*100).toFixed(1)),R.completion_rate=parseFloat((R.total_completed/R.total_wo*100).toFixed(1)));const F=R.urgent_total>0?parseFloat((R.urgent_completed/R.urgent_total*100).toFixed(1)):0,z={};e1.forEach(ze=>{var _t;const nt=C.reduce((lr,pr)=>lr+S(ze,pr),0);z[ze]=Math.max(0,((_t=R[ze])!=null?_t:0)-nt)}),z.total_wo>0&&(z.contractor_completion_rate=parseFloat((z.completed_by_contractor/z.total_wo*100).toFixed(1)),z.completion_rate=parseFloat((z.total_completed/z.total_wo*100).toFixed(1)));const W=z.urgent_total>0?parseFloat((z.urgent_completed/z.urgent_total*100).toFixed(1)):0,X=ze=>{var nt;return w.reduce((_t,lr,pr)=>lr===pm?_t:_t+S(ze,pr),0)+((nt=z[ze])!=null?nt:0)},B=[];C.forEach(ze=>{B.push({label:w[ze],dataIdx:ze,isCivilSub:!0})}),B.push({label:"None",dataIdx:null,isCivilSub:!0,isNone:!0}),B.push({label:pm,dataIdx:null,isCivilParent:!0});const Y=["Electrical","HVAC","Mechanical","Medical Gas","Electronics","Electronic"],G=[];w.forEach((ze,nt)=>{M.has(nt)||ze!==pm&&G.push({label:ze,dataIdx:nt})}),G.sort((ze,nt)=>{const _t=Y.findIndex(pr=>ze.label.toLowerCase().includes(pr.toLowerCase())),lr=Y.findIndex(pr=>nt.label.toLowerCase().includes(pr.toLowerCase()));return(_t===-1?999:_t)-(lr===-1?999:lr)}),G.forEach(ze=>B.push({label:ze.label,dataIdx:ze.dataIdx}));const ie=yield new Promise(ze=>{const nt=document.createElement("canvas");nt.width=900,nt.height=400;const _t=nt.getContext("2d");_t.fillStyle="#FFFFFF",_t.fillRect(0,0,nt.width,nt.height);const lr=B.map(Re=>Re.label),pr=[{label:"Total WO",color:"#4472C4",values:B.map(Re=>{var Q,he;return Re.isCivilParent?(Q=R.total_wo)!=null?Q:0:Re.isNone?(he=z.total_wo)!=null?he:0:Re.dataIdx===null?0:S("total_wo",Re.dataIdx)})},{label:"Completed",color:"#70AD47",values:B.map(Re=>{var Q,he;return Re.isCivilParent?(Q=R.total_completed)!=null?Q:0:Re.isNone?(he=z.total_completed)!=null?he:0:Re.dataIdx===null?0:S("total_completed",Re.dataIdx)})},{label:"Pending",color:"#ED7D31",values:B.map(Re=>{var Q,he;return Re.isCivilParent?(Q=R.pending_with_contractor)!=null?Q:0:Re.isNone?(he=z.pending_with_contractor)!=null?he:0:Re.dataIdx===null?0:S("pending_with_contractor",Re.dataIdx)})}],Nr=60,rr=20,_r=40,Nt=80,Cr=nt.width-Nr-rr,yr=nt.height-_r-Nt,jt=pr.flatMap(Re=>Re.values),Tt=Math.max(...jt,1),He=B.length,Fe=Cr/He,Ze=pr.length,vt=Math.min(Fe*.22,28),ir=(Fe-vt*Ze)/2;_t.strokeStyle="#E0E0E0",_t.lineWidth=1;for(let Re=0;Re<=5;Re++){const Q=_r+yr-Re/5*yr;_t.beginPath(),_t.moveTo(Nr,Q),_t.lineTo(Nr+Cr,Q),_t.stroke(),_t.fillStyle="#666666",_t.font="11px Arial",_t.textAlign="right",_t.fillText(Math.round(Tt*Re/5).toString(),Nr-6,Q+4)}pr.forEach((Re,Q)=>{Re.values.forEach((he,Se)=>{const ne=he/Tt*yr,_e=Nr+Se*Fe+ir+Q*vt,Ce=_r+yr-ne;_t.fillStyle=Re.color,_t.fillRect(_e,Ce,vt-2,ne),ne>16&&(_t.fillStyle="#333333",_t.font="9px Arial",_t.textAlign="center",_t.fillText(he.toString(),_e+(vt-2)/2,Ce-3))})}),_t.fillStyle="#333333",_t.font="10px Arial",_t.textAlign="center",lr.forEach((Re,Q)=>{const he=Nr+Q*Fe+Fe/2,Se=_r+yr+14,ne=Re.length>12?Re.substring(0,11)+"…":Re;_t.fillText(ne,he,Se)});const fr=nt.height-20;let Kt=Nr;pr.forEach(Re=>{_t.fillStyle=Re.color,_t.fillRect(Kt,fr-10,14,14),_t.fillStyle="#333333",_t.font="11px Arial",_t.textAlign="left",_t.fillText(Re.label,Kt+18,fr+2),Kt+=_t.measureText(Re.label).width+40}),_t.fillStyle="#1F4E79",_t.font="bold 13px Arial",_t.textAlign="center",_t.fillText(`KPI REPORT FOR THE MONTH OF ${g}`,nt.width/2,22),ze(nt.toDataURL("image/png").split(",")[1])});let fe=null;const K="png";try{const ze="/assets/asm_ui_app/asm_app/",nt=`${ze}${ze.endsWith("/")?"":"/"}kfsh-logo.png`,_t=yield fetch(nt);if(_t.ok){const lr=yield _t.arrayBuffer();fe=btoa(String.fromCharCode(...new Uint8Array(lr)))}}catch(ze){console.warn("Could not load hospital logo:",ze)}const ke=(yield Nd(()=>me(null,null,function*(){const{default:ze}=yield import("./exceljs.min-D41JvsuX.js").then(nt=>nt.e);return{default:ze}}),[])).default,ge=new ke.Workbook,re=ge.addWorksheet("KPI Monthly Report");re.columns=[{width:36},{width:10},{width:18},{width:20},{width:20},{width:14},{width:16},{width:10},{width:13},{width:11},{width:18},{width:18},{width:18}];const we=ze=>({type:"pattern",pattern:"solid",fgColor:{argb:"FF"+ze.replace("#","")}}),ee=(ze=!1,nt=10,_t="000000")=>({name:"Arial",bold:ze,size:nt,color:{argb:"FF"+_t}}),ve=()=>({top:{style:"thin",color:{argb:"FF000000"}},bottom:{style:"thin",color:{argb:"FF000000"}},left:{style:"thin",color:{argb:"FF000000"}},right:{style:"thin",color:{argb:"FF000000"}}}),ce=(ze="center",nt=!0)=>({horizontal:ze,vertical:"middle",wrapText:nt}),ye=(ze,nt)=>{var _t,lr,pr,Nr;ze.font=ee(nt.bold,(_t=nt.size)!=null?_t:10,(lr=nt.color)!=null?lr:"000000"),ze.alignment=ce((pr=nt.h)!=null?pr:"center",(Nr=nt.wrap)!=null?Nr:!0),nt.bg&&(ze.fill=we(nt.bg)),nt.brd!==!1&&(ze.border=ve())},te="1F4E79",q="7030A0",J="00B050",ae="DCE6F1",oe="E2EFDA",le="F2FAF0",be="BDD7EE";if(re.getRow(1).height=55,fe){const ze=ge.addImage({base64:fe,extension:K});re.addImage(ze,{tl:{col:0,row:0},br:{col:3,row:1},editAs:"oneCell"}),re.mergeCells("D1:K1");const nt=re.getCell("D1");nt.value="King Fahad Specialist Hospital",ye(nt,{bold:!0,size:13,h:"center",brd:!1}),re.mergeCells("L1:M1");const _t=re.getCell("L1");_t.value="TARGET :95%",ye(_t,{bold:!0,size:12,color:"FF0000",bg:"FFE699",h:"center",brd:!0})}else{re.mergeCells("A1:K1");const ze=re.getCell("A1");ze.value="King Fahad Specialist Hospital",ye(ze,{bold:!0,size:13,h:"center",brd:!1}),re.mergeCells("L1:M1");const nt=re.getCell("L1");nt.value="TARGET :95%",ye(nt,{bold:!0,size:12,color:"FF0000",bg:"FFE699",h:"center",brd:!0})}re.mergeCells("A2:M2");const Z=re.getCell("A2");Z.value=`CORRECTIVE MONTHLY KPI REPORT (INT / EXT) ${g}`,ye(Z,{bold:!0,size:12,color:"FFFFFF",bg:J,h:"center"}),re.getRow(2).height=26;const Le=[["A3","A4"],["B3","B4"],["C3","C4"],["D3","D4"],["E3","E4"],["F3","F4"],["G3","G4"],["K3","K4"],["L3","L4"],["M3","M4"]],Pe=["DEPARTMENT","TOTAL WO","Not Assigned",`Pending with contractor
(WO on Progress)`,`TOTAL COMPLETED
by Contractor`,`PENDING
with MOH`,"TOTAL COMPLETED",`Contractor
Completion Rate %`,`TOTAL WO
Completion Rate %`,`URGENT WO
Completion Rate %`];Le.forEach(([ze,nt],_t)=>{re.mergeCells(`${ze}:${nt}`);const lr=re.getCell(ze);lr.value=Pe[_t],ye(lr,{bold:!0,size:9,color:"FFFFFF",bg:te})}),re.mergeCells("H3:J3");const Be=re.getCell("H3");Be.value="PRIORITY",ye(Be,{bold:!0,size:10,color:"FFFFFF",bg:q}),re.getRow(3).height=42,[["H4","URGENT"],["I4","COMPLETED"],["J4","PENDING"]].forEach(([ze,nt])=>{const _t=re.getCell(ze);_t.value=nt,ye(_t,{bold:!0,size:9,color:"FFFFFF",bg:q})}),re.getRow(4).height=18;const pe="1F4E79",rt="D6E4F0",ct="EBF2F9",et=5;B.forEach((ze,nt)=>{const _t=et+nt,lr=nt%2===1,pr=lr?ae:"FFFFFF",Nr=lr?oe:le,rr=re.getRow(_t);rr.height=ze.isCivilSub?16:18;const _r=Tt=>{var He,Fe;return ze.isCivilParent?(He=R[Tt])!=null?He:0:ze.isNone?(Fe=z[Tt])!=null?Fe:0:ze.dataIdx===null?0:S(Tt,ze.dataIdx)},Nt=_r("urgent_total"),Cr=_r("urgent_completed"),yr=ze.isCivilParent?F:ze.isNone?W:Nt>0?parseFloat((Cr/Nt*100).toFixed(1)):0;[ze.isCivilSub?` ${ze.label}`:ze.label,_r("total_wo"),_r("not_assigned"),_r("pending_with_contractor"),_r("completed_by_contractor"),_r("pending_with_moh"),_r("total_completed"),_r("urgent_total"),_r("urgent_completed"),_r("urgent_pending_review"),_r("contractor_completion_rate")>0?`${_r("contractor_completion_rate").toFixed(1)}%`:"-",_r("completion_rate")>0?`${_r("completion_rate").toFixed(1)}%`:"-",yr>0?`${yr.toFixed(1)}%`:"-"].forEach((Tt,He)=>{const Fe=rr.getCell(He+1);Fe.value=Tt;let Ze;ze.isCivilParent?Ze=He>=7&&He<=9?q:pe:ze.isCivilSub?Ze=He>=7&&He<=9?Nr:lr?ct:rt:Ze=He>=7&&He<=9?Nr:pr,ye(Fe,{bold:ze.isCivilParent||He===0,size:ze.isCivilSub?9:10,color:ze.isCivilParent?"FFFFFF":"000000",bg:Ze,h:He===0?"left":"center"})})});const It=et+B.length,ft=re.getRow(It);ft.height=22;const Lt=X("total_wo"),Je=X("total_completed"),Ve=X("urgent_total"),Xe=X("urgent_completed"),Rt=Lt>0?`${(X("completed_by_contractor")/Lt*100).toFixed(1)}%`:"-",qe=Lt>0?`${(Je/Lt*100).toFixed(1)}%`:"-",Dt=Ve>0?`${(Xe/Ve*100).toFixed(1)}%`:"-";["GRAND TOTAL",Lt,X("not_assigned"),X("pending_with_contractor"),X("completed_by_contractor"),X("pending_with_moh"),Je,Ve,Xe,X("urgent_pending_review"),Rt,qe,Dt].forEach((ze,nt)=>{const _t=ft.getCell(nt+1);_t.value=ze,ye(_t,{bold:!0,size:10,bg:be,h:nt===0?"left":"center"})});const St=It+1+1;re.mergeCells(`A${St}:M${St}`);const Ot=re.getCell(`A${St}`);Ot.value=`KPI REPORT FOR THE MONTH OF ${g}`,ye(Ot,{bold:!0,size:12,color:"FFFFFF",bg:J,h:"center"}),re.getRow(St).height=24;const Yt=ge.addImage({base64:ie,extension:"png"});re.addImage(Yt,{tl:{col:0,row:St},br:{col:13,row:St+20},editAs:"oneCell"}),re.views=[{state:"frozen",xSplit:1,ySplit:4}],re.pageSetup={orientation:"landscape",fitToPage:!0,fitToWidth:1};const Ye=yield ge.xlsx.writeBuffer(),wt=new Blob([Ye],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),zt=URL.createObjectURL(wt),qt=document.createElement("a");qt.href=zt,qt.download=`KPI_Monthly_Report_${g}.xlsx`,document.body.appendChild(qt),qt.click(),document.body.removeChild(qt),URL.revokeObjectURL(zt)});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:"KPI Monthly Report"}),t.jsx("div",{className:"flex items-center gap-1",children:t.jsx("button",{onClick:()=>s(i),className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:n("dashboard.viewFullReport"),children:t.jsx(ps,{className:"w-3.5 h-3.5 text-gray-400"})})})]}),!e||!((c=e.datasets)!=null&&c.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"})}):a]})},MB=({ppmKpiChartData:e,dashFromDate:r,chartElement:a,onOpenDetail:s})=>{var c;const{t:n}=Rr(),i=()=>me(null,null,function*(){var Be;if(!((Be=e==null?void 0:e.labels)!=null&&Be.length))return;const u=["JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"],h=r?new Date(r+"T00:00:00"):new Date,g=`${u[h.getMonth()]}-${h.getFullYear()}`,y=e.labels,w=e.datasets||[],E=(pe,rt)=>{var et;const ct=w.find(It=>It.name===pe);return Number((et=ct==null?void 0:ct.values)==null?void 0:et[rt])||0},S=yield new Promise(pe=>{const rt=document.createElement("canvas");rt.width=900,rt.height=420;const ct=rt.getContext("2d");ct.fillStyle="#FCE8D8",ct.fillRect(0,0,rt.width,rt.height);const et=["#4472C4","#ED7D31","#A9D18E","#7030A0","#FF0000","#00B0F0","#92D050","#FFC000"],It=["Total WOs","Pending","Completed"],ft=y.map((kt,ze)=>({label:(kt||"").toUpperCase(),color:et[ze%et.length],values:It.map(nt=>E(nt,ze))})),Lt=60,Je=20,Ve=50,Xe=90,Rt=rt.width-Lt-Je,qe=rt.height-Ve-Xe,Dt=ft.flatMap(kt=>kt.values),ar=Math.max(...Dt,1),yt=It.length,St=Rt/yt,Ot=ft.length,Yt=Math.min(St*.8/Ot,30),Ye=(St-Yt*Ot)/2;ct.strokeStyle="#D0D0D0",ct.lineWidth=1;for(let kt=0;kt<=5;kt++){const ze=Ve+qe-kt/5*qe;ct.beginPath(),ct.moveTo(Lt,ze),ct.lineTo(Lt+Rt,ze),ct.stroke(),ct.fillStyle="#555555",ct.font="11px Arial",ct.textAlign="right",ct.fillText(Math.round(ar*kt/5).toString(),Lt-6,ze+4)}It.forEach((kt,ze)=>{ft.forEach((nt,_t)=>{const lr=nt.values[ze],pr=ar>0?lr/ar*qe:0,Nr=Lt+ze*St+Ye+_t*Yt,rr=Ve+qe-pr;ct.fillStyle=nt.color,ct.fillRect(Nr,rr,Yt-1,pr),lr>0&&(ct.fillStyle="#222222",ct.font="8px Arial",ct.textAlign="center",ct.fillText(lr.toString(),Nr+(Yt-1)/2,rr-3))})}),ct.fillStyle="#333333",ct.font="11px Arial",ct.textAlign="center",It.forEach((kt,ze)=>{const nt=Lt+ze*St+St/2,_t=Ve+qe+16;ct.fillText(kt,nt,_t)}),ct.strokeStyle="#999999",ct.lineWidth=1,ct.beginPath(),ct.moveTo(Lt,Ve+qe),ct.lineTo(Lt+Rt,Ve+qe),ct.stroke();const wt=Ve+qe+36,zt=110,qt=Math.floor(Rt/zt);ft.forEach((kt,ze)=>{const nt=Math.floor(ze/qt),_t=ze%qt,lr=Lt+_t*zt,pr=wt+nt*16;ct.fillStyle=kt.color,ct.fillRect(lr,pr-9,12,12),ct.fillStyle="#333333",ct.font="10px Arial",ct.textAlign="left";const Nr=kt.label.length>10?kt.label.substring(0,9)+"…":kt.label;ct.fillText(Nr,lr+16,pr)}),ct.fillStyle="#7030A0",ct.font="bold 14px Arial",ct.textAlign="center",ct.fillText(`PPM FOR ${g}`,rt.width/2,28),pe(rt.toDataURL("image/png").split(",")[1])}),A=pe=>me(null,null,function*(){try{const rt="/assets/asm_ui_app/asm_app/",ct=`${rt}${rt.endsWith("/")?"":"/"}${pe}`,et=yield fetch(ct);if(!et.ok)return null;const It=yield et.arrayBuffer();return btoa(String.fromCharCode(...new Uint8Array(It)))}catch(rt){return null}}),[C,O]=yield Promise.all([A("kfsh-logo.png"),A("ehc-logo.png")]),M=(yield Nd(()=>me(null,null,function*(){const{default:pe}=yield import("./exceljs.min-D41JvsuX.js").then(rt=>rt.e);return{default:pe}}),[])).default,R=new M.Workbook,F=R.addWorksheet("PPM KPI Report");F.columns=[{width:20},{width:12},{width:12},{width:12},{width:14}];const z=pe=>({type:"pattern",pattern:"solid",fgColor:{argb:"FF"+pe.replace("#","")}}),W=(pe=!1,rt=10,ct="000000")=>({name:"Arial",bold:pe,size:rt,color:{argb:"FF"+ct}}),X=(pe="thin")=>({top:{style:pe,color:{argb:"FF000000"}},bottom:{style:pe,color:{argb:"FF000000"}},left:{style:pe,color:{argb:"FF000000"}},right:{style:pe,color:{argb:"FF000000"}}}),B=(pe="center",rt=!0)=>({horizontal:pe,vertical:"middle",wrapText:rt}),Y=(pe,rt)=>{var ct,et,It,ft,Lt;pe.font=W(rt.bold,(ct=rt.size)!=null?ct:10,(et=rt.color)!=null?et:"000000"),pe.alignment=B((It=rt.h)!=null?It:"center",(ft=rt.wrap)!=null?ft:!0),rt.bg&&(pe.fill=z(rt.bg)),rt.brd!==!1&&(pe.border=X((Lt=rt.brdStyle)!=null?Lt:"thin"))},G="70AD47",ie="F2F2F2",fe="FFFFC7",K="D9B3FF",ke="D9B3FF";if(F.getRow(1).height=30,F.getRow(2).height=20,F.getRow(3).height=16,F.mergeCells("A1:B3"),F.mergeCells("C1:C3"),F.mergeCells("D1:E3"),C){const pe=R.addImage({base64:C,extension:"png"});F.addImage(pe,{tl:{col:0,row:0},br:{col:2,row:3},editAs:"oneCell"})}else{const pe=F.getCell("A1");pe.value="King Fahad Specialist Hospital",Y(pe,{bold:!0,size:10,h:"center",brd:!1})}if(O){const pe=R.addImage({base64:O,extension:"png"});F.addImage(pe,{tl:{col:3,row:0},br:{col:5,row:3},editAs:"oneCell"})}else{const pe=F.getCell("D1");pe.value="Eastern Health Cluster",Y(pe,{bold:!0,size:10,h:"center",brd:!1})}F.getRow(4).height=6,F.mergeCells("A5:E5");const ge=F.getCell("A5");ge.value=`PPM JOB ORDERS KPI REPORT FOR THE MONTH OF ${g}`,Y(ge,{bold:!0,size:11,color:"FFFFFF",bg:G,h:"center"}),F.getRow(5).height=24,F.getRow(6).height=6,["DEPARTMENT","Totl Wos","PENDING","COMPLETED",`Completion
Rate`].forEach((pe,rt)=>{const ct=F.getRow(7).getCell(rt+1);ct.value=pe,rt===4?(ct.fill=z(K),ct.font=W(!0,10,"000000"),ct.alignment=B("center",!0),ct.border=X()):Y(ct,{bold:!0,size:10,bg:ie,h:"center"})}),F.getRow(7).height=28;const we=8;y.forEach((pe,rt)=>{const ct=we+rt,It=rt%2===0?fe:"FFFFFF",ft=F.getRow(ct);ft.height=18;const Lt=E("Total WOs",rt),Je=E("Completed",rt),Ve=E("Pending",rt),Xe=Lt>0?parseFloat((Je/Lt*100).toFixed(0)):0;[(pe||"").toUpperCase(),Lt,Ve,Je,Xe>0?`${Xe}%`:"0%"].forEach((qe,Dt)=>{const ar=ft.getCell(Dt+1);ar.value=qe,Y(ar,{bold:Dt===4,size:10,bg:Dt===4?K:It,h:"center"})})});const ee=we+y.length,ve=F.getRow(ee);ve.height=20;const ce=y.reduce((pe,rt,ct)=>pe+E("Total WOs",ct),0),ye=y.reduce((pe,rt,ct)=>pe+E("Completed",ct),0),te=y.reduce((pe,rt,ct)=>pe+E("Pending",ct),0),q=ce>0?`${(ye/ce*100).toFixed(0)}%`:"0%";["TOTAL",ce,te,ye,q].forEach((pe,rt)=>{const ct=ve.getCell(rt+1);ct.value=pe,Y(ct,{bold:!0,size:10,bg:ke,h:"center",brdStyle:"medium"})});const J=ee+1;F.getRow(J).height=8;const ae=J+1;F.mergeCells(`A${ae}:E${ae}`);const oe=F.getCell(`A${ae}`);oe.value=`PPM FOR ${g}`,Y(oe,{bold:!0,size:12,color:"7030A0",bg:"F8E4FF",h:"center",brd:!1}),F.getRow(ae).height=22;const le=R.addImage({base64:S,extension:"png"});F.addImage(le,{tl:{col:0,row:ae},br:{col:5,row:ae+22},editAs:"oneCell"}),F.views=[{state:"frozen",xSplit:1,ySplit:7}],F.pageSetup={orientation:"landscape",fitToPage:!0,fitToWidth:1};const be=yield R.xlsx.writeBuffer(),Z=new Blob([be],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),Le=URL.createObjectURL(Z),Pe=document.createElement("a");Pe.href=Le,Pe.download=`PPM_KPI_Report_${g}.xlsx`,document.body.appendChild(Pe),Pe.click(),document.body.removeChild(Pe),URL.revokeObjectURL(Le)});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:"PPM KPI Report"}),t.jsx("div",{className:"flex items-center gap-1",children:t.jsx("button",{onClick:()=>s(i),className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:n("dashboard.viewFullReport"),children:t.jsx(ps,{className:"w-3.5 h-3.5 text-gray-400"})})})]}),!e||!((c=e.datasets)!=null&&c.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"})}):a]})},eb=(e="Asset")=>{const[r,a]=_.useState({isAdmin:!1,restrictions:{},permissionFilters:{},targetDoctype:e,loading:!0,error:null}),s=_.useCallback(g=>me(null,null,function*(){const y=g||e;try{a(E=>Ke(Te({},E),{loading:!0,error:null,targetDoctype:y}));const w=yield Xt.getPermissionFilters(y);return a({isAdmin:w.is_admin,restrictions:w.restrictions||{},permissionFilters:w.filters||{},targetDoctype:y,loading:!1,error:null}),w}catch(w){return console.error(`Error fetching permissions for ${y}:`,w),a(E=>Ke(Te({},E),{loading:!1,error:w instanceof Error?w.message:"Failed to fetch permissions"})),null}}),[e]);_.useEffect(()=>{s()},[s]);const n=_.useCallback(g=>{var y;return((y=r.restrictions[g])==null?void 0:y.values)||[]},[r.restrictions]),i=_.useCallback(g=>r.isAdmin?!1:!!r.restrictions[g],[r.isAdmin,r.restrictions]),c=_.useMemo(()=>!r.isAdmin&&Object.keys(r.restrictions).length>0,[r.isAdmin,r.restrictions]),u=_.useCallback(g=>{if(r.isAdmin)return g;const y=Te({},g);for(const[w,E]of Object.entries(r.permissionFilters))if(!y[w])y[w]=E;else if(Array.isArray(E)&&E[0]==="in"){const S=E[1];typeof y[w]=="string"&&!S.includes(y[w])&&(y[w]=["in",[]])}return y},[r.isAdmin,r.permissionFilters]),h=_.useMemo(()=>Object.entries(r.restrictions).map(([g,y])=>({type:g,field:y.field,values:y.values,count:y.count})),[r.restrictions]);return Ke(Te({},r),{refetch:s,switchDoctype:s,getAllowedValues:n,hasRestriction:i,hasAnyRestrictions:c,mergeFilters:u,restrictionsList:h})},mj={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"}]},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"}]},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"}]},"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"}]}},PB=e=>mj[e]||null,I1=e=>e in mj,Ku=new Map;let LB=null,ym=null,bk=0;const BB=300*1e3,UB=()=>me(null,null,function*(){var r,a;const e=Date.now();if(ym&&e-bk<BB)return ym;try{const i=(yield(yield fetch("/api/method/asset_lite.api.user_roles.get_user_info_with_roles",{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json()).message;return i&&Array.isArray(i.roles)?(ym={user:(r=i.user)!=null?r:null,roles:i.roles,full_name:(a=i.full_name)!=null?a:null},LB=i.roles,bk=e,ym):{user:null,roles:[],full_name:null}}catch(s){return console.error("[PermissionService] Error fetching user info with roles:",s),{user:null,roles:[],full_name:null}}}),zB=e=>me(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}}),WB=e=>me(null,null,function*(){var a,s,n,i;const r=`create_${e}`;if(Ku.has(r)){const c=Ku.get(r);return console.log(`[PermissionService] ${e} (cached): ${c}`),c}console.log(`[PermissionService] Checking create permission for: ${e}`);try{const u=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}:`,u);const h=((a=u.message)==null?void 0:a.has_permission)===!0;return console.log(h?`[PermissionService] ${e}: Permission GRANTED via ${(s=u.message)==null?void 0:s.reason} (role: ${(n=u.message)==null?void 0:n.role})`:`[PermissionService] ${e}: Permission DENIED - ${(i=u.message)==null?void 0:i.reason}`),Ku.set(r,h),h}catch(c){console.error(`[PermissionService] Error checking permission for ${e}:`,c);try{if(yield zB(["System Manager","Administrator"]))return console.log("[PermissionService] Fallback: User is admin, granting permission"),Ku.set(r,!0),!0}catch(u){console.error("[PermissionService] Fallback check failed:",u)}return Ku.set(r,!1),!1}});function gj(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=gj(e[r]))&&(s&&(s+=" "),s+=a)}else for(a in e)e[a]&&(s&&(s+=" "),s+=a);return s}function Od(){for(var e,r,a=0,s="",n=arguments.length;a<n;a++)(e=arguments[a])&&(r=gj(e))&&(s&&(s+=" "),s+=r);return s}function HB(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))}HB(`: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 Qf=e=>typeof e=="number"&&!isNaN(e),Hd=e=>typeof e=="string",fc=e=>typeof e=="function",$B=e=>Hd(e)||Qf(e),M1=e=>Hd(e)||fc(e)?e:null,VB=(e,r)=>e===!1||Qf(e)&&e>0?e:r,P1=e=>_.isValidElement(e)||Hd(e)||fc(e)||Qf(e);function GB(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 YB({enter:e,exit:r,appendPosition:a=!1,collapse:s=!0,collapseDuration:n=300}){return function({children:i,position:c,preventExitTransition:u,done:h,nodeRef:g,isIn:y,playToast:w}){let E=a?`${e}--${c}`:e,S=a?`${r}--${c}`:r,A=_.useRef(0);return _.useLayoutEffect(()=>{let C=g.current,O=E.split(" "),M=R=>{R.target===g.current&&(w(),C.removeEventListener("animationend",M),C.removeEventListener("animationcancel",M),A.current===0&&R.type!=="animationcancel"&&C.classList.remove(...O))};C.classList.add(...O),C.addEventListener("animationend",M),C.addEventListener("animationcancel",M)},[]),_.useEffect(()=>{let C=g.current,O=()=>{C.removeEventListener("animationend",O),s?GB(C,h,n):h()};y||(u?O():(A.current=1,C.className+=` ${S}`,C.addEventListener("animationend",O)))},[y]),ea.createElement(ea.Fragment,null,i)}}function vk(e,r){return{content:xj(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 xj(e,r,a=!1){return _.isValidElement(e)&&!Hd(e.type)?_.cloneElement(e,{closeToast:r.closeToast,toastProps:r,data:r.data,isPaused:a}):fc(e)?e({closeToast:r.closeToast,toastProps:r,data:r.data,isPaused:a}):e}function qB({closeToast:e,theme:r,ariaLabel:a="close"}){return ea.createElement("button",{className:`Toastify__close-button Toastify__close-button--${r}`,type:"button",onClick:s=>{s.stopPropagation(),e(!0)},"aria-label":a},ea.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},ea.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 XB({delay:e,isRunning:r,closeToast:a,type:s="default",hide:n,className:i,controlledProgress:c,progress:u,rtl:h,isIn:g,theme:y}){let w=n||c&&u===0,E={animationDuration:`${e}ms`,animationPlayState:r?"running":"paused"};c&&(E.transform=`scaleX(${u})`);let S=Od("Toastify__progress-bar",c?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated",`Toastify__progress-bar-theme--${y}`,`Toastify__progress-bar--${s}`,{"Toastify__progress-bar--rtl":h}),A=fc(i)?i({rtl:h,type:s,defaultClassName:S}):Od(S,i),C={[c&&u>=1?"onTransitionEnd":"onAnimationEnd"]:c&&u<1?null:()=>{g&&a()}};return ea.createElement("div",{className:"Toastify__progress-bar--wrp","data-hidden":w},ea.createElement("div",{className:`Toastify__progress-bar--bg Toastify__progress-bar-theme--${y} Toastify__progress-bar--${s}`}),ea.createElement("div",Te({role:"progressbar","aria-hidden":w?"true":"false","aria-label":"notification timer",className:A,style:E},C)))}var ZB=1,pj=()=>`${ZB++}`;function KB(e,r,a){let s=1,n=0,i=[],c=[],u=r,h=new Map,g=new Set,y=R=>(g.add(R),()=>g.delete(R)),w=()=>{c=Array.from(h.values()),g.forEach(R=>R())},E=({containerId:R,toastId:F,updateId:z})=>{let W=R?R!==e:e!==1,X=h.has(F)&&z==null;return W||X},S=(R,F)=>{h.forEach(z=>{var W;(F==null||F===z.props.toastId)&&((W=z.toggle)==null||W.call(z,R))})},A=R=>{var F,z;(z=(F=R.props)==null?void 0:F.onClose)==null||z.call(F,R.removalReason),R.isActive=!1},C=R=>{if(R==null)h.forEach(A);else{let F=h.get(R);F&&A(F)}w()},O=()=>{n-=i.length,i=[]},M=R=>{var F,z;let{toastId:W,updateId:X}=R.props,B=X==null;R.staleId&&h.delete(R.staleId),R.isActive=!0,h.set(W,R),w(),a(vk(R,B?"added":"updated")),B&&((z=(F=R.props).onOpen)==null||z.call(F))};return{id:e,props:u,observe:y,toggle:S,removeToast:C,toasts:h,clearQueue:O,buildToast:(R,F)=>{if(E(F))return;let{toastId:z,updateId:W,data:X,staleId:B,delay:Y}=F,G=W==null;G&&n++;let ie=Ke(Te(Ke(Te({},u),{style:u.toastStyle,key:s++}),Object.fromEntries(Object.entries(F).filter(([K,ke])=>ke!=null))),{toastId:z,updateId:W,data:X,isIn:!1,className:M1(F.className||u.toastClassName),progressClassName:M1(F.progressClassName||u.progressClassName),autoClose:F.isLoading?!1:VB(F.autoClose,u.autoClose),closeToast(K){h.get(z).removalReason=K,C(z)},deleteToast(){let K=h.get(z);if(K!=null){if(a(vk(K,"removed")),h.delete(z),n--,n<0&&(n=0),i.length>0){M(i.shift());return}w()}}});ie.closeButton=u.closeButton,F.closeButton===!1||P1(F.closeButton)?ie.closeButton=F.closeButton:F.closeButton===!0&&(ie.closeButton=P1(u.closeButton)?u.closeButton:!0);let fe={content:R,props:ie,staleId:B};u.limit&&u.limit>0&&n>u.limit&&G?i.push(fe):Qf(Y)?setTimeout(()=>{M(fe)},Y):M(fe)},setProps(R){u=R},setToggle:(R,F)=>{let z=h.get(R);z&&(z.toggle=F)},isToastActive:R=>{var F;return(F=h.get(R))==null?void 0:F.isActive},getSnapshot:()=>c}}var Li=new Map,Bf=[],L1=new Set,JB=e=>L1.forEach(r=>r(e)),yj=()=>Li.size>0;function QB(){Bf.forEach(e=>vj(e.content,e.options)),Bf=[]}var eU=(e,{containerId:r})=>{var a;return(a=Li.get(r||1))==null?void 0:a.toasts.get(e)};function bj(e,r){var a;if(r)return!!((a=Li.get(r))!=null&&a.isToastActive(e));let s=!1;return Li.forEach(n=>{n.isToastActive(e)&&(s=!0)}),s}function tU(e){if(!yj()){Bf=Bf.filter(r=>e!=null&&r.options.toastId!==e);return}if(e==null||$B(e))Li.forEach(r=>{r.removeToast(e)});else if(e&&("containerId"in e||"id"in e)){let r=Li.get(e.containerId);r?r.removeToast(e.id):Li.forEach(a=>{a.removeToast(e.id)})}}var rU=(e={})=>{Li.forEach(r=>{r.props.limit&&(!e.containerId||r.id===e.containerId)&&r.clearQueue()})};function vj(e,r){P1(e)&&(yj()||Bf.push({content:e,options:r}),Li.forEach(a=>{a.buildToast(e,r)}))}function aU(e){var r;(r=Li.get(e.containerId||1))==null||r.setToggle(e.id,e.fn)}function wj(e,r){Li.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 sU(e){let r=e.containerId||1;return{subscribe(a){let s=KB(r,e,JB);Li.set(r,s);let n=s.observe(a);return QB(),()=>{n(),Li.delete(r)}},setProps(a){var s;(s=Li.get(r))==null||s.setProps(a)},getSnapshot(){var a;return(a=Li.get(r))==null?void 0:a.getSnapshot()}}}function nU(e){return L1.add(e),()=>{L1.delete(e)}}function iU(e){return e&&(Hd(e.toastId)||Qf(e.toastId))?e.toastId:pj()}function eh(e,r){return vj(e,r),r.toastId}function Sg(e,r){return Ke(Te({},r),{type:r&&r.type||e,toastId:iU(r)})}function Cg(e){return(r,a)=>eh(r,Sg(e,a))}function Mt(e,r){return eh(e,Sg("default",r))}Mt.loading=(e,r)=>eh(e,Sg("default",Te({isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1},r)));function oU(e,{pending:r,error:a,success:s},n){let i;r&&(i=Hd(r)?Mt.loading(r,n):Mt.loading(r.render,Te(Te({},n),r)));let c={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},u=(g,y,w)=>{if(y==null){Mt.dismiss(i);return}let E=Ke(Te(Te({type:g},c),n),{data:w}),S=Hd(y)?{render:y}:y;return i?Mt.update(i,Te(Te({},E),S)):Mt(S.render,Te(Te({},E),S)),w},h=fc(e)?e():e;return h.then(g=>u("success",s,g)).catch(g=>u("error",a,g)),h}Mt.promise=oU;Mt.success=Cg("success");Mt.info=Cg("info");Mt.error=Cg("error");Mt.warning=Cg("warning");Mt.warn=Mt.warning;Mt.dark=(e,r)=>eh(e,Sg("default",Te({theme:"dark"},r)));function lU(e){tU(e)}Mt.dismiss=lU;Mt.clearWaitingQueue=rU;Mt.isActive=bj;Mt.update=(e,r={})=>{let a=eU(e,r);if(a){let{props:s,content:n}=a,i=Ke(Te(Te({delay:100},s),r),{toastId:r.toastId||e,updateId:pj()});i.toastId!==e&&(i.staleId=e);let c=i.render||n;delete i.render,eh(c,i)}};Mt.done=e=>{Mt.update(e,{progress:1})};Mt.onChange=nU;Mt.play=e=>wj(!0,e);Mt.pause=e=>wj(!1,e);function cU(e){var r;let{subscribe:a,getSnapshot:s,setProps:n}=_.useRef(sU(e)).current;n(e);let i=(r=_.useSyncExternalStore(a,s,s))==null?void 0:r.slice();function c(u){if(!i)return[];let h=new Map;return e.newestOnTop&&i.reverse(),i.forEach(g=>{let{position:y}=g.props;h.has(y)||h.set(y,[]),h.get(y).push(g)}),Array.from(h,g=>u(g[0],g[1]))}return{getToastToRender:c,isToastActive:bj,count:i==null?void 0:i.length}}function dU(e){let[r,a]=_.useState(!1),[s,n]=_.useState(!1),i=_.useRef(null),c=_.useRef({start:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,didMove:!1}).current,{autoClose:u,pauseOnHover:h,closeToast:g,onClick:y,closeOnClick:w}=e;aU({id:e.toastId,containerId:e.containerId,fn:a}),_.useEffect(()=>{if(e.pauseOnFocusLoss)return E(),()=>{S()}},[e.pauseOnFocusLoss]);function E(){document.hasFocus()||M(),window.addEventListener("focus",O),window.addEventListener("blur",M)}function S(){window.removeEventListener("focus",O),window.removeEventListener("blur",M)}function A(B){if(e.draggable===!0||e.draggable===B.pointerType){R();let Y=i.current;c.canCloseOnClick=!0,c.canDrag=!0,Y.style.transition="none",e.draggableDirection==="x"?(c.start=B.clientX,c.removalDistance=Y.offsetWidth*(e.draggablePercent/100)):(c.start=B.clientY,c.removalDistance=Y.offsetHeight*(e.draggablePercent===80?e.draggablePercent*1.5:e.draggablePercent)/100)}}function C(B){let{top:Y,bottom:G,left:ie,right:fe}=i.current.getBoundingClientRect();B.nativeEvent.type!=="touchend"&&e.pauseOnHover&&B.clientX>=ie&&B.clientX<=fe&&B.clientY>=Y&&B.clientY<=G?M():O()}function O(){a(!0)}function M(){a(!1)}function R(){c.didMove=!1,document.addEventListener("pointermove",z),document.addEventListener("pointerup",W)}function F(){document.removeEventListener("pointermove",z),document.removeEventListener("pointerup",W)}function z(B){let Y=i.current;if(c.canDrag&&Y){c.didMove=!0,r&&M(),e.draggableDirection==="x"?c.delta=B.clientX-c.start:c.delta=B.clientY-c.start,c.start!==B.clientX&&(c.canCloseOnClick=!1);let G=e.draggableDirection==="x"?`${c.delta}px, var(--y)`:`0, calc(${c.delta}px + var(--y))`;Y.style.transform=`translate3d(${G},0)`,Y.style.opacity=`${1-Math.abs(c.delta/c.removalDistance)}`}}function W(){F();let B=i.current;if(c.canDrag&&c.didMove&&B){if(c.canDrag=!1,Math.abs(c.delta)>c.removalDistance){n(!0),e.closeToast(!0),e.collapseAll();return}B.style.transition="transform 0.2s, opacity 0.2s",B.style.removeProperty("transform"),B.style.removeProperty("opacity")}}let X={onPointerDown:A,onPointerUp:C};return u&&h&&(X.onMouseEnter=M,e.stacked||(X.onMouseLeave=O)),w&&(X.onClick=B=>{y&&y(B),c.canCloseOnClick&&g(!0)}),{playToast:O,pauseToast:M,isRunning:r,preventExitTransition:s,toastRef:i,eventHandlers:X}}var uU=typeof window!="undefined"?_.useLayoutEffect:_.useEffect,Eg=n=>{var i=n,{theme:e,type:r,isLoading:a}=i,s=Ji(i,["theme","type","isLoading"]);return ea.createElement("svg",Te({viewBox:"0 0 24 24",width:"100%",height:"100%",fill:e==="colored"?"currentColor":`var(--toastify-icon-color-${r})`},s))};function fU(e){return ea.createElement(Eg,Te({},e),ea.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 hU(e){return ea.createElement(Eg,Te({},e),ea.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 mU(e){return ea.createElement(Eg,Te({},e),ea.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 gU(e){return ea.createElement(Eg,Te({},e),ea.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 xU(){return ea.createElement("div",{className:"Toastify__spinner"})}var B1={info:hU,warning:fU,success:mU,error:gU,spinner:xU},pU=e=>e in B1;function yU({theme:e,type:r,isLoading:a,icon:s}){let n=null,i={theme:e,type:r};return s===!1||(fc(s)?n=s(Ke(Te({},i),{isLoading:a})):_.isValidElement(s)?n=_.cloneElement(s,i):a?n=B1.spinner():pU(r)&&(n=B1[r](i))),n}var bU=e=>{let{isRunning:r,preventExitTransition:a,toastRef:s,eventHandlers:n,playToast:i}=dU(e),{closeButton:c,children:u,autoClose:h,onClick:g,type:y,hideProgressBar:w,closeToast:E,transition:S,position:A,className:C,style:O,progressClassName:M,updateId:R,role:F,progress:z,rtl:W,toastId:X,deleteToast:B,isIn:Y,isLoading:G,closeOnClick:ie,theme:fe,ariaLabel:K}=e,ke=Od("Toastify__toast",`Toastify__toast-theme--${fe}`,`Toastify__toast--${y}`,{"Toastify__toast--rtl":W},{"Toastify__toast--close-on-click":ie}),ge=fc(C)?C({rtl:W,position:A,type:y,defaultClassName:ke}):Od(ke,C),re=yU(e),we=!!z||!h,ee={closeToast:E,type:y,theme:fe},ve=null;return c===!1||(fc(c)?ve=c(ee):_.isValidElement(c)?ve=_.cloneElement(c,ee):ve=qB(ee)),ea.createElement(S,{isIn:Y,done:B,position:A,preventExitTransition:a,nodeRef:s,playToast:i},ea.createElement("div",Te(Ke(Te({id:X,tabIndex:0,onClick:g,"data-in":Y,className:ge},n),{style:O,ref:s}),Y&&{role:F,"aria-label":K}),re!=null&&ea.createElement("div",{className:Od("Toastify__toast-icon",{"Toastify--animate-icon Toastify__zoom-enter":!G})},re),xj(u,e,!r),ve,!e.customProgressBar&&ea.createElement(XB,Ke(Te({},R&&!we?{key:`p-${R}`}:{}),{rtl:W,theme:fe,delay:h,isRunning:r,isIn:Y,closeToast:E,hide:w,type:y,className:M,controlledProgress:we,progress:z||0}))))},vU=(e,r=!1)=>({enter:`Toastify--animate Toastify__${e}-enter`,exit:`Toastify--animate Toastify__${e}-exit`,appendPosition:r}),Ll=YB(vU("bounce",!0)),wU={position:"top-right",transition:Ll,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 xc(e){let r=Te(Te({},wU),e),a=e.stacked,[s,n]=_.useState(!0),i=_.useRef(null),{getToastToRender:c,isToastActive:u,count:h}=cU(r),{className:g,style:y,rtl:w,containerId:E,hotKeys:S}=r;function A(O){let M=Od("Toastify__toast-container",`Toastify__toast-container--${O}`,{"Toastify__toast-container--rtl":w});return fc(g)?g({position:O,rtl:w,defaultClassName:M}):Od(M,M1(g))}function C(){a&&(n(!0),Mt.play())}return uU(()=>{var O;if(a){let M=i.current.querySelectorAll('[data-in="true"]'),R=12,F=(O=r.position)==null?void 0:O.includes("top"),z=0,W=0;Array.from(M).reverse().forEach((X,B)=>{let Y=X;Y.classList.add("Toastify__toast--stacked"),B>0&&(Y.dataset.collapsed=`${s}`),Y.dataset.pos||(Y.dataset.pos=F?"top":"bot");let G=z*(s?.2:1)+(s?0:R*B);Y.style.setProperty("--y",`${F?G:G*-1}px`),Y.style.setProperty("--g",`${R}`),Y.style.setProperty("--s",`${1-(s?W:0)}`),z+=Y.offsetHeight,W+=.025})}},[s,h,a]),_.useEffect(()=>{function O(M){var R;let F=i.current;S(M)&&((R=F.querySelector('[tabIndex="0"]'))==null||R.focus(),n(!1),Mt.pause()),M.key==="Escape"&&(document.activeElement===F||F!=null&&F.contains(document.activeElement))&&(n(!0),Mt.play())}return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O)}},[S]),ea.createElement("section",{ref:i,className:"Toastify",id:E,onMouseEnter:()=>{a&&(n(!1),Mt.pause())},onMouseLeave:C,"aria-live":"polite","aria-atomic":"false","aria-relevant":"additions text","aria-label":r["aria-label"]},c((O,M)=>{let R=M.length?Te({},y):Ke(Te({},y),{pointerEvents:"none"});return ea.createElement("div",{tabIndex:-1,className:A(O),"data-stacked":a,style:R,key:`c-${O}`},M.map(({content:F,props:z})=>ea.createElement(bU,Ke(Te({},z),{stacked:a,collapseAll:C,isIn:u(z.toastId,z.containerId),key:`t-${z.key}`}),F)))}))}const M0=Object.freeze({}),_U=({doctype:e,value:r,onChange:a,disabled:s=!1,placeholder:n="Search...",filters:i})=>{const[c,u]=_.useState(""),[h,g]=_.useState([]),[y,w]=_.useState(!1),[E,S]=_.useState(!1),A=_.useRef(null),C=_.useRef(null),O=_.useRef(i!=null?i:M0);O.current=i!=null?i:M0;const M=_.useCallback((z="")=>me(null,null,function*(){if(e){S(!0);try{const W=new URLSearchParams({doctype:e,txt:z,page_length:"20"}),X=O.current;X&&Object.keys(X).length>0&&W.append("filters",JSON.stringify(X));const B=yield Xt.apiCall(`/api/method/frappe.desk.search.search_link?${W.toString()}`);g(B||[])}catch(W){console.error(`Error fetching ${e} links:`,W),g([])}finally{S(!1)}}}),[e]);_.useEffect(()=>{if(y)return C.current&&clearTimeout(C.current),C.current=setTimeout(()=>M(c),300),()=>{C.current&&clearTimeout(C.current)}},[c,y,M]),_.useEffect(()=>{y&&M(c)},[y,M]),_.useEffect(()=>{const z=W=>{A.current&&!A.current.contains(W.target)&&(w(!1),u(""))};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[]);const R=z=>{a(z),u(""),w(!1)},F=()=>{a(""),u("")};return t.jsxs("div",{ref:A,className:"relative",children:[t.jsxs("div",{className:"relative",children:[t.jsx(In,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400",size:12}),t.jsx("input",{type:"text",value:y?c: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&&w(!0),onChange:z=>{u(z.target.value),w(!0)}}),r&&!s&&!y&&t.jsx("button",{type:"button",onClick:F,className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:t.jsx(Pt,{size:12})})]}),y&&!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:E?t.jsxs("div",{className:"p-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:[t.jsx(Ir,{className:"animate-spin inline mr-2",size:12}),"Loading..."]}):h.length>0?t.jsx("ul",{children:h.map((z,W)=>t.jsxs("li",{onClick:()=>R(z.value),className:`px-3 py-2 cursor-pointer text-sm hover:bg-blue-500 hover:text-white
${r===z.value?"bg-blue-50 dark:bg-blue-900/30":""}`,children:[z.value,z.description&&t.jsx("span",{className:"text-xs text-gray-500 ml-2",children:z.description})]},W))}):t.jsx("div",{className:"p-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:"No results found"})})]})},U1=({doctype:e,isOpen:r,onClose:a,onSuccess:s,initialValues:n,parentFilters:i,customConfig:c,submitLabel:u,submittingLabel:h,titleOverride:g})=>{const y=_.useMemo(()=>{if(n===void 0)return"__undef__";if(n===null)return"__null__";if(typeof n=="object"&&Object.keys(n).length===0)return"__empty__";try{return JSON.stringify(n)}catch(K){return"__nonserial__"}},[n]),w=_.useRef(n);w.current=n;const E=_.useMemo(()=>{const K=w.current;return K==null||typeof K=="object"&&Object.keys(K).length===0?M0:K},[y]),S=_.useMemo(()=>{if(i===void 0)return"__undef__";if(i===null)return"__null__";if(typeof i=="object"&&Object.keys(i).length===0)return"__empty__";try{return JSON.stringify(i)}catch(K){return"__nonserial__"}},[i]),A=_.useRef(i);A.current=i;const C=_.useMemo(()=>{const K=A.current;return K==null||typeof K=="object"&&Object.keys(K).length===0?M0:K},[S]),[O,M]=_.useState({}),[R,F]=_.useState({}),[z,W]=_.useState(!1),[X,B]=_.useState(null);_.useEffect(()=>{const K=c||PB(e);if(B(K),K){const ke={};K.fields.forEach(ge=>{ge.defaultValue!==void 0?ke[ge.fieldname]=ge.defaultValue:ge.fieldtype==="Check"?ke[ge.fieldname]=0:ke[ge.fieldname]=""}),M(Te(Te({},ke),E))}},[e,c,E]),_.useEffect(()=>{if(r&&X){const K={};X.fields.forEach(ke=>{ke.defaultValue!==void 0?K[ke.fieldname]=ke.defaultValue:ke.fieldtype==="Check"?K[ke.fieldname]=0:K[ke.fieldname]=""}),M(Te(Te({},K),E)),F({})}},[r,X,E]);const Y=_.useCallback((K,ke)=>{M(ge=>Ke(Te({},ge),{[K]:ke})),F(ge=>{const re=Te({},ge);return delete re[K],re})},[]),G=_.useCallback(()=>{if(!X)return!1;const K={};if(X.fields.forEach(ke=>{if(ke.required&&!ke.hidden){const ge=O[ke.fieldname];(ge==null||ge==="")&&(K[ke.fieldname]=`${ke.label} is required`)}}),X.validateBeforeCreate){const ke=X.validateBeforeCreate(O);if(ke)return Mt.error(ke,{position:"top-right",autoClose:4e3,icon:t.jsx(Jr,{})}),!1}return F(K),Object.keys(K).length===0},[X,O]),ie=K=>me(null,null,function*(){var ke,ge,re,we;if(K.preventDefault(),!(!G()||!X)){W(!0);try{const ee={};if(Object.entries(O).forEach(([ye,te])=>{te!==""&&te!==null&&te!==void 0&&(ee[ye]=te)}),X.doctype==="Department")try{const ye=yield fetch('/api/resource/Company?fields=["name"]&limit_page_length=1',{credentials:"include"});if(ye.ok){const q=(ge=(ke=(yield ye.json()).data)==null?void 0:ke[0])==null?void 0:ge.name;q&&String((re=ee.company)!=null?re:"").trim()===""&&(ee.company=q)}}catch(ye){}if(X.doctype==="Location"){const ye=String((we=ee.location_name)!=null?we:"").trim();if(ye)try{const te=yield Xt.apiCall("/api/method/frappe.client.get_list",{method:"POST",body:JSON.stringify({doctype:"Location",fields:["name"],filters:[["Location","location_name","=",ye]],limit_page_length:1})});if(Array.isArray(te)&&te.length>0){F(q=>Ke(Te({},q),{location_name:"Location name already exists."})),Mt.error(`Location name "${ye}" already exists. Choose a different name.`,{position:"top-right",autoClose:5e3,icon:t.jsx(Br,{})});return}}catch(te){}}const ve=yield Xt.apiCall(`/api/resource/${X.doctype}`,{method:"POST",body:JSON.stringify(ee)}),ce=ve&&typeof ve=="object"&&"data"in ve&&ve.data?ve.data:ve&&typeof ve=="object"&&typeof ve.name=="string"?ve:null;if(ce&&typeof ce.name=="string")Mt.success(`${X.title.replace("Create New ","")} created successfully!`,{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),X.afterCreate&&X.afterCreate(ce),s(ce),a();else throw new Error("Failed to create record")}catch(ee){console.error("Error creating record:",ee);const ve=ee instanceof Error?ee.message:"Unknown error occurred";ve.includes("Duplicate")||ve.includes("already exists")?Mt.error("A record with this name already exists. Please use a different name.",{position:"top-right",autoClose:5e3,icon:t.jsx(Br,{})}):Mt.error(`Failed to create: ${ve}`,{position:"top-right",autoClose:5e3,icon:t.jsx(Br,{})})}finally{W(!1)}}}),fe=K=>{if(K.hidden)return null;const ke=O[K.fieldname],ge=R[K.fieldname],re=K.readOnly||z;if(K.dependsOn&&!O[K.dependsOn])return null;const we=`w-full px-3 py-2 text-sm border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500
${ge?"border-red-500":"border-gray-300 dark:border-gray-600"}
${re?"bg-gray-100 dark:bg-gray-700 cursor-not-allowed":"bg-white dark:bg-gray-700"}
text-gray-900 dark:text-white`;switch(K.fieldtype){case"Data":return t.jsx("input",{type:"text",value:ke||"",onChange:ee=>Y(K.fieldname,ee.target.value),placeholder:K.placeholder,disabled:re,className:we});case"Text":return t.jsx("textarea",{value:ke||"",onChange:ee=>Y(K.fieldname,ee.target.value),placeholder:K.placeholder,disabled:re,rows:3,className:`${we} resize-none`});case"Select":return t.jsxs("select",{value:ke||"",onChange:ee=>Y(K.fieldname,ee.target.value),disabled:re,className:we,children:[t.jsxs("option",{value:"",children:["Select ",K.label]}),(K.options||[]).map(ee=>{const ve=typeof ee=="string"?ee:ee.value,ce=typeof ee=="string"?ee:ee.label;return t.jsx("option",{value:ve,children:ce},ve)})]});case"Link":return t.jsx(_U,{doctype:K.linkDoctype||"",value:ke||"",onChange:ee=>Y(K.fieldname,ee),disabled:re,placeholder:K.placeholder,filters:Te(Te({},K.linkFilters||{}),C)});case"Check":return t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:ke===1||ke===!0,onChange:ee=>Y(K.fieldname,ee.target.checked?1:0),disabled:re,className:`w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 \r
dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 \r
dark:bg-gray-700 dark:border-gray-600`}),t.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:K.description||K.label})]});case"Int":return t.jsx("input",{type:"number",value:ke||"",onChange:ee=>Y(K.fieldname,parseInt(ee.target.value)||""),placeholder:K.placeholder,disabled:re,step:"1",className:we});case"Float":return t.jsx("input",{type:"number",value:ke||"",onChange:ee=>Y(K.fieldname,parseFloat(ee.target.value)||""),placeholder:K.placeholder,disabled:re,step:"0.01",className:we});case"Date":return t.jsx("input",{type:"date",value:ke||"",onChange:ee=>Y(K.fieldname,ee.target.value),disabled:re,className:we});case"Datetime":return t.jsx("input",{type:"datetime-local",value:ke||"",onChange:ee=>Y(K.fieldname,ee.target.value),disabled:re,className:we});default:return t.jsx("input",{type:"text",value:ke||"",onChange:ee=>Y(K.fieldname,ee.target.value),placeholder:K.placeholder,disabled:re,className:we})}};return!r||!X?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(Js,{className:"text-blue-500",size:16}),g!=null?g:X.title]}),t.jsx("button",{type:"button",onClick:a,disabled:z,className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded transition-colors disabled:opacity-50",children:t.jsx(Pt,{size:18})})]}),t.jsx("form",{onSubmit:ie,className:"flex-1 overflow-y-auto p-4",children:t.jsx("div",{className:"space-y-4",children:X.fields.map(K=>K.hidden||K.dependsOn&&!O[K.dependsOn]?null:t.jsxs("div",{children:[K.fieldtype!=="Check"&&t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:[K.label,K.required&&t.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),fe(K),K.description&&K.fieldtype!=="Check"&&t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:K.description}),R[K.fieldname]&&t.jsxs("p",{className:"mt-1 text-xs text-red-500 flex items-center gap-1",children:[t.jsx(Jr,{size:10}),R[K.fieldname]]})]},K.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:z,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:ie,disabled:z,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:z?t.jsxs(t.Fragment,{children:[t.jsx(Ir,{className:"animate-spin",size:14}),h!=null?h:"Creating..."]}):t.jsxs(t.Fragment,{children:[u?t.jsx(bs,{size:14}):t.jsx(Js,{size:14}),u!=null?u:"Create"]})})]})]})})},kU={},hr=({label:e,doctype:r,value:a,onChange:s,hideLabel:n=!1,placeholder:i,disabled:c=!1,filters:u,compact:h=!1,usePortal:g=!1,allowQuickCreate:y=!1,onQuickCreateSuccess:w,quickCreateInitialValues:E={},query:S,clearable:A=!0})=>{const{t:C}=Rr(),[O,M]=_.useState([]),[R,F]=_.useState(""),[z,W]=_.useState(!1),[X,B]=_.useState(!1),[Y,G]=_.useState({top:0,left:0,width:0}),[ie,fe]=_.useState(!1),[K,ke]=_.useState(null),ge=_.useRef(null),re=_.useRef(null),we=_.useRef(null),ee=_.useRef(null),ve=_.useRef(""),ce=_.useRef(!1),ye=u||kU,te=_.useMemo(()=>JSON.stringify(ye),[ye]),q=_.useMemo(()=>{const pe=I1(r);return console.log(`[LinkField] ${r} hasQuickCreateConfig: ${pe}`),pe},[r]);_.useEffect(()=>{ke(null),y&&q?(console.log(`[LinkField] Checking permission for ${r}...`),WB(r).then(pe=>{console.log(`[LinkField] Permission for ${r}: ${pe}`),ke(pe)}).catch(pe=>{console.error(`[LinkField] Permission check failed for ${r}:`,pe),ke(!1)})):(ke(!1),y&&!q&&console.warn(`[LinkField] ${r}: allowQuickCreate=true but no config in QuickCreateConfig.ts`))},[y,r,q]);const J=_.useMemo(()=>{const pe=y&&q&&K===!0;return console.log(`[LinkField] canQuickCreate for ${r}: ${pe}`,{allowQuickCreate:y,hasQuickCreateConfig:q,hasPermission:K}),pe},[y,q,K,r]),ae=_.useCallback((pe="",rt=!1)=>me(null,null,function*(){const ct=`${pe}-${te}-${S||""}`;if(!(!rt&&ve.current===ct)){ve.current=ct,B(!0);try{let et=null;if(S){const It=new URLSearchParams({txt:pe,doctype:r,searchfield:"name",start:"0",page_len:"50"});ye&&Object.keys(ye).length>0&&It.append("filters",JSON.stringify(ye));const ft=yield Xt.apiCall(`/api/method/${S}?${It.toString()}`);Array.isArray(ft)?et=ft.map(Lt=>Array.isArray(Lt)?{value:Lt[0],description:Lt[1]||void 0}:{value:Lt.value||Lt.name||Lt,description:Lt.description}):et=[]}else{const It=new URLSearchParams({doctype:r,txt:pe,page_length:"50"});ye&&Object.keys(ye).length>0&&It.append("filters",JSON.stringify(ye)),et=yield Xt.apiCall(`/api/method/frappe.desk.search.search_link?${It.toString()}`)}M(et||[])}catch(et){console.error(`Error fetching ${r} links:`,et),M([])}finally{B(!1)}}}),[r,te,ye,S]),oe=_.useCallback(pe=>{ee.current&&clearTimeout(ee.current),ee.current=setTimeout(()=>{ae(pe)},300)},[ae]);_.useEffect(()=>{z&&!ce.current&&(ce.current=!0,ae(R||"",!0)),z||(ce.current=!1,ve.current="")},[z]),_.useEffect(()=>()=>{ee.current&&clearTimeout(ee.current)},[]);const le=_.useCallback(()=>{if(g&&re.current){const pe=re.current.getBoundingClientRect();G({top:pe.bottom+window.scrollY,left:pe.left+window.scrollX,width:pe.width})}},[g]);_.useEffect(()=>{if(z&&g){le();const pe=()=>le();return window.addEventListener("scroll",pe,!0),window.addEventListener("resize",pe),()=>{window.removeEventListener("scroll",pe,!0),window.removeEventListener("resize",pe)}}},[z,g,le]),_.useEffect(()=>{const pe=rt=>{const ct=rt.target,et=ge.current&&!ge.current.contains(ct),It=g&&we.current&&!we.current.contains(ct);g?et&&It&&(W(!1),F("")):et&&(W(!1),F(""))};return document.addEventListener("mousedown",pe),()=>document.removeEventListener("mousedown",pe)},[g]);const be=pe=>{s(pe),F(""),W(!1)},Z=()=>{s(""),F(""),W(!1)},Le=()=>{W(!1),F(""),fe(!0)},Pe=pe=>{const rt=pe.name||pe[Object.keys(pe)[0]];be(rt),w&&w(pe)},Be=()=>{const pe=`bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600
rounded-md w-full shadow-lg ${h?"mt-0.5":"mt-1"}`,rt=g?{position:"fixed",top:`${Y.top}px`,left:`${Y.left}px`,width:`${Y.width}px`,zIndex:1050,marginTop:h?"2px":"4px"}:{};if(!z||c)return null;const ct=t.jsxs("div",{ref:we,children:[X&&t.jsxs("div",{className:`${g?"":"absolute z-[1050]"} ${pe} text-center text-gray-500 dark:text-gray-400
${h?"p-1.5 text-[10px]":"p-3 text-sm"}`,style:rt,children:[t.jsx("span",{className:"inline-block animate-spin mr-2",children:"⏳"}),C("linkField.loading")]}),!X&&t.jsxs("div",{className:`${g?"":"absolute z-[1050]"} ${pe} overflow-hidden`,style:rt,children:[O.length>0?t.jsx("ul",{className:`overflow-auto ${h?"max-h-36":"max-h-48"}`,children:O.map((et,It)=>t.jsxs("li",{onClick:()=>be(et.value),className:`cursor-pointer text-gray-900 dark:text-gray-100
hover:bg-blue-500 dark:hover:bg-blue-600 hover:text-white
${h?"px-2 py-1 text-xs":"px-3 py-2 text-sm"}
${a===et.value?"bg-blue-50 dark:bg-blue-700 font-semibold":""}`,children:[et.value,et.description&&t.jsx("span",{className:`text-gray-600 dark:text-gray-300 ml-2
${h?"text-[9px] ml-1":"text-xs ml-2"}`,children:et.description})]},It))}):t.jsx("div",{className:`text-center text-gray-500 dark:text-gray-400
${h?"p-1.5 text-[10px]":"p-3 text-sm"}`,children:C("linkField.noResultsFound")}),J&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700"}),t.jsxs("div",{onClick:Le,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
${h?"px-2 py-1.5 text-xs":"px-3 py-2.5 text-sm"}`,children:[t.jsx(Js,{size:h?10:12}),t.jsx("span",{className:"font-medium",children:C("linkField.createNewDoctype",{doctype:r.replace(/_/g," ")})})]})]})]})]});return g?gg.createPortal(ct,document.body):ct};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:ge,className:`relative w-full ${h?"mb-2":n?"mb-0":"mb-4"}`,children:[!n&&t.jsx("label",{className:`block font-medium text-gray-700 dark:text-gray-300 ${h?"text-[10px] mb-0.5":"text-sm mb-1"}`,children:e}),t.jsxs("div",{className:"relative",children:[t.jsx("input",{ref:re,type:"text",value:z?R:a,placeholder:i||C("linkField.selectLabel",{label:e}),disabled:c,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
${h?"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?h?"pr-5":"pr-8":""}`,onFocus:()=>{c||(W(!0),F(""),g&&le())},onChange:pe=>{const rt=pe.target.value;F(rt),oe(rt)}}),A&&a&&!c&&!z&&t.jsx("button",{type:"button",onClick:Z,className:`absolute top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300
${h?"right-1 text-xs":"right-2 text-sm"}`,children:"✕"})]}),Be()]}),t.jsx(U1,{doctype:r,isOpen:ie,onClose:()=>fe(!1),onSuccess:Pe,initialValues:E,parentFilters:ye})]})};function _j(e){return e==null||e===""?"":String(e)}function NU(e,r,a){const s=[r.map(c=>c.label||c.fieldname),...e.map(c=>r.map(u=>_j(c[u.fieldname])))],n=Ur.aoa_to_sheet(s),i=Ur.book_new();Ur.book_append_sheet(i,n,"Export"),jo(i,a)}function jU(e,r,a){const s=window.open("","_blank");if(!s){window.alert("Please allow popups for this site to export PDF.");return}const n=`
<!DOCTYPE html>
<html>
<head>
<title>${a}</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
h1 { text-align: center; color: #333; margin-bottom: 8px; font-size: 18px; }
.meta { text-align: center; color: #666; margin-bottom: 20px; font-size: 11px; }
table { width: 100%; border-collapse: collapse; font-size: 10px; }
th, td { border: 1px solid #ccc; padding: 6px 8px; text-align: left; vertical-align: top; }
th { background: #047857; color: white; }
tr:nth-child(even) { background: #f9fafb; }
@media print { body { margin: 0; } }
</style>
</head>
<body>
<h1>${a}</h1>
<div class="meta">
Generated on: ${new Date().toLocaleString()} | Total Records: ${e.length}
</div>
<table>
<thead>
<tr>
${r.map(i=>`<th>${i.label||i.fieldname}</th>`).join("")}
</tr>
</thead>
<tbody>
${e.map(i=>`
<tr>
${r.map(c=>`<td>${_j(i[c.fieldname])||"—"}</td>`).join("")}
</tr>
`).join("")}
</tbody>
</table>
<script>window.onload = function() { window.print(); }<\/script>
</body>
</html>
`;s.document.write(n),s.document.close()}const SU=({isOpen:e,onClose:r,title:a="Export Report",columns:s,rows:n,fileNamePrefix:i="report"})=>{const[c,u]=_.useState("excel"),[h,g]=_.useState(new Set),[y,w]=_.useState(!1),E=_.useMemo(()=>s.filter(F=>F.fieldname),[s]);if(_.useEffect(()=>{e&&(u("excel"),g(new Set(E.map(F=>F.fieldname))))},[e,E]),!e)return null;const S=E.filter(F=>h.has(F.fieldname)),A=n.length>0&&S.length>0,C=F=>{g(z=>{const W=new Set(z);return W.has(F)?W.delete(F):W.add(F),W})},O=()=>g(new Set(E.map(F=>F.fieldname))),M=()=>g(new Set),R=()=>me(null,null,function*(){if(A){w(!0);try{const F=new Date().toISOString().split("T")[0];c==="excel"?NU(n,S,`${i}_${F}.xlsx`):jU(n,S,a),r()}catch(F){console.error("Export failed:",F),window.alert(`Export failed: ${F instanceof Error?F.message:"Unknown error"}`)}finally{w(!1)}}});return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[80] p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-lg max-h-[90vh] flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"bg-gradient-to-r from-emerald-600 to-teal-600 px-5 py-4 flex items-center justify-between shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ks,{className:"text-white"}),t.jsx("h3",{className:"text-base font-semibold text-white",children:a})]}),t.jsx("button",{type:"button",onClick:r,disabled:y,className:"text-white/80 hover:text-white p-1 rounded-lg hover:bg-white/20",children:t.jsx(Pt,{})})]}),t.jsxs("div",{className:"p-5 space-y-5 overflow-y-auto flex-1",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2",children:"File format"}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("label",{className:`flex-1 flex items-center gap-2 p-3 rounded-lg border cursor-pointer ${c==="excel"?"border-emerald-500 bg-emerald-50 dark:bg-emerald-900/20":"border-gray-200 dark:border-gray-700"}`,children:[t.jsx("input",{type:"radio",name:"wo_feedback_export_format",checked:c==="excel",onChange:()=>u("excel"),className:"text-emerald-600"}),t.jsx(zi,{className:"text-green-700"}),t.jsx("span",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:"Excel (.xlsx)"})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-2 p-3 rounded-lg border cursor-pointer ${c==="pdf"?"border-emerald-500 bg-emerald-50 dark:bg-emerald-900/20":"border-gray-200 dark:border-gray-700"}`,children:[t.jsx("input",{type:"radio",name:"wo_feedback_export_format",checked:c==="pdf",onChange:()=>u("pdf"),className:"text-emerald-600"}),t.jsx(Hf,{className:"text-red-600"}),t.jsx("span",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:"PDF"})]})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Columns to export"}),t.jsxs("div",{className:"flex gap-3 text-xs text-emerald-600 dark:text-emerald-400",children:[t.jsx("button",{type:"button",onClick:O,className:"hover:underline",children:"All"}),t.jsx("button",{type:"button",onClick:M,className:"hover:underline",children:"None"})]})]}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 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:E.map(F=>{const z=h.has(F.fieldname);return t.jsxs("button",{type:"button",onClick:()=>C(F.fieldname),className:`flex items-center gap-2 px-2 py-1.5 rounded text-left text-xs transition-colors ${z?"bg-emerald-100 dark:bg-emerald-900/30 text-emerald-800 dark:text-emerald-200":"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-600 dark:text-gray-400"}`,children:[z?t.jsx(jn,{size:13,className:"text-emerald-600 shrink-0"}):t.jsx(ys,{size:13,className:"text-gray-300 shrink-0"}),t.jsx("span",{className:"truncate",title:F.label||F.fieldname,children:F.label||F.fieldname})]},F.fieldname)})}),t.jsxs("p",{className:"text-xs text-gray-400 mt-1.5",children:[h.size," of ",E.length," columns selected · ",n.length," row",n.length!==1?"s":""]})]})]}),t.jsxs("div",{className:"px-5 py-4 border-t border-gray-200 dark:border-gray-700 flex justify-end gap-3 shrink-0",children:[t.jsx("button",{type:"button",onClick:r,disabled:y,className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg",children:"Cancel"}),t.jsx("button",{type:"button",onClick:R,disabled:!A||y,className:"px-4 py-2 text-sm font-medium text-white bg-emerald-600 hover:bg-emerald-700 rounded-lg flex items-center gap-2 disabled:opacity-50",children:y?t.jsxs(t.Fragment,{children:[t.jsx(Ir,{className:"animate-spin",size:14})," Exporting…"]}):t.jsxs(t.Fragment,{children:[t.jsx(Vo,{size:14})," Export"]})})]})]})})},z1=["Excellent / ممتاز","Good / جيد","Average / متوسط","Poor / ضعيف"];function kj(e){const r=e.toLowerCase();return r.includes("excellent")||r.includes("ممتاز")?0:r.includes("good")||r.includes("جيد")?1:r.includes("average")||r.includes("متوسط")?2:r.includes("poor")||r.includes("ضعيف")?3:-1}function W1(e){const r=kj(e);return r===0?"#10B981":r===1?"#3B82F6":r===2?"#F59E0B":r===3?"#EF4444":"#6B7280"}function CU(e){var c,u,h;const r=(e==null?void 0:e.labels)||[],a=((u=(c=e==null?void 0:e.datasets)==null?void 0:c[0])==null?void 0:u.values)||[],s=new Map;r.forEach((g,y)=>{const w=kj(g);if(w<0)return;const E=Number(a[y])||0,S=s.get(w);S?S.value+=E:s.set(w,{label:g,value:E})});const n=z1.map((g,y)=>{var w,E;return(E=(w=s.get(y))==null?void 0:w.label)!=null?E:g}),i=z1.map((g,y)=>{var w,E;return(E=(w=s.get(y))==null?void 0:w.value)!=null?E:0});return Ke(Te({},e||{}),{labels:n,datasets:[Ke(Te({},((h=e==null?void 0:e.datasets)==null?void 0:h[0])||{name:"Work Orders"}),{values:i})]})}function EU(e){var s,n,i;const r=CU(e),a=r.labels.map(c=>W1(c));return Ke(Te({},r),{type:"Pie",datasets:[Ke(Te({},((s=r.datasets)==null?void 0:s[0])||{name:"Work Orders",values:[]}),{colors:a,values:((i=(n=r.datasets)==null?void 0:n[0])==null?void 0:i.values)||[]})]})}const wk={work_order:"",requester_name:"",rating:""},TU=({isOpen:e,onClose:r})=>{const[a,s]=_.useState(null),[n,i]=_.useState(!1),[c,u]=_.useState(!1),[h,g]=_.useState(""),[y,w]=_.useState(""),[E,S]=_.useState(""),[A,C]=_.useState(wk),[O,M]=_.useState(!1),R=_.useRef(!1),F=_.useRef(null);_.useEffect(()=>{e||(g(""),w(""),S(""),C(wk),s(null),i(!1),u(!1),R.current=!1,M(!1),F.current&&clearTimeout(F.current))},[e]),_.useEffect(()=>{if(e)return F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{C({work_order:h.trim(),requester_name:y.trim(),rating:E})},450),()=>{F.current&&clearTimeout(F.current)}},[e,h,y,E]);const z=_.useCallback(ie=>me(null,null,function*(){const fe=R.current;fe?u(!0):i(!0);try{const K={};ie.work_order&&(K.work_order=ie.work_order),ie.requester_name&&(K.requester_name=ie.requester_name),ie.rating&&(K.rating=ie.rating);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:"WO feedback",filters:K,ignore_prepared_report:1})})).json();s(ge.message||null),R.current=!0}catch(K){console.error("WO feedback report error:",K),fe||s(null)}finally{i(!1),u(!1)}}),[]);if(_.useEffect(()=>{e&&z(A)},[e,A,z]),!e)return null;const W=(a==null?void 0:a.columns)||[],X=((a==null?void 0:a.result)||[]).filter(ie=>ie&&typeof ie=="object"&&!ie.is_total_row),B=!!(h.trim()||y.trim()||E),Y=n&&!R.current,G=!Y&&X.length===0;return t.jsxs("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-600 to-teal-600 px-6 py-4 flex items-center justify-between shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ul,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:"WO Feedback Report"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>M(!0),disabled:Y||X.length===0,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-emerald-700 bg-white hover:bg-emerald-50 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[t.jsx(Ks,{size:12})," Export"]}),t.jsx("button",{type:"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 shrink-0",children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-500 mb-1",children:"Work Order"}),t.jsx(hr,{label:"Work Order",hideLabel:!0,doctype:"Work_Order",value:h,onChange:g,placeholder:"Filter by work order…",compact:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-500 mb-1",children:"Requester Name"}),t.jsx("input",{type:"text",value:y,onChange:ie=>w(ie.target.value),placeholder:"Filter by requester…",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:outline-none focus:ring-2 focus:ring-emerald-500"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-500 mb-1",children:"Rating"}),t.jsxs("select",{value:E,onChange:ie=>S(ie.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:outline-none focus:ring-2 focus:ring-emerald-500",children:[t.jsx("option",{value:"",children:"All ratings"}),z1.map(ie=>t.jsx("option",{value:ie,children:ie},ie))]})]})]}),B&&t.jsxs("button",{type:"button",onClick:()=>{g(""),w(""),S("")},className:"mt-3 text-xs text-red-500 hover:text-red-700 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(Pt,{size:10})," Clear filters"]})]}),t.jsx("div",{className:"p-6 overflow-auto flex-1 relative min-h-[240px]",children:Y?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"})}):G?t.jsx("div",{className:"text-center text-gray-400 py-16",children:"No feedback records found"}):t.jsxs("div",{className:`overflow-x-auto transition-opacity duration-200 ${c?"opacity-60":"opacity-100"}`,children:[c&&t.jsx("div",{className:"absolute top-6 right-6 z-10",children:t.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-2 border-emerald-600 border-t-transparent"})}),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:W.map((ie,fe)=>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 text-left",children:ie.label||ie.fieldname},fe))})}),t.jsx("tbody",{children:X.map((ie,fe)=>t.jsx("tr",{className:"border-b border-gray-100 dark:border-gray-700/50 hover:bg-emerald-50/40 dark:hover:bg-emerald-900/10 transition-colors",children:W.map((K,ke)=>{var ce;const re=(K.fieldname||"").toLowerCase()==="work_order",we=(ce=ie[K.fieldname])!=null?ce:"—",ee=re?String(we):"",ve=re&&ee&&ee!=="—";return t.jsx("td",{className:`py-2.5 px-4 align-top ${ve?"cursor-pointer text-emerald-600 dark:text-emerald-400 font-semibold hover:underline":"text-gray-800 dark:text-gray-200"}`,onClick:ve?()=>{window.location.href=`/asm_app/work-orders/${encodeURIComponent(ee)}`}:void 0,title:ve?`Open Work Order ${ee}`:void 0,children:ve?t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[we,t.jsx(ps,{size:9,className:"opacity-50 shrink-0"})]}):we},ke)})},fe))})]})]})})]}),t.jsx(SU,{isOpen:O,onClose:()=>M(!1),title:"WO Feedback Report",columns:W,rows:X,fileNamePrefix:"wo_feedback_report"})]})},nc=e=>{if(e==null)return!0;const r=String(e).trim().toLowerCase();return r===""||r==="null"||r==="unknown"||r==="undefined"||r==="none"},t1=new Set(["CARPENTARY","MASONRY","PAINTING","PLUMPING"]),r1="Civil works-الأعمال المدنية",AU={"Not Assigned":"",not_assigned:"",Completed:"Closed",completed:"Closed","Total Completed":"Closed",total_completed:"Closed","Completed by Contractor":"Pending Review",completed_by_contractor:"Pending Review","Total Completed by Contractor":"Pending Review","Pending with Contractor":"",pending_with_contractor:"","Pending with MOH":"Pending Review",pending_with_moh:"Pending Review","Total Pending with MOH":"Pending Review",Pending:"",pending:"","Total WO":"",total_wo:"","Total WOs":"",total_wos:"",Urgent:"",urgent_total:"","Urgent Total":"","Urgent Completed":"Closed",urgent_completed:"Closed","Urgent Pending Review":"Pending Review",urgent_pending_review:"Pending Review","Contractor Completion Rate (%)":"",contractor_completion_rate:"","Total Completion Rate (%)":"",completion_rate:"","Urgent Completion Rate (%)":"",urgent_completion_rate:"","Total WO Completion Rate %":"","Urgent WO Completion Rate %":""},js=(e,r,a)=>{const s=new URLSearchParams;return Object.entries(e).forEach(([n,i])=>{i&&s.set(n,i)}),r&&(s.set("date_filter_by","creation"),s.set("date_start",r)),a&&(s.set("date_filter_by","creation"),s.set("date_end",a)),`/asm_app/work-orders?${s.toString()}`},H1=(e,r,a)=>{const s=new URLSearchParams;return Object.entries(e).forEach(([n,i])=>{i&&s.set(n,i)}),r&&(s.set("date_filter_by","creation"),s.set("date_start",r)),a&&(s.set("date_filter_by","creation"),s.set("date_end",a)),`/asm_app/assets?${s.toString()}`},OU=()=>{var Tt;const{t:e}=Rr(),[r,a]=_.useState(null),[s,n]=_.useState(null),[i,c]=_.useState(null),[u,h]=_.useState(0),[g,y]=_.useState(null),[w,E]=_.useState(null),[S,A]=_.useState(!0),[C,O]=_.useState(!0),[M,R]=_.useState([]),[F,z]=_.useState({total:0,completed:0,planned:0,overdue:0}),[W,X]=_.useState({open:0,inProgress:0,completed:0,pendingReview:0,rejected:0,total:0,wfCompleted:0,wfInProgress:0,wfRejected:0}),[B,Y]=_.useState({assetsDown:0,avgResponseTime:0,maintenanceEfficiency:0,overdueTasks:0,plannedMaintenance:0}),{restrictions:G,isAdmin:ie}=eb("Work_Order"),fe=ea.useMemo(()=>{var He;return((He=G["Issue Type"])==null?void 0:He.values)||[]},[JSON.stringify((Tt=G["Issue Type"])==null?void 0:Tt.values)]),[K,ke]=_.useState([]);_.useEffect(()=>{me(null,null,function*(){var Fe;try{const Ze=yield fetch('/api/method/frappe.client.get_value?doctype=User&fieldname=["roles"]&filters={"name":"__user__"}'.replace("__user__",""),{credentials:"include"}),fr=(yield(yield fetch("/api/method/frappe.auth.get_logged_user",{credentials:"include"})).json()).message;if(fr){const Q=(((Fe=(yield(yield fetch(`/api/resource/User/${encodeURIComponent(fr)}?fields=["roles"]`,{headers:{Accept:"application/json"},credentials:"include"})).json()).data)==null?void 0:Fe.roles)||[]).map(he=>he.role);ke(Q)}}catch(Ze){console.error("Error fetching user roles:",Ze)}})},[]);const ge=ie||K.includes("System Manager")||K.includes("Quality Supervisor"),re=ie||K.includes("System Manager")||K.includes("Cluster Manager"),[we,ee]=_.useState(null),[ve,ce]=_.useState(null),[ye,te]=_.useState(null),[q,J]=_.useState(null),[ae,oe]=_.useState(!1),[le,be]=_.useState(!1),[Z,Le]=_.useState(null),[Pe,Be]=_.useState(null),[pe,rt]=_.useState(!1),[ct,et]=_.useState(!1),[It,ft]=_.useState(null),[Lt,Je]=_.useState(!1),[Ve,Xe]=_.useState(!1),[Rt,qe]=_.useState(null),[Dt,ar]=_.useState(!1),[yt,St]=_.useState([]),[Ot,Yt]=_.useState(""),[Ye,wt]=_.useState(""),[zt,qt]=_.useState(""),[kt,ze]=_.useState(null),[nt,_t]=_.useState(!1),[lr,pr]=_.useState(!1);_.useEffect(()=>{const He=window.setTimeout(()=>pr(!0),50);return()=>window.clearTimeout(He)},[]),_.useEffect(()=>{if(!lr)return;let He=!1;return me(null,null,function*(){_t(!0);try{const Ze=yield Xt.getDashboardChartData("WO Feedback Summary");He||ze(Ze)}catch(Ze){console.error("Error fetching WO feedback chart:",Ze)}finally{He||_t(!1)}}),()=>{He=!0}},[lr]);const Nr=_.useCallback(()=>{const He={};return!ie&&fe.length>0?He.work_order_type=fe.length===1?fe[0]:["in",fe]:Ot&&(He.work_order_type=Ot),Ye&&(He.from_date=Ye),zt&&(He.to_date=zt),He},[ie,fe,Ot,Ye,zt]),rr=_.useCallback(()=>{const He={};return Ot&&(He.work_order_type=Ot),Ye&&(He.from_date=Ye),zt&&(He.to_date=zt),He},[Ot,Ye,zt]),_r=Ot,Nt=_.useCallback(()=>{const He=[["custom_delete_status","!=","Deleted"]];return Ot&&He.push(["custom_technical_department","=",Ot]),Ye&&He.push(["creation",">=",Ye]),zt&&He.push(["creation","<=",zt]),He},[Ot,Ye,zt]);_.useEffect(()=>{let He=!1;return me(null,null,function*(){A(!0);try{const Ze=yield Xt.getDashboardWorkOrderMetrics(Nr());if(He||!Ze)return;const vt=Ze.counts||{};X({open:vt.open||0,inProgress:vt.inProgress||0,completed:vt.completed||0,pendingReview:vt.pendingReview||0,rejected:vt.rejected||0,total:vt.total||0,wfCompleted:vt.wfCompleted||0,wfInProgress:vt.wfInProgress||0,wfRejected:vt.wfRejected||0}),a(Ze.work_order_chart||null),n(Ze.work_order_grouped_chart||null),y(Ze.completion_by_type||null),Y(ir=>Ke(Te({},ir),{avgResponseTime:Ze.avg_response_time||0}))}catch(Ze){console.error("Error fetching dashboard WO metrics:",Ze)}finally{He||A(!1)}}),()=>{He=!0}},[Nr]),_.useEffect(()=>{let He=!1;return me(null,null,function*(){O(!0);try{const Ze=yield Xt.getAssetDeviceStatusSummary(rr());if(He||!Ze||Ze.error)return;c(Ze.chart||null),h(Ze.total_assets||0),Y(vt=>Ke(Te({},vt),{assetsDown:Ze.assets_down||0}))}catch(Ze){console.error("Error fetching asset status summary:",Ze)}finally{He||O(!1)}}),()=>{He=!0}},[rr]),_.useEffect(()=>{if(!re||!lr)return;let He=!1;return me(null,null,function*(){try{const Ze=yield Xt.getMaintenanceInsights(rr());if(He||!Ze||Ze.error)return;z({total:Ze.total||0,completed:Ze.completed||0,planned:Ze.planned||0,overdue:Ze.overdue||0}),Y(vt=>Ke(Te({},vt),{maintenanceEfficiency:Ze.maintenance_efficiency||0,overdueTasks:Ze.overdue||0,plannedMaintenance:Ze.planned||0}))}catch(Ze){console.error("Error fetching maintenance insights:",Ze)}}),()=>{He=!0}},[re,rr,lr]),_.useEffect(()=>{if(!Dt)return;let He=!1;return me(null,null,function*(){try{const Ze=Nt(),ir=yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({doctype:"Asset",filters:Ze,fields:["name","asset_name","custom_device_status","location","department"],limit_page_length:500,order_by:"asset_name asc"})})).json();He||R(ir.message||[])}catch(Ze){console.error("Error fetching assets for report modal:",Ze)}}),()=>{He=!0}},[Dt,Nt]),_.useEffect(()=>{if(!lr)return;me(null,null,function*(){var Fe;try{const Ze={};Ye&&(Ze.from_date=Ye),zt&&(Ze.to_date=zt);const ir=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:"Asset Maintenance Assignees Status Count",filters:Ze,ignore_prepared_report:1})})).json();if(!((Fe=ir.message)!=null&&Fe.result))return;const fr=ir.message.result.filter(Q=>Q&&typeof Q=="object"&&!Q.is_total_row),Kt=[];[{label:"Planned",color:"#6366F1",fields:["pending"]},{label:"Completed",color:"#10B981",fields:["completed_on_time","completed_within_time","delay_in_completion"]},{label:"Cancelled",color:"#F59E0B",fields:["cancelled"]},{label:"Overdue",color:"#EF4444",fields:["overdue"]}].forEach(({label:Q,color:he,fields:Se})=>{const ne=fr.reduce((_e,Ce)=>_e+Se.reduce((Qe,xt)=>Qe+(parseFloat(Ce[xt])||0),0),0);Kt.push({label:Q,color:he,total:ne})}),E({labels:Kt.map(Q=>Q.label),datasets:[{name:"Tasks",values:Kt.map(Q=>Q.total),colors:Kt.map(Q=>Q.color)}],type:"Bar",rawRows:fr})}catch(Ze){console.error("Error fetching assignees status:",Ze)}})},[Ye,zt,lr]),_.useEffect(()=>{me(null,null,function*(){try{const Ze=yield(yield fetch('/api/resource/Issue Type?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"})).json();Ze.data&&St(Ze.data.map(vt=>vt.name))}catch(Fe){console.error("Error fetching issue types:",Fe)}})},[]);const Cr=ea.useMemo(()=>Ot?null:EU(kt!=null?kt:{}),[kt,Ot]);_.useEffect(()=>{if(!lr)return;me(null,null,function*(){var Fe,Ze;try{const vt={};!ie&&fe.length>0?vt.work_order_type=fe.length===1?fe[0]:["in",fe]:Ot&&(vt.work_order_type=Ot),Ye&&(vt.from_date=Ye),zt&&(vt.to_date=zt);const fr=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:"KPI Monthly Report",filters:vt,ignore_prepared_report:1})})).json();if((Fe=fr.message)!=null&&Fe.result){const Kt=fr.message.result.filter(tt=>tt&&typeof tt=="object"&&!tt.is_total_row),Re=((Ze=fr.message)==null?void 0:Ze.columns)||[],Q=Re.find(tt=>tt.fieldname==="department")||Re[0],he=new Set(["CARPENTARY","MASONRY","PAINTING","PLUMPING"]),Se="Civil works-الأعمال المدنية",ne=[];let _e=!1;if(Kt.forEach(tt=>{const gt=tt[Q==null?void 0:Q.fieldname]||"Unknown";if(gt===Se){if(!_e){const Wt={label:Se};Re.forEach(Ft=>{Ft!=null&&Ft.fieldname&&Ft.fieldname!=="department"&&(Wt[Ft.fieldname]=0)}),Kt.forEach(Ft=>{const Zt=Ft[Q==null?void 0:Q.fieldname]||"Unknown";(he.has(Zt)||Zt===Se)&&Re.forEach(br=>{br!=null&&br.fieldname&&br.fieldname!=="department"&&(Wt[br.fieldname]=(Wt[br.fieldname]||0)+(parseFloat(Ft[br.fieldname])||0))})}),ne.push(Wt),_e=!0}}else if(!nc(gt)){const Wt={label:gt};Re.forEach(Ft=>{Ft!=null&&Ft.fieldname&&Ft.fieldname!=="department"&&(Wt[Ft.fieldname]=parseFloat(tt[Ft.fieldname])||0)}),ne.push(Wt)}}),!_e){const tt={label:Se};Re.forEach(gt=>{gt!=null&&gt.fieldname&&gt.fieldname!=="department"&&(tt[gt.fieldname]=0)}),Kt.forEach(gt=>{const Wt=gt[Q==null?void 0:Q.fieldname]||"Unknown";(he.has(Wt)||Wt===Se)&&Re.forEach(Ft=>{Ft!=null&&Ft.fieldname&&Ft.fieldname!=="department"&&(tt[Ft.fieldname]=(tt[Ft.fieldname]||0)+(parseFloat(gt[Ft.fieldname])||0))})}),ne.unshift(tt)}ne.forEach(tt=>{tt.total_wo>0?(tt.completion_rate=parseFloat((tt.total_completed/tt.total_wo*100).toFixed(2)),tt.contractor_completion_rate=parseFloat((tt.completed_by_contractor/tt.total_wo*100).toFixed(2)),tt.urgent_completion_rate=tt.urgent_total>0?parseFloat((tt.urgent_completed/tt.urgent_total*100).toFixed(2)):0):(tt.completion_rate=0,tt.contractor_completion_rate=0,tt.urgent_completion_rate=0)});const Ce=ne.filter(tt=>!nc(tt.label)),Qe=Ce.map(tt=>tt.label),xt=[{name:"Total WO",values:Ce.map(tt=>tt.total_wo||0),color:"#6366F1"},{name:"Total Completed",values:Ce.map(tt=>tt.total_completed||0),color:"#10B981"},{name:"Pending with Contractor",values:Ce.map(tt=>tt.pending_with_contractor||0),color:"#F97316"}].filter(tt=>tt.values.some(gt=>gt>0)),dt=["#6366F1","#10B981","#F59E0B","#EF4444","#3B82F6","#EC4899","#8B5CF6","#06B6D4","#F97316","#14B8A6","#A855F7","#0EA5E9"],$e=Re.filter(tt=>(tt==null?void 0:tt.fieldname)&&tt.fieldname!=="department"&&["Int","Float","Percent","Currency"].includes(tt.fieldtype)).map((tt,gt)=>({name:tt.fieldname==="urgent_pending_review"?"Pending":tt.fieldname==="urgent_completed"?"Completed":tt.fieldname==="urgent_total"?"Urgent":tt.label||tt.fieldname,values:Ce.map(Wt=>parseFloat(Wt[tt.fieldname])||0),color:dt[gt%dt.length]})).filter(tt=>tt.values.some(gt=>gt>0));ee({labels:Qe,datasets:xt,allDatasets:$e,type:"Bar"})}}catch(vt){console.error("Error fetching KPI monthly:",vt)}})},[fe,ie,Ot,Ye,zt,lr]),_.useEffect(()=>{if(!lr)return;me(null,null,function*(){var Fe,Ze;try{const vt={};Ot&&(vt.custom_expertise=Ot),Ye&&(vt.from_date=Ye),zt&&(vt.to_date=zt);const fr=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:"PPM KPI Report",filters:vt,ignore_prepared_report:1})})).json();if((Fe=fr.message)!=null&&Fe.result){const Kt=fr.message.result.filter(ne=>ne&&typeof ne=="object"&&!ne.is_total_row),Re=((Ze=fr.message)==null?void 0:Ze.columns)||[],Q=Re.find(ne=>ne.fieldname==="Department"||ne.fieldname==="department")||Re[0],he=Kt.map(ne=>ne[Q==null?void 0:Q.fieldname]||"Unknown"),Se=[{name:"Total WOs",values:Kt.map(ne=>parseFloat(ne["Total WOs"])||0),color:"#6366F1"},{name:"Completed",values:Kt.map(ne=>parseFloat(ne.Completed)||0),color:"#10B981"},{name:"Pending",values:Kt.map(ne=>parseFloat(ne.Pending)||0),color:"#F59E0B"}];ce({labels:he,datasets:Se,type:"Bar"})}}catch(vt){console.error("Error fetching PPM KPI:",vt)}})},[fe,ie,Ot,Ye,zt,lr]),_.useEffect(()=>{if(!lr)return;me(null,null,function*(){var Fe;try{const Ze={};!ie&&fe.length>0?Ze.work_order_type=fe.length===1?fe[0]:["in",fe]:Ot&&(Ze.work_order_type=Ot),Ye&&(Ze.from_date=Ye),zt&&(Ze.to_date=zt);const ir=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:Ze,ignore_prepared_report:1})})).json();if((Fe=ir.message)!=null&&Fe.result){const fr=ir.message.result.filter(Q=>Q&&typeof Q=="object"&&!Q.is_total_row),Kt=fr.map(Q=>Q.technician_name||"Unknown"),Re=fr.map(Q=>parseFloat(Q.total_hours)||0);te({labels:Kt,datasets:[{name:"Total Hours",values:Re,colors:["#6366F1"]}],type:"Bar"})}}catch(Ze){console.error("Error fetching technician hours:",Ze)}})},[fe,ie,Ot,Ye,zt,lr]),_.useEffect(()=>{if(!lr)return;me(null,null,function*(){var Fe;try{const Ze={};!ie&&fe.length>0?Ze.work_order_type=fe.length===1?fe[0]:["in",fe]:Ot&&(Ze.work_order_type=Ot),Ye&&(Ze.from_date=Ye),zt&&(Ze.to_date=zt);const ir=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:Ze,ignore_prepared_report:1})})).json();if((Fe=ir.message)!=null&&Fe.result){const fr=ir.message.result.filter(Q=>Q&&typeof Q=="object"&&!Q.is_total_row),Kt=fr.map(Q=>Q.assigned_technician||"Unknown"),Re=[{name:"completed",values:fr.map(Q=>parseFloat(Q.completed)||0),color:"#10B981"},{name:"in_progress",values:fr.map(Q=>parseFloat(Q.in_progress)||0),color:"#3B82F6"},{name:"open",values:fr.map(Q=>parseFloat(Q.open)||0),color:"#F59E0B"}].filter(Q=>Q.values.some(he=>he>0));J({labels:Kt,datasets:Re,type:"Bar"})}}catch(Ze){console.error("Error fetching technician worked:",Ze)}})},[fe,ie,Ot,Ye,zt,lr]);const yr=(He,Fe)=>{var ir,fr;const Ze=He.find(Kt=>(Kt==null?void 0:Kt.fieldname)&&(Kt.fieldname.toLowerCase().includes("work_order_type")||Kt.fieldname.toLowerCase().includes("wo_type")||Kt.fieldname.toLowerCase()==="type"));if(Ze)return Ze.fieldname;const vt=He.find(Kt=>(Kt==null?void 0:Kt.label)&&(Kt.label.toLowerCase().includes("wo type")||Kt.label.toLowerCase().includes("work order type")||Kt.label.toLowerCase()==="type"));return vt?vt.fieldname:(ir=He[1])!=null&&ir.fieldname?He[1].fieldname:((fr=He[0])==null?void 0:fr.fieldname)||Object.keys(Fe[0]||{})[0]||"name"},jt=(He,Fe,Ze)=>{var Kt;const vt=Re=>typeof Re=="number"&&!isNaN(Re)||typeof Re=="string"&&Re!==""&&!isNaN(parseFloat(Re)),ir=He.filter(Re=>(Re==null?void 0:Re.fieldname)&&Re.fieldname!==Ze&&Fe.some(Q=>vt(Q[Re.fieldname]))),fr=ir.find(Re=>{const Q=((Re.label||"")+(Re.fieldname||"")).toLowerCase();return Q.includes("count")||Q.includes("linked")||Q.includes("inspection")||Q.includes("rejection")||Q.includes("total")||Q.includes("wo")});return fr?fr.fieldname:((Kt=ir[0])==null?void 0:Kt.fieldname)||null};return _.useEffect(()=>{if(!ge||!lr)return;me(null,null,function*(){var Fe,Ze;try{const vt={};!ie&&fe.length>0?vt.work_order_type=fe.length===1?fe[0]:fe:Ot&&(vt.work_order_type=Ot),Ye&&(vt.from_date=Ye),zt&&(vt.to_date=zt);const fr=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:vt,ignore_prepared_report:1})})).json();if((Fe=fr.message)!=null&&Fe.result){const Kt=fr.message.result.filter(Qe=>Qe&&typeof Qe=="object"&&!Qe.is_total_row),Re=((Ze=fr.message)==null?void 0:Ze.columns)||[],Q=yr(Re,Kt),he=jt(Re,Kt,Q),Se={};Kt.forEach(Qe=>{const xt=Qe[Q]!==null&&Qe[Q]!==void 0&&Qe[Q]!==""?String(Qe[Q]):"(No Type)",dt=he&&parseFloat(Qe[he])||0;Se[xt]=(Se[xt]||0)+dt});const ne=Object.keys(Se),_e=Object.values(Se),Ce=Re.find(Qe=>(Qe==null?void 0:Qe.fieldname)===he);Le({labels:ne,datasets:[{name:(Ce==null?void 0:Ce.label)||"Count",values:_e}],rawRows:Kt,columns:Re,type:"Bar"})}}catch(vt){console.error("Error fetching inspection summary:",vt)}})},[ge,fe,ie,Ot,Ye,zt,lr]),_.useEffect(()=>{if(!ge||!lr)return;me(null,null,function*(){var Fe,Ze;try{const vt={};!ie&&fe.length>0?vt.work_order_type=fe.length===1?fe[0]:fe:Ot&&(vt.work_order_type=Ot),Ye&&(vt.from_date=Ye),zt&&(vt.to_date=zt);const fr=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:vt,ignore_prepared_report:1})})).json();if((Fe=fr.message)!=null&&Fe.result){const Kt=fr.message.result.filter($e=>$e&&typeof $e=="object"&&!$e.is_total_row),Re=((Ze=fr.message)==null?void 0:Ze.columns)||[],Q=yr(Re,Kt),he=$e=>typeof $e=="number"&&!isNaN($e)||typeof $e=="string"&&$e!==""&&!isNaN(parseFloat($e)),Se=$e=>{if(!($e!=null&&$e.fieldname)||$e.fieldname===Q||!Kt.length)return!1;if($e.fieldtype&&["Int","Float","Currency","Percent"].includes($e.fieldtype))return!0;const tt=Kt.find(gt=>gt[$e.fieldname]!=null&&gt[$e.fieldname]!=="");return tt?he(tt[$e.fieldname]):!1},ne=Re.filter(Se),_e=ne.length>0?ne:Re.filter($e=>{if(!($e!=null&&$e.fieldname)||$e.fieldname===Q||!Kt.length)return!1;const tt=Kt.find(gt=>gt[$e.fieldname]!=null&&gt[$e.fieldname]!=="");return tt?!isNaN(parseFloat(String(tt[$e.fieldname]))):!1}),Ce={};Kt.forEach($e=>{const tt=$e[Q]!==null&&$e[Q]!==void 0&&$e[Q]!==""?String($e[Q]):"(No Type)";Ce[tt]||(Ce[tt]={}),_e.forEach(gt=>{Ce[tt][gt.fieldname]=(Ce[tt][gt.fieldname]||0)+(parseFloat($e[gt.fieldname])||0)})});const Qe=(()=>{var tt;const $e=_e.find(gt=>{const Wt=((gt.label||"")+(gt.fieldname||"")).toLowerCase();return Wt.includes("total_rejected")||Wt.includes("total rejected")||Wt.includes("rejected")});return($e==null?void 0:$e.fieldname)||((tt=_e[_e.length-1])==null?void 0:tt.fieldname)||null})(),xt=Object.keys(Ce),dt=xt.map($e=>Qe&&Ce[$e][Qe]||0),at=dt.reduce(($e,tt)=>$e+tt,0);Be({labels:xt,datasets:[{name:"Total Rejected",values:dt}],totalRejected:at,rawRows:Kt,columns:Re,type:"Bar"})}}catch(vt){console.error("Error fetching rejection summary:",vt)}})},[ge,fe,ie,Ot,Ye,zt,lr]),_.useEffect(()=>{if(!re||!lr)return;me(null,null,function*(){var Fe,Ze,vt;try{const ir={};!ie&&fe.length>0?ir.work_order_type=fe.length===1?fe[0]:fe:Ot&&(ir.work_order_type=Ot),Ye&&(ir.from_date=Ye),zt&&(ir.to_date=zt);const Kt=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:ir,ignore_prepared_report:1})})).json();if((Fe=Kt.message)!=null&&Fe.result){const Re=Kt.message.result.filter($e=>$e&&typeof $e=="object"&&!$e.is_total_row),Q=((Ze=Kt.message)==null?void 0:Ze.columns)||[],he=Q.find($e=>{const tt=(($e.label||"")+($e.fieldname||"")).toLowerCase();return tt.includes("wo_type")||tt.includes("wo type")||tt.includes("work_order_type")||tt.includes("work order type")})||Q[1],Se=Q.find($e=>{const tt=(($e.label||"")+($e.fieldname||"")).toLowerCase();return tt.includes("time_to_repair")||tt.includes("time to repair")||tt.includes("repair_time")||tt.includes("hours")})||Q[Q.length-1],ne={};Re.forEach($e=>{const tt=he?$e[he.fieldname]:null;if(nc(tt))return;const gt=String(tt),Wt=Se&&parseFloat($e[Se.fieldname])||0;ne[gt]||(ne[gt]={total:0,count:0}),ne[gt].total+=Wt,ne[gt].count+=1});const _e=Object.keys(ne),Ce=_e.map($e=>parseFloat((ne[$e].total/ne[$e].count).toFixed(3))),Qe=Re.filter($e=>!nc(he?$e[he.fieldname]:null)),xt=Qe.length>0?parseFloat((Qe.reduce(($e,tt)=>$e+(Se&&parseFloat(tt[Se.fieldname])||0),0)/Qe.length).toFixed(3)):0,dt=((vt=Kt.message)==null?void 0:vt.report_summary)||[],at=dt.find($e=>{var tt,gt;return((tt=$e.label)==null?void 0:tt.toLowerCase().includes("avg"))||((gt=$e.label)==null?void 0:gt.toLowerCase().includes("overall"))});ft({labels:_e,datasets:[{name:"Avg Time to Repair (hrs)",values:Ce}],overallAvg:at&&parseFloat(at.value)||xt,rawRows:Re,columns:Q,reportSummary:dt,type:"Bar"})}}catch(ir){console.error("Error fetching time to repair:",ir)}})},[re,fe,ie,Ot,Ye,zt,lr]),t.jsxs("div",{className:"min-h-screen w-full min-w-0 overflow-x-hidden bg-gray-50 dark:bg-gray-900 p-3 sm:p-6",children:[t.jsxs("div",{className:"max-w-[1600px] mx-auto w-full min-w-0",children:[(ie||fe.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-3 py-3 sm:px-5 mb-5 flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center sm:gap-4 w-full min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400 shrink-0",children:[t.jsx("div",{className:"w-7 h-7 bg-indigo-50 dark:bg-indigo-900/30 rounded-lg flex items-center justify-center shrink-0",children:t.jsx(Hs,{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 flex-col gap-1.5 min-w-0 w-full sm:w-auto sm:min-w-[12rem] sm:max-w-md sm:flex-1",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Technical Department"}),t.jsxs("select",{value:Ot,onChange:He=>Yt(He.target.value),className:"w-full min-w-0 max-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-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:e("dashboard.allDepartments","All Departments")}),yt.map(He=>t.jsx("option",{value:He,children:He},He))]})]}),Ot&&t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 min-w-0 w-full sm:w-auto",children:[t.jsxs("button",{type:"button",onClick:()=>Yt(""),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 shrink-0 self-start",children:[t.jsx(Pt,{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 min-w-0 max-w-full break-words",title:Ot,children:Ot})]}),t.jsxs("div",{className:"flex flex-col gap-1.5 min-w-0 w-full sm:w-auto",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"From Date"}),t.jsx("input",{type:"date",value:Ye,onChange:He=>wt(He.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-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{className:"flex flex-col gap-1.5 min-w-0 w-full sm:w-auto",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"To Date"}),t.jsx("input",{type:"date",value:zt,onChange:He=>qt(He.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-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),(Ye||zt)&&t.jsxs("button",{type:"button",onClick:()=>{wt(""),qt("")},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 shrink-0 self-end",children:[t.jsx(Pt,{size:10})," Clear Dates"]})]}),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(pd,{icon:t.jsx(_1,{className:"text-indigo-600"}),value:C?"—":u,label:e("dashboard.totalAssets"),bgColor:"bg-indigo-50 dark:bg-indigo-900/20",iconColor:"text-indigo-600",href:H1(_r?{technical_department:_r}:{},Ye,zt)}),t.jsx(pd,{icon:t.jsx(nT,{className:"text-amber-500"}),value:S?"—":W.open,label:e("dashboard.openWorkOrders"),bgColor:"bg-amber-50 dark:bg-amber-900/20",iconColor:"text-amber-500",href:js({status:"Open"},Ye,zt)}),t.jsx(pd,{icon:t.jsx(Ja,{className:"text-blue-600"}),value:S?"—":W.inProgress,label:e("dashboard.workOrdersInProgress"),bgColor:"bg-blue-50 dark:bg-blue-900/20",iconColor:"text-blue-600",href:js({status:"Work In Progress"},Ye,zt)}),t.jsx(pd,{icon:t.jsx(Jr,{className:"text-orange-500"}),value:S?"—":W.pendingReview,label:e("dashboard.pendingReviewWorkOrders","Pending Review"),bgColor:"bg-orange-50 dark:bg-orange-900/20",iconColor:"text-orange-500",href:js({status:"Pending Review"},Ye,zt)}),t.jsx(pd,{icon:t.jsx(Tr,{className:"text-emerald-600"}),value:S?"—":W.completed,label:e("dashboard.closedWorkOrders"),bgColor:"bg-emerald-50 dark:bg-emerald-900/20",iconColor:"text-emerald-600",href:js({status:"Closed"},Ye,zt)}),t.jsx(pd,{icon:t.jsx(po,{className:"text-red-500"}),value:S?"—":W.rejected,label:e("dashboard.rejectedWorkOrders","Rejected WOs"),bgColor:"bg-red-50 dark:bg-red-900/20",iconColor:"text-red-500",href:js({status:"Rejected"},Ye,zt)}),t.jsx(pd,{icon:t.jsx(X4,{className:"text-purple-600"}),value:S?"—":W.total,label:e("dashboard.totalWorkOrders"),bgColor:"bg-purple-50 dark:bg-purple-900/20",iconColor:"text-purple-600",href:js({},Ye,zt)})]})})}),t.jsx("div",{className:"col-span-12 lg:col-span-5 lg:row-span-2 flex",children:t.jsx(LU,{className:"flex-1 w-full",data:r,loading:S,totalWorkOrders:W.total,completedWorkOrders:W.completed,onOpenReport:()=>qe({title:"Work Order Status Distribution",data:r,redirectContext:"wo_status"})})}),t.jsx("div",{className:"col-span-12 lg:col-span-7 flex",children:t.jsx(RU,{className:"flex-1 w-full",loading:S,totalWorkOrders:W.total,completedWorkOrders:W.wfCompleted,inProgressWorkOrders:W.wfInProgress,rejectedWorkOrders:W.wfRejected,byTypeChartData:g,onOpenReport:()=>{const He=(g==null?void 0:g.rates)||[];qe({title:e("dashboard.completionRate","Completion Rate by Department"),redirectContext:"wo_type",data:{labels:He.map(Fe=>Fe.type),datasets:[{name:"Completion Rate (%)",values:He.map(Fe=>parseFloat(Fe.rate.toFixed(2)))},{name:"WF Completed",values:He.map(Fe=>Fe.wfCompleted)},{name:"In Progress",values:He.map(Fe=>Fe.wfInProgress)},{name:"Rejected (WF)",values:He.map(Fe=>Fe.wfRejected)},{name:"Closed WOs",values:He.map(Fe=>Fe.closed)},{name:"Pending Review",values:He.map(Fe=>Fe.pendingReview)},{name:"Open",values:He.map(Fe=>Fe.open)},{name:"Total",values:He.map(Fe=>Fe.total)}],hideFooterTotal:!0}})}})}),t.jsx("div",{className:"col-span-12 lg:col-span-7 flex",children:t.jsx(IU,{className:"flex-1 w-full",loading:S,totalWorkOrders:W.total,closedWorkOrders:W.completed,inProgressWorkOrders:W.inProgress,rejectedWorkOrders:W.rejected,byTypeChartData:g,onOpenReport:()=>{const He=(g==null?void 0:g.rates)||[];qe({title:"Overall Completion Rate by Department",redirectContext:"wo_type",data:{labels:He.map(Fe=>Fe.type),datasets:[{name:"Completion Rate (%)",values:He.map(Fe=>parseFloat((Fe.closed/(Fe.total||1)*100).toFixed(2)))},{name:"Closed WOs",values:He.map(Fe=>Fe.closed)},{name:"In Progress",values:He.map(Fe=>Fe.inProgress)},{name:"Rejected",values:He.map(Fe=>Fe.rejected)},{name:"Total WOs",values:He.map(Fe=>Fe.total)}],hideFooterTotal:!0}})}})}),t.jsx("div",{className:"col-span-12 lg:col-span-5 flex",children:t.jsx(BU,{className:"flex-1 w-full",data:i,loading:C,totalAssets:u,onOpenReport:()=>ar(!0)})})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-5",children:[t.jsx(bm,{icon:t.jsx(Jr,{className:"text-red-500"}),title:e("dashboard.assetsDown","Assets Down"),value:B.assetsDown,trend:B.assetsDown===0?"All Operational":B.assetsDown<=3?"Low":"High Priority",trendUp:B.assetsDown===0,bgColor:"bg-red-50 dark:bg-red-900/20"}),t.jsx(bm,{icon:t.jsx(Ja,{className:"text-blue-500"}),title:e("dashboard.avgResponseTime"),value:B.avgResponseTime>0?`${B.avgResponseTime.toFixed(1)} hrs`:"N/A",trend:B.avgResponseTime>0&&B.avgResponseTime<4?"Fast Response":"Monitor",trendUp:B.avgResponseTime>0&&B.avgResponseTime<4,bgColor:"bg-blue-50 dark:bg-blue-900/20"}),t.jsx(bm,{icon:t.jsx(e3,{className:"text-orange-500"}),title:e("dashboard.maintenanceEfficiency"),value:`${B.maintenanceEfficiency.toFixed(1)}%`,trend:B.maintenanceEfficiency>=70?"On Track":"Needs Attention",trendUp:B.maintenanceEfficiency>=70,bgColor:"bg-orange-50 dark:bg-orange-900/20"}),t.jsx(bm,{icon:t.jsx(Jr,{className:"text-rose-500"}),title:e("dashboard.overdueMaintenance"),value:B.overdueTasks,trend:B.overdueTasks===0?"All Clear":B.overdueTasks<=3?"Low":"High Priority",trendUp:B.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(_k,{title:e("dashboard.workOrderStatus"),data:s,loading:S,onOpenReport:()=>qe({title:e("dashboard.workOrderStatus"),data:s,redirectContext:"wo_type"})}),t.jsx(_k,{title:e("dashboard.assigneesStatus"),data:w,onOpenReport:()=>qe({title:e("dashboard.assigneesStatus"),data:w})})]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-5",children:[t.jsx(IB,{kpiMonthlyChartData:we,dashFromDate:Ye,chartElement:t.jsx($1,{data:we}),onOpenDetail:He=>qe({title:"KPI Monthly Report",data:Ke(Te({},we),{datasets:(we==null?void 0:we.allDatasets)||(we==null?void 0:we.datasets)}),redirectContext:"wo_type",showPendingPopover:!0,onExportExcel:He})}),t.jsx(MB,{ppmKpiChartData:ve,dashFromDate:Ye,chartElement:t.jsx($1,{data:ve}),onOpenDetail:He=>qe({title:"PPM KPI Report",data:ve,redirectContext:"ppm_type",showPendingPopover:!1,onExportExcel:He})})]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-5",children:[t.jsx(WU,{title:e("dashboard.technicianWorkingHours","Technicians Working Hours"),data:ye,onOpenReport:()=>oe(!0)}),t.jsx(HU,{title:e("dashboard.techniciansWorked","Technicians Work Summary"),data:q,onOpenReport:()=>be(!0)})]}),ge&&t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-5",children:[t.jsx(GU,{title:e("dashboard.inspectionLinkedWOSummary","Inspection Linked Work Orders Summary"),data:Z,onOpenReport:()=>rt(!0)}),t.jsx(YU,{title:e("dashboard.woRejectionSummary","WO Rejection Summary"),data:Pe,onOpenReport:()=>et(!0)})]}),re&&t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-5",children:[t.jsx(ZU,{data:It,onOpenReport:()=>Je(!0)}),t.jsx(PU,{insights:B,maintenanceSummary:F})]}),!Ot&&t.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-5",children:t.jsx(DU,{title:"WO Feedback Report",data:Cr,loading:nt,onOpenReport:()=>Xe(!0)})})]}),t.jsx(RB,{isOpen:ae,onClose:()=>oe(!1),permittedIssueTypes:fe,isAdmin:ie,defaultWorkOrderType:Ot,defaultFromDate:Ye,defaultToDate:zt}),t.jsx(FB,{isOpen:le,onClose:()=>be(!1),permittedIssueTypes:fe,isAdmin:ie,defaultWorkOrderType:Ot,defaultFromDate:Ye,defaultToDate:zt}),ge&&t.jsx(qU,{isOpen:pe,onClose:()=>rt(!1),permittedIssueTypes:fe,isAdmin:ie,defaultWorkOrderType:Ot,defaultFromDate:Ye,defaultToDate:zt}),ge&&t.jsx(XU,{isOpen:ct,onClose:()=>et(!1),permittedIssueTypes:fe,isAdmin:ie,defaultWorkOrderType:Ot,defaultFromDate:Ye,defaultToDate:zt}),re&&t.jsx(KU,{isOpen:Lt,onClose:()=>Je(!1),permittedIssueTypes:fe,isAdmin:ie,defaultWorkOrderType:Ot,defaultFromDate:Ye,defaultToDate:zt}),t.jsx(TU,{isOpen:Ve,onClose:()=>Xe(!1)}),t.jsx(UU,{isOpen:Dt,onClose:()=>ar(!1),assets:M,chartData:i,fromDate:Ye,toDate:zt,technicalDepartment:_r}),t.jsx(VU,{isOpen:!!Rt,onClose:()=>qe(null),title:(Rt==null?void 0:Rt.title)||"",data:Rt==null?void 0:Rt.data,redirectContext:Rt==null?void 0:Rt.redirectContext,fromDate:Ye,toDate:zt,showPendingPopover:Rt==null?void 0:Rt.showPendingPopover,wide:(Rt==null?void 0:Rt.title)==="KPI Monthly Report",onExportExcel:Rt==null?void 0:Rt.onExportExcel})]})},DU=({title:e,data:r,loading:a=!1,onOpenReport:s})=>{var S,A,C,O,M;const{t:n}=Rr(),[i,c]=_.useState(!1);_.useEffect(()=>{const R=()=>c(!1);if(i)return document.addEventListener("click",R),()=>document.removeEventListener("click",R)},[i]);const u=(r==null?void 0:r.labels)||[],h=((A=(S=r==null?void 0:r.datasets)==null?void 0:S[0])==null?void 0:A.values)||[],g=((M=(O=(C=r==null?void 0:r.datasets)==null?void 0:C[0])==null?void 0:O.colors)==null?void 0:M.length)===h.length?r.datasets[0].colors:u.map(R=>W1(R)),y=h.reduce((R,F)=>R+F,0),w=Math.max(...h,1),E=R=>{var z;const F=(z=R.split("/")[0])==null?void 0:z.trim();return F&&F.length<R.length?F:R};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",{type:"button",onClick:s,className:"w-10 h-10 bg-emerald-50 dark:bg-emerald-900/20 rounded-xl flex items-center justify-center hover:bg-emerald-100 dark:hover:bg-emerald-900/30 transition-colors group",children:t.jsx(ul,{className:"text-emerald-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:e}),t.jsxs("p",{className:"text-xs text-gray-400",children:["Total: ",t.jsxs("span",{className:"font-bold text-emerald-600 dark:text-emerald-400",children:[y," responses"]})]})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),c(!i)},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"})})}),i&&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",{type:"button",onClick:R=>{R.stopPropagation(),c(!1),s==null||s()},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(ps,{className:"text-gray-400",size:12}),n("dashboard.viewFullReport","View Full Report")]})})]})]}),t.jsxs("div",{className:"bg-gradient-to-r from-emerald-50 to-teal-50 dark:from-emerald-900/20 dark:to-teal-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-emerald-700 dark:text-emerald-300",children:"Total Feedback Responses"}),t.jsx("span",{className:"text-2xl font-bold text-emerald-600 dark:text-emerald-400",children:y})]}),a?t.jsx("div",{className:"h-40 flex items-center justify-center text-gray-400",children:t.jsxs("div",{className:"text-center",children:[t.jsx(ul,{className:"text-3xl mx-auto mb-1 opacity-20"}),t.jsx("div",{className:"text-xs",children:n("dashboard.loading","Loading…")})]})}):u.length?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"space-y-2 max-h-56 overflow-y-auto",children:u.map((R,F)=>{const z=h[F]||0,W=w>0?z/w*100:0,X=g[F]||W1(R),B=Math.max(W,z>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:`${B}%`,backgroundColor:X,opacity:.88},children:W>28&&t.jsx("span",{className:"text-[9px] font-bold text-white whitespace-nowrap",children:z})}),W<=28&&t.jsx("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:z})]}),t.jsx("div",{className:"w-36 text-[11px] text-gray-700 dark:text-gray-200 font-medium truncate flex-shrink-0",title:R,children:E(R)})]},F)})}),u.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:u.map((R,F)=>t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("div",{className:"w-2 h-2 rounded-sm shrink-0",style:{backgroundColor:g[F]}}),t.jsx("span",{className:"text-[9px] text-gray-400 truncate max-w-[90px]",title:R,children:E(R)})]},F))})]}):t.jsx("div",{className:"h-40 flex items-center justify-center text-gray-400 text-sm",children:n("dashboard.noDataAvailable","No data available")})]})},pd=({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 →"})]})},bm=({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(K8,{className:"text-[9px]"}):t.jsx(Z8,{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})]}),th=({className:e="h-48"})=>t.jsx("div",{className:`${e} flex items-center justify-center`,children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-indigo-600"})}),RU=({totalWorkOrders:e,completedWorkOrders:r,inProgressWorkOrders:a,rejectedWorkOrders:s,byTypeChartData:n,loading:i,onOpenReport:c,className:u=""})=>{var y;const{t:h}=Rr(),g=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 ${u}`,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(X4,{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:[g,"%"]}),t.jsx("div",{className:"text-xs font-semibold text-indigo-600 dark:text-indigo-400 uppercase tracking-wide",children:h("dashboard.completionRate","Workflow Completion Rate")})]})]}),c&&t.jsx("button",{onClick:c,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:"View Detail",children:t.jsx(ps,{className:"text-gray-400 text-xs"})})]}),i?t.jsx(th,{className:"h-28"}):n&&((y=n.rates)==null?void 0:y.length)>0?t.jsx(FU,{data:n}):t.jsx("div",{className:"h-28 flex items-center justify-center text-gray-400 text-xs",children:h("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"})]})]})]})},FU=({data:e})=>{const{t:r}=Rr(),[a,s]=ea.useState(null),n=ea.useRef(null),[i,c]=ea.useState(null),u=((e==null?void 0:e.rates)||[]).filter(X=>!nc(X.type));if(!u.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 h=Qc(u.length),g=110,y=32,w=12,E=10,A=g-E-28,C=u.length,O=Math.max(260,C*72+y+w),R=(O-y-w)/C,F=Math.min(44,R*.55),z=[0,.25,.5,.75,1],W=(X,B)=>{if(s(X),n.current){const Y=n.current.getBoundingClientRect(),ie=B.currentTarget.ownerSVGElement.getBoundingClientRect(),fe=ie.width/O,K=ie.left-Y.left+(y+X*R+R/2)*fe;c({x:K,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:g,viewBox:`0 0 ${O} ${g}`,preserveAspectRatio:"xMidYMid meet",className:"w-full",onMouseLeave:()=>{s(null),c(null)},children:[z.map((X,B)=>{const Y=E+A-X*A;return t.jsxs("g",{children:[t.jsx("line",{x1:y,y1:Y,x2:O-w,y2:Y,stroke:"#E5E7EB",strokeWidth:"1"}),t.jsxs("text",{x:y-3,y:Y+3,textAnchor:"end",fontSize:"7",fill:"#9CA3AF",children:[Math.round(X*100),"%"]})]},B)}),t.jsx("line",{x1:y,y1:E+A,x2:O-w,y2:E+A,stroke:"#D1D5DB",strokeWidth:"1"}),u.map((X,B)=>{const Y=Math.max(0,X.rate/100*A),G=y+B*R+R/2,ie=G-F/2,fe=E+A-Y,K=h[B],ke=a===B;return t.jsxs("g",{onMouseEnter:ge=>W(B,ge),style:{cursor:"pointer"},children:[t.jsx("rect",{x:y+B*R,y:E,width:R,height:A,fill:"transparent"}),t.jsx("rect",{x:ie,y:Y>0?fe:E+A-1,width:F,height:Y>0?Y:1,fill:K,rx:"4",ry:"4",opacity:ke?1:.8,style:{transition:"opacity 0.15s, filter 0.15s",filter:ke?"brightness(1.15)":"none"}}),Y>14&&t.jsxs("text",{x:G,y:fe-3,textAnchor:"middle",fontSize:"7.5",fontWeight:"700",fill:K,children:[X.rate.toFixed(1),"%"]}),t.jsx("text",{x:G,y:E+A+12,textAnchor:"middle",fontSize:"6.5",fill:ke?K:"#6B7280",fontWeight:ke?"700":"400",children:(X.type||"").length>11?(X.type||"").substring(0,9)+"…":X.type||""})]},B)})]})}),a!==null&&i&&u[a]&&(()=>{const X=u[a],B=h[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:B}}),t.jsx("span",{className:"font-semibold text-[11px] truncate max-w-[120px]",children:X.type})]}),t.jsxs("div",{className:"text-green-400 font-bold text-sm text-center mb-0.5",children:["WF: ",X.rate.toFixed(2),"%"]}),t.jsxs("div",{className:"text-gray-300 text-[10px] text-center",children:[X.wfCompleted," done · ",X.wfInProgress," prog · ",X.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:u.map((X,B)=>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:h[B]}}),t.jsx("span",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:(X.type||"").length>22?(X.type||"").substring(0,20)+"…":X.type||""})]},B))})]})},IU=({totalWorkOrders:e,closedWorkOrders:r,inProgressWorkOrders:a,rejectedWorkOrders:s,byTypeChartData:n,loading:i,onOpenReport:c,className:u=""})=>{var y;const{t:h}=Rr(),g=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 ${u}`,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(Tr,{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:[g,"%"]}),t.jsx("div",{className:"text-xs font-semibold text-emerald-600 dark:text-emerald-400 uppercase tracking-wide",children:"Overall Completion Rate"})]})]}),c&&t.jsx("button",{onClick:c,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:"View Detail",children:t.jsx(ps,{className:"text-gray-400 text-xs"})})]}),i?t.jsx(th,{className:"h-28"}):n&&((y=n.rates)==null?void 0:y.length)>0?t.jsx(MU,{data:n}):t.jsx("div",{className:"h-28 flex items-center justify-center text-gray-400 text-xs",children:h("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"})]})]})]})},MU=({data:e})=>{const{t:r}=Rr(),[a,s]=ea.useState(null),n=ea.useRef(null),[i,c]=ea.useState(null),u=((e==null?void 0:e.rates)||[]).filter(B=>!nc(B.type));if(!u.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 h=u.map(B=>({type:B.type,total:B.total,closed:B.closed,inProgress:B.inProgress,rejected:B.rejected,rate:B.total>0?B.closed/B.total*100:0})),g=Qc(h.length),y=110,w=32,E=12,S=10,C=y-S-28,O=h.length,M=Math.max(260,O*72+w+E),F=(M-w-E)/O,z=Math.min(44,F*.55),W=[0,.25,.5,.75,1],X=(B,Y)=>{if(s(B),n.current){const G=n.current.getBoundingClientRect(),fe=Y.currentTarget.ownerSVGElement.getBoundingClientRect(),K=fe.width/M,ke=fe.left-G.left+(w+B*F+F/2)*K;c({x:ke,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:y,viewBox:`0 0 ${M} ${y}`,preserveAspectRatio:"xMidYMid meet",className:"w-full",onMouseLeave:()=>{s(null),c(null)},children:[W.map((B,Y)=>{const G=S+C-B*C;return t.jsxs("g",{children:[t.jsx("line",{x1:w,y1:G,x2:M-E,y2:G,stroke:"#E5E7EB",strokeWidth:"1"}),t.jsxs("text",{x:w-3,y:G+3,textAnchor:"end",fontSize:"7",fill:"#9CA3AF",children:[Math.round(B*100),"%"]})]},Y)}),t.jsx("line",{x1:w,y1:S+C,x2:M-E,y2:S+C,stroke:"#D1D5DB",strokeWidth:"1"}),h.map((B,Y)=>{const G=Math.max(0,B.rate/100*C),ie=w+Y*F+F/2,fe=ie-z/2,K=S+C-G,ke=g[Y],ge=a===Y;return t.jsxs("g",{onMouseEnter:re=>X(Y,re),style:{cursor:"pointer"},children:[t.jsx("rect",{x:w+Y*F,y:S,width:F,height:C,fill:"transparent"}),t.jsx("rect",{x:fe,y:G>0?K:S+C-1,width:z,height:G>0?G:1,fill:ke,rx:"4",ry:"4",opacity:ge?1:.8,style:{transition:"opacity 0.15s, filter 0.15s",filter:ge?"brightness(1.15)":"none"}}),G>14&&t.jsxs("text",{x:ie,y:K-3,textAnchor:"middle",fontSize:"7.5",fontWeight:"700",fill:ke,children:[B.rate.toFixed(1),"%"]}),t.jsx("text",{x:ie,y:S+C+12,textAnchor:"middle",fontSize:"6.5",fill:ge?ke:"#6B7280",fontWeight:ge?"700":"400",children:(B.type||"").length>11?(B.type||"").substring(0,9)+"…":B.type||""})]},Y)})]})}),a!==null&&i&&h[a]&&(()=>{const B=h[a],Y=g[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:Y}}),t.jsx("span",{className:"font-semibold text-[11px] truncate max-w-[120px]",children:B.type})]}),t.jsxs("div",{className:"text-green-400 font-bold text-sm text-center mb-0.5",children:[B.rate.toFixed(2),"% Closed"]}),t.jsxs("div",{className:"text-gray-300 text-[10px] text-center",children:[B.closed," closed · ",B.inProgress," prog · ",B.rejected," rej"]}),t.jsxs("div",{className:"text-gray-400 text-[10px] text-center",children:[B.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:h.map((B,Y)=>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:g[Y]}}),t.jsx("span",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:(B.type||"").length>22?(B.type||"").substring(0,20)+"…":B.type||""})]},Y))})]})},PU=({insights:e,maintenanceSummary:r})=>{const a=r.completed,s=r.total,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),c=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(cy,{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((u,h)=>t.jsxs("div",{className:`${u.color} rounded-xl p-3 text-center`,children:[t.jsx("div",{className:`text-2xl font-bold ${u.textColor}`,children:u.value}),t.jsx("div",{className:"text-[10px] font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide mt-0.5",children:u.label})]},h))}),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:c},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:c}})}),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(Ja,{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"})]})]})},LU=({data:e,totalWorkOrders:r,completedWorkOrders:a,loading:s,onOpenReport:n,className:i=""})=>{var u,h,g,y;const{t:c}=Rr();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 ${i}`,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:n,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:c("dashboard.viewFullReport"),children:t.jsx(ps,{className:"w-4 h-4 text-gray-400"})})]}),t.jsx("div",{className:"flex-1",children:s?t.jsx(th,{}):e&&((u=e==null?void 0:e.labels)!=null&&u.length||(y=(g=(h=e==null?void 0:e.datasets)==null?void 0:h[0])==null?void 0:g.values)!=null&&y.length)?t.jsx(jj,{data:e}):t.jsx("div",{className:"h-48 flex items-center justify-center text-gray-400 text-sm",children:c("dashboard.noDataAvailable")})})]})},BU=({data:e,totalAssets:r,loading:a,onOpenReport:s,className:n=""})=>{var i;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:"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"})]})]}),s&&t.jsx("button",{onClick:s,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:"View Asset Status Report",children:t.jsx(ps,{className:"w-4 h-4 text-gray-400"})})]}),t.jsx("div",{className:"flex-1",children:a?t.jsx(th,{}):e&&((i=e==null?void 0:e.labels)!=null&&i.length)?t.jsx(jj,{data:e}):t.jsx("div",{className:"h-48 flex items-center justify-center text-gray-400 text-sm",children:"No asset status data"})})]})},UU=({isOpen:e,onClose:r,assets:a,chartData:s,fromDate:n="",toDate:i="",technicalDepartment:c=""})=>{var C,O,M,R,F,z;if(!e)return null;const u=c?{technical_department:c}:{},h=(s==null?void 0:s.labels)||[],g=((O=(C=s==null?void 0:s.datasets)==null?void 0:C[0])==null?void 0:O.values)||[],y=((R=(M=s==null?void 0:s.datasets)==null?void 0:M[0])==null?void 0:R.colors)||Qc(h.length),w=(z=(F=s==null?void 0:s.total)!=null?F:a==null?void 0:a.length)!=null?z:g.reduce((W,X)=>W+X,0),E=W=>{const X=W.toLowerCase();return X==="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"}:X==="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"}:X.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"}:X.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"}},S=W=>{window.location.href=H1(Ke(Te({},u),{device_status:W}),n,i)},A=()=>{window.location.href=H1(u,n,i)};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(_1,{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"})})})]}),(n||i)&&t.jsxs("div",{className:"px-5 py-2.5 bg-teal-50 dark:bg-teal-900/20 border-b border-teal-200 dark:border-teal-700 flex items-center gap-2 flex-wrap",children:[t.jsx(Hs,{className:"text-teal-500 text-xs shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-teal-700 dark:text-teal-300",children:"Filtered by date:"}),n&&t.jsxs("span",{className:"text-xs bg-white dark:bg-teal-900/40 text-teal-700 dark:text-teal-200 border border-teal-200 dark:border-teal-600 px-2 py-0.5 rounded-full font-medium",children:["From: ",n]}),i&&t.jsxs("span",{className:"text-xs bg-white dark:bg-teal-900/40 text-teal-700 dark:text-teal-200 border border-teal-200 dark:border-teal-600 px-2 py-0.5 rounded-full font-medium",children:["To: ",i]})]}),t.jsxs("div",{className:"p-6 space-y-4",children:[t.jsxs("button",{onClick:A,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(_1,{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:w})]})]}),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(ps,{size:10})]})]}),h.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:h.map((W,X)=>{var fe;const B=(fe=g[X])!=null?fe:0,Y=w>0?(B/w*100).toFixed(1):"0.0",G=E(W),ie=y[X]||"#6366F1";return t.jsxs("button",{onClick:()=>S(W),className:`flex flex-col items-start text-left ${G.bg} border ${G.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 ${G.text} leading-none`,children:B}),t.jsxs("div",{className:`flex items-center gap-1 text-[10px] font-semibold ${G.text} opacity-60 group-hover:opacity-100 transition-opacity mt-1`,children:["View ",t.jsx(ps,{size:8})]})]}),t.jsx("div",{className:`text-xs font-semibold ${G.text} uppercase tracking-wide mb-3`,children:W}),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:`${Y}%`,backgroundColor:ie}})}),t.jsxs("div",{className:`text-[11px] font-semibold ${G.text} mt-1.5 opacity-70`,children:[Y,"% of total"]})]},W)})})]})]})})},$1=({data:e})=>{const{t:r}=Rr(),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(A=>A.values||[]),i=Math.max(...n,1),c=240,u=Math.max(800,a.length*100),h=Math.min(120,(u-100)/a.length),g=4,y=s.length,w=Math.max(12,(h-g*(y+1))/y),E={"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","Total WO":"#6366F1","Total Completed":"#10B981","Pending with Contractor":"#EF4444","Total Completed by Contractor":"#10B981"},S=(A,C)=>{for(const[O,M]of Object.entries(E))if(A.toLowerCase().includes(O.toLowerCase()))return M;return Qc(y)[C]};return t.jsxs("div",{className:"relative w-full overflow-x-auto",children:[t.jsxs("svg",{width:"100%",height:c+40,viewBox:`0 0 ${u} ${c+40}`,className:"w-full",preserveAspectRatio:"xMidYMid meet",children:[t.jsx("defs",{children:s.map((A,C)=>{const O=S(A.name||"",C);return t.jsxs("linearGradient",{id:`groupedBarGradient${C}`,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[t.jsx("stop",{offset:"0%",style:{stopColor:O,stopOpacity:.9}}),t.jsx("stop",{offset:"100%",style:{stopColor:O,stopOpacity:.7}})]},C)})}),[0,.25,.5,.75,1].map((A,C)=>t.jsx("line",{x1:"60",y1:c-A*c,x2:u-20,y2:c-A*c,stroke:"#E5E7EB",strokeWidth:"1"},C)),[0,.25,.5,.75,1].map((A,C)=>t.jsx("text",{x:"45",y:c-A*c+4,textAnchor:"end",className:"text-xs fill-gray-400",children:(i*A).toFixed(A===0?0:i<5?1:0)},C)),a.map((A,C)=>{const O=80+C*h;return t.jsxs("g",{children:[s.map((M,R)=>{var Y;const F=((Y=M.values)==null?void 0:Y[C])||0,z=F/i*c,W=O+g+R*(w+g),X=c-z,B=S(M.name||"",R);return t.jsx("g",{children:t.jsx("rect",{x:W,y:X,width:w,height:z,fill:B,rx:"3",ry:"3",className:"hover:opacity-80 cursor-pointer transition-opacity",children:t.jsx("title",{children:`${A||"Unknown"} — ${M.name||"Series"}: ${F}`})})},R)}),t.jsx("text",{x:O+h/2,y:c+15,textAnchor:"middle",className:"text-xs fill-gray-600 dark:fill-gray-400",children:A&&A.length>12?A.substring(0,10)+"...":A||"null"})]},C)})]}),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((A,C)=>{const O=S(A.name||"",C);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:O}}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:A.name&&A.name.length>20?A.name.substring(0,18)+"...":A.name||`Series ${C+1}`})]},C)})})]})},zU=({data:e})=>{const{t:r}=Rr(),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((g,y)=>s.reduce((w,E)=>{var S;return w+(((S=E.values)==null?void 0:S[y])||0)},0)),c=Math.max(...i,1),u={total:"#6366F1",completed:"#10B981",in_progress:"#3B82F6",open:"#F59E0B"},h=(g,y)=>{for(const[w,E]of Object.entries(u))if(g.toLowerCase().includes(w))return E;return Qc(s.length)[y]};return t.jsxs("div",{className:"space-y-2 max-h-72 overflow-y-auto",children:[a.map((g,y)=>{const w=i[y],E=s.map(S=>{var C;const A=((C=S.values)==null?void 0:C[y])||0;return A>0?`${(S.name||"").replace(/_/g," ")}: ${A}`: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:g,children:g}),t.jsx("div",{className:"flex-1 h-4 bg-gray-100 dark:bg-gray-700 rounded-full overflow-hidden flex cursor-default",title:`${E} • Total: ${w}`,children:s.map((S,A)=>{var O;const C=((O=S.values)==null?void 0:O[y])||0;return C?t.jsx("div",{className:"h-full",style:{width:`${C/c*100}%`,backgroundColor:h(S.name||"",A)}},S.name):null})}),t.jsx("div",{className:"w-10 text-xs text-right text-gray-500 dark:text-gray-400",children:w})]},y)}),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((g,y)=>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:h(g.name||"",y)}}),t.jsx("span",{children:(g.name||`Series ${y+1}`).replace(/_/g," ")})]},g.name||y))})]})},WU=({title:e,data:r,onOpenReport:a})=>{var u;const{t:s}=Rr(),[n,i]=_.useState(!1),c=ea.useMemo(()=>{var h,g;return(g=(h=r==null?void 0:r.datasets)==null?void 0:h[0])!=null&&g.values?r.datasets[0].values.reduce((y,w)=>y+w,0):0},[r]);return _.useEffect(()=>{const h=()=>i(!1);if(n)return document.addEventListener("click",h),()=>document.removeEventListener("click",h)},[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(i_,{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:[c.toFixed(1)," hrs"]})]})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("button",{onClick:h=>{h.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:h=>{h.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(ps,{className:"text-gray-400",size:12}),s("dashboard.viewFullReport")]})})]})]}),!r||!((u=r.datasets)!=null&&u.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(i_,{className:"text-4xl mx-auto mb-2 opacity-30"}),t.jsx("div",{className:"text-sm",children:"Loading..."})]})}):t.jsx(Nj,{data:r,valueLabel:"hrs"})]})},HU=({title:e,data:r,onOpenReport:a})=>{var u;const{t:s}=Rr(),[n,i]=_.useState(!1),c=ea.useMemo(()=>{if(!(r!=null&&r.datasets))return{completed:0,inProgress:0,open:0};const h={completed:0,inProgress:0,open:0};return r.datasets.forEach(g=>{var w;const y=((w=g.values)==null?void 0:w.reduce((E,S)=>E+S,0))||0;g.name==="completed"?h.completed=y:g.name==="in_progress"?h.inProgress=y:g.name==="open"&&(h.open=y)}),h},[r]);return _.useEffect(()=>{const h=()=>i(!1);if(n)return document.addEventListener("click",h),()=>document.removeEventListener("click",h)},[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(Vm,{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:[c.completed," done"]}),t.jsx("span",{className:"text-gray-300",children:"•"}),t.jsxs("span",{className:"text-blue-600 font-semibold",children:[c.inProgress," wip"]}),t.jsx("span",{className:"text-gray-300",children:"•"}),t.jsxs("span",{className:"text-amber-600 font-semibold",children:[c.open," open"]})]})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("button",{onClick:h=>{h.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:h=>{h.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(ps,{className:"text-gray-400",size:12}),s("dashboard.viewFullReport")]})})]})]}),!r||!((u=r.datasets)!=null&&u.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(Vm,{className:"text-4xl mx-auto mb-2 opacity-30"}),t.jsx("div",{className:"text-sm",children:"Loading..."})]})}):t.jsx(zU,{data:r})]})},Nj=({data:e,valueLabel:r=""})=>{var c,u;const{t:a}=Rr(),s=(e==null?void 0:e.labels)||[],n=((u=(c=e==null?void 0:e.datasets)==null?void 0:c[0])==null?void 0:u.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((h,g)=>{const y=n[g]||0,w=y/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:h||"(No Type)",children:h||"(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:`${w}%`}})}),t.jsxs("div",{className:"w-12 text-xs font-semibold text-gray-800 dark:text-gray-200 text-right",children:[typeof y=="number"?Number.isInteger(y)?y:y.toFixed(1):y,r?` ${r}`:""]})]},g)})})},$U=({data:e})=>{var i,c;const{t:r}=Rr(),a=(e==null?void 0:e.labels)||[],s=((c=(i=e==null?void 0:e.datasets)==null?void 0:i[0])==null?void 0:c.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((u,h)=>{const g=s[h]||0,y=g/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:u||"(No Type)",children:u||"(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:`${y}%`,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 g=="number"?Number.isInteger(g)?g:g.toFixed(1):g})]},h)})})},jj=({data:e})=>{var w,E,S,A;const r=(e==null?void 0:e.labels)||[],a=((E=(w=e==null?void 0:e.datasets)==null?void 0:w[0])==null?void 0:E.values)||[],s=r.some(C=>C.toLowerCase().includes("up time")||C.toLowerCase().includes("down time")||C.toLowerCase().includes("uptime")||C.toLowerCase().includes("downtime"));let n=[];if(s)n=r.map(C=>{const O=C.toLowerCase();return O.includes("up time")||O.includes("uptime")?"#6366F1":"#8B5CF6"});else{const C=(A=(S=e==null?void 0:e.datasets)==null?void 0:S[0])==null?void 0:A.colors;n=C&&C.length===a.length?C:Qc(a.length)}const i=a.reduce((C,O)=>C+O,0),c=100,u=c+10,h=c+10;let g=0;const y=a.map((C,O)=>{const M=g/i*2*Math.PI-Math.PI/2;g+=C;const R=g/i*2*Math.PI-Math.PI/2,F=R-M>Math.PI?1:0,z=u+c*Math.cos(M),W=h+c*Math.sin(M),X=u+c*Math.cos(R),B=h+c*Math.sin(R);return{path:`M ${u} ${h} L ${z} ${W} A ${c} ${c} 0 ${F} 1 ${X} ${B} Z`,color:n[O],label:r[O],value:C,percentage:(C/i*100).toFixed(1)}});return t.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-around",children:[t.jsx("svg",{width:u*2,height:h*2,viewBox:`0 0 ${u*2} ${h*2}`,className:"max-w-xs",children:y.map((C,O)=>t.jsx("path",{d:C.path,fill:C.color,className:"hover:opacity-80 transition-opacity cursor-pointer drop-shadow-sm",children:t.jsx("title",{children:`${C.label}: ${C.value} (${C.percentage}%)`})},O))}),t.jsx("div",{className:"flex flex-col gap-2.5 mt-4 md:mt-0",children:y.map((C,O)=>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:C.color}}),t.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:C.label}),t.jsx("span",{className:"text-sm font-bold text-gray-900 dark:text-white ml-auto pl-4",children:C.value})]},O))})]})},_k=({title:e,data:r,loading:a,onOpenReport:s,showSummary:n})=>{const{t:i}=Rr(),c=(r==null?void 0:r.labels)||[],u=(r==null?void 0:r.datasets)||[],h=c.length,g=u.reduce((y,w)=>y+(w.values||[]).reduce((E,S)=>E+S,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:s,className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:i("dashboard.viewFullReport"),children:t.jsx(ps,{className:"w-3.5 h-3.5 text-gray-400"})})]}),a?t.jsx(th,{}):!r||!u.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($1,{data:r}),n&&h>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:h}),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:g}),t.jsx("div",{className:"text-[10px] text-gray-500 dark:text-gray-400 uppercase tracking-wide font-semibold",children:"Tasks"})]})]})]})]})},VU=({isOpen:e,onClose:r,title:a,data:s,redirectContext:n,fromDate:i="",toDate:c="",showPendingPopover:u=!1,wide:h=!1,onExportExcel:g})=>{const{t:y}=Rr(),[w,E]=_.useState(null);if(!e)return null;const S=(s==null?void 0:s.labels)||[],A=(s==null?void 0:s.datasets)||[],C=(s==null?void 0:s.hideFooterTotal)===!0,O=(s==null?void 0:s.noStatusInCells)===!0,M=["Urgent","Completed","Pending"],R=A.filter(G=>M.includes(G.name||"")),F=h&&R.length>=2,z=G=>{window.location.href=G},W=new Set(["Open","Work In Progress","Pending Review","Closed","Completed","Rejected","Cancelled","in_progress","open","completed","closed","rejected"]),X=G=>{if(!n)return null;if(n==="ppm_type"){const ie=new URLSearchParams;return ie.set("expertise",G),i&&ie.set("date_start",i),c&&ie.set("date_end",c),`/asm_app/maintenance?${ie.toString()}`}return n==="wo_status"?js({status:G},i,c):n==="wo_type"?t1.has(G)?js({work_order_type:r1,civil_work_category:G,page:"1"},i,c):js({work_order_type:G,page:"1"},i,c):null},B=(G,ie)=>{if(!n)return null;if(n==="ppm_type"){const fe=new URLSearchParams;return fe.set("expertise",G),i&&fe.set("date_start",i),c&&fe.set("date_end",c),ie==="Completed"&&fe.set("status","Completed"),ie==="Pending"&&fe.set("status","Planned"),`/asm_app/maintenance?${fe.toString()}`}if(n==="wo_status")return js({status:G},i,c);if(n==="wo_type"){const K=t1.has(G)?{work_order_type:r1,civil_work_category:G,page:"1"}:{work_order_type:G,page:"1"};if(ie==="Total WO"||ie==="total_wo"||ie==="Total WOs"||ie==="total_wos")return js(K,i,c);if(ie==="Not Assigned"||ie==="not_assigned")return js(Ke(Te({},K),{status:"Open"}),i,c);if(ie==="Pending with Contractor"||ie==="pending_with_contractor")return js(Ke(Te({},K),{status:"Work In Progress"}),i,c);if(ie==="Completed by Contractor"||ie==="completed_by_contractor"||ie==="Total Completed by Contractor")return js(Ke(Te({},K),{status:"Pending Review,Closed"}),i,c);if(ie==="Pending with MOH"||ie==="pending_with_moh"||ie==="Total Pending with MOH")return js(Ke(Te({},K),{status:"Pending Review"}),i,c);if(ie==="Total Completed"||ie==="total_completed")return js(Ke(Te({},K),{status:"Closed"}),i,c);if(ie==="Urgent"||ie==="Urgent Total"||ie==="urgent_total")return js(Ke(Te({},K),{priority:"Urgent"}),i,c);if(ie==="Urgent Completed"||ie==="urgent_completed"||ie==="Completed"||ie==="completed")return js(Ke(Te({},K),{priority:"Urgent",status:"Closed"}),i,c);if(ie==="Urgent Pending Review"||ie==="urgent_pending_review"||ie==="Pending")return js(Ke(Te({},K),{priority:"Urgent",status:"Open,Work In Progress,Pending Review"}),i,c);if(["contractor_completion_rate","completion_rate","urgent_completion_rate","Contractor Completion Rate (%)","Total Completion Rate (%)","Urgent Completion Rate (%)","Total WO Completion Rate %","Urgent WO Completion Rate %"].includes(ie))return null;const ke=AU[ie],ge=ke!==void 0?ke||void 0:W.has(ie)?ie:void 0;return js(O||!ge?K:Ke(Te({},K),{status:ge}),i,c)}return 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 ${h?"max-w-6xl":"max-w-4xl"} w-full overflow-auto max-h-[95vh]`,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",{className:"flex items-center justify-between flex-1 mr-4",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:n==="ppm_type"?"Click a row to view filtered maintenance logs":"Click a row or value to view filtered work orders"})]}),(a==="KPI Monthly Report"||a==="PPM KPI Report")&&g&&t.jsxs("button",{onClick:g,className:"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-lg transition-colors",children:[t.jsx(zi,{size:13}),"Export Excel"]})]}),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"})})})]}),(i||c)&&t.jsxs("div",{className:"px-6 py-2.5 bg-indigo-50 dark:bg-indigo-900/20 border-b border-indigo-200 dark:border-indigo-700 flex items-center gap-2 flex-wrap",children:[t.jsx(Hs,{className:"text-indigo-400 text-xs shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-indigo-700 dark:text-indigo-300",children:"Filtered by date:"}),i&&t.jsxs("span",{className:"text-xs bg-white dark:bg-indigo-900/40 text-indigo-700 dark:text-indigo-200 border border-indigo-200 dark:border-indigo-600 px-2 py-0.5 rounded-full font-medium",children:["From: ",i]}),c&&t.jsxs("span",{className:"text-xs bg-white dark:bg-indigo-900/40 text-indigo-700 dark:text-indigo-200 border border-indigo-200 dark:border-indigo-600 px-2 py-0.5 rounded-full font-medium",children:["To: ",c]})]}),t.jsx("div",{className:"p-6 overflow-auto",children:s!=null&&s.rawRows?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:"py-3 px-4 text-left font-semibold text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-900/50 rounded-tl-lg",children:"Assigned To"}),t.jsx("th",{className:"py-3 px-4 text-right font-semibold bg-gray-50 dark:bg-gray-900/50",style:{color:"#6366F1"},children:"Planned"}),t.jsx("th",{className:"py-3 px-4 text-right font-semibold bg-gray-50 dark:bg-gray-900/50",style:{color:"#10B981"},children:"Completed"}),t.jsx("th",{className:"py-3 px-4 text-right font-semibold bg-gray-50 dark:bg-gray-900/50",style:{color:"#F59E0B"},children:"Cancelled"}),t.jsx("th",{className:"py-3 px-4 text-right font-semibold bg-gray-50 dark:bg-gray-900/50",style:{color:"#EF4444"},children:"Overdue"}),t.jsx("th",{className:"py-3 px-4 text-right font-semibold text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-900/50 rounded-tr-lg",children:"Total"})]})}),t.jsx("tbody",{children:s.rawRows.map((G,ie)=>{const fe=parseFloat(G.pending)||0,K=(parseFloat(G.completed_on_time)||0)+(parseFloat(G.completed_within_time)||0)+(parseFloat(G.delay_in_completion)||0),ke=parseFloat(G.cancelled)||0,ge=parseFloat(G.overdue)||0,re=fe+K+ke+ge;return t.jsxs("tr",{className:"border-b border-gray-100 dark:border-gray-700/50 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",children:G["Assigned To"]||G.assign_to_name||G.assign_to_name||G.assigned_to||G.assign_to||"—"}),[{val:fe,status:"Planned",color:"#6366F1"},{val:K,status:"Completed",color:"#10B981"},{val:ke,status:"Cancelled",color:"#F59E0B"},{val:ge,status:"Overdue",color:"#EF4444"}].map(({val:we,status:ee,color:ve})=>{const ce=G["Assigned To"]||G.assign_to_name||G.assign_to_name||G.assigned_to||G.assign_to||"",ye=`/asm_app/maintenance?assignee=${encodeURIComponent(ce)}&status=${encodeURIComponent(ee)}${i?`&date_start=${i}`:""}${c?`&date_end=${c}`:""}`;return t.jsx("td",{className:`py-2.5 px-4 text-right tabular-nums ${we>0?"cursor-pointer font-semibold hover:underline":"text-gray-400 dark:text-gray-500"}`,style:we>0?{color:ve}:{},onClick:we>0?()=>{window.location.href=ye}:void 0,title:we>0?`View ${ee} tasks for ${ce}`:void 0,children:we>0?t.jsxs("span",{className:"flex items-center justify-end gap-1",children:[we,t.jsx(ps,{size:8,className:"opacity-60 flex-shrink-0"})]}):we},ee)}),t.jsx("td",{className:"py-2.5 px-4 text-right tabular-nums font-semibold text-gray-800 dark:text-gray-200",children:re})]},ie)})}),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"}),[s.rawRows.reduce((G,ie)=>G+(parseFloat(ie.pending)||0),0),s.rawRows.reduce((G,ie)=>G+(parseFloat(ie.completed_on_time)||0)+(parseFloat(ie.completed_within_time)||0)+(parseFloat(ie.delay_in_completion)||0),0),s.rawRows.reduce((G,ie)=>G+(parseFloat(ie.cancelled)||0),0),s.rawRows.reduce((G,ie)=>G+(parseFloat(ie.overdue)||0),0)].map((G,ie)=>t.jsx("td",{className:"py-3 px-4 text-right font-bold text-gray-800 dark:text-gray-200 tabular-nums",children:G},ie)),t.jsx("td",{className:"py-3 px-4 text-right font-bold text-gray-800 dark:text-gray-200 tabular-nums",children:s.rawRows.reduce((G,ie)=>G+(parseFloat(ie.pending)||0)+(parseFloat(ie.completed_on_time)||0)+(parseFloat(ie.completed_within_time)||0)+(parseFloat(ie.delay_in_completion)||0)+(parseFloat(ie.cancelled)||0)+(parseFloat(ie.overdue)||0),0)})]})})]}):S.length===0||A.length===0?t.jsx("div",{className:"text-center text-gray-400 py-8",children:y("dashboard.noDataAvailable")}):t.jsxs("table",{className:"w-full text-sm border-collapse",children:[t.jsxs("thead",{children:[F&&(()=>{let G=!1;return t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:[t.jsx("th",{className:"text-left py-2 px-2 text-xs font-semibold text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-900/50 rounded-tl-lg",rowSpan:2,children:"WO Type"}),A.map((ie,fe)=>M.includes(ie.name||"")?G?null:(G=!0,t.jsx("th",{colSpan:R.length,className:"py-1 px-2 text-xs text-center font-bold text-indigo-700 dark:text-indigo-300 bg-indigo-50 dark:bg-indigo-900/30 border-x-2 border-indigo-300 dark:border-indigo-600 uppercase tracking-wide",children:"Priority"},`pg-${fe}`)):t.jsx("th",{rowSpan:2,className:"py-1 px-2 text-xs text-right font-semibold text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-900/50 last:rounded-tr-lg",children:(ie.name||"").replace(/_/g," ")},fe))]})})(),t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:[!F&&t.jsx("th",{className:`text-left ${h?"py-2 px-2 text-xs":"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"}),A.map((G,ie)=>{const fe=M.includes(G.name||"");return F&&!fe?null:t.jsx("th",{className:`text-right ${h?"py-2 px-2 text-xs":"py-3 px-4"} font-semibold text-gray-700 dark:text-gray-300
${fe&&h?"bg-indigo-50 dark:bg-indigo-900/30 border-x border-indigo-200 dark:border-indigo-700":"bg-gray-50 dark:bg-gray-900/50"}
last:rounded-tr-lg`,children:(G.name||`Series ${ie+1}`).replace(/_/g," ")},ie)}),n==="ppm_type"&&t.jsx("th",{className:"py-3 px-4 text-right font-semibold text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-900/50 last:rounded-tr-lg",children:"Completion %"})]})]}),t.jsx("tbody",{children:(()=>{if(!h)return S.map((ve,ce)=>{const ye=X(ve);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 ${ye?"cursor-pointer text-indigo-700 dark:text-indigo-300 hover:underline":""}`,onClick:ye?()=>z(ye):void 0,children:t.jsxs("span",{className:"flex items-center gap-1.5",children:[ve||"Unknown",ye&&t.jsx(ps,{size:9,className:"opacity-50 flex-shrink-0"})]})}),A.map((te,q)=>{var be,Z;const J=(Z=(be=te.values)==null?void 0:be[ce])!=null?Z:0,ae=u&&te.name==="pending",oe=ae?null:B(ve,te.name||""),le=h&&M.includes(te.name||"");return t.jsx("td",{className:`py-2.5 px-4 text-right tabular-nums ${le?"bg-indigo-50/50 dark:bg-indigo-900/10 border-x border-indigo-100 dark:border-indigo-800/50":""} ${ae?"cursor-pointer text-indigo-600 font-semibold hover:underline":oe?"cursor-pointer text-indigo-600 dark:text-indigo-400 font-semibold hover:underline":"text-gray-600 dark:text-gray-300"}`,onClick:ae?Le=>{const Pe=Le.currentTarget.getBoundingClientRect();E({x:Pe.left,y:Pe.bottom,label:ve})}:oe?()=>z(oe):void 0,children:ae?t.jsxs("span",{children:[J," ▾"]}):J},q)}),n==="ppm_type"&&(()=>{var le,be,Z,Le;const te=A.find(Pe=>Pe.name==="Total WOs"),q=A.find(Pe=>Pe.name==="Completed"),J=(be=(le=te==null?void 0:te.values)==null?void 0:le[ce])!=null?be:0,ae=(Le=(Z=q==null?void 0:q.values)==null?void 0:Z[ce])!=null?Le:0,oe=J>0?Math.round(ae/J*100):0;return t.jsxs("td",{className:"py-2.5 px-4 text-right tabular-nums font-semibold",style:{color:oe>=80?"#10B981":oe>=50?"#F59E0B":"#EF4444"},children:[oe,"%"]})})()]},ce)});const G=new Set(["CARPENTARY","MASONRY","PAINTING","PLUMPING"]),ie="Civil works-الأعمال المدنية",fe=[];let K=null;S.forEach((ve,ce)=>{G.has(ve)&&fe.push(ce),ve===ie&&(K=ce)});const ke=new Set(fe),ge={};A.forEach(ve=>{var te,q;const ce=K!==null&&(q=(te=ve.values)==null?void 0:te[K])!=null?q:0,ye=fe.reduce((J,ae)=>{var oe,le;return J+((le=(oe=ve.values)==null?void 0:oe[ae])!=null?le:0)},0);ge[ve.name]=Math.max(0,ce-ye)});const re=[];fe.forEach(ve=>re.push({label:S[ve],idx:ve})),re.push({label:"None",idx:null,isNone:!0}),K!==null&&re.push({label:ie,idx:K,isCivilParent:!0});const we=["Electrical","HVAC","Mechanical","Medical Gas","Electronics","Electronic"],ee=[];return S.forEach((ve,ce)=>{ke.has(ce)||ve===ie||ee.push({label:ve,idx:ce})}),ee.sort((ve,ce)=>{const ye=we.findIndex(q=>ve.label.toLowerCase().includes(q.toLowerCase())),te=we.findIndex(q=>ce.label.toLowerCase().includes(q.toLowerCase()));return(ye===-1?999:ye)-(te===-1?999:te)}),ee.forEach(ve=>re.push({label:ve.label,idx:ve.idx})),re.map((ve,ce)=>{const ye=ve.isNone?null:X(ve.label);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-1.5 px-2 text-xs text-gray-800 dark:text-gray-200 font-medium ${ye?"cursor-pointer text-indigo-700 dark:text-indigo-300 hover:underline":""}`,onClick:ye?()=>z(ye):void 0,title:ye?`View work orders for ${ve.label}`:void 0,children:t.jsxs("span",{className:"flex items-center gap-1.5",children:[ve.label||"Unknown",ye&&t.jsx(ps,{size:9,className:"opacity-50 flex-shrink-0"})]})}),A.map((te,q)=>{var be,Z,Le,Pe,Be,pe,rt,ct,et,It,ft,Lt,Je;let J;if(ve.isNone){const Ve=(te.name||"").toLowerCase();if(Ve.includes("rate")||Ve.includes("%")){const Rt=(Z=(be=ge["Total WO"])!=null?be:ge.total_wo)!=null?Z:0;if(Ve.includes("contractor")){const qe=(Pe=(Le=ge["Total Completed by Contractor"])!=null?Le:ge.completed_by_contractor)!=null?Pe:0;J=Rt>0?parseFloat((qe/Rt*100).toFixed(2)):0}else if(Ve.includes("urgent")){const qe=(pe=(Be=ge.Urgent)!=null?Be:ge.urgent_total)!=null?pe:0,Dt=(ct=(rt=ge.Completed)!=null?rt:ge.urgent_completed)!=null?ct:0;J=qe>0?parseFloat((Dt/qe*100).toFixed(2)):0}else{const qe=(It=(et=ge["Total Completed"])!=null?et:ge.total_completed)!=null?It:0;J=Rt>0?parseFloat((qe/Rt*100).toFixed(2)):0}}else J=(ft=ge[te.name])!=null?ft:0}else J=(Je=(Lt=te.values)==null?void 0:Lt[ve.idx])!=null?Je:0;const ae=u&&te.name==="pending"&&!ve.isNone,oe=!ae&&!ve.isNone?B(ve.label,te.name||""):null,le=M.includes(te.name||"");return t.jsx("td",{className:`py-1.5 px-2 text-xs text-right tabular-nums
${le?"bg-indigo-50/50 dark:bg-indigo-900/10 border-x border-indigo-100 dark:border-indigo-800/50":""}
${ae?"cursor-pointer text-indigo-600 dark:text-indigo-400 font-semibold hover:underline":oe?"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:ae?Ve=>{const Xe=Ve.currentTarget.getBoundingClientRect();E({x:Xe.left,y:Xe.bottom,label:ve.label})}:oe?()=>z(oe):void 0,title:ae?"Filter by pending status":oe?`View ${te.name} work orders for ${ve.label}`:void 0,children:ae?t.jsxs("span",{children:[J," ▾"]}):J},q)})]},ce)})})()}),!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:`${h?"py-2 px-2 text-xs":"py-3 px-4"} font-bold text-gray-800 dark:text-gray-200`,children:"Total"}),A.map((G,ie)=>{var q,J;const K=h&&M.includes(G.name||"")?"bg-indigo-50/50 dark:bg-indigo-900/10 border-x border-indigo-100 dark:border-indigo-800/50":"";if((G.name||"").toLowerCase().includes("rate")||(G.name||"").toLowerCase().includes("%"))return t.jsx("td",{className:`${h?"py-2 px-2 text-xs":"py-3 px-4"} text-right text-gray-400 dark:text-gray-500 tabular-nums ${K}`,children:"—"},ie);const ge="Civil works-الأعمال المدنية",re=new Set(["CARPENTARY","MASONRY","PAINTING","PLUMPING"]),we=S.findIndex(ae=>ae===ge),ee=S.reduce((ae,oe,le)=>(re.has(oe)&&ae.push(le),ae),[]),ve=we>=0&&(J=(q=G.values)==null?void 0:q[we])!=null?J:0,ce=ee.reduce((ae,oe)=>{var le,be;return ae+((be=(le=G.values)==null?void 0:le[oe])!=null?be:0)},0),ye=Math.max(0,ve-ce),te=h?(G.values||[]).reduce((ae,oe,le)=>S[le]===ge?ae:ae+oe,0)+ye:(G.values||[]).reduce((ae,oe)=>ae+oe,0);return t.jsx("td",{className:`${h?"py-2 px-2 text-xs":"py-3 px-4"} text-right font-bold text-gray-800 dark:text-gray-200 tabular-nums ${K}`,children:typeof te=="number"&&te%1!==0?te.toFixed(1):te},ie)}),n==="ppm_type"&&(()=>{const G=A.find(ge=>ge.name==="Total WOs"),ie=A.find(ge=>ge.name==="Completed"),fe=((G==null?void 0:G.values)||[]).reduce((ge,re)=>ge+re,0),K=((ie==null?void 0:ie.values)||[]).reduce((ge,re)=>ge+re,0),ke=fe>0?Math.round(K/fe*100):0;return t.jsxs("td",{className:"py-3 px-4 text-right font-bold tabular-nums",style:{color:ke>=80?"#10B981":ke>=50?"#F59E0B":"#EF4444"},children:[ke,"%"]})})()]})})]})}),w&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[75]",onClick:()=>E(null)}),t.jsxs("div",{className:"fixed z-[80] bg-white dark:bg-gray-800 rounded-xl shadow-2xl border border-gray-200 dark:border-gray-700 py-1 min-w-[180px]",style:{left:w.x,top:w.y+4},children:[t.jsx("div",{className:"px-3 py-1.5 text-xs font-semibold text-gray-400 border-b border-gray-100 dark:border-gray-700",children:"Filter by status"}),["Open","Work In Progress","Pending Review"].map(G=>t.jsxs("button",{onClick:()=>{const ie=t1.has(w.label)?js({work_order_type:r1,civil_work_category:w.label,page:"1",status:G},i,c):js({work_order_type:w.label,page:"1",status:G},i,c);window.location.href=ie,E(null)},className:"w-full px-3 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-indigo-50 dark:hover:bg-indigo-900/20 flex items-center gap-2",children:[t.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${G==="Open"?"bg-amber-400":G==="Work In Progress"?"bg-blue-400":"bg-orange-400"}`}),G]},G)),t.jsx("button",{onClick:()=>E(null),className:"w-full px-3 py-2 text-left text-xs text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-700 border-t border-gray-100 dark:border-gray-700",children:"Cancel"})]})]})]})})},GU=({title:e,data:r,onOpenReport:a})=>{var u;const{t:s}=Rr(),[n,i]=_.useState(!1),c=ea.useMemo(()=>{var h,g,y,w;return(w=(y=(g=(h=r==null?void 0:r.datasets)==null?void 0:h[0])==null?void 0:g.values)==null?void 0:y.reduce((E,S)=>E+S,0))!=null?w:0},[r]);return _.useEffect(()=>{const h=()=>i(!1);if(n)return document.addEventListener("click",h),()=>document.removeEventListener("click",h)},[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(Tr,{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:c})]})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("button",{onClick:h=>{h.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:h=>{h.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(ps,{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(Tr,{className:"text-4xl mx-auto mb-2 opacity-20"}),t.jsx("div",{className:"text-sm",children:"Loading..."})]})}):(u=r.datasets)!=null&&u.length?t.jsx(Nj,{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(Tr,{className:"text-4xl mx-auto mb-2 opacity-10"}),t.jsx("div",{className:"text-sm",children:"No inspection data"})]})})]})},YU=({title:e,data:r,onOpenReport:a})=>{var u;const{t:s}=Rr(),[n,i]=_.useState(!1),c=ea.useMemo(()=>{var h,g,y;return(g=(h=r==null?void 0:r.datasets)==null?void 0:h[0])!=null&&g.values?r.datasets[0].values.reduce((w,E)=>w+E,0):(y=r==null?void 0:r.totalRejected)!=null?y:0},[r]);return _.useEffect(()=>{const h=()=>i(!1);if(n)return document.addEventListener("click",h),()=>document.removeEventListener("click",h)},[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(Jr,{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:c})]})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("button",{onClick:h=>{h.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:h=>{h.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(ps,{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(Jr,{className:"text-4xl mx-auto mb-2 opacity-20"}),t.jsx("div",{className:"text-sm",children:"Loading..."})]})}):(u=r.datasets)!=null&&u.length?t.jsx($U,{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(Jr,{className:"text-4xl mx-auto mb-2 opacity-10"}),t.jsx("div",{className:"text-sm",children:"No rejection data"})]})})]})},qU=({isOpen:e,onClose:r,permittedIssueTypes:a,isAdmin:s,defaultWorkOrderType:n,defaultFromDate:i,defaultToDate:c})=>{var ee,ve;const{t:u}=Rr(),[h,g]=_.useState(null),[y,w]=_.useState(!1),[E,S]=_.useState(""),[A,C]=_.useState(n||""),[O,M]=_.useState(i||""),[R,F]=_.useState(c||""),[z,W]=_.useState([]),[X,B]=_.useState([]);_.useEffect(()=>{C(n||"")},[n]),_.useEffect(()=>{e&&(M(i||""),F(c||""))},[e]),_.useEffect(()=>{if(!e)return;me(null,null,function*(){try{const[ye,te]=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"})]),q=yield ye.json(),J=yield te.json();q.data&&W(q.data.map(ae=>ae.name)),J.data&&B(J.data.map(ae=>ae.name))}catch(ye){console.error(ye)}})},[e]);const Y=s?z:a;if(_.useEffect(()=>{if(!e)return;me(null,null,function*(){w(!0);try{const ye={};!s&&a.length>0?ye.work_order_type=a.length===1?a[0]:a:A&&(ye.work_order_type=A),E&&(ye.department=E),O&&(ye.from_date=O),R&&(ye.to_date=R);const q=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:ye,ignore_prepared_report:1})})).json();g(q.message||null)}catch(ye){console.error(ye)}finally{w(!1)}})},[e,A,E,O,R,a,s]),!e)return null;const G=(h==null?void 0:h.columns)||[],ie=((h==null?void 0:h.result)||[]).filter(ce=>ce&&typeof ce=="object"),fe=ie.filter(ce=>!ce.is_total_row),K=(h==null?void 0:h.report_summary)||[],ke=(ve=(ee=K.find(ce=>{var ye;return(ye=ce.label)==null?void 0:ye.toLowerCase().includes("total inspection")}))==null?void 0:ee.value)!=null?ve:fe.reduce((ce,ye)=>{const te=G.find(q=>{var J,ae;return((J=q.label)==null?void 0:J.toLowerCase().includes("total inspection"))||((ae=q.fieldname)==null?void 0:ae.toLowerCase().includes("total_inspection"))});return ce+(te&&parseFloat(ye[te.fieldname])||0)},0),ge=K.length>0?K.map(ce=>({label:ce.label,value:ce.value,color:ce.color||"blue"})):[{label:"Total Inspections",value:ke,color:"blue"}],re={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"},we=E||O||R||A&&(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 min-w-0 max-h-[90vh] overflow-hidden flex flex-col",children:[t.jsxs("div",{className:"bg-gradient-to-r from-emerald-500 to-teal-600 px-3 sm:px-6 py-4 flex items-center justify-between gap-2 flex-shrink-0 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 min-w-0 flex-1",children:[t.jsx(Tr,{className:"text-white text-xl shrink-0"}),t.jsx("h3",{className:"text-base sm:text-lg font-semibold text-white leading-tight break-words",children:"Inspection Linked Work Orders Summary"})]}),t.jsx("button",{type:"button",onClick:r,className:"text-white/80 hover:text-white p-1 rounded-lg hover:bg-white/20 transition-colors shrink-0",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-3 sm: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-3 min-w-0",children:[t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 w-full min-w-0",children:[t.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"WO Type"}),t.jsxs("select",{value:A,onChange:ce=>C(ce.target.value),disabled:!s&&a.length>0,className:"w-full min-w-0 max-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-emerald-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:opacity-60",children:[t.jsx("option",{value:"",children:"All Types"}),Y.map(ce=>t.jsx("option",{value:ce,children:ce},ce))]})]}),t.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"From Date"}),t.jsx("input",{type:"date",value:O,onChange:ce=>M(ce.target.value),className:"w-full min-w-0 max-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-emerald-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"To Date"}),t.jsx("input",{type:"date",value:R,onChange:ce=>F(ce.target.value),className:"w-full min-w-0 max-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-emerald-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]}),t.jsxs("div",{className:"flex flex-col sm:flex-row sm:flex-wrap sm:items-end gap-3 w-full min-w-0",children:[t.jsxs("div",{className:"flex flex-col gap-1 min-w-0 flex-1 sm:min-w-[12rem] sm:max-w-xl",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Department"}),t.jsxs("select",{value:E,onChange:ce=>S(ce.target.value),className:"w-full min-w-0 max-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-emerald-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:"All Departments"}),X.map(ce=>t.jsx("option",{value:ce,children:ce},ce))]})]}),we&&t.jsxs("button",{type:"button",onClick:()=>{S(""),M(""),F(""),(s||a.length===0)&&C("")},className:"text-xs text-red-500 hover:text-red-700 flex items-center gap-1 px-2 py-1.5 rounded-lg hover:bg-red-50 transition-colors self-start sm:self-auto shrink-0",children:[t.jsx(Pt,{size:10})," Clear"]})]})]}),!y&&ge.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 ${ge.length===1?"grid-cols-1":ge.length===2?"grid-cols-2":"grid-cols-3"}`,children:ge.map((ce,ye)=>t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-xs font-medium text-gray-500 mb-1",children:ce.label}),t.jsx("div",{className:`text-2xl font-bold ${re[ce.color]||"text-blue-600"}`,children:ce.value})]},ye))})}),t.jsx("div",{className:"p-6 overflow-auto flex-1",children:y?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"})}):ie.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:G.map((ce,ye)=>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 ${ye===0?"text-left":"text-right"}`,children:ce.label||ce.fieldname},ye))})}),t.jsx("tbody",{children:ie.map((ce,ye)=>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:G.map((te,q)=>{var J;return t.jsx("td",{className:`py-2.5 px-4 ${q===0?"text-gray-800 dark:text-gray-200 font-medium":"text-right text-gray-600 dark:text-gray-300 tabular-nums"}`,children:(J=ce[te.fieldname])!=null?J:"—"},q)})},ye))})]})})]})})},XU=({isOpen:e,onClose:r,permittedIssueTypes:a,isAdmin:s,defaultWorkOrderType:n,defaultFromDate:i,defaultToDate:c})=>{const[u,h]=_.useState(null),[g,y]=_.useState(!1),[w,E]=_.useState(i||""),[S,A]=_.useState(c||""),[C,O]=_.useState(n||""),[M,R]=_.useState(""),[F,z]=_.useState([]),[W,X]=_.useState([]);_.useEffect(()=>{O(n||"")},[n]),_.useEffect(()=>{e&&(E(i||""),A(c||""))},[e]),_.useEffect(()=>{if(!e)return;me(null,null,function*(){try{const[te,q]=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"})]),J=yield te.json(),ae=yield q.json();J.data&&z(J.data.map(oe=>oe.name)),ae.data&&X(ae.data.map(oe=>oe.name))}catch(te){console.error(te)}})},[e]);const B=s?F:a;if(_.useEffect(()=>{if(!e)return;me(null,null,function*(){y(!0);try{const te={};!s&&a.length>0?te.work_order_type=a.length===1?a[0]:a:C&&(te.work_order_type=C),M&&(te.department=M),w&&(te.from_date=w),S&&(te.to_date=S);const J=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:te,ignore_prepared_report:1})})).json();h(J.message||null)}catch(te){console.error(te)}finally{y(!1)}})},[e,C,M,w,S,a,s]),!e)return null;const Y=(u==null?void 0:u.columns)||[],G=((u==null?void 0:u.result)||[]).filter(ye=>ye&&typeof ye=="object"&&ye.custom_delete_status!=="Deleted"),ie=G.filter(ye=>!ye.is_total_row),fe=(u==null?void 0:u.report_summary)||[];((ye,te)=>{var J,ae;const q=ye.find(oe=>(oe==null?void 0:oe.fieldname)&&(oe.fieldname.toLowerCase().includes("work_order_type")||oe.fieldname.toLowerCase().includes("wo_type")||oe.fieldname.toLowerCase()==="type"));return q?q.fieldname:(J=ye[1])!=null&&J.fieldname?ye[1].fieldname:((ae=ye[0])==null?void 0:ae.fieldname)||""})(Y);const ke=Y.find(ye=>{const te=((ye.label||"")+(ye.fieldname||"")).toLowerCase();return te.includes("total_work")||te.includes("total work")}),ge=Y.find(ye=>{const te=((ye.label||"")+(ye.fieldname||"")).toLowerCase();return te.includes("total_rejected")||te.includes("total rejected")||te.includes("rejected")&&!te.includes("%")}),re=ke?ie.reduce((ye,te)=>ye+(parseFloat(te[ke.fieldname])||0),0):null,we=ge?ie.reduce((ye,te)=>ye+(parseFloat(te[ge.fieldname])||0),0):null,ee=re&&we&&re>0?(we/re*100).toFixed(2)+"%":null,ve=fe.length>0?fe.map(ye=>({label:ye.label,value:ye.value,color:ye.color||"blue"})):[...re!==null?[{label:"Total Work Orders",value:re,color:"blue"}]:[],...we!==null?[{label:"Total Rejected",value:we,color:"red"}]:[],...ee!==null?[{label:"Rejected %",value:ee,color:"orange"}]:[]],ce={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 min-w-0 max-h-[90vh] overflow-hidden flex flex-col",children:[t.jsxs("div",{className:"bg-gradient-to-r from-red-500 to-rose-600 px-3 sm:px-6 py-4 flex items-center justify-between gap-2 flex-shrink-0 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 min-w-0 flex-1",children:[t.jsx(Jr,{className:"text-white text-xl shrink-0"}),t.jsx("h3",{className:"text-base sm:text-lg font-semibold text-white leading-tight break-words",children:"WO Rejection Summary"})]}),t.jsx("button",{type:"button",onClick:r,className:"text-white/80 hover:text-white p-1 rounded-lg hover:bg-white/20 transition-colors shrink-0",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-3 sm:px-6 py-3 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/30 flex-shrink-0 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 min-w-0",children:[t.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"From Date"}),t.jsx("input",{type:"date",value:w,onChange:ye=>E(ye.target.value),className:"w-full min-w-0 max-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-red-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"To Date"}),t.jsx("input",{type:"date",value:S,onChange:ye=>A(ye.target.value),className:"w-full min-w-0 max-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-red-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"WO Type"}),t.jsxs("select",{value:C,onChange:ye=>O(ye.target.value),disabled:!s&&a.length>0,className:"w-full min-w-0 max-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-red-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:opacity-60",children:[t.jsx("option",{value:"",children:"All Types"}),B.map(ye=>t.jsx("option",{value:ye,children:ye},ye))]})]}),t.jsxs("div",{className:"flex flex-col gap-1 min-w-0 sm:col-span-2 lg:col-span-1",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Department"}),t.jsxs("select",{value:M,onChange:ye=>R(ye.target.value),className:"w-full min-w-0 max-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-red-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:"All Departments"}),W.map(ye=>t.jsx("option",{value:ye,children:ye},ye))]})]}),(w||S||C||M)&&t.jsx("div",{className:"flex items-end sm:col-span-2 lg:col-span-3",children:t.jsxs("button",{type:"button",onClick:()=>{E(""),A(""),O(""),R("")},className:"text-xs text-red-500 hover:text-red-700 flex items-center gap-1 px-2 py-1.5 rounded-lg hover:bg-red-50 transition-colors",children:[t.jsx(Pt,{size:10})," Clear"]})})]}),!g&&ve.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 ${ve.length===1?"grid-cols-1":ve.length===2?"grid-cols-2":"grid-cols-3"}`,children:ve.map((ye,te)=>t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-xs font-medium text-gray-500 mb-1",children:ye.label}),t.jsx("div",{className:`text-2xl font-bold ${ce[ye.color]||"text-blue-600"}`,children:ye.value})]},te))})}),t.jsx("div",{className:"p-6 overflow-auto flex-1",children:g?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"})}):G.length===0?t.jsx("div",{className:"text-center text-gray-400 py-16",children:"No data available"}):(()=>{const ye=Y.find(ae=>{const oe=((ae.label||"")+(ae.fieldname||"")).toLowerCase();return oe.includes("work_order_type")||oe.includes("wo_type")||oe.includes("type")}),te=Y.find(ae=>{const oe=((ae.label||"")+(ae.fieldname||"")).toLowerCase();return oe.includes("department")||oe.includes("dept")}),q=Y.find(ae=>{const oe=((ae.label||"")+(ae.fieldname||"")).toLowerCase();return oe.includes("total_rejected")||oe.includes("total rejected")||oe.includes("rejected")&&!oe.includes("%")}),J=ae=>{const oe=ye&&ae[ye.fieldname]||"",le=te&&ae[te.fieldname]||"";return js({work_order_type:oe||void 0,page:"1",department:le||void 0,status:"Rejected"},w,S)};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:Y.map((ae,oe)=>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 ${oe===0?"text-left rounded-tl-lg":"text-right"} ${oe===Y.length-1?"rounded-tr-lg":""}`,children:[ae.label||ae.fieldname,q&&ae.fieldname===q.fieldname&&t.jsx("span",{className:"ml-1 text-[9px] text-red-400 font-normal normal-case",children:"(click to view)"})]},oe))})}),t.jsx("tbody",{children:G.map((ae,oe)=>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:Y.map((le,be)=>{var rt;const Z=q&&le.fieldname===q.fieldname,Le=(rt=ae[le.fieldname])!=null?rt:"—",Pe=Z&&parseFloat(ae[le.fieldname])||0,Be=Z&&Pe>0,pe=Be?J(ae):null;return t.jsx("td",{className:`py-2.5 px-4 ${be===0?"text-gray-800 dark:text-gray-200 font-medium text-left":"text-right tabular-nums"} ${Be?"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:Be?()=>{window.location.href=pe}:void 0,title:Be?"View rejected work orders":void 0,children:Be?t.jsxs("span",{className:"flex items-center justify-end gap-1.5",children:[Le,t.jsx(ps,{size:9,className:"opacity-60 flex-shrink-0"})]}):Le},be)})},oe))})]})})()})]})})},ZU=({data:e,onOpenReport:r})=>{var E,S,A;const[a,s]=_.useState(!1);_.useEffect(()=>{const C=()=>s(!1);if(a)return document.addEventListener("click",C),()=>document.removeEventListener("click",C)},[a]);const n=(e==null?void 0:e.labels)||[],i=((S=(E=e==null?void 0:e.datasets)==null?void 0:E[0])==null?void 0:S.values)||[],c=n.reduce((C,O,M)=>{var R;return nc(O)||(C.labels.push(O),C.values.push((R=i[M])!=null?R:0)),C},{labels:[],values:[]}),u=c.labels,h=c.values,g=(A=e==null?void 0:e.overallAvg)!=null?A:0,y=Qc(u.length),w=Math.max(...h,.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(Md,{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:[g.toFixed(3)," hrs"]})]})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("button",{onClick:C=>{C.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:C=>{C.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(ps,{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:[g.toFixed(3)," ",t.jsx("span",{className:"text-sm font-normal",children:"hrs"})]})]}),!e||!u.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(Md,{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:u.map((C,O)=>{const M=h[O]||0,R=w>0?M/w*100:0,F=y[O],z=Math.max(R,M>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:`${z}%`,backgroundColor:F,opacity:.88},children:R>28&&t.jsxs("span",{className:"text-[9px] font-bold text-white whitespace-nowrap",children:[M.toFixed(2)," hrs"]})}),R<=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:[M.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:C,children:C})]},O)})}),u.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:u.map((C,O)=>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:y[O]}}),t.jsx("span",{className:"text-[9px] text-gray-400 truncate max-w-[90px]",children:C.length>14?C.substring(0,12)+"…":C})]},O))})]})},KU=({isOpen:e,onClose:r,permittedIssueTypes:a,isAdmin:s,defaultWorkOrderType:n,defaultFromDate:i,defaultToDate:c})=>{const[u,h]=_.useState(null),[g,y]=_.useState(!1),[w,E]=_.useState(""),[S,A]=_.useState(n||""),[C,O]=_.useState(i||""),[M,R]=_.useState(c||""),[F,z]=_.useState([]),[W,X]=_.useState([]);_.useEffect(()=>{A(n||"")},[n]),_.useEffect(()=>{e&&(O(i||""),R(c||""))},[e]),_.useEffect(()=>{if(!e)return;me(null,null,function*(){try{const[ae,oe]=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"})]),le=yield ae.json(),be=yield oe.json();le.data&&z(le.data.map(Z=>Z.name)),be.data&&X(be.data.map(Z=>Z.name))}catch(ae){console.error(ae)}})},[e]);const B=s?W:a;if(_.useEffect(()=>{if(!e)return;me(null,null,function*(){y(!0);try{const ae={};!s&&a.length>0?ae.work_order_type=a.length===1?a[0]:a:S&&(ae.work_order_type=S),w&&(ae.department=w),C&&(ae.from_date=C),M&&(ae.to_date=M);const le=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:ae,ignore_prepared_report:1})})).json();h(le.message||null)}catch(ae){console.error(ae)}finally{y(!1)}})},[e,w,S,C,M,a,s]),!e)return null;const Y=(u==null?void 0:u.columns)||[],G=((u==null?void 0:u.result)||[]).filter(J=>J&&typeof J=="object"),ie=G.filter(J=>!J.is_total_row),fe=(u==null?void 0:u.report_summary)||[],K=Y.find(J=>{const ae=((J.label||"")+(J.fieldname||"")).toLowerCase();return ae.includes("time_to_repair")||ae.includes("time to repair")||ae.includes("hours")})||Y[Y.length-1],ke=Y.find(J=>{const ae=((J.label||"")+(J.fieldname||"")).toLowerCase();return ae.includes("wo_type")||ae.includes("wo type")||ae.includes("work_order_type")})||Y[1],ge=fe.find(J=>{var ae,oe;return((ae=J.label)==null?void 0:ae.toLowerCase().includes("avg"))||((oe=J.label)==null?void 0:oe.toLowerCase().includes("overall"))}),re=ie.filter(J=>!nc(ke?J[ke.fieldname]:null)),we=ge?parseFloat(ge.value)||0:re.length>0&&K?re.reduce((J,ae)=>J+(parseFloat(ae[K.fieldname])||0),0)/re.length:0,ee={};ie.forEach(J=>{const ae=ke?J[ke.fieldname]:null;if(nc(ae))return;const oe=String(ae),le=K&&parseFloat(J[K.fieldname])||0;ee[oe]||(ee[oe]={total:0,count:0}),ee[oe].total+=le,ee[oe].count+=1});const ve=Object.keys(ee),ce=ve.map(J=>parseFloat((ee[J].total/ee[J].count).toFixed(3))),ye=Math.max(...ce,.001),te=Qc(ve.length),q=w||C||M||S&&(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 min-w-0 max-h-[90vh] overflow-hidden flex flex-col",children:[t.jsxs("div",{className:"bg-gradient-to-r from-pink-500 to-rose-600 px-3 sm:px-6 py-4 flex items-center justify-between gap-2 flex-shrink-0 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 min-w-0 flex-1",children:[t.jsx(Md,{className:"text-white text-xl shrink-0"}),t.jsx("h3",{className:"text-base sm:text-lg font-semibold text-white leading-tight break-words",children:"Time to Repair"})]}),t.jsx("button",{type:"button",onClick:r,className:"text-white/80 hover:text-white p-1 rounded-lg hover:bg-white/20 transition-colors shrink-0",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-3 sm:px-6 py-3 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/30 flex-shrink-0 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3 min-w-0",children:[t.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"From Date"}),t.jsx("input",{type:"date",value:C,onChange:J=>O(J.target.value),className:"w-full min-w-0 max-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-pink-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"To Date"}),t.jsx("input",{type:"date",value:M,onChange:J=>R(J.target.value),className:"w-full min-w-0 max-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-pink-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),t.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Department"}),t.jsxs("select",{value:w,onChange:J=>E(J.target.value),className:"w-full min-w-0 max-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-pink-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[t.jsx("option",{value:"",children:"All Departments"}),F.map(J=>t.jsx("option",{value:J,children:J},J))]})]}),t.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[t.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"WO Type"}),t.jsxs("select",{value:S,onChange:J=>A(J.target.value),disabled:!s&&a.length>0,className:"w-full min-w-0 max-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-pink-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:opacity-60",children:[t.jsx("option",{value:"",children:"All Types"}),B.map(J=>t.jsx("option",{value:J,children:J},J))]})]}),q&&t.jsx("div",{className:"flex items-end sm:col-span-2 lg:col-span-4",children:t.jsxs("button",{type:"button",onClick:()=>{E(""),A(""),O(""),R("")},className:"text-xs text-red-500 hover:text-red-700 flex items-center gap-1 px-2 py-1.5 rounded-lg hover:bg-red-50 transition-colors",children:[t.jsx(Pt,{size:10})," Clear"]})})]}),!g&&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:we.toFixed(3)})]}),t.jsx("div",{className:"p-6 overflow-auto flex-1 flex flex-col gap-6",children:g?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"})}):G.length===0?t.jsx("div",{className:"text-center text-gray-400 py-16",children:"No data available"}):t.jsxs(t.Fragment,{children:[ve.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:ve.map((J,ae)=>{const oe=ce[ae],le=ye>0?oe/ye*100:0,be=te[ae],Z=Math.max(le,oe>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:`${Z}%`,backgroundColor:be,opacity:.85},children:le>20&&t.jsx("span",{className:"text-[11px] font-semibold text-white",children:oe.toFixed(3)})}),le<=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:oe.toFixed(3)})]}),t.jsx("div",{className:"w-52 text-xs text-gray-700 dark:text-gray-200 font-medium truncate flex-shrink-0",title:J,children:J})]},ae)})})]}),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:Y.map((J,ae)=>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 ${ae===0?"text-left":"text-right"}`,children:J.label||J.fieldname},ae))})}),t.jsx("tbody",{children:G.map((J,ae)=>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 ${J.is_total_row?"font-bold bg-gray-50 dark:bg-gray-900/40 border-t-2 border-gray-300 dark:border-gray-600":""}`,children:Y.map((oe,le)=>{var rt;const be=(oe.fieldname||"").toLowerCase(),Z=(oe.label||"").toLowerCase(),Le=!J.is_total_row&&(be==="name"||be==="work_order"||be==="work_order_id"||Z==="work order"||Z==="work order id"||Z==="wo"),Pe=(rt=J[oe.fieldname])!=null?rt:"—",Be=Le?String(Pe):"",pe=Le&&Be&&Be!=="—";return t.jsx("td",{className:`py-2.5 px-4 ${le===0?"text-left font-medium":"text-right tabular-nums"} ${pe?"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:pe?()=>{window.location.href=js({work_order_id:Be},C,M)}:void 0,title:pe?`Open Work Order ${Be}`:void 0,children:pe?t.jsxs("span",{className:"flex items-center gap-1.5",children:[Pe,t.jsx(ps,{size:9,className:"opacity-50 flex-shrink-0"})]}):Pe},le)})},ae))})]})]})})]})})};function Qc(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 Sj(e,r){return function(){return e.apply(r,arguments)}}const{toString:JU}=Object.prototype,{getPrototypeOf:tb}=Object,{iterator:Tg,toStringTag:Cj}=Symbol,Ag=(e=>r=>{const a=JU.call(r);return e[a]||(e[a]=a.slice(8,-1).toLowerCase())})(Object.create(null)),gl=e=>(e=e.toLowerCase(),r=>Ag(r)===e),Og=e=>r=>typeof r===e,{isArray:iu}=Array,K0=Og("undefined");function rh(e){return e!==null&&!K0(e)&&e.constructor!==null&&!K0(e.constructor)&&ao(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ej=gl("ArrayBuffer");function QU(e){let r;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?r=ArrayBuffer.isView(e):r=e&&e.buffer&&Ej(e.buffer),r}const ez=Og("string"),ao=Og("function"),Tj=Og("number"),ah=e=>e!==null&&typeof e=="object",tz=e=>e===!0||e===!1,Rm=e=>{if(Ag(e)!=="object")return!1;const r=tb(e);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Cj in e)&&!(Tg in e)},rz=e=>{if(!ah(e)||rh(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch(r){return!1}},az=gl("Date"),sz=gl("File"),nz=gl("Blob"),iz=gl("FileList"),oz=e=>ah(e)&&ao(e.pipe),lz=e=>{let r;return e&&(typeof FormData=="function"&&e instanceof FormData||ao(e.append)&&((r=Ag(e))==="formdata"||r==="object"&&ao(e.toString)&&e.toString()==="[object FormData]"))},cz=gl("URLSearchParams"),[dz,uz,fz,hz]=["ReadableStream","Request","Response","Headers"].map(gl),mz=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function sh(e,r,{allOwnKeys:a=!1}={}){if(e===null||typeof e=="undefined")return;let s,n;if(typeof e!="object"&&(e=[e]),iu(e))for(s=0,n=e.length;s<n;s++)r.call(null,e[s],s,e);else{if(rh(e))return;const i=a?Object.getOwnPropertyNames(e):Object.keys(e),c=i.length;let u;for(s=0;s<c;s++)u=i[s],r.call(null,e[u],u,e)}}function Aj(e,r){if(rh(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 _d=typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:global,Oj=e=>!K0(e)&&e!==_d;function V1(){const{caseless:e,skipUndefined:r}=Oj(this)&&this||{},a={},s=(n,i)=>{const c=e&&Aj(a,i)||i;Rm(a[c])&&Rm(n)?a[c]=V1(a[c],n):Rm(n)?a[c]=V1({},n):iu(n)?a[c]=n.slice():(!r||!K0(n))&&(a[c]=n)};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&sh(arguments[n],s);return a}const gz=(e,r,a,{allOwnKeys:s}={})=>(sh(r,(n,i)=>{a&&ao(n)?e[i]=Sj(n,a):e[i]=n},{allOwnKeys:s}),e),xz=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),pz=(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)},yz=(e,r,a,s)=>{let n,i,c;const u={};if(r=r||{},e==null)return r;do{for(n=Object.getOwnPropertyNames(e),i=n.length;i-- >0;)c=n[i],(!s||s(c,e,r))&&!u[c]&&(r[c]=e[c],u[c]=!0);e=a!==!1&&tb(e)}while(e&&(!a||a(e,r))&&e!==Object.prototype);return r},bz=(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},vz=e=>{if(!e)return null;if(iu(e))return e;let r=e.length;if(!Tj(r))return null;const a=new Array(r);for(;r-- >0;)a[r]=e[r];return a},wz=(e=>r=>e&&r instanceof e)(typeof Uint8Array!="undefined"&&tb(Uint8Array)),_z=(e,r)=>{const s=(e&&e[Tg]).call(e);let n;for(;(n=s.next())&&!n.done;){const i=n.value;r.call(e,i[0],i[1])}},kz=(e,r)=>{let a;const s=[];for(;(a=e.exec(r))!==null;)s.push(a);return s},Nz=gl("HTMLFormElement"),jz=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(a,s,n){return s.toUpperCase()+n}),kk=(({hasOwnProperty:e})=>(r,a)=>e.call(r,a))(Object.prototype),Sz=gl("RegExp"),Dj=(e,r)=>{const a=Object.getOwnPropertyDescriptors(e),s={};sh(a,(n,i)=>{let c;(c=r(n,i,e))!==!1&&(s[i]=c||n)}),Object.defineProperties(e,s)},Cz=e=>{Dj(e,(r,a)=>{if(ao(e)&&["arguments","caller","callee"].indexOf(a)!==-1)return!1;const s=e[a];if(ao(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+"'")})}})},Ez=(e,r)=>{const a={},s=n=>{n.forEach(i=>{a[i]=!0})};return iu(e)?s(e):s(String(e).split(r)),a},Tz=()=>{},Az=(e,r)=>e!=null&&Number.isFinite(e=+e)?e:r;function Oz(e){return!!(e&&ao(e.append)&&e[Cj]==="FormData"&&e[Tg])}const Dz=e=>{const r=new Array(10),a=(s,n)=>{if(ah(s)){if(r.indexOf(s)>=0)return;if(rh(s))return s;if(!("toJSON"in s)){r[n]=s;const i=iu(s)?[]:{};return sh(s,(c,u)=>{const h=a(c,n+1);!K0(h)&&(i[u]=h)}),r[n]=void 0,i}}return s};return a(e,0)},Rz=gl("AsyncFunction"),Fz=e=>e&&(ah(e)||ao(e))&&ao(e.then)&&ao(e.catch),Rj=((e,r)=>e?setImmediate:r?((a,s)=>(_d.addEventListener("message",({source:n,data:i})=>{n===_d&&i===a&&s.length&&s.shift()()},!1),n=>{s.push(n),_d.postMessage(a,"*")}))(`axios@${Math.random()}`,[]):a=>setTimeout(a))(typeof setImmediate=="function",ao(_d.postMessage)),Iz=typeof queueMicrotask!="undefined"?queueMicrotask.bind(_d):typeof process!="undefined"&&process.nextTick||Rj,Mz=e=>e!=null&&ao(e[Tg]),Jt={isArray:iu,isArrayBuffer:Ej,isBuffer:rh,isFormData:lz,isArrayBufferView:QU,isString:ez,isNumber:Tj,isBoolean:tz,isObject:ah,isPlainObject:Rm,isEmptyObject:rz,isReadableStream:dz,isRequest:uz,isResponse:fz,isHeaders:hz,isUndefined:K0,isDate:az,isFile:sz,isBlob:nz,isRegExp:Sz,isFunction:ao,isStream:oz,isURLSearchParams:cz,isTypedArray:wz,isFileList:iz,forEach:sh,merge:V1,extend:gz,trim:mz,stripBOM:xz,inherits:pz,toFlatObject:yz,kindOf:Ag,kindOfTest:gl,endsWith:bz,toArray:vz,forEachEntry:_z,matchAll:kz,isHTMLForm:Nz,hasOwnProperty:kk,hasOwnProp:kk,reduceDescriptors:Dj,freezeMethods:Cz,toObjectSet:Ez,toCamelCase:jz,noop:Tz,toFiniteNumber:Az,findKey:Aj,global:_d,isContextDefined:Oj,isSpecCompliantForm:Oz,toJSONObject:Dz,isAsyncFn:Rz,isThenable:Fz,setImmediate:Rj,asap:Iz,isIterable:Mz};function ya(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)}Jt.inherits(ya,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:Jt.toJSONObject(this.config),code:this.code,status:this.status}}});const Fj=ya.prototype,Ij={};["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=>{Ij[e]={value:e}});Object.defineProperties(ya,Ij);Object.defineProperty(Fj,"isAxiosError",{value:!0});ya.from=(e,r,a,s,n,i)=>{const c=Object.create(Fj);Jt.toFlatObject(e,c,function(y){return y!==Error.prototype},g=>g!=="isAxiosError");const u=e&&e.message?e.message:"Error",h=r==null&&e?e.code:r;return ya.call(c,u,h,a,s,n),e&&c.cause==null&&Object.defineProperty(c,"cause",{value:e,configurable:!0}),c.name=e&&e.name||"Error",i&&Object.assign(c,i),c};const Pz=null;function G1(e){return Jt.isPlainObject(e)||Jt.isArray(e)}function Mj(e){return Jt.endsWith(e,"[]")?e.slice(0,-2):e}function Nk(e,r,a){return e?e.concat(r).map(function(n,i){return n=Mj(n),!a&&i?"["+n+"]":n}).join(a?".":""):r}function Lz(e){return Jt.isArray(e)&&!e.some(G1)}const Bz=Jt.toFlatObject(Jt,{},null,function(r){return/^is[A-Z]/.test(r)});function Dg(e,r,a){if(!Jt.isObject(e))throw new TypeError("target must be an object");r=r||new FormData,a=Jt.toFlatObject(a,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,O){return!Jt.isUndefined(O[C])});const s=a.metaTokens,n=a.visitor||y,i=a.dots,c=a.indexes,h=(a.Blob||typeof Blob!="undefined"&&Blob)&&Jt.isSpecCompliantForm(r);if(!Jt.isFunction(n))throw new TypeError("visitor must be a function");function g(A){if(A===null)return"";if(Jt.isDate(A))return A.toISOString();if(Jt.isBoolean(A))return A.toString();if(!h&&Jt.isBlob(A))throw new ya("Blob is not supported. Use a Buffer instead.");return Jt.isArrayBuffer(A)||Jt.isTypedArray(A)?h&&typeof Blob=="function"?new Blob([A]):Buffer.from(A):A}function y(A,C,O){let M=A;if(A&&!O&&typeof A=="object"){if(Jt.endsWith(C,"{}"))C=s?C:C.slice(0,-2),A=JSON.stringify(A);else if(Jt.isArray(A)&&Lz(A)||(Jt.isFileList(A)||Jt.endsWith(C,"[]"))&&(M=Jt.toArray(A)))return C=Mj(C),M.forEach(function(F,z){!(Jt.isUndefined(F)||F===null)&&r.append(c===!0?Nk([C],z,i):c===null?C:C+"[]",g(F))}),!1}return G1(A)?!0:(r.append(Nk(O,C,i),g(A)),!1)}const w=[],E=Object.assign(Bz,{defaultVisitor:y,convertValue:g,isVisitable:G1});function S(A,C){if(!Jt.isUndefined(A)){if(w.indexOf(A)!==-1)throw Error("Circular reference detected in "+C.join("."));w.push(A),Jt.forEach(A,function(M,R){(!(Jt.isUndefined(M)||M===null)&&n.call(r,M,Jt.isString(R)?R.trim():R,C,E))===!0&&S(M,C?C.concat(R):[R])}),w.pop()}}if(!Jt.isObject(e))throw new TypeError("data must be an object");return S(e),r}function jk(e){const r={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(s){return r[s]})}function rb(e,r){this._pairs=[],e&&Dg(e,this,r)}const Pj=rb.prototype;Pj.append=function(r,a){this._pairs.push([r,a])};Pj.toString=function(r){const a=r?function(s){return r.call(this,s,jk)}:jk;return this._pairs.map(function(n){return a(n[0])+"="+a(n[1])},"").join("&")};function Uz(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Lj(e,r,a){if(!r)return e;const s=a&&a.encode||Uz;Jt.isFunction(a)&&(a={serialize:a});const n=a&&a.serialize;let i;if(n?i=n(r,a):i=Jt.isURLSearchParams(r)?r.toString():new rb(r,a).toString(s),i){const c=e.indexOf("#");c!==-1&&(e=e.slice(0,c)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class Sk{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){Jt.forEach(this.handlers,function(s){s!==null&&r(s)})}}const Bj={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},zz=typeof URLSearchParams!="undefined"?URLSearchParams:rb,Wz=typeof FormData!="undefined"?FormData:null,Hz=typeof Blob!="undefined"?Blob:null,$z={isBrowser:!0,classes:{URLSearchParams:zz,FormData:Wz,Blob:Hz},protocols:["http","https","file","blob","url","data"]},ab=typeof window!="undefined"&&typeof document!="undefined",Y1=typeof navigator=="object"&&navigator||void 0,Vz=ab&&(!Y1||["ReactNative","NativeScript","NS"].indexOf(Y1.product)<0),Gz=typeof WorkerGlobalScope!="undefined"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Yz=ab&&window.location.href||"http://localhost",qz=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ab,hasStandardBrowserEnv:Vz,hasStandardBrowserWebWorkerEnv:Gz,navigator:Y1,origin:Yz},Symbol.toStringTag,{value:"Module"})),Si=Te(Te({},qz),$z);function Xz(e,r){return Dg(e,new Si.classes.URLSearchParams,Te({visitor:function(a,s,n,i){return Si.isNode&&Jt.isBuffer(a)?(this.append(s,a.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},r))}function Zz(e){return Jt.matchAll(/\w+|\[(\w*)]/g,e).map(r=>r[0]==="[]"?"":r[1]||r[0])}function Kz(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 Uj(e){function r(a,s,n,i){let c=a[i++];if(c==="__proto__")return!0;const u=Number.isFinite(+c),h=i>=a.length;return c=!c&&Jt.isArray(n)?n.length:c,h?(Jt.hasOwnProp(n,c)?n[c]=[n[c],s]:n[c]=s,!u):((!n[c]||!Jt.isObject(n[c]))&&(n[c]=[]),r(a,s,n[c],i)&&Jt.isArray(n[c])&&(n[c]=Kz(n[c])),!u)}if(Jt.isFormData(e)&&Jt.isFunction(e.entries)){const a={};return Jt.forEachEntry(e,(s,n)=>{r(Zz(s),n,a,0)}),a}return null}function Jz(e,r,a){if(Jt.isString(e))try{return(r||JSON.parse)(e),Jt.trim(e)}catch(s){if(s.name!=="SyntaxError")throw s}return(a||JSON.stringify)(e)}const nh={transitional:Bj,adapter:["xhr","http","fetch"],transformRequest:[function(r,a){const s=a.getContentType()||"",n=s.indexOf("application/json")>-1,i=Jt.isObject(r);if(i&&Jt.isHTMLForm(r)&&(r=new FormData(r)),Jt.isFormData(r))return n?JSON.stringify(Uj(r)):r;if(Jt.isArrayBuffer(r)||Jt.isBuffer(r)||Jt.isStream(r)||Jt.isFile(r)||Jt.isBlob(r)||Jt.isReadableStream(r))return r;if(Jt.isArrayBufferView(r))return r.buffer;if(Jt.isURLSearchParams(r))return a.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),r.toString();let u;if(i){if(s.indexOf("application/x-www-form-urlencoded")>-1)return Xz(r,this.formSerializer).toString();if((u=Jt.isFileList(r))||s.indexOf("multipart/form-data")>-1){const h=this.env&&this.env.FormData;return Dg(u?{"files[]":r}:r,h&&new h,this.formSerializer)}}return i||n?(a.setContentType("application/json",!1),Jz(r)):r}],transformResponse:[function(r){const a=this.transitional||nh.transitional,s=a&&a.forcedJSONParsing,n=this.responseType==="json";if(Jt.isResponse(r)||Jt.isReadableStream(r))return r;if(r&&Jt.isString(r)&&(s&&!this.responseType||n)){const c=!(a&&a.silentJSONParsing)&&n;try{return JSON.parse(r,this.parseReviver)}catch(u){if(c)throw u.name==="SyntaxError"?ya.from(u,ya.ERR_BAD_RESPONSE,this,null,this.response):u}}return r}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Si.classes.FormData,Blob:Si.classes.Blob},validateStatus:function(r){return r>=200&&r<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Jt.forEach(["delete","get","head","post","put","patch"],e=>{nh.headers[e]={}});const Qz=Jt.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"]),eW=e=>{const r={};let a,s,n;return e&&e.split(`
`).forEach(function(c){n=c.indexOf(":"),a=c.substring(0,n).trim().toLowerCase(),s=c.substring(n+1).trim(),!(!a||r[a]&&Qz[a])&&(a==="set-cookie"?r[a]?r[a].push(s):r[a]=[s]:r[a]=r[a]?r[a]+", "+s:s)}),r},Ck=Symbol("internals");function Ju(e){return e&&String(e).trim().toLowerCase()}function Fm(e){return e===!1||e==null?e:Jt.isArray(e)?e.map(Fm):String(e)}function tW(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 rW=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function a1(e,r,a,s,n){if(Jt.isFunction(s))return s.call(this,r,a);if(n&&(r=a),!!Jt.isString(r)){if(Jt.isString(s))return r.indexOf(s)!==-1;if(Jt.isRegExp(s))return s.test(r)}}function aW(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(r,a,s)=>a.toUpperCase()+s)}function sW(e,r){const a=Jt.toCamelCase(" "+r);["get","set","has"].forEach(s=>{Object.defineProperty(e,s+a,{value:function(n,i,c){return this[s].call(this,r,n,i,c)},configurable:!0})})}let so=class{constructor(r){r&&this.set(r)}set(r,a,s){const n=this;function i(u,h,g){const y=Ju(h);if(!y)throw new Error("header name must be a non-empty string");const w=Jt.findKey(n,y);(!w||n[w]===void 0||g===!0||g===void 0&&n[w]!==!1)&&(n[w||h]=Fm(u))}const c=(u,h)=>Jt.forEach(u,(g,y)=>i(g,y,h));if(Jt.isPlainObject(r)||r instanceof this.constructor)c(r,a);else if(Jt.isString(r)&&(r=r.trim())&&!rW(r))c(eW(r),a);else if(Jt.isObject(r)&&Jt.isIterable(r)){let u={},h,g;for(const y of r){if(!Jt.isArray(y))throw TypeError("Object iterator must return a key-value pair");u[g=y[0]]=(h=u[g])?Jt.isArray(h)?[...h,y[1]]:[h,y[1]]:y[1]}c(u,a)}else r!=null&&i(a,r,s);return this}get(r,a){if(r=Ju(r),r){const s=Jt.findKey(this,r);if(s){const n=this[s];if(!a)return n;if(a===!0)return tW(n);if(Jt.isFunction(a))return a.call(this,n,s);if(Jt.isRegExp(a))return a.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(r,a){if(r=Ju(r),r){const s=Jt.findKey(this,r);return!!(s&&this[s]!==void 0&&(!a||a1(this,this[s],s,a)))}return!1}delete(r,a){const s=this;let n=!1;function i(c){if(c=Ju(c),c){const u=Jt.findKey(s,c);u&&(!a||a1(s,s[u],u,a))&&(delete s[u],n=!0)}}return Jt.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||a1(this,this[i],i,r,!0))&&(delete this[i],n=!0)}return n}normalize(r){const a=this,s={};return Jt.forEach(this,(n,i)=>{const c=Jt.findKey(s,i);if(c){a[c]=Fm(n),delete a[i];return}const u=r?aW(i):String(i).trim();u!==i&&delete a[i],a[u]=Fm(n),s[u]=!0}),this}concat(...r){return this.constructor.concat(this,...r)}toJSON(r){const a=Object.create(null);return Jt.forEach(this,(s,n)=>{s!=null&&s!==!1&&(a[n]=r&&Jt.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[Ck]=this[Ck]={accessors:{}}).accessors,n=this.prototype;function i(c){const u=Ju(c);s[u]||(sW(n,c),s[u]=!0)}return Jt.isArray(r)?r.forEach(i):i(r),this}};so.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Jt.reduceDescriptors(so.prototype,({value:e},r)=>{let a=r[0].toUpperCase()+r.slice(1);return{get:()=>e,set(s){this[a]=s}}});Jt.freezeMethods(so);function s1(e,r){const a=this||nh,s=r||a,n=so.from(s.headers);let i=s.data;return Jt.forEach(e,function(u){i=u.call(a,i,n.normalize(),r?r.status:void 0)}),n.normalize(),i}function zj(e){return!!(e&&e.__CANCEL__)}function ou(e,r,a){ya.call(this,e==null?"canceled":e,ya.ERR_CANCELED,r,a),this.name="CanceledError"}Jt.inherits(ou,ya,{__CANCEL__:!0});function Wj(e,r,a){const s=a.config.validateStatus;!a.status||!s||s(a.status)?e(a):r(new ya("Request failed with status code "+a.status,[ya.ERR_BAD_REQUEST,ya.ERR_BAD_RESPONSE][Math.floor(a.status/100)-4],a.config,a.request,a))}function nW(e){const r=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return r&&r[1]||""}function iW(e,r){e=e||10;const a=new Array(e),s=new Array(e);let n=0,i=0,c;return r=r!==void 0?r:1e3,function(h){const g=Date.now(),y=s[i];c||(c=g),a[n]=h,s[n]=g;let w=i,E=0;for(;w!==n;)E+=a[w++],w=w%e;if(n=(n+1)%e,n===i&&(i=(i+1)%e),g-c<r)return;const S=y&&g-y;return S?Math.round(E*1e3/S):void 0}}function oW(e,r){let a=0,s=1e3/r,n,i;const c=(g,y=Date.now())=>{a=y,n=null,i&&(clearTimeout(i),i=null),e(...g)};return[(...g)=>{const y=Date.now(),w=y-a;w>=s?c(g,y):(n=g,i||(i=setTimeout(()=>{i=null,c(n)},s-w)))},()=>n&&c(n)]}const ig=(e,r,a=3)=>{let s=0;const n=iW(50,250);return oW(i=>{const c=i.loaded,u=i.lengthComputable?i.total:void 0,h=c-s,g=n(h),y=c<=u;s=c;const w={loaded:c,total:u,progress:u?c/u:void 0,bytes:h,rate:g||void 0,estimated:g&&u&&y?(u-c)/g:void 0,event:i,lengthComputable:u!=null,[r?"download":"upload"]:!0};e(w)},a)},Ek=(e,r)=>{const a=e!=null;return[s=>r[0]({lengthComputable:a,total:e,loaded:s}),r[1]]},Tk=e=>(...r)=>Jt.asap(()=>e(...r)),lW=Si.hasStandardBrowserEnv?((e,r)=>a=>(a=new URL(a,Si.origin),e.protocol===a.protocol&&e.host===a.host&&(r||e.port===a.port)))(new URL(Si.origin),Si.navigator&&/(msie|trident)/i.test(Si.navigator.userAgent)):()=>!0,cW=Si.hasStandardBrowserEnv?{write(e,r,a,s,n,i,c){if(typeof document=="undefined")return;const u=[`${e}=${encodeURIComponent(r)}`];Jt.isNumber(a)&&u.push(`expires=${new Date(a).toUTCString()}`),Jt.isString(s)&&u.push(`path=${s}`),Jt.isString(n)&&u.push(`domain=${n}`),i===!0&&u.push("secure"),Jt.isString(c)&&u.push(`SameSite=${c}`),document.cookie=u.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 dW(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function uW(e,r){return r?e.replace(/\/?\/$/,"")+"/"+r.replace(/^\/+/,""):e}function Hj(e,r,a){let s=!dW(r);return e&&(s||a==!1)?uW(e,r):r}const Ak=e=>e instanceof so?Te({},e):e;function $d(e,r){r=r||{};const a={};function s(g,y,w,E){return Jt.isPlainObject(g)&&Jt.isPlainObject(y)?Jt.merge.call({caseless:E},g,y):Jt.isPlainObject(y)?Jt.merge({},y):Jt.isArray(y)?y.slice():y}function n(g,y,w,E){if(Jt.isUndefined(y)){if(!Jt.isUndefined(g))return s(void 0,g,w,E)}else return s(g,y,w,E)}function i(g,y){if(!Jt.isUndefined(y))return s(void 0,y)}function c(g,y){if(Jt.isUndefined(y)){if(!Jt.isUndefined(g))return s(void 0,g)}else return s(void 0,y)}function u(g,y,w){if(w in r)return s(g,y);if(w in e)return s(void 0,g)}const h={url:i,method:i,data:i,baseURL:c,transformRequest:c,transformResponse:c,paramsSerializer:c,timeout:c,timeoutMessage:c,withCredentials:c,withXSRFToken:c,adapter:c,responseType:c,xsrfCookieName:c,xsrfHeaderName:c,onUploadProgress:c,onDownloadProgress:c,decompress:c,maxContentLength:c,maxBodyLength:c,beforeRedirect:c,transport:c,httpAgent:c,httpsAgent:c,cancelToken:c,socketPath:c,responseEncoding:c,validateStatus:u,headers:(g,y,w)=>n(Ak(g),Ak(y),w,!0)};return Jt.forEach(Object.keys(Te(Te({},e),r)),function(y){const w=h[y]||n,E=w(e[y],r[y],y);Jt.isUndefined(E)&&w!==u||(a[y]=E)}),a}const $j=e=>{const r=$d({},e);let{data:a,withXSRFToken:s,xsrfHeaderName:n,xsrfCookieName:i,headers:c,auth:u}=r;if(r.headers=c=so.from(c),r.url=Lj(Hj(r.baseURL,r.url,r.allowAbsoluteUrls),e.params,e.paramsSerializer),u&&c.set("Authorization","Basic "+btoa((u.username||"")+":"+(u.password?unescape(encodeURIComponent(u.password)):""))),Jt.isFormData(a)){if(Si.hasStandardBrowserEnv||Si.hasStandardBrowserWebWorkerEnv)c.setContentType(void 0);else if(Jt.isFunction(a.getHeaders)){const h=a.getHeaders(),g=["content-type","content-length"];Object.entries(h).forEach(([y,w])=>{g.includes(y.toLowerCase())&&c.set(y,w)})}}if(Si.hasStandardBrowserEnv&&(s&&Jt.isFunction(s)&&(s=s(r)),s||s!==!1&&lW(r.url))){const h=n&&i&&cW.read(i);h&&c.set(n,h)}return r},fW=typeof XMLHttpRequest!="undefined",hW=fW&&function(e){return new Promise(function(a,s){const n=$j(e);let i=n.data;const c=so.from(n.headers).normalize();let{responseType:u,onUploadProgress:h,onDownloadProgress:g}=n,y,w,E,S,A;function C(){S&&S(),A&&A(),n.cancelToken&&n.cancelToken.unsubscribe(y),n.signal&&n.signal.removeEventListener("abort",y)}let O=new XMLHttpRequest;O.open(n.method.toUpperCase(),n.url,!0),O.timeout=n.timeout;function M(){if(!O)return;const F=so.from("getAllResponseHeaders"in O&&O.getAllResponseHeaders()),W={data:!u||u==="text"||u==="json"?O.responseText:O.response,status:O.status,statusText:O.statusText,headers:F,config:e,request:O};Wj(function(B){a(B),C()},function(B){s(B),C()},W),O=null}"onloadend"in O?O.onloadend=M:O.onreadystatechange=function(){!O||O.readyState!==4||O.status===0&&!(O.responseURL&&O.responseURL.indexOf("file:")===0)||setTimeout(M)},O.onabort=function(){O&&(s(new ya("Request aborted",ya.ECONNABORTED,e,O)),O=null)},O.onerror=function(z){const W=z&&z.message?z.message:"Network Error",X=new ya(W,ya.ERR_NETWORK,e,O);X.event=z||null,s(X),O=null},O.ontimeout=function(){let z=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const W=n.transitional||Bj;n.timeoutErrorMessage&&(z=n.timeoutErrorMessage),s(new ya(z,W.clarifyTimeoutError?ya.ETIMEDOUT:ya.ECONNABORTED,e,O)),O=null},i===void 0&&c.setContentType(null),"setRequestHeader"in O&&Jt.forEach(c.toJSON(),function(z,W){O.setRequestHeader(W,z)}),Jt.isUndefined(n.withCredentials)||(O.withCredentials=!!n.withCredentials),u&&u!=="json"&&(O.responseType=n.responseType),g&&([E,A]=ig(g,!0),O.addEventListener("progress",E)),h&&O.upload&&([w,S]=ig(h),O.upload.addEventListener("progress",w),O.upload.addEventListener("loadend",S)),(n.cancelToken||n.signal)&&(y=F=>{O&&(s(!F||F.type?new ou(null,e,O):F),O.abort(),O=null)},n.cancelToken&&n.cancelToken.subscribe(y),n.signal&&(n.signal.aborted?y():n.signal.addEventListener("abort",y)));const R=nW(n.url);if(R&&Si.protocols.indexOf(R)===-1){s(new ya("Unsupported protocol "+R+":",ya.ERR_BAD_REQUEST,e));return}O.send(i||null)})},mW=(e,r)=>{const{length:a}=e=e?e.filter(Boolean):[];if(r||a){let s=new AbortController,n;const i=function(g){if(!n){n=!0,u();const y=g instanceof Error?g:this.reason;s.abort(y instanceof ya?y:new ou(y instanceof Error?y.message:y))}};let c=r&&setTimeout(()=>{c=null,i(new ya(`timeout ${r} of ms exceeded`,ya.ETIMEDOUT))},r);const u=()=>{e&&(c&&clearTimeout(c),c=null,e.forEach(g=>{g.unsubscribe?g.unsubscribe(i):g.removeEventListener("abort",i)}),e=null)};e.forEach(g=>g.addEventListener("abort",i));const{signal:h}=s;return h.unsubscribe=()=>Jt.asap(u),h}},gW=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},xW=function(e,r){return bp(this,null,function*(){try{for(var a=mw(pW(e)),s,n,i;s=!(n=yield new xd(a.next())).done;s=!1){const c=n.value;yield*vp(gW(c,r))}}catch(n){i=[n]}finally{try{s&&(n=a.return)&&(yield new xd(n.call(a)))}finally{if(i)throw i[0]}}})},pW=function(e){return bp(this,null,function*(){if(e[Symbol.asyncIterator]){yield*vp(e);return}const r=e.getReader();try{for(;;){const{done:a,value:s}=yield new xd(r.read());if(a)break;yield s}}finally{yield new xd(r.cancel())}})},Ok=(e,r,a,s)=>{const n=xW(e,r);let i=0,c,u=g=>{c||(c=!0,s&&s(g))};return new ReadableStream({pull(g){return me(this,null,function*(){try{const{done:y,value:w}=yield n.next();if(y){u(),g.close();return}let E=w.byteLength;if(a){let S=i+=E;a(S)}g.enqueue(new Uint8Array(w))}catch(y){throw u(y),y}})},cancel(g){return u(g),n.return()}},{highWaterMark:2})},Dk=64*1024,{isFunction:vm}=Jt,yW=(({Request:e,Response:r})=>({Request:e,Response:r}))(Jt.global),{ReadableStream:Rk,TextEncoder:Fk}=Jt.global,Ik=(e,...r)=>{try{return!!e(...r)}catch(a){return!1}},bW=e=>{e=Jt.merge.call({skipUndefined:!0},yW,e);const{fetch:r,Request:a,Response:s}=e,n=r?vm(r):typeof fetch=="function",i=vm(a),c=vm(s);if(!n)return!1;const u=n&&vm(Rk),h=n&&(typeof Fk=="function"?(A=>C=>A.encode(C))(new Fk):A=>me(null,null,function*(){return new Uint8Array(yield new a(A).arrayBuffer())})),g=i&&u&&Ik(()=>{let A=!1;const C=new a(Si.origin,{body:new Rk,method:"POST",get duplex(){return A=!0,"half"}}).headers.has("Content-Type");return A&&!C}),y=c&&u&&Ik(()=>Jt.isReadableStream(new s("").body)),w={stream:y&&(A=>A.body)};n&&["text","arrayBuffer","blob","formData","stream"].forEach(A=>{!w[A]&&(w[A]=(C,O)=>{let M=C&&C[A];if(M)return M.call(C);throw new ya(`Response type '${A}' is not supported`,ya.ERR_NOT_SUPPORT,O)})});const E=A=>me(null,null,function*(){if(A==null)return 0;if(Jt.isBlob(A))return A.size;if(Jt.isSpecCompliantForm(A))return(yield new a(Si.origin,{method:"POST",body:A}).arrayBuffer()).byteLength;if(Jt.isArrayBufferView(A)||Jt.isArrayBuffer(A))return A.byteLength;if(Jt.isURLSearchParams(A)&&(A=A+""),Jt.isString(A))return(yield h(A)).byteLength}),S=(A,C)=>me(null,null,function*(){const O=Jt.toFiniteNumber(A.getContentLength());return O==null?E(C):O});return A=>me(null,null,function*(){let{url:C,method:O,data:M,signal:R,cancelToken:F,timeout:z,onDownloadProgress:W,onUploadProgress:X,responseType:B,headers:Y,withCredentials:G="same-origin",fetchOptions:ie}=$j(A),fe=r||fetch;B=B?(B+"").toLowerCase():"text";let K=mW([R,F&&F.toAbortSignal()],z),ke=null;const ge=K&&K.unsubscribe&&(()=>{K.unsubscribe()});let re;try{if(X&&g&&O!=="get"&&O!=="head"&&(re=yield S(Y,M))!==0){let te=new a(C,{method:"POST",body:M,duplex:"half"}),q;if(Jt.isFormData(M)&&(q=te.headers.get("content-type"))&&Y.setContentType(q),te.body){const[J,ae]=Ek(re,ig(Tk(X)));M=Ok(te.body,Dk,J,ae)}}Jt.isString(G)||(G=G?"include":"omit");const we=i&&"credentials"in a.prototype,ee=Ke(Te({},ie),{signal:K,method:O.toUpperCase(),headers:Y.normalize().toJSON(),body:M,duplex:"half",credentials:we?G:void 0});ke=i&&new a(C,ee);let ve=yield i?fe(ke,ie):fe(C,ee);const ce=y&&(B==="stream"||B==="response");if(y&&(W||ce&&ge)){const te={};["status","statusText","headers"].forEach(oe=>{te[oe]=ve[oe]});const q=Jt.toFiniteNumber(ve.headers.get("content-length")),[J,ae]=W&&Ek(q,ig(Tk(W),!0))||[];ve=new s(Ok(ve.body,Dk,J,()=>{ae&&ae(),ge&&ge()}),te)}B=B||"text";let ye=yield w[Jt.findKey(w,B)||"text"](ve,A);return!ce&&ge&&ge(),yield new Promise((te,q)=>{Wj(te,q,{data:ye,headers:so.from(ve.headers),status:ve.status,statusText:ve.statusText,config:A,request:ke})})}catch(we){throw ge&&ge(),we&&we.name==="TypeError"&&/Load failed|fetch/i.test(we.message)?Object.assign(new ya("Network Error",ya.ERR_NETWORK,A,ke),{cause:we.cause||we}):ya.from(we,we&&we.code,A,ke)}})},vW=new Map,Vj=e=>{let r=e&&e.env||{};const{fetch:a,Request:s,Response:n}=r,i=[s,n,a];let c=i.length,u=c,h,g,y=vW;for(;u--;)h=i[u],g=y.get(h),g===void 0&&y.set(h,g=u?new Map:bW(r)),y=g;return g};Vj();const sb={http:Pz,xhr:hW,fetch:{get:Vj}};Jt.forEach(sb,(e,r)=>{if(e){try{Object.defineProperty(e,"name",{value:r})}catch(a){}Object.defineProperty(e,"adapterName",{value:r})}});const Mk=e=>`- ${e}`,wW=e=>Jt.isFunction(e)||e===null||e===!1;function _W(e,r){e=Jt.isArray(e)?e:[e];const{length:a}=e;let s,n;const i={};for(let c=0;c<a;c++){s=e[c];let u;if(n=s,!wW(s)&&(n=sb[(u=String(s)).toLowerCase()],n===void 0))throw new ya(`Unknown adapter '${u}'`);if(n&&(Jt.isFunction(n)||(n=n.get(r))))break;i[u||"#"+c]=n}if(!n){const c=Object.entries(i).map(([h,g])=>`adapter ${h} `+(g===!1?"is not supported by the environment":"is not available in the build"));let u=a?c.length>1?`since :
`+c.map(Mk).join(`
`):" "+Mk(c[0]):"as no adapter specified";throw new ya("There is no suitable adapter to dispatch the request "+u,"ERR_NOT_SUPPORT")}return n}const Gj={getAdapter:_W,adapters:sb};function n1(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ou(null,e)}function Pk(e){return n1(e),e.headers=so.from(e.headers),e.data=s1.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Gj.getAdapter(e.adapter||nh.adapter,e)(e).then(function(s){return n1(e),s.data=s1.call(e,e.transformResponse,s),s.headers=so.from(s.headers),s},function(s){return zj(s)||(n1(e),s&&s.response&&(s.response.data=s1.call(e,e.transformResponse,s.response),s.response.headers=so.from(s.response.headers))),Promise.reject(s)})}const Yj="1.13.2",Rg={};["object","boolean","number","function","string","symbol"].forEach((e,r)=>{Rg[e]=function(s){return typeof s===e||"a"+(r<1?"n ":" ")+e}});const Lk={};Rg.transitional=function(r,a,s){function n(i,c){return"[Axios v"+Yj+"] Transitional option '"+i+"'"+c+(s?". "+s:"")}return(i,c,u)=>{if(r===!1)throw new ya(n(c," has been removed"+(a?" in "+a:"")),ya.ERR_DEPRECATED);return a&&!Lk[c]&&(Lk[c]=!0,console.warn(n(c," has been deprecated since v"+a+" and will be removed in the near future"))),r?r(i,c,u):!0}};Rg.spelling=function(r){return(a,s)=>(console.warn(`${s} is likely a misspelling of ${r}`),!0)};function kW(e,r,a){if(typeof e!="object")throw new ya("options must be an object",ya.ERR_BAD_OPTION_VALUE);const s=Object.keys(e);let n=s.length;for(;n-- >0;){const i=s[n],c=r[i];if(c){const u=e[i],h=u===void 0||c(u,i,e);if(h!==!0)throw new ya("option "+i+" must be "+h,ya.ERR_BAD_OPTION_VALUE);continue}if(a!==!0)throw new ya("Unknown option "+i,ya.ERR_BAD_OPTION)}}const Im={assertOptions:kW,validators:Rg},Cl=Im.validators;let Dd=class{constructor(r){this.defaults=r||{},this.interceptors={request:new Sk,response:new Sk}}request(r,a){return me(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(c){}}throw s}})}_request(r,a){typeof r=="string"?(a=a||{},a.url=r):a=r||{},a=$d(this.defaults,a);const{transitional:s,paramsSerializer:n,headers:i}=a;s!==void 0&&Im.assertOptions(s,{silentJSONParsing:Cl.transitional(Cl.boolean),forcedJSONParsing:Cl.transitional(Cl.boolean),clarifyTimeoutError:Cl.transitional(Cl.boolean)},!1),n!=null&&(Jt.isFunction(n)?a.paramsSerializer={serialize:n}:Im.assertOptions(n,{encode:Cl.function,serialize:Cl.function},!0)),a.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?a.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:a.allowAbsoluteUrls=!0),Im.assertOptions(a,{baseUrl:Cl.spelling("baseURL"),withXsrfToken:Cl.spelling("withXSRFToken")},!0),a.method=(a.method||this.defaults.method||"get").toLowerCase();let c=i&&Jt.merge(i.common,i[a.method]);i&&Jt.forEach(["delete","get","head","post","put","patch","common"],A=>{delete i[A]}),a.headers=so.concat(c,i);const u=[];let h=!0;this.interceptors.request.forEach(function(C){typeof C.runWhen=="function"&&C.runWhen(a)===!1||(h=h&&C.synchronous,u.unshift(C.fulfilled,C.rejected))});const g=[];this.interceptors.response.forEach(function(C){g.push(C.fulfilled,C.rejected)});let y,w=0,E;if(!h){const A=[Pk.bind(this),void 0];for(A.unshift(...u),A.push(...g),E=A.length,y=Promise.resolve(a);w<E;)y=y.then(A[w++],A[w++]);return y}E=u.length;let S=a;for(;w<E;){const A=u[w++],C=u[w++];try{S=A(S)}catch(O){C.call(this,O);break}}try{y=Pk.call(this,S)}catch(A){return Promise.reject(A)}for(w=0,E=g.length;w<E;)y=y.then(g[w++],g[w++]);return y}getUri(r){r=$d(this.defaults,r);const a=Hj(r.baseURL,r.url,r.allowAbsoluteUrls);return Lj(a,r.params,r.paramsSerializer)}};Jt.forEach(["delete","get","head","options"],function(r){Dd.prototype[r]=function(a,s){return this.request($d(s||{},{method:r,url:a,data:(s||{}).data}))}});Jt.forEach(["post","put","patch"],function(r){function a(s){return function(i,c,u){return this.request($d(u||{},{method:r,headers:s?{"Content-Type":"multipart/form-data"}:{},url:i,data:c}))}}Dd.prototype[r]=a(),Dd.prototype[r+"Form"]=a(!0)});let NW=class qj{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 c=new Promise(u=>{s.subscribe(u),i=u}).then(n);return c.cancel=function(){s.unsubscribe(i)},c},r(function(i,c,u){s.reason||(s.reason=new ou(i,c,u),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 qj(function(n){r=n}),cancel:r}}};function jW(e){return function(a){return e.apply(null,a)}}function SW(e){return Jt.isObject(e)&&e.isAxiosError===!0}const q1={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(q1).forEach(([e,r])=>{q1[r]=e});function Xj(e){const r=new Dd(e),a=Sj(Dd.prototype.request,r);return Jt.extend(a,Dd.prototype,r,{allOwnKeys:!0}),Jt.extend(a,r,null,{allOwnKeys:!0}),a.create=function(n){return Xj($d(e,n))},a}const ln=Xj(nh);ln.Axios=Dd;ln.CanceledError=ou;ln.CancelToken=NW;ln.isCancel=zj;ln.VERSION=Yj;ln.toFormData=Dg;ln.AxiosError=ya;ln.Cancel=ln.CanceledError;ln.all=function(r){return Promise.all(r)};ln.spread=jW;ln.isAxiosError=SW;ln.mergeConfig=$d;ln.AxiosHeaders=so;ln.formToJSON=e=>Uj(Jt.isHTMLForm(e)?new FormData(e):e);ln.getAdapter=Gj.getAdapter;ln.HttpStatusCode=q1;ln.default=ln;const{Axios:oq,AxiosError:lq,CanceledError:cq,isCancel:dq,CancelToken:uq,VERSION:fq,all:hq,Cancel:mq,isAxiosError:gq,spread:xq,toFormData:pq,AxiosHeaders:yq,HttpStatusCode:bq,formToJSON:vq,getAdapter:wq,mergeConfig:_q}=ln;class CW{constructor(){Ii(this,"client");Ii(this,"baseURL");Ii(this,"siteName");this.baseURL="http://localhost:8000",this.siteName="seeraasm-med.seeraarabia.com",this.client=ln.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 me(this,null,function*(){return(yield this.client.post("/api/method/login",r)).data})}logout(){return me(this,null,function*(){return(yield this.client.post("/api/method/logout")).data})}getCurrentUser(){return me(this,null,function*(){return(yield this.client.get("/api/method/frappe.auth.get_logged_user")).data})}callMethod(s){return me(this,arguments,function*(r,a={}){return(yield this.client.post(`/api/method/${r}`,a)).data})}frappeGet(s){return me(this,arguments,function*(r,a={}){return this.callMethod(r,a)})}getDocTypeRecords(n){return me(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 me(this,null,function*(){return(yield this.client.get(`/api/resource/${r}/${a}`)).data})}createDocTypeRecord(r,a){return me(this,null,function*(){return(yield this.client.post(`/api/resource/${r}`,a)).data})}updateDocTypeRecord(r,a,s){return me(this,null,function*(){return(yield this.client.put(`/api/resource/${r}/${a}`,s)).data})}deleteDocTypeRecord(r,a){return me(this,null,function*(){return(yield this.client.delete(`/api/resource/${r}/${a}`)).data})}uploadFile(r,a="Home"){return me(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 Zj=new CW,EW=()=>{const{t:e}=Rr(),[r,a]=_.useState([]),[s,n]=_.useState(!0),[i,c]=_.useState(null),[u,h]=_.useState(""),g=Na();_.useEffect(()=>{y()},[]);const y=()=>me(null,null,function*(){var S,A;try{n(!0);const C=yield Zj.getDocTypeRecords("User",{},["name","full_name","email","enabled","creation","modified"]);a(C.message||[])}catch(C){c(((A=(S=C.response)==null?void 0:S.data)==null?void 0:A.message)||"Failed to load users")}finally{n(!1)}}),w=r.filter(S=>{var A,C,O;return((A=S.full_name)==null?void 0:A.toLowerCase().includes(u.toLowerCase()))||((C=S.email)==null?void 0:C.toLowerCase().includes(u.toLowerCase()))||((O=S.name)==null?void 0:O.toLowerCase().includes(u.toLowerCase()))}),E=S=>{g(`/users/${S.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:()=>g("/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:()=>g("/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:u,onChange:S=>h(S.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:y,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")," (",w.length,")"]}),t.jsx("p",{className:"mt-1 max-w-2xl text-sm text-gray-500 dark:text-gray-400",children:e("users.manageUsers")})]}),w.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(u?"users.tryAdjustingSearch":"users.noUsersAvailable")})]}):t.jsx("ul",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:w.map(S=>{var A;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:()=>E(S),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:((A=S.full_name)==null?void 0:A.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||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 ${S.enabled?"bg-green-400":"bg-red-400"}`}),S.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(S.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"})})]})]})},S.name)})})]})]})]})},TW=()=>{const{t:e}=Rr(),[r,a]=_.useState([]),[s,n]=_.useState(!0),[i,c]=_.useState(null);_.useEffect(()=>{u()},[]);const u=()=>me(null,null,function*(){try{n(!0);const w=yield Zj.frappeGet("frappe.desk.doctype.event.event.get_events");a(w.message||[])}catch(w){console.log("API call failed, using demo events:",w);const E=[{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(E),c(null)}finally{n(!1)}}),h=w=>new Date(w).toLocaleString(),g=w=>{switch(w.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"}},y=w=>{switch(w.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:u,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(w=>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:w.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 ${g(w.status)}`,children:w.status}),t.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${y(w.event_type)}`,children:w.event_type})]})]}),w.description&&t.jsx("p",{className:"mt-1 text-sm text-gray-600 dark:text-gray-400",children:w.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:[h(w.starts_on)," - ",h(w.ends_on)]})]})]})})})},w.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)"]})]})]})]})})]})]})};class AW{getAssets(r,a,s=20,n=0,i){return me(this,null,function*(){const c=new URLSearchParams;if(r&&Object.keys(r).length>0){const{toFrappeFilterArray:h}=yield Nd(()=>me(null,null,function*(){const{toFrappeFilterArray:y}=yield Promise.resolve().then(()=>Jj);return{toFrappeFilterArray:y}}),void 0),g=h(r);g.length>0&&c.append("filters",JSON.stringify(g))}a&&a.length>0&&c.append("fields",JSON.stringify(a)),c.append("limit",s.toString()),c.append("offset",n.toString()),i&&c.append("order_by",i);const u=`${Or.ENDPOINTS.GET_ASSETS}?${c.toString()}`;return Xt.apiCall(u)})}getAssetDetails(r){return me(this,null,function*(){const a=`${Or.ENDPOINTS.GET_ASSET_DETAILS}?asset_name=${encodeURIComponent(r)}`;return Xt.apiCall(a)})}createAsset(r){return me(this,null,function*(){return Xt.apiCall(Or.ENDPOINTS.CREATE_ASSET,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({asset_data:r})})})}updateAsset(r,a){return me(this,null,function*(){return Xt.apiCall(Or.ENDPOINTS.UPDATE_ASSET,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({asset_name:r,asset_data:a})})})}deleteAsset(r){return me(this,null,function*(){return Xt.apiCall(Or.ENDPOINTS.DELETE_ASSET,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({asset_name:r})})})}getAssetFilters(){return me(this,null,function*(){return Xt.apiCall(Or.ENDPOINTS.GET_ASSET_FILTERS)})}getAssetStats(){return me(this,null,function*(){return Xt.apiCall(Or.ENDPOINTS.GET_ASSET_STATS)})}searchAssets(r,a=10){return me(this,null,function*(){const s=`${Or.ENDPOINTS.SEARCH_ASSETS}?search_term=${encodeURIComponent(r)}&limit=${a}`;return Xt.apiCall(s)})}submitAsset(r){return me(this,null,function*(){return Xt.apiCall(Or.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 P0=new AW,OW=(e,r)=>{const a=Te({},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],c=a[s];if(typeof c=="string")i.includes(c)||(a[s]=["in",[]]);else if(Array.isArray(c)&&c[0]==="in"){const h=c[1].filter(g=>i.includes(g));a[s]=["in",h]}else a[s]=n}return a};function DW(e,r=20,a=0,s,n={}){const[i,c]=_.useState([]),[u,h]=_.useState(0),[g,y]=_.useState(!1),[w,E]=_.useState(!0),[S,A]=_.useState(null),[C,O]=_.useState(0),M=_.useRef(!1),R=JSON.stringify(e),F=JSON.stringify(n);_.useEffect(()=>{if(M.current&&S)return;let W=!1;return M.current=!0,me(null,null,function*(){try{E(!0);const B=OW(e,n);console.log("[useAssets] User filters:",e),console.log("[useAssets] Permission filters:",n),console.log("[useAssets] Merged filters:",B);const Y=yield P0.getAssets(B,void 0,r,a,s);W||(c(Y.assets),h(Y.total_count),y(Y.has_more),A(null))}catch(B){if(!W){const Y=B instanceof Error?B.message:"Failed to fetch assets";Y.includes("417")||Y.includes("Expectation Failed")||Y.includes("has no attribute")?A("API endpoint not deployed or misconfigured. Please check FIX_417_ERROR.md for solutions."):A(Y),c([]),h(0),y(!1)}}finally{W||E(!1)}}),()=>{W=!0}},[R,F,r,a,s,C]);const z=_.useCallback(()=>{M.current=!1,O(W=>W+1)},[]);return{assets:i,totalCount:u,hasMore:g,loading:w,error:S,refetch:z}}function RW(e){const[r,a]=_.useState(null),[s,n]=_.useState(!0),[i,c]=_.useState(null),u=_.useCallback(()=>me(null,null,function*(){if(!e){a(null),n(!1);return}try{n(!0),c(null);const g=yield P0.getAssetDetails(e);a(g)}catch(g){c(g instanceof Error?g.message:"Failed to fetch asset details")}finally{n(!1)}}),[e]);_.useEffect(()=>{u()},[u]);const h=_.useCallback(()=>{u()},[u]);return{asset:r,loading:s,error:i,refetch:h}}function Kj(){const[e,r]=_.useState(!1),[a,s]=_.useState(null);return{createAsset:h=>me(null,null,function*(){try{r(!0),s(null),console.log("[useAssetMutations] Creating asset with data:",h);const g=yield P0.createAsset(h);if(console.log("[useAssetMutations] Create asset response:",g),g.success)return g.asset;{const y=g.error||"Failed to create asset";throw new Error(y)}}catch(g){console.error("[useAssetMutations] Create asset error:",g);const y=g instanceof Error?g.message:"Failed to create asset";throw s(y),g}finally{r(!1)}}),updateAsset:(h,g)=>me(null,null,function*(){try{r(!0),s(null),console.log("[useAssetMutations] Updating asset:",h,"with data:",g);const y=yield P0.updateAsset(h,g);if(console.log("[useAssetMutations] Update asset response:",y),y.success)return y.asset;{const w=y.error||"Failed to update asset";throw new Error(w)}}catch(y){console.error("[useAssetMutations] Update asset error:",y);const w=y instanceof Error?y.message:"Failed to update asset";throw s(w),y}finally{r(!1)}}),deleteAsset:h=>me(null,null,function*(){try{r(!0),s(null);const g=yield P0.deleteAsset(h);if(!g.success)throw new Error("Failed to delete asset");return g}catch(g){const y=g instanceof Error?g.message:"Failed to delete asset";throw s(y),g}finally{r(!1)}}),submitAsset:h=>me(null,null,function*(){try{r(!0),s(null),console.log("[useAssetMutations] Submitting asset:",h);const g=yield P0.submitAsset(h);return console.log("[useAssetMutations] Submit asset response:",g),g}catch(g){console.error("[useAssetMutations] Submit asset error:",g);const y=g instanceof Error?g.message:"Failed to submit asset";throw s(y),g}finally{r(!1)}}),loading:e,error:a}}const ed=({currentPage:e,totalCount:r=0,pageSize:a,hasMore:s=!1,itemLabel:n,onPageChange:i,className:c=""})=>{const{t:u}=Rr(),h=n!=null?n:u("listPages.results"),g=r>0?Math.max(1,Math.ceil(r/a)):0,y=r>0,w=(e-1)*a+1,E=y?Math.min(e*a,r):e*a,[S,A]=_.useState(""),C=R=>{R.preventDefault();const F=parseInt(S.trim(),10);if(!Number.isNaN(F)&&F>=1){const z=y?Math.min(F,g):F;i(z),A("")}},O=()=>{if(g<=7)return Array.from({length:g},(F,z)=>z+1);const R=[];R.push(1),e>3&&R.push("ellipsis");for(let F=Math.max(2,e-1);F<=Math.min(g-1,e+1);F++)R.includes(F)||R.push(F);return e<g-2&&R.push("ellipsis"),g>1&&R.push(g),R};return s||e>1||y&&g>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 ${c}`,children:[t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:y?u("pagination.showingToOf",{start:w,end:E,total:r,label:h}):u("pagination.showingTo",{start:w,end:E,label:h})}),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:u("pagination.previous")}),y&&g>1&&t.jsx("div",{className:"flex items-center gap-1",children:O().map((R,F)=>R==="ellipsis"?t.jsx("span",{className:"px-2 text-gray-500 dark:text-gray-400",children:"…"},`e-${F}`):t.jsx("button",{type:"button",onClick:()=>i(R),className:`min-w-[2rem] px-2 py-1 text-sm font-medium rounded-lg transition-colors ${R===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:R},R))}),t.jsx("button",{type:"button",onClick:()=>i(e+1),disabled:y?e>=g:!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:u("pagination.next")}),t.jsxs("form",{onSubmit:C,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:u("pagination.goTo")}),t.jsx("input",{type:"number",min:1,max:y?g:void 0,value:S,onChange:R=>A(R.target.value),placeholder:y?`1-${g}`:u("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:u("pagination.go")})]})]})]}):null};function Ln(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 td(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 Jj=Object.freeze(Object.defineProperty({__proto__:null,buildDateRangeFilters:td,toFrappeFilterArray:Ln},Symbol.toStringTag,{value:"Module"}));var Fr;(function(e){e[e.QR_CODE=0]="QR_CODE",e[e.AZTEC=1]="AZTEC",e[e.CODABAR=2]="CODABAR",e[e.CODE_39=3]="CODE_39",e[e.CODE_93=4]="CODE_93",e[e.CODE_128=5]="CODE_128",e[e.DATA_MATRIX=6]="DATA_MATRIX",e[e.MAXICODE=7]="MAXICODE",e[e.ITF=8]="ITF",e[e.EAN_13=9]="EAN_13",e[e.EAN_8=10]="EAN_8",e[e.PDF_417=11]="PDF_417",e[e.RSS_14=12]="RSS_14",e[e.RSS_EXPANDED=13]="RSS_EXPANDED",e[e.UPC_A=14]="UPC_A",e[e.UPC_E=15]="UPC_E",e[e.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(Fr||(Fr={}));var Bk=new Map([[Fr.QR_CODE,"QR_CODE"],[Fr.AZTEC,"AZTEC"],[Fr.CODABAR,"CODABAR"],[Fr.CODE_39,"CODE_39"],[Fr.CODE_93,"CODE_93"],[Fr.CODE_128,"CODE_128"],[Fr.DATA_MATRIX,"DATA_MATRIX"],[Fr.MAXICODE,"MAXICODE"],[Fr.ITF,"ITF"],[Fr.EAN_13,"EAN_13"],[Fr.EAN_8,"EAN_8"],[Fr.PDF_417,"PDF_417"],[Fr.RSS_14,"RSS_14"],[Fr.RSS_EXPANDED,"RSS_EXPANDED"],[Fr.UPC_A,"UPC_A"],[Fr.UPC_E,"UPC_E"],[Fr.UPC_EAN_EXTENSION,"UPC_EAN_EXTENSION"]]),Uk;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.URL=1]="URL"})(Uk||(Uk={}));function FW(e){return Object.values(Fr).includes(e)}var og;(function(e){e[e.SCAN_TYPE_CAMERA=0]="SCAN_TYPE_CAMERA",e[e.SCAN_TYPE_FILE=1]="SCAN_TYPE_FILE"})(og||(og={}));var IW=(function(){function e(){}return e.GITHUB_PROJECT_URL="https://github.com/mebjas/html5-qrcode",e.SCAN_DEFAULT_FPS=2,e.DEFAULT_DISABLE_FLIP=!1,e.DEFAULT_REMEMBER_LAST_CAMERA_USED=!0,e.DEFAULT_SUPPORTED_SCAN_TYPE=[og.SCAN_TYPE_CAMERA,og.SCAN_TYPE_FILE],e})(),Qj=(function(){function e(r,a){this.format=r,this.formatName=a}return e.prototype.toString=function(){return this.formatName},e.create=function(r){if(!Bk.has(r))throw"".concat(r," not in html5QrcodeSupportedFormatsTextMap");return new e(r,Bk.get(r))},e})(),zk=(function(){function e(){}return e.createFromText=function(r){var a={text:r};return{decodedText:r,result:a}},e.createFromQrcodeResult=function(r){return{decodedText:r.text,result:r}},e})(),X1;(function(e){e[e.UNKWOWN_ERROR=0]="UNKWOWN_ERROR",e[e.IMPLEMENTATION_ERROR=1]="IMPLEMENTATION_ERROR",e[e.NO_CODE_FOUND_ERROR=2]="NO_CODE_FOUND_ERROR"})(X1||(X1={}));var MW=(function(){function e(){}return e.createFrom=function(r){return{errorMessage:r,type:X1.UNKWOWN_ERROR}},e})(),PW=(function(){function e(r){this.verbose=r}return e.prototype.log=function(r){this.verbose&&console.log(r)},e.prototype.warn=function(r){this.verbose&&console.warn(r)},e.prototype.logError=function(r,a){(this.verbose||a===!0)&&console.error(r)},e.prototype.logErrors=function(r){if(r.length===0)throw"Logger#logError called without arguments";this.verbose&&console.error(r)},e})();function ac(e){return typeof e=="undefined"||e===null}var L0=(function(){function e(){}return e.codeParseError=function(r){return"QR code parse error, error = ".concat(r)},e.errorGettingUserMedia=function(r){return"Error getting userMedia, error = ".concat(r)},e.onlyDeviceSupportedError=function(){return"The device doesn't support navigator.mediaDevices , only supported cameraIdOrConfig in this case is deviceId parameter (string)."},e.cameraStreamingNotSupported=function(){return"Camera streaming not supported by the browser."},e.unableToQuerySupportedDevices=function(){return"Unable to query supported devices, unknown error."},e.insecureContextCameraQueryError=function(){return"Camera access is only supported in secure context like https or localhost."},e.scannerPaused=function(){return"Scanner paused"},e})(),eS=(function(){function e(){}return e.isMediaStreamConstraintsValid=function(r,a){if(typeof r!="object"){var s=typeof r;return a.logError("videoConstraints should be of type object, the "+"object passed is of type ".concat(s,"."),!0),!1}for(var n=["autoGainControl","channelCount","echoCancellation","latency","noiseSuppression","sampleRate","sampleSize","volume"],i=new Set(n),c=Object.keys(r),u=0,h=c;u<h.length;u++){var g=h[u];if(i.has(g))return a.logError("".concat(g," is not supported videoConstaints."),!0),!1}return!0},e})(),of={exports:{}},LW=of.exports,Wk;function BW(){return Wk||(Wk=1,(function(e,r){(function(a,s){s(r)})(LW,(function(a){function s(Ne){return Ne==null}var n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(Ne,l){Ne.__proto__=l}||function(Ne,l){for(var f in l)l.hasOwnProperty(f)&&(Ne[f]=l[f])};function i(Ne,l){n(Ne,l);function f(){this.constructor=Ne}Ne.prototype=l===null?Object.create(l):(f.prototype=l.prototype,new f)}function c(Ne,l){var f=Object.setPrototypeOf;f?f(Ne,l):Ne.__proto__=l}function u(Ne,l){l===void 0&&(l=Ne.constructor);var f=Error.captureStackTrace;f&&f(Ne,l)}var h=(function(Ne){i(l,Ne);function l(f){var x=this.constructor,b=Ne.call(this,f)||this;return Object.defineProperty(b,"name",{value:x.name,enumerable:!1}),c(b,x.prototype),u(b),b}return l})(Error);class g extends h{constructor(l=void 0){super(l),this.message=l}getKind(){return this.constructor.kind}}g.kind="Exception";class y extends g{}y.kind="ArgumentException";class w extends g{}w.kind="IllegalArgumentException";class E{constructor(l){if(this.binarizer=l,l===null)throw new w("Binarizer must be non-null.")}getWidth(){return this.binarizer.getWidth()}getHeight(){return this.binarizer.getHeight()}getBlackRow(l,f){return this.binarizer.getBlackRow(l,f)}getBlackMatrix(){return(this.matrix===null||this.matrix===void 0)&&(this.matrix=this.binarizer.getBlackMatrix()),this.matrix}isCropSupported(){return this.binarizer.getLuminanceSource().isCropSupported()}crop(l,f,x,b){const v=this.binarizer.getLuminanceSource().crop(l,f,x,b);return new E(this.binarizer.createBinarizer(v))}isRotateSupported(){return this.binarizer.getLuminanceSource().isRotateSupported()}rotateCounterClockwise(){const l=this.binarizer.getLuminanceSource().rotateCounterClockwise();return new E(this.binarizer.createBinarizer(l))}rotateCounterClockwise45(){const l=this.binarizer.getLuminanceSource().rotateCounterClockwise45();return new E(this.binarizer.createBinarizer(l))}toString(){try{return this.getBlackMatrix().toString()}catch(l){return""}}}class S extends g{static getChecksumInstance(){return new S}}S.kind="ChecksumException";class A{constructor(l){this.source=l}getLuminanceSource(){return this.source}getWidth(){return this.source.getWidth()}getHeight(){return this.source.getHeight()}}class C{static arraycopy(l,f,x,b,v){for(;v--;)x[b++]=l[f++]}static currentTimeMillis(){return Date.now()}}class O extends g{}O.kind="IndexOutOfBoundsException";class M extends O{constructor(l=void 0,f=void 0){super(f),this.index=l,this.message=f}}M.kind="ArrayIndexOutOfBoundsException";class R{static fill(l,f){for(let x=0,b=l.length;x<b;x++)l[x]=f}static fillWithin(l,f,x,b){R.rangeCheck(l.length,f,x);for(let v=f;v<x;v++)l[v]=b}static rangeCheck(l,f,x){if(f>x)throw new w("fromIndex("+f+") > toIndex("+x+")");if(f<0)throw new M(f);if(x>l)throw new M(x)}static asList(...l){return l}static create(l,f,x){return Array.from({length:l}).map(v=>Array.from({length:f}).fill(x))}static createInt32Array(l,f,x){return Array.from({length:l}).map(v=>Int32Array.from({length:f}).fill(x))}static equals(l,f){if(!l||!f||!l.length||!f.length||l.length!==f.length)return!1;for(let x=0,b=l.length;x<b;x++)if(l[x]!==f[x])return!1;return!0}static hashCode(l){if(l===null)return 0;let f=1;for(const x of l)f=31*f+x;return f}static fillUint8Array(l,f){for(let x=0;x!==l.length;x++)l[x]=f}static copyOf(l,f){return l.slice(0,f)}static copyOfUint8Array(l,f){if(l.length<=f){const x=new Uint8Array(f);return x.set(l),x}return l.slice(0,f)}static copyOfRange(l,f,x){const b=x-f,v=new Int32Array(b);return C.arraycopy(l,f,v,0,b),v}static binarySearch(l,f,x){x===void 0&&(x=R.numberComparator);let b=0,v=l.length-1;for(;b<=v;){const j=v+b>>1,T=x(f,l[j]);if(T>0)b=j+1;else if(T<0)v=j-1;else return j}return-b-1}static numberComparator(l,f){return l-f}}class F{static numberOfTrailingZeros(l){let f;if(l===0)return 32;let x=31;return f=l<<16,f!==0&&(x-=16,l=f),f=l<<8,f!==0&&(x-=8,l=f),f=l<<4,f!==0&&(x-=4,l=f),f=l<<2,f!==0&&(x-=2,l=f),x-(l<<1>>>31)}static numberOfLeadingZeros(l){if(l===0)return 32;let f=1;return l>>>16||(f+=16,l<<=16),l>>>24||(f+=8,l<<=8),l>>>28||(f+=4,l<<=4),l>>>30||(f+=2,l<<=2),f-=l>>>31,f}static toHexString(l){return l.toString(16)}static toBinaryString(l){return String(parseInt(String(l),2))}static bitCount(l){return l=l-(l>>>1&1431655765),l=(l&858993459)+(l>>>2&858993459),l=l+(l>>>4)&252645135,l=l+(l>>>8),l=l+(l>>>16),l&63}static truncDivision(l,f){return Math.trunc(l/f)}static parseInt(l,f=void 0){return parseInt(l,f)}}F.MIN_VALUE_32_BITS=-2147483648,F.MAX_VALUE=Number.MAX_SAFE_INTEGER;class z{constructor(l,f){l===void 0?(this.size=0,this.bits=new Int32Array(1)):(this.size=l,f==null?this.bits=z.makeArray(l):this.bits=f)}getSize(){return this.size}getSizeInBytes(){return Math.floor((this.size+7)/8)}ensureCapacity(l){if(l>this.bits.length*32){const f=z.makeArray(l);C.arraycopy(this.bits,0,f,0,this.bits.length),this.bits=f}}get(l){return(this.bits[Math.floor(l/32)]&1<<(l&31))!==0}set(l){this.bits[Math.floor(l/32)]|=1<<(l&31)}flip(l){this.bits[Math.floor(l/32)]^=1<<(l&31)}getNextSet(l){const f=this.size;if(l>=f)return f;const x=this.bits;let b=Math.floor(l/32),v=x[b];v&=~((1<<(l&31))-1);const j=x.length;for(;v===0;){if(++b===j)return f;v=x[b]}const T=b*32+F.numberOfTrailingZeros(v);return T>f?f:T}getNextUnset(l){const f=this.size;if(l>=f)return f;const x=this.bits;let b=Math.floor(l/32),v=~x[b];v&=~((1<<(l&31))-1);const j=x.length;for(;v===0;){if(++b===j)return f;v=~x[b]}const T=b*32+F.numberOfTrailingZeros(v);return T>f?f:T}setBulk(l,f){this.bits[Math.floor(l/32)]=f}setRange(l,f){if(f<l||l<0||f>this.size)throw new w;if(f===l)return;f--;const x=Math.floor(l/32),b=Math.floor(f/32),v=this.bits;for(let j=x;j<=b;j++){const T=j>x?0:l&31,H=(2<<(j<b?31:f&31))-(1<<T);v[j]|=H}}clear(){const l=this.bits.length,f=this.bits;for(let x=0;x<l;x++)f[x]=0}isRange(l,f,x){if(f<l||l<0||f>this.size)throw new w;if(f===l)return!0;f--;const b=Math.floor(l/32),v=Math.floor(f/32),j=this.bits;for(let T=b;T<=v;T++){const P=T>b?0:l&31,de=(2<<(T<v?31:f&31))-(1<<P)&4294967295;if((j[T]&de)!==(x?de:0))return!1}return!0}appendBit(l){this.ensureCapacity(this.size+1),l&&(this.bits[Math.floor(this.size/32)]|=1<<(this.size&31)),this.size++}appendBits(l,f){if(f<0||f>32)throw new w("Num bits must be between 0 and 32");this.ensureCapacity(this.size+f);for(let x=f;x>0;x--)this.appendBit((l>>x-1&1)===1)}appendBitArray(l){const f=l.size;this.ensureCapacity(this.size+f);for(let x=0;x<f;x++)this.appendBit(l.get(x))}xor(l){if(this.size!==l.size)throw new w("Sizes don't match");const f=this.bits;for(let x=0,b=f.length;x<b;x++)f[x]^=l.bits[x]}toBytes(l,f,x,b){for(let v=0;v<b;v++){let j=0;for(let T=0;T<8;T++)this.get(l)&&(j|=1<<7-T),l++;f[x+v]=j}}getBitArray(){return this.bits}reverse(){const l=new Int32Array(this.bits.length),f=Math.floor((this.size-1)/32),x=f+1,b=this.bits;for(let v=0;v<x;v++){let j=b[v];j=j>>1&1431655765|(j&1431655765)<<1,j=j>>2&858993459|(j&858993459)<<2,j=j>>4&252645135|(j&252645135)<<4,j=j>>8&16711935|(j&16711935)<<8,j=j>>16&65535|(j&65535)<<16,l[f-v]=j}if(this.size!==x*32){const v=x*32-this.size;let j=l[0]>>>v;for(let T=1;T<x;T++){const P=l[T];j|=P<<32-v,l[T-1]=j,j=P>>>v}l[x-1]=j}this.bits=l}static makeArray(l){return new Int32Array(Math.floor((l+31)/32))}equals(l){if(!(l instanceof z))return!1;const f=l;return this.size===f.size&&R.equals(this.bits,f.bits)}hashCode(){return 31*this.size+R.hashCode(this.bits)}toString(){let l="";for(let f=0,x=this.size;f<x;f++)(f&7)===0&&(l+=" "),l+=this.get(f)?"X":".";return l}clone(){return new z(this.size,this.bits.slice())}}var W;(function(Ne){Ne[Ne.OTHER=0]="OTHER",Ne[Ne.PURE_BARCODE=1]="PURE_BARCODE",Ne[Ne.POSSIBLE_FORMATS=2]="POSSIBLE_FORMATS",Ne[Ne.TRY_HARDER=3]="TRY_HARDER",Ne[Ne.CHARACTER_SET=4]="CHARACTER_SET",Ne[Ne.ALLOWED_LENGTHS=5]="ALLOWED_LENGTHS",Ne[Ne.ASSUME_CODE_39_CHECK_DIGIT=6]="ASSUME_CODE_39_CHECK_DIGIT",Ne[Ne.ASSUME_GS1=7]="ASSUME_GS1",Ne[Ne.RETURN_CODABAR_START_END=8]="RETURN_CODABAR_START_END",Ne[Ne.NEED_RESULT_POINT_CALLBACK=9]="NEED_RESULT_POINT_CALLBACK",Ne[Ne.ALLOWED_EAN_EXTENSIONS=10]="ALLOWED_EAN_EXTENSIONS"})(W||(W={}));var X=W;class B extends g{static getFormatInstance(){return new B}}B.kind="FormatException";var Y;(function(Ne){Ne[Ne.Cp437=0]="Cp437",Ne[Ne.ISO8859_1=1]="ISO8859_1",Ne[Ne.ISO8859_2=2]="ISO8859_2",Ne[Ne.ISO8859_3=3]="ISO8859_3",Ne[Ne.ISO8859_4=4]="ISO8859_4",Ne[Ne.ISO8859_5=5]="ISO8859_5",Ne[Ne.ISO8859_6=6]="ISO8859_6",Ne[Ne.ISO8859_7=7]="ISO8859_7",Ne[Ne.ISO8859_8=8]="ISO8859_8",Ne[Ne.ISO8859_9=9]="ISO8859_9",Ne[Ne.ISO8859_10=10]="ISO8859_10",Ne[Ne.ISO8859_11=11]="ISO8859_11",Ne[Ne.ISO8859_13=12]="ISO8859_13",Ne[Ne.ISO8859_14=13]="ISO8859_14",Ne[Ne.ISO8859_15=14]="ISO8859_15",Ne[Ne.ISO8859_16=15]="ISO8859_16",Ne[Ne.SJIS=16]="SJIS",Ne[Ne.Cp1250=17]="Cp1250",Ne[Ne.Cp1251=18]="Cp1251",Ne[Ne.Cp1252=19]="Cp1252",Ne[Ne.Cp1256=20]="Cp1256",Ne[Ne.UnicodeBigUnmarked=21]="UnicodeBigUnmarked",Ne[Ne.UTF8=22]="UTF8",Ne[Ne.ASCII=23]="ASCII",Ne[Ne.Big5=24]="Big5",Ne[Ne.GB18030=25]="GB18030",Ne[Ne.EUC_KR=26]="EUC_KR"})(Y||(Y={}));class G{constructor(l,f,x,...b){this.valueIdentifier=l,this.name=x,typeof f=="number"?this.values=Int32Array.from([f]):this.values=f,this.otherEncodingNames=b,G.VALUE_IDENTIFIER_TO_ECI.set(l,this),G.NAME_TO_ECI.set(x,this);const v=this.values;for(let j=0,T=v.length;j!==T;j++){const P=v[j];G.VALUES_TO_ECI.set(P,this)}for(const j of b)G.NAME_TO_ECI.set(j,this)}getValueIdentifier(){return this.valueIdentifier}getName(){return this.name}getValue(){return this.values[0]}static getCharacterSetECIByValue(l){if(l<0||l>=900)throw new B("incorect value");const f=G.VALUES_TO_ECI.get(l);if(f===void 0)throw new B("incorect value");return f}static getCharacterSetECIByName(l){const f=G.NAME_TO_ECI.get(l);if(f===void 0)throw new B("incorect value");return f}equals(l){if(!(l instanceof G))return!1;const f=l;return this.getName()===f.getName()}}G.VALUE_IDENTIFIER_TO_ECI=new Map,G.VALUES_TO_ECI=new Map,G.NAME_TO_ECI=new Map,G.Cp437=new G(Y.Cp437,Int32Array.from([0,2]),"Cp437"),G.ISO8859_1=new G(Y.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),G.ISO8859_2=new G(Y.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),G.ISO8859_3=new G(Y.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),G.ISO8859_4=new G(Y.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),G.ISO8859_5=new G(Y.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),G.ISO8859_6=new G(Y.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),G.ISO8859_7=new G(Y.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),G.ISO8859_8=new G(Y.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),G.ISO8859_9=new G(Y.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),G.ISO8859_10=new G(Y.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),G.ISO8859_11=new G(Y.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),G.ISO8859_13=new G(Y.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),G.ISO8859_14=new G(Y.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),G.ISO8859_15=new G(Y.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),G.ISO8859_16=new G(Y.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),G.SJIS=new G(Y.SJIS,20,"SJIS","Shift_JIS"),G.Cp1250=new G(Y.Cp1250,21,"Cp1250","windows-1250"),G.Cp1251=new G(Y.Cp1251,22,"Cp1251","windows-1251"),G.Cp1252=new G(Y.Cp1252,23,"Cp1252","windows-1252"),G.Cp1256=new G(Y.Cp1256,24,"Cp1256","windows-1256"),G.UnicodeBigUnmarked=new G(Y.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),G.UTF8=new G(Y.UTF8,26,"UTF8","UTF-8"),G.ASCII=new G(Y.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),G.Big5=new G(Y.Big5,28,"Big5"),G.GB18030=new G(Y.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),G.EUC_KR=new G(Y.EUC_KR,30,"EUC_KR","EUC-KR");class ie extends g{}ie.kind="UnsupportedOperationException";class fe{static decode(l,f){const x=this.encodingName(f);return this.customDecoder?this.customDecoder(l,x):typeof TextDecoder=="undefined"||this.shouldDecodeOnFallback(x)?this.decodeFallback(l,x):new TextDecoder(x).decode(l)}static shouldDecodeOnFallback(l){return!fe.isBrowser()&&l==="ISO-8859-1"}static encode(l,f){const x=this.encodingName(f);return this.customEncoder?this.customEncoder(l,x):typeof TextEncoder=="undefined"?this.encodeFallback(l):new TextEncoder().encode(l)}static isBrowser(){return typeof window!="undefined"&&{}.toString.call(window)==="[object Window]"}static encodingName(l){return typeof l=="string"?l:l.getName()}static encodingCharacterSet(l){return l instanceof G?l:G.getCharacterSetECIByName(l)}static decodeFallback(l,f){const x=this.encodingCharacterSet(f);if(fe.isDecodeFallbackSupported(x)){let b="";for(let v=0,j=l.length;v<j;v++){let T=l[v].toString(16);T.length<2&&(T="0"+T),b+="%"+T}return decodeURIComponent(b)}if(x.equals(G.UnicodeBigUnmarked))return String.fromCharCode.apply(null,new Uint16Array(l.buffer));throw new ie(`Encoding ${this.encodingName(f)} not supported by fallback.`)}static isDecodeFallbackSupported(l){return l.equals(G.UTF8)||l.equals(G.ISO8859_1)||l.equals(G.ASCII)}static encodeFallback(l){const x=btoa(unescape(encodeURIComponent(l))).split(""),b=[];for(let v=0;v<x.length;v++)b.push(x[v].charCodeAt(0));return new Uint8Array(b)}}class K{static castAsNonUtf8Char(l,f=null){const x=f?f.getName():this.ISO88591;return fe.decode(new Uint8Array([l]),x)}static guessEncoding(l,f){if(f!=null&&f.get(X.CHARACTER_SET)!==void 0)return f.get(X.CHARACTER_SET).toString();const x=l.length;let b=!0,v=!0,j=!0,T=0,P=0,H=0,de=0,je=0,Ae=0,Ge=0,ot=0,ut=0,At=0,se=0;const Ee=l.length>3&&l[0]===239&&l[1]===187&&l[2]===191;for(let Ue=0;Ue<x&&(b||v||j);Ue++){const ht=l[Ue]&255;j&&(T>0?(ht&128)===0?j=!1:T--:(ht&128)!==0&&((ht&64)===0?j=!1:(T++,(ht&32)===0?P++:(T++,(ht&16)===0?H++:(T++,(ht&8)===0?de++:j=!1))))),b&&(ht>127&&ht<160?b=!1:ht>159&&(ht<192||ht===215||ht===247)&&se++),v&&(je>0?ht<64||ht===127||ht>252?v=!1:je--:ht===128||ht===160||ht>239?v=!1:ht>160&&ht<224?(Ae++,ot=0,Ge++,Ge>ut&&(ut=Ge)):ht>127?(je++,Ge=0,ot++,ot>At&&(At=ot)):(Ge=0,ot=0))}return j&&T>0&&(j=!1),v&&je>0&&(v=!1),j&&(Ee||P+H+de>0)?K.UTF8:v&&(K.ASSUME_SHIFT_JIS||ut>=3||At>=3)?K.SHIFT_JIS:b&&v?ut===2&&Ae===2||se*10>=x?K.SHIFT_JIS:K.ISO88591:b?K.ISO88591:v?K.SHIFT_JIS:j?K.UTF8:K.PLATFORM_DEFAULT_ENCODING}static format(l,...f){let x=-1;function b(j,T,P,H,de,je){if(j==="%%")return"%";if(f[++x]===void 0)return;j=H?parseInt(H.substr(1)):void 0;let Ae=de?parseInt(de.substr(1)):void 0,Ge;switch(je){case"s":Ge=f[x];break;case"c":Ge=f[x][0];break;case"f":Ge=parseFloat(f[x]).toFixed(j);break;case"p":Ge=parseFloat(f[x]).toPrecision(j);break;case"e":Ge=parseFloat(f[x]).toExponential(j);break;case"x":Ge=parseInt(f[x]).toString(Ae||16);break;case"d":Ge=parseFloat(parseInt(f[x],Ae||10).toPrecision(j)).toFixed(0);break}Ge=typeof Ge=="object"?JSON.stringify(Ge):(+Ge).toString(Ae);let ot=parseInt(P),ut=P&&P[0]+""=="0"?"0":" ";for(;Ge.length<ot;)Ge=T!==void 0?Ge+ut:ut+Ge;return Ge}let v=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return l.replace(v,b)}static getBytes(l,f){return fe.encode(l,f)}static getCharCode(l,f=0){return l.charCodeAt(f)}static getCharAt(l){return String.fromCharCode(l)}}K.SHIFT_JIS=G.SJIS.getName(),K.GB2312="GB2312",K.ISO88591=G.ISO8859_1.getName(),K.EUC_JP="EUC_JP",K.UTF8=G.UTF8.getName(),K.PLATFORM_DEFAULT_ENCODING=K.UTF8,K.ASSUME_SHIFT_JIS=!1;class ke{constructor(l=""){this.value=l}enableDecoding(l){return this.encoding=l,this}append(l){return typeof l=="string"?this.value+=l.toString():this.encoding?this.value+=K.castAsNonUtf8Char(l,this.encoding):this.value+=String.fromCharCode(l),this}appendChars(l,f,x){for(let b=f;f<f+x;b++)this.append(l[b]);return this}length(){return this.value.length}charAt(l){return this.value.charAt(l)}deleteCharAt(l){this.value=this.value.substr(0,l)+this.value.substring(l+1)}setCharAt(l,f){this.value=this.value.substr(0,l)+f+this.value.substr(l+1)}substring(l,f){return this.value.substring(l,f)}setLengthToZero(){this.value=""}toString(){return this.value}insert(l,f){this.value=this.value.substr(0,l)+f+this.value.substr(l+f.length)}}class ge{constructor(l,f,x,b){if(this.width=l,this.height=f,this.rowSize=x,this.bits=b,f==null&&(f=l),this.height=f,l<1||f<1)throw new w("Both dimensions must be greater than 0");x==null&&(x=Math.floor((l+31)/32)),this.rowSize=x,b==null&&(this.bits=new Int32Array(this.rowSize*this.height))}static parseFromBooleanArray(l){const f=l.length,x=l[0].length,b=new ge(x,f);for(let v=0;v<f;v++){const j=l[v];for(let T=0;T<x;T++)j[T]&&b.set(T,v)}return b}static parseFromString(l,f,x){if(l===null)throw new w("stringRepresentation cannot be null");const b=new Array(l.length);let v=0,j=0,T=-1,P=0,H=0;for(;H<l.length;)if(l.charAt(H)===`
`||l.charAt(H)==="\r"){if(v>j){if(T===-1)T=v-j;else if(v-j!==T)throw new w("row lengths do not match");j=v,P++}H++}else if(l.substring(H,H+f.length)===f)H+=f.length,b[v]=!0,v++;else if(l.substring(H,H+x.length)===x)H+=x.length,b[v]=!1,v++;else throw new w("illegal character encountered: "+l.substring(H));if(v>j){if(T===-1)T=v-j;else if(v-j!==T)throw new w("row lengths do not match");P++}const de=new ge(T,P);for(let je=0;je<v;je++)b[je]&&de.set(Math.floor(je%T),Math.floor(je/T));return de}get(l,f){const x=f*this.rowSize+Math.floor(l/32);return(this.bits[x]>>>(l&31)&1)!==0}set(l,f){const x=f*this.rowSize+Math.floor(l/32);this.bits[x]|=1<<(l&31)&4294967295}unset(l,f){const x=f*this.rowSize+Math.floor(l/32);this.bits[x]&=~(1<<(l&31)&4294967295)}flip(l,f){const x=f*this.rowSize+Math.floor(l/32);this.bits[x]^=1<<(l&31)&4294967295}xor(l){if(this.width!==l.getWidth()||this.height!==l.getHeight()||this.rowSize!==l.getRowSize())throw new w("input matrix dimensions do not match");const f=new z(Math.floor(this.width/32)+1),x=this.rowSize,b=this.bits;for(let v=0,j=this.height;v<j;v++){const T=v*x,P=l.getRow(v,f).getBitArray();for(let H=0;H<x;H++)b[T+H]^=P[H]}}clear(){const l=this.bits,f=l.length;for(let x=0;x<f;x++)l[x]=0}setRegion(l,f,x,b){if(f<0||l<0)throw new w("Left and top must be nonnegative");if(b<1||x<1)throw new w("Height and width must be at least 1");const v=l+x,j=f+b;if(j>this.height||v>this.width)throw new w("The region must fit inside the matrix");const T=this.rowSize,P=this.bits;for(let H=f;H<j;H++){const de=H*T;for(let je=l;je<v;je++)P[de+Math.floor(je/32)]|=1<<(je&31)&4294967295}}getRow(l,f){f==null||f.getSize()<this.width?f=new z(this.width):f.clear();const x=this.rowSize,b=this.bits,v=l*x;for(let j=0;j<x;j++)f.setBulk(j*32,b[v+j]);return f}setRow(l,f){C.arraycopy(f.getBitArray(),0,this.bits,l*this.rowSize,this.rowSize)}rotate180(){const l=this.getWidth(),f=this.getHeight();let x=new z(l),b=new z(l);for(let v=0,j=Math.floor((f+1)/2);v<j;v++)x=this.getRow(v,x),b=this.getRow(f-1-v,b),x.reverse(),b.reverse(),this.setRow(v,b),this.setRow(f-1-v,x)}getEnclosingRectangle(){const l=this.width,f=this.height,x=this.rowSize,b=this.bits;let v=l,j=f,T=-1,P=-1;for(let H=0;H<f;H++)for(let de=0;de<x;de++){const je=b[H*x+de];if(je!==0){if(H<j&&(j=H),H>P&&(P=H),de*32<v){let Ae=0;for(;(je<<31-Ae&4294967295)===0;)Ae++;de*32+Ae<v&&(v=de*32+Ae)}if(de*32+31>T){let Ae=31;for(;!(je>>>Ae);)Ae--;de*32+Ae>T&&(T=de*32+Ae)}}}return T<v||P<j?null:Int32Array.from([v,j,T-v+1,P-j+1])}getTopLeftOnBit(){const l=this.rowSize,f=this.bits;let x=0;for(;x<f.length&&f[x]===0;)x++;if(x===f.length)return null;const b=x/l;let v=x%l*32;const j=f[x];let T=0;for(;(j<<31-T&4294967295)===0;)T++;return v+=T,Int32Array.from([v,b])}getBottomRightOnBit(){const l=this.rowSize,f=this.bits;let x=f.length-1;for(;x>=0&&f[x]===0;)x--;if(x<0)return null;const b=Math.floor(x/l);let v=Math.floor(x%l)*32;const j=f[x];let T=31;for(;!(j>>>T);)T--;return v+=T,Int32Array.from([v,b])}getWidth(){return this.width}getHeight(){return this.height}getRowSize(){return this.rowSize}equals(l){if(!(l instanceof ge))return!1;const f=l;return this.width===f.width&&this.height===f.height&&this.rowSize===f.rowSize&&R.equals(this.bits,f.bits)}hashCode(){let l=this.width;return l=31*l+this.width,l=31*l+this.height,l=31*l+this.rowSize,l=31*l+R.hashCode(this.bits),l}toString(l="X ",f=" ",x=`
`){return this.buildToString(l,f,x)}buildToString(l,f,x){let b=new ke;for(let v=0,j=this.height;v<j;v++){for(let T=0,P=this.width;T<P;T++)b.append(this.get(T,v)?l:f);b.append(x)}return b.toString()}clone(){return new ge(this.width,this.height,this.rowSize,this.bits.slice())}}class re extends g{static getNotFoundInstance(){return new re}}re.kind="NotFoundException";class we extends A{constructor(l){super(l),this.luminances=we.EMPTY,this.buckets=new Int32Array(we.LUMINANCE_BUCKETS)}getBlackRow(l,f){const x=this.getLuminanceSource(),b=x.getWidth();f==null||f.getSize()<b?f=new z(b):f.clear(),this.initArrays(b);const v=x.getRow(l,this.luminances),j=this.buckets;for(let P=0;P<b;P++)j[(v[P]&255)>>we.LUMINANCE_SHIFT]++;const T=we.estimateBlackPoint(j);if(b<3)for(let P=0;P<b;P++)(v[P]&255)<T&&f.set(P);else{let P=v[0]&255,H=v[1]&255;for(let de=1;de<b-1;de++){const je=v[de+1]&255;(H*4-P-je)/2<T&&f.set(de),P=H,H=je}}return f}getBlackMatrix(){const l=this.getLuminanceSource(),f=l.getWidth(),x=l.getHeight(),b=new ge(f,x);this.initArrays(f);const v=this.buckets;for(let P=1;P<5;P++){const H=Math.floor(x*P/5),de=l.getRow(H,this.luminances),je=Math.floor(f*4/5);for(let Ae=Math.floor(f/5);Ae<je;Ae++){const Ge=de[Ae]&255;v[Ge>>we.LUMINANCE_SHIFT]++}}const j=we.estimateBlackPoint(v),T=l.getMatrix();for(let P=0;P<x;P++){const H=P*f;for(let de=0;de<f;de++)(T[H+de]&255)<j&&b.set(de,P)}return b}createBinarizer(l){return new we(l)}initArrays(l){this.luminances.length<l&&(this.luminances=new Uint8ClampedArray(l));const f=this.buckets;for(let x=0;x<we.LUMINANCE_BUCKETS;x++)f[x]=0}static estimateBlackPoint(l){const f=l.length;let x=0,b=0,v=0;for(let de=0;de<f;de++)l[de]>v&&(b=de,v=l[de]),l[de]>x&&(x=l[de]);let j=0,T=0;for(let de=0;de<f;de++){const je=de-b,Ae=l[de]*je*je;Ae>T&&(j=de,T=Ae)}if(b>j){const de=b;b=j,j=de}if(j-b<=f/16)throw new re;let P=j-1,H=-1;for(let de=j-1;de>b;de--){const je=de-b,Ae=je*je*(j-de)*(x-l[de]);Ae>H&&(P=de,H=Ae)}return P<<we.LUMINANCE_SHIFT}}we.LUMINANCE_BITS=5,we.LUMINANCE_SHIFT=8-we.LUMINANCE_BITS,we.LUMINANCE_BUCKETS=1<<we.LUMINANCE_BITS,we.EMPTY=Uint8ClampedArray.from([0]);class ee extends we{constructor(l){super(l),this.matrix=null}getBlackMatrix(){if(this.matrix!==null)return this.matrix;const l=this.getLuminanceSource(),f=l.getWidth(),x=l.getHeight();if(f>=ee.MINIMUM_DIMENSION&&x>=ee.MINIMUM_DIMENSION){const b=l.getMatrix();let v=f>>ee.BLOCK_SIZE_POWER;(f&ee.BLOCK_SIZE_MASK)!==0&&v++;let j=x>>ee.BLOCK_SIZE_POWER;(x&ee.BLOCK_SIZE_MASK)!==0&&j++;const T=ee.calculateBlackPoints(b,v,j,f,x),P=new ge(f,x);ee.calculateThresholdForBlock(b,v,j,f,x,T,P),this.matrix=P}else this.matrix=super.getBlackMatrix();return this.matrix}createBinarizer(l){return new ee(l)}static calculateThresholdForBlock(l,f,x,b,v,j,T){const P=v-ee.BLOCK_SIZE,H=b-ee.BLOCK_SIZE;for(let de=0;de<x;de++){let je=de<<ee.BLOCK_SIZE_POWER;je>P&&(je=P);const Ae=ee.cap(de,2,x-3);for(let Ge=0;Ge<f;Ge++){let ot=Ge<<ee.BLOCK_SIZE_POWER;ot>H&&(ot=H);const ut=ee.cap(Ge,2,f-3);let At=0;for(let Ee=-2;Ee<=2;Ee++){const Ue=j[Ae+Ee];At+=Ue[ut-2]+Ue[ut-1]+Ue[ut]+Ue[ut+1]+Ue[ut+2]}const se=At/25;ee.thresholdBlock(l,ot,je,se,b,T)}}}static cap(l,f,x){return l<f?f:l>x?x:l}static thresholdBlock(l,f,x,b,v,j){for(let T=0,P=x*v+f;T<ee.BLOCK_SIZE;T++,P+=v)for(let H=0;H<ee.BLOCK_SIZE;H++)(l[P+H]&255)<=b&&j.set(f+H,x+T)}static calculateBlackPoints(l,f,x,b,v){const j=v-ee.BLOCK_SIZE,T=b-ee.BLOCK_SIZE,P=new Array(x);for(let H=0;H<x;H++){P[H]=new Int32Array(f);let de=H<<ee.BLOCK_SIZE_POWER;de>j&&(de=j);for(let je=0;je<f;je++){let Ae=je<<ee.BLOCK_SIZE_POWER;Ae>T&&(Ae=T);let Ge=0,ot=255,ut=0;for(let se=0,Ee=de*b+Ae;se<ee.BLOCK_SIZE;se++,Ee+=b){for(let Ue=0;Ue<ee.BLOCK_SIZE;Ue++){const ht=l[Ee+Ue]&255;Ge+=ht,ht<ot&&(ot=ht),ht>ut&&(ut=ht)}if(ut-ot>ee.MIN_DYNAMIC_RANGE)for(se++,Ee+=b;se<ee.BLOCK_SIZE;se++,Ee+=b)for(let Ue=0;Ue<ee.BLOCK_SIZE;Ue++)Ge+=l[Ee+Ue]&255}let At=Ge>>ee.BLOCK_SIZE_POWER*2;if(ut-ot<=ee.MIN_DYNAMIC_RANGE&&(At=ot/2,H>0&&je>0)){const se=(P[H-1][je]+2*P[H][je-1]+P[H-1][je-1])/4;ot<se&&(At=se)}P[H][je]=At}}return P}}ee.BLOCK_SIZE_POWER=3,ee.BLOCK_SIZE=1<<ee.BLOCK_SIZE_POWER,ee.BLOCK_SIZE_MASK=ee.BLOCK_SIZE-1,ee.MINIMUM_DIMENSION=ee.BLOCK_SIZE*5,ee.MIN_DYNAMIC_RANGE=24;class ve{constructor(l,f){this.width=l,this.height=f}getWidth(){return this.width}getHeight(){return this.height}isCropSupported(){return!1}crop(l,f,x,b){throw new ie("This luminance source does not support cropping.")}isRotateSupported(){return!1}rotateCounterClockwise(){throw new ie("This luminance source does not support rotation by 90 degrees.")}rotateCounterClockwise45(){throw new ie("This luminance source does not support rotation by 45 degrees.")}toString(){const l=new Uint8ClampedArray(this.width);let f=new ke;for(let x=0;x<this.height;x++){const b=this.getRow(x,l);for(let v=0;v<this.width;v++){const j=b[v]&255;let T;j<64?T="#":j<128?T="+":j<192?T=".":T=" ",f.append(T)}f.append(`
`)}return f.toString()}}class ce extends ve{constructor(l){super(l.getWidth(),l.getHeight()),this.delegate=l}getRow(l,f){const x=this.delegate.getRow(l,f),b=this.getWidth();for(let v=0;v<b;v++)x[v]=255-(x[v]&255);return x}getMatrix(){const l=this.delegate.getMatrix(),f=this.getWidth()*this.getHeight(),x=new Uint8ClampedArray(f);for(let b=0;b<f;b++)x[b]=255-(l[b]&255);return x}isCropSupported(){return this.delegate.isCropSupported()}crop(l,f,x,b){return new ce(this.delegate.crop(l,f,x,b))}isRotateSupported(){return this.delegate.isRotateSupported()}invert(){return this.delegate}rotateCounterClockwise(){return new ce(this.delegate.rotateCounterClockwise())}rotateCounterClockwise45(){return new ce(this.delegate.rotateCounterClockwise45())}}class ye extends ve{constructor(l){super(l.width,l.height),this.canvas=l,this.tempCanvasElement=null,this.buffer=ye.makeBufferFromCanvasImageData(l)}static makeBufferFromCanvasImageData(l){const f=l.getContext("2d").getImageData(0,0,l.width,l.height);return ye.toGrayscaleBuffer(f.data,l.width,l.height)}static toGrayscaleBuffer(l,f,x){const b=new Uint8ClampedArray(f*x);for(let v=0,j=0,T=l.length;v<T;v+=4,j++){let P;if(l[v+3]===0)P=255;else{const de=l[v],je=l[v+1],Ae=l[v+2];P=306*de+601*je+117*Ae+512>>10}b[j]=P}return b}getRow(l,f){if(l<0||l>=this.getHeight())throw new w("Requested row is outside the image: "+l);const x=this.getWidth(),b=l*x;return f===null?f=this.buffer.slice(b,b+x):(f.length<x&&(f=new Uint8ClampedArray(x)),f.set(this.buffer.slice(b,b+x))),f}getMatrix(){return this.buffer}isCropSupported(){return!0}crop(l,f,x,b){return super.crop(l,f,x,b),this}isRotateSupported(){return!0}rotateCounterClockwise(){return this.rotate(-90),this}rotateCounterClockwise45(){return this.rotate(-45),this}getTempCanvasElement(){if(this.tempCanvasElement===null){const l=this.canvas.ownerDocument.createElement("canvas");l.width=this.canvas.width,l.height=this.canvas.height,this.tempCanvasElement=l}return this.tempCanvasElement}rotate(l){const f=this.getTempCanvasElement(),x=f.getContext("2d"),b=l*ye.DEGREE_TO_RADIANS,v=this.canvas.width,j=this.canvas.height,T=Math.ceil(Math.abs(Math.cos(b))*v+Math.abs(Math.sin(b))*j),P=Math.ceil(Math.abs(Math.sin(b))*v+Math.abs(Math.cos(b))*j);return f.width=T,f.height=P,x.translate(T/2,P/2),x.rotate(b),x.drawImage(this.canvas,v/-2,j/-2),this.buffer=ye.makeBufferFromCanvasImageData(f),this}invert(){return new ce(this)}}ye.DEGREE_TO_RADIANS=Math.PI/180;class te{constructor(l,f,x){this.deviceId=l,this.label=f,this.kind="videoinput",this.groupId=x||void 0}toJSON(){return{kind:this.kind,groupId:this.groupId,deviceId:this.deviceId,label:this.label}}}var q=(globalThis||am||self||window||void 0)&&(globalThis||am||self||window||void 0).__awaiter||function(Ne,l,f,x){function b(v){return v instanceof f?v:new f(function(j){j(v)})}return new(f||(f=Promise))(function(v,j){function T(de){try{H(x.next(de))}catch(je){j(je)}}function P(de){try{H(x.throw(de))}catch(je){j(je)}}function H(de){de.done?v(de.value):b(de.value).then(T,P)}H((x=x.apply(Ne,l||[])).next())})};class J{constructor(l,f=500,x){this.reader=l,this.timeBetweenScansMillis=f,this._hints=x,this._stopContinuousDecode=!1,this._stopAsyncDecode=!1,this._timeBetweenDecodingAttempts=0}get hasNavigator(){return typeof navigator!="undefined"}get isMediaDevicesSuported(){return this.hasNavigator&&!!navigator.mediaDevices}get canEnumerateDevices(){return!!(this.isMediaDevicesSuported&&navigator.mediaDevices.enumerateDevices)}get timeBetweenDecodingAttempts(){return this._timeBetweenDecodingAttempts}set timeBetweenDecodingAttempts(l){this._timeBetweenDecodingAttempts=l<0?0:l}set hints(l){this._hints=l||null}get hints(){return this._hints}listVideoInputDevices(){return q(this,void 0,void 0,function*(){if(!this.hasNavigator)throw new Error("Can't enumerate devices, navigator is not present.");if(!this.canEnumerateDevices)throw new Error("Can't enumerate devices, method not supported.");const l=yield navigator.mediaDevices.enumerateDevices(),f=[];for(const x of l){const b=x.kind==="video"?"videoinput":x.kind;if(b!=="videoinput")continue;const v=x.deviceId||x.id,j=x.label||`Video device ${f.length+1}`,T=x.groupId,P={deviceId:v,label:j,kind:b,groupId:T};f.push(P)}return f})}getVideoInputDevices(){return q(this,void 0,void 0,function*(){return(yield this.listVideoInputDevices()).map(f=>new te(f.deviceId,f.label))})}findDeviceById(l){return q(this,void 0,void 0,function*(){const f=yield this.listVideoInputDevices();return f?f.find(x=>x.deviceId===l):null})}decodeFromInputVideoDevice(l,f){return q(this,void 0,void 0,function*(){return yield this.decodeOnceFromVideoDevice(l,f)})}decodeOnceFromVideoDevice(l,f){return q(this,void 0,void 0,function*(){this.reset();let x;l?x={deviceId:{exact:l}}:x={facingMode:"environment"};const b={video:x};return yield this.decodeOnceFromConstraints(b,f)})}decodeOnceFromConstraints(l,f){return q(this,void 0,void 0,function*(){const x=yield navigator.mediaDevices.getUserMedia(l);return yield this.decodeOnceFromStream(x,f)})}decodeOnceFromStream(l,f){return q(this,void 0,void 0,function*(){this.reset();const x=yield this.attachStreamToVideo(l,f);return yield this.decodeOnce(x)})}decodeFromInputVideoDeviceContinuously(l,f,x){return q(this,void 0,void 0,function*(){return yield this.decodeFromVideoDevice(l,f,x)})}decodeFromVideoDevice(l,f,x){return q(this,void 0,void 0,function*(){let b;l?b={deviceId:{exact:l}}:b={facingMode:"environment"};const v={video:b};return yield this.decodeFromConstraints(v,f,x)})}decodeFromConstraints(l,f,x){return q(this,void 0,void 0,function*(){const b=yield navigator.mediaDevices.getUserMedia(l);return yield this.decodeFromStream(b,f,x)})}decodeFromStream(l,f,x){return q(this,void 0,void 0,function*(){this.reset();const b=yield this.attachStreamToVideo(l,f);return yield this.decodeContinuously(b,x)})}stopAsyncDecode(){this._stopAsyncDecode=!0}stopContinuousDecode(){this._stopContinuousDecode=!0}attachStreamToVideo(l,f){return q(this,void 0,void 0,function*(){const x=this.prepareVideoElement(f);return this.addVideoSource(x,l),this.videoElement=x,this.stream=l,yield this.playVideoOnLoadAsync(x),x})}playVideoOnLoadAsync(l){return new Promise((f,x)=>this.playVideoOnLoad(l,()=>f()))}playVideoOnLoad(l,f){this.videoEndedListener=()=>this.stopStreams(),this.videoCanPlayListener=()=>this.tryPlayVideo(l),l.addEventListener("ended",this.videoEndedListener),l.addEventListener("canplay",this.videoCanPlayListener),l.addEventListener("playing",f),this.tryPlayVideo(l)}isVideoPlaying(l){return l.currentTime>0&&!l.paused&&!l.ended&&l.readyState>2}tryPlayVideo(l){return q(this,void 0,void 0,function*(){if(this.isVideoPlaying(l)){console.warn("Trying to play video that is already playing.");return}try{yield l.play()}catch(f){console.warn("It was not possible to play the video.")}})}getMediaElement(l,f){const x=document.getElementById(l);if(!x)throw new y(`element with id '${l}' not found`);if(x.nodeName.toLowerCase()!==f.toLowerCase())throw new y(`element with id '${l}' must be an ${f} element`);return x}decodeFromImage(l,f){if(!l&&!f)throw new y("either imageElement with a src set or an url must be provided");return f&&!l?this.decodeFromImageUrl(f):this.decodeFromImageElement(l)}decodeFromVideo(l,f){if(!l&&!f)throw new y("Either an element with a src set or an URL must be provided");return f&&!l?this.decodeFromVideoUrl(f):this.decodeFromVideoElement(l)}decodeFromVideoContinuously(l,f,x){if(l===void 0&&f===void 0)throw new y("Either an element with a src set or an URL must be provided");return f&&!l?this.decodeFromVideoUrlContinuously(f,x):this.decodeFromVideoElementContinuously(l,x)}decodeFromImageElement(l){if(!l)throw new y("An image element must be provided.");this.reset();const f=this.prepareImageElement(l);this.imageElement=f;let x;return this.isImageLoaded(f)?x=this.decodeOnce(f,!1,!0):x=this._decodeOnLoadImage(f),x}decodeFromVideoElement(l){const f=this._decodeFromVideoElementSetup(l);return this._decodeOnLoadVideo(f)}decodeFromVideoElementContinuously(l,f){const x=this._decodeFromVideoElementSetup(l);return this._decodeOnLoadVideoContinuously(x,f)}_decodeFromVideoElementSetup(l){if(!l)throw new y("A video element must be provided.");this.reset();const f=this.prepareVideoElement(l);return this.videoElement=f,f}decodeFromImageUrl(l){if(!l)throw new y("An URL must be provided.");this.reset();const f=this.prepareImageElement();this.imageElement=f;const x=this._decodeOnLoadImage(f);return f.src=l,x}decodeFromVideoUrl(l){if(!l)throw new y("An URL must be provided.");this.reset();const f=this.prepareVideoElement(),x=this.decodeFromVideoElement(f);return f.src=l,x}decodeFromVideoUrlContinuously(l,f){if(!l)throw new y("An URL must be provided.");this.reset();const x=this.prepareVideoElement(),b=this.decodeFromVideoElementContinuously(x,f);return x.src=l,b}_decodeOnLoadImage(l){return new Promise((f,x)=>{this.imageLoadedListener=()=>this.decodeOnce(l,!1,!0).then(f,x),l.addEventListener("load",this.imageLoadedListener)})}_decodeOnLoadVideo(l){return q(this,void 0,void 0,function*(){return yield this.playVideoOnLoadAsync(l),yield this.decodeOnce(l)})}_decodeOnLoadVideoContinuously(l,f){return q(this,void 0,void 0,function*(){yield this.playVideoOnLoadAsync(l),this.decodeContinuously(l,f)})}isImageLoaded(l){return!(!l.complete||l.naturalWidth===0)}prepareImageElement(l){let f;return typeof l=="undefined"&&(f=document.createElement("img"),f.width=200,f.height=200),typeof l=="string"&&(f=this.getMediaElement(l,"img")),l instanceof HTMLImageElement&&(f=l),f}prepareVideoElement(l){let f;return!l&&typeof document!="undefined"&&(f=document.createElement("video"),f.width=200,f.height=200),typeof l=="string"&&(f=this.getMediaElement(l,"video")),l instanceof HTMLVideoElement&&(f=l),f.setAttribute("autoplay","true"),f.setAttribute("muted","true"),f.setAttribute("playsinline","true"),f}decodeOnce(l,f=!0,x=!0){this._stopAsyncDecode=!1;const b=(v,j)=>{if(this._stopAsyncDecode){j(new re("Video stream has ended before any code could be detected.")),this._stopAsyncDecode=void 0;return}try{const T=this.decode(l);v(T)}catch(T){const P=f&&T instanceof re,de=(T instanceof S||T instanceof B)&&x;if(P||de)return setTimeout(b,this._timeBetweenDecodingAttempts,v,j);j(T)}};return new Promise((v,j)=>b(v,j))}decodeContinuously(l,f){this._stopContinuousDecode=!1;const x=()=>{if(this._stopContinuousDecode){this._stopContinuousDecode=void 0;return}try{const b=this.decode(l);f(b,null),setTimeout(x,this.timeBetweenScansMillis)}catch(b){f(null,b);const v=b instanceof S||b instanceof B,j=b instanceof re;(v||j)&&setTimeout(x,this._timeBetweenDecodingAttempts)}};x()}decode(l){const f=this.createBinaryBitmap(l);return this.decodeBitmap(f)}_isHTMLVideoElement(l){return l.videoWidth!==0}drawFrameOnCanvas(l,f,x){f||(f={sx:0,sy:0,sWidth:l.videoWidth,sHeight:l.videoHeight,dx:0,dy:0,dWidth:l.videoWidth,dHeight:l.videoHeight}),x||(x=this.captureCanvasContext),x.drawImage(l,f.sx,f.sy,f.sWidth,f.sHeight,f.dx,f.dy,f.dWidth,f.dHeight)}drawImageOnCanvas(l,f,x=this.captureCanvasContext){f||(f={sx:0,sy:0,sWidth:l.naturalWidth,sHeight:l.naturalHeight,dx:0,dy:0,dWidth:l.naturalWidth,dHeight:l.naturalHeight}),x||(x=this.captureCanvasContext),x.drawImage(l,f.sx,f.sy,f.sWidth,f.sHeight,f.dx,f.dy,f.dWidth,f.dHeight)}createBinaryBitmap(l){this.getCaptureCanvasContext(l),this._isHTMLVideoElement(l)?this.drawFrameOnCanvas(l):this.drawImageOnCanvas(l);const f=this.getCaptureCanvas(l),x=new ye(f),b=new ee(x);return new E(b)}getCaptureCanvasContext(l){if(!this.captureCanvasContext){const x=this.getCaptureCanvas(l).getContext("2d");this.captureCanvasContext=x}return this.captureCanvasContext}getCaptureCanvas(l){if(!this.captureCanvas){const f=this.createCaptureCanvas(l);this.captureCanvas=f}return this.captureCanvas}decodeBitmap(l){return this.reader.decode(l,this._hints)}createCaptureCanvas(l){if(typeof document=="undefined")return this._destroyCaptureCanvas(),null;const f=document.createElement("canvas");let x,b;return typeof l!="undefined"&&(l instanceof HTMLVideoElement?(x=l.videoWidth,b=l.videoHeight):l instanceof HTMLImageElement&&(x=l.naturalWidth||l.width,b=l.naturalHeight||l.height)),f.style.width=x+"px",f.style.height=b+"px",f.width=x,f.height=b,f}stopStreams(){this.stream&&(this.stream.getVideoTracks().forEach(l=>l.stop()),this.stream=void 0),this._stopAsyncDecode===!1&&this.stopAsyncDecode(),this._stopContinuousDecode===!1&&this.stopContinuousDecode()}reset(){this.stopStreams(),this._destroyVideoElement(),this._destroyImageElement(),this._destroyCaptureCanvas()}_destroyVideoElement(){this.videoElement&&(typeof this.videoEndedListener!="undefined"&&this.videoElement.removeEventListener("ended",this.videoEndedListener),typeof this.videoPlayingEventListener!="undefined"&&this.videoElement.removeEventListener("playing",this.videoPlayingEventListener),typeof this.videoCanPlayListener!="undefined"&&this.videoElement.removeEventListener("loadedmetadata",this.videoCanPlayListener),this.cleanVideoSource(this.videoElement),this.videoElement=void 0)}_destroyImageElement(){this.imageElement&&(this.imageLoadedListener!==void 0&&this.imageElement.removeEventListener("load",this.imageLoadedListener),this.imageElement.src=void 0,this.imageElement.removeAttribute("src"),this.imageElement=void 0)}_destroyCaptureCanvas(){this.captureCanvasContext=void 0,this.captureCanvas=void 0}addVideoSource(l,f){try{l.srcObject=f}catch(x){l.src=URL.createObjectURL(f)}}cleanVideoSource(l){try{l.srcObject=null}catch(f){l.src=""}this.videoElement.removeAttribute("src")}}class ae{constructor(l,f,x=f==null?0:8*f.length,b,v,j=C.currentTimeMillis()){this.text=l,this.rawBytes=f,this.numBits=x,this.resultPoints=b,this.format=v,this.timestamp=j,this.text=l,this.rawBytes=f,x==null?this.numBits=f==null?0:8*f.length:this.numBits=x,this.resultPoints=b,this.format=v,this.resultMetadata=null,j==null?this.timestamp=C.currentTimeMillis():this.timestamp=j}getText(){return this.text}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}getResultPoints(){return this.resultPoints}getBarcodeFormat(){return this.format}getResultMetadata(){return this.resultMetadata}putMetadata(l,f){this.resultMetadata===null&&(this.resultMetadata=new Map),this.resultMetadata.set(l,f)}putAllMetadata(l){l!==null&&(this.resultMetadata===null?this.resultMetadata=l:this.resultMetadata=new Map(l))}addResultPoints(l){const f=this.resultPoints;if(f===null)this.resultPoints=l;else if(l!==null&&l.length>0){const x=new Array(f.length+l.length);C.arraycopy(f,0,x,0,f.length),C.arraycopy(l,0,x,f.length,l.length),this.resultPoints=x}}getTimestamp(){return this.timestamp}toString(){return this.text}}var oe;(function(Ne){Ne[Ne.AZTEC=0]="AZTEC",Ne[Ne.CODABAR=1]="CODABAR",Ne[Ne.CODE_39=2]="CODE_39",Ne[Ne.CODE_93=3]="CODE_93",Ne[Ne.CODE_128=4]="CODE_128",Ne[Ne.DATA_MATRIX=5]="DATA_MATRIX",Ne[Ne.EAN_8=6]="EAN_8",Ne[Ne.EAN_13=7]="EAN_13",Ne[Ne.ITF=8]="ITF",Ne[Ne.MAXICODE=9]="MAXICODE",Ne[Ne.PDF_417=10]="PDF_417",Ne[Ne.QR_CODE=11]="QR_CODE",Ne[Ne.RSS_14=12]="RSS_14",Ne[Ne.RSS_EXPANDED=13]="RSS_EXPANDED",Ne[Ne.UPC_A=14]="UPC_A",Ne[Ne.UPC_E=15]="UPC_E",Ne[Ne.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(oe||(oe={}));var le=oe,be;(function(Ne){Ne[Ne.OTHER=0]="OTHER",Ne[Ne.ORIENTATION=1]="ORIENTATION",Ne[Ne.BYTE_SEGMENTS=2]="BYTE_SEGMENTS",Ne[Ne.ERROR_CORRECTION_LEVEL=3]="ERROR_CORRECTION_LEVEL",Ne[Ne.ISSUE_NUMBER=4]="ISSUE_NUMBER",Ne[Ne.SUGGESTED_PRICE=5]="SUGGESTED_PRICE",Ne[Ne.POSSIBLE_COUNTRY=6]="POSSIBLE_COUNTRY",Ne[Ne.UPC_EAN_EXTENSION=7]="UPC_EAN_EXTENSION",Ne[Ne.PDF417_EXTRA_METADATA=8]="PDF417_EXTRA_METADATA",Ne[Ne.STRUCTURED_APPEND_SEQUENCE=9]="STRUCTURED_APPEND_SEQUENCE",Ne[Ne.STRUCTURED_APPEND_PARITY=10]="STRUCTURED_APPEND_PARITY"})(be||(be={}));var Z=be;class Le{constructor(l,f,x,b,v=-1,j=-1){this.rawBytes=l,this.text=f,this.byteSegments=x,this.ecLevel=b,this.structuredAppendSequenceNumber=v,this.structuredAppendParity=j,this.numBits=l==null?0:8*l.length}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}setNumBits(l){this.numBits=l}getText(){return this.text}getByteSegments(){return this.byteSegments}getECLevel(){return this.ecLevel}getErrorsCorrected(){return this.errorsCorrected}setErrorsCorrected(l){this.errorsCorrected=l}getErasures(){return this.erasures}setErasures(l){this.erasures=l}getOther(){return this.other}setOther(l){this.other=l}hasStructuredAppend(){return this.structuredAppendParity>=0&&this.structuredAppendSequenceNumber>=0}getStructuredAppendParity(){return this.structuredAppendParity}getStructuredAppendSequenceNumber(){return this.structuredAppendSequenceNumber}}class Pe{exp(l){return this.expTable[l]}log(l){if(l===0)throw new w;return this.logTable[l]}static addOrSubtract(l,f){return l^f}}class Be{constructor(l,f){if(f.length===0)throw new w;this.field=l;const x=f.length;if(x>1&&f[0]===0){let b=1;for(;b<x&&f[b]===0;)b++;b===x?this.coefficients=Int32Array.from([0]):(this.coefficients=new Int32Array(x-b),C.arraycopy(f,b,this.coefficients,0,this.coefficients.length))}else this.coefficients=f}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return this.coefficients[0]===0}getCoefficient(l){return this.coefficients[this.coefficients.length-1-l]}evaluateAt(l){if(l===0)return this.getCoefficient(0);const f=this.coefficients;let x;if(l===1){x=0;for(let j=0,T=f.length;j!==T;j++){const P=f[j];x=Pe.addOrSubtract(x,P)}return x}x=f[0];const b=f.length,v=this.field;for(let j=1;j<b;j++)x=Pe.addOrSubtract(v.multiply(l,x),f[j]);return x}addOrSubtract(l){if(!this.field.equals(l.field))throw new w("GenericGFPolys do not have same GenericGF field");if(this.isZero())return l;if(l.isZero())return this;let f=this.coefficients,x=l.coefficients;if(f.length>x.length){const j=f;f=x,x=j}let b=new Int32Array(x.length);const v=x.length-f.length;C.arraycopy(x,0,b,0,v);for(let j=v;j<x.length;j++)b[j]=Pe.addOrSubtract(f[j-v],x[j]);return new Be(this.field,b)}multiply(l){if(!this.field.equals(l.field))throw new w("GenericGFPolys do not have same GenericGF field");if(this.isZero()||l.isZero())return this.field.getZero();const f=this.coefficients,x=f.length,b=l.coefficients,v=b.length,j=new Int32Array(x+v-1),T=this.field;for(let P=0;P<x;P++){const H=f[P];for(let de=0;de<v;de++)j[P+de]=Pe.addOrSubtract(j[P+de],T.multiply(H,b[de]))}return new Be(T,j)}multiplyScalar(l){if(l===0)return this.field.getZero();if(l===1)return this;const f=this.coefficients.length,x=this.field,b=new Int32Array(f),v=this.coefficients;for(let j=0;j<f;j++)b[j]=x.multiply(v[j],l);return new Be(x,b)}multiplyByMonomial(l,f){if(l<0)throw new w;if(f===0)return this.field.getZero();const x=this.coefficients,b=x.length,v=new Int32Array(b+l),j=this.field;for(let T=0;T<b;T++)v[T]=j.multiply(x[T],f);return new Be(j,v)}divide(l){if(!this.field.equals(l.field))throw new w("GenericGFPolys do not have same GenericGF field");if(l.isZero())throw new w("Divide by 0");const f=this.field;let x=f.getZero(),b=this;const v=l.getCoefficient(l.getDegree()),j=f.inverse(v);for(;b.getDegree()>=l.getDegree()&&!b.isZero();){const T=b.getDegree()-l.getDegree(),P=f.multiply(b.getCoefficient(b.getDegree()),j),H=l.multiplyByMonomial(T,P),de=f.buildMonomial(T,P);x=x.addOrSubtract(de),b=b.addOrSubtract(H)}return[x,b]}toString(){let l="";for(let f=this.getDegree();f>=0;f--){let x=this.getCoefficient(f);if(x!==0){if(x<0?(l+=" - ",x=-x):l.length>0&&(l+=" + "),f===0||x!==1){const b=this.field.log(x);b===0?l+="1":b===1?l+="a":(l+="a^",l+=b)}f!==0&&(f===1?l+="x":(l+="x^",l+=f))}}return l}}class pe extends g{}pe.kind="ArithmeticException";class rt extends Pe{constructor(l,f,x){super(),this.primitive=l,this.size=f,this.generatorBase=x;const b=new Int32Array(f);let v=1;for(let T=0;T<f;T++)b[T]=v,v*=2,v>=f&&(v^=l,v&=f-1);this.expTable=b;const j=new Int32Array(f);for(let T=0;T<f-1;T++)j[b[T]]=T;this.logTable=j,this.zero=new Be(this,Int32Array.from([0])),this.one=new Be(this,Int32Array.from([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(l,f){if(l<0)throw new w;if(f===0)return this.zero;const x=new Int32Array(l+1);return x[0]=f,new Be(this,x)}inverse(l){if(l===0)throw new pe;return this.expTable[this.size-this.logTable[l]-1]}multiply(l,f){return l===0||f===0?0:this.expTable[(this.logTable[l]+this.logTable[f])%(this.size-1)]}getSize(){return this.size}getGeneratorBase(){return this.generatorBase}toString(){return"GF(0x"+F.toHexString(this.primitive)+","+this.size+")"}equals(l){return l===this}}rt.AZTEC_DATA_12=new rt(4201,4096,1),rt.AZTEC_DATA_10=new rt(1033,1024,1),rt.AZTEC_DATA_6=new rt(67,64,1),rt.AZTEC_PARAM=new rt(19,16,1),rt.QR_CODE_FIELD_256=new rt(285,256,0),rt.DATA_MATRIX_FIELD_256=new rt(301,256,1),rt.AZTEC_DATA_8=rt.DATA_MATRIX_FIELD_256,rt.MAXICODE_FIELD_64=rt.AZTEC_DATA_6;class ct extends g{}ct.kind="ReedSolomonException";class et extends g{}et.kind="IllegalStateException";class It{constructor(l){this.field=l}decode(l,f){const x=this.field,b=new Be(x,l),v=new Int32Array(f);let j=!0;for(let Ge=0;Ge<f;Ge++){const ot=b.evaluateAt(x.exp(Ge+x.getGeneratorBase()));v[v.length-1-Ge]=ot,ot!==0&&(j=!1)}if(j)return;const T=new Be(x,v),P=this.runEuclideanAlgorithm(x.buildMonomial(f,1),T,f),H=P[0],de=P[1],je=this.findErrorLocations(H),Ae=this.findErrorMagnitudes(de,je);for(let Ge=0;Ge<je.length;Ge++){const ot=l.length-1-x.log(je[Ge]);if(ot<0)throw new ct("Bad error location");l[ot]=rt.addOrSubtract(l[ot],Ae[Ge])}}runEuclideanAlgorithm(l,f,x){if(l.getDegree()<f.getDegree()){const Ge=l;l=f,f=Ge}const b=this.field;let v=l,j=f,T=b.getZero(),P=b.getOne();for(;j.getDegree()>=(x/2|0);){let Ge=v,ot=T;if(v=j,T=P,v.isZero())throw new ct("r_{i-1} was zero");j=Ge;let ut=b.getZero();const At=v.getCoefficient(v.getDegree()),se=b.inverse(At);for(;j.getDegree()>=v.getDegree()&&!j.isZero();){const Ee=j.getDegree()-v.getDegree(),Ue=b.multiply(j.getCoefficient(j.getDegree()),se);ut=ut.addOrSubtract(b.buildMonomial(Ee,Ue)),j=j.addOrSubtract(v.multiplyByMonomial(Ee,Ue))}if(P=ut.multiply(T).addOrSubtract(ot),j.getDegree()>=v.getDegree())throw new et("Division algorithm failed to reduce polynomial?")}const H=P.getCoefficient(0);if(H===0)throw new ct("sigmaTilde(0) was zero");const de=b.inverse(H),je=P.multiplyScalar(de),Ae=j.multiplyScalar(de);return[je,Ae]}findErrorLocations(l){const f=l.getDegree();if(f===1)return Int32Array.from([l.getCoefficient(1)]);const x=new Int32Array(f);let b=0;const v=this.field;for(let j=1;j<v.getSize()&&b<f;j++)l.evaluateAt(j)===0&&(x[b]=v.inverse(j),b++);if(b!==f)throw new ct("Error locator degree does not match number of roots");return x}findErrorMagnitudes(l,f){const x=f.length,b=new Int32Array(x),v=this.field;for(let j=0;j<x;j++){const T=v.inverse(f[j]);let P=1;for(let H=0;H<x;H++)if(j!==H){const de=v.multiply(f[H],T),je=(de&1)===0?de|1:de&-2;P=v.multiply(P,je)}b[j]=v.multiply(l.evaluateAt(T),v.inverse(P)),v.getGeneratorBase()!==0&&(b[j]=v.multiply(b[j],T))}return b}}var ft;(function(Ne){Ne[Ne.UPPER=0]="UPPER",Ne[Ne.LOWER=1]="LOWER",Ne[Ne.MIXED=2]="MIXED",Ne[Ne.DIGIT=3]="DIGIT",Ne[Ne.PUNCT=4]="PUNCT",Ne[Ne.BINARY=5]="BINARY"})(ft||(ft={}));class Lt{decode(l){this.ddata=l;let f=l.getBits(),x=this.extractBits(f),b=this.correctBits(x),v=Lt.convertBoolArrayToByteArray(b),j=Lt.getEncodedData(b),T=new Le(v,j,null,null);return T.setNumBits(b.length),T}static highLevelDecode(l){return this.getEncodedData(l)}static getEncodedData(l){let f=l.length,x=ft.UPPER,b=ft.UPPER,v="",j=0;for(;j<f;)if(b===ft.BINARY){if(f-j<5)break;let T=Lt.readCode(l,j,5);if(j+=5,T===0){if(f-j<11)break;T=Lt.readCode(l,j,11)+31,j+=11}for(let P=0;P<T;P++){if(f-j<8){j=f;break}const H=Lt.readCode(l,j,8);v+=K.castAsNonUtf8Char(H),j+=8}b=x}else{let T=b===ft.DIGIT?4:5;if(f-j<T)break;let P=Lt.readCode(l,j,T);j+=T;let H=Lt.getCharacter(b,P);H.startsWith("CTRL_")?(x=b,b=Lt.getTable(H.charAt(5)),H.charAt(6)==="L"&&(x=b)):(v+=H,b=x)}return v}static getTable(l){switch(l){case"L":return ft.LOWER;case"P":return ft.PUNCT;case"M":return ft.MIXED;case"D":return ft.DIGIT;case"B":return ft.BINARY;case"U":default:return ft.UPPER}}static getCharacter(l,f){switch(l){case ft.UPPER:return Lt.UPPER_TABLE[f];case ft.LOWER:return Lt.LOWER_TABLE[f];case ft.MIXED:return Lt.MIXED_TABLE[f];case ft.PUNCT:return Lt.PUNCT_TABLE[f];case ft.DIGIT:return Lt.DIGIT_TABLE[f];default:throw new et("Bad table")}}correctBits(l){let f,x;this.ddata.getNbLayers()<=2?(x=6,f=rt.AZTEC_DATA_6):this.ddata.getNbLayers()<=8?(x=8,f=rt.AZTEC_DATA_8):this.ddata.getNbLayers()<=22?(x=10,f=rt.AZTEC_DATA_10):(x=12,f=rt.AZTEC_DATA_12);let b=this.ddata.getNbDatablocks(),v=l.length/x;if(v<b)throw new B;let j=l.length%x,T=new Int32Array(v);for(let Ae=0;Ae<v;Ae++,j+=x)T[Ae]=Lt.readCode(l,j,x);try{new It(f).decode(T,v-b)}catch(Ae){throw new B(Ae)}let P=(1<<x)-1,H=0;for(let Ae=0;Ae<b;Ae++){let Ge=T[Ae];if(Ge===0||Ge===P)throw new B;(Ge===1||Ge===P-1)&&H++}let de=new Array(b*x-H),je=0;for(let Ae=0;Ae<b;Ae++){let Ge=T[Ae];if(Ge===1||Ge===P-1)de.fill(Ge>1,je,je+x-1),je+=x-1;else for(let ot=x-1;ot>=0;--ot)de[je++]=(Ge&1<<ot)!==0}return de}extractBits(l){let f=this.ddata.isCompact(),x=this.ddata.getNbLayers(),b=(f?11:14)+x*4,v=new Int32Array(b),j=new Array(this.totalBitsInLayer(x,f));if(f)for(let T=0;T<v.length;T++)v[T]=T;else{let T=b+1+2*F.truncDivision(F.truncDivision(b,2)-1,15),P=b/2,H=F.truncDivision(T,2);for(let de=0;de<P;de++){let je=de+F.truncDivision(de,15);v[P-de-1]=H-je-1,v[P+de]=H+je+1}}for(let T=0,P=0;T<x;T++){let H=(x-T)*4+(f?9:12),de=T*2,je=b-1-de;for(let Ae=0;Ae<H;Ae++){let Ge=Ae*2;for(let ot=0;ot<2;ot++)j[P+Ge+ot]=l.get(v[de+ot],v[de+Ae]),j[P+2*H+Ge+ot]=l.get(v[de+Ae],v[je-ot]),j[P+4*H+Ge+ot]=l.get(v[je-ot],v[je-Ae]),j[P+6*H+Ge+ot]=l.get(v[je-Ae],v[de+ot])}P+=H*8}return j}static readCode(l,f,x){let b=0;for(let v=f;v<f+x;v++)b<<=1,l[v]&&(b|=1);return b}static readByte(l,f){let x=l.length-f;return x>=8?Lt.readCode(l,f,8):Lt.readCode(l,f,x)<<8-x}static convertBoolArrayToByteArray(l){let f=new Uint8Array((l.length+7)/8);for(let x=0;x<f.length;x++)f[x]=Lt.readByte(l,8*x);return f}totalBitsInLayer(l,f){return((f?88:112)+16*l)*l}}Lt.UPPER_TABLE=["CTRL_PS"," ","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","CTRL_LL","CTRL_ML","CTRL_DL","CTRL_BS"],Lt.LOWER_TABLE=["CTRL_PS"," ","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","CTRL_US","CTRL_ML","CTRL_DL","CTRL_BS"],Lt.MIXED_TABLE=["CTRL_PS"," ","\\1","\\2","\\3","\\4","\\5","\\6","\\7","\b"," ",`
`,"\\13","\f","\r","\\33","\\34","\\35","\\36","\\37","@","\\","^","_","`","|","~","\\177","CTRL_LL","CTRL_UL","CTRL_PL","CTRL_BS"],Lt.PUNCT_TABLE=["","\r",`\r
`,". ",", ",": ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}","CTRL_UL"],Lt.DIGIT_TABLE=["CTRL_PS"," ","0","1","2","3","4","5","6","7","8","9",",",".","CTRL_UL","CTRL_US"];class Je{constructor(){}static round(l){return l===NaN?0:l<=Number.MIN_SAFE_INTEGER?Number.MIN_SAFE_INTEGER:l>=Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:l+(l<0?-.5:.5)|0}static distance(l,f,x,b){const v=l-x,j=f-b;return Math.sqrt(v*v+j*j)}static sum(l){let f=0;for(let x=0,b=l.length;x!==b;x++){const v=l[x];f+=v}return f}}class Ve{static floatToIntBits(l){return l}}Ve.MAX_VALUE=Number.MAX_SAFE_INTEGER;class Xe{constructor(l,f){this.x=l,this.y=f}getX(){return this.x}getY(){return this.y}equals(l){if(l instanceof Xe){const f=l;return this.x===f.x&&this.y===f.y}return!1}hashCode(){return 31*Ve.floatToIntBits(this.x)+Ve.floatToIntBits(this.y)}toString(){return"("+this.x+","+this.y+")"}static orderBestPatterns(l){const f=this.distance(l[0],l[1]),x=this.distance(l[1],l[2]),b=this.distance(l[0],l[2]);let v,j,T;if(x>=f&&x>=b?(j=l[0],v=l[1],T=l[2]):b>=x&&b>=f?(j=l[1],v=l[0],T=l[2]):(j=l[2],v=l[0],T=l[1]),this.crossProductZ(v,j,T)<0){const P=v;v=T,T=P}l[0]=v,l[1]=j,l[2]=T}static distance(l,f){return Je.distance(l.x,l.y,f.x,f.y)}static crossProductZ(l,f,x){const b=f.x,v=f.y;return(x.x-b)*(l.y-v)-(x.y-v)*(l.x-b)}}class Rt{constructor(l,f){this.bits=l,this.points=f}getBits(){return this.bits}getPoints(){return this.points}}class qe extends Rt{constructor(l,f,x,b,v){super(l,f),this.compact=x,this.nbDatablocks=b,this.nbLayers=v}getNbLayers(){return this.nbLayers}getNbDatablocks(){return this.nbDatablocks}isCompact(){return this.compact}}class Dt{constructor(l,f,x,b){this.image=l,this.height=l.getHeight(),this.width=l.getWidth(),f==null&&(f=Dt.INIT_SIZE),x==null&&(x=l.getWidth()/2|0),b==null&&(b=l.getHeight()/2|0);const v=f/2|0;if(this.leftInit=x-v,this.rightInit=x+v,this.upInit=b-v,this.downInit=b+v,this.upInit<0||this.leftInit<0||this.downInit>=this.height||this.rightInit>=this.width)throw new re}detect(){let l=this.leftInit,f=this.rightInit,x=this.upInit,b=this.downInit,v=!1,j=!0,T=!1,P=!1,H=!1,de=!1,je=!1;const Ae=this.width,Ge=this.height;for(;j;){j=!1;let ot=!0;for(;(ot||!P)&&f<Ae;)ot=this.containsBlackPoint(x,b,f,!1),ot?(f++,j=!0,P=!0):P||f++;if(f>=Ae){v=!0;break}let ut=!0;for(;(ut||!H)&&b<Ge;)ut=this.containsBlackPoint(l,f,b,!0),ut?(b++,j=!0,H=!0):H||b++;if(b>=Ge){v=!0;break}let At=!0;for(;(At||!de)&&l>=0;)At=this.containsBlackPoint(x,b,l,!1),At?(l--,j=!0,de=!0):de||l--;if(l<0){v=!0;break}let se=!0;for(;(se||!je)&&x>=0;)se=this.containsBlackPoint(l,f,x,!0),se?(x--,j=!0,je=!0):je||x--;if(x<0){v=!0;break}j&&(T=!0)}if(!v&&T){const ot=f-l;let ut=null;for(let Ue=1;ut===null&&Ue<ot;Ue++)ut=this.getBlackPointOnSegment(l,b-Ue,l+Ue,b);if(ut==null)throw new re;let At=null;for(let Ue=1;At===null&&Ue<ot;Ue++)At=this.getBlackPointOnSegment(l,x+Ue,l+Ue,x);if(At==null)throw new re;let se=null;for(let Ue=1;se===null&&Ue<ot;Ue++)se=this.getBlackPointOnSegment(f,x+Ue,f-Ue,x);if(se==null)throw new re;let Ee=null;for(let Ue=1;Ee===null&&Ue<ot;Ue++)Ee=this.getBlackPointOnSegment(f,b-Ue,f-Ue,b);if(Ee==null)throw new re;return this.centerEdges(Ee,ut,se,At)}else throw new re}getBlackPointOnSegment(l,f,x,b){const v=Je.round(Je.distance(l,f,x,b)),j=(x-l)/v,T=(b-f)/v,P=this.image;for(let H=0;H<v;H++){const de=Je.round(l+H*j),je=Je.round(f+H*T);if(P.get(de,je))return new Xe(de,je)}return null}centerEdges(l,f,x,b){const v=l.getX(),j=l.getY(),T=f.getX(),P=f.getY(),H=x.getX(),de=x.getY(),je=b.getX(),Ae=b.getY(),Ge=Dt.CORR;return v<this.width/2?[new Xe(je-Ge,Ae+Ge),new Xe(T+Ge,P+Ge),new Xe(H-Ge,de-Ge),new Xe(v+Ge,j-Ge)]:[new Xe(je+Ge,Ae+Ge),new Xe(T+Ge,P-Ge),new Xe(H-Ge,de+Ge),new Xe(v-Ge,j-Ge)]}containsBlackPoint(l,f,x,b){const v=this.image;if(b){for(let j=l;j<=f;j++)if(v.get(j,x))return!0}else for(let j=l;j<=f;j++)if(v.get(x,j))return!0;return!1}}Dt.INIT_SIZE=10,Dt.CORR=1;class ar{static checkAndNudgePoints(l,f){const x=l.getWidth(),b=l.getHeight();let v=!0;for(let j=0;j<f.length&&v;j+=2){const T=Math.floor(f[j]),P=Math.floor(f[j+1]);if(T<-1||T>x||P<-1||P>b)throw new re;v=!1,T===-1?(f[j]=0,v=!0):T===x&&(f[j]=x-1,v=!0),P===-1?(f[j+1]=0,v=!0):P===b&&(f[j+1]=b-1,v=!0)}v=!0;for(let j=f.length-2;j>=0&&v;j-=2){const T=Math.floor(f[j]),P=Math.floor(f[j+1]);if(T<-1||T>x||P<-1||P>b)throw new re;v=!1,T===-1?(f[j]=0,v=!0):T===x&&(f[j]=x-1,v=!0),P===-1?(f[j+1]=0,v=!0):P===b&&(f[j+1]=b-1,v=!0)}}}class yt{constructor(l,f,x,b,v,j,T,P,H){this.a11=l,this.a21=f,this.a31=x,this.a12=b,this.a22=v,this.a32=j,this.a13=T,this.a23=P,this.a33=H}static quadrilateralToQuadrilateral(l,f,x,b,v,j,T,P,H,de,je,Ae,Ge,ot,ut,At){const se=yt.quadrilateralToSquare(l,f,x,b,v,j,T,P);return yt.squareToQuadrilateral(H,de,je,Ae,Ge,ot,ut,At).times(se)}transformPoints(l){const f=l.length,x=this.a11,b=this.a12,v=this.a13,j=this.a21,T=this.a22,P=this.a23,H=this.a31,de=this.a32,je=this.a33;for(let Ae=0;Ae<f;Ae+=2){const Ge=l[Ae],ot=l[Ae+1],ut=v*Ge+P*ot+je;l[Ae]=(x*Ge+j*ot+H)/ut,l[Ae+1]=(b*Ge+T*ot+de)/ut}}transformPointsWithValues(l,f){const x=this.a11,b=this.a12,v=this.a13,j=this.a21,T=this.a22,P=this.a23,H=this.a31,de=this.a32,je=this.a33,Ae=l.length;for(let Ge=0;Ge<Ae;Ge++){const ot=l[Ge],ut=f[Ge],At=v*ot+P*ut+je;l[Ge]=(x*ot+j*ut+H)/At,f[Ge]=(b*ot+T*ut+de)/At}}static squareToQuadrilateral(l,f,x,b,v,j,T,P){const H=l-x+v-T,de=f-b+j-P;if(H===0&&de===0)return new yt(x-l,v-x,l,b-f,j-b,f,0,0,1);{const je=x-v,Ae=T-v,Ge=b-j,ot=P-j,ut=je*ot-Ae*Ge,At=(H*ot-Ae*de)/ut,se=(je*de-H*Ge)/ut;return new yt(x-l+At*x,T-l+se*T,l,b-f+At*b,P-f+se*P,f,At,se,1)}}static quadrilateralToSquare(l,f,x,b,v,j,T,P){return yt.squareToQuadrilateral(l,f,x,b,v,j,T,P).buildAdjoint()}buildAdjoint(){return new yt(this.a22*this.a33-this.a23*this.a32,this.a23*this.a31-this.a21*this.a33,this.a21*this.a32-this.a22*this.a31,this.a13*this.a32-this.a12*this.a33,this.a11*this.a33-this.a13*this.a31,this.a12*this.a31-this.a11*this.a32,this.a12*this.a23-this.a13*this.a22,this.a13*this.a21-this.a11*this.a23,this.a11*this.a22-this.a12*this.a21)}times(l){return new yt(this.a11*l.a11+this.a21*l.a12+this.a31*l.a13,this.a11*l.a21+this.a21*l.a22+this.a31*l.a23,this.a11*l.a31+this.a21*l.a32+this.a31*l.a33,this.a12*l.a11+this.a22*l.a12+this.a32*l.a13,this.a12*l.a21+this.a22*l.a22+this.a32*l.a23,this.a12*l.a31+this.a22*l.a32+this.a32*l.a33,this.a13*l.a11+this.a23*l.a12+this.a33*l.a13,this.a13*l.a21+this.a23*l.a22+this.a33*l.a23,this.a13*l.a31+this.a23*l.a32+this.a33*l.a33)}}class St extends ar{sampleGrid(l,f,x,b,v,j,T,P,H,de,je,Ae,Ge,ot,ut,At,se,Ee,Ue){const ht=yt.quadrilateralToQuadrilateral(b,v,j,T,P,H,de,je,Ae,Ge,ot,ut,At,se,Ee,Ue);return this.sampleGridWithTransform(l,f,x,ht)}sampleGridWithTransform(l,f,x,b){if(f<=0||x<=0)throw new re;const v=new ge(f,x),j=new Float32Array(2*f);for(let T=0;T<x;T++){const P=j.length,H=T+.5;for(let de=0;de<P;de+=2)j[de]=de/2+.5,j[de+1]=H;b.transformPoints(j),ar.checkAndNudgePoints(l,j);try{for(let de=0;de<P;de+=2)l.get(Math.floor(j[de]),Math.floor(j[de+1]))&&v.set(de/2,T)}catch(de){throw new re}}return v}}class Ot{static setGridSampler(l){Ot.gridSampler=l}static getInstance(){return Ot.gridSampler}}Ot.gridSampler=new St;class Yt{constructor(l,f){this.x=l,this.y=f}toResultPoint(){return new Xe(this.getX(),this.getY())}getX(){return this.x}getY(){return this.y}}class Ye{constructor(l){this.EXPECTED_CORNER_BITS=new Int32Array([3808,476,2107,1799]),this.image=l}detect(){return this.detectMirror(!1)}detectMirror(l){let f=this.getMatrixCenter(),x=this.getBullsEyeCorners(f);if(l){let j=x[0];x[0]=x[2],x[2]=j}this.extractParameters(x);let b=this.sampleGrid(this.image,x[this.shift%4],x[(this.shift+1)%4],x[(this.shift+2)%4],x[(this.shift+3)%4]),v=this.getMatrixCornerPoints(x);return new qe(b,v,this.compact,this.nbDataBlocks,this.nbLayers)}extractParameters(l){if(!this.isValidPoint(l[0])||!this.isValidPoint(l[1])||!this.isValidPoint(l[2])||!this.isValidPoint(l[3]))throw new re;let f=2*this.nbCenterLayers,x=new Int32Array([this.sampleLine(l[0],l[1],f),this.sampleLine(l[1],l[2],f),this.sampleLine(l[2],l[3],f),this.sampleLine(l[3],l[0],f)]);this.shift=this.getRotation(x,f);let b=0;for(let j=0;j<4;j++){let T=x[(this.shift+j)%4];this.compact?(b<<=7,b+=T>>1&127):(b<<=10,b+=(T>>2&992)+(T>>1&31))}let v=this.getCorrectedParameterData(b,this.compact);this.compact?(this.nbLayers=(v>>6)+1,this.nbDataBlocks=(v&63)+1):(this.nbLayers=(v>>11)+1,this.nbDataBlocks=(v&2047)+1)}getRotation(l,f){let x=0;l.forEach((b,v,j)=>{let T=(b>>f-2<<1)+(b&1);x=(x<<3)+T}),x=((x&1)<<11)+(x>>1);for(let b=0;b<4;b++)if(F.bitCount(x^this.EXPECTED_CORNER_BITS[b])<=2)return b;throw new re}getCorrectedParameterData(l,f){let x,b;f?(x=7,b=2):(x=10,b=4);let v=x-b,j=new Int32Array(x);for(let P=x-1;P>=0;--P)j[P]=l&15,l>>=4;try{new It(rt.AZTEC_PARAM).decode(j,v)}catch(P){throw new re}let T=0;for(let P=0;P<b;P++)T=(T<<4)+j[P];return T}getBullsEyeCorners(l){let f=l,x=l,b=l,v=l,j=!0;for(this.nbCenterLayers=1;this.nbCenterLayers<9;this.nbCenterLayers++){let je=this.getFirstDifferent(f,j,1,-1),Ae=this.getFirstDifferent(x,j,1,1),Ge=this.getFirstDifferent(b,j,-1,1),ot=this.getFirstDifferent(v,j,-1,-1);if(this.nbCenterLayers>2){let ut=this.distancePoint(ot,je)*this.nbCenterLayers/(this.distancePoint(v,f)*(this.nbCenterLayers+2));if(ut<.75||ut>1.25||!this.isWhiteOrBlackRectangle(je,Ae,Ge,ot))break}f=je,x=Ae,b=Ge,v=ot,j=!j}if(this.nbCenterLayers!==5&&this.nbCenterLayers!==7)throw new re;this.compact=this.nbCenterLayers===5;let T=new Xe(f.getX()+.5,f.getY()-.5),P=new Xe(x.getX()+.5,x.getY()+.5),H=new Xe(b.getX()-.5,b.getY()+.5),de=new Xe(v.getX()-.5,v.getY()-.5);return this.expandSquare([T,P,H,de],2*this.nbCenterLayers-3,2*this.nbCenterLayers)}getMatrixCenter(){let l,f,x,b;try{let T=new Dt(this.image).detect();l=T[0],f=T[1],x=T[2],b=T[3]}catch(T){let P=this.image.getWidth()/2,H=this.image.getHeight()/2;l=this.getFirstDifferent(new Yt(P+7,H-7),!1,1,-1).toResultPoint(),f=this.getFirstDifferent(new Yt(P+7,H+7),!1,1,1).toResultPoint(),x=this.getFirstDifferent(new Yt(P-7,H+7),!1,-1,1).toResultPoint(),b=this.getFirstDifferent(new Yt(P-7,H-7),!1,-1,-1).toResultPoint()}let v=Je.round((l.getX()+b.getX()+f.getX()+x.getX())/4),j=Je.round((l.getY()+b.getY()+f.getY()+x.getY())/4);try{let T=new Dt(this.image,15,v,j).detect();l=T[0],f=T[1],x=T[2],b=T[3]}catch(T){l=this.getFirstDifferent(new Yt(v+7,j-7),!1,1,-1).toResultPoint(),f=this.getFirstDifferent(new Yt(v+7,j+7),!1,1,1).toResultPoint(),x=this.getFirstDifferent(new Yt(v-7,j+7),!1,-1,1).toResultPoint(),b=this.getFirstDifferent(new Yt(v-7,j-7),!1,-1,-1).toResultPoint()}return v=Je.round((l.getX()+b.getX()+f.getX()+x.getX())/4),j=Je.round((l.getY()+b.getY()+f.getY()+x.getY())/4),new Yt(v,j)}getMatrixCornerPoints(l){return this.expandSquare(l,2*this.nbCenterLayers,this.getDimension())}sampleGrid(l,f,x,b,v){let j=Ot.getInstance(),T=this.getDimension(),P=T/2-this.nbCenterLayers,H=T/2+this.nbCenterLayers;return j.sampleGrid(l,T,T,P,P,H,P,H,H,P,H,f.getX(),f.getY(),x.getX(),x.getY(),b.getX(),b.getY(),v.getX(),v.getY())}sampleLine(l,f,x){let b=0,v=this.distanceResultPoint(l,f),j=v/x,T=l.getX(),P=l.getY(),H=j*(f.getX()-l.getX())/v,de=j*(f.getY()-l.getY())/v;for(let je=0;je<x;je++)this.image.get(Je.round(T+je*H),Je.round(P+je*de))&&(b|=1<<x-je-1);return b}isWhiteOrBlackRectangle(l,f,x,b){let v=3;l=new Yt(l.getX()-v,l.getY()+v),f=new Yt(f.getX()-v,f.getY()-v),x=new Yt(x.getX()+v,x.getY()-v),b=new Yt(b.getX()+v,b.getY()+v);let j=this.getColor(b,l);if(j===0)return!1;let T=this.getColor(l,f);return T!==j||(T=this.getColor(f,x),T!==j)?!1:(T=this.getColor(x,b),T===j)}getColor(l,f){let x=this.distancePoint(l,f),b=(f.getX()-l.getX())/x,v=(f.getY()-l.getY())/x,j=0,T=l.getX(),P=l.getY(),H=this.image.get(l.getX(),l.getY()),de=Math.ceil(x);for(let Ae=0;Ae<de;Ae++)T+=b,P+=v,this.image.get(Je.round(T),Je.round(P))!==H&&j++;let je=j/x;return je>.1&&je<.9?0:je<=.1===H?1:-1}getFirstDifferent(l,f,x,b){let v=l.getX()+x,j=l.getY()+b;for(;this.isValid(v,j)&&this.image.get(v,j)===f;)v+=x,j+=b;for(v-=x,j-=b;this.isValid(v,j)&&this.image.get(v,j)===f;)v+=x;for(v-=x;this.isValid(v,j)&&this.image.get(v,j)===f;)j+=b;return j-=b,new Yt(v,j)}expandSquare(l,f,x){let b=x/(2*f),v=l[0].getX()-l[2].getX(),j=l[0].getY()-l[2].getY(),T=(l[0].getX()+l[2].getX())/2,P=(l[0].getY()+l[2].getY())/2,H=new Xe(T+b*v,P+b*j),de=new Xe(T-b*v,P-b*j);v=l[1].getX()-l[3].getX(),j=l[1].getY()-l[3].getY(),T=(l[1].getX()+l[3].getX())/2,P=(l[1].getY()+l[3].getY())/2;let je=new Xe(T+b*v,P+b*j),Ae=new Xe(T-b*v,P-b*j);return[H,je,de,Ae]}isValid(l,f){return l>=0&&l<this.image.getWidth()&&f>0&&f<this.image.getHeight()}isValidPoint(l){let f=Je.round(l.getX()),x=Je.round(l.getY());return this.isValid(f,x)}distancePoint(l,f){return Je.distance(l.getX(),l.getY(),f.getX(),f.getY())}distanceResultPoint(l,f){return Je.distance(l.getX(),l.getY(),f.getX(),f.getY())}getDimension(){return this.compact?4*this.nbLayers+11:this.nbLayers<=4?4*this.nbLayers+15:4*this.nbLayers+2*(F.truncDivision(this.nbLayers-4,8)+1)+15}}class wt{decode(l,f=null){let x=null,b=new Ye(l.getBlackMatrix()),v=null,j=null;try{let de=b.detectMirror(!1);v=de.getPoints(),this.reportFoundResultPoints(f,v),j=new Lt().decode(de)}catch(de){x=de}if(j==null)try{let de=b.detectMirror(!0);v=de.getPoints(),this.reportFoundResultPoints(f,v),j=new Lt().decode(de)}catch(de){throw x!=null?x:de}let T=new ae(j.getText(),j.getRawBytes(),j.getNumBits(),v,le.AZTEC,C.currentTimeMillis()),P=j.getByteSegments();P!=null&&T.putMetadata(Z.BYTE_SEGMENTS,P);let H=j.getECLevel();return H!=null&&T.putMetadata(Z.ERROR_CORRECTION_LEVEL,H),T}reportFoundResultPoints(l,f){if(l!=null){let x=l.get(X.NEED_RESULT_POINT_CALLBACK);x!=null&&f.forEach((b,v,j)=>{x.foundPossibleResultPoint(b)})}}reset(){}}class zt extends J{constructor(l=500){super(new wt,l)}}class qt{decode(l,f){try{return this.doDecode(l,f)}catch(x){if(f&&f.get(X.TRY_HARDER)===!0&&l.isRotateSupported()){const v=l.rotateCounterClockwise(),j=this.doDecode(v,f),T=j.getResultMetadata();let P=270;T!==null&&T.get(Z.ORIENTATION)===!0&&(P=P+T.get(Z.ORIENTATION)%360),j.putMetadata(Z.ORIENTATION,P);const H=j.getResultPoints();if(H!==null){const de=v.getHeight();for(let je=0;je<H.length;je++)H[je]=new Xe(de-H[je].getY()-1,H[je].getX())}return j}else throw new re}}reset(){}doDecode(l,f){const x=l.getWidth(),b=l.getHeight();let v=new z(x);const j=f&&f.get(X.TRY_HARDER)===!0,T=Math.max(1,b>>(j?8:5));let P;j?P=b:P=15;const H=Math.trunc(b/2);for(let de=0;de<P;de++){const je=Math.trunc((de+1)/2),Ae=(de&1)===0,Ge=H+T*(Ae?je:-je);if(Ge<0||Ge>=b)break;try{v=l.getBlackRow(Ge,v)}catch(ot){continue}for(let ot=0;ot<2;ot++){if(ot===1&&(v.reverse(),f&&f.get(X.NEED_RESULT_POINT_CALLBACK)===!0)){const ut=new Map;f.forEach((At,se)=>ut.set(se,At)),ut.delete(X.NEED_RESULT_POINT_CALLBACK),f=ut}try{const ut=this.decodeRow(Ge,v,f);if(ot===1){ut.putMetadata(Z.ORIENTATION,180);const At=ut.getResultPoints();At!==null&&(At[0]=new Xe(x-At[0].getX()-1,At[0].getY()),At[1]=new Xe(x-At[1].getX()-1,At[1].getY()))}return ut}catch(ut){}}}throw new re}static recordPattern(l,f,x){const b=x.length;for(let H=0;H<b;H++)x[H]=0;const v=l.getSize();if(f>=v)throw new re;let j=!l.get(f),T=0,P=f;for(;P<v;){if(l.get(P)!==j)x[T]++;else{if(++T===b)break;x[T]=1,j=!j}P++}if(!(T===b||T===b-1&&P===v))throw new re}static recordPatternInReverse(l,f,x){let b=x.length,v=l.get(f);for(;f>0&&b>=0;)l.get(--f)!==v&&(b--,v=!v);if(b>=0)throw new re;qt.recordPattern(l,f+1,x)}static patternMatchVariance(l,f,x){const b=l.length;let v=0,j=0;for(let H=0;H<b;H++)v+=l[H],j+=f[H];if(v<j)return Number.POSITIVE_INFINITY;const T=v/j;x*=T;let P=0;for(let H=0;H<b;H++){const de=l[H],je=f[H]*T,Ae=de>je?de-je:je-de;if(Ae>x)return Number.POSITIVE_INFINITY;P+=Ae}return P/v}}class kt extends qt{static findStartPattern(l){const f=l.getSize(),x=l.getNextSet(0);let b=0,v=Int32Array.from([0,0,0,0,0,0]),j=x,T=!1;const P=6;for(let H=x;H<f;H++)if(l.get(H)!==T)v[b]++;else{if(b===P-1){let de=kt.MAX_AVG_VARIANCE,je=-1;for(let Ae=kt.CODE_START_A;Ae<=kt.CODE_START_C;Ae++){const Ge=qt.patternMatchVariance(v,kt.CODE_PATTERNS[Ae],kt.MAX_INDIVIDUAL_VARIANCE);Ge<de&&(de=Ge,je=Ae)}if(je>=0&&l.isRange(Math.max(0,j-(H-j)/2),j,!1))return Int32Array.from([j,H,je]);j+=v[0]+v[1],v=v.slice(2,v.length-1),v[b-1]=0,v[b]=0,b--}else b++;v[b]=1,T=!T}throw new re}static decodeCode(l,f,x){qt.recordPattern(l,x,f);let b=kt.MAX_AVG_VARIANCE,v=-1;for(let j=0;j<kt.CODE_PATTERNS.length;j++){const T=kt.CODE_PATTERNS[j],P=this.patternMatchVariance(f,T,kt.MAX_INDIVIDUAL_VARIANCE);P<b&&(b=P,v=j)}if(v>=0)return v;throw new re}decodeRow(l,f,x){const b=x&&x.get(X.ASSUME_GS1)===!0,v=kt.findStartPattern(f),j=v[2];let T=0;const P=new Uint8Array(20);P[T++]=j;let H;switch(j){case kt.CODE_START_A:H=kt.CODE_CODE_A;break;case kt.CODE_START_B:H=kt.CODE_CODE_B;break;case kt.CODE_START_C:H=kt.CODE_CODE_C;break;default:throw new B}let de=!1,je=!1,Ae="",Ge=v[0],ot=v[1];const ut=Int32Array.from([0,0,0,0,0,0]);let At=0,se=0,Ee=j,Ue=0,ht=!0,ur=!1,tr=!1;for(;!de;){const as=je;switch(je=!1,At=se,se=kt.decodeCode(f,ut,ot),P[T++]=se,se!==kt.CODE_STOP&&(ht=!0),se!==kt.CODE_STOP&&(Ue++,Ee+=Ue*se),Ge=ot,ot+=ut.reduce((xn,xa)=>xn+xa,0),se){case kt.CODE_START_A:case kt.CODE_START_B:case kt.CODE_START_C:throw new B}switch(H){case kt.CODE_CODE_A:if(se<64)tr===ur?Ae+=String.fromCharCode(32+se):Ae+=String.fromCharCode(32+se+128),tr=!1;else if(se<96)tr===ur?Ae+=String.fromCharCode(se-64):Ae+=String.fromCharCode(se+64),tr=!1;else switch(se!==kt.CODE_STOP&&(ht=!1),se){case kt.CODE_FNC_1:b&&(Ae.length===0?Ae+="]C1":Ae+="");break;case kt.CODE_FNC_2:case kt.CODE_FNC_3:break;case kt.CODE_FNC_4_A:!ur&&tr?(ur=!0,tr=!1):ur&&tr?(ur=!1,tr=!1):tr=!0;break;case kt.CODE_SHIFT:je=!0,H=kt.CODE_CODE_B;break;case kt.CODE_CODE_B:H=kt.CODE_CODE_B;break;case kt.CODE_CODE_C:H=kt.CODE_CODE_C;break;case kt.CODE_STOP:de=!0;break}break;case kt.CODE_CODE_B:if(se<96)tr===ur?Ae+=String.fromCharCode(32+se):Ae+=String.fromCharCode(32+se+128),tr=!1;else switch(se!==kt.CODE_STOP&&(ht=!1),se){case kt.CODE_FNC_1:b&&(Ae.length===0?Ae+="]C1":Ae+="");break;case kt.CODE_FNC_2:case kt.CODE_FNC_3:break;case kt.CODE_FNC_4_B:!ur&&tr?(ur=!0,tr=!1):ur&&tr?(ur=!1,tr=!1):tr=!0;break;case kt.CODE_SHIFT:je=!0,H=kt.CODE_CODE_A;break;case kt.CODE_CODE_A:H=kt.CODE_CODE_A;break;case kt.CODE_CODE_C:H=kt.CODE_CODE_C;break;case kt.CODE_STOP:de=!0;break}break;case kt.CODE_CODE_C:if(se<100)se<10&&(Ae+="0"),Ae+=se;else switch(se!==kt.CODE_STOP&&(ht=!1),se){case kt.CODE_FNC_1:b&&(Ae.length===0?Ae+="]C1":Ae+="");break;case kt.CODE_CODE_A:H=kt.CODE_CODE_A;break;case kt.CODE_CODE_B:H=kt.CODE_CODE_B;break;case kt.CODE_STOP:de=!0;break}break}as&&(H=H===kt.CODE_CODE_A?kt.CODE_CODE_B:kt.CODE_CODE_A)}const Ar=ot-Ge;if(ot=f.getNextUnset(ot),!f.isRange(ot,Math.min(f.getSize(),ot+(ot-Ge)/2),!1))throw new re;if(Ee-=Ue*At,Ee%103!==At)throw new S;const ra=Ae.length;if(ra===0)throw new re;ra>0&&ht&&(H===kt.CODE_CODE_C?Ae=Ae.substring(0,ra-2):Ae=Ae.substring(0,ra-1));const La=(v[1]+v[0])/2,Dr=Ge+Ar/2,Ta=P.length,gs=new Uint8Array(Ta);for(let as=0;as<Ta;as++)gs[as]=P[as];const vs=[new Xe(La,l),new Xe(Dr,l)];return new ae(Ae,gs,0,vs,le.CODE_128,new Date().getTime())}}kt.CODE_PATTERNS=[Int32Array.from([2,1,2,2,2,2]),Int32Array.from([2,2,2,1,2,2]),Int32Array.from([2,2,2,2,2,1]),Int32Array.from([1,2,1,2,2,3]),Int32Array.from([1,2,1,3,2,2]),Int32Array.from([1,3,1,2,2,2]),Int32Array.from([1,2,2,2,1,3]),Int32Array.from([1,2,2,3,1,2]),Int32Array.from([1,3,2,2,1,2]),Int32Array.from([2,2,1,2,1,3]),Int32Array.from([2,2,1,3,1,2]),Int32Array.from([2,3,1,2,1,2]),Int32Array.from([1,1,2,2,3,2]),Int32Array.from([1,2,2,1,3,2]),Int32Array.from([1,2,2,2,3,1]),Int32Array.from([1,1,3,2,2,2]),Int32Array.from([1,2,3,1,2,2]),Int32Array.from([1,2,3,2,2,1]),Int32Array.from([2,2,3,2,1,1]),Int32Array.from([2,2,1,1,3,2]),Int32Array.from([2,2,1,2,3,1]),Int32Array.from([2,1,3,2,1,2]),Int32Array.from([2,2,3,1,1,2]),Int32Array.from([3,1,2,1,3,1]),Int32Array.from([3,1,1,2,2,2]),Int32Array.from([3,2,1,1,2,2]),Int32Array.from([3,2,1,2,2,1]),Int32Array.from([3,1,2,2,1,2]),Int32Array.from([3,2,2,1,1,2]),Int32Array.from([3,2,2,2,1,1]),Int32Array.from([2,1,2,1,2,3]),Int32Array.from([2,1,2,3,2,1]),Int32Array.from([2,3,2,1,2,1]),Int32Array.from([1,1,1,3,2,3]),Int32Array.from([1,3,1,1,2,3]),Int32Array.from([1,3,1,3,2,1]),Int32Array.from([1,1,2,3,1,3]),Int32Array.from([1,3,2,1,1,3]),Int32Array.from([1,3,2,3,1,1]),Int32Array.from([2,1,1,3,1,3]),Int32Array.from([2,3,1,1,1,3]),Int32Array.from([2,3,1,3,1,1]),Int32Array.from([1,1,2,1,3,3]),Int32Array.from([1,1,2,3,3,1]),Int32Array.from([1,3,2,1,3,1]),Int32Array.from([1,1,3,1,2,3]),Int32Array.from([1,1,3,3,2,1]),Int32Array.from([1,3,3,1,2,1]),Int32Array.from([3,1,3,1,2,1]),Int32Array.from([2,1,1,3,3,1]),Int32Array.from([2,3,1,1,3,1]),Int32Array.from([2,1,3,1,1,3]),Int32Array.from([2,1,3,3,1,1]),Int32Array.from([2,1,3,1,3,1]),Int32Array.from([3,1,1,1,2,3]),Int32Array.from([3,1,1,3,2,1]),Int32Array.from([3,3,1,1,2,1]),Int32Array.from([3,1,2,1,1,3]),Int32Array.from([3,1,2,3,1,1]),Int32Array.from([3,3,2,1,1,1]),Int32Array.from([3,1,4,1,1,1]),Int32Array.from([2,2,1,4,1,1]),Int32Array.from([4,3,1,1,1,1]),Int32Array.from([1,1,1,2,2,4]),Int32Array.from([1,1,1,4,2,2]),Int32Array.from([1,2,1,1,2,4]),Int32Array.from([1,2,1,4,2,1]),Int32Array.from([1,4,1,1,2,2]),Int32Array.from([1,4,1,2,2,1]),Int32Array.from([1,1,2,2,1,4]),Int32Array.from([1,1,2,4,1,2]),Int32Array.from([1,2,2,1,1,4]),Int32Array.from([1,2,2,4,1,1]),Int32Array.from([1,4,2,1,1,2]),Int32Array.from([1,4,2,2,1,1]),Int32Array.from([2,4,1,2,1,1]),Int32Array.from([2,2,1,1,1,4]),Int32Array.from([4,1,3,1,1,1]),Int32Array.from([2,4,1,1,1,2]),Int32Array.from([1,3,4,1,1,1]),Int32Array.from([1,1,1,2,4,2]),Int32Array.from([1,2,1,1,4,2]),Int32Array.from([1,2,1,2,4,1]),Int32Array.from([1,1,4,2,1,2]),Int32Array.from([1,2,4,1,1,2]),Int32Array.from([1,2,4,2,1,1]),Int32Array.from([4,1,1,2,1,2]),Int32Array.from([4,2,1,1,1,2]),Int32Array.from([4,2,1,2,1,1]),Int32Array.from([2,1,2,1,4,1]),Int32Array.from([2,1,4,1,2,1]),Int32Array.from([4,1,2,1,2,1]),Int32Array.from([1,1,1,1,4,3]),Int32Array.from([1,1,1,3,4,1]),Int32Array.from([1,3,1,1,4,1]),Int32Array.from([1,1,4,1,1,3]),Int32Array.from([1,1,4,3,1,1]),Int32Array.from([4,1,1,1,1,3]),Int32Array.from([4,1,1,3,1,1]),Int32Array.from([1,1,3,1,4,1]),Int32Array.from([1,1,4,1,3,1]),Int32Array.from([3,1,1,1,4,1]),Int32Array.from([4,1,1,1,3,1]),Int32Array.from([2,1,1,4,1,2]),Int32Array.from([2,1,1,2,1,4]),Int32Array.from([2,1,1,2,3,2]),Int32Array.from([2,3,3,1,1,1,2])],kt.MAX_AVG_VARIANCE=.25,kt.MAX_INDIVIDUAL_VARIANCE=.7,kt.CODE_SHIFT=98,kt.CODE_CODE_C=99,kt.CODE_CODE_B=100,kt.CODE_CODE_A=101,kt.CODE_FNC_1=102,kt.CODE_FNC_2=97,kt.CODE_FNC_3=96,kt.CODE_FNC_4_A=101,kt.CODE_FNC_4_B=100,kt.CODE_START_A=103,kt.CODE_START_B=104,kt.CODE_START_C=105,kt.CODE_STOP=106;class ze extends qt{constructor(l=!1,f=!1){super(),this.usingCheckDigit=l,this.extendedMode=f,this.decodeRowResult="",this.counters=new Int32Array(9)}decodeRow(l,f,x){let b=this.counters;b.fill(0),this.decodeRowResult="";let v=ze.findAsteriskPattern(f,b),j=f.getNextSet(v[1]),T=f.getSize(),P,H;do{ze.recordPattern(f,j,b);let ut=ze.toNarrowWidePattern(b);if(ut<0)throw new re;P=ze.patternToChar(ut),this.decodeRowResult+=P,H=j;for(let At of b)j+=At;j=f.getNextSet(j)}while(P!=="*");this.decodeRowResult=this.decodeRowResult.substring(0,this.decodeRowResult.length-1);let de=0;for(let ut of b)de+=ut;let je=j-H-de;if(j!==T&&je*2<de)throw new re;if(this.usingCheckDigit){let ut=this.decodeRowResult.length-1,At=0;for(let se=0;se<ut;se++)At+=ze.ALPHABET_STRING.indexOf(this.decodeRowResult.charAt(se));if(this.decodeRowResult.charAt(ut)!==ze.ALPHABET_STRING.charAt(At%43))throw new S;this.decodeRowResult=this.decodeRowResult.substring(0,ut)}if(this.decodeRowResult.length===0)throw new re;let Ae;this.extendedMode?Ae=ze.decodeExtended(this.decodeRowResult):Ae=this.decodeRowResult;let Ge=(v[1]+v[0])/2,ot=H+de/2;return new ae(Ae,null,0,[new Xe(Ge,l),new Xe(ot,l)],le.CODE_39,new Date().getTime())}static findAsteriskPattern(l,f){let x=l.getSize(),b=l.getNextSet(0),v=0,j=b,T=!1,P=f.length;for(let H=b;H<x;H++)if(l.get(H)!==T)f[v]++;else{if(v===P-1){if(this.toNarrowWidePattern(f)===ze.ASTERISK_ENCODING&&l.isRange(Math.max(0,j-Math.floor((H-j)/2)),j,!1))return[j,H];j+=f[0]+f[1],f.copyWithin(0,2,2+v-1),f[v-1]=0,f[v]=0,v--}else v++;f[v]=1,T=!T}throw new re}static toNarrowWidePattern(l){let f=l.length,x=0,b;do{let v=2147483647;for(let P of l)P<v&&P>x&&(v=P);x=v,b=0;let j=0,T=0;for(let P=0;P<f;P++){let H=l[P];H>x&&(T|=1<<f-1-P,b++,j+=H)}if(b===3){for(let P=0;P<f&&b>0;P++){let H=l[P];if(H>x&&(b--,H*2>=j))return-1}return T}}while(b>3);return-1}static patternToChar(l){for(let f=0;f<ze.CHARACTER_ENCODINGS.length;f++)if(ze.CHARACTER_ENCODINGS[f]===l)return ze.ALPHABET_STRING.charAt(f);if(l===ze.ASTERISK_ENCODING)return"*";throw new re}static decodeExtended(l){let f=l.length,x="";for(let b=0;b<f;b++){let v=l.charAt(b);if(v==="+"||v==="$"||v==="%"||v==="/"){let j=l.charAt(b+1),T="\0";switch(v){case"+":if(j>="A"&&j<="Z")T=String.fromCharCode(j.charCodeAt(0)+32);else throw new B;break;case"$":if(j>="A"&&j<="Z")T=String.fromCharCode(j.charCodeAt(0)-64);else throw new B;break;case"%":if(j>="A"&&j<="E")T=String.fromCharCode(j.charCodeAt(0)-38);else if(j>="F"&&j<="J")T=String.fromCharCode(j.charCodeAt(0)-11);else if(j>="K"&&j<="O")T=String.fromCharCode(j.charCodeAt(0)+16);else if(j>="P"&&j<="T")T=String.fromCharCode(j.charCodeAt(0)+43);else if(j==="U")T="\0";else if(j==="V")T="@";else if(j==="W")T="`";else if(j==="X"||j==="Y"||j==="Z")T="";else throw new B;break;case"/":if(j>="A"&&j<="O")T=String.fromCharCode(j.charCodeAt(0)-32);else if(j==="Z")T=":";else throw new B;break}x+=T,b++}else x+=v}return x}}ze.ALPHABET_STRING="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%",ze.CHARACTER_ENCODINGS=[52,289,97,352,49,304,112,37,292,100,265,73,328,25,280,88,13,268,76,28,259,67,322,19,274,82,7,262,70,22,385,193,448,145,400,208,133,388,196,168,162,138,42],ze.ASTERISK_ENCODING=148;class nt extends qt{constructor(){super(...arguments),this.narrowLineWidth=-1}decodeRow(l,f,x){let b=this.decodeStart(f),v=this.decodeEnd(f),j=new ke;nt.decodeMiddle(f,b[1],v[0],j);let T=j.toString(),P=null;x!=null&&(P=x.get(X.ALLOWED_LENGTHS)),P==null&&(P=nt.DEFAULT_ALLOWED_LENGTHS);let H=T.length,de=!1,je=0;for(let ot of P){if(H===ot){de=!0;break}ot>je&&(je=ot)}if(!de&&H>je&&(de=!0),!de)throw new B;const Ae=[new Xe(b[1],l),new Xe(v[0],l)];return new ae(T,null,0,Ae,le.ITF,new Date().getTime())}static decodeMiddle(l,f,x,b){let v=new Int32Array(10),j=new Int32Array(5),T=new Int32Array(5);for(v.fill(0),j.fill(0),T.fill(0);f<x;){qt.recordPattern(l,f,v);for(let H=0;H<5;H++){let de=2*H;j[H]=v[de],T[H]=v[de+1]}let P=nt.decodeDigit(j);b.append(P.toString()),P=this.decodeDigit(T),b.append(P.toString()),v.forEach(function(H){f+=H})}}decodeStart(l){let f=nt.skipWhiteSpace(l),x=nt.findGuardPattern(l,f,nt.START_PATTERN);return this.narrowLineWidth=(x[1]-x[0])/4,this.validateQuietZone(l,x[0]),x}validateQuietZone(l,f){let x=this.narrowLineWidth*10;x=x<f?x:f;for(let b=f-1;x>0&&b>=0&&!l.get(b);b--)x--;if(x!==0)throw new re}static skipWhiteSpace(l){const f=l.getSize(),x=l.getNextSet(0);if(x===f)throw new re;return x}decodeEnd(l){l.reverse();try{let f=nt.skipWhiteSpace(l),x;try{x=nt.findGuardPattern(l,f,nt.END_PATTERN_REVERSED[0])}catch(v){v instanceof re&&(x=nt.findGuardPattern(l,f,nt.END_PATTERN_REVERSED[1]))}this.validateQuietZone(l,x[0]);let b=x[0];return x[0]=l.getSize()-x[1],x[1]=l.getSize()-b,x}finally{l.reverse()}}static findGuardPattern(l,f,x){let b=x.length,v=new Int32Array(b),j=l.getSize(),T=!1,P=0,H=f;v.fill(0);for(let de=f;de<j;de++)if(l.get(de)!==T)v[P]++;else{if(P===b-1){if(qt.patternMatchVariance(v,x,nt.MAX_INDIVIDUAL_VARIANCE)<nt.MAX_AVG_VARIANCE)return[H,de];H+=v[0]+v[1],C.arraycopy(v,2,v,0,P-1),v[P-1]=0,v[P]=0,P--}else P++;v[P]=1,T=!T}throw new re}static decodeDigit(l){let f=nt.MAX_AVG_VARIANCE,x=-1,b=nt.PATTERNS.length;for(let v=0;v<b;v++){let j=nt.PATTERNS[v],T=qt.patternMatchVariance(l,j,nt.MAX_INDIVIDUAL_VARIANCE);T<f?(f=T,x=v):T===f&&(x=-1)}if(x>=0)return x%10;throw new re}}nt.PATTERNS=[Int32Array.from([1,1,2,2,1]),Int32Array.from([2,1,1,1,2]),Int32Array.from([1,2,1,1,2]),Int32Array.from([2,2,1,1,1]),Int32Array.from([1,1,2,1,2]),Int32Array.from([2,1,2,1,1]),Int32Array.from([1,2,2,1,1]),Int32Array.from([1,1,1,2,2]),Int32Array.from([2,1,1,2,1]),Int32Array.from([1,2,1,2,1]),Int32Array.from([1,1,3,3,1]),Int32Array.from([3,1,1,1,3]),Int32Array.from([1,3,1,1,3]),Int32Array.from([3,3,1,1,1]),Int32Array.from([1,1,3,1,3]),Int32Array.from([3,1,3,1,1]),Int32Array.from([1,3,3,1,1]),Int32Array.from([1,1,1,3,3]),Int32Array.from([3,1,1,3,1]),Int32Array.from([1,3,1,3,1])],nt.MAX_AVG_VARIANCE=.38,nt.MAX_INDIVIDUAL_VARIANCE=.5,nt.DEFAULT_ALLOWED_LENGTHS=[6,8,10,12,14],nt.START_PATTERN=Int32Array.from([1,1,1,1]),nt.END_PATTERN_REVERSED=[Int32Array.from([1,1,2]),Int32Array.from([1,1,3])];class _t extends qt{constructor(){super(...arguments),this.decodeRowStringBuffer=""}static findStartGuardPattern(l){let f=!1,x,b=0,v=Int32Array.from([0,0,0]);for(;!f;){v=Int32Array.from([0,0,0]),x=_t.findGuardPattern(l,b,!1,this.START_END_PATTERN,v);let j=x[0];b=x[1];let T=j-(b-j);T>=0&&(f=l.isRange(T,j,!1))}return x}static checkChecksum(l){return _t.checkStandardUPCEANChecksum(l)}static checkStandardUPCEANChecksum(l){let f=l.length;if(f===0)return!1;let x=parseInt(l.charAt(f-1),10);return _t.getStandardUPCEANChecksum(l.substring(0,f-1))===x}static getStandardUPCEANChecksum(l){let f=l.length,x=0;for(let b=f-1;b>=0;b-=2){let v=l.charAt(b).charCodeAt(0)-48;if(v<0||v>9)throw new B;x+=v}x*=3;for(let b=f-2;b>=0;b-=2){let v=l.charAt(b).charCodeAt(0)-48;if(v<0||v>9)throw new B;x+=v}return(1e3-x)%10}static decodeEnd(l,f){return _t.findGuardPattern(l,f,!1,_t.START_END_PATTERN,new Int32Array(_t.START_END_PATTERN.length).fill(0))}static findGuardPatternWithoutCounters(l,f,x,b){return this.findGuardPattern(l,f,x,b,new Int32Array(b.length))}static findGuardPattern(l,f,x,b,v){let j=l.getSize();f=x?l.getNextUnset(f):l.getNextSet(f);let T=0,P=f,H=b.length,de=x;for(let je=f;je<j;je++)if(l.get(je)!==de)v[T]++;else{if(T===H-1){if(qt.patternMatchVariance(v,b,_t.MAX_INDIVIDUAL_VARIANCE)<_t.MAX_AVG_VARIANCE)return Int32Array.from([P,je]);P+=v[0]+v[1];let Ae=v.slice(2,v.length-1);for(let Ge=0;Ge<T-1;Ge++)v[Ge]=Ae[Ge];v[T-1]=0,v[T]=0,T--}else T++;v[T]=1,de=!de}throw new re}static decodeDigit(l,f,x,b){this.recordPattern(l,x,f);let v=this.MAX_AVG_VARIANCE,j=-1,T=b.length;for(let P=0;P<T;P++){let H=b[P],de=qt.patternMatchVariance(f,H,_t.MAX_INDIVIDUAL_VARIANCE);de<v&&(v=de,j=P)}if(j>=0)return j;throw new re}}_t.MAX_AVG_VARIANCE=.48,_t.MAX_INDIVIDUAL_VARIANCE=.7,_t.START_END_PATTERN=Int32Array.from([1,1,1]),_t.MIDDLE_PATTERN=Int32Array.from([1,1,1,1,1]),_t.END_PATTERN=Int32Array.from([1,1,1,1,1,1]),_t.L_PATTERNS=[Int32Array.from([3,2,1,1]),Int32Array.from([2,2,2,1]),Int32Array.from([2,1,2,2]),Int32Array.from([1,4,1,1]),Int32Array.from([1,1,3,2]),Int32Array.from([1,2,3,1]),Int32Array.from([1,1,1,4]),Int32Array.from([1,3,1,2]),Int32Array.from([1,2,1,3]),Int32Array.from([3,1,1,2])];class lr{constructor(){this.CHECK_DIGIT_ENCODINGS=[24,20,18,17,12,6,3,10,9,5],this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(l,f,x){let b=this.decodeRowStringBuffer,v=this.decodeMiddle(f,x,b),j=b.toString(),T=lr.parseExtensionString(j),P=[new Xe((x[0]+x[1])/2,l),new Xe(v,l)],H=new ae(j,null,0,P,le.UPC_EAN_EXTENSION,new Date().getTime());return T!=null&&H.putAllMetadata(T),H}decodeMiddle(l,f,x){let b=this.decodeMiddleCounters;b[0]=0,b[1]=0,b[2]=0,b[3]=0;let v=l.getSize(),j=f[1],T=0;for(let H=0;H<5&&j<v;H++){let de=_t.decodeDigit(l,b,j,_t.L_AND_G_PATTERNS);x+=String.fromCharCode(48+de%10);for(let je of b)j+=je;de>=10&&(T|=1<<4-H),H!==4&&(j=l.getNextSet(j),j=l.getNextUnset(j))}if(x.length!==5)throw new re;let P=this.determineCheckDigit(T);if(lr.extensionChecksum(x.toString())!==P)throw new re;return j}static extensionChecksum(l){let f=l.length,x=0;for(let b=f-2;b>=0;b-=2)x+=l.charAt(b).charCodeAt(0)-48;x*=3;for(let b=f-1;b>=0;b-=2)x+=l.charAt(b).charCodeAt(0)-48;return x*=3,x%10}determineCheckDigit(l){for(let f=0;f<10;f++)if(l===this.CHECK_DIGIT_ENCODINGS[f])return f;throw new re}static parseExtensionString(l){if(l.length!==5)return null;let f=lr.parseExtension5String(l);return f==null?null:new Map([[Z.SUGGESTED_PRICE,f]])}static parseExtension5String(l){let f;switch(l.charAt(0)){case"0":f="£";break;case"5":f="$";break;case"9":switch(l){case"90000":return null;case"99991":return"0.00";case"99990":return"Used"}f="";break;default:f="";break}let x=parseInt(l.substring(1)),b=(x/100).toString(),v=x%100,j=v<10?"0"+v:v.toString();return f+b+"."+j}}class pr{constructor(){this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(l,f,x){let b=this.decodeRowStringBuffer,v=this.decodeMiddle(f,x,b),j=b.toString(),T=pr.parseExtensionString(j),P=[new Xe((x[0]+x[1])/2,l),new Xe(v,l)],H=new ae(j,null,0,P,le.UPC_EAN_EXTENSION,new Date().getTime());return T!=null&&H.putAllMetadata(T),H}decodeMiddle(l,f,x){let b=this.decodeMiddleCounters;b[0]=0,b[1]=0,b[2]=0,b[3]=0;let v=l.getSize(),j=f[1],T=0;for(let P=0;P<2&&j<v;P++){let H=_t.decodeDigit(l,b,j,_t.L_AND_G_PATTERNS);x+=String.fromCharCode(48+H%10);for(let de of b)j+=de;H>=10&&(T|=1<<1-P),P!==1&&(j=l.getNextSet(j),j=l.getNextUnset(j))}if(x.length!==2)throw new re;if(parseInt(x.toString())%4!==T)throw new re;return j}static parseExtensionString(l){return l.length!==2?null:new Map([[Z.ISSUE_NUMBER,parseInt(l)]])}}class Nr{static decodeRow(l,f,x){let b=_t.findGuardPattern(f,x,!1,this.EXTENSION_START_PATTERN,new Int32Array(this.EXTENSION_START_PATTERN.length).fill(0));try{return new lr().decodeRow(l,f,b)}catch(v){return new pr().decodeRow(l,f,b)}}}Nr.EXTENSION_START_PATTERN=Int32Array.from([1,1,2]);class rr extends _t{constructor(){super(),this.decodeRowStringBuffer="",rr.L_AND_G_PATTERNS=rr.L_PATTERNS.map(l=>Int32Array.from(l));for(let l=10;l<20;l++){let f=rr.L_PATTERNS[l-10],x=new Int32Array(f.length);for(let b=0;b<f.length;b++)x[b]=f[f.length-b-1];rr.L_AND_G_PATTERNS[l]=x}}decodeRow(l,f,x){let b=rr.findStartGuardPattern(f),v=x==null?null:x.get(X.NEED_RESULT_POINT_CALLBACK);if(v!=null){const ht=new Xe((b[0]+b[1])/2,l);v.foundPossibleResultPoint(ht)}let j=this.decodeMiddle(f,b,this.decodeRowStringBuffer),T=j.rowOffset,P=j.resultString;if(v!=null){const ht=new Xe(T,l);v.foundPossibleResultPoint(ht)}let H=this.decodeEnd(f,T);if(v!=null){const ht=new Xe((H[0]+H[1])/2,l);v.foundPossibleResultPoint(ht)}let de=H[1],je=de+(de-H[0]);if(je>=f.getSize()||!f.isRange(de,je,!1))throw new re;let Ae=P.toString();if(Ae.length<8)throw new B;if(!rr.checkChecksum(Ae))throw new S;let Ge=(b[1]+b[0])/2,ot=(H[1]+H[0])/2,ut=this.getBarcodeFormat(),At=[new Xe(Ge,l),new Xe(ot,l)],se=new ae(Ae,null,0,At,ut,new Date().getTime()),Ee=0;try{let ht=Nr.decodeRow(l,f,H[1]);se.putMetadata(Z.UPC_EAN_EXTENSION,ht.getText()),se.putAllMetadata(ht.getResultMetadata()),se.addResultPoints(ht.getResultPoints()),Ee=ht.getText().length}catch(ht){}let Ue=x==null?null:x.get(X.ALLOWED_EAN_EXTENSIONS);if(Ue!=null){let ht=!1;for(let ur in Ue)if(Ee.toString()===ur){ht=!0;break}if(!ht)throw new re}return se}decodeEnd(l,f){return rr.findGuardPattern(l,f,!1,rr.START_END_PATTERN,new Int32Array(rr.START_END_PATTERN.length).fill(0))}static checkChecksum(l){return rr.checkStandardUPCEANChecksum(l)}static checkStandardUPCEANChecksum(l){let f=l.length;if(f===0)return!1;let x=parseInt(l.charAt(f-1),10);return rr.getStandardUPCEANChecksum(l.substring(0,f-1))===x}static getStandardUPCEANChecksum(l){let f=l.length,x=0;for(let b=f-1;b>=0;b-=2){let v=l.charAt(b).charCodeAt(0)-48;if(v<0||v>9)throw new B;x+=v}x*=3;for(let b=f-2;b>=0;b-=2){let v=l.charAt(b).charCodeAt(0)-48;if(v<0||v>9)throw new B;x+=v}return(1e3-x)%10}}class _r extends rr{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(l,f,x){let b=this.decodeMiddleCounters;b[0]=0,b[1]=0,b[2]=0,b[3]=0;let v=l.getSize(),j=f[1],T=0;for(let H=0;H<6&&j<v;H++){let de=rr.decodeDigit(l,b,j,rr.L_AND_G_PATTERNS);x+=String.fromCharCode(48+de%10);for(let je of b)j+=je;de>=10&&(T|=1<<5-H)}x=_r.determineFirstDigit(x,T),j=rr.findGuardPattern(l,j,!0,rr.MIDDLE_PATTERN,new Int32Array(rr.MIDDLE_PATTERN.length).fill(0))[1];for(let H=0;H<6&&j<v;H++){let de=rr.decodeDigit(l,b,j,rr.L_PATTERNS);x+=String.fromCharCode(48+de);for(let je of b)j+=je}return{rowOffset:j,resultString:x}}getBarcodeFormat(){return le.EAN_13}static determineFirstDigit(l,f){for(let x=0;x<10;x++)if(f===this.FIRST_DIGIT_ENCODINGS[x])return l=String.fromCharCode(48+x)+l,l;throw new re}}_r.FIRST_DIGIT_ENCODINGS=[0,11,13,14,19,25,28,21,22,26];class Nt extends rr{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(l,f,x){const b=this.decodeMiddleCounters;b[0]=0,b[1]=0,b[2]=0,b[3]=0;let v=l.getSize(),j=f[1];for(let P=0;P<4&&j<v;P++){let H=rr.decodeDigit(l,b,j,rr.L_PATTERNS);x+=String.fromCharCode(48+H);for(let de of b)j+=de}j=rr.findGuardPattern(l,j,!0,rr.MIDDLE_PATTERN,new Int32Array(rr.MIDDLE_PATTERN.length).fill(0))[1];for(let P=0;P<4&&j<v;P++){let H=rr.decodeDigit(l,b,j,rr.L_PATTERNS);x+=String.fromCharCode(48+H);for(let de of b)j+=de}return{rowOffset:j,resultString:x}}getBarcodeFormat(){return le.EAN_8}}class Cr extends rr{constructor(){super(...arguments),this.ean13Reader=new _r}getBarcodeFormat(){return le.UPC_A}decode(l,f){return this.maybeReturnResult(this.ean13Reader.decode(l))}decodeRow(l,f,x){return this.maybeReturnResult(this.ean13Reader.decodeRow(l,f,x))}decodeMiddle(l,f,x){return this.ean13Reader.decodeMiddle(l,f,x)}maybeReturnResult(l){let f=l.getText();if(f.charAt(0)==="0"){let x=new ae(f.substring(1),null,null,l.getResultPoints(),le.UPC_A);return l.getResultMetadata()!=null&&x.putAllMetadata(l.getResultMetadata()),x}else throw new re}reset(){this.ean13Reader.reset()}}class yr extends rr{constructor(){super(),this.decodeMiddleCounters=new Int32Array(4)}decodeMiddle(l,f,x){const b=this.decodeMiddleCounters.map(H=>H);b[0]=0,b[1]=0,b[2]=0,b[3]=0;const v=l.getSize();let j=f[1],T=0;for(let H=0;H<6&&j<v;H++){const de=yr.decodeDigit(l,b,j,yr.L_AND_G_PATTERNS);x+=String.fromCharCode(48+de%10);for(let je of b)j+=je;de>=10&&(T|=1<<5-H)}let P=yr.determineNumSysAndCheckDigit(x,T);return{rowOffset:j,resultString:P}}decodeEnd(l,f){return yr.findGuardPatternWithoutCounters(l,f,!0,yr.MIDDLE_END_PATTERN)}checkChecksum(l){return rr.checkChecksum(yr.convertUPCEtoUPCA(l))}static determineNumSysAndCheckDigit(l,f){for(let x=0;x<=1;x++)for(let b=0;b<10;b++)if(f===this.NUMSYS_AND_CHECK_DIGIT_PATTERNS[x][b]){let v=String.fromCharCode(48+x),j=String.fromCharCode(48+b);return v+l+j}throw re.getNotFoundInstance()}getBarcodeFormat(){return le.UPC_E}static convertUPCEtoUPCA(l){const f=l.slice(1,7).split("").map(v=>v.charCodeAt(0)),x=new ke;x.append(l.charAt(0));let b=f[5];switch(b){case 0:case 1:case 2:x.appendChars(f,0,2),x.append(b),x.append("0000"),x.appendChars(f,2,3);break;case 3:x.appendChars(f,0,3),x.append("00000"),x.appendChars(f,3,2);break;case 4:x.appendChars(f,0,4),x.append("00000"),x.append(f[4]);break;default:x.appendChars(f,0,5),x.append("0000"),x.append(b);break}return l.length>=8&&x.append(l.charAt(7)),x.toString()}}yr.MIDDLE_END_PATTERN=Int32Array.from([1,1,1,1,1,1]),yr.NUMSYS_AND_CHECK_DIGIT_PATTERNS=[Int32Array.from([56,52,50,49,44,38,35,42,41,37]),Int32Array.from([7,11,13,14,19,25,28,21,22,26])];class jt extends qt{constructor(l){super();let f=l==null?null:l.get(X.POSSIBLE_FORMATS),x=[];s(f)?(x.push(new _r),x.push(new Cr),x.push(new Nt),x.push(new yr)):(f.indexOf(le.EAN_13)>-1&&x.push(new _r),f.indexOf(le.UPC_A)>-1&&x.push(new Cr),f.indexOf(le.EAN_8)>-1&&x.push(new Nt),f.indexOf(le.UPC_E)>-1&&x.push(new yr)),this.readers=x}decodeRow(l,f,x){for(let b of this.readers)try{const v=b.decodeRow(l,f,x),j=v.getBarcodeFormat()===le.EAN_13&&v.getText().charAt(0)==="0",T=x==null?null:x.get(X.POSSIBLE_FORMATS),P=T==null||T.includes(le.UPC_A);if(j&&P){const H=v.getRawBytes(),de=new ae(v.getText().substring(1),H,H?H.length:null,v.getResultPoints(),le.UPC_A);return de.putAllMetadata(v.getResultMetadata()),de}return v}catch(v){}throw new re}reset(){for(let l of this.readers)l.reset()}}class Tt extends qt{constructor(){super(),this.decodeFinderCounters=new Int32Array(4),this.dataCharacterCounters=new Int32Array(8),this.oddRoundingErrors=new Array(4),this.evenRoundingErrors=new Array(4),this.oddCounts=new Array(this.dataCharacterCounters.length/2),this.evenCounts=new Array(this.dataCharacterCounters.length/2)}getDecodeFinderCounters(){return this.decodeFinderCounters}getDataCharacterCounters(){return this.dataCharacterCounters}getOddRoundingErrors(){return this.oddRoundingErrors}getEvenRoundingErrors(){return this.evenRoundingErrors}getOddCounts(){return this.oddCounts}getEvenCounts(){return this.evenCounts}parseFinderValue(l,f){for(let x=0;x<f.length;x++)if(qt.patternMatchVariance(l,f[x],Tt.MAX_INDIVIDUAL_VARIANCE)<Tt.MAX_AVG_VARIANCE)return x;throw new re}static count(l){return Je.sum(new Int32Array(l))}static increment(l,f){let x=0,b=f[0];for(let v=1;v<l.length;v++)f[v]>b&&(b=f[v],x=v);l[x]++}static decrement(l,f){let x=0,b=f[0];for(let v=1;v<l.length;v++)f[v]<b&&(b=f[v],x=v);l[x]--}static isFinderPattern(l){let f=l[0]+l[1],x=f+l[2]+l[3],b=f/x;if(b>=Tt.MIN_FINDER_PATTERN_RATIO&&b<=Tt.MAX_FINDER_PATTERN_RATIO){let v=Number.MAX_SAFE_INTEGER,j=Number.MIN_SAFE_INTEGER;for(let T of l)T>j&&(j=T),T<v&&(v=T);return j<10*v}return!1}}Tt.MAX_AVG_VARIANCE=.2,Tt.MAX_INDIVIDUAL_VARIANCE=.45,Tt.MIN_FINDER_PATTERN_RATIO=9.5/12,Tt.MAX_FINDER_PATTERN_RATIO=12.5/14;class He{constructor(l,f){this.value=l,this.checksumPortion=f}getValue(){return this.value}getChecksumPortion(){return this.checksumPortion}toString(){return this.value+"("+this.checksumPortion+")"}equals(l){if(!(l instanceof He))return!1;const f=l;return this.value===f.value&&this.checksumPortion===f.checksumPortion}hashCode(){return this.value^this.checksumPortion}}class Fe{constructor(l,f,x,b,v){this.value=l,this.startEnd=f,this.value=l,this.startEnd=f,this.resultPoints=new Array,this.resultPoints.push(new Xe(x,v)),this.resultPoints.push(new Xe(b,v))}getValue(){return this.value}getStartEnd(){return this.startEnd}getResultPoints(){return this.resultPoints}equals(l){if(!(l instanceof Fe))return!1;const f=l;return this.value===f.value}hashCode(){return this.value}}class Ze{constructor(){}static getRSSvalue(l,f,x){let b=0;for(let P of l)b+=P;let v=0,j=0,T=l.length;for(let P=0;P<T-1;P++){let H;for(H=1,j|=1<<P;H<l[P];H++,j&=~(1<<P)){let de=Ze.combins(b-H-1,T-P-2);if(x&&j===0&&b-H-(T-P-1)>=T-P-1&&(de-=Ze.combins(b-H-(T-P),T-P-2)),T-P-1>1){let je=0;for(let Ae=b-H-(T-P-2);Ae>f;Ae--)je+=Ze.combins(b-H-Ae-1,T-P-3);de-=je*(T-1-P)}else b-H>f&&de--;v+=de}b-=H}return v}static combins(l,f){let x,b;l-f>f?(b=f,x=l-f):(b=l-f,x=f);let v=1,j=1;for(let T=l;T>x;T--)v*=T,j<=b&&(v/=j,j++);for(;j<=b;)v/=j,j++;return v}}class vt{static buildBitArray(l){let f=l.length*2-1;l[l.length-1].getRightChar()==null&&(f-=1);let x=12*f,b=new z(x),v=0,T=l[0].getRightChar().getValue();for(let P=11;P>=0;--P)(T&1<<P)!=0&&b.set(v),v++;for(let P=1;P<l.length;++P){let H=l[P],de=H.getLeftChar().getValue();for(let je=11;je>=0;--je)(de&1<<je)!=0&&b.set(v),v++;if(H.getRightChar()!=null){let je=H.getRightChar().getValue();for(let Ae=11;Ae>=0;--Ae)(je&1<<Ae)!=0&&b.set(v),v++}}return b}}class ir{constructor(l,f){f?this.decodedInformation=null:(this.finished=l,this.decodedInformation=f)}getDecodedInformation(){return this.decodedInformation}isFinished(){return this.finished}}class fr{constructor(l){this.newPosition=l}getNewPosition(){return this.newPosition}}class Kt extends fr{constructor(l,f){super(l),this.value=f}getValue(){return this.value}isFNC1(){return this.value===Kt.FNC1}}Kt.FNC1="$";class Re extends fr{constructor(l,f,x){super(l),x?(this.remaining=!0,this.remainingValue=this.remainingValue):(this.remaining=!1,this.remainingValue=0),this.newString=f}getNewString(){return this.newString}isRemaining(){return this.remaining}getRemainingValue(){return this.remainingValue}}class Q extends fr{constructor(l,f,x){if(super(l),f<0||f>10||x<0||x>10)throw new B;this.firstDigit=f,this.secondDigit=x}getFirstDigit(){return this.firstDigit}getSecondDigit(){return this.secondDigit}getValue(){return this.firstDigit*10+this.secondDigit}isFirstDigitFNC1(){return this.firstDigit===Q.FNC1}isSecondDigitFNC1(){return this.secondDigit===Q.FNC1}isAnyFNC1(){return this.firstDigit===Q.FNC1||this.secondDigit===Q.FNC1}}Q.FNC1=10;class he{constructor(){}static parseFieldsInGeneralPurpose(l){if(!l)return null;if(l.length<2)throw new re;let f=l.substring(0,2);for(let v of he.TWO_DIGIT_DATA_LENGTH)if(v[0]===f)return v[1]===he.VARIABLE_LENGTH?he.processVariableAI(2,v[2],l):he.processFixedAI(2,v[1],l);if(l.length<3)throw new re;let x=l.substring(0,3);for(let v of he.THREE_DIGIT_DATA_LENGTH)if(v[0]===x)return v[1]===he.VARIABLE_LENGTH?he.processVariableAI(3,v[2],l):he.processFixedAI(3,v[1],l);for(let v of he.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH)if(v[0]===x)return v[1]===he.VARIABLE_LENGTH?he.processVariableAI(4,v[2],l):he.processFixedAI(4,v[1],l);if(l.length<4)throw new re;let b=l.substring(0,4);for(let v of he.FOUR_DIGIT_DATA_LENGTH)if(v[0]===b)return v[1]===he.VARIABLE_LENGTH?he.processVariableAI(4,v[2],l):he.processFixedAI(4,v[1],l);throw new re}static processFixedAI(l,f,x){if(x.length<l)throw new re;let b=x.substring(0,l);if(x.length<l+f)throw new re;let v=x.substring(l,l+f),j=x.substring(l+f),T="("+b+")"+v,P=he.parseFieldsInGeneralPurpose(j);return P==null?T:T+P}static processVariableAI(l,f,x){let b=x.substring(0,l),v;x.length<l+f?v=x.length:v=l+f;let j=x.substring(l,v),T=x.substring(v),P="("+b+")"+j,H=he.parseFieldsInGeneralPurpose(T);return H==null?P:P+H}}he.VARIABLE_LENGTH=[],he.TWO_DIGIT_DATA_LENGTH=[["00",18],["01",14],["02",14],["10",he.VARIABLE_LENGTH,20],["11",6],["12",6],["13",6],["15",6],["17",6],["20",2],["21",he.VARIABLE_LENGTH,20],["22",he.VARIABLE_LENGTH,29],["30",he.VARIABLE_LENGTH,8],["37",he.VARIABLE_LENGTH,8],["90",he.VARIABLE_LENGTH,30],["91",he.VARIABLE_LENGTH,30],["92",he.VARIABLE_LENGTH,30],["93",he.VARIABLE_LENGTH,30],["94",he.VARIABLE_LENGTH,30],["95",he.VARIABLE_LENGTH,30],["96",he.VARIABLE_LENGTH,30],["97",he.VARIABLE_LENGTH,3],["98",he.VARIABLE_LENGTH,30],["99",he.VARIABLE_LENGTH,30]],he.THREE_DIGIT_DATA_LENGTH=[["240",he.VARIABLE_LENGTH,30],["241",he.VARIABLE_LENGTH,30],["242",he.VARIABLE_LENGTH,6],["250",he.VARIABLE_LENGTH,30],["251",he.VARIABLE_LENGTH,30],["253",he.VARIABLE_LENGTH,17],["254",he.VARIABLE_LENGTH,20],["400",he.VARIABLE_LENGTH,30],["401",he.VARIABLE_LENGTH,30],["402",17],["403",he.VARIABLE_LENGTH,30],["410",13],["411",13],["412",13],["413",13],["414",13],["420",he.VARIABLE_LENGTH,20],["421",he.VARIABLE_LENGTH,15],["422",3],["423",he.VARIABLE_LENGTH,15],["424",3],["425",3],["426",3]],he.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH=[["310",6],["311",6],["312",6],["313",6],["314",6],["315",6],["316",6],["320",6],["321",6],["322",6],["323",6],["324",6],["325",6],["326",6],["327",6],["328",6],["329",6],["330",6],["331",6],["332",6],["333",6],["334",6],["335",6],["336",6],["340",6],["341",6],["342",6],["343",6],["344",6],["345",6],["346",6],["347",6],["348",6],["349",6],["350",6],["351",6],["352",6],["353",6],["354",6],["355",6],["356",6],["357",6],["360",6],["361",6],["362",6],["363",6],["364",6],["365",6],["366",6],["367",6],["368",6],["369",6],["390",he.VARIABLE_LENGTH,15],["391",he.VARIABLE_LENGTH,18],["392",he.VARIABLE_LENGTH,15],["393",he.VARIABLE_LENGTH,18],["703",he.VARIABLE_LENGTH,30]],he.FOUR_DIGIT_DATA_LENGTH=[["7001",13],["7002",he.VARIABLE_LENGTH,30],["7003",10],["8001",14],["8002",he.VARIABLE_LENGTH,20],["8003",he.VARIABLE_LENGTH,30],["8004",he.VARIABLE_LENGTH,30],["8005",6],["8006",18],["8007",he.VARIABLE_LENGTH,30],["8008",he.VARIABLE_LENGTH,12],["8018",18],["8020",he.VARIABLE_LENGTH,25],["8100",6],["8101",10],["8102",2],["8110",he.VARIABLE_LENGTH,70],["8200",he.VARIABLE_LENGTH,70]];class Se{constructor(l){this.buffer=new ke,this.information=l}decodeAllCodes(l,f){let x=f,b=null;do{let v=this.decodeGeneralPurposeField(x,b),j=he.parseFieldsInGeneralPurpose(v.getNewString());if(j!=null&&l.append(j),v.isRemaining()?b=""+v.getRemainingValue():b=null,x===v.getNewPosition())break;x=v.getNewPosition()}while(!0);return l.toString()}isStillNumeric(l){if(l+7>this.information.getSize())return l+4<=this.information.getSize();for(let f=l;f<l+3;++f)if(this.information.get(f))return!0;return this.information.get(l+3)}decodeNumeric(l){if(l+7>this.information.getSize()){let v=this.extractNumericValueFromBitArray(l,4);return v===0?new Q(this.information.getSize(),Q.FNC1,Q.FNC1):new Q(this.information.getSize(),v-1,Q.FNC1)}let f=this.extractNumericValueFromBitArray(l,7),x=(f-8)/11,b=(f-8)%11;return new Q(l+7,x,b)}extractNumericValueFromBitArray(l,f){return Se.extractNumericValueFromBitArray(this.information,l,f)}static extractNumericValueFromBitArray(l,f,x){let b=0;for(let v=0;v<x;++v)l.get(f+v)&&(b|=1<<x-v-1);return b}decodeGeneralPurposeField(l,f){this.buffer.setLengthToZero(),f!=null&&this.buffer.append(f),this.current.setPosition(l);let x=this.parseBlocks();return x!=null&&x.isRemaining()?new Re(this.current.getPosition(),this.buffer.toString(),x.getRemainingValue()):new Re(this.current.getPosition(),this.buffer.toString())}parseBlocks(){let l,f;do{let x=this.current.getPosition();if(this.current.isAlpha()?(f=this.parseAlphaBlock(),l=f.isFinished()):this.current.isIsoIec646()?(f=this.parseIsoIec646Block(),l=f.isFinished()):(f=this.parseNumericBlock(),l=f.isFinished()),!(x!==this.current.getPosition())&&!l)break}while(!l);return f.getDecodedInformation()}parseNumericBlock(){for(;this.isStillNumeric(this.current.getPosition());){let l=this.decodeNumeric(this.current.getPosition());if(this.current.setPosition(l.getNewPosition()),l.isFirstDigitFNC1()){let f;return l.isSecondDigitFNC1()?f=new Re(this.current.getPosition(),this.buffer.toString()):f=new Re(this.current.getPosition(),this.buffer.toString(),l.getSecondDigit()),new ir(!0,f)}if(this.buffer.append(l.getFirstDigit()),l.isSecondDigitFNC1()){let f=new Re(this.current.getPosition(),this.buffer.toString());return new ir(!0,f)}this.buffer.append(l.getSecondDigit())}return this.isNumericToAlphaNumericLatch(this.current.getPosition())&&(this.current.setAlpha(),this.current.incrementPosition(4)),new ir(!1)}parseIsoIec646Block(){for(;this.isStillIsoIec646(this.current.getPosition());){let l=this.decodeIsoIec646(this.current.getPosition());if(this.current.setPosition(l.getNewPosition()),l.isFNC1()){let f=new Re(this.current.getPosition(),this.buffer.toString());return new ir(!0,f)}this.buffer.append(l.getValue())}return this.isAlphaOr646ToNumericLatch(this.current.getPosition())?(this.current.incrementPosition(3),this.current.setNumeric()):this.isAlphaTo646ToAlphaLatch(this.current.getPosition())&&(this.current.getPosition()+5<this.information.getSize()?this.current.incrementPosition(5):this.current.setPosition(this.information.getSize()),this.current.setAlpha()),new ir(!1)}parseAlphaBlock(){for(;this.isStillAlpha(this.current.getPosition());){let l=this.decodeAlphanumeric(this.current.getPosition());if(this.current.setPosition(l.getNewPosition()),l.isFNC1()){let f=new Re(this.current.getPosition(),this.buffer.toString());return new ir(!0,f)}this.buffer.append(l.getValue())}return this.isAlphaOr646ToNumericLatch(this.current.getPosition())?(this.current.incrementPosition(3),this.current.setNumeric()):this.isAlphaTo646ToAlphaLatch(this.current.getPosition())&&(this.current.getPosition()+5<this.information.getSize()?this.current.incrementPosition(5):this.current.setPosition(this.information.getSize()),this.current.setIsoIec646()),new ir(!1)}isStillIsoIec646(l){if(l+5>this.information.getSize())return!1;let f=this.extractNumericValueFromBitArray(l,5);if(f>=5&&f<16)return!0;if(l+7>this.information.getSize())return!1;let x=this.extractNumericValueFromBitArray(l,7);if(x>=64&&x<116)return!0;if(l+8>this.information.getSize())return!1;let b=this.extractNumericValueFromBitArray(l,8);return b>=232&&b<253}decodeIsoIec646(l){let f=this.extractNumericValueFromBitArray(l,5);if(f===15)return new Kt(l+5,Kt.FNC1);if(f>=5&&f<15)return new Kt(l+5,"0"+(f-5));let x=this.extractNumericValueFromBitArray(l,7);if(x>=64&&x<90)return new Kt(l+7,""+(x+1));if(x>=90&&x<116)return new Kt(l+7,""+(x+7));let b=this.extractNumericValueFromBitArray(l,8),v;switch(b){case 232:v="!";break;case 233:v='"';break;case 234:v="%";break;case 235:v="&";break;case 236:v="'";break;case 237:v="(";break;case 238:v=")";break;case 239:v="*";break;case 240:v="+";break;case 241:v=",";break;case 242:v="-";break;case 243:v=".";break;case 244:v="/";break;case 245:v=":";break;case 246:v=";";break;case 247:v="<";break;case 248:v="=";break;case 249:v=">";break;case 250:v="?";break;case 251:v="_";break;case 252:v=" ";break;default:throw new B}return new Kt(l+8,v)}isStillAlpha(l){if(l+5>this.information.getSize())return!1;let f=this.extractNumericValueFromBitArray(l,5);if(f>=5&&f<16)return!0;if(l+6>this.information.getSize())return!1;let x=this.extractNumericValueFromBitArray(l,6);return x>=16&&x<63}decodeAlphanumeric(l){let f=this.extractNumericValueFromBitArray(l,5);if(f===15)return new Kt(l+5,Kt.FNC1);if(f>=5&&f<15)return new Kt(l+5,"0"+(f-5));let x=this.extractNumericValueFromBitArray(l,6);if(x>=32&&x<58)return new Kt(l+6,""+(x+33));let b;switch(x){case 58:b="*";break;case 59:b=",";break;case 60:b="-";break;case 61:b=".";break;case 62:b="/";break;default:throw new et("Decoding invalid alphanumeric value: "+x)}return new Kt(l+6,b)}isAlphaTo646ToAlphaLatch(l){if(l+1>this.information.getSize())return!1;for(let f=0;f<5&&f+l<this.information.getSize();++f)if(f===2){if(!this.information.get(l+2))return!1}else if(this.information.get(l+f))return!1;return!0}isAlphaOr646ToNumericLatch(l){if(l+3>this.information.getSize())return!1;for(let f=l;f<l+3;++f)if(this.information.get(f))return!1;return!0}isNumericToAlphaNumericLatch(l){if(l+1>this.information.getSize())return!1;for(let f=0;f<4&&f+l<this.information.getSize();++f)if(this.information.get(l+f))return!1;return!0}}class ne{constructor(l){this.information=l,this.generalDecoder=new Se(l)}getInformation(){return this.information}getGeneralDecoder(){return this.generalDecoder}}class _e extends ne{constructor(l){super(l)}encodeCompressedGtin(l,f){l.append("(01)");let x=l.length();l.append("9"),this.encodeCompressedGtinWithoutAI(l,f,x)}encodeCompressedGtinWithoutAI(l,f,x){for(let b=0;b<4;++b){let v=this.getGeneralDecoder().extractNumericValueFromBitArray(f+10*b,10);v/100===0&&l.append("0"),v/10===0&&l.append("0"),l.append(v)}_e.appendCheckDigit(l,x)}static appendCheckDigit(l,f){let x=0;for(let b=0;b<13;b++){let v=l.charAt(b+f).charCodeAt(0)-48;x+=(b&1)===0?3*v:v}x=10-x%10,x===10&&(x=0),l.append(x)}}_e.GTIN_SIZE=40;class Ce extends _e{constructor(l){super(l)}parseInformation(){let l=new ke;l.append("(01)");let f=l.length(),x=this.getGeneralDecoder().extractNumericValueFromBitArray(Ce.HEADER_SIZE,4);return l.append(x),this.encodeCompressedGtinWithoutAI(l,Ce.HEADER_SIZE+4,f),this.getGeneralDecoder().decodeAllCodes(l,Ce.HEADER_SIZE+44)}}Ce.HEADER_SIZE=4;class Qe extends ne{constructor(l){super(l)}parseInformation(){let l=new ke;return this.getGeneralDecoder().decodeAllCodes(l,Qe.HEADER_SIZE)}}Qe.HEADER_SIZE=5;class xt extends _e{constructor(l){super(l)}encodeCompressedWeight(l,f,x){let b=this.getGeneralDecoder().extractNumericValueFromBitArray(f,x);this.addWeightCode(l,b);let v=this.checkWeight(b),j=1e5;for(let T=0;T<5;++T)v/j===0&&l.append("0"),j/=10;l.append(v)}}class dt extends xt{constructor(l){super(l)}parseInformation(){if(this.getInformation().getSize()!=dt.HEADER_SIZE+xt.GTIN_SIZE+dt.WEIGHT_SIZE)throw new re;let l=new ke;return this.encodeCompressedGtin(l,dt.HEADER_SIZE),this.encodeCompressedWeight(l,dt.HEADER_SIZE+xt.GTIN_SIZE,dt.WEIGHT_SIZE),l.toString()}}dt.HEADER_SIZE=5,dt.WEIGHT_SIZE=15;class at extends dt{constructor(l){super(l)}addWeightCode(l,f){l.append("(3103)")}checkWeight(l){return l}}class $e extends dt{constructor(l){super(l)}addWeightCode(l,f){f<1e4?l.append("(3202)"):l.append("(3203)")}checkWeight(l){return l<1e4?l:l-1e4}}class tt extends _e{constructor(l){super(l)}parseInformation(){if(this.getInformation().getSize()<tt.HEADER_SIZE+_e.GTIN_SIZE)throw new re;let l=new ke;this.encodeCompressedGtin(l,tt.HEADER_SIZE);let f=this.getGeneralDecoder().extractNumericValueFromBitArray(tt.HEADER_SIZE+_e.GTIN_SIZE,tt.LAST_DIGIT_SIZE);l.append("(392"),l.append(f),l.append(")");let x=this.getGeneralDecoder().decodeGeneralPurposeField(tt.HEADER_SIZE+_e.GTIN_SIZE+tt.LAST_DIGIT_SIZE,null);return l.append(x.getNewString()),l.toString()}}tt.HEADER_SIZE=8,tt.LAST_DIGIT_SIZE=2;class gt extends _e{constructor(l){super(l)}parseInformation(){if(this.getInformation().getSize()<gt.HEADER_SIZE+_e.GTIN_SIZE)throw new re;let l=new ke;this.encodeCompressedGtin(l,gt.HEADER_SIZE);let f=this.getGeneralDecoder().extractNumericValueFromBitArray(gt.HEADER_SIZE+_e.GTIN_SIZE,gt.LAST_DIGIT_SIZE);l.append("(393"),l.append(f),l.append(")");let x=this.getGeneralDecoder().extractNumericValueFromBitArray(gt.HEADER_SIZE+_e.GTIN_SIZE+gt.LAST_DIGIT_SIZE,gt.FIRST_THREE_DIGITS_SIZE);x/100==0&&l.append("0"),x/10==0&&l.append("0"),l.append(x);let b=this.getGeneralDecoder().decodeGeneralPurposeField(gt.HEADER_SIZE+_e.GTIN_SIZE+gt.LAST_DIGIT_SIZE+gt.FIRST_THREE_DIGITS_SIZE,null);return l.append(b.getNewString()),l.toString()}}gt.HEADER_SIZE=8,gt.LAST_DIGIT_SIZE=2,gt.FIRST_THREE_DIGITS_SIZE=10;class Wt extends xt{constructor(l,f,x){super(l),this.dateCode=x,this.firstAIdigits=f}parseInformation(){if(this.getInformation().getSize()!=Wt.HEADER_SIZE+Wt.GTIN_SIZE+Wt.WEIGHT_SIZE+Wt.DATE_SIZE)throw new re;let l=new ke;return this.encodeCompressedGtin(l,Wt.HEADER_SIZE),this.encodeCompressedWeight(l,Wt.HEADER_SIZE+Wt.GTIN_SIZE,Wt.WEIGHT_SIZE),this.encodeCompressedDate(l,Wt.HEADER_SIZE+Wt.GTIN_SIZE+Wt.WEIGHT_SIZE),l.toString()}encodeCompressedDate(l,f){let x=this.getGeneralDecoder().extractNumericValueFromBitArray(f,Wt.DATE_SIZE);if(x==38400)return;l.append("("),l.append(this.dateCode),l.append(")");let b=x%32;x/=32;let v=x%12+1;x/=12;let j=x;j/10==0&&l.append("0"),l.append(j),v/10==0&&l.append("0"),l.append(v),b/10==0&&l.append("0"),l.append(b)}addWeightCode(l,f){l.append("("),l.append(this.firstAIdigits),l.append(f/1e5),l.append(")")}checkWeight(l){return l%1e5}}Wt.HEADER_SIZE=8,Wt.WEIGHT_SIZE=20,Wt.DATE_SIZE=16;function Ft(Ne){try{if(Ne.get(1))return new Ce(Ne);if(!Ne.get(2))return new Qe(Ne);switch(Se.extractNumericValueFromBitArray(Ne,1,4)){case 4:return new at(Ne);case 5:return new $e(Ne)}switch(Se.extractNumericValueFromBitArray(Ne,1,5)){case 12:return new tt(Ne);case 13:return new gt(Ne)}switch(Se.extractNumericValueFromBitArray(Ne,1,7)){case 56:return new Wt(Ne,"310","11");case 57:return new Wt(Ne,"320","11");case 58:return new Wt(Ne,"310","13");case 59:return new Wt(Ne,"320","13");case 60:return new Wt(Ne,"310","15");case 61:return new Wt(Ne,"320","15");case 62:return new Wt(Ne,"310","17");case 63:return new Wt(Ne,"320","17")}}catch(l){throw console.log(l),new et("unknown decoder: "+Ne)}}class Zt{constructor(l,f,x,b){this.leftchar=l,this.rightchar=f,this.finderpattern=x,this.maybeLast=b}mayBeLast(){return this.maybeLast}getLeftChar(){return this.leftchar}getRightChar(){return this.rightchar}getFinderPattern(){return this.finderpattern}mustBeLast(){return this.rightchar==null}toString(){return"[ "+this.leftchar+", "+this.rightchar+" : "+(this.finderpattern==null?"null":this.finderpattern.getValue())+" ]"}static equals(l,f){return l instanceof Zt?Zt.equalsOrNull(l.leftchar,f.leftchar)&&Zt.equalsOrNull(l.rightchar,f.rightchar)&&Zt.equalsOrNull(l.finderpattern,f.finderpattern):!1}static equalsOrNull(l,f){return l===null?f===null:Zt.equals(l,f)}hashCode(){return this.leftchar.getValue()^this.rightchar.getValue()^this.finderpattern.getValue()}}class br{constructor(l,f,x){this.pairs=l,this.rowNumber=f,this.wasReversed=x}getPairs(){return this.pairs}getRowNumber(){return this.rowNumber}isReversed(){return this.wasReversed}isEquivalent(l){return this.checkEqualitity(this,l)}toString(){return"{ "+this.pairs+" }"}equals(l,f){return l instanceof br?this.checkEqualitity(l,f)&&l.wasReversed===f.wasReversed:!1}checkEqualitity(l,f){if(!l||!f)return;let x;return l.forEach((b,v)=>{f.forEach(j=>{b.getLeftChar().getValue()===j.getLeftChar().getValue()&&b.getRightChar().getValue()===j.getRightChar().getValue()&&b.getFinderPatter().getValue()===j.getFinderPatter().getValue()&&(x=!0)})}),x}}class Ht extends Tt{constructor(l){super(...arguments),this.pairs=new Array(Ht.MAX_PAIRS),this.rows=new Array,this.startEnd=[2],this.verbose=l===!0}decodeRow(l,f,x){this.pairs.length=0,this.startFromEven=!1;try{return Ht.constructResult(this.decodeRow2pairs(l,f))}catch(b){this.verbose&&console.log(b)}return this.pairs.length=0,this.startFromEven=!0,Ht.constructResult(this.decodeRow2pairs(l,f))}reset(){this.pairs.length=0,this.rows.length=0}decodeRow2pairs(l,f){let x=!1;for(;!x;)try{this.pairs.push(this.retrieveNextPair(f,this.pairs,l))}catch(v){if(v instanceof re){if(!this.pairs.length)throw new re;x=!0}}if(this.checkChecksum())return this.pairs;let b;if(this.rows.length?b=!0:b=!1,this.storeRow(l,!1),b){let v=this.checkRowsBoolean(!1);if(v!=null||(v=this.checkRowsBoolean(!0),v!=null))return v}throw new re}checkRowsBoolean(l){if(this.rows.length>25)return this.rows.length=0,null;this.pairs.length=0,l&&(this.rows=this.rows.reverse());let f=null;try{f=this.checkRows(new Array,0)}catch(x){this.verbose&&console.log(x)}return l&&(this.rows=this.rows.reverse()),f}checkRows(l,f){for(let x=f;x<this.rows.length;x++){let b=this.rows[x];this.pairs.length=0;for(let j of l)this.pairs.push(j.getPairs());if(this.pairs.push(b.getPairs()),!Ht.isValidSequence(this.pairs))continue;if(this.checkChecksum())return this.pairs;let v=new Array(l);v.push(b);try{return this.checkRows(v,x+1)}catch(j){this.verbose&&console.log(j)}}throw new re}static isValidSequence(l){for(let f of Ht.FINDER_PATTERN_SEQUENCES){if(l.length>f.length)continue;let x=!0;for(let b=0;b<l.length;b++)if(l[b].getFinderPattern().getValue()!=f[b]){x=!1;break}if(x)return!0}return!1}storeRow(l,f){let x=0,b=!1,v=!1;for(;x<this.rows.length;){let j=this.rows[x];if(j.getRowNumber()>l){v=j.isEquivalent(this.pairs);break}b=j.isEquivalent(this.pairs),x++}v||b||Ht.isPartialRow(this.pairs,this.rows)||(this.rows.push(x,new br(this.pairs,l,f)),this.removePartialRows(this.pairs,this.rows))}removePartialRows(l,f){for(let x of f)if(x.getPairs().length!==l.length){for(let b of x.getPairs())for(let v of l)if(Zt.equals(b,v))break}}static isPartialRow(l,f){for(let x of f){let b=!0;for(let v of l){let j=!1;for(let T of x.getPairs())if(v.equals(T)){j=!0;break}if(!j){b=!1;break}}if(b)return!0}return!1}getRows(){return this.rows}static constructResult(l){let f=vt.buildBitArray(l),b=Ft(f).parseInformation(),v=l[0].getFinderPattern().getResultPoints(),j=l[l.length-1].getFinderPattern().getResultPoints(),T=[v[0],v[1],j[0],j[1]];return new ae(b,null,null,T,le.RSS_EXPANDED,null)}checkChecksum(){let l=this.pairs.get(0),f=l.getLeftChar(),x=l.getRightChar();if(x==null)return!1;let b=x.getChecksumPortion(),v=2;for(let T=1;T<this.pairs.size();++T){let P=this.pairs.get(T);b+=P.getLeftChar().getChecksumPortion(),v++;let H=P.getRightChar();H!=null&&(b+=H.getChecksumPortion(),v++)}return b%=211,211*(v-4)+b==f.getValue()}static getNextSecondBar(l,f){let x;return l.get(f)?(x=l.getNextUnset(f),x=l.getNextSet(x)):(x=l.getNextSet(f),x=l.getNextUnset(x)),x}retrieveNextPair(l,f,x){let b=f.length%2==0;this.startFromEven&&(b=!b);let v,j=!0,T=-1;do this.findNextPair(l,f,T),v=this.parseFoundFinderPattern(l,x,b),v==null?T=Ht.getNextSecondBar(l,this.startEnd[0]):j=!1;while(j);let P=this.decodeDataCharacter(l,v,b,!0);if(!this.isEmptyPair(f)&&f[f.length-1].mustBeLast())throw new re;let H;try{H=this.decodeDataCharacter(l,v,b,!1)}catch(de){H=null,this.verbose&&console.log(de)}return new Zt(P,H,v,!0)}isEmptyPair(l){return l.length===0}findNextPair(l,f,x){let b=this.getDecodeFinderCounters();b[0]=0,b[1]=0,b[2]=0,b[3]=0;let v=l.getSize(),j;x>=0?j=x:this.isEmptyPair(f)?j=0:j=f[f.length-1].getFinderPattern().getStartEnd()[1];let T=f.length%2!=0;this.startFromEven&&(T=!T);let P=!1;for(;j<v&&(P=!l.get(j),!!P);)j++;let H=0,de=j;for(let je=j;je<v;je++)if(l.get(je)!=P)b[H]++;else{if(H==3){if(T&&Ht.reverseCounters(b),Ht.isFinderPattern(b)){this.startEnd[0]=de,this.startEnd[1]=je;return}T&&Ht.reverseCounters(b),de+=b[0]+b[1],b[0]=b[2],b[1]=b[3],b[2]=0,b[3]=0,H--}else H++;b[H]=1,P=!P}throw new re}static reverseCounters(l){let f=l.length;for(let x=0;x<f/2;++x){let b=l[x];l[x]=l[f-x-1],l[f-x-1]=b}}parseFoundFinderPattern(l,f,x){let b,v,j;if(x){let H=this.startEnd[0]-1;for(;H>=0&&!l.get(H);)H--;H++,b=this.startEnd[0]-H,v=H,j=this.startEnd[1]}else v=this.startEnd[0],j=l.getNextUnset(this.startEnd[1]+1),b=j-this.startEnd[1];let T=this.getDecodeFinderCounters();C.arraycopy(T,0,T,1,T.length-1),T[0]=b;let P;try{P=this.parseFinderValue(T,Ht.FINDER_PATTERNS)}catch(H){return null}return new Fe(P,[v,j],v,j,f)}decodeDataCharacter(l,f,x,b){let v=this.getDataCharacterCounters();for(let Dr=0;Dr<v.length;Dr++)v[Dr]=0;if(b)Ht.recordPatternInReverse(l,f.getStartEnd()[0],v);else{Ht.recordPattern(l,f.getStartEnd()[1],v);for(let Dr=0,Ta=v.length-1;Dr<Ta;Dr++,Ta--){let gs=v[Dr];v[Dr]=v[Ta],v[Ta]=gs}}let j=17,T=Je.sum(new Int32Array(v))/j,P=(f.getStartEnd()[1]-f.getStartEnd()[0])/15;if(Math.abs(T-P)/P>.3)throw new re;let H=this.getOddCounts(),de=this.getEvenCounts(),je=this.getOddRoundingErrors(),Ae=this.getEvenRoundingErrors();for(let Dr=0;Dr<v.length;Dr++){let Ta=1*v[Dr]/T,gs=Ta+.5;if(gs<1){if(Ta<.3)throw new re;gs=1}else if(gs>8){if(Ta>8.7)throw new re;gs=8}let vs=Dr/2;(Dr&1)==0?(H[vs]=gs,je[vs]=Ta-gs):(de[vs]=gs,Ae[vs]=Ta-gs)}this.adjustOddEvenCounts(j);let Ge=4*f.getValue()+(x?0:2)+(b?0:1)-1,ot=0,ut=0;for(let Dr=H.length-1;Dr>=0;Dr--){if(Ht.isNotA1left(f,x,b)){let Ta=Ht.WEIGHTS[Ge][2*Dr];ut+=H[Dr]*Ta}ot+=H[Dr]}let At=0;for(let Dr=de.length-1;Dr>=0;Dr--)if(Ht.isNotA1left(f,x,b)){let Ta=Ht.WEIGHTS[Ge][2*Dr+1];At+=de[Dr]*Ta}let se=ut+At;if((ot&1)!=0||ot>13||ot<4)throw new re;let Ee=(13-ot)/2,Ue=Ht.SYMBOL_WIDEST[Ee],ht=9-Ue,ur=Ze.getRSSvalue(H,Ue,!0),tr=Ze.getRSSvalue(de,ht,!1),Ar=Ht.EVEN_TOTAL_SUBSET[Ee],ra=Ht.GSUM[Ee],La=ur*Ar+tr+ra;return new He(La,se)}static isNotA1left(l,f,x){return!(l.getValue()==0&&f&&x)}adjustOddEvenCounts(l){let f=Je.sum(new Int32Array(this.getOddCounts())),x=Je.sum(new Int32Array(this.getEvenCounts())),b=!1,v=!1;f>13?v=!0:f<4&&(b=!0);let j=!1,T=!1;x>13?T=!0:x<4&&(j=!0);let P=f+x-l,H=(f&1)==1,de=(x&1)==0;if(P==1)if(H){if(de)throw new re;v=!0}else{if(!de)throw new re;T=!0}else if(P==-1)if(H){if(de)throw new re;b=!0}else{if(!de)throw new re;j=!0}else if(P==0){if(H){if(!de)throw new re;f<x?(b=!0,T=!0):(v=!0,j=!0)}else if(de)throw new re}else throw new re;if(b){if(v)throw new re;Ht.increment(this.getOddCounts(),this.getOddRoundingErrors())}if(v&&Ht.decrement(this.getOddCounts(),this.getOddRoundingErrors()),j){if(T)throw new re;Ht.increment(this.getEvenCounts(),this.getOddRoundingErrors())}T&&Ht.decrement(this.getEvenCounts(),this.getEvenRoundingErrors())}}Ht.SYMBOL_WIDEST=[7,5,4,3,1],Ht.EVEN_TOTAL_SUBSET=[4,20,52,104,204],Ht.GSUM=[0,348,1388,2948,3988],Ht.FINDER_PATTERNS=[Int32Array.from([1,8,4,1]),Int32Array.from([3,6,4,1]),Int32Array.from([3,4,6,1]),Int32Array.from([3,2,8,1]),Int32Array.from([2,6,5,1]),Int32Array.from([2,2,9,1])],Ht.WEIGHTS=[[1,3,9,27,81,32,96,77],[20,60,180,118,143,7,21,63],[189,145,13,39,117,140,209,205],[193,157,49,147,19,57,171,91],[62,186,136,197,169,85,44,132],[185,133,188,142,4,12,36,108],[113,128,173,97,80,29,87,50],[150,28,84,41,123,158,52,156],[46,138,203,187,139,206,196,166],[76,17,51,153,37,111,122,155],[43,129,176,106,107,110,119,146],[16,48,144,10,30,90,59,177],[109,116,137,200,178,112,125,164],[70,210,208,202,184,130,179,115],[134,191,151,31,93,68,204,190],[148,22,66,198,172,94,71,2],[6,18,54,162,64,192,154,40],[120,149,25,75,14,42,126,167],[79,26,78,23,69,207,199,175],[103,98,83,38,114,131,182,124],[161,61,183,127,170,88,53,159],[55,165,73,8,24,72,5,15],[45,135,194,160,58,174,100,89]],Ht.FINDER_PAT_A=0,Ht.FINDER_PAT_B=1,Ht.FINDER_PAT_C=2,Ht.FINDER_PAT_D=3,Ht.FINDER_PAT_E=4,Ht.FINDER_PAT_F=5,Ht.FINDER_PATTERN_SEQUENCES=[[Ht.FINDER_PAT_A,Ht.FINDER_PAT_A],[Ht.FINDER_PAT_A,Ht.FINDER_PAT_B,Ht.FINDER_PAT_B],[Ht.FINDER_PAT_A,Ht.FINDER_PAT_C,Ht.FINDER_PAT_B,Ht.FINDER_PAT_D],[Ht.FINDER_PAT_A,Ht.FINDER_PAT_E,Ht.FINDER_PAT_B,Ht.FINDER_PAT_D,Ht.FINDER_PAT_C],[Ht.FINDER_PAT_A,Ht.FINDER_PAT_E,Ht.FINDER_PAT_B,Ht.FINDER_PAT_D,Ht.FINDER_PAT_D,Ht.FINDER_PAT_F],[Ht.FINDER_PAT_A,Ht.FINDER_PAT_E,Ht.FINDER_PAT_B,Ht.FINDER_PAT_D,Ht.FINDER_PAT_E,Ht.FINDER_PAT_F,Ht.FINDER_PAT_F],[Ht.FINDER_PAT_A,Ht.FINDER_PAT_A,Ht.FINDER_PAT_B,Ht.FINDER_PAT_B,Ht.FINDER_PAT_C,Ht.FINDER_PAT_C,Ht.FINDER_PAT_D,Ht.FINDER_PAT_D],[Ht.FINDER_PAT_A,Ht.FINDER_PAT_A,Ht.FINDER_PAT_B,Ht.FINDER_PAT_B,Ht.FINDER_PAT_C,Ht.FINDER_PAT_C,Ht.FINDER_PAT_D,Ht.FINDER_PAT_E,Ht.FINDER_PAT_E],[Ht.FINDER_PAT_A,Ht.FINDER_PAT_A,Ht.FINDER_PAT_B,Ht.FINDER_PAT_B,Ht.FINDER_PAT_C,Ht.FINDER_PAT_C,Ht.FINDER_PAT_D,Ht.FINDER_PAT_E,Ht.FINDER_PAT_F,Ht.FINDER_PAT_F],[Ht.FINDER_PAT_A,Ht.FINDER_PAT_A,Ht.FINDER_PAT_B,Ht.FINDER_PAT_B,Ht.FINDER_PAT_C,Ht.FINDER_PAT_D,Ht.FINDER_PAT_D,Ht.FINDER_PAT_E,Ht.FINDER_PAT_E,Ht.FINDER_PAT_F,Ht.FINDER_PAT_F]],Ht.MAX_PAIRS=11;class fa extends He{constructor(l,f,x){super(l,f),this.count=0,this.finderPattern=x}getFinderPattern(){return this.finderPattern}getCount(){return this.count}incrementCount(){this.count++}}class qr extends Tt{constructor(){super(...arguments),this.possibleLeftPairs=[],this.possibleRightPairs=[]}decodeRow(l,f,x){const b=this.decodePair(f,!1,l,x);qr.addOrTally(this.possibleLeftPairs,b),f.reverse();let v=this.decodePair(f,!0,l,x);qr.addOrTally(this.possibleRightPairs,v),f.reverse();for(let j of this.possibleLeftPairs)if(j.getCount()>1){for(let T of this.possibleRightPairs)if(T.getCount()>1&&qr.checkChecksum(j,T))return qr.constructResult(j,T)}throw new re}static addOrTally(l,f){if(f==null)return;let x=!1;for(let b of l)if(b.getValue()===f.getValue()){b.incrementCount(),x=!0;break}x||l.push(f)}reset(){this.possibleLeftPairs.length=0,this.possibleRightPairs.length=0}static constructResult(l,f){let x=4537077*l.getValue()+f.getValue(),b=new String(x).toString(),v=new ke;for(let H=13-b.length;H>0;H--)v.append("0");v.append(b);let j=0;for(let H=0;H<13;H++){let de=v.charAt(H).charCodeAt(0)-48;j+=(H&1)===0?3*de:de}j=10-j%10,j===10&&(j=0),v.append(j.toString());let T=l.getFinderPattern().getResultPoints(),P=f.getFinderPattern().getResultPoints();return new ae(v.toString(),null,0,[T[0],T[1],P[0],P[1]],le.RSS_14,new Date().getTime())}static checkChecksum(l,f){let x=(l.getChecksumPortion()+16*f.getChecksumPortion())%79,b=9*l.getFinderPattern().getValue()+f.getFinderPattern().getValue();return b>72&&b--,b>8&&b--,x===b}decodePair(l,f,x,b){try{let v=this.findFinderPattern(l,f),j=this.parseFoundFinderPattern(l,x,f,v),T=b==null?null:b.get(X.NEED_RESULT_POINT_CALLBACK);if(T!=null){let de=(v[0]+v[1])/2;f&&(de=l.getSize()-1-de),T.foundPossibleResultPoint(new Xe(de,x))}let P=this.decodeDataCharacter(l,j,!0),H=this.decodeDataCharacter(l,j,!1);return new fa(1597*P.getValue()+H.getValue(),P.getChecksumPortion()+4*H.getChecksumPortion(),j)}catch(v){return null}}decodeDataCharacter(l,f,x){let b=this.getDataCharacterCounters();for(let At=0;At<b.length;At++)b[At]=0;if(x)qt.recordPatternInReverse(l,f.getStartEnd()[0],b);else{qt.recordPattern(l,f.getStartEnd()[1]+1,b);for(let At=0,se=b.length-1;At<se;At++,se--){let Ee=b[At];b[At]=b[se],b[se]=Ee}}let v=x?16:15,j=Je.sum(new Int32Array(b))/v,T=this.getOddCounts(),P=this.getEvenCounts(),H=this.getOddRoundingErrors(),de=this.getEvenRoundingErrors();for(let At=0;At<b.length;At++){let se=b[At]/j,Ee=Math.floor(se+.5);Ee<1?Ee=1:Ee>8&&(Ee=8);let Ue=Math.floor(At/2);(At&1)===0?(T[Ue]=Ee,H[Ue]=se-Ee):(P[Ue]=Ee,de[Ue]=se-Ee)}this.adjustOddEvenCounts(x,v);let je=0,Ae=0;for(let At=T.length-1;At>=0;At--)Ae*=9,Ae+=T[At],je+=T[At];let Ge=0,ot=0;for(let At=P.length-1;At>=0;At--)Ge*=9,Ge+=P[At],ot+=P[At];let ut=Ae+3*Ge;if(x){if((je&1)!==0||je>12||je<4)throw new re;let At=(12-je)/2,se=qr.OUTSIDE_ODD_WIDEST[At],Ee=9-se,Ue=Ze.getRSSvalue(T,se,!1),ht=Ze.getRSSvalue(P,Ee,!0),ur=qr.OUTSIDE_EVEN_TOTAL_SUBSET[At],tr=qr.OUTSIDE_GSUM[At];return new He(Ue*ur+ht+tr,ut)}else{if((ot&1)!==0||ot>10||ot<4)throw new re;let At=(10-ot)/2,se=qr.INSIDE_ODD_WIDEST[At],Ee=9-se,Ue=Ze.getRSSvalue(T,se,!0),ht=Ze.getRSSvalue(P,Ee,!1),ur=qr.INSIDE_ODD_TOTAL_SUBSET[At],tr=qr.INSIDE_GSUM[At];return new He(ht*ur+Ue+tr,ut)}}findFinderPattern(l,f){let x=this.getDecodeFinderCounters();x[0]=0,x[1]=0,x[2]=0,x[3]=0;let b=l.getSize(),v=!1,j=0;for(;j<b&&(v=!l.get(j),f!==v);)j++;let T=0,P=j;for(let H=j;H<b;H++)if(l.get(H)!==v)x[T]++;else{if(T===3){if(Tt.isFinderPattern(x))return[P,H];P+=x[0]+x[1],x[0]=x[2],x[1]=x[3],x[2]=0,x[3]=0,T--}else T++;x[T]=1,v=!v}throw new re}parseFoundFinderPattern(l,f,x,b){let v=l.get(b[0]),j=b[0]-1;for(;j>=0&&v!==l.get(j);)j--;j++;const T=b[0]-j,P=this.getDecodeFinderCounters(),H=new Int32Array(P.length);C.arraycopy(P,0,H,1,P.length-1),H[0]=T;const de=this.parseFinderValue(H,qr.FINDER_PATTERNS);let je=j,Ae=b[1];return x&&(je=l.getSize()-1-je,Ae=l.getSize()-1-Ae),new Fe(de,[j,b[1]],je,Ae,f)}adjustOddEvenCounts(l,f){let x=Je.sum(new Int32Array(this.getOddCounts())),b=Je.sum(new Int32Array(this.getEvenCounts())),v=!1,j=!1,T=!1,P=!1;l?(x>12?j=!0:x<4&&(v=!0),b>12?P=!0:b<4&&(T=!0)):(x>11?j=!0:x<5&&(v=!0),b>10?P=!0:b<4&&(T=!0));let H=x+b-f,de=(x&1)===(l?1:0),je=(b&1)===1;if(H===1)if(de){if(je)throw new re;j=!0}else{if(!je)throw new re;P=!0}else if(H===-1)if(de){if(je)throw new re;v=!0}else{if(!je)throw new re;T=!0}else if(H===0){if(de){if(!je)throw new re;x<b?(v=!0,P=!0):(j=!0,T=!0)}else if(je)throw new re}else throw new re;if(v){if(j)throw new re;Tt.increment(this.getOddCounts(),this.getOddRoundingErrors())}if(j&&Tt.decrement(this.getOddCounts(),this.getOddRoundingErrors()),T){if(P)throw new re;Tt.increment(this.getEvenCounts(),this.getOddRoundingErrors())}P&&Tt.decrement(this.getEvenCounts(),this.getEvenRoundingErrors())}}qr.OUTSIDE_EVEN_TOTAL_SUBSET=[1,10,34,70,126],qr.INSIDE_ODD_TOTAL_SUBSET=[4,20,48,81],qr.OUTSIDE_GSUM=[0,161,961,2015,2715],qr.INSIDE_GSUM=[0,336,1036,1516],qr.OUTSIDE_ODD_WIDEST=[8,6,4,3,1],qr.INSIDE_ODD_WIDEST=[2,4,6,8],qr.FINDER_PATTERNS=[Int32Array.from([3,8,2,1]),Int32Array.from([3,5,5,1]),Int32Array.from([3,3,7,1]),Int32Array.from([3,1,9,1]),Int32Array.from([2,7,4,1]),Int32Array.from([2,5,6,1]),Int32Array.from([2,3,8,1]),Int32Array.from([1,5,7,1]),Int32Array.from([1,3,9,1])];class vr extends qt{constructor(l,f){super(),this.readers=[],this.verbose=f===!0;const x=l?l.get(X.POSSIBLE_FORMATS):null,b=l&&l.get(X.ASSUME_CODE_39_CHECK_DIGIT)!==void 0;x?((x.includes(le.EAN_13)||x.includes(le.UPC_A)||x.includes(le.EAN_8)||x.includes(le.UPC_E))&&this.readers.push(new jt(l)),x.includes(le.CODE_39)&&this.readers.push(new ze(b)),x.includes(le.CODE_128)&&this.readers.push(new kt),x.includes(le.ITF)&&this.readers.push(new nt),x.includes(le.RSS_14)&&this.readers.push(new qr),x.includes(le.RSS_EXPANDED)&&this.readers.push(new Ht(this.verbose))):(this.readers.push(new jt(l)),this.readers.push(new ze),this.readers.push(new jt(l)),this.readers.push(new kt),this.readers.push(new nt),this.readers.push(new qr),this.readers.push(new Ht(this.verbose)))}decodeRow(l,f,x){for(let b=0;b<this.readers.length;b++)try{return this.readers[b].decodeRow(l,f,x)}catch(v){}throw new re}reset(){this.readers.forEach(l=>l.reset())}}class da extends J{constructor(l=500,f){super(new vr(f),l,f)}}class zr{constructor(l,f,x){this.ecCodewords=l,this.ecBlocks=[f],x&&this.ecBlocks.push(x)}getECCodewords(){return this.ecCodewords}getECBlocks(){return this.ecBlocks}}class Kr{constructor(l,f){this.count=l,this.dataCodewords=f}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class Yr{constructor(l,f,x,b,v,j){this.versionNumber=l,this.symbolSizeRows=f,this.symbolSizeColumns=x,this.dataRegionSizeRows=b,this.dataRegionSizeColumns=v,this.ecBlocks=j;let T=0;const P=j.getECCodewords(),H=j.getECBlocks();for(let de of H)T+=de.getCount()*(de.getDataCodewords()+P);this.totalCodewords=T}getVersionNumber(){return this.versionNumber}getSymbolSizeRows(){return this.symbolSizeRows}getSymbolSizeColumns(){return this.symbolSizeColumns}getDataRegionSizeRows(){return this.dataRegionSizeRows}getDataRegionSizeColumns(){return this.dataRegionSizeColumns}getTotalCodewords(){return this.totalCodewords}getECBlocks(){return this.ecBlocks}static getVersionForDimensions(l,f){if((l&1)!==0||(f&1)!==0)throw new B;for(let x of Yr.VERSIONS)if(x.symbolSizeRows===l&&x.symbolSizeColumns===f)return x;throw new B}toString(){return""+this.versionNumber}static buildVersions(){return[new Yr(1,10,10,8,8,new zr(5,new Kr(1,3))),new Yr(2,12,12,10,10,new zr(7,new Kr(1,5))),new Yr(3,14,14,12,12,new zr(10,new Kr(1,8))),new Yr(4,16,16,14,14,new zr(12,new Kr(1,12))),new Yr(5,18,18,16,16,new zr(14,new Kr(1,18))),new Yr(6,20,20,18,18,new zr(18,new Kr(1,22))),new Yr(7,22,22,20,20,new zr(20,new Kr(1,30))),new Yr(8,24,24,22,22,new zr(24,new Kr(1,36))),new Yr(9,26,26,24,24,new zr(28,new Kr(1,44))),new Yr(10,32,32,14,14,new zr(36,new Kr(1,62))),new Yr(11,36,36,16,16,new zr(42,new Kr(1,86))),new Yr(12,40,40,18,18,new zr(48,new Kr(1,114))),new Yr(13,44,44,20,20,new zr(56,new Kr(1,144))),new Yr(14,48,48,22,22,new zr(68,new Kr(1,174))),new Yr(15,52,52,24,24,new zr(42,new Kr(2,102))),new Yr(16,64,64,14,14,new zr(56,new Kr(2,140))),new Yr(17,72,72,16,16,new zr(36,new Kr(4,92))),new Yr(18,80,80,18,18,new zr(48,new Kr(4,114))),new Yr(19,88,88,20,20,new zr(56,new Kr(4,144))),new Yr(20,96,96,22,22,new zr(68,new Kr(4,174))),new Yr(21,104,104,24,24,new zr(56,new Kr(6,136))),new Yr(22,120,120,18,18,new zr(68,new Kr(6,175))),new Yr(23,132,132,20,20,new zr(62,new Kr(8,163))),new Yr(24,144,144,22,22,new zr(62,new Kr(8,156),new Kr(2,155))),new Yr(25,8,18,6,16,new zr(7,new Kr(1,5))),new Yr(26,8,32,6,14,new zr(11,new Kr(1,10))),new Yr(27,12,26,10,24,new zr(14,new Kr(1,16))),new Yr(28,12,36,10,16,new zr(18,new Kr(1,22))),new Yr(29,16,36,14,16,new zr(24,new Kr(1,32))),new Yr(30,16,48,14,22,new zr(28,new Kr(1,49)))]}}Yr.VERSIONS=Yr.buildVersions();class Gr{constructor(l){const f=l.getHeight();if(f<8||f>144||(f&1)!==0)throw new B;this.version=Gr.readVersion(l),this.mappingBitMatrix=this.extractDataRegion(l),this.readMappingMatrix=new ge(this.mappingBitMatrix.getWidth(),this.mappingBitMatrix.getHeight())}getVersion(){return this.version}static readVersion(l){const f=l.getHeight(),x=l.getWidth();return Yr.getVersionForDimensions(f,x)}readCodewords(){const l=new Int8Array(this.version.getTotalCodewords());let f=0,x=4,b=0;const v=this.mappingBitMatrix.getHeight(),j=this.mappingBitMatrix.getWidth();let T=!1,P=!1,H=!1,de=!1;do if(x===v&&b===0&&!T)l[f++]=this.readCorner1(v,j)&255,x-=2,b+=2,T=!0;else if(x===v-2&&b===0&&(j&3)!==0&&!P)l[f++]=this.readCorner2(v,j)&255,x-=2,b+=2,P=!0;else if(x===v+4&&b===2&&(j&7)===0&&!H)l[f++]=this.readCorner3(v,j)&255,x-=2,b+=2,H=!0;else if(x===v-2&&b===0&&(j&7)===4&&!de)l[f++]=this.readCorner4(v,j)&255,x-=2,b+=2,de=!0;else{do x<v&&b>=0&&!this.readMappingMatrix.get(b,x)&&(l[f++]=this.readUtah(x,b,v,j)&255),x-=2,b+=2;while(x>=0&&b<j);x+=1,b+=3;do x>=0&&b<j&&!this.readMappingMatrix.get(b,x)&&(l[f++]=this.readUtah(x,b,v,j)&255),x+=2,b-=2;while(x<v&&b>=0);x+=3,b+=1}while(x<v||b<j);if(f!==this.version.getTotalCodewords())throw new B;return l}readModule(l,f,x,b){return l<0&&(l+=x,f+=4-(x+4&7)),f<0&&(f+=b,l+=4-(b+4&7)),this.readMappingMatrix.set(f,l),this.mappingBitMatrix.get(f,l)}readUtah(l,f,x,b){let v=0;return this.readModule(l-2,f-2,x,b)&&(v|=1),v<<=1,this.readModule(l-2,f-1,x,b)&&(v|=1),v<<=1,this.readModule(l-1,f-2,x,b)&&(v|=1),v<<=1,this.readModule(l-1,f-1,x,b)&&(v|=1),v<<=1,this.readModule(l-1,f,x,b)&&(v|=1),v<<=1,this.readModule(l,f-2,x,b)&&(v|=1),v<<=1,this.readModule(l,f-1,x,b)&&(v|=1),v<<=1,this.readModule(l,f,x,b)&&(v|=1),v}readCorner1(l,f){let x=0;return this.readModule(l-1,0,l,f)&&(x|=1),x<<=1,this.readModule(l-1,1,l,f)&&(x|=1),x<<=1,this.readModule(l-1,2,l,f)&&(x|=1),x<<=1,this.readModule(0,f-2,l,f)&&(x|=1),x<<=1,this.readModule(0,f-1,l,f)&&(x|=1),x<<=1,this.readModule(1,f-1,l,f)&&(x|=1),x<<=1,this.readModule(2,f-1,l,f)&&(x|=1),x<<=1,this.readModule(3,f-1,l,f)&&(x|=1),x}readCorner2(l,f){let x=0;return this.readModule(l-3,0,l,f)&&(x|=1),x<<=1,this.readModule(l-2,0,l,f)&&(x|=1),x<<=1,this.readModule(l-1,0,l,f)&&(x|=1),x<<=1,this.readModule(0,f-4,l,f)&&(x|=1),x<<=1,this.readModule(0,f-3,l,f)&&(x|=1),x<<=1,this.readModule(0,f-2,l,f)&&(x|=1),x<<=1,this.readModule(0,f-1,l,f)&&(x|=1),x<<=1,this.readModule(1,f-1,l,f)&&(x|=1),x}readCorner3(l,f){let x=0;return this.readModule(l-1,0,l,f)&&(x|=1),x<<=1,this.readModule(l-1,f-1,l,f)&&(x|=1),x<<=1,this.readModule(0,f-3,l,f)&&(x|=1),x<<=1,this.readModule(0,f-2,l,f)&&(x|=1),x<<=1,this.readModule(0,f-1,l,f)&&(x|=1),x<<=1,this.readModule(1,f-3,l,f)&&(x|=1),x<<=1,this.readModule(1,f-2,l,f)&&(x|=1),x<<=1,this.readModule(1,f-1,l,f)&&(x|=1),x}readCorner4(l,f){let x=0;return this.readModule(l-3,0,l,f)&&(x|=1),x<<=1,this.readModule(l-2,0,l,f)&&(x|=1),x<<=1,this.readModule(l-1,0,l,f)&&(x|=1),x<<=1,this.readModule(0,f-2,l,f)&&(x|=1),x<<=1,this.readModule(0,f-1,l,f)&&(x|=1),x<<=1,this.readModule(1,f-1,l,f)&&(x|=1),x<<=1,this.readModule(2,f-1,l,f)&&(x|=1),x<<=1,this.readModule(3,f-1,l,f)&&(x|=1),x}extractDataRegion(l){const f=this.version.getSymbolSizeRows(),x=this.version.getSymbolSizeColumns();if(l.getHeight()!==f)throw new w("Dimension of bitMatrix must match the version size");const b=this.version.getDataRegionSizeRows(),v=this.version.getDataRegionSizeColumns(),j=f/b|0,T=x/v|0,P=j*b,H=T*v,de=new ge(H,P);for(let je=0;je<j;++je){const Ae=je*b;for(let Ge=0;Ge<T;++Ge){const ot=Ge*v;for(let ut=0;ut<b;++ut){const At=je*(b+2)+1+ut,se=Ae+ut;for(let Ee=0;Ee<v;++Ee){const Ue=Ge*(v+2)+1+Ee;if(l.get(Ue,At)){const ht=ot+Ee;de.set(ht,se)}}}}}return de}}class Sa{constructor(l,f){this.numDataCodewords=l,this.codewords=f}static getDataBlocks(l,f){const x=f.getECBlocks();let b=0;const v=x.getECBlocks();for(let ut of v)b+=ut.getCount();const j=new Array(b);let T=0;for(let ut of v)for(let At=0;At<ut.getCount();At++){const se=ut.getDataCodewords(),Ee=x.getECCodewords()+se;j[T++]=new Sa(se,new Uint8Array(Ee))}const H=j[0].codewords.length-x.getECCodewords(),de=H-1;let je=0;for(let ut=0;ut<de;ut++)for(let At=0;At<T;At++)j[At].codewords[ut]=l[je++];const Ae=f.getVersionNumber()===24,Ge=Ae?8:T;for(let ut=0;ut<Ge;ut++)j[ut].codewords[H-1]=l[je++];const ot=j[0].codewords.length;for(let ut=H;ut<ot;ut++)for(let At=0;At<T;At++){const se=Ae?(At+8)%T:At,Ee=Ae&&se>7?ut-1:ut;j[se].codewords[Ee]=l[je++]}if(je!==l.length)throw new w;return j}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}class Ps{constructor(l){this.bytes=l,this.byteOffset=0,this.bitOffset=0}getBitOffset(){return this.bitOffset}getByteOffset(){return this.byteOffset}readBits(l){if(l<1||l>32||l>this.available())throw new w(""+l);let f=0,x=this.bitOffset,b=this.byteOffset;const v=this.bytes;if(x>0){const j=8-x,T=l<j?l:j,P=j-T,H=255>>8-T<<P;f=(v[b]&H)>>P,l-=T,x+=T,x===8&&(x=0,b++)}if(l>0){for(;l>=8;)f=f<<8|v[b]&255,b++,l-=8;if(l>0){const j=8-l,T=255>>j<<j;f=f<<l|(v[b]&T)>>j,x+=l}}return this.bitOffset=x,this.byteOffset=b,f}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}var ha;(function(Ne){Ne[Ne.PAD_ENCODE=0]="PAD_ENCODE",Ne[Ne.ASCII_ENCODE=1]="ASCII_ENCODE",Ne[Ne.C40_ENCODE=2]="C40_ENCODE",Ne[Ne.TEXT_ENCODE=3]="TEXT_ENCODE",Ne[Ne.ANSIX12_ENCODE=4]="ANSIX12_ENCODE",Ne[Ne.EDIFACT_ENCODE=5]="EDIFACT_ENCODE",Ne[Ne.BASE256_ENCODE=6]="BASE256_ENCODE"})(ha||(ha={}));class _s{static decode(l){const f=new Ps(l),x=new ke,b=new ke,v=new Array;let j=ha.ASCII_ENCODE;do if(j===ha.ASCII_ENCODE)j=this.decodeAsciiSegment(f,x,b);else{switch(j){case ha.C40_ENCODE:this.decodeC40Segment(f,x);break;case ha.TEXT_ENCODE:this.decodeTextSegment(f,x);break;case ha.ANSIX12_ENCODE:this.decodeAnsiX12Segment(f,x);break;case ha.EDIFACT_ENCODE:this.decodeEdifactSegment(f,x);break;case ha.BASE256_ENCODE:this.decodeBase256Segment(f,x,v);break;default:throw new B}j=ha.ASCII_ENCODE}while(j!==ha.PAD_ENCODE&&f.available()>0);return b.length()>0&&x.append(b.toString()),new Le(l,x.toString(),v.length===0?null:v,null)}static decodeAsciiSegment(l,f,x){let b=!1;do{let v=l.readBits(8);if(v===0)throw new B;if(v<=128)return b&&(v+=128),f.append(String.fromCharCode(v-1)),ha.ASCII_ENCODE;if(v===129)return ha.PAD_ENCODE;if(v<=229){const j=v-130;j<10&&f.append("0"),f.append(""+j)}else switch(v){case 230:return ha.C40_ENCODE;case 231:return ha.BASE256_ENCODE;case 232:f.append("");break;case 233:case 234:break;case 235:b=!0;break;case 236:f.append("[)>05"),x.insert(0,"");break;case 237:f.append("[)>06"),x.insert(0,"");break;case 238:return ha.ANSIX12_ENCODE;case 239:return ha.TEXT_ENCODE;case 240:return ha.EDIFACT_ENCODE;case 241:break;default:if(v!==254||l.available()!==0)throw new B;break}}while(l.available()>0);return ha.ASCII_ENCODE}static decodeC40Segment(l,f){let x=!1;const b=[];let v=0;do{if(l.available()===8)return;const j=l.readBits(8);if(j===254)return;this.parseTwoBytes(j,l.readBits(8),b);for(let T=0;T<3;T++){const P=b[T];switch(v){case 0:if(P<3)v=P+1;else if(P<this.C40_BASIC_SET_CHARS.length){const H=this.C40_BASIC_SET_CHARS[P];x?(f.append(String.fromCharCode(H.charCodeAt(0)+128)),x=!1):f.append(H)}else throw new B;break;case 1:x?(f.append(String.fromCharCode(P+128)),x=!1):f.append(String.fromCharCode(P)),v=0;break;case 2:if(P<this.C40_SHIFT2_SET_CHARS.length){const H=this.C40_SHIFT2_SET_CHARS[P];x?(f.append(String.fromCharCode(H.charCodeAt(0)+128)),x=!1):f.append(H)}else switch(P){case 27:f.append("");break;case 30:x=!0;break;default:throw new B}v=0;break;case 3:x?(f.append(String.fromCharCode(P+224)),x=!1):f.append(String.fromCharCode(P+96)),v=0;break;default:throw new B}}}while(l.available()>0)}static decodeTextSegment(l,f){let x=!1,b=[],v=0;do{if(l.available()===8)return;const j=l.readBits(8);if(j===254)return;this.parseTwoBytes(j,l.readBits(8),b);for(let T=0;T<3;T++){const P=b[T];switch(v){case 0:if(P<3)v=P+1;else if(P<this.TEXT_BASIC_SET_CHARS.length){const H=this.TEXT_BASIC_SET_CHARS[P];x?(f.append(String.fromCharCode(H.charCodeAt(0)+128)),x=!1):f.append(H)}else throw new B;break;case 1:x?(f.append(String.fromCharCode(P+128)),x=!1):f.append(String.fromCharCode(P)),v=0;break;case 2:if(P<this.TEXT_SHIFT2_SET_CHARS.length){const H=this.TEXT_SHIFT2_SET_CHARS[P];x?(f.append(String.fromCharCode(H.charCodeAt(0)+128)),x=!1):f.append(H)}else switch(P){case 27:f.append("");break;case 30:x=!0;break;default:throw new B}v=0;break;case 3:if(P<this.TEXT_SHIFT3_SET_CHARS.length){const H=this.TEXT_SHIFT3_SET_CHARS[P];x?(f.append(String.fromCharCode(H.charCodeAt(0)+128)),x=!1):f.append(H),v=0}else throw new B;break;default:throw new B}}}while(l.available()>0)}static decodeAnsiX12Segment(l,f){const x=[];do{if(l.available()===8)return;const b=l.readBits(8);if(b===254)return;this.parseTwoBytes(b,l.readBits(8),x);for(let v=0;v<3;v++){const j=x[v];switch(j){case 0:f.append("\r");break;case 1:f.append("*");break;case 2:f.append(">");break;case 3:f.append(" ");break;default:if(j<14)f.append(String.fromCharCode(j+44));else if(j<40)f.append(String.fromCharCode(j+51));else throw new B;break}}}while(l.available()>0)}static parseTwoBytes(l,f,x){let b=(l<<8)+f-1,v=Math.floor(b/1600);x[0]=v,b-=v*1600,v=Math.floor(b/40),x[1]=v,x[2]=b-v*40}static decodeEdifactSegment(l,f){do{if(l.available()<=16)return;for(let x=0;x<4;x++){let b=l.readBits(6);if(b===31){const v=8-l.getBitOffset();v!==8&&l.readBits(v);return}(b&32)===0&&(b|=64),f.append(String.fromCharCode(b))}}while(l.available()>0)}static decodeBase256Segment(l,f,x){let b=1+l.getByteOffset();const v=this.unrandomize255State(l.readBits(8),b++);let j;if(v===0?j=l.available()/8|0:v<250?j=v:j=250*(v-249)+this.unrandomize255State(l.readBits(8),b++),j<0)throw new B;const T=new Uint8Array(j);for(let P=0;P<j;P++){if(l.available()<8)throw new B;T[P]=this.unrandomize255State(l.readBits(8),b++)}x.push(T);try{f.append(fe.decode(T,K.ISO88591))}catch(P){throw new et("Platform does not support required encoding: "+P.message)}}static unrandomize255State(l,f){const x=149*f%255+1,b=l-x;return b>=0?b:b+256}}_s.C40_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],_s.C40_SHIFT2_SET_CHARS=["!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_"],_s.TEXT_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],_s.TEXT_SHIFT2_SET_CHARS=_s.C40_SHIFT2_SET_CHARS,_s.TEXT_SHIFT3_SET_CHARS=["`","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","{","|","}","~",""];class Wi{constructor(){this.rsDecoder=new It(rt.DATA_MATRIX_FIELD_256)}decode(l){const f=new Gr(l),x=f.getVersion(),b=f.readCodewords(),v=Sa.getDataBlocks(b,x);let j=0;for(let H of v)j+=H.getNumDataCodewords();const T=new Uint8Array(j),P=v.length;for(let H=0;H<P;H++){const de=v[H],je=de.getCodewords(),Ae=de.getNumDataCodewords();this.correctErrors(je,Ae);for(let Ge=0;Ge<Ae;Ge++)T[Ge*P+H]=je[Ge]}return _s.decode(T)}correctErrors(l,f){const x=new Int32Array(l);try{this.rsDecoder.decode(x,l.length-f)}catch(b){throw new S}for(let b=0;b<f;b++)l[b]=x[b]}}class De{constructor(l){this.image=l,this.rectangleDetector=new Dt(this.image)}detect(){const l=this.rectangleDetector.detect();let f=this.detectSolid1(l);if(f=this.detectSolid2(f),f[3]=this.correctTopRight(f),!f[3])throw new re;f=this.shiftToModuleCenter(f);const x=f[0],b=f[1],v=f[2],j=f[3];let T=this.transitionsBetween(x,j)+1,P=this.transitionsBetween(v,j)+1;(T&1)===1&&(T+=1),(P&1)===1&&(P+=1),4*T<7*P&&4*P<7*T&&(T=P=Math.max(T,P));let H=De.sampleGrid(this.image,x,b,v,j,T,P);return new Rt(H,[x,b,v,j])}static shiftPoint(l,f,x){let b=(f.getX()-l.getX())/(x+1),v=(f.getY()-l.getY())/(x+1);return new Xe(l.getX()+b,l.getY()+v)}static moveAway(l,f,x){let b=l.getX(),v=l.getY();return b<f?b-=1:b+=1,v<x?v-=1:v+=1,new Xe(b,v)}detectSolid1(l){let f=l[0],x=l[1],b=l[3],v=l[2],j=this.transitionsBetween(f,x),T=this.transitionsBetween(x,b),P=this.transitionsBetween(b,v),H=this.transitionsBetween(v,f),de=j,je=[v,f,x,b];return de>T&&(de=T,je[0]=f,je[1]=x,je[2]=b,je[3]=v),de>P&&(de=P,je[0]=x,je[1]=b,je[2]=v,je[3]=f),de>H&&(je[0]=b,je[1]=v,je[2]=f,je[3]=x),je}detectSolid2(l){let f=l[0],x=l[1],b=l[2],v=l[3],j=this.transitionsBetween(f,v),T=De.shiftPoint(x,b,(j+1)*4),P=De.shiftPoint(b,x,(j+1)*4),H=this.transitionsBetween(T,f),de=this.transitionsBetween(P,v);return H<de?(l[0]=f,l[1]=x,l[2]=b,l[3]=v):(l[0]=x,l[1]=b,l[2]=v,l[3]=f),l}correctTopRight(l){let f=l[0],x=l[1],b=l[2],v=l[3],j=this.transitionsBetween(f,v),T=this.transitionsBetween(x,v),P=De.shiftPoint(f,x,(T+1)*4),H=De.shiftPoint(b,x,(j+1)*4);j=this.transitionsBetween(P,v),T=this.transitionsBetween(H,v);let de=new Xe(v.getX()+(b.getX()-x.getX())/(j+1),v.getY()+(b.getY()-x.getY())/(j+1)),je=new Xe(v.getX()+(f.getX()-x.getX())/(T+1),v.getY()+(f.getY()-x.getY())/(T+1));if(!this.isValid(de))return this.isValid(je)?je:null;if(!this.isValid(je))return de;let Ae=this.transitionsBetween(P,de)+this.transitionsBetween(H,de),Ge=this.transitionsBetween(P,je)+this.transitionsBetween(H,je);return Ae>Ge?de:je}shiftToModuleCenter(l){let f=l[0],x=l[1],b=l[2],v=l[3],j=this.transitionsBetween(f,v)+1,T=this.transitionsBetween(b,v)+1,P=De.shiftPoint(f,x,T*4),H=De.shiftPoint(b,x,j*4);j=this.transitionsBetween(P,v)+1,T=this.transitionsBetween(H,v)+1,(j&1)===1&&(j+=1),(T&1)===1&&(T+=1);let de=(f.getX()+x.getX()+b.getX()+v.getX())/4,je=(f.getY()+x.getY()+b.getY()+v.getY())/4;f=De.moveAway(f,de,je),x=De.moveAway(x,de,je),b=De.moveAway(b,de,je),v=De.moveAway(v,de,je);let Ae,Ge;return P=De.shiftPoint(f,x,T*4),P=De.shiftPoint(P,v,j*4),Ae=De.shiftPoint(x,f,T*4),Ae=De.shiftPoint(Ae,b,j*4),H=De.shiftPoint(b,v,T*4),H=De.shiftPoint(H,x,j*4),Ge=De.shiftPoint(v,b,T*4),Ge=De.shiftPoint(Ge,f,j*4),[P,Ae,H,Ge]}isValid(l){return l.getX()>=0&&l.getX()<this.image.getWidth()&&l.getY()>0&&l.getY()<this.image.getHeight()}static sampleGrid(l,f,x,b,v,j,T){return Ot.getInstance().sampleGrid(l,j,T,.5,.5,j-.5,.5,j-.5,T-.5,.5,T-.5,f.getX(),f.getY(),v.getX(),v.getY(),b.getX(),b.getY(),x.getX(),x.getY())}transitionsBetween(l,f){let x=Math.trunc(l.getX()),b=Math.trunc(l.getY()),v=Math.trunc(f.getX()),j=Math.trunc(f.getY()),T=Math.abs(j-b)>Math.abs(v-x);if(T){let ut=x;x=b,b=ut,ut=v,v=j,j=ut}let P=Math.abs(v-x),H=Math.abs(j-b),de=-P/2,je=b<j?1:-1,Ae=x<v?1:-1,Ge=0,ot=this.image.get(T?b:x,T?x:b);for(let ut=x,At=b;ut!==v;ut+=Ae){let se=this.image.get(T?At:ut,T?ut:At);if(se!==ot&&(Ge++,ot=se),de+=H,de>0){if(At===j)break;At+=je,de-=P}}return Ge}}class wr{constructor(){this.decoder=new Wi}decode(l,f=null){let x,b;if(f!=null&&f.has(X.PURE_BARCODE)){const H=wr.extractPureBits(l.getBlackMatrix());x=this.decoder.decode(H),b=wr.NO_POINTS}else{const H=new De(l.getBlackMatrix()).detect();x=this.decoder.decode(H.getBits()),b=H.getPoints()}const v=x.getRawBytes(),j=new ae(x.getText(),v,8*v.length,b,le.DATA_MATRIX,C.currentTimeMillis()),T=x.getByteSegments();T!=null&&j.putMetadata(Z.BYTE_SEGMENTS,T);const P=x.getECLevel();return P!=null&&j.putMetadata(Z.ERROR_CORRECTION_LEVEL,P),j}reset(){}static extractPureBits(l){const f=l.getTopLeftOnBit(),x=l.getBottomRightOnBit();if(f==null||x==null)throw new re;const b=this.moduleSize(f,l);let v=f[1];const j=x[1];let T=f[0];const H=(x[0]-T+1)/b,de=(j-v+1)/b;if(H<=0||de<=0)throw new re;const je=b/2;v+=je,T+=je;const Ae=new ge(H,de);for(let Ge=0;Ge<de;Ge++){const ot=v+Ge*b;for(let ut=0;ut<H;ut++)l.get(T+ut*b,ot)&&Ae.set(ut,Ge)}return Ae}static moduleSize(l,f){const x=f.getWidth();let b=l[0];const v=l[1];for(;b<x&&f.get(b,v);)b++;if(b===x)throw new re;const j=b-l[0];if(j===0)throw new re;return j}}wr.NO_POINTS=[];class Cn extends J{constructor(l=500){super(new wr,l)}}var un;(function(Ne){Ne[Ne.L=0]="L",Ne[Ne.M=1]="M",Ne[Ne.Q=2]="Q",Ne[Ne.H=3]="H"})(un||(un={}));class Wr{constructor(l,f,x){this.value=l,this.stringValue=f,this.bits=x,Wr.FOR_BITS.set(x,this),Wr.FOR_VALUE.set(l,this)}getValue(){return this.value}getBits(){return this.bits}static fromString(l){switch(l){case"L":return Wr.L;case"M":return Wr.M;case"Q":return Wr.Q;case"H":return Wr.H;default:throw new y(l+"not available")}}toString(){return this.stringValue}equals(l){if(!(l instanceof Wr))return!1;const f=l;return this.value===f.value}static forBits(l){if(l<0||l>=Wr.FOR_BITS.size)throw new w;return Wr.FOR_BITS.get(l)}}Wr.FOR_BITS=new Map,Wr.FOR_VALUE=new Map,Wr.L=new Wr(un.L,"L",1),Wr.M=new Wr(un.M,"M",0),Wr.Q=new Wr(un.Q,"Q",3),Wr.H=new Wr(un.H,"H",2);class mt{constructor(l){this.errorCorrectionLevel=Wr.forBits(l>>3&3),this.dataMask=l&7}static numBitsDiffering(l,f){return F.bitCount(l^f)}static decodeFormatInformation(l,f){const x=mt.doDecodeFormatInformation(l,f);return x!==null?x:mt.doDecodeFormatInformation(l^mt.FORMAT_INFO_MASK_QR,f^mt.FORMAT_INFO_MASK_QR)}static doDecodeFormatInformation(l,f){let x=Number.MAX_SAFE_INTEGER,b=0;for(const v of mt.FORMAT_INFO_DECODE_LOOKUP){const j=v[0];if(j===l||j===f)return new mt(v[1]);let T=mt.numBitsDiffering(l,j);T<x&&(b=v[1],x=T),l!==f&&(T=mt.numBitsDiffering(f,j),T<x&&(b=v[1],x=T))}return x<=3?new mt(b):null}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getDataMask(){return this.dataMask}hashCode(){return this.errorCorrectionLevel.getBits()<<3|this.dataMask}equals(l){if(!(l instanceof mt))return!1;const f=l;return this.errorCorrectionLevel===f.errorCorrectionLevel&&this.dataMask===f.dataMask}}mt.FORMAT_INFO_MASK_QR=21522,mt.FORMAT_INFO_DECODE_LOOKUP=[Int32Array.from([21522,0]),Int32Array.from([20773,1]),Int32Array.from([24188,2]),Int32Array.from([23371,3]),Int32Array.from([17913,4]),Int32Array.from([16590,5]),Int32Array.from([20375,6]),Int32Array.from([19104,7]),Int32Array.from([30660,8]),Int32Array.from([29427,9]),Int32Array.from([32170,10]),Int32Array.from([30877,11]),Int32Array.from([26159,12]),Int32Array.from([25368,13]),Int32Array.from([27713,14]),Int32Array.from([26998,15]),Int32Array.from([5769,16]),Int32Array.from([5054,17]),Int32Array.from([7399,18]),Int32Array.from([6608,19]),Int32Array.from([1890,20]),Int32Array.from([597,21]),Int32Array.from([3340,22]),Int32Array.from([2107,23]),Int32Array.from([13663,24]),Int32Array.from([12392,25]),Int32Array.from([16177,26]),Int32Array.from([14854,27]),Int32Array.from([9396,28]),Int32Array.from([8579,29]),Int32Array.from([11994,30]),Int32Array.from([11245,31])];class We{constructor(l,...f){this.ecCodewordsPerBlock=l,this.ecBlocks=f}getECCodewordsPerBlock(){return this.ecCodewordsPerBlock}getNumBlocks(){let l=0;const f=this.ecBlocks;for(const x of f)l+=x.getCount();return l}getTotalECCodewords(){return this.ecCodewordsPerBlock*this.getNumBlocks()}getECBlocks(){return this.ecBlocks}}class Me{constructor(l,f){this.count=l,this.dataCodewords=f}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class Qt{constructor(l,f,...x){this.versionNumber=l,this.alignmentPatternCenters=f,this.ecBlocks=x;let b=0;const v=x[0].getECCodewordsPerBlock(),j=x[0].getECBlocks();for(const T of j)b+=T.getCount()*(T.getDataCodewords()+v);this.totalCodewords=b}getVersionNumber(){return this.versionNumber}getAlignmentPatternCenters(){return this.alignmentPatternCenters}getTotalCodewords(){return this.totalCodewords}getDimensionForVersion(){return 17+4*this.versionNumber}getECBlocksForLevel(l){return this.ecBlocks[l.getValue()]}static getProvisionalVersionForDimension(l){if(l%4!==1)throw new B;try{return this.getVersionForNumber((l-17)/4)}catch(f){throw new B}}static getVersionForNumber(l){if(l<1||l>40)throw new w;return Qt.VERSIONS[l-1]}static decodeVersionInformation(l){let f=Number.MAX_SAFE_INTEGER,x=0;for(let b=0;b<Qt.VERSION_DECODE_INFO.length;b++){const v=Qt.VERSION_DECODE_INFO[b];if(v===l)return Qt.getVersionForNumber(b+7);const j=mt.numBitsDiffering(l,v);j<f&&(x=b+7,f=j)}return f<=3?Qt.getVersionForNumber(x):null}buildFunctionPattern(){const l=this.getDimensionForVersion(),f=new ge(l);f.setRegion(0,0,9,9),f.setRegion(l-8,0,8,9),f.setRegion(0,l-8,9,8);const x=this.alignmentPatternCenters.length;for(let b=0;b<x;b++){const v=this.alignmentPatternCenters[b]-2;for(let j=0;j<x;j++)b===0&&(j===0||j===x-1)||b===x-1&&j===0||f.setRegion(this.alignmentPatternCenters[j]-2,v,5,5)}return f.setRegion(6,9,1,l-17),f.setRegion(9,6,l-17,1),this.versionNumber>6&&(f.setRegion(l-11,0,3,6),f.setRegion(0,l-11,6,3)),f}toString(){return""+this.versionNumber}}Qt.VERSION_DECODE_INFO=Int32Array.from([31892,34236,39577,42195,48118,51042,55367,58893,63784,68472,70749,76311,79154,84390,87683,92361,96236,102084,102881,110507,110734,117786,119615,126325,127568,133589,136944,141498,145311,150283,152622,158308,161089,167017]),Qt.VERSIONS=[new Qt(1,new Int32Array(0),new We(7,new Me(1,19)),new We(10,new Me(1,16)),new We(13,new Me(1,13)),new We(17,new Me(1,9))),new Qt(2,Int32Array.from([6,18]),new We(10,new Me(1,34)),new We(16,new Me(1,28)),new We(22,new Me(1,22)),new We(28,new Me(1,16))),new Qt(3,Int32Array.from([6,22]),new We(15,new Me(1,55)),new We(26,new Me(1,44)),new We(18,new Me(2,17)),new We(22,new Me(2,13))),new Qt(4,Int32Array.from([6,26]),new We(20,new Me(1,80)),new We(18,new Me(2,32)),new We(26,new Me(2,24)),new We(16,new Me(4,9))),new Qt(5,Int32Array.from([6,30]),new We(26,new Me(1,108)),new We(24,new Me(2,43)),new We(18,new Me(2,15),new Me(2,16)),new We(22,new Me(2,11),new Me(2,12))),new Qt(6,Int32Array.from([6,34]),new We(18,new Me(2,68)),new We(16,new Me(4,27)),new We(24,new Me(4,19)),new We(28,new Me(4,15))),new Qt(7,Int32Array.from([6,22,38]),new We(20,new Me(2,78)),new We(18,new Me(4,31)),new We(18,new Me(2,14),new Me(4,15)),new We(26,new Me(4,13),new Me(1,14))),new Qt(8,Int32Array.from([6,24,42]),new We(24,new Me(2,97)),new We(22,new Me(2,38),new Me(2,39)),new We(22,new Me(4,18),new Me(2,19)),new We(26,new Me(4,14),new Me(2,15))),new Qt(9,Int32Array.from([6,26,46]),new We(30,new Me(2,116)),new We(22,new Me(3,36),new Me(2,37)),new We(20,new Me(4,16),new Me(4,17)),new We(24,new Me(4,12),new Me(4,13))),new Qt(10,Int32Array.from([6,28,50]),new We(18,new Me(2,68),new Me(2,69)),new We(26,new Me(4,43),new Me(1,44)),new We(24,new Me(6,19),new Me(2,20)),new We(28,new Me(6,15),new Me(2,16))),new Qt(11,Int32Array.from([6,30,54]),new We(20,new Me(4,81)),new We(30,new Me(1,50),new Me(4,51)),new We(28,new Me(4,22),new Me(4,23)),new We(24,new Me(3,12),new Me(8,13))),new Qt(12,Int32Array.from([6,32,58]),new We(24,new Me(2,92),new Me(2,93)),new We(22,new Me(6,36),new Me(2,37)),new We(26,new Me(4,20),new Me(6,21)),new We(28,new Me(7,14),new Me(4,15))),new Qt(13,Int32Array.from([6,34,62]),new We(26,new Me(4,107)),new We(22,new Me(8,37),new Me(1,38)),new We(24,new Me(8,20),new Me(4,21)),new We(22,new Me(12,11),new Me(4,12))),new Qt(14,Int32Array.from([6,26,46,66]),new We(30,new Me(3,115),new Me(1,116)),new We(24,new Me(4,40),new Me(5,41)),new We(20,new Me(11,16),new Me(5,17)),new We(24,new Me(11,12),new Me(5,13))),new Qt(15,Int32Array.from([6,26,48,70]),new We(22,new Me(5,87),new Me(1,88)),new We(24,new Me(5,41),new Me(5,42)),new We(30,new Me(5,24),new Me(7,25)),new We(24,new Me(11,12),new Me(7,13))),new Qt(16,Int32Array.from([6,26,50,74]),new We(24,new Me(5,98),new Me(1,99)),new We(28,new Me(7,45),new Me(3,46)),new We(24,new Me(15,19),new Me(2,20)),new We(30,new Me(3,15),new Me(13,16))),new Qt(17,Int32Array.from([6,30,54,78]),new We(28,new Me(1,107),new Me(5,108)),new We(28,new Me(10,46),new Me(1,47)),new We(28,new Me(1,22),new Me(15,23)),new We(28,new Me(2,14),new Me(17,15))),new Qt(18,Int32Array.from([6,30,56,82]),new We(30,new Me(5,120),new Me(1,121)),new We(26,new Me(9,43),new Me(4,44)),new We(28,new Me(17,22),new Me(1,23)),new We(28,new Me(2,14),new Me(19,15))),new Qt(19,Int32Array.from([6,30,58,86]),new We(28,new Me(3,113),new Me(4,114)),new We(26,new Me(3,44),new Me(11,45)),new We(26,new Me(17,21),new Me(4,22)),new We(26,new Me(9,13),new Me(16,14))),new Qt(20,Int32Array.from([6,34,62,90]),new We(28,new Me(3,107),new Me(5,108)),new We(26,new Me(3,41),new Me(13,42)),new We(30,new Me(15,24),new Me(5,25)),new We(28,new Me(15,15),new Me(10,16))),new Qt(21,Int32Array.from([6,28,50,72,94]),new We(28,new Me(4,116),new Me(4,117)),new We(26,new Me(17,42)),new We(28,new Me(17,22),new Me(6,23)),new We(30,new Me(19,16),new Me(6,17))),new Qt(22,Int32Array.from([6,26,50,74,98]),new We(28,new Me(2,111),new Me(7,112)),new We(28,new Me(17,46)),new We(30,new Me(7,24),new Me(16,25)),new We(24,new Me(34,13))),new Qt(23,Int32Array.from([6,30,54,78,102]),new We(30,new Me(4,121),new Me(5,122)),new We(28,new Me(4,47),new Me(14,48)),new We(30,new Me(11,24),new Me(14,25)),new We(30,new Me(16,15),new Me(14,16))),new Qt(24,Int32Array.from([6,28,54,80,106]),new We(30,new Me(6,117),new Me(4,118)),new We(28,new Me(6,45),new Me(14,46)),new We(30,new Me(11,24),new Me(16,25)),new We(30,new Me(30,16),new Me(2,17))),new Qt(25,Int32Array.from([6,32,58,84,110]),new We(26,new Me(8,106),new Me(4,107)),new We(28,new Me(8,47),new Me(13,48)),new We(30,new Me(7,24),new Me(22,25)),new We(30,new Me(22,15),new Me(13,16))),new Qt(26,Int32Array.from([6,30,58,86,114]),new We(28,new Me(10,114),new Me(2,115)),new We(28,new Me(19,46),new Me(4,47)),new We(28,new Me(28,22),new Me(6,23)),new We(30,new Me(33,16),new Me(4,17))),new Qt(27,Int32Array.from([6,34,62,90,118]),new We(30,new Me(8,122),new Me(4,123)),new We(28,new Me(22,45),new Me(3,46)),new We(30,new Me(8,23),new Me(26,24)),new We(30,new Me(12,15),new Me(28,16))),new Qt(28,Int32Array.from([6,26,50,74,98,122]),new We(30,new Me(3,117),new Me(10,118)),new We(28,new Me(3,45),new Me(23,46)),new We(30,new Me(4,24),new Me(31,25)),new We(30,new Me(11,15),new Me(31,16))),new Qt(29,Int32Array.from([6,30,54,78,102,126]),new We(30,new Me(7,116),new Me(7,117)),new We(28,new Me(21,45),new Me(7,46)),new We(30,new Me(1,23),new Me(37,24)),new We(30,new Me(19,15),new Me(26,16))),new Qt(30,Int32Array.from([6,26,52,78,104,130]),new We(30,new Me(5,115),new Me(10,116)),new We(28,new Me(19,47),new Me(10,48)),new We(30,new Me(15,24),new Me(25,25)),new We(30,new Me(23,15),new Me(25,16))),new Qt(31,Int32Array.from([6,30,56,82,108,134]),new We(30,new Me(13,115),new Me(3,116)),new We(28,new Me(2,46),new Me(29,47)),new We(30,new Me(42,24),new Me(1,25)),new We(30,new Me(23,15),new Me(28,16))),new Qt(32,Int32Array.from([6,34,60,86,112,138]),new We(30,new Me(17,115)),new We(28,new Me(10,46),new Me(23,47)),new We(30,new Me(10,24),new Me(35,25)),new We(30,new Me(19,15),new Me(35,16))),new Qt(33,Int32Array.from([6,30,58,86,114,142]),new We(30,new Me(17,115),new Me(1,116)),new We(28,new Me(14,46),new Me(21,47)),new We(30,new Me(29,24),new Me(19,25)),new We(30,new Me(11,15),new Me(46,16))),new Qt(34,Int32Array.from([6,34,62,90,118,146]),new We(30,new Me(13,115),new Me(6,116)),new We(28,new Me(14,46),new Me(23,47)),new We(30,new Me(44,24),new Me(7,25)),new We(30,new Me(59,16),new Me(1,17))),new Qt(35,Int32Array.from([6,30,54,78,102,126,150]),new We(30,new Me(12,121),new Me(7,122)),new We(28,new Me(12,47),new Me(26,48)),new We(30,new Me(39,24),new Me(14,25)),new We(30,new Me(22,15),new Me(41,16))),new Qt(36,Int32Array.from([6,24,50,76,102,128,154]),new We(30,new Me(6,121),new Me(14,122)),new We(28,new Me(6,47),new Me(34,48)),new We(30,new Me(46,24),new Me(10,25)),new We(30,new Me(2,15),new Me(64,16))),new Qt(37,Int32Array.from([6,28,54,80,106,132,158]),new We(30,new Me(17,122),new Me(4,123)),new We(28,new Me(29,46),new Me(14,47)),new We(30,new Me(49,24),new Me(10,25)),new We(30,new Me(24,15),new Me(46,16))),new Qt(38,Int32Array.from([6,32,58,84,110,136,162]),new We(30,new Me(4,122),new Me(18,123)),new We(28,new Me(13,46),new Me(32,47)),new We(30,new Me(48,24),new Me(14,25)),new We(30,new Me(42,15),new Me(32,16))),new Qt(39,Int32Array.from([6,26,54,82,110,138,166]),new We(30,new Me(20,117),new Me(4,118)),new We(28,new Me(40,47),new Me(7,48)),new We(30,new Me(43,24),new Me(22,25)),new We(30,new Me(10,15),new Me(67,16))),new Qt(40,Int32Array.from([6,30,58,86,114,142,170]),new We(30,new Me(19,118),new Me(6,119)),new We(28,new Me(18,47),new Me(31,48)),new We(30,new Me(34,24),new Me(34,25)),new We(30,new Me(20,15),new Me(61,16)))];var Pr;(function(Ne){Ne[Ne.DATA_MASK_000=0]="DATA_MASK_000",Ne[Ne.DATA_MASK_001=1]="DATA_MASK_001",Ne[Ne.DATA_MASK_010=2]="DATA_MASK_010",Ne[Ne.DATA_MASK_011=3]="DATA_MASK_011",Ne[Ne.DATA_MASK_100=4]="DATA_MASK_100",Ne[Ne.DATA_MASK_101=5]="DATA_MASK_101",Ne[Ne.DATA_MASK_110=6]="DATA_MASK_110",Ne[Ne.DATA_MASK_111=7]="DATA_MASK_111"})(Pr||(Pr={}));class Oa{constructor(l,f){this.value=l,this.isMasked=f}unmaskBitMatrix(l,f){for(let x=0;x<f;x++)for(let b=0;b<f;b++)this.isMasked(x,b)&&l.flip(b,x)}}Oa.values=new Map([[Pr.DATA_MASK_000,new Oa(Pr.DATA_MASK_000,(Ne,l)=>(Ne+l&1)===0)],[Pr.DATA_MASK_001,new Oa(Pr.DATA_MASK_001,(Ne,l)=>(Ne&1)===0)],[Pr.DATA_MASK_010,new Oa(Pr.DATA_MASK_010,(Ne,l)=>l%3===0)],[Pr.DATA_MASK_011,new Oa(Pr.DATA_MASK_011,(Ne,l)=>(Ne+l)%3===0)],[Pr.DATA_MASK_100,new Oa(Pr.DATA_MASK_100,(Ne,l)=>(Math.floor(Ne/2)+Math.floor(l/3)&1)===0)],[Pr.DATA_MASK_101,new Oa(Pr.DATA_MASK_101,(Ne,l)=>Ne*l%6===0)],[Pr.DATA_MASK_110,new Oa(Pr.DATA_MASK_110,(Ne,l)=>Ne*l%6<3)],[Pr.DATA_MASK_111,new Oa(Pr.DATA_MASK_111,(Ne,l)=>(Ne+l+Ne*l%3&1)===0)]]);class Va{constructor(l){const f=l.getHeight();if(f<21||(f&3)!==1)throw new B;this.bitMatrix=l}readFormatInformation(){if(this.parsedFormatInfo!==null&&this.parsedFormatInfo!==void 0)return this.parsedFormatInfo;let l=0;for(let v=0;v<6;v++)l=this.copyBit(v,8,l);l=this.copyBit(7,8,l),l=this.copyBit(8,8,l),l=this.copyBit(8,7,l);for(let v=5;v>=0;v--)l=this.copyBit(8,v,l);const f=this.bitMatrix.getHeight();let x=0;const b=f-7;for(let v=f-1;v>=b;v--)x=this.copyBit(8,v,x);for(let v=f-8;v<f;v++)x=this.copyBit(v,8,x);if(this.parsedFormatInfo=mt.decodeFormatInformation(l,x),this.parsedFormatInfo!==null)return this.parsedFormatInfo;throw new B}readVersion(){if(this.parsedVersion!==null&&this.parsedVersion!==void 0)return this.parsedVersion;const l=this.bitMatrix.getHeight(),f=Math.floor((l-17)/4);if(f<=6)return Qt.getVersionForNumber(f);let x=0;const b=l-11;for(let j=5;j>=0;j--)for(let T=l-9;T>=b;T--)x=this.copyBit(T,j,x);let v=Qt.decodeVersionInformation(x);if(v!==null&&v.getDimensionForVersion()===l)return this.parsedVersion=v,v;x=0;for(let j=5;j>=0;j--)for(let T=l-9;T>=b;T--)x=this.copyBit(j,T,x);if(v=Qt.decodeVersionInformation(x),v!==null&&v.getDimensionForVersion()===l)return this.parsedVersion=v,v;throw new B}copyBit(l,f,x){return(this.isMirror?this.bitMatrix.get(f,l):this.bitMatrix.get(l,f))?x<<1|1:x<<1}readCodewords(){const l=this.readFormatInformation(),f=this.readVersion(),x=Oa.values.get(l.getDataMask()),b=this.bitMatrix.getHeight();x.unmaskBitMatrix(this.bitMatrix,b);const v=f.buildFunctionPattern();let j=!0;const T=new Uint8Array(f.getTotalCodewords());let P=0,H=0,de=0;for(let je=b-1;je>0;je-=2){je===6&&je--;for(let Ae=0;Ae<b;Ae++){const Ge=j?b-1-Ae:Ae;for(let ot=0;ot<2;ot++)v.get(je-ot,Ge)||(de++,H<<=1,this.bitMatrix.get(je-ot,Ge)&&(H|=1),de===8&&(T[P++]=H,de=0,H=0))}j=!j}if(P!==f.getTotalCodewords())throw new B;return T}remask(){if(this.parsedFormatInfo===null)return;const l=Oa.values[this.parsedFormatInfo.getDataMask()],f=this.bitMatrix.getHeight();l.unmaskBitMatrix(this.bitMatrix,f)}setMirror(l){this.parsedVersion=null,this.parsedFormatInfo=null,this.isMirror=l}mirror(){const l=this.bitMatrix;for(let f=0,x=l.getWidth();f<x;f++)for(let b=f+1,v=l.getHeight();b<v;b++)l.get(f,b)!==l.get(b,f)&&(l.flip(b,f),l.flip(f,b))}}class fn{constructor(l,f){this.numDataCodewords=l,this.codewords=f}static getDataBlocks(l,f,x){if(l.length!==f.getTotalCodewords())throw new w;const b=f.getECBlocksForLevel(x);let v=0;const j=b.getECBlocks();for(const ot of j)v+=ot.getCount();const T=new Array(v);let P=0;for(const ot of j)for(let ut=0;ut<ot.getCount();ut++){const At=ot.getDataCodewords(),se=b.getECCodewordsPerBlock()+At;T[P++]=new fn(At,new Uint8Array(se))}const H=T[0].codewords.length;let de=T.length-1;for(;de>=0&&T[de].codewords.length!==H;)de--;de++;const je=H-b.getECCodewordsPerBlock();let Ae=0;for(let ot=0;ot<je;ot++)for(let ut=0;ut<P;ut++)T[ut].codewords[ot]=l[Ae++];for(let ot=de;ot<P;ot++)T[ot].codewords[je]=l[Ae++];const Ge=T[0].codewords.length;for(let ot=je;ot<Ge;ot++)for(let ut=0;ut<P;ut++){const At=ut<de?ot:ot+1;T[ut].codewords[At]=l[Ae++]}return T}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}var Ea;(function(Ne){Ne[Ne.TERMINATOR=0]="TERMINATOR",Ne[Ne.NUMERIC=1]="NUMERIC",Ne[Ne.ALPHANUMERIC=2]="ALPHANUMERIC",Ne[Ne.STRUCTURED_APPEND=3]="STRUCTURED_APPEND",Ne[Ne.BYTE=4]="BYTE",Ne[Ne.ECI=5]="ECI",Ne[Ne.KANJI=6]="KANJI",Ne[Ne.FNC1_FIRST_POSITION=7]="FNC1_FIRST_POSITION",Ne[Ne.FNC1_SECOND_POSITION=8]="FNC1_SECOND_POSITION",Ne[Ne.HANZI=9]="HANZI"})(Ea||(Ea={}));class xr{constructor(l,f,x,b){this.value=l,this.stringValue=f,this.characterCountBitsForVersions=x,this.bits=b,xr.FOR_BITS.set(b,this),xr.FOR_VALUE.set(l,this)}static forBits(l){const f=xr.FOR_BITS.get(l);if(f===void 0)throw new w;return f}getCharacterCountBits(l){const f=l.getVersionNumber();let x;return f<=9?x=0:f<=26?x=1:x=2,this.characterCountBitsForVersions[x]}getValue(){return this.value}getBits(){return this.bits}equals(l){if(!(l instanceof xr))return!1;const f=l;return this.value===f.value}toString(){return this.stringValue}}xr.FOR_BITS=new Map,xr.FOR_VALUE=new Map,xr.TERMINATOR=new xr(Ea.TERMINATOR,"TERMINATOR",Int32Array.from([0,0,0]),0),xr.NUMERIC=new xr(Ea.NUMERIC,"NUMERIC",Int32Array.from([10,12,14]),1),xr.ALPHANUMERIC=new xr(Ea.ALPHANUMERIC,"ALPHANUMERIC",Int32Array.from([9,11,13]),2),xr.STRUCTURED_APPEND=new xr(Ea.STRUCTURED_APPEND,"STRUCTURED_APPEND",Int32Array.from([0,0,0]),3),xr.BYTE=new xr(Ea.BYTE,"BYTE",Int32Array.from([8,16,16]),4),xr.ECI=new xr(Ea.ECI,"ECI",Int32Array.from([0,0,0]),7),xr.KANJI=new xr(Ea.KANJI,"KANJI",Int32Array.from([8,10,12]),8),xr.FNC1_FIRST_POSITION=new xr(Ea.FNC1_FIRST_POSITION,"FNC1_FIRST_POSITION",Int32Array.from([0,0,0]),5),xr.FNC1_SECOND_POSITION=new xr(Ea.FNC1_SECOND_POSITION,"FNC1_SECOND_POSITION",Int32Array.from([0,0,0]),9),xr.HANZI=new xr(Ea.HANZI,"HANZI",Int32Array.from([8,10,12]),13);class ua{static decode(l,f,x,b){const v=new Ps(l);let j=new ke;const T=new Array;let P=-1,H=-1;try{let de=null,je=!1,Ae;do{if(v.available()<4)Ae=xr.TERMINATOR;else{const Ge=v.readBits(4);Ae=xr.forBits(Ge)}switch(Ae){case xr.TERMINATOR:break;case xr.FNC1_FIRST_POSITION:case xr.FNC1_SECOND_POSITION:je=!0;break;case xr.STRUCTURED_APPEND:if(v.available()<16)throw new B;P=v.readBits(8),H=v.readBits(8);break;case xr.ECI:const Ge=ua.parseECIValue(v);if(de=G.getCharacterSetECIByValue(Ge),de===null)throw new B;break;case xr.HANZI:const ot=v.readBits(4),ut=v.readBits(Ae.getCharacterCountBits(f));ot===ua.GB2312_SUBSET&&ua.decodeHanziSegment(v,j,ut);break;default:const At=v.readBits(Ae.getCharacterCountBits(f));switch(Ae){case xr.NUMERIC:ua.decodeNumericSegment(v,j,At);break;case xr.ALPHANUMERIC:ua.decodeAlphanumericSegment(v,j,At,je);break;case xr.BYTE:ua.decodeByteSegment(v,j,At,de,T,b);break;case xr.KANJI:ua.decodeKanjiSegment(v,j,At);break;default:throw new B}break}}while(Ae!==xr.TERMINATOR)}catch(de){throw new B}return new Le(l,j.toString(),T.length===0?null:T,x===null?null:x.toString(),P,H)}static decodeHanziSegment(l,f,x){if(x*13>l.available())throw new B;const b=new Uint8Array(2*x);let v=0;for(;x>0;){const j=l.readBits(13);let T=j/96<<8&4294967295|j%96;T<959?T+=41377:T+=42657,b[v]=T>>8&255,b[v+1]=T&255,v+=2,x--}try{f.append(fe.decode(b,K.GB2312))}catch(j){throw new B(j)}}static decodeKanjiSegment(l,f,x){if(x*13>l.available())throw new B;const b=new Uint8Array(2*x);let v=0;for(;x>0;){const j=l.readBits(13);let T=j/192<<8&4294967295|j%192;T<7936?T+=33088:T+=49472,b[v]=T>>8,b[v+1]=T,v+=2,x--}try{f.append(fe.decode(b,K.SHIFT_JIS))}catch(j){throw new B(j)}}static decodeByteSegment(l,f,x,b,v,j){if(8*x>l.available())throw new B;const T=new Uint8Array(x);for(let H=0;H<x;H++)T[H]=l.readBits(8);let P;b===null?P=K.guessEncoding(T,j):P=b.getName();try{f.append(fe.decode(T,P))}catch(H){throw new B(H)}v.push(T)}static toAlphaNumericChar(l){if(l>=ua.ALPHANUMERIC_CHARS.length)throw new B;return ua.ALPHANUMERIC_CHARS[l]}static decodeAlphanumericSegment(l,f,x,b){const v=f.length();for(;x>1;){if(l.available()<11)throw new B;const j=l.readBits(11);f.append(ua.toAlphaNumericChar(Math.floor(j/45))),f.append(ua.toAlphaNumericChar(j%45)),x-=2}if(x===1){if(l.available()<6)throw new B;f.append(ua.toAlphaNumericChar(l.readBits(6)))}if(b)for(let j=v;j<f.length();j++)f.charAt(j)==="%"&&(j<f.length()-1&&f.charAt(j+1)==="%"?f.deleteCharAt(j+1):f.setCharAt(j,""))}static decodeNumericSegment(l,f,x){for(;x>=3;){if(l.available()<10)throw new B;const b=l.readBits(10);if(b>=1e3)throw new B;f.append(ua.toAlphaNumericChar(Math.floor(b/100))),f.append(ua.toAlphaNumericChar(Math.floor(b/10)%10)),f.append(ua.toAlphaNumericChar(b%10)),x-=3}if(x===2){if(l.available()<7)throw new B;const b=l.readBits(7);if(b>=100)throw new B;f.append(ua.toAlphaNumericChar(Math.floor(b/10))),f.append(ua.toAlphaNumericChar(b%10))}else if(x===1){if(l.available()<4)throw new B;const b=l.readBits(4);if(b>=10)throw new B;f.append(ua.toAlphaNumericChar(b))}}static parseECIValue(l){const f=l.readBits(8);if((f&128)===0)return f&127;if((f&192)===128){const x=l.readBits(8);return(f&63)<<8&4294967295|x}if((f&224)===192){const x=l.readBits(16);return(f&31)<<16&4294967295|x}throw new B}}ua.ALPHANUMERIC_CHARS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",ua.GB2312_SUBSET=1;class Jn{constructor(l){this.mirrored=l}isMirrored(){return this.mirrored}applyMirroredCorrection(l){if(!this.mirrored||l===null||l.length<3)return;const f=l[0];l[0]=l[2],l[2]=f}}class mi{constructor(){this.rsDecoder=new It(rt.QR_CODE_FIELD_256)}decodeBooleanArray(l,f){return this.decodeBitMatrix(ge.parseFromBooleanArray(l),f)}decodeBitMatrix(l,f){const x=new Va(l);let b=null;try{return this.decodeBitMatrixParser(x,f)}catch(v){b=v}try{x.remask(),x.setMirror(!0),x.readVersion(),x.readFormatInformation(),x.mirror();const v=this.decodeBitMatrixParser(x,f);return v.setOther(new Jn(!0)),v}catch(v){throw b!==null?b:v}}decodeBitMatrixParser(l,f){const x=l.readVersion(),b=l.readFormatInformation().getErrorCorrectionLevel(),v=l.readCodewords(),j=fn.getDataBlocks(v,x,b);let T=0;for(const de of j)T+=de.getNumDataCodewords();const P=new Uint8Array(T);let H=0;for(const de of j){const je=de.getCodewords(),Ae=de.getNumDataCodewords();this.correctErrors(je,Ae);for(let Ge=0;Ge<Ae;Ge++)P[H++]=je[Ge]}return ua.decode(P,x,b,f)}correctErrors(l,f){const x=new Int32Array(l);try{this.rsDecoder.decode(x,l.length-f)}catch(b){throw new S}for(let b=0;b<f;b++)l[b]=x[b]}}class hn extends Xe{constructor(l,f,x){super(l,f),this.estimatedModuleSize=x}aboutEquals(l,f,x){if(Math.abs(f-this.getY())<=l&&Math.abs(x-this.getX())<=l){const b=Math.abs(l-this.estimatedModuleSize);return b<=1||b<=this.estimatedModuleSize}return!1}combineEstimate(l,f,x){const b=(this.getX()+f)/2,v=(this.getY()+l)/2,j=(this.estimatedModuleSize+x)/2;return new hn(b,v,j)}}class Ts{constructor(l,f,x,b,v,j,T){this.image=l,this.startX=f,this.startY=x,this.width=b,this.height=v,this.moduleSize=j,this.resultPointCallback=T,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(3)}find(){const l=this.startX,f=this.height,x=this.width,b=l+x,v=this.startY+f/2,j=new Int32Array(3),T=this.image;for(let P=0;P<f;P++){const H=v+((P&1)===0?Math.floor((P+1)/2):-Math.floor((P+1)/2));j[0]=0,j[1]=0,j[2]=0;let de=l;for(;de<b&&!T.get(de,H);)de++;let je=0;for(;de<b;){if(T.get(de,H))if(je===1)j[1]++;else if(je===2){if(this.foundPatternCross(j)){const Ae=this.handlePossibleCenter(j,H,de);if(Ae!==null)return Ae}j[0]=j[2],j[1]=1,j[2]=0,je=1}else j[++je]++;else je===1&&je++,j[je]++;de++}if(this.foundPatternCross(j)){const Ae=this.handlePossibleCenter(j,H,b);if(Ae!==null)return Ae}}if(this.possibleCenters.length!==0)return this.possibleCenters[0];throw new re}static centerFromEnd(l,f){return f-l[2]-l[1]/2}foundPatternCross(l){const f=this.moduleSize,x=f/2;for(let b=0;b<3;b++)if(Math.abs(f-l[b])>=x)return!1;return!0}crossCheckVertical(l,f,x,b){const v=this.image,j=v.getHeight(),T=this.crossCheckStateCount;T[0]=0,T[1]=0,T[2]=0;let P=l;for(;P>=0&&v.get(f,P)&&T[1]<=x;)T[1]++,P--;if(P<0||T[1]>x)return NaN;for(;P>=0&&!v.get(f,P)&&T[0]<=x;)T[0]++,P--;if(T[0]>x)return NaN;for(P=l+1;P<j&&v.get(f,P)&&T[1]<=x;)T[1]++,P++;if(P===j||T[1]>x)return NaN;for(;P<j&&!v.get(f,P)&&T[2]<=x;)T[2]++,P++;if(T[2]>x)return NaN;const H=T[0]+T[1]+T[2];return 5*Math.abs(H-b)>=2*b?NaN:this.foundPatternCross(T)?Ts.centerFromEnd(T,P):NaN}handlePossibleCenter(l,f,x){const b=l[0]+l[1]+l[2],v=Ts.centerFromEnd(l,x),j=this.crossCheckVertical(f,v,2*l[1],b);if(!isNaN(j)){const T=(l[0]+l[1]+l[2])/3;for(const H of this.possibleCenters)if(H.aboutEquals(T,j,v))return H.combineEstimate(j,v,T);const P=new hn(v,j,T);this.possibleCenters.push(P),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(P)}return null}}class Ai extends Xe{constructor(l,f,x,b){super(l,f),this.estimatedModuleSize=x,this.count=b,b===void 0&&(this.count=1)}getEstimatedModuleSize(){return this.estimatedModuleSize}getCount(){return this.count}aboutEquals(l,f,x){if(Math.abs(f-this.getY())<=l&&Math.abs(x-this.getX())<=l){const b=Math.abs(l-this.estimatedModuleSize);return b<=1||b<=this.estimatedModuleSize}return!1}combineEstimate(l,f,x){const b=this.count+1,v=(this.count*this.getX()+f)/b,j=(this.count*this.getY()+l)/b,T=(this.count*this.estimatedModuleSize+x)/b;return new Ai(v,j,T,b)}}class Hi{constructor(l){this.bottomLeft=l[0],this.topLeft=l[1],this.topRight=l[2]}getBottomLeft(){return this.bottomLeft}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}}class it{constructor(l,f){this.image=l,this.resultPointCallback=f,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(5),this.resultPointCallback=f}getImage(){return this.image}getPossibleCenters(){return this.possibleCenters}find(l){const f=l!=null&&l.get(X.TRY_HARDER)!==void 0,x=l!=null&&l.get(X.PURE_BARCODE)!==void 0,b=this.image,v=b.getHeight(),j=b.getWidth();let T=Math.floor(3*v/(4*it.MAX_MODULES));(T<it.MIN_SKIP||f)&&(T=it.MIN_SKIP);let P=!1;const H=new Int32Array(5);for(let je=T-1;je<v&&!P;je+=T){H[0]=0,H[1]=0,H[2]=0,H[3]=0,H[4]=0;let Ae=0;for(let Ge=0;Ge<j;Ge++)if(b.get(Ge,je))(Ae&1)===1&&Ae++,H[Ae]++;else if((Ae&1)===0)if(Ae===4)if(it.foundPatternCross(H)){if(this.handlePossibleCenter(H,je,Ge,x)===!0)if(T=2,this.hasSkipped===!0)P=this.haveMultiplyConfirmedCenters();else{const ut=this.findRowSkip();ut>H[2]&&(je+=ut-H[2]-T,Ge=j-1)}else{H[0]=H[2],H[1]=H[3],H[2]=H[4],H[3]=1,H[4]=0,Ae=3;continue}Ae=0,H[0]=0,H[1]=0,H[2]=0,H[3]=0,H[4]=0}else H[0]=H[2],H[1]=H[3],H[2]=H[4],H[3]=1,H[4]=0,Ae=3;else H[++Ae]++;else H[Ae]++;it.foundPatternCross(H)&&this.handlePossibleCenter(H,je,j,x)===!0&&(T=H[0],this.hasSkipped&&(P=this.haveMultiplyConfirmedCenters()))}const de=this.selectBestPatterns();return Xe.orderBestPatterns(de),new Hi(de)}static centerFromEnd(l,f){return f-l[4]-l[3]-l[2]/2}static foundPatternCross(l){let f=0;for(let v=0;v<5;v++){const j=l[v];if(j===0)return!1;f+=j}if(f<7)return!1;const x=f/7,b=x/2;return Math.abs(x-l[0])<b&&Math.abs(x-l[1])<b&&Math.abs(3*x-l[2])<3*b&&Math.abs(x-l[3])<b&&Math.abs(x-l[4])<b}getCrossCheckStateCount(){const l=this.crossCheckStateCount;return l[0]=0,l[1]=0,l[2]=0,l[3]=0,l[4]=0,l}crossCheckDiagonal(l,f,x,b){const v=this.getCrossCheckStateCount();let j=0;const T=this.image;for(;l>=j&&f>=j&&T.get(f-j,l-j);)v[2]++,j++;if(l<j||f<j)return!1;for(;l>=j&&f>=j&&!T.get(f-j,l-j)&&v[1]<=x;)v[1]++,j++;if(l<j||f<j||v[1]>x)return!1;for(;l>=j&&f>=j&&T.get(f-j,l-j)&&v[0]<=x;)v[0]++,j++;if(v[0]>x)return!1;const P=T.getHeight(),H=T.getWidth();for(j=1;l+j<P&&f+j<H&&T.get(f+j,l+j);)v[2]++,j++;if(l+j>=P||f+j>=H)return!1;for(;l+j<P&&f+j<H&&!T.get(f+j,l+j)&&v[3]<x;)v[3]++,j++;if(l+j>=P||f+j>=H||v[3]>=x)return!1;for(;l+j<P&&f+j<H&&T.get(f+j,l+j)&&v[4]<x;)v[4]++,j++;if(v[4]>=x)return!1;const de=v[0]+v[1]+v[2]+v[3]+v[4];return Math.abs(de-b)<2*b&&it.foundPatternCross(v)}crossCheckVertical(l,f,x,b){const v=this.image,j=v.getHeight(),T=this.getCrossCheckStateCount();let P=l;for(;P>=0&&v.get(f,P);)T[2]++,P--;if(P<0)return NaN;for(;P>=0&&!v.get(f,P)&&T[1]<=x;)T[1]++,P--;if(P<0||T[1]>x)return NaN;for(;P>=0&&v.get(f,P)&&T[0]<=x;)T[0]++,P--;if(T[0]>x)return NaN;for(P=l+1;P<j&&v.get(f,P);)T[2]++,P++;if(P===j)return NaN;for(;P<j&&!v.get(f,P)&&T[3]<x;)T[3]++,P++;if(P===j||T[3]>=x)return NaN;for(;P<j&&v.get(f,P)&&T[4]<x;)T[4]++,P++;if(T[4]>=x)return NaN;const H=T[0]+T[1]+T[2]+T[3]+T[4];return 5*Math.abs(H-b)>=2*b?NaN:it.foundPatternCross(T)?it.centerFromEnd(T,P):NaN}crossCheckHorizontal(l,f,x,b){const v=this.image,j=v.getWidth(),T=this.getCrossCheckStateCount();let P=l;for(;P>=0&&v.get(P,f);)T[2]++,P--;if(P<0)return NaN;for(;P>=0&&!v.get(P,f)&&T[1]<=x;)T[1]++,P--;if(P<0||T[1]>x)return NaN;for(;P>=0&&v.get(P,f)&&T[0]<=x;)T[0]++,P--;if(T[0]>x)return NaN;for(P=l+1;P<j&&v.get(P,f);)T[2]++,P++;if(P===j)return NaN;for(;P<j&&!v.get(P,f)&&T[3]<x;)T[3]++,P++;if(P===j||T[3]>=x)return NaN;for(;P<j&&v.get(P,f)&&T[4]<x;)T[4]++,P++;if(T[4]>=x)return NaN;const H=T[0]+T[1]+T[2]+T[3]+T[4];return 5*Math.abs(H-b)>=b?NaN:it.foundPatternCross(T)?it.centerFromEnd(T,P):NaN}handlePossibleCenter(l,f,x,b){const v=l[0]+l[1]+l[2]+l[3]+l[4];let j=it.centerFromEnd(l,x),T=this.crossCheckVertical(f,Math.floor(j),l[2],v);if(!isNaN(T)&&(j=this.crossCheckHorizontal(Math.floor(j),Math.floor(T),l[2],v),!isNaN(j)&&(!b||this.crossCheckDiagonal(Math.floor(T),Math.floor(j),l[2],v)))){const P=v/7;let H=!1;const de=this.possibleCenters;for(let je=0,Ae=de.length;je<Ae;je++){const Ge=de[je];if(Ge.aboutEquals(P,T,j)){de[je]=Ge.combineEstimate(T,j,P),H=!0;break}}if(!H){const je=new Ai(j,T,P);de.push(je),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(je)}return!0}return!1}findRowSkip(){if(this.possibleCenters.length<=1)return 0;let f=null;for(const x of this.possibleCenters)if(x.getCount()>=it.CENTER_QUORUM)if(f==null)f=x;else return this.hasSkipped=!0,Math.floor((Math.abs(f.getX()-x.getX())-Math.abs(f.getY()-x.getY()))/2);return 0}haveMultiplyConfirmedCenters(){let l=0,f=0;const x=this.possibleCenters.length;for(const j of this.possibleCenters)j.getCount()>=it.CENTER_QUORUM&&(l++,f+=j.getEstimatedModuleSize());if(l<3)return!1;const b=f/x;let v=0;for(const j of this.possibleCenters)v+=Math.abs(j.getEstimatedModuleSize()-b);return v<=.05*f}selectBestPatterns(){const l=this.possibleCenters.length;if(l<3)throw new re;const f=this.possibleCenters;let x;if(l>3){let b=0,v=0;for(const P of this.possibleCenters){const H=P.getEstimatedModuleSize();b+=H,v+=H*H}x=b/l;let j=Math.sqrt(v/l-x*x);f.sort((P,H)=>{const de=Math.abs(H.getEstimatedModuleSize()-x),je=Math.abs(P.getEstimatedModuleSize()-x);return de<je?-1:de>je?1:0});const T=Math.max(.2*x,j);for(let P=0;P<f.length&&f.length>3;P++){const H=f[P];Math.abs(H.getEstimatedModuleSize()-x)>T&&(f.splice(P,1),P--)}}if(f.length>3){let b=0;for(const v of f)b+=v.getEstimatedModuleSize();x=b/f.length,f.sort((v,j)=>{if(j.getCount()===v.getCount()){const T=Math.abs(j.getEstimatedModuleSize()-x),P=Math.abs(v.getEstimatedModuleSize()-x);return T<P?1:T>P?-1:0}else return j.getCount()-v.getCount()}),f.splice(3)}return[f[0],f[1],f[2]]}}it.CENTER_QUORUM=2,it.MIN_SKIP=3,it.MAX_MODULES=57;class bt{constructor(l){this.image=l}getImage(){return this.image}getResultPointCallback(){return this.resultPointCallback}detect(l){this.resultPointCallback=l==null?null:l.get(X.NEED_RESULT_POINT_CALLBACK);const x=new it(this.image,this.resultPointCallback).find(l);return this.processFinderPatternInfo(x)}processFinderPatternInfo(l){const f=l.getTopLeft(),x=l.getTopRight(),b=l.getBottomLeft(),v=this.calculateModuleSize(f,x,b);if(v<1)throw new re("No pattern found in proccess finder.");const j=bt.computeDimension(f,x,b,v),T=Qt.getProvisionalVersionForDimension(j),P=T.getDimensionForVersion()-7;let H=null;if(T.getAlignmentPatternCenters().length>0){const Ge=x.getX()-f.getX()+b.getX(),ot=x.getY()-f.getY()+b.getY(),ut=1-3/P,At=Math.floor(f.getX()+ut*(Ge-f.getX())),se=Math.floor(f.getY()+ut*(ot-f.getY()));for(let Ee=4;Ee<=16;Ee<<=1)try{H=this.findAlignmentInRegion(v,At,se,Ee);break}catch(Ue){if(!(Ue instanceof re))throw Ue}}const de=bt.createTransform(f,x,b,H,j),je=bt.sampleGrid(this.image,de,j);let Ae;return H===null?Ae=[b,f,x]:Ae=[b,f,x,H],new Rt(je,Ae)}static createTransform(l,f,x,b,v){const j=v-3.5;let T,P,H,de;return b!==null?(T=b.getX(),P=b.getY(),H=j-3,de=H):(T=f.getX()-l.getX()+x.getX(),P=f.getY()-l.getY()+x.getY(),H=j,de=j),yt.quadrilateralToQuadrilateral(3.5,3.5,j,3.5,H,de,3.5,j,l.getX(),l.getY(),f.getX(),f.getY(),T,P,x.getX(),x.getY())}static sampleGrid(l,f,x){return Ot.getInstance().sampleGridWithTransform(l,x,x,f)}static computeDimension(l,f,x,b){const v=Je.round(Xe.distance(l,f)/b),j=Je.round(Xe.distance(l,x)/b);let T=Math.floor((v+j)/2)+7;switch(T&3){case 0:T++;break;case 2:T--;break;case 3:throw new re("Dimensions could be not found.")}return T}calculateModuleSize(l,f,x){return(this.calculateModuleSizeOneWay(l,f)+this.calculateModuleSizeOneWay(l,x))/2}calculateModuleSizeOneWay(l,f){const x=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(l.getX()),Math.floor(l.getY()),Math.floor(f.getX()),Math.floor(f.getY())),b=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(f.getX()),Math.floor(f.getY()),Math.floor(l.getX()),Math.floor(l.getY()));return isNaN(x)?b/7:isNaN(b)?x/7:(x+b)/14}sizeOfBlackWhiteBlackRunBothWays(l,f,x,b){let v=this.sizeOfBlackWhiteBlackRun(l,f,x,b),j=1,T=l-(x-l);T<0?(j=l/(l-T),T=0):T>=this.image.getWidth()&&(j=(this.image.getWidth()-1-l)/(T-l),T=this.image.getWidth()-1);let P=Math.floor(f-(b-f)*j);return j=1,P<0?(j=f/(f-P),P=0):P>=this.image.getHeight()&&(j=(this.image.getHeight()-1-f)/(P-f),P=this.image.getHeight()-1),T=Math.floor(l+(T-l)*j),v+=this.sizeOfBlackWhiteBlackRun(l,f,T,P),v-1}sizeOfBlackWhiteBlackRun(l,f,x,b){const v=Math.abs(b-f)>Math.abs(x-l);if(v){let Ge=l;l=f,f=Ge,Ge=x,x=b,b=Ge}const j=Math.abs(x-l),T=Math.abs(b-f);let P=-j/2;const H=l<x?1:-1,de=f<b?1:-1;let je=0;const Ae=x+H;for(let Ge=l,ot=f;Ge!==Ae;Ge+=H){const ut=v?ot:Ge,At=v?Ge:ot;if(je===1===this.image.get(ut,At)){if(je===2)return Je.distance(Ge,ot,l,f);je++}if(P+=T,P>0){if(ot===b)break;ot+=de,P-=j}}return je===2?Je.distance(x+H,b,l,f):NaN}findAlignmentInRegion(l,f,x,b){const v=Math.floor(b*l),j=Math.max(0,f-v),T=Math.min(this.image.getWidth()-1,f+v);if(T-j<l*3)throw new re("Alignment top exceeds estimated module size.");const P=Math.max(0,x-v),H=Math.min(this.image.getHeight()-1,x+v);if(H-P<l*3)throw new re("Alignment bottom exceeds estimated module size.");return new Ts(this.image,j,P,T-j,H-P,l,this.resultPointCallback).find()}}class Qr{constructor(){this.decoder=new mi}getDecoder(){return this.decoder}decode(l,f){let x,b;if(f!=null&&f.get(X.PURE_BARCODE)!==void 0){const P=Qr.extractPureBits(l.getBlackMatrix());x=this.decoder.decodeBitMatrix(P,f),b=Qr.NO_POINTS}else{const P=new bt(l.getBlackMatrix()).detect(f);x=this.decoder.decodeBitMatrix(P.getBits(),f),b=P.getPoints()}x.getOther()instanceof Jn&&x.getOther().applyMirroredCorrection(b);const v=new ae(x.getText(),x.getRawBytes(),void 0,b,le.QR_CODE,void 0),j=x.getByteSegments();j!==null&&v.putMetadata(Z.BYTE_SEGMENTS,j);const T=x.getECLevel();return T!==null&&v.putMetadata(Z.ERROR_CORRECTION_LEVEL,T),x.hasStructuredAppend()&&(v.putMetadata(Z.STRUCTURED_APPEND_SEQUENCE,x.getStructuredAppendSequenceNumber()),v.putMetadata(Z.STRUCTURED_APPEND_PARITY,x.getStructuredAppendParity())),v}reset(){}static extractPureBits(l){const f=l.getTopLeftOnBit(),x=l.getBottomRightOnBit();if(f===null||x===null)throw new re;const b=this.moduleSize(f,l);let v=f[1],j=x[1],T=f[0],P=x[0];if(T>=P||v>=j)throw new re;if(j-v!==P-T&&(P=T+(j-v),P>=l.getWidth()))throw new re;const H=Math.round((P-T+1)/b),de=Math.round((j-v+1)/b);if(H<=0||de<=0)throw new re;if(de!==H)throw new re;const je=Math.floor(b/2);v+=je,T+=je;const Ae=T+Math.floor((H-1)*b)-P;if(Ae>0){if(Ae>je)throw new re;T-=Ae}const Ge=v+Math.floor((de-1)*b)-j;if(Ge>0){if(Ge>je)throw new re;v-=Ge}const ot=new ge(H,de);for(let ut=0;ut<de;ut++){const At=v+Math.floor(ut*b);for(let se=0;se<H;se++)l.get(T+Math.floor(se*b),At)&&ot.set(se,ut)}return ot}static moduleSize(l,f){const x=f.getHeight(),b=f.getWidth();let v=l[0],j=l[1],T=!0,P=0;for(;v<b&&j<x;){if(T!==f.get(v,j)){if(++P===5)break;T=!T}v++,j++}if(v===b||j===x)throw new re;return(v-l[0])/7}}Qr.NO_POINTS=new Array;class gr{PDF417Common(){}static getBitCountSum(l){return Je.sum(l)}static toIntArray(l){if(l==null||!l.length)return gr.EMPTY_INT_ARRAY;const f=new Int32Array(l.length);let x=0;for(const b of l)f[x++]=b;return f}static getCodeword(l){const f=R.binarySearch(gr.SYMBOL_TABLE,l&262143);return f<0?-1:(gr.CODEWORD_TABLE[f]-1)%gr.NUMBER_OF_CODEWORDS}}gr.NUMBER_OF_CODEWORDS=929,gr.MAX_CODEWORDS_IN_BARCODE=gr.NUMBER_OF_CODEWORDS-1,gr.MIN_ROWS_IN_BARCODE=3,gr.MAX_ROWS_IN_BARCODE=90,gr.MODULES_IN_CODEWORD=17,gr.MODULES_IN_STOP_PATTERN=18,gr.BARS_IN_MODULE=8,gr.EMPTY_INT_ARRAY=new Int32Array([]),gr.SYMBOL_TABLE=Int32Array.from([66142,66170,66206,66236,66290,66292,66350,66382,66396,66454,66470,66476,66594,66600,66614,66626,66628,66632,66640,66654,66662,66668,66682,66690,66718,66720,66748,66758,66776,66798,66802,66804,66820,66824,66832,66846,66848,66876,66880,66936,66950,66956,66968,66992,67006,67022,67036,67042,67044,67048,67062,67118,67150,67164,67214,67228,67256,67294,67322,67350,67366,67372,67398,67404,67416,67438,67474,67476,67490,67492,67496,67510,67618,67624,67650,67656,67664,67678,67686,67692,67706,67714,67716,67728,67742,67744,67772,67782,67788,67800,67822,67826,67828,67842,67848,67870,67872,67900,67904,67960,67974,67992,68016,68030,68046,68060,68066,68068,68072,68086,68104,68112,68126,68128,68156,68160,68216,68336,68358,68364,68376,68400,68414,68448,68476,68494,68508,68536,68546,68548,68552,68560,68574,68582,68588,68654,68686,68700,68706,68708,68712,68726,68750,68764,68792,68802,68804,68808,68816,68830,68838,68844,68858,68878,68892,68920,68976,68990,68994,68996,69e3,69008,69022,69024,69052,69062,69068,69080,69102,69106,69108,69142,69158,69164,69190,69208,69230,69254,69260,69272,69296,69310,69326,69340,69386,69394,69396,69410,69416,69430,69442,69444,69448,69456,69470,69478,69484,69554,69556,69666,69672,69698,69704,69712,69726,69754,69762,69764,69776,69790,69792,69820,69830,69836,69848,69870,69874,69876,69890,69918,69920,69948,69952,70008,70022,70040,70064,70078,70094,70108,70114,70116,70120,70134,70152,70174,70176,70264,70384,70412,70448,70462,70496,70524,70542,70556,70584,70594,70600,70608,70622,70630,70636,70664,70672,70686,70688,70716,70720,70776,70896,71136,71180,71192,71216,71230,71264,71292,71360,71416,71452,71480,71536,71550,71554,71556,71560,71568,71582,71584,71612,71622,71628,71640,71662,71726,71732,71758,71772,71778,71780,71784,71798,71822,71836,71864,71874,71880,71888,71902,71910,71916,71930,71950,71964,71992,72048,72062,72066,72068,72080,72094,72096,72124,72134,72140,72152,72174,72178,72180,72206,72220,72248,72304,72318,72416,72444,72456,72464,72478,72480,72508,72512,72568,72588,72600,72624,72638,72654,72668,72674,72676,72680,72694,72726,72742,72748,72774,72780,72792,72814,72838,72856,72880,72894,72910,72924,72930,72932,72936,72950,72966,72972,72984,73008,73022,73056,73084,73102,73116,73144,73156,73160,73168,73182,73190,73196,73210,73226,73234,73236,73250,73252,73256,73270,73282,73284,73296,73310,73318,73324,73346,73348,73352,73360,73374,73376,73404,73414,73420,73432,73454,73498,73518,73522,73524,73550,73564,73570,73572,73576,73590,73800,73822,73858,73860,73872,73886,73888,73916,73944,73970,73972,73992,74014,74016,74044,74048,74104,74118,74136,74160,74174,74210,74212,74216,74230,74244,74256,74270,74272,74360,74480,74502,74508,74544,74558,74592,74620,74638,74652,74680,74690,74696,74704,74726,74732,74782,74784,74812,74992,75232,75288,75326,75360,75388,75456,75512,75576,75632,75646,75650,75652,75664,75678,75680,75708,75718,75724,75736,75758,75808,75836,75840,75896,76016,76256,76736,76824,76848,76862,76896,76924,76992,77048,77296,77340,77368,77424,77438,77536,77564,77572,77576,77584,77600,77628,77632,77688,77702,77708,77720,77744,77758,77774,77788,77870,77902,77916,77922,77928,77966,77980,78008,78018,78024,78032,78046,78060,78074,78094,78136,78192,78206,78210,78212,78224,78238,78240,78268,78278,78284,78296,78322,78324,78350,78364,78448,78462,78560,78588,78600,78622,78624,78652,78656,78712,78726,78744,78768,78782,78798,78812,78818,78820,78824,78838,78862,78876,78904,78960,78974,79072,79100,79296,79352,79368,79376,79390,79392,79420,79424,79480,79600,79628,79640,79664,79678,79712,79740,79772,79800,79810,79812,79816,79824,79838,79846,79852,79894,79910,79916,79942,79948,79960,79982,79988,80006,80024,80048,80062,80078,80092,80098,80100,80104,80134,80140,80176,80190,80224,80252,80270,80284,80312,80328,80336,80350,80358,80364,80378,80390,80396,80408,80432,80446,80480,80508,80576,80632,80654,80668,80696,80752,80766,80776,80784,80798,80800,80828,80844,80856,80878,80882,80884,80914,80916,80930,80932,80936,80950,80962,80968,80976,80990,80998,81004,81026,81028,81040,81054,81056,81084,81094,81100,81112,81134,81154,81156,81160,81168,81182,81184,81212,81216,81272,81286,81292,81304,81328,81342,81358,81372,81380,81384,81398,81434,81454,81458,81460,81486,81500,81506,81508,81512,81526,81550,81564,81592,81602,81604,81608,81616,81630,81638,81644,81702,81708,81722,81734,81740,81752,81774,81778,81780,82050,82078,82080,82108,82180,82184,82192,82206,82208,82236,82240,82296,82316,82328,82352,82366,82402,82404,82408,82440,82448,82462,82464,82492,82496,82552,82672,82694,82700,82712,82736,82750,82784,82812,82830,82882,82884,82888,82896,82918,82924,82952,82960,82974,82976,83004,83008,83064,83184,83424,83468,83480,83504,83518,83552,83580,83648,83704,83740,83768,83824,83838,83842,83844,83848,83856,83872,83900,83910,83916,83928,83950,83984,84e3,84028,84032,84088,84208,84448,84928,85040,85054,85088,85116,85184,85240,85488,85560,85616,85630,85728,85756,85764,85768,85776,85790,85792,85820,85824,85880,85894,85900,85912,85936,85966,85980,86048,86080,86136,86256,86496,86976,88160,88188,88256,88312,88560,89056,89200,89214,89312,89340,89536,89592,89608,89616,89632,89664,89720,89840,89868,89880,89904,89952,89980,89998,90012,90040,90190,90204,90254,90268,90296,90306,90308,90312,90334,90382,90396,90424,90480,90494,90500,90504,90512,90526,90528,90556,90566,90572,90584,90610,90612,90638,90652,90680,90736,90750,90848,90876,90884,90888,90896,90910,90912,90940,90944,91e3,91014,91020,91032,91056,91070,91086,91100,91106,91108,91112,91126,91150,91164,91192,91248,91262,91360,91388,91584,91640,91664,91678,91680,91708,91712,91768,91888,91928,91952,91966,92e3,92028,92046,92060,92088,92098,92100,92104,92112,92126,92134,92140,92188,92216,92272,92384,92412,92608,92664,93168,93200,93214,93216,93244,93248,93304,93424,93664,93720,93744,93758,93792,93820,93888,93944,93980,94008,94064,94078,94084,94088,94096,94110,94112,94140,94150,94156,94168,94246,94252,94278,94284,94296,94318,94342,94348,94360,94384,94398,94414,94428,94440,94470,94476,94488,94512,94526,94560,94588,94606,94620,94648,94658,94660,94664,94672,94686,94694,94700,94714,94726,94732,94744,94768,94782,94816,94844,94912,94968,94990,95004,95032,95088,95102,95112,95120,95134,95136,95164,95180,95192,95214,95218,95220,95244,95256,95280,95294,95328,95356,95424,95480,95728,95758,95772,95800,95856,95870,95968,95996,96008,96016,96030,96032,96060,96064,96120,96152,96176,96190,96220,96226,96228,96232,96290,96292,96296,96310,96322,96324,96328,96336,96350,96358,96364,96386,96388,96392,96400,96414,96416,96444,96454,96460,96472,96494,96498,96500,96514,96516,96520,96528,96542,96544,96572,96576,96632,96646,96652,96664,96688,96702,96718,96732,96738,96740,96744,96758,96772,96776,96784,96798,96800,96828,96832,96888,97008,97030,97036,97048,97072,97086,97120,97148,97166,97180,97208,97220,97224,97232,97246,97254,97260,97326,97330,97332,97358,97372,97378,97380,97384,97398,97422,97436,97464,97474,97476,97480,97488,97502,97510,97516,97550,97564,97592,97648,97666,97668,97672,97680,97694,97696,97724,97734,97740,97752,97774,97830,97836,97850,97862,97868,97880,97902,97906,97908,97926,97932,97944,97968,97998,98012,98018,98020,98024,98038,98618,98674,98676,98838,98854,98874,98892,98904,98926,98930,98932,98968,99006,99042,99044,99048,99062,99166,99194,99246,99286,99350,99366,99372,99386,99398,99416,99438,99442,99444,99462,99504,99518,99534,99548,99554,99556,99560,99574,99590,99596,99608,99632,99646,99680,99708,99726,99740,99768,99778,99780,99784,99792,99806,99814,99820,99834,99858,99860,99874,99880,99894,99906,99920,99934,99962,99970,99972,99976,99984,99998,1e5,100028,100038,100044,100056,100078,100082,100084,100142,100174,100188,100246,100262,100268,100306,100308,100390,100396,100410,100422,100428,100440,100462,100466,100468,100486,100504,100528,100542,100558,100572,100578,100580,100584,100598,100620,100656,100670,100704,100732,100750,100792,100802,100808,100816,100830,100838,100844,100858,100888,100912,100926,100960,100988,101056,101112,101148,101176,101232,101246,101250,101252,101256,101264,101278,101280,101308,101318,101324,101336,101358,101362,101364,101410,101412,101416,101430,101442,101448,101456,101470,101478,101498,101506,101508,101520,101534,101536,101564,101580,101618,101620,101636,101640,101648,101662,101664,101692,101696,101752,101766,101784,101838,101858,101860,101864,101934,101938,101940,101966,101980,101986,101988,101992,102030,102044,102072,102082,102084,102088,102096,102138,102166,102182,102188,102214,102220,102232,102254,102282,102290,102292,102306,102308,102312,102326,102444,102458,102470,102476,102488,102514,102516,102534,102552,102576,102590,102606,102620,102626,102632,102646,102662,102668,102704,102718,102752,102780,102798,102812,102840,102850,102856,102864,102878,102886,102892,102906,102936,102974,103008,103036,103104,103160,103224,103280,103294,103298,103300,103312,103326,103328,103356,103366,103372,103384,103406,103410,103412,103472,103486,103520,103548,103616,103672,103920,103992,104048,104062,104160,104188,104194,104196,104200,104208,104224,104252,104256,104312,104326,104332,104344,104368,104382,104398,104412,104418,104420,104424,104482,104484,104514,104520,104528,104542,104550,104570,104578,104580,104592,104606,104608,104636,104652,104690,104692,104706,104712,104734,104736,104764,104768,104824,104838,104856,104910,104930,104932,104936,104968,104976,104990,104992,105020,105024,105080,105200,105240,105278,105312,105372,105410,105412,105416,105424,105446,105518,105524,105550,105564,105570,105572,105576,105614,105628,105656,105666,105672,105680,105702,105722,105742,105756,105784,105840,105854,105858,105860,105864,105872,105888,105932,105970,105972,106006,106022,106028,106054,106060,106072,106100,106118,106124,106136,106160,106174,106190,106210,106212,106216,106250,106258,106260,106274,106276,106280,106306,106308,106312,106320,106334,106348,106394,106414,106418,106420,106566,106572,106610,106612,106630,106636,106648,106672,106686,106722,106724,106728,106742,106758,106764,106776,106800,106814,106848,106876,106894,106908,106936,106946,106948,106952,106960,106974,106982,106988,107032,107056,107070,107104,107132,107200,107256,107292,107320,107376,107390,107394,107396,107400,107408,107422,107424,107452,107462,107468,107480,107502,107506,107508,107544,107568,107582,107616,107644,107712,107768,108016,108060,108088,108144,108158,108256,108284,108290,108292,108296,108304,108318,108320,108348,108352,108408,108422,108428,108440,108464,108478,108494,108508,108514,108516,108520,108592,108640,108668,108736,108792,109040,109536,109680,109694,109792,109820,110016,110072,110084,110088,110096,110112,110140,110144,110200,110320,110342,110348,110360,110384,110398,110432,110460,110478,110492,110520,110532,110536,110544,110558,110658,110686,110714,110722,110724,110728,110736,110750,110752,110780,110796,110834,110836,110850,110852,110856,110864,110878,110880,110908,110912,110968,110982,111e3,111054,111074,111076,111080,111108,111112,111120,111134,111136,111164,111168,111224,111344,111372,111422,111456,111516,111554,111556,111560,111568,111590,111632,111646,111648,111676,111680,111736,111856,112096,112152,112224,112252,112320,112440,112514,112516,112520,112528,112542,112544,112588,112686,112718,112732,112782,112796,112824,112834,112836,112840,112848,112870,112890,112910,112924,112952,113008,113022,113026,113028,113032,113040,113054,113056,113100,113138,113140,113166,113180,113208,113264,113278,113376,113404,113416,113424,113440,113468,113472,113560,113614,113634,113636,113640,113686,113702,113708,113734,113740,113752,113778,113780,113798,113804,113816,113840,113854,113870,113890,113892,113896,113926,113932,113944,113968,113982,114016,114044,114076,114114,114116,114120,114128,114150,114170,114194,114196,114210,114212,114216,114242,114244,114248,114256,114270,114278,114306,114308,114312,114320,114334,114336,114364,114380,114420,114458,114478,114482,114484,114510,114524,114530,114532,114536,114842,114866,114868,114970,114994,114996,115042,115044,115048,115062,115130,115226,115250,115252,115278,115292,115298,115300,115304,115318,115342,115394,115396,115400,115408,115422,115430,115436,115450,115478,115494,115514,115526,115532,115570,115572,115738,115758,115762,115764,115790,115804,115810,115812,115816,115830,115854,115868,115896,115906,115912,115920,115934,115942,115948,115962,115996,116024,116080,116094,116098,116100,116104,116112,116126,116128,116156,116166,116172,116184,116206,116210,116212,116246,116262,116268,116282,116294,116300,116312,116334,116338,116340,116358,116364,116376,116400,116414,116430,116444,116450,116452,116456,116498,116500,116514,116520,116534,116546,116548,116552,116560,116574,116582,116588,116602,116654,116694,116714,116762,116782,116786,116788,116814,116828,116834,116836,116840,116854,116878,116892,116920,116930,116936,116944,116958,116966,116972,116986,117006,117048,117104,117118,117122,117124,117136,117150,117152,117180,117190,117196,117208,117230,117234,117236,117304,117360,117374,117472,117500,117506,117508,117512,117520,117536,117564,117568,117624,117638,117644,117656,117680,117694,117710,117724,117730,117732,117736,117750,117782,117798,117804,117818,117830,117848,117874,117876,117894,117936,117950,117966,117986,117988,117992,118022,118028,118040,118064,118078,118112,118140,118172,118210,118212,118216,118224,118238,118246,118266,118306,118312,118338,118352,118366,118374,118394,118402,118404,118408,118416,118430,118432,118460,118476,118514,118516,118574,118578,118580,118606,118620,118626,118628,118632,118678,118694,118700,118730,118738,118740,118830,118834,118836,118862,118876,118882,118884,118888,118902,118926,118940,118968,118978,118980,118984,118992,119006,119014,119020,119034,119068,119096,119152,119166,119170,119172,119176,119184,119198,119200,119228,119238,119244,119256,119278,119282,119284,119324,119352,119408,119422,119520,119548,119554,119556,119560,119568,119582,119584,119612,119616,119672,119686,119692,119704,119728,119742,119758,119772,119778,119780,119784,119798,119920,119934,120032,120060,120256,120312,120324,120328,120336,120352,120384,120440,120560,120582,120588,120600,120624,120638,120672,120700,120718,120732,120760,120770,120772,120776,120784,120798,120806,120812,120870,120876,120890,120902,120908,120920,120946,120948,120966,120972,120984,121008,121022,121038,121058,121060,121064,121078,121100,121112,121136,121150,121184,121212,121244,121282,121284,121288,121296,121318,121338,121356,121368,121392,121406,121440,121468,121536,121592,121656,121730,121732,121736,121744,121758,121760,121804,121842,121844,121890,121922,121924,121928,121936,121950,121958,121978,121986,121988,121992,122e3,122014,122016,122044,122060,122098,122100,122116,122120,122128,122142,122144,122172,122176,122232,122246,122264,122318,122338,122340,122344,122414,122418,122420,122446,122460,122466,122468,122472,122510,122524,122552,122562,122564,122568,122576,122598,122618,122646,122662,122668,122694,122700,122712,122738,122740,122762,122770,122772,122786,122788,122792,123018,123026,123028,123042,123044,123048,123062,123098,123146,123154,123156,123170,123172,123176,123190,123202,123204,123208,123216,123238,123244,123258,123290,123314,123316,123402,123410,123412,123426,123428,123432,123446,123458,123464,123472,123486,123494,123500,123514,123522,123524,123528,123536,123552,123580,123590,123596,123608,123630,123634,123636,123674,123698,123700,123740,123746,123748,123752,123834,123914,123922,123924,123938,123944,123958,123970,123976,123984,123998,124006,124012,124026,124034,124036,124048,124062,124064,124092,124102,124108,124120,124142,124146,124148,124162,124164,124168,124176,124190,124192,124220,124224,124280,124294,124300,124312,124336,124350,124366,124380,124386,124388,124392,124406,124442,124462,124466,124468,124494,124508,124514,124520,124558,124572,124600,124610,124612,124616,124624,124646,124666,124694,124710,124716,124730,124742,124748,124760,124786,124788,124818,124820,124834,124836,124840,124854,124946,124948,124962,124964,124968,124982,124994,124996,125e3,125008,125022,125030,125036,125050,125058,125060,125064,125072,125086,125088,125116,125126,125132,125144,125166,125170,125172,125186,125188,125192,125200,125216,125244,125248,125304,125318,125324,125336,125360,125374,125390,125404,125410,125412,125416,125430,125444,125448,125456,125472,125504,125560,125680,125702,125708,125720,125744,125758,125792,125820,125838,125852,125880,125890,125892,125896,125904,125918,125926,125932,125978,125998,126002,126004,126030,126044,126050,126052,126056,126094,126108,126136,126146,126148,126152,126160,126182,126202,126222,126236,126264,126320,126334,126338,126340,126344,126352,126366,126368,126412,126450,126452,126486,126502,126508,126522,126534,126540,126552,126574,126578,126580,126598,126604,126616,126640,126654,126670,126684,126690,126692,126696,126738,126754,126756,126760,126774,126786,126788,126792,126800,126814,126822,126828,126842,126894,126898,126900,126934,127126,127142,127148,127162,127178,127186,127188,127254,127270,127276,127290,127302,127308,127320,127342,127346,127348,127370,127378,127380,127394,127396,127400,127450,127510,127526,127532,127546,127558,127576,127598,127602,127604,127622,127628,127640,127664,127678,127694,127708,127714,127716,127720,127734,127754,127762,127764,127778,127784,127810,127812,127816,127824,127838,127846,127866,127898,127918,127922,127924,128022,128038,128044,128058,128070,128076,128088,128110,128114,128116,128134,128140,128152,128176,128190,128206,128220,128226,128228,128232,128246,128262,128268,128280,128304,128318,128352,128380,128398,128412,128440,128450,128452,128456,128464,128478,128486,128492,128506,128522,128530,128532,128546,128548,128552,128566,128578,128580,128584,128592,128606,128614,128634,128642,128644,128648,128656,128670,128672,128700,128716,128754,128756,128794,128814,128818,128820,128846,128860,128866,128868,128872,128886,128918,128934,128940,128954,128978,128980,129178,129198,129202,129204,129238,129258,129306,129326,129330,129332,129358,129372,129378,129380,129384,129398,129430,129446,129452,129466,129482,129490,129492,129562,129582,129586,129588,129614,129628,129634,129636,129640,129654,129678,129692,129720,129730,129732,129736,129744,129758,129766,129772,129814,129830,129836,129850,129862,129868,129880,129902,129906,129908,129930,129938,129940,129954,129956,129960,129974,130010]),gr.CODEWORD_TABLE=Int32Array.from([2627,1819,2622,2621,1813,1812,2729,2724,2723,2779,2774,2773,902,896,908,868,865,861,859,2511,873,871,1780,835,2493,825,2491,842,837,844,1764,1762,811,810,809,2483,807,2482,806,2480,815,814,813,812,2484,817,816,1745,1744,1742,1746,2655,2637,2635,2626,2625,2623,2628,1820,2752,2739,2737,2728,2727,2725,2730,2785,2783,2778,2777,2775,2780,787,781,747,739,736,2413,754,752,1719,692,689,681,2371,678,2369,700,697,694,703,1688,1686,642,638,2343,631,2341,627,2338,651,646,643,2345,654,652,1652,1650,1647,1654,601,599,2322,596,2321,594,2319,2317,611,610,608,606,2324,603,2323,615,614,612,1617,1616,1614,1612,616,1619,1618,2575,2538,2536,905,901,898,909,2509,2507,2504,870,867,864,860,2512,875,872,1781,2490,2489,2487,2485,1748,836,834,832,830,2494,827,2492,843,841,839,845,1765,1763,2701,2676,2674,2653,2648,2656,2634,2633,2631,2629,1821,2638,2636,2770,2763,2761,2750,2745,2753,2736,2735,2733,2731,1848,2740,2738,2786,2784,591,588,576,569,566,2296,1590,537,534,526,2276,522,2274,545,542,539,548,1572,1570,481,2245,466,2242,462,2239,492,485,482,2249,496,494,1534,1531,1528,1538,413,2196,406,2191,2188,425,419,2202,415,2199,432,430,427,1472,1467,1464,433,1476,1474,368,367,2160,365,2159,362,2157,2155,2152,378,377,375,2166,372,2165,369,2162,383,381,379,2168,1419,1418,1416,1414,385,1411,384,1423,1422,1420,1424,2461,802,2441,2439,790,786,783,794,2409,2406,2403,750,742,738,2414,756,753,1720,2367,2365,2362,2359,1663,693,691,684,2373,680,2370,702,699,696,704,1690,1687,2337,2336,2334,2332,1624,2329,1622,640,637,2344,634,2342,630,2340,650,648,645,2346,655,653,1653,1651,1649,1655,2612,2597,2595,2571,2568,2565,2576,2534,2529,2526,1787,2540,2537,907,904,900,910,2503,2502,2500,2498,1768,2495,1767,2510,2508,2506,869,866,863,2513,876,874,1782,2720,2713,2711,2697,2694,2691,2702,2672,2670,2664,1828,2678,2675,2647,2646,2644,2642,1823,2639,1822,2654,2652,2650,2657,2771,1855,2765,2762,1850,1849,2751,2749,2747,2754,353,2148,344,342,336,2142,332,2140,345,1375,1373,306,2130,299,2128,295,2125,319,314,311,2132,1354,1352,1349,1356,262,257,2101,253,2096,2093,274,273,267,2107,263,2104,280,278,275,1316,1311,1308,1320,1318,2052,202,2050,2044,2040,219,2063,212,2060,208,2055,224,221,2066,1260,1258,1252,231,1248,229,1266,1264,1261,1268,155,1998,153,1996,1994,1991,1988,165,164,2007,162,2006,159,2003,2e3,172,171,169,2012,166,2010,1186,1184,1182,1179,175,1176,173,1192,1191,1189,1187,176,1194,1193,2313,2307,2305,592,589,2294,2292,2289,578,572,568,2297,580,1591,2272,2267,2264,1547,538,536,529,2278,525,2275,547,544,541,1574,1571,2237,2235,2229,1493,2225,1489,478,2247,470,2244,465,2241,493,488,484,2250,498,495,1536,1533,1530,1539,2187,2186,2184,2182,1432,2179,1430,2176,1427,414,412,2197,409,2195,405,2193,2190,426,424,421,2203,418,2201,431,429,1473,1471,1469,1466,434,1477,1475,2478,2472,2470,2459,2457,2454,2462,803,2437,2432,2429,1726,2443,2440,792,789,785,2401,2399,2393,1702,2389,1699,2411,2408,2405,745,741,2415,758,755,1721,2358,2357,2355,2353,1661,2350,1660,2347,1657,2368,2366,2364,2361,1666,690,687,2374,683,2372,701,698,705,1691,1689,2619,2617,2610,2608,2605,2613,2593,2588,2585,1803,2599,2596,2563,2561,2555,1797,2551,1795,2573,2570,2567,2577,2525,2524,2522,2520,1786,2517,1785,2514,1783,2535,2533,2531,2528,1788,2541,2539,906,903,911,2721,1844,2715,2712,1838,1836,2699,2696,2693,2703,1827,1826,1824,2673,2671,2669,2666,1829,2679,2677,1858,1857,2772,1854,1853,1851,1856,2766,2764,143,1987,139,1986,135,133,131,1984,128,1983,125,1981,138,137,136,1985,1133,1132,1130,112,110,1974,107,1973,104,1971,1969,122,121,119,117,1977,114,1976,124,1115,1114,1112,1110,1117,1116,84,83,1953,81,1952,78,1950,1948,1945,94,93,91,1959,88,1958,85,1955,99,97,95,1961,1086,1085,1083,1081,1078,100,1090,1089,1087,1091,49,47,1917,44,1915,1913,1910,1907,59,1926,56,1925,53,1922,1919,66,64,1931,61,1929,1042,1040,1038,71,1035,70,1032,68,1048,1047,1045,1043,1050,1049,12,10,1869,1867,1864,1861,21,1880,19,1877,1874,1871,28,1888,25,1886,22,1883,982,980,977,974,32,30,991,989,987,984,34,995,994,992,2151,2150,2147,2146,2144,356,355,354,2149,2139,2138,2136,2134,1359,343,341,338,2143,335,2141,348,347,346,1376,1374,2124,2123,2121,2119,1326,2116,1324,310,308,305,2131,302,2129,298,2127,320,318,316,313,2133,322,321,1355,1353,1351,1357,2092,2091,2089,2087,1276,2084,1274,2081,1271,259,2102,256,2100,252,2098,2095,272,269,2108,266,2106,281,279,277,1317,1315,1313,1310,282,1321,1319,2039,2037,2035,2032,1203,2029,1200,1197,207,2053,205,2051,201,2049,2046,2043,220,218,2064,215,2062,211,2059,228,226,223,2069,1259,1257,1254,232,1251,230,1267,1265,1263,2316,2315,2312,2311,2309,2314,2304,2303,2301,2299,1593,2308,2306,590,2288,2287,2285,2283,1578,2280,1577,2295,2293,2291,579,577,574,571,2298,582,581,1592,2263,2262,2260,2258,1545,2255,1544,2252,1541,2273,2271,2269,2266,1550,535,532,2279,528,2277,546,543,549,1575,1573,2224,2222,2220,1486,2217,1485,2214,1482,1479,2238,2236,2234,2231,1496,2228,1492,480,477,2248,473,2246,469,2243,490,487,2251,497,1537,1535,1532,2477,2476,2474,2479,2469,2468,2466,2464,1730,2473,2471,2453,2452,2450,2448,1729,2445,1728,2460,2458,2456,2463,805,804,2428,2427,2425,2423,1725,2420,1724,2417,1722,2438,2436,2434,2431,1727,2444,2442,793,791,788,795,2388,2386,2384,1697,2381,1696,2378,1694,1692,2402,2400,2398,2395,1703,2392,1701,2412,2410,2407,751,748,744,2416,759,757,1807,2620,2618,1806,1805,2611,2609,2607,2614,1802,1801,1799,2594,2592,2590,2587,1804,2600,2598,1794,1793,1791,1789,2564,2562,2560,2557,1798,2554,1796,2574,2572,2569,2578,1847,1846,2722,1843,1842,1840,1845,2716,2714,1835,1834,1832,1830,1839,1837,2700,2698,2695,2704,1817,1811,1810,897,862,1777,829,826,838,1760,1758,808,2481,1741,1740,1738,1743,2624,1818,2726,2776,782,740,737,1715,686,679,695,1682,1680,639,628,2339,647,644,1645,1643,1640,1648,602,600,597,595,2320,593,2318,609,607,604,1611,1610,1608,1606,613,1615,1613,2328,926,924,892,886,899,857,850,2505,1778,824,823,821,819,2488,818,2486,833,831,828,840,1761,1759,2649,2632,2630,2746,2734,2732,2782,2781,570,567,1587,531,527,523,540,1566,1564,476,467,463,2240,486,483,1524,1521,1518,1529,411,403,2192,399,2189,423,416,1462,1457,1454,428,1468,1465,2210,366,363,2158,360,2156,357,2153,376,373,370,2163,1410,1409,1407,1405,382,1402,380,1417,1415,1412,1421,2175,2174,777,774,771,784,732,725,722,2404,743,1716,676,674,668,2363,665,2360,685,1684,1681,626,624,622,2335,620,2333,617,2330,641,635,649,1646,1644,1642,2566,928,925,2530,2527,894,891,888,2501,2499,2496,858,856,854,851,1779,2692,2668,2665,2645,2643,2640,2651,2768,2759,2757,2744,2743,2741,2748,352,1382,340,337,333,1371,1369,307,300,296,2126,315,312,1347,1342,1350,261,258,250,2097,246,2094,271,268,264,1306,1301,1298,276,1312,1309,2115,203,2048,195,2045,191,2041,213,209,2056,1246,1244,1238,225,1234,222,1256,1253,1249,1262,2080,2079,154,1997,150,1995,147,1992,1989,163,160,2004,156,2001,1175,1174,1172,1170,1167,170,1164,167,1185,1183,1180,1177,174,1190,1188,2025,2024,2022,587,586,564,559,556,2290,573,1588,520,518,512,2268,508,2265,530,1568,1565,461,457,2233,450,2230,446,2226,479,471,489,1526,1523,1520,397,395,2185,392,2183,389,2180,2177,410,2194,402,422,1463,1461,1459,1456,1470,2455,799,2433,2430,779,776,773,2397,2394,2390,734,728,724,746,1717,2356,2354,2351,2348,1658,677,675,673,670,667,688,1685,1683,2606,2589,2586,2559,2556,2552,927,2523,2521,2518,2515,1784,2532,895,893,890,2718,2709,2707,2689,2687,2684,2663,2662,2660,2658,1825,2667,2769,1852,2760,2758,142,141,1139,1138,134,132,129,126,1982,1129,1128,1126,1131,113,111,108,105,1972,101,1970,120,118,115,1109,1108,1106,1104,123,1113,1111,82,79,1951,75,1949,72,1946,92,89,86,1956,1077,1076,1074,1072,98,1069,96,1084,1082,1079,1088,1968,1967,48,45,1916,42,1914,39,1911,1908,60,57,54,1923,50,1920,1031,1030,1028,1026,67,1023,65,1020,62,1041,1039,1036,1033,69,1046,1044,1944,1943,1941,11,9,1868,7,1865,1862,1859,20,1878,16,1875,13,1872,970,968,966,963,29,960,26,23,983,981,978,975,33,971,31,990,988,985,1906,1904,1902,993,351,2145,1383,331,330,328,326,2137,323,2135,339,1372,1370,294,293,291,289,2122,286,2120,283,2117,309,303,317,1348,1346,1344,245,244,242,2090,239,2088,236,2085,2082,260,2099,249,270,1307,1305,1303,1300,1314,189,2038,186,2036,183,2033,2030,2026,206,198,2047,194,216,1247,1245,1243,1240,227,1237,1255,2310,2302,2300,2286,2284,2281,565,563,561,558,575,1589,2261,2259,2256,2253,1542,521,519,517,514,2270,511,533,1569,1567,2223,2221,2218,2215,1483,2211,1480,459,456,453,2232,449,474,491,1527,1525,1522,2475,2467,2465,2451,2449,2446,801,800,2426,2424,2421,2418,1723,2435,780,778,775,2387,2385,2382,2379,1695,2375,1693,2396,735,733,730,727,749,1718,2616,2615,2604,2603,2601,2584,2583,2581,2579,1800,2591,2550,2549,2547,2545,1792,2542,1790,2558,929,2719,1841,2710,2708,1833,1831,2690,2688,2686,1815,1809,1808,1774,1756,1754,1737,1736,1734,1739,1816,1711,1676,1674,633,629,1638,1636,1633,1641,598,1605,1604,1602,1600,605,1609,1607,2327,887,853,1775,822,820,1757,1755,1584,524,1560,1558,468,464,1514,1511,1508,1519,408,404,400,1452,1447,1444,417,1458,1455,2208,364,361,358,2154,1401,1400,1398,1396,374,1393,371,1408,1406,1403,1413,2173,2172,772,726,723,1712,672,669,666,682,1678,1675,625,623,621,618,2331,636,632,1639,1637,1635,920,918,884,880,889,849,848,847,846,2497,855,852,1776,2641,2742,2787,1380,334,1367,1365,301,297,1340,1338,1335,1343,255,251,247,1296,1291,1288,265,1302,1299,2113,204,196,192,2042,1232,1230,1224,214,1220,210,1242,1239,1235,1250,2077,2075,151,148,1993,144,1990,1163,1162,1160,1158,1155,161,1152,157,1173,1171,1168,1165,168,1181,1178,2021,2020,2018,2023,585,560,557,1585,516,509,1562,1559,458,447,2227,472,1516,1513,1510,398,396,393,390,2181,386,2178,407,1453,1451,1449,1446,420,1460,2209,769,764,720,712,2391,729,1713,664,663,661,659,2352,656,2349,671,1679,1677,2553,922,919,2519,2516,885,883,881,2685,2661,2659,2767,2756,2755,140,1137,1136,130,127,1125,1124,1122,1127,109,106,102,1103,1102,1100,1098,116,1107,1105,1980,80,76,73,1947,1068,1067,1065,1063,90,1060,87,1075,1073,1070,1080,1966,1965,46,43,40,1912,36,1909,1019,1018,1016,1014,58,1011,55,1008,51,1029,1027,1024,1021,63,1037,1034,1940,1939,1937,1942,8,1866,4,1863,1,1860,956,954,952,949,946,17,14,969,967,964,961,27,957,24,979,976,972,1901,1900,1898,1896,986,1905,1903,350,349,1381,329,327,324,1368,1366,292,290,287,284,2118,304,1341,1339,1337,1345,243,240,237,2086,233,2083,254,1297,1295,1293,1290,1304,2114,190,187,184,2034,180,2031,177,2027,199,1233,1231,1229,1226,217,1223,1241,2078,2076,584,555,554,552,550,2282,562,1586,507,506,504,502,2257,499,2254,515,1563,1561,445,443,441,2219,438,2216,435,2212,460,454,475,1517,1515,1512,2447,798,797,2422,2419,770,768,766,2383,2380,2376,721,719,717,714,731,1714,2602,2582,2580,2548,2546,2543,923,921,2717,2706,2705,2683,2682,2680,1771,1752,1750,1733,1732,1731,1735,1814,1707,1670,1668,1631,1629,1626,1634,1599,1598,1596,1594,1603,1601,2326,1772,1753,1751,1581,1554,1552,1504,1501,1498,1509,1442,1437,1434,401,1448,1445,2206,1392,1391,1389,1387,1384,359,1399,1397,1394,1404,2171,2170,1708,1672,1669,619,1632,1630,1628,1773,1378,1363,1361,1333,1328,1336,1286,1281,1278,248,1292,1289,2111,1218,1216,1210,197,1206,193,1228,1225,1221,1236,2073,2071,1151,1150,1148,1146,152,1143,149,1140,145,1161,1159,1156,1153,158,1169,1166,2017,2016,2014,2019,1582,510,1556,1553,452,448,1506,1500,394,391,387,1443,1441,1439,1436,1450,2207,765,716,713,1709,662,660,657,1673,1671,916,914,879,878,877,882,1135,1134,1121,1120,1118,1123,1097,1096,1094,1092,103,1101,1099,1979,1059,1058,1056,1054,77,1051,74,1066,1064,1061,1071,1964,1963,1007,1006,1004,1002,999,41,996,37,1017,1015,1012,1009,52,1025,1022,1936,1935,1933,1938,942,940,938,935,932,5,2,955,953,950,947,18,943,15,965,962,958,1895,1894,1892,1890,973,1899,1897,1379,325,1364,1362,288,285,1334,1332,1330,241,238,234,1287,1285,1283,1280,1294,2112,188,185,181,178,2028,1219,1217,1215,1212,200,1209,1227,2074,2072,583,553,551,1583,505,503,500,513,1557,1555,444,442,439,436,2213,455,451,1507,1505,1502,796,763,762,760,767,711,710,708,706,2377,718,715,1710,2544,917,915,2681,1627,1597,1595,2325,1769,1749,1747,1499,1438,1435,2204,1390,1388,1385,1395,2169,2167,1704,1665,1662,1625,1623,1620,1770,1329,1282,1279,2109,1214,1207,1222,2068,2065,1149,1147,1144,1141,146,1157,1154,2013,2011,2008,2015,1579,1549,1546,1495,1487,1433,1431,1428,1425,388,1440,2205,1705,658,1667,1664,1119,1095,1093,1978,1057,1055,1052,1062,1962,1960,1005,1003,1e3,997,38,1013,1010,1932,1930,1927,1934,941,939,936,933,6,930,3,951,948,944,1889,1887,1884,1881,959,1893,1891,35,1377,1360,1358,1327,1325,1322,1331,1277,1275,1272,1269,235,1284,2110,1205,1204,1201,1198,182,1195,179,1213,2070,2067,1580,501,1551,1548,440,437,1497,1494,1490,1503,761,709,707,1706,913,912,2198,1386,2164,2161,1621,1766,2103,1208,2058,2054,1145,1142,2005,2002,1999,2009,1488,1429,1426,2200,1698,1659,1656,1975,1053,1957,1954,1001,998,1924,1921,1918,1928,937,934,931,1879,1876,1873,1870,945,1885,1882,1323,1273,1270,2105,1202,1199,1196,1211,2061,2057,1576,1543,1540,1484,1481,1478,1491,1700]);class En{constructor(l,f){this.bits=l,this.points=f}getBits(){return this.bits}getPoints(){return this.points}}class Lr{static detectMultiple(l,f,x){let b=l.getBlackMatrix(),v=Lr.detect(x,b);return v.length||(b=b.clone(),b.rotate180(),v=Lr.detect(x,b)),new En(b,v)}static detect(l,f){const x=new Array;let b=0,v=0,j=!1;for(;b<f.getHeight();){const T=Lr.findVertices(f,b,v);if(T[0]==null&&T[3]==null){if(!j)break;j=!1,v=0;for(const P of x)P[1]!=null&&(b=Math.trunc(Math.max(b,P[1].getY()))),P[3]!=null&&(b=Math.max(b,Math.trunc(P[3].getY())));b+=Lr.ROW_STEP;continue}if(j=!0,x.push(T),!l)break;T[2]!=null?(v=Math.trunc(T[2].getX()),b=Math.trunc(T[2].getY())):(v=Math.trunc(T[4].getX()),b=Math.trunc(T[4].getY()))}return x}static findVertices(l,f,x){const b=l.getHeight(),v=l.getWidth(),j=new Array(8);return Lr.copyToResult(j,Lr.findRowsWithPattern(l,b,v,f,x,Lr.START_PATTERN),Lr.INDEXES_START_PATTERN),j[4]!=null&&(x=Math.trunc(j[4].getX()),f=Math.trunc(j[4].getY())),Lr.copyToResult(j,Lr.findRowsWithPattern(l,b,v,f,x,Lr.STOP_PATTERN),Lr.INDEXES_STOP_PATTERN),j}static copyToResult(l,f,x){for(let b=0;b<x.length;b++)l[x[b]]=f[b]}static findRowsWithPattern(l,f,x,b,v,j){const T=new Array(4);let P=!1;const H=new Int32Array(j.length);for(;b<f;b+=Lr.ROW_STEP){let je=Lr.findGuardPattern(l,v,b,x,!1,j,H);if(je!=null){for(;b>0;){const Ae=Lr.findGuardPattern(l,v,--b,x,!1,j,H);if(Ae!=null)je=Ae;else{b++;break}}T[0]=new Xe(je[0],b),T[1]=new Xe(je[1],b),P=!0;break}}let de=b+1;if(P){let je=0,Ae=Int32Array.from([Math.trunc(T[0].getX()),Math.trunc(T[1].getX())]);for(;de<f;de++){const Ge=Lr.findGuardPattern(l,Ae[0],de,x,!1,j,H);if(Ge!=null&&Math.abs(Ae[0]-Ge[0])<Lr.MAX_PATTERN_DRIFT&&Math.abs(Ae[1]-Ge[1])<Lr.MAX_PATTERN_DRIFT)Ae=Ge,je=0;else{if(je>Lr.SKIPPED_ROW_COUNT_MAX)break;je++}}de-=je+1,T[2]=new Xe(Ae[0],de),T[3]=new Xe(Ae[1],de)}return de-b<Lr.BARCODE_MIN_HEIGHT&&R.fill(T,null),T}static findGuardPattern(l,f,x,b,v,j,T){R.fillWithin(T,0,T.length,0);let P=f,H=0;for(;l.get(P,x)&&P>0&&H++<Lr.MAX_PIXEL_DRIFT;)P--;let de=P,je=0,Ae=j.length;for(let Ge=v;de<b;de++)if(l.get(de,x)!==Ge)T[je]++;else{if(je===Ae-1){if(Lr.patternMatchVariance(T,j,Lr.MAX_INDIVIDUAL_VARIANCE)<Lr.MAX_AVG_VARIANCE)return new Int32Array([P,de]);P+=T[0]+T[1],C.arraycopy(T,2,T,0,je-1),T[je-1]=0,T[je]=0,je--}else je++;T[je]=1,Ge=!Ge}return je===Ae-1&&Lr.patternMatchVariance(T,j,Lr.MAX_INDIVIDUAL_VARIANCE)<Lr.MAX_AVG_VARIANCE?new Int32Array([P,de-1]):null}static patternMatchVariance(l,f,x){let b=l.length,v=0,j=0;for(let H=0;H<b;H++)v+=l[H],j+=f[H];if(v<j)return 1/0;let T=v/j;x*=T;let P=0;for(let H=0;H<b;H++){let de=l[H],je=f[H]*T,Ae=de>je?de-je:je-de;if(Ae>x)return 1/0;P+=Ae}return P/v}}Lr.INDEXES_START_PATTERN=Int32Array.from([0,4,1,5]),Lr.INDEXES_STOP_PATTERN=Int32Array.from([6,2,7,3]),Lr.MAX_AVG_VARIANCE=.42,Lr.MAX_INDIVIDUAL_VARIANCE=.8,Lr.START_PATTERN=Int32Array.from([8,1,1,1,1,1,1,3]),Lr.STOP_PATTERN=Int32Array.from([7,1,1,3,1,1,1,2,1]),Lr.MAX_PIXEL_DRIFT=3,Lr.MAX_PATTERN_DRIFT=5,Lr.SKIPPED_ROW_COUNT_MAX=25,Lr.ROW_STEP=5,Lr.BARCODE_MIN_HEIGHT=10;class oa{constructor(l,f){if(f.length===0)throw new w;this.field=l;let x=f.length;if(x>1&&f[0]===0){let b=1;for(;b<x&&f[b]===0;)b++;b===x?this.coefficients=new Int32Array([0]):(this.coefficients=new Int32Array(x-b),C.arraycopy(f,b,this.coefficients,0,this.coefficients.length))}else this.coefficients=f}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return this.coefficients[0]===0}getCoefficient(l){return this.coefficients[this.coefficients.length-1-l]}evaluateAt(l){if(l===0)return this.getCoefficient(0);if(l===1){let b=0;for(let v of this.coefficients)b=this.field.add(b,v);return b}let f=this.coefficients[0],x=this.coefficients.length;for(let b=1;b<x;b++)f=this.field.add(this.field.multiply(l,f),this.coefficients[b]);return f}add(l){if(!this.field.equals(l.field))throw new w("ModulusPolys do not have same ModulusGF field");if(this.isZero())return l;if(l.isZero())return this;let f=this.coefficients,x=l.coefficients;if(f.length>x.length){let j=f;f=x,x=j}let b=new Int32Array(x.length),v=x.length-f.length;C.arraycopy(x,0,b,0,v);for(let j=v;j<x.length;j++)b[j]=this.field.add(f[j-v],x[j]);return new oa(this.field,b)}subtract(l){if(!this.field.equals(l.field))throw new w("ModulusPolys do not have same ModulusGF field");return l.isZero()?this:this.add(l.negative())}multiply(l){return l instanceof oa?this.multiplyOther(l):this.multiplyScalar(l)}multiplyOther(l){if(!this.field.equals(l.field))throw new w("ModulusPolys do not have same ModulusGF field");if(this.isZero()||l.isZero())return new oa(this.field,new Int32Array([0]));let f=this.coefficients,x=f.length,b=l.coefficients,v=b.length,j=new Int32Array(x+v-1);for(let T=0;T<x;T++){let P=f[T];for(let H=0;H<v;H++)j[T+H]=this.field.add(j[T+H],this.field.multiply(P,b[H]))}return new oa(this.field,j)}negative(){let l=this.coefficients.length,f=new Int32Array(l);for(let x=0;x<l;x++)f[x]=this.field.subtract(0,this.coefficients[x]);return new oa(this.field,f)}multiplyScalar(l){if(l===0)return new oa(this.field,new Int32Array([0]));if(l===1)return this;let f=this.coefficients.length,x=new Int32Array(f);for(let b=0;b<f;b++)x[b]=this.field.multiply(this.coefficients[b],l);return new oa(this.field,x)}multiplyByMonomial(l,f){if(l<0)throw new w;if(f===0)return new oa(this.field,new Int32Array([0]));let x=this.coefficients.length,b=new Int32Array(x+l);for(let v=0;v<x;v++)b[v]=this.field.multiply(this.coefficients[v],f);return new oa(this.field,b)}toString(){let l=new ke;for(let f=this.getDegree();f>=0;f--){let x=this.getCoefficient(f);x!==0&&(x<0?(l.append(" - "),x=-x):l.length()>0&&l.append(" + "),(f===0||x!==1)&&l.append(x),f!==0&&(f===1?l.append("x"):(l.append("x^"),l.append(f))))}return l.toString()}}class gi{add(l,f){return(l+f)%this.modulus}subtract(l,f){return(this.modulus+l-f)%this.modulus}exp(l){return this.expTable[l]}log(l){if(l===0)throw new w;return this.logTable[l]}inverse(l){if(l===0)throw new pe;return this.expTable[this.modulus-this.logTable[l]-1]}multiply(l,f){return l===0||f===0?0:this.expTable[(this.logTable[l]+this.logTable[f])%(this.modulus-1)]}getSize(){return this.modulus}equals(l){return l===this}}class As extends gi{constructor(l,f){super(),this.modulus=l,this.expTable=new Int32Array(l),this.logTable=new Int32Array(l);let x=1;for(let b=0;b<l;b++)this.expTable[b]=x,x=x*f%l;for(let b=0;b<l-1;b++)this.logTable[this.expTable[b]]=b;this.zero=new oa(this,new Int32Array([0])),this.one=new oa(this,new Int32Array([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(l,f){if(l<0)throw new w;if(f===0)return this.zero;let x=new Int32Array(l+1);return x[0]=f,new oa(this,x)}}As.PDF417_GF=new As(gr.NUMBER_OF_CODEWORDS,3);class Os{constructor(){this.field=As.PDF417_GF}decode(l,f,x){let b=new oa(this.field,l),v=new Int32Array(f),j=!1;for(let ot=f;ot>0;ot--){let ut=b.evaluateAt(this.field.exp(ot));v[f-ot]=ut,ut!==0&&(j=!0)}if(!j)return 0;let T=this.field.getOne();if(x!=null)for(const ot of x){let ut=this.field.exp(l.length-1-ot),At=new oa(this.field,new Int32Array([this.field.subtract(0,ut),1]));T=T.multiply(At)}let P=new oa(this.field,v),H=this.runEuclideanAlgorithm(this.field.buildMonomial(f,1),P,f),de=H[0],je=H[1],Ae=this.findErrorLocations(de),Ge=this.findErrorMagnitudes(je,de,Ae);for(let ot=0;ot<Ae.length;ot++){let ut=l.length-1-this.field.log(Ae[ot]);if(ut<0)throw S.getChecksumInstance();l[ut]=this.field.subtract(l[ut],Ge[ot])}return Ae.length}runEuclideanAlgorithm(l,f,x){if(l.getDegree()<f.getDegree()){let Ae=l;l=f,f=Ae}let b=l,v=f,j=this.field.getZero(),T=this.field.getOne();for(;v.getDegree()>=Math.round(x/2);){let Ae=b,Ge=j;if(b=v,j=T,b.isZero())throw S.getChecksumInstance();v=Ae;let ot=this.field.getZero(),ut=b.getCoefficient(b.getDegree()),At=this.field.inverse(ut);for(;v.getDegree()>=b.getDegree()&&!v.isZero();){let se=v.getDegree()-b.getDegree(),Ee=this.field.multiply(v.getCoefficient(v.getDegree()),At);ot=ot.add(this.field.buildMonomial(se,Ee)),v=v.subtract(b.multiplyByMonomial(se,Ee))}T=ot.multiply(j).subtract(Ge).negative()}let P=T.getCoefficient(0);if(P===0)throw S.getChecksumInstance();let H=this.field.inverse(P),de=T.multiply(H),je=v.multiply(H);return[de,je]}findErrorLocations(l){let f=l.getDegree(),x=new Int32Array(f),b=0;for(let v=1;v<this.field.getSize()&&b<f;v++)l.evaluateAt(v)===0&&(x[b]=this.field.inverse(v),b++);if(b!==f)throw S.getChecksumInstance();return x}findErrorMagnitudes(l,f,x){let b=f.getDegree(),v=new Int32Array(b);for(let H=1;H<=b;H++)v[b-H]=this.field.multiply(H,f.getCoefficient(H));let j=new oa(this.field,v),T=x.length,P=new Int32Array(T);for(let H=0;H<T;H++){let de=this.field.inverse(x[H]),je=this.field.subtract(0,l.evaluateAt(de)),Ae=this.field.inverse(j.evaluateAt(de));P[H]=this.field.multiply(je,Ae)}return P}}class $s{constructor(l,f,x,b,v){l instanceof $s?this.constructor_2(l):this.constructor_1(l,f,x,b,v)}constructor_1(l,f,x,b,v){const j=f==null||x==null,T=b==null||v==null;if(j&&T)throw new re;j?(f=new Xe(0,b.getY()),x=new Xe(0,v.getY())):T&&(b=new Xe(l.getWidth()-1,f.getY()),v=new Xe(l.getWidth()-1,x.getY())),this.image=l,this.topLeft=f,this.bottomLeft=x,this.topRight=b,this.bottomRight=v,this.minX=Math.trunc(Math.min(f.getX(),x.getX())),this.maxX=Math.trunc(Math.max(b.getX(),v.getX())),this.minY=Math.trunc(Math.min(f.getY(),b.getY())),this.maxY=Math.trunc(Math.max(x.getY(),v.getY()))}constructor_2(l){this.image=l.image,this.topLeft=l.getTopLeft(),this.bottomLeft=l.getBottomLeft(),this.topRight=l.getTopRight(),this.bottomRight=l.getBottomRight(),this.minX=l.getMinX(),this.maxX=l.getMaxX(),this.minY=l.getMinY(),this.maxY=l.getMaxY()}static merge(l,f){return l==null?f:f==null?l:new $s(l.image,l.topLeft,l.bottomLeft,f.topRight,f.bottomRight)}addMissingRows(l,f,x){let b=this.topLeft,v=this.bottomLeft,j=this.topRight,T=this.bottomRight;if(l>0){let P=x?this.topLeft:this.topRight,H=Math.trunc(P.getY()-l);H<0&&(H=0);let de=new Xe(P.getX(),H);x?b=de:j=de}if(f>0){let P=x?this.bottomLeft:this.bottomRight,H=Math.trunc(P.getY()+f);H>=this.image.getHeight()&&(H=this.image.getHeight()-1);let de=new Xe(P.getX(),H);x?v=de:T=de}return new $s(this.image,b,v,j,T)}getMinX(){return this.minX}getMaxX(){return this.maxX}getMinY(){return this.minY}getMaxY(){return this.maxY}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}getBottomLeft(){return this.bottomLeft}getBottomRight(){return this.bottomRight}}class Qa{constructor(l,f,x,b){this.columnCount=l,this.errorCorrectionLevel=b,this.rowCountUpperPart=f,this.rowCountLowerPart=x,this.rowCount=f+x}getColumnCount(){return this.columnCount}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getRowCount(){return this.rowCount}getRowCountUpperPart(){return this.rowCountUpperPart}getRowCountLowerPart(){return this.rowCountLowerPart}}class en{constructor(){this.buffer=""}static form(l,f){let x=-1;function b(j,T,P,H,de,je){if(j==="%%")return"%";if(f[++x]===void 0)return;j=H?parseInt(H.substr(1)):void 0;let Ae=de?parseInt(de.substr(1)):void 0,Ge;switch(je){case"s":Ge=f[x];break;case"c":Ge=f[x][0];break;case"f":Ge=parseFloat(f[x]).toFixed(j);break;case"p":Ge=parseFloat(f[x]).toPrecision(j);break;case"e":Ge=parseFloat(f[x]).toExponential(j);break;case"x":Ge=parseInt(f[x]).toString(Ae||16);break;case"d":Ge=parseFloat(parseInt(f[x],Ae||10).toPrecision(j)).toFixed(0);break}Ge=typeof Ge=="object"?JSON.stringify(Ge):(+Ge).toString(Ae);let ot=parseInt(P),ut=P&&P[0]+""=="0"?"0":" ";for(;Ge.length<ot;)Ge=T!==void 0?Ge+ut:ut+Ge;return Ge}let v=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return l.replace(v,b)}format(l,...f){this.buffer+=en.form(l,f)}toString(){return this.buffer}}class Qn{constructor(l){this.boundingBox=new $s(l),this.codewords=new Array(l.getMaxY()-l.getMinY()+1)}getCodewordNearby(l){let f=this.getCodeword(l);if(f!=null)return f;for(let x=1;x<Qn.MAX_NEARBY_DISTANCE;x++){let b=this.imageRowToCodewordIndex(l)-x;if(b>=0&&(f=this.codewords[b],f!=null)||(b=this.imageRowToCodewordIndex(l)+x,b<this.codewords.length&&(f=this.codewords[b],f!=null)))return f}return null}imageRowToCodewordIndex(l){return l-this.boundingBox.getMinY()}setCodeword(l,f){this.codewords[this.imageRowToCodewordIndex(l)]=f}getCodeword(l){return this.codewords[this.imageRowToCodewordIndex(l)]}getBoundingBox(){return this.boundingBox}getCodewords(){return this.codewords}toString(){const l=new en;let f=0;for(const x of this.codewords){if(x==null){l.format("%3d: | %n",f++);continue}l.format("%3d: %3d|%3d%n",f++,x.getRowNumber(),x.getValue())}return l.toString()}}Qn.MAX_NEARBY_DISTANCE=5;class Bn{constructor(){this.values=new Map}setValue(l){l=Math.trunc(l);let f=this.values.get(l);f==null&&(f=0),f++,this.values.set(l,f)}getValue(){let l=-1,f=new Array;for(const[x,b]of this.values.entries()){const v={getKey:()=>x,getValue:()=>b};v.getValue()>l?(l=v.getValue(),f=[],f.push(v.getKey())):v.getValue()===l&&f.push(v.getKey())}return gr.toIntArray(f)}getConfidence(l){return this.values.get(l)}}class So extends Qn{constructor(l,f){super(l),this._isLeft=f}setRowNumbers(){for(let l of this.getCodewords())l!=null&&l.setRowNumberAsRowIndicatorColumn()}adjustCompleteIndicatorColumnRowNumbers(l){let f=this.getCodewords();this.setRowNumbers(),this.removeIncorrectCodewords(f,l);let x=this.getBoundingBox(),b=this._isLeft?x.getTopLeft():x.getTopRight(),v=this._isLeft?x.getBottomLeft():x.getBottomRight(),j=this.imageRowToCodewordIndex(Math.trunc(b.getY())),T=this.imageRowToCodewordIndex(Math.trunc(v.getY())),P=-1,H=1,de=0;for(let je=j;je<T;je++){if(f[je]==null)continue;let Ae=f[je],Ge=Ae.getRowNumber()-P;if(Ge===0)de++;else if(Ge===1)H=Math.max(H,de),de=1,P=Ae.getRowNumber();else if(Ge<0||Ae.getRowNumber()>=l.getRowCount()||Ge>je)f[je]=null;else{let ot;H>2?ot=(H-2)*Ge:ot=Ge;let ut=ot>=je;for(let At=1;At<=ot&&!ut;At++)ut=f[je-At]!=null;ut?f[je]=null:(P=Ae.getRowNumber(),de=1)}}}getRowHeights(){let l=this.getBarcodeMetadata();if(l==null)return null;this.adjustIncompleteIndicatorColumnRowNumbers(l);let f=new Int32Array(l.getRowCount());for(let x of this.getCodewords())if(x!=null){let b=x.getRowNumber();if(b>=f.length)continue;f[b]++}return f}adjustIncompleteIndicatorColumnRowNumbers(l){let f=this.getBoundingBox(),x=this._isLeft?f.getTopLeft():f.getTopRight(),b=this._isLeft?f.getBottomLeft():f.getBottomRight(),v=this.imageRowToCodewordIndex(Math.trunc(x.getY())),j=this.imageRowToCodewordIndex(Math.trunc(b.getY())),T=this.getCodewords(),P=-1;for(let H=v;H<j;H++){if(T[H]==null)continue;let de=T[H];de.setRowNumberAsRowIndicatorColumn();let je=de.getRowNumber()-P;je===0||(je===1?P=de.getRowNumber():de.getRowNumber()>=l.getRowCount()?T[H]=null:P=de.getRowNumber())}}getBarcodeMetadata(){let l=this.getCodewords(),f=new Bn,x=new Bn,b=new Bn,v=new Bn;for(let T of l){if(T==null)continue;T.setRowNumberAsRowIndicatorColumn();let P=T.getValue()%30,H=T.getRowNumber();switch(this._isLeft||(H+=2),H%3){case 0:x.setValue(P*3+1);break;case 1:v.setValue(P/3),b.setValue(P%3);break;case 2:f.setValue(P+1);break}}if(f.getValue().length===0||x.getValue().length===0||b.getValue().length===0||v.getValue().length===0||f.getValue()[0]<1||x.getValue()[0]+b.getValue()[0]<gr.MIN_ROWS_IN_BARCODE||x.getValue()[0]+b.getValue()[0]>gr.MAX_ROWS_IN_BARCODE)return null;let j=new Qa(f.getValue()[0],x.getValue()[0],b.getValue()[0],v.getValue()[0]);return this.removeIncorrectCodewords(l,j),j}removeIncorrectCodewords(l,f){for(let x=0;x<l.length;x++){let b=l[x];if(l[x]==null)continue;let v=b.getValue()%30,j=b.getRowNumber();if(j>f.getRowCount()){l[x]=null;continue}switch(this._isLeft||(j+=2),j%3){case 0:v*3+1!==f.getRowCountUpperPart()&&(l[x]=null);break;case 1:(Math.trunc(v/3)!==f.getErrorCorrectionLevel()||v%3!==f.getRowCountLowerPart())&&(l[x]=null);break;case 2:v+1!==f.getColumnCount()&&(l[x]=null);break}}}isLeft(){return this._isLeft}toString(){return"IsLeft: "+this._isLeft+`
`+super.toString()}}class cs{constructor(l,f){this.ADJUST_ROW_NUMBER_SKIP=2,this.barcodeMetadata=l,this.barcodeColumnCount=l.getColumnCount(),this.boundingBox=f,this.detectionResultColumns=new Array(this.barcodeColumnCount+2)}getDetectionResultColumns(){this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[0]),this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[this.barcodeColumnCount+1]);let l=gr.MAX_CODEWORDS_IN_BARCODE,f;do f=l,l=this.adjustRowNumbersAndGetCount();while(l>0&&l<f);return this.detectionResultColumns}adjustIndicatorColumnRowNumbers(l){l!=null&&l.adjustCompleteIndicatorColumnRowNumbers(this.barcodeMetadata)}adjustRowNumbersAndGetCount(){let l=this.adjustRowNumbersByRow();if(l===0)return 0;for(let f=1;f<this.barcodeColumnCount+1;f++){let x=this.detectionResultColumns[f].getCodewords();for(let b=0;b<x.length;b++)x[b]!=null&&(x[b].hasValidRowNumber()||this.adjustRowNumbers(f,b,x))}return l}adjustRowNumbersByRow(){return this.adjustRowNumbersFromBothRI(),this.adjustRowNumbersFromLRI()+this.adjustRowNumbersFromRRI()}adjustRowNumbersFromBothRI(){if(this.detectionResultColumns[0]==null||this.detectionResultColumns[this.barcodeColumnCount+1]==null)return;let l=this.detectionResultColumns[0].getCodewords(),f=this.detectionResultColumns[this.barcodeColumnCount+1].getCodewords();for(let x=0;x<l.length;x++)if(l[x]!=null&&f[x]!=null&&l[x].getRowNumber()===f[x].getRowNumber())for(let b=1;b<=this.barcodeColumnCount;b++){let v=this.detectionResultColumns[b].getCodewords()[x];v!=null&&(v.setRowNumber(l[x].getRowNumber()),v.hasValidRowNumber()||(this.detectionResultColumns[b].getCodewords()[x]=null))}}adjustRowNumbersFromRRI(){if(this.detectionResultColumns[this.barcodeColumnCount+1]==null)return 0;let l=0,f=this.detectionResultColumns[this.barcodeColumnCount+1].getCodewords();for(let x=0;x<f.length;x++){if(f[x]==null)continue;let b=f[x].getRowNumber(),v=0;for(let j=this.barcodeColumnCount+1;j>0&&v<this.ADJUST_ROW_NUMBER_SKIP;j--){let T=this.detectionResultColumns[j].getCodewords()[x];T!=null&&(v=cs.adjustRowNumberIfValid(b,v,T),T.hasValidRowNumber()||l++)}}return l}adjustRowNumbersFromLRI(){if(this.detectionResultColumns[0]==null)return 0;let l=0,f=this.detectionResultColumns[0].getCodewords();for(let x=0;x<f.length;x++){if(f[x]==null)continue;let b=f[x].getRowNumber(),v=0;for(let j=1;j<this.barcodeColumnCount+1&&v<this.ADJUST_ROW_NUMBER_SKIP;j++){let T=this.detectionResultColumns[j].getCodewords()[x];T!=null&&(v=cs.adjustRowNumberIfValid(b,v,T),T.hasValidRowNumber()||l++)}}return l}static adjustRowNumberIfValid(l,f,x){return x==null||x.hasValidRowNumber()||(x.isValidRowNumber(l)?(x.setRowNumber(l),f=0):++f),f}adjustRowNumbers(l,f,x){if(!this.detectionResultColumns[l-1])return;let b=x[f],v=this.detectionResultColumns[l-1].getCodewords(),j=v;this.detectionResultColumns[l+1]!=null&&(j=this.detectionResultColumns[l+1].getCodewords());let T=new Array(14);T[2]=v[f],T[3]=j[f],f>0&&(T[0]=x[f-1],T[4]=v[f-1],T[5]=j[f-1]),f>1&&(T[8]=x[f-2],T[10]=v[f-2],T[11]=j[f-2]),f<x.length-1&&(T[1]=x[f+1],T[6]=v[f+1],T[7]=j[f+1]),f<x.length-2&&(T[9]=x[f+2],T[12]=v[f+2],T[13]=j[f+2]);for(let P of T)if(cs.adjustRowNumber(b,P))return}static adjustRowNumber(l,f){return f==null?!1:f.hasValidRowNumber()&&f.getBucket()===l.getBucket()?(l.setRowNumber(f.getRowNumber()),!0):!1}getBarcodeColumnCount(){return this.barcodeColumnCount}getBarcodeRowCount(){return this.barcodeMetadata.getRowCount()}getBarcodeECLevel(){return this.barcodeMetadata.getErrorCorrectionLevel()}setBoundingBox(l){this.boundingBox=l}getBoundingBox(){return this.boundingBox}setDetectionResultColumn(l,f){this.detectionResultColumns[l]=f}getDetectionResultColumn(l){return this.detectionResultColumns[l]}toString(){let l=this.detectionResultColumns[0];l==null&&(l=this.detectionResultColumns[this.barcodeColumnCount+1]);let f=new en;for(let x=0;x<l.getCodewords().length;x++){f.format("CW %3d:",x);for(let b=0;b<this.barcodeColumnCount+2;b++){if(this.detectionResultColumns[b]==null){f.format(" | ");continue}let v=this.detectionResultColumns[b].getCodewords()[x];if(v==null){f.format(" | ");continue}f.format(" %3d|%3d",v.getRowNumber(),v.getValue())}f.format("%n")}return f.toString()}}class Ds{constructor(l,f,x,b){this.rowNumber=Ds.BARCODE_ROW_UNKNOWN,this.startX=Math.trunc(l),this.endX=Math.trunc(f),this.bucket=Math.trunc(x),this.value=Math.trunc(b)}hasValidRowNumber(){return this.isValidRowNumber(this.rowNumber)}isValidRowNumber(l){return l!==Ds.BARCODE_ROW_UNKNOWN&&this.bucket===l%3*3}setRowNumberAsRowIndicatorColumn(){this.rowNumber=Math.trunc(Math.trunc(this.value/30)*3+Math.trunc(this.bucket/3))}getWidth(){return this.endX-this.startX}getStartX(){return this.startX}getEndX(){return this.endX}getBucket(){return this.bucket}getValue(){return this.value}getRowNumber(){return this.rowNumber}setRowNumber(l){this.rowNumber=l}toString(){return this.rowNumber+"|"+this.value}}Ds.BARCODE_ROW_UNKNOWN=-1;class es{static initialize(){for(let l=0;l<gr.SYMBOL_TABLE.length;l++){let f=gr.SYMBOL_TABLE[l],x=f&1;for(let b=0;b<gr.BARS_IN_MODULE;b++){let v=0;for(;(f&1)===x;)v+=1,f>>=1;x=f&1,es.RATIOS_TABLE[l]||(es.RATIOS_TABLE[l]=new Array(gr.BARS_IN_MODULE)),es.RATIOS_TABLE[l][gr.BARS_IN_MODULE-b-1]=Math.fround(v/gr.MODULES_IN_CODEWORD)}}this.bSymbolTableReady=!0}static getDecodedValue(l){let f=es.getDecodedCodewordValue(es.sampleBitCounts(l));return f!==-1?f:es.getClosestDecodedValue(l)}static sampleBitCounts(l){let f=Je.sum(l),x=new Int32Array(gr.BARS_IN_MODULE),b=0,v=0;for(let j=0;j<gr.MODULES_IN_CODEWORD;j++){let T=f/(2*gr.MODULES_IN_CODEWORD)+j*f/gr.MODULES_IN_CODEWORD;v+l[b]<=T&&(v+=l[b],b++),x[b]++}return x}static getDecodedCodewordValue(l){let f=es.getBitValue(l);return gr.getCodeword(f)===-1?-1:f}static getBitValue(l){let f=0;for(let x=0;x<l.length;x++)for(let b=0;b<l[x];b++)f=f<<1|(x%2===0?1:0);return Math.trunc(f)}static getClosestDecodedValue(l){let f=Je.sum(l),x=new Array(gr.BARS_IN_MODULE);if(f>1)for(let j=0;j<x.length;j++)x[j]=Math.fround(l[j]/f);let b=Ve.MAX_VALUE,v=-1;this.bSymbolTableReady||es.initialize();for(let j=0;j<es.RATIOS_TABLE.length;j++){let T=0,P=es.RATIOS_TABLE[j];for(let H=0;H<gr.BARS_IN_MODULE;H++){let de=Math.fround(P[H]-x[H]);if(T+=Math.fround(de*de),T>=b)break}T<b&&(b=T,v=gr.SYMBOL_TABLE[j])}return v}}es.bSymbolTableReady=!1,es.RATIOS_TABLE=new Array(gr.SYMBOL_TABLE.length).map(Ne=>new Array(gr.BARS_IN_MODULE));class ei{constructor(){this.segmentCount=-1,this.fileSize=-1,this.timestamp=-1,this.checksum=-1}getSegmentIndex(){return this.segmentIndex}setSegmentIndex(l){this.segmentIndex=l}getFileId(){return this.fileId}setFileId(l){this.fileId=l}getOptionalData(){return this.optionalData}setOptionalData(l){this.optionalData=l}isLastSegment(){return this.lastSegment}setLastSegment(l){this.lastSegment=l}getSegmentCount(){return this.segmentCount}setSegmentCount(l){this.segmentCount=l}getSender(){return this.sender||null}setSender(l){this.sender=l}getAddressee(){return this.addressee||null}setAddressee(l){this.addressee=l}getFileName(){return this.fileName}setFileName(l){this.fileName=l}getFileSize(){return this.fileSize}setFileSize(l){this.fileSize=l}getChecksum(){return this.checksum}setChecksum(l){this.checksum=l}getTimestamp(){return this.timestamp}setTimestamp(l){this.timestamp=l}}class ga{static parseLong(l,f=void 0){return parseInt(l,f)}}class ti extends g{}ti.kind="NullPointerException";class Tn{writeBytes(l){this.writeBytesOffset(l,0,l.length)}writeBytesOffset(l,f,x){if(l==null)throw new ti;if(f<0||f>l.length||x<0||f+x>l.length||f+x<0)throw new O;if(x===0)return;for(let b=0;b<x;b++)this.write(l[f+b])}flush(){}close(){}}class Oi extends g{}class Zo extends Tn{constructor(l=32){if(super(),this.count=0,l<0)throw new w("Negative initial size: "+l);this.buf=new Uint8Array(l)}ensureCapacity(l){l-this.buf.length>0&&this.grow(l)}grow(l){let x=this.buf.length<<1;if(x-l<0&&(x=l),x<0){if(l<0)throw new Oi;x=F.MAX_VALUE}this.buf=R.copyOfUint8Array(this.buf,x)}write(l){this.ensureCapacity(this.count+1),this.buf[this.count]=l,this.count+=1}writeBytesOffset(l,f,x){if(f<0||f>l.length||x<0||f+x-l.length>0)throw new O;this.ensureCapacity(this.count+x),C.arraycopy(l,f,this.buf,this.count,x),this.count+=x}writeTo(l){l.writeBytesOffset(this.buf,0,this.count)}reset(){this.count=0}toByteArray(){return R.copyOfUint8Array(this.buf,this.count)}size(){return this.count}toString(l){return l?typeof l=="string"?this.toString_string(l):this.toString_number(l):this.toString_void()}toString_void(){return new String(this.buf).toString()}toString_string(l){return new String(this.buf).toString()}toString_number(l){return new String(this.buf).toString()}close(){}}var Pa;(function(Ne){Ne[Ne.ALPHA=0]="ALPHA",Ne[Ne.LOWER=1]="LOWER",Ne[Ne.MIXED=2]="MIXED",Ne[Ne.PUNCT=3]="PUNCT",Ne[Ne.ALPHA_SHIFT=4]="ALPHA_SHIFT",Ne[Ne.PUNCT_SHIFT=5]="PUNCT_SHIFT"})(Pa||(Pa={}));function ri(){if(typeof window!="undefined")return window.BigInt||null;if(typeof am!="undefined")return am.BigInt||null;if(typeof self!="undefined")return self.BigInt||null;throw new Error("Can't search globals for BigInt!")}let xl;function mn(Ne){if(typeof xl=="undefined"&&(xl=ri()),xl===null)throw new Error("BigInt is not supported!");return xl(Ne)}function Co(){let Ne=[];Ne[0]=mn(1);let l=mn(900);Ne[1]=l;for(let f=2;f<16;f++)Ne[f]=Ne[f-1]*l;return Ne}class Gt{static decode(l,f){let x=new ke(""),b=G.ISO8859_1;x.enableDecoding(b);let v=1,j=l[v++],T=new ei;for(;v<l[0];){switch(j){case Gt.TEXT_COMPACTION_MODE_LATCH:v=Gt.textCompaction(l,v,x);break;case Gt.BYTE_COMPACTION_MODE_LATCH:case Gt.BYTE_COMPACTION_MODE_LATCH_6:v=Gt.byteCompaction(j,l,b,v,x);break;case Gt.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:x.append(l[v++]);break;case Gt.NUMERIC_COMPACTION_MODE_LATCH:v=Gt.numericCompaction(l,v,x);break;case Gt.ECI_CHARSET:G.getCharacterSetECIByValue(l[v++]);break;case Gt.ECI_GENERAL_PURPOSE:v+=2;break;case Gt.ECI_USER_DEFINED:v++;break;case Gt.BEGIN_MACRO_PDF417_CONTROL_BLOCK:v=Gt.decodeMacroBlock(l,v,T);break;case Gt.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case Gt.MACRO_PDF417_TERMINATOR:throw new B;default:v--,v=Gt.textCompaction(l,v,x);break}if(v<l.length)j=l[v++];else throw B.getFormatInstance()}if(x.length()===0)throw B.getFormatInstance();let P=new Le(null,x.toString(),null,f);return P.setOther(T),P}static decodeMacroBlock(l,f,x){if(f+Gt.NUMBER_OF_SEQUENCE_CODEWORDS>l[0])throw B.getFormatInstance();let b=new Int32Array(Gt.NUMBER_OF_SEQUENCE_CODEWORDS);for(let T=0;T<Gt.NUMBER_OF_SEQUENCE_CODEWORDS;T++,f++)b[T]=l[f];x.setSegmentIndex(F.parseInt(Gt.decodeBase900toBase10(b,Gt.NUMBER_OF_SEQUENCE_CODEWORDS)));let v=new ke;f=Gt.textCompaction(l,f,v),x.setFileId(v.toString());let j=-1;for(l[f]===Gt.BEGIN_MACRO_PDF417_OPTIONAL_FIELD&&(j=f+1);f<l[0];)switch(l[f]){case Gt.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:switch(f++,l[f]){case Gt.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME:let T=new ke;f=Gt.textCompaction(l,f+1,T),x.setFileName(T.toString());break;case Gt.MACRO_PDF417_OPTIONAL_FIELD_SENDER:let P=new ke;f=Gt.textCompaction(l,f+1,P),x.setSender(P.toString());break;case Gt.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE:let H=new ke;f=Gt.textCompaction(l,f+1,H),x.setAddressee(H.toString());break;case Gt.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT:let de=new ke;f=Gt.numericCompaction(l,f+1,de),x.setSegmentCount(F.parseInt(de.toString()));break;case Gt.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP:let je=new ke;f=Gt.numericCompaction(l,f+1,je),x.setTimestamp(ga.parseLong(je.toString()));break;case Gt.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM:let Ae=new ke;f=Gt.numericCompaction(l,f+1,Ae),x.setChecksum(F.parseInt(Ae.toString()));break;case Gt.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE:let Ge=new ke;f=Gt.numericCompaction(l,f+1,Ge),x.setFileSize(ga.parseLong(Ge.toString()));break;default:throw B.getFormatInstance()}break;case Gt.MACRO_PDF417_TERMINATOR:f++,x.setLastSegment(!0);break;default:throw B.getFormatInstance()}if(j!==-1){let T=f-j;x.isLastSegment()&&T--,x.setOptionalData(R.copyOfRange(l,j,j+T))}return f}static textCompaction(l,f,x){let b=new Int32Array((l[0]-f)*2),v=new Int32Array((l[0]-f)*2),j=0,T=!1;for(;f<l[0]&&!T;){let P=l[f++];if(P<Gt.TEXT_COMPACTION_MODE_LATCH)b[j]=P/30,b[j+1]=P%30,j+=2;else switch(P){case Gt.TEXT_COMPACTION_MODE_LATCH:b[j++]=Gt.TEXT_COMPACTION_MODE_LATCH;break;case Gt.BYTE_COMPACTION_MODE_LATCH:case Gt.BYTE_COMPACTION_MODE_LATCH_6:case Gt.NUMERIC_COMPACTION_MODE_LATCH:case Gt.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case Gt.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case Gt.MACRO_PDF417_TERMINATOR:f--,T=!0;break;case Gt.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:b[j]=Gt.MODE_SHIFT_TO_BYTE_COMPACTION_MODE,P=l[f++],v[j]=P,j++;break}}return Gt.decodeTextCompaction(b,v,j,x),f}static decodeTextCompaction(l,f,x,b){let v=Pa.ALPHA,j=Pa.ALPHA,T=0;for(;T<x;){let P=l[T],H="";switch(v){case Pa.ALPHA:if(P<26)H=String.fromCharCode(65+P);else switch(P){case 26:H=" ";break;case Gt.LL:v=Pa.LOWER;break;case Gt.ML:v=Pa.MIXED;break;case Gt.PS:j=v,v=Pa.PUNCT_SHIFT;break;case Gt.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:b.append(f[T]);break;case Gt.TEXT_COMPACTION_MODE_LATCH:v=Pa.ALPHA;break}break;case Pa.LOWER:if(P<26)H=String.fromCharCode(97+P);else switch(P){case 26:H=" ";break;case Gt.AS:j=v,v=Pa.ALPHA_SHIFT;break;case Gt.ML:v=Pa.MIXED;break;case Gt.PS:j=v,v=Pa.PUNCT_SHIFT;break;case Gt.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:b.append(f[T]);break;case Gt.TEXT_COMPACTION_MODE_LATCH:v=Pa.ALPHA;break}break;case Pa.MIXED:if(P<Gt.PL)H=Gt.MIXED_CHARS[P];else switch(P){case Gt.PL:v=Pa.PUNCT;break;case 26:H=" ";break;case Gt.LL:v=Pa.LOWER;break;case Gt.AL:v=Pa.ALPHA;break;case Gt.PS:j=v,v=Pa.PUNCT_SHIFT;break;case Gt.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:b.append(f[T]);break;case Gt.TEXT_COMPACTION_MODE_LATCH:v=Pa.ALPHA;break}break;case Pa.PUNCT:if(P<Gt.PAL)H=Gt.PUNCT_CHARS[P];else switch(P){case Gt.PAL:v=Pa.ALPHA;break;case Gt.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:b.append(f[T]);break;case Gt.TEXT_COMPACTION_MODE_LATCH:v=Pa.ALPHA;break}break;case Pa.ALPHA_SHIFT:if(v=j,P<26)H=String.fromCharCode(65+P);else switch(P){case 26:H=" ";break;case Gt.TEXT_COMPACTION_MODE_LATCH:v=Pa.ALPHA;break}break;case Pa.PUNCT_SHIFT:if(v=j,P<Gt.PAL)H=Gt.PUNCT_CHARS[P];else switch(P){case Gt.PAL:v=Pa.ALPHA;break;case Gt.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:b.append(f[T]);break;case Gt.TEXT_COMPACTION_MODE_LATCH:v=Pa.ALPHA;break}break}H!==""&&b.append(H),T++}}static byteCompaction(l,f,x,b,v){let j=new Zo,T=0,P=0,H=!1;switch(l){case Gt.BYTE_COMPACTION_MODE_LATCH:let de=new Int32Array(6),je=f[b++];for(;b<f[0]&&!H;)switch(de[T++]=je,P=900*P+je,je=f[b++],je){case Gt.TEXT_COMPACTION_MODE_LATCH:case Gt.BYTE_COMPACTION_MODE_LATCH:case Gt.NUMERIC_COMPACTION_MODE_LATCH:case Gt.BYTE_COMPACTION_MODE_LATCH_6:case Gt.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case Gt.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case Gt.MACRO_PDF417_TERMINATOR:b--,H=!0;break;default:if(T%5===0&&T>0){for(let Ae=0;Ae<6;++Ae)j.write(Number(mn(P)>>mn(8*(5-Ae))));P=0,T=0}break}b===f[0]&&je<Gt.TEXT_COMPACTION_MODE_LATCH&&(de[T++]=je);for(let Ae=0;Ae<T;Ae++)j.write(de[Ae]);break;case Gt.BYTE_COMPACTION_MODE_LATCH_6:for(;b<f[0]&&!H;){let Ae=f[b++];if(Ae<Gt.TEXT_COMPACTION_MODE_LATCH)T++,P=900*P+Ae;else switch(Ae){case Gt.TEXT_COMPACTION_MODE_LATCH:case Gt.BYTE_COMPACTION_MODE_LATCH:case Gt.NUMERIC_COMPACTION_MODE_LATCH:case Gt.BYTE_COMPACTION_MODE_LATCH_6:case Gt.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case Gt.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case Gt.MACRO_PDF417_TERMINATOR:b--,H=!0;break}if(T%5===0&&T>0){for(let Ge=0;Ge<6;++Ge)j.write(Number(mn(P)>>mn(8*(5-Ge))));P=0,T=0}}break}return v.append(fe.decode(j.toByteArray(),x)),b}static numericCompaction(l,f,x){let b=0,v=!1,j=new Int32Array(Gt.MAX_NUMERIC_CODEWORDS);for(;f<l[0]&&!v;){let T=l[f++];if(f===l[0]&&(v=!0),T<Gt.TEXT_COMPACTION_MODE_LATCH)j[b]=T,b++;else switch(T){case Gt.TEXT_COMPACTION_MODE_LATCH:case Gt.BYTE_COMPACTION_MODE_LATCH:case Gt.BYTE_COMPACTION_MODE_LATCH_6:case Gt.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case Gt.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case Gt.MACRO_PDF417_TERMINATOR:f--,v=!0;break}(b%Gt.MAX_NUMERIC_CODEWORDS===0||T===Gt.NUMERIC_COMPACTION_MODE_LATCH||v)&&b>0&&(x.append(Gt.decodeBase900toBase10(j,b)),b=0)}return f}static decodeBase900toBase10(l,f){let x=mn(0);for(let v=0;v<f;v++)x+=Gt.EXP900[f-v-1]*mn(l[v]);let b=x.toString();if(b.charAt(0)!=="1")throw new B;return b.substring(1)}}Gt.TEXT_COMPACTION_MODE_LATCH=900,Gt.BYTE_COMPACTION_MODE_LATCH=901,Gt.NUMERIC_COMPACTION_MODE_LATCH=902,Gt.BYTE_COMPACTION_MODE_LATCH_6=924,Gt.ECI_USER_DEFINED=925,Gt.ECI_GENERAL_PURPOSE=926,Gt.ECI_CHARSET=927,Gt.BEGIN_MACRO_PDF417_CONTROL_BLOCK=928,Gt.BEGIN_MACRO_PDF417_OPTIONAL_FIELD=923,Gt.MACRO_PDF417_TERMINATOR=922,Gt.MODE_SHIFT_TO_BYTE_COMPACTION_MODE=913,Gt.MAX_NUMERIC_CODEWORDS=15,Gt.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME=0,Gt.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT=1,Gt.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP=2,Gt.MACRO_PDF417_OPTIONAL_FIELD_SENDER=3,Gt.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE=4,Gt.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE=5,Gt.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM=6,Gt.PL=25,Gt.LL=27,Gt.AS=27,Gt.ML=28,Gt.AL=28,Gt.PS=29,Gt.PAL=29,Gt.PUNCT_CHARS=`;<>@[\\]_\`~!\r ,:
-.$/"|*()?{}'`,Gt.MIXED_CHARS="0123456789&\r ,:#-.$/+%*=^",Gt.EXP900=ri()?Co():[],Gt.NUMBER_OF_SEQUENCE_CODEWORDS=2;class na{constructor(){}static decode(l,f,x,b,v,j,T){let P=new $s(l,f,x,b,v),H=null,de=null,je;for(let ot=!0;;ot=!1){if(f!=null&&(H=na.getRowIndicatorColumn(l,P,f,!0,j,T)),b!=null&&(de=na.getRowIndicatorColumn(l,P,b,!1,j,T)),je=na.merge(H,de),je==null)throw re.getNotFoundInstance();let ut=je.getBoundingBox();if(ot&&ut!=null&&(ut.getMinY()<P.getMinY()||ut.getMaxY()>P.getMaxY()))P=ut;else break}je.setBoundingBox(P);let Ae=je.getBarcodeColumnCount()+1;je.setDetectionResultColumn(0,H),je.setDetectionResultColumn(Ae,de);let Ge=H!=null;for(let ot=1;ot<=Ae;ot++){let ut=Ge?ot:Ae-ot;if(je.getDetectionResultColumn(ut)!==void 0)continue;let At;ut===0||ut===Ae?At=new So(P,ut===0):At=new Qn(P),je.setDetectionResultColumn(ut,At);let se=-1,Ee=se;for(let Ue=P.getMinY();Ue<=P.getMaxY();Ue++){if(se=na.getStartColumn(je,ut,Ue,Ge),se<0||se>P.getMaxX()){if(Ee===-1)continue;se=Ee}let ht=na.detectCodeword(l,P.getMinX(),P.getMaxX(),Ge,se,Ue,j,T);ht!=null&&(At.setCodeword(Ue,ht),Ee=se,j=Math.min(j,ht.getWidth()),T=Math.max(T,ht.getWidth()))}}return na.createDecoderResult(je)}static merge(l,f){if(l==null&&f==null)return null;let x=na.getBarcodeMetadata(l,f);if(x==null)return null;let b=$s.merge(na.adjustBoundingBox(l),na.adjustBoundingBox(f));return new cs(x,b)}static adjustBoundingBox(l){if(l==null)return null;let f=l.getRowHeights();if(f==null)return null;let x=na.getMax(f),b=0;for(let T of f)if(b+=x-T,T>0)break;let v=l.getCodewords();for(let T=0;b>0&&v[T]==null;T++)b--;let j=0;for(let T=f.length-1;T>=0&&(j+=x-f[T],!(f[T]>0));T--);for(let T=v.length-1;j>0&&v[T]==null;T--)j--;return l.getBoundingBox().addMissingRows(b,j,l.isLeft())}static getMax(l){let f=-1;for(let x of l)f=Math.max(f,x);return f}static getBarcodeMetadata(l,f){let x;if(l==null||(x=l.getBarcodeMetadata())==null)return f==null?null:f.getBarcodeMetadata();let b;return f==null||(b=f.getBarcodeMetadata())==null?x:x.getColumnCount()!==b.getColumnCount()&&x.getErrorCorrectionLevel()!==b.getErrorCorrectionLevel()&&x.getRowCount()!==b.getRowCount()?null:x}static getRowIndicatorColumn(l,f,x,b,v,j){let T=new So(f,b);for(let P=0;P<2;P++){let H=P===0?1:-1,de=Math.trunc(Math.trunc(x.getX()));for(let je=Math.trunc(Math.trunc(x.getY()));je<=f.getMaxY()&&je>=f.getMinY();je+=H){let Ae=na.detectCodeword(l,0,l.getWidth(),b,de,je,v,j);Ae!=null&&(T.setCodeword(je,Ae),b?de=Ae.getStartX():de=Ae.getEndX())}}return T}static adjustCodewordCount(l,f){let x=f[0][1],b=x.getValue(),v=l.getBarcodeColumnCount()*l.getBarcodeRowCount()-na.getNumberOfECCodeWords(l.getBarcodeECLevel());if(b.length===0){if(v<1||v>gr.MAX_CODEWORDS_IN_BARCODE)throw re.getNotFoundInstance();x.setValue(v)}else b[0]!==v&&x.setValue(v)}static createDecoderResult(l){let f=na.createBarcodeMatrix(l);na.adjustCodewordCount(l,f);let x=new Array,b=new Int32Array(l.getBarcodeRowCount()*l.getBarcodeColumnCount()),v=[],j=new Array;for(let P=0;P<l.getBarcodeRowCount();P++)for(let H=0;H<l.getBarcodeColumnCount();H++){let de=f[P][H+1].getValue(),je=P*l.getBarcodeColumnCount()+H;de.length===0?x.push(je):de.length===1?b[je]=de[0]:(j.push(je),v.push(de))}let T=new Array(v.length);for(let P=0;P<T.length;P++)T[P]=v[P];return na.createDecoderResultFromAmbiguousValues(l.getBarcodeECLevel(),b,gr.toIntArray(x),gr.toIntArray(j),T)}static createDecoderResultFromAmbiguousValues(l,f,x,b,v){let j=new Int32Array(b.length),T=100;for(;T-- >0;){for(let P=0;P<j.length;P++)f[b[P]]=v[P][j[P]];try{return na.decodeCodewords(f,l,x)}catch(P){if(!(P instanceof S))throw P}if(j.length===0)throw S.getChecksumInstance();for(let P=0;P<j.length;P++)if(j[P]<v[P].length-1){j[P]++;break}else if(j[P]=0,P===j.length-1)throw S.getChecksumInstance()}throw S.getChecksumInstance()}static createBarcodeMatrix(l){let f=Array.from({length:l.getBarcodeRowCount()},()=>new Array(l.getBarcodeColumnCount()+2));for(let b=0;b<f.length;b++)for(let v=0;v<f[b].length;v++)f[b][v]=new Bn;let x=0;for(let b of l.getDetectionResultColumns()){if(b!=null){for(let v of b.getCodewords())if(v!=null){let j=v.getRowNumber();if(j>=0){if(j>=f.length)continue;f[j][x].setValue(v.getValue())}}}x++}return f}static isValidBarcodeColumn(l,f){return f>=0&&f<=l.getBarcodeColumnCount()+1}static getStartColumn(l,f,x,b){let v=b?1:-1,j=null;if(na.isValidBarcodeColumn(l,f-v)&&(j=l.getDetectionResultColumn(f-v).getCodeword(x)),j!=null)return b?j.getEndX():j.getStartX();if(j=l.getDetectionResultColumn(f).getCodewordNearby(x),j!=null)return b?j.getStartX():j.getEndX();if(na.isValidBarcodeColumn(l,f-v)&&(j=l.getDetectionResultColumn(f-v).getCodewordNearby(x)),j!=null)return b?j.getEndX():j.getStartX();let T=0;for(;na.isValidBarcodeColumn(l,f-v);){f-=v;for(let P of l.getDetectionResultColumn(f).getCodewords())if(P!=null)return(b?P.getEndX():P.getStartX())+v*T*(P.getEndX()-P.getStartX());T++}return b?l.getBoundingBox().getMinX():l.getBoundingBox().getMaxX()}static detectCodeword(l,f,x,b,v,j,T,P){v=na.adjustCodewordStartColumn(l,f,x,b,v,j);let H=na.getModuleBitCount(l,f,x,b,v,j);if(H==null)return null;let de,je=Je.sum(H);if(b)de=v+je;else{for(let ot=0;ot<H.length/2;ot++){let ut=H[ot];H[ot]=H[H.length-1-ot],H[H.length-1-ot]=ut}de=v,v=de-je}if(!na.checkCodewordSkew(je,T,P))return null;let Ae=es.getDecodedValue(H),Ge=gr.getCodeword(Ae);return Ge===-1?null:new Ds(v,de,na.getCodewordBucketNumber(Ae),Ge)}static getModuleBitCount(l,f,x,b,v,j){let T=v,P=new Int32Array(8),H=0,de=b?1:-1,je=b;for(;(b?T<x:T>=f)&&H<P.length;)l.get(T,j)===je?(P[H]++,T+=de):(H++,je=!je);return H===P.length||T===(b?x:f)&&H===P.length-1?P:null}static getNumberOfECCodeWords(l){return 2<<l}static adjustCodewordStartColumn(l,f,x,b,v,j){let T=v,P=b?-1:1;for(let H=0;H<2;H++){for(;(b?T>=f:T<x)&&b===l.get(T,j);){if(Math.abs(v-T)>na.CODEWORD_SKEW_SIZE)return v;T+=P}P=-P,b=!b}return T}static checkCodewordSkew(l,f,x){return f-na.CODEWORD_SKEW_SIZE<=l&&l<=x+na.CODEWORD_SKEW_SIZE}static decodeCodewords(l,f,x){if(l.length===0)throw B.getFormatInstance();let b=1<<f+1,v=na.correctErrors(l,x,b);na.verifyCodewordCount(l,b);let j=Gt.decode(l,""+f);return j.setErrorsCorrected(v),j.setErasures(x.length),j}static correctErrors(l,f,x){if(f!=null&&f.length>x/2+na.MAX_ERRORS||x<0||x>na.MAX_EC_CODEWORDS)throw S.getChecksumInstance();return na.errorCorrection.decode(l,x,f)}static verifyCodewordCount(l,f){if(l.length<4)throw B.getFormatInstance();let x=l[0];if(x>l.length)throw B.getFormatInstance();if(x===0)if(f<l.length)l[0]=l.length-f;else throw B.getFormatInstance()}static getBitCountForCodeword(l){let f=new Int32Array(8),x=0,b=f.length-1;for(;!((l&1)!==x&&(x=l&1,b--,b<0));)f[b]++,l>>=1;return f}static getCodewordBucketNumber(l){return l instanceof Int32Array?this.getCodewordBucketNumber_Int32Array(l):this.getCodewordBucketNumber_number(l)}static getCodewordBucketNumber_number(l){return na.getCodewordBucketNumber(na.getBitCountForCodeword(l))}static getCodewordBucketNumber_Int32Array(l){return(l[0]-l[2]+l[4]-l[6]+9)%9}static toString(l){let f=new en;for(let x=0;x<l.length;x++){f.format("Row %2d: ",x);for(let b=0;b<l[x].length;b++){let v=l[x][b];v.getValue().length===0?f.format(" ",null):f.format("%4d(%2d)",v.getValue()[0],v.getConfidence(v.getValue()[0]))}f.format("%n")}return f.toString()}}na.CODEWORD_SKEW_SIZE=2,na.MAX_ERRORS=3,na.MAX_EC_CODEWORDS=512,na.errorCorrection=new Os;class Ls{decode(l,f=null){let x=Ls.decode(l,f,!1);if(x==null||x.length===0||x[0]==null)throw re.getNotFoundInstance();return x[0]}decodeMultiple(l,f=null){try{return Ls.decode(l,f,!0)}catch(x){throw x instanceof B||x instanceof S?re.getNotFoundInstance():x}}static decode(l,f,x){const b=new Array,v=Lr.detectMultiple(l,f,x);for(const j of v.getPoints()){const T=na.decode(v.getBits(),j[4],j[5],j[6],j[7],Ls.getMinCodewordWidth(j),Ls.getMaxCodewordWidth(j)),P=new ae(T.getText(),T.getRawBytes(),void 0,j,le.PDF_417);P.putMetadata(Z.ERROR_CORRECTION_LEVEL,T.getECLevel());const H=T.getOther();H!=null&&P.putMetadata(Z.PDF417_EXTRA_METADATA,H),b.push(P)}return b.map(j=>j)}static getMaxWidth(l,f){return l==null||f==null?0:Math.trunc(Math.abs(l.getX()-f.getX()))}static getMinWidth(l,f){return l==null||f==null?F.MAX_VALUE:Math.trunc(Math.abs(l.getX()-f.getX()))}static getMaxCodewordWidth(l){return Math.floor(Math.max(Math.max(Ls.getMaxWidth(l[0],l[4]),Ls.getMaxWidth(l[6],l[2])*gr.MODULES_IN_CODEWORD/gr.MODULES_IN_STOP_PATTERN),Math.max(Ls.getMaxWidth(l[1],l[5]),Ls.getMaxWidth(l[7],l[3])*gr.MODULES_IN_CODEWORD/gr.MODULES_IN_STOP_PATTERN)))}static getMinCodewordWidth(l){return Math.floor(Math.min(Math.min(Ls.getMinWidth(l[0],l[4]),Ls.getMinWidth(l[6],l[2])*gr.MODULES_IN_CODEWORD/gr.MODULES_IN_STOP_PATTERN),Math.min(Ls.getMinWidth(l[1],l[5]),Ls.getMinWidth(l[7],l[3])*gr.MODULES_IN_CODEWORD/gr.MODULES_IN_STOP_PATTERN)))}reset(){}}class An extends g{}An.kind="ReaderException";class pc{constructor(l,f){this.verbose=l===!0,f&&this.setHints(f)}decode(l,f){return f&&this.setHints(f),this.decodeInternal(l)}decodeWithState(l){return(this.readers===null||this.readers===void 0)&&this.setHints(null),this.decodeInternal(l)}setHints(l){this.hints=l;const f=!s(l)&&l.get(X.TRY_HARDER)===!0,x=s(l)?null:l.get(X.POSSIBLE_FORMATS),b=new Array;if(!s(x)){const v=x.some(j=>j===le.UPC_A||j===le.UPC_E||j===le.EAN_13||j===le.EAN_8||j===le.CODABAR||j===le.CODE_39||j===le.CODE_93||j===le.CODE_128||j===le.ITF||j===le.RSS_14||j===le.RSS_EXPANDED);v&&!f&&b.push(new vr(l,this.verbose)),x.includes(le.QR_CODE)&&b.push(new Qr),x.includes(le.DATA_MATRIX)&&b.push(new wr),x.includes(le.AZTEC)&&b.push(new wt),x.includes(le.PDF_417)&&b.push(new Ls),v&&f&&b.push(new vr(l,this.verbose))}b.length===0&&(f||b.push(new vr(l,this.verbose)),b.push(new Qr),b.push(new wr),b.push(new wt),b.push(new Ls),f&&b.push(new vr(l,this.verbose))),this.readers=b}reset(){if(this.readers!==null)for(const l of this.readers)l.reset()}decodeInternal(l){if(this.readers===null)throw new An("No readers where selected, nothing can be read.");for(const f of this.readers)try{return f.decode(l,this.hints)}catch(x){if(x instanceof An)continue}throw new re("No MultiFormat Readers were able to detect the code.")}}class Bl extends J{constructor(l=null,f=500){const x=new pc;x.setHints(l),super(x,f)}decodeBitmap(l){return this.reader.decodeWithState(l)}}class $i extends J{constructor(l=500){super(new Ls,l)}}class yc extends J{constructor(l=500){super(new Qr,l)}}var pl;(function(Ne){Ne[Ne.ERROR_CORRECTION=0]="ERROR_CORRECTION",Ne[Ne.CHARACTER_SET=1]="CHARACTER_SET",Ne[Ne.DATA_MATRIX_SHAPE=2]="DATA_MATRIX_SHAPE",Ne[Ne.MIN_SIZE=3]="MIN_SIZE",Ne[Ne.MAX_SIZE=4]="MAX_SIZE",Ne[Ne.MARGIN=5]="MARGIN",Ne[Ne.PDF417_COMPACT=6]="PDF417_COMPACT",Ne[Ne.PDF417_COMPACTION=7]="PDF417_COMPACTION",Ne[Ne.PDF417_DIMENSIONS=8]="PDF417_DIMENSIONS",Ne[Ne.AZTEC_LAYERS=9]="AZTEC_LAYERS",Ne[Ne.QR_VERSION=10]="QR_VERSION"})(pl||(pl={}));var ts=pl;class Ko{constructor(l){this.field=l,this.cachedGenerators=[],this.cachedGenerators.push(new Be(l,Int32Array.from([1])))}buildGenerator(l){const f=this.cachedGenerators;if(l>=f.length){let x=f[f.length-1];const b=this.field;for(let v=f.length;v<=l;v++){const j=x.multiply(new Be(b,Int32Array.from([1,b.exp(v-1+b.getGeneratorBase())])));f.push(j),x=j}}return f[l]}encode(l,f){if(f===0)throw new w("No error correction bytes");const x=l.length-f;if(x<=0)throw new w("No data bytes provided");const b=this.buildGenerator(f),v=new Int32Array(x);C.arraycopy(l,0,v,0,x);let j=new Be(this.field,v);j=j.multiplyByMonomial(f,1);const P=j.divide(b)[1].getCoefficients(),H=f-P.length;for(let de=0;de<H;de++)l[x+de]=0;C.arraycopy(P,0,l,x+H,P.length)}}class rs{constructor(){}static applyMaskPenaltyRule1(l){return rs.applyMaskPenaltyRule1Internal(l,!0)+rs.applyMaskPenaltyRule1Internal(l,!1)}static applyMaskPenaltyRule2(l){let f=0;const x=l.getArray(),b=l.getWidth(),v=l.getHeight();for(let j=0;j<v-1;j++){const T=x[j];for(let P=0;P<b-1;P++){const H=T[P];H===T[P+1]&&H===x[j+1][P]&&H===x[j+1][P+1]&&f++}}return rs.N2*f}static applyMaskPenaltyRule3(l){let f=0;const x=l.getArray(),b=l.getWidth(),v=l.getHeight();for(let j=0;j<v;j++)for(let T=0;T<b;T++){const P=x[j];T+6<b&&P[T]===1&&P[T+1]===0&&P[T+2]===1&&P[T+3]===1&&P[T+4]===1&&P[T+5]===0&&P[T+6]===1&&(rs.isWhiteHorizontal(P,T-4,T)||rs.isWhiteHorizontal(P,T+7,T+11))&&f++,j+6<v&&x[j][T]===1&&x[j+1][T]===0&&x[j+2][T]===1&&x[j+3][T]===1&&x[j+4][T]===1&&x[j+5][T]===0&&x[j+6][T]===1&&(rs.isWhiteVertical(x,T,j-4,j)||rs.isWhiteVertical(x,T,j+7,j+11))&&f++}return f*rs.N3}static isWhiteHorizontal(l,f,x){f=Math.max(f,0),x=Math.min(x,l.length);for(let b=f;b<x;b++)if(l[b]===1)return!1;return!0}static isWhiteVertical(l,f,x,b){x=Math.max(x,0),b=Math.min(b,l.length);for(let v=x;v<b;v++)if(l[v][f]===1)return!1;return!0}static applyMaskPenaltyRule4(l){let f=0;const x=l.getArray(),b=l.getWidth(),v=l.getHeight();for(let P=0;P<v;P++){const H=x[P];for(let de=0;de<b;de++)H[de]===1&&f++}const j=l.getHeight()*l.getWidth();return Math.floor(Math.abs(f*2-j)*10/j)*rs.N4}static getDataMaskBit(l,f,x){let b,v;switch(l){case 0:b=x+f&1;break;case 1:b=x&1;break;case 2:b=f%3;break;case 3:b=(x+f)%3;break;case 4:b=Math.floor(x/2)+Math.floor(f/3)&1;break;case 5:v=x*f,b=(v&1)+v%3;break;case 6:v=x*f,b=(v&1)+v%3&1;break;case 7:v=x*f,b=v%3+(x+f&1)&1;break;default:throw new w("Invalid mask pattern: "+l)}return b===0}static applyMaskPenaltyRule1Internal(l,f){let x=0;const b=f?l.getHeight():l.getWidth(),v=f?l.getWidth():l.getHeight(),j=l.getArray();for(let T=0;T<b;T++){let P=0,H=-1;for(let de=0;de<v;de++){const je=f?j[T][de]:j[de][T];je===H?P++:(P>=5&&(x+=rs.N1+(P-5)),P=1,H=je)}P>=5&&(x+=rs.N1+(P-5))}return x}}rs.N1=3,rs.N2=3,rs.N3=40,rs.N4=10;class Jo{constructor(l,f){this.width=l,this.height=f;const x=new Array(f);for(let b=0;b!==f;b++)x[b]=new Uint8Array(l);this.bytes=x}getHeight(){return this.height}getWidth(){return this.width}get(l,f){return this.bytes[f][l]}getArray(){return this.bytes}setNumber(l,f,x){this.bytes[f][l]=x}setBoolean(l,f,x){this.bytes[f][l]=x?1:0}clear(l){for(const f of this.bytes)R.fill(f,l)}equals(l){if(!(l instanceof Jo))return!1;const f=l;if(this.width!==f.width||this.height!==f.height)return!1;for(let x=0,b=this.height;x<b;++x){const v=this.bytes[x],j=f.bytes[x];for(let T=0,P=this.width;T<P;++T)if(v[T]!==j[T])return!1}return!0}toString(){const l=new ke;for(let f=0,x=this.height;f<x;++f){const b=this.bytes[f];for(let v=0,j=this.width;v<j;++v)switch(b[v]){case 0:l.append(" 0");break;case 1:l.append(" 1");break;default:l.append(" ");break}l.append(`
`)}return l.toString()}}class io{constructor(){this.maskPattern=-1}getMode(){return this.mode}getECLevel(){return this.ecLevel}getVersion(){return this.version}getMaskPattern(){return this.maskPattern}getMatrix(){return this.matrix}toString(){const l=new ke;return l.append(`<<
`),l.append(" mode: "),l.append(this.mode?this.mode.toString():"null"),l.append(`
ecLevel: `),l.append(this.ecLevel?this.ecLevel.toString():"null"),l.append(`
version: `),l.append(this.version?this.version.toString():"null"),l.append(`
maskPattern: `),l.append(this.maskPattern.toString()),this.matrix?(l.append(`
matrix:
`),l.append(this.matrix.toString())):l.append(`
matrix: null
`),l.append(`>>
`),l.toString()}setMode(l){this.mode=l}setECLevel(l){this.ecLevel=l}setVersion(l){this.version=l}setMaskPattern(l){this.maskPattern=l}setMatrix(l){this.matrix=l}static isValidMaskPattern(l){return l>=0&&l<io.NUM_MASK_PATTERNS}}io.NUM_MASK_PATTERNS=8;class za extends g{}za.kind="WriterException";class $r{constructor(){}static clearMatrix(l){l.clear(255)}static buildMatrix(l,f,x,b,v){$r.clearMatrix(v),$r.embedBasicPatterns(x,v),$r.embedTypeInfo(f,b,v),$r.maybeEmbedVersionInfo(x,v),$r.embedDataBits(l,b,v)}static embedBasicPatterns(l,f){$r.embedPositionDetectionPatternsAndSeparators(f),$r.embedDarkDotAtLeftBottomCorner(f),$r.maybeEmbedPositionAdjustmentPatterns(l,f),$r.embedTimingPatterns(f)}static embedTypeInfo(l,f,x){const b=new z;$r.makeTypeInfoBits(l,f,b);for(let v=0,j=b.getSize();v<j;++v){const T=b.get(b.getSize()-1-v),P=$r.TYPE_INFO_COORDINATES[v],H=P[0],de=P[1];if(x.setBoolean(H,de,T),v<8){const je=x.getWidth()-v-1;x.setBoolean(je,8,T)}else{const Ae=x.getHeight()-7+(v-8);x.setBoolean(8,Ae,T)}}}static maybeEmbedVersionInfo(l,f){if(l.getVersionNumber()<7)return;const x=new z;$r.makeVersionInfoBits(l,x);let b=17;for(let v=0;v<6;++v)for(let j=0;j<3;++j){const T=x.get(b);b--,f.setBoolean(v,f.getHeight()-11+j,T),f.setBoolean(f.getHeight()-11+j,v,T)}}static embedDataBits(l,f,x){let b=0,v=-1,j=x.getWidth()-1,T=x.getHeight()-1;for(;j>0;){for(j===6&&(j-=1);T>=0&&T<x.getHeight();){for(let P=0;P<2;++P){const H=j-P;if(!$r.isEmpty(x.get(H,T)))continue;let de;b<l.getSize()?(de=l.get(b),++b):de=!1,f!==255&&rs.getDataMaskBit(f,H,T)&&(de=!de),x.setBoolean(H,T,de)}T+=v}v=-v,T+=v,j-=2}if(b!==l.getSize())throw new za("Not all bits consumed: "+b+"/"+l.getSize())}static findMSBSet(l){return 32-F.numberOfLeadingZeros(l)}static calculateBCHCode(l,f){if(f===0)throw new w("0 polynomial");const x=$r.findMSBSet(f);for(l<<=x-1;$r.findMSBSet(l)>=x;)l^=f<<$r.findMSBSet(l)-x;return l}static makeTypeInfoBits(l,f,x){if(!io.isValidMaskPattern(f))throw new za("Invalid mask pattern");const b=l.getBits()<<3|f;x.appendBits(b,5);const v=$r.calculateBCHCode(b,$r.TYPE_INFO_POLY);x.appendBits(v,10);const j=new z;if(j.appendBits($r.TYPE_INFO_MASK_PATTERN,15),x.xor(j),x.getSize()!==15)throw new za("should not happen but we got: "+x.getSize())}static makeVersionInfoBits(l,f){f.appendBits(l.getVersionNumber(),6);const x=$r.calculateBCHCode(l.getVersionNumber(),$r.VERSION_INFO_POLY);if(f.appendBits(x,12),f.getSize()!==18)throw new za("should not happen but we got: "+f.getSize())}static isEmpty(l){return l===255}static embedTimingPatterns(l){for(let f=8;f<l.getWidth()-8;++f){const x=(f+1)%2;$r.isEmpty(l.get(f,6))&&l.setNumber(f,6,x),$r.isEmpty(l.get(6,f))&&l.setNumber(6,f,x)}}static embedDarkDotAtLeftBottomCorner(l){if(l.get(8,l.getHeight()-8)===0)throw new za;l.setNumber(8,l.getHeight()-8,1)}static embedHorizontalSeparationPattern(l,f,x){for(let b=0;b<8;++b){if(!$r.isEmpty(x.get(l+b,f)))throw new za;x.setNumber(l+b,f,0)}}static embedVerticalSeparationPattern(l,f,x){for(let b=0;b<7;++b){if(!$r.isEmpty(x.get(l,f+b)))throw new za;x.setNumber(l,f+b,0)}}static embedPositionAdjustmentPattern(l,f,x){for(let b=0;b<5;++b){const v=$r.POSITION_ADJUSTMENT_PATTERN[b];for(let j=0;j<5;++j)x.setNumber(l+j,f+b,v[j])}}static embedPositionDetectionPattern(l,f,x){for(let b=0;b<7;++b){const v=$r.POSITION_DETECTION_PATTERN[b];for(let j=0;j<7;++j)x.setNumber(l+j,f+b,v[j])}}static embedPositionDetectionPatternsAndSeparators(l){const f=$r.POSITION_DETECTION_PATTERN[0].length;$r.embedPositionDetectionPattern(0,0,l),$r.embedPositionDetectionPattern(l.getWidth()-f,0,l),$r.embedPositionDetectionPattern(0,l.getWidth()-f,l);const x=8;$r.embedHorizontalSeparationPattern(0,x-1,l),$r.embedHorizontalSeparationPattern(l.getWidth()-x,x-1,l),$r.embedHorizontalSeparationPattern(0,l.getWidth()-x,l);const b=7;$r.embedVerticalSeparationPattern(b,0,l),$r.embedVerticalSeparationPattern(l.getHeight()-b-1,0,l),$r.embedVerticalSeparationPattern(b,l.getHeight()-b,l)}static maybeEmbedPositionAdjustmentPatterns(l,f){if(l.getVersionNumber()<2)return;const x=l.getVersionNumber()-1,b=$r.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[x];for(let v=0,j=b.length;v!==j;v++){const T=b[v];if(T>=0)for(let P=0;P!==j;P++){const H=b[P];H>=0&&$r.isEmpty(f.get(H,T))&&$r.embedPositionAdjustmentPattern(H-2,T-2,f)}}}}$r.POSITION_DETECTION_PATTERN=Array.from([Int32Array.from([1,1,1,1,1,1,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,1,1,1,1,1,1])]),$r.POSITION_ADJUSTMENT_PATTERN=Array.from([Int32Array.from([1,1,1,1,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,0,1,0,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,1,1,1,1])]),$r.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE=Array.from([Int32Array.from([-1,-1,-1,-1,-1,-1,-1]),Int32Array.from([6,18,-1,-1,-1,-1,-1]),Int32Array.from([6,22,-1,-1,-1,-1,-1]),Int32Array.from([6,26,-1,-1,-1,-1,-1]),Int32Array.from([6,30,-1,-1,-1,-1,-1]),Int32Array.from([6,34,-1,-1,-1,-1,-1]),Int32Array.from([6,22,38,-1,-1,-1,-1]),Int32Array.from([6,24,42,-1,-1,-1,-1]),Int32Array.from([6,26,46,-1,-1,-1,-1]),Int32Array.from([6,28,50,-1,-1,-1,-1]),Int32Array.from([6,30,54,-1,-1,-1,-1]),Int32Array.from([6,32,58,-1,-1,-1,-1]),Int32Array.from([6,34,62,-1,-1,-1,-1]),Int32Array.from([6,26,46,66,-1,-1,-1]),Int32Array.from([6,26,48,70,-1,-1,-1]),Int32Array.from([6,26,50,74,-1,-1,-1]),Int32Array.from([6,30,54,78,-1,-1,-1]),Int32Array.from([6,30,56,82,-1,-1,-1]),Int32Array.from([6,30,58,86,-1,-1,-1]),Int32Array.from([6,34,62,90,-1,-1,-1]),Int32Array.from([6,28,50,72,94,-1,-1]),Int32Array.from([6,26,50,74,98,-1,-1]),Int32Array.from([6,30,54,78,102,-1,-1]),Int32Array.from([6,28,54,80,106,-1,-1]),Int32Array.from([6,32,58,84,110,-1,-1]),Int32Array.from([6,30,58,86,114,-1,-1]),Int32Array.from([6,34,62,90,118,-1,-1]),Int32Array.from([6,26,50,74,98,122,-1]),Int32Array.from([6,30,54,78,102,126,-1]),Int32Array.from([6,26,52,78,104,130,-1]),Int32Array.from([6,30,56,82,108,134,-1]),Int32Array.from([6,34,60,86,112,138,-1]),Int32Array.from([6,30,58,86,114,142,-1]),Int32Array.from([6,34,62,90,118,146,-1]),Int32Array.from([6,30,54,78,102,126,150]),Int32Array.from([6,24,50,76,102,128,154]),Int32Array.from([6,28,54,80,106,132,158]),Int32Array.from([6,32,58,84,110,136,162]),Int32Array.from([6,26,54,82,110,138,166]),Int32Array.from([6,30,58,86,114,142,170])]),$r.TYPE_INFO_COORDINATES=Array.from([Int32Array.from([8,0]),Int32Array.from([8,1]),Int32Array.from([8,2]),Int32Array.from([8,3]),Int32Array.from([8,4]),Int32Array.from([8,5]),Int32Array.from([8,7]),Int32Array.from([8,8]),Int32Array.from([7,8]),Int32Array.from([5,8]),Int32Array.from([4,8]),Int32Array.from([3,8]),Int32Array.from([2,8]),Int32Array.from([1,8]),Int32Array.from([0,8])]),$r.VERSION_INFO_POLY=7973,$r.TYPE_INFO_POLY=1335,$r.TYPE_INFO_MASK_PATTERN=21522;class bc{constructor(l,f){this.dataBytes=l,this.errorCorrectionBytes=f}getDataBytes(){return this.dataBytes}getErrorCorrectionBytes(){return this.errorCorrectionBytes}}class Wa{constructor(){}static calculateMaskPenalty(l){return rs.applyMaskPenaltyRule1(l)+rs.applyMaskPenaltyRule2(l)+rs.applyMaskPenaltyRule3(l)+rs.applyMaskPenaltyRule4(l)}static encode(l,f,x=null){let b=Wa.DEFAULT_BYTE_MODE_ENCODING;const v=x!==null&&x.get(ts.CHARACTER_SET)!==void 0;v&&(b=x.get(ts.CHARACTER_SET).toString());const j=this.chooseMode(l,b),T=new z;if(j===xr.BYTE&&(v||Wa.DEFAULT_BYTE_MODE_ENCODING!==b)){const Ue=G.getCharacterSetECIByName(b);Ue!==void 0&&this.appendECI(Ue,T)}this.appendModeInfo(j,T);const P=new z;this.appendBytes(l,j,P,b);let H;if(x!==null&&x.get(ts.QR_VERSION)!==void 0){const Ue=Number.parseInt(x.get(ts.QR_VERSION).toString(),10);H=Qt.getVersionForNumber(Ue);const ht=this.calculateBitsNeeded(j,T,P,H);if(!this.willFit(ht,H,f))throw new za("Data too big for requested version")}else H=this.recommendVersion(f,j,T,P);const de=new z;de.appendBitArray(T);const je=j===xr.BYTE?P.getSizeInBytes():l.length;this.appendLengthInfo(je,H,j,de),de.appendBitArray(P);const Ae=H.getECBlocksForLevel(f),Ge=H.getTotalCodewords()-Ae.getTotalECCodewords();this.terminateBits(Ge,de);const ot=this.interleaveWithECBytes(de,H.getTotalCodewords(),Ge,Ae.getNumBlocks()),ut=new io;ut.setECLevel(f),ut.setMode(j),ut.setVersion(H);const At=H.getDimensionForVersion(),se=new Jo(At,At),Ee=this.chooseMaskPattern(ot,f,H,se);return ut.setMaskPattern(Ee),$r.buildMatrix(ot,f,H,Ee,se),ut.setMatrix(se),ut}static recommendVersion(l,f,x,b){const v=this.calculateBitsNeeded(f,x,b,Qt.getVersionForNumber(1)),j=this.chooseVersion(v,l),T=this.calculateBitsNeeded(f,x,b,j);return this.chooseVersion(T,l)}static calculateBitsNeeded(l,f,x,b){return f.getSize()+l.getCharacterCountBits(b)+x.getSize()}static getAlphanumericCode(l){return l<Wa.ALPHANUMERIC_TABLE.length?Wa.ALPHANUMERIC_TABLE[l]:-1}static chooseMode(l,f=null){if(G.SJIS.getName()===f&&this.isOnlyDoubleByteKanji(l))return xr.KANJI;let x=!1,b=!1;for(let v=0,j=l.length;v<j;++v){const T=l.charAt(v);if(Wa.isDigit(T))x=!0;else if(this.getAlphanumericCode(T.charCodeAt(0))!==-1)b=!0;else return xr.BYTE}return b?xr.ALPHANUMERIC:x?xr.NUMERIC:xr.BYTE}static isOnlyDoubleByteKanji(l){let f;try{f=fe.encode(l,G.SJIS)}catch(b){return!1}const x=f.length;if(x%2!==0)return!1;for(let b=0;b<x;b+=2){const v=f[b]&255;if((v<129||v>159)&&(v<224||v>235))return!1}return!0}static chooseMaskPattern(l,f,x,b){let v=Number.MAX_SAFE_INTEGER,j=-1;for(let T=0;T<io.NUM_MASK_PATTERNS;T++){$r.buildMatrix(l,f,x,T,b);let P=this.calculateMaskPenalty(b);P<v&&(v=P,j=T)}return j}static chooseVersion(l,f){for(let x=1;x<=40;x++){const b=Qt.getVersionForNumber(x);if(Wa.willFit(l,b,f))return b}throw new za("Data too big")}static willFit(l,f,x){const b=f.getTotalCodewords(),j=f.getECBlocksForLevel(x).getTotalECCodewords(),T=b-j,P=(l+7)/8;return T>=P}static terminateBits(l,f){const x=l*8;if(f.getSize()>x)throw new za("data bits cannot fit in the QR Code"+f.getSize()+" > "+x);for(let j=0;j<4&&f.getSize()<x;++j)f.appendBit(!1);const b=f.getSize()&7;if(b>0)for(let j=b;j<8;j++)f.appendBit(!1);const v=l-f.getSizeInBytes();for(let j=0;j<v;++j)f.appendBits((j&1)===0?236:17,8);if(f.getSize()!==x)throw new za("Bits size does not equal capacity")}static getNumDataBytesAndNumECBytesForBlockID(l,f,x,b,v,j){if(b>=x)throw new za("Block ID too large");const T=l%x,P=x-T,H=Math.floor(l/x),de=H+1,je=Math.floor(f/x),Ae=je+1,Ge=H-je,ot=de-Ae;if(Ge!==ot)throw new za("EC bytes mismatch");if(x!==P+T)throw new za("RS blocks mismatch");if(l!==(je+Ge)*P+(Ae+ot)*T)throw new za("Total bytes mismatch");b<P?(v[0]=je,j[0]=Ge):(v[0]=Ae,j[0]=ot)}static interleaveWithECBytes(l,f,x,b){if(l.getSizeInBytes()!==x)throw new za("Number of bits and data bytes does not match");let v=0,j=0,T=0;const P=new Array;for(let de=0;de<b;++de){const je=new Int32Array(1),Ae=new Int32Array(1);Wa.getNumDataBytesAndNumECBytesForBlockID(f,x,b,de,je,Ae);const Ge=je[0],ot=new Uint8Array(Ge);l.toBytes(8*v,ot,0,Ge);const ut=Wa.generateECBytes(ot,Ae[0]);P.push(new bc(ot,ut)),j=Math.max(j,Ge),T=Math.max(T,ut.length),v+=je[0]}if(x!==v)throw new za("Data bytes does not match offset");const H=new z;for(let de=0;de<j;++de)for(const je of P){const Ae=je.getDataBytes();de<Ae.length&&H.appendBits(Ae[de],8)}for(let de=0;de<T;++de)for(const je of P){const Ae=je.getErrorCorrectionBytes();de<Ae.length&&H.appendBits(Ae[de],8)}if(f!==H.getSizeInBytes())throw new za("Interleaving error: "+f+" and "+H.getSizeInBytes()+" differ.");return H}static generateECBytes(l,f){const x=l.length,b=new Int32Array(x+f);for(let j=0;j<x;j++)b[j]=l[j]&255;new Ko(rt.QR_CODE_FIELD_256).encode(b,f);const v=new Uint8Array(f);for(let j=0;j<f;j++)v[j]=b[x+j];return v}static appendModeInfo(l,f){f.appendBits(l.getBits(),4)}static appendLengthInfo(l,f,x,b){const v=x.getCharacterCountBits(f);if(l>=1<<v)throw new za(l+" is bigger than "+((1<<v)-1));b.appendBits(l,v)}static appendBytes(l,f,x,b){switch(f){case xr.NUMERIC:Wa.appendNumericBytes(l,x);break;case xr.ALPHANUMERIC:Wa.appendAlphanumericBytes(l,x);break;case xr.BYTE:Wa.append8BitBytes(l,x,b);break;case xr.KANJI:Wa.appendKanjiBytes(l,x);break;default:throw new za("Invalid mode: "+f)}}static getDigit(l){return l.charCodeAt(0)-48}static isDigit(l){const f=Wa.getDigit(l);return f>=0&&f<=9}static appendNumericBytes(l,f){const x=l.length;let b=0;for(;b<x;){const v=Wa.getDigit(l.charAt(b));if(b+2<x){const j=Wa.getDigit(l.charAt(b+1)),T=Wa.getDigit(l.charAt(b+2));f.appendBits(v*100+j*10+T,10),b+=3}else if(b+1<x){const j=Wa.getDigit(l.charAt(b+1));f.appendBits(v*10+j,7),b+=2}else f.appendBits(v,4),b++}}static appendAlphanumericBytes(l,f){const x=l.length;let b=0;for(;b<x;){const v=Wa.getAlphanumericCode(l.charCodeAt(b));if(v===-1)throw new za;if(b+1<x){const j=Wa.getAlphanumericCode(l.charCodeAt(b+1));if(j===-1)throw new za;f.appendBits(v*45+j,11),b+=2}else f.appendBits(v,6),b++}}static append8BitBytes(l,f,x){let b;try{b=fe.encode(l,x)}catch(v){throw new za(v)}for(let v=0,j=b.length;v!==j;v++){const T=b[v];f.appendBits(T,8)}}static appendKanjiBytes(l,f){let x;try{x=fe.encode(l,G.SJIS)}catch(v){throw new za(v)}const b=x.length;for(let v=0;v<b;v+=2){const j=x[v]&255,T=x[v+1]&255,P=j<<8&4294967295|T;let H=-1;if(P>=33088&&P<=40956?H=P-33088:P>=57408&&P<=60351&&(H=P-49472),H===-1)throw new za("Invalid byte sequence");const de=(H>>8)*192+(H&255);f.appendBits(de,13)}}static appendECI(l,f){f.appendBits(xr.ECI.getBits(),4),f.appendBits(l.getValue(),8)}}Wa.ALPHANUMERIC_TABLE=Int32Array.from([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,36,-1,-1,-1,37,38,-1,-1,-1,-1,39,40,-1,41,42,43,0,1,2,3,4,5,6,7,8,9,44,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,-1,-1,-1,-1,-1]),Wa.DEFAULT_BYTE_MODE_ENCODING=G.UTF8.getName();class Un{write(l,f,x,b=null){if(l.length===0)throw new w("Found empty contents");if(f<0||x<0)throw new w("Requested dimensions are too small: "+f+"x"+x);let v=Wr.L,j=Un.QUIET_ZONE_SIZE;b!==null&&(b.get(ts.ERROR_CORRECTION)!==void 0&&(v=Wr.fromString(b.get(ts.ERROR_CORRECTION).toString())),b.get(ts.MARGIN)!==void 0&&(j=Number.parseInt(b.get(ts.MARGIN).toString(),10)));const T=Wa.encode(l,v,b);return this.renderResult(T,f,x,j)}writeToDom(l,f,x,b,v=null){typeof l=="string"&&(l=document.querySelector(l));const j=this.write(f,x,b,v);l&&l.appendChild(j)}renderResult(l,f,x,b){const v=l.getMatrix();if(v===null)throw new et;const j=v.getWidth(),T=v.getHeight(),P=j+b*2,H=T+b*2,de=Math.max(f,P),je=Math.max(x,H),Ae=Math.min(Math.floor(de/P),Math.floor(je/H)),Ge=Math.floor((de-j*Ae)/2),ot=Math.floor((je-T*Ae)/2),ut=this.createSVGElement(de,je);for(let At=0,se=ot;At<T;At++,se+=Ae)for(let Ee=0,Ue=Ge;Ee<j;Ee++,Ue+=Ae)if(v.get(Ee,At)===1){const ht=this.createSvgRectElement(Ue,se,Ae,Ae);ut.appendChild(ht)}return ut}createSVGElement(l,f){const x=document.createElementNS(Un.SVG_NS,"svg");return x.setAttributeNS(null,"height",l.toString()),x.setAttributeNS(null,"width",f.toString()),x}createSvgRectElement(l,f,x,b){const v=document.createElementNS(Un.SVG_NS,"rect");return v.setAttributeNS(null,"x",l.toString()),v.setAttributeNS(null,"y",f.toString()),v.setAttributeNS(null,"height",x.toString()),v.setAttributeNS(null,"width",b.toString()),v.setAttributeNS(null,"fill","#000000"),v}}Un.QUIET_ZONE_SIZE=4,Un.SVG_NS="http://www.w3.org/2000/svg";class zn{encode(l,f,x,b,v){if(l.length===0)throw new w("Found empty contents");if(f!==le.QR_CODE)throw new w("Can only encode QR_CODE, but got "+f);if(x<0||b<0)throw new w(`Requested dimensions are too small: ${x}x${b}`);let j=Wr.L,T=zn.QUIET_ZONE_SIZE;v!==null&&(v.get(ts.ERROR_CORRECTION)!==void 0&&(j=Wr.fromString(v.get(ts.ERROR_CORRECTION).toString())),v.get(ts.MARGIN)!==void 0&&(T=Number.parseInt(v.get(ts.MARGIN).toString(),10)));const P=Wa.encode(l,j,v);return zn.renderResult(P,x,b,T)}static renderResult(l,f,x,b){const v=l.getMatrix();if(v===null)throw new et;const j=v.getWidth(),T=v.getHeight(),P=j+b*2,H=T+b*2,de=Math.max(f,P),je=Math.max(x,H),Ae=Math.min(Math.floor(de/P),Math.floor(je/H)),Ge=Math.floor((de-j*Ae)/2),ot=Math.floor((je-T*Ae)/2),ut=new ge(de,je);for(let At=0,se=ot;At<T;At++,se+=Ae)for(let Ee=0,Ue=Ge;Ee<j;Ee++,Ue+=Ae)v.get(Ee,At)===1&&ut.setRegion(Ue,se,Ae,Ae);return ut}}zn.QUIET_ZONE_SIZE=4;class Vi{encode(l,f,x,b,v){let j;switch(f){case le.QR_CODE:j=new zn;break;default:throw new w("No encoder available for format "+f)}return j.encode(l,f,x,b,v)}}class ai extends ve{constructor(l,f,x,b,v,j,T,P){if(super(j,T),this.yuvData=l,this.dataWidth=f,this.dataHeight=x,this.left=b,this.top=v,b+j>f||v+T>x)throw new w("Crop rectangle does not fit within image data.");P&&this.reverseHorizontal(j,T)}getRow(l,f){if(l<0||l>=this.getHeight())throw new w("Requested row is outside the image: "+l);const x=this.getWidth();(f==null||f.length<x)&&(f=new Uint8ClampedArray(x));const b=(l+this.top)*this.dataWidth+this.left;return C.arraycopy(this.yuvData,b,f,0,x),f}getMatrix(){const l=this.getWidth(),f=this.getHeight();if(l===this.dataWidth&&f===this.dataHeight)return this.yuvData;const x=l*f,b=new Uint8ClampedArray(x);let v=this.top*this.dataWidth+this.left;if(l===this.dataWidth)return C.arraycopy(this.yuvData,v,b,0,x),b;for(let j=0;j<f;j++){const T=j*l;C.arraycopy(this.yuvData,v,b,T,l),v+=this.dataWidth}return b}isCropSupported(){return!0}crop(l,f,x,b){return new ai(this.yuvData,this.dataWidth,this.dataHeight,this.left+l,this.top+f,x,b,!1)}renderThumbnail(){const l=this.getWidth()/ai.THUMBNAIL_SCALE_FACTOR,f=this.getHeight()/ai.THUMBNAIL_SCALE_FACTOR,x=new Int32Array(l*f),b=this.yuvData;let v=this.top*this.dataWidth+this.left;for(let j=0;j<f;j++){const T=j*l;for(let P=0;P<l;P++){const H=b[v+P*ai.THUMBNAIL_SCALE_FACTOR]&255;x[T+P]=4278190080|H*65793}v+=this.dataWidth*ai.THUMBNAIL_SCALE_FACTOR}return x}getThumbnailWidth(){return this.getWidth()/ai.THUMBNAIL_SCALE_FACTOR}getThumbnailHeight(){return this.getHeight()/ai.THUMBNAIL_SCALE_FACTOR}reverseHorizontal(l,f){const x=this.yuvData;for(let b=0,v=this.top*this.dataWidth+this.left;b<f;b++,v+=this.dataWidth){const j=v+l/2;for(let T=v,P=v+l-1;T<j;T++,P--){const H=x[T];x[T]=x[P],x[P]=H}}}invert(){return new ce(this)}}ai.THUMBNAIL_SCALE_FACTOR=2;class oo extends ve{constructor(l,f,x,b,v,j,T){if(super(f,x),this.dataWidth=b,this.dataHeight=v,this.left=j,this.top=T,l.BYTES_PER_ELEMENT===4){const P=f*x,H=new Uint8ClampedArray(P);for(let de=0;de<P;de++){const je=l[de],Ae=je>>16&255,Ge=je>>7&510,ot=je&255;H[de]=(Ae+Ge+ot)/4&255}this.luminances=H}else this.luminances=l;if(b===void 0&&(this.dataWidth=f),v===void 0&&(this.dataHeight=x),j===void 0&&(this.left=0),T===void 0&&(this.top=0),this.left+f>this.dataWidth||this.top+x>this.dataHeight)throw new w("Crop rectangle does not fit within image data.")}getRow(l,f){if(l<0||l>=this.getHeight())throw new w("Requested row is outside the image: "+l);const x=this.getWidth();(f==null||f.length<x)&&(f=new Uint8ClampedArray(x));const b=(l+this.top)*this.dataWidth+this.left;return C.arraycopy(this.luminances,b,f,0,x),f}getMatrix(){const l=this.getWidth(),f=this.getHeight();if(l===this.dataWidth&&f===this.dataHeight)return this.luminances;const x=l*f,b=new Uint8ClampedArray(x);let v=this.top*this.dataWidth+this.left;if(l===this.dataWidth)return C.arraycopy(this.luminances,v,b,0,x),b;for(let j=0;j<f;j++){const T=j*l;C.arraycopy(this.luminances,v,b,T,l),v+=this.dataWidth}return b}isCropSupported(){return!0}crop(l,f,x,b){return new oo(this.luminances,x,b,this.dataWidth,this.dataHeight,this.left+l,this.top+f)}invert(){return new ce(this)}}class On extends G{static forName(l){return this.getCharacterSetECIByName(l)}}class Eo{}Eo.ISO_8859_1=G.ISO8859_1;class lo{isCompact(){return this.compact}setCompact(l){this.compact=l}getSize(){return this.size}setSize(l){this.size=l}getLayers(){return this.layers}setLayers(l){this.layers=l}getCodeWords(){return this.codeWords}setCodeWords(l){this.codeWords=l}getMatrix(){return this.matrix}setMatrix(l){this.matrix=l}}class vc{static singletonList(l){return[l]}static min(l,f){return l.sort(f)[0]}}class yl{constructor(l){this.previous=l}getPrevious(){return this.previous}}class xi extends yl{constructor(l,f,x){super(l),this.value=f,this.bitCount=x}appendTo(l,f){l.appendBits(this.value,this.bitCount)}add(l,f){return new xi(this,l,f)}addBinaryShift(l,f){return console.warn("addBinaryShift on SimpleToken, this simply returns a copy of this token"),new xi(this,l,f)}toString(){let l=this.value&(1<<this.bitCount)-1;return l|=1<<this.bitCount,"<"+F.toBinaryString(l|1<<this.bitCount).substring(1)+">"}}class ds extends xi{constructor(l,f,x){super(l,0,0),this.binaryShiftStart=f,this.binaryShiftByteCount=x}appendTo(l,f){for(let x=0;x<this.binaryShiftByteCount;x++)(x===0||x===31&&this.binaryShiftByteCount<=62)&&(l.appendBits(31,5),this.binaryShiftByteCount>62?l.appendBits(this.binaryShiftByteCount-31,16):x===0?l.appendBits(Math.min(this.binaryShiftByteCount,31),5):l.appendBits(this.binaryShiftByteCount-31,5)),l.appendBits(f[this.binaryShiftStart+x],8)}addBinaryShift(l,f){return new ds(this,l,f)}toString(){return"<"+this.binaryShiftStart+"::"+(this.binaryShiftStart+this.binaryShiftByteCount-1)+">"}}function Ul(Ne,l,f){return new ds(Ne,l,f)}function co(Ne,l,f){return new xi(Ne,l,f)}const To=["UPPER","LOWER","DIGIT","MIXED","PUNCT"],Rs=0,Di=1,Wn=2,si=3,ni=4,pi=new xi(null,0,0),yi=[Int32Array.from([0,(5<<16)+28,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(9<<16)+480+14,0,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(4<<16)+14,(9<<16)+448+28,0,(9<<16)+448+29,932798]),Int32Array.from([(5<<16)+29,(5<<16)+28,656318,0,(5<<16)+30]),Int32Array.from([(5<<16)+31,656380,656382,656381,0])];function Qo(Ne){for(let l of Ne)R.fill(l,-1);return Ne[Rs][ni]=0,Ne[Di][ni]=0,Ne[Di][Rs]=28,Ne[si][ni]=0,Ne[Wn][ni]=0,Ne[Wn][Rs]=15,Ne}const Ao=Qo(R.createInt32Array(6,6));class gn{constructor(l,f,x,b){this.token=l,this.mode=f,this.binaryShiftByteCount=x,this.bitCount=b}getMode(){return this.mode}getToken(){return this.token}getBinaryShiftByteCount(){return this.binaryShiftByteCount}getBitCount(){return this.bitCount}latchAndAppend(l,f){let x=this.bitCount,b=this.token;if(l!==this.mode){let j=yi[this.mode][l];b=co(b,j&65535,j>>16),x+=j>>16}let v=l===Wn?4:5;return b=co(b,f,v),new gn(b,l,0,x+v)}shiftAndAppend(l,f){let x=this.token,b=this.mode===Wn?4:5;return x=co(x,Ao[this.mode][l],b),x=co(x,f,5),new gn(x,this.mode,0,this.bitCount+b+5)}addBinaryShiftChar(l){let f=this.token,x=this.mode,b=this.bitCount;if(this.mode===ni||this.mode===Wn){let T=yi[x][Rs];f=co(f,T&65535,T>>16),b+=T>>16,x=Rs}let v=this.binaryShiftByteCount===0||this.binaryShiftByteCount===31?18:this.binaryShiftByteCount===62?9:8,j=new gn(f,x,this.binaryShiftByteCount+1,b+v);return j.binaryShiftByteCount===2078&&(j=j.endBinaryShift(l+1)),j}endBinaryShift(l){if(this.binaryShiftByteCount===0)return this;let f=this.token;return f=Ul(f,l-this.binaryShiftByteCount,this.binaryShiftByteCount),new gn(f,this.mode,0,this.bitCount)}isBetterThanOrEqualTo(l){let f=this.bitCount+(yi[this.mode][l.mode]>>16);return this.binaryShiftByteCount<l.binaryShiftByteCount?f+=gn.calculateBinaryShiftCost(l)-gn.calculateBinaryShiftCost(this):this.binaryShiftByteCount>l.binaryShiftByteCount&&l.binaryShiftByteCount>0&&(f+=10),f<=l.bitCount}toBitArray(l){let f=[];for(let b=this.endBinaryShift(l.length).token;b!==null;b=b.getPrevious())f.unshift(b);let x=new z;for(const b of f)b.appendTo(x,l);return x}toString(){return K.format("%s bits=%d bytes=%d",To[this.mode],this.bitCount,this.binaryShiftByteCount)}static calculateBinaryShiftCost(l){return l.binaryShiftByteCount>62?21:l.binaryShiftByteCount>31?20:l.binaryShiftByteCount>0?10:0}}gn.INITIAL_STATE=new gn(pi,Rs,0,0);function zl(Ne){const l=K.getCharCode(" "),f=K.getCharCode("."),x=K.getCharCode(",");Ne[Rs][l]=1;const b=K.getCharCode("Z"),v=K.getCharCode("A");for(let Ae=v;Ae<=b;Ae++)Ne[Rs][Ae]=Ae-v+2;Ne[Di][l]=1;const j=K.getCharCode("z"),T=K.getCharCode("a");for(let Ae=T;Ae<=j;Ae++)Ne[Di][Ae]=Ae-T+2;Ne[Wn][l]=1;const P=K.getCharCode("9"),H=K.getCharCode("0");for(let Ae=H;Ae<=P;Ae++)Ne[Wn][Ae]=Ae-H+2;Ne[Wn][x]=12,Ne[Wn][f]=13;const de=["\0"," ","","","","","","","\x07","\b"," ",`
`,"\v","\f","\r","\x1B","","","","","@","\\","^","_","`","|","~",""];for(let Ae=0;Ae<de.length;Ae++)Ne[si][K.getCharCode(de[Ae])]=Ae;const je=["\0","\r","\0","\0","\0","\0","!","'","#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}"];for(let Ae=0;Ae<je.length;Ae++)K.getCharCode(je[Ae])>0&&(Ne[ni][K.getCharCode(je[Ae])]=Ae);return Ne}const Hn=zl(R.createInt32Array(5,256));class ii{constructor(l){this.text=l}encode(){const l=K.getCharCode(" "),f=K.getCharCode(`
`);let x=vc.singletonList(gn.INITIAL_STATE);for(let v=0;v<this.text.length;v++){let j,T=v+1<this.text.length?this.text[v+1]:0;switch(this.text[v]){case K.getCharCode("\r"):j=T===f?2:0;break;case K.getCharCode("."):j=T===l?3:0;break;case K.getCharCode(","):j=T===l?4:0;break;case K.getCharCode(":"):j=T===l?5:0;break;default:j=0}j>0?(x=ii.updateStateListForPair(x,v,j),v++):x=this.updateStateListForChar(x,v)}return vc.min(x,(v,j)=>v.getBitCount()-j.getBitCount()).toBitArray(this.text)}updateStateListForChar(l,f){const x=[];for(let b of l)this.updateStateForChar(b,f,x);return ii.simplifyStates(x)}updateStateForChar(l,f,x){let b=this.text[f]&255,v=Hn[l.getMode()][b]>0,j=null;for(let T=0;T<=ni;T++){let P=Hn[T][b];if(P>0){if(j==null&&(j=l.endBinaryShift(f)),!v||T===l.getMode()||T===Wn){const H=j.latchAndAppend(T,P);x.push(H)}if(!v&&Ao[l.getMode()][T]>=0){const H=j.shiftAndAppend(T,P);x.push(H)}}}if(l.getBinaryShiftByteCount()>0||Hn[l.getMode()][b]===0){let T=l.addBinaryShiftChar(f);x.push(T)}}static updateStateListForPair(l,f,x){const b=[];for(let v of l)this.updateStateForPair(v,f,x,b);return this.simplifyStates(b)}static updateStateForPair(l,f,x,b){let v=l.endBinaryShift(f);if(b.push(v.latchAndAppend(ni,x)),l.getMode()!==ni&&b.push(v.shiftAndAppend(ni,x)),x===3||x===4){let j=v.latchAndAppend(Wn,16-x).latchAndAppend(Wn,1);b.push(j)}if(l.getBinaryShiftByteCount()>0){let j=l.addBinaryShiftChar(f).addBinaryShiftChar(f+1);b.push(j)}}static simplifyStates(l){let f=[];for(const x of l){let b=!0;for(const v of f){if(v.isBetterThanOrEqualTo(x)){b=!1;break}x.isBetterThanOrEqualTo(v)&&(f=f.filter(j=>j!==v))}b&&f.push(x)}return f}}class ja{constructor(){}static encodeBytes(l){return ja.encode(l,ja.DEFAULT_EC_PERCENT,ja.DEFAULT_AZTEC_LAYERS)}static encode(l,f,x){let b=new ii(l).encode(),v=F.truncDivision(b.getSize()*f,100)+11,j=b.getSize()+v,T,P,H,de,je;if(x!==ja.DEFAULT_AZTEC_LAYERS){if(T=x<0,P=Math.abs(x),P>(T?ja.MAX_NB_BITS_COMPACT:ja.MAX_NB_BITS))throw new w(K.format("Illegal value %s for layers",x));H=ja.totalBitsInLayer(P,T),de=ja.WORD_SIZE[P];let ht=H-H%de;if(je=ja.stuffBits(b,de),je.getSize()+v>ht)throw new w("Data to large for user specified layer");if(T&&je.getSize()>de*64)throw new w("Data to large for user specified layer")}else{de=0,je=null;for(let ht=0;;ht++){if(ht>ja.MAX_NB_BITS)throw new w("Data too large for an Aztec code");if(T=ht<=3,P=T?ht+1:ht,H=ja.totalBitsInLayer(P,T),j>H)continue;(je==null||de!==ja.WORD_SIZE[P])&&(de=ja.WORD_SIZE[P],je=ja.stuffBits(b,de));let ur=H-H%de;if(!(T&&je.getSize()>de*64)&&je.getSize()+v<=ur)break}}let Ae=ja.generateCheckWords(je,H,de),Ge=je.getSize()/de,ot=ja.generateModeMessage(T,P,Ge),ut=(T?11:14)+P*4,At=new Int32Array(ut),se;if(T){se=ut;for(let ht=0;ht<At.length;ht++)At[ht]=ht}else{se=ut+1+2*F.truncDivision(F.truncDivision(ut,2)-1,15);let ht=F.truncDivision(ut,2),ur=F.truncDivision(se,2);for(let tr=0;tr<ht;tr++){let Ar=tr+F.truncDivision(tr,15);At[ht-tr-1]=ur-Ar-1,At[ht+tr]=ur+Ar+1}}let Ee=new ge(se);for(let ht=0,ur=0;ht<P;ht++){let tr=(P-ht)*4+(T?9:12);for(let Ar=0;Ar<tr;Ar++){let ra=Ar*2;for(let La=0;La<2;La++)Ae.get(ur+ra+La)&&Ee.set(At[ht*2+La],At[ht*2+Ar]),Ae.get(ur+tr*2+ra+La)&&Ee.set(At[ht*2+Ar],At[ut-1-ht*2-La]),Ae.get(ur+tr*4+ra+La)&&Ee.set(At[ut-1-ht*2-La],At[ut-1-ht*2-Ar]),Ae.get(ur+tr*6+ra+La)&&Ee.set(At[ut-1-ht*2-Ar],At[ht*2+La])}ur+=tr*8}if(ja.drawModeMessage(Ee,T,se,ot),T)ja.drawBullsEye(Ee,F.truncDivision(se,2),5);else{ja.drawBullsEye(Ee,F.truncDivision(se,2),7);for(let ht=0,ur=0;ht<F.truncDivision(ut,2)-1;ht+=15,ur+=16)for(let tr=F.truncDivision(se,2)&1;tr<se;tr+=2)Ee.set(F.truncDivision(se,2)-ur,tr),Ee.set(F.truncDivision(se,2)+ur,tr),Ee.set(tr,F.truncDivision(se,2)-ur),Ee.set(tr,F.truncDivision(se,2)+ur)}let Ue=new lo;return Ue.setCompact(T),Ue.setSize(se),Ue.setLayers(P),Ue.setCodeWords(Ge),Ue.setMatrix(Ee),Ue}static drawBullsEye(l,f,x){for(let b=0;b<x;b+=2)for(let v=f-b;v<=f+b;v++)l.set(v,f-b),l.set(v,f+b),l.set(f-b,v),l.set(f+b,v);l.set(f-x,f-x),l.set(f-x+1,f-x),l.set(f-x,f-x+1),l.set(f+x,f-x),l.set(f+x,f-x+1),l.set(f+x,f+x-1)}static generateModeMessage(l,f,x){let b=new z;return l?(b.appendBits(f-1,2),b.appendBits(x-1,6),b=ja.generateCheckWords(b,28,4)):(b.appendBits(f-1,5),b.appendBits(x-1,11),b=ja.generateCheckWords(b,40,4)),b}static drawModeMessage(l,f,x,b){let v=F.truncDivision(x,2);if(f)for(let j=0;j<7;j++){let T=v-3+j;b.get(j)&&l.set(T,v-5),b.get(j+7)&&l.set(v+5,T),b.get(20-j)&&l.set(T,v+5),b.get(27-j)&&l.set(v-5,T)}else for(let j=0;j<10;j++){let T=v-5+j+F.truncDivision(j,5);b.get(j)&&l.set(T,v-7),b.get(j+10)&&l.set(v+7,T),b.get(29-j)&&l.set(T,v+7),b.get(39-j)&&l.set(v-7,T)}}static generateCheckWords(l,f,x){let b=l.getSize()/x,v=new Ko(ja.getGF(x)),j=F.truncDivision(f,x),T=ja.bitsToWords(l,x,j);v.encode(T,j-b);let P=f%x,H=new z;H.appendBits(0,P);for(const de of Array.from(T))H.appendBits(de,x);return H}static bitsToWords(l,f,x){let b=new Int32Array(x),v,j;for(v=0,j=l.getSize()/f;v<j;v++){let T=0;for(let P=0;P<f;P++)T|=l.get(v*f+P)?1<<f-P-1:0;b[v]=T}return b}static getGF(l){switch(l){case 4:return rt.AZTEC_PARAM;case 6:return rt.AZTEC_DATA_6;case 8:return rt.AZTEC_DATA_8;case 10:return rt.AZTEC_DATA_10;case 12:return rt.AZTEC_DATA_12;default:throw new w("Unsupported word size "+l)}}static stuffBits(l,f){let x=new z,b=l.getSize(),v=(1<<f)-2;for(let j=0;j<b;j+=f){let T=0;for(let P=0;P<f;P++)(j+P>=b||l.get(j+P))&&(T|=1<<f-1-P);(T&v)===v?(x.appendBits(T&v,f),j--):(T&v)===0?(x.appendBits(T|1,f),j--):x.appendBits(T,f)}return x}static totalBitsInLayer(l,f){return((f?88:112)+16*l)*l}}ja.DEFAULT_EC_PERCENT=33,ja.DEFAULT_AZTEC_LAYERS=0,ja.MAX_NB_BITS=32,ja.MAX_NB_BITS_COMPACT=4,ja.WORD_SIZE=Int32Array.from([4,6,6,8,8,8,8,8,8,10,10,10,10,10,10,10,10,10,10,10,10,10,10,12,12,12,12,12,12,12,12,12,12]);class tn{encode(l,f,x,b){return this.encodeWithHints(l,f,x,b,null)}encodeWithHints(l,f,x,b,v){let j=Eo.ISO_8859_1,T=ja.DEFAULT_EC_PERCENT,P=ja.DEFAULT_AZTEC_LAYERS;return v!=null&&(v.has(ts.CHARACTER_SET)&&(j=On.forName(v.get(ts.CHARACTER_SET).toString())),v.has(ts.ERROR_CORRECTION)&&(T=F.parseInt(v.get(ts.ERROR_CORRECTION).toString())),v.has(ts.AZTEC_LAYERS)&&(P=F.parseInt(v.get(ts.AZTEC_LAYERS).toString()))),tn.encodeLayers(l,f,x,b,j,T,P)}static encodeLayers(l,f,x,b,v,j,T){if(f!==le.AZTEC)throw new w("Can only encode AZTEC, but got "+f);let P=ja.encode(K.getBytes(l,v),j,T);return tn.renderResult(P,x,b)}static renderResult(l,f,x){let b=l.getMatrix();if(b==null)throw new et;let v=b.getWidth(),j=b.getHeight(),T=Math.max(f,v),P=Math.max(x,j),H=Math.min(T/v,P/j),de=(T-v*H)/2,je=(P-j*H)/2,Ae=new ge(T,P);for(let Ge=0,ot=je;Ge<j;Ge++,ot+=H)for(let ut=0,At=de;ut<v;ut++,At+=H)b.get(ut,Ge)&&Ae.setRegion(At,ot,H,H);return Ae}}a.AbstractExpandedDecoder=ne,a.ArgumentException=y,a.ArithmeticException=pe,a.AztecCode=lo,a.AztecCodeReader=wt,a.AztecCodeWriter=tn,a.AztecDecoder=Lt,a.AztecDetector=Ye,a.AztecDetectorResult=qe,a.AztecEncoder=ja,a.AztecHighLevelEncoder=ii,a.AztecPoint=Yt,a.BarcodeFormat=le,a.Binarizer=A,a.BinaryBitmap=E,a.BitArray=z,a.BitMatrix=ge,a.BitSource=Ps,a.BrowserAztecCodeReader=zt,a.BrowserBarcodeReader=da,a.BrowserCodeReader=J,a.BrowserDatamatrixCodeReader=Cn,a.BrowserMultiFormatReader=Bl,a.BrowserPDF417Reader=$i,a.BrowserQRCodeReader=yc,a.BrowserQRCodeSvgWriter=Un,a.CharacterSetECI=G,a.ChecksumException=S,a.Code128Reader=kt,a.Code39Reader=ze,a.DataMatrixDecodedBitStreamParser=_s,a.DataMatrixReader=wr,a.DecodeHintType=X,a.DecoderResult=Le,a.DefaultGridSampler=St,a.DetectorResult=Rt,a.EAN13Reader=_r,a.EncodeHintType=ts,a.Exception=g,a.FormatException=B,a.GenericGF=rt,a.GenericGFPoly=Be,a.GlobalHistogramBinarizer=we,a.GridSampler=ar,a.GridSamplerInstance=Ot,a.HTMLCanvasElementLuminanceSource=ye,a.HybridBinarizer=ee,a.ITFReader=nt,a.IllegalArgumentException=w,a.IllegalStateException=et,a.InvertedLuminanceSource=ce,a.LuminanceSource=ve,a.MathUtils=Je,a.MultiFormatOneDReader=vr,a.MultiFormatReader=pc,a.MultiFormatWriter=Vi,a.NotFoundException=re,a.OneDReader=qt,a.PDF417DecodedBitStreamParser=Gt,a.PDF417DecoderErrorCorrection=Os,a.PDF417Reader=Ls,a.PDF417ResultMetadata=ei,a.PerspectiveTransform=yt,a.PlanarYUVLuminanceSource=ai,a.QRCodeByteMatrix=Jo,a.QRCodeDataMask=Oa,a.QRCodeDecodedBitStreamParser=ua,a.QRCodeDecoderErrorCorrectionLevel=Wr,a.QRCodeDecoderFormatInformation=mt,a.QRCodeEncoder=Wa,a.QRCodeEncoderQRCode=io,a.QRCodeMaskUtil=rs,a.QRCodeMatrixUtil=$r,a.QRCodeMode=xr,a.QRCodeReader=Qr,a.QRCodeVersion=Qt,a.QRCodeWriter=zn,a.RGBLuminanceSource=oo,a.RSS14Reader=qr,a.RSSExpandedReader=Ht,a.ReaderException=An,a.ReedSolomonDecoder=It,a.ReedSolomonEncoder=Ko,a.ReedSolomonException=ct,a.Result=ae,a.ResultMetadataType=Z,a.ResultPoint=Xe,a.StringUtils=K,a.UnsupportedOperationException=ie,a.VideoInputDevice=te,a.WhiteRectangleDetector=Dt,a.WriterException=za,a.ZXingArrays=R,a.ZXingCharset=On,a.ZXingInteger=F,a.ZXingStandardCharsets=Eo,a.ZXingStringBuilder=ke,a.ZXingStringEncoding=fe,a.ZXingSystem=C,a.createAbstractExpandedDecoder=Ft,Object.defineProperty(a,"__esModule",{value:!0})}))})(of,of.exports)),of.exports}var Ns=BW();const UW=J1(Ns),zW=t6({__proto__:null,default:UW},[Ns]);var Hk=(function(){function e(r,a,s){if(this.formatMap=new Map([[Fr.QR_CODE,Ns.BarcodeFormat.QR_CODE],[Fr.AZTEC,Ns.BarcodeFormat.AZTEC],[Fr.CODABAR,Ns.BarcodeFormat.CODABAR],[Fr.CODE_39,Ns.BarcodeFormat.CODE_39],[Fr.CODE_93,Ns.BarcodeFormat.CODE_93],[Fr.CODE_128,Ns.BarcodeFormat.CODE_128],[Fr.DATA_MATRIX,Ns.BarcodeFormat.DATA_MATRIX],[Fr.MAXICODE,Ns.BarcodeFormat.MAXICODE],[Fr.ITF,Ns.BarcodeFormat.ITF],[Fr.EAN_13,Ns.BarcodeFormat.EAN_13],[Fr.EAN_8,Ns.BarcodeFormat.EAN_8],[Fr.PDF_417,Ns.BarcodeFormat.PDF_417],[Fr.RSS_14,Ns.BarcodeFormat.RSS_14],[Fr.RSS_EXPANDED,Ns.BarcodeFormat.RSS_EXPANDED],[Fr.UPC_A,Ns.BarcodeFormat.UPC_A],[Fr.UPC_E,Ns.BarcodeFormat.UPC_E],[Fr.UPC_EAN_EXTENSION,Ns.BarcodeFormat.UPC_EAN_EXTENSION]]),this.reverseFormatMap=this.createReverseFormatMap(),!zW)throw"Use html5qrcode.min.js without edit, ZXing not found.";this.verbose=a,this.logger=s;var n=this.createZXingFormats(r),i=new Map;i.set(Ns.DecodeHintType.POSSIBLE_FORMATS,n),i.set(Ns.DecodeHintType.TRY_HARDER,!1),this.hints=i}return e.prototype.decodeAsync=function(r){var a=this;return new Promise(function(s,n){try{s(a.decode(r))}catch(i){n(i)}})},e.prototype.decode=function(r){var a=new Ns.MultiFormatReader(this.verbose,this.hints),s=new Ns.HTMLCanvasElementLuminanceSource(r),n=new Ns.BinaryBitmap(new Ns.HybridBinarizer(s)),i=a.decode(n);return{text:i.text,format:Qj.create(this.toHtml5QrcodeSupportedFormats(i.format)),debugData:this.createDebugData()}},e.prototype.createReverseFormatMap=function(){var r=new Map;return this.formatMap.forEach(function(a,s,n){r.set(a,s)}),r},e.prototype.toHtml5QrcodeSupportedFormats=function(r){if(!this.reverseFormatMap.has(r))throw"reverseFormatMap doesn't have ".concat(r);return this.reverseFormatMap.get(r)},e.prototype.createZXingFormats=function(r){for(var a=[],s=0,n=r;s<n.length;s++){var i=n[s];this.formatMap.has(i)?a.push(this.formatMap.get(i)):this.logger.logError("".concat(i," is not supported by")+"ZXingHtml5QrcodeShim")}return a},e.prototype.createDebugData=function(){return{decoderName:"zxing-js"}},e})(),WW=function(e,r,a,s){function n(i){return i instanceof a?i:new a(function(c){c(i)})}return new(a||(a=Promise))(function(i,c){function u(y){try{g(s.next(y))}catch(w){c(w)}}function h(y){try{g(s.throw(y))}catch(w){c(w)}}function g(y){y.done?i(y.value):n(y.value).then(u,h)}g((s=s.apply(e,r||[])).next())})},HW=function(e,r){var a={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},s,n,i,c;return c={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function u(g){return function(y){return h([g,y])}}function h(g){if(s)throw new TypeError("Generator is already executing.");for(;c&&(c=0,g[0]&&(a=0)),a;)try{if(s=1,n&&(i=g[0]&2?n.return:g[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,g[1])).done)return i;switch(n=0,i&&(g=[g[0]&2,i.value]),g[0]){case 0:case 1:i=g;break;case 4:return a.label++,{value:g[1],done:!1};case 5:a.label++,n=g[1],g=[0];continue;case 7:g=a.ops.pop(),a.trys.pop();continue;default:if(i=a.trys,!(i=i.length>0&&i[i.length-1])&&(g[0]===6||g[0]===2)){a=0;continue}if(g[0]===3&&(!i||g[1]>i[0]&&g[1]<i[3])){a.label=g[1];break}if(g[0]===6&&a.label<i[1]){a.label=i[1],i=g;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(g);break}i[2]&&a.ops.pop(),a.trys.pop();continue}g=r.call(e,a)}catch(y){g=[6,y],n=0}finally{s=i=0}if(g[0]&5)throw g[1];return{value:g[0]?g[1]:void 0,done:!0}}},$k=(function(){function e(r,a,s){if(this.formatMap=new Map([[Fr.QR_CODE,"qr_code"],[Fr.AZTEC,"aztec"],[Fr.CODABAR,"codabar"],[Fr.CODE_39,"code_39"],[Fr.CODE_93,"code_93"],[Fr.CODE_128,"code_128"],[Fr.DATA_MATRIX,"data_matrix"],[Fr.ITF,"itf"],[Fr.EAN_13,"ean_13"],[Fr.EAN_8,"ean_8"],[Fr.PDF_417,"pdf417"],[Fr.UPC_A,"upc_a"],[Fr.UPC_E,"upc_e"]]),this.reverseFormatMap=this.createReverseFormatMap(),!e.isSupported())throw"Use html5qrcode.min.js without edit, Use BarcodeDetectorDelegate only if it isSupported();";this.verbose=a,this.logger=s;var n=this.createBarcodeDetectorFormats(r);if(this.detector=new BarcodeDetector(n),!this.detector)throw"BarcodeDetector detector not supported"}return e.isSupported=function(){if(!("BarcodeDetector"in window))return!1;var r=new BarcodeDetector({formats:["qr_code"]});return typeof r!="undefined"},e.prototype.decodeAsync=function(r){return WW(this,void 0,void 0,function(){var a,s;return HW(this,function(n){switch(n.label){case 0:return[4,this.detector.detect(r)];case 1:if(a=n.sent(),!a||a.length===0)throw"No barcode or QR code detected.";return s=this.selectLargestBarcode(a),[2,{text:s.rawValue,format:Qj.create(this.toHtml5QrcodeSupportedFormats(s.format)),debugData:this.createDebugData()}]}})})},e.prototype.selectLargestBarcode=function(r){for(var a=null,s=0,n=0,i=r;n<i.length;n++){var c=i[n],u=c.boundingBox.width*c.boundingBox.height;u>s&&(s=u,a=c)}if(!a)throw"No largest barcode found";return a},e.prototype.createBarcodeDetectorFormats=function(r){for(var a=[],s=0,n=r;s<n.length;s++){var i=n[s];this.formatMap.has(i)?a.push(this.formatMap.get(i)):this.logger.warn("".concat(i," is not supported by")+"BarcodeDetectorDelegate")}return{formats:a}},e.prototype.toHtml5QrcodeSupportedFormats=function(r){if(!this.reverseFormatMap.has(r))throw"reverseFormatMap doesn't have ".concat(r);return this.reverseFormatMap.get(r)},e.prototype.createReverseFormatMap=function(){var r=new Map;return this.formatMap.forEach(function(a,s,n){r.set(a,s)}),r},e.prototype.createDebugData=function(){return{decoderName:"BarcodeDetector"}},e})(),Vk=function(e,r,a,s){function n(i){return i instanceof a?i:new a(function(c){c(i)})}return new(a||(a=Promise))(function(i,c){function u(y){try{g(s.next(y))}catch(w){c(w)}}function h(y){try{g(s.throw(y))}catch(w){c(w)}}function g(y){y.done?i(y.value):n(y.value).then(u,h)}g((s=s.apply(e,r||[])).next())})},Gk=function(e,r){var a={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},s,n,i,c;return c={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function u(g){return function(y){return h([g,y])}}function h(g){if(s)throw new TypeError("Generator is already executing.");for(;c&&(c=0,g[0]&&(a=0)),a;)try{if(s=1,n&&(i=g[0]&2?n.return:g[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,g[1])).done)return i;switch(n=0,i&&(g=[g[0]&2,i.value]),g[0]){case 0:case 1:i=g;break;case 4:return a.label++,{value:g[1],done:!1};case 5:a.label++,n=g[1],g=[0];continue;case 7:g=a.ops.pop(),a.trys.pop();continue;default:if(i=a.trys,!(i=i.length>0&&i[i.length-1])&&(g[0]===6||g[0]===2)){a=0;continue}if(g[0]===3&&(!i||g[1]>i[0]&&g[1]<i[3])){a.label=g[1];break}if(g[0]===6&&a.label<i[1]){a.label=i[1],i=g;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(g);break}i[2]&&a.ops.pop(),a.trys.pop();continue}g=r.call(e,a)}catch(y){g=[6,y],n=0}finally{s=i=0}if(g[0]&5)throw g[1];return{value:g[0]?g[1]:void 0,done:!0}}},$W=(function(){function e(r,a,s,n){this.EXECUTIONS_TO_REPORT_PERFORMANCE=100,this.executions=0,this.executionResults=[],this.wasPrimaryDecoderUsedInLastDecode=!1,this.verbose=s,a&&$k.isSupported()?(this.primaryDecoder=new $k(r,s,n),this.secondaryDecoder=new Hk(r,s,n)):this.primaryDecoder=new Hk(r,s,n)}return e.prototype.decodeAsync=function(r){return Vk(this,void 0,void 0,function(){var a;return Gk(this,function(s){switch(s.label){case 0:a=performance.now(),s.label=1;case 1:return s.trys.push([1,,3,4]),[4,this.getDecoder().decodeAsync(r)];case 2:return[2,s.sent()];case 3:return this.possiblyLogPerformance(a),[7];case 4:return[2]}})})},e.prototype.decodeRobustlyAsync=function(r){return Vk(this,void 0,void 0,function(){var a,s;return Gk(this,function(n){switch(n.label){case 0:a=performance.now(),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,this.primaryDecoder.decodeAsync(r)];case 2:return[2,n.sent()];case 3:if(s=n.sent(),this.secondaryDecoder)return[2,this.secondaryDecoder.decodeAsync(r)];throw s;case 4:return this.possiblyLogPerformance(a),[7];case 5:return[2]}})})},e.prototype.getDecoder=function(){return this.secondaryDecoder?this.wasPrimaryDecoderUsedInLastDecode===!1?(this.wasPrimaryDecoderUsedInLastDecode=!0,this.primaryDecoder):(this.wasPrimaryDecoderUsedInLastDecode=!1,this.secondaryDecoder):this.primaryDecoder},e.prototype.possiblyLogPerformance=function(r){if(this.verbose){var a=performance.now()-r;this.executionResults.push(a),this.executions++,this.possiblyFlushPerformanceReport()}},e.prototype.possiblyFlushPerformanceReport=function(){if(!(this.executions<this.EXECUTIONS_TO_REPORT_PERFORMANCE)){for(var r=0,a=0,s=this.executionResults;a<s.length;a++){var n=s[a];r+=n}var i=r/this.executionResults.length;console.log("".concat(i," ms for ").concat(this.executionResults.length," last runs.")),this.executions=0,this.executionResults=[]}},e})(),nb=(function(){var e=function(r,a){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(s,n){s.__proto__=n}||function(s,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[i]=n[i])},e(r,a)};return function(r,a){if(typeof a!="function"&&a!==null)throw new TypeError("Class extends value "+String(a)+" is not a constructor or null");e(r,a);function s(){this.constructor=r}r.prototype=a===null?Object.create(a):(s.prototype=a.prototype,new s)}})(),lg=function(e,r,a,s){function n(i){return i instanceof a?i:new a(function(c){c(i)})}return new(a||(a=Promise))(function(i,c){function u(y){try{g(s.next(y))}catch(w){c(w)}}function h(y){try{g(s.throw(y))}catch(w){c(w)}}function g(y){y.done?i(y.value):n(y.value).then(u,h)}g((s=s.apply(e,r||[])).next())})},cg=function(e,r){var a={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},s,n,i,c;return c={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function u(g){return function(y){return h([g,y])}}function h(g){if(s)throw new TypeError("Generator is already executing.");for(;c&&(c=0,g[0]&&(a=0)),a;)try{if(s=1,n&&(i=g[0]&2?n.return:g[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,g[1])).done)return i;switch(n=0,i&&(g=[g[0]&2,i.value]),g[0]){case 0:case 1:i=g;break;case 4:return a.label++,{value:g[1],done:!1};case 5:a.label++,n=g[1],g=[0];continue;case 7:g=a.ops.pop(),a.trys.pop();continue;default:if(i=a.trys,!(i=i.length>0&&i[i.length-1])&&(g[0]===6||g[0]===2)){a=0;continue}if(g[0]===3&&(!i||g[1]>i[0]&&g[1]<i[3])){a.label=g[1];break}if(g[0]===6&&a.label<i[1]){a.label=i[1],i=g;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(g);break}i[2]&&a.ops.pop(),a.trys.pop();continue}g=r.call(e,a)}catch(y){g=[6,y],n=0}finally{s=i=0}if(g[0]&5)throw g[1];return{value:g[0]?g[1]:void 0,done:!0}}},tS=(function(){function e(r,a){this.name=r,this.track=a}return e.prototype.isSupported=function(){return this.track.getCapabilities?this.name in this.track.getCapabilities():!1},e.prototype.apply=function(r){var a={};a[this.name]=r;var s={advanced:[a]};return this.track.applyConstraints(s)},e.prototype.value=function(){var r=this.track.getSettings();if(this.name in r){var a=r[this.name];return a}return null},e})(),VW=(function(e){nb(r,e);function r(a,s){return e.call(this,a,s)||this}return r.prototype.min=function(){return this.getCapabilities().min},r.prototype.max=function(){return this.getCapabilities().max},r.prototype.step=function(){return this.getCapabilities().step},r.prototype.apply=function(a){var s={};s[this.name]=a;var n={advanced:[s]};return this.track.applyConstraints(n)},r.prototype.getCapabilities=function(){this.failIfNotSupported();var a=this.track.getCapabilities(),s=a[this.name];return{min:s.min,max:s.max,step:s.step}},r.prototype.failIfNotSupported=function(){if(!this.isSupported())throw new Error("".concat(this.name," capability not supported"))},r})(tS),GW=(function(e){nb(r,e);function r(a){return e.call(this,"zoom",a)||this}return r})(VW),YW=(function(e){nb(r,e);function r(a){return e.call(this,"torch",a)||this}return r})(tS),qW=(function(){function e(r){this.track=r}return e.prototype.zoomFeature=function(){return new GW(this.track)},e.prototype.torchFeature=function(){return new YW(this.track)},e})(),XW=(function(){function e(r,a,s){this.isClosed=!1,this.parentElement=r,this.mediaStream=a,this.callbacks=s,this.surface=this.createVideoElement(this.parentElement.clientWidth),r.append(this.surface)}return e.prototype.createVideoElement=function(r){var a=document.createElement("video");return a.style.width="".concat(r,"px"),a.style.display="block",a.muted=!0,a.setAttribute("muted","true"),a.playsInline=!0,a},e.prototype.setupSurface=function(){var r=this;this.surface.onabort=function(){throw"RenderedCameraImpl video surface onabort() called"},this.surface.onerror=function(){throw"RenderedCameraImpl video surface onerror() called"};var a=function(){var s=r.surface.clientWidth,n=r.surface.clientHeight;r.callbacks.onRenderSurfaceReady(s,n),r.surface.removeEventListener("playing",a)};this.surface.addEventListener("playing",a),this.surface.srcObject=this.mediaStream,this.surface.play()},e.create=function(r,a,s,n){return lg(this,void 0,void 0,function(){var i,c;return cg(this,function(u){switch(u.label){case 0:return i=new e(r,a,n),s.aspectRatio?(c={aspectRatio:s.aspectRatio},[4,i.getFirstTrackOrFail().applyConstraints(c)]):[3,2];case 1:u.sent(),u.label=2;case 2:return i.setupSurface(),[2,i]}})})},e.prototype.failIfClosed=function(){if(this.isClosed)throw"The RenderedCamera has already been closed."},e.prototype.getFirstTrackOrFail=function(){if(this.failIfClosed(),this.mediaStream.getVideoTracks().length===0)throw"No video tracks found";return this.mediaStream.getVideoTracks()[0]},e.prototype.pause=function(){this.failIfClosed(),this.surface.pause()},e.prototype.resume=function(r){this.failIfClosed();var a=this,s=function(){setTimeout(r,200),a.surface.removeEventListener("playing",s)};this.surface.addEventListener("playing",s),this.surface.play()},e.prototype.isPaused=function(){return this.failIfClosed(),this.surface.paused},e.prototype.getSurface=function(){return this.failIfClosed(),this.surface},e.prototype.getRunningTrackCapabilities=function(){return this.getFirstTrackOrFail().getCapabilities()},e.prototype.getRunningTrackSettings=function(){return this.getFirstTrackOrFail().getSettings()},e.prototype.applyVideoConstraints=function(r){return lg(this,void 0,void 0,function(){return cg(this,function(a){if("aspectRatio"in r)throw"Changing 'aspectRatio' in run-time is not yet supported.";return[2,this.getFirstTrackOrFail().applyConstraints(r)]})})},e.prototype.close=function(){if(this.isClosed)return Promise.resolve();var r=this;return new Promise(function(a,s){var n=r.mediaStream.getVideoTracks(),i=n.length,c=0;r.mediaStream.getVideoTracks().forEach(function(u){r.mediaStream.removeTrack(u),u.stop(),++c,c>=i&&(r.isClosed=!0,r.parentElement.removeChild(r.surface),a())})})},e.prototype.getCapabilities=function(){return new qW(this.getFirstTrackOrFail())},e})(),ZW=(function(){function e(r){this.mediaStream=r}return e.prototype.render=function(r,a,s){return lg(this,void 0,void 0,function(){return cg(this,function(n){return[2,XW.create(r,this.mediaStream,a,s)]})})},e.create=function(r){return lg(this,void 0,void 0,function(){var a,s;return cg(this,function(n){switch(n.label){case 0:if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return a={audio:!1,video:r},[4,navigator.mediaDevices.getUserMedia(a)];case 1:return s=n.sent(),[2,new e(s)]}})})},e})(),Yk=function(e,r,a,s){function n(i){return i instanceof a?i:new a(function(c){c(i)})}return new(a||(a=Promise))(function(i,c){function u(y){try{g(s.next(y))}catch(w){c(w)}}function h(y){try{g(s.throw(y))}catch(w){c(w)}}function g(y){y.done?i(y.value):n(y.value).then(u,h)}g((s=s.apply(e,r||[])).next())})},qk=function(e,r){var a={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},s,n,i,c;return c={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function u(g){return function(y){return h([g,y])}}function h(g){if(s)throw new TypeError("Generator is already executing.");for(;c&&(c=0,g[0]&&(a=0)),a;)try{if(s=1,n&&(i=g[0]&2?n.return:g[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,g[1])).done)return i;switch(n=0,i&&(g=[g[0]&2,i.value]),g[0]){case 0:case 1:i=g;break;case 4:return a.label++,{value:g[1],done:!1};case 5:a.label++,n=g[1],g=[0];continue;case 7:g=a.ops.pop(),a.trys.pop();continue;default:if(i=a.trys,!(i=i.length>0&&i[i.length-1])&&(g[0]===6||g[0]===2)){a=0;continue}if(g[0]===3&&(!i||g[1]>i[0]&&g[1]<i[3])){a.label=g[1];break}if(g[0]===6&&a.label<i[1]){a.label=i[1],i=g;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(g);break}i[2]&&a.ops.pop(),a.trys.pop();continue}g=r.call(e,a)}catch(y){g=[6,y],n=0}finally{s=i=0}if(g[0]&5)throw g[1];return{value:g[0]?g[1]:void 0,done:!0}}},KW=(function(){function e(){}return e.failIfNotSupported=function(){return Yk(this,void 0,void 0,function(){return qk(this,function(r){if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return[2,new e]})})},e.prototype.create=function(r){return Yk(this,void 0,void 0,function(){return qk(this,function(a){return[2,ZW.create(r)]})})},e})(),JW=function(e,r,a,s){function n(i){return i instanceof a?i:new a(function(c){c(i)})}return new(a||(a=Promise))(function(i,c){function u(y){try{g(s.next(y))}catch(w){c(w)}}function h(y){try{g(s.throw(y))}catch(w){c(w)}}function g(y){y.done?i(y.value):n(y.value).then(u,h)}g((s=s.apply(e,r||[])).next())})},QW=function(e,r){var a={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},s,n,i,c;return c={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function u(g){return function(y){return h([g,y])}}function h(g){if(s)throw new TypeError("Generator is already executing.");for(;c&&(c=0,g[0]&&(a=0)),a;)try{if(s=1,n&&(i=g[0]&2?n.return:g[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,g[1])).done)return i;switch(n=0,i&&(g=[g[0]&2,i.value]),g[0]){case 0:case 1:i=g;break;case 4:return a.label++,{value:g[1],done:!1};case 5:a.label++,n=g[1],g=[0];continue;case 7:g=a.ops.pop(),a.trys.pop();continue;default:if(i=a.trys,!(i=i.length>0&&i[i.length-1])&&(g[0]===6||g[0]===2)){a=0;continue}if(g[0]===3&&(!i||g[1]>i[0]&&g[1]<i[3])){a.label=g[1];break}if(g[0]===6&&a.label<i[1]){a.label=i[1],i=g;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(g);break}i[2]&&a.ops.pop(),a.trys.pop();continue}g=r.call(e,a)}catch(y){g=[6,y],n=0}finally{s=i=0}if(g[0]&5)throw g[1];return{value:g[0]?g[1]:void 0,done:!0}}},eH=(function(){function e(){}return e.retrieve=function(){if(navigator.mediaDevices)return e.getCamerasFromMediaDevices();var r=MediaStreamTrack;return MediaStreamTrack&&r.getSources?e.getCamerasFromMediaStreamTrack():e.rejectWithError()},e.rejectWithError=function(){var r=L0.unableToQuerySupportedDevices();return e.isHttpsOrLocalhost()||(r=L0.insecureContextCameraQueryError()),Promise.reject(r)},e.isHttpsOrLocalhost=function(){if(location.protocol==="https:")return!0;var r=location.host.split(":")[0];return r==="127.0.0.1"||r==="localhost"},e.getCamerasFromMediaDevices=function(){return JW(this,void 0,void 0,function(){var r,a,s,n,i,c,u;return QW(this,function(h){switch(h.label){case 0:return r=function(g){for(var y=g.getVideoTracks(),w=0,E=y;w<E.length;w++){var S=E[w];S.enabled=!1,S.stop(),g.removeTrack(S)}},[4,navigator.mediaDevices.getUserMedia({audio:!1,video:!0})];case 1:return a=h.sent(),[4,navigator.mediaDevices.enumerateDevices()];case 2:for(s=h.sent(),n=[],i=0,c=s;i<c.length;i++)u=c[i],u.kind==="videoinput"&&n.push({id:u.deviceId,label:u.label});return r(a),[2,n]}})})},e.getCamerasFromMediaStreamTrack=function(){return new Promise(function(r,a){var s=function(i){for(var c=[],u=0,h=i;u<h.length;u++){var g=h[u];g.kind==="video"&&c.push({id:g.id,label:g.label})}r(c)},n=MediaStreamTrack;n.getSources(s)})},e})(),qs;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.NOT_STARTED=1]="NOT_STARTED",e[e.SCANNING=2]="SCANNING",e[e.PAUSED=3]="PAUSED"})(qs||(qs={}));var tH=(function(){function e(){this.state=qs.NOT_STARTED,this.onGoingTransactionNewState=qs.UNKNOWN}return e.prototype.directTransition=function(r){this.failIfTransitionOngoing(),this.validateTransition(r),this.state=r},e.prototype.startTransition=function(r){return this.failIfTransitionOngoing(),this.validateTransition(r),this.onGoingTransactionNewState=r,this},e.prototype.execute=function(){if(this.onGoingTransactionNewState===qs.UNKNOWN)throw"Transaction is already cancelled, cannot execute().";var r=this.onGoingTransactionNewState;this.onGoingTransactionNewState=qs.UNKNOWN,this.directTransition(r)},e.prototype.cancel=function(){if(this.onGoingTransactionNewState===qs.UNKNOWN)throw"Transaction is already cancelled, cannot cancel().";this.onGoingTransactionNewState=qs.UNKNOWN},e.prototype.getState=function(){return this.state},e.prototype.failIfTransitionOngoing=function(){if(this.onGoingTransactionNewState!==qs.UNKNOWN)throw"Cannot transition to a new state, already under transition"},e.prototype.validateTransition=function(r){switch(this.state){case qs.UNKNOWN:throw"Transition from unknown is not allowed";case qs.NOT_STARTED:this.failIfNewStateIs(r,[qs.PAUSED]);break;case qs.SCANNING:break;case qs.PAUSED:break}},e.prototype.failIfNewStateIs=function(r,a){for(var s=0,n=a;s<n.length;s++){var i=n[s];if(r===i)throw"Cannot transition from ".concat(this.state," to ").concat(r)}},e})(),rH=(function(){function e(r){this.stateManager=r}return e.prototype.startTransition=function(r){return this.stateManager.startTransition(r)},e.prototype.directTransition=function(r){this.stateManager.directTransition(r)},e.prototype.getState=function(){return this.stateManager.getState()},e.prototype.canScanFile=function(){return this.stateManager.getState()===qs.NOT_STARTED},e.prototype.isScanning=function(){return this.stateManager.getState()!==qs.NOT_STARTED},e.prototype.isStrictlyScanning=function(){return this.stateManager.getState()===qs.SCANNING},e.prototype.isPaused=function(){return this.stateManager.getState()===qs.PAUSED},e})(),aH=(function(){function e(){}return e.create=function(){return new rH(new tH)},e})(),sH=(function(){var e=function(r,a){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(s,n){s.__proto__=n}||function(s,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[i]=n[i])},e(r,a)};return function(r,a){if(typeof a!="function"&&a!==null)throw new TypeError("Class extends value "+String(a)+" is not a constructor or null");e(r,a);function s(){this.constructor=r}r.prototype=a===null?Object.create(a):(s.prototype=a.prototype,new s)}})(),xo=(function(e){sH(r,e);function r(){return e!==null&&e.apply(this,arguments)||this}return r.DEFAULT_WIDTH=300,r.DEFAULT_WIDTH_OFFSET=2,r.FILE_SCAN_MIN_HEIGHT=300,r.FILE_SCAN_HIDDEN_CANVAS_PADDING=100,r.MIN_QR_BOX_SIZE=50,r.SHADED_LEFT=1,r.SHADED_RIGHT=2,r.SHADED_TOP=3,r.SHADED_BOTTOM=4,r.SHADED_REGION_ELEMENT_ID="qr-shaded-region",r.VERBOSE=!1,r.BORDER_SHADER_DEFAULT_COLOR="#ffffff",r.BORDER_SHADER_MATCH_COLOR="rgb(90, 193, 56)",r})(IW),nH=(function(){function e(r,a){this.logger=a,this.fps=xo.SCAN_DEFAULT_FPS,r?(r.fps&&(this.fps=r.fps),this.disableFlip=r.disableFlip===!0,this.qrbox=r.qrbox,this.aspectRatio=r.aspectRatio,this.videoConstraints=r.videoConstraints):this.disableFlip=xo.DEFAULT_DISABLE_FLIP}return e.prototype.isMediaStreamConstraintsValid=function(){return this.videoConstraints?eS.isMediaStreamConstraintsValid(this.videoConstraints,this.logger):(this.logger.logError("Empty videoConstraints",!0),!1)},e.prototype.isShadedBoxEnabled=function(){return!ac(this.qrbox)},e.create=function(r,a){return new e(r,a)},e})(),iH=(function(){function e(r,a){if(this.element=null,this.canvasElement=null,this.scannerPausedUiElement=null,this.hasBorderShaders=null,this.borderShaders=null,this.qrMatch=null,this.renderedCamera=null,this.qrRegion=null,this.context=null,this.lastScanImageFile=null,this.isScanning=!1,!document.getElementById(r))throw"HTML Element with id=".concat(r," not found");this.elementId=r,this.verbose=!1;var s;typeof a=="boolean"?this.verbose=a===!0:a&&(s=a,this.verbose=s.verbose===!0,s.experimentalFeatures),this.logger=new PW(this.verbose),this.qrcode=new $W(this.getSupportedFormats(a),this.getUseBarCodeDetectorIfSupported(s),this.verbose,this.logger),this.foreverScanTimeout,this.shouldScan=!0,this.stateManagerProxy=aH.create()}return e.prototype.start=function(r,a,s,n){var i=this;if(!r)throw"cameraIdOrConfig is required";if(!s||typeof s!="function")throw"qrCodeSuccessCallback is required and should be a function.";var c;n?c=n:c=this.verbose?this.logger.log:function(){};var u=nH.create(a,this.logger);this.clearElement();var h=!1;u.videoConstraints&&(u.isMediaStreamConstraintsValid()?h=!0:this.logger.logError("'videoConstraints' is not valid 'MediaStreamConstraints, it will be ignored.'",!0));var g=h,y=document.getElementById(this.elementId);y.clientWidth?y.clientWidth:xo.DEFAULT_WIDTH,y.style.position="relative",this.shouldScan=!0,this.element=y;var w=this,E=this.stateManagerProxy.startTransition(qs.SCANNING);return new Promise(function(S,A){var C=g?u.videoConstraints:w.createVideoConstraints(r);if(!C){E.cancel(),A("videoConstraints should be defined");return}var O={};(!g||u.aspectRatio)&&(O.aspectRatio=u.aspectRatio);var M={onRenderSurfaceReady:function(R,F){w.setupUi(R,F,u),w.isScanning=!0,w.foreverScan(u,s,c)}};KW.failIfNotSupported().then(function(R){R.create(C).then(function(F){return F.render(i.element,O,M).then(function(z){w.renderedCamera=z,E.execute(),S(null)}).catch(function(z){E.cancel(),A(z)})}).catch(function(F){E.cancel(),A(L0.errorGettingUserMedia(F))})}).catch(function(R){E.cancel(),A(L0.cameraStreamingNotSupported())})})},e.prototype.pause=function(r){if(!this.stateManagerProxy.isStrictlyScanning())throw"Cannot pause, scanner is not scanning.";this.stateManagerProxy.directTransition(qs.PAUSED),this.showPausedState(),(ac(r)||r!==!0)&&(r=!1),r&&this.renderedCamera&&this.renderedCamera.pause()},e.prototype.resume=function(){if(!this.stateManagerProxy.isPaused())throw"Cannot result, scanner is not paused.";if(!this.renderedCamera)throw"renderedCamera doesn't exist while trying resume()";var r=this,a=function(){r.stateManagerProxy.directTransition(qs.SCANNING),r.hidePausedState()};if(!this.renderedCamera.isPaused()){a();return}this.renderedCamera.resume(function(){a()})},e.prototype.getState=function(){return this.stateManagerProxy.getState()},e.prototype.stop=function(){var r=this;if(!this.stateManagerProxy.isScanning())throw"Cannot stop, scanner is not running or paused.";var a=this.stateManagerProxy.startTransition(qs.NOT_STARTED);this.shouldScan=!1,this.foreverScanTimeout&&clearTimeout(this.foreverScanTimeout);var s=function(){if(r.element){var i=document.getElementById(xo.SHADED_REGION_ELEMENT_ID);i&&r.element.removeChild(i)}},n=this;return this.renderedCamera.close().then(function(){return n.renderedCamera=null,n.element&&(n.element.removeChild(n.canvasElement),n.canvasElement=null),s(),n.qrRegion&&(n.qrRegion=null),n.context&&(n.context=null),a.execute(),n.hidePausedState(),n.isScanning=!1,Promise.resolve()})},e.prototype.scanFile=function(r,a){return this.scanFileV2(r,a).then(function(s){return s.decodedText})},e.prototype.scanFileV2=function(r,a){var s=this;if(!r||!(r instanceof File))throw"imageFile argument is mandatory and should be instance of File. Use 'event.target.files[0]'.";if(ac(a)&&(a=!0),!this.stateManagerProxy.canScanFile())throw"Cannot start file scan - ongoing camera scan";return new Promise(function(n,i){s.possiblyCloseLastScanImageFile(),s.clearElement(),s.lastScanImageFile=URL.createObjectURL(r);var c=new Image;c.onload=function(){var u=c.width,h=c.height,g=document.getElementById(s.elementId),y=g.clientWidth?g.clientWidth:xo.DEFAULT_WIDTH,w=Math.max(g.clientHeight?g.clientHeight:h,xo.FILE_SCAN_MIN_HEIGHT),E=s.computeCanvasDrawConfig(u,h,y,w);if(a){var S=s.createCanvasElement(y,w,"qr-canvas-visible");S.style.display="inline-block",g.appendChild(S);var A=S.getContext("2d");if(!A)throw"Unable to get 2d context from canvas";A.canvas.width=y,A.canvas.height=w,A.drawImage(c,0,0,u,h,E.x,E.y,E.width,E.height)}var C=xo.FILE_SCAN_HIDDEN_CANVAS_PADDING,O=Math.max(c.width,E.width),M=Math.max(c.height,E.height),R=O+2*C,F=M+2*C,z=s.createCanvasElement(R,F);g.appendChild(z);var W=z.getContext("2d");if(!W)throw"Unable to get 2d context from canvas";W.canvas.width=R,W.canvas.height=F,W.drawImage(c,0,0,u,h,C,C,O,M);try{s.qrcode.decodeRobustlyAsync(z).then(function(X){n(zk.createFromQrcodeResult(X))}).catch(i)}catch(X){i("QR code parse error, error = ".concat(X))}},c.onerror=i,c.onabort=i,c.onstalled=i,c.onsuspend=i,c.src=URL.createObjectURL(r)})},e.prototype.clear=function(){this.clearElement()},e.getCameras=function(){return eH.retrieve()},e.prototype.getRunningTrackCapabilities=function(){return this.getRenderedCameraOrFail().getRunningTrackCapabilities()},e.prototype.getRunningTrackSettings=function(){return this.getRenderedCameraOrFail().getRunningTrackSettings()},e.prototype.getRunningTrackCameraCapabilities=function(){return this.getRenderedCameraOrFail().getCapabilities()},e.prototype.applyVideoConstraints=function(r){if(r){if(!eS.isMediaStreamConstraintsValid(r,this.logger))throw"invalid videoConstaints passed, check logs for more details"}else throw"videoConstaints is required argument.";return this.getRenderedCameraOrFail().applyVideoConstraints(r)},e.prototype.getRenderedCameraOrFail=function(){if(this.renderedCamera==null)throw"Scanning is not in running state, call this API only when QR code scanning using camera is in running state.";return this.renderedCamera},e.prototype.getSupportedFormats=function(r){var a=[Fr.QR_CODE,Fr.AZTEC,Fr.CODABAR,Fr.CODE_39,Fr.CODE_93,Fr.CODE_128,Fr.DATA_MATRIX,Fr.MAXICODE,Fr.ITF,Fr.EAN_13,Fr.EAN_8,Fr.PDF_417,Fr.RSS_14,Fr.RSS_EXPANDED,Fr.UPC_A,Fr.UPC_E,Fr.UPC_EAN_EXTENSION];if(!r||typeof r=="boolean"||!r.formatsToSupport)return a;if(!Array.isArray(r.formatsToSupport))throw"configOrVerbosityFlag.formatsToSupport should be undefined or an array.";if(r.formatsToSupport.length===0)throw"Atleast 1 formatsToSupport is needed.";for(var s=[],n=0,i=r.formatsToSupport;n<i.length;n++){var c=i[n];FW(c)?s.push(c):this.logger.warn("Invalid format: ".concat(c," passed in config, ignoring."))}if(s.length===0)throw"None of formatsToSupport match supported values.";return s},e.prototype.getUseBarCodeDetectorIfSupported=function(r){if(ac(r))return!0;if(!ac(r.useBarCodeDetectorIfSupported))return r.useBarCodeDetectorIfSupported!==!1;if(ac(r.experimentalFeatures))return!0;var a=r.experimentalFeatures;return ac(a.useBarCodeDetectorIfSupported)?!0:a.useBarCodeDetectorIfSupported!==!1},e.prototype.validateQrboxSize=function(r,a,s){var n=this,i=s.qrbox;this.validateQrboxConfig(i);var c=this.toQrdimensions(r,a,i),u=function(g){if(g<xo.MIN_QR_BOX_SIZE)throw"minimum size of 'config.qrbox' dimension value is"+" ".concat(xo.MIN_QR_BOX_SIZE,"px.")},h=function(g){return g>r&&(n.logger.warn("`qrbox.width` or `qrbox` is larger than the width of the root element. The width will be truncated to the width of root element."),g=r),g};u(c.width),u(c.height),c.width=h(c.width)},e.prototype.validateQrboxConfig=function(r){if(typeof r!="number"&&typeof r!="function"&&(r.width===void 0||r.height===void 0))throw"Invalid instance of QrDimensions passed for 'config.qrbox'. Both 'width' and 'height' should be set."},e.prototype.toQrdimensions=function(r,a,s){if(typeof s=="number")return{width:s,height:s};if(typeof s=="function")try{return s(r,a)}catch(n){throw new Error("qrbox config was passed as a function but it failed with unknown error"+n)}return s},e.prototype.setupUi=function(r,a,s){s.isShadedBoxEnabled()&&this.validateQrboxSize(r,a,s);var n=ac(s.qrbox)?{width:r,height:a}:s.qrbox;this.validateQrboxConfig(n);var i=this.toQrdimensions(r,a,n);i.height>a&&this.logger.warn("[Html5Qrcode] config.qrbox has height that isgreater than the height of the video stream. Shading will be ignored");var c=s.isShadedBoxEnabled()&&i.height<=a,u={x:0,y:0,width:r,height:a},h=c?this.getShadedRegionBounds(r,a,i):u,g=this.createCanvasElement(h.width,h.height),y={willReadFrequently:!0},w=g.getContext("2d",y);w.canvas.width=h.width,w.canvas.height=h.height,this.element.append(g),c&&this.possiblyInsertShadingElement(this.element,r,a,i),this.createScannerPausedUiElement(this.element),this.qrRegion=h,this.context=w,this.canvasElement=g},e.prototype.createScannerPausedUiElement=function(r){var a=document.createElement("div");a.innerText=L0.scannerPaused(),a.style.display="none",a.style.position="absolute",a.style.top="0px",a.style.zIndex="1",a.style.background="rgba(9, 9, 9, 0.46)",a.style.color="#FFECEC",a.style.textAlign="center",a.style.width="100%",r.appendChild(a),this.scannerPausedUiElement=a},e.prototype.scanContext=function(r,a){var s=this;return this.stateManagerProxy.isPaused()?Promise.resolve(!1):this.qrcode.decodeAsync(this.canvasElement).then(function(n){return r(n.text,zk.createFromQrcodeResult(n)),s.possiblyUpdateShaders(!0),!0}).catch(function(n){s.possiblyUpdateShaders(!1);var i=L0.codeParseError(n);return a(i,MW.createFrom(i)),!1})},e.prototype.foreverScan=function(r,a,s){var n=this;if(this.shouldScan&&this.renderedCamera){var i=this.renderedCamera.getSurface(),c=i.videoWidth/i.clientWidth,u=i.videoHeight/i.clientHeight;if(!this.qrRegion)throw"qrRegion undefined when localMediaStream is ready.";var h=this.qrRegion.width*c,g=this.qrRegion.height*u,y=this.qrRegion.x*c,w=this.qrRegion.y*u;this.context.drawImage(i,y,w,h,g,0,0,this.qrRegion.width,this.qrRegion.height);var E=function(){n.foreverScanTimeout=setTimeout(function(){n.foreverScan(r,a,s)},n.getTimeoutFps(r.fps))};this.scanContext(a,s).then(function(S){!S&&r.disableFlip!==!0?(n.context.translate(n.context.canvas.width,0),n.context.scale(-1,1),n.scanContext(a,s).finally(function(){E()})):E()}).catch(function(S){n.logger.logError("Error happend while scanning context",S),E()})}},e.prototype.createVideoConstraints=function(r){if(typeof r=="string")return{deviceId:{exact:r}};if(typeof r=="object"){var a="facingMode",s="deviceId",n={user:!0,environment:!0},i="exact",c=function(A){if(A in n)return!0;throw"config has invalid 'facingMode' value = "+"'".concat(A,"'")},u=Object.keys(r);if(u.length!==1)throw"'cameraIdOrConfig' object should have exactly 1 key,"+" if passed as an object, found ".concat(u.length," keys");var h=Object.keys(r)[0];if(h!==a&&h!==s)throw"Only '".concat(a,"' and '").concat(s,"' ")+" are supported for 'cameraIdOrConfig'";if(h===a){var g=r.facingMode;if(typeof g=="string"){if(c(g))return{facingMode:g}}else if(typeof g=="object")if(i in g){if(c(g["".concat(i)]))return{facingMode:{exact:g["".concat(i)]}}}else throw"'facingMode' should be string or object with"+" ".concat(i," as key.");else{var y=typeof g;throw"Invalid type of 'facingMode' = ".concat(y)}}else{var w=r.deviceId;if(typeof w=="string")return{deviceId:w};if(typeof w=="object"){if(i in w)return{deviceId:{exact:w["".concat(i)]}};throw"'deviceId' should be string or object with"+" ".concat(i," as key.")}else{var E=typeof w;throw"Invalid type of 'deviceId' = ".concat(E)}}}var S=typeof r;throw"Invalid type of 'cameraIdOrConfig' = ".concat(S)},e.prototype.computeCanvasDrawConfig=function(r,a,s,n){if(r<=s&&a<=n){var i=(s-r)/2,c=(n-a)/2;return{x:i,y:c,width:r,height:a}}else{var u=r,h=a;return r>s&&(a=s/r*a,r=s),a>n&&(r=n/a*r,a=n),this.logger.log("Image downsampled from "+"".concat(u,"X").concat(h)+" to ".concat(r,"X").concat(a,".")),this.computeCanvasDrawConfig(r,a,s,n)}},e.prototype.clearElement=function(){if(this.stateManagerProxy.isScanning())throw"Cannot clear while scan is ongoing, close it first.";var r=document.getElementById(this.elementId);r&&(r.innerHTML="")},e.prototype.possiblyUpdateShaders=function(r){this.qrMatch!==r&&(this.hasBorderShaders&&this.borderShaders&&this.borderShaders.length&&this.borderShaders.forEach(function(a){a.style.backgroundColor=r?xo.BORDER_SHADER_MATCH_COLOR:xo.BORDER_SHADER_DEFAULT_COLOR}),this.qrMatch=r)},e.prototype.possiblyCloseLastScanImageFile=function(){this.lastScanImageFile&&(URL.revokeObjectURL(this.lastScanImageFile),this.lastScanImageFile=null)},e.prototype.createCanvasElement=function(r,a,s){var n=r,i=a,c=document.createElement("canvas");return c.style.width="".concat(n,"px"),c.style.height="".concat(i,"px"),c.style.display="none",c.id=ac(s)?"qr-canvas":s,c},e.prototype.getShadedRegionBounds=function(r,a,s){if(s.width>r||s.height>a)throw"'config.qrbox' dimensions should not be greater than the dimensions of the root HTML element.";return{x:(r-s.width)/2,y:(a-s.height)/2,width:s.width,height:s.height}},e.prototype.possiblyInsertShadingElement=function(r,a,s,n){if(!(a-n.width<1||s-n.height<1)){var i=document.createElement("div");i.style.position="absolute";var c=(a-n.width)/2,u=(s-n.height)/2;if(i.style.borderLeft="".concat(c,"px solid rgba(0, 0, 0, 0.48)"),i.style.borderRight="".concat(c,"px solid rgba(0, 0, 0, 0.48)"),i.style.borderTop="".concat(u,"px solid rgba(0, 0, 0, 0.48)"),i.style.borderBottom="".concat(u,"px solid rgba(0, 0, 0, 0.48)"),i.style.boxSizing="border-box",i.style.top="0px",i.style.bottom="0px",i.style.left="0px",i.style.right="0px",i.id="".concat(xo.SHADED_REGION_ELEMENT_ID),a-n.width<11||s-n.height<11)this.hasBorderShaders=!1;else{var h=5,g=40;this.insertShaderBorders(i,g,h,-h,null,0,!0),this.insertShaderBorders(i,g,h,-h,null,0,!1),this.insertShaderBorders(i,g,h,null,-h,0,!0),this.insertShaderBorders(i,g,h,null,-h,0,!1),this.insertShaderBorders(i,h,g+h,-h,null,-h,!0),this.insertShaderBorders(i,h,g+h,null,-h,-h,!0),this.insertShaderBorders(i,h,g+h,-h,null,-h,!1),this.insertShaderBorders(i,h,g+h,null,-h,-h,!1),this.hasBorderShaders=!0}r.append(i)}},e.prototype.insertShaderBorders=function(r,a,s,n,i,c,u){var h=document.createElement("div");h.style.position="absolute",h.style.backgroundColor=xo.BORDER_SHADER_DEFAULT_COLOR,h.style.width="".concat(a,"px"),h.style.height="".concat(s,"px"),n!==null&&(h.style.top="".concat(n,"px")),i!==null&&(h.style.bottom="".concat(i,"px")),u?h.style.left="".concat(c,"px"):h.style.right="".concat(c,"px"),this.borderShaders||(this.borderShaders=[]),this.borderShaders.push(h),r.appendChild(h)},e.prototype.showPausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="block"},e.prototype.hidePausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="none"},e.prototype.getTimeoutFps=function(r){return 1e3/r},e})(),Xk;(function(e){e[e.STATUS_DEFAULT=0]="STATUS_DEFAULT",e[e.STATUS_SUCCESS=1]="STATUS_SUCCESS",e[e.STATUS_WARNING=2]="STATUS_WARNING",e[e.STATUS_REQUESTING_PERMISSION=3]="STATUS_REQUESTING_PERMISSION"})(Xk||(Xk={}));const i1="/asm_app";function oH(e){const r=(e||"").trim();if(!r)return null;let a=r;try{if(/^https?:\/\//i.test(r)){const s=new URL(r);a=s.pathname+s.search+s.hash}}catch(s){}return(a.startsWith(i1+"/")||a===i1)&&(a=a.slice(i1.length)||"/"),a.startsWith("/")?a.split("?")[0]||a:/^(ACC-ASS-|AST-|ACC-WO-)/i.test(a)||/^[A-Z0-9-]+$/i.test(a)?/^(ACC-WO-|WO-)/i.test(a)?`/work-orders/${a}`:`/assets/${a}`:null}const lH=({isOpen:e,onClose:r,onScan:a,title:s="Scan QR Code",facingMode:n="environment"})=>{const i=Na(),u=`qr-reader-${_.useId().replace(/:/g,"")}`,h=_.useRef(null),g=_.useRef(!1),[y,w]=_.useState(null),[E,S]=_.useState(!1),A=()=>me(null,null,function*(){const O=h.current;if(h.current=null,!!O)try{O.isScanning&&(yield O.stop()),O.clear()}catch(M){}}),C=O=>me(null,null,function*(){if(g.current)return;g.current=!0;const M=oH(O);if(a){yield A(),r(),a(O,M);return}if(M){yield A(),r(),i(M);return}g.current=!1,w(`Unrecognized QR code: ${O}`)});return _.useEffect(()=>{if(!e)return;let O=!1;g.current=!1,w(null),S(!0);const M=()=>me(null,null,function*(){try{if(yield A(),O)return;const F=new iH(u);h.current=F,yield F.start({facingMode:n},{fps:10,qrbox:(z,W)=>{const X=Math.min(z,W),B=Math.max(180,Math.floor(X*.7));return{width:B,height:B}},aspectRatio:1},z=>{C(z)},()=>{})}catch(F){if(console.error("QR scanner start failed:",F),!O){const z=F instanceof Error?F.message:"Could not open camera";w(z.includes("NotAllowedError")||z.toLowerCase().includes("permission")?"Camera permission denied. Please allow camera access and try again.":`Camera unavailable: ${z}`)}}finally{O||S(!1)}}),R=window.setTimeout(()=>{M()},100);return()=>{O=!0,window.clearTimeout(R),A()}},[e,u,n]),e?gg.createPortal(t.jsx("div",{className:"fixed inset-0 z-[10050] flex items-center justify-center bg-black/70 p-4",children:t.jsxs("div",{className:"w-full max-w-md overflow-hidden rounded-xl bg-white shadow-2xl dark:bg-gray-800",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-700",children:[t.jsxs("h3",{className:"flex items-center gap-2 text-base font-semibold text-gray-900 dark:text-white",children:[t.jsx(q4,{className:"text-teal-600"}),s]}),t.jsx("button",{type:"button",onClick:()=>{A().then(r)},className:"rounded-lg p-2 text-gray-500 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","aria-label":"Close scanner",children:t.jsx(Pt,{})})]}),t.jsxs("div",{className:"space-y-3 p-4",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Point the camera at an asset QR code. You will stay inside the app."}),E&&!y&&t.jsx("p",{className:"text-center text-sm text-teal-600 dark:text-teal-400",children:"Starting camera…"}),y&&t.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-300",children:y}),t.jsx("div",{id:u,className:"overflow-hidden rounded-lg bg-black [&_video]:max-h-[60vh] [&_video]:w-full [&_video]:object-cover"})]}),t.jsx("div",{className:"border-t border-gray-200 px-4 py-3 dark:border-gray-700",children:t.jsx("button",{type:"button",onClick:()=>{A().then(r)},className:"w-full rounded-lg bg-gray-200 px-4 py-2 text-sm font-medium text-gray-800 hover:bg-gray-300 dark:bg-gray-700 dark:text-gray-100 dark:hover:bg-gray-600",children:"Cancel"})})]})}),document.body):null},cH=({className:e,label:r="Scan QR",title:a,onScan:s})=>{const[n,i]=_.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:()=>i(!0),className:e||"bg-teal-600 hover:bg-teal-700 text-white px-4 py-2 rounded-lg flex items-center justify-center gap-2 shadow transition-all w-full sm:w-auto",children:[t.jsx(q4,{}),t.jsx("span",{className:"font-medium",children:r})]}),t.jsx(lH,{isOpen:n,onClose:()=>i(!1),onScan:s,title:a})]})};function dH(e,r,a){return me(this,null,function*(){var s,n,i;try{const c=window.csrf_token||((s=document.cookie.split("; ").find(y=>y.startsWith("csrf_token=")))==null?void 0:s.split("=")[1])||"",h=yield(yield fetch(`/api/resource/${e}/${encodeURIComponent(r)}`,{method:"PUT",headers:{"Content-Type":"application/json","X-Frappe-CSRF-Token":c},credentials:"include",body:JSON.stringify({custom_delete_status:a})})).json();return h.data||h.message?{success:!0}:{success:!1,error:h.exc_type==="ValidationError"?h.exception||"Validation error":h._server_messages?((i=(n=JSON.parse(h._server_messages))==null?void 0:n[0])==null?void 0:i.message)||"Unknown error":"Failed to update delete status"}}catch(c){return{success:!1,error:c instanceof Error?c.message:"Network error"}}})}function uH(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")?"Contractor Supervisor":e.includes("DR Approver")?"DR Approver":e.includes("End user")?"End user":"Other"}function fH(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"?Ke(Te({},a),{showDirectDelete:!0}):e==="Contractor Supervisor"?Ke(Te({},a),{showRaiseRequest:!0}):Ke(Te({},a),{showRaiseRequest:!0}):r==="Delete Request With Supervisor"?e==="Contractor Supervisor"||e==="DR Approver"?Ke(Te({},a),{showApproveAsSupervisor:!0}):e==="System Manager"||e==="Cluster Manager"?Ke(Te({},a),{showApproveAsCM:!0}):a:r==="Delete Request With CM"&&(e==="System Manager"||e==="Cluster Manager"||e==="DR Approver")?Ke(Te({},a),{showApproveAsCM:!0}):a}function hH(e,r){return e==="reject"?"":e==="direct"||e==="cm_approve"?"Deleted":e==="supervisor_approve"||r==="Contractor Supervisor"||r==="DR Approver"?"Delete Request With CM":"Delete Request With Supervisor"}function mH({doctype:e,docname:r,currentDeleteStatus:a,userRoles:s,isSystemManager:n,onSuccess:i}){const[c,u]=_.useState(!1),[h,g]=_.useState(null),[y,w]=_.useState(a),E=y!==a?y:a,S=_.useMemo(()=>uH(s,n),[s,n]),A=_.useMemo(()=>fH(S,E),[S,E]),C=_.useCallback(O=>me(null,null,function*(){if(!r)return;u(!0),g(null);const M=hH(O,S),R=yield dH(e,r,M);u(!1),R.success?(w(M),i==null||i(M)):g(R.error||"Failed to update delete status")}),[e,r,S,i]);return Ke(Te({},A),{deleteStatus:E,loading:c,error:h,highestRole:S,raiseRequest:()=>C("raise"),approveAsSupervisor:()=>C("supervisor_approve"),approveAsCM:()=>C("cm_approve"),directDelete:()=>C("direct"),rejectRequest:()=>C("reject")})}const Zk=({title:e,message:r,confirmLabel:a,confirmClass:s,icon:n,loading:i,onConfirm:c,onCancel:u})=>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:u,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:c,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(Ir,{className:"animate-spin",size:13}):null,a]})]})]})}),Kk=({primaryLabel:e,primaryClass:r,primaryIcon:a,onPrimary:s,secondaryLabel:n,secondaryClass:i,secondaryIcon:c,onSecondary:u,disabled:h=!1,loading:g=!1})=>{const[y,w]=_.useState(!1),E=_.useRef(null);return _.useEffect(()=>{const S=A=>{E.current&&!E.current.contains(A.target)&&w(!1)};return y&&document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[y]),t.jsxs("div",{ref:E,className:"relative inline-flex rounded-lg overflow-visible",children:[t.jsxs("button",{type:"button",disabled:h,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:[g?t.jsx(Ir,{className:"animate-spin",size:13}):a,e]}),t.jsx("span",{className:"w-px bg-white/30"}),t.jsx("button",{type:"button",disabled:h,onClick:()=>w(S=>!S),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(on,{size:11,className:`transition-transform ${y?"rotate-180":""}`})}),y&&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:h,onClick:()=>{w(!1),u()},className:`w-full px-4 py-2.5 text-sm font-medium flex items-center gap-2 transition-colors ${i}`,children:[c,n]})})]})},Jk=({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},rd=({doctype:e,docname:r,currentDeleteStatus:a,userRoles:s,isSystemManager:n,onStatusChange:i,className:c="",inline:u=!1,redirectOnDelete:h,triggerMode:g=!1})=>{const y=Na(),[w,E]=_.useState(null),[S,A]=_.useState(!1),C=_.useRef(null),{showRaiseRequest:O,showApproveAsSupervisor:M,showApproveAsCM:R,showDirectDelete:F,deleteStatus:z,loading:W,error:X,raiseRequest:B,approveAsSupervisor:Y,approveAsCM:G,directDelete:ie,rejectRequest:fe}=mH({doctype:e,docname:r,currentDeleteStatus:a,userRoles:s,isSystemManager:n,onSuccess:we=>{i==null||i(we),we==="Deleted"&&h&&y(h)}});_.useEffect(()=>{if(!S)return;const we=ee=>{C.current&&!C.current.contains(ee.target)&&A(!1)};return document.addEventListener("mousedown",we),()=>document.removeEventListener("mousedown",we)},[S]);const K=()=>me(null,null,function*(){if(!w)return;yield{raise:B,supervisor_approve:Y,supervisor_reject:fe,cm_approve:G,cm_reject:fe,direct:ie}[w](),E(null)}),ke={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(Jr,{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(Tr,{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(po,{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(la,{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(po,{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(la,{className:"text-red-500"})}},ge={"Delete Request With Supervisor":"Delete Request Pending Supervisor","Delete Request With CM":"Delete Request Pending Cluster Manager",Deleted:"Marked for Deletion"};if(g){const ee=!!z?"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!O&&!M&&!R&&!F&&!z?null:t.jsxs(t.Fragment,{children:[w&&t.jsx(Zk,Ke(Te({},ke[w]),{loading:W,onConfirm:K,onCancel:()=>E(null)})),t.jsxs("div",{className:"relative",ref:C,children:[t.jsx("button",{type:"button",onClick:()=>A(ce=>!ce),title:z?ge[z]:"Request Deletion",className:`p-2 rounded transition-colors ${ee}`,disabled:W||!r,children:W?t.jsx(Ir,{className:"animate-spin",size:14}):t.jsx(la,{size:14})}),S&&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:[z&&t.jsx("div",{className:"mb-3",children:t.jsx(Jk,{status:z})}),X&&t.jsxs("p",{className:"text-xs text-red-500 mb-2 flex items-center gap-1",children:[t.jsx(Jr,{size:10})," ",X]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[O&&t.jsxs("button",{type:"button",disabled:W||!r,onClick:()=>{A(!1),E("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(la,{size:11})," Request Deletion"]}),M&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",disabled:W||!r,onClick:()=>{A(!1),E("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(Tr,{size:11})," Approve & Forward to CM"]}),t.jsxs("button",{type:"button",disabled:W||!r,onClick:()=>{A(!1),E("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(po,{size:11})," Reject Request"]})]}),R&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",disabled:W||!r,onClick:()=>{A(!1),E("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(Tr,{size:11})," Approve & Delete"]}),t.jsxs("button",{type:"button",disabled:W||!r,onClick:()=>{A(!1),E("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(po,{size:11})," Reject Request"]})]}),F&&t.jsxs("button",{type:"button",disabled:W||!r,onClick:()=>{A(!1),E("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(la,{size:11})," Delete"]})]})]})]})]})}const re=u?"flex flex-row flex-wrap items-center gap-2":"flex flex-col gap-2";return t.jsxs(t.Fragment,{children:[w&&t.jsx(Zk,Ke(Te({},ke[w]),{loading:W,onConfirm:K,onCancel:()=>E(null)})),t.jsxs("div",{className:`${re} ${c}`,children:[z&&t.jsx(Jk,{status:z}),X&&t.jsxs("p",{className:"text-xs text-red-500 dark:text-red-400 flex items-center gap-1",children:[t.jsx(Jr,{size:11})," ",X]}),O&&t.jsxs("button",{type:"button",disabled:W||!r,onClick:()=>E("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:[W?t.jsx(Ir,{className:"animate-spin",size:13}):t.jsx(la,{size:13}),"Request Deletion"]}),M&&t.jsx(Kk,{disabled:W||!r,loading:W,primaryLabel:"Approve Request",primaryClass:"bg-yellow-600 hover:bg-yellow-700",primaryIcon:t.jsx(Tr,{size:13}),onPrimary:()=>E("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(po,{size:13,className:"text-gray-500"}),onSecondary:()=>E("supervisor_reject")}),R&&t.jsx(Kk,{disabled:W||!r,loading:W,primaryLabel:"Approve & Delete",primaryClass:"bg-red-600 hover:bg-red-700",primaryIcon:t.jsx(Tr,{size:13}),onPrimary:()=>E("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(po,{size:13,className:"text-gray-500"}),onSecondary:()=>E("cm_reject")}),F&&t.jsxs("button",{type:"button",disabled:W||!r,onClick:()=>E("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:[W?t.jsx(Ir,{className:"animate-spin",size:13}):t.jsx(la,{size:13}),"Delete"]})]})]})},gH={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"]),"Asset Maintenance Log":new Set(["name","asset_name","task_name","maintenance_type","maintenance_status","due_date","assign_to_name","workflow_state","custom_hospital_name","creation"])},wm=new Map;function ib(e){const[r,a]=_.useState([]),[s,n]=_.useState(!1),[i,c]=_.useState(null),u=_.useRef(!1);return _.useEffect(()=>{if(!e)return;let g=!1;return me(null,null,function*(){if(!u.current){if(u.current=!0,wm.has(e)){g||a(wm.get(e)),u.current=!1;return}g||(n(!0),c(null));try{const w=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(!w.ok)throw new Error(`Server returned ${w.status}`);const E=yield w.json();if(E.exc)throw new Error(E.exc);const S=E.message||[],A=gH[e],C=S.map((O,M)=>({key:O.fieldname,label:O.label||O.fieldname,fieldtype:O.fieldtype||"Data",default:A?A.has(O.fieldname):M<8}));console.log(`[useDoctypeFields] ✅ "${e}": ${C.length} fields from server`),wm.set(e,C),g||a(C)}catch(w){console.error("[useDoctypeFields] ❌",w),g||(c(w instanceof Error?w.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{u.current=!1,g||n(!1)}}}),()=>{g=!0}},[e]),{fields:r,loading:s,error:i,refetchFields:()=>{wm.delete(e),u.current=!1,a([]),c(null)}}}function rS(e){return e==null?"":typeof e=="boolean"?e?"Yes":"No":String(e)}function xH(e,r,a){const s=r.map(g=>g.label),n=e.map(g=>r.map(y=>{const w=rS(g[y.key]);return w.includes(",")||w.includes('"')||w.includes(`
`)?`"${w.replace(/"/g,'""')}"`:w}).join(",")),i=[s.join(","),...n].join(`
`),c=new Blob(["\uFEFF"+i],{type:"text/csv;charset=utf-8;"}),u=URL.createObjectURL(c),h=document.createElement("a");h.href=u,h.download=a,h.click(),URL.revokeObjectURL(u)}function pH(e,r,a){const s=[r.map(c=>c.label),...e.map(c=>r.map(u=>rS(c[u.key])))],n=Ur.aoa_to_sheet(s),i=Ur.book_new();Ur.book_append_sheet(i,n,"Export"),jo(i,a)}const ob=({isOpen:e,onClose:r,doctype:a,selectedCount:s,pageCount:n,totalCount:i,onExport:c,onFetchAll:u,pageData:h,selectedRows:g,rowKey:y="name",extraColumns:w=[],hiddenColumns:E=[],defaultColumns:S,fileNamePrefix:A})=>{const{t:C}=Rr(),{fields:O,loading:M}=ib(a),R=ea.useMemo(()=>{const ye=new Set(E),te=[...O.filter(q=>!ye.has(q.key)),...w.filter(q=>!ye.has(q.key))];if(S){const q=new Set(S);return te.map(J=>Ke(Te({},J),{default:q.has(J.key)}))}return te},[O,w,E,S]),[F,z]=_.useState(s>0?"selected":"all_with_filters"),[W,X]=_.useState("csv"),[B,Y]=_.useState(new Set),[G,ie]=_.useState(""),[fe,K]=_.useState(!1),ke=ea.useRef(!1);if(_.useEffect(()=>{z(s>0?"selected":"all_with_filters")},[s]),_.useEffect(()=>{R.length!==0&&(ke.current||(ke.current=!0,Y(new Set(R.filter(ye=>ye.default).map(ye=>ye.key)))))},[R]),_.useEffect(()=>{e||(ke.current=!1,Y(new Set))},[e]),!e)return null;const ge=G.trim()?R.filter(ye=>ye.label.toLowerCase().includes(G.toLowerCase())||ye.key.toLowerCase().includes(G.toLowerCase())):R,re=ye=>{Y(te=>{const q=new Set(te);return q.has(ye)?q.delete(ye):q.add(ye),q})},we=()=>Y(new Set(R.map(ye=>ye.key))),ee=()=>Y(new Set(R.filter(ye=>ye.default).map(ye=>ye.key))),ve=()=>Y(new Set),ce=()=>me(null,null,function*(){if(B.size!==0){K(!0);try{if(c){yield c(F,W,[...B]),r();return}let ye=[];if(F==="selected"){const oe=g!=null?g:new Set;ye=h.filter(le=>oe.has(le[y]))}else if(F==="all_on_page")ye=h;else{if(!u){alert("onFetchAll not provided for all_with_filters scope");return}ye=yield u()}if(ye.length===0){alert("No data to export.");return}const te=R.filter(oe=>B.has(oe.key)),q=A!=null?A:a.toLowerCase().replace(/\s+/g,"_"),J=new Date().toISOString().split("T")[0],ae=`${q}_export_${J}.${W==="csv"?"csv":"xlsx"}`;W==="csv"?xH(ye,te,ae):pH(ye,te,ae),r()}catch(ye){console.error("Export failed:",ye),alert(`Export failed: ${ye instanceof Error?ye.message:"Unknown error"}`)}finally{K(!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(Ks,{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:[R.length," fields available · ",B.size," selected"]})]})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:fe,children:t.jsx(Pt,{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(o1,{value:"selected",current:F,onChange:z,disabled:s===0,badge:s,badgeColor:"green",label:"Selected rows",sub:`${s} row${s!==1?"s":""} selected`}),t.jsx(o1,{value:"all_on_page",current:F,onChange:z,badge:n,badgeColor:"blue",label:"Current page",sub:`${n} rows on this page`}),t.jsx(o1,{value:"all_with_filters",current:F,onChange:z,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(Qk,{value:"csv",current:W,onChange:X,icon:t.jsx(No,{className:"text-green-600 text-xl"}),label:"CSV",sub:"Universal, works everywhere"}),t.jsx(Qk,{value:"excel",current:W,onChange:X,icon:t.jsx(zi,{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",M&&t.jsx(Ir,{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:we,className:"hover:underline",children:"All"}),t.jsx("button",{onClick:ee,className:"hover:underline",children:"Default"}),t.jsx("button",{onClick:ve,className:"hover:underline",children:"None"})]})]}),t.jsxs("div",{className:"relative mb-2",children:[t.jsx(In,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400",size:12}),t.jsx("input",{type:"text",value:G,onChange:ye=>ie(ye.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"}),G&&t.jsx("button",{onClick:()=>ie(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:t.jsx(Pt,{size:10})})]}),M?t.jsxs("div",{className:"flex items-center justify-center h-24 text-gray-400 text-sm gap-2",children:[t.jsx(Ir,{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:[ge.map(ye=>{const te=B.has(ye.key);return t.jsxs("div",{onClick:()=>re(ye.key),className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-all text-xs select-none ${te?"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:te?t.jsx(jn,{size:13,className:"text-green-600"}):t.jsx(ys,{size:13,className:"text-gray-300 dark:text-gray-600"})}),t.jsx("span",{className:"truncate",title:`${ye.label} (${ye.key})`,children:ye.label})]},ye.key)}),ge.length===0&&t.jsxs("p",{className:"col-span-3 text-center text-gray-400 text-xs py-4",children:['No fields match "',G,'"']})]}),t.jsxs("p",{className:"text-xs text-gray-400 mt-1.5",children:[B.size," of ",R.length," fields selected",G&&` · showing ${ge.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:[F==="selected"&&`Exporting ${s} selected row${s!==1?"s":""}`,F==="all_on_page"&&`Exporting ${n} rows from current page`,F==="all_with_filters"&&`Exporting up to ${i} records`]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{onClick:r,disabled:fe,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:ce,disabled:B.size===0||fe,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:fe?t.jsxs(t.Fragment,{children:[t.jsx(Ir,{className:"animate-spin",size:14})," Exporting…"]}):t.jsxs(t.Fragment,{children:[t.jsx(Vo,{size:14})," Export"]})})]})]})]})})},yH={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"},o1=({value:e,current:r,onChange:a,disabled:s,label:n,sub:i,badge:c,badgeColor:u})=>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 ${yH[u]}`,children:c.toLocaleString()})]}),Qk=({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})]})]}),bH=({isOpen:e,onClose:r,selectedCount:a,totalCount:s,pageCount:n,onPrint:i,isPrinting:c})=>{const{t:u}=Rr(),[h,g]=_.useState(a>0?"selected":"all_with_filters");return _.useEffect(()=>{a>0?g("selected"):g("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(jd,{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:c,children:t.jsx(Pt,{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(jd,{}),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 ${h==="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:h==="selected",onChange:()=>g("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 ${h==="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:h==="all_on_page",onChange:()=>g("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 ${h==="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:h==="all_with_filters",onChange:()=>g("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:c,children:"Cancel"}),t.jsx("button",{onClick:()=>i(h),disabled:c,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:c?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(jd,{}),"Print QRs"]})})]})]})}):null},vH=()=>{const{t:e}=Rr(),r=Na(),[a,s]=Sn(),n=_.useMemo(()=>{const mt=parseInt(a.get("page")||"1",10);return Math.max(0,Number.isNaN(mt)?0:mt-1)},[a]),i=_.useCallback(mt=>{s(We=>{const Me=new URLSearchParams(We);return Me.set("page",String(mt+1)),Me})},[s]),[c,u]=_.useState(()=>a.get("search")||""),[h,g]=_.useState(null),[y,w]=_.useState(null),E=_.useRef(null),S=20,[A,C]=_.useState(!1),[O,M]=_.useState(new Set),[R,F]=_.useState(!1),[z,W]=_.useState(!1),[X,B]=_.useState(!1),[Y,G]=_.useState(!1),[ie,fe]=_.useState(!1),[K,ke]=_.useState([]),[ge,re]=_.useState(!1),{permissionFilters:we,loading:ee,error:ve}=eb("Asset"),[ce,ye]=_.useState(!1),te=["Maintenance Manager","Maintenance User","System Manager","Technician","Contractor Engineer","Work Control"],q=["Contractor Supervisor"];_.useEffect(()=>{me(null,null,function*(){try{console.log("🔍 [Role Check] Starting role check...");const Me=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:te.join(",")})})).json();if(console.log("🔍 [Role Check] API Response:",Me),Me.message){console.log("🔍 [Role Check] User roles:",Me.message.user_roles),console.log("🔍 [Role Check] Matching roles:",Me.message.matching_roles),console.log("✅ [Role Check] Has allowed role:",Me.message.has_role);const Va=Me.message.user_roles||[],fn=Va.includes("System Manager");q.some(xr=>Va.includes(xr))&&!fn?(console.log("🚫 [Role Check] Blocked: Contractor Supervisor without System Manager"),ye(!1)):ye(Me.message.has_role)}else console.error("❌ [Role Check] Invalid response:",Me),ye(!1);const Pr=yield(yield fetch("/api/method/asset_lite.api.user_roles.get_user_roles",{credentials:"include"})).json(),Oa=Array.isArray(Pr.message)?Pr.message:[];ke(Oa),re(Oa.includes("System Manager"))}catch(We){console.error("❌ [Role Check] Error:",We),ye(!1)}})},[]);const[J,ae]=_.useState(()=>a.get("date_filter_by")||""),[oe,le]=_.useState(()=>a.get("date_start")||""),[be,Z]=_.useState(()=>a.get("date_end")||""),[Le,Pe]=_.useState(()=>a.get("asset_id")||""),[Be,pe]=_.useState(()=>a.get("company")||""),[rt,ct]=_.useState(()=>a.get("manufacturer")||""),[et,It]=_.useState(()=>a.get("supplier")||""),[ft,Lt]=_.useState(()=>a.get("location")||""),[Je,Ve]=_.useState(()=>a.get("department")||""),[Xe,Rt]=_.useState(()=>a.get("modality")||""),[qe,Dt]=_.useState(()=>a.get("device_status")||""),[ar,yt]=_.useState(()=>a.get("asset_name")||""),[St,Ot]=_.useState(()=>a.get("serial_number")||""),[Yt,Ye]=_.useState(()=>a.get("technical_department")||""),[wt,zt]=_.useState(()=>a.get("local_id")||""),qt=["creation desc","creation asc","modified desc","modified asc","asset_name asc","asset_name desc","name asc","name desc"],[kt,ze]=_.useState(()=>a.get("sort_by")||"creation desc"),[nt,_t]=_.useState(!0),[lr,pr]=_.useState(0),[Nr,rr]=_.useState([]),[_r,Nt]=_.useState(!1),[Cr,yr]=_.useState(""),[jt,Tt]=_.useState(()=>a.get("asset_name")||""),[He,Fe]=_.useState(()=>a.get("serial_number")||""),[Ze,vt]=_.useState(()=>a.get("local_id")||""),ir=_.useRef(null),fr=_.useRef(null),Kt=_.useRef(null);_.useEffect(()=>{const mt=localStorage.getItem("assetFilterPresets");mt&&rr(JSON.parse(mt))},[]);const Re=J&&(oe||be);_.useEffect(()=>{const mt=[Le,Be,ft,Je,Xe,rt,et,qe,ar,St,Yt,wt,c].filter(Boolean).length+(Re?1:0);pr(mt)},[Re,J,oe,be,Le,Be,ft,Je,Xe,rt,et,qe,ar,St,Yt,wt,c]);const Q={};Le&&(Q.name=Le),Be&&(Q.company=Be),rt&&(Q.custom_manufacturer=rt),et&&(Q.supplier=et),ft&&(Q.location=ft),Je&&(Q.department=Je),Xe&&(Q.custom_modality=Xe),qe&&(Q.custom_device_status=qe),ar&&(Q.asset_name=["like",`%${ar}%`]),St&&(Q.custom_serial_number=["like",`%${St}%`]),Yt&&(Q.custom_technical_department=Yt),wt&&(Q.custom_local_id=["like",`%${wt}%`]),c&&(Q.asset_name=["like",`%${c}%`]),Object.assign(Q,td(J,oe,be)),Q.custom_delete_status=["!=","Deleted"];const he=qt.includes(kt)?kt:"creation desc",{assets:Se,totalCount:ne,hasMore:_e,loading:Ce,error:Qe,refetch:xt}=DW(Q,S,n*S,he,we),{deleteAsset:dt,loading:at}=Kj();_.useEffect(()=>{!Ce&&!A&&!ee&&C(!0)},[Ce,A,ee]);const $e=_.useRef(!1);_.useEffect(()=>{if(!$e.current){$e.current=!0;return}s(mt=>{const We=new URLSearchParams(mt);return J?We.set("date_filter_by",J):We.delete("date_filter_by"),oe?We.set("date_start",oe):We.delete("date_start"),be?We.set("date_end",be):We.delete("date_end"),Le?We.set("asset_id",Le):We.delete("asset_id"),Be?We.set("company",Be):We.delete("company"),rt?We.set("manufacturer",rt):We.delete("manufacturer"),et?We.set("supplier",et):We.delete("supplier"),ft?We.set("location",ft):We.delete("location"),Je?We.set("department",Je):We.delete("department"),Xe?We.set("modality",Xe):We.delete("modality"),qe?We.set("device_status",qe):We.delete("device_status"),ar?We.set("asset_name",ar):We.delete("asset_name"),St?We.set("serial_number",St):We.delete("serial_number"),Yt?We.set("technical_department",Yt):We.delete("technical_department"),wt?We.set("local_id",wt):We.delete("local_id"),c?We.set("search",c):We.delete("search"),kt&&kt!=="creation desc"?We.set("sort_by",kt):We.delete("sort_by"),We.set("page","1"),We})},[J,oe,be,Le,Be,rt,et,ft,Je,Xe,qe,ar,St,Yt,wt,c,kt]),_.useEffect(()=>{M(new Set)},[J,oe,be,Le,Be,rt,et,ft,Je,Xe,qe,ar,St,Yt,wt,c,n]);const tt=mt=>{Tt(mt),ir.current&&clearTimeout(ir.current),ir.current=window.setTimeout(()=>{yt(mt)},800)},gt=mt=>{Fe(mt),fr.current&&clearTimeout(fr.current),fr.current=window.setTimeout(()=>{Ot(mt)},800)},Wt=mt=>{vt(mt),Kt.current&&clearTimeout(Kt.current),Kt.current=window.setTimeout(()=>{zt(mt)},800)},Ft=(mt,We)=>{mt.key==="Enter"&&(mt.preventDefault(),We==="assetName"?(ir.current&&clearTimeout(ir.current),yt(jt)):We==="serialNumber"?(fr.current&&clearTimeout(fr.current),Ot(He)):We==="localId"&&(Kt.current&&clearTimeout(Kt.current),zt(Ze)))},Zt=()=>{if(!Cr.trim()){alert("Please enter a filter name");return}const mt={id:Date.now(),name:Cr,filters:{dateFilterBy:J,dateStart:oe,dateEnd:be,sortBy:kt,filterAssetId:Le,filterCompany:Be,filterLocation:ft,filterDepartment:Je,filterModality:Xe,filterManufacturer:rt,filterSupplier:et,filterDeviceStatus:qe,filterAssetName:ar,filterSerialNumber:St,filterTechnicalDepartment:Yt,filterLocalId:wt,searchTerm:c}},We=[...Nr,mt];rr(We),yr(""),Nt(!1),localStorage.setItem("assetFilterPresets",JSON.stringify(We))},br=mt=>{const We=mt.filters;ae(We.dateFilterBy||""),le(We.dateStart||""),Z(We.dateEnd||""),ze(We.sortBy||"creation desc"),Pe(We.filterAssetId||""),pe(We.filterCompany||""),Lt(We.filterLocation||""),Ve(We.filterDepartment||""),Rt(We.filterModality||""),ct(We.filterManufacturer||""),It(We.filterSupplier||""),Dt(We.filterDeviceStatus||""),yt(We.filterAssetName||""),Tt(We.filterAssetName||""),Ot(We.filterSerialNumber||""),Fe(We.filterSerialNumber||""),Ye(We.filterTechnicalDepartment||""),zt(We.filterLocalId||""),vt(We.filterLocalId||""),u(We.searchTerm||"")},Ht=mt=>{const We=Nr.filter(Me=>Me.id!==mt);rr(We),localStorage.setItem("assetFilterPresets",JSON.stringify(We))};_.useEffect(()=>()=>{ir.current&&clearTimeout(ir.current),fr.current&&clearTimeout(fr.current),Kt.current&&clearTimeout(Kt.current)},[]);const fa=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""}},qr=mt=>mt?new Date(mt).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"-";_.useEffect(()=>{const mt=We=>{E.current&&!E.current.contains(We.target)&&w(null)};return y&&document.addEventListener("mousedown",mt),()=>{document.removeEventListener("mousedown",mt)}},[y]);const vr=mt=>{M(We=>{const Me=new Set(We);return Me.has(mt)?Me.delete(mt):Me.add(mt),Me})},da=()=>{O.size===Se.length?M(new Set):M(new Set(Se.map(mt=>mt.name)))},zr=Se.length>0&&O.size===Se.length,Kr=O.size>0&&O.size<Se.length,Yr=_.useCallback(()=>me(null,null,function*(){const mt=[];let We=0;const Me=100;let Qt=!0;const Pr=Te(Te({},Q),we),Oa=Ln(Pr);for(;Qt;)try{const Ea=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Asset",filters:Oa.length>0?Oa:{},fields:["*"],limit_start:We*Me,limit_page_length:Me,order_by:"creation desc"})})).json()).message||[];mt.push(...Ea),Ea.length<Me?Qt=!1:We++,We>100&&(console.warn("Export safety limit reached"),Qt=!1)}catch(Va){throw console.error("Error fetching assets for export:",Va),Va}return mt}),[Q,we]),Gr=()=>r("/assets/new"),Sa=mt=>r(`/assets/${mt}`),Ps=mt=>r(`/assets/${mt}`),ha=mt=>r(`/assets/new?duplicate=${mt}`),_s=mt=>me(null,null,function*(){try{console.log("Fetching full asset details for:",mt.name);const Qt=(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:",Qt),console.log("Building:",Qt.custom_building),console.log("Room Number:",Qt.custom_room_number);const Pr=new URLSearchParams;Qt.name&&Pr.append("asset",Qt.name),Qt.asset_name&&Pr.append("asset_name",Qt.asset_name),Qt.custom_asset_type&&Pr.append("asset_type",Qt.custom_asset_type),Qt.custom_manufacturer&&Pr.append("manufacturer",Qt.custom_manufacturer),Qt.custom_serial_number&&Pr.append("serial_number",Qt.custom_serial_number),Qt.department&&Pr.append("department",Qt.department),Qt.custom_site_contractor&&Pr.append("site_contractor",Qt.custom_site_contractor),Qt.custom_subcontractor&&Pr.append("subcontractor",Qt.custom_subcontractor),Qt.company&&Pr.append("company",Qt.company),Qt.custom_service_agreement&&Pr.append("custom_service_agreement",Qt.custom_service_agreement),Qt.custom_service_coverage&&Pr.append("custom_service_coverage",Qt.custom_service_coverage),Qt.custom_site&&Pr.append("site_name",Qt.custom_site),Qt.supplier&&Pr.append("supplier",Qt.supplier),Qt.custom_building&&Pr.append("building",Qt.custom_building),Qt.custom_room_number&&Pr.append("room_no",Qt.custom_room_number),Qt.location&&Pr.append("location",Qt.location),r(`/work-orders/new?${Pr.toString()}`)}catch(We){console.error("Error fetching asset details:",We);const Me=new URLSearchParams;mt.name&&Me.append("asset",mt.name),r(`/work-orders/new?${Me.toString()}`)}}),Wi=mt=>{r(`/work-orders?asset=${encodeURIComponent(mt)}`)},De=mt=>me(null,null,function*(){try{yield dt(mt),g(null),xt(),alert("Asset deleted successfully!")}catch(We){alert(`Failed to delete asset: ${We instanceof Error?We.message:"Unknown error"}`)}}),wr=mt=>me(null,null,function*(){fe(!0);try{let We=[];if(mt==="selected"?We=Se.filter(xr=>O.has(xr.name)):mt==="all_on_page"?We=Se:We=yield Yr(),We.length===0){alert("No assets to print.");return}const Me=We.map(xr=>xr.name),Qt=100,Pr=[];for(let xr=0;xr<Me.length;xr+=Qt){const ua=Me.slice(xr,xr+Qt),mi=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",ua]],fields:["attached_to_name","file_url"],limit_page_length:Qt})})).json(),hn=(mi==null?void 0:mi.message)||[];Pr.push(...hn)}const Oa={};Pr.forEach(xr=>{xr.attached_to_name&&xr.file_url&&(Oa[xr.attached_to_name]=xr.file_url)});const fn=We.map(xr=>({name:xr.name,asset_name:xr.asset_name||xr.name,qrUrl:Oa[xr.name]||null,technical_department:xr.custom_technical_department||""})).map(xr=>`
<div class="qr-cell">
<div class="qr-image-wrapper">
${xr.qrUrl?`<img src="${xr.qrUrl}" alt="QR" class="qr-img" />`:'<div class="qr-placeholder">No QR</div>'}
</div>
<div class="qr-info">
<div class="qr-asset-name" title="${xr.asset_name}">${xr.asset_name}</div>
<div class="qr-asset-id">${xr.name}</div>
${xr.technical_department?`<div class="qr-dept">${xr.technical_department}</div>`:""}
</div>
</div>
`).join(""),Ea=window.open("","_blank");if(!Ea){alert("Pop-up blocked. Please allow pop-ups for this site.");return}Ea.document.write(`
<!DOCTYPE html>
<html>
<head>
<title>QR Codes - ${We.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>📄 ${We.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">
${fn}
</div>
</body>
</html>
`),Ea.document.close(),G(!1)}catch(We){console.error("QR print error:",We),alert(`Failed to print QR codes: ${We instanceof Error?We.message:"Unknown error"}`)}finally{fe(!1)}}),Cn=mt=>me(null,null,function*(){var Oa;const We=`/files/${mt}-qr.png`;let Me=null;try{if((yield fetch(We,{method:"HEAD",credentials:"include"})).ok)Me=We;else{const Ea=yield(yield fetch(`/api/resource/File?filters=[["File","attached_to_name","=","${mt}"]]`,{credentials:"include"})).json();((Oa=Ea==null?void 0:Ea.data)==null?void 0:Oa.length)>0&&(Me=Ea.data[0].file_url)}}catch(Va){console.error("Error fetching QR code:",Va)}const Qt=Se.find(Va=>Va.name===mt),Pr=window.open("","_blank");Pr&&(Pr.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> ${(Qt==null?void 0:Qt.asset_name)||"N/A"}
</div>
${Me?`<img src="${Me}" 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>
`),Pr.document.close())}),un=()=>{ae(""),le(""),Z(""),ze("creation desc"),Pe(""),pe(""),ct(""),It(""),Lt(""),Ve(""),Rt(""),Dt(""),yt(""),Ot(""),Ye(""),zt(""),Tt(""),Fe(""),vt(""),u(""),ir.current&&clearTimeout(ir.current),fr.current&&clearTimeout(fr.current),Kt.current&&clearTimeout(Kt.current),s(mt=>{const We=new URLSearchParams(mt);return We.delete("date_filter_by"),We.delete("date_start"),We.delete("date_end"),We.delete("sort_by"),We.delete("asset_id"),We.delete("company"),We.delete("manufacturer"),We.delete("supplier"),We.delete("location"),We.delete("department"),We.delete("modality"),We.delete("device_status"),We.delete("asset_name"),We.delete("serial_number"),We.delete("technical_department"),We.delete("local_id"),We.delete("search"),We.set("page","1"),We})},Wr=Re||Le||Be||rt||et||ft||Je||Xe||qe||ar||St||Yt||wt||c;return ee&&!A?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")})]})}):ve?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:ve}),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"})]})]})}):Ce&&!A?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")})]})}):Qe?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:xt,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-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen w-full min-w-0 overflow-x-hidden",children:[t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center w-full min-w-0",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-gray-800 dark:text-white break-words",children:e("assets.title")}),t.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:[e("assets.listTotal")," ",ne," asset",ne!==1?"s":"",O.size>0&&t.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",O.size," ",e("common.selected")]}),Ce&&A&&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 flex-col gap-2 w-full sm:flex-row sm:flex-wrap sm:justify-end sm:gap-3 sm:w-auto min-w-0 shrink-0",children:[t.jsx(cH,{label:"Scan QR",title:"Scan Asset QR"}),t.jsxs("button",{type:"button",onClick:()=>G(!0),className:"bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg flex items-center justify-center gap-2 shadow transition-all disabled:opacity-50 w-full sm:w-auto",disabled:ne===0,children:[t.jsx(jd,{}),t.jsx("span",{className:"font-medium",children:"Print QRs"}),O.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:O.size})]}),t.jsxs("button",{type:"button",onClick:()=>F(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center justify-center gap-2 shadow transition-all disabled:opacity-50 w-full sm:w-auto",disabled:ne===0,children:[t.jsx(Ks,{}),t.jsx("span",{className:"font-medium",children:e("listPages.export")}),O.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:O.size})]}),ce&&t.jsxs("button",{type:"button",onClick:Gr,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center justify-center gap-2 shadow-lg transition-all hover:shadow-xl w-full sm:w-auto",children:[t.jsx(Js,{}),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 flex-col gap-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0 min-w-0",children:[t.jsx("button",{onClick:()=>_t(!nt),className:"text-white hover:bg-white/20 p-2 rounded-lg transition-all",children:nt?t.jsx(Mn,{size:14}):t.jsx(on,{size:14})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Hs,{className:"text-white",size:16}),t.jsx("h3",{className:"text-white font-semibold text-sm",children:e("listPages.filters")})]}),lr>0&&t.jsx("span",{className:"bg-white text-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:lr})]}),Wr&&t.jsx("div",{className:"w-full min-w-0 sm:flex-1 overflow-x-auto scrollbar-hide sm:mx-2",children:t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[Re&&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(J==="creation"?"filters.createdDate":"filters.latestModifiedDate")," ",oe&&` ${oe}`," ",be&&` - ${be}`,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),ae(""),le(""),Z("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),Le&&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"),":"]})," ",Le,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),Pe("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),Be&&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"),":"]})," ",Be,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),pe("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),ar&&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"),":"]})," ",ar,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),yt(""),Tt("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),St&&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"),":"]})," ",St,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),Ot(""),Fe("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),Yt&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-sky-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsxs("span",{className:"font-semibold",children:[e("commonFields.technicalDepartment"),":"]})," ",Yt,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),Ye("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),wt&&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.jsxs("span",{className:"font-semibold",children:[e("commonFields.localId"),":"]})," ",wt,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),zt(""),vt("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),qe&&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"),":"]})," ",qe,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),Dt("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),ft&&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"),":"]})," ",ft,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),Lt("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),Je&&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"),":"]})," ",Je,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),Ve("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),Xe&&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"),":"]})," ",Xe,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),Rt("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),rt&&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"),":"]})," ",rt,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),ct("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),et&&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"),":"]})," ",et,t.jsx("button",{onClick:mt=>{mt.stopPropagation(),It("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]})]})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 flex-shrink-0 w-full sm:w-auto justify-end sm:justify-start",children:[lr>0&&t.jsxs("button",{type:"button",onClick:()=>Nt(!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(bs,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),Wr&&t.jsxs("button",{type:"button",onClick:un,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(Pt,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:"Clear"})]})]})]})}),nt&&t.jsxs("div",{className:"p-4",children:[Nr.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(ul,{className:"text-yellow-500",size:12}),"Saved Filters"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:Nr.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:()=>br(mt),className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:mt.name}),t.jsx("button",{onClick:()=>Ht(mt.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:t.jsx(la,{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:kt,onChange:mt=>ze(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:J,onChange:mt=>{const We=mt.target.value;ae(We)},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")})]})]}),J&&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:oe,onChange:mt=>{const We=mt.target.value;le(We),be&&We>be&&Z(We)},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:be,onChange:mt=>Z(mt.target.value),min:oe||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-10 lg:z-[60]",children:[t.jsx(hr,{label:e("commonFields.assetId"),doctype:"Asset",value:Le,onChange:mt=>Pe(mt),placeholder:e("assets.selectAssetId"),disabled:!1,compact:!0,filters:{custom_delete_status:["!=","Deleted"]}}),Le&&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(Pt,{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:jt,onChange:mt=>tt(mt.target.value),onKeyDown:mt=>Ft(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"}),jt&&jt!==ar&&t.jsx("span",{className:"absolute right-2 top-6 text-[9px] text-blue-500 animate-pulse",children:e("common.typing")}),ar&&t.jsx("button",{onClick:()=>{yt(""),Tt("")},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(Pt,{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:He,onChange:mt=>gt(mt.target.value),onKeyDown:mt=>Ft(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"}),He&&He!==St&&t.jsx("span",{className:"absolute right-2 top-6 text-[9px] text-blue-500 animate-pulse",children:e("common.typing")}),St&&t.jsx("button",{onClick:()=>{Ot(""),Fe("")},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[56]",children:[t.jsx(hr,{label:e("commonFields.technicalDepartment"),doctype:"Issue Type",value:Yt,onChange:mt=>Ye(mt),placeholder:e("linkField.selectLabel",{label:e("commonFields.technicalDepartment")}),disabled:!1,compact:!0}),Yt&&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(Pt,{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.localId")}),t.jsx("input",{type:"text",value:Ze,onChange:mt=>Wt(mt.target.value),onKeyDown:mt=>Ft(mt,"localId"),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"}),Ze&&Ze!==wt&&t.jsx("span",{className:"absolute right-2 top-6 text-[9px] text-blue-500 animate-pulse",children:e("common.typing")}),wt&&t.jsx("button",{onClick:()=>{zt(""),vt("")},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[59]",children:[t.jsx(hr,{label:e("assets.selectHospital"),doctype:"Company",value:Be,onChange:mt=>pe(mt),placeholder:e("linkField.selectLabel",{label:e("assets.selectHospital")}),disabled:!1,compact:!0,filters:{domain:"Healthcare"}}),Be&&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(Pt,{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:qe,onChange:mt=>Dt(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")]})]}),qe&&t.jsx("button",{onClick:()=>Dt(""),className:"absolute right-8 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[58]",children:[t.jsx(hr,{label:e("filters.location"),doctype:"Location",value:ft,onChange:mt=>Lt(mt),placeholder:e("linkField.selectLabel",{label:e("filters.location")}),disabled:!1,compact:!0}),ft&&t.jsx("button",{onClick:()=>Lt(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[57]",children:[t.jsx(hr,{label:e("filters.dept"),doctype:"Department",value:Je,onChange:mt=>Ve(mt),placeholder:e("linkField.selectLabel",{label:e("filters.dept")}),disabled:!1,compact:!0}),Je&&t.jsx("button",{onClick:()=>Ve(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[56]",children:[t.jsx(hr,{label:e("filters.modality"),doctype:"Modality",value:Xe,onChange:mt=>Rt(mt),placeholder:e("linkField.selectLabel",{label:e("filters.modality")}),disabled:!1,compact:!0}),Xe&&t.jsx("button",{onClick:()=>Rt(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[55]",children:[t.jsx(hr,{label:e("filters.mfr"),doctype:"Manufacturer",value:rt,onChange:mt=>ct(mt),placeholder:e("linkField.selectLabel",{label:e("filters.mfr")}),disabled:!1,compact:!0}),rt&&t.jsx("button",{onClick:()=>ct(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[54]",children:[t.jsx(hr,{label:e("filters.supplier"),doctype:"Supplier",value:et,onChange:mt=>It(mt),placeholder:e("linkField.selectLabel",{label:e("filters.supplier")}),disabled:!1,compact:!0}),et&&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(Pt,{size:10})})]})]})})})]})]}),_r&&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:Cr,onChange:mt=>yr(mt.target.value),onKeyDown:mt=>{mt.key==="Enter"&&(mt.preventDefault(),Zt())},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:()=>{Nt(!1),yr("")},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:Zt,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(bs,{size:12}),e("common.saveFilter")]})]})]})}),t.jsx(bH,{isOpen:Y,onClose:()=>G(!1),selectedCount:O.size,totalCount:ne,pageCount:Se.length,onPrint:wr,isPrinting:ie}),t.jsx(ob,{isOpen:R,onClose:()=>F(!1),doctype:"Asset",selectedCount:O.size,pageCount:Se.length,totalCount:ne,pageData:Se,selectedRows:O,rowKey:"name",onFetchAll:Yr,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:[Ce&&A&&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:da,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:e(zr?"common.deselectAllTitle":"common.selectAllTitle"),children:zr?t.jsx(jn,{className:"text-blue-600 dark:text-blue-400",size:18}):Kr?t.jsxs("div",{className:"relative",children:[t.jsx(ys,{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(ys,{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:Se.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(In,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("assets.noAssetsFound")}),Wr?t.jsx("button",{onClick:un,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:e("listPages.clearFilters")}):ce?t.jsx("button",{onClick:Gr,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]})})}):Se.map(mt=>{var We;return t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${O.has(mt.name)?"bg-blue-50 dark:bg-blue-900/20":fa(mt.custom_delete_status)}`,title:mt.custom_delete_status?`Delete Status: ${mt.custom_delete_status}`:void 0,onClick:()=>Sa(mt.name),children:[t.jsx("td",{className:"px-4 py-4",onClick:Me=>Me.stopPropagation(),children:t.jsx("button",{onClick:()=>vr(mt.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:O.has(mt.name)?t.jsx(jn,{className:"text-blue-600 dark:text-blue-400",size:18}):t.jsx(ys,{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:qr(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:Me=>Me.stopPropagation(),children:[t.jsx("button",{onClick:()=>Sa(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(to,{})}),t.jsx("button",{onClick:()=>Ps(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(Ms,{})}),t.jsx("button",{onClick:()=>ha(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(tu,{})}),t.jsx("button",{onClick:()=>_s(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(Md,{})}),t.jsx("button",{onClick:()=>Wi(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(s_,{})}),t.jsx("div",{onClick:Me=>Me.stopPropagation(),children:t.jsx(rd,{doctype:"Asset",docname:mt.name,currentDeleteStatus:(We=mt.custom_delete_status)!=null?We:null,userRoles:K,isSystemManager:ge,triggerMode:!0,redirectOnDelete:"/assets",onStatusChange:()=>xt()})}),t.jsxs("div",{className:"relative",ref:y===mt.name?E:null,children:[t.jsx("button",{onClick:()=>w(y===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(Wf,{})}),y===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:()=>{_s(mt),w(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(Md,{className:"text-orange-500"}),e("assets.createWorkOrder")]}),t.jsxs("button",{onClick:()=>{Wi(mt.name),w(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(s_,{className:"text-cyan-500"}),e("assets.viewLinkedWOs")]}),t.jsxs("button",{onClick:()=>{Cn(mt.name),w(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(Go,{className:"text-purple-500"}),e("assets.printAsset")]})]})]})]})})]},mt.name)})})]})}),t.jsx(ed,{currentPage:n+1,totalCount:ne,pageSize:S,hasMore:_e,itemLabel:e("pagination.assets"),onPageChange:mt=>i(Math.max(0,mt-1))})]}),h&&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(la,{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"),":"]})," ",h]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>g(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:()=>De(h),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(la,{}),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;
}
`})]})},nl=Xt;class wH{getMaintenanceLogs(r,a,s=20,n=0,i){return me(this,null,function*(){const c=new URLSearchParams;r&&c.append("filters",JSON.stringify(r)),a&&a.length>0&&c.append("fields",JSON.stringify(a)),c.append("limit",s.toString()),c.append("offset",n.toString()),i&&c.append("order_by",i),c.append("include_child_tables","true");const u=`${Or.ENDPOINTS.GET_ASSET_MAINTENANCE_LOGS}?${c.toString()}`;return nl.apiCall(u)})}getMaintenanceLogDetails(r){return me(this,null,function*(){const a=new URLSearchParams;a.append("log_name",r),a.append("include_child_tables","true");const s=`${Or.ENDPOINTS.GET_ASSET_MAINTENANCE_LOG_DETAILS}?${a.toString()}`;return nl.apiCall(s)})}createMaintenanceLog(r){return me(this,null,function*(){const a=this.prepareLogData(r);return nl.apiCall(Or.ENDPOINTS.CREATE_ASSET_MAINTENANCE_LOG,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_data:a})})})}updateMaintenanceLog(r,a){return me(this,null,function*(){const s=this.prepareLogData(a);return nl.apiCall(Or.ENDPOINTS.UPDATE_ASSET_MAINTENANCE_LOG,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_name:r,log_data:s})})})}deleteMaintenanceLog(r){return me(this,null,function*(){return nl.apiCall(Or.ENDPOINTS.DELETE_ASSET_MAINTENANCE_LOG,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_name:r})})})}updateMaintenanceStatus(r,a,s){return me(this,null,function*(){return nl.apiCall(Or.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 me(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 c=`${Or.ENDPOINTS.GET_MAINTENANCE_LOGS_BY_ASSET}?${i.toString()}`;return nl.apiCall(c)})}getOverdueMaintenanceLogs(r,a=20,s=0){return me(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=`${Or.ENDPOINTS.GET_OVERDUE_MAINTENANCE_LOGS}?${n.toString()}`;return nl.apiCall(i)})}addPPMTableRow(r,a){return me(this,null,function*(){return nl.apiCall(Or.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 me(this,null,function*(){return nl.apiCall(Or.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 me(this,null,function*(){return nl.apiCall(Or.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 Ke(Te({},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 Fl=new wH;function Fg(e,r=20,a=0,s){const[n,i]=_.useState([]),[c,u]=_.useState(0),[h,g]=_.useState(!1),[y,w]=_.useState(!0),[E,S]=_.useState(null),[A,C]=_.useState(0),O=_.useRef(!1),M=JSON.stringify(e);_.useEffect(()=>{if(O.current&&E)return;let F=!1;return O.current=!0,me(null,null,function*(){try{w(!0);const W=yield Fl.getMaintenanceLogs(e,void 0,r,a,s);F||(i(W.asset_maintenance_logs),u(W.total_count),g(W.has_more),S(null))}catch(W){if(!F){const X=W instanceof Error?W.message:"Failed to fetch maintenance logs";X.includes("417")||X.includes("Expectation Failed")||X.includes("has no attribute")?S("API endpoint not deployed. Please deploy asset_maintenance_api.py to your Frappe server."):S(X),i([]),u(0),g(!1)}}finally{F||w(!1)}}),()=>{F=!0}},[M,r,a,s,A]);const R=_.useCallback(()=>{O.current=!1,C(F=>F+1)},[]);return{logs:n,totalCount:c,hasMore:h,loading:y,error:E,refetch:R}}function _H(e){const[r,a]=_.useState(null),[s,n]=_.useState(!0),[i,c]=_.useState(null),u=_.useCallback(()=>me(null,null,function*(){if(!e){a(null),n(!1);return}try{n(!0),c(null);const g=yield Fl.getMaintenanceLogDetails(e);a(g)}catch(g){c(g instanceof Error?g.message:"Failed to fetch maintenance log details")}finally{n(!1)}}),[e]);_.useEffect(()=>{u()},[u]);const h=_.useCallback(()=>{u()},[u]);return{log:r,loading:s,error:i,refetch:h}}function aS(){const[e,r]=_.useState(!1),[a,s]=_.useState(null);return{createLog:h=>me(null,null,function*(){try{r(!0),s(null),console.log("[useMaintenanceMutations] Creating maintenance log:",h);const g=yield Fl.createMaintenanceLog(h);if(console.log("[useMaintenanceMutations] Create response:",g),g.success)return g.asset_maintenance_log;{const y=g.error||"Failed to create maintenance log";throw new Error(y)}}catch(g){console.error("[useMaintenanceMutations] Create error:",g);const y=g instanceof Error?g.message:"Failed to create maintenance log";throw s(y),g}finally{r(!1)}}),updateLog:(h,g)=>me(null,null,function*(){try{r(!0),s(null),console.log("[useMaintenanceMutations] Updating maintenance log:",h,g);const y=yield Fl.updateMaintenanceLog(h,g);if(console.log("[useMaintenanceMutations] Update response:",y),y.success)return y.asset_maintenance_log;{const w=y.error||"Failed to update maintenance log";throw new Error(w)}}catch(y){console.error("[useMaintenanceMutations] Update error:",y);const w=y instanceof Error?y.message:"Failed to update maintenance log";throw s(w),y}finally{r(!1)}}),deleteLog:h=>me(null,null,function*(){try{r(!0),s(null);const g=yield Fl.deleteMaintenanceLog(h);if(!g.success)throw new Error("Failed to delete maintenance log");return g}catch(g){const y=g instanceof Error?g.message:"Failed to delete maintenance log";throw s(y),g}finally{r(!1)}}),updateStatus:(h,g,y)=>me(null,null,function*(){try{r(!0),s(null);const w=yield Fl.updateMaintenanceStatus(h,g,y);if(w.success)return w.asset_maintenance_log;throw new Error("Failed to update maintenance status")}catch(w){const E=w instanceof Error?w.message:"Failed to update status";throw s(E),w}finally{r(!1)}}),loading:e,error:a}}function kH(e){const[r,a]=_.useState({planned:0,completed:0,overdue:0}),[s,n]=_.useState(!1),i=_.useCallback(()=>me(null,null,function*(){if(!e||e==="new"){a({planned:0,completed:0,overdue:0}),n(!1);return}try{n(!0);const[c,u,h]=yield Promise.all([Fl.getMaintenanceLogsByAsset(e,{maintenance_status:"Planned"},1,0),Fl.getMaintenanceLogsByAsset(e,{maintenance_status:"Completed"},1,0),Fl.getMaintenanceLogsByAsset(e,{maintenance_status:"Overdue"},1,0)]);a({planned:c.total_count,completed:u.total_count,overdue:h.total_count})}catch(c){a({planned:0,completed:0,overdue:0})}finally{n(!1)}}),[e]);return _.useEffect(()=>{i()},[i]),Ke(Te({},r),{loading:s,refetch:i})}const sS=e=>{const[r,a]=_.useState([]),[s,n]=_.useState(new Set),[i,c]=_.useState(!0),[u,h]=_.useState(null);return _.useEffect(()=>{me(null,null,function*(){if(!e){c(!1);return}try{c(!0);const w=yield Xt.apiCall(`/api/resource/DocType/${e}`),S=(w.data||w).fields||[],A=new Set;S.forEach(C=>{C.allow_on_submit===1&&A.add(C.fieldname)}),a(S),n(A),h(null)}catch(w){console.error(`[DocTypeMeta] Error fetching DocType meta for ${e}:`,w),h(w instanceof Error?w.message:"Unknown error"),a([]),n(new Set)}finally{c(!1)}})},[e]),{fields:r,allowOnSubmitFields:s,isAllowedOnSubmit:y=>s.has(y),loading:i,error:u}};function l1(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 NH(e){if(!e)return null;const r=e.split(".");return r.length!==2?null:{linkField:r[0],targetField:r[1]}}const c1={};function nS(e,r){const[a,s]=_.useState([]),[n,i]=_.useState(!0),[c,u]=_.useState(null);_.useEffect(()=>{if(!e){i(!1);return}if(c1[e]){s(c1[e]),i(!1);return}me(null,null,function*(){var R;i(!0);try{const F=yield Xt.apiCall(`/api/method/frappe.client.get_doc?doctype=DocType&name=${encodeURIComponent(e)}`,{credentials:"include"});if((R=F==null?void 0:F.message)!=null&&R.fields){const z=F.message.fields.map(W=>({fieldname:W.fieldname,label:W.label,fieldtype:W.fieldtype,options:W.options,reqd:W.reqd,hidden:W.hidden,read_only:W.read_only,depends_on:W.depends_on,mandatory_depends_on:W.mandatory_depends_on,read_only_depends_on:W.read_only_depends_on,fetch_from:W.fetch_from,fetch_if_empty:W.fetch_if_empty,default:W.default,description:W.description,in_list_view:W.in_list_view,permlevel:W.permlevel,allow_on_submit:W.allow_on_submit}));c1[e]=z,s(z)}}catch(F){console.warn(`Could not fetch DocType meta for ${e}:`,F.message),u(F.message)}finally{i(!1)}})},[e]);const h=_.useMemo(()=>{const M={};return a.forEach(R=>{M[R.fieldname]=R}),M},[a]),g=_.useCallback(M=>{const R=h[M];if(!R)return{isVisible:!0,isReadOnly:!1,isMandatory:!1};let F=!(R.hidden===1||R.hidden===!0);R.depends_on&&F&&(F=l1(R.depends_on,r));let z=R.read_only===1||R.read_only===!0;R.read_only_depends_on&&(z=z||l1(R.read_only_depends_on,r));let W=R.reqd===1||R.reqd===!0;return R.mandatory_depends_on&&(W=W||l1(R.mandatory_depends_on,r)),{isVisible:F,isReadOnly:z,isMandatory:W}},[h,r]),y=_.useCallback(M=>g(M).isVisible,[g]),w=_.useCallback(M=>{const R=g(M);return R.isVisible&&R.isMandatory},[g]),E=_.useCallback(M=>g(M).isReadOnly,[g]),S=_.useCallback(M=>{const R=h[M];return(R==null?void 0:R.label)||M},[h]),A=_.useCallback(M=>{const R=h[M];return R!=null&&R.options?R.fieldtype==="Select"?R.options.split(`
`).filter(F=>F.trim()!==""):[]:[]},[h]),C=_.useCallback((M,R)=>{const F=h[M];if(!(F!=null&&F.fetch_from)||!R)return;const z=NH(F.fetch_from);if(z)return R[z.targetField]},[h]),O=_.useCallback(()=>{const M={};return a.forEach(R=>{const F=g(R.fieldname);if(F.isVisible&&F.isMandatory){const z=r[R.fieldname];(z==null||z==="")&&(M[R.fieldname]=`${R.label||R.fieldname} is required`)}}),{valid:Object.keys(M).length===0,errors:M}},[a,r,g]);return{loading:n,error:c,fields:a,getFieldState:g,shouldShowField:y,isMandatory:w,isReadOnly:E,getFieldLabel:S,getFieldOptions:A,getFetchFromValue:C,validateMandatory:O}}const jH=`<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: Arial, sans-serif;
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
margin: 0;
color: #374151;
}
</style>
</head>
<body><p>Loading...</p></body>
</html>`;function SH(){return typeof window!="undefined"&&window.matchMedia("(min-width: 1024px)").matches}function CH(e){return!e||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")?e:`${typeof window!="undefined"?window.location.origin:""}${e.startsWith("/")?e:`/${e}`}`}function Z1(e){const r=`${typeof window!="undefined"?window.location.origin:""}/`;return/<base\s/i.test(e)?e:/<head[^>]*>/i.test(e)?e.replace(/<head([^>]*)>/i,`<head$1><base href="${r}">`):e}function EH(e){const r=e.contentWindow;if(!r){alert("Report is not ready yet. Please wait a moment and try again.");return}try{r.focus(),r.print()}catch(a){alert("Printing is not supported on this device. You can take a screenshot or use Share from your browser menu.")}}function TH(e){document.body.style.overflow="";const r=document.createElement("div");r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),Object.assign(r.style,{position:"fixed",inset:"0",zIndex:"2147483646",display:"flex",flexDirection:"column",width:"100vw",height:"100dvh",maxHeight:"100dvh",background:"#ffffff"});const a=document.createElement("div");Object.assign(a.style,{display:"flex",flexShrink:"0",alignItems:"center",justifyContent:"flex-end",gap:"8px",borderBottom:"1px solid #e5e7eb",background:"#ffffff",padding:"12px 16px"});const s=document.createElement("button");s.type="button",s.textContent="Print",Object.assign(s.style,{borderRadius:"8px",background:"#2563eb",color:"#ffffff",padding:"10px 16px",fontSize:"14px",fontWeight:"500",border:"none",minHeight:"44px"});const n=document.createElement("button");n.type="button",n.textContent="Close",Object.assign(n.style,{borderRadius:"8px",border:"1px solid #d1d5db",background:"#ffffff",color:"#374151",padding:"10px 16px",fontSize:"14px",fontWeight:"500",minHeight:"44px"});const i=document.createElement("iframe");i.setAttribute("title","Report"),Object.assign(i.style,{flex:"1 1 auto",width:"100%",minHeight:"0",border:"0",background:"#ffffff"});let c=null;const u=()=>{c&&(URL.revokeObjectURL(c),c=null)},h=y=>{u();const w=Z1(y),E=new Blob([w],{type:"text/html;charset=utf-8"});c=URL.createObjectURL(E),i.src=c};e&&h(e),s.onclick=()=>EH(i);const g=()=>{u(),r.remove()};return n.onclick=g,a.appendChild(s),a.appendChild(n),r.appendChild(a),r.appendChild(i),document.body.appendChild(r),{write:h,close:g}}function AH(e){const r=window.open("","_blank");return r?(e&&(r.document.write(Z1(e)),r.document.close()),{write:a=>{r.document.open(),r.document.write(Z1(a)),r.document.close()},close:()=>{r.close()}}):null}function _m(e){const r=e!=null?e:void 0;return SH()?AH(r):TH(r!=null?r:jH)}function km(){alert("Unable to open report. Please allow pop-ups or try again.")}let B0=null,U0=null;const OH=(e,r)=>{B0=e,r&&(U0=r),console.log("[Workflow] User set manually:",e,"Roles:",r)},DH=()=>{B0=null,U0=null},lb=()=>me(null,null,function*(){try{if(B0&&U0)return console.log("[Workflow] Using cached user:",B0,"roles:",U0),{user:B0,roles:U0};const e=yield Xt.getUserDetails();if(e&&e.email){const r=e.email||e.user_id,a=e.roles||[];return B0=r,U0=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:[]}}}),RH=()=>me(null,null,function*(){const{user:e}=yield lb();return e}),Ig=()=>me(null,null,function*(){const{roles:e}=yield lb();return e}),Mg=()=>me(null,null,function*(){try{const e=yield Ig(),r=e.includes("System Manager");return console.log("[Workflow] Is System Manager:",r,"Roles:",e),r}catch(e){return console.error("[Workflow] Error checking System Manager role:",e),!1}}),cb=(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 c=r[i];return c==null||c===""?"false":typeof c=="string"?`"${c.replace(/"/g,'\\"')}"`:typeof c=="boolean"?c?"true":"false":typeof c=="number"?String(c):JSON.stringify(c)}),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}},Pg=e=>me(null,null,function*(){var r,a,s,n;try{console.log("[Workflow] Getting workflow info for doctype:",e);const i=yield Xt.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 c=i.data[0].name;console.log("[Workflow] Found workflow:",c);const u=yield Xt.apiCall(`/api/resource/Workflow/${encodeURIComponent(c)}`);return console.log("[Workflow] Full workflow data:",u==null?void 0:u.data),console.log("[Workflow] Transitions count:",(a=(r=u==null?void 0:u.data)==null?void 0:r.transitions)==null?void 0:a.length),console.log("[Workflow] States count:",(n=(s=u==null?void 0:u.data)==null?void 0:s.states)==null?void 0:n.length),{workflow_name:u.data.name,workflow_state:"",workflow_state_field:u.data.workflow_state_field,transitions:u.data.transitions||[],states:u.data.states||[]}}catch(i){return console.error("[Workflow] Error fetching workflow info:",i),null}}),iS=(e,r,a)=>me(null,null,function*(){try{console.log("[Workflow] Getting all transitions for state:",r);const s=yield Pg(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(u=>u.state===r);console.log("[Workflow] Transitions for state",r,":",n.length),a&&(n=n.filter(u=>{const h=cb(u.condition,a);return console.log(`[Workflow] Transition "${u.action}" (allowed: ${u.allowed}) condition "${u.condition||"none"}" = ${h}`),h}),console.log("[Workflow] Transitions after condition evaluation:",n.length));const i=new Set,c=[];for(const u of n){const h=`${u.action}::${u.next_state}`;i.has(h)?console.log(`[Workflow] Skipping duplicate: ${u.action} → ${u.next_state} (allowed: ${u.allowed})`):(i.add(h),c.push(u))}return console.log("[Workflow] Unique transitions after deduplication:",c.length),c}catch(s){return console.error("[Workflow] Error fetching all transitions:",s),[]}}),FH=(e,r,a,s)=>me(null,null,function*(){var n;try{console.log("[Workflow] getWorkflowTransitions called with:",{doctype:e,docname:r,currentState:a});const i=yield Mg(),c=yield Ig();if(console.log("[Workflow] User is System Manager:",i),console.log("[Workflow] User roles:",c),i&&a){console.log("[Workflow] System Manager detected, getting all transitions for state:",a);const g=yield iS(e,a,s);return console.log("[Workflow] Final transitions for System Manager:",g.map(y=>`${y.action} → ${y.next_state}`)),g}console.log("[Workflow] Non-System Manager, using Frappe API");const u=yield Xt.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:",u);let h=[];if(Array.isArray(u)?h=u:u!=null&&u.message&&Array.isArray(u.message)?h=u.message:u!=null&&u.data&&Array.isArray(u.data)?h=u.data:(n=u==null?void 0:u.data)!=null&&n.message&&Array.isArray(u.data.message)&&(h=u.data.message),console.log("[Workflow] Parsed transitions:",h),console.log("[Workflow] Transitions count:",h.length),h.length===0&&a&&s){console.log("[Workflow] Frappe API returned no transitions, trying local filtering");const g=yield Pg(e);if(g){const y=g.transitions.filter(S=>!(S.state!==a||!c.includes(S.allowed)||!cb(S.condition,s))),w=new Set,E=[];for(const S of y){const A=`${S.action}::${S.next_state}`;w.has(A)||(w.add(A),E.push(S))}return console.log("[Workflow] Local filtered transitions:",E),E}}return h}catch(i){return console.error("[Workflow] Error fetching workflow transitions:",i),[]}}),IH=(e,r,a,s)=>me(null,null,function*(){try{if(console.log("[Workflow] Applying action:",{doctype:e,docname:r,action:a,nextState:s}),(yield Mg())&&s)try{const c=yield Xt.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"),c==null?void 0:c.message}catch(c){console.log("[Workflow] Normal workflow failed, System Manager forcing state change...");const u=yield Xt.apiCall(`/api/resource/${e}/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({workflow_state:s})});return console.log("[Workflow] Force update response:",u),u==null?void 0:u.data}const i=yield Xt.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}}),MH=(e,r,a)=>me(null,null,function*(){try{if(yield Mg())return console.log("[Workflow] System Manager can always edit"),!0;const n=yield Pg(e);if(!n)return!0;const i=yield Ig(),c=n.states.filter(h=>h.state===a);if(c.length===0)return!0;const u=c.some(h=>i.includes(h.allow_edit));return console.log("[Workflow] Can user edit:",u,"User roles:",i,"Allowed roles:",c.map(h=>h.allow_edit)),u}catch(s){return console.error("[Workflow] Error checking edit permission:",s),!1}}),oS=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"}};return r[e]||r.Draft},lS=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",cS=e=>({Apply:"📤","Send For Repair":"🔧","Send For Approval":"📋","Material Request":"📦",Accept:"✅",Reject:"❌",Close:"🔒","Re-Open":"🔓",Cancel:"🚫",Approve:"✅"})[e]||"▶️",yd={getWorkflowTransitions:FH,applyWorkflowAction:IH,getWorkflowInfo:Pg,getCurrentUserRoles:Ig,getCurrentUser:RH,getCurrentUserAndRoles:lb,setCurrentUser:OH,clearCurrentUser:DH,canUserEditDocument:MH,getWorkflowStateStyle:oS,getActionButtonStyle:lS,getActionIcon:cS,isSystemManager:Mg,getAllTransitionsForState:iS,evaluateCondition:cb},Lg=({doctype:e,docname:r,workflowState:a,enabled:s=!0,docData:n})=>{const[i,c]=_.useState([]),[u,h]=_.useState(null),[g,y]=_.useState([]),[w,E]=_.useState(""),[S,A]=_.useState(!1),[C,O]=_.useState(!1),[M,R]=_.useState(!1),[F,z]=_.useState(null),[W,X]=_.useState(!0);_.useEffect(()=>{if(!s)return;me(null,null,function*(){try{const ie=yield yd.getWorkflowInfo(e);h(ie)}catch(ie){console.error("Error fetching workflow info:",ie)}})},[e,s]),_.useEffect(()=>{if(!s)return;me(null,null,function*(){try{const[ie,fe,K]=yield Promise.all([yd.getCurrentUserRoles(),yd.getCurrentUser(),yd.isSystemManager()]);y(ie),E(fe),A(K),K&&X(!0)}catch(ie){console.error("Error fetching user info:",ie)}})},[s]);const B=_.useCallback(()=>me(null,null,function*(){if(!r||!s){c([]);return}O(!0),z(null);try{const G=yield yd.getWorkflowTransitions(e,r,a,n);if(console.log("[useWorkflow] Available transitions:",G),c(G),a){const ie=yield yd.canUserEditDocument(e,r,a);X(ie)}}catch(G){console.error("Error fetching transitions:",G),z("Failed to load workflow actions"),c([])}finally{O(!1)}}),[e,r,a,s,n]);_.useEffect(()=>{B()},[B]);const Y=_.useCallback((G,ie)=>me(null,null,function*(){if(!r)return z("Document not saved yet"),!1;R(!0),z(null);try{return yield yd.applyWorkflowAction(e,r,G,ie),yield B(),!0}catch(fe){console.error("Error applying workflow action:",fe);let K="Failed to apply action";if(fe.message)K=fe.message;else if(fe._server_messages)try{K=JSON.parse(fe._server_messages).map(ge=>{try{return JSON.parse(ge).message}catch(re){return ge}}).join(`
`)}catch(ke){K=fe._server_messages}return z(K),!1}finally{R(!1)}}),[e,r,B]);return{transitions:i,workflowInfo:u,userRoles:g,currentUser:w,isSystemManager:S,loading:C,actionLoading:M,error:F,canEdit:W,applyAction:Y,refreshTransitions:B,getStateStyle:oS,getButtonStyle:lS,getIcon:cS}},db=({doctype:e,docname:r,workflowState:a,onActionComplete:s,onStateChange:n,showStateInfo:i=!0,className:c="",hiddenActions:u=[]})=>{const{transitions:h,loading:g,actionLoading:y,error:w,applyAction:E,getStateStyle:S,getButtonStyle:A,getIcon:C}=Lg({doctype:e,docname:r,workflowState:a,enabled:!!r}),[O,M]=_.useState(null),R=["Reject","Cancel","Close"],F=B=>me(null,null,function*(){if(R.includes(B)&&O!==B){M(B);return}M(null);const Y=yield E(B);s&&s(B,Y),Y&&n&&n()}),z=()=>{M(null)};if(!r)return null;const W=S(a||"Draft"),X=h.filter(B=>!u.includes(B.action));return t.jsxs("div",{className:`space-y-4 ${c}`,children:[i&&a&&t.jsx("div",{className:`p-4 rounded-lg border ${W.bg} ${W.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:"Workflow State"}),t.jsx("p",{className:`text-lg font-semibold ${W.text}`,children:a})]}),t.jsx("div",{className:`w-3 h-3 rounded-full ${W.bg.replace("100","500").replace("900/30","500")}`})]})}),g&&t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t.jsx(Ir,{className:"animate-spin"}),t.jsx("span",{className:"text-sm",children:"Loading workflow actions..."})]}),w&&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(Jr,{className:"text-red-500 mt-0.5"}),t.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:w})]})}),O&&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(Jr,{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:O})," this work order?"]})]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>F(O),disabled:y,className:"px-3 py-1.5 bg-red-600 hover:bg-red-700 text-white text-sm rounded-md disabled:opacity-50",children:y?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(Ir,{className:"animate-spin",size:12}),"Processing..."]}):`Yes, ${O}`}),t.jsx("button",{onClick:z,disabled:y,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"})]})]}),!g&&X.length>0&&!O&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 flex items-center gap-1",children:[t.jsx(il,{size:12}),"Available Actions"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:X.map((B,Y)=>t.jsxs("button",{onClick:()=>F(B.action),disabled:y,className:`px-4 py-2 rounded-lg text-sm font-medium transition-colors disabled:opacity-50 flex items-center gap-2 ${A(B.action)}`,title:`Move to: ${B.next_state}`,children:[y?t.jsx(Ir,{className:"animate-spin",size:14}):t.jsx("span",{children:C(B.action)}),B.action]},`${B.action}-${Y}`))}),t.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:X.map((B,Y)=>t.jsxs("span",{className:"inline-block mr-3",children:[B.action," → ",t.jsx("span",{className:"font-medium",children:B.next_state})]},Y))})]}),!g&&X.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"})})]})},Qu={getComments(e,r){return me(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 Xt.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 me(this,null,function*(){const s=Or.BASE_URL,n=yield fetch(`${s}/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 c=yield n.json().catch(()=>({}));throw new Error((c==null?void 0:c.exc)||(c==null?void 0:c._server_messages)||"Failed to post comment")}return(yield n.json()).data})},deleteComment(e){return me(this,null,function*(){const r=Or.BASE_URL,a=yield fetch(`${r}/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 me(this,null,function*(){var c;const r=Or.BASE_URL,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(`${r}/api/resource/User?filters=${encodeURIComponent(a)}&fields=${encodeURIComponent(s)}&limit_page_length=20&order_by=full_name asc`,{credentials:"include"});return n.ok?((c=(yield n.json()).data)!=null?c:[]).filter(u=>u.name!=="Administrator"&&u.name!=="Guest"):[]})},getCurrentUser(){return me(this,null,function*(){const e=Or.BASE_URL;return(yield(yield fetch(`${e}/api/method/frappe.auth.get_logged_user`,{credentials:"include"})).json()).message||""})}};function PH({referenceDoctype:e,referenceName:r,pollInterval:a=3e4}){const[s,n]=_.useState([]),[i,c]=_.useState(!0),[u,h]=_.useState(!1),[g,y]=_.useState(null),[w,E]=_.useState(""),[S,A]=_.useState([]),[C,O]=_.useState(!1),M=_.useRef(null);_.useEffect(()=>{Qu.getCurrentUser().then(E).catch(()=>{})},[]);const R=_.useCallback(()=>me(null,null,function*(){if(!r){n([]),c(!1);return}try{const X=yield Qu.getComments(e,r);n(X),y(null)}catch(X){console.error("Error fetching comments:",X),y(X.message||"Failed to load comments")}finally{c(!1)}}),[e,r]);_.useEffect(()=>{c(!0),R()},[R]),_.useEffect(()=>{if(!a||!r)return;const X=setInterval(R,a);return()=>clearInterval(X)},[a,R,r]);const F=_.useCallback(X=>me(null,null,function*(){if(r){h(!0);try{yield Qu.postComment(e,r,X),yield R()}catch(B){throw B}finally{h(!1)}}}),[e,r,R]),z=_.useCallback(X=>me(null,null,function*(){try{yield Qu.deleteComment(X),n(B=>B.filter(Y=>Y.name!==X))}catch(B){throw B}}),[]),W=_.useCallback(X=>me(null,null,function*(){M.current&&clearTimeout(M.current),O(!0),M.current=setTimeout(()=>me(null,null,function*(){try{const B=yield Qu.searchUsers(X);A(B)}catch(B){A([])}finally{O(!1)}}),250)}),[]);return{comments:s,loading:i,posting:u,error:g,currentUser:w,refetch:R,postComment:F,deleteComment:z,mentionUsers:S,mentionLoading:C,searchMentionUsers:W}}const LH=({value:e,onChange:r,onSubmit:a,placeholder:s="Type a comment… Use @ to mention someone",disabled:n=!1,mentionUsers:i,mentionLoading:c,onMentionSearch:u,posting:h=!1})=>{const g=_.useRef(null),y=_.useRef(null),[w,E]=_.useState(!1),[S,A]=_.useState(""),[C,O]=_.useState(null),[M,R]=_.useState(0),[F,z]=_.useState([]),[W,X]=_.useState({top:0,left:0}),B=_.useCallback(()=>{var we,ee;const ge=g.current;if(!ge)return;const re=ge.getBoundingClientRect();(ee=(we=ge.offsetParent)==null?void 0:we.getBoundingClientRect())!=null,X({top:ge.offsetTop-4,left:ge.offsetLeft})},[]),Y=ge=>{var ce;const re=ge.target.value,we=(ce=ge.target.selectionStart)!=null?ce:0;r(re);const ee=re.substring(0,we),ve=ee.lastIndexOf("@");if(ve!==-1){const ye=ve>0?re[ve-1]:" ";if(ye===" "||ye===`
`||ve===0){const te=ee.substring(ve+1);if(!te.includes(" ")||te.length<=30){E(!0),A(te),O(ve),R(0),u(te),B();return}}}E(!1),O(null)},G=_.useCallback(ge=>{var te;if(C===null)return;const re=g.current,we=e.substring(0,C),ee=(te=re==null?void 0:re.selectionStart)!=null?te:C+S.length+1,ve=e.substring(ee),ce=ge.full_name||ge.name,ye=`${we}@${ce} ${ve}`;z(q=>[...q,{startIndex:C,displayText:ce,userId:ge.name,fullName:ge.full_name||ge.name}]),r(ye),E(!1),O(null),A(""),setTimeout(()=>{if(re){re.focus();const q=we.length+ce.length+2;re.selectionStart=q,re.selectionEnd=q}},0)},[C,S,e,r]),ie=ge=>{if(w&&i.length>0)switch(ge.key){case"ArrowDown":ge.preventDefault(),R(re=>Math.min(re+1,i.length-1));return;case"ArrowUp":ge.preventDefault(),R(re=>Math.max(re-1,0));return;case"Enter":ge.preventDefault(),G(i[M]);return;case"Escape":ge.preventDefault(),E(!1);return}ge.key==="Enter"&&(ge.ctrlKey||ge.metaKey)&&(ge.preventDefault(),K())},fe=_.useCallback(ge=>{let re=ge;const we=Or.BASE_URL,ee=[...F].sort((ve,ce)=>ce.startIndex-ve.startIndex);for(const ve of ee){const ce=`@${ve.displayText}`,ye=re.indexOf(ce);if(ye===-1)continue;const te=`${we}/app/user-profile/${encodeURIComponent(ve.userId)}`,q=`<span class="mention" data-id="${ve.userId}" data-value="&lt;a href=&quot;${te}&quot; target=&quot;_blank&quot;&gt;${ve.fullName}" data-denotation-char="@" data-is-group="false" data-link="${te}">\uFEFF<span contenteditable="false"><span class="ql-mention-denotation-char">@</span><a href="${te}" target="_blank">${ve.fullName}</a></span>\uFEFF</span>`;re=re.substring(0,ye)+q+re.substring(ye+ce.length)}return re=re.replace(/\n/g,"<br>"),`<div class="ql-editor read-mode"><p>${re}</p></div>`},[F]),K=()=>{const ge=e.trim();if(!ge||h)return;const re=fe(ge);a(re),z([])};_.useEffect(()=>{const ge=re=>{y.current&&!y.current.contains(re.target)&&g.current&&!g.current.contains(re.target)&&E(!1)};return document.addEventListener("mousedown",ge),()=>document.removeEventListener("mousedown",ge)},[]),_.useEffect(()=>{if(!y.current)return;const ge=y.current.querySelector(`[data-idx="${M}"]`);ge==null||ge.scrollIntoView({block:"nearest"})},[M]);const ke=Or.BASE_URL;return t.jsxs("div",{className:"relative",children:[w&&t.jsx("div",{ref:y,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:c&&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(Ir,{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((ge,re)=>t.jsxs("button",{"data-idx":re,type:"button",className:`w-full flex items-center gap-2.5 px-3 py-2 text-left transition-colors
${re===M?"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:()=>R(re),onMouseDown:we=>{we.preventDefault(),G(ge)},children:[ge.user_image?t.jsx("img",{src:`${ke}${ge.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(Yn,{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:ge.full_name||ge.name}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:ge.name})]})]},ge.name))}),t.jsxs("div",{className:"flex gap-2 items-end",children:[t.jsx("textarea",{ref:g,value:e,onChange:Y,onKeyDown:ie,placeholder:s,disabled:n||h,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:K,disabled:n||h||!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:h?t.jsxs(t.Fragment,{children:[t.jsx(Ir,{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"]})]})},e4={Comment:{icon:t.jsx(Om,{size:10}),color:"text-blue-600 dark:text-blue-400",label:"Comment"},Info:{icon:t.jsx(il,{size:10}),color:"text-gray-500 dark:text-gray-400",label:"Info"},Edit:{icon:t.jsx(Ms,{size:10}),color:"text-orange-500 dark:text-orange-400",label:"Edit"},Attachment:{icon:t.jsx(sT,{size:10}),color:"text-purple-500 dark:text-purple-400",label:"Attachment"},Like:{icon:t.jsx(rf,{size:10}),color:"text-pink-500 dark:text-pink-400",label:"Like"}},BH=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),c=Math.floor(s/864e5);return n<1?"Just now":n<60?`${n}m ago`:i<24?`${i}h ago`:c<7?`${c}d ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:r.getFullYear()!==a.getFullYear()?"numeric":void 0})},UH=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())},zH=({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}})},Kd=({referenceDoctype:e,referenceName:r,title:a="Comments & Discussion",pollInterval:s=3e4,initialLimit:n=5,collapsible:i=!0,startCollapsed:c=!1})=>{const{comments:u,loading:h,posting:g,error:y,currentUser:w,refetch:E,postComment:S,deleteComment:A,mentionUsers:C,mentionLoading:O,searchMentionUsers:M}=PH({referenceDoctype:e,referenceName:r,pollInterval:s}),[R,F]=_.useState(!c),[z,W]=_.useState(!1),[X,B]=_.useState(""),[Y,G]=_.useState(null),ie=_.useMemo(()=>u.filter(ge=>ge.comment_type==="Comment"),[u]),fe=_.useMemo(()=>z?u:u.slice(-n),[u,z,n]),K=ge=>me(null,null,function*(){try{yield S(ge),B(""),Mt.success("Comment posted!",{position:"top-right",autoClose:2e3,icon:t.jsx(Tr,{})})}catch(re){Mt.error(`Failed to post comment: ${re.message||"Unknown error"}`,{position:"top-right",autoClose:5e3,icon:t.jsx(Br,{})})}}),ke=ge=>me(null,null,function*(){G(ge);try{yield A(ge),Mt.success("Comment deleted",{position:"top-right",autoClose:2e3,icon:t.jsx(Tr,{})})}catch(re){Mt.error(`Failed to delete: ${re.message||"Unknown error"}`,{position:"top-right",autoClose:5e3,icon:t.jsx(Br,{})})}finally{G(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&&F(ge=>!ge),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Om,{className:"text-teal-500",size:16}),t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white",children:a}),ie.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:ie.length})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:ge=>{ge.stopPropagation(),E()},disabled:h,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(Ui,{className:h?"animate-spin":"",size:11})}),i&&t.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:R?t.jsx(Mn,{size:12}):t.jsx(on,{size:12})})]})]}),R&&t.jsxs("div",{className:"p-5 space-y-5",children:[y&&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(Jr,{size:12}),y]}),h&&u.length===0&&t.jsxs("div",{className:"flex items-center justify-center py-8",children:[t.jsx(Ir,{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…"})]}),u.length>0&&t.jsxs(t.Fragment,{children:[!z&&u.length>n&&t.jsxs("button",{type:"button",onClick:()=>W(!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 ",u.length-n," older comment",u.length-n!==1?"s":""]}),t.jsx("div",{className:"space-y-3",children:fe.map(ge=>{const re=e4[ge.comment_type]||e4.Comment,we=ge.comment_email===w||ge.owner===w,ee=Y===ge.name;return t.jsx("div",{className:`group relative rounded-lg border transition-colors ${ge.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(Yn,{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:ge.comment_by||UH(ge.comment_email||ge.owner)}),ge.comment_type!=="Comment"&&t.jsxs("span",{className:`ml-2 inline-flex items-center gap-1 text-[10px] font-medium ${re.color}`,children:[re.icon,re.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(ge.creation).toLocaleString(),children:[t.jsx(Ja,{size:9}),BH(ge.creation)]}),we&&ge.comment_type==="Comment"&&t.jsx("button",{type:"button",onClick:()=>ke(ge.name),disabled:ee,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:ee?t.jsx(Ir,{className:"animate-spin",size:10}):t.jsx(la,{size:10})})]})]}),t.jsx("div",{className:"ml-9",children:t.jsx(zH,{html:ge.content})})]})},ge.name)})}),z&&u.length>n&&t.jsx("button",{type:"button",onClick:()=>W(!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"})]}),!h&&u.length===0&&t.jsxs("div",{className:"text-center py-8",children:[t.jsx(Om,{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(LH,{value:X,onChange:B,onSubmit:K,disabled:!r,posting:g,mentionUsers:C,mentionLoading:O,onMentionSearch:M})})]})]}):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(Om,{className:"text-gray-400"}),t.jsx("span",{className:"text-sm",children:"Save the document first to enable comments."})]})})},WH=({doctype:e,docname:r,limit:a=50,enabled:s=!0})=>{const[n,i]=_.useState([]),[c,u]=_.useState(!1),[h,g]=_.useState(null),y=_.useCallback(()=>me(null,null,function*(){if(!(!s||!e||!r)){u(!0),g(null);try{const w=yield Xt.apiCall(`/api/resource/Version?filters=[["ref_doctype","=","${encodeURIComponent(e)}"],["docname","=","${encodeURIComponent(r)}"]]&fields=["name","owner","creation","data"]&order_by=creation desc&limit=${a}`);if(w!=null&&w.data&&w.data.length>0){const E=w.data.map(S=>{let A={added:[],changed:[],removed:[],row_changed:[]};try{A=JSON.parse(S.data||"{}")}catch(O){console.error("Error parsing version data:",O)}const C=(A.changed||[]).map(O=>({field:O[0]||"",oldValue:O[1],newValue:O[2]}));return{name:S.name,owner:S.owner,creation:S.creation,changes:C,added:A.added||[],removed:A.removed||[],rowChanged:A.row_changed||[]}});i(E)}else i([])}catch(w){console.error(`Error fetching audit logs for ${e}/${r}:`,w),g(w instanceof Error?w.message:"Failed to load activity log"),i([])}finally{u(!1)}}}),[e,r,a,s]);return _.useEffect(()=>{y()},[y]),{auditLogs:n,loading:c,error:h,refetch:y}},HH=e=>e?e.replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase()):"",t4=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),dS=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),c=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`:c<7?`${c} day${c>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"})},uS=e=>{if(!e)return"Unknown";const r=e.indexOf("@");return r===-1?e:e.substring(0,r)},$H=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"},VH=({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,c=a?"text-[10px]":"text-xs",u=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(Yn,{className:"text-gray-500 dark:text-gray-400",size:i})}),t.jsx("span",{className:`${c} font-medium text-gray-700 dark:text-gray-300`,children:uS(e.owner)})]}),t.jsxs("div",{className:`flex items-center gap-1 ${c} text-gray-500 dark:text-gray-400`,children:[t.jsx(Ja,{size:i}),t.jsx("span",{title:new Date(e.creation).toLocaleString(),children:dS(e.creation)})]})]}),t.jsxs("div",{className:"space-y-1",children:[e.changes.length>0?e.changes.map((h,g)=>t.jsxs("div",{className:c,children:[t.jsx("span",{className:`font-medium ${$H(h.field)}`,children:HH(h.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 ${u} font-mono`,children:t4(h.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 ${u} font-mono`,children:t4(h.newValue)})]},g)):t.jsx("p",{className:`${c} text-gray-500 dark:text-gray-400 italic`,children:"Document updated"}),e.added&&e.added.length>0&&t.jsxs("div",{className:`${c} 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:`${c} 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:`${c} text-orange-600 dark:text-orange-400`,children:[t.jsx("span",{className:"font-medium",children:"Modified:"})," ",e.rowChanged.length," row(s)"]})]})]})]})},r4=({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",c=s?8:10,u=s?"text-[10px]":"text-xs",h=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(Yn,{className:"text-green-600 dark:text-green-400",size:c})}),t.jsx("span",{className:`${u} font-medium text-gray-700 dark:text-gray-300`,children:uS(r)})]}),t.jsxs("div",{className:`flex items-center gap-1 ${u} text-gray-500 dark:text-gray-400`,children:[t.jsx(Ja,{size:c}),t.jsx("span",{title:new Date(e).toLocaleString(),children:dS(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 ${u} font-medium`,children:[t.jsx(Tr,{size:c}),"Created this ",h]})]})]})},fS=({doctype:e,docname:r,creationDate:a,createdBy:s,title:n="Activity Log",limit:i=50,initialVisible:c=5,collapsible:u=!0,startCollapsed:h=!1,compact:g=!1,className:y="",onRefresh:w})=>{const[E,S]=_.useState(!h),[A,C]=_.useState(!1),{auditLogs:O,loading:M,refetch:R}=WH({doctype:e,docname:r,limit:i,enabled:!!r}),F=()=>{R(),w==null||w()};if(!r)return null;const z=g?14:16,W=g?"text-sm":"text-base",X=g?"left-2":"left-3",B=g?"text-[10px]":"text-xs",Y=g?8:10,G=A?O:O.slice(0,c);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 ${y}`,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 ${u?"cursor-pointer":""}`,onClick:()=>u&&S(!E),children:[t.jsx(Id,{className:"text-blue-500",size:z}),t.jsx("h2",{className:`${W} font-semibold text-gray-800 dark:text-white`,children:n}),O.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:O.length})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button",onClick:ie=>{ie.stopPropagation(),F()},disabled:M,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(Ui,{className:M?"animate-spin":"",size:g?10:12})}),u&&t.jsx("button",{type:"button",onClick:()=>S(!E),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors p-1",children:E?t.jsx(Mn,{size:g?12:14}):t.jsx(on,{size:g?12:14})})]})]}),E&&t.jsxs("div",{className:"p-3",children:[M&&t.jsxs("div",{className:"flex items-center justify-center py-6",children:[t.jsx(Ir,{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..."})]}),!M&&O.length===0&&t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:`absolute ${X} top-0 bottom-0 w-0.5 bg-gray-200 dark:bg-gray-700`}),t.jsxs("div",{className:`relative ${g?"pl-6":"pl-8"} mb-3`,children:[t.jsx("div",{className:`absolute ${g?"left-1":"left-1.5"} top-1 ${g?"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:`${g?"p-2":"p-3"} rounded-lg bg-gray-50 dark:bg-gray-700/50`,children:t.jsx("p",{className:`${g?"text-[10px]":"text-xs"} text-gray-500 dark:text-gray-400 italic`,children:"No changes recorded yet"})})]}),a&&s&&t.jsx(r4,{creationDate:a,createdBy:s,doctype:e,compact:g})]}),!M&&O.length>0&&t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:`absolute ${X} top-0 bottom-0 w-0.5 bg-gray-200 dark:bg-gray-700`}),t.jsx("div",{className:"space-y-3",children:G.map((ie,fe)=>t.jsx(VH,{log:ie,isLatest:fe===0,compact:g},ie.name))}),O.length>c&&t.jsx("div",{className:"mt-3 text-center",children:t.jsx("button",{type:"button",onClick:()=>C(!A),className:`inline-flex items-center gap-1 px-2 py-1 ${B} 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:A?t.jsxs(t.Fragment,{children:[t.jsx(Mn,{size:Y})," Show Less"]}):t.jsxs(t.Fragment,{children:[t.jsx(on,{size:Y})," Show All (",O.length,")"]})})}),a&&s&&t.jsx("div",{className:"mt-3",children:t.jsx(r4,{creationDate:a,createdBy:s,doctype:e,compact:g})})]})]})]})},GH=()=>{var fr,Kt;const{t:e}=Rr(),{assetName:r}=ml(),a=Na(),[s]=Sn(),n=s.get("duplicate"),i=r==="new",c=i&&!!n,{isAllowedOnSubmit:u}=sS("Asset"),[h,g]=_.useState({asset_name:"",company:"",custom_serial_number:"",custom_local_id:"",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:"",is_existing_asset:!0,__islocal:!1}),{shouldShowField:y,isMandatory:w,isReadOnly:E}=nS("Asset",h),{asset:S,loading:A,error:C,refetch:O}=RW(c?n:i?null:r||null),{planned:M,completed:R,overdue:F,loading:z}=kH(i?null:r||null),{createAsset:W,updateAsset:X,submitAsset:B,loading:Y}=Kj(),G=(S==null?void 0:S.workflow_state)||"Draft",{transitions:ie,workflowInfo:fe,userRoles:K,isSystemManager:ke,error:ge,canEdit:re,getStateStyle:we}=Lg({doctype:"Asset",docname:i?null:r||null,workflowState:G,enabled:!i&&!!r,docData:h}),[ee,ve]=_.useState(i),ce=(fr=S==null?void 0:S.docstatus)!=null?fr:0,ye=ce===1,te=ce===2,q=ce===0,J=!!(S!=null&&S.custom_delete_status),ae=_.useMemo(()=>{const Re=["System Manager","Contractor Supervisor","Contractor Manager"];return ke||K.some(Q=>Re.includes(Q))},[ke,K]);_.useMemo(()=>ae&&(fe!=null&&fe.transitions)?fe.transitions.filter(Q=>Q.state===G).map(Q=>({action:Q.action,next_state:Q.next_state,allowed:Q.allowed,condition:Q.condition})):ie,[ae,fe,G,ie]);const oe=_.useMemo(()=>i||ae?!0:te?!1:fe&&G?re:q||ie.length>0,[i,ae,te,fe,G,re,q,ie.length]),le=_.useMemo(()=>ke?!0:!(K.includes("Contractor Supervisor")||K.includes("End user")&&K.filter(Q=>!["End user","All","Guest","Desk User"].includes(Q)).length===0),[ke,K]),be=_.useMemo(()=>K.includes("Cluster Manager")||ke,[ke,K]),[Z,Le]=_.useState(!1),Pe=_.useRef(null),Be=_.useRef(null);_.useEffect(()=>{if(!Z||!window.matchMedia("(min-width: 1024px)").matches)return;const Q=he=>{Pe.current&&!Pe.current.contains(he.target)&&Le(!1)};return document.addEventListener("click",Q),()=>document.removeEventListener("click",Q)},[Z]),_.useEffect(()=>{if(!Z||window.matchMedia("(min-width: 1024px)").matches)return;const Q=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=Q}},[Z]),_.useEffect(()=>{},[S,ce,q,ye,te,ee]);const pe=_.useCallback(Re=>!ee||te||J||E(Re)?!0:ye?!u(Re):!q,[ee,te,ye,q,u,E,J]),rt=_.useCallback(Re=>y(Re),[y]);_.useCallback(Re=>w(Re),[w]);const ct=_.useCallback(()=>!!(h.custom_building||h.department),[h.custom_building,h.department]),et=_.useCallback(()=>!!(h.department||h.custom_room_number),[h.department,h.custom_room_number]),It=_.useCallback(()=>!!(h.custom_room_number||h.location),[h.custom_room_number,h.location]),[ft,Lt]=_.useState(""),[Je,Ve]=_.useState({}),[Xe,Rt]=_.useState([]),[qe,Dt]=_.useState([]),[ar,yt]=_.useState(!1),[St,Ot]=_.useState(!1);_.useEffect(()=>{i&&!h.available_for_use_date&&g(Re=>Ke(Te({},Re),{available_for_use_date:new Date().toISOString().split("T")[0],__islocal:!0}))},[i]),_.useEffect(()=>{function Re(){return me(this,null,function*(){try{const Q=yield Xt.getUserDetails();Lt(Q.custom_site_name||""),g(he=>{const Se={};if(i||!he.company){const ne=Q.custom_site_name||"King Fahad Specialist Hospital - Dammam";Se.company=ne,Se.asset_owner_company=ne}return!he.custom_site&&Q.custom_phcc_site_name&&(Se.custom_site=Q.custom_phcc_site_name),Te(Te({},he),Se)})}catch(Q){console.error("Error loading user details",Q)}})}Re()},[i]);const Yt=()=>{const Q={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]};g(he=>Ke(Te({},he),{finance_books:[...he.finance_books||[],Q]}))},Ye=Re=>{g(Q=>{const he=[...Q.finance_books||[]];return he.splice(Re,1),Ke(Te({},Q),{finance_books:he})})},wt=(Re,Q)=>{g(he=>{const Se=[...he.finance_books||[]];return Se[Re]=Te(Te({},Se[Re]||{}),Q),Ke(Te({},he),{finance_books:Se})})};_.useEffect(()=>{if(h.calculate_depreciation&&(!h.finance_books||h.finance_books.length===0)){const Q={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]};g(he=>Ke(Te({},he),{finance_books:[Q]}))}},[h.calculate_depreciation]);const zt=(Re,Q,he)=>{g(Se=>{const ne=[...Se.custom_spare_parts||[]],_e=Te({},ne[Re]);Q==="qty"||Q==="rate"?(_e[Q]=he,_e.amount=(_e.qty||0)*(_e.rate||0)):_e[Q]=he,ne[Re]=_e;const Ce=ne.reduce((Qe,xt)=>Qe+(xt.amount||0),0);return Ke(Te({},Se),{custom_spare_parts:ne,custom_total_spare_parts_amount:Ce})})},qt=()=>{g(Re=>Ke(Te({},Re),{custom_spare_parts:[...Re.custom_spare_parts||[],{qty:0,rate:0,amount:0}]}))},kt=Re=>{g(Q=>{const he=[...Q.custom_spare_parts||[]];he.splice(Re,1);const Se=he.reduce((ne,_e)=>ne+(_e.amount||0),0);return Ke(Te({},Q),{custom_spare_parts:he,custom_total_spare_parts_amount:Se})})};_.useEffect(()=>{if(h.available_for_use_date){const Re=new Date(h.available_for_use_date),he=new Date().getTime()-Re.getTime(),ne=Math.floor(he/(1e3*60*60*24))*24,_e=ne-(h.custom_down_time||0);g(Ce=>Ke(Te({},Ce),{custom_total_hours:ne,custom_up_time:_e}))}},[h.available_for_use_date,h.custom_down_time]);const ze=_.useRef("");_.useEffect(()=>{if(!ee){ze.current=h.custom_asset_type||"";return}const Re=(h.custom_asset_type||"").toString().trim().toLowerCase(),Q=(ze.current||"").toString().trim().toLowerCase();Re!==Q&&(ze.current=h.custom_asset_type||"",Re==="biomedical"?h.custom_site_contractor!=="SAMAMA"&&g(he=>Ke(Te({},he),{custom_site_contractor:"SAMAMA"})):Q==="biomedical"&&h.custom_site_contractor==="SAMAMA"&&g(he=>Ke(Te({},he),{custom_site_contractor:""})))},[h.custom_asset_type,ee]),_.useEffect(()=>{const Re={};h.company&&(Re.company=h.company);const Q=ft&&ft.startsWith("Mobile")||h.company&&h.company.startsWith("Mobile");(ft||h.company)&&(Q?Re.department_name=["not like","Non Bio%"]:Re.department_name=["not like","Non Bio%"]),Ve(Re)},[h.company,ft]);const nt=_.useCallback((Re,Q)=>me(null,null,function*(){if(!Re){Rt([]);return}Ot(!0);try{const he=new URLSearchParams;he.append("building",Re),Q&&he.append("company",Q);const _e=(yield(yield fetch(`/api/method/asset_lite.api.room_filter.get_department_count?${he.toString()}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json()).message||0;Rt(new Array(_e).fill("")),console.log("Department count for Asset:",{building:Re,company:Q,count:_e})}catch(he){console.error("Error fetching department count:",he),Rt([])}finally{Ot(!1)}}),[]),_t=_.useCallback((Re,Q)=>me(null,null,function*(){if(!Re&&!Q){Dt([]);return}yt(!0);try{const he=new URLSearchParams;Re&&he.append("building",Re),Q&&he.append("department",Q);const _e=(yield(yield fetch(`/api/method/asset_lite.api.room_filter.get_room_count?${he.toString()}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json()).message||0;Dt(new Array(_e).fill("")),console.log("Room count for Asset:",{building:Re,department:Q,count:_e})}catch(he){console.error("Error fetching room count:",he),Dt([])}finally{yt(!1)}}),[]);_.useEffect(()=>{const Re=h.custom_building||void 0,Q=h.company||void 0;Re?nt(Re,Q):Rt([])},[h.custom_building,h.company,nt]),_.useEffect(()=>{const Re=h.custom_building||void 0,Q=h.department||void 0;Re||Q?_t(Re,Q):Dt([])},[h.custom_building,h.department,_t]);const lr=_.useCallback(Re=>me(null,null,function*(){if(g(Q=>Ke(Te({},Q),{custom_room_number:Re})),!Re){g(Q=>Ke(Te({},Q),{location:""}));return}try{const Q=h.custom_building||"",he=h.department||"",Se=[["room_no","=",Re]];Q&&Se.push(["building","=",Q]),he&&Se.push(["department","=",he]);const ne=JSON.stringify(Se),_e=yield Xt.apiCall(`/api/resource/Infrastructure Location?filters=${encodeURIComponent(ne)}&fields=["location"]&limit=1`);_e!=null&&_e.data&&_e.data.length>0&&_e.data[0].location&&(g(Ce=>Ke(Te({},Ce),{location:_e.data[0].location})),console.log("Auto-set location:",_e.data[0].location))}catch(Q){console.error("Error fetching location for room:",Q)}}),[h.custom_building,h.department]);_.useEffect(()=>{S&&(ze.current=S.custom_asset_type||"",g({asset_name:c?`${S.asset_name} (Copy)`:S.asset_name||"",company:S.company||"",custom_serial_number:c?"":S.custom_serial_number||"",custom_local_id:c?"":S.custom_local_id||"",custom_technical_department:S.custom_technical_department||"",location:S.location||"",custom_manufacturer:S.custom_manufacturer||"",department:S.department||"",custom_asset_type:S.custom_asset_type||"Non Biomedical",custom_category:S.custom_category||"General",custom_manufacturing_year:S.custom_manufacturing_year||"",custom_model:S.custom_model||"",custom_class:S.custom_class||"",custom_device_status:S.custom_device_status||"",custom_down_time:S.custom_down_time||0,asset_owner_company:S.asset_owner_company||"",custom_up_time:S.custom_up_time||0,custom_total_hours:S.custom_total_hours||0,custom_modality:S.custom_modality||"",custom_attach_image:S.custom_attach_image||"",custom_site_contractor:S.custom_site_contractor||"",custom_site:S.custom_site||"",custom_total_amount:S.custom_total_amount||0,gross_purchase_amount:S.gross_purchase_amount||0,available_for_use_date:S.available_for_use_date||"",calculate_depreciation:S.calculate_depreciation||!1,finance_books:S.finance_books||[],custom_service_agreement:S.custom_service_agreement||"",custom_service_coverage:S.custom_service_coverage||"",custom_start_date:S.custom_start_date?S.custom_start_date.split(" ")[0]:"",custom_end_date:S.custom_end_date?S.custom_end_date.split(" ")[0]:"",custom_building:S.custom_building||"",custom_room_number:S.custom_room_number||"",custom_warranty:S.custom_warranty||!1,custom_extended_warranty:S.custom_extended_warranty||!1,custom__service_contract:S.custom__service_contract||!1,custom_covering_spare_parts:S.custom_covering_spare_parts||!1,custom_spare_parts_labour:S.custom_spare_parts_labour||!1,custom_covering_labour:S.custom_covering_labour||!1,custom_ppm_only:S.custom_ppm_only||!1,custom_support_plan:S.custom_support_plan||"",custom_spare_parts:S.custom_spare_parts||[],custom_total_spare_parts_amount:S.custom_total_spare_parts_amount||0}))},[S,c]);const[pr,Nr]=_.useState(null);_.useEffect(()=>{if(!r||r==="new")return;me(null,null,function*(){var Q;try{const he=`/files/${r}-qr.png`;if((yield fetch(he,{method:"HEAD"})).ok){Nr(he);return}const ne=yield Xt.apiCall(`/api/resource/File?filters=[["File","attached_to_name","=","${r}"]]`);((Q=ne==null?void 0:ne.data)==null?void 0:Q.length)>0&&Nr(ne.data[0].file_url)}catch(he){console.error("Error loading QR code:",he)}})},[r,S]);const rr=Re=>{const{name:Q,value:he}=Re.target;g(Se=>Ke(Te({},Se),{[Q]:he}))},_r=Re=>me(null,null,function*(){if(Re.preventDefault(),!h.asset_name){alert(e("assets.pleaseEnterAssetName"));return}if(!h.custom_asset_type){alert(e("assets.pleaseSelectCategory"));return}console.log("Submitting asset data:",h);try{if(i||c){const Q=yield W(h);if(Q.name){const Se=`/files/${Q.name}-qr.png`;Nr(Se)}const he=e(c?"assets.detail.assetDuplicatedSuccess":"assets.detail.assetCreatedSuccess");alert(he),a(`/assets/${Q.name}`)}else r&&(yield X(r,h),alert(e("assets.detail.assetUpdatedSuccess")),ve(!1),O())}catch(Q){console.error("Asset save error:",Q);const he=Q instanceof Error?Q.message:"Unknown error";he.includes("404")||he.includes("not found")||he.includes("has no attribute")||he.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: `+he):alert(e("assets.detail.failedToSave")+`:
`+he)}}),Nt=()=>{O()},Cr=()=>me(null,null,function*(){if(!r||i){alert(e("assets.detail.cannotSubmitNotSaved"));return}if(window.confirm(e("assets.detail.confirmSubmit")))try{yield B(r),alert(e("assets.detail.assetSubmittedSuccess")),O(),ve(!1)}catch(Re){console.error("Asset submit error:",Re);const Q=Re instanceof Error?Re.message:"Unknown error";alert(e("assets.detail.failedToSubmit")+`:
`+Q)}});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("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(C&&!i&&!c)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"),": ",C]}),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(C&&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-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 yr=()=>{if(!pr||!S)return;const Re=_m();if(!Re){km();return}const Q=CH(pr),he=window.matchMedia("(min-width: 1024px)").matches;Re.write(`
<!DOCTYPE html>
<html>
<head>
<title>Print QR Code - ${S.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> ${S.name}<br/>
<strong>Asset Name:</strong> ${S.asset_name||"N/A"}
</div>
<img src="${Q}" alt="QR Code" class="qr-image"${he?' onload="window.print();"':""} />
</div>
</body>
</html>
`)},jt=()=>me(null,null,function*(){if(!r||i){alert(e("assets.detail.pleaseSaveFirstForPPM"));return}const Re=_m("Loading...");if(!Re){km();return}try{const Q=yield Xt.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"]`),he=(Q==null?void 0:Q.data)||[],Se=($e,tt)=>{const gt=new Date($e);return gt.setDate(gt.getDate()+tt),gt},ne=($e,tt)=>{const gt=new Date($e);return gt.setMonth(gt.getMonth()+tt),gt},_e=($e,tt)=>{const gt=new Date($e);return gt.setFullYear(gt.getFullYear()+tt),gt},Ce=($e,tt)=>{switch(tt){case"Daily":return Se($e,1);case"Weekly":return Se($e,7);case"Monthly":return ne($e,1);case"Quarterly":return ne($e,3);case"Half-yearly":return ne($e,6);case"Yearly":return _e($e,1);case"2 Yearly":return _e($e,2);case"3 Yearly":return _e($e,3);default:return ne($e,1)}},Qe=$e=>$e.toISOString().split("T")[0],xt=_e(new Date,5),dt=[];for(const $e of he){let tt=new Date($e.due_date);const gt=$e.periodicity||"Monthly";for(let Wt=0;Wt<60&&(dt.push({asset_name:$e.asset_name||"",custom_asset_names:$e.custom_asset_names||"",serial_number:h.custom_serial_number||"N/A",due_date:Qe(tt),periodicity:gt,maintenance_type:$e.maintenance_type||"",assign_to_name:$e.assign_to_name||"",status:"Planned"}),tt=Ce(tt,gt),!(tt>xt));Wt++);}dt.sort(($e,tt)=>new Date($e.due_date).getTime()-new Date(tt.due_date).getTime());const at=dt.length>0?dt.map(($e,tt)=>`
<tr class="${tt%2===0?"bg-white":"bg-gray-50"}">
<td class="border px-3 py-2">${$e.asset_name}</td>
<td class="border px-3 py-2">${$e.custom_asset_names}</td>
<td class="border px-3 py-2">${$e.serial_number}</td>
<td class="border px-3 py-2">${$e.due_date}</td>
<td class="border px-3 py-2">${$e.periodicity}</td>
<td class="border px-3 py-2">${$e.maintenance_type}</td>
<td class="border px-3 py-2">${$e.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">${$e.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>';Re.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> ${h.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>
${at}
</tbody>
</table>
</div>
<div class="summary">
<strong>Summary:</strong> ${dt.length} planned maintenance entries for the next 5 years
</div>
</div>
</body>
</html>
`)}catch(Q){console.error("Error fetching PPM Plan:",Q),Re.close(),alert(e("assets.detail.failedToLoadPPMPlan"))}}),Tt=()=>me(null,null,function*(){if(!r||i){alert(e("assets.detail.pleaseSaveFirstForHistory"));return}const Re=_m("Loading...");if(!Re){km();return}try{const Q=yield Xt.apiCall(`/api/resource/Asset/${r}`),he=(Q==null?void 0:Q.data)||{},Se=yield Xt.apiCall(`/api/resource/Work_Order?filters=[["asset","=","${r}"]]&fields=["name","work_order_type","repair_status","creation","total_repair_cost"]`),ne=(Se==null?void 0:Se.data)||[],_e=yield Xt.apiCall(`/api/resource/Asset Maintenance?filters=[["asset_name","=","${r}"]]&fields=["name","maintenance_team","custom_type_of_maintenance"]`),Ce=(_e==null?void 0:_e.data)||[];let Qe=[],xt=[];for(const vr of Ce){const da=yield Xt.apiCall(`/api/resource/Asset Maintenance/${vr.name}`),zr=(da==null?void 0:da.data)||{};zr.asset_maintenance_tasks&&(xt=[...xt,...zr.asset_maintenance_tasks.map(Yr=>Ke(Te({},Yr),{maintenance_id:vr.name}))]);const Kr=yield Xt.apiCall(`/api/resource/Asset Maintenance Log?filters=[["asset_maintenance","=","${vr.name}"]]&fields=["name","maintenance_status","assign_to_name","maintenance_type","due_date","completion_date","periodicity","actions_performed"]&order_by=completion_date desc`);Qe=[...Qe,...(Kr==null?void 0:Kr.data)||[]]}const dt=Qe.filter(vr=>vr.maintenance_status==="Completed"),at=Qe.filter(vr=>vr.maintenance_status!=="Completed"),$e={};Qe.forEach(vr=>{$e[vr.maintenance_status]=($e[vr.maintenance_status]||0)+1});const tt=he.custom_spare_parts||[],gt={};tt.forEach(vr=>{const da=vr.work_order||"Unassigned";gt[da]||(gt[da]=[]),gt[da].push(vr)});const Wt=ne.length>0?ne.map((vr,da)=>{const zr=vr.repair_status==="Completed"?"bg-green-100 text-green-800":vr.repair_status==="Work In Progress"?"bg-yellow-100 text-yellow-800":"bg-gray-100 text-gray-800";return`
<tr class="${da%2===0?"bg-white":"bg-gray-50"}">
<td class="px-4 py-3 font-medium text-blue-600">${vr.name}</td>
<td class="px-4 py-3">${vr.work_order_type||"-"}</td>
<td class="px-4 py-3"><span class="px-2 py-1 rounded-full text-xs font-medium ${zr}">${vr.repair_status||"-"}</span></td>
<td class="px-4 py-3 font-semibold">${parseFloat(vr.total_repair_cost||0).toFixed(2)} ر.س</td>
<td class="px-4 py-3 text-gray-500">${vr.creation?new Date(vr.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 Ft="";Object.keys(gt).length>0?Object.keys(gt).forEach(vr=>{Ft+=`
<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">${vr}</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>
${gt[vr].map((da,zr)=>`
<tr class="${zr%2===0?"bg-white":"bg-gray-50"}">
<td class="px-4 py-2">${da.item_code||"-"}</td>
<td class="px-4 py-2">${da.qty||0}</td>
<td class="px-4 py-2">${da.rate||0} ر.س</td>
<td class="px-4 py-2 font-medium">${da.amount||0} ر.س</td>
</tr>
`).join("")}
</tbody>
</table>
</div>
`}):Ft='<p class="text-gray-500 text-center py-8">No Spare Parts Used</p>';const Zt=Ce.length>0?Ce.map(vr=>`
<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">${vr.name}</p>
</div>
<div class="text-right">
<p class="text-sm text-gray-500">Type</p>
<p class="font-medium">${vr.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">${vr.maintenance_team||"-"}</p>
</div>
</div>
`).join(""):'<p class="text-gray-500 text-center py-8">No Maintenance Records Found</p>',br=xt.length>0?xt.map((vr,da)=>`
<tr class="${da%2===0?"bg-white":"bg-gray-50"}">
<td class="px-4 py-3">${vr.assign_to_name||"-"}</td>
<td class="px-4 py-3">${vr.periodicity||"-"}</td>
<td class="px-4 py-3">${vr.next_due_date||"-"}</td>
<td class="px-4 py-3 text-blue-600 text-sm">${vr.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>',Ht=Object.keys($e).length>0?Object.entries($e).map(([vr,da])=>`
<div class="flex items-center justify-between p-3 rounded-lg border ${vr==="Completed"?"bg-green-100 text-green-800 border-green-200":vr==="Planned"?"bg-blue-100 text-blue-800 border-blue-200":"bg-yellow-100 text-yellow-800 border-yellow-200"}">
<span class="font-medium">${vr}</span>
<span class="text-2xl font-bold">${da}</span>
</div>
`).join(""):'<p class="text-gray-500 text-center">No Data</p>',fa=dt.length>0?dt.map((vr,da)=>`
<tr class="${da%2===0?"bg-white":"bg-gray-50"}">
<td class="px-3 py-2 text-blue-600 font-medium">${vr.name}</td>
<td class="px-3 py-2">${vr.assign_to_name||"-"}</td>
<td class="px-3 py-2">${vr.maintenance_type||"-"}</td>
<td class="px-3 py-2">${vr.due_date||"-"}</td>
<td class="px-3 py-2 text-green-600 font-medium">${vr.completion_date||"-"}</td>
<td class="px-3 py-2">${vr.periodicity||"-"}</td>
<td class="px-3 py-2 text-sm text-gray-600">${vr.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>',qr=at.length>0?at.map((vr,da)=>{const zr=vr.maintenance_status==="Planned"?"bg-blue-100 text-blue-800":"bg-yellow-100 text-yellow-800";return`
<tr class="${da%2===0?"bg-white":"bg-gray-50"}">
<td class="px-3 py-2 text-blue-600 font-medium">${vr.name}</td>
<td class="px-3 py-2">${vr.assign_to_name||"-"}</td>
<td class="px-3 py-2">${vr.maintenance_type||"-"}</td>
<td class="px-3 py-2">${vr.due_date||"-"}</td>
<td class="px-3 py-2">${vr.periodicity||"-"}</td>
<td class="px-3 py-2"><span class="px-2 py-1 rounded-full text-xs font-medium ${zr}">${vr.maintenance_status||"-"}</span></td>
<td class="px-3 py-2 text-sm text-gray-600">${vr.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>';Re.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">${he.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">${he.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">${he.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">${he.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">${he.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>
${Wt}
</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">
${Ft}
</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">
${Zt}
</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>
${br}
</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">
${Ht}
</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>
${fa}
</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>
${qr}
</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>
`)}catch(Q){console.error("Error fetching Asset History:",Q),Re.close(),alert("Failed to load Asset History. Please try again.")}}),He=()=>{if(!r||i){alert("Please save the asset first to view Dismantling Report");return}const Re=_m();if(!Re){km();return}const Q=new Date,he=_e=>{const Ce=String(_e.getDate()).padStart(2,"0"),Qe=String(_e.getMonth()+1).padStart(2,"0"),xt=_e.getFullYear();return`${Ce}/${Qe}/${xt}`},Se=S!=null&&S.creation?new Date(S.creation):null;let ne="";if(Se){const _e=Math.floor((Q.getTime()-Se.getTime())/31536e6),Ce=Math.floor((Q.getTime()-Se.getTime())%(1e3*60*60*24*365)/(1e3*60*60*24*30));ne=`${_e} سنة و ${Ce} شهر`}Re.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;">${h.department||""}</span>
</div>
<!-- Equipment Data Section -->
<div class="section-title">0-1 بيانات الجهاز المطلوب تكهينه :</div>
<table class="equipment-table">
<tr>
<td>اسم الجهاز</td>
<td>${h.asset_name||""}</td>
<td>الرقم التسلسلي</td>
<td>${h.custom_serial_number||""}</td>
</tr>
<tr>
<td>الشركة الصانعة</td>
<td>${h.custom_manufacturer||""}</td>
<td>تاريخ التوريد</td>
<td>${Se?he(Se):""}</td>
</tr>
<tr>
<td>الطراز/الموديل</td>
<td>${h.custom_model||""}</td>
<td>مدة استخدام الجهاز</td>
<td>${ne}</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>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</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>
`)},Fe=Re=>{if(window.matchMedia("(min-width: 1024px)").matches){Re(),Le(!1);return}Le(!1),window.setTimeout(()=>Re(),0)},Ze=()=>{if(!r||i)return;const Re=S||h,Q=new URLSearchParams,he=(Se,ne)=>{ne!=null&&String(ne).trim()!==""&&Q.append(Se,String(ne))};he("asset",r),he("asset_name",Re.asset_name||h.asset_name),he("asset_type",Re.custom_asset_type||h.custom_asset_type),he("manufacturer",Re.custom_manufacturer||h.custom_manufacturer),he("serial_number",Re.custom_serial_number||h.custom_serial_number),he("local_id",Re.custom_local_id||h.custom_local_id),he("work_order_type",Re.custom_technical_department||h.custom_technical_department),he("department",Re.department||h.department),he("site_contractor",Re.custom_site_contractor||h.custom_site_contractor),he("subcontractor",Re.custom_subcontractor),he("company",Re.company||h.company),he("custom_service_agreement",Re.custom_service_agreement||h.custom_service_agreement),he("custom_service_coverage",Re.custom_service_coverage||h.custom_service_coverage),he("site_name",Re.custom_site||h.custom_site),he("supplier",Re.supplier||h.supplier),he("building",Re.custom_building||h.custom_building),he("room_no",Re.custom_room_number||h.custom_room_number),he("location",Re.location||h.location),he("team_leader",Re.team_leader||Re.custom_team_leader||Re.custom_assigned_supervisor),he("moh_supervisor",Re.moh_supervisor||Re.custom_moh_supervisor||Re.maintenance_manager),a(`/work-orders/new?${Q.toString()}`)},vt="px-3 py-1 rounded-lg flex items-center gap-2 text-sm min-h-[36px]",ir=()=>t.jsxs(t.Fragment,{children:[pr&&t.jsxs("button",{type:"button",onClick:()=>Fe(yr),className:"flex min-h-[48px] w-full items-center gap-2 px-4 py-2 text-left text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700",children:[t.jsx(jd,{size:14}),"Print QR"]}),t.jsxs("button",{type:"button",onClick:()=>Fe(jt),className:"flex min-h-[48px] w-full items-center gap-2 px-4 py-2 text-left text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700",children:[t.jsx($o,{size:14}),"PPM Plan"]}),t.jsxs("button",{type:"button",onClick:()=>Fe(Tt),className:"flex min-h-[48px] w-full items-center gap-2 px-4 py-2 text-left text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700",children:[t.jsx(Id,{size:14}),"Asset History"]}),(S==null?void 0:S.status)==="Scrapped"&&t.jsxs("button",{type:"button",onClick:()=>Fe(He),className:"flex min-h-[48px] w-full items-center gap-2 border-t border-gray-200 px-4 py-2 text-left text-sm text-red-600 hover:bg-red-50 dark:border-gray-700 dark:text-red-400 dark:hover:bg-red-900/20",children:[t.jsx(lT,{size:14}),"Dismantling Report"]})]});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 flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("button",{type:"button",onClick:()=>a(-1),className:"flex min-h-[44px] items-center gap-2 text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:[t.jsx(Kn,{}),t.jsx("span",{className:"text-gray-900 dark:text-white font-medium",children:c?"Duplicate Asset":i?"New Asset Details":"Asset Details"})]}),S&&t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${we(G).bg} ${we(G).text} ${we(G).border} border`,children:G})})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:justify-end",children:[!i&&!ee&&!z&&t.jsxs(t.Fragment,{children:[M>0&&t.jsxs("button",{type:"button",onClick:()=>a(`/maintenance?asset=${encodeURIComponent(r)}&status=Planned`),className:"min-h-[44px] rounded-lg border border-orange-300 bg-orange-50 px-2 py-1 text-sm font-medium text-orange-700 hover:bg-orange-100 dark:border-orange-700 dark:bg-orange-900/20 dark:text-orange-300 dark:hover:bg-orange-900/30",children:[e("assetDetail.plannedPms")," (",M,")"]}),R>0&&t.jsxs("button",{type:"button",onClick:()=>a(`/maintenance?asset=${encodeURIComponent(r)}&status=Completed`),className:"min-h-[44px] rounded-lg border border-green-300 bg-green-50 px-2 py-1 text-sm font-medium text-green-700 hover:bg-green-100 dark:border-green-700 dark:bg-green-900/20 dark:text-green-300 dark:hover:bg-green-900/30",children:[e("assetDetail.completedPms")," (",R,")"]}),F>0&&t.jsxs("button",{type:"button",onClick:()=>a(`/maintenance?asset=${encodeURIComponent(r)}&status=Overdue`),className:"min-h-[44px] rounded-lg border border-red-300 bg-red-50 px-2 py-1 text-sm font-medium text-red-700 hover:bg-red-100 dark:border-red-700 dark:bg-red-900/20 dark:text-red-300 dark:hover:bg-red-900/30",children:[e("assetDetail.overduePms")," (",F,")"]})]}),!i&&!ee&&!te&&oe&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative",ref:Pe,children:[t.jsxs("button",{type:"button",onClick:()=>Le(!Z),className:`${vt} bg-blue-600 text-white hover:bg-blue-700`,children:["Actions",t.jsx(on,{size:12,className:`transition-transform ${Z?"rotate-180":""}`})]}),Z&&t.jsx("div",{className:"absolute right-0 z-50 mt-2 hidden w-56 rounded-md border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-800 lg:block",children:t.jsx("div",{className:"py-1",children:ir()})})]}),Z&&gg.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button","aria-label":"Close actions menu",className:"fixed inset-0 z-[10000] bg-black/50 lg:hidden",onClick:()=>Le(!1)}),t.jsxs("div",{ref:Be,className:"fixed inset-x-0 bottom-0 z-[10001] max-h-[85vh] overflow-y-auto rounded-t-2xl border-t border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-800 lg:hidden",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-700",children:[t.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-white",children:"Actions"}),t.jsx("button",{type:"button",onClick:()=>Le(!1),className:"flex min-h-[44px] min-w-[44px] items-center justify-center rounded-lg text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-700","aria-label":"Close",children:t.jsx(Pt,{size:18})})]}),t.jsx("div",{className:"py-1",children:ir()})]})]}),document.body),le&&!J&&t.jsxs("button",{type:"button",onClick:()=>ve(!0),className:`${vt} bg-blue-600 text-white hover:bg-blue-700`,children:[t.jsx(Ms,{}),"Edit"]}),t.jsxs("button",{type:"button",onClick:Ze,className:`${vt} bg-green-600 text-white hover:bg-green-700`,children:[t.jsx(Js,{}),"Add New WO"]}),q&&be&&t.jsxs("button",{type:"button",onClick:Cr,disabled:Y,className:`${vt} bg-purple-600 text-white hover:bg-purple-700 disabled:opacity-50`,children:[t.jsx(Z4,{}),Y?"Submitting...":"Submit"]})]}),te&&t.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 italic",children:"Cancelled documents cannot be edited"}),ee&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{i?a(-1):ve(!1)},className:"bg-gray-300 hover:bg-gray-400 text-gray-700 dark:text-gray-800 px-2 py-1 rounded-lg",disabled:Y,children:"Cancel"}),t.jsxs("button",{onClick:_r,disabled:Y,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(bs,{}),Y?"Saving...":"Save Changes"]})]})]})]}),t.jsxs("form",{onSubmit:_r,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:h.asset_name,onChange:rr,placeholder:e("assets.detail.placeholderAssetName"),required:!0,disabled:pe("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:h.custom_category||"General",onChange:rr,disabled:pe("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(hr,{label:e("assets.detail.modality"),doctype:"Modality",value:h.custom_modality||"",onChange:Re=>g(Ke(Te({},h),{custom_modality:Re})),disabled:pe("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:h.custom_class,onChange:rr,disabled:pe("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||c?e("assets.detail.autoGenerated"):S==null?void 0:S.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"}),c&&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:h.custom_device_status,onChange:rr,disabled:!ee,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:h.custom_serial_number,onChange:rr,placeholder:e("assets.detail.placeholderSerialCode"),disabled:pe("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.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.localId")}),t.jsx("input",{type:"text",name:"custom_local_id",value:h.custom_local_id||"",onChange:rr,placeholder:e("assets.detail.placeholderLocalId"),disabled:pe("custom_local_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.jsx(hr,{label:e("assets.detail.technicalDepartment"),doctype:"Issue Type",value:h.custom_technical_department||"",onChange:Re=>g(Ke(Te({},h),{custom_technical_department:Re})),disabled:pe("custom_technical_department")}),t.jsx(hr,{label:e("assets.detail.manufacturer"),doctype:"Manufacturer",value:h.custom_manufacturer||"",onChange:Re=>g(Ke(Te({},h),{custom_manufacturer:Re})),disabled:pe("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:h.custom_model,onChange:rr,placeholder:e("assets.detail.placeholderModelNumber"),disabled:pe("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:h.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:h.custom_down_time||0,onChange:rr,placeholder:e("assets.detail.placeholderZero"),disabled:pe("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:h.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(hr,{label:e("assets.detail.hospital"),doctype:"Company",value:h.company||"",onChange:Re=>{g(Ke(Te({},h),{company:Re,asset_owner_company:Re,department:""}))},disabled:pe("company"),filters:{domain:"Healthcare"}}),rt("custom_site")&&t.jsx("div",{children:t.jsx(hr,{label:e("assets.detail.siteName"),doctype:"Mobile Team Site",value:h.custom_site||"",onChange:Re=>g(Ke(Te({},h),{custom_site:Re})),disabled:pe("custom_site"),placeholder:e("assets.detail.selectSite")})}),t.jsxs("div",{children:[t.jsx(hr,{label:e("assets.detail.building"),doctype:"Building",value:h.custom_building||"",onChange:Re=>{g(Q=>Ke(Te({},Q),{custom_building:Re,department:"",custom_room_number:"",location:""}))},disabled:pe("custom_building"),allowQuickCreate:!0}),!h.custom_building&&ee&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:e("assets.detail.selectBuildingFirst")})]}),ct()&&t.jsxs("div",{children:[t.jsx(hr,{label:e("assets.detail.department"),doctype:"Department",value:h.department||"",onChange:Re=>{g(Q=>Ke(Te({},Q),{department:Re,custom_room_number:"",location:""}))},disabled:pe("department"),query:h.custom_building?"asset_lite.api.room_filter.get_filtered_departments":void 0,filters:(()=>{const Re={};return h.custom_building&&(Re.building=h.custom_building),h.company&&(Re.company=h.company),ft&&ft.startsWith("Mobile")||h.company&&h.company.startsWith("Mobile")||(Re.department_name=["not like","Non Bio%"]),Re})(),allowQuickCreate:!0}),St&&t.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400 flex items-center gap-1",children:[t.jsx(Ir,{className:"animate-spin",size:10}),e("common.loading")]}),!St&&h.custom_building&&Xe.length===0&&t.jsx("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:e("assets.detail.noDepartmentsMapped")}),!St&&h.custom_building&&Xe.length>0&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:e("assets.detail.departmentsAvailable",{count:Xe.length})}),!h.department&&h.custom_building&&ee&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:e("assets.detail.selectDepartmentForRoom")})]}),et()&&t.jsxs("div",{children:[t.jsx(hr,{label:e("assets.detail.roomNumber"),doctype:"Room",value:h.custom_room_number||"",onChange:lr,disabled:pe("custom_room_number"),query:"asset_lite.api.room_filter.get_filtered_rooms",filters:(()=>{const Re={};return h.custom_building&&(Re.building=h.custom_building),h.department&&(Re.department=h.department),Re})(),allowQuickCreate:!0}),ar&&t.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400 flex items-center gap-1",children:[t.jsx(Ir,{className:"animate-spin",size:10}),e("common.loading")]}),!ar&&(h.custom_building||h.department)&&qe.length===0&&t.jsxs("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:["No rooms mapped to ",h.custom_building&&h.department?"this building + department":h.custom_building?"this building":"this department"]}),!ar&&(h.custom_building||h.department)&&qe.length>0&&t.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:[qe.length," room(s) available",h.custom_building&&!h.department&&" (filtered by building)",!h.custom_building&&h.department&&" (filtered by department)",h.custom_building&&h.department&&" (filtered by building + department)"]}),!h.custom_room_number&&h.department&&ee&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:e("assets.detail.selectRoomFirst")})]}),It()&&t.jsxs("div",{children:[t.jsx(hr,{label:e("assets.detail.location"),doctype:"Location",value:h.location||"",onChange:Re=>g(Ke(Te({},h),{location:Re})),disabled:pe("location"),allowQuickCreate:!0}),h.custom_room_number&&h.location&&t.jsxs("p",{className:"mt-1 text-xs text-green-600 dark:text-green-400",children:["✓ ",e("assets.detail.autoSetFromRoom")]})]})]})]}),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:pr?t.jsxs(t.Fragment,{children:[t.jsx("img",{src:pr,alt:`QR Code for ${(S==null?void 0:S.name)||"Asset"}`,className:"w-[120px] h-[120px] object-contain",onError:Re=>{const Q=Re.target;Q.style.display="none";const he=Q.nextElementSibling;he&&(he.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(jd,{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(jd,{size:80,className:"text-gray-400 dark:text-gray-500"})})}),(S==null?void 0:S.name)&&t.jsxs("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400 text-center",children:["Asset ID: ",S.name]})]}),!i&&S&&!c&&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(db,{doctype:"Asset",docname:r||null,workflowState:G,onActionComplete:(Re,Q)=>{Q&&O()},onStateChange:Nt,showStateInfo:!0,className:""}),ge&&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:ge})}),!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:!ee,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:h.custom_site_contractor,onChange:rr,disabled:pe("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:!ee,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:h.custom_service_agreement||"",onChange:rr,disabled:pe("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:h.custom_service_coverage||"",onChange:rr,disabled:pe("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:h.custom_start_date||"",onChange:rr,disabled:pe("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:h.custom_end_date||"",onChange:rr,disabled:pe("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:h.custom_total_amount,onChange:rr,disabled:pe("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:!ee,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:!ee,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(hr,{label:e("assets.detail.supplierVendor"),doctype:"Supplier",value:h.supplier||"",onChange:Re=>g(Ke(Te({},h),{supplier:Re})),disabled:pe("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:h.gross_purchase_amount||0,onChange:rr,disabled:pe("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:!ee,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:!ee,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:h.available_for_use_date||"",onChange:Re=>g(Q=>Ke(Te({},Q),{available_for_use_date:Re.target.value})),disabled:pe("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:h.calculate_depreciation,onChange:Re=>g(Ke(Te({},h),{calculate_depreciation:Re.target.checked})),disabled:!ee,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")})]}),h.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")}),ee&&t.jsxs("button",{type:"button",onClick:Yt,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")]})]}),(!h.finance_books||h.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")}),h.finance_books&&h.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"),"*"]}),ee&&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:h.finance_books.map((Re,Q)=>{var he,Se;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(hr,{label:"",doctype:"Finance Book",value:Re.finance_book||"",onChange:ne=>wt(Q,{finance_book:ne}),disabled:!ee})})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("select",{value:Re.depreciation_method||"",onChange:ne=>wt(Q,{depreciation_method:ne.target.value}),disabled:!ee,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:(he=Re.total_number_of_depreciations)!=null?he:"",onChange:ne=>wt(Q,{total_number_of_depreciations:Number(ne.target.value)}),disabled:!ee,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:(Se=Re.frequency_of_depreciation)!=null?Se:"",onChange:ne=>wt(Q,{frequency_of_depreciation:Number(ne.target.value)}),disabled:!ee,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:Re.depreciation_start_date||"",onChange:ne=>wt(Q,{depreciation_start_date:ne.target.value}),disabled:!ee,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"})}),ee&&t.jsx("td",{className:"px-4 py-3 text-center",children:t.jsx("button",{type:"button",onClick:()=>Ye(Q),className:"px-3 py-2 bg-red-600 text-white rounded-md hover:bg-red-700 transition-colors",children:"Remove"})})]},Q)})})]})})})]})]})}),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:!ee,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:!ee,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"}),ee&&t.jsxs("button",{type:"button",onClick:qt,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")]})]}),(!h.custom_spare_parts||h.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")}),h.custom_spare_parts&&h.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"}),ee&&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:h.custom_spare_parts.map((Re,Q)=>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:Re.item_code||"",onChange:he=>zt(Q,"item_code",he.target.value),disabled:!ee,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:Re.item_name||"",onChange:he=>zt(Q,"item_name",he.target.value),disabled:!ee,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:Re.qty||0,onChange:he=>zt(Q,"qty",Number(he.target.value)),disabled:!ee,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:Re.rate||0,onChange:he=>zt(Q,"rate",Number(he.target.value)),disabled:!ee,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:Re.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:Re.uom||"",onChange:he=>zt(Q,"uom",he.target.value),disabled:!ee,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"})}),ee&&t.jsx("td",{className:"px-4 py-3 text-center",children:t.jsx("button",{type:"button",onClick:()=>kt(Q),className:"px-3 py-2 bg-red-600 text-white rounded-md hover:bg-red-700 transition-colors text-sm",children:"Remove"})})]},Q))}),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:h.custom_total_spare_parts_amount||0}),t.jsx("td",{colSpan:ee?2:1})]})})]})})]})]}),!i&&t.jsx(Kd,{referenceDoctype:"Asset",referenceName:r||null,title:"Comments & Discussion",pollInterval:3e4,initialLimit:5,collapsible:!0,startCollapsed:!1}),!i&&!c&&t.jsx("div",{className:"mt-6",children:t.jsx(fS,{doctype:"Asset",docname:r||null,creationDate:S==null?void 0:S.creation,createdBy:S==null?void 0:S.owner,compact:!1,initialVisible:5,collapsible:!0,startCollapsed:!0})}),!i&&((S==null?void 0:S.docstatus)===0||(S==null?void 0:S.docstatus)===1||(S==null?void 0:S.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(rd,{doctype:"Asset",docname:r,currentDeleteStatus:(Kt=S==null?void 0:S.custom_delete_status)!=null?Kt:null,userRoles:K,isSystemManager:ke,redirectOnDelete:"/assets",onStatusChange:()=>{O()}})]})]})},YH=["name","modified","asset_name","asset","work_order_type","actions_performed","department","repair_status","custom_priority_","custom_delete_status","workflow_state","company","creation"];function a4({filters:e,fields:r,limit:a=20,offset:s=0,orderBy:n,orFilters:i}){const c=Ln(e||{}),u=c.length>0?c:{},h={doctype:"Work_Order",filters:u,fields:r||YH,limit_start:s,limit_page_length:a,order_by:n||"creation desc"},g={doctype:"Work_Order",filters:u};return i&&i.length>0&&(h.or_filters=i,g.or_filters=i),{listRequestBody:h,countRequestBody:g}}class qH{fetchWorkOrderListPage(r,a,s=20,n=0,i,c){return me(this,null,function*(){const{listRequestBody:u}=a4({filters:r,fields:a,limit:s,offset:n,orderBy:i,orFilters:c}),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}`);return(yield h.json()).message||[]})}fetchWorkOrderCount(r,a){return me(this,null,function*(){const{countRequestBody:s}=a4({filters:r,orFilters:a}),n=yield fetch("/api/method/frappe.desk.reportview.get_count",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ke(Te({},s),{fields:[]}))});if(!n.ok)return 0;const i=yield n.json();return typeof i.message=="number"?i.message:0})}getWorkOrders(r,a,s=20,n=0,i,c){return me(this,null,function*(){try{const u=yield this.fetchWorkOrderListPage(r,a,s,n,i,c),h=yield this.fetchWorkOrderCount(r,c);return{work_orders:u,total_count:h||u.length,limit:s,offset:n,has_more:n+s<(h||u.length)}}catch(u){throw console.error("[workOrderService] getWorkOrders error:",u),u}})}getWorkOrderDetails(r){return me(this,null,function*(){const a=`${Or.ENDPOINTS.GET_WORK_ORDER_DETAILS}?work_order_name=${encodeURIComponent(r)}`;return Xt.apiCall(a)})}createWorkOrder(r){return me(this,null,function*(){return Xt.apiCall(Or.ENDPOINTS.CREATE_WORK_ORDER,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({work_order_data:r})})})}updateWorkOrder(r,a){return me(this,null,function*(){return Xt.apiCall(Or.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 me(this,null,function*(){return Xt.apiCall(Or.ENDPOINTS.DELETE_WORK_ORDER,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({work_order_name:r})})})}updateWorkOrderStatus(r,a,s){return me(this,null,function*(){return Xt.apiCall(Or.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 me(this,null,function*(){return Xt.apiCall(Or.ENDPOINTS.GET_WORK_ORDER_FILTERS)})}getWorkOrderStats(){return me(this,null,function*(){return Xt.apiCall(Or.ENDPOINTS.GET_WORK_ORDER_STATS)})}searchWorkOrders(r,a=10){return me(this,null,function*(){const s=`${Or.ENDPOINTS.SEARCH_WORK_ORDERS}?search_term=${encodeURIComponent(r)}&limit=${a}`;return Xt.apiCall(s)})}submitWorkOrder(r){return me(this,null,function*(){return Xt.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 me(this,null,function*(){return Xt.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 me(this,null,function*(){const s={asset:r};return(yield this.getWorkOrders(s,void 0,a,0,"creation desc")).work_orders})}getOpenWorkOrders(r=50){return me(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 me(this,null,function*(){const s={custom_priority_:r};return(yield this.getWorkOrders(s,void 0,a,0,"creation desc")).work_orders})}}const Wc=new qH,XH=(e,r)=>{const a=Te({},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],c=a[s];if(typeof c=="string")i.includes(c)||(a[s]=["in",[]]);else if(Array.isArray(c)&&c[0]==="in"){const h=c[1].filter(g=>i.includes(g));a[s]=["in",h]}else a[s]=n}return a};function ZH(e,r=20,a=0,s,n={},i){const[c,u]=_.useState([]),[h,g]=_.useState(0),[y,w]=_.useState(!1),[E,S]=_.useState(!0),[A,C]=_.useState(null),[O,M]=_.useState(0),R=_.useRef(!1),F=JSON.stringify(e),z=JSON.stringify(n),W=JSON.stringify(i);_.useEffect(()=>{if(R.current&&A)return;let B=!1;return R.current=!0,me(null,null,function*(){try{S(!0);const G=XH(e,n),ie=yield Wc.fetchWorkOrderListPage(G,void 0,r,a,s,i);B||(u(ie),w(ie.length===r),C(null),S(!1));const fe=yield Wc.fetchWorkOrderCount(G,i);B||(g(fe||ie.length),w(a+r<(fe||ie.length)))}catch(G){if(!B){const ie=G instanceof Error?G.message:"Failed to fetch work orders";ie.includes("417")||ie.includes("Expectation Failed")||ie.includes("has no attribute")?C("API endpoint not deployed or misconfigured. Please check FIX_417_ERROR.md for solutions."):C(ie),u([]),g(0),w(!1),S(!1)}}}),()=>{B=!0}},[F,z,W,r,a,s,O]);const X=_.useCallback(()=>{R.current=!1,M(B=>B+1)},[]);return{workOrders:c,totalCount:h,hasMore:y,loading:E,error:A,refetch:X}}function KH(e){const[r,a]=_.useState(null),[s,n]=_.useState(!0),[i,c]=_.useState(null),u=_.useCallback(()=>me(null,null,function*(){if(!e){a(null),n(!1);return}try{n(!0),c(null);const g=yield Wc.getWorkOrderDetails(e);a(g)}catch(g){c(g instanceof Error?g.message:"Failed to fetch work order details")}finally{n(!1)}}),[e]);_.useEffect(()=>{u()},[u]);const h=_.useCallback(()=>{u()},[u]);return{workOrder:r,loading:s,error:i,refetch:h}}function hS(){const[e,r]=_.useState(!1),[a,s]=_.useState(null);return{createWorkOrder:g=>me(null,null,function*(){try{r(!0),s(null),console.log("[useWorkOrderMutations] Creating work order with data:",g);const y=yield Wc.createWorkOrder(g);if(console.log("[useWorkOrderMutations] Create work order response:",y),y.success)return y.work_order;{const w=y.error||"Failed to create work order";throw new Error(w)}}catch(y){console.error("[useWorkOrderMutations] Create work order error:",y);const w=y instanceof Error?y.message:"Failed to create work order";throw s(w),y}finally{r(!1)}}),updateWorkOrder:(g,y)=>me(null,null,function*(){try{r(!0),s(null),console.log("[useWorkOrderMutations] Updating work order:",g,"with data:",y);const w=yield Wc.updateWorkOrder(g,y);if(console.log("[useWorkOrderMutations] Update work order response:",w),w.success)return w.work_order;{const E=w.error||"Failed to update work order";throw new Error(E)}}catch(w){console.error("[useWorkOrderMutations] Update work order error:",w);const E=w instanceof Error?w.message:"Failed to update work order";throw s(E),w}finally{r(!1)}}),deleteWorkOrder:g=>me(null,null,function*(){try{r(!0),s(null);const y=yield Wc.deleteWorkOrder(g);if(!y.success)throw new Error("Failed to delete work order");return y}catch(y){const w=y instanceof Error?y.message:"Failed to delete work order";throw s(w),y}finally{r(!1)}}),submitWorkOrder:g=>me(null,null,function*(){try{r(!0),s(null),console.log("[useWorkOrderMutations] Submitting work order:",g);const y=yield Wc.submitWorkOrder(g);return console.log("[useWorkOrderMutations] Submit work order response:",y),y}catch(y){console.error("[useWorkOrderMutations] Submit work order error:",y);const w=y instanceof Error?y.message:"Failed to submit work order";throw s(w),y}finally{r(!1)}}),updateStatus:(g,y,w)=>me(null,null,function*(){try{r(!0),s(null);const E=yield Wc.updateWorkOrderStatus(g,y,w);if(E.success)return E.work_order;throw new Error("Failed to update work order status")}catch(E){const S=E instanceof Error?E.message:"Failed to update status";throw s(S),E}finally{r(!1)}}),loading:e,error:a}}const JH=["System Manager","Administrator","Contractor Supervisor","Contractor Manager","Work Control","End user"];function QH(){const[e,r]=_.useState(""),[a,s]=_.useState(!1),[n,i]=_.useState(!0),[c,u]=_.useState(null);_.useEffect(()=>{me(null,null,function*(){try{i(!0);const y=yield fetch("/api/method/asset_lite.api.user_roles.get_user_info_with_roles",{method:"GET",headers:{"Content-Type":"application/json"}});if(!y.ok)throw new Error(`HTTP error! status: ${y.status}`);const w=yield y.json();if(w.message){const{user:E,roles:S}=w.message;if(r(E||""),!E||E==="Guest"){s(!1);return}const A=S.includes("Technician"),C=S.some(M=>JH.includes(M)),O=A&&!C;console.log("[useTechnicianFilter] User:",E),console.log("[useTechnicianFilter] Roles:",S),console.log("[useTechnicianFilter] Has Technician:",A),console.log("[useTechnicianFilter] Has Full Access:",C),console.log("[useTechnicianFilter] Is Technician Only:",O),s(O)}u(null)}catch(y){console.error("[useTechnicianFilter] Error checking technician role:",y),u(y instanceof Error?y.message:"Failed to check user roles"),s(!1)}finally{i(!1)}})},[]);const h=_.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:h,loading:n,error:c}}const El=48,s4=10,e$=({isOpen:e,onClose:r})=>{const{t:a}=Rr(),[s,n]=_.useState(!1),[i,c]=_.useState(null),[u,h]=_.useState([]),[g,y]=_.useState([]),[w,E]=_.useState(!0),[S,A]=_.useState(""),[C,O]=_.useState(""),[M,R]=_.useState(!1),F=_.useRef(null),[z,W]=_.useState(0),[X,B]=_.useState(600),Y="Work Order Data",G=_.useCallback(()=>me(null,null,function*(){var le,be;n(!0),c(null),W(0);try{const Z={};S&&(Z.work_order_type=S),C&&(Z.repair_status=C);const Pe=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:Y,filters:Z,ignore_prepared_report:1})})).json();if(Pe.exc)throw new Error(Pe.exc);Pe.message&&(((le=Pe.message.columns)==null?void 0:le.length)>0&&y(Pe.message.columns),h((be=Pe.message.result)!=null?be:[]))}catch(Z){console.error("Error fetching report:",Z),c(Z instanceof Error?Z.message:"Failed to fetch report data"),h([])}finally{n(!1)}}),[S,C]);_.useEffect(()=>{e&&G()},[e,G]),_.useEffect(()=>{const le=be=>{be.key==="Escape"&&e&&r()};return document.addEventListener("keydown",le),()=>document.removeEventListener("keydown",le)},[e,r]),_.useEffect(()=>(document.body.style.overflow=e?"hidden":"unset",()=>{document.body.style.overflow="unset"}),[e]),_.useEffect(()=>{if(!F.current)return;const le=new ResizeObserver(([be])=>{B(be.contentRect.height)});return le.observe(F.current),B(F.current.clientHeight),()=>le.disconnect()},[e]);const ie=u.length*El,fe=Math.max(0,Math.floor(z/El)-s4),K=Math.ceil(X/El)+s4*2,ke=Math.min(u.length,fe+K),ge=_.useMemo(()=>u.slice(fe,ke),[u,fe,ke]),re=fe*El,we=_.useCallback(le=>{W(le.currentTarget.scrollTop)},[]),ee=()=>{A(""),O("")},ve=()=>{if(u.length!==0){R(!0);try{const be=[g.map(Be=>Be.label).join(","),...u.map(Be=>g.map(pe=>{var ct;let rt=(ct=Be[pe.fieldname])!=null?ct:"";return typeof rt=="string"&&(rt.includes(",")||rt.includes('"')||rt.includes(`
`))&&(rt=`"${rt.replace(/"/g,'""')}"`),rt}).join(","))].join(`
`),Z=new Blob(["\uFEFF"+be],{type:"text/csv;charset=utf-8;"}),Le=URL.createObjectURL(Z),Pe=document.createElement("a");Pe.href=Le,Pe.download=`work_order_report_${new Date().toISOString().split("T")[0]}.csv`,Pe.click(),URL.revokeObjectURL(Le)}finally{R(!1)}}},ce=()=>me(null,null,function*(){var le,be,Z;if(u.length!==0){R(!0);try{const Le={};S&&(Le.work_order_type=S),C&&(Le.repair_status=C);const Pe=yield fetch("/api/method/frappe.desk.query_report.export_query",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:Y,file_format_type:"Excel",filters:JSON.stringify(Le),ignore_prepared_report:1,visible_idx:g.map((ft,Lt)=>Lt)})});if(!Pe.ok)throw new Error(`Server returned ${Pe.status}`);const Be=yield Pe.blob(),rt=((le=Pe.headers.get("content-disposition"))!=null?le:"").match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/),ct=(Z=(be=rt==null?void 0:rt[1])==null?void 0:be.replace(/['"]/g,""))!=null?Z:`work_order_report_${new Date().toISOString().split("T")[0]}.xlsx`,et=URL.createObjectURL(Be),It=document.createElement("a");It.href=et,It.download=ct,It.click(),URL.revokeObjectURL(et)}catch(Le){console.error("Excel export error:",Le),alert("Excel export failed. Please try CSV instead.")}finally{R(!1)}}}),ye=_.useCallback(()=>{var pe,rt;if(u.length===0)return;const le=[S&&`Type: ${S}`,C&&`Status: ${C}`].filter(Boolean).join(" · "),be=u.map((ct,et)=>{const It=g.map(ft=>{const Lt=ct[ft.fieldname],Je=ae(Lt,ft);return`<td>${Je==="-"?"":Je}</td>`}).join("");return`<tr class="${et%2===0?"even":""}"><td class="num">${et+1}</td>${It}</tr>`}).join(""),Z=g.map(ct=>`<th>${ct.label}</th>`).join(""),Le=`<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Work Order Report</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Arial, sans-serif; font-size: 11px; color: #111; padding: 16px; }
h1 { font-size: 16px; margin-bottom: 4px; }
.meta { font-size: 10px; color: #555; margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; }
th { background: #4F46E5; color: #fff; padding: 6px 8px; text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
td { padding: 5px 8px; border-bottom: 1px solid #e5e7eb; vertical-align: middle; }
tr.even td { background: #f9fafb; }
td.num { color: #9ca3af; width: 36px; }
@media print {
@page { margin: 12mm; size: landscape; }
body { padding: 0; }
thead { display: table-header-group; }
tr { page-break-inside: avoid; }
}
</style>
</head>
<body>
<h1>Work Order Report</h1>
<div class="meta">
Generated: ${new Date().toLocaleString()}
&nbsp;·&nbsp; Total records: ${u.length.toLocaleString()}
${le?`&nbsp;·&nbsp; Filters: ${le}`:""}
</div>
<table>
<thead><tr><th>#</th>${Z}</tr></thead>
<tbody>${be}</tbody>
</table>
<script>window.onload = () => { window.print(); window.onafterprint = () => document.body.innerHTML = ''; }<\/script>
</body>
</html>`,Pe=document.createElement("iframe");Pe.style.cssText="position:fixed;width:0;height:0;border:0;visibility:hidden;",document.body.appendChild(Pe);const Be=Pe.contentDocument||((pe=Pe.contentWindow)==null?void 0:pe.document);if(!Be){document.body.removeChild(Pe);return}Be.open(),Be.write(Le),Be.close(),(rt=Pe.contentWindow)==null||rt.addEventListener("afterprint",()=>{document.body.removeChild(Pe)}),setTimeout(()=>{document.body.contains(Pe)&&document.body.removeChild(Pe)},6e4)},[u,g,S,C]),te=()=>ye(),q=le=>{switch(le==null?void 0:le.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"}},J=le=>{switch(le==null?void 0:le.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"}},ae=(le,be)=>{if(le==null||le==="")return"-";switch(be.fieldtype){case"Date":return new Date(le).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});case"Datetime":return new Date(le).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(le);default:return String(le)}},oe=(le,be,Z)=>{const Le=Z[le.fieldname],Pe=ae(Le,le);return le.fieldname==="repair_status"?t.jsx("td",{className:"px-4 whitespace-nowrap",style:{height:El},children:t.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${q(Le)}`,children:Pe})},be):le.fieldname==="custom_priority_"?t.jsx("td",{className:"px-4 whitespace-nowrap",style:{height:El},children:t.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${J(Le)}`,children:Pe})},be):le.fieldtype==="Link"&&le.fieldname==="name"?t.jsx("td",{className:"px-4 whitespace-nowrap",style:{height:El},children:t.jsx("a",{href:`/asm_app/work-orders/${Le}`,target:"_blank",rel:"noopener noreferrer",className:"text-indigo-600 dark:text-indigo-400 hover:underline font-medium text-sm",children:Pe})},be):t.jsx("td",{className:"px-4 text-sm text-gray-700 dark:text-gray-300",style:{height:El},title:typeof Le=="string"&&Le.length>50?Le:void 0,children:t.jsx("div",{className:"max-w-xs truncate",children:Pe})},be)};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(Kn,{size:18})}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Q4,{className:"text-white text-xl"}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-bold text-white",children:"Work Order Report"}),t.jsx("p",{className:"text-white/70 text-sm",children:s?"Loading…":`${u.length.toLocaleString()} record${u.length!==1?"s":""} found`})]})]})]}),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(Pt,{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:()=>E(!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(Hs,{size:12}),"Filters",(S||C)&&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:[S,C].filter(Boolean).length}),w?t.jsx(Mn,{size:10}):t.jsx(on,{size:10})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:G,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(Ui,{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:ve,disabled:u.length===0||M,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:[M?t.jsx(Ir,{className:"animate-spin",size:14}):t.jsx(No,{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:ce,disabled:u.length===0||M,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 (server-generated)",children:[M?t.jsx(Ir,{className:"animate-spin",size:14}):t.jsx(zi,{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:te,disabled:u.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(Hf,{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:ye,disabled:u.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(Go,{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.jsx("div",{className:"relative z-[70]",children:t.jsx(hr,{label:"Work Order Type",doctype:"Issue Type",value:S,onChange:le=>A(le),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:C,onChange:le=>O(le.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:ee,disabled:!S&&!C,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(Pt,{size:12}),"Clear Filters"]})})]})})]}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col p-6 gap-4",children:[s&&t.jsx("div",{className:"flex items-center justify-center py-20",children:t.jsxs("div",{className:"text-center",children:[t.jsx(Ir,{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: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"})]}),!s&&!i&&u.length===0&&t.jsxs("div",{className:"text-center py-20",children:[t.jsx(In,{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&&u.length>0&&t.jsxs("div",{className:"flex-1 overflow-hidden bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 shadow-sm flex flex-col",children:[t.jsx("div",{className:"overflow-x-auto flex-shrink-0",children:t.jsx("table",{className:"w-full",children:t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700",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:"#"}),g.map((le,be)=>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:le.width||120},children:le.label},be))]})})})}),t.jsx("div",{ref:F,className:"flex-1 overflow-auto",onScroll:we,children:t.jsx("div",{style:{height:ie,position:"relative"},children:t.jsx("table",{className:"w-full",style:{position:"absolute",top:0,left:0,transform:`translateY(${re}px)`},children:t.jsx("tbody",{children:ge.map((le,be)=>{const Z=fe+be;return t.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors border-b border-gray-200 dark:border-gray-700",style:{height:El},children:[t.jsx("td",{className:"px-4 text-sm text-gray-500 dark:text-gray-400 font-medium w-16",style:{height:El},children:Z+1}),g.map((Le,Pe)=>oe(Le,Pe,le))]},Z)})})})})})]})]}),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.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:u.length>0&&!s&&t.jsxs(t.Fragment,{children:["Showing all ",u.length.toLocaleString()," record",u.length!==1?"s":"",(S||C)&&" (filtered)"," · ",t.jsxs("span",{className:"text-gray-400 dark:text-gray-500",children:["rows ",fe+1,"–",Math.min(ke,u.length)," visible"]})]})}),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},t$=["CARPENTARY","MASONRY","PAINTING","PLUMPING"],r$="Civil works-الأعمال المدنية",a$=({isOpen:e,onClose:r,selectedWorkOrders:a,onConfirmClose:s,isClosing:n})=>{const{t:i}=Rr();if(!e)return null;const c=g=>{switch(g==null?void 0:g.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"}},u=a.filter(g=>{var y;return((y=g.workflow_state)==null?void 0:y.toLowerCase())==="closed"}).length,h=a.length-u;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(k1,{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(Pt,{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(Jr,{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:h})}),u>0&&t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:i("workOrders.closeModal.alreadyClosedNote",{count:u})})]})]})}),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(g=>{var w;const y=((w=g.workflow_state)==null?void 0:w.toLowerCase())==="closed";return t.jsxs("tr",{className:`${y?"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:g.name}),y&&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 ${c(g.repair_status)}`,children:g.repair_status||"Open"})})]},g.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:h>0?t.jsx("span",{children:i("workOrders.closeModal.willClose",{count:h})}):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:h===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(Ir,{className:"animate-spin",size:14}),i("workOrders.closeModal.closing")]}):t.jsxs(t.Fragment,{children:[t.jsx(k1,{size:14}),i("workOrders.closeModal.close")," ",h>0?`(${h})`:""]})})]})]})]})})},s$=()=>{const{t:e}=Rr(),r=Na(),[a,s]=Sn(),n=_.useMemo(()=>{const it=parseInt(a.get("page")||"1",10);return Math.max(0,Number.isNaN(it)?0:it-1)},[a]),i=_.useCallback(it=>{s(bt=>{const Qr=new URLSearchParams(bt);return Qr.set("page",String(it+1)),Qr})},[s]),[c,u]=_.useState(null),[h,g]=_.useState(null),y=_.useRef(null),w=20;a.get("asset"),a.get("work_order_type");const[E,S]=_.useState(!1),[A,C]=_.useState(new Set),[O,M]=_.useState(!1),[R,F]=_.useState(!1),[z,W]=_.useState(!1),[X,B]=_.useState(!1),[Y,G]=_.useState([]),[ie,fe]=_.useState(!1),[K,ke]=_.useState(!1),[ge,re]=_.useState(""),[we,ee]=_.useState([]),[ve,ce]=_.useState(!1),{permissionFilters:ye,error:te}=eb("Work_Order"),{technicianOrFilters:q,isTechnicianOnly:J,error:ae}=QH(),oe=["System Manager","Cluster Manager","Contractor Supervisor","Contractor Manager","Work Control"],le=["System Manager","Cluster Manager","Work Control","End user"],be=["System Manager","Maintenance Manager","Work Control","Technician","Contractor Supervisor","Contractor Manager","Contractor Engineer"],Z=["Cluster Manager"],[Le,Pe]=_.useState(!1),[Be,pe]=_.useState(!1),[rt,ct]=_.useState(!1);_.useEffect(()=>{me(null,null,function*(){try{const[bt,Qr,gr,En,Lr]=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:oe.join(",")})}),fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:le.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:Z.join(",")})}),fetch("/api/method/frappe.auth.get_logged_user",{credentials:"include"})]),[oa,gi,As,Os,$s]=yield Promise.all([bt.json(),Qr.json(),gr.json(),En.json(),Lr.json()]);oa.message&&Pe(oa.message.has_role),gi.message&&pe(gi.message.has_role),As.message&&ct(As.message.has_role),Os.message&&fe(Os.message.has_role);const Qa=$s.message||"";re(Qa);const[en,Qn]=yield Promise.all([fetch("/api/method/asset_lite.api.user_roles.get_user_roles",{credentials:"include"}),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(",")})})]),[Bn,So]=yield Promise.all([en.json(),Qn.json()]),cs=Array.isArray(Bn.message)?Bn.message:[];ee(cs);const Ds=cs.includes("System Manager");ce(Ds),So.message&&ke(!So.message.has_role)}catch(bt){console.error("Error checking permissions:",bt),Pe(!1),pe(!1),ct(!1),fe(!1),ke(!1)}})},[]);const[et,It]=_.useState(()=>a.get("date_filter_by")||""),[ft,Lt]=_.useState(()=>a.get("date_start")||""),[Je,Ve]=_.useState(()=>a.get("date_end")||""),[Xe,Rt]=_.useState(()=>a.get("work_order_id")||""),[qe,Dt]=_.useState(()=>a.get("asset")||""),[ar,yt]=_.useState(()=>a.get("work_order_type")||""),[St,Ot]=_.useState(()=>a.get("civil_work_category")||""),[Yt,Ye]=_.useState(()=>a.get("company")||""),[wt,zt]=_.useState(()=>a.get("status")||""),[qt,kt]=_.useState(()=>a.get("serial_number")||""),[ze,nt]=_.useState(()=>a.get("manufacturer")||""),[_t,lr]=_.useState(()=>a.get("supplier")||""),[pr,Nr]=_.useState(()=>a.get("department")||""),[rr,_r]=_.useState(()=>a.get("priority")||""),[Nt,Cr]=_.useState(()=>a.get("workflow_state")||""),[yr,jt]=_.useState(()=>a.get("extension_no")||""),[Tt,He]=_.useState(()=>a.get("building")||""),[Fe,Ze]=_.useState(()=>a.get("room_no")||""),[vt,ir]=_.useState(()=>a.get("location")||""),fr=ar===r$,Kt=["creation desc","creation asc","modified desc","modified asc","name asc","name desc"],[Re,Q]=_.useState(()=>a.get("sort_by")||"modified desc"),[he,Se]=_.useState(!0),[ne,_e]=_.useState(0),[Ce,Qe]=_.useState([]),[xt,dt]=_.useState(!1),[at,$e]=_.useState(""),[tt,gt]=_.useState(()=>a.get("serial_number")||""),Wt=_.useRef(null);_.useEffect(()=>{const it=localStorage.getItem("workOrderFilterPresets");it&&Qe(JSON.parse(it))},[]);const Ft=et&&(ft||Je);_.useEffect(()=>{const it=[Xe,qe,ar,fr?St:"",Yt,wt,qt,ze,_t,pr,rr,Nt,yr,Tt,Fe,vt].filter(Boolean).length+(Ft?1:0);_e(it)},[Ft,Xe,qe,ar,fr,St,Yt,wt,qt,ze,_t,pr,rr,Nt,yr,Tt,Fe,vt]);const Zt={};if(Xe&&(Zt.name=Xe),qe&&(Zt.asset=qe),ar&&(Zt.work_order_type=ar),fr&&St&&(Zt.custom_civil_work_category=St),Yt&&(Zt.company=Yt),wt){const it=wt.split(",").map(bt=>bt.trim()).filter(Boolean);Zt.repair_status=it.length>1?["in",it]:wt}qt&&(Zt.custom_serial_number=["like",`%${qt}%`]),ze&&(Zt.custom_manufacturer=ze),_t&&(Zt.supplier=_t),pr&&(Zt.department=pr),rr&&(Zt.custom_priority_=rr),Nt&&(Zt.workflow_state=Nt),yr&&(Zt.custom_extension_no=yr),Tt&&(Zt.custom_building=Tt),Fe&&(Zt.custom_room_no=Fe),vt&&(Zt.custom_location=vt),Object.assign(Zt,td(et,ft,Je)),Zt.custom_delete_status=["!=","Deleted"],K&&ge&&(Zt.owner=ge);const br=Kt.includes(Re)?Re:"modified desc",{workOrders:Ht,totalCount:fa,hasMore:qr,loading:vr,error:da,refetch:zr}=ZH(Zt,w,n*w,br,ye,q),{deleteWorkOrder:Kr,loading:Yr}=hS(),Gr=_.useRef(!1);_.useEffect(()=>{vr||(da||(Gr.current=!0),E||S(!0))},[vr,E,da]);const Sa=_.useRef(!1);_.useEffect(()=>{if(!Sa.current){Sa.current=!0;return}s(it=>{const bt=new URLSearchParams(it);return et?bt.set("date_filter_by",et):bt.delete("date_filter_by"),ft?bt.set("date_start",ft):bt.delete("date_start"),Je?bt.set("date_end",Je):bt.delete("date_end"),Xe?bt.set("work_order_id",Xe):bt.delete("work_order_id"),qe?bt.set("asset",qe):bt.delete("asset"),ar?bt.set("work_order_type",ar):bt.delete("work_order_type"),fr&&St?bt.set("civil_work_category",St):bt.delete("civil_work_category"),Yt?bt.set("company",Yt):bt.delete("company"),wt?bt.set("status",wt):bt.delete("status"),qt?bt.set("serial_number",qt):bt.delete("serial_number"),ze?bt.set("manufacturer",ze):bt.delete("manufacturer"),_t?bt.set("supplier",_t):bt.delete("supplier"),pr?bt.set("department",pr):bt.delete("department"),rr?bt.set("priority",rr):bt.delete("priority"),Nt?bt.set("workflow_state",Nt):bt.delete("workflow_state"),yr?bt.set("extension_no",yr):bt.delete("extension_no"),Tt?bt.set("building",Tt):bt.delete("building"),Fe?bt.set("room_no",Fe):bt.delete("room_no"),vt?bt.set("location",vt):bt.delete("location"),Re&&Re!=="modified desc"?bt.set("sort_by",Re):bt.delete("sort_by"),bt.set("page","1"),bt})},[et,ft,Je,Xe,qe,ar,fr,St,Yt,wt,qt,ze,_t,pr,rr,Nt,yr,Tt,Fe,vt,Re]),_.useEffect(()=>{fr||Ot("")},[fr]),_.useEffect(()=>{C(new Set)},[et,ft,Je,Xe,qe,ar,St,Yt,wt,qt,ze,_t,pr,rr,Nt,yr,Tt,Fe,vt,n]);const Ps=it=>{gt(it),Wt.current&&clearTimeout(Wt.current),Wt.current=window.setTimeout(()=>kt(it),800)},ha=it=>{it.key==="Enter"&&(it.preventDefault(),Wt.current&&clearTimeout(Wt.current),kt(tt))},_s=()=>{if(!at.trim()){alert("Please enter a filter name");return}const it={id:Date.now(),name:at,filters:{dateFilterBy:et,dateStart:ft,dateEnd:Je,sortBy:Re,filterWorkOrderId:Xe,filterAsset:qe,filterType:ar,filterCivilWorkCategory:St,filterCompany:Yt,filterStatus:wt,filterSerialNumber:qt,filterManufacturer:ze,filterSupplier:_t,filterDepartment:pr,filterPriority:rr,filterWorkflowState:Nt,filterExtensionNo:yr,filterBuilding:Tt,filterRoomNo:Fe,filterLocation:vt}},bt=[...Ce,it];Qe(bt),$e(""),dt(!1),localStorage.setItem("workOrderFilterPresets",JSON.stringify(bt))},Wi=it=>{const bt=it.filters;It(bt.dateFilterBy||""),Lt(bt.dateStart||""),Ve(bt.dateEnd||""),Q(bt.sortBy||"modified desc"),Rt(bt.filterWorkOrderId||""),Dt(bt.filterAsset||""),yt(bt.filterType||""),Ot(bt.filterCivilWorkCategory||""),Ye(bt.filterCompany||""),zt(bt.filterStatus||""),kt(bt.filterSerialNumber||""),gt(bt.filterSerialNumber||""),nt(bt.filterManufacturer||""),lr(bt.filterSupplier||""),Nr(bt.filterDepartment||""),_r(bt.filterPriority||""),Cr(bt.filterWorkflowState||""),jt(bt.filterExtensionNo||""),He(bt.filterBuilding||""),Ze(bt.filterRoomNo||""),ir(bt.filterLocation||"")},De=it=>{const bt=Ce.filter(Qr=>Qr.id!==it);Qe(bt),localStorage.setItem("workOrderFilterPresets",JSON.stringify(bt))};_.useEffect(()=>()=>{Wt.current&&clearTimeout(Wt.current)},[]),_.useEffect(()=>{const it=bt=>{y.current&&!y.current.contains(bt.target)&&g(null)};return h&&document.addEventListener("mousedown",it),()=>document.removeEventListener("mousedown",it)},[h]);const wr=it=>{C(bt=>{const Qr=new Set(bt);return Qr.has(it)?Qr.delete(it):Qr.add(it),Qr})},Cn=()=>{A.size===Ht.length?C(new Set):C(new Set(Ht.map(it=>it.name)))},un=Ht.length>0&&A.size===Ht.length,Wr=A.size>0&&A.size<Ht.length,mt=_.useCallback(()=>me(null,null,function*(){const it=[];let bt=0;const Qr=100;let gr=!0;const En=Te(Te({},Zt),ye),Lr=Ln(En);for(;gr;)try{const oa={doctype:"Work_Order",filters:Lr.length>0?Lr:{},fields:["*"],limit_start:bt*Qr,limit_page_length:Qr,order_by:"creation desc"};q&&q.length>0&&(oa.or_filters=q);const Os=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(oa)})).json()).message||[];it.push(...Os),Os.length<Qr?gr=!1:bt++,bt>100&&(console.warn("Export safety limit reached"),gr=!1)}catch(oa){throw console.error("Error fetching work orders for export:",oa),oa}return it}),[Zt,ye,q]),We=()=>{const it=Ht.filter(bt=>A.has(bt.name)).map(bt=>({name:bt.name,workflow_state:bt.workflow_state||"Draft",repair_status:bt.repair_status||"Open"}));G(it),W(!0)},Me=()=>me(null,null,function*(){B(!0);const it=Y.filter(En=>{var Lr;return((Lr=En.workflow_state)==null?void 0:Lr.toLowerCase())!=="closed"});let bt=0,Qr=0;const gr=[];for(const En of it)try{const oa=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:En.name},action:"Close"})})).json();if(oa.exc||oa.exception)throw new Error(oa.exc||oa.exception);bt++}catch(Lr){console.error(`Failed to close ${En.name}:`,Lr),Qr++,gr.push(En.name)}B(!1),W(!1),C(new Set),zr(),bt>0&&Qr===0?alert(`Successfully closed ${bt} work order${bt!==1?"s":""}.`):bt>0&&Qr>0?alert(`Closed ${bt} work order${bt!==1?"s":""}. Failed to close ${Qr}: ${gr.join(", ")}`):Qr>0&&alert(`Failed to close work orders: ${gr.join(", ")}`)}),Qt=()=>r("/work-orders/new"),Pr=it=>r(`/work-orders/${it}`),Oa=it=>r(`/work-orders/${it}`),Va=it=>r(`/work-orders/new?duplicate=${it}`),fn=it=>me(null,null,function*(){try{yield Kr(it),u(null),zr(),alert("Work order deleted successfully!")}catch(bt){alert(`Failed to delete work order: ${bt instanceof Error?bt.message:"Unknown error"}`)}}),Ea="Service_Report",xr=it=>{const Qr=`${Or.BASE_URL}/printview?doctype=Work_Order&name=${encodeURIComponent(it)}&format=${encodeURIComponent(Ea)}&trigger_print=1`;window.open(Qr,"_blank")},ua=()=>{It(""),Lt(""),Ve(""),Q("modified desc"),Rt(""),Dt(""),yt(""),Ot(""),Ye(""),zt(""),kt(""),gt(""),nt(""),lr(""),Nr(""),_r(""),Cr(""),jt(""),He(""),Ze(""),ir(""),s(it=>{const bt=new URLSearchParams(it);return bt.delete("date_filter_by"),bt.delete("date_start"),bt.delete("date_end"),bt.delete("work_order_id"),bt.delete("asset"),bt.delete("work_order_type"),bt.delete("civil_work_category"),bt.delete("company"),bt.delete("status"),bt.delete("serial_number"),bt.delete("manufacturer"),bt.delete("supplier"),bt.delete("department"),bt.delete("priority"),bt.delete("workflow_state"),bt.delete("extension_no"),bt.delete("building"),bt.delete("room_no"),bt.delete("location"),bt.set("page","1"),bt}),Wt.current&&clearTimeout(Wt.current)},Jn=Ft||Xe||qe||ar||fr&&St||Yt||wt||qt||ze||_t||pr||rr||Nt||yr||Tt||Fe||vt,mi=it=>it?new Date(it).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"-",hn=it=>{switch(it){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""}},Ts=it=>{switch(it==null?void 0:it.toLowerCase()){case"completed":return t.jsx(Tr,{className:"text-green-500"});case"in progress":return t.jsx(Ja,{className:"text-blue-500"});case"pending":return t.jsx(Jr,{className:"text-yellow-500"});default:return t.jsx(Ja,{className:"text-gray-400"})}},Ai=it=>{switch(it==null?void 0:it.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"}},Hi=it=>{switch(it==null?void 0:it.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 te||ae?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:te||ae}),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"})]})]})}):da&&E&&!Gr.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:zr,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-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen w-full min-w-0 overflow-x-hidden",children:[t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center w-full min-w-0",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-gray-800 dark:text-white break-words",children:e("workOrders.title")}),t.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:["Total: ",fa," work order",fa!==1?"s":"",A.size>0&&t.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",A.size," selected"]}),J&&t.jsx("span",{className:"ml-2 text-amber-600 dark:text-amber-400",children:"• Showing your assigned work orders"}),vr&&E&&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 flex-col gap-2 w-full sm:flex-row sm:flex-wrap sm:justify-end sm:gap-3 sm:w-auto min-w-0 shrink-0",children:[rt&&t.jsxs("button",{type:"button",onClick:()=>F(!0),className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg flex items-center justify-center gap-2 shadow transition-all w-full sm:w-auto",children:[t.jsx(Q4,{}),t.jsx("span",{className:"font-medium",children:"WO Report"})]}),ie&&A.size>0&&t.jsxs("button",{type:"button",onClick:We,className:"bg-orange-600 hover:bg-orange-700 text-white px-4 py-2 rounded-lg flex items-center justify-center gap-2 shadow transition-all w-full sm:w-auto",children:[t.jsx(k1,{}),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:A.size})]}),t.jsxs("button",{type:"button",onClick:()=>M(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center justify-center gap-2 shadow transition-all disabled:opacity-50 w-full sm:w-auto",disabled:fa===0,children:[t.jsx(Ks,{}),t.jsx("span",{className:"font-medium",children:e("listPages.export")}),A.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:A.size})]}),Be&&t.jsxs("button",{type:"button",onClick:Qt,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center justify-center gap-2 shadow-lg transition-all hover:shadow-xl w-full sm:w-auto",children:[t.jsx(Js,{}),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 flex-col gap-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0 min-w-0",children:[t.jsx("button",{onClick:()=>Se(!he),className:"text-white hover:bg-white/20 p-2 rounded-lg transition-all",children:he?t.jsx(Mn,{size:14}):t.jsx(on,{size:14})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Hs,{className:"text-white",size:16}),t.jsx("h3",{className:"text-white font-semibold text-sm",children:"Filters"})]}),ne>0&&t.jsx("span",{className:"bg-white text-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:ne})]}),Jn&&t.jsx("div",{className:"w-full min-w-0 sm:flex-1 overflow-x-auto scrollbar-hide sm:mx-2",children:t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[Ft&&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(et==="creation"?"filters.createdDate":"filters.latestModifiedDate")," ",ft&&` ${ft}`," ",Je&&` - ${Je}`,t.jsx("button",{onClick:it=>{it.stopPropagation(),It(""),Lt(""),Ve("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),Xe&&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:"})," ",Xe,t.jsx("button",{onClick:it=>{it.stopPropagation(),Rt("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),qe&&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:"})," ",qe,t.jsx("button",{onClick:it=>{it.stopPropagation(),Dt(""),a.delete("asset"),s(a)},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),ar&&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:"})," ",ar,t.jsx("button",{onClick:it=>{it.stopPropagation(),yt(""),a.delete("work_order_type"),s(a)},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),fr&&St&&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:"})," ",St,t.jsx("button",{onClick:it=>{it.stopPropagation(),Ot(""),a.delete("civil_work_category"),s(a)},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),Yt&&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:"})," ",Yt,t.jsx("button",{onClick:it=>{it.stopPropagation(),Ye("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),wt&&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:"})," ",wt,t.jsx("button",{onClick:it=>{it.stopPropagation(),zt("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),Nt&&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:"})," ",Nt,t.jsx("button",{onClick:it=>{it.stopPropagation(),Cr(""),a.delete("workflow_state"),s(a)},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),yr&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-sky-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsx("span",{className:"font-semibold",children:"Ext No:"})," ",yr,t.jsx("button",{onClick:it=>{it.stopPropagation(),jt("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),Tt&&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.jsx("span",{className:"font-semibold",children:"Building:"})," ",Tt,t.jsx("button",{onClick:it=>{it.stopPropagation(),He("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),Fe&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-rose-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsx("span",{className:"font-semibold",children:"Room:"})," ",Fe,t.jsx("button",{onClick:it=>{it.stopPropagation(),Ze("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),vt&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-fuchsia-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[t.jsx("span",{className:"font-semibold",children:"Location:"})," ",vt,t.jsx("button",{onClick:it=>{it.stopPropagation(),ir("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),qt&&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:"})," ",qt,t.jsx("button",{onClick:it=>{it.stopPropagation(),kt(""),gt("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),ze&&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:"})," ",ze,t.jsx("button",{onClick:it=>{it.stopPropagation(),nt("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),_t&&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:"})," ",_t,t.jsx("button",{onClick:it=>{it.stopPropagation(),lr("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),pr&&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:"})," ",pr,t.jsx("button",{onClick:it=>{it.stopPropagation(),Nr("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),rr&&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:"})," ",rr,t.jsx("button",{onClick:it=>{it.stopPropagation(),_r("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]})]})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 flex-shrink-0 w-full sm:w-auto justify-end sm:justify-start",children:[ne>0&&t.jsxs("button",{type:"button",onClick:()=>dt(!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(bs,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),Jn&&t.jsxs("button",{type:"button",onClick:ua,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(Pt,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:"Clear"})]})]})]})}),he&&t.jsxs("div",{className:"p-4",children:[Ce.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(ul,{className:"text-yellow-500",size:12}),"Saved Filters"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:Ce.map(it=>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:()=>Wi(it),className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:it.name}),t.jsx("button",{onClick:()=>De(it.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:t.jsx(la,{size:10})})]},it.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:Re,onChange:it=>Q(it.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:et,onChange:it=>{const bt=it.target.value;It(bt)},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")})]})]}),et&&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:ft,onChange:it=>{const bt=it.target.value;Lt(bt),Je&&bt>Je&&Ve(bt)},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:Je,onChange:it=>Ve(it.target.value),min:ft||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-10 lg:z-[60]",children:[t.jsx(hr,{label:e("filters.workOrderId"),doctype:"Work_Order",value:Xe,onChange:it=>Rt(it),placeholder:e("linkField.selectLabel",{label:e("filters.workOrderId")}),disabled:!1,compact:!0,filters:{custom_delete_status:["!=","Deleted"]}}),Xe&&t.jsx("button",{onClick:()=>Rt(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[59]",children:[t.jsx(hr,{label:e("filters.asset"),doctype:"Asset",value:qe,onChange:it=>Dt(it),placeholder:e("linkField.selectLabel",{label:e("filters.asset")}),disabled:!1,compact:!0,filters:{custom_delete_status:["!=","Deleted"]}}),qe&&t.jsx("button",{onClick:()=>{Dt(""),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(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[58]",children:[t.jsx(hr,{label:e("filters.type"),doctype:"Issue Type",value:ar,onChange:it=>{yt(it),a.has("work_order_type")&&(a.delete("work_order_type"),s(a))},placeholder:e("linkField.selectLabel",{label:e("filters.type")}),disabled:!1,compact:!0}),ar&&t.jsx("button",{onClick:()=>{yt(""),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(Pt,{size:10})})]}),fr&&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:St,onChange:it=>Ot(it.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"}),t$.map(it=>t.jsx("option",{value:it,children:it},it))]}),St&&t.jsx("button",{onClick:()=>Ot(""),className:"absolute right-8 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[57]",children:[t.jsx(hr,{label:e("filters.hospital"),doctype:"Company",value:Yt,onChange:it=>Ye(it),placeholder:e("linkField.selectLabel",{label:e("filters.hospital")}),disabled:!1,compact:!0,filters:{domain:"Healthcare"}}),Yt&&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(Pt,{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:wt,onChange:it=>zt(it.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")})]}),wt&&t.jsx("button",{onClick:()=>zt(""),className:"absolute right-8 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[56]",children:[t.jsx(hr,{label:e("filters.workflowState","Workflow State"),doctype:"Workflow State",value:Nt,onChange:it=>Cr(it),placeholder:e("linkField.selectLabel",{label:e("filters.workflowState","Workflow State")}),disabled:!1,compact:!0}),Nt&&t.jsx("button",{onClick:()=>{Cr(""),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(Pt,{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:tt,onChange:it=>Ps(it.target.value),onKeyDown:ha,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"}),tt&&tt!==qt&&t.jsx("span",{className:"absolute right-2 top-6 text-[9px] text-blue-500 animate-pulse",children:e("common.typing")}),qt&&t.jsx("button",{onClick:()=>{kt(""),gt("")},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[55]",children:[t.jsx(hr,{label:e("filters.mfr"),doctype:"Manufacturer",value:ze,onChange:it=>nt(it),placeholder:e("linkField.selectLabel",{label:e("filters.mfr")}),disabled:!1,compact:!0}),ze&&t.jsx("button",{onClick:()=>nt(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[54]",children:[t.jsx(hr,{label:e("filters.supplier"),doctype:"Supplier",value:_t,onChange:it=>lr(it),placeholder:e("linkField.selectLabel",{label:e("filters.supplier")}),disabled:!1,compact:!0}),_t&&t.jsx("button",{onClick:()=>lr(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{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:rr,onChange:it=>_r(it.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")})]}),rr&&t.jsx("button",{onClick:()=>_r(""),className:"absolute right-8 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[52]",children:[t.jsx(hr,{label:"Extension No",doctype:"Extension Directory",value:yr,onChange:it=>jt(it),placeholder:"Select Extension No",disabled:!1,compact:!0}),yr&&t.jsx("button",{onClick:()=>jt(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[51]",children:[t.jsx(hr,{label:"Building",doctype:"Building",value:Tt,onChange:it=>He(it),placeholder:"Select Building",disabled:!1,compact:!0}),Tt&&t.jsx("button",{onClick:()=>He(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[50]",children:[t.jsx(hr,{label:"Department",doctype:"Department",value:pr,onChange:it=>Nr(it),placeholder:"Select Department",disabled:!1,compact:!0}),pr&&t.jsx("button",{onClick:()=>Nr(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[49]",children:[t.jsx(hr,{label:"Room No",doctype:"Room",value:Fe,onChange:it=>Ze(it),placeholder:"Select Room No",disabled:!1,compact:!0}),Fe&&t.jsx("button",{onClick:()=>Ze(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[48]",children:[t.jsx(hr,{label:"Location",doctype:"Location",value:vt,onChange:it=>ir(it),placeholder:"Select Location",disabled:!1,compact:!0}),vt&&t.jsx("button",{onClick:()=>ir(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{size:10})})]})]})})})]})]}),xt&&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:at,onChange:it=>$e(it.target.value),onKeyDown:it=>{it.key==="Enter"&&(it.preventDefault(),_s())},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:()=>{dt(!1),$e("")},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:_s,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(bs,{size:12}),"Save Filter"]})]})]})}),t.jsx(ob,{isOpen:O,onClose:()=>M(!1),doctype:"Work_Order",selectedCount:A.size,pageCount:Ht.length,totalCount:fa,pageData:Ht,selectedRows:A,rowKey:"name",onFetchAll:mt,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(a$,{isOpen:z,onClose:()=>W(!1),selectedWorkOrders:Y,onConfirmClose:Me,isClosing:X}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden relative",children:[vr&&E&&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:Cn,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:un?"Deselect all":"Select all",children:un?t.jsx(jn,{className:"text-blue-600 dark:text-blue-400",size:18}):Wr?t.jsxs("div",{className:"relative",children:[t.jsx(ys,{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(ys,{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:vr&&Ht.length===0?Array.from({length:8}).map((it,bt)=>t.jsxs("tr",{className:"animate-pulse",children:[t.jsx("td",{className:"px-4 py-4",children:t.jsx("div",{className:"h-4 w-4 bg-gray-200 dark:bg-gray-700 rounded"})}),t.jsxs("td",{className:"px-6 py-4",children:[t.jsx("div",{className:"h-4 w-28 bg-gray-200 dark:bg-gray-700 rounded mb-2"}),t.jsx("div",{className:"h-3 w-20 bg-gray-100 dark:bg-gray-700 rounded"})]}),t.jsxs("td",{className:"px-6 py-4",children:[t.jsx("div",{className:"h-4 w-32 bg-gray-200 dark:bg-gray-700 rounded mb-2"}),t.jsx("div",{className:"h-3 w-24 bg-gray-100 dark:bg-gray-700 rounded"})]}),t.jsx("td",{className:"px-6 py-4",children:t.jsx("div",{className:"h-4 w-36 bg-gray-200 dark:bg-gray-700 rounded"})}),t.jsx("td",{className:"px-6 py-4",children:t.jsx("div",{className:"h-4 w-40 bg-gray-200 dark:bg-gray-700 rounded"})}),t.jsx("td",{className:"px-6 py-4",children:t.jsx("div",{className:"h-4 w-24 bg-gray-200 dark:bg-gray-700 rounded"})}),t.jsx("td",{className:"px-6 py-4",children:t.jsx("div",{className:"h-6 w-20 bg-gray-200 dark:bg-gray-700 rounded-full"})}),t.jsx("td",{className:"px-6 py-4",children:t.jsx("div",{className:"h-6 w-16 bg-gray-200 dark:bg-gray-700 rounded-full"})}),t.jsx("td",{className:"px-6 py-4",children:t.jsx("div",{className:"h-4 w-24 bg-gray-200 dark:bg-gray-700 rounded"})})]},`wo-skeleton-${bt}`)):Ht.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(In,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("workOrders.table.noWorkOrdersFound")}),Jn?t.jsx("button",{onClick:ua,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:e("common.clearFilters")}):Be?t.jsx("button",{onClick:Qt,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]})})}):Ht.map(it=>{var bt,Qr;return t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${A.has(it.name)?"bg-blue-50 dark:bg-blue-900/20":hn((bt=it.custom_delete_status)!=null?bt:void 0)}`,title:it.custom_delete_status?`Delete Status: ${it.custom_delete_status}`:void 0,onClick:()=>Pr(it.name),children:[t.jsx("td",{className:"px-4 py-4",onClick:gr=>gr.stopPropagation(),children:t.jsx("button",{onClick:()=>wr(it.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:A.has(it.name)?t.jsx(jn,{className:"text-blue-600 dark:text-blue-400",size:18}):t.jsx(ys,{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:it.name}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:mi(it.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:it.asset_name||"-"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:it.asset||""})]}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:it.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:it.actions_performed||"",children:it.actions_performed||"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:it.department||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsxs("div",{className:"flex items-center gap-2",children:[Ts(it.repair_status||""),t.jsx("span",{className:`px-3 py-1 inline-flex text-xs leading-5 font-semibold rounded-full ${Ai(it.repair_status||"")}`,children:it.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 ${Hi(it.custom_priority_||"")}`,children:it.custom_priority_?e(`workOrders.priority.${it.custom_priority_.toLowerCase()}`,it.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:gr=>gr.stopPropagation(),children:[t.jsx("button",{onClick:()=>Pr(it.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(to,{})}),t.jsx("button",{onClick:()=>Oa(it.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(Ms,{})}),t.jsx("button",{onClick:()=>Va(it.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(tu,{})}),t.jsx("div",{onClick:gr=>gr.stopPropagation(),children:t.jsx(rd,{doctype:"Work_Order",docname:it.name,currentDeleteStatus:(Qr=it.custom_delete_status)!=null?Qr:null,userRoles:we,isSystemManager:ve,triggerMode:!0,redirectOnDelete:"/work-orders",onStatusChange:()=>zr()})}),t.jsxs("div",{className:"relative",ref:h===it.name?y:null,children:[t.jsx("button",{onClick:()=>g(h===it.name?null:it.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(Wf,{})}),h===it.name&&t.jsx("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:()=>{xr(it.name),g(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(Go,{className:"text-purple-500"}),"Print Work Order"]})})]})]})})]},it.name)})})]})}),t.jsx(ed,{currentPage:n+1,totalCount:fa,pageSize:w,hasMore:qr,itemLabel:e("pagination.workOrders"),onPageChange:it=>i(Math.max(0,it-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(la,{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"),":"]})," ",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:Yr,children:e("common.cancel")}),t.jsx("button",{onClick:()=>fn(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:Yr,children:Yr?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(la,{}),e("workOrders.deleteWorkOrder")]})})]})]})]})})}),t.jsx(e$,{isOpen:R,onClose:()=>F(!1)}),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; }
`})]})},n$=({workOrder:e})=>{const[r,a]=_.useState(!0),[s,n]=_.useState(null);return _.useEffect(()=>{if(!e){a(!1),n(null);return}let i=!1;return me(null,null,function*(){a(!0);try{const c=yield Dm.getFeedbackForWorkOrder(e);i||n(c)}catch(c){i||n(null)}finally{i||a(!1)}}),()=>{i=!0}},[e]),r||!(s!=null&&s.rating)?null: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:"WO Feedback"}),t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(ul,{className:"text-amber-500 mt-0.5 shrink-0"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase mb-1",children:"Rating"}),t.jsx("p",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:s.rating}),s.requester_name&&t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:[t.jsx("span",{className:"font-medium",children:"Requester:"})," ",s.requester_name]}),s.comments&&t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:[t.jsx("span",{className:"font-medium",children:"Comments:"})," ",s.comments]})]})]})]})},i$="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}`},d1=()=>{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"),c=String(e.getSeconds()).padStart(2,"0");return`${r}-${a}-${s} ${n}:${i}:${c}`},O0=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},D0=e=>e?e.includes("T")?e.replace("T"," ")+":00":e:"",Tl=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}},o$=(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]},n4=e=>!(!e||Number(e.docstatus)!==1||e.custom_delete_status==="Deleted"),i4=(e=[])=>[["docstatus","=",1],["custom_delete_status","!=","Deleted"],...e],l$={docstatus:1,custom_delete_status:["!=","Deleted"]},c$=!1,d$=()=>{var ot,ut,At;const{t:e}=Rr(),{workOrderName:r}=ml(),a=Na(),[s]=Sn(),n=s.get("duplicate"),i=s.get("asset"),c=!!i,u=r==="new",h=u&&!!n,g=()=>{if(!r||u)return;const Ee=`${Or.BASE_URL}/printview?doctype=Work_Order&name=${encodeURIComponent(r)}&format=${encodeURIComponent(i$)}&trigger_print=1`;window.open(Ee,"_blank")||Mt.warning(e("workOrders.detail.pleaseAllowPopupsServiceReport"),{position:"top-right",autoClose:5e3,icon:t.jsx(Jr,{})})},[y,w]=_.useState(!1),[E,S]=_.useState([]),[A,C]=_.useState(!1),[O,M]=_.useState(""),[R,F]=_.useState(!1),[z,W]=_.useState([]),[X,B]=_.useState([]),[Y,G]=_.useState(""),[ie,fe]=_.useState(!1),[K,ke]=_.useState(!1),[ge,re]=_.useState(null),[we,ee]=_.useState([]),[ve,ce]=_.useState(!1),[ye,te]=_.useState([]),[q,J]=_.useState("room"),[ae,oe]=_.useState(!1),[le,be]=_.useState(0),{workOrder:Z,loading:Le,error:Pe,refetch:Be}=KH(h?n:u?null:r||null),{createWorkOrder:pe,updateWorkOrder:rt,loading:ct}=hS(),[et,It]=_.useState(u),[ft,Lt]=_.useState(!1),[Je,Ve]=_.useState(null),[Xe,Rt]=_.useState(""),qe=["System Manager","Work Control","Contractor Supervisor","Contractor Manager","Maintenance Manager","Cluster Manager","Contractor Engineer","Quality Supervisor","Technician"],[Dt,ar]=_.useState(!1),[yt,St]=_.useState(!1),[Ot,Yt]=_.useState(null),Ye=ea.useRef(!1),[wt,zt]=_.useState(!1),[qt,kt]=_.useState(!1),[ze,nt]=_.useState(!1),[_t,lr]=_.useState([]),[pr,Nr]=_.useState([]),[rr,_r]=_.useState([]),[Nt,Cr]=_.useState(!1),[yr,jt]=_.useState(""),[Tt,He]=_.useState(""),[Fe,Ze]=_.useState(""),[vt,ir]=_.useState(""),[fr,Kt]=_.useState([]),[Re,Q]=_.useState([]),[he,Se]=_.useState(!1),[ne,_e]=_.useState(!1),[Ce,Qe]=_.useState(""),[xt,dt]=_.useState(!1),[at,$e]=_.useState([]),[tt,gt]=_.useState(!1),[Wt,Ft]=_.useState(!1),[Zt,br]=_.useState(!1),[Ht,fa]=_.useState(null),[qr,vr]=_.useState(!1),[da,zr]=_.useState(!1),[Kr,Yr]=_.useState("give"),[Gr,Sa]=_.useState([{parameter:"Quality of Service",rating:0,feedback:""},{parameter:"Timeliness",rating:0,feedback:""},{parameter:"Professionalism",rating:0,feedback:""},{parameter:"Communication",rating:0,feedback:""}]),[Ps,ha]=_.useState(!1),[_s,Wi]=_.useState(""),[De,wr]=_.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:"",custom_local_id:"",model:"",custom_site_contractor:"",custom_subcontractor:"",failure_date:u?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_room_no:"",custom_building:"",__islocal:!1}),Cn=De.asset_type==="Non Biomedical",Wr=_.useCallback(()=>{const se=(Z==null?void 0:Z.workflow_state)||De.workflow_state||"Draft";return se==="Cancelled"?2:se==="Closed"?1:(Z==null?void 0:Z.docstatus)||De.docstatus||0},[Z==null?void 0:Z.workflow_state,De.workflow_state,Z==null?void 0:Z.docstatus,De.docstatus])(),Me=Wr===1||Wr===2,Qt=!!Ot;O&&(Z!=null&&Z.owner)&&Z.owner;const Pr=se=>{const Ee=new Date;return Ee.setDate(Ee.getDate()-(se-1)),Ee.toISOString().split("T")[0]},Oa=()=>me(null,null,function*(){var se;try{const Ee=yield Xt.apiCall("/api/resource/Work Order Settings/Work Order Settings");return(se=Ee==null?void 0:Ee.data)!=null&&se.custom_days&&parseInt(Ee.data.custom_days)||1}catch(Ee){return console.error("Error fetching days config:",Ee),1}}),Va=_.useCallback((se,Ee)=>me(null,null,function*(){if(!(!se||!Ee||!u)){oe(!0);try{const Ue=yield Oa(),ht=Pr(Ue),ur=[["work_order_type","=",se],["custom_room_no","=",Ee],["workflow_state","not in",["Approved","Closed","Cancelled"]],["creation",">=",`${ht} 00:00:00`]],tr=yield Xt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify(ur))}&fields=["name","workflow_state","creation"]&limit=10`);tr!=null&&tr.data&&tr.data.length>0&&(te(tr.data),J("room"),ce(!0))}catch(Ue){console.error("Error checking duplicates by Room No:",Ue)}finally{oe(!1)}}}),[u]),fn=_.useCallback(se=>me(null,null,function*(){if(!(!se||!u)){oe(!0);try{const Ee=[["asset","=",se],["workflow_state","not in",["Approved","Closed","Cancelled"]]],Ue=yield Xt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify(Ee))}&fields=["name","workflow_state","creation"]&limit=10`);Ue!=null&&Ue.data&&Ue.data.length>0&&(te(Ue.data),J("asset"),ce(!0))}catch(Ee){console.error("Error checking duplicates by Asset:",Ee)}finally{oe(!1)}}}),[u]),Ea=()=>{ce(!1),te([])},xr=()=>{ce(!1),te([]),wr(q==="asset"?se=>Ke(Te({},se),{asset:"",asset_name:""}):se=>Ke(Te({},se),{work_order_type:"",custom_room_no:""}))};_.useEffect(()=>{const se=De.work_order_type,Ee=De.custom_room_no;if(u&&!De.asset&&se&&Ee){const Ue=setTimeout(()=>{Va(se,Ee)},500);return()=>clearTimeout(Ue)}},[u,De.asset,De.work_order_type,De.custom_room_no,Va]),_.useEffect(()=>{const se=De.asset;if(u&&se){const Ee=setTimeout(()=>{fn(se)},500);return()=>clearTimeout(Ee)}},[u,De.asset,fn]),_.useEffect(()=>{const Ee=setTimeout(()=>me(null,null,function*(){var ht,ur;if(De.asset){be(0);return}if(!(De.custom_building||De.department||De.custom_room_no)){be(0);return}try{const tr=i4();De.company&&tr.push(["company","=",De.company]),De.custom_building&&tr.push(["custom_building","=",De.custom_building]),De.department&&tr.push(["department","=",De.department]),De.custom_room_no&&tr.push(["custom_room_number","=",De.custom_room_no]);const Ar=yield Xt.apiCall(`/api/resource/Asset?filters=${encodeURIComponent(JSON.stringify(tr))}&fields=["name"]&limit=1000`),ra=((ht=Ar==null?void 0:Ar.data)==null?void 0:ht.length)||0;be(ra);const La=!!(De.custom_building&&De.department&&De.custom_room_no);c$&&ra===1&&((ur=Ar.data[0])!=null&&ur.name)&&De.asset}catch(tr){console.error("Error checking asset count:",tr),be(0)}}),500);return()=>clearTimeout(Ee)},[De.asset,De.company,De.custom_building,De.department,De.custom_room_no]),_.useEffect(()=>{const se=E.includes("Technician");!u&&(Z==null?void 0:Z.workflow_state)==="Repair InProgress"&&!Qt&&se&&It(!0)},[u,Z==null?void 0:Z.workflow_state,Qt,E]),_.useEffect(()=>{me(null,null,function*(){if(!u&&r&&(Z==null?void 0:Z.workflow_state)==="Repair InProgress"&&(!(Z!=null&&Z.first_responded_on)||Z.first_responded_on==="")){const Ee=d1();try{yield rt(r,{first_responded_on:Ee}),wr(Ue=>Ke(Te({},Ue),{first_responded_on:O0(Ee)})),Mt.info(e("workOrders.detail.firstRespondedOnSetTo",{datetime:Tl(Ee)}),{position:"top-right",autoClose:3e3,icon:t.jsx(Ja,{})}),Be(),setTimeout(()=>{ua()},500),console.log("Auto-set first_responded_on to:",Ee)}catch(Ue){console.error("Error auto-setting first_responded_on:",Ue)}}})},[u,r,Z==null?void 0:Z.workflow_state,Z==null?void 0:Z.first_responded_on]),_.useEffect(()=>{me(null,null,function*(){if(!u&&r&&(Z==null?void 0:Z.workflow_state)==="Closed"&&(!(Z!=null&&Z.completion_date)||Z.completion_date==="")){const Ee=d1();try{yield rt(r,{completion_date:Ee}),wr(Ue=>Ke(Te({},Ue),{completion_date:O0(Ee)})),Mt.info(e("workOrders.detail.completionDateSetTo",{datetime:Tl(Ee)}),{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),Be(),setTimeout(()=>{ua()},500),console.log("Auto-set completion_date to:",Ee)}catch(Ue){console.error("Error auto-setting completion_date:",Ue)}}})},[u,r,Z==null?void 0:Z.workflow_state,Z==null?void 0:Z.completion_date]),_.useEffect(()=>{if(!O)return;C(!1),S([]),me(null,null,function*(){try{const Ue=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();Ue.message&&Array.isArray(Ue.message)&&(S(Ue.message),console.log("User roles fetched for:",O,Ue.message))}catch(Ee){console.error("Error fetching user roles:",Ee),S([])}finally{C(!0)}})},[O]),_.useEffect(()=>{me(null,null,function*(){try{const Ue=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();Ue.message&&(M(Ue.message),console.log("Current user:",Ue.message))}catch(Ee){console.error("Error fetching current user:",Ee),M("")}})},[]),_.useEffect(()=>{me(null,null,function*(){try{const Ue=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:qe.join(",")})})).json();Ue.message&&(ar(Ue.message.has_role),console.log("Can delete/cancel:",Ue.message.has_role));const ur=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:"DR Approver"})})).json();ur.message&&St(ur.message.has_role)}catch(Ee){console.error("Error checking delete permissions:",Ee),ar(!1)}})},[]);const ua=_.useCallback(()=>me(null,null,function*(){if(!(u||!r)){gt(!0);try{const se=yield Xt.apiCall(`/api/resource/Version?filters=[["ref_doctype","=","Work_Order"],["docname","=","${encodeURIComponent(r)}"]]&fields=["name","owner","creation","data"]&order_by=creation desc&limit=50`);if(se!=null&&se.data&&se.data.length>0){const Ee=se.data.map(Ue=>{let ht={added:[],changed:[],removed:[],row_changed:[]};try{ht=JSON.parse(Ue.data||"{}")}catch(tr){console.error("Error parsing version data:",tr)}const ur=(ht.changed||[]).map(tr=>({field:tr[0]||"",oldValue:tr[1],newValue:tr[2]}));return{name:Ue.name,owner:Ue.owner,creation:Ue.creation,changes:ur,added:ht.added||[],removed:ht.removed||[],rowChanged:ht.row_changed||[]}});$e(Ee),console.log("Audit logs fetched:",Ee.length)}else $e([])}catch(se){console.error("Error fetching audit logs:",se),$e([])}finally{gt(!1)}}}),[u,r]);_.useEffect(()=>{ua()},[ua]);const Jn=_.useCallback(()=>me(null,null,function*(){var se;try{const Ue=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:O},fieldname:"full_name"})})).json();(se=Ue.message)!=null&&se.full_name&&Wi(Ue.message.full_name)}catch(Ee){console.error("Error fetching user full name:",Ee)}}),[O]),mi=_.useCallback(()=>me(null,null,function*(){if(!(u||!r)){vr(!0);try{const se=new URLSearchParams({work_order:r}),Ee=yield Xt.apiCall(`${Or.ENDPOINTS.GET_WORK_ORDER_FEEDBACK}?${se.toString()}`);Ee&&typeof Ee=="object"&&!Ee.error&&Ee.name?fa(Ee):fa(null)}catch(se){console.error("Error fetching feedback:",se),fa(null)}finally{vr(!1)}}}),[u,r]);_.useEffect(()=>{const se=(Z==null?void 0:Z.workflow_state)||De.workflow_state||"";["Approved","Closed"].includes(se)&&(O||Z!=null&&Z.owner)&&(mi(),O&&Jn())},[Z==null?void 0:Z.workflow_state,De.workflow_state,O,Z==null?void 0:Z.owner,mi,Jn]);const hn=se=>({"Medical Gas – الغازات الطبية":"Mechanical Maintenance-الصيانة الميكانيكية"})[se]||se,Ts=_.useCallback(se=>me(null,null,function*(){if(!se){lr([]);return}const Ee=hn(se);try{const Ue=yield Xt.apiCall(`/api/resource/Asset Maintenance Team?filters=[["custom_expertise","=","${encodeURIComponent(Ee)}"]]&fields=["maintenance_manager"]&limit=100`);if(Ue!=null&&Ue.data&&Ue.data.length>0){const ht=Ue.data.map(tr=>tr.maintenance_manager).filter(tr=>tr),ur=[...new Set(ht)];console.log("Filtered Managers based on expertise:",ur),lr(ur)}else lr([])}catch(Ue){console.error("Error fetching managers based on expertise:",Ue),lr([])}}),[]),Ai=_.useCallback(se=>me(null,null,function*(){if(!se){Nr([]);return}const Ee=hn(se);try{console.log("Filtering technicians for work order type:",se,"→ expertise:",Ee);const Ue=yield Xt.apiCall(`/api/resource/Asset Maintenance Team?filters=[["custom_expertise","=","${encodeURIComponent(Ee)}"]]&fields=["name"]&limit=100`);if(Ue!=null&&Ue.data&&Ue.data.length>0){const ht=new Set,ur=Ue.data.map(Ar=>me(null,null,function*(){try{const ra=yield Xt.apiCall(`/api/resource/Asset Maintenance Team/${encodeURIComponent(Ar.name)}`);ra!=null&&ra.data&&(ra.data.maintenance_team_members||[]).forEach(Dr=>{Dr.team_member&&Dr.maintenance_role==="Technician"&&ht.add(Dr.team_member)})}catch(ra){console.error("Error fetching team:",Ar.name,ra)}}));yield Promise.all(ur);const tr=Array.from(ht);console.log("Filtered Technicians (Technician role only):",tr),Nr(tr)}else Nr([])}catch(Ue){console.error("Error fetching technicians:",Ue),Nr([])}}),[]),Hi=_.useCallback(se=>me(null,null,function*(){if(!se){_r([]);return}const Ee=hn(se);try{console.log("Filtering engineers for work order type:",se,"→ expertise:",Ee);const Ue=yield Xt.apiCall(`/api/resource/Asset Maintenance Team?filters=[["custom_expertise","=","${encodeURIComponent(Ee)}"]]&fields=["name"]&limit=100`);if(Ue!=null&&Ue.data&&Ue.data.length>0){const ht=new Set,ur=Ue.data.map(Ar=>me(null,null,function*(){try{const ra=yield Xt.apiCall(`/api/resource/Asset Maintenance Team/${encodeURIComponent(Ar.name)}`);ra!=null&&ra.data&&(ra.data.maintenance_team_members||[]).forEach(Dr=>{Dr.team_member&&Dr.maintenance_role==="Contractor Engineer"&&ht.add(Dr.team_member)})}catch(ra){console.error("Error fetching team for engineers:",Ar.name,ra)}}));yield Promise.all(ur);const tr=Array.from(ht);console.log("Filtered Engineers (Contractor Engineer role):",tr),_r(tr)}else _r([])}catch(Ue){console.error("Error fetching engineers:",Ue),_r([])}}),[]),it=_.useCallback(se=>me(null,null,function*(){if(!se){Kt([]);return}Se(!0);try{const Ee=JSON.stringify([["building","=",se]]),Ue=yield Xt.apiCall(`/api/resource/Infrastructure Location?filters=${encodeURIComponent(Ee)}&fields=["department"]&limit=9999`);if(Ue!=null&&Ue.data&&Ue.data.length>0){const ht=Ue.data.map(tr=>tr.department).filter(tr=>tr),ur=[...new Set(ht)];console.log("Filtered Departments for building:",se,ur),Kt(ur)}else Kt([])}catch(Ee){console.error("Error fetching departments for building:",Ee),Kt([])}finally{Se(!1)}}),[]),bt=_.useCallback((se,Ee)=>me(null,null,function*(){if(!se&&!Ee){Q([]);return}Se(!0);try{const Ue=new URLSearchParams;se&&Ue.append("building",se),Ee&&Ue.append("department",Ee);const tr=(yield(yield fetch(`/api/method/asset_lite.api.room_filter.get_room_count?${Ue.toString()}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json()).message||0;Q(new Array(tr).fill("")),console.log("Room count:",{building:se,department:Ee,count:tr})}catch(Ue){console.error("Error fetching room count:",Ue),Q([])}finally{Se(!1)}}),[]),Qr=_.useCallback((se,Ee,Ue)=>me(null,null,function*(){if(Ue&&!(!se&&!Ee)){Se(!0);try{const ht=[["room_no","=",Ue]];se&&ht.push(["building","=",se]),Ee&&ht.push(["department","=",Ee]);const ur=JSON.stringify(ht),tr=yield Xt.apiCall(`/api/resource/Infrastructure Location?filters=${encodeURIComponent(ur)}&fields=["location"]&limit=1`);if(tr!=null&&tr.data&&tr.data.length>0&&tr.data[0].location){const Ar=tr.data[0].location;console.log("Auto-setting location:",Ar,{building:se,department:Ee,roomNo:Ue}),wr(ra=>ra.custom_location===Ar?ra:(Mt.info(e("workOrders.detail.locationAutoSetTo",{location:Ar}),{position:"top-right",autoClose:2e3,icon:t.jsx(Tr,{})}),Ke(Te({},ra),{custom_location:Ar})))}}catch(ht){console.error("Error fetching location:",ht)}finally{Se(!1)}}}),[]);_.useCallback(()=>me(null,null,function*(){fe(!0);try{const Ee=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(Ee.message&&Array.isArray(Ee.message)){const Ue=Ee.message.map(ht=>({name:ht.name,full_name:ht.full_name||ht.name}));B(Ue),console.log("Fetched technicians:",Ue.length)}else B([]),console.log("No technicians found")}catch(se){console.error("Error fetching technicians:",se),B([])}finally{fe(!1)}}),[]);const gr=se=>{W(Ee=>Ee.includes(se)?Ee.filter(Ue=>Ue!==se):[...Ee,se])},En=()=>{if(z.length===0){Mt.warning(e("workOrders.detail.noTechniciansSelected"),{position:"top-right",autoClose:3e3,icon:t.jsx(Jr,{})});return}ee(z),ke(!0)},Lr=()=>{const se=we.join(",");wr(Ee=>Ke(Te({},Ee),{custom_add_technicians:se})),ke(!1),F(!1),ee([]),Mt.success(e("workOrders.detail.techniciansAssignedSuccessfully",{count:we.length}),{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})})},oa=()=>{ke(!1),ee([])},gi=_.useMemo(()=>{if(!Y)return X;const se=Y.toLowerCase();return X.filter(Ee=>Ee.name.toLowerCase().includes(se)||Ee.full_name&&Ee.full_name.toLowerCase().includes(se))},[X,Y]);_.useEffect(()=>{De.work_order_type?Ts(De.work_order_type):lr([])},[De.work_order_type,Ts]),_.useEffect(()=>{De.work_order_type?Ai(De.work_order_type):Nr([])},[De.work_order_type,Ai]),_.useEffect(()=>{De.work_order_type?Hi(De.work_order_type):_r([])},[De.work_order_type,Hi]),_.useEffect(()=>{De.custom_building?it(De.custom_building):Kt([])},[De.custom_building,it]),_.useEffect(()=>{const se=De.custom_building||void 0,Ee=De.department||void 0;se||Ee?bt(se,Ee):Q([])},[De.custom_building,De.department,bt]),_.useEffect(()=>{const se=De.custom_building||void 0,Ee=De.department||void 0,Ue=De.custom_room_no||void 0;Ue&&(se||Ee)&&Qr(se,Ee,Ue)},[De.custom_building,De.department,De.custom_room_no,Qr]);const As=_.useCallback((se,Ee,Ue)=>{if(!se)return"";let ht=0;const ur=Ue===1;return Ee==="Normal"?ht=ur?30:5:Ee==="Medium"?ht=ur?30:3:Ee==="Urgent"&&(ht=ur?30:1),o$(se,ht)},[]);_.useEffect(()=>{if(!et)return;const se=As(De.failure_date,De.custom_priority_||"Normal",De.need_procurement||0);se&&se!==De.custom_deadline_date&&wr(Ee=>Ke(Te({},Ee),{custom_deadline_date:se}))},[De.failure_date,De.custom_priority_,De.need_procurement,et,As]),_.useEffect(()=>{Cn&&et&&wr(se=>Ke(Te({},se),{manufacturer:"",supplier:"",model:""}))},[Cn,et]);const{shouldShowField:Os,isMandatory:$s,isReadOnly:Qa}=nS("Work_Order",De);_.useCallback(se=>Os(se),[Os]),_.useCallback(se=>$s(se),[$s]);const en=_.useCallback(se=>Qa(se),[Qa]),Qn=_.useCallback(()=>!!(De.custom_building||De.department),[De.custom_building,De.department]),Bn=_.useCallback(()=>!!(De.department||De.custom_room_no),[De.department,De.custom_room_no]),So=_.useCallback(()=>!!(De.custom_room_no||De.custom_location),[De.custom_room_no,De.custom_location]);_.useCallback(se=>Me||Qt||!et?!0:en(se),[et,en,Me,Qt]),_.useMemo(()=>{if(!Ce)return Re.slice(0,30);const se=Ce.toLowerCase();return Re.filter(Ee=>Ee.toLowerCase().includes(se)).slice(0,50)},[Re,Ce]);const cs=_.useMemo(()=>{if(!u)return{asset_type:(Z==null?void 0:Z.asset_type)||De.asset_type||"",site_name:(Z==null?void 0:Z.site_name)||De.site_name||"",need_procurement:(Z==null?void 0:Z.need_procurement)||De.need_procurement||0,custom_assign_to_contractor:(Z==null?void 0:Z.custom_assign_to_contractor)||De.custom_assign_to_contractor||"",assigned_technician:(Z==null?void 0:Z.assigned_technician)||De.assigned_technician||"",custom_assigned_engineer:(Z==null?void 0:Z.custom_assigned_engineer)||De.custom_assigned_engineer||"",docstatus:(Z==null?void 0:Z.docstatus)||De.docstatus||0,company:(Z==null?void 0:Z.company)||De.company||"",department:(Z==null?void 0:Z.department)||De.department||"",repair_status:(Z==null?void 0:Z.repair_status)||De.repair_status||"",first_responded_on:(Z==null?void 0:Z.first_responded_on)||De.first_responded_on||""}},[u,Z==null?void 0:Z.asset_type,Z==null?void 0:Z.site_name,Z==null?void 0:Z.need_procurement,Z==null?void 0:Z.custom_assign_to_contractor,Z==null?void 0:Z.docstatus,Z==null?void 0:Z.company,Z==null?void 0:Z.department,Z==null?void 0:Z.repair_status,Z==null?void 0:Z.first_responded_on,De.first_responded_on,De.asset_type,De.site_name,De.need_procurement,De.custom_assign_to_contractor,De.docstatus,De.company,De.department,De.repair_status]),{transitions:Ds,loading:es,actionLoading:ei,error:ga,isSystemManager:ti,applyAction:Tn,getStateStyle:Oi,getButtonStyle:Zo,getIcon:Pa}=Lg({doctype:"Work_Order",docname:u?null:r||null,workflowState:Z==null?void 0:Z.workflow_state,enabled:!u,docData:cs}),ri=_.useMemo(()=>{if(!Ds||Ds.length===0)return re(null),[];const se=Ds.filter(vs=>vs.action!=="DR Reject");if(se.length===0)return re(null),[];const Ee=E.includes("Work Control"),Ue=E.includes("System Manager")||ti,ht=(Z==null?void 0:Z.workflow_state)||De.workflow_state||"Draft",ur=De.assigned_technician||(Z==null?void 0:Z.assigned_technician)||"",tr=De.custom_assigned_supervisor||(Z==null?void 0:Z.custom_assigned_supervisor)||"",Ar=De.custom_assigned_engineer||(Z==null?void 0:Z.custom_assigned_engineer)||"",ra=(Z==null?void 0:Z.work_order_type)||"",La=yr!==""&&ra!==""&&ra!==yr;if(ht==="Sent to Engineer"){if(La){setTimeout(()=>re('WO Type has been changed. Use "Back To Controller" to send for reassignment, or revert the change.'),0);const $n=se.find(bl=>bl.action==="Back To Controller"&&bl.state==="Sent to Engineer");return $n?[$n]:[]}const as=(De.actions_performed||(Z==null?void 0:Z.actions_performed)||"").trim().length>0,xn=!!ur,xa=se.filter($n=>$n.state==="Sent to Engineer"),Bs=xa.find($n=>$n.action==="Send to Supervisor"),pn=xa.find($n=>$n.action==="Back To Controller"),oi=xa.filter($n=>$n.action!=="Send to Supervisor"&&$n.action!=="Back To Controller"),ws=[];return xn&&as?(setTimeout(()=>re(null),0),ws.push(...oi),Bs&&ws.push(Bs),pn&&ws.push(pn)):xn&&!as?(setTimeout(()=>re('Technician assigned. Fill "Technical Report" to also enable "Send to Supervisor" option.'),0),ws.push(...oi),pn&&ws.push(pn)):!xn&&as?(setTimeout(()=>re('Technical Report filled. You can "Send to Supervisor" directly, OR assign a Technician for more workflow options.'),0),Bs&&ws.push(Bs),pn&&ws.push(pn)):(setTimeout(()=>re(null),0),pn&&ws.push(pn)),ws}if(ht==="Repair InProgress"){if(La){setTimeout(()=>re('WO Type has been changed. Use "Back To Controller" to send for reassignment, or revert the change.'),0);const xa=se.find(Bs=>Bs.action==="Back To Controller"&&Bs.state==="Repair InProgress");return xa?[xa]:[]}const as=(De.actions_performed||(Z==null?void 0:Z.actions_performed)||"").trim().length>0,xn=se.filter(xa=>xa.state==="Repair InProgress");return as?(setTimeout(()=>re(null),0),xn):(setTimeout(()=>re('Please fill the "Technical Report" field to enable "Send For Approval" action.'),0),xn.filter(xa=>xa.action!=="Send For Approval"))}const Dr={};se.forEach(vs=>{Dr[vs.action]||(Dr[vs.action]=[]),Dr[vs.action].push(vs)});const Ta=[];let gs=null;return Object.entries(Dr).forEach(([vs,as])=>{if(as.length===1){const xn=as[0];if(vs==="Apply"&&xn.allowed==="Work Control"&&(Ee||Ue)){const xa=[];if(tr||xa.push("Assigned Supervisor"),Ar||xa.push("Assigned Engineer"),xa.length>0){gs=`Please assign ${xa.join(" and ")} before applying`,console.log(`Apply hidden for Work Control: ${gs}`);return}}Ta.push(xn)}else{const xn=as.find(xa=>xa.allowed==="Work Control");if(as.find(xa=>xa.allowed==="End user"),Ee||Ue)if(xn){if(vs==="Apply"){const xa=[];if(tr||xa.push("Assigned Supervisor"),Ar||xa.push("Assigned Engineer"),xa.length>0){gs=`Please assign ${xa.join(" and ")} before applying`,console.log(`Apply hidden for Work Control: ${gs}`);return}}Ta.push(xn)}else as.forEach(xa=>Ta.push(xa));else as.forEach(xa=>Ta.push(xa))}}),setTimeout(()=>re(gs),0),Ta.filter(vs=>vs.action==="Send For Approval"&&ht==="Repair InProgress"?Ue?!0:O?!!(O===ur||(De.custom_add_technicians||(Z==null?void 0:Z.custom_add_technicians)||"").split(",").map(pn=>pn.trim()).filter(pn=>pn).includes(O)):!1:!0)},[Ds,E,ti,O,De.assigned_technician,De.custom_assigned_supervisor,De.custom_assigned_engineer,De.workflow_state,De.custom_add_technicians,De.actions_performed,Z==null?void 0:Z.assigned_technician,Z==null?void 0:Z.custom_assigned_supervisor,Z==null?void 0:Z.custom_assigned_engineer,Z==null?void 0:Z.workflow_state,Z==null?void 0:Z.custom_add_technicians,Z==null?void 0:Z.work_order_type,Z==null?void 0:Z.actions_performed,yr]),xl=_.useMemo(()=>E.includes("Work Control")||ti,[E,ti]),mn="Stores - KFSH-D",[Co,Gt]=_.useState({}),na=(se,Ee)=>me(null,null,function*(){if(!se||!Ee)return 0;try{const Ue=yield Xt.apiCall(`/api/resource/Bin?filters=[["item_code","=","${se}"],["warehouse","=","${Ee}"]]&fields=["actual_qty"]&limit=1`);return Ue!=null&&Ue.data&&Ue.data.length>0&&Ue.data[0].actual_qty||0}catch(Ue){return console.error("Error fetching available stock:",Ue),0}}),Ls=se=>me(null,null,function*(){var Ee;if(!se)return 0;try{const Ue=yield Xt.apiCall(`/api/resource/Item/${se}?fields=["valuation_rate"]`);return((Ee=Ue==null?void 0:Ue.data)==null?void 0:Ee.valuation_rate)||0}catch(Ue){return console.error("Error fetching valuation rate:",Ue),0}}),An=se=>me(null,null,function*(){var Ee;if(!se)return mn;try{const Ue=yield Xt.apiCall(`/api/resource/Item/${se}?fields=["item_defaults"]`),ht=((Ee=Ue==null?void 0:Ue.data)==null?void 0:Ee.item_defaults)||[];return ht.length>0&&ht[0].default_warehouse?ht[0].default_warehouse:mn}catch(Ue){return console.error("Error fetching item default warehouse:",Ue),mn}}),pc=(se,Ee)=>me(null,null,function*(){const Ue=[...De.stock_items||[]];if(Ee){const ht=Ue.findIndex((ur,tr)=>tr!==se&&ur.item_code===Ee);if(ht!==-1){Mt.warning(e("workOrders.detail.itemAlreadyAdded",{itemCode:Ee,row:ht+1}),{position:"top-right",autoClose:4e3,icon:t.jsx(Jr,{}),toastId:`duplicate-item-${se}`}),Ue[se]=Ke(Te({},Ue[se]),{item_code:"",item_name:"",valuation_rate:0,custom_available_stock:0,total_value:0}),wr(Ke(Te({},De),{stock_items:Ue}));return}}if(Ue[se]=Ke(Te({},Ue[se]),{item_code:Ee}),Ee){const[ht,ur]=yield Promise.all([Ls(Ee),An(Ee)]);Ue[se].valuation_rate=ht,Ue[se].total_value=ht*(Ue[se].consumed_quantity||1),Ue[se].warehouse=ur;const tr=yield na(Ee,ur);Ue[se].custom_available_stock=tr,ts(se,Ue[se].consumed_quantity,tr,Ee,ur)}wr(Ke(Te({},De),{stock_items:Ue}))}),Bl=se=>{wr(Ee=>Ke(Te({},Ee),{custom_building:se,department:"",custom_room_no:"",custom_location:""}))},$i=se=>{wr(Ee=>Ke(Te({},Ee),{department:se,custom_room_no:"",custom_location:""}))},yc=se=>{wr(Ee=>Ke(Te({},Ee),{custom_room_no:se,custom_location:""}))},pl=(se,Ee)=>me(null,null,function*(){const Ue=[...De.stock_items||[]];if(Ue[se]=Ke(Te({},Ue[se]),{warehouse:Ee}),Ee&&Ue[se].item_code){const ht=yield na(Ue[se].item_code,Ee);Ue[se].custom_available_stock=ht,ts(se,Ue[se].consumed_quantity,ht,Ue[se].item_code,Ee)}wr(Ke(Te({},De),{stock_items:Ue}))}),ts=(se,Ee,Ue,ht,ur)=>{Ee>Ue?(Gt(tr=>Ke(Te({},tr),{[se]:`Insufficient stock for ${ht} in ${ur}. Available: ${Ue}, Required: ${Ee}`})),Mt.warning(e("workOrders.detail.insufficientStock",{itemCode:ht,available:Ue,required:Ee}),{position:"top-right",autoClose:5e3,icon:t.jsx(Jr,{}),toastId:`stock-warning-${se}`})):Gt(tr=>{const Ar=Te({},tr);return delete Ar[se],Ar})},Ko=(se,Ee)=>{const Ue=[...De.stock_items||[]],ht=Ue[se].valuation_rate||0,ur=Ue[se].custom_available_stock||0;Ue[se]=Ke(Te({},Ue[se]),{consumed_quantity:Ee,total_value:ht*Ee}),Ue[se].item_code&&Ue[se].warehouse&&ts(se,Ee,ur,Ue[se].item_code,Ue[se].warehouse),wr(Ke(Te({},De),{stock_items:Ue}))},[rs,Jo]=_.useState({});_.useEffect(()=>{const se={};De.company&&(se.company=De.company),Jo(se)},[De.company]);const io=se=>me(null,null,function*(){if(!se)return null;try{Lt(!0);const Ee=yield Xt.apiCall(`/api/resource/Asset/${se}?fields=["name","asset_name","company","department","custom_serial_number","custom_local_id","custom_technical_department","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","docstatus","custom_delete_status"]`),Ue=(Ee==null?void 0:Ee.data)||null;return Ue&&!n4(Ue)?null:Ue}catch(Ee){return console.error("Error fetching asset details:",Ee),null}finally{Lt(!1)}}),za='["name","asset_name","company","department","custom_serial_number","custom_local_id","custom_technical_department","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","docstatus","custom_delete_status"]',$r=(se,Ee)=>me(null,null,function*(){const Ue=Ee.trim();if(!Ue)return null;try{Lt(!0);const ht=i4([[se,"=",Ue]]),ur=yield Xt.apiCall(`/api/resource/Asset?filters=${encodeURIComponent(JSON.stringify(ht))}&fields=${za}&limit=1`);if(ur!=null&&ur.data&&ur.data.length>0){const tr=ur.data[0];return n4(tr)?tr:null}return null}catch(ht){return console.error(`Error fetching asset by ${se}:`,ht),null}finally{Lt(!1)}}),bc=se=>$r("custom_serial_number",se),Wa=se=>$r("custom_local_id",se),Un=se=>se?se.split(" ")[0]:"",zn=se=>{se&&wr(Ee=>Ke(Te({},Ee),{asset:se.name||Ee.asset,asset_name:se.asset_name||"",company:se.company||"",department:se.department||"",serial_number:se.custom_serial_number||"",custom_local_id:se.custom_local_id||"",work_order_type:se.custom_technical_department||"",asset_type:se.custom_asset_type||"",manufacturer:se.custom_manufacturer||"",supplier:se.supplier||"",custom_site_contractor:se.custom_site_contractor||"",custom_subcontractor:se.custom_subcontractor||"",model:se.custom_model||"",site_name:se.custom_site||"",custom_service_agreement:se.custom_service_agreement||"",custom_service_coverage:se.custom_service_coverage||"",custom_start_date:Un(se.custom_start_date)||"",custom_end_date:Un(se.custom_end_date)||"",custom_total_amount:se.custom_total_amount||0,custom_location:se.location||se.custom_location||"",custom_building:se.custom_building||"",custom_room_no:se.custom_room_number||""}))},Vi=se=>me(null,null,function*(){if(wr(Ee=>Ke(Te({},Ee),{asset:se})),se){const Ee=yield io(se);Ee?zn(Ee):(wr(Ue=>Ke(Te({},Ue),{asset:""})),Mt.error(e("workOrders.detail.assetNotAvailable"),{position:"top-right",autoClose:4e3,icon:t.jsx(Br,{})}))}else wr(Ee=>Ke(Te({},Ee),{asset:"",asset_name:"",serial_number:"",custom_local_id:"",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:""}))}),ai=(se,Ee,Ue,ht,ur)=>{if(!ur.trim()){Mt.warning(e(ht),{position:"top-right",autoClose:3e3,icon:t.jsx(Jr,{})});return}se?(zn(se),Mt.success(e(Ee,{name:se.asset_name||se.name}),{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})})):Mt.error(e(Ue),{position:"top-right",autoClose:4e3,icon:t.jsx(Br,{})})},oo=()=>me(null,null,function*(){const se=yield bc(De.serial_number);ai(se,"workOrders.detail.assetFound","workOrders.detail.noAssetFoundWithSerialNumber","workOrders.detail.pleaseEnterSerialNumberToSearch",De.serial_number)}),On=()=>me(null,null,function*(){if(De.serial_number&&!De.asset){const se=yield bc(De.serial_number);se&&zn(se)}}),Eo=()=>me(null,null,function*(){const se=yield Wa(De.custom_local_id);ai(se,"workOrders.detail.assetFound","workOrders.detail.noAssetFoundWithLocalId","workOrders.detail.pleaseEnterLocalIdToSearch",De.custom_local_id)}),lo=()=>me(null,null,function*(){if(De.custom_local_id&&!De.asset){const se=yield Wa(De.custom_local_id);se&&zn(se)}}),vc=se=>me(null,null,function*(){var ht,ur;const Ee=(ht=se.target.files)==null?void 0:ht[0];if(!Ee)return;const Ue=10*1024*1024;if(Ee.size>Ue){Mt.error(e("workOrders.detail.fileSizeExceeds"),{position:"top-right",autoClose:4e3,icon:t.jsx(Br,{})});return}_e(!0);try{const tr=new FormData;tr.append("file",Ee),tr.append("is_private","0"),tr.append("folder","Home/Attachments"),!u&&r&&(tr.append("doctype","Work_Order"),tr.append("docname",r));const Ar=Or.BASE_URL||"",La=yield(yield fetch(`${Ar}/api/method/upload_file`,{method:"POST",credentials:"include",body:tr})).json();if((ur=La.message)!=null&&ur.file_url)wr(Dr=>Ke(Te({},Dr),{custom_attachment:La.message.file_url})),Mt.success(e("workOrders.detail.fileUploadedSuccessfully"),{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})});else throw new Error("Upload failed")}catch(tr){console.error("File upload error:",tr),Mt.error(e("workOrders.detail.failedToUploadFile"),{position:"top-right",autoClose:4e3,icon:t.jsx(Br,{})})}finally{_e(!1),se.target.value=""}}),yl=()=>{wr(se=>Ke(Te({},se),{custom_attachment:""})),Mt.info(e("workOrders.detail.attachmentRemoved"),{position:"top-right",autoClose:2e3})},xi=se=>{if(!se)return"";const Ee=se.split("/");return Ee[Ee.length-1]||se};_.useEffect(()=>{if(u&&c&&!h){const se={asset:s.get("asset")||"",asset_name:s.get("asset_name")||"",asset_type:s.get("asset_type")||"Non Biomedical",manufacturer:s.get("manufacturer")||"",supplier:s.get("supplier")||"",serial_number:s.get("serial_number")||"",custom_local_id:s.get("local_id")||"",work_order_type:s.get("work_order_type")||"",department:s.get("department")||"",custom_site_contractor:s.get("site_contractor")||"",custom_subcontractor:s.get("subcontractor")||"",company:s.get("company")||"",site_name:s.get("site_name")||"",custom_building:s.get("building")||"",custom_room_no:s.get("room_no")||"",custom_location:s.get("location")||"",custom_service_agreement:s.get("custom_service_agreement")||"",custom_service_coverage:s.get("custom_service_coverage")||"",custom_assigned_supervisor:s.get("team_leader")||""};wr(Ee=>Ke(Te(Te({},Ee),se),{repair_status:"Open",workflow_state:"Draft",custom_priority_:"Normal",failure_date:ef()}))}},[u,c,h,s]),_.useEffect(()=>{Z&&!Nt&&!u&&!h&&(jt(Z.work_order_type||""),He(Z.custom_assigned_supervisor||""),Ze(Z.custom_assigned_engineer||""),ir(Z.assigned_technician||""),Cr(!0),console.log("Initial values stored:",{workOrderType:Z.work_order_type,supervisor:Z.custom_assigned_supervisor,engineer:Z.custom_assigned_engineer,technician:Z.assigned_technician}))},[Z,Nt,u,h]),_.useEffect(()=>{var se;Z&&(Ye.current||Yt((se=Z.custom_delete_status)!=null?se:null),Ye.current=!1,wr({company:Z.company||"",work_order_type:Z.work_order_type||"",asset:Z.asset||"",asset_name:h?`${Z.asset_name} (Copy)`:Z.asset_name||"",description:Z.description||"",repair_status:h?"Open":Z.repair_status||"Open",workflow_state:h?"Draft":Z.workflow_state||"Draft",department:Z.department||"",custom_priority_:Z.custom_priority_||"Normal",asset_type:Z.asset_type||"Non Biomedical",custom_type:Z.custom_type||"Corrective",manufacturer:Z.manufacturer||"",supplier:Z.supplier||"",serial_number:Z.serial_number||"",custom_local_id:Z.custom_local_id||"",model:Z.model||"",custom_site_contractor:Z.custom_site_contractor||"",custom_subcontractor:Z.custom_subcontractor||"",failure_date:O0(Z.failure_date)||"",custom_deadline_date:Un(Z.custom_deadline_date)||"",first_responded_on:O0(Z.first_responded_on)||"",completion_date:O0(Z.completion_date)||"",actions_performed:Z.actions_performed||"",stock_consumption:Z.stock_consumption||0,stock_items:Z.stock_items||[],site_name:Z.site_name||"",need_procurement:Z.need_procurement||0,custom_assign_to_contractor:Z.custom_assign_to_contractor||"",assigned_technician:Z.assigned_technician||"",custom_assigned_engineer:Z.custom_assigned_engineer||"",custom_add_technicians:Z.custom_add_technicians||"",docstatus:Z.docstatus||0,custom_assigned_supervisor:Z.custom_assigned_supervisor||"",total_hours_spent:Z.total_hours_spent||0,custom_pending_reason:Z.custom_pending_reason||"",total_repair_cost:Z.total_repair_cost||0,custom_travel_hour:Z.custom_travel_hour||"",custom_service_agreement:Z.custom_service_agreement||"",custom_service_coverage:Z.custom_service_coverage||"",custom_start_date:Un(Z.custom_start_date)||"",custom_end_date:Un(Z.custom_end_date)||"",custom_total_amount:Z.custom_total_amount||0,custom_location:Z.custom_location||"",custom_extension_no:Z.custom_extension_no||"",custom_attachment:Z.custom_attachment||"",custom_attachment_on_close:Z.custom_attachment_on_close||"",inspection:Z.inspection||"",custom_department_no:Z.custom_department_no||"",custom_reason:Z.custom_reason||"",custom_room_no:Z.custom_room_no||"",custom_building:Z.custom_building||"",custom_civil_work_category:Z.custom_civil_work_category||""}))},[Z,h]);const ds=se=>{const{name:Ee,value:Ue}=se.target;wr(ht=>Ke(Te({},ht),{[Ee]:Ue}))},Ul=se=>{const Ee=se.target.value;wr(Ue=>Ke(Te({},Ue),{custom_priority_:Ee}))},co=se=>{const Ee=se.target.value;wr(Ue=>Ke(Te({},Ue),{failure_date:Ee}))},To=se=>{const Ee=se.target.value;wr(Ue=>Ke(Te({},Ue),{first_responded_on:Ee}))},Rs=se=>{const Ee=se.target.value;wr(Ue=>Ke(Te({},Ue),{completion_date:Ee}))},Di=()=>{const se=ef();wr(Ee=>Ke(Te({},Ee),{failure_date:se})),Mt.info(e("workOrders.detail.failureDateSetToCurrentTime"),{position:"top-right",autoClose:2e3,icon:t.jsx(Ja,{})})},Wn=()=>{const se=ef();wr(Ee=>Ke(Te({},Ee),{first_responded_on:se})),Mt.info(e("workOrders.detail.firstRespondedOnSetToCurrentTime"),{position:"top-right",autoClose:2e3,icon:t.jsx(Ja,{})})},si=()=>{const se=ef();wr(Ee=>Ke(Te({},Ee),{completion_date:se})),Mt.info(e("workOrders.detail.completionDateSetToCurrentTime"),{position:"top-right",autoClose:2e3,icon:t.jsx(Ja,{})})},ni=se=>{se===yr&&yr!==""?(wr(Ee=>Ke(Te({},Ee),{work_order_type:se,custom_assigned_supervisor:Tt,custom_assigned_engineer:Fe,assigned_technician:vt,custom_civil_work_category:se==="Civil works-الأعمال المدنية"?Ee.custom_civil_work_category:""})),console.log("Reverted to original work_order_type, restored values:",{supervisor:Tt,engineer:Fe,technician:vt})):wr(Ee=>Ke(Te({},Ee),{work_order_type:se,custom_assigned_supervisor:"",custom_assigned_engineer:"",custom_assign_to_contractor:"",assigned_technician:"",custom_civil_work_category:se==="Civil works-الأعمال المدنية"?Ee.custom_civil_work_category:""}))},pi=se=>{wr(Ee=>Ke(Te({},Ee),{custom_assigned_supervisor:se}))},yi=_.useMemo(()=>E.includes("Work Control")||E.includes("System Manager"),[E]),Qo=()=>{if(yi&&!u){if(!De.custom_assigned_supervisor)return Mt.error(e("workOrders.detail.assignedSupervisorMandatory"),{position:"top-right",autoClose:5e3,icon:t.jsx(Br,{})}),!1;if(!De.custom_assigned_engineer)return Mt.error(e("workOrders.detail.assignedEngineerMandatory"),{position:"top-right",autoClose:5e3,icon:t.jsx(Br,{})}),!1;if(f==="Sent to Engineer"&&!De.assigned_technician)return Mt.error(e("workOrders.detail.assignedTechnicianMandatory"),{position:"top-right",autoClose:5e3,icon:t.jsx(Br,{})}),!1}return!0},Ao=()=>me(null,null,function*(){if(r){kt(!0);try{yield rt(r,{workflow_state:"Cancelled",docstatus:2,repair_status:"Cancelled"}),Mt.success(e("workOrders.detail.workOrderCancelledSuccessfully"),{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),zt(!1),Be(),setTimeout(()=>{ua()},500)}catch(se){const Ee=se instanceof Error?se.message:"Unknown error";Mt.error(e("workOrders.detail.failedToCancel",{error:Ee}),{position:"top-right",autoClose:6e3,icon:t.jsx(Br,{})})}finally{kt(!1)}}}),gn=()=>me(null,null,function*(){if(r)try{yield Xt.apiCall(`/api/resource/Work_Order/${r}`,{method:"DELETE"}),Mt.success(e("workOrders.detail.workOrderDeletedSuccessfully"),{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),a(-1)}catch(se){const Ee=se instanceof Error?se.message:"Unknown error";Mt.error(e("workOrders.detail.failedToDelete",{error:Ee}),{position:"top-right",autoClose:6e3,icon:t.jsx(Br,{})})}}),zl=se=>me(null,null,function*(){if(se.preventDefault(),!De.work_order_type){Mt.error(e("workOrders.detail.pleaseSelectWorkOrderType"),{position:"top-right",autoClose:4e3,icon:t.jsx(Br,{})});return}if(De.work_order_type==="Civil works-الأعمال المدنية"&&!String(De.custom_civil_work_category||"").trim()){Mt.error(e("workOrders.detail.civilWorkCategoryMandatory"),{position:"top-right",autoClose:5e3,icon:t.jsx(Br,{})});return}if(!Qo())return;const Ee=Ke(Te({},De),{failure_date:D0(De.failure_date),first_responded_on:D0(De.first_responded_on),completion_date:D0(De.completion_date)});try{if(u||h){const Ue=yield pe(Ee),ht=e(h?"workOrders.detail.workOrderDuplicatedSuccessfully":c?"workOrders.detail.workOrderCreatedFromAssetSuccessfully":"workOrders.detail.workOrderCreatedSuccessfully");Mt.success(ht,{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),a(`/work-orders/${Ue.name}`)}else r&&(yield rt(r,Ee),Mt.success(e("workOrders.detail.workOrderUpdatedSuccessfully"),{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),It(!1),Be(),setTimeout(()=>{ua()},500))}catch(Ue){console.error("Work order save error:",Ue);const ht=Ue instanceof Error?Ue.message:"Unknown error",ur=JSON.stringify(Ue);ht.includes("TimestampMismatchError")||ht.includes("Document has been modified")||ht.includes("Please refresh")||ur.includes("TimestampMismatchError")?(Mt.error(e("workOrders.detail.documentModifiedByAnotherUser"),{position:"top-right",autoClose:4e3,icon:t.jsx(Jr,{})}),yield Be(),Mt.info(e("workOrders.detail.pleaseReviewLatestChanges"),{position:"top-right",autoClose:5e3,icon:t.jsx(il,{})})):Mt.error(e("workOrders.detail.failedToSaveWorkOrder",{error:ht}),{position:"top-right",autoClose:6e3,icon:t.jsx(Br,{})})}});_.useEffect(()=>{u||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(se=>se.json()).then(se=>{var Ee;(Ee=se.message)!=null&&Ee.has_role&&w(!0)}).catch(se=>console.error("Role check error:",se))},[u]);const Hn=se=>me(null,null,function*(){if(!r||u||!["Apply","Send For Repair"].includes(se))return null;try{const Ue=yield Xt.apiCall("/api/method/assign_supervisor_or_technician",{method:"POST",body:JSON.stringify({work_order:r,action:se,asset_type:De.asset_type||(Z==null?void 0:Z.asset_type)||""})});return(Ue==null?void 0:Ue.message)||null}catch(Ue){return console.error("Error in before_workflow_action:",Ue),null}}),ii=(se,Ee)=>me(null,null,function*(){if(["Reject","Cancel","Close"].includes(se)&&(Je==null?void 0:Je.action)!==se){Ve({action:se,nextState:Ee||""});return}if(Ve(null),Rt(""),se==="Cancel"&&r){const Dr=d1();try{yield rt(r,{completion_date:Dr}),wr(Ta=>Ke(Te({},Ta),{completion_date:O0(Dr)})),console.log("Auto-set completion_date on Cancel:",Dr)}catch(Ta){console.error("Error setting completion_date on Cancel:",Ta)}}const ht=(Z==null?void 0:Z.workflow_state)||De.workflow_state||"Draft";if(se==="Send to Supervisor"&&ht==="Sent to Engineer"&&!(De.actions_performed||"").trim()){Mt.dismiss(),setTimeout(()=>{Mt.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(Jr,{})})},100);return}const ur=Mt.loading(e("workOrders.detail.applyingAction",{action:se}),{position:"top-right"});yield Be();const tr=yield Hn(se);tr!=null&&tr.assigned_to&&(Mt.info(e("workOrders.detail.assignedTo",{name:tr.assigned_to}),{position:"top-right",autoClose:4e3,icon:t.jsx(Tr,{})}),yield Be());let Ar=!1,ra=0;const La=3;for(;!Ar&&ra<La;)try{if(se==="Reject"&&r&&Xe.trim()){const Ta=f==="Pending Approval"?"custom_engineer_reject_reason":"custom_supervisor_reject_reason";try{yield rt(r,{[Ta]:Xe.trim()})}catch(gs){console.error("Error saving reject reason:",gs)}}Ar=yield Tn(se,Ee);break}catch(Dr){const Ta=(Dr==null?void 0:Dr.message)||String(Dr);if((Ta.includes("TimestampMismatchError")||Ta.includes("Document has been modified")||Ta.includes("Please refresh"))&&ra<La-1)ra++,console.log(`Timestamp mismatch, retrying... (attempt ${ra})`),yield Be(),yield new Promise(vs=>setTimeout(vs,500));else throw Dr}if(Mt.dismiss(ur),Ar)Mt.success(e("workOrders.detail.actionCompletedSuccessfully",{action:se}),{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),Be(),setTimeout(()=>ua(),500);else{const Dr=ga||"Please try again.";Dr.includes("TimestampMismatchError")||Dr.includes("Document has been modified")||Dr.includes("Please refresh")?(Mt.error(e("workOrders.detail.documentModifiedRefreshing"),{position:"top-right",autoClose:4e3,icon:t.jsx(Jr,{})}),yield Be(),Mt.info(e("workOrders.detail.tryActionAgainAfterReview"),{position:"top-right",autoClose:5e3,icon:t.jsx(il,{})})):Mt.error(e("workOrders.detail.failedToApplyAction",{action:se,error:Dr}),{position:"top-right",autoClose:6e3,icon:t.jsx(Br,{})})}});if(Le)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("workOrders.loadingDetails")})]})});if(Pe&&!u&&!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-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 ja=()=>e(h?"workOrders.detail.duplicateWorkOrder":c?"workOrders.detail.createFromAsset":u?"workOrders.detail.newWorkOrder":"workOrders.detail.workOrderDetails"),tn=(Z==null?void 0:Z.workflow_state)||De.workflow_state||"Draft",Ne=Oi(tn),l=(ut=(ot=Z==null?void 0:Z.docstatus)!=null?ot:De.docstatus)!=null?ut:0,f=(Z==null?void 0:Z.workflow_state)||De.workflow_state||"Draft",x=E.includes("Work Control"),b=E.includes("Contractor Engineer"),j=E.includes("Contractor Supervisor")&&!ti,T=u||ti&&l===0||y&&f==="Sent to Team Leader"||x&&(f==="Draft"||f==="Sent to Work Control")&&l===0||b&&f==="Sent to Engineer"&&l===0||!es&&ri.length>0,P=()=>{const se=De.custom_priority_||"Normal";if(De.need_procurement===1)return`${se} priority + Procurement: +30 days`;switch(se){case"Urgent":return"Urgent priority: +1 day";case"Medium":return"Medium priority: +3 days";case"Normal":default:return"Normal priority: +5 days"}},H=se=>se?se.replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,Ee=>Ee.toUpperCase()):"",de=se=>se==null||se===""?"(empty)":se===0?"0":se===1?"1":typeof se=="boolean"?se?"Yes":"No":typeof se=="object"?JSON.stringify(se):String(se),je=se=>{if(!se)return"";const Ee=new Date(se),Ue=new Date,ht=Ue.getTime()-Ee.getTime(),ur=Math.floor(ht/6e4),tr=Math.floor(ht/36e5),Ar=Math.floor(ht/864e5);return ur<1?"Just now":ur<60?`${ur} min${ur>1?"s":""} ago`:tr<24?`${tr} hour${tr>1?"s":""} ago`:Ar<7?`${Ar} day${Ar>1?"s":""} ago`:Ee.toLocaleDateString("en-US",{month:"short",day:"numeric",year:Ee.getFullYear()!==Ue.getFullYear()?"numeric":void 0,hour:"2-digit",minute:"2-digit"})},Ae=se=>{if(!se)return"Unknown";const Ee=se.indexOf("@");return Ee===-1?se:se.substring(0,Ee)},Ge=se=>{const Ee=se.toLowerCase();return Ee.includes("status")||Ee.includes("state")?"text-purple-600 dark:text-purple-400":Ee.includes("date")?"text-blue-600 dark:text-blue-400":Ee.includes("technician")||Ee.includes("supervisor")||Ee.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(xc,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:Ll}),ve&&ye.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(Jr,{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(q==="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:ye.map(se=>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/${se.name}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 font-medium hover:underline flex items-center gap-1",children:[se.name," ",t.jsx(ps,{size:10})]}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:[e("workOrders.detail.created"),": ",Tl(se.creation)]})]}),t.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${se.workflow_state==="Draft"?"bg-gray-100 text-gray-700":se.workflow_state==="Repair InProgress"?"bg-blue-100 text-blue-700":"bg-purple-100 text-purple-700"}`,children:se.workflow_state})]},se.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:xr,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:Ea,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(Tr,{size:14})," ",e("workOrders.detail.proceedAnyway")]})]})]})}),wt&&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(po,{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:()=>zt(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",disabled:qt,children:e("workOrders.detail.noGoBack")}),t.jsx("button",{onClick:Ao,disabled:qt,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:qt?t.jsxs(t.Fragment,{children:[t.jsx(Ir,{className:"animate-spin"}),e("workOrders.detail.cancelling")]}):t.jsxs(t.Fragment,{children:[t.jsx(po,{}),e("workOrders.detail.yesCancel")]})})]})]})}),ze&&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(Jr,{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:()=>nt(!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:gn,disabled:ct,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:ct?t.jsxs(t.Fragment,{children:[t.jsx(Ir,{className:"animate-spin"}),e("workOrders.detail.deleting")]}):t.jsxs(t.Fragment,{children:[t.jsx(la,{}),e("common.delete")]})})]})]})}),R&&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(Yn,{className:"text-blue-500"}),e("workOrders.detail.selectAdditionalTechnicians")]}),t.jsx("button",{onClick:()=>F(!1),className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded",children:t.jsx(Pt,{size:18})})]}),t.jsx("div",{className:"mb-4",children:t.jsxs("div",{className:"relative",children:[t.jsx(In,{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:Y,onChange:se=>G(se.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:()=>W([]),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:ie?t.jsxs("div",{className:"flex items-center justify-center py-8",children:[t.jsx(Ir,{className:"animate-spin text-blue-500 mr-2"}),t.jsx("span",{className:"text-sm text-gray-500",children:e("workOrders.detail.loadingTechnicians")})]}):gi.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(Y?"workOrders.detail.noTechniciansMatchSearch":"workOrders.detail.noTechniciansFound")})}):t.jsx("div",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:gi.map(se=>{const Ee=z.includes(se.name),Ue=De.assigned_technician===se.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 ${Ee?"bg-blue-50 dark:bg-blue-900/20":""} ${Ue?"opacity-50 cursor-not-allowed":""}`,children:[t.jsx("input",{type:"checkbox",checked:Ee,onChange:()=>!Ue&&gr(se.name),disabled:Ue,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:se.full_name||se.name}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:se.name})]}),Ue&&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"}),Ee&&!Ue&&t.jsx(Tr,{className:"text-blue-500",size:16})]},se.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:()=>F(!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:En,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(Tr,{size:14}),e("workOrders.detail.saveSelection")," (",z.length,")"]})]})]})}),K&&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(Yn,{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 (",we.length,"):"]}),t.jsx("div",{className:"space-y-2",children:we.map(se=>{const Ee=X.find(ur=>ur.name===se),Ue=(Ee==null?void 0:Ee.full_name)||se,ht=se;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(Yn,{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:Ue}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:ht})]})]},se)})})]}),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:oa,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:Lr,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(Tr,{size:14}),e("workOrders.detail.confirmAssignment")]})]})]})}),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(Kn,{}),t.jsx("span",{className:"text-gray-900 dark:text-white",children:ja()})]}),!u&&t.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${Ne.bg} ${Ne.text} ${Ne.border} border`,children:(Z==null?void 0:Z.repair_status)||De.repair_status||"Open"}),c&&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(Pp,{size:10}),e("workOrders.detail.linkedFromAsset")," ",i]}),ft&&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(Ir,{className:"animate-spin",size:12}),e("workOrders.detail.loadingAssetDetails")]})]}),t.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[!u&&t.jsxs("button",{onClick:g,className:"bg-purple-600 hover:bg-purple-700 text-white px-3 sm:px-6 py-2 rounded-lg flex items-center justify-center gap-2 whitespace-nowrap h-10 sm:h-auto",title:e("workOrders.detail.printServiceReport"),children:[t.jsx(Go,{}),e("workOrders.detail.serviceReport")]}),!u&&!et&&!Me&&!Qt&&T&&!j&&A&&t.jsxs("button",{onClick:()=>{It(!0),Mt.info(e("workOrders.detail.editModeEnabled"),{position:"top-right",autoClose:2e3,icon:t.jsx(Ms,{})})},className:"bg-blue-600 hover:bg-blue-700 text-white px-3 sm:px-6 py-2 rounded-lg flex items-center justify-center gap-2 whitespace-nowrap h-10 sm:h-auto",children:[t.jsx(Ms,{}),e("common.edit")]}),!u&&!et&&(Z==null?void 0:Z.docstatus)===1&&Dt&&t.jsxs("button",{onClick:()=>zt(!0),className:"bg-orange-600 hover:bg-orange-700 text-white px-3 sm:px-6 py-2 rounded-lg flex items-center justify-center gap-2 whitespace-nowrap h-10 sm:h-auto",children:[t.jsx(po,{}),e("common.cancel")]}),et&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{u?a(-1):(It(!1),Mt.info(e("workOrders.detail.editCancelledChangesDiscarded"),{position:"top-right",autoClose:2e3,icon:t.jsx(Br,{})}))},className:"bg-gray-300 hover:bg-gray-400 text-gray-700 px-3 sm:px-6 py-2 rounded-lg whitespace-nowrap h-10 sm:h-auto",disabled:ct,children:e("common.cancel")}),t.jsxs("button",{onClick:zl,disabled:ct||ft,className:"bg-green-600 hover:bg-green-700 text-white px-3 sm:px-6 py-2 rounded-lg flex items-center justify-center gap-2 whitespace-nowrap h-10 sm:h-auto disabled:opacity-50",children:[t.jsx(bs,{}),e(ct?"common.saving":"common.saveChanges")]})]})]})]}),c&&u&&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(Pp,{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:De.asset_name||i}),".",e("assets.pleaseSelectWorkOrderType")]})]})]})}),t.jsx("form",{onSubmit:zl,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"}),c&&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(Pp,{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(hr,{label:e("workOrders.detail.hospital"),doctype:"Company",value:De.company||"",onChange:se=>wr(Ke(Te({},De),{company:se,department:""})),disabled:!et,filters:{domain:"Healthcare"}})}),t.jsxs("div",{className:"relative z-10 lg:z-[50]",children:[t.jsx(hr,{label:e("workOrders.detail.technicalDepartment"),doctype:"Issue Type",value:De.work_order_type||"",onChange:ni,disabled:!et}),_t.length>0&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:e("workOrders.detail.supervisorsAvailableForType",{count:_t.length})})]}),De.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:De.custom_civil_work_category||"",onChange:ds,disabled:!et,required:!0,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:De.custom_type,onChange:Ul,disabled:!et,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-10 lg:z-[40]",children:(()=>{const se=Te({},l$);return De.company&&(se.company=De.company),De.custom_building&&(se.custom_building=De.custom_building),De.department&&(se.department=De.department),De.custom_room_no&&(se.custom_room_number=De.custom_room_no),t.jsxs(t.Fragment,{children:[t.jsx(hr,{label:e("workOrders.detail.assetId"),doctype:"Asset",value:De.asset||"",onChange:Vi,disabled:!et||ft||!!De.asset,filters:se}),De.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"}),et&&t.jsx("button",{type:"button",onClick:()=>Vi(""),className:"text-xs text-red-500 hover:text-red-700 underline",children:"Clear Asset"})]}),!De.asset&&(De.custom_building||De.department||De.custom_room_no)&&le>0&&t.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:[le," asset(s) available for selected location"]})]})})()}),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.serialNo")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",name:"serial_number",value:De.serial_number,onChange:ds,onBlur:On,disabled:!et||ft,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"}),et&&t.jsx("button",{type:"button",onClick:oo,disabled:ft||!De.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(In,{size:14})})]})]}),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.localId")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",name:"custom_local_id",value:De.custom_local_id||"",onChange:ds,onBlur:lo,disabled:!et||ft,placeholder:e("workOrders.detail.enterLocalId"),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"}),et&&t.jsx("button",{type:"button",onClick:Eo,disabled:ft||!De.custom_local_id,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.searchAssetByLocalId"),children:t.jsx(In,{size:14})})]})]}),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:De.asset_name,onChange:ds,disabled:!et,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(hr,{label:e("workOrders.detail.extensionNo"),doctype:"Extension Directory",value:De.custom_extension_no||"",onChange:se=>wr(Ke(Te({},De),{custom_extension_no:se})),disabled:!et,allowQuickCreate:xl})}),t.jsxs("div",{children:[t.jsx(hr,{label:e("workOrders.detail.building"),doctype:"Building",value:De.custom_building||"",onChange:Bl,disabled:!et,allowQuickCreate:yt}),!De.custom_building&&et&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:e("workOrders.detail.selectBuildingFirst")})]}),Qn()&&t.jsxs("div",{children:[t.jsx(hr,{label:e("workOrders.detail.departmentName"),doctype:"Department",value:De.department||"",onChange:$i,disabled:!et,filters:fr.length>0?{name:["in",fr]}:rs,allowQuickCreate:yt}),De.custom_building&&fr.length===0&&!he&&t.jsx("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:"No departments mapped to this building"}),De.custom_building&&fr.length>0&&t.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:[fr.length," department(s) available for this building"]}),!De.department&&De.custom_building&&et&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:"Select Department to enable Room No"})]}),Bn()&&t.jsxs("div",{children:[t.jsx(hr,{label:e("workOrders.detail.roomNo"),doctype:"Room",value:De.custom_room_no||"",onChange:yc,disabled:!et,query:"asset_lite.api.room_filter.get_filtered_rooms",filters:(()=>{const se={};return De.custom_building&&(se.building=De.custom_building),De.department&&(se.department=De.department),se})(),allowQuickCreate:yt}),he&&t.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400 flex items-center gap-1",children:[t.jsx(Ir,{className:"animate-spin",size:10}),"Loading..."]}),!he&&(De.custom_building||De.department)&&Re.length===0&&t.jsxs("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:["No rooms mapped to ",De.custom_building&&De.department?"this building + department":De.custom_building?"this building":"this department"]}),!he&&(De.custom_building||De.department)&&Re.length>0&&t.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:[Re.length," room(s) available",De.custom_building&&!De.department&&" (filtered by building)",!De.custom_building&&De.department&&" (filtered by department)",De.custom_building&&De.department&&" (filtered by building + department)"]}),!De.custom_room_no&&De.department&&et&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:"Select Room No to enable Location"})]}),So()&&t.jsxs("div",{children:[t.jsx(hr,{label:e("workOrders.detail.location"),doctype:"Location",value:De.custom_location||"",onChange:se=>wr(Ke(Te({},De),{custom_location:se})),disabled:!et,allowQuickCreate:yt}),he&&t.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400 flex items-center gap-1",children:[t.jsx(Ir,{className:"animate-spin",size:10}),"Loading location data..."]}),(De.custom_building||De.department)&&De.custom_room_no&&De.custom_location&&t.jsx("p",{className:"mt-1 text-xs text-green-600 dark:text-green-400",children:"✓ Location auto-set from Infrastructure mapping"})]}),De.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:De.inspection}),t.jsxs("button",{type:"button",onClick:()=>a(`/inspections/${De.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(ps,{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"}),De.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($m,{className:"text-blue-500 flex-shrink-0",size:16}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("a",{href:`${Or.BASE_URL}${De.custom_attachment}`,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 dark:text-blue-400 hover:underline truncate block",children:xi(De.custom_attachment)})}),et&&t.jsx("button",{type:"button",onClick:yl,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(Pt,{size:12})})]}):et?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:[ne?t.jsxs(t.Fragment,{children:[t.jsx(Ir,{className:"animate-spin",size:14}),t.jsx("span",{className:"text-sm",children:e("workOrders.detail.uploading")})]}):t.jsxs(t.Fragment,{children:[t.jsx(Gm,{size:14}),t.jsx("span",{className:"text-sm",children:e("workOrders.detail.uploadOpeningFile")})]}),t.jsx("input",{type:"file",onChange:vc,disabled:ne,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(tn)&&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")}),De.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($m,{className:"text-green-500 flex-shrink-0",size:16}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("a",{href:`${Or.BASE_URL}${De.custom_attachment_on_close}`,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 dark:text-blue-400 hover:underline truncate block",children:xi(De.custom_attachment_on_close)})}),et&&t.jsx("button",{type:"button",onClick:()=>{wr(se=>Ke(Te({},se),{custom_attachment_on_close:""})),Mt.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(Pt,{size:12})})]}):et?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:[ne?t.jsxs(t.Fragment,{children:[t.jsx(Ir,{className:"animate-spin",size:14}),t.jsx("span",{className:"text-sm",children:e("workOrders.detail.uploading")})]}):t.jsxs(t.Fragment,{children:[t.jsx(Gm,{size:14}),t.jsx("span",{className:"text-sm",children:e("workOrders.detail.uploadClosingFile")})]}),t.jsx("input",{type:"file",onChange:se=>me(null,null,function*(){var ht,ur;const Ee=(ht=se.target.files)==null?void 0:ht[0];if(!Ee)return;const Ue=10*1024*1024;if(Ee.size>Ue){Mt.error(e("workOrders.detail.fileSizeExceeds"),{position:"top-right",autoClose:4e3,icon:t.jsx(Br,{})});return}_e(!0);try{const tr=new FormData;tr.append("file",Ee),tr.append("is_private","0"),tr.append("folder","Home/Attachments"),!u&&r&&(tr.append("doctype","Work_Order"),tr.append("docname",r));const Ar=Or.BASE_URL||"",La=yield(yield fetch(`${Ar}/api/method/upload_file`,{method:"POST",credentials:"include",body:tr})).json();if((ur=La.message)!=null&&ur.file_url)wr(Dr=>Ke(Te({},Dr),{custom_attachment_on_close:La.message.file_url})),Mt.success(e("workOrders.detail.closingAttachmentUploadedSuccessfully"),{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})});else throw new Error("Upload failed")}catch(tr){console.error("File upload error:",tr),Mt.error(e("workOrders.detail.failedToUploadClosingAttachment"),{position:"top-right",autoClose:4e3,icon:t.jsx(Br,{})})}finally{_e(!1),se.target.value=""}}),disabled:ne,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")})]}),!Cn&&t.jsxs(t.Fragment,{children:[t.jsx("div",{children:t.jsx(hr,{label:e("workOrders.detail.manufacturer"),doctype:"Manufacturer",value:De.manufacturer||"",onChange:se=>wr(Ke(Te({},De),{manufacturer:se})),disabled:!et})}),t.jsx("div",{children:t.jsx(hr,{label:e("workOrders.detail.supplier"),doctype:"Supplier",value:De.supplier||"",onChange:se=>wr(Ke(Te({},De),{supplier:se})),disabled:!et})}),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:De.model,onChange:ds,disabled:!et,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:u||h?e("workOrders.detail.autoGenerated"):Z==null?void 0:Z.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:De.custom_priority_,onChange:Ul,disabled:!et,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:De.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:De.custom_pending_reason||"",onChange:se=>{const Ee=se.target.value;wr(Ue=>Ke(Te({},Ue),{custom_pending_reason:Ee,custom_reason:Ee==="Other"?Ue.custom_reason:""}))},disabled:!et,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"})]})]}),De.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:De.custom_reason||"",onChange:ds,disabled:!et,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"})]})]})]}),!Cn&&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:De.custom_site_contractor,onChange:ds,disabled:!et,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:De.custom_subcontractor,onChange:ds,disabled:!et,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:De.custom_service_agreement||"",onChange:ds,disabled:!et,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:De.custom_service_coverage||"",onChange:ds,disabled:!et,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:De.custom_start_date||"",onChange:ds,disabled:!et,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:De.custom_end_date||"",onChange:ds,disabled:!et,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:De.custom_total_amount||0,onChange:ds,disabled:!et,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.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:De.description,onChange:ds,disabled:!et||!u&&!(tn==="Draft"&&O===(Z==null?void 0:Z.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:De.actions_performed,onChange:ds,disabled:!et,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(hr,{label:e("workOrders.detail.assignedSupervisor"),doctype:"User",value:De.custom_assigned_supervisor||"",onChange:pi,disabled:!et,filters:_t.length>0?{name:["in",_t]}:{}}),!De.work_order_type&&et&&t.jsx("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:e("workOrders.detail.selectWoTypeFirstForSupervisors")}),De.work_order_type&&_t.length===0&&et&&t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:e("workOrders.detail.noSupervisorsFound")}),!u&&yi&&t.jsx("p",{className:"mt-1 text-xs text-red-500",children:e("workOrders.detail.requiredForExistingWO")})]}),t.jsxs("div",{children:[t.jsx(hr,{label:e("workOrders.detail.assignedEngineer"),doctype:"User",value:De.custom_assigned_engineer||"",onChange:se=>wr(Ke(Te({},De),{custom_assigned_engineer:se})),disabled:!et,filters:rr.length>0?{name:["in",rr]}:{}}),!De.work_order_type&&et&&t.jsx("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:e("workOrders.detail.selectWoTypeFirstForEngineers")}),De.work_order_type&&rr.length===0&&et&&t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:e("workOrders.detail.noEngineersFound")}),rr.length>0&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:e("workOrders.detail.engineersAvailable",{count:rr.length})}),!u&&yi&&t.jsx("p",{className:"mt-1 text-xs text-red-500",children:e("workOrders.detail.requiredForExistingWO")})]}),t.jsxs("div",{children:[t.jsx(hr,{label:e("workOrders.detail.assignedTechnician"),doctype:"User",value:De.assigned_technician||"",onChange:se=>wr(Ke(Te({},De),{assigned_technician:se})),disabled:!et,filters:pr.length>0?{name:["in",pr]}:{}}),!De.work_order_type&&et&&t.jsx("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:e("workOrders.detail.selectWoTypeFirstForTechnicians")}),De.work_order_type&&pr.length===0&&et&&t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:e("workOrders.detail.noTechniciansFoundForType")}),pr.length>0&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:e("workOrders.detail.techniciansAvailable",{count:pr.length})}),!u&&yi&&tn==="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:De.failure_date,onChange:co,disabled:!et,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"}),et&&t.jsxs("button",{type:"button",onClick:Di,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(Ja,{size:12}),"Now"]})]}),De.failure_date&&t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:Tl(D0(De.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:De.custom_deadline_date,onChange:ds,disabled:!et,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"}),et&&De.failure_date&&t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:P()})]}),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:De.total_hours_spent||0,onChange:ds,disabled:!et,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:De.first_responded_on,onChange:To,disabled:!et,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"}),et&&t.jsxs("button",{type:"button",onClick:Wn,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(Ja,{size:12}),"Now"]})]}),De.first_responded_on&&t.jsxs("p",{className:"mt-1 text-xs text-green-600 dark:text-green-400",children:["✓ ",Tl(D0(De.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:De.completion_date,onChange:Rs,disabled:!et,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"}),et&&t.jsxs("button",{type:"button",onClick:si,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(Ja,{size:12}),"Now"]})]}),De.completion_date&&t.jsxs("p",{className:"mt-1 text-xs text-purple-600 dark:text-purple-400",children:["✓ ",Tl(D0(De.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:De.custom_travel_hour,onChange:ds,disabled:!et,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:De.stock_consumption===1,onChange:se=>{var Ee;wr(Ke(Te({},De),{stock_consumption:se.target.checked?1:0,stock_items:se.target.checked?(Ee=De.stock_items)!=null&&Ee.length?De.stock_items:[{item_code:"",warehouse:mn,consumed_quantity:1,valuation_rate:0,custom_available_stock:0,total_value:0}]:[]}))},disabled:!et,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"})]}),De.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"}),et&&t.jsxs("button",{type:"button",onClick:()=>{wr(Ke(Te({},De),{stock_items:[...De.stock_items||[],{item_code:"",warehouse:mn,consumed_quantity:1,valuation_rate:0,custom_available_stock:0,total_value:0}]})),Mt.info(e("workOrders.detail.newStockItemRowAdded"),{position:"top-right",autoClose:2e3,icon:t.jsx(Js,{})})},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(Js,{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")}),et&&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:(De.stock_items||[]).length===0?t.jsx("tr",{children:t.jsxs("td",{colSpan:et?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")}),et&&t.jsx("button",{type:"button",onClick:()=>{wr(Ke(Te({},De),{stock_items:[{item_code:"",warehouse:mn,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")})]})}):(De.stock_items||[]).map((se,Ee)=>t.jsxs(ea.Fragment,{children:[t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 ${Co[Ee]?"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:Ee+1}),t.jsx("td",{className:"px-3 py-3 relative",style:{zIndex:50-Ee},children:t.jsx("div",{className:"relative",children:t.jsx(hr,{label:"",doctype:"Item",value:se.item_code,onChange:Ue=>pc(Ee,Ue),disabled:!et,placeholder:e("workOrders.detail.selectItem"),compact:!0,usePortal:!0,filters:Te(Te({is_stock_item:1},De.company?{custom_hospital_name:De.company}:{}),De.work_order_type?{custom_technical_department:De.work_order_type}:{})})})}),t.jsx("td",{className:"px-3 py-3",children:t.jsx("input",{type:"number",min:"0",step:"0.01",value:se.valuation_rate||0,onChange:Ue=>{const ht=[...De.stock_items||[]],ur=parseFloat(Ue.target.value)||0,tr=ht[Ee].consumed_quantity||0;ht[Ee]=Ke(Te({},ht[Ee]),{valuation_rate:ur,total_value:ur*tr}),wr(Ke(Te({},De),{stock_items:ht}))},disabled:!et,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-Ee},children:t.jsx("div",{className:"relative",children:t.jsx(hr,{label:"",doctype:"Warehouse",value:se.warehouse,onChange:Ue=>pl(Ee,Ue),disabled:!et,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:se.consumed_quantity||1,onChange:Ue=>Ko(Ee,parseInt(Ue.target.value)||1),disabled:!et,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 ${Co[Ee]?"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:se.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:se.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"})}),et&&t.jsx("td",{className:"px-3 py-3 text-center",children:t.jsx("button",{type:"button",onClick:()=>{var ur;const Ue=(ur=De.stock_items)==null?void 0:ur[Ee],ht=(De.stock_items||[]).filter((tr,Ar)=>Ar!==Ee);wr(Ke(Te({},De),{stock_items:ht})),Gt(tr=>{const Ar=Te({},tr);return delete Ar[Ee],Ar}),Mt.warning(e("workOrders.detail.stockItemRemoved",{item:(Ue==null?void 0:Ue.item_code)||"row"}),{position:"top-right",autoClose:2e3,icon:t.jsx(la,{})})},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(la,{size:14})})})]}),Co[Ee]&&t.jsx("tr",{className:"bg-red-50 dark:bg-red-900/30",children:t.jsx("td",{colSpan:et?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(Jr,{}),t.jsx("span",{children:Co[Ee]})]})})})]},Ee))})]})})}),(De.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:(De.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:(De.stock_items||[]).reduce((se,Ee)=>se+(Number(Ee.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:(De.stock_items||[]).reduce((se,Ee)=>se+(Number(Ee.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:De.total_repair_cost||0,onChange:ds,disabled:!et,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"})]})})})]}),!u&&t.jsx(Kd,{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:[!u&&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 ${Ne.bg} ${Ne.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 ${Ne.text}`,children:tn})]}),es&&t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400 mb-4",children:[t.jsx(Ir,{className:"animate-spin"}),t.jsx("span",{className:"text-sm",children:e("workOrders.detail.loadingActions")})]}),ga&&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(Jr,{className:"text-red-500 mt-0.5"}),t.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:ga})]})}),Je&&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(Jr,{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:Je.action})})]})]}),Je.action==="Reject"&&t.jsxs("div",{className:"mb-3",children:[t.jsxs("label",{className:"block text-xs font-medium text-red-700 dark:text-red-300 mb-1",children:["Reject Reason ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("textarea",{value:Xe,onChange:se=>Rt(se.target.value),placeholder:f==="Pending Approval"?"Enter reason for rejection as Engineer...":"Enter reason for rejection as Supervisor...",rows:3,className:"w-full px-3 py-2 text-sm border border-red-300 dark:border-red-600 rounded-md focus:outline-none focus:ring-2 focus:ring-red-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white resize-none"}),!Xe.trim()&&t.jsxs("p",{className:"mt-1 text-xs text-red-600 dark:text-red-400 flex items-center gap-1",children:[t.jsx(Jr,{size:10}),"Please enter a reject reason before confirming rejection."]})]}),t.jsxs("div",{className:"flex gap-2",children:[Je.action!=="Reject"||Xe.trim()?t.jsx("button",{onClick:()=>ii(Je.action,Je.nextState),disabled:ei,className:"px-3 py-1.5 bg-red-600 hover:bg-red-700 text-white text-sm rounded-md disabled:opacity-50",children:ei?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(Ir,{className:"animate-spin",size:12}),e("workOrders.detail.processing")]}):e("workOrders.detail.yesAction",{action:Je.action})}):t.jsxs("button",{disabled:!0,className:"px-3 py-1.5 bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 text-sm rounded-md cursor-not-allowed opacity-60",title:"Enter a reject reason first",children:["Yes, ",Je.action]}),t.jsx("button",{onClick:()=>{Ve(null),Rt("")},disabled:ei,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")})]})]}),!es&&ri.length>0&&!Je&&t.jsxs("div",{className:"space-y-3",children:[ti&&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")})}),et&&ri.some(se=>se.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(il,{className:"inline mr-1",size:10}),e("workOrders.detail.saveToSeeActions")]})}),(()=>{const se=et?ri.filter(Ee=>Ee.action==="Apply"):ri;return se.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(il,{size:12}),e("workOrders.detail.availableActions")," (",se.length,")"]}),t.jsx("div",{className:"flex flex-col gap-2",children:se.map((Ee,Ue)=>t.jsxs("button",{onClick:()=>ii(Ee.action,Ee.next_state),disabled:ei,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 ${Zo(Ee.action)}`,children:[ei?t.jsx(Ir,{className:"animate-spin",size:14}):t.jsx("span",{children:Pa(Ee.action)}),Ee.action]},`${Ee.action}-${Ee.next_state}-${Ue}`))})]})})(),(()=>{const se=et?ri.filter(Ee=>Ee.action==="Apply"):ri;return se.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")}),se.map((Ee,Ue)=>t.jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-300",children:[Ee.action," → ",t.jsx("span",{className:"font-medium",children:Ee.next_state})]},Ue))]})})()]}),!u&&!es&&tn==="Sent to Engineer"&&(()=>{const se=!!(De.assigned_technician||Z!=null&&Z.assigned_technician),Ee=!!(De.actions_performed||(Z==null?void 0:Z.actions_performed)||"").trim();return se&&Ee?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(Tr,{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")})]})]})}):se&&!Ee?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(il,{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(Tr,{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:De.assigned_technician||(Z==null?void 0:Z.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(Jr,{size:10,className:"mt-0.5 flex-shrink-0"}),t.jsx("span",{children:e("workOrders.detail.fillTechnicalReportToUnlock")})]})]})]})]})}):!se&&Ee?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(il,{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(Tr,{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(Jr,{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(il,{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(Jr,{size:10}),'Fill "Technical Report" field to enable "Send to Supervisor" button']})]})]})]})})})(),!u&&!es&&tn==="Repair InProgress"&&(E.includes("Technician")||E.includes("Contractor Engineer"))&&((De.actions_performed||(Z==null?void 0:Z.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(Tr,{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(Jr,{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(Jr,{size:10}),'Please fill the "Technical Report" field to enable "Send For Approval" button']})]})]})]})})),!es&&ge&&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(il,{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:ge.includes("WO Type has been changed")?"Technical Dept Changed":tn==="Sent to Engineer"?"Choose Your Path":tn==="Repair InProgress"?"Action Required":"Apply Action Unavailable"}),t.jsx("p",{className:"text-xs text-orange-600 dark:text-orange-400 mt-1",children:ge}),!ge.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."})]})]})}),!es&&ri.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)"})]})]}),!u&&["Approved","Closed"].includes((Z==null?void 0:Z.workflow_state)||De.workflow_state||"")&&r&&t.jsx(n$,{workOrder: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-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")}),!u&&Z&&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:Z.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:Z.creation?Tl(Z.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:Z.modified?Tl(Z.modified):"-"})]}),Z.custom_engineer_reject_reason&&t.jsxs("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:[t.jsxs("p",{className:"text-xs text-red-500 dark:text-red-400 mb-1 font-medium flex items-center gap-1",children:[t.jsx(Br,{size:10}),"Engineer Rejection Reason"]}),t.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:Z.custom_engineer_reject_reason})]}),Z.custom_supervisor_reject_reason&&t.jsxs("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:[t.jsxs("p",{className:"text-xs text-red-500 dark:text-red-400 mb-1 font-medium flex items-center gap-1",children:[t.jsx(Br,{size:10}),"Supervisor Rejection Reason"]}),t.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:Z.custom_supervisor_reject_reason})]})]}),u&&t.jsxs("div",{className:"text-center py-8",children:[t.jsx(il,{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")})]})]}),!u&&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:()=>Ft(!Wt),children:[t.jsx(Id,{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")}),at.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:at.length})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),ua(),Mt.info(e("workOrders.detail.activityLogRefreshed"),{position:"top-right",autoClose:1500,icon:t.jsx(Ui,{})})},disabled:tt,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(Ui,{className:`${tt?"animate-spin":""}`,size:12})}),t.jsx("button",{type:"button",onClick:()=>Ft(!Wt),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:Wt?t.jsx(Mn,{size:14}):t.jsx(on,{size:14})})]})]}),Wt&&t.jsxs("div",{className:"p-4",children:[tt&&t.jsxs("div",{className:"flex items-center justify-center py-8",children:[t.jsx(Ir,{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")})]}),!tt&&at.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")})})]}),(Z==null?void 0:Z.creation)&&(Z==null?void 0:Z.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(Yn,{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:Ae(Z.owner)})]}),t.jsxs("div",{className:"flex items-center gap-1 text-xs text-gray-500 dark:text-gray-400",children:[t.jsx(Ja,{size:10}),t.jsx("span",{title:Tl(Z.creation),children:je(Z.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(Tr,{size:10}),"Created this Work Order"]})})]})]})]}),!tt&&at.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:(Zt?at:at.slice(0,5)).map((se,Ee)=>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 ${Ee===0?"bg-blue-500":"bg-gray-300 dark:bg-gray-600"}`}),t.jsxs("div",{className:`p-3 rounded-lg ${Ee===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(Yn,{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:Ae(se.owner)})]}),t.jsxs("div",{className:"flex items-center gap-1 text-xs text-gray-500 dark:text-gray-400",children:[t.jsx(Ja,{size:10}),t.jsx("span",{title:Tl(se.creation),children:je(se.creation)})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[se.changes.length>0?se.changes.map((Ue,ht)=>t.jsxs("div",{className:"text-xs",children:[t.jsx("span",{className:`font-medium ${Ge(Ue.field)}`,children:H(Ue.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:de(Ue.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:de(Ue.newValue)})]},ht)):t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 italic",children:e("workOrders.detail.documentUpdated")}),se.added&&se.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")})," ",se.added.length," ",e("workOrders.detail.items")]}),se.removed&&se.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")})," ",se.removed.length," ",e("workOrders.detail.items")]}),se.rowChanged&&se.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")})," ",se.rowChanged.length," ",e("workOrders.detail.rows")]})]})]})]},se.name))}),at.length>5&&t.jsx("div",{className:"mt-4 text-center",children:t.jsx("button",{type:"button",onClick:()=>br(!Zt),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:Zt?t.jsxs(t.Fragment,{children:[t.jsx(Mn,{size:10}),e("workOrders.detail.showLess")]}):t.jsxs(t.Fragment,{children:[t.jsx(on,{size:10}),e("workOrders.detail.showAll")," (",at.length," ",e("workOrders.detail.entries"),")"]})})}),(Z==null?void 0:Z.creation)&&(Z==null?void 0:Z.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(Yn,{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:Ae(Z.owner)})]}),t.jsxs("div",{className:"flex items-center gap-1 text-xs text-gray-500 dark:text-gray-400",children:[t.jsx(Ja,{size:10}),t.jsx("span",{title:new Date(Z.creation).toLocaleString(),children:je(Z.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(Tr,{size:10}),"Created this Work Order"]})})]})]})]})]})]}),!u&&((Z==null?void 0:Z.docstatus)===0||(Z==null?void 0:Z.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(rd,{doctype:"Work_Order",docname:r,currentDeleteStatus:(At=Z==null?void 0:Z.custom_delete_status)!=null?At:null,userRoles:E,isSystemManager:ti,redirectOnDelete:"/work-orders",onStatusChange:se=>me(null,null,function*(){if(Ye.current=!0,Yt(se),se===""&&(De.custom_assigned_engineer||(Z==null?void 0:Z.custom_assigned_engineer)||"")&&r)try{yield rt(r,{workflow_state:"Sent to Engineer"}),Mt.success('Delete request rejected — work order returned to "Sent to Engineer".',{position:"top-right",autoClose:4e3,icon:t.jsx(Tr,{})})}catch(Ue){const ht=Ue instanceof Error?Ue.message:"Unknown error";Mt.error(`Failed to revert workflow state: ${ht}`,{position:"top-right",autoClose:5e3,icon:t.jsx(Br,{})})}Be()})})]})]})]})}),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;
}
`})]})},u$={docstatus:1,custom_delete_status:["!=","Deleted"]},f$=()=>{const{t:e}=Rr(),r=Na(),[a,s]=_.useState(0),[n,i]=_.useState(""),[c]=Sn(),[u,h]=_.useState(""),[g,y]=_.useState(null),[w,E]=_.useState(null),[S,A]=_.useState(!1),C=_.useRef(null),O=20,[M,R]=_.useState(()=>c.get("asset")||""),[F,z]=_.useState(""),[W,X]=_.useState(""),[B,Y]=_.useState(""),[G,ie]=_.useState(""),[fe,K]=_.useState(""),[ke,ge]=_.useState(""),[re,we]=_.useState(""),[ee,ve]=_.useState(""),[ce,ye]=_.useState(""),[te,q]=_.useState(!1),[J,ae]=_.useState(null),[,oe]=_.useState(!1),[le,be]=_.useState(()=>!!c.get("asset")),[Z,Le]=_.useState(""),[Pe,Be]=_.useState(""),[pe,rt]=_.useState(null);_.useEffect(()=>{h(c.get("status")||""),Le(c.get("expertise")||""),Be(c.get("assignee")||""),R(c.get("asset")||""),c.get("asset")&&be(!0);const Nt=c.get("asset_type")||"";we(Nt);const Cr=c.get("year"),yr=c.get("month");if(Cr&&yr){const jt=parseInt(Cr,10),Tt=parseInt(yr,10),He=new Date(jt,Tt,0).getDate(),Fe=String(Tt).padStart(2,"0");ve(`${jt}-${Fe}-01`),ye(`${jt}-${Fe}-${String(He).padStart(2,"0")}`)}else{const jt=c.get("due_date_start")||"",Tt=c.get("due_date_end")||"";ve(jt),ye(Tt)}s(0)},[c]),_.useEffect(()=>{me(null,null,function*(){var Cr;try{const Tt=(yield(yield fetch("/api/method/frappe.auth.get_logged_user",{headers:{"X-Frappe-CSRF-Token":window.csrf_token||""},credentials:"include"})).json()).message;if(!Tt)return;const Fe=yield(yield fetch(`/api/resource/User/${encodeURIComponent(Tt)}?fields=["role_profile_name"]`,{headers:{"X-Frappe-CSRF-Token":window.csrf_token||""},credentials:"include"})).json();((Cr=Fe==null?void 0:Fe.data)==null?void 0:Cr.role_profile_name)==="Technician"&&(ie(Tt),q(!0),s(0))}catch(yr){console.error("Failed to check role_profile_name for assignee auto-set",yr)}})},[]),_.useEffect(()=>{me(null,null,function*(){try{const jt=(yield(yield fetch("/api/method/frappe.auth.get_logged_user",{headers:{"X-Frappe-CSRF-Token":window.csrf_token||""},credentials:"include"})).json()).message;if(!jt){ae(null),oe(!0);return}const Tt=new URLSearchParams({doctype:"User Permission",fields:JSON.stringify(["for_value"]),filters:JSON.stringify([["user","=",jt],["allow","=","Issue Type"]]),limit_page_length:"0"}),Ze=((yield(yield fetch(`/api/method/frappe.client.get_list?${Tt}`,{headers:{"X-Frappe-CSRF-Token":window.csrf_token||""},credentials:"include"})).json()).message||[]).map(ir=>ir.for_value).filter(Boolean),vt=[...new Set(Ze)];vt.length>0?(ae(vt),Y(vt[0])):ae(null)}catch(Cr){console.error("Failed to load user permissions for Issue Type",Cr),ae(null)}finally{oe(!0)}})},[]);const[ct,et]=_.useState("");_.useEffect(()=>{const Nt=setTimeout(()=>{et(fe),s(0)},500);return()=>clearTimeout(Nt)},[fe]);const It=_.useMemo(()=>{const Nt={};return u&&u!=="Pending"&&(Nt.maintenance_status=u),te&&G?Nt.task_assignee_email=G:(Pe&&(Nt.assign_to_name=Pe),G&&(Nt.task_assignee_email=G)),M&&(Nt.asset_name=M),F&&(Nt.custom_building=F),W&&(Nt.custom_department=W),re&&(Nt.custom_asset_type=re),ee&&ce?Nt.due_date=["between",[ee,ce]]:ee?Nt.due_date=[">=",ee]:ce&&(Nt.due_date=["<=",ce]),B&&(Nt.custom_technical_department=B),ke&&(Nt.name=["like",`%${ke}%`]),ct&&(Nt.custom_asset_names=["like",`%${ct}%`]),Nt},[u,Pe,te,M,F,W,B,G,ke,re,ee,ce,ct]),ft=Pe?500:O,Lt=Pe?0:a*O,{logs:Je,totalCount:Ve,hasMore:Xe,loading:Rt,error:qe,refetch:Dt}=Fg(It,ft,Lt,"due_date asc"),{deleteLog:ar,loading:yt}=aS();_.useEffect(()=>{const Nt=Cr=>{C.current&&!C.current.contains(Cr.target)&&E(null)};return w&&document.addEventListener("mousedown",Nt),()=>{document.removeEventListener("mousedown",Nt)}},[w]);const St=()=>{r("/maintenance/new")},Ot=Nt=>{r(`/maintenance/${Nt}`)},Yt=Nt=>{r(`/maintenance/${Nt}`)},Ye=Nt=>me(null,null,function*(){try{yield ar(Nt),y(null),Dt(),alert(e("maintenance.deletedSuccessfully"))}catch(Cr){alert(`Failed to delete: ${Cr instanceof Error?Cr.message:"Unknown error"}`)}}),wt=Nt=>{r(`/maintenance/new?duplicate=${Nt}`)},zt=Nt=>{const Cr=JSON.stringify(Nt,null,2),yr=new Blob([Cr],{type:"application/json"}),jt=URL.createObjectURL(yr),Tt=document.createElement("a");Tt.href=jt,Tt.download=`maintenance_${Nt.name}.json`,Tt.click(),URL.revokeObjectURL(jt)},qt=Nt=>{window.open(`/maintenance/${Nt}?print=true`,"_blank")},kt=[ke,M,F,W,B,u,G,fe,re,ee,ce].filter(Boolean).length,ze=kt>0,nt=()=>{ge(""),R(""),z(""),X(""),Y(""),h(""),te||ie(""),K(""),we(""),ve(""),ye(""),s(0)},_t=_.useCallback(()=>me(null,null,function*(){const Nt=[];let Cr=0;const yr=100;let jt=!0,Tt=0;const He=100;for(;jt;){const Ze=yield Fl.getMaintenanceLogs(It,void 0,yr,Cr,"due_date asc");if(Nt.push(...Ze.asset_maintenance_logs),jt=Ze.has_more,Cr+=yr,Tt++,Tt>He){console.warn("Export safety limit reached");break}}const Fe=n.trim().toLowerCase();return Fe?Nt.filter(Ze=>{var vt,ir,fr;return((vt=Ze.name)==null?void 0:vt.toLowerCase().includes(Fe))||((ir=Ze.asset_name)==null?void 0:ir.toLowerCase().includes(Fe))||((fr=Ze.task_name)==null?void 0:fr.toLowerCase().includes(Fe))}):Nt}),[It,n]),lr=_.useMemo(()=>["name","asset_name","task_name","maintenance_type","maintenance_status","due_date","assign_to_name","workflow_state","custom_hospital_name","creation"],[]),pr=Nt=>{switch(Nt==null?void 0:Nt.toLowerCase()){case"completed":return t.jsx(Tr,{className:"text-green-500"});case"planned":return t.jsx(cy,{className:"text-blue-500"});case"overdue":return t.jsx(Jr,{className:"text-red-500"});default:return t.jsx(Ja,{className:"text-gray-400"})}},Nr=Nt=>{switch(Nt==null?void 0:Nt.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"}},rr=(Nt,Cr)=>!Nt||(Cr==null?void 0:Cr.toLowerCase())==="completed"?!1:new Date(Nt)<new Date;if(Rt&&a===0&&!Pe&&!u)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(qe)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:Dt,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:"})," ",qe]})})]})});const _r=Je.filter(Nt=>{var He,Fe,Ze;const Cr=((He=Nt.name)==null?void 0:He.toLowerCase().includes(n.toLowerCase()))||((Fe=Nt.asset_name)==null?void 0:Fe.toLowerCase().includes(n.toLowerCase()))||((Ze=Nt.task_name)==null?void 0:Ze.toLowerCase().includes(n.toLowerCase())),yr=!Z||pe===null||pe.includes(Nt.asset_maintenance||""),jt=!Pe||(Nt.assign_to_name||"").toLowerCase().includes(Pe.toLowerCase()),Tt=u?u==="Overdue"?Nt.maintenance_status==="Overdue":u==="Pending"?Nt.maintenance_status==="Planned":!0:!0;return Cr&&yr&&jt&&Tt});return t.jsxs("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen w-full min-w-0 overflow-x-hidden",children:[t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center w-full min-w-0",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-gray-800 dark:text-white break-words",children:e("maintenance.title")}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:e("maintenance.listTotal",{count:Z?_r.length:Ve})})]}),t.jsxs("div",{className:"flex flex-col gap-2 w-full sm:flex-row sm:flex-wrap sm:justify-end sm:gap-3 sm:w-auto min-w-0 shrink-0",children:[t.jsxs("button",{type:"button",onClick:()=>be(!le),className:`px-4 py-3 border rounded-lg flex items-center justify-center gap-2 transition-colors w-full sm:w-auto ${ze?"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 bg-white dark:bg-gray-800"}`,children:[t.jsx(Hs,{}),t.jsx("span",{className:"font-medium",children:e("maintenanceCalendarPage.filters")}),kt>0&&t.jsx("span",{className:"bg-blue-600 text-white rounded-full w-5 h-5 flex items-center justify-center text-xs",children:kt}),le?t.jsx(Mn,{size:12}):t.jsx(on,{size:12})]}),t.jsxs("button",{type:"button",onClick:()=>A(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-3 rounded-lg flex items-center justify-center gap-2 shadow transition-all disabled:opacity-50 w-full sm:w-auto",disabled:Je.length===0,children:[t.jsx(Ks,{}),t.jsx("span",{className:"font-medium",children:e("listPages.export")})]}),t.jsxs("button",{type:"button",onClick:St,className:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-lg flex items-center justify-center gap-2 shadow-lg transition-all hover:shadow-xl w-full sm:w-auto",children:[t.jsx(Js,{}),t.jsx("span",{className:"font-medium",children:e("maintenance.addMaintenance")})]})]})]}),le&&t.jsxs("div",{className:"mb-6 p-3 md:p-4 bg-gray-50 dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 shadow",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-10 lg:z-[46]",children:[t.jsx("label",{className:"block text-[11px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("PM Work Order ID")}),t.jsx("input",{type:"text",value:ke,onChange:Nt=>ge(Nt.target.value),placeholder:e("Search by ID"),className:"w-full px-2 py-1 text-xs 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"}),ge&&t.jsx("button",{onClick:()=>ge(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[49]",children:[t.jsx(hr,{label:e("Asset ID"),doctype:"Asset",value:M,onChange:Nt=>{R(Nt),s(0)},placeholder:e("All Assets"),compact:!0,usePortal:!0,filters:u$}),M&&t.jsx("button",{onClick:()=>{R(""),s(0)},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 z-10",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[47]",children:[t.jsx(hr,{label:e("Building"),doctype:"Building",value:F,onChange:Nt=>{z(Nt),s(0)},placeholder:e("All Buildings"),compact:!0,usePortal:!0}),F&&t.jsx("button",{onClick:()=>{z(""),s(0)},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 z-10",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[55]",children:[t.jsx(hr,{label:e("maintenanceCalendarPage.department"),doctype:"Department",value:W,onChange:Nt=>{X(Nt),s(0)},placeholder:e("maintenanceCalendarPage.allDepartments"),compact:!0,usePortal:!0}),W&&t.jsx("button",{onClick:()=>{X(""),s(0)},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 z-10",children:t.jsx(Pt,{size:10})})]}),t.jsx("div",{className:"relative z-10 lg:z-[54]",children:J&&J.length>0?t.jsxs(t.Fragment,{children:[t.jsx("label",{className:"block text-[11px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("Technical Department")}),t.jsx("select",{value:B,onChange:Nt=>{Y(Nt.target.value),s(0)},className:"w-full px-2 py-1 text-xs 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",children:J.map(Nt=>t.jsx("option",{value:Nt,children:Nt},Nt))})]}):t.jsxs(t.Fragment,{children:[t.jsx(hr,{label:e("Technical Department"),doctype:"Issue Type",value:B,onChange:Nt=>{Y(Nt),s(0)},placeholder:e("All Technical Departments"),compact:!0,clearable:!1,usePortal:!0}),B&&t.jsx("button",{onClick:()=>{Y(""),s(0)},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 z-10",children:t.jsx(Pt,{size:10})})]})}),t.jsxs("div",{className:"relative z-10 lg:z-[50]",children:[t.jsx("label",{className:"block text-[11px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("maintenanceCalendarPage.status")}),t.jsxs("select",{value:u,onChange:Nt=>{h(Nt.target.value),s(0)},className:"w-full px-2 py-1 text-xs 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",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")})]}),u&&t.jsx("button",{onClick:()=>{h(""),s(0)},className:"absolute right-7 top-6 text-gray-400 hover:text-red-500",children:t.jsx(Pt,{size:10})})]}),t.jsx("div",{className:"relative z-10 lg:z-[50]",children:te?t.jsxs(t.Fragment,{children:[t.jsx("label",{className:"block text-[11px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("maintenanceCalendarPage.assignedTo")}),t.jsx("input",{type:"text",value:G,disabled:!0,className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400 cursor-not-allowed"})]}):t.jsxs(t.Fragment,{children:[t.jsx(hr,{label:e("maintenanceCalendarPage.assignedTo"),doctype:"User",value:G,onChange:Nt=>{ie(Nt),s(0)},placeholder:e("maintenanceCalendarPage.allTechnicians"),compact:!0,usePortal:!0}),G&&t.jsx("button",{onClick:()=>{ie(""),s(0)},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 z-10",children:t.jsx(Pt,{size:10})})]})}),t.jsxs("div",{className:"relative z-10 lg:z-[48]",children:[t.jsx("label",{className:"block text-[11px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("Asset Name")}),t.jsx("input",{type:"text",value:fe,onChange:Nt=>K(Nt.target.value),placeholder:e("All Assets"),className:"w-full px-2 py-1 text-xs 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"}),fe&&t.jsx("button",{onClick:()=>{K(""),s(0)},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 z-10",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[45]",children:[t.jsx(hr,{label:e("Asset Type"),doctype:"Asset Type",value:re,onChange:Nt=>{we(Nt),s(0)},placeholder:e("All Asset Types"),compact:!0,usePortal:!0}),re&&t.jsx("button",{onClick:()=>{we(""),s(0)},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 z-10",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[44]",children:[t.jsx("label",{className:"block text-[11px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("Due Date From")}),t.jsx("input",{type:"date",value:ee,onChange:Nt=>{const Cr=Nt.target.value;ve(Cr),ce&&Cr>ce&&ye(Cr),s(0)},className:"w-full px-2 py-1 text-xs 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"}),ee&&t.jsx("button",{onClick:()=>{ve(""),s(0)},className:"absolute right-7 top-6 text-gray-400 hover:text-red-500 z-10",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[43]",children:[t.jsx("label",{className:"block text-[11px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("Due Date To")}),t.jsx("input",{type:"date",value:ce,min:ee||void 0,onChange:Nt=>{ye(Nt.target.value),s(0)},className:"w-full px-2 py-1 text-xs 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"}),ce&&t.jsx("button",{onClick:()=>{ye(""),s(0)},className:"absolute right-7 top-6 text-gray-400 hover:text-red-500 z-10",children:t.jsx(Pt,{size:10})})]})]}),ze&&t.jsx("div",{className:"mt-3 flex justify-end",children:t.jsxs("button",{onClick:nt,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(Pt,{}),e("maintenanceCalendarPage.clearFilters")]})})]}),Z&&t.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[t.jsx("span",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400",children:"Filtered by:"}),t.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-medium bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 px-3 py-1 rounded-full",children:["Department: ",Z,t.jsx("button",{type:"button",onClick:()=>Le(""),className:"ml-1 hover:text-purple-900 dark:hover:text-purple-100",children:"×"})]})]}),Pe&&t.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[t.jsx("span",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400",children:"Filtered by:"}),t.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-medium bg-indigo-100 dark:bg-indigo-900/30 text-indigo-700 dark:text-indigo-300 px-3 py-1 rounded-full",children:["Assignee: ",Pe,t.jsx("button",{type:"button",onClick:()=>Be(""),className:"ml-1 hover:text-indigo-900 dark:hover:text-indigo-100",children:"×"})]})]}),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:"PM Work Order ID"}),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:_r.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(In,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("listPages.noMaintenanceLogsFound")}),t.jsx("button",{onClick:St,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:e("listPages.createFirstMaintenanceLog")})]})})}):_r.map(Nt=>{const Cr=rr(Nt.due_date||"",Nt.maintenance_status||"");return t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${Cr?"bg-red-50 dark:bg-red-900/10":""}`,onClick:()=>Ot(Nt.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:Nt.name}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:Nt.creation?new Date(Nt.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:Nt.asset_name||"-"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:Nt.custom_asset_type||""})]}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:Nt.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:Nt.due_date?new Date(Nt.due_date).toLocaleDateString():"-"}),Cr&&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:[pr(Nt.maintenance_status||""),t.jsx("span",{className:`px-3 py-1 inline-flex text-xs leading-5 font-semibold rounded-full ${Nr(Nt.maintenance_status||"")}`,children:Nt.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:yr=>yr.stopPropagation(),children:[t.jsx("button",{onClick:()=>Ot(Nt.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(to,{})}),t.jsx("button",{onClick:()=>Yt(Nt.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(Ms,{})}),t.jsx("button",{onClick:()=>wt(Nt.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(tu,{})}),t.jsx("button",{onClick:()=>y(Nt.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:yt,children:t.jsx(la,{})}),t.jsxs("div",{className:"relative",ref:w===Nt.name?C:null,children:[t.jsx("button",{onClick:()=>E(w===Nt.name?null:Nt.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(Wf,{})}),w===Nt.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:()=>{zt(Nt),E(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(Vo,{className:"text-blue-500"}),"Export as JSON"]}),t.jsxs("button",{onClick:()=>{qt(Nt.name),E(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(Go,{className:"text-purple-500"}),"Print Log"]})]})]})]})})]},Nt.name)})})]})}),_r.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*O+1})," to"," ",t.jsx("span",{className:"font-medium",children:Math.min((a+1)*O,Ve)})," ","of ",t.jsx("span",{className:"font-medium",children:Ve})," 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:!Xe,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"})]})]})]}),t.jsx(ob,{isOpen:S,onClose:()=>A(!1),doctype:"Asset Maintenance Log",selectedCount:0,pageCount:_r.length,totalCount:Ve,pageData:_r,onFetchAll:_t,fileNamePrefix:"asset_maintenance_logs",defaultColumns:lr,hiddenColumns:["docstatus","idx","amended_from","naming_series","custom_table"]}),g&&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(la,{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:"})," ",g]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>y(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:yt,children:"Cancel"}),t.jsx("button",{onClick:()=>Ye(g),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:yt,children:yt?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(la,{}),"Delete Log"]})})]})]})]})})})]})},o4=Xt,h$="Asset Maintenance Log",m$="PM log";function g$(e){if(Array.isArray(e))return e;if(!e||typeof e!="object")return[];const r=e;return Array.isArray(r.data)?r.data:Array.isArray(r.message)?r.message:[]}function mS(e,r){var a;return{name:e.name,idx:e.idx||r+1,maintenance_name:String((a=e.maintenance_name)!=null?a:""),working:e.working===1||e.working===!0?1:0,defect_found:e.defect_found===1||e.defect_found===!0?1:0,not_working:e.not_working===1||e.not_working===!0?1:0,remarks:e.remarks!=null?String(e.remarks):""}}function x$(e,r){return me(this,null,function*(){const a=JSON.stringify([["parent","=",r],["parenttype","=","Asset Maintenance Log"]]),s=JSON.stringify(["name","idx","maintenance_name","working","defect_found","not_working","remarks"]),i=`/api/resource/${encodeURIComponent("PPM Table")}?filters=${encodeURIComponent(a)}&fields=${encodeURIComponent(s)}&limit_page_length=500&order_by=${encodeURIComponent("idx asc")}`;try{const c=yield e.apiCall(i);return g$(c).map((u,h)=>mS(u,h))}catch(c){return[]}})}function R0(e){return e===1||e===!0?"Yes":""}function p$(e){return e==null?"":typeof e=="boolean"?e?"Yes":"No":Array.isArray(e)||typeof e=="object"&&e!==null?JSON.stringify(e):String(e)}const y$=new Set(["docstatus","idx","amended_from","naming_series","custom_table","custom_template","custom_asset_type","item_code","item_name"]);function b$(e){const r=String(e);return r.includes(",")||r.includes('"')||r.includes(`
`)||r.includes("\r")?`"${r.replace(/"/g,'""')}"`:r}function v$(e,r){const a=e.map(c=>c.map(b$).join(",")).join(`
`),s=new Blob(["\uFEFF"+a],{type:"text/csv;charset=utf-8;"}),n=URL.createObjectURL(s),i=document.createElement("a");i.href=n,i.download=r,i.click(),URL.revokeObjectURL(n)}const w$=({message:e,type:r,onClose:a})=>{_.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(Jr,{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(Pt,{})})]})})},_$=()=>{const{t:e}=Rr(),{logName:r}=ml(),a=Na(),[s]=Sn(),n=s.get("duplicate"),i=r==="new",c=i&&!!n,{log:u,loading:h,error:g}=_H(c?n:i?null:r||null),{createLog:y,updateLog:w,loading:E}=aS(),{fields:S,loading:A}=ib("Asset Maintenance Log"),C=_.useMemo(()=>S.filter(Ve=>!y$.has(Ve.key)),[S]),O=(u==null?void 0:u.workflow_state)==="Approved",[M,R]=_.useState(i),[F,z]=_.useState([]),[W,X]=_.useState(null),[B,Y]=_.useState(!1),[G,ie]=_.useState(!1),[fe,K]=_.useState("excel"),[ke,ge]=_.useState(!1),[re,we]=_.useState(new Set),[ee,ve]=_.useState(""),[ce,ye]=_.useState(!0),te=_.useRef(!1),[q,J]=_.useState({asset_name:"",custom_asset_type:"",custom_building:"",custom_department:"",custom_room:"",custom_location:"",custom_technical_department:"",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:""});_.useEffect(()=>{if(!G){te.current=!1,we(new Set),ve("");return}C.length===0||te.current||(te.current=!0,we(new Set(C.filter(Ve=>Ve.default).map(Ve=>Ve.key))))},[G,C]);const ae=_.useCallback((Ve,Xe,Rt)=>{if(Rt!=="Completed"){J(yt=>Ke(Te({},yt),{custom_early_completion:""}));return}if(!Ve||!Xe)return;const qe=new Date(Ve),Dt=new Date(Xe),ar=new Date(qe.getFullYear(),qe.getMonth(),1);if(Dt<ar){J(Ot=>Ke(Te({},Ot),{custom_early_completion:"Yes"}));const yt=Dt.toLocaleDateString(),St=qe.toLocaleDateString();X({message:`⚠️ Warning: Completion Date (${yt}) is before the Due Date Month (${St}). Please verify.`,type:"warning"})}},[]),oe=_.useCallback(Ve=>me(null,null,function*(){var Xe;if(Ve){Y(!0);try{const Rt=yield o4.apiCall(`/api/resource/PPM Templates/${encodeURIComponent(Ve)}`,"GET");if((Xe=Rt==null?void 0:Rt.data)!=null&&Xe.ppm_template_table&&Array.isArray(Rt.data.ppm_template_table)){const qe=Rt.data.ppm_template_table.map((Dt,ar)=>({idx:ar+1,maintenance_name:Dt.maintenance_name||"",working:0,defect_found:0,not_working:0,remarks:Dt.remarks||""}));z(qe)}}catch(Rt){console.error("Error loading PPM template:",Rt),X({message:"Failed to load PPM template. Please add items manually.",type:"error"})}finally{Y(!1)}}}),[]);_.useEffect(()=>{u&&(u.workflow_state==="Approved"&&R(!1),J({asset_name:u.asset_name||"",custom_asset_type:u.custom_asset_type||"",custom_building:u.custom_building||"",custom_department:u.custom_department||"",custom_room:u.custom_room||"",custom_location:u.custom_location||"",custom_technical_department:u.custom_technical_department||"",item_code:u.item_code||"",item_name:u.item_name||"",custom_asset_names:u.custom_asset_names||"",custom_hospital_name:u.custom_hospital_name||"",task:u.task||"",task_name:u.task_name||"",maintenance_type:u.maintenance_type||"Preventive Maintenance",periodicity:u.periodicity||"",has_certificate:u.has_certificate||0,custom_early_completion:c?"":u.custom_early_completion||"",maintenance_status:c?"Planned":u.maintenance_status||"Planned",custom_accepted_by_moh:u.custom_accepted_by_moh||0,assign_to_name:u.assign_to_name||"",due_date:u.due_date||"",completion_date:c?"":u.completion_date||"",custom_early_completion_reason:c?"":u.custom_early_completion_reason||"",custom_accepted_by_moh_:u.custom_accepted_by_moh_||0,custom_template:u.custom_template||"",custom_table:u.custom_table||[],description:u.description||""}),u.custom_table&&Array.isArray(u.custom_table)&&u.custom_table.length>0?z(u.custom_table.map((Ve,Xe)=>({name:Ve.name,idx:Ve.idx||Xe+1,maintenance_name:Ve.maintenance_name||"",working:Ve.working||0,defect_found:Ve.defect_found||0,not_working:Ve.not_working||0,remarks:Ve.remarks||""}))):u.custom_template&&(!u.custom_table||u.custom_table.length===0)&&oe(u.custom_template))},[u,c,oe]),_.useEffect(()=>{q.completion_date&&q.due_date&&ae(q.due_date,q.completion_date,q.maintenance_status)},[q.completion_date,q.due_date,q.maintenance_status,ae]);const le=Ve=>{const{name:Xe,value:Rt,type:qe}=Ve.target,Dt=Ve.target.checked;J(ar=>Ke(Te({},ar),{[Xe]:qe==="checkbox"?Dt?1:0:Rt}))},be=Ve=>{const Xe=Ve.target.value;J(Rt=>Ke(Te({},Rt),{maintenance_status:Xe})),Xe==="Completed"?ae(q.due_date||"",q.completion_date||"",Xe):J(Rt=>Ke(Te({},Rt),{custom_early_completion:""}))},Z=Ve=>{const Xe=Ve.target.value;J(Rt=>Ke(Te({},Rt),{completion_date:Xe})),q.maintenance_status==="Completed"&&ae(q.due_date||"",Xe,q.maintenance_status)},Le=()=>{const Ve={idx:F.length+1,maintenance_name:"",working:0,defect_found:0,not_working:0,remarks:""};z([...F,Ve])},Pe=Ve=>{const Xe=F.filter((Rt,qe)=>qe!==Ve).map((Rt,qe)=>Ke(Te({},Rt),{idx:qe+1}));z(Xe)},Be=(Ve,Xe,Rt)=>{const qe=[...F];qe[Ve]=Ke(Te({},qe[Ve]),{[Xe]:Rt}),z(qe)},pe=Ve=>me(null,null,function*(){if(Ve.preventDefault(),!q.asset_name){alert("Please enter Asset Name");return}if(!q.maintenance_type){alert("Please select Maintenance Type");return}const Xe=F.map((qe,Dt)=>{const ar={idx:qe.idx||Dt+1,maintenance_name:qe.maintenance_name||"",working:qe.working?1:0,defect_found:qe.defect_found?1:0,not_working:qe.not_working?1:0,remarks:qe.remarks||""};return qe.name&&typeof qe.name=="string"&&qe.name.trim()!==""&&(ar.name=qe.name),ar}),Rt=Ke(Te({},q),{custom_table:Xe});console.log("Submitting maintenance log data:",Rt);try{if(i||c){const qe=yield y(Rt);alert(c?"Maintenance log duplicated successfully!":"Maintenance log created successfully!"),a(`/maintenance/${qe.name}`)}else r&&(yield w(r,Rt),alert("Maintenance log updated successfully!"),R(!1))}catch(qe){console.error("Maintenance log save error:",qe),alert("Failed to save: "+(qe instanceof Error?qe.message:"Unknown error"))}}),rt=Ve=>({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"})[Ve]||"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",ct=Ve=>({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"})[Ve]||"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",et=_.useCallback(Ve=>me(null,null,function*(){let Xe=F.length>0?[...F]:[];return Xe.length===0&&(Xe=yield x$(o4,Ve)),Xe.length===0&&(u!=null&&u.custom_table)&&Array.isArray(u.custom_table)&&(Xe=u.custom_table.map((Rt,qe)=>mS(Rt,qe))),Xe}),[u,F]),It=_.useCallback((Ve,Xe,Rt)=>me(null,null,function*(){const qe=(u==null?void 0:u.name)||(r&&r!=="new"?r:"");if(!qe){alert("Save the maintenance log before exporting.");return}if(Xe.size===0&&!Rt){alert("Select at least one field or include the PPM checklist.");return}const Dt=yield et(qe),ar=Te(Te({},u||{}),q),yt=C.filter(qt=>Xe.has(qt.key)),St=yt.map(qt=>qt.label),Ot=yt.map(qt=>p$(ar[qt.key])),Yt=qe.replace(/[^\w.-]+/g,"_"),Ye=new Date().toISOString().split("T")[0],wt=`maintenance_log_details_${Yt}_${Ye}`;if(Ve==="excel"){const qt=Ur.book_new();if(yt.length>0){const kt=Ur.aoa_to_sheet([St,Ot]);Ur.book_append_sheet(qt,kt,"Details")}if(Rt){const kt=["#","Maintenance task","Working","Defect","N/W","Remarks"],ze=Dt.length===0?[["—","No checklist rows","","","",""]]:Dt.map((_t,lr)=>{var pr;return[(pr=_t.idx)!=null?pr:lr+1,(_t.maintenance_name||"").trim()||"—",R0(_t.working),R0(_t.defect_found),R0(_t.not_working),(_t.remarks||"").trim()||"—"]}),nt=Ur.aoa_to_sheet([kt,...ze]);Ur.book_append_sheet(qt,nt,"PPM checklist")}jo(qt,`${wt}.xlsx`);return}const zt=[];yt.length>0&&zt.push(St,Ot),Rt&&(zt.length>0&&zt.push([]),zt.push(["PPM checklist"]),zt.push(["#","Maintenance task","Working","Defect","N/W","Remarks"]),Dt.length===0?zt.push(["—","No checklist rows","","","",""]):Dt.forEach((qt,kt)=>{var ze;zt.push([(ze=qt.idx)!=null?ze:kt+1,(qt.maintenance_name||"").trim()||"—",R0(qt.working),R0(qt.defect_found),R0(qt.not_working),(qt.remarks||"").trim()||"—"])})),v$(zt,`${wt}.csv`)}),[u,r,q,et,C]),ft=_.useCallback(()=>{const Ve=(u==null?void 0:u.name)||(r&&r!=="new"?r:"");if(!Ve){alert("Save the maintenance log before printing.");return}const Xe=Or.BASE_URL,Rt=new URLSearchParams({doctype:h$,name:Ve,format:m$,no_letterhead:"1",_lang:"en"}),qe=`${Xe}/printview?${Rt.toString()}`;window.open(qe,"_blank")||alert("Please allow pop-ups to open the print view.")},[u,r]),Lt=_.useMemo(()=>{const Ve=ee.trim().toLowerCase();return Ve?C.filter(Xe=>Xe.label.toLowerCase().includes(Ve)||Xe.key.toLowerCase().includes(Ve)):C},[C,ee]),Je=re.size>0||ce;return h?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..."})]})}):g&&!i&&!c?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: ",g]}),t.jsx("button",{onClick:()=>a("/maintenance"),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:[W&&t.jsx(w$,{message:W.message,type:W.type,onClose:()=>X(null)}),G&&(u==null?void 0:u.name)&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",role:"dialog","aria-modal":"true","aria-labelledby":"aml-export-title",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 overflow-hidden animate-scale-in",children:[t.jsxs("div",{className:"bg-gradient-to-r from-green-500 to-green-600 px-6 py-4 flex items-center justify-between flex-shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(Ks,{className:"text-white text-xl flex-shrink-0"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{id:"aml-export-title",className:"text-lg font-semibold text-white truncate",children:"Export PM Work Order Details"}),t.jsxs("p",{className:"text-green-100 text-xs mt-0.5",children:[C.length," fields available · ",re.size," selected"]})]})]}),t.jsx("button",{type:"button",onClick:()=>!ke&&ie(!1),className:"text-white/80 hover:text-white transition-colors flex-shrink-0 ml-2",disabled:ke,"aria-label":"Close",children:t.jsx(Pt,{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:"File format"}),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 ${fe==="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:"aml_export_format",checked:fe==="csv",onChange:()=>K("csv"),className:"text-green-600 focus:ring-green-500"}),t.jsx(No,{className:"text-green-600 text-xl flex-shrink-0"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-sm text-gray-900 dark:text-white",children:"CSV"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Universal format"})]})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${fe==="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:"aml_export_format",checked:fe==="excel",onChange:()=>K("excel"),className:"text-green-600 focus:ring-green-500"}),t.jsx(zi,{className:"text-green-700 text-xl flex-shrink-0"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-sm text-gray-900 dark:text-white",children:"Excel (.xlsx)"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Native workbook"})]})]})]})]}),t.jsxs("label",{className:"flex items-start gap-3 p-3 rounded-lg border border-gray-200 dark:border-gray-700 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",children:[t.jsx("input",{type:"checkbox",checked:ce,onChange:Ve=>ye(Ve.target.checked),className:"mt-0.5 text-green-600 focus:ring-green-500 rounded"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-sm text-gray-900 dark:text-white",children:"Include PPM checklist"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Adds a second sheet in Excel (or a following section in CSV), same rows as print view."})]})]}),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",A&&t.jsx(Ir,{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",{type:"button",onClick:()=>we(new Set(C.map(Ve=>Ve.key))),className:"hover:underline",children:"All"}),t.jsx("button",{type:"button",onClick:()=>we(new Set(C.filter(Ve=>Ve.default).map(Ve=>Ve.key))),className:"hover:underline",children:"Default"}),t.jsx("button",{type:"button",onClick:()=>we(new Set),className:"hover:underline",children:"None"})]})]}),t.jsxs("div",{className:"relative mb-2",children:[t.jsx(In,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400",size:12}),t.jsx("input",{type:"text",value:ee,onChange:Ve=>ve(Ve.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"}),ee&&t.jsx("button",{type:"button",onClick:()=>ve(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:t.jsx(Pt,{size:10})})]}),A?t.jsxs("div",{className:"flex items-center justify-center h-24 text-gray-400 text-sm gap-2",children:[t.jsx(Ir,{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:[Lt.map(Ve=>{const Xe=re.has(Ve.key);return t.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{we(Rt=>{const qe=new Set(Rt);return qe.has(Ve.key)?qe.delete(Ve.key):qe.add(Ve.key),qe})},onKeyDown:Rt=>{(Rt.key==="Enter"||Rt.key===" ")&&(Rt.preventDefault(),we(qe=>{const Dt=new Set(qe);return Dt.has(Ve.key)?Dt.delete(Ve.key):Dt.add(Ve.key),Dt}))},className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-all text-xs select-none ${Xe?"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:Xe?t.jsx(jn,{size:13,className:"text-green-600"}):t.jsx(ys,{size:13,className:"text-gray-300 dark:text-gray-600"})}),t.jsx("span",{className:"truncate",title:`${Ve.label} (${Ve.key})`,children:Ve.label})]},Ve.key)}),Lt.length===0&&t.jsxs("p",{className:"col-span-3 text-center text-gray-400 text-xs py-4",children:['No fields match "',ee,'"']})]}),t.jsxs("p",{className:"text-xs text-gray-400 mt-1.5",children:[re.size," of ",C.length," fields selected",ee&&` · showing ${Lt.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 flex justify-between items-center gap-3",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Exporting 1 document"}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{type:"button",onClick:()=>!ke&&ie(!1),disabled:ke,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",{type:"button",disabled:ke||!Je,onClick:()=>{me(null,null,function*(){ge(!0);try{yield It(fe,re,ce),ie(!1)}catch(Ve){console.error(Ve),alert(`Export failed: ${Ve instanceof Error?Ve.message:"Unknown error"}`)}finally{ge(!1)}})},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:ke?t.jsxs(t.Fragment,{children:[t.jsx(Ir,{className:"animate-spin",size:14}),"Exporting…"]}):t.jsxs(t.Fragment,{children:[t.jsx(Vo,{size:14}),e("listPages.export")]})})]})]})]})}),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("/maintenance"),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(Kn,{}),t.jsx("span",{className:"text-gray-900 dark:text-white font-semibold",children:c?"Duplicate PM Work Order":i?"New PM Work Order":"PM Work Order Details"})]}),!i&&(u==null?void 0:u.workflow_state)&&t.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-medium ${rt(u.workflow_state)}`,children:u.workflow_state})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[!i&&(u==null?void 0:u.name)&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:()=>ie(!0),className:"bg-green-600 hover:bg-green-700 text-white px-5 py-2 rounded-lg flex items-center gap-2 text-sm font-medium shadow-sm",children:[t.jsx(Ks,{}),t.jsx("span",{className:"font-medium",children:e("listPages.export")})]}),t.jsxs("button",{type:"button",onClick:ft,className:"bg-slate-700 hover:bg-slate-800 text-white px-5 py-2 rounded-lg flex items-center gap-2 text-sm font-medium shadow-sm",children:[t.jsx(Go,{}),"Print"]})]}),!i&&!M&&!O&&t.jsxs("button",{onClick:()=>R(!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(Ms,{}),"Edit"]}),M&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{i?a("/maintenance"):R(!1)},className:"bg-gray-300 hover:bg-gray-400 text-gray-700 px-6 py-2 rounded-lg",disabled:E,children:"Cancel"}),t.jsxs("button",{onClick:pe,disabled:E,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(bs,{}),E?"Saving...":"Save Changes"]})]})]})]}),t.jsx("form",{onSubmit:pe,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:"PM Work Order ID"}),t.jsx("input",{type:"text",value:i||c?"Auto-generated":(u==null?void 0:u.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"}),c&&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:q.custom_hospital_name||"",onChange:le,disabled:!M,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 ID ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",name:"asset_name",value:q.asset_name,onChange:le,required:!0,disabled:!M,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 name"}),t.jsx("input",{type:"text",name:"custom_asset_names",value:q.custom_asset_names||"",onChange:le,disabled:!M,placeholder:"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.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Building"}),t.jsx("input",{type:"text",name:"custom_building",value:q.custom_building||"",onChange:le,disabled:!M,placeholder:"Building",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:"Department"}),t.jsx("input",{type:"text",name:"custom_department",value:q.custom_department||"",onChange:le,disabled:!M,placeholder:"Department",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:"Room"}),t.jsx("input",{type:"text",name:"custom_room",value:q.custom_room||"",onChange:le,disabled:!M,placeholder:"Room",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:"Location"}),t.jsx("input",{type:"text",name:"custom_location",value:q.custom_location||"",onChange:le,disabled:!M,placeholder:"Location",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:"Technical Department"}),t.jsx("input",{type:"text",name:"custom_technical_department",value:q.custom_technical_department||"",onChange:le,disabled:!M,placeholder:"Technical Department",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:q.maintenance_type,onChange:le,required:!0,disabled:!M,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:q.periodicity||"",onChange:le,disabled:!M,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:"Weekly",children:"15 Days"}),t.jsx("option",{value:"Monthly",children:"Monthly"}),t.jsx("option",{value:"Quarterly",children:"Quarterly"}),t.jsx("option",{value:"Quarterly",children:"4 Months"}),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-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Status"}),t.jsxs("select",{name:"maintenance_status",value:q.maintenance_status,onChange:be,disabled:!M,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:q.assign_to_name||"",onChange:le,disabled:!M,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:q.due_date||"",onChange:le,disabled:!M,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:q.completion_date||"",onChange:Z,disabled:!M,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",q.custom_early_completion==="Yes"&&t.jsx("span",{className:"ml-2 text-yellow-500",children:"⚠️ Auto-detected"})]}),t.jsx("input",{type:"text",value:q.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"})]}),q.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:q.custom_early_completion_reason||"",onChange:le,disabled:!M,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:!!q.custom_accepted_by_moh,onChange:le,disabled:!M,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(aT,{}),"PPM Checklist Table",B&&t.jsx("span",{className:"text-sm text-blue-500 font-normal",children:"(Loading template...)"})]}),M&&t.jsxs("button",{type:"button",onClick:Le,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(Js,{className:"text-xs"}),"Add Row"]})]}),t.jsx("div",{className:"overflow-x-auto rounded-lg border border-slate-200 dark:border-slate-600 shadow-inner bg-white dark:bg-gray-900/30",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"bg-gradient-to-r from-slate-100 to-slate-50 dark:from-slate-700 dark:to-slate-800 border-b border-slate-200 dark:border-slate-600",children:[t.jsx("th",{className:"text-left py-3 px-3 text-xs font-semibold text-slate-700 dark:text-slate-200 w-12",children:"#"}),t.jsx("th",{className:"text-left py-3 px-3 text-xs font-semibold text-slate-700 dark:text-slate-200",children:"Maintenance Task"}),t.jsx("th",{className:"text-center py-3 px-3 text-xs font-semibold text-emerald-700 dark:text-emerald-300 w-24",children:t.jsxs("div",{className:"flex items-center justify-center gap-1",children:[t.jsx(Z4,{})," Working"]})}),t.jsx("th",{className:"text-center py-3 px-3 text-xs font-semibold text-amber-700 dark:text-amber-300 w-28",children:t.jsxs("div",{className:"flex items-center justify-center gap-1",children:[t.jsx(Jr,{})," Defect"]})}),t.jsx("th",{className:"text-center py-3 px-3 text-xs font-semibold text-rose-700 dark:text-rose-300 w-28",children:t.jsxs("div",{className:"flex items-center justify-center gap-1",children:[t.jsx(Pt,{})," Not Working"]})}),t.jsx("th",{className:"text-left py-3 px-3 text-xs font-semibold text-slate-700 dark:text-slate-200 min-w-[120px]",children:"Remarks"}),M&&t.jsx("th",{className:"text-center py-3 px-3 text-xs font-semibold text-slate-700 dark:text-slate-200 w-16",children:"Action"})]})}),t.jsx("tbody",{children:F.length===0?t.jsx("tr",{children:t.jsxs("td",{colSpan:M?7:6,className:"text-center py-10 text-slate-500 dark:text-slate-400 text-sm",children:["No checklist items. ",M&&'Enter a template name above or click "Add Row" to add items.']})}):F.map((Ve,Xe)=>{var Rt;return t.jsxs("tr",{className:`border-b border-slate-100 dark:border-slate-700/80 transition-colors hover:bg-slate-50/90 dark:hover:bg-slate-700/40 ${Xe%2===1?"bg-slate-50/50 dark:bg-slate-800/25":""}`,children:[t.jsx("td",{className:"py-3 px-3 text-sm text-gray-600 dark:text-gray-400",children:Ve.idx||Xe+1}),t.jsx("td",{className:"py-3 px-3",children:M?t.jsx("input",{type:"text",value:Ve.maintenance_name,onChange:qe=>Be(Xe,"maintenance_name",qe.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:Ve.maintenance_name})}),t.jsx("td",{className:"py-3 px-3 text-center",children:t.jsx("input",{type:"checkbox",checked:!!Ve.working,onChange:qe=>Be(Xe,"working",qe.target.checked?1:0),disabled:!M,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:!!Ve.defect_found,onChange:qe=>Be(Xe,"defect_found",qe.target.checked?1:0),disabled:!M,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:!!Ve.not_working,onChange:qe=>Be(Xe,"not_working",qe.target.checked?1:0),disabled:!M,className:"w-5 h-5 text-red-600 rounded focus:ring-2 focus:ring-red-500 cursor-pointer disabled:cursor-default"})}),t.jsx("td",{className:"py-3 px-3",children:M?t.jsx("input",{type:"text",value:Ve.remarks||"",onChange:qe=>Be(Xe,"remarks",qe.target.value),placeholder:"Remarks",className:"w-full min-w-[100px] 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 whitespace-pre-wrap",children:(Rt=Ve.remarks)!=null&&Rt.trim()?Ve.remarks:"—"})}),M&&t.jsx("td",{className:"py-3 px-3 text-center",children:t.jsx("button",{type:"button",onClick:()=>Pe(Xe),className:"text-red-500 hover:text-red-700 p-1",title:"Remove row",children:t.jsx(la,{})})})]},Ve.name||Xe)})})]})})]})]}),t.jsxs("div",{className:"space-y-6",children:[!i&&u&&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(db,{doctype:"Asset Maintenance Log",docname:u.name||null,workflowState:u.workflow_state,showStateInfo:!1,onActionComplete:(Ve,Xe)=>{Xe&&console.log(`Action "${Ve}" 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&&u?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 ${ct(q.maintenance_status)}`,children:q.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 ${rt(u.workflow_state||"Draft")}`,children:u.workflow_state||"Draft"})]}),q.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:q.due_date?new Date(q.due_date).toLocaleDateString():"Not set"}),q.due_date&&new Date(q.due_date)<new Date&&q.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:q.completion_date?new Date(q.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:q.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:[F.length," item(s)"]}),F.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: ",F.filter(Ve=>Ve.working).length]}),t.jsxs("p",{className:"text-yellow-600 dark:text-yellow-400",children:["⚠ Defects: ",F.filter(Ve=>Ve.defect_found).length]}),t.jsxs("p",{className:"text-red-600 dark:text-red-400",children:["✗ Not Working: ",F.filter(Ve=>Ve.not_working).length]})]})]})]}):t.jsxs("div",{className:"text-center py-8",children:[t.jsx(Ja,{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&&u&&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:u.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:u.creation?new Date(u.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:u.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:u.modified?new Date(u.modified).toLocaleString():"-"})]})]})]})]})]})})]})};class k${getAssetMaintenances(r,a,s=20,n=0,i){return me(this,null,function*(){const c=new URLSearchParams;r&&c.append("filters",JSON.stringify(r)),a&&a.length>0&&c.append("fields",JSON.stringify(a)),c.append("limit",s.toString()),c.append("offset",n.toString()),i&&c.append("order_by",i);const u=`${Or.ENDPOINTS.GET_ASSET_MAINTENANCES}?${c.toString()}`;return Xt.apiCall(u)})}getAssetMaintenanceDetails(r){return me(this,null,function*(){const a=new URLSearchParams;a.append("maintenance_name",r);const s=`${Or.ENDPOINTS.GET_ASSET_MAINTENANCE_DETAILS}?${a.toString()}`;return Xt.apiCall(s)})}createAssetMaintenance(r){return me(this,null,function*(){const a=`${Or.ENDPOINTS.CREATE_ASSET_MAINTENANCE}`;return Xt.apiCall(a,{method:"POST",body:JSON.stringify({maintenance_data:JSON.stringify(r)})})})}updateAssetMaintenance(r,a){return me(this,null,function*(){const s=`${Or.ENDPOINTS.UPDATE_ASSET_MAINTENANCE}`;return Xt.apiCall(s,{method:"POST",body:JSON.stringify({maintenance_name:r,maintenance_data:JSON.stringify(a)})})})}deleteAssetMaintenance(r){return me(this,null,function*(){const a=`${Or.ENDPOINTS.DELETE_ASSET_MAINTENANCE}`;return Xt.apiCall(a,{method:"POST",body:JSON.stringify({maintenance_name:r})})})}getMaintenanceTasks(r){return me(this,null,function*(){const a=new URLSearchParams;a.append("maintenance_name",r);const s=`${Or.ENDPOINTS.GET_MAINTENANCE_TASKS}?${a.toString()}`;return Xt.apiCall(s)})}getServiceCoverage(r){return me(this,null,function*(){const a=new URLSearchParams;a.append("maintenance_name",r);const s=`${Or.ENDPOINTS.GET_SERVICE_COVERAGE}?${a.toString()}`;return Xt.apiCall(s)})}getMaintenancesByAsset(r,a,s=20,n=0){return me(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 c=`${Or.ENDPOINTS.GET_MAINTENANCES_BY_ASSET}?${i.toString()}`;return Xt.apiCall(c)})}getActiveServiceContracts(r,a=20,s=0){return me(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=`${Or.ENDPOINTS.GET_ACTIVE_SERVICE_CONTRACTS}?${n.toString()}`;return Xt.apiCall(i)})}}const wf=new k$;function N$(e,r=20,a=0,s){const[n,i]=_.useState([]),[c,u]=_.useState(0),[h,g]=_.useState(!1),[y,w]=_.useState(!0),[E,S]=_.useState(null),[A,C]=_.useState(0),O=_.useRef(!1),M=JSON.stringify(e);_.useEffect(()=>{if(O.current&&E)return;let F=!1;return O.current=!0,me(null,null,function*(){try{w(!0);const W=yield wf.getAssetMaintenances(e,void 0,r,a,s);F||(i(W.asset_maintenances),u(W.total_count),g(W.has_more),S(null))}catch(W){if(!F){const X=W instanceof Error?W.message:"Failed to fetch PPM schedules";X.includes("417")||X.includes("Expectation Failed")||X.includes("has no attribute")?S("API endpoint not deployed. Please deploy ppm_api.py to your Frappe server."):S(X),i([]),u(0),g(!1)}}finally{F||w(!1)}}),()=>{F=!0}},[M,r,a,s,A]);const R=_.useCallback(()=>{O.current=!1,C(F=>F+1)},[]);return{ppms:n,totalCount:c,hasMore:h,loading:y,error:E,refetch:R}}function j$(e){const[r,a]=_.useState(null),[s,n]=_.useState(!0),[i,c]=_.useState(null),u=_.useCallback(()=>me(null,null,function*(){if(!e){a(null),n(!1);return}try{n(!0),c(null);const g=yield wf.getAssetMaintenanceDetails(e);a(g)}catch(g){c(g instanceof Error?g.message:"Failed to fetch PPM details")}finally{n(!1)}}),[e]);_.useEffect(()=>{u()},[u]);const h=_.useCallback(()=>{u()},[u]);return{ppm:r,loading:s,error:i,refetch:h}}function gS(){const[e,r]=_.useState(!1),[a,s]=_.useState(null),n=_.useCallback(u=>me(null,null,function*(){try{return r(!0),s(null),yield wf.createAssetMaintenance(u)}catch(h){const g=h instanceof Error?h.message:"Failed to create PPM schedule";throw s(g),h}finally{r(!1)}}),[]),i=_.useCallback((u,h)=>me(null,null,function*(){try{return r(!0),s(null),yield wf.updateAssetMaintenance(u,h)}catch(g){const y=g instanceof Error?g.message:"Failed to update PPM schedule";throw s(y),g}finally{r(!1)}}),[]),c=_.useCallback(u=>me(null,null,function*(){try{return r(!0),s(null),yield wf.deleteAssetMaintenance(u)}catch(h){const g=h instanceof Error?h.message:"Failed to delete PPM schedule";throw s(g),h}finally{r(!1)}}),[]);return{createPPM:n,updatePPM:i,deletePPM:c,loading:e,error:a}}const S$=()=>{const{t:e}=Rr(),r=Na(),[a,s]=_.useState(0),[n,i]=_.useState(""),[c,u]=_.useState(""),[h,g]=_.useState(null),[y,w]=_.useState(null),E=_.useRef(null),S=20,A=c?{company:c}:{},{ppms:C,totalCount:O,hasMore:M,loading:R,error:F,refetch:z}=N$(A,S,a*S,"creation desc"),{deletePPM:W,loading:X}=gS();_.useEffect(()=>{const re=we=>{E.current&&!E.current.contains(we.target)&&w(null)};return y&&document.addEventListener("mousedown",re),()=>{document.removeEventListener("mousedown",re)}},[y]);const B=()=>{r("/ppm/new")},Y=re=>{r(`/ppm/${re}`)},G=re=>{r(`/ppm/${re}`)},ie=re=>me(null,null,function*(){try{yield W(re),g(null),z(),alert(e("ppm.deletedSuccessfully"))}catch(we){alert(`Failed to delete: ${we instanceof Error?we.message:"Unknown error"}`)}}),fe=re=>{r(`/ppm/new?duplicate=${re}`)},K=re=>{const we=JSON.stringify(re,null,2),ee=new Blob([we],{type:"application/json"}),ve=URL.createObjectURL(ee),ce=document.createElement("a");ce.href=ve,ce.download=`ppm_${re.name}.json`,ce.click(),URL.revokeObjectURL(ve)},ke=()=>{const we=[["PPM ID","Company","Asset","Asset Type","Frequency","No. of PMs","Total Amount"].join(","),...C.map(ye=>[ye.name,ye.company||"",ye.asset_name||"",ye.custom_asset_type||"",ye.custom_frequency||"",ye.custom_no_of_pms||"",ye.custom_total_amount||""].join(","))].join(`
`),ee=new Blob([we],{type:"text/csv"}),ve=URL.createObjectURL(ee),ce=document.createElement("a");ce.href=ve,ce.download=`ppm_schedules_${new Date().toISOString().split("T")[0]}.csv`,ce.click(),URL.revokeObjectURL(ve)};if(R&&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(F)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:z,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:"})," ",F]})})]})});const ge=C.filter(re=>{var we,ee,ve,ce;return((we=re.name)==null?void 0:we.toLowerCase().includes(n.toLowerCase()))||((ee=re.asset_name)==null?void 0:ee.toLowerCase().includes(n.toLowerCase()))||((ve=re.company)==null?void 0:ve.toLowerCase().includes(n.toLowerCase()))||((ce=re.custom_asset_type)==null?void 0:ce.toLowerCase().includes(n.toLowerCase()))});return t.jsxs("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen w-full min-w-0 overflow-x-hidden",children:[t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center w-full min-w-0",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-gray-800 dark:text-white break-words",children:e("ppm.title")}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:e("ppm.listTotal",{count:O})})]}),t.jsxs("div",{className:"flex flex-col gap-2 w-full sm:flex-row sm:flex-wrap sm:justify-end sm:gap-3 sm:w-auto min-w-0 shrink-0",children:[t.jsxs("button",{type:"button",onClick:ke,className:"bg-green-600 hover:bg-green-700 text-white px-4 py-3 rounded-lg flex items-center justify-center gap-2 shadow transition-all disabled:opacity-50 w-full sm:w-auto",disabled:C.length===0,children:[t.jsx(Ks,{}),t.jsx("span",{className:"font-medium",children:e("listPages.export")})]}),t.jsxs("button",{type:"button",onClick:B,className:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-lg flex items-center justify-center gap-2 shadow-lg transition-all hover:shadow-xl w-full sm:w-auto",children:[t.jsx(Js,{}),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(In,{className:"text-gray-400 dark:text-gray-500"}),t.jsx("input",{type:"text",placeholder:e("ppm.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.jsx("input",{type:"text",placeholder:e("ppm.filterByCompany"),value:c,onChange:re=>{u(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"})})]}),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:ge.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(In,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("ppm.noSchedulesFound")}),t.jsx("button",{onClick:B,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:e("ppm.createFirstSchedule")})]})})}):ge.map(re=>t.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors cursor-pointer",onClick:()=>Y(re.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:re.name})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ly,{className:"text-gray-400"}),t.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:re.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:re.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:re.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(cy,{className:"text-blue-500"}),t.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:re.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:re.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:re.custom_total_amount?`$${re.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:we=>we.stopPropagation(),children:[t.jsx("button",{onClick:()=>w(y===re.name?null:re.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(Wf,{})}),y===re.name&&t.jsxs("div",{ref:E,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:()=>{Y(re.name),w(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(to,{}),e("listPages.view")]}),t.jsxs("button",{onClick:()=>{G(re.name),w(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(Ms,{}),e("listPages.edit")]}),t.jsxs("button",{onClick:()=>{fe(re.name),w(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(tu,{}),e("listPages.duplicate")]}),t.jsxs("button",{onClick:()=>{K(re),w(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(Ks,{}),e("listPages.export")]}),t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700"}),t.jsxs("button",{onClick:()=>{g(re.name),w(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(la,{}),e("listPages.delete")]})]})]})})]},re.name))})]})}),(M||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*S+1,end:Math.min((a+1)*S,O),total:O,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:!M,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")})]})]})]}),h&&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:()=>g(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:()=>ie(h),disabled:X,className:"px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 disabled:opacity-50",children:e(X?"common.deleting":"common.delete")})]})]})})]})},C$=()=>{const{t:e}=Rr(),{ppmName:r}=ml(),a=Na(),[s]=Sn(),n=s.get("duplicate"),i=r==="new",c=i&&!!n,{ppm:u,loading:h,error:g,refetch:y}=j$(c?n:i?null:r||null),{createPPM:w,updatePPM:E,loading:S}=gS(),[A,C]=_.useState(i),[O,M]=_.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});_.useEffect(()=>{u&&M({company:u.company||"",asset_name:u.asset_name||"",custom_asset_type:u.custom_asset_type||"",maintenance_team:u.maintenance_team||"",custom_frequency:u.custom_frequency||"",custom_total_amount:u.custom_total_amount||0,custom_no_of_pms:u.custom_no_of_pms||0,custom_price_per_pm:u.custom_price_per_pm||0})},[u,c]);const R=z=>{const{name:W,value:X}=z.target;M(B=>Ke(Te({},B),{[W]:W.includes("amount")||W.includes("pms")||W.includes("price")?parseFloat(X)||0:X}))},F=z=>me(null,null,function*(){var W;if(z.preventDefault(),!O.asset_name){alert(e("ppm.detail.pleaseEnterAssetName"));return}try{if(i||c){const X=yield w(O),B=e(c?"ppm.detail.duplicatedSuccessfully":"ppm.detail.createdSuccessfully");alert(B),(W=X.asset_maintenance)!=null&&W.name?a(`/ppm/${X.asset_maintenance.name}`):(y(),a(-1))}else r&&(yield E(r,O),alert(e("ppm.detail.updatedSuccessfully")),C(!1),y())}catch(X){console.error("PPM save error:",X),alert(e("ppm.detail.failedToSave")+": "+(X instanceof Error?X.message:"Unknown error"))}});return h?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")})]})}):g&&!i&&!c?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"),": ",g]}),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(Kn,{}),t.jsx("span",{className:"text-gray-900 dark:text-white",children:e(c?"ppm.detail.duplicateSchedule":i?"ppm.detail.newSchedule":"ppm.detail.scheduleDetails")})]})}),t.jsx("div",{className:"flex items-center gap-3",children:!i&&!A&&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(Ms,{}),e("common.edit")]})})]}),t.jsxs("form",{onSubmit:F,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")," *"]}),A?t.jsx("input",{type:"text",name:"company",value:O.company,onChange:R,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:(u==null?void 0:u.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")," *"]}),A?t.jsx("input",{type:"text",name:"asset_name",value:O.asset_name,onChange:R,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:(u==null?void 0:u.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")}),A?t.jsx("input",{type:"text",name:"custom_asset_type",value:O.custom_asset_type,onChange:R,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:(u==null?void 0:u.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")}),A?t.jsx("input",{type:"text",name:"maintenance_team",value:O.maintenance_team,onChange:R,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:(u==null?void 0:u.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")}),A?t.jsx("input",{type:"text",name:"custom_frequency",value:O.custom_frequency,onChange:R,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:(u==null?void 0:u.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")}),A?t.jsx("input",{type:"number",name:"custom_no_of_pms",value:O.custom_no_of_pms,onChange:R,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:(u==null?void 0:u.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")}),A?t.jsx("input",{type:"number",name:"custom_price_per_pm",value:O.custom_price_per_pm,onChange:R,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:u!=null&&u.custom_price_per_pm?`$${u.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")}),A?t.jsx("input",{type:"number",name:"custom_total_amount",value:O.custom_total_amount,onChange:R,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:u!=null&&u.custom_total_amount?`$${u.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&&u&&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:u.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:u.creation?new Date(u.creation).toLocaleString():"-"})]})]}),i&&t.jsxs("div",{className:"text-center py-8",children:[t.jsx(e3,{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")})]})]})})]}),A&&t.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[t.jsx("button",{type:"button",onClick:()=>{i?a(-1):(C(!1),u&&M({company:u.company||"",asset_name:u.asset_name||"",custom_asset_type:u.custom_asset_type||"",maintenance_team:u.maintenance_team||"",custom_frequency:u.custom_frequency||"",custom_total_amount:u.custom_total_amount||0,custom_no_of_pms:u.custom_no_of_pms||0,custom_price_per_pm:u.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:S,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(bs,{}),e(S?"common.saving":i?"common.create":"ppm.detail.saveChanges")]})]})]})]})};class E${submitDocument(r,a){return me(this,null,function*(){try{const s=yield this.fetchWithTimeout(`${Or.BASE_URL}/api/method/asset_lite.api.ppm_generator_api.submit_pm_schedule`,{method:"POST",headers:a,credentials:"include",body:JSON.stringify({pm_schedule_name:r})},6e4);if(s.ok)console.log("✅ Document submitted successfully");else{const n=yield s.text();console.warn("Failed to submit document:",n)}}catch(s){console.warn("Error submitting document:",s.message)}})}fetchWithTimeout(r,a,s=12e4){return me(this,null,function*(){var c,u;const n=new AbortController,i=setTimeout(()=>n.abort(),s);try{const h=yield fetch(r,Ke(Te({},a),{signal:n.signal}));return clearTimeout(i),h}catch(h){throw clearTimeout(i),h.name==="AbortError"?new Error(`Request timeout after ${s}ms. The server may be slow or the request is too large.`):(c=h.message)!=null&&c.includes("Failed to fetch")||(u=h.message)!=null&&u.includes("ERR_CONNECTION_TIMED_OUT")?new Error(`Connection timeout. Please check:
1. Your internet connection
2. Server is accessible
3. Try with fewer assets`):h}})}getFilteredAssets(r){return me(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 Xt.apiCall(`/api/resource/Asset?filters=${encodeURIComponent(s)}&fields=${encodeURIComponent(n)}&limit_page_length=1000`);return(i==null?void 0:i.data)||[]})}createBulkMaintenanceSchedules(r){return me(this,null,function*(){var w,E,S,C,O,M,R,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=r.assets[0],s=((w=r.pm_for)==null?void 0:w.trim())||(a==null?void 0:a.asset_name)||null,n=r.modality||(a==null?void 0:a.custom_modality)||null,i=r.manufacturer||(a==null?void 0:a.custom_manufacturer)||null,c=r.model||(a==null?void 0:a.custom_model)||null,u=((E=r.device_status)==null?void 0:E.trim())||(a==null?void 0:a.custom_device_status)||null,h={doctype:"PM Schedule Generator",hospital:r.hospital,start_date:r.start_date,end_date:r.end_date,periodicity:r.periodicity,asset_name:s,device_status:u,maintenance_team:r.maintenance_team||null,maintenance_manager:r.maintenance_manager||null,assign_to:r.assign_to||null,modality:n,manufacturer:i,model:c,department:r.department||null,maintenance_entries:r.assets.map(z=>({doctype:"PM Entry Line",asset:z.name,asset_name:z.asset_name||null,start_date:r.start_date,end_date:r.end_date,manufacturer:z.custom_manufacturer||null,model:z.custom_model||null}))};console.log("Creating PM Schedule Generator with document:",JSON.stringify(h,null,2));const g=yield Xt.getCSRFToken(),y={"Content-Type":"application/json",Accept:"application/json"};g&&(y["X-Frappe-CSRF-Token"]=g);try{const z=yield this.fetchWithTimeout(`${Or.BASE_URL}/api/method/frappe.client.insert`,{method:"POST",headers:y,credentials:"include",body:JSON.stringify({doc:h})},12e4),W=yield z.text();if(console.log("frappe.client.insert response:",W),!z.ok)throw new Error(`HTTP ${z.status}: ${W}`);const X=JSON.parse(W),B=(S=X==null?void 0:X.message)==null?void 0:S.name;if(B)return console.log("✅ PM Schedule Generator created successfully:",B),yield this.submitDocument(B,y),{success:!0,created:r.assets.length,document:B,message:`PM Schedule Generator "${B}" created and submitted with ${r.assets.length} assets`};throw new Error("No document name in response")}catch(z){console.warn("Method 1 (frappe.client.insert) failed:",z.message);try{const A=h,{doctype:W,maintenance_entries:X}=A,B=Ji(A,["doctype","maintenance_entries"]),Y=Ke(Te({},B),{maintenance_entries:X.map(re=>{var we=re,{doctype:ke}=we,ge=Ji(we,["doctype"]);return ge})});console.log("Trying Resource API with:",JSON.stringify(Y,null,2));const G=yield this.fetchWithTimeout(`${Or.BASE_URL}/api/resource/PM%20Schedule%20Generator`,{method:"POST",headers:y,credentials:"include",body:JSON.stringify(Y)},12e4),ie=yield G.text();if(console.log("Resource API response:",ie),!G.ok)throw new Error(`HTTP ${G.status}: ${ie}`);const fe=JSON.parse(ie),K=(C=fe==null?void 0:fe.data)==null?void 0:C.name;if(K)return console.log("✅ PM Schedule Generator created via Resource API:",K),yield this.submitDocument(K,y),{success:!0,created:r.assets.length,document:K,message:`PM Schedule Generator "${K}" created and submitted with ${r.assets.length} assets`};throw new Error("No document name in response")}catch(W){console.warn("Method 2 (Resource API) failed:",W.message);const X=[];throw(((O=z==null?void 0:z.message)==null?void 0:O.includes("timeout"))||((M=z==null?void 0:z.message)==null?void 0:M.includes("Failed to fetch")))&&(((R=W==null?void 0:W.message)==null?void 0:R.includes("timeout"))||((F=W==null?void 0:W.message)==null?void 0:F.includes("Failed to fetch")))?X.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`):(X.push("Failed to create PM Schedule Generator. Errors:"),z!=null&&z.message&&X.push(`• frappe.client.insert: ${z.message.substring(0,150)}`),W!=null&&W.message&&X.push(`• Resource API: ${W.message.substring(0,150)}`),X.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.
${X.join(`
`)}`)}}})}getFilterOptions(){return me(this,null,function*(){try{const r=yield Xt.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 me(this,null,function*(){try{const r=yield Xt.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 me(this,null,function*(){try{const a=yield Xt.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 Nm=new E$,T$="King Fahad Specialist Hospital - Dammam",A$={docstatus:1,custom_delete_status:["!=","Deleted"]},O$=()=>{const{t:e}=Rr(),r=Na(),[a,s]=_.useState({company:T$}),[n,i]=_.useState([]),[c,u]=_.useState({start_date:"",end_date:"",maintenance_team:"",assign_to:"",pm_for:"",maintenance_manager:"",periodicity:"Monthly",maintenance_type:"Preventive",no_of_pms:"",department:""}),[h,g]=_.useState(!1),[y,w]=_.useState(!1),[E,S]=_.useState([]),[A,C]=_.useState({modalities:[],assetTypes:[],departments:[],locations:[],manufacturers:[],models:[],company:[]}),[O,M]=_.useState([]),[R,F]=_.useState(""),[z,W]=_.useState(null);_.useEffect(()=>{B(),Y()},[]);const X=(ee,ve,ce)=>{if(!ee||!ve||!ce)return null;const ye=parseInt(ce,10);if(isNaN(ye)||ye<1)return null;const te=ye-1;if(te<0)return null;const q=new Date(ee),J=new Date(q);switch(ve){case"Daily":J.setDate(J.getDate()+te);break;case"Weekly":J.setDate(J.getDate()+te*7);break;case"15 Days":J.setDate(J.getDate()+te*15);break;case"Monthly":J.setMonth(J.getMonth()+te);break;case"Quarterly":J.setMonth(J.getMonth()+te*3);break;case"4 Months":J.setMonth(J.getMonth()+te*4);break;case"Half-yearly":J.setMonth(J.getMonth()+te*6);break;case"Yearly":J.setFullYear(J.getFullYear()+te);break;case"2 Yearly":J.setFullYear(J.getFullYear()+te*2);break;case"3 Yearly":J.setFullYear(J.getFullYear()+te*3);break;default:return null}const ae=J.getFullYear(),oe=String(J.getMonth()+1).padStart(2,"0"),le=String(J.getDate()).padStart(2,"0");return`${ae}-${oe}-${le}`};_.useEffect(()=>{me(null,null,function*(){if(c.maintenance_team){const ve=yield Nm.getMaintenanceTeamDetails(c.maintenance_team);ve&&u(ce=>Ke(Te({},ce),{maintenance_manager:ve.maintenance_manager||"",assign_to:ve.team_members&&ve.team_members.length===1?ve.team_members[0]:ce.assign_to}))}else u(ve=>Ke(Te({},ve),{maintenance_manager:"",assign_to:""}))})},[c.maintenance_team]),_.useEffect(()=>{if(c.start_date&&c.periodicity&&c.no_of_pms){const ee=X(c.start_date,c.periodicity,c.no_of_pms);ee&&u(ve=>Ke(Te({},ve),{end_date:ee}))}},[c.start_date,c.periodicity,c.no_of_pms]);const B=()=>me(null,null,function*(){const ee=yield Nm.getFilterOptions();C(ee)}),Y=()=>me(null,null,function*(){const ee=yield Nm.getMaintenanceTeams();M(ee)}),G=()=>me(null,null,function*(){w(!0);try{const ee=new URLSearchParams;a.company&&ee.append("company",a.company),a.custom_modality&&ee.append("custom_modality",a.custom_modality),a.custom_manufacturer&&ee.append("custom_manufacturer",a.custom_manufacturer),a.custom_device_status&&ee.append("custom_device_status",a.custom_device_status),a.custom_model&&ee.append("custom_model",a.custom_model),a.department&&ee.append("department",a.department),a.custom_class&&ee.append("custom_class",a.custom_class),a.custom_site&&ee.append("custom_site",a.custom_site),a.name&&ee.append("name",a.name),a.custom_serial_number&&ee.append("custom_serial_number",a.custom_serial_number),a.custom_room_number&&ee.append("custom_room_number",a.custom_room_number);const ve=yield fetch(`/api/method/get_assets?${ee.toString()}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"});if(!ve.ok)throw new Error(`HTTP error! status: ${ve.status}`);const ye=(yield ve.json()).message||[];S(ye),i([])}catch(ee){console.error("Error fetching assets:",ee),alert("Failed to fetch assets: "+(ee instanceof Error?ee.message:"Unknown error"))}finally{w(!1)}}),ie=(ee,ve)=>{s(ce=>Ke(Te({},ce),{[ee]:ve||void 0}))},fe=ee=>{i(ve=>ve.includes(ee)?ve.filter(ce=>ce!==ee):[...ve,ee])},K=()=>{const ee=ke();n.length===ee.length&&ee.length>0?i([]):i(ee.map(ve=>ve.name))},ke=()=>{if(!R)return E;const ee=R.toLowerCase();return E.filter(ve=>{var ce,ye,te,q,J,ae;return((ce=ve.asset_name)==null?void 0:ce.toLowerCase().includes(ee))||((ye=ve.custom_modality)==null?void 0:ye.toLowerCase().includes(ee))||((te=ve.company)==null?void 0:te.toLowerCase().includes(ee))||((q=ve.custom_manufacturer)==null?void 0:q.toLowerCase().includes(ee))||((J=ve.custom_model)==null?void 0:J.toLowerCase().includes(ee))||((ae=ve.custom_device_status)==null?void 0:ae.toLowerCase().includes(ee))})},ge=()=>me(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(!c.pm_for){alert("Please enter a PM Name");return}if(!c.start_date||!c.end_date){alert("Please select start and end dates");return}if(new Date(c.start_date)>new Date(c.end_date)){alert("Start date must be before end date");return}if(!c.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)?`)){g(!0);try{const ve=E.filter(te=>n.includes(te.name)).map(te=>({name:te.name,asset_name:te.asset_name,custom_modality:te.custom_modality,custom_manufacturer:te.custom_manufacturer,custom_model:te.custom_model,custom_device_status:te.custom_device_status})),ce={assets:ve,start_date:c.start_date,end_date:c.end_date,maintenance_team:c.maintenance_team||void 0,assign_to:c.assign_to||void 0,maintenance_manager:c.maintenance_manager||void 0,periodicity:c.periodicity,maintenance_type:c.maintenance_type,no_of_pms:c.no_of_pms||void 0,pm_for:c.pm_for||void 0,hospital:a.company,modality:a.custom_modality,manufacturer:a.custom_manufacturer,model:a.custom_model,device_status:a.custom_device_status,department:c.department||a.department||void 0};console.log("=== DEBUG: Selected Asset Details ===",ve),console.log("=== DEBUG: bulkData ===",ce);const ye=yield Nm.createBulkMaintenanceSchedules(ce);W({show:!0,document:ye.document,count:ye.created||n.length,type:"pm_schedule"}),i([]),u({start_date:"",end_date:"",maintenance_team:"",assign_to:"",pm_for:"",maintenance_manager:"",periodicity:"Monthly",maintenance_type:"Preventive",no_of_pms:"",department:""})}catch(ve){console.error("Error creating schedules:",ve);const ce=ve instanceof Error?ve.message:"Unknown error";alert(`Failed to create maintenance schedules:
${ce}`)}finally{g(!1)}}}),re=ke(),we=Object.values(a).some(ee=>ee);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(Kn,{}),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(Hs,{})," Filter Assets"]}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[t.jsx("div",{children:t.jsx(hr,{label:"Hospital/Company *",doctype:"Company",value:a.company||"",onChange:ee=>ie("company",ee),placeholder:"Select a hospital/company"})}),t.jsx("div",{children:t.jsx(hr,{label:"Modality",doctype:"Modality",value:a.custom_modality||"",onChange:ee=>ie("custom_modality",ee),placeholder:"Leave empty for all modalities"})}),t.jsx("div",{children:t.jsx(hr,{label:"Manufacturer",doctype:"Manufacturer",value:a.custom_manufacturer||"",onChange:ee=>ie("custom_manufacturer",ee),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:ee=>ie("custom_device_status",ee.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:"Up",children:"Up"}),t.jsx("option",{value:"Down",children:"Down"})]})]}),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:ee=>ie("custom_model",ee.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)"}),A.models.map(ee=>t.jsx("option",{value:ee,children:ee},ee))]})]}),t.jsx("div",{children:t.jsx(hr,{label:"Department",doctype:"Department",value:a.department||"",onChange:ee=>ie("department",ee),placeholder:"Select department (optional)"})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"Class"}),t.jsxs("select",{value:a.custom_class||"",onChange:ee=>ie("custom_class",ee.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 Classes"}),t.jsx("option",{value:"Class A",children:"Class A"}),t.jsx("option",{value:"Class B",children:"Class B"}),t.jsx("option",{value:"Class C",children:"Class C"})]})]}),t.jsx("div",{children:t.jsx(hr,{label:"PHCC Site",doctype:"Mobile Team Site",value:a.custom_site||"",onChange:ee=>ie("custom_site",ee),placeholder:"Select PHCC site (optional)"})}),t.jsx("div",{children:t.jsx(hr,{label:"Asset ID",doctype:"Asset",value:a.name||"",onChange:ee=>ie("name",ee),placeholder:"Search by asset ID (optional)",filters:Te(Te({},A$),a.company?{company:a.company}:{})})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"Serial Number"}),t.jsx("input",{type:"text",value:a.custom_serial_number||"",onChange:ee=>ie("custom_serial_number",ee.target.value),placeholder:"Enter serial number (optional)",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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"Room Number"}),t.jsx("input",{type:"text",value:a.custom_room_number||"",onChange:ee=>ie("custom_room_number",ee.target.value),placeholder:"Enter room number (optional)",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"})]})]}),t.jsxs("div",{className:"mt-4 flex gap-3",children:[t.jsx("button",{onClick:G,disabled:y,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:y?t.jsxs(t.Fragment,{children:[t.jsx(Ir,{className:"animate-spin"}),"Loading..."]}):t.jsxs(t.Fragment,{children:[t.jsx(In,{}),"Fetch Assets"]})}),we&&t.jsx("button",{onClick:()=>{s({}),S([]),i([])},className:"bg-gray-600 hover:bg-gray-700 text-white px-6 py-2 rounded-lg",children:"Clear Filters"})]})]}),E.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 ",E.length," selected)"]}),t.jsxs("div",{className:"flex gap-3 items-center",children:[t.jsxs("div",{className:"relative",children:[t.jsx(In,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"}),t.jsx("input",{type:"text",placeholder:"Search assets...",value:R,onChange:ee=>F(ee.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:K,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===re.length&&re.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===re.length&&re.length>0,onChange:K,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:re.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"})}):re.map(ee=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors ${n.includes(ee.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(ee.name),onChange:()=>fe(ee.name),className:"rounded"})}),t.jsx("td",{className:"p-3 text-sm text-gray-900 dark:text-white font-medium",children:ee.asset_name}),t.jsx("td",{className:"p-3 text-sm text-gray-700 dark:text-gray-300",children:ee.custom_modality||"-"}),t.jsx("td",{className:"p-3 text-sm text-gray-700 dark:text-gray-300",children:ee.custom_manufacturer||"-"}),t.jsx("td",{className:"p-3 text-sm text-gray-700 dark:text-gray-300",children:ee.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 ${ee.custom_device_status==="Active"?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":ee.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:ee.custom_device_status||"-"})})]},ee.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(uf,{})," 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:c.pm_for,onChange:ee=>u(ve=>Ke(Te({},ve),{pm_for:ee.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:c.start_date,onChange:ee=>u(ve=>Ke(Te({},ve),{start_date:ee.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:c.periodicity,onChange:ee=>u(ve=>Ke(Te({},ve),{periodicity:ee.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:"15 Days",children:"15 Days"})," ",t.jsx("option",{value:"Monthly",children:"Monthly"}),t.jsx("option",{value:"Quarterly",children:"Quarterly"}),t.jsx("option",{value:"4 Months",children:"4 Months"})," ",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:c.maintenance_type,onChange:ee=>u(ve=>Ke(Te({},ve),{maintenance_type:ee.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:c.no_of_pms,onChange:ee=>u(ve=>Ke(Te({},ve),{no_of_pms:ee.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:c.end_date,onChange:ee=>u(ve=>Ke(Te({},ve),{end_date:ee.target.value})),min:c.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(hr,{label:"Maintenance Team",doctype:"Asset Maintenance Team",value:c.maintenance_team,onChange:ee=>u(ve=>Ke(Te({},ve),{maintenance_team:ee}))}),c.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:"})," ",c.maintenance_manager]})]}),t.jsxs("div",{children:[t.jsx(hr,{label:"Assign To *",doctype:"User",value:c.assign_to,onChange:ee=>u(ve=>Ke(Te({},ve),{assign_to:ee})),placeholder:c.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"}),c.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:"})," ",c.assign_to]})]}),t.jsx("div",{children:t.jsx(hr,{label:"Department",doctype:"Department",value:c.department,onChange:ee=>u(ve=>Ke(Te({},ve),{department:ee})),placeholder:"Select department (optional)"})})]}),t.jsx("button",{onClick:ge,disabled:h||!c.start_date||!c.end_date||!c.pm_for||!c.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:h?t.jsxs(t.Fragment,{children:[t.jsx(Ir,{className:"animate-spin"}),"Creating Schedules..."]}):t.jsxs(t.Fragment,{children:[t.jsx(Tr,{}),"Generate Maintenance Schedules (",n.length," asset",n.length!==1?"s":"",")"]})})]}),E.length===0&&!y&&!(z!=null&&z.show)&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-12 text-center",children:[t.jsx(Hs,{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."})]}),(z==null?void 0:z.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(Tr,{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:[z.count," maintenance schedule",z.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:z.document})]}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["A PM Schedule Generator document has been created with ",z.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:[z.document&&t.jsxs("button",{onClick:()=>{r(`/ppm-planner/${z.document}`),W(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(uf,{}),"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(uf,{}),"View Calendar"]}),t.jsx("button",{onClick:()=>W(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 ub(e={},r=20,a=0,s="creation desc",n={}){const[i,c]=_.useState([]),[u,h]=_.useState(0),[g,y]=_.useState(!1),[w,E]=_.useState(!0),[S,A]=_.useState(null),[C,O]=_.useState(0),M=JSON.stringify(e),R=JSON.stringify(n);_.useEffect(()=>{let z=!1;const W=M,X=R,B=r,Y=a,G=s;return me(null,null,function*(){var fe;try{E(!0),A(null);let K={},ke={};try{K=W?JSON.parse(W):{}}catch(we){K={}}try{ke=X?JSON.parse(X):{}}catch(we){ke={}}const ge=Te(Te({},K),ke),re=yield Xt.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(ge),limit:B,offset:Y,order_by:G,include_child_tables:!0,fields:JSON.stringify(["name","asset_name","hospital","modality","manufacturer","periodicity","start_date","end_date","due_date","docstatus","maintenance_team","assign_to"])})});if(!z){const we=(fe=re==null?void 0:re.message)!=null?fe:re;if(we!=null&&we.error){A(typeof we.error=="string"?we.error:"Failed to load PM schedules"),c([]),h(0),y(!1);return}if(we&&Array.isArray(we.pm_schedules)){const ee=we.pm_schedules;c(ee),h(we.total_count||0),y(we.has_more||!1)}else console.warn("[usePMSchedules] Unexpected response shape:",re),c([]),h(0),y(!1)}}catch(K){z||(console.error("Error fetching PM Schedules:",K),A(K instanceof Error?K.message:"Failed to fetch PM Schedules"),c([]),h(0))}finally{z||E(!1)}}),()=>{z=!0}},[M,R,r,a,s,C]);const F=_.useCallback(()=>{O(z=>z+1)},[]);return{pmSchedules:i,totalCount:u,hasMore:g,loading:w,error:S,refetch:F}}function D$(e){const[r,a]=_.useState(null),[s,n]=_.useState(!0),[i,c]=_.useState(null),u=_.useCallback(()=>me(null,null,function*(){if(!e){a(null),n(!1);return}n(!0),c(null);try{const h=yield Xt.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:",h),h&&h.name&&!h.error)console.log("[usePMScheduleDetails] Setting PM Schedule:",h),a(h);else{const g=(h==null?void 0:h.error)||"PM Schedule not found";console.warn("[usePMScheduleDetails] Error or not found:",g),c(g),a(null)}}catch(h){console.error("Error fetching PM Schedule details:",h),c(h instanceof Error?h.message:"Failed to fetch PM Schedule"),a(null)}finally{n(!1)}}),[e]);return _.useEffect(()=>{u()},[u]),{pmSchedule:r,loading:s,error:i,refetch:u}}function xS(){const[e,r]=_.useState(!1);return{createPMSchedule:y=>me(null,null,function*(){r(!0);try{const w=yield Xt.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(y)})});if(w!=null&&w.success)return w.pm_schedule;throw new Error((w==null?void 0:w.error)||"Failed to create PM Schedule")}finally{r(!1)}}),updatePMSchedule:(y,w)=>me(null,null,function*(){r(!0);try{const E=yield Xt.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:y,pm_schedule_data:JSON.stringify(w)})});if(E!=null&&E.success)return E.pm_schedule;throw new Error((E==null?void 0:E.error)||"Failed to update PM Schedule")}finally{r(!1)}}),deletePMSchedule:y=>me(null,null,function*(){r(!0);try{const w=yield Xt.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:y})});if(!(w!=null&&w.success))throw new Error((w==null?void 0:w.error)||"Failed to delete PM Schedule")}finally{r(!1)}}),submitPMSchedule:y=>me(null,null,function*(){r(!0);try{const w=yield Xt.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:y})});if(w!=null&&w.success)return w.pm_schedule;throw new Error((w==null?void 0:w.error)||"Failed to submit PM Schedule")}finally{r(!1)}}),cancelPMSchedule:y=>me(null,null,function*(){r(!0);try{const w=yield Xt.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:y})});if(w!=null&&w.success)return w.pm_schedule;throw new Error((w==null?void 0:w.error)||"Failed to cancel PM Schedule")}finally{r(!1)}}),addMaintenanceEntry:(y,w)=>me(null,null,function*(){r(!0);try{const E=yield Xt.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:y,entry_data:JSON.stringify(w)})});if(E!=null&&E.success)return E.maintenance_entries;throw new Error((E==null?void 0:E.error)||"Failed to add maintenance entry")}finally{r(!1)}}),removeMaintenanceEntry:(y,w)=>me(null,null,function*(){r(!0);try{const E=yield Xt.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:y,entry_name:w})});if(E!=null&&E.success)return E.maintenance_entries;throw new Error((E==null?void 0:E.error)||"Failed to remove maintenance entry")}finally{r(!1)}}),updateMaintenanceEntry:(y,w,E)=>me(null,null,function*(){r(!0);try{const S=yield Xt.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:y,entry_name:w,entry_data:JSON.stringify(E)})});if(S!=null&&S.success)return S.maintenance_entries;throw new Error((S==null?void 0:S.error)||"Failed to update maintenance entry")}finally{r(!1)}}),loading:e}}const R$=({isOpen:e,onClose:r,selectedCount:a,totalCount:s,pageCount:n,onExport:i,isExporting:c,exportColumns:u})=>{const{t:h}=Rr(),[g,y]=_.useState(a>0?"selected":"all_with_filters"),[w,E]=_.useState("csv"),[S,A]=_.useState(u.filter(R=>R.default).map(R=>R.key));_.useEffect(()=>{a>0?y("selected"):y("all_with_filters")},[a]);const C=R=>{A(F=>F.includes(R)?F.filter(z=>z!==R):[...F,R])},O=()=>{A(u.map(R=>R.key))},M=()=>{A(u.filter(R=>R.default).map(R=>R.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(Ks,{className:"text-white text-xl"}),t.jsxs("h3",{className:"text-lg font-semibold text-white",children:[h("listPages.export")," PPM Schedules"]})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:c,children:t.jsx(Pt,{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:"Export Scope"}),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 ${g==="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:g==="selected",onChange:()=>y("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:"Selected Rows"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export ",a," selected schedule",a!==1?"s":""]})]}),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 ${g==="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:g==="all_on_page",onChange:()=>y("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:"Current Page"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export ",n," schedule",n!==1?"s":""," on current page"]})]}),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 ${g==="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:g==="all_with_filters",onChange:()=>y("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:"All Records (with current filters)"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export all ",s," schedule",s!==1?"s":""," matching current filters"]})]}),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:h("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 ${w==="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:w==="csv",onChange:()=>E("csv"),className:"text-green-600 focus:ring-green-500"}),t.jsx(No,{className:"text-green-600 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("listPages.csv")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Comma-separated values"})]})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${w==="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:w==="excel",onChange:()=>E("excel"),className:"text-green-600 focus:ring-green-500"}),t.jsx(zi,{className:"text-green-700 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("listPages.excel")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"XLSX spreadsheet"})]})]})]})]}),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:"Columns to Export"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:O,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",{onClick:M,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:"Reset to Default"})]})]}),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:u.map(R=>t.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${S.includes(R.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:S.includes(R.key),onChange:()=>C(R.key),className:"rounded text-green-600 focus:ring-green-500"}),t.jsx("span",{className:"text-sm truncate",children:R.label})]},R.key))}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:[S.length," column",S.length!==1?"s":""," selected"]})]})]}),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:[g==="selected"&&`Exporting ${a} selected row${a!==1?"s":""}`,g==="all_on_page"&&`Exporting ${n} row${n!==1?"s":""} from current page`,g==="all_with_filters"&&`Exporting all ${s} row${s!==1?"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:c,children:"Cancel"}),t.jsx("button",{onClick:()=>i(g,w,S),disabled:S.length===0||c,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:c?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Exporting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(Vo,{}),"Export"]})})]})]})]})}):null},F$=({isOpen:e,onClose:r,selectedItems:a,onPrint:s,isPrinting:n})=>{const[i,c]=_.useState(""),[u,h]=_.useState(!0),[g,y]=_.useState(""),[w,E]=_.useState("A4"),[S,A]=_.useState([]),[C,O]=_.useState([]),[M,R]=_.useState(!1);_.useEffect(()=>{e&&(F(),z())},[e]);const F=()=>me(null,null,function*(){R(!0);try{const Y=((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);A(Y),Y.length>0&&!i&&c(Y[0])}catch(X){console.error("Error fetching print formats:",X)}finally{R(!1)}}),z=()=>me(null,null,function*(){try{const Y=((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);O(Y),Y.length>0&&!g&&y(Y[0])}catch(X){console.error("Error fetching letterheads:",X)}}),W=()=>{if(!i){alert("Please select a print format");return}s(i,g,!u,w)};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(Go,{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(Pt,{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(jn,{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:"*"})]}),M?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..."]}):S.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:i,onChange:X=>c(X.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"}),S.map(X=>t.jsx("option",{value:X,children:X},X))]})]}),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:u,onChange:X=>h(X.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"})]})}),u&&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:g,onChange:X=>y(X.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"}),C.map(X=>t.jsx("option",{value:X,children:X},X))]})]}),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:w,onChange:X=>E(X.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:W,disabled:!i||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(Go,{}),"Print ",a.length," Schedule",a.length!==1?"s":""]})})]})]})}):null},I$=()=>{const{t:e}=Rr(),r=Na(),[a,s]=_.useState(0),[n,i]=_.useState(""),[c,u]=_.useState(null),[h,g]=_.useState(null),y=_.useRef(null),[w,E]=_.useState(!1),[S,A]=_.useState(""),[C,O]=_.useState(""),[M,R]=_.useState(""),[F,z]=_.useState(""),[W,X]=_.useState(new Set),[B,Y]=_.useState(!1),[G,ie]=_.useState(!1),[fe,K]=_.useState(!1),[ke,ge]=_.useState(!1),re=20,we=[{key:"name",label:e("commonFields.pmId"),default:!0},{key:"asset_name",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}],ee={};S&&(ee.hospital=S),C&&(ee.modality=C),M&&(ee.manufacturer=M),F&&(ee.periodicity=F);const{pmSchedules:ve,totalCount:ce,hasMore:ye,loading:te,error:q,refetch:J}=ub(ee,re,a*re,"creation desc"),{deletePMSchedule:ae,loading:oe}=xS();_.useEffect(()=>{const qe=Dt=>{y.current&&!y.current.contains(Dt.target)&&g(null)};return h&&document.addEventListener("mousedown",qe),()=>{document.removeEventListener("mousedown",qe)}},[h]),_.useEffect(()=>{X(new Set)},[S,C,M,F,n,a]);const le=ve.filter(qe=>{var ar,yt,St,Ot,Yt,Ye;if(!n)return!0;const Dt=n.toLowerCase();return((ar=qe.name)==null?void 0:ar.toLowerCase().includes(Dt))||((yt=qe.asset_name)==null?void 0:yt.toLowerCase().includes(Dt))||((St=qe.hospital)==null?void 0:St.toLowerCase().includes(Dt))||((Ot=qe.modality)==null?void 0:Ot.toLowerCase().includes(Dt))||((Yt=qe.manufacturer)==null?void 0:Yt.toLowerCase().includes(Dt))||((Ye=qe.maintenance_team)==null?void 0:Ye.toLowerCase().includes(Dt))}),be=()=>{W.size===le.length?X(new Set):X(new Set(le.map(qe=>qe.name)))},Z=le.length>0&&W.size===le.length,Le=W.size>0&&W.size<le.length,Pe=qe=>{X(Dt=>{const ar=new Set(Dt);return ar.has(qe)?ar.delete(qe):ar.add(qe),ar})},Be=_.useCallback(()=>me(null,null,function*(){const qe=[];let Dt=0;const ar=100;let yt=!0;for(;yt;)try{const Yt=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"PM Schedule Generator",filters:ee,fields:["*"],limit_start:Dt*ar,limit_page_length:ar,order_by:"creation desc"})})).json()).message||[];qe.push(...Yt),Yt.length<ar?yt=!1:Dt++,Dt>100&&(console.warn("Export safety limit reached"),yt=!1)}catch(St){throw console.error("Error fetching schedules for export:",St),St}return qe}),[ee]),pe=(qe,Dt,ar)=>me(null,null,function*(){ie(!0);try{let yt=[];switch(qe){case"selected":yt=le.filter(Yt=>W.has(Yt.name));break;case"all_on_page":yt=le;break;case"all_with_filters":yt=yield Be();break}if(yt.length===0){alert("No data to export");return}const St=yt.map(Yt=>{const Ye=Te({},Yt);if(ar.includes("docstatus")){const wt=Je(Yt);Ye.docstatus=wt===1?"Submitted":wt===2?"Cancelled":"Draft"}return Ye}),Ot=ar.map(Yt=>{const Ye=we.find(wt=>wt.key===Yt);return(Ye==null?void 0:Ye.label)||Yt});if(Dt==="csv"){const Yt=[Ot.join(","),...St.map(qt=>ar.map(kt=>{let ze=qt[kt]||"";return typeof ze=="string"&&(ze.includes(",")||ze.includes('"')||ze.includes(`
`))&&(ze=`"${ze.replace(/"/g,'""')}"`),ze}).join(","))].join(`
`),Ye=new Blob(["\uFEFF"+Yt],{type:"text/csv;charset=utf-8;"}),wt=URL.createObjectURL(Ye),zt=document.createElement("a");zt.href=wt,zt.download=`ppm_schedules_export_${new Date().toISOString().split("T")[0]}.csv`,zt.click(),URL.revokeObjectURL(wt)}else if(Dt==="excel"){const Yt=[Ot,...St.map(zt=>ar.map(qt=>zt[qt]||""))],Ye=Ur.aoa_to_sheet(Yt),wt=Ur.book_new();Ur.book_append_sheet(wt,Ye,"PPM Schedules"),jo(wt,`ppm_schedules_export_${new Date().toISOString().split("T")[0]}.xlsx`)}Y(!1),X(new Set)}catch(yt){console.error("Export failed:",yt),alert(`Export failed: ${yt instanceof Error?yt.message:"Unknown error"}`)}finally{ie(!1)}}),rt=(qe,Dt,ar,yt)=>{ge(!0);try{const St=Array.from(W);if(St.length===0){alert("No schedules selected for printing");return}const Ot=window.location.origin,Yt=new URLSearchParams;Yt.append("doctype","PM Schedule Generator"),Yt.append("name",JSON.stringify(St)),Yt.append("format",qe),Yt.append("no_letterhead",ar?"1":"0"),Dt&&!ar&&Yt.append("letterhead",Dt),Yt.append("options",JSON.stringify({"page-size":yt}));const Ye=`${Ot}/api/method/frappe.utils.print_format.download_multi_pdf?${Yt.toString()}`;window.open(Ye,"_blank"),K(!1)}catch(St){console.error("Print failed:",St),alert(`Print failed: ${St instanceof Error?St.message:"Unknown error"}`)}finally{ge(!1)}},ct=()=>{r("/ppm-planner/new")},et=qe=>{r(`/ppm-planner/${qe}`)},It=qe=>{r(`/ppm-planner/${qe}`)},ft=qe=>me(null,null,function*(){try{yield ae(qe),J(),u(null)}catch(Dt){console.error("Error deleting PM Schedule:",Dt),alert("Failed to delete PM Schedule")}}),Lt=()=>{A(""),O(""),R(""),z(""),s(0)},Je=qe=>{var Dt;return qe.docstatus!==void 0?Number(qe.docstatus):((Dt=qe.maintenance_entries)==null?void 0:Dt.length)>0?Number(qe.maintenance_entries[0].docstatus):0},Ve=S||C||M||F,Xe=[S,C,M,F].filter(Boolean).length,Rt=Math.ceil(ce/re);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($o,{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"),W.size>0&&t.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",W.size," selected"]})]})]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("button",{onClick:()=>Y(!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:ce===0,children:[t.jsx(Ks,{}),t.jsx("span",{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:()=>K(!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:W.size===0,title:W.size===0?"Select schedules to print":`Print ${W.size} selected`,children:[t.jsx(Go,{}),t.jsx("span",{children:"Print"}),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:ct,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(Js,{}),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(In,{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:n,onChange:qe=>i(qe.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:()=>E(!w),className:`px-3 py-1.5 border rounded-lg transition-colors flex items-center gap-2 text-sm ${Ve?"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(Hs,{}),t.jsx("span",{children:e("listPages.filters")}),Xe>0&&t.jsx("span",{className:"bg-blue-600 text-white rounded-full w-5 h-5 flex items-center justify-center text-xs",children:Xe}),w?t.jsx(Mn,{}):t.jsx(on,{})]})]}),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.jsx("div",{children:t.jsx(hr,{label:e("commonFields.hospital"),doctype:"Company",value:S,onChange:A,placeholder:e("filters.allHospitals"),filters:{domain:"Healthcare"}})}),t.jsx("div",{children:t.jsx(hr,{label:e("commonFields.modality"),doctype:"Modality",value:C,onChange:O,placeholder:e("filters.allModalities"),filters:{}})}),t.jsx("div",{children:t.jsx(hr,{label:e("commonFields.manufacturer"),doctype:"Manufacturer",value:M,onChange:R,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:F,onChange:qe=>z(qe.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"})]})]})]}),Ve&&t.jsx("div",{className:"mt-4 flex justify-end",children:t.jsxs("button",{onClick:Lt,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(Pt,{}),e("listPages.clearFilters")]})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto p-4 lg:p-5",children:te&&a===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")})]}):q?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:q})}):le.length===0?t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-8 text-center",children:[t.jsx($o,{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(n||Ve?"listPages.tryAdjustingFilters":"listPages.getStartedCreateFirst")}),!n&&!Ve&&t.jsx("button",{onClick:ct,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:be,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:Z?"Deselect all":"Select all",children:Z?t.jsx(jn,{className:"text-blue-600 dark:text-blue-400",size:18}):Le?t.jsxs("div",{className:"relative",children:[t.jsx(ys,{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(ys,{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:le.map(qe=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors ${W.has(qe.name)?"bg-blue-50 dark:bg-blue-900/20":""}`,children:[t.jsx("td",{className:"px-4 py-4",children:t.jsx("button",{onClick:()=>Pe(qe.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:W.has(qe.name)?t.jsx(jn,{className:"text-blue-600 dark:text-blue-400",size:18}):t.jsx(ys,{size:18})})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("button",{onClick:()=>et(qe.name),className:"text-blue-600 dark:text-blue-400 hover:underline font-medium",children:qe.name})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:qe.asset_name||(Array.isArray(qe.maintenance_entries)&&qe.maintenance_entries.length>0?qe.maintenance_entries.map(Dt=>Dt==null?void 0:Dt.asset_name).filter(Boolean).slice(0,3).join(", "):"-")||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:qe.hospital||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:qe.modality||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:qe.manufacturer||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:qe.periodicity||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:(()=>{const Dt=Je(qe);return t.jsx("span",{className:`px-2 py-1 text-xs font-semibold rounded-full ${Dt===1?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":Dt===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:Dt===1?"Submitted":Dt===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:h===qe.name?y:null,children:[t.jsx("button",{onClick:()=>g(h===qe.name?null:qe.name),className:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 p-2",children:t.jsx(Wf,{})}),h===qe.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:()=>{et(qe.name),g(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(to,{})," ",e("listPages.view")]}),t.jsxs("button",{onClick:()=>{It(qe.name),g(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(Ms,{})," ",e("listPages.edit")]}),t.jsxs("button",{onClick:()=>{u(qe.name),g(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(la,{})," ",e("listPages.delete")]})]})]})})]},qe.name))})]}),Rt>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")," ",a*re+1," ",e("listPages.to")," ",Math.min((a+1)*re,ce)," ",e("listPages.of")," ",ce," ",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 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:()=>s(a+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(R$,{isOpen:B,onClose:()=>Y(!1),selectedCount:W.size,totalCount:ce,pageCount:le.length,onExport:pe,isExporting:G,exportColumns:we}),t.jsx(F$,{isOpen:fe,onClose:()=>K(!1),selectedItems:Array.from(W),onPrint:rt,isPrinting:ke}),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 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:()=>u(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:oe,children:e("common.cancel")}),t.jsx("button",{onClick:()=>ft(c),className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors",disabled:oe,children:e(oe?"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;
}
`})]})},M$=()=>{var Se;Rr();const{scheduleName:e}=ml(),r=Na(),{pmSchedule:a,loading:s,error:n,refetch:i}=D$(e||null),{updatePMSchedule:c,deletePMSchedule:u,submitPMSchedule:h,cancelPMSchedule:g,loading:y}=xS(),{logs:w,refetch:E}=Fg({},1e4,0),[S,A]=_.useState(!1),[C,O]=_.useState(!1),[M,R]=_.useState(!1),[F,z]=_.useState(""),[W,X]=_.useState(""),[B,Y]=_.useState(!1),[G,ie]=_.useState(!1),[fe,K]=_.useState(new Set),[ke,ge]=_.useState(!1),[re,we]=_.useState(!1),[ee,ve]=_.useState(new Set),[ce,ye]=_.useState([]),[te,q]=_.useState([]),[J,ae]=_.useState([]),[oe,le]=_.useState([]),[be,Z]=_.useState(!1),[Le,Pe]=_.useState(!0),[Be,pe]=_.useState(!1),[rt,ct]=_.useState(""),[et,It]=_.useState([]),[ft,Lt]=_.useState(""),[Je,Ve]=_.useState({modality:"",device_status:"",manufacturer:"",model:""}),[Xe,Rt]=_.useState([]),[qe,Dt]=_.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:""}),ar=ne=>{if(!ne)return"";if(ne==="Administrator")return"Administrator";const _e=ne.indexOf("@");return _e>0?ne.slice(0,_e):ne},yt=ne=>{try{return new Date(ne).toLocaleString()}catch(_e){return ne}};_.useEffect(()=>{me(null,null,function*(){try{const Ce=yield(yield fetch("/api/method/frappe.auth.get_logged_user",{method:"GET",credentials:"include"})).json();Ce.message&&ct(Ce.message)}catch(_e){console.error("Error fetching current user:",_e)}})},[]);const St=_.useCallback(()=>me(null,null,function*(){var ne;if(e){Z(!0);try{const Ce=yield(yield fetch("/api/method/frappe.desk.form.load.getdoc",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({doctype:"PM Schedule Generator",name:e})})).json(),Qe=(ne=Ce==null?void 0:Ce.message)==null?void 0:ne.docinfo,dt=((Qe==null?void 0:Qe.versions)||[]).map(at=>{let $e={};try{$e=typeof at.data=="string"?JSON.parse(at.data||"{}"):at.data||{}}catch(gt){$e={}}const tt=($e.changed||[]).map(gt=>{var Wt,Ft,Zt;return{field:String((Wt=gt==null?void 0:gt[0])!=null?Wt:""),old_value:String((Ft=gt==null?void 0:gt[1])!=null?Ft:""),new_value:String((Zt=gt==null?void 0:gt[2])!=null?Zt:"")}});return{name:String(at.name||""),owner:String(at.owner||""),creation:String(at.creation||""),changes:tt}});le(dt)}catch(_e){console.error("Failed to fetch audit logs:",_e),le([])}finally{Z(!1)}}}),[e]),Ot=_.useCallback(()=>me(null,null,function*(){var ne,_e;if(e)try{const Qe=yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({doctype:"Asset Maintenance",filters:{custom_pm_schedule:e,docstatus:["<",2]},fields:["name","custom_asset_name","asset_name"],limit_page_length:0})})).json(),xt=(Qe==null?void 0:Qe.message)||[],dt=xt.map(Zt=>(Zt==null?void 0:Zt.custom_asset_name)||(Zt==null?void 0:Zt.asset_name)||(Zt==null?void 0:Zt.name)).filter(Boolean);It(dt);const at=(ne=xt==null?void 0:xt[0])==null?void 0:ne.name;if(!at){Lt("");return}const tt=yield(yield fetch(`/api/resource/Asset%20Maintenance/${encodeURIComponent(at)}`,{method:"GET",credentials:"include"})).json(),gt=tt==null?void 0:tt.data,Wt=(gt==null?void 0:gt.custom_service_coverage_table)||(gt==null?void 0:gt.service_coverage_table)||[],Ft=(_e=Wt==null?void 0:Wt[0])==null?void 0:_e.no_of_pms;Lt(Ft!=null?String(Ft):"")}catch(Ce){console.warn("Failed to fetch Asset Maintenance names:",Ce),It([]),Lt("")}}),[e]);_.useEffect(()=>{if(e){const ne=localStorage.getItem(`ppm_activity_${e}`);ne&&ae(JSON.parse(ne))}},[e]),_.useEffect(()=>{St(),Ot()},[St,Ot]),_.useEffect(()=>{var at;if(!((at=a==null?void 0:a.maintenance_entries)!=null&&at.length)){Ve({modality:"",device_status:"",manufacturer:"",model:""}),Rt([]);return}const ne=a.maintenance_entries,_e=[...new Set(ne.map($e=>$e.asset).filter(Boolean))];if(_e.length===0)return;const Ce=ne[0],Qe=!a.modality||!a.device_status||!a.manufacturer||!a.model||!(Ce!=null&&Ce.manufacturer)||!(Ce!=null&&Ce.model),xt=ne.some($e=>$e.asset&&!$e.asset_name);if(!Qe&&!xt){Ve({modality:"",device_status:"",manufacturer:"",model:""}),Rt([]);return}let dt=!1;return me(null,null,function*(){try{const tt=yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({doctype:"Asset",filters:{name:["in",_e]},fields:["name","asset_name","custom_modality","custom_manufacturer","custom_model","custom_device_status"],limit_page_length:0})})).json();if(dt)return;const gt=(tt==null?void 0:tt.message)||[],Wt=new Map(gt.map(Ft=>[Ft.name,Ft]));if(Qe){const Ft=Wt.get(Ce.asset);Ve({modality:(Ft==null?void 0:Ft.custom_modality)||"",device_status:(Ft==null?void 0:Ft.custom_device_status)||"",manufacturer:(Ft==null?void 0:Ft.custom_manufacturer)||"",model:(Ft==null?void 0:Ft.custom_model)||""})}else Ve({modality:"",device_status:"",manufacturer:"",model:""});if(xt){const Ft=ne.map(Zt=>{if(Zt.asset_name)return Zt.asset_name;const br=Zt.asset?Wt.get(Zt.asset):void 0;return(br==null?void 0:br.asset_name)||Zt.asset||""}).filter(Boolean);Rt(Ft)}else Rt([])}catch($e){dt||(Ve({modality:"",device_status:"",manufacturer:"",model:""}),Rt([]))}}),()=>{dt=!0}},[a==null?void 0:a.name,a==null?void 0:a.modality,a==null?void 0:a.device_status,a==null?void 0:a.manufacturer,a==null?void 0:a.model,a==null?void 0:a.maintenance_entries]),_.useEffect(()=>{if(a!=null&&a.maintenance_entries&&w.length>0){const ne=[],_e=[];a.maintenance_entries.forEach(Ce=>{w.filter(xt=>xt.asset_name===Ce.asset).forEach(xt=>{xt.workflow_state==="Applied"?_e.push(Ke(Te({},xt),{asset_display_name:Ce.asset_name||Ce.asset})):xt.maintenance_status==="Planned"&&(!xt.workflow_state||xt.workflow_state==="Draft")&&ne.push(Ke(Te({},xt),{asset_display_name:Ce.asset_name||Ce.asset}))})}),ye(ne),q(_e)}},[a,w]),_.useEffect(()=>{if(w.length>0&&(a!=null&&a.maintenance_entries)){const ne=[];if(a.maintenance_entries.forEach(_e=>{w.filter(Qe=>Qe.asset_name===_e.asset).forEach(Qe=>{const xt=Qe.maintenance_status==="Planned"&&(!Qe.workflow_state||Qe.workflow_state==="Draft"),dt=Qe.workflow_state==="Applied";(xt||dt)&&Qe.due_date&&ne.push(Qe.due_date)})}),ne.length>0){const _e=ne.sort((Ce,Qe)=>new Date(Ce).getTime()-new Date(Qe).getTime())[0];console.log("📅 Pending due dates:",ne),console.log("📅 Earliest (Next PM Date):",_e),Dt(Ce=>Ce.next_pm_date!==_e?Ke(Te({},Ce),{next_pm_date:_e}):Ce)}else console.log("📅 No pending entries found - all completed"),Dt(_e=>Ke(Te({},_e),{next_pm_date:""}))}},[a,w]),_.useEffect(()=>{var ne;if(a){const _e=(ne=a.maintenance_entries)==null?void 0:ne[0];Dt({hospital:a.hospital||"",modality:a.modality||Je.modality||"",device_status:a.device_status||Je.device_status||"",start_date:a.start_date||"",end_date:a.end_date||"",maintenance_team:a.maintenance_team||"",maintenance_manager:a.maintenance_manager||"",periodicity:a.periodicity||"Monthly",assign_to:a.assign_to||"",due_date:a.due_date||"",next_pm_date:a.next_pm_date||"",manufacturer:a.manufacturer||(_e==null?void 0:_e.manufacturer)||Je.manufacturer||"",model:a.model||(_e==null?void 0:_e.model)||Je.model||"",pm_for:a.pm_for||"",asset_name:a.asset_name||"",no_of_pms:a.no_of_pms!=null?String(a.no_of_pms):""})}},[a,Je]),_.useEffect(()=>{if(F&&qe.next_pm_date){const ne=new Date(F),_e=new Date(qe.next_pm_date);Y(ne<_e)}else Y(!1)},[F,qe.next_pm_date]);const Yt=(ne,_e,Ce)=>{if(!ne||!_e||!Ce)return null;const Qe=parseInt(Ce,10);if(isNaN(Qe)||Qe<1)return null;const xt=Qe-1;if(xt<0)return null;const dt=new Date(ne),at=new Date(dt);switch(_e){case"Daily":at.setDate(at.getDate()+xt);break;case"Weekly":at.setDate(at.getDate()+xt*7);break;case"Monthly":at.setMonth(at.getMonth()+xt);break;case"Quarterly":at.setMonth(at.getMonth()+xt*3);break;case"Half-yearly":at.setMonth(at.getMonth()+xt*6);break;case"Yearly":at.setFullYear(at.getFullYear()+xt);break;case"2 Yearly":at.setFullYear(at.getFullYear()+xt*2);break;case"3 Yearly":at.setFullYear(at.getFullYear()+xt*3);break;default:return null}const $e=at.getFullYear(),tt=String(at.getMonth()+1).padStart(2,"0"),gt=String(at.getDate()).padStart(2,"0");return`${$e}-${tt}-${gt}`},Ye=ne=>{const{name:_e,value:Ce}=ne.target;Dt(Qe=>{const xt=Ke(Te({},Qe),{[_e]:Ce});if(_e==="start_date"||_e==="periodicity"||_e==="no_of_pms"){const dt=Yt(_e==="start_date"?Ce:Qe.start_date,_e==="periodicity"?Ce:Qe.periodicity,_e==="no_of_pms"?Ce:Qe.no_of_pms);dt&&(xt.end_date=dt)}return xt})},wt=()=>me(null,null,function*(){if(e)try{yield c(e,qe),A(!1),i(),alert("PPM Planner updated successfully")}catch(ne){console.error("Error updating PPM Planner:",ne),alert("Failed to update PPM Planner")}}),zt=()=>me(null,null,function*(){if(e)try{yield u(e),r(-1)}catch(ne){console.error("Error deleting PPM Planner:",ne),alert("Failed to delete PPM Planner")}}),qt=()=>me(null,null,function*(){if(e)try{yield h(e),i(),alert("PPM Planner submitted successfully")}catch(ne){console.error("Error submitting PPM Planner:",ne),alert("Failed to submit PPM Planner")}}),kt=()=>me(null,null,function*(){if(e)try{yield g(e),i(),alert("PPM Planner cancelled successfully")}catch(ne){console.error("Error cancelling PPM Planner:",ne),alert("Failed to cancel PPM Planner")}}),ze=()=>{if(ce.length===0){alert("No planned maintenance entries found to apply.");return}const ne=new Date().toISOString().split("T")[0];z(ne),X(""),K(new Set(ce.map(_e=>_e.name))),R(!0)},nt=ne=>{K(_e=>{const Ce=new Set(_e);return Ce.has(ne)?Ce.delete(ne):Ce.add(ne),Ce})},_t=()=>{K(new Set(ce.map(ne=>ne.name)))},lr=()=>{K(new Set)},pr=()=>me(null,null,function*(){if(!F){alert("Please enter a completion date.");return}if(B&&!W.trim()){alert("Please provide a reason for early completion.");return}if(fe.size===0){alert("Please select at least one entry to complete.");return}ie(!0);try{let ne=0,_e=0;const Ce=[],Qe=ce.filter(at=>fe.has(at.name));for(const at of Qe)try{const $e={maintenance_status:"Completed",workflow_state:"Applied",completion_date:F};B&&W&&($e.custom_early_completion_reason=W,$e.custom_early_completion="Yes");const gt=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:at.name,fieldname:$e})})).json();gt.message?(ne++,Ce.push(at.name)):(_e++,console.error(`Failed to apply ${at.name}:`,gt))}catch($e){_e++,console.error(`Error applying ${at.name}:`,$e)}const dt=[{id:Date.now().toString(),user:rt||"Unknown User",timestamp:new Date().toISOString(),action:"Applied",entriesCount:ne,completionDate:F,earlyReason:B?W:void 0,entries:Ce},...J];ae(dt),e&&localStorage.setItem(`ppm_activity_${e}`,JSON.stringify(dt)),R(!1),z(""),X(""),K(new Set),E(),i(),alert(_e===0?`Successfully applied ${ne} maintenance entries. They are now pending approval.`:`Applied ${ne} entries. Failed to apply ${_e} entries.`)}catch(ne){console.error("Error applying entries:",ne),alert("Failed to apply entries.")}finally{ie(!1)}}),Nr=()=>{if(te.length===0){alert("No entries pending approval.");return}ve(new Set(te.map(ne=>ne.name))),ge(!0)},rr=ne=>{ve(_e=>{const Ce=new Set(_e);return Ce.has(ne)?Ce.delete(ne):Ce.add(ne),Ce})},_r=()=>{ve(new Set(te.map(ne=>ne.name)))},Nt=()=>{ve(new Set)},Cr=()=>me(null,null,function*(){if(ee.size===0){alert("Please select at least one entry to approve.");return}we(!0);try{let ne=0,_e=0;const Ce=[],Qe=te.filter(at=>ee.has(at.name));for(const at of Qe)try{const tt=yield(yield fetch(`/api/resource/Asset Maintenance Log/${encodeURIComponent(at.name)}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json();if(!tt.data){console.error(`Failed to get document ${at.name}`),_e++;continue}const gt=Ke(Te({},tt.data),{workflow_state:"Approved",docstatus:1}),Ft=yield(yield fetch(`/api/resource/Asset Maintenance Log/${encodeURIComponent(at.name)}`,{method:"PUT",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(gt)})).json();if(Ft.data&&Ft.data.docstatus===1)ne++,Ce.push(at.name),console.log(`✅ Successfully approved and submitted: ${at.name}`);else{console.log(`Trying alternative submit method for ${at.name}...`),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:at.name,workflow_action:"Approve"})});const br=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:at.name,method:"submit"})})).json();br.message||!br.exc?(ne++,Ce.push(at.name),console.log(`✅ Successfully submitted via run_doc_method: ${at.name}`)):(_e++,console.error(`Failed to submit ${at.name}:`,br))}}catch($e){_e++,console.error(`Error approving ${at.name}:`,$e)}const dt=[{id:Date.now().toString(),user:rt||"Unknown User",timestamp:new Date().toISOString(),action:"Approved",entriesCount:ne,entries:Ce},...J];ae(dt),e&&localStorage.setItem(`ppm_activity_${e}`,JSON.stringify(dt)),ge(!1),ve(new Set),setTimeout(()=>{E(),i()},1e3),alert(_e===0?`Successfully approved and submitted ${ne} maintenance entries. New planned entries should be created automatically.`:`Approved ${ne} entries. Failed to approve ${_e} entries.`)}catch(ne){console.error("Error approving entries:",ne),alert("Failed to approve entries.")}finally{we(!1)}}),yr=ne=>{switch(ne){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"}},jt=ne=>w.filter(Ce=>Ce.asset_name===ne).filter(Ce=>{const Qe=Ce.maintenance_status==="Planned"&&(!Ce.workflow_state||Ce.workflow_state==="Draft"),xt=Ce.workflow_state==="Applied";return Qe||xt}),Tt=ne=>jt(ne).length>0,He=()=>a!=null&&a.maintenance_entries?a.maintenance_entries.filter(ne=>Tt(ne.asset)):[];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:"flex items-center gap-3",children:[t.jsx(Ir,{className:"animate-spin text-blue-600",size:24}),t.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Loading PPM Planner..."})]})});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:"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:n}),t.jsx("button",{onClick:()=>r(-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(!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:"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:()=>r(-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 Fe=a.docstatus===0,Ze=a.docstatus===1,vt=(Se=a.maintenance_entries)==null?void 0:Se[0],ir=a.modality||Je.modality||"",fr=a.device_status||Je.device_status||"",Kt=a.manufacturer||(vt==null?void 0:vt.manufacturer)||Je.manufacturer||"",Re=a.model||(vt==null?void 0:vt.model)||Je.model||"",Q=et.length>0?et.join(", "):Xe.length>0?Xe.join(", "):(a.maintenance_entries||[]).map(ne=>ne.asset_name||ne.asset).filter(Boolean).join(", "),he=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-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:()=>r(-1),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:t.jsx(Kn,{className:"text-gray-600 dark:text-gray-400"})}),t.jsx($o,{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:a.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 ${Ze?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":Fe?"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:Ze?"Submitted":Fe?"Draft":"Cancelled"})]}),t.jsxs("div",{className:"flex gap-2",children:[Ze&&t.jsxs("div",{className:"flex gap-2 mr-4 pr-4 border-r border-gray-300 dark:border-gray-600",children:[ce.length>0&&t.jsxs("button",{onClick:ze,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(Wo,{}),"Bulk Complete(",ce.length,")"]}),te.length>0&&t.jsxs("button",{onClick:Nr,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(rf,{}),"Approve (",te.length,")"]})]}),Fe&&!S&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>A(!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(Ms,{}),"Edit"]}),t.jsxs("button",{onClick:qt,disabled:y,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(Tr,{}),"Submit"]}),t.jsxs("button",{onClick:()=>O(!0),disabled:y,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(la,{}),"Delete"]})]}),S&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:wt,disabled:y,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:[y?t.jsx(Ir,{className:"animate-spin"}):t.jsx(bs,{}),"Save"]}),t.jsx("button",{onClick:()=>{A(!1),Dt({hospital:a.hospital||"",modality:a.modality||"",device_status:a.device_status||"",start_date:a.start_date||"",end_date:a.end_date||"",maintenance_team:a.maintenance_team||"",maintenance_manager:a.maintenance_manager||"",periodicity:a.periodicity||"Monthly",assign_to:a.assign_to||"",due_date:a.due_date||"",next_pm_date:a.next_pm_date||"",manufacturer:a.manufacturer||"",model:a.model||"",pm_for:a.pm_for||"",asset_name:a.asset_name||"",no_of_pms:a.no_of_pms!=null?String(a.no_of_pms):""})},disabled:y,className:"px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg transition-colors disabled:opacity-50",children:"Cancel"})]}),Ze&&t.jsx("button",{onClick:kt,disabled:y,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"})]})]}),Ze&&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:"}),ce.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:[ce.length," Planned"]}),te.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:[te.length," Pending Approval"]}),ce.length===0&&te.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:S?t.jsx(hr,{label:"Hospital *",doctype:"Company",value:qe.hospital,onChange:ne=>Dt(_e=>Ke(Te({},_e),{hospital:ne})),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:a.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"}),S?t.jsx("input",{type:"text",name:"modality",value:qe.modality,onChange:Ye,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:ir||"-"})]}),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"}),S?t.jsx("input",{type:"text",name:"device_status",value:qe.device_status,onChange:Ye,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:fr||"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Periodicity *"}),S?t.jsxs("select",{name:"periodicity",value:qe.periodicity,onChange:Ye,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:a.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"}),S?t.jsx("input",{type:"text",name:"manufacturer",value:qe.manufacturer,onChange:Ye,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:Kt||"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Model"}),S?t.jsx("input",{type:"text",name:"model",value:qe.model,onChange:Ye,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:Re||"-"})]}),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"}),S?t.jsx("input",{type:"text",name:"pm_for",value:qe.pm_for,onChange:Ye,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:a.asset_name||a.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"}),S?t.jsx("input",{type:"text",name:"asset_name",value:qe.asset_name,onChange:Ye,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:Q||"-"})]})]})]}),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 *"}),S?t.jsx("input",{type:"date",name:"start_date",value:qe.start_date,onChange:Ye,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:a.start_date?new Date(a.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 *"}),S?t.jsx("input",{type:"date",name:"end_date",value:qe.end_date,onChange:Ye,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:a.end_date?new Date(a.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"}),S?t.jsx("input",{type:"date",name:"due_date",value:qe.due_date,onChange:Ye,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:a.due_date?new Date(a.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"}),S?t.jsx("input",{type:"date",name:"next_pm_date",value:qe.next_pm_date,onChange:Ye,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:qe.next_pm_date?new Date(qe.next_pm_date).toLocaleDateString():a.next_pm_date?new Date(a.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"}),S?t.jsx("input",{type:"number",name:"no_of_pms",value:qe.no_of_pms,onChange:Ye,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:ft||(a.no_of_pms!=null?String(a.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"}),S?t.jsx("input",{type:"text",name:"maintenance_team",value:qe.maintenance_team,onChange:Ye,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:a.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"}),S?t.jsx("input",{type:"text",name:"maintenance_manager",value:qe.maintenance_manager,onChange:Ye,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:a.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"}),S?t.jsx("input",{type:"text",name:"assign_to",value:qe.assign_to,onChange:Ye,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:a.assign_to||"-"})]})]})]}),he.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:"PM Work Order"}),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:he.map((ne,_e)=>{const Ce=jt(ne.asset);return Ce.map((Qe,xt)=>t.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50",children:[xt===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:Ce.length,children:ne.asset?t.jsx("button",{onClick:()=>r(`/assets/${ne.asset}`),className:"text-blue-600 dark:text-blue-400 hover:underline",children:ne.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:Ce.length,children:ne.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:Ce.length,children:ne.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:()=>r(`/maintenance/${Qe.name}`),className:"text-blue-600 dark:text-blue-400 hover:underline",children:Qe.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 ${Qe.workflow_state==="Applied"?yr("Applied"):yr("Planned")}`,children:Qe.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:Qe.due_date?new Date(Qe.due_date).toLocaleDateString():"-"})]},`${ne.name}-${Qe.name}`))})})]})})]}),Ze&&he.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(Tr,{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:a.creation?new Date(a.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:a.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:a.modified?new Date(a.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:a.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(Id,{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"})]}),t.jsxs("div",{className:"mb-6",children:[t.jsxs("div",{className:"flex items-center justify-between cursor-pointer",onClick:()=>Pe(!Le),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-white",children:"Timeline"}),oe.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:oe.length})]}),t.jsx("button",{type:"button",onClick:ne=>{ne.stopPropagation(),St()},disabled:be,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline disabled:opacity-50",children:"Refresh"})]}),Le&&t.jsx("div",{className:"mt-3",children:be?t.jsxs("div",{className:"flex items-center justify-center py-6 text-gray-500 dark:text-gray-400",children:[t.jsx(Ir,{className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:"Loading..."})]}):oe.length===0?t.jsxs("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:[t.jsx(Id,{className:"mx-auto text-3xl mb-2 opacity-50"}),t.jsx("p",{className:"text-sm",children:"No activity recorded yet"}),(a==null?void 0:a.creation)&&(a==null?void 0:a.owner)&&t.jsxs("p",{className:"text-xs mt-2",children:["Created by ",t.jsx("span",{className:"font-medium",children:ar(a.owner)})," on"," ",t.jsx("span",{className:"font-medium",children:yt(a.creation)})]})]}):t.jsxs("div",{className:"space-y-3",children:[(Be?oe:oe.slice(0,8)).map(ne=>t.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-700 p-3 bg-gray-50 dark:bg-gray-700/40",children:[t.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:ar(ne.owner)}),t.jsx("span",{children:yt(ne.creation)})]}),t.jsx("div",{className:"mt-2 space-y-1",children:ne.changes.length>0?ne.changes.slice(0,6).map((_e,Ce)=>t.jsxs("div",{className:"text-xs text-gray-700 dark:text-gray-200",children:[t.jsx("span",{className:"font-medium",children:_e.field}),": ",_e.old_value," → ",_e.new_value]},`${ne.name}-${Ce}`)):t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 italic",children:"No field changes"})})]},ne.name)),oe.length>8&&t.jsx("button",{type:"button",onClick:()=>pe(!Be),className:"w-full text-xs text-blue-600 dark:text-blue-400 hover:underline",children:Be?"Show less":`Show all (${oe.length})`})]})})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-semibold text-gray-800 dark:text-white mb-3",children:"Workflow Actions"}),J.length===0?t.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:t.jsx("p",{className:"text-sm",children:"No workflow actions recorded yet"})}):t.jsx("div",{className:"space-y-3",children:J.map(ne=>t.jsx("div",{className:`rounded-lg p-3 border ${ne.action==="Approved"?"bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-800":ne.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 ${ne.action==="Approved"?"bg-green-100 dark:bg-green-900/30":ne.action==="Applied"?"bg-blue-100 dark:bg-blue-900/30":"bg-gray-100 dark:bg-gray-600"}`,children:ne.action==="Approved"?t.jsx(rf,{className:"text-green-600 dark:text-green-400 text-sm"}):t.jsx(Wo,{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 ${ne.action==="Approved"?"text-green-800 dark:text-green-300":ne.action==="Applied"?"text-blue-800 dark:text-blue-300":"text-gray-900 dark:text-white"}`,children:ne.action}),t.jsxs("div",{className:"flex items-center gap-1 mt-1 text-xs text-gray-500 dark:text-gray-400",children:[t.jsx(Yn,{className:"text-[10px]"}),t.jsx("span",{className:"truncate",children:ne.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(Ja,{className:"text-[10px]"}),t.jsx("span",{children:new Date(ne.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 ${ne.action==="Approved"?"text-green-600 dark:text-green-400":"text-blue-600 dark:text-blue-400"}`,children:ne.entriesCount})]}),ne.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(ne.completionDate).toLocaleDateString()})]})]})})]})]})},ne.id))})]})]})})]}),M&&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(Wo,{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:[fe.size," of ",ce.length," ",ce.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:_t,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:lr,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:ce.map((ne,_e)=>t.jsxs("label",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-all ${fe.has(ne.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:fe.has(ne.name),onChange:()=>nt(ne.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:_e+1}),t.jsxs("div",{className:"truncate",children:[t.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:ne.asset_display_name||ne.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:ne.name})]})]}),ne.due_date&&t.jsxs("div",{className:"ml-7 text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:["Due: ",new Date(ne.due_date).toLocaleDateString()]})]})]},ne.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:[fe.size," selected"]}),fe.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:F,onChange:ne=>z(ne.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"})]}),qe.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($o,{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(qe.next_pm_date).toLocaleDateString()})]})]})}),B&&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:W,onChange:ne=>X(ne.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:()=>{R(!1),z(""),X(""),K(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:pr,disabled:G||!F||fe.size===0||B&&!W.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(Ir,{className:"animate-spin"}),"Applying..."]}):t.jsxs(t.Fragment,{children:[t.jsx(Wo,{}),"Complete (",fe.size,")"]})})]})]})}),ke&&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(rf,{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:[ee.size," of ",te.length," ",te.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:_r,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:Nt,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:te.map((ne,_e)=>t.jsxs("label",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-all ${ee.has(ne.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:ee.has(ne.name),onChange:()=>rr(ne.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:_e+1}),t.jsxs("div",{className:"truncate",children:[t.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:ne.asset_display_name||ne.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:ne.name})]})]}),ne.completion_date&&t.jsxs("div",{className:"ml-7 text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:["Completed: ",new Date(ne.completion_date).toLocaleDateString()]})]})]},ne.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.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:()=>{ge(!1),ve(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:re,children:"Cancel"}),t.jsx("button",{onClick:Cr,disabled:re||ee.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:re?t.jsxs(t.Fragment,{children:[t.jsx(Ir,{className:"animate-spin"}),"Approving..."]}):t.jsxs(t.Fragment,{children:[t.jsx(rf,{}),"Approve (",ee.size,")"]})})]})]})}),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 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:()=>O(!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:y,children:"Cancel"}),t.jsx("button",{onClick:zt,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors",disabled:y,children:y?"Deleting...":"Delete"})]})]})})]})},P$=({month:e,year:r,filters:a={},viewType:s="maintenance-log",timeView:n="day-month"})=>{const{t:i}=Rr(),c=Na(),u=new Date,[h,g]=_.useState(e!=null?e:u.getMonth()),[y,w]=_.useState(r!=null?r:u.getFullYear()),[E,S]=_.useState(null),A=_.useRef(null);_.useEffect(()=>{const le=be=>{A.current&&!A.current.contains(be.target)&&S(null)};return E&&document.addEventListener("mousedown",le),()=>document.removeEventListener("mousedown",le)},[E]);const C=new Date(y,h,1).toISOString().split("T")[0],O=new Date(y,h+1,0).toISOString().split("T")[0],M=JSON.stringify(a),R=_.useMemo(()=>a,[M]),F=_.useMemo(()=>Te({due_date:["between",[C,O]]},R),[C,O,R]),z=_.useMemo(()=>({}),[]),W=_.useMemo(()=>({}),[]),{logs:X,loading:B}=Fg(s==="maintenance-log"?F:z,s==="maintenance-log"?1e3:0,0,"due_date asc"),{pmSchedules:Y,loading:G}=ub(s==="ppm-planner"?R:z,1e3,0,"creation desc",W),ie=s==="maintenance-log"?B:G,fe=_.useMemo(()=>s==="maintenance-log"?X.filter(le=>{if(!le.due_date)return!1;const be=new Date(le.due_date);return be.getMonth()===h&&be.getFullYear()===y}):Y.filter(le=>{const be=le.due_date||le.start_date;if(!be)return!1;const[Z,Le,Pe]=be.split("-").map(Number),Be=new Date(Z,Le-1,Pe);return Be.getMonth()===h&&Be.getFullYear()===y}),[X,Y,h,y,s]);_.useEffect(()=>{s==="ppm-planner"&&!G&&(console.log("=== PPM PLANNER DEBUG ==="),console.log("[MaintenanceCalendar] Viewing Month:",h+1,"Year:",y),console.log("[MaintenanceCalendar] Total PM Schedules fetched:",Y.length),console.log("[MaintenanceCalendar] Filtered for current month:",fe.length),console.log("========================="))},[s,Y,G,fe.length,h,y]);const K=(le,be)=>{const Z=new Date(be)<new Date&&le!=="Completed";switch(le){case"Completed":return"bg-green-500 text-white border-green-600";case"Planned":return Z?"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"}},ke=(le,be)=>{const Z=new Date(be)<new Date&&le!=="Completed";switch(le){case"Completed":return"bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-400";case"Planned":return Z?"bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-400":"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/40 dark:text-yellow-400";case"Overdue":return"bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-400";default:return"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-400"}},ge=(le,be)=>{const Z=new Date(be)<new Date&&le!=="Completed";return le==="Completed"?"bg-green-500":le==="Overdue"||Z?"bg-red-500":"bg-yellow-500"},re=new Date(y,h,1).getDay(),we=new Date(y,h+1,0).getDate(),ee=Array.from({length:we},(le,be)=>be+1),ve=le=>{S(null),le>0?h===11?(g(0),w(y+1)):g(h+1):h===0?(g(11),w(y-1)):g(h-1)},ce=le=>s==="maintenance-log"?fe.filter(be=>be.due_date?new Date(be.due_date).getDate()===le:!1):fe.filter(be=>{const Z=be.due_date||be.start_date;if(!Z)return!1;const[Le,Pe,Be]=Z.split("-").map(Number),pe=new Date(Le,Pe-1,Be);return pe.getDate()===le&&pe.getMonth()===h&&pe.getFullYear()===y}),ye=()=>{S(null),g(u.getMonth()),w(u.getFullYear())},te=(le,be,Z)=>{le.stopPropagation();const Le=le.currentTarget.getBoundingClientRect();S({day:be,items:Z,anchorRect:Le})},q=()=>{if(!E)return{};const{anchorRect:le}=E,be=320,Z=420,Le=8;let Pe=le.bottom+Le,Be=le.left;return Pe+Z>window.innerHeight-Le&&(Pe=le.top-Z-Le),Be+be>window.innerWidth-Le&&(Be=window.innerWidth-be-Le),Be<Le&&(Be=Le),{top:Pe,left:Be,width:be,maxHeight:Z}},J=[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")],ae=[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")],oe=E?new Date(y,h,E.day).toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric"}):"";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($o,{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:[J[h]," ",y]})]}),t.jsxs("div",{className:"flex gap-1 lg:gap-2",children:[t.jsx("button",{onClick:()=>ve(-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(dy,{})}),t.jsx("button",{onClick:ye,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:()=>ve(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(uy,{})})]})]}),ie?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:ae.map(le=>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:le},le))}),t.jsxs("div",{className:"grid grid-cols-7 gap-1 lg:gap-2 auto-rows-fr",children:[Array.from({length:re}).map((le,be)=>t.jsx("div",{className:"p-1 lg:p-2"},`empty-${be}`)),ee.map(le=>{const be=ce(le),Z=be.length-2,Le=le===u.getDate()&&h===u.getMonth()&&y===u.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 ${Le?"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 ${Le?"text-blue-700 dark:text-blue-300":"text-gray-700 dark:text-gray-300"}`,children:le}),t.jsxs("div",{className:"space-y-1 flex-1 overflow-hidden",children:[be.slice(0,2).map(Pe=>{if(s==="maintenance-log"){const Be=Pe,pe=new Date(Be.due_date||"")<new Date&&Be.maintenance_status!=="Completed";return t.jsxs("div",{onClick:()=>c(`/maintenance/${Be.name}`),className:`text-xs p-1 rounded border ${K(Be.maintenance_status||"Planned",Be.due_date||"")} truncate cursor-pointer hover:opacity-80 transition-opacity`,title:`${Be.asset_name||Be.name}${Be.custom_asset_names?` | ${Be.custom_asset_names}`:""} - ${Be.maintenance_status||"Planned"}${pe?` ${i("maintenanceCalendarPage.overdueInTooltip")}`:""} - ${i("maintenanceCalendarPage.clickToViewDetails")}`,children:[t.jsx("div",{className:"truncate font-medium text-xs",children:Be.asset_name||Be.name}),Be.custom_asset_names&&t.jsx("div",{className:"truncate text-[10px] opacity-85 leading-tight",children:Be.custom_asset_names})]},Be.name)}else{const Be=Pe,rt=Be.asset_name||Be["PM Name"]||null||Be.name||i("maintenanceCalendarPage.ppmPlannerDefault");return t.jsx("div",{onClick:()=>c(`/ppm-planner/${Be.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:`${Be.name}${Be.modality?` - ${Be.modality}`:""}${Be.hospital?` - ${Be.hospital}`:""} - ${i("maintenanceCalendarPage.clickToViewPpmPlanner")}`,children:t.jsx("div",{className:"truncate font-medium text-xs",children:rt})},Be.name)}}),Z>0&&t.jsxs("button",{onClick:Pe=>te(Pe,le,be),className:"w-full text-left text-xs text-blue-600 dark:text-blue-400 font-semibold hover:text-blue-800 dark:hover:text-blue-300 hover:underline transition-colors px-0.5 py-0.5 rounded",children:["+",Z," more"]})]})]},le)})]})]}),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:fe.filter(le=>le.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:fe.filter(le=>le.maintenance_status==="Planned"&&new Date(le.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:fe.filter(le=>new Date(le.due_date||"")<new Date&&le.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:fe.length}),t.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:i("maintenanceCalendarPage.summaryPpmPlanners")})]})})]})})]}),E&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[998] bg-black/20",onClick:()=>S(null)}),t.jsxs("div",{ref:A,className:"fixed z-[999] bg-white dark:bg-gray-800 rounded-xl shadow-2xl border border-gray-200 dark:border-gray-700 flex flex-col overflow-hidden",style:q(),children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-gray-700 flex-shrink-0 bg-gray-50 dark:bg-gray-700/50",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:oe}),t.jsxs("p",{className:"text-sm font-bold text-gray-800 dark:text-white mt-0.5",children:[E.items.length," ",s==="maintenance-log"?"Maintenance Tasks":"PPM Schedules"]})]}),t.jsx("button",{onClick:()=>S(null),className:"p-1.5 rounded-lg text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:t.jsx(Pt,{size:13})})]}),t.jsx("div",{className:"overflow-y-auto flex-1 p-2 space-y-1",children:E.items.map(le=>{if(s==="maintenance-log"){const be=le,Le=new Date(be.due_date||"")<new Date&&be.maintenance_status!=="Completed"&&be.maintenance_status!=="Overdue"?"Overdue":be.maintenance_status||"Planned";return t.jsx("button",{onClick:()=>{c(`/maintenance/${be.name}`),S(null)},className:"w-full text-left px-3 py-2.5 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors group border border-transparent hover:border-gray-200 dark:hover:border-gray-600",children:t.jsxs("div",{className:"flex items-start gap-2.5",children:[t.jsx("div",{className:`w-2 h-2 rounded-full mt-1.5 flex-shrink-0 ${ge(be.maintenance_status||"Planned",be.due_date||"")}`}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("p",{className:"text-xs font-semibold text-gray-800 dark:text-white group-hover:text-blue-600 dark:group-hover:text-blue-400 truncate flex items-center gap-1",children:[be.asset_name||be.name,t.jsx(ps,{size:9,className:"opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]}),be.custom_asset_names&&t.jsx("p",{className:"text-[10px] text-blue-600 dark:text-blue-400 truncate mt-0.5 font-medium",children:be.custom_asset_names}),t.jsx("p",{className:"text-[10px] text-gray-400 dark:text-gray-500 truncate mt-0.5",children:be.name}),t.jsx("span",{className:`inline-block mt-1 text-[10px] px-1.5 py-0.5 rounded font-semibold ${ke(be.maintenance_status||"Planned",be.due_date||"")}`,children:Le})]})]})},be.name)}else{const be=le,Le=be.asset_name||be["PM Name"]||null||be.name||"PPM Schedule";return t.jsx("button",{onClick:()=>{c(`/ppm-planner/${be.name}`),S(null)},className:"w-full text-left px-3 py-2.5 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors group border border-transparent hover:border-gray-200 dark:hover:border-gray-600",children:t.jsxs("div",{className:"flex items-start gap-2.5",children:[t.jsx("div",{className:"w-2 h-2 rounded-full mt-1.5 flex-shrink-0 bg-purple-500"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("p",{className:"text-xs font-semibold text-gray-800 dark:text-white group-hover:text-purple-600 dark:group-hover:text-purple-400 truncate flex items-center gap-1",children:[Le,t.jsx(ps,{size:9,className:"opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]}),t.jsx("p",{className:"text-[10px] text-gray-400 dark:text-gray-500 truncate mt-0.5",children:be.name}),(be.modality||be.hospital)&&t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400 mt-0.5 truncate",children:[be.modality,be.hospital].filter(Boolean).join(" · ")})]})]})},be.name)}})})]})]})]})},L$={docstatus:1,custom_delete_status:["!=","Deleted"]},l4=()=>{const{t:e}=Rr(),r=Na(),[a]=Sn(),[s,n]=_.useState(""),[i,c]=_.useState(""),[u,h]=_.useState(""),[g,y]=_.useState(""),[w,E]=_.useState(""),[S,A]=_.useState(""),[C,O]=_.useState(""),[M,R]=_.useState(""),[F,z]=_.useState(""),[W,X]=_.useState(!1);_.useEffect(()=>{const ce=a.get("hospital"),ye=a.get("status");ce&&n(ce),ye&&h(ye)},[a]);const[B,Y]=_.useState(null),[,G]=_.useState(!1);_.useEffect(()=>{me(null,null,function*(){try{const q=(yield(yield fetch("/api/method/frappe.auth.get_logged_user",{headers:{"X-Frappe-CSRF-Token":window.csrf_token||""},credentials:"include"})).json()).message;if(!q){Y(null),G(!0);return}const J=new URLSearchParams({doctype:"User Permission",fields:JSON.stringify(["for_value"]),filters:JSON.stringify([["user","=",q],["allow","=","Issue Type"]]),limit_page_length:"0"}),le=((yield(yield fetch(`/api/method/frappe.client.get_list?${J}`,{headers:{"X-Frappe-CSRF-Token":window.csrf_token||""},credentials:"include"})).json()).message||[]).map(Z=>Z.for_value).filter(Boolean),be=[...new Set(le)];be.length>0?(Y(be),A(be[0])):Y(null)}catch(ye){console.error("Failed to load user permissions for Issue Type",ye),Y(null)}finally{G(!0)}})},[]),_.useEffect(()=>{me(null,null,function*(){var ye;try{const J=(yield(yield fetch("/api/method/frappe.auth.get_logged_user",{headers:{"X-Frappe-CSRF-Token":window.csrf_token||""},credentials:"include"})).json()).message;if(!J)return;const oe=yield(yield fetch(`/api/resource/User/${encodeURIComponent(J)}?fields=["role_profile_name"]`,{headers:{"X-Frappe-CSRF-Token":window.csrf_token||""},credentials:"include"})).json();((ye=oe==null?void 0:oe.data)==null?void 0:ye.role_profile_name)==="Technician"&&(y(J),X(!0))}catch(te){console.error("Failed to check role_profile_name for assignee auto-set",te)}})},[]);const[ie,fe]=_.useState("maintenance-log"),[K,ke]=_.useState(!1),[ge,re]=_.useState(0);_.useEffect(()=>{const ce=[s,i,u,g,S,C,M,F,w].filter(Boolean).length;re(ce)},[s,i,u,g,S,C,M,F,w]);const we=()=>{n(""),c(""),h(""),W||y(""),E(""),A(""),O(""),R(""),z("")},ee=s||i||u||g,ve=_.useMemo(()=>{const ce={};return s&&(ce.custom_hospital_name=s),i&&(ce.custom_department=i),u&&(ce.maintenance_status=u),g&&(ce.task_assignee_email=g),S&&(ce.custom_technical_department=S),C&&(ce.asset_name=C),M&&(ce.custom_building=M),F&&(ce.name=["like",`%${F}%`]),w&&(ce.custom_asset_names=["like",`%${w}%`]),ce},[s,i,u,g,S,C,M,F,w]);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($o,{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.jsx("select",{value:ie,onChange:ce=>fe(ce.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.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:()=>ke(!K),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 ${ee?"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(Hs,{size:14}),t.jsx("span",{className:"hidden sm:inline",children:e("maintenanceCalendarPage.filters")}),ge>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:ge}),K?t.jsx(Mn,{size:12}):t.jsx(on,{size:12})]})]}),ie==="maintenance-log"&&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:"Yearly View"}),t.jsxs("button",{onClick:()=>r("/yearly-logs"),className:"px-3 md:px-4 py-1.5 md:py-2 bg-green-600 hover:bg-green-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:"Yearly Maintenance Logs View",children:[t.jsx($o,{size:14}),t.jsx("span",{className:"hidden sm:inline",children:"Yearly View"}),t.jsx("span",{className:"sm:hidden",children:"Yearly"})]})]})]})]}),K&&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 relative overflow-visible",children:[t.jsxs("div",{className:"relative z-10 lg:z-[46]",children:[t.jsx("label",{className:"block text-[11px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("PM Work Order ID")}),t.jsx("input",{type:"text",value:F,onChange:ce=>z(ce.target.value),placeholder:e("Search by ID"),className:"w-full px-2 py-1 text-xs 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"}),F&&t.jsx("button",{onClick:()=>z(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[49]",children:[t.jsx(hr,{label:e("Asset ID"),doctype:"Asset",value:C,onChange:ce=>O(ce),placeholder:e("All Assets"),compact:!0,usePortal:!0,filters:L$}),C&&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(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[47]",children:[t.jsx(hr,{label:e("Building"),doctype:"Building",value:M,onChange:ce=>R(ce),placeholder:e("All Buildings"),compact:!0,usePortal:!0}),M&&t.jsx("button",{onClick:()=>R(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[55]",children:[t.jsx(hr,{label:e("maintenanceCalendarPage.department"),doctype:"Department",value:i,onChange:ce=>c(ce),placeholder:e("maintenanceCalendarPage.allDepartments"),compact:!0,usePortal:!0}),i&&t.jsx("button",{onClick:()=>c(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{size:10})})]}),t.jsx("div",{className:"relative z-10 lg:z-[54]",children:B&&B.length>0?t.jsxs(t.Fragment,{children:[t.jsx("label",{className:"block text-[11px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("Technical Department")}),t.jsx("select",{value:S,onChange:ce=>A(ce.target.value),className:"w-full px-2 py-1 text-xs 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",children:B.map(ce=>t.jsx("option",{value:ce,children:ce},ce))})]}):t.jsxs(t.Fragment,{children:[t.jsx(hr,{label:e("Technical Department"),doctype:"Issue Type",value:S,onChange:ce=>A(ce),placeholder:e("All Technical Departments"),compact:!0,clearable:!1,usePortal:!0}),S&&t.jsx("button",{onClick:()=>A(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{size:10})})]})}),t.jsxs("div",{className:"relative z-10 lg:z-[50]",children:[t.jsx("label",{className:"block text-[11px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("maintenanceCalendarPage.status")}),t.jsxs("select",{value:u,onChange:ce=>h(ce.target.value),className:"w-full px-2 py-1 text-xs 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",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")})]}),u&&t.jsx("button",{onClick:()=>h(""),className:"absolute right-7 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(Pt,{size:10})})]}),t.jsx("div",{className:"relative z-10 lg:z-[50]",children:W?t.jsxs(t.Fragment,{children:[t.jsx("label",{className:"block text-[11px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("maintenanceCalendarPage.assignedTo")}),t.jsx("input",{type:"text",value:g,disabled:!0,className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400 cursor-not-allowed"})]}):t.jsxs(t.Fragment,{children:[t.jsx(hr,{label:e("maintenanceCalendarPage.assignedTo"),doctype:"User",value:g,onChange:ce=>y(ce),placeholder:e("maintenanceCalendarPage.allTechnicians"),compact:!0,usePortal:!0}),g&&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(Pt,{size:10})})]})}),t.jsxs("div",{className:"relative z-10 lg:z-[48]",children:[t.jsx("label",{className:"block text-[11px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:e("Asset Name")}),t.jsx("input",{type:"text",value:w,onChange:ce=>E(ce.target.value),placeholder:e("All Assets"),className:"w-full px-2 py-1 text-xs 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"}),w&&t.jsx("button",{onClick:()=>E(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{size:10})})]})]}),ee&&t.jsx("div",{className:"mt-3 flex justify-end",children:t.jsxs("button",{onClick:we,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(Pt,{}),e("maintenanceCalendarPage.clearFilters")]})})]})]}),t.jsx("div",{className:"flex-1 overflow-hidden px-3 pb-3 lg:px-4 lg:pb-4",children:t.jsx(P$,{filters:ve,viewType:ie,timeView:"day-month"})})]})},B$=()=>{const e=Na(),[r,a]=_.useState(2025),[s,n]=_.useState(2030),i=_.useMemo(()=>({}),[]),c=_.useMemo(()=>({}),[]),{pmSchedules:u,loading:h,error:g}=ub(i,1e3,0,"creation desc",c),y=(C,O,M,R,F)=>{const z=C.toLowerCase().trim(),W=O.getFullYear(),X=O.getMonth(),B=new Date(R,F,1),Y=new Date(R,F+1,0,23,59,59,999);if(B>M||Y<O)return!1;const G=(R-W)*12+(F-X);switch(z){case"daily":return B<=M&&Y>=O;case"weekly":return B<=M&&Y>=O;case"monthly":return G>=0&&B<=M;case"quarterly":return G>=0&&G%3===0&&B<=M;case"half-yearly":case"half yearly":return G>=0&&G%6===0&&B<=M;case"yearly":case"annually":return F===X&&B<=M&&B>=O;case"2 yearly":case"2-yearly":return G>=0&&G%24===0&&B<=M;case"3 yearly":case"3-yearly":return G>=0&&G%36===0&&B<=M;default:return B<=M&&Y>=O}},w=_.useMemo(()=>{const C={};for(let O=r;O<=s;O++){C[O]={};for(let M=0;M<12;M++)C[O][M]=[]}return u.forEach(O=>{let M=null,R=null;if(O.start_date){const[W,X,B]=O.start_date.split("-").map(Number)}if(O.end_date){const[W,X,B]=O.end_date.split("-").map(Number);M=new Date(W,X-1,B)}if(O.due_date){const[W,X,B]=O.due_date.split("-").map(Number);R=new Date(W,X-1,B)}if(!R)return;const F=M||R,z=O.periodicity||"monthly";for(let W=r;W<=s;W++)for(let X=0;X<12;X++)y(z,R,F,W,X)&&(C[W][X].some(Y=>Y.name===O.name)||C[W][X].push(O))}),C},[u,r,s]);_.useEffect(()=>{h||(console.log("[YearlyPPMPlannerPage] PM Schedules count:",u.length),console.log("[YearlyPPMPlannerPage] Matrix years:",r,"to",s))},[u,h,r,s]);const E=C=>{a(O=>O+C),n(O=>O+C)},S=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],A=Array.from({length:s-r+1},(C,O)=>r+O);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(Kn,{className:"text-gray-600 dark:text-gray-400",size:18})}),t.jsx($o,{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(uf,{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:()=>E(-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(dy,{})}),t.jsxs("h2",{className:"text-lg font-bold text-gray-800 dark:text-white",children:[r," - ",s]}),t.jsx("button",{onClick:()=>E(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(uy,{})})]})})}),t.jsx("div",{className:"flex-1 overflow-auto px-3 pb-3 lg:px-4 lg:pb-4",children:h?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..."})]}):g?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: ",g]})})}):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"}),S.map((C,O)=>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:C},O))]})}),t.jsx("tbody",{children:A.map(C=>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:C}),S.map((O,M)=>{var F;const R=((F=w[C])==null?void 0:F[M])||[];return t.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-2 py-2 align-top min-h-[60px]",children:R.length>0?t.jsx("div",{className:"space-y-1",children:R.map(z=>{const X=z.asset_name||z["PM Name"]||null||z.name||"PPM Planner",B=[];z.name&&B.push(z.name),z.modality&&B.push(z.modality),z.hospital&&B.push(z.hospital);const Y=B.length>0?`${B.join(" - ")} - Click to view details`:"Click to view details";return t.jsx("div",{onClick:()=>e(`/ppm-planner/${z.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:Y,children:t.jsx("div",{className:"font-medium text-blue-900 dark:text-blue-300 leading-tight group-hover:underline break-words",children:X})},z.name)})}):t.jsx("div",{className:"text-xs text-gray-300 dark:text-gray-700 text-center py-1",children:"-"})},M)})]},C))})]})})})})]})};function pS(e,r){const a=_.useRef(r);_.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 U$=1;function z$(e){return Object.freeze({__version:U$,map:e})}function W$(e,r){return Object.freeze(Te(Te({},e),r))}const fb=_.createContext(null);function hb(){const e=_.use(fb);if(e==null)throw new Error("No context provided: useLeafletContext() can only be used in a descendant of <MapContainer>");return e}function H$(e){function r(a,s){const{instance:n,context:i}=e(a).current;_.useImperativeHandle(s,()=>n);const{children:c}=a;return c==null?null:ea.createElement(fb,{value:i},c)}return _.forwardRef(r)}function $$(e){function r(a,s){const[n,i]=_.useState(!1),{instance:c}=e(a,i).current;_.useImperativeHandle(s,()=>c),_.useEffect(function(){n&&c.update()},[c,n,a.children]);const u=c._contentNode;return u?gg.createPortal(a.children,u):null}return _.forwardRef(r)}function V$(e){function r(a,s){const{instance:n}=e(a).current;return _.useImperativeHandle(s,()=>n),null}return _.forwardRef(r)}function yS(e,r){const a=_.useRef(void 0);_.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 mb(e,r){var s;const a=(s=e.pane)!=null?s:r.pane;return a?Ke(Te({},e),{pane:a}):e}function G$(e,r){return function(s,n){const i=hb(),c=e(mb(s,i),i);return pS(i.map,s.attribution),yS(c.current,s.eventHandlers),r(c.current,i,s,n),c}}var lf={exports:{}};var Y$=lf.exports,c4;function q$(){return c4||(c4=1,(function(e,r){(function(a,s){s(r)})(Y$,(function(a){var s="1.9.4";function n(m){var k,D,V,ue;for(D=1,V=arguments.length;D<V;D++){ue=arguments[D];for(k in ue)m[k]=ue[k]}return m}var i=Object.create||(function(){function m(){}return function(k){return m.prototype=k,new m}})();function c(m,k){var D=Array.prototype.slice;if(m.bind)return m.bind.apply(m,D.call(arguments,1));var V=D.call(arguments,2);return function(){return m.apply(k,V.length?V.concat(D.call(arguments)):arguments)}}var u=0;function h(m){return"_leaflet_id"in m||(m._leaflet_id=++u),m._leaflet_id}function g(m,k,D){var V,ue,Oe,st;return st=function(){V=!1,ue&&(Oe.apply(D,ue),ue=!1)},Oe=function(){V?ue=arguments:(m.apply(D,arguments),setTimeout(st,k),V=!0)},Oe}function y(m,k,D){var V=k[1],ue=k[0],Oe=V-ue;return m===V&&D?m:((m-ue)%Oe+Oe)%Oe+ue}function w(){return!1}function E(m,k){if(k===!1)return m;var D=Math.pow(10,k===void 0?6:k);return Math.round(m*D)/D}function S(m){return m.trim?m.trim():m.replace(/^\s+|\s+$/g,"")}function A(m){return S(m).split(/\s+/)}function C(m,k){Object.prototype.hasOwnProperty.call(m,"options")||(m.options=m.options?i(m.options):{});for(var D in k)m.options[D]=k[D];return m.options}function O(m,k,D){var V=[];for(var ue in m)V.push(encodeURIComponent(D?ue.toUpperCase():ue)+"="+encodeURIComponent(m[ue]));return(!k||k.indexOf("?")===-1?"?":"&")+V.join("&")}var M=/\{ *([\w_ -]+) *\}/g;function R(m,k){return m.replace(M,function(D,V){var ue=k[V];if(ue===void 0)throw new Error("No value provided for variable "+D);return typeof ue=="function"&&(ue=ue(k)),ue})}var F=Array.isArray||function(m){return Object.prototype.toString.call(m)==="[object Array]"};function z(m,k){for(var D=0;D<m.length;D++)if(m[D]===k)return D;return-1}var W="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";function X(m){return window["webkit"+m]||window["moz"+m]||window["ms"+m]}var B=0;function Y(m){var k=+new Date,D=Math.max(0,16-(k-B));return B=k+D,window.setTimeout(m,D)}var G=window.requestAnimationFrame||X("RequestAnimationFrame")||Y,ie=window.cancelAnimationFrame||X("CancelAnimationFrame")||X("CancelRequestAnimationFrame")||function(m){window.clearTimeout(m)};function fe(m,k,D){if(D&&G===Y)m.call(k);else return G.call(window,c(m,k))}function K(m){m&&ie.call(window,m)}var ke={__proto__:null,extend:n,create:i,bind:c,get lastId(){return u},stamp:h,throttle:g,wrapNum:y,falseFn:w,formatNum:E,trim:S,splitWords:A,setOptions:C,getParamString:O,template:R,isArray:F,indexOf:z,emptyImageUrl:W,requestFn:G,cancelFn:ie,requestAnimFrame:fe,cancelAnimFrame:K};function ge(){}ge.extend=function(m){var k=function(){C(this),this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()},D=k.__super__=this.prototype,V=i(D);V.constructor=k,k.prototype=V;for(var ue in this)Object.prototype.hasOwnProperty.call(this,ue)&&ue!=="prototype"&&ue!=="__super__"&&(k[ue]=this[ue]);return m.statics&&n(k,m.statics),m.includes&&(re(m.includes),n.apply(null,[V].concat(m.includes))),n(V,m),delete V.statics,delete V.includes,V.options&&(V.options=D.options?i(D.options):{},n(V.options,m.options)),V._initHooks=[],V.callInitHooks=function(){if(!this._initHooksCalled){D.callInitHooks&&D.callInitHooks.call(this),this._initHooksCalled=!0;for(var Oe=0,st=V._initHooks.length;Oe<st;Oe++)V._initHooks[Oe].call(this)}},k},ge.include=function(m){var k=this.prototype.options;return n(this.prototype,m),m.options&&(this.prototype.options=k,this.mergeOptions(m.options)),this},ge.mergeOptions=function(m){return n(this.prototype.options,m),this},ge.addInitHook=function(m){var k=Array.prototype.slice.call(arguments,1),D=typeof m=="function"?m:function(){this[m].apply(this,k)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(D),this};function re(m){if(!(typeof L=="undefined"||!L||!L.Mixin)){m=F(m)?m:[m];for(var k=0;k<m.length;k++)m[k]===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 we={on:function(m,k,D){if(typeof m=="object")for(var V in m)this._on(V,m[V],k);else{m=A(m);for(var ue=0,Oe=m.length;ue<Oe;ue++)this._on(m[ue],k,D)}return this},off:function(m,k,D){if(!arguments.length)delete this._events;else if(typeof m=="object")for(var V in m)this._off(V,m[V],k);else{m=A(m);for(var ue=arguments.length===1,Oe=0,st=m.length;Oe<st;Oe++)ue?this._off(m[Oe]):this._off(m[Oe],k,D)}return this},_on:function(m,k,D,V){if(typeof k!="function"){console.warn("wrong listener type: "+typeof k);return}if(this._listens(m,k,D)===!1){D===this&&(D=void 0);var ue={fn:k,ctx:D};V&&(ue.once=!0),this._events=this._events||{},this._events[m]=this._events[m]||[],this._events[m].push(ue)}},_off:function(m,k,D){var V,ue,Oe;if(this._events&&(V=this._events[m],!!V)){if(arguments.length===1){if(this._firingCount)for(ue=0,Oe=V.length;ue<Oe;ue++)V[ue].fn=w;delete this._events[m];return}if(typeof k!="function"){console.warn("wrong listener type: "+typeof k);return}var st=this._listens(m,k,D);if(st!==!1){var Et=V[st];this._firingCount&&(Et.fn=w,this._events[m]=V=V.slice()),V.splice(st,1)}}},fire:function(m,k,D){if(!this.listens(m,D))return this;var V=n({},k,{type:m,target:this,sourceTarget:k&&k.sourceTarget||this});if(this._events){var ue=this._events[m];if(ue){this._firingCount=this._firingCount+1||1;for(var Oe=0,st=ue.length;Oe<st;Oe++){var Et=ue[Oe],$t=Et.fn;Et.once&&this.off(m,$t,Et.ctx),$t.call(Et.ctx||this,V)}this._firingCount--}}return D&&this._propagateEvent(V),this},listens:function(m,k,D,V){typeof m!="string"&&console.warn('"string" type argument expected');var ue=k;typeof k!="function"&&(V=!!k,ue=void 0,D=void 0);var Oe=this._events&&this._events[m];if(Oe&&Oe.length&&this._listens(m,ue,D)!==!1)return!0;if(V){for(var st in this._eventParents)if(this._eventParents[st].listens(m,k,D,V))return!0}return!1},_listens:function(m,k,D){if(!this._events)return!1;var V=this._events[m]||[];if(!k)return!!V.length;D===this&&(D=void 0);for(var ue=0,Oe=V.length;ue<Oe;ue++)if(V[ue].fn===k&&V[ue].ctx===D)return ue;return!1},once:function(m,k,D){if(typeof m=="object")for(var V in m)this._on(V,m[V],k,!0);else{m=A(m);for(var ue=0,Oe=m.length;ue<Oe;ue++)this._on(m[ue],k,D,!0)}return this},addEventParent:function(m){return this._eventParents=this._eventParents||{},this._eventParents[h(m)]=m,this},removeEventParent:function(m){return this._eventParents&&delete this._eventParents[h(m)],this},_propagateEvent:function(m){for(var k in this._eventParents)this._eventParents[k].fire(m.type,n({layer:m.target,propagatedFrom:m.target},m),!0)}};we.addEventListener=we.on,we.removeEventListener=we.clearAllEventListeners=we.off,we.addOneTimeEventListener=we.once,we.fireEvent=we.fire,we.hasEventListeners=we.listens;var ee=ge.extend(we);function ve(m,k,D){this.x=D?Math.round(m):m,this.y=D?Math.round(k):k}var ce=Math.trunc||function(m){return m>0?Math.floor(m):Math.ceil(m)};ve.prototype={clone:function(){return new ve(this.x,this.y)},add:function(m){return this.clone()._add(ye(m))},_add:function(m){return this.x+=m.x,this.y+=m.y,this},subtract:function(m){return this.clone()._subtract(ye(m))},_subtract:function(m){return this.x-=m.x,this.y-=m.y,this},divideBy:function(m){return this.clone()._divideBy(m)},_divideBy:function(m){return this.x/=m,this.y/=m,this},multiplyBy:function(m){return this.clone()._multiplyBy(m)},_multiplyBy:function(m){return this.x*=m,this.y*=m,this},scaleBy:function(m){return new ve(this.x*m.x,this.y*m.y)},unscaleBy:function(m){return new ve(this.x/m.x,this.y/m.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=ce(this.x),this.y=ce(this.y),this},distanceTo:function(m){m=ye(m);var k=m.x-this.x,D=m.y-this.y;return Math.sqrt(k*k+D*D)},equals:function(m){return m=ye(m),m.x===this.x&&m.y===this.y},contains:function(m){return m=ye(m),Math.abs(m.x)<=Math.abs(this.x)&&Math.abs(m.y)<=Math.abs(this.y)},toString:function(){return"Point("+E(this.x)+", "+E(this.y)+")"}};function ye(m,k,D){return m instanceof ve?m:F(m)?new ve(m[0],m[1]):m==null?m:typeof m=="object"&&"x"in m&&"y"in m?new ve(m.x,m.y):new ve(m,k,D)}function te(m,k){if(m)for(var D=k?[m,k]:m,V=0,ue=D.length;V<ue;V++)this.extend(D[V])}te.prototype={extend:function(m){var k,D;if(!m)return this;if(m instanceof ve||typeof m[0]=="number"||"x"in m)k=D=ye(m);else if(m=q(m),k=m.min,D=m.max,!k||!D)return this;return!this.min&&!this.max?(this.min=k.clone(),this.max=D.clone()):(this.min.x=Math.min(k.x,this.min.x),this.max.x=Math.max(D.x,this.max.x),this.min.y=Math.min(k.y,this.min.y),this.max.y=Math.max(D.y,this.max.y)),this},getCenter:function(m){return ye((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,m)},getBottomLeft:function(){return ye(this.min.x,this.max.y)},getTopRight:function(){return ye(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(m){var k,D;return typeof m[0]=="number"||m instanceof ve?m=ye(m):m=q(m),m instanceof te?(k=m.min,D=m.max):k=D=m,k.x>=this.min.x&&D.x<=this.max.x&&k.y>=this.min.y&&D.y<=this.max.y},intersects:function(m){m=q(m);var k=this.min,D=this.max,V=m.min,ue=m.max,Oe=ue.x>=k.x&&V.x<=D.x,st=ue.y>=k.y&&V.y<=D.y;return Oe&&st},overlaps:function(m){m=q(m);var k=this.min,D=this.max,V=m.min,ue=m.max,Oe=ue.x>k.x&&V.x<D.x,st=ue.y>k.y&&V.y<D.y;return Oe&&st},isValid:function(){return!!(this.min&&this.max)},pad:function(m){var k=this.min,D=this.max,V=Math.abs(k.x-D.x)*m,ue=Math.abs(k.y-D.y)*m;return q(ye(k.x-V,k.y-ue),ye(D.x+V,D.y+ue))},equals:function(m){return m?(m=q(m),this.min.equals(m.getTopLeft())&&this.max.equals(m.getBottomRight())):!1}};function q(m,k){return!m||m instanceof te?m:new te(m,k)}function J(m,k){if(m)for(var D=k?[m,k]:m,V=0,ue=D.length;V<ue;V++)this.extend(D[V])}J.prototype={extend:function(m){var k=this._southWest,D=this._northEast,V,ue;if(m instanceof oe)V=m,ue=m;else if(m instanceof J){if(V=m._southWest,ue=m._northEast,!V||!ue)return this}else return m?this.extend(le(m)||ae(m)):this;return!k&&!D?(this._southWest=new oe(V.lat,V.lng),this._northEast=new oe(ue.lat,ue.lng)):(k.lat=Math.min(V.lat,k.lat),k.lng=Math.min(V.lng,k.lng),D.lat=Math.max(ue.lat,D.lat),D.lng=Math.max(ue.lng,D.lng)),this},pad:function(m){var k=this._southWest,D=this._northEast,V=Math.abs(k.lat-D.lat)*m,ue=Math.abs(k.lng-D.lng)*m;return new J(new oe(k.lat-V,k.lng-ue),new oe(D.lat+V,D.lng+ue))},getCenter:function(){return new oe((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 oe(this.getNorth(),this.getWest())},getSouthEast:function(){return new oe(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(m){typeof m[0]=="number"||m instanceof oe||"lat"in m?m=le(m):m=ae(m);var k=this._southWest,D=this._northEast,V,ue;return m instanceof J?(V=m.getSouthWest(),ue=m.getNorthEast()):V=ue=m,V.lat>=k.lat&&ue.lat<=D.lat&&V.lng>=k.lng&&ue.lng<=D.lng},intersects:function(m){m=ae(m);var k=this._southWest,D=this._northEast,V=m.getSouthWest(),ue=m.getNorthEast(),Oe=ue.lat>=k.lat&&V.lat<=D.lat,st=ue.lng>=k.lng&&V.lng<=D.lng;return Oe&&st},overlaps:function(m){m=ae(m);var k=this._southWest,D=this._northEast,V=m.getSouthWest(),ue=m.getNorthEast(),Oe=ue.lat>k.lat&&V.lat<D.lat,st=ue.lng>k.lng&&V.lng<D.lng;return Oe&&st},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(",")},equals:function(m,k){return m?(m=ae(m),this._southWest.equals(m.getSouthWest(),k)&&this._northEast.equals(m.getNorthEast(),k)):!1},isValid:function(){return!!(this._southWest&&this._northEast)}};function ae(m,k){return m instanceof J?m:new J(m,k)}function oe(m,k,D){if(isNaN(m)||isNaN(k))throw new Error("Invalid LatLng object: ("+m+", "+k+")");this.lat=+m,this.lng=+k,D!==void 0&&(this.alt=+D)}oe.prototype={equals:function(m,k){if(!m)return!1;m=le(m);var D=Math.max(Math.abs(this.lat-m.lat),Math.abs(this.lng-m.lng));return D<=(k===void 0?1e-9:k)},toString:function(m){return"LatLng("+E(this.lat,m)+", "+E(this.lng,m)+")"},distanceTo:function(m){return Z.distance(this,le(m))},wrap:function(){return Z.wrapLatLng(this)},toBounds:function(m){var k=180*m/40075017,D=k/Math.cos(Math.PI/180*this.lat);return ae([this.lat-k,this.lng-D],[this.lat+k,this.lng+D])},clone:function(){return new oe(this.lat,this.lng,this.alt)}};function le(m,k,D){return m instanceof oe?m:F(m)&&typeof m[0]!="object"?m.length===3?new oe(m[0],m[1],m[2]):m.length===2?new oe(m[0],m[1]):null:m==null?m:typeof m=="object"&&"lat"in m?new oe(m.lat,"lng"in m?m.lng:m.lon,m.alt):k===void 0?null:new oe(m,k,D)}var be={latLngToPoint:function(m,k){var D=this.projection.project(m),V=this.scale(k);return this.transformation._transform(D,V)},pointToLatLng:function(m,k){var D=this.scale(k),V=this.transformation.untransform(m,D);return this.projection.unproject(V)},project:function(m){return this.projection.project(m)},unproject:function(m){return this.projection.unproject(m)},scale:function(m){return 256*Math.pow(2,m)},zoom:function(m){return Math.log(m/256)/Math.LN2},getProjectedBounds:function(m){if(this.infinite)return null;var k=this.projection.bounds,D=this.scale(m),V=this.transformation.transform(k.min,D),ue=this.transformation.transform(k.max,D);return new te(V,ue)},infinite:!1,wrapLatLng:function(m){var k=this.wrapLng?y(m.lng,this.wrapLng,!0):m.lng,D=this.wrapLat?y(m.lat,this.wrapLat,!0):m.lat,V=m.alt;return new oe(D,k,V)},wrapLatLngBounds:function(m){var k=m.getCenter(),D=this.wrapLatLng(k),V=k.lat-D.lat,ue=k.lng-D.lng;if(V===0&&ue===0)return m;var Oe=m.getSouthWest(),st=m.getNorthEast(),Et=new oe(Oe.lat-V,Oe.lng-ue),$t=new oe(st.lat-V,st.lng-ue);return new J(Et,$t)}},Z=n({},be,{wrapLng:[-180,180],R:6371e3,distance:function(m,k){var D=Math.PI/180,V=m.lat*D,ue=k.lat*D,Oe=Math.sin((k.lat-m.lat)*D/2),st=Math.sin((k.lng-m.lng)*D/2),Et=Oe*Oe+Math.cos(V)*Math.cos(ue)*st*st,$t=2*Math.atan2(Math.sqrt(Et),Math.sqrt(1-Et));return this.R*$t}}),Le=6378137,Pe={R:Le,MAX_LATITUDE:85.0511287798,project:function(m){var k=Math.PI/180,D=this.MAX_LATITUDE,V=Math.max(Math.min(D,m.lat),-D),ue=Math.sin(V*k);return new ve(this.R*m.lng*k,this.R*Math.log((1+ue)/(1-ue))/2)},unproject:function(m){var k=180/Math.PI;return new oe((2*Math.atan(Math.exp(m.y/this.R))-Math.PI/2)*k,m.x*k/this.R)},bounds:(function(){var m=Le*Math.PI;return new te([-m,-m],[m,m])})()};function Be(m,k,D,V){if(F(m)){this._a=m[0],this._b=m[1],this._c=m[2],this._d=m[3];return}this._a=m,this._b=k,this._c=D,this._d=V}Be.prototype={transform:function(m,k){return this._transform(m.clone(),k)},_transform:function(m,k){return k=k||1,m.x=k*(this._a*m.x+this._b),m.y=k*(this._c*m.y+this._d),m},untransform:function(m,k){return k=k||1,new ve((m.x/k-this._b)/this._a,(m.y/k-this._d)/this._c)}};function pe(m,k,D,V){return new Be(m,k,D,V)}var rt=n({},Z,{code:"EPSG:3857",projection:Pe,transformation:(function(){var m=.5/(Math.PI*Pe.R);return pe(m,.5,-m,.5)})()}),ct=n({},rt,{code:"EPSG:900913"});function et(m){return document.createElementNS("http://www.w3.org/2000/svg",m)}function It(m,k){var D="",V,ue,Oe,st,Et,$t;for(V=0,Oe=m.length;V<Oe;V++){for(Et=m[V],ue=0,st=Et.length;ue<st;ue++)$t=Et[ue],D+=(ue?"L":"M")+$t.x+" "+$t.y;D+=k?Re.svg?"z":"x":""}return D||"M0 0"}var ft=document.documentElement.style,Lt="ActiveXObject"in window,Je=Lt&&!document.addEventListener,Ve="msLaunchUri"in navigator&&!("documentMode"in document),Xe=Kt("webkit"),Rt=Kt("android"),qe=Kt("android 2")||Kt("android 3"),Dt=parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1],10),ar=Rt&&Kt("Google")&&Dt<537&&!("AudioNode"in window),yt=!!window.opera,St=!Ve&&Kt("chrome"),Ot=Kt("gecko")&&!Xe&&!yt&&!Lt,Yt=!St&&Kt("safari"),Ye=Kt("phantom"),wt="OTransition"in ft,zt=navigator.platform.indexOf("Win")===0,qt=Lt&&"transition"in ft,kt="WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix&&!qe,ze="MozPerspective"in ft,nt=!window.L_DISABLE_3D&&(qt||kt||ze)&&!wt&&!Ye,_t=typeof orientation!="undefined"||Kt("mobile"),lr=_t&&Xe,pr=_t&&kt,Nr=!window.PointerEvent&&window.MSPointerEvent,rr=!!(window.PointerEvent||Nr),_r="ontouchstart"in window||!!window.TouchEvent,Nt=!window.L_NO_TOUCH&&(_r||rr),Cr=_t&&yt,yr=_t&&Ot,jt=(window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI)>1,Tt=(function(){var m=!1;try{var k=Object.defineProperty({},"passive",{get:function(){m=!0}});window.addEventListener("testPassiveEventSupport",w,k),window.removeEventListener("testPassiveEventSupport",w,k)}catch(D){}return m})(),He=(function(){return!!document.createElement("canvas").getContext})(),Fe=!!(document.createElementNS&&et("svg").createSVGRect),Ze=!!Fe&&(function(){var m=document.createElement("div");return m.innerHTML="<svg/>",(m.firstChild&&m.firstChild.namespaceURI)==="http://www.w3.org/2000/svg"})(),vt=!Fe&&(function(){try{var m=document.createElement("div");m.innerHTML='<v:shape adj="1"/>';var k=m.firstChild;return k.style.behavior="url(#default#VML)",k&&typeof k.adj=="object"}catch(D){return!1}})(),ir=navigator.platform.indexOf("Mac")===0,fr=navigator.platform.indexOf("Linux")===0;function Kt(m){return navigator.userAgent.toLowerCase().indexOf(m)>=0}var Re={ie:Lt,ielt9:Je,edge:Ve,webkit:Xe,android:Rt,android23:qe,androidStock:ar,opera:yt,chrome:St,gecko:Ot,safari:Yt,phantom:Ye,opera12:wt,win:zt,ie3d:qt,webkit3d:kt,gecko3d:ze,any3d:nt,mobile:_t,mobileWebkit:lr,mobileWebkit3d:pr,msPointer:Nr,pointer:rr,touch:Nt,touchNative:_r,mobileOpera:Cr,mobileGecko:yr,retina:jt,passiveEvents:Tt,canvas:He,svg:Fe,vml:vt,inlineSvg:Ze,mac:ir,linux:fr},Q=Re.msPointer?"MSPointerDown":"pointerdown",he=Re.msPointer?"MSPointerMove":"pointermove",Se=Re.msPointer?"MSPointerUp":"pointerup",ne=Re.msPointer?"MSPointerCancel":"pointercancel",_e={touchstart:Q,touchmove:he,touchend:Se,touchcancel:ne},Ce={touchstart:Zt,touchmove:Ft,touchend:Ft,touchcancel:Ft},Qe={},xt=!1;function dt(m,k,D){return k==="touchstart"&&Wt(),Ce[k]?(D=Ce[k].bind(this,D),m.addEventListener(_e[k],D,!1),D):(console.warn("wrong event specified:",k),w)}function at(m,k,D){if(!_e[k]){console.warn("wrong event specified:",k);return}m.removeEventListener(_e[k],D,!1)}function $e(m){Qe[m.pointerId]=m}function tt(m){Qe[m.pointerId]&&(Qe[m.pointerId]=m)}function gt(m){delete Qe[m.pointerId]}function Wt(){xt||(document.addEventListener(Q,$e,!0),document.addEventListener(he,tt,!0),document.addEventListener(Se,gt,!0),document.addEventListener(ne,gt,!0),xt=!0)}function Ft(m,k){if(k.pointerType!==(k.MSPOINTER_TYPE_MOUSE||"mouse")){k.touches=[];for(var D in Qe)k.touches.push(Qe[D]);k.changedTouches=[k],m(k)}}function Zt(m,k){k.MSPOINTER_TYPE_TOUCH&&k.pointerType===k.MSPOINTER_TYPE_TOUCH&&Qa(k),Ft(m,k)}function br(m){var k={},D,V;for(V in m)D=m[V],k[V]=D&&D.bind?D.bind(m):D;return m=k,k.type="dblclick",k.detail=2,k.isTrusted=!1,k._simulated=!0,k}var Ht=200;function fa(m,k){m.addEventListener("dblclick",k);var D=0,V;function ue(Oe){if(Oe.detail!==1){V=Oe.detail;return}if(!(Oe.pointerType==="mouse"||Oe.sourceCapabilities&&!Oe.sourceCapabilities.firesTouchEvents)){var st=Qn(Oe);if(!(st.some(function($t){return $t instanceof HTMLLabelElement&&$t.attributes.for})&&!st.some(function($t){return $t instanceof HTMLInputElement||$t instanceof HTMLSelectElement}))){var Et=Date.now();Et-D<=Ht?(V++,V===2&&k(br(Oe))):V=1,D=Et}}}return m.addEventListener("click",ue),{dblclick:k,simDblclick:ue}}function qr(m,k){m.removeEventListener("dblclick",k.dblclick),m.removeEventListener("click",k.simDblclick)}var vr=We(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),da=We(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),zr=da==="webkitTransition"||da==="OTransition"?da+"End":"transitionend";function Kr(m){return typeof m=="string"?document.getElementById(m):m}function Yr(m,k){var D=m.style[k]||m.currentStyle&&m.currentStyle[k];if((!D||D==="auto")&&document.defaultView){var V=document.defaultView.getComputedStyle(m,null);D=V?V[k]:null}return D==="auto"?null:D}function Gr(m,k,D){var V=document.createElement(m);return V.className=k||"",D&&D.appendChild(V),V}function Sa(m){var k=m.parentNode;k&&k.removeChild(m)}function Ps(m){for(;m.firstChild;)m.removeChild(m.firstChild)}function ha(m){var k=m.parentNode;k&&k.lastChild!==m&&k.appendChild(m)}function _s(m){var k=m.parentNode;k&&k.firstChild!==m&&k.insertBefore(m,k.firstChild)}function Wi(m,k){if(m.classList!==void 0)return m.classList.contains(k);var D=un(m);return D.length>0&&new RegExp("(^|\\s)"+k+"(\\s|$)").test(D)}function De(m,k){if(m.classList!==void 0)for(var D=A(k),V=0,ue=D.length;V<ue;V++)m.classList.add(D[V]);else if(!Wi(m,k)){var Oe=un(m);Cn(m,(Oe?Oe+" ":"")+k)}}function wr(m,k){m.classList!==void 0?m.classList.remove(k):Cn(m,S((" "+un(m)+" ").replace(" "+k+" "," ")))}function Cn(m,k){m.className.baseVal===void 0?m.className=k:m.className.baseVal=k}function un(m){return m.correspondingElement&&(m=m.correspondingElement),m.className.baseVal===void 0?m.className:m.className.baseVal}function Wr(m,k){"opacity"in m.style?m.style.opacity=k:"filter"in m.style&&mt(m,k)}function mt(m,k){var D=!1,V="DXImageTransform.Microsoft.Alpha";try{D=m.filters.item(V)}catch(ue){if(k===1)return}k=Math.round(k*100),D?(D.Enabled=k!==100,D.Opacity=k):m.style.filter+=" progid:"+V+"(opacity="+k+")"}function We(m){for(var k=document.documentElement.style,D=0;D<m.length;D++)if(m[D]in k)return m[D];return!1}function Me(m,k,D){var V=k||new ve(0,0);m.style[vr]=(Re.ie3d?"translate("+V.x+"px,"+V.y+"px)":"translate3d("+V.x+"px,"+V.y+"px,0)")+(D?" scale("+D+")":"")}function Qt(m,k){m._leaflet_pos=k,Re.any3d?Me(m,k):(m.style.left=k.x+"px",m.style.top=k.y+"px")}function Pr(m){return m._leaflet_pos||new ve(0,0)}var Oa,Va,fn;if("onselectstart"in document)Oa=function(){bt(window,"selectstart",Qa)},Va=function(){gr(window,"selectstart",Qa)};else{var Ea=We(["userSelect","WebkitUserSelect","OUserSelect","MozUserSelect","msUserSelect"]);Oa=function(){if(Ea){var m=document.documentElement.style;fn=m[Ea],m[Ea]="none"}},Va=function(){Ea&&(document.documentElement.style[Ea]=fn,fn=void 0)}}function xr(){bt(window,"dragstart",Qa)}function ua(){gr(window,"dragstart",Qa)}var Jn,mi;function hn(m){for(;m.tabIndex===-1;)m=m.parentNode;m.style&&(Ts(),Jn=m,mi=m.style.outlineStyle,m.style.outlineStyle="none",bt(window,"keydown",Ts))}function Ts(){Jn&&(Jn.style.outlineStyle=mi,Jn=void 0,mi=void 0,gr(window,"keydown",Ts))}function Ai(m){do m=m.parentNode;while((!m.offsetWidth||!m.offsetHeight)&&m!==document.body);return m}function Hi(m){var k=m.getBoundingClientRect();return{x:k.width/m.offsetWidth||1,y:k.height/m.offsetHeight||1,boundingClientRect:k}}var it={__proto__:null,TRANSFORM:vr,TRANSITION:da,TRANSITION_END:zr,get:Kr,getStyle:Yr,create:Gr,remove:Sa,empty:Ps,toFront:ha,toBack:_s,hasClass:Wi,addClass:De,removeClass:wr,setClass:Cn,getClass:un,setOpacity:Wr,testProp:We,setTransform:Me,setPosition:Qt,getPosition:Pr,get disableTextSelection(){return Oa},get enableTextSelection(){return Va},disableImageDrag:xr,enableImageDrag:ua,preventOutline:hn,restoreOutline:Ts,getSizedParentNode:Ai,getScale:Hi};function bt(m,k,D,V){if(k&&typeof k=="object")for(var ue in k)oa(m,ue,k[ue],D);else{k=A(k);for(var Oe=0,st=k.length;Oe<st;Oe++)oa(m,k[Oe],D,V)}return this}var Qr="_leaflet_events";function gr(m,k,D,V){if(arguments.length===1)En(m),delete m[Qr];else if(k&&typeof k=="object")for(var ue in k)gi(m,ue,k[ue],D);else if(k=A(k),arguments.length===2)En(m,function(Et){return z(k,Et)!==-1});else for(var Oe=0,st=k.length;Oe<st;Oe++)gi(m,k[Oe],D,V);return this}function En(m,k){for(var D in m[Qr]){var V=D.split(/\d/)[0];(!k||k(V))&&gi(m,V,null,null,D)}}var Lr={mouseenter:"mouseover",mouseleave:"mouseout",wheel:!("onwheel"in window)&&"mousewheel"};function oa(m,k,D,V){var ue=k+h(D)+(V?"_"+h(V):"");if(m[Qr]&&m[Qr][ue])return this;var Oe=function(Et){return D.call(V||m,Et||window.event)},st=Oe;!Re.touchNative&&Re.pointer&&k.indexOf("touch")===0?Oe=dt(m,k,Oe):Re.touch&&k==="dblclick"?Oe=fa(m,Oe):"addEventListener"in m?k==="touchstart"||k==="touchmove"||k==="wheel"||k==="mousewheel"?m.addEventListener(Lr[k]||k,Oe,Re.passiveEvents?{passive:!1}:!1):k==="mouseenter"||k==="mouseleave"?(Oe=function(Et){Et=Et||window.event,Ds(m,Et)&&st(Et)},m.addEventListener(Lr[k],Oe,!1)):m.addEventListener(k,st,!1):m.attachEvent("on"+k,Oe),m[Qr]=m[Qr]||{},m[Qr][ue]=Oe}function gi(m,k,D,V,ue){ue=ue||k+h(D)+(V?"_"+h(V):"");var Oe=m[Qr]&&m[Qr][ue];if(!Oe)return this;!Re.touchNative&&Re.pointer&&k.indexOf("touch")===0?at(m,k,Oe):Re.touch&&k==="dblclick"?qr(m,Oe):"removeEventListener"in m?m.removeEventListener(Lr[k]||k,Oe,!1):m.detachEvent("on"+k,Oe),m[Qr][ue]=null}function As(m){return m.stopPropagation?m.stopPropagation():m.originalEvent?m.originalEvent._stopped=!0:m.cancelBubble=!0,this}function Os(m){return oa(m,"wheel",As),this}function $s(m){return bt(m,"mousedown touchstart dblclick contextmenu",As),m._leaflet_disable_click=!0,this}function Qa(m){return m.preventDefault?m.preventDefault():m.returnValue=!1,this}function en(m){return Qa(m),As(m),this}function Qn(m){if(m.composedPath)return m.composedPath();for(var k=[],D=m.target;D;)k.push(D),D=D.parentNode;return k}function Bn(m,k){if(!k)return new ve(m.clientX,m.clientY);var D=Hi(k),V=D.boundingClientRect;return new ve((m.clientX-V.left)/D.x-k.clientLeft,(m.clientY-V.top)/D.y-k.clientTop)}var So=Re.linux&&Re.chrome?window.devicePixelRatio:Re.mac?window.devicePixelRatio*3:window.devicePixelRatio>0?2*window.devicePixelRatio:1;function cs(m){return Re.edge?m.wheelDeltaY/2:m.deltaY&&m.deltaMode===0?-m.deltaY/So:m.deltaY&&m.deltaMode===1?-m.deltaY*20:m.deltaY&&m.deltaMode===2?-m.deltaY*60:m.deltaX||m.deltaZ?0:m.wheelDelta?(m.wheelDeltaY||m.wheelDelta)/2:m.detail&&Math.abs(m.detail)<32765?-m.detail*20:m.detail?m.detail/-32765*60:0}function Ds(m,k){var D=k.relatedTarget;if(!D)return!0;try{for(;D&&D!==m;)D=D.parentNode}catch(V){return!1}return D!==m}var es={__proto__:null,on:bt,off:gr,stopPropagation:As,disableScrollPropagation:Os,disableClickPropagation:$s,preventDefault:Qa,stop:en,getPropagationPath:Qn,getMousePosition:Bn,getWheelDelta:cs,isExternalTarget:Ds,addListener:bt,removeListener:gr},ei=ee.extend({run:function(m,k,D,V){this.stop(),this._el=m,this._inProgress=!0,this._duration=D||.25,this._easeOutPower=1/Math.max(V||.5,.2),this._startPos=Pr(m),this._offset=k.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=fe(this._animate,this),this._step()},_step:function(m){var k=+new Date-this._startTime,D=this._duration*1e3;k<D?this._runFrame(this._easeOut(k/D),m):(this._runFrame(1),this._complete())},_runFrame:function(m,k){var D=this._startPos.add(this._offset.multiplyBy(m));k&&D._round(),Qt(this._el,D),this.fire("step")},_complete:function(){K(this._animId),this._inProgress=!1,this.fire("end")},_easeOut:function(m){return 1-Math.pow(1-m,this._easeOutPower)}}),ga=ee.extend({options:{crs:rt,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(m,k){k=C(this,k),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this._initContainer(m),this._initLayout(),this._onResize=c(this._onResize,this),this._initEvents(),k.maxBounds&&this.setMaxBounds(k.maxBounds),k.zoom!==void 0&&(this._zoom=this._limitZoom(k.zoom)),k.center&&k.zoom!==void 0&&this.setView(le(k.center),k.zoom,{reset:!0}),this.callInitHooks(),this._zoomAnimated=da&&Re.any3d&&!Re.mobileOpera&&this.options.zoomAnimation,this._zoomAnimated&&(this._createAnimProxy(),bt(this._proxy,zr,this._catchTransitionEnd,this)),this._addLayers(this.options.layers)},setView:function(m,k,D){if(k=k===void 0?this._zoom:this._limitZoom(k),m=this._limitCenter(le(m),k,this.options.maxBounds),D=D||{},this._stop(),this._loaded&&!D.reset&&D!==!0){D.animate!==void 0&&(D.zoom=n({animate:D.animate},D.zoom),D.pan=n({animate:D.animate,duration:D.duration},D.pan));var V=this._zoom!==k?this._tryAnimatedZoom&&this._tryAnimatedZoom(m,k,D.zoom):this._tryAnimatedPan(m,D.pan);if(V)return clearTimeout(this._sizeTimer),this}return this._resetView(m,k,D.pan&&D.pan.noMoveStart),this},setZoom:function(m,k){return this._loaded?this.setView(this.getCenter(),m,{zoom:k}):(this._zoom=m,this)},zoomIn:function(m,k){return m=m||(Re.any3d?this.options.zoomDelta:1),this.setZoom(this._zoom+m,k)},zoomOut:function(m,k){return m=m||(Re.any3d?this.options.zoomDelta:1),this.setZoom(this._zoom-m,k)},setZoomAround:function(m,k,D){var V=this.getZoomScale(k),ue=this.getSize().divideBy(2),Oe=m instanceof ve?m:this.latLngToContainerPoint(m),st=Oe.subtract(ue).multiplyBy(1-1/V),Et=this.containerPointToLatLng(ue.add(st));return this.setView(Et,k,{zoom:D})},_getBoundsCenterZoom:function(m,k){k=k||{},m=m.getBounds?m.getBounds():ae(m);var D=ye(k.paddingTopLeft||k.padding||[0,0]),V=ye(k.paddingBottomRight||k.padding||[0,0]),ue=this.getBoundsZoom(m,!1,D.add(V));if(ue=typeof k.maxZoom=="number"?Math.min(k.maxZoom,ue):ue,ue===1/0)return{center:m.getCenter(),zoom:ue};var Oe=V.subtract(D).divideBy(2),st=this.project(m.getSouthWest(),ue),Et=this.project(m.getNorthEast(),ue),$t=this.unproject(st.add(Et).divideBy(2).add(Oe),ue);return{center:$t,zoom:ue}},fitBounds:function(m,k){if(m=ae(m),!m.isValid())throw new Error("Bounds are not valid.");var D=this._getBoundsCenterZoom(m,k);return this.setView(D.center,D.zoom,k)},fitWorld:function(m){return this.fitBounds([[-90,-180],[90,180]],m)},panTo:function(m,k){return this.setView(m,this._zoom,{pan:k})},panBy:function(m,k){if(m=ye(m).round(),k=k||{},!m.x&&!m.y)return this.fire("moveend");if(k.animate!==!0&&!this.getSize().contains(m))return this._resetView(this.unproject(this.project(this.getCenter()).add(m)),this.getZoom()),this;if(this._panAnim||(this._panAnim=new ei,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),k.noMoveStart||this.fire("movestart"),k.animate!==!1){De(this._mapPane,"leaflet-pan-anim");var D=this._getMapPanePos().subtract(m).round();this._panAnim.run(this._mapPane,D,k.duration||.25,k.easeLinearity)}else this._rawPanBy(m),this.fire("move").fire("moveend");return this},flyTo:function(m,k,D){if(D=D||{},D.animate===!1||!Re.any3d)return this.setView(m,k,D);this._stop();var V=this.project(this.getCenter()),ue=this.project(m),Oe=this.getSize(),st=this._zoom;m=le(m),k=k===void 0?st:k;var Et=Math.max(Oe.x,Oe.y),$t=Et*this.getZoomScale(st,k),cr=ue.distanceTo(V)||1,Er=1.42,Vr=Er*Er;function va(Us){var el=Us?-1:1,$l=Us?$t:Et,gu=$t*$t-Et*Et+el*Vr*Vr*cr*cr,nd=2*$l*Vr*cr,id=gu/nd,kl=Math.sqrt(id*id+1)-id,tl=kl<1e-9?-18:Math.log(kl);return tl}function Dn(Us){return(Math.exp(Us)-Math.exp(-Us))/2}function Vs(Us){return(Math.exp(Us)+Math.exp(-Us))/2}function Ri(Us){return Dn(Us)/Vs(Us)}var Ga=va(0);function Ya(Us){return Et*(Vs(Ga)/Vs(Ga+Er*Us))}function Da(Us){return Et*(Vs(Ga)*Ri(Ga+Er*Us)-Dn(Ga))/Vr}function wl(Us){return 1-Math.pow(1-Us,1.5)}var Gi=Date.now(),t0=(va(1)-Ga)/Er,_l=D.duration?1e3*D.duration:1e3*t0*.8;function mu(){var Us=(Date.now()-Gi)/_l,el=wl(Us)*t0;Us<=1?(this._flyToFrame=fe(mu,this),this._move(this.unproject(V.add(ue.subtract(V).multiplyBy(Da(el)/cr)),st),this.getScaleZoom(Et/Ya(el),st),{flyTo:!0})):this._move(m,k)._moveEnd(!0)}return this._moveStart(!0,D.noMoveStart),mu.call(this),this},flyToBounds:function(m,k){var D=this._getBoundsCenterZoom(m,k);return this.flyTo(D.center,D.zoom,k)},setMaxBounds:function(m){return m=ae(m),this.listens("moveend",this._panInsideMaxBounds)&&this.off("moveend",this._panInsideMaxBounds),m.isValid()?(this.options.maxBounds=m,this._loaded&&this._panInsideMaxBounds(),this.on("moveend",this._panInsideMaxBounds)):(this.options.maxBounds=null,this)},setMinZoom:function(m){var k=this.options.minZoom;return this.options.minZoom=m,this._loaded&&k!==m&&(this.fire("zoomlevelschange"),this.getZoom()<this.options.minZoom)?this.setZoom(m):this},setMaxZoom:function(m){var k=this.options.maxZoom;return this.options.maxZoom=m,this._loaded&&k!==m&&(this.fire("zoomlevelschange"),this.getZoom()>this.options.maxZoom)?this.setZoom(m):this},panInsideBounds:function(m,k){this._enforcingBounds=!0;var D=this.getCenter(),V=this._limitCenter(D,this._zoom,ae(m));return D.equals(V)||this.panTo(V,k),this._enforcingBounds=!1,this},panInside:function(m,k){k=k||{};var D=ye(k.paddingTopLeft||k.padding||[0,0]),V=ye(k.paddingBottomRight||k.padding||[0,0]),ue=this.project(this.getCenter()),Oe=this.project(m),st=this.getPixelBounds(),Et=q([st.min.add(D),st.max.subtract(V)]),$t=Et.getSize();if(!Et.contains(Oe)){this._enforcingBounds=!0;var cr=Oe.subtract(Et.getCenter()),Er=Et.extend(Oe).getSize().subtract($t);ue.x+=cr.x<0?-Er.x:Er.x,ue.y+=cr.y<0?-Er.y:Er.y,this.panTo(this.unproject(ue),k),this._enforcingBounds=!1}return this},invalidateSize:function(m){if(!this._loaded)return this;m=n({animate:!1,pan:!0},m===!0?{animate:!0}:m);var k=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var D=this.getSize(),V=k.divideBy(2).round(),ue=D.divideBy(2).round(),Oe=V.subtract(ue);return!Oe.x&&!Oe.y?this:(m.animate&&m.pan?this.panBy(Oe):(m.pan&&this._rawPanBy(Oe),this.fire("move"),m.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(c(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:k,newSize:D}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(m){if(m=this._locateOptions=n({timeout:1e4,watch:!1},m),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var k=c(this._handleGeolocationResponse,this),D=c(this._handleGeolocationError,this);return m.watch?this._locationWatchId=navigator.geolocation.watchPosition(k,D,m):navigator.geolocation.getCurrentPosition(k,D,m),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(m){if(this._container._leaflet_id){var k=m.code,D=m.message||(k===1?"permission denied":k===2?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:k,message:"Geolocation error: "+D+"."})}},_handleGeolocationResponse:function(m){if(this._container._leaflet_id){var k=m.coords.latitude,D=m.coords.longitude,V=new oe(k,D),ue=V.toBounds(m.coords.accuracy*2),Oe=this._locateOptions;if(Oe.setView){var st=this.getBoundsZoom(ue);this.setView(V,Oe.maxZoom?Math.min(st,Oe.maxZoom):st)}var Et={latlng:V,bounds:ue,timestamp:m.timestamp};for(var $t in m.coords)typeof m.coords[$t]=="number"&&(Et[$t]=m.coords[$t]);this.fire("locationfound",Et)}},addHandler:function(m,k){if(!k)return this;var D=this[m]=new k(this);return this._handlers.push(D),this.options[m]&&D.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(k){this._container._leaflet_id=void 0,this._containerId=void 0}this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),Sa(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(K(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload");var m;for(m in this._layers)this._layers[m].remove();for(m in this._panes)Sa(this._panes[m]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(m,k){var D="leaflet-pane"+(m?" leaflet-"+m.replace("Pane","")+"-pane":""),V=Gr("div",D,k||this._mapPane);return m&&(this._panes[m]=V),V},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var m=this.getPixelBounds(),k=this.unproject(m.getBottomLeft()),D=this.unproject(m.getTopRight());return new J(k,D)},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(m,k,D){m=ae(m),D=ye(D||[0,0]);var V=this.getZoom()||0,ue=this.getMinZoom(),Oe=this.getMaxZoom(),st=m.getNorthWest(),Et=m.getSouthEast(),$t=this.getSize().subtract(D),cr=q(this.project(Et,V),this.project(st,V)).getSize(),Er=Re.any3d?this.options.zoomSnap:1,Vr=$t.x/cr.x,va=$t.y/cr.y,Dn=k?Math.max(Vr,va):Math.min(Vr,va);return V=this.getScaleZoom(Dn,V),Er&&(V=Math.round(V/(Er/100))*(Er/100),V=k?Math.ceil(V/Er)*Er:Math.floor(V/Er)*Er),Math.max(ue,Math.min(Oe,V))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new ve(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(m,k){var D=this._getTopLeftPoint(m,k);return new te(D,D.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(m){return this.options.crs.getProjectedBounds(m===void 0?this.getZoom():m)},getPane:function(m){return typeof m=="string"?this._panes[m]:m},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(m,k){var D=this.options.crs;return k=k===void 0?this._zoom:k,D.scale(m)/D.scale(k)},getScaleZoom:function(m,k){var D=this.options.crs;k=k===void 0?this._zoom:k;var V=D.zoom(m*D.scale(k));return isNaN(V)?1/0:V},project:function(m,k){return k=k===void 0?this._zoom:k,this.options.crs.latLngToPoint(le(m),k)},unproject:function(m,k){return k=k===void 0?this._zoom:k,this.options.crs.pointToLatLng(ye(m),k)},layerPointToLatLng:function(m){var k=ye(m).add(this.getPixelOrigin());return this.unproject(k)},latLngToLayerPoint:function(m){var k=this.project(le(m))._round();return k._subtract(this.getPixelOrigin())},wrapLatLng:function(m){return this.options.crs.wrapLatLng(le(m))},wrapLatLngBounds:function(m){return this.options.crs.wrapLatLngBounds(ae(m))},distance:function(m,k){return this.options.crs.distance(le(m),le(k))},containerPointToLayerPoint:function(m){return ye(m).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(m){return ye(m).add(this._getMapPanePos())},containerPointToLatLng:function(m){var k=this.containerPointToLayerPoint(ye(m));return this.layerPointToLatLng(k)},latLngToContainerPoint:function(m){return this.layerPointToContainerPoint(this.latLngToLayerPoint(le(m)))},mouseEventToContainerPoint:function(m){return Bn(m,this._container)},mouseEventToLayerPoint:function(m){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(m))},mouseEventToLatLng:function(m){return this.layerPointToLatLng(this.mouseEventToLayerPoint(m))},_initContainer:function(m){var k=this._container=Kr(m);if(k){if(k._leaflet_id)throw new Error("Map container is already initialized.")}else throw new Error("Map container not found.");bt(k,"scroll",this._onScroll,this),this._containerId=h(k)},_initLayout:function(){var m=this._container;this._fadeAnimated=this.options.fadeAnimation&&Re.any3d,De(m,"leaflet-container"+(Re.touch?" leaflet-touch":"")+(Re.retina?" leaflet-retina":"")+(Re.ielt9?" leaflet-oldie":"")+(Re.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var k=Yr(m,"position");k!=="absolute"&&k!=="relative"&&k!=="fixed"&&k!=="sticky"&&(m.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var m=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),Qt(this._mapPane,new ve(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(De(m.markerPane,"leaflet-zoom-hide"),De(m.shadowPane,"leaflet-zoom-hide"))},_resetView:function(m,k,D){Qt(this._mapPane,new ve(0,0));var V=!this._loaded;this._loaded=!0,k=this._limitZoom(k),this.fire("viewprereset");var ue=this._zoom!==k;this._moveStart(ue,D)._move(m,k)._moveEnd(ue),this.fire("viewreset"),V&&this.fire("load")},_moveStart:function(m,k){return m&&this.fire("zoomstart"),k||this.fire("movestart"),this},_move:function(m,k,D,V){k===void 0&&(k=this._zoom);var ue=this._zoom!==k;return this._zoom=k,this._lastCenter=m,this._pixelOrigin=this._getNewPixelOrigin(m),V?D&&D.pinch&&this.fire("zoom",D):((ue||D&&D.pinch)&&this.fire("zoom",D),this.fire("move",D)),this},_moveEnd:function(m){return m&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return K(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(m){Qt(this._mapPane,this._getMapPanePos().subtract(m))},_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(m){this._targets={},this._targets[h(this._container)]=this;var k=m?gr:bt;k(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&k(window,"resize",this._onResize,this),Re.any3d&&this.options.transform3DLimit&&(m?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){K(this._resizeRequest),this._resizeRequest=fe(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var m=this._getMapPanePos();Math.max(Math.abs(m.x),Math.abs(m.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(m,k){for(var D=[],V,ue=k==="mouseout"||k==="mouseover",Oe=m.target||m.srcElement,st=!1;Oe;){if(V=this._targets[h(Oe)],V&&(k==="click"||k==="preclick")&&this._draggableMoved(V)){st=!0;break}if(V&&V.listens(k,!0)&&(ue&&!Ds(Oe,m)||(D.push(V),ue))||Oe===this._container)break;Oe=Oe.parentNode}return!D.length&&!st&&!ue&&this.listens(k,!0)&&(D=[this]),D},_isClickDisabled:function(m){for(;m&&m!==this._container;){if(m._leaflet_disable_click)return!0;m=m.parentNode}},_handleDOMEvent:function(m){var k=m.target||m.srcElement;if(!(!this._loaded||k._leaflet_disable_events||m.type==="click"&&this._isClickDisabled(k))){var D=m.type;D==="mousedown"&&hn(k),this._fireDOMEvent(m,D)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(m,k,D){if(m.type==="click"){var V=n({},m);V.type="preclick",this._fireDOMEvent(V,V.type,D)}var ue=this._findEventTargets(m,k);if(D){for(var Oe=[],st=0;st<D.length;st++)D[st].listens(k,!0)&&Oe.push(D[st]);ue=Oe.concat(ue)}if(ue.length){k==="contextmenu"&&Qa(m);var Et=ue[0],$t={originalEvent:m};if(m.type!=="keypress"&&m.type!=="keydown"&&m.type!=="keyup"){var cr=Et.getLatLng&&(!Et._radius||Et._radius<=10);$t.containerPoint=cr?this.latLngToContainerPoint(Et.getLatLng()):this.mouseEventToContainerPoint(m),$t.layerPoint=this.containerPointToLayerPoint($t.containerPoint),$t.latlng=cr?Et.getLatLng():this.layerPointToLatLng($t.layerPoint)}for(st=0;st<ue.length;st++)if(ue[st].fire(k,$t,!0),$t.originalEvent._stopped||ue[st].options.bubblingMouseEvents===!1&&z(this._mouseEvents,k)!==-1)return}},_draggableMoved:function(m){return m=m.dragging&&m.dragging.enabled()?m:this,m.dragging&&m.dragging.moved()||this.boxZoom&&this.boxZoom.moved()},_clearHandlers:function(){for(var m=0,k=this._handlers.length;m<k;m++)this._handlers[m].disable()},whenReady:function(m,k){return this._loaded?m.call(k||this,{target:this}):this.on("load",m,k),this},_getMapPanePos:function(){return Pr(this._mapPane)||new ve(0,0)},_moved:function(){var m=this._getMapPanePos();return m&&!m.equals([0,0])},_getTopLeftPoint:function(m,k){var D=m&&k!==void 0?this._getNewPixelOrigin(m,k):this.getPixelOrigin();return D.subtract(this._getMapPanePos())},_getNewPixelOrigin:function(m,k){var D=this.getSize()._divideBy(2);return this.project(m,k)._subtract(D)._add(this._getMapPanePos())._round()},_latLngToNewLayerPoint:function(m,k,D){var V=this._getNewPixelOrigin(D,k);return this.project(m,k)._subtract(V)},_latLngBoundsToNewLayerBounds:function(m,k,D){var V=this._getNewPixelOrigin(D,k);return q([this.project(m.getSouthWest(),k)._subtract(V),this.project(m.getNorthWest(),k)._subtract(V),this.project(m.getSouthEast(),k)._subtract(V),this.project(m.getNorthEast(),k)._subtract(V)])},_getCenterLayerPoint:function(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))},_getCenterOffset:function(m){return this.latLngToLayerPoint(m).subtract(this._getCenterLayerPoint())},_limitCenter:function(m,k,D){if(!D)return m;var V=this.project(m,k),ue=this.getSize().divideBy(2),Oe=new te(V.subtract(ue),V.add(ue)),st=this._getBoundsOffset(Oe,D,k);return Math.abs(st.x)<=1&&Math.abs(st.y)<=1?m:this.unproject(V.add(st),k)},_limitOffset:function(m,k){if(!k)return m;var D=this.getPixelBounds(),V=new te(D.min.add(m),D.max.add(m));return m.add(this._getBoundsOffset(V,k))},_getBoundsOffset:function(m,k,D){var V=q(this.project(k.getNorthEast(),D),this.project(k.getSouthWest(),D)),ue=V.min.subtract(m.min),Oe=V.max.subtract(m.max),st=this._rebound(ue.x,-Oe.x),Et=this._rebound(ue.y,-Oe.y);return new ve(st,Et)},_rebound:function(m,k){return m+k>0?Math.round(m-k)/2:Math.max(0,Math.ceil(m))-Math.max(0,Math.floor(k))},_limitZoom:function(m){var k=this.getMinZoom(),D=this.getMaxZoom(),V=Re.any3d?this.options.zoomSnap:1;return V&&(m=Math.round(m/V)*V),Math.max(k,Math.min(D,m))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){wr(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(m,k){var D=this._getCenterOffset(m)._trunc();return(k&&k.animate)!==!0&&!this.getSize().contains(D)?!1:(this.panBy(D,k),!0)},_createAnimProxy:function(){var m=this._proxy=Gr("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(m),this.on("zoomanim",function(k){var D=vr,V=this._proxy.style[D];Me(this._proxy,this.project(k.center,k.zoom),this.getZoomScale(k.zoom,1)),V===this._proxy.style[D]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){Sa(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var m=this.getCenter(),k=this.getZoom();Me(this._proxy,this.project(m,k),this.getZoomScale(k,1))},_catchTransitionEnd:function(m){this._animatingZoom&&m.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(m,k,D){if(this._animatingZoom)return!0;if(D=D||{},!this._zoomAnimated||D.animate===!1||this._nothingToAnimate()||Math.abs(k-this._zoom)>this.options.zoomAnimationThreshold)return!1;var V=this.getZoomScale(k),ue=this._getCenterOffset(m)._divideBy(1-1/V);return D.animate!==!0&&!this.getSize().contains(ue)?!1:(fe(function(){this._moveStart(!0,D.noMoveStart||!1)._animateZoom(m,k,!0)},this),!0)},_animateZoom:function(m,k,D,V){this._mapPane&&(D&&(this._animatingZoom=!0,this._animateToCenter=m,this._animateToZoom=k,De(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:m,zoom:k,noUpdate:V}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(c(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&wr(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 ti(m,k){return new ga(m,k)}var Tn=ge.extend({options:{position:"topright"},initialize:function(m){C(this,m)},getPosition:function(){return this.options.position},setPosition:function(m){var k=this._map;return k&&k.removeControl(this),this.options.position=m,k&&k.addControl(this),this},getContainer:function(){return this._container},addTo:function(m){this.remove(),this._map=m;var k=this._container=this.onAdd(m),D=this.getPosition(),V=m._controlCorners[D];return De(k,"leaflet-control"),D.indexOf("bottom")!==-1?V.insertBefore(k,V.firstChild):V.appendChild(k),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(Sa(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(m){this._map&&m&&m.screenX>0&&m.screenY>0&&this._map.getContainer().focus()}}),Oi=function(m){return new Tn(m)};ga.include({addControl:function(m){return m.addTo(this),this},removeControl:function(m){return m.remove(),this},_initControlPos:function(){var m=this._controlCorners={},k="leaflet-",D=this._controlContainer=Gr("div",k+"control-container",this._container);function V(ue,Oe){var st=k+ue+" "+k+Oe;m[ue+Oe]=Gr("div",st,D)}V("top","left"),V("top","right"),V("bottom","left"),V("bottom","right")},_clearControlPos:function(){for(var m in this._controlCorners)Sa(this._controlCorners[m]);Sa(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var Zo=Tn.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(m,k,D,V){return D<V?-1:V<D?1:0}},initialize:function(m,k,D){C(this,D),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,this._preventClick=!1;for(var V in m)this._addLayer(m[V],V);for(V in k)this._addLayer(k[V],V,!0)},onAdd:function(m){this._initLayout(),this._update(),this._map=m,m.on("zoomend",this._checkDisabledLayers,this);for(var k=0;k<this._layers.length;k++)this._layers[k].layer.on("add remove",this._onLayerChange,this);return this._container},addTo:function(m){return Tn.prototype.addTo.call(this,m),this._expandIfNotCollapsed()},onRemove:function(){this._map.off("zoomend",this._checkDisabledLayers,this);for(var m=0;m<this._layers.length;m++)this._layers[m].layer.off("add remove",this._onLayerChange,this)},addBaseLayer:function(m,k){return this._addLayer(m,k),this._map?this._update():this},addOverlay:function(m,k){return this._addLayer(m,k,!0),this._map?this._update():this},removeLayer:function(m){m.off("add remove",this._onLayerChange,this);var k=this._getLayer(h(m));return k&&this._layers.splice(this._layers.indexOf(k),1),this._map?this._update():this},expand:function(){De(this._container,"leaflet-control-layers-expanded"),this._section.style.height=null;var m=this._map.getSize().y-(this._container.offsetTop+50);return m<this._section.clientHeight?(De(this._section,"leaflet-control-layers-scrollbar"),this._section.style.height=m+"px"):wr(this._section,"leaflet-control-layers-scrollbar"),this._checkDisabledLayers(),this},collapse:function(){return wr(this._container,"leaflet-control-layers-expanded"),this},_initLayout:function(){var m="leaflet-control-layers",k=this._container=Gr("div",m),D=this.options.collapsed;k.setAttribute("aria-haspopup",!0),$s(k),Os(k);var V=this._section=Gr("section",m+"-list");D&&(this._map.on("click",this.collapse,this),bt(k,{mouseenter:this._expandSafely,mouseleave:this.collapse},this));var ue=this._layersLink=Gr("a",m+"-toggle",k);ue.href="#",ue.title="Layers",ue.setAttribute("role","button"),bt(ue,{keydown:function(Oe){Oe.keyCode===13&&this._expandSafely()},click:function(Oe){Qa(Oe),this._expandSafely()}},this),D||this.expand(),this._baseLayersList=Gr("div",m+"-base",V),this._separator=Gr("div",m+"-separator",V),this._overlaysList=Gr("div",m+"-overlays",V),k.appendChild(V)},_getLayer:function(m){for(var k=0;k<this._layers.length;k++)if(this._layers[k]&&h(this._layers[k].layer)===m)return this._layers[k]},_addLayer:function(m,k,D){this._map&&m.on("add remove",this._onLayerChange,this),this._layers.push({layer:m,name:k,overlay:D}),this.options.sortLayers&&this._layers.sort(c(function(V,ue){return this.options.sortFunction(V.layer,ue.layer,V.name,ue.name)},this)),this.options.autoZIndex&&m.setZIndex&&(this._lastZIndex++,m.setZIndex(this._lastZIndex)),this._expandIfNotCollapsed()},_update:function(){if(!this._container)return this;Ps(this._baseLayersList),Ps(this._overlaysList),this._layerControlInputs=[];var m,k,D,V,ue=0;for(D=0;D<this._layers.length;D++)V=this._layers[D],this._addItem(V),k=k||V.overlay,m=m||!V.overlay,ue+=V.overlay?0:1;return this.options.hideSingleBase&&(m=m&&ue>1,this._baseLayersList.style.display=m?"":"none"),this._separator.style.display=k&&m?"":"none",this},_onLayerChange:function(m){this._handlingClick||this._update();var k=this._getLayer(h(m.target)),D=k.overlay?m.type==="add"?"overlayadd":"overlayremove":m.type==="add"?"baselayerchange":null;D&&this._map.fire(D,k)},_createRadioElement:function(m,k){var D='<input type="radio" class="leaflet-control-layers-selector" name="'+m+'"'+(k?' checked="checked"':"")+"/>",V=document.createElement("div");return V.innerHTML=D,V.firstChild},_addItem:function(m){var k=document.createElement("label"),D=this._map.hasLayer(m.layer),V;m.overlay?(V=document.createElement("input"),V.type="checkbox",V.className="leaflet-control-layers-selector",V.defaultChecked=D):V=this._createRadioElement("leaflet-base-layers_"+h(this),D),this._layerControlInputs.push(V),V.layerId=h(m.layer),bt(V,"click",this._onInputClick,this);var ue=document.createElement("span");ue.innerHTML=" "+m.name;var Oe=document.createElement("span");k.appendChild(Oe),Oe.appendChild(V),Oe.appendChild(ue);var st=m.overlay?this._overlaysList:this._baseLayersList;return st.appendChild(k),this._checkDisabledLayers(),k},_onInputClick:function(){if(!this._preventClick){var m=this._layerControlInputs,k,D,V=[],ue=[];this._handlingClick=!0;for(var Oe=m.length-1;Oe>=0;Oe--)k=m[Oe],D=this._getLayer(k.layerId).layer,k.checked?V.push(D):k.checked||ue.push(D);for(Oe=0;Oe<ue.length;Oe++)this._map.hasLayer(ue[Oe])&&this._map.removeLayer(ue[Oe]);for(Oe=0;Oe<V.length;Oe++)this._map.hasLayer(V[Oe])||this._map.addLayer(V[Oe]);this._handlingClick=!1,this._refocusOnMap()}},_checkDisabledLayers:function(){for(var m=this._layerControlInputs,k,D,V=this._map.getZoom(),ue=m.length-1;ue>=0;ue--)k=m[ue],D=this._getLayer(k.layerId).layer,k.disabled=D.options.minZoom!==void 0&&V<D.options.minZoom||D.options.maxZoom!==void 0&&V>D.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var m=this._section;this._preventClick=!0,bt(m,"click",Qa),this.expand();var k=this;setTimeout(function(){gr(m,"click",Qa),k._preventClick=!1})}}),Pa=function(m,k,D){return new Zo(m,k,D)},ri=Tn.extend({options:{position:"topleft",zoomInText:'<span aria-hidden="true">+</span>',zoomInTitle:"Zoom in",zoomOutText:'<span aria-hidden="true">&#x2212;</span>',zoomOutTitle:"Zoom out"},onAdd:function(m){var k="leaflet-control-zoom",D=Gr("div",k+" leaflet-bar"),V=this.options;return this._zoomInButton=this._createButton(V.zoomInText,V.zoomInTitle,k+"-in",D,this._zoomIn),this._zoomOutButton=this._createButton(V.zoomOutText,V.zoomOutTitle,k+"-out",D,this._zoomOut),this._updateDisabled(),m.on("zoomend zoomlevelschange",this._updateDisabled,this),D},onRemove:function(m){m.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(m){!this._disabled&&this._map._zoom<this._map.getMaxZoom()&&this._map.zoomIn(this._map.options.zoomDelta*(m.shiftKey?3:1))},_zoomOut:function(m){!this._disabled&&this._map._zoom>this._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(m.shiftKey?3:1))},_createButton:function(m,k,D,V,ue){var Oe=Gr("a",D,V);return Oe.innerHTML=m,Oe.href="#",Oe.title=k,Oe.setAttribute("role","button"),Oe.setAttribute("aria-label",k),$s(Oe),bt(Oe,"click",en),bt(Oe,"click",ue,this),bt(Oe,"click",this._refocusOnMap,this),Oe},_updateDisabled:function(){var m=this._map,k="leaflet-disabled";wr(this._zoomInButton,k),wr(this._zoomOutButton,k),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||m._zoom===m.getMinZoom())&&(De(this._zoomOutButton,k),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||m._zoom===m.getMaxZoom())&&(De(this._zoomInButton,k),this._zoomInButton.setAttribute("aria-disabled","true"))}});ga.mergeOptions({zoomControl:!0}),ga.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new ri,this.addControl(this.zoomControl))});var xl=function(m){return new ri(m)},mn=Tn.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(m){var k="leaflet-control-scale",D=Gr("div",k),V=this.options;return this._addScales(V,k+"-line",D),m.on(V.updateWhenIdle?"moveend":"move",this._update,this),m.whenReady(this._update,this),D},onRemove:function(m){m.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(m,k,D){m.metric&&(this._mScale=Gr("div",k,D)),m.imperial&&(this._iScale=Gr("div",k,D))},_update:function(){var m=this._map,k=m.getSize().y/2,D=m.distance(m.containerPointToLatLng([0,k]),m.containerPointToLatLng([this.options.maxWidth,k]));this._updateScales(D)},_updateScales:function(m){this.options.metric&&m&&this._updateMetric(m),this.options.imperial&&m&&this._updateImperial(m)},_updateMetric:function(m){var k=this._getRoundNum(m),D=k<1e3?k+" m":k/1e3+" km";this._updateScale(this._mScale,D,k/m)},_updateImperial:function(m){var k=m*3.2808399,D,V,ue;k>5280?(D=k/5280,V=this._getRoundNum(D),this._updateScale(this._iScale,V+" mi",V/D)):(ue=this._getRoundNum(k),this._updateScale(this._iScale,ue+" ft",ue/k))},_updateScale:function(m,k,D){m.style.width=Math.round(this.options.maxWidth*D)+"px",m.innerHTML=k},_getRoundNum:function(m){var k=Math.pow(10,(Math.floor(m)+"").length-1),D=m/k;return D=D>=10?10:D>=5?5:D>=3?3:D>=2?2:1,k*D}}),Co=function(m){return new mn(m)},Gt='<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>',na=Tn.extend({options:{position:"bottomright",prefix:'<a href="https://leafletjs.com" title="A JavaScript library for interactive maps">'+(Re.inlineSvg?Gt+" ":"")+"Leaflet</a>"},initialize:function(m){C(this,m),this._attributions={}},onAdd:function(m){m.attributionControl=this,this._container=Gr("div","leaflet-control-attribution"),$s(this._container);for(var k in m._layers)m._layers[k].getAttribution&&this.addAttribution(m._layers[k].getAttribution());return this._update(),m.on("layeradd",this._addAttribution,this),this._container},onRemove:function(m){m.off("layeradd",this._addAttribution,this)},_addAttribution:function(m){m.layer.getAttribution&&(this.addAttribution(m.layer.getAttribution()),m.layer.once("remove",function(){this.removeAttribution(m.layer.getAttribution())},this))},setPrefix:function(m){return this.options.prefix=m,this._update(),this},addAttribution:function(m){return m?(this._attributions[m]||(this._attributions[m]=0),this._attributions[m]++,this._update(),this):this},removeAttribution:function(m){return m?(this._attributions[m]&&(this._attributions[m]--,this._update()),this):this},_update:function(){if(this._map){var m=[];for(var k in this._attributions)this._attributions[k]&&m.push(k);var D=[];this.options.prefix&&D.push(this.options.prefix),m.length&&D.push(m.join(", ")),this._container.innerHTML=D.join(' <span aria-hidden="true">|</span> ')}}});ga.mergeOptions({attributionControl:!0}),ga.addInitHook(function(){this.options.attributionControl&&new na().addTo(this)});var Ls=function(m){return new na(m)};Tn.Layers=Zo,Tn.Zoom=ri,Tn.Scale=mn,Tn.Attribution=na,Oi.layers=Pa,Oi.zoom=xl,Oi.scale=Co,Oi.attribution=Ls;var An=ge.extend({initialize:function(m){this._map=m},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}});An.addTo=function(m,k){return m.addHandler(k,this),this};var pc={Events:we},Bl=Re.touch?"touchstart mousedown":"mousedown",$i=ee.extend({options:{clickTolerance:3},initialize:function(m,k,D,V){C(this,V),this._element=m,this._dragStartTarget=k||m,this._preventOutline=D},enable:function(){this._enabled||(bt(this._dragStartTarget,Bl,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&($i._dragging===this&&this.finishDrag(!0),gr(this._dragStartTarget,Bl,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(m){if(this._enabled&&(this._moved=!1,!Wi(this._element,"leaflet-zoom-anim"))){if(m.touches&&m.touches.length!==1){$i._dragging===this&&this.finishDrag();return}if(!($i._dragging||m.shiftKey||m.which!==1&&m.button!==1&&!m.touches)&&($i._dragging=this,this._preventOutline&&hn(this._element),xr(),Oa(),!this._moving)){this.fire("down");var k=m.touches?m.touches[0]:m,D=Ai(this._element);this._startPoint=new ve(k.clientX,k.clientY),this._startPos=Pr(this._element),this._parentScale=Hi(D);var V=m.type==="mousedown";bt(document,V?"mousemove":"touchmove",this._onMove,this),bt(document,V?"mouseup":"touchend touchcancel",this._onUp,this)}}},_onMove:function(m){if(this._enabled){if(m.touches&&m.touches.length>1){this._moved=!0;return}var k=m.touches&&m.touches.length===1?m.touches[0]:m,D=new ve(k.clientX,k.clientY)._subtract(this._startPoint);!D.x&&!D.y||Math.abs(D.x)+Math.abs(D.y)<this.options.clickTolerance||(D.x/=this._parentScale.x,D.y/=this._parentScale.y,Qa(m),this._moved||(this.fire("dragstart"),this._moved=!0,De(document.body,"leaflet-dragging"),this._lastTarget=m.target||m.srcElement,window.SVGElementInstance&&this._lastTarget instanceof window.SVGElementInstance&&(this._lastTarget=this._lastTarget.correspondingUseElement),De(this._lastTarget,"leaflet-drag-target")),this._newPos=this._startPos.add(D),this._moving=!0,this._lastEvent=m,this._updatePosition())}},_updatePosition:function(){var m={originalEvent:this._lastEvent};this.fire("predrag",m),Qt(this._element,this._newPos),this.fire("drag",m)},_onUp:function(){this._enabled&&this.finishDrag()},finishDrag:function(m){wr(document.body,"leaflet-dragging"),this._lastTarget&&(wr(this._lastTarget,"leaflet-drag-target"),this._lastTarget=null),gr(document,"mousemove touchmove",this._onMove,this),gr(document,"mouseup touchend touchcancel",this._onUp,this),ua(),Va();var k=this._moved&&this._moving;this._moving=!1,$i._dragging=!1,k&&this.fire("dragend",{noInertia:m,distance:this._newPos.distanceTo(this._startPos)})}});function yc(m,k,D){var V,ue=[1,4,2,8],Oe,st,Et,$t,cr,Er,Vr,va;for(Oe=0,Er=m.length;Oe<Er;Oe++)m[Oe]._code=Vi(m[Oe],k);for(Et=0;Et<4;Et++){for(Vr=ue[Et],V=[],Oe=0,Er=m.length,st=Er-1;Oe<Er;st=Oe++)$t=m[Oe],cr=m[st],$t._code&Vr?cr._code&Vr||(va=zn(cr,$t,Vr,k,D),va._code=Vi(va,k),V.push(va)):(cr._code&Vr&&(va=zn(cr,$t,Vr,k,D),va._code=Vi(va,k),V.push(va)),V.push($t));m=V}return m}function pl(m,k){var D,V,ue,Oe,st,Et,$t,cr,Er;if(!m||m.length===0)throw new Error("latlngs not passed");On(m)||(console.warn("latlngs are not flat! Only the first ring will be used"),m=m[0]);var Vr=le([0,0]),va=ae(m),Dn=va.getNorthWest().distanceTo(va.getSouthWest())*va.getNorthEast().distanceTo(va.getNorthWest());Dn<1700&&(Vr=ts(m));var Vs=m.length,Ri=[];for(D=0;D<Vs;D++){var Ga=le(m[D]);Ri.push(k.project(le([Ga.lat-Vr.lat,Ga.lng-Vr.lng])))}for(Et=$t=cr=0,D=0,V=Vs-1;D<Vs;V=D++)ue=Ri[D],Oe=Ri[V],st=ue.y*Oe.x-Oe.y*ue.x,$t+=(ue.x+Oe.x)*st,cr+=(ue.y+Oe.y)*st,Et+=st*3;Et===0?Er=Ri[0]:Er=[$t/Et,cr/Et];var Ya=k.unproject(ye(Er));return le([Ya.lat+Vr.lat,Ya.lng+Vr.lng])}function ts(m){for(var k=0,D=0,V=0,ue=0;ue<m.length;ue++){var Oe=le(m[ue]);k+=Oe.lat,D+=Oe.lng,V++}return le([k/V,D/V])}var Ko={__proto__:null,clipPolygon:yc,polygonCenter:pl,centroid:ts};function rs(m,k){if(!k||!m.length)return m.slice();var D=k*k;return m=bc(m,D),m=za(m,D),m}function Jo(m,k,D){return Math.sqrt(oo(m,k,D,!0))}function io(m,k,D){return oo(m,k,D)}function za(m,k){var D=m.length,V=typeof Uint8Array!="undefined"?Uint8Array:Array,ue=new V(D);ue[0]=ue[D-1]=1,$r(m,ue,k,0,D-1);var Oe,st=[];for(Oe=0;Oe<D;Oe++)ue[Oe]&&st.push(m[Oe]);return st}function $r(m,k,D,V,ue){var Oe=0,st,Et,$t;for(Et=V+1;Et<=ue-1;Et++)$t=oo(m[Et],m[V],m[ue],!0),$t>Oe&&(st=Et,Oe=$t);Oe>D&&(k[st]=1,$r(m,k,D,V,st),$r(m,k,D,st,ue))}function bc(m,k){for(var D=[m[0]],V=1,ue=0,Oe=m.length;V<Oe;V++)ai(m[V],m[ue])>k&&(D.push(m[V]),ue=V);return ue<Oe-1&&D.push(m[Oe-1]),D}var Wa;function Un(m,k,D,V,ue){var Oe=V?Wa:Vi(m,D),st=Vi(k,D),Et,$t,cr;for(Wa=st;;){if(!(Oe|st))return[m,k];if(Oe&st)return!1;Et=Oe||st,$t=zn(m,k,Et,D,ue),cr=Vi($t,D),Et===Oe?(m=$t,Oe=cr):(k=$t,st=cr)}}function zn(m,k,D,V,ue){var Oe=k.x-m.x,st=k.y-m.y,Et=V.min,$t=V.max,cr,Er;return D&8?(cr=m.x+Oe*($t.y-m.y)/st,Er=$t.y):D&4?(cr=m.x+Oe*(Et.y-m.y)/st,Er=Et.y):D&2?(cr=$t.x,Er=m.y+st*($t.x-m.x)/Oe):D&1&&(cr=Et.x,Er=m.y+st*(Et.x-m.x)/Oe),new ve(cr,Er,ue)}function Vi(m,k){var D=0;return m.x<k.min.x?D|=1:m.x>k.max.x&&(D|=2),m.y<k.min.y?D|=4:m.y>k.max.y&&(D|=8),D}function ai(m,k){var D=k.x-m.x,V=k.y-m.y;return D*D+V*V}function oo(m,k,D,V){var ue=k.x,Oe=k.y,st=D.x-ue,Et=D.y-Oe,$t=st*st+Et*Et,cr;return $t>0&&(cr=((m.x-ue)*st+(m.y-Oe)*Et)/$t,cr>1?(ue=D.x,Oe=D.y):cr>0&&(ue+=st*cr,Oe+=Et*cr)),st=m.x-ue,Et=m.y-Oe,V?st*st+Et*Et:new ve(ue,Oe)}function On(m){return!F(m[0])||typeof m[0][0]!="object"&&typeof m[0][0]!="undefined"}function Eo(m){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),On(m)}function lo(m,k){var D,V,ue,Oe,st,Et,$t,cr;if(!m||m.length===0)throw new Error("latlngs not passed");On(m)||(console.warn("latlngs are not flat! Only the first ring will be used"),m=m[0]);var Er=le([0,0]),Vr=ae(m),va=Vr.getNorthWest().distanceTo(Vr.getSouthWest())*Vr.getNorthEast().distanceTo(Vr.getNorthWest());va<1700&&(Er=ts(m));var Dn=m.length,Vs=[];for(D=0;D<Dn;D++){var Ri=le(m[D]);Vs.push(k.project(le([Ri.lat-Er.lat,Ri.lng-Er.lng])))}for(D=0,V=0;D<Dn-1;D++)V+=Vs[D].distanceTo(Vs[D+1])/2;if(V===0)cr=Vs[0];else for(D=0,Oe=0;D<Dn-1;D++)if(st=Vs[D],Et=Vs[D+1],ue=st.distanceTo(Et),Oe+=ue,Oe>V){$t=(Oe-V)/ue,cr=[Et.x-$t*(Et.x-st.x),Et.y-$t*(Et.y-st.y)];break}var Ga=k.unproject(ye(cr));return le([Ga.lat+Er.lat,Ga.lng+Er.lng])}var vc={__proto__:null,simplify:rs,pointToSegmentDistance:Jo,closestPointOnSegment:io,clipSegment:Un,_getEdgeIntersection:zn,_getBitCode:Vi,_sqClosestPointOnSegment:oo,isFlat:On,_flat:Eo,polylineCenter:lo},yl={project:function(m){return new ve(m.lng,m.lat)},unproject:function(m){return new oe(m.y,m.x)},bounds:new te([-180,-90],[180,90])},xi={R:6378137,R_MINOR:6356752314245179e-9,bounds:new te([-2003750834279e-5,-1549657073972e-5],[2003750834279e-5,1876465623138e-5]),project:function(m){var k=Math.PI/180,D=this.R,V=m.lat*k,ue=this.R_MINOR/D,Oe=Math.sqrt(1-ue*ue),st=Oe*Math.sin(V),Et=Math.tan(Math.PI/4-V/2)/Math.pow((1-st)/(1+st),Oe/2);return V=-D*Math.log(Math.max(Et,1e-10)),new ve(m.lng*k*D,V)},unproject:function(m){for(var k=180/Math.PI,D=this.R,V=this.R_MINOR/D,ue=Math.sqrt(1-V*V),Oe=Math.exp(-m.y/D),st=Math.PI/2-2*Math.atan(Oe),Et=0,$t=.1,cr;Et<15&&Math.abs($t)>1e-7;Et++)cr=ue*Math.sin(st),cr=Math.pow((1-cr)/(1+cr),ue/2),$t=Math.PI/2-2*Math.atan(Oe*cr)-st,st+=$t;return new oe(st*k,m.x*k/D)}},ds={__proto__:null,LonLat:yl,Mercator:xi,SphericalMercator:Pe},Ul=n({},Z,{code:"EPSG:3395",projection:xi,transformation:(function(){var m=.5/(Math.PI*xi.R);return pe(m,.5,-m,.5)})()}),co=n({},Z,{code:"EPSG:4326",projection:yl,transformation:pe(1/180,1,-1/180,.5)}),To=n({},be,{projection:yl,transformation:pe(1,0,-1,0),scale:function(m){return Math.pow(2,m)},zoom:function(m){return Math.log(m)/Math.LN2},distance:function(m,k){var D=k.lng-m.lng,V=k.lat-m.lat;return Math.sqrt(D*D+V*V)},infinite:!0});be.Earth=Z,be.EPSG3395=Ul,be.EPSG3857=rt,be.EPSG900913=ct,be.EPSG4326=co,be.Simple=To;var Rs=ee.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(m){return m.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(m){return m&&m.removeLayer(this),this},getPane:function(m){return this._map.getPane(m?this.options[m]||m:this.options.pane)},addInteractiveTarget:function(m){return this._map._targets[h(m)]=this,this},removeInteractiveTarget:function(m){return delete this._map._targets[h(m)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(m){var k=m.target;if(k.hasLayer(this)){if(this._map=k,this._zoomAnimated=k._zoomAnimated,this.getEvents){var D=this.getEvents();k.on(D,this),this.once("remove",function(){k.off(D,this)},this)}this.onAdd(k),this.fire("add"),k.fire("layeradd",{layer:this})}}});ga.include({addLayer:function(m){if(!m._layerAdd)throw new Error("The provided object is not a Layer.");var k=h(m);return this._layers[k]?this:(this._layers[k]=m,m._mapToAdd=this,m.beforeAdd&&m.beforeAdd(this),this.whenReady(m._layerAdd,m),this)},removeLayer:function(m){var k=h(m);return this._layers[k]?(this._loaded&&m.onRemove(this),delete this._layers[k],this._loaded&&(this.fire("layerremove",{layer:m}),m.fire("remove")),m._map=m._mapToAdd=null,this):this},hasLayer:function(m){return h(m)in this._layers},eachLayer:function(m,k){for(var D in this._layers)m.call(k,this._layers[D]);return this},_addLayers:function(m){m=m?F(m)?m:[m]:[];for(var k=0,D=m.length;k<D;k++)this.addLayer(m[k])},_addZoomLimit:function(m){(!isNaN(m.options.maxZoom)||!isNaN(m.options.minZoom))&&(this._zoomBoundLayers[h(m)]=m,this._updateZoomLevels())},_removeZoomLimit:function(m){var k=h(m);this._zoomBoundLayers[k]&&(delete this._zoomBoundLayers[k],this._updateZoomLevels())},_updateZoomLevels:function(){var m=1/0,k=-1/0,D=this._getZoomSpan();for(var V in this._zoomBoundLayers){var ue=this._zoomBoundLayers[V].options;m=ue.minZoom===void 0?m:Math.min(m,ue.minZoom),k=ue.maxZoom===void 0?k:Math.max(k,ue.maxZoom)}this._layersMaxZoom=k===-1/0?void 0:k,this._layersMinZoom=m===1/0?void 0:m,D!==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 Di=Rs.extend({initialize:function(m,k){C(this,k),this._layers={};var D,V;if(m)for(D=0,V=m.length;D<V;D++)this.addLayer(m[D])},addLayer:function(m){var k=this.getLayerId(m);return this._layers[k]=m,this._map&&this._map.addLayer(m),this},removeLayer:function(m){var k=m in this._layers?m:this.getLayerId(m);return this._map&&this._layers[k]&&this._map.removeLayer(this._layers[k]),delete this._layers[k],this},hasLayer:function(m){var k=typeof m=="number"?m:this.getLayerId(m);return k in this._layers},clearLayers:function(){return this.eachLayer(this.removeLayer,this)},invoke:function(m){var k=Array.prototype.slice.call(arguments,1),D,V;for(D in this._layers)V=this._layers[D],V[m]&&V[m].apply(V,k);return this},onAdd:function(m){this.eachLayer(m.addLayer,m)},onRemove:function(m){this.eachLayer(m.removeLayer,m)},eachLayer:function(m,k){for(var D in this._layers)m.call(k,this._layers[D]);return this},getLayer:function(m){return this._layers[m]},getLayers:function(){var m=[];return this.eachLayer(m.push,m),m},setZIndex:function(m){return this.invoke("setZIndex",m)},getLayerId:function(m){return h(m)}}),Wn=function(m,k){return new Di(m,k)},si=Di.extend({addLayer:function(m){return this.hasLayer(m)?this:(m.addEventParent(this),Di.prototype.addLayer.call(this,m),this.fire("layeradd",{layer:m}))},removeLayer:function(m){return this.hasLayer(m)?(m in this._layers&&(m=this._layers[m]),m.removeEventParent(this),Di.prototype.removeLayer.call(this,m),this.fire("layerremove",{layer:m})):this},setStyle:function(m){return this.invoke("setStyle",m)},bringToFront:function(){return this.invoke("bringToFront")},bringToBack:function(){return this.invoke("bringToBack")},getBounds:function(){var m=new J;for(var k in this._layers){var D=this._layers[k];m.extend(D.getBounds?D.getBounds():D.getLatLng())}return m}}),ni=function(m,k){return new si(m,k)},pi=ge.extend({options:{popupAnchor:[0,0],tooltipAnchor:[0,0],crossOrigin:!1},initialize:function(m){C(this,m)},createIcon:function(m){return this._createIcon("icon",m)},createShadow:function(m){return this._createIcon("shadow",m)},_createIcon:function(m,k){var D=this._getIconUrl(m);if(!D){if(m==="icon")throw new Error("iconUrl not set in Icon options (see the docs).");return null}var V=this._createImg(D,k&&k.tagName==="IMG"?k:null);return this._setIconStyles(V,m),(this.options.crossOrigin||this.options.crossOrigin==="")&&(V.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),V},_setIconStyles:function(m,k){var D=this.options,V=D[k+"Size"];typeof V=="number"&&(V=[V,V]);var ue=ye(V),Oe=ye(k==="shadow"&&D.shadowAnchor||D.iconAnchor||ue&&ue.divideBy(2,!0));m.className="leaflet-marker-"+k+" "+(D.className||""),Oe&&(m.style.marginLeft=-Oe.x+"px",m.style.marginTop=-Oe.y+"px"),ue&&(m.style.width=ue.x+"px",m.style.height=ue.y+"px")},_createImg:function(m,k){return k=k||document.createElement("img"),k.src=m,k},_getIconUrl:function(m){return Re.retina&&this.options[m+"RetinaUrl"]||this.options[m+"Url"]}});function yi(m){return new pi(m)}var Qo=pi.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(m){return typeof Qo.imagePath!="string"&&(Qo.imagePath=this._detectIconPath()),(this.options.imagePath||Qo.imagePath)+pi.prototype._getIconUrl.call(this,m)},_stripUrl:function(m){var k=function(D,V,ue){var Oe=V.exec(D);return Oe&&Oe[ue]};return m=k(m,/^url\((['"])?(.+)\1\)$/,2),m&&k(m,/^(.*)marker-icon\.png$/,1)},_detectIconPath:function(){var m=Gr("div","leaflet-default-icon-path",document.body),k=Yr(m,"background-image")||Yr(m,"backgroundImage");if(document.body.removeChild(m),k=this._stripUrl(k),k)return k;var D=document.querySelector('link[href$="leaflet.css"]');return D?D.href.substring(0,D.href.length-11-1):""}}),Ao=An.extend({initialize:function(m){this._marker=m},addHooks:function(){var m=this._marker._icon;this._draggable||(this._draggable=new $i(m,m,!0)),this._draggable.on({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),De(m,"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&&wr(this._marker._icon,"leaflet-marker-draggable")},moved:function(){return this._draggable&&this._draggable._moved},_adjustPan:function(m){var k=this._marker,D=k._map,V=this._marker.options.autoPanSpeed,ue=this._marker.options.autoPanPadding,Oe=Pr(k._icon),st=D.getPixelBounds(),Et=D.getPixelOrigin(),$t=q(st.min._subtract(Et).add(ue),st.max._subtract(Et).subtract(ue));if(!$t.contains(Oe)){var cr=ye((Math.max($t.max.x,Oe.x)-$t.max.x)/(st.max.x-$t.max.x)-(Math.min($t.min.x,Oe.x)-$t.min.x)/(st.min.x-$t.min.x),(Math.max($t.max.y,Oe.y)-$t.max.y)/(st.max.y-$t.max.y)-(Math.min($t.min.y,Oe.y)-$t.min.y)/(st.min.y-$t.min.y)).multiplyBy(V);D.panBy(cr,{animate:!1}),this._draggable._newPos._add(cr),this._draggable._startPos._add(cr),Qt(k._icon,this._draggable._newPos),this._onDrag(m),this._panRequest=fe(this._adjustPan.bind(this,m))}},_onDragStart:function(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup&&this._marker.closePopup(),this._marker.fire("movestart").fire("dragstart")},_onPreDrag:function(m){this._marker.options.autoPan&&(K(this._panRequest),this._panRequest=fe(this._adjustPan.bind(this,m)))},_onDrag:function(m){var k=this._marker,D=k._shadow,V=Pr(k._icon),ue=k._map.layerPointToLatLng(V);D&&Qt(D,V),k._latlng=ue,m.latlng=ue,m.oldLatLng=this._oldLatLng,k.fire("move",m).fire("drag",m)},_onDragEnd:function(m){K(this._panRequest),delete this._oldLatLng,this._marker.fire("moveend").fire("dragend",m)}}),gn=Rs.extend({options:{icon:new Qo,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(m,k){C(this,k),this._latlng=le(m)},onAdd:function(m){this._zoomAnimated=this._zoomAnimated&&m.options.markerZoomAnimation,this._zoomAnimated&&m.on("zoomanim",this._animateZoom,this),this._initIcon(),this.update()},onRemove:function(m){this.dragging&&this.dragging.enabled()&&(this.options.draggable=!0,this.dragging.removeHooks()),delete this.dragging,this._zoomAnimated&&m.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(m){var k=this._latlng;return this._latlng=le(m),this.update(),this.fire("move",{oldLatLng:k,latlng:this._latlng})},setZIndexOffset:function(m){return this.options.zIndexOffset=m,this.update()},getIcon:function(){return this.options.icon},setIcon:function(m){return this.options.icon=m,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 m=this._map.latLngToLayerPoint(this._latlng).round();this._setPos(m)}return this},_initIcon:function(){var m=this.options,k="leaflet-zoom-"+(this._zoomAnimated?"animated":"hide"),D=m.icon.createIcon(this._icon),V=!1;D!==this._icon&&(this._icon&&this._removeIcon(),V=!0,m.title&&(D.title=m.title),D.tagName==="IMG"&&(D.alt=m.alt||"")),De(D,k),m.keyboard&&(D.tabIndex="0",D.setAttribute("role","button")),this._icon=D,m.riseOnHover&&this.on({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&bt(D,"focus",this._panOnFocus,this);var ue=m.icon.createShadow(this._shadow),Oe=!1;ue!==this._shadow&&(this._removeShadow(),Oe=!0),ue&&(De(ue,k),ue.alt=""),this._shadow=ue,m.opacity<1&&this._updateOpacity(),V&&this.getPane().appendChild(this._icon),this._initInteraction(),ue&&Oe&&this.getPane(m.shadowPane).appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&this.off({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&gr(this._icon,"focus",this._panOnFocus,this),Sa(this._icon),this.removeInteractiveTarget(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&Sa(this._shadow),this._shadow=null},_setPos:function(m){this._icon&&Qt(this._icon,m),this._shadow&&Qt(this._shadow,m),this._zIndex=m.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(m){this._icon&&(this._icon.style.zIndex=this._zIndex+m)},_animateZoom:function(m){var k=this._map._latLngToNewLayerPoint(this._latlng,m.zoom,m.center).round();this._setPos(k)},_initInteraction:function(){if(this.options.interactive&&(De(this._icon,"leaflet-interactive"),this.addInteractiveTarget(this._icon),Ao)){var m=this.options.draggable;this.dragging&&(m=this.dragging.enabled(),this.dragging.disable()),this.dragging=new Ao(this),m&&this.dragging.enable()}},setOpacity:function(m){return this.options.opacity=m,this._map&&this._updateOpacity(),this},_updateOpacity:function(){var m=this.options.opacity;this._icon&&Wr(this._icon,m),this._shadow&&Wr(this._shadow,m)},_bringToFront:function(){this._updateZIndex(this.options.riseOffset)},_resetZIndex:function(){this._updateZIndex(0)},_panOnFocus:function(){var m=this._map;if(m){var k=this.options.icon.options,D=k.iconSize?ye(k.iconSize):ye(0,0),V=k.iconAnchor?ye(k.iconAnchor):ye(0,0);m.panInside(this._latlng,{paddingTopLeft:V,paddingBottomRight:D.subtract(V)})}},_getPopupAnchor:function(){return this.options.icon.options.popupAnchor},_getTooltipAnchor:function(){return this.options.icon.options.tooltipAnchor}});function zl(m,k){return new gn(m,k)}var Hn=Rs.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(m){this._renderer=m.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(m){return C(this,m),this._renderer&&(this._renderer._updateStyle(this),this.options.stroke&&m&&Object.prototype.hasOwnProperty.call(m,"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)}}),ii=Hn.extend({options:{fill:!0,radius:10},initialize:function(m,k){C(this,k),this._latlng=le(m),this._radius=this.options.radius},setLatLng:function(m){var k=this._latlng;return this._latlng=le(m),this.redraw(),this.fire("move",{oldLatLng:k,latlng:this._latlng})},getLatLng:function(){return this._latlng},setRadius:function(m){return this.options.radius=this._radius=m,this.redraw()},getRadius:function(){return this._radius},setStyle:function(m){var k=m&&m.radius||this._radius;return Hn.prototype.setStyle.call(this,m),this.setRadius(k),this},_project:function(){this._point=this._map.latLngToLayerPoint(this._latlng),this._updateBounds()},_updateBounds:function(){var m=this._radius,k=this._radiusY||m,D=this._clickTolerance(),V=[m+D,k+D];this._pxBounds=new te(this._point.subtract(V),this._point.add(V))},_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(m){return m.distanceTo(this._point)<=this._radius+this._clickTolerance()}});function ja(m,k){return new ii(m,k)}var tn=ii.extend({initialize:function(m,k,D){if(typeof k=="number"&&(k=n({},D,{radius:k})),C(this,k),this._latlng=le(m),isNaN(this.options.radius))throw new Error("Circle radius cannot be NaN");this._mRadius=this.options.radius},setRadius:function(m){return this._mRadius=m,this.redraw()},getRadius:function(){return this._mRadius},getBounds:function(){var m=[this._radius,this._radiusY||this._radius];return new J(this._map.layerPointToLatLng(this._point.subtract(m)),this._map.layerPointToLatLng(this._point.add(m)))},setStyle:Hn.prototype.setStyle,_project:function(){var m=this._latlng.lng,k=this._latlng.lat,D=this._map,V=D.options.crs;if(V.distance===Z.distance){var ue=Math.PI/180,Oe=this._mRadius/Z.R/ue,st=D.project([k+Oe,m]),Et=D.project([k-Oe,m]),$t=st.add(Et).divideBy(2),cr=D.unproject($t).lat,Er=Math.acos((Math.cos(Oe*ue)-Math.sin(k*ue)*Math.sin(cr*ue))/(Math.cos(k*ue)*Math.cos(cr*ue)))/ue;(isNaN(Er)||Er===0)&&(Er=Oe/Math.cos(Math.PI/180*k)),this._point=$t.subtract(D.getPixelOrigin()),this._radius=isNaN(Er)?0:$t.x-D.project([cr,m-Er]).x,this._radiusY=$t.y-st.y}else{var Vr=V.unproject(V.project(this._latlng).subtract([this._mRadius,0]));this._point=D.latLngToLayerPoint(this._latlng),this._radius=this._point.x-D.latLngToLayerPoint(Vr).x}this._updateBounds()}});function Ne(m,k,D){return new tn(m,k,D)}var l=Hn.extend({options:{smoothFactor:1,noClip:!1},initialize:function(m,k){C(this,k),this._setLatLngs(m)},getLatLngs:function(){return this._latlngs},setLatLngs:function(m){return this._setLatLngs(m),this.redraw()},isEmpty:function(){return!this._latlngs.length},closestLayerPoint:function(m){for(var k=1/0,D=null,V=oo,ue,Oe,st=0,Et=this._parts.length;st<Et;st++)for(var $t=this._parts[st],cr=1,Er=$t.length;cr<Er;cr++){ue=$t[cr-1],Oe=$t[cr];var Vr=V(m,ue,Oe,!0);Vr<k&&(k=Vr,D=V(m,ue,Oe))}return D&&(D.distance=Math.sqrt(k)),D},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");return lo(this._defaultShape(),this._map.options.crs)},getBounds:function(){return this._bounds},addLatLng:function(m,k){return k=k||this._defaultShape(),m=le(m),k.push(m),this._bounds.extend(m),this.redraw()},_setLatLngs:function(m){this._bounds=new J,this._latlngs=this._convertLatLngs(m)},_defaultShape:function(){return On(this._latlngs)?this._latlngs:this._latlngs[0]},_convertLatLngs:function(m){for(var k=[],D=On(m),V=0,ue=m.length;V<ue;V++)D?(k[V]=le(m[V]),this._bounds.extend(k[V])):k[V]=this._convertLatLngs(m[V]);return k},_project:function(){var m=new te;this._rings=[],this._projectLatlngs(this._latlngs,this._rings,m),this._bounds.isValid()&&m.isValid()&&(this._rawPxBounds=m,this._updateBounds())},_updateBounds:function(){var m=this._clickTolerance(),k=new ve(m,m);this._rawPxBounds&&(this._pxBounds=new te([this._rawPxBounds.min.subtract(k),this._rawPxBounds.max.add(k)]))},_projectLatlngs:function(m,k,D){var V=m[0]instanceof oe,ue=m.length,Oe,st;if(V){for(st=[],Oe=0;Oe<ue;Oe++)st[Oe]=this._map.latLngToLayerPoint(m[Oe]),D.extend(st[Oe]);k.push(st)}else for(Oe=0;Oe<ue;Oe++)this._projectLatlngs(m[Oe],k,D)},_clipPoints:function(){var m=this._renderer._bounds;if(this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(m))){if(this.options.noClip){this._parts=this._rings;return}var k=this._parts,D,V,ue,Oe,st,Et,$t;for(D=0,ue=0,Oe=this._rings.length;D<Oe;D++)for($t=this._rings[D],V=0,st=$t.length;V<st-1;V++)Et=Un($t[V],$t[V+1],m,V,!0),Et&&(k[ue]=k[ue]||[],k[ue].push(Et[0]),(Et[1]!==$t[V+1]||V===st-2)&&(k[ue].push(Et[1]),ue++))}},_simplifyPoints:function(){for(var m=this._parts,k=this.options.smoothFactor,D=0,V=m.length;D<V;D++)m[D]=rs(m[D],k)},_update:function(){this._map&&(this._clipPoints(),this._simplifyPoints(),this._updatePath())},_updatePath:function(){this._renderer._updatePoly(this)},_containsPoint:function(m,k){var D,V,ue,Oe,st,Et,$t=this._clickTolerance();if(!this._pxBounds||!this._pxBounds.contains(m))return!1;for(D=0,Oe=this._parts.length;D<Oe;D++)for(Et=this._parts[D],V=0,st=Et.length,ue=st-1;V<st;ue=V++)if(!(!k&&V===0)&&Jo(m,Et[ue],Et[V])<=$t)return!0;return!1}});function f(m,k){return new l(m,k)}l._flat=Eo;var x=l.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 pl(this._defaultShape(),this._map.options.crs)},_convertLatLngs:function(m){var k=l.prototype._convertLatLngs.call(this,m),D=k.length;return D>=2&&k[0]instanceof oe&&k[0].equals(k[D-1])&&k.pop(),k},_setLatLngs:function(m){l.prototype._setLatLngs.call(this,m),On(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return On(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var m=this._renderer._bounds,k=this.options.weight,D=new ve(k,k);if(m=new te(m.min.subtract(D),m.max.add(D)),this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(m))){if(this.options.noClip){this._parts=this._rings;return}for(var V=0,ue=this._rings.length,Oe;V<ue;V++)Oe=yc(this._rings[V],m,!0),Oe.length&&this._parts.push(Oe)}},_updatePath:function(){this._renderer._updatePoly(this,!0)},_containsPoint:function(m){var k=!1,D,V,ue,Oe,st,Et,$t,cr;if(!this._pxBounds||!this._pxBounds.contains(m))return!1;for(Oe=0,$t=this._parts.length;Oe<$t;Oe++)for(D=this._parts[Oe],st=0,cr=D.length,Et=cr-1;st<cr;Et=st++)V=D[st],ue=D[Et],V.y>m.y!=ue.y>m.y&&m.x<(ue.x-V.x)*(m.y-V.y)/(ue.y-V.y)+V.x&&(k=!k);return k||l.prototype._containsPoint.call(this,m,!0)}});function b(m,k){return new x(m,k)}var v=si.extend({initialize:function(m,k){C(this,k),this._layers={},m&&this.addData(m)},addData:function(m){var k=F(m)?m:m.features,D,V,ue;if(k){for(D=0,V=k.length;D<V;D++)ue=k[D],(ue.geometries||ue.geometry||ue.features||ue.coordinates)&&this.addData(ue);return this}var Oe=this.options;if(Oe.filter&&!Oe.filter(m))return this;var st=j(m,Oe);return st?(st.feature=Ge(m),st.defaultOptions=st.options,this.resetStyle(st),Oe.onEachFeature&&Oe.onEachFeature(m,st),this.addLayer(st)):this},resetStyle:function(m){return m===void 0?this.eachLayer(this.resetStyle,this):(m.options=n({},m.defaultOptions),this._setLayerStyle(m,this.options.style),this)},setStyle:function(m){return this.eachLayer(function(k){this._setLayerStyle(k,m)},this)},_setLayerStyle:function(m,k){m.setStyle&&(typeof k=="function"&&(k=k(m.feature)),m.setStyle(k))}});function j(m,k){var D=m.type==="Feature"?m.geometry:m,V=D?D.coordinates:null,ue=[],Oe=k&&k.pointToLayer,st=k&&k.coordsToLatLng||P,Et,$t,cr,Er;if(!V&&!D)return null;switch(D.type){case"Point":return Et=st(V),T(Oe,m,Et,k);case"MultiPoint":for(cr=0,Er=V.length;cr<Er;cr++)Et=st(V[cr]),ue.push(T(Oe,m,Et,k));return new si(ue);case"LineString":case"MultiLineString":return $t=H(V,D.type==="LineString"?0:1,st),new l($t,k);case"Polygon":case"MultiPolygon":return $t=H(V,D.type==="Polygon"?1:2,st),new x($t,k);case"GeometryCollection":for(cr=0,Er=D.geometries.length;cr<Er;cr++){var Vr=j({geometry:D.geometries[cr],type:"Feature",properties:m.properties},k);Vr&&ue.push(Vr)}return new si(ue);case"FeatureCollection":for(cr=0,Er=D.features.length;cr<Er;cr++){var va=j(D.features[cr],k);va&&ue.push(va)}return new si(ue);default:throw new Error("Invalid GeoJSON object.")}}function T(m,k,D,V){return m?m(k,D):new gn(D,V&&V.markersInheritOptions&&V)}function P(m){return new oe(m[1],m[0],m[2])}function H(m,k,D){for(var V=[],ue=0,Oe=m.length,st;ue<Oe;ue++)st=k?H(m[ue],k-1,D):(D||P)(m[ue]),V.push(st);return V}function de(m,k){return m=le(m),m.alt!==void 0?[E(m.lng,k),E(m.lat,k),E(m.alt,k)]:[E(m.lng,k),E(m.lat,k)]}function je(m,k,D,V){for(var ue=[],Oe=0,st=m.length;Oe<st;Oe++)ue.push(k?je(m[Oe],On(m[Oe])?0:k-1,D,V):de(m[Oe],V));return!k&&D&&ue.length>0&&ue.push(ue[0].slice()),ue}function Ae(m,k){return m.feature?n({},m.feature,{geometry:k}):Ge(k)}function Ge(m){return m.type==="Feature"||m.type==="FeatureCollection"?m:{type:"Feature",properties:{},geometry:m}}var ot={toGeoJSON:function(m){return Ae(this,{type:"Point",coordinates:de(this.getLatLng(),m)})}};gn.include(ot),tn.include(ot),ii.include(ot),l.include({toGeoJSON:function(m){var k=!On(this._latlngs),D=je(this._latlngs,k?1:0,!1,m);return Ae(this,{type:(k?"Multi":"")+"LineString",coordinates:D})}}),x.include({toGeoJSON:function(m){var k=!On(this._latlngs),D=k&&!On(this._latlngs[0]),V=je(this._latlngs,D?2:k?1:0,!0,m);return k||(V=[V]),Ae(this,{type:(D?"Multi":"")+"Polygon",coordinates:V})}}),Di.include({toMultiPoint:function(m){var k=[];return this.eachLayer(function(D){k.push(D.toGeoJSON(m).geometry.coordinates)}),Ae(this,{type:"MultiPoint",coordinates:k})},toGeoJSON:function(m){var k=this.feature&&this.feature.geometry&&this.feature.geometry.type;if(k==="MultiPoint")return this.toMultiPoint(m);var D=k==="GeometryCollection",V=[];return this.eachLayer(function(ue){if(ue.toGeoJSON){var Oe=ue.toGeoJSON(m);if(D)V.push(Oe.geometry);else{var st=Ge(Oe);st.type==="FeatureCollection"?V.push.apply(V,st.features):V.push(st)}}}),D?Ae(this,{geometries:V,type:"GeometryCollection"}):{type:"FeatureCollection",features:V}}});function ut(m,k){return new v(m,k)}var At=ut,se=Rs.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(m,k,D){this._url=m,this._bounds=ae(k),C(this,D)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(De(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){Sa(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(m){return this.options.opacity=m,this._image&&this._updateOpacity(),this},setStyle:function(m){return m.opacity&&this.setOpacity(m.opacity),this},bringToFront:function(){return this._map&&ha(this._image),this},bringToBack:function(){return this._map&&_s(this._image),this},setUrl:function(m){return this._url=m,this._image&&(this._image.src=m),this},setBounds:function(m){return this._bounds=ae(m),this._map&&this._reset(),this},getEvents:function(){var m={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(m.zoomanim=this._animateZoom),m},setZIndex:function(m){return this.options.zIndex=m,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var m=this._url.tagName==="IMG",k=this._image=m?this._url:Gr("img");if(De(k,"leaflet-image-layer"),this._zoomAnimated&&De(k,"leaflet-zoom-animated"),this.options.className&&De(k,this.options.className),k.onselectstart=w,k.onmousemove=w,k.onload=c(this.fire,this,"load"),k.onerror=c(this._overlayOnError,this,"error"),(this.options.crossOrigin||this.options.crossOrigin==="")&&(k.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),m){this._url=k.src;return}k.src=this._url,k.alt=this.options.alt},_animateZoom:function(m){var k=this._map.getZoomScale(m.zoom),D=this._map._latLngBoundsToNewLayerBounds(this._bounds,m.zoom,m.center).min;Me(this._image,D,k)},_reset:function(){var m=this._image,k=new te(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),D=k.getSize();Qt(m,k.min),m.style.width=D.x+"px",m.style.height=D.y+"px"},_updateOpacity:function(){Wr(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 m=this.options.errorOverlayUrl;m&&this._url!==m&&(this._url=m,this._image.src=m)},getCenter:function(){return this._bounds.getCenter()}}),Ee=function(m,k,D){return new se(m,k,D)},Ue=se.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var m=this._url.tagName==="VIDEO",k=this._image=m?this._url:Gr("video");if(De(k,"leaflet-image-layer"),this._zoomAnimated&&De(k,"leaflet-zoom-animated"),this.options.className&&De(k,this.options.className),k.onselectstart=w,k.onmousemove=w,k.onloadeddata=c(this.fire,this,"load"),m){for(var D=k.getElementsByTagName("source"),V=[],ue=0;ue<D.length;ue++)V.push(D[ue].src);this._url=D.length>0?V:[k.src];return}F(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(k.style,"objectFit")&&(k.style.objectFit="fill"),k.autoplay=!!this.options.autoplay,k.loop=!!this.options.loop,k.muted=!!this.options.muted,k.playsInline=!!this.options.playsInline;for(var Oe=0;Oe<this._url.length;Oe++){var st=Gr("source");st.src=this._url[Oe],k.appendChild(st)}}});function ht(m,k,D){return new Ue(m,k,D)}var ur=se.extend({_initImage:function(){var m=this._image=this._url;De(m,"leaflet-image-layer"),this._zoomAnimated&&De(m,"leaflet-zoom-animated"),this.options.className&&De(m,this.options.className),m.onselectstart=w,m.onmousemove=w}});function tr(m,k,D){return new ur(m,k,D)}var Ar=Rs.extend({options:{interactive:!1,offset:[0,0],className:"",pane:void 0,content:""},initialize:function(m,k){m&&(m instanceof oe||F(m))?(this._latlng=le(m),C(this,k)):(C(this,m),this._source=k),this.options.content&&(this._content=this.options.content)},openOn:function(m){return m=arguments.length?m:this._source._map,m.hasLayer(this)||m.addLayer(this),this},close:function(){return this._map&&this._map.removeLayer(this),this},toggle:function(m){return this._map?this.close():(arguments.length?this._source=m:m=this._source,this._prepareOpen(),this.openOn(m._map)),this},onAdd:function(m){this._zoomAnimated=m._zoomAnimated,this._container||this._initLayout(),m._fadeAnimated&&Wr(this._container,0),clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.update(),m._fadeAnimated&&Wr(this._container,1),this.bringToFront(),this.options.interactive&&(De(this._container,"leaflet-interactive"),this.addInteractiveTarget(this._container))},onRemove:function(m){m._fadeAnimated?(Wr(this._container,0),this._removeTimeout=setTimeout(c(Sa,void 0,this._container),200)):Sa(this._container),this.options.interactive&&(wr(this._container,"leaflet-interactive"),this.removeInteractiveTarget(this._container))},getLatLng:function(){return this._latlng},setLatLng:function(m){return this._latlng=le(m),this._map&&(this._updatePosition(),this._adjustPan()),this},getContent:function(){return this._content},setContent:function(m){return this._content=m,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 m={zoom:this._updatePosition,viewreset:this._updatePosition};return this._zoomAnimated&&(m.zoomanim=this._animateZoom),m},isOpen:function(){return!!this._map&&this._map.hasLayer(this)},bringToFront:function(){return this._map&&ha(this._container),this},bringToBack:function(){return this._map&&_s(this._container),this},_prepareOpen:function(m){var k=this._source;if(!k._map)return!1;if(k instanceof si){k=null;var D=this._source._layers;for(var V in D)if(D[V]._map){k=D[V];break}if(!k)return!1;this._source=k}if(!m)if(k.getCenter)m=k.getCenter();else if(k.getLatLng)m=k.getLatLng();else if(k.getBounds)m=k.getBounds().getCenter();else throw new Error("Unable to get source layer LatLng.");return this.setLatLng(m),this._map&&this.update(),!0},_updateContent:function(){if(this._content){var m=this._contentNode,k=typeof this._content=="function"?this._content(this._source||this):this._content;if(typeof k=="string")m.innerHTML=k;else{for(;m.hasChildNodes();)m.removeChild(m.firstChild);m.appendChild(k)}this.fire("contentupdate")}},_updatePosition:function(){if(this._map){var m=this._map.latLngToLayerPoint(this._latlng),k=ye(this.options.offset),D=this._getAnchor();this._zoomAnimated?Qt(this._container,m.add(D)):k=k.add(m).add(D);var V=this._containerBottom=-k.y,ue=this._containerLeft=-Math.round(this._containerWidth/2)+k.x;this._container.style.bottom=V+"px",this._container.style.left=ue+"px"}},_getAnchor:function(){return[0,0]}});ga.include({_initOverlay:function(m,k,D,V){var ue=k;return ue instanceof m||(ue=new m(V).setContent(k)),D&&ue.setLatLng(D),ue}}),Rs.include({_initOverlay:function(m,k,D,V){var ue=D;return ue instanceof m?(C(ue,V),ue._source=this):(ue=k&&!V?k:new m(V,this),ue.setContent(D)),ue}});var ra=Ar.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(m){return m=arguments.length?m:this._source._map,!m.hasLayer(this)&&m._popup&&m._popup.options.autoClose&&m.removeLayer(m._popup),m._popup=this,Ar.prototype.openOn.call(this,m)},onAdd:function(m){Ar.prototype.onAdd.call(this,m),m.fire("popupopen",{popup:this}),this._source&&(this._source.fire("popupopen",{popup:this},!0),this._source instanceof Hn||this._source.on("preclick",As))},onRemove:function(m){Ar.prototype.onRemove.call(this,m),m.fire("popupclose",{popup:this}),this._source&&(this._source.fire("popupclose",{popup:this},!0),this._source instanceof Hn||this._source.off("preclick",As))},getEvents:function(){var m=Ar.prototype.getEvents.call(this);return(this.options.closeOnClick!==void 0?this.options.closeOnClick:this._map.options.closePopupOnClick)&&(m.preclick=this.close),this.options.keepInView&&(m.moveend=this._adjustPan),m},_initLayout:function(){var m="leaflet-popup",k=this._container=Gr("div",m+" "+(this.options.className||"")+" leaflet-zoom-animated"),D=this._wrapper=Gr("div",m+"-content-wrapper",k);if(this._contentNode=Gr("div",m+"-content",D),$s(k),Os(this._contentNode),bt(k,"contextmenu",As),this._tipContainer=Gr("div",m+"-tip-container",k),this._tip=Gr("div",m+"-tip",this._tipContainer),this.options.closeButton){var V=this._closeButton=Gr("a",m+"-close-button",k);V.setAttribute("role","button"),V.setAttribute("aria-label","Close popup"),V.href="#close",V.innerHTML='<span aria-hidden="true">&#215;</span>',bt(V,"click",function(ue){Qa(ue),this.close()},this)}},_updateLayout:function(){var m=this._contentNode,k=m.style;k.width="",k.whiteSpace="nowrap";var D=m.offsetWidth;D=Math.min(D,this.options.maxWidth),D=Math.max(D,this.options.minWidth),k.width=D+1+"px",k.whiteSpace="",k.height="";var V=m.offsetHeight,ue=this.options.maxHeight,Oe="leaflet-popup-scrolled";ue&&V>ue?(k.height=ue+"px",De(m,Oe)):wr(m,Oe),this._containerWidth=this._container.offsetWidth},_animateZoom:function(m){var k=this._map._latLngToNewLayerPoint(this._latlng,m.zoom,m.center),D=this._getAnchor();Qt(this._container,k.add(D))},_adjustPan:function(){if(this.options.autoPan){if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning){this._autopanning=!1;return}var m=this._map,k=parseInt(Yr(this._container,"marginBottom"),10)||0,D=this._container.offsetHeight+k,V=this._containerWidth,ue=new ve(this._containerLeft,-D-this._containerBottom);ue._add(Pr(this._container));var Oe=m.layerPointToContainerPoint(ue),st=ye(this.options.autoPanPadding),Et=ye(this.options.autoPanPaddingTopLeft||st),$t=ye(this.options.autoPanPaddingBottomRight||st),cr=m.getSize(),Er=0,Vr=0;Oe.x+V+$t.x>cr.x&&(Er=Oe.x+V-cr.x+$t.x),Oe.x-Er-Et.x<0&&(Er=Oe.x-Et.x),Oe.y+D+$t.y>cr.y&&(Vr=Oe.y+D-cr.y+$t.y),Oe.y-Vr-Et.y<0&&(Vr=Oe.y-Et.y),(Er||Vr)&&(this.options.keepInView&&(this._autopanning=!0),m.fire("autopanstart").panBy([Er,Vr]))}},_getAnchor:function(){return ye(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),La=function(m,k){return new ra(m,k)};ga.mergeOptions({closePopupOnClick:!0}),ga.include({openPopup:function(m,k,D){return this._initOverlay(ra,m,k,D).openOn(this),this},closePopup:function(m){return m=arguments.length?m:this._popup,m&&m.close(),this}}),Rs.include({bindPopup:function(m,k){return this._popup=this._initOverlay(ra,this._popup,m,k),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(m){return this._popup&&(this instanceof si||(this._popup._source=this),this._popup._prepareOpen(m||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(m){return this._popup&&this._popup.setContent(m),this},getPopup:function(){return this._popup},_openPopup:function(m){if(!(!this._popup||!this._map)){en(m);var k=m.layer||m.target;if(this._popup._source===k&&!(k instanceof Hn)){this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(m.latlng);return}this._popup._source=k,this.openPopup(m.latlng)}},_movePopup:function(m){this._popup.setLatLng(m.latlng)},_onKeyPress:function(m){m.originalEvent.keyCode===13&&this._openPopup(m)}});var Dr=Ar.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(m){Ar.prototype.onAdd.call(this,m),this.setOpacity(this.options.opacity),m.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(m){Ar.prototype.onRemove.call(this,m),m.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var m=Ar.prototype.getEvents.call(this);return this.options.permanent||(m.preclick=this.close),m},_initLayout:function(){var m="leaflet-tooltip",k=m+" "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=Gr("div",k),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+h(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(m){var k,D,V=this._map,ue=this._container,Oe=V.latLngToContainerPoint(V.getCenter()),st=V.layerPointToContainerPoint(m),Et=this.options.direction,$t=ue.offsetWidth,cr=ue.offsetHeight,Er=ye(this.options.offset),Vr=this._getAnchor();Et==="top"?(k=$t/2,D=cr):Et==="bottom"?(k=$t/2,D=0):Et==="center"?(k=$t/2,D=cr/2):Et==="right"?(k=0,D=cr/2):Et==="left"?(k=$t,D=cr/2):st.x<Oe.x?(Et="right",k=0,D=cr/2):(Et="left",k=$t+(Er.x+Vr.x)*2,D=cr/2),m=m.subtract(ye(k,D,!0)).add(Er).add(Vr),wr(ue,"leaflet-tooltip-right"),wr(ue,"leaflet-tooltip-left"),wr(ue,"leaflet-tooltip-top"),wr(ue,"leaflet-tooltip-bottom"),De(ue,"leaflet-tooltip-"+Et),Qt(ue,m)},_updatePosition:function(){var m=this._map.latLngToLayerPoint(this._latlng);this._setPosition(m)},setOpacity:function(m){this.options.opacity=m,this._container&&Wr(this._container,m)},_animateZoom:function(m){var k=this._map._latLngToNewLayerPoint(this._latlng,m.zoom,m.center);this._setPosition(k)},_getAnchor:function(){return ye(this._source&&this._source._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}}),Ta=function(m,k){return new Dr(m,k)};ga.include({openTooltip:function(m,k,D){return this._initOverlay(Dr,m,k,D).openOn(this),this},closeTooltip:function(m){return m.close(),this}}),Rs.include({bindTooltip:function(m,k){return this._tooltip&&this.isTooltipOpen()&&this.unbindTooltip(),this._tooltip=this._initOverlay(Dr,this._tooltip,m,k),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(m){if(!(!m&&this._tooltipHandlersAdded)){var k=m?"off":"on",D={remove:this.closeTooltip,move:this._moveTooltip};this._tooltip.options.permanent?D.add=this._openTooltip:(D.mouseover=this._openTooltip,D.mouseout=this.closeTooltip,D.click=this._openTooltip,this._map?this._addFocusListeners():D.add=this._addFocusListeners),this._tooltip.options.sticky&&(D.mousemove=this._moveTooltip),this[k](D),this._tooltipHandlersAdded=!m}},openTooltip:function(m){return this._tooltip&&(this instanceof si||(this._tooltip._source=this),this._tooltip._prepareOpen(m)&&(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(m){return this._tooltip&&this._tooltip.setContent(m),this},getTooltip:function(){return this._tooltip},_addFocusListeners:function(){this.getElement?this._addFocusListenersOnLayer(this):this.eachLayer&&this.eachLayer(this._addFocusListenersOnLayer,this)},_addFocusListenersOnLayer:function(m){var k=typeof m.getElement=="function"&&m.getElement();k&&(bt(k,"focus",function(){this._tooltip._source=m,this.openTooltip()},this),bt(k,"blur",this.closeTooltip,this))},_setAriaDescribedByOnLayer:function(m){var k=typeof m.getElement=="function"&&m.getElement();k&&k.setAttribute("aria-describedby",this._tooltip._container.id)},_openTooltip:function(m){if(!(!this._tooltip||!this._map)){if(this._map.dragging&&this._map.dragging.moving()&&!this._openOnceFlag){this._openOnceFlag=!0;var k=this;this._map.once("moveend",function(){k._openOnceFlag=!1,k._openTooltip(m)});return}this._tooltip._source=m.layer||m.target,this.openTooltip(this._tooltip.options.sticky?m.latlng:void 0)}},_moveTooltip:function(m){var k=m.latlng,D,V;this._tooltip.options.sticky&&m.originalEvent&&(D=this._map.mouseEventToContainerPoint(m.originalEvent),V=this._map.containerPointToLayerPoint(D),k=this._map.layerPointToLatLng(V)),this._tooltip.setLatLng(k)}});var gs=pi.extend({options:{iconSize:[12,12],html:!1,bgPos:null,className:"leaflet-div-icon"},createIcon:function(m){var k=m&&m.tagName==="DIV"?m:document.createElement("div"),D=this.options;if(D.html instanceof Element?(Ps(k),k.appendChild(D.html)):k.innerHTML=D.html!==!1?D.html:"",D.bgPos){var V=ye(D.bgPos);k.style.backgroundPosition=-V.x+"px "+-V.y+"px"}return this._setIconStyles(k,"icon"),k},createShadow:function(){return null}});function vs(m){return new gs(m)}pi.Default=Qo;var as=Rs.extend({options:{tileSize:256,opacity:1,updateWhenIdle:Re.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(m){C(this,m)},onAdd:function(){this._initContainer(),this._levels={},this._tiles={},this._resetView()},beforeAdd:function(m){m._addZoomLimit(this)},onRemove:function(m){this._removeAllTiles(),Sa(this._container),m._removeZoomLimit(this),this._container=null,this._tileZoom=void 0},bringToFront:function(){return this._map&&(ha(this._container),this._setAutoZIndex(Math.max)),this},bringToBack:function(){return this._map&&(_s(this._container),this._setAutoZIndex(Math.min)),this},getContainer:function(){return this._container},setOpacity:function(m){return this.options.opacity=m,this._updateOpacity(),this},setZIndex:function(m){return this.options.zIndex=m,this._updateZIndex(),this},isLoading:function(){return this._loading},redraw:function(){if(this._map){this._removeAllTiles();var m=this._clampZoom(this._map.getZoom());m!==this._tileZoom&&(this._tileZoom=m,this._updateLevels()),this._update()}return this},getEvents:function(){var m={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};return this.options.updateWhenIdle||(this._onMove||(this._onMove=g(this._onMoveEnd,this.options.updateInterval,this)),m.move=this._onMove),this._zoomAnimated&&(m.zoomanim=this._animateZoom),m},createTile:function(){return document.createElement("div")},getTileSize:function(){var m=this.options.tileSize;return m instanceof ve?m:new ve(m,m)},_updateZIndex:function(){this._container&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(m){for(var k=this.getPane().children,D=-m(-1/0,1/0),V=0,ue=k.length,Oe;V<ue;V++)Oe=k[V].style.zIndex,k[V]!==this._container&&Oe&&(D=m(D,+Oe));isFinite(D)&&(this.options.zIndex=D+m(-1,1),this._updateZIndex())},_updateOpacity:function(){if(this._map&&!Re.ielt9){Wr(this._container,this.options.opacity);var m=+new Date,k=!1,D=!1;for(var V in this._tiles){var ue=this._tiles[V];if(!(!ue.current||!ue.loaded)){var Oe=Math.min(1,(m-ue.loaded)/200);Wr(ue.el,Oe),Oe<1?k=!0:(ue.active?D=!0:this._onOpaqueTile(ue),ue.active=!0)}}D&&!this._noPrune&&this._pruneTiles(),k&&(K(this._fadeFrame),this._fadeFrame=fe(this._updateOpacity,this))}},_onOpaqueTile:w,_initContainer:function(){this._container||(this._container=Gr("div","leaflet-layer "+(this.options.className||"")),this._updateZIndex(),this.options.opacity<1&&this._updateOpacity(),this.getPane().appendChild(this._container))},_updateLevels:function(){var m=this._tileZoom,k=this.options.maxZoom;if(m!==void 0){for(var D in this._levels)D=Number(D),this._levels[D].el.children.length||D===m?(this._levels[D].el.style.zIndex=k-Math.abs(m-D),this._onUpdateLevel(D)):(Sa(this._levels[D].el),this._removeTilesAtZoom(D),this._onRemoveLevel(D),delete this._levels[D]);var V=this._levels[m],ue=this._map;return V||(V=this._levels[m]={},V.el=Gr("div","leaflet-tile-container leaflet-zoom-animated",this._container),V.el.style.zIndex=k,V.origin=ue.project(ue.unproject(ue.getPixelOrigin()),m).round(),V.zoom=m,this._setZoomTransform(V,ue.getCenter(),ue.getZoom()),w(V.el.offsetWidth),this._onCreateLevel(V)),this._level=V,V}},_onUpdateLevel:w,_onRemoveLevel:w,_onCreateLevel:w,_pruneTiles:function(){if(this._map){var m,k,D=this._map.getZoom();if(D>this.options.maxZoom||D<this.options.minZoom){this._removeAllTiles();return}for(m in this._tiles)k=this._tiles[m],k.retain=k.current;for(m in this._tiles)if(k=this._tiles[m],k.current&&!k.active){var V=k.coords;this._retainParent(V.x,V.y,V.z,V.z-5)||this._retainChildren(V.x,V.y,V.z,V.z+2)}for(m in this._tiles)this._tiles[m].retain||this._removeTile(m)}},_removeTilesAtZoom:function(m){for(var k in this._tiles)this._tiles[k].coords.z===m&&this._removeTile(k)},_removeAllTiles:function(){for(var m in this._tiles)this._removeTile(m)},_invalidateAll:function(){for(var m in this._levels)Sa(this._levels[m].el),this._onRemoveLevel(Number(m)),delete this._levels[m];this._removeAllTiles(),this._tileZoom=void 0},_retainParent:function(m,k,D,V){var ue=Math.floor(m/2),Oe=Math.floor(k/2),st=D-1,Et=new ve(+ue,+Oe);Et.z=+st;var $t=this._tileCoordsToKey(Et),cr=this._tiles[$t];return cr&&cr.active?(cr.retain=!0,!0):(cr&&cr.loaded&&(cr.retain=!0),st>V?this._retainParent(ue,Oe,st,V):!1)},_retainChildren:function(m,k,D,V){for(var ue=2*m;ue<2*m+2;ue++)for(var Oe=2*k;Oe<2*k+2;Oe++){var st=new ve(ue,Oe);st.z=D+1;var Et=this._tileCoordsToKey(st),$t=this._tiles[Et];if($t&&$t.active){$t.retain=!0;continue}else $t&&$t.loaded&&($t.retain=!0);D+1<V&&this._retainChildren(ue,Oe,D+1,V)}},_resetView:function(m){var k=m&&(m.pinch||m.flyTo);this._setView(this._map.getCenter(),this._map.getZoom(),k,k)},_animateZoom:function(m){this._setView(m.center,m.zoom,!0,m.noUpdate)},_clampZoom:function(m){var k=this.options;return k.minNativeZoom!==void 0&&m<k.minNativeZoom?k.minNativeZoom:k.maxNativeZoom!==void 0&&k.maxNativeZoom<m?k.maxNativeZoom:m},_setView:function(m,k,D,V){var ue=Math.round(k);this.options.maxZoom!==void 0&&ue>this.options.maxZoom||this.options.minZoom!==void 0&&ue<this.options.minZoom?ue=void 0:ue=this._clampZoom(ue);var Oe=this.options.updateWhenZooming&&ue!==this._tileZoom;(!V||Oe)&&(this._tileZoom=ue,this._abortLoading&&this._abortLoading(),this._updateLevels(),this._resetGrid(),ue!==void 0&&this._update(m),D||this._pruneTiles(),this._noPrune=!!D),this._setZoomTransforms(m,k)},_setZoomTransforms:function(m,k){for(var D in this._levels)this._setZoomTransform(this._levels[D],m,k)},_setZoomTransform:function(m,k,D){var V=this._map.getZoomScale(D,m.zoom),ue=m.origin.multiplyBy(V).subtract(this._map._getNewPixelOrigin(k,D)).round();Re.any3d?Me(m.el,ue,V):Qt(m.el,ue)},_resetGrid:function(){var m=this._map,k=m.options.crs,D=this._tileSize=this.getTileSize(),V=this._tileZoom,ue=this._map.getPixelWorldBounds(this._tileZoom);ue&&(this._globalTileRange=this._pxBoundsToTileRange(ue)),this._wrapX=k.wrapLng&&!this.options.noWrap&&[Math.floor(m.project([0,k.wrapLng[0]],V).x/D.x),Math.ceil(m.project([0,k.wrapLng[1]],V).x/D.y)],this._wrapY=k.wrapLat&&!this.options.noWrap&&[Math.floor(m.project([k.wrapLat[0],0],V).y/D.x),Math.ceil(m.project([k.wrapLat[1],0],V).y/D.y)]},_onMoveEnd:function(){!this._map||this._map._animatingZoom||this._update()},_getTiledPixelBounds:function(m){var k=this._map,D=k._animatingZoom?Math.max(k._animateToZoom,k.getZoom()):k.getZoom(),V=k.getZoomScale(D,this._tileZoom),ue=k.project(m,this._tileZoom).floor(),Oe=k.getSize().divideBy(V*2);return new te(ue.subtract(Oe),ue.add(Oe))},_update:function(m){var k=this._map;if(k){var D=this._clampZoom(k.getZoom());if(m===void 0&&(m=k.getCenter()),this._tileZoom!==void 0){var V=this._getTiledPixelBounds(m),ue=this._pxBoundsToTileRange(V),Oe=ue.getCenter(),st=[],Et=this.options.keepBuffer,$t=new te(ue.getBottomLeft().subtract([Et,-Et]),ue.getTopRight().add([Et,-Et]));if(!(isFinite(ue.min.x)&&isFinite(ue.min.y)&&isFinite(ue.max.x)&&isFinite(ue.max.y)))throw new Error("Attempted to load an infinite number of tiles");for(var cr in this._tiles){var Er=this._tiles[cr].coords;(Er.z!==this._tileZoom||!$t.contains(new ve(Er.x,Er.y)))&&(this._tiles[cr].current=!1)}if(Math.abs(D-this._tileZoom)>1){this._setView(m,D);return}for(var Vr=ue.min.y;Vr<=ue.max.y;Vr++)for(var va=ue.min.x;va<=ue.max.x;va++){var Dn=new ve(va,Vr);if(Dn.z=this._tileZoom,!!this._isValidTile(Dn)){var Vs=this._tiles[this._tileCoordsToKey(Dn)];Vs?Vs.current=!0:st.push(Dn)}}if(st.sort(function(Ga,Ya){return Ga.distanceTo(Oe)-Ya.distanceTo(Oe)}),st.length!==0){this._loading||(this._loading=!0,this.fire("loading"));var Ri=document.createDocumentFragment();for(va=0;va<st.length;va++)this._addTile(st[va],Ri);this._level.el.appendChild(Ri)}}}},_isValidTile:function(m){var k=this._map.options.crs;if(!k.infinite){var D=this._globalTileRange;if(!k.wrapLng&&(m.x<D.min.x||m.x>D.max.x)||!k.wrapLat&&(m.y<D.min.y||m.y>D.max.y))return!1}if(!this.options.bounds)return!0;var V=this._tileCoordsToBounds(m);return ae(this.options.bounds).overlaps(V)},_keyToBounds:function(m){return this._tileCoordsToBounds(this._keyToTileCoords(m))},_tileCoordsToNwSe:function(m){var k=this._map,D=this.getTileSize(),V=m.scaleBy(D),ue=V.add(D),Oe=k.unproject(V,m.z),st=k.unproject(ue,m.z);return[Oe,st]},_tileCoordsToBounds:function(m){var k=this._tileCoordsToNwSe(m),D=new J(k[0],k[1]);return this.options.noWrap||(D=this._map.wrapLatLngBounds(D)),D},_tileCoordsToKey:function(m){return m.x+":"+m.y+":"+m.z},_keyToTileCoords:function(m){var k=m.split(":"),D=new ve(+k[0],+k[1]);return D.z=+k[2],D},_removeTile:function(m){var k=this._tiles[m];k&&(Sa(k.el),delete this._tiles[m],this.fire("tileunload",{tile:k.el,coords:this._keyToTileCoords(m)}))},_initTile:function(m){De(m,"leaflet-tile");var k=this.getTileSize();m.style.width=k.x+"px",m.style.height=k.y+"px",m.onselectstart=w,m.onmousemove=w,Re.ielt9&&this.options.opacity<1&&Wr(m,this.options.opacity)},_addTile:function(m,k){var D=this._getTilePos(m),V=this._tileCoordsToKey(m),ue=this.createTile(this._wrapCoords(m),c(this._tileReady,this,m));this._initTile(ue),this.createTile.length<2&&fe(c(this._tileReady,this,m,null,ue)),Qt(ue,D),this._tiles[V]={el:ue,coords:m,current:!0},k.appendChild(ue),this.fire("tileloadstart",{tile:ue,coords:m})},_tileReady:function(m,k,D){k&&this.fire("tileerror",{error:k,tile:D,coords:m});var V=this._tileCoordsToKey(m);D=this._tiles[V],D&&(D.loaded=+new Date,this._map._fadeAnimated?(Wr(D.el,0),K(this._fadeFrame),this._fadeFrame=fe(this._updateOpacity,this)):(D.active=!0,this._pruneTiles()),k||(De(D.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:D.el,coords:m})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),Re.ielt9||!this._map._fadeAnimated?fe(this._pruneTiles,this):setTimeout(c(this._pruneTiles,this),250)))},_getTilePos:function(m){return m.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(m){var k=new ve(this._wrapX?y(m.x,this._wrapX):m.x,this._wrapY?y(m.y,this._wrapY):m.y);return k.z=m.z,k},_pxBoundsToTileRange:function(m){var k=this.getTileSize();return new te(m.min.unscaleBy(k).floor(),m.max.unscaleBy(k).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var m in this._tiles)if(!this._tiles[m].loaded)return!1;return!0}});function xn(m){return new as(m)}var xa=as.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(m,k){this._url=m,k=C(this,k),k.detectRetina&&Re.retina&&k.maxZoom>0?(k.tileSize=Math.floor(k.tileSize/2),k.zoomReverse?(k.zoomOffset--,k.minZoom=Math.min(k.maxZoom,k.minZoom+1)):(k.zoomOffset++,k.maxZoom=Math.max(k.minZoom,k.maxZoom-1)),k.minZoom=Math.max(0,k.minZoom)):k.zoomReverse?k.minZoom=Math.min(k.maxZoom,k.minZoom):k.maxZoom=Math.max(k.minZoom,k.maxZoom),typeof k.subdomains=="string"&&(k.subdomains=k.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(m,k){return this._url===m&&k===void 0&&(k=!0),this._url=m,k||this.redraw(),this},createTile:function(m,k){var D=document.createElement("img");return bt(D,"load",c(this._tileOnLoad,this,k,D)),bt(D,"error",c(this._tileOnError,this,k,D)),(this.options.crossOrigin||this.options.crossOrigin==="")&&(D.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),typeof this.options.referrerPolicy=="string"&&(D.referrerPolicy=this.options.referrerPolicy),D.alt="",D.src=this.getTileUrl(m),D},getTileUrl:function(m){var k={r:Re.retina?"@2x":"",s:this._getSubdomain(m),x:m.x,y:m.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var D=this._globalTileRange.max.y-m.y;this.options.tms&&(k.y=D),k["-y"]=D}return R(this._url,n(k,this.options))},_tileOnLoad:function(m,k){Re.ielt9?setTimeout(c(m,this,null,k),0):m(null,k)},_tileOnError:function(m,k,D){var V=this.options.errorTileUrl;V&&k.getAttribute("src")!==V&&(k.src=V),m(D,k)},_onTileRemove:function(m){m.tile.onload=null},_getZoomForUrl:function(){var m=this._tileZoom,k=this.options.maxZoom,D=this.options.zoomReverse,V=this.options.zoomOffset;return D&&(m=k-m),m+V},_getSubdomain:function(m){var k=Math.abs(m.x+m.y)%this.options.subdomains.length;return this.options.subdomains[k]},_abortLoading:function(){var m,k;for(m in this._tiles)if(this._tiles[m].coords.z!==this._tileZoom&&(k=this._tiles[m].el,k.onload=w,k.onerror=w,!k.complete)){k.src=W;var D=this._tiles[m].coords;Sa(k),delete this._tiles[m],this.fire("tileabort",{tile:k,coords:D})}},_removeTile:function(m){var k=this._tiles[m];if(k)return k.el.setAttribute("src",W),as.prototype._removeTile.call(this,m)},_tileReady:function(m,k,D){if(!(!this._map||D&&D.getAttribute("src")===W))return as.prototype._tileReady.call(this,m,k,D)}});function Bs(m,k){return new xa(m,k)}var pn=xa.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(m,k){this._url=m;var D=n({},this.defaultWmsParams);for(var V in k)V in this.options||(D[V]=k[V]);k=C(this,k);var ue=k.detectRetina&&Re.retina?2:1,Oe=this.getTileSize();D.width=Oe.x*ue,D.height=Oe.y*ue,this.wmsParams=D},onAdd:function(m){this._crs=this.options.crs||m.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var k=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[k]=this._crs.code,xa.prototype.onAdd.call(this,m)},getTileUrl:function(m){var k=this._tileCoordsToNwSe(m),D=this._crs,V=q(D.project(k[0]),D.project(k[1])),ue=V.min,Oe=V.max,st=(this._wmsVersion>=1.3&&this._crs===co?[ue.y,ue.x,Oe.y,Oe.x]:[ue.x,ue.y,Oe.x,Oe.y]).join(","),Et=xa.prototype.getTileUrl.call(this,m);return Et+O(this.wmsParams,Et,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+st},setParams:function(m,k){return n(this.wmsParams,m),k||this.redraw(),this}});function oi(m,k){return new pn(m,k)}xa.WMS=pn,Bs.wms=oi;var ws=Rs.extend({options:{padding:.1},initialize:function(m){C(this,m),h(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),De(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 m={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(m.zoomanim=this._onAnimZoom),m},_onAnimZoom:function(m){this._updateTransform(m.center,m.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(m,k){var D=this._map.getZoomScale(k,this._zoom),V=this._map.getSize().multiplyBy(.5+this.options.padding),ue=this._map.project(this._center,k),Oe=V.multiplyBy(-D).add(ue).subtract(this._map._getNewPixelOrigin(m,k));Re.any3d?Me(this._container,Oe,D):Qt(this._container,Oe)},_reset:function(){this._update(),this._updateTransform(this._center,this._zoom);for(var m in this._layers)this._layers[m]._reset()},_onZoomEnd:function(){for(var m in this._layers)this._layers[m]._project()},_updatePaths:function(){for(var m in this._layers)this._layers[m]._update()},_update:function(){var m=this.options.padding,k=this._map.getSize(),D=this._map.containerPointToLayerPoint(k.multiplyBy(-m)).round();this._bounds=new te(D,D.add(k.multiplyBy(1+m*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),$n=ws.extend({options:{tolerance:0},getEvents:function(){var m=ws.prototype.getEvents.call(this);return m.viewprereset=this._onViewPreReset,m},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){ws.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var m=this._container=document.createElement("canvas");bt(m,"mousemove",this._onMouseMove,this),bt(m,"click dblclick mousedown mouseup contextmenu",this._onClick,this),bt(m,"mouseout",this._handleMouseOut,this),m._leaflet_disable_events=!0,this._ctx=m.getContext("2d")},_destroyContainer:function(){K(this._redrawRequest),delete this._ctx,Sa(this._container),gr(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var m;this._redrawBounds=null;for(var k in this._layers)m=this._layers[k],m._update();this._redraw()}},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){ws.prototype._update.call(this);var m=this._bounds,k=this._container,D=m.getSize(),V=Re.retina?2:1;Qt(k,m.min),k.width=V*D.x,k.height=V*D.y,k.style.width=D.x+"px",k.style.height=D.y+"px",Re.retina&&this._ctx.scale(2,2),this._ctx.translate(-m.min.x,-m.min.y),this.fire("update")}},_reset:function(){ws.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(m){this._updateDashArray(m),this._layers[h(m)]=m;var k=m._order={layer:m,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=k),this._drawLast=k,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(m){this._requestRedraw(m)},_removePath:function(m){var k=m._order,D=k.next,V=k.prev;D?D.prev=V:this._drawLast=V,V?V.next=D:this._drawFirst=D,delete m._order,delete this._layers[h(m)],this._requestRedraw(m)},_updatePath:function(m){this._extendRedrawBounds(m),m._project(),m._update(),this._requestRedraw(m)},_updateStyle:function(m){this._updateDashArray(m),this._requestRedraw(m)},_updateDashArray:function(m){if(typeof m.options.dashArray=="string"){var k=m.options.dashArray.split(/[, ]+/),D=[],V,ue;for(ue=0;ue<k.length;ue++){if(V=Number(k[ue]),isNaN(V))return;D.push(V)}m.options._dashArray=D}else m.options._dashArray=m.options.dashArray},_requestRedraw:function(m){this._map&&(this._extendRedrawBounds(m),this._redrawRequest=this._redrawRequest||fe(this._redraw,this))},_extendRedrawBounds:function(m){if(m._pxBounds){var k=(m.options.weight||0)+1;this._redrawBounds=this._redrawBounds||new te,this._redrawBounds.extend(m._pxBounds.min.subtract([k,k])),this._redrawBounds.extend(m._pxBounds.max.add([k,k]))}},_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 m=this._redrawBounds;if(m){var k=m.getSize();this._ctx.clearRect(m.min.x,m.min.y,k.x,k.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 m,k=this._redrawBounds;if(this._ctx.save(),k){var D=k.getSize();this._ctx.beginPath(),this._ctx.rect(k.min.x,k.min.y,D.x,D.y),this._ctx.clip()}this._drawing=!0;for(var V=this._drawFirst;V;V=V.next)m=V.layer,(!k||m._pxBounds&&m._pxBounds.intersects(k))&&m._updatePath();this._drawing=!1,this._ctx.restore()},_updatePoly:function(m,k){if(this._drawing){var D,V,ue,Oe,st=m._parts,Et=st.length,$t=this._ctx;if(Et){for($t.beginPath(),D=0;D<Et;D++){for(V=0,ue=st[D].length;V<ue;V++)Oe=st[D][V],$t[V?"lineTo":"moveTo"](Oe.x,Oe.y);k&&$t.closePath()}this._fillStroke($t,m)}}},_updateCircle:function(m){if(!(!this._drawing||m._empty())){var k=m._point,D=this._ctx,V=Math.max(Math.round(m._radius),1),ue=(Math.max(Math.round(m._radiusY),1)||V)/V;ue!==1&&(D.save(),D.scale(1,ue)),D.beginPath(),D.arc(k.x,k.y/ue,V,0,Math.PI*2,!1),ue!==1&&D.restore(),this._fillStroke(D,m)}},_fillStroke:function(m,k){var D=k.options;D.fill&&(m.globalAlpha=D.fillOpacity,m.fillStyle=D.fillColor||D.color,m.fill(D.fillRule||"evenodd")),D.stroke&&D.weight!==0&&(m.setLineDash&&m.setLineDash(k.options&&k.options._dashArray||[]),m.globalAlpha=D.opacity,m.lineWidth=D.weight,m.strokeStyle=D.color,m.lineCap=D.lineCap,m.lineJoin=D.lineJoin,m.stroke())},_onClick:function(m){for(var k=this._map.mouseEventToLayerPoint(m),D,V,ue=this._drawFirst;ue;ue=ue.next)D=ue.layer,D.options.interactive&&D._containsPoint(k)&&(!(m.type==="click"||m.type==="preclick")||!this._map._draggableMoved(D))&&(V=D);this._fireEvent(V?[V]:!1,m)},_onMouseMove:function(m){if(!(!this._map||this._map.dragging.moving()||this._map._animatingZoom)){var k=this._map.mouseEventToLayerPoint(m);this._handleMouseHover(m,k)}},_handleMouseOut:function(m){var k=this._hoveredLayer;k&&(wr(this._container,"leaflet-interactive"),this._fireEvent([k],m,"mouseout"),this._hoveredLayer=null,this._mouseHoverThrottled=!1)},_handleMouseHover:function(m,k){if(!this._mouseHoverThrottled){for(var D,V,ue=this._drawFirst;ue;ue=ue.next)D=ue.layer,D.options.interactive&&D._containsPoint(k)&&(V=D);V!==this._hoveredLayer&&(this._handleMouseOut(m),V&&(De(this._container,"leaflet-interactive"),this._fireEvent([V],m,"mouseover"),this._hoveredLayer=V)),this._fireEvent(this._hoveredLayer?[this._hoveredLayer]:!1,m),this._mouseHoverThrottled=!0,setTimeout(c(function(){this._mouseHoverThrottled=!1},this),32)}},_fireEvent:function(m,k,D){this._map._fireDOMEvent(k,D||k.type,m)},_bringToFront:function(m){var k=m._order;if(k){var D=k.next,V=k.prev;if(D)D.prev=V;else return;V?V.next=D:D&&(this._drawFirst=D),k.prev=this._drawLast,this._drawLast.next=k,k.next=null,this._drawLast=k,this._requestRedraw(m)}},_bringToBack:function(m){var k=m._order;if(k){var D=k.next,V=k.prev;if(V)V.next=D;else return;D?D.prev=V:V&&(this._drawLast=V),k.prev=null,k.next=this._drawFirst,this._drawFirst.prev=k,this._drawFirst=k,this._requestRedraw(m)}}});function bl(m){return Re.canvas?new $n(m):null}var vl=(function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(m){return document.createElement("<lvml:"+m+' class="lvml">')}}catch(m){}return function(m){return document.createElement("<"+m+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}})(),du={_initContainer:function(){this._container=Gr("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(ws.prototype._update.call(this),this.fire("update"))},_initPath:function(m){var k=m._container=vl("shape");De(k,"leaflet-vml-shape "+(this.options.className||"")),k.coordsize="1 1",m._path=vl("path"),k.appendChild(m._path),this._updateStyle(m),this._layers[h(m)]=m},_addPath:function(m){var k=m._container;this._container.appendChild(k),m.options.interactive&&m.addInteractiveTarget(k)},_removePath:function(m){var k=m._container;Sa(k),m.removeInteractiveTarget(k),delete this._layers[h(m)]},_updateStyle:function(m){var k=m._stroke,D=m._fill,V=m.options,ue=m._container;ue.stroked=!!V.stroke,ue.filled=!!V.fill,V.stroke?(k||(k=m._stroke=vl("stroke")),ue.appendChild(k),k.weight=V.weight+"px",k.color=V.color,k.opacity=V.opacity,V.dashArray?k.dashStyle=F(V.dashArray)?V.dashArray.join(" "):V.dashArray.replace(/( *, *)/g," "):k.dashStyle="",k.endcap=V.lineCap.replace("butt","flat"),k.joinstyle=V.lineJoin):k&&(ue.removeChild(k),m._stroke=null),V.fill?(D||(D=m._fill=vl("fill")),ue.appendChild(D),D.color=V.fillColor||V.color,D.opacity=V.fillOpacity):D&&(ue.removeChild(D),m._fill=null)},_updateCircle:function(m){var k=m._point.round(),D=Math.round(m._radius),V=Math.round(m._radiusY||D);this._setPath(m,m._empty()?"M0 0":"AL "+k.x+","+k.y+" "+D+","+V+" 0,"+65535*360)},_setPath:function(m,k){m._path.v=k},_bringToFront:function(m){ha(m._container)},_bringToBack:function(m){_s(m._container)}},Oo=Re.vml?vl:et,wc=ws.extend({_initContainer:function(){this._container=Oo("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=Oo("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){Sa(this._container),gr(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){ws.prototype._update.call(this);var m=this._bounds,k=m.getSize(),D=this._container;(!this._svgSize||!this._svgSize.equals(k))&&(this._svgSize=k,D.setAttribute("width",k.x),D.setAttribute("height",k.y)),Qt(D,m.min),D.setAttribute("viewBox",[m.min.x,m.min.y,k.x,k.y].join(" ")),this.fire("update")}},_initPath:function(m){var k=m._path=Oo("path");m.options.className&&De(k,m.options.className),m.options.interactive&&De(k,"leaflet-interactive"),this._updateStyle(m),this._layers[h(m)]=m},_addPath:function(m){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(m._path),m.addInteractiveTarget(m._path)},_removePath:function(m){Sa(m._path),m.removeInteractiveTarget(m._path),delete this._layers[h(m)]},_updatePath:function(m){m._project(),m._update()},_updateStyle:function(m){var k=m._path,D=m.options;k&&(D.stroke?(k.setAttribute("stroke",D.color),k.setAttribute("stroke-opacity",D.opacity),k.setAttribute("stroke-width",D.weight),k.setAttribute("stroke-linecap",D.lineCap),k.setAttribute("stroke-linejoin",D.lineJoin),D.dashArray?k.setAttribute("stroke-dasharray",D.dashArray):k.removeAttribute("stroke-dasharray"),D.dashOffset?k.setAttribute("stroke-dashoffset",D.dashOffset):k.removeAttribute("stroke-dashoffset")):k.setAttribute("stroke","none"),D.fill?(k.setAttribute("fill",D.fillColor||D.color),k.setAttribute("fill-opacity",D.fillOpacity),k.setAttribute("fill-rule",D.fillRule||"evenodd")):k.setAttribute("fill","none"))},_updatePoly:function(m,k){this._setPath(m,It(m._parts,k))},_updateCircle:function(m){var k=m._point,D=Math.max(Math.round(m._radius),1),V=Math.max(Math.round(m._radiusY),1)||D,ue="a"+D+","+V+" 0 1,0 ",Oe=m._empty()?"M0 0":"M"+(k.x-D)+","+k.y+ue+D*2+",0 "+ue+-D*2+",0 ";this._setPath(m,Oe)},_setPath:function(m,k){m._path.setAttribute("d",k)},_bringToFront:function(m){ha(m._path)},_bringToBack:function(m){_s(m._path)}});Re.vml&&wc.include(du);function ad(m){return Re.svg||Re.vml?new wc(m):null}ga.include({getRenderer:function(m){var k=m.options.renderer||this._getPaneRenderer(m.options.pane)||this.options.renderer||this._renderer;return k||(k=this._renderer=this._createRenderer()),this.hasLayer(k)||this.addLayer(k),k},_getPaneRenderer:function(m){if(m==="overlayPane"||m===void 0)return!1;var k=this._paneRenderers[m];return k===void 0&&(k=this._createRenderer({pane:m}),this._paneRenderers[m]=k),k},_createRenderer:function(m){return this.options.preferCanvas&&bl(m)||ad(m)}});var Wl=x.extend({initialize:function(m,k){x.prototype.initialize.call(this,this._boundsToLatLngs(m),k)},setBounds:function(m){return this.setLatLngs(this._boundsToLatLngs(m))},_boundsToLatLngs:function(m){return m=ae(m),[m.getSouthWest(),m.getNorthWest(),m.getNorthEast(),m.getSouthEast()]}});function zg(m,k){return new Wl(m,k)}wc.create=Oo,wc.pointsToPath=It,v.geometryToLayer=j,v.coordsToLatLng=P,v.coordsToLatLngs=H,v.latLngToCoords=de,v.latLngsToCoords=je,v.getFeature=Ae,v.asFeature=Ge,ga.mergeOptions({boxZoom:!0});var bi=An.extend({initialize:function(m){this._map=m,this._container=m._container,this._pane=m._panes.overlayPane,this._resetStateTimeout=0,m.on("unload",this._destroy,this)},addHooks:function(){bt(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){gr(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){Sa(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(m){if(!m.shiftKey||m.which!==1&&m.button!==1)return!1;this._clearDeferredResetState(),this._resetState(),Oa(),xr(),this._startPoint=this._map.mouseEventToContainerPoint(m),bt(document,{contextmenu:en,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(m){this._moved||(this._moved=!0,this._box=Gr("div","leaflet-zoom-box",this._container),De(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(m);var k=new te(this._point,this._startPoint),D=k.getSize();Qt(this._box,k.min),this._box.style.width=D.x+"px",this._box.style.height=D.y+"px"},_finish:function(){this._moved&&(Sa(this._box),wr(this._container,"leaflet-crosshair")),Va(),ua(),gr(document,{contextmenu:en,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(m){if(!(m.which!==1&&m.button!==1)&&(this._finish(),!!this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(c(this._resetState,this),0);var k=new J(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(k).fire("boxzoomend",{boxZoomBounds:k})}},_onKeyDown:function(m){m.keyCode===27&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});ga.addInitHook("addHandler","boxZoom",bi),ga.mergeOptions({doubleClickZoom:!0});var Qd=An.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(m){var k=this._map,D=k.getZoom(),V=k.options.zoomDelta,ue=m.originalEvent.shiftKey?D-V:D+V;k.options.doubleClickZoom==="center"?k.setZoom(ue):k.setZoomAround(m.containerPoint,ue)}});ga.addInitHook("addHandler","doubleClickZoom",Qd),ga.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var Do=An.extend({addHooks:function(){if(!this._draggable){var m=this._map;this._draggable=new $i(m._mapPane,m._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),m.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),m.on("zoomend",this._onZoomEnd,this),m.whenReady(this._onZoomEnd,this))}De(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){wr(this._map._container,"leaflet-grab"),wr(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 m=this._map;if(m._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var k=ae(this._map.options.maxBounds);this._offsetLimit=q(this._map.latLngToContainerPoint(k.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(k.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;m.fire("movestart").fire("dragstart"),m.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(m){if(this._map.options.inertia){var k=this._lastTime=+new Date,D=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(D),this._times.push(k),this._prunePositions(k)}this._map.fire("move",m).fire("drag",m)},_prunePositions:function(m){for(;this._positions.length>1&&m-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var m=this._map.getSize().divideBy(2),k=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=k.subtract(m).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(m,k){return m-(m-k)*this._viscosity},_onPreDragLimit:function(){if(!(!this._viscosity||!this._offsetLimit)){var m=this._draggable._newPos.subtract(this._draggable._startPos),k=this._offsetLimit;m.x<k.min.x&&(m.x=this._viscousLimit(m.x,k.min.x)),m.y<k.min.y&&(m.y=this._viscousLimit(m.y,k.min.y)),m.x>k.max.x&&(m.x=this._viscousLimit(m.x,k.max.x)),m.y>k.max.y&&(m.y=this._viscousLimit(m.y,k.max.y)),this._draggable._newPos=this._draggable._startPos.add(m)}},_onPreDragWrap:function(){var m=this._worldWidth,k=Math.round(m/2),D=this._initialWorldOffset,V=this._draggable._newPos.x,ue=(V-k+D)%m+k-D,Oe=(V+k+D)%m-k-D,st=Math.abs(ue+D)<Math.abs(Oe+D)?ue:Oe;this._draggable._absPos=this._draggable._newPos.clone(),this._draggable._newPos.x=st},_onDragEnd:function(m){var k=this._map,D=k.options,V=!D.inertia||m.noInertia||this._times.length<2;if(k.fire("dragend",m),V)k.fire("moveend");else{this._prunePositions(+new Date);var ue=this._lastPos.subtract(this._positions[0]),Oe=(this._lastTime-this._times[0])/1e3,st=D.easeLinearity,Et=ue.multiplyBy(st/Oe),$t=Et.distanceTo([0,0]),cr=Math.min(D.inertiaMaxSpeed,$t),Er=Et.multiplyBy(cr/$t),Vr=cr/(D.inertiaDeceleration*st),va=Er.multiplyBy(-Vr/2).round();!va.x&&!va.y?k.fire("moveend"):(va=k._limitOffset(va,k.options.maxBounds),fe(function(){k.panBy(va,{duration:Vr,easeLinearity:st,noMoveStart:!0,animate:!0})}))}}});ga.addInitHook("addHandler","dragging",Do),ga.mergeOptions({keyboard:!0,keyboardPanDelta:80});var uu=An.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,54,173]},initialize:function(m){this._map=m,this._setPanDelta(m.options.keyboardPanDelta),this._setZoomDelta(m.options.zoomDelta)},addHooks:function(){var m=this._map._container;m.tabIndex<=0&&(m.tabIndex="0"),bt(m,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)},removeHooks:function(){this._removeHooks(),gr(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 m=document.body,k=document.documentElement,D=m.scrollTop||k.scrollTop,V=m.scrollLeft||k.scrollLeft;this._map._container.focus(),window.scrollTo(V,D)}},_onFocus:function(){this._focused=!0,this._map.fire("focus")},_onBlur:function(){this._focused=!1,this._map.fire("blur")},_setPanDelta:function(m){var k=this._panKeys={},D=this.keyCodes,V,ue;for(V=0,ue=D.left.length;V<ue;V++)k[D.left[V]]=[-1*m,0];for(V=0,ue=D.right.length;V<ue;V++)k[D.right[V]]=[m,0];for(V=0,ue=D.down.length;V<ue;V++)k[D.down[V]]=[0,m];for(V=0,ue=D.up.length;V<ue;V++)k[D.up[V]]=[0,-1*m]},_setZoomDelta:function(m){var k=this._zoomKeys={},D=this.keyCodes,V,ue;for(V=0,ue=D.zoomIn.length;V<ue;V++)k[D.zoomIn[V]]=m;for(V=0,ue=D.zoomOut.length;V<ue;V++)k[D.zoomOut[V]]=-m},_addHooks:function(){bt(document,"keydown",this._onKeyDown,this)},_removeHooks:function(){gr(document,"keydown",this._onKeyDown,this)},_onKeyDown:function(m){if(!(m.altKey||m.ctrlKey||m.metaKey)){var k=m.keyCode,D=this._map,V;if(k in this._panKeys){if(!D._panAnim||!D._panAnim._inProgress)if(V=this._panKeys[k],m.shiftKey&&(V=ye(V).multiplyBy(3)),D.options.maxBounds&&(V=D._limitOffset(ye(V),D.options.maxBounds)),D.options.worldCopyJump){var ue=D.wrapLatLng(D.unproject(D.project(D.getCenter()).add(V)));D.panTo(ue)}else D.panBy(V)}else if(k in this._zoomKeys)D.setZoom(D.getZoom()+(m.shiftKey?3:1)*this._zoomKeys[k]);else if(k===27&&D._popup&&D._popup.options.closeOnEscapeKey)D.closePopup();else return;en(m)}}});ga.addInitHook("addHandler","keyboard",uu),ga.mergeOptions({scrollWheelZoom:!0,wheelDebounceTime:40,wheelPxPerZoomLevel:60});var sd=An.extend({addHooks:function(){bt(this._map._container,"wheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){gr(this._map._container,"wheel",this._onWheelScroll,this)},_onWheelScroll:function(m){var k=cs(m),D=this._map.options.wheelDebounceTime;this._delta+=k,this._lastMousePos=this._map.mouseEventToContainerPoint(m),this._startTime||(this._startTime=+new Date);var V=Math.max(D-(+new Date-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(c(this._performZoom,this),V),en(m)},_performZoom:function(){var m=this._map,k=m.getZoom(),D=this._map.options.zoomSnap||0;m._stop();var V=this._delta/(this._map.options.wheelPxPerZoomLevel*4),ue=4*Math.log(2/(1+Math.exp(-Math.abs(V))))/Math.LN2,Oe=D?Math.ceil(ue/D)*D:ue,st=m._limitZoom(k+(this._delta>0?Oe:-Oe))-k;this._delta=0,this._startTime=null,st&&(m.options.scrollWheelZoom==="center"?m.setZoom(k+st):m.setZoomAround(this._lastMousePos,k+st))}});ga.addInitHook("addHandler","scrollWheelZoom",sd);var Hl=600;ga.mergeOptions({tapHold:Re.touchNative&&Re.safari&&Re.mobile,tapTolerance:15});var e0=An.extend({addHooks:function(){bt(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){gr(this._map._container,"touchstart",this._onDown,this)},_onDown:function(m){if(clearTimeout(this._holdTimeout),m.touches.length===1){var k=m.touches[0];this._startPos=this._newPos=new ve(k.clientX,k.clientY),this._holdTimeout=setTimeout(c(function(){this._cancel(),this._isTapValid()&&(bt(document,"touchend",Qa),bt(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",k))},this),Hl),bt(document,"touchend touchcancel contextmenu",this._cancel,this),bt(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function m(){gr(document,"touchend",Qa),gr(document,"touchend touchcancel",m)},_cancel:function(){clearTimeout(this._holdTimeout),gr(document,"touchend touchcancel contextmenu",this._cancel,this),gr(document,"touchmove",this._onMove,this)},_onMove:function(m){var k=m.touches[0];this._newPos=new ve(k.clientX,k.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(m,k){var D=new MouseEvent(m,{bubbles:!0,cancelable:!0,view:window,screenX:k.screenX,screenY:k.screenY,clientX:k.clientX,clientY:k.clientY});D._simulated=!0,k.target.dispatchEvent(D)}});ga.addInitHook("addHandler","tapHold",e0),ga.mergeOptions({touchZoom:Re.touch,bounceAtZoomLimits:!0});var fu=An.extend({addHooks:function(){De(this._map._container,"leaflet-touch-zoom"),bt(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){wr(this._map._container,"leaflet-touch-zoom"),gr(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(m){var k=this._map;if(!(!m.touches||m.touches.length!==2||k._animatingZoom||this._zooming)){var D=k.mouseEventToContainerPoint(m.touches[0]),V=k.mouseEventToContainerPoint(m.touches[1]);this._centerPoint=k.getSize()._divideBy(2),this._startLatLng=k.containerPointToLatLng(this._centerPoint),k.options.touchZoom!=="center"&&(this._pinchStartLatLng=k.containerPointToLatLng(D.add(V)._divideBy(2))),this._startDist=D.distanceTo(V),this._startZoom=k.getZoom(),this._moved=!1,this._zooming=!0,k._stop(),bt(document,"touchmove",this._onTouchMove,this),bt(document,"touchend touchcancel",this._onTouchEnd,this),Qa(m)}},_onTouchMove:function(m){if(!(!m.touches||m.touches.length!==2||!this._zooming)){var k=this._map,D=k.mouseEventToContainerPoint(m.touches[0]),V=k.mouseEventToContainerPoint(m.touches[1]),ue=D.distanceTo(V)/this._startDist;if(this._zoom=k.getScaleZoom(ue,this._startZoom),!k.options.bounceAtZoomLimits&&(this._zoom<k.getMinZoom()&&ue<1||this._zoom>k.getMaxZoom()&&ue>1)&&(this._zoom=k._limitZoom(this._zoom)),k.options.touchZoom==="center"){if(this._center=this._startLatLng,ue===1)return}else{var Oe=D._add(V)._divideBy(2)._subtract(this._centerPoint);if(ue===1&&Oe.x===0&&Oe.y===0)return;this._center=k.unproject(k.project(this._pinchStartLatLng,this._zoom).subtract(Oe),this._zoom)}this._moved||(k._moveStart(!0,!1),this._moved=!0),K(this._animRequest);var st=c(k._move,k,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=fe(st,this,!0),Qa(m)}},_onTouchEnd:function(){if(!this._moved||!this._zooming){this._zooming=!1;return}this._zooming=!1,K(this._animRequest),gr(document,"touchmove",this._onTouchMove,this),gr(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))}});ga.addInitHook("addHandler","touchZoom",fu),ga.BoxZoom=bi,ga.DoubleClickZoom=Qd,ga.Drag=Do,ga.Keyboard=uu,ga.ScrollWheelZoom=sd,ga.TapHold=e0,ga.TouchZoom=fu,a.Bounds=te,a.Browser=Re,a.CRS=be,a.Canvas=$n,a.Circle=tn,a.CircleMarker=ii,a.Class=ge,a.Control=Tn,a.DivIcon=gs,a.DivOverlay=Ar,a.DomEvent=es,a.DomUtil=it,a.Draggable=$i,a.Evented=ee,a.FeatureGroup=si,a.GeoJSON=v,a.GridLayer=as,a.Handler=An,a.Icon=pi,a.ImageOverlay=se,a.LatLng=oe,a.LatLngBounds=J,a.Layer=Rs,a.LayerGroup=Di,a.LineUtil=vc,a.Map=ga,a.Marker=gn,a.Mixin=pc,a.Path=Hn,a.Point=ve,a.PolyUtil=Ko,a.Polygon=x,a.Polyline=l,a.Popup=ra,a.PosAnimation=ei,a.Projection=ds,a.Rectangle=Wl,a.Renderer=ws,a.SVG=wc,a.SVGOverlay=ur,a.TileLayer=xa,a.Tooltip=Dr,a.Transformation=Be,a.Util=ke,a.VideoOverlay=Ue,a.bind=c,a.bounds=q,a.canvas=bl,a.circle=Ne,a.circleMarker=ja,a.control=Oi,a.divIcon=vs,a.extend=n,a.featureGroup=ni,a.geoJSON=ut,a.geoJson=At,a.gridLayer=xn,a.icon=yi,a.imageOverlay=Ee,a.latLng=le,a.latLngBounds=ae,a.layerGroup=Wn,a.map=ti,a.marker=zl,a.point=ye,a.polygon=b,a.polyline=f,a.popup=La,a.rectangle=zg,a.setOptions=C,a.stamp=h,a.svg=ad,a.svgOverlay=tr,a.tileLayer=Bs,a.tooltip=Ta,a.transformation=pe,a.version=s,a.videoOverlay=ht;var hu=window.L;a.noConflict=function(){return window.L=hu,this},window.L=a}))})(lf,lf.exports)),lf.exports}var lu=q$();const Bg=J1(lu);function Ug(e,r,a){return Object.freeze({instance:e,context:r,container:a})}function gb(e,r){return r==null?function(s,n){const i=_.useRef(void 0);return i.current||(i.current=e(s,n)),i}:function(s,n){const i=_.useRef(void 0);i.current||(i.current=e(s,n));const c=_.useRef(s),{instance:u}=i.current;return _.useEffect(function(){c.current!==s&&(r(u,s,c.current),c.current=s)},[u,s,r]),i}}function X$(e,r){_.useEffect(function(){var n;return((n=r.layerContainer)!=null?n:r.map).addLayer(e.instance),function(){var c;(c=r.layerContainer)==null||c.removeLayer(e.instance),r.map.removeLayer(e.instance)}},[r,e])}function bS(e){return function(a){const s=hb(),n=e(mb(a,s),s);return pS(s.map,a.attribution),yS(n.current,a.eventHandlers),X$(n.current,s),n}}function Z$(e,r){const a=gb(e,r),s=bS(a);return H$(s)}function vS(e,r){const a=gb(e),s=G$(a,r);return $$(s)}function K$(e,r){const a=gb(e,r),s=bS(a);return V$(s)}function J$(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 Q$(){return hb().map}function eV(E,w){var S=E,{bounds:e,boundsOptions:r,center:a,children:s,className:n,id:i,placeholder:c,style:u,whenReady:h,zoom:g}=S,y=Ji(S,["bounds","boundsOptions","center","children","className","id","placeholder","style","whenReady","zoom"]);const[A]=_.useState({className:n,id:i,style:u}),[C,O]=_.useState(null),M=_.useRef(void 0);_.useImperativeHandle(w,()=>{var z;return(z=C==null?void 0:C.map)!=null?z:null},[C]);const R=_.useCallback(z=>{if(z!==null&&!M.current){const W=new lu.Map(z,y);M.current=W,a!=null&&g!=null?W.setView(a,g):e!=null&&W.fitBounds(e,r),h!=null&&W.whenReady(h),O(z$(W))}},[]);_.useEffect(()=>()=>{C==null||C.map.remove()},[C]);const F=C?ea.createElement(fb,{value:C},s):c!=null?c:null;return ea.createElement("div",Ke(Te({},A),{ref:R}),F)}const tV=_.forwardRef(eV),rV=Z$(function(n,s){var i=n,{position:r}=i,a=Ji(i,["position"]);const c=new lu.Marker(r,a);return Ug(c,W$(s,{overlayContainer:c}))},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())}),aV=vS(function(r,a){const s=new lu.Popup(r,a.overlayContainer);return Ug(s,a)},function(r,a,{position:s},n){_.useEffect(function(){const{instance:c}=r;function u(g){g.popup===c&&(c.update(),n(!0))}function h(g){g.popup===c&&n(!1)}return a.map.on({popupopen:u,popupclose:h}),a.overlayContainer==null?(s!=null&&c.setLatLng(s),c.openOn(a.map)):a.overlayContainer.bindPopup(c),function(){var y;a.map.off({popupopen:u,popupclose:h}),(y=a.overlayContainer)==null||y.unbindPopup(),a.map.removeLayer(c)}},[r,a,n,s])}),sV=K$(function(n,s){var i=n,{url:r}=i,a=Ji(i,["url"]);const c=new lu.TileLayer(r,mb(a,s));return Ug(c,s)},function(r,a,s){J$(r,a,s);const{url:n}=a;n!=null&&n!==s.url&&r.setUrl(n)}),nV=vS(function(r,a){const s=new lu.Tooltip(r,a.overlayContainer);return Ug(s,a)},function(r,a,{position:s},n){_.useEffect(function(){const c=a.overlayContainer;if(c==null)return;const{instance:u}=r,h=y=>{y.tooltip===u&&(s!=null&&u.setLatLng(s),u.update(),n(!0))},g=y=>{y.tooltip===u&&n(!1)};return c.on({tooltipopen:h,tooltipclose:g}),c.bindTooltip(u),function(){c.off({tooltipopen:h,tooltipclose:g}),c._map!=null&&c.unbindTooltip()}},[r,a,n,s])}),wS="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=",_S="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC",kS=Bg.icon({iconUrl:wS,shadowUrl:_S,iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]});Bg.Marker.prototype.options.icon=kS;const iV=Bg.icon({iconUrl:wS,shadowUrl:_S,iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41],className:"department-marker-icon"}),oV=({locations:e})=>{const r=Q$();return _.useEffect(()=>{if(e.length>0&&e.some(a=>a.latitude&&a.longitude)){const a=Bg.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},lV=()=>{const{t:e}=Rr(),r=Na(),[a,s]=_.useState(""),[n,i]=_.useState(""),[c,u]=_.useState([]),[h,g]=_.useState(!0),y=_.useRef({}),[w,E]=_.useState(null),[S,A]=_.useState(!1);_.useEffect(()=>{me(null,null,function*(){try{const ie=yield(yield fetch("/api/method/frappe.auth.get_logged_user")).json(),fe=ie==null?void 0:ie.message;if(!fe){console.warn("[ActiveMap] Could not determine logged-in user, response:",ie),E(null),A(!0);return}console.log("[ActiveMap] Logged-in user:",fe);const ke=yield(yield fetch(`/api/resource/User Permission?filters=${encodeURIComponent(JSON.stringify({user:fe,allow:"Issue Type"}))}&fields=["for_value"]&limit_page_length=0`)).json(),ge=(ke==null?void 0:ke.data)||[];if(ge.length>0){const re=ge.map(we=>we.for_value).filter(Boolean);console.log("[ActiveMap] Allowed departments:",re),E(re)}else console.log("[ActiveMap] No Issue Type permissions → showing all departments"),E(null)}catch(G){console.error("[ActiveMap] Error fetching User Permissions:",G),E(null)}finally{A(!0)}})},[]);const C=()=>me(null,null,function*(){if(S){g(!0);try{const Y=[];if(!n){const G={latitude:["!=",""],longitude:["!=",""],custom_is_hospital:1};a&&(G.name=a);const ie=yield Xt.apiCall(`/api/resource/Location?filters=${encodeURIComponent(JSON.stringify(G))}&fields=["name","latitude","longitude"]&limit_page_length=0`),K=((ie==null?void 0:ie.data)||[]).map(ge=>me(null,null,function*(){var we,ee,ve,ce,ye,te,q,J,ae,oe,le;const re={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 be=yield Xt.apiCall(`/api/resource/Asset?filters=${encodeURIComponent(JSON.stringify({company:ge.name}))}&fields=["name"]&limit_page_length=0`);re.assets=((we=be==null?void 0:be.data)==null?void 0:we.length)||0;const Z=yield Xt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:ge.name,custom_priority_:"Normal",repair_status:["in",["Open","Work In Progress","Closed"]]}))}&fields=["name"]&limit_page_length=0`);re.normal_work_orders=((ee=Z==null?void 0:Z.data)==null?void 0:ee.length)||0;const Le=yield Xt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:ge.name,custom_priority_:"Urgent",repair_status:["in",["Open","Work In Progress","Closed"]]}))}&fields=["name"]&limit_page_length=0`);re.urgent_work_orders=((ve=Le==null?void 0:Le.data)==null?void 0:ve.length)||0;const[Pe,Be,pe,rt,ct,et,It,ft]=yield Promise.all([Xt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:ge.name,repair_status:"Open"}))}&fields=["name"]&limit_page_length=0`),Xt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:ge.name,repair_status:"Work In Progress"}))}&fields=["name"]&limit_page_length=0`),Xt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:ge.name,repair_status:"Pending Review"}))}&fields=["name"]&limit_page_length=0`),Xt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:ge.name,repair_status:"Completed"}))}&fields=["name"]&limit_page_length=0`),Xt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:ge.name,repair_status:"Closed"}))}&fields=["name"]&limit_page_length=0`),Xt.apiCall(`/api/resource/Asset Maintenance Log?filters=${encodeURIComponent(JSON.stringify({custom_hospital_name:ge.name,maintenance_status:"Planned"}))}&fields=["name"]&limit_page_length=0`),Xt.apiCall(`/api/resource/Asset Maintenance Log?filters=${encodeURIComponent(JSON.stringify({custom_hospital_name:ge.name,maintenance_status:"Completed"}))}&fields=["name"]&limit_page_length=0`),Xt.apiCall(`/api/resource/Asset Maintenance Log?filters=${encodeURIComponent(JSON.stringify({custom_hospital_name:ge.name,maintenance_status:"Overdue"}))}&fields=["name"]&limit_page_length=0`)]);re.wo_open=((ce=Pe==null?void 0:Pe.data)==null?void 0:ce.length)||0,re.wo_progress=((ye=Be==null?void 0:Be.data)==null?void 0:ye.length)||0,re.wo_review=((te=pe==null?void 0:pe.data)==null?void 0:te.length)||0,re.wo_completed=((q=rt==null?void 0:rt.data)==null?void 0:q.length)||0,re.wo_closed=((J=ct==null?void 0:ct.data)==null?void 0:J.length)||0,re.planned_maintenance=((ae=et==null?void 0:et.data)==null?void 0:ae.length)||0,re.completed_maintenance=((oe=It==null?void 0:It.data)==null?void 0:oe.length)||0,re.overdue_maintenance=((le=ft==null?void 0:ft.data)==null?void 0:le.length)||0}catch(be){console.error(`Error fetching counts for hospital ${ge.name}:`,be)}return Te({name:ge.name,latitude:parseFloat(ge.latitude),longitude:parseFloat(ge.longitude)},re)})),ke=yield Promise.all(K);Y.push(...ke.filter(ge=>!isNaN(ge.latitude)&&!isNaN(ge.longitude)))}if(!a){const G={latitude:["!=",""],longitude:["!=",""],custom_is_wo_type:1};if(n&&(G.name=n),w!==null&&w.length>0&&!n)G.name=["in",w];else if(w!==null&&w.length===0){console.log("[ActiveMap] User has Issue Type permissions but no matching values — skipping departments"),u(Y),g(!1);return}console.log("[ActiveMap] Department filters:",G);const ie=yield Xt.apiCall(`/api/resource/Location?filters=${encodeURIComponent(JSON.stringify(G))}&fields=["name","latitude","longitude"]&limit_page_length=0`),fe=(ie==null?void 0:ie.data)||[];console.log("[ActiveMap] Departments to show on map:",fe.map(ge=>ge.name));const K=fe.map(ge=>me(null,null,function*(){var we,ee,ve,ce,ye,te,q;const re={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 J=yield Xt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:ge.name,custom_priority_:"Normal",repair_status:["in",["Open","Work In Progress","Closed"]]}))}&fields=["name"]&limit_page_length=0`);re.normal_work_orders=((we=J==null?void 0:J.data)==null?void 0:we.length)||0;const ae=yield Xt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:ge.name,custom_priority_:"Urgent",repair_status:["in",["Open","Work In Progress","Closed"]]}))}&fields=["name"]&limit_page_length=0`);re.urgent_work_orders=((ee=ae==null?void 0:ae.data)==null?void 0:ee.length)||0;const[oe,le,be,Z,Le]=yield Promise.all([Xt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:ge.name,repair_status:"Open"}))}&fields=["name"]&limit_page_length=0`),Xt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:ge.name,repair_status:"Work In Progress"}))}&fields=["name"]&limit_page_length=0`),Xt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:ge.name,repair_status:"Pending Review"}))}&fields=["name"]&limit_page_length=0`),Xt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:ge.name,repair_status:"Completed"}))}&fields=["name"]&limit_page_length=0`),Xt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:ge.name,repair_status:"Closed"}))}&fields=["name"]&limit_page_length=0`)]);re.wo_open=((ve=oe==null?void 0:oe.data)==null?void 0:ve.length)||0,re.wo_progress=((ce=le==null?void 0:le.data)==null?void 0:ce.length)||0,re.wo_review=((ye=be==null?void 0:be.data)==null?void 0:ye.length)||0,re.wo_completed=((te=Z==null?void 0:Z.data)==null?void 0:te.length)||0,re.wo_closed=((q=Le==null?void 0:Le.data)==null?void 0:q.length)||0}catch(J){console.error(`Error fetching counts for department ${ge.name}:`,J)}return Te({name:ge.name,latitude:parseFloat(ge.latitude),longitude:parseFloat(ge.longitude)},re)})),ke=yield Promise.all(K);Y.push(...ke.filter(ge=>!isNaN(ge.latitude)&&!isNaN(ge.longitude)))}u(Y)}catch(Y){console.error("Error fetching map data:",Y)}finally{g(!1)}}});_.useEffect(()=>{C()},[a,n,S]);const O=Y=>{s(Y),Y&&i("")},M=Y=>{i(Y),Y&&s("")},R=(Y,G,ie,fe)=>{const K=new URLSearchParams;G==="hospital"?Y&&K.set("company",Y):Y&&K.set("work_order_type",Y),ie&&K.set("priority",ie),fe&&K.set("status",fe),r(`/work-orders?${K.toString()}`)},F=Y=>{const G=new URLSearchParams;Y&&G.set("company",Y),r(`/assets?${G.toString()}`)},z=(Y,G)=>{const ie=new URLSearchParams;Y&&ie.set("hospital",Y),G&&ie.set("status",G),r(`/maintenance-calendar?${ie.toString()}`)},W=Y=>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:Y.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:Y.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:()=>R(Y.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"),": ",Y.normal_work_orders]}),t.jsxs("button",{onClick:()=>R(Y.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"),": ",Y.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:()=>R(Y.name,"hospital",void 0,"Open"),className:"text-red-700 dark:text-red-400 font-bold hover:underline cursor-pointer",children:Y.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:()=>R(Y.name,"hospital",void 0,"Work In Progress"),className:"text-yellow-700 dark:text-yellow-400 font-bold hover:underline cursor-pointer",children:Y.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:()=>R(Y.name,"hospital",void 0,"Pending Review"),className:"text-blue-700 dark:text-blue-400 font-bold hover:underline cursor-pointer",children:Y.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:()=>R(Y.name,"hospital",void 0,"Completed"),className:"text-green-700 dark:text-green-400 font-bold hover:underline cursor-pointer",children:Y.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:()=>R(Y.name,"hospital",void 0,"Closed"),className:"text-gray-700 dark:text-gray-400 font-bold hover:underline cursor-pointer",children:Y.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:()=>z(Y.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"),": ",Y.planned_maintenance]}),t.jsxs("button",{onClick:()=>z(Y.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"),": ",Y.completed_maintenance]}),t.jsxs("button",{onClick:()=>z(Y.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"),": ",Y.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:()=>F(Y.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:()=>R(Y.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")})]})]}),X=Y=>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:Y.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:()=>R(Y.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"),": ",Y.normal_work_orders]}),t.jsxs("button",{onClick:()=>R(Y.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"),": ",Y.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:()=>R(Y.name,"department",void 0,"Open"),className:"text-red-700 dark:text-red-400 font-bold hover:underline cursor-pointer",children:Y.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:()=>R(Y.name,"department",void 0,"Work In Progress"),className:"text-yellow-700 dark:text-yellow-400 font-bold hover:underline cursor-pointer",children:Y.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:()=>R(Y.name,"department",void 0,"Pending Review"),className:"text-blue-700 dark:text-blue-400 font-bold hover:underline cursor-pointer",children:Y.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:()=>R(Y.name,"department",void 0,"Completed"),className:"text-green-700 dark:text-green-400 font-bold hover:underline cursor-pointer",children:Y.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:()=>R(Y.name,"department",void 0,"Closed"),className:"text-gray-700 dark:text-gray-400 font-bold hover:underline cursor-pointer",children:Y.wo_closed})})]})]})]})})]}),t.jsx("div",{className:"pt-3 border-t border-gray-200 dark:border-gray-700",children:t.jsx("button",{onClick:()=>R(Y.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")})})]}),B=Y=>{const G=Y.urgent_work_orders>0?`🚨 ${e("activeMap.tooltipUrgent")}`:"",ie=Y.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 ${Y.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:ie})}),t.jsxs("h4",{className:"text-sm font-bold text-gray-900 dark:text-white",children:[G,Y.name]}),Y.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:Y.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:Y.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:Y.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:Y.wo_closed})]}),Y.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:Y.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:Y.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(hr,{label:e("activeMap.hospital"),doctype:"Location",value:a,onChange:O,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(hr,{label:e("activeMap.departmentWoType"),doctype:"Location",value:n,onChange:M,filters:w!==null&&w.length>0?{custom_is_wo_type:1,name:["in",w]}:{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:[h&&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(tV,{center:[24.8,45.5],zoom:6,style:{height:"100%",width:"100%"},zoomControl:!0,children:[t.jsx(sV,{attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}),t.jsx(oV,{locations:c}),c.map(Y=>{const G=`${Y.locationType}-${Y.latitude}-${Y.longitude}`,ie=Y.locationType==="department";return t.jsxs(rV,{position:[Y.latitude,Y.longitude],icon:ie?iV:kS,ref:fe=>{fe&&(y.current[G]=fe,setTimeout(()=>{const K=fe.getElement();K&&(Y.urgent_work_orders>0&&K.classList.add("urgent-marker"),ie&&K.classList.add("department-marker"))},100))},children:[t.jsx(nV,{permanent:!1,direction:"right",className:"hospital-tooltip-modern",children:B(Y)}),t.jsx(aV,{className:"hospital-popup-container",maxWidth:300,maxHeight:450,autoPan:!0,keepInView:!0,closeButton:!0,autoClose:!1,children:ie?X(Y):W(Y)})]},G)})]})]}),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 cV{getItems(r,a,s=20,n=0,i){return me(this,null,function*(){try{const{toFrappeFilterArray:c}=yield Nd(()=>me(null,null,function*(){const{toFrappeFilterArray:g}=yield Promise.resolve().then(()=>Jj);return{toFrappeFilterArray:g}}),void 0);let u=[];r&&Object.keys(r).length>0&&(u=c(r));const h=yield Xt.apiCall("/api/method/asset_lite.api.item_api.get_items",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filters:u.length>0?u:[],fields:a||[],limit:s,offset:n,order_by:i||"creation desc"})});return{data:h.data||[],total:h.total||0}}catch(c){throw console.error("Error fetching items:",c),c}})}getItem(r){return me(this,null,function*(){try{return(yield Xt.apiCall(`/api/resource/Item/${encodeURIComponent(r)}`)).data}catch(a){throw console.error("Error fetching item:",a),a}})}createItem(r){return me(this,null,function*(){try{return(yield Xt.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 me(this,null,function*(){try{return(yield Xt.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 me(this,null,function*(){try{yield Xt.apiCall(`/api/resource/Item/${encodeURIComponent(r)}`,{method:"DELETE"})}catch(a){throw console.error("Error deleting item:",a),a}})}submitItem(r){return me(this,null,function*(){try{return(yield Xt.apiCall(`/api/resource/Item/${encodeURIComponent(r)}/submit`,{method:"POST"})).data}catch(a){throw console.error("Error submitting item:",a),a}})}cancelItem(r){return me(this,null,function*(){try{return(yield Xt.apiCall(`/api/resource/Item/${r}/cancel`,{method:"POST"})).data}catch(a){throw console.error("Error cancelling item:",a),a}})}}const z0=new cV;function dV(e,r=20,a=0,s){const[n,i]=_.useState([]),[c,u]=_.useState(0),[h,g]=_.useState(!1),[y,w]=_.useState(!0),[E,S]=_.useState(null),[A,C]=_.useState(0);_.useRef(!1);const O=JSON.stringify(e);_.useEffect(()=>{let R=!1;return me(null,null,function*(){try{w(!0);const z=["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"],W=yield z0.getItems(e,z,r,a,s);R||(i(W.data),u(W.total),g(W.data.length===r),S(null))}catch(z){if(!R){const W=z instanceof Error?z.message:"Failed to fetch items";S(W),i([]),u(0),g(!1)}}finally{R||w(!1)}}),()=>{R=!0}},[O,r,a,s,A]);const M=_.useCallback(()=>{C(R=>R+1)},[]);return{items:n,totalCount:c,hasMore:h,loading:y,error:E,refetch:M}}function uV(e){const[r,a]=_.useState(null),[s,n]=_.useState(!0),[i,c]=_.useState(null),u=_.useCallback(()=>me(null,null,function*(){if(!e){a(null),n(!1);return}try{n(!0),c(null);const g=yield z0.getItem(e);a(g)}catch(g){c(g instanceof Error?g.message:"Failed to fetch item details")}finally{n(!1)}}),[e]);_.useEffect(()=>{u()},[u]);const h=_.useCallback(()=>{u()},[u]);return{item:r,loading:s,error:i,refetch:h}}function NS(){const[e,r]=_.useState(!1),[a,s]=_.useState(null),n=_.useCallback(h=>me(null,null,function*(){try{return r(!0),s(null),yield z0.createItem(h)}catch(g){const y=g instanceof Error?g.message:"Failed to create item";throw s(y),g}finally{r(!1)}}),[]),i=_.useCallback((h,g)=>me(null,null,function*(){try{return r(!0),s(null),yield z0.updateItem(h,g)}catch(y){const w=y instanceof Error?y.message:"Failed to update item";throw s(w),y}finally{r(!1)}}),[]),c=_.useCallback(h=>me(null,null,function*(){try{r(!0),s(null),yield z0.deleteItem(h)}catch(g){const y=g instanceof Error?g.message:"Failed to delete item";throw s(y),g}finally{r(!1)}}),[]),u=_.useCallback(h=>me(null,null,function*(){try{return r(!0),s(null),yield z0.submitItem(h)}catch(g){const y=g instanceof Error?g.message:"Failed to submit item";throw s(y),g}finally{r(!1)}}),[]);return{createItem:n,updateItem:i,deleteItem:c,submitItem:u,loading:e,error:a}}const fV=({isOpen:e,onClose:r,selectedCount:a,totalCount:s,pageCount:n,onExport:i,isExporting:c,exportColumns:u})=>{const{t:h}=Rr(),[g,y]=_.useState(a>0?"selected":"all_with_filters"),[w,E]=_.useState("csv"),[S,A]=_.useState(u.filter(R=>R.default).map(R=>R.key));_.useEffect(()=>{a>0?y("selected"):y("all_with_filters")},[a]);const C=R=>{A(F=>F.includes(R)?F.filter(z=>z!==R):[...F,R])},O=()=>{A(u.map(R=>R.key))},M=()=>{A(u.filter(R=>R.default).map(R=>R.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(Ks,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:h("items.export.title")})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:c,children:t.jsx(Pt,{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:h("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 ${g==="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:g==="selected",onChange:()=>y("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:h("items.export.selectedRows")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("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," ",h("common.selected")]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${g==="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:g==="all_on_page",onChange:()=>y("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:h("items.export.currentPage")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("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," ",h("common.rows")]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${g==="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:g==="all_with_filters",onChange:()=>y("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:h("items.export.allWithFilters")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("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," ",h("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:h("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 ${w==="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:w==="csv",onChange:()=>E("csv"),className:"text-green-600 focus:ring-green-500"}),t.jsx(No,{className:"text-green-600 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("listPages.csv")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("items.export.csvDesc")})]})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${w==="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:w==="excel",onChange:()=>E("excel"),className:"text-green-600 focus:ring-green-500"}),t.jsx(zi,{className:"text-green-700 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("listPages.excel")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("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:h("items.export.columnsToExport")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:O,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("items.export.selectAll")}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{onClick:M,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("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:u.map(R=>t.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${S.includes(R.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:S.includes(R.key),onChange:()=>C(R.key),className:"rounded text-green-600 focus:ring-green-500"}),t.jsx("span",{className:"text-sm truncate",children:R.label})]},R.key))}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:h("items.export.columnsSelected",{count:S.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:[g==="selected"&&h("items.export.exportingSelected",{count:a}),g==="all_on_page"&&h("items.export.exportingPage",{count:n}),g==="all_with_filters"&&h("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:c,children:h("common.cancel")}),t.jsx("button",{onClick:()=>i(g,w,S),disabled:S.length===0||c,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:c?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),h("items.export.exporting")]}):t.jsxs(t.Fragment,{children:[t.jsx(Vo,{}),h("items.export.exportButton")]})})]})]})]})}):null},hV=()=>{const{t:e}=Rr(),r=Na(),[a,s]=Sn(),i=_.useMemo(()=>{const Fe=parseInt(a.get("page")||"1",10);return Math.max(0,Number.isNaN(Fe)?0:Fe-1)},[a]),c=_.useCallback(Fe=>{s(Ze=>{const vt=new URLSearchParams(Ze);return vt.set("page",String(Fe+1)),vt})},[s]),[u,h]=_.useState(null),g=20,y=[{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}],[w,E]=_.useState(!1),[S,A]=_.useState(new Set),[C,O]=_.useState(!1),[M,R]=_.useState(!1),[F,z]=_.useState([]),[W,X]=_.useState(!1);_.useEffect(()=>{me(null,null,function*(){try{const vt=yield(yield fetch("/api/method/asset_lite.api.user_roles.get_user_roles",{credentials:"include"})).json(),ir=Array.isArray(vt.message)?vt.message:[];z(ir),X(ir.includes("System Manager"))}catch(Ze){console.error("Failed to fetch user roles:",Ze)}})},[]);const[B,Y]=_.useState(()=>a.get("date_filter_by")||""),[G,ie]=_.useState(()=>a.get("date_start")||""),[fe,K]=_.useState(()=>a.get("date_end")||""),[ke,ge]=_.useState(()=>a.get("item_id")||""),[re,we]=_.useState(()=>a.get("item_group")||""),[ee,ve]=_.useState(()=>a.get("company")||""),[ce,ye]=_.useState(()=>a.get("item_name")||""),te=["creation desc","creation asc","modified desc","modified asc","item_name asc","item_name desc","name asc","name desc"],[q,J]=_.useState(()=>a.get("sort_by")||"creation desc"),[ae,oe]=_.useState(!0),[le,be]=_.useState(0),[Z,Le]=_.useState([]),[Pe,Be]=_.useState(!1),[pe,rt]=_.useState(""),[ct,et]=_.useState(()=>a.get("item_name")||""),It=_.useRef(null);_.useEffect(()=>{const Fe=localStorage.getItem("itemFilterPresets");Fe&&Le(JSON.parse(Fe))},[]);const ft=B&&(G||fe);_.useEffect(()=>{const Fe=[ke,re,ee,ce].filter(Boolean).length+(ft?1:0);be(Fe)},[ke,re,ee,ce,ft]);const Lt={};ke&&(Lt.name=ke),re&&(Lt.item_group=re),ee&&(Lt.custom_hospital_name=ee),ce&&(Lt.item_name=["like",`%${ce}%`]),Object.assign(Lt,td(B,G,fe)),Lt.is_stock_item=1,Lt.custom_delete_status=["!=","Deleted"];const Je=te.includes(q)?q:"creation desc",{items:Ve,totalCount:Xe,hasMore:Rt,loading:qe,error:Dt,refetch:ar}=dV(Object.keys(Lt).length>0?Lt:void 0,g,i*g,Je),{deleteItem:yt,loading:St}=NS();_.useEffect(()=>{!qe&&!w&&E(!0)},[qe,w]);const Ot=_.useRef(!1);_.useEffect(()=>{if(!Ot.current){Ot.current=!0;return}s(Fe=>{const Ze=new URLSearchParams(Fe);return B?Ze.set("date_filter_by",B):Ze.delete("date_filter_by"),G?Ze.set("date_start",G):Ze.delete("date_start"),fe?Ze.set("date_end",fe):Ze.delete("date_end"),ke?Ze.set("item_id",ke):Ze.delete("item_id"),re?Ze.set("item_group",re):Ze.delete("item_group"),ee?Ze.set("company",ee):Ze.delete("company"),ce?Ze.set("item_name",ce):Ze.delete("item_name"),q&&q!=="creation desc"?Ze.set("sort_by",q):Ze.delete("sort_by"),Ze.set("page","1"),Ze})},[B,G,fe,ke,re,ee,ce,q]),_.useEffect(()=>{A(new Set)},[B,G,fe,ke,re,ee,ce,i]);const Yt=Fe=>{et(Fe),It.current&&clearTimeout(It.current),It.current=window.setTimeout(()=>{ye(Fe)},800)},Ye=Fe=>{Fe.key==="Enter"&&(Fe.preventDefault(),It.current&&clearTimeout(It.current),ye(ct))},wt=()=>{if(!pe.trim()){alert("Please enter a filter name");return}const Fe={id:Date.now(),name:pe,filters:{dateFilterBy:B,dateStart:G,dateEnd:fe,sortBy:q,filterItemId:ke,filterItemGroup:re,filterCompany:ee,filterItemName:ce}},Ze=[...Z,Fe];Le(Ze),rt(""),Be(!1),localStorage.setItem("itemFilterPresets",JSON.stringify(Ze))},zt=Fe=>{const Ze=Fe.filters;Y(Ze.dateFilterBy||""),ie(Ze.dateStart||""),K(Ze.dateEnd||""),J(Ze.sortBy||"creation desc"),ge(Ze.filterItemId||""),we(Ze.filterItemGroup||""),ve(Ze.filterCompany||""),ye(Ze.filterItemName||""),et(Ze.filterItemName||"")},qt=Fe=>{const Ze=Z.filter(vt=>vt.id!==Fe);Le(Ze),localStorage.setItem("itemFilterPresets",JSON.stringify(Ze))};_.useEffect(()=>()=>{It.current&&clearTimeout(It.current)},[]);const kt=()=>{Y(""),ie(""),K(""),J("creation desc"),ge(""),we(""),ve(""),ye(""),et(""),It.current&&clearTimeout(It.current),s(Fe=>{const Ze=new URLSearchParams(Fe);return Ze.delete("date_filter_by"),Ze.delete("date_start"),Ze.delete("date_end"),Ze.delete("sort_by"),Ze.delete("item_id"),Ze.delete("item_group"),Ze.delete("company"),Ze.delete("item_name"),Ze.set("page","1"),Ze})},ze=ft||ke||re||ee||ce,nt=Fe=>{switch(Fe){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""}},_t=Fe=>Fe?new Date(Fe).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"-",lr=Fe=>{A(Ze=>{const vt=new Set(Ze);return vt.has(Fe)?vt.delete(Fe):vt.add(Fe),vt})},pr=()=>{S.size===Ve.length?A(new Set):A(new Set(Ve.map(Fe=>Fe.name)))},Nr=Ve.length>0&&S.size===Ve.length,rr=S.size>0&&S.size<Ve.length,_r=_.useCallback(()=>me(null,null,function*(){const Fe=[];let Ze=0;const vt=100;let ir=!0;const fr=Ln(Lt);for(;ir;)try{const Q=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Item",filters:fr.length>0?fr:{},fields:["*"],limit_start:Ze*vt,limit_page_length:vt,order_by:"creation desc"})})).json()).message||[];Fe.push(...Q),Q.length<vt?ir=!1:Ze++,Ze>100&&(console.warn("Export safety limit reached"),ir=!1)}catch(Kt){throw console.error("Error fetching items for export:",Kt),Kt}return Fe}),[Lt]),Nt=(Fe,Ze,vt)=>me(null,null,function*(){R(!0);try{let ir=[];switch(Fe){case"selected":ir=Ve.filter(Kt=>S.has(Kt.name));break;case"all_on_page":ir=Ve;break;case"all_with_filters":ir=yield _r();break}if(ir.length===0){alert(e("assets.noDataToExport"));return}const fr=vt.map(Kt=>{const Re=y.find(Q=>Q.key===Kt);return(Re==null?void 0:Re.label)||Kt});if(Ze==="csv"){const Kt=[fr.join(","),...ir.map(Se=>vt.map(ne=>{let _e=Se[ne]||"";return typeof _e=="string"&&(_e.includes(",")||_e.includes('"')||_e.includes(`
`))&&(_e=`"${_e.replace(/"/g,'""')}"`),_e}).join(","))].join(`
`),Re=new Blob(["\uFEFF"+Kt],{type:"text/csv;charset=utf-8;"}),Q=URL.createObjectURL(Re),he=document.createElement("a");he.href=Q,he.download=`items_export_${new Date().toISOString().split("T")[0]}.csv`,he.click(),URL.revokeObjectURL(Q)}else if(Ze==="excel"){const Kt=[fr,...ir.map(he=>vt.map(Se=>he[Se]||""))],Re=Ur.aoa_to_sheet(Kt),Q=Ur.book_new();Ur.book_append_sheet(Q,Re,"Items"),jo(Q,`items_export_${new Date().toISOString().split("T")[0]}.xlsx`)}O(!1),A(new Set)}catch(ir){console.error("Export failed:",ir),alert(`Export failed: ${ir instanceof Error?ir.message:"Unknown error"}`)}finally{R(!1)}}),Cr=()=>{r("/inventory/new")},yr=Fe=>{r(`/inventory/${encodeURIComponent(Fe)}`)},jt=Fe=>{r(`/inventory/${encodeURIComponent(Fe)}`)},Tt=Fe=>me(null,null,function*(){try{yield yt(Fe),h(null),ar(),alert("Item deleted successfully!")}catch(Ze){alert(`Failed to delete: ${Ze instanceof Error?Ze.message:"Unknown error"}`)}}),He=Fe=>{r(`/inventory/new?duplicate=${encodeURIComponent(Fe)}`)};return qe&&!w?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")})]})}):Dt?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:ar,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:"})," ",Dt]})})]})}):t.jsxs("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen w-full min-w-0 overflow-x-hidden",children:[t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center w-full min-w-0",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-gray-800 dark:text-white break-words",children:e("items.listTitle")}),t.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:[e("items.listTotal",{count:Xe}),S.size>0&&t.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",S.size," ",e("common.selected")]}),qe&&w&&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 flex-col gap-2 w-full sm:flex-row sm:flex-wrap sm:justify-end sm:gap-3 sm:w-auto min-w-0 shrink-0",children:[t.jsxs("button",{type:"button",onClick:()=>O(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center justify-center gap-2 shadow transition-all disabled:opacity-50 w-full sm:w-auto",disabled:Xe===0,children:[t.jsx(Ks,{}),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})]}),t.jsxs("button",{type:"button",onClick:Cr,className:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg flex items-center justify-center gap-2 shadow-lg transition-all hover:shadow-xl w-full sm:w-auto",children:[t.jsx(Js,{}),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 flex-col gap-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0 min-w-0",children:[t.jsx("button",{onClick:()=>oe(!ae),className:"text-white hover:bg-white/20 p-2 rounded-lg transition-all",children:ae?t.jsx(Mn,{size:14}):t.jsx(on,{size:14})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Hs,{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-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:le})]}),ze&&t.jsx("div",{className:"w-full min-w-0 sm:flex-1 overflow-x-auto scrollbar-hide sm:mx-2",children:t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[ft&&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(B==="creation"?"filters.createdDate":"filters.latestModifiedDate")," ",G&&` ${G}`," ",fe&&` - ${fe}`,t.jsx("button",{onClick:Fe=>{Fe.stopPropagation(),Y(""),ie(""),K("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),ke&&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:"})," ",ke,t.jsx("button",{onClick:Fe=>{Fe.stopPropagation(),ge("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),ce&&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:"})," ",ce,t.jsx("button",{onClick:Fe=>{Fe.stopPropagation(),ye(""),et("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{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.jsx("span",{className:"font-semibold",children:"Hospital:"})," ",ee,t.jsx("button",{onClick:Fe=>{Fe.stopPropagation(),ve("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]}),re&&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:"})," ",re,t.jsx("button",{onClick:Fe=>{Fe.stopPropagation(),we("")},className:"hover:text-red-500 transition-colors",children:t.jsx(Pt,{className:"text-[9px]"})})]})]})}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[le>0&&t.jsxs("button",{onClick:()=>Be(!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(bs,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),ze&&t.jsxs("button",{onClick:kt,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(Pt,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:e("listPages.clear")})]})]})]})}),ae&&t.jsxs("div",{className:"p-4",children:[Z.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(ul,{className:"text-yellow-500",size:12}),e("listPages.savedFilters")]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:Z.map(Fe=>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:()=>zt(Fe),className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:Fe.name}),t.jsx("button",{onClick:()=>qt(Fe.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:t.jsx(la,{size:10})})]},Fe.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:q,onChange:Fe=>J(Fe.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:B,onChange:Fe=>{const Ze=Fe.target.value;Y(Ze)},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")})]})]}),B&&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:Fe=>{const Ze=Fe.target.value;ie(Ze),fe&&Ze>fe&&K(Ze)},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:fe,onChange:Fe=>K(Fe.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-10 lg:z-[60]",children:[t.jsx(hr,{label:e("items.itemId"),doctype:"Item",value:ke,onChange:Fe=>ge(Fe),placeholder:e("linkField.selectLabel",{label:e("items.itemId")}),disabled:!1,compact:!0,filters:{is_stock_item:1,custom_delete_status:["!=","Deleted"]}}),ke&&t.jsx("button",{onClick:()=>ge(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{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:ct,onChange:Fe=>Yt(Fe.target.value),onKeyDown:Ye,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"}),ct&&ct!==ce&&t.jsx("span",{className:"absolute right-2 top-6 text-[9px] text-blue-500 animate-pulse",children:e("common.typing")}),ce&&t.jsx("button",{onClick:()=>{ye(""),et("")},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[59]",children:[t.jsx(hr,{label:e("items.selectHospital"),doctype:"Company",value:ee,onChange:Fe=>ve(Fe),placeholder:e("linkField.selectLabel",{label:e("items.selectHospital")}),disabled:!1,compact:!0,filters:{domain:"Healthcare"}}),ee&&t.jsx("button",{onClick:()=>ve(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[58]",children:[t.jsx(hr,{label:e("items.itemGroup"),doctype:"Item Group",value:re,onChange:Fe=>we(Fe),placeholder:e("linkField.selectLabel",{label:e("items.itemGroup")}),disabled:!1,compact:!0}),re&&t.jsx("button",{onClick:()=>we(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{size:10})})]})]})})})]})]}),Pe&&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:pe,onChange:Fe=>rt(Fe.target.value),onKeyDown:Fe=>{Fe.key==="Enter"&&(Fe.preventDefault(),wt())},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:()=>{Be(!1),rt("")},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:wt,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(bs,{size:12}),e("common.saveFilter")]})]})]})}),t.jsx(fV,{isOpen:C,onClose:()=>O(!1),selectedCount:S.size,totalCount:Xe,pageCount:Ve.length,onExport:Nt,isExporting:M,exportColumns:y}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden relative",children:[qe&&w&&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:pr,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:Nr?"Deselect all":"Select all",children:Nr?t.jsx(jn,{className:"text-blue-600 dark:text-blue-400",size:18}):rr?t.jsxs("div",{className:"relative",children:[t.jsx(ys,{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(ys,{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:Ve.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(J8,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("items.noItemsFound")}),ze?t.jsx("button",{onClick:kt,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:Cr,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:e("items.createFirstItem")})]})})}):Ve.map(Fe=>{var Ze;return t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors cursor-pointer ${S.has(Fe.name)?"bg-blue-50 dark:bg-blue-900/20":nt(Fe.custom_delete_status)}`,title:Fe.custom_delete_status?`Delete Status: ${Fe.custom_delete_status}`:void 0,onClick:()=>yr(Fe.name),children:[t.jsx("td",{className:"px-4 py-4",onClick:vt=>vt.stopPropagation(),children:t.jsx("button",{onClick:()=>lr(Fe.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:S.has(Fe.name)?t.jsx(jn,{className:"text-blue-600 dark:text-blue-400",size:18}):t.jsx(ys,{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:Fe.item_code||Fe.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:Fe.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:Fe.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:Fe.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:Fe.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:Fe.custom_date_in?_t(Fe.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:_t(Fe.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:vt=>vt.stopPropagation(),children:[t.jsx("button",{onClick:()=>yr(Fe.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(to,{})}),t.jsx("button",{onClick:()=>jt(Fe.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(Ms,{})}),t.jsx("button",{onClick:()=>He(Fe.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(tu,{})}),t.jsx("div",{onClick:vt=>vt.stopPropagation(),children:t.jsx(rd,{doctype:"Item",docname:Fe.name,currentDeleteStatus:(Ze=Fe.custom_delete_status)!=null?Ze:null,userRoles:F,isSystemManager:W,triggerMode:!0,redirectOnDelete:"/inventory",onStatusChange:()=>ar()})})]})})]},Fe.name)})})]})}),t.jsx(ed,{currentPage:i+1,totalCount:Xe,pageSize:g,hasMore:Rt,itemLabel:e("pagination.items"),onPageChange:Fe=>c(Math.max(0,Fe-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(la,{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"),":"]})," ",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:St,children:e("common.cancel")}),t.jsx("button",{onClick:()=>Tt(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:St,children:St?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(la,{}),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;
}
`})]})},mV=()=>{var be,Z,Le,Pe;const{t:e}=Rr(),{itemName:r}=ml(),a=Na(),s=hl(),[n]=Sn(),i=n.get("duplicate"),c=_.useMemo(()=>{if(r==="new")return"new";const Be="/inventory/",pe=window.location.pathname,rt=pe.indexOf(Be);if(rt!==-1){const ct=pe.slice(rt+Be.length);try{return decodeURIComponent(ct)}catch(et){return ct}}return r||""},[r,s.pathname]),u=c==="new",h=u&&!!i,[g,y]=_.useState(0),[w,E]=_.useState(!1),[S,A]=_.useState([]),[C,O]=_.useState(!1),[M,R]=_.useState(!1);_.useEffect(()=>{me(null,null,function*(){try{const pe=yield Xt.apiCall("/api/method/asset_lite.api.user_roles.get_user_roles"),rt=Array.isArray(pe)?pe:(pe==null?void 0:pe.message)||[];A(rt),O(rt.includes("System Manager"))}catch(pe){console.error("Error fetching roles:",pe)}finally{R(!0)}})},[]);const[F,z]=_.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:W,loading:X,error:B,refetch:Y}=uV(h?i:u?null:c||null),{createItem:G,updateItem:ie,loading:fe}=NS(),[K,ke]=_.useState(u),ge=(be=W==null?void 0:W.docstatus)!=null?be:0,re=ge===1,we=ge===2,ee=ge===0,ve=!!(W!=null&&W.custom_delete_status),ce=F.item_group==="Tools",ye=_.useCallback(Be=>me(null,null,function*(){var pe;if(Be){E(!0);try{let rt=null;typeof window!="undefined"&&window.csrf_token&&(rt=window.csrf_token);const ct=JSON.stringify([["item_code","=",Be]]),et=JSON.stringify(["actual_qty","warehouse"]),It=`${Or.BASE_URL}/api/resource/Bin?filters=${encodeURIComponent(ct)}&fields=${encodeURIComponent(et)}&limit_page_length=0`,ft={Accept:"application/json","Content-Type":"application/json"};rt&&(ft["X-Frappe-CSRF-Token"]=rt);const Lt=yield fetch(It,{method:"GET",headers:ft,credentials:"include"});if(!Lt.ok)throw new Error(`HTTP error! status: ${Lt.status}`);const Ve=((pe=(yield Lt.json()).data)==null?void 0:pe.reduce((Xe,Rt)=>Xe+(Rt.actual_qty||0),0))||0;y(Ve)}catch(rt){console.error("Failed to fetch balance qty:",rt),y(0)}finally{E(!1)}}}),[]);_.useEffect(()=>{!u&&(W!=null&&W.item_code)&&ye(W.item_code)},[u,W==null?void 0:W.item_code,ye]),_.useEffect(()=>{var Be,pe,rt,ct,et,It,ft,Lt,Je,Ve;W&&!h?(z({item_code:W.item_code||"",item_name:W.item_name||"",item_group:W.item_group||"",custom_technical_department:W.custom_technical_department||"",custom_hospital_name:W.custom_hospital_name||"",custom_part_description:W.custom_part_description||"",stock_uom:W.stock_uom||"Nos",custom_item_cost_per_unit:W.custom_item_cost_per_unit||0,disabled:W.disabled||0,is_stock_item:(Be=W.is_stock_item)!=null?Be:1,is_fixed_asset:(pe=W.is_fixed_asset)!=null?pe:0,opening_stock:W.opening_stock||0,valuation_rate:(rt=W.valuation_rate)!=null?rt:0,standard_rate:W.standard_rate||0,custom_last_calibration_date:W.custom_last_calibration_date||"",custom_next_due_calibration_date:W.custom_next_due_calibration_date||"",description:W.description||"",brand:W.brand||"",custom_warranty_in_months:W.custom_warranty_in_months||"",valuation_method:W.valuation_method||"",has_batch_no:W.has_batch_no||0,has_serial_no:W.has_serial_no||0,is_purchase_item:(ct=W.is_purchase_item)!=null?ct:1,is_sales_item:(et=W.is_sales_item)!=null?et:1,country_of_origin:W.country_of_origin||"Saudi Arabia",uoms:W.uoms||[],item_defaults:W.item_defaults||[],custom_serial_no:W.custom_serial_no||"",custom_date_in:W.custom_date_in||"",custom_code:W.custom_code||"",custom_type:W.custom_type||"",custom_volts:W.custom_volts,custom_w:W.custom_w}),ke(!1)):h&&W&&z({item_code:"",item_name:W.item_name||"",item_group:W.item_group||"",custom_technical_department:W.custom_technical_department||"",custom_hospital_name:W.custom_hospital_name||"",custom_part_description:W.custom_part_description||"",stock_uom:W.stock_uom||"Nos",custom_item_cost_per_unit:W.custom_item_cost_per_unit||0,disabled:0,is_stock_item:(It=W.is_stock_item)!=null?It:1,is_fixed_asset:(ft=W.is_fixed_asset)!=null?ft:0,opening_stock:W.opening_stock||0,valuation_rate:(Lt=W.valuation_rate)!=null?Lt:0,standard_rate:W.standard_rate||0,custom_last_calibration_date:W.custom_last_calibration_date||"",custom_next_due_calibration_date:W.custom_next_due_calibration_date||"",description:W.description||"",brand:W.brand||"",custom_warranty_in_months:W.custom_warranty_in_months||"",valuation_method:W.valuation_method||"",has_batch_no:W.has_batch_no||0,has_serial_no:W.has_serial_no||0,is_purchase_item:(Je=W.is_purchase_item)!=null?Je:1,is_sales_item:(Ve=W.is_sales_item)!=null?Ve:1,country_of_origin:W.country_of_origin||"Saudi Arabia",uoms:W.uoms||[],item_defaults:W.item_defaults||[],custom_serial_no:W.custom_serial_no||"",custom_date_in:W.custom_date_in||"",custom_code:W.custom_code||"",custom_type:W.custom_type||"",custom_volts:W.custom_volts,custom_w:W.custom_w})},[W,h]);const te=()=>me(null,null,function*(){try{if(u){const Be=yield G(F);a(`/inventory/${Be.name}`)}else yield ie(c,F),yield Y(),F.item_code&&ye(F.item_code),ke(!1),alert(e("items.itemUpdatedSuccessfully"))}catch(Be){alert(`${e("items.failedToSave")}: ${Be instanceof Error?Be.message:"Unknown error"}`)}}),q=_.useCallback(Be=>!!(!K||we||ve||re),[K,we,re,ve]);if(X)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(B&&!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-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:B}),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 J="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",ae="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",oe="text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",le="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(Kn,{}),t.jsx("span",{className:"text-gray-900 dark:text-white font-medium",children:u?e("items.newItem"):(W==null?void 0:W.item_name)||(W==null?void 0:W.item_code)||e("items.title")})]}),!u&&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:(W==null?void 0:W.item_code)||c})]}),t.jsxs("div",{className:"flex gap-3",children:[!u&&!K&&ee&&!ve&&t.jsxs("button",{onClick:()=>ke(!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(Ms,{}),e("common.edit")]}),K&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>{u?a(-1):(ke(!1),Y())},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:te,disabled:fe,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(bs,{}),e(fe?"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:le,children:[t.jsx("h2",{className:oe,children:e("items.basicInformation")}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:ae,children:[e("items.itemCode")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",value:F.item_code,onChange:Be=>z(Ke(Te({},F),{item_code:Be.target.value})),disabled:q("item_code")||!u,className:J,required:!0})]}),t.jsx(hr,{label:e("commonFields.hospital"),doctype:"Company",value:F.custom_hospital_name||"",onChange:Be=>z(Ke(Te({},F),{custom_hospital_name:Be})),disabled:q("custom_hospital_name"),placeholder:e("items.selectHospital"),filters:{domain:"Healthcare"}}),t.jsx(hr,{label:e("items.itemGroup"),doctype:"Item Group",value:F.item_group||"",onChange:Be=>z(Ke(Te({},F),{item_group:Be})),disabled:q("item_group"),placeholder:e("items.selectItemGroup")}),t.jsx(hr,{label:e("items.technicalDepartment"),doctype:"Issue Type",value:F.custom_technical_department||"",onChange:Be=>z(Ke(Te({},F),{custom_technical_department:Be})),disabled:q("custom_technical_department"),placeholder:e("items.selectTechnicalDepartment")}),t.jsxs("div",{children:[t.jsx("label",{className:ae,children:e("items.stockUOM")}),t.jsx("input",{type:"text",value:F.stock_uom,onChange:Be=>z(Ke(Te({},F),{stock_uom:Be.target.value})),disabled:q("stock_uom"),className:J})]}),t.jsxs("div",{children:[t.jsx("label",{className:ae,children:e("items.partDescription")}),t.jsx("input",{type:"text",value:F.custom_part_description,onChange:Be=>z(Ke(Te({},F),{custom_part_description:Be.target.value})),disabled:q("custom_part_description"),className:J})]})]})]}),t.jsxs("div",{className:le,children:[t.jsx("h2",{className:oe,children:e("items.inventoryDetails")}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:ae,children:e("items.serialNo")}),t.jsx("input",{type:"text",value:F.custom_serial_no,onChange:Be=>z(Ke(Te({},F),{custom_serial_no:Be.target.value})),disabled:q("custom_serial_no"),className:J})]}),t.jsxs("div",{children:[t.jsx("label",{className:ae,children:e("items.dateIn")}),t.jsx("input",{type:"date",value:F.custom_date_in,onChange:Be=>z(Ke(Te({},F),{custom_date_in:Be.target.value})),disabled:q("custom_date_in"),className:J})]}),t.jsxs("div",{children:[t.jsx("label",{className:ae,children:e("items.watts")}),t.jsx("input",{type:"number",step:"0.01",value:(Z=F.custom_w)!=null?Z:"",onChange:Be=>{const pe=parseFloat(Be.target.value);z(Ke(Te({},F),{custom_w:Be.target.value===""||isNaN(pe)?void 0:pe}))},disabled:q("custom_w"),className:J})]}),t.jsxs("div",{children:[t.jsx("label",{className:ae,children:e("items.volts")}),t.jsx("input",{type:"number",step:"0.01",value:(Le=F.custom_volts)!=null?Le:"",onChange:Be=>{const pe=parseFloat(Be.target.value);z(Ke(Te({},F),{custom_volts:Be.target.value===""||isNaN(pe)?void 0:pe}))},disabled:q("custom_volts"),className:J})]}),t.jsxs("div",{children:[t.jsx("label",{className:ae,children:e("items.type")}),t.jsx("input",{type:"text",value:F.custom_type,onChange:Be=>z(Ke(Te({},F),{custom_type:Be.target.value})),disabled:q("custom_type"),className:J})]}),t.jsxs("div",{children:[t.jsx("label",{className:ae,children:e("items.code")}),t.jsx("input",{type:"text",value:F.custom_code,onChange:Be=>z(Ke(Te({},F),{custom_code:Be.target.value})),disabled:q("custom_code"),className:J})]})]})]}),t.jsxs("div",{className:le,children:[t.jsx("h2",{className:oe,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:F.is_stock_item===1,onChange:Be=>z(Ke(Te({},F),{is_stock_item:Be.target.checked?1:0})),disabled:q("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:F.is_fixed_asset===1,onChange:Be=>z(Ke(Te({},F),{is_fixed_asset:Be.target.checked?1:0})),disabled:q("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")})]}),u&&F.is_stock_item===1&&t.jsxs("div",{children:[t.jsx("label",{className:ae,children:e("items.openingStock")}),t.jsx("input",{type:"number",value:F.opening_stock,onChange:Be=>z(Ke(Te({},F),{opening_stock:parseFloat(Be.target.value)||0})),disabled:q("opening_stock"),className:J})]}),F.is_stock_item===1&&t.jsxs("div",{children:[t.jsx("label",{className:ae,children:e("items.valuationRate")}),t.jsx("input",{type:"number",step:"0.01",value:F.valuation_rate,onChange:Be=>z(Ke(Te({},F),{valuation_rate:parseFloat(Be.target.value)||0})),disabled:q("valuation_rate"),className:J})]}),!u&&F.is_stock_item===1&&t.jsxs("div",{children:[t.jsx("label",{className:ae,children:e("items.balanceQty")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"number",value:g,readOnly:!0,className:`${J} bg-gray-100 dark:bg-gray-800 cursor-not-allowed`}),t.jsx("button",{type:"button",onClick:()=>F.item_code&&ye(F.item_code),disabled:w,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(Ui,{className:w?"animate-spin":""})})]})]})]}),ce&&t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:`${oe} mt-6`,children:e("items.calibrationInformation")}),t.jsxs("div",{className:"space-y-4 mt-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:ae,children:e("items.lastCalibrationDate")}),t.jsx("input",{type:"date",value:F.custom_last_calibration_date,onChange:Be=>z(Ke(Te({},F),{custom_last_calibration_date:Be.target.value})),disabled:q("custom_last_calibration_date"),className:J})]}),t.jsxs("div",{children:[t.jsx("label",{className:ae,children:e("items.nextCalibrationDate")}),t.jsx("input",{type:"date",value:F.custom_next_due_calibration_date,onChange:Be=>z(Ke(Te({},F),{custom_next_due_calibration_date:Be.target.value})),disabled:q("custom_next_due_calibration_date"),className:J})]})]})]}),t.jsx("h2",{className:`${oe} mt-6`,children:e("items.additionalInformation")}),t.jsxs("div",{className:"space-y-4 mt-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:ae,children:e("commonFields.description")}),t.jsx("textarea",{value:F.description,onChange:Be=>z(Ke(Te({},F),{description:Be.target.value})),disabled:q("description"),rows:3,className:J})]}),t.jsxs("div",{children:[t.jsx("label",{className:ae,children:e("items.warrantyMonths")}),t.jsx("input",{type:"text",value:F.custom_warranty_in_months,onChange:Be=>z(Ke(Te({},F),{custom_warranty_in_months:Be.target.value})),disabled:q("custom_warranty_in_months"),className:J})]})]})]})," ",!u&&t.jsx("div",{className:"mt-6",children:t.jsx(Kd,{referenceDoctype:"Item",referenceName:c||null,title:"Comments & Discussion",pollInterval:3e4,initialLimit:5,collapsible:!0,startCollapsed:!1})}),!u&&!h&&t.jsx("div",{className:"mt-6",children:t.jsx(fS,{doctype:"Item",docname:c||null,creationDate:W==null?void 0:W.creation,createdBy:W==null?void 0:W.owner,compact:!1,initialVisible:5,collapsible:!0,startCollapsed:!0})}),!u&&M&&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(rd,{doctype:"Item",docname:c,currentDeleteStatus:(Pe=W==null?void 0:W.custom_delete_status)!=null?Pe:null,userRoles:S,isSystemManager:C,redirectOnDelete:"/inventory",onStatusChange:()=>Y()})]})})]})," "]})};const gV=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),xV=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,a,s)=>s?s.toUpperCase():a.toLowerCase()),d4=e=>{const r=xV(e);return r.charAt(0).toUpperCase()+r.slice(1)},jS=(...e)=>e.filter((r,a,s)=>!!r&&r.trim()!==""&&s.indexOf(r)===a).join(" ").trim(),pV=e=>{for(const r in e)if(r.startsWith("aria-")||r==="role"||r==="title")return!0};var yV={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 bV=_.forwardRef((g,h)=>{var y=g,{color:e="currentColor",size:r=24,strokeWidth:a=2,absoluteStrokeWidth:s,className:n="",children:i,iconNode:c}=y,u=Ji(y,["color","size","strokeWidth","absoluteStrokeWidth","className","children","iconNode"]);return _.createElement("svg",Te(Te(Ke(Te({ref:h},yV),{width:r,height:r,stroke:e,strokeWidth:s?Number(a)*24/Number(r):a,className:jS("lucide",n)}),!i&&!pV(u)&&{"aria-hidden":"true"}),u),[...c.map(([w,E])=>_.createElement(w,E)),...Array.isArray(i)?i:[i]])});const dn=(e,r)=>{const a=_.forwardRef((c,i)=>{var u=c,{className:s}=u,n=Ji(u,["className"]);return _.createElement(bV,Te({ref:i,iconNode:r,className:jS(`lucide-${gV(d4(e))}`,`lucide-${e}`,s)},n))});return a.displayName=d4(e),a};const vV=[["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"}]],wV=dn("bell",vV);const _V=[["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"}]],kV=dn("box",_V);const NV=[["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"}]],jV=dn("calendar-check",NV);const SV=[["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"}]],CV=dn("calendar",SV);const EV=[["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"}]],TV=dn("circle-question-mark",EV);const AV=[["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"}]],OV=dn("circle-user",AV);const DV=[["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"}]],RV=dn("clipboard-list",DV);const FV=[["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"}]],IV=dn("construction",FV);const MV=[["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"}]],PV=dn("file-text",MV);const LV=[["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"}]],BV=dn("languages",LV);const UV=[["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"}]],zV=dn("layout-dashboard",UV);const WV=[["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"}]],HV=dn("log-out",WV);const $V=[["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"}]],VV=dn("map",$V);const GV=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],SS=dn("menu",GV);const YV=[["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"}]],qV=dn("moon",YV);const XV=[["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"}]],ZV=dn("package",XV);const KV=[["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"}]],JV=dn("shopping-cart",KV);const QV=[["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"}]],eG=dn("sun",QV);const tG=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],rG=dn("upload",tG);const aG=[["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"}]],sG=dn("users",aG);const nG=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],u4=dn("x",nG),iG=({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(IV,{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"})]})}),CS=_.createContext(void 0),oG=({children:e})=>{const{i18n:r}=Rr(),[a,s]=_.useState(()=>localStorage.getItem("i18nextLng")==="ar"?"ar":"en"),n=a==="ar";_.useEffect(()=>{const c=document.documentElement,u=document.documentElement;r.changeLanguage(a),u.setAttribute("lang",a),n?(u.setAttribute("dir","rtl"),c.classList.add("rtl"),c.classList.remove("ltr")):(u.setAttribute("dir","ltr"),c.classList.add("ltr"),c.classList.remove("rtl"))},[a,r,n]);const i=c=>me(null,null,function*(){s(c),localStorage.setItem("i18nextLng",c),yield Q1()});return t.jsx(CS.Provider,{value:{language:a,changeLanguage:i,isRTL:n},children:e})},xb=()=>{const e=_.useContext(CS);if(!e)throw new Error("useLanguage must be used within LanguageProvider");return e},ES=_.createContext(null),lG=({children:e})=>{const[r,a]=_.useState(!1),s=_.useCallback(()=>a(!0),[]),n=_.useCallback(()=>a(!1),[]),i=_.useMemo(()=>({mobileOpen:r,setMobileOpen:a,openMobileSidebar:s,closeMobileSidebar:n}),[r,s,n]);return t.jsx(ES.Provider,{value:i,children:e})};function pb(){const e=_.useContext(ES);if(!e)throw new Error("useSidebarLayout must be used within SidebarLayoutProvider");return e}function cG(){const[e,r]=_.useState(()=>typeof window!="undefined"?window.matchMedia("(min-width: 1024px)").matches:!1);return _.useEffect(()=>{const a=window.matchMedia("(min-width: 1024px)"),s=()=>r(a.matches);return a.addEventListener("change",s),()=>a.removeEventListener("change",s)},[]),e}const dG=["System Manager","Contractor Supervisor","Contractor Manager","Work Control","Contractor Engineer"],uG="Technician",fG="End User";function hG(e){const r=new Set(e);return{isAdmin:dG.some(a=>r.has(a)),isTechnician:r.has(uG),isEndUser:r.has(fG),isDRApprover:r.has("DR Approver")}}const mG=({userEmail:e})=>{const[r,a]=_.useState(!1),s=hl();Na();const n=cG(),{closeMobileSidebar:i}=pb(),{isRTL:c}=xb(),{t:u}=Rr(),h=()=>{n||i()},[g,y]=_.useState({isAdmin:!1,isTechnician:!1,isEndUser:!1,isDRApprover:!1,isLoading:!0}),[w,E]=_.useState(""),S="/assets/asm_ui_app/asm_app/",A="?v=1768316563",C="?v=1768316563",O=S.endsWith("/")?`${S}sidebar-background.jpg${A}`:`${S}/sidebar-background.jpg${A}`;_.useEffect(()=>{let B=!1;return me(null,null,function*(){try{const G=yield UB();if(B)return;const ie=hG(G.roles);y(Ke(Te({},ie),{isLoading:!1})),E(G.full_name||G.user||e||"")}catch(G){console.error("Error fetching user roles:",G),B||(y({isAdmin:!1,isTechnician:!1,isEndUser:!0,isDRApprover:!1,isLoading:!1}),e&&E(e))}}),()=>{B=!0}},[e]);const M=B=>{const{isAdmin:Y,isTechnician:G,isEndUser:ie,isLoading:fe}=g;if(fe)return!1;if(Y)return!0;const K=["work-orders","support","assets","inventory"],ke=["work-orders","inspections","procurement","support","active-map","assets","inventory"];let ge=!1;return ie&&K.includes(B)&&(ge=!0),G&&ke.includes(B)&&(ge=!0),!Y&&!G&&!ie&&(ge=K.includes(B)),ge},F=[{id:"dashboard",title:u("common.dashboard"),icon:t.jsx(zV,{size:20}),path:"/dashboard",visible:g.isAdmin},{id:"assets",title:u("common.assets"),icon:t.jsx(ZV,{size:20}),path:"/assets",visible:M("assets")},{id:"inventory",title:u("sidebar.inventory"),icon:t.jsx(kV,{size:20}),path:"/inventory",visible:M("inventory")},{id:"work-orders",title:u("common.workOrders"),icon:t.jsx(RV,{size:20}),path:"/work-orders",visible:M("work-orders")},{id:"inspections",title:u("sidebar.inspection"),icon:t.jsx(Wo,{size:20}),path:"/inspections",visible:M("inspections")},{id:"ppm-planner",title:u("sidebar.ppmPlanner"),icon:t.jsx(jV,{size:20}),path:"/ppm-planner",visible:g.isAdmin},{id:"maintenance-calendar",title:u("sidebar.maintenanceCalendar"),icon:t.jsx(CV,{size:20}),path:"/maintenance-calendar",visible:g.isAdmin||g.isTechnician},{id:"active-map",title:u("sidebar.activeMap"),icon:t.jsx(VV,{size:20}),path:"/active-map",visible:M("active-map")},{id:"maintenance-teams",title:u("sidebar.maintenanceTeam"),icon:t.jsx(sG,{size:20}),path:"/maintenance-teams",visible:g.isAdmin},{id:"procurement",title:u("sidebar.procurement"),icon:t.jsx(JV,{size:20}),path:"/procurement",visible:M("procurement")},{id:"sla",title:u("sidebar.sla"),icon:t.jsx(PV,{size:20}),path:"/sla",visible:g.isAdmin},{id:"data-import",title:u("sidebar.dataImport"),icon:t.jsx(rG,{size:20}),path:"/data-import",visible:g.isDRApprover},{id:"support",title:u("sidebar.support"),icon:t.jsx(TV,{size:20}),path:"/support",visible:M("support")}].filter(B=>B.visible),z=B=>s.pathname===B,W=n&&r?"w-16":"w-64",X=c?"border-l border-gray-200 dark:border-gray-700":"border-r border-gray-200 dark:border-gray-700";return t.jsxs("div",{className:`
relative
h-screen
transition-all
duration-300
ease-in-out
flex
flex-col
shadow-xl
${X}
${W}
`,style:{backgroundImage:`url(${O})`,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:`${S}${S.endsWith("/")?"":"/"}seera-logo.png${C}`,alt:"SEERA-ASM",className:"w-full h-full object-contain",onError:B=>{var Y;B.currentTarget.style.display="none",(Y=B.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:`${S}${S.endsWith("/")?"":"/"}seera-logo.png?v=1765198405${C}`,alt:"SEERA-ASM",className:"w-full h-full object-contain",onError:B=>{var Y;B.currentTarget.style.display="none",(Y=B.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:()=>{n?a(!r):i()},className:"text-white dark:text-white hover:bg-white/20 dark:hover:bg-white/20 p-2 rounded-lg transition-colors","aria-label":n?r?u("common.expandSidebar",{defaultValue:"Expand sidebar"}):u("common.collapseSidebar",{defaultValue:"Collapse sidebar"}):u("common.closeMenu",{defaultValue:"Close menu"}),children:n?r?t.jsx(SS,{size:20}):t.jsx(u4,{size:20}):t.jsx(u4,{size:20})})]}),t.jsx("nav",{className:"flex-1 overflow-y-auto py-4",children:g.isLoading?Array.from({length:6}).map((B,Y)=>t.jsx("div",{className:`mx-3 my-1.5 h-11 rounded-lg bg-white/10 animate-pulse ${r?"mx-2":""}`},`sidebar-skeleton-${Y}`)):F.map(B=>t.jsxs(oy,{to:B.path,onClick:h,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
${z(B.path)?`bg-white/30 dark:bg-white/30 text-white dark:text-white ${c?"border-r-4":"border-l-4"} border-white`:""}
${r?"justify-center":""}
`,title:r?B.title:"",children:[t.jsx("span",{children:B.icon}),!r&&t.jsx("span",{className:`${c?"mr-4":"ml-4"} font-medium`,children:B.title})]},B.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")})})]})]})},TS=_.createContext(void 0),gG=({children:e})=>{const[r,a]=_.useState(()=>localStorage.getItem("theme")||"light");_.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(TS.Provider,{value:{theme:r,toggleTheme:s},children:e})},xG=()=>{const e=_.useContext(TS);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e};class pG{getNotifications(r=50,a=0){return me(this,null,function*(){var i,c,u,h;const s=localStorage.getItem("user"),n=s?JSON.parse(s).email:"";if(!n)return[];try{const g=JSON.stringify([["for_user","=",n]]),y=JSON.stringify(["name","subject","email_content","document_type","document_name","read","creation","from_user","type"]),w=yield Xt.apiCall(`/api/resource/Notification Log?filters=${encodeURIComponent(g)}&fields=${encodeURIComponent(y)}&order_by=creation desc&limit=${r}&offset=${a}`);return console.log("[NotificationService] Fetched notifications:",w==null?void 0:w.data),((i=w==null?void 0:w.data)==null?void 0:i.length)>0&&console.log("[NotificationService] First notification sample:",w.data[0]),(w==null?void 0:w.data)||[]}catch(g){return(c=g==null?void 0:g.message)!=null&&c.includes("417")||(u=g==null?void 0:g.message)!=null&&u.includes("EXPECTATION FAILED")?[]:((h=g==null?void 0:g.message)!=null&&h.includes("417")||console.warn("Notifications API not available:",(g==null?void 0:g.message)||"Unknown error"),[])}})}markAsRead(r){return me(this,null,function*(){var a,s,n,i;try{return yield Xt.apiCall(`/api/resource/Notification Log/${r}`,{method:"PUT",body:JSON.stringify({read:1})})}catch(c){if((a=c==null?void 0:c.message)!=null&&a.includes("417")||(s=c==null?void 0:c.message)!=null&&s.includes("EXPECTATION FAILED")||(n=c==null?void 0:c.message)!=null&&n.includes("PermissionError")||(i=c==null?void 0:c.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:",(c==null?void 0:c.message)||"Unknown error"),c}})}markAllAsRead(){return me(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 me(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 u1=new pG;function yG(){const[e,r]=_.useState([]),[a,s]=_.useState(0),[n,i]=_.useState(!0),[c,u]=_.useState(null),h=_.useCallback(()=>me(null,null,function*(){var w,E;try{i(!0),u(null);const A=(yield u1.getNotifications()).filter(C=>{var O;return!((O=C.subject)!=null&&O.startsWith("Failed to send email"))});r(A),s(A.filter(C=>!C.read).length)}catch(S){if((w=S==null?void 0:S.message)!=null&&w.includes("417")||(E=S==null?void 0:S.message)!=null&&E.includes("EXPECTATION FAILED"))r([]),s(0),u(null);else{const A=S instanceof Error?S.message:"Failed to fetch notifications";u(A),console.warn("Error fetching notifications:",S)}}finally{i(!1)}}),[]);_.useEffect(()=>{h();const w=setInterval(h,3e4);return()=>clearInterval(w)},[h]);const g=_.useCallback(w=>me(null,null,function*(){const E=e,S=a;r(A=>A.map(C=>C.name===w?Ke(Te({},C),{read:1}):C)),s(A=>Math.max(0,A-1));try{yield u1.markAsRead(w)}catch(A){throw console.error("Error marking notification as read:",A),r(E),s(S),A}}),[e,a]),y=_.useCallback(()=>me(null,null,function*(){const w=e,E=a;r(S=>S.map(A=>Ke(Te({},A),{read:1}))),s(0);try{yield u1.markAllAsRead()}catch(S){throw console.error("Error marking all notifications as read:",S),r(w),s(E),S}}),[e,a]);return{notifications:e,unreadCount:a,loading:n,error:c,markAsRead:g,markAllAsRead:y,refetch:h}}const jm=e=>e?(new DOMParser().parseFromString(e,"text/html").body.textContent||"").replace(/\uFEFF/g,"").replace(/\s+/g," ").trim():"",bG=()=>{const{notifications:e,unreadCount:r,markAsRead:a,markAllAsRead:s}=yG(),[n,i]=_.useState(!1),[c,u]=_.useState(!1),h=_.useRef(null),g=Na();_.useEffect(()=>{const C=O=>{h.current&&!h.current.contains(O.target)&&i(!1)};return n&&document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},[n]);const y=()=>me(null,null,function*(){u(!0);try{yield s()}catch(C){console.warn("[NotificationBell] Could not mark all as read:",C)}finally{u(!1)}}),w=C=>me(null,null,function*(){if(console.log("[NotificationBell] Clicked notification:",C),console.log("[NotificationBell] document_type:",C.document_type),console.log("[NotificationBell] document_name:",C.document_name),!C.read)try{yield a(C.name)}catch(O){console.warn("[NotificationBell] Could not mark as read (permission issue):",O)}if(C.document_type&&C.document_name){const O=C.document_type,M=C.document_name,R=O.replace(/_/g," ").trim();if(console.log("[NotificationBell] Normalized type:",R),console.log("[NotificationBell] Document name:",M),R==="Asset Maintenance Log"||R==="Asset Maintenance")console.log("[NotificationBell] Navigating to maintenance:",`/maintenance/${M}`),g(`/maintenance/${M}`);else if(R==="Work Order"||R==="Asset Repair")console.log("[NotificationBell] Navigating to work order:",`/work-orders/${M}`),g(`/work-orders/${M}`);else if(R==="Asset")console.log("[NotificationBell] Navigating to asset:",`/assets/${M}`),g(`/assets/${M}`);else if(R==="PM Schedule Generator"||R==="PM Schedule")console.log("[NotificationBell] Navigating to PPM planner:",`/ppm-planner/${M}`),g(`/ppm-planner/${M}`);else if(R==="PPM")console.log("[NotificationBell] Navigating to PPM:",`/ppm/${M}`),g(`/ppm/${M}`);else if(R==="Item")console.log("[NotificationBell] Navigating to inventory:",`/inventory/${M}`),g(`/inventory/${M}`);else if(R==="Inspection")console.log("[NotificationBell] Navigating to inspection:",`/inspections/${M}`),g(`/inspections/${M}`);else{console.warn(`[NotificationBell] Unknown document type: ${O}, opening in Frappe`);const F=O.toLowerCase().replace(/\s+/g,"-").replace(/_/g,"-");window.open(`/app/${F}/${M}`,"_blank")}}else console.warn("[NotificationBell] No document_type or document_name found:",{document_type:C.document_type,document_name:C.document_name,notification:C});i(!1)}),E=C=>{const O=new Date(C),R=new Date().getTime()-O.getTime(),F=Math.floor(R/6e4),z=Math.floor(R/36e5),W=Math.floor(R/864e5);return F<1?"Just now":F<60?`${F}m ago`:z<24?`${z}h ago`:W<7?`${W}d ago`:O.toLocaleDateString()},S=e.filter(C=>!C.read),A=e.filter(C=>C.read).slice(0,10);return t.jsxs("div",{className:"relative",ref:h,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(wV,{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:["fixed left-1/2 top-16 w-[calc(100vw-1rem)] max-w-sm -translate-x-1/2","sm:absolute sm:left-auto sm:right-0 sm:top-auto sm:mt-2 sm:w-80 sm:max-w-none sm:translate-x-0","bg-white dark:bg-gray-800 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700","z-[9999] overflow-hidden flex flex-col","max-h-[60vh] sm:max-h-96"].join(" "),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(a_,{}),"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:y,disabled:c,className:`text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:underline ${c?"opacity-50 cursor-not-allowed":""}`,children:c?"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(a_,{className:"mx-auto text-3xl mb-2 opacity-50"}),t.jsx("p",{children:"No notifications"})]}):t.jsxs(t.Fragment,{children:[S.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"}),S.map(C=>t.jsx("div",{onClick:()=>w(C),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:jm(C.subject||"")||C.document_type||"Notification"}),C.email_content&&t.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-1 line-clamp-2",children:jm(C.email_content||"")}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-500 mt-1",children:E(C.creation)})]}),t.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full flex-shrink-0 mt-1"})]})},C.name))]}),A.length>0&&t.jsxs("div",{className:"p-2 border-t border-gray-200 dark:border-gray-700",children:[S.length>0&&t.jsx("div",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 px-2 mb-1",children:"EARLIER"}),A.map(C=>t.jsx("div",{onClick:()=>w(C),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:jm(C.subject||"")||C.document_type||"Notification"}),C.email_content&&t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1 line-clamp-2",children:jm(C.email_content||"")}),t.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:E(C.creation)})]})})},C.name))]})]})})]})]})},vG=()=>{const{theme:e,toggleTheme:r}=xG(),{language:a,changeLanguage:s}=xb(),{t:n}=Rr(),{openMobileSidebar:i}=pb(),c=Na(),[u,h]=_.useState(""),[g,y]=_.useState(!1);_.useEffect(()=>{me(null,null,function*(){var S;try{const O=(yield(yield fetch("/api/method/frappe.auth.get_logged_user",{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json()).message;if(O){const R=yield(yield fetch(`/api/resource/User/${encodeURIComponent(O)}?fields=["full_name"]`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json();(S=R.data)!=null&&S.full_name?h(R.data.full_name):h(O)}}catch(A){console.error("Error fetching user full name:",A)}})},[]);const w=()=>me(null,null,function*(){var E;localStorage.removeItem("user"),localStorage.removeItem("sid");try{const S=((E=document.cookie.split("; ").find(A=>A.startsWith("X-Frappe-CSRF-Token=")))==null?void 0:E.split("=")[1])||"";yield fetch("/api/method/frappe.auth.logout",{method:"POST",headers:{"Content-Type":"application/json","X-Frappe-CSRF-Token":S},credentials:"include"}),yield fetch("/?cmd=web_logout",{credentials:"include"})}catch(S){console.error("Logout error:",S)}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(SS,{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:[u&&t.jsxs("div",{className:"relative",children:[t.jsx("button",{type:"button",onClick:()=>c("/user-profile"),onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1),className:"p-2 rounded-lg bg-[#7911cc] hover:bg-[#6a0fb5] transition-colors text-white",title:u,children:t.jsx(OV,{size:20})}),g&&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:[u,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(bG,{})}),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(BV,{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(qV,{size:20}):t.jsx(eG,{size:20})}),t.jsx("button",{onClick:w,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(HV,{size:20})})]})]})};class wG{constructor(){Ii(this,"baseURL");this.baseURL=Or.BASE_URL}getCSRFToken(){return me(this,null,function*(){try{return typeof window!="undefined"&&window.csrf_token?window.csrf_token:null}catch(r){return null}})}getHeaders(){return me(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 me(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:c="creation desc"}=r,u=new URLSearchParams;if(u.append("fields",JSON.stringify(s)),u.append("limit_start",n.toString()),u.append("limit_page_length",i.toString()),u.append("order_by",c),Object.keys(a).length>0){const y=Ln(a);y.length>0&&u.append("filters",JSON.stringify(y))}const h=yield fetch(`${this.baseURL}/api/resource/Issue?${u.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);return{data:(yield h.json()).data||[]}})}getIssue(r){return me(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 me(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 me(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 me(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 me(this,arguments,function*(r={}){var i,c;const a=new URLSearchParams;if(a.append("fields",JSON.stringify(["count(name) as count"])),Object.keys(r).length>0){const u=Ln(r);u.length>0&&a.append("filters",JSON.stringify(u))}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((c=(i=(yield s.json()).data)==null?void 0:i[0])==null?void 0:c.count)||0})}}const G0=new wG,_G=(e={})=>{const[r,a]=_.useState([]),[s,n]=_.useState(!0),[i,c]=_.useState(null),[u,h]=_.useState(0),g=_.useCallback(()=>me(null,null,function*(){try{n(!0),c(null);const y=yield G0.getIssues(e);a(y.data);const w=yield G0.getIssueCount(e.filters);h(w)}catch(y){c(y instanceof Error?y.message:"Failed to fetch issues")}finally{n(!1)}}),[JSON.stringify(e)]);return _.useEffect(()=>{g()},[g]),{issues:r,loading:s,error:i,totalCount:u,refetch:g}},kG=e=>{const[r,a]=_.useState(null),[s,n]=_.useState(!1),[i,c]=_.useState(null),u=_.useCallback(()=>me(null,null,function*(){if(!e){a(null);return}try{n(!0),c(null);const h=yield G0.getIssue(e);a(h)}catch(h){c(h instanceof Error?h.message:"Failed to fetch issue details")}finally{n(!1)}}),[e]);return _.useEffect(()=>{u()},[u]),{issue:r,loading:s,error:i,refetch:u}},NG=()=>{const[e,r]=_.useState(!1),[a,s]=_.useState(null);return{createIssue:u=>me(null,null,function*(){try{return r(!0),s(null),yield G0.createIssue(u)}catch(h){const g=h instanceof Error?h.message:"Failed to create issue";throw s(g),h}finally{r(!1)}}),updateIssue:(u,h)=>me(null,null,function*(){try{return r(!0),s(null),yield G0.updateIssue(u,h)}catch(g){const y=g instanceof Error?g.message:"Failed to update issue";throw s(y),g}finally{r(!1)}}),deleteIssue:u=>me(null,null,function*(){try{r(!0),s(null),yield G0.deleteIssue(u)}catch(h){const g=h instanceof Error?h.message:"Failed to delete issue";throw s(g),h}finally{r(!1)}}),loading:e,error:a}},jG=({isOpen:e,onClose:r,selectedCount:a,totalCount:s,pageCount:n,onExport:i,isExporting:c,exportColumns:u})=>{const{t:h}=Rr(),[g,y]=_.useState(a>0?"selected":"all_with_filters"),[w,E]=_.useState("csv"),[S,A]=_.useState(u.filter(R=>R.default).map(R=>R.key));_.useEffect(()=>{a>0?y("selected"):y("all_with_filters")},[a]);const C=R=>{A(F=>F.includes(R)?F.filter(z=>z!==R):[...F,R])},O=()=>A(u.map(R=>R.key)),M=()=>A(u.filter(R=>R.default).map(R=>R.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(Ks,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:h("issues.export.title")})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:c,children:t.jsx(Pt,{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:h("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 ${g==="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:g==="selected",onChange:()=>y("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:h("issues.export.selectedRows")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("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 ${g==="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:g==="all_on_page",onChange:()=>y("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:h("issues.export.currentPage")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("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 ${g==="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:g==="all_with_filters",onChange:()=>y("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:h("issues.export.allWithFilters")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("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:h("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 ${w==="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:w==="csv",onChange:()=>E("csv"),className:"text-green-600 focus:ring-green-500"}),t.jsx(No,{className:"text-green-600 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("issues.export.csv")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("issues.export.csvDesc")})]})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${w==="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:w==="excel",onChange:()=>E("excel"),className:"text-green-600 focus:ring-green-500"}),t.jsx(zi,{className:"text-green-700 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("issues.export.excel")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("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:h("issues.export.columnsToExport")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:O,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("issues.export.selectAll")}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{onClick:M,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("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:u.map(R=>t.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${S.includes(R.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:S.includes(R.key),onChange:()=>C(R.key),className:"rounded text-green-600 focus:ring-green-500"}),t.jsx("span",{className:"text-sm truncate",children:R.label})]},R.key))}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:h("issues.export.columnsSelected",{count:S.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:[g==="selected"&&h("issues.export.exportingSelected",{count:a}),g==="all_on_page"&&h("issues.export.exportingPage",{count:n}),g==="all_with_filters"&&h("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:c,children:h("common.cancel")}),t.jsx("button",{onClick:()=>i(g,w,S),disabled:S.length===0||c,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:c?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),h("issues.export.exporting")]}):t.jsxs(t.Fragment,{children:[t.jsx(Vo,{}),h("issues.export.exportButton")]})})]})]})]})}):null},SG=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"}},CG=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"}},EG=()=>{const{t:e}=Rr(),r=Na(),[a,s]=Sn(),n=_.useMemo(()=>{const Ye=parseInt(a.get("page")||"1",10);return Number.isNaN(Ye)||Ye<1?1:Ye},[a]),i=_.useCallback(Ye=>{const wt=typeof Ye=="function"?Ye(n):Ye;s(zt=>{const qt=new URLSearchParams(zt);return qt.set("page",String(wt)),qt})},[n,s]),c=[{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}],[u]=_.useState(20),[h,g]=_.useState(!1),[y,w]=_.useState(new Set),[E,S]=_.useState(!1),[A,C]=_.useState(!1),[O,M]=_.useState(null),[R,F]=_.useState(()=>a.get("date_filter_by")||""),[z,W]=_.useState(()=>a.get("date_start")||""),[X,B]=_.useState(()=>a.get("date_end")||""),[Y,G]=_.useState(()=>a.get("status")||""),[ie,fe]=_.useState(()=>a.get("priority")||""),[K,ke]=_.useState(()=>a.get("company")||""),[ge,re]=_.useState(()=>a.get("issue_id")||""),[we,ee]=_.useState(()=>a.get("sort_by")||"creation desc"),[ve,ce]=_.useState(!1),[ye,te]=_.useState(0),[q,J]=_.useState([]),[ae,oe]=_.useState(!1),[le,be]=_.useState("");_.useEffect(()=>{const Ye=localStorage.getItem("issueFilterPresets");Ye&&J(JSON.parse(Ye))},[]);const Z=R&&(z||X);_.useEffect(()=>{const Ye=[Y,ie,K,ge].filter(Boolean).length+(Z?1:0);te(Ye)},[Y,ie,K,ge,Z]);const Le=_.useMemo(()=>{const Ye={};return Y&&(Ye.status=Y),ie&&(Ye.priority=ie),K&&(Ye.company=K),ge&&(Ye.name=ge),Object.assign(Ye,td(R,z,X)),Ye},[Y,ie,K,ge,R,z,X]),Pe=["creation desc","creation asc","modified desc","modified asc","name asc","name desc"].includes(we)?we:"creation desc",{issues:Be,loading:pe,error:rt,totalCount:ct,refetch:et}=_G({filters:Le,limit_start:(n-1)*u,limit_page_length:u,order_by:Pe});_.useEffect(()=>{!pe&&!h&&g(!0)},[pe,h]);const It=_.useRef(!1);_.useEffect(()=>{if(!It.current){It.current=!0;return}s(Ye=>{const wt=new URLSearchParams(Ye);return R?wt.set("date_filter_by",R):wt.delete("date_filter_by"),z?wt.set("date_start",z):wt.delete("date_start"),X?wt.set("date_end",X):wt.delete("date_end"),Y?wt.set("status",Y):wt.delete("status"),ie?wt.set("priority",ie):wt.delete("priority"),K?wt.set("company",K):wt.delete("company"),ge?wt.set("issue_id",ge):wt.delete("issue_id"),we&&we!=="creation desc"?wt.set("sort_by",we):wt.delete("sort_by"),wt.set("page","1"),wt})},[R,z,X,Y,ie,K,ge,we]),_.useEffect(()=>{w(new Set)},[R,z,X,Y,ie,K,ge,n]);const ft=Ye=>Ye?new Date(Ye).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-",Lt=()=>{F(""),W(""),B(""),ee("creation desc"),G(""),fe(""),ke(""),re(""),s(Ye=>{const wt=new URLSearchParams(Ye);return wt.delete("date_filter_by"),wt.delete("date_start"),wt.delete("date_end"),wt.delete("sort_by"),wt.delete("status"),wt.delete("priority"),wt.delete("company"),wt.delete("issue_id"),wt.set("page","1"),wt})},Je=Z||!!Y||!!ie||!!K||!!ge,Ve=()=>{if(!le.trim()){alert("Please enter a filter name");return}const Ye={id:Date.now(),name:le,filters:{dateFilterBy:R,dateStart:z,dateEnd:X,sortBy:we,statusFilter:Y,priorityFilter:ie,companyFilter:K,issueIdFilter:ge}},wt=[...q,Ye];J(wt),be(""),oe(!1),localStorage.setItem("issueFilterPresets",JSON.stringify(wt))},Xe=Ye=>{const wt=Ye.filters;F(wt.dateFilterBy||""),W(wt.dateStart||""),B(wt.dateEnd||""),ee(wt.sortBy||"creation desc"),G(wt.statusFilter||""),fe(wt.priorityFilter||""),ke(wt.companyFilter||""),re(wt.issueIdFilter||"")},Rt=Ye=>{const wt=q.filter(zt=>zt.id!==Ye);J(wt),localStorage.setItem("issueFilterPresets",JSON.stringify(wt))},qe=Ye=>{w(wt=>{const zt=new Set(wt);return zt.has(Ye)?zt.delete(Ye):zt.add(Ye),zt})},Dt=()=>{y.size===Be.length?w(new Set):w(new Set(Be.map(Ye=>Ye.name)))},ar=Be.length>0&&y.size===Be.length,yt=y.size>0&&y.size<Be.length,St=_.useCallback(()=>me(null,null,function*(){const Ye=[];let wt=0;const zt=100;let qt=!0;const kt=Ln(Le);for(;qt;)try{const _t=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Issue",filters:kt.length>0?kt:{},fields:["*"],limit_start:wt*zt,limit_page_length:zt,order_by:Pe})})).json()).message||[];Ye.push(..._t),_t.length<zt?qt=!1:wt++,wt>100&&(console.warn("Export safety limit reached"),qt=!1)}catch(ze){throw console.error("Error fetching issues for export:",ze),ze}return Ye}),[Le,Pe]),Ot=(Ye,wt,zt)=>me(null,null,function*(){C(!0);try{let qt=[];switch(Ye){case"selected":qt=Be.filter(ze=>y.has(ze.name));break;case"all_on_page":qt=Be;break;case"all_with_filters":qt=yield St();break}if(qt.length===0){alert(e("assets.noDataToExport"));return}const kt=zt.map(ze=>{var nt;return((nt=c.find(_t=>_t.key===ze))==null?void 0:nt.label)||ze});if(wt==="csv"){const ze=[kt.join(","),...qt.map(pr=>zt.map(Nr=>{let rr=pr[Nr]||"";return typeof rr=="string"&&(rr.includes(",")||rr.includes('"')||rr.includes(`
`))&&(rr=`"${rr.replace(/"/g,'""')}"`),rr}).join(","))].join(`
`),nt=new Blob(["\uFEFF"+ze],{type:"text/csv;charset=utf-8;"}),_t=URL.createObjectURL(nt),lr=document.createElement("a");lr.href=_t,lr.download=`issues_export_${new Date().toISOString().split("T")[0]}.csv`,lr.click(),URL.revokeObjectURL(_t)}else if(wt==="excel"){const ze=[kt,...qt.map(lr=>zt.map(pr=>lr[pr]||""))],nt=Ur.aoa_to_sheet(ze),_t=Ur.book_new();Ur.book_append_sheet(_t,nt,"Issues"),jo(_t,`issues_export_${new Date().toISOString().split("T")[0]}.xlsx`)}S(!1),w(new Set)}catch(qt){console.error("Export failed:",qt),alert(`Export failed: ${qt instanceof Error?qt.message:"Unknown error"}`)}finally{C(!1)}}),Yt=Ye=>me(null,null,function*(){try{if(!(yield fetch(`/api/resource/Issue/${Ye}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to delete");M(null),et(),alert(e("issues.deletedSuccessfully"))}catch(wt){alert(`Failed to delete: ${wt instanceof Error?wt.message:"Unknown error"}`)}});return pe&&!h?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")})]})}):rt?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:rt}),t.jsx("button",{onClick:et,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:e("common.tryAgain")})]})}):t.jsxs("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen w-full min-w-0 overflow-x-hidden",children:[t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center w-full min-w-0",children:[t.jsx("div",{className:"min-w-0",children:t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(n_,{className:"text-3xl text-blue-600 dark:text-blue-400"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-gray-800 dark:text-white break-words",children:e("issues.listTitle")}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[e("issues.listTotal"),": ",ct,y.size>0&&t.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",y.size," ",e("issues.listSelected")]}),pe&&h&&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 flex-col gap-2 w-full sm:flex-row sm:flex-wrap sm:justify-end sm:gap-3 sm:w-auto min-w-0 shrink-0",children:[t.jsxs("button",{type:"button",onClick:()=>ce(!ve),className:`px-4 py-2 rounded-lg flex items-center justify-center gap-2 transition-colors w-full sm:w-auto ${ve||Je?"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(Hs,{}),e("listPages.filters"),ye>0&&t.jsx("span",{className:"bg-blue-600 text-white text-xs px-1.5 py-0.5 rounded-full",children:ye})]}),t.jsxs("button",{type:"button",onClick:et,disabled:pe,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 justify-center gap-2 disabled:opacity-50 w-full sm:w-auto",children:[t.jsx(Ui,{className:pe?"animate-spin":""}),e("listPages.refresh")]}),t.jsxs("button",{type:"button",onClick:()=>S(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center justify-center gap-2 shadow transition-all disabled:opacity-50 w-full sm:w-auto",disabled:ct===0,children:[t.jsx(Ks,{}),t.jsx("span",{className:"font-medium",children:e("listPages.export")}),y.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:y.size})]}),t.jsxs("button",{type:"button",onClick:()=>r("/support/new"),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center justify-center gap-2 shadow-lg transition-all hover:shadow-xl w-full sm:w-auto",children:[t.jsx(Js,{}),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:ct})]}),t.jsx(eT,{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:Be.filter(Ye=>Ye.status==="Open").length})]}),t.jsx(Ja,{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:Be.filter(Ye=>Ye.status==="Resolved").length})]}),t.jsx(Tr,{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:Be.filter(Ye=>Ye.status==="Closed").length})]}),t.jsx(Br,{className:"text-3xl text-gray-500"})]})})]}),ve&&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(Hs,{className:"text-white",size:16}),t.jsx("h3",{className:"text-white font-semibold text-sm",children:e("listPages.filters")}),ye>0&&t.jsx("span",{className:"bg-white text-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:ye})]}),Je&&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:[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("issues.issueId"),":"]})," ",ge,t.jsx("button",{onClick:()=>re(""),className:"hover:text-red-500",children:t.jsx(Pt,{className:"text-[9px]"})})]}),Y&&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"),":"]})," ",Y,t.jsx("button",{onClick:()=>G(""),className:"hover:text-red-500",children:t.jsx(Pt,{className:"text-[9px]"})})]}),ie&&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"),":"]})," ",ie,t.jsx("button",{onClick:()=>fe(""),className:"hover:text-red-500",children:t.jsx(Pt,{className:"text-[9px]"})})]}),K&&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"),":"]})," ",K,t.jsx("button",{onClick:()=>ke(""),className:"hover:text-red-500",children:t.jsx(Pt,{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.filterBy"),":"]})," ",e(R==="creation"?"filters.createdDate":"filters.latestModifiedDate")," ",z&&` ${z}`," ",X&&` - ${X}`,t.jsx("button",{onClick:()=>{F(""),W(""),B("")},className:"hover:text-red-500",children:t.jsx(Pt,{className:"text-[9px]"})})]})]})}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[ye>0&&t.jsxs("button",{onClick:()=>oe(!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(bs,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:e("listPages.saveFilterPreset")})]}),Je&&t.jsxs("button",{onClick:Lt,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(Pt,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:e("listPages.clearFilters")})]})]})]})}),t.jsxs("div",{className:"p-4",children:[q.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(ul,{className:"text-yellow-500",size:12}),e("inspections.savedFilters")]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:q.map(Ye=>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:()=>Xe(Ye),className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:Ye.name}),t.jsx("button",{onClick:()=>Rt(Ye.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:t.jsx(la,{size:10})})]},Ye.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:we,onChange:Ye=>{ee(Ye.target.value),i(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:R,onChange:Ye=>{const wt=Ye.target.value;F(wt),i(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")})]})]}),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:z,onChange:Ye=>{const wt=Ye.target.value;W(wt),X&&wt>X&&B(wt),i(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:X,onChange:Ye=>{B(Ye.target.value),i(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-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]}),t.jsxs("div",{className:"relative z-10 lg:z-[60]",children:[t.jsx(hr,{label:e("issues.issueId"),doctype:"Issue",value:ge,onChange:Ye=>{re(Ye),i(1)},placeholder:e("linkField.selectLabel",{label:e("issues.issueId")}),disabled:!1,compact:!0}),ge&&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(Pt,{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:Y,onChange:Ye=>{G(Ye.target.value),i(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-10 lg:z-[59]",children:[t.jsx(hr,{label:e("commonFields.priority"),doctype:"Issue Priority",value:ie,onChange:Ye=>{fe(Ye),i(1)},placeholder:e("issues.allPriorities"),disabled:!1,compact:!0}),ie&&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(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[58]",children:[t.jsx(hr,{label:e("commonFields.company"),doctype:"Company",value:K,onChange:Ye=>{ke(Ye),i(1)},placeholder:e("issues.allCompanies"),disabled:!1,compact:!0}),K&&t.jsx("button",{onClick:()=>ke(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(Pt,{size:10})})]})]})})]})]}),ae&&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:le,onChange:Ye=>be(Ye.target.value),onKeyDown:Ye=>{Ye.key==="Enter"&&(Ye.preventDefault(),Ve())},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:()=>{oe(!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:Ve,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(bs,{size:12}),"Save Filter"]})]})]})}),t.jsx(jG,{isOpen:E,onClose:()=>S(!1),selectedCount:y.size,totalCount:ct,pageCount:Be.length,onExport:Ot,isExporting:A,exportColumns:c}),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:[pe&&h&&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:Dt,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:e(ar?"listPages.deselectAllTitle":"listPages.selectAllTitle"),children:ar?t.jsx(jn,{className:"text-blue-600 dark:text-blue-400",size:18}):yt?t.jsxs("div",{className:"relative",children:[t.jsx(ys,{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(ys,{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:Be.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(n_,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("issues.noIssuesFound")}),Je?t.jsx("button",{onClick:Lt,className:"mt-4 text-blue-600 dark:text-blue-400 hover:underline",children:e("common.clearFilters")}):t.jsx("button",{onClick:()=>r("/support/new"),className:"mt-4 text-blue-600 dark:text-blue-400 hover:underline",children:e("issues.createFirstIssue")})]})})}):Be.map(Ye=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 cursor-pointer transition-colors ${y.has(Ye.name)?"bg-blue-50 dark:bg-blue-900/20":""}`,onClick:()=>r(`/support/${Ye.name}`),children:[t.jsx("td",{className:"px-4 py-3",onClick:wt=>wt.stopPropagation(),children:t.jsx("button",{onClick:()=>qe(Ye.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:y.has(Ye.name)?t.jsx(jn,{className:"text-blue-600 dark:text-blue-400",size:18}):t.jsx(ys,{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:Ye.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:Ye.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 ${SG(Ye.status)}`,children:Ye.status?e(`issues.status.${Ye.status.toLowerCase().replace(/\\s+/g,"_")}`,Ye.status):"-"})}),t.jsx("td",{className:"px-4 py-3",children:Ye.priority?t.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${CG(Ye.priority)}`,children:e(`issues.priority.${Ye.priority.toLowerCase()}`,Ye.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:Ye.company||"-"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:ft(Ye.opening_date)})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-1",onClick:wt=>wt.stopPropagation(),children:[t.jsx("button",{onClick:()=>r(`/support/${Ye.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(to,{})}),t.jsx("button",{onClick:()=>r(`/support/${Ye.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(Ms,{})}),t.jsx("button",{onClick:()=>M(Ye.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(la,{})})]})})]},Ye.name))})]})}),t.jsx(ed,{currentPage:n,totalCount:ct,pageSize:u,itemLabel:e("pagination.issues"),onPageChange:Ye=>i(Ye)})]}),O&&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(la,{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"),":"]})," ",O]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>M(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(O),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(la,{}),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; }
`})]})},TG=()=>new Date().toISOString().split("T")[0],AG=()=>new Date().toTimeString().split(" ")[0],OG=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"}}},DG=()=>{const{t:e}=Rr(),{issueName:r}=ml(),a=Na(),s=r==="new",[n,i]=_.useState({subject:"",raised_by:"",status:"Open",priority:"",issue_type:"",description:"",contact:"",company:"",customer:"",project:"",resolution_details:"",opening_date:s?TG():"",opening_time:s?AG():"",first_responded_on:"",sla_resolution_date:"",sla_resolution_by:""}),{issue:c,loading:u,error:h,refetch:g}=kG(s?null:r||null),{createIssue:y,updateIssue:w,deleteIssue:E,loading:S}=NG(),[A,C]=_.useState(s),[O,M]=_.useState(!1);_.useEffect(()=>{c&&!s&&(i({subject:c.subject||"",raised_by:c.raised_by||"",status:c.status||"Open",priority:c.priority||"",issue_type:c.issue_type||"",description:c.description||"",contact:c.contact||"",company:c.company||"",customer:c.customer||"",project:c.project||"",resolution_details:c.resolution_details||"",opening_date:c.opening_date||"",opening_time:c.opening_time||"",first_responded_on:c.first_responded_on?c.first_responded_on.split(" ")[0]:"",sla_resolution_date:c.sla_resolution_date?c.sla_resolution_date.split(" ")[0]:"",sla_resolution_by:c.sla_resolution_by||""}),C(!1))},[c,s]);const R=G=>{const{name:ie,value:fe}=G.target;i(K=>Ke(Te({},K),{[ie]:fe}))},F=()=>me(null,null,function*(){if(!n.subject){Mt.error("Please enter a subject",{position:"top-right",autoClose:4e3,icon:t.jsx(Br,{})});return}try{if(s){const G=yield y(n);Mt.success("Issue created successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),a(`/support/${G.name}`)}else yield w(r,n),Mt.success("Issue updated successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),C(!1),g()}catch(G){const ie=G instanceof Error?G.message:"Unknown error";Mt.error(`Failed to save: ${ie}`,{position:"top-right",autoClose:6e3,icon:t.jsx(Br,{})})}}),z=()=>me(null,null,function*(){try{yield E(r),Mt.success("Issue deleted successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),a(-1)}catch(G){const ie=G instanceof Error?G.message:"Unknown error";Mt.error(`Failed to delete: ${ie}`,{position:"top-right",autoClose:6e3,icon:t.jsx(Br,{})})}}),W=_.useCallback(G=>!!(!A||["opening_date","opening_time"].includes(G)&&!s),[A,s]),X=G=>G?new Date(G).toLocaleString():"-";if(u)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(h&&!s)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:h}),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 B=(c==null?void 0:c.status)||n.status||"Open",Y=OG(B);return t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[t.jsx(xc,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:Ll}),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(Kn,{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:[s?e("issues.newIssue"):(c==null?void 0:c.name)||e("issues.issueDetails"),!s&&t.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-medium ${Y.bg} ${Y.text} ${Y.border} border`,children:B})]}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:s?e("issues.createNewIssue"):n.subject})]})]}),t.jsxs("div",{className:"flex gap-3",children:[!s&&!A&&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(Ms,{}),e("common.edit")]}),t.jsxs("button",{onClick:()=>M(!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(la,{}),e("common.delete")]})]}),A&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{s?a(-1):(C(!1),g())},className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg",children:e("common.cancel")}),t.jsxs("button",{onClick:F,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(bs,{}),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(Jr,{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:()=>M(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",children:"Cancel"}),t.jsx("button",{onClick:z,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(Q8,{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:n.subject,onChange:R,disabled:W("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:n.status,onChange:R,disabled:W("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(hr,{label:e("commonFields.priority"),doctype:"Issue Priority",value:n.priority||"",onChange:G=>i(Ke(Te({},n),{priority:G})),disabled:W("priority"),placeholder:e("issues.selectPriority")})})]}),t.jsx("div",{children:t.jsx(hr,{label:e("issues.issueType"),doctype:"Issue Type",value:n.issue_type||"",onChange:G=>i(Ke(Te({},n),{issue_type:G})),disabled:W("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:n.description,onChange:R,disabled:W("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(Yn,{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(K4,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"}),t.jsx("input",{type:"email",name:"raised_by",value:n.raised_by,onChange:R,disabled:W("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(hr,{label:e("commonFields.company"),doctype:"Company",value:n.company||"",onChange:G=>i(Ke(Te({},n),{company:G})),disabled:W("company"),placeholder:e("issues.selectCompany")})})]})]}),!s&&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(Tr,{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:n.first_responded_on||"",onChange:R,disabled:W("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:n.sla_resolution_date||"",onChange:R,disabled:W("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(hr,{label:e("issues.resolvedBy"),doctype:"User",value:n.sla_resolution_by||"",onChange:G=>i(Ke(Te({},n),{sla_resolution_by:G})),disabled:W("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:n.resolution_details,onChange:R,disabled:W("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"})]})]})]}),!s&&t.jsx(Kd,{referenceDoctype:"Issue",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(oT,{className:"text-orange-500"}),e("issues.statusInformation")]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:`p-4 rounded-lg border ${Y.bg} ${Y.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 ${Y.text}`,children:B})]}),n.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:n.priority})]}),n.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:n.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($o,{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:n.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:n.opening_time||"-"})]}),!s&&c&&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:X(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:X(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||"-"})]})]})]})]}),n.company&&!s&&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(ly,{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:n.company})})]})]})]})]})};class RG{constructor(){Ii(this,"baseURL");this.baseURL=Or.BASE_URL}getCSRFToken(){return me(this,null,function*(){try{return typeof window!="undefined"&&window.csrf_token?window.csrf_token:null}catch(r){return null}})}getHeaders(){return me(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 me(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:c="creation desc"}=r,u=new URLSearchParams;if(u.append("fields",JSON.stringify(s)),u.append("limit_start",n.toString()),u.append("limit_page_length",i.toString()),u.append("order_by",c),Object.keys(a).length>0){const y=Ln(a);y.length>0&&u.append("filters",JSON.stringify(y))}const h=yield fetch(`${this.baseURL}/api/resource/Asset Maintenance Team?${u.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);return{data:(yield h.json()).data||[]}})}getMaintenanceTeam(r){return me(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 me(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 me(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 me(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 me(this,arguments,function*(r={}){var i,c;const a=new URLSearchParams;if(a.append("fields",JSON.stringify(["count(name) as count"])),Object.keys(r).length>0){const u=Ln(r);u.length>0&&a.append("filters",JSON.stringify(u))}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((c=(i=(yield s.json()).data)==null?void 0:i[0])==null?void 0:c.count)||0})}getUserFullName(r){return me(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 kd=new RG,FG=(e={})=>{const[r,a]=_.useState([]),[s,n]=_.useState(!0),[i,c]=_.useState(null),[u,h]=_.useState(0),g=_.useCallback(()=>me(null,null,function*(){try{n(!0),c(null);const y=yield kd.getMaintenanceTeams(e);a(y.data);const w=yield kd.getMaintenanceTeamCount(e.filters);h(w)}catch(y){c(y instanceof Error?y.message:"Failed to fetch maintenance teams")}finally{n(!1)}}),[JSON.stringify(e)]);return _.useEffect(()=>{g()},[g]),{teams:r,loading:s,error:i,totalCount:u,refetch:g}},IG=e=>{const[r,a]=_.useState(null),[s,n]=_.useState(!1),[i,c]=_.useState(null),u=_.useCallback(()=>me(null,null,function*(){if(!e){a(null);return}try{n(!0),c(null);const h=yield kd.getMaintenanceTeam(e);a(h)}catch(h){c(h instanceof Error?h.message:"Failed to fetch maintenance team details")}finally{n(!1)}}),[e]);return _.useEffect(()=>{u()},[u]),{team:r,loading:s,error:i,refetch:u}},MG=()=>{const[e,r]=_.useState(!1),[a,s]=_.useState(null);return{createTeam:h=>me(null,null,function*(){try{return r(!0),s(null),yield kd.createMaintenanceTeam(h)}catch(g){const y=g instanceof Error?g.message:"Failed to create maintenance team";throw s(y),g}finally{r(!1)}}),updateTeam:(h,g)=>me(null,null,function*(){try{return r(!0),s(null),yield kd.updateMaintenanceTeam(h,g)}catch(y){const w=y instanceof Error?y.message:"Failed to update maintenance team";throw s(w),y}finally{r(!1)}}),deleteTeam:h=>me(null,null,function*(){try{r(!0),s(null),yield kd.deleteMaintenanceTeam(h)}catch(g){const y=g instanceof Error?g.message:"Failed to delete maintenance team";throw s(y),g}finally{r(!1)}}),getUserFullName:h=>me(null,null,function*(){return yield kd.getUserFullName(h)}),loading:e,error:a}},PG=({isOpen:e,onClose:r,selectedCount:a,totalCount:s,pageCount:n,onExport:i,isExporting:c,exportColumns:u})=>{const{t:h}=Rr(),[g,y]=_.useState(a>0?"selected":"all_with_filters"),[w,E]=_.useState("csv"),[S,A]=_.useState(u.filter(R=>R.default).map(R=>R.key));_.useEffect(()=>{y(a>0?"selected":"all_with_filters")},[a]);const C=R=>A(F=>F.includes(R)?F.filter(z=>z!==R):[...F,R]),O=()=>A(u.map(R=>R.key)),M=()=>A(u.filter(R=>R.default).map(R=>R.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(Ks,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:h("maintenance.export.title")})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:c,children:t.jsx(Pt,{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:h("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 ${g==="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:g==="selected",onChange:()=>y("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:h("maintenance.export.selectedRows")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("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 ${g==="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:g==="all_on_page",onChange:()=>y("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:h("maintenance.export.currentPage")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("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 ${g==="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:g==="all_with_filters",onChange:()=>y("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:h("maintenance.export.allWithFilters")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("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:h("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 ${w==="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:w==="csv",onChange:()=>E("csv"),className:"text-green-600 focus:ring-green-500"}),t.jsx(No,{className:"text-green-600 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("maintenance.export.csv")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("maintenance.export.csvDesc")})]})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${w==="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:w==="excel",onChange:()=>E("excel"),className:"text-green-600 focus:ring-green-500"}),t.jsx(zi,{className:"text-green-700 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("maintenance.export.excel")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("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:h("maintenance.export.columnsToExport")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:O,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("maintenance.export.selectAll")}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{onClick:M,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("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:u.map(R=>t.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${S.includes(R.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:S.includes(R.key),onChange:()=>C(R.key),className:"rounded text-green-600 focus:ring-green-500"}),t.jsx("span",{className:"text-sm truncate",children:R.label})]},R.key))}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:h("maintenance.export.columnsSelected",{count:S.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:[g==="selected"&&h("maintenance.export.exportingSelected",{count:a}),g==="all_on_page"&&h("maintenance.export.exportingPage",{count:n}),g==="all_with_filters"&&h("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:c,children:h("common.cancel")}),t.jsx("button",{onClick:()=>i(g,w,S),disabled:S.length===0||c,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:c?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),h("maintenance.export.exporting")]}):t.jsxs(t.Fragment,{children:[t.jsx(Vo,{}),h("maintenance.export.exportButton")]})})]})]})]})}):null},LG=()=>{const{t:e}=Rr(),r=Na(),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]=Sn(),i=_.useMemo(()=>{const yt=parseInt(s.get("page")||"1",10);return Number.isNaN(yt)||yt<1?1:yt},[s]),c=_.useCallback(yt=>{const St=typeof yt=="function"?yt(i):yt;n(Ot=>{const Yt=new URLSearchParams(Ot);return Yt.set("page",String(St)),Yt})},[i,n]),[u]=_.useState(20),[h,g]=_.useState(!1),[y,w]=_.useState(new Set),[E,S]=_.useState(!1),[A,C]=_.useState(!1),[O,M]=_.useState(null),[R,F]=_.useState(()=>s.get("date_filter_by")||""),[z,W]=_.useState(()=>s.get("date_start")||""),[X,B]=_.useState(()=>s.get("date_end")||""),[Y,G]=_.useState(()=>s.get("company")||""),[ie,fe]=_.useState(()=>s.get("team_name")||""),[K,ke]=_.useState(()=>s.get("sort_by")||"creation desc"),[ge,re]=_.useState(!1),[we,ee]=_.useState(0),[ve,ce]=_.useState([]),[ye,te]=_.useState(!1),[q,J]=_.useState("");_.useEffect(()=>{const yt=localStorage.getItem("maintenanceTeamFilterPresets");yt&&ce(JSON.parse(yt))},[]);const ae=R&&(z||X);_.useEffect(()=>{const yt=[Y,ie].filter(Boolean).length+(ae?1:0);ee(yt)},[Y,ie,ae]);const oe=_.useMemo(()=>{const yt={};return Y&&(yt.company=Y),ie&&(yt.name=ie),Object.assign(yt,td(R,z,X)),yt},[Y,ie,R,z,X]),le=["creation desc","creation asc","modified desc","modified asc","name asc","name desc","maintenance_team_name asc","maintenance_team_name desc"].includes(K)?K:"creation desc",{teams:be,loading:Z,error:Le,totalCount:Pe,refetch:Be}=FG({filters:oe,limit_start:(i-1)*u,limit_page_length:u,order_by:le});_.useEffect(()=>{!Z&&!h&&g(!0)},[Z,h]);const pe=_.useRef(!1);_.useEffect(()=>{if(!pe.current){pe.current=!0;return}n(yt=>{const St=new URLSearchParams(yt);return R?St.set("date_filter_by",R):St.delete("date_filter_by"),z?St.set("date_start",z):St.delete("date_start"),X?St.set("date_end",X):St.delete("date_end"),Y?St.set("company",Y):St.delete("company"),ie?St.set("team_name",ie):St.delete("team_name"),K&&K!=="creation desc"?St.set("sort_by",K):St.delete("sort_by"),St.set("page","1"),St})},[R,z,X,Y,ie,K]),_.useEffect(()=>{w(new Set)},[R,z,X,Y,ie,i]);const rt=yt=>yt?new Date(yt).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-",ct=()=>{F(""),W(""),B(""),ke("creation desc"),G(""),fe(""),n(yt=>{const St=new URLSearchParams(yt);return St.delete("date_filter_by"),St.delete("date_start"),St.delete("date_end"),St.delete("sort_by"),St.delete("company"),St.delete("team_name"),St.set("page","1"),St})},et=ae||!!Y||!!ie,It=()=>{if(!q.trim()){alert("Please enter a filter name");return}const yt={id:Date.now(),name:q,filters:{dateFilterBy:R,dateStart:z,dateEnd:X,sortBy:K,companyFilter:Y,teamNameFilter:ie}},St=[...ve,yt];ce(St),J(""),te(!1),localStorage.setItem("maintenanceTeamFilterPresets",JSON.stringify(St))},ft=yt=>{const St=yt.filters;F(St.dateFilterBy||""),W(St.dateStart||""),B(St.dateEnd||""),ke(St.sortBy||"creation desc"),G(St.companyFilter||""),fe(St.teamNameFilter||"")},Lt=yt=>{const St=ve.filter(Ot=>Ot.id!==yt);ce(St),localStorage.setItem("maintenanceTeamFilterPresets",JSON.stringify(St))},Je=yt=>{w(St=>{const Ot=new Set(St);return Ot.has(yt)?Ot.delete(yt):Ot.add(yt),Ot})},Ve=()=>{y.size===be.length?w(new Set):w(new Set(be.map(yt=>yt.name)))},Xe=be.length>0&&y.size===be.length,Rt=y.size>0&&y.size<be.length,qe=_.useCallback(()=>me(null,null,function*(){const yt=[];let St=0;const Ot=100;let Yt=!0;const Ye=Ln(oe);for(;Yt;)try{const qt=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Asset Maintenance Team",filters:Ye.length>0?Ye:{},fields:["*"],limit_start:St*Ot,limit_page_length:Ot,order_by:le})})).json()).message||[];yt.push(...qt),qt.length<Ot?Yt=!1:St++,St>100&&(console.warn("Export safety limit reached"),Yt=!1)}catch(wt){throw console.error("Error fetching teams for export:",wt),wt}return yt}),[oe]),Dt=(yt,St,Ot)=>me(null,null,function*(){C(!0);try{let Yt=[];switch(yt){case"selected":Yt=be.filter(wt=>y.has(wt.name));break;case"all_on_page":Yt=be;break;case"all_with_filters":Yt=yield qe();break}if(Yt.length===0){alert(e("assets.noDataToExport"));return}const Ye=Ot.map(wt=>{var zt;return((zt=a.find(qt=>qt.key===wt))==null?void 0:zt.label)||wt});if(St==="csv"){const wt=[Ye.join(","),...Yt.map(ze=>Ot.map(nt=>{let _t=ze[nt]||"";return typeof _t=="string"&&(_t.includes(",")||_t.includes('"')||_t.includes(`
`))&&(_t=`"${_t.replace(/"/g,'""')}"`),_t}).join(","))].join(`
`),zt=new Blob(["\uFEFF"+wt],{type:"text/csv;charset=utf-8;"}),qt=URL.createObjectURL(zt),kt=document.createElement("a");kt.href=qt,kt.download=`maintenance_teams_export_${new Date().toISOString().split("T")[0]}.csv`,kt.click(),URL.revokeObjectURL(qt)}else if(St==="excel"){const wt=[Ye,...Yt.map(kt=>Ot.map(ze=>kt[ze]||""))],zt=Ur.aoa_to_sheet(wt),qt=Ur.book_new();Ur.book_append_sheet(qt,zt,"Maintenance Teams"),jo(qt,`maintenance_teams_export_${new Date().toISOString().split("T")[0]}.xlsx`)}S(!1),w(new Set)}catch(Yt){console.error("Export failed:",Yt),alert(`Export failed: ${Yt instanceof Error?Yt.message:"Unknown error"}`)}finally{C(!1)}}),ar=yt=>me(null,null,function*(){try{if(!(yield fetch(`/api/resource/Asset Maintenance Team/${encodeURIComponent(yt)}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to delete");M(null),Be(),alert(e("maintenance.deletedSuccessfully"))}catch(St){alert(`Failed to delete: ${St instanceof Error?St.message:"Unknown error"}`)}});return Z&&!h?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")})]})}):Le?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:Le}),t.jsx("button",{onClick:Be,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:e("common.tryAgain")})]})}):t.jsxs("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen w-full min-w-0 overflow-x-hidden",children:[t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center w-full min-w-0",children:[t.jsx("div",{className:"min-w-0",children:t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(Sd,{className:"text-3xl text-indigo-600 dark:text-indigo-400"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-gray-800 dark:text-white break-words",children:e("maintenance.listTitle")}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[e("issues.listTotal"),": ",Pe,y.size>0&&t.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",y.size," ",e("issues.listSelected")]}),Z&&h&&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 flex-col gap-2 w-full sm:flex-row sm:flex-wrap sm:justify-end sm:gap-3 sm:w-auto min-w-0 shrink-0",children:[t.jsxs("button",{type:"button",onClick:()=>re(!ge),className:`px-4 py-2 rounded-lg flex items-center justify-center gap-2 transition-colors w-full sm:w-auto ${ge||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(Hs,{}),e("listPages.filters"),we>0&&t.jsx("span",{className:"bg-blue-600 text-white text-xs px-1.5 py-0.5 rounded-full",children:we})]}),t.jsxs("button",{type:"button",onClick:Be,disabled:Z,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 justify-center gap-2 disabled:opacity-50 w-full sm:w-auto",children:[t.jsx(Ui,{className:Z?"animate-spin":""}),e("listPages.refresh")]}),t.jsxs("button",{type:"button",onClick:()=>S(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center justify-center gap-2 shadow transition-all disabled:opacity-50 w-full sm:w-auto",disabled:Pe===0,children:[t.jsx(Ks,{}),t.jsx("span",{className:"font-medium",children:e("listPages.export")}),y.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:y.size})]}),t.jsxs("button",{type:"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 justify-center gap-2 shadow-lg transition-all hover:shadow-xl w-full sm:w-auto",children:[t.jsx(Js,{}),t.jsx("span",{className:"font-medium",children:e("maintenance.newMaintenanceTeam")})]})]})]}),ge&&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(Hs,{className:"text-white",size:16}),t.jsx("h3",{className:"text-white font-semibold text-sm",children:e("listPages.filters")}),we>0&&t.jsx("span",{className:"bg-white text-indigo-600 px-2 py-0.5 rounded-full text-xs font-bold",children:we})]}),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:[ae&&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(R==="creation"?"filters.createdDate":"filters.latestModifiedDate"),":"]})," ",[z,X].filter(Boolean).join(" – "),t.jsx("button",{onClick:()=>{F(""),W(""),B("")},className:"hover:text-red-500",children:t.jsx(Pt,{className:"text-[9px]"})})]}),Y&&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"),":"]})," ",Y,t.jsx("button",{onClick:()=>G(""),className:"hover:text-red-500",children:t.jsx(Pt,{className:"text-[9px]"})})]}),ie&&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"),":"]})," ",ie,t.jsx("button",{onClick:()=>fe(""),className:"hover:text-red-500",children:t.jsx(Pt,{className:"text-[9px]"})})]})]})}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[we>0&&t.jsxs("button",{onClick:()=>te(!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(bs,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:e("listPages.saveFilterPreset")})]}),et&&t.jsxs("button",{onClick:ct,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(Pt,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:e("listPages.clearFilters")})]})]})]})}),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(ul,{className:"text-yellow-500",size:12}),e("inspections.savedFilters")]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:ve.map(yt=>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:()=>ft(yt),className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:yt.name}),t.jsx("button",{onClick:()=>Lt(yt.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:t.jsx(la,{size:10})})]},yt.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:K,onChange:yt=>{ke(yt.target.value),c(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:R,onChange:yt=>{const St=yt.target.value;F(St),c(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")})]})]}),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:z,onChange:yt=>{const St=yt.target.value;W(St),X&&St>X&&B(St),c(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:X,onChange:yt=>{B(yt.target.value),c(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:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[t.jsxs("div",{className:"relative z-10 lg:z-[60]",children:[t.jsx(hr,{label:"Hospital",doctype:"Company",value:Y,onChange:yt=>{G(yt),c(1)},placeholder:"Select Hospital",disabled:!1,compact:!0,usePortal:!0}),Y&&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(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[59]",children:[t.jsx(hr,{label:e("maintenance.teamName"),doctype:"Asset Maintenance Team",value:ie,onChange:yt=>{fe(yt),c(1)},placeholder:e("maintenance.selectTeam"),disabled:!1,compact:!0,usePortal:!0}),ie&&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(Pt,{size:10})})]})]})]})]})]}),ye&&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:q,onChange:yt=>J(yt.target.value),onKeyDown:yt=>{yt.key==="Enter"&&(yt.preventDefault(),It())},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:()=>{te(!1),J("")},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:It,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(bs,{size:12}),e("listPages.saveFilter")]})]})]})}),t.jsx(PG,{isOpen:E,onClose:()=>S(!1),selectedCount:y.size,totalCount:Pe,pageCount:be.length,onExport:Dt,isExporting:A,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:[Z&&h&&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:Ve,className:"text-gray-500 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors",title:e(Xe?"listPages.deselectAllTitle":"listPages.selectAllTitle"),children:Xe?t.jsx(jn,{className:"text-indigo-600 dark:text-indigo-400",size:18}):Rt?t.jsxs("div",{className:"relative",children:[t.jsx(ys,{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(ys,{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:be.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(Sd,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("listPages.noMaintenanceTeamsFound")}),et?t.jsx("button",{onClick:ct,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")})]})})}):be.map(yt=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 cursor-pointer transition-colors ${y.has(yt.name)?"bg-indigo-50 dark:bg-indigo-900/20":""}`,onClick:()=>r(`/maintenance-teams/${yt.name}`),children:[t.jsx("td",{className:"px-4 py-3",onClick:St=>St.stopPropagation(),children:t.jsx("button",{onClick:()=>Je(yt.name),className:"text-gray-500 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors",children:y.has(yt.name)?t.jsx(jn,{className:"text-indigo-600 dark:text-indigo-400",size:18}):t.jsx(ys,{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:yt.maintenance_team_name}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:yt.name})]}),t.jsxs("td",{className:"px-4 py-3",children:[t.jsx("div",{className:"text-sm text-gray-900 dark:text-white",children:yt.maintenance_manager_name||"-"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:yt.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:yt.company||"-"})}),t.jsx("td",{className:"px-4 py-3",children:yt.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:yt.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:rt(yt.creation)})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-1",onClick:St=>St.stopPropagation(),children:[t.jsx("button",{onClick:()=>r(`/maintenance-teams/${yt.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(to,{})}),t.jsx("button",{onClick:()=>r(`/maintenance-teams/${yt.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(Ms,{})}),t.jsx("button",{onClick:()=>r(`/maintenance-teams/new?duplicate=${yt.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(tu,{})}),t.jsx("button",{onClick:()=>M(yt.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(la,{})})]})})]},yt.name))})]})}),t.jsx(ed,{currentPage:i,totalCount:Pe,pageSize:u,itemLabel:e("pagination.teams"),onPageChange:yt=>c(yt)})]}),O&&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(la,{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"),":"]})," ",O]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>M(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:()=>ar(O),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(la,{}),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; }
`})]})},BG=()=>{var ye;const{t:e}=Rr(),{teamName:r}=ml(),[a]=Sn(),s=Na(),n=r==="new",i=a.get("duplicate"),[c,u]=_.useState({maintenance_team_name:"",maintenance_manager:"",maintenance_manager_name:"",company:"",custom_expertise:"",maintenance_team_members:[]}),{team:h,loading:g,error:y,refetch:w}=IG(n?i||null:r||null),{createTeam:E,updateTeam:S,deleteTeam:A,getUserFullName:C,loading:O}=MG(),[M,R]=_.useState(n),[F,z]=_.useState(!1),[W,X]=_.useState(null),[B,Y]=_.useState(null),G=te=>me(null,null,function*(){if(!te)return{exists:!1};try{const q=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(!q.ok)return yield ie(te);const ae=(yield q.json()).message||[];for(const oe of ae)if(!(oe.name===r||oe.name===(h==null?void 0:h.name))&&oe["maintenance_team_members.team_member"]===te)return{exists:!0,teamName:oe.maintenance_team_name||oe.name};return yield ie(te)}catch(q){return console.error("Error checking member in other teams:",q),yield ie(te)}}),ie=te=>me(null,null,function*(){var q,J;try{const ae=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(!ae.ok)return{exists:!1};const le=(yield ae.json()).data||[];for(const be of le){if(be.name===r||be.name===(h==null?void 0:h.name))continue;const Z=yield fetch(`/api/resource/Asset Maintenance Team/${encodeURIComponent(be.name)}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"});if(!Z.ok)continue;const Le=yield Z.json();if((((q=Le.data)==null?void 0:q.maintenance_team_members)||[]).some(pe=>pe.team_member===te))return{exists:!0,teamName:((J=Le.data)==null?void 0:J.maintenance_team_name)||be.name}}return{exists:!1}}catch(ae){return console.error("Fallback check failed:",ae),{exists:!1}}});_.useEffect(()=>{var te;h&&(u({maintenance_team_name:n&&i?`${h.maintenance_team_name} (Copy)`:h.maintenance_team_name||"",maintenance_manager:h.maintenance_manager||"",maintenance_manager_name:h.maintenance_manager_name||"",company:h.company||"",custom_expertise:h.custom_expertise||"",maintenance_team_members:((te=h.maintenance_team_members)==null?void 0:te.map((q,J)=>Ke(Te({},q),{idx:J+1,name:n?void 0:q.name})))||[]}),n||R(!1))},[h,n,i]);const fe=te=>{const{name:q,value:J}=te.target;u(ae=>Ke(Te({},ae),{[q]:J}))},K=te=>me(null,null,function*(){if(u(q=>Ke(Te({},q),{maintenance_manager:te})),te){const q=yield C(te);u(J=>Ke(Te({},J),{maintenance_manager_name:q}))}else u(q=>Ke(Te({},q),{maintenance_manager_name:""}))}),ke=(te,q,J)=>me(null,null,function*(){var ae;if(q==="team_member"&&J){if((ae=c.maintenance_team_members)==null?void 0:ae.some((Pe,Be)=>Be!==te&&Pe.team_member===J)){Mt.error("This member is already added to this team!",{position:"top-right",autoClose:4e3,icon:t.jsx(Br,{})});return}Y(te),Mt.info("Checking member availability...",{position:"top-right",autoClose:2e3,icon:()=>t.jsx("span",{children:"🔍"})});const{exists:le,teamName:be}=yield G(J);if(Y(null),le){Mt.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:be})]})]}),{position:"top-right",autoClose:5e3,icon:t.jsx(Br,{})});return}const Z=yield C(J),Le=[...c.maintenance_team_members||[]];Le[te]=Ke(Te({},Le[te]),{team_member:J,full_name:Z}),u(Pe=>Ke(Te({},Pe),{maintenance_team_members:Le})),Mt.success("Member added successfully!",{position:"top-right",autoClose:2e3,icon:t.jsx(Tr,{})})}else{const oe=[...c.maintenance_team_members||[]];oe[te]=Ke(Te({},oe[te]),{[q]:J}),u(le=>Ke(Te({},le),{maintenance_team_members:oe}))}}),ge=()=>{var q;const te={team_member:"",full_name:"",maintenance_role:"",idx:(((q=c.maintenance_team_members)==null?void 0:q.length)||0)+1};u(J=>Ke(Te({},J),{maintenance_team_members:[...J.maintenance_team_members||[],te]}))},re=te=>{var J;const q=((J=c.maintenance_team_members)==null?void 0:J.filter((ae,oe)=>oe!==te))||[];q.forEach((ae,oe)=>{ae.idx=oe+1}),u(ae=>Ke(Te({},ae),{maintenance_team_members:q})),X(null)},we=()=>me(null,null,function*(){var te;if(!c.maintenance_team_name){Mt.error("Please enter a team name",{position:"top-right",autoClose:4e3,icon:t.jsx(Br,{})});return}try{const q=Ke(Te({},c),{maintenance_team_members:(te=c.maintenance_team_members)==null?void 0:te.map(J=>({team_member:J.team_member,full_name:J.full_name,maintenance_role:J.maintenance_role})).filter(J=>J.team_member)});if(n){const J=yield E(q);Mt.success("Maintenance Team created successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),s(`/maintenance-teams/${J.name}`)}else yield S(r,q),Mt.success("Maintenance Team updated successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),R(!1),w()}catch(q){const J=q instanceof Error?q.message:"Unknown error";Mt.error(`Failed to save: ${J}`,{position:"top-right",autoClose:6e3,icon:t.jsx(Br,{})})}}),ee=()=>me(null,null,function*(){try{yield A(r),Mt.success("Maintenance Team deleted successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),s(-1)}catch(te){const q=te instanceof Error?te.message:"Unknown error";Mt.error(`Failed to delete: ${q}`,{position:"top-right",autoClose:6e3,icon:t.jsx(Br,{})})}}),ve=_.useCallback(te=>!M,[M]),ce=te=>te?new Date(te).toLocaleString():"-";return g?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..."})]})}):y&&!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:y}),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(xc,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:Ll}),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(Kn,{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(Sd,{className:"text-indigo-500"}),n?"New Maintenance Team":(h==null?void 0:h.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":h==null?void 0:h.name})]})]}),t.jsxs("div",{className:"flex gap-3",children:[!n&&!M&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>R(!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(Ms,{}),e("common.edit")]}),t.jsxs("button",{onClick:()=>z(!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(la,{}),e("common.delete")]})]}),M&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{n?s(-1):(R(!1),w())},className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg",children:e("common.cancel")}),t.jsxs("button",{onClick:we,disabled:O,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(bs,{}),e(O?"common.saving":"common.save")]})]})]})]}),F&&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(Jr,{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:()=>z(!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:ee,disabled:O,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg disabled:opacity-50",children:e(O?"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(Sd,{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:c.maintenance_team_name,onChange:fe,disabled:ve("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(hr,{label:e("commonFields.hospital"),doctype:"Company",value:c.company||"",onChange:te=>u(Ke(Te({},c),{company:te})),disabled:ve("company"),placeholder:e("maintenance.selectHospital")})}),t.jsx("div",{children:t.jsx(hr,{label:e("maintenance.expertise"),doctype:"Issue Type",value:c.custom_expertise||"",onChange:te=>u(Ke(Te({},c),{custom_expertise:te})),disabled:ve("custom_expertise"),placeholder:e("maintenance.selectExpertise"),allowQuickCreate:!0})}),t.jsx("div",{children:t.jsx(hr,{label:e("maintenance.manager"),doctype:"User",value:c.maintenance_manager||"",onChange:K,disabled:ve("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:c.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(cT,{className:"text-green-500"}),"Team Members"]}),M&&t.jsxs("button",{onClick:ge,disabled:B!==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(Js,{size:12}),"Add Member"]})]}),c.maintenance_team_members&&c.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:"*"})]}),M&&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:c.maintenance_team_members.map((te,q)=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 ${B===q?"opacity-70":""}`,children:[t.jsx("td",{className:"px-3 py-2 text-sm text-gray-600 dark:text-gray-400",children:q+1}),t.jsx("td",{className:"px-3 py-2",children:M?t.jsxs("div",{className:"relative",children:[t.jsx(hr,{label:"",doctype:"User",value:te.team_member||"",onChange:J=>ke(q,"team_member",J),disabled:B!==null,placeholder:e("maintenance.selectUser"),compact:!0}),B===q&&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:te.team_member||"-"})}),t.jsx("td",{className:"px-3 py-2 text-sm text-gray-600 dark:text-gray-300",children:te.full_name||"-"}),t.jsx("td",{className:"px-3 py-2",children:M?t.jsx(hr,{label:"",doctype:"Role",value:te.maintenance_role||"",onChange:J=>ke(q,"maintenance_role",J),disabled:B!==null,placeholder:e("maintenance.selectRole"),compact:!0}):t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:te.maintenance_role||"-"})}),M&&t.jsx("td",{className:"px-3 py-2 text-center",children:t.jsx("button",{onClick:()=>X(q),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(la,{size:14})})})]},q))})]})}):t.jsxs("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:[t.jsx(Sd,{className:"text-4xl mx-auto mb-2 text-gray-300 dark:text-gray-600"}),t.jsx("p",{children:e("maintenance.noTeamMembersYet")}),M&&t.jsxs("button",{onClick:ge,className:"mt-3 text-indigo-600 dark:text-indigo-400 hover:underline",children:["+ ",e("maintenance.addFirstMember")]})]})]}),!n&&t.jsx(Kd,{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(uT,{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:((ye=c.maintenance_team_members)==null?void 0:ye.filter(te=>te.team_member).length)||0})]}),c.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:c.maintenance_manager_name})]}),c.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:c.company})]}),c.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:c.custom_expertise})]})]})]}),!n&&h&&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(ly,{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:ce(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:ce(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||"-"})]})]})]})]})]}),W!==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(Jr,{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:()=>X(null),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",children:"Cancel"}),t.jsx("button",{onClick:()=>re(W),className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg",children:"Remove"})]})]})})]})};class UG{constructor(){Ii(this,"baseURL");this.baseURL=Or.BASE_URL}getCSRFToken(){return me(this,null,function*(){try{return typeof window!="undefined"&&window.csrf_token?window.csrf_token:null}catch(r){return null}})}getHeaders(){return me(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 me(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:c="creation desc"}=r,u=new URLSearchParams;if(u.append("fields",JSON.stringify(s)),u.append("limit_start",n.toString()),u.append("limit_page_length",i.toString()),u.append("order_by",c),Object.keys(a).length>0){const y=Ln(a);y.length>0&&u.append("filters",JSON.stringify(y))}const h=yield fetch(`${this.baseURL}/api/resource/Inspection?${u.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);return{data:(yield h.json()).data||[]}})}getInspection(r){return me(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 me(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 me(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 me(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 me(this,arguments,function*(r={}){var i,c;const a=new URLSearchParams;if(a.append("fields",JSON.stringify(["count(name) as count"])),Object.keys(r).length>0){const u=Ln(r);u.length>0&&a.append("filters",JSON.stringify(u))}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((c=(i=(yield s.json()).data)==null?void 0:i[0])==null?void 0:c.count)||0})}getCurrentUser(){return me(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 Rd=new UG;function zG(e={}){const[r,a]=_.useState([]),[s,n]=_.useState(!0),[i,c]=_.useState(null),[u,h]=_.useState(0),g=_.useCallback(()=>me(null,null,function*(){try{n(!0),c(null);const[y,w]=yield Promise.all([Rd.getInspections(e),Rd.getInspectionCount(e.filters||{})]);a(y.data),h(w)}catch(y){const w=y instanceof Error?y.message:"Failed to fetch inspections";c(w),console.error("Error fetching inspections:",y)}finally{n(!1)}}),[JSON.stringify(e)]);return _.useEffect(()=>{g()},[g]),{inspections:r,loading:s,error:i,totalCount:u,refetch:g}}function WG(e){const[r,a]=_.useState(null),[s,n]=_.useState(!0),[i,c]=_.useState(null),u=_.useCallback(()=>me(null,null,function*(){if(!e){n(!1);return}try{n(!0),c(null);const h=yield Rd.getInspection(e);a(h)}catch(h){const g=h instanceof Error?h.message:"Failed to fetch inspection";c(g),console.error("Error fetching inspection:",h)}finally{n(!1)}}),[e]);return _.useEffect(()=>{u()},[u]),{inspection:r,loading:s,error:i,refetch:u}}function HG(){const[e,r]=_.useState(!1),[a,s]=_.useState(null);return{createInspection:u=>me(null,null,function*(){try{return r(!0),s(null),yield Rd.createInspection(u)}catch(h){const g=h instanceof Error?h.message:"Failed to create inspection";throw s(g),h}finally{r(!1)}}),updateInspection:(u,h)=>me(null,null,function*(){try{return r(!0),s(null),yield Rd.updateInspection(u,h)}catch(g){const y=g instanceof Error?g.message:"Failed to update inspection";throw s(y),g}finally{r(!1)}}),deleteInspection:u=>me(null,null,function*(){try{r(!0),s(null),yield Rd.deleteInspection(u)}catch(h){const g=h instanceof Error?h.message:"Failed to delete inspection";throw s(g),h}finally{r(!1)}}),loading:e,error:a}}const $G=({isOpen:e,onClose:r,permittedIssueTypes:a=[],isAdmin:s=!0})=>{const{t:n}=Rr(),[i,c]=_.useState(!1),[u,h]=_.useState(null),[g,y]=_.useState([]),[w,E]=_.useState([]),[S,A]=_.useState(!0),[C,O]=_.useState(!1),[M,R]=_.useState([]),[F,z]=_.useState(""),[W,X]=_.useState(""),[B,Y]=_.useState(""),G="Inspection";_.useEffect(()=>{if(!s)return;me(null,null,function*(){try{const Le=yield(yield fetch('/api/resource/Issue Type?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"})).json();Le.data&&R(Le.data.map(Pe=>Pe.name))}catch(Z){console.error(Z)}})},[s]),_.useEffect(()=>{!s&&a.length===1?Y(a[0]):Y("")},[a,s]);const ie=_.useCallback(()=>me(null,null,function*(){var be;c(!0),h(null);try{const Z={};F&&(Z.status=F),W&&(Z.only_late=W),B?Z.work_order_type=B:!s&&a.length===1&&(Z.work_order_type=a[0]);const Pe=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:Z,ignore_prepared_report:1})})).json();if(Pe.exc)throw new Error(Pe.exc);if(Pe.message)if(((be=Pe.message.columns)==null?void 0:be.length)>0&&E(Pe.message.columns),Pe.message.result){let Be=Pe.message.result;!s&&a.length>1&&!B&&(Be=Be.filter(pe=>a.includes(pe.work_order_type))),y(Be)}else y([])}catch(Z){console.error("Error fetching report:",Z),h(Z instanceof Error?Z.message:"Failed to fetch report data"),y([])}finally{c(!1)}}),[F,W,B,s,a]);_.useEffect(()=>{e&&ie()},[e,ie]),_.useEffect(()=>{const be=Z=>{Z.key==="Escape"&&e&&r()};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[e,r]),_.useEffect(()=>(document.body.style.overflow=e?"hidden":"unset",()=>{document.body.style.overflow="unset"}),[e]);const fe=()=>{z(""),X(""),(s||a.length!==1)&&Y("")},K=()=>g.filter(be=>be.status!=="TOTAL"),ke=()=>g.find(be=>be.status==="TOTAL"),ge=be=>{switch(be==null?void 0:be.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"}},re=be=>be==="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",we=(be,Z)=>{if(be==null||be==="")return"-";switch(Z.fieldtype){case"Date":return new Date(be).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});case"Datetime":return new Date(be).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});default:return String(be)}},ee=()=>{const be=K();if(be.length){O(!0);try{const Z=[w.map(pe=>pe.label).join(","),...be.map(pe=>w.map(rt=>{let ct=pe[rt.fieldname]||"";return typeof ct=="string"&&(ct.includes(",")||ct.includes('"')||ct.includes(`
`))&&(ct=`"${ct.replace(/"/g,'""')}"`),ct}).join(","))].join(`
`),Le=new Blob(["\uFEFF"+Z],{type:"text/csv;charset=utf-8;"}),Pe=URL.createObjectURL(Le),Be=document.createElement("a");Be.href=Pe,Be.download=`inspection_report_${new Date().toISOString().split("T")[0]}.csv`,Be.click(),URL.revokeObjectURL(Pe)}finally{O(!1)}}},ve=()=>{const be=K();if(be.length){O(!0);try{const Z=Ur.aoa_to_sheet([w.map(Pe=>Pe.label),...be.map(Pe=>w.map(Be=>Pe[Be.fieldname]||""))]);Z["!cols"]=w.map(Pe=>({wch:Pe.width?Math.floor(Pe.width/7):15}));const Le=Ur.book_new();Ur.book_append_sheet(Le,Z,"Inspection Report"),jo(Le,`inspection_report_${new Date().toISOString().split("T")[0]}.xlsx`)}finally{O(!1)}}},ce=()=>{const be=K(),Z=ke(),Le=window.open("","_blank");if(!Le){alert("Please allow popups to print.");return}Le.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: ${be.length}
${F?` | Status: ${F}`:""}
${B?` | Dept: ${B}`:""}
${W==="Yes"?" | Only Late":""}
</div>
${Z?`
<div class="summary">
<div class="summary-item"><div class="summary-label">Total Inspections</div><div class="summary-value">${Z.inspection||0}</div></div>
<div class="summary-item"><div class="summary-label">WO Created</div><div class="summary-value">${Z.wo_created||0}</div></div>
<div class="summary-item"><div class="summary-label">Not Closed On Time</div><div class="summary-value late">${Z.not_closed_on_time||0}</div></div>
</div>`:""}
<table>
<thead><tr><th>#</th>${w.map(Pe=>`<th>${Pe.label}</th>`).join("")}</tr></thead>
<tbody>
${be.map((Pe,Be)=>`
<tr><td>${Be+1}</td>${w.map(pe=>{let rt=Pe[pe.fieldname]||"-",ct="";return pe.fieldname==="status"&&(String(rt).toLowerCase()==="open"?ct="status-open":String(rt).toLowerCase()==="closed"?ct="status-closed":String(rt).toLowerCase().includes("progress")&&(ct="status-inprogress")),pe.fieldname==="not_closed_on_time"&&(ct=rt==="Yes"?"late-yes":"late-no"),`<td class="${ct}">${rt}</td>`}).join("")}</tr>
`).join("")}
</tbody>
</table>
<script>window.onload=function(){window.print()}<\/script>
</body></html>`),Le.document.close()},ye=()=>ce();if(!e)return null;const te=K(),q=ke(),J=!!(F||W||B),ae=[F,W,B].filter(Boolean).length,oe=s?M:a,le=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(Kn,{size:18})}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Wo,{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:[te.length," record",te.length!==1?"s":""," found",B&&t.jsx("span",{className:"ml-2 bg-white/20 px-2 py-0.5 rounded-full text-xs",children:B})]})]})]})]}),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(Pt,{size:20})})]})}),q&&!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:q.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:q.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(Jr,{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:q.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:()=>A(!S),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(Hs,{size:12}),"Filters",J&&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:ae}),S?t.jsx(Mn,{size:10}):t.jsx(on,{size:10})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:ie,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(Ui,{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:ee,disabled:!te.length||C,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(No,{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:ve,disabled:!te.length||C,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(zi,{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:ye,disabled:!te.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(Hf,{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:ce,disabled:!te.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(Go,{className:"text-purple-600",size:14}),t.jsx("span",{children:"Print"})]})]})]})]}),S&&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:F,onChange:be=>z(be.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:W,onChange:be=>X(be.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)"})]})]}),le&&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"}),B,t.jsx("span",{className:"ml-auto text-[10px] text-gray-400 dark:text-gray-500 uppercase tracking-wide",children:"Restricted"})]}):t.jsxs("select",{value:B,onChange:be=>Y(be.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"}),oe.map(be=>t.jsx("option",{value:be,children:be},be))]})]}),t.jsx("div",{className:"flex items-end",children:t.jsxs("button",{onClick:fe,disabled:!J,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(Pt,{size:12}),"Clear Filters"]})})]}),J&&t.jsxs("div",{className:"flex flex-wrap gap-2 mt-3",children:[F&&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: ",F]}),W&&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"}),B&&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: ",B]})]})]})]}),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(Ir,{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..."})]})}),u&&!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:u}),t.jsx("button",{onClick:ie,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&&!u&&te.length===0&&t.jsxs("div",{className:"text-center py-20",children:[t.jsx(In,{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&&!u&&te.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:"#"}),w.map((be,Z)=>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:be.width||120},children:be.label},Z))]})}),t.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:te.map((be,Z)=>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:Z+1}),w.map((Le,Pe)=>{const Be=be[Le.fieldname],pe=we(Be,Le);return Le.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 ${ge(Be)}`,children:pe})},Pe):Le.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:pe})},Pe):Le.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 ${re(Be)}`,children:pe})},Pe):Le.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:pe})},Pe):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:pe})},Pe)})]},Z))})]})})})]}),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 ",te.length," record",te.length!==1?"s":"",J&&" (filtered)",B&&t.jsxs("span",{className:"ml-2 text-teal-600 dark:text-teal-400",children:["· ",B]})]}),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"})]})})]})},VG=({isOpen:e,onClose:r,selectedCount:a,totalCount:s,pageCount:n,onExport:i,isExporting:c,exportColumns:u})=>{const{t:h}=Rr(),[g,y]=_.useState(a>0?"selected":"all_with_filters"),[w,E]=_.useState("csv"),[S,A]=_.useState(u.filter(R=>R.default).map(R=>R.key));_.useEffect(()=>{a>0?y("selected"):y("all_with_filters")},[a]);const C=R=>{A(F=>F.includes(R)?F.filter(z=>z!==R):[...F,R])},O=()=>A(u.map(R=>R.key)),M=()=>A(u.filter(R=>R.default).map(R=>R.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(Ks,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:h("inspections.export.title")})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:c,children:t.jsx(Pt,{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:h("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 ${g==="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:g==="selected",onChange:()=>y("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:h("inspections.export.selectedRows")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("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 ${g==="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:g==="all_on_page",onChange:()=>y("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:h("inspections.export.currentPage")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("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 ${g==="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:g==="all_with_filters",onChange:()=>y("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:h("inspections.export.allWithFilters")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("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:h("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 ${w==="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:w==="csv",onChange:()=>E("csv"),className:"text-teal-600 focus:ring-teal-500"}),t.jsx(No,{className:"text-teal-600 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("inspections.export.csv")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("inspections.export.csvDesc")})]})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${w==="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:w==="excel",onChange:()=>E("excel"),className:"text-teal-600 focus:ring-teal-500"}),t.jsx(zi,{className:"text-green-700 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("inspections.export.excel")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("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:h("inspections.export.columnsToExport")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:O,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("inspections.export.selectAll")}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{onClick:M,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("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:u.map(R=>t.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${S.includes(R.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:S.includes(R.key),onChange:()=>C(R.key),className:"rounded text-teal-600 focus:ring-teal-500"}),t.jsx("span",{className:"text-sm truncate",children:h(R.labelKey)})]},R.key))}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:h("inspections.export.columnsSelected",{count:S.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:[g==="selected"&&h("inspections.export.exportingSelected",{count:a}),g==="all_on_page"&&h("inspections.export.exportingPage",{count:n}),g==="all_with_filters"&&h("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:c,children:h("common.cancel")}),t.jsx("button",{onClick:()=>i(g,w,S),disabled:S.length===0||c,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:c?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),h("inspections.export.exporting")]}):t.jsxs(t.Fragment,{children:[t.jsx(Vo,{}),h("inspections.export.exportButton")]})})]})]})]})}):null},GG=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"}},YG=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"}},qG=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"}},XG=()=>{const{t:e}=Rr(),r=Na(),[a,s]=Sn(),[n,i]=_.useState([]),[c,u]=_.useState(!0),h=_.useMemo(()=>{const He=parseInt(a.get("page")||"1",10);return Number.isNaN(He)||He<1?1:He},[a]),g=_.useCallback(He=>{const Fe=typeof He=="function"?He(h):He;s(Ze=>{const vt=new URLSearchParams(Ze);return vt.set("page",String(Fe)),vt})},[h,s]),y=[{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}],[w]=_.useState(20),[E,S]=_.useState(!1),[A,C]=_.useState(new Set),[O,M]=_.useState(!1),[R,F]=_.useState(!1),[z,W]=_.useState(null),[X,B]=_.useState(!1),Y=["System Manager","Contractor Supervisor","Contractor Manager","Work Control"],[G,ie]=_.useState(!1),[fe,K]=_.useState(!1),[ke,ge]=_.useState([]),[re,we]=_.useState(!1);_.useEffect(()=>{me(null,null,function*(){var Fe,Ze,vt;try{const fr=yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:Y.join(",")})})).json();if(fr.message){const he=fr.message.has_role;ie(he),K(he)}const Re=yield(yield fetch("/api/method/asset_lite.api.user_roles.get_user_roles",{credentials:"include"})).json(),Q=Array.isArray(Re.message)?Re.message:[];ge(Q),we(Q.includes("System Manager"));try{const ne=(yield(yield fetch("/api/method/asset_lite.api.userperm_api.get_permission_filters?target_doctype=Work_Order",{credentials:"include"})).json()).message||{};u((Fe=ne.is_admin)!=null?Fe:!0),i(((vt=(Ze=ne.restrictions)==null?void 0:Ze["Issue Type"])==null?void 0:vt.values)||[])}catch(he){console.error("Error fetching issue type permissions:",he),u(!0),i([])}}catch(ir){console.error("Error checking permissions:",ir),ie(!1),K(!1)}})},[]);const[ee,ve]=_.useState(()=>a.get("date_filter_by")||""),[ce,ye]=_.useState(()=>a.get("date_start")||""),[te,q]=_.useState(()=>a.get("date_end")||""),[J,ae]=_.useState(()=>a.get("status")||""),[oe,le]=_.useState(()=>a.get("workflow_state")||""),[be,Z]=_.useState(()=>a.get("inspection_type")||""),[Le,Pe]=_.useState(()=>a.get("work_order")||""),[Be,pe]=_.useState(()=>a.get("department")||""),[rt,ct]=_.useState(()=>a.get("sort_by")||"creation desc"),[et,It]=_.useState(!1),[ft,Lt]=_.useState(0),[Je,Ve]=_.useState([]),[Xe,Rt]=_.useState(!1),[qe,Dt]=_.useState("");_.useEffect(()=>{const He=localStorage.getItem("inspectionFilterPresets");He&&Ve(JSON.parse(He))},[]);const ar=ee&&(ce||te);_.useEffect(()=>{const He=[J,oe,be,Le,Be].filter(Boolean).length+(ar?1:0);Lt(He)},[J,oe,be,Le,Be,ar]);const yt=_.useMemo(()=>{const He={};return J&&(He.status=J),oe&&(He.workflow_state=oe),be&&(He.inspection_type=be),Le&&(He.linked_corrective_wo_no=Le),Be&&(He.work_order_type=Be),Object.assign(He,td(ee,ce,te)),He.custom_delete_status=["!=","Deleted"],He},[J,oe,be,Le,Be,ee,ce,te]),St=["creation desc","creation asc","modified desc","modified asc","name asc","name desc"].includes(rt)?rt:"creation desc",{inspections:Ot,loading:Yt,error:Ye,totalCount:wt,refetch:zt}=zG({filters:yt,limit_start:(h-1)*w,limit_page_length:w,order_by:St});_.useEffect(()=>{!Yt&&!E&&S(!0)},[Yt,E]);const qt=_.useRef(!1);_.useEffect(()=>{if(!qt.current){qt.current=!0;return}s(He=>{const Fe=new URLSearchParams(He);return ee?Fe.set("date_filter_by",ee):Fe.delete("date_filter_by"),ce?Fe.set("date_start",ce):Fe.delete("date_start"),te?Fe.set("date_end",te):Fe.delete("date_end"),J?Fe.set("status",J):Fe.delete("status"),oe?Fe.set("workflow_state",oe):Fe.delete("workflow_state"),be?Fe.set("inspection_type",be):Fe.delete("inspection_type"),Le?Fe.set("work_order",Le):Fe.delete("work_order"),Be?Fe.set("department",Be):Fe.delete("department"),rt&&rt!=="creation desc"?Fe.set("sort_by",rt):Fe.delete("sort_by"),Fe.set("page","1"),Fe})},[ee,ce,te,J,oe,be,Le,Be,rt]),_.useEffect(()=>{C(new Set)},[ee,ce,te,J,oe,be,Le,Be,h]);const kt=He=>{switch(He){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""}},ze=He=>He?new Date(He).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-",nt=()=>{ve(""),ye(""),q(""),ct("creation desc"),ae(""),le(""),Z(""),Pe(""),pe(""),s(He=>{const Fe=new URLSearchParams(He);return Fe.delete("date_filter_by"),Fe.delete("date_start"),Fe.delete("date_end"),Fe.delete("sort_by"),Fe.delete("status"),Fe.delete("workflow_state"),Fe.delete("inspection_type"),Fe.delete("work_order"),Fe.delete("department"),Fe.set("page","1"),Fe})},_t=ar||!!J||!!oe||!!be||!!Le||!!Be,lr=()=>{if(!qe.trim()){alert(e("common.enterFilterName"));return}const He={id:Date.now(),name:qe,filters:{dateFilterBy:ee,dateStart:ce,dateEnd:te,sortBy:rt,statusFilter:J,workflowStateFilter:oe,inspectionTypeFilter:be,workOrderFilter:Le,departmentFilter:Be}},Fe=[...Je,He];Ve(Fe),Dt(""),Rt(!1),localStorage.setItem("inspectionFilterPresets",JSON.stringify(Fe))},pr=He=>{const Fe=He.filters;ve(Fe.dateFilterBy||""),ye(Fe.dateStart||""),q(Fe.dateEnd||""),ct(Fe.sortBy||"creation desc"),ae(Fe.statusFilter||""),le(Fe.workflowStateFilter||""),Z(Fe.inspectionTypeFilter||""),Pe(Fe.workOrderFilter||""),pe(Fe.departmentFilter||"")},Nr=He=>{const Fe=Je.filter(Ze=>Ze.id!==He);Ve(Fe),localStorage.setItem("inspectionFilterPresets",JSON.stringify(Fe))},rr=He=>{C(Fe=>{const Ze=new Set(Fe);return Ze.has(He)?Ze.delete(He):Ze.add(He),Ze})},_r=()=>{A.size===Ot.length?C(new Set):C(new Set(Ot.map(He=>He.name)))},Nt=Ot.length>0&&A.size===Ot.length,Cr=A.size>0&&A.size<Ot.length,yr=_.useCallback(()=>me(null,null,function*(){const He=[];let Fe=0;const Ze=100;let vt=!0;const ir=Ln(yt);for(;vt;)try{const Re=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Inspection",filters:ir.length>0?ir:{},fields:["*"],limit_start:Fe*Ze,limit_page_length:Ze,order_by:St})})).json()).message||[];He.push(...Re),Re.length<Ze?vt=!1:Fe++,Fe>100&&(console.warn("Export safety limit reached"),vt=!1)}catch(fr){throw console.error("Error fetching inspections for export:",fr),fr}return He}),[yt,St]),jt=(He,Fe,Ze)=>me(null,null,function*(){F(!0);try{let vt=[];switch(He){case"selected":vt=Ot.filter(fr=>A.has(fr.name));break;case"all_on_page":vt=Ot;break;case"all_with_filters":vt=yield yr();break}if(vt.length===0){alert(e("assets.noDataToExport"));return}const ir=Ze.map(fr=>{var Kt;return e(((Kt=y.find(Re=>Re.key===fr))==null?void 0:Kt.labelKey)||fr)});if(Fe==="csv"){const fr=[ir.join(","),...vt.map(he=>Ze.map(Se=>{let ne=he[Se]||"";return typeof ne=="string"&&(ne.includes(",")||ne.includes('"')||ne.includes(`
`))&&(ne=`"${ne.replace(/"/g,'""')}"`),ne}).join(","))].join(`
`),Kt=new Blob(["\uFEFF"+fr],{type:"text/csv;charset=utf-8;"}),Re=URL.createObjectURL(Kt),Q=document.createElement("a");Q.href=Re,Q.download=`inspections_export_${new Date().toISOString().split("T")[0]}.csv`,Q.click(),URL.revokeObjectURL(Re)}else if(Fe==="excel"){const fr=[ir,...vt.map(Q=>Ze.map(he=>Q[he]||""))],Kt=Ur.aoa_to_sheet(fr),Re=Ur.book_new();Ur.book_append_sheet(Re,Kt,"Inspections"),jo(Re,`inspections_export_${new Date().toISOString().split("T")[0]}.xlsx`)}M(!1),C(new Set)}catch(vt){console.error("Export failed:",vt),alert(`Export failed: ${vt instanceof Error?vt.message:"Unknown error"}`)}finally{F(!1)}}),Tt=He=>me(null,null,function*(){try{if(!(yield fetch(`/api/resource/Inspection/${He}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to delete");W(null),zt(),alert(e("inspections.deletedSuccessfully"))}catch(Fe){alert(`Failed to delete: ${Fe instanceof Error?Fe.message:"Unknown error"}`)}});return Yt&&!E?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")})]})}):Ye?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:Ye}),t.jsx("button",{onClick:zt,className:"bg-teal-600 hover:bg-teal-700 text-white px-4 py-2 rounded",children:e("common.tryAgain")})]})}):t.jsxs("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen w-full min-w-0 overflow-x-hidden",children:[t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center w-full min-w-0",children:[t.jsx("div",{className:"min-w-0",children:t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(Wo,{className:"text-3xl text-teal-600 dark:text-teal-400"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-gray-800 dark:text-white break-words",children:e("inspections.title")}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[e("common.total"),": ",wt,A.size>0&&t.jsxs("span",{className:"ml-2 text-teal-600 dark:text-teal-400",children:["• ",A.size," selected"]}),Yt&&E&&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:"grid grid-cols-2 gap-2 w-full sm:flex sm:flex-row sm:flex-wrap sm:justify-end sm:gap-3 sm:w-auto min-w-0 shrink-0",children:[t.jsxs("button",{type:"button",onClick:()=>It(!et),className:`px-4 py-2 rounded-lg h-10 flex items-center justify-center gap-2 transition-colors w-full sm:w-auto ${et||_t?"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(Hs,{}),e("listPages.filters"),ft>0&&t.jsx("span",{className:"bg-teal-600 text-white text-xs px-1.5 py-0.5 rounded-full",children:ft})]}),t.jsxs("button",{type:"button",onClick:zt,disabled:Yt,className:"px-4 py-2 rounded-lg h-10 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 justify-center gap-2 disabled:opacity-50 w-full sm:w-auto",children:[t.jsx(Ui,{className:Yt?"animate-spin":""}),e("listPages.refresh")]}),t.jsxs("button",{type:"button",onClick:()=>B(!0),className:"bg-cyan-600 hover:bg-cyan-700 text-white px-4 py-2 rounded-lg h-10 flex items-center justify-center gap-2 shadow transition-all col-span-2 sm:col-span-1 w-full sm:w-auto",children:[t.jsx(Wo,{}),t.jsx("span",{className:"font-medium",children:e("inspections.inspectionReport")})]}),t.jsxs("button",{type:"button",onClick:()=>M(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg h-10 flex items-center justify-center gap-2 shadow transition-all disabled:opacity-50 col-span-2 sm:col-span-1 w-full sm:w-auto",disabled:wt===0,children:[t.jsx(Ks,{}),t.jsx("span",{className:"font-medium",children:e("common.export")}),A.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:A.size})]}),fe&&t.jsxs("button",{type:"button",onClick:()=>r("/inspections/new"),className:"bg-teal-600 hover:bg-teal-700 text-white px-4 py-2 rounded-lg h-10 flex items-center justify-center gap-2 shadow-lg transition-all hover:shadow-xl col-span-2 w-full sm:w-auto",children:[t.jsx(Js,{}),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:wt})]}),t.jsx(Wo,{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:Ot.filter(He=>He.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:Ot.filter(He=>He.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:Ot.filter(He=>He.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"})})]})})]}),et&&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(Hs,{className:"text-white",size:16}),t.jsx("h3",{className:"text-white font-semibold text-sm",children:e("listPages.filters")}),ft>0&&t.jsx("span",{className:"bg-white text-teal-600 px-2 py-0.5 rounded-full text-xs font-bold",children:ft})]}),_t&&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:[J&&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.${(J||"").toLowerCase().replace(/\s+/g,"_")}`,{defaultValue:J}),t.jsx("button",{onClick:()=>ae(""),className:"hover:text-red-500",children:t.jsx(Pt,{className:"text-[9px]"})})]}),oe&&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.${(oe||"").toLowerCase().replace(/\s+/g,"_")}`,{defaultValue:oe}),t.jsx("button",{onClick:()=>le(""),className:"hover:text-red-500",children:t.jsx(Pt,{className:"text-[9px]"})})]}),be&&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.${(be||"").toLowerCase().replace(/\s+/g,"_")}`,{defaultValue:be}),t.jsx("button",{onClick:()=>Z(""),className:"hover:text-red-500",children:t.jsx(Pt,{className:"text-[9px]"})})]}),Le&&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"),":"]})," ",Le,t.jsx("button",{onClick:()=>Pe(""),className:"hover:text-red-500",children:t.jsx(Pt,{className:"text-[9px]"})})]}),Be&&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"),":"]})," ",Be,t.jsx("button",{onClick:()=>pe(""),className:"hover:text-red-500",children:t.jsx(Pt,{className:"text-[9px]"})})]}),ar&&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(ee==="creation"?"filters.createdDate":"filters.latestModifiedDate")," ",ce&&` ${ce}`," ",te&&` - ${te}`,t.jsx("button",{onClick:()=>{ve(""),ye(""),q("")},className:"hover:text-red-500",children:t.jsx(Pt,{className:"text-[9px]"})})]})]})}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[ft>0&&t.jsxs("button",{onClick:()=>Rt(!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(bs,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:e("common.save")})]}),_t&&t.jsxs("button",{onClick:nt,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(Pt,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:e("common.clearFilters")})]})]})]})}),t.jsxs("div",{className:"p-4",children:[Je.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(ul,{className:"text-yellow-500",size:12}),e("inspections.savedFilters")]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:Je.map(He=>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:()=>pr(He),className:"text-xs font-medium text-teal-700 dark:text-teal-300",children:He.name}),t.jsx("button",{onClick:()=>Nr(He.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:t.jsx(la,{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-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:rt,onChange:He=>{ct(He.target.value),g(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:ee,onChange:He=>{const Fe=He.target.value;ve(Fe),g(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")})]})]}),ee&&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:ce,onChange:He=>{const Fe=He.target.value;ye(Fe),te&&Fe>te&&q(Fe),g(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:te,onChange:He=>{q(He.target.value),g(1)},min:ce||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:J,onChange:He=>{ae(He.target.value),g(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:oe,onChange:He=>{le(He.target.value),g(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:be,onChange:He=>{Z(He.target.value),g(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-10 lg:z-[60]",children:[t.jsx(hr,{label:e("inspections.filterWorkOrder"),doctype:"Work_Order",value:Le,onChange:He=>{Pe(He),g(1)},placeholder:e("inspections.selectWorkOrder"),disabled:!1,compact:!0,filters:{custom_delete_status:["!=","Deleted"]}}),Le&&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(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[59]",children:[t.jsx(hr,{label:e("inspections.technicalDepartment"),doctype:"Issue Type",value:Be,onChange:He=>{pe(He),g(1)},placeholder:e("inspections.selectDepartment"),disabled:!1,compact:!0}),Be&&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(Pt,{size:10})})]})]})})]})]}),Xe&&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:qe,onChange:He=>Dt(He.target.value),onKeyDown:He=>{He.key==="Enter"&&(He.preventDefault(),lr())},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:()=>{Rt(!1),Dt("")},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:lr,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(bs,{size:12}),e("common.saveFilter")]})]})]})}),t.jsx(VG,{isOpen:O,onClose:()=>M(!1),selectedCount:A.size,totalCount:wt,pageCount:Ot.length,onExport:jt,isExporting:R,exportColumns:y}),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:[Yt&&E&&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:_r,className:"text-gray-500 dark:text-gray-400 hover:text-teal-600 dark:hover:text-teal-400 transition-colors",title:e(Nt?"common.deselectAllTitle":"common.selectAllTitle"),children:Nt?t.jsx(jn,{className:"text-teal-600 dark:text-teal-400",size:18}):Cr?t.jsxs("div",{className:"relative",children:[t.jsx(ys,{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(ys,{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:Ot.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(Wo,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("inspections.noInspectionsFound")}),_t?t.jsx("button",{onClick:nt,className:"mt-4 text-teal-600 dark:text-teal-400 hover:underline",children:e("common.clearFilters")}):fe?t.jsx("button",{onClick:()=>r("/inspections/new"),className:"mt-4 text-teal-600 dark:text-teal-400 hover:underline",children:e("inspections.createFirstInspection")}):null]})})}):Ot.map(He=>{var Fe;return t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 cursor-pointer transition-colors ${A.has(He.name)?"bg-teal-50 dark:bg-teal-900/20":kt(He.custom_delete_status)}`,title:He.custom_delete_status?`Delete Status: ${He.custom_delete_status}`:void 0,onClick:()=>r(`/inspections/${He.name}`),children:[t.jsx("td",{className:"px-4 py-3",onClick:Ze=>Ze.stopPropagation(),children:t.jsx("button",{onClick:()=>rr(He.name),className:"text-gray-500 dark:text-gray-400 hover:text-teal-600 dark:hover:text-teal-400 transition-colors",children:A.has(He.name)?t.jsx(jn,{className:"text-teal-600 dark:text-teal-400",size:18}):t.jsx(ys,{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:He.name})}),t.jsx("td",{className:"px-4 py-3",children:He.inspection_type?t.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${qG(He.inspection_type)}`,children:e(`inspections.typeMap.${(He.inspection_type||"").toLowerCase().replace(/\s+/g,"_")}`,{defaultValue:He.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 ${GG(He.status)}`,children:He.status?e(`inspections.status.${(He.status||"").toLowerCase().replace(/\s+/g,"_")}`,{defaultValue:He.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 ${YG(He.workflow_state)}`,children:He.workflow_state?e(`inspections.workflowState.${(He.workflow_state||"").toLowerCase().replace(/\s+/g,"_")}`,{defaultValue:He.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:ze(He.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:He.requested_by||"-"})}),t.jsx("td",{className:"px-4 py-3",onClick:Ze=>Ze.stopPropagation(),children:He.linked_corrective_wo_no?t.jsxs("button",{onClick:()=>r(`/work-orders/${He.linked_corrective_wo_no}`),className:"text-sm text-blue-600 dark:text-blue-400 hover:underline flex items-center gap-1",children:[He.linked_corrective_wo_no,t.jsx(ps,{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:Ze=>Ze.stopPropagation(),children:[t.jsx("button",{onClick:()=>r(`/inspections/${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("inspections.viewDetails"),children:t.jsx(to,{})}),t.jsx("button",{onClick:()=>r(`/inspections/${He.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(Ms,{})}),t.jsx("div",{onClick:Ze=>Ze.stopPropagation(),children:t.jsx(rd,{doctype:"Inspection",docname:He.name,currentDeleteStatus:(Fe=He.custom_delete_status)!=null?Fe:null,userRoles:ke,isSystemManager:re,triggerMode:!0,redirectOnDelete:"/inspections",onStatusChange:()=>zt()})})]})})]},He.name)})})]})}),t.jsx(ed,{currentPage:h,totalCount:wt,pageSize:w,itemLabel:e("pagination.inspections"),onPageChange:He=>g(He)})]}),z&&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(la,{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"),":"]})," ",z]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>W(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:()=>Tt(z),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(la,{}),e("common.delete")]})]})]})]})})}),t.jsx($G,{isOpen:X,onClose:()=>B(!1),permittedIssueTypes:n,isAdmin:c}),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; }
`})]})},tf=()=>new Date().toISOString().split("T")[0],ZG=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"}}},KG=()=>{var yr;const{t:e}=Rr(),{inspectionName:r}=ml(),[a]=Sn(),s=Na(),n=r==="new",i=a.get("edit")==="true",c=["System Manager","Contractor Supervisor","Contractor Manager"],[u,h]=_.useState(!1);_.useEffect(()=>{me(null,null,function*(){try{const He=yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:c.join(",")})})).json();He.message&&h(He.message.has_role)}catch(Tt){console.error("Error checking permissions:",Tt),h(!1)}})},[]);const[g,y]=_.useState([]),[w,E]=_.useState(!1);_.useEffect(()=>{me(null,null,function*(){try{const Tt=yield Xt.apiCall("/api/method/asset_lite.api.user_roles.get_user_roles");Array.isArray(Tt)?y(Tt):Tt!=null&&Tt.message&&y(Tt.message)}catch(Tt){console.error("Error fetching roles:",Tt)}finally{E(!0)}})},[]);const[S,A]=_.useState(!1),[C,O]=_.useState(!1);_.useEffect(()=>{me(null,null,function*(){try{const He=yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:c.join(",")})})).json();He.message&&h(He.message.has_role)}catch(Tt){console.error("Error checking permissions:",Tt),h(!1)}})},[]);const[M,R]=_.useState({inspection_type:"",status:"Open",inspection_date:n?tf():"",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:"",assigned_engineer:"",attachment:"",attachment_on_close:"",extension_no:"",docstatus:0}),[F,z]=_.useState(n),[W,X]=_.useState([]),[B,Y]=_.useState(!1),[G,ie]=_.useState([]),[fe,K]=_.useState(!1),[ke,ge]=_.useState(!1),[re,we]=_.useState(!1),{inspection:ee,loading:ve,error:ce,refetch:ye}=WG(n?null:r||null),{createInspection:te,updateInspection:q,deleteInspection:J,loading:ae}=HG(),{isSystemManager:oe,canEdit:le,getStateStyle:be}=Lg({doctype:"Inspection",docname:n?null:r||null,workflowState:M.workflow_state,enabled:!n,docData:M}),Z=!M.assigned_engineer,Le=!M.assigned_technician,[Pe,Be]=_.useState(n||i),[pe,rt]=_.useState(!1),et=_.useCallback(()=>{const jt=M.workflow_state||"Draft";return jt==="Cancelled"?2:jt==="Closed"?1:M.docstatus||0},[M.workflow_state,M.docstatus])(),It=et===1,ft=et===2,Lt=!!(ee!=null&&ee.custom_delete_status),Je=It||ft||Lt,Ve=_.useCallback(()=>me(null,null,function*(){if(!(n||!r)){K(!0);try{const jt=yield Xt.apiCall(`/api/resource/Version?filters=[["ref_doctype","=","Inspection"],["docname","=","${encodeURIComponent(r)}"]]&fields=["name","owner","creation","data"]&order_by=creation desc&limit=50`);if(jt!=null&&jt.data&&jt.data.length>0){const Tt=jt.data.map(He=>{let Fe={added:[],changed:[],removed:[],row_changed:[]};try{Fe=JSON.parse(He.data||"{}")}catch(vt){console.error("Error parsing version data:",vt)}const Ze=(Fe.changed||[]).map(vt=>({field:vt[0]||"",oldValue:vt[1],newValue:vt[2]}));return{name:He.name,owner:He.owner,creation:He.creation,changes:Ze,added:Fe.added||[],removed:Fe.removed||[],rowChanged:Fe.row_changed||[]}});ie(Tt),console.log("Audit logs fetched:",Tt.length)}else ie([])}catch(jt){console.error("Error fetching audit logs:",jt),ie([])}finally{K(!1)}}}),[n,r]);_.useEffect(()=>{Ve()},[Ve]);const Xe=jt=>jt?jt.replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,Tt=>Tt.toUpperCase()):"",Rt=jt=>jt==null||jt===""?"(empty)":jt===0?"0":jt===1?"1":typeof jt=="boolean"?jt?"Yes":"No":typeof jt=="object"?JSON.stringify(jt):String(jt),qe=jt=>{if(!jt)return"";const Tt=new Date(jt),He=new Date,Fe=He.getTime()-Tt.getTime(),Ze=Math.floor(Fe/6e4),vt=Math.floor(Fe/36e5),ir=Math.floor(Fe/864e5);return Ze<1?"Just now":Ze<60?`${Ze} min${Ze>1?"s":""} ago`:vt<24?`${vt} hour${vt>1?"s":""} ago`:ir<7?`${ir} day${ir>1?"s":""} ago`:Tt.toLocaleDateString("en-US",{month:"short",day:"numeric",year:Tt.getFullYear()!==He.getFullYear()?"numeric":void 0,hour:"2-digit",minute:"2-digit"})},Dt=jt=>{if(!jt)return"Unknown";const Tt=jt.indexOf("@");return Tt===-1?jt:jt.substring(0,Tt)},ar=jt=>{const Tt=jt.toLowerCase();return Tt.includes("status")||Tt.includes("state")?"text-purple-600 dark:text-purple-400":Tt.includes("date")?"text-blue-600 dark:text-blue-400":Tt.includes("technician")||Tt.includes("supervisor")||Tt.includes("assigned")?"text-green-600 dark:text-green-400":"text-gray-600 dark:text-gray-400"},yt=_.useCallback(jt=>me(null,null,function*(){if(!jt){X([]);return}try{console.log("Filtering technicians for work order type:",jt);const Tt=yield Xt.apiCall(`/api/resource/Asset Maintenance Team?filters=[["custom_expertise","=","${encodeURIComponent(jt)}"]]&fields=["name"]&limit=100`);if(Tt!=null&&Tt.data&&Tt.data.length>0){const He=new Set,Fe=Tt.data.map(vt=>me(null,null,function*(){try{const ir=yield Xt.apiCall(`/api/resource/Asset Maintenance Team/${encodeURIComponent(vt.name)}`);ir!=null&&ir.data&&(ir.data.maintenance_team_members||[]).forEach(Kt=>{Kt.team_member&&He.add(Kt.team_member)})}catch(ir){console.error("Error fetching team:",vt.name,ir)}}));yield Promise.all(Fe);const Ze=Array.from(He);console.log("Filtered Technicians:",Ze),X(Ze)}else X([])}catch(Tt){console.error("Error fetching technicians:",Tt),X([])}}),[]);_.useEffect(()=>{M.work_order_type?yt(M.work_order_type):X([])},[M.work_order_type,yt]);const St=jt=>{if(!jt)return!0;const Tt=tf();return jt<Tt?(Mt.error(e("inspections.detail.inspectionDateInPast"),{position:"top-right",autoClose:5e3,icon:t.jsx(Jr,{})}),!1):!0},Ot=(jt,Tt)=>{if(!jt)return!0;const He=tf();return Tt&&jt<Tt?(Mt.error(e("inspections.detail.targetClosureEarlier"),{position:"top-right",autoClose:5e3,icon:t.jsx(Jr,{})}),!1):jt<He?(Mt.error(e("inspections.detail.targetClosureInPast"),{position:"top-right",autoClose:5e3,icon:t.jsx(Jr,{})}),!1):!0},Yt=jt=>{const Tt=jt.target.value;St(Tt)&&(R(He=>Ke(Te({},He),{inspection_date:Tt})),M.target_closure_date&&Ot(M.target_closure_date,Tt))},Ye=jt=>{const Tt=jt.target.value;Ot(Tt,M.inspection_date||"")&&R(He=>Ke(Te({},He),{target_closure_date:Tt}))},wt=jt=>{R(Tt=>Ke(Te({},Tt),{work_order_type:jt,assigned_technician:""}))},zt=jt=>me(null,null,function*(){var Fe,Ze;const Tt=(Fe=jt.target.files)==null?void 0:Fe[0];if(!Tt)return;const He=10*1024*1024;if(Tt.size>He){Mt.error(e("inspections.detail.fileSizeExceeds"),{position:"top-right",autoClose:4e3,icon:t.jsx(Br,{})});return}Y(!0);try{const vt=new FormData;vt.append("file",Tt),vt.append("is_private","0"),vt.append("folder","Home/Attachments"),!n&&r&&(vt.append("doctype","Inspection"),vt.append("docname",r));const ir=Or.BASE_URL||"",Kt=yield(yield fetch(`${ir}/api/method/upload_file`,{method:"POST",credentials:"include",body:vt})).json();if((Ze=Kt.message)!=null&&Ze.file_url)R(Re=>Ke(Te({},Re),{attachment:Kt.message.file_url})),Mt.success(e("inspections.detail.fileUploadedSuccess"),{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})});else throw new Error("Upload failed")}catch(vt){console.error("File upload error:",vt),Mt.error(e("inspections.detail.failedToUpload"),{position:"top-right",autoClose:4e3,icon:t.jsx(Br,{})})}finally{Y(!1),jt.target.value=""}}),qt=()=>{R(jt=>Ke(Te({},jt),{attachment:""})),Mt.info(e("inspections.detail.attachmentRemoved"),{position:"top-right",autoClose:2e3})},kt=jt=>{if(!jt)return"";const Tt=jt.split("/");return Tt[Tt.length-1]||jt},ze=()=>me(null,null,function*(){O(!0);try{yield q(r,Ke(Te({},M),{workflow_state:"Cancelled",docstatus:2,status:"Cancelled"})),Mt.success(e("inspections.detail.cancelledSuccessfully"),{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),A(!1),ye(),setTimeout(()=>{Ve()},500)}catch(jt){const Tt=jt instanceof Error?jt.message:"Unknown error";Mt.error(e("inspections.detail.failedToCancel",{error:Tt}),{position:"top-right",autoClose:6e3,icon:t.jsx(Br,{})})}finally{O(!1)}});_.useEffect(()=>{me(null,null,function*(){if(n&&!M.requested_by)try{const Tt=yield Rd.getCurrentUser();Tt&&R(He=>Ke(Te({},He),{requested_by:Tt}))}catch(Tt){console.error("Error fetching current user:",Tt)}finally{z(!1)}else z(!1)})},[n]),_.useEffect(()=>{ee&&!n&&(R({inspection_type:ee.inspection_type||"",status:ee.status||"Open",inspection_date:ee.inspection_date||"",target_closure_date:ee.target_closure_date||"",requested_by:ee.requested_by||"",technician_department:ee.technician_department||"",linked_corrective_wo_no:ee.linked_corrective_wo_no||"",observation_note:ee.observation_note||"",technical_response:ee.technical_response||"",workflow_state:ee.workflow_state||"Draft",work_order_type:ee.work_order_type||"",department:ee.department||"",location:ee.location||"",assigned_technician:ee.assigned_technician||"",assigned_engineer:ee.assigned_engineer||"",attachment:ee.attachment||"",attachment_on_close:ee.attachment_on_close||"",extension_no:ee.extension_no||"",docstatus:ee.docstatus||0}),ee.workflow_state==="Closed"||ee.workflow_state==="Cancelled"||ee.docstatus>=1?Be(!1):i||Be(!1))},[ee,n,i]);const nt=jt=>{const{name:Tt,value:He}=jt.target;R(Fe=>Ke(Te({},Fe),{[Tt]:He}))},_t=()=>me(null,null,function*(){if(!M.target_closure_date){Mt.error(e("inspections.detail.targetClosureMandatory"),{position:"top-right",autoClose:5e3,icon:t.jsx(Br,{})});return}if(!M.attachment){Mt.error(e("inspections.detail.attachmentMandatory"),{position:"top-right",autoClose:5e3,icon:t.jsx(Br,{})});return}if(!M.extension_no){Mt.error(e("inspections.detail.extensionMandatory"),{position:"top-right",autoClose:5e3,icon:t.jsx(Br,{})});return}if(St(M.inspection_date||"")&&Ot(M.target_closure_date||"",M.inspection_date||""))try{if(n){const jt=yield te(M);Mt.success(e("inspections.detail.createdSuccessfully"),{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),s(`/inspections/${jt.name}`)}else yield q(r,M),Mt.success(e("inspections.detail.updatedSuccessfully"),{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),Be(!1),ye(),setTimeout(()=>{Ve()},500)}catch(jt){const Tt=jt instanceof Error?jt.message:"Unknown error";Mt.error(e("inspections.detail.failedToSave",{error:Tt}),{position:"top-right",autoClose:6e3,icon:t.jsx(Br,{})})}}),lr=()=>me(null,null,function*(){try{yield J(r),Mt.success(e("inspections.detail.deletedSuccessfully"),{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),s(-1)}catch(jt){const Tt=jt instanceof Error?jt.message:"Unknown error";Mt.error(e("inspections.detail.failedToDelete",{error:Tt}),{position:"top-right",autoClose:6e3,icon:t.jsx(Br,{})})}}),pr=(jt,Tt)=>{Tt&&(Mt.success(`Action "${jt}" applied successfully!`,{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),setTimeout(()=>{Ve()},500))},Nr=()=>{ye()},rr=_.useCallback(jt=>!!(Je||!Pe||jt==="linked_corrective_wo_no"||!n&&!le&&!oe),[Pe,n,le,oe,Je]);if(ve||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-teal-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("inspections.detail.loadingDetails")})]})});if(ce&&!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:ce}),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 _r=(ee==null?void 0:ee.workflow_state)||M.workflow_state||"Draft",Nt=be(_r),Cr=ZG(M.status||"Open");return t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[t.jsx(xc,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:Ll}),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(Kn,{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"):(ee==null?void 0:ee.name)||e("inspections.detail.inspectionDetails"),!n&&t.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-medium ${Cr.bg} ${Cr.text} ${Cr.border} border`,children:M.status||"Open"}),ft&&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")}),oe&&!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"):`${M.inspection_type||e("inspections.typeMap.inspection")}`})]})]}),t.jsxs("div",{className:"flex gap-3",children:[!n&&!Pe&&t.jsxs(t.Fragment,{children:[!Je&&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(Ms,{}),e("common.edit")]}),It&&u&&t.jsxs("button",{onClick:()=>A(!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(po,{}),e("common.cancel")]})]}),Pe&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{n?s(-1):(Be(!1),ye())},className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg",children:e("common.cancel")}),t.jsxs("button",{onClick:_t,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(bs,{}),e(ae?"common.saving":"common.save")]})]})]})]}),S&&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(po,{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:()=>A(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",disabled:C,children:e("inspections.detail.noGoBack")}),t.jsx("button",{onClick:ze,disabled:C,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:C?t.jsxs(t.Fragment,{children:[t.jsx(Ir,{className:"animate-spin"}),e("inspections.detail.cancelling")]}):t.jsxs(t.Fragment,{children:[t.jsx(po,{}),e("inspections.detail.yesCancel")]})})]})]})}),pe&&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(Jr,{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:()=>rt(!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:lr,disabled:ae,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg disabled:opacity-50",children:e(ae?"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(Wo,{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:M.inspection_type,onChange:nt,disabled:rr("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:M.status,onChange:nt,disabled:rr("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(hr,{label:e("inspections.detail.workOrderType"),doctype:"Issue Type",value:M.work_order_type||"",onChange:wt,disabled:rr("work_order_type"),placeholder:e("inspections.detail.selectWorkOrderType")}),W.length>0&&t.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:e("inspections.detail.techniciansAvailable",{count:W.length})})]}),t.jsx("div",{children:t.jsx(hr,{label:e("inspections.detail.department"),doctype:"Department",value:M.department||"",onChange:jt=>R(Ke(Te({},M),{department:jt})),disabled:rr("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(hr,{label:e("inspections.detail.location"),doctype:"Location",value:M.location||"",onChange:jt=>R(Ke(Te({},M),{location:jt})),disabled:rr("location"),placeholder:e("inspections.detail.selectLocation"),allowQuickCreate:!0})}),t.jsx("div",{children:t.jsx(hr,{label:e("inspections.detail.extensionNo"),doctype:"Extension Directory",value:M.extension_no||"",onChange:jt=>R(Ke(Te({},M),{extension_no:jt})),disabled:rr("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:M.inspection_date||"",onChange:Yt,min:tf(),disabled:rr("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:M.target_closure_date||"",onChange:Ye,min:M.inspection_date||tf(),disabled:rr("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")}),M.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($m,{className:"text-blue-500 flex-shrink-0",size:18}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("a",{href:`${Or.BASE_URL}${M.attachment}`,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 dark:text-blue-400 hover:underline truncate block",children:kt(M.attachment)})}),Pe&&!Je&&t.jsx("button",{type:"button",onClick:qt,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(Pt,{size:14})})]}):Pe&&!Je?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:[B?t.jsxs(t.Fragment,{children:[t.jsx(Ir,{className:"animate-spin",size:14}),t.jsx("span",{className:"text-sm",children:e("inspections.detail.uploading")})]}):t.jsxs(t.Fragment,{children:[t.jsx(Gm,{size:14}),t.jsx("span",{className:"text-sm",children:e("inspections.detail.uploadFile")})]}),t.jsx("input",{type:"file",onChange:zt,disabled:B||rr("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")}),M.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($m,{className:"text-green-500 flex-shrink-0",size:18}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("a",{href:`${Or.BASE_URL}${M.attachment_on_close}`,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 dark:text-blue-400 hover:underline truncate block",children:kt(M.attachment_on_close)})}),Pe&&!Je&&t.jsx("button",{type:"button",onClick:()=>{R(jt=>Ke(Te({},jt),{attachment_on_close:""})),Mt.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(Pt,{size:14})})]}):Pe&&!Je?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:[B?t.jsxs(t.Fragment,{children:[t.jsx(Ir,{className:"animate-spin",size:14}),t.jsx("span",{className:"text-sm",children:e("inspections.detail.uploading")})]}):t.jsxs(t.Fragment,{children:[t.jsx(Gm,{size:14}),t.jsx("span",{className:"text-sm",children:e("inspections.detail.uploadClosingFile")})]}),t.jsx("input",{type:"file",onChange:jt=>me(null,null,function*(){var Fe,Ze;const Tt=(Fe=jt.target.files)==null?void 0:Fe[0];if(!Tt)return;const He=10*1024*1024;if(Tt.size>He){Mt.error(e("inspections.detail.fileSizeExceeds"),{position:"top-right",autoClose:4e3,icon:t.jsx(Br,{})});return}Y(!0);try{const vt=new FormData;vt.append("file",Tt),vt.append("is_private","0"),vt.append("folder","Home/Attachments"),!n&&r&&(vt.append("doctype","Inspection"),vt.append("docname",r));const ir=Or.BASE_URL||"",Kt=yield(yield fetch(`${ir}/api/method/upload_file`,{method:"POST",credentials:"include",body:vt})).json();if((Ze=Kt.message)!=null&&Ze.file_url)R(Re=>Ke(Te({},Re),{attachment_on_close:Kt.message.file_url})),Mt.success(e("inspections.detail.closingAttachmentUploadedSuccess"),{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})});else throw new Error("Upload failed")}catch(vt){console.error("File upload error:",vt),Mt.error(e("inspections.detail.failedToUploadClosing"),{position:"top-right",autoClose:4e3,icon:t.jsx(Br,{})})}finally{Y(!1),jt.target.value=""}}),disabled:B||rr("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(Yn,{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(hr,{label:e("inspections.detail.requestedBy"),doctype:"User",value:M.requested_by||"",onChange:jt=>R(Ke(Te({},M),{requested_by:jt})),disabled:rr("requested_by"),placeholder:e("inspections.detail.selectUser")})}),t.jsx("div",{children:t.jsx(hr,{label:e("inspections.detail.technicalDepartment"),doctype:"Technical Department",value:M.technician_department||"",onChange:jt=>R(Ke(Te({},M),{technician_department:jt})),disabled:rr("technician_department"),placeholder:e("inspections.detail.selectDepartment"),allowQuickCreate:!0})}),t.jsx("div",{children:t.jsx(hr,{label:e("inspections.detail.assignedEngineer"),doctype:"User",value:M.assigned_engineer||"",onChange:jt=>R(Ke(Te({},M),{assigned_engineer:jt})),disabled:rr("assigned_engineer"),placeholder:e("inspections.detail.selectEngineer")})}),t.jsxs("div",{children:[t.jsx(hr,{label:e("inspections.detail.assignedTechnician"),doctype:"User",value:M.assigned_technician||"",onChange:jt=>R(Ke(Te({},M),{assigned_technician:jt})),disabled:rr("assigned_technician"),placeholder:e("inspections.detail.selectTechnician"),filters:W.length>0?{name:["in",W]}:{}}),!M.work_order_type&&Pe&&!Je&&t.jsx("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:e("inspections.detail.selectWOTypeFirst")}),M.work_order_type&&W.length===0&&Pe&&!Je&&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(iT,{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:M.observation_note,onChange:nt,disabled:rr("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:M.technical_response,onChange:nt,disabled:rr("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(Hm,{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"),")"]})]}),M.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:M.linked_corrective_wo_no}),t.jsxs("button",{onClick:()=>s(`/work-orders/${M.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(ps,{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(Kd,{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&&!Pe&&!Je&&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(Hm,{className:"text-purple-500",size:14}),e("inspections.detail.workflowActions")]}),Z&&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(Jr,{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:"Engineer Required"}),t.jsx("p",{className:"text-[11px] text-amber-700 dark:text-amber-400 mt-0.5",children:'Assign an engineer before the "Send to Engineer" action becomes available.'})]})]}),Le&&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(Jr,{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:'Assign a technician before the "Send to Technician" action becomes available.'})]})]}),t.jsx(db,{doctype:"Inspection",docname:r||null,workflowState:_r,onActionComplete:pr,onStateChange:Nr,showStateInfo:!1,hiddenActions:[...Z?["Send to Engineer"]:[],...Le?["Send to Technician"]:[]]})]}),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(Wo,{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 ${Nt.bg} ${Nt.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 ${Nt.text}`,children:_r})]}),t.jsxs("div",{className:`p-2 rounded-lg border ${Cr.bg} ${Cr.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 ${Cr.text}`,children:M.status||"Open"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[M.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:M.inspection_type})]}),M.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:M.work_order_type})]})]}),M.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:M.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:()=>ge(!ke),children:[t.jsx(Id,{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")}),G.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:G.length})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button",onClick:jt=>{jt.stopPropagation(),Ve(),Mt.info(e("inspections.detail.activityLogRefreshed"),{position:"top-right",autoClose:1500,icon:t.jsx(Ui,{})})},disabled:fe,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(Ui,{className:`${fe?"animate-spin":""}`,size:10})}),t.jsx("button",{type:"button",onClick:()=>ge(!ke),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors p-1",children:ke?t.jsx(Mn,{size:12}):t.jsx(on,{size:12})})]})]}),ke&&t.jsxs("div",{className:"p-3",children:[fe&&t.jsxs("div",{className:"flex items-center justify-center py-6",children:[t.jsx(Ir,{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")})]}),!fe&&G.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")})})]}),(ee==null?void 0:ee.creation)&&(ee==null?void 0:ee.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(Yn,{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:Dt(ee.owner)})]}),t.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-500 dark:text-gray-400",children:[t.jsx(Ja,{size:8}),t.jsx("span",{title:new Date(ee.creation).toLocaleString(),children:qe(ee.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(Tr,{size:8}),e("inspections.detail.createdThisInspection")]})})]})]})]}),!fe&&G.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:(re?G:G.slice(0,5)).map((jt,Tt)=>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 ${Tt===0?"bg-blue-500":"bg-gray-300 dark:bg-gray-600"}`}),t.jsxs("div",{className:`p-2 rounded-lg ${Tt===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(Yn,{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:Dt(jt.owner)})]}),t.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-500 dark:text-gray-400",children:[t.jsx(Ja,{size:8}),t.jsx("span",{title:new Date(jt.creation).toLocaleString(),children:qe(jt.creation)})]})]}),t.jsxs("div",{className:"space-y-1",children:[jt.changes.length>0?jt.changes.map((He,Fe)=>t.jsxs("div",{className:"text-[10px]",children:[t.jsx("span",{className:`font-medium ${ar(He.field)}`,children:Xe(He.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:Rt(He.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:Rt(He.newValue)})]},Fe)):t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400 italic",children:e("inspections.detail.documentUpdated")}),jt.added&&jt.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")})," ",jt.added.length," ",e("inspections.detail.items")]}),jt.removed&&jt.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")})," ",jt.removed.length," ",e("inspections.detail.items")]}),jt.rowChanged&&jt.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")})," ",jt.rowChanged.length," ",e("inspections.detail.rows")]})]})]})]},jt.name))}),G.length>5&&t.jsx("div",{className:"mt-3 text-center",children:t.jsx("button",{type:"button",onClick:()=>we(!re),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:re?t.jsxs(t.Fragment,{children:[t.jsx(Mn,{size:8}),e("inspections.detail.showLess")]}):t.jsxs(t.Fragment,{children:[t.jsx(on,{size:8}),e("inspections.detail.showAll")," (",G.length,")"]})})}),(ee==null?void 0:ee.creation)&&(ee==null?void 0:ee.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(Yn,{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:Dt(ee.owner)})]}),t.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-500 dark:text-gray-400",children:[t.jsx(Ja,{size:8}),t.jsx("span",{title:new Date(ee.creation).toLocaleString(),children:qe(ee.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(Tr,{size:8}),e("inspections.detail.createdThisInspection")]})})]})]})]})]})]}),!n&&w&&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(rd,{doctype:"Inspection",docname:r,currentDeleteStatus:(yr=ee==null?void 0:ee.custom_delete_status)!=null?yr:null,userRoles:g,isSystemManager:oe,redirectOnDelete:"/inspections",onStatusChange:()=>ye()})]})]})]})]})};class JG{constructor(){Ii(this,"baseURL");this.baseURL=Or.BASE_URL}getCSRFToken(){return me(this,null,function*(){try{return typeof window!="undefined"&&window.csrf_token?window.csrf_token:null}catch(r){return null}})}getHeaders(){return me(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 me(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:c="creation desc"}=r,u=new URLSearchParams;if(u.append("fields",JSON.stringify(s)),u.append("limit_start",n.toString()),u.append("limit_page_length",i.toString()),u.append("order_by",c),Object.keys(a).length>0){const y=Ln(a);y.length>0&&u.append("filters",JSON.stringify(y))}const h=yield fetch(`${this.baseURL}/api/resource/Support Plans?${u.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);return{data:(yield h.json()).data||[]}})}getSupportPlan(r){return me(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 me(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 me(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 me(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 me(this,arguments,function*(r={}){var i,c;const a=new URLSearchParams;if(a.append("fields",JSON.stringify(["count(name) as count"])),Object.keys(r).length>0){const u=Ln(r);u.length>0&&a.append("filters",JSON.stringify(u))}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((c=(i=(yield s.json()).data)==null?void 0:i[0])==null?void 0:c.count)||0})}getCurrentUser(){return me(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 _f=new JG,QG=(e={})=>{const[r,a]=_.useState([]),[s,n]=_.useState(!0),[i,c]=_.useState(null),[u,h]=_.useState(0),g=_.useCallback(()=>me(null,null,function*(){try{n(!0),c(null);const y=yield _f.getSupportPlans(e);a(y.data);const E=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();h(E.message||y.data.length)}catch(y){c(y instanceof Error?y.message:"Failed to fetch support plans"),a([])}finally{n(!1)}}),[e.filters,e.limit_start,e.limit_page_length,e.order_by]);return _.useEffect(()=>{g()},[g]),{supportPlans:r,loading:s,error:i,totalCount:u,refetch:g}},eY=e=>{const[r,a]=_.useState(null),[s,n]=_.useState(!0),[i,c]=_.useState(null),u=_.useCallback(()=>me(null,null,function*(){if(!e){n(!1);return}try{n(!0),c(null);const h=yield _f.getSupportPlan(e);a(h)}catch(h){c(h instanceof Error?h.message:"Failed to fetch support plan"),a(null)}finally{n(!1)}}),[e]);return _.useEffect(()=>{u()},[u]),{supportPlan:r,loading:s,error:i,refetch:u}},tY=()=>{const[e,r]=_.useState(!1),[a,s]=_.useState(null),n=_.useCallback(u=>me(null,null,function*(){try{return r(!0),s(null),yield _f.createSupportPlan(u)}catch(h){const g=h instanceof Error?h.message:"Failed to create support plan";throw s(g),h}finally{r(!1)}}),[]),i=_.useCallback((u,h)=>me(null,null,function*(){try{return r(!0),s(null),yield _f.updateSupportPlan(u,h)}catch(g){const y=g instanceof Error?g.message:"Failed to update support plan";throw s(y),g}finally{r(!1)}}),[]),c=_.useCallback(u=>me(null,null,function*(){try{r(!0),s(null),yield _f.deleteSupportPlan(u)}catch(h){const g=h instanceof Error?h.message:"Failed to delete support plan";throw s(g),h}finally{r(!1)}}),[]);return{createSupportPlan:n,updateSupportPlan:i,deleteSupportPlan:c,loading:e,error:a}},rY=({isOpen:e,onClose:r,selectedCount:a,totalCount:s,pageCount:n,onExport:i,isExporting:c,exportColumns:u})=>{const{t:h}=Rr(),[g,y]=_.useState(a>0?"selected":"all_with_filters"),[w,E]=_.useState("csv"),[S,A]=_.useState(u.filter(R=>R.default).map(R=>R.key));_.useEffect(()=>{y(a>0?"selected":"all_with_filters")},[a]);const C=R=>A(F=>F.includes(R)?F.filter(z=>z!==R):[...F,R]),O=()=>A(u.map(R=>R.key)),M=()=>A(u.filter(R=>R.default).map(R=>R.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(Ks,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:h("supportPlans.export.title")})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:c,children:t.jsx(Pt,{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:h("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 ${g==="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:g==="selected",onChange:()=>y("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:h("supportPlans.export.selectedRows")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("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 ${g==="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:g==="all_on_page",onChange:()=>y("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:h("supportPlans.export.currentPage")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("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 ${g==="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:g==="all_with_filters",onChange:()=>y("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:h("supportPlans.export.allWithFilters")}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("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:h("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 ${w==="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:w==="csv",onChange:()=>E("csv"),className:"text-indigo-600"}),t.jsx(No,{className:"text-indigo-600 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("supportPlans.export.csv")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("supportPlans.export.csvDesc")})]})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${w==="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:w==="excel",onChange:()=>E("excel"),className:"text-indigo-600"}),t.jsx(zi,{className:"text-green-700 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("supportPlans.export.excel")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("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:h("supportPlans.export.columnsToExport")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:O,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("supportPlans.export.selectAll")}),t.jsx("span",{className:"text-gray-300",children:"|"}),t.jsx("button",{onClick:M,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("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:u.map(R=>t.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${S.includes(R.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:S.includes(R.key),onChange:()=>C(R.key),className:"rounded text-indigo-600"}),t.jsx("span",{className:"text-sm truncate",children:R.label})]},R.key))}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:h("supportPlans.export.columnsSelected",{count:S.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:[g==="selected"&&h("supportPlans.export.exportingSelected",{count:a}),g==="all_on_page"&&h("supportPlans.export.exportingPage",{count:n}),g==="all_with_filters"&&h("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:c,children:h("common.cancel")}),t.jsx("button",{onClick:()=>i(g,w,S),disabled:S.length===0||c,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:c?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),h("supportPlans.export.exporting")]}):t.jsxs(t.Fragment,{children:[t.jsx(Vo,{}),h("supportPlans.export.exportButton")]})})]})]})]})}):null},aY=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"}},f4=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"}},sY=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"}},nY=()=>{const{t:e}=Rr(),r=Na(),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]=Sn(),i=_.useMemo(()=>{const ze=parseInt(s.get("page")||"1",10);return Number.isNaN(ze)||ze<1?1:ze},[s]),c=_.useCallback(ze=>{const nt=typeof ze=="function"?ze(i):ze;n(_t=>{const lr=new URLSearchParams(_t);return lr.set("page",String(nt)),lr})},[i,n]),[u]=_.useState(20),[h,g]=_.useState(!1),[y,w]=_.useState(new Set),[E,S]=_.useState(!1),[A,C]=_.useState(!1),[O,M]=_.useState(null),[R,F]=_.useState(!0),[z,W]=_.useState(!0),[X,B]=_.useState(()=>s.get("date_filter_by")||""),[Y,G]=_.useState(()=>s.get("date_start")||""),[ie,fe]=_.useState(()=>s.get("date_end")||""),[K,ke]=_.useState(()=>s.get("contract_warranty")||""),[ge,re]=_.useState(()=>s.get("frequency")||""),[we,ee]=_.useState(()=>s.get("war_status")||""),[ve,ce]=_.useState(()=>s.get("service_contract_status")||""),[ye,te]=_.useState(()=>s.get("vendor")||""),[q,J]=_.useState(()=>s.get("asset")||""),[ae,oe]=_.useState(!1),[le,be]=_.useState(0),[Z,Le]=_.useState([]),[Pe,Be]=_.useState(!1),[pe,rt]=_.useState("");_.useEffect(()=>{const ze=localStorage.getItem("supportPlanFilterPresets");ze&&Le(JSON.parse(ze))},[]);const ct=X&&(Y||ie);_.useEffect(()=>{const ze=[K,ge,we,ve,ye,q].filter(Boolean).length+(ct?1:0);be(ze)},[K,ge,we,ve,ye,q,ct]);const et=_.useMemo(()=>{const ze={};return K&&(ze.custom_contractwarranty=K),ge&&(ze.frequency=ge),we&&(ze.war_status=we),ve&&(ze.service_contract_status=ve),ye&&(ze.vendor=ye),q&&(ze.asset=q),Object.assign(ze,td(X,Y,ie)),ze},[K,ge,we,ve,ye,q,X,Y,ie]),{supportPlans:It,loading:ft,error:Lt,totalCount:Je,refetch:Ve}=QG({filters:et,limit_start:(i-1)*u,limit_page_length:u,order_by:"creation desc"});_.useEffect(()=>{!ft&&!h&&g(!0)},[ft,h]);const Xe=_.useRef(!1);_.useEffect(()=>{if(!Xe.current){Xe.current=!0;return}n(ze=>{const nt=new URLSearchParams(ze);return X?nt.set("date_filter_by",X):nt.delete("date_filter_by"),Y?nt.set("date_start",Y):nt.delete("date_start"),ie?nt.set("date_end",ie):nt.delete("date_end"),K?nt.set("contract_warranty",K):nt.delete("contract_warranty"),ge?nt.set("frequency",ge):nt.delete("frequency"),we?nt.set("war_status",we):nt.delete("war_status"),ve?nt.set("service_contract_status",ve):nt.delete("service_contract_status"),ye?nt.set("vendor",ye):nt.delete("vendor"),q?nt.set("asset",q):nt.delete("asset"),nt.set("page","1"),nt})},[X,Y,ie,K,ge,we,ve,ye,q]),_.useEffect(()=>{w(new Set)},[X,Y,ie,K,ge,we,ve,ye,q,i]);const Rt=ze=>{if(!ze)return"-";const nt=typeof ze=="string"?parseFloat(ze):ze;return new Intl.NumberFormat("en-US",{style:"currency",currency:"SAR"}).format(nt)},qe=()=>{B(""),G(""),fe(""),ke(""),re(""),ee(""),ce(""),te(""),J(""),n(ze=>{const nt=new URLSearchParams(ze);return nt.delete("date_filter_by"),nt.delete("date_start"),nt.delete("date_end"),nt.delete("contract_warranty"),nt.delete("frequency"),nt.delete("war_status"),nt.delete("service_contract_status"),nt.delete("vendor"),nt.delete("asset"),nt.set("page","1"),nt})},Dt=ct||!!K||!!ge||!!we||!!ve||!!ye||!!q,ar=()=>{if(!pe.trim()){alert("Please enter a filter name");return}const ze={id:Date.now(),name:pe,filters:{dateFilterBy:X,dateStart:Y,dateEnd:ie,contractWarrantyFilter:K,frequencyFilter:ge,warStatusFilter:we,serviceContractStatusFilter:ve,vendorFilter:ye,assetFilter:q}},nt=[...Z,ze];Le(nt),rt(""),Be(!1),localStorage.setItem("supportPlanFilterPresets",JSON.stringify(nt))},yt=ze=>{const nt=ze.filters;B(nt.dateFilterBy||""),G(nt.dateStart||""),fe(nt.dateEnd||""),ke(nt.contractWarrantyFilter||""),re(nt.frequencyFilter||""),ee(nt.warStatusFilter||""),ce(nt.serviceContractStatusFilter||""),te(nt.vendorFilter||""),J(nt.assetFilter||"")},St=ze=>{const nt=Z.filter(_t=>_t.id!==ze);Le(nt),localStorage.setItem("supportPlanFilterPresets",JSON.stringify(nt))},Ot=ze=>w(nt=>{const _t=new Set(nt);return _t.has(ze)?_t.delete(ze):_t.add(ze),_t}),Yt=()=>y.size===It.length?w(new Set):w(new Set(It.map(ze=>ze.name))),Ye=It.length>0&&y.size===It.length,wt=y.size>0&&y.size<It.length,zt=_.useCallback(()=>me(null,null,function*(){const ze=[];let nt=0;const _t=100;let lr=!0;const pr=Ln(et);for(;lr;)try{const _r=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Support Plans",filters:pr.length>0?pr:{},fields:["*"],limit_start:nt*_t,limit_page_length:_t,order_by:"creation desc"})})).json()).message||[];ze.push(..._r),_r.length<_t?lr=!1:nt++,nt>100&&(console.warn("Export safety limit reached"),lr=!1)}catch(Nr){throw console.error("Error fetching support plans for export:",Nr),Nr}return ze}),[et]),qt=(ze,nt,_t)=>me(null,null,function*(){C(!0);try{let lr=[];switch(ze){case"selected":lr=It.filter(Nr=>y.has(Nr.name));break;case"all_on_page":lr=It;break;case"all_with_filters":lr=yield zt();break}if(lr.length===0){alert(e("assets.noDataToExport"));return}const pr=_t.map(Nr=>{var rr;return((rr=a.find(_r=>_r.key===Nr))==null?void 0:rr.label)||Nr});if(nt==="csv"){const Nr=[pr.join(","),...lr.map(Cr=>_t.map(yr=>{var Tt;let jt=(Tt=Cr[yr])!=null?Tt:"";return typeof jt=="string"&&(jt.includes(",")||jt.includes('"')||jt.includes(`
`))&&(jt=`"${jt.replace(/"/g,'""')}"`),jt}).join(","))].join(`
`),rr=new Blob(["\uFEFF"+Nr],{type:"text/csv;charset=utf-8;"}),_r=URL.createObjectURL(rr),Nt=document.createElement("a");Nt.href=_r,Nt.download=`support_plans_export_${new Date().toISOString().split("T")[0]}.csv`,Nt.click(),URL.revokeObjectURL(_r)}else if(nt==="excel"){const Nr=[pr,...lr.map(Nt=>_t.map(Cr=>{var yr;return(yr=Nt[Cr])!=null?yr:""}))],rr=Ur.aoa_to_sheet(Nr),_r=Ur.book_new();Ur.book_append_sheet(_r,rr,"Support Plans"),jo(_r,`support_plans_export_${new Date().toISOString().split("T")[0]}.xlsx`)}S(!1),w(new Set)}catch(lr){console.error("Export failed:",lr),alert(`Export failed: ${lr instanceof Error?lr.message:"Unknown error"}`)}finally{C(!1)}}),kt=ze=>me(null,null,function*(){try{if(!(yield fetch(`/api/resource/Support Plans/${encodeURIComponent(ze)}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to delete");M(null),Ve(),alert(e("supportPlans.deletedSuccessfully"))}catch(nt){alert(`Failed to delete: ${nt instanceof Error?nt.message:"Unknown error"}`)}});return ft&&!h?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")})]})}):Lt?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:Lt}),t.jsx("button",{onClick:Ve,className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded",children:"Try Again"})]})}):t.jsxs("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen w-full min-w-0 overflow-x-hidden",children:[t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center w-full min-w-0",children:[t.jsx("div",{className:"min-w-0",children:t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(ff,{className:"text-3xl text-indigo-600 dark:text-indigo-400"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-gray-800 dark:text-white break-words",children:e("supportPlans.listTitle")}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[e("issues.listTotal"),": ",Je,y.size>0&&t.jsxs("span",{className:"ml-2 text-indigo-600 dark:text-indigo-400",children:["• ",y.size," selected"]}),ft&&h&&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 flex-col gap-2 w-full sm:flex-row sm:flex-wrap sm:justify-end sm:gap-3 sm:w-auto min-w-0 shrink-0",children:[t.jsxs("button",{type:"button",onClick:()=>oe(!ae),className:`px-4 py-2 rounded-lg flex items-center justify-center gap-2 transition-colors w-full sm:w-auto ${ae||Dt?"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(Hs,{}),"Filters",le>0&&t.jsx("span",{className:"bg-indigo-600 text-white text-xs px-1.5 py-0.5 rounded-full",children:le})]}),t.jsxs("button",{type:"button",onClick:Ve,disabled:ft,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 justify-center gap-2 disabled:opacity-50 w-full sm:w-auto",children:[t.jsx(Ui,{className:ft?"animate-spin":""}),"Refresh"]}),t.jsxs("button",{type:"button",onClick:()=>S(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center justify-center gap-2 shadow disabled:opacity-50 w-full sm:w-auto",disabled:Je===0,children:[t.jsx(Ks,{}),t.jsx("span",{className:"font-medium",children:e("listPages.export")}),y.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:y.size})]}),z&&t.jsxs("button",{type:"button",onClick:()=>r("/sla/new"),className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg flex items-center justify-center gap-2 shadow-lg w-full sm:w-auto",children:[t.jsx(Js,{}),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:Je})]}),t.jsx(ff,{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:It.filter(ze=>ze.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(Hm,{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:It.filter(ze=>ze.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(fy,{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:It.filter(ze=>ze.service_contract_status==="Active"||ze.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:"✓"})})]})})]}),ae&&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(Hs,{className:"text-white",size:16}),t.jsx("h3",{className:"text-white font-semibold text-sm",children:"Filters"}),le>0&&t.jsx("span",{className:"bg-white text-indigo-600 px-2 py-0.5 rounded-full text-xs font-bold",children:le})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[le>0&&t.jsxs("button",{onClick:()=>Be(!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(bs,{size:12}),"Save"]}),Dt&&t.jsxs("button",{onClick:qe,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(Pt,{size:12}),"Clear"]})]})]})}),t.jsxs("div",{className:"p-4",children:[Z.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(ul,{className:"text-yellow-500",size:12}),"Saved Filters"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:Z.map(ze=>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:()=>yt(ze),className:"text-xs font-medium text-indigo-700 dark:text-indigo-300",children:ze.name}),t.jsx("button",{onClick:()=>St(ze.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700",children:t.jsx(la,{size:10})})]},ze.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:X,onChange:ze=>{const nt=ze.target.value;B(nt),c(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")})]})]}),X&&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:Y,onChange:ze=>{const nt=ze.target.value;G(nt),ie&&nt>ie&&fe(nt),c(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:ie,onChange:ze=>{fe(ze.target.value),c(1)},min:Y||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:K,onChange:ze=>{ke(ze.target.value),c(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:ge,onChange:ze=>{re(ze.target.value),c(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:we,onChange:ze=>{ee(ze.target.value),c(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:ve,onChange:ze=>{ce(ze.target.value),c(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-10 lg:z-[60]",children:[t.jsx(hr,{label:"Vendor",doctype:"Supplier",value:ye,onChange:ze=>{te(ze),c(1)},placeholder:"Select Vendor",disabled:!1,compact:!0}),ye&&t.jsx("button",{onClick:()=>te(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 z-10",children:t.jsx(Pt,{size:10})})]}),t.jsxs("div",{className:"relative z-10 lg:z-[59]",children:[t.jsx(hr,{label:"Asset",doctype:"Asset",value:q,onChange:ze=>{J(ze),c(1)},placeholder:"Select Asset",disabled:!1,compact:!0}),q&&t.jsx("button",{onClick:()=>J(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 z-10",children:t.jsx(Pt,{size:10})})]})]})})]})]}),Pe&&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:pe,onChange:ze=>rt(ze.target.value),onKeyDown:ze=>{ze.key==="Enter"&&ar()},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:()=>{Be(!1),rt("")},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:ar,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(bs,{size:12}),e("common.saveFilter")]})]})]})}),t.jsx(rY,{isOpen:E,onClose:()=>S(!1),selectedCount:y.size,totalCount:Je,pageCount:It.length,onExport:qt,isExporting:A,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:[ft&&h&&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:Yt,className:"text-gray-500 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400",title:Ye?"Deselect all":"Select all",children:Ye?t.jsx(jn,{className:"text-indigo-600 dark:text-indigo-400",size:18}):wt?t.jsxs("div",{className:"relative",children:[t.jsx(ys,{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(ys,{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:It.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(ff,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("supportPlans.noSupportPlansFound","No support plans found")}),Dt?t.jsx("button",{onClick:qe,className:"mt-4 text-indigo-600 dark:text-indigo-400 hover:underline",children:e("common.clearFilters")}):z?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]})})}):It.map(ze=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 cursor-pointer transition-colors ${y.has(ze.name)?"bg-indigo-50 dark:bg-indigo-900/20":""}`,onClick:()=>r(`/sla/${ze.name}`),children:[t.jsx("td",{className:"px-4 py-3",onClick:nt=>nt.stopPropagation(),children:t.jsx("button",{onClick:()=>Ot(ze.name),className:"text-gray-500 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400",children:y.has(ze.name)?t.jsx(jn,{className:"text-indigo-600 dark:text-indigo-400",size:18}):t.jsx(ys,{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:ze.support_plan||ze.name}),ze.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(Md,{size:10})," ",ze.asset]})]})}),t.jsx("td",{className:"px-4 py-3",children:ze.custom_contractwarranty?t.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${aY(ze.custom_contractwarranty)}`,children:ze.custom_contractwarranty}):t.jsx("span",{className:"text-gray-400",children:"-"})}),t.jsx("td",{className:"px-4 py-3",children:ze.frequency?t.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${sY(ze.frequency)}`,children:ze.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:Rt(ze.custom_contract_value)})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex flex-col gap-1",children:[ze.custom_contractwarranty==="Warranty"&&ze.war_status&&t.jsxs("span",{className:`inline-flex px-2 py-0.5 text-[10px] font-medium rounded-full ${f4(ze.war_status)}`,children:[e("supportPlans.statusLabel.warrantyPrefix","W:")," ",e(`supportPlans.status.${ze.war_status.toLowerCase().replace(/\\s+/g,"_")}`,ze.war_status)]}),ze.custom_contractwarranty==="Contract"&&ze.service_contract_status&&t.jsxs("span",{className:`inline-flex px-2 py-0.5 text-[10px] font-medium rounded-full ${f4(ze.service_contract_status)}`,children:[e("supportPlans.statusLabel.contractPrefix","C:")," ",e(`supportPlans.status.${ze.service_contract_status.toLowerCase().replace(/\\s+/g,"_")}`,ze.service_contract_status)]}),!ze.war_status&&!ze.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:ze.vendor||"-"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-1",onClick:nt=>nt.stopPropagation(),children:[t.jsx("button",{onClick:()=>r(`/sla/${ze.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(to,{})}),t.jsx("button",{onClick:()=>r(`/sla/${ze.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(Ms,{})}),R&&t.jsx("button",{onClick:()=>M(ze.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(la,{})})]})})]},ze.name))})]})}),t.jsx(ed,{currentPage:i,totalCount:Je,pageSize:u,itemLabel:e("pagination.plans"),onPageChange:ze=>c(ze)})]}),O&&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(la,{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"),":"]})," ",O]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>M(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:()=>kt(O),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(la,{}),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; }
`})]})},h4=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"}}},iY=()=>{var oe,le;const{t:e}=Rr(),{slaName:r}=ml(),[a]=Sn(),s=Na(),n=r==="new",i=a.get("edit")==="true",[c,u]=_.useState(!0),[h,g]=_.useState(!1),[y,w]=_.useState([]),[E,S]=_.useState(!1),[A,C]=_.useState(!1),[O,M]=_.useState(!1),[R,F]=_.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:z,loading:W,error:X,refetch:B}=eY(n?null:r||null),{createSupportPlan:Y,updateSupportPlan:G,deleteSupportPlan:ie,loading:fe}=tY(),[K,ke]=_.useState(n||i),ge=_.useCallback(()=>me(null,null,function*(){if(!(n||!r)){S(!0);try{const Z=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(Z!=null&&Z.data&&Z.data.length>0){const Le=Z.data.map(Pe=>{let Be={changed:[]};try{Be=JSON.parse(Pe.data||"{}")}catch(pe){}return{name:Pe.name,owner:Pe.owner,creation:Pe.creation,changes:(Be.changed||[]).map(pe=>({field:pe[0]||"",oldValue:pe[1],newValue:pe[2]}))}});w(Le)}else w([])}catch(be){console.error("Error fetching audit logs:",be),w([])}finally{S(!1)}}}),[n,r]);_.useEffect(()=>{ge()},[ge]),_.useEffect(()=>{z&&!n&&(F({support_plan:z.support_plan||"",frequency:z.frequency||"Quarterly",max_downtime_hrs:z.max_downtime_hrs||0,asset:z.asset||null,starting_date:z.starting_date||null,penalty_factor:z.penalty_factor||5,custom_contractwarranty:z.custom_contractwarranty||"Contract",custom_contract_value:z.custom_contract_value||"",warranty:z.warranty||0,warranty_start_date:z.warranty_start_date||null,warranty_end_date:z.warranty_end_date||null,war_status:z.war_status||"Active",extended_warranty:z.extended_warranty||0,start:z.start||null,end:z.end||null,service_contract:z.service_contract||0,spare_parts:z.spare_parts||0,spare_parts_labour:z.spare_parts_labour||0,labour:z.labour||0,ppm_only:z.ppm_only||0,no:z.no||0,start_date:z.start_date||null,end_date:z.end_date||null,service_contract_status:z.service_contract_status||"Active",vendor:z.vendor||null,asset_list:z.asset_list||[]}),i||ke(!1))},[z,n,i]);const re=be=>{const{name:Z,value:Le,type:Pe}=be.target;F(Pe==="checkbox"?Be=>Ke(Te({},Be),{[Z]:be.target.checked?1:0}):Pe==="number"?Be=>Ke(Te({},Be),{[Z]:parseFloat(Le)||0}):Be=>Ke(Te({},Be),{[Z]:Le}))},we=()=>me(null,null,function*(){var be;if(!((be=R.support_plan)!=null&&be.trim())){Mt.error("Support Plan Name is required",{position:"top-right",autoClose:5e3,icon:t.jsx(Br,{})});return}try{if(n){const Z=yield Y(R);Mt.success("Support Plan created successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),s(`/sla/${Z.name}`)}else yield G(r,R),Mt.success("Support Plan updated successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),ke(!1),B(),setTimeout(()=>ge(),500)}catch(Z){const Le=Z instanceof Error?Z.message:"Unknown error";Mt.error(`Failed to save: ${Le}`,{position:"top-right",autoClose:6e3,icon:t.jsx(Br,{})})}}),ee=()=>me(null,null,function*(){try{yield ie(r),Mt.success("Support Plan deleted successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),s(-1)}catch(be){const Z=be instanceof Error?be.message:"Unknown error";Mt.error(`Failed to delete: ${Z}`,{position:"top-right",autoClose:6e3,icon:t.jsx(Br,{})})}}),ve=_.useCallback(be=>!K,[K]),ce=be=>be.replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,Z=>Z.toUpperCase()),ye=be=>be==null||be===""?"(empty)":String(be),te=be=>{if(!be)return"";const Z=new Date(be),Le=new Date,Pe=Le.getTime()-Z.getTime(),Be=Math.floor(Pe/6e4),pe=Math.floor(Pe/36e5),rt=Math.floor(Pe/864e5);return Be<1?"Just now":Be<60?`${Be} min${Be>1?"s":""} ago`:pe<24?`${pe} hour${pe>1?"s":""} ago`:rt<7?`${rt} day${rt>1?"s":""} ago`:Z.toLocaleDateString("en-US",{month:"short",day:"numeric",year:Z.getFullYear()!==Le.getFullYear()?"numeric":void 0,hour:"2-digit",minute:"2-digit"})},q=be=>be?be.split("@")[0]:"Unknown";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-indigo-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading support plan..."})]})});if(X&&!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:X}),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 J=h4(R.war_status||""),ae=h4(R.service_contract_status||"");return t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[t.jsx(xc,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:Ll}),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(Kn,{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":R.support_plan||(z==null?void 0:z.name)||"Support Plan Details",!n&&R.custom_contractwarranty&&t.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-medium ${R.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:R.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&&!K&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>ke(!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(Ms,{}),"Edit"]}),c&&t.jsxs("button",{onClick:()=>g(!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(la,{}),"Delete"]})]}),K&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{n?s(-1):(ke(!1),B())},className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg",children:"Cancel"}),t.jsxs("button",{onClick:we,disabled:fe,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(bs,{}),fe?"Saving...":"Save"]})]})]})]}),h&&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(Jr,{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:()=>g(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",children:"Cancel"}),t.jsx("button",{onClick:ee,disabled:fe,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg disabled:opacity-50",children:fe?"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(ff,{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:R.support_plan||"",onChange:re,disabled:ve("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:R.custom_contractwarranty||"",onChange:re,disabled:ve("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:R.frequency||"",onChange:re,disabled:ve("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:R.custom_contract_value||"",onChange:re,disabled:ve("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(hr,{label:"Asset",doctype:"Asset",value:R.asset||"",onChange:be=>F(Ke(Te({},R),{asset:be||null})),disabled:ve("asset"),placeholder:"Select Asset"})}),t.jsx("div",{children:t.jsx(hr,{label:"Vendor",doctype:"Supplier",value:R.vendor||"",onChange:be=>F(Ke(Te({},R),{vendor:be||null})),disabled:ve("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(Hm,{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:R.max_downtime_hrs||0,onChange:re,disabled:ve("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:R.penalty_factor||0,onChange:re,disabled:ve("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:R.starting_date||"",onChange:re,disabled:ve("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(fy,{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:!!R.warranty,onChange:re,disabled:ve("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:!!R.extended_warranty,onChange:re,disabled:ve("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:R.war_status||"",onChange:re,disabled:ve("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:R.warranty_start_date||"",onChange:re,disabled:ve("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:R.warranty_end_date||"",onChange:re,disabled:ve("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(Md,{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:!!R.service_contract,onChange:re,disabled:ve("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:R.service_contract_status||"",onChange:re,disabled:ve("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:R.start_date||"",onChange:re,disabled:ve("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:R.end_date||"",onChange:re,disabled:ve("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:!!R.spare_parts,onChange:re,disabled:ve("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:!!R.spare_parts_labour,onChange:re,disabled:ve("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:!!R.labour,onChange:re,disabled:ve("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:!!R.ppm_only,onChange:re,disabled:ve("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(Kd,{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(ff,{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 ${R.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 ${R.custom_contractwarranty==="Contract"?"text-blue-700 dark:text-blue-300":"text-purple-700 dark:text-purple-300"}`,children:R.custom_contractwarranty||"Not Set"})]}),R.custom_contractwarranty==="Warranty"&&t.jsxs("div",{className:`p-3 rounded-lg border ${J.bg} ${J.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 ${J.text}`,children:R.war_status||"Not Set"})]}),R.custom_contractwarranty==="Contract"&&t.jsxs("div",{className:`p-3 rounded-lg border ${ae.bg} ${ae.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 ${ae.text}`,children:R.service_contract_status||"Not Set"})]}),R.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:R.frequency})]}),R.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(R.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($o,{className:"text-orange-500",size:14}),"Quick Info"]}),t.jsxs("div",{className:"space-y-2 text-sm",children:[R.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:R.asset})]}),R.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:R.vendor})]}),((oe=R.max_downtime_hrs)!=null?oe: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:[R.max_downtime_hrs," hrs"]})]}),((le=R.penalty_factor)!=null?le: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:[R.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:()=>C(!A),children:[t.jsx(Id,{className:"text-blue-500",size:14}),t.jsx("h2",{className:"text-sm font-semibold text-gray-800 dark:text-white",children:"Activity Log"}),y.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:y.length})]}),t.jsx("button",{onClick:()=>C(!A),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-1",children:A?t.jsx(Mn,{size:12}):t.jsx(on,{size:12})})]}),A&&t.jsx("div",{className:"p-3",children:E?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..."})]}):y.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:(O?y:y.slice(0,5)).map((be,Z)=>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 ${Z===0?"bg-blue-500":"bg-gray-300 dark:bg-gray-600"}`}),t.jsxs("div",{className:`p-2 rounded-lg ${Z===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:q(be.owner)}),t.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-500",children:[t.jsx(Ja,{size:8}),te(be.creation)]})]}),be.changes.length>0?be.changes.map((Le,Pe)=>t.jsxs("div",{className:"text-[10px]",children:[t.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:ce(Le.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:ye(Le.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:ye(Le.newValue)})]},Pe)):t.jsx("p",{className:"text-[10px] text-gray-500 italic",children:"Document updated"})]})]},be.name))}),y.length>5&&t.jsx("div",{className:"mt-3 text-center",children:t.jsx("button",{onClick:()=>M(!O),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:O?t.jsxs(t.Fragment,{children:[t.jsx(Mn,{size:8}),"Show Less"]}):t.jsxs(t.Fragment,{children:[t.jsx(on,{size:8}),"Show All (",y.length,")"]})})}),(z==null?void 0:z.creation)&&(z==null?void 0:z.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:q(z.owner)}),t.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-500",children:[t.jsx(Ja,{size:8}),te(z.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(Tr,{size:8}),"Created this Support Plan"]})]})]})]})})]})]})]})]})},oY=()=>me(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 c=i.message;return c.roles||(c.roles=[]),c}throw new Error("Failed to fetch user profile")}catch(r){throw console.error("Error fetching user profile:",r),r}}),lY=(e,r)=>me(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}}),cY=(e,r)=>me(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}}),dY=()=>{const e=Na(),[r,a]=_.useState(!0),[s,n]=_.useState(!1),[i,c]=_.useState(!1),[u,h]=_.useState(null),[g,y]=_.useState(null),[w,E]=_.useState({first_name:"",middle_name:"",last_name:"",role_profile_name:"",custom_user_id:""}),[S,A]=_.useState(!1),[C,O]=_.useState({old_password:"",new_password:"",confirm_password:""}),[M,R]=_.useState(!1),[F,z]=_.useState(!1),[W,X]=_.useState(!1);_.useEffect(()=>{me(null,null,function*(){try{a(!0);const K=yield oY();console.log("Full profile data:",JSON.stringify(K,null,2)),console.log("role_profile_name:",K.role_profile_name),console.log("All keys:",Object.keys(K)),h(K),E({first_name:K.first_name||"",middle_name:K.middle_name||"",last_name:K.last_name||"",role_profile_name:K.role_profile_name||"",custom_user_id:K.custom_user_id||""}),console.log("FormData role_profile_name:",K.role_profile_name||"")}catch(K){const ke=K instanceof Error?K.message:"Failed to load profile";y(ke),Mt.error(ke,{position:"top-right",autoClose:5e3,icon:t.jsx(Br,{})})}finally{a(!1)}})},[]);const B=fe=>{const{name:K,value:ke}=fe.target;E(ge=>Ke(Te({},ge),{[K]:ke}))},Y=fe=>{const{name:K,value:ke}=fe.target;O(ge=>Ke(Te({},ge),{[K]:ke}))},G=()=>me(null,null,function*(){if(u!=null&&u.email)try{n(!0);const fe={first_name:w.first_name,middle_name:w.middle_name,last_name:w.last_name},K=yield lY(u.email,fe);h(ke=>ke?Te(Te({},ke),K):K),Mt.success("Profile updated successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})})}catch(fe){const K=fe instanceof Error?fe.message:"Failed to update profile";Mt.error(K,{position:"top-right",autoClose:5e3,icon:t.jsx(Br,{})})}finally{n(!1)}}),ie=()=>me(null,null,function*(){if(!C.old_password){Mt.error("Please enter your current password",{position:"top-right",autoClose:3e3,icon:t.jsx(Jr,{})});return}if(!C.new_password){Mt.error("Please enter a new password",{position:"top-right",autoClose:3e3,icon:t.jsx(Jr,{})});return}if(C.new_password.length<8){Mt.error("Password must be at least 8 characters long",{position:"top-right",autoClose:3e3,icon:t.jsx(Jr,{})});return}if(C.new_password!==C.confirm_password){Mt.error("New passwords do not match",{position:"top-right",autoClose:3e3,icon:t.jsx(Jr,{})});return}try{c(!0),yield cY(C.new_password,C.old_password),Mt.success("Password changed successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Tr,{})}),O({old_password:"",new_password:"",confirm_password:""}),A(!1)}catch(fe){const K=fe instanceof Error?fe.message:"Failed to change password";Mt.error(K,{position:"top-right",autoClose:5e3,icon:t.jsx(Br,{})})}finally{c(!1)}});return r?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(Ir,{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..."})]})}):g&&!u?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(Br,{className:"inline mr-2"}),"Error Loading Profile"]}),t.jsx("p",{className:"text-red-700 dark:text-red-400",children:g}),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"})]})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[t.jsx(xc,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:Ll}),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(Kn,{}),t.jsx("span",{className:"text-gray-900 dark:text-white text-xl font-semibold",children:"User Profile"})]})}),t.jsx("button",{onClick:G,disabled:s,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:s?t.jsxs(t.Fragment,{children:[t.jsx(Ir,{className:"animate-spin"}),"Saving..."]}):t.jsxs(t.Fragment,{children:[t.jsx(bs,{}),"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:u!=null&&u.user_image?t.jsx("img",{src:u.user_image,alt:"Profile",className:"w-20 h-20 rounded-full object-cover"}):t.jsx(Yn,{className:"text-white text-4xl"})}),t.jsx("h2",{className:"text-xl font-bold text-white",children:(u==null?void 0:u.full_name)||"User"}),t.jsx("p",{className:"text-white/80 text-sm mt-1",children:u==null?void 0:u.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(rT,{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:(u==null?void 0:u.username)||"-"})]})]}),t.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx(dT,{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:(u==null?void 0:u.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(fy,{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 ${u!=null&&u.enabled?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:u!=null&&u.enabled?"Active":"Inactive"})]})]})]})]})}),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(Yn,{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(K4,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400",size:14}),t.jsx("input",{type:"email",value:(u==null?void 0:u.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:(u==null?void 0:u.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:B,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:B,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:B,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:B,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.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Role Profile"}),t.jsx("input",{type:"text",value:w.role_profile_name||(u==null?void 0:u.role_profile_name)||"",readOnly:!0,disabled:!0,placeholder:"Role Profile",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/60 text-gray-700 dark:text-gray-200 cursor-not-allowed"})]})]})]}),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(Mp,{className:"text-orange-500"}),"Change Password"]}),t.jsx("button",{onClick:()=>A(!S),className:"text-sm text-blue-600 dark:text-blue-400 hover:underline",children:S?"Cancel":"Change Password"})]}),S?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:M?"text":"password",name:"old_password",value:C.old_password,onChange:Y,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:()=>R(!M),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:M?t.jsx(Ip,{size:14}):t.jsx(to,{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:F?"text":"password",name:"new_password",value:C.new_password,onChange:Y,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:()=>z(!F),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:F?t.jsx(Ip,{size:14}):t.jsx(to,{size:14})})]}),C.new_password&&C.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:W?"text":"password",name:"confirm_password",value:C.confirm_password,onChange:Y,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:()=>X(!W),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:W?t.jsx(Ip,{size:14}):t.jsx(to,{size:14})})]}),C.confirm_password&&C.new_password!==C.confirm_password&&t.jsx("p",{className:"mt-1 text-xs text-red-500",children:"Passwords do not match"}),C.confirm_password&&C.new_password===C.confirm_password&&C.new_password.length>=8&&t.jsxs("p",{className:"mt-1 text-xs text-green-500 flex items-center gap-1",children:[t.jsx(Tr,{size:10})," Passwords match"]})]}),t.jsx("div",{className:"pt-2",children:t.jsx("button",{onClick:ie,disabled:i,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:i?t.jsxs(t.Fragment,{children:[t.jsx(Ir,{className:"animate-spin"}),"Changing Password..."]}):t.jsxs(t.Fragment,{children:[t.jsx(Mp,{}),"Change Password"]})})})]}):t.jsxs("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:[t.jsx(Mp,{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'})]})]})]})]})]})},uY=`
<h1>Privacy Policy</h1>
<p>Last updated: August 28, 2025</p>
<p>This Privacy Policy describes Our policies and procedures on the collection, use and disclosure of Your information when You use the Service and tells You about Your privacy rights and how the law protects You.</p>
<p>We use Your Personal data to provide and improve the Service. By using the Service, You agree to the collection and use of information in accordance with this Privacy Policy. This Privacy Policy has been created with the help of the <a href="https://www.termsfeed.com/privacy-policy-generator/" target="_blank" rel="noreferrer">Privacy Policy Generator</a>.</p>
<h2>Interpretation and Definitions</h2>
<h3>Interpretation</h3>
<p>The words of which the initial letter is capitalized have meanings defined under the following conditions. The following definitions shall have the same meaning regardless of whether they appear in singular or in plural.</p>
<h3>Definitions</h3>
<p>For the purposes of this Privacy Policy:</p>
<ul>
<li><p><strong>Account</strong> means a unique account created for You to access our Service or parts of our Service.</p></li>
<li><p><strong>Affiliate</strong> means an entity that controls, is controlled by or is under common control with a party, where "control" means ownership of 50% or more of the shares, equity interest or other securities entitled to vote for election of directors or other managing authority.</p></li>
<li><p><strong>Application</strong> refers to Seera ASM the software program provided by the Company.</p></li>
<li><p><strong>Company</strong> (referred to as either "the Company", "We", "Us" or "Our" in this Agreement) refers to Seera ASM</p></li>
<li><p><strong>Country</strong> refers to: Saudi Arabia</p></li>
<li><p><strong>Device</strong> means any device that can access the Service such as a computer, a cellphone or a digital tablet.</p></li>
<li><p><strong>Personal Data</strong> is any information that relates to an identified or identifiable individual.</p></li>
<li><p><strong>Service</strong> refers to the Application.</p></li>
<li><p><strong>Service Provider</strong> means any natural or legal person who processes the data on behalf of the Company. It refers to third-party companies or individuals employed by the Company to facilitate the Service, to provide the Service on behalf of the Company, to perform services related to the Service or to assist the Company in analyzing how the Service is used.</p></li>
<li><p><strong>Usage Data</strong> refers to data collected automatically, either generated by the use of the Service or from the Service infrastructure itself (for example, the duration of a page visit).</p></li>
<li><p><strong>You</strong> means the individual accessing or using the Service, or the company, or other legal entity on behalf of which such individual is accessing or using the Service, as applicable.</p></li>
</ul>
<h2>Collecting and Using Your Personal Data</h2>
<h3>Types of Data Collected</h3>
<h4>Personal Data</h4>
<p>While using Our Service, We may ask You to provide Us with certain personally identifiable information that can be used to contact or identify You. Personally identifiable information may include, but is not limited to:</p>
<ul>
<li><p>Email address</p></li>
<li><p>First name and last name</p></li>
<li><p>Address, State, Province, ZIP/Postal code, City</p></li>
<li><p>Usage Data</p></li>
</ul>
<h4>Usage Data</h4>
<p>Usage Data is collected automatically when using the Service.</p>
<p>Usage Data may include information such as Your Device's Internet Protocol address (e.g. IP address), browser type, browser version, the pages of our Service that You visit, the time and date of Your visit, the time spent on those pages, unique device identifiers and other diagnostic data.</p>
<p>When You access the Service by or through a mobile device, We may collect certain information automatically, including, but not limited to, the type of mobile device You use, Your mobile device unique ID, the IP address of Your mobile device, Your mobile operating system, the type of mobile Internet browser You use, unique device identifiers and other diagnostic data.</p>
<p>We may also collect information that Your browser sends whenever You visit our Service or when You access the Service by or through a mobile device.</p>
<h4>Information Collected while Using the Application</h4>
<p>While using Our Application, in order to provide features of Our Application, We may collect, with Your prior permission:</p>
<ul>
<li>Pictures and other information from your Device's camera and photo library</li>
</ul>
<p>We use this information to provide features of Our Service, to improve and customize Our Service. The information may be uploaded to the Company's servers and/or a Service Provider's server or it may be simply stored on Your device.</p>
<p>You can enable or disable access to this information at any time, through Your Device settings.</p>
<h3>Use of Your Personal Data</h3>
<p>The Company may use Personal Data for the following purposes:</p>
<ul>
<li><p><strong>To provide and maintain our Service</strong>, including to monitor the usage of our Service.</p></li>
<li><p><strong>To manage Your Account:</strong> to manage Your registration as a user of the Service. The Personal Data You provide can give You access to different functionalities of the Service that are available to You as a registered user.</p></li>
<li><p><strong>For the performance of a contract:</strong> the development, compliance and undertaking of the purchase contract for the products, items or services You have purchased or of any other contract with Us through the Service.</p></li>
<li><p><strong>To contact You:</strong> To contact You by email, telephone calls, SMS, or other equivalent forms of electronic communication, such as a mobile application's push notifications regarding updates or informative communications related to the functionalities, products or contracted services, including the security updates, when necessary or reasonable for their implementation.</p></li>
<li><p><strong>To provide You</strong> with news, special offers and general information about other goods, services and events which we offer that are similar to those that you have already purchased or enquired about unless You have opted not to receive such information.</p></li>
<li><p><strong>To manage Your requests:</strong> To attend and manage Your requests to Us.</p></li>
<li><p><strong>For business transfers:</strong> We may use Your information to evaluate or conduct a merger, divestiture, restructuring, reorganization, dissolution, or other sale or transfer of some or all of Our assets, whether as a going concern or as part of bankruptcy, liquidation, or similar proceeding, in which Personal Data held by Us about our Service users is among the assets transferred.</p></li>
<li><p><strong>For other purposes</strong>: We may use Your information for other purposes, such as data analysis, identifying usage trends, determining the effectiveness of our promotional campaigns and to evaluate and improve our Service, products, services, marketing and your experience.</p></li>
</ul>
<p>We may share Your personal information in the following situations:</p>
<ul>
<li><strong>With Service Providers:</strong> We may share Your personal information with Service Providers to monitor and analyze the use of our Service, to contact You.</li>
<li><strong>For business transfers:</strong> We may share or transfer Your personal information in connection with, or during negotiations of, any merger, sale of Company assets, financing, or acquisition of all or a portion of Our business to another company.</li>
<li><strong>With Affiliates:</strong> We may share Your information with Our affiliates, in which case we will require those affiliates to honor this Privacy Policy. Affiliates include Our parent company and any other subsidiaries, joint venture partners or other companies that We control or that are under common control with Us.</li>
<li><strong>With business partners:</strong> We may share Your information with Our business partners to offer You certain products, services or promotions.</li>
<li><strong>With other users:</strong> when You share personal information or otherwise interact in the public areas with other users, such information may be viewed by all users and may be publicly distributed outside.</li>
<li><strong>With Your consent</strong>: We may disclose Your personal information for any other purpose with Your consent.</li>
</ul>
<h3>Retention of Your Personal Data</h3>
<p>The Company will retain Your Personal Data only for as long as is necessary for the purposes set out in this Privacy Policy. We will retain and use Your Personal Data to the extent necessary to comply with our legal obligations (for example, if we are required to retain your data to comply with applicable laws), resolve disputes, and enforce our legal agreements and policies.</p>
<p>The Company will also retain Usage Data for internal analysis purposes. Usage Data is generally retained for a shorter period of time, except when this data is used to strengthen the security or to improve the functionality of Our Service, or We are legally obligated to retain this data for longer time periods.</p>
<h3>Transfer of Your Personal Data</h3>
<p>Your information, including Personal Data, is processed at the Company's operating offices and in any other places where the parties involved in the processing are located. It means that this information may be transferred to - and maintained on - computers located outside of Your state, province, country or other governmental jurisdiction where the data protection laws may differ than those from Your jurisdiction.</p>
<p>Your consent to this Privacy Policy followed by Your submission of such information represents Your agreement to that transfer.</p>
<p>The Company will take all steps reasonably necessary to ensure that Your data is treated securely and in accordance with this Privacy Policy and no transfer of Your Personal Data will take place to an organization or a country unless there are adequate controls in place including the security of Your data and other personal information.</p>
<h3>Delete Your Personal Data</h3>
<p>You have the right to delete or request that We assist in deleting the Personal Data that We have collected about You.</p>
<p>Our Service may give You the ability to delete certain information about You from within the Service.</p>
<p>You may update, amend, or delete Your information at any time by signing in to Your Account, if you have one, and visiting the account settings section that allows you to manage Your personal information. You may also contact Us to request access to, correct, or delete any personal information that You have provided to Us.</p>
<p>Please note, however, that We may need to retain certain information when we have a legal obligation or lawful basis to do so.</p>
<h3>Disclosure of Your Personal Data</h3>
<h4>Business Transactions</h4>
<p>If the Company is involved in a merger, acquisition or asset sale, Your Personal Data may be transferred. We will provide notice before Your Personal Data is transferred and becomes subject to a different Privacy Policy.</p>
<h4>Law enforcement</h4>
<p>Under certain circumstances, the Company may be required to disclose Your Personal Data if required to do so by law or in response to valid requests by public authorities (e.g. a court or a government agency).</p>
<h4>Other legal requirements</h4>
<p>The Company may disclose Your Personal Data in the good faith belief that such action is necessary to:</p>
<ul>
<li>Comply with a legal obligation</li>
<li>Protect and defend the rights or property of the Company</li>
<li>Prevent or investigate possible wrongdoing in connection with the Service</li>
<li>Protect the personal safety of Users of the Service or the public</li>
<li>Protect against legal liability</li>
</ul>
<h3>Security of Your Personal Data</h3>
<p>The security of Your Personal Data is important to Us, but remember that no method of transmission over the Internet, or method of electronic storage is 100% secure. While We strive to use commercially acceptable means to protect Your Personal Data, We cannot guarantee its absolute security.</p>
<h2>Children's Privacy</h2>
<p>Our Service does not address anyone under the age of 13. We do not knowingly collect personally identifiable information from anyone under the age of 13. If You are a parent or guardian and You are aware that Your child has provided Us with Personal Data, please contact Us. If We become aware that We have collected Personal Data from anyone under the age of 13 without verification of parental consent, We take steps to remove that information from Our servers.</p>
<p>If We need to rely on consent as a legal basis for processing Your information and Your country requires consent from a parent, We may require Your parent's consent before We collect and use that information.</p>
<h2>Links to Other Websites</h2>
<p>Our Service may contain links to other websites that are not operated by Us. If You click on a third party link, You will be directed to that third party's site. We strongly advise You to review the Privacy Policy of every site You visit.</p>
<p>We have no control over and assume no responsibility for the content, privacy policies or practices of any third party sites or services.</p>
<h2>Changes to this Privacy Policy</h2>
<p>We may update Our Privacy Policy from time to time. We will notify You of any changes by posting the new Privacy Policy on this page.</p>
<p>We will let You know via email and/or a prominent notice on Our Service, prior to the change becoming effective and update the "Last updated" date at the top of this Privacy Policy.</p>
<p>You are advised to review this Privacy Policy periodically for any changes. Changes to this Privacy Policy are effective when they are posted on this page.</p>
<h2>Contact Us</h2>
<p>If you have any questions about this Privacy Policy, You can contact us:</p>
<ul>
<li>By email: support@seeraarabia.com</li>
</ul>
`,fY=()=>t.jsx("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 px-4 py-8 sm:px-6 lg:px-8",children:t.jsx("div",{className:"mx-auto max-w-4xl rounded-xl border border-gray-200 bg-white p-6 shadow-sm dark:border-gray-700 dark:bg-gray-800 sm:p-8",children:t.jsx("article",{className:"privacy-policy-content text-sm leading-6 text-gray-700 dark:text-gray-200",dangerouslySetInnerHTML:{__html:uY}})})}),hY=({isOpen:e,onClose:r,columns:a,loading:s,onExport:n})=>{const{t:i}=Rr(),[c,u]=_.useState("xlsx"),[h,g]=_.useState(new Set),y=_.useMemo(()=>a.map(M=>M.key),[a]),w=_.useMemo(()=>new Set(a.filter(M=>M.mandatory).map(M=>M.key)),[a]);if(_.useEffect(()=>{if(!e||a.length===0)return;const M=a.filter(R=>R.mandatory);M.length>0?g(new Set(M.map(R=>R.key))):g(new Set(a.slice(0,Math.min(8,a.length)).map(R=>R.key)))},[e,a]),!e)return null;const E=M=>{g(R=>{const F=new Set(R);return F.has(M)?F.delete(M):F.add(M),F})},S=()=>g(new Set(y)),A=()=>g(new Set(w)),C=()=>g(new Set),O=()=>{h.size!==0&&n(Array.from(h),c)};return t.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-black/50 p-4 backdrop-blur-[2px]",children:t.jsxs("div",{className:"flex max-h-[90vh] w-full max-w-2xl flex-col overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-2xl dark:border-gray-700 dark:bg-gray-800",role:"dialog","aria-labelledby":"data-import-template-title",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 bg-gradient-to-r from-indigo-600 to-indigo-700 px-5 py-4 dark:from-indigo-800 dark:to-indigo-900",children:[t.jsx("h2",{id:"data-import-template-title",className:"text-lg font-semibold text-white",children:i("dataImport.templateModal.title")}),t.jsx("button",{type:"button",onClick:r,className:"rounded-lg p-1.5 text-white/90 transition hover:bg-white/10","aria-label":i("common.cancel"),children:t.jsx(Pt,{size:18})})]}),t.jsx("div",{className:"flex-1 overflow-y-auto p-5 sm:p-6",children:s?t.jsx("div",{className:"flex justify-center py-12 text-sm text-gray-500 dark:text-gray-400",children:i("common.loading")}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1.5 block text-xs font-semibold uppercase tracking-wide text-indigo-600 dark:text-indigo-400",children:i("dataImport.templateModal.fileType")}),t.jsxs("select",{value:c,onChange:M=>u(M.target.value),className:"w-full rounded-lg border border-gray-300 bg-white px-3 py-2.5 text-sm font-medium text-gray-900 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500 dark:border-gray-600 dark:bg-gray-900 dark:text-white",children:[t.jsx("option",{value:"xlsx",children:i("dataImport.templateModal.fileTypeExcel")}),t.jsx("option",{value:"csv",children:i("dataImport.templateModal.fileTypeCsv")})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1.5 block text-xs font-semibold uppercase tracking-wide text-indigo-600 dark:text-indigo-400",children:i("dataImport.templateModal.exportType")}),t.jsx("div",{className:"rounded-lg border border-gray-200 bg-gray-50 px-3 py-2.5 text-sm font-medium text-gray-800 dark:border-gray-600 dark:bg-gray-900/60 dark:text-gray-200",children:i("dataImport.templateModal.exportTypeBlank")})]})]}),t.jsx("p",{className:"mt-3 text-xs text-gray-500 dark:text-gray-400",children:i("dataImport.templateModal.blankHint")}),t.jsxs("div",{className:"mt-6",children:[t.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[t.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-indigo-600 dark:text-indigo-400",children:i("dataImport.templateModal.selectFields")}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx("button",{type:"button",onClick:S,className:"rounded-full border border-gray-200 bg-white px-3 py-1 text-xs font-medium text-gray-700 shadow-sm hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-800",children:i("dataImport.templateModal.selectAll")}),t.jsx("button",{type:"button",onClick:A,className:"rounded-full border border-gray-200 bg-white px-3 py-1 text-xs font-medium text-gray-700 shadow-sm hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-800",children:i("dataImport.templateModal.selectMandatory")}),t.jsx("button",{type:"button",onClick:C,className:"rounded-full border border-gray-200 bg-white px-3 py-1 text-xs font-medium text-gray-700 shadow-sm hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-800",children:i("dataImport.templateModal.unselectAll")})]})]}),t.jsx("div",{className:"grid max-h-64 grid-cols-1 gap-2 overflow-y-auto rounded-xl border border-gray-100 bg-gray-50/80 p-3 sm:grid-cols-2 dark:border-gray-700 dark:bg-gray-900/40",children:a.map(M=>{const R=h.has(M.key);return t.jsxs("label",{className:`flex cursor-pointer items-start gap-2.5 rounded-lg border px-3 py-2.5 text-sm transition ${R?"border-indigo-300 bg-indigo-50/90 dark:border-indigo-700 dark:bg-indigo-950/50":"border-transparent hover:bg-white dark:hover:bg-gray-800/80"}`,children:[t.jsx("input",{type:"checkbox",checked:R,onChange:()=>E(M.key),className:"mt-0.5 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"}),t.jsxs("span",{className:`leading-snug ${M.mandatory?"font-semibold text-red-600 dark:text-red-400":"font-medium text-gray-800 dark:text-gray-200"}`,children:[M.label,M.mandatory&&t.jsx("span",{className:"ms-1 text-red-500","aria-hidden":!0,children:"*"})]})]},M.key)})})]})]})}),t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-gray-100 bg-gray-50 px-5 py-4 dark:border-gray-700 dark:bg-gray-900/50",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400",children:[c==="xlsx"?t.jsx(zi,{className:"text-green-600"}):t.jsx(No,{className:"text-amber-600"}),h.size," ",i("dataImport.templateModal.fieldsSelected")]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"button",onClick:r,className:"rounded-lg px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-200/80 dark:text-gray-300 dark:hover:bg-gray-700",children:i("common.cancel")}),t.jsx("button",{type:"button",disabled:s||h.size===0,onClick:O,className:"rounded-lg bg-indigo-600 px-5 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-700 disabled:cursor-not-allowed disabled:opacity-50",children:i("dataImport.templateModal.export")})]})]})]})})};function eo(e){if(!e||typeof e!="string")return e;const r=e.trim();if(!r.includes("<"))return r;if(typeof document!="undefined"){const a=document.createElement("div");return a.innerHTML=r,(a.textContent||a.innerText||"").replace(/\s+/g," ").trim()}return r.replace(/<br\s*\/?>/gi," ").replace(/<\/(p|div|li|tr)>/gi," ").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim()}function dg(e){if(e==null)return"";const r=s=>{if(s==null)return[];if(typeof s=="string"){const n=s.trim();if(!n)return[];if(n.startsWith("[")||n.startsWith("{"))try{const i=JSON.parse(n);return r(i)}catch(i){return[eo(n)]}return[eo(n)]}if(Array.isArray(s)){const n=[];for(const i of s)if(i!=null&&typeof i=="object"&&"message"in i){const c=i.message;c!=null&&String(c).trim()!==""&&n.push(eo(String(c)))}else typeof i=="string"&&n.push(eo(i));return n}if(typeof s=="object"&&"message"in s){const n=s.message;if(n!=null)return[eo(String(n))]}return[eo(JSON.stringify(s))]};return r(e).filter(Boolean).join("; ")}function AS(e){if(!e)return"";let r=e.replace(/\r\n/g,`
`).trim();const a=r.search(/Traceback\s*\(most recent call last\)/i);if(a!==-1)r=r.slice(0,a).trim();else{const n=r.search(/\n\s*Traceback\b/i);n!==-1?r=r.slice(0,n).trim():/\bTraceback\b/i.test(r)&&(r=r.split(/\bTraceback\b/i)[0].trim())}return r=r.replace(/\s+[—–]\s*$/u,"").trim(),r=r.split(`
`).map(n=>n.trim()).filter(n=>n.length>0&&!/^\s*File\s+"/.test(n)).join(" ").replace(/\s+/g," ").trim(),r}const m4=new Set(["Tab Break","Section Break","Column Break","HTML","Button","Table","Heading"]),mY=new Set(["creation","modified","modified_by","owner","docstatus","idx","_user_tags","_comments","_assign","_liked_by"]);function gY(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function Hc(e){const r=eo(e);return r.length>600?`${r.slice(0,600)}…`:r}function cu(e){const r=e._server_messages;if(typeof r=="string")try{const n=JSON.parse(r);if(Array.isArray(n)&&n[0]&&typeof n[0]=="string"){const i=JSON.parse(n[0]);if(i!=null&&i.message&&!String(i.message).includes("Traceback"))return Hc(String(i.message))}}catch(n){}const a=e.message;if(typeof a=="string"&&a.length>0&&!a.includes("Traceback"))return Hc(a.length>500?`${a.slice(0,500)}…`:a);const s=e.exc;if(typeof s=="string"){const n=K1(s);if(n)return Hc(n)}if(typeof s=="string"&&s.trim().startsWith("["))try{const n=JSON.parse(s.trim());if(Array.isArray(n)&&n.length>0){const i=String(n[0]),c=K1(i);if(c)return Hc(c);if(!i.includes("Traceback"))return Hc(i.slice(0,500))}}catch(n){}return"Could not save the row. Please check the values and try again."}function K1(e){const r=e.trim();if(!r)return null;const a=r.match(/DuplicateEntryError:\s*\(\s*'([^']+)'\s*,\s*'([^']+)'/);if(a)return`${a[1]} ${a[2]} already exists`;const s=r.match(/Duplicate entry\s+'([^']+)'\s+for\s+key\s+'PRIMARY'/i);if(s)return`Duplicate entry: "${s[1]}" already exists (primary key / document name).`;const n=r.match(/Duplicate entry\s+"([^"]+)"\s+for\s+key\s+'PRIMARY'/i);if(n)return`Duplicate entry: "${n[1]}" already exists (primary key / document name).`;const i=r.match(/(?:ValidationError|MandatoryError)\s*:\s*([^\n]+?)(?:\s*Traceback|$)/i);if(i!=null&&i[1]&&!i[1].includes('File "')){const h=i[1].trim();if(h.length>0&&h.length<400)return h}const c=r.match(/Duplicate entry\s+['"]([^'"]+)['"]/i);if(c)return`Duplicate entry: "${c[1]}" already exists.`;if(/IntegrityError|1062/i.test(r)&&/duplicate/i.test(r))return"Duplicate entry: this row conflicts with an existing record (same unique ID).";const u=r.split(`
`).map(h=>h.trim());for(let h=u.length-1;h>=0;h--){const g=u[h];if(!(!g||g.startsWith("File "))&&(g.includes("Could not find")||g.includes("ValidationError")||g.includes("MandatoryError")||g.includes("LinkValidationError"))){const y=g.replace(/^[^:]+:\s*/,"").slice(0,400);if(y&&!y.includes("Traceback"))return y}}return r.includes("Traceback")?"Could not save this row (server rejected the data). See the message above if any, or check required fields and links.":r.length>400?`${r.slice(0,400)}…`:r}function xY(e){return me(this,null,function*(){var h;const r=yield e.arrayBuffer(),a=Z0(r,{type:"array",cellDates:!0}),s=a.SheetNames[0];if(!s)throw new Error("EMPTY_WORKBOOK");const n=a.Sheets[s],i=Ur.sheet_to_json(n,{header:1,defval:"",raw:!0}),c=i.length>0?((h=i[0])!=null?h:[]).map(g=>String(g!=null?g:"").trim()):[],u=Ur.sheet_to_json(n,{defval:"",raw:!0});return{headersOrdered:c,rows:u}})}function pY(e,r){const a=[],s=OS(r),n=new Map;for(let i=0;i<e.length;i++){const c=e[i];if(!c)continue;const u=gY(c);if(n.has(u)){const h=n.get(u)+1;a.push({rowIndex:1,success:!1,message:`Duplicate column "${c}" — columns ${h} and ${i+1} use the same header. Remove or rename one.`});continue}n.set(u,i),s(c)||a.push({rowIndex:1,success:!1,message:`Column ${i+1} (${c}): not recognized. Use the same headers as the Download template (first row), or the exact field names.`})}return a}function OS(e){const r=s=>s.trim().toLowerCase().replace(/\s+/g," "),a=new Map;for(const s of e)a.set(r(s.label),s.key),a.set(r(s.key),s.key);return s=>a.get(r(s))}function yY(e,r,a="location_import_template"){const s=e.length>0?e.map(c=>c.label):["location_name","company"],n=Ur.aoa_to_sheet([s]);if(r==="csv"){const c=Ur.sheet_to_csv(n),u=new Blob([c],{type:"text/csv;charset=utf-8;"}),h=document.createElement("a"),g=URL.createObjectURL(u);h.href=g,h.download=`${a}.csv`,h.click(),URL.revokeObjectURL(g);return}const i=Ur.book_new();Ur.book_append_sheet(i,n,"Location"),jo(i,`${a}.xlsx`)}function bY(e,r){return me(this,null,function*(){var A;const a=yield e.arrayBuffer(),s=Z0(a,{type:"array",cellDates:!0}),n=s.SheetNames[0];if(!n)return e;const i=s.Sheets[n],c=Ur.sheet_to_json(i,{header:1,defval:"",raw:!0});if(c.length===0)return e;const u=OS(r),g=((A=c[0])!=null?A:[]).map(C=>{const O=String(C!=null?C:"").trim();return O?u(O)||O:""});if(c[0]=g,e.name.toLowerCase().endsWith(".csv")){const C=Ur.aoa_to_sheet(c),O=Ur.sheet_to_csv(C);return new File([O],e.name,{type:"text/csv;charset=utf-8;"})}const w=Ur.book_new(),E=Ur.aoa_to_sheet(c);Ur.book_append_sheet(w,E,n);const S=Jf(w,{bookType:"xlsx",type:"array"});return new File([S],e.name,{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})})}function vY(e){const r=n=>{if(!n||typeof n!="object"||Array.isArray(n))return null;const i=n;return typeof i.name=="string"&&i.name.trim()?i.name.trim():i.data!=null&&typeof i.data=="object"?r(i.data):null},a=r(e.data);if(a)return a;const s=e.message;return s!=null&&typeof s!="string"?r(s):null}function DS(e){return me(this,null,function*(){var c,u,h;const r=e.trim();if(!r)return null;const a=g=>me(null,null,function*(){return(yield fetch(`/api/resource/Department/${encodeURIComponent(g)}`,{credentials:"include"})).ok?g:null});let s=yield a(r);if(s)return s;const n=r.includes(" - ")?r.split(" - ")[0].trim():r;if(n!==r&&(s=yield a(n),s))return s;const i=n!==r?[n,r]:[r];for(const g of i){const y=encodeURIComponent(JSON.stringify([["name","like",`${g}%`]])),w=yield fetch(`/api/resource/Department?fields=["name","department_name"]&filters=${y}&limit_page_length=100`,{credentials:"include"});if(!w.ok)continue;const S=(c=(yield w.json()).data)!=null?c:[],A=S.find(O=>O.name===g);if(A)return A.name;const C=S.filter(O=>O.name.startsWith(`${g} -`)).sort((O,M)=>O.name.length-M.name.length||O.name.localeCompare(M.name));if(C[0])return C[0].name}for(const g of i){const y=encodeURIComponent(JSON.stringify([["department_name","=",g]])),w=yield fetch(`/api/resource/Department?fields=["name","department_name"]&filters=${y}&limit_page_length=20`,{credentials:"include"});if(w.ok){const C=(u=(yield w.json()).data)==null?void 0:u[0];if(C!=null&&C.name)return C.name}const E=encodeURIComponent(JSON.stringify([["department_name","like",`${g}%`]])),S=yield fetch(`/api/resource/Department?fields=["name","department_name"]&filters=${E}&limit_page_length=50`,{credentials:"include"});if(S.ok){const C=(h=(yield S.json()).data)!=null?h:[],O=R=>R.trim().toLowerCase(),M=C.find(R=>R.department_name&&O(R.department_name)===O(g));if(M!=null&&M.name)return M.name;if(C.length===1&&C[0].name)return C[0].name}}return null})}function wY(e,r,a){return me(this,null,function*(){var R,F,z,W,X;const s=yield e.arrayBuffer(),n=Z0(s,{type:"array",cellDates:!0}),i=n.SheetNames[0];if(!i)return e;const c=n.Sheets[i],u=Ur.sheet_to_json(c,{header:1,defval:"",raw:!0});if(u.length<2)return e;const g=((R=u[0])!=null?R:[]).map(B=>String(B!=null?B:"").trim()).findIndex(B=>B==="department");if(g===-1)return e;const y=new Set;for(let B=1;B<u.length;B++){const G=((F=u[B])!=null?F:[])[g],ie=G!=null&&G!==""?String(G).trim():"";ie&&y.add(ie)}if(y.size===0)return e;const w=(z=a==null?void 0:a.preferredNames)!=null?z:{},E=new Map,S=B=>me(null,null,function*(){var fe;if(E.has(B))return E.get(B);const Y=B.trim();if(!Y)return E.set(B,B),B;const G=(fe=w[B])!=null?fe:w[Y];if(G&&String(G).trim()!==""){const K=String(G).trim();return E.set(B,K),K}const ie=yield DS(Y);return ie?(E.set(B,ie),ie):(E.set(B,Y),Y)});yield Promise.all([...y].map(B=>S(B)));for(let B=1;B<u.length;B++){const Y=(W=u[B])!=null?W:[],G=Y[g],ie=G!=null&&G!==""?String(G).trim():"";if(!ie)continue;const fe=(X=E.get(ie))!=null?X:ie,K=[...Y];for(;K.length<=g;)K.push("");K[g]=fe,u[B]=K}if(e.name.toLowerCase().endsWith(".csv")){const B=Ur.aoa_to_sheet(u),Y=Ur.sheet_to_csv(B);return new File([Y],e.name,{type:"text/csv;charset=utf-8;"})}const C=Ur.book_new(),O=Ur.aoa_to_sheet(u);Ur.book_append_sheet(C,O,i);const M=Jf(C,{bookType:"xlsx",type:"array"});return new File([M],e.name,{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})})}function Sm(e){return e.trim().toLowerCase().replace(/#/g," ").replace(/\bbldg\b/g,"building").replace(/\s+/g," ").trim()}function _Y(e,r,a){return me(this,null,function*(){var W,X,B,Y,G,ie,fe;const s=[],n=yield e.arrayBuffer(),i=Z0(n,{type:"array",cellDates:!0}),c=i.SheetNames[0];if(!c)return{file:e,mappingMessages:s};const u=i.Sheets[c],h=Ur.sheet_to_json(u,{header:1,defval:"",raw:!0});if(h.length<2)return{file:e,mappingMessages:s};const y=((W=h[0])!=null?W:[]).map(K=>String(K!=null?K:"").trim()).findIndex(K=>K==="building");if(y===-1)return{file:e,mappingMessages:s};const w=yield fetch('/api/resource/Building?fields=["name"]&limit_page_length=10000',{credentials:"include"});if(!w.ok)return{file:e,mappingMessages:s};const S=((X=(yield w.json()).data)!=null?X:[]).map(K=>K.name).filter(Boolean);if(S.length===0)return{file:e,mappingMessages:s};const A=new Set;for(let K=1;K<h.length;K++){const ge=((B=h[K])!=null?B:[])[y],re=ge!=null&&ge!==""?String(ge).trim():"";re&&A.add(re)}if(A.size===0)return{file:e,mappingMessages:s};const C=K=>{const ke=K.trim();if(!ke)return{canonical:ke,note:null};const ge=S.find(ye=>ye.toLowerCase()===ke.toLowerCase());if(ge)return ge!==ke?{canonical:ge,note:`Building: "${K}" → "${ge}" (matched existing master, case/spelling).`}:{canonical:ge,note:null};const re=Sm(ke),we=S.find(ye=>Sm(ye)===re);if(we)return{canonical:we,note:`Building: "${K}" → "${we}" (matched existing master).`};const ee=ke.replace(/\s+/g,"");if(/^-?\d+$/.test(ee)){const te=ee.replace(/^-/,"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),q=S.filter(ae=>{const oe=ae.replace(/#/g," ").toLowerCase();return new RegExp(`building\\s*#?\\s*${te}\\b`,"i").test(oe)||new RegExp(`bldg\\s*#?\\s*${te}\\b`,"i").test(oe)}),J=[...new Set(q)];if(J.length===1)return{canonical:J[0],note:`Building: "${K}" → "${J[0]}" (mapped to existing master; file value was numeric only).`}}const ve=ke.replace(/\s*-\s*/g,"-").trim(),ce=S.find(ye=>Sm(ye)===Sm(ve));return ce?{canonical:ce,note:`Building: "${K}" → "${ce}" (matched existing master).`}:{canonical:ke,note:null}},O=(Y=a==null?void 0:a.preferredNames)!=null?Y:{},M=new Map,R=new Set;for(const K of A){const ke=(G=O[K])!=null?G:O[K.trim()];if(ke&&String(ke).trim()!==""){const we=String(ke).trim();if(M.set(K,we),we!==K){const ee=`Building: "${K}" → "${we}" (matched newly created / linked master).`;R.has(ee)||(R.add(ee),s.push(ee))}continue}const{canonical:ge,note:re}=C(K);M.set(K,ge),re&&!R.has(re)&&(R.add(re),s.push(re))}for(let K=1;K<h.length;K++){const ke=(ie=h[K])!=null?ie:[],ge=ke[y],re=ge!=null&&ge!==""?String(ge).trim():"";if(!re)continue;const we=(fe=M.get(re))!=null?fe:re,ee=[...ke];for(;ee.length<=y;)ee.push("");ee[y]=we,h[K]=ee}const F=e.name.toLowerCase().endsWith(".csv");let z;if(F){const K=Ur.aoa_to_sheet(h),ke=Ur.sheet_to_csv(K);z=new File([ke],e.name,{type:"text/csv;charset=utf-8;"})}else{const K=Ur.book_new(),ke=Ur.aoa_to_sheet(h);Ur.book_append_sheet(K,ke,c);const ge=Jf(K,{bookType:"xlsx",type:"array"});z=new File([ge],e.name,{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}return{file:z,mappingMessages:s}})}function RS(){var e;return typeof window=="undefined"?"":window.csrf_token||((e=document.cookie.split("; ").find(r=>r.startsWith("csrf_token=")))==null?void 0:e.split("=")[1])||""}function Jd(){return{"Content-Type":"application/json","X-Frappe-CSRF-Token":RS()}}function kY(e){return me(this,null,function*(){var c;const r=new FormData;r.append("file",e),r.append("is_private","0"),r.append("folder","Home");const a=yield fetch("/api/method/upload_file",{method:"POST",credentials:"include",headers:{"X-Frappe-CSRF-Token":RS()},body:r}),s=yield a.json();if(!a.ok)throw new Error(cu(s));const n=s.message,i=typeof n=="object"&&n!==null?n.file_url||((c=n.message)==null?void 0:c.file_url):void 0;if(!i)throw new Error("Upload did not return a file URL");return i})}function g4(e){return me(this,null,function*(){const r=yield fetch("/api/resource/Data Import",{method:"POST",headers:Jd(),credentials:"include",body:JSON.stringify({reference_doctype:e.reference_doctype,import_file:e.import_file,import_type:e.import_type})}),a=yield r.json();if(!r.ok)throw new Error(cu(a));const s=a.data;if(!(s!=null&&s.name))throw new Error("Data Import document was not created");return s.name})}function NY(e,r){return me(this,null,function*(){const a=yield fetch(`/api/resource/Data Import/${encodeURIComponent(e)}`,{method:"PUT",headers:Jd(),credentials:"include",body:JSON.stringify({import_file:r})}),s=yield a.json();if(!a.ok)throw new Error(cu(s))})}function jY(e){return me(this,null,function*(){const r=yield fetch("/api/method/frappe.core.doctype.data_import.data_import.form_start_import",{method:"POST",headers:Jd(),credentials:"include",body:JSON.stringify({data_import:e})}),a=yield r.json();if(!r.ok)throw new Error(cu(a))})}function SY(e){return me(this,null,function*(){var n,i;const r=yield fetch("/api/method/frappe.core.doctype.data_import.data_import.get_import_status",{method:"POST",headers:Jd(),credentials:"include",body:JSON.stringify({data_import_name:e})}),a=yield r.json();if(!r.ok)return"Error";const s=a.message;if(s&&typeof s=="object"&&"status"in s)return String((n=s.status)!=null?n:"Pending");if(typeof s=="string")try{return(i=JSON.parse(s).status)!=null?i:"Pending"}catch(c){return s}return"Pending"})}function CY(e){const r=e.exception,a=e.messages,s=typeof r=="string"?r:r!=null?JSON.stringify(r):"",n=typeof a=="string"?a:a!=null?JSON.stringify(a):"";return`${s}
${n}`}function EY(e){const r=dg(e.messages),a=dg(e.exception),s=AS([r,a].filter(Boolean).join(" — ")),n=K1(CY(e));return s&&!/File\s+"/.test(s)?Hc(s):n?Hc(n):s?Hc(s):"Could not import this row."}function TY(e){let r=0;const a=e.row_indexes;if(typeof a=="string")try{const i=JSON.parse(a);Array.isArray(i)&&i.length>0&&(r=Number(i[0])||0)}catch(i){const c=parseInt(a,10);Number.isNaN(c)||(r=c)}else Array.isArray(a)&&a.length>0&&(r=Number(a[0])||0);const s=e.docname!=null?String(e.docname).trim():"";if(Number(e.success)===1){const i=dg(e.messages),c=dg(e.exception),u=AS([i,c].filter(Boolean).join(" — "));return{rowIndex:r,success:!0,message:s?`Successfully imported ${s}`:u||"Successfully imported.",importedDocname:s||void 0}}return{rowIndex:r,success:!1,message:EY(e)}}function AY(e){return me(this,null,function*(){var i;const r=yield fetch("/api/method/frappe.core.doctype.data_import.data_import.get_import_logs",{method:"POST",headers:Jd(),credentials:"include",body:JSON.stringify({data_import:e})}),a=yield r.json();if(!r.ok)return[];const s=(i=a.message)!=null?i:a.data;return(Array.isArray(s)?s:[]).map(TY)})}function FS(e){return e.type!=="info"}function OY(e){return e.some(FS)}function x4(e){const r=eo(e).trim(),a=Math.max(r.lastIndexOf(":"),r.lastIndexOf(":"));if(a===-1)return null;const s=r.slice(a+1).trim();if(!s)return null;const n=s.split(",").map(i=>i.trim()).filter(Boolean);return n.length>0?n:null}function DY(e){const a=eo(e).trim().match(/do\s+not\s+exist\s+for\s+([^:\n\r]+?)\s*:/i);if(a!=null&&a[1])return a[1].trim()}function RY(){return me(this,null,function*(){var e,r;try{const a=yield fetch('/api/resource/Company?fields=["name"]&limit_page_length=1',{credentials:"include"}),s=yield a.json();if(!a.ok)return null;const n=(r=(e=s.data)==null?void 0:e[0])==null?void 0:r.name;return n&&String(n).trim()!==""?String(n):null}catch(a){return null}})}function FY(e,r,a){const s=r.trim();switch(e){case"Building":return{building:s};case"Room":return{room:s};case"Department":return Te({department_name:s},a?{company:a}:{});case"Location":return{location_name:s};default:return{name:s}}}function IY(e,r){return me(this,null,function*(){const a=[...new Set(r.map(u=>u.trim()).filter(Boolean))];let s=null;e==="Department"&&(s=yield RY());let n=0;const i=[],c={};for(const u of a)try{const h=FY(e,u,s),g=yield fetch(`/api/resource/${encodeURIComponent(e)}`,{method:"POST",headers:Jd(),credentials:"include",body:JSON.stringify(h)}),y=yield g.json();if(!g.ok){i.push(`${u}: ${cu(y)}`);continue}n+=1;const w=vY(y);w&&(c[u.trim()]=w)}catch(h){i.push(`${u}: ${h instanceof Error?h.message:String(h)}`)}if(e==="Department"&&!s&&a.length>0&&i.length===a.length&&i.unshift("Company is required for Department — ensure at least one Company exists."),e==="Department"&&a.length>0){yield new Promise(u=>setTimeout(u,200));for(const u of a){const h=u.trim();if(c[h])continue;const g=yield DS(h);g&&(c[h]=g)}}return{created:n,errors:i,resolvedNamesByInput:c}})}function MY(e){return me(this,null,function*(){const r=yield fetch("/api/method/frappe.core.doctype.data_import.data_import.get_preview_from_template",{method:"POST",headers:Jd(),credentials:"include",body:JSON.stringify({data_import:e})}),a=yield r.json();if(!r.ok)throw new Error(cu(a));const s=a.message;if(!s||typeof s!="object"||Array.isArray(s))return{dataImportName:e,fileUrl:"",warnings:[],columns:[]};const n=Array.isArray(s.warnings)?s.warnings:[],i=Array.isArray(s.columns)?s.columns:[];return{dataImportName:e,fileUrl:"",warnings:n,columns:i}})}function PY(e,r){return me(this,null,function*(){var c,u,h,g,y,w;(c=r.onProgress)==null||c.call(r,"Uploading file…");const a=yield kY(e);let s;const n=(u=r.reuseDataImportName)==null?void 0:u.trim();if(n){(h=r.onProgress)==null||h.call(r,"Updating Data Import…");try{yield NY(n,a),s=n}catch(E){console.warn("[Data Import] Reuse update failed, creating new document:",E),(g=r.onProgress)==null||g.call(r,"Saving Data Import…"),s=yield g4({reference_doctype:r.referenceDoctype,import_file:a,import_type:r.importType})}}else(y=r.onProgress)==null||y.call(r,"Saving Data Import…"),s=yield g4({reference_doctype:r.referenceDoctype,import_file:a,import_type:r.importType});(w=r.onProgress)==null||w.call(r,"Validating template…");const i=yield MY(s);return{dataImportName:s,fileUrl:a,warnings:i.warnings,columns:i.columns}})}function LY(e,r){return me(this,null,function*(){let a="Pending";for(let s=0;s<90&&(yield new Promise(n=>setTimeout(n,2e3)),a=yield SY(e),r(`Import status: ${a}`),a==="Pending");s++);return a})}function BY(e,r){return me(this,null,function*(){let a=yield AY(e);if(a.length===0){const s=r==="Success",n=r==="Partial Success";a=[{rowIndex:0,success:s||n,message:r==="Pending"?"Import is still running or the scheduler may be inactive.":s?"Import completed successfully.":n?"Import finished with partial success.":`Import finished with status: ${r}`}]}return a})}function UY(e,r){return me(this,null,function*(){r.onProgress("Queueing import…"),yield jY(e);const a=yield LY(e,r.onProgress),s=yield BY(e,a);return{finalStatus:a,logs:s}})}const f1="Location",h1="Infrastructure Location",p4={building:"Building",room_no:"Room No",department:"Department",location:"Location"},y4=[{key:"location_name",label:"Location Name"},{key:"company",label:"Company"},{key:"parent_location",label:"Parent Location"},{key:"is_group",label:"Is Group"}],zY=()=>{const{t:e}=Rr(),r=Na(),{fields:a,loading:s}=ib(h1),{fields:n,loading:i}=sS(h1),[c,u]=_.useState(!1),[h,g]=_.useState(null),[y,w]=_.useState(!1),[E,S]=_.useState(null),[A,C]=_.useState(null),[O,M]=_.useState(!1),[R,F]=_.useState([]),[z,W]=_.useState([]),[X,B]=_.useState(null),[Y,G]=_.useState(null),[ie,fe]=_.useState(null),[K,ke]=_.useState(null),[ge,re]=_.useState([]),[we,ee]=_.useState(!1),ve=_.useRef(0),ce=_.useRef(!1),ye=_.useRef(null),te=_.useRef(null),q=_.useRef(null),J=_.useMemo(()=>{const Je=new Map;return n.forEach(Ve=>{Je.set(Ve.fieldname,{reqd:Ve.reqd,read_only:Ve.read_only})}),Je},[n]),ae=_.useMemo(()=>{const Je=a.filter(Ve=>!m4.has(Ve.fieldtype)&&!Ve.key.startsWith("_")&&!mY.has(Ve.key)&&Ve.key!=="name").map(Ve=>{var Rt,qe;const Xe=J.get(Ve.key);return{key:Ve.key,label:(qe=(Rt=p4[Ve.key])!=null?Rt:Ve.label)!=null?qe:Ve.key,fieldtype:Ve.fieldtype,mandatory:(Xe==null?void 0:Xe.reqd)===1,readOnly:(Xe==null?void 0:Xe.read_only)===1}}).filter(Ve=>!Ve.readOnly);return Je.length>0?Je.map(({key:Ve,label:Xe,mandatory:Rt})=>({key:Ve,label:Xe,mandatory:Rt})):y4.map(Ve=>Ke(Te({},Ve),{mandatory:!1}))},[a,J]),oe=_.useMemo(()=>a.length>0?a.filter(Je=>!m4.has(Je.fieldtype)&&!Je.key.startsWith("_")&&Je.key!=="name").map(Je=>{var Ve,Xe;return{key:Je.key,label:(Xe=(Ve=p4[Je.key])!=null?Ve:Je.label)!=null?Xe:Je.key}}):y4,[a]),le=s||i;_.useEffect(()=>{ye.current=h},[h]);const be=_.useMemo(()=>{if(!A||A.length===0)return null;const Je=A.length,Ve=A.filter(Xe=>Xe.success).length;return{total:Je,ok:Ve}},[A]),Z=_.useMemo(()=>Y&&Y.length>0?!0:OY(R),[Y,R]),Le=_.useCallback(Je=>{if(Je===void 0||Je==="")return;const Ve=typeof Je=="string"?parseInt(Je,10):Number(Je);if(!Number.isNaN(Ve))return z[Ve]},[z]),Pe=_.useCallback(Je=>{var Rt;const Ve=Le(Je.col),Xe=((Rt=Ve==null?void 0:Ve.df)==null?void 0:Rt.fieldtype)==="Link"&&Ve.df.options?Ve.df.options:void 0;return Xe||DY(Je.message)},[Le]),Be=_.useMemo(()=>[...R].sort((Je,Ve)=>{var qe,Dt;const Xe=typeof Je.col=="number"?Je.col:parseInt(String((qe=Je.col)!=null?qe:""),10),Rt=typeof Ve.col=="number"?Ve.col:parseInt(String((Dt=Ve.col)!=null?Dt:""),10);return Number.isNaN(Xe)&&Number.isNaN(Rt)?0:Number.isNaN(Xe)?1:Number.isNaN(Rt)?-1:Xe-Rt}),[R]),pe=_.useCallback((Je,Ve)=>me(null,null,function*(){const Xe=++ve.current;M(!0),fe(null),G(null),B(null),F([]),W([]),re([]),S(null);try{const{headersOrdered:Rt,rows:qe}=yield xY(Je);if(!qe.length)return Xe!==ve.current||fe(e("dataImport.errors.noRows")),null;if(a.length===0&&!s)return Xe!==ve.current||fe(e("dataImport.errors.noSchema")),null;const Dt=pY(Rt,oe);if(Dt.length>0)return Xe!==ve.current||G(Dt.map(Yt=>({rowIndex:Yt.rowIndex,success:!1,message:Yt.message}))),null;const ar=yield bY(Je,oe),yt=yield wY(ar,oe,{preferredNames:Ve==null?void 0:Ve.preferredDepartmentNames}),St=yield _Y(yt,oe,{preferredNames:Ve==null?void 0:Ve.preferredBuildingNames});if(Xe!==ve.current)return null;re(St.mappingMessages);const Ot=yield PY(St.file,{referenceDoctype:h1,importType:"Insert New Records",onProgress:Yt=>S(Yt),reuseDataImportName:te.current});return Xe!==ve.current?null:(te.current=Ot.dataImportName,B(Ot),F(Ot.warnings),W(Ot.columns),St.file)}catch(Rt){if(Xe!==ve.current)return null;console.error(Rt);const qe=Rt instanceof Error?Rt.message:String(Rt);return qe==="EMPTY_WORKBOOK"?(fe(e("dataImport.errors.noRows")),null):(fe(eo(qe).slice(0,500)),null)}finally{Xe===ve.current&&(M(!1),S(null))}}),[a.length,s,oe,e]);_.useEffect(()=>{if(!h){M(!1),B(null),F([]),W([]),G(null),fe(null),re([]),ee(!1),te.current=null;return}if(!le){if(ce.current){ce.current=!1;return}me(null,null,function*(){const Je=h,Ve=yield pe(Je);if(Ve&&ye.current===Je){ce.current=!0,ee(!1),g(Ve);return}!Ve&&ye.current===Je?ee(!0):ee(!1)})}},[h,le,pe]);const rt=_.useCallback((Je,Ve)=>{const Xe=ae.filter(Rt=>Je.includes(Rt.key));if(Xe.length===0){Mt.error(e("dataImport.templateModal.nothingSelected"),{icon:t.jsx(Br,{})});return}yY(Xe.map(Rt=>({key:Rt.key,label:Rt.label})),Ve,"location_import_template"),Mt.success(e("dataImport.templateDownloaded"),{icon:t.jsx(Tr,{})}),u(!1)},[ae,e]),ct=Je=>{var Xe;const Ve=(Xe=Je.target.files)==null?void 0:Xe[0];ee(!1),te.current=null,g(Ve!=null?Ve:null),C(null)},et=()=>{g(null),C(null),re([]),ee(!1),te.current=null,q.current&&(q.current.value="")},It=_.useCallback(()=>{if(!h)return;const Je=URL.createObjectURL(h),Ve=document.createElement("a");Ve.href=Je,Ve.download=h.name||"import.xlsx",document.body.appendChild(Ve),Ve.click(),Ve.remove(),URL.revokeObjectURL(Je)},[h]),ft=Je=>me(null,null,function*(){var Rt;const Ve=Pe(Je);if(!Ve)return;const Xe=x4(Je.message);if(Xe!=null&&Xe.length){ke(`${String((Rt=Je.col)!=null?Rt:"")}:${Ve}`);try{const{created:qe,errors:Dt,resolvedNamesByInput:ar}=yield IY(Ve,Xe);if(qe>0&&Mt.success(e("dataImport.mastersCreated",{count:qe}),{icon:t.jsx(Tr,{})}),Dt.length>0&&Mt.warning(Dt.slice(0,4).join(" · "),{icon:t.jsx(Br,{})}),h){const Ot=yield pe(h,{preferredDepartmentNames:Ve==="Department"?ar:void 0,preferredBuildingNames:Ve==="Building"?ar:void 0});Ot?(ce.current=!0,ee(!1),g(Ot)):ee(!0)}}catch(qe){console.error(qe);const Dt=qe instanceof Error?qe.message:String(qe);Mt.error(eo(Dt).slice(0,400),{icon:t.jsx(Br,{})})}finally{ke(null)}}}),Lt=()=>me(null,null,function*(){if(!h){Mt.error(e("dataImport.errors.noFile"),{icon:t.jsx(Br,{})});return}if(!(X!=null&&X.dataImportName)){Mt.error(e("dataImport.errors.previewNotReady"),{icon:t.jsx(Br,{})});return}if(Z){Mt.error(e("dataImport.errors.fixPreviewFirst"),{icon:t.jsx(Br,{})});return}w(!0),S(null),C(null);try{const Je=yield UY(X.dataImportName,{onProgress:Xe=>S(Xe)});C(Je.logs);const Ve=Je.logs.filter(Xe=>!Xe.success).length;Je.finalStatus==="Success"&&Ve===0?Mt.success(e("dataImport.toastImportSuccess"),{icon:t.jsx(Tr,{})}):Je.finalStatus==="Partial Success"||Ve>0?Mt.warning(e("dataImport.toastImportPartial"),{icon:t.jsx(Br,{})}):Je.finalStatus==="Error"?Mt.error(e("dataImport.toastImportError"),{icon:t.jsx(Br,{})}):Mt.info(e("dataImport.toastImportStatus",{status:Je.finalStatus}),{icon:t.jsx(Tr,{})})}catch(Je){console.error(Je);const Ve=Je instanceof Error?Je.message:String(Je);Mt.error(eo(Ve).slice(0,500),{icon:t.jsx(Br,{})})}finally{w(!1),S(null)}});return t.jsxs("div",{className:"min-h-screen w-full min-w-0 overflow-x-hidden bg-gray-50 p-4 sm:p-6 dark:bg-gray-900",children:[t.jsx(xc,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:Ll}),t.jsx(hY,{isOpen:c,onClose:()=>u(!1),columns:ae,loading:le,onExport:rt}),t.jsxs("div",{className:"w-full min-w-0",children:[t.jsx("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:t.jsx("div",{className:"min-w-0",children:t.jsx("h1",{className:"text-2xl font-bold break-words text-gray-800 dark:text-white sm:text-3xl",children:e("dataImport.title")})})}),t.jsx("div",{className:"rounded-lg border border-gray-200 bg-white p-6 shadow-lg dark:border-gray-700 dark:bg-gray-800",children:t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300",children:[e("dataImport.documentType")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("select",{disabled:!0,value:f1,className:"w-full cursor-not-allowed rounded-lg border border-gray-200 bg-gray-100 px-3 py-2.5 text-sm font-semibold text-gray-800 opacity-90 dark:border-gray-600 dark:bg-gray-900/80 dark:text-white","aria-readonly":!0,children:t.jsx("option",{value:f1,children:f1})}),t.jsx("div",{className:"mt-2.5 rounded-lg border border-blue-100 bg-blue-50/70 px-3 py-2 dark:border-blue-900/50 dark:bg-blue-950/35",children:t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[t.jsx("p",{className:"text-sm leading-snug text-gray-600 dark:text-gray-300",children:e("dataImport.locationQuickHint")}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>r("/locations/new"),className:"inline-flex items-center justify-center gap-1.5 rounded-lg border border-blue-200 bg-white px-2.5 py-1.5 text-sm font-semibold text-blue-700 shadow-sm transition hover:bg-blue-50 dark:border-blue-800 dark:bg-gray-900 dark:text-blue-300 dark:hover:bg-gray-800",children:[t.jsx(Js,{size:13}),e("dataImport.btnAddLocation")]}),t.jsxs("button",{type:"button",onClick:()=>r("/locations"),className:"inline-flex items-center justify-center gap-1.5 rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-sm font-medium text-gray-800 shadow-sm transition hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-800",children:[t.jsx(J4,{size:13,className:"text-blue-600 dark:text-blue-400"}),e("dataImport.btnViewLocations")]})]})]})})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300",children:[e("dataImport.fileLabel")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center",children:[t.jsxs("label",{className:"inline-flex cursor-pointer items-center justify-center rounded-lg border border-gray-300 bg-white px-4 py-2.5 text-sm font-medium text-gray-700 shadow transition hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-800",children:[t.jsx(tT,{className:"mr-2 text-blue-600 dark:text-blue-400"}),e("dataImport.chooseFile"),t.jsx("input",{ref:q,type:"file",accept:".xlsx,.xls,.csv,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel",className:"hidden",onChange:ct,disabled:y})]}),t.jsxs("button",{type:"button",onClick:()=>u(!0),disabled:y||le,className:"inline-flex items-center justify-center rounded-lg border border-gray-300 bg-white px-4 py-2.5 text-sm font-medium text-gray-800 shadow transition hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-800",children:[t.jsx(Vo,{className:"mr-2 text-gray-600 dark:text-gray-400"}),e("dataImport.downloadTemplate")]})]}),h&&t.jsxs("div",{className:"mt-2 flex max-w-full flex-col gap-1.5 sm:flex-row sm:flex-wrap sm:items-center sm:gap-2",children:[t.jsxs("div",{className:"inline-flex max-w-full flex-wrap items-center gap-0.5 text-sm text-gray-600 dark:text-gray-400",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[h.name," (",Math.max(1,Math.round(h.size/1024))," KB)"]}),t.jsx("button",{type:"button",onClick:et,disabled:y||O,className:"-m-0.5 inline-flex items-center justify-center rounded p-0.5 text-gray-500 transition hover:bg-gray-100 hover:text-gray-900 disabled:cursor-not-allowed disabled:opacity-50 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-100","aria-label":e("dataImport.clearFile",{defaultValue:"Remove file"}),title:e("dataImport.clearFile",{defaultValue:"Remove file"}),children:t.jsx(Pt,{size:13})})]}),t.jsxs("button",{type:"button",onClick:It,disabled:y||O,className:"inline-flex w-fit items-center justify-center gap-0.5 rounded border border-gray-300 bg-white px-1.5 py-0.5 text-[10px] font-medium leading-tight text-gray-800 shadow-sm transition hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-800",children:[t.jsx(Vo,{className:"text-gray-600 dark:text-gray-400",size:10}),e("dataImport.downloadFile")]})]}),t.jsx("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:e("dataImport.fileHint")})]}),ie&&t.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-900 dark:border-red-900/50 dark:bg-red-950/30 dark:text-red-100",children:ie}),we&&h&&!O&&t.jsx("div",{className:"rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800/60 dark:bg-amber-950/30 dark:text-amber-100",children:e("dataImport.alignedWorkbookNotApplied")}),Y&&Y.length>0||R.length>0?t.jsxs("div",{className:"rounded border border-amber-200 bg-amber-50/90 px-3 py-2.5 dark:border-amber-900/40 dark:bg-amber-950/25",children:[t.jsx("h2",{className:"text-sm font-semibold text-slate-800 dark:text-slate-100",children:e("dataImport.previewTitle")}),t.jsx("div",{className:"mt-2 max-h-56 overflow-y-auto rounded border border-amber-200/70 bg-white text-xs dark:border-amber-900/35 dark:bg-gray-900/50",children:t.jsxs("ul",{className:"divide-y divide-amber-100 dark:divide-amber-900/40",children:[Y==null?void 0:Y.map((Je,Ve)=>t.jsxs("li",{className:"px-2.5 py-1.5 leading-snug",children:[t.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:e("dataImport.previewHeaderIssue")}),t.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:" — "}),t.jsx("span",{className:"break-words text-gray-700 dark:text-gray-300",children:Je.message})]},`hdr-${Je.rowIndex}-${Ve}`)),Be.map((Je,Ve)=>{var Ot,Yt,Ye,wt,zt;const Xe=Le(Je.col),Rt=Je.type==="info",qe=Pe(Je),Dt=!!qe&&!Rt&&((Yt=(Ot=x4(Je.message))==null?void 0:Ot.length)!=null?Yt:0)>0,ar=qe&&K===`${String((Ye=Je.col)!=null?Ye:"")}:${qe}`,yt=[];Je.row!=null&&String(Je.row).trim()!==""&&yt.push(e("dataImport.previewRowHeading",{row:String(Je.row)})),Je.col!=null&&String(Je.col).trim()!==""&&yt.push(e("dataImport.previewColumnHeading",{n:String(Je.col),label:(zt=(wt=Xe==null?void 0:Xe.header_title)!=null?wt:qe)!=null?zt:"—"}));const St=yt.join(" · ");return t.jsx("li",{className:`px-2.5 py-1.5 leading-snug ${Rt?"bg-blue-50/50 dark:bg-blue-950/20":FS(Je)?"":"bg-gray-50/80 dark:bg-gray-900/30"}`,children:t.jsxs("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-start sm:justify-between sm:gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[St?t.jsx("p",{className:"font-medium text-gray-900 dark:text-gray-100",children:St}):t.jsx("p",{className:"font-medium text-gray-900 dark:text-gray-100",children:e("dataImport.previewGenericHeading")}),t.jsx("p",{className:"break-words text-gray-700 dark:text-gray-300",children:eo(Je.message)}),Dt&&qe&&t.jsxs("p",{className:"mt-0.5 text-[11px] text-gray-600 dark:text-gray-400",children:[e("dataImport.previewSaveHintPrefix")," ",t.jsx("span",{className:"font-bold text-gray-800 dark:text-gray-200",children:e("dataImport.previewSaveAction")})," ",e("dataImport.previewSaveHintSuffix")]})]}),Dt&&qe&&t.jsx("button",{type:"button",disabled:ar||O||y,onClick:()=>ft(Je),className:"inline-flex shrink-0 items-center justify-center rounded border border-blue-400 bg-blue-600 px-2.5 py-1 text-[11px] font-bold text-white shadow-sm transition hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50 dark:border-blue-700 dark:bg-blue-700 dark:hover:bg-blue-600",children:ar?t.jsx(Ir,{className:"animate-spin",size:11}):e("dataImport.previewSaveAction")})]})},`pw-${String(Je.col)}-${String(Je.row)}-${Ve}-${Je.message.slice(0,24)}`)})]})})]}):null,ge.length>0&&t.jsxs("div",{className:"rounded-lg border border-blue-200 bg-blue-50/90 px-3 py-2 text-xs text-blue-950 dark:border-blue-900/40 dark:bg-blue-950/35 dark:text-blue-100",children:[t.jsx("p",{className:"font-semibold",children:e("dataImport.normalizationNotes")}),t.jsx("ul",{className:"mt-1 list-inside list-disc space-y-0.5",children:ge.map((Je,Ve)=>t.jsx("li",{className:"break-words",children:Je},`norm-${Ve}-${Je.slice(0,24)}`))})]}),E&&t.jsx("div",{className:"rounded-lg border border-blue-100 bg-blue-50 px-4 py-3 text-sm text-blue-900 dark:border-blue-900 dark:bg-blue-950/40 dark:text-blue-100",children:t.jsxs("span",{className:"inline-flex items-center gap-2",children:[t.jsx(Ir,{className:"animate-spin"}),E]})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-t border-gray-200 pt-6 dark:border-gray-700",children:[t.jsx("button",{type:"button",onClick:Lt,disabled:y||!h||le||O||!(X!=null&&X.dataImportName)||Z,className:"inline-flex items-center justify-center rounded-lg bg-blue-600 px-6 py-2.5 text-sm font-semibold text-white shadow-lg transition hover:bg-blue-700 hover:shadow-xl disabled:cursor-not-allowed disabled:opacity-50",children:y?t.jsxs(t.Fragment,{children:[t.jsx(Ir,{className:"mr-2 animate-spin"}),e("dataImport.importing")]}):O?t.jsxs(t.Fragment,{children:[t.jsx(Ir,{className:"mr-2 animate-spin"}),e("dataImport.validatingFile")]}):e("dataImport.startImport")}),be&&!y&&t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[t.jsx("span",{className:`text-sm font-medium ${be.ok===be.total?"text-green-700 dark:text-green-400":be.ok===0?"text-red-700 dark:text-red-400":"text-amber-700 dark:text-amber-400"}`,children:be.ok===0?e("dataImport.importSummaryLineAllFailed",{total:be.total}):be.ok===be.total?e("dataImport.importSummaryLineAllOk",{total:be.total}):e("dataImport.importSummaryLine",{ok:be.ok,total:be.total})}),t.jsx("span",{className:`inline-flex shrink-0 rounded-full px-2.5 py-0.5 text-xs font-semibold ${be.ok===be.total?"bg-green-100 text-green-800 dark:bg-green-950/50 dark:text-green-300":be.ok===0?"bg-red-100 text-red-800 dark:bg-red-950/50 dark:text-red-300":"bg-amber-100 text-amber-900 dark:bg-amber-950/40 dark:text-amber-200"}`,children:be.ok===be.total?e("dataImport.importSummaryBadgeAll"):be.ok===0?e("dataImport.importSummaryBadgeNone"):e("dataImport.importSummaryBadgePartial")})]})]})]})}),A&&A.length>0&&t.jsxs("div",{className:"mt-6 rounded-lg border border-gray-200 bg-white p-4 shadow-lg dark:border-gray-700 dark:bg-gray-800",children:[t.jsx("h2",{className:"mb-3 text-lg font-semibold text-gray-800 dark:text-white",children:e("dataImport.logsTitle")}),t.jsx("div",{className:"max-h-96 overflow-auto rounded-lg border border-gray-200 dark:border-gray-600",children:t.jsxs("table",{className:"min-w-full divide-y divide-gray-200 text-sm dark:divide-gray-600",children:[t.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/80",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-start font-medium text-gray-700 dark:text-gray-300",children:e("dataImport.logRow")}),t.jsx("th",{className:"px-3 py-2 text-start font-medium text-gray-700 dark:text-gray-300",children:e("dataImport.logStatus")}),t.jsx("th",{className:"px-3 py-2 text-start font-medium text-gray-700 dark:text-gray-300",children:e("dataImport.logMessage")})]})}),t.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-700",children:A.map((Je,Ve)=>t.jsxs("tr",{className:Je.success?"bg-white dark:bg-gray-800":"bg-red-50/60 dark:bg-red-950/20",children:[t.jsx("td",{className:"px-3 py-2 font-mono text-gray-800 dark:text-gray-200",children:Je.rowIndex}),t.jsx("td",{className:"px-3 py-2",children:Je.success?t.jsxs("span",{className:"inline-flex items-center gap-1 text-green-700 dark:text-green-400",children:[t.jsx(Tr,{size:12})," ",e("dataImport.statusOk")]}):t.jsxs("span",{className:"inline-flex items-center gap-1 text-red-700 dark:text-red-400",children:[t.jsx(Br,{size:12})," ",e("dataImport.statusFailed")]})}),t.jsx("td",{className:"max-w-2xl break-words px-3 py-2 text-gray-700 dark:text-gray-300",children:Je.success&&Je.importedDocname?e("dataImport.successImported",{name:Je.importedDocname}):eo(Je.message)})]},`${Je.rowIndex}-${Ve}-${Je.message.slice(0,24)}`))})]})})]})]})]})},WY=["name","building","department","room_no","location"];function Cm(e){const r={};for(const[a,s]of Object.entries(e)){if(a==="doctype"){r[a]=s;continue}s!=null&&(typeof s=="string"&&s.trim()===""||(r[a]=s))}return r}function HY(){var e;return typeof window=="undefined"?"":window.csrf_token||((e=document.cookie.split("; ").find(r=>r.startsWith("csrf_token=")))==null?void 0:e.split("=")[1])||""}function $Y(e){return me(this,null,function*(){const r=HY();if(r)return r;const a=yield Xt.getCSRFToken();if(a)return typeof window!="undefined"&&(window.csrf_token=a),a;try{const s=yield fetch(`${e}/api/method/frappe.sessions.get_csrf_token`,{method:"GET",headers:{Accept:"application/json"},credentials:"include"});if(!s.ok)return"";const n=yield s.json(),i=typeof n.message=="string"?n.message:"";return i&&typeof window!="undefined"&&(window.csrf_token=i),i}catch(s){return""}})}function b4(e){if(e&&typeof e=="object"){const r=e;if(typeof r.name=="string"&&r.name.trim())return e;if(Array.isArray(r.docs)&&r.docs.length>0){const a=r.docs[0];if(a&&typeof a=="object"&&"name"in a&&typeof a.name=="string")return a}if(r.data&&typeof r.data=="object"&&"name"in r.data)return r.data}if(typeof e=="string")try{const r=JSON.parse(e);if(r&&typeof r=="object"&&"name"in r)return r}catch(r){return null}return null}function v4(e,r){if(typeof r.exc=="string"&&r.exc.trim())return r.exc.slice(0,400);if(typeof r.exception=="string"&&r.exception.trim()){const a=r.exception.split(`
`).find(s=>s.trim().length>0);if(a)return a.replace(/^frappe\.exceptions\.\w+:\s*/,"").slice(0,400)}return typeof r.message=="string"&&r.message.trim()?r.message:e.ok?"Insert returned no document":`Insert failed (HTTP ${e.status})`}class VY{constructor(){Ii(this,"baseURL");this.baseURL=Or.BASE_URL}getHeaders(){return me(this,null,function*(){const r={Accept:"application/json","Content-Type":"application/json"},a=yield $Y(this.baseURL);return a&&(r["X-Frappe-CSRF-Token"]=a),r})}readHttpError(r){return me(this,null,function*(){try{const a=yield r.json();if(typeof a.exc_type=="string"&&a.exc_type&&typeof a.exception=="string"&&a.exception){const s=a.exception.split(`
`).find(n=>String(n).trim().length>0);if(s)return String(s).replace(/^frappe\.exceptions\.\w+:\s*/,"").slice(0,500)}if(typeof a.message=="string"&&a.message.trim())return a.message;if(a.message&&typeof a.message=="object"&&"message"in a.message){const s=a.message.message;if(typeof s=="string"&&s.trim())return s}if(typeof a.exception=="string"&&a.exception.trim()){const s=a.exception.split(`
`).find(n=>n.trim().length>0);if(s)return s.replace(/^frappe\.exceptions\.\w+:\s*/,"").slice(0,400)}if(typeof a.exc_type=="string")return a.exc_type}catch(a){}return`HTTP error! status: ${r.status}`})}getLocations(){return me(this,arguments,function*(r={}){const{filters:a={},or_filters:s,fields:n=[...WY],limit_start:i=0,limit_page_length:c=20,order_by:u="modified desc"}=r,h=a&&typeof a=="object"&&Object.keys(a).length>0?Ln(a):[],g={doctype:"Infrastructure Location",fields:n,filters:h,limit_start:i,limit_page_length:c,order_by:u};s&&s.length>0&&(g.or_filters=s);const y=yield fetch(`${this.baseURL}/api/method/frappe.client.get_list`,{method:"POST",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(g)});if(!y.ok)throw new Error(yield this.readHttpError(y));const w=yield y.json();return{data:Array.isArray(w.message)?w.message:[]}})}getLocationCount(){return me(this,arguments,function*(r={}){const s={doctype:"Infrastructure Location",filters:r.filters&&typeof r.filters=="object"&&Object.keys(r.filters).length>0?Ln(r.filters):[]};r.or_filters&&r.or_filters.length>0&&(s.or_filters=r.or_filters);const n=yield fetch(`${this.baseURL}/api/method/frappe.client.get_count`,{method:"POST",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(s)});if(!n.ok)throw new Error(yield this.readHttpError(n));const i=yield n.json();return typeof i.message=="number"?i.message:0})}getLocation(r){return me(this,null,function*(){const a=yield fetch(`${this.baseURL}/api/resource/Infrastructure Location/${encodeURIComponent(r)}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!a.ok)throw new Error(yield this.readHttpError(a));return(yield a.json()).data})}deleteLocation(r){return me(this,null,function*(){const a=yield this.getHeaders(),s=yield fetch(`${this.baseURL}/api/resource/Infrastructure Location/${encodeURIComponent(r)}`,{method:"DELETE",headers:a,credentials:"include"});if(!s.ok)throw new Error(yield this.readHttpError(s))})}renameLocation(r,a){return me(this,null,function*(){const s=a.trim();if(!s||s===r)return;const n=yield this.getHeaders(),i=yield fetch(`${this.baseURL}/api/method/frappe.model.rename_doc.update_document_title`,{method:"POST",headers:n,credentials:"include",body:JSON.stringify({doctype:"Infrastructure Location",docname:r,name:s,merge:!1})});if(!i.ok)throw new Error(yield this.readHttpError(i))})}createLocation(r){return me(this,null,function*(){const a=yield this.getHeaders(),s=Cm(Te({doctype:"Infrastructure Location"},r)),n=yield fetch(`${this.baseURL}/api/method/frappe.client.insert`,{method:"POST",headers:a,credentials:"include",body:JSON.stringify({doc:s})}),i=yield n.json(),c=!!(i.exc_type||i.exc);if(n.ok&&!c){const y=b4(i.message);if(y)return y}const u=Cm(Te({},r)),h=yield fetch(`${this.baseURL}/api/resource/Infrastructure Location`,{method:"POST",headers:a,credentials:"include",body:JSON.stringify(u)});if(!h.ok){const y=v4(n,i),w=yield this.readHttpError(h);throw new Error(y?`${y} | ${w}`:w)}return(yield h.json()).data})}updateLocation(r,a){return me(this,null,function*(){const s=yield this.getHeaders(),n=yield this.getLocation(r),i=Cm(a),c=Ke(Te(Te({},n),i),{doctype:"Infrastructure Location",name:n.name});delete c.creation,delete c.modified,delete c.modified_by,delete c.owner;for(const A of Object.keys(c))A.startsWith("__")&&delete c[A];const u=yield fetch(`${this.baseURL}/api/method/frappe.client.save`,{method:"POST",headers:s,credentials:"include",body:JSON.stringify({doc:c})}),h=yield u.json(),g=!!(h.exc_type||h.exc);if(u.ok&&!g){const A=b4(h.message);return A||this.getLocation(r)}const y=Cm(a),w=yield fetch(`${this.baseURL}/api/resource/Infrastructure Location/${encodeURIComponent(r)}`,{method:"PUT",headers:s,credentials:"include",body:JSON.stringify(y)});if(w.ok){const A=yield w.text();if(!A.trim())return this.getLocation(r);try{const C=JSON.parse(A);if(C.data)return C.data}catch(C){return this.getLocation(r)}return this.getLocation(r)}const E=v4(u,h),S=yield this.readHttpError(w);throw new Error(E?`${E} | ${S}`:S)})}}const Il=new VY,GY=e=>{var S,A;const[r,a]=_.useState([]),[s,n]=_.useState(!0),[i,c]=_.useState(null),[u,h]=_.useState(0),g=JSON.stringify((S=e.filters)!=null?S:{}),y=JSON.stringify((A=e.or_filters)!=null?A:[]),w=_.useRef(e);w.current=e,_.useEffect(()=>{let C=!1;return me(null,null,function*(){try{n(!0),c(null);const O=w.current,M=yield Il.getLocations(O);C||a(M.data);const R=yield Il.getLocationCount({filters:O.filters,or_filters:O.or_filters});C||h(R)}catch(O){C||c(O instanceof Error?O.message:"Failed to fetch locations")}finally{C||n(!1)}}),()=>{C=!0}},[e.limit_start,e.limit_page_length,e.order_by,g,y]);const E=_.useCallback(()=>me(null,null,function*(){const C=w.current;try{n(!0),c(null);const O=yield Il.getLocations(C);a(O.data);const M=yield Il.getLocationCount({filters:C.filters,or_filters:C.or_filters});h(M)}catch(O){c(O instanceof Error?O.message:"Failed to fetch locations")}finally{n(!1)}}),[]);return{locations:r,loading:s,error:i,totalCount:u,refetch:E}},YY=e=>{const[r,a]=_.useState(null),[s,n]=_.useState(!1),[i,c]=_.useState(null),u=_.useCallback(()=>me(null,null,function*(){if(!e){a(null);return}try{n(!0),c(null);const h=yield Il.getLocation(e);a(h)}catch(h){c(h instanceof Error?h.message:"Failed to load location"),a(null)}finally{n(!1)}}),[e]);return _.useEffect(()=>{u()},[u]),{doc:r,loading:s,error:i,refetch:u}},qY=()=>{const[e,r]=_.useState(!1),[a,s]=_.useState(null),n=h=>me(null,null,function*(){try{return r(!0),s(null),yield Il.createLocation(h)}catch(g){const y=g instanceof Error?g.message:"Failed to create";throw s(y),g}finally{r(!1)}}),i=(h,g)=>me(null,null,function*(){try{return r(!0),s(null),yield Il.updateLocation(h,g)}catch(y){const w=y instanceof Error?y.message:"Failed to save";throw s(w),y}finally{r(!1)}}),c=_.useCallback((h,g)=>me(null,null,function*(){try{r(!0),s(null),yield Il.renameLocation(h,g)}catch(y){const w=y instanceof Error?y.message:"Failed to rename";throw s(w),y}finally{r(!1)}}),[]),u=_.useCallback(h=>me(null,null,function*(){try{r(!0),s(null),yield Il.deleteLocation(h)}catch(g){const y=g instanceof Error?g.message:"Failed to delete";throw s(y),g}finally{r(!1)}}),[]);return{createLocation:n,updateLocation:i,renameLocation:c,deleteLocation:u,loading:e,error:a}},m1=20,Em=["name","building","department","room_no","location"];function w4(e,r){if(r==null||String(r).trim()==="")return"";const a=String(r);return e==="room_no"?a.replace(/_/g,""):a}const XY=()=>{const{t:e}=Rr(),r=Na(),[a,s]=Sn(),{deleteLocation:n,loading:i}=qY(),c=_.useMemo(()=>{const X=parseInt(a.get("page")||"1",10);return Number.isNaN(X)||X<1?1:X},[a]),u=_.useCallback(X=>{s(B=>{const Y=new URLSearchParams(B);return Y.set("page",String(X)),Y})},[s]),[h,g]=_.useState(""),[y,w]=_.useState("");_.useEffect(()=>{const X=window.setTimeout(()=>w(h.trim()),350);return()=>window.clearTimeout(X)},[h]);const E=_.useRef(y);_.useEffect(()=>{E.current!==y&&(E.current=y,u(1))},[y,u]);const S=_.useMemo(()=>{const X=y.length>0?[["name","like",`%${y}%`],["building","like",`%${y}%`],["department","like",`%${y}%`],["room_no","like",`%${y}%`],["location","like",`%${y}%`]]:void 0;return{fields:[...Em],limit_start:(c-1)*m1,limit_page_length:m1,order_by:"modified desc",or_filters:X}},[c,y]),{locations:A,loading:C,error:O,totalCount:M,refetch:R}=GY(S),F=Em.length+1,z=X=>{r(`/locations/${encodeURIComponent(X)}`)},W=(X,B)=>me(null,null,function*(){if(window.confirm(e("locations.deleteConfirm",{name:B||X})))try{yield n(X),Mt.success(e("locations.deleteSuccess"),{icon:t.jsx(Tr,{})}),R()}catch(G){const ie=G instanceof Error?G.message:String(G);Mt.error(ie.slice(0,500))}});return t.jsxs("div",{className:"min-h-screen w-full min-w-0 overflow-x-hidden bg-gray-50 p-4 sm:p-6 dark:bg-gray-900",children:[t.jsx(xc,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:Ll}),t.jsxs("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between lg:items-center",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-2xl font-bold break-words text-gray-800 dark:text-white sm:text-3xl",children:e("locations.title")}),t.jsx("p",{className:"mt-1 text-sm text-gray-600 dark:text-gray-400",children:e("locations.listTotal",{count:M})})]}),t.jsxs("button",{type:"button",onClick:()=>r("/locations/new"),className:"inline-flex w-full shrink-0 items-center justify-center gap-2 rounded-lg bg-blue-600 px-4 py-2 text-sm font-semibold text-white shadow transition hover:bg-blue-700 sm:w-auto",children:[t.jsx(Js,{size:14}),e("locations.add")]})]}),t.jsxs("div",{className:"mb-3 rounded-lg border border-gray-200 bg-white px-3 py-2.5 shadow-sm dark:border-gray-700 dark:bg-gray-800",children:[t.jsx("label",{className:"mb-0.5 block text-xs font-medium text-gray-600 dark:text-gray-400",children:e("common.search")}),t.jsxs("div",{className:"relative max-w-lg",children:[t.jsx(In,{className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400",size:14}),t.jsx("input",{type:"search",value:h,onChange:X=>g(X.target.value),placeholder:e("locations.searchPlaceholder"),className:"w-full rounded-lg border border-gray-300 bg-white py-1.5 pl-9 pr-3 text-sm text-gray-900 shadow-sm placeholder:text-gray-500 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/30 dark:border-gray-600 dark:bg-gray-900 dark:text-white dark:placeholder:text-gray-500","aria-label":e("locations.searchPlaceholder")})]})]}),t.jsxs("div",{className:"overflow-hidden rounded-lg border border-gray-200 bg-white shadow dark:border-gray-700 dark:bg-gray-800",children:[O&&t.jsx("div",{className:"border-b border-red-100 bg-red-50 px-4 py-2 text-sm text-red-800 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-200",children:O}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"min-w-full divide-y divide-gray-200 text-xs dark:divide-gray-700",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700",children:t.jsxs("tr",{children:[Em.map(X=>t.jsx("th",{className:`px-2 py-1.5 text-left text-[11px] font-semibold uppercase tracking-wide text-gray-600 dark:text-gray-300 ${X==="name"?"max-w-[10rem] sm:max-w-[14rem] md:max-w-xs":""}`,children:e(`locations.fieldLabel.${X}`,{defaultValue:X})},X)),t.jsx("th",{className:"w-20 shrink-0 px-2 py-1.5 text-left text-[11px] font-semibold uppercase tracking-wide text-gray-600 dark:text-gray-300",children:e("common.actions")})]})}),t.jsx("tbody",{className:"divide-y divide-gray-200 bg-white dark:divide-gray-700 dark:bg-gray-800",children:C&&A.length===0?t.jsx("tr",{children:t.jsxs("td",{colSpan:F,className:"px-2 py-10 text-center text-sm text-gray-500 dark:text-gray-400",children:[t.jsx(Ir,{className:"mx-auto mb-2 animate-spin text-blue-500",size:24}),e("locations.loading")]})}):A.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:F,className:"px-2 py-10 text-center text-sm text-gray-500 dark:text-gray-400",children:e("locations.empty")})}):A.map(X=>t.jsxs("tr",{className:"cursor-pointer transition-colors hover:bg-gray-50 dark:hover:bg-gray-700/50",onClick:()=>z(X.name),onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),z(X.name))},tabIndex:0,role:"link",children:[Em.map(B=>t.jsx("td",{className:`px-2 py-1.5 align-middle text-[11px] leading-snug text-gray-900 dark:text-white ${B==="name"?"max-w-[10rem] truncate font-mono sm:max-w-[14rem] md:max-w-xs":"max-w-[8rem] truncate sm:max-w-[10rem] md:max-w-[12rem]"}`,title:(()=>{const Y=X[B];return w4(B,Y)||void 0})(),children:(()=>{const Y=X[B],G=w4(B,Y);return G||"—"})()},B)),t.jsx("td",{className:"whitespace-nowrap px-2 py-1.5 align-middle",onClick:B=>B.stopPropagation(),children:t.jsxs("div",{className:"flex items-center gap-0.5",children:[t.jsx("button",{type:"button",onClick:()=>z(X.name),className:"rounded p-1.5 text-blue-600 transition-colors hover:bg-blue-50 hover:text-blue-900 dark:text-blue-400 dark:hover:bg-blue-900/30 dark:hover:text-blue-300",title:e("locations.viewRow"),children:t.jsx(to,{size:13})}),t.jsx("button",{type:"button",onClick:()=>z(X.name),className:"rounded p-1.5 text-green-600 transition-colors hover:bg-green-50 hover:text-green-900 dark:text-green-400 dark:hover:bg-green-900/30 dark:hover:text-green-300",title:e("locations.editRow"),children:t.jsx(Ms,{size:13})}),t.jsx("button",{type:"button",onClick:()=>void W(X.name,X.location||X.name),disabled:i,className:"rounded p-1.5 text-red-600 transition-colors hover:bg-red-50 hover:text-red-900 disabled:opacity-50 dark:text-red-400 dark:hover:bg-red-900/30 dark:hover:text-red-300",title:e("locations.deleteRow"),children:t.jsx(la,{size:13})})]})})]},X.name))})]})}),t.jsx(ed,{currentPage:c,totalCount:M,pageSize:m1,itemLabel:e("locations.paginationLabel"),onPageChange:u}),t.jsx("div",{className:"border-t border-gray-100 px-4 py-2 dark:border-gray-700",children:t.jsx("button",{type:"button",onClick:()=>R(),disabled:C,className:"text-sm font-medium text-blue-600 hover:text-blue-800 disabled:opacity-50 dark:text-blue-400 dark:hover:text-blue-300",children:e("locations.refresh")})})]})]})},ZY="Location",KY="Infrastructure Location",JY=()=>{const{t:e}=Rr(),{locationName:r}=ml(),a=Na(),s=(r!=null?r:"")==="new",{doc:n,loading:i,error:c,refetch:u}=YY(s?null:r!=null?r:null),[h,g]=_.useState(""),[y,w]=_.useState(""),[E,S]=_.useState(""),[A,C]=_.useState(""),[O,M]=_.useState(!1),[R,F]=_.useState(!1),[z,W]=_.useState(!1),[X,B]=_.useState(null),Y=_.useRef(null),[G,ie]=_.useState(s),fe=_.useCallback(()=>{Y.current&&(clearTimeout(Y.current),Y.current=null)},[]),K=_.useCallback(ce=>{fe(),Y.current=setTimeout(()=>{B(ye=>ye===ce?null:ye),Y.current=null},220)},[fe]);_.useEffect(()=>{ie((r!=null?r:"")==="new")},[r]),_.useEffect(()=>()=>fe(),[fe]),_.useEffect(()=>{var ce,ye,te,q;n&&(g((ce=n.building)!=null?ce:""),w((ye=n.department)!=null?ye:""),S((te=n.room_no)!=null?te:""),C((q=n.location)!=null?q:""))},[n]);const ge=!s&&i||!(s||G),re=_.useMemo(()=>({building:h||void 0,department:y||void 0,room_no:E||void 0,location:A||void 0}),[h,y,E,A]),we=()=>me(null,null,function*(){var ce;if(!re.building&&!re.department&&!re.room_no&&!re.location){Mt.error(e("common.validationRequired",{defaultValue:"Please fill at least one field."}),{icon:t.jsx(Br,{})});return}M(!0);try{if(s){const ye=yield Il.createLocation(re),te=(ce=ye==null?void 0:ye.name)==null?void 0:ce.trim();if(!te)return Mt.error(e("locations.saveMissingName"),{icon:t.jsx(Br,{})});Mt.success(e("locations.saved"),{icon:t.jsx(Tr,{})}),a(`/locations/${encodeURIComponent(te)}`,{replace:!0})}else r&&(yield Xt.apiCall(`/api/resource/${encodeURIComponent(KY)}/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify(re)}),Mt.success(e("locations.saved"),{icon:t.jsx(Tr,{})}),ie(!1),u())}catch(ye){const te=ye instanceof Error?ye.message:String(ye),q=te.includes("Duplicate")||te.includes("already exists")?e("locations.errorDuplicateEntry",{name:A||r||""}):mT(te);Mt.error(q,{icon:t.jsx(Br,{})})}finally{M(!1)}}),ee=s?e("locations.newTitle"):(n==null?void 0:n.name)||r||e("locations.title"),ve=!s&&i&&!n;return t.jsxs("div",{className:"min-h-screen w-full min-w-0 overflow-x-hidden bg-gray-50 p-4 sm:p-6 dark:bg-gray-900",children:[t.jsx(xc,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:Ll}),ve?t.jsx("div",{className:"flex items-center justify-center rounded-lg border border-gray-200 bg-white py-16 dark:border-gray-700 dark:bg-gray-800",children:t.jsx(Ir,{className:"animate-spin text-blue-500",size:28})}):t.jsxs("form",{id:"location-detail-form",className:"w-full rounded-xl border border-gray-200 bg-white p-4 shadow-md dark:border-gray-700 dark:bg-gray-800 sm:p-6",onSubmit:ce=>{ce.preventDefault(),we()},children:[t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[t.jsx("div",{className:"min-w-0",children:t.jsx("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white sm:text-3xl",children:ee})}),t.jsxs("div",{className:"flex w-full flex-row flex-wrap items-center justify-end gap-2 sm:w-auto",children:[t.jsxs("button",{type:"button",onClick:()=>a("/locations"),className:"inline-flex shrink-0 items-center justify-center gap-2 rounded-lg border border-gray-200 bg-white px-4 py-2.5 text-sm font-medium text-gray-800 shadow-sm transition hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-800",children:[t.jsx(J4,{size:14,className:"text-blue-600 dark:text-blue-400"}),e("dataImport.btnViewLocations")]}),!s&&!G&&t.jsxs("button",{type:"button",onClick:()=>ie(!0),disabled:i||O,className:"inline-flex shrink-0 items-center justify-center gap-2 rounded-lg bg-blue-600 px-5 py-2.5 text-sm font-semibold text-white shadow transition hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Ms,{}),e("common.edit")]}),!s&&G&&t.jsx("button",{type:"button",onClick:()=>{ie(!1),u()},disabled:O,className:"inline-flex shrink-0 items-center justify-center gap-2 rounded-lg border border-gray-300 bg-white px-5 py-2.5 text-sm font-semibold text-gray-800 shadow transition hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-800",children:e("common.cancel")}),(s||G)&&t.jsxs("button",{type:"button",onClick:()=>void we(),disabled:O||!s&&i,className:"inline-flex shrink-0 items-center justify-center gap-2 rounded-lg bg-blue-600 px-5 py-2.5 text-sm font-semibold text-white shadow transition hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50",children:[O?t.jsx(Ir,{className:"animate-spin"}):t.jsx(bs,{}),e(O?"common.saving":"locations.save")]})]})]}),!s&&c&&t.jsx("div",{className:"mb-6 rounded-lg border border-red-100 bg-red-50 px-4 py-3 text-sm text-red-800 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-200",children:c}),t.jsx("div",{className:"w-full space-y-3",children:t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2 md:gap-3",children:[t.jsx("div",{children:t.jsx(hr,{label:"Building",doctype:"Building",value:h,onChange:g,disabled:ge,allowQuickCreate:!0})}),t.jsx("div",{children:t.jsx(hr,{label:"Department",doctype:"Department",value:y,onChange:w,disabled:ge,allowQuickCreate:!0})}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-sm font-medium text-gray-700 dark:text-gray-300",children:e("locations.fieldRoom",{defaultValue:"Room"})}),t.jsx("input",{type:"text",name:"room_no",autoComplete:"off",value:E,onChange:ce=>S(ce.target.value),onFocus:()=>{fe(),B("room")},onBlur:()=>K("room"),disabled:ge,placeholder:e("locations.roomTextPlaceholder",{defaultValue:"Type or add a room"}),className:"w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/30 disabled:cursor-not-allowed disabled:bg-gray-100 dark:border-gray-600 dark:bg-gray-800 dark:text-white dark:placeholder:text-gray-500 dark:disabled:bg-gray-900"}),I1("Room")&&X==="room"&&t.jsxs("button",{type:"button",disabled:ge,onMouseDown:ce=>ce.preventDefault(),onClick:()=>{fe(),B(null),F(!0)},className:"mt-1.5 inline-flex items-center gap-1.5 text-sm font-medium text-green-600 hover:text-green-800 disabled:cursor-not-allowed disabled:opacity-50 dark:text-green-400 dark:hover:text-green-300",children:[t.jsx(Js,{size:12}),e("locations.addRoomAction",{defaultValue:"Add room"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-sm font-medium text-gray-700 dark:text-gray-300",children:ZY}),t.jsx("input",{type:"text",name:"location_link",autoComplete:"off",value:A,onChange:ce=>C(ce.target.value),onFocus:()=>{fe(),B("location")},onBlur:()=>K("location"),disabled:ge,placeholder:e("locations.locationTextPlaceholder",{defaultValue:"Type or add a location"}),className:"w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/30 disabled:cursor-not-allowed disabled:bg-gray-100 dark:border-gray-600 dark:bg-gray-800 dark:text-white dark:placeholder:text-gray-500 dark:disabled:bg-gray-900"}),I1("Location")&&X==="location"&&t.jsxs("button",{type:"button",disabled:ge,onMouseDown:ce=>ce.preventDefault(),onClick:()=>{fe(),B(null),W(!0)},className:"mt-1.5 inline-flex items-center gap-1.5 text-sm font-medium text-green-600 hover:text-green-800 disabled:cursor-not-allowed disabled:opacity-50 dark:text-green-400 dark:hover:text-green-300",children:[t.jsx(Js,{size:12}),e("locations.addLocationAction",{defaultValue:"Add location"})]})]})]})}),t.jsx(U1,{doctype:"Room",isOpen:R,onClose:()=>F(!1),onSuccess:ce=>{ce&&typeof ce.name=="string"&&S(ce.name)}}),t.jsx(U1,{doctype:"Location",isOpen:z,onClose:()=>W(!1),onSuccess:ce=>{ce&&typeof ce.name=="string"&&C(ce.name)}})]})]})};function QY(){const[e,r]=_.useState("loading");return _.useEffect(()=>{let a=!1;return me(null,null,function*(){var s;try{const i=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:"DR Approver"})})).json();if(a)return;r((s=i.message)!=null&&s.has_role?"yes":"no")}catch(n){a||r("no")}}),()=>{a=!0}},[]),e}const eq=({children:e})=>{const r=QY();return r==="loading"?t.jsx("div",{className:"flex min-h-[40vh] items-center justify-center bg-gray-50 dark:bg-gray-900",children:t.jsx(Ir,{className:"h-8 w-8 animate-spin text-blue-600","aria-hidden":!0})}):r==="no"?t.jsx(Um,{to:"/dashboard",replace:!0}):t.jsx(t.Fragment,{children:e})},tq=()=>{const e=Na(),[r,a]=_.useState(2025),[s,n]=_.useState(2030),i=_.useMemo(()=>({}),[]),{logs:c,loading:u,error:h}=Fg(i,5e3,0,"due_date asc"),g=_.useMemo(()=>{const S={};for(let A=r;A<=s;A++){S[A]={};for(let C=0;C<12;C++)S[A][C]={}}return c.forEach(A=>{if(!A.due_date)return;const[C,O]=A.due_date.split("-").map(Number),M=O-1;if(C<r||C>s||M<0||M>11)return;const R=A.custom_asset_type||"Unspecified";S[C][M][R]||(S[C][M][R]=0),S[C][M][R]+=1}),S},[c,r,s]);_.useEffect(()=>{u||(console.log("[YearlyLogsPage] Logs count:",c.length),console.log("[YearlyLogsPage] Matrix years:",r,"to",s))},[c,u,r,s]);const y=S=>{a(A=>A+S),n(A=>A+S)},w=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],E=Array.from({length:s-r+1},(S,A)=>r+A);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(Kn,{className:"text-gray-600 dark:text-gray-400",size:18})}),t.jsx($o,{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:"Yearly Maintenance Logs"}),t.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Asset Maintenance Log counts by asset type 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(uf,{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(dy,{})}),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(uy,{})})]})})}),t.jsx("div",{className:"flex-1 overflow-auto px-3 pb-3 lg:px-4 lg:pb-4",children:u?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 Maintenance Logs..."})]}):h?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 Maintenance Logs: ",h]})})}):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"}),w.map((S,A)=>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:S},A))]})}),t.jsx("tbody",{children:E.map(S=>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:S}),w.map((A,C)=>{var F;const O=((F=g[S])==null?void 0:F[C])||{},M=Object.keys(O).sort(),R=M.reduce((z,W)=>z+O[W],0);return t.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-2 py-2 align-top min-h-[60px]",children:M.length>0?t.jsxs("div",{className:"space-y-1",children:[M.map(z=>{const W=O[z],X=`${z}: ${W} log${W>1?"s":""} due in ${w[C]} ${S}`;return t.jsx("div",{onClick:()=>e(`/maintenance?asset_type=${encodeURIComponent(z)}&year=${S}&month=${C+1}`),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:X,children:t.jsxs("div",{className:"flex items-center justify-between gap-1",children:[t.jsx("span",{className:"font-medium text-blue-900 dark:text-blue-300 leading-tight group-hover:underline break-words",children:z}),t.jsx("span",{className:"flex-shrink-0 inline-flex items-center justify-center min-w-[18px] h-[18px] px-1 bg-blue-600 text-white rounded-full text-[9px] font-bold",children:W})]})},z)}),M.length>1&&t.jsxs("div",{className:"text-[9px] text-gray-500 dark:text-gray-400 text-right pt-0.5 border-t border-gray-200 dark:border-gray-700",children:["Total: ",R]})]}):t.jsx("div",{className:"text-xs text-gray-300 dark:text-gray-700 text-center py-1",children:"-"})},C)})]},S))})]})})})})]})},rq=({children:e,userEmail:r})=>{const{isRTL:a}=xb(),{mobileOpen:s,closeMobileSidebar:n}=pb();_.useEffect(()=>{const c=window.matchMedia("(min-width: 1024px)"),u=()=>{c.matches&&n()};return c.addEventListener("change",u),()=>c.removeEventListener("change",u)},[n]);const i=a?s?"translate-x-0":"translate-x-full lg:translate-x-0":s?"translate-x-0":"-translate-x-full lg:translate-x-0";return t.jsxs("div",{className:"flex h-screen overflow-hidden bg-gray-50 dark:bg-gray-900",children:[s&&t.jsx("button",{type:"button","aria-label":"Close menu",className:"fixed inset-0 z-40 bg-black/50 lg:hidden",onClick:n}),t.jsx("div",{className:["fixed top-0 z-50 h-full max-h-screen flex-shrink-0 transition-transform duration-300 ease-out","lg:static lg:z-auto lg:translate-x-0",a?"right-0 left-auto":"left-0",i].join(" "),children:t.jsx(mG,{userEmail:r})}),t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[t.jsx(vG,{userEmail:r}),t.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 dark:bg-gray-900",children:e})]})]})},Ba=({children:e})=>{const r=localStorage.getItem("user"),a=r?JSON.parse(r).email:"";return t.jsx(lG,{children:t.jsx(rq,{userEmail:a,children:e})})},Ua=({children:e})=>{const[r,a]=ea.useState(null);return _.useEffect(()=>{me(null,null,function*(){if(localStorage.getItem("user")){a(!0);return}try{const c=yield(yield fetch("/api/method/frappe.auth.get_logged_user",{credentials:"include"})).json();if(c.message&&c.message!=="Guest"){const h=yield(yield fetch(`/api/method/frappe.client.get?doctype=User&name=${encodeURIComponent(c.message)}`,{credentials:"include"})).json();if(h.message){localStorage.setItem("user",JSON.stringify(Ke(Te({},h.message),{email:c.message}))),a(!0);return}}a(!1)}catch(i){console.error("Auth check failed:",i),a(!1)}})},[]),r===null?t.jsx("div",{className:"flex items-center justify-center h-screen",children:"Loading..."}):r?t.jsx(t.Fragment,{children:e}):t.jsx(Um,{to:"/login",replace:!0})},aq=()=>t.jsx(T8,{basename:"/asm_app",children:t.jsxs(n8,{children:[t.jsx(_a,{path:"/login",element:t.jsx(W8,{})}),t.jsx(_a,{path:"/privacy-policy",element:t.jsx(fY,{})}),t.jsx(_a,{path:"/wo-feedback",element:t.jsx(_T,{})}),t.jsx(_a,{path:"/dashboard",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(OU,{})})})}),t.jsx(_a,{path:"/assets",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(vH,{})})})}),t.jsx(_a,{path:"/assets/:assetName",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(GH,{})})})}),t.jsx(_a,{path:"/work-orders",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(s$,{})})})}),t.jsx(_a,{path:"/work-orders/:workOrderName",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(d$,{})})})}),t.jsx(_a,{path:"/maintenance",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(f$,{})})})}),t.jsx(_a,{path:"/maintenance/:logName",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(_$,{})})})}),t.jsx(_a,{path:"/ppm",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(S$,{})})})}),t.jsx(_a,{path:"/ppm/:ppmName",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(C$,{})})})}),t.jsx(_a,{path:"/ppm-planner",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(I$,{})})})}),t.jsx(_a,{path:"/ppm-planner/new",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(O$,{})})})}),t.jsx(_a,{path:"/ppm-planner/:scheduleName",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(M$,{})})})}),t.jsx(_a,{path:"/maintenance-calendar",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(l4,{})})})}),t.jsx(_a,{path:"/maintenance-calendar/month-view",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(l4,{})})})}),t.jsx(_a,{path:"/yearly-ppm-planner",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(B$,{})})})}),t.jsx(_a,{path:"/yearly-logs",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(tq,{})})})}),t.jsx(_a,{path:"/active-map",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(lV,{})})})}),t.jsx(_a,{path:"/inventory",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(hV,{})})})}),t.jsx(_a,{path:"/inventory/:itemName",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(mV,{})})})}),t.jsx(_a,{path:"/users",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(EW,{})})})}),t.jsx(_a,{path:"/events",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(TW,{})})})}),t.jsx(_a,{path:"/old-dashboard",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(DT,{})})})}),t.jsx(_a,{path:"/maintenance-teams",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(LG,{})})})}),t.jsx(_a,{path:"/maintenance-teams/:teamName",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(BG,{})})})}),t.jsx(_a,{path:"/inspections",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(XG,{})})})}),t.jsx(_a,{path:"/inspections/:inspectionName",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(KG,{})})})}),t.jsx(_a,{path:"/procurement",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(iG,{title:"Procurement"})})})}),t.jsx(_a,{path:"/sla",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(nY,{})})})}),t.jsx(_a,{path:"/sla/:slaName",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(iY,{})})})}),t.jsx(_a,{path:"/support",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(EG,{})})})}),t.jsx(_a,{path:"/support/:issueName",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(DG,{})})})}),t.jsx(_a,{path:"/user-profile",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(dY,{})})})}),t.jsx(_a,{path:"/data-import",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(eq,{children:t.jsx(zY,{})})})})}),t.jsx(_a,{path:"/locations/:locationName",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(JY,{})})})}),t.jsx(_a,{path:"/locations",element:t.jsx(Ua,{children:t.jsx(Ba,{children:t.jsx(XY,{})})})}),t.jsx(_a,{path:"/",element:t.jsx(Um,{to:"/login",replace:!0})}),t.jsx(_a,{path:"*",element:t.jsx(Um,{to:"/login",replace:!0})})]})});d6.createRoot(document.getElementById("root")).render(t.jsx(_.StrictMode,{children:t.jsx(oG,{children:t.jsx(gG,{children:t.jsx(aq,{})})})}));export{am as c,J1 as g};